comparison libinterp/corefcn/graphics.cc @ 20597:bc6daa38ff50

eliminate more simple uses of error_state * graphics.cc: Eliminate simple uses of error_state.
author John W. Eaton <jwe@octave.org>
date Tue, 06 Oct 2015 14:47:41 -0400
parents dcfbf4c1c3c8
children ba2b07c13913
comparison
equal deleted inserted replaced
20596:87b557ee8e5d 20597:bc6daa38ff50
860 860
861 if (fig.valid_object ()) 861 if (fig.valid_object ())
862 { 862 {
863 Matrix _cmap = fig.get (caseless_str ("colormap")).matrix_value (); 863 Matrix _cmap = fig.get (caseless_str ("colormap")).matrix_value ();
864 864
865 if (! error_state) 865 cmap = _cmap;
866 cmap = _cmap;
867 } 866 }
868 867
869 if (is_scaled) 868 if (is_scaled)
870 { 869 {
871 graphics_object ax = go.get_ancestor ("axes"); 870 graphics_object ax = go.get_ancestor ("axes");
872 871
873 if (ax.valid_object ()) 872 if (ax.valid_object ())
874 { 873 {
875 Matrix _clim = ax.get (caseless_str ("clim")).matrix_value (); 874 Matrix _clim = ax.get (caseless_str ("clim")).matrix_value ();
876 875
877 if (! error_state) 876 clim = _clim;
878 clim = _clim;
879 } 877 }
880 } 878 }
881 879
882 dv.resize (cdim); 880 dv.resize (cdim);
883 dv(cdim-1) = 3; 881 dv(cdim-1) = 3;
1091 if (go) 1089 if (go)
1092 go.update (id); 1090 go.update (id);
1093 } 1091 }
1094 1092
1095 // run listeners 1093 // run listeners
1096 if (do_run && ! error_state) 1094 if (do_run)
1097 run_listeners (POSTSET); 1095 run_listeners (POSTSET);
1098 1096
1099 return true; 1097 return true;
1100 } 1098 }
1101 1099
1107 base_property::run_listeners (listener_mode mode) 1105 base_property::run_listeners (listener_mode mode)
1108 { 1106 {
1109 const octave_value_list& l = listeners[mode]; 1107 const octave_value_list& l = listeners[mode];
1110 1108
1111 for (int i = 0; i < l.length (); i++) 1109 for (int i = 0; i < l.length (); i++)
1112 { 1110 gh_manager::execute_listener (parent, l(i));
1113 gh_manager::execute_listener (parent, l(i));
1114
1115 if (error_state)
1116 break;
1117 }
1118 } 1111 }
1119 1112
1120 radio_values::radio_values (const std::string& opt_string) 1113 radio_values::radio_values (const std::string& opt_string)
1121 : default_val (), possible_vals () 1114 : default_val (), possible_vals ()
1122 { 1115 {
1259 } 1252 }
1260 } 1253 }
1261 else 1254 else
1262 { 1255 {
1263 color_values col (s); 1256 color_values col (s);
1257
1264 if (! error_state) 1258 if (! error_state)
1265 { 1259 {
1266 if (current_type != color_t || col != color_val) 1260 if (current_type != color_t || col != color_val)
1267 { 1261 {
1268 color_val = col; 1262 color_val = col;
1284 Matrix m = val.matrix_value (); 1278 Matrix m = val.matrix_value ();
1285 1279
1286 if (m.numel () == 3) 1280 if (m.numel () == 3)
1287 { 1281 {
1288 color_values col (m(0), m(1), m(2)); 1282 color_values col (m(0), m(1), m(2));
1289 if (! error_state) 1283
1284 if (current_type != color_t || col != color_val)
1290 { 1285 {
1291 if (current_type != color_t || col != color_val) 1286 color_val = col;
1292 { 1287 current_type = color_t;
1293 color_val = col; 1288 return true;
1294 current_type = color_t;
1295 return true;
1296 }
1297 } 1289 }
1298 } 1290 }
1299 else 1291 else
1300 error ("invalid value for color property \"%s\"", 1292 error ("invalid value for color property \"%s\"",
1301 get_name ().c_str ()); 1293 get_name ().c_str ());
1664 1656
1665 if (type.compare ("string")) 1657 if (type.compare ("string"))
1666 { 1658 {
1667 std::string sv = (args.length () > 0 ? args(0).string_value () : ""); 1659 std::string sv = (args.length () > 0 ? args(0).string_value () : "");
1668 1660
1669 if (! error_state) 1661 retval = property (new string_property (name, h, sv));
1670 retval = property (new string_property (name, h, sv));
1671 } 1662 }
1672 else if (type.compare ("any")) 1663 else if (type.compare ("any"))
1673 { 1664 {
1674 octave_value ov = args.length () > 0 ? args(0) 1665 octave_value ov = args.length () > 0 ? args(0)
1675 : octave_value (Matrix ()); 1666 : octave_value (Matrix ());
1697 } 1688 }
1698 else if (type.compare ("double")) 1689 else if (type.compare ("double"))
1699 { 1690 {
1700 double dv = (args.length () > 0 ? args(0).double_value () : 0.0); 1691 double dv = (args.length () > 0 ? args(0).double_value () : 0.0);
1701 1692
1702 if (! error_state) 1693 retval = property (new double_property (name, h, dv));
1703 retval = property (new double_property (name, h, dv));
1704 } 1694 }
1705 else if (type.compare ("handle")) 1695 else if (type.compare ("handle"))
1706 { 1696 {
1707 double hv = (args.length () > 0 ? args(0).double_value () : octave_NaN); 1697 double hv = (args.length () > 0 ? args(0).double_value () : octave_NaN);
1708 1698
1709 if (! error_state) 1699 graphics_handle gh (hv);
1710 { 1700
1711 graphics_handle gh (hv); 1701 retval = property (new handle_property (name, h, gh));
1712
1713 retval = property (new handle_property (name, h, gh));
1714 }
1715 } 1702 }
1716 else if (type.compare ("boolean")) 1703 else if (type.compare ("boolean"))
1717 { 1704 {
1718 retval = property (new bool_property (name, h, false)); 1705 retval = property (new bool_property (name, h, false));
1719 1706
1737 radio_values rv; 1724 radio_values rv;
1738 1725
1739 if (args.length () > 1) 1726 if (args.length () > 1)
1740 rv = radio_values (args(1).string_value ()); 1727 rv = radio_values (args(1).string_value ());
1741 1728
1742 if (! error_state) 1729 retval = property (new color_property (name, h, cv, rv));
1743 { 1730
1744 retval = property (new color_property (name, h, cv, rv)); 1731 if (args.length () > 0 && ! args(0).is_empty ())
1745 1732 retval.set (args(0));
1746 if (! error_state) 1733 else
1747 { 1734 retval.set (rv.default_value ());
1748 if (args.length () > 0 && ! args(0).is_empty ())
1749 retval.set (args(0));
1750 else
1751 retval.set (rv.default_value ());
1752 }
1753 }
1754 } 1735 }
1755 else 1736 else
1756 { 1737 {
1757 caseless_str go_name, go_rest; 1738 caseless_str go_name, go_rest;
1758 1739
1780 1761
1781 if (go.valid_object ()) 1762 if (go.valid_object ())
1782 { 1763 {
1783 property prop = go.get_properties ().get_property (go_rest); 1764 property prop = go.get_properties ().get_property (go_rest);
1784 1765
1785 if (! error_state) 1766 retval = prop.clone ();
1786 { 1767
1787 retval = prop.clone (); 1768 retval.set_parent (h);
1788 1769 retval.set_name (name);
1789 retval.set_parent (h); 1770
1790 retval.set_name (name); 1771 if (args.length () > 0)
1791 1772 retval.set (args(0));
1792 if (args.length () > 0)
1793 retval.set (args(0));
1794 }
1795 } 1773 }
1796 else 1774 else
1797 error ("addproperty: invalid object type (= %s)", 1775 error ("addproperty: invalid object type (= %s)",
1798 go_name.c_str ()); 1776 go_name.c_str ());
1799 } 1777 }
1854 } 1832 }
1855 1833
1856 void 1834 void
1857 figure::properties::set___mouse_mode__ (const octave_value& val_arg) 1835 figure::properties::set___mouse_mode__ (const octave_value& val_arg)
1858 { 1836 {
1859 if (! error_state) 1837 std::string direction = "in";
1860 { 1838
1861 std::string direction = "in"; 1839 octave_value val = val_arg;
1862 1840
1863 octave_value val = val_arg; 1841 if (val.is_string ())
1864 1842 {
1865 if (val.is_string ()) 1843 std::string modestr = val.string_value ();
1866 { 1844
1867 std::string modestr = val.string_value (); 1845 if (modestr == "zoom in")
1868 1846 {
1869 if (modestr == "zoom in") 1847 val = modestr = "zoom";
1848 direction = "in";
1849 }
1850 else if (modestr == "zoom out")
1851 {
1852 val = modestr = "zoom";
1853 direction = "out";
1854 }
1855
1856 if (__mouse_mode__.set (val, true))
1857 {
1858 std::string mode = __mouse_mode__.current_value ();
1859
1860 octave_scalar_map pm = get___pan_mode__ ().scalar_map_value ();
1861 pm.setfield ("Enable", mode == "pan" ? "on" : "off");
1862 set___pan_mode__ (pm);
1863
1864 octave_scalar_map rm = get___rotate_mode__ ().scalar_map_value ();
1865 rm.setfield ("Enable", mode == "rotate" ? "on" : "off");
1866 set___rotate_mode__ (rm);
1867
1868 octave_scalar_map zm = get___zoom_mode__ ().scalar_map_value ();
1869 zm.setfield ("Enable", mode == "zoom" ? "on" : "off");
1870 zm.setfield ("Direction", direction);
1871 set___zoom_mode__ (zm);
1872
1873 mark_modified ();
1874 }
1875 else if (modestr == "zoom")
1876 {
1877 octave_scalar_map zm = get___zoom_mode__ ().scalar_map_value ();
1878 std::string curr_direction
1879 = zm.getfield ("Direction").string_value ();
1880
1881 if (direction != curr_direction)
1870 { 1882 {
1871 val = modestr = "zoom";
1872 direction = "in";
1873 }
1874 else if (modestr == "zoom out")
1875 {
1876 val = modestr = "zoom";
1877 direction = "out";
1878 }
1879
1880 if (__mouse_mode__.set (val, true))
1881 {
1882 std::string mode = __mouse_mode__.current_value ();
1883
1884 octave_scalar_map pm = get___pan_mode__ ().scalar_map_value ();
1885 pm.setfield ("Enable", mode == "pan" ? "on" : "off");
1886 set___pan_mode__ (pm);
1887
1888 octave_scalar_map rm = get___rotate_mode__ ().scalar_map_value ();
1889 rm.setfield ("Enable", mode == "rotate" ? "on" : "off");
1890 set___rotate_mode__ (rm);
1891
1892 octave_scalar_map zm = get___zoom_mode__ ().scalar_map_value ();
1893 zm.setfield ("Enable", mode == "zoom" ? "on" : "off");
1894 zm.setfield ("Direction", direction); 1883 zm.setfield ("Direction", direction);
1895 set___zoom_mode__ (zm); 1884 set___zoom_mode__ (zm);
1896 1885
1897 mark_modified (); 1886 mark_modified ();
1898 }
1899 else if (modestr == "zoom")
1900 {
1901 octave_scalar_map zm = get___zoom_mode__ ().scalar_map_value ();
1902 std::string curr_direction
1903 = zm.getfield ("Direction").string_value ();
1904
1905 if (direction != curr_direction)
1906 {
1907 zm.setfield ("Direction", direction);
1908 set___zoom_mode__ (zm);
1909
1910 mark_modified ();
1911 }
1912 } 1887 }
1913 } 1888 }
1914 } 1889 }
1915 } 1890 }
1916 1891
2047 else 2022 else
2048 error ("invalid %s property '%s'", pfx.c_str (), pname.c_str ()); 2023 error ("invalid %s property '%s'", pfx.c_str (), pname.c_str ());
2049 } 2024 }
2050 } 2025 }
2051 2026
2052 if (! error_state && offset == 0) 2027 if (offset == 0)
2053 error ("invalid default property specification"); 2028 error ("invalid default property specification");
2054 } 2029 }
2055 2030
2056 octave_value 2031 octave_value
2057 property_list::lookup (const caseless_str& name) const 2032 property_list::lookup (const caseless_str& name) const
2186 if (! error_state) 2161 if (! error_state)
2187 { 2162 {
2188 octave_value val = args(i+1); 2163 octave_value val = args(i+1);
2189 2164
2190 set_value_or_default (pname, val); 2165 set_value_or_default (pname, val);
2191
2192 if (error_state)
2193 break;
2194 } 2166 }
2195 else 2167 else
2196 error ("set: expecting argument %d to be a property name", i); 2168 error ("set: expecting argument %d to be a property name", i);
2197 } 2169 }
2198 } 2170 }
2228 { 2200 {
2229 caseless_str pname = pnames(column); 2201 caseless_str pname = pnames(column);
2230 octave_value val = values(row, column); 2202 octave_value val = values(row, column);
2231 2203
2232 set_value_or_default (pname, val); 2204 set_value_or_default (pname, val);
2233
2234 if (error_state)
2235 break;
2236 } 2205 }
2237 } 2206 }
2238 2207
2239 /* 2208 /*
2240 ## test set with cell array arguments 2209 ## test set with cell array arguments
2293 caseless_str pname = m.keys ()[p]; 2262 caseless_str pname = m.keys ()[p];
2294 2263
2295 octave_value val = octave_value (m.contents (pname).elem (m.numel () - 1)); 2264 octave_value val = octave_value (m.contents (pname).elem (m.numel () - 1));
2296 2265
2297 set_value_or_default (pname, val); 2266 set_value_or_default (pname, val);
2298
2299 if (error_state)
2300 break;
2301 } 2267 }
2302 } 2268 }
2303 2269
2304 /* 2270 /*
2305 ## test set ticklabels for compatibility 2271 ## test set ticklabels for compatibility
2396 2362
2397 if (sval.compare ("default") == 0) 2363 if (sval.compare ("default") == 0)
2398 { 2364 {
2399 default_val = get_default (pname); 2365 default_val = get_default (pname);
2400 2366
2401 if (error_state)
2402 return;
2403
2404 rep->set (pname, default_val); 2367 rep->set (pname, default_val);
2405 } 2368 }
2406 else if (sval.compare ("factory") == 0) 2369 else if (sval.compare ("factory") == 0)
2407 { 2370 {
2408 default_val = get_factory_default (pname); 2371 default_val = get_factory_default (pname);
2409
2410 if (error_state)
2411 return;
2412 2372
2413 rep->set (pname, default_val); 2373 rep->set (pname, default_val);
2414 } 2374 }
2415 else 2375 else
2416 { 2376 {
2792 retval = true; 2752 retval = true;
2793 else if (val.is_numeric_type () && val.is_real_type ()) 2753 else if (val.is_numeric_type () && val.is_real_type ())
2794 { 2754 {
2795 const NDArray handles = val.array_value (); 2755 const NDArray handles = val.array_value ();
2796 2756
2797 if (! error_state) 2757 boolNDArray result (handles.dims ());
2798 { 2758
2799 boolNDArray result (handles.dims ()); 2759 for (octave_idx_type i = 0; i < handles.numel (); i++)
2800 2760 result.xelem (i) = is_handle (handles(i));
2801 for (octave_idx_type i = 0; i < handles.numel (); i++) 2761
2802 result.xelem (i) = is_handle (handles(i)); 2762 retval = result;
2803
2804 retval = result;
2805 }
2806 } 2763 }
2807 2764
2808 return retval; 2765 return retval;
2809 } 2766 }
2810 2767
3003 if (it != all_props.end ()) 2960 if (it != all_props.end ())
3004 it->second.set (val); 2961 it->second.set (val);
3005 else 2962 else
3006 error ("set: unknown property \"%s\"", pname.c_str ()); 2963 error ("set: unknown property \"%s\"", pname.c_str ());
3007 2964
3008 if (! error_state) 2965 dynamic_properties.insert (pname);
3009 { 2966
3010 dynamic_properties.insert (pname); 2967 mark_modified ();
3011
3012 mark_modified ();
3013 }
3014 } 2968 }
3015 2969
3016 property 2970 property
3017 base_properties::get_property_dynamic (const caseless_str& pname) 2971 base_properties::get_property_dynamic (const caseless_str& pname)
3018 { 2972 {
3187 const octave_value& val, 3141 const octave_value& val,
3188 listener_mode mode) 3142 listener_mode mode)
3189 { 3143 {
3190 property p = get_property (pname); 3144 property p = get_property (pname);
3191 3145
3192 if (! error_state && p.ok ()) 3146 if (p.ok ())
3193 p.add_listener (val, mode); 3147 p.add_listener (val, mode);
3194 } 3148 }
3195 3149
3196 void 3150 void
3197 base_properties::delete_listener (const caseless_str& pname, 3151 base_properties::delete_listener (const caseless_str& pname,
3198 const octave_value& val, 3152 const octave_value& val,
3199 listener_mode mode) 3153 listener_mode mode)
3200 { 3154 {
3201 property p = get_property (pname); 3155 property p = get_property (pname);
3202 3156
3203 if (! error_state && p.ok ()) 3157 if (p.ok ())
3204 p.delete_listener (val, mode); 3158 p.delete_listener (val, mode);
3205 } 3159 }
3206 3160
3207 // --------------------------------------------------------------------- 3161 // ---------------------------------------------------------------------
3208 3162
3246 // ask whether it is OK to delete the listener for the given 3200 // ask whether it is OK to delete the listener for the given
3247 // property. How can we know in advance that it will be OK? 3201 // property. How can we know in advance that it will be OK?
3248 3202
3249 unwind_protect frame; 3203 unwind_protect frame;
3250 3204
3251 frame.protect_var (error_state);
3252 frame.protect_var (discard_error_messages); 3205 frame.protect_var (discard_error_messages);
3253 frame.protect_var (Vdebug_on_error); 3206 frame.protect_var (Vdebug_on_error);
3254 frame.protect_var (Vdebug_on_warning); 3207 frame.protect_var (Vdebug_on_warning);
3255 3208
3256 discard_error_messages = true; 3209 discard_error_messages = true;
3257 Vdebug_on_error = false; 3210 Vdebug_on_error = false;
3258 Vdebug_on_warning = false; 3211 Vdebug_on_warning = false;
3259 3212
3260 property p = get_properties ().get_property (pa->first); 3213 property p = get_properties ().get_property (pa->first);
3261 3214
3262 if (! error_state && p.ok ()) 3215 if (p.ok ())
3263 p.delete_listener (); 3216 p.delete_listener ();
3264 } 3217 }
3265 } 3218 }
3266 3219
3267 void 3220 void
3442 void 3395 void
3443 root_figure::properties::set_callbackobject (const octave_value& v) 3396 root_figure::properties::set_callbackobject (const octave_value& v)
3444 { 3397 {
3445 graphics_handle val (v); 3398 graphics_handle val (v);
3446 3399
3447 if (error_state)
3448 return;
3449
3450 if (xisnan (val.value ())) 3400 if (xisnan (val.value ()))
3451 { 3401 {
3452 if (! cbo_stack.empty ()) 3402 if (! cbo_stack.empty ())
3453 { 3403 {
3454 val = cbo_stack.front (); 3404 val = cbo_stack.front ();
3472 void 3422 void
3473 root_figure::properties::set_currentfigure (const octave_value& v) 3423 root_figure::properties::set_currentfigure (const octave_value& v)
3474 { 3424 {
3475 graphics_handle val (v); 3425 graphics_handle val (v);
3476 3426
3477 if (error_state)
3478 return;
3479
3480 if (xisnan (val.value ()) || is_handle (val)) 3427 if (xisnan (val.value ()) || is_handle (val))
3481 { 3428 {
3482 currentfigure = val; 3429 currentfigure = val;
3483 3430
3484 if (val.ok ()) 3431 if (val.ok ())
3489 } 3436 }
3490 3437
3491 void 3438 void
3492 figure::properties::set_integerhandle (const octave_value& val) 3439 figure::properties::set_integerhandle (const octave_value& val)
3493 { 3440 {
3494 if (! error_state) 3441 if (integerhandle.set (val, true))
3495 { 3442 {
3496 if (integerhandle.set (val, true)) 3443 bool int_fig_handle = integerhandle.is_on ();
3497 { 3444
3498 bool int_fig_handle = integerhandle.is_on (); 3445 graphics_object this_go = gh_manager::get_object (__myhandle__);
3499 3446
3500 graphics_object this_go = gh_manager::get_object (__myhandle__); 3447 graphics_handle old_myhandle = __myhandle__;
3501 3448
3502 graphics_handle old_myhandle = __myhandle__; 3449 __myhandle__ = gh_manager::get_handle (int_fig_handle);
3503 3450
3504 __myhandle__ = gh_manager::get_handle (int_fig_handle); 3451 gh_manager::renumber_figure (old_myhandle, __myhandle__);
3505 3452
3506 gh_manager::renumber_figure (old_myhandle, __myhandle__); 3453 graphics_object parent_go = gh_manager::get_object (get_parent ());
3507 3454
3508 graphics_object parent_go = gh_manager::get_object (get_parent ()); 3455 base_properties& props = parent_go.get_properties ();
3509 3456
3510 base_properties& props = parent_go.get_properties (); 3457 props.renumber_child (old_myhandle, __myhandle__);
3511 3458
3512 props.renumber_child (old_myhandle, __myhandle__); 3459 Matrix kids = get_children ();
3513 3460
3514 Matrix kids = get_children (); 3461 for (octave_idx_type i = 0; i < kids.numel (); i++)
3515 3462 {
3516 for (octave_idx_type i = 0; i < kids.numel (); i++) 3463 graphics_object kid = gh_manager::get_object (kids(i));
3517 { 3464
3518 graphics_object kid = gh_manager::get_object (kids(i)); 3465 kid.get_properties ().renumber_parent (__myhandle__);
3519 3466 }
3520 kid.get_properties ().renumber_parent (__myhandle__); 3467
3521 } 3468 graphics_handle cf = gh_manager::current_figure ();
3522 3469
3523 graphics_handle cf = gh_manager::current_figure (); 3470 if (__myhandle__ == cf)
3524 3471 xset (0, "currentfigure", __myhandle__.value ());
3525 if (__myhandle__ == cf) 3472
3526 xset (0, "currentfigure", __myhandle__.value ()); 3473 this_go.update (integerhandle.get_id ());
3527 3474
3528 this_go.update (integerhandle.get_id ()); 3475 mark_modified ();
3529
3530 mark_modified ();
3531 }
3532 } 3476 }
3533 } 3477 }
3534 3478
3535 // FIXME: This should update monitorpositions and pointerlocation, but as these 3479 // FIXME: This should update monitorpositions and pointerlocation, but as these
3536 // properties aren't yet used, it doesn't matter that they aren't set either. 3480 // properties aren't yet used, it doesn't matter that they aren't set either.
3638 void 3582 void
3639 figure::properties::set_currentaxes (const octave_value& val) 3583 figure::properties::set_currentaxes (const octave_value& val)
3640 { 3584 {
3641 graphics_handle hax (val); 3585 graphics_handle hax (val);
3642 3586
3643 if (error_state)
3644 return;
3645
3646 if (xisnan (hax.value ()) || is_handle (hax)) 3587 if (xisnan (hax.value ()) || is_handle (hax))
3647 currentaxes = hax; 3588 currentaxes = hax;
3648 else 3589 else
3649 gripe_set_invalid ("currentaxes"); 3590 gripe_set_invalid ("currentaxes");
3650 } 3591 }
3712 void 3653 void
3713 figure::properties::set_visible (const octave_value& val) 3654 figure::properties::set_visible (const octave_value& val)
3714 { 3655 {
3715 std::string sval = val.string_value (); 3656 std::string sval = val.string_value ();
3716 3657
3717 if (! error_state) 3658 if (sval == "on")
3718 { 3659 xset (0, "currentfigure", __myhandle__.value ());
3719 if (sval == "on") 3660
3720 xset (0, "currentfigure", __myhandle__.value ()); 3661 visible = val;
3721
3722 visible = val;
3723 }
3724 } 3662 }
3725 3663
3726 Matrix 3664 Matrix
3727 figure::properties::get_boundingbox (bool internal, const Matrix&) const 3665 figure::properties::get_boundingbox (bool internal, const Matrix&) const
3728 { 3666 {
3794 3732
3795 void 3733 void
3796 figure::properties::set_position (const octave_value& v, 3734 figure::properties::set_position (const octave_value& v,
3797 bool do_notify_toolkit) 3735 bool do_notify_toolkit)
3798 { 3736 {
3799 if (! error_state) 3737 Matrix old_bb, new_bb;
3800 { 3738 bool modified = false;
3801 Matrix old_bb, new_bb; 3739
3802 bool modified = false; 3740 old_bb = get_boundingbox (true);
3803 3741 modified = position.set (v, false, do_notify_toolkit);
3804 old_bb = get_boundingbox (true); 3742 new_bb = get_boundingbox (true);
3805 modified = position.set (v, false, do_notify_toolkit); 3743
3806 new_bb = get_boundingbox (true); 3744 if (old_bb != new_bb)
3807 3745 {
3808 if (old_bb != new_bb) 3746 if (old_bb(2) != new_bb(2) || old_bb(3) != new_bb(3))
3809 { 3747 {
3810 if (old_bb(2) != new_bb(2) || old_bb(3) != new_bb(3)) 3748 execute_resizefcn ();
3811 { 3749 update_boundingbox ();
3812 execute_resizefcn (); 3750 }
3813 update_boundingbox (); 3751 }
3814 } 3752
3815 } 3753 if (modified)
3816 3754 {
3817 if (modified) 3755 position.run_listeners (POSTSET);
3818 { 3756 mark_modified ();
3819 position.run_listeners (POSTSET); 3757 }
3820 mark_modified (); 3758
3821 } 3759 if (paperpositionmode.is ("auto"))
3822 3760 paperposition.set (get_auto_paperposition ());
3823 if (paperpositionmode.is ("auto"))
3824 paperposition.set (get_auto_paperposition ());
3825 }
3826 } 3761 }
3827 3762
3828 void 3763 void
3829 figure::properties::set_outerposition (const octave_value& v, 3764 figure::properties::set_outerposition (const octave_value& v,
3830 bool do_notify_toolkit) 3765 bool do_notify_toolkit)
3831 { 3766 {
3832 if (! error_state) 3767 if (outerposition.set (v, true, do_notify_toolkit))
3833 { 3768 mark_modified ();
3834 if (outerposition.set (v, true, do_notify_toolkit)) 3769 }
3835 { 3770
3771 void
3772 figure::properties::set_paperunits (const octave_value& val)
3773 {
3774 caseless_str punits = val.string_value ();
3775 caseless_str ptype = get_papertype ();
3776
3777 if (punits.compare ("normalized") && ptype.compare ("<custom>"))
3778 error ("set: can't set paperunits to normalized when papertype is custom");
3779 else
3780 {
3781 caseless_str old_paperunits = get_paperunits ();
3782 if (paperunits.set (val, true))
3783 {
3784 update_paperunits (old_paperunits);
3836 mark_modified (); 3785 mark_modified ();
3837 } 3786 }
3838 } 3787 }
3839 } 3788 }
3840 3789
3841 void 3790 void
3842 figure::properties::set_paperunits (const octave_value& val)
3843 {
3844 if (! error_state)
3845 {
3846 caseless_str punits = val.string_value ();
3847 caseless_str ptype = get_papertype ();
3848 if (! error_state)
3849 {
3850 if (punits.compare ("normalized") && ptype.compare ("<custom>"))
3851 error ("set: can't set paperunits to normalized when papertype is custom");
3852 else
3853 {
3854 caseless_str old_paperunits = get_paperunits ();
3855 if (paperunits.set (val, true))
3856 {
3857 update_paperunits (old_paperunits);
3858 mark_modified ();
3859 }
3860 }
3861 }
3862 }
3863 }
3864
3865 void
3866 figure::properties::set_papertype (const octave_value& val) 3791 figure::properties::set_papertype (const octave_value& val)
3867 { 3792 {
3868 if (! error_state) 3793 caseless_str ptype = val.string_value ();
3869 { 3794 caseless_str punits = get_paperunits ();
3870 caseless_str ptype = val.string_value (); 3795
3871 caseless_str punits = get_paperunits (); 3796 if (punits.compare ("normalized") && ptype.compare ("<custom>"))
3872 if (! error_state) 3797 error ("set: can't set paperunits to normalized when papertype is custom");
3873 { 3798 else
3874 if (punits.compare ("normalized") && ptype.compare ("<custom>")) 3799 {
3875 error ("set: can't set paperunits to normalized when papertype is custom"); 3800 if (papertype.set (val, true))
3876 else 3801 {
3877 { 3802 update_papertype ();
3878 if (papertype.set (val, true)) 3803 mark_modified ();
3879 {
3880 update_papertype ();
3881 mark_modified ();
3882 }
3883 }
3884 } 3804 }
3885 } 3805 }
3886 } 3806 }
3887 3807
3888 static Matrix 3808 static Matrix
4448 */ 4368 */
4449 4369
4450 void 4370 void
4451 figure::properties::set_units (const octave_value& val) 4371 figure::properties::set_units (const octave_value& val)
4452 { 4372 {
4453 if (! error_state) 4373 caseless_str old_units = get_units ();
4454 { 4374
4455 caseless_str old_units = get_units (); 4375 if (units.set (val, true))
4456 if (units.set (val, true)) 4376 {
4457 { 4377 update_units (old_units);
4458 update_units (old_units); 4378 mark_modified ();
4459 mark_modified ();
4460 }
4461 } 4379 }
4462 } 4380 }
4463 4381
4464 void 4382 void
4465 figure::properties::update_units (const caseless_str& old_units) 4383 figure::properties::update_units (const caseless_str& old_units)
4772 4690
4773 error ("set: expecting text graphics object or character string for %s property, found %s", 4691 error ("set: expecting text graphics object or character string for %s property, found %s",
4774 who.c_str (), cname.c_str ()); 4692 who.c_str (), cname.c_str ());
4775 } 4693 }
4776 4694
4777 if (! error_state) 4695 xset (val, "handlevisibility", "off");
4778 { 4696
4779 xset (val, "handlevisibility", "off"); 4697 gh_manager::free (hp.handle_value ());
4780 4698
4781 gh_manager::free (hp.handle_value ()); 4699 base_properties::remove_child (hp.handle_value ());
4782 4700
4783 base_properties::remove_child (hp.handle_value ()); 4701 hp = val;
4784 4702
4785 hp = val; 4703 adopt (hp.handle_value ());
4786
4787 adopt (hp.handle_value ());
4788 }
4789 } 4704 }
4790 4705
4791 void 4706 void
4792 axes::properties::set_xlabel (const octave_value& v) 4707 axes::properties::set_xlabel (const octave_value& v)
4793 { 4708 {
6457 } 6372 }
6458 6373
6459 void 6374 void
6460 axes::properties::set_xticklabel (const octave_value& val) 6375 axes::properties::set_xticklabel (const octave_value& val)
6461 { 6376 {
6462 if (! error_state) 6377 if (xticklabel.set (convert_ticklabel_string (val), false))
6463 { 6378 {
6464 if (xticklabel.set (convert_ticklabel_string (val), false)) 6379 set_xticklabelmode ("manual");
6465 { 6380 xticklabel.run_listeners (POSTSET);
6466 set_xticklabelmode ("manual"); 6381 mark_modified ();
6467 xticklabel.run_listeners (POSTSET); 6382 }
6468 mark_modified (); 6383 else
6469 } 6384 set_xticklabelmode ("manual");
6470 else 6385
6471 set_xticklabelmode ("manual"); 6386 sync_positions ();
6472
6473 sync_positions ();
6474 }
6475 } 6387 }
6476 6388
6477 void 6389 void
6478 axes::properties::set_yticklabel (const octave_value& val) 6390 axes::properties::set_yticklabel (const octave_value& val)
6479 { 6391 {
6480 if (! error_state) 6392 if (yticklabel.set (convert_ticklabel_string (val), false))
6481 { 6393 {
6482 if (yticklabel.set (convert_ticklabel_string (val), false)) 6394 set_yticklabelmode ("manual");
6483 { 6395 yticklabel.run_listeners (POSTSET);
6484 set_yticklabelmode ("manual"); 6396 mark_modified ();
6485 yticklabel.run_listeners (POSTSET); 6397 }
6486 mark_modified (); 6398 else
6487 } 6399 set_yticklabelmode ("manual");
6488 else 6400
6489 set_yticklabelmode ("manual"); 6401 sync_positions ();
6490
6491 sync_positions ();
6492 }
6493 } 6402 }
6494 6403
6495 void 6404 void
6496 axes::properties::set_zticklabel (const octave_value& val) 6405 axes::properties::set_zticklabel (const octave_value& val)
6497 { 6406 {
6498 if (! error_state) 6407 if (zticklabel.set (convert_ticklabel_string (val), false))
6499 { 6408 {
6500 if (zticklabel.set (convert_ticklabel_string (val), false)) 6409 set_zticklabelmode ("manual");
6501 { 6410 zticklabel.run_listeners (POSTSET);
6502 set_zticklabelmode ("manual"); 6411 mark_modified ();
6503 zticklabel.run_listeners (POSTSET); 6412 }
6504 mark_modified (); 6413 else
6505 } 6414 set_zticklabelmode ("manual");
6506 else 6415
6507 set_zticklabelmode ("manual"); 6416 sync_positions ();
6508
6509 sync_positions ();
6510 }
6511 } 6417 }
6512 6418
6513 // Almost identical to convert_ticklabel_string but it only accepts 6419 // Almost identical to convert_ticklabel_string but it only accepts
6514 // cellstr or string, not numeric input. 6420 // cellstr or string, not numeric input.
6515 static octave_value 6421 static octave_value
6552 } 6458 }
6553 6459
6554 void 6460 void
6555 axes::properties::set_linestyleorder (const octave_value& val) 6461 axes::properties::set_linestyleorder (const octave_value& val)
6556 { 6462 {
6557 if (! error_state) 6463 linestyleorder.set (convert_linestyleorder_string (val), false);
6558 {
6559 linestyleorder.set (convert_linestyleorder_string (val), false);
6560 }
6561 } 6464 }
6562 6465
6563 void 6466 void
6564 axes::properties::set_units (const octave_value& val) 6467 axes::properties::set_units (const octave_value& val)
6565 { 6468 {
6566 if (! error_state) 6469 caseless_str old_units = get_units ();
6567 { 6470
6568 caseless_str old_units = get_units (); 6471 if (units.set (val, true))
6569 if (units.set (val, true)) 6472 {
6570 { 6473 update_units (old_units);
6571 update_units (old_units); 6474 mark_modified ();
6572 mark_modified ();
6573 }
6574 } 6475 }
6575 } 6476 }
6576 6477
6577 void 6478 void
6578 axes::properties::update_units (const caseless_str& old_units) 6479 axes::properties::update_units (const caseless_str& old_units)
6600 } 6501 }
6601 6502
6602 void 6503 void
6603 axes::properties::set_fontunits (const octave_value& val) 6504 axes::properties::set_fontunits (const octave_value& val)
6604 { 6505 {
6605 if (! error_state) 6506 caseless_str old_fontunits = get_fontunits ();
6606 { 6507
6607 caseless_str old_fontunits = get_fontunits (); 6508 if (fontunits.set (val, true))
6608 if (fontunits.set (val, true)) 6509 {
6609 { 6510 update_fontunits (old_fontunits);
6610 update_fontunits (old_fontunits); 6511 mark_modified ();
6611 mark_modified ();
6612 }
6613 } 6512 }
6614 } 6513 }
6615 6514
6616 void 6515 void
6617 axes::properties::update_fontunits (const caseless_str& old_units) 6516 axes::properties::update_fontunits (const caseless_str& old_units)
6724 { 6623 {
6725 if (data.is_matrix_type ()) 6624 if (data.is_matrix_type ())
6726 { 6625 {
6727 Matrix m = data.matrix_value (); 6626 Matrix m = data.matrix_value ();
6728 6627
6729 if (! error_state && m.numel () == 4) 6628 if (m.numel () == 4)
6730 { 6629 {
6731 double val; 6630 double val;
6732 6631
6733 val = m(0); 6632 val = m(0);
6734 if (xfinite (val) && val < min_val) 6633 if (xfinite (val) && val < min_val)
8030 } 7929 }
8031 7930
8032 void 7931 void
8033 text::properties::set_fontunits (const octave_value& val) 7932 text::properties::set_fontunits (const octave_value& val)
8034 { 7933 {
8035 if (! error_state) 7934 caseless_str old_fontunits = get_fontunits ();
8036 { 7935
8037 caseless_str old_fontunits = get_fontunits (); 7936 if (fontunits.set (val, true))
8038 if (fontunits.set (val, true)) 7937 {
8039 { 7938 update_fontunits (old_fontunits);
8040 update_fontunits (old_fontunits); 7939 mark_modified ();
8041 mark_modified ();
8042 }
8043 } 7940 }
8044 } 7941 }
8045 7942
8046 void 7943 void
8047 text::properties::update_fontunits (const caseless_str& old_units) 7944 text::properties::update_fontunits (const caseless_str& old_units)
8883 } 8780 }
8884 8781
8885 void 8782 void
8886 uicontrol::properties::set_fontunits (const octave_value& val) 8783 uicontrol::properties::set_fontunits (const octave_value& val)
8887 { 8784 {
8888 if (! error_state) 8785 caseless_str old_fontunits = get_fontunits ();
8889 { 8786
8890 caseless_str old_fontunits = get_fontunits (); 8787 if (fontunits.set (val, true))
8891 if (fontunits.set (val, true)) 8788 {
8892 { 8789 update_fontunits (old_fontunits);
8893 update_fontunits (old_fontunits); 8790 mark_modified ();
8894 mark_modified ();
8895 }
8896 } 8791 }
8897 } 8792 }
8898 8793
8899 void 8794 void
8900 uicontrol::properties::update_fontunits (const caseless_str& old_units) 8795 uicontrol::properties::update_fontunits (const caseless_str& old_units)
8992 } 8887 }
8993 8888
8994 void 8889 void
8995 uipanel::properties::set_units (const octave_value& val) 8890 uipanel::properties::set_units (const octave_value& val)
8996 { 8891 {
8997 if (! error_state) 8892 caseless_str old_units = get_units ();
8998 { 8893
8999 caseless_str old_units = get_units (); 8894 if (units.set (val, true))
9000 if (units.set (val, true)) 8895 {
9001 { 8896 update_units (old_units);
9002 update_units (old_units); 8897 mark_modified ();
9003 mark_modified ();
9004 }
9005 } 8898 }
9006 } 8899 }
9007 8900
9008 void 8901 void
9009 uipanel::properties::update_units (const caseless_str& old_units) 8902 uipanel::properties::update_units (const caseless_str& old_units)
9019 } 8912 }
9020 8913
9021 void 8914 void
9022 uipanel::properties::set_fontunits (const octave_value& val) 8915 uipanel::properties::set_fontunits (const octave_value& val)
9023 { 8916 {
9024 if (! error_state) 8917 caseless_str old_fontunits = get_fontunits ();
9025 { 8918
9026 caseless_str old_fontunits = get_fontunits (); 8919 if (fontunits.set (val, true))
9027 if (fontunits.set (val, true)) 8920 {
9028 { 8921 update_fontunits (old_fontunits);
9029 update_fontunits (old_fontunits); 8922 mark_modified ();
9030 mark_modified ();
9031 }
9032 } 8923 }
9033 } 8924 }
9034 8925
9035 void 8926 void
9036 uipanel::properties::update_fontunits (const caseless_str& old_units) 8927 uipanel::properties::update_fontunits (const caseless_str& old_units)
9458 || cb.cell_value ()(0).is_function_handle ())) 9349 || cb.cell_value ()(0).is_function_handle ()))
9459 { 9350 {
9460 Cell c = cb.cell_value (); 9351 Cell c = cb.cell_value ();
9461 9352
9462 fcn = c(0).function_value (); 9353 fcn = c(0).function_value ();
9463 if (! error_state) 9354
9464 { 9355 for (int i = 1; i < c.numel () ; i++)
9465 for (int i = 1; i < c.numel () ; i++) 9356 args(1+i) = c(i);
9466 args(1+i) = c(i);
9467 }
9468 } 9357 }
9469 else 9358 else
9470 { 9359 {
9471 std::string nm = cb.class_name (); 9360 std::string nm = cb.class_name ();
9472 error ("trying to execute non-executable object (class = %s)", 9361 error ("trying to execute non-executable object (class = %s)",
9473 nm.c_str ()); 9362 nm.c_str ());
9474 } 9363 }
9475 9364
9476 if (fcn && ! error_state) 9365 if (fcn)
9477 feval (fcn, args); 9366 feval (fcn, args);
9478 9367
9479 END_INTERRUPT_WITH_EXCEPTIONS; 9368 END_INTERRUPT_WITH_EXCEPTIONS;
9480 } 9369 }
9481 } 9370 }
9702 retval = true; 9591 retval = true;
9703 else if (val.is_numeric_type () && val.is_real_type ()) 9592 else if (val.is_numeric_type () && val.is_real_type ())
9704 { 9593 {
9705 const NDArray handles = val.array_value (); 9594 const NDArray handles = val.array_value ();
9706 9595
9707 if (! error_state) 9596 boolNDArray result (handles.dims ());
9708 { 9597
9709 boolNDArray result (handles.dims ()); 9598 for (octave_idx_type i = 0; i < handles.numel (); i++)
9710 9599 result.xelem (i) = is_handle_visible (handles(i));
9711 for (octave_idx_type i = 0; i < handles.numel (); i++) 9600
9712 result.xelem (i) = is_handle_visible (handles(i)); 9601 retval = result;
9713
9714 retval = result;
9715 }
9716 } 9602 }
9717 9603
9718 return retval; 9604 return retval;
9719 } 9605 }
9720 9606
9756 else 9642 else
9757 { 9643 {
9758 // get vector of graphics handles 9644 // get vector of graphics handles
9759 ColumnVector hcv (args(0).vector_value ()); 9645 ColumnVector hcv (args(0).vector_value ());
9760 9646
9761 if (! error_state) 9647 // loop over graphics objects
9762 { 9648 for (octave_idx_type n = 0; n < hcv.numel (); n++)
9763 // loop over graphics objects 9649 gh_manager::get_object (hcv(n)).reset_default_properties ();
9764 for (octave_idx_type n = 0; n < hcv.numel (); n++) 9650
9765 gh_manager::get_object (hcv(n)).reset_default_properties (); 9651 Fdrawnow ();
9766
9767 if (! error_state)
9768 Fdrawnow ();
9769 }
9770 } 9652 }
9771 9653
9772 return octave_value (); 9654 return octave_value ();
9773 } 9655 }
9774 9656
10024 if (nargout != 0) 9906 if (nargout != 0)
10025 retval = pmap.getfield (property)(0); 9907 retval = pmap.getfield (property)(0);
10026 else 9908 else
10027 { 9909 {
10028 std::string s = go.value_as_string (property); 9910 std::string s = go.value_as_string (property);
10029 if (! error_state) 9911
10030 octave_stdout << s; 9912 octave_stdout << s;
10031 } 9913 }
10032 } 9914 }
10033 else 9915 else
10034 { 9916 {
10035 error ("set: unknown property"); 9917 error ("set: unknown property");
10041 if (nargout != 0) 9923 if (nargout != 0)
10042 retval = go.values_as_struct (); 9924 retval = go.values_as_struct ();
10043 else 9925 else
10044 { 9926 {
10045 std::string s = go.values_as_string (); 9927 std::string s = go.values_as_string ();
10046 if (! error_state) 9928
10047 octave_stdout << s; 9929 octave_stdout << s;
10048 } 9930 }
10049 } 9931 }
10050 else 9932 else
10051 { 9933 {
10052 go.set (args.splice (0, 1)); 9934 go.set (args.splice (0, 1));
10057 { 9939 {
10058 error ("set: invalid handle (= %g)", hcv(n)); 9940 error ("set: invalid handle (= %g)", hcv(n));
10059 break; 9941 break;
10060 } 9942 }
10061 9943
10062 if (error_state)
10063 break;
10064
10065 request_drawnow = true; 9944 request_drawnow = true;
10066 } 9945 }
10067 9946
10068 if (! error_state && request_drawnow) 9947 if (request_drawnow)
10069 Vdrawnow_requested = true; 9948 Vdrawnow_requested = true;
10070 } 9949 }
10071 else 9950 else
10072 error ("set: expecting graphics handle as first argument"); 9951 error ("set: expecting graphics handle as first argument");
10073 } 9952 }
10132 10011
10133 if (nargin == 1 && len > 1) 10012 if (nargin == 1 && len > 1)
10134 { 10013 {
10135 std::string typ0 = get_graphics_object_type (hcv(0)); 10014 std::string typ0 = get_graphics_object_type (hcv(0));
10136 10015
10016 for (octave_idx_type n = 1; n < len; n++)
10017 {
10018 std::string typ = get_graphics_object_type (hcv(n));
10019
10020 if (typ != typ0)
10021 {
10022 error ("get: vector of handles must all have same type");
10023 break;
10024 }
10025 }
10026 }
10027
10028 if (nargin > 1 && args(1).is_cellstr ())
10029 {
10030 Array<std::string> plist = args(1).cellstr_value ();
10031
10137 if (! error_state) 10032 if (! error_state)
10138 { 10033 {
10139 for (octave_idx_type n = 1; n < len; n++) 10034 octave_idx_type plen = plist.numel ();
10035
10036 use_cell_format = true;
10037
10038 vals.resize (dim_vector (len, plen));
10039
10040 for (octave_idx_type n = 0; n < len; n++)
10140 { 10041 {
10141 std::string typ = get_graphics_object_type (hcv(n)); 10042 graphics_object go = gh_manager::get_object (hcv(n));
10142 10043
10143 if (error_state) 10044 if (go)
10144 break;
10145
10146 if (typ != typ0)
10147 { 10045 {
10148 error ("get: vector of handles must all have same type"); 10046 for (octave_idx_type m = 0; m < plen; m++)
10047 {
10048 caseless_str property = plist(m);
10049
10050 vals(n, m) = go.get (property);
10051 }
10052 }
10053 else
10054 {
10055 error ("get: invalid handle (= %g)", hcv(n));
10149 break; 10056 break;
10150 } 10057 }
10151 } 10058 }
10152
10153 } 10059 }
10060 else
10061 error ("get: expecting property name or cell array of property names as second argument");
10154 } 10062 }
10155 10063 else
10156 if (! error_state)
10157 { 10064 {
10158 if (nargin > 1 && args(1).is_cellstr ()) 10065 caseless_str property;
10066
10067 if (nargin > 1)
10159 { 10068 {
10160 Array<std::string> plist = args(1).cellstr_value (); 10069 property = args(1).string_value ();
10161 10070
10162 if (! error_state) 10071 if (error_state)
10072 error ("get: expecting property name or cell array of property names as second argument");
10073 }
10074
10075 vals.resize (dim_vector (len, 1));
10076
10077 for (octave_idx_type n = 0; n < len; n++)
10078 {
10079 graphics_object go = gh_manager::get_object (hcv(n));
10080
10081 if (go)
10163 { 10082 {
10164 octave_idx_type plen = plist.numel (); 10083 if (nargin == 1)
10165 10084 vals(n) = go.get ();
10166 use_cell_format = true; 10085 else
10167 10086 vals(n) = go.get (property);
10168 vals.resize (dim_vector (len, plen));
10169
10170 for (octave_idx_type n = 0; ! error_state && n < len; n++)
10171 {
10172 graphics_object go = gh_manager::get_object (hcv(n));
10173
10174 if (go)
10175 {
10176 for (octave_idx_type m = 0;
10177 ! error_state && m < plen;
10178 m++)
10179 {
10180 caseless_str property = plist(m);
10181
10182 vals(n, m) = go.get (property);
10183 }
10184 }
10185 else
10186 {
10187 error ("get: invalid handle (= %g)", hcv(n));
10188 break;
10189 }
10190 }
10191 } 10087 }
10192 else 10088 else
10193 error ("get: expecting property name or cell array of property names as second argument");
10194 }
10195 else
10196 {
10197 caseless_str property;
10198
10199 if (nargin > 1)
10200 { 10089 {
10201 property = args(1).string_value (); 10090 error ("get: invalid handle (= %g)", hcv(n));
10202 10091 break;
10203 if (error_state)
10204 error ("get: expecting property name or cell array of property names as second argument");
10205 }
10206
10207 vals.resize (dim_vector (len, 1));
10208
10209 if (! error_state)
10210 {
10211 for (octave_idx_type n = 0; ! error_state && n < len; n++)
10212 {
10213 graphics_object go = gh_manager::get_object (hcv(n));
10214
10215 if (go)
10216 {
10217 if (nargin == 1)
10218 vals(n) = go.get ();
10219 else
10220 vals(n) = go.get (property);
10221 }
10222 else
10223 {
10224 error ("get: invalid handle (= %g)", hcv(n));
10225 break;
10226 }
10227 }
10228 } 10092 }
10229 } 10093 }
10230 } 10094 }
10231 } 10095 }
10232 else 10096 else
10233 error ("get: expecting graphics handle as first argument"); 10097 error ("get: expecting graphics handle as first argument");
10234 } 10098 }
10235 else 10099 else
10236 print_usage (); 10100 print_usage ();
10237 10101
10238 if (! error_state) 10102 if (use_cell_format)
10239 { 10103 retval = vals;
10240 if (use_cell_format) 10104 else
10105 {
10106 octave_idx_type len = vals.numel ();
10107
10108 if (len == 0)
10109 retval = Matrix ();
10110 else if (len == 1)
10111 retval = vals(0);
10112 else if (len > 1 && nargin == 1)
10113 {
10114 OCTAVE_LOCAL_BUFFER (octave_scalar_map, tmp, len);
10115
10116 for (octave_idx_type n = 0; n < len; n++)
10117 tmp[n] = vals(n).scalar_map_value ();
10118
10119 retval = octave_map::cat (0, len, tmp);
10120 }
10121 else
10241 retval = vals; 10122 retval = vals;
10242 else
10243 {
10244 octave_idx_type len = vals.numel ();
10245
10246 if (len == 0)
10247 retval = Matrix ();
10248 else if (len == 1)
10249 retval = vals(0);
10250 else if (len > 1 && nargin == 1)
10251 {
10252 OCTAVE_LOCAL_BUFFER (octave_scalar_map, tmp, len);
10253
10254 for (octave_idx_type n = 0; n < len; n++)
10255 tmp[n] = vals(n).scalar_map_value ();
10256
10257 retval = octave_map::cat (0, len, tmp);
10258 }
10259 else
10260 retval = vals;
10261 }
10262 } 10123 }
10263 10124
10264 return retval; 10125 return retval;
10265 } 10126 }
10266 10127
10313 error ("get: expecting graphics handle as first argument"); 10174 error ("get: expecting graphics handle as first argument");
10314 } 10175 }
10315 else 10176 else
10316 print_usage (); 10177 print_usage ();
10317 10178
10318 if (! error_state) 10179 octave_idx_type len = vals.numel ();
10319 { 10180
10320 octave_idx_type len = vals.numel (); 10181 if (len > 1)
10321 10182 retval = vals;
10322 if (len > 1) 10183 else if (len == 1)
10323 retval = vals; 10184 retval = vals(0);
10324 else if (len == 1)
10325 retval = vals(0);
10326 }
10327 10185
10328 return retval; 10186 return retval;
10329 } 10187 }
10330 10188
10331 static octave_value 10189 static octave_value
10346 { 10204 {
10347 if (i < (xargs.length () - 1)) 10205 if (i < (xargs.length () - 1))
10348 { 10206 {
10349 val = xargs(i+1).double_value (); 10207 val = xargs(i+1).double_value ();
10350 10208
10351 if (! error_state) 10209 xargs = xargs.splice (i, 2);
10352 { 10210 break;
10353 xargs = xargs.splice (i, 2);
10354 break;
10355 }
10356 } 10211 }
10357 else 10212 else
10358 error ("__go_%s__: missing value for parent property", 10213 error ("__go_%s__: missing value for parent property",
10359 go_name.c_str ()); 10214 go_name.c_str ());
10360 } 10215 }
10361 10216
10362 if (! error_state && xisnan (val)) 10217 if (xisnan (val))
10363 val = args(0).double_value (); 10218 val = args(0).double_value ();
10364 10219
10365 if (! error_state) 10220 if (! error_state)
10366 { 10221 {
10367 graphics_handle parent = gh_manager::lookup (val); 10222 graphics_handle parent = gh_manager::lookup (val);
10381 xcreatefcn (h); 10236 xcreatefcn (h);
10382 xinitialize (h); 10237 xinitialize (h);
10383 10238
10384 retval = h.value (); 10239 retval = h.value ();
10385 10240
10386 if (! error_state) 10241 Vdrawnow_requested = true;
10387 Vdrawnow_requested = true;
10388 } 10242 }
10389 else 10243 else
10390 error ("__go%s__: unable to create graphics handle", 10244 error ("__go%s__: unable to create graphics handle",
10391 go_name.c_str ()); 10245 go_name.c_str ());
10392 } 10246 }
10442 { 10296 {
10443 if (i < (xargs.length () - 1)) 10297 if (i < (xargs.length () - 1))
10444 { 10298 {
10445 std::string pval = xargs(i+1).string_value (); 10299 std::string pval = xargs(i+1).string_value ();
10446 10300
10447 if (! error_state) 10301 caseless_str on ("on");
10448 { 10302 int_fig_handle = on.compare (pval);
10449 caseless_str on ("on"); 10303 xargs = xargs.splice (i, 2);
10450 int_fig_handle = on.compare (pval); 10304
10451 xargs = xargs.splice (i, 2); 10305 break;
10452 break;
10453 }
10454 } 10306 }
10455 } 10307 }
10456 } 10308 }
10457 10309
10458 h = gh_manager::make_graphics_handle ("figure", 0, 10310 h = gh_manager::make_graphics_handle ("figure", 0,
10726 error ("delete: invalid graphics object (= %g)", vals(i)); 10578 error ("delete: invalid graphics object (= %g)", vals(i));
10727 break; 10579 break;
10728 } 10580 }
10729 } 10581 }
10730 10582
10731 if (! error_state) 10583 delete_graphics_objects (vals);
10732 delete_graphics_objects (vals);
10733 } 10584 }
10734 else 10585 else
10735 error ("delete: invalid graphics object"); 10586 error ("delete: invalid graphics object");
10736 } 10587 }
10737 else 10588 else
10753 int nargin = args.length (); 10604 int nargin = args.length ();
10754 10605
10755 std::string mode = ""; 10606 std::string mode = "";
10756 10607
10757 if (nargin == 2) 10608 if (nargin == 2)
10758 { 10609 mode = args(1).string_value ();
10759 mode = args(1).string_value ();
10760
10761 if (error_state)
10762 return retval;
10763 }
10764 10610
10765 if (nargin == 1 || nargin == 2) 10611 if (nargin == 1 || nargin == 2)
10766 { 10612 {
10767 graphics_handle h = octave_NaN; 10613 graphics_handle h = octave_NaN;
10768 10614
10940 { 10786 {
10941 octave_value_list args; 10787 octave_value_list args;
10942 args(0) = dtk; 10788 args(0) = dtk;
10943 feval ("graphics_toolkit", args); 10789 feval ("graphics_toolkit", args);
10944 10790
10945 if (! error_state) 10791 pl = loaded_toolkits.find (dtk);
10946 pl = loaded_toolkits.find (dtk);
10947 10792
10948 if (error_state || pl == loaded_toolkits.end ()) 10793 if (error_state || pl == loaded_toolkits.end ())
10949 error ("failed to load %s graphics toolkit", dtk.c_str ()); 10794 error ("failed to load %s graphics toolkit", dtk.c_str ());
10950 else 10795 else
10951 retval = pl->second; 10796 retval = pl->second;
11086 { 10931 {
11087 if (args.length () == 0 || args.length () == 1) 10932 if (args.length () == 0 || args.length () == 1)
11088 { 10933 {
11089 Matrix hlist = gh_manager::figure_handle_list (true); 10934 Matrix hlist = gh_manager::figure_handle_list (true);
11090 10935
11091 for (int i = 0; ! error_state && i < hlist.numel (); i++) 10936 for (int i = 0; i < hlist.numel (); i++)
11092 { 10937 {
11093 graphics_handle h = gh_manager::lookup (hlist(i)); 10938 graphics_handle h = gh_manager::lookup (hlist(i));
11094 10939
11095 if (h.ok () && h != 0) 10940 if (h.ok () && h != 0)
11096 { 10941 {
11507 if (! go.get_properties ().has_property (name)) 11352 if (! go.get_properties ().has_property (name))
11508 { 11353 {
11509 property p = property::create (name, gh, type, 11354 property p = property::create (name, gh, type,
11510 args.splice (0, 3)); 11355 args.splice (0, 3));
11511 11356
11512 if (! error_state) 11357 go.get_properties ().insert_property (name, p);
11513 go.get_properties ().insert_property (name, p);
11514 } 11358 }
11515 else 11359 else
11516 error ("addproperty: a '%s' property already exists in the graphics object", 11360 error ("addproperty: a '%s' property already exists in the graphics object",
11517 name.c_str ()); 11361 name.c_str ());
11518 } 11362 }
11562 11406
11563 if (go) 11407 if (go)
11564 { 11408 {
11565 go.set (caseless_str (property), arg); 11409 go.set (caseless_str (property), arg);
11566 11410
11567 if (! error_state) 11411 ret = true;
11568 ret = true;
11569 } 11412 }
11570 else 11413 else
11571 error ("%s: invalid handle (= %g)", func.c_str (), handle); 11414 error ("%s: invalid handle (= %g)", func.c_str (), handle);
11572 11415
11573 return ret; 11416 return ret;
11581 args(0) = ov1; 11424 args(0) = ov1;
11582 args(1) = ov2; 11425 args(1) = ov2;
11583 11426
11584 octave_value_list result = feval ("isequal", args, 1); 11427 octave_value_list result = feval ("isequal", args, 1);
11585 11428
11586 if (! error_state && result.length () > 0) 11429 if (result.length () > 0)
11587 return result(0).bool_value (); 11430 return result(0).bool_value ();
11588 11431
11589 return false; 11432 return false;
11590 } 11433 }
11591 11434
11605 11448
11606 if (c.numel () >= 4) 11449 if (c.numel () >= 4)
11607 { 11450 {
11608 double h = c(2).double_value (); 11451 double h = c(2).double_value ();
11609 11452
11610 if (! error_state) 11453 caseless_str pname = c(3).string_value ();
11611 { 11454
11612 caseless_str pname = c(3).string_value (); 11455 gh_manager::auto_lock guard;
11613 11456
11614 if (! error_state) 11457 graphics_handle gh = gh_manager::lookup (h);
11458
11459 if (gh.ok ())
11460 {
11461 graphics_object go = gh_manager::get_object (gh);
11462
11463 if (go.get_properties ().has_property (pname))
11615 { 11464 {
11616 gh_manager::auto_lock guard; 11465 go.get_properties ().delete_listener (pname, listener, mode);
11617 11466
11618 graphics_handle gh = gh_manager::lookup (h); 11467 if (mode == POSTSET)
11619 11468 go.get_properties ().delete_listener (pname, listener,
11620 if (gh.ok ()) 11469 PERSISTENT);
11621 {
11622 graphics_object go = gh_manager::get_object (gh);
11623
11624 if (go.get_properties ().has_property (pname))
11625 {
11626 go.get_properties ().delete_listener (pname, listener,
11627 mode);
11628 if (mode == POSTSET)
11629 go.get_properties ().delete_listener (pname, listener,
11630 PERSISTENT);
11631 }
11632 }
11633 } 11470 }
11634 } 11471 }
11635 } 11472 }
11636 } 11473 }
11637 11474
11648 { 11485 {
11649 if (args.length () > 3) 11486 if (args.length () > 3)
11650 { 11487 {
11651 uint32_t id = args(2).uint32_scalar_value ().value (); 11488 uint32_t id = args(2).uint32_scalar_value ().value ();
11652 11489
11653 if (! error_state) 11490 if (args.length () > 5)
11654 { 11491 {
11655 if (args.length () > 5) 11492 double h = args(0).double_value ();
11493
11494 caseless_str pname = args(4).string_value ();
11495
11496 gh_manager::auto_lock guard;
11497
11498 graphics_handle gh = gh_manager::lookup (h);
11499
11500 if (gh.ok ())
11656 { 11501 {
11657 double h = args(0).double_value (); 11502 graphics_object go = gh_manager::get_object (gh);
11658 11503 octave_value pvalue = go.get (pname);
11659 if (! error_state) 11504
11660 { 11505 if (compare_property_values (pvalue, args(5)))
11661 caseless_str pname = args(4).string_value (); 11506 waitfor_results[id] = true;
11662
11663 if (! error_state)
11664 {
11665 gh_manager::auto_lock guard;
11666
11667 graphics_handle gh = gh_manager::lookup (h);
11668
11669 if (gh.ok ())
11670 {
11671 graphics_object go = gh_manager::get_object (gh);
11672 octave_value pvalue = go.get (pname);
11673
11674 if (compare_property_values (pvalue, args(5)))
11675 waitfor_results[id] = true;
11676 }
11677 }
11678 }
11679 } 11507 }
11680 else 11508 }
11681 waitfor_results[id] = true; 11509 else
11682 } 11510 waitfor_results[id] = true;
11683 } 11511 }
11684 11512
11685 return octave_value_list (); 11513 return octave_value_list ();
11686 } 11514 }
11687 11515
11690 { 11518 {
11691 if (args.length () > 2) 11519 if (args.length () > 2)
11692 { 11520 {
11693 uint32_t id = args(2).uint32_scalar_value ().value (); 11521 uint32_t id = args(2).uint32_scalar_value ().value ();
11694 11522
11695 if (! error_state) 11523 waitfor_results[id] = true;
11696 waitfor_results[id] = true;
11697 } 11524 }
11698 11525
11699 return octave_value_list (); 11526 return octave_value_list ();
11700 } 11527 }
11701 11528
11760 int timeout = 0; 11587 int timeout = 0;
11761 11588
11762 if (args.length () > 1) 11589 if (args.length () > 1)
11763 { 11590 {
11764 pname = args(1).string_value (); 11591 pname = args(1).string_value ();
11592
11765 if (! error_state 11593 if (! error_state
11766 && ! pname.empty () && ! pname.compare ("timeout")) 11594 && ! pname.empty () && ! pname.compare ("timeout"))
11767 { 11595 {
11768 if (pname.compare ("\\timeout")) 11596 if (pname.compare ("\\timeout"))
11769 pname = "timeout"; 11597 pname = "timeout";
11859 } 11687 }
11860 else if (error_state || pname.empty ()) 11688 else if (error_state || pname.empty ())
11861 error ("waitfor: invalid property name, expected a non-empty string value"); 11689 error ("waitfor: invalid property name, expected a non-empty string value");
11862 } 11690 }
11863 11691
11864 if (! error_state 11692 if (timeout_index < 0 && args.length () > (max_arg_index + 1))
11865 && timeout_index < 0 && args.length () > (max_arg_index + 1))
11866 { 11693 {
11867 caseless_str s = args(max_arg_index + 1).string_value (); 11694 caseless_str s = args(max_arg_index + 1).string_value ();
11868 11695
11869 if (! error_state) 11696 if (! error_state)
11870 { 11697 {
11875 } 11702 }
11876 else 11703 else
11877 error ("waitfor: invalid parameter, expected 'timeout'"); 11704 error ("waitfor: invalid parameter, expected 'timeout'");
11878 } 11705 }
11879 11706
11880 if (! error_state && timeout_index >= 0) 11707 if (timeout_index >= 0)
11881 { 11708 {
11882 if (args.length () > (timeout_index + 1)) 11709 if (args.length () > (timeout_index + 1))
11883 { 11710 {
11884 timeout = static_cast<int> 11711 timeout = static_cast<int>
11885 (args(timeout_index + 1).scalar_value ()); 11712 (args(timeout_index + 1).scalar_value ());
11976 return retval; 11803 return retval;
11977 } 11804 }
11978 11805
11979 double h = args(0).double_value (); 11806 double h = args(0).double_value ();
11980 11807
11981 if (error_state)
11982 return retval;
11983
11984 gh_manager::auto_lock guard; 11808 gh_manager::auto_lock guard;
11985 11809
11986 graphics_handle handle = gh_manager::lookup (h); 11810 graphics_handle handle = gh_manager::lookup (h);
11987 11811
11988 if (! handle.ok ()) 11812 if (! handle.ok ())
11997 dynamic_cast<axes::properties&> (ax.get_properties ()); 11821 dynamic_cast<axes::properties&> (ax.get_properties ());
11998 11822
11999 if (nargin == 2) 11823 if (nargin == 2)
12000 { 11824 {
12001 std::string opt = args(1).string_value (); 11825 std::string opt = args(1).string_value ();
12002
12003 if (error_state)
12004 return retval;
12005 11826
12006 if (opt == "out" || opt == "reset") 11827 if (opt == "out" || opt == "reset")
12007 { 11828 {
12008 if (opt == "out") 11829 if (opt == "out")
12009 { 11830 {
12017 else 11838 else
12018 { 11839 {
12019 std::string mode = args(1).string_value (); 11840 std::string mode = args(1).string_value ();
12020 double factor = args(2).scalar_value (); 11841 double factor = args(2).scalar_value ();
12021 11842
12022 if (error_state)
12023 return retval;
12024
12025 ax_props.zoom (mode, factor); 11843 ax_props.zoom (mode, factor);
12026 Vdrawnow_requested = true; 11844 Vdrawnow_requested = true;
12027 } 11845 }
12028 11846
12029 return retval; 11847 return retval;