[new function/changeset] thought/request for ishandle()
Ben Abbott
bpabbott at mac.com
Tue Oct 14 07:05:52 CDT 2008
On Oct 14, 2008, at 3:50 AM, Michael Goffioul wrote:
> On Tue, Oct 14, 2008 at 4:18 AM, Ben Abbott <bpabbott at mac.com> wrote:
>> Please consider the attached changeset for the new function
>> ishandle_with_props().
>>
>> ishandle_with_prop (h, "prop1", value1, "prop2", value2, ...)
>>
>> My intent is that it be used to verify axes handles. I'm prepared
>> to apply
>> it to the existing m-files provided it is accepted. The files I've
>> identified as the present are: axes.m , cla.m, colorbar.m, comet.m,
>> hold.m,
>> plotmatrix.m, plotyy.m, & colorbar.m.
>>
>> With the exception of colorbar() which looks for an image handle,
>> the others
>> seek an axes handle. In the case of plotyy looking for an axes
>> handle with a
>> specific "position" would be useful.
>
> Isn't this redundant with findobj using 'flat' argument?
>
> Basically
> ishandle_with_prop (h, "prop1", value1, "prop2", value2, ...)
> is the same as
> ishandle(h) && findobj(h, "flat", "prop1", value1, "prop2",
> value2, ...)
>
> Michael.
If "h" is a vector, then things get a bit more complicated. However,
using findobj certainly has advantages over what I had done.
For scalar "h"
props = { "prop1", value1, "prop2", value2, ... }
ishandle(h) && findobj(h, "flat", props{:}) == h
For vector "h"
ishandle(h) & ismember (h, findobj (h,"flat", props{:}));
Which would reduce my function to the trivial ...
function [ ret ] = ishandle_with_props (h, varargin)
ret = (ishandle (h) & ismember (h, findobj (h, "flat",
varargin{:})));
endfunction
The isfigure() and ishghandle() functions are quite similar. I like
those as they make the m-file if-blocks easier to read. For that
reason I was looking for a similar funcition for axes, but wanted to
include additional information, and decided to try to float a version
of ishande() with properties specified.
In any event, would an isaxes() is a better choice?
Ben
More information about the Octave-maintainers
mailing list