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;
2094children_property::do_delete_children (
bool clear,
bool from_root)
2096 gh_manager& gh_mgr = octave::__get_gh_manager__ ();
2102 graphics_object go = gh_mgr.
get_object (hchild);
2103 if (go.valid_object ()
2104 && ! go.get_properties ().is_beingdeleted ())
2105 gh_mgr.
free (hchild, from_root);
2107 m_children_list.clear ();
2110 while (! m_children_list.empty ())
2114 graphics_object go = gh_mgr.
get_object (hchild);
2115 if (go.valid_object ()
2116 && ! go.get_properties ().is_beingdeleted ())
2117 gh_mgr.
free (hchild, from_root);
2122 m_children_list.clear ();
2126callback_property::validate (
const octave_value& v)
const
2152 callback_props () : m_set () { }
2154 OCTAVE_DISABLE_COPY_MOVE (callback_props)
2156 ~callback_props () =
default;
2158 bool empty ()
const {
return m_set.empty (); }
2160 void insert (
const callback_property *ptr)
2162 m_set.insert (
reinterpret_cast<intptr_t
> (ptr));
2165 void erase (
const callback_property *ptr)
2167 m_set.erase (
reinterpret_cast<intptr_t
> (ptr));
2170 bool contains (
const callback_property *ptr)
const
2172 return m_set.find (
reinterpret_cast<intptr_t
> (ptr)) != m_set.end ();
2177 std::set<intptr_t> m_set;
2184static callback_props executing_callbacks;
2187callback_property::execute (
const octave_value& data)
const
2192 octave::unwind_action executing_callbacks_cleanup
2193 ([
this] () { executing_callbacks.erase (
this); });
2195 if (! executing_callbacks.contains (
this))
2197 executing_callbacks.insert (
this);
2199 if (m_callback.is_defined () && ! m_callback.isempty ())
2201 gh_manager& gh_mgr = octave::__get_gh_manager__ ();
2210static std::map<caseless_str, graphics_object> dprop_obj_map;
2220 std::string sv = (args.
length () > 0 ? args(0).string_value () :
"");
2222 retval = property (
new string_property (name, h, sv));
2224 else if (type.
compare (
"any"))
2229 retval = property (
new any_property (name, h, ov));
2231 else if (type.
compare (
"radio"))
2234 error (
"addproperty: missing possible values for radio property");
2236 std::string sv = args(0).xstring_value (
"addproperty: argument for radio property must be a string");
2238 retval = property (
new radio_property (name, h, sv));
2241 retval.set (args(1));
2243 else if (type.
compare (
"double"))
2245 double dv = (args.
length () > 0 ? args(0).double_value () : 0.0);
2247 retval = property (
new double_property (name, h, dv));
2249 else if (type.
compare (
"handle"))
2251 double hv = (args.
length () > 0 ? args(0).double_value ()
2252 : octave::numeric_limits<double>::NaN ());
2256 retval = property (
new handle_property (name, h, gh));
2258 else if (type.
compare (
"boolean"))
2260 retval = property (
new bool_property (name, h,
false));
2263 retval.set (args(0));
2265 else if (type.
compare (
"data"))
2267 retval = property (
new array_property (name, h,
Matrix ()));
2271 retval.set (args(0));
2276 else if (type.
compare (
"color"))
2278 color_values cv (0, 0, 0);
2282 rv = radio_values (args(1).string_value ());
2284 retval = property (
new color_property (name, h, cv, rv));
2286 if (args.
length () > 0 && ! args(0).isempty ())
2287 retval.set (args(0));
2289 retval.set (rv.default_value ());
2295 if (! lookup_object_name (type, go_name, go_rest))
2296 error (
"addproperty: unsupported type for dynamic property (= %s)",
2301 std::map<caseless_str, graphics_object>::const_iterator it
2302 = dprop_obj_map.find (go_name);
2304 if (it == dprop_obj_map.end ())
2310 go = graphics_object (bgo);
2312 dprop_obj_map[go_name] = go;
2318 if (! go.valid_object ())
2319 error (
"addproperty: invalid object type (= %s)",
2322 property prop = go.get_properties ().get_property (go_rest);
2324 retval = prop.clone ();
2326 retval.set_parent (h);
2327 retval.set_name (name);
2330 retval.set (args(0));
2339 gh_manager& gh_mgr = octave::__get_gh_manager__ ();
2345 Matrix children = go.get_properties ().get_all_children ();
2347 for (
int k = 0; k < children.
numel (); k++)
2348 finalize_r (children(k));
2357 gh_manager& gh_mgr = octave::__get_gh_manager__ ();
2363 Matrix children = go.get_properties ().get_all_children ();
2367 for (
int k = 0; k < children.
numel (); k++)
2368 initialize_r (children(k));
2373figure::properties::set_toolkit (
const octave::graphics_toolkit& b)
2376 finalize_r (get___myhandle__ ());
2379 m___graphics_toolkit__ = b.get_name ();
2380 m___plot_stream__ =
Matrix ();
2383 initialize_r (get___myhandle__ ());
2389figure::properties::set___mouse_mode__ (
const octave_value& val_arg)
2391 std::string direction =
"in";
2399 if (modestr ==
"zoom in")
2401 val = modestr =
"zoom";
2404 else if (modestr ==
"zoom out")
2406 val = modestr =
"zoom";
2410 if (m___mouse_mode__.set (val,
true))
2412 std::string mode = m___mouse_mode__.current_value ();
2415 pm.
setfield (
"Enable", mode ==
"pan" ?
"on" :
"off");
2416 set___pan_mode__ (pm);
2419 rm.
setfield (
"Enable", mode ==
"rotate" ?
"on" :
"off");
2420 set___rotate_mode__ (rm);
2423 zm.
setfield (
"Enable", mode ==
"zoom" ?
"on" :
"off");
2424 zm.
setfield (
"Direction", direction);
2425 set___zoom_mode__ (zm);
2429 else if (modestr ==
"zoom")
2432 std::string curr_direction
2435 if (direction != curr_direction)
2437 zm.
setfield (
"Direction", direction);
2438 set___zoom_mode__ (zm);
2447figure::properties::update_handlevisibility ()
2449 if (! is_handle_visible ())
2451 gh_manager& gh_mgr = octave::__get_gh_manager__ ();
2466 gh_mgr.
get_object (0).set (
"currentfigure", kidsarray(0));
2471 base_properties::update_handlevisibility ();
2477 gh_manager& gh_mgr = octave::__get_gh_manager__ ();
2481 if (go.isa (
"text"))
2483 text::properties& tp
2484 =
dynamic_cast<text::properties&
> (go.get_properties ());
2486 tp.update_text_extent ();
2488 else if (go.isa (
"figure") || go.isa (
"uipanel") || go.isa (
"axes")
2489 || go.isa (
"hggroup"))
2491 Matrix ch = go.get_properties ().get_all_children ();
2495 if (go.isa (
"axes"))
2497 axes::properties& ap
2498 =
dynamic_cast<axes::properties&
> (go.get_properties ());
2500 ap.sync_positions ();
2506figure::properties::update___device_pixel_ratio__ ()
2508 update_text_pos (get___myhandle__ ());
2516 std::size_t offset = 0;
2518 std::size_t
len = name.length ();
2529 pfx = name.substr (0, 5);
2535 pfx = name.substr (0, 6);
2541 pfx = name.substr (0, 7);
2549 pfx = name.substr (0, 9);
2556 pfx = name.substr (0, 10);
2558 if (pfx.
compare (
"uipushtool"))
2562 pfx = name.substr (0, 12);
2564 if (pfx.
compare (
"uitoogletool"))
2568 pfx = name.substr (0, 13);
2570 if (pfx.
compare (
"uicontextmenu")
2571 || pfx.
compare (
"uibuttongroup"))
2585 std::string pname = name.substr (offset);
2587 std::transform (pfx.begin (), pfx.end (), pfx.begin (), tolower);
2588 std::transform (pname.begin (), pname.end (), pname.begin (),
2591 bool has_property =
false;
2593 has_property = axes::properties::has_core_property (pname);
2594 else if (pfx ==
"figure")
2595 has_property = figure::properties::has_core_property (pname);
2596 else if (pfx ==
"line")
2597 has_property = line::properties::has_core_property (pname);
2598 else if (pfx ==
"text")
2599 has_property = text::properties::has_core_property (pname);
2600 else if (pfx ==
"image")
2601 has_property = image::properties::has_core_property (pname);
2602 else if (pfx ==
"patch")
2603 has_property = patch::properties::has_core_property (pname);
2604 else if (pfx ==
"scatter")
2605 has_property = scatter::properties::has_core_property (pname);
2606 else if (pfx ==
"surface")
2607 has_property = surface::properties::has_core_property (pname);
2608 else if (pfx ==
"hggroup")
2609 has_property = hggroup::properties::has_core_property (pname);
2610 else if (pfx ==
"uimenu")
2611 has_property = uimenu::properties::has_core_property (pname);
2612 else if (pfx ==
"uicontrol")
2613 has_property = uicontrol::properties::has_core_property (pname);
2614 else if (pfx ==
"uibuttongroup")
2615 has_property = uibuttongroup::properties::has_core_property (pname);
2616 else if (pfx ==
"uipanel")
2617 has_property = uipanel::properties::has_core_property (pname);
2618 else if (pfx ==
"uicontextmenu")
2619 has_property = uicontextmenu::properties::has_core_property (pname);
2620 else if (pfx ==
"uitable")
2621 has_property = uitable::properties::has_core_property (pname);
2622 else if (pfx ==
"uitoolbar")
2623 has_property = uitoolbar::properties::has_core_property (pname);
2624 else if (pfx ==
"uipushtool")
2625 has_property = uipushtool::properties::has_core_property (pname);
2628 error (
"invalid %s property '%s'", pfx.c_str (), pname.c_str ());
2630 bool remove =
false;
2635 remove = (sval ==
"remove");
2638 pval_map_type& pval_map = m_plist_map[pfx];
2642 auto p = pval_map.find (pname);
2644 if (p != pval_map.end ())
2648 pval_map[pname] = val;
2653 error (
"invalid default property specification");
2661 std::size_t offset = 0;
2663 std::size_t
len = name.length ();
2674 pfx = name.substr (0, 5);
2680 pfx = name.substr (0, 6);
2686 pfx = name.substr (0, 7);
2694 pfx = name.substr (0, 9);
2701 pfx = name.substr (0, 10);
2703 if (pfx.
compare (
"uipushtool"))
2707 pfx = name.substr (0, 12);
2709 if (pfx.
compare (
"uitoggletool"))
2713 pfx = name.substr (0, 13);
2715 if (pfx.
compare (
"uicontextmenu")
2716 || pfx.
compare (
"uibuttongroup"))
2728 std::string pname = name.substr (offset);
2730 std::transform (pfx.begin (), pfx.end (), pfx.begin (), tolower);
2731 std::transform (pname.begin (), pname.end (), pname.begin (),
2734 plist_map_const_iterator p = find (pfx);
2738 const pval_map_type& pval_map = p->second;
2740 pval_map_const_iterator q = pval_map.find (pname);
2742 if (q != pval_map.end ())
2752property_list::as_struct (
const std::string& prefix_arg)
const
2756 for (
const auto& p : *this)
2758 std::string prefix = prefix_arg + p.first;
2760 for (
const auto& prop_val : p.second)
2761 m.assign (prefix + prop_val.first, prop_val.second);
2772 int nargin = args.
length ();
2775 error (
"graphics_object::set: Nothing to set");
2777 for (
int i = 0; i < nargin; )
2779 if (args(i).isstruct ())
2781 set (args(i).map_value ());
2784 else if (i < nargin - 1)
2786 caseless_str pname = args(i).xstring_value (
"set: argument %d must be a property name", i);
2788 set_value_or_default (pname, val);
2792 error (
"set: invalid number of arguments");
2815 error (
"set: number of names must match number of value columns "
2816 "(%" OCTAVE_IDX_TYPE_FORMAT
" != %" OCTAVE_IDX_TYPE_FORMAT
")",
2826 set_value_or_default (pname, val);
2888 set_value_or_default (pname, val);
2941graphics_object::set_value_or_default (
const caseless_str& pname,
2950 if (sval ==
"default")
2952 default_val = get_default (pname);
2954 m_rep->set (pname, default_val);
2956 else if (sval ==
"factory")
2958 default_val = get_factory_default (pname);
2960 m_rep->set (pname, default_val);
2965 if (sval == R
"(\default)")
2966 m_rep->set (pname, "default");
2967 else if (sval == R
"(\factory)")
2968 m_rep->set (pname, "factory");
2970 m_rep->set (pname, val);
2974 m_rep->set (pname, val);
3001 return val.
isempty () ? octave::numeric_limits<double>::NaN ()
3011 return val.
isempty () ? octave::numeric_limits<double>::NaN ()
3018 gh_manager& gh_mgr = octave::__get_gh_manager__ ();
3020 graphics_object parent_go = gh_mgr.
get_object (parent_h);
3022 parent_go.adopt (h);
3032ishghandle (
double val)
3034 gh_manager& gh_mgr = octave::__get_gh_manager__ ();
3055 result.xelem (i) = ishghandle (handles(i));
3066 gh_manager& gh_mgr = octave::__get_gh_manager__ ();
3070 go.get_properties ().execute_createfcn ();
3076 gh_manager& gh_mgr = octave::__get_gh_manager__ ();
3087toggle_warn (std::string
id,
bool on,
int state = -1)
3091 state = octave::warning_enabled (
id);
3092 octave::disable_warning (
id);
3097 octave::set_warning_state (
id,
"on");
3098 else if (state == 2)
3099 octave::set_warning_state (
id,
"error");
3106 property_list::pval_map_type factory_pval)
3108 gh_manager& gh_mgr = octave::__get_gh_manager__ ();
3113 std::string go_name = go.get_properties ().graphics_object_name ();
3114 property_list::pval_map_type pval;
3115 go.build_user_defaults_map (pval, go_name);
3117 for (
const auto& p : pval)
3118 factory_pval[p.first] = p.second;
3121 int state = toggle_warn (
"Octave:deprecated-property",
false);
3124 for (
const auto& p : factory_pval)
3126 std::string pname = p.first;
3129 if (! go.has_readonly_property (pname)
3130 && pname.find (
"__") != 0 && pname.find (
"current") != 0
3131 && pname !=
"uicontextmenu" && pname !=
"parent")
3134 if (pname.find (
"mode") == (pname.length () - 4))
3135 pval[pname] = p.second;
3137 go.set (pname, p.second);
3142 for (
const auto& p : pval)
3143 go.set (p.first, p.second);
3145 toggle_warn (
"Octave:deprecated-property",
true, state);
3151base_properties::set_from_list (base_graphics_object& bgo,
3152 property_list& defaults)
3154 std::string go_name = graphics_object_name ();
3156 property_list::plist_map_const_iterator plist = defaults.find (go_name);
3158 if (plist != defaults.end ())
3160 const property_list::pval_map_type pval_map = plist->second;
3162 for (
const auto& prop_val : pval_map)
3164 std::string pname = prop_val.first;
3168 bgo.set (pname, prop_val.second);
3170 catch (octave::execution_exception& ee)
3172 error (ee,
"error setting default property %s", pname.c_str ());
3195base_properties::get_dynamic (
const caseless_str& pname)
const
3197 std::map<caseless_str, property, cmp_caseless_str>::const_iterator it
3198 = m_all_props.find (pname);
3200 if (it == m_all_props.end ())
3201 error (R
"(get: unknown property "%s")", pname.c_str ());
3203 return it->second.get ();
3207base_properties::get_dynamic (
bool all)
const
3211 for (
const auto& it : m_all_props)
3212 if (all || ! it.second.is_hidden ())
3213 m.assign (it.second.get_name (), it.second.get ());
3218std::set<std::string>
3219base_properties::dynamic_property_names ()
const
3221 return m_dynamic_properties;
3225base_properties::has_dynamic_property (
const std::string& pname)
const
3227 const std::set<std::string>& dynprops = dynamic_property_names ();
3229 if (dynprops.find (pname) != dynprops.end ())
3232 return m_all_props.find (pname) != m_all_props.end ();
3236base_properties::set_dynamic (
const caseless_str& pname,
3239 auto it = m_all_props.find (pname);
3241 if (it == m_all_props.end ())
3242 error (R
"(set: unknown property "%s")", pname.c_str ());
3244 it->second.set (val);
3246 m_dynamic_properties.insert (pname);
3252base_properties::get_property_dynamic (
const caseless_str& pname)
const
3254 std::map<caseless_str, property, cmp_caseless_str>::const_iterator it
3255 = m_all_props.find (pname);
3257 if (it == m_all_props.end ())
3258 error (R
"(get_property: unknown property "%s")", pname.c_str ());
3266 double hp = val.
xdouble_value (
"set: parent must be a graphics handle");
3267 if (hp == m___myhandle__)
3268 error (
"set: can not set object parent to be object itself");
3270 gh_manager& gh_mgr = octave::__get_gh_manager__ ();
3273 if (! new_parent.
ok ())
3274 error (
"set: invalid graphics handle (= %g) for parent", hp);
3277 graphics_object old_parent_go;
3278 old_parent_go = gh_mgr.
get_object (get_parent ());
3280 if (old_parent_go.get_handle () != hp)
3281 old_parent_go.remove_child (m___myhandle__);
3286 graphics_object new_parent_go;
3287 new_parent_go = gh_mgr.
get_object (new_parent);
3288 if (new_parent_go.get_parent () == m___myhandle__)
3291 new_parent_go.get_properties ().set_parent (get_parent ().as_octave_value ());
3296 octave::adopt (m_parent.handle_value (), m___myhandle__);
3312base_properties::mark_modified ()
3315 m___modified__ =
"on";
3319 gh_manager& gh_mgr = octave::__get_gh_manager__ ();
3321 graphics_object parent_go = gh_mgr.
get_object (get_parent ());
3324 parent_go.mark_modified ();
3328base_properties::override_defaults (base_graphics_object& obj)
3330 gh_manager& gh_mgr = octave::__get_gh_manager__ ();
3332 graphics_object parent_go = gh_mgr.
get_object (get_parent ());
3335 parent_go.override_defaults (obj);
3339base_properties::update_axis_limits (
const std::string& axis_type)
const
3341 gh_manager& gh_mgr = octave::__get_gh_manager__ ();
3343 graphics_object go = gh_mgr.
get_object (m___myhandle__);
3346 go.update_axis_limits (axis_type);
3350base_properties::update_axis_limits (
const std::string& axis_type,
3353 gh_manager& gh_mgr = octave::__get_gh_manager__ ();
3355 graphics_object go = gh_mgr.
get_object (m___myhandle__);
3358 go.update_axis_limits (axis_type, h);
3362base_properties::update_contextmenu ()
const
3364 if (m_contextmenu.get ().isempty ())
3367 gh_manager& gh_mgr = octave::__get_gh_manager__ ();
3369 graphics_object go = gh_mgr.
get_object (m_contextmenu.get ());
3371 if (go && go.isa (
"uicontextmenu"))
3373 uicontextmenu::properties& props
3374 =
reinterpret_cast<uicontextmenu::properties&
> (go.get_properties ());
3375 props.add_dependent_obj (m___myhandle__);
3380base_properties::is_handle_visible ()
const
3382 return (m_handlevisibility.is (
"on")
3383 || (! executing_callbacks.empty () && ! m_handlevisibility.is (
"off")));
3386octave::graphics_toolkit
3387base_properties::get_toolkit ()
const
3389 gh_manager& gh_mgr = octave::__get_gh_manager__ ();
3391 graphics_object go = gh_mgr.
get_object (get_parent ());
3394 return go.get_toolkit ();
3396 return octave::graphics_toolkit ();
3400base_properties::update_boundingbox ()
3402 Matrix kids = get_children ();
3404 gh_manager& gh_mgr = octave::__get_gh_manager__ ();
3406 for (
int i = 0; i < kids.
numel (); i++)
3408 graphics_object go = gh_mgr.
get_object (kids(i));
3410 if (go.valid_object ())
3411 go.get_properties ().update_boundingbox ();
3416base_properties::update_autopos (
const std::string& elem_type)
3418 gh_manager& gh_mgr = octave::__get_gh_manager__ ();
3420 graphics_object parent_go = gh_mgr.
get_object (get_parent ());
3422 if (parent_go.valid_object ())
3423 parent_go.get_properties ().update_autopos (elem_type);
3427base_properties::update_handlevisibility ()
3429 if (is_handle_visible ())
3434 gh_manager& gh_mgr = octave::__get_gh_manager__ ();
3436 graphics_object go (gh_mgr.
get_object (get___myhandle__ ()));
3438 graphics_object fig (go.get_ancestor (
"figure"));
3440 if (fig.valid_object ())
3447 auto& fig_props =
dynamic_cast<figure::properties&
> (fig.get_properties ());
3448 fig_props.set_currentobject (
Matrix ());
3492base_properties::add_listener (
const caseless_str& pname,
3496 property p = get_property (pname);
3499 p.add_listener (val, mode);
3503base_properties::delete_listener (
const caseless_str& pname,
3507 property p = get_property (pname);
3510 p.delete_listener (val, mode);
3514base_properties::get_children_of_type (
const caseless_str& chtype,
3517 std::list<graphics_object>& children_list)
const
3519 gh_manager& gh_mgr = octave::__get_gh_manager__ ();
3521 Matrix ch = get_children ();
3529 graphics_object go = gh_mgr.
get_object (hkid);
3530 if ( get_invisible || go.get_properties ().is_visible () )
3532 if (go.isa (chtype))
3533 children_list.push_back (go);
3534 else if (traverse && go.isa (
"hggroup"))
3535 go.get_properties ().get_children_of_type (chtype,
3547base_graphics_object::update_axis_limits (
const std::string& axis_type)
3549 if (! valid_object ())
3550 error (
"base_graphics_object::update_axis_limits: invalid graphics object");
3552 gh_manager& gh_mgr = octave::__get_gh_manager__ ();
3554 graphics_object parent_go = gh_mgr.
get_object (get_parent ());
3557 parent_go.update_axis_limits (axis_type);
3561base_graphics_object::update_axis_limits (
const std::string& axis_type,
3564 if (! valid_object ())
3565 error (
"base_graphics_object::update_axis_limits: invalid graphics object");
3567 gh_manager& gh_mgr = octave::__get_gh_manager__ ();
3569 graphics_object parent_go = gh_mgr.
get_object (get_parent ());
3572 parent_go.update_axis_limits (axis_type, h);
3576base_graphics_object::remove_all_listeners ()
3578 int state = toggle_warn (
"Octave:deprecated-property",
false);
3580 toggle_warn (
"Octave:deprecated-property",
true, state);
3582 for (
const auto& pm : m)
3588 octave::unwind_protect frame;
3590 octave::interpreter_try (frame);
3594 property p = get_properties ().get_property (pm.first);
3597 p.delete_listener ();
3599 catch (
const octave::execution_exception&)
3601 octave::interpreter& interp = octave::__get_interpreter__ ();
3603 interp.recover_from_exception ();
3609base_graphics_object::build_user_defaults_map (property_list::pval_map_type& def,
3610 const std::string go_name)
const
3612 property_list local_defaults = get_defaults_list ();
3613 const auto it = local_defaults.find (go_name);
3615 if (it != local_defaults.end ())
3617 property_list::pval_map_type pval_lst = it->second;
3618 for (
const auto& prop_val : pval_lst)
3620 std::string pname = prop_val.first;
3621 if (def.find (pname) == def.end ())
3622 def[pname] = prop_val.second;
3626 gh_manager& gh_mgr = octave::__get_gh_manager__ ();
3628 graphics_object parent_go = gh_mgr.
get_object (get_parent ());
3631 parent_go.build_user_defaults_map (def, go_name);
3635base_graphics_object::reset_default_properties ()
3637 if (valid_object ())
3639 gh_manager& gh_mgr = octave::__get_gh_manager__ ();
3641 property_list::pval_map_type factory_pval
3642 = gh_mgr.
get_object (0).get_factory_defaults_list ().find (type ())->second;
3644 remove_all_listeners ();
3645 xreset_default_properties (get_handle (), factory_pval);
3650base_graphics_object::values_as_string ()
3652 if (! valid_object ())
3653 error (
"base_graphics_object::values_as_string: invalid graphics object");
3658 gh_manager& gh_mgr = octave::__get_gh_manager__ ();
3660 graphics_object go = gh_mgr.
get_object (get_handle ());
3662 for (
const auto& pm : m)
3664 const auto& pname = pm.first;
3665 if (pname !=
"children" && ! go.has_readonly_property (pname))
3667 property p = get_properties ().get_property (pname);
3669 if (p.ok () && ! p.is_hidden ())
3671 retval +=
"\n\t" + std::string (pname) +
": ";
3673 retval += p.values_as_string ();
3678 if (! retval.empty ())
3685base_graphics_object::value_as_string (
const std::string& prop)
3689 if (! valid_object ())
3690 error (
"base_graphics_object::value_as_string: invalid graphics object");
3692 gh_manager& gh_mgr = octave::__get_gh_manager__ ();
3694 graphics_object go = gh_mgr.
get_object (get_handle ());
3696 if (prop !=
"children" && ! go.has_readonly_property (prop))
3698 property p = get_properties ().get_property (prop);
3700 if (p.ok () && ! p.is_hidden ())
3703 retval += p.values_as_string ();
3707 if (! retval.empty ())
3714base_graphics_object::values_as_struct ()
3718 if (! valid_object ())
3719 error (
"base_graphics_object::values_as_struct: invalid graphics object");
3723 gh_manager& gh_mgr = octave::__get_gh_manager__ ();
3725 graphics_object go = gh_mgr.
get_object (get_handle ());
3727 for (
const auto& pm : m)
3729 const auto& pname = pm.first;
3730 if (pname !=
"children" && ! go.has_readonly_property (pname))
3732 property p = get_properties ().get_property (pname);
3734 if (p.ok () && ! p.is_hidden ())
3737 retval.
assign (p.get_name (), p.values_as_cell ());
3768graphics_object::get_ancestor (
const std::string& obj_type)
const
3770 if (valid_object ())
3776 gh_manager& gh_mgr = octave::__get_gh_manager__ ();
3778 return gh_mgr.
get_object (get_parent ()).get_ancestor (obj_type);
3782 return graphics_object ();
3787#include "graphics-props.cc"
3792root_figure::properties::set_callbackobject (
const octave_value& v)
3796 if (octave::math::isnan (val.value ()))
3798 else if (ishghandle (val))
3799 m_callbackobject = val;
3801 err_set_invalid (
"callbackobject");
3805root_figure::properties::set_currentfigure (
const octave_value& v)
3809 if (octave::math::isnan (val.value ()) || ishghandle (val))
3811 m_currentfigure = val;
3815 gh_manager& gh_mgr = octave::__get_gh_manager__ ();
3821 err_set_invalid (
"currentfigure");
3825figure::properties::set_integerhandle (
const octave_value& val)
3827 if (m_integerhandle.set (val,
true))
3829 bool int_fig_handle = m_integerhandle.is_on ();
3831 gh_manager& gh_mgr = octave::__get_gh_manager__ ();
3833 graphics_object this_go = gh_mgr.
get_object (m___myhandle__);
3837 m___myhandle__ = gh_mgr.
get_handle (int_fig_handle);
3841 graphics_object parent_go = gh_mgr.
get_object (get_parent ());
3843 base_properties& props = parent_go.get_properties ();
3845 props.renumber_child (old_myhandle, m___myhandle__);
3847 Matrix kids = get_children ();
3851 graphics_object kid = gh_mgr.
get_object (kids(i));
3853 kid.get_properties ().renumber_parent (m___myhandle__);
3858 if (m___myhandle__ == cf)
3859 xset (0,
"currentfigure", m___myhandle__.value ());
3861 this_go.update (m_integerhandle.get_id ());
3870root_figure::properties::update_units ()
3872 std::string xunits = get_units ();
3874 Matrix scrn_sz = default_screensize ();
3876 double dpi = get_screenpixelsperinch ();
3878 if (xunits ==
"pixels")
3883 else if (xunits ==
"normalized")
3885 scrn_sz =
Matrix (1, 4, 1.0);
3889 else if (xunits ==
"inches")
3896 else if (xunits ==
"centimeters")
3900 scrn_sz(2) *= 2.54 / dpi;
3901 scrn_sz(3) *= 2.54 / dpi;
3903 else if (xunits ==
"points")
3907 scrn_sz(2) *= 72 / dpi;
3908 scrn_sz(3) *= 72 / dpi;
3910 else if (xunits ==
"characters")
3916 scrn_sz(2) *= 74.951 / 12.0 / dpi;
3917 scrn_sz(3) *= 74.951 / 12.0 / dpi;
3920 set_screensize (scrn_sz);
3924root_figure::properties::get_boundingbox (
bool,
const Matrix&)
const
3926 Matrix screen_size = screen_size_pixels ();
3929 pos(2) = screen_size(0);
3930 pos(3) = screen_size(1);
3963 gh_manager& gh_mgr = octave::__get_gh_manager__ ();
3971 base_properties::remove_child (h,
true);
3975root_figure::reset_default_properties ()
3978 m_default_properties = property_list ();
3980 remove_all_listeners ();
3981 xreset_default_properties (get_handle (),
3982 m_properties.factory_defaults ());
3988figure::properties::set_currentaxes (
const octave_value& val)
3992 if (octave::math::isnan (hax.value ()) || ishghandle (hax))
3993 m_currentaxes = hax;
3995 err_set_invalid (
"currentaxes");
3999figure::properties::remove_child (
const graphics_handle& h,
bool from_root)
4001 base_properties::remove_child (h, from_root);
4003 if (h == m_currentaxes.handle_value ())
4007 Matrix kids = get_children ();
4009 gh_manager& gh_mgr = octave::__get_gh_manager__ ();
4015 graphics_object go = gh_mgr.
get_object (kid);
4017 if (go.isa (
"axes"))
4019 new_currentaxes = kid;
4024 m_currentaxes = new_currentaxes;
4029figure::properties::get_number ()
const
4031 if (m_integerhandle.is_on ())
4032 return m___myhandle__.value ();
4037octave::graphics_toolkit
4038figure::properties::get_toolkit ()
const
4044figure::properties::set___graphics_toolkit__ (
const octave_value& val)
4047 error (
"set___graphics_toolkit__: toolkit must be a string");
4051 octave::gtk_manager& gtk_mgr = octave::__get_gtk_manager__ ();
4053 octave::graphics_toolkit b = gtk_mgr.find_toolkit (nm);
4055 if (b.get_name () != nm)
4056 error (
"set___graphics_toolkit__: invalid graphics toolkit");
4058 if (nm != get___graphics_toolkit__ ())
4068 base_properties::adopt (h);
4070 if (! get_currentaxes ().ok ())
4072 gh_manager& gh_mgr = octave::__get_gh_manager__ ();
4076 if (go.type () ==
"axes")
4100figure::properties::set_visible (
const octave_value& val)
4105 xset (0,
"currentfigure", m___myhandle__.value ());
4111figure::properties::get_boundingbox (
bool internal,
const Matrix&)
const
4113#if defined (__APPLE__) && defined (__MACH__)
4127 double dpr = get___device_pixel_ratio__ ();
4129 Matrix screen_size = screen_size_pixels ();
4131 get_position ().matrix_value () :
4132 get_outerposition ().matrix_value ());
4134 pos = convert_position (pos, get_units (),
"pixels", screen_size);
4138 pos(1) = screen_size(1) / dpr - pos(1) - pos(3);
4144figure::properties::bbox2position (
const Matrix& bb)
const
4146#if defined (__APPLE__) && defined (__MACH__)
4150 double dpr = get___device_pixel_ratio__ ();
4152 Matrix screen_size = screen_size_pixels ();
4155 pos(1) = screen_size(1) - (pos(1) + pos(3)) * dpr;
4158 pos = convert_position (pos,
"pixels", get_units (), screen_size);
4163figure::properties::set_boundingbox (
const Matrix& bb,
bool internal,
4164 bool do_notify_toolkit)
4166 Matrix pos = bbox2position (bb);
4169 set_position (pos, do_notify_toolkit);
4171 set_outerposition (pos, do_notify_toolkit);
4175figure::properties::map_from_boundingbox (
double x,
double y)
const
4177 Matrix bb = get_boundingbox (
true);
4183 pos(1) = bb(3) - pos(1);
4185 pos = convert_position (pos,
"pixels", get_units (),
4192figure::properties::map_to_boundingbox (
double x,
double y)
const
4194 Matrix bb = get_boundingbox (
true);
4200 pos = convert_position (pos, get_units (),
"pixels",
4203 pos(1) = bb(3) - pos(1);
4209figure::properties::set_position (
const octave_value& v,
4210 bool do_notify_toolkit)
4213 bool modified =
false;
4215 old_bb = get_boundingbox (
true);
4216 modified = m_position.set (v,
false, do_notify_toolkit);
4217 new_bb = get_boundingbox (
true);
4219 if (old_bb != new_bb)
4221 if (old_bb(2) != new_bb(2) || old_bb(3) != new_bb(3))
4223 gh_manager& gh_mgr = octave::__get_gh_manager__ ();
4225 if (! get_resizefcn ().isempty ())
4228 if (! get_sizechangedfcn ().isempty ())
4231 update_boundingbox ();
4237 m_position.run_listeners (GCB_POSTSET);
4241 if (m_paperpositionmode.is (
"auto"))
4242 m_paperposition.set (get_auto_paperposition ());
4246figure::properties::set_outerposition (
const octave_value& v,
4247 bool do_notify_toolkit)
4249 if (m_outerposition.set (v,
true, do_notify_toolkit))
4254figure::properties::set_paperunits (
const octave_value& val)
4260 error (
"set: can't set paperunits to normalized when papertype is custom");
4263 if (m_paperunits.set (val,
true))
4265 update_paperunits (old_paperunits);
4271figure::properties::set_papertype (
const octave_value& val)
4277 error (
"set: can't set paperunits to normalized when papertype is custom");
4279 if (m_papertype.set (val,
true))
4281 update_papertype ();
4289 Matrix retval (1, 2, 1.0);
4291 if (! punits.
compare (
"normalized"))
4296 if (punits.
compare (
"inches"))
4299 mm2units = 1 / 25.4;
4301 else if (punits.
compare (
"centimeters"))
4304 mm2units = 1 / 10.0;
4309 mm2units = 72.0 / 25.4;
4312 if (ptype.
compare (
"usletter"))
4314 retval(0) = 8.5 * in2units;
4315 retval(1) = 11.0 * in2units;
4317 else if (ptype.
compare (
"uslegal"))
4319 retval(0) = 8.5 * in2units;
4320 retval(1) = 14.0 * in2units;
4322 else if (ptype.
compare (
"tabloid"))
4324 retval(0) = 11.0 * in2units;
4325 retval(1) = 17.0 * in2units;
4327 else if (ptype.
compare (
"a0"))
4329 retval(0) = 841.0 * mm2units;
4330 retval(1) = 1189.0 * mm2units;
4332 else if (ptype.
compare (
"a1"))
4334 retval(0) = 594.0 * mm2units;
4335 retval(1) = 841.0 * mm2units;
4337 else if (ptype.
compare (
"a2"))
4339 retval(0) = 420.0 * mm2units;
4340 retval(1) = 594.0 * mm2units;
4342 else if (ptype.
compare (
"a3"))
4344 retval(0) = 297.0 * mm2units;
4345 retval(1) = 420.0 * mm2units;
4347 else if (ptype.
compare (
"a4"))
4349 retval(0) = 210.0 * mm2units;
4350 retval(1) = 297.0 * mm2units;
4352 else if (ptype.
compare (
"a5"))
4354 retval(0) = 148.0 * mm2units;
4355 retval(1) = 210.0 * mm2units;
4357 else if (ptype.
compare (
"b0"))
4359 retval(0) = 1029.0 * mm2units;
4360 retval(1) = 1456.0 * mm2units;
4362 else if (ptype.
compare (
"b1"))
4364 retval(0) = 728.0 * mm2units;
4365 retval(1) = 1028.0 * mm2units;
4367 else if (ptype.
compare (
"b2"))
4369 retval(0) = 514.0 * mm2units;
4370 retval(1) = 728.0 * mm2units;
4372 else if (ptype.
compare (
"b3"))
4374 retval(0) = 364.0 * mm2units;
4375 retval(1) = 514.0 * mm2units;
4377 else if (ptype.
compare (
"b4"))
4379 retval(0) = 257.0 * mm2units;
4380 retval(1) = 364.0 * mm2units;
4382 else if (ptype.
compare (
"b5"))
4384 retval(0) = 182.0 * mm2units;
4385 retval(1) = 257.0 * mm2units;
4387 else if (ptype.
compare (
"arch-a"))
4389 retval(0) = 9.0 * in2units;
4390 retval(1) = 12.0 * in2units;
4392 else if (ptype.
compare (
"arch-b"))
4394 retval(0) = 12.0 * in2units;
4395 retval(1) = 18.0 * in2units;
4397 else if (ptype.
compare (
"arch-c"))
4399 retval(0) = 18.0 * in2units;
4400 retval(1) = 24.0 * in2units;
4402 else if (ptype.
compare (
"arch-d"))
4404 retval(0) = 24.0 * in2units;
4405 retval(1) = 36.0 * in2units;
4407 else if (ptype.
compare (
"arch-e"))
4409 retval(0) = 36.0 * in2units;
4410 retval(1) = 48.0 * in2units;
4414 retval(0) = 8.5 * in2units;
4415 retval(1) = 11.0 * in2units;
4419 retval(0) = 11.0 * in2units;
4420 retval(1) = 17.0 * in2units;
4424 retval(0) = 17.0 * in2units;
4425 retval(1) = 22.0 * in2units;
4429 retval(0) = 22.0 * in2units;
4430 retval(1) = 34.0 * in2units;
4434 retval(0) = 34.0 * in2units;
4435 retval(1) = 43.0 * in2units;
4443figure::properties::get_auto_paperposition ()
4445 Matrix pos = get_position ().matrix_value ();
4452 if (funits ==
"normalized" || punits ==
"normalized")
4454 sz = screen_size_pixels ();
4455 pos = convert_position (pos, funits,
"inches", sz);
4457 if (punits ==
"normalized")
4458 sz = papersize_from_type (
"points", get_papertype ());
4460 pos = convert_position (pos,
"inches", punits, sz);
4463 pos = convert_position (pos, funits, punits, sz);
4466 sz = get_papersize ().matrix_value ();
4468 pos(0) = sz(0)/2 - pos(2)/2;
4469 pos(1) = sz(1)/2 - pos(3)/2;
4558figure::properties::update_paperunits (
const caseless_str& old_paperunits)
4560 Matrix pos = get_paperposition ().matrix_value ();
4561 Matrix sz = get_papersize ().matrix_value ();
4568 std::string porient = get_paperorientation ();
4572 if (ptype.
compare (
"<custom>"))
4574 if (old_paperunits.
compare (
"centimeters"))
4579 else if (old_paperunits.
compare (
"points"))
4585 if (punits.
compare (
"centimeters"))
4590 else if (punits.
compare (
"points"))
4598 sz = papersize_from_type (punits, ptype);
4599 if (porient ==
"landscape")
4600 std::swap (sz(0), sz(1));
4613figure::properties::update_papertype ()
4615 std::string typ = get_papertype ();
4616 if (typ !=
"<custom>")
4618 Matrix sz = papersize_from_type (get_paperunits (), typ);
4619 if (get_paperorientation () ==
"landscape")
4620 std::swap (sz(0), sz(1));
4626 if (m_paperpositionmode.is (
"auto"))
4627 m_paperposition.set (get_auto_paperposition ());
4631figure::properties::update_papersize ()
4633 Matrix sz = get_papersize ().matrix_value ();
4636 std::swap (sz(0), sz(1));
4642 m_paperorientation.set (
"portrait");
4645 std::string punits = get_paperunits ();
4646 if (punits ==
"centimeters")
4651 else if (punits ==
"points")
4656 if (punits ==
"normalized")
4658 if (get_papertype () ==
"<custom>")
4659 error (
"set: can't set the papertype to <custom> when the paperunits is normalized");
4666 std::string ptype =
"<custom>";
4667 const double mm2in = 1.0 / 25.4;
4668 const double tol = 0.01;
4670 if (std::abs (sz(0) - 8.5) + std::abs (sz(1) - 11.0) < tol)
4672 else if (std::abs (sz(0) - 8.5) + std::abs (sz(1) - 14.0) < tol)
4674 else if (std::abs (sz(0) - 11.0) + std::abs (sz(1) - 17.0) < tol)
4676 else if (std::abs (sz(0) - 841.0 * mm2in)
4677 + std::abs (sz(1) - 1198.0 * mm2in) < tol)
4679 else if (std::abs (sz(0) - 594.0 * mm2in)
4680 + std::abs (sz(1) - 841.0 * mm2in) < tol)
4682 else if (std::abs (sz(0) - 420.0 * mm2in)
4683 + std::abs (sz(1) - 594.0 * mm2in) < tol)
4685 else if (std::abs (sz(0) - 297.0 * mm2in)
4686 + std::abs (sz(1) - 420.0 * mm2in) < tol)
4688 else if (std::abs (sz(0) - 210.0 * mm2in)
4689 + std::abs (sz(1) - 297.0 * mm2in) < tol)
4691 else if (std::abs (sz(0) - 148.0 * mm2in)
4692 + std::abs (sz(1) - 210.0 * mm2in) < tol)
4694 else if (std::abs (sz(0) - 1029.0 * mm2in)
4695 + std::abs (sz(1) - 1456.0 * mm2in) < tol)
4697 else if (std::abs (sz(0) - 728.0 * mm2in)
4698 + std::abs (sz(1) - 1028.0 * mm2in) < tol)
4700 else if (std::abs (sz(0) - 514.0 * mm2in)
4701 + std::abs (sz(1) - 728.0 * mm2in) < tol)
4703 else if (std::abs (sz(0) - 364.0 * mm2in)
4704 + std::abs (sz(1) - 514.0 * mm2in) < tol)
4706 else if (std::abs (sz(0) - 257.0 * mm2in)
4707 + std::abs (sz(1) - 364.0 * mm2in) < tol)
4709 else if (std::abs (sz(0) - 182.0 * mm2in)
4710 + std::abs (sz(1) - 257.0 * mm2in) < tol)
4712 else if (std::abs (sz(0) - 9.0)
4713 + std::abs (sz(1) - 12.0) < tol)
4715 else if (std::abs (sz(0) - 12.0)
4716 + std::abs (sz(1) - 18.0) < tol)
4718 else if (std::abs (sz(0) - 18.0)
4719 + std::abs (sz(1) - 24.0) < tol)
4721 else if (std::abs (sz(0) - 24.0)
4722 + std::abs (sz(1) - 36.0) < tol)
4724 else if (std::abs (sz(0) - 36.0)
4725 + std::abs (sz(1) - 48.0) < tol)
4727 else if (std::abs (sz(0) - 8.5)
4728 + std::abs (sz(1) - 11.0) < tol)
4730 else if (std::abs (sz(0) - 11.0)
4731 + std::abs (sz(1) - 17.0) < tol)
4733 else if (std::abs (sz(0) - 17.0)
4734 + std::abs (sz(1) - 22.0) < tol)
4736 else if (std::abs (sz(0) - 22.0)
4737 + std::abs (sz(1) - 34.0) < tol)
4739 else if (std::abs (sz(0) - 34.0)
4740 + std::abs (sz(1) - 43.0) < tol)
4744 m_papertype.set (ptype);
4746 if (punits ==
"centimeters")
4751 else if (punits ==
"points")
4756 if (get_paperorientation () ==
"landscape")
4758 std::swap (sz(0), sz(1));
4762 if (m_paperpositionmode.is (
"auto"))
4763 m_paperposition.set (get_auto_paperposition ());
4799figure::properties::update_paperorientation ()
4801 std::string porient = get_paperorientation ();
4802 Matrix sz = get_papersize ().matrix_value ();
4803 if ((sz(0) > sz(1) && porient ==
"portrait")
4804 || (sz(0) < sz(1) && porient ==
"landscape"))
4806 std::swap (sz(0), sz(1));
4812 if (m_paperpositionmode.is (
"auto"))
4813 m_paperposition.set (get_auto_paperposition ());
4848 if (m_units.set (val,
true))
4850 update_units (old_units);
4856figure::properties::update_units (
const caseless_str& old_units)
4858 m_position.set (convert_position (get_position ().matrix_value (),
4859 old_units, get_units (),
4860 screen_size_pixels ()),
false);
4882figure::properties::get_title ()
const
4885 if (! get_number ().isempty () && is_numbertitle ())
4887 std::ostringstream os;
4888 std::string nm = get_name ();
4890 os <<
"Figure " << m___myhandle__.value ();
4892 os <<
": " << get_name ();
4897 title = get_name ();
4910 octave_value retval = m_default_properties.lookup (name);
4916 gh_manager& gh_mgr = octave::__get_gh_manager__ ();
4918 graphics_object parent_go = gh_mgr.
get_object (parent_h);
4920 retval = parent_go.get_default (name);
4927figure::reset_default_properties ()
4930 m_default_properties = property_list ();
4931 property_list::pval_map_type plist = m_properties.factory_defaults ();
4933 plist.erase (
"units");
4934 plist.erase (
"position");
4935 plist.erase (
"innerposition");
4936 plist.erase (
"outerposition");
4937 plist.erase (
"paperunits");
4938 plist.erase (
"paperposition");
4939 plist.erase (
"paperpositionmode");
4940 plist.erase (
"windowstyle");
4942 remove_all_listeners ();
4943 xreset_default_properties (get_handle (), plist);
4949axes::properties::init ()
4951 m_position.add_constraint (
dim_vector (1, 4));
4952 m_outerposition.add_constraint (
dim_vector (1, 4));
4953 m_tightinset.add_constraint (
dim_vector (1, 4));
4954 m_looseinset.add_constraint (
dim_vector (1, 4));
4955 m_colororder.add_constraint (
dim_vector (-1, 3));
4956 m_dataaspectratio.add_constraint (3);
4957 m_dataaspectratio.add_constraint (
"min", 0,
false);
4958 m_dataaspectratio.add_constraint (FINITE);
4959 m_plotboxaspectratio.add_constraint (3);
4960 m_plotboxaspectratio.add_constraint (
"min", 0,
false);
4961 m_plotboxaspectratio.add_constraint (FINITE);
4964 m_alim.add_constraint (2);
4965 m_alim.add_constraint (NOT_NAN);
4966 m_clim.add_constraint (2);
4967 m_clim.add_constraint (NOT_NAN);
4968 m_xlim.add_constraint (2);
4969 m_xlim.add_constraint (NOT_NAN);
4970 m_ylim.add_constraint (2);
4971 m_ylim.add_constraint (NOT_NAN);
4972 m_zlim.add_constraint (2);
4973 m_zlim.add_constraint (NOT_NAN);
4975 m_xtick.add_constraint (FINITE);
4977 m_ytick.add_constraint (FINITE);
4979 m_ztick.add_constraint (FINITE);
4980 m_ticklength.add_constraint (
dim_vector (1, 2));
4985 m_cameraposition.add_constraint (3);
4986 m_cameraposition.add_constraint (FINITE);
4987 m_cameratarget.add_constraint (3);
4988 m_cameratarget.add_constraint (FINITE);
4991 m_cameraupvector = upv;
4992 m_cameraupvector.add_constraint (3);
4993 m_cameraupvector.add_constraint (FINITE);
4994 m_cameraviewangle.add_constraint (FINITE);
4995 m_currentpoint.add_constraint (
dim_vector (2, 3));
4998 m_fontsize.add_constraint (
"min", 0.0,
false);
4999 m_gridalpha.add_constraint (
"min", 0.0,
true);
5000 m_gridalpha.add_constraint (
"max", 1.0,
true);
5001 m_labelfontsizemultiplier.add_constraint (
"min", 0.0,
false);
5002 m_linewidth.add_constraint (
"min", 0.0,
false);
5003 m_minorgridalpha.add_constraint (
"min", 0.0,
true);
5004 m_minorgridalpha.add_constraint (
"max", 1.0,
true);
5005 m_titlefontsizemultiplier.add_constraint (
"min", 0.0,
false);
5010 m_x_zlim.resize (1, 2);
5016 calc_ticklabels (m_xtick, m_xticklabel, m_xscale.is (
"log"),
5017 xaxislocation_is (
"origin"),
5018 m_yscale.is (
"log") ? 2 : (yaxislocation_is (
"origin") ? 0 :
5019 (yaxislocation_is (
"left") ? -1 : 1)), m_xlim);
5020 calc_ticklabels (m_ytick, m_yticklabel, m_yscale.is (
"log"),
5021 yaxislocation_is (
"origin"),
5022 m_xscale.is (
"log") ? 2 : (xaxislocation_is (
"origin") ? 0 :
5023 (xaxislocation_is (
"bottom") ? -1 : 1)), m_ylim);
5024 calc_ticklabels (m_ztick, m_zticklabel, m_zscale.is (
"log"),
5027 xset (m_xlabel.handle_value (),
"handlevisibility",
"off");
5028 xset (m_ylabel.handle_value (),
"handlevisibility",
"off");
5029 xset (m_zlabel.handle_value (),
"handlevisibility",
"off");
5030 xset (m_title.handle_value (),
"handlevisibility",
"off");
5032 xset (m_xlabel.handle_value (),
"horizontalalignment",
"center");
5033 xset (m_xlabel.handle_value (),
"horizontalalignmentmode",
"auto");
5034 xset (m_ylabel.handle_value (),
"horizontalalignment",
"center");
5035 xset (m_ylabel.handle_value (),
"horizontalalignmentmode",
"auto");
5036 xset (m_zlabel.handle_value (),
"horizontalalignment",
"right");
5037 xset (m_zlabel.handle_value (),
"horizontalalignmentmode",
"auto");
5038 xset (m_title.handle_value (),
"horizontalalignment",
"center");
5039 xset (m_title.handle_value (),
"horizontalalignmentmode",
"auto");
5041 xset (m_xlabel.handle_value (),
"verticalalignment",
"top");
5042 xset (m_xlabel.handle_value (),
"verticalalignmentmode",
"auto");
5043 xset (m_ylabel.handle_value (),
"verticalalignment",
"bottom");
5044 xset (m_ylabel.handle_value (),
"verticalalignmentmode",
"auto");
5045 xset (m_title.handle_value (),
"verticalalignment",
"bottom");
5046 xset (m_title.handle_value (),
"verticalalignmentmode",
"auto");
5048 xset (m_ylabel.handle_value (),
"rotation", 90.0);
5049 xset (m_ylabel.handle_value (),
"rotationmode",
"auto");
5051 xset (m_zlabel.handle_value (),
"visible",
"off");
5053 xset (m_xlabel.handle_value (),
"clipping",
"off");
5054 xset (m_ylabel.handle_value (),
"clipping",
"off");
5055 xset (m_zlabel.handle_value (),
"clipping",
"off");
5056 xset (m_title.handle_value (),
"clipping",
"off");
5058 xset (m_xlabel.handle_value (),
"__autopos_tag__",
"xlabel");
5059 xset (m_ylabel.handle_value (),
"__autopos_tag__",
"ylabel");
5060 xset (m_zlabel.handle_value (),
"__autopos_tag__",
"zlabel");
5061 xset (m_title.handle_value (),
"__autopos_tag__",
"title");
5063 double fs = m_labelfontsizemultiplier.double_value () *
5064 m_fontsize.double_value ();
5068 fs = m_titlefontsizemultiplier.double_value () * m_fontsize.double_value ();
5070 xset (m_title.handle_value (),
"fontweight", m_titlefontweight.get ());
5072 adopt (m_xlabel.handle_value ());
5073 adopt (m_ylabel.handle_value ());
5074 adopt (m_zlabel.handle_value ());
5075 adopt (m_title.handle_value ());
5077 Matrix tlooseinset = default_axes_position ();
5078 tlooseinset(2) = 1-tlooseinset(0)-tlooseinset(2);
5079 tlooseinset(3) = 1-tlooseinset(1)-tlooseinset(3);
5080 m_looseinset = tlooseinset;
5107axes::properties::calc_tightbox (
const Matrix& init_pos)
5111 gh_manager& gh_mgr = octave::__get_gh_manager__ ();
5113 graphics_object go = gh_mgr.
get_object (get_parent ());
5115 Matrix parent_bb = go.get_properties ().get_boundingbox (
true);
5119 update_ticklength ();
5121 Matrix ext = get_extent (
true,
true);
5122 ext(1) = parent_bb(3) - ext(1) - ext(3);
5125 ext = convert_position (ext,
"pixels", get_units (),
5127 if (ext(0) < pos(0))
5129 pos(2) += pos(0)-ext(0);
5132 if (ext(0)+ext(2) > pos(0)+pos(2))
5133 pos(2) = ext(0)+ext(2)-pos(0);
5135 if (ext(1) < pos(1))
5137 pos(3) += pos(1)-ext(1);
5140 if (ext(1)+ext(3) > pos(1)+pos(3))
5141 pos(3) = ext(1)+ext(3)-pos(1);
5147axes::properties::sync_positions ()
5150 if (m_positionconstraint.is (
"innerposition"))
5153 update_outerposition ();
5155 set_units (
"normalized");
5156 Matrix pos = m_position.get ().matrix_value ();
5157 Matrix outpos = m_outerposition.get ().matrix_value ();
5158 Matrix tightpos = calc_tightbox (pos);
5159 Matrix tinset (1, 4, 1.0);
5160 tinset(0) = pos(0)-tightpos(0);
5161 tinset(1) = pos(1)-tightpos(1);
5162 tinset(2) = tightpos(0)+tightpos(2)-pos(0)-pos(2);
5163 tinset(3) = tightpos(1)+tightpos(3)-pos(1)-pos(3);
5164 m_tightinset = tinset;
5165 set_units (old_units);
5166 update_transform ();
5167 if (m_positionconstraint.is (
"innerposition"))
5170 update_outerposition ();
5237axes::properties::set_text_child (handle_property& hp,
5238 const std::string& who,
5243 xset (hp.handle_value (),
"string", v);
5249 gh_manager& gh_mgr = octave::__get_gh_manager__ ();
5253 if (go.isa (
"text"))
5254 val = octave::reparent (v,
"set", who, m___myhandle__,
false);
5259 error (
"set: expecting text graphics object or character string for %s property, found %s",
5260 who.c_str (), cname.c_str ());
5263 xset (val,
"handlevisibility",
"off");
5265 gh_mgr.
free (hp.handle_value ());
5269 adopt (hp.handle_value ());
5275 set_text_child (m_xlabel,
"xlabel", v);
5276 xset (m_xlabel.handle_value (),
"positionmode",
"auto");
5277 xset (m_xlabel.handle_value (),
"rotationmode",
"auto");
5278 xset (m_xlabel.handle_value (),
"horizontalalignmentmode",
"auto");
5279 xset (m_xlabel.handle_value (),
"verticalalignmentmode",
"auto");
5280 xset (m_xlabel.handle_value (),
"clipping",
"off");
5281 xset (m_xlabel.handle_value (),
"color", get_xcolor ());
5282 xset (m_xlabel.handle_value (),
"__autopos_tag__",
"xlabel");
5283 update_xlabel_position ();
5289 set_text_child (m_ylabel,
"ylabel", v);
5290 xset (m_ylabel.handle_value (),
"positionmode",
"auto");
5291 xset (m_ylabel.handle_value (),
"rotationmode",
"auto");
5292 xset (m_ylabel.handle_value (),
"horizontalalignmentmode",
"auto");
5293 xset (m_ylabel.handle_value (),
"verticalalignmentmode",
"auto");
5294 xset (m_ylabel.handle_value (),
"clipping",
"off");
5295 xset (m_ylabel.handle_value (),
"color", get_ycolor ());
5296 xset (m_ylabel.handle_value (),
"__autopos_tag__",
"ylabel");
5297 update_ylabel_position ();
5303 set_text_child (m_zlabel,
"zlabel", v);
5304 xset (m_zlabel.handle_value (),
"positionmode",
"auto");
5305 xset (m_zlabel.handle_value (),
"rotationmode",
"auto");
5306 xset (m_zlabel.handle_value (),
"horizontalalignmentmode",
"auto");
5307 xset (m_zlabel.handle_value (),
"verticalalignmentmode",
"auto");
5308 xset (m_zlabel.handle_value (),
"clipping",
"off");
5309 xset (m_zlabel.handle_value (),
"color", get_zcolor ());
5310 xset (m_zlabel.handle_value (),
"__autopos_tag__",
"zlabel");
5311 update_zlabel_position ();
5317 set_text_child (m_title,
"title", v);
5318 xset (m_title.handle_value (),
"positionmode",
"auto");
5319 xset (m_title.handle_value (),
"horizontalalignment",
"center");
5320 xset (m_title.handle_value (),
"horizontalalignmentmode",
"auto");
5321 xset (m_title.handle_value (),
"verticalalignment",
"bottom");
5322 xset (m_title.handle_value (),
"verticalalignmentmode",
"auto");
5323 xset (m_title.handle_value (),
"clipping",
"off");
5324 xset (m_title.handle_value (),
"__autopos_tag__",
"title");
5325 update_title_position ();
5329axes::properties::set_defaults (base_graphics_object& bgo,
5330 const std::string& mode)
5342 if (mode !=
"reset")
5343 error (R
"(axes::properties::set_defaults: expected mode = "reset", found "%s")", mode.c_str ());
5353 m_alimmode = "auto";
5354 m_climmode =
"auto";
5355 m_xlimmode =
"auto";
5356 m_ylimmode =
"auto";
5357 m_zlimmode =
"auto";
5360 m_alphascale =
"linear";
5362 m_ambientlightcolor =
Matrix (1, 3, 1.0);
5365 m_boxstyle =
"back";
5368 m_camerapositionmode =
"auto";
5369 m_cameratargetmode =
"auto";
5370 m_cameraupvectormode =
"auto";
5371 m_cameraviewanglemode =
"auto";
5373 m_clippingstyle =
"3dbox";
5375 m_color = color_values (
"white");
5377 m_colororder = default_colororder ();
5378 m_colororderindex = 1.0;
5379 m_colorscale =
"linear";
5382 m_dataaspectratiomode =
"auto";
5384 m_fontangle =
"normal";
5385 m_fontname = OCTAVE_DEFAULT_FONTNAME;
5387 m_fontsizemode =
"auto";
5388 m_fontsmoothing =
"on";
5389 m_fontunits =
"points";
5390 m_fontweight =
"normal";
5393 m_gridalphamode =
"auto";
5394 m_gridcolor = color_values (0.15, 0.15, 0.15);
5395 m_gridcolormode =
"auto";
5396 m_gridlinestyle =
"-";
5398 m_labelfontsizemultiplier = 1.1;
5402 m_linestyleorder =
"-";
5403 m_linestyleorderindex = 1.0;
5407 m_minorgridalpha = 0.25;
5408 m_minorgridalphamode =
"auto";
5409 m_minorgridcolor = color_values (0.1, 0.1, 0.1);
5410 m_minorgridcolormode =
"auto";
5411 m_minorgridlinestyle =
":";
5413 m_nextplot =
"replace";
5416 m_plotboxaspectratiomode =
"auto";
5417 m_projection =
"orthographic";
5419 m_sortmethod =
"depth";
5422 m_tickdirmode =
"auto";
5423 m_ticklabelinterpreter =
"tex";
5424 m_ticklength = default_axes_ticklength ();
5426 m_tightinset =
Matrix (1, 4, 0.0);
5428 m_titlefontsizemultiplier = 1.1;
5429 m_titlefontweight =
"bold";
5431 Matrix tview (1, 2, 0.0);
5435 m_xaxislocation =
"bottom";
5437 m_xcolor = color_values (0.15, 0.15, 0.15);
5438 m_xcolormode =
"auto";
5441 m_xlimitmethod =
"tickaligned";
5442 m_xminorgrid =
"off";
5443 m_xminortick =
"off";
5444 m_xscale =
"linear";
5447 m_xticklabelmode =
"auto";
5448 m_xticklabelrotation = 0.0;
5449 m_xtickmode =
"auto";
5451 m_yaxislocation =
"left";
5453 m_ycolor = color_values (0.15, 0.15, 0.15);
5454 m_ycolormode =
"auto";
5457 m_ylimitmethod =
"tickaligned";
5458 m_yminorgrid =
"off";
5459 m_yminortick =
"off";
5460 m_yscale =
"linear";
5463 m_yticklabelmode =
"auto";
5464 m_yticklabelrotation = 0.0;
5465 m_ytickmode =
"auto";
5467 m_zcolor = color_values (0.15, 0.15, 0.15);
5468 m_zcolormode =
"auto";
5471 m_zlimitmethod =
"tickaligned";
5472 m_zminorgrid =
"off";
5473 m_zminortick =
"off";
5474 m_zscale =
"linear";
5477 m_zticklabelmode =
"auto";
5478 m_zticklabelrotation = 0.0;
5479 m_ztickmode =
"auto";
5487 gh_manager& gh_mgr = octave::__get_gh_manager__ ();
5489 graphics_object go = gh_mgr.
get_object (m_xlabel.handle_value ());
5490 go.reset_default_properties ();
5491 go = gh_mgr.
get_object (m_ylabel.handle_value ());
5492 go.reset_default_properties ();
5493 go = gh_mgr.
get_object (m_zlabel.handle_value ());
5494 go.reset_default_properties ();
5495 go = gh_mgr.
get_object (m_title.handle_value ());
5496 go.reset_default_properties ();
5498 xset (m_xlabel.handle_value (),
"handlevisibility",
"off");
5499 xset (m_ylabel.handle_value (),
"handlevisibility",
"off");
5500 xset (m_zlabel.handle_value (),
"handlevisibility",
"off");
5501 xset (m_title.handle_value (),
"handlevisibility",
"off");
5503 xset (m_xlabel.handle_value (),
"horizontalalignment",
"center");
5504 xset (m_xlabel.handle_value (),
"horizontalalignmentmode",
"auto");
5505 xset (m_ylabel.handle_value (),
"horizontalalignment",
"center");
5506 xset (m_ylabel.handle_value (),
"horizontalalignmentmode",
"auto");
5507 xset (m_zlabel.handle_value (),
"horizontalalignment",
"right");
5508 xset (m_zlabel.handle_value (),
"horizontalalignmentmode",
"auto");
5509 xset (m_title.handle_value (),
"horizontalalignment",
"center");
5510 xset (m_title.handle_value (),
"horizontalalignmentmode",
"auto");
5512 xset (m_xlabel.handle_value (),
"verticalalignment",
"top");
5513 xset (m_xlabel.handle_value (),
"verticalalignmentmode",
"auto");
5514 xset (m_ylabel.handle_value (),
"verticalalignment",
"bottom");
5515 xset (m_ylabel.handle_value (),
"verticalalignmentmode",
"auto");
5516 xset (m_title.handle_value (),
"verticalalignment",
"bottom");
5517 xset (m_title.handle_value (),
"verticalalignmentmode",
"auto");
5519 xset (m_ylabel.handle_value (),
"rotation", 90.0);
5520 xset (m_ylabel.handle_value (),
"rotationmode",
"auto");
5522 xset (m_zlabel.handle_value (),
"visible",
"off");
5524 xset (m_xlabel.handle_value (),
"clipping",
"off");
5525 xset (m_ylabel.handle_value (),
"clipping",
"off");
5526 xset (m_zlabel.handle_value (),
"clipping",
"off");
5527 xset (m_title.handle_value (),
"clipping",
"off");
5529 xset (m_xlabel.handle_value (),
"__autopos_tag__",
"xlabel");
5530 xset (m_ylabel.handle_value (),
"__autopos_tag__",
"ylabel");
5531 xset (m_zlabel.handle_value (),
"__autopos_tag__",
"zlabel");
5532 xset (m_title.handle_value (),
"__autopos_tag__",
"title");
5535 fs = m_labelfontsizemultiplier.double_value () * m_fontsize.double_value ();
5539 fs = m_titlefontsizemultiplier.double_value () * m_fontsize.double_value ();
5541 xset (m_title.handle_value (),
"fontweight", m_titlefontweight.get ());
5543 update_transform ();
5545 override_defaults (bgo);
5549axes::properties::get_colormap ()
const
5551 if (m___colormap__.get ().isempty ())
5553 gh_manager& gh_mgr = octave::__get_gh_manager__ ();
5555 graphics_object go (gh_mgr.
get_object (get___myhandle__ ()));
5556 graphics_object go_f (go.get_ancestor (
"figure"));
5557 figure::properties& figure_props
5558 =
reinterpret_cast<figure::properties&
> (go_f.get_properties ());
5559 return figure_props.get_colormap ();
5562 return get___colormap__ ();
5566axes::properties::delete_text_child (handle_property& hp,
bool from_root)
5570 gh_manager& gh_mgr = octave::__get_gh_manager__ ();
5576 if (go.valid_object ())
5577 gh_mgr.
free (h, from_root);
5585 if (! is_beingdeleted ())
5589 xset (hp.handle_value (),
"handlevisibility",
"off");
5591 adopt (hp.handle_value ());
5596axes::properties::remove_child (
const graphics_handle& h,
bool from_root)
5598 gh_manager& gh_mgr = octave::__get_gh_manager__ ();
5602 if (m_xlabel.handle_value ().ok () && h == m_xlabel.handle_value ())
5604 delete_text_child (m_xlabel, from_root);
5605 update_xlabel_position ();
5607 else if (m_ylabel.handle_value ().ok () && h == m_ylabel.handle_value ())
5609 delete_text_child (m_ylabel, from_root);
5610 update_ylabel_position ();
5612 else if (m_zlabel.handle_value ().ok () && h == m_zlabel.handle_value ())
5614 delete_text_child (m_zlabel, from_root);
5615 update_zlabel_position ();
5617 else if (m_title.handle_value ().ok () && h == m_title.handle_value ())
5619 delete_text_child (m_title, from_root);
5620 update_title_position ();
5622 else if (get_num_lights () > 0 && go.isa (
"light")
5623 && go.get_properties ().is_visible ())
5624 decrease_num_lights ();
5626 if (go.valid_object ())
5627 base_properties::remove_child (h, from_root);
5634 gh_manager& gh_mgr = octave::__get_gh_manager__ ();
5638 if (go.isa (
"light") && go.get_properties ().is_visible ())
5639 increase_num_lights ();
5641 base_properties::adopt (h);
5649 if (xlimmode_is (
"auto"))
5650 update_axis_limits (
"xlim");
5652 if (ylimmode_is (
"auto"))
5653 update_axis_limits (
"ylim");
5655 if (zlimmode_is (
"auto"))
5656 update_axis_limits (
"zlim");
5658 if (climmode_is (
"auto"))
5659 update_axis_limits (
"clim");
5661 if (climmode_is (
"auto"))
5662 update_axis_limits (
"alim");
5670 for (
int i = 0; i < 4; i++)
5767 double fact = 1.0 / sqrt (v(0)*v(0)+v(1)*v(1)+v(2)*v(2));
5768 scale (v, fact, fact, fact);
5774 return (v1(0)*
v2(0)+v1(1)*
v2(1)+v1(2)*
v2(2));
5780 return sqrt (
dot (v, v));
5788 r(0) = v1(1)*
v2(2) - v1(2)*
v2(1);
5789 r(1) = v1(2)*
v2(0) - v1(0)*
v2(2);
5790 r(2) = v1(0)*
v2(1) - v1(1)*
v2(0);
5798 static double data[32] =
5811 memcpy (m.
rwdata (), data, sizeof (
double)*32);
5821 memcpy (retval.
rwdata (), m.
data (), sizeof (
double)*3);
5833axes::properties::update_camera ()
5835 double xd = (xdir_is (
"normal") ? 1 : -1);
5836 double yd = (ydir_is (
"normal") ? 1 : -1);
5837 double zd = (zdir_is (
"normal") ? 1 : -1);
5839 Matrix xlimits = m_sx.scale (get_xlim ().matrix_value ());
5840 Matrix ylimits = m_sy.scale (get_ylim ().matrix_value ());
5841 Matrix zlimits = m_sz.scale (get_zlim ().matrix_value ());
5843 double xo = xlimits(xd > 0 ? 0 : 1);
5844 double yo = ylimits(yd > 0 ? 0 : 1);
5845 double zo = zlimits(zd > 0 ? 0 : 1);
5847 Matrix pb = get_plotboxaspectratio ().matrix_value ();
5849 bool autocam = (camerapositionmode_is (
"auto")
5850 && cameratargetmode_is (
"auto")
5851 && cameraupvectormode_is (
"auto")
5852 && cameraviewanglemode_is (
"auto"));
5853 bool dowarp = (autocam && dataaspectratiomode_is (
"auto")
5854 && plotboxaspectratiomode_is (
"auto"));
5860 if (cameratargetmode_is (
"auto"))
5862 c_center(0) = (xlimits(0) + xlimits(1)) / 2;
5863 c_center(1) = (ylimits(0) + ylimits(1)) / 2;
5864 c_center(2) = (zlimits(0) + zlimits(1)) / 2;
5869 c_center =
cam2xform (get_cameratarget ().matrix_value ());
5871 if (camerapositionmode_is (
"auto"))
5873 Matrix tview = get_view ().matrix_value ();
5874 double az = tview(0);
5875 double el = tview(1);
5876 double d = 5 * sqrt (pb(0)*pb(0) + pb(1)*pb(1) + pb(2)*pb(2));
5878 if (el == 90 || el == -90)
5879 c_eye(2) =
d*octave::math::signum (el);
5884 c_eye(0) =
d * cos (el) * sin (az);
5885 c_eye(1) = -
d* cos (el) * cos (az);
5886 c_eye(2) =
d * sin (el);
5888 c_eye(0) = c_eye(0)*(xlimits(1)-xlimits(0))/(xd*pb(0))+c_center(0);
5889 c_eye(1) = c_eye(1)*(ylimits(1)-ylimits(0))/(yd*pb(1))+c_center(1);
5890 c_eye(2) = c_eye(2)*(zlimits(1)-zlimits(0))/(zd*pb(2))+c_center(2);
5895 c_eye =
cam2xform (get_cameraposition ().matrix_value ());
5897 if (cameraupvectormode_is (
"auto"))
5899 Matrix tview = get_view ().matrix_value ();
5900 double az = tview(0);
5901 double el = tview(1);
5903 if (el == 90 || el == -90)
5905 c_upv(0) = -octave::math::signum (el)
5906 * sin (az*M_PI/180.0)*(xlimits(1)-xlimits(0))/pb(0);
5907 c_upv(1) = octave::math::signum (el)
5908 * cos (az*M_PI/180.0)*(ylimits(1)-ylimits(0))/pb(1);
5916 c_upv =
cam2xform (get_cameraupvector ().matrix_value ());
5927 scale (x_pre, pb(0), pb(1), pb(2));
5929 scale (x_pre, xd/(xlimits(1)-xlimits(0)), yd/(ylimits(1)-ylimits(0)),
5930 zd/(zlimits(1)-zlimits(0)));
5933 xform (c_eye, x_pre);
5934 xform (c_center, x_pre);
5935 scale (c_upv, pb(0)/(xlimits(1)-xlimits(0)), pb(1)/(ylimits(1)-ylimits(0)),
5936 pb(2)/(zlimits(1)-zlimits(0)));
5937 translate (c_center, -c_eye(0), -c_eye(1), -c_eye(2));
5943 if (std::abs (
dot (
f, UP)) > 1e-15)
5945 double fa = 1 / sqrt (1 -
f(2)*
f(2));
5946 scale (UP, fa, fa, fa);
5952 scale (x_view, 1, 1, -1);
5954 l(0, 0) = s(0); l(0, 1) = s(1); l(0, 2) = s(2);
5955 l(1, 0) = u(0); l(1, 1) = u(1); l(1, 2) = u(2);
5956 l(2, 0) = -
f(0); l(2, 1) = -
f(1); l(2, 2) = -
f(2);
5957 x_view = x_view * l;
5958 translate (x_view, -c_eye(0), -c_eye(1), -c_eye(2));
5959 scale (x_view, pb(0), pb(1), pb(2));
5965 double xM = cmax(0) - cmin(0);
5966 double yM = cmax(1) - cmin(1);
5968 Matrix bb = get_boundingbox (
true);
5972 if (cameraviewanglemode_is (
"auto"))
5979 if (
false && dowarp)
5980 af = (1.0 / (xM > yM ? xM : yM));
5983 if ((bb(2)/bb(3)) > (xM/yM))
5988 v_angle = 2 * (180.0 / M_PI) *
atan (1 / (2 * af *
norm (F)));
5990 m_cameraviewangle = v_angle;
5993 v_angle = get_cameraviewangle ();
5995 double pf = 1 / (2 * tan ((v_angle / 2) * M_PI / 180.0) *
norm (F));
5996 scale (x_projection, pf, pf, 1);
6002 translate (x_viewport, bb(0)+bb(2)/2, bb(1)+bb(3)/2, 0);
6003 scale (x_viewport, bb(2)/xM, -bb(3)/yM, 1);
6010 if ((bb(2)/bb(3)) > (xM/yM))
6016 pix = (bb(2) < bb(3) ? bb(2) : bb(3));
6017 translate (x_viewport, bb(0)+bb(2)/2, bb(1)+bb(3)/2, 0);
6018 scale (x_viewport, pix, -pix, 1);
6021 x_normrender = x_viewport * x_projection * x_view;
6027 m_x_zlim(0) = cmin(2);
6028 m_x_zlim(1) = cmax(2);
6030 m_x_render = x_normrender;
6031 scale (m_x_render, xd/(xlimits(1)-xlimits(0)), yd/(ylimits(1)-ylimits(0)),
6032 zd/(zlimits(1)-zlimits(0)));
6035 m_x_render_inv = m_x_render.inverse ();
6039 m_x_gl_mat1 = x_view;
6040 scale (m_x_gl_mat1, xd/(xlimits(1)-xlimits(0)), yd/(ylimits(1)-ylimits(0)),
6041 zd/(zlimits(1)-zlimits(0)));
6043 m_x_gl_mat2 = x_viewport * x_projection;
6046static bool updating_axes_layout =
false;
6049axes::properties::update_axes_layout ()
6051 if (updating_axes_layout)
6054 graphics_xform
xform = get_transform ();
6056 double xd = (xdir_is (
"normal") ? 1 : -1);
6057 double yd = (ydir_is (
"normal") ? 1 : -1);
6058 double zd = (zdir_is (
"normal") ? 1 : -1);
6060 const Matrix xlims =
xform.xscale (get_xlim ().matrix_value ());
6061 const Matrix ylims =
xform.yscale (get_ylim ().matrix_value ());
6062 const Matrix zlims =
xform.zscale (get_zlim ().matrix_value ());
6064 double x_min, x_max, y_min, y_max, z_min, z_max;
6065 x_min = xlims(0), x_max = xlims(1);
6066 y_min = ylims(0), y_max = ylims(1);
6067 z_min = zlims(0), z_max = zlims(1);
6071 m_xstate = m_ystate = m_zstate = AXE_ANY_DIR;
6073 p1 =
xform.transform (x_min, (y_min+y_max)/2, (z_min+z_max)/2,
false);
6074 p2 =
xform.transform (x_max, (y_min+y_max)/2, (z_min+z_max)/2,
false);
6075 dir(0) = octave::math::round (p2(0) - p1(0));
6076 dir(1) = octave::math::round (p2(1) - p1(1));
6077 dir(2) = (p2(2) - p1(2));
6078 if (dir(0) == 0 && dir(1) == 0)
6079 m_xstate = AXE_DEPTH_DIR;
6080 else if (dir(2) == 0)
6083 m_xstate = AXE_VERT_DIR;
6084 else if (dir(1) == 0)
6085 m_xstate = AXE_HORZ_DIR;
6091 m_xPlane = (dir(0) > 0 ? x_max : x_min);
6093 m_xPlane = (dir(1) < 0 ? x_max : x_min);
6096 m_xPlane = (dir(2) < 0 ? x_min : x_max);
6098 m_xPlaneN = (m_xPlane == x_min ? x_max : x_min);
6099 m_fx = (x_max - x_min) / sqrt (dir(0)*dir(0) + dir(1)*dir(1));
6101 p1 =
xform.transform ((x_min + x_max)/2, y_min, (z_min + z_max)/2,
false);
6102 p2 =
xform.transform ((x_min + x_max)/2, y_max, (z_min + z_max)/2,
false);
6103 dir(0) = octave::math::round (p2(0) - p1(0));
6104 dir(1) = octave::math::round (p2(1) - p1(1));
6105 dir(2) = (p2(2) - p1(2));
6106 if (dir(0) == 0 && dir(1) == 0)
6107 m_ystate = AXE_DEPTH_DIR;
6108 else if (dir(2) == 0)
6111 m_ystate = AXE_VERT_DIR;
6112 else if (dir(1) == 0)
6113 m_ystate = AXE_HORZ_DIR;
6119 m_yPlane = (dir(0) > 0 ? y_max : y_min);
6121 m_yPlane = (dir(1) < 0 ? y_max : y_min);
6124 m_yPlane = (dir(2) < 0 ? y_min : y_max);
6126 m_yPlaneN = (m_yPlane == y_min ? y_max : y_min);
6127 m_fy = (y_max - y_min) / sqrt (dir(0)*dir(0) + dir(1)*dir(1));
6129 p1 =
xform.transform ((x_min + x_max)/2, (y_min + y_max)/2, z_min,
false);
6130 p2 =
xform.transform ((x_min + x_max)/2, (y_min + y_max)/2, z_max,
false);
6131 dir(0) = octave::math::round (p2(0) - p1(0));
6132 dir(1) = octave::math::round (p2(1) - p1(1));
6133 dir(2) = (p2(2) - p1(2));
6134 if (dir(0) == 0 && dir(1) == 0)
6135 m_zstate = AXE_DEPTH_DIR;
6136 else if (dir(2) == 0)
6139 m_zstate = AXE_VERT_DIR;
6140 else if (dir(1) == 0)
6141 m_zstate = AXE_HORZ_DIR;
6147 m_zPlane = (dir(0) > 0 ? z_min : z_max);
6149 m_zPlane = (dir(1) < 0 ? z_min : z_max);
6152 m_zPlane = (dir(2) < 0 ? z_min : z_max);
6154 m_zPlaneN = (m_zPlane == z_min ? z_max : z_min);
6155 m_fz = (z_max - z_min) / sqrt (dir(0)*dir(0) + dir(1)*dir(1));
6157 octave::unwind_protect_var<bool> restore_var (updating_axes_layout,
true);
6159 m_xySym = (xd*yd*(m_xPlane-m_xPlaneN)*(m_yPlane-m_yPlaneN) > 0);
6160 m_zSign = (zd*(m_zPlane-m_zPlaneN) <= 0);
6161 m_xyzSym = (m_zSign ? m_xySym : ! m_xySym);
6162 m_xpTick = (m_zSign ? m_xPlaneN : m_xPlane);
6163 m_ypTick = (m_zSign ? m_yPlaneN : m_yPlane);
6164 m_zpTick = (m_zSign ? m_zPlane : m_zPlaneN);
6165 m_xpTickN = (m_zSign ? m_xPlane : m_xPlaneN);
6166 m_ypTickN = (m_zSign ? m_yPlane : m_yPlaneN);
6167 m_zpTickN = (m_zSign ? m_zPlaneN : m_zPlane);
6172 m_layer2Dtop =
false;
6173 if (m_xstate == AXE_HORZ_DIR && m_ystate == AXE_VERT_DIR)
6175 Matrix ylimits = get_ylim ().matrix_value ();
6176 if (xaxislocation_is (
"top")
6177 || (yscale_is (
"log") && xaxislocation_is (
"origin")
6178 && (ylimits(1) < 0.)))
6180 std::swap (m_yPlane, m_yPlaneN);
6183 m_ypTick = m_yPlaneN;
6184 m_ypTickN = m_yPlane;
6185 Matrix xlimits = get_xlim ().matrix_value ();
6186 if (yaxislocation_is (
"right")
6187 || (xscale_is (
"log") && yaxislocation_is (
"origin")
6188 && (xlimits(1) < 0.)))
6190 std::swap (m_xPlane, m_xPlaneN);
6193 m_xpTick = m_xPlaneN;
6194 m_xpTickN = m_xPlane;
6195 if (layer_is (
"top"))
6197 m_zpTick = m_zPlaneN;
6198 m_layer2Dtop =
true;
6201 m_zpTick = m_zPlane;
6204 Matrix viewmat = get_view ().matrix_value ();
6205 m_nearhoriz = std::abs (viewmat(1)) <= 5;
6206 m_is2D = viewmat(1) == 90;
6208 update_ticklength ();
6212axes::properties::update_ticklength ()
6214 bool mode2D = (((m_xstate > AXE_DEPTH_DIR ? 1 : 0) +
6215 (m_ystate > AXE_DEPTH_DIR ? 1 : 0) +
6216 (m_zstate > AXE_DEPTH_DIR ? 1 : 0)) == 2);
6218 if (tickdirmode_is (
"auto"))
6219 m_tickdir.set (mode2D ?
"in" :
"out", true);
6222 std::string tickdir = get_tickdir ();
6223 if (tickdir ==
"in")
6225 else if (tickdir ==
"out")
6227 else if (tickdir ==
"both")
6232 Matrix bbox = get_boundingbox (
true);
6233 Matrix ticklen = get_ticklength ().matrix_value ();
6234 ticklen(0) *= std::max (bbox(2), bbox(3));
6237 ticklen(1) *= (0.76 * std::max (bbox(2), bbox(3)));
6239 m_xticklen = ticksign * (mode2D ? ticklen(0) : ticklen(1));
6240 m_yticklen = ticksign * (mode2D ? ticklen(0) : ticklen(1));
6241 m_zticklen = ticksign * (mode2D ? ticklen(0) : ticklen(1));
6243 double offset = get___fontsize_points__ () / 2;
6245 m_xtickoffset = (mode2D ? std::max (0., m_xticklen) : std::
abs (m_xticklen)) +
6246 (m_xstate == AXE_HORZ_DIR ? offset*1.5 : offset);
6247 m_ytickoffset = (mode2D ? std::max (0., m_yticklen) : std::
abs (m_yticklen)) +
6248 (m_ystate == AXE_HORZ_DIR ? offset*1.5 : offset);
6249 m_ztickoffset = (mode2D ? std::max (0., m_zticklen) : std::
abs (m_zticklen)) +
6250 (m_zstate == AXE_HORZ_DIR ? offset*1.5 : offset);
6252 update_xlabel_position ();
6253 update_ylabel_position ();
6254 update_zlabel_position ();
6255 update_title_position ();
6278 const text::properties& props,
6279 const graphics_xform&
xform,
6284 std::string to_units = props.get_units ();
6286 if (to_units !=
"data")
6292 retval(0) = v(0) - bbox(0) + 1;
6293 retval(1) = bbox(1) + bbox(3) - v(1) + 1;
6296 retval = convert_position (retval,
"pixels", to_units,
6305static bool updating_xlabel_position =
false;
6308axes::properties::update_xlabel_position ()
6310 if (updating_xlabel_position)
6313 gh_manager& gh_mgr = octave::__get_gh_manager__ ();
6315 graphics_object go = gh_mgr.
get_object (get_xlabel ());
6317 if (! go.valid_object ())
6320 text::properties& xlabel_props
6321 =
reinterpret_cast<text::properties&
> (go.get_properties ());
6323 bool isempty = xlabel_props.get_string ().isempty ();
6325 octave::unwind_protect_var<bool>
6326 restore_var (updating_xlabel_position,
true);
6330 if (xlabel_props.horizontalalignmentmode_is (
"auto"))
6332 xlabel_props.set_horizontalalignment
6333 (m_xstate > AXE_DEPTH_DIR ?
"center"
6334 : (m_xyzSym ?
"left" :
"right"));
6336 xlabel_props.set_horizontalalignmentmode (
"auto");
6339 if (xlabel_props.verticalalignmentmode_is (
"auto"))
6341 xlabel_props.set_verticalalignment
6342 (m_xstate == AXE_VERT_DIR || m_x2Dtop ?
"bottom" :
"top");
6344 xlabel_props.set_verticalalignmentmode (
"auto");
6348 if (xlabel_props.positionmode_is (
"auto")
6349 || xlabel_props.rotationmode_is (
"auto"))
6351 graphics_xform
xform = get_transform ();
6354 ext = get_ticklabel_extents (get_xtick ().matrix_value (),
6355 get_xticklabel ().string_vector_value (),
6356 get_xlim ().matrix_value ());
6359 double wmax = ext(0) + margin;
6360 double hmax = ext(1) + margin;
6363 = graphics_xform::xform_vector ((m_xpTickN + m_xpTick)/2, m_ypTick, m_zpTick);
6365 bool tick_along_z = m_nearhoriz || octave::math::isinf (m_fy);
6367 p(2) += (octave::math::signum (m_zpTick - m_zpTickN) * m_fz * m_xtickoffset);
6369 p(1) += (octave::math::signum (m_ypTick - m_ypTickN) * m_fy * m_xtickoffset);
6371 p =
xform.transform (p(0), p(1), p(2),
false);
6376 p(0) += (m_xyzSym ? wmax : -wmax);
6386 p(1) += (m_x2Dtop ? -hmax : hmax);
6390 if (xlabel_props.positionmode_is (
"auto"))
6392 p =
xform.untransform (p(0), p(1), p(2),
true);
6394 p = convert_label_position (p, xlabel_props,
xform,
6395 get_extent (
false));
6398 xlabel_props.set_positionmode (
"auto");
6401 if (! isempty && xlabel_props.rotationmode_is (
"auto"))
6403 xlabel_props.set_rotation (angle);
6404 xlabel_props.set_rotationmode (
"auto");
6409static bool updating_ylabel_position =
false;
6412axes::properties::update_ylabel_position ()
6414 if (updating_ylabel_position)
6417 gh_manager& gh_mgr = octave::__get_gh_manager__ ();
6419 graphics_object go = gh_mgr.
get_object (get_ylabel ());
6421 if (! go.valid_object ())
6424 text::properties& ylabel_props
6425 =
reinterpret_cast<text::properties&
> (go.get_properties ());
6427 bool isempty = ylabel_props.get_string ().isempty ();
6429 octave::unwind_protect_var<bool>
6430 restore_var (updating_ylabel_position,
true);
6434 if (ylabel_props.horizontalalignmentmode_is (
"auto"))
6436 ylabel_props.set_horizontalalignment
6437 (m_ystate > AXE_DEPTH_DIR ?
"center"
6438 : (! m_xyzSym ?
"left" :
"right"));
6440 ylabel_props.set_horizontalalignmentmode (
"auto");
6443 if (ylabel_props.verticalalignmentmode_is (
"auto"))
6445 ylabel_props.set_verticalalignment
6446 (m_ystate == AXE_VERT_DIR && ! m_y2Dright ?
"bottom" :
"top");
6448 ylabel_props.set_verticalalignmentmode (
"auto");
6452 if (ylabel_props.positionmode_is (
"auto")
6453 || ylabel_props.rotationmode_is (
"auto"))
6455 graphics_xform
xform = get_transform ();
6459 ext = get_ticklabel_extents (get_ytick ().matrix_value (),
6460 get_yticklabel ().string_vector_value (),
6461 get_ylim ().matrix_value ());
6463 double wmax = ext(0) + margin;
6464 double hmax = ext(1) + margin;
6467 = graphics_xform::xform_vector (m_xpTick, (m_ypTickN + m_ypTick)/2, m_zpTick);
6469 bool tick_along_z = m_nearhoriz || octave::math::isinf (m_fx);
6471 p(2) += (octave::math::signum (m_zpTick - m_zpTickN) * m_fz * m_ytickoffset);
6473 p(0) += (octave::math::signum (m_xpTick - m_xpTickN) * m_fx * m_ytickoffset);
6475 p =
xform.transform (p(0), p(1), p(2),
false);
6480 p(0) += (! m_xyzSym ? wmax : -wmax);
6485 p(0) += (m_y2Dright ? wmax : -wmax);
6494 if (ylabel_props.positionmode_is (
"auto"))
6496 p =
xform.untransform (p(0), p(1), p(2),
true);
6498 p = convert_label_position (p, ylabel_props,
xform,
6499 get_extent (
false));
6502 ylabel_props.set_positionmode (
"auto");
6505 if (! isempty && ylabel_props.rotationmode_is (
"auto"))
6507 ylabel_props.set_rotation (angle);
6508 ylabel_props.set_rotationmode (
"auto");
6513static bool updating_zlabel_position =
false;
6516axes::properties::update_zlabel_position ()
6518 if (updating_zlabel_position)
6521 gh_manager& gh_mgr = octave::__get_gh_manager__ ();
6523 graphics_object go = gh_mgr.
get_object (get_zlabel ());
6525 if (! go.valid_object ())
6528 text::properties& zlabel_props
6529 =
reinterpret_cast<text::properties&
> (go.get_properties ());
6531 bool camAuto = cameraupvectormode_is (
"auto");
6532 bool isempty = zlabel_props.get_string ().isempty ();
6534 octave::unwind_protect_var<bool>
6535 restore_updating_zlabel_position (updating_zlabel_position,
true);
6539 if (zlabel_props.horizontalalignmentmode_is (
"auto"))
6541 zlabel_props.set_horizontalalignment
6542 ((m_zstate > AXE_DEPTH_DIR || camAuto) ?
"center" :
"right");
6544 zlabel_props.set_horizontalalignmentmode (
"auto");
6547 if (zlabel_props.verticalalignmentmode_is (
"auto"))
6549 zlabel_props.set_verticalalignment
6550 (m_zstate == AXE_VERT_DIR
6551 ?
"bottom" : ((m_zSign || camAuto) ?
"bottom" :
"top"));
6553 zlabel_props.set_verticalalignmentmode (
"auto");
6557 if (zlabel_props.positionmode_is (
"auto")
6558 || zlabel_props.rotationmode_is (
"auto"))
6560 graphics_xform
xform = get_transform ();
6563 ext = get_ticklabel_extents (get_ztick ().matrix_value (),
6564 get_zticklabel ().string_vector_value (),
6565 get_zlim ().matrix_value ());
6568 double wmax = ext(0) + margin;
6569 double hmax = ext(1) + margin;
6575 p = graphics_xform::xform_vector (m_xPlaneN, m_yPlane,
6576 (m_zpTickN + m_zpTick)/2);
6577 if (octave::math::isinf (m_fy))
6578 p(0) += octave::math::signum (m_xPlaneN - m_xPlane) * m_fx * m_ztickoffset;
6580 p(1) += octave::math::signum (m_yPlane - m_yPlaneN) * m_fy * m_ztickoffset;
6584 p = graphics_xform::xform_vector (m_xPlane, m_yPlaneN,
6585 (m_zpTickN + m_zpTick)/2);
6586 if (octave::math::isinf (m_fx))
6587 p(1) += octave::math::signum (m_yPlaneN - m_yPlane) * m_fy * m_ztickoffset;
6589 p(0) += octave::math::signum (m_xPlane - m_xPlaneN) * m_fx * m_ztickoffset;
6592 p =
xform.transform (p(0), p(1), p(2),
false);
6620 if (zlabel_props.positionmode_is (
"auto"))
6622 p =
xform.untransform (p(0), p(1), p(2),
true);
6624 p = convert_label_position (p, zlabel_props,
xform,
6625 get_extent (
false));
6628 zlabel_props.set_positionmode (
"auto");
6631 if (! isempty && zlabel_props.rotationmode_is (
"auto"))
6633 zlabel_props.set_rotation (angle);
6634 zlabel_props.set_rotationmode (
"auto");
6639static bool updating_title_position =
false;
6642axes::properties::update_title_position ()
6644 if (updating_title_position)
6647 gh_manager& gh_mgr = octave::__get_gh_manager__ ();
6649 graphics_object go = gh_mgr.
get_object (get_title ());
6651 if (! go.valid_object ())
6654 text::properties& title_props
6655 =
reinterpret_cast<text::properties&
> (go.get_properties ());
6657 octave::unwind_protect_var<bool> restore_var (updating_title_position,
true);
6659 if (title_props.positionmode_is (
"auto"))
6661 graphics_xform
xform = get_transform ();
6664 Matrix bbox = get_extent (
false);
6667 = graphics_xform::xform_vector (bbox(0) + bbox(2)/2, bbox(1) - 10,
6668 (m_x_zlim(0) + m_x_zlim(1))/2);
6673 ext = get_ticklabel_extents (get_xtick ().matrix_value (),
6674 get_xticklabel ().string_vector_value (),
6675 get_xlim ().matrix_value ());
6679 p =
xform.untransform (p(0), p(1), p(2),
true);
6681 p = convert_label_position (p, title_props,
xform, bbox);
6684 title_props.set_positionmode (
"auto");
6689axes::properties::update_autopos (
const std::string& elem_type)
6691 if (elem_type ==
"xlabel")
6692 update_xlabel_position ();
6693 else if (elem_type ==
"ylabel")
6694 update_ylabel_position ();
6695 else if (elem_type ==
"zlabel")
6696 update_zlabel_position ();
6697 else if (elem_type ==
"title")
6698 update_title_position ();
6699 else if (elem_type ==
"sync")
6704normalized_aspectratios (
Matrix& aspectratios,
const Matrix& scalefactors,
6705 double xlength,
double ylength,
double zlength)
6707 double xval = xlength / scalefactors(0);
6708 double yval = ylength / scalefactors(1);
6709 double zval = zlength / scalefactors(2);
6711 double minval = octave::math::min (octave::math::min (xval, yval), zval);
6713 aspectratios(0) = xval / minval;
6714 aspectratios(1) = yval / minval;
6715 aspectratios(2) = zval / minval;
6719max_axes_scale (
double& s,
Matrix& limits,
const Matrix& kids,
6720 double pbfactor,
double dafactor,
char limit_type,
bool tight)
6724 double minval = octave::numeric_limits<double>::Inf ();
6725 double maxval = -octave::numeric_limits<double>::Inf ();
6726 double min_pos = octave::numeric_limits<double>::Inf ();
6727 double max_neg = -octave::numeric_limits<double>::Inf ();
6729 if (octave::math::isfinite (minval) && octave::math::isfinite (maxval))
6733 s = octave::math::max (s, (maxval - minval) / (pbfactor * dafactor));
6737 s = octave::math::max (s, (limits(1) - limits(0)) / (pbfactor * dafactor));
6740static std::set<double> updating_aspectratios;
6743axes::properties::update_aspectratios ()
6745 if (updating_aspectratios.find (get___myhandle__ ().value ())
6746 != updating_aspectratios.end ())
6749 Matrix xlimits = get_xlim ().matrix_value ();
6750 Matrix ylimits = get_ylim ().matrix_value ();
6751 Matrix zlimits = get_zlim ().matrix_value ();
6753 double dx = (xlimits(1) - xlimits(0));
6754 double dy = (ylimits(1) - ylimits(0));
6755 double dz = (zlimits(1) - zlimits(0));
6757 Matrix da = get_dataaspectratio ().matrix_value ();
6758 Matrix pba = get_plotboxaspectratio ().matrix_value ();
6760 if (dataaspectratiomode_is (
"auto"))
6762 if (plotboxaspectratiomode_is (
"auto"))
6764 pba =
Matrix (1, 3, 1.0);
6765 m_plotboxaspectratio.set (pba,
false);
6768 normalized_aspectratios (da, pba, dx, dy, dz);
6769 m_dataaspectratio.set (da,
false);
6771 else if (plotboxaspectratiomode_is (
"auto"))
6773 normalized_aspectratios (pba, da, dx, dy, dz);
6774 m_plotboxaspectratio.set (pba,
false);
6778 double s = -octave::numeric_limits<double>::Inf ();
6779 bool modified_limits =
false;
6782 if (xlimmode_is (
"auto") && ylimmode_is (
"auto") && zlimmode_is (
"auto"))
6784 modified_limits =
true;
6785 kids = get_children ();
6786 max_axes_scale (s, xlimits, kids, pba(0), da(0),
'x',
true);
6787 max_axes_scale (s, ylimits, kids, pba(1), da(1),
'y',
true);
6788 max_axes_scale (s, zlimits, kids, pba(2), da(2),
'z',
true);
6790 else if (xlimmode_is (
"auto") && ylimmode_is (
"auto"))
6792 modified_limits =
true;
6793 max_axes_scale (s, zlimits, kids, pba(2), da(2),
'z',
false);
6795 else if (ylimmode_is (
"auto") && zlimmode_is (
"auto"))
6797 modified_limits =
true;
6798 max_axes_scale (s, xlimits, kids, pba(0), da(0),
'x',
false);
6800 else if (zlimmode_is (
"auto") && xlimmode_is (
"auto"))
6802 modified_limits =
true;
6803 max_axes_scale (s, ylimits, kids, pba(1), da(1),
'y',
false);
6806 if (modified_limits)
6808 octave::unwind_protect_var<std::set<double>>
6809 restore_var (updating_aspectratios);
6811 updating_aspectratios.insert (get___myhandle__ ().value ());
6813 dx = pba(0) * da(0);
6814 dy = pba(1) * da(1);
6815 dz = pba(2) * da(2);
6816 if (octave::math::isinf (s))
6817 s = 1 / octave::math::min (octave::math::min (dx, dy), dz);
6819 if (xlimmode_is (
"auto"))
6822 xlimits(0) = 0.5 * (xlimits(0) + xlimits(1) - dx);
6823 xlimits(1) = xlimits(0) + dx;
6825 set_xlimmode (
"auto");
6828 if (ylimmode_is (
"auto"))
6831 ylimits(0) = 0.5 * (ylimits(0) + ylimits(1) - dy);
6832 ylimits(1) = ylimits(0) + dy;
6834 set_ylimmode (
"auto");
6837 if (zlimmode_is (
"auto"))
6840 zlimits(0) = 0.5 * (zlimits(0) + zlimits(1) - dz);
6841 zlimits(1) = zlimits(0) + dz;
6843 set_zlimmode (
"auto");
6848 normalized_aspectratios (pba, da, dx, dy, dz);
6849 m_plotboxaspectratio.set (pba,
false);
6855axes::properties::update_label_color (handle_property label,
6858 gh_manager& gh_mgr = octave::__get_gh_manager__ ();
6860 gh_mgr.
get_object (label.handle_value ()).set (
"color", col.get ());
6864axes::properties::update_font (std::string prop)
6866 gh_manager& gh_mgr = octave::__get_gh_manager__ ();
6868 if (! prop.empty ())
6872 if (prop ==
"fontsize")
6875 get_titlefontsizemultiplier ());
6877 get_labelfontsizemultiplier ());
6879 else if (prop ==
"fontweight")
6880 tval = get (
"titlefontweight");
6882 gh_mgr.
get_object (get_xlabel ()).set (prop, val);
6883 gh_mgr.
get_object (get_ylabel ()).set (prop, val);
6884 gh_mgr.
get_object (get_zlabel ()).set (prop, val);
6885 gh_mgr.
get_object (get_title ()).set (prop, tval);
6888 double dpr = device_pixel_ratio (get___myhandle__ ());
6892 m_txt_renderer.set_font (get (
"fontname").string_value (),
6893 get (
"fontweight").string_value (),
6894 get (
"fontangle").string_value (),
6895 get (
"__fontsize_points__").double_value () * dpr);
6901axes::properties::get_boundingbox (
bool internal,
6902 const Matrix& parent_pix_size)
const
6904 Matrix pos = (internal ? get_position ().matrix_value ()
6905 : get_outerposition ().matrix_value ());
6906 Matrix parent_size (parent_pix_size);
6908 if (parent_size.isempty ())
6910 gh_manager& gh_mgr = octave::__get_gh_manager__ ();
6912 graphics_object go = gh_mgr.
get_object (get_parent ());
6914 if (go.valid_object ())
6916 = go.get_properties ().get_boundingbox (
true).extract_n (0, 2, 1, 2);
6918 parent_size = default_figure_position ();
6921 pos = convert_position (pos, get_units (),
"pixels", parent_size);
6925 pos(1) = parent_size(1) - pos(1) - pos(3);
6931axes::properties::get_extent (
bool with_text,
bool only_text_height)
const
6933 graphics_xform
xform = get_transform ();
6936 ext(0) = ext(1) = octave::numeric_limits<double>::Inf ();
6937 ext(2) = ext(3) = -octave::numeric_limits<double>::Inf ();
6938 for (
int i = 0; i <= 1; i++)
6939 for (
int j = 0; j <= 1; j++)
6940 for (
int k = 0; k <= 1; k++)
6943 j ? m_yPlaneN : m_yPlane,
6944 k ? m_zPlaneN : m_zPlane, false);
6945 ext(0) = std::min (ext(0), p(0));
6946 ext(1) = std::min (ext(1), p(1));
6947 ext(2) = std::max (ext(2), p(0));
6948 ext(3) = std::max (ext(3), p(1));
6953 for (
int i = 0; i < 4; i++)
6957 htext = get_title ();
6959 htext = get_xlabel ();
6961 htext = get_ylabel ();
6963 htext = get_zlabel ();
6965 gh_manager& gh_mgr = octave::__get_gh_manager__ ();
6967 text::properties& text_props
6968 =
reinterpret_cast<text::properties&
>
6969 (gh_mgr.
get_object (htext).get_properties ());
6971 Matrix text_pos = text_props.get_data_position ();
6972 text_pos =
xform.transform (text_pos(0), text_pos(1), text_pos(2));
6973 if (text_props.get_string ().isempty ())
6975 ext(0) = std::min (ext(0), text_pos(0));
6976 ext(1) = std::min (ext(1), text_pos(1));
6977 ext(2) = std::max (ext(2), text_pos(0));
6978 ext(3) = std::max (ext(3), text_pos(1));
6982 Matrix text_ext = text_props.get_extent_matrix (
true);
6986 double dpr = device_pixel_ratio (get___myhandle__ ());
6988 for (
int j = 0; j < 4; j++)
6991 bool ignore_horizontal =
false;
6992 bool ignore_vertical =
false;
6993 if (only_text_height)
6995 double text_rotation = text_props.get_rotation ();
6996 if (text_rotation == 0. || text_rotation == 180.)
6997 ignore_horizontal =
true;
6998 else if (text_rotation == 90. || text_rotation == 270.)
6999 ignore_vertical =
true;
7002 if (! ignore_horizontal)
7004 ext(0) = std::min (ext(0), text_pos(0)+text_ext(0));
7005 ext(2) = std::max (ext(2),
7006 text_pos(0)+text_ext(0)+text_ext(2));
7009 if (! ignore_vertical)
7011 ext(1) = std::min (ext(1),
7012 text_pos(1)-text_ext(1)-text_ext(3));
7013 ext(3) = std::max (ext(3), text_pos(1)-text_ext(1));
7019 ext(2) = ext(2) - ext(0);
7020 ext(3) = ext(3) - ext(1);
7042 std::ostringstream oss;
7050 if (std::abs (data(i)) < 1.0)
7061 std::istringstream iss (valstr);
7065 while (std::getline (iss, tmpstr,
'|'))
7069 if (*valstr.rbegin () ==
'|')
7070 sv.
append (std::string (
""));
7084axes::properties::set_xticklabel (
const octave_value& val)
7086 if (m_xticklabel.set (convert_ticklabel_string (val),
false))
7088 set_xticklabelmode (
"manual");
7089 m_xticklabel.run_listeners (GCB_POSTSET);
7093 set_xticklabelmode (
"manual");
7099axes::properties::set_yticklabel (
const octave_value& val)
7101 if (m_yticklabel.set (convert_ticklabel_string (val),
false))
7103 set_yticklabelmode (
"manual");
7104 m_yticklabel.run_listeners (GCB_POSTSET);
7108 set_yticklabelmode (
"manual");
7114axes::properties::set_zticklabel (
const octave_value& val)
7116 if (m_zticklabel.set (convert_ticklabel_string (val),
false))
7118 set_zticklabelmode (
"manual");
7119 m_zticklabel.run_listeners (GCB_POSTSET);
7123 set_zticklabelmode (
"manual");
7147 std::istringstream iss (valstr);
7151 while (std::getline (iss, tmpstr,
'|'))
7155 if (*valstr.rbegin () ==
'|')
7156 sv.
append (std::string (
""));
7170axes::properties::set_linestyleorder (
const octave_value& val)
7172 m_linestyleorder.set (convert_linestyleorder_string (val),
false);
7180 if (m_units.set (val,
true))
7182 update_units (old_units);
7188axes::properties::update_units (
const caseless_str& old_units)
7190 gh_manager& gh_mgr = octave::__get_gh_manager__ ();
7192 graphics_object parent_go = gh_mgr.
get_object (get_parent ());
7195 = parent_go.get_properties ().get_boundingbox (
true).
extract_n (0, 2, 1, 2);
7199 (convert_position (get_position ().matrix_value (),
7200 old_units, new_units, parent_bb)),
7203 (convert_position (get_outerposition ().matrix_value (),
7204 old_units, new_units, parent_bb)),
7207 (convert_position (get_tightinset ().matrix_value (),
7208 old_units, new_units, parent_bb)),
7211 (convert_position (get_looseinset ().matrix_value (),
7212 old_units, new_units, parent_bb)),
7217axes::properties::set_fontunits (
const octave_value& val)
7221 if (m_fontunits.set (val,
true))
7223 update_fontunits (old_fontunits);
7229axes::properties::update_fontunits (
const caseless_str& old_units)
7232 double parent_height = get_boundingbox (
true).elem (3);
7233 double fontsz = get_fontsize ();
7235 fontsz = convert_font_size (fontsz, old_units, new_units, parent_height);
7241axes::properties::get___fontsize_points__ (
double box_pix_height)
const
7243 double fontsz = get_fontsize ();
7244 double parent_height = box_pix_height;
7246 if (fontunits_is (
"normalized") && parent_height <= 0)
7247 parent_height = get_boundingbox (
true).elem (3);
7249 return convert_font_size (fontsz, get_fontunits (),
"points", parent_height);
7253graphics_xform::xform_vector (
double x,
double y,
double z)
7255 return octave::xform_vector (
x, y, z);
7259graphics_xform::xform_eye ()
7261 return octave::xform_matrix ();
7265graphics_xform::transform (
double x,
double y,
double z,
bool use_scale)
const
7274 return octave::transform (m_xform,
x, y, z);
7278graphics_xform::untransform (
double x,
double y,
double z,
7279 bool use_scale)
const
7285 v(0) = m_sx.unscale (v(0));
7286 v(1) = m_sy.unscale (v(1));
7287 v(2) = m_sz.unscale (v(2));
7296 octave_value retval = m_default_properties.lookup (pname);
7302 gh_manager& gh_mgr = octave::__get_gh_manager__ ();
7304 graphics_object parent_go = gh_mgr.
get_object (parent_h);
7306 retval = parent_go.get_default (pname);
7336check_limit_vals (
double& min_val,
double& max_val,
7337 double& min_pos,
double& max_neg,
7345 if (m.
numel () != 4)
7348 m(2) = octave::numeric_limits<double>::Inf ();
7349 m(3) = -octave::numeric_limits<double>::Inf ();
7355 if (octave::math::isfinite (val) && val < min_val)
7359 if (octave::math::isfinite (val) && val > max_val)
7363 if (octave::math::isfinite (val) && val > 0 && val < min_pos)
7367 if (octave::math::isfinite (val) && val < 0 && val > max_neg)
7375magform (
double x,
double& a,
int& b)
7384 b =
static_cast<int> (std::floor (std::log10 (std::abs (
x))));
7385 a =
x / std::pow (10.0, b);
7390axes::properties::update_outerposition ()
7392 set_positionconstraint (
"outerposition");
7394 set_units (
"normalized");
7396 Matrix outerbox = m_outerposition.get ().matrix_value ();
7398 double outer_left = outerbox(0);
7399 double outer_bottom = outerbox(1);
7400 double outer_width = outerbox(2);
7401 double outer_height = outerbox(3);
7403 double outer_right = outer_width + outer_left;
7404 double outer_top = outer_height + outer_bottom;
7406 Matrix linset = m_looseinset.get ().matrix_value ();
7407 Matrix tinset = m_tightinset.get ().matrix_value ();
7409 double left_margin = std::max (linset(0), tinset(0));
7410 double bottom_margin = std::max (linset(1), tinset(1));
7411 double right_margin = std::max (linset(2), tinset(2));
7412 double top_margin = std::max (linset(3), tinset(3));
7414 double inner_left = outer_left;
7415 double inner_right = outer_right;
7417 if ((left_margin + right_margin) < outer_width)
7419 inner_left += left_margin;
7420 inner_right -= right_margin;
7423 double inner_bottom = outer_bottom;
7424 double inner_top = outer_top;
7426 if ((bottom_margin + top_margin) < outer_height)
7428 inner_bottom += bottom_margin;
7429 inner_top -= top_margin;
7432 double inner_width = inner_right - inner_left;
7433 double inner_height = inner_top - inner_bottom;
7437 innerbox(0) = inner_left;
7438 innerbox(1) = inner_bottom;
7439 innerbox(2) = inner_width;
7440 innerbox(3) = inner_height;
7442 m_position = innerbox;
7444 set_units (old_units);
7445 update_transform ();
7449axes::properties::update_position ()
7451 set_positionconstraint (
"innerposition");
7453 set_units (
"normalized");
7455 Matrix innerbox = m_position.get ().matrix_value ();
7457 double inner_left = innerbox(0);
7458 double inner_bottom = innerbox(1);
7459 double inner_width = innerbox(2);
7460 double inner_height = innerbox(3);
7462 double inner_right = inner_width + inner_left;
7463 double inner_top = inner_height + inner_bottom;
7465 Matrix linset = m_looseinset.get ().matrix_value ();
7466 Matrix tinset = m_tightinset.get ().matrix_value ();
7468 double left_margin = std::max (linset(0), tinset(0));
7469 double bottom_margin = std::max (linset(1), tinset(1));
7470 double right_margin = std::max (linset(2), tinset(2));
7471 double top_margin = std::max (linset(3), tinset(3));
7475 double outer_left = inner_left - left_margin;
7476 double outer_bottom = inner_bottom - bottom_margin;
7477 double outer_right = inner_right + right_margin;
7478 double outer_top = inner_top + top_margin;
7480 double outer_width = outer_right - outer_left;
7481 double outer_height = outer_top - outer_bottom;
7485 outerbox(0) = outer_left;
7486 outerbox(1) = outer_bottom;
7487 outerbox(2) = outer_width;
7488 outerbox(3) = outer_height;
7490 m_outerposition = outerbox;
7492 set_units (old_units);
7493 update_transform ();
7497axes::properties::update_looseinset ()
7500 set_units (
"normalized");
7502 Matrix linset = m_looseinset.get ().matrix_value ();
7503 Matrix tinset = m_tightinset.get ().matrix_value ();
7505 double left_margin = std::max (linset(0), tinset(0));
7506 double bottom_margin = std::max (linset(1), tinset(1));
7507 double right_margin = std::max (linset(2), tinset(2));
7508 double top_margin = std::max (linset(3), tinset(3));
7510 if (m_positionconstraint.is (
"innerposition"))
7512 Matrix innerbox = m_position.get ().matrix_value ();
7514 double inner_left = innerbox(0);
7515 double inner_bottom = innerbox(1);
7516 double inner_width = innerbox(2);
7517 double inner_height = innerbox(3);
7519 double inner_right = inner_width + inner_left;
7520 double inner_top = inner_height + inner_bottom;
7524 double outer_left = inner_left - left_margin;
7525 double outer_bottom = inner_bottom - bottom_margin;
7526 double outer_right = inner_right + right_margin;
7527 double outer_top = inner_top + top_margin;
7529 double outer_width = outer_right - outer_left;
7530 double outer_height = outer_top - outer_bottom;
7534 outerbox(0) = outer_left;
7535 outerbox(1) = outer_bottom;
7536 outerbox(2) = outer_width;
7537 outerbox(3) = outer_height;
7539 m_outerposition = outerbox;
7543 Matrix outerbox = m_outerposition.get ().matrix_value ();
7545 double outer_left = outerbox(0);
7546 double outer_bottom = outerbox(1);
7547 double outer_width = outerbox(2);
7548 double outer_height = outerbox(3);
7550 double outer_right = outer_width + outer_left;
7551 double outer_top = outer_height + outer_bottom;
7553 double inner_left = outer_left;
7554 double inner_right = outer_right;
7556 if ((left_margin + right_margin) < outer_width)
7558 inner_left += left_margin;
7559 inner_right -= right_margin;
7562 double inner_bottom = outer_bottom;
7563 double inner_top = outer_top;
7565 if ((bottom_margin + top_margin) < outer_height)
7567 inner_bottom += bottom_margin;
7568 inner_top -= top_margin;
7571 double inner_width = inner_right - inner_left;
7572 double inner_height = inner_top - inner_bottom;
7576 innerbox(0) = inner_left;
7577 innerbox(1) = inner_bottom;
7578 innerbox(2) = inner_width;
7579 innerbox(3) = inner_height;
7581 m_position = innerbox;
7584 set_units (old_units);
7585 update_transform ();
7593axes::properties::calc_tick_sep (
double lo,
double hi)
7605 magform ((hi - lo) / ticint, a, b);
7607 static const double SQRT_2 = sqrt (2.0);
7608 static const double SQRT_10 = sqrt (10.0);
7609 static const double SQRT_50 = sqrt (50.0);
7613 else if (a < SQRT_10)
7615 else if (a < SQRT_50)
7620 return x * std::pow (10.0, b);
7627axes::properties::get_axis_limits (
double xmin,
double xmax,
7628 double min_pos,
double max_neg,
7629 const bool logscale,
7630 const std::string& method)
7634 double min_val =
xmin;
7635 double max_val =
xmax;
7637 if (octave::math::isinf (min_val) && min_val > 0
7638 && octave::math::isinf (max_val) && max_val < 0)
7640 retval = default_lim (logscale);
7643 else if (! (octave::math::isinf (min_val) || octave::math::isinf (max_val)))
7647 if (octave::math::isinf (min_pos) && octave::math::isinf (max_neg))
7652 retval = default_lim (logscale);
7660 "axis: omitting non-positive data in log plot");
7663 else if (max_val == 0)
7667 if (std::abs (min_val - max_val)
7668 < sqrt (std::numeric_limits<double>::epsilon ()))
7683 if (method ==
"tickaligned")
7688 min_val = std::pow (10, std::floor (log10 (min_val)));
7689 max_val = std::pow (10, std::ceil (log10 (max_val)));
7694 min_val = -std::pow (10, std::ceil (log10 (-min_val)));
7695 max_val = -std::pow (10, std::floor (log10 (-max_val)));
7698 else if (method ==
"padded")
7703 double pad = (log10 (max_val) - log10 (min_val)) * 0.07;
7704 min_val = std::pow (10, log10 (min_val) - pad);
7705 max_val = std::pow (10, log10 (max_val) + pad);
7710 double pad = (log10 (-min_val) - log10 (-max_val)) * 0.07;
7711 min_val = -std::pow (10, log10 (-min_val) + pad);
7712 max_val = -std::pow (10, log10 (-max_val) - pad);
7718 if (min_val == 0 && max_val == 0)
7724 else if (std::abs (min_val - max_val)
7725 < sqrt (std::numeric_limits<double>::epsilon ()))
7727 min_val -= 0.1 * std::abs (min_val);
7728 max_val += 0.1 * std::abs (max_val);
7731 if (method ==
"tickaligned")
7733 double tick_sep = calc_tick_sep (min_val, max_val);
7734 double min_tick = std::floor (min_val / tick_sep);
7735 double max_tick = std::ceil (max_val / tick_sep);
7737 min_val = std::min (min_val, tick_sep * min_tick);
7738 max_val = std::max (max_val, tick_sep * max_tick);
7740 else if (method ==
"padded")
7742 double pad = 0.07 * (max_val - min_val);
7751 retval(0) = min_val;
7752 retval(1) = max_val;
7758axes::properties::check_axis_limits (
Matrix& limits,
const Matrix kids,
7759 const bool logscale,
char& update_type)
7761 double min_val = octave::numeric_limits<double>::Inf ();
7762 double max_val = -octave::numeric_limits<double>::Inf ();
7763 double min_pos = octave::numeric_limits<double>::Inf ();
7764 double max_neg = -octave::numeric_limits<double>::Inf ();
7765 double eps = std::numeric_limits<double>::epsilon ();
7766 bool do_update =
false;
7767 bool have_children_limits =
false;
7770 if (! octave::math::isfinite (limits(0))
7771 || ! octave::math::isfinite (limits(1)))
7775 have_children_limits =
true;
7777 if (! octave::math::isfinite (limits(0)))
7779 limits(0) = min_val;
7782 if (! octave::math::isfinite (limits(1)))
7784 limits(1) = max_val;
7787 if (limits(0) == 0 && limits(1) == 0)
7789 limits = default_lim (logscale);
7793 else if (! logscale && (std::abs (limits(0) - limits(1)) < sqrt (
eps)))
7795 limits(0) -= 0.1 * std::abs (limits(0));
7796 limits(1) += 0.1 * std::abs (limits(1));
7800 && (std::abs (std::log10 (limits(0) / limits(1))) < sqrt (
eps)))
7802 limits(0) = (limits(0) < 0 ? 10.0 * limits(0) : 0.1 * limits(0));
7803 limits(1) = (limits(1) < 0 ? 0.1 * limits(1) : 10.0 * limits(1));
7807 if (logscale && limits(0)*limits(1) <= 0)
7809 if (! have_children_limits)
7816 "Non-positive limit for logarithmic axis ignored\n");
7817 if (octave::math::isfinite (min_pos))
7818 limits(0) = min_pos;
7820 limits(0) = 0.1 * limits(1);
7825 "Non-negative limit for logarithmic axis ignored\n");
7826 if (octave::math::isfinite (max_neg))
7827 limits(1) = max_neg;
7829 limits(1) = 0.1 * limits(0);
7832 if (std::abs (limits(0) - limits(1)) < sqrt (
eps))
7984axes::properties::calc_ticks_and_lims (array_property& lims,
7985 array_property& ticks,
7986 array_property& mticks,
7987 bool limmode_is_auto,
7988 bool tickmode_is_auto,
7990 bool method_is_padded,
7991 bool method_is_tight)
7993 if (lims.get ().isempty ())
7996 double lo = (lims.get ().matrix_value ())(0);
7997 double hi = (lims.get ().matrix_value ())(1);
8001 bool is_negative = lo < 0 && hi < 0;
8012 hi = std::log10 (-lo);
8013 lo = std::log10 (-tmp);
8017 hi = std::log10 (hi);
8018 lo = std::log10 (lo);
8023 if (tickmode_is_auto)
8029 if (! (octave::math::isinf (hi) || octave::math::isinf (lo)))
8035 tick_sep = calc_tick_sep (lo, hi);
8037 double i1 = std::floor (lo / tick_sep);
8038 double i2 = std::ceil (hi / tick_sep);
8040 if (limmode_is_auto)
8044 if (! method_is_padded && ! method_is_tight)
8047 tmp_lims(0) = std::min (tick_sep * i1, lo);
8048 tmp_lims(1) = std::max (tick_sep * i2, hi);
8056 if (i1*tick_sep < lo)
8058 if (i2*tick_sep > hi && i2 > i1)
8064 tmp_lims(0) = std::pow (10., tmp_lims(0));
8065 tmp_lims(1) = std::pow (10., tmp_lims(1));
8067 if (tmp_lims(0) <= 0)
8068 tmp_lims(0) = std::pow (10., lo);
8072 double tmp = tmp_lims(0);
8073 tmp_lims(0) = -tmp_lims(1);
8083 if (i1*tick_sep < lo)
8085 if (i2*tick_sep > hi && i2 > i1)
8089 tmp_ticks =
Matrix (1, i2-i1+1);
8090 for (
int i = 0; i <= static_cast<int> (i2-i1); i++)
8092 tmp_ticks(i) = tick_sep * (i+i1);
8094 tmp_ticks(i) = std::pow (10., tmp_ticks(i));
8096 if (is_logscale && is_negative)
8098 Matrix rev_ticks (1, i2-i1+1);
8099 rev_ticks = -tmp_ticks;
8100 for (
int i = 0; i <= static_cast<int> (i2-i1); i++)
8101 tmp_ticks(i) = rev_ticks(i2-i1-i);
8107 tmp_ticks = ticks.get ().matrix_value ();
8114 const int MAX_MINOR_TICKS = 1000;
8115 int n = (is_logscale ? 8 : 4);
8116 double mult_below = (is_logscale ? tmp_ticks(1) / tmp_ticks(0) : 1);
8117 double mult_above = (is_logscale ? tmp_ticks(n_ticks-1) / tmp_ticks(n_ticks-2)
8120 double d_below = (tmp_ticks(1) - tmp_ticks(0)) / mult_below / (n+1);
8121 int n_below =
static_cast<int> (std::floor ((tmp_ticks(0)-lo_lim) / d_below));
8124 else if (n_below > MAX_MINOR_TICKS)
8125 n_below = MAX_MINOR_TICKS;
8127 int n_between = n * (n_ticks - 1);
8128 double d_above = (tmp_ticks(n_ticks-1) - tmp_ticks(n_ticks-2)) * mult_above
8130 int n_above =
static_cast<int> (std::floor ((hi_lim-tmp_ticks(n_ticks-1))
8134 else if (n_above > MAX_MINOR_TICKS)
8135 n_above = MAX_MINOR_TICKS;
8137 Matrix tmp_mticks (1, n_below + n_between + n_above);
8138 for (
int i = 0; i < n_below; i++)
8139 tmp_mticks(i) = tmp_ticks(0) - (n_below-i) * d_below;
8140 for (
int i = 0; i < n_ticks-1; i++)
8142 double d = (tmp_ticks(i+1) - tmp_ticks(i)) / (n + 1);
8143 for (
int j = 0; j < n; j++)
8144 tmp_mticks(n_below+n*i+j) = tmp_ticks(i) +
d * (j+1);
8146 for (
int i = 0; i < n_above; i++)
8147 tmp_mticks(n_below+n_between+i) = tmp_ticks(n_ticks-1) + (i + 1) * d_above;
8149 mticks = tmp_mticks;
8166axes::properties::calc_ticklabels (
const array_property& ticks,
8167 any_property& labels,
bool logscale,
8168 const bool is_origin,
8169 const int other_axislocation,
8170 const array_property& axis_lims)
8172 Matrix values = ticks.get ().matrix_value ();
8173 Matrix lims = axis_lims.get ().matrix_value ();
8175 std::ostringstream os;
8178 ColumnVector omit_ticks (3, octave::numeric_limits<double>::NaN ());
8179 if (get_is2D () && is_origin)
8181 if (other_axislocation == 0)
8183 omit_ticks(0) = octave::math::max (octave::math::min (0., lims(1)),
8186 else if (other_axislocation == 1)
8187 omit_ticks(0) = lims(1);
8188 else if (other_axislocation == -1)
8189 omit_ticks(0) = lims(0);
8192 omit_ticks(1) = lims(0);
8193 omit_ticks(2) = lims(1);
8201 bool is_2digit_exp =
false;
8203 for (
int i = 0; i < values.
numel (); i++)
8205 double exp = std::abs (std::log10 (values(i)));
8208 is_2digit_exp =
true;
8213 for (
int i = 0; i < values.
numel (); i++)
8215 bool omit_tick =
false;
8216 for (
int i_omit = 0; i_omit < omit_ticks.numel (); i_omit++)
8217 if (values(i) == omit_ticks(i_omit))
8225 if (values(i) < 0.0)
8226 exponent = std::floor (std::log10 (-values(i)));
8228 exponent = std::floor (std::log10 (values(i)));
8229 significand = values(i) * std::pow (10.0, -exponent);
8233 if ((std::abs (significand) - 1) >
8234 10*std::numeric_limits<double>::epsilon())
8235 os << significand <<
'x';
8236 else if (significand < 0)
8244 exponent = -exponent;
8246 if (exponent < 10.0 && is_2digit_exp)
8248 os << exponent <<
'}';
8250 if (m_ticklabelinterpreter.is (
"latex"))
8251 c(i) =
"$" + os.str () +
"$";
8258 for (
int i = 0; i < values.
numel (); i++)
8260 bool omit_tick =
false;
8261 for (
int i_omit = 0; i_omit < omit_ticks.numel (); i_omit++)
8262 if (values(i) == omit_ticks(i_omit))
8274 if (std::abs (values(i)) < 1.0)
8288axes::properties::get_ticklabel_extents (
const Matrix& ticks,
8294 double dpr = device_pixel_ratio (get___myhandle__ ());
8296 int n = std::min (ticklabels.
numel (), ticks.
numel ());
8297 for (
int i = 0; i < n; i++)
8299 double val = ticks(i);
8300 if (limits(0) <= val && val <= limits(1))
8302 std::string label (ticklabels(i));
8303 label.erase (0, label.find_first_not_of (
' '));
8304 label = label.substr (0, label.find_last_not_of (
' ')+1);
8306 if (m_txt_renderer.ok ())
8308 gh_manager& gh_mgr = octave::__get_gh_manager__ ();
8312 ext = m_txt_renderer.get_extent (label, 0.0,
8313 get_ticklabelinterpreter ());
8315 wmax = std::max (wmax, ext(0) / dpr);
8316 hmax = std::max (hmax, ext(1) / dpr);
8321 double fsize = get (
"fontsize").double_value ();
8322 int len = label.length ();
8324 wmax = std::max (wmax, 0.5*fsize*
len);
8337 double& min_pos,
double& max_neg,
8338 const Matrix& kids,
char limit_type)
8342 gh_manager& gh_mgr = octave::__get_gh_manager__ ();
8349 graphics_object go = gh_mgr.
get_object (kids(i));
8351 if (go.is_xliminclude ())
8355 check_limit_vals (min_val, max_val, min_pos, max_neg, lim);
8363 graphics_object go = gh_mgr.
get_object (kids(i));
8365 if (go.is_yliminclude ())
8369 check_limit_vals (min_val, max_val, min_pos, max_neg, lim);
8377 graphics_object go = gh_mgr.
get_object (kids(i));
8379 if (go.is_zliminclude ())
8383 check_limit_vals (min_val, max_val, min_pos, max_neg, lim);
8391 graphics_object go = gh_mgr.
get_object (kids(i));
8393 if (go.is_climinclude ())
8397 check_limit_vals (min_val, max_val, min_pos, max_neg, lim);
8405 graphics_object go = gh_mgr.
get_object (kids(i));
8407 if (go.is_aliminclude ())
8411 check_limit_vals (min_val, max_val, min_pos, max_neg, lim);
8421static std::set<double> updating_axis_limits;
8424axes::update_axis_limits (
const std::string& axis_type,
8427 if (updating_axis_limits.find (get_handle ().value ())
8428 != updating_axis_limits.end ())
8433 double min_val = octave::numeric_limits<double>::Inf ();
8434 double max_val = -octave::numeric_limits<double>::Inf ();
8435 double min_pos = octave::numeric_limits<double>::Inf ();
8436 double max_neg = -octave::numeric_limits<double>::Inf ();
8438 char update_type = 0;
8445 if (octave::math::isfinite (val)) \
8448 if (octave::math::isfinite (val)) \
8451 if (axis_type ==
"xdata" || axis_type ==
"xscale"
8452 || axis_type ==
"xlimmode" || axis_type ==
"xliminclude"
8453 || axis_type ==
"xlim")
8455 limits = m_properties.get_xlim ().matrix_value ();
8459 if (m_properties.xlimmode_is (
"auto"))
8463 std::string method = m_properties.get_xlimitmethod ();
8464 limits = m_properties.get_axis_limits (min_val, max_val,
8466 m_properties.xscale_is (
"log"),
8470 m_properties.check_axis_limits (limits, kids,
8471 m_properties.xscale_is (
"log"),
8474 else if (axis_type ==
"ydata" || axis_type ==
"yscale"
8475 || axis_type ==
"ylimmode" || axis_type ==
"yliminclude"
8476 || axis_type ==
"ylim")
8478 limits = m_properties.get_ylim ().matrix_value ();
8482 if (m_properties.ylimmode_is (
"auto"))
8486 std::string method = m_properties.get_ylimitmethod ();
8487 limits = m_properties.get_axis_limits (min_val, max_val,
8489 m_properties.yscale_is (
"log"),
8493 m_properties.check_axis_limits (limits, kids,
8494 m_properties.yscale_is (
"log"),
8497 else if (axis_type ==
"zdata" || axis_type ==
"zscale"
8498 || axis_type ==
"zlimmode" || axis_type ==
"zliminclude"
8499 || axis_type ==
"zlim")
8501 limits = m_properties.get_zlim ().matrix_value ();
8505 if (m_properties.zlimmode_is (
"auto"))
8509 m_properties.set_has3Dkids ((max_val - min_val) >
8510 std::numeric_limits<double>::epsilon ());
8512 std::string method = m_properties.get_zlimitmethod ();
8513 limits = m_properties.get_axis_limits (min_val, max_val,
8515 m_properties.zscale_is (
"log"),
8524 m_properties.set_has3Dkids ((max_val - min_val) >
8525 std::numeric_limits<double>::epsilon ());
8527 m_properties.check_axis_limits (limits, kids,
8528 m_properties.zscale_is (
"log"),
8532 else if (axis_type ==
"cdata" || axis_type ==
"climmode"
8533 || axis_type ==
"cdatamapping" || axis_type ==
"climinclude"
8534 || axis_type ==
"clim")
8536 if (m_properties.climmode_is (
"auto"))
8538 limits = m_properties.get_clim ().matrix_value ();
8543 if (min_val > max_val)
8545 min_val = min_pos = 0;
8548 else if (min_val == max_val)
8550 max_val = min_val + 1;
8554 limits(0) = min_val;
8555 limits(1) = max_val;
8560 else if (axis_type ==
"alphadata" || axis_type ==
"alimmode"
8561 || axis_type ==
"alphadatamapping" || axis_type ==
"aliminclude"
8562 || axis_type ==
"alim")
8564 if (m_properties.alimmode_is (
"auto"))
8566 limits = m_properties.get_alim ().matrix_value ();
8571 if (min_val > max_val)
8573 min_val = min_pos = 0;
8576 else if (min_val == max_val)
8577 max_val = min_val + 1;
8579 limits(0) = min_val;
8580 limits(1) = max_val;
8588 octave::unwind_protect_var<std::set<double>>
8589 restore_var (updating_axis_limits);
8591 updating_axis_limits.insert (get_handle ().value ());
8594 switch (update_type)
8597 is_auto = m_properties.xlimmode_is (
"auto");
8598 m_properties.set_xlim (limits);
8600 m_properties.set_xlimmode (
"auto");
8601 m_properties.update_xlim ();
8605 is_auto = m_properties.ylimmode_is (
"auto");
8606 m_properties.set_ylim (limits);
8608 m_properties.set_ylimmode (
"auto");
8609 m_properties.update_ylim ();
8613 is_auto = m_properties.zlimmode_is (
"auto");
8614 m_properties.set_zlim (limits);
8616 m_properties.set_zlimmode (
"auto");
8617 m_properties.update_zlim ();
8621 m_properties.set_clim (limits);
8622 m_properties.set_climmode (
"auto");
8626 m_properties.set_alim (limits);
8627 m_properties.set_alimmode (
"auto");
8634 m_properties.update_transform ();
8641axes::update_axis_limits (
const std::string& axis_type)
8643 if ((updating_axis_limits.find (get_handle ().value ())
8644 != updating_axis_limits.end ())
8645 || (updating_aspectratios.find (get_handle ().value ())
8646 != updating_aspectratios.end ()))
8649 Matrix kids = m_properties.get_all_children ();
8651 double min_val = octave::numeric_limits<double>::Inf ();
8652 double max_val = -octave::numeric_limits<double>::Inf ();
8653 double min_pos = octave::numeric_limits<double>::Inf ();
8654 double max_neg = -octave::numeric_limits<double>::Inf ();
8656 char update_type = 0;
8660 if (axis_type ==
"xdata" || axis_type ==
"xscale"
8661 || axis_type ==
"xlimmode" || axis_type ==
"xliminclude"
8662 || axis_type ==
"xlim")
8665 if (m_properties.xlimmode_is (
"auto"))
8669 std::string method = m_properties.get_xlimitmethod ();
8670 limits = m_properties.get_axis_limits (min_val, max_val,
8672 m_properties.xscale_is (
"log"),
8677 limits = m_properties.get_xlim ().matrix_value ();
8678 m_properties.check_axis_limits (limits, kids,
8679 m_properties.xscale_is (
"log"),
8681 if (axis_type ==
"xscale")
8685 else if (axis_type ==
"ydata" || axis_type ==
"yscale"
8686 || axis_type ==
"ylimmode" || axis_type ==
"yliminclude"
8687 || axis_type ==
"ylim")
8690 if (m_properties.ylimmode_is (
"auto"))
8694 std::string method = m_properties.get_ylimitmethod ();
8695 limits = m_properties.get_axis_limits (min_val, max_val,
8697 m_properties.yscale_is (
"log"),
8702 limits = m_properties.get_ylim ().matrix_value ();
8703 m_properties.check_axis_limits (limits, kids,
8704 m_properties.yscale_is (
"log"),
8706 if (axis_type ==
"yscale")
8710 else if (axis_type ==
"zdata" || axis_type ==
"zscale"
8711 || axis_type ==
"zlimmode" || axis_type ==
"zliminclude"
8712 || axis_type ==
"zlim")
8715 if (m_properties.zlimmode_is (
"auto"))
8719 m_properties.set_has3Dkids ((max_val - min_val) >
8720 std::numeric_limits<double>::epsilon ());
8723 if ((! octave::math::isfinite (min_val)
8724 || ! octave::math::isfinite (max_val))
8725 && ! m_properties.zscale_is (
"log"))
8726 min_val = max_val = 0.;
8728 std::string method = m_properties.get_zlimitmethod ();
8729 limits = m_properties.get_axis_limits (min_val, max_val,
8731 m_properties.zscale_is (
"log"),
8740 m_properties.set_has3Dkids ((max_val - min_val) >
8741 std::numeric_limits<double>::epsilon ());
8743 limits = m_properties.get_zlim ().matrix_value ();
8744 m_properties.check_axis_limits (limits, kids,
8745 m_properties.zscale_is (
"log"),
8747 if (axis_type ==
"zscale")
8751 else if (axis_type ==
"cdata" || axis_type ==
"climmode"
8752 || axis_type ==
"cdatamapping" || axis_type ==
"climinclude"
8753 || axis_type ==
"clim")
8755 if (m_properties.climmode_is (
"auto"))
8759 if (min_val > max_val)
8761 min_val = min_pos = 0;
8764 else if (min_val == max_val)
8766 max_val = min_val + 1;
8772 limits(0) = min_val;
8773 limits(1) = max_val;
8779 else if (axis_type ==
"alphadata" || axis_type ==
"alimmode"
8780 || axis_type ==
"alphadatamapping" || axis_type ==
"aliminclude"
8781 || axis_type ==
"alim")
8783 if (m_properties.alimmode_is (
"auto"))
8787 if (min_val > max_val)
8789 min_val = min_pos = 0;
8792 else if (min_val == max_val)
8793 max_val = min_val + 1;
8797 limits(0) = min_val;
8798 limits(1) = max_val;
8805 octave::unwind_protect_var<std::set<double>>
8806 restore_var (updating_axis_limits);
8808 updating_axis_limits.insert (get_handle ().value ());
8811 switch (update_type)
8814 is_auto = m_properties.xlimmode_is (
"auto");
8815 m_properties.set_xlim (limits);
8817 m_properties.set_xlimmode (
"auto");
8818 m_properties.update_xlim ();
8822 is_auto = m_properties.ylimmode_is (
"auto");
8823 m_properties.set_ylim (limits);
8825 m_properties.set_ylimmode (
"auto");
8826 m_properties.update_ylim ();
8830 is_auto = m_properties.zlimmode_is (
"auto");
8831 m_properties.set_zlim (limits);
8833 m_properties.set_zlimmode (
"auto");
8834 m_properties.update_zlim ();
8838 m_properties.set_clim (limits);
8839 m_properties.set_climmode (
"auto");
8843 m_properties.set_alim (limits);
8844 m_properties.set_alimmode (
"auto");
8851 m_properties.update_transform ();
8866do_zoom (
double val,
double factor,
const Matrix& lims,
bool is_logscale)
8870 double lo = lims(0);
8871 double hi = lims(1);
8873 bool is_negative = lo < 0 && hi < 0;
8880 hi = std::log10 (-lo);
8881 lo = std::log10 (-tmp);
8882 val = std::log10 (-val);
8886 hi = std::log10 (hi);
8887 lo = std::log10 (lo);
8888 val = std::log10 (val);
8893 lo = val + (lo - val) / factor;
8894 hi = val + (hi - val) / factor;
8900 double tmp = -std::pow (10.0, hi);
8901 hi = -std::pow (10.0, lo);
8906 lo = std::pow (10.0, lo);
8907 hi = std::pow (10.0, hi);
8918axes::properties::zoom_about_point (
const std::string& mode,
8919 double x,
double y,
double factor,
8920 bool push_to_zoom_stack)
8923 Matrix xlims = get_xlim ().matrix_value ();
8924 Matrix ylims = get_ylim ().matrix_value ();
8927 Matrix kids = get_children ();
8928 double minx = octave::numeric_limits<double>::Inf ();
8929 double maxx = -octave::numeric_limits<double>::Inf ();
8930 double min_pos_x = octave::numeric_limits<double>::Inf ();
8931 double max_neg_x = -octave::numeric_limits<double>::Inf ();
8934 double miny = octave::numeric_limits<double>::Inf ();
8935 double maxy = -octave::numeric_limits<double>::Inf ();
8936 double min_pos_y = octave::numeric_limits<double>::Inf ();
8937 double max_neg_y = -octave::numeric_limits<double>::Inf ();
8940 xlims = do_zoom (
x, factor, xlims, xscale_is (
"log"));
8941 ylims = do_zoom (y, factor, ylims, yscale_is (
"log"));
8943 zoom (mode, xlims, ylims, push_to_zoom_stack);
8947axes::properties::zoom (
const std::string& mode,
double factor,
8948 bool push_to_zoom_stack)
8951 Matrix xlims = get_xlim ().matrix_value ();
8952 Matrix ylims = get_ylim ().matrix_value ();
8954 double x = (xlims(0) + xlims(1)) / 2;
8955 double y = (ylims(0) + ylims(1)) / 2;
8957 zoom_about_point (mode,
x, y, factor, push_to_zoom_stack);
8961axes::properties::push_zoom_stack ()
8963 if (m_zoom_stack.empty ())
8965 m_zoom_stack.push_front (m_xlimmode.get ());
8966 m_zoom_stack.push_front (m_xlim.get ());
8967 m_zoom_stack.push_front (m_ylimmode.get ());
8968 m_zoom_stack.push_front (m_ylim.get ());
8969 m_zoom_stack.push_front (m_zlimmode.get ());
8970 m_zoom_stack.push_front (m_zlim.get ());
8971 m_zoom_stack.push_front (m_view.get ());
8976axes::properties::zoom (
const std::string& mode,
8978 bool push_to_zoom_stack)
8980 if (xl(0) == xl(1) || yl(0) == yl(1))
8982 warning (
"invalid zoom region");
8986 if (push_to_zoom_stack)
8989 if (mode ==
"horizontal" || mode ==
"both")
8992 m_xlimmode =
"manual";
8995 if (mode ==
"vertical" || mode ==
"both")
8998 m_ylimmode =
"manual";
9001 update_transform ();
9003 if (mode ==
"horizontal" || mode ==
"both")
9006 if (mode ==
"vertical" || mode ==
"both")
9011do_translate (
double x0,
double x1,
const Matrix& lims,
bool is_logscale)
9015 double lo = lims(0);
9016 double hi = lims(1);
9018 bool is_negative = lo < 0 && hi < 0;
9027 hi = std::log10 (-lo);
9028 lo = std::log10 (-tmp);
9034 hi = std::log10 (hi);
9035 lo = std::log10 (lo);
9038 delta = std::log10 (x0) - std::log10 (x1);
9053 double tmp = -std::pow (10.0, hi);
9054 hi = -std::pow (10.0, lo);
9059 lo = std::pow (10.0, lo);
9060 hi = std::pow (10.0, hi);
9071axes::properties::translate_view (
const std::string& mode,
9072 double x0,
double x1,
double y0,
double y1,
9073 bool push_to_zoom_stack)
9076 Matrix xlims = get_xlim ().matrix_value ();
9077 Matrix ylims = get_ylim ().matrix_value ();
9080 Matrix kids = get_children ();
9081 double minx = octave::numeric_limits<double>::Inf ();
9082 double maxx = -octave::numeric_limits<double>::Inf ();
9083 double min_pos_x = octave::numeric_limits<double>::Inf ();
9084 double max_neg_x = -octave::numeric_limits<double>::Inf ();
9087 double miny = octave::numeric_limits<double>::Inf ();
9088 double maxy = -octave::numeric_limits<double>::Inf ();
9089 double min_pos_y = octave::numeric_limits<double>::Inf ();
9090 double max_neg_y = -octave::numeric_limits<double>::Inf ();
9093 xlims = do_translate (x0, x1, xlims, xscale_is (
"log"));
9094 ylims = do_translate (y0, y1, ylims, yscale_is (
"log"));
9096 zoom (mode, xlims, ylims, push_to_zoom_stack);
9100axes::properties::pan (
const std::string& mode,
double factor,
9101 bool push_to_zoom_stack)
9104 Matrix xlims = get_xlim ().matrix_value ();
9105 Matrix ylims = get_ylim ().matrix_value ();
9107 double x0 = (xlims(0) + xlims(1)) / 2;
9108 double y0 = (ylims(0) + ylims(1)) / 2;
9110 double x1 = x0 + (xlims(1) - xlims(0)) * factor;
9111 double y1 = y0 + (ylims(1) - ylims(0)) * factor;
9113 translate_view (mode, x0, x1, y0, y1, push_to_zoom_stack);
9117axes::properties::rotate3d (
double x0,
double x1,
double y0,
double y1,
9118 bool push_to_zoom_stack)
9120 if (push_to_zoom_stack)
9123 Matrix bb = get_boundingbox (
true);
9124 Matrix new_view = get_view ().matrix_value ();
9127 new_view(0) += ((x0 - x1) * (180.0 / bb(2)));
9128 new_view(1) += ((y1 - y0) * (180.0 / bb(3)));
9131 new_view(1) = std::min (new_view(1), 90.0);
9132 new_view(1) = std::max (new_view(1), -90.0);
9133 if (new_view(0) > 180.0)
9134 new_view(0) -= 360.0;
9135 else if (new_view(0) < -180.0)
9136 new_view(0) += 360.0;
9139 double snapmargin = 1.0;
9140 for (
int a = -90; a <= 90; a += 90)
9142 if ((a - snapmargin) < new_view(1) && new_view(1) < (a + snapmargin))
9149 for (
int a = -180; a <= 180; a += 180)
9150 if ((a - snapmargin) < new_view(0) && new_view(0) < (a + snapmargin))
9160 set_view (new_view);
9164axes::properties::rotate_view (
double delta_el,
double delta_az,
9165 bool push_to_zoom_stack)
9167 if (push_to_zoom_stack)
9170 Matrix v = get_view ().matrix_value ();
9179 v(0) = fmod (v(0) - delta_az + 720, 360);
9183 update_transform ();
9187axes::properties::unzoom ()
9189 if (m_zoom_stack.size () >= 7)
9191 m_view = m_zoom_stack.front ();
9192 m_zoom_stack.pop_front ();
9194 m_zlim = m_zoom_stack.front ();
9195 m_zoom_stack.pop_front ();
9197 m_zlimmode = m_zoom_stack.front ();
9198 m_zoom_stack.pop_front ();
9200 m_ylim = m_zoom_stack.front ();
9201 m_zoom_stack.pop_front ();
9203 m_ylimmode = m_zoom_stack.front ();
9204 m_zoom_stack.pop_front ();
9206 m_xlim = m_zoom_stack.front ();
9207 m_zoom_stack.pop_front ();
9209 m_xlimmode = m_zoom_stack.front ();
9210 m_zoom_stack.pop_front ();
9212 update_transform ();
9223axes::properties::update_handlevisibility ()
9225 if (! is_handle_visible ())
9227 gh_manager& gh_mgr = octave::__get_gh_manager__ ();
9229 graphics_object go (gh_mgr.
get_object (get___myhandle__ ()));
9231 graphics_object fig (go.get_ancestor (
"figure"));
9239 fig.set (
"currentaxes",
Matrix ());
9243 fig.set (
"currentaxes", kidsarray(0));
9248 base_properties::update_handlevisibility ();
9252figure::properties::init_toolkit ()
9254 octave::gtk_manager& gtk_mgr = octave::__get_gtk_manager__ ();
9256 m_toolkit = gtk_mgr.get_toolkit ();
9260axes::properties::clear_zoom_stack (
bool do_unzoom)
9262 std::size_t items_to_leave_on_stack = (do_unzoom ? 7 : 0);
9264 while (m_zoom_stack.size () > items_to_leave_on_stack)
9265 m_zoom_stack.pop_front ();
9272axes::properties::trigger_normals_calc ()
9275 std::list<graphics_object> children_list;
9276 std::list<graphics_object>::iterator children_list_iter;
9277 get_children_of_type (
"patch",
false,
true, children_list);
9278 get_children_of_type (
"surface",
false,
true, children_list);
9281 for (children_list_iter = children_list.begin ();
9282 children_list_iter != children_list.end (); children_list_iter++)
9284 graphics_object kid = *children_list_iter;
9285 if (kid.isa (
"patch"))
9287 patch::properties& patch_props
9288 =
dynamic_cast<patch::properties&
> (kid.get_properties ());
9289 patch_props.update_normals (
false);
9293 surface::properties& surface_props
9294 =
dynamic_cast<surface::properties&
> (kid.get_properties ());
9295 surface_props.update_normals (
false);
9301axes::reset_default_properties ()
9304 m_default_properties = property_list ();
9307 int state = toggle_warn (
"Octave:deprecated-property",
false);
9310 remove_all_listeners ();
9311 set_defaults (
"reset");
9313 toggle_warn (
"Octave:deprecated-property",
true, state);
9317axes::initialize (
const graphics_object& go)
9319 base_graphics_object::initialize (go);
9321 xinitialize (m_properties.get_title ());
9322 xinitialize (m_properties.get_xlabel ());
9323 xinitialize (m_properties.get_ylabel ());
9324 xinitialize (m_properties.get_zlabel ());
9326 m_properties.sync_positions ();
9332line::properties::compute_xlim ()
const
9336 m(0) = m_xdata.min_val ();
9337 m(1) = m_xdata.max_val ();
9338 m(2) = m_xdata.min_pos ();
9339 m(3) = m_xdata.max_neg ();
9345line::properties::compute_ylim ()
const
9349 m(0) = m_ydata.min_val ();
9350 m(1) = m_ydata.max_val ();
9351 m(2) = m_ydata.min_pos ();
9352 m(3) = m_ydata.max_neg ();
9360text::properties::get_data_position ()
const
9362 Matrix pos = get_position ().matrix_value ();
9364 if (! units_is (
"data"))
9365 pos = convert_text_position (pos, *
this, get_units (),
"data");
9371text::properties::get_extent_matrix (
bool rotated)
const
9374 Matrix ext = m_extent.get ().matrix_value ();
9376 if (rotated && get_rotation () != 0)
9378 double rot = get_rotation () * 4.0 *
atan (1.0) / 180;
9379 double x0 = ext(0) * cos (rot) - ext(1) * sin (rot);
9381 double y0 = ext(0) * sin (rot) + ext(1) * cos (rot);
9384 double tmp = (ext(0)+ext(2)) * cos (rot) - ext(1) * sin (rot);
9385 x0 = std::min (x0, tmp);
9386 x1 = std::max (x1, tmp);
9387 tmp = (ext(0)+ext(2)) * sin (rot) + ext(1) * cos (rot);
9388 y0 = std::min (y0, tmp);
9389 y1 = std::max (y1, tmp);
9391 tmp = (ext(0)+ext(2)) * cos (rot) - (ext(1)+ext(3)) * sin (rot);
9392 x0 = std::min (x0, tmp);
9393 x1 = std::max (x1, tmp);
9394 tmp = (ext(0)+ext(2)) * sin (rot) + (ext(1)+ext(3)) * cos (rot);
9395 y0 = std::min (y0, tmp);
9396 y1 = std::max (y1, tmp);
9398 tmp = ext(0) * cos (rot) - (ext(1)+ext(3)) * sin (rot);
9399 x0 = std::min (x0, tmp);
9400 x1 = std::max (x1, tmp);
9401 tmp = ext(0) * sin (rot) + (ext(1)+ext(3)) * cos (rot);
9402 y0 = std::min (y0, tmp);
9403 y1 = std::max (y1, tmp);
9415text::properties::get_extent ()
const
9419 Matrix m = get_extent_matrix (
true);
9420 Matrix pos = get_position ().matrix_value ();
9421 Matrix p = convert_text_position (pos, *
this, get_units (),
"pixels");
9426 Matrix bbox = convert_text_position (m, *
this,
"pixels", get_units ());
9428 double dpr = device_pixel_ratio (get___myhandle__ ());
9431 bbox(ii) = bbox(ii) / dpr;
9437text::properties::set_fontunits (
const octave_value& val)
9441 if (m_fontunits.set (val,
true))
9443 update_fontunits (old_fontunits);
9449text::properties::update_fontunits (
const caseless_str& old_units)
9452 double parent_height = 0;
9453 double fontsz = get_fontsize ();
9455 if (new_units ==
"normalized" || old_units ==
"normalized")
9457 gh_manager& gh_mgr = octave::__get_gh_manager__ ();
9459 graphics_object go (gh_mgr.
get_object (get___myhandle__ ()));
9461 graphics_object ax (go.get_ancestor (
"axes"));
9463 parent_height = ax.get_properties ().get_boundingbox (
true).elem (3);
9466 fontsz = convert_font_size (fontsz, old_units, new_units, parent_height);
9472text::properties::update_font ()
9474 double dpr = device_pixel_ratio (get___myhandle__ ());
9476 gh_manager& gh_mgr = octave::__get_gh_manager__ ();
9480 m_txt_renderer.set_font (get (
"fontname").string_value (),
9481 get (
"fontweight").string_value (),
9482 get (
"fontangle").string_value (),
9483 get (
"__fontsize_points__").double_value () * dpr);
9485 m_txt_renderer.set_anti_aliasing (is_fontsmoothing ());
9487 Matrix c = get_color_rgb ();
9489 m_txt_renderer.set_color (c);
9494text::properties::update_text_extent ()
9499 if (horizontalalignment_is (
"center"))
9501 else if (horizontalalignment_is (
"right"))
9504 if (verticalalignment_is (
"middle"))
9506 else if (verticalalignment_is (
"top"))
9508 else if (verticalalignment_is (
"baseline"))
9510 else if (verticalalignment_is (
"cap"))
9521 gh_manager& gh_mgr = octave::__get_gh_manager__ ();
9525 m_txt_renderer.text_to_pixels (sv.
join (
"\n"), m_pixels, bbox,
9526 halign, valign, 0.0, get_interpreter ());
9533 if (__autopos_tag___is (
"xlabel") || __autopos_tag___is (
"ylabel")
9534 || __autopos_tag___is (
"zlabel") || __autopos_tag___is (
"title"))
9535 update_autopos (
"sync");
9539text::properties::request_autopos ()
9541 if (__autopos_tag___is (
"xlabel") || __autopos_tag___is (
"ylabel")
9542 || __autopos_tag___is (
"zlabel") || __autopos_tag___is (
"title"))
9543 update_autopos (get___autopos_tag__ ());
9547text::properties::update_units ()
9549 if (! units_is (
"data"))
9551 set_xliminclude (
"off");
9552 set_yliminclude (
"off");
9553 set_zliminclude (
"off");
9556 Matrix pos = get_position ().matrix_value ();
9558 pos = convert_text_position (pos, *
this, m_cached_units, get_units ());
9563 bool autopos = positionmode_is (
"auto");
9568 set_positionmode (
"auto");
9570 if (units_is (
"data"))
9572 set_xliminclude (
"on");
9573 set_yliminclude (
"on");
9575 set_zliminclude (
"off");
9578 m_cached_units = get_units ();
9582text::properties::get___fontsize_points__ (
double box_pix_height)
const
9584 double fontsz = get_fontsize ();
9585 double parent_height = box_pix_height;
9587 gh_manager& gh_mgr = octave::__get_gh_manager__ ();
9589 graphics_object go (gh_mgr.
get_object (get___myhandle__ ()));
9591 if (fontunits_is (
"normalized") && parent_height <= 0)
9593 graphics_object ax (go.get_ancestor (
"axes"));
9595 parent_height = ax.get_properties ().get_boundingbox (
true).elem (3);
9598 return convert_font_size (fontsz, get_fontunits (),
"points", parent_height);
9604image::properties::get_color_data ()
const
9606 return convert_cdata (*
this, get_cdata (), cdatamapping_is (
"scaled"), 3);
9612light::initialize (
const graphics_object& go)
9614 base_graphics_object::initialize (go);
9617 axes::properties& parent_axes_prop
9618 =
dynamic_cast<axes::properties&
> (go.get_ancestor (
"axes").get_properties ());
9619 parent_axes_prop.trigger_normals_calc ();
9623light::properties::update_visible ()
9625 gh_manager& gh_mgr = octave::__get_gh_manager__ ();
9627 graphics_object go = gh_mgr.
get_object (get___myhandle__ ());
9629 axes::properties& ax_props =
dynamic_cast<axes::properties&
>
9630 (go.get_ancestor (
"axes").get_properties ());
9632 ax_props.increase_num_lights ();
9634 ax_props.decrease_num_lights ();
9640patch::properties::get_do_lighting ()
const
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 return (ax_props.get_num_lights () > 0);
9653patch::properties::get_color_data ()
const
9659 return convert_cdata (*
this, fvc, cdatamapping_is (
"scaled"), 2);
9662static bool updating_patch_data =
false;
9665patch::properties::update_fvc ()
9667 if (updating_patch_data)
9670 Matrix xd = get_xdata ().matrix_value ();
9671 Matrix yd = get_ydata ().matrix_value ();
9672 Matrix zd = get_zdata ().matrix_value ();
9673 NDArray cd = get_cdata ().array_value ();
9675 m_bad_data_msg =
"";
9679 m_bad_data_msg =
"x/y/zdata must have the same dimensions";
9687 if ((ncf > 1 || ncv > 1) && ((ncf != nf) || (ncv != 1 && ncv != nv)))
9689 m_bad_data_msg =
"cdata does not match number of faces "
9690 "or number of vertices per face";
9695 if (cd.
ndims () == 3)
9701 if (nv == 1 && nf > 1)
9710 bool pervertex =
false;
9730 fvc.
resize (nv * nf, (isRGB ? 3 : 1));
9736 dv(1) = (isRGB ? 3 : 1);
9747 vert(kk, 0) = xd(ii, jj);
9748 vert(kk, 1) = yd(ii, jj);
9750 vert(kk, 2) = zd(ii, jj);
9754 fvc(kk, 0) = cd(ii, jj, 0);
9757 fvc(kk, 1) = cd(ii, jj, 1);
9758 fvc(kk, 2) = cd(ii, jj, 2);
9762 idx(jj, ii) =
static_cast<double> (kk+1);
9770 octave::unwind_protect_var<bool> restore_var (updating_patch_data,
true);
9773 m_vertices.set (vert);
9774 m_facevertexcdata.set (fvc);
9784 double tol = 100 * std::numeric_limits<double>::epsilon ();
9785 EIG eig (cov,
false,
false,
true);
9787 return ev.
min () <= tol * ev.
max ();
9790std::vector<octave_idx_type>
9794 std::vector<octave_idx_type> coplanar_ends;
9798 plane_pivot(0, i) = vert(idx(0, jj)-1, i);
9816 fc(j-1, i) = vert(idx(j, jj)-1, i) - plane_pivot(i);
9821 coplanar_ends.push_back (nc - 1);
9822 return coplanar_ends;
9832 while (i_start < nc - 1)
9834 i_end = i_start + 2;
9837 coplanar_ends.push_back (nc - 1);
9849 fc(j, i) = vert(idx(j+i_start, jj)-1, i) - plane_pivot(i);
9866 fa(0, i) = vert(idx(i_end, jj)-1, i) - plane_pivot(i);
9870 i_start = i_end - 1;
9871 coplanar_ends.push_back (i_start);
9873 return coplanar_ends;
9877patch::properties::update_data ()
9879 if (updating_patch_data)
9883 Matrix vert = get_vertices ().matrix_value ();
9884 NDArray fvc = get_facevertexcdata ().array_value ();
9890 m_bad_data_msg =
"";
9891 if (
static_cast<double> (nvert) < idx.
row_max ().
max ())
9893 m_bad_data_msg = R
"(some vertices in "faces" property are undefined)";
9899 if (nfvc > 1 && nfvc != nfaces && nfvc != nvert)
9901 m_bad_data_msg =
"number of facevertexcdata values matches "
9902 "neither number of faces nor number of vertices";
9911 double valid_vert = idx(0, jj);
9912 bool turn_valid =
false;
9915 if (octave::math::isnan (idx(ii, jj)) || turn_valid)
9917 idx(ii, jj) = valid_vert;
9921 valid_vert = idx(ii, jj);
9927 int fcmax = idx.
rows ();
9928 if (fcmax > 3 && vert.
columns () > 2
9929 && ! (facecolor_is (
"none") && edgecolor_is (
"none")))
9931 m_coplanar_last_idx.resize (idx.
columns ());
9934 if (octave::math::isnan (idx(3, jj)))
9939 while (nc < fcmax && ! octave::math::isnan (idx(nc, jj)))
9944 bool is_unclosed =
false;
9948 if (! (octave::math::isfinite (vert(k, 0))
9949 && octave::math::isfinite (vert(k, 1))
9950 && octave::math::isfinite (vert(k, 2))))
9963 m_coplanar_last_idx.resize (0);
9968 bool pervertex =
false;
9970 if (fvc.
rows () == nfaces || fvc.
rows () == 1)
9974 dv(1) = fvc.
rows ();
9981 dv(0) = idx.
rows ();
9992 bool has_zd =
false;
10004 xd(ii, jj) = vert(row, 0);
10005 yd(ii, jj) = vert(row, 1);
10008 zd(ii, jj) = vert(row, 2);
10011 for (
int kk = 0; kk < fvc.
columns (); kk++)
10012 cd(ii, jj, kk) = fvc(row, kk);
10017 update_normals (
true);
10019 octave::unwind_protect_var<bool> restore_var (updating_patch_data,
true);
10029 double x2,
double y2,
double z2,
10030 double&
x,
double& y,
double& z)
10032 x += (y1 * z2 - z1 * y2);
10033 y += (z1 * x2 - x1 * z2);
10034 z += (x1 * y2 - y1 * x2);
10038patch::properties::calc_face_normals (
Matrix& fn)
10040 Matrix v = get_vertices ().matrix_value ();
10041 Matrix f = get_faces ().matrix_value ();
10043 bool is_3D = (v.
columns () == 3);
10060 if (m_coplanar_last_idx.size () > 0 && m_coplanar_last_idx[i].size () > 1)
10067 while (nc < max_nc && ! octave::math::isnan (
f(i, nc)))
10072 double& nx = fnc(0);
10073 double& ny = fnc(1);
10074 double& nz = fnc(2);
10079 i1 =
f(i, 0) - 1; i2 =
f(i, 1) - 1; i3 =
f(i, nc-1) - 1;
10083 (v(i3, 0) - v(i1, 0), v(i3, 1) - v(i1, 1), v(i3, 2) - v(i1, 2),
10084 v(i2, 0) - v(i1, 0), v(i2, 1) - v(i1, 1), v(i2, 2) - v(i1, 2),
10088 nz = (v(i2, 0) - v(i1, 0)) * (v(i3, 1) - v(i1, 1)) -
10089 (v(i2, 1) - v(i1, 1)) * (v(i3, 0) - v(i1, 0));
10091 nz = (nz < 0) ? -nz : nz;
10101 j1 = nc - 1; j2 = 0;
10102 i1 =
f(i, j1) - 1; i2 =
f(i, j2) - 1;
10104 nx = (v(i2, 1) - v(i1, 1)) * (v(i1, 2) + v(i2, 2));
10105 ny = (v(i2, 2) - v(i1, 2)) * (v(i1, 0) + v(i2, 0));
10106 nz = (v(i2, 0) - v(i1, 0)) * (v(i1, 1) + v(i2, 1));
10111 i1 =
f(i, j1) - 1; i2 =
f(i, j2) - 1;
10113 nx += (v(i2, 1) - v(i1, 1)) * (v(i1, 2) + v(i2, 2));
10114 ny += (v(i2, 2) - v(i1, 2)) * (v(i1, 0) + v(i2, 0));
10115 nz += (v(i2, 0) - v(i1, 0)) * (v(i1, 1) + v(i2, 1));
10120 double n_len = sqrt (nx*nx+ny*ny+nz*nz);
10123 if ( n_len < std::numeric_limits<double>::epsilon () )
10128 fn(i, j) = fnc(j) / n_len;
10133patch::properties::update_face_normals (
bool reset,
bool force)
10135 if (updating_patch_data || ! facenormalsmode_is (
"auto"))
10138 if (force || ((facelighting_is (
"flat") || edgelighting_is (
"flat"))
10139 && get_do_lighting ()))
10141 Matrix f = get_faces ().matrix_value ();
10144 Matrix fn (num_f, 3, 0.0);
10146 calc_face_normals (fn);
10147 m_facenormals = fn;
10150 m_facenormals =
Matrix ();
10154patch::properties::update_vertex_normals (
bool reset,
bool force)
10156 if (updating_patch_data || ! vertexnormalsmode_is (
"auto"))
10159 if (force || ((facelighting_is (
"gouraud") || facelighting_is (
"phong")
10160 || edgelighting_is (
"gouraud") || edgelighting_is (
"phong"))
10161 && get_do_lighting ()))
10163 Matrix v = get_vertices ().matrix_value ();
10164 Matrix f = get_faces ().matrix_value ();
10175 Matrix fn = get_facenormals ().matrix_value ();
10179 fn =
Matrix (num_f, 3, 0.0);
10180 calc_face_normals (fn);
10192 std::vector<std::vector<RowVector>> vec_vn (num_v);
10199 while (nc < max_nc && ! octave::math::isnan (
f(i, nc)))
10209 Matrix vn (num_v, 3, 0.0);
10212 std::vector<RowVector>::iterator it = vec_vn[i].begin ();
10217 if (it != vec_vn[i].end ())
10228 for (++it; it != vec_vn[i].end (); ++it)
10233 double dir = (vn0(0)*vn1(0) + vn0(1)*vn1(1) + vn0(2)*vn1(2) < 0) ? -1 : 1;
10235 vn0(j) += dir * vn1(j);
10239 double n_len = sqrt (vn0(0)*vn0(0)+vn0(1)*vn0(1)+vn0(2)*vn0(2));
10243 vn(i, j) = vn0(j)/n_len;
10247 m_vertexnormals = vn;
10250 m_vertexnormals =
Matrix ();
10254patch::initialize (
const graphics_object& go)
10256 base_graphics_object::initialize (go);
10261 m_properties.update_normals (
true);
10266patch::reset_default_properties ()
10269 m_default_properties = property_list ();
10270 xreset_default_properties (get_handle (), m_properties.factory_defaults ());
10275 m_properties.update_normals (
true);
10281scatter::properties::get_color_data ()
const
10287 return convert_cdata (*
this, c, c.
columns () == 1, 2);
10291scatter::properties::update_data ()
10293 Matrix xd = get_xdata ().matrix_value ();
10294 Matrix yd = get_ydata ().matrix_value ();
10295 Matrix zd = get_zdata ().matrix_value ();
10296 Matrix cd = get_cdata ().matrix_value ();
10297 Matrix sd = get_sizedata ().matrix_value ();
10299 m_bad_data_msg =
"";
10303 m_bad_data_msg =
"x/y/zdata must have the same dimensions";
10311 if (! cd.
isempty () && (c_rows != 1 || c_cols != 3)
10312 && (c_rows != x_rows || (c_cols != 1 && c_cols != 3)))
10314 m_bad_data_msg =
"cdata must be an rgb triplet or have the same number "
10315 "of rows as X and one or three columns";
10320 if (s_rows != 1 && s_rows != x_rows)
10322 m_bad_data_msg =
"sizedata must be a scalar or a vector with the same "
10328static bool updating_scatter_cdata =
false;
10331scatter::properties::update_color ()
10333 if (updating_scatter_cdata)
10336 Matrix series_idx = get_seriesindex ().matrix_value ();
10340 gh_manager& gh_mgr = octave::__get_gh_manager__ ();
10342 graphics_object go = gh_mgr.
get_object (get___myhandle__ ());
10344 axes::properties& parent_axes_prop
10345 =
dynamic_cast<axes::properties&
>
10346 (go.get_ancestor (
"axes").get_properties ());
10348 Matrix color_order = parent_axes_prop.get_colororder ().matrix_value ();
10350 % color_order.
rows ();
10353 color(0) = color_order(s, 0);
10354 color(1) = color_order(s, 1);
10355 color(2) = color_order(s, 2);
10357 octave::unwind_protect_var<bool> restore_var (updating_scatter_cdata,
true);
10360 set_cdatamode (
"auto");
10364scatter::initialize (
const graphics_object& go)
10366 base_graphics_object::initialize (go);
10368 Matrix series_idx = m_properties.get_seriesindex ().matrix_value ();
10372 axes::properties& parent_axes_prop
10373 =
dynamic_cast<axes::properties&
>
10374 (go.get_ancestor (
"axes").get_properties ());
10376 if (! parent_axes_prop.nextplot_is (
"add"))
10377 parent_axes_prop.set_nextseriesindex (1);
10379 series_idx.
resize (1, 1);
10380 series_idx(0) = parent_axes_prop.get_nextseriesindex ();
10381 m_properties.set_seriesindex (series_idx);
10383 parent_axes_prop.set_nextseriesindex
10384 (parent_axes_prop.get_nextseriesindex () + 1);
10387 if (m_properties.cdatamode_is (
"auto"))
10388 m_properties.update_color ();
10394surface::properties::get_color_data ()
const
10396 return convert_cdata (*
this, get_cdata (), cdatamapping_is (
"scaled"), 3);
10400surface::properties::get_do_lighting ()
const
10402 gh_manager& gh_mgr = octave::__get_gh_manager__ ();
10404 graphics_object go = gh_mgr.
get_object (get___myhandle__ ());
10406 axes::properties& ax_prop =
dynamic_cast<axes::properties&
>
10407 (go.get_ancestor (
"axes").get_properties ());
10409 return (ax_prop.get_num_lights () > 0);
10413surface::properties::update_face_normals (
bool reset,
bool force)
10415 if (! facenormalsmode_is (
"auto"))
10418 if (force || ((facelighting_is (
"flat") || edgelighting_is (
"flat"))
10419 && get_do_lighting ()))
10421 Matrix x = get_xdata ().matrix_value ();
10422 Matrix y = get_ydata ().matrix_value ();
10423 Matrix z = get_zdata ().matrix_value ();
10434 if (
x.columns () != p || y.
rows () != q)
10437 bool x_mat = (
x.rows () == q);
10438 bool y_mat = (y.
columns () == p);
10442 int i1, i2, j1, j2;
10445 double x0, x1, x2, x3, y0, y1, y2, y3, z0, z1, z2, z3;
10446 double x1m0, x2m1, x3m2, x0m3, y1m0, y2m1, y3m2, y0m3;
10447 double x1p0, x2p1, x3p2, x0p3, y1p0, y2p1, y3p2, y0p3;
10449 x2m1 = x0m3 = y1m0 = y3m2 = 0;
10452 x1p0 = x3p2 = y2p1 = y0p3 = 1;
10455 for (
int i = 0; i < p-1; i++)
10460 for (
int j = 0; j < q-1; j++)
10465 if (x_mat || y_mat)
10467 x0 =
x(x_mat?j1:0, y_mat?i1:0);
10468 x1 =
x(x_mat?j1:0, y_mat?i2:0);
10469 x2 =
x(x_mat?j2:0, y_mat?i2:0);
10470 x3 =
x(x_mat?j2:0, y_mat?i1:0);
10479 y0 = y(x_mat?j1:0, y_mat?i1:0);
10480 y1 = y(x_mat?j1:0, y_mat?i2:0);
10481 y2 = y(x_mat?j2:0, y_mat?i2:0);
10482 y3 = y(x_mat?j2:0, y_mat?i1:0);
10493 double& nx = n(j, i, 0);
10494 double& ny = n(j, i, 1);
10495 double& nz = n(j, i, 2);
10505 nx = y1m0 * (z1 + z0) + y2m1 * (z2 + z1)
10506 + y3m2 * (z3 + z2) + y0m3 * (z0 + z3);
10507 ny = (z1 - z0) * x1p0 + (z2 - z1) * x2p1
10508 + (z3 - z2) * x3p2 + (z0 - z3) * x0p3;
10509 nz = x1m0 * y1p0 + x2m1 * y2p1 + x3m2 * y3p2 + x0m3 * y0p3;
10511 double d = std::max (std::max (fabs (nx), fabs (ny)), fabs (nz));
10521 m_facenormals =
Matrix ();
10525surface::properties::update_vertex_normals (
bool reset,
bool force)
10527 if (! vertexnormalsmode_is (
"auto"))
10530 if (force || ((facelighting_is (
"gouraud") || facelighting_is (
"phong")
10531 || edgelighting_is (
"gouraud") || edgelighting_is (
"phong"))
10532 && get_do_lighting ()))
10534 Matrix x = get_xdata ().matrix_value ();
10535 Matrix y = get_ydata ().matrix_value ();
10536 Matrix z = get_zdata ().matrix_value ();
10547 if (
x.columns () != p || y.
rows () != q)
10552 bool x_mat = (
x.rows () == q);
10553 bool y_mat = (y.
columns () == p);
10555 int i1, i2, i3, j1, j2, j3;
10559 for (
int i = 0; i < p; i++)
10568 for (
int j = 0; j < q; j++)
10577 double& nx = n(j, i, 0);
10578 double& ny = n(j, i, 1);
10579 double& nz = n(j, i, 2);
10581 if ((j > 0) && (i > 0))
10584 (
x(j1, i-1)-
x(j2, i), y(j-1, i1)-y(j, i2), z(j-1, i-1)-z(j, i),
10585 x(j2, i-1)-
x(j1, i), y(j, i1)-y(j-1, i2), z(j, i-1)-z(j-1, i),
10588 if ((j > 0) && (i < (p -1)))
10591 (
x(j1, i+1)-
x(j2, i), y(j-1, i3)-y(j, i2), z(j-1, i+1)-z(j, i),
10592 x(j1, i)-
x(j2, i+1), y(j-1, i2)-y(j, i3), z(j-1, i)-z(j, i+1),
10595 if ((j < (q - 1)) && (i > 0))
10598 (
x(j2, i-1)-
x(j3, i), y(j, i1)-y(j+1, i2), z(j, i-1)-z(j+1, i),
10599 x(j3, i-1)-
x(j2, i), y(j+1, i1)-y(j, i2), z(j+1, i-1)-z(j, i),
10602 if ((j < (q - 1)) && (i < (p -1)))
10605 (
x(j3, i)-
x(j2, i+1), y(j+1, i2)-y(j, i3), z(j+1, i)-z(j, i+1),
10606 x(j3, i+1)-
x(j2, i), y(j+1, i3)-y(j, i2), z(j+1, i+1)-z(j, i),
10609 double d = -std::max (std::max (fabs (nx), fabs (ny)), fabs (nz));
10616 m_vertexnormals = n;
10619 m_vertexnormals =
Matrix ();
10622DEFMETHOD (__update_normals__, interp, args, ,
10630 gh_manager& gh_mgr = interp.get_gh_manager ();
10634 if (args.
length () != 1)
10639 graphics_object go = gh_mgr.
get_object (val);
10641 if (go.isa (
"surface"))
10643 surface::properties& props
10644 =
dynamic_cast <surface::properties&
> (go.get_properties ());
10645 props.update_normals (
false,
true);
10647 else if (go.isa (
"patch"))
10649 patch::properties& props
10650 =
dynamic_cast <patch::properties&
> (go.get_properties ());
10651 props.update_normals (
false,
true);
10654 error (
"__update_normals__: "
10655 "H must be a handle to a valid surface or patch object.");
10692hggroup::properties::remove_child (
const graphics_handle& h,
bool from_root)
10694 gh_manager& gh_mgr = octave::__get_gh_manager__ ();
10698 if (! from_root && go.isa (
"light") && go.get_properties ().is_visible ())
10700 axes::properties& ax_props
10701 =
dynamic_cast<axes::properties&
> (go.get_ancestor (
"axes").get_properties ());
10702 ax_props.decrease_num_lights ();
10704 base_properties::remove_child (h, from_root);
10711 gh_manager& gh_mgr = octave::__get_gh_manager__ ();
10715 if (go.isa (
"light") && go.get_properties ().is_visible ())
10717 axes::properties& ax_props
10718 =
dynamic_cast<axes::properties&
> (go.get_ancestor (
"axes").get_properties ());
10719 ax_props.increase_num_lights ();
10721 base_properties::adopt (h);
10726hggroup::properties::update_limits ()
const
10728 gh_manager& gh_mgr = octave::__get_gh_manager__ ();
10730 graphics_object go = gh_mgr.
get_object (m___myhandle__);
10734 go.update_axis_limits (
"xlim");
10735 go.update_axis_limits (
"ylim");
10736 go.update_axis_limits (
"zlim");
10737 go.update_axis_limits (
"clim");
10738 go.update_axis_limits (
"alim");
10745 gh_manager& gh_mgr = octave::__get_gh_manager__ ();
10747 graphics_object go = gh_mgr.
get_object (m___myhandle__);
10751 go.update_axis_limits (
"xlim", h);
10752 go.update_axis_limits (
"ylim", h);
10753 go.update_axis_limits (
"zlim", h);
10754 go.update_axis_limits (
"clim", h);
10755 go.update_axis_limits (
"alim", h);
10759static bool updating_hggroup_limits =
false;
10762hggroup::update_axis_limits (
const std::string& axis_type,
10765 if (updating_hggroup_limits)
10770 double min_val = octave::numeric_limits<double>::Inf ();
10771 double max_val = -octave::numeric_limits<double>::Inf ();
10772 double min_pos = octave::numeric_limits<double>::Inf ();
10773 double max_neg = -octave::numeric_limits<double>::Inf ();
10778 char update_type = 0;
10780 if (axis_type ==
"xlim" || axis_type ==
"xliminclude")
10782 limits = m_properties.get_xlim ().matrix_value ();
10785 else if (axis_type ==
"ylim" || axis_type ==
"yliminclude")
10787 limits = m_properties.get_ylim ().matrix_value ();
10790 else if (axis_type ==
"zlim" || axis_type ==
"zliminclude")
10792 limits = m_properties.get_zlim ().matrix_value ();
10795 else if (axis_type ==
"clim" || axis_type ==
"climinclude")
10797 limits = m_properties.get_clim ().matrix_value ();
10800 else if (axis_type ==
"alim" || axis_type ==
"aliminclude")
10802 limits = m_properties.get_alim ().matrix_value ();
10806 if (limits.
numel () == 4)
10809 if (octave::math::isfinite (val))
10812 if (octave::math::isfinite (val))
10815 if (octave::math::isfinite (val))
10818 if (octave::math::isfinite (val))
10824 limits(0) = min_val;
10825 limits(1) = max_val;
10826 limits(2) = min_pos;
10827 limits(3) = max_neg;
10832 octave::unwind_protect_var<bool> restore_var (updating_hggroup_limits,
true);
10834 if (limits(0) != min_val || limits(1) != max_val
10835 || limits(2) != min_pos || limits(3) != max_neg)
10837 limits(0) = min_val;
10838 limits(1) = max_val;
10839 limits(2) = min_pos;
10840 limits(3) = max_neg;
10842 switch (update_type)
10845 m_properties.set_xlim (limits);
10849 m_properties.set_ylim (limits);
10853 m_properties.set_zlim (limits);
10857 m_properties.set_clim (limits);
10861 m_properties.set_alim (limits);
10869 base_graphics_object::update_axis_limits (axis_type, hg);
10874hggroup::update_axis_limits (
const std::string& axis_type)
10876 if (updating_hggroup_limits)
10879 Matrix kids = m_properties.get_children ();
10881 double min_val = octave::numeric_limits<double>::Inf ();
10882 double max_val = -octave::numeric_limits<double>::Inf ();
10883 double min_pos = octave::numeric_limits<double>::Inf ();
10884 double max_neg = -octave::numeric_limits<double>::Inf ();
10886 char update_type = 0;
10888 if (axis_type ==
"xlim" || axis_type ==
"xliminclude")
10894 else if (axis_type ==
"ylim" || axis_type ==
"yliminclude")
10900 else if (axis_type ==
"zlim" || axis_type ==
"zliminclude")
10906 else if (axis_type ==
"clim" || axis_type ==
"climinclude")
10912 else if (axis_type ==
"alim" || axis_type ==
"aliminclude")
10919 octave::unwind_protect_var<bool> restore_var (updating_hggroup_limits,
true);
10923 limits(0) = min_val;
10924 limits(1) = max_val;
10925 limits(2) = min_pos;
10926 limits(3) = max_neg;
10928 switch (update_type)
10931 m_properties.set_xlim (limits);
10935 m_properties.set_ylim (limits);
10939 m_properties.set_zlim (limits);
10943 m_properties.set_clim (limits);
10947 m_properties.set_alim (limits);
10954 base_graphics_object::update_axis_limits (axis_type);
10960uicontextmenu::properties::update_beingdeleted ()
10963 if (m_beingdeleted.is (
"on"))
10965 gh_manager& gh_mgr = octave::__get_gh_manager__ ();
10967 std::list<graphics_handle> lst = get_dependent_obj_list ();
10969 for (
auto& hobj : lst)
10971 graphics_object go = gh_mgr.
get_object (hobj);
10973 if (go.valid_object ()
10974 && go.get (
"contextmenu") == get___myhandle__ ())
10975 go.set (
"contextmenu",
Matrix ());
11010uicontrol::properties::get_extent ()
const
11012 Matrix m = m_extent.get ().matrix_value ();
11014 gh_manager& gh_mgr = octave::__get_gh_manager__ ();
11016 graphics_object parent_go = gh_mgr.
get_object (get_parent ());
11018 Matrix parent_bbox = parent_go.get_properties ().get_boundingbox (
true);
11021 return convert_position (m,
"pixels", get_units (), parent_size);
11025uicontrol::properties::update_text_extent ()
11029 gh_manager& gh_mgr = octave::__get_gh_manager__ ();
11031 graphics_object go = gh_mgr.
get_object (get___myhandle__ ());
11033 set_extent (go.get_toolkit ().get_text_extent (go));
11037uicontrol::properties::update_units ()
11039 Matrix pos = get_position ().matrix_value ();
11041 gh_manager& gh_mgr = octave::__get_gh_manager__ ();
11043 graphics_object parent_go = gh_mgr.
get_object (get_parent ());
11045 Matrix parent_bbox = parent_go.get_properties ().get_boundingbox (
true);
11048 pos = convert_position (pos, m_cached_units, get_units (), parent_size);
11049 set_position (pos);
11051 m_cached_units = get_units ();
11055uicontrol::properties::set_style (
const octave_value& st)
11057 gh_manager& gh_mgr = octave::__get_gh_manager__ ();
11059 graphics_object go_parent = gh_mgr.
get_object (get_parent ());
11060 if (go_parent.valid_object () && go_parent.isa (
"uibuttongroup"))
11062 bool was_button = style_is (
"radiobutton") || style_is (
"togglebutton");
11064 bool now_button = style_is (
"radiobutton") || style_is (
"togglebutton");
11065 uibuttongroup::properties& props =
11066 dynamic_cast<uibuttongroup::properties&
> (go_parent.get_properties ());
11068 if (! was_button && now_button && ! props.get_selectedobject ().ok ())
11070 props.set_selectedobject (get___myhandle__ ().value ());
11073 else if (was_button && ! now_button
11074 && (props.get_selectedobject ().value ()
11075 == get___myhandle__ ().value ()))
11076 props.set_selectedobject (
Matrix ());
11080 bool modified = m_style.set (st,
true,
false);
11085 if (style_is (
"listbox") || style_is (
"popupmenu"))
11087 Matrix v = m_value.get ().matrix_value ();
11088 if (v.
numel () == 1 && v(0) == 0)
11094 graphics_object go = gh_mgr.
get_object (get___myhandle__ ());
11097 go.update (m_style.get_id ());
11102uicontrol::properties::get_boundingbox (
bool,
11103 const Matrix& parent_pix_size)
const
11105 Matrix pos = get_position ().matrix_value ();
11106 Matrix parent_size (parent_pix_size);
11110 gh_manager& gh_mgr = octave::__get_gh_manager__ ();
11112 graphics_object go = gh_mgr.
get_object (get_parent ());
11114 if (go.valid_object ())
11115 parent_size = go.get_properties ().get_boundingbox (
true).
extract_n (0, 2, 1, 2);
11117 parent_size = default_figure_position ();
11120 pos = convert_position (pos, get_units (),
"pixels", parent_size);
11124 pos(1) = parent_size(1) - pos(1) - pos(3);
11130uicontrol::properties::set_fontunits (
const octave_value& val)
11134 if (m_fontunits.set (val,
true))
11136 update_fontunits (old_fontunits);
11142uicontrol::properties::update_fontunits (
const caseless_str& old_units)
11145 double parent_height = get_boundingbox (
false).elem (3);
11146 double fontsz = get_fontsize ();
11148 fontsz = convert_font_size (fontsz, old_units, new_units, parent_height);
11154uicontrol::properties::get___fontsize_points__ (
double box_pix_height)
const
11156 double fontsz = get_fontsize ();
11157 double parent_height = box_pix_height;
11159 if (fontunits_is (
"normalized") && parent_height <= 0)
11160 parent_height = get_boundingbox (
false).elem (3);
11162 return convert_font_size (fontsz, get_fontunits (),
"points", parent_height);
11168uibuttongroup::properties::get_boundingbox (
bool internal,
11169 const Matrix& parent_pix_size)
const
11171 Matrix pos = get_position ().matrix_value ();
11172 Matrix parent_size (parent_pix_size);
11176 gh_manager& gh_mgr = octave::__get_gh_manager__ ();
11178 graphics_object go = gh_mgr.
get_object (get_parent ());
11180 parent_size = go.get_properties ().get_boundingbox (
true).
extract_n (0, 2, 1, 2);
11183 pos = convert_position (pos, get_units (),
"pixels", parent_size);
11187 pos(1) = parent_size(1) - pos(1) - pos(3);
11191 double outer_height = pos(3);
11193 pos(0) = pos(1) = 0;
11195 if (! bordertype_is (
"none"))
11197 double bw = get_borderwidth ();
11200 if (bordertype_is (
"etchedin") || bordertype_is (
"etchedout"))
11203 pos(0) += mul * bw;
11204 pos(1) += mul * bw;
11205 pos(2) -= 2 * mul * bw;
11206 pos(3) -= 2 * mul * bw;
11209 if (! get_title ().empty ())
11211 double fontsz = get_fontsize ();
11213 if (! fontunits_is (
"pixels"))
11217 if (fontunits_is (
"points"))
11218 fontsz *= (res / 72.0);
11219 else if (fontunits_is (
"inches"))
11221 else if (fontunits_is (
"centimeters"))
11222 fontsz *= (res / 2.54);
11223 else if (fontunits_is (
"normalized"))
11224 fontsz *= outer_height;
11227 if (titleposition_is (
"lefttop") || titleposition_is (
"centertop")
11228 || titleposition_is (
"righttop"))
11229 pos(1) += (fontsz / 2);
11230 pos(3) -= (fontsz / 2);
11238uibuttongroup::properties::set_position (
const octave_value& v)
11241 bool modified =
false;
11243 old_bb = get_boundingbox (
true);
11244 modified = m_position.set (v,
false);
11245 new_bb = get_boundingbox (
true);
11247 if (old_bb != new_bb)
11249 if (old_bb(2) != new_bb(2) || old_bb(3) != new_bb(3))
11251 gh_manager& gh_mgr = octave::__get_gh_manager__ ();
11253 if (! get_resizefcn ().isempty ())
11256 if (! get_sizechangedfcn ().isempty ())
11259 update_boundingbox ();
11265 m_position.run_listeners (GCB_POSTSET);
11271uibuttongroup::properties::set_units (
const octave_value& val)
11275 if (m_units.set (val,
true))
11277 update_units (old_units);
11283uibuttongroup::properties::update_units (
const caseless_str& old_units)
11285 Matrix pos = get_position ().matrix_value ();
11287 gh_manager& gh_mgr = octave::__get_gh_manager__ ();
11289 graphics_object parent_go = gh_mgr.
get_object (get_parent ());
11291 Matrix parent_bbox = parent_go.get_properties ().get_boundingbox (
true);
11294 pos = convert_position (pos, old_units, get_units (), parent_size);
11295 set_position (pos);
11299uibuttongroup::properties::set_fontunits (
const octave_value& val)
11303 if (m_fontunits.set (val,
true))
11305 update_fontunits (old_fontunits);
11311uibuttongroup::properties::update_fontunits (
const caseless_str& old_units)
11314 double parent_height = get_boundingbox (
false).elem (3);
11315 double fontsz = get_fontsize ();
11317 fontsz = convert_font_size (fontsz, old_units, new_units, parent_height);
11323uibuttongroup::properties::get___fontsize_points__ (
double box_pix_height)
const
11325 double fontsz = get_fontsize ();
11326 double parent_height = box_pix_height;
11328 if (fontunits_is (
"normalized") && parent_height <= 0)
11329 parent_height = get_boundingbox (
false).elem (3);
11331 return convert_font_size (fontsz, get_fontunits (),
"points", parent_height);
11335uibuttongroup::properties::set_selectedobject (
const octave_value& v)
11338 m_selectedobject = current_selectedobject;
11341 if (current_selectedobject.
ok ())
11352 gh_manager& gh_mgr = octave::__get_gh_manager__ ();
11354 graphics_object go (gh_mgr.
get_object (val));
11356 base_properties& gop = go.get_properties ();
11358 if (go.valid_object ()
11359 && gop.get_parent () == get___myhandle__ ()
11360 && go.isa (
"uicontrol"))
11362 uicontrol::properties& cop
11363 =
dynamic_cast<uicontrol::properties&
> (go.get_properties ());
11365 if (style.
compare (
"radiobutton") || style.
compare (
"togglebutton"))
11367 m_selectedobject = val;
11373 err_set_invalid (
"selectedobject");
11381 if (h.
value () == current_selected.
value ())
11382 set_selectedobject (
Matrix ());
11384 base_properties::remove_child (h, from_root);
11390 base_properties::adopt (h);
11393 bool has_selected = current_selected.
ok ();
11395 gh_manager& gh_mgr = octave::__get_gh_manager__ ();
11399 if (! has_selected && go.valid_object () && go.isa (
"uicontrol"))
11401 const uicontrol::properties& props =
11402 dynamic_cast<const uicontrol::properties&
> (go.get_properties ());
11403 if (props.style_is (
"radiobutton") || props.style_is (
"togglebutton"))
11404 set_selectedobject (h.
value ());
11411uipanel::properties::get_boundingbox (
bool internal,
11412 const Matrix& parent_pix_size)
const
11414 Matrix pos = get_position ().matrix_value ();
11415 Matrix parent_size (parent_pix_size);
11419 gh_manager& gh_mgr = octave::__get_gh_manager__ ();
11421 graphics_object go = gh_mgr.
get_object (get_parent ());
11423 parent_size = go.get_properties ().get_boundingbox (
true).
extract_n (0, 2, 1, 2);
11426 pos = convert_position (pos, get_units (),
"pixels", parent_size);
11430 pos(1) = parent_size(1) - pos(1) - pos(3);
11434 double outer_height = pos(3);
11436 pos(0) = pos(1) = 0;
11438 if (! bordertype_is (
"none"))
11440 double bw = get_borderwidth ();
11443 if (bordertype_is (
"etchedin") || bordertype_is (
"etchedout"))
11446 pos(0) += mul * bw;
11447 pos(1) += mul * bw;
11448 pos(2) -= 2 * mul * bw;
11449 pos(3) -= 2 * mul * bw;
11452 if (! get_title ().empty ())
11454 double fontsz = get_fontsize ();
11456 if (! fontunits_is (
"pixels"))
11460 if (fontunits_is (
"points"))
11461 fontsz *= (res / 72.0);
11462 else if (fontunits_is (
"inches"))
11464 else if (fontunits_is (
"centimeters"))
11465 fontsz *= (res / 2.54);
11466 else if (fontunits_is (
"normalized"))
11467 fontsz *= outer_height;
11470 if (titleposition_is (
"lefttop") || titleposition_is (
"centertop")
11471 || titleposition_is (
"righttop"))
11472 pos(1) += (fontsz / 2);
11473 pos(3) -= (fontsz / 2);
11481uipanel::properties::set_position (
const octave_value& v)
11484 bool modified =
false;
11486 old_bb = get_boundingbox (
true);
11487 modified = m_position.set (v,
false);
11488 new_bb = get_boundingbox (
true);
11490 if (old_bb != new_bb)
11492 if (old_bb(2) != new_bb(2) || old_bb(3) != new_bb(3))
11494 gh_manager& gh_mgr = octave::__get_gh_manager__ ();
11496 if (! get_resizefcn ().isempty ())
11499 if (! get_sizechangedfcn ().isempty ())
11502 update_boundingbox ();
11508 m_position.run_listeners (GCB_POSTSET);
11515uipanel::properties::set_units (
const octave_value& val)
11519 if (m_units.set (val,
true))
11521 update_units (old_units);
11527uipanel::properties::update_units (
const caseless_str& old_units)
11529 Matrix pos = get_position ().matrix_value ();
11531 gh_manager& gh_mgr = octave::__get_gh_manager__ ();
11533 graphics_object parent_go = gh_mgr.
get_object (get_parent ());
11535 Matrix parent_bbox = parent_go.get_properties ().get_boundingbox (
true);
11538 pos = convert_position (pos, old_units, get_units (), parent_size);
11539 set_position (pos);
11543uipanel::properties::set_fontunits (
const octave_value& val)
11547 if (m_fontunits.set (val,
true))
11549 update_fontunits (old_fontunits);
11555uipanel::properties::update_fontunits (
const caseless_str& old_units)
11558 double parent_height = get_boundingbox (
false).elem (3);
11559 double fontsz = get_fontsize ();
11561 fontsz = convert_font_size (fontsz, old_units, new_units, parent_height);
11567uipanel::properties::get___fontsize_points__ (
double box_pix_height)
const
11569 double fontsz = get_fontsize ();
11570 double parent_height = box_pix_height;
11572 if (fontunits_is (
"normalized") && parent_height <= 0)
11573 parent_height = get_boundingbox (
false).elem (3);
11575 return convert_font_size (fontsz, get_fontunits (),
"points", parent_height);
11581uitable::properties::get_boundingbox (
bool,
11582 const Matrix& parent_pix_size)
const
11584 Matrix pos = get_position ().matrix_value ();
11585 Matrix parent_size (parent_pix_size);
11589 gh_manager& gh_mgr = octave::__get_gh_manager__ ();
11591 graphics_object go = gh_mgr.
get_object (get_parent ());
11593 parent_size = go.get_properties ().get_boundingbox (
true).
extract_n (0, 2, 1, 2);
11596 pos = convert_position (pos, get_units (),
"pixels", parent_size);
11600 pos(1) = parent_size(1) - pos(1) - pos(3);
11606uitable::properties::set_columnformat (
const octave_value& val)
11613 if (m_columnformat.set (val,
true))
11620 for (
int i = 0; i < cell_value.
numel (); i++)
11628 for (
int j = 0; j < popup.
numel (); j++)
11632 error (
"set: pop-up menu definitions must be non-empty strings");
11637 error (
"set: columnformat definintions must be a cellstr of "
11638 "either 'char', 'short [e|g|eng]?', 'long [e|g|eng]?', "
11639 "'numeric', 'bank', '+', 'rat', 'logical', "
11640 "or a cellstr of non-empty pop-up menu definitions.");
11644 if (m_columnformat.set (val,
true))
11649 if (m_columnformat.set (
Cell (),
true))
11654 error (
"set: expecting cell of strings");
11659uitable::properties::set_columnwidth (
const octave_value& val)
11661 bool error_exists =
false;
11664 error_exists =
false;
11668 for (
int i = 0; i < cell_value.
numel (); i++)
11674 error_exists =
true;
11678 error_exists =
true;
11682 error_exists =
true;
11687 error_exists =
true;
11690 error (
"set: expecting either 'auto' or a cell of pixel values or auto");
11693 if (m_columnwidth.set (val,
true))
11699uitable::properties::set_units (
const octave_value& val)
11703 if (m_units.set (val,
true))
11705 update_units (old_units);
11711uitable::properties::update_units (
const caseless_str& old_units)
11713 Matrix pos = get_position ().matrix_value ();
11715 gh_manager& gh_mgr = octave::__get_gh_manager__ ();
11717 graphics_object parent_go = gh_mgr.
get_object (get_parent ());
11719 Matrix parent_bbox = parent_go.get_properties ().get_boundingbox (
true);
11722 pos = convert_position (pos, old_units, get_units (), parent_size);
11723 set_position (pos);
11727uitable::properties::set_fontunits (
const octave_value& val)
11731 if (m_fontunits.set (val,
true))
11733 update_fontunits (old_fontunits);
11739uitable::properties::update_fontunits (
const caseless_str& old_units)
11742 double parent_height = get_boundingbox (
false).elem (3);
11743 double fontsz = get_fontsize ();
11745 fontsz = convert_font_size (fontsz, old_units, new_units, parent_height);
11751uitable::properties::get___fontsize_points__ (
double box_pix_height)
const
11753 double fontsz = get_fontsize ();
11754 double parent_height = box_pix_height;
11756 if (fontunits_is (
"normalized") && parent_height <= 0)
11757 parent_height = get_boundingbox (
false).elem (3);
11759 return convert_font_size (fontsz, get_fontunits (),
"points", parent_height);
11763uitable::properties::get_fontsize_pixels (
double box_pix_height)
const
11765 double fontsz = get_fontsize ();
11766 double parent_height = box_pix_height;
11768 if (fontunits_is (
"normalized") && parent_height <= 0)
11769 parent_height = get_boundingbox (
false).elem (3);
11771 return convert_font_size (fontsz, get_fontunits (),
"pixels", parent_height);
11775uitable::properties::get_backgroundcolor_rgb ()
11777 Matrix bg = m_backgroundcolor.get ().matrix_value ();
11782uitable::properties::get_alternatebackgroundcolor_rgb ()
11785 Matrix bg = m_backgroundcolor.get ().matrix_value ();
11786 if (bg.
rows () > 1)
11793uitable::properties::get_extent_matrix ()
const
11795 return m_extent.get ().matrix_value ();
11799uitable::properties::get_extent ()
const
11802 Matrix m = m_extent.get ().matrix_value ();
11804 gh_manager& gh_mgr = octave::__get_gh_manager__ ();
11806 graphics_object parent_go = gh_mgr.
get_object (get_parent ());
11810 Matrix parent_bbox = parent_go.get_properties ().get_boundingbox (
true);
11813 return convert_position (m,
"pixels", get_units (), parent_size);
11822uitoolbar::get_default (
const caseless_str& pname)
const
11830 gh_manager& gh_mgr = octave::__get_gh_manager__ ();
11832 graphics_object parent_go = gh_mgr.
get_object (parent_h);
11834 retval = parent_go.get_default (pname);
11841uitoolbar::reset_default_properties ()
11844 m_default_properties = property_list ();
11846 remove_all_listeners ();
11847 xreset_default_properties (get_handle (), m_properties.factory_defaults ());
11853base_graphics_object::get_default (
const caseless_str& pname)
const
11857 gh_manager& gh_mgr = octave::__get_gh_manager__ ();
11859 graphics_object parent_go = gh_mgr.
get_object (parent_h);
11861 return parent_go.get_default (type () + pname);
11865base_graphics_object::get_factory_default (
const caseless_str& name)
const
11867 gh_manager& gh_mgr = octave::__get_gh_manager__ ();
11869 graphics_object parent_go = gh_mgr.
get_object (0);
11871 return parent_go.get_factory_default (type () + name);
11874class callback_event :
public base_graphics_event
11879 int busyaction = base_graphics_event::QUEUE)
11880 : base_graphics_event (busyaction), m_handle (h), m_callback_name (name),
11881 m_callback (), m_callback_data (data) { }
11885 int busyaction = base_graphics_event::QUEUE)
11886 : base_graphics_event (busyaction), m_handle (h), m_callback_name (),
11887 m_callback (cb), m_callback_data (data) { }
11889 OCTAVE_DISABLE_CONSTRUCT_COPY_MOVE (callback_event)
11891 ~callback_event () =
default;
11895 gh_manager& gh_mgr = octave::__get_gh_manager__ ();
11897 if (m_callback.is_defined ())
11905 std::string m_callback_name;
11910class mcode_event :
public base_graphics_event
11914 int busyaction = base_graphics_event::QUEUE)
11915 : base_graphics_event (busyaction), m_handle (h), m_mcode (cmd)
11918 OCTAVE_DISABLE_CONSTRUCT_COPY_MOVE (mcode_event)
11920 ~mcode_event () =
default;
11924 if (! m_mcode.empty ())
11926 gh_manager& gh_mgr = octave::__get_gh_manager__ ();
11928 graphics_object go = gh_mgr.
get_object (m_handle);
11930 if (go.valid_object ())
11940 std::string m_mcode;
11943class function_event :
public base_graphics_event
11947 function_event (graphics_event::event_fcn fcn,
void *data =
nullptr)
11948 : base_graphics_event (), m_function (fcn), m_function_data (data)
11951 OCTAVE_DISABLE_CONSTRUCT_COPY_MOVE (function_event)
11953 ~function_event () =
default;
11957 m_function (m_function_data);
11962 graphics_event::event_fcn m_function;
11964 void *m_function_data;
11967class set_event :
public base_graphics_event
11971 const octave_value& value,
bool do_notify_toolkit =
true,
11972 bool redraw_figure =
false)
11973 : base_graphics_event (), m_handle (h), m_property_name (name),
11974 m_property_value (value), m_notify_toolkit (do_notify_toolkit),
11975 m_redraw_figure (redraw_figure)
11978 OCTAVE_DISABLE_CONSTRUCT_COPY_MOVE (set_event)
11980 ~set_event () =
default;
11984 gh_manager& gh_mgr = octave::__get_gh_manager__ ();
11988 graphics_object go = gh_mgr.
get_object (m_handle);
11992 property p = go.get_properties ().get_property (m_property_name);
12002 if (go.isa (
"figure") && m_property_name ==
"position")
12004 figure::properties& fprops
12005 =
dynamic_cast<figure::properties&
> (go.get_properties ());
12006 fprops.set_position (m_property_value, m_notify_toolkit);
12008 else if (go.isa (
"figure") && m_property_name ==
"outerposition")
12010 figure::properties& fprops
12011 =
dynamic_cast<figure::properties&
> (go.get_properties ());
12012 fprops.set_outerposition (m_property_value, m_notify_toolkit);
12015 p.set (m_property_value,
true, m_notify_toolkit);
12017 if (m_redraw_figure)
12019 if (! go.isa (
"figure"))
12020 go = go.get_ancestor (
"figure");
12022 if (go.valid_object ())
12024 figure::properties& fprops
12025 =
dynamic_cast<figure::properties&
> (go.get_properties ());
12026 fprops.get_toolkit ().redraw_figure (go);
12035 std::string m_property_name;
12037 bool m_notify_toolkit;
12038 bool m_redraw_figure;
12043 const std::string& name,
12047 return graphics_event (
new callback_event (h, name, data, busyaction));
12056 return graphics_event (
new callback_event (h, cb, data, busyaction));
12061 const std::string& cmd,
12064 return graphics_event (
new mcode_event (h, cmd, busyaction));
12068graphics_event::create_function_event (graphics_event::event_fcn fcn,
12071 return graphics_event (
new function_event (fcn, data));
12076 const std::string& name,
12078 bool notify_toolkit,
bool redraw_figure)
12080 return graphics_event (
new set_event (h, name, data, notify_toolkit,
12084property_list::plist_map_type
12085root_figure::init_factory_properties ()
12087 property_list::plist_map_type plist_map;
12089 plist_map[
"figure"] = figure::properties::factory_defaults ();
12090 plist_map[
"axes"] = axes::properties::factory_defaults ();
12091 plist_map[
"line"] = line::properties::factory_defaults ();
12092 plist_map[
"text"] = text::properties::factory_defaults ();
12093 plist_map[
"image"] = image::properties::factory_defaults ();
12094 plist_map[
"patch"] = patch::properties::factory_defaults ();
12095 plist_map[
"scatter"] = scatter::properties::factory_defaults ();
12096 plist_map[
"surface"] = surface::properties::factory_defaults ();
12097 plist_map[
"light"] = light::properties::factory_defaults ();
12098 plist_map[
"hggroup"] = hggroup::properties::factory_defaults ();
12099 plist_map[
"uimenu"] = uimenu::properties::factory_defaults ();
12100 plist_map[
"uicontrol"] = uicontrol::properties::factory_defaults ();
12101 plist_map[
"uibuttongroup"] = uibuttongroup::properties::factory_defaults ();
12102 plist_map[
"uipanel"] = uipanel::properties::factory_defaults ();
12103 plist_map[
"uicontextmenu"] = uicontextmenu::properties::factory_defaults ();
12104 plist_map[
"uitoolbar"] = uitoolbar::properties::factory_defaults ();
12105 plist_map[
"uipushtool"] = uipushtool::properties::factory_defaults ();
12106 plist_map[
"uitoggletool"] = uitoggletool::properties::factory_defaults ();
12124 gh_manager& gh_mgr = interp.get_gh_manager ();
12128 if (args.
length () != 1)
12131 return ovl (ishghandle (args(0)));
12156 gh_manager& gh_mgr = octave::__get_gh_manager__ ();
12162is_handle_visible (
double val)
12164 gh_manager& gh_mgr = octave::__get_gh_manager__ ();
12166 return is_handle_visible (gh_mgr.
lookup (val));
12183 result.xelem (i) = is_handle_visible (handles(i));
12191DEFUN (__is_handle_visible__, args, ,
12197 if (args.
length () != 1)
12200 return ovl (is_handle_visible (args(0)));
12218 if (args.
length () != 1)
12222 ColumnVector hcv = args(0).xvector_value (
"reset: H must be a graphics handle");
12224 gh_manager& gh_mgr = interp.get_gh_manager ();
12228 gh_mgr.
get_object (hcv(n)).reset_default_properties ();
12458 int nargin = args.
length ();
12464 ColumnVector hcv = args(0).xvector_value (
"set: H must be a graphics handle");
12466 gh_manager& gh_mgr = interp.get_gh_manager ();
12475 if (hcv.
numel () > 1)
12476 error (
"set: H must be a single graphics handle when querying properties");
12478 graphics_object go = gh_mgr.
get_object (hcv(0));
12480 error (
"set: invalid handle (= %g)", hcv(0));
12483 retval = go.values_as_struct ();
12486 std::string s = go.values_as_string ();
12493 else if (nargin == 2 && args(1).is_string ())
12495 if (hcv.
numel () > 1)
12496 error (
"set: H must be a single graphics handle when querying properties");
12498 std::string
property = args(1).string_value ();
12499 std::transform (property.begin (), property.end (),
12500 property.begin (), tolower);
12502 graphics_object go = gh_mgr.
get_object (hcv(0));
12505 error (
"set: invalid handle (= %g)", hcv(0));
12509 if (go.has_readonly_property (property))
12517 else if (pmap.
isfield (property))
12520 retval = pmap.
getfield (property)(0);
12523 std::string s = go.value_as_string (property);
12529 error (R
"(set: unknown property "%s")", property.c_str ());
12534 bool request_drawnow =
false;
12539 graphics_object go = gh_mgr.
get_object (hcv(n));
12542 error (
"set: invalid handle (= %g)", hcv(n));
12547 if (args(i).is_string ())
12549 if (i == nargin - 1)
12550 error (
"set: PROPERTY name must be followed by a VALUE");
12553 go.set_value_or_default (pname, val);
12556 else if (args(i).iscellstr ())
12558 if ((i == nargin - 1) || ! args(i+1).iscell ())
12559 error (
"set: cell array of PROPERTIES must be followed by cell array of VALUES");
12560 if (args(i+1).cell_value ().rows () == 1)
12561 go.set (args(i).cellstr_value (), args(i+1).cell_value (), 0);
12562 else if (hcv.
numel () == args(i+1).cell_value ().rows ())
12563 go.set (args(i).cellstr_value (), args(i+1).cell_value (), n);
12565 error (
"set: number of graphics handles must match number of "
12566 "value rows (%" OCTAVE_IDX_TYPE_FORMAT
" != "
12567 "%" OCTAVE_IDX_TYPE_FORMAT
")",
12568 hcv.
numel (), args(i+1).cell_value ().rows ());
12571 else if (args(i).isstruct ())
12573 go.set (args(i).map_value ());
12577 error (
"set: invalid syntax");
12580 request_drawnow =
true;
12583 if (request_drawnow)
12625get_graphics_object_type (
double val)
12627 std::string retval;
12629 gh_manager& gh_mgr = octave::__get_gh_manager__ ();
12631 graphics_object go = gh_mgr.
get_object (val);
12634 error (
"get: invalid handle (= %g)", val);
12653 gh_manager& gh_mgr = interp.get_gh_manager ();
12657 int nargin = args.
length ();
12659 if (nargin < 1 || nargin > 2)
12662 if (args(0).isempty ())
12665 ColumnVector hcv = args(0).xvector_value (
"get: H must be a graphics handle");
12669 if (nargin == 1 && hcv_len > 1)
12671 std::string typ0 = get_graphics_object_type (hcv(0));
12675 std::string typ = get_graphics_object_type (hcv(n));
12678 error (
"get: vector of handles must all have the same type");
12684 bool use_cell_format =
false;
12686 if (nargin > 1 && args(1).iscellstr ())
12692 use_cell_format =
true;
12698 graphics_object go = gh_mgr.
get_object (hcv(n));
12701 error (
"get: invalid handle (= %g)", hcv(n));
12707 vals(n, m) = go.get (property);
12716 property = args(1).xstring_value (
"get: second argument must be property name or cell array of property names");
12722 graphics_object go = gh_mgr.
get_object (hcv(n));
12725 error (
"get: invalid handle (= %g)", hcv(n));
12728 vals(n) = go.get ();
12730 vals(n) = go.get (property);
12734 if (use_cell_format)
12742 else if (vals_len == 1)
12744 else if (vals_len > 1 && nargin == 1)
12749 tmp[n] = vals(n).scalar_map_value ();
12774 gh_manager& gh_mgr = interp.get_gh_manager ();
12778 if (args.
length () != 1)
12781 ColumnVector hcv = args(0).xvector_value (
"get: H must be a graphics handle");
12791 graphics_object go = gh_mgr.
get_object (hcv(n));
12794 error (
"get: invalid handle (= %g)", hcv(n));
12797 int state = toggle_warn (
"Octave:deprecated-property",
false);
12799 vals(n) = go.get (
true);
12801 toggle_warn (
"Octave:deprecated-property",
true, state);
12808 else if (vals_len == 1)
12809 return ovl (vals(0));
12815make_graphics_object (
const std::string& go_name,
12816 bool integer_figure_handle,
12821 double val = octave::numeric_limits<double>::NaN ();
12829 for (
int i = 0; i < xargs.
length (); i += 2)
12831 if (xargs(i).is_string () && p.compare (xargs(i).string_value ()))
12833 if (i >= (xargs.
length () - 1))
12834 error (
"__go_%s__: missing value for parent property",
12837 val = xargs(i+1).double_value ();
12839 xargs = xargs.
splice (i, 2);
12844 if (octave::math::isnan (val))
12845 val = args(0).xdouble_value (
"__go_%s__: invalid parent", go_name.c_str ());
12847 gh_manager& gh_mgr = octave::__get_gh_manager__ ();
12851 if (! parent.
ok ())
12852 error (
"__go_%s__: invalid parent", go_name.c_str ());
12859 integer_figure_handle,
false,
false);
12861 catch (octave::execution_exception& ee)
12863 error (ee,
"__go_%s__: %s, unable to create graphics handle",
12864 go_name.c_str (), ee.message ().c_str ());
12871 catch (octave::execution_exception& ee)
12874 error (ee,
"__go_%s__: %s, unable to create graphics handle",
12875 go_name.c_str (), ee.message ().c_str ());
12883 retval = h.
value ();
12890DEFMETHOD (__go_figure__, interp, args, ,
12896 gh_manager& gh_mgr = interp.get_gh_manager ();
12900 if (args.
length () == 0)
12903 double val = args(0).xdouble_value (
"__go_figure__: figure number must be a double value");
12913 retval = h.
value ();
12917 bool int_fig_handle =
true;
12923 if (octave::math::isnan (val))
12927 for (
int i = 0; i < xargs.
length (); i++)
12929 if (xargs(i).is_string ()
12930 && pname.
compare (xargs(i).string_value ()))
12932 if (i < (xargs.
length () - 1))
12934 std::string pval = xargs(i+1).string_value ();
12937 int_fig_handle = on.
compare (pval);
12938 xargs = xargs.
splice (i, 2);
12948 if (! int_fig_handle)
12954 go.get_properties ().init_integerhandle (
"off");
12957 else if (val > 0 && octave::math::x_nint (val) == val)
12961 error (
"__go_figure__: failed to create figure handle");
12967 catch (octave::execution_exception& ee)
12970 error (ee,
"__go_figure__: unable to create figure handle");
12980 retval = h.
value ();
12986#define GO_BODY(TYPE) \
12987 gh_manager& gh_mgr = interp.get_gh_manager (); \
12989 octave::autolock guard (gh_mgr.graphics_lock ()); \
12991 if (args.length () == 0) \
12994 return octave_value (make_graphics_object (#TYPE, false, args)); \
13001 if (go.isa (
"surface"))
13003 else if ((go.isa (
"line") || go.isa (
"patch") || go.isa (
"scatter"))
13004 && ! go.get (
"zdata").isempty ())
13008 Matrix kids = go.get_properties ().get_children ();
13010 gh_manager& gh_mgr = octave::__get_gh_manager__ ();
13018 const graphics_object& kid = gh_mgr.
get_object (hkid);
13020 if (kid.valid_object ())
13032DEFMETHOD (__calc_dimensions__, interp, args, ,
13040 gh_manager& gh_mgr = interp.get_gh_manager ();
13044 if (args.
length () != 1)
13047 double h = args(0).xdouble_value (
"__calc_dimensions__: first argument must be a graphics handle");
13079DEFMETHOD (__go_image__, interp, args, ,
13088DEFMETHOD (__go_surface__, interp, args, ,
13097DEFMETHOD (__go_patch__, interp, args, ,
13106DEFMETHOD (__go_scatter__, interp, args, ,
13115DEFMETHOD (__go_light__, interp, args, ,
13124DEFMETHOD (__go_hggroup__, interp, args, ,
13133DEFMETHOD (__go_uimenu__, interp, args, ,
13142DEFMETHOD (__go_uicontrol__, interp, args, ,
13151DEFMETHOD (__go_uibuttongroup__, interp, args, ,
13160DEFMETHOD (__go_uipanel__, interp, args, ,
13169DEFMETHOD (__go_uicontextmenu__, interp, args, ,
13178DEFMETHOD (__go_uitable__, interp, args, ,
13187DEFMETHOD (__go_uitoolbar__, interp, args, ,
13196DEFMETHOD (__go_uipushtool__, interp, args, ,
13205DEFMETHOD (__go_uitoggletool__, interp, args, ,
13214DEFMETHOD (__go_delete__, interp, args, ,
13220 gh_manager& gh_mgr = interp.get_gh_manager ();
13224 if (args.
length () != 1)
13229 const NDArray vals = args(0).xarray_value (
"delete: invalid graphics object");
13235 h = gh_mgr.
lookup (vals(i));
13238 error (
"delete: invalid graphics object (= %g)", vals(i));
13246DEFMETHOD (__go_handles__, interp, args, ,
13252 gh_manager& gh_mgr = interp.get_gh_manager ();
13256 bool show_hidden =
false;
13259 show_hidden = args(0).bool_value ();
13264DEFMETHOD (__go_figure_handles__, interp, args, ,
13270 gh_manager& gh_mgr = interp.get_gh_manager ();
13274 bool show_hidden =
false;
13277 show_hidden = args(0).bool_value ();
13282DEFMETHOD (__go_execute_callback__, interp, args, ,
13289 int nargin = args.
length ();
13291 if (nargin < 2 || nargin > 3)
13294 const NDArray vals = args(0).xarray_value (
"__go_execute_callback__: invalid graphics object");
13296 std::string name = args(1).xstring_value (
"__go_execute_callback__: invalid callback name");
13298 gh_manager& gh_mgr = interp.get_gh_manager ();
13302 double val = vals(i);
13307 error (
"__go_execute_callback__: invalid graphics object (= %g)", val);
13318DEFMETHOD (__go_post_callback__, interp, args, ,
13325 int nargin = args.
length ();
13327 if (nargin < 2 || nargin > 3)
13330 const NDArray vals = args(0).xarray_value (
"__go_post_callback__: invalid graphics object");
13332 std::string name = args(1).xstring_value (
"__go_post_callback__: invalid callback name");
13334 gh_manager& gh_mgr = interp.get_gh_manager ();
13338 double val = vals(i);
13343 error (
"__go_execute_callback__: invalid graphics object (= %g)", val);
13354DEFMETHOD (__image_pixel_size__, interp, args, ,
13360 if (args.
length () != 1)
13363 gh_manager& gh_mgr = interp.get_gh_manager ();
13365 double h = args(0).xdouble_value (
"__image_pixel_size__: argument is not a handle");
13369 if (! go || ! go.isa (
"image"))
13370 error (
"__image_pixel_size__: object is not an image");
13372 image::properties& ip
13373 =
dynamic_cast<image::properties&
> (go.get_properties ());
13376 dp(0) = ip.pixel_xsize ();
13377 dp(1) = ip.pixel_ysize ();
13381DEFMETHOD (available_graphics_toolkits, interp, , ,
13388 gh_manager& gh_mgr = interp.get_gh_manager ();
13392 octave::gtk_manager& gtk_mgr = interp.get_gtk_manager ();
13394 return ovl (gtk_mgr.available_toolkits_list ());
13397DEFMETHOD (register_graphics_toolkit, interp, args, ,
13407 gh_manager& gh_mgr = interp.get_gh_manager ();
13411 if (args.
length () != 1)
13414 std::string name = args(0).xstring_value (
"register_graphics_toolkit: TOOLKIT must be a string");
13416 octave::gtk_manager& gtk_mgr = interp.get_gtk_manager ();
13418 gtk_mgr.register_toolkit (name);
13423DEFMETHOD (loaded_graphics_toolkits, interp, , ,
13430 gh_manager& gh_mgr = interp.get_gh_manager ();
13434 octave::gtk_manager& gtk_mgr = interp.get_gtk_manager ();
13436 return ovl (gtk_mgr.loaded_toolkits_list ());
13439DEFMETHOD (__show_figure__, interp, args, ,
13445 if (args.
length () != 1)
13448 gh_manager& gh_mgr = interp.get_gh_manager ();
13450 double h = args(0).xdouble_value (
"__show_figure__: invalid handle H");
13455 error (
"__show_figure__: invalid graphics object (= %g)", h);
13457 graphics_object go = gh_mgr.
get_object (gh);
13459 figure::properties& fprops
13460 =
dynamic_cast<figure::properties&
> (go.get_properties ());
13462 fprops.get_toolkit ().show_figure (go);
13493 gh_manager& gh_mgr = interp.get_gh_manager ();
13497 if (args.
length () <= 1)
13501 bool do_events =
true;
13503 if (args.
length () == 1)
13505 caseless_str val (args(0).xstring_value (
"drawnow: first argument must be a string"));
13510 error (
"drawnow: invalid argument, 'expose' is only valid option");
13525 for (
int i = 0; i < hlist.
numel (); i++)
13529 if (h.
ok () && h != 0)
13532 figure::properties& fprops
13533 =
dynamic_cast<figure::properties&
> (go.get_properties ());
13535 if (fprops.is_modified ())
13537 if (fprops.is_visible ())
13541 fprops.get_toolkit ().redraw_figure (go);
13546 fprops.set_modified (
false);
13554 std::string term, file, debug_file;
13556 term = args(0).xstring_value (
"drawnow: TERM must be a string");
13558 file = args(1).xstring_value (
"drawnow: FILE must be a string");
13561 error (
"drawnow: empty output ''");
13562 else if (file.length () == 1 && file[0] ==
'|')
13563 error (
"drawnow: empty pipe '|'");
13564 else if (file[0] !=
'|')
13566 std::size_t pos = file.find_last_of (octave::sys::file_ops::dir_sep_chars ());
13568 if (pos != std::string::npos)
13570 std::string
dirname = file.substr (0, pos+1);
13572 if (! octave::sys::dir_exists (
dirname))
13573 error (
"drawnow: nonexistent directory '%s'",
13579 debug_file = (args.
length () > 2 ? args(2).xstring_value (
"drawnow: DEBUG_FILE must be a string") :
13585 error (
"drawnow: nothing to draw");
13591 go.get_toolkit ().print_figure (go, term, file, debug_file);
13635 gh_manager& gh_mgr = interp.get_gh_manager ();
13639 int nargin = args.
length ();
13641 if (nargin < 3 || nargin > 4)
13644 double h = args(0).xdouble_value (
"addlistener: invalid handle H");
13646 std::string pname = args(1).xstring_value (
"addlistener: PROP must be a string");
13651 error (
"addlistener: invalid graphics object (= %g)", h);
13653 graphics_object go = gh_mgr.
get_object (gh);
13655 go.add_property_listener (pname, args(2), GCB_POSTSET);
13657 if (args.
length () == 4)
13660 if (persistent.
compare (
"persistent"))
13661 go.add_property_listener (pname, args(2), GCB_PERSISTENT);
13696 gh_manager& gh_mgr = interp.get_gh_manager ();
13703 double h = args(0).xdouble_value (
"dellistener: invalid handle");
13705 std::string pname = args(1).xstring_value (
"dellistener: PROP must be a string");
13710 error (
"dellistener: invalid graphics object (= %g)", h);
13712 graphics_object go = gh_mgr.
get_object (gh);
13714 if (args.
length () == 2)
13715 go.delete_property_listener (pname,
octave_value (), GCB_POSTSET);
13718 if (args(2).is_string ()
13719 && args(2).string_value () ==
"persistent")
13727 go.delete_property_listener (pname, args(2), GCB_POSTSET);
13805 gh_manager& gh_mgr = interp.get_gh_manager ();
13812 std::string name = args(0).xstring_value (
"addproperty: NAME must be a string");
13814 double h = args(1).xdouble_value (
"addproperty: invalid handle H");
13819 error (
"addproperty: invalid graphics object (= %g)", h);
13821 graphics_object go = gh_mgr.
get_object (gh);
13823 std::string type = args(2).xstring_value (
"addproperty: TYPE must be a string");
13825 if (go.get_properties ().has_property (name))
13826 error (
"addproperty: a '%s' property already exists in the graphics object",
13829 property p = property::create (name, gh, type, args.
splice (0, 3));
13831 go.get_properties ().insert_property (name, p);
13838 const std::string& fcn)
13840 gh_manager& gh_mgr = octave::__get_gh_manager__ ();
13844 graphics_object go = gh_mgr.
get_object (handle);
13847 error (
"%s: invalid handle (= %g)", fcn.c_str (), handle);
13856 gh_manager& gh_mgr = octave::__get_gh_manager__ ();
13860 graphics_object go = gh_mgr.
get_object (handle);
13863 error (
"%s: invalid handle (= %g)", fcn.c_str (), handle);
13871compare_property_values (octave::interpreter& interp,
13881 if (result.
length () > 0)
13882 return result(0).bool_value ();
13887static std::map<uint32_t, bool> waitfor_results;
13890cleanup_waitfor_id (uint32_t
id)
13892 waitfor_results.erase (
id);
13896do_cleanup_waitfor_listener (
const octave_value& listener,
13897 listener_mode mode = GCB_POSTSET)
13901 if (c.
numel () >= 4)
13903 double h = c(2).double_value ();
13907 gh_manager& gh_mgr = octave::__get_gh_manager__ ();
13915 graphics_object go = gh_mgr.
get_object (gh);
13917 if (go.get_properties ().has_property (pname))
13919 go.get_properties ().delete_listener (pname, listener, mode);
13921 if (mode == GCB_POSTSET)
13922 go.get_properties ().delete_listener (pname, listener,
13930cleanup_waitfor_postset_listener (
const octave_value& listener)
13931{ do_cleanup_waitfor_listener (listener, GCB_POSTSET); }
13934cleanup_waitfor_predelete_listener (
const octave_value& listener)
13935{ do_cleanup_waitfor_listener (listener, GCB_PREDELETE); }
13941 uint32_t
id = args(2).uint32_scalar_value ().value ();
13945 double h = args(0).double_value ();
13949 gh_manager& gh_mgr = octave::__get_gh_manager__ ();
13957 graphics_object go = gh_mgr.
get_object (gh);
13960 if (compare_property_values (interp, pvalue, args(5)))
13961 waitfor_results[id] =
true;
13965 waitfor_results[id] =
true;
13975 uint32_t
id = args(2).uint32_scalar_value ().value ();
13977 waitfor_results[id] =
true;
14026 if (args.
length () == 0)
14030 if (args(0).isempty ())
14033 double h = args(0).xdouble_value (
"waitfor: invalid handle value");
14035 if (! ishghandle (h) || (h == 0 && args.
length () == 1))
14040 octave::unwind_action cleanup_waitfor_id_action;
14041 octave::unwind_action cleanup_waitfor_postset_listener_action;
14042 octave::unwind_action cleanup_waitfor_predelete_listener_action;
14044 static uint32_t id_counter = 0;
14047 int max_arg_index = 0;
14048 int timeout_index = -1;
14050 double timeout = 0;
14052 gh_manager& gh_mgr = interp.get_gh_manager ();
14056 pname = args(1).xstring_value (
"waitfor: PROP must be a string");
14058 if (pname.empty ())
14059 error (
"waitfor: PROP must be a non-empty string");
14061 if (pname !=
"timeout")
14063 if (pname.
compare (R
"(\timeout)"))
14071 "waitfor_listener"));
14076 if (args(2).is_string ())
14089 Cell listener (1, max_arg_index >= 2 ? 5 : 4);
14092 cleanup_waitfor_id_action.set (cleanup_waitfor_id,
id);
14093 waitfor_results[id] =
false;
14095 listener(0) = wf_listener;
14098 listener(3) = pname;
14100 if (max_arg_index >= 2)
14101 listener(4) = args(2);
14111 graphics_object go = gh_mgr.
get_object (gh);
14113 if (max_arg_index >= 2
14114 && compare_property_values (interp, go.get (pname), args(2)))
14115 waitfor_results[id] =
true;
14118 cleanup_waitfor_postset_listener_action.set
14119 (cleanup_waitfor_postset_listener, ov_listener);
14121 go.add_property_listener (pname, ov_listener, GCB_POSTSET);
14122 go.add_property_listener (pname, ov_listener, GCB_PERSISTENT);
14124 if (go.get_properties ().has_dynamic_property (pname))
14131 (waitfor_del_listener,
14132 "waitfor_del_listener"));
14134 Cell del_listener (1, 4);
14136 del_listener(0) = wf_del_listener;
14138 del_listener(2) = h;
14139 del_listener(3) = pname;
14143 cleanup_waitfor_predelete_listener_action.set
14144 (cleanup_waitfor_predelete_listener, ov_del_listener);
14146 go.add_property_listener (pname, ov_del_listener,
14154 if (timeout_index < 0 && args.
length () > (max_arg_index + 1))
14157 1).xstring_value (
"waitfor: invalid parameter, expected 'timeout'");
14160 error (
"waitfor: invalid parameter '%s'", s.c_str ());
14162 timeout_index = max_arg_index + 1;
14165 if (timeout_index >= 0)
14167 if (args.
length () <= (timeout_index + 1))
14168 error (
"waitfor: missing TIMEOUT value");
14170 timeout = args(timeout_index + 1).xscalar_value (
"waitfor: TIMEOUT must be a scalar >= 1");
14174 warning (
"waitfor: TIMEOUT value must be >= 1, using 1 instead");
14194 octave::sys::time start;
14209 if (! pname.empty () && waitfor_results[
id])
14216 octave::sleep (0.1);
14220 octave::command_editor::run_event_hooks ();
14224 octave::sys::time now;
14226 if (start + timeout < now)
14242 int nargin = args.
length ();
14244 if (nargin != 2 && nargin != 3)
14247 double h = args(0).double_value ();
14249 gh_manager& gh_mgr = interp.get_gh_manager ();
14255 if (! handle.
ok ())
14256 error (
"__zoom__: invalid handle");
14258 graphics_object ax = gh_mgr.
get_object (handle);
14260 axes::properties& ax_props
14261 =
dynamic_cast<axes::properties&
> (ax.get_properties ());
14265 std::string opt = args(1).string_value ();
14267 if (opt ==
"out" || opt ==
"reset")
14271 ax_props.clear_zoom_stack ();
14275 ax_props.clear_zoom_stack (
false);
14280 std::string mode = args(1).string_value ();
14281 double factor = args(2).scalar_value ();
14283 ax_props.zoom (mode, factor);
14290DEFMETHOD (__get_frame__, interp, args, ,
14299 if (args.
length () != 1)
14302 double h = args(0).xdouble_value (
"__get_frame__: HFIG is not a handle");
14304 gh_manager& gh_mgr = interp.get_gh_manager ();
14308 if (! go || ! go.isa (
"figure"))
14309 error (
"__get_frame__: HFIG is not a figure");
14314 return ovl (go.get_toolkit ().get_pixels (go));
14317DEFMETHOD (__get_position__, interp, args, ,
14326 if (args.
length () != 2)
14330 = args(0).xdouble_value (
"__get_position__: H must be a graphics handle");
14333 = args(1).xstring_value (
"__get_position__: UNITS must be a string");
14335 gh_manager& gh_mgr = interp.get_gh_manager ();
14339 if (h == 0 || ! go)
14340 error (
"__get_position__: H must be a handle to a valid graphics object");
14342 graphics_object parent_go = gh_mgr.
get_object (go.get_parent ());
14343 Matrix bbox = parent_go.get_properties ().get_boundingbox (
true)
14346 Matrix pos = convert_position (go.get (
"position").matrix_value (),
14347 go.get (
"units").string_value (),
14353DEFUN (__get_system_fonts__, args, ,
14359 if (args.
length () != 0)
14362 octave::text_renderer txt_renderer;
14364 return ovl (txt_renderer.get_system_fonts ());
14367OCTAVE_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)
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
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)