[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: How to find if an object contains another



Hello,

I encourage you to look into using Martin Schultz's MGS_CONTAINER
replacement for IDL_CONTAINER.  (Follow the links form David Fanning's  web
page to get to Martin's site.)  Any objects with a NAME property (accessible
via the objects GETPROPERTY method) can be retrieved by name, a name that
you can specify.  I'm not sure that all of the RSI provided objects have a
NAME property (the TrackBall object comes to mind, but there may be
others.)  Any of the home-grown variety may or may not have the NAME
property, depending upon the author's decision to build it in to the object.

The ability to retrieve by the user's NAME of the object has great
advantages in many places.   You can see how it might be valubale if you
have two objects of the same class in the container, but only want one of
them.  Unless, you remember the position in which they are stored in the
container you'll be up the creek figuring out which one is which.... well,
you get the idea.

Concerning the validity of an object, you also have access to the OBJ_VALID
and OBJ_CLASS functions as well as the COUNT keyword to the container GET
method.  Each of these will tell you something about the object you
retrieved (or didn't retrieve, as the case may be.)

Hope this helps,

Ben

Dave Greenwood wrote:

> How do I determine if an object "contains" another one?
>
> For example, I can create a model object and add a surface object or
> a plot object.  Given that model object, how would I find out whether
> or not a surface object has been added?
>
> The best I've come up with is something like:
>
>   xx = model->get(/all,isa='idlgrsurface')
>   s = size(xx)
>   if s[1] eq 11 then $
>        print,'Has one or more surface' $
>   else $
>        print,'Has no surfaces'
>
> Surely there's a simpler way?
>
> A related question is: how do I test if an object pointer (returned by
> the GetByName method, for example) is null?
>
> Thanks,
> Dave
> --------------
> Dave Greenwood                Email: Greenwoodde@ORNL.GOV
> Oak Ridge National Lab        %STD-W-DISCLAIMER, I only speak for myself

--
Ben Tupper
248 Lower Round Pond Road
POB 106
Bristol, ME 04539

Tel: (207) 563-1048
Email: PemaquidRiver@tidewater.net