comparison src/graphics.cc @ 6732:4ba39e63b005

[project @ 2007-06-15 18:07:29 by jwe]
author jwe
date Fri, 15 Jun 2007 18:07:29 +0000
parents 3d1e0a056e6e
children d6e615183a80
comparison
equal deleted inserted replaced
6731:aff0c76321aa 6732:4ba39e63b005
2130 } 2130 }
2131 2131
2132 DEFUN (set, args, , 2132 DEFUN (set, args, ,
2133 "-*- texinfo -*-\n\ 2133 "-*- texinfo -*-\n\
2134 @deftypefn {Built-in Function} {} set (@var{h}, @var{p}, @var{v}, @dots{})\n\ 2134 @deftypefn {Built-in Function} {} set (@var{h}, @var{p}, @var{v}, @dots{})\n\
2135 Set the named property @var{p} to the value @var{v} in the graphics\n\ 2135 Set the named property value or vector @var{p} to the value @var{v}\n\
2136 handle @var{h}.\n\ 2136 in the graphics handle @var{h}.\n\
2137 @end deftypefn") 2137 @end deftypefn")
2138 { 2138 {
2139 octave_value retval; 2139 octave_value retval;
2140 2140
2141 int nargin = args.length (); 2141 int nargin = args.length ();
2142 2142
2143 if (nargin > 0) 2143 if (nargin > 0)
2144 { 2144 {
2145 double handle = args(0).double_value (); 2145 ColumnVector hcv (args(0).vector_value ());
2146 2146
2147 if (! error_state) 2147 if (! error_state)
2148 { 2148 {
2149 graphics_object obj = gh_manager::get_object (handle); 2149 for (octave_idx_type n = 0; n < hcv.length (); n++)
2150 2150 {
2151 if (obj) 2151 graphics_object obj = gh_manager::get_object (hcv(n));
2152 { 2152
2153 obj.set (args.splice (0, 1)); 2153 if (obj)
2154 2154 {
2155 feval ("__request_drawnow__"); 2155 obj.set (args.splice (0, 1));
2156 } 2156
2157 else 2157 feval ("__request_drawnow__");
2158 error ("set: invalid handle (= %g)", handle); 2158 }
2159 } 2159 else
2160 error ("set: invalid handle (= %g)", hcv(n));
2161 }
2162 }
2160 else 2163 else
2161 error ("set: expecting graphics handle as first argument"); 2164 error ("set: expecting graphics handle as first argument");
2162 } 2165 }
2163 else 2166 else
2164 print_usage (); 2167 print_usage ();
2165 2168
2166 return retval; 2169 return retval;
2169 DEFUN (get, args, , 2172 DEFUN (get, args, ,
2170 "-*- texinfo -*-\n\ 2173 "-*- texinfo -*-\n\
2171 @deftypefn {Built-in Function} {} get (@var{h}, @var{p})\n\ 2174 @deftypefn {Built-in Function} {} get (@var{h}, @var{p})\n\
2172 Return the named property @var{p} from the graphics handle @var{h}.\n\ 2175 Return the named property @var{p} from the graphics handle @var{h}.\n\
2173 If @var{p} is omitted, return the complete property list for @var{h}.\n\ 2176 If @var{p} is omitted, return the complete property list for @var{h}.\n\
2177 If @var{h} is a vector, return a cell array including the property\n\
2178 values or lists respectively.\n\
2174 @end deftypefn") 2179 @end deftypefn")
2175 { 2180 {
2176 octave_value retval; 2181 octave_value retval;
2182 octave_value_list vlist;
2177 2183
2178 int nargin = args.length (); 2184 int nargin = args.length ();
2179 2185
2180 if (nargin == 1 || nargin == 2) 2186 if (nargin == 1 || nargin == 2)
2181 { 2187 {
2182 double handle = args(0).double_value (); 2188 ColumnVector hcv (args(0).vector_value ());
2183 2189
2184 if (! error_state) 2190 if (! error_state)
2185 { 2191 {
2186 graphics_object obj = gh_manager::get_object (handle); 2192 for (octave_idx_type n = 0; n < hcv.length (); n++)
2187 2193 {
2188 if (obj) 2194 graphics_object obj = gh_manager::get_object (hcv(n));
2189 { 2195
2190 if (nargin == 1) 2196 if (obj)
2191 retval = obj.get (); 2197 {
2192 else 2198 if (nargin == 1)
2193 { 2199 vlist(n) = obj.get ();
2194 property_name property = args(1).string_value (); 2200 else
2195 2201 {
2196 if (! error_state) 2202 property_name property = args(1).string_value ();
2197 retval = obj.get (property); 2203
2198 else 2204 if (! error_state)
2199 error ("get: expecting property name as second argument"); 2205 vlist(n) = obj.get (property);
2200 } 2206 else
2201 } 2207 error ("get: expecting property name as second argument");
2202 else 2208 }
2203 error ("get: invalid handle (= %g)", handle); 2209 }
2204 } 2210 else
2211 error ("get: invalid handle (= %g)", hcv(n));
2212 }
2213 }
2205 else 2214 else
2206 error ("get: expecting graphics handle as first argument"); 2215 error ("get: expecting graphics handle as first argument");
2207 } 2216 }
2208 else 2217 else
2209 print_usage (); 2218 print_usage ();
2219
2220 if (vlist.length () > 1)
2221 {
2222 Cell c(vlist);
2223 retval = c;
2224 }
2225 else
2226 retval = vlist(0);
2210 2227
2211 return retval; 2228 return retval;
2212 } 2229 }
2213 2230
2214 static octave_value 2231 static octave_value
2215 make_graphics_object (const std::string& go_name, 2232 make_graphics_object (const std::string& go_name,
2216 const octave_value_list& args) 2233 const octave_value_list& args)
2217 { 2234 {
2218 octave_value retval; 2235 octave_value retval;
2219 2236
2220 double val = args(0).double_value (); 2237 double val = args(0).double_value ();
2221 2238