Re: Recovering Object Oriented References [message #94225 is a reply to message #94224] |
Wed, 01 March 2017 19:40  |
Jim Pendleton
Messages: 165 Registered: November 2011
|
Senior Member |
|
|
On Wednesday, March 1, 2017 at 6:55:29 PM UTC-7, Dave Schlossberg wrote:
> I have a routine that creates a window object using "p1 = Plot(x,y)" or similar.
>
> The program finishes executing, and now I have a window that persists. But I have no idea how to access it since p1 is not a global variable!
>
> Is there some way to query the current window for the reference, or to create a new reference for it?
> I suppose I could make p1 global, but this seems like a much more generic, general question.
>
> Thanks in advance,
> Dave
>
> p.s. I'm new to Object Oriented programming, but not to IDL. Used IDL extensively ~12 years ago for a while, then hiatus (grad school). Sorry if this is a noob question!
Welcome back to IDL. Lots of new language features since you were last here.
The simplest technique may be to apply a unique NAME property to each graphic you want to access later, but don't want to cache yourself.
Here's a quick example, uniquely naming the plot graphic "myplot".
IDL> .reset
IDL> p = plot(/test, name = 'myplot')
IDL> help, p
P PLOT <5168>
IDL> p = 0 ; "lose" the reference
IDL> w = getwindows(/current)
IDL> help, w
W GRAPHICSWIN <1812>
IDL> p = w['myplot']
IDL> help, p
P PLOT <5168>
For an example in the context of a widget application, see
http://www.harrisgeospatial.com/docs/IncludeGraphicInApp.htm l
Jim P.
|
|
|