comparison src/graphics.cc @ 7379:a78c7bccda91

[project @ 2008-01-15 18:42:29 by jwe]
author jwe
date Tue, 15 Jan 2008 18:42:30 +0000
parents 3771971e8891
children 135c13496faf
comparison
equal deleted inserted replaced
7378:3771971e8891 7379:a78c7bccda91
952 952
953 return retval; 953 return retval;
954 } 954 }
955 955
956 octave_value 956 octave_value
957 base_properties::get (void) const 957 base_properties::get (bool all) const
958 { 958 {
959 Octave_map m; 959 Octave_map m;
960 960
961 for (std::map<caseless_str, property>::const_iterator it = all_props.begin (); 961 for (std::map<caseless_str, property>::const_iterator it = all_props.begin ();
962 it != all_props.end (); ++it) 962 it != all_props.end (); ++it)
963 m.assign (it->second.get_name (), it->second.get ()); 963 if (all || ! it->second.is_hidden ())
964 m.assign (it->second.get_name (), it->second.get ());
964 965
965 m.assign ("tag", get_tag ()); 966 m.assign ("tag", get_tag ());
966 m.assign ("type", get_type ()); 967 m.assign ("type", get_type ());
967 m.assign ("__modified__", is_modified ()); 968 if (all)
969 m.assign ("__modified__", is_modified ());
968 m.assign ("parent", get_parent ().as_octave_value ()); 970 m.assign ("parent", get_parent ().as_octave_value ());
969 m.assign ("children", children); 971 m.assign ("children", children);
970 m.assign ("busyaction", get_busyaction ()); 972 m.assign ("busyaction", get_busyaction ());
971 m.assign ("buttondownfcn", get_buttondownfcn ()); 973 m.assign ("buttondownfcn", get_buttondownfcn ());
972 m.assign ("clipping", get_clipping ()); 974 m.assign ("clipping", get_clipping ());
1105 void 1107 void
1106 base_properties::mark_modified (void) 1108 base_properties::mark_modified (void)
1107 { 1109 {
1108 __modified__ = "on"; 1110 __modified__ = "on";
1109 graphics_object parent_obj = gh_manager::get_object (get_parent ()); 1111 graphics_object parent_obj = gh_manager::get_object (get_parent ());
1110 parent_obj.mark_modified (); 1112 if (parent_obj)
1113 parent_obj.mark_modified ();
1111 } 1114 }
1112 1115
1113 void 1116 void
1114 base_properties::override_defaults (base_graphics_object& obj) 1117 base_properties::override_defaults (base_graphics_object& obj)
1115 { 1118 {
1968 } 1971 }
1969 1972
1970 return retval; 1973 return retval;
1971 } 1974 }
1972 1975
1976 DEFUN (__get__, args, ,
1977 "-*- texinfo -*-\n\
1978 @deftypefn {Built-in Function} {} __get__ (@var{h})\n\
1979 Return all properties from the graphics handle @var{h}.\n\
1980 If @var{h} is a vector, return a cell array including the property\n\
1981 values or lists respectively.\n\
1982 @end deftypefn")
1983 {
1984 octave_value retval;
1985 octave_value_list vlist;
1986
1987 int nargin = args.length ();
1988
1989 if (nargin == 1)
1990 {
1991 ColumnVector hcv (args(0).vector_value ());
1992
1993 if (! error_state)
1994 {
1995 octave_idx_type len = hcv.length ();
1996
1997 vlist.resize (len);
1998
1999 for (octave_idx_type n = 0; n < len; n++)
2000 {
2001 graphics_object obj = gh_manager::get_object (hcv(n));
2002
2003 if (obj)
2004 vlist(n) = obj.get (true);
2005 else
2006 {
2007 error ("get: invalid handle (= %g)", hcv(n));
2008 break;
2009 }
2010 }
2011 }
2012 else
2013 error ("get: expecting graphics handle as first argument");
2014 }
2015 else
2016 print_usage ();
2017
2018 if (! error_state)
2019 {
2020 octave_idx_type len = vlist.length ();
2021
2022 if (len > 1)
2023 retval = Cell (vlist);
2024 else if (len == 1)
2025 retval = vlist(0);
2026 }
2027
2028 return retval;
2029 }
2030
1973 static octave_value 2031 static octave_value
1974 make_graphics_object (const std::string& go_name, 2032 make_graphics_object (const std::string& go_name,
1975 const octave_value_list& args) 2033 const octave_value_list& args)
1976 { 2034 {
1977 octave_value retval; 2035 octave_value retval;