comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » Re: How to find if an object contains another
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Switch to threaded view of this topic Create a new topic Submit Reply
Re: How to find if an object contains another [message #22138] Thu, 19 October 2000 00:00
Ben Tupper is currently offline  Ben Tupper
Messages: 186
Registered: August 1999
Senior Member
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
Re: How to find if an object contains another [message #22144 is a reply to message #22138] Thu, 19 October 2000 00:00 Go to previous message
promashkin is currently offline  promashkin
Messages: 169
Registered: December 1999
Senior Member
I would try

if obj_valid((model->get(/all,isa='idlgrsurface'))[0]) then $
print,'Has one or more surface' $
else $
print,'Has no surfaces'

or, better yet, because it provides a useful list as the result:

surf_list = model->get(/all,isa='idlgrsurface', count=n_surfs)
if n_surfs gt 0 then .....

Same thing about finding out if GetbyName returned a valid object.
Cheers,
Pavel

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
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: HDF File Label and Description
Next Topic: Problems Compiling Projects

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Wed Oct 08 13:53:22 PDT 2025

Total time taken to generate the page: 0.00544 seconds