25 #if ! defined (octave_graphics_h)
26 #define octave_graphics_h 1
28 #include "octave-config.h"
52 #if ! defined (OCTAVE_DEFAULT_FONTNAME)
53 #define OCTAVE_DEFAULT_FONTNAME "*"
69 error (
"invalid axis scale");
74 error (
"invalid axis scale");
77 virtual double scale (
double)
const
79 error (
"invalid axis scale");
84 error (
"invalid axis scale");
136 {
return log10 (d); }
139 {
return pow (10.0, d); }
145 void do_scale (
const double *src,
double *dest,
int n)
const
147 for (
int i = 0;
i < n;
i++)
148 dest[
i] = log10 (src[
i]);
176 {
return -log10 (-d); }
179 {
return -
pow (10.0, -d); }
185 void do_scale (
const double *src,
double *dest,
int n)
const
187 for (
int i = 0;
i < n;
i++)
188 dest[
i] = -log10 (-src[
i]);
246 else if (s ==
"neglog")
248 else if (s ==
"linear")
301 virtual bool is_radio (
void)
const {
return false; }
310 bool do_notify_toolkit =
true);
314 error (
"get: invalid property \"%s\"",
name.c_str ());
319 error (
"values_as_string: invalid property \"%s\"",
name.c_str ());
324 error (
"values_as_cell: invalid property \"%s\"",
name.c_str ());
349 for (i = 0; i < l.
length (); i++)
351 if (v.internal_rep () == l(i).internal_rep ())
359 for (
int j = i; j < l.
length () - 1; j++)
373 for (
int i = l.
length () - 1;
i >= 0 ;
i--)
375 for (
int j = 0; j < lp.
length (); j++)
377 if (l(
i).internal_rep () == lp(j).internal_rep ())
398 error (
"set: invalid property \"%s\"",
name.c_str ());
403 typedef std::map<listener_mode, octave_value_list>::iterator
405 typedef std::map<listener_mode, octave_value_list>::const_iterator
446 error (
"set: invalid string property value for \"%s\"",
481 if (new_pos == std::string::npos)
494 const Cell&
c,
const char& sep =
'|',
499 error (
"set: invalid order property value for \"%s\"",
505 strings[
i] =
c(
i).string_value ();
560 while (pos != std::string::npos)
562 size_t new_pos = new_str.find_first_of (
separator, pos);
564 if (new_pos == std::string::npos)
566 strings.
append (new_str.substr (pos));
570 strings.
append (new_str.substr (pos, new_pos - pos));
578 if (strings[
i] !=
str[
i])
607 if (! replace && strings[
i] !=
str[
i])
634 if (strings[
i] !=
str[
i])
651 error (
"set: invalid string property value for \"%s\"",
685 std::ostringstream buf;
707 double d =
c(
i).double_value ();
709 std::ostringstream buf;
779 double d =
c(
i).double_value ();
781 std::ostringstream buf;
797 catch (octave::execution_exception&
e)
799 error (e,
"set: invalid string property value for \"%s\"",
809 std::ostringstream buf;
853 error (
"invalid value = %s", val.c_str ());
862 size_t len = val.length ();
868 if (possible_val.compare (val, len))
870 if (len == possible_val.length ())
875 match = possible_val;
881 first_match = possible_val;
955 error (
"set: invalid value for radio property \"%s\"",
963 error (
"set: invalid value for radio property \"%s\" (value = %s)",
968 if (s.length () != match.length ())
970 "%s: allowing %s to match %s value %s",
971 "set", s.c_str (),
get_name ().c_str (),
1003 error (
"invalid color specification: %s", str.c_str ());
1026 {
return ! (*
this ==
c); }
1034 for (
int i = 0;
i < 3;
i++)
1037 error (
"invalid RGB color specification");
1114 error (
"color has no RGB value");
1122 error (
"color has no radio value");
1181 error (
"set: invalid value for double property \"%s\"",
1255 error (
"%s: property has no radio value");
1359 error (
"invalid value for array property \"%s\"",
1455 if (
dv(0) > 1 &&
dv(1) == 1)
1653 if (hchild == old_gh)
1655 hchild = new_gh.
value ();
1660 error (
"children_list::renumber: child not found!");
1677 catch (octave::execution_exception&
e)
1679 error (e,
"set: children must be an array of graphics handles");
1687 bool add_hidden =
true;
1691 if (visible_kids.
numel () == new_kids.
numel ())
1707 error (
"set: new children must be a permutation of existing children");
1716 children_list.clear ();
1723 children_list.push_back (tmp.
xelem (
i));
1732 children_list.clear ();
1734 children_list.push_front (val.
xelem (
i));
1739 children_list.clear ();
1740 children_list =
val;
1750 for (
const auto& hchild : children_list)
1758 for (
auto it = children_list.begin (); it != children_list.end (); it++)
1762 children_list.erase (it);
1771 children_list.push_front (val);
1810 error (
"invalid value for callback property \"%s\"",
1851 {
return rep->
ok (); }
1884 bool do_notify_toolkit =
true)
1885 {
return rep->
set (val, do_run, do_notify_toolkit); }
1963 for (it = (*this).begin (); it != (*this).end (); it++)
1964 if (pname == (*it).first)
1967 return (*this).end ();
1974 for (it = (*this).begin (); it != (*this).end (); it++)
1975 if (pname == (*it).first)
1978 return (*this).end ();
1985 const_iterator it =
find (pname);
1987 if (it != (*this).end ())
1988 retval = (*it).second;
1995 iterator it =
find (pname);
1997 if (it == (*this).end ())
2000 return (*this).back ().second;
2003 return (*it).second;
2008 iterator it =
find (pname);
2009 if (it != (*this).end ())
2015 std::vector<pval_pair>::erase (it);
2094 return Matrix (1, 2, 0.0);
2106 return Matrix (1, 2, 0.0);
2148 error (
"%s: invalid graphics toolkit", fname.c_str ());
2321 error (
"unable to create gh_manager!");
2341 typedef std::set<std::string>::const_iterator
2344 typedef std::map<std::string, graphics_toolkit>::iterator
2347 typedef std::map<std::string, graphics_toolkit>::const_iterator
2358 loaded_toolkits[tk.
get_name ()] = tk;
2363 loaded_toolkits.erase (name);
2370 if (p != loaded_toolkits.end ())
2378 Cell m (1, available_toolkits.size ());
2381 for (
const auto& tkit : available_toolkits)
2389 Cell m (1, loaded_toolkits.size ());
2392 for (
const auto& nm_tkit_p : loaded_toolkits)
2393 m(i++) = nm_tkit_p.first;
2400 while (! loaded_toolkits.empty ())
2409 if (loaded_toolkits.find (name) != loaded_toolkits.end ())
2433 void mark_modified (
void);
2451 all_props[
name] =
p;
2482 if (children.remove_child (h.
value ()))
2484 children.run_listeners ();
2491 children.adopt (h.
value ());
2492 children.run_listeners ();
2501 {
return Matrix (1, 4, 0.0); }
2503 virtual void update_boundingbox (
void);
2505 virtual void update_autopos (
const std::string& elem_type);
2519 return children.get_children ();
2524 return children.get_all ();
2529 return children.get_hidden ();
2541 virtual void update_axis_limits (
const std::string& axis_type)
const;
2543 virtual void update_axis_limits (
const std::string& axis_type,
2546 virtual void update_uicontextmenu (
void)
const;
2550 children.delete_children (
clear);
2555 children.renumber (old_gh, new_gh);
2584 std::set<std::string> dynamic_property_names (
void)
const;
2602 static std::set<std::string> core_property_names (
void);
2604 static std::set<std::string> readonly_property_names (
void);
2610 std::set<std::string> all_property_names (
void)
const;
2639 ID_BEINGDELETED = 0,
2641 ID_BUTTONDOWNFCN = 2,
2646 ID_HANDLEVISIBILITY = 7,
2648 ID_INTERRUPTIBLE = 9,
2651 ID_SELECTIONHIGHLIGHT = 12,
2654 ID_UICONTEXTMENU = 15,
2657 ID___MODIFIED__ = 18,
2658 ID___MYHANDLE__ = 19
2716 if (beingdeleted.
set (val,
true))
2726 if (busyaction.
set (val,
true))
2736 if (buttondownfcn.
set (val,
true))
2746 if (children.
set (val,
true))
2756 if (clipping.
set (val,
true))
2766 if (createfcn.
set (val,
true))
2776 if (deletefcn.
set (val,
true))
2786 if (handlevisibility.
set (val,
true))
2796 if (hittest.
set (val,
true))
2806 if (interruptible.
set (val,
true))
2816 if (selected.
set (val,
true))
2826 if (selectionhighlight.
set (val,
true))
2836 if (uicontextmenu.
set (val,
true))
2838 update_uicontextmenu ();
2847 if (userdata.
set (val,
true))
2857 if (visible.
set (val,
true))
2879 std::map<caseless_str, property, cmp_caseless_str>
all_props;
2883 { insert_property (name,
property (&p,
true)); }
2900 error (
"base_graphics_object::mark_modified: invalid graphics object");
2908 error (
"base_graphics_object::override_defaults: invalid graphics object");
2918 error (
"base_graphics_object::set_from_list: invalid graphics object");
2926 error (
"base_graphics_object::set: invalid graphics object");
2933 error (
"base_graphics_object::set_defaults: invalid graphics object");
2939 error (
"base_graphics_object::get: invalid graphics object");
2947 error (
"base_graphics_object::get: invalid graphics object");
2958 error (
"base_graphics_object::get_defaults: invalid graphics object");
2964 error (
"base_graphics_object::get_defaults_list: invalid graphics object");
2971 error (
"base_graphics_object::get_factory_defaults: invalid graphics object");
2976 error (
"base_graphics_object::get_factory_defaults_list: invalid graphics object");
2993 error (
"base_graphics_object::get_parent: invalid graphics object");
3001 error (
"base_graphics_object::get_handle: invalid graphics object");
3009 error (
"base_graphics_object::remove_child: invalid graphics object");
3017 error (
"base_graphics_object::adopt: invalid graphics object");
3025 error (
"base_graphics_object::reparent: invalid graphics object");
3033 error (
"base_graphics_object::default: invalid graphics object");
3042 warning (
"base_graphics_object::get_properties: invalid graphics object");
3049 warning (
"base_graphics_object::get_properties: invalid graphics object");
3070 return type () == go_name;
3076 error (
"base_graphics_object::get_toolkit: invalid graphics object");
3097 virtual void remove_all_listeners (
void);
3113 toolkit_flag =
false;
3158 if (--rep->count == 0)
3170 if (--rep->count == 0)
3178 rep->override_defaults (obj);
3183 rep->override_defaults (*rep);
3189 rep->build_user_defaults_map (def, go_name);
3196 rep->set (name, val);
3215 return name.compare (
"default")
3217 : (
name.compare (
"factory")
3218 ? get_factory_defaults () : rep->get (
name));
3233 return rep->get_default (name);
3238 return rep->get_factory_default (name);
3245 return rep->get_defaults_list ();
3250 return rep->get_factory_defaults ();
3255 return rep->get_factory_defaults_list ();
3260 return rep->has_readonly_property (pname);
3267 return rep->value_as_string (prop);
3292 return rep->get_properties ();
3297 rep->update_axis_limits (axis_type);
3303 rep->update_axis_limits (axis_type, h);
3310 operator bool (
void)
const {
return rep->valid_object (); }
3318 {
return get_properties ().get_alim (); }
3321 {
return get_properties ().get_clim (); }
3324 {
return get_properties ().get_xlim (); }
3327 {
return get_properties ().get_ylim (); }
3330 {
return get_properties ().get_zlim (); }
3333 {
return get_properties ().is_aliminclude (); }
3336 {
return get_properties ().is_climinclude (); }
3339 {
return get_properties ().is_xliminclude (); }
3342 {
return get_properties ().is_yliminclude (); }
3345 {
return get_properties ().is_zliminclude (); }
3348 {
return get_properties ().is_handle_visible (); }
3354 { rep->add_property_listener (nm, v,
mode); }
3358 { rep->delete_property_listener (nm, v,
mode); }
3364 void update (
int id) { rep->update (*
this,
id); }
3367 { rep->reset_default_properties (); }
3464 ID_CALLBACKOBJECT = 1000,
3465 ID_COMMANDWINDOWSIZE = 1001,
3466 ID_CURRENTFIGURE = 1002,
3467 ID_FIXEDWIDTHFONTNAME = 1003,
3468 ID_MONITORPOSITIONS = 1004,
3469 ID_POINTERLOCATION = 1005,
3470 ID_POINTERWINDOW = 1006,
3471 ID_SCREENDEPTH = 1007,
3472 ID_SCREENPIXELSPERINCH = 1008,
3473 ID_SCREENSIZE = 1009,
3474 ID_SHOWHIDDENHANDLES = 1010,
3510 if (commandwindowsize.
set (val,
true))
3522 if (fixedwidthfontname.
set (val,
true))
3532 if (monitorpositions.
set (val,
true))
3542 if (pointerlocation.
set (val,
true))
3552 if (pointerwindow.
set (val,
true))
3562 if (screendepth.
set (val,
true))
3572 if (screenpixelsperinch.
set (val,
true))
3582 if (screensize.
set (val,
true))
3592 if (showhiddenhandles.
set (val,
true))
3602 if (units.
set (val,
true))
3610 void update_units (
void);
3642 if (name.
compare (
"default", 7))
3646 default_properties.set (name.substr (7),
value);
3648 xproperties.
set (name, value);
3655 if (
name.compare (
"default", 7))
3656 return get_default (
name.substr (7));
3657 else if (
name.compare (
"factory", 7))
3658 return get_factory_default (
name.substr (7));
3660 retval = xproperties.
get (
name);
3672 retval = factory_properties.lookup (name);
3675 error (
"get: invalid default property '%s'", name.c_str ());
3686 error (
"get: invalid factory default property '%s'", name.c_str ());
3693 return default_properties.as_struct (
"default");
3698 return default_properties;
3703 return factory_properties.as_struct (
"factory");
3708 return factory_properties;
3717 void reset_default_properties (
void);
3745 integerhandle =
val;
3765 error (
"set___graphics_toolkit__ must be a string");
3771 error (
"set___graphics_toolkit__: invalid graphics toolkit");
3773 if (nm != get___graphics_toolkit__ ())
3783 bool do_notify_toolkit =
true);
3786 bool do_notify_toolkit =
true);
3791 void set_boundingbox (
const Matrix& bb,
bool internal =
false,
3792 bool do_notify_toolkit =
true);
3794 Matrix map_from_boundingbox (
double x,
double y)
const;
3796 Matrix map_to_boundingbox (
double x,
double y)
const;
3800 void update_paperunits (
const caseless_str& old_paperunits);
3931 ID_BUTTONDOWNFCN = 2001,
3932 ID_CLOSEREQUESTFCN = 2002,
3935 ID_CURRENTAXES = 2005,
3936 ID_CURRENTCHARACTER = 2006,
3937 ID_CURRENTOBJECT = 2007,
3938 ID_CURRENTPOINT = 2008,
3939 ID_DOCKCONTROLS = 2009,
3941 ID_GRAPHICSSMOOTHING = 2011,
3942 ID_INTEGERHANDLE = 2012,
3943 ID_INVERTHARDCOPY = 2013,
3944 ID_KEYPRESSFCN = 2014,
3945 ID_KEYRELEASEFCN = 2015,
3949 ID_NUMBERTITLE = 2019,
3950 ID_OUTERPOSITION = 2020,
3951 ID_PAPERORIENTATION = 2021,
3952 ID_PAPERPOSITION = 2022,
3953 ID_PAPERPOSITIONMODE = 2023,
3954 ID_PAPERSIZE = 2024,
3955 ID_PAPERTYPE = 2025,
3956 ID_PAPERUNITS = 2026,
3958 ID_POINTERSHAPECDATA = 2028,
3959 ID_POINTERSHAPEHOTSPOT = 2029,
3962 ID_RENDERERMODE = 2032,
3964 ID_RESIZEFCN = 2034,
3965 ID_SELECTIONTYPE = 2035,
3966 ID_SIZECHANGEDFCN = 2036,
3969 ID_WINDOWBUTTONDOWNFCN = 2039,
3970 ID_WINDOWBUTTONMOTIONFCN = 2040,
3971 ID_WINDOWBUTTONUPFCN = 2041,
3972 ID_WINDOWKEYPRESSFCN = 2042,
3973 ID_WINDOWKEYRELEASEFCN = 2043,
3974 ID_WINDOWSCROLLWHEELFCN = 2044,
3975 ID_WINDOWSTYLE = 2045,
3976 ID___GL_EXTENSIONS__ = 2046,
3977 ID___GL_RENDERER__ = 2047,
3978 ID___GL_VENDOR__ = 2048,
3979 ID___GL_VERSION__ = 2049,
3980 ID___GRAPHICS_TOOLKIT__ = 2050,
3981 ID___GUIDATA__ = 2051,
3982 ID___MOUSE_MODE__ = 2052,
3983 ID___PAN_MODE__ = 2053,
3984 ID___PLOT_STREAM__ = 2054,
3985 ID___ROTATE_MODE__ = 2055,
3986 ID___ZOOM_MODE__ = 2056,
3987 ID_DOUBLEBUFFER = 2057,
3988 ID_MINCOLORMAP = 2058,
3990 ID_WVISUALMODE = 2060,
3993 ID_XVISUALMODE = 2063
4166 if (alphamap.
set (val,
true))
4176 if (buttondownfcn.
set (val,
true))
4186 if (closerequestfcn.
set (val,
true))
4196 if (color.
set (val,
true))
4206 if (colormap.
set (val,
true))
4218 if (currentcharacter.
set (val,
true))
4228 if (currentobject.
set (val,
true))
4238 if (currentpoint.
set (val,
true))
4248 if (dockcontrols.
set (val,
true))
4258 if (filename.
set (val,
true))
4268 if (graphicssmoothing.
set (val,
true))
4280 if (inverthardcopy.
set (val,
true))
4290 if (keypressfcn.
set (val,
true))
4300 if (keyreleasefcn.
set (val,
true))
4310 if (menubar.
set (val,
true))
4320 if (name.
set (val,
true))
4330 if (nextplot.
set (val,
true))
4340 if (numbertitle.
set (val,
true))
4350 if (paperorientation.
set (val,
true))
4352 update_paperorientation ();
4358 void update_paperorientation (
void);
4363 if (paperposition.
set (val,
false))
4365 set_paperpositionmode (
"manual");
4370 set_paperpositionmode (
"manual");
4377 if (paperpositionmode.
set (val,
true))
4379 update_paperpositionmode ();
4388 if (papersize.
set (val,
true))
4390 update_papersize ();
4396 void update_papersize (
void);
4400 void update_papertype (
void);
4407 if (pointer.
set (val,
true))
4417 if (pointershapecdata.
set (val,
true))
4427 if (pointershapehotspot.
set (val,
true))
4437 if (renderer.
set (val,
false))
4439 set_renderermode (
"manual");