How to get all graphics elements in a Window? [message #94412] |
Fri, 12 May 2017 13:45  |
Ayris Narock
Messages: 2 Registered: May 2017
|
Junior Member |
|
|
Hi,
I feel like this should be a simple question but I simply can not find any documentation. It seems like this functionality should exist . . . I hope someone can help.
After using the Plot() or Window() functions I can get a reference to the window (help lists it as a <GRAPHICSWIN>)
I can access the graphics elements contained within if I already know their names using bracket notation, like so:
--------------
x = Findgen(200)
y = Sin(x*2*!PI/25.0)*Exp(-0.01*x)
y2 = Cos(x*2*!PI/25.0)*Exp(-0.01*x)
p = PLOT(x, y, TITLE='PanHandler Test',name="name1")
p2 = PLOT(x,y2, name="name2",OVERPLOT=p)
w = GetWindows(/CURRENT)
p1 = w['name1']
p2 = w['name2']
p1.Select
p2.Select
---------------
But, if I don't already know 'name1' and 'name2', and just have the reference to the window, w, how can I retrieve a reference to all the graphics contained in w?
Thanks,
Ayris
|
|
|
Re: How to get all graphics elements in a Window? [message #94413 is a reply to message #94412] |
Sat, 13 May 2017 06:33   |
Markus Schmassmann
Messages: 129 Registered: April 2016
|
Senior Member |
|
|
Am 12.05.2017 um 22:45 schrieb Ayris Narock:
> I feel like this should be a simple question but I simply can not find any documentation. It seems like this functionality should exist . . . I hope someone can help.
>
> After using the Plot() or Window() functions I can get a reference to the window (help lists it as a <GRAPHICSWIN>)
>
> I can access the graphics elements contained within if I already know their names using bracket notation, like so:
>
> --------------
> x = Findgen(200)
> y = Sin(x*2*!PI/25.0)*Exp(-0.01*x)
> y2 = Cos(x*2*!PI/25.0)*Exp(-0.01*x)
> p = PLOT(x, y, TITLE='PanHandler Test',name="name1")
> p2 = PLOT(x,y2, name="name2",OVERPLOT=p)
>
> w = GetWindows(/CURRENT)
> p1 = w['name1']
> p2 = w['name2']
> p1.Select
> p2.Select
> ---------------
>
> But, if I don't already know 'name1' and 'name2', and just have the reference to the window, w, how can I retrieve a reference to all the graphics contained in w?
if you know one of the graphic elements names or have it's handle, you
can get all, by
p.Select, /all
pp=w.getSelect()
otherwise use
pp=w.HitTest(w.dimensions[0]/2,w.dimensions[1]/2, $
dimensions=w.dimensions)
but this will give you more, incl. some axes, you will then have to
filter out what you want.
Markus
|
|
|
|