25 #if !defined (octave_graphics_h)
26 #define octave_graphics_h 1
54 #if !defined (OCTAVE_DEFAULT_FONTNAME)
55 #define OCTAVE_DEFAULT_FONTNAME "*"
71 error (
"invalid axis scale");
77 error (
"invalid axis scale");
81 virtual double scale (
double d)
const
83 error (
"invalid axis scale");
89 error (
"invalid axis scale");
142 {
return log10 (d); }
145 {
return pow (10.0, d); }
151 void do_scale (
const double *src,
double *dest,
int n)
const
153 for (
int i = 0; i < n; i++)
154 dest[i] = log10 (src[i]);
182 {
return -log10 (-d); }
185 {
return -
pow (10.0, -d); }
191 void do_scale (
const double *src,
double *dest,
int n)
const
193 for (
int i = 0; i < n; i++)
194 dest[i] = -log10 (-src[i]);
252 else if (s ==
"neglog")
254 else if (s ==
"linear")
307 virtual bool is_radio (
void)
const {
return false; }
316 bool do_notify_toolkit =
true);
320 error (
"get: invalid property \"%s\"",
name.c_str ());
327 error (
"values_as_string: invalid property \"%s\"",
name.c_str ());
328 return std::string ();
333 error (
"values_as_cell: invalid property \"%s\"",
name.c_str ());
359 for (i = 0; i < l.
length (); i++)
361 if (v.internal_rep () == l(i).internal_rep ())
369 for (
int j = i; j < l.
length () - 1; j++)
383 for (
int i = l.
length () - 1; i >= 0 ; i--)
385 for (
int j = 0; j < lp.
length (); j++)
387 if (l(i).internal_rep () == lp(j).internal_rep ())
408 error (
"set: invalid property \"%s\"",
name.c_str ());
414 typedef std::map<listener_mode, octave_value_list>::iterator
416 typedef std::map<listener_mode, octave_value_list>::const_iterator
434 const std::string& val =
"")
467 error (
"set: invalid string property value for \"%s\"",
484 const std::string& val =
"",
const char& sep =
'|',
492 size_t new_pos = val.find_first_of (
separator, pos);
494 if (new_pos == std::string::npos)
500 str.
append (val.substr (pos, new_pos - pos));
507 const Cell& c,
const char& sep =
'|',
516 strings[i] = c(i).string_value ();
521 error (
"set: invalid order property value for \"%s\"",
575 while (pos != std::string::npos)
577 size_t new_pos = new_str.find_first_of (
separator, pos);
579 if (new_pos == std::string::npos)
581 strings.
append (new_str.substr (pos));
585 strings.
append (new_str.substr (pos, new_pos - pos));
593 if (strings[i] !=
str[i])
622 if (!replace && strings[i] !=
str[i])
649 if (strings[i] !=
str[i])
666 error (
"set: invalid string property value for \"%s\"",
685 const std::string& val =
"")
699 std::ostringstream buf;
701 value[i] = buf.str ();
718 value[i] = c(i).string_value ();
721 double d = c(i).double_value ();
725 std::ostringstream buf;
727 value[i] = buf.str ();
795 value[i] = c(i).string_value ();
798 double d = c(i).double_value ();
802 std::ostringstream buf;
804 value[i] = buf.str ();
825 std::ostringstream buf;
827 value[i] = buf.str ();
834 error (
"set: invalid string property value for \"%s\"",
878 error (
"invalid value = %s", val.c_str ());
889 size_t len = val.length ();
891 std::string first_match;
893 for (std::set<caseless_str>::const_iterator p =
possible_vals.begin ();
896 if (p->compare (val, len))
898 if (len == p->length ())
948 const std::string& v)
994 if (s.length () != match.length ())
996 "%s: allowing %s to match %s value %s",
997 "set", s.c_str (),
get_name ().c_str (),
1004 error (
"set: invalid value for radio property \"%s\" (value = %s)",
1008 error (
"set: invalid value for radio property \"%s\"",
1037 error (
"invalid color specification: %s", str.c_str ());
1060 {
return ! (*
this == c); }
1068 for (
int i = 0; i < 3; i++)
1072 error (
"invalid RGB color specification");
1115 const std::string& v)
1145 bool is (
const std::string& v)
const
1151 error (
"color has no rgb value");
1159 error (
"color has no radio value");
1228 error (
"set: invalid value for double property \"%s\"",
1249 const std::string& v)
1279 bool is (
const std::string& v)
const
1293 error (
"%s: property has no radio value");
1409 error (
"invalid value for array property \"%s\"",
1496 if (dv(0) > 1 && dv(1) == 1)
1698 *p = new_gh.
value ();
1703 error (
"children_list::renumber: child not found!");
1726 if (visible_kids.
numel () == new_kids.
numel ())
1738 error (
"set: new children must be a permutation of existing children");
1743 error (
"set: expecting children to be array of graphics handles");
1853 error (
"invalid value for callback property \"%s\"",
1891 {
return rep->
ok (); }
1924 bool do_notify_toolkit =
true)
1925 {
return rep->
set (val, do_run, do_notify_toolkit); }
2061 const std::string&,
bool,
2062 const std::string& =
"")
const
2068 return Matrix (1, 2, 0.0);
2080 return Matrix (1, 2, 0.0);
2095 {
gripe_invalid (
"base_graphics_toolkit::initialize");
return false; }
2119 error (
"%s: invalid graphics toolkit", fname.c_str ());
2172 const std::string& file,
bool mono,
2173 const std::string& debug_file =
"")
const
2293 ::error (
"unable to create gh_manager!");
2316 typedef std::set<std::string>::const_iterator
2319 typedef std::map<std::string, graphics_toolkit>::iterator
2322 typedef std::map<std::string, graphics_toolkit>::const_iterator
2387 std::string name = p->first;
2417 void mark_modified (
void);
2431 void insert_property (
const std::string& name,
property p)
2435 all_props[name] = p;
2454 virtual property get_property (
const caseless_str& pname);
2466 if (children.remove_child (h.
value ()))
2472 children.adopt (h.
value ());
2479 get_boundingbox (
bool =
false,
2481 {
return Matrix (1, 4, 0.0); }
2483 virtual void update_boundingbox (
void);
2485 virtual void update_autopos (
const std::string& elem_type);
2499 return children.get_children ();
2504 return children.get_all ();
2509 return children.get_hidden ();
2521 virtual void update_axis_limits (
const std::string& axis_type)
const;
2523 virtual void update_axis_limits (
const std::string& axis_type,
2526 virtual void delete_children (
bool clear =
false)
2528 children.delete_children (
clear);
2533 children.renumber (old_gh, new_gh);
2562 std::set<std::string> dynamic_property_names (
void)
const;
2564 bool has_dynamic_property (
const std::string& pname);
2575 property get_property_dynamic (
const caseless_str& pname);
2580 static std::set<std::string> core_property_names (
void);
2582 static bool has_core_property (
const caseless_str& pname);
2584 std::set<std::string> all_property_names (
void)
const;
2613 ID_BEINGDELETED = 0,
2615 ID_BUTTONDOWNFCN = 2,
2620 ID_HANDLEVISIBILITY = 7,
2622 ID_INTERRUPTIBLE = 9,
2625 ID_SELECTIONHIGHLIGHT = 12,
2628 ID_UICONTEXTMENU = 15,
2631 ID___MODIFIED__ = 18,
2632 ID___MYHANDLE__ = 19
2645 std::string
get_clipping (
void)
const {
return clipping.current_value (); }
2657 std::string
get_hittest (
void)
const {
return hittest.current_value (); }
2665 std::string
get_selected (
void)
const {
return selected.current_value (); }
2670 std::string
get_tag (
void)
const {
return tag.string_value (); }
2679 std::string
get_visible (
void)
const {
return visible.current_value (); }
2691 if (beingdeleted.set (val,
true))
2702 if (busyaction.set (val,
true))
2713 if (buttondownfcn.set (val,
true))
2724 if (children.set (val,
true))
2735 if (clipping.set (val,
true))
2746 if (createfcn.set (val,
true))
2757 if (deletefcn.set (val,
true))
2768 if (handlevisibility.set (val,
true))
2779 if (hittest.set (val,
true))
2790 if (interruptible.set (val,
true))
2801 if (selected.set (val,
true))
2812 if (selectionhighlight.set (val,
true))
2834 if (userdata.set (val,
true))
2845 if (visible.set (val,
true))
2867 std::map<caseless_str, property, cmp_caseless_str>
all_props;
2871 { insert_property (name,
property (&p,
true)); }
2890 error (
"base_graphics_object::mark_modified: invalid graphics object");
2898 error (
"base_graphics_object::override_defaults: invalid graphics object");
2906 error (
"base_graphics_object::set_from_list: invalid graphics object");
2914 error (
"base_graphics_object::set: invalid graphics object");
2919 error (
"base_graphics_object::set_defaults: invalid graphics object");
2928 error (
"base_graphics_object::get: invalid graphics object");
2939 error (
"base_graphics_object::get: invalid graphics object");
2950 error (
"base_graphics_object::get_defaults: invalid graphics object");
2956 error (
"base_graphics_object::get_factory_defaults: invalid graphics object");
2970 error (
"base_graphics_object::get_parent: invalid graphics object");
2981 error (
"base_graphics_object::get_handle: invalid graphics object");
2991 error (
"base_graphics_object::remove_child: invalid graphics object");
2999 error (
"base_graphics_object::adopt: invalid graphics object");
3007 error (
"base_graphics_object::reparent: invalid graphics object");
3014 std::string msg = (
type () +
"::defaults");
3018 error (
"base_graphics_object::default: invalid graphics object");
3024 error (
"base_graphics_object::get_properties: invalid graphics object");
3031 error (
"base_graphics_object::get_properties: invalid graphics object");
3044 virtual std::string
type (
void)
const
3050 bool isa (
const std::string& go_name)
const
3052 return type () == go_name;
3061 error (
"base_graphics_object::get_toolkit: invalid graphics object");
3082 virtual void remove_all_listeners (
void);
3088 std::string msg = (
type () +
"::reset_default_properties");
3092 error (
"base_graphics_object::default: invalid graphics object");
3107 toolkit_flag =
false;
3152 if (--rep->count == 0)
3164 if (--rep->count == 0)
3172 rep->override_defaults (obj);
3179 rep->set (name, val);
3198 return name.compare (
"default")
3200 : (name.compare (
"factory")
3201 ? get_factory_defaults () : rep->get (name));
3216 return rep->get_default (name);
3221 return rep->get_factory_default (name);
3228 return rep->get_factory_defaults ();
3249 bool isa (
const std::string& go_name)
const {
return rep->isa (go_name); }
3255 return rep->get_properties ();
3258 void update_axis_limits (
const std::string& axis_type)
3263 void update_axis_limits (
const std::string& axis_type,
3266 rep->update_axis_limits (axis_type, h);
3271 std::string
type (
void)
const {
return rep->type (); }
3273 operator bool (
void)
const {
return rep->valid_object (); }
3281 {
return get_properties ().get_alim (); }
3284 {
return get_properties ().get_clim (); }
3287 {
return get_properties ().get_xlim (); }
3290 {
return get_properties ().get_ylim (); }
3293 {
return get_properties ().get_zlim (); }
3295 bool is_aliminclude (
void)
const
3296 {
return get_properties ().is_aliminclude (); }
3298 bool is_climinclude (
void)
const
3299 {
return get_properties ().is_climinclude (); }
3301 bool is_xliminclude (
void)
const
3302 {
return get_properties ().is_xliminclude (); }
3304 bool is_yliminclude (
void)
const
3305 {
return get_properties ().is_yliminclude (); }
3307 bool is_zliminclude (
void)
const
3308 {
return get_properties ().is_zliminclude (); }
3311 {
return get_properties ().is_handle_visible (); }
3317 { rep->add_property_listener (nm, v, mode); }
3319 void delete_property_listener (
const std::string& nm,
const octave_value& v,
3321 { rep->delete_property_listener (nm, v, mode); }
3327 void update (
int id) { rep->update (*
this,
id); }
3330 { rep->reset_default_properties (); }
3346 Matrix get_boundingbox (
bool internal =
false,
3402 static std::set<std::string> core_property_names (
void);
3404 static bool has_core_property (
const caseless_str& pname);
3406 std::set<std::string> all_property_names (
void)
const;
3437 ID_CALLBACKOBJECT = 1000,
3438 ID_COMMANDWINDOWSIZE = 1001,
3439 ID_CURRENTFIGURE = 1002,
3441 ID_DIARYFILE = 1004,
3443 ID_ERRORMESSAGE = 1006,
3444 ID_FIXEDWIDTHFONTNAME = 1007,
3446 ID_FORMATSPACING = 1009,
3448 ID_MONITORPOSITIONS = 1011,
3449 ID_POINTERLOCATION = 1012,
3450 ID_POINTERWINDOW = 1013,
3451 ID_RECURSIONLIMIT = 1014,
3452 ID_SCREENDEPTH = 1015,
3453 ID_SCREENPIXELSPERINCH = 1016,
3454 ID_SCREENSIZE = 1017,
3455 ID_SHOWHIDDENHANDLES = 1018,
3466 std::string
get_diary (
void)
const {
return diary.current_value (); }
3470 bool is_echo (
void)
const {
return echo.is_on (); }
3471 std::string
get_echo (
void)
const {
return echo.current_value (); }
3477 bool format_is (
const std::string& v)
const {
return format.is (v); }
3478 std::string
get_format (
void)
const {
return format.current_value (); }
3502 bool units_is (
const std::string& v)
const {
return units.is (v); }
3503 std::string
get_units (
void)
const {
return units.current_value (); }
3512 if (commandwindowsize.set (val,
true))
3525 if (diary.set (val,
true))
3536 if (diaryfile.set (val,
true))
3547 if (echo.set (val,
true))
3558 if (errormessage.set (val,
true))
3569 if (fixedwidthfontname.set (val,
true))
3580 if (format.set (val,
true))
3591 if (formatspacing.set (val,
true))
3602 if (language.set (val,
true))
3613 if (monitorpositions.set (val,
true))
3624 if (pointerlocation.set (val,
true))
3635 if (pointerwindow.set (val,
true))
3646 if (recursionlimit.set (val,
true))
3657 if (screendepth.set (val,
true))
3668 if (screenpixelsperinch.set (val,
true))
3679 if (screensize.set (val,
true))
3690 if (showhiddenhandles.set (val,
true))
3701 if (units.set (val,
true))
3709 void update_units (
void);
3740 if (name.compare (
"default", 7))
3744 default_properties.set (name.substr (7), value);
3746 xproperties.set (name, value);
3753 if (name.compare (
"default", 7))
3754 return get_default (name.substr (7));
3755 else if (name.compare (
"factory", 7))
3756 return get_factory_default (name.substr (7));
3758 retval = xproperties.get (name);
3765 octave_value retval = default_properties.lookup (name);
3770 retval = factory_properties.lookup (name);
3773 error (
"get: invalid default property '%s'", name.c_str ());
3781 octave_value retval = factory_properties.lookup (name);
3784 error (
"get: invalid factory default property '%s'", name.c_str ());
3791 return default_properties.as_struct (
"default");
3796 return factory_properties.as_struct (
"factory");
3825 integerhandle = val;
3852 error (
"set___graphics_toolkit__: invalid graphics toolkit");
3861 error (
"set___graphics_toolkit__ must be a string");
3866 bool do_notify_toolkit =
true);
3869 bool do_notify_toolkit =
true);
3871 Matrix get_boundingbox (
bool internal =
false,
3874 void set_boundingbox (
const Matrix& bb,
bool internal =
false,
3875 bool do_notify_toolkit =
true);
3877 Matrix map_from_boundingbox (
double x,
double y)
const;
3879 Matrix map_to_boundingbox (
double x,
double y)
const;
3883 void update_paperunits (
const caseless_str& old_paperunits);
3885 std::string get_title (
void)
const;
3924 static std::set<std::string> core_property_names (
void);
3926 static bool has_core_property (
const caseless_str& pname);
3928 std::set<std::string> all_property_names (
void)
const;
3995 ID_BUTTONDOWNFCN = 2001,
3996 ID_CLOSEREQUESTFCN = 2002,
3999 ID_CURRENTAXES = 2005,
4000 ID_CURRENTCHARACTER = 2006,
4001 ID_CURRENTOBJECT = 2007,
4002 ID_CURRENTPOINT = 2008,
4003 ID_DOCKCONTROLS = 2009,
4004 ID_DOUBLEBUFFER = 2010,
4006 ID_INTEGERHANDLE = 2012,
4007 ID_INVERTHARDCOPY = 2013,
4008 ID_KEYPRESSFCN = 2014,
4009 ID_KEYRELEASEFCN = 2015,
4011 ID_MINCOLORMAP = 2017,
4014 ID_NUMBERTITLE = 2020,
4015 ID_OUTERPOSITION = 2021,
4016 ID_PAPERORIENTATION = 2022,
4017 ID_PAPERPOSITION = 2023,
4018 ID_PAPERPOSITIONMODE = 2024,
4019 ID_PAPERSIZE = 2025,
4020 ID_PAPERTYPE = 2026,
4021 ID_PAPERUNITS = 2027,
4023 ID_POINTERSHAPECDATA = 2029,
4024 ID_POINTERSHAPEHOTSPOT = 2030,
4027 ID_RENDERERMODE = 2033,
4029 ID_RESIZEFCN = 2035,
4030 ID_SELECTIONTYPE = 2036,
4033 ID_WINDOWBUTTONDOWNFCN = 2039,
4034 ID_WINDOWBUTTONMOTIONFCN = 2040,
4035 ID_WINDOWBUTTONUPFCN = 2041,
4036 ID_WINDOWKEYPRESSFCN = 2042,
4037 ID_WINDOWKEYRELEASEFCN = 2043,
4038 ID_WINDOWSCROLLWHEELFCN = 2044,
4039 ID_WINDOWSTYLE = 2045,
4041 ID_WVISUALMODE = 2047,
4044 ID_XVISUALMODE = 2050,
4045 ID___ENHANCED__ = 2051,
4046 ID___GRAPHICS_TOOLKIT__ = 2052,
4047 ID___GUIDATA__ = 2053,
4048 ID___PLOT_STREAM__ = 2054
4060 bool color_is (
const std::string& v)
const {
return color.is (v); }
4094 bool menubar_is (
const std::string& v)
const {
return menubar.is (v); }
4095 std::string
get_menubar (
void)
const {
return menubar.current_value (); }
4099 std::string
get_name (
void)
const {
return name.string_value (); }
4101 bool nextplot_is (
const std::string& v)
const {
return nextplot.is (v); }
4102 std::string
get_nextplot (
void)
const {
return nextplot.current_value (); }
4119 bool papertype_is (
const std::string& v)
const {
return papertype.is (v); }
4125 bool pointer_is (
const std::string& v)
const {
return pointer.is (v); }
4126 std::string
get_pointer (
void)
const {
return pointer.current_value (); }
4134 bool renderer_is (
const std::string& v)
const {
return renderer.is (v); }
4135 std::string
get_renderer (
void)
const {
return renderer.current_value (); }
4141 std::string
get_resize (
void)
const {
return resize.current_value (); }
4149 bool toolbar_is (
const std::string& v)
const {
return toolbar.is (v); }
4150 std::string
get_toolbar (
void)
const {
return toolbar.current_value (); }
4152 bool units_is (
const std::string& v)
const {
return units.is (v); }
4153 std::string
get_units (
void)
const {
return units.current_value (); }
4176 std::string
get_wvisual (
void)
const {
return wvisual.string_value (); }
4183 std::string
get_xvisual (
void)
const {
return xvisual.string_value (); }
4202 if (alphamap.set (val,
true))
4213 if (buttondownfcn.set (val,
true))
4224 if (closerequestfcn.set (val,
true))
4235 if (color.set (val,
true))
4246 if (colormap.set (val,
true))
4259 if (currentcharacter.set (val,
true))
4270 if (currentobject.set (val,
true))
4281 if (currentpoint.set (val,
true))
4292 if (dockcontrols.set (val,
true))
4303 if (doublebuffer.set (val,
true))
4314 if (filename.set (val,
true))
4327 if (inverthardcopy.set (val,
true))
4338 if (keypressfcn.set (val,
true))
4349 if (keyreleasefcn.set (val,
true))
4360 if (menubar.set (val,
true))
4371 if (mincolormap.set (val,
true))
4382 if (name.set (val,
true))
4393 if (nextplot.set (val,
true))
4404 if (numbertitle.set (val,
true))
4415 if (paperorientation.set (val,
true))
4417 update_paperorientation ();
4423 void update_paperorientation (
void);
4429 if (paperposition.set (val,
true))
4440 if (paperpositionmode.set (val,
true))
4451 if (papersize.set (val,
true))
4453 update_papersize ();
4459 void update_papersize (
void);
4463 void update_papertype (
void);
4471 if (pointer.set (val,
true))
4482 if (pointershapecdata.set (val,
true))
4493 if (pointershapehotspot.set (val,
true))
4504 if (renderer.set (val,
true))
4515 if (renderermode.set (val,
true))
4526 if (resize.set (val,
true))
4537 if (resizefcn.set (val,
true))
4548 if (selectiontype.set (val,
true))
4559 if (toolbar.set (val,
true))
4572 if (windowbuttondownfcn.set (val,
true))
4583 if (windowbuttonmotionfcn.set (val,
true))
4594 if (windowbuttonupfcn.set (val,
true))
4605 if (windowkeypressfcn.set (val,
true))
4616 if (windowkeyreleasefcn.set (val,
true))
4627 if (windowscrollwheelfcn.set (val,
true))
4638 if (windowstyle.set (val,
true))
4649 if (wvisual.set (val,
true))
4660 if (wvisualmode.set (val,
true))
4671 if (xdisplay.set (val,
true))
4682 if (xvisual.set (val,
true))
4693 if (xvisualmode.set (val,
true))
4704 if (__enhanced__.set (val,
true))
4715 if (__guidata__.set (val,
true))
4726 if (__plot_stream__.set (val,
true))
4737 alphamap.add_constraint (
dim_vector (-1, 1));
4738 colormap.add_constraint (
dim_vector (-1, 3));
4739 outerposition.add_constraint (
dim_vector (1, 4));
4740 paperposition.add_constraint (
dim_vector (1, 4));
4741 papersize.add_constraint (
dim_vector (1, 2));
4742 pointershapecdata.add_constraint (
dim_vector (16, 16));
4743 pointershapehotspot.add_constraint (
dim_vector (1, 2));
4767 xproperties.override_defaults (obj);
4779 if (name.compare (
"default", 7))
4783 default_properties.set (name.substr (7), value);
4785 xproperties.set (name, value);
4792 if (name.compare (
"default", 7))
4793 retval = get_default (name.substr (7));
4795 retval = xproperties.get (name);
4804 return default_properties.as_struct (
"default");
4825 :
xform (xform_eye ()), xform_inv (xform_eye ()),
4826 sx (
"linear"), sy (
"linear"), sz (
"linear"), zlim (1, 2, 0.0)
4834 :
xform (xm), xform_inv (xim), sx (x), sy (y), sz (z), zlim (zl) { }
4837 :
xform (g.
xform), xform_inv (g.xform_inv), sx (g.sx),
4838 sy (g.sy), sz (g.sz), zlim (g.zlim) { }
4856 static Matrix xform_eye (
void);
4859 bool use_scale =
true)
const;
4862 bool use_scale =
true)
const;
4865 {
return untransform (x, y, (zlim(0)+zlim(1))/2, use_scale); }
4873 bool has_z = (m.
columns () > 2);
4875 if (sx.is_linear () && sy.is_linear ()
4876 && (! has_z || sz.is_linear ()))
4883 for (
int i = 0; i < r; i++)
4885 retval(i,0) = sx.scale (m(i,0));
4886 retval(i,1) = sy.scale (m(i,1));
4888 retval(i,2) = sz.scale (m(i,2));
4923 Matrix get_boundingbox (
bool internal =
false,
4925 Matrix get_extent (
bool with_text =
false,
4926 bool only_text_height=
false)
const;
4928 double get_fontsize_points (
double box_pix_height = 0)
const;
4930 void update_boundingbox (
void)
4932 if (units_is (
"normalized"))
4939 void update_camera (
void);
4940 void update_axes_layout (
void);
4941 void update_aspectratios (
void);
4942 void update_transform (
void)
4944 update_aspectratios ();
4946 update_axes_layout ();
4949 void sync_positions (
void);
4951 void update_autopos (
const std::string& elem_type);
4952 void update_xlabel_position (
void);
4953 void update_ylabel_position (
void);
4954 void update_zlabel_position (
void);
4955 void update_title_position (
void);
4958 {
return graphics_xform (x_render, x_render_inv, sx, sy, sz, x_zlim); }