26 #if ! defined (octave_graphics_h)
27 #define octave_graphics_h 1
29 #include "octave-config.h"
57 #if ! defined (OCTAVE_DEFAULT_FONTNAME)
58 #define OCTAVE_DEFAULT_FONTNAME "*"
72 error (
"invalid axis scale");
77 error (
"invalid axis scale");
80 virtual double scale (
double)
const
82 error (
"invalid axis scale");
87 error (
"invalid axis scale");
139 {
return log10 (
d); }
148 void do_scale (
const double *src,
double *dest,
int n)
const
150 for (
int i = 0; i <
n; i++)
151 dest[i] = log10 (src[i]);
179 {
return -log10 (-
d); }
188 void do_scale (
const double *src,
double *dest,
int n)
const
190 for (
int i = 0; i <
n; i++)
191 dest[i] = -log10 (-src[i]);
255 else if (s ==
"neglog")
257 else if (s ==
"linear")
315 virtual bool is_radio (
void)
const {
return false; }
324 bool do_notify_toolkit =
true);
328 error (R
"(get: invalid property "%s")", name.c_str ());
333 error (R
"(values_as_string: invalid property "%s")", name.c_str ());
338 error (R
"(values_as_cell: invalid property "%s")", name.c_str ());
363 for (i = 0; i < l.
length (); i++)
365 if (v.internal_rep () == l(i).internal_rep ())
373 for (
int j = i; j < l.
length () - 1; j++)
387 for (
int i = l.
length () - 1; i >= 0 ; i--)
389 for (
int j = 0; j < lp.
length (); j++)
391 if (l(i).internal_rep () == lp(j).internal_rep ())
412 error (R
"(set: invalid property "%s")", name.c_str ());
417 typedef std::map<listener_mode, octave_value_list>::iterator
419 typedef std::map<listener_mode, octave_value_list>::const_iterator
437 const std::string& val =
"")
460 error (R
"(set: invalid string property value for "%s")",
485 const std::string& val =
"",
const char& sep =
'|',
493 size_t new_pos = val.find_first_of (
separator, pos);
495 if (new_pos == std::string::npos)
501 str.
append (val.substr (pos, new_pos - pos));
508 const Cell& c,
const char& sep =
'|',
513 error (R
"(set: invalid order property value for "%s")",
519 strings[i] = c(i).string_value ();
568 bool replace =
false;
574 while (pos != std::string::npos)
576 size_t new_pos = new_str.find_first_of (
separator, pos);
578 if (new_pos == std::string::npos)
580 strings.
append (new_str.substr (pos));
584 strings.
append (new_str.substr (pos, new_pos - pos));
592 if (strings[i] !=
str[i])
611 bool replace =
false;
621 if (! replace && strings[i] !=
str[i])
635 bool replace =
false;
648 if (strings[i] !=
str[i])
665 error (R
"(set: invalid string property value for "%s")",
685 const std::string& val =
"")
699 std::ostringstream buf;
701 value[i] = buf.str ();
718 value[i] = c(i).string_value ();
721 double d = c(i).double_value ();
723 std::ostringstream buf;
725 value[i] = buf.str ();
790 value[i] = c(i).string_value ();
793 double d = c(i).double_value ();
795 std::ostringstream buf;
797 value[i] = buf.str ();
811 catch (octave::execution_exception& e)
813 error (e, R
"(set: invalid string property value for "%s")",
823 std::ostringstream buf;
825 value[i] = buf.str ();
844 OCTINTERP_API
radio_values (
const std::string& opt_string =
"");
862 bool validate (
const std::string& val, std::string& match)
867 error (
"invalid value = %s", val.c_str ());
872 bool contains (
const std::string& val, std::string& match)
876 size_t len = val.length ();
878 std::string first_match;
882 if (possible_val.compare (val,
len))
884 if (
len == possible_val.length ())
889 match = possible_val;
895 first_match = possible_val;
932 const std::string& v)
969 error (R
"(set: invalid value for radio property "%s")",
977 error (R
"(set: invalid value for radio property "%s" (value = %s))",
982 if (s.length () != match.length ())
984 "%s: allowing %s to match %s value %s",
985 "set", s.c_str (),
get_name ().c_str (),
1017 error (
"invalid color specification: %s", str.c_str ());
1040 {
return ! (*
this == c); }
1048 for (
int i = 0; i < 3; i++)
1051 error (
"invalid RGB color specification");
1058 OCTINTERP_API
bool str2rgb (
const std::string& str);
1092 const std::string& v)
1122 bool is (
const std::string& v)
const
1128 error (
"color has no RGB value");
1136 error (
"color has no radio value");
1215 minval = std::pair<double, bool> (val, inclusive);
1216 else if (
type ==
"max")
1217 maxval = std::pair<double, bool> (val, inclusive);
1227 error (R
"(set: invalid value for double property "%s")",
1236 error (R
"(set: "%s" must be greater than or equal to %g)",
1239 error (R
"(set: "%s" must be greater than %g)",
1246 error (R
"(set: "%s" must be less than or equal to %g)",
1249 error (R
"(set: "%s" must be less than %g)",
1257 error (R
"(set: "%s" must be finite)", get_name ().c_str ());
1262 error (R
"(set: "%s" must not be nan)", get_name ().c_str ());
1267 error (R
"(set: "%s" must not be infinite)", get_name ().c_str ());
1297 const std::string& v)
1327 bool is (
const std::string& v)
const
1341 error (
"%s: property has no radio value",
get_name ().c_str ());
1418 minval = std::pair<double, bool> (val, inclusive);
1419 else if (
type ==
"max")
1420 maxval = std::pair<double, bool> (val, inclusive);
1465 error (R
"(invalid value for array property "%s")",
1576 if (dv(0) > 1 && dv(1) == 1)
1605 "{on}|off" :
"on|{off}"), val)
1780 if (hchild == old_gh)
1782 hchild = new_gh.
value ();
1787 error (
"children_list::renumber: child not found!");
1804 catch (octave::execution_exception& e)
1806 error (e,
"set: children must be an array of graphics handles");
1814 bool add_hidden =
true;
1818 if (visible_kids.
numel () == new_kids.
numel ())
1834 error (
"set: new children must be a permutation of existing children");
1836 Matrix tmp = new_kids_column;
1933 error (R
"(invalid value for callback property "%s")",
1971 {
return rep->
ok (); }
2004 bool do_notify_toolkit =
true)
2005 {
return rep->
set (val, do_run, do_notify_toolkit); }
2040 OCTINTERP_API
static
2079 const_iterator
find (
const std::string pname)
const
2083 for (it = (*this).begin (); it != (*this).end (); it++)
2084 if (pname == (*it).first)
2087 return (*this).end ();
2090 iterator
find (
const std::string pname)
2094 for (it = (*this).begin (); it != (*this).end (); it++)
2095 if (pname == (*it).first)
2098 return (*this).end ();
2105 const_iterator it =
find (pname);
2107 if (it != (*this).end ())
2115 iterator it =
find (pname);
2117 if (it == (*this).end ())
2120 return (*this).back ().second;
2123 return (*it).second;
2128 iterator it =
find (pname);
2129 if (it != (*this).end ())
2135 std::vector<pval_pair>::erase (it);
2199 void mark_modified (
void);
2217 all_props[
name] = p;
2251 if (children.remove_child (h.
value ()))
2253 children.run_listeners ();
2260 children.adopt (h.
value ());
2261 children.run_listeners ();
2270 {
return Matrix (1, 4, 0.0); }
2272 virtual void update_boundingbox (
void);
2274 virtual void update_autopos (
const std::string& elem_type);
2284 beingdeleted.set (val,
true,
false);
2285 update_beingdeleted ();
2294 return children.get_children ();
2299 return children.get_all ();
2304 return children.get_hidden ();
2309 std::list<graphics_object> &children_list)
const;
2320 virtual void update_axis_limits (
const std::string& axis_type)
const;
2322 virtual void update_axis_limits (
const std::string& axis_type,
2325 virtual void update_uicontextmenu (
void)
const;
2329 children.delete_children (clear, from_root);
2334 children.renumber (old_gh, new_gh);
2363 std::set<std::string> dynamic_property_names (
void)
const;
2365 bool has_dynamic_property (
const std::string& pname)
const;
2376 property get_property_dynamic (
const caseless_str& pname)
const;
2378 BEGIN_BASE_PROPERTIES
2388 bool_property hittest , "on
"
2389 bool_property interruptible , "on
"
2390 handle_property parent fs , p
2391 radio_property pickableparts , "{visible}|all|none
"
2392 bool_property selected , "off
"
2393 bool_property selectionhighlight , "on
"
2394 string_property tag s , ""
2395 string_property type frs , ty
2396 handle_property uicontextmenu u , graphics_handle ()
2397 any_property userdata , Matrix ()
2398 bool_property visible u , "on
"
2400 // Octave-specific properties
2401 any_property __appdata__ h , Matrix ()
2402 bool_property __modified__ hs , "on
"
2403 graphics_handle __myhandle__ fhrs , mh
2406 virtual void update_beingdeleted (void) { };
2408 virtual void update_handlevisibility (void);
2410 virtual void update_visible (void) { };
2413 struct cmp_caseless_str
2415 bool operator () (const caseless_str& a, const caseless_str& b) const
2418 std::transform (a1.begin (), a1.end (), a1.begin (), tolower);
2420 std::transform (b1.begin (), b1.end (), b1.begin (), tolower);
2426 std::map<caseless_str, property, cmp_caseless_str> all_props;
2429 void insert_static_property (const std::string& name, base_property& p)
2430 { insert_property (name, property (&p, true)); }
2432 virtual void init (void)
2438 class OCTINTERP_API base_graphics_object
2441 friend class graphics_object;
2443 base_graphics_object (void) : toolkit_flag (false) { }
2447 base_graphics_object (const base_graphics_object&) = delete;
2449 base_graphics_object& operator = (const base_graphics_object&) = delete;
2451 virtual ~base_graphics_object (void) = default;
2453 virtual void mark_modified (void)
2455 if (! valid_object ())
2458 get_properties ().mark_modified ();
2461 virtual void override_defaults (base_graphics_object& obj)
2463 if (! valid_object ())
2465 get_properties ().override_defaults (obj);
2468 void build_user_defaults_map (property_list::pval_map_type& def,
2469 const std::string go_name) const;
2471 virtual void set_from_list (property_list& plist)
2473 if (! valid_object ())
2476 get_properties ().set_from_list (*this, plist);
2479 virtual void set (const caseless_str& pname, const octave_value& pval)
2481 if (! valid_object ())
2484 get_properties ().set (pname, pval);
2487 virtual void set_defaults (const std::string&)
2492 // The following version of the get method is not declared virtual
2493 // because no derived class overrides it.
2495 octave_value get (bool all = false) const
2497 if (! valid_object ())
2500 return get_properties ().get (all);
2503 virtual octave_value get (const caseless_str& pname) const
2505 if (! valid_object ())
2508 return get_properties ().get (pname);
2511 virtual octave_value get_default (const caseless_str&) const;
2513 virtual octave_value get_factory_default (const caseless_str&) const;
2515 virtual octave_value get_defaults (void) const
2520 virtual property_list get_defaults_list (void) const
2522 if (! valid_object ())
2525 return property_list ();
2528 virtual octave_value get_factory_defaults (void) const
2533 virtual property_list get_factory_defaults_list (void) const
2538 virtual bool has_readonly_property (const caseless_str& pname) const
2540 return base_properties::has_readonly_property (pname);
2543 // FIXME: It seems like this function should be const, but that is
2544 // currently not possible.
2545 virtual std::string values_as_string (void);
2547 // FIXME: It seems like this function should be const, but that is
2548 // currently not possible.
2549 virtual std::string value_as_string (const std::string& prop);
2551 // FIXME: It seems like this function should be const, but that is
2552 // currently not possible.
2553 virtual octave_scalar_map values_as_struct (void);
2555 virtual graphics_handle get_parent (void) const
2557 if (! valid_object ())
2560 return get_properties ().get_parent ();
2563 graphics_handle get_handle (void) const
2565 if (! valid_object ())
2568 return get_properties ().get___myhandle__ ();
2571 virtual void remove_child (const graphics_handle& h, bool from_root = false)
2573 if (! valid_object ())
2576 get_properties ().remove_child (h, from_root);
2579 virtual void adopt (const graphics_handle& h)
2581 if (! valid_object ())
2584 get_properties ().adopt (h);
2587 virtual void reparent (const graphics_handle& np)
2589 if (! valid_object ())
2592 get_properties ().reparent (np);
2595 virtual void defaults (void) const
2597 if (! valid_object ())
2598 error ("base_graphics_object::default: invalid graphics
object");
2600 std::string msg = (type () + "::defaults
");
2601 err_not_implemented (msg.c_str ());
2604 virtual base_properties& get_properties (void)
2606 static base_properties properties;
2611 virtual const base_properties& get_properties (void) const
2613 static base_properties properties;
2618 virtual void update_axis_limits (const std::string& axis_type);
2620 virtual void update_axis_limits (const std::string& axis_type,
2621 const graphics_handle& h);
2623 virtual bool valid_object (void) const { return false; }
2625 bool valid_toolkit_object (void) const { return toolkit_flag; }
2627 virtual std::string type (void) const
2629 return (valid_object () ? get_properties ().graphics_object_name ()
2633 bool isa (const std::string& go_name) const
2635 return type () == go_name;
2638 virtual octave::graphics_toolkit get_toolkit (void) const
2640 if (! valid_object ())
2643 return get_properties ().get_toolkit ();
2646 virtual void add_property_listener (const std::string& nm,
2647 const octave_value& v,
2648 listener_mode mode = GCB_POSTSET)
2650 if (valid_object ())
2651 get_properties ().add_listener (nm, v, mode);
2654 virtual void delete_property_listener (const std::string& nm,
2655 const octave_value& v,
2656 listener_mode mode = GCB_POSTSET)
2658 if (valid_object ())
2659 get_properties ().delete_listener (nm, v, mode);
2662 virtual void remove_all_listeners (void);
2664 virtual void reset_default_properties (void);
2667 virtual void initialize (const graphics_object& go)
2670 toolkit_flag = get_toolkit ().initialize (go);
2673 virtual void finalize (const graphics_object& go)
2677 get_toolkit ().finalize (go);
2678 toolkit_flag = false;
2682 virtual void update (const graphics_object& go, int id)
2685 get_toolkit ().update (go, id);
2690 // A flag telling whether this object is a valid object
2691 // in the backend context.
2695 class OCTINTERP_API graphics_object
2699 graphics_object (void) : rep (new base_graphics_object ()) { }
2701 graphics_object (base_graphics_object *new_rep) : rep (new_rep) { }
2703 graphics_object (const graphics_object&) = default;
2705 graphics_object& operator = (const graphics_object&) = default;
2707 ~graphics_object (void) = default;
2709 void mark_modified (void) { rep->mark_modified (); }
2711 void override_defaults (base_graphics_object& obj)
2713 rep->override_defaults (obj);
2716 void override_defaults (void)
2718 rep->override_defaults (*rep);
2721 void build_user_defaults_map (property_list::pval_map_type& def,
2722 const std::string go_name) const
2724 rep->build_user_defaults_map (def, go_name);
2727 void set_from_list (property_list& plist) { rep->set_from_list (plist); }
2729 void set (const caseless_str& name, const octave_value& val)
2731 rep->set (name, val);
2734 void set (const octave_value_list& args);
2736 void set (const Array<std::string>& names, const Cell& values,
2737 octave_idx_type row);
2739 void set (const octave_map& m);
2741 void set_value_or_default (const caseless_str& name,
2742 const octave_value& val);
2744 void set_defaults (const std::string& mode) { rep->set_defaults (mode); }
2746 octave_value get (bool all = false) const { return rep->get (all); }
2748 octave_value get (const caseless_str& name) const
2750 return name.compare ("default")
2752 : (name.compare ("factory
")
2753 ? get_factory_defaults () : rep->get (name));
2756 octave_value get (const std::string& name) const
2758 return get (caseless_str (name));
2761 octave_value get (const char *name) const
2763 return get (caseless_str (name));
2766 octave_value get_default (const caseless_str& name) const
2768 return rep->get_default (name);
2771 octave_value get_factory_default (const caseless_str& name) const
2773 return rep->get_factory_default (name);
2776 octave_value get_defaults (void) const { return rep->get_defaults (); }
2778 property_list get_defaults_list (void) const
2780 return rep->get_defaults_list ();
2783 octave_value get_factory_defaults (void) const
2785 return rep->get_factory_defaults ();
2788 property_list get_factory_defaults_list (void) const
2790 return rep->get_factory_defaults_list ();
2793 bool has_readonly_property (const caseless_str& pname) const
2795 return rep->has_readonly_property (pname);
2798 // FIXME: It seems like this function should be const, but that is
2799 // currently not possible.
2800 std::string values_as_string (void) { return rep->values_as_string (); }
2802 // FIXME: It seems like this function should be const, but that is
2803 // currently not possible.
2804 std::string value_as_string (const std::string& prop)
2806 return rep->value_as_string (prop);
2809 // FIXME: It seems like this function should be const, but that is
2810 // currently not possible.
2811 octave_map values_as_struct (void) { return rep->values_as_struct (); }
2813 graphics_handle get_parent (void) const { return rep->get_parent (); }
2815 graphics_handle get_handle (void) const { return rep->get_handle (); }
2817 graphics_object get_ancestor (const std::string& type) const;
2819 void remove_child (const graphics_handle& h) { rep->remove_child (h); }
2821 void adopt (const graphics_handle& h) { rep->adopt (h); }
2823 void reparent (const graphics_handle& h) { rep->reparent (h); }
2825 void defaults (void) const { rep->defaults (); }
2827 bool isa (const std::string& go_name) const { return rep->isa (go_name); }
2829 base_properties& get_properties (void) { return rep->get_properties (); }
2831 const base_properties& get_properties (void) const
2833 return rep->get_properties ();
2836 void update_axis_limits (const std::string& axis_type)
2838 rep->update_axis_limits (axis_type);
2841 void update_axis_limits (const std::string& axis_type,
2842 const graphics_handle& h)
2844 rep->update_axis_limits (axis_type, h);
2847 bool valid_object (void) const { return rep->valid_object (); }
2849 std::string type (void) const { return rep->type (); }
2851 operator bool (void) const { return rep->valid_object (); }
2853 // FIXME: These functions should be generated automatically by the
2854 // genprops.awk script.
2856 // EMIT_GRAPHICS_OBJECT_GET_FUNCTIONS
2858 octave_value get_alim (void) const
2859 { return get_properties ().get_alim (); }
2861 octave_value get_clim (void) const
2862 { return get_properties ().get_clim (); }
2864 octave_value get_xlim (void) const
2865 { return get_properties ().get_xlim (); }
2867 octave_value get_ylim (void) const
2868 { return get_properties ().get_ylim (); }
2870 octave_value get_zlim (void) const
2871 { return get_properties ().get_zlim (); }
2873 bool is_aliminclude (void) const
2874 { return get_properties ().is_aliminclude (); }
2876 bool is_climinclude (void) const
2877 { return get_properties ().is_climinclude (); }
2879 bool is_xliminclude (void) const
2880 { return get_properties ().is_xliminclude (); }
2882 bool is_yliminclude (void) const
2883 { return get_properties ().is_yliminclude (); }
2885 bool is_zliminclude (void) const
2886 { return get_properties ().is_zliminclude (); }
2888 bool is_handle_visible (void) const
2889 { return get_properties ().is_handle_visible (); }
2891 octave::graphics_toolkit get_toolkit (void) const { return rep->get_toolkit (); }
2893 void add_property_listener (const std::string& nm, const octave_value& v,
2894 listener_mode mode = GCB_POSTSET)
2895 { rep->add_property_listener (nm, v, mode); }
2897 void delete_property_listener (const std::string& nm, const octave_value& v,
2898 listener_mode mode = GCB_POSTSET)
2899 { rep->delete_property_listener (nm, v, mode); }
2901 void remove_all_listeners (void) { rep->remove_all_listeners (); }
2903 void initialize (void) { rep->initialize (*this); }
2905 void finalize (void) { rep->finalize (*this); }
2907 void update (int id) { rep->update (*this, id); }
2909 void reset_default_properties (void)
2910 { rep->reset_default_properties (); }
2914 std::shared_ptr<base_graphics_object> rep;
2917 // ---------------------------------------------------------------------
2919 class OCTINTERP_API root_figure : public base_graphics_object
2923 // The gh_manager constructor creates the single instance of
2924 // the root_figure object.
2926 friend class gh_manager;
2928 class OCTINTERP_API properties : public base_properties
2931 void remove_child (const graphics_handle& h, bool from_root = false);
2933 Matrix get_boundingbox (bool internal = false,
2934 const Matrix& parent_pix_size = Matrix ()) const;
2936 // See the genprops.awk script for an explanation of the
2937 // properties declarations.
2939 // FIXME: Properties that still don't have callbacks are:
2940 // monitorpositions, pointerlocation, pointerwindow.
2941 // Note that these properties are not yet used by Octave, so setting
2942 // them will have no effect.
2944 // FIXME: The commandwindowsize property has been deprecated in Matlab
2945 // and is now available through matlab.desktop.comandwindow.size.
2946 // Until Octave has something similar, keep this property in root.
2948 // Programming note: Keep property list sorted if new ones are added.
2950 BEGIN_PROPERTIES (root_figure, root)
2951 handle_property callbackobject Sr , graphics_handle ()
2952 array_property commandwindowsize r , Matrix (1, 2, 0)
2953 handle_property currentfigure S , graphics_handle ()
2954 string_property fixedwidthfontname , "Courier
"
2955 array_property monitorpositions r , default_screensize ()
2956 array_property pointerlocation , Matrix (1, 2, 0)
2957 double_property pointerwindow r , 0.0
2958 double_property screendepth r , default_screendepth ()
2959 double_property screenpixelsperinch r , default_screenpixelsperinch ()
2960 array_property screensize r , default_screensize ()
2961 bool_property showhiddenhandles , "off
"
2962 radio_property units U , "{pixels}|inches|centimeters|points|normalized|characters
"
2963 // Hide base properties which don't make sense for root object
2964 //radio_property beingdeleted h , "{off}|on
"
2970 properties xproperties;
2975 : xproperties (0, graphics_handle ()), default_properties (),
2976 factory_properties (init_factory_properties ())
2981 ~root_figure (void) = default;
2983 root_figure (const root_figure&) = delete;
2985 root_figure& operator = (const root_figure&) = delete;
2987 void mark_modified (void) { }
2989 void override_defaults (base_graphics_object& obj)
2991 // Now override with our defaults. If the default_properties
2992 // list includes the properties for all defaults (line,
2993 // surface, etc.) then we don't have to know the type of OBJ
2994 // here, we just call its set function and let it decide which
2995 // properties from the list to use.
2996 obj.set_from_list (default_properties);
2999 void set (const caseless_str& name, const octave_value& value)
3001 if (name.compare ("default", 7))
3002 // strip "default", pass rest to function that will
3003 // parse the remainder and add the element to the
3004 // default_properties map.
3005 default_properties.set (name.substr (7), value);
3007 xproperties.set (name, value);
3010 octave_value get (const caseless_str& name) const
3012 octave_value retval;
3014 if (name.compare ("default", 7))
3015 return get_default (name.substr (7));
3016 else if (name.compare ("factory
", 7))
3017 return get_factory_default (name.substr (7));
3019 retval = xproperties.get (name);
3024 octave_value get_default (const caseless_str& name) const
3026 octave_value retval = default_properties.lookup (name);
3028 if (retval.is_undefined ())
3030 // no default property found, use factory default
3031 retval = factory_properties.lookup (name);
3033 if (retval.is_undefined ())
3034 error ("get: invalid
default property '%s'", name.c_str ());
3040 octave_value get_factory_default (const caseless_str& name) const
3042 octave_value retval = factory_properties.lookup (name);
3044 if (retval.is_undefined ())
3045 error ("get: invalid factory
default property '%s'", name.c_str ());
3050 octave_value get_defaults (void) const
3052 return default_properties.as_struct ("default");
3055 property_list get_defaults_list (void) const
3057 return default_properties;
3060 octave_value get_factory_defaults (void) const
3062 return factory_properties.as_struct ("factory
");
3065 property_list get_factory_defaults_list (void) const
3067 return factory_properties;
3070 base_properties& get_properties (void) { return xproperties; }
3072 const base_properties& get_properties (void) const { return xproperties; }
3074 bool valid_object (void) const { return true; }
3076 void reset_default_properties (void);
3078 bool has_readonly_property (const caseless_str& pname) const
3080 bool retval = xproperties.has_readonly_property (pname);
3082 retval = base_properties::has_readonly_property (pname);
3088 property_list default_properties;
3090 property_list factory_properties;
3092 static property_list::plist_map_type init_factory_properties (void);
3095 // ---------------------------------------------------------------------
3097 class OCTINTERP_API figure : public base_graphics_object
3100 class OCTINTERP_API properties : public base_properties
3103 void init_integerhandle (const octave_value& val)
3105 integerhandle = val;
3108 void remove_child (const graphics_handle& h, bool from_root = false);
3110 void set_visible (const octave_value& val);
3112 octave::graphics_toolkit get_toolkit (void) const;
3114 void set_toolkit (const octave::graphics_toolkit& b);
3116 void set___graphics_toolkit__ (const octave_value& val);
3118 void adopt (const graphics_handle& h);
3120 void set_position (const octave_value& val,
3121 bool do_notify_toolkit = true);
3123 void set_outerposition (const octave_value& val,
3124 bool do_notify_toolkit = true);
3126 Matrix bbox2position (const Matrix& bbox) const;
3128 Matrix get_boundingbox (bool internal = false,
3129 const Matrix& parent_pix_size = Matrix ()) const;
3131 void set_boundingbox (const Matrix& bb, bool internal = false,
3132 bool do_notify_toolkit = true);
3134 Matrix map_from_boundingbox (double x, double y) const;
3136 Matrix map_to_boundingbox (double x, double y) const;
3138 void update_units (const caseless_str& old_units);
3140 void update_paperunits (const caseless_str& old_paperunits);
3142 std::string get_title (void) const;
3144 // See the genprops.awk script for an explanation of the
3145 // properties declarations.
3146 // Programming note: Keep property list sorted if new ones are added.
3148 BEGIN_PROPERTIES (figure)
3149 array_property alphamap , Matrix (64, 1, 1)
3150 callback_property buttondownfcn , Matrix ()
3151 callback_property closerequestfcn , "closereq
"
3152 color_property color , color_property (color_values (1, 1, 1), radio_values ("none
"))
3153 array_property colormap , viridis_colormap ()
3154 handle_property currentaxes S , graphics_handle ()
3155 string_property currentcharacter r , ""
3156 handle_property currentobject r , graphics_handle ()
3157 array_property currentpoint r , Matrix (2, 1, 0)
3158 bool_property dockcontrols , "off
"
3159 string_property filename , ""
3160 bool_property graphicssmoothing , "on
"
3161 bool_property integerhandle S , "on
"
3162 bool_property inverthardcopy , "on
"
3163 callback_property keypressfcn , Matrix ()
3164 callback_property keyreleasefcn , Matrix ()
3165 radio_property menubar , "{
figure}|none
"
3166 string_property name , ""
3167 array_property number rG , Matrix ()
3168 radio_property nextplot , "{add}|
new|replace|replacechildren
"
3169 bool_property numbertitle , "on
"
3170 array_property outerposition s , Matrix (1, 4, -1.0)
3171 radio_property paperorientation U , "{portrait}|landscape
"
3172 array_property paperposition m , default_figure_paperposition ()
3173 // FIXME: Matlab default is "auto", but this messes up hgsave BIST test.
3174 radio_property paperpositionmode au , "{
auto}|manual
"
3175 array_property papersize U , default_figure_papersize ()
3176 radio_property papertype SU , "{usletter}|uslegal|a0|a1|
a2|a3|a4|a5|b0|b1|b2|b3|b4|b5|arch-a|arch-b|arch-c|arch-
d|arch-e|a|b|c|
d|e|tabloid|<custom>
"
3177 radio_property paperunits Su , "{inches}|centimeters|normalized|points
"
3178 radio_property pointer , "crosshair|{arrow}|ibeam|watch|topl|topr|botl|botr|
left|top|right|bottom|circle|
cross|fleur|custom|hand
"
3179 array_property pointershapecdata , Matrix (16, 16, 1)
3180 array_property pointershapehotspot , Matrix (1, 2, 1)
3181 array_property position s , default_figure_position ()
3182 radio_property renderer m , "{opengl}|painters
"
3183 radio_property renderermode , "{
auto}|manual
"
3184 bool_property resize , "on
"
3185 // FIXME: "resizefcn
" is no longer recommended by Matlab,
3186 // and has been replaced with "sizechangedfcn
"
3187 // Eventually this will need to be hidden, and then removed.
3188 callback_property resizefcn , Matrix ()
3189 radio_property selectiontype , "{normal}|extend|alt|open
"
3190 callback_property sizechangedfcn , Matrix ()
3191 radio_property toolbar , "{
auto}|
figure|none
"
3192 radio_property units Su , "{pixels}|normalized|inches|centimeters|points|characters
"
3193 callback_property windowbuttondownfcn , Matrix ()
3194 callback_property windowbuttonmotionfcn , Matrix ()
3195 callback_property windowbuttonupfcn , Matrix ()
3196 callback_property windowkeypressfcn , Matrix ()
3197 callback_property windowkeyreleasefcn , Matrix ()
3198 callback_property windowscrollwheelfcn , Matrix ()
3199 radio_property windowstyle , "{normal}|modal|docked
"
3201 // Overridden base property
3202 // Property is not implemented for figures.
3203 // Hide it and set it to a default value that works.
3204 radio_property pickableparts h , "{visible}
"
3206 // Octave-specific properties
3207 mutable string_property __gl_extensions__ hr , ""
3208 mutable string_property __gl_renderer__ hr , ""
3209 mutable string_property __gl_vendor__ hr , ""
3210 mutable string_property __gl_version__ hr , ""
3211 bool_property __gl_window__ h , "off
"
3212 string_property __graphics_toolkit__ hs , default_graphics_toolkit ()
3213 any_property __guidata__ h , Matrix ()
3214 radio_property __mouse_mode__ hS , "{none}|pan|rotate|select|
text|zoom
"
3215 bool_property __printing__ h , "off
"
3216 any_property __pan_mode__ h , Matrix ()
3217 any_property __plot_stream__ h , Matrix ()
3218 any_property __rotate_mode__ h , Matrix ()
3219 any_property __zoom_mode__ h , Matrix ()
3220 double_property __device_pixel_ratio__ hU , 1.0
3227 alphamap.add_constraint (dim_vector (-1, 1));
3228 colormap.add_constraint (dim_vector (-1, 3));
3229 colormap.add_constraint (dim_vector (0, 0));
3230 outerposition.add_constraint (dim_vector (1, 4));
3231 outerposition.add_constraint (FINITE);
3232 paperposition.add_constraint (dim_vector (1, 4));
3233 paperposition.add_constraint (FINITE);
3234 papersize.add_constraint (dim_vector (1, 2));
3235 papersize.add_constraint (FINITE);
3236 pointershapecdata.add_constraint (dim_vector (16, 16));
3237 pointershapecdata.add_constraint (dim_vector (32, 32));
3238 pointershapehotspot.add_constraint (dim_vector (1, 2));
3239 position.add_constraint (dim_vector (1, 4));
3240 position.add_constraint (FINITE);
3246 Matrix get_auto_paperposition (void);
3248 void update_paperpositionmode (void)
3250 if (paperpositionmode.is ("auto"))
3251 paperposition.set (get_auto_paperposition ());
3254 void update_handlevisibility (void);
3256 void init_toolkit (void);
3258 octave::graphics_toolkit toolkit;
3262 properties xproperties;
3265 figure (const graphics_handle& mh, const graphics_handle& p)
3266 : base_graphics_object (), xproperties (mh, p), default_properties ()
3269 ~figure (void) = default;
3271 void override_defaults (base_graphics_object& obj)
3273 // Allow parent (root object) to override first (properties knows how
3274 // to find the parent object).
3275 xproperties.override_defaults (obj);
3277 // Now override with our defaults. If the default_properties
3278 // list includes the properties for all defaults (line,
3279 // surface, etc.) then we don't have to know the type of OBJ
3280 // here, we just call its set function and let it decide which
3281 // properties from the list to use.
3282 obj.set_from_list (default_properties);
3285 void set (const caseless_str& name, const octave_value& value)
3287 if (name.compare ("default", 7))
3288 // strip "default", pass rest to function that will
3289 // parse the remainder and add the element to the
3290 // default_properties map.
3291 default_properties.set (name.substr (7), value);
3293 xproperties.set (name, value);
3296 octave_value get (const caseless_str& name) const
3298 octave_value retval;
3300 if (name.compare ("default", 7))
3301 retval = get_default (name.substr (7));
3303 retval = xproperties.get (name);
3308 octave_value get_default (const caseless_str& name) const;
3310 octave_value get_defaults (void) const
3312 return default_properties.as_struct ("default");
3315 property_list get_defaults_list (void) const
3317 return default_properties;
3320 base_properties& get_properties (void) { return xproperties; }
3322 const base_properties& get_properties (void) const { return xproperties; }
3324 bool valid_object (void) const { return true; }
3326 void reset_default_properties (void);
3328 bool has_readonly_property (const caseless_str& pname) const
3330 bool retval = xproperties.has_readonly_property (pname);
3332 retval = base_properties::has_readonly_property (pname);
3337 property_list default_properties;
3340 // ---------------------------------------------------------------------
3342 class OCTINTERP_API graphics_xform
3345 graphics_xform (void)
3346 : xform (xform_eye ()), xform_inv (xform_eye ()),
3347 sx ("linear
"), sy ("linear
"), sz ("linear
"), zlim (1, 2, 0.0)
3352 graphics_xform (const Matrix& xm, const Matrix& xim,
3353 const scaler& x, const scaler& y, const scaler& z,
3355 : xform (xm), xform_inv (xim), sx (x), sy (y), sz (z), zlim (zl) { }
3357 graphics_xform (const graphics_xform& g)
3358 : xform (g.xform), xform_inv (g.xform_inv), sx (g.sx),
3359 sy (g.sy), sz (g.sz), zlim (g.zlim) { }
3361 ~graphics_xform (void) = default;
3363 graphics_xform& operator = (const graphics_xform& g)
3366 xform_inv = g.xform_inv;
3375 static ColumnVector xform_vector (double x, double y, double z);
3377 static Matrix xform_eye (void);
3379 ColumnVector transform (double x, double y, double z,
3380 bool use_scale = true) const;
3382 ColumnVector untransform (double x, double y, double z,
3383 bool use_scale = true) const;
3385 ColumnVector untransform (double x, double y, bool use_scale = true) const
3386 { return untransform (x, y, (zlim(0)+zlim(1))/2, use_scale); }
3388 Matrix xscale (const Matrix& m) const { return sx.scale (m); }
3389 Matrix yscale (const Matrix& m) const { return sy.scale (m); }
3390 Matrix zscale (const Matrix& m) const { return sz.scale (m); }
3392 Matrix scale (const Matrix& m) const
3394 bool has_z = (m.columns () > 2);
3396 if (sx.is_linear () && sy.is_linear ()
3397 && (! has_z || sz.is_linear ()))
3400 Matrix retval (m.dims ());
3404 for (int i = 0; i < r; i++)
3406 retval(i,0) = sx.scale (m(i,0));
3407 retval(i,1) = sy.scale (m(i,1));
3409 retval(i,2) = sz.scale (m(i,2));
3430 class OCTINTERP_API axes : public base_graphics_object
3433 class OCTINTERP_API properties : public base_properties
3436 void set_defaults (base_graphics_object& obj, const std::string& mode);
3438 void remove_child (const graphics_handle& h, bool from_root = false);
3440 void adopt (const graphics_handle& h);
3442 const scaler& get_x_scaler (void) const { return sx; }
3443 const scaler& get_y_scaler (void) const { return sy; }
3444 const scaler& get_z_scaler (void) const { return sz; }
3446 Matrix get_boundingbox (bool internal = false,
3447 const Matrix& parent_pix_size = Matrix ()) const;
3448 Matrix get_extent (bool with_text = false,
3449 bool only_text_height=false) const;
3451 double get___fontsize_points__ (double box_pix_height = 0) const;
3453 void update_boundingbox (void)
3455 if (units_is ("normalized
"))
3458 base_properties::update_boundingbox ();
3462 void update_camera (void);
3463 void update_axes_layout (void);
3464 void update_aspectratios (void);
3465 void update_transform (void)
3467 update_aspectratios ();
3469 update_axes_layout ();
3472 void sync_positions (void);
3474 void update_autopos (const std::string& elem_type);
3475 void update_xlabel_position (void);
3476 void update_ylabel_position (void);
3477 void update_zlabel_position (void);
3478 void update_title_position (void);
3480 graphics_xform get_transform (void) const
3481 { return graphics_xform (x_render, x_render_inv, sx, sy, sz, x_zlim); }
3483 Matrix get_transform_matrix (void) const { return x_render; }
3484 Matrix get_inverse_transform_matrix (void) const { return x_render_inv; }
3485 Matrix get_opengl_matrix_1 (void) const { return x_gl_mat1; }
3486 Matrix get_opengl_matrix_2 (void) const { return x_gl_mat2; }
3487 Matrix get_transform_zlim (void) const { return x_zlim; }
3489 int get_xstate (void) const { return xstate; }
3490 int get_ystate (void) const { return ystate; }
3491 int get_zstate (void) const { return zstate; }
3492 double get_xPlane (void) const { return xPlane; }
3493 double get_xPlaneN (void) const { return xPlaneN; }
3494 double get_yPlane (void) const { return yPlane; }
3495 double get_yPlaneN (void) const { return yPlaneN; }
3496 double get_zPlane (void) const { return zPlane; }
3497 double get_zPlaneN (void) const { return zPlaneN; }
3498 double get_xpTick (void) const { return xpTick; }
3499 double get_xpTickN (void) const { return xpTickN; }
3500 double get_ypTick (void) const { return ypTick; }
3501 double get_ypTickN (void) const { return ypTickN; }
3502 double get_zpTick (void) const { return zpTick; }
3503 double get_zpTickN (void) const { return zpTickN; }
3504 double get_x_min (void) const { return std::min (xPlane, xPlaneN); }
3505 double get_x_max (void) const { return std::max (xPlane, xPlaneN); }
3506 double get_y_min (void) const { return std::min (yPlane, yPlaneN); }
3507 double get_y_max (void) const { return std::max (yPlane, yPlaneN); }
3508 double get_z_min (void) const { return std::min (zPlane, zPlaneN); }
3509 double get_z_max (void) const { return std::max (zPlane, zPlaneN); }
3510 double get_fx (void) const { return fx; }
3511 double get_fy (void) const { return fy; }
3512 double get_fz (void) const { return fz; }
3513 double get_xticklen (void) const { return xticklen; }
3514 double get_yticklen (void) const { return yticklen; }
3515 double get_zticklen (void) const { return zticklen; }
3516 double get_xtickoffset (void) const { return xtickoffset; }
3517 double get_ytickoffset (void) const { return ytickoffset; }
3518 double get_ztickoffset (void) const { return ztickoffset; }
3519 bool get_x2Dtop (void) const { return x2Dtop; }
3520 bool get_y2Dright (void) const { return y2Dright; }
3521 bool get_layer2Dtop (void) const { return layer2Dtop; }
3522 bool get_is2D (bool include_kids = false) const
3523 { return (include_kids ? (is2D && ! has3Dkids) : is2D); }
3524 void set_has3Dkids (bool val) { has3Dkids = val; }
3525 bool get_xySym (void) const { return xySym; }
3526 bool get_xyzSym (void) const { return xyzSym; }
3527 bool get_zSign (void) const { return zSign; }
3528 bool get_nearhoriz (void) const { return nearhoriz; }
3530 ColumnVector pixel2coord (double px, double py) const
3531 { return get_transform ().untransform (px, py, (x_zlim(0)+x_zlim(1))/2); }
3533 ColumnVector coord2pixel (double x, double y, double z) const
3534 { return get_transform ().transform (x, y, z); }
3536 void zoom_about_point (const std::string& mode, double x, double y,
3537 double factor, bool push_to_zoom_stack = true);
3538 void zoom (const std::string& mode, double factor,
3539 bool push_to_zoom_stack = true);
3540 void zoom (const std::string& mode, const Matrix& xl, const Matrix& yl,
3541 bool push_to_zoom_stack = true);
3543 void translate_view (const std::string& mode,
3544 double x0, double x1, double y0, double y1,
3545 bool push_to_zoom_stack = true);
3547 void pan (const std::string& mode, double factor,
3548 bool push_to_zoom_stack = true);
3550 void rotate3d (double x0, double x1, double y0, double y1,
3551 bool push_to_zoom_stack = true);
3553 void rotate_view (double delta_az, double delta_el,
3554 bool push_to_zoom_stack = true);
3557 void update_handlevisibility (void);
3558 void push_zoom_stack (void);
3559 void clear_zoom_stack (bool do_unzoom = true);
3561 void update_units (const caseless_str& old_units);
3563 void update_font (std::string prop = "");
3565 void update_fontunits (const caseless_str& old_fontunits);
3567 void increase_num_lights (void) { num_lights++; }
3568 void decrease_num_lights (void) { num_lights--; }
3569 unsigned int get_num_lights (void) const { return num_lights; }
3573 scaler sx = scaler ();
3574 scaler sy = scaler ();
3575 scaler sz = scaler ();
3577 Matrix x_render = Matrix ();
3578 Matrix x_render_inv = Matrix ();
3579 Matrix x_gl_mat1 = Matrix ();
3580 Matrix x_gl_mat2 = Matrix ();
3581 Matrix x_zlim = Matrix ();
3583 std::list<octave_value> zoom_stack = std::list<octave_value> ();
3590 double xPlane = 0.0;
3591 double yPlane = 0.0;
3592 double zPlane = 0.0;
3594 double xPlaneN = 0.0;
3595 double yPlaneN = 0.0;
3596 double zPlaneN = 0.0;
3598 double xpTick = 0.0;
3599 double ypTick = 0.0;
3600 double zpTick = 0.0;
3602 double xpTickN = 0.0;
3603 double ypTickN = 0.0;
3604 double zpTickN = 0.0;
3610 double xticklen = 0.0;
3611 double yticklen = 0.0;
3612 double zticklen = 0.0;
3614 double xtickoffset = 0.0;
3615 double ytickoffset = 0.0;
3616 double ztickoffset = 0.0;
3618 bool x2Dtop = false;
3619 bool y2Dright = false;
3620 bool layer2Dtop = false;
3622 bool has3Dkids = false;
3624 bool xyzSym = false;
3626 bool nearhoriz = false;
3628 unsigned int num_lights = 0;
3630 // Text renderer, used for calculation of text (tick labels) size
3631 octave::text_renderer txt_renderer;
3633 void set_text_child (handle_property& h, const std::string& who,
3634 const octave_value& v);
3636 void delete_text_child (handle_property& h, bool from_root = false);
3638 // See the genprops.awk script for an explanation of the
3639 // properties declarations.
3640 // Programming note: Keep property list sorted if new ones are added.
3642 BEGIN_PROPERTIES (axes)
3643 radio_property activepositionproperty , "{outerposition}|position
"
3644 row_vector_property alim m , default_lim ()
3645 radio_property alimmode , "{
auto}|manual
"
3646 color_property ambientlightcolor , color_values (1, 1, 1)
3647 bool_property box u , "off
"
3648 radio_property boxstyle , "{back}|full
"
3649 row_vector_property cameraposition mu , Matrix (1, 3, 0.0)
3650 radio_property camerapositionmode u , "{
auto}|manual
"
3651 row_vector_property cameratarget mu , Matrix (1, 3, 0.0)
3652 radio_property cameratargetmode u , "{
auto}|manual
"
3653 row_vector_property cameraupvector mu , Matrix (1, 3, 0.0)
3654 radio_property cameraupvectormode u , "{
auto}|manual
"
3655 double_property cameraviewangle mu , 6.6086
3656 radio_property cameraviewanglemode u , "{
auto}|manual
"
3657 row_vector_property clim m , default_lim ()
3658 radio_property climmode al , "{
auto}|manual
"
3659 radio_property clippingstyle , "{3dbox}|rectangle
"
3660 color_property color , color_property (color_values (1, 1, 1), radio_values ("none
"))
3661 array_property colormap sg , Matrix ()
3662 array_property colororder , default_colororder ()
3663 double_property colororderindex , 1.0
3664 array_property currentpoint , Matrix (2, 3, 0.0)
3665 row_vector_property dataaspectratio mu , Matrix (1, 3, 1.0)
3666 radio_property dataaspectratiomode u , "{
auto}|manual
"
3667 radio_property fontangle u , "{normal}|italic
"
3668 string_property fontname u , OCTAVE_DEFAULT_FONTNAME
3669 double_property fontsize u , 10
3670 bool_property fontsmoothing u , "on
"
3671 radio_property fontunits SU , "{points}|inches|centimeters|normalized|pixels
"
3672 radio_property fontweight u , "{normal}|bold
"
3673 double_property gridalpha m , 0.15
3674 radio_property gridalphamode , "{
auto}|manual
"
3675 color_property gridcolor m , color_property (color_values (0.15, 0.15, 0.15), radio_values ("none
"))
3676 radio_property gridcolormode , "{
auto}|manual
"
3677 radio_property gridlinestyle , "{-}|--|:|-.|none
"
3678 double_property labelfontsizemultiplier u , 1.1
3679 radio_property layer u , "{bottom}|top
"
3680 // FIXME: should be kind of string array.
3681 any_property linestyleorder S , "-
"
3682 double_property linestyleorderindex , 1.0
3683 double_property linewidth , 0.5
3684 double_property minorgridalpha m , 0.25
3685 radio_property minorgridalphamode , "{
auto}|manual
"
3686 color_property minorgridcolor m , color_property (color_values (0.1, 0.1, 0.1), radio_values ("none
"))
3687 radio_property minorgridcolormode , "{
auto}|manual
"
3688 radio_property minorgridlinestyle , "{:}|-|--|-.|none
"
3689 radio_property nextplot , "{replace}|add|replacechildren
"
3690 array_property outerposition u , default_axes_outerposition ()
3691 row_vector_property plotboxaspectratio mu , Matrix (1, 3, 1.0)
3692 radio_property plotboxaspectratiomode u , "{
auto}|manual
"
3693 array_property position u , default_axes_position ()
3694 radio_property projection , "{orthographic}|perspective
"
3695 radio_property sortmethod , "{depth}|childorder
"
3696 radio_property tickdir mu , "{in}|out
"
3697 radio_property tickdirmode u , "{
auto}|manual
"
3698 // FIXME: Added recently to Matlab, should replace interpreter property.
3699 radio_property ticklabelinterpreter u , "{tex}|latex|none
"
3700 array_property ticklength u , default_axes_ticklength ()
3701 array_property tightinset r , Matrix (1, 4, 0.0)
3702 handle_property title SOf , make_graphics_handle ("text", __myhandle__, false, false, false)
3703 double_property titlefontsizemultiplier u , 1.1
3704 radio_property titlefontweight u , "{bold}|normal
"
3705 // FIXME: uicontextmenu should be moved here.
3706 radio_property units SU , "{normalized}|inches|centimeters|points|pixels|characters
"
3707 array_property view u , default_axes_view ()
3708 radio_property xaxislocation u , "{bottom}|top|origin
"
3709 color_property xcolor mu , color_property (color_values (0.15, 0.15, 0.15), radio_values ("none
"))
3710 radio_property xcolormode , "{
auto}|manual
"
3711 radio_property xdir u , "{normal}|reverse
"
3712 bool_property xgrid , "off
"
3713 handle_property xlabel SOf , make_graphics_handle ("text", __myhandle__, false, false, false)
3714 row_vector_property xlim mu , default_lim ()
3715 radio_property xlimmode al , "{
auto}|manual
"
3716 bool_property xminorgrid , "off
"
3717 bool_property xminortick , "off
"
3718 radio_property xscale alu , "{linear}|log
"
3719 row_vector_property xtick mu , default_axes_tick ()
3720 // FIXME: should be kind of string array.
3721 any_property xticklabel S , ""
3722 radio_property xticklabelmode u , "{
auto}|manual
"
3723 double_property xticklabelrotation , 0.0
3724 radio_property xtickmode u , "{
auto}|manual
"
3725 radio_property yaxislocation u , "{
left}|right|origin
"
3726 color_property ycolor mu , color_property (color_values (0.15, 0.15, 0.15), radio_values ("none
"))
3727 radio_property ycolormode , "{
auto}|manual
"
3728 radio_property ydir u , "{normal}|reverse
"
3729 bool_property ygrid , "off
"
3730 handle_property ylabel SOf , make_graphics_handle ("text", __myhandle__, false, false, false)
3731 row_vector_property ylim mu , default_lim ()
3732 radio_property ylimmode al , "{
auto}|manual
"
3733 bool_property yminorgrid , "off
"
3734 bool_property yminortick , "off
"
3735 radio_property yscale alu , "{linear}|log
"
3736 row_vector_property ytick mu , default_axes_tick ()
3737 any_property yticklabel S , ""
3738 radio_property yticklabelmode u , "{
auto}|manual
"
3739 double_property yticklabelrotation , 0.0
3740 radio_property ytickmode u , "{
auto}|manual
"
3741 color_property zcolor mu , color_property (color_values (0.15, 0.15, 0.15), radio_values ("none
"))
3742 radio_property zcolormode , "{
auto}|manual
"
3743 radio_property zdir u , "{normal}|reverse
"
3744 bool_property zgrid , "off
"
3745 handle_property zlabel SOf , make_graphics_handle ("text", __myhandle__, false, false, false)
3746 row_vector_property zlim mu , default_lim ()
3747 radio_property zlimmode al , "{
auto}|manual
"
3748 bool_property zminorgrid , "off
"
3749 bool_property zminortick , "off
"
3750 radio_property zscale alu , "{linear}|log
"
3751 row_vector_property ztick mu , default_axes_tick ()
3752 any_property zticklabel S , ""
3753 radio_property zticklabelmode u , "{
auto}|manual
"
3754 double_property zticklabelrotation , 0.0
3755 radio_property ztickmode u , "{
auto}|manual
"
3757 // Octave-specific properties
3758 array_property __colormap__ hu , Matrix ()
3759 double_property mousewheelzoom , 0.5
3761 // hidden properties for alignment of subplots
3762 radio_property __autopos_tag__ h , "{none}|subplot
"
3763 // hidden properties for inset
3764 array_property looseinset hu , Matrix (1, 4, 0.0)
3765 // hidden properties for minor ticks
3766 row_vector_property xminortickvalues h , Matrix ()
3767 row_vector_property yminortickvalues h , Matrix ()
3768 row_vector_property zminortickvalues h , Matrix ()
3769 // hidden property for text rendering
3770 double_property __fontsize_points__ hgr , 0
3779 get_scale (const std::string& scale, const Matrix& lims)
3781 std::string retval = scale;
3783 if (scale == "log
" && lims.numel () > 1 && lims(0) < 0 && lims(1) < 0)
3789 void update_xscale (void)
3791 sx = get_scale (get_xscale (), xlim.get ().matrix_value ());
3794 void update_yscale (void)
3796 sy = get_scale (get_yscale (), ylim.get ().matrix_value ());
3799 void update_zscale (void)
3801 sz = get_scale (get_zscale (), zlim.get ().matrix_value ());
3804 void update_label_color (handle_property label, color_property col);
3805 void update_xcolor (void)
3806 { update_label_color (xlabel, xcolor); }
3808 void update_ycolor (void)
3809 { update_label_color (ylabel, ycolor); }
3811 void update_zcolor (void)
3812 { update_label_color (zlabel, zcolor); }
3814 void update_view (void) { sync_positions (); }
3816 void update_cameraposition (void) { update_transform (); }
3817 void update_cameratarget (void) { update_transform (); }
3818 void update_cameraupvector (void) { update_transform (); }
3819 void update_cameraviewangle (void) { update_transform (); }
3821 void update_camerapositionmode (void)
3823 if (camerapositionmode_is ("auto"))
3824 update_cameraposition ();
3826 void update_cameratargetmode (void)
3828 if (cameratargetmode_is ("auto"))
3829 update_cameratarget ();
3831 void update_cameraupvectormode (void)
3833 if (cameraupvectormode_is ("auto"))
3834 update_cameraupvector ();
3836 void update_cameraviewanglemode (void)
3838 if (cameraviewanglemode_is ("auto"))
3839 update_cameraviewangle ();
3842 void update_dataaspectratio (void) { sync_positions (); }
3843 void update_dataaspectratiomode (void) { sync_positions (); }
3844 void update_plotboxaspectratio (void) { sync_positions (); }
3845 void update_plotboxaspectratiomode (void) { sync_positions (); }
3847 void update_layer (void) { update_axes_layout (); }
3848 void update_box (void)
3850 if (xticklabelmode.is ("auto"))
3851 calc_ticklabels (xtick, xticklabel, xscale.is ("log
"),
3852 xaxislocation_is ("origin
"),
3853 yscale.is ("log
") ? 2 :
3854 (yaxislocation_is ("origin
") ? 0 :
3855 (yaxislocation_is ("left") ? -1 : 1)),
3857 if (yticklabelmode.is ("auto"))
3858 calc_ticklabels (ytick, yticklabel, yscale.is ("log
"),
3859 yaxislocation_is ("origin
"),
3860 xscale.is ("log
") ? 2 :
3861 (xaxislocation_is ("origin
") ? 0 :
3862 (xaxislocation_is ("bottom
") ? -1 : 1)),
3865 void update_yaxislocation (void)
3868 update_axes_layout ();
3869 if (xticklabelmode.is ("auto"))
3870 calc_ticklabels (xtick, xticklabel, xscale.is ("log
"),
3871 xaxislocation_is ("origin
"),
3872 yscale.is ("log
") ? 2 :
3873 (yaxislocation_is ("origin
") ? 0 :
3874 (yaxislocation_is ("left") ? -1 : 1)),
3876 if (yticklabelmode.is ("auto"))
3877 calc_ticklabels (ytick, yticklabel, yscale.is ("log
"),
3878 yaxislocation_is ("origin
"),
3879 xscale.is ("log
") ? 2 :
3880 (xaxislocation_is ("origin
") ? 0 :
3881 (xaxislocation_is ("bottom
") ? -1 : 1)),
3883 update_ylabel_position ();
3885 void update_xaxislocation (void)
3888 update_axes_layout ();
3889 if (xticklabelmode.is ("auto"))
3890 calc_ticklabels (xtick, xticklabel, xscale.is ("log
"),
3891 xaxislocation_is ("origin
"),
3892 yscale.is ("log
") ? 2 :
3893 (yaxislocation_is ("origin
") ? 0 :
3894 (yaxislocation_is ("left") ? -1 : 1)),
3896 if (yticklabelmode.is ("auto"))
3897 calc_ticklabels (ytick, yticklabel, yscale.is ("log
"),
3898 yaxislocation_is ("origin
"),
3899 xscale.is ("log
") ? 2 :
3900 (xaxislocation_is ("origin
") ? 0 :
3901 (xaxislocation_is ("bottom
") ? -1 : 1)),
3903 update_xlabel_position ();
3906 void update_xdir (void) { update_camera (); update_axes_layout (); }
3907 void update_ydir (void) { update_camera (); update_axes_layout (); }
3908 void update_zdir (void) { update_camera (); update_axes_layout (); }
3910 void update_ticklength (void);
3911 void update_tickdir (void) { update_ticklength (); }
3912 void update_tickdirmode (void) { update_ticklength (); }
3914 void update_ticklabelinterpreter (void)
3921 void update_xtick (void)
3923 calc_ticks_and_lims (xlim, xtick, xminortickvalues, xlimmode.is ("auto"),
3924 xtickmode.is ("auto"), xscale.is ("log
"));
3925 if (xticklabelmode.is ("auto"))
3926 calc_ticklabels (xtick, xticklabel, xscale.is ("log
"),
3927 xaxislocation_is ("origin
"),
3928 yscale.is ("log
") ? 2 :
3929 (yaxislocation_is ("origin
") ? 0 :
3930 (yaxislocation_is ("left") ? -1 : 1)),
3934 void update_ytick (void)
3936 calc_ticks_and_lims (ylim, ytick, yminortickvalues, ylimmode.is ("auto"),
3937 ytickmode.is ("auto"), yscale.is ("log
"));
3938 if (yticklabelmode.is ("auto"))
3939 calc_ticklabels (ytick, yticklabel, yscale.is ("log
"),
3940 yaxislocation_is ("origin
"),
3941 xscale.is ("log
") ? 2 :
3942 (xaxislocation_is ("origin
") ? 0 :
3943 (xaxislocation_is ("bottom
") ? -1 : 1)),
3947 void update_ztick (void)
3949 calc_ticks_and_lims (zlim, ztick, zminortickvalues, zlimmode.is ("auto"),
3950 ztickmode.is ("auto"), zscale.is ("log
"));
3951 if (zticklabelmode.is ("auto"))
3952 calc_ticklabels (ztick, zticklabel, zscale.is ("log
"), false, 2, zlim);
3956 void update_xtickmode (void)
3958 if (xtickmode.is ("auto"))
3961 void update_ytickmode (void)
3963 if (ytickmode.is ("auto"))
3966 void update_ztickmode (void)
3968 if (ztickmode.is ("auto"))
3972 void update_xticklabelmode (void)
3974 if (xticklabelmode.is ("auto"))
3975 calc_ticklabels (xtick, xticklabel, xscale.is ("log
"),
3976 xaxislocation_is ("origin
"),
3977 yscale.is ("log
") ? 2 :
3978 (yaxislocation_is ("origin
") ? 0 :
3979 (yaxislocation_is ("left") ? -1 : 1)),
3982 void update_yticklabelmode (void)
3984 if (yticklabelmode.is ("auto"))
3985 calc_ticklabels (ytick, yticklabel, yscale.is ("log
"),
3986 yaxislocation_is ("origin
"),
3987 xscale.is ("log
") ? 2 :
3988 (xaxislocation_is ("origin
") ? 0 :
3989 (xaxislocation_is ("bottom
") ? -1 : 1)),
3992 void update_zticklabelmode (void)
3994 if (zticklabelmode.is ("auto"))
3995 calc_ticklabels (ztick, zticklabel, zscale.is ("log
"), false, 2, zlim);
3998 void update_fontname (void)
4000 update_font ("fontname
");
4003 void update_fontsize (void)
4005 update_font ("fontsize
");
4008 void update_fontsmoothing (void)
4010 update_font ("fontsmoothing
");
4012 void update_fontangle (void)
4014 update_font ("fontangle
");
4017 void update_fontweight (void)
4019 update_font ("fontweight
");
4023 void update_titlefontsizemultiplier (void)
4025 // update_font handles title and axis labels
4026 update_font ("fontsize
");
4030 void update_labelfontsizemultiplier (void)
4032 update_font ("fontsize
");
4036 void update_titlefontweight (void)
4038 // update_font handles title and axis labels
4039 update_font ("fontweight
");
4043 void update_outerposition (void);
4044 void update_position (void);
4045 void update_looseinset (void);
4047 double calc_tick_sep (double minval, double maxval);
4048 void calc_ticks_and_lims (array_property& lims, array_property& ticks,
4049 array_property& mticks, bool limmode_is_auto,
4050 bool tickmode_is_auto, bool is_logscale);
4051 void calc_ticklabels (const array_property& ticks, any_property& labels,
4052 bool is_logscale, const bool is_origin,
4053 const int other_axislocation,
4054 const array_property& axis_lims);
4055 Matrix get_ticklabel_extents (const Matrix& ticks,
4056 const string_vector& ticklabels,
4057 const Matrix& limits);
4059 void fix_limits (array_property& lims)
4061 if (lims.get ().isempty ())
4064 Matrix l = lims.get ().matrix_value ();
4071 else if (l(0) == l(1))
4079 Matrix calc_tightbox (const Matrix& init_pos);
4081 void set_colormap (const octave_value& val)
4083 set___colormap__ (val);
4086 void update___colormap__ (void)
4088 colormap.run_listeners (GCB_POSTSET);
4091 octave_value get_colormap (void) const;
4094 Matrix get_axis_limits (double xmin, double xmax,
4095 double min_pos, double max_neg,
4096 const bool logscale);
4098 void check_axis_limits (Matrix &limits, const Matrix kids,
4099 const bool logscale, char &update_type);
4103 update_axis_limits ("xlim
");
4105 calc_ticks_and_lims (xlim, xtick, xminortickvalues, xlimmode.is ("auto"),
4106 xtickmode.is ("auto"), xscale.is ("log
"));
4107 if (xticklabelmode.is ("auto"))
4108 calc_ticklabels (xtick, xticklabel, xscale.is ("log
"),
4109 xaxislocation.is ("origin
"),
4110 yscale.is ("log
") ? 2 :
4111 (yaxislocation_is ("origin
") ? 0 :
4112 (yaxislocation_is ("left") ? -1 : 1)),
4119 update_axes_layout ();
4122 void update_ylim (void)
4124 update_axis_limits ("ylim
");
4126 calc_ticks_and_lims (ylim, ytick, yminortickvalues, ylimmode.is ("auto"),
4127 ytickmode.is ("auto"), yscale.is ("log
"));
4128 if (yticklabelmode.is ("auto"))
4129 calc_ticklabels (ytick, yticklabel, yscale.is ("log
"),
4130 yaxislocation_is ("origin
"),
4131 xscale.is ("log
") ? 2 :
4132 (xaxislocation_is ("origin
") ? 0 :
4133 (xaxislocation_is ("bottom
") ? -1 : 1)),
4140 update_axes_layout ();
4143 void update_zlim (void)
4145 update_axis_limits ("zlim
");
4147 calc_ticks_and_lims (zlim, ztick, zminortickvalues, zlimmode.is ("auto"),
4148 ztickmode.is ("auto"), zscale.is ("log
"));
4149 if (zticklabelmode.is ("auto"))
4150 calc_ticklabels (ztick, zticklabel, zscale.is ("log
"), false, 2, zlim);
4156 update_axes_layout ();
4159 void trigger_normals_calc (void);
4164 properties xproperties;
4167 axes (const graphics_handle& mh, const graphics_handle& p)
4168 : base_graphics_object (), xproperties (mh, p), default_properties ()
4170 xproperties.update_transform ();
4173 ~axes (void) = default;
4175 void override_defaults (base_graphics_object& obj)
4177 // Allow parent (figure) to override first (properties knows how
4178 // to find the parent object).
4179 xproperties.override_defaults (obj);
4181 // Now override with our defaults. If the default_properties
4182 // list includes the properties for all defaults (line,
4183 // surface, etc.) then we don't have to know the type of OBJ
4184 // here, we just call its set function and let it decide which
4185 // properties from the list to use.
4186 obj.set_from_list (default_properties);
4189 void set (const caseless_str& name, const octave_value& value)
4191 if (name.compare ("default", 7))
4192 // strip "default", pass rest to function that will
4193 // parse the remainder and add the element to the
4194 // default_properties map.
4195 default_properties.set (name.substr (7), value);
4197 xproperties.set (name, value);
4200 void set_defaults (const std::string& mode)
4202 xproperties.set_defaults (*this, mode);
4205 octave_value get (const caseless_str& name) const
4207 octave_value retval;
4209 // FIXME: finish this.
4210 if (name.compare ("default", 7))
4211 retval = get_default (name.substr (7));
4213 retval = xproperties.get (name);
4218 octave_value get_default (const caseless_str& name) const;
4220 octave_value get_defaults (void) const
4222 return default_properties.as_struct ("default");
4225 property_list get_defaults_list (void) const
4227 return default_properties;
4230 base_properties& get_properties (void) { return xproperties; }
4232 const base_properties& get_properties (void) const { return xproperties; }
4234 void update_axis_limits (const std::string& axis_type);
4236 void update_axis_limits (const std::string& axis_type,
4237 const graphics_handle& h);
4239 bool valid_object (void) const { return true; }
4241 void reset_default_properties (void);
4243 bool has_readonly_property (const caseless_str& pname) const
4245 bool retval = xproperties.has_readonly_property (pname);
4247 retval = base_properties::has_readonly_property (pname);
4252 void initialize (const graphics_object& go);
4255 property_list default_properties;
4258 // ---------------------------------------------------------------------
4260 class OCTINTERP_API line : public base_graphics_object
4263 class OCTINTERP_API properties : public base_properties
4266 // See the genprops.awk script for an explanation of the
4267 // properties declarations.
4268 // Programming note: Keep property list sorted if new ones are added.
4270 BEGIN_PROPERTIES (line)
4271 color_property color , color_property (color_values (0, 0, 0), radio_values ("none
"))
4272 string_property displayname , ""
4273 radio_property linejoin , "{
round}|miter|chamfer
"
4274 radio_property linestyle , "{-}|--|:|-.|none
"
4275 double_property linewidth , 0.5
4276 radio_property marker , "{none}|+|o|*|.|
x|s|square|
d|diamond|^|v|>|<|p|pentagram|h|hexagram
"
4277 color_property markeredgecolor , color_property (radio_values ("{
auto}|none
"), color_values (0, 0, 0))
4278 color_property markerfacecolor , color_property (radio_values ("auto|{none}
"), color_values (0, 0, 0))
4279 double_property markersize , 6
4280 row_vector_property xdata u , default_data ()
4281 string_property xdatasource , ""
4282 row_vector_property ydata u , default_data ()
4283 string_property ydatasource , ""
4284 row_vector_property zdata u , Matrix ()
4285 string_property zdatasource , ""
4287 // hidden properties for limit computation
4288 row_vector_property xlim hlr , default_data_lim ()
4289 row_vector_property ylim hlr , default_data_lim ()
4290 row_vector_property zlim hlr , Matrix ()
4291 bool_property xliminclude hl , "on
"
4292 bool_property yliminclude hl , "on
"
4293 bool_property zliminclude hl , "on
"
4299 linewidth.add_constraint ("min", 0, false);
4300 markersize.add_constraint ("min", 0, false);
4304 Matrix compute_xlim (void) const;
4305 Matrix compute_ylim (void) const;
4307 void update_xdata (void) { set_xlim (compute_xlim ()); }
4309 void update_ydata (void) { set_ylim (compute_ylim ()); }
4311 void update_zdata (void) { set_zlim (zdata.get_limits ()); }
4315 properties xproperties;
4318 line (const graphics_handle& mh, const graphics_handle& p)
4319 : base_graphics_object (), xproperties (mh, p)
4322 ~line (void) = default;
4324 base_properties& get_properties (void) { return xproperties; }
4326 const base_properties& get_properties (void) const { return xproperties; }
4328 bool valid_object (void) const { return true; }
4330 bool has_readonly_property (const caseless_str& pname) const
4332 bool retval = xproperties.has_readonly_property (pname);
4334 retval = base_properties::has_readonly_property (pname);
4339 // ---------------------------------------------------------------------
4341 class OCTINTERP_API text : public base_graphics_object
4344 class OCTINTERP_API properties : public base_properties
4347 double get___fontsize_points__ (double box_pix_height = 0) const;
4349 void update_text_extent (void);
4351 void update_font (void);
4353 void set_position (const octave_value& val)
4355 octave_value new_val (val);
4357 if (new_val.numel () == 2)
4359 dim_vector dv (1, 3);
4361 new_val = new_val.resize (dv, true);
4364 if (position.set (new_val, false))
4366 set_positionmode ("manual
");
4368 position.run_listeners (GCB_POSTSET);
4372 set_positionmode ("manual
");
4375 // See the genprops.awk script for an explanation of the
4376 // properties declarations.
4377 // Programming note: Keep property list sorted if new ones are added.
4379 BEGIN_PROPERTIES (text)
4380 color_property backgroundcolor , color_property (radio_values ("{none}
"), color_values (1, 1, 1))
4381 color_property color u , color_property (color_values (0, 0, 0), radio_values ("none
"))
4382 color_property edgecolor , color_property (radio_values ("{none}
"), color_values (0, 0, 0))
4383 bool_property editing , "off
"
4384 array_property extent rG , Matrix (1, 4, 0.0)
4385 // FIXME: DEPRECATED: Remove "oblique
" in version 7.
4386 radio_property fontangle u , "{normal}|italic|oblique
"
4387 string_property fontname u , OCTAVE_DEFAULT_FONTNAME
4388 double_property fontsize u , 10
4389 bool_property fontsmoothing u , "on
"
4390 radio_property fontunits SU , "inches|centimeters|normalized|{points}|pixels
"
4391 radio_property fontweight u , "{normal}|bold
"
4392 radio_property horizontalalignment mu , "{
left}|center|right
"
4393 radio_property interpreter u , "{tex}|none|latex
"
4394 radio_property linestyle , "{-}|--|:|-.|none
"
4395 double_property linewidth , 0.5
4396 double_property margin , 3
4397 array_property position smu , Matrix (1, 3, 0.0)
4398 double_property rotation mu , 0
4399 text_label_property string u , ""
4400 radio_property units u , "{data}|pixels|normalized|inches|centimeters|points
"
4401 radio_property verticalalignment mu , "top|cap|{middle}|baseline|bottom
"
4403 // hidden properties for limit computation
4404 row_vector_property xlim hlr , Matrix ()
4405 row_vector_property ylim hlr , Matrix ()
4406 row_vector_property zlim hlr , Matrix ()
4407 bool_property xliminclude hl , "off
"
4408 bool_property yliminclude hl , "off
"
4409 bool_property zliminclude hl , "off
"
4410 // hidden properties for auto-positioning
4411 radio_property positionmode hu , "{
auto}|manual
"
4412 radio_property rotationmode hu , "{
auto}|manual
"
4413 radio_property horizontalalignmentmode hu , "{
auto}|manual
"
4414 radio_property verticalalignmentmode hu , "{
auto}|manual
"
4415 radio_property __autopos_tag__ h , "{none}|xlabel|ylabel|zlabel|title
"
4416 // hidden property for text rendering
4417 double_property __fontsize_points__ hgr , 0
4420 Matrix get_data_position (void) const;
4421 Matrix get_extent_matrix (void) const;
4422 const uint8NDArray& get_pixels (void) const { return pixels; }
4424 // Text renderer, used for calculation of text size
4425 octave::text_renderer txt_renderer;
4430 position.add_constraint (dim_vector (1, 3));
4431 fontsize.add_constraint ("min", 0.0, false);
4432 linewidth.add_constraint ("min", 0.0, false);
4433 margin.add_constraint ("min", 0.0, false);
4434 cached_units = get_units ();
4439 void update_position (void)
4441 Matrix pos = get_data_position ();
4444 lim = Matrix (1, 4, pos(0));
4445 lim(2) = (lim(2) <= 0 ? octave::numeric_limits<double>::Inf () : lim(2));
4446 lim(3) = (lim(3) >= 0 ? -octave::numeric_limits<double>::Inf () : lim(3));
4449 lim = Matrix (1, 4, pos(1));
4450 lim(2) = (lim(2) <= 0 ? octave::numeric_limits<double>::Inf () : lim(2));
4451 lim(3) = (lim(3) >= 0 ? -octave::numeric_limits<double>::Inf () : lim(3));
4454 if (pos.numel () == 3)
4456 lim = Matrix (1, 4, pos(2));
4457 lim(2) = (lim(2) <= 0 ? octave::numeric_limits<double>::Inf ()
4459 lim(3) = (lim(3) >= 0 ? -octave::numeric_limits<double>::Inf ()
4461 set_zliminclude ("on
");
4465 set_zliminclude ("off
");
4468 void request_autopos (void);
4469 void update_positionmode (void) { request_autopos (); }
4470 void update_rotationmode (void) { request_autopos (); }
4471 void update_horizontalalignmentmode (void) { request_autopos (); }
4472 void update_verticalalignmentmode (void) { request_autopos (); }
4474 void update_string (void) { request_autopos (); update_text_extent (); }
4475 void update_rotation (void) { update_text_extent (); }
4476 void update_fontname (void) { update_font (); update_text_extent (); }
4477 void update_fontsize (void) { update_font (); update_text_extent (); }
4478 void update_fontsmoothing (void) { update_font (); update_text_extent (); }
4480 void update_color (void)
4482 if (! color.is ("none
"))
4485 update_text_extent ();
4489 void update_fontangle (void)
4492 update_text_extent ();
4493 // FIXME: DEPRECATED: Remove warning for "oblique
" in version 7.
4494 if (fontangle.is ("oblique
"))
4495 warning_with_id ("Octave:deprecated-
property",
4496 "Setting
'fontangle' to
'%s' is deprecated, \
4497 use
'italic' or
'normal'.
", fontangle.current_value ().c_str ());
4499 void update_fontweight (void) { update_font (); update_text_extent (); }
4501 void update_interpreter (void) { update_text_extent (); }
4502 void update_horizontalalignment (void) { update_text_extent (); }
4503 void update_verticalalignment (void) { update_text_extent (); }
4505 void update_units (void);
4506 void update_fontunits (const caseless_str& old_fontunits);
4509 std::string cached_units;
4510 uint8NDArray pixels;
4514 properties xproperties;
4517 text (const graphics_handle& mh, const graphics_handle& p)
4518 : base_graphics_object (), xproperties (mh, p)
4520 xproperties.set_clipping ("off
");
4523 ~text (void) = default;
4525 base_properties& get_properties (void) { return xproperties; }
4527 const base_properties& get_properties (void) const { return xproperties; }
4529 bool valid_object (void) const { return true; }
4531 bool has_readonly_property (const caseless_str& pname) const
4533 bool retval = xproperties.has_readonly_property (pname);
4535 retval = base_properties::has_readonly_property (pname);
4540 // ---------------------------------------------------------------------
4542 class OCTINTERP_API image : public base_graphics_object
4545 class OCTINTERP_API properties : public base_properties
4548 bool is_aliminclude (void) const
4549 { return (aliminclude.is_on () && alphadatamapping.is ("scaled
")); }
4550 std::string get_aliminclude (void) const
4551 { return aliminclude.current_value (); }
4553 bool is_climinclude (void) const
4554 { return (climinclude.is_on () && cdatamapping.is ("scaled
")); }
4555 std::string get_climinclude (void) const
4556 { return climinclude.current_value (); }
4558 octave_value get_color_data (void) const;
4560 void initialize_data (void) { update_cdata (); }
4562 // See the genprops.awk script for an explanation of the
4563 // properties declarations.
4564 // Programming note: Keep property list sorted if new ones are added.
4566 BEGIN_PROPERTIES (image)
4567 array_property alphadata u , Matrix (1, 1, 1.0)
4568 radio_property alphadatamapping al , "{none}|direct|scaled
"
4569 array_property cdata u , default_image_cdata ()
4570 radio_property cdatamapping al , "scaled|{direct}
"
4571 row_vector_property xdata mu , Matrix ()
4572 row_vector_property ydata mu , Matrix ()
4573 // hidden properties for limit computation
4574 row_vector_property alim hlr , Matrix ()
4575 row_vector_property clim hlr , Matrix ()
4576 row_vector_property xlim hlr , Matrix ()
4577 row_vector_property ylim hlr , Matrix ()
4578 bool_property aliminclude hlg , "on
"
4579 bool_property climinclude hlg , "on
"
4580 bool_property xliminclude hl , "on
"
4581 bool_property yliminclude hl , "on
"
4582 radio_property xdatamode ha , "{
auto}|manual
"
4583 radio_property ydatamode ha , "{
auto}|manual
"
4589 xdata.add_constraint (2);
4590 xdata.add_constraint (dim_vector (0, 0));
4591 ydata.add_constraint (2);
4592 ydata.add_constraint (dim_vector (0, 0));
4593 cdata.add_constraint ("double");
4594 cdata.add_constraint ("single
");
4595 cdata.add_constraint ("logical
");
4596 cdata.add_constraint ("int8
");
4597 cdata.add_constraint ("int16
");
4598 cdata.add_constraint ("int32
");
4599 cdata.add_constraint ("int64
");
4600 cdata.add_constraint ("uint8
");
4601 cdata.add_constraint ("uint16
");
4602 cdata.add_constraint ("uint32
");
4603 cdata.add_constraint ("uint64
");
4604 cdata.add_constraint ("real");
4605 cdata.add_constraint (dim_vector (-1, -1));
4606 cdata.add_constraint (dim_vector (-1, -1, 3));
4607 alphadata.add_constraint ("double");
4608 alphadata.add_constraint ("uint8
");
4609 alphadata.add_constraint (dim_vector (-1, -1));
4613 void update_alphadata (void)
4615 if (alphadatamapping_is ("scaled
"))
4616 set_alim (alphadata.get_limits ());
4618 alim = alphadata.get_limits ();
4621 void update_cdata (void)
4623 if (cdatamapping_is ("scaled
"))
4624 set_clim (cdata.get_limits ());
4626 clim = cdata.get_limits ();
4628 if (xdatamode.is ("auto"))
4631 if (ydatamode.is ("auto"))
4635 void update_xdata (void)
4637 if (xdata.get ().isempty ())
4638 set_xdatamode ("auto");
4640 if (xdatamode.is ("auto"))
4642 set_xdata (get_auto_xdata ());
4643 set_xdatamode ("auto");
4646 Matrix limits = xdata.get_limits ();
4647 float dp = pixel_xsize ();
4649 limits(0) = limits(0) - dp;
4650 limits(1) = limits(1) + dp;
4654 void update_ydata (void)
4656 if (ydata.get ().isempty ())
4657 set_ydatamode ("auto");
4659 if (ydatamode.is ("auto"))
4661 set_ydata (get_auto_ydata ());
4662 set_ydatamode ("auto");
4665 Matrix limits = ydata.get_limits ();
4666 float dp = pixel_ysize ();
4668 limits(0) = limits(0) - dp;
4669 limits(1) = limits(1) + dp;
4673 Matrix get_auto_xdata (void)
4675 dim_vector dv = get_cdata ().dims ();
4679 data = Matrix (1, 2, 1);
4685 Matrix get_auto_ydata (void)
4687 dim_vector dv = get_cdata ().dims ();
4691 data = Matrix (1, 2, 1);
4697 float pixel_size (octave_idx_type dim, const Matrix limits)
4699 octave_idx_type l = dim - 1;
4702 if (l > 0 && limits(0) != limits(1))
4703 dp = (limits(1) - limits(0))/(2*l);
4706 if (limits(1) == limits(2))
4709 dp = (limits(1) - limits(0))/2;
4715 float pixel_xsize (void)
4717 return pixel_size ((get_cdata ().dims ())(1), xdata.get_limits ());
4720 float pixel_ysize (void)
4722 return pixel_size ((get_cdata ().dims ())(0), ydata.get_limits ());
4727 properties xproperties;
4730 image (const graphics_handle& mh, const graphics_handle& p)
4731 : base_graphics_object (), xproperties (mh, p)
4733 xproperties.initialize_data ();
4736 ~image (void) = default;
4738 base_properties& get_properties (void) { return xproperties; }
4740 const base_properties& get_properties (void) const { return xproperties; }
4742 bool valid_object (void) const { return true; }
4744 bool has_readonly_property (const caseless_str& pname) const
4746 bool retval = xproperties.has_readonly_property (pname);
4748 retval = base_properties::has_readonly_property (pname);
4753 // ---------------------------------------------------------------------
4755 class OCTINTERP_API light : public base_graphics_object
4758 class OCTINTERP_API properties : public base_properties
4760 // See the genprops.awk script for an explanation of the
4761 // properties declarations.
4762 // Programming note: Keep property list sorted if new ones are added.
4764 BEGIN_PROPERTIES (light)
4765 color_property color , color_values (1, 1, 1)
4766 array_property position , default_light_position ()
4767 radio_property style , "{infinite}|local
"
4773 position.add_constraint (dim_vector (1, 3));
4777 void update_visible (void);
4781 properties xproperties;
4784 light (const graphics_handle& mh, const graphics_handle& p)
4785 : base_graphics_object (), xproperties (mh, p)
4788 ~light (void) = default;
4790 base_properties& get_properties (void) { return xproperties; }
4792 const base_properties& get_properties (void) const { return xproperties; }
4794 bool valid_object (void) const { return true; }
4796 bool has_readonly_property (const caseless_str& pname) const
4798 bool retval = xproperties.has_readonly_property (pname);
4800 retval = base_properties::has_readonly_property (pname);
4805 void initialize (const graphics_object& go);
4808 // ---------------------------------------------------------------------
4810 class OCTINTERP_API patch : public base_graphics_object
4813 class OCTINTERP_API properties : public base_properties
4816 octave_value get_color_data (void) const;
4818 // Matlab allows incoherent data to be stored into patch properties.
4819 // The patch should then be ignored by the renderer.
4820 bool has_bad_data (std::string& msg) const
4823 return ! msg.empty ();
4826 bool is_aliminclude (void) const
4827 { return (aliminclude.is_on () && alphadatamapping.is ("scaled
")); }
4828 std::string get_aliminclude (void) const
4829 { return aliminclude.current_value (); }
4831 bool is_climinclude (void) const
4832 { return (climinclude.is_on () && cdatamapping.is ("scaled
")); }
4833 std::string get_climinclude (void) const
4834 { return climinclude.current_value (); }
4836 bool get_do_lighting (void) const;
4838 std::vector<std::vector<octave_idx_type>> coplanar_last_idx;
4840 // See the genprops.awk script for an explanation of the
4841 // properties declarations.
4842 // Programming note: Keep property list sorted if new ones are added.
4844 BEGIN_PROPERTIES (patch)
4845 radio_property alphadatamapping l , "none|{scaled}|direct
"
4846 double_property ambientstrength , 0.3
4847 radio_property backfacelighting , "unlit|lit|{reverselit}
"
4848 array_property cdata u , Matrix ()
4849 radio_property cdatamapping l , "{scaled}|direct
"
4850 double_property diffusestrength , 0.6
4851 string_property displayname , ""
4852 double_radio_property edgealpha , double_radio_property (1.0, radio_values ("flat|interp
"))
4853 color_property edgecolor , color_property (color_values (0, 0, 0), radio_values ("none|flat|interp
"))
4854 radio_property edgelighting u , "{none}|flat|gouraud|phong
"
4855 double_radio_property facealpha , double_radio_property (1.0, radio_values ("flat|interp
"))
4856 color_property facecolor , color_property (color_values (0, 0, 0), radio_values ("none|flat|interp
"))
4857 radio_property facelighting u , "none|{flat}|gouraud|phong
"
4858 array_property facenormals m , Matrix ()
4859 radio_property facenormalsmode u , "{
auto}|manual
"
4860 array_property faces u , default_patch_faces ()
4861 array_property facevertexalphadata , Matrix ()
4862 array_property facevertexcdata u , Matrix ()
4863 radio_property linestyle , "{-}|--|:|-.|none
"
4864 double_property linewidth , 0.5
4865 radio_property marker , "{none}|+|o|*|.|
x|s|square|
d|diamond|^|v|>|<|p|pentagram|h|hexagram
"
4866 color_property markeredgecolor , color_property (radio_values ("none|{
auto}|flat
"), color_values (0, 0, 0))
4867 color_property markerfacecolor , color_property (radio_values ("{none}|
auto|flat
"), color_values (0, 0, 0))
4868 double_property markersize , 6
4869 double_property specularcolorreflectance , 1.0
4870 double_property specularexponent , 10.0
4871 double_property specularstrength , 0.9
4872 array_property vertexnormals m , Matrix ()
4873 radio_property vertexnormalsmode u , "{
auto}|manual
"
4874 array_property vertices u , default_patch_vertices ()
4875 array_property xdata u , default_patch_xdata ()
4876 array_property ydata u , default_patch_ydata ()
4877 array_property zdata u , Matrix ()
4879 // hidden properties for limit computation
4880 row_vector_property alim hlr , Matrix ()
4881 row_vector_property clim hlr , Matrix ()
4882 row_vector_property xlim hlr , Matrix ()
4883 row_vector_property ylim hlr , Matrix ()
4884 row_vector_property zlim hlr , Matrix ()
4885 bool_property aliminclude hlg , "on
"
4886 bool_property climinclude hlg , "on
"
4887 bool_property xliminclude hl , "on
"
4888 bool_property yliminclude hl , "on
"
4889 bool_property zliminclude hl , "on
"
4895 xdata.add_constraint (dim_vector (-1, -1));
4896 ydata.add_constraint (dim_vector (-1, -1));
4897 zdata.add_constraint (dim_vector (-1, -1));
4898 faces.add_constraint (dim_vector (-1, -1));
4899 vertices.add_constraint (dim_vector (-1, 2));
4900 vertices.add_constraint (dim_vector (-1, 3));
4901 cdata.add_constraint ("double");
4902 cdata.add_constraint ("single
");
4903 cdata.add_constraint ("logical
");
4904 cdata.add_constraint ("int8
");
4905 cdata.add_constraint ("int16
");
4906 cdata.add_constraint ("int32
");
4907 cdata.add_constraint ("int64
");
4908 cdata.add_constraint ("uint8
");
4909 cdata.add_constraint ("uint16
");
4910 cdata.add_constraint ("uint32
");
4911 cdata.add_constraint ("uint64
");
4912 cdata.add_constraint ("real");
4913 cdata.add_constraint (dim_vector (-1, -1));
4914 cdata.add_constraint (dim_vector (-1, -1, 3));
4915 facevertexcdata.add_constraint (dim_vector (-1, 1));
4916 facevertexcdata.add_constraint (dim_vector (-1, 3));
4917 facevertexcdata.add_constraint (dim_vector (0, 0));
4918 facevertexalphadata.add_constraint (dim_vector (-1, 1));
4919 facevertexalphadata.add_constraint (dim_vector (0, 0));
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 void update_normals (bool reset, bool force = false)
4941 update_face_normals (reset, force);
4942 update_vertex_normals (reset, force);
4947 std::string bad_data_msg;
4949 void update_faces (void) { update_data ();}
4951 void update_vertices (void) { update_data ();}
4953 void update_facevertexcdata (void) { update_data ();}
4955 void update_fvc (void);
4957 void update_xdata (void)
4959 if (get_xdata ().isempty ())
4961 // For compatibility with matlab behavior,
4962 // if x/ydata are set empty, silently empty other *data and
4963 // faces properties while vertices remain unchanged.
4964 set_ydata (Matrix ());
4965 set_zdata (Matrix ());
4966 set_cdata (Matrix ());
4967 set_faces (Matrix ());
4972 update_normals (true);
4975 set_xlim (xdata.get_limits ());
4978 void update_ydata (void)
4980 if (get_ydata ().isempty ())
4982 set_xdata (Matrix ());
4983 set_zdata (Matrix ());
4984 set_cdata (Matrix ());
4985 set_faces (Matrix ());
4990 update_normals (true);
4993 set_ylim (ydata.get_limits ());
4996 void update_zdata (void)
4999 update_normals (true);
5000 set_zlim (zdata.get_limits ());
5003 void update_cdata (void)
5006 update_normals (false);
5008 if (cdatamapping_is ("scaled
"))
5009 set_clim (cdata.get_limits ());
5011 clim = cdata.get_limits ();
5014 void update_data (void);
5016 void calc_face_normals (Matrix& normals);
5017 void update_face_normals (bool reset, bool force = false);
5018 void update_vertex_normals (bool reset, bool force = false);
5020 void update_edgelighting (void)
5022 update_normals (false);
5025 void update_facelighting (void)
5027 update_normals (false);
5030 void update_facenormalsmode (void)
5032 update_face_normals (false);
5035 void update_vertexnormalsmode (void)
5037 update_vertex_normals (false);
5040 void update_visible (void)
5043 update_normals (false);
5048 properties xproperties;
5049 property_list default_properties;
5052 patch (const graphics_handle& mh, const graphics_handle& p)
5053 : base_graphics_object (), xproperties (mh, p)
5056 ~patch (void) = default;
5058 base_properties& get_properties (void) { return xproperties; }
5060 const base_properties& get_properties (void) const { return xproperties; }
5062 bool valid_object (void) const { return true; }
5064 bool has_readonly_property (const caseless_str& pname) const
5066 bool retval = xproperties.has_readonly_property (pname);
5068 retval = base_properties::has_readonly_property (pname);
5072 void reset_default_properties (void);
5075 void initialize (const graphics_object& go);
5079 // ---------------------------------------------------------------------
5081 class OCTINTERP_API surface : public base_graphics_object
5084 class OCTINTERP_API properties : public base_properties
5087 octave_value get_color_data (void) const;
5089 bool is_aliminclude (void) const
5090 { return (aliminclude.is_on () && alphadatamapping.is ("scaled
")); }
5091 std::string get_aliminclude (void) const
5092 { return aliminclude.current_value (); }
5094 bool is_climinclude (void) const
5095 { return (climinclude.is_on () && cdatamapping.is ("scaled
")); }
5096 std::string get_climinclude (void) const
5097 { return climinclude.current_value (); }
5099 bool get_do_lighting (void) const;
5101 // See the genprops.awk script for an explanation of the
5102 // properties declarations.
5103 // Programming note: Keep property list sorted if new ones are added.
5105 BEGIN_PROPERTIES (surface)
5106 array_property alphadata u , Matrix (1, 1, 1.0)
5107 radio_property alphadatamapping l , "none|direct|{scaled}
"
5108 double_property ambientstrength , 0.3
5109 radio_property backfacelighting , "unlit|lit|{reverselit}
"
5110 array_property cdata u , default_surface_cdata ()
5111 radio_property cdatamapping al , "{scaled}|direct
"
5112 string_property cdatasource , ""
5113 double_property diffusestrength , 0.6
5114 string_property displayname , ""
5115 double_radio_property edgealpha , double_radio_property (1.0, radio_values ("flat|interp
"))
5116 color_property edgecolor , color_property (color_values (0, 0, 0), radio_values ("none|flat|interp
"))
5117 radio_property edgelighting u , "{none}|flat|gouraud|phong
"
5118 double_radio_property facealpha , double_radio_property (1.0, radio_values ("flat|interp|texturemap
"))
5119 color_property facecolor , color_property (radio_values ("none|{flat}|interp|texturemap
"), color_values (0, 0, 0))
5120 radio_property facelighting u , "none|{flat}|gouraud|phong
"
5121 array_property facenormals m , Matrix ()
5122 radio_property facenormalsmode u , "{
auto}|manual
"
5123 radio_property linestyle , "{-}|--|:|-.|none
"
5124 double_property linewidth , 0.5
5125 radio_property marker , "{none}|+|o|*|.|
x|s|square|
d|diamond|^|v|>|<|p|pentagram|h|hexagram
"
5126 color_property markeredgecolor , color_property (radio_values ("none|{
auto}|flat
"), color_values (0, 0, 0))
5127 color_property markerfacecolor , color_property (radio_values ("{none}|
auto|flat
"), color_values (0, 0, 0))
5128 double_property markersize , 6
5129 radio_property meshstyle , "{both}|row|column
"
5130 double_property specularcolorreflectance , 1
5131 double_property specularexponent , 10
5132 double_property specularstrength , 0.9
5133 array_property vertexnormals m , Matrix ()
5134 radio_property vertexnormalsmode u , "{
auto}|manual
"
5135 array_property xdata u , default_surface_xdata ()
5136 string_property xdatasource , ""
5137 array_property ydata u , default_surface_ydata ()
5138 string_property ydatasource , ""
5139 array_property zdata u , default_surface_zdata ()
5140 string_property zdatasource , ""
5142 // hidden properties for limit computation
5143 row_vector_property alim hlr , Matrix ()
5144 row_vector_property clim hlr , Matrix ()
5145 row_vector_property xlim hlr , Matrix ()
5146 row_vector_property ylim hlr , Matrix ()
5147 row_vector_property zlim hlr , Matrix ()
5148 bool_property aliminclude hlg , "on
"
5149 bool_property climinclude hlg , "on
"
5150 bool_property xliminclude hl , "on
"
5151 bool_property yliminclude hl , "on
"
5152 bool_property zliminclude hl , "on
"
5158 xdata.add_constraint (dim_vector (-1, -1));
5159 ydata.add_constraint (dim_vector (-1, -1));
5160 zdata.add_constraint (dim_vector (-1, -1));
5161 cdata.add_constraint ("double");
5162 cdata.add_constraint ("single
");
5163 cdata.add_constraint ("logical
");
5164 cdata.add_constraint ("int8
");
5165 cdata.add_constraint ("int16
");
5166 cdata.add_constraint ("int32
");
5167 cdata.add_constraint ("int64
");
5168 cdata.add_constraint ("uint8
");
5169 cdata.add_constraint ("uint16
");
5170 cdata.add_constraint ("uint32
");
5171 cdata.add_constraint ("uint64
");
5172 cdata.add_constraint ("real");
5173 cdata.add_constraint (dim_vector (-1, -1));
5174 cdata.add_constraint (dim_vector (-1, -1, 3));
5175 alphadata.add_constraint ("double");
5176 alphadata.add_constraint ("uint8
");
5177 alphadata.add_constraint (dim_vector (-1, -1));
5178 facenormals.add_constraint (dim_vector (-1, -1, 3));
5179 facenormals.add_constraint (dim_vector (0, 0));
5180 vertexnormals.add_constraint (dim_vector (-1, -1, 3));
5181 vertexnormals.add_constraint (dim_vector (0, 0));
5183 ambientstrength.add_constraint ("min", 0.0, true);
5184 ambientstrength.add_constraint ("max", 1.0, true);
5185 diffusestrength.add_constraint ("min", 0.0, true);
5186 diffusestrength.add_constraint ("max", 1.0, true);
5187 linewidth.add_constraint ("min", 0.0, false);
5188 markersize.add_constraint ("min", 0.0, false);
5189 specularcolorreflectance.add_constraint ("min", 0.0, true);
5190 specularcolorreflectance.add_constraint ("max", 1.0, true);
5191 specularexponent.add_constraint ("min", 0.0, false);
5192 specularstrength.add_constraint ("min", 0.0, true);
5193 specularstrength.add_constraint ("max", 1.0, true);
5197 void update_normals (bool reset, bool force = false)
5199 update_face_normals (reset, force);
5200 update_vertex_normals (reset, force);
5205 void update_alphadata (void)
5207 if (alphadatamapping_is ("scaled
"))
5208 set_alim (alphadata.get_limits ());
5210 alim = alphadata.get_limits ();
5213 void update_cdata (void)
5215 if (cdatamapping_is ("scaled
"))
5216 set_clim (cdata.get_limits ());
5218 clim = cdata.get_limits ();
5221 void update_xdata (void)
5223 update_normals (true);
5224 set_xlim (xdata.get_limits ());
5227 void update_ydata (void)
5229 update_normals (true);
5230 set_ylim (ydata.get_limits ());
5233 void update_zdata (void)
5235 update_normals (true);
5236 set_zlim (zdata.get_limits ());
5239 void update_face_normals (bool reset, bool force = false);
5240 void update_vertex_normals (bool reset, bool force = false);
5242 void update_facenormalsmode (void)
5243 { update_face_normals (false); }
5245 void update_vertexnormalsmode (void)
5246 { update_vertex_normals (false); }
5248 void update_edgelighting (void)
5249 { update_normals (false); }
5251 void update_facelighting (void)
5252 { update_normals (false); }
5254 void update_visible (void)
5257 update_normals (false);
5263 properties xproperties;
5266 surface (const graphics_handle& mh, const graphics_handle& p)
5267 : base_graphics_object (), xproperties (mh, p)
5270 ~surface (void) = default;
5272 base_properties& get_properties (void) { return xproperties; }
5274 const base_properties& get_properties (void) const { return xproperties; }
5276 bool valid_object (void) const { return true; }
5278 bool has_readonly_property (const caseless_str& pname) const
5280 bool retval = xproperties.has_readonly_property (pname);
5282 retval = base_properties::has_readonly_property (pname);
5287 // ---------------------------------------------------------------------
5289 class OCTINTERP_API hggroup : public base_graphics_object
5292 class OCTINTERP_API properties : public base_properties
5295 void remove_child (const graphics_handle& h, bool from_root = false);
5297 void adopt (const graphics_handle& h);
5299 // See the genprops.awk script for an explanation of the
5300 // properties declarations.
5301 // Programming note: Keep property list sorted if new ones are added.
5303 BEGIN_PROPERTIES (hggroup)
5304 string_property displayname , ""
5306 // hidden properties for limit computation
5307 row_vector_property alim hr , Matrix ()
5308 row_vector_property clim hr , Matrix ()
5309 row_vector_property xlim hr , Matrix ()
5310 row_vector_property ylim hr , Matrix ()
5311 row_vector_property zlim hr , Matrix ()
5312 bool_property aliminclude h , "on
"
5313 bool_property climinclude h , "on
"
5314 bool_property xliminclude h , "on
"
5315 bool_property yliminclude h , "on
"
5316 bool_property zliminclude h , "on
"
5320 void update_limits (void) const;
5322 void update_limits (const graphics_handle& h) const;
5331 properties xproperties;
5334 hggroup (const graphics_handle& mh, const graphics_handle& p)
5335 : base_graphics_object (), xproperties (mh, p)
5338 ~hggroup (void) = default;
5340 base_properties& get_properties (void) { return xproperties; }
5342 const base_properties& get_properties (void) const { return xproperties; }
5344 bool valid_object (void) const { return true; }
5346 void update_axis_limits (const std::string& axis_type);
5348 void update_axis_limits (const std::string& axis_type,
5349 const graphics_handle& h);
5351 bool has_readonly_property (const caseless_str& pname) const
5353 bool retval = xproperties.has_readonly_property (pname);
5355 retval = base_properties::has_readonly_property (pname);
5361 // ---------------------------------------------------------------------
5363 class OCTINTERP_API uimenu : public base_graphics_object
5366 class OCTINTERP_API properties : public base_properties
5369 void remove_child (const graphics_handle& h, bool from_root = false)
5371 base_properties::remove_child (h, from_root);
5374 void adopt (const graphics_handle& h)
5376 base_properties::adopt (h);
5379 // See the genprops.awk script for an explanation of the
5380 // properties declarations.
5381 // Programming note: Keep property list sorted if new ones are added.
5383 BEGIN_PROPERTIES (uimenu)
5384 string_property accelerator , ""
5385 callback_property callback , Matrix ()
5386 bool_property checked , "off
"
5387 bool_property enable , "on
"
5388 color_property foregroundcolor , color_values (0, 0, 0)
5389 string_property label , ""
5390 double_property position , 0
5391 bool_property separator , "off
"
5393 // Octave-specific properties
5394 string_property __fltk_label__ h , ""
5395 any_property __object__ h , Matrix ()
5401 position.add_constraint ("min", 0, false);
5406 properties xproperties;
5409 uimenu (const graphics_handle& mh, const graphics_handle& p)
5410 : base_graphics_object (), xproperties (mh, p)
5413 ~uimenu (void) = default;
5415 base_properties& get_properties (void) { return xproperties; }
5417 const base_properties& get_properties (void) const { return xproperties; }
5419 bool valid_object (void) const { return true; }
5421 bool has_readonly_property (const caseless_str& pname) const
5423 bool retval = xproperties.has_readonly_property (pname);
5425 retval = base_properties::has_readonly_property (pname);
5431 // ---------------------------------------------------------------------
5433 class OCTINTERP_API uicontextmenu : public base_graphics_object
5436 class OCTINTERP_API properties : public base_properties
5440 void add_dependent_obj (graphics_handle gh)
5441 { dependent_obj_list.push_back (gh); }
5443 // FIXME: the list may contain duplicates.
5444 // Should we return only unique elements?
5445 const std::list<graphics_handle> get_dependent_obj_list (void)
5446 { return dependent_obj_list; }
5448 // See the genprops.awk script for an explanation of the
5449 // properties declarations.
5450 // Programming note: Keep property list sorted if new ones are added.
5452 BEGIN_PROPERTIES (uicontextmenu)
5453 callback_property callback , Matrix ()
5454 array_property position , Matrix (1, 2, 0.0)
5456 // Octave-specific properties
5457 any_property __object__ h , Matrix ()
5463 position.add_constraint (dim_vector (1, 2));
5464 position.add_constraint (dim_vector (2, 1));
5465 visible.set (octave_value (false));
5469 // List of objects that might depend on this uicontextmenu object
5470 std::list<graphics_handle> dependent_obj_list;
5472 void update_beingdeleted (void);
5477 properties xproperties;
5480 uicontextmenu (const graphics_handle& mh, const graphics_handle& p)
5481 : base_graphics_object (), xproperties (mh, p)
5484 ~uicontextmenu (void) = default;
5486 base_properties& get_properties (void) { return xproperties; }
5488 const base_properties& get_properties (void) const { return xproperties; }
5490 bool valid_object (void) const { return true; }
5492 bool has_readonly_property (const caseless_str& pname) const
5494 bool retval = xproperties.has_readonly_property (pname);
5496 retval = base_properties::has_readonly_property (pname);
5502 // ---------------------------------------------------------------------
5504 class OCTINTERP_API uicontrol : public base_graphics_object
5507 class OCTINTERP_API properties : public base_properties
5510 Matrix get_boundingbox (bool internal = false,
5511 const Matrix& parent_pix_size = Matrix ()) const;
5513 double get___fontsize_points__ (double box_pix_height = 0) const;
5515 // See the genprops.awk script for an explanation of the
5516 // properties declarations.
5517 // Programming note: Keep property list sorted if new ones are added.
5519 BEGIN_PROPERTIES (uicontrol)
5520 color_property backgroundcolor , color_values (0.94, 0.94, 0.94)
5521 callback_property callback , Matrix ()
5522 array_property cdata , Matrix ()
5523 bool_property clipping , "on
"
5524 radio_property enable , "{on}|inactive|off
"
5525 array_property extent rG , Matrix (1, 4, 0.0)
5526 // FIXME: DEPRECATED: Remove "oblique
" in version 7.
5527 radio_property fontangle u , "{normal}|italic|oblique
"
5528 string_property fontname u , OCTAVE_DEFAULT_FONTNAME
5529 double_property fontsize u , 10
5530 radio_property fontunits S , "inches|centimeters|normalized|{points}|pixels
"
5531 radio_property fontweight u , "{normal}|bold
"
5532 color_property foregroundcolor , color_values (0, 0, 0)
5533 radio_property horizontalalignment , "left|{center}|right
"
5534 callback_property keypressfcn , Matrix ()
5535 double_property listboxtop , 1
5536 double_property max , 1
5537 double_property min , 0
5538 array_property position , default_control_position ()
5539 array_property sliderstep , default_control_sliderstep ()
5540 string_array_property string u , ""
5541 radio_property style S , "{pushbutton}|togglebutton|radiobutton|checkbox|edit|
text|slider|frame|listbox|popupmenu
"
5542 string_property tooltipstring , ""
5543 radio_property units u , "normalized|inches|centimeters|points|{pixels}|characters
"
5544 row_vector_property value , Matrix (1, 1, 0.0)
5545 radio_property verticalalignment , "top|{middle}|bottom
"
5547 // Octave-specific properties
5548 bool_property __focus__ h , "off
"
5549 any_property __object__ h , Matrix ()
5553 std::string cached_units;
5558 cdata.add_constraint ("double");
5559 cdata.add_constraint ("single
");
5560 cdata.add_constraint ("uint8
");
5561 cdata.add_constraint (dim_vector (-1, -1, 3));
5562 cdata.add_constraint (dim_vector (0, 0));
5563 position.add_constraint (dim_vector (1, 4));
5564 sliderstep.add_constraint (dim_vector (1, 2));
5565 fontsize.add_constraint ("min", 0.0, false);
5566 cached_units = get_units ();
5569 void update_text_extent (void);
5571 void update_string (void) { update_text_extent (); }
5572 void update_fontname (void) { update_text_extent (); }
5573 void update_fontsize (void) { update_text_extent (); }
5574 void update_fontangle (void)
5576 update_text_extent ();
5577 // FIXME: DEPRECATED: Remove warning for "oblique
" in version 7.
5578 if (fontangle.is ("oblique
"))
5579 warning_with_id ("Octave:deprecated-
property",
5580 "Setting
'fontangle' to
'%s' is deprecated, \
5581 use
'italic' or
'normal'.
", fontangle.current_value ().c_str ());
5583 void update_fontweight (void) { update_text_extent (); }
5585 void update_fontunits (const caseless_str& old_units);
5587 void update_units (void);
5592 properties xproperties;
5595 uicontrol (const graphics_handle& mh, const graphics_handle& p)
5596 : base_graphics_object (), xproperties (mh, p)
5599 ~uicontrol (void) = default;
5601 base_properties& get_properties (void) { return xproperties; }
5603 const base_properties& get_properties (void) const { return xproperties; }
5605 bool valid_object (void) const { return true; }
5607 bool has_readonly_property (const caseless_str& pname) const
5609 bool retval = xproperties.has_readonly_property (pname);
5611 retval = base_properties::has_readonly_property (pname);
5616 // ---------------------------------------------------------------------
5618 class OCTINTERP_API uibuttongroup : public base_graphics_object
5621 class OCTINTERP_API properties : public base_properties
5624 void remove_child (const graphics_handle& h, bool from_root = false);
5626 void adopt (const graphics_handle& h);
5628 Matrix get_boundingbox (bool internal = false,
5629 const Matrix& parent_pix_size = Matrix ()) const;
5631 double get___fontsize_points__ (double box_pix_height = 0) const;
5633 // See the genprops.awk script for an explanation of the
5634 // properties declarations.
5635 // Programming note: Keep property list sorted if new ones are added.
5637 BEGIN_PROPERTIES (uibuttongroup)
5638 color_property backgroundcolor , color_values (0.94, 0.94, 0.94)
5639 radio_property bordertype , "none|{etchedin}|etchedout|beveledin|beveledout|
line"
5640 double_property borderwidth , 1
5641 bool_property clipping , "on
"
5642 // FIXME: DEPRECATED: Remove "oblique
" in version 7.
5643 radio_property fontangle , "{normal}|italic|oblique
"
5644 string_property fontname , OCTAVE_DEFAULT_FONTNAME
5645 double_property fontsize , 10
5646 radio_property fontunits S , "inches|centimeters|normalized|{points}|pixels
"
5647 radio_property fontweight , "{normal}|bold
"
5648 color_property foregroundcolor , color_values (0, 0, 0)
5649 color_property highlightcolor , color_values (1, 1, 1)
5650 array_property position S , default_panel_position ()
5651 // FIXME: "resizefcn
" is no longer recommended by Matlab,
5652 // and has been replaced with "sizechangedfcn
"
5653 // Eventually this will need to be hidden, and then removed.
5654 callback_property resizefcn , Matrix ()
5655 handle_property selectedobject S , graphics_handle ()
5656 callback_property selectionchangedfcn , Matrix ()
5657 color_property shadowcolor , color_values (0.7, 0.7, 0.7)
5658 callback_property sizechangedfcn , Matrix ()
5659 radio_property units S , "{normalized}|inches|centimeters|points|pixels|characters
"
5660 string_property title , ""
5661 radio_property titleposition , "{lefttop}|centertop|righttop|leftbottom|centerbottom|rightbottom
"
5663 // Octave-specific properties
5664 any_property __object__ h , Matrix ()
5670 position.add_constraint (dim_vector (1, 4));
5671 borderwidth.add_constraint ("min", 0.0, true);
5672 fontsize.add_constraint ("min", 0.0, false);
5675 // void update_text_extent (void);
5676 // void update_string (void) { update_text_extent (); }
5677 // void update_fontname (void) { update_text_extent (); }
5678 // void update_fontsize (void) { update_text_extent (); }
5679 // void update_fontangle (void) { update_text_extent (); }
5680 // void update_fontweight (void) { update_fontweight (); }
5682 void update_units (const caseless_str& old_units);
5683 void update_fontunits (const caseless_str& old_units);
5688 properties xproperties;
5691 uibuttongroup (const graphics_handle& mh, const graphics_handle& p)
5692 : base_graphics_object (), xproperties (mh, p)
5695 ~uibuttongroup (void) = default;
5697 base_properties& get_properties (void) { return xproperties; }
5699 const base_properties& get_properties (void) const { return xproperties; }
5701 bool valid_object (void) const { return true; }
5703 bool has_readonly_property (const caseless_str& pname) const
5705 bool retval = xproperties.has_readonly_property (pname);
5707 retval = base_properties::has_readonly_property (pname);
5713 // ---------------------------------------------------------------------
5715 class OCTINTERP_API uipanel : public base_graphics_object
5718 class OCTINTERP_API properties : public base_properties
5721 Matrix get_boundingbox (bool internal = false,
5722 const Matrix& parent_pix_size = Matrix ()) const;
5724 double get___fontsize_points__ (double box_pix_height = 0) const;
5726 // See the genprops.awk script for an explanation of the
5727 // properties declarations.
5728 // Programming note: Keep property list sorted if new ones are added.
5730 BEGIN_PROPERTIES (uipanel)
5731 color_property backgroundcolor , color_values (0.94, 0.94, 0.94)
5732 radio_property bordertype , "none|{etchedin}|etchedout|beveledin|beveledout|
line"
5733 double_property borderwidth , 1
5734 // FIXME: DEPRECATED: Remove "oblique
" in version 7.
5735 radio_property fontangle , "{normal}|italic|oblique
"
5736 string_property fontname , OCTAVE_DEFAULT_FONTNAME
5737 double_property fontsize , 10
5738 radio_property fontunits S , "inches|centimeters|normalized|{points}|pixels
"
5739 radio_property fontweight , "{normal}|bold
"
5740 color_property foregroundcolor , color_values (0, 0, 0)
5741 color_property highlightcolor , color_values (1, 1, 1)
5742 array_property position S , default_panel_position ()
5743 // FIXME: "resizefcn
" is no longer recommended by Matlab,
5744 // and has been replaced with "sizechangedfcn
"
5745 // Eventually this will need to be hidden, and then removed.
5746 callback_property resizefcn , Matrix ()
5747 color_property shadowcolor , color_values (0.7, 0.7, 0.7)
5748 callback_property sizechangedfcn , Matrix ()
5749 string_property title , ""
5750 radio_property titleposition , "{lefttop}|centertop|righttop|leftbottom|centerbottom|rightbottom
"
5751 radio_property units S , "{normalized}|inches|centimeters|points|pixels|characters
"
5752 // Octave-specific properties
5753 any_property __object__ h , Matrix ()
5759 borderwidth.add_constraint ("min", 0.0, true);
5760 fontsize.add_constraint ("min", 0.0, false);
5761 position.add_constraint (dim_vector (1, 4));
5764 void update_units (const caseless_str& old_units);
5765 void update_fontunits (const caseless_str& old_units);
5770 properties xproperties;
5773 uipanel (const graphics_handle& mh, const graphics_handle& p)
5774 : base_graphics_object (), xproperties (mh, p)
5777 ~uipanel (void) = default;
5779 base_properties& get_properties (void) { return xproperties; }
5781 const base_properties& get_properties (void) const { return xproperties; }
5783 bool valid_object (void) const { return true; }
5785 bool has_readonly_property (const caseless_str& pname) const
5787 bool retval = xproperties.has_readonly_property (pname);
5789 retval = base_properties::has_readonly_property (pname);
5794 // ---------------------------------------------------------------------
5796 class OCTINTERP_API uitable : public base_graphics_object
5799 class OCTINTERP_API properties : public base_properties
5802 Matrix get_boundingbox (bool internal = false,
5803 const Matrix& parent_pix_size = Matrix ()) const;
5805 double get___fontsize_points__ (double box_pix_height = 0) const;
5807 double get_fontsize_pixels (double box_pix_height = 0) const;
5809 // See the genprops.awk script for an explanation of the
5810 // properties declarations.
5811 // Programming note: Keep property list sorted if new ones are added.
5813 // FIXME: keypressfcn, keyreleasefcn, rearrangeablecolumns properties
5814 // seem to have been removed from Matlab.
5816 BEGIN_PROPERTIES (uitable)
5817 any_property __object__ h , Matrix ()
5818 array_property backgroundcolor , default_table_backgroundcolor ()
5819 callback_property celleditcallback , Matrix ()
5820 callback_property cellselectioncallback , Matrix ()
5821 row_vector_property columneditable , Matrix ()
5822 any_property columnformat S , Cell ()
5823 any_property columnname , "numbered
"
5824 any_property columnwidth S , "auto"
5825 any_property data u , Matrix ()
5826 bool_property enable , "on
"
5827 array_property extent rG , Matrix (1, 4, 0.0)
5828 // FIXME: DEPRECATED: Remove "oblique
" in version 7.
5829 radio_property fontangle u , "{normal}|italic|oblique
"
5830 string_property fontname u , OCTAVE_DEFAULT_FONTNAME
5831 double_property fontsize u , 10
5832 radio_property fontunits S , "inches|centimeters|normalized|{points}|pixels
"
5833 radio_property fontweight u , "{normal}|bold
"
5834 color_property foregroundcolor , color_values (0, 0, 0)
5835 callback_property keypressfcn , Matrix ()
5836 callback_property keyreleasefcn , Matrix ()
5837 array_property position , default_table_position ()
5838 bool_property rearrangeablecolumns , "off
"
5839 any_property rowname , "numbered
"
5840 bool_property rowstriping , "on
"
5841 string_property tooltipstring , ""
5842 radio_property units S , "normalized|inches|centimeters|points|{pixels}|characters
"
5845 Matrix get_extent_matrix (void) const;
5847 Matrix get_backgroundcolor_rgb (void);
5849 Matrix get_alternatebackgroundcolor_rgb (void);
5854 position.add_constraint (dim_vector (1, 4));
5855 extent.add_constraint (dim_vector (1, 4));
5856 backgroundcolor.add_constraint ("double");
5857 backgroundcolor.add_constraint (dim_vector (-1, 3));
5858 columneditable.add_constraint ("logical
");
5861 void update_units (const caseless_str& old_units);
5862 void update_fontunits (const caseless_str& old_units);
5863 void update_table_extent (void) { };
5864 void update_data (void) { update_table_extent (); }
5865 void update_fontname (void) { update_table_extent (); }
5866 void update_fontsize (void) { update_table_extent (); }
5867 void update_fontangle (void)
5869 update_table_extent ();
5870 // FIXME: DEPRECATED: Remove warning for "oblique
" in version 7.
5871 if (fontangle.is ("oblique
"))
5872 warning_with_id ("Octave:deprecated-
property",
5873 "Setting
'fontangle' to
'%s' is deprecated, \
5874 use
'italic' or
'normal'.
", fontangle.current_value ().c_str ());
5876 void update_fontweight (void) { update_table_extent (); }
5880 properties xproperties;
5883 uitable (const graphics_handle& mh, const graphics_handle& p)
5884 : base_graphics_object (), xproperties (mh, p)
5889 base_properties& get_properties (void) { return xproperties; }
5891 const base_properties& get_properties (void) const { return xproperties; }
5893 bool valid_object (void) const { return true; }
5895 bool has_readonly_property (const caseless_str& pname) const
5897 bool retval = xproperties.has_readonly_property (pname);
5899 retval = base_properties::has_readonly_property (pname);
5904 // ---------------------------------------------------------------------
5906 class OCTINTERP_API uitoolbar : public base_graphics_object
5909 class OCTINTERP_API properties : public base_properties
5912 // See the genprops.awk script for an explanation of the
5913 // properties declarations.
5914 // Programming note: Keep property list sorted if new ones are added.
5916 BEGIN_PROPERTIES (uitoolbar)
5917 // Octave-specific properties
5918 any_property __object__ h , Matrix ()
5927 properties xproperties;
5930 uitoolbar (const graphics_handle& mh, const graphics_handle& p)
5931 : base_graphics_object (), xproperties (mh, p), default_properties ()
5934 ~uitoolbar (void) = default;
5936 void override_defaults (base_graphics_object& obj)
5938 // Allow parent (figure) to override first (properties knows how
5939 // to find the parent object).
5940 xproperties.override_defaults (obj);
5942 // Now override with our defaults. If the default_properties
5943 // list includes the properties for all defaults (line,
5944 // surface, etc.) then we don't have to know the type of OBJ
5945 // here, we just call its set function and let it decide which
5946 // properties from the list to use.
5947 obj.set_from_list (default_properties);
5950 void set (const caseless_str& name, const octave_value& value)
5952 if (name.compare ("default
", 7))
5953 // strip "default", pass rest to function that will
5954 // parse the remainder and add the element to the
5955 // default_properties map.
5956 default_properties.set (name.substr (7), value);
5958 xproperties.set (name, value);
5961 octave_value get (const caseless_str& name) const
5963 octave_value retval;
5965 if (name.compare ("default", 7))
5966 retval = get_default (name.substr (7));
5968 retval = xproperties.get (name);
5973 octave_value get_default (const caseless_str& name) const;
5975 octave_value get_defaults (void) const
5977 return default_properties.as_struct ("default");
5980 property_list get_defaults_list (void) const
5982 return default_properties;
5985 base_properties& get_properties (void) { return xproperties; }
5987 const base_properties& get_properties (void) const { return xproperties; }
5989 bool valid_object (void) const { return true; }
5991 void reset_default_properties (void);
5993 bool has_readonly_property (const caseless_str& pname) const
5995 bool retval = xproperties.has_readonly_property (pname);
5997 retval = base_properties::has_readonly_property (pname);
6002 property_list default_properties;
6005 // ---------------------------------------------------------------------
6007 class OCTINTERP_API uipushtool : public base_graphics_object
6010 class OCTINTERP_API properties : public base_properties
6013 // See the genprops.awk script for an explanation of the
6014 // properties declarations.
6015 // Programming note: Keep property list sorted if new ones are added.
6017 BEGIN_PROPERTIES (uipushtool)
6018 array_property cdata , Matrix ()
6019 callback_property clickedcallback , Matrix ()
6020 bool_property enable , "on
"
6021 bool_property separator , "off
"
6022 string_property tooltipstring , ""
6024 // Octave-specific properties
6025 string_property __named_icon__ , ""
6026 any_property __object__ h , Matrix ()
6032 cdata.add_constraint ("double");
6033 cdata.add_constraint ("single
");
6034 cdata.add_constraint ("uint8
");
6035 cdata.add_constraint (dim_vector (-1, -1, 3));
6036 cdata.add_constraint (dim_vector (0, 0));
6041 properties xproperties;
6044 uipushtool (const graphics_handle& mh, const graphics_handle& p)
6045 : base_graphics_object (), xproperties (mh, p)
6048 ~uipushtool (void) = default;
6050 base_properties& get_properties (void) { return xproperties; }
6052 const base_properties& get_properties (void) const { return xproperties; }
6054 bool valid_object (void) const { return true; }
6056 bool has_readonly_property (const caseless_str& pname) const
6058 bool retval = xproperties.has_readonly_property (pname);
6060 retval = base_properties::has_readonly_property (pname);
6066 // ---------------------------------------------------------------------
6068 class OCTINTERP_API uitoggletool : public base_graphics_object
6071 class OCTINTERP_API properties : public base_properties
6074 // See the genprops.awk script for an explanation of the
6075 // properties declarations.
6076 // Programming note: Keep property list sorted if new ones are added.
6078 BEGIN_PROPERTIES (uitoggletool)
6079 array_property cdata , Matrix ()
6080 callback_property clickedcallback , Matrix ()
6081 bool_property enable , "on
"
6082 callback_property offcallback , Matrix ()
6083 callback_property oncallback , Matrix ()
6084 bool_property separator , "off
"
6085 bool_property state , "off
"
6086 string_property tooltipstring , ""
6088 // Octave-specific properties
6089 string_property __named_icon__ , ""
6090 any_property __object__ h , Matrix ()
6096 cdata.add_constraint ("double");
6097 cdata.add_constraint ("single
");
6098 cdata.add_constraint ("uint8
");
6099 cdata.add_constraint (dim_vector (-1, -1, 3));
6100 cdata.add_constraint (dim_vector (0, 0));
6105 properties xproperties;
6108 uitoggletool (const graphics_handle& mh, const graphics_handle& p)
6109 : base_graphics_object (), xproperties (mh, p)
6112 ~uitoggletool (void) = default;
6114 base_properties& get_properties (void) { return xproperties; }
6116 const base_properties& get_properties (void) const { return xproperties; }
6118 bool valid_object (void) const { return true; }
6120 bool has_readonly_property (const caseless_str& pname) const
6122 bool retval = xproperties.has_readonly_property (pname);
6124 retval = base_properties::has_readonly_property (pname);
6130 // ---------------------------------------------------------------------
6133 get_property_from_handle (double handle, const std::string& property,
6134 const std::string& func);
6136 set_property_in_handle (double handle, const std::string& property,
6137 const octave_value& arg, const std::string& func);
6139 // ---------------------------------------------------------------------
6141 class graphics_event;
6147 enum priority { INTERRUPT, QUEUE, CANCEL };
6149 friend class graphics_event;
6151 base_graphics_event (void)
6152 : m_busyaction (QUEUE)
6155 base_graphics_event (int busyaction)
6156 : m_busyaction (busyaction)
6159 virtual ~base_graphics_event (void) = default;
6161 int get_busyaction (void) { return m_busyaction; };
6163 virtual void execute (void) = 0;
6174 typedef void (*event_fcn) (void*);
6176 graphics_event (void) = default;
6178 graphics_event (base_graphics_event *new_rep) : rep (new_rep) { }
6180 graphics_event (const graphics_event&) = default;
6182 ~graphics_event (void) = default;
6184 graphics_event& operator = (const graphics_event&) = default;
6186 int get_busyaction (void)
6189 return rep->get_busyaction ();
6200 bool ok (void) const { return (rep != nullptr); }
6202 static graphics_event
6203 create_callback_event (const graphics_handle& h,
6204 const std::string& name,
6205 const octave_value& data = Matrix (),
6206 int busyaction = base_graphics_event::QUEUE);
6208 static graphics_event
6209 create_callback_event (const graphics_handle& h,
6210 const octave_value& cb,
6211 const octave_value& data = Matrix (),
6212 int busyaction = base_graphics_event::QUEUE);
6214 static graphics_event
6215 create_mcode_event (const graphics_handle& h, const std::string& cmd,
6218 static graphics_event
6219 create_function_event (event_fcn fcn, void *data = nullptr);
6221 static graphics_event
6222 create_set_event (const graphics_handle& h, const std::string& name,
6223 const octave_value& value, bool notify_toolkit = true,
6224 bool redraw_figure = false);
6227 std::shared_ptr <base_graphics_event> rep;
6230 class OCTINTERP_API gh_manager
6234 gh_manager (octave::interpreter& interp);
6236 // FIXME: eventually eliminate these static functions and access
6237 // gh_manager object through the interpreter.
6239 graphics_handle get_handle (bool integer_figure_handle);
6241 void free (const graphics_handle& h, bool from_root = false);
6243 void renumber_figure (const graphics_handle& old_gh,
6244 const graphics_handle& new_gh);
6246 graphics_handle lookup (double val) const
6248 const_iterator p = (octave::math::isnan (val)
6249 ? m_handle_map.end () : m_handle_map.find (val));
6251 return (p != m_handle_map.end ()) ? p->first : graphics_handle ();
6254 graphics_handle lookup (const octave_value& val) const
6256 return (val.is_real_scalar ()
6257 ? lookup (val.double_value ()) : graphics_handle ());
6260 graphics_object get_object (double val) const
6262 return get_object (lookup (val));
6265 graphics_object get_object (const graphics_handle& h) const
6267 const_iterator p = (h.ok () ? m_handle_map.find (h) : m_handle_map.end ());
6269 return (p != m_handle_map.end ()) ? p->second : graphics_object ();
6272 graphics_handle make_graphics_handle (const std::string& go_name,
6273 const graphics_handle& p,
6274 bool integer_figure_handle = false,
6275 bool call_createfcn = true,
6276 bool notify_toolkit = true);
6278 graphics_handle make_figure_handle (double val,
6279 bool notify_toolkit = true);
6281 void push_figure (const graphics_handle& h);
6283 void pop_figure (const graphics_handle& h);
6285 graphics_handle current_figure (void) const
6287 graphics_handle retval;
6289 for (const auto& hfig : m_figure_list)
6291 if (is_handle_visible (hfig))
6298 Matrix handle_list (bool show_hidden = false)
6300 Matrix retval (1, m_handle_map.size ());
6302 octave_idx_type i = 0;
6303 for (const auto& h_iter : m_handle_map)
6305 graphics_handle h = h_iter.first;
6307 if (show_hidden || is_handle_visible (h))
6308 retval(i++) = h.value ();
6311 retval.resize (1, i);
6316 void lock (void) { m_graphics_lock.lock (); }
6318 bool try_lock (void) { return m_graphics_lock.try_lock (); }
6320 void unlock (void) { m_graphics_lock.unlock (); }
6322 Matrix figure_handle_list (bool show_hidden = false)
6324 Matrix retval (1, m_figure_list.size ());
6326 octave_idx_type i = 0;
6327 for (const auto& hfig : m_figure_list)
6329 if (show_hidden || is_handle_visible (hfig))
6330 retval(i++) = hfig.value ();
6333 retval.resize (1, i);
6338 void execute_listener (const graphics_handle& h, const octave_value& l);
6340 void execute_callback (const graphics_handle& h,
6341 const std::string& name,
6342 const octave_value& data = Matrix ())
6348 octave::autolock guard (graphics_lock ());
6350 graphics_object go = get_object (h);
6352 if (go.valid_object ())
6356 execute_callback (h, cb, data);
6359 void execute_callback (const graphics_handle& h, const octave_value& cb,
6360 const octave_value& data = Matrix ());
6362 void post_callback (const graphics_handle& h, const std::string& name,
6363 const octave_value& data = Matrix ());
6365 void post_function (graphics_event::event_fcn fcn, void *fcn_data = nullptr);
6367 void post_set (const graphics_handle& h, const std::string& name,
6368 const octave_value& value, bool notify_toolkit = true,
6369 bool redraw_figure = false);
6371 int process_events (bool force = false);
6373 void enable_event_processing (bool enable = true);
6375 bool is_handle_visible (const graphics_handle& h) const
6377 bool retval = false;
6379 graphics_object go = get_object (h);
6381 if (go.valid_object ())
6382 retval = go.is_handle_visible ();
6387 void close_all_figures (void);
6389 void restore_gcbo (void);
6391 void post_event (const graphics_event& e);
6393 octave::mutex graphics_lock (void)
6395 return m_graphics_lock;
6400 typedef std::map<graphics_handle, graphics_object>::iterator iterator;
6401 typedef std::map<graphics_handle, graphics_object>::const_iterator
6404 typedef std::set<graphics_handle>::iterator free_list_iterator;
6405 typedef std::set<graphics_handle>::const_iterator const_free_list_iterator;
6407 typedef std::list<graphics_handle>::iterator figure_list_iterator;
6408 typedef std::list<graphics_handle>::const_iterator const_figure_list_iterator;
6410 octave::interpreter& m_interpreter;
6412 // A map of handles to graphics objects.
6413 std::map<graphics_handle, graphics_object> m_handle_map;
6415 // The available graphics handles.
6416 std::set<graphics_handle> m_handle_free_list;
6418 // The next handle available if m_handle_free_list is empty.
6419 double m_next_handle;
6421 // The allocated figure handles. Top of the stack is most recently
6423 std::list<graphics_handle> m_figure_list;
6425 // The lock for accessing the graphics sytsem.
6426 octave::mutex m_graphics_lock;
6428 // The list of events queued by graphics toolkits.
6429 std::list<graphics_event> m_event_queue;
6431 // The stack of callback objects.
6432 std::list<graphics_object> m_callback_objects;
6434 // A flag telling whether event processing must be constantly on.
6435 int m_event_processing;
6438 void get_children_limits (double& min_val, double& max_val,
6439 double& min_pos, double& max_neg,
6440 const Matrix& kids, char limit_type);
6442 OCTINTERP_API int calc_dimensions (const graphics_object& gh);
6444 // This function is NOT equivalent to the scripting language function gcf.
6445 OCTINTERP_API graphics_handle gcf (void);
6447 // This function is NOT equivalent to the scripting language function gca.
6448 OCTINTERP_API graphics_handle gca (void);
6450 OCTINTERP_API void close_all_figures (void);
charNDArray max(char d, const charNDArray &m)
charNDArray min(char d, const charNDArray &m)
Array< T > sort(int dim=0, sortmode mode=ASCENDING) const
Size of the specified dimension.
T & xelem(octave_idx_type n)
Size of the specified dimension.
octave_idx_type numel(void) const
Number of elements in the array.
octave_idx_type rows(void) const
const T * fortran_vec(void) const
Size of the specified dimension.
bool iscellstr(void) const
Array< std::string > cellstr_value(void) const
MArray< T > reshape(const dim_vector &new_dims) const
Matrix stack(const Matrix &a) const
base_property * clone(void) const
any_property(const any_property &p)
any_property & operator=(const octave_value &val)
any_property(const std::string &nm, const graphics_handle &h, const octave_value &m=Matrix())
octave_value get(void) const
bool do_set(const octave_value &v)
finite_type finite_constraint
array_property(const array_property &p)
std::pair< double, bool > minval
std::pair< double, bool > maxval
double max_val(void) const
bool do_set(const octave_value &v)
OCTINTERP_API void get_data_limits(void)
array_property(const std::string &nm, const graphics_handle &h, const octave_value &m)
OCTINTERP_API bool is_equal(const octave_value &v) const
double min_val(void) const
Matrix get_limits(void) const
OCTINTERP_API bool validate(const octave_value &v)
base_property * clone(void) const
double min_pos(void) const
octave_value get(void) const
std::list< dim_vector > size_constraints
std::set< std::string > type_constraints
void add_constraint(const dim_vector &dims)
void add_constraint(const std::string &type, double val, bool inclusive)
array_property & operator=(const octave_value &val)
void add_constraint(const finite_type finite)
void add_constraint(const std::string &type)
double max_neg(void) const
virtual octave::graphics_toolkit get_toolkit(void) const
virtual graphics_handle get_parent(void) const
virtual void adopt(const graphics_handle &h)
virtual property_list get_defaults_list(void) const
virtual property_list get_factory_defaults_list(void) const
graphics_handle get_handle(void) const
virtual void reparent(const graphics_handle &np)
virtual octave_value get_defaults(void) const
virtual base_properties & get_properties(void)
virtual void set(const caseless_str &pname, const octave_value &pval)
octave_value get(bool all=false) const
virtual void remove_child(const graphics_handle &h, bool from_root=false)
virtual octave_value get_factory_defaults(void) const
virtual void set_from_list(property_list &plist)
virtual void override_defaults(base_graphics_object &obj)
virtual void set_defaults(const std::string &)
virtual void mark_modified(void)
virtual bool is_yliminclude(void) const
void set___modified__(const octave_value &val)
BEGIN_BASE_PROPERTIES bool_property beingdeleted s
Matrix get_children(void) const
void reparent(const graphics_handle &new_parent)
virtual bool is_zliminclude(void) const
virtual bool is_climinclude(void) const
virtual bool is_aliminclude(void) const
bool is_modified(void) const
virtual octave_value get_ylim(void) const
Matrix get_hidden_children(void) const
virtual octave_value get_xlim(void) const
std::set< std::string > dynamic_properties
virtual ~base_properties(void)=default
Matrix get_all_children(void) const
virtual octave_value get(bool all=false) const
static property_list::pval_map_type factory_defaults(void)
virtual void set(const caseless_str &, const octave_value &)
void insert_property(const std::string &name, property p)
virtual bool is_xliminclude(void) const
virtual bool has_property(const caseless_str &) const
BEGIN_BASE_PROPERTIES bool_property beingdeleted off radio_property busyaction
void set_modified(const octave_value &val)
virtual octave_value get_alim(void) const
virtual octave_value get(const caseless_str &pname) const
virtual octave_value get(const char *pname) const
virtual void adopt(const graphics_handle &h)
virtual octave_value get_zlim(void) const
virtual octave_value get_clim(void) const
void set_beingdeleted(const octave_value &val)
virtual void init_integerhandle(const octave_value &)
virtual void delete_children(bool clear=false, bool from_root=false)
virtual void remove_child(const graphics_handle &h, bool=false)
base_properties(const std::string &ty="unknown", const graphics_handle &mh=graphics_handle(), const graphics_handle &p=graphics_handle())
virtual property get_property(const caseless_str &pname)
virtual std::string graphics_object_name(void) const
void renumber_child(graphics_handle old_gh, graphics_handle new_gh)
virtual octave_value get(const std::string &pname) const
virtual Matrix get_boundingbox(bool=false, const Matrix &=Matrix()) const
void set_tag(const octave_value &val)
void renumber_parent(graphics_handle new_gh)
virtual base_property * clone(void) const
octave::refcount< octave_idx_type > count
void set_name(const std::string &s)
void set_parent(const graphics_handle &h)
std::map< listener_mode, octave_value_list >::iterator listener_map_iterator
void add_listener(const octave_value &v, listener_mode mode=GCB_POSTSET)
bool is_hidden(void) const
std::map< listener_mode, octave_value_list >::const_iterator listener_map_const_iterator
base_property & operator=(const octave_value &val)
virtual Cell values_as_cell(void) const
base_property(const base_property &p)
virtual ~base_property(void)=default
virtual octave_value get(void) const
void delete_listener(const octave_value &v=octave_value(), listener_mode mode=GCB_POSTSET)
std::string get_name(void) const
virtual bool do_set(const octave_value &)
virtual std::string values_as_string(void) const
void set_hidden(bool flag)
OCTINTERP_API void run_listeners(listener_mode mode=GCB_POSTSET)
base_property(const std::string &s, const graphics_handle &h)
std::map< listener_mode, octave_value_list > listener_map
graphics_handle get_parent(void) const
virtual bool is_radio(void) const
OCTINTERP_API bool set(const octave_value &v, bool do_run=true, bool do_notify_toolkit=true)
virtual ~base_scaler(void)=default
virtual double unscale(double) const
virtual double scale(double) const
virtual NDArray scale(const NDArray &) const
virtual bool is_linear(void) const
virtual base_scaler * clone() const
virtual Matrix scale(const Matrix &) const
bool_property(const std::string &nm, const graphics_handle &h, bool val)
bool do_set(const octave_value &val)
base_property * clone(void) const
bool_property(const std::string &nm, const graphics_handle &h, const char *val)
bool_property(const bool_property &p)
bool_property & operator=(const octave_value &val)
bool do_set(const octave_value &v)
octave_value get(void) const
callback_property(const callback_property &p)
OCTINTERP_API void execute(const octave_value &data=octave_value()) const
callback_property & operator=(const octave_value &val)
OCTINTERP_API bool validate(const octave_value &v) const
bool is_defined(void) const
base_property * clone(void) const
callback_property(const std::string &nm, const graphics_handle &h, const octave_value &m)
bool compare(const std::string &s, size_t limit=std::string::npos) const
std::string row_as_string(octave_idx_type, bool strip_ws=false) const
Matrix get_all(void) const
Matrix get_children(void) const
octave_value get(void) const
void delete_children(bool clear=false, bool from_root=false)
bool do_remove_child(double child)
children_property(const children_property &p)
void do_init_children(const Matrix &val)
void do_adopt_child(double val)
Matrix do_get_all_children(void) const
std::list< double >::iterator children_list_iterator
children_property & operator=(const octave_value &val)
void do_delete_children(bool clear, bool from_root)
Matrix do_get_children(bool return_hidden) const
std::list< double > children_list
std::list< double >::const_iterator const_children_list_iterator
void do_init_children(const std::list< double > &val)
void renumber(graphics_handle old_gh, graphics_handle new_gh)
Matrix get_hidden(void) const
bool remove_child(double val)
children_property(const std::string &nm, const graphics_handle &h, const Matrix &val)
bool do_set(const octave_value &val)
base_property * clone(void) const
color_property(const radio_values &v, const color_values &c)
color_property(const std::string &nm, const graphics_handle &h, const color_values &c=color_values(), const radio_values &v=radio_values())
const std::string & current_value(void) const
bool is(const std::string &v) const
color_property(const color_values &c, const radio_values &v)
color_property(const color_property &p)
OCTINTERP_API bool do_set(const octave_value &newval)
color_property(const std::string &nm, const graphics_handle &h, const radio_values &v)
color_property(const std::string &nm, const graphics_handle &h, const color_property &v)
color_property(const std::string &nm, const graphics_handle &h, const std::string &v)
base_property * clone(void) const
enum color_property::current_enum current_type
std::string values_as_string(void) const
bool is_radio(void) const
Cell values_as_cell(void) const
color_property & operator=(const octave_value &val)
octave_value get(void) const
OCTINTERP_API bool str2rgb(const std::string &str)
color_values(double r=0, double g=0, double b=1)
bool operator!=(const color_values &c) const
color_values(const std::string &str)
color_values(const color_values &c)
bool operator==(const color_values &c) const
color_values & operator=(const color_values &c)
void validate(void) const
Vector representing the dimensions (size) of an Array.
double_property(const double_property &p)
finite_type finite_constraint
double_property & operator=(const octave_value &val)
void add_constraint(const finite_type finite)
bool do_set(const octave_value &v)
std::pair< double, bool > minval
double_property(const std::string &nm, const graphics_handle &h, double d=0)
std::pair< double, bool > maxval
base_property * clone(void) const
octave_value get(void) const
void add_constraint(const std::string &type, double val, bool inclusive)
double double_value(void) const
base_property * clone(void) const
const std::string & current_value(void) const
double_radio_property(const double_radio_property &p)
double_radio_property(const std::string &nm, const graphics_handle &h, const double_radio_property &v)
double_radio_property & operator=(const octave_value &val)
double double_value(void) const
enum double_radio_property::current_enum current_type
OCTINTERP_API bool do_set(const octave_value &v)
double_radio_property(const std::string &nm, const graphics_handle &h, const std::string &v)
octave_value get(void) const
bool is_radio(void) const
bool is_double(void) const
bool is(const std::string &v) const
double_radio_property(double d, const radio_values &v)
std::set< std::string > type_constraints
handle_property(const handle_property &p)
base_property * clone(void) const
handle_property(const std::string &nm, const graphics_handle &h, const graphics_handle &val=graphics_handle())
graphics_handle current_val
octave_value get(void) const
void add_constraint(const std::string &type)
OCTINTERP_API bool do_set(const octave_value &v)
graphics_handle handle_value(void) const
handle_property & operator=(const octave_value &val)
base_scaler * clone(void) const
bool is_linear(void) const
double unscale(double d) const
double scale(double d) const
NDArray scale(const NDArray &m) const
Matrix scale(const Matrix &m) const
Matrix scale(const Matrix &m) const
base_scaler * clone(void) const
NDArray scale(const NDArray &m) const
void do_scale(const double *src, double *dest, int n) const
double unscale(double d) const
double scale(double d) const
Matrix scale(const Matrix &m) const
double unscale(double d) const
void do_scale(const double *src, double *dest, int n) const
NDArray scale(const NDArray &m) const
base_scaler * clone(void) const
double scale(double d) const
octave_value as_octave_value(void) const
void resize(octave_idx_type n, const octave_value &rfv=octave_value())
octave_idx_type length(void) const
bool iscellstr(void) const
bool bool_value(bool warn=false) const
bool issparse(void) const
charMatrix char_matrix_value(bool frc_str_conv=false) const
bool is_bool_scalar(void) const
octave_idx_type rows(void) const
bool is_scalar_type(void) const
octave_value full_value(void) const
bool is_string(void) const
bool is_defined(void) const
Cell cell_value(void) const
octave_value reshape(const dim_vector &dv) const
std::string string_value(bool force=false) const
string_vector string_vector_value(bool pad=false) const
NDArray array_value(bool frc_str_conv=false) const
Matrix matrix_value(bool frc_str_conv=false) const
double double_value(bool frc_str_conv=false) const
dim_vector dims(void) const
~property_list(void)=default
octave_scalar_map as_struct(const std::string &prefix_arg) const
plist_map_const_iterator end(void) const
plist_map_iterator find(const std::string &go_name)
property_list(const plist_map_type &m=plist_map_type())
plist_map_iterator end(void)
void set(const caseless_str &name, const octave_value &val)
plist_map_const_iterator find(const std::string &go_name) const
plist_map_type::const_iterator plist_map_const_iterator
pval_map_type::iterator pval_map_iterator
octave_value lookup(const caseless_str &name) const
plist_map_iterator begin(void)
pval_map_type::const_iterator pval_map_const_iterator
std::map< std::string, pval_map_type > plist_map_type
plist_map_type::iterator plist_map_iterator
plist_map_const_iterator begin(void) const
pval_vector pval_map_type
property & operator=(const octave_value &val)
void delete_listener(const octave_value &v=octave_value(), listener_mode mode=GCB_POSTSET)
std::string get_name(void) const
property clone(void) const
std::string values_as_string(void) const
octave_value get(void) const
static OCTINTERP_API property create(const std::string &name, const graphics_handle &parent, const caseless_str &type, const octave_value_list &args)
void set_hidden(bool flag)
bool is_radio(void) const
bool is_hidden(void) const
void set_parent(const graphics_handle &h)
property(base_property *bp, bool persist=false)
property(const property &p)
void set_name(const std::string &name)
void run_listeners(listener_mode mode=GCB_POSTSET)
graphics_handle get_parent(void) const
void add_listener(const octave_value &v, listener_mode mode=GCB_POSTSET)
bool set(const octave_value &val, bool do_run=true, bool do_notify_toolkit=true)
Cell values_as_cell(void) const
octave_value lookup(const std::string pname) const
iterator find(const std::string pname)
octave_value & operator[](const std::string pname)
void erase(const std::string pname)
const_iterator find(const std::string pname) const
base_property * clone(void) const
std::string values_as_string(void) const
Cell values_as_cell(void) const
radio_property(const std::string &nm, const graphics_handle &h, const std::string &v)
radio_property(const std::string &nm, const graphics_handle &h, const radio_values &v=radio_values())
bool is_radio(void) const
radio_property(const std::string &nm, const graphics_handle &h, const radio_values &v, const std::string &def)
const std::string & current_value(void) const
bool is(const caseless_str &v) const
radio_property & operator=(const octave_value &val)
radio_property(const radio_property &p)
bool do_set(const octave_value &newval)
octave_value get(void) const
radio_values & operator=(const radio_values &a)
octave_idx_type nelem(void) const
bool contains(const std::string &val, std::string &match)
Cell values_as_cell(void) const
OCTINTERP_API radio_values(const std::string &opt_string="")
std::string values_as_string(void) const
std::set< caseless_str > possible_vals
radio_values(const radio_values &a)
bool validate(const std::string &val, std::string &match)
std::string default_value(void) const
row_vector_property(const row_vector_property &p)
row_vector_property(const std::string &nm, const graphics_handle &h, const octave_value &m)
base_property * clone(void) const
bool do_set(const octave_value &v)
OCTINTERP_API bool validate(const octave_value &v)
void add_constraint(const finite_type finite)
row_vector_property & operator=(const octave_value &val)
void add_constraint(octave_idx_type len)
void add_constraint(const dim_vector &dims)
void add_constraint(const std::string &type)
void add_constraint(const std::string &type, double val, bool inclusive)
scaler & operator=(const scaler &s)
Matrix scale(const Matrix &m) const
scaler(const std::string &s)
double scale(double d) const
double unscale(double d) const
bool is_linear(void) const
NDArray scale(const NDArray &m) const
base_property * clone(void) const
bool do_set(const octave_value &val)
std::string string_value(void) const
desired_enum desired_type
string_array_property(const std::string &s, const graphics_handle &h, const Cell &c, const char &sep='|', const desired_enum &typ=string_t)
string_array_property(const string_array_property &p)
string_vector string_vector_value(void) const
string_array_property(const std::string &s, const graphics_handle &h, const std::string &val="", const char &sep='|', const desired_enum &typ=string_t)
octave_value get(void) const
Cell cell_value(void) const
string_array_property & operator=(const octave_value &val)
string_property & operator=(const octave_value &val)
string_property(const string_property &p)
base_property * clone(void) const
bool do_set(const octave_value &val)
string_property(const std::string &s, const graphics_handle &h, const std::string &val="")
octave_value get(void) const
std::string string_value(void) const
string_vector & append(const std::string &s)
void resize(octave_idx_type n, const std::string &rfv="")
octave_idx_type numel(void) const
bool do_set(const octave_value &val)
text_label_property(const text_label_property &p)
text_label_property(const std::string &s, const graphics_handle &h, const Cell &c)
text_label_property(const std::string &s, const graphics_handle &h, const std::string &val="")
base_property * clone(void) const
text_label_property(const std::string &s, const graphics_handle &h, const NDArray &nda)
octave_value get(void) const
Cell cell_value(void) const
string_vector string_vector_value(void) const
charMatrix char_value(void) const
std::string string_value(void) const
text_label_property & operator=(const octave_value &val)
ColumnVector real(const ComplexColumnVector &a)
void warning_with_id(const char *id, const char *fmt,...)
void error(const char *fmt,...)
#define panic_impossible()
ColumnVector cross(const ColumnVector &v1, const ColumnVector &v2)
static bool is_handle_visible(const graphics_handle &h)
std::pair< std::string, octave_value > pval_pair
F77_RET_T const F77_DBLE const F77_DBLE F77_DBLE * d
F77_RET_T const F77_DBLE * x
octave_int< T > pow(const octave_int< T > &a, const octave_int< T > &b)
const octave_base_value & a2
return octave_value(v1.char_array_value() . concat(v2.char_array_value(), ra_idx),((a1.is_sq_string()||a2.is_sq_string()) ? '\'' :'"'))
octave_value::octave_value(const Array< char > &chm, char type) return retval