26#if defined (HAVE_CONFIG_H)
50#include "builtin-defun-decls.h"
79 error (
"set: invalid value for %s property", pname.c_str ());
88 const std::set<std::string>& pnames,
91 std::size_t
len = pname.length ();
92 std::set<std::string> matches;
95 for (
const auto& propnm : pnames)
99 if (
len == propnm.length ())
102 matches.insert (propnm);
106 std::size_t num_matches = matches.size ();
108 if (num_matches == 0)
109 error (
"%s: unknown %s property %s",
110 who.c_str (), what.c_str (), pname.c_str ());
111 else if (num_matches > 1)
115 std::ostringstream os;
119 std::string match_list = os.str ();
121 error (
"%s: ambiguous %s property name %s; possible matches:\n\n%s",
122 who.c_str (), what.c_str (), pname.c_str (), match_list.c_str ());
127 std::string possible_match = *(matches.begin ());
130 "%s: allowing %s to match %s property %s",
131 who.c_str (), pname.c_str (), what.c_str (),
132 possible_match.c_str ());
134 return possible_match;
149 const double cmapv[] =
151 2.67004010000000e-01, 2.72651720952381e-01, 2.77106307619048e-01,
152 2.80356151428571e-01, 2.82390045238095e-01, 2.83204606666667e-01,
153 2.82809341428571e-01, 2.81230763333333e-01, 2.78516153333333e-01,
154 2.74735528571429e-01, 2.69981791904762e-01, 2.64368580952381e-01,
155 2.58026184285714e-01, 2.51098684761905e-01, 2.43732853333333e-01,
156 2.36073294285714e-01, 2.28263191428571e-01, 2.20424955714286e-01,
157 2.12666598571429e-01, 2.05079113809524e-01, 1.97721880952381e-01,
158 1.90631350000000e-01, 1.83819438571429e-01, 1.77272360952381e-01,
159 1.70957518571429e-01, 1.64832915714286e-01, 1.58845368095238e-01,
160 1.52951235714286e-01, 1.47131626666667e-01, 1.41402210952381e-01,
161 1.35832975714286e-01, 1.30582113809524e-01, 1.25898377619048e-01,
162 1.22163105714286e-01, 1.19872409523810e-01, 1.19626570000000e-01,
163 1.22045948571429e-01, 1.27667691904762e-01, 1.36834947142857e-01,
164 1.49643331428571e-01, 1.65967274285714e-01, 1.85538397142857e-01,
165 2.08030450000000e-01, 2.33127309523809e-01, 2.60531475238095e-01,
166 2.90000730000000e-01, 3.21329971428571e-01, 3.54355250000000e-01,
167 3.88930322857143e-01, 4.24933143333333e-01, 4.62246770476190e-01,
168 5.00753620000000e-01, 5.40336957142857e-01, 5.80861172380952e-01,
169 6.22170772857143e-01, 6.64087320476191e-01, 7.06403823333333e-01,
170 7.48885251428571e-01, 7.91273132857143e-01, 8.33302102380952e-01,
171 8.74717527142857e-01, 9.15296319047619e-01, 9.54839555238095e-01,
172 9.93247890000000e-01, 4.87433000000000e-03, 2.58456800000000e-02,
173 5.09139004761905e-02, 7.42014957142857e-02, 9.59536042857143e-02,
174 1.16893314761905e-01, 1.37350195714286e-01, 1.57479940000000e-01,
175 1.77347967619048e-01, 1.96969168571429e-01, 2.16330337619048e-01,
176 2.35404660952381e-01, 2.54161735714286e-01, 2.72573219047619e-01,
177 2.90619516666667e-01, 3.08291041428571e-01, 3.25586450952381e-01,
178 3.42517215238095e-01, 3.59102207142857e-01, 3.75366067142857e-01,
179 3.91340913333333e-01, 4.07061480000000e-01, 4.22563764285714e-01,
180 4.37885543809524e-01, 4.53062984285714e-01, 4.68129543809524e-01,
181 4.83117059523810e-01, 4.98052961428571e-01, 5.12959473333333e-01,
182 5.27854311428571e-01, 5.42750087142857e-01, 5.57652481904762e-01,
183 5.72563073333333e-01, 5.87476284285714e-01, 6.02382410952381e-01,
184 6.17265840000000e-01, 6.32106955714286e-01, 6.46881817142857e-01,
185 6.61562926190476e-01, 6.76119717142857e-01, 6.90518987142857e-01,
186 7.04725181904762e-01, 7.18700950000000e-01, 7.32406441904762e-01,
187 7.45802021904762e-01, 7.58846480000000e-01, 7.71497934761905e-01,
188 7.83714033809524e-01, 7.95453081428571e-01, 8.06673890000000e-01,
189 8.17337565714286e-01, 8.27409135714286e-01, 8.36858167619048e-01,
190 8.45663399523809e-01, 8.53815582857143e-01, 8.61321019047619e-01,
191 8.68206316666667e-01, 8.74522215714286e-01, 8.80346158571429e-01,
192 8.85780083333333e-01, 8.90945338571429e-01, 8.95973498571429e-01,
193 9.01005800000000e-01, 9.06156570000000e-01, 3.29415190000000e-01,
194 3.53367293333333e-01, 3.76236064761905e-01, 3.97901482857143e-01,
195 4.18250757142857e-01, 4.37178920000000e-01, 4.54595888571429e-01,
196 4.70433883333333e-01, 4.84653865714286e-01, 4.97250492857143e-01,
197 5.08254501428571e-01, 5.17731949047619e-01, 5.25780221428571e-01,
198 5.32522206190476e-01, 5.38097133333333e-01, 5.42651800000000e-01,
199 5.46335411904762e-01, 5.49287148571429e-01, 5.51635008571429e-01,
200 5.53493173333333e-01, 5.54953478571429e-01, 5.56089070000000e-01,
201 5.56952166666667e-01, 5.57576145714286e-01, 5.57974025714286e-01,
202 5.58142745238095e-01, 5.58058673809524e-01, 5.57684744285714e-01,
203 5.56973310000000e-01, 5.55864478571429e-01, 5.54288677142857e-01,
204 5.52175699047619e-01, 5.49445382857143e-01, 5.46023368571429e-01,
205 5.41830633809524e-01, 5.36795616666667e-01, 5.30847985714286e-01,
206 5.23924198571429e-01, 5.15966779523810e-01, 5.06924262857143e-01,
207 4.96751861428571e-01, 4.85412122857143e-01, 4.72873300000000e-01,
208 4.59105875238095e-01, 4.44095883333333e-01, 4.27825852857143e-01,
209 4.10292713809524e-01, 3.91487632857143e-01, 3.71420688571429e-01,
210 3.50098750000000e-01, 3.27544678571429e-01, 3.03798967142857e-01,
211 2.78916748571429e-01, 2.53000856190476e-01, 2.26223670000000e-01,
212 1.98879439523810e-01, 1.71494930000000e-01, 1.45037631428572e-01,
213 1.21291048571429e-01, 1.03326155238095e-01, 9.53507900000000e-02,
214 1.00469958095238e-01, 1.17876387142857e-01, 1.43936200000000e-01
220 std::copy (cmapv, cmapv + (64*3), cmap.
fortran_vec ());
227 octave::display_info& dpy_info
230 return dpy_info.depth ();
238 octave::display_info& dpy_info
243 retval(2) = dpy_info.width ();
244 retval(3) = dpy_info.height ();
252 octave::display_info& dpy_info
255 return (dpy_info.x_dpi () + dpy_info.y_dpi ()) / 2;
261 Matrix retval (7, 3, 0.0);
263 retval(0, 1) = 0.447;
264 retval(0, 2) = 0.741;
266 retval(1, 0) = 0.850;
267 retval(1, 1) = 0.325;
268 retval(1, 2) = 0.098;
270 retval(2, 0) = 0.929;
271 retval(2, 1) = 0.694;
272 retval(2, 2) = 0.125;
274 retval(3, 0) = 0.494;
275 retval(3, 1) = 0.184;
276 retval(3, 2) = 0.556;
278 retval(4, 0) = 0.466;
279 retval(4, 1) = 0.674;
280 retval(4, 2) = 0.188;
282 retval(5, 0) = 0.301;
283 retval(5, 1) = 0.745;
284 retval(5, 2) = 0.933;
286 retval(6, 0) = 0.635;
287 retval(6, 1) = 0.078;
288 retval(6, 2) = 0.184;
342 for (
int col = 0; col < 64; col++)
343 for (
int row = 0; row < 64; row++)
357 for (
int col = 0; col < 3; col++)
358 for (
int row = 0; row < 3; row++)
369 for (
int row = 0; row < 3; row++)
370 for (
int col = 0; col < 3; col++)
381 for (
int row = 0; row < 3; row++)
530 m(0) = 1.3421852580027660;
531 m(1) = 3.3191389435020748;
532 m(2) = 5.8156294839944680;
533 m(3) = 4.3617221129958503;
625 bool integer_figure_handle =
false,
626 bool call_createfcn =
true,
627 bool notify_toolkit =
true)
631 return gh_mgr.make_graphics_handle (go_name, parent, integer_figure_handle,
632 call_createfcn, notify_toolkit);
641 if (from_units.
compare (to_units))
647 double points_size = 0;
650 if (from_units.
compare (
"points"))
651 points_size = font_size;
656 if (from_units.
compare (
"pixels"))
657 points_size = font_size * 72.0 / res;
658 else if (from_units.
compare (
"inches"))
659 points_size = font_size * 72.0;
660 else if (from_units.
compare (
"centimeters"))
661 points_size = font_size * 72.0 / 2.54;
662 else if (from_units.
compare (
"normalized"))
663 points_size = font_size * parent_height * 72.0 / res;
666 double new_font_size = 0;
668 if (to_units.
compare (
"points"))
669 new_font_size = points_size;
675 if (to_units.
compare (
"pixels"))
676 new_font_size = points_size * res / 72.0;
677 else if (to_units.
compare (
"inches"))
678 new_font_size = points_size / 72.0;
679 else if (to_units.
compare (
"centimeters"))
680 new_font_size = points_size * 2.54 / 72.0;
681 else if (to_units.
compare (
"normalized"))
685 if (parent_height > 0)
686 new_font_size = points_size * res / (parent_height * 72.0);
690 return new_font_size;
699 bool is_rectangle = (pos.
numel () == 4);
700 bool is_2D = (pos.
numel () == 2);
702 if (from_units.
compare (
"pixels"))
704 else if (from_units.
compare (
"normalized"))
706 retval(0) = pos(0) * parent_dim(0) + 1;
707 retval(1) = pos(1) * parent_dim(1) + 1;
710 retval(2) = pos(2) * parent_dim(0);
711 retval(3) = pos(3) * parent_dim(1);
716 else if (from_units.
compare (
"characters"))
725 f = 12.0 * res / 74.951;
729 retval(0) = 0.5 * pos(0) *
f;
730 retval(1) = pos(1) *
f;
733 retval(2) = 0.5 * pos(2) *
f;
734 retval(3) = pos(3) *
f;
747 if (from_units.
compare (
"points"))
749 else if (from_units.
compare (
"inches"))
751 else if (from_units.
compare (
"centimeters"))
756 retval(0) = pos(0) *
f + 1;
757 retval(1) = pos(1) *
f + 1;
760 retval(2) = pos(2) *
f;
761 retval(3) = pos(3) *
f;
768 if (! to_units.
compare (
"pixels"))
770 if (to_units.
compare (
"normalized"))
772 retval(0) = (retval(0) - 1) / parent_dim(0);
773 retval(1) = (retval(1) - 1) / parent_dim(1);
776 retval(2) /= parent_dim(0);
777 retval(3) /= parent_dim(1);
782 else if (to_units.
compare (
"characters"))
789 f = 12.0 * res / 74.951;
793 retval(0) = 2 * retval(0) /
f;
794 retval(1) = retval(1) /
f;
797 retval(2) = 2 * retval(2) /
f;
798 retval(3) = retval(3) /
f;
811 if (to_units.
compare (
"points"))
813 else if (to_units.
compare (
"inches"))
815 else if (to_units.
compare (
"centimeters"))
820 retval(0) = (retval(0) - 1) /
f;
821 retval(1) = (retval(1) - 1) /
f;
843 graphics_object go = gh_mgr.get_object (props.get___myhandle__ ());
845 graphics_object ax = go.get_ancestor (
"axes");
849 if (ax.valid_object ())
853 graphics_xform ax_xform = ax_props.get_transform ();
854 bool is_rectangle = (pos.
numel () == 4);
855 Matrix ax_bbox = ax_props.get_boundingbox (
true),
856 ax_size = ax_bbox.
extract_n (0, 2, 1, 2);
858 if (from_units.
compare (
"data"))
862 ColumnVector v1 = ax_xform.transform (pos(0), pos(1), 0),
863 v2 = ax_xform.transform (pos(0) + pos(2),
868 retval(0) = v1(0) - ax_bbox(0) + 1;
869 retval(1) = ax_bbox(1) + ax_bbox(3) - v1(1) + 1;
870 retval(2) =
v2(0) - v1(0);
871 retval(3) = v1(1) -
v2(1);
875 ColumnVector v = ax_xform.transform (pos(0), pos(1), pos(2));
879 retval(0) = v(0) - ax_bbox(0) + 1;
880 retval(1) = ax_bbox(1) + ax_bbox(3) - v(1) + 1;
887 if (! to_units.
compare (
"pixels"))
894 v1 = ax_xform.untransform (retval(0) + ax_bbox(0) - 1,
895 ax_bbox(1) + ax_bbox(3) - retval(1) + 1);
896 v2 = ax_xform.untransform (retval(0) + retval(2) + ax_bbox(0) - 1,
897 ax_bbox(1) + ax_bbox(3) - (retval(1) + retval(3)) + 1);
903 retval(2) =
v2(0) - v1(0);
904 retval(3) =
v2(1) - v1(1);
909 v = ax_xform.untransform (retval(0) + ax_bbox(0) - 1,
910 ax_bbox(1) + ax_bbox(3) - retval(1) + 1);
933 graphics_object obj = gh_mgr.get_object (0);
935 Matrix sz = obj.get (
"screensize").matrix_value ();
948 graphics_object fig = gh_mgr.get_object (h).get_ancestor (
"figure");
950 if (fig.valid_object ())
951 retval = fig.get (
"__device_pixel_ratio__").double_value ();
982 av[i+lda] = cmapv[idx+nc];
983 av[i+2*lda] = cmapv[idx+2*nc];
995 clim_0, clim_1, cmapv, cv[i], lda, nc, i, av);
1000 bool is_scaled,
int cdim)
1005 if (dv.
ndims () == cdim && dv(cdim-1) == 3)
1013 graphics_object go = gh_mgr.get_object (props.get___myhandle__ ());
1014 graphics_object ax = go.get_ancestor (
"axes");
1016 if (ax.valid_object ())
1039 const double *cmapv = cmap.
data ();
1041 double clim_0 = clim(0);
1042 double clim_1 = clim(1);
1052#define CONVERT_CDATA_1(ARRAY_T, VAL_FN, IS_REAL) \
1055 ARRAY_T tmp = cdata. VAL_FN ## array_value (); \
1057 convert_cdata_1 (is_scaled, IS_REAL, clim_0, clim_1, cmapv, \
1058 tmp.data (), lda, nc, av); \
1087 warning (
"unsupported type for cdata (= %s). "
1088 "Valid types are int8, int16, int32, int64, uint8, uint16, "
1089 "uint32, uint64, double, single, and bool.",
1094#undef CONVERT_CDATA_1
1099template <
typename T>
1102 double& eminp,
double& emaxp)
1104 const T *data = m.
data ();
1109 double e =
double (data[i]);
1120 if (e > 0 && e < eminp)
1123 if (e < 0 && e > emaxp)
1135 bool result =
false;
1146 pfx =
name.substr (0, 5);
1152 pfx =
name.substr (0, 6);
1158 pfx =
name.substr (0, 7);
1166 pfx =
name.substr (0, 9);
1173 pfx =
name.substr (0, 10);
1175 if (pfx.
compare (
"uipushtool"))
1179 pfx =
name.substr (0, 12);
1181 if (pfx.
compare (
"uitoggletool"))
1185 pfx =
name.substr (0, 13);
1187 if (pfx.
compare (
"uicontextmenu")
1188 || pfx.
compare (
"uibuttongroup"))
1201 rest =
name.substr (offset);
1209static base_graphics_object *
1214 base_graphics_object *go =
nullptr;
1217 go =
new figure (h, p);
1218 else if (type.
compare (
"axes"))
1219 go =
new axes (h, p);
1220 else if (type.
compare (
"line"))
1221 go =
new line (h, p);
1222 else if (type.
compare (
"text"))
1223 go =
new text (h, p);
1224 else if (type.
compare (
"image"))
1225 go =
new image (h, p);
1226 else if (type.
compare (
"light"))
1227 go =
new light (h, p);
1228 else if (type.
compare (
"patch"))
1229 go =
new patch (h, p);
1230 else if (type.
compare (
"scatter"))
1231 go =
new scatter (h, p);
1232 else if (type.
compare (
"surface"))
1233 go =
new surface (h, p);
1234 else if (type.
compare (
"hggroup"))
1235 go =
new hggroup (h, p);
1236 else if (type.
compare (
"uimenu"))
1237 go =
new uimenu (h, p);
1238 else if (type.
compare (
"uicontrol"))
1239 go =
new uicontrol (h, p);
1240 else if (type.
compare (
"uipanel"))
1241 go =
new uipanel (h, p);
1242 else if (type.
compare (
"uibuttongroup"))
1243 go =
new uibuttongroup (h, p);
1244 else if (type.
compare (
"uicontextmenu"))
1245 go =
new uicontextmenu (h, p);
1246 else if (type.
compare (
"uitable"))
1247 go =
new uitable (h, p);
1248 else if (type.
compare (
"uitoolbar"))
1249 go =
new uitoolbar (h, p);
1250 else if (type.
compare (
"uipushtool"))
1251 go =
new uipushtool (h, p);
1252 else if (type.
compare (
"uitoggletool"))
1253 go =
new uitoggletool (h, p);
1260base_property::set (
const octave_value& v,
bool do_run,
bool do_notify_toolkit)
1265 if (m_id >= 0 && do_notify_toolkit)
1270 graphics_object go = gh_mgr.get_object (m_parent);
1277 run_listeners (GCB_POSTSET);
1286base_property::run_listeners (listener_mode mode)
1293 for (
int i = 0; i < l.
length (); i++)
1294 gh_mgr.execute_listener (m_parent, l(i));
1297radio_values::radio_values (
const std::string& opt_string)
1298 : m_default_val (), m_possible_vals ()
1300 std::size_t beg = 0;
1301 std::size_t
len = opt_string.length ();
1302 bool done =
len == 0;
1306 std::size_t end = opt_string.find (
'|', beg);
1308 if (end == std::string::npos)
1314 std::string t = opt_string.substr (beg, end-beg);
1317 if (t.empty () && opt_string[beg] ==
'|')
1326 t = t.substr (1, t.length () - 2);
1332 m_possible_vals.insert (t);
1339radio_values::values_as_string (
void)
const
1343 for (
const auto& val : m_possible_vals)
1345 if (retval.empty ())
1347 if (val == default_value ())
1348 retval =
'{' + val +
'}';
1354 if (val == default_value ())
1355 retval +=
" | {" + val +
'}';
1357 retval +=
" | " + val;
1361 if (! retval.empty ())
1362 retval =
"[ " + retval +
" ]";
1368radio_values::values_as_cell (
void)
const
1371 Cell retval (nelem (), 1);
1373 for (
const auto& val : m_possible_vals)
1374 retval(i++) = std::string (val);
1380color_values::str2rgb (
const std::string& str_arg)
1384 double tmp_rgb[3] = {0, 0, 0};
1386 std::string str = str_arg;
1387 unsigned int len = str.length ();
1389 std::transform (str.begin (), str.end (), str.begin (), tolower);
1392 if (str.compare (0,
len,
"blue", 0,
len) == 0)
1394 else if (str.compare (0,
len,
"black", 0,
len) == 0
1395 || str.compare (0,
len,
"k", 0,
len) == 0)
1396 tmp_rgb[0] = tmp_rgb[1] = tmp_rgb[2] = 0;
1397 else if (str.compare (0,
len,
"red", 0,
len) == 0)
1399 else if (str.compare (0,
len,
"green", 0,
len) == 0)
1401 else if (str.compare (0,
len,
"yellow", 0,
len) == 0)
1402 tmp_rgb[0] = tmp_rgb[1] = 1;
1403 else if (str.compare (0,
len,
"magenta", 0,
len) == 0)
1404 tmp_rgb[0] = tmp_rgb[2] = 1;
1405 else if (str.compare (0,
len,
"cyan", 0,
len) == 0)
1406 tmp_rgb[1] = tmp_rgb[2] = 1;
1407 else if (str.compare (0,
len,
"white", 0,
len) == 0
1408 || str.compare (0,
len,
"w", 0,
len) == 0)
1409 tmp_rgb[0] = tmp_rgb[1] = tmp_rgb[2] = 1;
1410 else if (str[0] ==
'#' &&
len == 7)
1414 tmp_rgb[0] =
static_cast<double> (stoi (str.substr (1, 2),
nullptr, 16))
1416 tmp_rgb[1] =
static_cast<double> (stoi (str.substr (3, 2),
nullptr, 16))
1418 tmp_rgb[2] =
static_cast<double> (stoi (str.substr (5, 2),
nullptr, 16))
1421 catch (
const octave::execution_exception&)
1426 else if (str[0] ==
'#' &&
len == 4)
1430 tmp_rgb[0] =
static_cast<double> (stoi (str.substr (1, 1),
nullptr, 16))
1432 tmp_rgb[1] =
static_cast<double> (stoi (str.substr (2, 1),
nullptr, 16))
1434 tmp_rgb[2] =
static_cast<double> (stoi (str.substr (3, 1),
nullptr, 16))
1437 catch (
const octave::execution_exception&)
1447 for (
int i = 0; i < 3; i++)
1448 m_rgb(i) = tmp_rgb[i];
1462 error (R
"(invalid value for color property "%s")",
1463 get_name ().c_str ());
1467 if (m_radio_val.contains (s, match))
1469 if (m_current_type != radio_t || match != m_current_val)
1471 if (s.length () != match.length ())
1473 "%s: allowing %s to match %s value %s",
1474 "set", s.c_str (), get_name ().c_str (),
1476 m_current_val = match;
1477 m_current_type = radio_t;
1485 color_values col (s);
1487 if (m_current_type != color_t || col != m_color_val)
1490 m_current_type = color_t;
1494 catch (octave::execution_exception& ee)
1496 error (ee, R
"(invalid value for color property "%s" (value = %s))",
1497 get_name ().c_str (), s.c_str ());
1505 if (m.
numel () != 3)
1506 error (R
"(invalid value for color property "%s")",
1507 get_name ().c_str ());
1509 color_values col (m(0), m(1), m(2));
1511 if (m_current_type != color_t || col != m_color_val)
1514 m_current_type = color_t;
1519 error (R
"(invalid value for color property "%s")",
1520 get_name ().c_str ());
1533 if (s.empty () || ! m_radio_val.contains (s, match))
1534 error (R
"(invalid value for double_radio property "%s")",
1535 get_name ().c_str ());
1537 if (m_current_type != radio_t || match != m_current_val)
1539 if (s.length () != match.length ())
1541 "%s: allowing %s to match %s value %s",
1542 "set", s.c_str (), get_name ().c_str (),
1544 m_current_val = match;
1545 m_current_type = radio_t;
1553 if (m_current_type != double_t || new_dval != m_dval)
1556 m_current_type = double_t;
1561 error (R
"(invalid value for double_radio property "%s")",
1562 get_name ().c_str ());
1573 if (m_type_constraints.size () > 0)
1575 if (m_type_constraints.find (v.
class_name ()) != m_type_constraints.end ())
1580 if (m_type_constraints.find (
"real") != m_type_constraints.end ()
1587 if (xok && m_size_constraints.size () > 0)
1590 int vlen = vdims.
ndims ();
1595 for (
auto it = m_size_constraints.cbegin ();
1596 ! xok && it != m_size_constraints.cend ();
1601 if (itdims.
ndims () == vlen)
1605 for (
int i = 0; xok && i < vlen; i++)
1609 if (itdims(i) != vdims(i))
1612 else if (itdims(i) == 0)
1630 if (m_minval.second && m_minval.first > v_mat(i))
1631 error (R
"(set: "%s" must be greater than or equal to %g)",
1632 get_name ().c_str (), m_minval.first);
1633 else if (! m_minval.second && m_minval.first >= v_mat(i))
1634 error (R
"(set: "%s" must be greater than %g)",
1635 get_name ().c_str (), m_minval.first);
1641 if (m_maxval.second && m_maxval.first < v_mat(i))
1642 error (R
"(set: "%s" must be less than or equal to %g)",
1643 get_name ().c_str (), m_maxval.first);
1644 else if (! m_maxval.second && m_maxval.first <= v_mat(i))
1645 error (R
"(set: "%s" must be less than %g)",
1646 get_name ().c_str (), m_maxval.first);
1649 if (m_finite_constraint == NO_CHECK) { }
1650 else if (m_finite_constraint == FINITE)
1654 error (R
"(set: "%s" must be finite)", get_name ().c_str ());
1656 else if (m_finite_constraint == NOT_NAN)
1660 error (R
"(set: "%s" must not be nan)", get_name ().c_str ());
1662 else if (m_finite_constraint == NOT_INF)
1666 error (R
"(set: "%s" must not be infinite)", get_name ().c_str ());
1677 if (m_data.type_name () == v.
type_name ())
1679 if (m_data.dims () == v.
dims ())
1682#define CHECK_ARRAY_EQUAL(T, F, A) \
1684 if (m_data.numel () == 1) \
1685 return m_data.F ## scalar_value () == \
1686 v.F ## scalar_value (); \
1692 const A m1 = m_data.F ## array_value (); \
1693 const T *d1 = m1.data (); \
1694 const A m2 = v.F ## array_value (); \
1695 const T *d2 = m2.data (); \
1699 for (int i = 0; flag && i < m_data.numel (); i++) \
1700 if (d1[i] != d2[i]) \
1707 if (m_data.is_double_type () || m_data.islogical ())
1709 else if (m_data.is_single_type ())
1711 else if (m_data.is_int8_type ())
1713 else if (m_data.is_int16_type ())
1715 else if (m_data.is_int32_type ())
1717 else if (m_data.is_int64_type ())
1719 else if (m_data.is_uint8_type ())
1721 else if (m_data.is_uint16_type ())
1723 else if (m_data.is_uint32_type ())
1725 else if (m_data.is_uint64_type ())
1734array_property::get_data_limits (
void)
1739 if (! m_data.isempty ())
1741 if (m_data.isinteger ())
1743 if (m_data.is_int8_type ())
1745 m_min_val, m_max_val, m_min_pos, m_max_neg);
1746 else if (m_data.is_uint8_type ())
1748 m_min_val, m_max_val, m_min_pos, m_max_neg);
1749 else if (m_data.is_int16_type ())
1751 m_min_val, m_max_val, m_min_pos, m_max_neg);
1752 else if (m_data.is_uint16_type ())
1754 m_min_val, m_max_val, m_min_pos, m_max_neg);
1755 else if (m_data.is_int32_type ())
1757 m_min_val, m_max_val, m_min_pos, m_max_neg);
1758 else if (m_data.is_uint32_type ())
1760 m_min_val, m_max_val, m_min_pos, m_max_neg);
1761 else if (m_data.is_int64_type ())
1763 m_min_val, m_max_val, m_min_pos, m_max_neg);
1764 else if (m_data.is_uint64_type ())
1766 m_min_val, m_max_val, m_min_pos, m_max_neg);
1770 m_min_val, m_max_val, m_min_pos, m_max_neg);
1780 if (! get ().isempty ())
1789 double dv = v.
xdouble_value (R
"(set: invalid graphics handle for property "%s")",
1790 get_name ().c_str ());
1797 bool type_ok =
true;
1798 if (gh.
ok () && ! m_type_constraints.empty ())
1801 graphics_object obj = gh_mgr.get_object (gh);
1803 for (
const auto& type : m_type_constraints)
1814 error (R
"(set: invalid graphics handle (= %g) for property "%s")",
1815 dv, get_name ().c_str ());
1817 error (R
"(set: invalid graphics object type for property "%s")",
1818 get_name ().c_str ());
1821 if (m_current_val != gh)
1849children_property::do_get_children (
bool return_hidden)
const
1851 Matrix retval (m_children_list.size (), 1);
1857 graphics_object go = gh_mgr.get_object (0);
1862 if (! props.is_showhiddenhandles ())
1864 for (
const auto& hchild : m_children_list)
1868 if (gh_mgr.is_handle_visible (kid))
1870 if (! return_hidden)
1871 retval(k++) = hchild;
1873 else if (return_hidden)
1874 retval(k++) = hchild;
1877 retval.resize (k, 1);
1881 for (
const auto& hchild : m_children_list)
1882 retval(k++) = hchild;
1889children_property::do_delete_children (
bool clear,
bool from_root)
1898 graphics_object go = gh_mgr.get_object (hchild);
1899 if (go.valid_object ()
1900 && ! go.get_properties ().is_beingdeleted ())
1901 gh_mgr.free (hchild, from_root);
1903 m_children_list.clear ();
1906 while (! m_children_list.empty ())
1910 graphics_object go = gh_mgr.get_object (hchild);
1911 if (go.valid_object ()
1912 && ! go.get_properties ().is_beingdeleted ())
1913 gh_mgr.free (hchild, from_root);
1918 m_children_list.clear ();
1922callback_property::validate (
const octave_value& v)
const
1960 m_set.insert (
reinterpret_cast<intptr_t
> (ptr));
1963 void erase (
const callback_property *ptr)
1965 m_set.erase (
reinterpret_cast<intptr_t
> (ptr));
1970 return m_set.find (
reinterpret_cast<intptr_t
> (ptr)) !=
m_set.end ();
1985callback_property::execute (
const octave_value& data)
const
1997 if (m_callback.is_defined () && ! m_callback.isempty ())
2002 gh_mgr.execute_callback (get_parent (), m_callback, data);
2019 std::string sv = (args.
length () > 0 ? args(0).string_value () :
"");
2021 retval = property (
new string_property (
name, h, sv));
2023 else if (type.
compare (
"any"))
2028 retval = property (
new any_property (
name, h, ov));
2030 else if (type.
compare (
"radio"))
2033 error (
"addproperty: missing possible values for radio property");
2035 std::string sv = args(0).xstring_value (
"addproperty: argument for radio property must be a string");
2037 retval = property (
new radio_property (
name, h, sv));
2040 retval.set (args(1));
2042 else if (type.
compare (
"double"))
2044 double dv = (args.
length () > 0 ? args(0).double_value () : 0.0);
2046 retval = property (
new double_property (
name, h, dv));
2048 else if (type.
compare (
"handle"))
2050 double hv = (args.
length () > 0 ? args(0).double_value ()
2055 retval = property (
new handle_property (
name, h, gh));
2057 else if (type.
compare (
"boolean"))
2059 retval = property (
new bool_property (
name, h,
false));
2062 retval.set (args(0));
2064 else if (type.
compare (
"data"))
2066 retval = property (
new array_property (
name, h,
Matrix ()));
2070 retval.set (args(0));
2075 else if (type.
compare (
"color"))
2077 color_values cv (0, 0, 0);
2081 rv = radio_values (args(1).string_value ());
2083 retval = property (
new color_property (
name, h, cv, rv));
2085 if (args.
length () > 0 && ! args(0).isempty ())
2086 retval.set (args(0));
2088 retval.set (rv.default_value ());
2095 error (
"addproperty: unsupported type for dynamic property (= %s)",
2100 std::map<caseless_str, graphics_object>::const_iterator it
2109 go = graphics_object (bgo);
2117 if (! go.valid_object ())
2118 error (
"addproperty: invalid object type (= %s)",
2121 property prop = go.get_properties ().get_property (go_rest);
2123 retval = prop.clone ();
2125 retval.set_parent (h);
2126 retval.set_name (
name);
2129 retval.set (args(0));
2140 graphics_object go = gh_mgr.get_object (h);
2144 Matrix children = go.get_properties ().get_all_children ();
2146 for (
int k = 0; k < children.
numel (); k++)
2158 graphics_object go = gh_mgr.get_object (h);
2162 Matrix children = go.get_properties ().get_all_children ();
2166 for (
int k = 0; k < children.
numel (); k++)
2178 m___graphics_toolkit__ = b.
get_name ();
2179 m___plot_stream__ =
Matrix ();
2188figure::properties::set___mouse_mode__ (
const octave_value& val_arg)
2190 std::string direction =
"in";
2198 if (modestr ==
"zoom in")
2200 val = modestr =
"zoom";
2203 else if (modestr ==
"zoom out")
2205 val = modestr =
"zoom";
2209 if (m___mouse_mode__.set (val,
true))
2211 std::string mode = m___mouse_mode__.current_value ();
2214 pm.
setfield (
"Enable", mode ==
"pan" ?
"on" :
"off");
2215 set___pan_mode__ (pm);
2218 rm.
setfield (
"Enable", mode ==
"rotate" ?
"on" :
"off");
2219 set___rotate_mode__ (rm);
2222 zm.
setfield (
"Enable", mode ==
"zoom" ?
"on" :
"off");
2223 zm.
setfield (
"Direction", direction);
2224 set___zoom_mode__ (zm);
2228 else if (modestr ==
"zoom")
2231 std::string curr_direction
2234 if (direction != curr_direction)
2236 zm.
setfield (
"Direction", direction);
2237 set___zoom_mode__ (zm);
2246figure::properties::update_handlevisibility (
void)
2253 octave_value cf = gh_mgr.get_object (0).get (
"currentfigure");
2259 octave_value kids = gh_mgr.get_object (0).get (
"children");
2262 gh_mgr.get_object (0).set (
"currentfigure",
Matrix ());
2266 gh_mgr.get_object (0).set (
"currentfigure", kidsarray(0));
2271 base_properties::update_handlevisibility ();
2279 graphics_object go = gh_mgr.get_object (h);
2281 if (go.isa (
"text"))
2286 tp.update_text_extent ();
2288 else if (go.isa (
"figure") || go.isa (
"uipanel") || go.isa (
"axes")
2289 || go.isa (
"hggroup"))
2291 Matrix ch = go.get_properties ().get_all_children ();
2295 if (go.isa (
"axes"))
2300 ap.sync_positions ();
2306figure::properties::update___device_pixel_ratio__ (
void)
2316 std::size_t offset = 0;
2318 std::size_t
len =
name.length ();
2329 pfx =
name.substr (0, 5);
2335 pfx =
name.substr (0, 6);
2341 pfx =
name.substr (0, 7);
2349 pfx =
name.substr (0, 9);
2356 pfx =
name.substr (0, 10);
2358 if (pfx.
compare (
"uipushtool"))
2362 pfx =
name.substr (0, 12);
2364 if (pfx.
compare (
"uitoogletool"))
2368 pfx =
name.substr (0, 13);
2370 if (pfx.
compare (
"uicontextmenu")
2371 || pfx.
compare (
"uibuttongroup"))
2385 std::string pname =
name.substr (offset);
2387 std::transform (pfx.begin (), pfx.end (), pfx.begin (), tolower);
2391 bool has_property =
false;
2393 has_property = axes::properties::has_core_property (pname);
2394 else if (pfx ==
"figure")
2395 has_property = figure::properties::has_core_property (pname);
2396 else if (pfx ==
"line")
2397 has_property = line::properties::has_core_property (pname);
2398 else if (pfx ==
"text")
2399 has_property = text::properties::has_core_property (pname);
2400 else if (pfx ==
"image")
2401 has_property = image::properties::has_core_property (pname);
2402 else if (pfx ==
"patch")
2403 has_property = patch::properties::has_core_property (pname);
2404 else if (pfx ==
"scatter")
2405 has_property = scatter::properties::has_core_property (pname);
2406 else if (pfx ==
"surface")
2407 has_property = surface::properties::has_core_property (pname);
2408 else if (pfx ==
"hggroup")
2409 has_property = hggroup::properties::has_core_property (pname);
2410 else if (pfx ==
"uimenu")
2411 has_property = uimenu::properties::has_core_property (pname);
2412 else if (pfx ==
"uicontrol")
2413 has_property = uicontrol::properties::has_core_property (pname);
2414 else if (pfx ==
"uibuttongroup")
2415 has_property = uibuttongroup::properties::has_core_property (pname);
2416 else if (pfx ==
"uipanel")
2417 has_property = uipanel::properties::has_core_property (pname);
2418 else if (pfx ==
"uicontextmenu")
2419 has_property = uicontextmenu::properties::has_core_property (pname);
2420 else if (pfx ==
"uitable")
2421 has_property = uitable::properties::has_core_property (pname);
2422 else if (pfx ==
"uitoolbar")
2423 has_property = uitoolbar::properties::has_core_property (pname);
2424 else if (pfx ==
"uipushtool")
2425 has_property = uipushtool::properties::has_core_property (pname);
2428 error (
"invalid %s property '%s'", pfx.c_str (), pname.c_str ());
2430 bool remove =
false;
2435 remove = (sval ==
"remove");
2438 pval_map_type& pval_map = m_plist_map[pfx];
2442 auto p = pval_map.find (pname);
2444 if (p != pval_map.end ())
2448 pval_map[pname] = val;
2453 error (
"invalid default property specification");
2461 std::size_t offset = 0;
2463 std::size_t
len =
name.length ();
2474 pfx =
name.substr (0, 5);
2480 pfx =
name.substr (0, 6);
2486 pfx =
name.substr (0, 7);
2494 pfx =
name.substr (0, 9);
2501 pfx =
name.substr (0, 10);
2503 if (pfx.
compare (
"uipushtool"))
2507 pfx =
name.substr (0, 12);
2509 if (pfx.
compare (
"uitoggletool"))
2513 pfx =
name.substr (0, 13);
2515 if (pfx.
compare (
"uicontextmenu")
2516 || pfx.
compare (
"uibuttongroup"))
2528 std::string pname =
name.substr (offset);
2530 std::transform (pfx.begin (), pfx.end (), pfx.begin (), tolower);
2534 plist_map_const_iterator p =
find (pfx);
2538 const pval_map_type& pval_map = p->second;
2540 pval_map_const_iterator q = pval_map.find (pname);
2542 if (q != pval_map.end ())
2552property_list::as_struct (
const std::string& prefix_arg)
const
2556 for (
auto p = begin (); p != end (); p++)
2558 std::string prefix = prefix_arg + p->first;
2560 for (
const auto& prop_val : p->second)
2561 m.
assign (prefix + prop_val.first, prop_val.second);
2572 int nargin = args.
length ();
2575 error (
"graphics_object::set: Nothing to set");
2577 for (
int i = 0; i < nargin; )
2579 if (args(i).isstruct () )
2581 set (args(i).map_value ());
2584 else if (i < nargin - 1)
2586 caseless_str pname = args(i).xstring_value (
"set: argument %d must be a property name", i);
2588 set_value_or_default (pname, val);
2592 error (
"set: invalid number of arguments");
2615 error (
"set: number of names must match number of value columns "
2616 "(%" OCTAVE_IDX_TYPE_FORMAT
" != %" OCTAVE_IDX_TYPE_FORMAT
")",
2626 set_value_or_default (pname, val);
2688 set_value_or_default (pname, val);
2776graphics_object::set_value_or_default (
const caseless_str& pname,
2785 if (sval ==
"default")
2787 default_val = get_default (pname);
2789 m_rep->set (pname, default_val);
2791 else if (sval ==
"factory")
2793 default_val = get_factory_default (pname);
2795 m_rep->set (pname, default_val);
2800 if (sval == R
"(\default)")
2801 m_rep->set (pname, "default");
2802 else if (sval == R
"(\factory)")
2803 m_rep->set (pname, "factory");
2805 m_rep->set (pname, val);
2809 m_rep->set (pname, val);
2833 static double maxrand = RAND_MAX + 2.0;
2835 return (rand () + 1.0) / maxrand;
2839gh_manager::get_handle (
bool integer_figure_handle)
2843 if (integer_figure_handle)
2852 while (m_handle_map.find (retval) != m_handle_map.end ())
2861 auto p = m_handle_free_list.begin ();
2863 if (p != m_handle_free_list.end ())
2866 m_handle_free_list.erase (p);
2884 graphics_object go = gh_mgr.get_object (val);
2886 return go && go.isa (
"figure");
2894 if (h.
value () == 0)
2895 error (
"graphics_handle::free: can't delete root object");
2897 auto p = m_handle_map.find (h);
2899 if (p == m_handle_map.end ())
2900 error (
"graphics_handle::free: invalid object %g", h.
value ());
2902 base_properties& bp = p->second.get_properties ();
2904 if (! p->second.valid_object () || bp.is_beingdeleted ())
2908 graphics_object parent_go =
nullptr;
2910 parent_go = get_object (parent_h);
2912 bp.set_beingdeleted (
true);
2915 p->second.remove_all_listeners ();
2917 bp.delete_children (
true, from_root);
2922 bp.execute_deletefcn ();
2925 p->second.finalize ();
2931 if ((! from_root ||
isfigure (h.
value ())) && parent_go.valid_object ()
2933 parent_go.remove_child (h);
2944 m_handle_map.erase (p);
2947 m_handle_free_list.insert
2956 auto p = m_handle_map.find (old_gh);
2958 if (p == m_handle_map.end ())
2959 error (
"graphics_handle::free: invalid object %g", old_gh.
value ());
2961 graphics_object go = p->second;
2963 m_handle_map.erase (p);
2965 m_handle_map[new_gh] = go;
2967 if (old_gh.
value () < 0)
2971 for (
auto& hfig : m_figure_list)
2987 graphics_object go = gh_mgr.get_object (h);
2989 go.set (pname, val);
2999 graphics_object go = gh_mgr.get_object (h);
3010 graphics_object go = gh_mgr.get_object (h);
3012 return go.get (pname);
3020 double hv = ov.
xdouble_value (
"%s: %s must be a graphics handle",
3021 who.c_str (), pname.c_str ());
3028 error (
"%s: invalid graphics handle (= %g) for %s",
3029 who.c_str (), hv, pname.c_str ());
3031 graphics_object go = gh_mgr.get_object (h);
3035 graphics_object parent_go = gh_mgr.get_object (parent_h);
3037 parent_go.remove_child (h);
3040 go.set (
"parent", new_parent.
value ());
3042 go.reparent (new_parent);
3075 graphics_object go = gh_mgr.get_object (h);
3078 if (! go.get_properties ().is_beingdeleted ())
3083 gh_mgr.free (h, from_root || go.isa (
"figure"));
3118 gh_mgr.execute_callback (h, closerequestfcn);
3134gh_manager::close_all_figures (
void)
3138 m_event_queue.clear ();
3143 Matrix hlist = figure_handle_list (
true);
3155 hlist = figure_handle_list (
true);
3167 hlist = figure_handle_list (
true);
3169 if (hlist.
numel () != 0)
3170 warning (
"gh_manager::close_all_figures: some graphics elements failed to close");
3174 m_callback_objects.clear ();
3182 graphics_object parent_go = gh_mgr.get_object (parent_h);
3184 parent_go.adopt (h);
3230 graphics_object go = gh_mgr.get_object (h);
3232 go.get_properties ().execute_createfcn ();
3240 graphics_object go = gh_mgr.get_object (h);
3260 else if (
state == 2)
3268 property_list::pval_map_type factory_pval)
3273 graphics_object go = gh_mgr.get_object (h);
3276 std::string go_name = go.get_properties ().graphics_object_name ();
3277 property_list::pval_map_type pval;
3278 go.build_user_defaults_map (pval, go_name);
3280 for (
const auto& p : pval)
3281 factory_pval[p.first] = p.second;
3287 for (
const auto& p : factory_pval)
3289 std::string pname = p.first;
3292 if (! go.has_readonly_property (pname)
3293 && pname.find (
"__") != 0 && pname.find (
"current") != 0
3294 && pname !=
"uicontextmenu" && pname !=
"parent")
3297 if (pname.find (
"mode") == (pname.length () - 4))
3298 pval[pname] = p.second;
3300 go.set (pname, p.second);
3305 for (
const auto& p : pval)
3306 go.set (p.first, p.second);
3314base_properties::set_from_list (base_graphics_object& bgo,
3315 property_list& defaults)
3317 std::string go_name = graphics_object_name ();
3319 property_list::plist_map_const_iterator plist = defaults.find (go_name);
3321 if (plist != defaults.end ())
3323 const property_list::pval_map_type pval_map = plist->second;
3325 for (
const auto& prop_val : pval_map)
3327 std::string pname = prop_val.first;
3331 bgo.set (pname, prop_val.second);
3333 catch (octave::execution_exception& ee)
3335 error (ee,
"error setting default property %s", pname.c_str ());
3358base_properties::get_dynamic (
const caseless_str& pname)
const
3360 std::map<caseless_str, property, cmp_caseless_str>::const_iterator it
3361 = m_all_props.find (pname);
3363 if (it == m_all_props.end ())
3364 error (R
"(get: unknown property "%s")", pname.c_str ());
3366 return it->second.get ();
3370base_properties::get_dynamic (
bool all)
const
3374 for (std::map<caseless_str, property, cmp_caseless_str>::const_iterator
3375 it = m_all_props.begin (); it != m_all_props.end (); ++it)
3376 if (all || ! it->second.is_hidden ())
3377 m.
assign (it->second.get_name (), it->second.get ());
3382std::set<std::string>
3383base_properties::dynamic_property_names (
void)
const
3385 return m_dynamic_properties;
3389base_properties::has_dynamic_property (
const std::string& pname)
const
3391 const std::set<std::string>& dynprops = dynamic_property_names ();
3393 if (dynprops.find (pname) != dynprops.end ())
3396 return m_all_props.find (pname) != m_all_props.end ();
3400base_properties::set_dynamic (
const caseless_str& pname,
3403 auto it = m_all_props.find (pname);
3405 if (it == m_all_props.end ())
3406 error (R
"(set: unknown property "%s")", pname.c_str ());
3408 it->second.set (val);
3410 m_dynamic_properties.insert (pname);
3416base_properties::get_property_dynamic (
const caseless_str& pname)
const
3418 std::map<caseless_str, property, cmp_caseless_str>::const_iterator it
3419 = m_all_props.find (pname);
3421 if (it == m_all_props.end ())
3422 error (R
"(get_property: unknown property "%s")", pname.c_str ());
3430 double hp = val.
xdouble_value (
"set: parent must be a graphics handle");
3431 if (hp == m___myhandle__)
3432 error (
"set: can not set object parent to be object itself");
3438 if (! new_parent.
ok ())
3439 error (
"set: invalid graphics handle (= %g) for parent", hp);
3442 graphics_object old_parent_go;
3443 old_parent_go = gh_mgr.get_object (get_parent ());
3445 if (old_parent_go.get_handle () != hp)
3446 old_parent_go.remove_child (m___myhandle__);
3451 graphics_object new_parent_go;
3452 new_parent_go = gh_mgr.get_object (new_parent);
3453 if (new_parent_go.get_parent () == m___myhandle__)
3456 new_parent_go.get_properties ().set_parent (get_parent ().as_octave_value ());
3477base_properties::mark_modified (
void)
3480 m___modified__ =
"on";
3487 graphics_object parent_go = gh_mgr.get_object (get_parent ());
3490 parent_go.mark_modified ();
3494base_properties::override_defaults (base_graphics_object& obj)
3499 graphics_object parent_go = gh_mgr.get_object (get_parent ());
3502 parent_go.override_defaults (obj);
3506base_properties::update_axis_limits (
const std::string& axis_type)
const
3511 graphics_object go = gh_mgr.get_object (m___myhandle__);
3514 go.update_axis_limits (axis_type);
3518base_properties::update_axis_limits (
const std::string& axis_type,
3524 graphics_object go = gh_mgr.get_object (m___myhandle__);
3527 go.update_axis_limits (axis_type, h);
3531base_properties::update_contextmenu (
void)
const
3533 if (m_contextmenu.get ().isempty ())
3539 graphics_object go = gh_mgr.get_object (m_contextmenu.get ());
3541 if (go && go.isa (
"uicontextmenu"))
3545 props.add_dependent_obj (m___myhandle__);
3552 return (m_handlevisibility.is (
"on")
3557base_properties::get_toolkit (
void)
const
3562 graphics_object go = gh_mgr.get_object (get_parent ());
3565 return go.get_toolkit ();
3571base_properties::update_boundingbox (
void)
3573 Matrix kids = get_children ();
3578 for (
int i = 0; i < kids.
numel (); i++)
3580 graphics_object go = gh_mgr.get_object (kids(i));
3582 if (go.valid_object ())
3583 go.get_properties ().update_boundingbox ();
3588base_properties::update_autopos (
const std::string& elem_type)
3593 graphics_object parent_go = gh_mgr.get_object (get_parent ());
3595 if (parent_go.valid_object ())
3596 parent_go.get_properties ().update_autopos (elem_type);
3600base_properties::update_handlevisibility (
void)
3610 graphics_object go (gh_mgr.get_object (get___myhandle__ ()));
3612 graphics_object fig (go.get_ancestor (
"figure"));
3614 if (fig.valid_object ())
3622 fig_props.set_currentobject (
Matrix ());
3666base_properties::add_listener (
const caseless_str& pname,
3670 property p = get_property (pname);
3673 p.add_listener (val, mode);
3677base_properties::delete_listener (
const caseless_str& pname,
3681 property p = get_property (pname);
3684 p.delete_listener (val, mode);
3688base_properties::get_children_of_type (
const caseless_str& chtype,
3691 std::list<graphics_object>& children_list)
const
3696 Matrix ch = get_children ();
3704 graphics_object go = gh_mgr.get_object (hkid);
3705 if ( get_invisible || go.get_properties ().is_visible () )
3707 if (go.isa (chtype))
3708 children_list.push_back (go);
3709 else if (traverse && go.isa (
"hggroup"))
3710 go.get_properties ().get_children_of_type (chtype,
3722base_graphics_object::update_axis_limits (
const std::string& axis_type)
3724 if (! valid_object ())
3725 error (
"base_graphics_object::update_axis_limits: invalid graphics object");
3730 graphics_object parent_go = gh_mgr.get_object (get_parent ());
3733 parent_go.update_axis_limits (axis_type);
3737base_graphics_object::update_axis_limits (
const std::string& axis_type,
3740 if (! valid_object ())
3741 error (
"base_graphics_object::update_axis_limits: invalid graphics object");
3746 graphics_object parent_go = gh_mgr.get_object (get_parent ());
3749 parent_go.update_axis_limits (axis_type, h);
3753base_graphics_object::remove_all_listeners (
void)
3759 for (
const auto& pm : m)
3771 property p = get_properties ().get_property (pm.first);
3774 p.delete_listener ();
3776 catch (
const octave::execution_exception&)
3778 octave::interpreter& interp
3781 interp.recover_from_exception ();
3787base_graphics_object::build_user_defaults_map (property_list::pval_map_type& def,
3788 const std::string go_name)
const
3790 property_list local_defaults = get_defaults_list ();
3791 const auto it = local_defaults.find (go_name);
3793 if (it != local_defaults.end ())
3795 property_list::pval_map_type pval_lst = it->second;
3796 for (
const auto& prop_val : pval_lst)
3798 std::string pname = prop_val.first;
3799 if (def.find (pname) == def.end ())
3800 def[pname] = prop_val.second;
3807 graphics_object parent_go = gh_mgr.get_object (get_parent ());
3810 parent_go.build_user_defaults_map (def, go_name);
3814base_graphics_object::reset_default_properties (
void)
3816 if (valid_object ())
3821 property_list::pval_map_type factory_pval
3822 = gh_mgr.get_object (0).get_factory_defaults_list ().find (type ())->second;
3824 remove_all_listeners ();
3830base_graphics_object::values_as_string (
void)
3832 if (! valid_object ())
3833 error (
"base_graphics_object::values_as_string: invalid graphics object");
3841 graphics_object go = gh_mgr.get_object (get_handle ());
3843 for (
const auto& pm : m)
3845 const auto& pname = pm.first;
3846 if (pname !=
"children" && ! go.has_readonly_property (pname))
3848 property p = get_properties ().get_property (pname);
3850 if (p.ok () && ! p.is_hidden ())
3852 retval +=
"\n\t" + std::string (pname) +
": ";
3854 retval += p.values_as_string ();
3859 if (! retval.empty ())
3866base_graphics_object::value_as_string (
const std::string& prop)
3870 if (! valid_object ())
3871 error (
"base_graphics_object::value_as_string: invalid graphics object");
3876 graphics_object go = gh_mgr.get_object (get_handle ());
3878 if (prop !=
"children" && ! go.has_readonly_property (prop))
3880 property p = get_properties ().get_property (prop);
3882 if (p.ok () && ! p.is_hidden ())
3885 retval += p.values_as_string ();
3889 if (! retval.empty ())
3896base_graphics_object::values_as_struct (
void)
3900 if (! valid_object ())
3901 error (
"base_graphics_object::values_as_struct: invalid graphics object");
3908 graphics_object go = gh_mgr.get_object (get_handle ());
3910 for (
const auto& pm : m)
3912 const auto& pname = pm.first;
3913 if (pname !=
"children" && ! go.has_readonly_property (pname))
3915 property p = get_properties ().get_property (pname);
3917 if (p.ok () && ! p.is_hidden ())
3920 retval.
assign (p.get_name (), p.values_as_cell ());
3951graphics_object::get_ancestor (
const std::string& obj_type)
const
3953 if (valid_object ())
3962 return gh_mgr.get_object (get_parent ()).get_ancestor (obj_type);
3966 return graphics_object ();
3971#include "graphics-props.cc"
3976root_figure::properties::set_callbackobject (
const octave_value& v)
3983 m_callbackobject = val;
3989root_figure::properties::set_currentfigure (
const octave_value& v)
3995 m_currentfigure = val;
4002 gh_mgr.push_figure (val);
4010figure::properties::set_integerhandle (
const octave_value& val)
4012 if (m_integerhandle.set (val,
true))
4014 bool int_fig_handle = m_integerhandle.is_on ();
4019 graphics_object this_go = gh_mgr.get_object (m___myhandle__);
4023 m___myhandle__ = gh_mgr.get_handle (int_fig_handle);
4025 gh_mgr.renumber_figure (old_myhandle, m___myhandle__);
4027 graphics_object parent_go = gh_mgr.get_object (get_parent ());
4029 base_properties& props = parent_go.get_properties ();
4031 props.renumber_child (old_myhandle, m___myhandle__);
4033 Matrix kids = get_children ();
4037 graphics_object kid = gh_mgr.get_object (kids(i));
4039 kid.get_properties ().renumber_parent (m___myhandle__);
4044 if (m___myhandle__ == cf)
4045 xset (0,
"currentfigure", m___myhandle__.value ());
4047 this_go.update (m_integerhandle.get_id ());
4056root_figure::properties::update_units (
void)
4058 std::string xunits = get_units ();
4062 double dpi = get_screenpixelsperinch ();
4064 if (xunits ==
"pixels")
4069 else if (xunits ==
"normalized")
4071 scrn_sz =
Matrix (1, 4, 1.0);
4075 else if (xunits ==
"inches")
4082 else if (xunits ==
"centimeters")
4086 scrn_sz(2) *= 2.54 / dpi;
4087 scrn_sz(3) *= 2.54 / dpi;
4089 else if (xunits ==
"points")
4093 scrn_sz(2) *= 72 / dpi;
4094 scrn_sz(3) *= 72 / dpi;
4096 else if (xunits ==
"characters")
4102 scrn_sz(2) *= 74.951 / 12.0 / dpi;
4103 scrn_sz(3) *= 74.951 / 12.0 / dpi;
4106 set_screensize (scrn_sz);
4110root_figure::properties::get_boundingbox (
bool,
const Matrix&)
const
4115 pos(2) = screen_size(0);
4116 pos(3) = screen_size(1);
4151 gh_mgr.pop_figure (h);
4157 base_properties::remove_child (h,
true);
4161root_figure::reset_default_properties (
void)
4164 m_default_properties = property_list ();
4166 remove_all_listeners ();
4168 m_properties.factory_defaults ());
4174figure::properties::set_currentaxes (
const octave_value& val)
4179 m_currentaxes = hax;
4185figure::properties::remove_child (
const graphics_handle& h,
bool from_root)
4187 base_properties::remove_child (h, from_root);
4189 if (h == m_currentaxes.handle_value ())
4193 Matrix kids = get_children ();
4202 graphics_object go = gh_mgr.get_object (kid);
4204 if (go.isa (
"axes"))
4206 new_currentaxes = kid;
4211 m_currentaxes = new_currentaxes;
4216figure::properties::get_number (
void)
const
4218 if (m_integerhandle.is_on ())
4219 return m___myhandle__.value ();
4225figure::properties::get_toolkit (
void)
const
4231figure::properties::set___graphics_toolkit__ (
const octave_value& val)
4234 error (
"set___graphics_toolkit__: toolkit must be a string");
4244 error (
"set___graphics_toolkit__: invalid graphics toolkit");
4246 if (nm != get___graphics_toolkit__ ())
4258 if (! get_currentaxes ().ok ())
4263 graphics_object go = gh_mgr.get_object (h);
4265 if (go.type () ==
"axes")
4289figure::properties::set_visible (
const octave_value& val)
4294 xset (0,
"currentfigure", m___myhandle__.value ());
4300figure::properties::get_boundingbox (
bool internal,
const Matrix&)
const
4304 get_position ().matrix_value () :
4305 get_outerposition ().matrix_value ());
4311 pos(1) = screen_size(1) - pos(1) - pos(3);
4317figure::properties::bbox2position (
const Matrix& bb)
const
4322 pos(1) = screen_size(1) - pos(1) - pos(3);
4330figure::properties::set_boundingbox (
const Matrix& bb,
bool internal,
4331 bool do_notify_toolkit)
4334 Matrix pos = bbox2position (bb);
4337 set_position (pos, do_notify_toolkit);
4339 set_outerposition (pos, do_notify_toolkit);
4343figure::properties::map_from_boundingbox (
double x,
double y)
const
4345 Matrix bb = get_boundingbox (
true);
4351 pos(1) = bb(3) - pos(1);
4360figure::properties::map_to_boundingbox (
double x,
double y)
const
4362 Matrix bb = get_boundingbox (
true);
4371 pos(1) = bb(3) - pos(1);
4377figure::properties::set_position (
const octave_value& v,
4378 bool do_notify_toolkit)
4381 bool modified =
false;
4383 old_bb = get_boundingbox (
true);
4384 modified = m_position.set (v,
false, do_notify_toolkit);
4385 new_bb = get_boundingbox (
true);
4387 if (old_bb != new_bb)
4389 if (old_bb(2) != new_bb(2) || old_bb(3) != new_bb(3))
4394 if (! get_resizefcn ().isempty ())
4395 gh_mgr.post_callback (m___myhandle__,
"resizefcn");
4397 if (! get_sizechangedfcn ().isempty ())
4398 gh_mgr.post_callback (m___myhandle__,
"sizechangedfcn");
4400 update_boundingbox ();
4406 m_position.run_listeners (GCB_POSTSET);
4410 if (m_paperpositionmode.is (
"auto"))
4411 m_paperposition.set (get_auto_paperposition ());
4415figure::properties::set_outerposition (
const octave_value& v,
4416 bool do_notify_toolkit)
4418 if (m_outerposition.set (v,
true, do_notify_toolkit))
4423figure::properties::set_paperunits (
const octave_value& val)
4429 error (
"set: can't set paperunits to normalized when papertype is custom");
4432 if (m_paperunits.set (val,
true))
4434 update_paperunits (old_paperunits);
4440figure::properties::set_papertype (
const octave_value& val)
4446 error (
"set: can't set paperunits to normalized when papertype is custom");
4448 if (m_papertype.set (val,
true))
4450 update_papertype ();
4458 Matrix retval (1, 2, 1.0);
4460 if (! punits.
compare (
"normalized"))
4465 if (punits.
compare (
"inches"))
4468 mm2units = 1 / 25.4;
4470 else if (punits.
compare (
"centimeters"))
4473 mm2units = 1 / 10.0;
4478 mm2units = 72.0 / 25.4;
4481 if (ptype.
compare (
"usletter"))
4483 retval(0) = 8.5 * in2units;
4484 retval(1) = 11.0 * in2units;
4486 else if (ptype.
compare (
"uslegal"))
4488 retval(0) = 8.5 * in2units;
4489 retval(1) = 14.0 * in2units;
4491 else if (ptype.
compare (
"tabloid"))
4493 retval(0) = 11.0 * in2units;
4494 retval(1) = 17.0 * in2units;
4496 else if (ptype.
compare (
"a0"))
4498 retval(0) = 841.0 * mm2units;
4499 retval(1) = 1189.0 * mm2units;
4501 else if (ptype.
compare (
"a1"))
4503 retval(0) = 594.0 * mm2units;
4504 retval(1) = 841.0 * mm2units;
4506 else if (ptype.
compare (
"a2"))
4508 retval(0) = 420.0 * mm2units;
4509 retval(1) = 594.0 * mm2units;
4511 else if (ptype.
compare (
"a3"))
4513 retval(0) = 297.0 * mm2units;
4514 retval(1) = 420.0 * mm2units;
4516 else if (ptype.
compare (
"a4"))
4518 retval(0) = 210.0 * mm2units;
4519 retval(1) = 297.0 * mm2units;
4521 else if (ptype.
compare (
"a5"))
4523 retval(0) = 148.0 * mm2units;
4524 retval(1) = 210.0 * mm2units;
4526 else if (ptype.
compare (
"b0"))
4528 retval(0) = 1029.0 * mm2units;
4529 retval(1) = 1456.0 * mm2units;
4531 else if (ptype.
compare (
"b1"))
4533 retval(0) = 728.0 * mm2units;
4534 retval(1) = 1028.0 * mm2units;
4536 else if (ptype.
compare (
"b2"))
4538 retval(0) = 514.0 * mm2units;
4539 retval(1) = 728.0 * mm2units;
4541 else if (ptype.
compare (
"b3"))
4543 retval(0) = 364.0 * mm2units;
4544 retval(1) = 514.0 * mm2units;
4546 else if (ptype.
compare (
"b4"))
4548 retval(0) = 257.0 * mm2units;
4549 retval(1) = 364.0 * mm2units;
4551 else if (ptype.
compare (
"b5"))
4553 retval(0) = 182.0 * mm2units;
4554 retval(1) = 257.0 * mm2units;
4556 else if (ptype.
compare (
"arch-a"))
4558 retval(0) = 9.0 * in2units;
4559 retval(1) = 12.0 * in2units;
4561 else if (ptype.
compare (
"arch-b"))
4563 retval(0) = 12.0 * in2units;
4564 retval(1) = 18.0 * in2units;
4566 else if (ptype.
compare (
"arch-c"))
4568 retval(0) = 18.0 * in2units;
4569 retval(1) = 24.0 * in2units;
4571 else if (ptype.
compare (
"arch-d"))
4573 retval(0) = 24.0 * in2units;
4574 retval(1) = 36.0 * in2units;
4576 else if (ptype.
compare (
"arch-e"))
4578 retval(0) = 36.0 * in2units;
4579 retval(1) = 48.0 * in2units;
4583 retval(0) = 8.5 * in2units;
4584 retval(1) = 11.0 * in2units;
4588 retval(0) = 11.0 * in2units;
4589 retval(1) = 17.0 * in2units;
4593 retval(0) = 17.0 * in2units;
4594 retval(1) = 22.0 * in2units;
4598 retval(0) = 22.0 * in2units;
4599 retval(1) = 34.0 * in2units;
4603 retval(0) = 34.0 * in2units;
4604 retval(1) = 43.0 * in2units;
4612figure::properties::get_auto_paperposition (
void)
4614 Matrix pos = get_position ().matrix_value ();
4621 if (funits ==
"normalized" || punits ==
"normalized")
4626 if (punits ==
"normalized")
4635 sz = get_papersize ().matrix_value ();
4637 pos(0) = sz(0)/2 - pos(2)/2;
4638 pos(1) = sz(1)/2 - pos(3)/2;
4727figure::properties::update_paperunits (
const caseless_str& old_paperunits)
4729 Matrix pos = get_paperposition ().matrix_value ();
4730 Matrix sz = get_papersize ().matrix_value ();
4737 std::string porient = get_paperorientation ();
4741 if (ptype.
compare (
"<custom>"))
4743 if (old_paperunits.
compare (
"centimeters"))
4748 else if (old_paperunits.
compare (
"points"))
4754 if (punits.
compare (
"centimeters"))
4759 else if (punits.
compare (
"points"))
4768 if (porient ==
"landscape")
4769 std::swap (sz(0), sz(1));
4782figure::properties::update_papertype (
void)
4784 std::string typ = get_papertype ();
4785 if (typ !=
"<custom>")
4788 if (get_paperorientation () ==
"landscape")
4789 std::swap (sz(0), sz(1));
4795 if (m_paperpositionmode.is (
"auto"))
4796 m_paperposition.set (get_auto_paperposition ());
4800figure::properties::update_papersize (
void)
4802 Matrix sz = get_papersize ().matrix_value ();
4805 std::swap (sz(0), sz(1));
4811 m_paperorientation.set (
"portrait");
4814 std::string punits = get_paperunits ();
4815 if (punits ==
"centimeters")
4820 else if (punits ==
"points")
4825 if (punits ==
"normalized")
4827 if (get_papertype () ==
"<custom>")
4828 error (
"set: can't set the papertype to <custom> when the paperunits is normalized");
4835 std::string ptype =
"<custom>";
4836 const double mm2in = 1.0 / 25.4;
4837 const double tol = 0.01;
4845 else if (
std::abs (sz(0) - 841.0 * mm2in)
4846 +
std::abs (sz(1) - 1198.0 * mm2in) < tol)
4848 else if (
std::abs (sz(0) - 594.0 * mm2in)
4849 +
std::abs (sz(1) - 841.0 * mm2in) < tol)
4851 else if (
std::abs (sz(0) - 420.0 * mm2in)
4852 +
std::abs (sz(1) - 594.0 * mm2in) < tol)
4854 else if (
std::abs (sz(0) - 297.0 * mm2in)
4855 +
std::abs (sz(1) - 420.0 * mm2in) < tol)
4857 else if (
std::abs (sz(0) - 210.0 * mm2in)
4858 +
std::abs (sz(1) - 297.0 * mm2in) < tol)
4860 else if (
std::abs (sz(0) - 148.0 * mm2in)
4861 +
std::abs (sz(1) - 210.0 * mm2in) < tol)
4863 else if (
std::abs (sz(0) - 1029.0 * mm2in)
4864 +
std::abs (sz(1) - 1456.0 * mm2in) < tol)
4866 else if (
std::abs (sz(0) - 728.0 * mm2in)
4867 +
std::abs (sz(1) - 1028.0 * mm2in) < tol)
4869 else if (
std::abs (sz(0) - 514.0 * mm2in)
4870 +
std::abs (sz(1) - 728.0 * mm2in) < tol)
4872 else if (
std::abs (sz(0) - 364.0 * mm2in)
4873 +
std::abs (sz(1) - 514.0 * mm2in) < tol)
4875 else if (
std::abs (sz(0) - 257.0 * mm2in)
4876 +
std::abs (sz(1) - 364.0 * mm2in) < tol)
4878 else if (
std::abs (sz(0) - 182.0 * mm2in)
4879 +
std::abs (sz(1) - 257.0 * mm2in) < tol)
4913 m_papertype.set (ptype);
4915 if (punits ==
"centimeters")
4920 else if (punits ==
"points")
4925 if (get_paperorientation () ==
"landscape")
4927 std::swap (sz(0), sz(1));
4931 if (m_paperpositionmode.is (
"auto"))
4932 m_paperposition.set (get_auto_paperposition ());
4968figure::properties::update_paperorientation (
void)
4970 std::string porient = get_paperorientation ();
4971 Matrix sz = get_papersize ().matrix_value ();
4972 if ((sz(0) > sz(1) && porient ==
"portrait")
4973 || (sz(0) < sz(1) && porient ==
"landscape"))
4975 std::swap (sz(0), sz(1));
4981 if (m_paperpositionmode.is (
"auto"))
4982 m_paperposition.set (get_auto_paperposition ());
5017 if (m_units.set (val,
true))
5019 update_units (old_units);
5025figure::properties::update_units (
const caseless_str& old_units)
5028 old_units, get_units (),
5051figure::properties::get_title (
void)
const
5054 if (! get_number ().isempty () && is_numbertitle ())
5056 std::ostringstream os;
5057 std::string nm = get_name ();
5059 os <<
"Figure " << m___myhandle__.value ();
5061 os <<
": " << get_name ();
5066 title = get_name ();
5087 graphics_object parent_go = gh_mgr.get_object (parent_h);
5089 retval = parent_go.get_default (
name);
5096figure::reset_default_properties (
void)
5099 m_default_properties = property_list ();
5100 property_list::pval_map_type plist = m_properties.factory_defaults ();
5102 plist.erase (
"units");
5103 plist.erase (
"position");
5104 plist.erase (
"outerposition");
5105 plist.erase (
"paperunits");
5106 plist.erase (
"paperposition");
5107 plist.erase (
"windowstyle");
5109 remove_all_listeners ();
5116axes::properties::init (
void)
5118 m_position.add_constraint (
dim_vector (1, 4));
5119 m_outerposition.add_constraint (
dim_vector (1, 4));
5120 m_tightinset.add_constraint (
dim_vector (1, 4));
5121 m_looseinset.add_constraint (
dim_vector (1, 4));
5122 m_colororder.add_constraint (
dim_vector (-1, 3));
5123 m_dataaspectratio.add_constraint (3);
5124 m_dataaspectratio.add_constraint (
"min", 0,
false);
5125 m_dataaspectratio.add_constraint (FINITE);
5126 m_plotboxaspectratio.add_constraint (3);
5127 m_plotboxaspectratio.add_constraint (
"min", 0,
false);
5128 m_plotboxaspectratio.add_constraint (FINITE);
5131 m_alim.add_constraint (2);
5132 m_alim.add_constraint (NOT_NAN);
5133 m_clim.add_constraint (2);
5134 m_clim.add_constraint (NOT_NAN);
5135 m_xlim.add_constraint (2);
5136 m_xlim.add_constraint (NOT_NAN);
5137 m_ylim.add_constraint (2);
5138 m_ylim.add_constraint (NOT_NAN);
5139 m_zlim.add_constraint (2);
5140 m_zlim.add_constraint (NOT_NAN);
5142 m_xtick.add_constraint (FINITE);
5144 m_ytick.add_constraint (FINITE);
5146 m_ztick.add_constraint (FINITE);
5147 m_ticklength.add_constraint (
dim_vector (1, 2));
5152 m_cameraposition.add_constraint (3);
5153 m_cameraposition.add_constraint (FINITE);
5154 m_cameratarget.add_constraint (3);
5155 m_cameratarget.add_constraint (FINITE);
5158 m_cameraupvector = upv;
5159 m_cameraupvector.add_constraint (3);
5160 m_cameraupvector.add_constraint (FINITE);
5161 m_cameraviewangle.add_constraint (FINITE);
5162 m_currentpoint.add_constraint (
dim_vector (2, 3));
5165 m_fontsize.add_constraint (
"min", 0.0,
false);
5166 m_gridalpha.add_constraint (
"min", 0.0,
true);
5167 m_gridalpha.add_constraint (
"max", 1.0,
true);
5168 m_labelfontsizemultiplier.add_constraint (
"min", 0.0,
false);
5169 m_linewidth.add_constraint (
"min", 0.0,
false);
5170 m_minorgridalpha.add_constraint (
"min", 0.0,
true);
5171 m_minorgridalpha.add_constraint (
"max", 1.0,
true);
5172 m_titlefontsizemultiplier.add_constraint (
"min", 0.0,
false);
5177 m_x_zlim.resize (1, 2);
5183 calc_ticklabels (m_xtick, m_xticklabel, m_xscale.is (
"log"),
5184 xaxislocation_is (
"origin"),
5185 m_yscale.is (
"log") ? 2 : (yaxislocation_is (
"origin") ? 0 :
5186 (yaxislocation_is (
"left") ? -1 : 1)), m_xlim);
5187 calc_ticklabels (m_ytick, m_yticklabel, m_yscale.is (
"log"),
5188 yaxislocation_is (
"origin"),
5189 m_xscale.is (
"log") ? 2 : (xaxislocation_is (
"origin") ? 0 :
5190 (xaxislocation_is (
"bottom") ? -1 : 1)), m_ylim);
5191 calc_ticklabels (m_ztick, m_zticklabel, m_zscale.is (
"log"),
false, 2, m_zlim);
5193 xset (m_xlabel.handle_value (),
"handlevisibility",
"off");
5194 xset (m_ylabel.handle_value (),
"handlevisibility",
"off");
5195 xset (m_zlabel.handle_value (),
"handlevisibility",
"off");
5196 xset (m_title.handle_value (),
"handlevisibility",
"off");
5198 xset (m_xlabel.handle_value (),
"horizontalalignment",
"center");
5199 xset (m_xlabel.handle_value (),
"horizontalalignmentmode",
"auto");
5200 xset (m_ylabel.handle_value (),
"horizontalalignment",
"center");
5201 xset (m_ylabel.handle_value (),
"horizontalalignmentmode",
"auto");
5202 xset (m_zlabel.handle_value (),
"horizontalalignment",
"right");
5203 xset (m_zlabel.handle_value (),
"horizontalalignmentmode",
"auto");
5204 xset (m_title.handle_value (),
"horizontalalignment",
"center");
5205 xset (m_title.handle_value (),
"horizontalalignmentmode",
"auto");
5207 xset (m_xlabel.handle_value (),
"verticalalignment",
"top");
5208 xset (m_xlabel.handle_value (),
"verticalalignmentmode",
"auto");
5209 xset (m_ylabel.handle_value (),
"verticalalignment",
"bottom");
5210 xset (m_ylabel.handle_value (),
"verticalalignmentmode",
"auto");
5211 xset (m_title.handle_value (),
"verticalalignment",
"bottom");
5212 xset (m_title.handle_value (),
"verticalalignmentmode",
"auto");
5214 xset (m_ylabel.handle_value (),
"rotation", 90.0);
5215 xset (m_ylabel.handle_value (),
"rotationmode",
"auto");
5217 xset (m_zlabel.handle_value (),
"visible",
"off");
5219 xset (m_xlabel.handle_value (),
"clipping",
"off");
5220 xset (m_ylabel.handle_value (),
"clipping",
"off");
5221 xset (m_zlabel.handle_value (),
"clipping",
"off");
5222 xset (m_title.handle_value (),
"clipping",
"off");
5224 xset (m_xlabel.handle_value (),
"__autopos_tag__",
"xlabel");
5225 xset (m_ylabel.handle_value (),
"__autopos_tag__",
"ylabel");
5226 xset (m_zlabel.handle_value (),
"__autopos_tag__",
"zlabel");
5227 xset (m_title.handle_value (),
"__autopos_tag__",
"title");
5229 double fs = m_labelfontsizemultiplier.double_value () *
5230 m_fontsize.double_value ();
5234 fs = m_titlefontsizemultiplier.double_value () * m_fontsize.double_value ();
5236 xset (m_title.handle_value (),
"fontweight", m_titlefontweight.get ());
5238 adopt (m_xlabel.handle_value ());
5239 adopt (m_ylabel.handle_value ());
5240 adopt (m_zlabel.handle_value ());
5241 adopt (m_title.handle_value ());
5244 tlooseinset(2) = 1-tlooseinset(0)-tlooseinset(2);
5245 tlooseinset(3) = 1-tlooseinset(1)-tlooseinset(3);
5246 m_looseinset = tlooseinset;
5273axes::properties::calc_tightbox (
const Matrix& init_pos)
5280 graphics_object go = gh_mgr.get_object (get_parent ());
5282 Matrix parent_bb = go.get_properties ().get_boundingbox (
true);
5286 update_ticklength ();
5288 Matrix ext = get_extent (
true,
true);
5289 ext(1) = parent_bb(3) - ext(1) - ext(3);
5294 if (ext(0) < pos(0))
5296 pos(2) += pos(0)-ext(0);
5299 if (ext(0)+ext(2) > pos(0)+pos(2))
5300 pos(2) = ext(0)+ext(2)-pos(0);
5302 if (ext(1) < pos(1))
5304 pos(3) += pos(1)-ext(1);
5307 if (ext(1)+ext(3) > pos(1)+pos(3))
5308 pos(3) = ext(1)+ext(3)-pos(1);
5314axes::properties::sync_positions (
void)
5317 if (m_positionconstraint.is (
"innerposition"))
5320 update_outerposition ();
5322 set_units (
"normalized");
5323 Matrix pos = m_position.get ().matrix_value ();
5324 Matrix outpos = m_outerposition.get ().matrix_value ();
5325 Matrix tightpos = calc_tightbox (pos);
5326 Matrix tinset (1, 4, 1.0);
5327 tinset(0) = pos(0)-tightpos(0);
5328 tinset(1) = pos(1)-tightpos(1);
5329 tinset(2) = tightpos(0)+tightpos(2)-pos(0)-pos(2);
5330 tinset(3) = tightpos(1)+tightpos(3)-pos(1)-pos(3);
5331 m_tightinset = tinset;
5332 set_units (old_units);
5333 update_transform ();
5334 if (m_positionconstraint.is (
"innerposition"))
5337 update_outerposition ();
5404axes::properties::set_text_child (handle_property& hp,
5405 const std::string& who,
5410 xset (hp.handle_value (),
"string", v);
5419 graphics_object go = gh_mgr.get_object (gh_mgr.lookup (v));
5421 if (go.isa (
"text"))
5427 error (
"set: expecting text graphics object or character string for %s property, found %s",
5428 who.c_str (), cname.c_str ());
5431 xset (val,
"handlevisibility",
"off");
5433 gh_mgr.free (hp.handle_value ());
5437 adopt (hp.handle_value ());
5443 set_text_child (m_xlabel,
"xlabel", v);
5444 xset (m_xlabel.handle_value (),
"positionmode",
"auto");
5445 xset (m_xlabel.handle_value (),
"rotationmode",
"auto");
5446 xset (m_xlabel.handle_value (),
"horizontalalignmentmode",
"auto");
5447 xset (m_xlabel.handle_value (),
"verticalalignmentmode",
"auto");
5448 xset (m_xlabel.handle_value (),
"clipping",
"off");
5449 xset (m_xlabel.handle_value (),
"color", get_xcolor ());
5450 xset (m_xlabel.handle_value (),
"__autopos_tag__",
"xlabel");
5451 update_xlabel_position ();
5457 set_text_child (m_ylabel,
"ylabel", v);
5458 xset (m_ylabel.handle_value (),
"positionmode",
"auto");
5459 xset (m_ylabel.handle_value (),
"rotationmode",
"auto");
5460 xset (m_ylabel.handle_value (),
"horizontalalignmentmode",
"auto");
5461 xset (m_ylabel.handle_value (),
"verticalalignmentmode",
"auto");
5462 xset (m_ylabel.handle_value (),
"clipping",
"off");
5463 xset (m_ylabel.handle_value (),
"color", get_ycolor ());
5464 xset (m_ylabel.handle_value (),
"__autopos_tag__",
"ylabel");
5465 update_ylabel_position ();
5471 set_text_child (m_zlabel,
"zlabel", v);
5472 xset (m_zlabel.handle_value (),
"positionmode",
"auto");
5473 xset (m_zlabel.handle_value (),
"rotationmode",
"auto");
5474 xset (m_zlabel.handle_value (),
"horizontalalignmentmode",
"auto");
5475 xset (m_zlabel.handle_value (),
"verticalalignmentmode",
"auto");
5476 xset (m_zlabel.handle_value (),
"clipping",
"off");
5477 xset (m_zlabel.handle_value (),
"color", get_zcolor ());
5478 xset (m_zlabel.handle_value (),
"__autopos_tag__",
"zlabel");
5479 update_zlabel_position ();
5485 set_text_child (m_title,
"title", v);
5486 xset (m_title.handle_value (),
"positionmode",
"auto");
5487 xset (m_title.handle_value (),
"horizontalalignment",
"center");
5488 xset (m_title.handle_value (),
"horizontalalignmentmode",
"auto");
5489 xset (m_title.handle_value (),
"verticalalignment",
"bottom");
5490 xset (m_title.handle_value (),
"verticalalignmentmode",
"auto");
5491 xset (m_title.handle_value (),
"clipping",
"off");
5492 xset (m_title.handle_value (),
"__autopos_tag__",
"title");
5493 update_title_position ();
5497axes::properties::set_defaults (base_graphics_object& bgo,
5498 const std::string& mode)
5507 assert (mode ==
"reset");
5516 m_alimmode =
"auto";
5517 m_climmode =
"auto";
5518 m_xlimmode =
"auto";
5519 m_ylimmode =
"auto";
5520 m_zlimmode =
"auto";
5522 m_ambientlightcolor =
Matrix (1, 3, 1.0);
5525 m_boxstyle =
"back";
5528 m_camerapositionmode =
"auto";
5529 m_cameratargetmode =
"auto";
5530 m_cameraupvectormode =
"auto";
5531 m_cameraviewanglemode =
"auto";
5537 m_clippingstyle =
"3dbox";
5539 m_color = color_values (
"white");
5541 m_colororderindex = 1.0;
5544 m_dataaspectratiomode =
"auto";
5546 m_fontangle =
"normal";
5547 m_fontname = OCTAVE_DEFAULT_FONTNAME;
5549 m_fontunits =
"points";
5550 m_fontsmoothing =
"on";
5551 m_fontweight =
"normal";
5554 m_gridalphamode =
"auto";
5555 m_gridcolor = color_values (0.15, 0.15, 0.15);
5556 m_gridcolormode =
"auto";
5557 m_gridlinestyle =
"-";
5559 m_labelfontsizemultiplier = 1.1;
5563 m_linestyleorder =
"-";
5564 m_linestyleorderindex = 1.0;
5568 m_minorgridalpha = 0.25;
5569 m_minorgridalphamode =
"auto";
5570 m_minorgridcolor = color_values (0.1, 0.1, 0.1);
5571 m_minorgridcolormode =
"auto";
5572 m_minorgridlinestyle =
":";
5574 m_nextplot =
"replace";
5577 m_plotboxaspectratiomode =
"auto";
5578 m_projection =
"orthographic";
5580 m_sortmethod =
"depth";
5583 m_tickdirmode =
"auto";
5584 m_ticklabelinterpreter =
"tex";
5587 m_tightinset =
Matrix (1, 4, 0.0);
5589 m_titlefontsizemultiplier = 1.1;
5590 m_titlefontweight =
"bold";
5592 Matrix tview (1, 2, 0.0);
5596 m_xaxislocation =
"bottom";
5598 m_xcolor = color_values (0.15, 0.15, 0.15);
5599 m_xcolormode =
"auto";
5602 m_xminorgrid =
"off";
5603 m_xminortick =
"off";
5604 m_xscale =
"linear";
5607 m_xticklabelmode =
"auto";
5608 m_xticklabelrotation = 0.0;
5609 m_xtickmode =
"auto";
5611 m_yaxislocation =
"left";
5613 m_ycolor = color_values (0.15, 0.15, 0.15);
5614 m_ycolormode =
"auto";
5617 m_yminorgrid =
"off";
5618 m_yminortick =
"off";
5619 m_yscale =
"linear";
5622 m_yticklabelmode =
"auto";
5623 m_yticklabelrotation = 0.0;
5624 m_ytickmode =
"auto";
5626 m_zcolor = color_values (0.15, 0.15, 0.15);
5627 m_zcolormode =
"auto";
5630 m_zminorgrid =
"off";
5631 m_zminortick =
"off";
5632 m_zscale =
"linear";
5635 m_zticklabelmode =
"auto";
5636 m_zticklabelrotation = 0.0;
5637 m_ztickmode =
"auto";
5648 graphics_object go = gh_mgr.get_object (m_xlabel.handle_value ());
5649 go.reset_default_properties ();
5650 go = gh_mgr.get_object (m_ylabel.handle_value ());
5651 go.reset_default_properties ();
5652 go = gh_mgr.get_object (m_zlabel.handle_value ());
5653 go.reset_default_properties ();
5654 go = gh_mgr.get_object (m_title.handle_value ());
5655 go.reset_default_properties ();
5657 xset (m_xlabel.handle_value (),
"handlevisibility",
"off");
5658 xset (m_ylabel.handle_value (),
"handlevisibility",
"off");
5659 xset (m_zlabel.handle_value (),
"handlevisibility",
"off");
5660 xset (m_title.handle_value (),
"handlevisibility",
"off");
5662 xset (m_xlabel.handle_value (),
"horizontalalignment",
"center");
5663 xset (m_xlabel.handle_value (),
"horizontalalignmentmode",
"auto");
5664 xset (m_ylabel.handle_value (),
"horizontalalignment",
"center");
5665 xset (m_ylabel.handle_value (),
"horizontalalignmentmode",
"auto");
5666 xset (m_zlabel.handle_value (),
"horizontalalignment",
"right");
5667 xset (m_zlabel.handle_value (),
"horizontalalignmentmode",
"auto");
5668 xset (m_title.handle_value (),
"horizontalalignment",
"center");
5669 xset (m_title.handle_value (),
"horizontalalignmentmode",
"auto");
5671 xset (m_xlabel.handle_value (),
"verticalalignment",
"top");
5672 xset (m_xlabel.handle_value (),
"verticalalignmentmode",
"auto");
5673 xset (m_ylabel.handle_value (),
"verticalalignment",
"bottom");
5674 xset (m_ylabel.handle_value (),
"verticalalignmentmode",
"auto");
5675 xset (m_title.handle_value (),
"verticalalignment",
"bottom");
5676 xset (m_title.handle_value (),
"verticalalignmentmode",
"auto");
5678 xset (m_ylabel.handle_value (),
"rotation", 90.0);
5679 xset (m_ylabel.handle_value (),
"rotationmode",
"auto");
5681 xset (m_zlabel.handle_value (),
"visible",
"off");
5683 xset (m_xlabel.handle_value (),
"clipping",
"off");
5684 xset (m_ylabel.handle_value (),
"clipping",
"off");
5685 xset (m_zlabel.handle_value (),
"clipping",
"off");
5686 xset (m_title.handle_value (),
"clipping",
"off");
5688 xset (m_xlabel.handle_value (),
"__autopos_tag__",
"xlabel");
5689 xset (m_ylabel.handle_value (),
"__autopos_tag__",
"ylabel");
5690 xset (m_zlabel.handle_value (),
"__autopos_tag__",
"zlabel");
5691 xset (m_title.handle_value (),
"__autopos_tag__",
"title");
5694 fs = m_labelfontsizemultiplier.double_value () * m_fontsize.double_value ();
5698 fs = m_titlefontsizemultiplier.double_value () * m_fontsize.double_value ();
5700 xset (m_title.handle_value (),
"fontweight", m_titlefontweight.get ());
5702 update_transform ();
5704 override_defaults (bgo);
5708axes::properties::get_colormap (
void)
const
5710 if (m___colormap__.get ().isempty ())
5715 graphics_object go (gh_mgr.get_object (get___myhandle__ ()));
5716 graphics_object go_f (go.get_ancestor (
"figure"));
5719 return figure_props.get_colormap ();
5722 return get___colormap__ ();
5726axes::properties::delete_text_child (handle_property& hp,
bool from_root)
5735 graphics_object go = gh_mgr.get_object (h);
5737 if (go.valid_object ())
5738 gh_mgr.free (h, from_root);
5746 if (! is_beingdeleted ())
5748 hp = gh_mgr.make_graphics_handle (
"text", m___myhandle__,
false,
false);
5750 xset (hp.handle_value (),
"handlevisibility",
"off");
5752 adopt (hp.handle_value ());
5757axes::properties::remove_child (
const graphics_handle& h,
bool from_root)
5762 graphics_object go = gh_mgr.get_object (h);
5764 if (m_xlabel.handle_value ().ok () && h == m_xlabel.handle_value ())
5766 delete_text_child (m_xlabel, from_root);
5767 update_xlabel_position ();
5769 else if (m_ylabel.handle_value ().ok () && h == m_ylabel.handle_value ())
5771 delete_text_child (m_ylabel, from_root);
5772 update_ylabel_position ();
5774 else if (m_zlabel.handle_value ().ok () && h == m_zlabel.handle_value ())
5776 delete_text_child (m_zlabel, from_root);
5777 update_zlabel_position ();
5779 else if (m_title.handle_value ().ok () && h == m_title.handle_value ())
5781 delete_text_child (m_title, from_root);
5782 update_title_position ();
5784 else if (get_num_lights () > 0 && go.isa (
"light")
5785 && go.get_properties ().is_visible ())
5786 decrease_num_lights ();
5788 if (go.valid_object ())
5789 base_properties::remove_child (h, from_root);
5798 graphics_object go (gh_mgr.get_object (h));
5800 if (go.isa (
"light") && go.get_properties ().is_visible ())
5801 increase_num_lights ();
5811 if (xlimmode_is (
"auto"))
5812 update_axis_limits (
"xlim");
5814 if (ylimmode_is (
"auto"))
5815 update_axis_limits (
"ylim");
5817 if (zlimmode_is (
"auto"))
5818 update_axis_limits (
"zlim");
5820 if (climmode_is (
"auto"))
5821 update_axis_limits (
"clim");
5823 if (climmode_is (
"auto"))
5824 update_axis_limits (
"alim");
5832 for (
int i = 0; i < 4; i++)
5929 double fact = 1.0 / sqrt (v(0)*v(0)+v(1)*v(1)+v(2)*v(2));
5930 scale (v, fact, fact, fact);
5936 return (v1(0)*
v2(0)+v1(1)*
v2(1)+v1(2)*
v2(2));
5942 return sqrt (
dot (v, v));
5950 r(0) = v1(1)*
v2(2) - v1(2)*
v2(1);
5951 r(1) = v1(2)*
v2(0) - v1(0)*
v2(2);
5952 r(2) = v1(0)*
v2(1) - v1(1)*
v2(0);
5960 static double data[32] =
5973 memcpy (m.
fortran_vec (), data, sizeof (
double)*32);
5995axes::properties::update_camera (
void)
5997 double xd = (xdir_is (
"normal") ? 1 : -1);
5998 double yd = (ydir_is (
"normal") ? 1 : -1);
5999 double zd = (zdir_is (
"normal") ? 1 : -1);
6001 Matrix xlimits = m_sx.scale (get_xlim ().matrix_value ());
6002 Matrix ylimits = m_sy.scale (get_ylim ().matrix_value ());
6003 Matrix zlimits = m_sz.scale (get_zlim ().matrix_value ());
6005 double xo = xlimits(xd > 0 ? 0 : 1);
6006 double yo = ylimits(yd > 0 ? 0 : 1);
6007 double zo = zlimits(zd > 0 ? 0 : 1);
6009 Matrix pb = get_plotboxaspectratio ().matrix_value ();
6011 bool autocam = (camerapositionmode_is (
"auto")
6012 && cameratargetmode_is (
"auto")
6013 && cameraupvectormode_is (
"auto")
6014 && cameraviewanglemode_is (
"auto"));
6015 bool dowarp = (autocam && dataaspectratiomode_is (
"auto")
6016 && plotboxaspectratiomode_is (
"auto"));
6022 if (cameratargetmode_is (
"auto"))
6024 c_center(0) = (xlimits(0) + xlimits(1)) / 2;
6025 c_center(1) = (ylimits(0) + ylimits(1)) / 2;
6026 c_center(2) = (zlimits(0) + zlimits(1)) / 2;
6031 c_center =
cam2xform (get_cameratarget ().matrix_value ());
6033 if (camerapositionmode_is (
"auto"))
6035 Matrix tview = get_view ().matrix_value ();
6036 double az = tview(0);
6037 double el = tview(1);
6038 double d = 5 * sqrt (pb(0)*pb(0) + pb(1)*pb(1) + pb(2)*pb(2));
6040 if (el == 90 || el == -90)
6046 c_eye(0) =
d * cos (el) * sin (az);
6047 c_eye(1) = -
d* cos (el) * cos (az);
6048 c_eye(2) =
d * sin (el);
6050 c_eye(0) = c_eye(0)*(xlimits(1)-xlimits(0))/(xd*pb(0))+c_center(0);
6051 c_eye(1) = c_eye(1)*(ylimits(1)-ylimits(0))/(yd*pb(1))+c_center(1);
6052 c_eye(2) = c_eye(2)*(zlimits(1)-zlimits(0))/(zd*pb(2))+c_center(2);
6057 c_eye =
cam2xform (get_cameraposition ().matrix_value ());
6059 if (cameraupvectormode_is (
"auto"))
6061 Matrix tview = get_view ().matrix_value ();
6062 double az = tview(0);
6063 double el = tview(1);
6065 if (el == 90 || el == -90)
6068 * sin (az*M_PI/180.0)*(xlimits(1)-xlimits(0))/pb(0);
6070 * cos (az*M_PI/180.0)*(ylimits(1)-ylimits(0))/pb(1);
6078 c_upv =
cam2xform (get_cameraupvector ().matrix_value ());
6089 scale (x_pre, pb(0), pb(1), pb(2));
6091 scale (x_pre, xd/(xlimits(1)-xlimits(0)), yd/(ylimits(1)-ylimits(0)),
6092 zd/(zlimits(1)-zlimits(0)));
6095 xform (c_eye, x_pre);
6096 xform (c_center, x_pre);
6097 scale (c_upv, pb(0)/(xlimits(1)-xlimits(0)), pb(1)/(ylimits(1)-ylimits(0)),
6098 pb(2)/(zlimits(1)-zlimits(0)));
6099 translate (c_center, -c_eye(0), -c_eye(1), -c_eye(2));
6107 double fa = 1 / sqrt (1 -
f(2)*
f(2));
6108 scale (UP, fa, fa, fa);
6114 scale (x_view, 1, 1, -1);
6116 l(0, 0) = s(0); l(0, 1) = s(1); l(0, 2) = s(2);
6117 l(1, 0) = u(0); l(1, 1) = u(1); l(1, 2) = u(2);
6118 l(2, 0) = -
f(0); l(2, 1) = -
f(1); l(2, 2) = -
f(2);
6119 x_view = x_view * l;
6120 translate (x_view, -c_eye(0), -c_eye(1), -c_eye(2));
6121 scale (x_view, pb(0), pb(1), pb(2));
6127 double xM = cmax(0) - cmin(0);
6128 double yM = cmax(1) - cmin(1);
6130 Matrix bb = get_boundingbox (
true);
6134 if (cameraviewanglemode_is (
"auto"))
6141 if (
false && dowarp)
6142 af = (1.0 / (xM > yM ? xM : yM));
6145 if ((bb(2)/bb(3)) > (xM/yM))
6150 v_angle = 2 * (180.0 / M_PI) *
atan (1 / (2 * af *
norm (
F)));
6152 m_cameraviewangle = v_angle;
6155 v_angle = get_cameraviewangle ();
6157 double pf = 1 / (2 * tan ((v_angle / 2) * M_PI / 180.0) *
norm (
F));
6158 scale (x_projection, pf, pf, 1);
6164 translate (x_viewport, bb(0)+bb(2)/2, bb(1)+bb(3)/2, 0);
6165 scale (x_viewport, bb(2)/xM, -bb(3)/yM, 1);
6172 if ((bb(2)/bb(3)) > (xM/yM))
6178 pix = (bb(2) < bb(3) ? bb(2) : bb(3));
6179 translate (x_viewport, bb(0)+bb(2)/2, bb(1)+bb(3)/2, 0);
6180 scale (x_viewport, pix, -pix, 1);
6183 x_normrender = x_viewport * x_projection * x_view;
6189 m_x_zlim(0) = cmin(2);
6190 m_x_zlim(1) = cmax(2);
6192 m_x_render = x_normrender;
6193 scale (m_x_render, xd/(xlimits(1)-xlimits(0)), yd/(ylimits(1)-ylimits(0)),
6194 zd/(zlimits(1)-zlimits(0)));
6197 m_x_render_inv = m_x_render.inverse ();
6201 m_x_gl_mat1 = x_view;
6202 scale (m_x_gl_mat1, xd/(xlimits(1)-xlimits(0)), yd/(ylimits(1)-ylimits(0)),
6203 zd/(zlimits(1)-zlimits(0)));
6205 m_x_gl_mat2 = x_viewport * x_projection;
6211axes::properties::update_axes_layout (
void)
6216 graphics_xform
xform = get_transform ();
6218 double xd = (xdir_is (
"normal") ? 1 : -1);
6219 double yd = (ydir_is (
"normal") ? 1 : -1);
6220 double zd = (zdir_is (
"normal") ? 1 : -1);
6222 const Matrix xlims =
xform.xscale (get_xlim ().matrix_value ());
6223 const Matrix ylims =
xform.yscale (get_ylim ().matrix_value ());
6224 const Matrix zlims =
xform.zscale (get_zlim ().matrix_value ());
6226 double x_min, x_max, y_min, y_max, z_min, z_max;
6227 x_min = xlims(0), x_max = xlims(1);
6228 y_min = ylims(0), y_max = ylims(1);
6229 z_min = zlims(0), z_max = zlims(1);
6233 m_xstate = m_ystate = m_zstate = AXE_ANY_DIR;
6235 p1 =
xform.transform (x_min, (y_min+y_max)/2, (z_min+z_max)/2,
false);
6236 p2 =
xform.transform (x_max, (y_min+y_max)/2, (z_min+z_max)/2,
false);
6239 dir(2) = (p2(2) - p1(2));
6240 if (dir(0) == 0 && dir(1) == 0)
6241 m_xstate = AXE_DEPTH_DIR;
6242 else if (dir(2) == 0)
6245 m_xstate = AXE_VERT_DIR;
6246 else if (dir(1) == 0)
6247 m_xstate = AXE_HORZ_DIR;
6253 m_xPlane = (dir(0) > 0 ? x_max : x_min);
6255 m_xPlane = (dir(1) < 0 ? x_max : x_min);
6258 m_xPlane = (dir(2) < 0 ? x_min : x_max);
6260 m_xPlaneN = (m_xPlane == x_min ? x_max : x_min);
6261 m_fx = (x_max - x_min) / sqrt (dir(0)*dir(0) + dir(1)*dir(1));
6263 p1 =
xform.transform ((x_min + x_max)/2, y_min, (z_min + z_max)/2,
false);
6264 p2 =
xform.transform ((x_min + x_max)/2, y_max, (z_min + z_max)/2,
false);
6267 dir(2) = (p2(2) - p1(2));
6268 if (dir(0) == 0 && dir(1) == 0)
6269 m_ystate = AXE_DEPTH_DIR;
6270 else if (dir(2) == 0)
6273 m_ystate = AXE_VERT_DIR;
6274 else if (dir(1) == 0)
6275 m_ystate = AXE_HORZ_DIR;
6281 m_yPlane = (dir(0) > 0 ? y_max : y_min);
6283 m_yPlane = (dir(1) < 0 ? y_max : y_min);
6286 m_yPlane = (dir(2) < 0 ? y_min : y_max);
6288 m_yPlaneN = (m_yPlane == y_min ? y_max : y_min);
6289 m_fy = (y_max - y_min) / sqrt (dir(0)*dir(0) + dir(1)*dir(1));
6291 p1 =
xform.transform ((x_min + x_max)/2, (y_min + y_max)/2, z_min,
false);
6292 p2 =
xform.transform ((x_min + x_max)/2, (y_min + y_max)/2, z_max,
false);
6295 dir(2) = (p2(2) - p1(2));
6296 if (dir(0) == 0 && dir(1) == 0)
6297 m_zstate = AXE_DEPTH_DIR;
6298 else if (dir(2) == 0)
6301 m_zstate = AXE_VERT_DIR;
6302 else if (dir(1) == 0)
6303 m_zstate = AXE_HORZ_DIR;
6309 m_zPlane = (dir(0) > 0 ? z_min : z_max);
6311 m_zPlane = (dir(1) < 0 ? z_min : z_max);
6314 m_zPlane = (dir(2) < 0 ? z_min : z_max);
6316 m_zPlaneN = (m_zPlane == z_min ? z_max : z_min);
6317 m_fz = (z_max - z_min) / sqrt (dir(0)*dir(0) + dir(1)*dir(1));
6321 m_xySym = (xd*yd*(m_xPlane-m_xPlaneN)*(m_yPlane-m_yPlaneN) > 0);
6322 m_zSign = (zd*(m_zPlane-m_zPlaneN) <= 0);
6323 m_xyzSym = (m_zSign ? m_xySym : ! m_xySym);
6324 m_xpTick = (m_zSign ? m_xPlaneN : m_xPlane);
6325 m_ypTick = (m_zSign ? m_yPlaneN : m_yPlane);
6326 m_zpTick = (m_zSign ? m_zPlane : m_zPlaneN);
6327 m_xpTickN = (m_zSign ? m_xPlane : m_xPlaneN);
6328 m_ypTickN = (m_zSign ? m_yPlane : m_yPlaneN);
6329 m_zpTickN = (m_zSign ? m_zPlaneN : m_zPlane);
6334 m_layer2Dtop =
false;
6335 if (m_xstate == AXE_HORZ_DIR && m_ystate == AXE_VERT_DIR)
6337 Matrix ylimits = get_ylim ().matrix_value ();
6338 if (xaxislocation_is (
"top")
6339 || (yscale_is (
"log") && xaxislocation_is (
"origin")
6340 && (ylimits(1) < 0.)))
6342 std::swap (m_yPlane, m_yPlaneN);
6345 m_ypTick = m_yPlaneN;
6346 m_ypTickN = m_yPlane;
6347 Matrix xlimits = get_xlim ().matrix_value ();
6348 if (yaxislocation_is (
"right")
6349 || (xscale_is (
"log") && yaxislocation_is (
"origin")
6350 && (xlimits(1) < 0.)))
6352 std::swap (m_xPlane, m_xPlaneN);
6355 m_xpTick = m_xPlaneN;
6356 m_xpTickN = m_xPlane;
6357 if (layer_is (
"top"))
6359 m_zpTick = m_zPlaneN;
6360 m_layer2Dtop =
true;
6363 m_zpTick = m_zPlane;
6366 Matrix viewmat = get_view ().matrix_value ();
6367 m_nearhoriz =
std::abs (viewmat(1)) <= 5;
6368 m_is2D = viewmat(1) == 90;
6370 update_ticklength ();
6374axes::properties::update_ticklength (
void)
6376 bool mode2D = (((m_xstate > AXE_DEPTH_DIR ? 1 : 0) +
6377 (m_ystate > AXE_DEPTH_DIR ? 1 : 0) +
6378 (m_zstate > AXE_DEPTH_DIR ? 1 : 0)) == 2);
6380 if (tickdirmode_is (
"auto"))
6381 m_tickdir.set (mode2D ?
"in" :
"out",
true);
6383 double ticksign = (tickdir_is (
"in") ? -1 : 1);
6385 Matrix bbox = get_boundingbox (
true);
6386 Matrix ticklen = get_ticklength ().matrix_value ();
6387 ticklen(0) *=
std::max (bbox(2), bbox(3));
6390 ticklen(1) *= (0.76 *
std::max (bbox(2), bbox(3)));
6392 m_xticklen = ticksign * (mode2D ? ticklen(0) : ticklen(1));
6393 m_yticklen = ticksign * (mode2D ? ticklen(0) : ticklen(1));
6394 m_zticklen = ticksign * (mode2D ? ticklen(0) : ticklen(1));
6396 double offset = get___fontsize_points__ () / 2;
6398 m_xtickoffset = (mode2D ?
std::max (0., m_xticklen) :
std::
abs (m_xticklen)) +
6399 (m_xstate == AXE_HORZ_DIR ? offset*1.5 : offset);
6400 m_ytickoffset = (mode2D ?
std::max (0., m_yticklen) :
std::
abs (m_yticklen)) +
6401 (m_ystate == AXE_HORZ_DIR ? offset*1.5 : offset);
6402 m_ztickoffset = (mode2D ?
std::max (0., m_zticklen) :
std::
abs (m_zticklen)) +
6403 (m_zstate == AXE_HORZ_DIR ? offset*1.5 : offset);
6405 update_xlabel_position ();
6406 update_ylabel_position ();
6407 update_zlabel_position ();
6408 update_title_position ();
6432 const graphics_xform&
xform,
6437 std::string to_units = props.get_units ();
6439 if (to_units !=
"data")
6445 retval(0) = v(0) - bbox(0) + 1;
6446 retval(1) = bbox(1) + bbox(3) - v(1) + 1;
6461axes::properties::update_xlabel_position (
void)
6469 graphics_object go = gh_mgr.get_object (get_xlabel ());
6471 if (! go.valid_object ())
6477 bool isempty = xlabel_props.get_string ().isempty ();
6484 if (xlabel_props.horizontalalignmentmode_is (
"auto"))
6486 xlabel_props.set_horizontalalignment
6487 (m_xstate > AXE_DEPTH_DIR ?
"center" : (m_xyzSym ?
"left" :
"right"));
6489 xlabel_props.set_horizontalalignmentmode (
"auto");
6492 if (xlabel_props.verticalalignmentmode_is (
"auto"))
6494 xlabel_props.set_verticalalignment
6495 (m_xstate == AXE_VERT_DIR || m_x2Dtop ?
"bottom" :
"top");
6497 xlabel_props.set_verticalalignmentmode (
"auto");
6501 if (xlabel_props.positionmode_is (
"auto")
6502 || xlabel_props.rotationmode_is (
"auto"))
6504 graphics_xform
xform = get_transform ();
6507 ext = get_ticklabel_extents (get_xtick ().matrix_value (),
6508 get_xticklabel ().string_vector_value (),
6509 get_xlim ().matrix_value ());
6512 double wmax = ext(0) + margin;
6513 double hmax = ext(1) + margin;
6524 p =
xform.transform (p(0), p(1), p(2),
false);
6529 p(0) += (m_xyzSym ? wmax : -wmax);
6539 p(1) += (m_x2Dtop ? -hmax : hmax);
6543 if (xlabel_props.positionmode_is (
"auto"))
6545 p =
xform.untransform (p(0), p(1), p(2),
true);
6548 get_extent (
false));
6551 xlabel_props.set_positionmode (
"auto");
6554 if (! isempty && xlabel_props.rotationmode_is (
"auto"))
6556 xlabel_props.set_rotation (angle);
6557 xlabel_props.set_rotationmode (
"auto");
6565axes::properties::update_ylabel_position (
void)
6573 graphics_object go = gh_mgr.get_object (get_ylabel ());
6575 if (! go.valid_object ())
6581 bool isempty = ylabel_props.get_string ().isempty ();
6588 if (ylabel_props.horizontalalignmentmode_is (
"auto"))
6590 ylabel_props.set_horizontalalignment
6591 (m_ystate > AXE_DEPTH_DIR ?
"center" : (! m_xyzSym ?
"left" :
"right"));
6593 ylabel_props.set_horizontalalignmentmode (
"auto");
6596 if (ylabel_props.verticalalignmentmode_is (
"auto"))
6598 ylabel_props.set_verticalalignment
6599 (m_ystate == AXE_VERT_DIR && ! m_y2Dright ?
"bottom" :
"top");
6601 ylabel_props.set_verticalalignmentmode (
"auto");
6605 if (ylabel_props.positionmode_is (
"auto")
6606 || ylabel_props.rotationmode_is (
"auto"))
6608 graphics_xform
xform = get_transform ();
6612 ext = get_ticklabel_extents (get_ytick ().matrix_value (),
6613 get_yticklabel ().string_vector_value (),
6614 get_ylim ().matrix_value ());
6616 double wmax = ext(0) + margin;
6617 double hmax = ext(1) + margin;
6628 p =
xform.transform (p(0), p(1), p(2),
false);
6633 p(0) += (! m_xyzSym ? wmax : -wmax);
6638 p(0) += (m_y2Dright ? wmax : -wmax);
6647 if (ylabel_props.positionmode_is (
"auto"))
6649 p =
xform.untransform (p(0), p(1), p(2),
true);
6652 get_extent (
false));
6655 ylabel_props.set_positionmode (
"auto");
6658 if (! isempty && ylabel_props.rotationmode_is (
"auto"))
6660 ylabel_props.set_rotation (angle);
6661 ylabel_props.set_rotationmode (
"auto");
6669axes::properties::update_zlabel_position (
void)
6677 graphics_object go = gh_mgr.get_object (get_zlabel ());
6679 if (! go.valid_object ())
6685 bool camAuto = cameraupvectormode_is (
"auto");
6686 bool isempty = zlabel_props.get_string ().isempty ();
6693 if (zlabel_props.horizontalalignmentmode_is (
"auto"))
6695 zlabel_props.set_horizontalalignment
6696 ((m_zstate > AXE_DEPTH_DIR || camAuto) ?
"center" :
"right");
6698 zlabel_props.set_horizontalalignmentmode (
"auto");
6701 if (zlabel_props.verticalalignmentmode_is (
"auto"))
6703 zlabel_props.set_verticalalignment
6704 (m_zstate == AXE_VERT_DIR
6705 ?
"bottom" : ((m_zSign || camAuto) ?
"bottom" :
"top"));
6707 zlabel_props.set_verticalalignmentmode (
"auto");
6711 if (zlabel_props.positionmode_is (
"auto")
6712 || zlabel_props.rotationmode_is (
"auto"))
6714 graphics_xform
xform = get_transform ();
6717 ext = get_ticklabel_extents (get_ztick ().matrix_value (),
6718 get_zticklabel ().string_vector_value (),
6719 get_zlim ().matrix_value ());
6722 double wmax = ext(0) + margin;
6723 double hmax = ext(1) + margin;
6730 (m_zpTickN + m_zpTick)/2);
6739 (m_zpTickN + m_zpTick)/2);
6746 p =
xform.transform (p(0), p(1), p(2),
false);
6774 if (zlabel_props.positionmode_is (
"auto"))
6776 p =
xform.untransform (p(0), p(1), p(2),
true);
6779 get_extent (
false));
6782 zlabel_props.set_positionmode (
"auto");
6785 if (! isempty && zlabel_props.rotationmode_is (
"auto"))
6787 zlabel_props.set_rotation (angle);
6788 zlabel_props.set_rotationmode (
"auto");
6796axes::properties::update_title_position (
void)
6804 graphics_object go = gh_mgr.get_object (get_title ());
6806 if (! go.valid_object ())
6814 if (title_props.positionmode_is (
"auto"))
6816 graphics_xform
xform = get_transform ();
6819 Matrix bbox = get_extent (
false);
6823 (m_x_zlim(0) + m_x_zlim(1))/2);
6828 ext = get_ticklabel_extents (get_xtick ().matrix_value (),
6829 get_xticklabel ().string_vector_value (),
6830 get_xlim ().matrix_value ());
6834 p =
xform.untransform (p(0), p(1), p(2),
true);
6839 title_props.set_positionmode (
"auto");
6844axes::properties::update_autopos (
const std::string& elem_type)
6846 if (elem_type ==
"xlabel")
6847 update_xlabel_position ();
6848 else if (elem_type ==
"ylabel")
6849 update_ylabel_position ();
6850 else if (elem_type ==
"zlabel")
6851 update_zlabel_position ();
6852 else if (elem_type ==
"title")
6853 update_title_position ();
6854 else if (elem_type ==
"sync")
6860 double xlength,
double ylength,
double zlength)
6862 double xval = xlength / scalefactors(0);
6863 double yval = ylength / scalefactors(1);
6864 double zval = zlength / scalefactors(2);
6868 aspectratios(0) = xval / minval;
6869 aspectratios(1) = yval / minval;
6870 aspectratios(2) = zval / minval;
6875 double pbfactor,
double dafactor,
char limit_type,
bool tight)
6898axes::properties::update_aspectratios (
void)
6904 Matrix xlimits = get_xlim ().matrix_value ();
6905 Matrix ylimits = get_ylim ().matrix_value ();
6906 Matrix zlimits = get_zlim ().matrix_value ();
6908 double dx = (xlimits(1) - xlimits(0));
6909 double dy = (ylimits(1) - ylimits(0));
6910 double dz = (zlimits(1) - zlimits(0));
6912 Matrix da = get_dataaspectratio ().matrix_value ();
6913 Matrix pba = get_plotboxaspectratio ().matrix_value ();
6915 if (dataaspectratiomode_is (
"auto"))
6917 if (plotboxaspectratiomode_is (
"auto"))
6919 pba =
Matrix (1, 3, 1.0);
6920 m_plotboxaspectratio.set (pba,
false);
6924 m_dataaspectratio.set (da,
false);
6926 else if (plotboxaspectratiomode_is (
"auto"))
6929 m_plotboxaspectratio.set (pba,
false);
6934 bool modified_limits =
false;
6937 if (xlimmode_is (
"auto") && ylimmode_is (
"auto") && zlimmode_is (
"auto"))
6939 modified_limits =
true;
6940 kids = get_children ();
6945 else if (xlimmode_is (
"auto") && ylimmode_is (
"auto"))
6947 modified_limits =
true;
6950 else if (ylimmode_is (
"auto") && zlimmode_is (
"auto"))
6952 modified_limits =
true;
6955 else if (zlimmode_is (
"auto") && xlimmode_is (
"auto"))
6957 modified_limits =
true;
6961 if (modified_limits)
6968 dx = pba(0) * da(0);
6969 dy = pba(1) * da(1);
6970 dz = pba(2) * da(2);
6974 if (xlimmode_is (
"auto"))
6977 xlimits(0) = 0.5 * (xlimits(0) + xlimits(1) - dx);
6978 xlimits(1) = xlimits(0) + dx;
6980 set_xlimmode (
"auto");
6983 if (ylimmode_is (
"auto"))
6986 ylimits(0) = 0.5 * (ylimits(0) + ylimits(1) - dy);
6987 ylimits(1) = ylimits(0) + dy;
6989 set_ylimmode (
"auto");
6992 if (zlimmode_is (
"auto"))
6995 zlimits(0) = 0.5 * (zlimits(0) + zlimits(1) - dz);
6996 zlimits(1) = zlimits(0) + dz;
6998 set_zlimmode (
"auto");
7004 m_plotboxaspectratio.set (pba,
false);
7010axes::properties::update_label_color (handle_property label,
7016 gh_mgr.get_object (label.handle_value ()).set (
"color", col.get ());
7020axes::properties::update_font (std::string prop)
7025 if (! prop.empty ())
7029 if (prop ==
"fontsize")
7032 get_titlefontsizemultiplier ());
7034 get_labelfontsizemultiplier ());
7036 else if (prop ==
"fontweight")
7037 tval = get (
"titlefontweight");
7039 gh_mgr.get_object (get_xlabel ()).set (prop, val);
7040 gh_mgr.get_object (get_ylabel ()).set (prop, val);
7041 gh_mgr.get_object (get_zlabel ()).set (prop, val);
7042 gh_mgr.get_object (get_title ()).set (prop, tval);
7049 m_txt_renderer.set_font (get (
"fontname").string_value (),
7050 get (
"fontweight").string_value (),
7051 get (
"fontangle").string_value (),
7052 get (
"__fontsize_points__").double_value () * dpr);
7058axes::properties::get_boundingbox (
bool internal,
7059 const Matrix& parent_pix_size)
const
7061 Matrix pos = (internal ? get_position ().matrix_value ()
7062 : get_outerposition ().matrix_value ());
7063 Matrix parent_size (parent_pix_size);
7065 if (parent_size.isempty ())
7070 graphics_object go = gh_mgr.get_object (get_parent ());
7072 if (go.valid_object ())
7074 = go.get_properties ().get_boundingbox (
true).extract_n (0, 2, 1, 2);
7083 pos(1) = parent_size(1) - pos(1) - pos(3);
7089axes::properties::get_extent (
bool with_text,
bool only_text_height)
const
7091 graphics_xform
xform = get_transform ();
7096 for (
int i = 0; i <= 1; i++)
7097 for (
int j = 0; j <= 1; j++)
7098 for (
int k = 0; k <= 1; k++)
7101 j ? m_yPlaneN : m_yPlane,
7102 k ? m_zPlaneN : m_zPlane,
false);
7111 for (
int i = 0; i < 4; i++)
7115 htext = get_title ();
7117 htext = get_xlabel ();
7119 htext = get_ylabel ();
7121 htext = get_zlabel ();
7128 (gh_mgr.get_object (htext).get_properties ());
7130 Matrix text_pos = text_props.get_data_position ();
7131 text_pos =
xform.transform (text_pos(0), text_pos(1), text_pos(2));
7132 if (text_props.get_string ().isempty ())
7134 ext(0) =
std::min (ext(0), text_pos(0));
7135 ext(1) =
std::min (ext(1), text_pos(1));
7136 ext(2) =
std::max (ext(2), text_pos(0));
7137 ext(3) =
std::max (ext(3), text_pos(1));
7141 Matrix text_ext = text_props.get_extent_matrix (
true);
7147 for (
int j = 0; j < 4; j++)
7150 bool ignore_horizontal =
false;
7151 bool ignore_vertical =
false;
7152 if (only_text_height)
7154 double text_rotation = text_props.get_rotation ();
7155 if (text_rotation == 0. || text_rotation == 180.)
7156 ignore_horizontal =
true;
7157 else if (text_rotation == 90. || text_rotation == 270.)
7158 ignore_vertical =
true;
7161 if (! ignore_horizontal)
7163 ext(0) =
std::min (ext(0), text_pos(0)+text_ext(0));
7165 text_pos(0)+text_ext(0)+text_ext(2));
7168 if (! ignore_vertical)
7171 text_pos(1)-text_ext(1)-text_ext(3));
7172 ext(3) =
std::max (ext(3), text_pos(1)-text_ext(1));
7178 ext(2) = ext(2) - ext(0);
7179 ext(3) = ext(3) - ext(1);
7201 std::ostringstream oss;
7213 std::istringstream iss (valstr);
7217 while (std::getline (iss, tmpstr,
'|'))
7221 if (*valstr.rbegin () ==
'|')
7222 sv.
append (std::string (
""));
7236axes::properties::set_xticklabel (
const octave_value& val)
7240 set_xticklabelmode (
"manual");
7241 m_xticklabel.run_listeners (GCB_POSTSET);
7245 set_xticklabelmode (
"manual");
7251axes::properties::set_yticklabel (
const octave_value& val)
7255 set_yticklabelmode (
"manual");
7256 m_yticklabel.run_listeners (GCB_POSTSET);
7260 set_yticklabelmode (
"manual");
7266axes::properties::set_zticklabel (
const octave_value& val)
7270 set_zticklabelmode (
"manual");
7271 m_zticklabel.run_listeners (GCB_POSTSET);
7275 set_zticklabelmode (
"manual");
7299 std::istringstream iss (valstr);
7303 while (std::getline (iss, tmpstr,
'|'))
7307 if (*valstr.rbegin () ==
'|')
7308 sv.
append (std::string (
""));
7322axes::properties::set_linestyleorder (
const octave_value& val)
7332 if (m_units.set (val,
true))
7334 update_units (old_units);
7340axes::properties::update_units (
const caseless_str& old_units)
7345 graphics_object parent_go = gh_mgr.get_object (get_parent ());
7348 = parent_go.get_properties ().get_boundingbox (
true).
extract_n (0, 2, 1, 2);
7353 old_units, new_units, parent_bb)),
7357 old_units, new_units, parent_bb)),
7361 old_units, new_units, parent_bb)),
7365 old_units, new_units, parent_bb)),
7370axes::properties::set_fontunits (
const octave_value& val)
7374 if (m_fontunits.set (val,
true))
7376 update_fontunits (old_fontunits);
7382axes::properties::update_fontunits (
const caseless_str& old_units)
7385 double parent_height = get_boundingbox (
true).elem (3);
7386 double fontsz = get_fontsize ();
7394axes::properties::get___fontsize_points__ (
double box_pix_height)
const
7396 double fontsz = get_fontsize ();
7397 double parent_height = box_pix_height;
7399 if (fontunits_is (
"normalized") && parent_height <= 0)
7400 parent_height = get_boundingbox (
true).elem (3);
7412graphics_xform::xform_eye (
void)
7431graphics_xform::untransform (
double x,
double y,
double z,
7432 bool use_scale)
const
7438 v(0) = m_sx.unscale (v(0));
7439 v(1) = m_sy.unscale (v(1));
7440 v(2) = m_sz.unscale (v(2));
7449 octave_value retval = m_default_properties.lookup (pname);
7458 graphics_object parent_go = gh_mgr.get_object (parent_h);
7460 retval = parent_go.get_default (pname);
7491 double& min_pos,
double& max_neg,
7499 if (m.
numel () != 4)
7544axes::properties::update_outerposition (
void)
7546 set_positionconstraint (
"outerposition");
7548 set_units (
"normalized");
7550 Matrix outerbox = m_outerposition.get ().matrix_value ();
7552 double outer_left = outerbox(0);
7553 double outer_bottom = outerbox(1);
7554 double outer_width = outerbox(2);
7555 double outer_height = outerbox(3);
7557 double outer_right = outer_width + outer_left;
7558 double outer_top = outer_height + outer_bottom;
7560 Matrix linset = m_looseinset.get ().matrix_value ();
7561 Matrix tinset = m_tightinset.get ().matrix_value ();
7563 double left_margin =
std::max (linset(0), tinset(0));
7564 double bottom_margin =
std::max (linset(1), tinset(1));
7565 double right_margin =
std::max (linset(2), tinset(2));
7566 double top_margin =
std::max (linset(3), tinset(3));
7568 double inner_left = outer_left;
7569 double inner_right = outer_right;
7571 if ((left_margin + right_margin) < outer_width)
7573 inner_left += left_margin;
7574 inner_right -= right_margin;
7577 double inner_bottom = outer_bottom;
7578 double inner_top = outer_top;
7580 if ((bottom_margin + top_margin) < outer_height)
7582 inner_bottom += bottom_margin;
7583 inner_top -= top_margin;
7586 double inner_width = inner_right - inner_left;
7587 double inner_height = inner_top - inner_bottom;
7591 innerbox(0) = inner_left;
7592 innerbox(1) = inner_bottom;
7593 innerbox(2) = inner_width;
7594 innerbox(3) = inner_height;
7596 m_position = innerbox;
7598 set_units (old_units);
7599 update_transform ();
7603axes::properties::update_position (
void)
7605 set_positionconstraint (
"innerposition");
7607 set_units (
"normalized");
7609 Matrix innerbox = m_position.get ().matrix_value ();
7611 double inner_left = innerbox(0);
7612 double inner_bottom = innerbox(1);
7613 double inner_width = innerbox(2);
7614 double inner_height = innerbox(3);
7616 double inner_right = inner_width + inner_left;
7617 double inner_top = inner_height + inner_bottom;
7619 Matrix linset = m_looseinset.get ().matrix_value ();
7620 Matrix tinset = m_tightinset.get ().matrix_value ();
7622 double left_margin =
std::max (linset(0), tinset(0));
7623 double bottom_margin =
std::max (linset(1), tinset(1));
7624 double right_margin =
std::max (linset(2), tinset(2));
7625 double top_margin =
std::max (linset(3), tinset(3));
7629 double outer_left = inner_left - left_margin;
7630 double outer_bottom = inner_bottom - bottom_margin;
7631 double outer_right = inner_right + right_margin;
7632 double outer_top = inner_top + top_margin;
7634 double outer_width = outer_right - outer_left;
7635 double outer_height = outer_top - outer_bottom;
7639 outerbox(0) = outer_left;
7640 outerbox(1) = outer_bottom;
7641 outerbox(2) = outer_width;
7642 outerbox(3) = outer_height;
7644 m_outerposition = outerbox;
7646 set_units (old_units);
7647 update_transform ();
7651axes::properties::update_looseinset (
void)
7654 set_units (
"normalized");
7656 Matrix linset = m_looseinset.get ().matrix_value ();
7657 Matrix tinset = m_tightinset.get ().matrix_value ();
7659 double left_margin =
std::max (linset(0), tinset(0));
7660 double bottom_margin =
std::max (linset(1), tinset(1));
7661 double right_margin =
std::max (linset(2), tinset(2));
7662 double top_margin =
std::max (linset(3), tinset(3));
7664 if (m_positionconstraint.is (
"innerposition"))
7666 Matrix innerbox = m_position.get ().matrix_value ();
7668 double inner_left = innerbox(0);
7669 double inner_bottom = innerbox(1);
7670 double inner_width = innerbox(2);
7671 double inner_height = innerbox(3);
7673 double inner_right = inner_width + inner_left;
7674 double inner_top = inner_height + inner_bottom;
7678 double outer_left = inner_left - left_margin;
7679 double outer_bottom = inner_bottom - bottom_margin;
7680 double outer_right = inner_right + right_margin;
7681 double outer_top = inner_top + top_margin;
7683 double outer_width = outer_right - outer_left;
7684 double outer_height = outer_top - outer_bottom;
7688 outerbox(0) = outer_left;
7689 outerbox(1) = outer_bottom;
7690 outerbox(2) = outer_width;
7691 outerbox(3) = outer_height;
7693 m_outerposition = outerbox;
7697 Matrix outerbox = m_outerposition.get ().matrix_value ();
7699 double outer_left = outerbox(0);
7700 double outer_bottom = outerbox(1);
7701 double outer_width = outerbox(2);
7702 double outer_height = outerbox(3);
7704 double outer_right = outer_width + outer_left;
7705 double outer_top = outer_height + outer_bottom;
7707 double inner_left = outer_left;
7708 double inner_right = outer_right;
7710 if ((left_margin + right_margin) < outer_width)
7712 inner_left += left_margin;
7713 inner_right -= right_margin;
7716 double inner_bottom = outer_bottom;
7717 double inner_top = outer_top;
7719 if ((bottom_margin + top_margin) < outer_height)
7721 inner_bottom += bottom_margin;
7722 inner_top -= top_margin;
7725 double inner_width = inner_right - inner_left;
7726 double inner_height = inner_top - inner_bottom;
7730 innerbox(0) = inner_left;
7731 innerbox(1) = inner_bottom;
7732 innerbox(2) = inner_width;
7733 innerbox(3) = inner_height;
7735 m_position = innerbox;
7738 set_units (old_units);
7739 update_transform ();
7747axes::properties::calc_tick_sep (
double lo,
double hi)
7759 magform ((hi - lo) / ticint, a, b);
7761 static const double sqrt_2 = sqrt (2.0);
7762 static const double sqrt_10 = sqrt (10.0);
7763 static const double sqrt_50 = sqrt (50.0);
7767 else if (a < sqrt_10)
7769 else if (a < sqrt_50)
7781axes::properties::get_axis_limits (
double xmin,
double xmax,
7782 double min_pos,
double max_neg,
7783 const bool logscale)
7787 double min_val =
xmin;
7788 double max_val =
xmax;
7813 "axis: omitting non-positive data in log plot");
7816 else if (max_val == 0)
7821 < sqrt (std::numeric_limits<double>::epsilon ()))
7850 if (min_val == 0 && max_val == 0)
7856 else if (
std::abs (min_val - max_val)
7857 < sqrt (std::numeric_limits<double>::epsilon ()))
7859 min_val -= 0.1 *
std::abs (min_val);
7860 max_val += 0.1 *
std::abs (max_val);
7863 double tick_sep = calc_tick_sep (min_val, max_val);
7864 double min_tick =
std::floor (min_val / tick_sep);
7865 double max_tick =
std::ceil (max_val / tick_sep);
7867 min_val =
std::min (min_val, tick_sep * min_tick);
7868 max_val =
std::max (max_val, tick_sep * max_tick);
7874 retval(0) = min_val;
7875 retval(1) = max_val;
7881axes::properties::check_axis_limits (
Matrix& limits,
const Matrix kids,
7882 const bool logscale,
char& update_type)
7888 double eps = std::numeric_limits<double>::epsilon ();
7889 bool do_update =
false;
7890 bool have_children_limits =
false;
7898 have_children_limits =
true;
7902 limits(0) = min_val;
7907 limits(1) = max_val;
7910 if (limits(0) == 0 && limits(1) == 0)
7916 else if (! logscale && (
std::abs (limits(0) - limits(1)) < sqrt (
eps)))
7918 limits(0) -= 0.1 *
std::abs (limits(0));
7919 limits(1) += 0.1 *
std::abs (limits(1));
7923 && (
std::abs (std::log10 (limits(0) / limits(1))) < sqrt (
eps)))
7925 limits(0) = (limits(0) < 0 ? 10.0 * limits(0) : 0.1 * limits(0));
7926 limits(1) = (limits(1) < 0 ? 0.1 * limits(1) : 10.0 * limits(1));
7930 if (logscale && limits(0)*limits(1) <= 0)
7932 if (! have_children_limits)
7939 "Non-positive limit for logarithmic axis ignored\n");
7941 limits(0) = min_pos;
7943 limits(0) = 0.1 * limits(1);
7948 "Non-negative limit for logarithmic axis ignored\n");
7950 limits(1) = max_neg;
7952 limits(1) = 0.1 * limits(0);
7955 if (
std::abs (limits(0) - limits(1)) < sqrt (
eps))
8078axes::properties::calc_ticks_and_lims (array_property& lims,
8079 array_property& ticks,
8080 array_property& mticks,
8081 bool limmode_is_auto,
8082 bool tickmode_is_auto,
8085 if (lims.get ().isempty ())
8088 double lo = (lims.get ().matrix_value ())(0);
8089 double hi = (lims.get ().matrix_value ())(1);
8092 bool is_negative = lo < 0 && hi < 0;
8103 hi = std::log10 (-lo);
8104 lo = std::log10 (-tmp);
8108 hi = std::log10 (hi);
8109 lo = std::log10 (lo);
8114 if (tickmode_is_auto)
8126 tick_sep = calc_tick_sep (lo, hi);
8131 if (limmode_is_auto)
8135 tmp_lims(0) =
std::min (tick_sep * i1, lo);
8136 tmp_lims(1) =
std::max (tick_sep * i2, hi);
8140 tmp_lims(0) =
std::pow (10., tmp_lims(0));
8141 tmp_lims(1) =
std::pow (10., tmp_lims(1));
8142 if (tmp_lims(0) <= 0)
8146 double tmp = tmp_lims(0);
8147 tmp_lims(0) = -tmp_lims(1);
8156 if (i1*tick_sep < lo)
8158 if (i2*tick_sep > hi && i2 > i1)
8162 tmp_ticks =
Matrix (1, i2-i1+1);
8163 for (
int i = 0; i <= static_cast<int> (i2-i1); i++)
8165 tmp_ticks(i) = tick_sep * (i+i1);
8167 tmp_ticks(i) =
std::pow (10., tmp_ticks(i));
8169 if (is_logscale && is_negative)
8171 Matrix rev_ticks (1, i2-i1+1);
8172 rev_ticks = -tmp_ticks;
8173 for (
int i = 0; i <= static_cast<int> (i2-i1); i++)
8174 tmp_ticks(i) = rev_ticks(i2-i1-i);
8180 tmp_ticks = ticks.get ().matrix_value ();
8187 int n = (is_logscale ? 8 : 4);
8188 double mult_below = (is_logscale ? tmp_ticks(1) / tmp_ticks(0) : 1);
8189 double mult_above = (is_logscale ? tmp_ticks(n_ticks-1) / tmp_ticks(n_ticks-2)
8192 double d_below = (tmp_ticks(1) - tmp_ticks(0)) / mult_below / (n+1);
8193 int n_below =
static_cast<int> (
std::floor ((tmp_ticks(0)-lo_lim) / d_below));
8196 int n_between = n * (n_ticks - 1);
8197 double d_above = (tmp_ticks(n_ticks-1) - tmp_ticks(n_ticks-2)) * mult_above
8199 int n_above =
static_cast<int> (
std::floor ((hi_lim-tmp_ticks(n_ticks-1))
8204 Matrix tmp_mticks (1, n_below + n_between + n_above);
8205 for (
int i = 0; i < n_below; i++)
8206 tmp_mticks(i) = tmp_ticks(0) - (n_below-i) * d_below;
8207 for (
int i = 0; i < n_ticks-1; i++)
8209 double d = (tmp_ticks(i+1) - tmp_ticks(i)) / (n + 1);
8210 for (
int j = 0; j < n; j++)
8211 tmp_mticks(n_below+n*i+j) = tmp_ticks(i) +
d * (j+1);
8213 for (
int i = 0; i < n_above; i++)
8214 tmp_mticks(n_below+n_between+i) = tmp_ticks(n_ticks-1) + (i + 1) * d_above;
8216 mticks = tmp_mticks;
8233axes::properties::calc_ticklabels (
const array_property& ticks,
8234 any_property& labels,
bool logscale,
8235 const bool is_origin,
8236 const int other_axislocation,
8237 const array_property& axis_lims)
8239 Matrix values = ticks.get ().matrix_value ();
8240 Matrix lims = axis_lims.get ().matrix_value ();
8242 std::ostringstream os;
8246 if (get_is2D () && is_origin)
8248 if (other_axislocation == 0)
8253 else if (other_axislocation == 1)
8254 omit_ticks(0) = lims(1);
8255 else if (other_axislocation == -1)
8256 omit_ticks(0) = lims(0);
8259 omit_ticks(1) = lims(0);
8260 omit_ticks(2) = lims(1);
8268 double exp_max = 0.0;
8269 double exp_min = 0.0;
8271 for (
int i = 0; i < values.
numel (); i++)
8273 double exp = std::log10 (values(i));
8278 for (
int i = 0; i < values.
numel (); i++)
8280 bool omit_tick =
false;
8281 for (
int i_omit = 0; i_omit < omit_ticks.numel (); i_omit++)
8282 if (values(i) == omit_ticks(i_omit))
8290 if (values(i) < 0.0)
8291 exponent =
std::floor (std::log10 (-values(i)));
8293 exponent =
std::floor (std::log10 (values(i)));
8294 significand = values(i) *
std::pow (10., -exponent);
8298 10*std::numeric_limits<double>::epsilon())
8299 os << significand <<
'x';
8300 else if (significand < 0)
8308 exponent = -exponent;
8310 if (exponent < 10. && (exp_max > 9 || exp_min < -9))
8312 os << exponent <<
'}';
8314 if (m_ticklabelinterpreter.is (
"latex"))
8315 c(i) =
"$" + os.str () +
"$";
8322 for (
int i = 0; i < values.
numel (); i++)
8324 bool omit_tick =
false;
8325 for (
int i_omit = 0; i_omit < omit_ticks.numel (); i_omit++)
8326 if (values(i) == omit_ticks(i_omit))
8343axes::properties::get_ticklabel_extents (
const Matrix& ticks,
8352 for (
int i = 0; i < n; i++)
8354 double val = ticks(i);
8355 if (limits(0) <= val && val <= limits(1))
8357 std::string label (ticklabels(i));
8358 label.erase (0, label.find_first_not_of (
' '));
8359 label = label.substr (0, label.find_last_not_of (
' ')+1);
8361 if (m_txt_renderer.ok ())
8368 ext = m_txt_renderer.get_extent (label, 0.0,
8369 get_ticklabelinterpreter ());
8371 wmax =
std::max (wmax, ext(0) / dpr);
8372 hmax =
std::max (hmax, ext(1) / dpr);
8377 double fsize = get (
"fontsize").double_value ();
8378 int len = label.length ();
8393 double& min_pos,
double& max_neg,
8394 const Matrix& kids,
char limit_type)
8405 graphics_object go = gh_mgr.get_object (kids(i));
8407 if (go.is_xliminclude ())
8419 graphics_object go = gh_mgr.get_object (kids(i));
8421 if (go.is_yliminclude ())
8433 graphics_object go = gh_mgr.get_object (kids(i));
8435 if (go.is_zliminclude ())
8447 graphics_object go = gh_mgr.get_object (kids(i));
8449 if (go.is_climinclude ())
8461 graphics_object go = gh_mgr.get_object (kids(i));
8463 if (go.is_aliminclude ())
8480axes::update_axis_limits (
const std::string& axis_type,
8494 char update_type = 0;
8501 if (octave::math::isfinite (val)) \
8504 if (octave::math::isfinite (val)) \
8507 if (axis_type ==
"xdata" || axis_type ==
"xscale"
8508 || axis_type ==
"xlimmode" || axis_type ==
"xliminclude"
8509 || axis_type ==
"xlim")
8511 limits = m_properties.get_xlim ().matrix_value ();
8515 if (m_properties.xlimmode_is (
"auto"))
8519 limits = m_properties.get_axis_limits (min_val, max_val,
8521 m_properties.xscale_is (
"log"));
8524 m_properties.check_axis_limits (limits, kids,
8525 m_properties.xscale_is (
"log"),
8528 else if (axis_type ==
"ydata" || axis_type ==
"yscale"
8529 || axis_type ==
"ylimmode" || axis_type ==
"yliminclude"
8530 || axis_type ==
"ylim")
8532 limits = m_properties.get_ylim ().matrix_value ();
8536 if (m_properties.ylimmode_is (
"auto"))
8540 limits = m_properties.get_axis_limits (min_val, max_val,
8542 m_properties.yscale_is (
"log"));
8545 m_properties.check_axis_limits (limits, kids,
8546 m_properties.yscale_is (
"log"),
8549 else if (axis_type ==
"zdata" || axis_type ==
"zscale"
8550 || axis_type ==
"zlimmode" || axis_type ==
"zliminclude"
8551 || axis_type ==
"zlim")
8553 limits = m_properties.get_zlim ().matrix_value ();
8557 if (m_properties.zlimmode_is (
"auto"))
8561 m_properties.set_has3Dkids ((max_val - min_val) >
8562 std::numeric_limits<double>::epsilon ());
8564 limits = m_properties.get_axis_limits (min_val, max_val,
8566 m_properties.zscale_is (
"log"));
8574 m_properties.set_has3Dkids ((max_val - min_val) >
8575 std::numeric_limits<double>::epsilon ());
8577 m_properties.check_axis_limits (limits, kids,
8578 m_properties.zscale_is (
"log"),
8582 else if (axis_type ==
"cdata" || axis_type ==
"climmode"
8583 || axis_type ==
"cdatamapping" || axis_type ==
"climinclude"
8584 || axis_type ==
"clim")
8586 if (m_properties.climmode_is (
"auto"))
8588 limits = m_properties.get_clim ().matrix_value ();
8593 if (min_val > max_val)
8595 min_val = min_pos = 0;
8598 else if (min_val == max_val)
8600 max_val = min_val + 1;
8604 limits(0) = min_val;
8605 limits(1) = max_val;
8610 else if (axis_type ==
"alphadata" || axis_type ==
"alimmode"
8611 || axis_type ==
"alphadatamapping" || axis_type ==
"aliminclude"
8612 || axis_type ==
"alim")
8614 if (m_properties.alimmode_is (
"auto"))
8616 limits = m_properties.get_alim ().matrix_value ();
8621 if (min_val > max_val)
8623 min_val = min_pos = 0;
8626 else if (min_val == max_val)
8627 max_val = min_val + 1;
8629 limits(0) = min_val;
8630 limits(1) = max_val;
8644 switch (update_type)
8647 is_auto = m_properties.xlimmode_is (
"auto");
8648 m_properties.set_xlim (limits);
8650 m_properties.set_xlimmode (
"auto");
8651 m_properties.update_xlim ();
8655 is_auto = m_properties.ylimmode_is (
"auto");
8656 m_properties.set_ylim (limits);
8658 m_properties.set_ylimmode (
"auto");
8659 m_properties.update_ylim ();
8663 is_auto = m_properties.zlimmode_is (
"auto");
8664 m_properties.set_zlim (limits);
8666 m_properties.set_zlimmode (
"auto");
8667 m_properties.update_zlim ();
8671 m_properties.set_clim (limits);
8672 m_properties.set_climmode (
"auto");
8676 m_properties.set_alim (limits);
8677 m_properties.set_alimmode (
"auto");
8684 m_properties.update_transform ();
8691axes::update_axis_limits (
const std::string& axis_type)
8699 Matrix kids = m_properties.get_children ();
8706 char update_type = 0;
8710 if (axis_type ==
"xdata" || axis_type ==
"xscale"
8711 || axis_type ==
"xlimmode" || axis_type ==
"xliminclude"
8712 || axis_type ==
"xlim")
8715 if (m_properties.xlimmode_is (
"auto"))
8719 limits = m_properties.get_axis_limits (min_val, max_val,
8721 m_properties.xscale_is (
"log"));
8725 limits = m_properties.get_xlim ().matrix_value ();
8726 m_properties.check_axis_limits (limits, kids,
8727 m_properties.xscale_is (
"log"),
8729 if (axis_type ==
"xscale")
8733 else if (axis_type ==
"ydata" || axis_type ==
"yscale"
8734 || axis_type ==
"ylimmode" || axis_type ==
"yliminclude"
8735 || axis_type ==
"ylim")
8738 if (m_properties.ylimmode_is (
"auto"))
8742 limits = m_properties.get_axis_limits (min_val, max_val,
8744 m_properties.yscale_is (
"log"));
8748 limits = m_properties.get_ylim ().matrix_value ();
8749 m_properties.check_axis_limits (limits, kids,
8750 m_properties.yscale_is (
"log"),
8752 if (axis_type ==
"yscale")
8756 else if (axis_type ==
"zdata" || axis_type ==
"zscale"
8757 || axis_type ==
"zlimmode" || axis_type ==
"zliminclude"
8758 || axis_type ==
"zlim")
8761 if (m_properties.zlimmode_is (
"auto"))
8765 m_properties.set_has3Dkids ((max_val - min_val) >
8766 std::numeric_limits<double>::epsilon ());
8771 && ! m_properties.zscale_is (
"log"))
8772 min_val = max_val = 0.;
8774 limits = m_properties.get_axis_limits (min_val, max_val,
8776 m_properties.zscale_is (
"log"));
8784 m_properties.set_has3Dkids ((max_val - min_val) >
8785 std::numeric_limits<double>::epsilon ());
8787 limits = m_properties.get_zlim ().matrix_value ();
8788 m_properties.check_axis_limits (limits, kids,
8789 m_properties.zscale_is (
"log"),
8791 if (axis_type ==
"zscale")
8795 else if (axis_type ==
"cdata" || axis_type ==
"climmode"
8796 || axis_type ==
"cdatamapping" || axis_type ==
"climinclude"
8797 || axis_type ==
"clim")
8799 if (m_properties.climmode_is (
"auto"))
8803 if (min_val > max_val)
8805 min_val = min_pos = 0;
8808 else if (min_val == max_val)
8810 max_val = min_val + 1;
8816 limits(0) = min_val;
8817 limits(1) = max_val;
8823 else if (axis_type ==
"alphadata" || axis_type ==
"alimmode"
8824 || axis_type ==
"alphadatamapping" || axis_type ==
"aliminclude"
8825 || axis_type ==
"alim")
8827 if (m_properties.alimmode_is (
"auto"))
8831 if (min_val > max_val)
8833 min_val = min_pos = 0;
8836 else if (min_val == max_val)
8837 max_val = min_val + 1;
8841 limits(0) = min_val;
8842 limits(1) = max_val;
8855 switch (update_type)
8858 is_auto = m_properties.xlimmode_is (
"auto");
8859 m_properties.set_xlim (limits);
8861 m_properties.set_xlimmode (
"auto");
8862 m_properties.update_xlim ();
8866 is_auto = m_properties.ylimmode_is (
"auto");
8867 m_properties.set_ylim (limits);
8869 m_properties.set_ylimmode (
"auto");
8870 m_properties.update_ylim ();
8874 is_auto = m_properties.zlimmode_is (
"auto");
8875 m_properties.set_zlim (limits);
8877 m_properties.set_zlimmode (
"auto");
8878 m_properties.update_zlim ();
8882 m_properties.set_clim (limits);
8883 m_properties.set_climmode (
"auto");
8887 m_properties.set_alim (limits);
8888 m_properties.set_alimmode (
"auto");
8895 m_properties.update_transform ();
8914 double lo = lims(0);
8915 double hi = lims(1);
8917 bool is_negative = lo < 0 && hi < 0;
8924 hi = std::log10 (-lo);
8925 lo = std::log10 (-tmp);
8926 val = std::log10 (-val);
8930 hi = std::log10 (hi);
8931 lo = std::log10 (lo);
8932 val = std::log10 (val);
8937 lo = val + (lo - val) / factor;
8938 hi = val + (hi - val) / factor;
8962axes::properties::zoom_about_point (
const std::string& mode,
8963 double x,
double y,
double factor,
8964 bool push_to_zoom_stack)
8967 Matrix xlims = get_xlim ().matrix_value ();
8968 Matrix ylims = get_ylim ().matrix_value ();
8971 Matrix kids = get_children ();
8984 xlims =
do_zoom (
x, factor, xlims, xscale_is (
"log"));
8985 ylims =
do_zoom (y, factor, ylims, yscale_is (
"log"));
8987 zoom (mode, xlims, ylims, push_to_zoom_stack);
8991axes::properties::zoom (
const std::string& mode,
double factor,
8992 bool push_to_zoom_stack)
8995 Matrix xlims = get_xlim ().matrix_value ();
8996 Matrix ylims = get_ylim ().matrix_value ();
8998 double x = (xlims(0) + xlims(1)) / 2;
8999 double y = (ylims(0) + ylims(1)) / 2;
9001 zoom_about_point (mode,
x, y, factor, push_to_zoom_stack);
9005axes::properties::push_zoom_stack (
void)
9007 if (m_zoom_stack.empty ())
9009 m_zoom_stack.push_front (m_xlimmode.get ());
9010 m_zoom_stack.push_front (m_xlim.get ());
9011 m_zoom_stack.push_front (m_ylimmode.get ());
9012 m_zoom_stack.push_front (m_ylim.get ());
9013 m_zoom_stack.push_front (m_zlimmode.get ());
9014 m_zoom_stack.push_front (m_zlim.get ());
9015 m_zoom_stack.push_front (m_view.get ());
9020axes::properties::zoom (
const std::string& mode,
9022 bool push_to_zoom_stack)
9024 if (xl(0) == xl(1) || yl(0) == yl(1))
9026 warning (
"invalid zoom region");
9030 if (push_to_zoom_stack)
9033 if (mode ==
"horizontal" || mode ==
"both")
9036 m_xlimmode =
"manual";
9039 if (mode ==
"vertical" || mode ==
"both")
9042 m_ylimmode =
"manual";
9045 update_transform ();
9047 if (mode ==
"horizontal" || mode ==
"both")
9050 if (mode ==
"vertical" || mode ==
"both")
9059 double lo = lims(0);
9060 double hi = lims(1);
9062 bool is_negative = lo < 0 && hi < 0;
9071 hi = std::log10 (-lo);
9072 lo = std::log10 (-tmp);
9078 hi = std::log10 (hi);
9079 lo = std::log10 (lo);
9082 delta = std::log10 (x0) - std::log10 (x1);
9115axes::properties::translate_view (
const std::string& mode,
9116 double x0,
double x1,
double y0,
double y1,
9117 bool push_to_zoom_stack)
9120 Matrix xlims = get_xlim ().matrix_value ();
9121 Matrix ylims = get_ylim ().matrix_value ();
9124 Matrix kids = get_children ();
9137 xlims =
do_translate (x0, x1, xlims, xscale_is (
"log"));
9138 ylims =
do_translate (y0, y1, ylims, yscale_is (
"log"));
9140 zoom (mode, xlims, ylims, push_to_zoom_stack);
9144axes::properties::pan (
const std::string& mode,
double factor,
9145 bool push_to_zoom_stack)
9148 Matrix xlims = get_xlim ().matrix_value ();
9149 Matrix ylims = get_ylim ().matrix_value ();
9151 double x0 = (xlims(0) + xlims(1)) / 2;
9152 double y0 = (ylims(0) + ylims(1)) / 2;
9154 double x1 = x0 + (xlims(1) - xlims(0)) * factor;
9155 double y1 = y0 + (ylims(1) - ylims(0)) * factor;
9157 translate_view (mode, x0, x1, y0, y1, push_to_zoom_stack);
9161axes::properties::rotate3d (
double x0,
double x1,
double y0,
double y1,
9162 bool push_to_zoom_stack)
9164 if (push_to_zoom_stack)
9167 Matrix bb = get_boundingbox (
true);
9168 Matrix new_view = get_view ().matrix_value ();
9171 new_view(0) += ((x0 - x1) * (180.0 / bb(2)));
9172 new_view(1) += ((y1 - y0) * (180.0 / bb(3)));
9175 new_view(1) =
std::min (new_view(1), 90.0);
9176 new_view(1) =
std::max (new_view(1), -90.0);
9177 if (new_view(0) > 180.0)
9178 new_view(0) -= 360.0;
9179 else if (new_view(0) < -180.0)
9180 new_view(0) += 360.0;
9183 double snapmargin = 1.0;
9184 for (
int a = -90; a <= 90; a += 90)
9186 if ((a - snapmargin) < new_view(1) && new_view(1) < (a + snapmargin))
9193 for (
int a = -180; a <= 180; a += 180)
9194 if ((a - snapmargin) < new_view(0) && new_view(0) < (a + snapmargin))
9204 set_view (new_view);
9208axes::properties::rotate_view (
double delta_el,
double delta_az,
9209 bool push_to_zoom_stack)
9211 if (push_to_zoom_stack)
9214 Matrix v = get_view ().matrix_value ();
9223 v(0) = fmod (v(0) - delta_az + 720, 360);
9227 update_transform ();
9231axes::properties::unzoom (
void)
9233 if (m_zoom_stack.size () >= 7)
9235 m_view = m_zoom_stack.front ();
9236 m_zoom_stack.pop_front ();
9238 m_zlim = m_zoom_stack.front ();
9239 m_zoom_stack.pop_front ();
9241 m_zlimmode = m_zoom_stack.front ();
9242 m_zoom_stack.pop_front ();
9244 m_ylim = m_zoom_stack.front ();
9245 m_zoom_stack.pop_front ();
9247 m_ylimmode = m_zoom_stack.front ();
9248 m_zoom_stack.pop_front ();
9250 m_xlim = m_zoom_stack.front ();
9251 m_zoom_stack.pop_front ();
9253 m_xlimmode = m_zoom_stack.front ();
9254 m_zoom_stack.pop_front ();
9256 update_transform ();
9267axes::properties::update_handlevisibility (
void)
9274 graphics_object go (gh_mgr.get_object (get___myhandle__ ()));
9276 graphics_object fig (go.get_ancestor (
"figure"));
9284 fig.set (
"currentaxes",
Matrix ());
9288 fig.set (
"currentaxes", kidsarray(0));
9293 base_properties::update_handlevisibility ();
9297figure::properties::init_toolkit (
void)
9306axes::properties::clear_zoom_stack (
bool do_unzoom)
9308 std::size_t items_to_leave_on_stack = (do_unzoom ? 7 : 0);
9310 while (m_zoom_stack.size () > items_to_leave_on_stack)
9311 m_zoom_stack.pop_front ();
9318axes::properties::trigger_normals_calc (
void)
9321 std::list<graphics_object> children_list;
9322 std::list<graphics_object>::iterator children_list_iter;
9323 get_children_of_type (
"patch",
false,
true, children_list);
9324 get_children_of_type (
"surface",
false,
true, children_list);
9327 for (children_list_iter = children_list.begin ();
9328 children_list_iter != children_list.end (); children_list_iter++)
9330 graphics_object kid = *children_list_iter;
9331 if (kid.isa (
"patch"))
9335 patch_props.update_normals (
false);
9341 surface_props.update_normals (
false);
9347axes::reset_default_properties (
void)
9350 m_default_properties = property_list ();
9356 remove_all_listeners ();
9357 set_defaults (
"reset");
9372 m_properties.sync_positions ();
9378line::properties::compute_xlim (
void)
const
9382 m(0) = m_xdata.min_val ();
9383 m(1) = m_xdata.max_val ();
9384 m(2) = m_xdata.min_pos ();
9385 m(3) = m_xdata.max_neg ();
9391line::properties::compute_ylim (
void)
const
9395 m(0) = m_ydata.min_val ();
9396 m(1) = m_ydata.max_val ();
9397 m(2) = m_ydata.min_pos ();
9398 m(3) = m_ydata.max_neg ();
9406text::properties::get_data_position (
void)
const
9408 Matrix pos = get_position ().matrix_value ();
9410 if (! units_is (
"data"))
9417text::properties::get_extent_matrix (
bool rotated)
const
9420 Matrix ext = m_extent.get ().matrix_value ();
9422 if (rotated && get_rotation () != 0)
9424 double rot = get_rotation () * 4.0 *
atan (1.0) / 180;
9425 double x0 = ext(0) * cos (rot) - ext(1) * sin (rot);
9427 double y0 = ext(0) * sin (rot) + ext(1) * cos (rot);
9430 double tmp = (ext(0)+ext(2)) * cos (rot) - ext(1) * sin (rot);
9433 tmp = (ext(0)+ext(2)) * sin (rot) + ext(1) * cos (rot);
9437 tmp = (ext(0)+ext(2)) * cos (rot) - (ext(1)+ext(3)) * sin (rot);
9440 tmp = (ext(0)+ext(2)) * sin (rot) + (ext(1)+ext(3)) * cos (rot);
9444 tmp = ext(0) * cos (rot) - (ext(1)+ext(3)) * sin (rot);
9447 tmp = ext(0) * sin (rot) + (ext(1)+ext(3)) * cos (rot);
9461text::properties::get_extent (
void)
const
9465 Matrix m = get_extent_matrix (
true);
9466 Matrix pos = get_position ().matrix_value ();
9477 bbox(ii) = bbox(ii) / dpr;
9483text::properties::set_fontunits (
const octave_value& val)
9487 if (m_fontunits.set (val,
true))
9489 update_fontunits (old_fontunits);
9495text::properties::update_fontunits (
const caseless_str& old_units)
9498 double parent_height = 0;
9499 double fontsz = get_fontsize ();
9501 if (new_units ==
"normalized" || old_units ==
"normalized")
9506 graphics_object go (gh_mgr.get_object (get___myhandle__ ()));
9508 graphics_object ax (go.get_ancestor (
"axes"));
9510 parent_height = ax.get_properties ().get_boundingbox (
true).elem (3);
9519text::properties::update_font (
void)
9528 m_txt_renderer.set_font (get (
"fontname").string_value (),
9529 get (
"fontweight").string_value (),
9530 get (
"fontangle").string_value (),
9531 get (
"__fontsize_points__").double_value () * dpr);
9533 m_txt_renderer.set_anti_aliasing (is_fontsmoothing ());
9535 Matrix c = get_color_rgb ();
9537 m_txt_renderer.set_color (c);
9542text::properties::update_text_extent (
void)
9547 if (horizontalalignment_is (
"center"))
9549 else if (horizontalalignment_is (
"right"))
9552 if (verticalalignment_is (
"middle"))
9554 else if (verticalalignment_is (
"top"))
9556 else if (verticalalignment_is (
"baseline"))
9558 else if (verticalalignment_is (
"cap"))
9574 m_txt_renderer.text_to_pixels (sv.
join (
"\n"), m_pixels, bbox,
9575 halign, valign, 0.0, get_interpreter ());
9582 if (__autopos_tag___is (
"xlabel") || __autopos_tag___is (
"ylabel")
9583 || __autopos_tag___is (
"zlabel") || __autopos_tag___is (
"title"))
9584 update_autopos (
"sync");
9588text::properties::request_autopos (
void)
9590 if (__autopos_tag___is (
"xlabel") || __autopos_tag___is (
"ylabel")
9591 || __autopos_tag___is (
"zlabel") || __autopos_tag___is (
"title"))
9592 update_autopos (get___autopos_tag__ ());
9596text::properties::update_units (
void)
9598 if (! units_is (
"data"))
9600 set_xliminclude (
"off");
9601 set_yliminclude (
"off");
9602 set_zliminclude (
"off");
9605 Matrix pos = get_position ().matrix_value ();
9612 bool autopos = positionmode_is (
"auto");
9617 set_positionmode (
"auto");
9619 if (units_is (
"data"))
9621 set_xliminclude (
"on");
9622 set_yliminclude (
"on");
9624 set_zliminclude (
"off");
9627 m_cached_units = get_units ();
9631text::properties::get___fontsize_points__ (
double box_pix_height)
const
9633 double fontsz = get_fontsize ();
9634 double parent_height = box_pix_height;
9639 graphics_object go (gh_mgr.get_object (get___myhandle__ ()));
9641 if (fontunits_is (
"normalized") && parent_height <= 0)
9643 graphics_object ax (go.get_ancestor (
"axes"));
9645 parent_height = ax.get_properties ().get_boundingbox (
true).elem (3);
9654image::properties::get_color_data (
void)
const
9656 return convert_cdata (*
this, get_cdata (), cdatamapping_is (
"scaled"), 3);
9668 =
dynamic_cast<axes::properties&
> (go.get_ancestor (
"axes").get_properties ());
9669 parent_axes_prop.trigger_normals_calc ();
9673light::properties::update_visible (
void)
9678 graphics_object go = gh_mgr.get_object (get___myhandle__ ());
9681 (go.get_ancestor (
"axes").get_properties ());
9683 ax_props.increase_num_lights ();
9685 ax_props.decrease_num_lights ();
9691patch::properties::get_do_lighting (
void)
const
9696 graphics_object go = gh_mgr.get_object (get___myhandle__ ());
9699 (go.get_ancestor (
"axes").get_properties ());
9701 return (ax_props.get_num_lights () > 0);
9705patch::properties::get_color_data (
void)
const
9711 return convert_cdata (*
this, fvc, cdatamapping_is (
"scaled"), 2);
9717patch::properties::update_fvc (
void)
9722 Matrix xd = get_xdata ().matrix_value ();
9723 Matrix yd = get_ydata ().matrix_value ();
9724 Matrix zd = get_zdata ().matrix_value ();
9725 NDArray cd = get_cdata ().array_value ();
9727 m_bad_data_msg =
"";
9731 m_bad_data_msg =
"x/y/zdata must have the same dimensions";
9740 if (nr == 1 && nc > 1)
9766 vert(kk, 0) = xd(ii, jj);
9767 vert(kk, 1) = yd(ii, jj);
9769 vert(kk, 2) = zd(ii, jj);
9771 idx(jj, ii) =
static_cast<double> (kk+1);
9779 if (cd.
ndims () == 3)
9782 dv(1) = cd.
dims ()(2);
9793 m_vertices.set (vert);
9794 m_facevertexcdata.set (fvc);
9803 double tol = 100 * std::numeric_limits<double>::epsilon ();
9804 EIG eig (cov,
false,
false,
true);
9806 return ev.
min () <= tol * ev.
max ();
9809std::vector<octave_idx_type>
9813 std::vector<octave_idx_type> coplanar_ends;
9817 plane_pivot(0, i) = vert(idx(0, jj)-1, i);
9835 fc(j-1, i) = vert(idx(j, jj)-1, i) - plane_pivot(i);
9840 coplanar_ends.push_back (nc - 1);
9841 return coplanar_ends;
9851 while (i_start < nc - 1)
9853 i_end = i_start + 2;
9856 coplanar_ends.push_back (nc - 1);
9868 fc(j, i) = vert(idx(j+i_start, jj)-1, i) - plane_pivot(i);
9885 fa(0, i) = vert(idx(i_end, jj)-1, i) - plane_pivot(i);
9889 i_start = i_end - 1;
9890 coplanar_ends.push_back (i_start);
9892 return coplanar_ends;
9896patch::properties::update_data (
void)
9902 Matrix vert = get_vertices ().matrix_value ();
9909 m_bad_data_msg =
"";
9910 if (
static_cast<double> (nvert) < idx.
row_max ().
max ())
9912 m_bad_data_msg = R
"(some vertices in "faces" property are undefined)";
9921 double valid_vert = idx(0, jj);
9922 bool turn_valid =
false;
9927 idx(ii, jj) = valid_vert;
9931 valid_vert = idx(ii, jj);
9937 int fcmax = idx.
rows ();
9938 if (fcmax > 3 && vert.
columns () > 2
9939 && ! (facecolor_is (
"none") && edgecolor_is (
"none")))
9941 m_coplanar_last_idx.resize (idx.
columns ());
9954 bool is_unclosed =
false;
9973 m_coplanar_last_idx.resize (0);
9978 bool pervertex =
false;
9980 if (fvc.
rows () == nfaces || fvc.
rows () == 1)
9983 dv(1) = fvc.
rows ();
9991 dv(0) = idx.
rows ();
10003 bool has_zd =
false;
10015 xd(ii, jj) = vert(row, 0);
10016 yd(ii, jj) = vert(row, 1);
10019 zd(ii, jj) = vert(row, 2);
10022 for (
int kk = 0; kk < fvc.
columns (); kk++)
10023 cd(ii, jj, kk) = fvc(row, kk);
10028 update_normals (
true);
10040 double x2,
double y2,
double z2,
10041 double&
x,
double& y,
double& z)
10043 x += (y1 * z2 - z1 * y2);
10044 y += (z1 * x2 - x1 * z2);
10045 z += (x1 * y2 - y1 * x2);
10049patch::properties::calc_face_normals (
Matrix& fn)
10051 Matrix v = get_vertices ().matrix_value ();
10052 Matrix f = get_faces ().matrix_value ();
10054 bool is_3D = (v.
columns () == 3);
10071 if (m_coplanar_last_idx.size () > 0 && m_coplanar_last_idx[i].size () > 1)
10083 double& nx = fnc(0);
10084 double& ny = fnc(1);
10085 double& nz = fnc(2);
10090 i1 =
f(i, 0) - 1; i2 =
f(i, 1) - 1; i3 =
f(i, nc-1) - 1;
10094 (v(i3, 0) - v(i1, 0), v(i3, 1) - v(i1, 1), v(i3, 2) - v(i1, 2),
10095 v(i2, 0) - v(i1, 0), v(i2, 1) - v(i1, 1), v(i2, 2) - v(i1, 2),
10099 nz = (v(i2, 0) - v(i1, 0)) * (v(i3, 1) - v(i1, 1)) -
10100 (v(i2, 1) - v(i1, 1)) * (v(i3, 0) - v(i1, 0));
10102 nz = (nz < 0) ? -nz : nz;
10112 j1 = nc - 1; j2 = 0;
10113 i1 =
f(i, j1) - 1; i2 =
f(i, j2) - 1;
10115 nx = (v(i2, 1) - v(i1, 1)) * (v(i1, 2) + v(i2, 2));
10116 ny = (v(i2, 2) - v(i1, 2)) * (v(i1, 0) + v(i2, 0));
10117 nz = (v(i2, 0) - v(i1, 0)) * (v(i1, 1) + v(i2, 1));
10122 i1 =
f(i, j1) - 1; i2 =
f(i, j2) - 1;
10124 nx += (v(i2, 1) - v(i1, 1)) * (v(i1, 2) + v(i2, 2));
10125 ny += (v(i2, 2) - v(i1, 2)) * (v(i1, 0) + v(i2, 0));
10126 nz += (v(i2, 0) - v(i1, 0)) * (v(i1, 1) + v(i2, 1));
10131 double n_len = sqrt (nx*nx+ny*ny+nz*nz);
10134 if ( n_len < std::numeric_limits<double>::epsilon () )
10139 fn(i, j) = fnc(j) / n_len;
10144patch::properties::update_face_normals (
bool reset,
bool force)
10149 if (force || ((facelighting_is (
"flat") || edgelighting_is (
"flat"))
10150 && get_do_lighting ()))
10152 Matrix f = get_faces ().matrix_value ();
10155 Matrix fn (num_f, 3, 0.0);
10157 calc_face_normals (fn);
10158 m_facenormals = fn;
10161 m_facenormals =
Matrix ();
10165patch::properties::update_vertex_normals (
bool reset,
bool force)
10170 if (force || ((facelighting_is (
"gouraud") || facelighting_is (
"phong")
10171 || edgelighting_is (
"gouraud") || edgelighting_is (
"phong"))
10172 && get_do_lighting ()))
10174 Matrix v = get_vertices ().matrix_value ();
10175 Matrix f = get_faces ().matrix_value ();
10186 Matrix fn = get_facenormals ().matrix_value ();
10190 fn =
Matrix (num_f, 3, 0.0);
10191 calc_face_normals (fn);
10203 std::vector<std::vector<RowVector>> vec_vn (num_v);
10220 Matrix vn (num_v, 3, 0.0);
10223 std::vector<RowVector>::iterator it = vec_vn[i].begin ();
10228 if (it != vec_vn[i].end ())
10239 for (++it; it != vec_vn[i].end (); ++it)
10244 double dir = (vn0(0)*vn1(0) + vn0(1)*vn1(1) + vn0(2)*vn1(2) < 0) ? -1 : 1;
10246 vn0(j) += dir * vn1(j);
10250 double n_len = sqrt (vn0(0)*vn0(0)+vn0(1)*vn0(1)+vn0(2)*vn0(2));
10254 vn(i, j) = vn0(j)/n_len;
10258 m_vertexnormals = vn;
10261 m_vertexnormals =
Matrix ();
10272 m_properties.update_normals (
true);
10277patch::reset_default_properties (
void)
10280 m_default_properties = property_list ();
10286 m_properties.update_normals (
true);
10292scatter::properties::get_color_data (
void)
const
10302scatter::properties::update_data (
void)
10304 Matrix xd = get_xdata ().matrix_value ();
10305 Matrix yd = get_ydata ().matrix_value ();
10306 Matrix zd = get_zdata ().matrix_value ();
10307 Matrix cd = get_cdata ().matrix_value ();
10308 Matrix sd = get_sizedata ().matrix_value ();
10310 m_bad_data_msg =
"";
10314 m_bad_data_msg =
"x/y/zdata must have the same dimensions";
10322 if (! cd.
isempty () && (c_rows != 1 || c_cols != 3)
10323 && (c_rows != x_rows || (c_cols != 1 && c_cols != 3)))
10325 m_bad_data_msg =
"cdata must be an rgb triplet or have the same number of "
10326 "rows as X and one or three columns";
10331 if (s_rows != 1 && s_rows != x_rows)
10333 m_bad_data_msg =
"sizedata must be a scalar or a vector with the same "
10342scatter::properties::update_color (
void)
10347 Matrix series_idx = get_seriesindex ().matrix_value ();
10354 graphics_object go = gh_mgr.get_object (get___myhandle__ ());
10358 (go.get_ancestor (
"axes").get_properties ());
10360 Matrix color_order = parent_axes_prop.get_colororder ().matrix_value ();
10362 % color_order.
rows ();
10365 color(0) = color_order(s, 0);
10366 color(1) = color_order(s, 1);
10367 color(2) = color_order(s, 2);
10372 set_cdatamode (
"auto");
10380 Matrix series_idx = m_properties.get_seriesindex ().matrix_value ();
10386 (go.get_ancestor (
"axes").get_properties ());
10388 if (! parent_axes_prop.nextplot_is (
"add"))
10389 parent_axes_prop.set_nextseriesindex (1);
10391 series_idx.
resize (1, 1);
10392 series_idx(0) = parent_axes_prop.get_nextseriesindex ();
10393 m_properties.set_seriesindex (series_idx);
10395 parent_axes_prop.set_nextseriesindex
10396 (parent_axes_prop.get_nextseriesindex () + 1);
10399 if (m_properties.cdatamode_is (
"auto"))
10400 m_properties.update_color ();
10406surface::properties::get_color_data (
void)
const
10408 return convert_cdata (*
this, get_cdata (), cdatamapping_is (
"scaled"), 3);
10412surface::properties::get_do_lighting (
void)
const
10417 graphics_object go = gh_mgr.get_object (get___myhandle__ ());
10420 (go.get_ancestor (
"axes").get_properties ());
10422 return (ax_prop.get_num_lights () > 0);
10426surface::properties::update_face_normals (
bool reset,
bool force)
10428 if (! facenormalsmode_is (
"auto"))
10431 if (force || ((facelighting_is (
"flat") || edgelighting_is (
"flat"))
10432 && get_do_lighting ()))
10434 Matrix x = get_xdata ().matrix_value ();
10435 Matrix y = get_ydata ().matrix_value ();
10436 Matrix z = get_zdata ().matrix_value ();
10447 if (
x.columns () != p || y.
rows () != q)
10450 bool x_mat = (
x.rows () == q);
10451 bool y_mat = (y.
columns () == p);
10455 int i1, i2, j1, j2;
10458 double x0, x1, x2, x3, y0, y1, y2, y3, z0, z1, z2, z3;
10459 double x1m0, x2m1, x3m2, x0m3, y1m0, y2m1, y3m2, y0m3;
10460 double x1p0, x2p1, x3p2, x0p3, y1p0, y2p1, y3p2, y0p3;
10462 x2m1 = x0m3 = y1m0 = y3m2 = 0;
10465 x1p0 = x3p2 = y2p1 = y0p3 = 1;
10468 for (
int i = 0; i < p-1; i++)
10473 for (
int j = 0; j < q-1; j++)
10478 if (x_mat || y_mat)
10480 x0 =
x(x_mat?j1:0, y_mat?i1:0);
10481 x1 =
x(x_mat?j1:0, y_mat?i2:0);
10482 x2 =
x(x_mat?j2:0, y_mat?i2:0);
10483 x3 =
x(x_mat?j2:0, y_mat?i1:0);
10492 y0 = y(x_mat?j1:0, y_mat?i1:0);
10493 y1 = y(x_mat?j1:0, y_mat?i2:0);
10494 y2 = y(x_mat?j2:0, y_mat?i2:0);
10495 y3 = y(x_mat?j2:0, y_mat?i1:0);
10506 double& nx = n(j, i, 0);
10507 double& ny = n(j, i, 1);
10508 double& nz = n(j, i, 2);
10518 nx = y1m0 * (z1 + z0) + y2m1 * (z2 + z1)
10519 + y3m2 * (z3 + z2) + y0m3 * (z0 + z3);
10520 ny = (z1 - z0) * x1p0 + (z2 - z1) * x2p1
10521 + (z3 - z2) * x3p2 + (z0 - z3) * x0p3;
10522 nz = x1m0 * y1p0 + x2m1 * y2p1 + x3m2 * y3p2 + x0m3 * y0p3;
10534 m_facenormals =
Matrix ();
10538surface::properties::update_vertex_normals (
bool reset,
bool force)
10540 if (! vertexnormalsmode_is (
"auto"))
10543 if (force || ((facelighting_is (
"gouraud") || facelighting_is (
"phong")
10544 || edgelighting_is (
"gouraud") || edgelighting_is (
"phong"))
10545 && get_do_lighting ()))
10547 Matrix x = get_xdata ().matrix_value ();
10548 Matrix y = get_ydata ().matrix_value ();
10549 Matrix z = get_zdata ().matrix_value ();
10560 if (
x.columns () != p || y.
rows () != q)
10565 bool x_mat = (
x.rows () == q);
10566 bool y_mat = (y.
columns () == p);
10568 int i1, i2, i3, j1, j2, j3;
10572 for (
int i = 0; i < p; i++)
10581 for (
int j = 0; j < q; j++)
10590 double& nx = n(j, i, 0);
10591 double& ny = n(j, i, 1);
10592 double& nz = n(j, i, 2);
10594 if ((j > 0) && (i > 0))
10597 (
x(j1,i-1)-
x(j2,i), y(j-1,i1)-y(j,i2), z(j-1,i-1)-z(j,i),
10598 x(j2,i-1)-
x(j1,i), y(j,i1)-y(j-1,i2), z(j,i-1)-z(j-1,i),
10601 if ((j > 0) && (i < (p -1)))
10604 (
x(j1,i+1)-
x(j2,i), y(j-1,i3)-y(j,i2), z(j-1,i+1)-z(j,i),
10605 x(j1,i)-
x(j2,i+1), y(j-1,i2)-y(j,i3), z(j-1,i)-z(j,i+1),
10608 if ((j < (q - 1)) && (i > 0))
10611 (
x(j2,i-1)-
x(j3,i), y(j,i1)-y(j+1,i2), z(j,i-1)-z(j+1,i),
10612 x(j3,i-1)-
x(j2,i), y(j+1,i1)-y(j,i2), z(j+1,i-1)-z(j,i),
10615 if ((j < (q - 1)) && (i < (p -1)))
10618 (
x(j3,i)-
x(j2,i+1), y(j+1,i2)-y(j,i3), z(j+1,i)-z(j,i+1),
10619 x(j3,i+1)-
x(j2,i), y(j+1,i3)-y(j,i2), z(j+1,i+1)-z(j,i),
10629 m_vertexnormals = n;
10632 m_vertexnormals =
Matrix ();
10635DEFMETHOD (__update_normals__, interp, args, ,
10643 gh_manager& gh_mgr = interp.get_gh_manager ();
10647 if (args.
length () != 1)
10652 graphics_object go = gh_mgr.get_object (val);
10654 if (go.isa (
"surface"))
10658 props.update_normals (
false,
true);
10660 else if (go.isa (
"patch"))
10664 props.update_normals (
false,
true);
10667 error (
"__update_normals__: "
10668 "H must be a handle to a valid surface or patch object.");
10705hggroup::properties::remove_child (
const graphics_handle& h,
bool from_root)
10710 graphics_object go = gh_mgr.get_object (h);
10712 if (! from_root && go.isa (
"light") && go.get_properties ().is_visible ())
10715 =
dynamic_cast<axes::properties&
> (go.get_ancestor (
"axes").get_properties ());
10716 ax_props.decrease_num_lights ();
10718 base_properties::remove_child (h, from_root);
10728 graphics_object go = gh_mgr.get_object (h);
10730 if (go.isa (
"light") && go.get_properties ().is_visible ())
10733 =
dynamic_cast<axes::properties&
> (go.get_ancestor (
"axes").get_properties ());
10734 ax_props.increase_num_lights ();
10741hggroup::properties::update_limits (
void)
const
10746 graphics_object go = gh_mgr.get_object (m___myhandle__);
10750 go.update_axis_limits (
"xlim");
10751 go.update_axis_limits (
"ylim");
10752 go.update_axis_limits (
"zlim");
10753 go.update_axis_limits (
"clim");
10754 go.update_axis_limits (
"alim");
10764 graphics_object go = gh_mgr.get_object (m___myhandle__);
10768 go.update_axis_limits (
"xlim", h);
10769 go.update_axis_limits (
"ylim", h);
10770 go.update_axis_limits (
"zlim", h);
10771 go.update_axis_limits (
"clim", h);
10772 go.update_axis_limits (
"alim", h);
10779hggroup::update_axis_limits (
const std::string& axis_type,
10795 char update_type = 0;
10797 if (axis_type ==
"xlim" || axis_type ==
"xliminclude")
10799 limits = m_properties.get_xlim ().matrix_value ();
10802 else if (axis_type ==
"ylim" || axis_type ==
"yliminclude")
10804 limits = m_properties.get_ylim ().matrix_value ();
10807 else if (axis_type ==
"zlim" || axis_type ==
"zliminclude")
10809 limits = m_properties.get_zlim ().matrix_value ();
10812 else if (axis_type ==
"clim" || axis_type ==
"climinclude")
10814 limits = m_properties.get_clim ().matrix_value ();
10817 else if (axis_type ==
"alim" || axis_type ==
"aliminclude")
10819 limits = m_properties.get_alim ().matrix_value ();
10823 if (limits.
numel () == 4)
10841 limits(0) = min_val;
10842 limits(1) = max_val;
10843 limits(2) = min_pos;
10844 limits(3) = max_neg;
10851 if (limits(0) != min_val || limits(1) != max_val
10852 || limits(2) != min_pos || limits(3) != max_neg)
10854 limits(0) = min_val;
10855 limits(1) = max_val;
10856 limits(2) = min_pos;
10857 limits(3) = max_neg;
10859 switch (update_type)
10862 m_properties.set_xlim (limits);
10866 m_properties.set_ylim (limits);
10870 m_properties.set_zlim (limits);
10874 m_properties.set_clim (limits);
10878 m_properties.set_alim (limits);
10886 base_graphics_object::update_axis_limits (axis_type, hg);
10891hggroup::update_axis_limits (
const std::string& axis_type)
10896 Matrix kids = m_properties.get_children ();
10903 char update_type = 0;
10905 if (axis_type ==
"xlim" || axis_type ==
"xliminclude")
10911 else if (axis_type ==
"ylim" || axis_type ==
"yliminclude")
10917 else if (axis_type ==
"zlim" || axis_type ==
"zliminclude")
10923 else if (axis_type ==
"clim" || axis_type ==
"climinclude")
10929 else if (axis_type ==
"alim" || axis_type ==
"aliminclude")
10940 limits(0) = min_val;
10941 limits(1) = max_val;
10942 limits(2) = min_pos;
10943 limits(3) = max_neg;
10945 switch (update_type)
10948 m_properties.set_xlim (limits);
10952 m_properties.set_ylim (limits);
10956 m_properties.set_zlim (limits);
10960 m_properties.set_clim (limits);
10964 m_properties.set_alim (limits);
10971 base_graphics_object::update_axis_limits (axis_type);
10977uicontextmenu::properties::update_beingdeleted (
void)
10980 if (m_beingdeleted.is (
"on"))
10985 std::list<graphics_handle> lst = get_dependent_obj_list ();
10987 for (
auto& hobj : lst)
10989 graphics_object go = gh_mgr.get_object (hobj);
10991 if (go.valid_object ()
10992 && go.get (
"contextmenu") == get___myhandle__ ())
10993 go.set (
"contextmenu",
Matrix ());
11028uicontrol::properties::get_extent (
void)
const
11030 Matrix m = m_extent.get ().matrix_value ();
11035 graphics_object parent_go = gh_mgr.get_object (get_parent ());
11037 Matrix parent_bbox = parent_go.get_properties ().get_boundingbox (
true);
11044uicontrol::properties::update_text_extent (
void)
11051 graphics_object go = gh_mgr.get_object (get___myhandle__ ());
11053 set_extent (go.get_toolkit ().get_text_extent (go));
11057uicontrol::properties::update_units (
void)
11059 Matrix pos = get_position ().matrix_value ();
11064 graphics_object parent_go = gh_mgr.get_object (get_parent ());
11066 Matrix parent_bbox = parent_go.get_properties ().get_boundingbox (
true);
11070 set_position (pos);
11072 m_cached_units = get_units ();
11076uicontrol::properties::set_style (
const octave_value& st)
11081 graphics_object go_parent = gh_mgr.get_object (get_parent ());
11082 if (go_parent.valid_object () && go_parent.isa (
"uibuttongroup"))
11084 bool was_button = style_is (
"radiobutton") || style_is (
"togglebutton");
11086 bool now_button = style_is (
"radiobutton") || style_is (
"togglebutton");
11090 if (! was_button && now_button && ! props.get_selectedobject ().ok ())
11092 props.set_selectedobject (get___myhandle__ ().value ());
11095 else if (was_button && ! now_button
11096 && (props.get_selectedobject ().value ()
11097 == get___myhandle__ ().value ()))
11098 props.set_selectedobject (
Matrix ());
11102 bool modified = m_style.set (st,
true,
false);
11107 if (style_is (
"listbox") || style_is (
"popupmenu"))
11109 Matrix v = m_value.get ().matrix_value ();
11110 if (v.
numel () == 1 && v(0) == 0)
11116 graphics_object go = gh_mgr.get_object (get___myhandle__ ());
11119 go.update (m_style.get_id ());
11124uicontrol::properties::get_boundingbox (
bool,
11125 const Matrix& parent_pix_size)
const
11127 Matrix pos = get_position ().matrix_value ();
11128 Matrix parent_size (parent_pix_size);
11135 graphics_object go = gh_mgr.get_object (get_parent ());
11137 if (go.valid_object ())
11138 parent_size = go.get_properties ().get_boundingbox (
true).
extract_n (0, 2, 1, 2);
11147 pos(1) = parent_size(1) - pos(1) - pos(3);
11153uicontrol::properties::set_fontunits (
const octave_value& val)
11157 if (m_fontunits.set (val,
true))
11159 update_fontunits (old_fontunits);
11165uicontrol::properties::update_fontunits (
const caseless_str& old_units)
11168 double parent_height = get_boundingbox (
false).elem (3);
11169 double fontsz = get_fontsize ();
11177uicontrol::properties::get___fontsize_points__ (
double box_pix_height)
const
11179 double fontsz = get_fontsize ();
11180 double parent_height = box_pix_height;
11182 if (fontunits_is (
"normalized") && parent_height <= 0)
11183 parent_height = get_boundingbox (
false).elem (3);
11191uibuttongroup::properties::get_boundingbox (
bool internal,
11192 const Matrix& parent_pix_size)
const
11194 Matrix pos = get_position ().matrix_value ();
11195 Matrix parent_size (parent_pix_size);
11202 graphics_object go = gh_mgr.get_object (get_parent ());
11204 parent_size = go.get_properties ().get_boundingbox (
true).
extract_n (0, 2, 1, 2);
11211 pos(1) = parent_size(1) - pos(1) - pos(3);
11215 double outer_height = pos(3);
11217 pos(0) = pos(1) = 0;
11219 if (! bordertype_is (
"none"))
11221 double bw = get_borderwidth ();
11224 if (bordertype_is (
"etchedin") || bordertype_is (
"etchedout"))
11227 pos(0) += mul * bw;
11228 pos(1) += mul * bw;
11229 pos(2) -= 2 * mul * bw;
11230 pos(3) -= 2 * mul * bw;
11233 if (! get_title ().empty ())
11235 double fontsz = get_fontsize ();
11237 if (! fontunits_is (
"pixels"))
11241 if (fontunits_is (
"points"))
11242 fontsz *= (res / 72.0);
11243 else if (fontunits_is (
"inches"))
11245 else if (fontunits_is (
"centimeters"))
11246 fontsz *= (res / 2.54);
11247 else if (fontunits_is (
"normalized"))
11248 fontsz *= outer_height;
11251 if (titleposition_is (
"lefttop") || titleposition_is (
"centertop")
11252 || titleposition_is (
"righttop"))
11253 pos(1) += (fontsz / 2);
11254 pos(3) -= (fontsz / 2);
11262uibuttongroup::properties::set_position (
const octave_value& v)
11265 bool modified =
false;
11267 old_bb = get_boundingbox (
true);
11268 modified = m_position.set (v,
false);
11269 new_bb = get_boundingbox (
true);
11271 if (old_bb != new_bb)
11273 if (old_bb(2) != new_bb(2) || old_bb(3) != new_bb(3))
11278 if (! get_resizefcn ().isempty ())
11279 gh_mgr.post_callback (m___myhandle__,
"resizefcn");
11281 if (! get_sizechangedfcn ().isempty ())
11282 gh_mgr.post_callback (m___myhandle__,
"sizechangedfcn");
11284 update_boundingbox ();
11290 m_position.run_listeners (GCB_POSTSET);
11296uibuttongroup::properties::set_units (
const octave_value& val)
11300 if (m_units.set (val,
true))
11302 update_units (old_units);
11308uibuttongroup::properties::update_units (
const caseless_str& old_units)
11310 Matrix pos = get_position ().matrix_value ();
11315 graphics_object parent_go = gh_mgr.get_object (get_parent ());
11317 Matrix parent_bbox = parent_go.get_properties ().get_boundingbox (
true);
11321 set_position (pos);
11325uibuttongroup::properties::set_fontunits (
const octave_value& val)
11329 if (m_fontunits.set (val,
true))
11331 update_fontunits (old_fontunits);
11337uibuttongroup::properties::update_fontunits (
const caseless_str& old_units)
11340 double parent_height = get_boundingbox (
false).elem (3);
11341 double fontsz = get_fontsize ();
11349uibuttongroup::properties::get___fontsize_points__ (
double box_pix_height)
const
11351 double fontsz = get_fontsize ();
11352 double parent_height = box_pix_height;
11354 if (fontunits_is (
"normalized") && parent_height <= 0)
11355 parent_height = get_boundingbox (
false).elem (3);
11361uibuttongroup::properties::set_selectedobject (
const octave_value& v)
11364 m_selectedobject = current_selectedobject;
11367 if (current_selectedobject.
ok ())
11381 graphics_object go (gh_mgr.get_object (val));
11383 base_properties& gop = go.get_properties ();
11385 if (go.valid_object ()
11386 && gop.get_parent () == get___myhandle__ ()
11387 && go.isa (
"uicontrol"))
11392 if (style.
compare (
"radiobutton") || style.
compare (
"togglebutton"))
11394 m_selectedobject = val;
11408 if (h.
value () == current_selected.
value ())
11409 set_selectedobject (
Matrix ());
11411 base_properties::remove_child (h, from_root);
11420 bool has_selected = current_selected.
ok ();
11425 graphics_object go = gh_mgr.get_object (h);
11427 if (! has_selected && go.valid_object () && go.isa (
"uicontrol"))
11431 if (props.style_is (
"radiobutton") || props.style_is (
"togglebutton"))
11432 set_selectedobject (h.
value ());
11439uipanel::properties::get_boundingbox (
bool internal,
11440 const Matrix& parent_pix_size)
const
11442 Matrix pos = get_position ().matrix_value ();
11443 Matrix parent_size (parent_pix_size);
11450 graphics_object go = gh_mgr.get_object (get_parent ());
11452 parent_size = go.get_properties ().get_boundingbox (
true).
extract_n (0, 2, 1, 2);
11459 pos(1) = parent_size(1) - pos(1) - pos(3);
11463 double outer_height = pos(3);
11465 pos(0) = pos(1) = 0;
11467 if (! bordertype_is (
"none"))
11469 double bw = get_borderwidth ();
11472 if (bordertype_is (
"etchedin") || bordertype_is (
"etchedout"))
11475 pos(0) += mul * bw;
11476 pos(1) += mul * bw;
11477 pos(2) -= 2 * mul * bw;
11478 pos(3) -= 2 * mul * bw;
11481 if (! get_title ().empty ())
11483 double fontsz = get_fontsize ();
11485 if (! fontunits_is (
"pixels"))
11489 if (fontunits_is (
"points"))
11490 fontsz *= (res / 72.0);
11491 else if (fontunits_is (
"inches"))
11493 else if (fontunits_is (
"centimeters"))
11494 fontsz *= (res / 2.54);
11495 else if (fontunits_is (
"normalized"))
11496 fontsz *= outer_height;
11499 if (titleposition_is (
"lefttop") || titleposition_is (
"centertop")
11500 || titleposition_is (
"righttop"))
11501 pos(1) += (fontsz / 2);
11502 pos(3) -= (fontsz / 2);
11510uipanel::properties::set_position (
const octave_value& v)
11513 bool modified =
false;
11515 old_bb = get_boundingbox (
true);
11516 modified = m_position.set (v,
false);
11517 new_bb = get_boundingbox (
true);
11519 if (old_bb != new_bb)
11521 if (old_bb(2) != new_bb(2) || old_bb(3) != new_bb(3))
11526 if (! get_resizefcn ().isempty ())
11527 gh_mgr.post_callback (m___myhandle__,
"resizefcn");
11529 if (! get_sizechangedfcn ().isempty ())
11530 gh_mgr.post_callback (m___myhandle__,
"sizechangedfcn");
11532 update_boundingbox ();
11538 m_position.run_listeners (GCB_POSTSET);
11545uipanel::properties::set_units (
const octave_value& val)
11549 if (m_units.set (val,
true))
11551 update_units (old_units);
11557uipanel::properties::update_units (
const caseless_str& old_units)
11559 Matrix pos = get_position ().matrix_value ();
11564 graphics_object parent_go = gh_mgr.get_object (get_parent ());
11566 Matrix parent_bbox = parent_go.get_properties ().get_boundingbox (
true);
11570 set_position (pos);
11574uipanel::properties::set_fontunits (
const octave_value& val)
11578 if (m_fontunits.set (val,
true))
11580 update_fontunits (old_fontunits);
11586uipanel::properties::update_fontunits (
const caseless_str& old_units)
11589 double parent_height = get_boundingbox (
false).elem (3);
11590 double fontsz = get_fontsize ();
11598uipanel::properties::get___fontsize_points__ (
double box_pix_height)
const
11600 double fontsz = get_fontsize ();
11601 double parent_height = box_pix_height;
11603 if (fontunits_is (
"normalized") && parent_height <= 0)
11604 parent_height = get_boundingbox (
false).elem (3);
11612uitable::properties::get_boundingbox (
bool,
11613 const Matrix& parent_pix_size)
const
11615 Matrix pos = get_position ().matrix_value ();
11616 Matrix parent_size (parent_pix_size);
11623 graphics_object go = gh_mgr.get_object (get_parent ());
11625 parent_size = go.get_properties ().get_boundingbox (
true).
extract_n (0, 2, 1, 2);
11632 pos(1) = parent_size(1) - pos(1) - pos(3);
11638uitable::properties::set_columnformat (
const octave_value& val)
11645 if (m_columnformat.set (val,
true))
11652 for (
int i = 0; i < cell_value.
numel (); i++)
11660 for (
int j = 0; j < popup.
numel (); j++)
11664 error (
"set: pop-up menu definitions must be non-empty strings");
11669 error (
"set: columnformat definintions must be a cellstr of "
11670 "either 'char', 'short [e|g|eng]?', 'long [e|g|eng]?', "
11671 "'numeric', 'bank', '+', 'rat', 'logical', "
11672 "or a cellstr of non-empty pop-up menu definitions.");
11676 if (m_columnformat.set (val,
true))
11681 if (m_columnformat.set (
Cell (),
true))
11686 error (
"set: expecting cell of strings");
11691uitable::properties::set_columnwidth (
const octave_value& val)
11693 bool error_exists =
false;
11696 error_exists =
false;
11700 for (
int i = 0; i < cell_value.
numel (); i++)
11706 error_exists =
true;
11710 error_exists =
true;
11714 error_exists =
true;
11719 error_exists =
true;
11722 error (
"set: expecting either 'auto' or a cell of pixel values or auto");
11725 if (m_columnwidth.set (val,
true))
11731uitable::properties::set_units (
const octave_value& val)
11735 if (m_units.set (val,
true))
11737 update_units (old_units);
11743uitable::properties::update_units (
const caseless_str& old_units)
11745 Matrix pos = get_position ().matrix_value ();
11750 graphics_object parent_go = gh_mgr.get_object (get_parent ());
11752 Matrix parent_bbox = parent_go.get_properties ().get_boundingbox (
true);
11756 set_position (pos);
11760uitable::properties::set_fontunits (
const octave_value& val)
11764 if (m_fontunits.set (val,
true))
11766 update_fontunits (old_fontunits);
11772uitable::properties::update_fontunits (
const caseless_str& old_units)
11775 double parent_height = get_boundingbox (
false).elem (3);
11776 double fontsz = get_fontsize ();
11784uitable::properties::get___fontsize_points__ (
double box_pix_height)
const
11786 double fontsz = get_fontsize ();
11787 double parent_height = box_pix_height;
11789 if (fontunits_is (
"normalized") && parent_height <= 0)
11790 parent_height = get_boundingbox (
false).elem (3);
11796uitable::properties::get_fontsize_pixels (
double box_pix_height)
const
11798 double fontsz = get_fontsize ();
11799 double parent_height = box_pix_height;
11801 if (fontunits_is (
"normalized") && parent_height <= 0)
11802 parent_height = get_boundingbox (
false).elem (3);
11808uitable::properties::get_backgroundcolor_rgb (
void)
11810 Matrix bg = m_backgroundcolor.get ().matrix_value ();
11815uitable::properties::get_alternatebackgroundcolor_rgb (
void)
11818 Matrix bg = m_backgroundcolor.get ().matrix_value ();
11819 if (bg.
rows () > 1)
11826uitable::properties::get_extent_matrix (
void)
const
11828 return m_extent.get ().matrix_value ();
11832uitable::properties::get_extent (
void)
const
11835 Matrix m = m_extent.get ().matrix_value ();
11840 graphics_object parent_go = gh_mgr.get_object (get_parent ());
11844 Matrix parent_bbox = parent_go.get_properties ().get_boundingbox (
true);
11856uitoolbar::get_default (
const caseless_str& pname)
const
11867 graphics_object parent_go = gh_mgr.get_object (parent_h);
11869 retval = parent_go.get_default (pname);
11876uitoolbar::reset_default_properties (
void)
11879 m_default_properties = property_list ();
11881 remove_all_listeners ();
11888base_graphics_object::get_default (
const caseless_str& pname)
const
11895 graphics_object parent_go = gh_mgr.get_object (parent_h);
11897 return parent_go.get_default (type () + pname);
11906 graphics_object parent_go = gh_mgr.get_object (0);
11908 return parent_go.get_factory_default (type () +
name);
11913gh_manager::gh_manager (octave::interpreter& interp)
11914 : m_interpreter (interp), m_handle_map (), m_handle_free_list (),
11915 m_next_handle (-1.0 - (rand () + 1.0) / (RAND_MAX + 2.0)),
11916 m_figure_list (), m_graphics_lock (), m_event_queue (),
11917 m_callback_objects (), m_event_processing (0)
11919 m_handle_map[0] = graphics_object (
new root_figure ());
11930 bool integer_figure_handle,
11931 bool call_createfcn,
bool notify_toolkit)
11938 error (
"gh_manager::make_graphics_handle: invalid object type '%s'",
11941 graphics_object go (bgo);
11943 m_handle_map[h] = go;
11945 if (go_name ==
"axes")
11954 graphics_object tgo;
11956 tgo = get_object (props.get_xlabel ());
11957 tgo.override_defaults ();
11959 tgo = get_object (props.get_ylabel ());
11960 tgo.override_defaults ();
11962 tgo = get_object (props.get_zlabel ());
11963 tgo.override_defaults ();
11965 tgo = get_object (props.get_title ());
11966 tgo.override_defaults ();
11971 go.override_defaults ();
11973 if (call_createfcn)
11974 bgo->get_properties ().execute_createfcn ();
11977 if (notify_toolkit)
11984gh_manager::make_figure_handle (
double val,
bool notify_toolkit)
11988 base_graphics_object *bgo =
new figure (h, 0);
11989 graphics_object go (bgo);
11991 m_handle_map[h] = go;
11994 if (notify_toolkit)
11997 go.override_defaults ();
12007 m_figure_list.push_front (h);
12013 for (
auto it = m_figure_list.begin (); it != m_figure_list.end (); it++)
12017 m_figure_list.erase (it);
12029 int busyaction = base_graphics_event::QUEUE)
12031 m_callback (), m_callback_data (data) { }
12035 int busyaction = base_graphics_event::QUEUE)
12037 m_callback (cb), m_callback_data (data) { }
12044 if (m_callback.is_defined ())
12045 gh_mgr.execute_callback (m_handle, m_callback, m_callback_data);
12047 gh_mgr.execute_callback (m_handle, m_callback_name, m_callback_data);
12068 int busyaction = base_graphics_event::QUEUE)
12074 if (! m_mcode.empty ())
12079 graphics_object go = gh_mgr.get_object (m_handle);
12081 if (go.valid_object ())
12084 gh_mgr.execute_callback (m_handle, cb);
12120 m_function (m_function_data);
12135 const octave_value& value,
bool do_notify_toolkit =
true,
12136 bool redraw_figure =
false)
12138 m_property_value (value), m_notify_toolkit (do_notify_toolkit),
12139 m_redraw_figure (redraw_figure)
12148 graphics_object go = gh_mgr.get_object (m_handle);
12152 property p = go.get_properties ().get_property (m_property_name);
12162 if (go.isa (
"figure") && m_property_name ==
"position")
12166 fprops.set_position (m_property_value, m_notify_toolkit);
12168 else if (go.isa (
"figure") && m_property_name ==
"outerposition")
12172 fprops.set_outerposition (m_property_value, m_notify_toolkit);
12175 p.set (m_property_value,
true, m_notify_toolkit);
12177 if (m_redraw_figure)
12179 if (! go.isa (
"figure"))
12180 go = go.get_ancestor (
"figure");
12182 if (go.valid_object ())
12186 fprops.get_toolkit ().redraw_figure (go);
12208 const std::string&
name,
12221 return graphics_event (
new callback_event (h, cb, data, busyaction));
12226 const std::string& cmd,
12229 return graphics_event (
new mcode_event (h, cmd, busyaction));
12233graphics_event::create_function_event (graphics_event::event_fcn fcn,
12241 const std::string&
name,
12243 bool notify_toolkit,
bool redraw_figure)
12245 return graphics_event (
new set_event (h,
name, data, notify_toolkit,
12254 graphics_object go = gh_mgr.get_object (0);
12263gh_manager::restore_gcbo (
void)
12267 m_callback_objects.pop_front ();
12282 post_event (graphics_event::create_callback_event (h, l));
12304 (&gh_manager::restore_gcbo,
this);
12306 graphics_object go (get_object (h));
12312 m_callback_objects.push_front (go);
12330 m_interpreter.eval_string (s,
false, status, 0);
12332 catch (
const octave::execution_exception& ee)
12334 m_interpreter.handle_exception (ee);
12340 || cb.
cell_value ()(0).is_function_handle ()))
12346 for (
int i = 1; i < c.
numel () ; i++)
12352 error (
"trying to execute non-executable object (class = %s)",
12364 catch (
const octave::execution_exception& ee)
12366 m_interpreter.handle_exception (ee);
12374 std::string go_name
12375 = go.get_properties ().graphics_object_name ();
12377 if (go_name.length () > 1
12378 && go_name[0] ==
'u' && go_name[1] ==
'i')
12393 return gh_mgr.process_events ();
12397gh_manager::post_event (
const graphics_event& e)
12399 m_event_queue.push_back (e);
12410 graphics_object go = get_object (h);
12412 if (go.valid_object ())
12415 int busyaction = base_graphics_event::QUEUE;
12417 if (cname ==
"deletefcn" || cname ==
"createfcn"
12418 || cname ==
"closerequestfcn"
12419 || ((go.isa (
"figure") || go.isa (
"uipanel")
12420 || go.isa (
"uibuttongroup"))
12421 && (cname ==
"resizefcn" || cname ==
"sizechangedfcn")))
12422 busyaction = base_graphics_event::INTERRUPT;
12423 else if (go.get_properties ().get_busyaction () ==
"cancel")
12424 busyaction = base_graphics_event::CANCEL;
12428 if (cname ==
"closerequestfcn")
12430 std::string cmd (
"close (gcbf ());");
12431 post_event (graphics_event::create_mcode_event (h, cmd, busyaction));
12434 post_event (graphics_event::create_callback_event (h,
name, data,
12440gh_manager::post_function (graphics_event::event_fcn fcn,
void *fcn_data)
12444 post_event (graphics_event::create_function_event (fcn, fcn_data));
12450 bool redraw_figure)
12454 post_event (graphics_event::create_set_event (h,
name, value, notify_toolkit,
12459gh_manager::process_events (
bool force)
12463 bool events_executed =
false;
12467 e = graphics_event ();
12472 if (! m_event_queue.empty ())
12474 if (m_callback_objects.empty () || force)
12476 e = m_event_queue.front ();
12478 m_event_queue.pop_front ();
12482 const graphics_object& go = m_callback_objects.front ();
12484 if (go.get_properties ().is_interruptible ())
12486 e = m_event_queue.front ();
12488 m_event_queue.pop_front ();
12492 std::list<graphics_event>::iterator p = m_event_queue.begin ();
12494 while (p != m_event_queue.end ())
12495 if (p->get_busyaction () == base_graphics_event::CANCEL)
12497 p = m_event_queue.erase (p);
12499 else if (p->get_busyaction ()
12500 == base_graphics_event::INTERRUPT)
12503 m_event_queue.erase (p);
12516 events_executed =
true;
12524 if (m_event_queue.empty () && m_event_processing == 0)
12528 if (events_executed)
12597gh_manager::enable_event_processing (
bool enable)
12603 m_event_processing++;
12609 m_event_processing--;
12611 if (m_event_queue.empty () && m_event_processing == 0)
12616property_list::plist_map_type
12617root_figure::init_factory_properties (
void)
12619 property_list::plist_map_type plist_map;
12621 plist_map[
"figure"] = figure::properties::factory_defaults ();
12622 plist_map[
"axes"] = axes::properties::factory_defaults ();
12623 plist_map[
"line"] = line::properties::factory_defaults ();
12624 plist_map[
"text"] = text::properties::factory_defaults ();
12625 plist_map[
"image"] = image::properties::factory_defaults ();
12626 plist_map[
"patch"] = patch::properties::factory_defaults ();
12627 plist_map[
"scatter"] = scatter::properties::factory_defaults ();
12628 plist_map[
"surface"] = surface::properties::factory_defaults ();
12629 plist_map[
"light"] = light::properties::factory_defaults ();
12630 plist_map[
"hggroup"] = hggroup::properties::factory_defaults ();
12631 plist_map[
"uimenu"] = uimenu::properties::factory_defaults ();
12632 plist_map[
"uicontrol"] = uicontrol::properties::factory_defaults ();
12633 plist_map[
"uibuttongroup"] = uibuttongroup::properties::factory_defaults ();
12634 plist_map[
"uipanel"] = uipanel::properties::factory_defaults ();
12635 plist_map[
"uicontextmenu"] = uicontextmenu::properties::factory_defaults ();
12636 plist_map[
"uitoolbar"] = uitoolbar::properties::factory_defaults ();
12637 plist_map[
"uipushtool"] = uipushtool::properties::factory_defaults ();
12638 plist_map[
"uitoggletool"] = uitoggletool::properties::factory_defaults ();
12656 gh_manager& gh_mgr = interp.get_gh_manager ();
12660 if (args.
length () != 1)
12690 return h.
ok () && gh_mgr.is_handle_visible (h);
12723DEFUN (__is_handle_visible__, args, ,
12729 if (args.
length () != 1)
12750 if (args.
length () != 1)
12754 ColumnVector hcv = args(0).xvector_value (
"reset: H must be a graphics handle");
12756 gh_manager& gh_mgr = interp.get_gh_manager ();
12760 gh_mgr.get_object (hcv(n)).reset_default_properties ();
12953 gh_manager& gh_mgr = interp.get_gh_manager ();
12957 int nargin = args.
length ();
12965 ColumnVector hcv = args(0).xvector_value (
"set: H must be a graphics handle");
12967 bool request_drawnow =
false;
12972 graphics_object go = gh_mgr.get_object (hcv(n));
12975 error (
"set: invalid handle (= %g)", hcv(n));
12977 if (nargin == 3 && args(1).iscellstr () && args(2).iscell ())
12979 if (args(2).cell_value ().rows () == 1)
12980 go.set (args(1).cellstr_value (), args(2).cell_value (), 0);
12981 else if (hcv.
numel () == args(2).cell_value ().rows ())
12982 go.set (args(1).cellstr_value (), args(2).cell_value (), n);
12984 error (
"set: number of graphics handles must match number of "
12985 "value rows (%" OCTAVE_IDX_TYPE_FORMAT
" != "
12986 "%" OCTAVE_IDX_TYPE_FORMAT
")",
12987 hcv.
numel (), args(2).cell_value ().rows ());
12989 else if (nargin == 2 && args(1).isstruct ())
12990 go.set (args(1).map_value ());
12991 else if (nargin == 2 && args(1).is_string ())
12993 std::string
property = args(1).string_value ();
12995 property.begin (), tolower);
12999 if (go.has_readonly_property (property))
13004 <<
" is read-only" << std::endl;
13005 else if (pmap.
isfield (property))
13008 retval = pmap.
getfield (property)(0);
13011 std::string s = go.value_as_string (property);
13017 error (R
"(set: unknown property "%s")", property.c_str ());
13019 else if (nargin == 1)
13022 retval = go.values_as_struct ();
13025 std::string s = go.values_as_string ();
13032 go.set (args.
splice (0, 1));
13035 request_drawnow =
true;
13038 if (request_drawnow)
13047 std::string retval;
13051 graphics_object go = gh_mgr.get_object (val);
13054 error (
"get: invalid handle (= %g)", val);
13073 gh_manager& gh_mgr = interp.get_gh_manager ();
13077 int nargin = args.
length ();
13079 if (nargin < 1 || nargin > 2)
13082 if (args(0).isempty ())
13085 ColumnVector hcv = args(0).xvector_value (
"get: H must be a graphics handle");
13089 if (nargin == 1 && hcv_len > 1)
13098 error (
"get: vector of handles must all have the same type");
13104 bool use_cell_format =
false;
13106 if (nargin > 1 && args(1).iscellstr ())
13112 use_cell_format =
true;
13118 graphics_object go = gh_mgr.get_object (hcv(n));
13121 error (
"get: invalid handle (= %g)", hcv(n));
13127 vals(n, m) = go.get (property);
13136 property = args(1).xstring_value (
"get: second argument must be property name or cell array of property names");
13142 graphics_object go = gh_mgr.get_object (hcv(n));
13145 error (
"get: invalid handle (= %g)", hcv(n));
13148 vals(n) = go.get ();
13150 vals(n) = go.get (property);
13154 if (use_cell_format)
13162 else if (vals_len == 1)
13164 else if (vals_len > 1 && nargin == 1)
13169 tmp[n] = vals(n).scalar_map_value ();
13194 gh_manager& gh_mgr = interp.get_gh_manager ();
13198 if (args.
length () != 1)
13201 ColumnVector hcv = args(0).xvector_value (
"get: H must be a graphics handle");
13211 graphics_object go = gh_mgr.get_object (hcv(n));
13214 error (
"get: invalid handle (= %g)", hcv(n));
13219 vals(n) = go.get (
true);
13228 else if (vals_len == 1)
13229 return ovl (vals(0));
13236 bool integer_figure_handle,
13249 for (
int i = 0; i < xargs.
length (); i += 2)
13251 if (xargs(i).is_string () && p.
compare (xargs(i).string_value ()))
13253 if (i >= (xargs.
length () - 1))
13254 error (
"__go_%s__: missing value for parent property",
13257 val = xargs(i+1).double_value ();
13259 xargs = xargs.
splice (i, 2);
13265 val = args(0).xdouble_value (
"__go_%s__: invalid parent", go_name.c_str ());
13271 if (! parent.
ok ())
13272 error (
"__go_%s__: invalid parent", go_name.c_str ());
13278 h = gh_mgr.make_graphics_handle (go_name, parent,
13279 integer_figure_handle,
false,
false);
13281 catch (octave::execution_exception& ee)
13283 error (ee,
"__go_%s__: %s, unable to create graphics handle",
13284 go_name.c_str (), ee.message ().c_str ());
13291 catch (octave::execution_exception& ee)
13294 error (ee,
"__go_%s__: %s, unable to create graphics handle",
13295 go_name.c_str (), ee.message ().c_str ());
13303 retval = h.
value ();
13310DEFMETHOD (__go_figure__, interp, args, ,
13316 gh_manager& gh_mgr = interp.get_gh_manager ();
13320 if (args.
length () == 0)
13323 double val = args(0).xdouble_value (
"__go_figure__: figure number must be a double value");
13333 retval = h.
value ();
13337 bool int_fig_handle =
true;
13347 for (
int i = 0; i < xargs.
length (); i++)
13349 if (xargs(i).is_string ()
13350 && pname.
compare (xargs(i).string_value ()))
13352 if (i < (xargs.
length () - 1))
13354 std::string pval = xargs(i+1).string_value ();
13357 int_fig_handle = on.
compare (pval);
13358 xargs = xargs.
splice (i, 2);
13365 h = gh_mgr.make_graphics_handle (
"figure", 0, int_fig_handle,
13368 if (! int_fig_handle)
13373 graphics_object go = gh_mgr.get_object (h);
13374 go.get_properties ().init_integerhandle (
"off");
13378 h = gh_mgr.make_figure_handle (val,
false);
13381 error (
"__go_figure__: failed to create figure handle");
13387 catch (octave::execution_exception& ee)
13390 error (ee,
"__go_figure__: unable to create figure handle");
13395 gh_mgr.push_figure (h);
13400 retval = h.
value ();
13406#define GO_BODY(TYPE) \
13407 gh_manager& gh_mgr = interp.get_gh_manager (); \
13409 octave::autolock guard (gh_mgr.graphics_lock ()); \
13411 if (args.length () == 0) \
13414 return octave_value (make_graphics_object (#TYPE, false, args)); \
13421 if (go.isa (
"surface"))
13423 else if ((go.isa (
"line") || go.isa (
"patch") || go.isa (
"scatter"))
13424 && ! go.get (
"zdata").isempty ())
13428 Matrix kids = go.get_properties ().get_children ();
13438 const graphics_object& kid = gh_mgr.get_object (hkid);
13440 if (kid.valid_object ())
13452DEFMETHOD (__calc_dimensions__, interp, args, ,
13460 gh_manager& gh_mgr = interp.get_gh_manager ();
13464 if (args.
length () != 1)
13467 double h = args(0).xdouble_value (
"__calc_dimensions__: first argument must be a graphics handle");
13499DEFMETHOD (__go_image__, interp, args, ,
13508DEFMETHOD (__go_surface__, interp, args, ,
13517DEFMETHOD (__go_patch__, interp, args, ,
13526DEFMETHOD (__go_scatter__, interp, args, ,
13535DEFMETHOD (__go_light__, interp, args, ,
13544DEFMETHOD (__go_hggroup__, interp, args, ,
13553DEFMETHOD (__go_uimenu__, interp, args, ,
13562DEFMETHOD (__go_uicontrol__, interp, args, ,
13571DEFMETHOD (__go_uibuttongroup__, interp, args, ,
13580DEFMETHOD (__go_uipanel__, interp, args, ,
13589DEFMETHOD (__go_uicontextmenu__, interp, args, ,
13598DEFMETHOD (__go_uitable__, interp, args, ,
13607DEFMETHOD (__go_uitoolbar__, interp, args, ,
13616DEFMETHOD (__go_uipushtool__, interp, args, ,
13625DEFMETHOD (__go_uitoggletool__, interp, args, ,
13634DEFMETHOD (__go_delete__, interp, args, ,
13640 gh_manager& gh_mgr = interp.get_gh_manager ();
13644 if (args.
length () != 1)
13649 const NDArray vals = args(0).xarray_value (
"delete: invalid graphics object");
13655 h = gh_mgr.lookup (vals(i));
13658 error (
"delete: invalid graphics object (= %g)", vals(i));
13666DEFMETHOD (__go_handles__, interp, args, ,
13672 gh_manager& gh_mgr = interp.get_gh_manager ();
13676 bool show_hidden =
false;
13679 show_hidden = args(0).bool_value ();
13681 return ovl (gh_mgr.handle_list (show_hidden));
13684DEFMETHOD (__go_figure_handles__, interp, args, ,
13690 gh_manager& gh_mgr = interp.get_gh_manager ();
13694 bool show_hidden =
false;
13697 show_hidden = args(0).bool_value ();
13699 return ovl (gh_mgr.figure_handle_list (show_hidden));
13702DEFMETHOD (__go_execute_callback__, interp, args, ,
13709 int nargin = args.
length ();
13711 if (nargin < 2 || nargin > 3)
13714 const NDArray vals = args(0).xarray_value (
"__go_execute_callback__: invalid graphics object");
13716 std::string
name = args(1).xstring_value (
"__go_execute_callback__: invalid callback name");
13718 gh_manager& gh_mgr = interp.get_gh_manager ();
13722 double val = vals(i);
13727 error (
"__go_execute_callback__: invalid graphics object (= %g)", val);
13730 gh_mgr.execute_callback (h,
name);
13732 gh_mgr.execute_callback (h,
name, args(2));
13738DEFMETHOD (__go_post_callback__, interp, args, ,
13745 int nargin = args.
length ();
13747 if (nargin < 2 || nargin > 3)
13750 const NDArray vals = args(0).xarray_value (
"__go_post_callback__: invalid graphics object");
13752 std::string
name = args(1).xstring_value (
"__go_post_callback__: invalid callback name");
13754 gh_manager& gh_mgr = interp.get_gh_manager ();
13758 double val = vals(i);
13763 error (
"__go_execute_callback__: invalid graphics object (= %g)", val);
13766 gh_mgr.post_callback (h,
name);
13768 gh_mgr.post_callback (h,
name, args(2));
13774DEFMETHOD (__image_pixel_size__, interp, args, ,
13780 if (args.
length () != 1)
13783 gh_manager& gh_mgr = interp.get_gh_manager ();
13785 double h = args(0).xdouble_value (
"__image_pixel_size__: argument is not a handle");
13787 graphics_object go = gh_mgr.get_object (h);
13789 if (! go || ! go.isa (
"image"))
13790 error (
"__image_pixel_size__: object is not an image");
13796 dp(0) = ip.pixel_xsize ();
13797 dp(1) = ip.pixel_ysize ();
13801DEFMETHOD (available_graphics_toolkits, interp, , ,
13808 gh_manager& gh_mgr = interp.get_gh_manager ();
13817DEFMETHOD (register_graphics_toolkit, interp, args, ,
13824 gh_manager& gh_mgr = interp.get_gh_manager ();
13828 if (args.
length () != 1)
13831 std::string
name = args(0).xstring_value (
"register_graphics_toolkit: TOOLKIT must be a string");
13840DEFMETHOD (loaded_graphics_toolkits, interp, , ,
13847 gh_manager& gh_mgr = interp.get_gh_manager ();
13856DEFMETHOD (__show_figure__, interp, args, ,
13862 if (args.
length () != 1)
13865 gh_manager& gh_mgr = interp.get_gh_manager ();
13867 double h = args(0).xdouble_value (
"__show_figure__: invalid handle H");
13872 error (
"__show_figure__: invalid graphics object (= %g)", h);
13874 graphics_object go = gh_mgr.get_object (gh);
13879 fprops.get_toolkit ().show_figure (go);
13910 gh_manager& gh_mgr = interp.get_gh_manager ();
13914 if (args.
length () <= 1)
13918 bool do_events =
true;
13920 if (args.
length () == 1)
13922 caseless_str val (args(0).xstring_value (
"drawnow: first argument must be a string"));
13927 error (
"drawnow: invalid argument, 'expose' is only valid option");
13934 gh_mgr.process_events ();
13939 Matrix hlist = gh_mgr.figure_handle_list (
true);
13942 for (
int i = 0; i < hlist.
numel (); i++)
13946 if (h.
ok () && h != 0)
13948 graphics_object go = gh_mgr.get_object (h);
13952 if (fprops.is_modified ())
13954 if (fprops.is_visible ())
13958 fprops.get_toolkit ().redraw_figure (go);
13963 fprops.set_modified (
false);
13971 std::string term, file, debug_file;
13973 term = args(0).xstring_value (
"drawnow: TERM must be a string");
13975 file = args(1).xstring_value (
"drawnow: FILE must be a string");
13978 error (
"drawnow: empty output ''");
13979 else if (file.length () == 1 && file[0] ==
'|')
13980 error (
"drawnow: empty pipe '|'");
13981 else if (file[0] !=
'|')
13985 if (pos != std::string::npos)
13987 std::string
dirname = file.substr (0, pos+1);
13991 if (! fs || ! fs.
is_dir ())
13992 error (
"drawnow: nonexistent directory '%s'",
13998 debug_file = (args.
length () > 2 ? args(2).xstring_value (
"drawnow: DEBUG_FILE must be a string") :
"");
14003 error (
"drawnow: nothing to draw");
14005 graphics_object go = gh_mgr.get_object (h);
14009 go.get_toolkit ().print_figure (go, term, file, debug_file);
14053 gh_manager& gh_mgr = interp.get_gh_manager ();
14057 int nargin = args.
length ();
14059 if (nargin < 3 || nargin > 4)
14062 double h = args(0).xdouble_value (
"addlistener: invalid handle H");
14064 std::string pname = args(1).xstring_value (
"addlistener: PROP must be a string");
14069 error (
"addlistener: invalid graphics object (= %g)", h);
14071 graphics_object go = gh_mgr.get_object (gh);
14073 go.add_property_listener (pname, args(2), GCB_POSTSET);
14075 if (args.
length () == 4)
14078 if (persistent.
compare (
"persistent"))
14079 go.add_property_listener (pname, args(2), GCB_PERSISTENT);
14114 gh_manager& gh_mgr = interp.get_gh_manager ();
14121 double h = args(0).xdouble_value (
"dellistener: invalid handle");
14123 std::string pname = args(1).xstring_value (
"dellistener: PROP must be a string");
14128 error (
"dellistener: invalid graphics object (= %g)", h);
14130 graphics_object go = gh_mgr.get_object (gh);
14132 if (args.
length () == 2)
14133 go.delete_property_listener (pname,
octave_value (), GCB_POSTSET);
14136 if (args(2).is_string ()
14137 && args(2).string_value () ==
"persistent")
14145 go.delete_property_listener (pname, args(2), GCB_POSTSET);
14223 gh_manager& gh_mgr = interp.get_gh_manager ();
14230 std::string
name = args(0).xstring_value (
"addproperty: NAME must be a string");
14232 double h = args(1).xdouble_value (
"addproperty: invalid handle H");
14237 error (
"addproperty: invalid graphics object (= %g)", h);
14239 graphics_object go = gh_mgr.get_object (gh);
14241 std::string type = args(2).xstring_value (
"addproperty: TYPE must be a string");
14243 if (go.get_properties ().has_property (
name))
14244 error (
"addproperty: a '%s' property already exists in the graphics object",
14247 property p = property::create (
name, gh, type, args.
splice (0, 3));
14249 go.get_properties ().insert_property (
name, p);
14256 const std::string& func)
14262 graphics_object go = gh_mgr.get_object (handle);
14265 error (
"%s: invalid handle (= %g)", func.c_str (), handle);
14278 graphics_object go = gh_mgr.get_object (handle);
14281 error (
"%s: invalid handle (= %g)", func.c_str (), handle);
14298 if (result.
length () > 0)
14299 return result(0).bool_value ();
14314 listener_mode mode = GCB_POSTSET)
14318 if (c.
numel () >= 4)
14320 double h = c(2).double_value ();
14333 graphics_object go = gh_mgr.get_object (gh);
14335 if (go.get_properties ().has_property (pname))
14337 go.get_properties ().delete_listener (pname, listener, mode);
14339 if (mode == GCB_POSTSET)
14340 go.get_properties ().delete_listener (pname, listener,
14359 uint32_t
id = args(2).uint32_scalar_value ().value ();
14363 double h = args(0).double_value ();
14375 graphics_object go = gh_mgr.get_object (gh);
14393 uint32_t
id = args(2).uint32_scalar_value ().value ();
14444 if (args.
length () == 0)
14448 if (args(0).isempty ())
14451 double h = args(0).xdouble_value (
"waitfor: invalid handle value");
14462 static uint32_t id_counter = 0;
14465 int max_arg_index = 0;
14466 int timeout_index = -1;
14468 double timeout = 0;
14470 gh_manager& gh_mgr = interp.get_gh_manager ();
14474 pname = args(1).xstring_value (
"waitfor: PROP must be a string");
14476 if (pname.empty ())
14477 error (
"waitfor: PROP must be a non-empty string");
14479 if (pname !=
"timeout")
14481 if (pname.
compare (R
"(\timeout)"))
14489 "waitfor_listener"));
14494 if (args(2).is_string ())
14507 Cell listener (1, max_arg_index >= 2 ? 5 : 4);
14513 listener(0) = wf_listener;
14516 listener(3) = pname;
14518 if (max_arg_index >= 2)
14519 listener(4) = args(2);
14529 graphics_object go = gh_mgr.get_object (gh);
14531 if (max_arg_index >= 2
14536 cleanup_waitfor_postset_listener_action.
set
14539 go.add_property_listener (pname, ov_listener, GCB_POSTSET);
14540 go.add_property_listener (pname, ov_listener, GCB_PERSISTENT);
14542 if (go.get_properties ().has_dynamic_property (pname))
14550 "waitfor_del_listener"));
14552 Cell del_listener (1, 4);
14554 del_listener(0) = wf_del_listener;
14556 del_listener(2) = h;
14557 del_listener(3) = pname;
14561 cleanup_waitfor_predelete_listener_action.
set
14564 go.add_property_listener (pname, ov_del_listener,
14572 if (timeout_index < 0 && args.
length () > (max_arg_index + 1))
14574 caseless_str s = args(max_arg_index + 1).xstring_value (
"waitfor: invalid parameter, expected 'timeout'");
14577 error (
"waitfor: invalid parameter '%s'", s.c_str ());
14579 timeout_index = max_arg_index + 1;
14582 if (timeout_index >= 0)
14584 if (args.
length () <= (timeout_index + 1))
14585 error (
"waitfor: missing TIMEOUT value");
14587 timeout = args(timeout_index + 1).xscalar_value (
"waitfor: TIMEOUT must be a scalar >= 1");
14591 warning (
"waitfor: TIMEOUT value must be >= 1, using 1 instead");
14643 if (start + timeout < now)
14659 int nargin = args.
length ();
14661 if (nargin != 2 && nargin != 3)
14664 double h = args(0).double_value ();
14666 gh_manager& gh_mgr = interp.get_gh_manager ();
14672 if (! handle.
ok ())
14673 error (
"__zoom__: invalid handle");
14675 graphics_object ax = gh_mgr.get_object (handle);
14682 std::string opt = args(1).string_value ();
14684 if (opt ==
"out" || opt ==
"reset")
14688 ax_props.clear_zoom_stack ();
14692 ax_props.clear_zoom_stack (
false);
14697 std::string mode = args(1).string_value ();
14698 double factor = args(2).scalar_value ();
14700 ax_props.zoom (mode, factor);
14707DEFMETHOD (__get_frame__, interp, args, ,
14716 if (args.
length () != 1)
14719 double h = args(0).xdouble_value (
"__get_frame__: HFIG is not a handle");
14721 gh_manager& gh_mgr = interp.get_gh_manager ();
14723 graphics_object go = gh_mgr.get_object (h);
14725 if (! go || ! go.isa (
"figure"))
14726 error (
"__get_frame__: HFIG is not a figure");
14729 gh_mgr.process_events ();
14731 return ovl (go.get_toolkit ().get_pixels (go));
14734DEFMETHOD (__get_position__, interp, args, ,
14743 if (args.
length () != 2)
14747 = args(0).xdouble_value (
"__get_position__: H must be a graphics handle");
14750 = args(1).xstring_value (
"__get_position__: UNITS must be a string");
14752 gh_manager& gh_mgr = interp.get_gh_manager ();
14754 graphics_object go = gh_mgr.get_object (h);
14756 if (h == 0 || ! go)
14757 error (
"__get_position__: H must be a handle to a valid graphics object");
14759 graphics_object parent_go = gh_mgr.get_object (go.get_parent ());
14760 Matrix bbox = parent_go.get_properties ().get_boundingbox (
true)
14764 go.get (
"units").string_value (),
14770DEFUN (__get_system_fonts__, args, ,
14776 if (args.
length () != 0)
14784OCTAVE_NAMESPACE_END
octave_idx_type lookup(const T *x, octave_idx_type n, T y)
charNDArray max(char d, const charNDArray &m)
charNDArray min(char d, const charNDArray &m)
T & xelem(octave_idx_type n)
Size of the specified dimension.
octave_idx_type numel(void) const
Number of elements in the array.
const dim_vector & dims(void) const
Return a const-reference so that dims ()(i) works efficiently.
T & elem(octave_idx_type n)
Size of the specified dimension.
octave_idx_type rows(void) const
bool isempty(void) const
Size of the specified dimension.
OCTARRAY_API void resize(const dim_vector &dv, const T &rfv)
Size of the specified dimension.
octave_idx_type columns(void) const
const T * data(void) const
Size of the specified dimension.
OCTARRAY_API T * fortran_vec(void)
Size of the specified dimension.
Array< T, Alloc > as_column(void) const
Return the array as a column vector.
int ndims(void) const
Size of the specified dimension.
OCTARRAY_API octave_idx_type lookup(const T &value, sortmode mode=UNSORTED) const
Do a binary lookup in a sorted array.
OCTAVE_API double max(void) const
void resize(octave_idx_type n, const double &rfv=0)
OCTAVE_API RowVector transpose(void) const
OCTAVE_API double min(void) const
OCTAVE_API ColumnVector extract_n(octave_idx_type r1, octave_idx_type n) const
ComplexColumnVector eigenvalues(void) const
MArray< T > reshape(const dim_vector &new_dims) const
OCTAVE_API ColumnVector row_max(void) const
OCTAVE_API RowVector row(octave_idx_type i) const
OCTAVE_API Matrix extract_n(octave_idx_type r1, octave_idx_type c1, octave_idx_type nr, octave_idx_type nc) const
OCTAVE_API ColumnVector row_min(void) const
Matrix transpose(void) const
void resize(octave_idx_type nr, octave_idx_type nc, double rfv=0)
OCTAVE_API bool any_element_is_inf_or_nan(void) const
callback_event(const graphics_handle &h, const std::string &name, const octave_value &data=Matrix(), int busyaction=base_graphics_event::QUEUE)
std::string m_callback_name
callback_event(const graphics_handle &h, const octave_value &cb, const octave_value &data=Matrix(), int busyaction=base_graphics_event::QUEUE)
octave_value m_callback_data
~callback_props(void)=default
callback_props(const callback_props &)=delete
callback_props & operator=(const callback_props &)=delete
void erase(const callback_property *ptr)
std::set< intptr_t > m_set
bool contains(const callback_property *ptr) const
void insert(const callback_property *ptr)
bool compare(const std::string &s, std::size_t limit=std::string::npos) const
Vector representing the dimensions (size) of an Array.
void resize(int n, int fill_value=0)
static dim_vector alloc(int n)
octave_idx_type ndims(void) const
Number of dimensions.
graphics_event::event_fcn m_function
function_event(graphics_event::event_fcn fcn, void *data=nullptr)
function_event(void)=delete
function_event(const function_event &)=delete
mcode_event(const graphics_handle &h, const std::string &cmd, int busyaction=base_graphics_event::QUEUE)
static void remove_event_hook(event_hook_fcn f)
static void run_event_hooks(void)
static void add_event_hook(event_hook_fcn f)
graphics_toolkit find_toolkit(const std::string &name) const
void register_toolkit(const std::string &name)
Cell loaded_toolkits_list(void) const
Cell available_toolkits_list(void) const
graphics_toolkit get_toolkit(void) const
std::string default_toolkit(void) const
OCTAVE_API void stamp(void)
octave_map get_system_fonts(void)
static bool is_thread(void)
void set(F &&fcn, Args &&... args)
octave_value as_octave_value(void) const
Cell getfield(const std::string &key) const
octave_idx_type nfields(void) const
const Cell & contents(const_iterator p) const
bool isfield(const std::string &name) const
octave_idx_type numel(void) const
string_vector keys(void) 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_idx_type length(void) const
octave_value_list splice(octave_idx_type offset, octave_idx_type len, const octave_value_list &lst=octave_value_list()) const
bool is_function(void) const
bool iscellstr(void) const
OCTINTERP_API octave_function * function_value(bool silent=false) const
bool is_uint16_type(void) const
bool is_bool_scalar(void) const
bool is_int8_type(void) const
octave_idx_type rows(void) const
bool isnumeric(void) const
octave_idx_type numel(void) const
bool is_scalar_type(void) const
bool is_string(void) const
bool is_defined(void) const
bool is_double_type(void) const
Cell cell_value(void) const
bool is_function_handle(void) const
std::string class_name(void) const
bool is_uint32_type(void) const
octave_idx_type columns(void) const
bool is_int64_type(void) const
octave_value reshape(const dim_vector &dv) const
std::string string_value(bool force=false) const
bool is_matrix_type(void) const
bool is_int32_type(void) const
bool is_uint64_type(void) const
bool is_int16_type(void) const
string_vector string_vector_value(bool pad=false) const
NDArray array_value(bool frc_str_conv=false) const
bool is_single_type(void) const
bool is_real_scalar(void) const
bool is_undefined(void) const
OCTINTERP_API octave_idx_type length(void) const
bool is_uint8_type(void) const
Matrix matrix_value(bool frc_str_conv=false) const
bool iscomplex(void) const
double double_value(bool frc_str_conv=false) const
std::string type_name(void) const
bool islogical(void) const
dim_vector dims(void) const
OCTINTERP_API double xdouble_value(const char *fmt,...) const
std::string m_property_name
set_event(const graphics_handle &h, const std::string &name, const octave_value &value, bool do_notify_toolkit=true, bool redraw_figure=false)
octave_value m_property_value
string_vector & append(const std::string &s)
std::ostream & list_in_columns(std::ostream &, int width=0, const std::string &prefix="") const
std::string join(const std::string &sep="") const
octave_idx_type numel(void) const
static octave_idx_type find(octave_idx_type i, octave_idx_type *pp)
ColumnVector real(const ComplexColumnVector &a)
#define DECLARE_STATIC_FUNX(name, args_name, nargout_name)
OCTINTERP_API void print_usage(void)
#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 interpreter_try(unwind_protect &frame)
void warning(const char *fmt,...)
void warning_with_id(const char *id, const char *fmt,...)
void error(const char *fmt,...)
octave_value_list set_warning_state(const std::string &id, const std::string &state)
void disable_warning(const std::string &id)
int warning_enabled(const std::string &id)
octave_handle graphics_handle
static double default_screendepth(void)
static Matrix default_patch_vertices(void)
static void xset(const graphics_handle &h, const caseless_str &pname, const octave_value &val)
static graphics_handle reparent(const octave_value &ov, const std::string &who, const std::string &pname, const graphics_handle &new_parent, bool adopt=true)
static Matrix default_surface_ydata(void)
static Matrix default_light_position(void)
static bool compare_property_values(const octave_value &ov1, const octave_value &ov2)
static Matrix default_patch_ydata(void)
static double make_handle_fraction(void)
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)
static bool updating_zlabel_position
static Matrix default_image_cdata(void)
static base_graphics_object * make_graphics_object_from_type(const caseless_str &type, const graphics_handle &h=graphics_handle(), const graphics_handle &p=graphics_handle())
void translate(Matrix &m, double x, double y, double z)
static std::set< double > updating_aspectratios
OCTAVE_EXPORT octave_value_list Fdrawnow(octave::interpreter &interp, const octave_value_list &args, int)
static caseless_str validate_property_name(const std::string &who, const std::string &what, const std::set< std::string > &pnames, const caseless_str &pname)
static Matrix default_data(void)
#define CONVERT_CDATA_1(ARRAY_T, VAL_FN, IS_REAL)
static graphics_handle make_graphics_handle(const std::string &go_name, const graphics_handle &parent, bool integer_figure_handle=false, bool call_createfcn=true, bool notify_toolkit=true)
static bool updating_hggroup_limits
ColumnVector cross(const ColumnVector &v1, const ColumnVector &v2)
static void delete_graphics_objects(const NDArray vals, bool from_root=false)
std::vector< octave_idx_type > coplanar_partition(const Matrix &vert, const Matrix &idx, octave_idx_type nc, octave_idx_type jj)
static void finalize_r(const graphics_handle &h)
static Matrix default_figure_paperposition(void)
static Matrix default_figure_papersize(void)
graphics_handle gca(void)
static Matrix default_table_backgroundcolor(void)
static octave_value convert_ticklabel_string(const octave_value &val)
void get_children_limits(double &min_val, double &max_val, double &min_pos, double &max_neg, const Matrix &kids, char limit_type)
static Matrix screen_size_pixels(void)
double norm(const ColumnVector &v)
static void xreset_default_properties(graphics_handle h, property_list::pval_map_type factory_pval)
static bool updating_patch_data
void xform(ColumnVector &v, const Matrix &m)
static Matrix default_axes_position(void)
static Matrix default_screensize(void)
void normalize(ColumnVector &v)
static Matrix default_axes_view(void)
static Matrix default_surface_xdata(void)
static void close_figure(const graphics_handle &h)
Matrix xform_scale(double x, double y, double z)
static void normalized_aspectratios(Matrix &aspectratios, const Matrix &scalefactors, double xlength, double ylength, double zlength)
static std::map< caseless_str, graphics_object > dprop_obj_map
static Matrix default_control_position(void)
static Matrix do_translate(double x0, double x1, const Matrix &lims, bool is_logscale)
static Matrix default_axes_tick(void)
static bool updating_scatter_cdata
static void update_text_pos(graphics_handle h)
static callback_props executing_callbacks
static double device_pixel_ratio(graphics_handle h)
static Matrix default_control_sliderstep(void)
ColumnVector cam2xform(const Array< double > &m)
static void delete_graphics_object(const graphics_handle &h, bool from_root=false)
static OCTAVE_NORETURN void err_set_invalid(const std::string &pname)
int calc_dimensions(const graphics_object &go)
static bool updating_ylabel_position
static bool ishghandle(const graphics_handle &h)
RowVector xform2cam(const ColumnVector &v)
static bool delete_executing
static void magform(double x, double &a, int &b)
static Matrix papersize_from_type(const caseless_str punits, const caseless_str ptype)
static std::map< uint32_t, bool > waitfor_results
static bool updating_axes_layout
static Matrix default_patch_xdata(void)
static void check_limit_vals(double &min_val, double &max_val, double &min_pos, double &max_neg, const octave_value &data)
static bool lookup_object_name(const caseless_str &name, caseless_str &go_name, caseless_str &rest)
static Matrix default_lim(bool logscale=false)
static void force_close_figure(const graphics_handle &h)
static Matrix default_table_position(void)
static int process_graphics_events(void)
static double convert_font_size(double font_size, const caseless_str &from_units, const caseless_str &to_units, double parent_height=0)
static Matrix viridis_colormap(void)
static void get_array_limits(const Array< T > &m, double &emin, double &emax, double &eminp, double &emaxp)
static void cleanup_waitfor_predelete_listener(const octave_value &listener)
static octave_value_list waitfor_listener(const octave_value_list &args, int)
static std::set< double > updating_axis_limits
bool set_property_in_handle(double handle, const std::string &property, const octave_value &arg, const std::string &func)
static void xset_gcbo(const graphics_handle &h)
static ColumnVector convert_label_position(const ColumnVector &p, const text::properties &props, const graphics_xform &xform, const Matrix &bbox)
void scale(Matrix &m, double x, double y, double z)
static octave_value convert_linestyleorder_string(const octave_value &val)
Matrix xform_translate(double x, double y, double z)
static std::string default_graphics_toolkit(void)
static void initialize_r(const graphics_handle &h)
static void cleanup_waitfor_id(uint32_t id)
static std::string get_graphics_object_type(double val)
octave_value get_property_from_handle(double handle, const std::string &property, const std::string &func)
Matrix xform_matrix(void)
static double default_screenpixelsperinch(void)
static bool updating_xlabel_position
ColumnVector xform_vector(void)
static Matrix default_surface_cdata(void)
ColumnVector transform(const Matrix &m, double x, double y, double z)
graphics_handle gcf(void)
static void do_cleanup_waitfor_listener(const octave_value &listener, listener_mode mode=GCB_POSTSET)
static void xinitialize(const graphics_handle &h)
static OCTAVE_NAMESPACE_BEGIN octave_value xget(const graphics_handle &h, const caseless_str &name)
static void convert_cdata_2(bool is_scaled, bool is_real, double clim_0, double clim_1, const double *cmapv, double x, octave_idx_type lda, octave_idx_type nc, octave_idx_type i, double *av)
static Matrix default_data_lim(void)
#define CHECK_ARRAY_EQUAL(T, F, A)
static Matrix default_panel_position(void)
static octave_value_list waitfor_del_listener(const octave_value_list &args, int)
bool is_coplanar(const Matrix &cov)
static Matrix do_zoom(double val, double factor, const Matrix &lims, bool is_logscale)
static bool updating_title_position
static bool is_handle_visible(const graphics_handle &h)
static Matrix default_colororder(void)
static octave_value convert_cdata(const base_properties &props, const octave_value &cdata, bool is_scaled, int cdim)
static void adopt(const graphics_handle &parent_h, const graphics_handle &h)
static Matrix default_axes_ticklength(void)
double force_in_range(double x, double lower, double upper)
static Matrix default_surface_zdata(void)
static void max_axes_scale(double &s, Matrix &limits, const Matrix &kids, double pbfactor, double dafactor, char limit_type, bool tight)
static void xcreatefcn(const graphics_handle &h)
static Matrix default_axes_outerposition(void)
static Matrix convert_position(const Matrix &pos, const caseless_str &from_units, const caseless_str &to_units, const Matrix &parent_dim)
static Matrix default_patch_faces(void)
static octave_value make_graphics_object(const std::string &go_name, bool integer_figure_handle, const octave_value_list &args)
static Matrix convert_text_position(const Matrix &pos, const text::properties &props, const caseless_str &from_units, const caseless_str &to_units)
static int toggle_warn(std::string id, bool on, int state=-1)
static bool isfigure(double val)
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)
static Matrix default_figure_position(void)
static void cleanup_waitfor_postset_listener(const octave_value &listener)
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
void F(const TSRC *v, TRES *r, octave_idx_type m, octave_idx_type n)
T::properties & properties(graphics_object obj)
Complex atan(const Complex &x)
std::complex< T > ceil(const std::complex< T > &x)
std::complex< T > floor(const std::complex< T > &x)
std::string dirname(const std::string &path)
std::string dir_sep_chars(void)
static uint32_t state[624]
OCTINTERP_API octave_value_list feval(const char *name, const octave_value_list &args=octave_value_list(), int nargout=0)
interpreter & __get_interpreter__(const std::string &who)
gh_manager & __get_gh_manager__(const std::string &who)
display_info & __get_display_info__(const std::string &who)
gtk_manager & __get_gtk_manager__(const std::string &who)
octave_int< uint32_t > octave_uint32
octave_int< T > pow(const octave_int< T > &a, const octave_int< T > &b)
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)
static void initialize(void)
static char default_im_data[]
return octave_value(v1.char_array_value() . concat(v2.char_array_value(), ra_idx),((a1.is_sq_string()||a2.is_sq_string()) ? '\'' :'"'))
const octave_char_matrix & v2
octave_value_list ovl(const OV_Args &... args)
Construct an octave_value_list with less typing.
void sleep(double seconds, bool do_graphics_events)