23 #if ! defined (octave_graphics_h) 24 #define octave_graphics_h 1 26 #include "octave-config.h" 53 #if ! defined (OCTAVE_DEFAULT_FONTNAME) 54 #define OCTAVE_DEFAULT_FONTNAME "*" 68 error (
"invalid axis scale");
73 error (
"invalid axis scale");
76 virtual double scale (
double)
const 78 error (
"invalid axis scale");
83 error (
"invalid axis scale");
135 {
return log10 (
d); }
144 void do_scale (
const double *src,
double *dest,
int n)
const 146 for (
int i = 0;
i < n;
i++)
147 dest[
i] = log10 (src[
i]);
175 {
return -log10 (-
d); }
184 void do_scale (
const double *src,
double *dest,
int n)
const 186 for (
int i = 0;
i < n;
i++)
187 dest[
i] = -log10 (-src[
i]);
233 rep =
s.rep->clone ();
248 else if (
s ==
"neglog")
250 else if (
s ==
"linear")
303 virtual bool is_radio (
void)
const {
return false; }
311 OCTINTERP_API
bool set (
const octave_value& v,
bool do_run =
true,
312 bool do_notify_toolkit =
true);
316 error (R
"(get: invalid property "%s")", name.c_str ()); 321 error (R
"(values_as_string: invalid property "%s")", name.c_str ()); 326 error (R
"(values_as_cell: invalid property "%s")", name.c_str ()); 361 for (
int j =
i; j < l.
length () - 1; j++)
375 for (
int i = l.
length () - 1;
i >= 0 ;
i--)
377 for (
int j = 0; j < lp.
length (); j++)
379 if (l(
i).internal_rep () == lp(j).internal_rep ())
400 error (R
"(set: invalid property "%s")", name.c_str ()); 405 typedef std::map<listener_mode, octave_value_list>::iterator
407 typedef std::map<listener_mode, octave_value_list>::const_iterator
447 if (!
val.is_string ())
448 error (R
"(set: invalid string property value for "%s")", 483 if (new_pos == std::string::npos)
496 const Cell&
c,
const char& sep =
'|',
500 if (!
c.iscellstr ())
501 error (R
"(set: invalid order property value for "%s")", 554 if (
val.is_string () &&
val.rows () == 1)
556 bool replace =
false;
562 while (pos != std::string::npos)
564 size_t new_pos = new_str.find_first_of (
separator, pos);
566 if (new_pos == std::string::npos)
568 strings.append (new_str.substr (pos));
572 strings.append (new_str.substr (pos, new_pos - pos));
597 else if (
val.is_string ())
599 bool replace =
false;
621 else if (
val.iscellstr ())
623 bool replace =
false;
624 Cell new_cell =
val.cell_value ();
653 error (R
"(set: invalid string property value for "%s")", 687 std::ostringstream buf;
705 if (
tmp.is_string ())
709 double d =
c(
i).double_value ();
711 std::ostringstream buf;
725 return tmp.isempty ();
759 if (
val.is_string ())
765 else if (
val.iscell ())
777 if (
tmp.is_string ())
781 double d =
c(
i).double_value ();
783 std::ostringstream buf;
797 nda =
val.array_value ();
799 catch (octave::execution_exception&
e)
801 error (
e, R
"(set: invalid string property value for "%s")", 811 std::ostringstream buf;
855 error (
"invalid value = %s",
val.c_str ());
864 size_t len =
val.length ();
870 if (possible_val.compare (
val, len))
872 if (len == possible_val.length ())
877 match = possible_val;
883 first_match = possible_val;
957 error (R
"(set: invalid value for radio property "%s")", 965 error (R
"(set: invalid value for radio property "%s" (value = %s))", 970 if (
s.length () != match.length ())
972 "%s: allowing %s to match %s value %s",
1005 error (
"invalid color specification: %s",
str.c_str ());
1022 return (
xrgb(0) ==
c.xrgb(0)
1023 &&
xrgb(1) ==
c.xrgb(1)
1024 &&
xrgb(2) ==
c.xrgb(2));
1028 {
return ! (*
this ==
c); }
1036 for (
int i = 0;
i < 3;
i++)
1039 error (
"invalid RGB color specification");
1116 error (
"color has no RGB value");
1124 error (
"color has no radio value");
1203 minval = std::pair<double, bool> (
val, inclusive);
1204 else if (
type ==
"max")
1205 maxval = std::pair<double, bool> (
val, inclusive);
1215 error (R
"(set: invalid value for double property "%s")", 1224 error (R
"(set: "%s" must be greater than or equal to %g)", 1227 error (R
"(set: "%s" must be greater than %g)", 1234 error (R
"(set: "%s" must be less than or equal to %g)", 1237 error (R
"(set: "%s" must be less than %g)", 1245 error (R
"(set: "%s" must be finite)", get_name ().c_str ()); 1250 error (R
"(set: "%s" must not be nan)", get_name ().c_str ()); 1255 error (R
"(set: "%s" must not be infinite)", get_name ().c_str ()); 1329 error (
"%s: property has no radio value");
1406 minval = std::pair<double, bool> (
val, inclusive);
1407 else if (
type ==
"max")
1408 maxval = std::pair<double, bool> (
val, inclusive);
1453 error (R
"(invalid value for array property "%s")", 1564 if (
dv(0) > 1 &&
dv(1) == 1)
1593 "{on}|off" :
"on|{off}"),
val)
1612 if (
val.is_bool_scalar ())
1768 if (hchild == old_gh)
1770 hchild = new_gh.
value ();
1775 error (
"children_list::renumber: child not found!");
1790 new_kids =
val.matrix_value ();
1792 catch (octave::execution_exception&
e)
1794 error (
e,
"set: children must be an array of graphics handles");
1802 bool add_hidden =
true;
1806 if (visible_kids.
numel () == new_kids.
numel ())
1822 error (
"set: new children must be a permutation of existing children");
1925 error (R
"(invalid value for callback property "%s")", 1963 {
return rep->
ok (); }
1996 bool do_notify_toolkit =
true)
1997 {
return rep->
set (
val, do_run, do_notify_toolkit); }
2032 OCTINTERP_API
static 2075 for (it = (*this).begin (); it != (*this).end (); it++)
2076 if (
pname == (*it).first)
2079 return (*this).end ();
2086 for (it = (*this).begin (); it != (*this).end (); it++)
2087 if (
pname == (*it).first)
2090 return (*this).end ();
2099 if (it != (*this).end ())
2109 if (it == (*this).end ())
2112 return (*this).back ().second;
2115 return (*it).second;
2121 if (it != (*this).end ())
2127 std::vector<pval_pair>::erase (it);
2191 void mark_modified (
void);
2208 p.set_parent (__myhandle__);
2209 all_props[
name] =
p;
2240 if (children.remove_child (
h.value ()))
2242 children.run_listeners ();
2249 children.adopt (
h.value ());
2250 children.run_listeners ();
2259 {
return Matrix (1, 4, 0.0); }
2261 virtual void update_boundingbox (
void);
2263 virtual void update_autopos (
const std::string& elem_type);
2277 return children.get_children ();
2282 return children.get_all ();
2287 return children.get_hidden ();
2299 virtual void update_axis_limits (
const std::string& axis_type)
const;
2301 virtual void update_axis_limits (
const std::string& axis_type,
2304 virtual void update_uicontextmenu (
void)
const;
2308 children.delete_children (clear);
2313 children.renumber (old_gh, new_gh);
2342 std::set<std::string> dynamic_property_names (
void)
const;
2357 BEGIN_BASE_PROPERTIES
2367 bool_property hittest , "on" 2368 bool_property interruptible , "on" 2369 handle_property parent fs , p 2370 radio_property pickableparts , "{visible}|all|none
" 2371 bool_property selected , "off
" 2372 bool_property selectionhighlight , "on" 2373 string_property tag s , "" 2374 string_property type frs , ty 2375 handle_property uicontextmenu u , graphics_handle () 2376 any_property userdata , Matrix () 2377 bool_property visible , "on" 2379 // Octave-specific properties 2380 bool_property __modified__ hs , "on" 2381 graphics_handle __myhandle__ fhrs , mh 2384 virtual void update_handlevisibility (void); 2387 struct cmp_caseless_str 2389 bool operator () (const caseless_str& a, const caseless_str& b) const 2392 std::transform (a1.begin (), a1.end (), a1.begin (), tolower); 2394 std::transform (b1.begin (), b1.end (), b1.begin (), tolower); 2400 std::map<caseless_str, property, cmp_caseless_str> all_props; 2403 void insert_static_property (const std::string& name, base_property& p) 2404 { insert_property (name, property (&p, true)); } 2406 virtual void init (void) 2412 class OCTINTERP_API base_graphics_object 2415 friend class graphics_object; 2417 base_graphics_object (void) : toolkit_flag (false) { } 2421 base_graphics_object (const base_graphics_object&) = delete; 2423 base_graphics_object& operator = (const base_graphics_object&) = delete; 2425 virtual ~base_graphics_object (void) = default; 2427 virtual void mark_modified (void) 2429 if (! valid_object ()) 2432 get_properties ().mark_modified (); 2435 virtual void override_defaults (base_graphics_object& obj) 2437 if (! valid_object ()) 2439 get_properties ().override_defaults (obj); 2442 void build_user_defaults_map (property_list::pval_map_type& def, 2443 const std::string go_name) const; 2445 virtual void set_from_list (property_list& plist) 2447 if (! valid_object ()) 2450 get_properties ().set_from_list (*this, plist); 2453 virtual void set (const caseless_str& pname, const octave_value& pval) 2455 if (! valid_object ()) 2458 get_properties ().set (pname, pval); 2461 virtual void set_defaults (const std::string&) 2466 virtual octave_value get (bool all = false) const 2468 if (! valid_object ()) 2471 return get_properties ().get (all); 2474 virtual octave_value get (const caseless_str& pname) const 2476 if (! valid_object ()) 2479 return get_properties ().get (pname); 2482 virtual octave_value get_default (const caseless_str&) const; 2484 virtual octave_value get_factory_default (const caseless_str&) const; 2486 virtual octave_value get_defaults (void) const 2491 virtual property_list get_defaults_list (void) const 2493 if (! valid_object ()) 2496 return property_list (); 2499 virtual octave_value get_factory_defaults (void) const 2504 virtual property_list get_factory_defaults_list (void) const 2509 virtual bool has_readonly_property (const caseless_str& pname) const 2511 return base_properties::has_readonly_property (pname); 2514 virtual std::string values_as_string (void); 2516 virtual std::string value_as_string (const std::string& prop); 2518 virtual octave_scalar_map values_as_struct (void); 2520 virtual graphics_handle get_parent (void) const 2522 if (! valid_object ()) 2525 return get_properties ().get_parent (); 2528 graphics_handle get_handle (void) const 2530 if (! valid_object ()) 2533 return get_properties ().get___myhandle__ (); 2536 virtual void remove_child (const graphics_handle& h) 2538 if (! valid_object ()) 2541 get_properties ().remove_child (h); 2544 virtual void adopt (const graphics_handle& h) 2546 if (! valid_object ()) 2549 get_properties ().adopt (h); 2552 virtual void reparent (const graphics_handle& np) 2554 if (! valid_object ()) 2557 get_properties ().reparent (np); 2560 virtual void defaults (void) const 2562 if (! valid_object ()) 2565 std::string msg = (type () + "::defaults
"); 2566 err_not_implemented (msg.c_str ()); 2569 virtual base_properties& get_properties (void) 2571 static base_properties properties; 2576 virtual const base_properties& get_properties (void) const 2578 static base_properties properties; 2583 virtual void update_axis_limits (const std::string& axis_type); 2585 virtual void update_axis_limits (const std::string& axis_type, 2586 const graphics_handle& h); 2588 virtual bool valid_object (void) const { return false; } 2590 bool valid_toolkit_object (void) const { return toolkit_flag; } 2592 virtual std::string type (void) const 2594 return (valid_object () ? get_properties ().graphics_object_name () 2598 bool isa (const std::string& go_name) const 2600 return type () == go_name; 2603 virtual graphics_toolkit get_toolkit (void) const 2605 if (! valid_object ()) 2608 return get_properties ().get_toolkit (); 2611 virtual void add_property_listener (const std::string& nm, 2612 const octave_value& v, 2613 listener_mode mode = POSTSET) 2615 if (valid_object ()) 2616 get_properties ().add_listener (nm, v, mode); 2619 virtual void delete_property_listener (const std::string& nm, 2620 const octave_value& v, 2621 listener_mode mode = POSTSET) 2623 if (valid_object ()) 2624 get_properties ().delete_listener (nm, v, mode); 2627 virtual void remove_all_listeners (void); 2629 virtual void reset_default_properties (void); 2632 virtual void initialize (const graphics_object& go) 2635 toolkit_flag = get_toolkit ().initialize (go); 2638 virtual void finalize (const graphics_object& go) 2642 get_toolkit ().finalize (go); 2643 toolkit_flag = false; 2647 virtual void update (const graphics_object& go, int id) 2650 get_toolkit ().update (go, id); 2655 // A flag telling whether this object is a valid object 2656 // in the backend context. 2660 class OCTINTERP_API graphics_object 2664 graphics_object (void) : rep (new base_graphics_object ()) { } 2666 graphics_object (base_graphics_object *new_rep) : rep (new_rep) { } 2668 graphics_object (const graphics_object&) = default; 2670 graphics_object& operator = (const graphics_object&) = default; 2672 ~graphics_object (void) = default; 2674 void mark_modified (void) { rep->mark_modified (); } 2676 void override_defaults (base_graphics_object& obj) 2678 rep->override_defaults (obj); 2681 void override_defaults (void) 2683 rep->override_defaults (*rep); 2686 void build_user_defaults_map (property_list::pval_map_type& def, 2687 const std::string go_name) const 2689 rep->build_user_defaults_map (def, go_name); 2692 void set_from_list (property_list& plist) { rep->set_from_list (plist); } 2694 void set (const caseless_str& name, const octave_value& val) 2696 rep->set (name, val); 2699 void set (const octave_value_list& args); 2701 void set (const Array<std::string>& names, const Cell& values, 2702 octave_idx_type row); 2704 void set (const octave_map& m); 2706 void set_value_or_default (const caseless_str& name, 2707 const octave_value& val); 2709 void set_defaults (const std::string& mode) { rep->set_defaults (mode); } 2711 octave_value get (bool all = false) const { return rep->get (all); } 2713 octave_value get (const caseless_str& name) const 2715 return name.compare ("default") 2717 : (name.compare ("factory
") 2718 ? get_factory_defaults () : rep->get (name)); 2721 octave_value get (const std::string& name) const 2723 return get (caseless_str (name)); 2726 octave_value get (const char *name) const 2728 return get (caseless_str (name)); 2731 octave_value get_default (const caseless_str& name) const 2733 return rep->get_default (name); 2736 octave_value get_factory_default (const caseless_str& name) const 2738 return rep->get_factory_default (name); 2741 octave_value get_defaults (void) const { return rep->get_defaults (); } 2743 property_list get_defaults_list (void) const 2745 return rep->get_defaults_list (); 2748 octave_value get_factory_defaults (void) const 2750 return rep->get_factory_defaults (); 2753 property_list get_factory_defaults_list (void) const 2755 return rep->get_factory_defaults_list (); 2758 bool has_readonly_property (const caseless_str& pname) const 2760 return rep->has_readonly_property (pname); 2763 std::string values_as_string (void) { return rep->values_as_string (); } 2765 std::string value_as_string (const std::string& prop) 2767 return rep->value_as_string (prop); 2770 octave_map values_as_struct (void) { return rep->values_as_struct (); } 2772 graphics_handle get_parent (void) const { return rep->get_parent (); } 2774 graphics_handle get_handle (void) const { return rep->get_handle (); } 2776 graphics_object get_ancestor (const std::string& type) const; 2778 void remove_child (const graphics_handle& h) { rep->remove_child (h); } 2780 void adopt (const graphics_handle& h) { rep->adopt (h); } 2782 void reparent (const graphics_handle& h) { rep->reparent (h); } 2784 void defaults (void) const { rep->defaults (); } 2786 bool isa (const std::string& go_name) const { return rep->isa (go_name); } 2788 base_properties& get_properties (void) { return rep->get_properties (); } 2790 const base_properties& get_properties (void) const 2792 return rep->get_properties (); 2795 void update_axis_limits (const std::string& axis_type) 2797 rep->update_axis_limits (axis_type); 2800 void update_axis_limits (const std::string& axis_type, 2801 const graphics_handle& h) 2803 rep->update_axis_limits (axis_type, h); 2806 bool valid_object (void) const { return rep->valid_object (); } 2808 std::string type (void) const { return rep->type (); } 2810 operator bool (void) const { return rep->valid_object (); } 2812 // FIXME: these functions should be generated automatically by the 2813 // genprops.awk script. 2815 // EMIT_GRAPHICS_OBJECT_GET_FUNCTIONS 2817 octave_value get_alim (void) const 2818 { return get_properties ().get_alim (); } 2820 octave_value get_clim (void) const 2821 { return get_properties ().get_clim (); } 2823 octave_value get_xlim (void) const 2824 { return get_properties ().get_xlim (); } 2826 octave_value get_ylim (void) const 2827 { return get_properties ().get_ylim (); } 2829 octave_value get_zlim (void) const 2830 { return get_properties ().get_zlim (); } 2832 bool is_aliminclude (void) const 2833 { return get_properties ().is_aliminclude (); } 2835 bool is_climinclude (void) const 2836 { return get_properties ().is_climinclude (); } 2838 bool is_xliminclude (void) const 2839 { return get_properties ().is_xliminclude (); } 2841 bool is_yliminclude (void) const 2842 { return get_properties ().is_yliminclude (); } 2844 bool is_zliminclude (void) const 2845 { return get_properties ().is_zliminclude (); } 2847 bool is_handle_visible (void) const 2848 { return get_properties ().is_handle_visible (); } 2850 graphics_toolkit get_toolkit (void) const { return rep->get_toolkit (); } 2852 void add_property_listener (const std::string& nm, const octave_value& v, 2853 listener_mode mode = POSTSET) 2854 { rep->add_property_listener (nm, v, mode); } 2856 void delete_property_listener (const std::string& nm, const octave_value& v, 2857 listener_mode mode = POSTSET) 2858 { rep->delete_property_listener (nm, v, mode); } 2860 void initialize (void) { rep->initialize (*this); } 2862 void finalize (void) { rep->finalize (*this); } 2864 void update (int id) { rep->update (*this, id); } 2866 void reset_default_properties (void) 2867 { rep->reset_default_properties (); } 2871 std::shared_ptr<base_graphics_object> rep; 2874 // --------------------------------------------------------------------- 2876 class OCTINTERP_API root_figure : public base_graphics_object 2880 // The gh_manager constructor creates the single instance of 2881 // the root_figure object. 2883 friend class gh_manager; 2885 class OCTINTERP_API properties : public base_properties 2888 void remove_child (const graphics_handle& h); 2890 Matrix get_boundingbox (bool internal = false, 2891 const Matrix& parent_pix_size = Matrix ()) const; 2893 // See the genprops.awk script for an explanation of the 2894 // properties declarations. 2896 // FIXME: Properties that still don't have callbacks are: 2897 // monitorpositions, pointerlocation, pointerwindow. 2898 // Note that these properties are not yet used by Octave, so setting 2899 // them will have no effect. 2901 // FIXME: The commandwindowsize property has been deprecated in Matlab 2902 // and is now available through matlab.desktop.comandwindow.size. 2903 // Until Octave has something similar, keep this property in root. 2905 // Programming note: Keep property list sorted if new ones are added. 2907 BEGIN_PROPERTIES (root_figure, root) 2908 handle_property callbackobject Sr , graphics_handle () 2909 array_property commandwindowsize r , Matrix (1, 2, 0) 2910 handle_property currentfigure S , graphics_handle () 2911 string_property fixedwidthfontname , "Courier
" 2912 array_property monitorpositions r , default_screensize () 2913 array_property pointerlocation , Matrix (1, 2, 0) 2914 double_property pointerwindow r , 0.0 2915 double_property screendepth r , default_screendepth () 2916 double_property screenpixelsperinch r , default_screenpixelsperinch () 2917 array_property screensize r , default_screensize () 2918 bool_property showhiddenhandles , "off
" 2919 radio_property units U , "inches|centimeters|normalized|points|{pixels}
" 2920 // Hide base properties which don't make sense for root object 2921 //radio_property beingdeleted h , "{off}|
on" 2925 std::list<graphics_handle> cbo_stack; 2931 properties xproperties; 2936 : xproperties (0, graphics_handle ()), default_properties (), 2937 factory_properties (init_factory_properties ()) 2942 ~root_figure (void) = default; 2944 root_figure (const root_figure&) = delete; 2946 root_figure& operator = (const root_figure&) = delete; 2948 void mark_modified (void) { } 2950 void override_defaults (base_graphics_object& obj) 2952 // Now override with our defaults. If the default_properties 2953 // list includes the properties for all defaults (line, 2954 // surface, etc.) then we don't have to know the type of OBJ 2955 // here, we just call its set function and let it decide which 2956 // properties from the list to use. 2957 obj.set_from_list (default_properties); 2960 void set (const caseless_str& name, const octave_value& value) 2962 if (name.compare ("default", 7)) 2963 // strip "default", pass rest to function that will 2964 // parse the remainder and add the element to the 2965 // default_properties map. 2966 default_properties.set (name.substr (7), value); 2968 xproperties.set (name, value); 2971 octave_value get (const caseless_str& name) const 2973 octave_value retval; 2975 if (name.compare ("default", 7)) 2976 return get_default (name.substr (7)); 2977 else if (name.compare ("factory
", 7)) 2978 return get_factory_default (name.substr (7)); 2980 retval = xproperties.get (name); 2985 octave_value get_default (const caseless_str& name) const 2987 octave_value retval = default_properties.lookup (name); 2989 if (retval.is_undefined ()) 2991 // no default property found, use factory default 2992 retval = factory_properties.lookup (name); 2994 if (retval.is_undefined ()) 2995 error ("get: invalid
default property '%s'", name.c_str ()); 3001 octave_value get_factory_default (const caseless_str& name) const 3003 octave_value retval = factory_properties.lookup (name); 3005 if (retval.is_undefined ()) 3006 error ("get: invalid factory
default property '%s'", name.c_str ()); 3011 octave_value get_defaults (void) const 3013 return default_properties.as_struct ("default"); 3016 property_list get_defaults_list (void) const 3018 return default_properties; 3021 octave_value get_factory_defaults (void) const 3023 return factory_properties.as_struct ("factory
"); 3026 property_list get_factory_defaults_list (void) const 3028 return factory_properties; 3031 base_properties& get_properties (void) { return xproperties; } 3033 const base_properties& get_properties (void) const { return xproperties; } 3035 bool valid_object (void) const { return true; } 3037 void reset_default_properties (void); 3039 bool has_readonly_property (const caseless_str& pname) const 3041 bool retval = xproperties.has_readonly_property (pname); 3043 retval = base_properties::has_readonly_property (pname); 3049 property_list default_properties; 3051 property_list factory_properties; 3053 static property_list::plist_map_type init_factory_properties (void); 3056 // --------------------------------------------------------------------- 3058 class OCTINTERP_API figure : public base_graphics_object 3061 class OCTINTERP_API properties : public base_properties 3064 void init_integerhandle (const octave_value& val) 3066 integerhandle = val; 3069 void remove_child (const graphics_handle& h); 3071 void set_visible (const octave_value& val); 3073 graphics_toolkit get_toolkit (void) const; 3075 void set_toolkit (const graphics_toolkit& b); 3077 void set___graphics_toolkit__ (const octave_value& val); 3079 void adopt (const graphics_handle& h); 3081 void set_position (const octave_value& val, 3082 bool do_notify_toolkit = true); 3084 void set_outerposition (const octave_value& val, 3085 bool do_notify_toolkit = true); 3087 Matrix get_boundingbox (bool internal = false, 3088 const Matrix& parent_pix_size = Matrix ()) const; 3090 void set_boundingbox (const Matrix& bb, bool internal = false, 3091 bool do_notify_toolkit = true); 3093 Matrix map_from_boundingbox (double x, double y) const; 3095 Matrix map_to_boundingbox (double x, double y) const; 3097 void update_units (const caseless_str& old_units); 3099 void update_paperunits (const caseless_str& old_paperunits); 3101 std::string get_title (void) const; 3103 // See the genprops.awk script for an explanation of the 3104 // properties declarations. 3106 // Programming note: Keep property list sorted if new ones are added. 3108 BEGIN_PROPERTIES (figure) 3109 array_property alphamap , Matrix (64, 1, 1) 3110 callback_property buttondownfcn , Matrix () 3111 callback_property closerequestfcn , "closereq
" 3112 color_property color , color_property (color_values (1, 1, 1), radio_values ("none
")) 3113 array_property colormap , viridis_colormap () 3114 handle_property currentaxes S , graphics_handle () 3115 string_property currentcharacter r , "" 3116 handle_property currentobject r , graphics_handle () 3117 array_property currentpoint r , Matrix (2, 1, 0) 3118 bool_property dockcontrols , "off
" 3119 string_property filename , "" 3120 bool_property graphicssmoothing , "on" 3121 bool_property integerhandle S , "on" 3122 bool_property inverthardcopy , "on" 3123 callback_property keypressfcn , Matrix () 3124 callback_property keyreleasefcn , Matrix () 3125 radio_property menubar , "{
figure}|none
" 3126 string_property name , "" 3127 // FIXME: Need RO property which returns current figure number. 3128 // double_property number r , 3129 radio_property nextplot , "{add}|
new|replace|replacechildren
" 3130 bool_property numbertitle , "on" 3131 array_property outerposition s , Matrix (1, 4, -1.0) 3132 radio_property paperorientation U , "{portrait}|landscape
" 3133 array_property paperposition m , default_figure_paperposition () 3134 // FIXME: Matlab default is "auto", but this messes up hgsave BIST test. 3135 radio_property paperpositionmode au , "auto|{manual}
" 3136 array_property papersize U , default_figure_papersize () 3138 radio_property paperunits Su , "{inches}|centimeters|normalized|points
" 3139 radio_property pointer , "crosshair|fullcrosshair|{arrow}|ibeam|watch|topl|topr|botl|botr|
left|top|
right|bottom|circle|
cross|fleur|custom|hand
" 3140 array_property pointershapecdata , Matrix (16, 16, 0) 3141 array_property pointershapehotspot , Matrix (1, 2, 0) 3142 array_property position s , default_figure_position () 3143 radio_property renderer m , "{opengl}|painters
" 3144 radio_property renderermode , "{
auto}|manual
" 3145 bool_property resize , "on" 3146 // FIXME: resizefcn has been deprecated by Matlab, and 3147 // replaced with sizechangedfcn 3148 // Eventually this will need to be hidden, and then removed. 3149 callback_property resizefcn , Matrix () 3150 radio_property selectiontype , "{normal}|extend|alt|open
" 3151 callback_property sizechangedfcn , Matrix () 3152 radio_property toolbar , "{
auto}|
figure|none
" 3153 radio_property units Su , "{pixels}|normalized|inches|centimeters|points|
characters" 3154 callback_property windowbuttondownfcn , Matrix () 3155 callback_property windowbuttonmotionfcn , Matrix () 3156 callback_property windowbuttonupfcn , Matrix () 3157 callback_property windowkeypressfcn , Matrix () 3158 callback_property windowkeyreleasefcn , Matrix () 3159 callback_property windowscrollwheelfcn , Matrix () 3160 radio_property windowstyle , "{normal}|modal|docked
" 3162 // Overridden base property 3163 // Property is not implemented for figures. 3164 // Hide it and set it to a default value that works. 3165 radio_property pickableparts h , "{visible}
" 3167 // Octave-specific properties 3168 mutable string_property __gl_extensions__ hr , "" 3169 mutable string_property __gl_renderer__ hr , "" 3170 mutable string_property __gl_vendor__ hr , "" 3171 mutable string_property __gl_version__ hr , "" 3172 bool_property __gl_window__ h , "off
" 3173 string_property __graphics_toolkit__ hs , default_graphics_toolkit () 3174 any_property __guidata__ h , Matrix () 3175 radio_property __mouse_mode__ hS , "{none}|pan|rotate|select|
text|zoom
" 3176 bool_property __printing__ h , "off
" 3177 any_property __pan_mode__ h , Matrix () 3178 any_property __plot_stream__ h , Matrix () 3179 any_property __rotate_mode__ h , Matrix () 3180 any_property __zoom_mode__ h , Matrix () 3182 // Obsolete properties: doublebuffer, mincolormap, wvisual, wvisualmode, 3183 // xdisplay, xvisual, xvisualmode 3184 // FIXME: DEPRECATED: Remove in version 5. 3185 bool_property doublebuffer hd , "on" 3186 double_property mincolormap hd , 64 3187 string_property wvisual hmd , "" 3188 radio_property wvisualmode hd , "{
auto}|manual
" 3189 string_property xdisplay hd , "" 3190 string_property xvisual hmd , "" 3191 radio_property xvisualmode hd , "{
auto}|manual
" 3197 alphamap.add_constraint (dim_vector (-1, 1)); 3198 colormap.add_constraint (dim_vector (-1, 3)); 3199 outerposition.add_constraint (dim_vector (1, 4)); 3200 outerposition.add_constraint (FINITE); 3201 paperposition.add_constraint (dim_vector (1, 4)); 3202 paperposition.add_constraint (FINITE); 3203 papersize.add_constraint (dim_vector (1, 2)); 3204 papersize.add_constraint (FINITE); 3205 pointershapecdata.add_constraint (dim_vector (16, 16)); 3206 pointershapehotspot.add_constraint (dim_vector (1, 2)); 3207 position.add_constraint (dim_vector (1, 4)); 3208 position.add_constraint (FINITE); 3212 Matrix get_auto_paperposition (void); 3214 void update_paperpositionmode (void) 3216 if (paperpositionmode.is ("auto")) 3217 paperposition.set (get_auto_paperposition ()); 3220 void update_handlevisibility (void); 3222 mutable graphics_toolkit toolkit; 3226 properties xproperties; 3229 figure (const graphics_handle& mh, const graphics_handle& p) 3230 : base_graphics_object (), xproperties (mh, p), default_properties () 3233 ~figure (void) = default; 3235 void override_defaults (base_graphics_object& obj) 3237 // Allow parent (root figure) to override first (properties knows how 3238 // to find the parent object). 3239 xproperties.override_defaults (obj); 3241 // Now override with our defaults. If the default_properties 3242 // list includes the properties for all defaults (line, 3243 // surface, etc.) then we don't have to know the type of OBJ 3244 // here, we just call its set function and let it decide which 3245 // properties from the list to use. 3246 obj.set_from_list (default_properties); 3249 void set (const caseless_str& name, const octave_value& value) 3251 if (name.compare ("default", 7)) 3252 // strip "default", pass rest to function that will 3253 // parse the remainder and add the element to the 3254 // default_properties map. 3255 default_properties.set (name.substr (7), value); 3257 xproperties.set (name, value); 3260 octave_value get (const caseless_str& name) const 3262 octave_value retval; 3264 if (name.compare ("default", 7)) 3265 retval = get_default (name.substr (7)); 3267 retval = xproperties.get (name); 3272 octave_value get_default (const caseless_str& name) const; 3274 octave_value get_defaults (void) const 3276 return default_properties.as_struct ("default"); 3279 property_list get_defaults_list (void) const 3281 return default_properties; 3284 base_properties& get_properties (void) { return xproperties; } 3286 const base_properties& get_properties (void) const { return xproperties; } 3288 bool valid_object (void) const { return true; } 3290 void reset_default_properties (void); 3292 bool has_readonly_property (const caseless_str& pname) const 3294 bool retval = xproperties.has_readonly_property (pname); 3296 retval = base_properties::has_readonly_property (pname); 3301 property_list default_properties; 3304 // --------------------------------------------------------------------- 3306 class OCTINTERP_API graphics_xform 3309 graphics_xform (void) 3310 : xform (xform_eye ()), xform_inv (xform_eye ()), 3311 sx ("linear
"), sy ("linear
"), sz ("linear
"), zlim (1, 2, 0.0) 3316 graphics_xform (const Matrix& xm, const Matrix& xim, 3317 const scaler& x, const scaler& y, const scaler& z, 3319 : xform (xm), xform_inv (xim), sx (x), sy (y), sz (z), zlim (zl) { } 3321 graphics_xform (const graphics_xform& g) 3322 : xform (g.xform), xform_inv (g.xform_inv), sx (g.sx), 3323 sy (g.sy), sz (g.sz), zlim (g.zlim) { } 3325 ~graphics_xform (void) = default; 3327 graphics_xform& operator = (const graphics_xform& g) 3330 xform_inv = g.xform_inv; 3339 static ColumnVector xform_vector (double x, double y, double z); 3341 static Matrix xform_eye (void); 3343 ColumnVector transform (double x, double y, double z, 3344 bool use_scale = true) const; 3346 ColumnVector untransform (double x, double y, double z, 3347 bool use_scale = true) const; 3349 ColumnVector untransform (double x, double y, bool use_scale = true) const 3350 { return untransform (x, y, (zlim(0)+zlim(1))/2, use_scale); } 3352 Matrix xscale (const Matrix& m) const { return sx.scale (m); } 3353 Matrix yscale (const Matrix& m) const { return sy.scale (m); } 3354 Matrix zscale (const Matrix& m) const { return sz.scale (m); } 3356 Matrix scale (const Matrix& m) const 3358 bool has_z = (m.columns () > 2); 3360 if (sx.is_linear () && sy.is_linear () 3361 && (! has_z || sz.is_linear ())) 3364 Matrix retval (m.dims ()); 3368 for (int i = 0; i < r; i++) 3370 retval(i,0) = sx.scale (m(i,0)); 3371 retval(i,1) = sy.scale (m(i,1)); 3373 retval(i,2) = sz.scale (m(i,2)); 3394 class OCTINTERP_API axes : public base_graphics_object 3397 class OCTINTERP_API properties : public base_properties 3400 void set_defaults (base_graphics_object& obj, const std::string& mode); 3402 void remove_child (const graphics_handle& h); 3404 const scaler& get_x_scaler (void) const { return sx; } 3405 const scaler& get_y_scaler (void) const { return sy; } 3406 const scaler& get_z_scaler (void) const { return sz; } 3408 Matrix get_boundingbox (bool internal = false, 3409 const Matrix& parent_pix_size = Matrix ()) const; 3410 Matrix get_extent (bool with_text = false, 3411 bool only_text_height=false) const; 3413 double get___fontsize_points__ (double box_pix_height = 0) const; 3415 void update_boundingbox (void) 3417 if (units_is ("normalized
")) 3420 base_properties::update_boundingbox (); 3424 void update_camera (void); 3425 void update_axes_layout (void); 3426 void update_aspectratios (void); 3427 void update_transform (void) 3429 update_aspectratios (); 3431 update_axes_layout (); 3434 void sync_positions (void); 3436 void update_autopos (const std::string& elem_type); 3437 void update_xlabel_position (void); 3438 void update_ylabel_position (void); 3439 void update_zlabel_position (void); 3440 void update_title_position (void); 3442 graphics_xform get_transform (void) const 3443 { return graphics_xform (x_render, x_render_inv, sx, sy, sz, x_zlim); } 3445 Matrix get_transform_matrix (void) const { return x_render; } 3446 Matrix get_inverse_transform_matrix (void) const { return x_render_inv; } 3447 Matrix get_opengl_matrix_1 (void) const { return x_gl_mat1; } 3448 Matrix get_opengl_matrix_2 (void) const { return x_gl_mat2; } 3449 Matrix get_transform_zlim (void) const { return x_zlim; } 3451 int get_xstate (void) const { return xstate; } 3452 int get_ystate (void) const { return ystate; } 3453 int get_zstate (void) const { return zstate; } 3454 double get_xPlane (void) const { return xPlane; } 3455 double get_xPlaneN (void) const { return xPlaneN; } 3456 double get_yPlane (void) const { return yPlane; } 3457 double get_yPlaneN (void) const { return yPlaneN; } 3458 double get_zPlane (void) const { return zPlane; } 3459 double get_zPlaneN (void) const { return zPlaneN; } 3460 double get_xpTick (void) const { return xpTick; } 3461 double get_xpTickN (void) const { return xpTickN; } 3462 double get_ypTick (void) const { return ypTick; } 3463 double get_ypTickN (void) const { return ypTickN; } 3464 double get_zpTick (void) const { return zpTick; } 3465 double get_zpTickN (void) const { return zpTickN; } 3466 double get_x_min (void) const { return std::min (xPlane, xPlaneN); } 3467 double get_x_max (void) const { return std::max (xPlane, xPlaneN); } 3468 double get_y_min (void) const { return std::min (yPlane, yPlaneN); } 3469 double get_y_max (void) const { return std::max (yPlane, yPlaneN); } 3470 double get_z_min (void) const { return std::min (zPlane, zPlaneN); } 3471 double get_z_max (void) const { return std::max (zPlane, zPlaneN); } 3472 double get_fx (void) const { return fx; } 3473 double get_fy (void) const { return fy; } 3474 double get_fz (void) const { return fz; } 3475 double get_xticklen (void) const { return xticklen; } 3476 double get_yticklen (void) const { return yticklen; } 3477 double get_zticklen (void) const { return zticklen; } 3478 double get_xtickoffset (void) const { return xtickoffset; } 3479 double get_ytickoffset (void) const { return ytickoffset; } 3480 double get_ztickoffset (void) const { return ztickoffset; } 3481 bool get_x2Dtop (void) const { return x2Dtop; } 3482 bool get_y2Dright (void) const { return y2Dright; } 3483 bool get_layer2Dtop (void) const { return layer2Dtop; } 3484 bool get_is2D (bool include_kids = false) const 3485 { return (include_kids ? (is2D && ! has3Dkids) : is2D); } 3486 void set_has3Dkids (bool val) { has3Dkids = val; } 3487 bool get_xySym (void) const { return xySym; } 3488 bool get_xyzSym (void) const { return xyzSym; } 3489 bool get_zSign (void) const { return zSign; } 3490 bool get_nearhoriz (void) const { return nearhoriz; } 3492 ColumnVector pixel2coord (double px, double py) const 3493 { return get_transform ().untransform (px, py, (x_zlim(0)+x_zlim(1))/2); } 3495 ColumnVector coord2pixel (double x, double y, double z) const 3496 { return get_transform ().transform (x, y, z); } 3498 void zoom_about_point (const std::string& mode, double x, double y, 3499 double factor, bool push_to_zoom_stack = true); 3500 void zoom (const std::string& mode, double factor, 3501 bool push_to_zoom_stack = true); 3502 void zoom (const std::string& mode, const Matrix& xl, const Matrix& yl, 3503 bool push_to_zoom_stack = true); 3505 void translate_view (const std::string& mode, 3506 double x0, double x1, double y0, double y1, 3507 bool push_to_zoom_stack = true); 3509 void pan (const std::string& mode, double factor, 3510 bool push_to_zoom_stack = true); 3512 void rotate3d (double x0, double x1, double y0, double y1, 3513 bool push_to_zoom_stack = true); 3515 void rotate_view (double delta_az, double delta_el, 3516 bool push_to_zoom_stack = true); 3519 void update_handlevisibility (void); 3520 void push_zoom_stack (void); 3521 void clear_zoom_stack (bool do_unzoom = true); 3523 void update_units (const caseless_str& old_units); 3525 void update_fontunits (const caseless_str& old_fontunits); 3529 scaler sx = scaler (); 3530 scaler sy = scaler (); 3531 scaler sz = scaler (); 3533 Matrix x_render = Matrix (); 3534 Matrix x_render_inv = Matrix (); 3535 Matrix x_gl_mat1 = Matrix (); 3536 Matrix x_gl_mat2 = Matrix (); 3537 Matrix x_zlim = Matrix (); 3539 std::list<octave_value> zoom_stack = std::list<octave_value> (); 3546 double xPlane = 0.0; 3547 double yPlane = 0.0; 3548 double zPlane = 0.0; 3550 double xPlaneN = 0.0; 3551 double yPlaneN = 0.0; 3552 double zPlaneN = 0.0; 3554 double xpTick = 0.0; 3555 double ypTick = 0.0; 3556 double zpTick = 0.0; 3558 double xpTickN = 0.0; 3559 double ypTickN = 0.0; 3560 double zpTickN = 0.0; 3566 double xticklen = 0.0; 3567 double yticklen = 0.0; 3568 double zticklen = 0.0; 3570 double xtickoffset = 0.0; 3571 double ytickoffset = 0.0; 3572 double ztickoffset = 0.0; 3574 bool x2Dtop = false; 3575 bool y2Dright = false; 3576 bool layer2Dtop = false; 3578 bool has3Dkids = false; 3580 bool xyzSym = false; 3582 bool nearhoriz = false; 3584 // Text renderer, used for calculation of text (tick labels) size 3585 octave::text_renderer txt_renderer; 3587 void set_text_child (handle_property& h, const std::string& who, 3588 const octave_value& v); 3590 void delete_text_child (handle_property& h); 3592 // See the genprops.awk script for an explanation of the 3593 // properties declarations. 3595 // Programming note: Keep property list sorted if new ones are added. 3597 BEGIN_PROPERTIES (axes) 3598 radio_property activepositionproperty , "{outerposition}|position
" 3599 row_vector_property alim m , default_lim () 3600 radio_property alimmode , "{
auto}|manual
" 3601 color_property ambientlightcolor , color_values (1, 1, 1) 3602 bool_property box u , "off
" 3603 radio_property boxstyle , "{back}|full
" 3604 row_vector_property cameraposition mu , Matrix (1, 3, 0.0) 3605 radio_property camerapositionmode u , "{
auto}|manual
" 3606 row_vector_property cameratarget mu , Matrix (1, 3, 0.0) 3607 radio_property cameratargetmode u , "{
auto}|manual
" 3608 row_vector_property cameraupvector mu , Matrix (1, 3, 0.0) 3609 radio_property cameraupvectormode u , "{
auto}|manual
" 3610 double_property cameraviewangle mu , 6.6086 3611 radio_property cameraviewanglemode u , "{
auto}|manual
" 3612 row_vector_property clim m , default_lim () 3613 radio_property climmode al , "{
auto}|manual
" 3614 radio_property clippingstyle , "{3dbox}|rectangle
" 3615 color_property color , color_property (color_values (1, 1, 1), radio_values ("none
")) 3616 array_property colormap sg , Matrix () 3617 array_property colororder , default_colororder () 3618 double_property colororderindex , 1.0 3619 array_property currentpoint , Matrix (2, 3, 0.0) 3620 row_vector_property dataaspectratio mu , Matrix (1, 3, 1.0) 3621 radio_property dataaspectratiomode u , "{
auto}|manual
" 3622 radio_property drawmode hd , "{normal}|fast
" 3623 radio_property fontangle u , "{normal}|italic
" 3624 string_property fontname u , OCTAVE_DEFAULT_FONTNAME 3625 double_property fontsize u , 10 3626 radio_property fontunits SU , "{points}|inches|centimeters|normalized|pixels
" 3627 bool_property fontsmoothing , "on" 3628 radio_property fontweight u , "{normal}|bold
" 3629 double_property gridalpha m , 0.15 3630 radio_property gridalphamode , "{
auto}|manual
" 3631 color_property gridcolor , color_property (color_values (0.15, 0.15, 0.15), radio_values ("none
")) 3632 radio_property gridcolormode , "{
auto}|manual
" 3633 radio_property gridlinestyle , "{-}|--|:|-.|none
" 3634 double_property labelfontsizemultiplier u , 1.1 3635 radio_property layer u , "{bottom}|top
" 3636 // FIXME: should be kind of string array. 3637 any_property linestyleorder S , "-
" 3638 double_property linestyleorderindex , 1.0 3639 double_property linewidth , 0.5 3640 double_property minorgridalpha m , 0.25 3641 radio_property minorgridalphamode , "{
auto}|manual
" 3642 color_property minorgridcolor m , color_property (color_values (0.1, 0.1, 0.1), radio_values ("none
")) 3643 radio_property minorgridcolormode , "{
auto}|manual
" 3644 radio_property minorgridlinestyle , "{:}|-|--|-.|none
" 3645 radio_property nextplot , "{replace}|add|replacechildren
" 3646 array_property outerposition u , default_axes_outerposition () 3647 row_vector_property plotboxaspectratio mu , Matrix (1, 3, 1.0) 3648 radio_property plotboxaspectratiomode u , "{
auto}|manual
" 3649 array_property position u , default_axes_position () 3650 radio_property projection , "{orthographic}|perspective
" 3651 radio_property sortmethod , "{depth}|childorder
" 3652 radio_property tickdir mu , "{in}|out
" 3653 radio_property tickdirmode u , "{
auto}|manual
" 3654 // FIXME: Added recently to Matlab, should replace interpreter property. 3655 radio_property ticklabelinterpreter , "{tex}|latex|none
" 3656 array_property ticklength u , default_axes_ticklength () 3657 array_property tightinset r , Matrix (1, 4, 0.0) 3658 handle_property title SOf , gh_manager::make_graphics_handle ("text", __myhandle__, false, false, false) 3659 double_property titlefontsizemultiplier u , 1.1 3660 radio_property titlefontweight u , "{bold}|normal
" 3661 // FIXME: uicontextmenu should be moved here. 3662 radio_property units SU , "{normalized}|inches|centimeters|points|pixels|
characters" 3663 array_property view u , default_axes_view () 3664 // FIXME: DEPRECATED: Remove "zero" in version 5. 3665 radio_property xaxislocation u , "{bottom}|top|origin|
zero" 3666 color_property xcolor mu , color_values (0.15, 0.15, 0.15) 3667 radio_property xcolormode , "{
auto}|manual
" 3668 radio_property xdir u , "{normal}|reverse
" 3669 bool_property xgrid , "off
" 3670 handle_property xlabel SOf , gh_manager::make_graphics_handle ("text", __myhandle__, false, false, false) 3671 row_vector_property xlim mu , default_lim () 3672 radio_property xlimmode al , "{
auto}|manual
" 3673 bool_property xminorgrid , "off
" 3674 bool_property xminortick , "off
" 3675 radio_property xscale alu , "{linear}|
log" 3676 row_vector_property xtick mu , default_axes_tick () 3677 // FIXME: should be kind of string array. 3678 any_property xticklabel S , "" 3679 radio_property xticklabelmode u , "{
auto}|manual
" 3680 double_property xticklabelrotation , 0.0 3681 radio_property xtickmode u , "{
auto}|manual
" 3682 // FIXME: DEPRECATED: Remove "zero" in version 5. 3684 color_property ycolor mu , color_values (0.15, 0.15, 0.15) 3685 radio_property ycolormode , "{
auto}|manual
" 3686 radio_property ydir u , "{normal}|reverse
" 3687 bool_property ygrid , "off
" 3688 handle_property ylabel SOf , gh_manager::make_graphics_handle ("text", __myhandle__, false, false, false) 3689 row_vector_property ylim mu , default_lim () 3690 radio_property ylimmode al , "{
auto}|manual
" 3691 bool_property yminorgrid , "off
" 3692 bool_property yminortick , "off
" 3693 radio_property yscale alu , "{linear}|
log" 3694 row_vector_property ytick mu , default_axes_tick () 3695 any_property yticklabel S , "" 3696 radio_property yticklabelmode u , "{
auto}|manual
" 3697 double_property yticklabelrotation , 0.0 3698 radio_property ytickmode u , "{
auto}|manual
" 3699 color_property zcolor mu , color_values (0.15, 0.15, 0.15) 3700 radio_property zcolormode , "{
auto}|manual
" 3701 radio_property zdir u , "{normal}|reverse
" 3702 bool_property zgrid , "off
" 3703 handle_property zlabel SOf , gh_manager::make_graphics_handle ("text", __myhandle__, false, false, false) 3704 row_vector_property zlim mu , default_lim () 3705 radio_property zlimmode al , "{
auto}|manual
" 3706 bool_property zminorgrid , "off
" 3707 bool_property zminortick , "off
" 3708 radio_property zscale alu , "{linear}|
log" 3709 row_vector_property ztick mu , default_axes_tick () 3710 any_property zticklabel S , "" 3711 radio_property zticklabelmode u , "{
auto}|manual
" 3712 double_property zticklabelrotation , 0.0 3713 radio_property ztickmode u , "{
auto}|manual
" 3715 // Octave-specific properties 3716 array_property __colormap__ hu , Matrix () 3717 double_property mousewheelzoom , 0.5 3719 // hidden properties for alignment of subplots 3720 radio_property __autopos_tag__ h , "{none}|subplot
" 3721 // hidden properties for inset 3722 array_property looseinset hu , Matrix (1, 4, 0.0) 3723 // hidden properties for minor ticks 3724 row_vector_property xminortickvalues h , Matrix () 3725 row_vector_property yminortickvalues h , Matrix () 3726 row_vector_property zminortickvalues h , Matrix () 3727 // hidden property for text rendering 3728 double_property __fontsize_points__ hgr , 0 3737 get_scale (const std::string& scale, const Matrix& lims) 3739 std::string retval = scale; 3741 if (scale == "log" && lims.numel () > 1 && lims(0) < 0 && lims(1) < 0) 3747 void update_xscale (void) 3749 sx = get_scale (get_xscale (), xlim.get ().matrix_value ()); 3752 void update_yscale (void) 3754 sy = get_scale (get_yscale (), ylim.get ().matrix_value ()); 3757 void update_zscale (void) 3759 sz = get_scale (get_zscale (), zlim.get ().matrix_value ()); 3762 void update_label_color (handle_property label, color_property col); 3763 void update_xcolor (void) 3764 { update_label_color (xlabel, xcolor); } 3766 void update_ycolor (void) 3767 { update_label_color (ylabel, ycolor); } 3769 void update_zcolor (void) 3770 { update_label_color (zlabel, zcolor); } 3772 void update_view (void) { sync_positions (); } 3774 void update_cameraposition (void) { update_transform (); } 3775 void update_cameratarget (void) { update_transform (); } 3776 void update_cameraupvector (void) { update_transform (); } 3777 void update_cameraviewangle (void) { update_transform (); } 3779 void update_camerapositionmode (void) 3781 if (camerapositionmode_is ("auto")) 3782 update_cameraposition (); 3784 void update_cameratargetmode (void) 3786 if (cameratargetmode_is ("auto")) 3787 update_cameratarget (); 3789 void update_cameraupvectormode (void) 3791 if (cameraupvectormode_is ("auto")) 3792 update_cameraupvector (); 3794 void update_cameraviewanglemode (void) 3796 if (cameraviewanglemode_is ("auto")) 3797 update_cameraviewangle (); 3800 void update_dataaspectratio (void) { sync_positions (); } 3801 void update_dataaspectratiomode (void) { sync_positions (); } 3802 void update_plotboxaspectratio (void) { sync_positions (); } 3803 void update_plotboxaspectratiomode (void) { sync_positions (); } 3805 void update_layer (void) { update_axes_layout (); } 3806 void update_box (void) 3808 if (xticklabelmode.is ("auto")) 3809 calc_ticklabels (xtick, xticklabel, xscale.is ("log"), 3810 xaxislocation_is ("origin
"), 3811 yscale.is ("log") ? 2 : 3812 (yaxislocation_is ("origin
") ? 0 : 3813 (yaxislocation_is ("left") ? -1 : 1)), 3815 if (yticklabelmode.is ("auto")) 3816 calc_ticklabels (ytick, yticklabel, yscale.is ("log"), 3817 yaxislocation_is ("origin
"), 3818 xscale.is ("log") ? 2 : 3819 (xaxislocation_is ("origin
") ? 0 : 3820 (xaxislocation_is ("bottom
") ? -1 : 1)), 3823 void update_yaxislocation (void) 3825 // FIXME: DEPRECATED: Remove warning with "zero" in version 5. 3826 if (yaxislocation_is ("zero")) 3827 warning_with_id ("Octave:deprecated-
property", 3828 "Setting
'yaxislocation' to
'zero' is deprecated,
" 3831 update_axes_layout (); 3832 if (xticklabelmode.is ("auto
")) 3833 calc_ticklabels (xtick, xticklabel, xscale.is ("log"), 3834 xaxislocation_is ("origin
"), 3835 yscale.is ("log") ? 2 : 3836 (yaxislocation_is ("origin
") ? 0 : 3837 (yaxislocation_is ("left") ? -1 : 1)), 3839 if (yticklabelmode.is ("auto")) 3840 calc_ticklabels (ytick, yticklabel, yscale.is ("log"), 3841 yaxislocation_is ("origin
"), 3842 xscale.is ("log") ? 2 : 3843 (xaxislocation_is ("origin
") ? 0 : 3844 (xaxislocation_is ("bottom
") ? -1 : 1)), 3846 update_ylabel_position (); 3848 void update_xaxislocation (void) 3850 // FIXME: DEPRECATED: Remove warning with "zero" in version 5. 3851 if (xaxislocation_is ("zero")) 3852 warning_with_id ("Octave:deprecated-
property", 3853 "Setting
'xaxislocation' to
'zero' is deprecated,
" 3856 update_axes_layout (); 3857 if (xticklabelmode.is ("auto
")) 3858 calc_ticklabels (xtick, xticklabel, xscale.is ("log"), 3859 xaxislocation_is ("origin
"), 3860 yscale.is ("log") ? 2 : 3861 (yaxislocation_is ("origin
") ? 0 : 3862 (yaxislocation_is ("left") ? -1 : 1)), 3864 if (yticklabelmode.is ("auto")) 3865 calc_ticklabels (ytick, yticklabel, yscale.is ("log"), 3866 yaxislocation_is ("origin
"), 3867 xscale.is ("log") ? 2 : 3868 (xaxislocation_is ("origin
") ? 0 : 3869 (xaxislocation_is ("bottom
") ? -1 : 1)), 3871 update_xlabel_position (); 3874 void update_xdir (void) { update_camera (); update_axes_layout (); } 3875 void update_ydir (void) { update_camera (); update_axes_layout (); } 3876 void update_zdir (void) { update_camera (); update_axes_layout (); } 3878 void update_ticklength (void); 3879 void update_tickdir (void) { update_ticklength (); } 3880 void update_tickdirmode (void) { update_ticklength (); } 3882 void update_xtick (void) 3884 calc_ticks_and_lims (xlim, xtick, xminortickvalues, xlimmode.is ("auto"), 3885 xtickmode.is ("auto"), xscale.is ("log")); 3886 if (xticklabelmode.is ("auto")) 3887 calc_ticklabels (xtick, xticklabel, xscale.is ("log"), 3888 xaxislocation_is ("origin
"), 3889 yscale.is ("log") ? 2 : 3890 (yaxislocation_is ("origin
") ? 0 : 3891 (yaxislocation_is ("left") ? -1 : 1)), 3895 void update_ytick (void) 3897 calc_ticks_and_lims (ylim, ytick, yminortickvalues, ylimmode.is ("auto"), 3898 ytickmode.is ("auto"), yscale.is ("log")); 3899 if (yticklabelmode.is ("auto")) 3900 calc_ticklabels (ytick, yticklabel, yscale.is ("log"), 3901 yaxislocation_is ("origin
"), 3902 xscale.is ("log") ? 2 : 3903 (xaxislocation_is ("origin
") ? 0 : 3904 (xaxislocation_is ("bottom
") ? -1 : 1)), 3908 void update_ztick (void) 3910 calc_ticks_and_lims (zlim, ztick, zminortickvalues, zlimmode.is ("auto"), 3911 ztickmode.is ("auto"), zscale.is ("log")); 3912 if (zticklabelmode.is ("auto")) 3913 calc_ticklabels (ztick, zticklabel, zscale.is ("log"), false, 2, zlim); 3917 void update_xtickmode (void) 3919 if (xtickmode.is ("auto")) 3922 void update_ytickmode (void) 3924 if (ytickmode.is ("auto")) 3927 void update_ztickmode (void) 3929 if (ztickmode.is ("auto")) 3933 void update_xticklabelmode (void) 3935 if (xticklabelmode.is ("auto")) 3936 calc_ticklabels (xtick, xticklabel, xscale.is ("log"), 3937 xaxislocation_is ("origin
"), 3938 yscale.is ("log") ? 2 : 3939 (yaxislocation_is ("origin
") ? 0 : 3940 (yaxislocation_is ("left") ? -1 : 1)), 3943 void update_yticklabelmode (void) 3945 if (yticklabelmode.is ("auto")) 3946 calc_ticklabels (ytick, yticklabel, yscale.is ("log"), 3947 yaxislocation_is ("origin
"), 3948 xscale.is ("log") ? 2 : 3949 (xaxislocation_is ("origin
") ? 0 : 3950 (xaxislocation_is ("bottom
") ? -1 : 1)), 3953 void update_zticklabelmode (void) 3955 if (zticklabelmode.is ("auto")) 3956 calc_ticklabels (ztick, zticklabel, zscale.is ("log"), false, 2, zlim); 3959 void update_font (std::string prop = ""); 3960 void update_fontname (void) 3962 update_font ("fontname
"); 3965 void update_fontsize (void) 3967 update_font ("fontsize
"); 3970 void update_fontangle (void) 3972 update_font ("fontangle
"); 3975 void update_fontweight (void) 3977 update_font ("fontweight
"); 3981 void update_titlefontsizemultiplier (void) 3983 update_font ("fontsize
"); 3987 void update_labelfontsizemultiplier (void) 3989 update_font ("fontsize
"); 3993 void update_titlefontweight (void) 3995 update_font ("fontweight
"); 3999 void update_outerposition (void) 4001 set_activepositionproperty ("outerposition
"); 4002 caseless_str old_units = get_units (); 4003 set_units ("normalized
"); 4004 Matrix outerbox = outerposition.get ().matrix_value (); 4005 Matrix innerbox = position.get ().matrix_value (); 4006 Matrix linset = looseinset.get ().matrix_value (); 4007 Matrix tinset = tightinset.get ().matrix_value (); 4008 outerbox(2) = outerbox(2) + outerbox(0); 4009 outerbox(3) = outerbox(3) + outerbox(1); 4010 innerbox(0) = outerbox(0) + std::max (linset(0), tinset(0)); 4011 innerbox(1) = outerbox(1) + std::max (linset(1), tinset(1)); 4012 innerbox(2) = outerbox(2) - std::max (linset(2), tinset(2)); 4013 innerbox(3) = outerbox(3) - std::max (linset(3), tinset(3)); 4014 innerbox(2) = innerbox(2) - innerbox(0); 4015 innerbox(3) = innerbox(3) - innerbox(1); 4016 position = innerbox; 4017 set_units (old_units); 4018 update_transform (); 4021 void update_position (void) 4023 set_activepositionproperty ("position
"); 4024 caseless_str old_units = get_units (); 4025 set_units ("normalized
"); 4026 Matrix outerbox = outerposition.get ().matrix_value (); 4027 Matrix innerbox = position.get ().matrix_value (); 4028 Matrix linset = looseinset.get ().matrix_value (); 4029 Matrix tinset = tightinset.get ().matrix_value (); 4030 innerbox(2) = innerbox(2) + innerbox(0); 4031 innerbox(3) = innerbox(3) + innerbox(1); 4032 outerbox(0) = innerbox(0) - std::max (linset(0), tinset(0)); 4033 outerbox(1) = innerbox(1) - std::max (linset(1), tinset(1)); 4034 outerbox(2) = innerbox(2) + std::max (linset(2), tinset(2)); 4035 outerbox(3) = innerbox(3) + std::max (linset(3), tinset(3)); 4036 outerbox(2) = outerbox(2) - outerbox(0); 4037 outerbox(3) = outerbox(3) - outerbox(1); 4038 outerposition = outerbox; 4039 set_units (old_units); 4040 update_transform (); 4043 void update_looseinset (void) 4045 caseless_str old_units = get_units (); 4046 set_units ("normalized
"); 4047 Matrix innerbox = position.get ().matrix_value (); 4048 innerbox(2) = innerbox(2) + innerbox(0); 4049 innerbox(3) = innerbox(3) + innerbox(1); 4050 Matrix outerbox = outerposition.get ().matrix_value (); 4051 outerbox(2) = outerbox(2) + outerbox(0); 4052 outerbox(3) = outerbox(3) + outerbox(1); 4053 Matrix linset = looseinset.get ().matrix_value (); 4054 Matrix tinset = tightinset.get ().matrix_value (); 4055 if (activepositionproperty.is ("position
")) 4057 outerbox(0) = innerbox(0) - std::max (linset(0), tinset(0)); 4058 outerbox(1) = innerbox(1) - std::max (linset(1), tinset(1)); 4059 outerbox(2) = innerbox(2) + std::max (linset(2), tinset(2)); 4060 outerbox(3) = innerbox(3) + std::max (linset(3), tinset(3)); 4061 outerbox(2) = outerbox(2) - outerbox(0); 4062 outerbox(3) = outerbox(3) - outerbox(1); 4063 outerposition = outerbox; 4067 innerbox(0) = outerbox(0) + std::max (linset(0), tinset(0)); 4068 innerbox(1) = outerbox(1) + std::max (linset(1), tinset(1)); 4069 innerbox(2) = outerbox(2) - std::max (linset(2), tinset(2)); 4070 innerbox(3) = outerbox(3) - std::max (linset(3), tinset(3)); 4071 innerbox(2) = innerbox(2) - innerbox(0); 4072 innerbox(3) = innerbox(3) - innerbox(1); 4073 position = innerbox; 4075 set_units (old_units); 4076 update_transform (); 4079 double calc_tick_sep (double minval, double maxval); 4080 void calc_ticks_and_lims (array_property& lims, array_property& ticks, 4081 array_property& mticks, bool limmode_is_auto, 4082 bool tickmode_is_auto, bool is_logscale); 4083 void calc_ticklabels (const array_property& ticks, any_property& labels, 4084 bool is_logscale, const bool is_origin, 4085 const int other_axislocation, 4086 const array_property& axis_lims); 4087 Matrix get_ticklabel_extents (const Matrix& ticks, 4088 const string_vector& ticklabels, 4089 const Matrix& limits); 4091 void fix_limits (array_property& lims) 4093 if (lims.get ().isempty ()) 4096 Matrix l = lims.get ().matrix_value (); 4103 else if (l(0) == l(1)) 4111 Matrix calc_tightbox (const Matrix& init_pos); 4113 void set_colormap (const octave_value& val) 4115 set___colormap__ (val); 4118 void update___colormap__ (void) 4120 colormap.run_listeners (POSTSET); 4123 octave_value get_colormap (void) const; 4126 Matrix get_axis_limits (double xmin, double xmax, 4127 double min_pos, double max_neg, 4128 const bool logscale); 4130 void check_axis_limits (Matrix &limits, const Matrix kids, 4131 const bool logscale, char &update_type); 4135 update_axis_limits ("xlim
"); 4137 calc_ticks_and_lims (xlim, xtick, xminortickvalues, xlimmode.is ("auto"), 4138 xtickmode.is ("auto"), xscale.is ("log")); 4139 if (xticklabelmode.is ("auto")) 4140 calc_ticklabels (xtick, xticklabel, xscale.is ("log"), 4141 xaxislocation.is ("origin
"), 4142 yscale.is ("log") ? 2 : 4143 (yaxislocation_is ("origin
") ? 0 : 4144 (yaxislocation_is ("left") ? -1 : 1)), 4151 update_axes_layout (); 4154 void update_ylim (void) 4156 update_axis_limits ("ylim
"); 4158 calc_ticks_and_lims (ylim, ytick, yminortickvalues, ylimmode.is ("auto"), 4159 ytickmode.is ("auto"), yscale.is ("log")); 4160 if (yticklabelmode.is ("auto")) 4161 calc_ticklabels (ytick, yticklabel, yscale.is ("log"), 4162 yaxislocation_is ("origin
"), 4163 xscale.is ("log") ? 2 : 4164 (xaxislocation_is ("origin
") ? 0 : 4165 (xaxislocation_is ("bottom
") ? -1 : 1)), 4172 update_axes_layout (); 4175 void update_zlim (void) 4177 update_axis_limits ("zlim
"); 4179 calc_ticks_and_lims (zlim, ztick, zminortickvalues, zlimmode.is ("auto"), 4180 ztickmode.is ("auto"), zscale.is ("log")); 4181 if (zticklabelmode.is ("auto")) 4182 calc_ticklabels (ztick, zticklabel, zscale.is ("log"), false, 2, zlim); 4188 update_axes_layout (); 4194 properties xproperties; 4197 axes (const graphics_handle& mh, const graphics_handle& p) 4198 : base_graphics_object (), xproperties (mh, p), default_properties () 4200 xproperties.update_transform (); 4203 ~axes (void) = default; 4205 void override_defaults (base_graphics_object& obj) 4207 // Allow parent (figure) to override first (properties knows how 4208 // to find the parent object). 4209 xproperties.override_defaults (obj); 4211 // Now override with our defaults. If the default_properties 4212 // list includes the properties for all defaults (line, 4213 // surface, etc.) then we don't have to know the type of OBJ 4214 // here, we just call its set function and let it decide which 4215 // properties from the list to use. 4216 obj.set_from_list (default_properties); 4219 void set (const caseless_str& name, const octave_value& value) 4221 if (name.compare ("default", 7)) 4222 // strip "default", pass rest to function that will 4223 // parse the remainder and add the element to the 4224 // default_properties map. 4225 default_properties.set (name.substr (7), value); 4227 xproperties.set (name, value); 4230 void set_defaults (const std::string& mode) 4232 xproperties.set_defaults (*this, mode); 4235 octave_value get (const caseless_str& name) const 4237 octave_value retval; 4239 // FIXME: finish this. 4240 if (name.compare ("default", 7)) 4241 retval = get_default (name.substr (7)); 4243 retval = xproperties.get (name); 4248 octave_value get_default (const caseless_str& name) const; 4250 octave_value get_defaults (void) const 4252 return default_properties.as_struct ("default"); 4255 property_list get_defaults_list (void) const 4257 return default_properties; 4260 base_properties& get_properties (void) { return xproperties; } 4262 const base_properties& get_properties (void) const { return xproperties; } 4264 void update_axis_limits (const std::string& axis_type); 4266 void update_axis_limits (const std::string& axis_type, 4267 const graphics_handle& h); 4269 bool valid_object (void) const { return true; } 4271 void reset_default_properties (void); 4273 bool has_readonly_property (const caseless_str& pname) const 4275 bool retval = xproperties.has_readonly_property (pname); 4277 retval = base_properties::has_readonly_property (pname); 4282 void initialize (const graphics_object& go); 4285 property_list default_properties; 4288 // --------------------------------------------------------------------- 4290 class OCTINTERP_API line : public base_graphics_object 4293 class OCTINTERP_API properties : public base_properties 4296 // See the genprops.awk script for an explanation of the 4297 // properties declarations. 4298 // Programming note: Keep property list sorted if new ones are added. 4300 BEGIN_PROPERTIES (line) 4301 color_property color , color_property (color_values (0, 0, 0), radio_values ("none
")) 4302 string_property displayname , "" 4303 // FIXME: DEPRECATED: Remove erasemode property in version 5 4304 // (rm all instances in file). 4305 radio_property erasemode h , "{normal}|none|xor|background
" 4306 // FIXME: DEPRECATED: Remove interpreter property in version 6. 4307 radio_property interpreter hd , "{tex}|none|latex
" 4308 radio_property linejoin , "{
round}|miter|chamfer
" 4309 radio_property linestyle , "{-}|--|:|-.|none
" 4310 double_property linewidth , 0.5 4311 radio_property marker , "{none}|+|o|*|.|
x|
s|square|
d|diamond|^|v|>|<|
p|pentagram|
h|hexagram
" 4312 color_property markeredgecolor , color_property (radio_values ("{
auto}|none
"), color_values (0, 0, 0)) 4313 color_property markerfacecolor , color_property (radio_values ("auto|{none}
"), color_values (0, 0, 0)) 4314 double_property markersize , 6 4315 row_vector_property xdata u , default_data () 4316 string_property xdatasource , "" 4317 row_vector_property ydata u , default_data () 4318 string_property ydatasource , "" 4319 row_vector_property zdata u , Matrix () 4320 string_property zdatasource , "" 4322 // hidden properties for limit computation 4323 row_vector_property xlim hlr , Matrix () 4324 row_vector_property ylim hlr , Matrix () 4325 row_vector_property zlim hlr , Matrix () 4326 bool_property xliminclude hl , "on" 4327 bool_property yliminclude hl , "on" 4328 bool_property zliminclude hl , "off
" 4334 linewidth.add_constraint ("min", 0, false); 4335 markersize.add_constraint ("min", 0, false); 4339 Matrix compute_xlim (void) const; 4340 Matrix compute_ylim (void) const; 4342 void update_xdata (void) { set_xlim (compute_xlim ()); } 4344 void update_ydata (void) { set_ylim (compute_ylim ()); } 4346 void update_zdata (void) 4348 set_zlim (zdata.get_limits ()); 4349 set_zliminclude (get_zdata ().numel () > 0); 4354 properties xproperties; 4357 line (const graphics_handle& mh, const graphics_handle& p) 4358 : base_graphics_object (), xproperties (mh, p) 4361 ~line (void) = default; 4363 base_properties& get_properties (void) { return xproperties; } 4365 const base_properties& get_properties (void) const { return xproperties; } 4367 bool valid_object (void) const { return true; } 4369 bool has_readonly_property (const caseless_str& pname) const 4371 bool retval = xproperties.has_readonly_property (pname); 4373 retval = base_properties::has_readonly_property (pname); 4378 // --------------------------------------------------------------------- 4380 class OCTINTERP_API text : public base_graphics_object 4383 class OCTINTERP_API properties : public base_properties 4386 double get___fontsize_points__ (double box_pix_height = 0) const; 4388 void set_position (const octave_value& val) 4390 octave_value new_val (val); 4392 if (new_val.numel () == 2) 4394 dim_vector dv (1, 3); 4396 new_val = new_val.resize (dv, true); 4399 if (position.set (new_val, false)) 4401 set_positionmode ("manual
"); 4403 position.run_listeners (POSTSET); 4407 set_positionmode ("manual
"); 4410 // See the genprops.awk script for an explanation of the 4411 // properties declarations. 4413 BEGIN_PROPERTIES (text) 4414 color_property backgroundcolor , color_property (radio_values ("{none}
"), color_values (1, 1, 1)) 4415 color_property color u , color_values (0, 0, 0) 4416 color_property edgecolor , color_property (radio_values ("{none}
"), color_values (0, 0, 0)) 4417 bool_property editing , "off
" 4418 radio_property erasemode h , "{normal}|none|xor|background
" 4419 array_property extent rG , Matrix (1, 4, 0.0) 4420 radio_property fontangle u , "{normal}|italic|oblique
" 4421 string_property fontname u , OCTAVE_DEFAULT_FONTNAME 4422 double_property fontsize u , 10 4423 radio_property fontunits SU , "inches|centimeters|normalized|{points}|pixels
" 4424 radio_property fontweight u , "light|{normal}|demi|bold
" 4425 radio_property horizontalalignment mu , "{
left}|center|
right" 4426 radio_property interpreter u , "{tex}|none|latex
" 4427 radio_property linestyle , "{-}|--|:|-.|none
" 4428 double_property linewidth , 0.5 4429 double_property margin , 2 4430 array_property position smu , Matrix (1, 3, 0.0) 4431 double_property rotation mu , 0 4432 text_label_property string u , "" 4433 radio_property units u , "{data}|pixels|normalized|inches|centimeters|points
" 4434 radio_property verticalalignment mu , "top|cap|{middle}|baseline|bottom
" 4436 // hidden properties for limit computation 4437 row_vector_property xlim hlr , Matrix () 4438 row_vector_property ylim hlr , Matrix () 4439 row_vector_property zlim hlr , Matrix () 4440 bool_property xliminclude hl , "off
" 4441 bool_property yliminclude hl , "off
" 4442 bool_property zliminclude hl , "off
" 4443 // hidden properties for auto-positioning 4444 radio_property positionmode hu , "{
auto}|manual
" 4445 radio_property rotationmode hu , "{
auto}|manual
" 4446 radio_property horizontalalignmentmode hu , "{
auto}|manual
" 4447 radio_property verticalalignmentmode hu , "{
auto}|manual
" 4448 radio_property __autopos_tag__ h , "{none}|xlabel|ylabel|zlabel|title
" 4449 // hidden property for text rendering 4450 double_property __fontsize_points__ hgr , 0 4453 Matrix get_data_position (void) const; 4454 Matrix get_extent_matrix (void) const; 4455 const uint8NDArray& get_pixels (void) const { return pixels; } 4457 // Text renderer, used for calculation of text size 4458 octave::text_renderer txt_renderer; 4463 position.add_constraint (dim_vector (1, 3)); 4464 fontsize.add_constraint ("min", 0.0, false); 4465 linewidth.add_constraint ("min", 0.0, false); 4466 margin.add_constraint ("min", 0.0, false); 4467 cached_units = get_units (); 4472 void update_position (void) 4474 Matrix pos = get_data_position (); 4477 lim = Matrix (1, 3, pos(0)); 4478 lim(2) = (lim(2) <= 0 ? octave::numeric_limits<double>::Inf () : lim(2)); 4481 lim = Matrix (1, 3, pos(1)); 4482 lim(2) = (lim(2) <= 0 ? octave::numeric_limits<double>::Inf () : lim(2)); 4485 if (pos.numel () == 3) 4487 lim = Matrix (1, 3, pos(2)); 4488 lim(2) = (lim(2) <= 0 ? octave::numeric_limits<double>::Inf () 4490 set_zliminclude ("on"); 4494 set_zliminclude ("off
"); 4497 void update_text_extent (void); 4499 void request_autopos (void); 4500 void update_positionmode (void) { request_autopos (); } 4501 void update_rotationmode (void) { request_autopos (); } 4502 void update_horizontalalignmentmode (void) { request_autopos (); } 4503 void update_verticalalignmentmode (void) { request_autopos (); } 4505 void update_font (void); 4506 void update_string (void) { request_autopos (); update_text_extent (); } 4507 void update_rotation (void) { update_text_extent (); } 4508 void update_color (void) { update_font (); update_text_extent (); } 4509 void update_fontname (void) { update_font (); update_text_extent (); } 4510 void update_fontsize (void) { update_font (); update_text_extent (); } 4511 void update_fontangle (void) { update_font (); update_text_extent (); } 4513 void update_fontweight (void) 4516 update_text_extent (); 4517 // FIXME: DEPRECATED: Remove warning with demi and light in 4519 if (fontweight.is ("demi
") || fontweight.is ("light")) 4520 warning_with_id ("Octave:deprecated-
property", 4521 "Setting
'fontweight' to
'%s' is deprecated, \
4522 use
'normal' or 'bold'.
", fontweight.current_value ().c_str ()); 4525 void update_interpreter (void) { update_text_extent (); } 4526 void update_horizontalalignment (void) { update_text_extent (); } 4527 void update_verticalalignment (void) { update_text_extent (); } 4529 void update_units (void); 4530 void update_fontunits (const caseless_str& old_fontunits); 4533 std::string cached_units; 4534 uint8NDArray pixels; 4538 properties xproperties; 4541 text (const graphics_handle& mh, const graphics_handle& p) 4542 : base_graphics_object (), xproperties (mh, p) 4544 xproperties.set_clipping ("off
"); 4547 ~text (void) = default; 4549 base_properties& get_properties (void) { return xproperties; } 4551 const base_properties& get_properties (void) const { return xproperties; } 4553 bool valid_object (void) const { return true; } 4555 bool has_readonly_property (const caseless_str& pname) const 4557 bool retval = xproperties.has_readonly_property (pname); 4559 retval = base_properties::has_readonly_property (pname); 4564 // --------------------------------------------------------------------- 4566 class OCTINTERP_API image : public base_graphics_object 4569 class OCTINTERP_API properties : public base_properties 4572 bool is_aliminclude (void) const 4573 { return (aliminclude.is_on () && alphadatamapping.is ("scaled
")); } 4574 std::string get_aliminclude (void) const 4575 { return aliminclude.current_value (); } 4577 bool is_climinclude (void) const 4578 { return (climinclude.is_on () && cdatamapping.is ("scaled
")); } 4579 std::string get_climinclude (void) const 4580 { return climinclude.current_value (); } 4582 octave_value get_color_data (void) const; 4584 void initialize_data (void) { update_cdata (); } 4586 // See the genprops.awk script for an explanation of the 4587 // properties declarations. 4588 // Programming note: Keep property list sorted if new ones are added. 4590 BEGIN_PROPERTIES (image) 4591 array_property alphadata u , Matrix (1, 1, 1.0) 4592 radio_property alphadatamapping al , "{none}|direct|scaled
" 4593 array_property cdata u , default_image_cdata () 4594 radio_property cdatamapping al , "scaled|{direct}
" 4595 radio_property erasemode h , "{normal}|none|xor|background
" 4596 row_vector_property xdata mu , Matrix () 4597 row_vector_property ydata mu , Matrix () 4598 // hidden properties for limit computation 4599 row_vector_property alim hlr , Matrix () 4600 row_vector_property clim hlr , Matrix () 4601 row_vector_property xlim hlr , Matrix () 4602 row_vector_property ylim hlr , Matrix () 4603 bool_property aliminclude hlg , "on" 4604 bool_property climinclude hlg , "on" 4605 bool_property xliminclude hl , "on" 4606 bool_property yliminclude hl , "on" 4607 radio_property xdatamode ha , "{
auto}|manual
" 4608 radio_property ydatamode ha , "{
auto}|manual
" 4614 xdata.add_constraint (2); 4615 xdata.add_constraint (dim_vector (0, 0)); 4616 ydata.add_constraint (2); 4617 ydata.add_constraint (dim_vector (0, 0)); 4618 cdata.add_constraint ("double"); 4619 cdata.add_constraint ("single
"); 4620 cdata.add_constraint ("logical
"); 4621 cdata.add_constraint ("uint8
"); 4622 cdata.add_constraint ("uint16
"); 4623 cdata.add_constraint ("int16
"); 4624 cdata.add_constraint ("real"); 4625 cdata.add_constraint (dim_vector (-1, -1)); 4626 cdata.add_constraint (dim_vector (-1, -1, 3)); 4627 alphadata.add_constraint (dim_vector (-1, -1)); 4628 alphadata.add_constraint ("double"); 4629 alphadata.add_constraint ("uint8
"); 4633 void update_alphadata (void) 4635 if (alphadatamapping_is ("scaled
")) 4636 set_alim (alphadata.get_limits ()); 4638 alim = alphadata.get_limits (); 4641 void update_cdata (void) 4643 if (cdatamapping_is ("scaled
")) 4644 set_clim (cdata.get_limits ()); 4646 clim = cdata.get_limits (); 4648 if (xdatamode.is ("auto")) 4651 if (ydatamode.is ("auto")) 4655 void update_xdata (void) 4657 if (xdata.get ().isempty ()) 4658 set_xdatamode ("auto"); 4660 if (xdatamode.is ("auto")) 4662 set_xdata (get_auto_xdata ()); 4663 set_xdatamode ("auto"); 4666 Matrix limits = xdata.get_limits (); 4667 float dp = pixel_xsize (); 4669 limits(0) = limits(0) - dp; 4670 limits(1) = limits(1) + dp; 4674 void update_ydata (void) 4676 if (ydata.get ().isempty ()) 4677 set_ydatamode ("auto"); 4679 if (ydatamode.is ("auto")) 4681 set_ydata (get_auto_ydata ()); 4682 set_ydatamode ("auto"); 4685 Matrix limits = ydata.get_limits (); 4686 float dp = pixel_ysize (); 4688 limits(0) = limits(0) - dp; 4689 limits(1) = limits(1) + dp; 4693 Matrix get_auto_xdata (void) 4695 dim_vector dv = get_cdata ().dims (); 4699 data = Matrix (1, 2, 1); 4705 Matrix get_auto_ydata (void) 4707 dim_vector dv = get_cdata ().dims (); 4711 data = Matrix (1, 2, 1); 4717 float pixel_size (octave_idx_type dim, const Matrix limits) 4719 octave_idx_type l = dim - 1; 4722 if (l > 0 && limits(0) != limits(1)) 4723 dp = (limits(1) - limits(0))/(2*l); 4726 if (limits(1) == limits(2)) 4729 dp = (limits(1) - limits(0))/2; 4735 float pixel_xsize (void) 4737 return pixel_size ((get_cdata ().dims ())(1), xdata.get_limits ()); 4740 float pixel_ysize (void) 4742 return pixel_size ((get_cdata ().dims ())(0), ydata.get_limits ()); 4747 properties xproperties; 4750 image (const graphics_handle& mh, const graphics_handle& p) 4751 : base_graphics_object (), xproperties (mh, p) 4753 xproperties.initialize_data (); 4756 ~image (void) = default; 4758 base_properties& get_properties (void) { return xproperties; } 4760 const base_properties& get_properties (void) const { return xproperties; } 4762 bool valid_object (void) const { return true; } 4764 bool has_readonly_property (const caseless_str& pname) const 4766 bool retval = xproperties.has_readonly_property (pname); 4768 retval = base_properties::has_readonly_property (pname); 4773 // --------------------------------------------------------------------- 4775 class OCTINTERP_API light : public base_graphics_object 4778 class OCTINTERP_API properties : public base_properties 4780 // See the genprops.awk script for an explanation of the 4781 // properties declarations. 4782 // Programming note: Keep property list sorted if new ones are added. 4784 BEGIN_PROPERTIES (light) 4785 color_property color , color_values (1, 1, 1) 4786 array_property position , default_light_position () 4787 radio_property style , "{infinite}|local
" 4793 position.add_constraint (dim_vector (1, 3)); 4798 properties xproperties; 4801 light (const graphics_handle& mh, const graphics_handle& p) 4802 : base_graphics_object (), xproperties (mh, p) 4805 ~light (void) = default; 4807 base_properties& get_properties (void) { return xproperties; } 4809 const base_properties& get_properties (void) const { return xproperties; } 4811 bool valid_object (void) const { return true; } 4813 bool has_readonly_property (const caseless_str& pname) const 4815 bool retval = xproperties.has_readonly_property (pname); 4817 retval = base_properties::has_readonly_property (pname); 4822 // --------------------------------------------------------------------- 4824 class OCTINTERP_API patch : public base_graphics_object 4827 class OCTINTERP_API properties : public base_properties 4830 octave_value get_color_data (void) const; 4832 // Matlab allows incoherent data to be stored into patch properties. 4833 // The patch should then be ignored by the renderer. 4834 bool has_bad_data (std::string& msg) const 4837 return ! msg.empty (); 4840 bool is_aliminclude (void) const 4841 { return (aliminclude.is_on () && alphadatamapping.is ("scaled
")); } 4842 std::string get_aliminclude (void) const 4843 { return aliminclude.current_value (); } 4845 bool is_climinclude (void) const 4846 { return (climinclude.is_on () && cdatamapping.is ("scaled
")); } 4847 std::string get_climinclude (void) const 4848 { return climinclude.current_value (); } 4850 // See the genprops.awk script for an explanation of the 4851 // properties declarations. 4852 // Programming note: Keep property list sorted if new ones are added. 4854 BEGIN_PROPERTIES (patch) 4855 radio_property alphadatamapping l , "none|{scaled}|direct
" 4856 double_property ambientstrength , 0.3 4857 radio_property backfacelighting , "unlit|lit|{reverselit}
" 4858 array_property cdata u , Matrix () 4859 radio_property cdatamapping l , "{scaled}|direct
" 4860 double_property diffusestrength , 0.6 4861 string_property displayname , "" 4862 double_radio_property edgealpha , double_radio_property (1.0, radio_values ("flat|interp
")) 4863 color_property edgecolor , color_property (color_values (0, 0, 0), radio_values ("none|flat|interp
")) 4864 radio_property edgelighting , "{none}|flat|gouraud|phong
" 4865 radio_property erasemode h , "{normal}|none|xor|background
" 4866 double_radio_property facealpha , double_radio_property (1.0, radio_values ("flat|interp
")) 4867 color_property facecolor , color_property (color_values (0, 0, 0), radio_values ("none|flat|interp
")) 4868 radio_property facelighting , "none|{flat}|gouraud|phong
" 4869 array_property facenormals m , Matrix () 4870 radio_property facenormalsmode , "{
auto}|manual
" 4871 array_property faces u , default_patch_faces () 4872 array_property facevertexalphadata , Matrix () 4873 array_property facevertexcdata u , Matrix () 4874 // FIXME: DEPRECATED: Remove interpreter property in version 6. 4875 radio_property interpreter hd , "{tex}|none|latex
" 4876 radio_property linestyle , "{-}|--|:|-.|none
" 4877 double_property linewidth , 0.5 4878 radio_property marker , "{none}|+|o|*|.|
x|
s|square|
d|diamond|^|v|>|<|
p|pentagram|
h|hexagram
" 4879 color_property markeredgecolor , color_property (radio_values ("none|{
auto}|flat
"), color_values (0, 0, 0)) 4880 color_property markerfacecolor , color_property (radio_values ("{none}|
auto|flat
"), color_values (0, 0, 0)) 4881 double_property markersize , 6 4882 radio_property normalmode hsg , "{
auto}|manual
" 4883 double_property specularcolorreflectance , 1.0 4884 double_property specularexponent , 10.0 4885 double_property specularstrength , 0.9 4886 array_property vertexnormals m , Matrix () 4887 radio_property vertexnormalsmode , "{
auto}|manual
" 4888 array_property vertices u , default_patch_vertices () 4889 array_property xdata u , default_patch_xdata () 4890 array_property ydata u , default_patch_ydata () 4891 array_property zdata u , Matrix () 4893 // hidden properties for limit computation 4894 row_vector_property alim hlr , Matrix () 4895 row_vector_property clim hlr , Matrix () 4896 row_vector_property xlim hlr , Matrix () 4897 row_vector_property ylim hlr , Matrix () 4898 row_vector_property zlim hlr , Matrix () 4899 bool_property aliminclude hlg , "on" 4900 bool_property climinclude hlg , "on" 4901 bool_property xliminclude hl , "on" 4902 bool_property yliminclude hl , "on" 4903 bool_property zliminclude hl , "on" 4909 xdata.add_constraint (dim_vector (-1, -1)); 4910 ydata.add_constraint (dim_vector (-1, -1)); 4911 zdata.add_constraint (dim_vector (-1, -1)); 4912 faces.add_constraint (dim_vector (-1, -1)); 4913 vertices.add_constraint (dim_vector (-1, 2)); 4914 vertices.add_constraint (dim_vector (-1, 3)); 4915 cdata.add_constraint (dim_vector (-1, -1)); 4916 cdata.add_constraint (dim_vector (-1, -1, 3)); 4917 facevertexcdata.add_constraint (dim_vector (-1, 1)); 4918 facevertexcdata.add_constraint (dim_vector (-1, 3)); 4919 facevertexalphadata.add_constraint (dim_vector (-1, 1)); 4920 facenormals.add_constraint (dim_vector (-1, 3)); 4921 facenormals.add_constraint (dim_vector (0, 0)); 4922 vertexnormals.add_constraint (dim_vector (-1, 3)); 4923 vertexnormals.add_constraint (dim_vector (0, 0)); 4925 ambientstrength.add_constraint ("min", 0.0, true); 4926 ambientstrength.add_constraint ("max", 1.0, true); 4927 diffusestrength.add_constraint ("min", 0.0, true); 4928 diffusestrength.add_constraint ("max", 1.0, true); 4929 linewidth.add_constraint ("min", 0.0, false); 4930 markersize.add_constraint ("min", 0.0, false); 4931 specularcolorreflectance.add_constraint ("min", 0.0, true); 4932 specularcolorreflectance.add_constraint ("max", 1.0, true); 4933 specularexponent.add_constraint ("min", 0.0, false); 4934 specularstrength.add_constraint ("min", 0.0, true); 4935 specularstrength.add_constraint ("max", 1.0, true); 4939 std::string bad_data_msg; 4941 void update_faces (void) { update_data ();} 4943 void update_vertices (void) { update_data ();} 4945 void update_facevertexcdata (void) { update_data ();} 4947 void update_fvc (void); 4949 void update_xdata (void) 4951 if (get_xdata ().isempty ()) 4953 // For compatibility with matlab behavior, 4954 // if x/ydata are set empty, silently empty other *data and 4955 // faces properties while vertices remain unchanged. 4956 set_ydata (Matrix ()); 4957 set_zdata (Matrix ()); 4958 set_cdata (Matrix ()); 4959 set_faces (Matrix ()); 4964 set_xlim (xdata.get_limits ()); 4967 void update_ydata (void) 4969 if (get_ydata ().isempty ()) 4971 set_xdata (Matrix ()); 4972 set_zdata (Matrix ()); 4973 set_cdata (Matrix ()); 4974 set_faces (Matrix ()); 4979 set_ylim (ydata.get_limits ()); 4982 void update_zdata (void) 4985 set_zlim (zdata.get_limits ()); 4988 void update_cdata (void) 4992 if (cdatamapping_is ("scaled
")) 4993 set_clim (cdata.get_limits ()); 4995 clim = cdata.get_limits (); 4998 void update_data (void); 5000 void set_normalmode (const octave_value& val) 5002 warning_with_id ("Octave:deprecated-
property", 5003 "patch: Property
'normalmode' is deprecated and will be removed
" 5004 "from
a future version
of Octave. Use
'vertexnormalsmode' instead.
"); 5005 set_vertexnormalsmode (val); 5008 std::string get_normalmode (void) const 5010 warning_with_id ("Octave:deprecated-
property", 5011 "patch: Property
'normalmode' is deprecated and will be removed
" 5012 "from
a future version
of Octave. Use
'vertexnormalsmode' instead.
"); 5013 return vertexnormalsmode.current_value (); 5018 properties xproperties; 5021 patch (const graphics_handle& mh, const graphics_handle& p) 5022 : base_graphics_object (), xproperties (mh, p) 5025 ~patch (void) = default; 5027 base_properties& get_properties (void) { return xproperties; } 5029 const base_properties& get_properties (void) const { return xproperties; } 5031 bool valid_object (void) const { return true; } 5033 bool has_readonly_property (const caseless_str& pname) const 5035 bool retval = xproperties.has_readonly_property (pname); 5037 retval = base_properties::has_readonly_property (pname); 5042 // --------------------------------------------------------------------- 5044 class OCTINTERP_API surface : public base_graphics_object 5047 class OCTINTERP_API properties : public base_properties 5050 octave_value get_color_data (void) const; 5052 bool is_aliminclude (void) const 5053 { return (aliminclude.is_on () && alphadatamapping.is ("scaled
")); } 5054 std::string get_aliminclude (void) const 5055 { return aliminclude.current_value (); } 5057 bool is_climinclude (void) const 5058 { return (climinclude.is_on () && cdatamapping.is ("scaled
")); } 5059 std::string get_climinclude (void) const 5060 { return climinclude.current_value (); } 5062 // See the genprops.awk script for an explanation of the 5063 // properties declarations. 5064 // Programming note: Keep property list sorted if new ones are added. 5066 BEGIN_PROPERTIES (surface) 5067 array_property alphadata u , Matrix (1, 1, 1.0) 5068 radio_property alphadatamapping l , "none|direct|{scaled}
" 5069 double_property ambientstrength , 0.3 5070 radio_property backfacelighting , "unlit|lit|{reverselit}
" 5071 array_property cdata u , default_surface_cdata () 5072 radio_property cdatamapping al , "{scaled}|direct
" 5073 string_property cdatasource , "" 5074 double_property diffusestrength , 0.6 5075 string_property displayname , "" 5076 double_radio_property edgealpha , double_radio_property (1.0, radio_values ("flat|interp
")) 5077 color_property edgecolor , color_property (color_values (0, 0, 0), radio_values ("none|flat|interp
")) 5078 radio_property edgelighting , "{none}|flat|gouraud|phong
" 5079 radio_property erasemode h , "{normal}|none|xor|background
" 5080 double_radio_property facealpha , double_radio_property (1.0, radio_values ("flat|interp|texturemap
")) 5081 color_property facecolor , color_property (radio_values ("none|{flat}|interp|texturemap
"), color_values (0, 0, 0)) 5082 radio_property facelighting , "none|{flat}|gouraud|phong
" 5083 array_property facenormals m , Matrix () 5084 radio_property facenormalsmode , "{
auto}|manual
" 5085 // FIXME: DEPRECATED: Remove interpreter property in version 6. 5086 radio_property interpreter hd , "{tex}|none|latex
" 5087 radio_property linestyle , "{-}|--|:|-.|none
" 5088 double_property linewidth , 0.5 5089 radio_property marker , "{none}|+|o|*|.|
x|
s|square|
d|diamond|^|v|>|<|
p|pentagram|
h|hexagram
" 5090 color_property markeredgecolor , color_property (radio_values ("none|{
auto}|flat
"), color_values (0, 0, 0)) 5091 color_property markerfacecolor , color_property (radio_values ("{none}|
auto|flat
"), color_values (0, 0, 0)) 5092 double_property markersize , 6 5093 radio_property meshstyle , "{both}|
row|
column" 5094 radio_property normalmode hsg , "{
auto}|manual
" 5095 double_property specularcolorreflectance , 1 5096 double_property specularexponent , 10 5097 double_property specularstrength , 0.9 5098 array_property vertexnormals m , Matrix () 5099 radio_property vertexnormalsmode u , "{
auto}|manual
" 5100 array_property xdata u , default_surface_xdata () 5101 string_property xdatasource , "" 5102 array_property ydata u , default_surface_ydata () 5103 string_property ydatasource , "" 5104 array_property zdata u , default_surface_zdata () 5105 string_property zdatasource , "" 5107 // hidden properties for limit computation 5108 row_vector_property alim hlr , Matrix () 5109 row_vector_property clim hlr , Matrix () 5110 row_vector_property xlim hlr , Matrix () 5111 row_vector_property ylim hlr , Matrix () 5112 row_vector_property zlim hlr , Matrix () 5113 bool_property aliminclude hlg , "on" 5114 bool_property climinclude hlg , "on" 5115 bool_property xliminclude hl , "on" 5116 bool_property yliminclude hl , "on" 5117 bool_property zliminclude hl , "on" 5123 xdata.add_constraint (dim_vector (-1, -1)); 5124 ydata.add_constraint (dim_vector (-1, -1)); 5125 zdata.add_constraint (dim_vector (-1, -1)); 5126 cdata.add_constraint ("double"); 5127 cdata.add_constraint ("single
"); 5128 cdata.add_constraint (dim_vector (-1, -1)); 5129 cdata.add_constraint (dim_vector (-1, -1, 3)); 5130 alphadata.add_constraint ("double"); 5131 alphadata.add_constraint ("uint8
"); 5132 alphadata.add_constraint (dim_vector (-1, -1)); 5133 facenormals.add_constraint (dim_vector (-1, -1, 3)); 5134 facenormals.add_constraint (dim_vector (0, 0)); 5135 vertexnormals.add_constraint (dim_vector (-1, -1, 3)); 5136 vertexnormals.add_constraint (dim_vector (0, 0)); 5138 ambientstrength.add_constraint ("min", 0.0, true); 5139 ambientstrength.add_constraint ("max", 1.0, true); 5140 diffusestrength.add_constraint ("min", 0.0, true); 5141 diffusestrength.add_constraint ("max", 1.0, true); 5142 linewidth.add_constraint ("min", 0.0, false); 5143 markersize.add_constraint ("min", 0.0, false); 5144 specularcolorreflectance.add_constraint ("min", 0.0, true); 5145 specularcolorreflectance.add_constraint ("max", 1.0, true); 5146 specularexponent.add_constraint ("min", 0.0, false); 5147 specularstrength.add_constraint ("min", 0.0, true); 5148 specularstrength.add_constraint ("max", 1.0, true); 5152 void update_alphadata (void) 5154 if (alphadatamapping_is ("scaled
")) 5155 set_alim (alphadata.get_limits ()); 5157 alim = alphadata.get_limits (); 5160 void update_cdata (void) 5162 if (cdatamapping_is ("scaled
")) 5163 set_clim (cdata.get_limits ()); 5165 clim = cdata.get_limits (); 5168 void update_xdata (void) 5170 update_vertex_normals (); 5171 set_xlim (xdata.get_limits ()); 5174 void update_ydata (void) 5176 update_vertex_normals (); 5177 set_ylim (ydata.get_limits ()); 5180 void update_zdata (void) 5182 update_vertex_normals (); 5183 set_zlim (zdata.get_limits ()); 5186 void update_vertex_normals (void); 5188 void update_vertexnormalsmode (void) 5189 { update_vertex_normals (); } 5191 void set_normalmode (const octave_value& val) 5193 warning_with_id ("Octave:deprecated-
property", 5194 "surface: Property
'normalmode' is deprecated and will be removed
" 5195 "from
a future version
of Octave. Use
'vertexnormalsmode' instead.
"); 5196 set_vertexnormalsmode (val); 5199 std::string get_normalmode (void) const 5201 warning_with_id ("Octave:deprecated-
property", 5202 "surface: Property
'normalmode' is deprecated and will be removed
" 5203 "from
a future version
of Octave. Use
'vertexnormalsmode' instead.
"); 5204 return vertexnormalsmode.current_value (); 5209 properties xproperties; 5212 surface (const graphics_handle& mh, const graphics_handle& p) 5213 : base_graphics_object (), xproperties (mh, p) 5216 ~surface (void) = default; 5218 base_properties& get_properties (void) { return xproperties; } 5220 const base_properties& get_properties (void) const { return xproperties; } 5222 bool valid_object (void) const { return true; } 5224 bool has_readonly_property (const caseless_str& pname) const 5226 bool retval = xproperties.has_readonly_property (pname); 5228 retval = base_properties::has_readonly_property (pname); 5233 // --------------------------------------------------------------------- 5235 class OCTINTERP_API hggroup : public base_graphics_object 5238 class OCTINTERP_API properties : public base_properties 5241 void remove_child (const graphics_handle& h) 5243 base_properties::remove_child (h); 5247 void adopt (const graphics_handle& h) 5250 base_properties::adopt (h); 5254 // See the genprops.awk script for an explanation of the 5255 // properties declarations. 5256 // Programming note: Keep property list sorted if new ones are added. 5258 BEGIN_PROPERTIES (hggroup) 5259 string_property displayname , "" 5260 radio_property erasemode h , "{normal}|none|xor|background
" 5262 // hidden properties for limit computation 5263 row_vector_property alim hr , Matrix () 5264 row_vector_property clim hr , Matrix () 5265 row_vector_property xlim hr , Matrix () 5266 row_vector_property ylim hr , Matrix () 5267 row_vector_property zlim hr , Matrix () 5268 bool_property aliminclude h , "on" 5269 bool_property climinclude h , "on" 5270 bool_property xliminclude h , "on" 5271 bool_property yliminclude h , "on" 5272 bool_property zliminclude h , "on" 5276 void update_limits (void) const; 5278 void update_limits (const graphics_handle& h) const; 5287 properties xproperties; 5290 hggroup (const graphics_handle& mh, const graphics_handle& p) 5291 : base_graphics_object (), xproperties (mh, p) 5294 ~hggroup (void) = default; 5296 base_properties& get_properties (void) { return xproperties; } 5298 const base_properties& get_properties (void) const { return xproperties; } 5300 bool valid_object (void) const { return true; } 5302 void update_axis_limits (const std::string& axis_type); 5304 void update_axis_limits (const std::string& axis_type, 5305 const graphics_handle& h); 5307 bool has_readonly_property (const caseless_str& pname) const 5309 bool retval = xproperties.has_readonly_property (pname); 5311 retval = base_properties::has_readonly_property (pname); 5317 // --------------------------------------------------------------------- 5319 class OCTINTERP_API uimenu : public base_graphics_object 5322 class OCTINTERP_API properties : public base_properties 5325 void remove_child (const graphics_handle& h) 5327 base_properties::remove_child (h); 5330 void adopt (const graphics_handle& h) 5332 base_properties::adopt (h); 5335 // See the genprops.awk script for an explanation of the 5336 // properties declarations. 5337 // Programming note: Keep property list sorted if new ones are added. 5339 BEGIN_PROPERTIES (uimenu) 5340 string_property accelerator , "" 5341 callback_property callback , Matrix () 5342 bool_property checked , "off
" 5343 bool_property enable , "on" 5344 color_property foregroundcolor , color_values (0, 0, 0) 5345 string_property label , "" 5346 double_property position , 0 5347 bool_property separator , "off
" 5349 // Octave-specific properties 5350 string_property __fltk_label__ h , "" 5351 any_property __object__ h , Matrix () 5357 position.add_constraint ("min", 0, false); 5362 properties xproperties; 5365 uimenu (const graphics_handle& mh, const graphics_handle& p) 5366 : base_graphics_object (), xproperties (mh, p) 5369 ~uimenu (void) = default; 5371 base_properties& get_properties (void) { return xproperties; } 5373 const base_properties& get_properties (void) const { return xproperties; } 5375 bool valid_object (void) const { return true; } 5377 bool has_readonly_property (const caseless_str& pname) const 5379 bool retval = xproperties.has_readonly_property (pname); 5381 retval = base_properties::has_readonly_property (pname); 5387 // --------------------------------------------------------------------- 5389 class OCTINTERP_API uicontextmenu : public base_graphics_object 5392 class OCTINTERP_API properties : public base_properties 5396 void add_dependent_obj (graphics_handle gh) 5397 { dependent_obj_list.push_back (gh); } 5399 // FIXME: the list may contain duplicates. 5400 // Should we return only unique elements? 5401 const std::list<graphics_handle> get_dependent_obj_list (void) 5402 { return dependent_obj_list; } 5404 // See the genprops.awk script for an explanation of the 5405 // properties declarations. 5406 // Programming note: Keep property list sorted if new ones are added. 5408 BEGIN_PROPERTIES (uicontextmenu) 5409 callback_property callback , Matrix () 5410 array_property position , Matrix (1, 2, 0.0) 5412 // Octave-specific properties 5413 any_property __object__ h , Matrix () 5419 position.add_constraint (dim_vector (1, 2)); 5420 position.add_constraint (dim_vector (2, 1)); 5421 visible.set (octave_value (false)); 5425 // List of objects that might depend on this uicontextmenu object 5426 std::list<graphics_handle> dependent_obj_list; 5430 properties xproperties; 5433 uicontextmenu (const graphics_handle& mh, const graphics_handle& p) 5434 : base_graphics_object (), xproperties (mh, p) 5437 ~uicontextmenu (void); 5439 base_properties& get_properties (void) { return xproperties; } 5441 const base_properties& get_properties (void) const { return xproperties; } 5443 bool valid_object (void) const { return true; } 5445 bool has_readonly_property (const caseless_str& pname) const 5447 bool retval = xproperties.has_readonly_property (pname); 5449 retval = base_properties::has_readonly_property (pname); 5455 // --------------------------------------------------------------------- 5457 class OCTINTERP_API uicontrol : public base_graphics_object 5460 class OCTINTERP_API properties : public base_properties 5463 Matrix get_boundingbox (bool internal = false, 5464 const Matrix& parent_pix_size = Matrix ()) const; 5466 double get___fontsize_points__ (double box_pix_height = 0) const; 5468 // See the genprops.awk script for an explanation of the 5469 // properties declarations. 5470 // Programming note: Keep property list sorted if new ones are added. 5472 BEGIN_PROPERTIES (uicontrol) 5473 color_property backgroundcolor , color_values (1, 1, 1) 5474 callback_property callback , Matrix () 5475 array_property cdata , Matrix () 5476 bool_property clipping , "on" 5477 radio_property enable , "{
on}|inactive|off
" 5478 array_property extent rG , Matrix (1, 4, 0.0) 5479 radio_property fontangle u , "{normal}|italic|oblique
" 5480 string_property fontname u , OCTAVE_DEFAULT_FONTNAME 5481 double_property fontsize u , 10 5482 radio_property fontunits S , "inches|centimeters|normalized|{points}|pixels
" 5483 radio_property fontweight u , "light|{normal}|demi|bold
" 5484 color_property foregroundcolor , color_values (0, 0, 0) 5485 radio_property horizontalalignment , "left|{center}|
right" 5486 callback_property keypressfcn , Matrix () 5487 double_property listboxtop , 1 5488 double_property max , 1 5489 double_property min , 0 5490 array_property position , default_control_position () 5491 array_property sliderstep , default_control_sliderstep () 5492 string_array_property string u , "" 5493 radio_property style S , "{pushbutton}|togglebutton|radiobutton|checkbox|edit|
text|slider|
frame|listbox|popupmenu
" 5494 string_property tooltipstring , "" 5495 radio_property units u , "normalized|inches|centimeters|points|{pixels}|
characters" 5496 row_vector_property value , Matrix (1, 1, 0.0) 5497 radio_property verticalalignment , "top|{middle}|bottom
" 5499 // Octave-specific properties 5500 any_property __object__ h , Matrix () 5504 std::string cached_units; 5509 cdata.add_constraint ("double"); 5510 cdata.add_constraint ("single
"); 5511 cdata.add_constraint (dim_vector (-1, -1, 3)); 5512 position.add_constraint (dim_vector (1, 4)); 5513 sliderstep.add_constraint (dim_vector (1, 2)); 5514 fontsize.add_constraint ("min", 0.0, false); 5515 cached_units = get_units (); 5518 void update_text_extent (void); 5520 void update_string (void) { update_text_extent (); } 5521 void update_fontname (void) { update_text_extent (); } 5522 void update_fontsize (void) { update_text_extent (); } 5523 void update_fontangle (void) { update_text_extent (); } 5525 void update_fontweight (void) 5527 update_text_extent (); 5528 // FIXME: DEPRECATED: Remove warning with demi and light in 5530 if (fontweight.is ("demi
") || fontweight.is ("light")) 5531 warning_with_id ("Octave:deprecated-
property", 5532 "Setting
'fontweight' to
'%s' is deprecated, \
5533 use
'normal' or 'bold'.
", fontweight.current_value ().c_str ()); 5536 void update_fontunits (const caseless_str& old_units); 5538 void update_units (void); 5543 properties xproperties; 5546 uicontrol (const graphics_handle& mh, const graphics_handle& p) 5547 : base_graphics_object (), xproperties (mh, p) 5550 ~uicontrol (void) = default; 5552 base_properties& get_properties (void) { return xproperties; } 5554 const base_properties& get_properties (void) const { return xproperties; } 5556 bool valid_object (void) const { return true; } 5558 bool has_readonly_property (const caseless_str& pname) const 5560 bool retval = xproperties.has_readonly_property (pname); 5562 retval = base_properties::has_readonly_property (pname); 5567 // --------------------------------------------------------------------- 5569 class OCTINTERP_API uibuttongroup : public base_graphics_object 5572 class OCTINTERP_API properties : public base_properties 5575 Matrix get_boundingbox (bool internal = false, 5576 const Matrix& parent_pix_size = Matrix ()) const; 5578 double get___fontsize_points__ (double box_pix_height = 0) const; 5580 // See the genprops.awk script for an explanation of the 5581 // properties declarations. 5582 // Programming note: Keep property list sorted if new ones are added. 5584 BEGIN_PROPERTIES (uibuttongroup) 5585 color_property backgroundcolor , color_values (1, 1, 1) 5586 radio_property bordertype , "none|{etchedin}|etchedout|beveledin|beveledout|
line" 5587 double_property borderwidth , 1 5588 bool_property clipping , "on" 5589 radio_property fontangle , "{normal}|italic|oblique
" 5590 string_property fontname , OCTAVE_DEFAULT_FONTNAME 5591 double_property fontsize , 10 5592 radio_property fontunits S , "inches|centimeters|normalized|{points}|pixels
" 5593 radio_property fontweight u , "light|{normal}|demi|bold
" 5594 color_property foregroundcolor , color_values (0, 0, 0) 5595 color_property highlightcolor , color_values (1, 1, 1) 5596 array_property position , default_panel_position () 5597 callback_property resizefcn , Matrix () 5598 handle_property selectedobject S , graphics_handle () 5599 callback_property selectionchangedfcn , Matrix () 5600 color_property shadowcolor , color_values (0, 0, 0) 5601 callback_property sizechangedfcn , Matrix () 5602 radio_property units S , "{normalized}|inches|centimeters|points|pixels|
characters" 5603 string_property title , "" 5604 radio_property titleposition , "{lefttop}|centertop|righttop|leftbottom|centerbottom|rightbottom
" 5606 // Octave-specific properties 5607 any_property __object__ h , Matrix () 5613 position.add_constraint (dim_vector (1, 4)); 5614 borderwidth.add_constraint ("min", 0.0, true); 5615 fontsize.add_constraint ("min", 0.0, false); 5618 // void update_text_extent (void); 5619 // void update_string (void) { update_text_extent (); } 5620 // void update_fontname (void) { update_text_extent (); } 5621 // void update_fontsize (void) { update_text_extent (); } 5622 // void update_fontangle (void) { update_text_extent (); } 5624 void update_fontweight (void) 5626 // FIXME: DEPRECATED: Remove this warning in version 6. 5627 if (fontweight.is ("demi
") || fontweight.is ("light")) 5628 warning_with_id ("Octave:deprecated-
property", 5629 "Setting
'fontweight' to
'%s' is deprecated, \
5630 use
'normal' or 'bold'.
", fontweight.current_value ().c_str ()); 5633 void update_units (const caseless_str& old_units); 5634 void update_fontunits (const caseless_str& old_units); 5639 properties xproperties; 5642 uibuttongroup (const graphics_handle& mh, const graphics_handle& p) 5643 : base_graphics_object (), xproperties (mh, p) 5646 ~uibuttongroup (void) = default; 5648 base_properties& get_properties (void) { return xproperties; } 5650 const base_properties& get_properties (void) const { return xproperties; } 5652 bool valid_object (void) const { return true; } 5654 bool has_readonly_property (const caseless_str& pname) const 5656 bool retval = xproperties.has_readonly_property (pname); 5658 retval = base_properties::has_readonly_property (pname); 5664 // --------------------------------------------------------------------- 5666 class OCTINTERP_API uipanel : public base_graphics_object 5669 class OCTINTERP_API properties : public base_properties 5672 Matrix get_boundingbox (bool internal = false, 5673 const Matrix& parent_pix_size = Matrix ()) const; 5675 double get___fontsize_points__ (double box_pix_height = 0) const; 5677 // See the genprops.awk script for an explanation of the 5678 // properties declarations. 5679 // Programming note: Keep property list sorted if new ones are added. 5681 BEGIN_PROPERTIES (uipanel) 5682 color_property backgroundcolor , color_values (1, 1, 1) 5683 radio_property bordertype , "none|{etchedin}|etchedout|beveledin|beveledout|
line" 5684 double_property borderwidth , 1 5685 radio_property fontangle , "{normal}|italic|oblique
" 5686 string_property fontname , OCTAVE_DEFAULT_FONTNAME 5687 double_property fontsize , 10 5688 radio_property fontunits S , "inches|centimeters|normalized|{points}|pixels
" 5689 radio_property fontweight u , "light|{normal}|demi|bold
" 5690 color_property foregroundcolor , color_values (0, 0, 0) 5691 color_property highlightcolor , color_values (1, 1, 1) 5692 array_property position , default_panel_position () 5693 callback_property resizefcn , Matrix () 5694 color_property shadowcolor , color_values (0, 0, 0) 5695 string_property title , "" 5696 radio_property titleposition , "{lefttop}|centertop|righttop|leftbottom|centerbottom|rightbottom
" 5697 radio_property units S , "{normalized}|inches|centimeters|points|pixels|
characters" 5698 // Octave-specific properties 5699 any_property __object__ h , Matrix () 5705 borderwidth.add_constraint ("min", 0.0, true); 5706 fontsize.add_constraint ("min", 0.0, false); 5707 position.add_constraint (dim_vector (1, 4)); 5710 void update_units (const caseless_str& old_units); 5711 void update_fontunits (const caseless_str& old_units); 5713 void update_fontweight (void) 5715 // FIXME: DEPRECATED: Remove this warning in version 6. 5716 if (fontweight.is ("demi
") || fontweight.is ("light")) 5717 warning_with_id ("Octave:deprecated-
property", 5718 "Setting
'fontweight' to
'%s' is deprecated, \
5719 use
'normal' or 'bold'.
", fontweight.current_value ().c_str ()); 5724 properties xproperties; 5727 uipanel (const graphics_handle& mh, const graphics_handle& p) 5728 : base_graphics_object (), xproperties (mh, p) 5731 ~uipanel (void) = default; 5733 base_properties& get_properties (void) { return xproperties; } 5735 const base_properties& get_properties (void) const { return xproperties; } 5737 bool valid_object (void) const { return true; } 5739 bool has_readonly_property (const caseless_str& pname) const 5741 bool retval = xproperties.has_readonly_property (pname); 5743 retval = base_properties::has_readonly_property (pname); 5748 // --------------------------------------------------------------------- 5750 class OCTINTERP_API uitoolbar : public base_graphics_object 5753 class OCTINTERP_API properties : public base_properties 5756 // See the genprops.awk script for an explanation of the 5757 // properties declarations. 5758 // Programming note: Keep property list sorted if new ones are added. 5760 BEGIN_PROPERTIES (uitoolbar) 5761 // Octave-specific properties 5762 any_property __object__ h , Matrix () 5771 properties xproperties; 5774 uitoolbar (const graphics_handle& mh, const graphics_handle& p) 5775 : base_graphics_object (), xproperties (mh, p), default_properties () 5778 ~uitoolbar (void) = default; 5780 void override_defaults (base_graphics_object& obj) 5782 // Allow parent (figure) to override first (properties knows how 5783 // to find the parent object). 5784 xproperties.override_defaults (obj); 5786 // Now override with our defaults. If the default_properties 5787 // list includes the properties for all defaults (line, 5788 // surface, etc.) then we don't have to know the type of OBJ 5789 // here, we just call its set function and let it decide which 5790 // properties from the list to use. 5791 obj.set_from_list (default_properties); 5794 void set (const caseless_str& name, const octave_value& value) 5796 if (name.compare ("default
", 7)) 5797 // strip "default", pass rest to function that will 5798 // parse the remainder and add the element to the 5799 // default_properties map. 5800 default_properties.set (name.substr (7), value); 5802 xproperties.set (name, value); 5805 octave_value get (const caseless_str& name) const 5807 octave_value retval; 5809 if (name.compare ("default", 7)) 5810 retval = get_default (name.substr (7)); 5812 retval = xproperties.get (name); 5817 octave_value get_default (const caseless_str& name) const; 5819 octave_value get_defaults (void) const 5821 return default_properties.as_struct ("default"); 5824 property_list get_defaults_list (void) const 5826 return default_properties; 5829 base_properties& get_properties (void) { return xproperties; } 5831 const base_properties& get_properties (void) const { return xproperties; } 5833 bool valid_object (void) const { return true; } 5835 void reset_default_properties (void); 5837 bool has_readonly_property (const caseless_str& pname) const 5839 bool retval = xproperties.has_readonly_property (pname); 5841 retval = base_properties::has_readonly_property (pname); 5846 property_list default_properties; 5849 // --------------------------------------------------------------------- 5851 class OCTINTERP_API uipushtool : public base_graphics_object 5854 class OCTINTERP_API properties : public base_properties 5857 // See the genprops.awk script for an explanation of the 5858 // properties declarations. 5859 // Programming note: Keep property list sorted if new ones are added. 5861 BEGIN_PROPERTIES (uipushtool) 5862 array_property cdata , Matrix () 5863 callback_property clickedcallback , Matrix () 5864 bool_property enable , "on" 5865 bool_property separator , "off
" 5866 string_property tooltipstring , "" 5868 // Octave-specific properties 5869 any_property __object__ h , Matrix () 5875 cdata.add_constraint ("double"); 5876 cdata.add_constraint ("single
"); 5877 cdata.add_constraint (dim_vector (-1, -1, 3)); 5882 properties xproperties; 5885 uipushtool (const graphics_handle& mh, const graphics_handle& p) 5886 : base_graphics_object (), xproperties (mh, p) 5889 ~uipushtool (void) = default; 5891 base_properties& get_properties (void) { return xproperties; } 5893 const base_properties& get_properties (void) const { return xproperties; } 5895 bool valid_object (void) const { return true; } 5897 bool has_readonly_property (const caseless_str& pname) const 5899 bool retval = xproperties.has_readonly_property (pname); 5901 retval = base_properties::has_readonly_property (pname); 5907 // --------------------------------------------------------------------- 5909 class OCTINTERP_API uitoggletool : public base_graphics_object 5912 class OCTINTERP_API properties : public base_properties 5915 // See the genprops.awk script for an explanation of the 5916 // properties declarations. 5917 // Programming note: Keep property list sorted if new ones are added. 5919 BEGIN_PROPERTIES (uitoggletool) 5920 array_property cdata , Matrix () 5921 callback_property clickedcallback , Matrix () 5922 bool_property enable , "on" 5923 callback_property offcallback , Matrix () 5924 callback_property oncallback , Matrix () 5925 bool_property separator , "off
" 5926 bool_property state , "off
" 5927 string_property tooltipstring , "" 5929 // Octave-specific properties 5930 any_property __object__ h , Matrix () 5936 cdata.add_constraint ("double"); 5937 cdata.add_constraint ("single
"); 5938 cdata.add_constraint (dim_vector (-1, -1, 3)); 5943 properties xproperties; 5946 uitoggletool (const graphics_handle& mh, const graphics_handle& p) 5947 : base_graphics_object (), xproperties (mh, p) 5950 ~uitoggletool (void) = default; 5952 base_properties& get_properties (void) { return xproperties; } 5954 const base_properties& get_properties (void) const { return xproperties; } 5956 bool valid_object (void) const { return true; } 5958 bool has_readonly_property (const caseless_str& pname) const 5960 bool retval = xproperties.has_readonly_property (pname); 5962 retval = base_properties::has_readonly_property (pname); 5968 // --------------------------------------------------------------------- 5971 get_property_from_handle (double handle, const std::string& property, 5972 const std::string& func); 5974 set_property_in_handle (double handle, const std::string& property, 5975 const octave_value& arg, const std::string& func); 5977 // --------------------------------------------------------------------- 5979 class graphics_event; 5986 friend class graphics_event; 5988 base_graphics_event (void) = default; 5990 virtual ~base_graphics_event (void) = default; 5992 virtual void execute (void) = 0; 6000 typedef void (*event_fcn) (void*); 6002 graphics_event (void) = default; 6004 graphics_event (base_graphics_event *new_rep) : rep (new_rep) { } 6006 graphics_event (const graphics_event&) = default; 6008 ~graphics_event (void) = default; 6010 graphics_event& operator = (const graphics_event&) = default; 6018 bool ok (void) const { return (rep != nullptr); } 6020 static graphics_event 6021 create_callback_event (const graphics_handle& h, 6022 const std::string& name, 6023 const octave_value& data = Matrix ()); 6025 static graphics_event 6026 create_callback_event (const graphics_handle& h, 6027 const octave_value& cb, 6028 const octave_value& data = Matrix ()); 6030 static graphics_event 6031 create_function_event (event_fcn fcn, void *data = nullptr); 6033 static graphics_event 6034 create_set_event (const graphics_handle& h, const std::string& name, 6035 const octave_value& value, 6036 bool notify_toolkit = true); 6039 std::shared_ptr <base_graphics_event> rep; 6042 class OCTINTERP_API gh_manager 6050 static void create_instance (void); 6052 static bool instance_ok (void) 6065 static void cleanup_instance (void) { delete instance; instance = nullptr; } 6067 static graphics_handle get_handle (bool integer_figure_handle) 6069 return instance_ok () 6070 ? instance->do_get_handle (integer_figure_handle) 6071 : graphics_handle (); 6074 static void free (const graphics_handle& h) 6077 instance->do_free (h); 6080 static void renumber_figure (const graphics_handle& old_gh, 6081 const graphics_handle& new_gh) 6084 instance->do_renumber_figure (old_gh, new_gh); 6087 static graphics_handle lookup (double val) 6089 return instance_ok () ? instance->do_lookup (val) : graphics_handle (); 6092 static graphics_handle lookup (const octave_value& val) 6094 return val.is_real_scalar () 6095 ? lookup (val.double_value ()) : graphics_handle (); 6098 static graphics_object get_object (double val) 6100 return get_object (lookup (val)); 6103 static graphics_object get_object (const graphics_handle& h) 6105 return instance_ok () ? instance->do_get_object (h) : graphics_object (); 6108 static graphics_handle 6109 make_graphics_handle (const std::string& go_name, 6110 const graphics_handle& parent, 6111 bool integer_figure_handle = false, 6112 bool do_createfcn = true, 6113 bool do_notify_toolkit = true) 6115 return instance_ok () 6116 ? instance->do_make_graphics_handle (go_name, parent, 6117 integer_figure_handle, 6118 do_createfcn, do_notify_toolkit) 6119 : graphics_handle (); 6122 static graphics_handle make_figure_handle (double val, 6123 bool do_notify_toolkit = true) 6125 return instance_ok () 6126 ? instance->do_make_figure_handle (val, do_notify_toolkit) 6127 : graphics_handle (); 6130 static void push_figure (const graphics_handle& h) 6133 instance->do_push_figure (h); 6136 static void pop_figure (const graphics_handle& h) 6139 instance->do_pop_figure (h); 6142 static graphics_handle current_figure (void) 6144 return instance_ok () 6145 ? instance->do_current_figure () : graphics_handle (); 6148 static Matrix handle_list (bool show_hidden = false) 6150 return instance_ok () 6151 ? instance->do_handle_list (show_hidden) : Matrix (); 6154 static void lock (void) 6157 instance->do_lock (); 6160 static bool try_lock (void) 6163 return instance->do_try_lock (); 6168 static void unlock (void) 6171 instance->do_unlock (); 6174 static Matrix figure_handle_list (bool show_hidden = false) 6176 return instance_ok () 6177 ? instance->do_figure_handle_list (show_hidden) : Matrix (); 6180 static void execute_listener (const graphics_handle& h, 6181 const octave_value& l) 6184 instance->do_execute_listener (h, l); 6187 static void execute_callback (const graphics_handle& h, 6188 const std::string& name, 6189 const octave_value& data = Matrix ()) 6195 gh_manager::auto_lock lock; 6197 graphics_object go = get_object (h); 6199 if (go.valid_object ()) 6203 execute_callback (h, cb, data); 6206 static void execute_callback (const graphics_handle& h, 6207 const octave_value& cb, 6208 const octave_value& data = Matrix ()) 6211 instance->do_execute_callback (h, cb, data); 6214 static void post_callback (const graphics_handle& h, 6215 const std::string& name, 6216 const octave_value& data = Matrix ()) 6219 instance->do_post_callback (h, name, data); 6222 static void post_function (graphics_event::event_fcn fcn, void *data = nullptr) 6225 instance->do_post_function (fcn, data); 6228 static void post_set (const graphics_handle& h, const std::string& name, 6229 const octave_value& value, bool notify_toolkit = true) 6232 instance->do_post_set (h, name, value, notify_toolkit); 6235 static int process_events (void) 6237 return (instance_ok () ? instance->do_process_events () : 0); 6240 static int flush_events (void) 6242 return (instance_ok () ? instance->do_process_events (true) : 0); 6245 static void enable_event_processing (bool enable = true) 6248 instance->do_enable_event_processing (enable); 6251 static bool is_handle_visible (const graphics_handle& h) 6253 bool retval = false; 6255 graphics_object go = get_object (h); 6257 if (go.valid_object ()) 6258 retval = go.is_handle_visible (); 6263 static void close_all_figures (void) 6266 instance->do_close_all_figures (); 6270 class auto_lock : public octave::autolock 6273 auto_lock (bool wait = true) 6274 : octave::autolock (instance_ok () 6275 ? instance->graphics_lock 6282 auto_lock (const auto_lock&) = delete; 6284 auto_lock& operator = (const auto_lock&) = delete; 6289 static gh_manager *instance; 6291 typedef std::map<graphics_handle, graphics_object>::iterator iterator; 6292 typedef std::map<graphics_handle, graphics_object>::const_iterator 6295 typedef std::set<graphics_handle>::iterator free_list_iterator; 6296 typedef std::set<graphics_handle>::const_iterator const_free_list_iterator; 6298 typedef std::list<graphics_handle>::iterator figure_list_iterator; 6299 typedef std::list<graphics_handle>::const_iterator const_figure_list_iterator; 6301 // A map of handles to graphics objects. 6302 std::map<graphics_handle, graphics_object> handle_map; 6304 // The available graphics handles. 6305 std::set<graphics_handle> handle_free_list; 6307 // The next handle available if handle_free_list is empty. 6310 // The allocated figure handles. Top of the stack is most recently 6312 std::list<graphics_handle> figure_list; 6314 // The lock for accessing the graphics sytsem. 6315 octave::mutex graphics_lock; 6317 // The list of events queued by graphics toolkits. 6318 std::list<graphics_event> event_queue; 6320 // The stack of callback objects. 6321 std::list<graphics_object> callback_objects; 6323 // A flag telling whether event processing must be constantly on. 6324 int event_processing; 6326 graphics_handle do_get_handle (bool integer_figure_handle); 6328 void do_free (const graphics_handle& h); 6330 void do_renumber_figure (const graphics_handle& old_gh, 6331 const graphics_handle& new_gh); 6333 graphics_handle do_lookup (double val) 6335 iterator p = (octave::math::isnan (val) ? handle_map.end () 6336 : handle_map.find (val)); 6338 return (p != handle_map.end ()) ? p->first : graphics_handle (); 6341 graphics_object do_get_object (const graphics_handle& h) 6343 iterator p = (h.ok () ? handle_map.find (h) : handle_map.end ()); 6345 return (p != handle_map.end ()) ? p->second : graphics_object (); 6348 graphics_handle do_make_graphics_handle (const std::string& go_name, 6349 const graphics_handle& p, 6350 bool integer_figure_handle, 6352 bool do_notify_toolkit); 6354 graphics_handle do_make_figure_handle (double val, bool do_notify_toolkit); 6356 Matrix do_handle_list (bool show_hidden) 6358 Matrix retval (1, handle_map.size ()); 6360 octave_idx_type i = 0; 6361 for (const auto& h_iter : handle_map) 6363 graphics_handle h = h_iter.first; 6365 if (show_hidden || is_handle_visible (h)) 6366 retval(i++) = h.value (); 6369 retval.resize (1, i); 6374 Matrix do_figure_handle_list (bool show_hidden) 6376 Matrix retval (1, figure_list.size ()); 6378 octave_idx_type i = 0; 6379 for (const auto& hfig : figure_list) 6381 if (show_hidden || is_handle_visible (hfig)) 6382 retval(i++) = hfig.value (); 6385 retval.resize (1, i); 6390 void do_push_figure (const graphics_handle& h); 6392 void do_pop_figure (const graphics_handle& h); 6394 graphics_handle do_current_figure (void) const 6396 graphics_handle retval; 6398 for (const auto& hfig : figure_list) 6400 if (is_handle_visible (hfig)) 6407 void do_lock (void) { graphics_lock.lock (); } 6409 bool do_try_lock (void) { return graphics_lock.try_lock (); } 6411 void do_unlock (void) { graphics_lock.unlock (); } 6413 void do_execute_listener (const graphics_handle& h, const octave_value& l); 6415 void do_execute_callback (const graphics_handle& h, const octave_value& cb, 6416 const octave_value& data); 6418 void do_post_callback (const graphics_handle& h, const std::string& name, 6419 const octave_value& data); 6421 void do_post_function (graphics_event::event_fcn fcn, void *fcn_data); 6423 void do_post_set (const graphics_handle& h, const std::string& name, 6424 const octave_value& value, bool notify_toolkit = true); 6426 int do_process_events (bool force = false); 6428 void do_close_all_figures (void); 6430 static void restore_gcbo (void) 6433 instance->do_restore_gcbo (); 6436 void do_restore_gcbo (void); 6438 void do_post_event (const graphics_event& e); 6440 void do_enable_event_processing (bool enable = true); 6443 void get_children_limits (double& min_val, double& max_val, 6444 double& min_pos, double& max_neg, 6445 const Matrix& kids, char limit_type); 6447 OCTINTERP_API int calc_dimensions (const graphics_object& gh); 6449 // This function is NOT equivalent to the scripting language function gcf. 6450 OCTINTERP_API graphics_handle gcf (void); 6452 // This function is NOT equivalent to the scripting language function gca. 6453 OCTINTERP_API graphics_handle gca (void); 6455 OCTINTERP_API void close_all_figures (void);
bool do_set(const octave_value &newval)
Matrix do_get_children(bool return_hidden) const
virtual std::string graphics_object_name(void) const
octave_idx_type rows(void) const
base_property * clone(void) const
virtual property_list get_defaults_list(void) const
base_property * clone(void) const
void warning_with_id(const char *id, const char *fmt,...)
OCTINTERP_API bool validate(const octave_value &v) const
plist_map_iterator find(const std::string &go_name)
color_property(const std::string &nm, const graphics_handle &h, const color_values &c=color_values(), const radio_values &v=radio_values())
void add_constraint(const std::string &type)
Matrix scale(const Matrix &m) const
void delete_listener(const octave_value &v=octave_value(), listener_mode mode=POSTSET)
OCTAVE_EXPORT octave_value_list column
virtual void reparent(const graphics_handle &np)
virtual std::string values_as_string(void) const
virtual double unscale(double) const
row_vector_property(const std::string &nm, const graphics_handle &h, const octave_value &m)
radio_values & operator=(const radio_values &a)
is already an absolute the name is checked against the file system instead of Octave s loadpath In this if otherwise an empty string is returned If the first argument is a cell array of search each directory of the loadpath for element of the cell array and return the first that matches If the second optional argument return a cell array containing the list of all files that have the same name in the path If no files are found
octave_base_value * internal_rep(void) const
bool compare(const std::string &s, size_t limit=std::string::npos) const
std::set< std::string > dynamic_properties
Matrix get_all(void) const
virtual bool is_linear(void) const
void add_constraint(const std::string &type, double val, bool inclusive)
text_label_property(const std::string &s, const graphics_handle &h, const NDArray &nda)
virtual bool is_zliminclude(void) const
void set_name(const std::string &name)
OCTINTERP_API bool validate(const octave_value &v)
virtual Matrix scale(const Matrix &) const
const std::string & current_value(void) const
virtual bool do_set(const octave_value &)
std::string string_value(void) const
color_property(const std::string &nm, const graphics_handle &h, const radio_values &v)
base_property * clone(void) const
double scale(double d) const
virtual bool is_yliminclude(void) const
std::set< std::string > type_constraints
property(base_property *bp, bool persist=false)
double_radio_property(const std::string &nm, const graphics_handle &h, const std::string &v)
color_property & operator=(const octave_value &val)
std::string values_as_string(void) const
std::string string_value(bool force=false) const
bool_property(const bool_property &p)
void erase(const std::string pname)
bool do_set(const octave_value &val)
const T * data(void) const
color_property(const radio_values &v, const color_values &c)
void do_scale(const double *src, double *dest, int n) const
Cell cell_value(void) const
radio_property & operator=(const octave_value &val)
finite_type finite_constraint
void insert_property(const std::string &name, property p)
octave_value & operator[](const std::string pname)
virtual void init_integerhandle(const octave_value &)
double scale(double d) const
double scale(double d) const
const_iterator find(const std::string pname) const
identity matrix If supplied two scalar respectively For allows like xample val
std::map< listener_mode, octave_value_list >::iterator listener_map_iterator
handle_property(const handle_property &p)
OCTINTERP_API bool do_set(const octave_value &v)
void add_constraint(const finite_type finite)
Return the CPU time used by your Octave session The first output is the total time spent executing your process and is equal to the sum of second and third which are the number of CPU seconds spent executing in user mode and the number of CPU seconds spent executing in system mode
base_property(const base_property &p)
OCTAVE_EXPORT octave_value_list or N dimensional array whose elements are all equal to the IEEE symbol zero divided by zero($0/0$)
std::pair< double, bool > maxval
graphics_handle get_parent(void) const
std::string values_as_string(void) const
virtual ~base_scaler(void)=default
color_values & operator=(const color_values &c)
plist_map_const_iterator find(const std::string &go_name) const
void set_hidden(bool flag)
void add_constraint(const std::string &type)
void set_parent(const graphics_handle &h)
double min_val(void) const
void reparent(const graphics_handle &new_parent)
OCTAVE_EXPORT octave_value_list or N dimensional array whose elements are all equal to the base of natural logarithms The constant ex $e satisfies the equation log(e)
bool operator!=(const color_values &c) const
OCTINTERP_API void run_listeners(listener_mode mode=POSTSET)
array_property(const std::string &nm, const graphics_handle &h, const octave_value &m)
graphics_handle handle_value(void) const
pval_map_type::const_iterator pval_map_const_iterator
plist_map_const_iterator end(void) const
void error(const char *fmt,...)
radio_property(const std::string &nm, const graphics_handle &h, const radio_values &v=radio_values())
bool is_hidden(void) const
bool is_linear(void) const
virtual bool is_xliminclude(void) const
bool_property & operator=(const octave_value &val)
std::set< std::string > type_constraints
pval_map_type::iterator pval_map_iterator
OCTINTERP_API bool str2rgb(const std::string &str)
property(const property &p)
bool contains(const std::string &val, std::string &match)
const dim_vector & dims(void) const
Return a const-reference so that dims ()(i) works efficiently.
base_property(const std::string &s, const graphics_handle &h)
radio_property(const std::string &nm, const graphics_handle &h, const std::string &v)
double double_value(void) const
base_property * clone(void) const
bool is_defined(void) const
numeric fields are padded if necessary Padding is with zeros by default
void add_listener(const octave_value &v, listener_mode mode=POSTSET)
void do_scale(const double *src, double *dest, int n) const
virtual octave_value get(void) const
bool is_modified(void) const
children_property(const std::string &nm, const graphics_handle &h, const Matrix &val)
enum double_radio_property::current_enum current_type
bool do_set(const octave_value &v)
string_array_property(const std::string &s, const graphics_handle &h, const Cell &c, const char &sep='|', const desired_enum &typ=string_t)
virtual void set_from_list(property_list &plist)
double_radio_property & operator=(const octave_value &val)
virtual base_property * clone(void) const
virtual bool is_aliminclude(void) const
const std::string & current_value(void) const
virtual void delete_children(bool clear=false)
std::pair< double, bool > minval
Matrix scale(const Matrix &m) const
color_values(const color_values &c)
nd example oindent opens the file binary numeric values will be read assuming they are stored in IEEE format with the least significant bit and then converted to the native representation Opening a file that is already open simply opens it again and returns a separate file id It is not an error to open a file several though writing to the same file through several different file ids may produce unexpected results The possible values of text mode reading and writing automatically converts linefeeds to the appropriate line end character for the you may append a you must also open the file in binary mode The parameter conversions are currently only supported for and permissions will be set to and then everything is written in a single operation This is very efficient and improves performance c
Matrix get_limits(void) const
virtual Matrix get_boundingbox(bool=false, const Matrix &=Matrix()) const
pval_vector pval_map_type
in this the arguments are accumulated from left to right
OCTAVE_EXPORT octave_value_list or class The return code an ordinary file in Octave s or(after appending @samp{.m}) a function file in Octave 's ode
bool is_defined(void) const
virtual octave_value get(bool all=false) const
children_property & operator=(const octave_value &val)
double max_neg(void) const
desired_enum desired_type
Matrix get_children(void) const
graphics_handle current_val
string_vector string_vector_value(void) const
Matrix get_hidden_children(void) const
double double_value(void) const
void resize(octave_idx_type n, const std::string &rfv="")
virtual void set(const caseless_str &pname, const octave_value &pval)
void renumber_child(graphics_handle old_gh, graphics_handle new_gh)
base_property * clone(void) const
void set_hidden(bool flag)
bool is(const std::string &v) const
color_values(const std::string &str)
bool is_hidden(void) const
void delete_listener(const octave_value &v=octave_value(), listener_mode mode=POSTSET)
bool validate(const std::string &val, std::string &match)
F77_RET_T const F77_REAL const F77_REAL F77_REAL &F77_RET_T const F77_DBLE const F77_DBLE F77_DBLE &F77_RET_T const F77_DBLE F77_DBLE &F77_RET_T const F77_REAL F77_REAL &F77_RET_T const F77_DBLE const F77_DBLE F77_DBLE * d
OCTINTERP_API bool do_set(const octave_value &newval)
text_label_property(const std::string &s, const graphics_handle &h, const Cell &c)
string_array_property(const string_array_property &p)
~property_list(void)=default
bool is_radio(void) const
bool do_set(const octave_value &v)
double_radio_property(const double_radio_property &p)
bool_property(const std::string &nm, const graphics_handle &h, bool val)
color_property(const std::string &nm, const graphics_handle &h, const color_property &v)
std::set< caseless_str > possible_vals
octave_idx_type cols(void) const
virtual octave_value get_alim(void) const
string_array_property & operator=(const octave_value &val)
std::list< dim_vector > size_constraints
bool do_set(const octave_value &v)
const octave_base_value & a2
calling an anonymous function involves an overhead quite comparable to the overhead of an m file function Passing a handle to a built in function is because the interpreter is not involved in the internal loop For a
any_property(const any_property &p)
virtual void adopt(const graphics_handle &h)
callback_property & operator=(const octave_value &val)
text_label_property & operator=(const octave_value &val)
Array< T > sort(int dim=0, sortmode mode=ASCENDING) const
void do_adopt_child(double val)
octave_value lookup(const std::string pname) const
std::list< double > children_list
finite_type finite_constraint
virtual property_list get_factory_defaults_list(void) const
base_property * clone(void) const
double unscale(double d) const
virtual graphics_toolkit get_toolkit(void) const
any_property & operator=(const octave_value &val)
double scale(double d) const
nd deftypefn *std::string name
text_label_property(const text_label_property &p)
OCTAVE_EXPORT octave_value_list isdir nd deftypefn *std::string nm
bool_property(const std::string &nm, const graphics_handle &h, const char *val)
MArray< T > reshape(const dim_vector &new_dims) const
scaler & operator=(const scaler &s)
base_property * clone(void) const
std::list< double >::iterator children_list_iterator
color_values(double r=0, double g=0, double b=1)
void delete_children(bool clear=false)
property & operator=(const octave_value &val)
virtual bool has_property(const caseless_str &) const
std::string values_as_string(void) const
base_property * clone(void) const
void add_constraint(const finite_type finite)
color_property(const std::string &nm, const graphics_handle &h, const std::string &v)
OCTINTERP_API void execute(const octave_value &data=octave_value()) const
plist_map_iterator end(void)
virtual octave_value get_xlim(void) const
void add_constraint(const std::string &type, double val, bool inclusive)
std::map< listener_mode, octave_value_list > listener_map
Cell cell_value(void) const
NDArray scale(const NDArray &m) const
virtual void adopt(const graphics_handle &h)
virtual NDArray scale(const NDArray &) const
std::string get_name(void) const
bool do_set(const octave_value &v)
void do_delete_children(bool clear)
void renumber(graphics_handle old_gh, graphics_handle new_gh)
property_list(const plist_map_type &m=plist_map_type())
write the output to stdout if nargout otherwise return the output in a character string able ode tem append Append to the destination instead of overwriting tem ascii Save a matrix in a text file without a header or any other information The matrix must be D and only the real part of any complex value is written to the file Numbers are stored in single precision format and separated by spaces Additional options for the and gzip can also be used to convert the files for backward compatibility This option is only available if Octave was built with a link to the zlib libraries end table The list of variables to save may use wildcard patterns containing the following special characters
octave_idx_type nelem(void) const
octave_value as_octave_value(void) const
dim_vector dims(void) const
iterator find(const std::string pname)
void set___modified__(const octave_value &val)
void add_constraint(const dim_vector &dims)
string_vector & append(const std::string &s)
std::string string_value(void) const
callback_property(const std::string &nm, const graphics_handle &h, const octave_value &m)
bool is_linear(void) const
virtual octave_value get_ylim(void) const
virtual double scale(double) const
octave_int< T > pow(const octave_int< T > &a, const octave_int< T > &b)
bool do_set(const octave_value &val)
bool issparse(void) const
handle_property(const std::string &nm, const graphics_handle &h, const graphics_handle &val=graphics_handle())
#define panic_impossible()
void do_init_children(const Matrix &val)
base_property * clone(void) const
virtual void remove_child(const graphics_handle &h)
virtual base_properties & get_properties(void)
virtual graphics_handle get_parent(void) const
double unscale(double d) const
NDArray scale(const NDArray &m) const
virtual void remove_child(const graphics_handle &h)
bool is_radio(void) const
std::string string_value(void) const
void set_parent(const graphics_handle &h)
virtual bool is_radio(void) const
double unscale(double d) const
graphics_handle get_handle(void) const
void renumber_parent(graphics_handle new_gh)
Matrix do_get_all_children(void) const
virtual bool is_climinclude(void) const
graphics_handle get_parent(void) const
ColumnVector cross(const ColumnVector &v1, const ColumnVector &v2)
is already an absolute the name is checked against the file system instead of Octave s loadpath In this if otherwise an empty string is returned If the first argument is a cell array of strings
the exceeded dimensions are set to if fewer subscripts than dimensions are the exceeding dimensions are merged into the final requested dimension For consider the following dims
callback_property(const callback_property &p)
double unscale(double d) const
OCTINTERP_API radio_values(const std::string &opt_string="")
virtual octave_value get_zlim(void) const
row_vector_property(const row_vector_property &p)
Matrix scale(const Matrix &m) const
double_property(const double_property &p)
octave_scalar_map as_struct(const std::string &prefix_arg) const
any_property(const std::string &nm, const graphics_handle &h, const octave_value &m=Matrix())
base_property * clone(void) const
std::list< double >::const_iterator const_children_list_iterator
bool operator==(const color_values &c) const
double min_pos(void) const
Matrix get_all_children(void) const
Cell values_as_cell(void) const
string_property(const string_property &p)
virtual void set_defaults(const std::string &)
base_scaler * clone(void) const
string_property(const std::string &s, const graphics_handle &h, const std::string &val="")
octave_value reshape(const dim_vector &dv) const
octave::unwind_protect frame
array_property & operator=(const octave_value &val)
return octave_value(v1.char_array_value() . concat(v2.char_array_value(), ra_idx),((a1.is_sq_string()||a2.is_sq_string()) ? '\'' :'"'))
OCTINTERP_API bool validate(const octave_value &v)
charNDArray max(char d, const charNDArray &m)
std::map< listener_mode, octave_value_list >::const_iterator listener_map_const_iterator
void run_listeners(listener_mode mode=POSTSET)
bool do_set(const octave_value &val)
Array< std::string > cellstr_value(void) const
std::pair< double, bool > maxval
Cell values_as_cell(void) const
void add_listener(const octave_value &v, listener_mode mode=POSTSET)
virtual octave_value get_factory_defaults(void) const
enum color_property::current_enum current_type
double_radio_property(const std::string &nm, const graphics_handle &h, const double_radio_property &v)
NDArray scale(const NDArray &m) const
void add_constraint(const dim_vector &dims)
string_property & operator=(const octave_value &val)
double max_val(void) const
std::string row_as_string(octave_idx_type, bool strip_ws=false) const
Matrix get_children(void) const
radio_values(const radio_values &a)
std::map< std::string, pval_map_type > plist_map_type
OCTAVE_EXPORT octave_value_list or N dimensional array whose elements are all equal to the IEEE symbol NaN(Not a Number). NaN is the result of operations which do not produce a well defined 0 result. Common operations which produce a NaN are arithmetic with infinity ex($\infty - \infty$)
bool remove_child(double val)
std::string default_value(void) const
double_property & operator=(const octave_value &val)
OCTINTERP_API bool is_equal(const octave_value &v) const
static OCTINTERP_API property create(const std::string &name, const graphics_handle &parent, const caseless_str &type, const octave_value_list &args)
Matrix get_hidden(void) const
OCTINTERP_API bool set(const octave_value &v, bool do_run=true, bool do_notify_toolkit=true)
virtual base_scaler * clone() const
octave_value full_value(void) const
OCTAVE_EXPORT octave_value_list single and double will be bytes and bytes respectively the return value is a row vector
bool is_radio(void) const
bool is_radio(void) const
plist_map_iterator begin(void)
octave_value lookup(const caseless_str &name) const
handle_property & operator=(const octave_value &val)
void add_constraint(const finite_type finite)
double_radio_property(double d, const radio_values &v)
virtual octave_value get_defaults(void) const
virtual void mark_modified(void)
bool is(const caseless_str &v) const
double double_value(bool frc_str_conv=false) const
octave_idx_type length(void) const
defaults to zero A value of zero computes the digamma a value of
base_property * clone(void) const
base_property * clone(void) const
virtual octave_value get_clim(void) const
void set_name(const std::string &s)
property clone(void) const
octave::refcount< int > count
radio_property(const radio_property &p)
void resize(octave_idx_type n, const octave_value &rfv=octave_value())
base_property * clone(void) const
radio_property(const std::string &nm, const graphics_handle &h, const radio_values &v, const std::string &def)
array_property(const array_property &p)
std::pair< double, bool > minval
charMatrix char_value(void) const
void add_constraint(const std::string &type)
Cell values_as_cell(void) const
bool is_string(void) const
base_property * clone(void) const
base_scaler * clone(void) const
color_property(const color_values &c, const radio_values &v)
Matrix scale(const Matrix &m) const
virtual void override_defaults(base_graphics_object &obj)
base_scaler * clone(void) const
void add_constraint(octave_idx_type len)
NDArray scale(const NDArray &m) const
void set_modified(const octave_value &val)
void add_constraint(const std::string &type, double val, bool inclusive)
base_property & operator=(const octave_value &val)
octave_idx_type numel(void) const
Number of elements in the array.
bool do_set(const octave_value &val)
ColumnVector real(const ComplexColumnVector &a)
write the output to stdout if nargout is
bool is_double(void) const
Vector representing the dimensions (size) of an Array.
row_vector_property & operator=(const octave_value &val)
bool do_remove_child(double child)
std::string values_as_string(void) const
void validate(void) const
virtual ~base_property(void)=default
string_array_property(const std::string &s, const graphics_handle &h, const std::string &val="", const char &sep='|', const desired_enum &typ=string_t)
If this string is the system will ring the terminal sometimes it is useful to be able to print the original representation of the string
plist_map_const_iterator begin(void) const
text_label_property(const std::string &s, const graphics_handle &h, const std::string &val="")
void set_tag(const octave_value &val)
scaler(const std::string &s)
bool do_set(const octave_value &v)
bool do_set(const octave_value &val)
BEGIN_BASE_PROPERTIES bool_property off radio_property busyaction
children_property(const children_property &p)
std::string get_name(void) const
bool is_scalar_type(void) const
static bool is_handle_visible(const graphics_handle &h)
virtual Cell values_as_cell(void) const
plist_map_type::const_iterator plist_map_const_iterator
const std::string & current_value(void) const
where the brackets indicate optional arguments and and character or cell array For character arrays the conversion is repeated for every row
string_vector string_vector_value(void) const
Cell values_as_cell(void) const
F77_RET_T const F77_REAL const F77_REAL F77_REAL &F77_RET_T const F77_DBLE const F77_DBLE F77_DBLE &F77_RET_T const F77_DBLE F77_DBLE &F77_RET_T const F77_REAL F77_REAL &F77_RET_T const F77_DBLE * x
double_property(const std::string &nm, const graphics_handle &h, double d=0)
color_property(const color_property &p)
charNDArray min(char d, const charNDArray &m)
void do_init_children(const std::list< double > &val)
OCTINTERP_API bool do_set(const octave_value &v)
OCTINTERP_API void get_data_limits(void)
std::pair< std::string, octave_value > pval_pair
bool is(const std::string &v) const
plist_map_type::iterator plist_map_iterator