26#if defined (HAVE_CONFIG_H)
51#include "builtin-defun-decls.h"
76err_set_invalid (
const std::string& pname)
78 error (
"set: invalid value for %s property", pname.c_str ());
86validate_property_name (
const std::string& who,
const std::string& what,
87 const std::set<std::string>& pnames,
90 std::size_t
len = pname.length ();
91 std::set<std::string> matches;
94 for (
const auto& propnm : pnames)
98 if (
len == propnm.length ())
101 matches.insert (propnm);
105 std::size_t num_matches = matches.size ();
107 if (num_matches == 0)
108 error (
"%s: unknown %s property %s",
109 who.c_str (), what.c_str (), pname.c_str ());
110 else if (num_matches > 1)
114 std::ostringstream os;
116 sv.list_in_columns (os);
118 std::string match_list = os.str ();
120 error (
"%s: ambiguous %s property name %s; possible matches:\n\n%s",
121 who.c_str (), what.c_str (), pname.c_str (), match_list.c_str ());
126 std::string possible_match = *(matches.begin ());
129 "%s: allowing %s to match %s property %s",
130 who.c_str (), pname.c_str (), what.c_str (),
131 possible_match.c_str ());
133 return possible_match;
148 const double cmapv[] =
150 0.26700401, 0.26851048, 0.26994384,
151 0.27130489, 0.27259384, 0.27380934,
152 0.27495242, 0.27602238, 0.27701840,
153 0.27794143, 0.27879067, 0.27956550,
154 0.28026658, 0.28089358, 0.28144581,
155 0.28192358, 0.28232739, 0.28265633,
156 0.28291049, 0.28309095, 0.28319704,
157 0.28322882, 0.28318684, 0.28307200,
158 0.28288389, 0.28262297, 0.28229037,
159 0.28188676, 0.28141228, 0.28086773,
160 0.28025468, 0.27957399, 0.27882618,
161 0.27801236, 0.27713437, 0.27619376,
162 0.27519116, 0.27412802, 0.27300596,
163 0.27182812, 0.27059473, 0.26930756,
164 0.26796846, 0.26657984, 0.26514450,
165 0.26366320, 0.26213801, 0.26057103,
166 0.25896451, 0.25732244, 0.25564519,
167 0.25393498, 0.25219404, 0.25042462,
168 0.24862899, 0.24681140, 0.24497208,
169 0.24311324, 0.24123708, 0.23934575,
170 0.23744138, 0.23552606, 0.23360277,
171 0.23167350, 0.22973926, 0.22780192,
172 0.22586330, 0.22392515, 0.22198915,
173 0.22005691, 0.21812995, 0.21620971,
174 0.21429757, 0.21239477, 0.21050310,
175 0.20862342, 0.20675628, 0.20490257,
176 0.20306309, 0.20123854, 0.19942950,
177 0.19763650, 0.19585993, 0.19410009,
178 0.19235719, 0.19063135, 0.18892259,
179 0.18723083, 0.18555593, 0.18389763,
180 0.18225561, 0.18062949, 0.17901879,
181 0.17742298, 0.17584148, 0.17427363,
182 0.17271876, 0.17117615, 0.16964573,
183 0.16812641, 0.16661710, 0.16511703,
184 0.16362543, 0.16214155, 0.16066467,
185 0.15919413, 0.15772933, 0.15626973,
186 0.15481488, 0.15336445, 0.15191820,
187 0.15047605, 0.14903918, 0.14760731,
188 0.14618026, 0.14475863, 0.14334327,
189 0.14193527, 0.14053599, 0.13914708,
190 0.13777048, 0.13640850, 0.13506561,
191 0.13374299, 0.13244401, 0.13117249,
192 0.12993270, 0.12872938, 0.12756771,
193 0.12645338, 0.12539383, 0.12439474,
194 0.12346281, 0.12260562, 0.12183122,
195 0.12114807, 0.12056501, 0.12009154,
196 0.11973756, 0.11951163, 0.11942341,
197 0.11948255, 0.11969858, 0.12008079,
198 0.12063824, 0.12137972, 0.12231244,
199 0.12344358, 0.12477953, 0.12632581,
200 0.12808703, 0.13006688, 0.13226797,
201 0.13469183, 0.13733921, 0.14020991,
202 0.14330291, 0.14661640, 0.15014782,
203 0.15389405, 0.15785146, 0.16201598,
204 0.16638320, 0.17094840, 0.17570671,
205 0.18065314, 0.18578266, 0.19109018,
206 0.19657063, 0.20221902, 0.20803045,
207 0.21400015, 0.22012381, 0.22639690,
208 0.23281498, 0.23937390, 0.24606968,
209 0.25289851, 0.25985676, 0.26694127,
210 0.27414922, 0.28147681, 0.28892102,
211 0.29647899, 0.30414796, 0.31192534,
212 0.31980860, 0.32779580, 0.33588539,
213 0.34407411, 0.35235985, 0.36074053,
214 0.36921420, 0.37777892, 0.38643282,
215 0.39517408, 0.40400101, 0.41291350,
216 0.42190813, 0.43098317, 0.44013691,
217 0.44936763, 0.45867362, 0.46805314,
218 0.47750446, 0.48702580, 0.49661536,
219 0.50627130, 0.51599182, 0.52577622,
220 0.53562110, 0.54552440, 0.55548397,
221 0.56549760, 0.57556297, 0.58567772,
222 0.59583934, 0.60604528, 0.61629283,
223 0.62657923, 0.63690157, 0.64725685,
224 0.65764197, 0.66805369, 0.67848868,
225 0.68894351, 0.69941463, 0.70989842,
226 0.72039115, 0.73088902, 0.74138803,
227 0.75188414, 0.76237342, 0.77285183,
228 0.78331535, 0.79375994, 0.80418159,
229 0.81457634, 0.82494028, 0.83526959,
230 0.84556056, 0.85580960, 0.86601325,
231 0.87616824, 0.88627146, 0.89632002,
232 0.90631121, 0.91624212, 0.92610579,
233 0.93590444, 0.94563626, 0.95529972,
234 0.96489353, 0.97441665, 0.98386829,
235 0.99324789, 0.00487433, 0.00960483,
236 0.01462494, 0.01994186, 0.02556309,
237 0.03149748, 0.03775181, 0.04416723,
238 0.05034437, 0.05632444, 0.06214536,
239 0.06783587, 0.07341724, 0.07890703,
240 0.08431970, 0.08966622, 0.09495545,
241 0.10019576, 0.10539345, 0.11055307,
242 0.11567966, 0.12077701, 0.12584799,
243 0.13089477, 0.13592005, 0.14092556,
244 0.14591233, 0.15088147, 0.15583425,
245 0.16077132, 0.16569272, 0.17059884,
246 0.17549020, 0.18036684, 0.18522836,
247 0.19007447, 0.19490540, 0.19972086,
248 0.20452049, 0.20930306, 0.21406899,
249 0.21881782, 0.22354911, 0.22826210,
250 0.23295593, 0.23763078, 0.24228619,
251 0.24692170, 0.25153685, 0.25613040,
252 0.26070284, 0.26525384, 0.26978306,
253 0.27429024, 0.27877509, 0.28323662,
254 0.28767547, 0.29209154, 0.29648471,
255 0.30085494, 0.30520222, 0.30952657,
256 0.31382773, 0.31810580, 0.32236127,
257 0.32659432, 0.33080515, 0.33499400,
258 0.33916114, 0.34330688, 0.34743154,
259 0.35153548, 0.35561907, 0.35968273,
260 0.36372671, 0.36775151, 0.37175775,
261 0.37574589, 0.37971644, 0.38366989,
262 0.38760678, 0.39152762, 0.39543297,
263 0.39932336, 0.40319934, 0.40706148,
264 0.41091033, 0.41474645, 0.41857040,
265 0.42238275, 0.42618405, 0.42997486,
266 0.43375572, 0.43752720, 0.44128981,
267 0.44504410, 0.44879060, 0.45252980,
268 0.45626209, 0.45998802, 0.46370813,
269 0.46742290, 0.47113278, 0.47483821,
270 0.47853961, 0.48223740, 0.48593197,
271 0.48962370, 0.49331293, 0.49700003,
272 0.50068529, 0.50436904, 0.50805136,
273 0.51173263, 0.51541316, 0.51909319,
274 0.52277292, 0.52645254, 0.53013219,
275 0.53381201, 0.53749213, 0.54117264,
276 0.54485335, 0.54853458, 0.55221637,
277 0.55589872, 0.55958162, 0.56326503,
278 0.56694891, 0.57063316, 0.57431754,
279 0.57800205, 0.58168661, 0.58537105,
280 0.58905521, 0.59273889, 0.59642187,
281 0.60010387, 0.60378459, 0.60746388,
282 0.61114146, 0.61481702, 0.61849025,
283 0.62216081, 0.62582833, 0.62949242,
284 0.63315277, 0.63680899, 0.64046069,
285 0.64410744, 0.64774881, 0.65138436,
286 0.65501363, 0.65863619, 0.66225157,
287 0.66585927, 0.66945881, 0.67304968,
288 0.67663139, 0.68020343, 0.68376525,
289 0.68731632, 0.69085611, 0.69438405,
290 0.69789960, 0.70140222, 0.70489133,
291 0.70836635, 0.71182668, 0.71527175,
292 0.71870095, 0.72211371, 0.72550945,
293 0.72888753, 0.73224735, 0.73558828,
294 0.73890972, 0.74221104, 0.74549162,
295 0.74875084, 0.75198807, 0.75520266,
296 0.75839399, 0.76156142, 0.76470433,
297 0.76782207, 0.77091403, 0.77397953,
298 0.77701790, 0.78002855, 0.78301086,
299 0.78596419, 0.78888793, 0.79178146,
300 0.79464415, 0.79747541, 0.80027461,
301 0.80304099, 0.80577412, 0.80847343,
302 0.81113836, 0.81376835, 0.81636288,
303 0.81892143, 0.82144351, 0.82392862,
304 0.82637633, 0.82878621, 0.83115784,
305 0.83349064, 0.83578452, 0.83803918,
306 0.84025437, 0.84242990, 0.84456561,
307 0.84666139, 0.84871722, 0.85073310,
308 0.85270912, 0.85464543, 0.85654226,
309 0.85839991, 0.86021878, 0.86199932,
310 0.86374211, 0.86544779, 0.86711711,
311 0.86875092, 0.87035015, 0.87191584,
312 0.87344918, 0.87495143, 0.87642392,
313 0.87786808, 0.87928545, 0.88067763,
314 0.88204632, 0.88339329, 0.88472036,
315 0.88602943, 0.88732243, 0.88860134,
316 0.88986815, 0.89112487, 0.89237353,
317 0.89361614, 0.89485467, 0.89609127,
318 0.89732977, 0.89857040, 0.89981500,
319 0.90106534, 0.90232311, 0.90358991,
320 0.90486726, 0.90615657, 0.32941519,
321 0.33542652, 0.34137895, 0.34726862,
322 0.35309303, 0.35885256, 0.36454323,
323 0.37016418, 0.37571452, 0.38119074,
324 0.38659204, 0.39191723, 0.39716349,
325 0.40232944, 0.40741404, 0.41241521,
326 0.41733086, 0.42216032, 0.42690202,
327 0.43155375, 0.43611482, 0.44058404,
328 0.44496000, 0.44924127, 0.45342734,
329 0.45751726, 0.46150995, 0.46540474,
330 0.46920128, 0.47289909, 0.47649762,
331 0.47999675, 0.48339654, 0.48669702,
332 0.48989831, 0.49300074, 0.49600488,
333 0.49891131, 0.50172076, 0.50443413,
334 0.50705243, 0.50957678, 0.51200840,
335 0.51434870, 0.51659930, 0.51876163,
336 0.52083736, 0.52282822, 0.52473609,
337 0.52656332, 0.52831152, 0.52998273,
338 0.53157905, 0.53310261, 0.53455561,
339 0.53594093, 0.53726018, 0.53851561,
340 0.53970946, 0.54084398, 0.54192140,
341 0.54294396, 0.54391424, 0.54483444,
342 0.54570633, 0.54653200, 0.54731353,
343 0.54805291, 0.54875211, 0.54941304,
344 0.55003755, 0.55062743, 0.55118440,
345 0.55171011, 0.55220646, 0.55267486,
346 0.55311653, 0.55353282, 0.55392505,
347 0.55429441, 0.55464205, 0.55496905,
348 0.55527637, 0.55556494, 0.55583559,
349 0.55608907, 0.55632606, 0.55654717,
350 0.55675292, 0.55694377, 0.55712010,
351 0.55728221, 0.55743035, 0.55756466,
352 0.55768526, 0.55779216, 0.55788532,
353 0.55796464, 0.55803034, 0.55808199,
354 0.55811913, 0.55814141, 0.55814842,
355 0.55813967, 0.55811466, 0.55807280,
356 0.55801347, 0.55793600, 0.55783967,
357 0.55772371, 0.55758733, 0.55742968,
358 0.55725050, 0.55704861, 0.55682271,
359 0.55657181, 0.55629491, 0.55599097,
360 0.55565893, 0.55529773, 0.55490625,
361 0.55448339, 0.55402906, 0.55354108,
362 0.55301828, 0.55245948, 0.55186354,
363 0.55122927, 0.55055551, 0.54984110,
364 0.54908564, 0.54828740, 0.54744498,
365 0.54655722, 0.54562298, 0.54464114,
366 0.54361058, 0.54253043, 0.54139999,
367 0.54021751, 0.53898192, 0.53769219,
368 0.53634733, 0.53494633, 0.53348834,
369 0.53197275, 0.53039808, 0.52876343,
370 0.52706792, 0.52531069, 0.52349092,
371 0.52160791, 0.51966086, 0.51764880,
372 0.51557101, 0.51342680, 0.51121549,
373 0.50893644, 0.50658890, 0.50417217,
374 0.50168574, 0.49912906, 0.49650163,
375 0.49380294, 0.49103252, 0.48818938,
376 0.48527326, 0.48228395, 0.47922108,
377 0.47608431, 0.47287330, 0.46958774,
378 0.46622638, 0.46278934, 0.45927675,
379 0.45568838, 0.45202405, 0.44828355,
380 0.44446673, 0.44057284, 0.43660090,
381 0.43255207, 0.42842626, 0.42422341,
382 0.41994346, 0.41558638, 0.41115215,
383 0.40664011, 0.40204917, 0.39738103,
384 0.39263579, 0.38781353, 0.38291438,
385 0.37793850, 0.37288606, 0.36775726,
386 0.36255223, 0.35726893, 0.35191009,
387 0.34647607, 0.34096730, 0.33538426,
388 0.32972749, 0.32399761, 0.31819529,
389 0.31232133, 0.30637661, 0.30036211,
390 0.29427888, 0.28812650, 0.28190832,
391 0.27562602, 0.26928147, 0.26287683,
392 0.25641457, 0.24989748, 0.24332878,
393 0.23671214, 0.23005179, 0.22335258,
394 0.21662012, 0.20986086, 0.20308229,
395 0.19629307, 0.18950326, 0.18272455,
396 0.17597055, 0.16925712, 0.16260273,
397 0.15602894, 0.14956101, 0.14322828,
398 0.13706449, 0.13110864, 0.12540538,
399 0.12000532, 0.11496505, 0.11034678,
400 0.10621724, 0.10264590, 0.09970219,
401 0.09745186, 0.09595277, 0.09525046,
402 0.09537439, 0.09633538, 0.09812496,
403 0.10071680, 0.10407067, 0.10813094,
404 0.11283773, 0.11812832, 0.12394051,
405 0.13021494, 0.13689671, 0.14393620,
410 Matrix cmap (256, 3, 0.0);
411 std::copy (cmapv, cmapv + (256*3), cmap.rwdata ());
428default_screendepth ()
430 octave::display_info& dpy_info = octave::__get_display_info__ ();
432 return dpy_info.depth ();
440 octave::display_info& dpy_info = octave::__get_display_info__ ();
444 retval(2) = dpy_info.width ();
445 retval(3) = dpy_info.height ();
451default_screenpixelsperinch ()
453 octave::display_info& dpy_info = octave::__get_display_info__ ();
455 return (dpy_info.x_dpi () + dpy_info.y_dpi ()) / 2;
461 Matrix retval (7, 3, 0.0);
463 retval(0, 1) = 0.447;
464 retval(0, 2) = 0.741;
466 retval(1, 0) = 0.850;
467 retval(1, 1) = 0.325;
468 retval(1, 2) = 0.098;
470 retval(2, 0) = 0.929;
471 retval(2, 1) = 0.694;
472 retval(2, 2) = 0.125;
474 retval(3, 0) = 0.494;
475 retval(3, 1) = 0.184;
476 retval(3, 2) = 0.556;
478 retval(4, 0) = 0.466;
479 retval(4, 1) = 0.674;
480 retval(4, 2) = 0.188;
482 retval(5, 0) = 0.301;
483 retval(5, 1) = 0.745;
484 retval(5, 2) = 0.933;
486 retval(6, 0) = 0.635;
487 retval(6, 1) = 0.078;
488 retval(6, 2) = 0.184;
494default_lim (
bool logscale =
false)
531 retval(3) = -octave::numeric_limits<double>::Inf ();
537default_image_cdata ()
542 for (
int col = 0; col < 64; col++)
543 for (
int row = 0; row < 64; row++)
545 m(col, row) =
static_cast<double> (default_im_data[i]);
553default_surface_xdata ()
557 for (
int col = 0; col < 3; col++)
558 for (
int row = 0; row < 3; row++)
565default_surface_ydata ()
569 for (
int row = 0; row < 3; row++)
570 for (
int col = 0; col < 3; col++)
577default_surface_zdata ()
581 for (
int row = 0; row < 3; row++)
588default_surface_cdata ()
590 return default_surface_zdata ();
594default_patch_faces ()
606default_patch_vertices ()
618default_patch_xdata ()
628default_patch_ydata ()
638default_axes_position ()
651default_axes_outerposition ()
690default_axes_ticklength ()
701default_figure_position ()
714default_figure_papersize ()
725default_figure_paperposition ()
730 m(0) = 1.3421852580027660;
731 m(1) = 3.3191389435020748;
732 m(2) = 5.8156294839944680;
733 m(3) = 4.3617221129958503;
739default_graphics_toolkit ()
741 octave::gtk_manager& gtk_mgr = octave::__get_gtk_manager__ ();
743 return gtk_mgr.default_toolkit ();
747default_control_position ()
760default_control_sliderstep ()
771default_panel_position ()
784default_light_position ()
796default_table_position ()
809default_table_backgroundcolor ()
822make_graphics_handle (
const std::string& go_name,
824 bool integer_figure_handle =
false,
825 bool call_createfcn =
true,
826 bool notify_toolkit =
true)
828 gh_manager& gh_mgr = octave::__get_gh_manager__ ();
831 call_createfcn, notify_toolkit);
835convert_font_size (
double font_size,
const caseless_str& from_units,
840 if (from_units.
compare (to_units))
846 double points_size = 0;
849 if (from_units.
compare (
"points"))
850 points_size = font_size;
855 if (from_units.
compare (
"pixels"))
856 points_size = font_size * 72.0 / res;
857 else if (from_units.
compare (
"inches"))
858 points_size = font_size * 72.0;
859 else if (from_units.
compare (
"centimeters"))
860 points_size = font_size * 72.0 / 2.54;
861 else if (from_units.
compare (
"normalized"))
862 points_size = font_size * parent_height * 72.0 / res;
865 double new_font_size = 0;
867 if (to_units.
compare (
"points"))
868 new_font_size = points_size;
874 if (to_units.
compare (
"pixels"))
875 new_font_size = points_size * res / 72.0;
876 else if (to_units.
compare (
"inches"))
877 new_font_size = points_size / 72.0;
878 else if (to_units.
compare (
"centimeters"))
879 new_font_size = points_size * 2.54 / 72.0;
880 else if (to_units.
compare (
"normalized"))
884 if (parent_height > 0)
885 new_font_size = points_size * res / (parent_height * 72.0);
889 return new_font_size;
898 bool is_rectangle = (pos.
numel () == 4);
899 bool is_2D = (pos.
numel () == 2);
901 if (from_units.
compare (
"pixels"))
903 else if (from_units.
compare (
"normalized"))
905 retval(0) = pos(0) * parent_dim(0) + 1;
906 retval(1) = pos(1) * parent_dim(1) + 1;
909 retval(2) = pos(2) * parent_dim(0);
910 retval(3) = pos(3) * parent_dim(1);
915 else if (from_units.
compare (
"characters"))
924 f = 12.0 * res / 74.951;
928 retval(0) = 0.5 * pos(0) *
f;
929 retval(1) = pos(1) *
f;
932 retval(2) = 0.5 * pos(2) *
f;
933 retval(3) = pos(3) *
f;
946 if (from_units.
compare (
"points"))
948 else if (from_units.
compare (
"inches"))
950 else if (from_units.
compare (
"centimeters"))
955 retval(0) = pos(0) *
f + 1;
956 retval(1) = pos(1) *
f + 1;
959 retval(2) = pos(2) *
f;
960 retval(3) = pos(3) *
f;
967 if (! to_units.
compare (
"pixels"))
969 if (to_units.
compare (
"normalized"))
971 retval(0) = (retval(0) - 1) / parent_dim(0);
972 retval(1) = (retval(1) - 1) / parent_dim(1);
975 retval(2) /= parent_dim(0);
976 retval(3) /= parent_dim(1);
981 else if (to_units.
compare (
"characters"))
988 f = 12.0 * res / 74.951;
992 retval(0) = 2 * retval(0) /
f;
993 retval(1) = retval(1) /
f;
996 retval(2) = 2 * retval(2) /
f;
997 retval(3) = retval(3) /
f;
1010 if (to_units.
compare (
"points"))
1012 else if (to_units.
compare (
"inches"))
1014 else if (to_units.
compare (
"centimeters"))
1019 retval(0) = (retval(0) - 1) /
f;
1020 retval(1) = (retval(1) - 1) /
f;
1036convert_text_position (
const Matrix& pos,
const text::properties& props,
1040 gh_manager& gh_mgr = octave::__get_gh_manager__ ();
1042 graphics_object go = gh_mgr.
get_object (props.get___myhandle__ ());
1044 graphics_object ax = go.get_ancestor (
"axes");
1048 if (ax.valid_object ())
1050 const axes::properties& ax_props
1051 =
dynamic_cast<const axes::properties&
> (ax.get_properties ());
1052 graphics_xform ax_xform = ax_props.get_transform ();
1053 bool is_rectangle = (pos.
numel () == 4);
1054 Matrix ax_bbox = ax_props.get_boundingbox (
true),
1055 ax_size = ax_bbox.
extract_n (0, 2, 1, 2);
1057 if (from_units.
compare (
"data"))
1061 ColumnVector v1 = ax_xform.transform (pos(0), pos(1), 0),
1062 v2 = ax_xform.transform (pos(0) + pos(2),
1063 pos(1) + pos(3), 0);
1067 retval(0) = v1(0) - ax_bbox(0) + 1;
1068 retval(1) = ax_bbox(1) + ax_bbox(3) - v1(1) + 1;
1069 retval(2) =
v2(0) - v1(0);
1070 retval(3) = v1(1) -
v2(1);
1074 ColumnVector v = ax_xform.transform (pos(0), pos(1), pos(2));
1078 retval(0) = v(0) - ax_bbox(0) + 1;
1079 retval(1) = ax_bbox(1) + ax_bbox(3) - v(1) + 1;
1084 retval = convert_position (pos, from_units,
"pixels", ax_size);
1086 if (! to_units.
compare (
"pixels"))
1088 if (to_units.
compare (
"data"))
1093 v1 = ax_xform.untransform (retval(0) + ax_bbox(0) - 1,
1094 ax_bbox(1) + ax_bbox(3) - retval(1) + 1);
1095 v2 = ax_xform.untransform (retval(0) + retval(2) + ax_bbox(0) - 1,
1096 ax_bbox(1) + ax_bbox(3) - (retval(1) + retval(3)) + 1);
1102 retval(2) =
v2(0) - v1(0);
1103 retval(3) =
v2(1) - v1(1);
1108 v = ax_xform.untransform (retval(0) + ax_bbox(0) - 1,
1109 ax_bbox(1) + ax_bbox(3) - retval(1) + 1);
1119 retval = convert_position (retval,
"pixels", to_units, ax_size);
1128screen_size_pixels ()
1130 gh_manager& gh_mgr = octave::__get_gh_manager__ ();
1134 Matrix sz = obj.get (
"screensize").matrix_value ();
1136 return convert_position (sz, obj.get (
"units").string_value (),
"pixels",
1143 double retval = 1.0;
1145 gh_manager& gh_mgr = octave::__get_gh_manager__ ();
1147 graphics_object fig = gh_mgr.
get_object (h).get_ancestor (
"figure");
1149 if (fig.valid_object ())
1150 retval = fig.get (
"__device_pixel_ratio__").double_value ();
1156convert_cdata_2 (
bool is_scaled,
bool is_real,
double clim_0,
double clim_1,
1161 x = octave::math::fix (nc * (
x - clim_0) / (clim_1 - clim_0));
1163 x = octave::math::fix (
x - 1);
1165 if (octave::math::isnan (
x))
1181 av[i+lda] = cmapv[idx+nc];
1182 av[i+2*lda] = cmapv[idx+2*nc];
1186template <
typename T>
1193 convert_cdata_2 (is_scaled, is_real,
1194 clim_0, clim_1, cmapv, cv[i], lda, nc, i, av);
1198convert_cdata (
const base_properties& props,
const octave_value& cdata,
1199 bool is_scaled,
int cdim)
1204 if (dv.ndims () == cdim && dv(cdim-1) == 3)
1210 gh_manager& gh_mgr = octave::__get_gh_manager__ ();
1212 graphics_object go = gh_mgr.
get_object (props.get___myhandle__ ());
1213 graphics_object ax = go.get_ancestor (
"axes");
1215 if (ax.valid_object ())
1237 double *av = a.rwdata ();
1238 const double *cmapv = cmap.data ();
1240 double clim_0 = clim(0);
1241 double clim_1 = clim(1);
1251#define CONVERT_CDATA_1(ARRAY_T, VAL_FN, IS_REAL) \
1254 ARRAY_T tmp = cdata. VAL_FN ## array_value (); \
1256 convert_cdata_1 (is_scaled, IS_REAL, clim_0, clim_1, cmapv, \
1257 tmp.data (), lda, nc, av); \
1286 warning (
"unsupported type for cdata (= %s). "
1287 "Valid types are int8, int16, int32, int64, uint8, uint16, "
1288 "uint32, uint64, double, single, and bool.",
1293#undef CONVERT_CDATA_1
1298template <
typename T>
1300get_array_limits (
const Array<T>& m,
double& emin,
double& emax,
1301 double& eminp,
double& emaxp)
1303 const T *data = m.
data ();
1308 double e =
double (data[i]);
1311 if (! octave::math::isinf (e))
1319 if (e > 0 && e < eminp)
1322 if (e < 0 && e > emaxp)
1332 int len = name.length ();
1334 bool result =
false;
1345 pfx = name.substr (0, 5);
1351 pfx = name.substr (0, 6);
1357 pfx = name.substr (0, 7);
1365 pfx = name.substr (0, 9);
1372 pfx = name.substr (0, 10);
1374 if (pfx.
compare (
"uipushtool"))
1378 pfx = name.substr (0, 12);
1380 if (pfx.
compare (
"uitoggletool"))
1384 pfx = name.substr (0, 13);
1386 if (pfx.
compare (
"uicontextmenu")
1387 || pfx.
compare (
"uibuttongroup"))
1400 rest = name.substr (offset);
1408base_graphics_object *
1413 base_graphics_object *go =
nullptr;
1416 go =
new figure (h, p);
1417 else if (type.
compare (
"axes"))
1418 go =
new axes (h, p);
1419 else if (type.
compare (
"line"))
1420 go =
new line (h, p);
1421 else if (type.
compare (
"text"))
1422 go =
new text (h, p);
1423 else if (type.
compare (
"image"))
1424 go =
new image (h, p);
1425 else if (type.
compare (
"light"))
1426 go =
new light (h, p);
1427 else if (type.
compare (
"patch"))
1428 go =
new patch (h, p);
1429 else if (type.
compare (
"scatter"))
1430 go =
new scatter (h, p);
1431 else if (type.
compare (
"surface"))
1432 go =
new surface (h, p);
1433 else if (type.
compare (
"hggroup"))
1434 go =
new hggroup (h, p);
1435 else if (type.
compare (
"uimenu"))
1436 go =
new uimenu (h, p);
1437 else if (type.
compare (
"uicontrol"))
1438 go =
new uicontrol (h, p);
1439 else if (type.
compare (
"uipanel"))
1440 go =
new uipanel (h, p);
1441 else if (type.
compare (
"uibuttongroup"))
1442 go =
new uibuttongroup (h, p);
1443 else if (type.
compare (
"uicontextmenu"))
1444 go =
new uicontextmenu (h, p);
1445 else if (type.
compare (
"uitable"))
1446 go =
new uitable (h, p);
1447 else if (type.
compare (
"uitoolbar"))
1448 go =
new uitoolbar (h, p);
1449 else if (type.
compare (
"uipushtool"))
1450 go =
new uipushtool (h, p);
1451 else if (type.
compare (
"uitoggletool"))
1452 go =
new uitoggletool (h, p);
1459base_property::set (
const octave_value& v,
bool do_run,
bool do_notify_toolkit)
1464 if (m_id >= 0 && do_notify_toolkit)
1466 gh_manager& gh_mgr = octave::__get_gh_manager__ ();
1468 graphics_object go = gh_mgr.
get_object (m_parent);
1475 run_listeners (GCB_POSTSET);
1484base_property::run_listeners (listener_mode mode)
1488 gh_manager& gh_mgr = octave::__get_gh_manager__ ();
1490 for (
int i = 0; i < l.
length (); i++)
1494radio_values::radio_values (
const std::string& opt_string)
1495 : m_default_val (), m_possible_vals ()
1497 std::size_t beg = 0;
1498 std::size_t
len = opt_string.length ();
1499 bool done =
len == 0;
1503 std::size_t end = opt_string.find (
'|', beg);
1505 if (end == std::string::npos)
1511 std::string t = opt_string.substr (beg, end-beg);
1514 if (t.empty () && opt_string[beg] ==
'|')
1523 t = t.substr (1, t.length () - 2);
1529 m_possible_vals.insert (t);
1536radio_values::values_as_string ()
const
1540 for (
const auto& val : m_possible_vals)
1542 if (retval.empty ())
1544 if (val == default_value ())
1545 retval =
'{' + val +
'}';
1551 if (val == default_value ())
1552 retval +=
" | {" + val +
'}';
1554 retval +=
" | " + val;
1558 if (! retval.empty ())
1559 retval =
"[ " + retval +
" ]";
1565radio_values::values_as_cell ()
const
1568 Cell retval (nelem (), 1);
1570 for (
const auto& val : m_possible_vals)
1571 retval(i++) = std::string (val);
1577color_values::str2rgb (
const std::string& str_arg)
1581 double tmp_rgb[3] = {0, 0, 0};
1583 std::string str = str_arg;
1584 unsigned int len = str.length ();
1586 std::transform (str.begin (), str.end (), str.begin (), tolower);
1589 if (str.compare (0,
len,
"blue", 0,
len) == 0)
1591 else if (str.compare (0,
len,
"black", 0,
len) == 0
1592 || str.compare (0,
len,
"k", 0,
len) == 0)
1593 tmp_rgb[0] = tmp_rgb[1] = tmp_rgb[2] = 0;
1594 else if (str.compare (0,
len,
"red", 0,
len) == 0)
1596 else if (str.compare (0,
len,
"green", 0,
len) == 0)
1598 else if (str.compare (0,
len,
"yellow", 0,
len) == 0)
1599 tmp_rgb[0] = tmp_rgb[1] = 1;
1600 else if (str.compare (0,
len,
"magenta", 0,
len) == 0)
1601 tmp_rgb[0] = tmp_rgb[2] = 1;
1602 else if (str.compare (0,
len,
"cyan", 0,
len) == 0)
1603 tmp_rgb[1] = tmp_rgb[2] = 1;
1604 else if (str.compare (0,
len,
"white", 0,
len) == 0
1605 || str.compare (0,
len,
"w", 0,
len) == 0)
1606 tmp_rgb[0] = tmp_rgb[1] = tmp_rgb[2] = 1;
1607 else if (str[0] ==
'#' &&
len == 7)
1611 tmp_rgb[0] =
static_cast<double> (stoi (str.substr (1, 2),
nullptr, 16))
1613 tmp_rgb[1] =
static_cast<double> (stoi (str.substr (3, 2),
nullptr, 16))
1615 tmp_rgb[2] =
static_cast<double> (stoi (str.substr (5, 2),
nullptr, 16))
1618 catch (
const octave::execution_exception&)
1622 catch (
const std::invalid_argument&)
1628 else if (str[0] ==
'#' &&
len == 4)
1632 tmp_rgb[0] =
static_cast<double> (stoi (str.substr (1, 1),
nullptr, 16))
1634 tmp_rgb[1] =
static_cast<double> (stoi (str.substr (2, 1),
nullptr, 16))
1636 tmp_rgb[2] =
static_cast<double> (stoi (str.substr (3, 1),
nullptr, 16))
1639 catch (
const octave::execution_exception&)
1643 catch (
const std::invalid_argument&)
1653 for (
int i = 0; i < 3; i++)
1654 m_rgb(i) = tmp_rgb[i];
1668 error (R
"(invalid value for color property "%s")",
1669 get_name ().c_str ());
1673 if (m_radio_val.contains (s, match))
1675 if (m_current_type != radio_t || match != m_current_val)
1677 if (s.length () != match.length ())
1679 "%s: allowing %s to match %s value %s",
1680 "set", s.c_str (), get_name ().c_str (),
1682 m_current_val = match;
1683 m_current_type = radio_t;
1691 color_values col (s);
1693 if (m_current_type != color_t || col != m_color_val)
1696 m_current_type = color_t;
1700 catch (octave::execution_exception& ee)
1702 error (ee, R
"(invalid value for color property "%s" (value = %s))",
1703 get_name ().c_str (), s.c_str ());
1711 if (m.
numel () != 3)
1712 error (R
"(invalid value for color property "%s")",
1713 get_name ().c_str ());
1715 color_values col (m(0), m(1), m(2));
1717 if (m_current_type != color_t || col != m_color_val)
1720 m_current_type = color_t;
1725 error (R
"(invalid value for color property "%s")",
1726 get_name ().c_str ());
1739 if (s.empty () || ! m_radio_val.contains (s, match))
1740 error (R
"(invalid value for double_radio property "%s")",
1741 get_name ().c_str ());
1743 if (m_current_type != radio_t || match != m_current_val)
1745 if (s.length () != match.length ())
1747 "%s: allowing %s to match %s value %s",
1748 "set", s.c_str (), get_name ().c_str (),
1750 m_current_val = match;
1751 m_current_type = radio_t;
1759 if (m_current_type != double_t || new_dval != m_dval)
1762 m_current_type = double_t;
1767 error (R
"(invalid value for double_radio property "%s")",
1768 get_name ().c_str ());
1779 if (m_type_constraints.size () > 0)
1781 if (m_type_constraints.find (v.
class_name ()) != m_type_constraints.end ())
1786 if (m_type_constraints.find (
"real") != m_type_constraints.end ()
1793 if (xok && m_size_constraints.size () > 0)
1796 int vlen = vdims.
ndims ();
1801 for (
auto it = m_size_constraints.cbegin ();
1802 ! xok && it != m_size_constraints.cend ();
1807 if (itdims.
ndims () == vlen)
1811 for (
int i = 0; xok && i < vlen; i++)
1815 if (itdims(i) != vdims(i))
1818 else if (itdims(i) == 0)
1833 if (! octave::math::isnan (m_minval.first))
1836 if (m_minval.second && m_minval.first > v_mat(i))
1837 error (R
"(set: "%s" must be greater than or equal to %g)",
1838 get_name ().c_str (), m_minval.first);
1839 else if (! m_minval.second && m_minval.first >= v_mat(i))
1840 error (R
"(set: "%s" must be greater than %g)",
1841 get_name ().c_str (), m_minval.first);
1844 if (! octave::math::isnan (m_maxval.first))
1847 if (m_maxval.second && m_maxval.first < v_mat(i))
1848 error (R
"(set: "%s" must be less than or equal to %g)",
1849 get_name ().c_str (), m_maxval.first);
1850 else if (! m_maxval.second && m_maxval.first <= v_mat(i))
1851 error (R
"(set: "%s" must be less than %g)",
1852 get_name ().c_str (), m_maxval.first);
1855 if (m_finite_constraint == NO_CHECK) { }
1856 else if (m_finite_constraint == FINITE)
1859 if (! octave::math::isfinite (v_mat(i)))
1860 error (R
"(set: "%s" must be finite)", get_name ().c_str ());
1862 else if (m_finite_constraint == NOT_NAN)
1865 if (octave::math::isnan (v_mat(i)))
1866 error (R
"(set: "%s" must not be NaN)", get_name ().c_str ());
1868 else if (m_finite_constraint == NOT_INF)
1871 if (octave::math::isinf (v_mat(i)))
1872 error (R
"(set: "%s" must not be infinite)", get_name ().c_str ());
1883 if (m_data.type_name () == v.
type_name ())
1885 if (m_data.dims () == v.
dims ())
1888#define CHECK_ARRAY_EQUAL(T, F, A) \
1890 if (m_data.numel () == 1) \
1891 return m_data.F ## scalar_value () == \
1892 v.F ## scalar_value (); \
1898 const A m1 = m_data.F ## array_value (); \
1899 const T *d1 = m1.data (); \
1900 const A m2 = v.F ## array_value (); \
1901 const T *d2 = m2.data (); \
1905 for (int i = 0; flag && i < m_data.numel (); i++) \
1906 if (d1[i] != d2[i]) \
1913 if (m_data.is_double_type () || m_data.islogical ())
1915 else if (m_data.is_single_type ())
1917 else if (m_data.is_int8_type ())
1919 else if (m_data.is_int16_type ())
1921 else if (m_data.is_int32_type ())
1923 else if (m_data.is_int64_type ())
1925 else if (m_data.is_uint8_type ())
1927 else if (m_data.is_uint16_type ())
1929 else if (m_data.is_uint32_type ())
1931 else if (m_data.is_uint64_type ())
1940array_property::get_data_limits ()
1942 m_min_val = m_min_pos = octave::numeric_limits<double>::Inf ();
1943 m_max_val = m_max_neg = -octave::numeric_limits<double>::Inf ();
1945 if (! m_data.isempty ())
1947 if (m_data.isinteger ())
1949 if (m_data.is_int8_type ())
1950 get_array_limits (m_data.int8_array_value (),
1951 m_min_val, m_max_val, m_min_pos, m_max_neg);
1952 else if (m_data.is_uint8_type ())
1953 get_array_limits (m_data.uint8_array_value (),
1954 m_min_val, m_max_val, m_min_pos, m_max_neg);
1955 else if (m_data.is_int16_type ())
1956 get_array_limits (m_data.int16_array_value (),
1957 m_min_val, m_max_val, m_min_pos, m_max_neg);
1958 else if (m_data.is_uint16_type ())
1959 get_array_limits (m_data.uint16_array_value (),
1960 m_min_val, m_max_val, m_min_pos, m_max_neg);
1961 else if (m_data.is_int32_type ())
1962 get_array_limits (m_data.int32_array_value (),
1963 m_min_val, m_max_val, m_min_pos, m_max_neg);
1964 else if (m_data.is_uint32_type ())
1965 get_array_limits (m_data.uint32_array_value (),
1966 m_min_val, m_max_val, m_min_pos, m_max_neg);
1967 else if (m_data.is_int64_type ())
1968 get_array_limits (m_data.int64_array_value (),
1969 m_min_val, m_max_val, m_min_pos, m_max_neg);
1970 else if (m_data.is_uint64_type ())
1971 get_array_limits (m_data.uint64_array_value (),
1972 m_min_val, m_max_val, m_min_pos, m_max_neg);
1975 get_array_limits (m_data.array_value (),
1976 m_min_val, m_max_val, m_min_pos, m_max_neg);
1986 if (! get ().isempty ())
1995 double dv = v.
xdouble_value (R
"(set: invalid graphics handle for property "%s")",
1996 get_name ().c_str ());
1998 gh_manager& gh_mgr = octave::__get_gh_manager__ ();
2003 bool type_ok =
true;
2004 if (gh.
ok () && ! m_type_constraints.empty ())
2007 graphics_object obj = gh_mgr.
get_object (gh);
2009 for (
const auto& type : m_type_constraints)
2017 if (! octave::math::isnan (gh.
value ()) && ! (gh.
ok () && type_ok))
2020 error (R
"(set: invalid graphics handle (= %g) for property "%s")",
2021 dv, get_name ().c_str ());
2023 error (R
"(set: invalid graphics object type for property "%s")",
2024 get_name ().c_str ());
2027 if (m_current_val != gh)
2055children_property::do_get_children (
bool return_hidden)
const
2057 Matrix retval (m_children_list.size (), 1);
2060 gh_manager& gh_mgr = octave::__get_gh_manager__ ();
2064 root_figure::properties& props
2065 =
dynamic_cast<root_figure::properties&
> (go.get_properties ());
2067 if (! props.is_showhiddenhandles ())
2069 for (
const auto& hchild : m_children_list)
2075 if (! return_hidden)
2076 retval(k++) = hchild;
2078 else if (return_hidden)
2079 retval(k++) = hchild;
2082 retval.resize (k, 1);
2086 for (
const auto& hchild : m_children_list)
2087 retval(k++) = hchild;
2091 if (retval.isempty ())
2092 retval.resize (0,0);
2098children_property::do_delete_children (
bool clear,
bool from_root)
2100 gh_manager& gh_mgr = octave::__get_gh_manager__ ();
2106 graphics_object go = gh_mgr.
get_object (hchild);
2107 if (go.valid_object ()
2108 && ! go.get_properties ().is_beingdeleted ())
2109 gh_mgr.
free (hchild, from_root);
2111 m_children_list.clear ();
2114 while (! m_children_list.empty ())
2118 graphics_object go = gh_mgr.
get_object (hchild);
2119 if (go.valid_object ()
2120 && ! go.get_properties ().is_beingdeleted ())
2121 gh_mgr.
free (hchild, from_root);
2126 m_children_list.clear ();
2130callback_property::validate (
const octave_value& v)
const
2156 callback_props () : m_set () { }
2158 OCTAVE_DISABLE_COPY_MOVE (callback_props)
2160 ~callback_props () =
default;
2162 bool empty ()
const {
return m_set.empty (); }
2164 void insert (
const callback_property *ptr)
2166 m_set.insert (
reinterpret_cast<intptr_t
> (ptr));
2169 void erase (
const callback_property *ptr)
2171 m_set.erase (
reinterpret_cast<intptr_t
> (ptr));
2174 bool contains (
const callback_property *ptr)
const
2176 return m_set.find (
reinterpret_cast<intptr_t
> (ptr)) != m_set.end ();
2181 std::set<intptr_t> m_set;
2188static callback_props executing_callbacks;
2191callback_property::execute (
const octave_value& data)
const
2196 octave::unwind_action executing_callbacks_cleanup
2197 ([
this] () { executing_callbacks.erase (
this); });
2199 if (! executing_callbacks.contains (
this))
2201 executing_callbacks.insert (
this);
2203 if (m_callback.is_defined () && ! m_callback.isempty ())
2205 gh_manager& gh_mgr = octave::__get_gh_manager__ ();
2214static std::map<caseless_str, graphics_object> dprop_obj_map;
2224 std::string sv = (args.
length () > 0 ? args(0).string_value () :
"");
2226 retval = property (
new string_property (name, h, sv));
2228 else if (type.
compare (
"any"))
2233 retval = property (
new any_property (name, h, ov));
2235 else if (type.
compare (
"radio"))
2238 error (
"addproperty: missing possible values for radio property");
2240 std::string sv = args(0).xstring_value (
"addproperty: argument for radio property must be a string");
2242 retval = property (
new radio_property (name, h, sv));
2245 retval.set (args(1));
2247 else if (type.
compare (
"double"))
2249 double dv = (args.
length () > 0 ? args(0).double_value () : 0.0);
2251 retval = property (
new double_property (name, h, dv));
2253 else if (type.
compare (
"handle"))
2255 double hv = (args.
length () > 0 ? args(0).double_value ()
2256 : octave::numeric_limits<double>::NaN ());
2260 retval = property (
new handle_property (name, h, gh));
2262 else if (type.
compare (
"boolean"))
2264 retval = property (
new bool_property (name, h,
false));
2267 retval.set (args(0));
2269 else if (type.
compare (
"data"))
2271 retval = property (
new array_property (name, h,
Matrix ()));
2275 retval.set (args(0));
2280 else if (type.
compare (
"color"))
2282 color_values cv (0, 0, 0);
2286 rv = radio_values (args(1).string_value ());
2288 retval = property (
new color_property (name, h, cv, rv));
2290 if (args.
length () > 0 && ! args(0).isempty ())
2291 retval.set (args(0));
2293 retval.set (rv.default_value ());
2299 if (! lookup_object_name (type, go_name, go_rest))
2300 error (
"addproperty: unsupported type for dynamic property (= %s)",
2305 std::map<caseless_str, graphics_object>::const_iterator it
2306 = dprop_obj_map.find (go_name);
2308 if (it == dprop_obj_map.end ())
2314 go = graphics_object (bgo);
2316 dprop_obj_map[go_name] = go;
2322 if (! go.valid_object ())
2323 error (
"addproperty: invalid object type (= %s)",
2326 property prop = go.get_properties ().get_property (go_rest);
2328 retval = prop.clone ();
2330 retval.set_parent (h);
2331 retval.set_name (name);
2334 retval.set (args(0));
2343 gh_manager& gh_mgr = octave::__get_gh_manager__ ();
2349 Matrix children = go.get_properties ().get_all_children ();
2351 for (
int k = 0; k < children.
numel (); k++)
2352 finalize_r (children(k));
2361 gh_manager& gh_mgr = octave::__get_gh_manager__ ();
2367 Matrix children = go.get_properties ().get_all_children ();
2371 for (
int k = 0; k < children.
numel (); k++)
2372 initialize_r (children(k));
2377figure::properties::set_toolkit (
const octave::graphics_toolkit& b)
2380 finalize_r (get___myhandle__ ());
2383 m___graphics_toolkit__ = b.get_name ();
2384 m___plot_stream__ =
Matrix ();
2387 initialize_r (get___myhandle__ ());
2393figure::properties::set___mouse_mode__ (
const octave_value& val_arg)
2395 std::string direction =
"in";
2403 if (modestr ==
"zoom in")
2405 val = modestr =
"zoom";
2408 else if (modestr ==
"zoom out")
2410 val = modestr =
"zoom";
2414 if (m___mouse_mode__.set (val,
true))
2416 std::string mode = m___mouse_mode__.current_value ();
2419 pm.
setfield (
"Enable", mode ==
"pan" ?
"on" :
"off");
2420 set___pan_mode__ (pm);
2423 rm.
setfield (
"Enable", mode ==
"rotate" ?
"on" :
"off");
2424 set___rotate_mode__ (rm);
2427 zm.
setfield (
"Enable", mode ==
"zoom" ?
"on" :
"off");
2428 zm.
setfield (
"Direction", direction);
2429 set___zoom_mode__ (zm);
2433 else if (modestr ==
"zoom")
2436 std::string curr_direction
2439 if (direction != curr_direction)
2441 zm.
setfield (
"Direction", direction);
2442 set___zoom_mode__ (zm);
2451figure::properties::update_handlevisibility ()
2453 if (! is_handle_visible ())
2455 gh_manager& gh_mgr = octave::__get_gh_manager__ ();
2470 gh_mgr.
get_object (0).set (
"currentfigure", kidsarray(0));
2475 base_properties::update_handlevisibility ();
2481 gh_manager& gh_mgr = octave::__get_gh_manager__ ();
2485 if (go.isa (
"text"))
2487 text::properties& tp
2488 =
dynamic_cast<text::properties&
> (go.get_properties ());
2490 tp.update_text_extent ();
2492 else if (go.isa (
"figure") || go.isa (
"uipanel") || go.isa (
"axes")
2493 || go.isa (
"hggroup"))
2495 Matrix ch = go.get_properties ().get_all_children ();
2499 if (go.isa (
"axes"))
2501 axes::properties& ap
2502 =
dynamic_cast<axes::properties&
> (go.get_properties ());
2504 ap.sync_positions ();
2510figure::properties::update___device_pixel_ratio__ ()
2512 update_text_pos (get___myhandle__ ());
2520 std::size_t offset = 0;
2522 std::size_t
len = name.length ();
2533 pfx = name.substr (0, 5);
2539 pfx = name.substr (0, 6);
2545 pfx = name.substr (0, 7);
2553 pfx = name.substr (0, 9);
2560 pfx = name.substr (0, 10);
2562 if (pfx.
compare (
"uipushtool"))
2566 pfx = name.substr (0, 12);
2568 if (pfx.
compare (
"uitoogletool"))
2572 pfx = name.substr (0, 13);
2574 if (pfx.
compare (
"uicontextmenu")
2575 || pfx.
compare (
"uibuttongroup"))
2589 std::string pname = name.substr (offset);
2591 std::transform (pfx.begin (), pfx.end (), pfx.begin (), tolower);
2592 std::transform (pname.begin (), pname.end (), pname.begin (),
2595 bool has_property =
false;
2597 has_property = axes::properties::has_core_property (pname);
2598 else if (pfx ==
"figure")
2599 has_property = figure::properties::has_core_property (pname);
2600 else if (pfx ==
"line")
2601 has_property = line::properties::has_core_property (pname);
2602 else if (pfx ==
"text")
2603 has_property = text::properties::has_core_property (pname);
2604 else if (pfx ==
"image")
2605 has_property = image::properties::has_core_property (pname);
2606 else if (pfx ==
"patch")
2607 has_property = patch::properties::has_core_property (pname);
2608 else if (pfx ==
"scatter")
2609 has_property = scatter::properties::has_core_property (pname);
2610 else if (pfx ==
"surface")
2611 has_property = surface::properties::has_core_property (pname);
2612 else if (pfx ==
"hggroup")
2613 has_property = hggroup::properties::has_core_property (pname);
2614 else if (pfx ==
"uimenu")
2615 has_property = uimenu::properties::has_core_property (pname);
2616 else if (pfx ==
"uicontrol")
2617 has_property = uicontrol::properties::has_core_property (pname);
2618 else if (pfx ==
"uibuttongroup")
2619 has_property = uibuttongroup::properties::has_core_property (pname);
2620 else if (pfx ==
"uipanel")
2621 has_property = uipanel::properties::has_core_property (pname);
2622 else if (pfx ==
"uicontextmenu")
2623 has_property = uicontextmenu::properties::has_core_property (pname);
2624 else if (pfx ==
"uitable")
2625 has_property = uitable::properties::has_core_property (pname);
2626 else if (pfx ==
"uitoolbar")
2627 has_property = uitoolbar::properties::has_core_property (pname);
2628 else if (pfx ==
"uipushtool")
2629 has_property = uipushtool::properties::has_core_property (pname);
2632 error (
"invalid %s property '%s'", pfx.c_str (), pname.c_str ());
2634 bool remove =
false;
2639 remove = (sval ==
"remove");
2642 pval_map_type& pval_map = m_plist_map[pfx];
2646 auto p = pval_map.find (pname);
2648 if (p != pval_map.end ())
2652 pval_map[pname] = val;
2657 error (
"invalid default property specification");
2665 std::size_t offset = 0;
2667 std::size_t
len = name.length ();
2678 pfx = name.substr (0, 5);
2684 pfx = name.substr (0, 6);
2690 pfx = name.substr (0, 7);
2698 pfx = name.substr (0, 9);
2705 pfx = name.substr (0, 10);
2707 if (pfx.
compare (
"uipushtool"))
2711 pfx = name.substr (0, 12);
2713 if (pfx.
compare (
"uitoggletool"))
2717 pfx = name.substr (0, 13);
2719 if (pfx.
compare (
"uicontextmenu")
2720 || pfx.
compare (
"uibuttongroup"))
2732 std::string pname = name.substr (offset);
2734 std::transform (pfx.begin (), pfx.end (), pfx.begin (), tolower);
2735 std::transform (pname.begin (), pname.end (), pname.begin (),
2738 plist_map_const_iterator p = find (pfx);
2742 const pval_map_type& pval_map = p->second;
2744 pval_map_const_iterator q = pval_map.find (pname);
2746 if (q != pval_map.end ())
2756property_list::as_struct (
const std::string& prefix_arg)
const
2760 for (
const auto& p : *this)
2762 std::string prefix = prefix_arg + p.first;
2764 for (
const auto& prop_val : p.second)
2765 m.assign (prefix + prop_val.first, prop_val.second);
2776 int nargin = args.
length ();
2779 error (
"graphics_object::set: Nothing to set");
2781 for (
int i = 0; i < nargin; )
2783 if (args(i).isstruct ())
2785 set (args(i).map_value ());
2788 else if (i < nargin - 1)
2790 caseless_str pname = args(i).xstring_value (
"set: argument %d must be a property name", i);
2792 set_value_or_default (pname, val);
2796 error (
"set: invalid number of arguments");
2819 error (
"set: number of names must match number of value columns "
2820 "(%" OCTAVE_IDX_TYPE_FORMAT
" != %" OCTAVE_IDX_TYPE_FORMAT
")",
2830 set_value_or_default (pname, val);
2892 set_value_or_default (pname, val);
2945graphics_object::set_value_or_default (
const caseless_str& pname,
2954 if (sval ==
"default")
2956 default_val = get_default (pname);
2958 m_rep->set (pname, default_val);
2960 else if (sval ==
"factory")
2962 default_val = get_factory_default (pname);
2964 m_rep->set (pname, default_val);
2969 if (sval == R
"(\default)")
2970 m_rep->set (pname, "default");
2971 else if (sval == R
"(\factory)")
2972 m_rep->set (pname, "factory");
2974 m_rep->set (pname, val);
2978 m_rep->set (pname, val);
3005 return val.
isempty () ? octave::numeric_limits<double>::NaN ()
3015 return val.
isempty () ? octave::numeric_limits<double>::NaN ()
3022 gh_manager& gh_mgr = octave::__get_gh_manager__ ();
3024 graphics_object parent_go = gh_mgr.
get_object (parent_h);
3026 parent_go.adopt (h);
3036ishghandle (
double val)
3038 gh_manager& gh_mgr = octave::__get_gh_manager__ ();
3059 result.xelem (i) = ishghandle (handles(i));
3070 gh_manager& gh_mgr = octave::__get_gh_manager__ ();
3074 go.get_properties ().execute_createfcn ();
3080 gh_manager& gh_mgr = octave::__get_gh_manager__ ();
3091toggle_warn (std::string
id,
bool on,
int state = -1)
3095 state = octave::warning_enabled (
id);
3096 octave::disable_warning (
id);
3101 octave::set_warning_state (
id,
"on");
3102 else if (state == 2)
3103 octave::set_warning_state (
id,
"error");
3110 property_list::pval_map_type factory_pval)
3112 gh_manager& gh_mgr = octave::__get_gh_manager__ ();
3117 std::string go_name = go.get_properties ().graphics_object_name ();
3118 property_list::pval_map_type pval;
3119 go.build_user_defaults_map (pval, go_name);
3121 for (
const auto& p : pval)
3122 factory_pval[p.first] = p.second;
3125 int state = toggle_warn (
"Octave:deprecated-property",
false);
3128 for (
const auto& p : factory_pval)
3130 std::string pname = p.first;
3133 if (! go.has_readonly_property (pname)
3134 && pname.find (
"__") != 0 && pname.find (
"current") != 0
3135 && pname !=
"uicontextmenu" && pname !=
"parent")
3138 if (pname.find (
"mode") == (pname.length () - 4))
3139 pval[pname] = p.second;
3141 go.set (pname, p.second);
3146 for (
const auto& p : pval)
3147 go.set (p.first, p.second);
3149 toggle_warn (
"Octave:deprecated-property",
true, state);
3155base_properties::set_from_list (base_graphics_object& bgo,
3156 property_list& defaults)
3158 std::string go_name = graphics_object_name ();
3160 property_list::plist_map_const_iterator plist = defaults.find (go_name);
3162 if (plist != defaults.end ())
3164 const property_list::pval_map_type pval_map = plist->second;
3166 for (
const auto& prop_val : pval_map)
3168 std::string pname = prop_val.first;
3172 bgo.set (pname, prop_val.second);
3174 catch (octave::execution_exception& ee)
3176 error (ee,
"error setting default property %s", pname.c_str ());
3199base_properties::get_dynamic (
const caseless_str& pname)
const
3201 std::map<caseless_str, property, cmp_caseless_str>::const_iterator it
3202 = m_all_props.find (pname);
3204 if (it == m_all_props.end ())
3205 error (R
"(get: unknown property "%s")", pname.c_str ());
3207 return it->second.get ();
3211base_properties::get_dynamic (
bool all)
const
3215 for (
const auto& it : m_all_props)
3216 if (all || ! it.second.is_hidden ())
3217 m.assign (it.second.get_name (), it.second.get ());
3222std::set<std::string>
3223base_properties::dynamic_property_names ()
const
3225 return m_dynamic_properties;
3229base_properties::has_dynamic_property (
const std::string& pname)
const
3231 const std::set<std::string>& dynprops = dynamic_property_names ();
3233 if (dynprops.find (pname) != dynprops.end ())
3236 return m_all_props.find (pname) != m_all_props.end ();
3240base_properties::set_dynamic (
const caseless_str& pname,
3243 auto it = m_all_props.find (pname);
3245 if (it == m_all_props.end ())
3246 error (R
"(set: unknown property "%s")", pname.c_str ());
3248 it->second.set (val);
3250 m_dynamic_properties.insert (pname);
3256base_properties::get_property_dynamic (
const caseless_str& pname)
const
3258 std::map<caseless_str, property, cmp_caseless_str>::const_iterator it
3259 = m_all_props.find (pname);
3261 if (it == m_all_props.end ())
3262 error (R
"(get_property: unknown property "%s")", pname.c_str ());
3270 double hp = val.
xdouble_value (
"set: parent must be a graphics handle");
3271 if (hp == m___myhandle__)
3272 error (
"set: can not set object parent to be object itself");
3274 gh_manager& gh_mgr = octave::__get_gh_manager__ ();
3277 if (! new_parent.
ok ())
3278 error (
"set: invalid graphics handle (= %g) for parent", hp);
3281 graphics_object old_parent_go;
3282 old_parent_go = gh_mgr.
get_object (get_parent ());
3284 if (old_parent_go.get_handle () != hp)
3285 old_parent_go.remove_child (m___myhandle__);
3290 graphics_object new_parent_go;
3291 new_parent_go = gh_mgr.
get_object (new_parent);
3292 if (new_parent_go.get_parent () == m___myhandle__)
3295 new_parent_go.get_properties ().set_parent (get_parent ().as_octave_value ());
3300 octave::adopt (m_parent.handle_value (), m___myhandle__);
3316base_properties::mark_modified ()
3319 m___modified__ =
"on";
3323 gh_manager& gh_mgr = octave::__get_gh_manager__ ();
3325 graphics_object parent_go = gh_mgr.
get_object (get_parent ());
3328 parent_go.mark_modified ();
3332base_properties::override_defaults (base_graphics_object& obj)
3334 gh_manager& gh_mgr = octave::__get_gh_manager__ ();
3336 graphics_object parent_go = gh_mgr.
get_object (get_parent ());
3339 parent_go.override_defaults (obj);
3343base_properties::update_axis_limits (
const std::string& axis_type)
const
3345 gh_manager& gh_mgr = octave::__get_gh_manager__ ();
3347 graphics_object go = gh_mgr.
get_object (m___myhandle__);
3350 go.update_axis_limits (axis_type);
3354base_properties::update_axis_limits (
const std::string& axis_type,
3357 gh_manager& gh_mgr = octave::__get_gh_manager__ ();
3359 graphics_object go = gh_mgr.
get_object (m___myhandle__);
3362 go.update_axis_limits (axis_type, h);
3366base_properties::update_contextmenu ()
const
3368 if (m_contextmenu.get ().isempty ())
3371 gh_manager& gh_mgr = octave::__get_gh_manager__ ();
3373 graphics_object go = gh_mgr.
get_object (m_contextmenu.get ());
3375 if (go && go.isa (
"uicontextmenu"))
3377 uicontextmenu::properties& props
3378 =
reinterpret_cast<uicontextmenu::properties&
> (go.get_properties ());
3379 props.add_dependent_obj (m___myhandle__);
3384base_properties::is_handle_visible ()
const
3386 return (m_handlevisibility.is (
"on")
3387 || (! executing_callbacks.empty () && ! m_handlevisibility.is (
"off")));
3390octave::graphics_toolkit
3391base_properties::get_toolkit ()
const
3393 gh_manager& gh_mgr = octave::__get_gh_manager__ ();
3395 graphics_object go = gh_mgr.
get_object (get_parent ());
3398 return go.get_toolkit ();
3400 return octave::graphics_toolkit ();
3404base_properties::update_boundingbox ()
3406 Matrix kids = get_children ();
3408 gh_manager& gh_mgr = octave::__get_gh_manager__ ();
3410 for (
int i = 0; i < kids.
numel (); i++)
3412 graphics_object go = gh_mgr.
get_object (kids(i));
3414 if (go.valid_object ())
3415 go.get_properties ().update_boundingbox ();
3420base_properties::update_autopos (
const std::string& elem_type)
3422 gh_manager& gh_mgr = octave::__get_gh_manager__ ();
3424 graphics_object parent_go = gh_mgr.
get_object (get_parent ());
3426 if (parent_go.valid_object ())
3427 parent_go.get_properties ().update_autopos (elem_type);
3431base_properties::update_handlevisibility ()
3433 if (is_handle_visible ())
3438 gh_manager& gh_mgr = octave::__get_gh_manager__ ();
3440 graphics_object go (gh_mgr.
get_object (get___myhandle__ ()));
3442 graphics_object fig (go.get_ancestor (
"figure"));
3444 if (fig.valid_object ())
3451 auto& fig_props =
dynamic_cast<figure::properties&
> (fig.get_properties ());
3452 fig_props.set_currentobject (
Matrix ());
3496base_properties::add_listener (
const caseless_str& pname,
3500 property p = get_property (pname);
3503 p.add_listener (val, mode);
3507base_properties::delete_listener (
const caseless_str& pname,
3511 property p = get_property (pname);
3514 p.delete_listener (val, mode);
3518base_properties::get_children_of_type (
const caseless_str& chtype,
3521 std::list<graphics_object>& children_list)
const
3523 gh_manager& gh_mgr = octave::__get_gh_manager__ ();
3525 Matrix ch = get_children ();
3533 graphics_object go = gh_mgr.
get_object (hkid);
3534 if ( get_invisible || go.get_properties ().is_visible () )
3536 if (go.isa (chtype))
3537 children_list.push_back (go);
3538 else if (traverse && go.isa (
"hggroup"))
3539 go.get_properties ().get_children_of_type (chtype,
3551base_graphics_object::update_axis_limits (
const std::string& axis_type)
3553 if (! valid_object ())
3554 error (
"base_graphics_object::update_axis_limits: invalid graphics object");
3556 gh_manager& gh_mgr = octave::__get_gh_manager__ ();
3558 graphics_object parent_go = gh_mgr.
get_object (get_parent ());
3561 parent_go.update_axis_limits (axis_type);
3565base_graphics_object::update_axis_limits (
const std::string& axis_type,
3568 if (! valid_object ())
3569 error (
"base_graphics_object::update_axis_limits: invalid graphics object");
3571 gh_manager& gh_mgr = octave::__get_gh_manager__ ();
3573 graphics_object parent_go = gh_mgr.
get_object (get_parent ());
3576 parent_go.update_axis_limits (axis_type, h);
3580base_graphics_object::remove_all_listeners ()
3582 int state = toggle_warn (
"Octave:deprecated-property",
false);
3584 toggle_warn (
"Octave:deprecated-property",
true, state);
3586 for (
const auto& pm : m)
3592 octave::unwind_protect frame;
3594 octave::interpreter_try (frame);
3598 property p = get_properties ().get_property (pm.first);
3601 p.delete_listener ();
3603 catch (
const octave::execution_exception&)
3605 octave::interpreter& interp = octave::__get_interpreter__ ();
3607 interp.recover_from_exception ();
3613base_graphics_object::build_user_defaults_map (property_list::pval_map_type& def,
3614 const std::string go_name)
const
3616 property_list local_defaults = get_defaults_list ();
3617 const auto it = local_defaults.find (go_name);
3619 if (it != local_defaults.end ())
3621 property_list::pval_map_type pval_lst = it->second;
3622 for (
const auto& prop_val : pval_lst)
3624 std::string pname = prop_val.first;
3625 if (def.find (pname) == def.end ())
3626 def[pname] = prop_val.second;
3630 gh_manager& gh_mgr = octave::__get_gh_manager__ ();
3632 graphics_object parent_go = gh_mgr.
get_object (get_parent ());
3635 parent_go.build_user_defaults_map (def, go_name);
3639base_graphics_object::reset_default_properties ()
3641 if (valid_object ())
3643 gh_manager& gh_mgr = octave::__get_gh_manager__ ();
3645 property_list::pval_map_type factory_pval
3646 = gh_mgr.
get_object (0).get_factory_defaults_list ().find (type ())->second;
3648 remove_all_listeners ();
3649 xreset_default_properties (get_handle (), factory_pval);
3654base_graphics_object::values_as_string ()
3656 if (! valid_object ())
3657 error (
"base_graphics_object::values_as_string: invalid graphics object");
3662 gh_manager& gh_mgr = octave::__get_gh_manager__ ();
3664 graphics_object go = gh_mgr.
get_object (get_handle ());
3666 for (
const auto& pm : m)
3668 const auto& pname = pm.first;
3669 if (pname !=
"children" && ! go.has_readonly_property (pname))
3671 property p = get_properties ().get_property (pname);
3673 if (p.ok () && ! p.is_hidden ())
3675 retval +=
"\n\t" + std::string (pname) +
": ";
3677 retval += p.values_as_string ();
3682 if (! retval.empty ())
3689base_graphics_object::value_as_string (
const std::string& prop)
3693 if (! valid_object ())
3694 error (
"base_graphics_object::value_as_string: invalid graphics object");
3696 gh_manager& gh_mgr = octave::__get_gh_manager__ ();
3698 graphics_object go = gh_mgr.
get_object (get_handle ());
3700 if (prop !=
"children" && ! go.has_readonly_property (prop))
3702 property p = get_properties ().get_property (prop);
3704 if (p.ok () && ! p.is_hidden ())
3707 retval += p.values_as_string ();
3711 if (! retval.empty ())
3718base_graphics_object::values_as_struct ()
3722 if (! valid_object ())
3723 error (
"base_graphics_object::values_as_struct: invalid graphics object");
3727 gh_manager& gh_mgr = octave::__get_gh_manager__ ();
3729 graphics_object go = gh_mgr.
get_object (get_handle ());
3731 for (
const auto& pm : m)
3733 const auto& pname = pm.first;
3734 if (pname !=
"children" && ! go.has_readonly_property (pname))
3736 property p = get_properties ().get_property (pname);
3738 if (p.ok () && ! p.is_hidden ())
3741 retval.
assign (p.get_name (), p.values_as_cell ());
3772graphics_object::get_ancestor (
const std::string& obj_type)
const
3774 if (valid_object ())
3780 gh_manager& gh_mgr = octave::__get_gh_manager__ ();
3782 return gh_mgr.
get_object (get_parent ()).get_ancestor (obj_type);
3786 return graphics_object ();
3791#include "graphics-props.cc"
3796root_figure::properties::set_callbackobject (
const octave_value& v)
3800 if (octave::math::isnan (val.value ()))
3802 else if (ishghandle (val))
3803 m_callbackobject = val;
3805 err_set_invalid (
"callbackobject");
3809root_figure::properties::set_currentfigure (
const octave_value& v)
3813 if (octave::math::isnan (val.value ()) || ishghandle (val))
3815 m_currentfigure = val;
3819 gh_manager& gh_mgr = octave::__get_gh_manager__ ();
3825 err_set_invalid (
"currentfigure");
3829figure::properties::set_integerhandle (
const octave_value& val)
3831 if (m_integerhandle.set (val,
true))
3833 bool int_fig_handle = m_integerhandle.is_on ();
3835 gh_manager& gh_mgr = octave::__get_gh_manager__ ();
3837 graphics_object this_go = gh_mgr.
get_object (m___myhandle__);
3841 m___myhandle__ = gh_mgr.
get_handle (int_fig_handle);
3845 graphics_object parent_go = gh_mgr.
get_object (get_parent ());
3847 base_properties& props = parent_go.get_properties ();
3849 props.renumber_child (old_myhandle, m___myhandle__);
3851 Matrix kids = get_children ();
3855 graphics_object kid = gh_mgr.
get_object (kids(i));
3857 kid.get_properties ().renumber_parent (m___myhandle__);
3862 if (m___myhandle__ == cf)
3863 xset (0,
"currentfigure", m___myhandle__.value ());
3865 this_go.update (m_integerhandle.get_id ());
3874root_figure::properties::update_units ()
3876 std::string xunits = get_units ();
3878 Matrix scrn_sz = default_screensize ();
3880 double dpi = get_screenpixelsperinch ();
3882 if (xunits ==
"pixels")
3887 else if (xunits ==
"normalized")
3889 scrn_sz =
Matrix (1, 4, 1.0);
3893 else if (xunits ==
"inches")
3900 else if (xunits ==
"centimeters")
3904 scrn_sz(2) *= 2.54 / dpi;
3905 scrn_sz(3) *= 2.54 / dpi;
3907 else if (xunits ==
"points")
3911 scrn_sz(2) *= 72 / dpi;
3912 scrn_sz(3) *= 72 / dpi;
3914 else if (xunits ==
"characters")
3920 scrn_sz(2) *= 74.951 / 12.0 / dpi;
3921 scrn_sz(3) *= 74.951 / 12.0 / dpi;
3924 set_screensize (scrn_sz);
3928root_figure::properties::get_boundingbox (
bool,
const Matrix&)
const
3930 Matrix screen_size = screen_size_pixels ();
3933 pos(2) = screen_size(0);
3934 pos(3) = screen_size(1);
3967 gh_manager& gh_mgr = octave::__get_gh_manager__ ();
3975 base_properties::remove_child (h,
true);
3979root_figure::reset_default_properties ()
3982 m_default_properties = property_list ();
3984 remove_all_listeners ();
3985 xreset_default_properties (get_handle (),
3986 m_properties.factory_defaults ());
3992figure::properties::set_currentaxes (
const octave_value& val)
3996 if (octave::math::isnan (hax.value ()) || ishghandle (hax))
3997 m_currentaxes = hax;
3999 err_set_invalid (
"currentaxes");
4003figure::properties::remove_child (
const graphics_handle& h,
bool from_root)
4005 base_properties::remove_child (h, from_root);
4007 if (h == m_currentaxes.handle_value ())
4011 Matrix kids = get_children ();
4013 gh_manager& gh_mgr = octave::__get_gh_manager__ ();
4019 graphics_object go = gh_mgr.
get_object (kid);
4021 if (go.isa (
"axes"))
4023 new_currentaxes = kid;
4028 m_currentaxes = new_currentaxes;
4033figure::properties::get_number ()
const
4035 if (m_integerhandle.is_on ())
4036 return m___myhandle__.value ();
4041octave::graphics_toolkit
4042figure::properties::get_toolkit ()
const
4048figure::properties::set___graphics_toolkit__ (
const octave_value& val)
4051 error (
"set___graphics_toolkit__: toolkit must be a string");
4055 octave::gtk_manager& gtk_mgr = octave::__get_gtk_manager__ ();
4057 octave::graphics_toolkit b = gtk_mgr.find_toolkit (nm);
4059 if (b.get_name () != nm)
4060 error (
"set___graphics_toolkit__: invalid graphics toolkit");
4062 if (nm != get___graphics_toolkit__ ())
4072 base_properties::adopt (h);
4074 if (! get_currentaxes ().ok ())
4076 gh_manager& gh_mgr = octave::__get_gh_manager__ ();
4080 if (go.type () ==
"axes")
4104figure::properties::set_visible (
const octave_value& val)
4109 xset (0,
"currentfigure", m___myhandle__.value ());
4115figure::properties::get_boundingbox (
bool internal,
const Matrix&)
const
4117#if defined (__APPLE__) && defined (__MACH__)
4131 double dpr = get___device_pixel_ratio__ ();
4133 Matrix screen_size = screen_size_pixels ();
4135 get_position ().matrix_value () :
4136 get_outerposition ().matrix_value ());
4138 pos = convert_position (pos, get_units (),
"pixels", screen_size);
4142 pos(1) = screen_size(1) / dpr - pos(1) - pos(3);
4148figure::properties::bbox2position (
const Matrix& bb)
const
4150#if defined (__APPLE__) && defined (__MACH__)
4154 double dpr = get___device_pixel_ratio__ ();
4156 Matrix screen_size = screen_size_pixels ();
4159 pos(1) = screen_size(1) - (pos(1) + pos(3)) * dpr;
4162 pos = convert_position (pos,
"pixels", get_units (), screen_size);
4167figure::properties::set_boundingbox (
const Matrix& bb,
bool internal,
4168 bool do_notify_toolkit)
4170 Matrix pos = bbox2position (bb);
4173 set_position (pos, do_notify_toolkit);
4175 set_outerposition (pos, do_notify_toolkit);
4179figure::properties::map_from_boundingbox (
double x,
double y)
const
4181 Matrix bb = get_boundingbox (
true);
4187 pos(1) = bb(3) - pos(1);
4189 pos = convert_position (pos,
"pixels", get_units (),
4196figure::properties::map_to_boundingbox (
double x,
double y)
const
4198 Matrix bb = get_boundingbox (
true);
4204 pos = convert_position (pos, get_units (),
"pixels",
4207 pos(1) = bb(3) - pos(1);
4213figure::properties::set_position (
const octave_value& v,
4214 bool do_notify_toolkit)
4217 bool modified =
false;
4219 old_bb = get_boundingbox (
true);
4220 modified = m_position.set (v,
false, do_notify_toolkit);
4221 new_bb = get_boundingbox (
true);
4223 if (old_bb != new_bb)
4225 if (old_bb(2) != new_bb(2) || old_bb(3) != new_bb(3))
4227 gh_manager& gh_mgr = octave::__get_gh_manager__ ();
4229 if (! get_resizefcn ().isempty ())
4232 if (! get_sizechangedfcn ().isempty ())
4235 update_boundingbox ();
4241 m_position.run_listeners (GCB_POSTSET);
4245 if (m_paperpositionmode.is (
"auto"))
4246 m_paperposition.set (get_auto_paperposition ());
4250figure::properties::set_outerposition (
const octave_value& v,
4251 bool do_notify_toolkit)
4253 if (m_outerposition.set (v,
true, do_notify_toolkit))
4258figure::properties::set_paperunits (
const octave_value& val)
4264 error (
"set: can't set paperunits to normalized when papertype is custom");
4267 if (m_paperunits.set (val,
true))
4269 update_paperunits (old_paperunits);
4275figure::properties::set_papertype (
const octave_value& val)
4281 error (
"set: can't set paperunits to normalized when papertype is custom");
4283 if (m_papertype.set (val,
true))
4285 update_papertype ();
4293 Matrix retval (1, 2, 1.0);
4295 if (! punits.
compare (
"normalized"))
4300 if (punits.
compare (
"inches"))
4303 mm2units = 1 / 25.4;
4305 else if (punits.
compare (
"centimeters"))
4308 mm2units = 1 / 10.0;
4313 mm2units = 72.0 / 25.4;
4316 if (ptype.
compare (
"usletter"))
4318 retval(0) = 8.5 * in2units;
4319 retval(1) = 11.0 * in2units;
4321 else if (ptype.
compare (
"uslegal"))
4323 retval(0) = 8.5 * in2units;
4324 retval(1) = 14.0 * in2units;
4326 else if (ptype.
compare (
"tabloid"))
4328 retval(0) = 11.0 * in2units;
4329 retval(1) = 17.0 * in2units;
4331 else if (ptype.
compare (
"a0"))
4333 retval(0) = 841.0 * mm2units;
4334 retval(1) = 1189.0 * mm2units;
4336 else if (ptype.
compare (
"a1"))
4338 retval(0) = 594.0 * mm2units;
4339 retval(1) = 841.0 * mm2units;
4341 else if (ptype.
compare (
"a2"))
4343 retval(0) = 420.0 * mm2units;
4344 retval(1) = 594.0 * mm2units;
4346 else if (ptype.
compare (
"a3"))
4348 retval(0) = 297.0 * mm2units;
4349 retval(1) = 420.0 * mm2units;
4351 else if (ptype.
compare (
"a4"))
4353 retval(0) = 210.0 * mm2units;
4354 retval(1) = 297.0 * mm2units;
4356 else if (ptype.
compare (
"a5"))
4358 retval(0) = 148.0 * mm2units;
4359 retval(1) = 210.0 * mm2units;
4361 else if (ptype.
compare (
"b0"))
4363 retval(0) = 1029.0 * mm2units;
4364 retval(1) = 1456.0 * mm2units;
4366 else if (ptype.
compare (
"b1"))
4368 retval(0) = 728.0 * mm2units;
4369 retval(1) = 1028.0 * mm2units;
4371 else if (ptype.
compare (
"b2"))
4373 retval(0) = 514.0 * mm2units;
4374 retval(1) = 728.0 * mm2units;
4376 else if (ptype.
compare (
"b3"))
4378 retval(0) = 364.0 * mm2units;
4379 retval(1) = 514.0 * mm2units;
4381 else if (ptype.
compare (
"b4"))
4383 retval(0) = 257.0 * mm2units;
4384 retval(1) = 364.0 * mm2units;
4386 else if (ptype.
compare (
"b5"))
4388 retval(0) = 182.0 * mm2units;
4389 retval(1) = 257.0 * mm2units;
4391 else if (ptype.
compare (
"arch-a"))
4393 retval(0) = 9.0 * in2units;
4394 retval(1) = 12.0 * in2units;
4396 else if (ptype.
compare (
"arch-b"))
4398 retval(0) = 12.0 * in2units;
4399 retval(1) = 18.0 * in2units;
4401 else if (ptype.
compare (
"arch-c"))
4403 retval(0) = 18.0 * in2units;
4404 retval(1) = 24.0 * in2units;
4406 else if (ptype.
compare (
"arch-d"))
4408 retval(0) = 24.0 * in2units;
4409 retval(1) = 36.0 * in2units;
4411 else if (ptype.
compare (
"arch-e"))
4413 retval(0) = 36.0 * in2units;
4414 retval(1) = 48.0 * in2units;
4418 retval(0) = 8.5 * in2units;
4419 retval(1) = 11.0 * in2units;
4423 retval(0) = 11.0 * in2units;
4424 retval(1) = 17.0 * in2units;
4428 retval(0) = 17.0 * in2units;
4429 retval(1) = 22.0 * in2units;
4433 retval(0) = 22.0 * in2units;
4434 retval(1) = 34.0 * in2units;
4438 retval(0) = 34.0 * in2units;
4439 retval(1) = 43.0 * in2units;
4447figure::properties::get_auto_paperposition ()
4449 Matrix pos = get_position ().matrix_value ();
4456 if (funits ==
"normalized" || punits ==
"normalized")
4458 sz = screen_size_pixels ();
4459 pos = convert_position (pos, funits,
"inches", sz);
4461 if (punits ==
"normalized")
4462 sz = papersize_from_type (
"points", get_papertype ());
4464 pos = convert_position (pos,
"inches", punits, sz);
4467 pos = convert_position (pos, funits, punits, sz);
4470 sz = get_papersize ().matrix_value ();
4472 pos(0) = sz(0)/2 - pos(2)/2;
4473 pos(1) = sz(1)/2 - pos(3)/2;
4562figure::properties::update_paperunits (
const caseless_str& old_paperunits)
4564 Matrix pos = get_paperposition ().matrix_value ();
4565 Matrix sz = get_papersize ().matrix_value ();
4572 std::string porient = get_paperorientation ();
4576 if (ptype.
compare (
"<custom>"))
4578 if (old_paperunits.
compare (
"centimeters"))
4583 else if (old_paperunits.
compare (
"points"))
4589 if (punits.
compare (
"centimeters"))
4594 else if (punits.
compare (
"points"))
4602 sz = papersize_from_type (punits, ptype);
4603 if (porient ==
"landscape")
4604 std::swap (sz(0), sz(1));
4617figure::properties::update_papertype ()
4619 std::string typ = get_papertype ();
4620 if (typ !=
"<custom>")
4622 Matrix sz = papersize_from_type (get_paperunits (), typ);
4623 if (get_paperorientation () ==
"landscape")
4624 std::swap (sz(0), sz(1));
4630 if (m_paperpositionmode.is (
"auto"))
4631 m_paperposition.set (get_auto_paperposition ());
4635figure::properties::update_papersize ()
4637 Matrix sz = get_papersize ().matrix_value ();
4640 std::swap (sz(0), sz(1));
4646 m_paperorientation.set (
"portrait");
4649 std::string punits = get_paperunits ();
4650 if (punits ==
"centimeters")
4655 else if (punits ==
"points")
4660 if (punits ==
"normalized")
4662 if (get_papertype () ==
"<custom>")
4663 error (
"set: can't set the papertype to <custom> when the paperunits is normalized");
4670 std::string ptype =
"<custom>";
4671 const double mm2in = 1.0 / 25.4;
4672 const double tol = 0.01;
4674 if (std::abs (sz(0) - 8.5) + std::abs (sz(1) - 11.0) < tol)
4676 else if (std::abs (sz(0) - 8.5) + std::abs (sz(1) - 14.0) < tol)
4678 else if (std::abs (sz(0) - 11.0) + std::abs (sz(1) - 17.0) < tol)
4680 else if (std::abs (sz(0) - 841.0 * mm2in)
4681 + std::abs (sz(1) - 1198.0 * mm2in) < tol)
4683 else if (std::abs (sz(0) - 594.0 * mm2in)
4684 + std::abs (sz(1) - 841.0 * mm2in) < tol)
4686 else if (std::abs (sz(0) - 420.0 * mm2in)
4687 + std::abs (sz(1) - 594.0 * mm2in) < tol)
4689 else if (std::abs (sz(0) - 297.0 * mm2in)
4690 + std::abs (sz(1) - 420.0 * mm2in) < tol)
4692 else if (std::abs (sz(0) - 210.0 * mm2in)
4693 + std::abs (sz(1) - 297.0 * mm2in) < tol)
4695 else if (std::abs (sz(0) - 148.0 * mm2in)
4696 + std::abs (sz(1) - 210.0 * mm2in) < tol)
4698 else if (std::abs (sz(0) - 1029.0 * mm2in)
4699 + std::abs (sz(1) - 1456.0 * mm2in) < tol)
4701 else if (std::abs (sz(0) - 728.0 * mm2in)
4702 + std::abs (sz(1) - 1028.0 * mm2in) < tol)
4704 else if (std::abs (sz(0) - 514.0 * mm2in)
4705 + std::abs (sz(1) - 728.0 * mm2in) < tol)
4707 else if (std::abs (sz(0) - 364.0 * mm2in)
4708 + std::abs (sz(1) - 514.0 * mm2in) < tol)
4710 else if (std::abs (sz(0) - 257.0 * mm2in)
4711 + std::abs (sz(1) - 364.0 * mm2in) < tol)
4713 else if (std::abs (sz(0) - 182.0 * mm2in)
4714 + std::abs (sz(1) - 257.0 * mm2in) < tol)
4716 else if (std::abs (sz(0) - 9.0)
4717 + std::abs (sz(1) - 12.0) < tol)
4719 else if (std::abs (sz(0) - 12.0)
4720 + std::abs (sz(1) - 18.0) < tol)
4722 else if (std::abs (sz(0) - 18.0)
4723 + std::abs (sz(1) - 24.0) < tol)
4725 else if (std::abs (sz(0) - 24.0)
4726 + std::abs (sz(1) - 36.0) < tol)
4728 else if (std::abs (sz(0) - 36.0)
4729 + std::abs (sz(1) - 48.0) < tol)
4731 else if (std::abs (sz(0) - 8.5)
4732 + std::abs (sz(1) - 11.0) < tol)
4734 else if (std::abs (sz(0) - 11.0)
4735 + std::abs (sz(1) - 17.0) < tol)
4737 else if (std::abs (sz(0) - 17.0)
4738 + std::abs (sz(1) - 22.0) < tol)
4740 else if (std::abs (sz(0) - 22.0)
4741 + std::abs (sz(1) - 34.0) < tol)
4743 else if (std::abs (sz(0) - 34.0)
4744 + std::abs (sz(1) - 43.0) < tol)
4748 m_papertype.set (ptype);
4750 if (punits ==
"centimeters")
4755 else if (punits ==
"points")
4760 if (get_paperorientation () ==
"landscape")
4762 std::swap (sz(0), sz(1));
4766 if (m_paperpositionmode.is (
"auto"))
4767 m_paperposition.set (get_auto_paperposition ());
4803figure::properties::update_paperorientation ()
4805 std::string porient = get_paperorientation ();
4806 Matrix sz = get_papersize ().matrix_value ();
4807 if ((sz(0) > sz(1) && porient ==
"portrait")
4808 || (sz(0) < sz(1) && porient ==
"landscape"))
4810 std::swap (sz(0), sz(1));
4816 if (m_paperpositionmode.is (
"auto"))
4817 m_paperposition.set (get_auto_paperposition ());
4852 if (m_units.set (val,
true))
4854 update_units (old_units);
4860figure::properties::update_units (
const caseless_str& old_units)
4862 m_position.set (convert_position (get_position ().matrix_value (),
4863 old_units, get_units (),
4864 screen_size_pixels ()),
false);
4886figure::properties::get_title ()
const
4889 if (! get_number ().isempty () && is_numbertitle ())
4891 std::ostringstream os;
4892 std::string nm = get_name ();
4894 os <<
"Figure " << m___myhandle__.value ();
4896 os <<
": " << get_name ();
4901 title = get_name ();
4914 octave_value retval = m_default_properties.lookup (name);
4920 gh_manager& gh_mgr = octave::__get_gh_manager__ ();
4922 graphics_object parent_go = gh_mgr.
get_object (parent_h);
4924 retval = parent_go.get_default (name);
4931figure::reset_default_properties ()
4934 m_default_properties = property_list ();
4935 property_list::pval_map_type plist = m_properties.factory_defaults ();
4937 plist.erase (
"units");
4938 plist.erase (
"position");
4939 plist.erase (
"innerposition");
4940 plist.erase (
"outerposition");
4941 plist.erase (
"paperunits");
4942 plist.erase (
"paperposition");
4943 plist.erase (
"paperpositionmode");
4944 plist.erase (
"windowstyle");
4946 remove_all_listeners ();
4947 xreset_default_properties (get_handle (), plist);
4953axes::properties::init ()
4955 m_position.add_constraint (
dim_vector (1, 4));
4956 m_outerposition.add_constraint (
dim_vector (1, 4));
4957 m_tightinset.add_constraint (
dim_vector (1, 4));
4958 m_looseinset.add_constraint (
dim_vector (1, 4));
4959 m_colororder.add_constraint (
dim_vector (-1, 3));
4960 m_dataaspectratio.add_constraint (3);
4961 m_dataaspectratio.add_constraint (
"min", 0,
false);
4962 m_dataaspectratio.add_constraint (FINITE);
4963 m_plotboxaspectratio.add_constraint (3);
4964 m_plotboxaspectratio.add_constraint (
"min", 0,
false);
4965 m_plotboxaspectratio.add_constraint (FINITE);
4968 m_alim.add_constraint (2);
4969 m_alim.add_constraint (NOT_NAN);
4970 m_clim.add_constraint (2);
4971 m_clim.add_constraint (NOT_NAN);
4972 m_xlim.add_constraint (2);
4973 m_xlim.add_constraint (NOT_NAN);
4974 m_ylim.add_constraint (2);
4975 m_ylim.add_constraint (NOT_NAN);
4976 m_zlim.add_constraint (2);
4977 m_zlim.add_constraint (NOT_NAN);
4979 m_xtick.add_constraint (FINITE);
4981 m_ytick.add_constraint (FINITE);
4983 m_ztick.add_constraint (FINITE);
4984 m_ticklength.add_constraint (
dim_vector (1, 2));
4989 m_cameraposition.add_constraint (3);
4990 m_cameraposition.add_constraint (FINITE);
4991 m_cameratarget.add_constraint (3);
4992 m_cameratarget.add_constraint (FINITE);
4995 m_cameraupvector = upv;
4996 m_cameraupvector.add_constraint (3);
4997 m_cameraupvector.add_constraint (FINITE);
4998 m_cameraviewangle.add_constraint (FINITE);
4999 m_currentpoint.add_constraint (
dim_vector (2, 3));
5002 m_fontsize.add_constraint (
"min", 0.0,
false);
5003 m_gridalpha.add_constraint (
"min", 0.0,
true);
5004 m_gridalpha.add_constraint (
"max", 1.0,
true);
5005 m_labelfontsizemultiplier.add_constraint (
"min", 0.0,
false);
5006 m_linewidth.add_constraint (
"min", 0.0,
false);
5007 m_minorgridalpha.add_constraint (
"min", 0.0,
true);
5008 m_minorgridalpha.add_constraint (
"max", 1.0,
true);
5009 m_titlefontsizemultiplier.add_constraint (
"min", 0.0,
false);
5014 m_x_zlim.resize (1, 2);
5020 calc_ticklabels (m_xtick, m_xticklabel, m_xscale.is (
"log"),
5021 xaxislocation_is (
"origin"),
5022 m_yscale.is (
"log") ? 2 : (yaxislocation_is (
"origin") ? 0 :
5023 (yaxislocation_is (
"left") ? -1 : 1)), m_xlim);
5024 calc_ticklabels (m_ytick, m_yticklabel, m_yscale.is (
"log"),
5025 yaxislocation_is (
"origin"),
5026 m_xscale.is (
"log") ? 2 : (xaxislocation_is (
"origin") ? 0 :
5027 (xaxislocation_is (
"bottom") ? -1 : 1)), m_ylim);
5028 calc_ticklabels (m_ztick, m_zticklabel, m_zscale.is (
"log"),
5031 xset (m_xlabel.handle_value (),
"handlevisibility",
"off");
5032 xset (m_ylabel.handle_value (),
"handlevisibility",
"off");
5033 xset (m_zlabel.handle_value (),
"handlevisibility",
"off");
5034 xset (m_title.handle_value (),
"handlevisibility",
"off");
5036 xset (m_xlabel.handle_value (),
"horizontalalignment",
"center");
5037 xset (m_xlabel.handle_value (),
"horizontalalignmentmode",
"auto");
5038 xset (m_ylabel.handle_value (),
"horizontalalignment",
"center");
5039 xset (m_ylabel.handle_value (),
"horizontalalignmentmode",
"auto");
5040 xset (m_zlabel.handle_value (),
"horizontalalignment",
"right");
5041 xset (m_zlabel.handle_value (),
"horizontalalignmentmode",
"auto");
5042 xset (m_title.handle_value (),
"horizontalalignment",
"center");
5043 xset (m_title.handle_value (),
"horizontalalignmentmode",
"auto");
5045 xset (m_xlabel.handle_value (),
"verticalalignment",
"top");
5046 xset (m_xlabel.handle_value (),
"verticalalignmentmode",
"auto");
5047 xset (m_ylabel.handle_value (),
"verticalalignment",
"bottom");
5048 xset (m_ylabel.handle_value (),
"verticalalignmentmode",
"auto");
5049 xset (m_title.handle_value (),
"verticalalignment",
"bottom");
5050 xset (m_title.handle_value (),
"verticalalignmentmode",
"auto");
5052 xset (m_ylabel.handle_value (),
"rotation", 90.0);
5053 xset (m_ylabel.handle_value (),
"rotationmode",
"auto");
5055 xset (m_zlabel.handle_value (),
"visible",
"off");
5057 xset (m_xlabel.handle_value (),
"clipping",
"off");
5058 xset (m_ylabel.handle_value (),
"clipping",
"off");
5059 xset (m_zlabel.handle_value (),
"clipping",
"off");
5060 xset (m_title.handle_value (),
"clipping",
"off");
5062 xset (m_xlabel.handle_value (),
"__autopos_tag__",
"xlabel");
5063 xset (m_ylabel.handle_value (),
"__autopos_tag__",
"ylabel");
5064 xset (m_zlabel.handle_value (),
"__autopos_tag__",
"zlabel");
5065 xset (m_title.handle_value (),
"__autopos_tag__",
"title");
5067 double fs = m_labelfontsizemultiplier.double_value () *
5068 m_fontsize.double_value ();
5072 fs = m_titlefontsizemultiplier.double_value () * m_fontsize.double_value ();
5074 xset (m_title.handle_value (),
"fontweight", m_titlefontweight.get ());
5076 adopt (m_xlabel.handle_value ());
5077 adopt (m_ylabel.handle_value ());
5078 adopt (m_zlabel.handle_value ());
5079 adopt (m_title.handle_value ());
5081 Matrix tlooseinset = default_axes_position ();
5082 tlooseinset(2) = 1-tlooseinset(0)-tlooseinset(2);
5083 tlooseinset(3) = 1-tlooseinset(1)-tlooseinset(3);
5084 m_looseinset = tlooseinset;
5111axes::properties::calc_tightbox (
const Matrix& init_pos)
5115 gh_manager& gh_mgr = octave::__get_gh_manager__ ();
5117 graphics_object go = gh_mgr.
get_object (get_parent ());
5119 Matrix parent_bb = go.get_properties ().get_boundingbox (
true);
5123 update_ticklength ();
5125 Matrix ext = get_extent (
true,
true);
5126 ext(1) = parent_bb(3) - ext(1) - ext(3);
5129 ext = convert_position (ext,
"pixels", get_units (),
5131 if (ext(0) < pos(0))
5133 pos(2) += pos(0)-ext(0);
5136 if (ext(0)+ext(2) > pos(0)+pos(2))
5137 pos(2) = ext(0)+ext(2)-pos(0);
5139 if (ext(1) < pos(1))
5141 pos(3) += pos(1)-ext(1);
5144 if (ext(1)+ext(3) > pos(1)+pos(3))
5145 pos(3) = ext(1)+ext(3)-pos(1);
5151axes::properties::sync_positions ()
5154 if (m_positionconstraint.is (
"innerposition"))
5157 update_outerposition ();
5159 set_units (
"normalized");
5160 Matrix pos = m_position.get ().matrix_value ();
5161 Matrix outpos = m_outerposition.get ().matrix_value ();
5162 Matrix tightpos = calc_tightbox (pos);
5163 Matrix tinset (1, 4, 1.0);
5164 tinset(0) = pos(0)-tightpos(0);
5165 tinset(1) = pos(1)-tightpos(1);
5166 tinset(2) = tightpos(0)+tightpos(2)-pos(0)-pos(2);
5167 tinset(3) = tightpos(1)+tightpos(3)-pos(1)-pos(3);
5168 m_tightinset = tinset;
5169 set_units (old_units);
5170 update_transform ();
5171 if (m_positionconstraint.is (
"innerposition"))
5174 update_outerposition ();
5241axes::properties::set_text_child (handle_property& hp,
5242 const std::string& who,
5247 xset (hp.handle_value (),
"string", v);
5253 gh_manager& gh_mgr = octave::__get_gh_manager__ ();
5257 if (go.isa (
"text"))
5258 val = octave::reparent (v,
"set", who, m___myhandle__,
false);
5263 error (
"set: expecting text graphics object or character string for %s property, found %s",
5264 who.c_str (), cname.c_str ());
5267 xset (val,
"handlevisibility",
"off");
5269 gh_mgr.
free (hp.handle_value ());
5273 adopt (hp.handle_value ());
5279 set_text_child (m_xlabel,
"xlabel", v);
5280 xset (m_xlabel.handle_value (),
"positionmode",
"auto");
5281 xset (m_xlabel.handle_value (),
"rotationmode",
"auto");
5282 xset (m_xlabel.handle_value (),
"horizontalalignmentmode",
"auto");
5283 xset (m_xlabel.handle_value (),
"verticalalignmentmode",
"auto");
5284 xset (m_xlabel.handle_value (),
"clipping",
"off");
5285 xset (m_xlabel.handle_value (),
"color", get_xcolor ());
5286 xset (m_xlabel.handle_value (),
"__autopos_tag__",
"xlabel");
5287 update_xlabel_position ();
5293 set_text_child (m_ylabel,
"ylabel", v);
5294 xset (m_ylabel.handle_value (),
"positionmode",
"auto");
5295 xset (m_ylabel.handle_value (),
"rotationmode",
"auto");
5296 xset (m_ylabel.handle_value (),
"horizontalalignmentmode",
"auto");
5297 xset (m_ylabel.handle_value (),
"verticalalignmentmode",
"auto");
5298 xset (m_ylabel.handle_value (),
"clipping",
"off");
5299 xset (m_ylabel.handle_value (),
"color", get_ycolor ());
5300 xset (m_ylabel.handle_value (),
"__autopos_tag__",
"ylabel");
5301 update_ylabel_position ();
5307 set_text_child (m_zlabel,
"zlabel", v);
5308 xset (m_zlabel.handle_value (),
"positionmode",
"auto");
5309 xset (m_zlabel.handle_value (),
"rotationmode",
"auto");
5310 xset (m_zlabel.handle_value (),
"horizontalalignmentmode",
"auto");
5311 xset (m_zlabel.handle_value (),
"verticalalignmentmode",
"auto");
5312 xset (m_zlabel.handle_value (),
"clipping",
"off");
5313 xset (m_zlabel.handle_value (),
"color", get_zcolor ());
5314 xset (m_zlabel.handle_value (),
"__autopos_tag__",
"zlabel");
5315 update_zlabel_position ();
5321 set_text_child (m_title,
"title", v);
5322 xset (m_title.handle_value (),
"positionmode",
"auto");
5323 xset (m_title.handle_value (),
"horizontalalignment",
"center");
5324 xset (m_title.handle_value (),
"horizontalalignmentmode",
"auto");
5325 xset (m_title.handle_value (),
"verticalalignment",
"bottom");
5326 xset (m_title.handle_value (),
"verticalalignmentmode",
"auto");
5327 xset (m_title.handle_value (),
"clipping",
"off");
5328 xset (m_title.handle_value (),
"__autopos_tag__",
"title");
5329 update_title_position ();
5333axes::properties::set_defaults (base_graphics_object& bgo,
5334 const std::string& mode)
5346 if (mode !=
"reset")
5347 error (R
"(axes::properties::set_defaults: expected mode = "reset", found "%s")", mode.c_str ());
5357 m_alimmode = "auto";
5358 m_climmode =
"auto";
5359 m_xlimmode =
"auto";
5360 m_ylimmode =
"auto";
5361 m_zlimmode =
"auto";
5364 m_alphascale =
"linear";
5366 m_ambientlightcolor =
Matrix (1, 3, 1.0);
5369 m_boxstyle =
"back";
5372 m_camerapositionmode =
"auto";
5373 m_cameratargetmode =
"auto";
5374 m_cameraupvectormode =
"auto";
5375 m_cameraviewanglemode =
"auto";
5377 m_clippingstyle =
"3dbox";
5379 m_color = color_values (
"white");
5381 m_colororder = default_colororder ();
5382 m_colororderindex = 1.0;
5383 m_colorscale =
"linear";
5386 m_dataaspectratiomode =
"auto";
5388 m_fontangle =
"normal";
5389 m_fontname = OCTAVE_DEFAULT_FONTNAME;
5391 m_fontsizemode =
"auto";
5392 m_fontsmoothing =
"on";
5393 m_fontunits =
"points";
5394 m_fontweight =
"normal";
5397 m_gridalphamode =
"auto";
5398 m_gridcolor = color_values (0.15, 0.15, 0.15);
5399 m_gridcolormode =
"auto";
5400 m_gridlinestyle =
"-";
5402 m_labelfontsizemultiplier = 1.1;
5406 m_linestyleorder =
"-";
5407 m_linestyleorderindex = 1.0;
5411 m_minorgridalpha = 0.25;
5412 m_minorgridalphamode =
"auto";
5413 m_minorgridcolor = color_values (0.1, 0.1, 0.1);
5414 m_minorgridcolormode =
"auto";
5415 m_minorgridlinestyle =
":";
5417 m_nextplot =
"replace";
5420 m_plotboxaspectratiomode =
"auto";
5421 m_projection =
"orthographic";
5423 m_sortmethod =
"depth";
5426 m_tickdirmode =
"auto";
5427 m_ticklabelinterpreter =
"tex";
5428 m_ticklength = default_axes_ticklength ();
5430 m_tightinset =
Matrix (1, 4, 0.0);
5432 m_titlefontsizemultiplier = 1.1;
5433 m_titlefontweight =
"bold";
5435 Matrix tview (1, 2, 0.0);
5439 m_xaxislocation =
"bottom";
5441 m_xcolor = color_values (0.15, 0.15, 0.15);
5442 m_xcolormode =
"auto";
5445 m_xlimitmethod =
"tickaligned";
5446 m_xminorgrid =
"off";
5447 m_xminortick =
"off";
5448 m_xminortickvalues =
Matrix ();
5449 m_xminortickvaluesmode =
"auto";
5450 m_xscale =
"linear";
5453 m_xticklabelmode =
"auto";
5454 m_xticklabelrotation = 0.0;
5455 m_xtickmode =
"auto";
5457 m_yaxislocation =
"left";
5459 m_ycolor = color_values (0.15, 0.15, 0.15);
5460 m_ycolormode =
"auto";
5463 m_ylimitmethod =
"tickaligned";
5464 m_yminorgrid =
"off";
5465 m_yminortick =
"off";
5466 m_yminortickvalues =
Matrix ();
5467 m_yminortickvaluesmode =
"auto";
5468 m_yscale =
"linear";
5471 m_yticklabelmode =
"auto";
5472 m_yticklabelrotation = 0.0;
5473 m_ytickmode =
"auto";
5475 m_zcolor = color_values (0.15, 0.15, 0.15);
5476 m_zcolormode =
"auto";
5479 m_zlimitmethod =
"tickaligned";
5480 m_zminorgrid =
"off";
5481 m_zminortick =
"off";
5482 m_zminortickvalues =
Matrix ();
5483 m_zminortickvaluesmode =
"auto";
5484 m_zscale =
"linear";
5487 m_zticklabelmode =
"auto";
5488 m_zticklabelrotation = 0.0;
5489 m_ztickmode =
"auto";
5497 gh_manager& gh_mgr = octave::__get_gh_manager__ ();
5499 graphics_object go = gh_mgr.
get_object (m_xlabel.handle_value ());
5500 go.reset_default_properties ();
5501 go = gh_mgr.
get_object (m_ylabel.handle_value ());
5502 go.reset_default_properties ();
5503 go = gh_mgr.
get_object (m_zlabel.handle_value ());
5504 go.reset_default_properties ();
5505 go = gh_mgr.
get_object (m_title.handle_value ());
5506 go.reset_default_properties ();
5508 xset (m_xlabel.handle_value (),
"handlevisibility",
"off");
5509 xset (m_ylabel.handle_value (),
"handlevisibility",
"off");
5510 xset (m_zlabel.handle_value (),
"handlevisibility",
"off");
5511 xset (m_title.handle_value (),
"handlevisibility",
"off");
5513 xset (m_xlabel.handle_value (),
"horizontalalignment",
"center");
5514 xset (m_xlabel.handle_value (),
"horizontalalignmentmode",
"auto");
5515 xset (m_ylabel.handle_value (),
"horizontalalignment",
"center");
5516 xset (m_ylabel.handle_value (),
"horizontalalignmentmode",
"auto");
5517 xset (m_zlabel.handle_value (),
"horizontalalignment",
"right");
5518 xset (m_zlabel.handle_value (),
"horizontalalignmentmode",
"auto");
5519 xset (m_title.handle_value (),
"horizontalalignment",
"center");
5520 xset (m_title.handle_value (),
"horizontalalignmentmode",
"auto");
5522 xset (m_xlabel.handle_value (),
"verticalalignment",
"top");
5523 xset (m_xlabel.handle_value (),
"verticalalignmentmode",
"auto");
5524 xset (m_ylabel.handle_value (),
"verticalalignment",
"bottom");
5525 xset (m_ylabel.handle_value (),
"verticalalignmentmode",
"auto");
5526 xset (m_title.handle_value (),
"verticalalignment",
"bottom");
5527 xset (m_title.handle_value (),
"verticalalignmentmode",
"auto");
5529 xset (m_ylabel.handle_value (),
"rotation", 90.0);
5530 xset (m_ylabel.handle_value (),
"rotationmode",
"auto");
5532 xset (m_zlabel.handle_value (),
"visible",
"off");
5534 xset (m_xlabel.handle_value (),
"clipping",
"off");
5535 xset (m_ylabel.handle_value (),
"clipping",
"off");
5536 xset (m_zlabel.handle_value (),
"clipping",
"off");
5537 xset (m_title.handle_value (),
"clipping",
"off");
5539 xset (m_xlabel.handle_value (),
"__autopos_tag__",
"xlabel");
5540 xset (m_ylabel.handle_value (),
"__autopos_tag__",
"ylabel");
5541 xset (m_zlabel.handle_value (),
"__autopos_tag__",
"zlabel");
5542 xset (m_title.handle_value (),
"__autopos_tag__",
"title");
5545 fs = m_labelfontsizemultiplier.double_value () * m_fontsize.double_value ();
5549 fs = m_titlefontsizemultiplier.double_value () * m_fontsize.double_value ();
5551 xset (m_title.handle_value (),
"fontweight", m_titlefontweight.get ());
5553 update_transform ();
5555 override_defaults (bgo);
5559axes::properties::get_colormap ()
const
5561 if (m___colormap__.get ().isempty ())
5563 gh_manager& gh_mgr = octave::__get_gh_manager__ ();
5565 graphics_object go (gh_mgr.
get_object (get___myhandle__ ()));
5566 graphics_object go_f (go.get_ancestor (
"figure"));
5567 figure::properties& figure_props
5568 =
reinterpret_cast<figure::properties&
> (go_f.get_properties ());
5569 return figure_props.get_colormap ();
5572 return get___colormap__ ();
5576axes::properties::delete_text_child (handle_property& hp,
bool from_root)
5580 gh_manager& gh_mgr = octave::__get_gh_manager__ ();
5586 if (go.valid_object ())
5587 gh_mgr.
free (h, from_root);
5595 if (! is_beingdeleted ())
5599 xset (hp.handle_value (),
"handlevisibility",
"off");
5601 adopt (hp.handle_value ());
5606axes::properties::remove_child (
const graphics_handle& h,
bool from_root)
5608 gh_manager& gh_mgr = octave::__get_gh_manager__ ();
5612 if (m_xlabel.handle_value ().ok () && h == m_xlabel.handle_value ())
5614 delete_text_child (m_xlabel, from_root);
5615 update_xlabel_position ();
5617 else if (m_ylabel.handle_value ().ok () && h == m_ylabel.handle_value ())
5619 delete_text_child (m_ylabel, from_root);
5620 update_ylabel_position ();
5622 else if (m_zlabel.handle_value ().ok () && h == m_zlabel.handle_value ())
5624 delete_text_child (m_zlabel, from_root);
5625 update_zlabel_position ();
5627 else if (m_title.handle_value ().ok () && h == m_title.handle_value ())
5629 delete_text_child (m_title, from_root);
5630 update_title_position ();
5632 else if (get_num_lights () > 0 && go.isa (
"light")
5633 && go.get_properties ().is_visible ())
5634 decrease_num_lights ();
5636 if (go.valid_object ())
5637 base_properties::remove_child (h, from_root);
5644 gh_manager& gh_mgr = octave::__get_gh_manager__ ();
5648 if (go.isa (
"light") && go.get_properties ().is_visible ())
5649 increase_num_lights ();
5651 base_properties::adopt (h);
5659 if (xlimmode_is (
"auto"))
5660 update_axis_limits (
"xlim");
5662 if (ylimmode_is (
"auto"))
5663 update_axis_limits (
"ylim");
5665 if (zlimmode_is (
"auto"))
5666 update_axis_limits (
"zlim");
5668 if (climmode_is (
"auto"))
5669 update_axis_limits (
"clim");
5671 if (climmode_is (
"auto"))
5672 update_axis_limits (
"alim");
5680 for (
int i = 0; i < 4; i++)
5777 double fact = 1.0 / sqrt (v(0)*v(0)+v(1)*v(1)+v(2)*v(2));
5778 scale (v, fact, fact, fact);
5784 return (v1(0)*
v2(0)+v1(1)*
v2(1)+v1(2)*
v2(2));
5790 return sqrt (
dot (v, v));
5798 r(0) = v1(1)*
v2(2) - v1(2)*
v2(1);
5799 r(1) = v1(2)*
v2(0) - v1(0)*
v2(2);
5800 r(2) = v1(0)*
v2(1) - v1(1)*
v2(0);
5808 static double data[32] =
5821 memcpy (m.
rwdata (), data, sizeof (
double)*32);
5831 memcpy (retval.
rwdata (), m.
data (), sizeof (
double)*3);
5843axes::properties::update_camera ()
5845 double xd = (xdir_is (
"normal") ? 1 : -1);
5846 double yd = (ydir_is (
"normal") ? 1 : -1);
5847 double zd = (zdir_is (
"normal") ? 1 : -1);
5849 Matrix xlimits = m_sx.scale (get_xlim ().matrix_value ());
5850 Matrix ylimits = m_sy.scale (get_ylim ().matrix_value ());
5851 Matrix zlimits = m_sz.scale (get_zlim ().matrix_value ());
5853 double xo = xlimits(xd > 0 ? 0 : 1);
5854 double yo = ylimits(yd > 0 ? 0 : 1);
5855 double zo = zlimits(zd > 0 ? 0 : 1);
5857 Matrix pb = get_plotboxaspectratio ().matrix_value ();
5859 bool autocam = (camerapositionmode_is (
"auto")
5860 && cameratargetmode_is (
"auto")
5861 && cameraupvectormode_is (
"auto")
5862 && cameraviewanglemode_is (
"auto"));
5863 bool dowarp = (autocam && dataaspectratiomode_is (
"auto")
5864 && plotboxaspectratiomode_is (
"auto"));
5870 if (cameratargetmode_is (
"auto"))
5872 c_center(0) = (xlimits(0) + xlimits(1)) / 2;
5873 c_center(1) = (ylimits(0) + ylimits(1)) / 2;
5874 c_center(2) = (zlimits(0) + zlimits(1)) / 2;
5879 c_center =
cam2xform (get_cameratarget ().matrix_value ());
5881 if (camerapositionmode_is (
"auto"))
5883 Matrix tview = get_view ().matrix_value ();
5884 double az = tview(0);
5885 double el = tview(1);
5886 double d = 5 * sqrt (pb(0)*pb(0) + pb(1)*pb(1) + pb(2)*pb(2));
5888 if (el == 90 || el == -90)
5889 c_eye(2) =
d*octave::math::signum (el);
5894 c_eye(0) =
d * cos (el) * sin (az);
5895 c_eye(1) = -
d* cos (el) * cos (az);
5896 c_eye(2) =
d * sin (el);
5898 c_eye(0) = c_eye(0)*(xlimits(1)-xlimits(0))/(xd*pb(0))+c_center(0);
5899 c_eye(1) = c_eye(1)*(ylimits(1)-ylimits(0))/(yd*pb(1))+c_center(1);
5900 c_eye(2) = c_eye(2)*(zlimits(1)-zlimits(0))/(zd*pb(2))+c_center(2);
5905 c_eye =
cam2xform (get_cameraposition ().matrix_value ());
5907 if (cameraupvectormode_is (
"auto"))
5909 Matrix tview = get_view ().matrix_value ();
5910 double az = tview(0);
5911 double el = tview(1);
5913 if (el == 90 || el == -90)
5915 c_upv(0) = -octave::math::signum (el)
5916 * sin (az*M_PI/180.0)*(xlimits(1)-xlimits(0))/pb(0);
5917 c_upv(1) = octave::math::signum (el)
5918 * cos (az*M_PI/180.0)*(ylimits(1)-ylimits(0))/pb(1);
5926 c_upv =
cam2xform (get_cameraupvector ().matrix_value ());
5937 scale (x_pre, pb(0), pb(1), pb(2));
5939 scale (x_pre, xd/(xlimits(1)-xlimits(0)), yd/(ylimits(1)-ylimits(0)),
5940 zd/(zlimits(1)-zlimits(0)));
5943 xform (c_eye, x_pre);
5944 xform (c_center, x_pre);
5945 scale (c_upv, pb(0)/(xlimits(1)-xlimits(0)), pb(1)/(ylimits(1)-ylimits(0)),
5946 pb(2)/(zlimits(1)-zlimits(0)));
5947 translate (c_center, -c_eye(0), -c_eye(1), -c_eye(2));
5953 if (std::abs (
dot (
f, UP)) > 1e-15)
5955 double fa = 1 / sqrt (1 -
f(2)*
f(2));
5956 scale (UP, fa, fa, fa);
5962 scale (x_view, 1, 1, -1);
5964 l(0, 0) = s(0); l(0, 1) = s(1); l(0, 2) = s(2);
5965 l(1, 0) = u(0); l(1, 1) = u(1); l(1, 2) = u(2);
5966 l(2, 0) = -
f(0); l(2, 1) = -
f(1); l(2, 2) = -
f(2);
5967 x_view = x_view * l;
5968 translate (x_view, -c_eye(0), -c_eye(1), -c_eye(2));
5969 scale (x_view, pb(0), pb(1), pb(2));
5975 double xM = cmax(0) - cmin(0);
5976 double yM = cmax(1) - cmin(1);
5978 Matrix bb = get_boundingbox (
true);
5982 if (cameraviewanglemode_is (
"auto"))
5989 if (
false && dowarp)
5990 af = (1.0 / (xM > yM ? xM : yM));
5993 if ((bb(2)/bb(3)) > (xM/yM))
5998 v_angle = 2 * (180.0 / M_PI) *
atan (1 / (2 * af *
norm (F)));
6000 m_cameraviewangle = v_angle;
6003 v_angle = get_cameraviewangle ();
6005 double pf = 1 / (2 * tan ((v_angle / 2) * M_PI / 180.0) *
norm (F));
6006 scale (x_projection, pf, pf, 1);
6012 translate (x_viewport, bb(0)+bb(2)/2, bb(1)+bb(3)/2, 0);
6013 scale (x_viewport, bb(2)/xM, -bb(3)/yM, 1);
6020 if ((bb(2)/bb(3)) > (xM/yM))
6026 pix = (bb(2) < bb(3) ? bb(2) : bb(3));
6027 translate (x_viewport, bb(0)+bb(2)/2, bb(1)+bb(3)/2, 0);
6028 scale (x_viewport, pix, -pix, 1);
6031 x_normrender = x_viewport * x_projection * x_view;
6037 m_x_zlim(0) = cmin(2);
6038 m_x_zlim(1) = cmax(2);
6040 m_x_render = x_normrender;
6041 scale (m_x_render, xd/(xlimits(1)-xlimits(0)), yd/(ylimits(1)-ylimits(0)),
6042 zd/(zlimits(1)-zlimits(0)));
6045 m_x_render_inv = m_x_render.inverse ();
6049 m_x_gl_mat1 = x_view;
6050 scale (m_x_gl_mat1, xd/(xlimits(1)-xlimits(0)), yd/(ylimits(1)-ylimits(0)),
6051 zd/(zlimits(1)-zlimits(0)));
6053 m_x_gl_mat2 = x_viewport * x_projection;
6056static bool updating_axes_layout =
false;
6059axes::properties::update_axes_layout ()
6061 if (updating_axes_layout)
6064 graphics_xform
xform = get_transform ();
6066 double xd = (xdir_is (
"normal") ? 1 : -1);
6067 double yd = (ydir_is (
"normal") ? 1 : -1);
6068 double zd = (zdir_is (
"normal") ? 1 : -1);
6070 const Matrix xlims =
xform.xscale (get_xlim ().matrix_value ());
6071 const Matrix ylims =
xform.yscale (get_ylim ().matrix_value ());
6072 const Matrix zlims =
xform.zscale (get_zlim ().matrix_value ());
6074 double x_min, x_max, y_min, y_max, z_min, z_max;
6075 x_min = xlims(0), x_max = xlims(1);
6076 y_min = ylims(0), y_max = ylims(1);
6077 z_min = zlims(0), z_max = zlims(1);
6081 m_xstate = m_ystate = m_zstate = AXE_ANY_DIR;
6083 p1 =
xform.transform (x_min, (y_min+y_max)/2, (z_min+z_max)/2,
false);
6084 p2 =
xform.transform (x_max, (y_min+y_max)/2, (z_min+z_max)/2,
false);
6085 dir(0) = octave::math::round (p2(0) - p1(0));
6086 dir(1) = octave::math::round (p2(1) - p1(1));
6087 dir(2) = (p2(2) - p1(2));
6088 if (dir(0) == 0 && dir(1) == 0)
6089 m_xstate = AXE_DEPTH_DIR;
6090 else if (dir(2) == 0)
6093 m_xstate = AXE_VERT_DIR;
6094 else if (dir(1) == 0)
6095 m_xstate = AXE_HORZ_DIR;
6101 m_xPlane = (dir(0) > 0 ? x_max : x_min);
6103 m_xPlane = (dir(1) < 0 ? x_max : x_min);
6106 m_xPlane = (dir(2) < 0 ? x_min : x_max);
6108 m_xPlaneN = (m_xPlane == x_min ? x_max : x_min);
6109 m_fx = (x_max - x_min) / sqrt (dir(0)*dir(0) + dir(1)*dir(1));
6111 p1 =
xform.transform ((x_min + x_max)/2, y_min, (z_min + z_max)/2,
false);
6112 p2 =
xform.transform ((x_min + x_max)/2, y_max, (z_min + z_max)/2,
false);
6113 dir(0) = octave::math::round (p2(0) - p1(0));
6114 dir(1) = octave::math::round (p2(1) - p1(1));
6115 dir(2) = (p2(2) - p1(2));
6116 if (dir(0) == 0 && dir(1) == 0)
6117 m_ystate = AXE_DEPTH_DIR;
6118 else if (dir(2) == 0)
6121 m_ystate = AXE_VERT_DIR;
6122 else if (dir(1) == 0)
6123 m_ystate = AXE_HORZ_DIR;
6129 m_yPlane = (dir(0) > 0 ? y_max : y_min);
6131 m_yPlane = (dir(1) < 0 ? y_max : y_min);
6134 m_yPlane = (dir(2) < 0 ? y_min : y_max);
6136 m_yPlaneN = (m_yPlane == y_min ? y_max : y_min);
6137 m_fy = (y_max - y_min) / sqrt (dir(0)*dir(0) + dir(1)*dir(1));
6139 p1 =
xform.transform ((x_min + x_max)/2, (y_min + y_max)/2, z_min,
false);
6140 p2 =
xform.transform ((x_min + x_max)/2, (y_min + y_max)/2, z_max,
false);
6141 dir(0) = octave::math::round (p2(0) - p1(0));
6142 dir(1) = octave::math::round (p2(1) - p1(1));
6143 dir(2) = (p2(2) - p1(2));
6144 if (dir(0) == 0 && dir(1) == 0)
6145 m_zstate = AXE_DEPTH_DIR;
6146 else if (dir(2) == 0)
6149 m_zstate = AXE_VERT_DIR;
6150 else if (dir(1) == 0)
6151 m_zstate = AXE_HORZ_DIR;
6157 m_zPlane = (dir(0) > 0 ? z_min : z_max);
6159 m_zPlane = (dir(1) < 0 ? z_min : z_max);
6162 m_zPlane = (dir(2) < 0 ? z_min : z_max);
6164 m_zPlaneN = (m_zPlane == z_min ? z_max : z_min);
6165 m_fz = (z_max - z_min) / sqrt (dir(0)*dir(0) + dir(1)*dir(1));
6167 octave::unwind_protect_var<bool> restore_var (updating_axes_layout,
true);
6169 m_xySym = (xd*yd*(m_xPlane-m_xPlaneN)*(m_yPlane-m_yPlaneN) > 0);
6170 m_zSign = (zd*(m_zPlane-m_zPlaneN) <= 0);
6171 m_xyzSym = (m_zSign ? m_xySym : ! m_xySym);
6172 m_xpTick = (m_zSign ? m_xPlaneN : m_xPlane);
6173 m_ypTick = (m_zSign ? m_yPlaneN : m_yPlane);
6174 m_zpTick = (m_zSign ? m_zPlane : m_zPlaneN);
6175 m_xpTickN = (m_zSign ? m_xPlane : m_xPlaneN);
6176 m_ypTickN = (m_zSign ? m_yPlane : m_yPlaneN);
6177 m_zpTickN = (m_zSign ? m_zPlaneN : m_zPlane);
6182 m_layer2Dtop =
false;
6183 if (m_xstate == AXE_HORZ_DIR && m_ystate == AXE_VERT_DIR)
6185 Matrix ylimits = get_ylim ().matrix_value ();
6186 if (xaxislocation_is (
"top")
6187 || (yscale_is (
"log") && xaxislocation_is (
"origin")
6188 && (ylimits(1) < 0.)))
6190 std::swap (m_yPlane, m_yPlaneN);
6193 m_ypTick = m_yPlaneN;
6194 m_ypTickN = m_yPlane;
6195 Matrix xlimits = get_xlim ().matrix_value ();
6196 if (yaxislocation_is (
"right")
6197 || (xscale_is (
"log") && yaxislocation_is (
"origin")
6198 && (xlimits(1) < 0.)))
6200 std::swap (m_xPlane, m_xPlaneN);
6203 m_xpTick = m_xPlaneN;
6204 m_xpTickN = m_xPlane;
6205 if (layer_is (
"top"))
6207 m_zpTick = m_zPlaneN;
6208 m_layer2Dtop =
true;
6211 m_zpTick = m_zPlane;
6214 Matrix viewmat = get_view ().matrix_value ();
6215 m_nearhoriz = std::abs (viewmat(1)) <= 5;
6216 m_is2D = viewmat(1) == 90;
6218 update_ticklength ();
6222axes::properties::update_ticklength ()
6224 bool mode2D = (((m_xstate > AXE_DEPTH_DIR ? 1 : 0) +
6225 (m_ystate > AXE_DEPTH_DIR ? 1 : 0) +
6226 (m_zstate > AXE_DEPTH_DIR ? 1 : 0)) == 2);
6228 if (tickdirmode_is (
"auto"))
6229 m_tickdir.set (mode2D ?
"in" :
"out", true);
6232 std::string tickdir = get_tickdir ();
6233 if (tickdir ==
"in")
6235 else if (tickdir ==
"out")
6237 else if (tickdir ==
"both")
6242 Matrix bbox = get_boundingbox (
true);
6243 Matrix ticklen = get_ticklength ().matrix_value ();
6244 ticklen(0) *= std::max (bbox(2), bbox(3));
6247 ticklen(1) *= (0.76 * std::max (bbox(2), bbox(3)));
6249 m_xticklen = ticksign * (mode2D ? ticklen(0) : ticklen(1));
6250 m_yticklen = ticksign * (mode2D ? ticklen(0) : ticklen(1));
6251 m_zticklen = ticksign * (mode2D ? ticklen(0) : ticklen(1));
6253 double offset = get___fontsize_points__ () / 2;
6255 m_xtickoffset = (mode2D ? std::max (0., m_xticklen) : std::
abs (m_xticklen)) +
6256 (m_xstate == AXE_HORZ_DIR ? offset*1.5 : offset);
6257 m_ytickoffset = (mode2D ? std::max (0., m_yticklen) : std::
abs (m_yticklen)) +
6258 (m_ystate == AXE_HORZ_DIR ? offset*1.5 : offset);
6259 m_ztickoffset = (mode2D ? std::max (0., m_zticklen) : std::
abs (m_zticklen)) +
6260 (m_zstate == AXE_HORZ_DIR ? offset*1.5 : offset);
6262 update_xlabel_position ();
6263 update_ylabel_position ();
6264 update_zlabel_position ();
6265 update_title_position ();
6288 const text::properties& props,
6289 const graphics_xform&
xform,
6294 std::string to_units = props.get_units ();
6296 if (to_units !=
"data")
6302 retval(0) = v(0) - bbox(0) + 1;
6303 retval(1) = bbox(1) + bbox(3) - v(1) + 1;
6306 retval = convert_position (retval,
"pixels", to_units,
6315static bool updating_xlabel_position =
false;
6318axes::properties::update_xlabel_position ()
6320 if (updating_xlabel_position)
6323 gh_manager& gh_mgr = octave::__get_gh_manager__ ();
6325 graphics_object go = gh_mgr.
get_object (get_xlabel ());
6327 if (! go.valid_object ())
6330 text::properties& xlabel_props
6331 =
reinterpret_cast<text::properties&
> (go.get_properties ());
6333 bool isempty = xlabel_props.get_string ().isempty ();
6335 octave::unwind_protect_var<bool>
6336 restore_var (updating_xlabel_position,
true);
6340 if (xlabel_props.horizontalalignmentmode_is (
"auto"))
6342 xlabel_props.set_horizontalalignment
6343 (m_xstate > AXE_DEPTH_DIR ?
"center"
6344 : (m_xyzSym ?
"left" :
"right"));
6346 xlabel_props.set_horizontalalignmentmode (
"auto");
6349 if (xlabel_props.verticalalignmentmode_is (
"auto"))
6351 xlabel_props.set_verticalalignment
6352 (m_xstate == AXE_VERT_DIR || m_x2Dtop ?
"bottom" :
"top");
6354 xlabel_props.set_verticalalignmentmode (
"auto");
6358 if (xlabel_props.positionmode_is (
"auto")
6359 || xlabel_props.rotationmode_is (
"auto"))
6361 graphics_xform
xform = get_transform ();
6364 ext = get_ticklabel_extents (get_xtick ().matrix_value (),
6365 get_xticklabel ().string_vector_value (),
6366 get_xlim ().matrix_value ());
6369 double wmax = ext(0) + margin;
6370 double hmax = ext(1) + margin;
6373 = graphics_xform::xform_vector ((m_xpTickN + m_xpTick)/2, m_ypTick, m_zpTick);
6375 bool tick_along_z = m_nearhoriz || octave::math::isinf (m_fy);
6377 p(2) += (octave::math::signum (m_zpTick - m_zpTickN) * m_fz * m_xtickoffset);
6379 p(1) += (octave::math::signum (m_ypTick - m_ypTickN) * m_fy * m_xtickoffset);
6381 p =
xform.transform (p(0), p(1), p(2),
false);
6386 p(0) += (m_xyzSym ? wmax : -wmax);
6396 p(1) += (m_x2Dtop ? -hmax : hmax);
6400 if (xlabel_props.positionmode_is (
"auto"))
6402 p =
xform.untransform (p(0), p(1), p(2),
true);
6404 p = convert_label_position (p, xlabel_props,
xform,
6405 get_extent (
false));
6408 xlabel_props.set_positionmode (
"auto");
6411 if (! isempty && xlabel_props.rotationmode_is (
"auto"))
6413 xlabel_props.set_rotation (angle);
6414 xlabel_props.set_rotationmode (
"auto");
6419static bool updating_ylabel_position =
false;
6422axes::properties::update_ylabel_position ()
6424 if (updating_ylabel_position)
6427 gh_manager& gh_mgr = octave::__get_gh_manager__ ();
6429 graphics_object go = gh_mgr.
get_object (get_ylabel ());
6431 if (! go.valid_object ())
6434 text::properties& ylabel_props
6435 =
reinterpret_cast<text::properties&
> (go.get_properties ());
6437 bool isempty = ylabel_props.get_string ().isempty ();
6439 octave::unwind_protect_var<bool>
6440 restore_var (updating_ylabel_position,
true);
6444 if (ylabel_props.horizontalalignmentmode_is (
"auto"))
6446 ylabel_props.set_horizontalalignment
6447 (m_ystate > AXE_DEPTH_DIR ?
"center"
6448 : (! m_xyzSym ?
"left" :
"right"));
6450 ylabel_props.set_horizontalalignmentmode (
"auto");
6453 if (ylabel_props.verticalalignmentmode_is (
"auto"))
6455 ylabel_props.set_verticalalignment
6456 (m_ystate == AXE_VERT_DIR && ! m_y2Dright ?
"bottom" :
"top");
6458 ylabel_props.set_verticalalignmentmode (
"auto");
6462 if (ylabel_props.positionmode_is (
"auto")
6463 || ylabel_props.rotationmode_is (
"auto"))
6465 graphics_xform
xform = get_transform ();
6469 ext = get_ticklabel_extents (get_ytick ().matrix_value (),
6470 get_yticklabel ().string_vector_value (),
6471 get_ylim ().matrix_value ());
6473 double wmax = ext(0) + margin;
6474 double hmax = ext(1) + margin;
6477 = graphics_xform::xform_vector (m_xpTick, (m_ypTickN + m_ypTick)/2, m_zpTick);
6479 bool tick_along_z = m_nearhoriz || octave::math::isinf (m_fx);
6481 p(2) += (octave::math::signum (m_zpTick - m_zpTickN) * m_fz * m_ytickoffset);
6483 p(0) += (octave::math::signum (m_xpTick - m_xpTickN) * m_fx * m_ytickoffset);
6485 p =
xform.transform (p(0), p(1), p(2),
false);
6490 p(0) += (! m_xyzSym ? wmax : -wmax);
6495 p(0) += (m_y2Dright ? wmax : -wmax);
6504 if (ylabel_props.positionmode_is (
"auto"))
6506 p =
xform.untransform (p(0), p(1), p(2),
true);
6508 p = convert_label_position (p, ylabel_props,
xform,
6509 get_extent (
false));
6512 ylabel_props.set_positionmode (
"auto");
6515 if (! isempty && ylabel_props.rotationmode_is (
"auto"))
6517 ylabel_props.set_rotation (angle);
6518 ylabel_props.set_rotationmode (
"auto");
6523static bool updating_zlabel_position =
false;
6526axes::properties::update_zlabel_position ()
6528 if (updating_zlabel_position)
6531 gh_manager& gh_mgr = octave::__get_gh_manager__ ();
6533 graphics_object go = gh_mgr.
get_object (get_zlabel ());
6535 if (! go.valid_object ())
6538 text::properties& zlabel_props
6539 =
reinterpret_cast<text::properties&
> (go.get_properties ());
6541 bool camAuto = cameraupvectormode_is (
"auto");
6542 bool isempty = zlabel_props.get_string ().isempty ();
6544 octave::unwind_protect_var<bool>
6545 restore_updating_zlabel_position (updating_zlabel_position,
true);
6549 if (zlabel_props.horizontalalignmentmode_is (
"auto"))
6551 zlabel_props.set_horizontalalignment
6552 ((m_zstate > AXE_DEPTH_DIR || camAuto) ?
"center" :
"right");
6554 zlabel_props.set_horizontalalignmentmode (
"auto");
6557 if (zlabel_props.verticalalignmentmode_is (
"auto"))
6559 zlabel_props.set_verticalalignment
6560 (m_zstate == AXE_VERT_DIR
6561 ?
"bottom" : ((m_zSign || camAuto) ?
"bottom" :
"top"));
6563 zlabel_props.set_verticalalignmentmode (
"auto");
6567 if (zlabel_props.positionmode_is (
"auto")
6568 || zlabel_props.rotationmode_is (
"auto"))
6570 graphics_xform
xform = get_transform ();
6573 ext = get_ticklabel_extents (get_ztick ().matrix_value (),
6574 get_zticklabel ().string_vector_value (),
6575 get_zlim ().matrix_value ());
6578 double wmax = ext(0) + margin;
6579 double hmax = ext(1) + margin;
6585 p = graphics_xform::xform_vector (m_xPlaneN, m_yPlane,
6586 (m_zpTickN + m_zpTick)/2);
6587 if (octave::math::isinf (m_fy))
6588 p(0) += octave::math::signum (m_xPlaneN - m_xPlane) * m_fx * m_ztickoffset;
6590 p(1) += octave::math::signum (m_yPlane - m_yPlaneN) * m_fy * m_ztickoffset;
6594 p = graphics_xform::xform_vector (m_xPlane, m_yPlaneN,
6595 (m_zpTickN + m_zpTick)/2);
6596 if (octave::math::isinf (m_fx))
6597 p(1) += octave::math::signum (m_yPlaneN - m_yPlane) * m_fy * m_ztickoffset;
6599 p(0) += octave::math::signum (m_xPlane - m_xPlaneN) * m_fx * m_ztickoffset;
6602 p =
xform.transform (p(0), p(1), p(2),
false);
6630 if (zlabel_props.positionmode_is (
"auto"))
6632 p =
xform.untransform (p(0), p(1), p(2),
true);
6634 p = convert_label_position (p, zlabel_props,
xform,
6635 get_extent (
false));
6638 zlabel_props.set_positionmode (
"auto");
6641 if (! isempty && zlabel_props.rotationmode_is (
"auto"))
6643 zlabel_props.set_rotation (angle);
6644 zlabel_props.set_rotationmode (
"auto");
6649static bool updating_title_position =
false;
6652axes::properties::update_title_position ()
6654 if (updating_title_position)
6657 gh_manager& gh_mgr = octave::__get_gh_manager__ ();
6659 graphics_object go = gh_mgr.
get_object (get_title ());
6661 if (! go.valid_object ())
6664 text::properties& title_props
6665 =
reinterpret_cast<text::properties&
> (go.get_properties ());
6667 octave::unwind_protect_var<bool> restore_var (updating_title_position,
true);
6669 if (title_props.positionmode_is (
"auto"))
6671 graphics_xform
xform = get_transform ();
6674 Matrix bbox = get_extent (
false);
6677 = graphics_xform::xform_vector (bbox(0) + bbox(2)/2, bbox(1) - 10,
6678 (m_x_zlim(0) + m_x_zlim(1))/2);
6683 ext = get_ticklabel_extents (get_xtick ().matrix_value (),
6684 get_xticklabel ().string_vector_value (),
6685 get_xlim ().matrix_value ());
6689 p =
xform.untransform (p(0), p(1), p(2),
true);
6691 p = convert_label_position (p, title_props,
xform, bbox);
6694 title_props.set_positionmode (
"auto");
6699axes::properties::update_autopos (
const std::string& elem_type)
6701 if (elem_type ==
"xlabel")
6702 update_xlabel_position ();
6703 else if (elem_type ==
"ylabel")
6704 update_ylabel_position ();
6705 else if (elem_type ==
"zlabel")
6706 update_zlabel_position ();
6707 else if (elem_type ==
"title")
6708 update_title_position ();
6709 else if (elem_type ==
"sync")
6714normalized_aspectratios (
Matrix& aspectratios,
const Matrix& scalefactors,
6715 double xlength,
double ylength,
double zlength)
6717 double xval = xlength / scalefactors(0);
6718 double yval = ylength / scalefactors(1);
6719 double zval = zlength / scalefactors(2);
6721 double minval = octave::math::min (octave::math::min (xval, yval), zval);
6723 aspectratios(0) = xval / minval;
6724 aspectratios(1) = yval / minval;
6725 aspectratios(2) = zval / minval;
6729max_axes_scale (
double& s,
Matrix& limits,
const Matrix& kids,
6730 double pbfactor,
double dafactor,
char limit_type,
bool tight)
6734 double minval = octave::numeric_limits<double>::Inf ();
6735 double maxval = -octave::numeric_limits<double>::Inf ();
6736 double min_pos = octave::numeric_limits<double>::Inf ();
6737 double max_neg = -octave::numeric_limits<double>::Inf ();
6739 if (octave::math::isfinite (minval) && octave::math::isfinite (maxval))
6743 s = octave::math::max (s, (maxval - minval) / (pbfactor * dafactor));
6747 s = octave::math::max (s, (limits(1) - limits(0)) / (pbfactor * dafactor));
6750static std::set<double> updating_aspectratios;
6753axes::properties::update_aspectratios ()
6755 if (updating_aspectratios.find (get___myhandle__ ().value ())
6756 != updating_aspectratios.end ())
6759 Matrix xlimits = get_xlim ().matrix_value ();
6760 Matrix ylimits = get_ylim ().matrix_value ();
6761 Matrix zlimits = get_zlim ().matrix_value ();
6763 double dx = (xlimits(1) - xlimits(0));
6764 double dy = (ylimits(1) - ylimits(0));
6765 double dz = (zlimits(1) - zlimits(0));
6767 Matrix da = get_dataaspectratio ().matrix_value ();
6768 Matrix pba = get_plotboxaspectratio ().matrix_value ();
6770 if (dataaspectratiomode_is (
"auto"))
6772 if (plotboxaspectratiomode_is (
"auto"))
6774 pba =
Matrix (1, 3, 1.0);
6775 m_plotboxaspectratio.set (pba,
false);
6778 normalized_aspectratios (da, pba, dx, dy, dz);
6779 m_dataaspectratio.set (da,
false);
6781 else if (plotboxaspectratiomode_is (
"auto"))
6783 normalized_aspectratios (pba, da, dx, dy, dz);
6784 m_plotboxaspectratio.set (pba,
false);
6788 double s = -octave::numeric_limits<double>::Inf ();
6789 bool modified_limits =
false;
6792 if (xlimmode_is (
"auto") && ylimmode_is (
"auto") && zlimmode_is (
"auto"))
6794 modified_limits =
true;
6795 kids = get_children ();
6796 max_axes_scale (s, xlimits, kids, pba(0), da(0),
'x',
true);
6797 max_axes_scale (s, ylimits, kids, pba(1), da(1),
'y',
true);
6798 max_axes_scale (s, zlimits, kids, pba(2), da(2),
'z',
true);
6800 else if (xlimmode_is (
"auto") && ylimmode_is (
"auto"))
6802 modified_limits =
true;
6803 max_axes_scale (s, zlimits, kids, pba(2), da(2),
'z',
false);
6805 else if (ylimmode_is (
"auto") && zlimmode_is (
"auto"))
6807 modified_limits =
true;
6808 max_axes_scale (s, xlimits, kids, pba(0), da(0),
'x',
false);
6810 else if (zlimmode_is (
"auto") && xlimmode_is (
"auto"))
6812 modified_limits =
true;
6813 max_axes_scale (s, ylimits, kids, pba(1), da(1),
'y',
false);
6816 if (modified_limits)
6818 octave::unwind_protect_var<std::set<double>>
6819 restore_var (updating_aspectratios);
6821 updating_aspectratios.insert (get___myhandle__ ().value ());
6823 dx = pba(0) * da(0);
6824 dy = pba(1) * da(1);
6825 dz = pba(2) * da(2);
6826 if (octave::math::isinf (s))
6827 s = 1 / octave::math::min (octave::math::min (dx, dy), dz);
6829 if (xlimmode_is (
"auto"))
6832 xlimits(0) = 0.5 * (xlimits(0) + xlimits(1) - dx);
6833 xlimits(1) = xlimits(0) + dx;
6835 set_xlimmode (
"auto");
6838 if (ylimmode_is (
"auto"))
6841 ylimits(0) = 0.5 * (ylimits(0) + ylimits(1) - dy);
6842 ylimits(1) = ylimits(0) + dy;
6844 set_ylimmode (
"auto");
6847 if (zlimmode_is (
"auto"))
6850 zlimits(0) = 0.5 * (zlimits(0) + zlimits(1) - dz);
6851 zlimits(1) = zlimits(0) + dz;
6853 set_zlimmode (
"auto");
6858 normalized_aspectratios (pba, da, dx, dy, dz);
6859 m_plotboxaspectratio.set (pba,
false);
6865axes::properties::update_label_color (handle_property label,
6868 gh_manager& gh_mgr = octave::__get_gh_manager__ ();
6870 gh_mgr.
get_object (label.handle_value ()).set (
"color", col.get ());
6874axes::properties::update_font (std::string prop)
6876 gh_manager& gh_mgr = octave::__get_gh_manager__ ();
6878 if (! prop.empty ())
6882 if (prop ==
"fontsize")
6885 get_titlefontsizemultiplier ());
6887 get_labelfontsizemultiplier ());
6889 else if (prop ==
"fontweight")
6890 tval = get (
"titlefontweight");
6892 gh_mgr.
get_object (get_xlabel ()).set (prop, val);
6893 gh_mgr.
get_object (get_ylabel ()).set (prop, val);
6894 gh_mgr.
get_object (get_zlabel ()).set (prop, val);
6895 gh_mgr.
get_object (get_title ()).set (prop, tval);
6898 double dpr = device_pixel_ratio (get___myhandle__ ());
6902 m_txt_renderer.set_font (get (
"fontname").string_value (),
6903 get (
"fontweight").string_value (),
6904 get (
"fontangle").string_value (),
6905 get (
"__fontsize_points__").double_value () * dpr);
6911axes::properties::get_boundingbox (
bool internal,
6912 const Matrix& parent_pix_size)
const
6914 Matrix pos = (internal ? get_position ().matrix_value ()
6915 : get_outerposition ().matrix_value ());
6916 Matrix parent_size (parent_pix_size);
6918 if (parent_size.isempty ())
6920 gh_manager& gh_mgr = octave::__get_gh_manager__ ();
6922 graphics_object go = gh_mgr.
get_object (get_parent ());
6924 if (go.valid_object ())
6926 = go.get_properties ().get_boundingbox (
true).extract_n (0, 2, 1, 2);
6928 parent_size = default_figure_position ();
6931 pos = convert_position (pos, get_units (),
"pixels", parent_size);
6935 pos(1) = parent_size(1) - pos(1) - pos(3);
6941axes::properties::get_extent (
bool with_text,
bool only_text_height)
const
6943 graphics_xform
xform = get_transform ();
6946 ext(0) = ext(1) = octave::numeric_limits<double>::Inf ();
6947 ext(2) = ext(3) = -octave::numeric_limits<double>::Inf ();
6948 for (
int i = 0; i <= 1; i++)
6949 for (
int j = 0; j <= 1; j++)
6950 for (
int k = 0; k <= 1; k++)
6953 j ? m_yPlaneN : m_yPlane,
6954 k ? m_zPlaneN : m_zPlane, false);
6955 ext(0) = std::min (ext(0), p(0));
6956 ext(1) = std::min (ext(1), p(1));
6957 ext(2) = std::max (ext(2), p(0));
6958 ext(3) = std::max (ext(3), p(1));
6963 for (
int i = 0; i < 4; i++)
6967 htext = get_title ();
6969 htext = get_xlabel ();
6971 htext = get_ylabel ();
6973 htext = get_zlabel ();
6975 gh_manager& gh_mgr = octave::__get_gh_manager__ ();
6977 text::properties& text_props
6978 =
reinterpret_cast<text::properties&
>
6979 (gh_mgr.
get_object (htext).get_properties ());
6981 Matrix text_pos = text_props.get_data_position ();
6982 text_pos =
xform.transform (text_pos(0), text_pos(1), text_pos(2));
6983 if (text_props.get_string ().isempty ())
6985 ext(0) = std::min (ext(0), text_pos(0));
6986 ext(1) = std::min (ext(1), text_pos(1));
6987 ext(2) = std::max (ext(2), text_pos(0));
6988 ext(3) = std::max (ext(3), text_pos(1));
6992 Matrix text_ext = text_props.get_extent_matrix (
true);
6996 double dpr = device_pixel_ratio (get___myhandle__ ());
6998 for (
int j = 0; j < 4; j++)
7001 bool ignore_horizontal =
false;
7002 bool ignore_vertical =
false;
7003 if (only_text_height)
7005 double text_rotation = text_props.get_rotation ();
7006 if (text_rotation == 0. || text_rotation == 180.)
7007 ignore_horizontal =
true;
7008 else if (text_rotation == 90. || text_rotation == 270.)
7009 ignore_vertical =
true;
7012 if (! ignore_horizontal)
7014 ext(0) = std::min (ext(0), text_pos(0)+text_ext(0));
7015 ext(2) = std::max (ext(2),
7016 text_pos(0)+text_ext(0)+text_ext(2));
7019 if (! ignore_vertical)
7021 ext(1) = std::min (ext(1),
7022 text_pos(1)-text_ext(1)-text_ext(3));
7023 ext(3) = std::max (ext(3), text_pos(1)-text_ext(1));
7029 ext(2) = ext(2) - ext(0);
7030 ext(3) = ext(3) - ext(1);
7052 std::ostringstream oss;
7060 if (std::abs (data(i)) < 1.0)
7071 std::istringstream iss (valstr);
7075 while (std::getline (iss, tmpstr,
'|'))
7079 if (*valstr.rbegin () ==
'|')
7080 sv.
append (std::string (
""));
7094axes::properties::set_xticklabel (
const octave_value& val)
7096 if (m_xticklabel.set (convert_ticklabel_string (val),
false))
7098 set_xticklabelmode (
"manual");
7099 m_xticklabel.run_listeners (GCB_POSTSET);
7103 set_xticklabelmode (
"manual");
7109axes::properties::set_yticklabel (
const octave_value& val)
7111 if (m_yticklabel.set (convert_ticklabel_string (val),
false))
7113 set_yticklabelmode (
"manual");
7114 m_yticklabel.run_listeners (GCB_POSTSET);
7118 set_yticklabelmode (
"manual");
7124axes::properties::set_zticklabel (
const octave_value& val)
7126 if (m_zticklabel.set (convert_ticklabel_string (val),
false))
7128 set_zticklabelmode (
"manual");
7129 m_zticklabel.run_listeners (GCB_POSTSET);
7133 set_zticklabelmode (
"manual");
7157 std::istringstream iss (valstr);
7161 while (std::getline (iss, tmpstr,
'|'))
7165 if (*valstr.rbegin () ==
'|')
7166 sv.
append (std::string (
""));
7180axes::properties::set_linestyleorder (
const octave_value& val)
7182 m_linestyleorder.set (convert_linestyleorder_string (val),
false);
7190 if (m_units.set (val,
true))
7192 update_units (old_units);
7198axes::properties::update_units (
const caseless_str& old_units)
7200 gh_manager& gh_mgr = octave::__get_gh_manager__ ();
7202 graphics_object parent_go = gh_mgr.
get_object (get_parent ());
7205 = parent_go.get_properties ().get_boundingbox (
true).
extract_n (0, 2, 1, 2);
7209 (convert_position (get_position ().matrix_value (),
7210 old_units, new_units, parent_bb)),
7213 (convert_position (get_outerposition ().matrix_value (),
7214 old_units, new_units, parent_bb)),
7217 (convert_position (get_tightinset ().matrix_value (),
7218 old_units, new_units, parent_bb)),
7221 (convert_position (get_looseinset ().matrix_value (),
7222 old_units, new_units, parent_bb)),
7227axes::properties::set_fontunits (
const octave_value& val)
7231 if (m_fontunits.set (val,
true))
7233 update_fontunits (old_fontunits);
7239axes::properties::update_fontunits (
const caseless_str& old_units)
7242 double parent_height = get_boundingbox (
true).elem (3);
7243 double fontsz = get_fontsize ();
7245 fontsz = convert_font_size (fontsz, old_units, new_units, parent_height);
7251axes::properties::get___fontsize_points__ (
double box_pix_height)
const
7253 double fontsz = get_fontsize ();
7254 double parent_height = box_pix_height;
7256 if (fontunits_is (
"normalized") && parent_height <= 0)
7257 parent_height = get_boundingbox (
true).elem (3);
7259 return convert_font_size (fontsz, get_fontunits (),
"points", parent_height);
7263graphics_xform::xform_vector (
double x,
double y,
double z)
7265 return octave::xform_vector (
x, y, z);
7269graphics_xform::xform_eye ()
7271 return octave::xform_matrix ();
7275graphics_xform::transform (
double x,
double y,
double z,
bool use_scale)
const
7284 return octave::transform (m_xform,
x, y, z);
7288graphics_xform::untransform (
double x,
double y,
double z,
7289 bool use_scale)
const
7295 v(0) = m_sx.unscale (v(0));
7296 v(1) = m_sy.unscale (v(1));
7297 v(2) = m_sz.unscale (v(2));
7306 octave_value retval = m_default_properties.lookup (pname);
7312 gh_manager& gh_mgr = octave::__get_gh_manager__ ();
7314 graphics_object parent_go = gh_mgr.
get_object (parent_h);
7316 retval = parent_go.get_default (pname);
7346check_limit_vals (
double& min_val,
double& max_val,
7347 double& min_pos,
double& max_neg,
7355 if (m.
numel () != 4)
7358 m(2) = octave::numeric_limits<double>::Inf ();
7359 m(3) = -octave::numeric_limits<double>::Inf ();
7365 if (octave::math::isfinite (val) && val < min_val)
7369 if (octave::math::isfinite (val) && val > max_val)
7373 if (octave::math::isfinite (val) && val > 0 && val < min_pos)
7377 if (octave::math::isfinite (val) && val < 0 && val > max_neg)
7385magform (
double x,
double& a,
int& b)
7394 b =
static_cast<int> (std::floor (std::log10 (std::abs (
x))));
7395 a =
x / std::pow (10.0, b);
7400axes::properties::update_outerposition ()
7402 set_positionconstraint (
"outerposition");
7404 set_units (
"normalized");
7406 Matrix outerbox = m_outerposition.get ().matrix_value ();
7408 double outer_left = outerbox(0);
7409 double outer_bottom = outerbox(1);
7410 double outer_width = outerbox(2);
7411 double outer_height = outerbox(3);
7413 double outer_right = outer_width + outer_left;
7414 double outer_top = outer_height + outer_bottom;
7416 Matrix linset = m_looseinset.get ().matrix_value ();
7417 Matrix tinset = m_tightinset.get ().matrix_value ();
7419 double left_margin = std::max (linset(0), tinset(0));
7420 double bottom_margin = std::max (linset(1), tinset(1));
7421 double right_margin = std::max (linset(2), tinset(2));
7422 double top_margin = std::max (linset(3), tinset(3));
7424 double inner_left = outer_left;
7425 double inner_right = outer_right;
7427 if ((left_margin + right_margin) < outer_width)
7429 inner_left += left_margin;
7430 inner_right -= right_margin;
7433 double inner_bottom = outer_bottom;
7434 double inner_top = outer_top;
7436 if ((bottom_margin + top_margin) < outer_height)
7438 inner_bottom += bottom_margin;
7439 inner_top -= top_margin;
7442 double inner_width = inner_right - inner_left;
7443 double inner_height = inner_top - inner_bottom;
7447 innerbox(0) = inner_left;
7448 innerbox(1) = inner_bottom;
7449 innerbox(2) = inner_width;
7450 innerbox(3) = inner_height;
7452 m_position = innerbox;
7454 set_units (old_units);
7455 update_transform ();
7459axes::properties::update_position ()
7461 set_positionconstraint (
"innerposition");
7463 set_units (
"normalized");
7465 Matrix innerbox = m_position.get ().matrix_value ();
7467 double inner_left = innerbox(0);
7468 double inner_bottom = innerbox(1);
7469 double inner_width = innerbox(2);
7470 double inner_height = innerbox(3);
7472 double inner_right = inner_width + inner_left;
7473 double inner_top = inner_height + inner_bottom;
7475 Matrix linset = m_looseinset.get ().matrix_value ();
7476 Matrix tinset = m_tightinset.get ().matrix_value ();
7478 double left_margin = std::max (linset(0), tinset(0));
7479 double bottom_margin = std::max (linset(1), tinset(1));
7480 double right_margin = std::max (linset(2), tinset(2));
7481 double top_margin = std::max (linset(3), tinset(3));
7485 double outer_left = inner_left - left_margin;
7486 double outer_bottom = inner_bottom - bottom_margin;
7487 double outer_right = inner_right + right_margin;
7488 double outer_top = inner_top + top_margin;
7490 double outer_width = outer_right - outer_left;
7491 double outer_height = outer_top - outer_bottom;
7495 outerbox(0) = outer_left;
7496 outerbox(1) = outer_bottom;
7497 outerbox(2) = outer_width;
7498 outerbox(3) = outer_height;
7500 m_outerposition = outerbox;
7502 set_units (old_units);
7503 update_transform ();
7507axes::properties::update_looseinset ()
7510 set_units (
"normalized");
7512 Matrix linset = m_looseinset.get ().matrix_value ();
7513 Matrix tinset = m_tightinset.get ().matrix_value ();
7515 double left_margin = std::max (linset(0), tinset(0));
7516 double bottom_margin = std::max (linset(1), tinset(1));
7517 double right_margin = std::max (linset(2), tinset(2));
7518 double top_margin = std::max (linset(3), tinset(3));
7520 if (m_positionconstraint.is (
"innerposition"))
7522 Matrix innerbox = m_position.get ().matrix_value ();
7524 double inner_left = innerbox(0);
7525 double inner_bottom = innerbox(1);
7526 double inner_width = innerbox(2);
7527 double inner_height = innerbox(3);
7529 double inner_right = inner_width + inner_left;
7530 double inner_top = inner_height + inner_bottom;
7534 double outer_left = inner_left - left_margin;
7535 double outer_bottom = inner_bottom - bottom_margin;
7536 double outer_right = inner_right + right_margin;
7537 double outer_top = inner_top + top_margin;
7539 double outer_width = outer_right - outer_left;
7540 double outer_height = outer_top - outer_bottom;
7544 outerbox(0) = outer_left;
7545 outerbox(1) = outer_bottom;
7546 outerbox(2) = outer_width;
7547 outerbox(3) = outer_height;
7549 m_outerposition = outerbox;
7553 Matrix outerbox = m_outerposition.get ().matrix_value ();
7555 double outer_left = outerbox(0);
7556 double outer_bottom = outerbox(1);
7557 double outer_width = outerbox(2);
7558 double outer_height = outerbox(3);
7560 double outer_right = outer_width + outer_left;
7561 double outer_top = outer_height + outer_bottom;
7563 double inner_left = outer_left;
7564 double inner_right = outer_right;
7566 if ((left_margin + right_margin) < outer_width)
7568 inner_left += left_margin;
7569 inner_right -= right_margin;
7572 double inner_bottom = outer_bottom;
7573 double inner_top = outer_top;
7575 if ((bottom_margin + top_margin) < outer_height)
7577 inner_bottom += bottom_margin;
7578 inner_top -= top_margin;
7581 double inner_width = inner_right - inner_left;
7582 double inner_height = inner_top - inner_bottom;
7586 innerbox(0) = inner_left;
7587 innerbox(1) = inner_bottom;
7588 innerbox(2) = inner_width;
7589 innerbox(3) = inner_height;
7591 m_position = innerbox;
7594 set_units (old_units);
7595 update_transform ();
7603axes::properties::calc_tick_sep (
double lo,
double hi)
7615 magform ((hi - lo) / ticint, a, b);
7617 static const double SQRT_2 = sqrt (2.0);
7618 static const double SQRT_10 = sqrt (10.0);
7619 static const double SQRT_50 = sqrt (50.0);
7623 else if (a < SQRT_10)
7625 else if (a < SQRT_50)
7630 return x * std::pow (10.0, b);
7637axes::properties::get_axis_limits (
double xmin,
double xmax,
7638 double min_pos,
double max_neg,
7639 const bool logscale,
7640 const std::string& method)
7644 double min_val =
xmin;
7645 double max_val =
xmax;
7647 if (octave::math::isinf (min_val) && min_val > 0
7648 && octave::math::isinf (max_val) && max_val < 0)
7650 retval = default_lim (logscale);
7653 else if (! (octave::math::isinf (min_val) || octave::math::isinf (max_val)))
7657 if (octave::math::isinf (min_pos) && octave::math::isinf (max_neg))
7662 retval = default_lim (logscale);
7670 "axis: omitting non-positive data in log plot");
7673 else if (max_val == 0)
7677 if (std::abs (min_val - max_val)
7678 < sqrt (std::numeric_limits<double>::epsilon ()))
7693 if (method ==
"tickaligned")
7698 min_val = std::pow (10, std::floor (log10 (min_val)));
7699 max_val = std::pow (10, std::ceil (log10 (max_val)));
7704 min_val = -std::pow (10, std::ceil (log10 (-min_val)));
7705 max_val = -std::pow (10, std::floor (log10 (-max_val)));
7708 else if (method ==
"padded")
7713 double pad = (log10 (max_val) - log10 (min_val)) * 0.07;
7714 min_val = std::pow (10, log10 (min_val) - pad);
7715 max_val = std::pow (10, log10 (max_val) + pad);
7720 double pad = (log10 (-min_val) - log10 (-max_val)) * 0.07;
7721 min_val = -std::pow (10, log10 (-min_val) + pad);
7722 max_val = -std::pow (10, log10 (-max_val) - pad);
7728 if (min_val == 0 && max_val == 0)
7734 else if (std::abs (min_val - max_val)
7735 < sqrt (std::numeric_limits<double>::epsilon ()))
7737 min_val -= 0.1 * std::abs (min_val);
7738 max_val += 0.1 * std::abs (max_val);
7741 if (method ==
"tickaligned")
7743 double tick_sep = calc_tick_sep (min_val, max_val);
7744 double min_tick = std::floor (min_val / tick_sep);
7745 double max_tick = std::ceil (max_val / tick_sep);
7747 min_val = std::min (min_val, tick_sep * min_tick);
7748 max_val = std::max (max_val, tick_sep * max_tick);
7750 else if (method ==
"padded")
7752 double pad = 0.07 * (max_val - min_val);
7761 retval(0) = min_val;
7762 retval(1) = max_val;
7768axes::properties::check_axis_limits (
Matrix& limits,
const Matrix kids,
7769 const bool logscale,
char& update_type)
7771 double min_val = octave::numeric_limits<double>::Inf ();
7772 double max_val = -octave::numeric_limits<double>::Inf ();
7773 double min_pos = octave::numeric_limits<double>::Inf ();
7774 double max_neg = -octave::numeric_limits<double>::Inf ();
7775 double eps = std::numeric_limits<double>::epsilon ();
7776 bool do_update =
false;
7777 bool have_children_limits =
false;
7780 if (! octave::math::isfinite (limits(0))
7781 || ! octave::math::isfinite (limits(1)))
7785 have_children_limits =
true;
7787 if (! octave::math::isfinite (limits(0)))
7789 limits(0) = min_val;
7792 if (! octave::math::isfinite (limits(1)))
7794 limits(1) = max_val;
7797 if (limits(0) == 0 && limits(1) == 0)
7799 limits = default_lim (logscale);
7803 else if (! logscale && (std::abs (limits(0) - limits(1)) < sqrt (
eps)))
7805 limits(0) -= 0.1 * std::abs (limits(0));
7806 limits(1) += 0.1 * std::abs (limits(1));
7810 && (std::abs (std::log10 (limits(0) / limits(1))) < sqrt (
eps)))
7812 limits(0) = (limits(0) < 0 ? 10.0 * limits(0) : 0.1 * limits(0));
7813 limits(1) = (limits(1) < 0 ? 0.1 * limits(1) : 10.0 * limits(1));
7817 if (logscale && limits(0)*limits(1) <= 0)
7819 if (! have_children_limits)
7826 "Non-positive limit for logarithmic axis ignored\n");
7827 if (octave::math::isfinite (min_pos))
7828 limits(0) = min_pos;
7830 limits(0) = 0.1 * limits(1);
7835 "Non-negative limit for logarithmic axis ignored\n");
7836 if (octave::math::isfinite (max_neg))
7837 limits(1) = max_neg;
7839 limits(1) = 0.1 * limits(0);
7842 if (std::abs (limits(0) - limits(1)) < sqrt (
eps))
7994axes::properties::calc_ticks_and_lims (array_property& lims,
7995 array_property& ticks,
7996 array_property& mticks,
7997 bool limmode_is_auto,
7998 bool tickmode_is_auto,
7999 bool minortickvaluesmode_is_auto,
8001 bool method_is_padded,
8002 bool method_is_tight)
8004 if (lims.get ().isempty ())
8007 double lo = (lims.get ().matrix_value ())(0);
8008 double hi = (lims.get ().matrix_value ())(1);
8012 bool is_negative = lo < 0 && hi < 0;
8023 hi = std::log10 (-lo);
8024 lo = std::log10 (-tmp);
8028 hi = std::log10 (hi);
8029 lo = std::log10 (lo);
8034 if (tickmode_is_auto)
8040 if (! (octave::math::isinf (hi) || octave::math::isinf (lo)))
8046 tick_sep = calc_tick_sep (lo, hi);
8048 double i1 = std::floor (lo / tick_sep);
8049 double i2 = std::ceil (hi / tick_sep);
8051 if (limmode_is_auto)
8055 if (! method_is_padded && ! method_is_tight)
8058 tmp_lims(0) = std::min (tick_sep * i1, lo);
8059 tmp_lims(1) = std::max (tick_sep * i2, hi);
8067 if (i1*tick_sep < lo)
8069 if (i2*tick_sep > hi && i2 > i1)
8075 tmp_lims(0) = std::pow (10., tmp_lims(0));
8076 tmp_lims(1) = std::pow (10., tmp_lims(1));
8078 if (tmp_lims(0) <= 0)
8079 tmp_lims(0) = std::pow (10., lo);
8083 double tmp = tmp_lims(0);
8084 tmp_lims(0) = -tmp_lims(1);
8094 if (i1*tick_sep < lo)
8096 if (i2*tick_sep > hi && i2 > i1)
8100 tmp_ticks =
Matrix (1, i2-i1+1);
8101 for (
int i = 0; i <= static_cast<int> (i2-i1); i++)
8103 tmp_ticks(i) = tick_sep * (i+i1);
8105 tmp_ticks(i) = std::pow (10., tmp_ticks(i));
8107 if (is_logscale && is_negative)
8109 Matrix rev_ticks (1, i2-i1+1);
8110 rev_ticks = -tmp_ticks;
8111 for (
int i = 0; i <= static_cast<int> (i2-i1); i++)
8112 tmp_ticks(i) = rev_ticks(i2-i1-i);
8118 tmp_ticks = ticks.get ().matrix_value ();
8125 if (minortickvaluesmode_is_auto)
8127 const int MAX_MINOR_TICKS = 1000;
8128 int n = (is_logscale ? 8 : 4);
8129 double mult_below = (is_logscale ? tmp_ticks(1) / tmp_ticks(0) : 1);
8130 double mult_above = (is_logscale ?
8131 tmp_ticks(n_ticks-1) / tmp_ticks(n_ticks-2) : 1);
8133 double d_below = (tmp_ticks(1) - tmp_ticks(0)) / mult_below / (n+1);
8134 int n_below =
static_cast<int> (std::floor ((tmp_ticks(0)-lo_lim)
8138 else if (n_below > MAX_MINOR_TICKS)
8139 n_below = MAX_MINOR_TICKS;
8141 int n_between = n * (n_ticks - 1);
8142 double d_above = (tmp_ticks(n_ticks-1) - tmp_ticks(n_ticks-2))
8145 int n_above =
static_cast<int> (std::floor ((hi_lim-tmp_ticks(n_ticks-1))
8149 else if (n_above > MAX_MINOR_TICKS)
8150 n_above = MAX_MINOR_TICKS;
8152 Matrix tmp_mticks (1, n_below + n_between + n_above);
8153 for (
int i = 0; i < n_below; i++)
8154 tmp_mticks(i) = tmp_ticks(0) - (n_below-i) * d_below;
8155 for (
int i = 0; i < n_ticks-1; i++)
8157 double d = (tmp_ticks(i+1) - tmp_ticks(i)) / (n + 1);
8158 for (
int j = 0; j < n; j++)
8159 tmp_mticks(n_below+n*i+j) = tmp_ticks(i) +
d * (j+1);
8161 for (
int i = 0; i < n_above; i++)
8162 tmp_mticks(n_below+n_between+i) = tmp_ticks(n_ticks-1) + (i + 1)
8165 mticks = tmp_mticks;
8183axes::properties::calc_ticklabels (
const array_property& ticks,
8184 any_property& labels,
bool logscale,
8185 const bool is_origin,
8186 const int other_axislocation,
8187 const array_property& axis_lims)
8189 Matrix values = ticks.get ().matrix_value ();
8190 Matrix lims = axis_lims.get ().matrix_value ();
8192 std::ostringstream os;
8195 ColumnVector omit_ticks (3, octave::numeric_limits<double>::NaN ());
8196 if (get_is2D () && is_origin)
8198 if (other_axislocation == 0)
8200 omit_ticks(0) = octave::math::max (octave::math::min (0., lims(1)),
8203 else if (other_axislocation == 1)
8204 omit_ticks(0) = lims(1);
8205 else if (other_axislocation == -1)
8206 omit_ticks(0) = lims(0);
8209 omit_ticks(1) = lims(0);
8210 omit_ticks(2) = lims(1);
8218 bool is_2digit_exp =
false;
8220 for (
int i = 0; i < values.
numel (); i++)
8222 double exp = std::abs (std::log10 (values(i)));
8225 is_2digit_exp =
true;
8230 for (
int i = 0; i < values.
numel (); i++)
8232 bool omit_tick =
false;
8233 for (
int i_omit = 0; i_omit < omit_ticks.numel (); i_omit++)
8234 if (values(i) == omit_ticks(i_omit))
8242 if (values(i) < 0.0)
8243 exponent = std::floor (std::log10 (-values(i)));
8245 exponent = std::floor (std::log10 (values(i)));
8246 significand = values(i) * std::pow (10.0, -exponent);
8250 if ((std::abs (significand) - 1) >
8251 10*std::numeric_limits<double>::epsilon())
8252 os << significand <<
'x';
8253 else if (significand < 0)
8261 exponent = -exponent;
8263 if (exponent < 10.0 && is_2digit_exp)
8265 os << exponent <<
'}';
8267 if (m_ticklabelinterpreter.is (
"latex"))
8268 c(i) =
"$" + os.str () +
"$";
8275 for (
int i = 0; i < values.
numel (); i++)
8277 bool omit_tick =
false;
8278 for (
int i_omit = 0; i_omit < omit_ticks.numel (); i_omit++)
8279 if (values(i) == omit_ticks(i_omit))
8291 if (std::abs (values(i)) < 1.0)
8305axes::properties::get_ticklabel_extents (
const Matrix& ticks,
8311 double dpr = device_pixel_ratio (get___myhandle__ ());
8313 int n = std::min (ticklabels.
numel (), ticks.
numel ());
8314 for (
int i = 0; i < n; i++)
8316 double val = ticks(i);
8317 if (limits(0) <= val && val <= limits(1))
8319 std::string label (ticklabels(i));
8320 label.erase (0, label.find_first_not_of (
' '));
8321 label = label.substr (0, label.find_last_not_of (
' ')+1);
8323 if (m_txt_renderer.ok ())
8325 gh_manager& gh_mgr = octave::__get_gh_manager__ ();
8329 ext = m_txt_renderer.get_extent (label, 0.0,
8330 get_ticklabelinterpreter ());
8332 wmax = std::max (wmax, ext(0) / dpr);
8333 hmax = std::max (hmax, ext(1) / dpr);
8338 double fsize = get (
"fontsize").double_value ();
8339 int len = label.length ();
8341 wmax = std::max (wmax, 0.5*fsize*
len);
8354 double& min_pos,
double& max_neg,
8355 const Matrix& kids,
char limit_type)
8359 gh_manager& gh_mgr = octave::__get_gh_manager__ ();
8366 graphics_object go = gh_mgr.
get_object (kids(i));
8368 if (go.is_xliminclude ())
8372 check_limit_vals (min_val, max_val, min_pos, max_neg, lim);
8380 graphics_object go = gh_mgr.
get_object (kids(i));
8382 if (go.is_yliminclude ())
8386 check_limit_vals (min_val, max_val, min_pos, max_neg, lim);
8394 graphics_object go = gh_mgr.
get_object (kids(i));
8396 if (go.is_zliminclude ())
8400 check_limit_vals (min_val, max_val, min_pos, max_neg, lim);
8408 graphics_object go = gh_mgr.
get_object (kids(i));
8410 if (go.is_climinclude ())
8414 check_limit_vals (min_val, max_val, min_pos, max_neg, lim);
8422 graphics_object go = gh_mgr.
get_object (kids(i));
8424 if (go.is_aliminclude ())
8428 check_limit_vals (min_val, max_val, min_pos, max_neg, lim);
8438static std::set<double> updating_axis_limits;
8441axes::update_axis_limits (
const std::string& axis_type,
8444 if (updating_axis_limits.find (get_handle ().value ())
8445 != updating_axis_limits.end ())
8450 double min_val = octave::numeric_limits<double>::Inf ();
8451 double max_val = -octave::numeric_limits<double>::Inf ();
8452 double min_pos = octave::numeric_limits<double>::Inf ();
8453 double max_neg = -octave::numeric_limits<double>::Inf ();
8455 char update_type = 0;
8462 if (octave::math::isfinite (val)) \
8465 if (octave::math::isfinite (val)) \
8468 if (axis_type ==
"xdata" || axis_type ==
"xscale"
8469 || axis_type ==
"xlimmode" || axis_type ==
"xliminclude"
8470 || axis_type ==
"xlim")
8472 limits = m_properties.get_xlim ().matrix_value ();
8476 if (m_properties.xlimmode_is (
"auto"))
8480 std::string method = m_properties.get_xlimitmethod ();
8481 limits = m_properties.get_axis_limits (min_val, max_val,
8483 m_properties.xscale_is (
"log"),
8487 m_properties.check_axis_limits (limits, kids,
8488 m_properties.xscale_is (
"log"),
8491 else if (axis_type ==
"ydata" || axis_type ==
"yscale"
8492 || axis_type ==
"ylimmode" || axis_type ==
"yliminclude"
8493 || axis_type ==
"ylim")
8495 limits = m_properties.get_ylim ().matrix_value ();
8499 if (m_properties.ylimmode_is (
"auto"))
8503 std::string method = m_properties.get_ylimitmethod ();
8504 limits = m_properties.get_axis_limits (min_val, max_val,
8506 m_properties.yscale_is (
"log"),
8510 m_properties.check_axis_limits (limits, kids,
8511 m_properties.yscale_is (
"log"),
8514 else if (axis_type ==
"zdata" || axis_type ==
"zscale"
8515 || axis_type ==
"zlimmode" || axis_type ==
"zliminclude"
8516 || axis_type ==
"zlim")
8518 limits = m_properties.get_zlim ().matrix_value ();
8522 if (m_properties.zlimmode_is (
"auto"))
8526 m_properties.set_has3Dkids ((max_val - min_val) >
8527 std::numeric_limits<double>::epsilon ());
8529 std::string method = m_properties.get_zlimitmethod ();
8530 limits = m_properties.get_axis_limits (min_val, max_val,
8532 m_properties.zscale_is (
"log"),
8541 m_properties.set_has3Dkids ((max_val - min_val) >
8542 std::numeric_limits<double>::epsilon ());
8544 m_properties.check_axis_limits (limits, kids,
8545 m_properties.zscale_is (
"log"),
8549 else if (axis_type ==
"cdata" || axis_type ==
"climmode"
8550 || axis_type ==
"cdatamapping" || axis_type ==
"climinclude"
8551 || axis_type ==
"clim")
8553 if (m_properties.climmode_is (
"auto"))
8555 limits = m_properties.get_clim ().matrix_value ();
8560 if (min_val > max_val)
8562 min_val = min_pos = 0;
8565 else if (min_val == max_val)
8567 max_val = min_val + 1;
8571 limits(0) = min_val;
8572 limits(1) = max_val;
8577 else if (axis_type ==
"alphadata" || axis_type ==
"alimmode"
8578 || axis_type ==
"alphadatamapping" || axis_type ==
"aliminclude"
8579 || axis_type ==
"alim")
8581 if (m_properties.alimmode_is (
"auto"))
8583 limits = m_properties.get_alim ().matrix_value ();
8588 if (min_val > max_val)
8590 min_val = min_pos = 0;
8593 else if (min_val == max_val)
8594 max_val = min_val + 1;
8596 limits(0) = min_val;
8597 limits(1) = max_val;
8605 octave::unwind_protect_var<std::set<double>>
8606 restore_var (updating_axis_limits);
8608 updating_axis_limits.insert (get_handle ().value ());
8611 switch (update_type)
8614 is_auto = m_properties.xlimmode_is (
"auto");
8615 m_properties.set_xlim (limits);
8617 m_properties.set_xlimmode (
"auto");
8618 m_properties.update_xlim ();
8622 is_auto = m_properties.ylimmode_is (
"auto");
8623 m_properties.set_ylim (limits);
8625 m_properties.set_ylimmode (
"auto");
8626 m_properties.update_ylim ();
8630 is_auto = m_properties.zlimmode_is (
"auto");
8631 m_properties.set_zlim (limits);
8633 m_properties.set_zlimmode (
"auto");
8634 m_properties.update_zlim ();
8638 m_properties.set_clim (limits);
8639 m_properties.set_climmode (
"auto");
8643 m_properties.set_alim (limits);
8644 m_properties.set_alimmode (
"auto");
8651 m_properties.update_transform ();
8658axes::update_axis_limits (
const std::string& axis_type)
8660 if ((updating_axis_limits.find (get_handle ().value ())
8661 != updating_axis_limits.end ())
8662 || (updating_aspectratios.find (get_handle ().value ())
8663 != updating_aspectratios.end ()))
8666 Matrix kids = m_properties.get_all_children ();
8668 double min_val = octave::numeric_limits<double>::Inf ();
8669 double max_val = -octave::numeric_limits<double>::Inf ();
8670 double min_pos = octave::numeric_limits<double>::Inf ();
8671 double max_neg = -octave::numeric_limits<double>::Inf ();
8673 char update_type = 0;
8677 if (axis_type ==
"xdata" || axis_type ==
"xscale"
8678 || axis_type ==
"xlimmode" || axis_type ==
"xliminclude"
8679 || axis_type ==
"xlim")
8682 if (m_properties.xlimmode_is (
"auto"))
8686 std::string method = m_properties.get_xlimitmethod ();
8687 limits = m_properties.get_axis_limits (min_val, max_val,
8689 m_properties.xscale_is (
"log"),
8694 limits = m_properties.get_xlim ().matrix_value ();
8695 m_properties.check_axis_limits (limits, kids,
8696 m_properties.xscale_is (
"log"),
8698 if (axis_type ==
"xscale")
8702 else if (axis_type ==
"ydata" || axis_type ==
"yscale"
8703 || axis_type ==
"ylimmode" || axis_type ==
"yliminclude"
8704 || axis_type ==
"ylim")
8707 if (m_properties.ylimmode_is (
"auto"))
8711 std::string method = m_properties.get_ylimitmethod ();
8712 limits = m_properties.get_axis_limits (min_val, max_val,
8714 m_properties.yscale_is (
"log"),
8719 limits = m_properties.get_ylim ().matrix_value ();
8720 m_properties.check_axis_limits (limits, kids,
8721 m_properties.yscale_is (
"log"),
8723 if (axis_type ==
"yscale")
8727 else if (axis_type ==
"zdata" || axis_type ==
"zscale"
8728 || axis_type ==
"zlimmode" || axis_type ==
"zliminclude"
8729 || axis_type ==
"zlim")
8732 if (m_properties.zlimmode_is (
"auto"))
8736 m_properties.set_has3Dkids ((max_val - min_val) >
8737 std::numeric_limits<double>::epsilon ());
8740 if ((! octave::math::isfinite (min_val)
8741 || ! octave::math::isfinite (max_val))
8742 && ! m_properties.zscale_is (
"log"))
8743 min_val = max_val = 0.;
8745 std::string method = m_properties.get_zlimitmethod ();
8746 limits = m_properties.get_axis_limits (min_val, max_val,
8748 m_properties.zscale_is (
"log"),
8757 m_properties.set_has3Dkids ((max_val - min_val) >
8758 std::numeric_limits<double>::epsilon ());
8760 limits = m_properties.get_zlim ().matrix_value ();
8761 m_properties.check_axis_limits (limits, kids,
8762 m_properties.zscale_is (
"log"),
8764 if (axis_type ==
"zscale")
8768 else if (axis_type ==
"cdata" || axis_type ==
"climmode"
8769 || axis_type ==
"cdatamapping" || axis_type ==
"climinclude"
8770 || axis_type ==
"clim")
8772 if (m_properties.climmode_is (
"auto"))
8776 if (min_val > max_val)
8778 min_val = min_pos = 0;
8781 else if (min_val == max_val)
8783 max_val = min_val + 1;
8789 limits(0) = min_val;
8790 limits(1) = max_val;
8796 else if (axis_type ==
"alphadata" || axis_type ==
"alimmode"
8797 || axis_type ==
"alphadatamapping" || axis_type ==
"aliminclude"
8798 || axis_type ==
"alim")
8800 if (m_properties.alimmode_is (
"auto"))
8804 if (min_val > max_val)
8806 min_val = min_pos = 0;
8809 else if (min_val == max_val)
8810 max_val = min_val + 1;
8814 limits(0) = min_val;
8815 limits(1) = max_val;
8822 octave::unwind_protect_var<std::set<double>>
8823 restore_var (updating_axis_limits);
8825 updating_axis_limits.insert (get_handle ().value ());
8828 switch (update_type)
8831 is_auto = m_properties.xlimmode_is (
"auto");
8832 m_properties.set_xlim (limits);
8834 m_properties.set_xlimmode (
"auto");
8835 m_properties.update_xlim ();
8839 is_auto = m_properties.ylimmode_is (
"auto");
8840 m_properties.set_ylim (limits);
8842 m_properties.set_ylimmode (
"auto");
8843 m_properties.update_ylim ();
8847 is_auto = m_properties.zlimmode_is (
"auto");
8848 m_properties.set_zlim (limits);
8850 m_properties.set_zlimmode (
"auto");
8851 m_properties.update_zlim ();
8855 m_properties.set_clim (limits);
8856 m_properties.set_climmode (
"auto");
8860 m_properties.set_alim (limits);
8861 m_properties.set_alimmode (
"auto");
8868 m_properties.update_transform ();
8883do_zoom (
double val,
double factor,
const Matrix& lims,
bool is_logscale)
8887 double lo = lims(0);
8888 double hi = lims(1);
8890 bool is_negative = lo < 0 && hi < 0;
8897 hi = std::log10 (-lo);
8898 lo = std::log10 (-tmp);
8899 val = std::log10 (-val);
8903 hi = std::log10 (hi);
8904 lo = std::log10 (lo);
8905 val = std::log10 (val);
8910 lo = val + (lo - val) / factor;
8911 hi = val + (hi - val) / factor;
8917 double tmp = -std::pow (10.0, hi);
8918 hi = -std::pow (10.0, lo);
8923 lo = std::pow (10.0, lo);
8924 hi = std::pow (10.0, hi);
8935axes::properties::zoom_about_point (
const std::string& mode,
8936 double x,
double y,
double factor,
8937 bool push_to_zoom_stack)
8940 Matrix xlims = get_xlim ().matrix_value ();
8941 Matrix ylims = get_ylim ().matrix_value ();
8944 Matrix kids = get_children ();
8945 double minx = octave::numeric_limits<double>::Inf ();
8946 double maxx = -octave::numeric_limits<double>::Inf ();
8947 double min_pos_x = octave::numeric_limits<double>::Inf ();
8948 double max_neg_x = -octave::numeric_limits<double>::Inf ();
8951 double miny = octave::numeric_limits<double>::Inf ();
8952 double maxy = -octave::numeric_limits<double>::Inf ();
8953 double min_pos_y = octave::numeric_limits<double>::Inf ();
8954 double max_neg_y = -octave::numeric_limits<double>::Inf ();
8957 xlims = do_zoom (
x, factor, xlims, xscale_is (
"log"));
8958 ylims = do_zoom (y, factor, ylims, yscale_is (
"log"));
8960 zoom (mode, xlims, ylims, push_to_zoom_stack);
8964axes::properties::zoom (
const std::string& mode,
double factor,
8965 bool push_to_zoom_stack)
8968 Matrix xlims = get_xlim ().matrix_value ();
8969 Matrix ylims = get_ylim ().matrix_value ();
8971 double x = (xlims(0) + xlims(1)) / 2;
8972 double y = (ylims(0) + ylims(1)) / 2;
8974 zoom_about_point (mode,
x, y, factor, push_to_zoom_stack);
8978axes::properties::push_zoom_stack ()
8980 if (m_zoom_stack.empty ())
8982 m_zoom_stack.push_front (m_xlimmode.get ());
8983 m_zoom_stack.push_front (m_xlim.get ());
8984 m_zoom_stack.push_front (m_ylimmode.get ());
8985 m_zoom_stack.push_front (m_ylim.get ());
8986 m_zoom_stack.push_front (m_zlimmode.get ());
8987 m_zoom_stack.push_front (m_zlim.get ());
8988 m_zoom_stack.push_front (m_view.get ());
8993axes::properties::zoom (
const std::string& mode,
8995 bool push_to_zoom_stack)
8997 if (xl(0) == xl(1) || yl(0) == yl(1))
8999 warning (
"invalid zoom region");
9003 if (push_to_zoom_stack)
9006 if (mode ==
"horizontal" || mode ==
"both")
9009 m_xlimmode =
"manual";
9012 if (mode ==
"vertical" || mode ==
"both")
9015 m_ylimmode =
"manual";
9018 update_transform ();
9020 if (mode ==
"horizontal" || mode ==
"both")
9023 if (mode ==
"vertical" || mode ==
"both")
9028do_translate (
double x0,
double x1,
const Matrix& lims,
bool is_logscale)
9032 double lo = lims(0);
9033 double hi = lims(1);
9035 bool is_negative = lo < 0 && hi < 0;
9044 hi = std::log10 (-lo);
9045 lo = std::log10 (-tmp);
9051 hi = std::log10 (hi);
9052 lo = std::log10 (lo);
9055 delta = std::log10 (x0) - std::log10 (x1);
9070 double tmp = -std::pow (10.0, hi);
9071 hi = -std::pow (10.0, lo);
9076 lo = std::pow (10.0, lo);
9077 hi = std::pow (10.0, hi);
9088axes::properties::translate_view (
const std::string& mode,
9089 double x0,
double x1,
double y0,
double y1,
9090 bool push_to_zoom_stack)
9093 Matrix xlims = get_xlim ().matrix_value ();
9094 Matrix ylims = get_ylim ().matrix_value ();
9097 Matrix kids = get_children ();
9098 double minx = octave::numeric_limits<double>::Inf ();
9099 double maxx = -octave::numeric_limits<double>::Inf ();
9100 double min_pos_x = octave::numeric_limits<double>::Inf ();
9101 double max_neg_x = -octave::numeric_limits<double>::Inf ();
9104 double miny = octave::numeric_limits<double>::Inf ();
9105 double maxy = -octave::numeric_limits<double>::Inf ();
9106 double min_pos_y = octave::numeric_limits<double>::Inf ();
9107 double max_neg_y = -octave::numeric_limits<double>::Inf ();
9110 xlims = do_translate (x0, x1, xlims, xscale_is (
"log"));
9111 ylims = do_translate (y0, y1, ylims, yscale_is (
"log"));
9113 zoom (mode, xlims, ylims, push_to_zoom_stack);
9117axes::properties::pan (
const std::string& mode,
double factor,
9118 bool push_to_zoom_stack)
9121 Matrix xlims = get_xlim ().matrix_value ();
9122 Matrix ylims = get_ylim ().matrix_value ();
9124 double x0 = (xlims(0) + xlims(1)) / 2;
9125 double y0 = (ylims(0) + ylims(1)) / 2;
9127 double x1 = x0 + (xlims(1) - xlims(0)) * factor;
9128 double y1 = y0 + (ylims(1) - ylims(0)) * factor;
9130 translate_view (mode, x0, x1, y0, y1, push_to_zoom_stack);
9134axes::properties::rotate3d (
double x0,
double x1,
double y0,
double y1,
9135 bool push_to_zoom_stack)
9137 if (push_to_zoom_stack)
9140 Matrix bb = get_boundingbox (
true);
9141 Matrix new_view = get_view ().matrix_value ();
9144 new_view(0) += ((x0 - x1) * (180.0 / bb(2)));
9145 new_view(1) += ((y1 - y0) * (180.0 / bb(3)));
9148 new_view(1) = std::min (new_view(1), 90.0);
9149 new_view(1) = std::max (new_view(1), -90.0);
9150 if (new_view(0) > 180.0)
9151 new_view(0) -= 360.0;
9152 else if (new_view(0) < -180.0)
9153 new_view(0) += 360.0;
9156 double snapmargin = 1.0;
9157 for (
int a = -90; a <= 90; a += 90)
9159 if ((a - snapmargin) < new_view(1) && new_view(1) < (a + snapmargin))
9166 for (
int a = -180; a <= 180; a += 180)
9167 if ((a - snapmargin) < new_view(0) && new_view(0) < (a + snapmargin))
9177 set_view (new_view);
9181axes::properties::rotate_view (
double delta_el,
double delta_az,
9182 bool push_to_zoom_stack)
9184 if (push_to_zoom_stack)
9187 Matrix v = get_view ().matrix_value ();
9196 v(0) = fmod (v(0) - delta_az + 720, 360);
9200 update_transform ();
9204axes::properties::unzoom ()
9206 if (m_zoom_stack.size () >= 7)
9208 m_view = m_zoom_stack.front ();
9209 m_zoom_stack.pop_front ();
9211 m_zlim = m_zoom_stack.front ();
9212 m_zoom_stack.pop_front ();
9214 m_zlimmode = m_zoom_stack.front ();
9215 m_zoom_stack.pop_front ();
9217 m_ylim = m_zoom_stack.front ();
9218 m_zoom_stack.pop_front ();
9220 m_ylimmode = m_zoom_stack.front ();
9221 m_zoom_stack.pop_front ();
9223 m_xlim = m_zoom_stack.front ();
9224 m_zoom_stack.pop_front ();
9226 m_xlimmode = m_zoom_stack.front ();
9227 m_zoom_stack.pop_front ();
9229 update_transform ();
9240axes::properties::update_handlevisibility ()
9242 if (! is_handle_visible ())
9244 gh_manager& gh_mgr = octave::__get_gh_manager__ ();
9246 graphics_object go (gh_mgr.
get_object (get___myhandle__ ()));
9248 graphics_object fig (go.get_ancestor (
"figure"));
9256 fig.set (
"currentaxes",
Matrix ());
9260 fig.set (
"currentaxes", kidsarray(0));
9265 base_properties::update_handlevisibility ();
9269figure::properties::init_toolkit ()
9271 octave::gtk_manager& gtk_mgr = octave::__get_gtk_manager__ ();
9273 m_toolkit = gtk_mgr.get_toolkit ();
9277axes::properties::clear_zoom_stack (
bool do_unzoom)
9279 std::size_t items_to_leave_on_stack = (do_unzoom ? 7 : 0);
9281 while (m_zoom_stack.size () > items_to_leave_on_stack)
9282 m_zoom_stack.pop_front ();
9289axes::properties::trigger_normals_calc ()
9292 std::list<graphics_object> children_list;
9293 std::list<graphics_object>::iterator children_list_iter;
9294 get_children_of_type (
"patch",
false,
true, children_list);
9295 get_children_of_type (
"surface",
false,
true, children_list);
9298 for (children_list_iter = children_list.begin ();
9299 children_list_iter != children_list.end (); children_list_iter++)
9301 graphics_object kid = *children_list_iter;
9302 if (kid.isa (
"patch"))
9304 patch::properties& patch_props
9305 =
dynamic_cast<patch::properties&
> (kid.get_properties ());
9306 patch_props.update_normals (
false);
9310 surface::properties& surface_props
9311 =
dynamic_cast<surface::properties&
> (kid.get_properties ());
9312 surface_props.update_normals (
false);
9318axes::reset_default_properties ()
9321 m_default_properties = property_list ();
9324 int state = toggle_warn (
"Octave:deprecated-property",
false);
9327 remove_all_listeners ();
9328 set_defaults (
"reset");
9330 toggle_warn (
"Octave:deprecated-property",
true, state);
9334axes::initialize (
const graphics_object& go)
9336 base_graphics_object::initialize (go);
9338 xinitialize (m_properties.get_title ());
9339 xinitialize (m_properties.get_xlabel ());
9340 xinitialize (m_properties.get_ylabel ());
9341 xinitialize (m_properties.get_zlabel ());
9343 m_properties.sync_positions ();
9349line::properties::compute_xlim ()
const
9353 m(0) = m_xdata.min_val ();
9354 m(1) = m_xdata.max_val ();
9355 m(2) = m_xdata.min_pos ();
9356 m(3) = m_xdata.max_neg ();
9362line::properties::compute_ylim ()
const
9366 m(0) = m_ydata.min_val ();
9367 m(1) = m_ydata.max_val ();
9368 m(2) = m_ydata.min_pos ();
9369 m(3) = m_ydata.max_neg ();
9377text::properties::get_data_position ()
const
9379 Matrix pos = get_position ().matrix_value ();
9381 if (! units_is (
"data"))
9382 pos = convert_text_position (pos, *
this, get_units (),
"data");
9388text::properties::get_extent_matrix (
bool rotated)
const
9391 Matrix ext = m_extent.get ().matrix_value ();
9393 if (rotated && get_rotation () != 0)
9395 double rot = get_rotation () * 4.0 *
atan (1.0) / 180;
9396 double x0 = ext(0) * cos (rot) - ext(1) * sin (rot);
9398 double y0 = ext(0) * sin (rot) + ext(1) * cos (rot);
9401 double tmp = (ext(0)+ext(2)) * cos (rot) - ext(1) * sin (rot);
9402 x0 = std::min (x0, tmp);
9403 x1 = std::max (x1, tmp);
9404 tmp = (ext(0)+ext(2)) * sin (rot) + ext(1) * cos (rot);
9405 y0 = std::min (y0, tmp);
9406 y1 = std::max (y1, tmp);
9408 tmp = (ext(0)+ext(2)) * cos (rot) - (ext(1)+ext(3)) * sin (rot);
9409 x0 = std::min (x0, tmp);
9410 x1 = std::max (x1, tmp);
9411 tmp = (ext(0)+ext(2)) * sin (rot) + (ext(1)+ext(3)) * cos (rot);
9412 y0 = std::min (y0, tmp);
9413 y1 = std::max (y1, tmp);
9415 tmp = ext(0) * cos (rot) - (ext(1)+ext(3)) * sin (rot);
9416 x0 = std::min (x0, tmp);
9417 x1 = std::max (x1, tmp);
9418 tmp = ext(0) * sin (rot) + (ext(1)+ext(3)) * cos (rot);
9419 y0 = std::min (y0, tmp);
9420 y1 = std::max (y1, tmp);
9432text::properties::get_extent ()
const
9436 Matrix m = get_extent_matrix (
true);
9437 Matrix pos = get_position ().matrix_value ();
9438 Matrix p = convert_text_position (pos, *
this, get_units (),
"pixels");
9443 Matrix bbox = convert_text_position (m, *
this,
"pixels", get_units ());
9445 double dpr = device_pixel_ratio (get___myhandle__ ());
9448 bbox(ii) = bbox(ii) / dpr;
9454text::properties::set_fontunits (
const octave_value& val)
9458 if (m_fontunits.set (val,
true))
9460 update_fontunits (old_fontunits);
9466text::properties::update_fontunits (
const caseless_str& old_units)
9469 double parent_height = 0;
9470 double fontsz = get_fontsize ();
9472 if (new_units ==
"normalized" || old_units ==
"normalized")
9474 gh_manager& gh_mgr = octave::__get_gh_manager__ ();
9476 graphics_object go (gh_mgr.
get_object (get___myhandle__ ()));
9478 graphics_object ax (go.get_ancestor (
"axes"));
9480 parent_height = ax.get_properties ().get_boundingbox (
true).elem (3);
9483 fontsz = convert_font_size (fontsz, old_units, new_units, parent_height);
9489text::properties::update_font ()
9491 double dpr = device_pixel_ratio (get___myhandle__ ());
9493 gh_manager& gh_mgr = octave::__get_gh_manager__ ();
9497 m_txt_renderer.set_font (get (
"fontname").string_value (),
9498 get (
"fontweight").string_value (),
9499 get (
"fontangle").string_value (),
9500 get (
"__fontsize_points__").double_value () * dpr);
9502 m_txt_renderer.set_anti_aliasing (is_fontsmoothing ());
9504 Matrix c = get_color_rgb ();
9506 m_txt_renderer.set_color (c);
9511text::properties::update_text_extent ()
9516 if (horizontalalignment_is (
"center"))
9518 else if (horizontalalignment_is (
"right"))
9521 if (verticalalignment_is (
"middle"))
9523 else if (verticalalignment_is (
"top"))
9525 else if (verticalalignment_is (
"baseline"))
9527 else if (verticalalignment_is (
"cap"))
9538 gh_manager& gh_mgr = octave::__get_gh_manager__ ();
9542 m_txt_renderer.text_to_pixels (sv.
join (
"\n"), m_pixels, bbox,
9543 halign, valign, 0.0, get_interpreter ());
9550 if (__autopos_tag___is (
"xlabel") || __autopos_tag___is (
"ylabel")
9551 || __autopos_tag___is (
"zlabel") || __autopos_tag___is (
"title"))
9552 update_autopos (
"sync");
9556text::properties::request_autopos ()
9558 if (__autopos_tag___is (
"xlabel") || __autopos_tag___is (
"ylabel")
9559 || __autopos_tag___is (
"zlabel") || __autopos_tag___is (
"title"))
9560 update_autopos (get___autopos_tag__ ());
9564text::properties::update_units ()
9566 if (! units_is (
"data"))
9568 set_xliminclude (
"off");
9569 set_yliminclude (
"off");
9570 set_zliminclude (
"off");
9573 Matrix pos = get_position ().matrix_value ();
9575 pos = convert_text_position (pos, *
this, m_cached_units, get_units ());
9580 bool autopos = positionmode_is (
"auto");
9585 set_positionmode (
"auto");
9587 if (units_is (
"data"))
9589 set_xliminclude (
"on");
9590 set_yliminclude (
"on");
9592 set_zliminclude (
"off");
9595 m_cached_units = get_units ();
9599text::properties::get___fontsize_points__ (
double box_pix_height)
const
9601 double fontsz = get_fontsize ();
9602 double parent_height = box_pix_height;
9604 gh_manager& gh_mgr = octave::__get_gh_manager__ ();
9606 graphics_object go (gh_mgr.
get_object (get___myhandle__ ()));
9608 if (fontunits_is (
"normalized") && parent_height <= 0)
9610 graphics_object ax (go.get_ancestor (
"axes"));
9612 parent_height = ax.get_properties ().get_boundingbox (
true).elem (3);
9615 return convert_font_size (fontsz, get_fontunits (),
"points", parent_height);
9621image::properties::get_color_data ()
const
9623 return convert_cdata (*
this, get_cdata (), cdatamapping_is (
"scaled"), 3);
9629light::initialize (
const graphics_object& go)
9631 base_graphics_object::initialize (go);
9634 axes::properties& parent_axes_prop
9635 =
dynamic_cast<axes::properties&
> (go.get_ancestor (
"axes").get_properties ());
9636 parent_axes_prop.trigger_normals_calc ();
9640light::properties::update_visible ()
9642 gh_manager& gh_mgr = octave::__get_gh_manager__ ();
9644 graphics_object go = gh_mgr.
get_object (get___myhandle__ ());
9646 axes::properties& ax_props =
dynamic_cast<axes::properties&
>
9647 (go.get_ancestor (
"axes").get_properties ());
9649 ax_props.increase_num_lights ();
9651 ax_props.decrease_num_lights ();
9657patch::properties::get_do_lighting ()
const
9659 gh_manager& gh_mgr = octave::__get_gh_manager__ ();
9661 graphics_object go = gh_mgr.
get_object (get___myhandle__ ());
9663 axes::properties& ax_props =
dynamic_cast<axes::properties&
>
9664 (go.get_ancestor (
"axes").get_properties ());
9666 return (ax_props.get_num_lights () > 0);
9670patch::properties::get_color_data ()
const
9676 return convert_cdata (*
this, fvc, cdatamapping_is (
"scaled"), 2);
9679static bool updating_patch_data =
false;
9682patch::properties::update_fvc ()
9684 if (updating_patch_data)
9687 Matrix xd = get_xdata ().matrix_value ();
9688 Matrix yd = get_ydata ().matrix_value ();
9689 Matrix zd = get_zdata ().matrix_value ();
9690 NDArray cd = get_cdata ().array_value ();
9692 m_bad_data_msg =
"";
9696 m_bad_data_msg =
"x/y/zdata must have the same dimensions";
9704 if ((ncf > 1 || ncv > 1) && ((ncf != nf) || (ncv != 1 && ncv != nv)))
9706 m_bad_data_msg =
"cdata does not match number of faces "
9707 "or number of vertices per face";
9712 if (cd.
ndims () == 3)
9718 if (nv == 1 && nf > 1)
9727 bool pervertex =
false;
9747 fvc.
resize (nv * nf, (isRGB ? 3 : 1));
9753 dv(1) = (isRGB ? 3 : 1);
9764 vert(kk, 0) = xd(ii, jj);
9765 vert(kk, 1) = yd(ii, jj);
9767 vert(kk, 2) = zd(ii, jj);
9771 fvc(kk, 0) = cd(ii, jj, 0);
9774 fvc(kk, 1) = cd(ii, jj, 1);
9775 fvc(kk, 2) = cd(ii, jj, 2);
9779 idx(jj, ii) =
static_cast<double> (kk+1);
9787 octave::unwind_protect_var<bool> restore_var (updating_patch_data,
true);
9790 m_vertices.set (vert);
9791 m_facevertexcdata.set (fvc);
9793 updating_patch_data =
false;
9804 double tol = 100 * std::numeric_limits<double>::epsilon ();
9805 EIG eig (cov,
false,
false,
true);
9807 return ev.
min () <= tol * ev.
max ();
9810std::vector<octave_idx_type>
9814 std::vector<octave_idx_type> coplanar_ends;
9818 plane_pivot(0, i) = vert(idx(0, jj)-1, i);
9836 fc(j-1, i) = vert(idx(j, jj)-1, i) - plane_pivot(i);
9841 coplanar_ends.push_back (nc - 1);
9842 return coplanar_ends;
9852 while (i_start < nc - 1)
9854 i_end = i_start + 2;
9857 coplanar_ends.push_back (nc - 1);
9869 fc(j, i) = vert(idx(j+i_start, jj)-1, i) - plane_pivot(i);
9886 fa(0, i) = vert(idx(i_end, jj)-1, i) - plane_pivot(i);
9890 i_start = i_end - 1;
9891 coplanar_ends.push_back (i_start);
9893 return coplanar_ends;
9897patch::properties::update_data ()
9899 if (updating_patch_data)
9903 Matrix vert = get_vertices ().matrix_value ();
9904 NDArray fvc = get_facevertexcdata ().array_value ();
9910 m_bad_data_msg =
"";
9911 if (
static_cast<double> (nvert) < idx.
row_max ().
max ())
9913 m_bad_data_msg = R
"(some vertices in "faces" property are undefined)";
9919 if (nfvc > 1 && nfvc != nfaces && nfvc != nvert)
9921 m_bad_data_msg =
"number of facevertexcdata values matches "
9922 "neither number of faces nor number of vertices";
9931 double valid_vert = idx(0, jj);
9932 bool turn_valid =
false;
9935 if (octave::math::isnan (idx(ii, jj)) || turn_valid)
9937 idx(ii, jj) = valid_vert;
9941 valid_vert = idx(ii, jj);
9947 int fcmax = idx.
rows ();
9948 if (fcmax > 3 && vert.
columns () > 2
9949 && ! (facecolor_is (
"none") && edgecolor_is (
"none")))
9951 m_coplanar_last_idx.resize (idx.
columns ());
9954 if (octave::math::isnan (idx(3, jj)))
9959 while (nc < fcmax && ! octave::math::isnan (idx(nc, jj)))
9964 bool is_unclosed =
false;
9968 if (! (octave::math::isfinite (vert(k, 0))
9969 && octave::math::isfinite (vert(k, 1))
9970 && octave::math::isfinite (vert(k, 2))))
9983 m_coplanar_last_idx.resize (0);
9988 bool pervertex =
false;
9990 if (fvc.
rows () == nfaces || fvc.
rows () == 1)
9994 dv(1) = fvc.
rows ();
10001 dv(0) = idx.
rows ();
10012 bool has_zd =
false;
10024 xd(ii, jj) = vert(row, 0);
10025 yd(ii, jj) = vert(row, 1);
10028 zd(ii, jj) = vert(row, 2);
10031 for (
int kk = 0; kk < fvc.
columns (); kk++)
10032 cd(ii, jj, kk) = fvc(row, kk);
10037 update_normals (
true);
10039 octave::unwind_protect_var<bool> restore_var (updating_patch_data,
true);
10049 double x2,
double y2,
double z2,
10050 double&
x,
double& y,
double& z)
10052 x += (y1 * z2 - z1 * y2);
10053 y += (z1 * x2 - x1 * z2);
10054 z += (x1 * y2 - y1 * x2);
10058patch::properties::calc_face_normals (
Matrix& fn)
10060 Matrix v = get_vertices ().matrix_value ();
10061 Matrix f = get_faces ().matrix_value ();
10063 bool is_3D = (v.
columns () == 3);
10080 if (m_coplanar_last_idx.size () > 0 && m_coplanar_last_idx[i].size () > 1)
10087 while (nc < max_nc && ! octave::math::isnan (
f(i, nc)))
10092 double& nx = fnc(0);
10093 double& ny = fnc(1);
10094 double& nz = fnc(2);
10099 i1 =
f(i, 0) - 1; i2 =
f(i, 1) - 1; i3 =
f(i, nc-1) - 1;
10103 (v(i3, 0) - v(i1, 0), v(i3, 1) - v(i1, 1), v(i3, 2) - v(i1, 2),
10104 v(i2, 0) - v(i1, 0), v(i2, 1) - v(i1, 1), v(i2, 2) - v(i1, 2),
10108 nz = (v(i2, 0) - v(i1, 0)) * (v(i3, 1) - v(i1, 1)) -
10109 (v(i2, 1) - v(i1, 1)) * (v(i3, 0) - v(i1, 0));
10111 nz = (nz < 0) ? -nz : nz;
10121 j1 = nc - 1; j2 = 0;
10122 i1 =
f(i, j1) - 1; i2 =
f(i, j2) - 1;
10124 nx = (v(i2, 1) - v(i1, 1)) * (v(i1, 2) + v(i2, 2));
10125 ny = (v(i2, 2) - v(i1, 2)) * (v(i1, 0) + v(i2, 0));
10126 nz = (v(i2, 0) - v(i1, 0)) * (v(i1, 1) + v(i2, 1));
10131 i1 =
f(i, j1) - 1; i2 =
f(i, j2) - 1;
10133 nx += (v(i2, 1) - v(i1, 1)) * (v(i1, 2) + v(i2, 2));
10134 ny += (v(i2, 2) - v(i1, 2)) * (v(i1, 0) + v(i2, 0));
10135 nz += (v(i2, 0) - v(i1, 0)) * (v(i1, 1) + v(i2, 1));
10140 double n_len = sqrt (nx*nx+ny*ny+nz*nz);
10143 if ( n_len < std::numeric_limits<double>::epsilon () )
10148 fn(i, j) = fnc(j) / n_len;
10153patch::properties::update_face_normals (
bool reset,
bool force)
10155 if (updating_patch_data || ! facenormalsmode_is (
"auto"))
10158 if (force || ((facelighting_is (
"flat") || edgelighting_is (
"flat"))
10159 && get_do_lighting ()))
10161 Matrix f = get_faces ().matrix_value ();
10164 Matrix fn (num_f, 3, 0.0);
10166 calc_face_normals (fn);
10167 m_facenormals = fn;
10170 m_facenormals =
Matrix ();
10174patch::properties::update_vertex_normals (
bool reset,
bool force)
10176 if (updating_patch_data || ! vertexnormalsmode_is (
"auto"))
10179 if (force || ((facelighting_is (
"gouraud") || facelighting_is (
"phong")
10180 || edgelighting_is (
"gouraud") || edgelighting_is (
"phong"))
10181 && get_do_lighting ()))
10183 Matrix v = get_vertices ().matrix_value ();
10184 Matrix f = get_faces ().matrix_value ();
10195 Matrix fn = get_facenormals ().matrix_value ();
10199 fn =
Matrix (num_f, 3, 0.0);
10200 calc_face_normals (fn);
10212 std::vector<std::vector<RowVector>> vec_vn (num_v);
10219 while (nc < max_nc && ! octave::math::isnan (
f(i, nc)))
10229 Matrix vn (num_v, 3, 0.0);
10232 std::vector<RowVector>::iterator it = vec_vn[i].begin ();
10237 if (it != vec_vn[i].end ())
10248 for (++it; it != vec_vn[i].end (); ++it)
10253 double dir = (vn0(0)*vn1(0) + vn0(1)*vn1(1) + vn0(2)*vn1(2) < 0) ? -1 : 1;
10255 vn0(j) += dir * vn1(j);
10259 double n_len = sqrt (vn0(0)*vn0(0)+vn0(1)*vn0(1)+vn0(2)*vn0(2));
10263 vn(i, j) = vn0(j)/n_len;
10267 m_vertexnormals = vn;
10270 m_vertexnormals =
Matrix ();
10274patch::initialize (
const graphics_object& go)
10276 base_graphics_object::initialize (go);
10281 m_properties.update_normals (
true);
10286patch::reset_default_properties ()
10289 m_default_properties = property_list ();
10290 xreset_default_properties (get_handle (), m_properties.factory_defaults ());
10295 m_properties.update_normals (
true);
10301scatter::properties::get_color_data ()
const
10307 return convert_cdata (*
this, c, c.
columns () == 1, 2);
10311scatter::properties::update_data ()
10313 Matrix xd = get_xdata ().matrix_value ();
10314 Matrix yd = get_ydata ().matrix_value ();
10315 Matrix zd = get_zdata ().matrix_value ();
10316 Matrix cd = get_cdata ().matrix_value ();
10317 Matrix sd = get_sizedata ().matrix_value ();
10319 m_bad_data_msg =
"";
10323 m_bad_data_msg =
"x/y/zdata must have the same dimensions";
10331 if (! cd.
isempty () && (c_rows != 1 || c_cols != 3)
10332 && (c_rows != x_rows || (c_cols != 1 && c_cols != 3)))
10334 m_bad_data_msg =
"cdata must be an rgb triplet or have the same number "
10335 "of rows as X and one or three columns";
10340 if (s_rows != 1 && s_rows != x_rows)
10342 m_bad_data_msg =
"sizedata must be a scalar or a vector with the same "
10348static bool updating_scatter_cdata =
false;
10351scatter::properties::update_color ()
10353 if (updating_scatter_cdata)
10356 Matrix series_idx = get_seriesindex ().matrix_value ();
10360 gh_manager& gh_mgr = octave::__get_gh_manager__ ();
10362 graphics_object go = gh_mgr.
get_object (get___myhandle__ ());
10364 axes::properties& parent_axes_prop
10365 =
dynamic_cast<axes::properties&
>
10366 (go.get_ancestor (
"axes").get_properties ());
10368 Matrix color_order = parent_axes_prop.get_colororder ().matrix_value ();
10370 % color_order.
rows ();
10373 color(0) = color_order(s, 0);
10374 color(1) = color_order(s, 1);
10375 color(2) = color_order(s, 2);
10377 octave::unwind_protect_var<bool> restore_var (updating_scatter_cdata,
true);
10380 set_cdatamode (
"auto");
10384scatter::initialize (
const graphics_object& go)
10386 base_graphics_object::initialize (go);
10388 Matrix series_idx = m_properties.get_seriesindex ().matrix_value ();
10392 axes::properties& parent_axes_prop
10393 =
dynamic_cast<axes::properties&
>
10394 (go.get_ancestor (
"axes").get_properties ());
10396 if (! parent_axes_prop.nextplot_is (
"add"))
10397 parent_axes_prop.set_nextseriesindex (1);
10399 series_idx.
resize (1, 1);
10400 series_idx(0) = parent_axes_prop.get_nextseriesindex ();
10401 m_properties.set_seriesindex (series_idx);
10403 parent_axes_prop.set_nextseriesindex
10404 (parent_axes_prop.get_nextseriesindex () + 1);
10407 if (m_properties.cdatamode_is (
"auto"))
10408 m_properties.update_color ();
10414surface::properties::get_color_data ()
const
10416 return convert_cdata (*
this, get_cdata (), cdatamapping_is (
"scaled"), 3);
10420surface::properties::get_do_lighting ()
const
10422 gh_manager& gh_mgr = octave::__get_gh_manager__ ();
10424 graphics_object go = gh_mgr.
get_object (get___myhandle__ ());
10426 axes::properties& ax_prop =
dynamic_cast<axes::properties&
>
10427 (go.get_ancestor (
"axes").get_properties ());
10429 return (ax_prop.get_num_lights () > 0);
10433surface::properties::update_face_normals (
bool reset,
bool force)
10435 if (! facenormalsmode_is (
"auto"))
10438 if (force || ((facelighting_is (
"flat") || edgelighting_is (
"flat"))
10439 && get_do_lighting ()))
10441 Matrix x = get_xdata ().matrix_value ();
10442 Matrix y = get_ydata ().matrix_value ();
10443 Matrix z = get_zdata ().matrix_value ();
10454 if (
x.columns () != p || y.
rows () != q)
10457 bool x_mat = (
x.rows () == q);
10458 bool y_mat = (y.
columns () == p);
10462 int i1, i2, j1, j2;
10465 double x0, x1, x2, x3, y0, y1, y2, y3, z0, z1, z2, z3;
10466 double x1m0, x2m1, x3m2, x0m3, y1m0, y2m1, y3m2, y0m3;
10467 double x1p0, x2p1, x3p2, x0p3, y1p0, y2p1, y3p2, y0p3;
10469 x2m1 = x0m3 = y1m0 = y3m2 = 0;
10472 x1p0 = x3p2 = y2p1 = y0p3 = 1;
10475 for (
int i = 0; i < p-1; i++)
10480 for (
int j = 0; j < q-1; j++)
10485 if (x_mat || y_mat)
10487 x0 =
x(x_mat?j1:0, y_mat?i1:0);
10488 x1 =
x(x_mat?j1:0, y_mat?i2:0);
10489 x2 =
x(x_mat?j2:0, y_mat?i2:0);
10490 x3 =
x(x_mat?j2:0, y_mat?i1:0);
10499 y0 = y(x_mat?j1:0, y_mat?i1:0);
10500 y1 = y(x_mat?j1:0, y_mat?i2:0);
10501 y2 = y(x_mat?j2:0, y_mat?i2:0);
10502 y3 = y(x_mat?j2:0, y_mat?i1:0);
10513 double& nx = n(j, i, 0);
10514 double& ny = n(j, i, 1);
10515 double& nz = n(j, i, 2);
10525 nx = y1m0 * (z1 + z0) + y2m1 * (z2 + z1)
10526 + y3m2 * (z3 + z2) + y0m3 * (z0 + z3);
10527 ny = (z1 - z0) * x1p0 + (z2 - z1) * x2p1
10528 + (z3 - z2) * x3p2 + (z0 - z3) * x0p3;
10529 nz = x1m0 * y1p0 + x2m1 * y2p1 + x3m2 * y3p2 + x0m3 * y0p3;
10531 double d = std::max (std::max (fabs (nx), fabs (ny)), fabs (nz));
10541 m_facenormals =
Matrix ();
10545surface::properties::update_vertex_normals (
bool reset,
bool force)
10547 if (! vertexnormalsmode_is (
"auto"))
10550 if (force || ((facelighting_is (
"gouraud") || facelighting_is (
"phong")
10551 || edgelighting_is (
"gouraud") || edgelighting_is (
"phong"))
10552 && get_do_lighting ()))
10554 Matrix x = get_xdata ().matrix_value ();
10555 Matrix y = get_ydata ().matrix_value ();
10556 Matrix z = get_zdata ().matrix_value ();
10567 if (
x.columns () != p || y.
rows () != q)
10572 bool x_mat = (
x.rows () == q);
10573 bool y_mat = (y.
columns () == p);
10575 int i1, i2, i3, j1, j2, j3;
10579 for (
int i = 0; i < p; i++)
10588 for (
int j = 0; j < q; j++)
10597 double& nx = n(j, i, 0);
10598 double& ny = n(j, i, 1);
10599 double& nz = n(j, i, 2);
10601 if ((j > 0) && (i > 0))
10604 (
x(j1, i-1)-
x(j2, i), y(j-1, i1)-y(j, i2), z(j-1, i-1)-z(j, i),
10605 x(j2, i-1)-
x(j1, i), y(j, i1)-y(j-1, i2), z(j, i-1)-z(j-1, i),
10608 if ((j > 0) && (i < (p -1)))
10611 (
x(j1, i+1)-
x(j2, i), y(j-1, i3)-y(j, i2), z(j-1, i+1)-z(j, i),
10612 x(j1, i)-
x(j2, i+1), y(j-1, i2)-y(j, i3), z(j-1, i)-z(j, i+1),
10615 if ((j < (q - 1)) && (i > 0))
10618 (
x(j2, i-1)-
x(j3, i), y(j, i1)-y(j+1, i2), z(j, i-1)-z(j+1, i),
10619 x(j3, i-1)-
x(j2, i), y(j+1, i1)-y(j, i2), z(j+1, i-1)-z(j, i),
10622 if ((j < (q - 1)) && (i < (p -1)))
10625 (
x(j3, i)-
x(j2, i+1), y(j+1, i2)-y(j, i3), z(j+1, i)-z(j, i+1),
10626 x(j3, i+1)-
x(j2, i), y(j+1, i3)-y(j, i2), z(j+1, i+1)-z(j, i),
10629 double d = -std::max (std::max (fabs (nx), fabs (ny)), fabs (nz));
10636 m_vertexnormals = n;
10639 m_vertexnormals =
Matrix ();
10642DEFMETHOD (__update_normals__, interp, args, ,
10650 gh_manager& gh_mgr = interp.get_gh_manager ();
10654 if (args.
length () != 1)
10659 graphics_object go = gh_mgr.
get_object (val);
10661 if (go.isa (
"surface"))
10663 surface::properties& props
10664 =
dynamic_cast<surface::properties&
> (go.get_properties ());
10665 props.update_normals (
false,
true);
10667 else if (go.isa (
"patch"))
10669 patch::properties& props
10670 =
dynamic_cast<patch::properties&
> (go.get_properties ());
10671 props.update_normals (
false,
true);
10674 error (
"__update_normals__: "
10675 "H must be a handle to a valid surface or patch object.");
10712hggroup::properties::remove_child (
const graphics_handle& h,
bool from_root)
10714 gh_manager& gh_mgr = octave::__get_gh_manager__ ();
10718 if (! from_root && go.isa (
"light") && go.get_properties ().is_visible ())
10720 axes::properties& ax_props
10721 =
dynamic_cast<axes::properties&
> (go.get_ancestor (
"axes").get_properties ());
10722 ax_props.decrease_num_lights ();
10724 base_properties::remove_child (h, from_root);
10731 gh_manager& gh_mgr = octave::__get_gh_manager__ ();
10735 if (go.isa (
"light") && go.get_properties ().is_visible ())
10737 axes::properties& ax_props
10738 =
dynamic_cast<axes::properties&
> (go.get_ancestor (
"axes").get_properties ());
10739 ax_props.increase_num_lights ();
10741 base_properties::adopt (h);
10746hggroup::properties::update_limits ()
const
10748 gh_manager& gh_mgr = octave::__get_gh_manager__ ();
10750 graphics_object go = gh_mgr.
get_object (m___myhandle__);
10754 go.update_axis_limits (
"xlim");
10755 go.update_axis_limits (
"ylim");
10756 go.update_axis_limits (
"zlim");
10757 go.update_axis_limits (
"clim");
10758 go.update_axis_limits (
"alim");
10765 gh_manager& gh_mgr = octave::__get_gh_manager__ ();
10767 graphics_object go = gh_mgr.
get_object (m___myhandle__);
10771 go.update_axis_limits (
"xlim", h);
10772 go.update_axis_limits (
"ylim", h);
10773 go.update_axis_limits (
"zlim", h);
10774 go.update_axis_limits (
"clim", h);
10775 go.update_axis_limits (
"alim", h);
10779static bool updating_hggroup_limits =
false;
10782hggroup::update_axis_limits (
const std::string& axis_type,
10785 if (updating_hggroup_limits)
10790 double min_val = octave::numeric_limits<double>::Inf ();
10791 double max_val = -octave::numeric_limits<double>::Inf ();
10792 double min_pos = octave::numeric_limits<double>::Inf ();
10793 double max_neg = -octave::numeric_limits<double>::Inf ();
10798 char update_type = 0;
10800 if (axis_type ==
"xlim" || axis_type ==
"xliminclude")
10802 limits = m_properties.get_xlim ().matrix_value ();
10805 else if (axis_type ==
"ylim" || axis_type ==
"yliminclude")
10807 limits = m_properties.get_ylim ().matrix_value ();
10810 else if (axis_type ==
"zlim" || axis_type ==
"zliminclude")
10812 limits = m_properties.get_zlim ().matrix_value ();
10815 else if (axis_type ==
"clim" || axis_type ==
"climinclude")
10817 limits = m_properties.get_clim ().matrix_value ();
10820 else if (axis_type ==
"alim" || axis_type ==
"aliminclude")
10822 limits = m_properties.get_alim ().matrix_value ();
10826 if (limits.
numel () == 4)
10829 if (octave::math::isfinite (val))
10832 if (octave::math::isfinite (val))
10835 if (octave::math::isfinite (val))
10838 if (octave::math::isfinite (val))
10844 limits(0) = min_val;
10845 limits(1) = max_val;
10846 limits(2) = min_pos;
10847 limits(3) = max_neg;
10852 octave::unwind_protect_var<bool> restore_var (updating_hggroup_limits,
true);
10854 if (limits(0) != min_val || limits(1) != max_val
10855 || limits(2) != min_pos || limits(3) != max_neg)
10857 limits(0) = min_val;
10858 limits(1) = max_val;
10859 limits(2) = min_pos;
10860 limits(3) = max_neg;
10862 switch (update_type)
10865 m_properties.set_xlim (limits);
10869 m_properties.set_ylim (limits);
10873 m_properties.set_zlim (limits);
10877 m_properties.set_clim (limits);
10881 m_properties.set_alim (limits);
10889 base_graphics_object::update_axis_limits (axis_type, hg);
10894hggroup::update_axis_limits (
const std::string& axis_type)
10896 if (updating_hggroup_limits)
10899 Matrix kids = m_properties.get_children ();
10901 double min_val = octave::numeric_limits<double>::Inf ();
10902 double max_val = -octave::numeric_limits<double>::Inf ();
10903 double min_pos = octave::numeric_limits<double>::Inf ();
10904 double max_neg = -octave::numeric_limits<double>::Inf ();
10906 char update_type = 0;
10908 if (axis_type ==
"xlim" || axis_type ==
"xliminclude")
10914 else if (axis_type ==
"ylim" || axis_type ==
"yliminclude")
10920 else if (axis_type ==
"zlim" || axis_type ==
"zliminclude")
10926 else if (axis_type ==
"clim" || axis_type ==
"climinclude")
10932 else if (axis_type ==
"alim" || axis_type ==
"aliminclude")
10939 octave::unwind_protect_var<bool> restore_var (updating_hggroup_limits,
true);
10943 limits(0) = min_val;
10944 limits(1) = max_val;
10945 limits(2) = min_pos;
10946 limits(3) = max_neg;
10948 switch (update_type)
10951 m_properties.set_xlim (limits);
10955 m_properties.set_ylim (limits);
10959 m_properties.set_zlim (limits);
10963 m_properties.set_clim (limits);
10967 m_properties.set_alim (limits);
10974 base_graphics_object::update_axis_limits (axis_type);
10980uicontextmenu::properties::update_beingdeleted ()
10983 if (m_beingdeleted.is (
"on"))
10985 gh_manager& gh_mgr = octave::__get_gh_manager__ ();
10987 std::list<graphics_handle> lst = get_dependent_obj_list ();
10989 for (
auto& hobj : lst)
10991 graphics_object go = gh_mgr.
get_object (hobj);
10993 if (go.valid_object ()
10994 && go.get (
"contextmenu") == get___myhandle__ ())
10995 go.set (
"contextmenu",
Matrix ());
11030uicontrol::properties::get_extent ()
const
11032 Matrix m = m_extent.get ().matrix_value ();
11034 gh_manager& gh_mgr = octave::__get_gh_manager__ ();
11036 graphics_object parent_go = gh_mgr.
get_object (get_parent ());
11038 Matrix parent_bbox = parent_go.get_properties ().get_boundingbox (
true);
11041 return convert_position (m,
"pixels", get_units (), parent_size);
11045uicontrol::properties::update_text_extent ()
11049 gh_manager& gh_mgr = octave::__get_gh_manager__ ();
11051 graphics_object go = gh_mgr.
get_object (get___myhandle__ ());
11053 set_extent (go.get_toolkit ().get_text_extent (go));
11057uicontrol::properties::update_units ()
11059 Matrix pos = get_position ().matrix_value ();
11061 gh_manager& gh_mgr = octave::__get_gh_manager__ ();
11063 graphics_object parent_go = gh_mgr.
get_object (get_parent ());
11065 Matrix parent_bbox = parent_go.get_properties ().get_boundingbox (
true);
11068 pos = convert_position (pos, m_cached_units, get_units (), parent_size);
11069 set_position (pos);
11071 m_cached_units = get_units ();
11075uicontrol::properties::set_style (
const octave_value& st)
11077 gh_manager& gh_mgr = octave::__get_gh_manager__ ();
11079 graphics_object go_parent = gh_mgr.
get_object (get_parent ());
11080 if (go_parent.valid_object () && go_parent.isa (
"uibuttongroup"))
11082 bool was_button = style_is (
"radiobutton") || style_is (
"togglebutton");
11084 bool now_button = style_is (
"radiobutton") || style_is (
"togglebutton");
11085 uibuttongroup::properties& props =
11086 dynamic_cast<uibuttongroup::properties&
> (go_parent.get_properties ());
11088 if (! was_button && now_button && ! props.get_selectedobject ().ok ())
11090 props.set_selectedobject (get___myhandle__ ().value ());
11093 else if (was_button && ! now_button
11094 && (props.get_selectedobject ().value ()
11095 == get___myhandle__ ().value ()))
11096 props.set_selectedobject (
Matrix ());
11100 bool modified = m_style.set (st,
true,
false);
11105 if (style_is (
"listbox") || style_is (
"popupmenu"))
11107 Matrix v = m_value.get ().matrix_value ();
11108 if (v.
numel () == 1 && v(0) == 0)
11114 graphics_object go = gh_mgr.
get_object (get___myhandle__ ());
11117 go.update (m_style.get_id ());
11122uicontrol::properties::get_boundingbox (
bool,
11123 const Matrix& parent_pix_size)
const
11125 Matrix pos = get_position ().matrix_value ();
11126 Matrix parent_size (parent_pix_size);
11130 gh_manager& gh_mgr = octave::__get_gh_manager__ ();
11132 graphics_object go = gh_mgr.
get_object (get_parent ());
11134 if (go.valid_object ())
11135 parent_size = go.get_properties ().get_boundingbox (
true).
extract_n (0, 2, 1, 2);
11137 parent_size = default_figure_position ();
11140 pos = convert_position (pos, get_units (),
"pixels", parent_size);
11144 pos(1) = parent_size(1) - pos(1) - pos(3);
11150uicontrol::properties::set_fontunits (
const octave_value& val)
11154 if (m_fontunits.set (val,
true))
11156 update_fontunits (old_fontunits);
11162uicontrol::properties::update_fontunits (
const caseless_str& old_units)
11165 double parent_height = get_boundingbox (
false).elem (3);
11166 double fontsz = get_fontsize ();
11168 fontsz = convert_font_size (fontsz, old_units, new_units, parent_height);
11174uicontrol::properties::get___fontsize_points__ (
double box_pix_height)
const
11176 double fontsz = get_fontsize ();
11177 double parent_height = box_pix_height;
11179 if (fontunits_is (
"normalized") && parent_height <= 0)
11180 parent_height = get_boundingbox (
false).elem (3);
11182 return convert_font_size (fontsz, get_fontunits (),
"points", parent_height);
11188uibuttongroup::properties::get_boundingbox (
bool internal,
11189 const Matrix& parent_pix_size)
const
11191 Matrix pos = get_position ().matrix_value ();
11192 Matrix parent_size (parent_pix_size);
11196 gh_manager& gh_mgr = octave::__get_gh_manager__ ();
11198 graphics_object go = gh_mgr.
get_object (get_parent ());
11200 parent_size = go.get_properties ().get_boundingbox (
true).
extract_n (0, 2, 1, 2);
11203 pos = convert_position (pos, get_units (),
"pixels", parent_size);
11207 pos(1) = parent_size(1) - pos(1) - pos(3);
11211 double outer_height = pos(3);
11213 pos(0) = pos(1) = 0;
11215 if (! bordertype_is (
"none"))
11217 double bw = get_borderwidth ();
11220 if (bordertype_is (
"etchedin") || bordertype_is (
"etchedout"))
11223 pos(0) += mul * bw;
11224 pos(1) += mul * bw;
11225 pos(2) -= 2 * mul * bw;
11226 pos(3) -= 2 * mul * bw;
11229 if (! get_title ().empty ())
11231 double fontsz = get_fontsize ();
11233 if (! fontunits_is (
"pixels"))
11237 if (fontunits_is (
"points"))
11238 fontsz *= (res / 72.0);
11239 else if (fontunits_is (
"inches"))
11241 else if (fontunits_is (
"centimeters"))
11242 fontsz *= (res / 2.54);
11243 else if (fontunits_is (
"normalized"))
11244 fontsz *= outer_height;
11247 if (titleposition_is (
"lefttop") || titleposition_is (
"centertop")
11248 || titleposition_is (
"righttop"))
11249 pos(1) += (fontsz / 2);
11250 pos(3) -= (fontsz / 2);
11258uibuttongroup::properties::set_position (
const octave_value& v)
11261 bool modified =
false;
11263 old_bb = get_boundingbox (
true);
11264 modified = m_position.set (v,
false);
11265 new_bb = get_boundingbox (
true);
11267 if (old_bb != new_bb)
11269 if (old_bb(2) != new_bb(2) || old_bb(3) != new_bb(3))
11271 gh_manager& gh_mgr = octave::__get_gh_manager__ ();
11273 if (! get_resizefcn ().isempty ())
11276 if (! get_sizechangedfcn ().isempty ())
11279 update_boundingbox ();
11285 m_position.run_listeners (GCB_POSTSET);
11291uibuttongroup::properties::set_units (
const octave_value& val)
11295 if (m_units.set (val,
true))
11297 update_units (old_units);
11303uibuttongroup::properties::update_units (
const caseless_str& old_units)
11305 Matrix pos = get_position ().matrix_value ();
11307 gh_manager& gh_mgr = octave::__get_gh_manager__ ();
11309 graphics_object parent_go = gh_mgr.
get_object (get_parent ());
11311 Matrix parent_bbox = parent_go.get_properties ().get_boundingbox (
true);
11314 pos = convert_position (pos, old_units, get_units (), parent_size);
11315 set_position (pos);
11319uibuttongroup::properties::set_fontunits (
const octave_value& val)
11323 if (m_fontunits.set (val,
true))
11325 update_fontunits (old_fontunits);
11331uibuttongroup::properties::update_fontunits (
const caseless_str& old_units)
11334 double parent_height = get_boundingbox (
false).elem (3);
11335 double fontsz = get_fontsize ();
11337 fontsz = convert_font_size (fontsz, old_units, new_units, parent_height);
11343uibuttongroup::properties::get___fontsize_points__ (
double box_pix_height)
const
11345 double fontsz = get_fontsize ();
11346 double parent_height = box_pix_height;
11348 if (fontunits_is (
"normalized") && parent_height <= 0)
11349 parent_height = get_boundingbox (
false).elem (3);
11351 return convert_font_size (fontsz, get_fontunits (),
"points", parent_height);
11355uibuttongroup::properties::set_selectedobject (
const octave_value& v)
11358 m_selectedobject = current_selectedobject;
11361 if (current_selectedobject.
ok ())
11372 gh_manager& gh_mgr = octave::__get_gh_manager__ ();
11374 graphics_object go (gh_mgr.
get_object (val));
11376 base_properties& gop = go.get_properties ();
11378 if (go.valid_object ()
11379 && gop.get_parent () == get___myhandle__ ()
11380 && go.isa (
"uicontrol"))
11382 uicontrol::properties& cop
11383 =
dynamic_cast<uicontrol::properties&
> (go.get_properties ());
11385 if (style.
compare (
"radiobutton") || style.
compare (
"togglebutton"))
11387 m_selectedobject = val;
11393 err_set_invalid (
"selectedobject");
11401 if (h.
value () == current_selected.
value ())
11402 set_selectedobject (
Matrix ());
11404 base_properties::remove_child (h, from_root);
11410 base_properties::adopt (h);
11413 bool has_selected = current_selected.
ok ();
11415 gh_manager& gh_mgr = octave::__get_gh_manager__ ();
11419 if (! has_selected && go.valid_object () && go.isa (
"uicontrol"))
11421 const uicontrol::properties& props =
11422 dynamic_cast<const uicontrol::properties&
> (go.get_properties ());
11423 if (props.style_is (
"radiobutton") || props.style_is (
"togglebutton"))
11424 set_selectedobject (h.
value ());
11431uipanel::properties::get_boundingbox (
bool internal,
11432 const Matrix& parent_pix_size)
const
11434 Matrix pos = get_position ().matrix_value ();
11435 Matrix parent_size (parent_pix_size);
11439 gh_manager& gh_mgr = octave::__get_gh_manager__ ();
11441 graphics_object go = gh_mgr.
get_object (get_parent ());
11443 parent_size = go.get_properties ().get_boundingbox (
true).
extract_n (0, 2, 1, 2);
11446 pos = convert_position (pos, get_units (),
"pixels", parent_size);
11450 pos(1) = parent_size(1) - pos(1) - pos(3);
11454 double outer_height = pos(3);
11456 pos(0) = pos(1) = 0;
11458 if (! bordertype_is (
"none"))
11460 double bw = get_borderwidth ();
11463 if (bordertype_is (
"etchedin") || bordertype_is (
"etchedout"))
11466 pos(0) += mul * bw;
11467 pos(1) += mul * bw;
11468 pos(2) -= 2 * mul * bw;
11469 pos(3) -= 2 * mul * bw;
11472 if (! get_title ().empty ())
11474 double fontsz = get_fontsize ();
11476 if (! fontunits_is (
"pixels"))
11480 if (fontunits_is (
"points"))
11481 fontsz *= (res / 72.0);
11482 else if (fontunits_is (
"inches"))
11484 else if (fontunits_is (
"centimeters"))
11485 fontsz *= (res / 2.54);
11486 else if (fontunits_is (
"normalized"))
11487 fontsz *= outer_height;
11490 if (titleposition_is (
"lefttop") || titleposition_is (
"centertop")
11491 || titleposition_is (
"righttop"))
11492 pos(1) += (fontsz / 2);
11493 pos(3) -= (fontsz / 2);
11501uipanel::properties::set_position (
const octave_value& v)
11504 bool modified =
false;
11506 old_bb = get_boundingbox (
true);
11507 modified = m_position.set (v,
false);
11508 new_bb = get_boundingbox (
true);
11510 if (old_bb != new_bb)
11512 if (old_bb(2) != new_bb(2) || old_bb(3) != new_bb(3))
11514 gh_manager& gh_mgr = octave::__get_gh_manager__ ();
11516 if (! get_resizefcn ().isempty ())
11519 if (! get_sizechangedfcn ().isempty ())
11522 update_boundingbox ();
11528 m_position.run_listeners (GCB_POSTSET);
11535uipanel::properties::set_units (
const octave_value& val)
11539 if (m_units.set (val,
true))
11541 update_units (old_units);
11547uipanel::properties::update_units (
const caseless_str& old_units)
11549 Matrix pos = get_position ().matrix_value ();
11551 gh_manager& gh_mgr = octave::__get_gh_manager__ ();
11553 graphics_object parent_go = gh_mgr.
get_object (get_parent ());
11555 Matrix parent_bbox = parent_go.get_properties ().get_boundingbox (
true);
11558 pos = convert_position (pos, old_units, get_units (), parent_size);
11559 set_position (pos);
11563uipanel::properties::set_fontunits (
const octave_value& val)
11567 if (m_fontunits.set (val,
true))
11569 update_fontunits (old_fontunits);
11575uipanel::properties::update_fontunits (
const caseless_str& old_units)
11578 double parent_height = get_boundingbox (
false).elem (3);
11579 double fontsz = get_fontsize ();
11581 fontsz = convert_font_size (fontsz, old_units, new_units, parent_height);
11587uipanel::properties::get___fontsize_points__ (
double box_pix_height)
const
11589 double fontsz = get_fontsize ();
11590 double parent_height = box_pix_height;
11592 if (fontunits_is (
"normalized") && parent_height <= 0)
11593 parent_height = get_boundingbox (
false).elem (3);
11595 return convert_font_size (fontsz, get_fontunits (),
"points", parent_height);
11601uitable::properties::get_boundingbox (
bool,
11602 const Matrix& parent_pix_size)
const
11604 Matrix pos = get_position ().matrix_value ();
11605 Matrix parent_size (parent_pix_size);
11609 gh_manager& gh_mgr = octave::__get_gh_manager__ ();
11611 graphics_object go = gh_mgr.
get_object (get_parent ());
11613 parent_size = go.get_properties ().get_boundingbox (
true).
extract_n (0, 2, 1, 2);
11616 pos = convert_position (pos, get_units (),
"pixels", parent_size);
11620 pos(1) = parent_size(1) - pos(1) - pos(3);
11626uitable::properties::set_columnformat (
const octave_value& val)
11633 if (m_columnformat.set (val,
true))
11640 for (
int i = 0; i < cell_value.
numel (); i++)
11648 for (
int j = 0; j < popup.
numel (); j++)
11652 error (
"set: pop-up menu definitions must be non-empty strings");
11657 error (
"set: columnformat definintions must be a cellstr of "
11658 "either 'char', 'short [e|g|eng]?', 'long [e|g|eng]?', "
11659 "'numeric', 'bank', '+', 'rat', 'logical', "
11660 "or a cellstr of non-empty pop-up menu definitions.");
11664 if (m_columnformat.set (val,
true))
11669 if (m_columnformat.set (
Cell (),
true))
11674 error (
"set: expecting cell of strings");
11679uitable::properties::set_columnwidth (
const octave_value& val)
11681 bool isvalid =
true;
11686 if (option !=
"auto" && option !=
"fit")
11692 for (
int i = 0; i < cell_value.
numel (); i++)
11698 if (option !=
"auto" && option !=
"fit")
11711 error (
"set: expecting either 'auto', 'fit', or a cell array of pixel values, 'auto', or 'fit'");
11713 if (m_columnwidth.set (val,
true))
11718uitable::properties::set_data (
const octave_value& val)
11722 error (
"set: 'Data' must be an array or cell array");
11724 if (m_data.set (val,
true))
11729uitable::properties::set_units (
const octave_value& val)
11733 if (m_units.set (val,
true))
11735 update_units (old_units);
11741uitable::properties::update_units (
const caseless_str& old_units)
11743 Matrix pos = get_position ().matrix_value ();
11745 gh_manager& gh_mgr = octave::__get_gh_manager__ ();
11747 graphics_object parent_go = gh_mgr.
get_object (get_parent ());
11749 Matrix parent_bbox = parent_go.get_properties ().get_boundingbox (
true);
11752 pos = convert_position (pos, old_units, get_units (), parent_size);
11753 set_position (pos);
11757uitable::properties::set_fontunits (
const octave_value& val)
11761 if (m_fontunits.set (val,
true))
11763 update_fontunits (old_fontunits);
11769uitable::properties::update_fontunits (
const caseless_str& old_units)
11772 double parent_height = get_boundingbox (
false).elem (3);
11773 double fontsz = get_fontsize ();
11775 fontsz = convert_font_size (fontsz, old_units, new_units, parent_height);
11781uitable::properties::get___fontsize_points__ (
double box_pix_height)
const
11783 double fontsz = get_fontsize ();
11784 double parent_height = box_pix_height;
11786 if (fontunits_is (
"normalized") && parent_height <= 0)
11787 parent_height = get_boundingbox (
false).elem (3);
11789 return convert_font_size (fontsz, get_fontunits (),
"points", parent_height);
11793uitable::properties::get_fontsize_pixels (
double box_pix_height)
const
11795 double fontsz = get_fontsize ();
11796 double parent_height = box_pix_height;
11798 if (fontunits_is (
"normalized") && parent_height <= 0)
11799 parent_height = get_boundingbox (
false).elem (3);
11801 return convert_font_size (fontsz, get_fontunits (),
"pixels", parent_height);
11805uitable::properties::get_backgroundcolor_rgb ()
11807 Matrix bg = m_backgroundcolor.get ().matrix_value ();
11812uitable::properties::get_alternatebackgroundcolor_rgb ()
11815 Matrix bg = m_backgroundcolor.get ().matrix_value ();
11816 if (bg.
rows () > 1)
11823uitable::properties::get_extent_matrix ()
const
11825 return m_extent.get ().matrix_value ();
11829uitable::properties::get_extent ()
const
11832 Matrix m = m_extent.get ().matrix_value ();
11834 gh_manager& gh_mgr = octave::__get_gh_manager__ ();
11836 graphics_object parent_go = gh_mgr.
get_object (get_parent ());
11840 Matrix parent_bbox = parent_go.get_properties ().get_boundingbox (
true);
11843 return convert_position (m,
"pixels", get_units (), parent_size);
11852uitoolbar::get_default (
const caseless_str& pname)
const
11860 gh_manager& gh_mgr = octave::__get_gh_manager__ ();
11862 graphics_object parent_go = gh_mgr.
get_object (parent_h);
11864 retval = parent_go.get_default (pname);
11871uitoolbar::reset_default_properties ()
11874 m_default_properties = property_list ();
11876 remove_all_listeners ();
11877 xreset_default_properties (get_handle (), m_properties.factory_defaults ());
11883base_graphics_object::get_default (
const caseless_str& pname)
const
11887 gh_manager& gh_mgr = octave::__get_gh_manager__ ();
11889 graphics_object parent_go = gh_mgr.
get_object (parent_h);
11891 return parent_go.get_default (type () + pname);
11895base_graphics_object::get_factory_default (
const caseless_str& name)
const
11897 gh_manager& gh_mgr = octave::__get_gh_manager__ ();
11899 graphics_object parent_go = gh_mgr.
get_object (0);
11901 return parent_go.get_factory_default (type () + name);
11904class callback_event :
public base_graphics_event
11909 int busyaction = base_graphics_event::QUEUE)
11910 : base_graphics_event (busyaction), m_handle (h), m_callback_name (name),
11911 m_callback (), m_callback_data (data) { }
11915 int busyaction = base_graphics_event::QUEUE)
11916 : base_graphics_event (busyaction), m_handle (h), m_callback_name (),
11917 m_callback (cb), m_callback_data (data) { }
11919 OCTAVE_DISABLE_CONSTRUCT_COPY_MOVE (callback_event)
11921 ~callback_event () =
default;
11925 gh_manager& gh_mgr = octave::__get_gh_manager__ ();
11927 if (m_callback.is_defined ())
11935 std::string m_callback_name;
11940class mcode_event :
public base_graphics_event
11944 int busyaction = base_graphics_event::QUEUE)
11945 : base_graphics_event (busyaction), m_handle (h), m_mcode (cmd)
11948 OCTAVE_DISABLE_CONSTRUCT_COPY_MOVE (mcode_event)
11950 ~mcode_event () =
default;
11954 if (! m_mcode.empty ())
11956 gh_manager& gh_mgr = octave::__get_gh_manager__ ();
11958 graphics_object go = gh_mgr.
get_object (m_handle);
11960 if (go.valid_object ())
11970 std::string m_mcode;
11973class function_event :
public base_graphics_event
11977 function_event (graphics_event::event_fcn fcn,
void *data =
nullptr)
11978 : base_graphics_event (), m_function (fcn), m_function_data (data)
11981 OCTAVE_DISABLE_CONSTRUCT_COPY_MOVE (function_event)
11983 ~function_event () =
default;
11987 m_function (m_function_data);
11992 graphics_event::event_fcn m_function;
11994 void *m_function_data;
11997class set_event :
public base_graphics_event
12001 const octave_value& value,
bool do_notify_toolkit =
true,
12002 bool redraw_figure =
false)
12003 : base_graphics_event (), m_handle (h), m_property_name (name),
12004 m_property_value (value), m_notify_toolkit (do_notify_toolkit),
12005 m_redraw_figure (redraw_figure)
12008 OCTAVE_DISABLE_CONSTRUCT_COPY_MOVE (set_event)
12010 ~set_event () =
default;
12014 gh_manager& gh_mgr = octave::__get_gh_manager__ ();
12018 graphics_object go = gh_mgr.
get_object (m_handle);
12022 property p = go.get_properties ().get_property (m_property_name);
12032 if (go.isa (
"figure") && m_property_name ==
"position")
12034 figure::properties& fprops
12035 =
dynamic_cast<figure::properties&
> (go.get_properties ());
12036 fprops.set_position (m_property_value, m_notify_toolkit);
12038 else if (go.isa (
"figure") && m_property_name ==
"outerposition")
12040 figure::properties& fprops
12041 =
dynamic_cast<figure::properties&
> (go.get_properties ());
12042 fprops.set_outerposition (m_property_value, m_notify_toolkit);
12045 p.set (m_property_value,
true, m_notify_toolkit);
12047 if (m_redraw_figure)
12049 if (! go.isa (
"figure"))
12050 go = go.get_ancestor (
"figure");
12052 if (go.valid_object ())
12054 figure::properties& fprops
12055 =
dynamic_cast<figure::properties&
> (go.get_properties ());
12056 fprops.get_toolkit ().redraw_figure (go);
12065 std::string m_property_name;
12067 bool m_notify_toolkit;
12068 bool m_redraw_figure;
12073 const std::string& name,
12077 return graphics_event (
new callback_event (h, name, data, busyaction));
12086 return graphics_event (
new callback_event (h, cb, data, busyaction));
12091 const std::string& cmd,
12094 return graphics_event (
new mcode_event (h, cmd, busyaction));
12098graphics_event::create_function_event (graphics_event::event_fcn fcn,
12101 return graphics_event (
new function_event (fcn, data));
12106 const std::string& name,
12108 bool notify_toolkit,
bool redraw_figure)
12110 return graphics_event (
new set_event (h, name, data, notify_toolkit,
12114property_list::plist_map_type
12115root_figure::init_factory_properties ()
12117 property_list::plist_map_type plist_map;
12119 plist_map[
"figure"] = figure::properties::factory_defaults ();
12120 plist_map[
"axes"] = axes::properties::factory_defaults ();
12121 plist_map[
"line"] = line::properties::factory_defaults ();
12122 plist_map[
"text"] = text::properties::factory_defaults ();
12123 plist_map[
"image"] = image::properties::factory_defaults ();
12124 plist_map[
"patch"] = patch::properties::factory_defaults ();
12125 plist_map[
"scatter"] = scatter::properties::factory_defaults ();
12126 plist_map[
"surface"] = surface::properties::factory_defaults ();
12127 plist_map[
"light"] = light::properties::factory_defaults ();
12128 plist_map[
"hggroup"] = hggroup::properties::factory_defaults ();
12129 plist_map[
"uimenu"] = uimenu::properties::factory_defaults ();
12130 plist_map[
"uicontrol"] = uicontrol::properties::factory_defaults ();
12131 plist_map[
"uibuttongroup"] = uibuttongroup::properties::factory_defaults ();
12132 plist_map[
"uipanel"] = uipanel::properties::factory_defaults ();
12133 plist_map[
"uicontextmenu"] = uicontextmenu::properties::factory_defaults ();
12134 plist_map[
"uitoolbar"] = uitoolbar::properties::factory_defaults ();
12135 plist_map[
"uipushtool"] = uipushtool::properties::factory_defaults ();
12136 plist_map[
"uitoggletool"] = uitoggletool::properties::factory_defaults ();
12154 gh_manager& gh_mgr = interp.get_gh_manager ();
12158 if (args.
length () != 1)
12161 return ovl (ishghandle (args(0)));
12186 gh_manager& gh_mgr = octave::__get_gh_manager__ ();
12192is_handle_visible (
double val)
12194 gh_manager& gh_mgr = octave::__get_gh_manager__ ();
12196 return is_handle_visible (gh_mgr.
lookup (val));
12213 result.xelem (i) = is_handle_visible (handles(i));
12221DEFUN (__is_handle_visible__, args, ,
12227 if (args.
length () != 1)
12230 return ovl (is_handle_visible (args(0)));
12248 if (args.
length () != 1)
12252 ColumnVector hcv = args(0).xvector_value (
"reset: H must be a graphics handle");
12254 gh_manager& gh_mgr = interp.get_gh_manager ();
12258 gh_mgr.
get_object (hcv(n)).reset_default_properties ();
12488 int nargin = args.
length ();
12494 ColumnVector hcv = args(0).xvector_value (
"set: H must be a graphics handle");
12496 gh_manager& gh_mgr = interp.get_gh_manager ();
12505 if (hcv.
numel () > 1)
12506 error (
"set: H must be a single graphics handle when querying properties");
12508 graphics_object go = gh_mgr.
get_object (hcv(0));
12510 error (
"set: invalid handle (= %g)", hcv(0));
12513 retval = go.values_as_struct ();
12516 std::string s = go.values_as_string ();
12523 else if (nargin == 2 && args(1).is_string ())
12525 if (hcv.
numel () > 1)
12526 error (
"set: H must be a single graphics handle when querying properties");
12528 std::string
property = args(1).string_value ();
12529 std::transform (property.begin (), property.end (),
12530 property.begin (), tolower);
12532 graphics_object go = gh_mgr.
get_object (hcv(0));
12535 error (
"set: invalid handle (= %g)", hcv(0));
12539 if (go.has_readonly_property (property))
12547 else if (pmap.
isfield (property))
12550 retval = pmap.
getfield (property)(0);
12553 std::string s = go.value_as_string (property);
12559 error (R
"(set: unknown property "%s")", property.c_str ());
12564 bool request_drawnow =
false;
12569 graphics_object go = gh_mgr.
get_object (hcv(n));
12572 error (
"set: invalid handle (= %g)", hcv(n));
12577 if (args(i).is_string ())
12579 if (i == nargin - 1)
12580 error (
"set: PROPERTY name must be followed by a VALUE");
12583 go.set_value_or_default (pname, val);
12586 else if (args(i).iscellstr ())
12588 if ((i == nargin - 1) || ! args(i+1).iscell ())
12589 error (
"set: cell array of PROPERTIES must be followed by cell array of VALUES");
12590 if (args(i+1).cell_value ().rows () == 1)
12591 go.set (args(i).cellstr_value (), args(i+1).cell_value (), 0);
12592 else if (hcv.
numel () == args(i+1).cell_value ().rows ())
12593 go.set (args(i).cellstr_value (), args(i+1).cell_value (), n);
12595 error (
"set: number of graphics handles must match number of "
12596 "value rows (%" OCTAVE_IDX_TYPE_FORMAT
" != "
12597 "%" OCTAVE_IDX_TYPE_FORMAT
")",
12598 hcv.
numel (), args(i+1).cell_value ().rows ());
12601 else if (args(i).isstruct ())
12603 go.set (args(i).map_value ());
12607 error (
"set: invalid syntax");
12610 request_drawnow =
true;
12613 if (request_drawnow)
12655get_graphics_object_type (
double val)
12657 std::string retval;
12659 gh_manager& gh_mgr = octave::__get_gh_manager__ ();
12661 graphics_object go = gh_mgr.
get_object (val);
12664 error (
"get: invalid handle (= %g)", val);
12683 gh_manager& gh_mgr = interp.get_gh_manager ();
12687 int nargin = args.
length ();
12689 if (nargin < 1 || nargin > 2)
12692 if (args(0).isempty ())
12695 ColumnVector hcv = args(0).xvector_value (
"get: H must be a graphics handle");
12699 if (nargin == 1 && hcv_len > 1)
12701 std::string typ0 = get_graphics_object_type (hcv(0));
12705 std::string typ = get_graphics_object_type (hcv(n));
12708 error (
"get: vector of handles must all have the same type");
12714 bool use_cell_format =
false;
12716 if (nargin > 1 && args(1).iscellstr ())
12722 use_cell_format =
true;
12728 graphics_object go = gh_mgr.
get_object (hcv(n));
12731 error (
"get: invalid handle (= %g)", hcv(n));
12737 vals(n, m) = go.get (property);
12746 property = args(1).xstring_value (
"get: second argument must be property name or cell array of property names");
12752 graphics_object go = gh_mgr.
get_object (hcv(n));
12755 error (
"get: invalid handle (= %g)", hcv(n));
12758 vals(n) = go.get ();
12760 vals(n) = go.get (property);
12764 if (use_cell_format)
12772 else if (vals_len == 1)
12774 else if (vals_len > 1 && nargin == 1)
12779 tmp[n] = vals(n).scalar_map_value ();
12804 gh_manager& gh_mgr = interp.get_gh_manager ();
12808 if (args.
length () != 1)
12811 ColumnVector hcv = args(0).xvector_value (
"get: H must be a graphics handle");
12821 graphics_object go = gh_mgr.
get_object (hcv(n));
12824 error (
"get: invalid handle (= %g)", hcv(n));
12827 int state = toggle_warn (
"Octave:deprecated-property",
false);
12829 vals(n) = go.get (
true);
12831 toggle_warn (
"Octave:deprecated-property",
true, state);
12838 else if (vals_len == 1)
12839 return ovl (vals(0));
12845make_graphics_object (
const std::string& go_name,
12846 bool integer_figure_handle,
12851 double val = octave::numeric_limits<double>::NaN ();
12859 for (
int i = 0; i < xargs.
length (); i += 2)
12861 if (xargs(i).is_string () && p.compare (xargs(i).string_value ()))
12863 if (i >= (xargs.
length () - 1))
12864 error (
"__go_%s__: missing value for parent property",
12867 val = xargs(i+1).double_value ();
12869 xargs = xargs.
splice (i, 2);
12874 if (octave::math::isnan (val))
12875 val = args(0).xdouble_value (
"__go_%s__: invalid parent", go_name.c_str ());
12877 gh_manager& gh_mgr = octave::__get_gh_manager__ ();
12881 if (! parent.
ok ())
12882 error (
"__go_%s__: invalid parent", go_name.c_str ());
12889 integer_figure_handle,
false,
false);
12891 catch (octave::execution_exception& ee)
12893 error (ee,
"__go_%s__: %s, unable to create graphics handle",
12894 go_name.c_str (), ee.message ().c_str ());
12901 catch (octave::execution_exception& ee)
12904 error (ee,
"__go_%s__: %s, unable to create graphics handle",
12905 go_name.c_str (), ee.message ().c_str ());
12913 retval = h.
value ();
12920DEFMETHOD (__go_figure__, interp, args, ,
12926 gh_manager& gh_mgr = interp.get_gh_manager ();
12930 if (args.
length () == 0)
12933 double val = args(0).xdouble_value (
"__go_figure__: figure number must be a double value");
12943 retval = h.
value ();
12947 bool int_fig_handle =
true;
12953 if (octave::math::isnan (val))
12957 for (
int i = 0; i < xargs.
length (); i++)
12959 if (xargs(i).is_string ()
12960 && pname.
compare (xargs(i).string_value ()))
12962 if (i < (xargs.
length () - 1))
12964 std::string pval = xargs(i+1).string_value ();
12967 int_fig_handle = on.
compare (pval);
12968 xargs = xargs.
splice (i, 2);
12978 if (! int_fig_handle)
12984 go.get_properties ().init_integerhandle (
"off");
12987 else if (val > 0 && octave::math::is_integer (val))
12991 error (
"__go_figure__: failed to create figure handle");
12997 catch (octave::execution_exception& ee)
13000 error (ee,
"__go_figure__: unable to create figure handle");
13010 retval = h.
value ();
13016#define GO_BODY(TYPE) \
13017 gh_manager& gh_mgr = interp.get_gh_manager (); \
13019 octave::autolock guard (gh_mgr.graphics_lock ()); \
13021 if (args.length () == 0) \
13024 return octave_value (make_graphics_object (#TYPE, false, args)); \
13031 if (go.isa (
"surface"))
13033 else if ((go.isa (
"line") || go.isa (
"patch") || go.isa (
"scatter"))
13034 && ! go.get (
"zdata").isempty ())
13038 Matrix kids = go.get_properties ().get_children ();
13040 gh_manager& gh_mgr = octave::__get_gh_manager__ ();
13048 const graphics_object& kid = gh_mgr.
get_object (hkid);
13050 if (kid.valid_object ())
13062DEFMETHOD (__calc_dimensions__, interp, args, ,
13070 gh_manager& gh_mgr = interp.get_gh_manager ();
13074 if (args.
length () != 1)
13077 double h = args(0).xdouble_value (
"__calc_dimensions__: first argument must be a graphics handle");
13109DEFMETHOD (__go_image__, interp, args, ,
13118DEFMETHOD (__go_surface__, interp, args, ,
13127DEFMETHOD (__go_patch__, interp, args, ,
13136DEFMETHOD (__go_scatter__, interp, args, ,
13145DEFMETHOD (__go_light__, interp, args, ,
13154DEFMETHOD (__go_hggroup__, interp, args, ,
13163DEFMETHOD (__go_uimenu__, interp, args, ,
13172DEFMETHOD (__go_uicontrol__, interp, args, ,
13181DEFMETHOD (__go_uibuttongroup__, interp, args, ,
13190DEFMETHOD (__go_uipanel__, interp, args, ,
13199DEFMETHOD (__go_uicontextmenu__, interp, args, ,
13208DEFMETHOD (__go_uitable__, interp, args, ,
13217DEFMETHOD (__go_uitoolbar__, interp, args, ,
13226DEFMETHOD (__go_uipushtool__, interp, args, ,
13235DEFMETHOD (__go_uitoggletool__, interp, args, ,
13244DEFMETHOD (__go_delete__, interp, args, ,
13250 gh_manager& gh_mgr = interp.get_gh_manager ();
13254 if (args.
length () != 1)
13259 const NDArray vals = args(0).xarray_value (
"delete: invalid graphics object");
13265 h = gh_mgr.
lookup (vals(i));
13268 error (
"delete: invalid graphics object (= %g)", vals(i));
13276DEFMETHOD (__go_handles__, interp, args, ,
13282 gh_manager& gh_mgr = interp.get_gh_manager ();
13286 bool show_hidden =
false;
13289 show_hidden = args(0).bool_value ();
13294DEFMETHOD (__go_figure_handles__, interp, args, ,
13300 gh_manager& gh_mgr = interp.get_gh_manager ();
13304 bool show_hidden =
false;
13307 show_hidden = args(0).bool_value ();
13312DEFMETHOD (__go_execute_callback__, interp, args, ,
13319 int nargin = args.
length ();
13321 if (nargin < 2 || nargin > 3)
13324 const NDArray vals = args(0).xarray_value (
"__go_execute_callback__: invalid graphics object");
13326 std::string name = args(1).xstring_value (
"__go_execute_callback__: invalid callback name");
13328 gh_manager& gh_mgr = interp.get_gh_manager ();
13332 double val = vals(i);
13337 error (
"__go_execute_callback__: invalid graphics object (= %g)", val);
13348DEFMETHOD (__go_post_callback__, interp, args, ,
13355 int nargin = args.
length ();
13357 if (nargin < 2 || nargin > 3)
13360 const NDArray vals = args(0).xarray_value (
"__go_post_callback__: invalid graphics object");
13362 std::string name = args(1).xstring_value (
"__go_post_callback__: invalid callback name");
13364 gh_manager& gh_mgr = interp.get_gh_manager ();
13368 double val = vals(i);
13373 error (
"__go_execute_callback__: invalid graphics object (= %g)", val);
13384DEFMETHOD (__image_pixel_size__, interp, args, ,
13390 if (args.
length () != 1)
13393 gh_manager& gh_mgr = interp.get_gh_manager ();
13395 double h = args(0).xdouble_value (
"__image_pixel_size__: argument is not a handle");
13399 if (! go || ! go.isa (
"image"))
13400 error (
"__image_pixel_size__: object is not an image");
13402 image::properties& ip
13403 =
dynamic_cast<image::properties&
> (go.get_properties ());
13406 dp(0) = ip.pixel_xsize ();
13407 dp(1) = ip.pixel_ysize ();
13411DEFMETHOD (available_graphics_toolkits, interp, , ,
13418 gh_manager& gh_mgr = interp.get_gh_manager ();
13422 octave::gtk_manager& gtk_mgr = interp.get_gtk_manager ();
13424 return ovl (gtk_mgr.available_toolkits_list ());
13427DEFMETHOD (register_graphics_toolkit, interp, args, ,
13437 gh_manager& gh_mgr = interp.get_gh_manager ();
13441 if (args.
length () != 1)
13444 std::string name = args(0).xstring_value (
"register_graphics_toolkit: TOOLKIT must be a string");
13446 octave::gtk_manager& gtk_mgr = interp.get_gtk_manager ();
13448 gtk_mgr.register_toolkit (name);
13453DEFMETHOD (loaded_graphics_toolkits, interp, , ,
13460 gh_manager& gh_mgr = interp.get_gh_manager ();
13464 octave::gtk_manager& gtk_mgr = interp.get_gtk_manager ();
13466 return ovl (gtk_mgr.loaded_toolkits_list ());
13469DEFMETHOD (__show_figure__, interp, args, ,
13475 if (args.
length () != 1)
13478 gh_manager& gh_mgr = interp.get_gh_manager ();
13480 double h = args(0).xdouble_value (
"__show_figure__: invalid handle H");
13485 error (
"__show_figure__: invalid graphics object (= %g)", h);
13487 graphics_object go = gh_mgr.
get_object (gh);
13489 figure::properties& fprops
13490 =
dynamic_cast<figure::properties&
> (go.get_properties ());
13492 fprops.get_toolkit ().show_figure (go);
13523 gh_manager& gh_mgr = interp.get_gh_manager ();
13527 if (args.
length () <= 1)
13531 bool do_events =
true;
13533 if (args.
length () == 1)
13535 caseless_str val (args(0).xstring_value (
"drawnow: first argument must be a string"));
13540 error (
"drawnow: invalid argument, 'expose' is only valid option");
13555 for (
int i = 0; i < hlist.
numel (); i++)
13559 if (h.
ok () && h != 0)
13562 figure::properties& fprops
13563 =
dynamic_cast<figure::properties&
> (go.get_properties ());
13565 if (fprops.is_modified ())
13567 if (fprops.is_visible ())
13571 fprops.get_toolkit ().redraw_figure (go);
13576 fprops.set_modified (
false);
13584 std::string term, file, debug_file;
13586 term = args(0).xstring_value (
"drawnow: TERM must be a string");
13588 file = args(1).xstring_value (
"drawnow: FILE must be a string");
13591 error (
"drawnow: empty output ''");
13592 else if (file.length () == 1 && file[0] ==
'|')
13593 error (
"drawnow: empty pipe '|'");
13594 else if (file[0] !=
'|')
13596 std::size_t pos = file.find_last_of (octave::sys::file_ops::dir_sep_chars ());
13598 if (pos != std::string::npos)
13600 std::string
dirname = file.substr (0, pos+1);
13602 if (! octave::sys::dir_exists (
dirname))
13603 error (
"drawnow: nonexistent directory '%s'",
13609 debug_file = (args.
length () > 2 ? args(2).xstring_value (
"drawnow: DEBUG_FILE must be a string") :
13615 error (
"drawnow: nothing to draw");
13621 go.get_toolkit ().print_figure (go, term, file, debug_file);
13665 gh_manager& gh_mgr = interp.get_gh_manager ();
13669 int nargin = args.
length ();
13671 if (nargin < 3 || nargin > 4)
13674 double h = args(0).xdouble_value (
"addlistener: invalid handle H");
13676 std::string pname = args(1).xstring_value (
"addlistener: PROP must be a string");
13681 error (
"addlistener: invalid graphics object (= %g)", h);
13683 graphics_object go = gh_mgr.
get_object (gh);
13685 go.add_property_listener (pname, args(2), GCB_POSTSET);
13687 if (args.
length () == 4)
13690 if (persistent.
compare (
"persistent"))
13691 go.add_property_listener (pname, args(2), GCB_PERSISTENT);
13726 gh_manager& gh_mgr = interp.get_gh_manager ();
13733 double h = args(0).xdouble_value (
"dellistener: invalid handle");
13735 std::string pname = args(1).xstring_value (
"dellistener: PROP must be a string");
13740 error (
"dellistener: invalid graphics object (= %g)", h);
13742 graphics_object go = gh_mgr.
get_object (gh);
13744 if (args.
length () == 2)
13745 go.delete_property_listener (pname,
octave_value (), GCB_POSTSET);
13748 if (args(2).is_string ()
13749 && args(2).string_value () ==
"persistent")
13757 go.delete_property_listener (pname, args(2), GCB_POSTSET);
13835 gh_manager& gh_mgr = interp.get_gh_manager ();
13842 std::string name = args(0).xstring_value (
"addproperty: NAME must be a string");
13844 double h = args(1).xdouble_value (
"addproperty: invalid handle H");
13849 error (
"addproperty: invalid graphics object (= %g)", h);
13851 graphics_object go = gh_mgr.
get_object (gh);
13853 std::string type = args(2).xstring_value (
"addproperty: TYPE must be a string");
13855 if (go.get_properties ().has_property (name))
13856 error (
"addproperty: a '%s' property already exists in the graphics object",
13859 property p = property::create (name, gh, type, args.
splice (0, 3));
13861 go.get_properties ().insert_property (name, p);
13868 const std::string& fcn)
13870 gh_manager& gh_mgr = octave::__get_gh_manager__ ();
13874 graphics_object go = gh_mgr.
get_object (handle);
13877 error (
"%s: invalid handle (= %g)", fcn.c_str (), handle);
13886 gh_manager& gh_mgr = octave::__get_gh_manager__ ();
13890 graphics_object go = gh_mgr.
get_object (handle);
13893 error (
"%s: invalid handle (= %g)", fcn.c_str (), handle);
13901compare_property_values (octave::interpreter& interp,
13911 if (result.
length () > 0)
13912 return result(0).bool_value ();
13917static std::map<uint32_t, bool> waitfor_results;
13920cleanup_waitfor_id (uint32_t
id)
13922 waitfor_results.erase (
id);
13926do_cleanup_waitfor_listener (
const octave_value& listener,
13927 listener_mode mode = GCB_POSTSET)
13931 if (c.
numel () >= 4)
13933 double h = c(2).double_value ();
13937 gh_manager& gh_mgr = octave::__get_gh_manager__ ();
13945 graphics_object go = gh_mgr.
get_object (gh);
13947 if (go.get_properties ().has_property (pname))
13949 go.get_properties ().delete_listener (pname, listener, mode);
13951 if (mode == GCB_POSTSET)
13952 go.get_properties ().delete_listener (pname, listener,
13960cleanup_waitfor_postset_listener (
const octave_value& listener)
13961{ do_cleanup_waitfor_listener (listener, GCB_POSTSET); }
13964cleanup_waitfor_predelete_listener (
const octave_value& listener)
13965{ do_cleanup_waitfor_listener (listener, GCB_PREDELETE); }
13971 uint32_t
id = args(2).uint32_scalar_value ().value ();
13975 double h = args(0).double_value ();
13979 gh_manager& gh_mgr = octave::__get_gh_manager__ ();
13987 graphics_object go = gh_mgr.
get_object (gh);
13990 if (compare_property_values (interp, pvalue, args(5)))
13991 waitfor_results[id] =
true;
13995 waitfor_results[id] =
true;
14005 uint32_t
id = args(2).uint32_scalar_value ().value ();
14007 waitfor_results[id] =
true;
14056 if (args.
length () == 0)
14060 if (args(0).isempty ())
14063 double h = args(0).xdouble_value (
"waitfor: invalid handle value");
14065 if (! ishghandle (h) || (h == 0 && args.
length () == 1))
14070 octave::unwind_action cleanup_waitfor_id_action;
14071 octave::unwind_action cleanup_waitfor_postset_listener_action;
14072 octave::unwind_action cleanup_waitfor_predelete_listener_action;
14074 static uint32_t id_counter = 0;
14077 int max_arg_index = 0;
14078 int timeout_index = -1;
14080 double timeout = 0;
14082 gh_manager& gh_mgr = interp.get_gh_manager ();
14086 pname = args(1).xstring_value (
"waitfor: PROP must be a string");
14088 if (pname.empty ())
14089 error (
"waitfor: PROP must be a non-empty string");
14091 if (pname !=
"timeout")
14093 if (pname.
compare (R
"(\timeout)"))
14101 "waitfor_listener"));
14106 if (args(2).is_string ())
14119 Cell listener (1, max_arg_index >= 2 ? 5 : 4);
14122 cleanup_waitfor_id_action.set (cleanup_waitfor_id,
id);
14123 waitfor_results[id] =
false;
14125 listener(0) = wf_listener;
14128 listener(3) = pname;
14130 if (max_arg_index >= 2)
14131 listener(4) = args(2);
14141 graphics_object go = gh_mgr.
get_object (gh);
14143 if (max_arg_index >= 2
14144 && compare_property_values (interp, go.get (pname), args(2)))
14145 waitfor_results[id] =
true;
14148 cleanup_waitfor_postset_listener_action.set
14149 (cleanup_waitfor_postset_listener, ov_listener);
14151 go.add_property_listener (pname, ov_listener, GCB_POSTSET);
14152 go.add_property_listener (pname, ov_listener, GCB_PERSISTENT);
14154 if (go.get_properties ().has_dynamic_property (pname))
14161 (waitfor_del_listener,
14162 "waitfor_del_listener"));
14164 Cell del_listener (1, 4);
14166 del_listener(0) = wf_del_listener;
14168 del_listener(2) = h;
14169 del_listener(3) = pname;
14173 cleanup_waitfor_predelete_listener_action.set
14174 (cleanup_waitfor_predelete_listener, ov_del_listener);
14176 go.add_property_listener (pname, ov_del_listener,
14184 if (timeout_index < 0 && args.
length () > (max_arg_index + 1))
14187 1).xstring_value (
"waitfor: invalid parameter, expected 'timeout'");
14190 error (
"waitfor: invalid parameter '%s'", s.c_str ());
14192 timeout_index = max_arg_index + 1;
14195 if (timeout_index >= 0)
14197 if (args.
length () <= (timeout_index + 1))
14198 error (
"waitfor: missing TIMEOUT value");
14200 timeout = args(timeout_index + 1).xscalar_value (
"waitfor: TIMEOUT must be a scalar >= 1");
14204 warning (
"waitfor: TIMEOUT value must be >= 1, using 1 instead");
14224 octave::sys::time start;
14239 if (! pname.empty () && waitfor_results[
id])
14246 octave::sleep (0.1);
14250 octave::command_editor::run_event_hooks ();
14254 octave::sys::time now;
14256 if (start + timeout < now)
14272 int nargin = args.
length ();
14274 if (nargin != 2 && nargin != 3)
14277 double h = args(0).double_value ();
14279 gh_manager& gh_mgr = interp.get_gh_manager ();
14285 if (! handle.
ok ())
14286 error (
"__zoom__: invalid handle");
14288 graphics_object ax = gh_mgr.
get_object (handle);
14290 axes::properties& ax_props
14291 =
dynamic_cast<axes::properties&
> (ax.get_properties ());
14295 std::string opt = args(1).string_value ();
14297 if (opt ==
"out" || opt ==
"reset")
14301 ax_props.clear_zoom_stack ();
14305 ax_props.clear_zoom_stack (
false);
14310 std::string mode = args(1).string_value ();
14311 double factor = args(2).scalar_value ();
14313 ax_props.zoom (mode, factor);
14320DEFMETHOD (__get_frame__, interp, args, ,
14329 if (args.
length () != 1)
14332 double h = args(0).xdouble_value (
"__get_frame__: HFIG is not a handle");
14334 gh_manager& gh_mgr = interp.get_gh_manager ();
14338 if (! go || ! go.isa (
"figure"))
14339 error (
"__get_frame__: HFIG is not a figure");
14344 return ovl (go.get_toolkit ().get_pixels (go));
14347DEFMETHOD (__get_position__, interp, args, ,
14356 if (args.
length () != 2)
14360 = args(0).xdouble_value (
"__get_position__: H must be a graphics handle");
14363 = args(1).xstring_value (
"__get_position__: UNITS must be a string");
14365 gh_manager& gh_mgr = interp.get_gh_manager ();
14369 if (h == 0 || ! go)
14370 error (
"__get_position__: H must be a handle to a valid graphics object");
14372 graphics_object parent_go = gh_mgr.
get_object (go.get_parent ());
14373 Matrix bbox = parent_go.get_properties ().get_boundingbox (
true)
14376 Matrix pos = convert_position (go.get (
"position").matrix_value (),
14377 go.get (
"units").string_value (),
14383DEFUN (__get_system_fonts__, args, ,
14389 if (args.
length () != 0)
14392 octave::text_renderer txt_renderer;
14394 return ovl (txt_renderer.get_system_fonts ());
14397OCTAVE_END_NAMESPACE(octave)
N Dimensional Array with copy-on-write semantics.
const dim_vector & dims() const
Return a const-reference so that dims ()(i) works efficiently.
T & elem(octave_idx_type n)
Size of the specified dimension.
int ndims() const
Size of the specified dimension.
octave_idx_type rows() const
void resize(const dim_vector &dv, const T &rfv)
Size of the specified dimension.
Array< T, Alloc > as_column() const
Return the array as a column vector.
octave_idx_type columns() const
bool isempty() const
Size of the specified dimension.
const T * data() const
Size of the specified dimension.
T * rwdata()
Size of the specified dimension.
octave_idx_type lookup(const T &value, sortmode mode=UNSORTED) const
Do a binary lookup in a sorted array.
octave_idx_type numel() const
Number of elements in the array.
void resize(octave_idx_type n, const double &rfv=0)
RowVector transpose() const
ColumnVector extract_n(octave_idx_type r1, octave_idx_type n) const
ComplexColumnVector eigenvalues() const
MArray< T > reshape(const dim_vector &new_dims) const
RowVector row(octave_idx_type i) const
Matrix extract_n(octave_idx_type r1, octave_idx_type c1, octave_idx_type nr, octave_idx_type nc) const
ColumnVector row_min() const
void resize(octave_idx_type nr, octave_idx_type nc, double rfv=0)
ColumnVector row_max() const
bool any_element_is_inf_or_nan() const
bool compare(const std::string &s, std::size_t limit=std::string::npos) const
Vector representing the dimensions (size) of an Array.
static dim_vector alloc(int n)
octave_idx_type ndims() const
Number of dimensions.
graphics_handle current_figure() const
Matrix handle_list(bool show_hidden=false)
octave::mutex graphics_lock()
graphics_object get_object(double val) const
void renumber_figure(const graphics_handle &old_gh, const graphics_handle &new_gh)
void execute_listener(const graphics_handle &h, const octave_value &l)
void push_figure(const graphics_handle &h)
bool is_handle_visible(const graphics_handle &h) const
Matrix figure_handle_list(bool show_hidden=false)
graphics_handle lookup(double val) const
void free(const graphics_handle &h, bool from_root=false)
void pop_figure(const graphics_handle &h)
void post_callback(const graphics_handle &h, const std::string &name, const octave_value &data=Matrix())
graphics_handle make_graphics_handle(const std::string &go_name, const graphics_handle &p, bool integer_figure_handle=false, bool call_createfcn=true, bool notify_toolkit=true)
void execute_callback(const graphics_handle &h, const std::string &name, const octave_value &data=Matrix())
int process_events(bool force=false)
graphics_handle make_figure_handle(double val, bool notify_toolkit=true)
graphics_handle get_handle(bool integer_figure_handle)
octave_value as_octave_value() const
Cell getfield(const std::string &key) const
octave_idx_type nfields() const
string_vector keys() const
const Cell & contents(const_iterator p) const
bool isfield(const std::string &name) const
octave_idx_type numel() const
static octave_map cat(int dim, octave_idx_type n, const octave_scalar_map *map_list)
void setfield(const std::string &key, const octave_value &val)
void assign(const std::string &k, const octave_value &val)
octave_value getfield(const std::string &key) const
octave_value_list splice(octave_idx_type offset, octave_idx_type len, const octave_value_list &lst=octave_value_list()) const
octave_idx_type length() const
bool is_function_handle() const
bool is_undefined() const
bool is_uint32_type() const
std::string class_name() const
bool is_real_scalar() const
octave_idx_type rows() const
bool is_scalar_type() const
bool is_int8_type() const
bool is_single_type() const
double xdouble_value(const char *fmt,...) const
bool is_uint8_type() const
bool is_uint64_type() const
bool is_uint16_type() const
bool is_int16_type() const
octave_value reshape(const dim_vector &dv) const
octave_idx_type numel() const
std::string string_value(bool force=false) const
bool is_int64_type() const
bool is_matrix_type() const
string_vector string_vector_value(bool pad=false) const
NDArray array_value(bool frc_str_conv=false) const
bool is_double_type() const
bool is_int32_type() const
bool is_bool_scalar() const
std::string type_name() const
octave_idx_type columns() const
Matrix matrix_value(bool frc_str_conv=false) const
double double_value(bool frc_str_conv=false) const
string_vector & append(const std::string &s)
octave_idx_type numel() const
std::string join(const std::string &sep="") const
ColumnVector real(const ComplexColumnVector &a)
OCTAVE_BEGIN_NAMESPACE(octave) static octave_value daspk_fcn
#define DECLARE_STATIC_FUNX(name, args_name, nargout_name)
#define DECLARE_STATIC_METHODX(name, interp_name, args_name, nargout_name)
#define DEFMETHOD(name, interp_name, args_name, nargout_name, doc)
Macro to define a builtin method.
#define DEFUN(name, args_name, nargout_name, doc)
Macro to define a builtin function.
void warning(const char *fmt,...)
void warning_with_id(const char *id, const char *fmt,...)
void error(const char *fmt,...)
std::string dirname(const std::string &path)
octave_handle graphics_handle
void xset(const graphics_handle &h, const caseless_str &pname, const octave_value &val)
bool isfigure(double val)
void delete_graphics_object(const graphics_handle &h, bool from_root)
octave_value xget(const graphics_handle &h, const caseless_str &pname)
void delete_graphics_objects(const NDArray vals, bool from_root)
ColumnVector xform_vector()
void cross_product(double x1, double y1, double z1, double x2, double y2, double z2, double &x, double &y, double &z)
double dot(const ColumnVector &v1, const ColumnVector &v2)
void translate(Matrix &m, double x, double y, double z)
bool set_property_in_handle(double handle, const std::string &property, const octave_value &arg, const std::string &fcn)
#define CONVERT_CDATA_1(ARRAY_T, VAL_FN, IS_REAL)
ColumnVector cross(const ColumnVector &v1, const ColumnVector &v2)
std::vector< octave_idx_type > coplanar_partition(const Matrix &vert, const Matrix &idx, octave_idx_type nc, octave_idx_type jj)
void get_children_limits(double &min_val, double &max_val, double &min_pos, double &max_neg, const Matrix &kids, char limit_type)
double norm(const ColumnVector &v)
void xform(ColumnVector &v, const Matrix &m)
void normalize(ColumnVector &v)
base_graphics_object * make_graphics_object_from_type(const caseless_str &type, const graphics_handle &h, const graphics_handle &p)
Matrix xform_scale(double x, double y, double z)
ColumnVector cam2xform(const Array< double > &m)
int calc_dimensions(const graphics_object &go)
RowVector xform2cam(const ColumnVector &v)
void scale(Matrix &m, double x, double y, double z)
Matrix xform_translate(double x, double y, double z)
ColumnVector transform(const Matrix &m, double x, double y, double z)
#define CHECK_ARRAY_EQUAL(T, F, A)
bool is_coplanar(const Matrix &cov)
double force_in_range(double x, double lower, double upper)
octave_value get_property_from_handle(double handle, const std::string &property, const std::string &fcn)
void convert_cdata_1(bool is_scaled, bool is_real, double clim_0, double clim_1, const double *cmapv, const T *cv, octave_idx_type lda, octave_idx_type nc, double *av)
Complex atan(const Complex &x)
octave_int< uint32_t > octave_uint32
octave_int< T > xmin(const octave_int< T > &x, const octave_int< T > &y)
octave_int< T > xmax(const octave_int< T > &x, const octave_int< T > &y)
#define OCTAVE_LOCAL_BUFFER(T, buf, size)
const octave_char_matrix & v2
octave_value_list ovl(const OV_Args &... args)
Construct an octave_value_list with less typing.
template int8_t abs(int8_t)
F77_RET_T const F77_DBLE const F77_DBLE F77_DBLE * d
F77_RET_T const F77_DBLE * x
F77_RET_T const F77_DBLE const F77_DBLE * f