23 #if !defined (octave_graphics_h)
24 #define octave_graphics_h 1
52 #if !defined (OCTAVE_DEFAULT_FONTNAME)
53 #define OCTAVE_DEFAULT_FONTNAME "*"
69 error (
"invalid axis scale");
75 error (
"invalid axis scale");
79 virtual double scale (
double d)
const
81 error (
"invalid axis scale");
87 error (
"invalid axis scale");
140 {
return log10 (d); }
143 {
return pow (10.0, d); }
149 void do_scale (
const double *src,
double *dest,
int n)
const
151 for (
int i = 0; i < n; i++)
152 dest[i] = log10 (src[i]);
180 {
return -log10 (-d); }
183 {
return -
pow (10.0, -d); }
189 void do_scale (
const double *src,
double *dest,
int n)
const
191 for (
int i = 0; i < n; i++)
192 dest[i] = -log10 (-src[i]);
250 else if (s ==
"neglog")
252 else if (s ==
"linear")
305 virtual bool is_radio (
void)
const {
return false; }
314 bool do_notify_toolkit =
true);
318 error (
"get: invalid property \"%s\"",
name.c_str ());
325 error (
"values_as_string: invalid property \"%s\"",
name.c_str ());
326 return std::string ();
331 error (
"values_as_cell: invalid property \"%s\"",
name.c_str ());
357 for (i = 0; i < l.
length (); i++)
359 if (v.internal_rep () == l(i).internal_rep ())
367 for (
int j = i; j < l.
length () - 1; j++)
381 for (
int i = l.
length () - 1; i >= 0 ; i--)
383 for (
int j = 0; j < lp.
length (); j++)
385 if (l(i).internal_rep () == lp(j).internal_rep ())
406 error (
"set: invalid property \"%s\"",
name.c_str ());
412 typedef std::map<listener_mode, octave_value_list>::iterator
414 typedef std::map<listener_mode, octave_value_list>::const_iterator
432 const std::string& val =
"")
465 error (
"set: invalid string property value for \"%s\"",
482 const std::string& val =
"",
const char& sep =
'|',
490 size_t new_pos = val.find_first_of (
separator, pos);
492 if (new_pos == std::string::npos)
498 str.
append (val.substr (pos, new_pos - pos));
505 const Cell& c,
const char& sep =
'|',
514 strings[i] = c(i).string_value ();
519 error (
"set: invalid order property value for \"%s\"",
573 while (pos != std::string::npos)
575 size_t new_pos = new_str.find_first_of (
separator, pos);
577 if (new_pos == std::string::npos)
579 strings.
append (new_str.substr (pos));
583 strings.
append (new_str.substr (pos, new_pos - pos));
591 if (strings[i] !=
str[i])
620 if (!replace && strings[i] !=
str[i])
647 if (strings[i] !=
str[i])
664 error (
"set: invalid string property value for \"%s\"",
683 const std::string& val =
"")
697 std::ostringstream buf;
699 value[i] = buf.str ();
716 value[i] = c(i).string_value ();
719 double d = c(i).double_value ();
723 std::ostringstream buf;
725 value[i] = buf.str ();
793 value[i] = c(i).string_value ();
796 double d = c(i).double_value ();
800 std::ostringstream buf;
802 value[i] = buf.str ();
823 std::ostringstream buf;
825 value[i] = buf.str ();
832 error (
"set: invalid string property value for \"%s\"",
876 error (
"invalid value = %s", val.c_str ());
887 size_t len = val.length ();
889 std::string first_match;
891 for (std::set<caseless_str>::const_iterator p =
possible_vals.begin ();
894 if (p->compare (val, len))
896 if (len == p->length ())
946 const std::string& v)
992 if (s.length () != match.length ())
994 "%s: allowing %s to match %s value %s",
995 "set", s.c_str (),
get_name ().c_str (),
1002 error (
"set: invalid value for radio property \"%s\" (value = %s)",
1006 error (
"set: invalid value for radio property \"%s\"",
1035 error (
"invalid color specification: %s", str.c_str ());
1058 {
return ! (*
this == c); }
1066 for (
int i = 0; i < 3; i++)
1070 error (
"invalid RGB color specification");
1113 const std::string& v)
1143 bool is (
const std::string& v)
const
1149 error (
"color has no rgb value");
1157 error (
"color has no radio value");
1226 error (
"set: invalid value for double property \"%s\"",
1247 const std::string& v)
1277 bool is (
const std::string& v)
const
1291 error (
"%s: property has no radio value");
1407 error (
"invalid value for array property \"%s\"",
1494 if (dv(0) > 1 && dv(1) == 1)
1696 *p = new_gh.
value ();
1701 error (
"children_list::renumber: child not found!");
1724 if (visible_kids.
numel () == new_kids.
numel ())
1736 error (
"set: new children must be a permutation of existing children");
1741 error (
"set: expecting children to be array of graphics handles");
1851 error (
"invalid value for callback property \"%s\"",
1889 {
return rep->
ok (); }
1922 bool do_notify_toolkit =
true)
1923 {
return rep->
set (val, do_run, do_notify_toolkit); }
2059 const std::string&,
bool,
2060 const std::string& =
"")
const
2066 return Matrix (1, 2, 0.0);
2078 return Matrix (1, 2, 0.0);
2093 {
gripe_invalid (
"base_graphics_toolkit::initialize");
return false; }
2117 error (
"%s: invalid graphics toolkit", fname.c_str ());
2170 const std::string& file,
bool mono,
2171 const std::string& debug_file =
"")
const
2291 ::error (
"unable to create gh_manager!");
2314 typedef std::set<std::string>::const_iterator
2317 typedef std::map<std::string, graphics_toolkit>::iterator
2320 typedef std::map<std::string, graphics_toolkit>::const_iterator
2385 std::string name = p->first;
2415 void mark_modified (
void);
2429 void insert_property (
const std::string& name,
property p)
2433 all_props[name] = p;
2452 virtual property get_property (
const caseless_str& pname);
2464 if (children.remove_child (h.
value ()))
2470 children.adopt (h.
value ());
2477 get_boundingbox (
bool =
false,
2479 {
return Matrix (1, 4, 0.0); }
2481 virtual void update_boundingbox (
void);
2483 virtual void update_autopos (
const std::string& elem_type);
2497 return children.get_children ();
2502 return children.get_all ();
2507 return children.get_hidden ();
2519 virtual void update_axis_limits (
const std::string& axis_type)
const;
2521 virtual void update_axis_limits (
const std::string& axis_type,
2524 virtual void delete_children (
bool clear =
false)
2526 children.delete_children (
clear);
2531 children.renumber (old_gh, new_gh);
2560 std::set<std::string> dynamic_property_names (
void)
const;
2562 bool has_dynamic_property (
const std::string& pname);
2565 std::set<std::string> dynamic_properties;
2573 property get_property_dynamic (
const caseless_str& pname);
2575 BEGIN_BASE_PROPERTIES
2585 bool_property hittest , "on
"
2586 bool_property interruptible , "on
"
2587 handle_property parent fs , p
2588 bool_property selected , "off
"
2589 bool_property selectionhighlight , "on
"
2590 string_property tag s , ""
2591 string_property type frs , ty
2592 handle_property uicontextmenu , graphics_handle ()
2593 any_property userdata , Matrix ()
2594 bool_property visible , "on
"
2595 // additional (Octave-specific) properties
2596 bool_property __modified__ s , "on
"
2597 graphics_handle __myhandle__ fhrs , mh
2601 struct cmp_caseless_str
2603 bool operator () (const caseless_str &a, const caseless_str &b) const
2606 std::transform (a1.begin (), a1.end (), a1.begin (), tolower);
2608 std::transform (b1.begin (), b1.end (), b1.begin (), tolower);
2614 std::map<caseless_str, property, cmp_caseless_str> all_props;
2617 void insert_static_property (const std::string& name, base_property& p)
2618 { insert_property (name, property (&p, true)); }
2620 virtual void init (void) { }
2623 class OCTINTERP_API base_graphics_object
2626 friend class graphics_object;
2628 base_graphics_object (void) : count (1), toolkit_flag (false) { }
2630 virtual ~base_graphics_object (void) { }
2632 virtual void mark_modified (void)
2634 if (valid_object ())
2635 get_properties ().mark_modified ();
2640 virtual void override_defaults (base_graphics_object& obj)
2642 if (valid_object ())
2643 get_properties ().override_defaults (obj);
2648 virtual void set_from_list (property_list& plist)
2650 if (valid_object ())
2651 get_properties ().set_from_list (*this, plist);
2656 virtual void set (const caseless_str& pname, const octave_value& pval)
2658 if (valid_object ())
2659 get_properties ().set (pname, pval);
2664 virtual void set_defaults (const std::string&)
2669 virtual octave_value get (bool all = false) const
2671 if (valid_object ())
2672 return get_properties ().get (all);
2676 return octave_value ();
2680 virtual octave_value get (const caseless_str& pname) const
2682 if (valid_object ())
2683 return get_properties ().get (pname);
2687 return octave_value ();
2691 virtual octave_value get_default (const caseless_str&) const;
2693 virtual octave_value get_factory_default (const caseless_str&) const;
2695 virtual octave_value get_defaults (void) const
2698 return octave_value ();
2701 virtual octave_value get_factory_defaults (void) const
2704 return octave_value ();
2707 virtual std::string values_as_string (void);
2709 virtual octave_scalar_map values_as_struct (void);
2711 virtual graphics_handle get_parent (void) const
2713 if (valid_object ())
2714 return get_properties ().get_parent ();
2718 return graphics_handle ();
2722 graphics_handle get_handle (void) const
2724 if (valid_object ())
2725 return get_properties ().get___myhandle__ ();
2729 return graphics_handle ();
2733 virtual void remove_child (const graphics_handle& h)
2735 if (valid_object ())
2736 get_properties ().remove_child (h);
2741 virtual void adopt (const graphics_handle& h)
2743 if (valid_object ())
2744 get_properties ().adopt (h);
2749 virtual void reparent (const graphics_handle& np)
2751 if (valid_object ())
2752 get_properties ().reparent (np);
2757 virtual void defaults (void) const
2759 if (valid_object ())
2761 std::string msg = (type () + "::defaults
");
2762 gripe_not_implemented (msg.c_str ());
2765 error ("base_graphics_object::default: invalid graphics
object");
2768 virtual base_properties& get_properties (void)
2770 static base_properties properties;
2775 virtual const base_properties& get_properties (void) const
2777 static base_properties properties;
2782 virtual void update_axis_limits (const std::string& axis_type);
2784 virtual void update_axis_limits (const std::string& axis_type,
2785 const graphics_handle& h);
2787 virtual bool valid_object (void) const { return false; }
2789 bool valid_toolkit_object (void) const { return toolkit_flag; }
2791 virtual std::string type (void) const
2793 return (valid_object () ? get_properties ().graphics_object_name ()
2797 bool isa (const std::string& go_name) const
2799 return type () == go_name;
2802 virtual graphics_toolkit get_toolkit (void) const
2804 if (valid_object ())
2805 return get_properties ().get_toolkit ();
2809 return graphics_toolkit ();
2813 virtual void add_property_listener (const std::string& nm,
2814 const octave_value& v,
2815 listener_mode mode = POSTSET)
2817 if (valid_object ())
2818 get_properties ().add_listener (nm, v, mode);
2821 virtual void delete_property_listener (const std::string& nm,
2822 const octave_value& v,
2823 listener_mode mode = POSTSET)
2825 if (valid_object ())
2826 get_properties ().delete_listener (nm, v, mode);
2829 virtual void remove_all_listeners (void);
2831 virtual void reset_default_properties (void)
2833 if (valid_object ())
2836 gripe_not_implemented (msg.c_str ());
2839 error ("base_graphics_object::default: invalid graphics
object");
2843 virtual void initialize (const graphics_object& go)
2846 toolkit_flag = get_toolkit ().initialize (go);
2849 virtual void finalize (const graphics_object& go)
2853 get_toolkit ().finalize (go);
2854 toolkit_flag = false;
2858 virtual void update (const graphics_object& go, int id)
2861 get_toolkit ().update (go, id);
2865 // A reference count.
2866 octave_refcount<int> count;
2868 // A flag telling whether this object is a valid object
2869 // in the backend context.
2874 base_graphics_object (const base_graphics_object&) : count (0) { }
2876 base_graphics_object& operator = (const base_graphics_object&)
2882 class OCTINTERP_API graphics_object
2885 graphics_object (void) : rep (new base_graphics_object ()) { }
2887 graphics_object (base_graphics_object *new_rep)
2890 graphics_object (const graphics_object& obj) : rep (obj.rep)
2895 graphics_object& operator = (const graphics_object& obj)
2899 if (--rep->count == 0)
2909 ~graphics_object (void)
2911 if (--rep->count == 0)
2915 void mark_modified (void) { rep->mark_modified (); }
2917 void override_defaults (base_graphics_object& obj)
2919 rep->override_defaults (obj);
2922 void set_from_list (property_list& plist) { rep->set_from_list (plist); }
2924 void set (const caseless_str& name, const octave_value& val)
2926 rep->set (name, val);
2929 void set (const octave_value_list& args);
2931 void set (const Array<std::string>& names, const Cell& values,
2932 octave_idx_type row);
2934 void set (const octave_map& m);
2936 void set_value_or_default (const caseless_str& name,
2937 const octave_value& val);
2939 void set_defaults (const std::string& mode) { rep->set_defaults (mode); }
2941 octave_value get (bool all = false) const { return rep->get (all); }
2943 octave_value get (const caseless_str& name) const
2945 return name.compare ("default")
2947 : (name.compare ("factory
")
2948 ? get_factory_defaults () : rep->get (name));
2951 octave_value get (const std::string& name) const
2953 return get (caseless_str (name));
2956 octave_value get (const char *name) const
2958 return get (caseless_str (name));
2961 octave_value get_default (const caseless_str& name) const
2963 return rep->get_default (name);
2966 octave_value get_factory_default (const caseless_str& name) const
2968 return rep->get_factory_default (name);
2971 octave_value get_defaults (void) const { return rep->get_defaults (); }
2973 octave_value get_factory_defaults (void) const
2975 return rep->get_factory_defaults ();
2978 std::string values_as_string (void) { return rep->values_as_string (); }
2980 octave_map values_as_struct (void) { return rep->values_as_struct (); }
2982 graphics_handle get_parent (void) const { return rep->get_parent (); }
2984 graphics_handle get_handle (void) const { return rep->get_handle (); }
2986 graphics_object get_ancestor (const std::string& type) const;
2988 void remove_child (const graphics_handle& h) { rep->remove_child (h); }
2990 void adopt (const graphics_handle& h) { rep->adopt (h); }
2992 void reparent (const graphics_handle& h) { rep->reparent (h); }
2994 void defaults (void) const { rep->defaults (); }
2996 bool isa (const std::string& go_name) const { return rep->isa (go_name); }
2998 base_properties& get_properties (void) { return rep->get_properties (); }
3000 const base_properties& get_properties (void) const
3002 return rep->get_properties ();
3005 void update_axis_limits (const std::string& axis_type)
3007 rep->update_axis_limits (axis_type);
3010 void update_axis_limits (const std::string& axis_type,
3011 const graphics_handle& h)
3013 rep->update_axis_limits (axis_type, h);
3016 bool valid_object (void) const { return rep->valid_object (); }
3018 std::string type (void) const { return rep->type (); }
3020 operator bool (void) const { return rep->valid_object (); }
3022 // FIXME: these functions should be generated automatically by the
3023 // genprops.awk script.
3025 // EMIT_GRAPHICS_OBJECT_GET_FUNCTIONS
3027 octave_value get_alim (void) const
3028 { return get_properties ().get_alim (); }
3030 octave_value get_clim (void) const
3031 { return get_properties ().get_clim (); }
3033 octave_value get_xlim (void) const
3034 { return get_properties ().get_xlim (); }
3036 octave_value get_ylim (void) const
3037 { return get_properties ().get_ylim (); }
3039 octave_value get_zlim (void) const
3040 { return get_properties ().get_zlim (); }
3042 bool is_aliminclude (void) const
3043 { return get_properties ().is_aliminclude (); }
3045 bool is_climinclude (void) const
3046 { return get_properties ().is_climinclude (); }
3048 bool is_xliminclude (void) const
3049 { return get_properties ().is_xliminclude (); }
3051 bool is_yliminclude (void) const
3052 { return get_properties ().is_yliminclude (); }
3054 bool is_zliminclude (void) const
3055 { return get_properties ().is_zliminclude (); }
3057 bool is_handle_visible (void) const
3058 { return get_properties ().is_handle_visible (); }
3060 graphics_toolkit get_toolkit (void) const { return rep->get_toolkit (); }
3062 void add_property_listener (const std::string& nm, const octave_value& v,
3063 listener_mode mode = POSTSET)
3064 { rep->add_property_listener (nm, v, mode); }
3066 void delete_property_listener (const std::string& nm, const octave_value& v,
3067 listener_mode mode = POSTSET)
3068 { rep->delete_property_listener (nm, v, mode); }
3070 void initialize (void) { rep->initialize (*this); }
3072 void finalize (void) { rep->finalize (*this); }
3074 void update (int id) { rep->update (*this, id); }
3076 void reset_default_properties (void)
3077 { rep->reset_default_properties (); }
3080 base_graphics_object *rep;
3083 // ---------------------------------------------------------------------
3085 class OCTINTERP_API root_figure : public base_graphics_object
3088 class OCTINTERP_API properties : public base_properties
3091 void remove_child (const graphics_handle& h);
3093 Matrix get_boundingbox (bool internal = false,
3094 const Matrix& parent_pix_size = Matrix ()) const;
3096 // See the genprops.awk script for an explanation of the
3097 // properties declarations.
3099 // FIXME: it seems strange to me that the diary, diaryfile,
3100 // echo, errormessage, format, formatspacing, language, and
3101 // recursionlimit properties are here.
3102 // WTF do they have to do with graphics?
3103 // Also note that these properties (and the monitorpositions,
3104 // pointerlocation, and pointerwindow properties) are not yet used
3105 // by Octave, so setting them will have no effect, and changes
3106 // made elswhere (say, the diary or format functions) will not
3107 // cause these properties to be updated.
3108 // ANSWER: Matlab defines these properties and uses them in
3109 // the same way that Octave uses an internal static variable to
3110 // keep track of state. set (0, "echo
", "on
") is equivalent
3111 // to Octave's echo ("on
"). Maybe someday we can connect callbacks
3112 // that actually call Octave's own functions for this.
3114 // Programming note: Keep property list sorted if new ones are added.
3116 BEGIN_PROPERTIES (root_figure, root)
3117 handle_property callbackobject Sr , graphics_handle ()
3118 array_property commandwindowsize r , Matrix (1, 2, 0)
3119 handle_property currentfigure S , graphics_handle ()
3120 bool_property diary , "off
"
3121 string_property diaryfile , "diary
"
3122 bool_property echo , "off
"
3123 string_property errormessage , ""
3124 string_property fixedwidthfontname , "Courier
"
3125 radio_property format , "+|bank|bit|hex|
long|longe|longeng|longg|native-bit|native-hex|none|rational|{
short}|shorte|shorteng|shortg
"
3126 radio_property formatspacing , "compact|{loose}
"
3127 string_property language , "ascii
"
3128 array_property monitorpositions , Matrix (1, 4, 0)
3129 array_property pointerlocation , Matrix (1, 2, 0)
3130 double_property pointerwindow r , 0.0
3131 double_property recursionlimit , 256.0
3132 double_property screendepth r , default_screendepth ()
3133 double_property screenpixelsperinch r , default_screenpixelsperinch ()
3134 array_property screensize r , default_screensize ()
3135 bool_property showhiddenhandles , "off
"
3136 radio_property units U , "inches|centimeters|normalized|points|{pixels}
"
3140 std::list<graphics_handle> cbo_stack;
3144 properties xproperties;
3149 : xproperties (0, graphics_handle ()), default_properties () { }
3151 ~root_figure (void) { }
3153 void mark_modified (void) { }
3155 void override_defaults (base_graphics_object& obj)
3157 // Now override with our defaults. If the default_properties
3158 // list includes the properties for all defaults (line,
3159 // surface, etc.) then we don't have to know the type of OBJ
3160 // here, we just call its set function and let it decide which
3161 // properties from the list to use.
3162 obj.set_from_list (default_properties);
3165 void set (const caseless_str& name, const octave_value& value)
3167 if (name.compare ("default", 7))
3168 // strip "default", pass rest to function that will
3169 // parse the remainder and add the element to the
3170 // default_properties map.
3171 default_properties.set (name.substr (7), value);
3173 xproperties.set (name, value);
3176 octave_value get (const caseless_str& name) const
3178 octave_value retval;
3180 if (name.compare ("default", 7))
3181 return get_default (name.substr (7));
3182 else if (name.compare ("factory
", 7))
3183 return get_factory_default (name.substr (7));
3185 retval = xproperties.get (name);
3190 octave_value get_default (const caseless_str& name) const
3192 octave_value retval = default_properties.lookup (name);
3194 if (retval.is_undefined ())
3196 // no default property found, use factory default
3197 retval = factory_properties.lookup (name);
3199 if (retval.is_undefined ())
3200 error ("get: invalid
default property '%s'", name.c_str ());
3206 octave_value get_factory_default (const caseless_str& name) const
3208 octave_value retval = factory_properties.lookup (name);
3210 if (retval.is_undefined ())
3211 error ("get: invalid factory
default property '%s'", name.c_str ());
3216 octave_value get_defaults (void) const
3218 return default_properties.as_struct ("default");
3221 octave_value get_factory_defaults (void) const
3223 return factory_properties.as_struct ("factory
");
3226 base_properties& get_properties (void) { return xproperties; }
3228 const base_properties& get_properties (void) const { return xproperties; }
3230 bool valid_object (void) const { return true; }
3232 void reset_default_properties (void);
3235 property_list default_properties;
3237 static property_list factory_properties;
3239 static property_list::plist_map_type init_factory_properties (void);
3242 // ---------------------------------------------------------------------
3244 class OCTINTERP_API figure : public base_graphics_object
3247 class OCTINTERP_API properties : public base_properties
3250 void init_integerhandle (const octave_value& val)
3252 integerhandle = val;
3255 void remove_child (const graphics_handle& h);
3257 void set_visible (const octave_value& val);
3259 graphics_toolkit get_toolkit (void) const
3262 toolkit = gtk_manager::get_toolkit ();
3267 void set_toolkit (const graphics_toolkit& b);
3269 void set___graphics_toolkit__ (const octave_value& val)
3273 if (val.is_string ())
3275 std::string nm = val.string_value ();
3276 graphics_toolkit b = gtk_manager::find_toolkit (nm);
3277 if (b.get_name () != nm)
3279 error ("set___graphics_toolkit__: invalid graphics toolkit
");
3288 error ("set___graphics_toolkit__ must be a
string");
3292 void set_position (const octave_value& val,
3293 bool do_notify_toolkit = true);
3295 void set_outerposition (const octave_value& val,
3296 bool do_notify_toolkit = true);
3298 Matrix get_boundingbox (bool internal = false,
3299 const Matrix& parent_pix_size = Matrix ()) const;
3301 void set_boundingbox (const Matrix& bb, bool internal = false,
3302 bool do_notify_toolkit = true);
3304 Matrix map_from_boundingbox (double x, double y) const;
3306 Matrix map_to_boundingbox (double x, double y) const;
3308 void update_units (const caseless_str& old_units);
3310 void update_paperunits (const caseless_str& old_paperunits);
3312 std::string get_title (void) const;
3314 // See the genprops.awk script for an explanation of the
3315 // properties declarations.
3316 // Programming note: Keep property list sorted if new ones are added.
3318 BEGIN_PROPERTIES (figure)
3319 array_property alphamap , Matrix (64, 1, 1)
3320 callback_property buttondownfcn , Matrix ()
3321 callback_property closerequestfcn , "closereq
"
3322 color_property color , color_property (color_values (1, 1, 1), radio_values ("none
"))
3323 array_property colormap , jet_colormap ()
3324 handle_property currentaxes S , graphics_handle ()
3325 string_property currentcharacter r , ""
3326 handle_property currentobject r , graphics_handle ()
3327 array_property currentpoint r , Matrix (2, 1, 0)
3328 bool_property dockcontrols , "off
"
3329 bool_property doublebuffer , "on
"
3330 string_property filename , ""
3331 bool_property integerhandle S , "on
"
3332 bool_property inverthardcopy , "off
"
3333 callback_property keypressfcn , Matrix ()
3334 callback_property keyreleasefcn , Matrix ()
3335 radio_property menubar , "none|{
figure}
"
3336 double_property mincolormap , 64
3337 string_property name , ""
3338 radio_property nextplot , "new|{add}|replacechildren|
replace"
3339 bool_property numbertitle , "on
"
3340 array_property outerposition s , Matrix (1, 4, -1.0)
3341 radio_property paperorientation U , "{portrait}|landscape|rotated
"
3342 array_property paperposition , default_figure_paperposition ()
3343 radio_property paperpositionmode , "auto|{manual}
"
3344 array_property papersize U , default_figure_papersize ()
3345 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>
"
3346 radio_property paperunits Su , "{inches}|centimeters|normalized|points
"
3347 radio_property pointer , "crosshair|fullcrosshair|{arrow}|ibeam|watch|topl|topr|botl|botr|
left|top|right|bottom|circle|
cross|fleur|custom|hand
"
3348 array_property pointershapecdata , Matrix (16, 16, 0)
3349 array_property pointershapehotspot , Matrix (1, 2, 0)
3350 array_property position s , default_figure_position ()
3351 radio_property renderer , "{painters}|zbuffer|opengl|none
"
3352 radio_property renderermode , "{
auto}|manual
"
3353 bool_property resize , "on
"
3354 callback_property resizefcn , Matrix ()
3355 radio_property selectiontype , "{normal}|open|alt|extend
"
3356 radio_property toolbar , "none|{
auto}|
figure"
3357 radio_property units Su , "inches|centimeters|normalized|points|{pixels}|characters
"
3358 callback_property windowbuttondownfcn , Matrix ()
3359 callback_property windowbuttonmotionfcn , Matrix ()
3360 callback_property windowbuttonupfcn , Matrix ()
3361 callback_property windowkeypressfcn , Matrix ()
3362 callback_property windowkeyreleasefcn , Matrix ()
3363 callback_property windowscrollwheelfcn , Matrix ()
3364 radio_property windowstyle , "{normal}|modal|docked
"
3365 string_property wvisual , ""
3366 radio_property wvisualmode , "{
auto}|manual
"
3367 string_property xdisplay , ""
3368 string_property xvisual , ""
3369 radio_property xvisualmode , "{
auto}|manual
"
3370 // Octave-specific properties
3371 bool_property __enhanced__ h , "on
"
3372 string_property __graphics_toolkit__ s , gtk_manager::default_toolkit ()
3373 any_property __guidata__ h , Matrix ()
3374 any_property __plot_stream__ h , Matrix ()
3380 alphamap.add_constraint (dim_vector (-1, 1));
3381 colormap.add_constraint (dim_vector (-1, 3));
3382 outerposition.add_constraint (dim_vector (1, 4));
3383 paperposition.add_constraint (dim_vector (1, 4));
3384 papersize.add_constraint (dim_vector (1, 2));
3385 pointershapecdata.add_constraint (dim_vector (16, 16));
3386 pointershapehotspot.add_constraint (dim_vector (1, 2));
3387 position.add_constraint (dim_vector (1, 4));
3391 mutable graphics_toolkit toolkit;
3395 properties xproperties;
3398 figure (const graphics_handle& mh, const graphics_handle& p)
3399 : base_graphics_object (), xproperties (mh, p), default_properties ()
3401 xproperties.override_defaults (*this);
3406 void override_defaults (base_graphics_object& obj)
3408 // Allow parent (root figure) to override first (properties knows how
3409 // to find the parent object).
3410 xproperties.override_defaults (obj);
3412 // Now override with our defaults. If the default_properties
3413 // list includes the properties for all defaults (line,
3414 // surface, etc.) then we don't have to know the type of OBJ
3415 // here, we just call its set function and let it decide which
3416 // properties from the list to use.
3417 obj.set_from_list (default_properties);
3420 void set (const caseless_str& name, const octave_value& value)
3422 if (name.compare ("default", 7))
3423 // strip "default", pass rest to function that will
3424 // parse the remainder and add the element to the
3425 // default_properties map.
3426 default_properties.set (name.substr (7), value);
3428 xproperties.set (name, value);
3431 octave_value get (const caseless_str& name) const
3433 octave_value retval;
3435 if (name.compare ("default", 7))
3436 retval = get_default (name.substr (7));
3438 retval = xproperties.get (name);
3443 octave_value get_default (const caseless_str& name) const;
3445 octave_value get_defaults (void) const
3447 return default_properties.as_struct ("default");
3450 base_properties& get_properties (void) { return xproperties; }
3452 const base_properties& get_properties (void) const { return xproperties; }
3454 bool valid_object (void) const { return true; }
3456 void reset_default_properties (void);
3459 property_list default_properties;
3462 // ---------------------------------------------------------------------
3464 class OCTINTERP_API graphics_xform
3467 graphics_xform (void)
3468 : xform (xform_eye ()), xform_inv (xform_eye ()),
3469 sx ("linear
"), sy ("linear
"), sz ("linear
"), zlim (1, 2, 0.0)
3474 graphics_xform (const Matrix& xm, const Matrix& xim,
3475 const scaler& x, const scaler& y, const scaler& z,
3477 : xform (xm), xform_inv (xim), sx (x), sy (y), sz (z), zlim (zl) { }
3479 graphics_xform (const graphics_xform& g)
3480 : xform (g.xform), xform_inv (g.xform_inv), sx (g.sx),
3481 sy (g.sy), sz (g.sz), zlim (g.zlim) { }
3483 ~graphics_xform (void) { }
3485 graphics_xform& operator = (const graphics_xform& g)
3488 xform_inv = g.xform_inv;
3497 static ColumnVector xform_vector (double x, double y, double z);
3499 static Matrix xform_eye (void);
3501 ColumnVector transform (double x, double y, double z,
3502 bool use_scale = true) const;
3504 ColumnVector untransform (double x, double y, double z,
3505 bool use_scale = true) const;
3507 ColumnVector untransform (double x, double y, bool use_scale = true) const
3508 { return untransform (x, y, (zlim(0)+zlim(1))/2, use_scale); }
3510 Matrix xscale (const Matrix& m) const { return sx.scale (m); }
3511 Matrix yscale (const Matrix& m) const { return sy.scale (m); }
3512 Matrix zscale (const Matrix& m) const { return sz.scale (m); }
3514 Matrix scale (const Matrix& m) const
3516 bool has_z = (m.columns () > 2);
3518 if (sx.is_linear () && sy.is_linear ()
3519 && (! has_z || sz.is_linear ()))
3522 Matrix retval (m.dims ());
3526 for (int i = 0; i < r; i++)
3528 retval(i,0) = sx.scale (m(i,0));
3529 retval(i,1) = sy.scale (m(i,1));
3531 retval(i,2) = sz.scale (m(i,2));
3552 class OCTINTERP_API axes : public base_graphics_object
3555 class OCTINTERP_API properties : public base_properties
3558 void set_defaults (base_graphics_object& obj, const std::string& mode);
3560 void remove_child (const graphics_handle& h);
3562 const scaler& get_x_scaler (void) const { return sx; }
3563 const scaler& get_y_scaler (void) const { return sy; }
3564 const scaler& get_z_scaler (void) const { return sz; }
3566 Matrix get_boundingbox (bool internal = false,
3567 const Matrix& parent_pix_size = Matrix ()) const;
3568 Matrix get_extent (bool with_text = false,
3569 bool only_text_height=false) const;
3571 double get_fontsize_points (double box_pix_height = 0) const;
3573 void update_boundingbox (void)
3575 if (units_is ("normalized
"))
3578 base_properties::update_boundingbox ();
3582 void update_camera (void);
3583 void update_axes_layout (void);
3584 void update_aspectratios (void);
3585 void update_transform (void)
3587 update_aspectratios ();
3589 update_axes_layout ();
3592 void sync_positions (void);
3594 void update_autopos (const std::string& elem_type);
3595 void update_xlabel_position (void);
3596 void update_ylabel_position (void);
3597 void update_zlabel_position (void);
3598 void update_title_position (void);
3600 graphics_xform get_transform (void) const
3601 { return graphics_xform (x_render, x_render_inv, sx, sy, sz, x_zlim); }
3603 Matrix get_transform_matrix (void) const { return x_render; }
3604 Matrix get_inverse_transform_matrix (void) const { return x_render_inv; }
3605 Matrix get_opengl_matrix_1 (void) const { return x_gl_mat1; }
3606 Matrix get_opengl_matrix_2 (void) const { return x_gl_mat2; }
3607 Matrix get_transform_zlim (void) const { return x_zlim; }
3609 int get_xstate (void) const { return xstate; }
3610 int get_ystate (void) const { return ystate; }
3611 int get_zstate (void) const { return zstate; }
3612 double get_xPlane (void) const { return xPlane; }
3613 double get_xPlaneN (void) const { return xPlaneN; }
3614 double get_yPlane (void) const { return yPlane; }
3615 double get_yPlaneN (void) const { return yPlaneN; }
3616 double get_zPlane (void) const { return zPlane; }
3617 double get_zPlaneN (void) const { return zPlaneN; }
3618 double get_xpTick (void) const { return xpTick; }
3619 double get_xpTickN (void) const { return xpTickN; }
3620 double get_ypTick (void) const { return ypTick; }
3621 double get_ypTickN (void) const { return ypTickN; }
3622 double get_zpTick (void) const { return zpTick; }
3623 double get_zpTickN (void) const { return zpTickN; }
3624 double get_x_min (void) const { return std::min (xPlane, xPlaneN); }
3625 double get_x_max (void) const { return std::max (xPlane, xPlaneN); }
3626 double get_y_min (void) const { return std::min (yPlane, yPlaneN); }
3627 double get_y_max (void) const { return std::max (yPlane, yPlaneN); }
3628 double get_z_min (void) const { return std::min (zPlane, zPlaneN); }
3629 double get_z_max (void) const { return std::max (zPlane, zPlaneN); }
3630 double get_fx (void) const { return fx; }
3631 double get_fy (void) const { return fy; }
3632 double get_fz (void) const { return fz; }
3633 double get_xticklen (void) const { return xticklen; }
3634 double get_yticklen (void) const { return yticklen; }
3635 double get_zticklen (void) const { return zticklen; }
3636 double get_xtickoffset (void) const { return xtickoffset; }
3637 double get_ytickoffset (void) const { return ytickoffset; }
3638 double get_ztickoffset (void) const { return ztickoffset; }
3639 bool get_x2Dtop (void) const { return x2Dtop; }
3640 bool get_y2Dright (void) const { return y2Dright; }
3641 bool get_layer2Dtop (void) const { return layer2Dtop; }
3642 bool get_xySym (void) const { return xySym; }
3643 bool get_xyzSym (void) const { return xyzSym; }
3644 bool get_zSign (void) const { return zSign; }
3645 bool get_nearhoriz (void) const { return nearhoriz; }
3647 ColumnVector pixel2coord (double px, double py) const
3648 { return get_transform ().untransform (px, py, (x_zlim(0)+x_zlim(1))/2); }
3650 ColumnVector coord2pixel (double x, double y, double z) const
3651 { return get_transform ().transform (x, y, z); }
3653 void zoom_about_point (double x, double y, double factor,
3654 bool push_to_zoom_stack = true);
3655 void zoom (const Matrix& xl, const Matrix& yl,
3656 bool push_to_zoom_stack = true);
3657 void translate_view (double x0, double x1, double y0, double y1);
3658 void rotate_view (double delta_az, double delta_el);
3660 void clear_zoom_stack (void);
3662 void update_units (const caseless_str& old_units);
3664 void update_fontunits (const caseless_str& old_fontunits);
3668 Matrix x_render, x_render_inv;
3669 Matrix x_gl_mat1, x_gl_mat2;
3671 std::list<octave_value> zoom_stack;
3674 int xstate, ystate, zstate;
3675 double xPlane, xPlaneN, yPlane, yPlaneN, zPlane, zPlaneN;
3676 double xpTick, xpTickN, ypTick, ypTickN, zpTick, zpTickN;
3678 double xticklen, yticklen, zticklen;
3679 double xtickoffset, ytickoffset, ztickoffset;
3680 bool x2Dtop, y2Dright, layer2Dtop;
3681 bool xySym, xyzSym, zSign, nearhoriz;
3684 // freetype renderer, used for calculation of text (tick labels) size
3685 ft_render text_renderer;
3688 void set_text_child (handle_property& h, const std::string& who,
3689 const octave_value& v);
3691 void delete_text_child (handle_property& h);
3693 // See the genprops.awk script for an explanation of the
3694 // properties declarations.
3695 // Programming note: Keep property list sorted if new ones are added.
3697 BEGIN_PROPERTIES (axes)
3698 radio_property activepositionproperty , "{outerposition}|position
"
3699 row_vector_property alim m , default_lim ()
3700 radio_property alimmode , "{
auto}|manual
"
3701 color_property ambientlightcolor , color_values (1, 1, 1)
3702 bool_property box , "on
"
3703 array_property cameraposition m , Matrix (1, 3, 0.0)
3704 radio_property camerapositionmode , "{
auto}|manual
"
3705 array_property cameratarget m , Matrix (1, 3, 0.0)
3706 radio_property cameratargetmode , "{
auto}|manual
"
3707 array_property cameraupvector m , Matrix ()
3708 radio_property cameraupvectormode , "{
auto}|manual
"
3709 double_property cameraviewangle m , 10.0
3710 radio_property cameraviewanglemode , "{
auto}|manual
"
3711 row_vector_property clim m , default_lim ()
3712 radio_property climmode al , "{
auto}|manual
"
3713 color_property color , color_property (color_values (1, 1, 1), radio_values ("none
"))
3714 array_property colororder , default_colororder ()
3715 array_property currentpoint , Matrix (2, 3, 0.0)
3716 array_property dataaspectratio mu , Matrix (1, 3, 1.0)
3717 radio_property dataaspectratiomode u , "{
auto}|manual
"
3718 radio_property drawmode , "{normal}|fast
"
3719 radio_property fontangle u , "{normal}|italic|oblique
"
3720 string_property fontname u , OCTAVE_DEFAULT_FONTNAME
3721 double_property fontsize u , 10
3722 radio_property fontunits SU , "{points}|normalized|inches|centimeters|pixels
"
3723 radio_property fontweight u , "{normal}|light|demi|bold
"
3724 radio_property gridlinestyle , "-|--|{:}|-.|none
"
3725 // NOTE: interpreter is not a Matlab axis property, but it makes
3726 // more sense to have it so that axis ticklabels can use it.
3727 radio_property interpreter , "tex|{none}|latex
"
3728 radio_property layer u , "{bottom}|top
"
3729 // FIXME: should be kind of string array.
3730 any_property linestyleorder S , "-
"
3731 double_property linewidth , 0.5
3732 radio_property minorgridlinestyle , "-|--|{:}|-.|none
"
3733 radio_property nextplot , "add|replacechildren|{
replace}
"
3734 array_property outerposition u , default_axes_outerposition ()
3735 array_property plotboxaspectratio mu , Matrix (1, 3, 1.0)
3736 radio_property plotboxaspectratiomode u , "{
auto}|manual
"
3737 array_property position u , default_axes_position ()
3738 radio_property projection , "{orthographic}|perpective
"
3739 radio_property tickdir mu , "{in}|out
"
3740 radio_property tickdirmode u , "{
auto}|manual
"
3741 array_property ticklength u , default_axes_ticklength ()
3742 array_property tightinset r , Matrix (1, 4, 0.0)
3743 handle_property title SOf , gh_manager::make_graphics_handle ("text", __myhandle__, false, false, false)
3744 // FIXME: uicontextmenu should be moved here.
3745 radio_property units SU , "{normalized}|inches|centimeters|points|pixels|characters
"
3746 array_property view u , Matrix ()
3747 radio_property xaxislocation u , "{bottom}|top|zero
"
3748 color_property xcolor , color_values (0, 0, 0)
3749 radio_property xdir u , "{normal}|reverse
"
3750 bool_property xgrid , "off
"
3751 handle_property xlabel SOf , gh_manager::make_graphics_handle ("text", __myhandle__, false, false, false)
3752 row_vector_property xlim mu , default_lim ()
3753 radio_property xlimmode al , "{
auto}|manual
"
3754 bool_property xminorgrid , "off
"
3755 bool_property xminortick , "off
"
3756 radio_property xscale alu , "{linear}|log
"
3757 row_vector_property xtick mu , default_axes_tick ()
3758 // FIXME: should be kind of string array.
3759 any_property xticklabel S , ""
3760 radio_property xticklabelmode u , "{
auto}|manual
"
3761 radio_property xtickmode u , "{
auto}|manual
"
3762 radio_property yaxislocation u , "{
left}|right|zero
"
3763 color_property ycolor , color_values (0, 0, 0)
3764 radio_property ydir u , "{normal}|reverse
"
3765 bool_property ygrid , "off
"
3766 handle_property ylabel SOf , gh_manager::make_graphics_handle ("text", __myhandle__, false, false, false)
3767 row_vector_property ylim mu , default_lim ()
3768 radio_property ylimmode al , "{
auto}|manual
"
3769 bool_property yminorgrid , "off
"
3770 bool_property yminortick , "off
"
3771 radio_property yscale alu , "{linear}|log
"
3772 row_vector_property ytick mu , default_axes_tick ()
3773 any_property yticklabel S , ""
3774 radio_property yticklabelmode u , "{
auto}|manual
"
3775 radio_property ytickmode u , "{
auto}|manual
"
3776 color_property zcolor , color_values (0, 0, 0)
3777 radio_property zdir u , "{normal}|reverse
"
3778 bool_property zgrid , "off
"
3779 handle_property zlabel SOf , gh_manager::make_graphics_handle ("text", __myhandle__, false, false, false)
3780 row_vector_property zlim mu , default_lim ()
3781 radio_property zlimmode al , "{
auto}|manual
"
3782 bool_property zminorgrid , "off
"
3783 bool_property zminortick , "off
"
3784 radio_property zscale alu , "{linear}|log
"
3785 row_vector_property ztick mu , default_axes_tick ()
3786 any_property zticklabel S , ""
3787 radio_property zticklabelmode u , "{
auto}|manual
"
3788 radio_property ztickmode u , "{
auto}|manual
"
3789 // Octave-specific properties
3790 bool_property __hold_all__ h , "off
"
3791 // hidden properties for alignment of subplots
3792 radio_property autopos_tag h , "{none}|subplot
"
3793 // hidden properties for inset
3794 array_property looseinset hu , Matrix (1, 4, 0.0)
3795 // hidden properties for transformation computation
3796 array_property x_viewtransform h , Matrix (4, 4, 0.0)
3797 array_property x_projectiontransform h , Matrix (4, 4, 0.0)
3798 array_property x_viewporttransform h , Matrix (4, 4, 0.0)
3799 array_property x_normrendertransform h , Matrix (4, 4, 0.0)
3800 array_property x_rendertransform h , Matrix (4, 4, 0.0)
3801 // hidden properties for minor ticks
3802 row_vector_property xmtick h , Matrix ()
3803 row_vector_property ymtick h , Matrix ()
3804 row_vector_property zmtick h , Matrix ()
3813 get_scale (const std::string& scale, const Matrix& lims)
3815 std::string retval = scale;
3817 if (scale == "log
" && lims.numel () > 1 && lims(0) < 0 && lims(1) < 0)
3823 void update_xscale (void)
3825 sx = get_scale (get_xscale (), xlim.get ().matrix_value ());
3828 void update_yscale (void)
3830 sy = get_scale (get_yscale (), ylim.get ().matrix_value ());
3833 void update_zscale (void)
3835 sz = get_scale (get_zscale (), zlim.get ().matrix_value ());
3838 void update_view (void) { sync_positions (); }
3839 void update_dataaspectratio (void) { sync_positions (); }
3840 void update_dataaspectratiomode (void) { sync_positions (); }
3841 void update_plotboxaspectratio (void) { sync_positions (); }
3842 void update_plotboxaspectratiomode (void) { sync_positions (); }
3844 void update_layer (void) { update_axes_layout (); }
3845 void update_yaxislocation (void)
3847 update_axes_layout ();
3848 update_ylabel_position ();
3850 void update_xaxislocation (void)
3852 update_axes_layout ();
3853 update_xlabel_position ();
3856 void update_xdir (void) { update_camera (); update_axes_layout (); }
3857 void update_ydir (void) { update_camera (); update_axes_layout (); }
3858 void update_zdir (void) { update_camera (); update_axes_layout (); }
3860 void update_ticklength (void);
3861 void update_tickdir (void) { update_ticklength (); }
3862 void update_tickdirmode (void) { update_ticklength (); }
3864 void update_xtick (void)
3866 if (xticklabelmode.is ("auto"))
3867 calc_ticklabels (xtick, xticklabel, xscale.is ("log
"));
3869 void update_ytick (void)
3871 if (yticklabelmode.is ("auto"))
3872 calc_ticklabels (ytick, yticklabel, yscale.is ("log
"));
3874 void update_ztick (void)
3876 if (zticklabelmode.is ("auto"))
3877 calc_ticklabels (ztick, zticklabel, zscale.is ("log
"));
3880 void update_xtickmode (void)
3882 if (xtickmode.is ("auto"))
3884 calc_ticks_and_lims (xlim, xtick, xmtick, xlimmode.is ("auto"),
3889 void update_ytickmode (void)
3891 if (ytickmode.is ("auto"))
3893 calc_ticks_and_lims (ylim, ytick, ymtick, ylimmode.is ("auto"),
3898 void update_ztickmode (void)
3900 if (ztickmode.is ("auto"))
3902 calc_ticks_and_lims (zlim, ztick, zmtick, zlimmode.is ("auto"),
3908 void update_xticklabelmode (void)
3910 if (xticklabelmode.is ("auto"))
3911 calc_ticklabels (xtick, xticklabel, xscale.is ("log
"));
3913 void update_yticklabelmode (void)
3915 if (yticklabelmode.is ("auto"))
3916 calc_ticklabels (ytick, yticklabel, yscale.is ("log
"));
3918 void update_zticklabelmode (void)
3920 if (zticklabelmode.is ("auto"))
3921 calc_ticklabels (ztick, zticklabel, zscale.is ("log
"));
3924 void update_font (void);
3925 void update_fontname (void) { update_font (); }
3926 void update_fontsize (void) { update_font (); }
3927 void update_fontangle (void) { update_font (); }
3928 void update_fontweight (void) { update_font (); }
3930 void update_outerposition (void)
3932 set_activepositionproperty ("outerposition
");
3933 caseless_str old_units = get_units ();
3934 set_units ("normalized
");
3935 Matrix outerbox = outerposition.get ().matrix_value ();
3936 Matrix innerbox = position.get ().matrix_value ();
3937 Matrix linset = looseinset.get ().matrix_value ();
3938 Matrix tinset = tightinset.get ().matrix_value ();
3939 outerbox(2) = outerbox(2) + outerbox(0);
3940 outerbox(3) = outerbox(3) + outerbox(1);
3941 innerbox(0) = outerbox(0) + std::max (linset(0), tinset(0));
3942 innerbox(1) = outerbox(1) + std::max (linset(1), tinset(1));
3943 innerbox(2) = outerbox(2) - std::max (linset(2), tinset(2));
3944 innerbox(3) = outerbox(3) - std::max (linset(3), tinset(3));
3945 innerbox(2) = innerbox(2) - innerbox(0);
3946 innerbox(3) = innerbox(3) - innerbox(1);
3947 position = innerbox;
3948 set_units (old_units);
3949 update_transform ();
3952 void update_position (void)
3954 set_activepositionproperty ("position
");
3955 caseless_str old_units = get_units ();
3956 set_units ("normalized
");
3957 Matrix outerbox = outerposition.get ().matrix_value ();
3958 Matrix innerbox = position.get ().matrix_value ();
3959 Matrix linset = looseinset.get ().matrix_value ();
3960 Matrix tinset = tightinset.get ().matrix_value ();
3961 innerbox(2) = innerbox(2) + innerbox(0);
3962 innerbox(3) = innerbox(3) + innerbox(1);
3963 outerbox(0) = innerbox(0) - std::max (linset(0), tinset(0));
3964 outerbox(1) = innerbox(1) - std::max (linset(1), tinset(1));
3965 outerbox(2) = innerbox(2) + std::max (linset(2), tinset(2));
3966 outerbox(3) = innerbox(3) + std::max (linset(3), tinset(3));
3967 outerbox(2) = outerbox(2) - outerbox(0);
3968 outerbox(3) = outerbox(3) - outerbox(1);
3969 outerposition = outerbox;
3970 set_units (old_units);
3971 update_transform ();
3974 void update_looseinset (void)
3976 caseless_str old_units = get_units ();
3977 set_units ("normalized
");
3978 Matrix innerbox = position.get ().matrix_value ();
3979 innerbox(2) = innerbox(2) + innerbox(0);
3980 innerbox(3) = innerbox(3) + innerbox(1);
3981 Matrix outerbox = outerposition.get ().matrix_value ();
3982 outerbox(2) = outerbox(2) + outerbox(0);
3983 outerbox(3) = outerbox(3) + outerbox(1);
3984 Matrix linset = looseinset.get ().matrix_value ();
3985 Matrix tinset = tightinset.get ().matrix_value ();
3986 if (activepositionproperty.is ("position
"))
3988 outerbox(0) = innerbox(0) - std::max (linset(0), tinset(0));
3989 outerbox(1) = innerbox(1) - std::max (linset(1), tinset(1));
3990 outerbox(2) = innerbox(2) + std::max (linset(2), tinset(2));
3991 outerbox(3) = innerbox(3) + std::max (linset(3), tinset(3));
3992 outerbox(2) = outerbox(2) - outerbox(0);
3993 outerbox(3) = outerbox(3) - outerbox(1);
3994 outerposition = outerbox;
3998 innerbox(0) = outerbox(0) + std::max (linset(0), tinset(0));
3999 innerbox(1) = outerbox(1) + std::max (linset(1), tinset(1));
4000 innerbox(2) = outerbox(2) - std::max (linset(2), tinset(2));
4001 innerbox(3) = outerbox(3) - std::max (linset(3), tinset(3));
4002 innerbox(2) = innerbox(2) - innerbox(0);
4003 innerbox(3) = innerbox(3) - innerbox(1);
4004 position = innerbox;
4006 set_units (old_units);
4007 update_transform ();
4010 double calc_tick_sep (double minval, double maxval);
4011 void calc_ticks_and_lims (array_property& lims, array_property& ticks,
4012 array_property& mticks,
4013 bool limmode_is_auto, bool is_logscale);
4014 void calc_ticklabels (const array_property& ticks, any_property& labels,
4016 Matrix get_ticklabel_extents (const Matrix& ticks,
4017 const string_vector& ticklabels,
4018 const Matrix& limits);
4020 void fix_limits (array_property& lims)
4022 if (lims.get ().is_empty ())
4025 Matrix l = lims.get ().matrix_value ();
4032 else if (l(0) == l(1))
4040 Matrix calc_tightbox (const Matrix& init_pos);
4043 Matrix get_axis_limits (double xmin, double xmax,
4044 double min_pos, double max_neg,
4047 void update_xlim (bool do_clr_zoom = true)
4049 if (xtickmode.is ("auto"))
4050 calc_ticks_and_lims (xlim, xtick, xmtick, xlimmode.is ("auto"),
4052 if (xticklabelmode.is ("auto"))
4053 calc_ticklabels (xtick, xticklabel, xscale.is ("log
"));
4060 zoom_stack.clear ();
4062 update_axes_layout ();
4065 void update_ylim (bool do_clr_zoom = true)
4067 if (ytickmode.is ("auto"))
4068 calc_ticks_and_lims (ylim, ytick, ymtick, ylimmode.is ("auto"),
4070 if (yticklabelmode.is ("auto"))
4071 calc_ticklabels (ytick, yticklabel, yscale.is ("log
"));
4078 zoom_stack.clear ();
4080 update_axes_layout ();
4083 void update_zlim (void)
4085 if (ztickmode.is ("auto"))
4086 calc_ticks_and_lims (zlim, ztick, zmtick, zlimmode.is ("auto"),
4088 if (zticklabelmode.is ("auto"))
4089 calc_ticklabels (ztick, zticklabel, zscale.is ("log
"));
4095 zoom_stack.clear ();
4097 update_axes_layout ();
4103 properties xproperties;
4106 axes (const graphics_handle& mh, const graphics_handle& p)
4107 : base_graphics_object (), xproperties (mh, p), default_properties ()
4109 xproperties.override_defaults (*this);
4110 xproperties.update_transform ();
4115 void override_defaults (base_graphics_object& obj)
4117 // Allow parent (figure) to override first (properties knows how
4118 // to find the parent object).
4119 xproperties.override_defaults (obj);
4121 // Now override with our defaults. If the default_properties
4122 // list includes the properties for all defaults (line,
4123 // surface, etc.) then we don't have to know the type of OBJ
4124 // here, we just call its set function and let it decide which
4125 // properties from the list to use.
4126 obj.set_from_list (default_properties);
4129 void set (const caseless_str& name, const octave_value& value)
4131 if (name.compare ("default", 7))
4132 // strip "default", pass rest to function that will
4133 // parse the remainder and add the element to the
4134 // default_properties map.
4135 default_properties.set (name.substr (7), value);
4137 xproperties.set (name, value);
4140 void set_defaults (const std::string& mode)
4142 remove_all_listeners ();
4143 xproperties.set_defaults (*this, mode);
4146 octave_value get (const caseless_str& name) const
4148 octave_value retval;
4150 // FIXME: finish this.
4151 if (name.compare ("default", 7))
4152 retval = get_default (name.substr (7));
4154 retval = xproperties.get (name);
4159 octave_value get_default (const caseless_str& name) const;
4161 octave_value get_defaults (void) const
4163 return default_properties.as_struct ("default");
4166 base_properties& get_properties (void) { return xproperties; }
4168 const base_properties& get_properties (void) const { return xproperties; }
4170 void update_axis_limits (const std::string& axis_type);
4172 void update_axis_limits (const std::string& axis_type,
4173 const graphics_handle& h);
4175 bool valid_object (void) const { return true; }
4177 void reset_default_properties (void);
4180 void initialize (const graphics_object& go);
4183 property_list default_properties;
4186 // ---------------------------------------------------------------------
4188 class OCTINTERP_API line : public base_graphics_object
4191 class OCTINTERP_API properties : public base_properties
4194 // See the genprops.awk script for an explanation of the
4195 // properties declarations.
4196 // Programming note: Keep property list sorted if new ones are added.
4198 BEGIN_PROPERTIES (line)
4199 color_property color , color_values (0, 0, 0)
4200 string_property displayname , ""
4201 radio_property erasemode , "{normal}|none|xor|background
"
4202 // FIXME: interpreter is not a property of Matlab line objects.
4203 // Octave uses this for legend() with the string displayname.
4204 radio_property interpreter , "{tex}|none|latex
"
4205 radio_property linestyle , "{-}|--|:|-.|none
"
4206 double_property linewidth , 0.5
4207 radio_property marker , "{none}|+|o|*|.|
x|s|square|
d|diamond|^|v|>|<|p|pentagram|h|hexagram
"
4208 color_property markeredgecolor , color_property (radio_values ("{
auto}|none
"), color_values (0, 0, 0))
4209 color_property markerfacecolor , color_property (radio_values ("auto|{none}
"), color_values (0, 0, 0))
4210 double_property markersize , 6
4211 row_vector_property xdata u , default_data ()
4212 string_property xdatasource , ""
4213 row_vector_property ydata u , default_data ()
4214 string_property ydatasource , ""
4215 row_vector_property zdata u , Matrix ()
4216 string_property zdatasource , ""
4218 // hidden properties for limit computation
4219 row_vector_property xlim hlr , Matrix ()
4220 row_vector_property ylim hlr , Matrix ()
4221 row_vector_property zlim hlr , Matrix ()
4222 bool_property xliminclude hl , "on
"
4223 bool_property yliminclude hl , "on
"
4224 bool_property zliminclude hl , "off
"
4228 Matrix compute_xlim (void) const;
4229 Matrix compute_ylim (void) const;
4231 void update_xdata (void) { set_xlim (compute_xlim ()); }
4233 void update_ydata (void) { set_ylim (compute_ylim ()); }
4235 void update_zdata (void)
4237 set_zlim (zdata.get_limits ());
4238 set_zliminclude (get_zdata ().numel () > 0);
4243 properties xproperties;
4246 line (const graphics_handle& mh, const graphics_handle& p)
4247 : base_graphics_object (), xproperties (mh, p)
4249 xproperties.override_defaults (*this);
4254 base_properties& get_properties (void) { return xproperties; }
4256 const base_properties& get_properties (void) const { return xproperties; }
4258 bool valid_object (void) const { return true; }
4261 // ---------------------------------------------------------------------
4263 class OCTINTERP_API text : public base_graphics_object
4266 class OCTINTERP_API properties : public base_properties
4269 double get_fontsize_points (double box_pix_height = 0) const;
4271 void set_position (const octave_value& val)
4275 octave_value new_val (val);
4277 if (new_val.numel () == 2)
4279 dim_vector dv (1, 3);
4281 new_val = new_val.resize (dv, true);
4284 if (position.set (new_val, false))
4286 set_positionmode ("manual
");
4288 position.run_listeners (POSTSET);
4292 set_positionmode ("manual
");
4296 // See the genprops.awk script for an explanation of the
4297 // properties declarations.
4299 BEGIN_PROPERTIES (text)
4300 color_property backgroundcolor , color_property (radio_values ("{none}
"), color_values (1, 1, 1))
4301 color_property color u , color_values (0, 0, 0)
4302 string_property displayname , ""
4303 color_property edgecolor , color_property (radio_values ("{none}
"), color_values (0, 0, 0))
4304 bool_property editing , "off
"
4305 radio_property erasemode , "{normal}|none|xor|background
"
4306 array_property extent rG , Matrix (1, 4, 0.0)
4307 radio_property fontangle u , "{normal}|italic|oblique
"
4308 string_property fontname u , OCTAVE_DEFAULT_FONTNAME
4309 double_property fontsize u , 10
4310 radio_property fontunits , "inches|centimeters|normalized|{points}|pixels
"
4311 radio_property fontweight u , "light|{normal}|demi|bold
"
4312 radio_property horizontalalignment mu , "{
left}|center|right
"
4313 radio_property interpreter u , "{tex}|none|latex
"
4314 radio_property linestyle , "{-}|--|:|-.|none
"
4315 double_property linewidth , 0.5
4316 double_property margin , 1
4317 array_property position smu , Matrix (1, 3, 0.0)
4318 double_property rotation mu , 0
4319 text_label_property string u , ""
4320 radio_property units u , "{data}|pixels|normalized|inches|centimeters|points
"
4321 radio_property verticalalignment mu , "top|cap|{middle}|baseline|bottom
"
4323 // hidden properties for limit computation
4324 row_vector_property xlim hlr , Matrix ()
4325 row_vector_property ylim hlr , Matrix ()
4326 row_vector_property zlim hlr , Matrix ()
4327 bool_property xliminclude hl , "off
"
4328 bool_property yliminclude hl , "off
"
4329 bool_property zliminclude hl , "off
"
4330 // hidden properties for auto-positioning
4331 radio_property positionmode hu , "{
auto}|manual
"
4332 radio_property rotationmode hu , "{
auto}|manual
"
4333 radio_property horizontalalignmentmode hu , "{
auto}|manual
"
4334 radio_property verticalalignmentmode hu , "{
auto}|manual
"
4335 radio_property autopos_tag h , "{none}|xlabel|ylabel|zlabel|title
"
4338 Matrix get_data_position (void) const;
4339 Matrix get_extent_matrix (void) const;
4340 const uint8NDArray& get_pixels (void) const { return pixels; }
4342 // freetype renderer, used for calculation of text size
4349 position.add_constraint (dim_vector (1, 3));
4350 cached_units = get_units ();
4355 void update_position (void)
4357 Matrix pos = get_data_position ();
4360 lim = Matrix (1, 3, pos(0));
4361 lim(2) = (lim(2) <= 0 ? octave_Inf : lim(2));
4364 lim = Matrix (1, 3, pos(1));
4365 lim(2) = (lim(2) <= 0 ? octave_Inf : lim(2));
4368 if (pos.numel () == 3)
4370 lim = Matrix (1, 3, pos(2));
4371 lim(2) = (lim(2) <= 0 ? octave_Inf : lim(2));
4372 set_zliminclude ("on
");
4376 set_zliminclude ("off
");
4379 void update_text_extent (void);
4381 void request_autopos (void);
4382 void update_positionmode (void) { request_autopos (); }
4383 void update_rotationmode (void) { request_autopos (); }
4384 void update_horizontalalignmentmode (void) { request_autopos (); }
4385 void update_verticalalignmentmode (void) { request_autopos (); }
4387 void update_font (void);
4388 void update_string (void) { request_autopos (); update_text_extent (); }
4389 void update_rotation (void) { update_text_extent (); }
4390 void update_color (void) { update_font (); update_text_extent (); }
4391 void update_fontname (void) { update_font (); update_text_extent (); }
4392 void update_fontsize (void) { update_font (); update_text_extent (); }
4393 void update_fontangle (void) { update_font (); update_text_extent (); }
4394 void update_fontweight (void) { update_font (); update_text_extent (); }
4395 void update_interpreter (void) { update_text_extent (); }
4396 void update_horizontalalignment (void) { update_text_extent (); }
4397 void update_verticalalignment (void) { update_text_extent (); }
4399 void update_units (void);
4402 std::string cached_units;
4403 uint8NDArray pixels;
4407 properties xproperties;
4410 text (const graphics_handle& mh, const graphics_handle& p)
4411 : base_graphics_object (), xproperties (mh, p)
4413 xproperties.set_clipping ("off
");
4414 xproperties.override_defaults (*this);
4419 base_properties& get_properties (void) { return xproperties; }
4421 const base_properties& get_properties (void) const { return xproperties; }
4423 bool valid_object (void) const { return true; }
4426 // ---------------------------------------------------------------------
4428 class OCTINTERP_API image : public base_graphics_object
4431 class OCTINTERP_API properties : public base_properties
4434 bool is_aliminclude (void) const
4435 { return (aliminclude.is_on () && alphadatamapping.is ("scaled
")); }
4436 std::string get_aliminclude (void) const
4437 { return aliminclude.current_value (); }
4439 bool is_climinclude (void) const
4440 { return (climinclude.is_on () && cdatamapping.is ("scaled
")); }
4441 std::string get_climinclude (void) const
4442 { return climinclude.current_value (); }
4444 octave_value get_color_data (void) const;
4446 // See the genprops.awk script for an explanation of the
4447 // properties declarations.
4448 // Programming note: Keep property list sorted if new ones are added.
4450 BEGIN_PROPERTIES (image)
4451 array_property alphadata u , Matrix ()
4452 radio_property alphadatamapping al , "none|direct|{scaled}
"
4453 array_property cdata u , Matrix ()
4454 radio_property cdatamapping al , "scaled|{direct}
"
4455 radio_property erasemode , "{normal}|none|xor|background
"
4456 row_vector_property xdata u , Matrix ()
4457 row_vector_property ydata u , Matrix ()
4458 // hidden properties for limit computation
4459 row_vector_property alim hlr , Matrix ()
4460 row_vector_property clim hlr , Matrix ()
4461 row_vector_property xlim hlr , Matrix ()
4462 row_vector_property ylim hlr , Matrix ()
4463 bool_property aliminclude hlg , "on
"
4464 bool_property climinclude hlg , "on
"
4465 bool_property xliminclude hl , "on
"
4466 bool_property yliminclude hl , "on
"
4472 xdata.add_constraint (2);
4473 ydata.add_constraint (2);
4474 cdata.add_constraint ("double");
4475 cdata.add_constraint ("single
");
4476 cdata.add_constraint ("logical
");
4477 cdata.add_constraint ("uint8
");
4478 cdata.add_constraint ("uint16
");
4479 cdata.add_constraint ("int16
");
4480 cdata.add_constraint ("real");
4481 cdata.add_constraint (dim_vector (-1, -1));
4482 cdata.add_constraint (dim_vector (-1, -1, 3));
4483 alphadata.add_constraint (dim_vector (-1, -1));
4484 alphadata.add_constraint ("double");
4485 alphadata.add_constraint ("uint8
");
4489 void update_alphadata (void)
4491 if (alphadatamapping_is ("scaled
"))
4492 set_alim (alphadata.get_limits ());
4494 alim = alphadata.get_limits ();
4497 void update_cdata (void)
4499 if (cdatamapping_is ("scaled
"))
4500 set_clim (cdata.get_limits ());
4502 clim = cdata.get_limits ();
4505 void update_xdata (void)
4507 Matrix limits = xdata.get_limits ();
4508 float dp = pixel_xsize ();
4510 limits(0) = limits(0) - dp;
4511 limits(1) = limits(1) + dp;
4515 void update_ydata (void)
4517 Matrix limits = ydata.get_limits ();
4518 float dp = pixel_ysize ();
4520 limits(0) = limits(0) - dp;
4521 limits(1) = limits(1) + dp;
4525 float pixel_size (octave_idx_type dim, const Matrix limits)
4527 octave_idx_type l = dim - 1;
4530 if (l > 0 && limits(0) != limits(1))
4531 dp = (limits(1) - limits(0))/(2*l);
4534 if (limits(1) == limits(2))
4537 dp = (limits(1) - limits(0))/2;
4543 float pixel_xsize (void)
4545 return pixel_size ((get_cdata ().dims ())(1), xdata.get_limits ());
4548 float pixel_ysize (void)
4550 return pixel_size ((get_cdata ().dims ())(0), ydata.get_limits ());
4555 properties xproperties;
4558 image (const graphics_handle& mh, const graphics_handle& p)
4559 : base_graphics_object (), xproperties (mh, p)
4561 xproperties.override_defaults (*this);
4566 base_properties& get_properties (void) { return xproperties; }
4568 const base_properties& get_properties (void) const { return xproperties; }
4570 bool valid_object (void) const { return true; }
4573 // ---------------------------------------------------------------------
4575 class OCTINTERP_API patch : public base_graphics_object
4578 class OCTINTERP_API properties : public base_properties
4581 octave_value get_color_data (void) const;
4583 bool is_aliminclude (void) const
4584 { return (aliminclude.is_on () && alphadatamapping.is ("scaled
")); }
4585 std::string get_aliminclude (void) const
4586 { return aliminclude.current_value (); }
4588 bool is_climinclude (void) const
4589 { return (climinclude.is_on () && cdatamapping.is ("scaled
")); }
4590 std::string get_climinclude (void) const
4591 { return climinclude.current_value (); }
4593 // See the genprops.awk script for an explanation of the
4594 // properties declarations.
4595 // Programming note: Keep property list sorted if new ones are added.
4597 BEGIN_PROPERTIES (patch)
4598 radio_property alphadatamapping l , "none|{scaled}|direct
"
4599 double_property ambientstrength , 0.3
4600 radio_property backfacelighting , "unlit|lit|{reverselit}
"
4601 array_property cdata u , Matrix ()
4602 radio_property cdatamapping l , "{scaled}|direct
"
4603 double_property diffusestrength , 0.6
4604 string_property displayname , ""
4605 double_radio_property edgealpha , double_radio_property (1.0, radio_values ("flat|interp
"))
4606 color_property edgecolor , color_property (color_values (0, 0, 0), radio_values ("none|flat|interp
"))
4607 radio_property edgelighting , "{none}|flat|gouraud|phong
"
4608 radio_property erasemode , "{normal}|background|xor|none
"
4609 double_radio_property facealpha , double_radio_property (1.0, radio_values ("flat|interp
"))
4610 color_property facecolor , color_property (color_values (0, 0, 0), radio_values ("none|flat|interp
"))
4611 radio_property facelighting , "{none}|flat|gouraud|phong
"
4612 array_property faces , Matrix ()
4613 array_property facevertexalphadata , Matrix ()
4614 array_property facevertexcdata , Matrix ()
4615 // FIXME: interpreter is not a property of a Matlab patch.
4616 // Octave uses this for legend() with the string displayname.
4617 radio_property interpreter , "{tex}|none|latex
"
4618 radio_property linestyle , "{-}|--|:|-.|none
"
4619 double_property linewidth , 0.5
4620 radio_property marker , "{none}|+|o|*|.|
x|s|square|
d|diamond|^|v|>|<|p|pentagram|h|hexagram
"
4621 color_property markeredgecolor , color_property (radio_values ("none|{
auto}|flat
"), color_values (0, 0, 0))
4622 color_property markerfacecolor , color_property (radio_values ("{none}|
auto|flat
"), color_values (0, 0, 0))
4623 double_property markersize , 6
4624 radio_property normalmode , "{
auto}|manual
"
4625 double_property specularcolorreflectance , 1.0
4626 double_property specularexponent , 10.0
4627 double_property specularstrength , 0.6
4628 array_property vertexnormals , Matrix ()
4629 array_property vertices , Matrix ()
4630 array_property xdata u , Matrix ()
4631 array_property ydata u , Matrix ()
4632 array_property zdata u , Matrix ()
4634 // hidden properties for limit computation
4635 row_vector_property alim hlr , Matrix ()
4636 row_vector_property clim hlr , Matrix ()
4637 row_vector_property xlim hlr , Matrix ()
4638 row_vector_property ylim hlr , Matrix ()
4639 row_vector_property zlim hlr , Matrix ()
4640 bool_property aliminclude hlg , "on
"
4641 bool_property climinclude hlg , "on
"
4642 bool_property xliminclude hl , "on
"
4643 bool_property yliminclude hl , "on
"
4644 bool_property zliminclude hl , "on
"
4650 xdata.add_constraint (dim_vector (-1, -1));
4651 ydata.add_constraint (dim_vector (-1, -1));
4652 zdata.add_constraint (dim_vector (-1, -1));
4653 faces.add_constraint (dim_vector (-1, -1));
4654 vertices.add_constraint (dim_vector (-1, 2));
4655 vertices.add_constraint (dim_vector (-1, 3));
4656 cdata.add_constraint (dim_vector (-1, -1));
4657 cdata.add_constraint (dim_vector (-1, -1, 3));
4658 facevertexcdata.add_constraint (dim_vector (-1, 1));
4659 facevertexcdata.add_constraint (dim_vector (-1, 3));
4660 facevertexalphadata.add_constraint (dim_vector (-1, 1));
4661 vertexnormals.add_constraint (dim_vector (-1, -1));
4665 void update_xdata (void) { set_xlim (xdata.get_limits ()); }
4666 void update_ydata (void) { set_ylim (ydata.get_limits ()); }
4667 void update_zdata (void) { set_zlim (zdata.get_limits ()); }
4669 void update_cdata (void)
4671 if (cdatamapping_is ("scaled
"))
4672 set_clim (cdata.get_limits ());
4674 clim = cdata.get_limits ();
4679 properties xproperties;
4682 patch (const graphics_handle& mh, const graphics_handle& p)
4683 : base_graphics_object (), xproperties (mh, p)
4685 xproperties.override_defaults (*this);
4690 base_properties& get_properties (void) { return xproperties; }
4692 const base_properties& get_properties (void) const { return xproperties; }
4694 bool valid_object (void) const { return true; }
4697 // ---------------------------------------------------------------------
4699 class OCTINTERP_API surface : public base_graphics_object
4702 class OCTINTERP_API properties : public base_properties
4705 octave_value get_color_data (void) const;
4707 bool is_aliminclude (void) const
4708 { return (aliminclude.is_on () && alphadatamapping.is ("scaled
")); }
4709 std::string get_aliminclude (void) const
4710 { return aliminclude.current_value (); }
4712 bool is_climinclude (void) const
4713 { return (climinclude.is_on () && cdatamapping.is ("scaled
")); }
4714 std::string get_climinclude (void) const
4715 { return climinclude.current_value (); }
4717 // See the genprops.awk script for an explanation of the
4718 // properties declarations.
4719 // Programming note: Keep property list sorted if new ones are added.
4721 BEGIN_PROPERTIES (surface)
4722 array_property alphadata u , Matrix ()
4723 radio_property alphadatamapping l , "none|direct|{scaled}
"
4724 double_property ambientstrength , 0.3
4725 radio_property backfacelighting , "unlit|lit|{reverselit}
"
4726 array_property cdata u , Matrix ()
4727 radio_property cdatamapping al , "{scaled}|direct
"
4728 string_property cdatasource , ""
4729 double_property diffusestrength , 0.6
4730 string_property displayname , ""
4731 double_radio_property edgealpha , double_radio_property (1.0, radio_values ("flat|interp
"))
4732 color_property edgecolor , color_property (color_values (0, 0, 0), radio_values ("none|flat|interp
"))
4733 radio_property edgelighting , "{none}|flat|gouraud|phong
"
4734 radio_property erasemode , "{normal}|none|xor|background
"
4735 double_radio_property facealpha , double_radio_property (1.0, radio_values ("flat|interp|texturemap
"))
4736 color_property facecolor , color_property (radio_values ("none|{flat}|interp|texturemap
"), color_values (0, 0, 0))
4737 radio_property facelighting , "{none}|flat|gouraud|phong
"
4738 // FIXME: interpreter is not a Matlab surface property
4739 // Octave uses this for legend() with the string displayname.
4740 radio_property interpreter , "{tex}|none|latex
"
4741 radio_property linestyle , "{-}|--|:|-.|none
"
4742 double_property linewidth , 0.5
4743 radio_property marker , "{none}|+|o|*|.|
x|s|square|
d|diamond|^|v|>|<|p|pentagram|h|hexagram
"
4744 color_property markeredgecolor , color_property (radio_values ("none|{
auto}|flat
"), color_values (0, 0, 0))
4745 color_property markerfacecolor , color_property (radio_values ("{none}|
auto|flat
"), color_values (0, 0, 0))
4746 double_property markersize , 6
4747 radio_property meshstyle , "{both}|row|column
"
4748 radio_property normalmode u , "{
auto}|manual
"
4749 double_property specularcolorreflectance , 1
4750 double_property specularexponent , 10
4751 double_property specularstrength , 0.9
4752 array_property vertexnormals u , Matrix ()
4753 array_property xdata u , Matrix ()
4754 string_property xdatasource , ""
4755 array_property ydata u , Matrix ()
4756 string_property ydatasource , ""
4757 array_property zdata u , Matrix ()
4758 string_property zdatasource , ""
4760 // hidden properties for limit computation
4761 row_vector_property alim hlr , Matrix ()
4762 row_vector_property clim hlr , Matrix ()
4763 row_vector_property xlim hlr , Matrix ()
4764 row_vector_property ylim hlr , Matrix ()
4765 row_vector_property zlim hlr , Matrix ()
4766 bool_property aliminclude hlg , "on
"
4767 bool_property climinclude hlg , "on
"
4768 bool_property xliminclude hl , "on
"
4769 bool_property yliminclude hl , "on
"
4770 bool_property zliminclude hl , "on
"
4776 xdata.add_constraint (dim_vector (-1, -1));
4777 ydata.add_constraint (dim_vector (-1, -1));
4778 zdata.add_constraint (dim_vector (-1, -1));
4779 cdata.add_constraint ("double");
4780 cdata.add_constraint ("single
");
4781 cdata.add_constraint (dim_vector (-1, -1));
4782 cdata.add_constraint (dim_vector (-1, -1, 3));
4783 alphadata.add_constraint ("double");
4784 alphadata.add_constraint ("uint8
");
4785 alphadata.add_constraint (dim_vector (-1, -1));
4786 vertexnormals.add_constraint (dim_vector (-1, -1, 3));
4790 void update_alphadata (void)
4792 if (alphadatamapping_is ("scaled
"))
4793 set_alim (alphadata.get_limits ());
4795 alim = alphadata.get_limits ();
4798 void update_cdata (void)
4800 if (cdatamapping_is ("scaled
"))
4801 set_clim (cdata.get_limits ());
4803 clim = cdata.get_limits ();
4806 void update_xdata (void)
4809 set_xlim (xdata.get_limits ());
4812 void update_ydata (void)
4815 set_ylim (ydata.get_limits ());
4818 void update_zdata (void)
4821 set_zlim (zdata.get_limits ());
4824 void update_normals (void);
4826 void update_normalmode (void)
4827 { update_normals (); }
4829 void update_vertexnormals (void)
4830 { set_normalmode ("manual
"); }
4834 properties xproperties;
4837 surface (const graphics_handle& mh, const graphics_handle& p)
4838 : base_graphics_object (), xproperties (mh, p)
4840 xproperties.override_defaults (*this);
4845 base_properties& get_properties (void) { return xproperties; }
4847 const base_properties& get_properties (void) const { return xproperties; }
4849 bool valid_object (void) const { return true; }
4852 // ---------------------------------------------------------------------
4854 class OCTINTERP_API hggroup : public base_graphics_object
4857 class OCTINTERP_API properties : public base_properties
4860 void remove_child (const graphics_handle& h)
4862 base_properties::remove_child (h);
4866 void adopt (const graphics_handle& h)
4869 base_properties::adopt (h);
4873 // See the genprops.awk script for an explanation of the
4874 // properties declarations.
4875 // Programming note: Keep property list sorted if new ones are added.
4877 BEGIN_PROPERTIES (hggroup)
4878 string_property displayname , ""
4879 radio_property erasemode , "{normal}|none|xor|background
"
4881 // hidden properties for limit computation
4882 row_vector_property alim hr , Matrix ()
4883 row_vector_property clim hr , Matrix ()
4884 row_vector_property xlim hr , Matrix ()
4885 row_vector_property ylim hr , Matrix ()
4886 row_vector_property zlim hr , Matrix ()
4887 bool_property aliminclude h , "on
"
4888 bool_property climinclude h , "on
"
4889 bool_property xliminclude h , "on
"
4890 bool_property yliminclude h , "on
"
4891 bool_property zliminclude h , "on
"
4895 void update_limits (void) const;
4897 void update_limits (const graphics_handle& h) const;
4906 properties xproperties;
4909 hggroup (const graphics_handle& mh, const graphics_handle& p)
4910 : base_graphics_object (), xproperties (mh, p)
4912 xproperties.override_defaults (*this);
4917 base_properties& get_properties (void) { return xproperties; }
4919 const base_properties& get_properties (void) const { return xproperties; }
4921 bool valid_object (void) const { return true; }
4923 void update_axis_limits (const std::string& axis_type);
4925 void update_axis_limits (const std::string& axis_type,
4926 const graphics_handle& h);
4930 // ---------------------------------------------------------------------
4932 class OCTINTERP_API uimenu : public base_graphics_object
4935 class OCTINTERP_API properties : public base_properties
4938 void remove_child (const graphics_handle& h)
4940 base_properties::remove_child (h);
4943 void adopt (const graphics_handle& h)
4945 base_properties::adopt (h);
4948 // See the genprops.awk script for an explanation of the
4949 // properties declarations.
4950 // Programming note: Keep property list sorted if new ones are added.
4952 BEGIN_PROPERTIES (uimenu)
4953 any_property __object__ , Matrix ()
4954 string_property accelerator , ""
4955 callback_property callback , Matrix ()
4956 bool_property checked , "off
"
4957 bool_property enable , "on
"
4958 color_property foregroundcolor , color_values (0, 0, 0)
4959 string_property label , ""
4960 double_property position , 9
4961 bool_property separator , "off
"
4962 // Octave-specific properties
4963 string_property fltk_label h , ""
4972 properties xproperties;
4975 uimenu (const graphics_handle& mh, const graphics_handle& p)
4976 : base_graphics_object (), xproperties (mh, p)
4978 xproperties.override_defaults (*this);
4983 base_properties& get_properties (void) { return xproperties; }
4985 const base_properties& get_properties (void) const { return xproperties; }
4987 bool valid_object (void) const { return true; }
4991 // ---------------------------------------------------------------------
4993 class OCTINTERP_API uicontextmenu : public base_graphics_object
4996 class OCTINTERP_API properties : public base_properties
4999 // See the genprops.awk script for an explanation of the
5000 // properties declarations.
5001 // Programming note: Keep property list sorted if new ones are added.
5003 BEGIN_PROPERTIES (uicontextmenu)
5004 any_property __object__ , Matrix ()
5005 callback_property callback , Matrix ()
5006 array_property position , Matrix (1, 2, 0.0)
5012 position.add_constraint (dim_vector (1, 2));
5013 position.add_constraint (dim_vector (2, 1));
5014 visible.set (octave_value (true));
5019 properties xproperties;
5022 uicontextmenu (const graphics_handle& mh, const graphics_handle& p)
5023 : base_graphics_object (), xproperties (mh, p)
5025 xproperties.override_defaults (*this);
5028 ~uicontextmenu (void) { }
5030 base_properties& get_properties (void) { return xproperties; }
5032 const base_properties& get_properties (void) const { return xproperties; }
5034 bool valid_object (void) const { return true; }
5038 // ---------------------------------------------------------------------
5040 class OCTINTERP_API uicontrol : public base_graphics_object
5043 class OCTINTERP_API properties : public base_properties
5046 Matrix get_boundingbox (bool internal = false,
5047 const Matrix& parent_pix_size = Matrix ()) const;
5049 double get_fontsize_points (double box_pix_height = 0) const;
5051 // See the genprops.awk script for an explanation of the
5052 // properties declarations.
5053 // Programming note: Keep property list sorted if new ones are added.
5055 BEGIN_PROPERTIES (uicontrol)
5056 any_property __object__ , Matrix ()
5057 color_property backgroundcolor , color_values (1, 1, 1)
5058 callback_property callback , Matrix ()
5059 array_property cdata , Matrix ()
5060 bool_property clipping , "on
"
5061 radio_property enable , "{on}|inactive|off
"
5062 array_property extent rG , Matrix (1, 4, 0.0)
5063 radio_property fontangle u , "{normal}|italic|oblique
"
5064 string_property fontname u , OCTAVE_DEFAULT_FONTNAME
5065 double_property fontsize u , 10
5066 radio_property fontunits S , "inches|centimeters|normalized|{points}|pixels
"
5067 radio_property fontweight u , "light|{normal}|demi|bold
"
5068 color_property foregroundcolor , color_values (0, 0, 0)
5069 radio_property horizontalalignment , "left|{center}|right
"
5070 callback_property keypressfcn , Matrix ()
5071 double_property listboxtop , 1
5072 double_property max , 1
5073 double_property min , 0
5074 array_property position , default_control_position ()
5075 array_property sliderstep , default_control_sliderstep ()
5076 string_array_property string u , ""
5077 radio_property style S , "{pushbutton}|togglebutton|radiobutton|checkbox|edit|
text|slider|frame|listbox|popupmenu
"
5078 string_property tooltipstring , ""
5079 radio_property units u , "normalized|inches|centimeters|points|{pixels}|characters
"
5080 row_vector_property value , Matrix (1, 1, 1.0)
5081 radio_property verticalalignment , "top|{middle}|bottom
"
5085 std::string cached_units;
5090 cdata.add_constraint ("double");
5091 cdata.add_constraint ("single
");
5092 cdata.add_constraint (dim_vector (-1, -1, 3));
5093 position.add_constraint (dim_vector (1, 4));
5094 sliderstep.add_constraint (dim_vector (1, 2));
5095 cached_units = get_units ();
5098 void update_text_extent (void);
5100 void update_string (void) { update_text_extent (); }
5101 void update_fontname (void) { update_text_extent (); }
5102 void update_fontsize (void) { update_text_extent (); }
5103 void update_fontangle (void) { update_text_extent (); }
5104 void update_fontweight (void) { update_text_extent (); }
5105 void update_fontunits (const caseless_str& old_units);
5107 void update_units (void);
5112 properties xproperties;
5115 uicontrol (const graphics_handle& mh, const graphics_handle& p)
5116 : base_graphics_object (), xproperties (mh, p)
5118 xproperties.override_defaults (*this);
5121 ~uicontrol (void) { }
5123 base_properties& get_properties (void) { return xproperties; }
5125 const base_properties& get_properties (void) const { return xproperties; }
5127 bool valid_object (void) const { return true; }
5130 // ---------------------------------------------------------------------
5132 class OCTINTERP_API uipanel : public base_graphics_object
5135 class OCTINTERP_API properties : public base_properties
5138 Matrix get_boundingbox (bool internal = false,
5139 const Matrix& parent_pix_size = Matrix ()) const;
5141 double get_fontsize_points (double box_pix_height = 0) const;
5143 // See the genprops.awk script for an explanation of the
5144 // properties declarations.
5145 // Programming note: Keep property list sorted if new ones are added.
5147 BEGIN_PROPERTIES (uipanel)
5148 any_property __object__ , Matrix ()
5149 color_property backgroundcolor , color_values (1, 1, 1)
5150 radio_property bordertype , "none|{etchedin}|etchedout|beveledin|beveledout|
line"
5151 double_property borderwidth , 1
5152 radio_property fontangle , "{normal}|italic|oblique
"
5153 string_property fontname , OCTAVE_DEFAULT_FONTNAME
5154 double_property fontsize , 10
5155 radio_property fontunits S , "inches|centimeters|normalized|{points}|pixels
"
5156 radio_property fontweight , "light|{normal}|demi|bold
"
5157 color_property foregroundcolor , color_values (0, 0, 0)
5158 color_property highlightcolor , color_values (1, 1, 1)
5159 array_property position , default_panel_position ()
5160 callback_property resizefcn , Matrix ()
5161 color_property shadowcolor , color_values (0, 0, 0)
5162 string_property title , ""
5163 radio_property titleposition , "{lefttop}|centertop|righttop|leftbottom|centerbottom|rightbottom
"
5164 radio_property units S , "{normalized}|inches|centimeters|points|pixels|characters
"
5170 position.add_constraint (dim_vector (1, 4));
5173 void update_units (const caseless_str& old_units);
5174 void update_fontunits (const caseless_str& old_units);
5179 properties xproperties;
5182 uipanel (const graphics_handle& mh, const graphics_handle& p)
5183 : base_graphics_object (), xproperties (mh, p)
5185 xproperties.override_defaults (*this);
5190 base_properties& get_properties (void) { return xproperties; }
5192 const base_properties& get_properties (void) const { return xproperties; }
5194 bool valid_object (void) const { return true; }
5197 // ---------------------------------------------------------------------
5199 class OCTINTERP_API uitoolbar : public base_graphics_object
5202 class OCTINTERP_API properties : public base_properties
5205 // See the genprops.awk script for an explanation of the
5206 // properties declarations.
5207 // Programming note: Keep property list sorted if new ones are added.
5209 BEGIN_PROPERTIES (uitoolbar)
5210 any_property __object__ , Matrix ()
5219 properties xproperties;
5222 uitoolbar (const graphics_handle& mh, const graphics_handle& p)
5223 : base_graphics_object (), xproperties (mh, p), default_properties ()
5225 xproperties.override_defaults (*this);
5228 ~uitoolbar (void) { }
5230 void override_defaults (base_graphics_object& obj)
5232 // Allow parent (figure) to override first (properties knows how
5233 // to find the parent object).
5234 xproperties.override_defaults (obj);
5236 // Now override with our defaults. If the default_properties
5237 // list includes the properties for all defaults (line,
5238 // surface, etc.) then we don't have to know the type of OBJ
5239 // here, we just call its set function and let it decide which
5240 // properties from the list to use.
5241 obj.set_from_list (default_properties);
5244 void set (const caseless_str& name, const octave_value& value)
5246 if (name.compare ("default", 7))
5247 // strip "default", pass rest to function that will
5248 // parse the remainder and add the element to the
5249 // default_properties map.
5250 default_properties.set (name.substr (7), value);
5252 xproperties.set (name, value);
5255 octave_value get (const caseless_str& name) const
5257 octave_value retval;
5259 if (name.compare ("default", 7))
5260 retval = get_default (name.substr (7));
5262 retval = xproperties.get (name);
5267 octave_value get_default (const caseless_str& name) const;
5269 octave_value get_defaults (void) const
5271 return default_properties.as_struct ("default");
5274 base_properties& get_properties (void) { return xproperties; }
5276 const base_properties& get_properties (void) const { return xproperties; }
5278 bool valid_object (void) const { return true; }
5280 void reset_default_properties (void);
5283 property_list default_properties;
5286 // ---------------------------------------------------------------------
5288 class OCTINTERP_API uipushtool : public base_graphics_object
5291 class OCTINTERP_API properties : public base_properties
5294 // See the genprops.awk script for an explanation of the
5295 // properties declarations.
5296 // Programming note: Keep property list sorted if new ones are added.
5298 BEGIN_PROPERTIES (uipushtool)
5299 any_property __object__ , Matrix ()
5300 array_property cdata , Matrix ()
5301 callback_property clickedcallback , Matrix ()
5302 bool_property enable , "on
"
5303 bool_property separator , "off
"
5304 string_property tooltipstring , ""
5310 cdata.add_constraint ("double");
5311 cdata.add_constraint ("single
");
5312 cdata.add_constraint (dim_vector (-1, -1, 3));
5317 properties xproperties;
5320 uipushtool (const graphics_handle& mh, const graphics_handle& p)
5321 : base_graphics_object (), xproperties (mh, p)
5323 xproperties.override_defaults (*this);
5326 ~uipushtool (void) { }
5328 base_properties& get_properties (void) { return xproperties; }
5330 const base_properties& get_properties (void) const { return xproperties; }
5332 bool valid_object (void) const { return true; }
5336 // ---------------------------------------------------------------------
5338 class OCTINTERP_API uitoggletool : public base_graphics_object
5341 class OCTINTERP_API properties : public base_properties
5344 // See the genprops.awk script for an explanation of the
5345 // properties declarations.
5346 // Programming note: Keep property list sorted if new ones are added.
5348 BEGIN_PROPERTIES (uitoggletool)
5349 any_property __object__ , Matrix ()
5350 array_property cdata , Matrix ()
5351 callback_property clickedcallback , Matrix ()
5352 bool_property enable , "on
"
5353 callback_property offcallback , Matrix ()
5354 callback_property oncallback , Matrix ()
5355 bool_property separator , "off
"
5356 bool_property state , "off
"
5357 string_property tooltipstring , ""
5363 cdata.add_constraint ("double");
5364 cdata.add_constraint ("single
");
5365 cdata.add_constraint (dim_vector (-1, -1, 3));
5370 properties xproperties;
5373 uitoggletool (const graphics_handle& mh, const graphics_handle& p)
5374 : base_graphics_object (), xproperties (mh, p)
5376 xproperties.override_defaults (*this);
5379 ~uitoggletool (void) { }
5381 base_properties& get_properties (void) { return xproperties; }
5383 const base_properties& get_properties (void) const { return xproperties; }
5385 bool valid_object (void) const { return true; }
5389 // ---------------------------------------------------------------------
5392 get_property_from_handle (double handle, const std::string &property,
5393 const std::string &func);
5395 set_property_in_handle (double handle, const std::string &property,
5396 const octave_value &arg, const std::string &func);
5398 // ---------------------------------------------------------------------
5400 class graphics_event;
5406 friend class graphics_event;
5408 base_graphics_event (void) : count (1) { }
5410 virtual ~base_graphics_event (void) { }
5412 virtual void execute (void) = 0;
5415 octave_refcount<int> count;
5422 typedef void (*event_fcn) (void*);
5424 graphics_event (void) : rep (0) { }
5426 graphics_event (const graphics_event& e) : rep (e.rep)
5431 ~graphics_event (void)
5433 if (rep && --rep->count == 0)
5437 graphics_event& operator = (const graphics_event& e)
5441 if (rep && --rep->count == 0)
5453 { if (rep) rep->execute (); }
5455 bool ok (void) const
5456 { return (rep != 0); }
5458 static graphics_event
5459 create_callback_event (const graphics_handle& h,
5460 const std::string& name,
5461 const octave_value& data = Matrix ());
5463 static graphics_event
5464 create_callback_event (const graphics_handle& h,
5465 const octave_value& cb,
5466 const octave_value& data = Matrix ());
5468 static graphics_event
5469 create_function_event (event_fcn fcn, void *data = 0);
5471 static graphics_event
5472 create_set_event (const graphics_handle& h, const std::string& name,
5473 const octave_value& value,
5474 bool notify_toolkit = true);
5476 base_graphics_event *rep;
5479 class OCTINTERP_API gh_manager
5487 static void create_instance (void);
5489 static bool instance_ok (void)
5506 static void cleanup_instance (void) { delete instance; instance = 0; }
5508 static graphics_handle get_handle (bool integer_figure_handle)
5510 return instance_ok ()
5511 ? instance->do_get_handle (integer_figure_handle)
5512 : graphics_handle ();
5515 static void free (const graphics_handle& h)
5518 instance->do_free (h);
5521 static void renumber_figure (const graphics_handle& old_gh,
5522 const graphics_handle& new_gh)
5525 instance->do_renumber_figure (old_gh, new_gh);
5528 static graphics_handle lookup (double val)
5530 return instance_ok () ? instance->do_lookup (val) : graphics_handle ();
5533 static graphics_handle lookup (const octave_value& val)
5535 return val.is_real_scalar ()
5536 ? lookup (val.double_value ()) : graphics_handle ();
5539 static graphics_object get_object (double val)
5541 return get_object (lookup (val));
5544 static graphics_object get_object (const graphics_handle& h)
5546 return instance_ok () ? instance->do_get_object (h) : graphics_object ();
5549 static graphics_handle
5550 make_graphics_handle (const std::string& go_name,
5551 const graphics_handle& parent,
5552 bool integer_figure_handle = false,
5553 bool do_createfcn = true,
5554 bool do_notify_toolkit = true)
5556 return instance_ok ()
5557 ? instance->do_make_graphics_handle (go_name, parent,
5558 integer_figure_handle,
5559 do_createfcn, do_notify_toolkit)
5560 : graphics_handle ();
5563 static graphics_handle make_figure_handle (double val,
5564 bool do_notify_toolkit = true)
5566 return instance_ok ()
5567 ? instance->do_make_figure_handle (val, do_notify_toolkit)
5568 : graphics_handle ();
5571 static void push_figure (const graphics_handle& h)
5574 instance->do_push_figure (h);
5577 static void pop_figure (const graphics_handle& h)
5580 instance->do_pop_figure (h);
5583 static graphics_handle current_figure (void)
5585 return instance_ok ()
5586 ? instance->do_current_figure () : graphics_handle ();
5589 static Matrix handle_list (bool show_hidden = false)
5591 return instance_ok ()
5592 ? instance->do_handle_list (show_hidden) : Matrix ();
5595 static void lock (void)
5598 instance->do_lock ();
5601 static bool try_lock (void)
5604 return instance->do_try_lock ();
5609 static void unlock (void)
5612 instance->do_unlock ();
5615 static Matrix figure_handle_list (bool show_hidden = false)
5617 return instance_ok ()
5618 ? instance->do_figure_handle_list (show_hidden) : Matrix ();
5621 static void execute_listener (const graphics_handle& h,
5622 const octave_value& l)
5625 instance->do_execute_listener (h, l);
5628 static void execute_callback (const graphics_handle& h,
5629 const std::string& name,
5630 const octave_value& data = Matrix ())
5636 gh_manager::auto_lock lock;
5638 graphics_object go = get_object (h);
5640 if (go.valid_object ())
5645 execute_callback (h, cb, data);
5648 static void execute_callback (const graphics_handle& h,
5649 const octave_value& cb,
5650 const octave_value& data = Matrix ())
5653 instance->do_execute_callback (h, cb, data);
5656 static void post_callback (const graphics_handle& h,
5657 const std::string& name,
5658 const octave_value& data = Matrix ())
5661 instance->do_post_callback (h, name, data);
5664 static void post_function (graphics_event::event_fcn fcn, void* data = 0)
5667 instance->do_post_function (fcn, data);
5670 static void post_set (const graphics_handle& h, const std::string& name,
5671 const octave_value& value, bool notify_toolkit = true)
5674 instance->do_post_set (h, name, value, notify_toolkit);
5677 static int process_events (void)
5679 return (instance_ok () ? instance->do_process_events () : 0);
5682 static int flush_events (void)
5684 return (instance_ok () ? instance->do_process_events (true) : 0);
5687 static void enable_event_processing (bool enable = true)
5690 instance->do_enable_event_processing (enable);
5693 static bool is_handle_visible (const graphics_handle& h)
5695 bool retval = false;
5697 graphics_object go = get_object (h);
5699 if (go.valid_object ())
5700 retval = go.is_handle_visible ();
5705 static void close_all_figures (void)
5708 instance->do_close_all_figures ();
5712 class auto_lock : public octave_autolock
5715 auto_lock (bool wait = true)
5716 : octave_autolock (instance_ok ()
5717 ? instance->graphics_lock
5725 auto_lock (const auto_lock&);
5726 auto_lock& operator = (const auto_lock&);
5731 static gh_manager *instance;
5733 typedef std::map<graphics_handle, graphics_object>::iterator iterator;
5734 typedef std::map<graphics_handle, graphics_object>::const_iterator
5737 typedef std::set<graphics_handle>::iterator free_list_iterator;
5738 typedef std::set<graphics_handle>::const_iterator const_free_list_iterator;
5740 typedef std::list<graphics_handle>::iterator figure_list_iterator;
5741 typedef std::list<graphics_handle>::const_iterator const_figure_list_iterator;
5743 // A map of handles to graphics objects.
5744 std::map<graphics_handle, graphics_object> handle_map;
5746 // The available graphics handles.
5747 std::set<graphics_handle> handle_free_list;
5749 // The next handle available if handle_free_list is empty.
5752 // The allocated figure handles. Top of the stack is most recently
5754 std::list<graphics_handle> figure_list;
5756 // The lock for accessing the graphics sytsem.
5757 octave_mutex graphics_lock;
5759 // The list of events queued by graphics toolkits.
5760 std::list<graphics_event> event_queue;
5762 // The stack of callback objects.
5763 std::list<graphics_object> callback_objects;
5765 // A flag telling whether event processing must be constantly on.
5766 int event_processing;
5768 graphics_handle do_get_handle (bool integer_figure_handle);
5770 void do_free (const graphics_handle& h);
5772 void do_renumber_figure (const graphics_handle& old_gh,
5773 const graphics_handle& new_gh);
5775 graphics_handle do_lookup (double val)
5777 iterator p = (xisnan (val) ? handle_map.end () : handle_map.find (val));
5779 return (p != handle_map.end ()) ? p->first : graphics_handle ();
5782 graphics_object do_get_object (const graphics_handle& h)
5784 iterator p = (h.ok () ? handle_map.find (h) : handle_map.end ());
5786 return (p != handle_map.end ()) ? p->second : graphics_object ();
5789 graphics_handle do_make_graphics_handle (const std::string& go_name,
5790 const graphics_handle& p,
5791 bool integer_figure_handle,
5793 bool do_notify_toolkit);
5795 graphics_handle do_make_figure_handle (double val, bool do_notify_toolkit);
5797 Matrix do_handle_list (bool show_hidden)
5799 Matrix retval (1, handle_map.size ());
5801 octave_idx_type i = 0;
5802 for (const_iterator p = handle_map.begin (); p != handle_map.end (); p++)
5804 graphics_handle h = p->first;
5806 if (show_hidden || is_handle_visible (h))
5807 retval(i++) = h.value ();
5810 retval.resize (1, i);
5815 Matrix do_figure_handle_list (bool show_hidden)
5817 Matrix retval (1, figure_list.size ());
5819 octave_idx_type i = 0;
5820 for (const_figure_list_iterator p = figure_list.begin ();
5821 p != figure_list.end ();
5824 graphics_handle h = *p;
5826 if (show_hidden || is_handle_visible (h))
5827 retval(i++) = h.value ();
5830 retval.resize (1, i);
5835 void do_push_figure (const graphics_handle& h);
5837 void do_pop_figure (const graphics_handle& h);
5839 graphics_handle do_current_figure (void) const
5841 graphics_handle retval;
5843 for (const_figure_list_iterator p = figure_list.begin ();
5844 p != figure_list.end ();
5847 graphics_handle h = *p;
5849 if (is_handle_visible (h))
5856 void do_lock (void) { graphics_lock.lock (); }
5858 bool do_try_lock (void) { return graphics_lock.try_lock (); }
5860 void do_unlock (void) { graphics_lock.unlock (); }
5862 void do_execute_listener (const graphics_handle& h, const octave_value& l);
5864 void do_execute_callback (const graphics_handle& h, const octave_value& cb,
5865 const octave_value& data);
5867 void do_post_callback (const graphics_handle& h, const std::string name,
5868 const octave_value& data);
5870 void do_post_function (graphics_event::event_fcn fcn, void* fcn_data);
5872 void do_post_set (const graphics_handle& h, const std::string name,
5873 const octave_value& value, bool notify_toolkit = true);
5875 int do_process_events (bool force = false);
5877 void do_close_all_figures (void);
5879 static void restore_gcbo (void)
5882 instance->do_restore_gcbo ();
5885 void do_restore_gcbo (void);
5887 void do_post_event (const graphics_event& e);
5889 void do_enable_event_processing (bool enable = true);
5892 void get_children_limits (double& min_val, double& max_val,
5893 double& min_pos, double& max_neg,
5894 const Matrix& kids, char limit_type);
5896 OCTINTERP_API int calc_dimensions (const graphics_object& gh);
5898 // This function is NOT equivalent to the scripting language function gcf.
5899 OCTINTERP_API graphics_handle gcf (void);
5901 // This function is NOT equivalent to the scripting language function gca.
5902 OCTINTERP_API graphics_handle gca (void);
5904 OCTINTERP_API void close_all_figures (void);