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

Home » Public Forums » archive » Re: How to erase a (function graphics) plot.
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Return to the default flat view Create a new topic Submit Reply
Re: How to erase a (function graphics) plot. [message #88544 is a reply to message #88543] Mon, 12 May 2014 03:13 Go to previous messageGo to previous message
andeh is currently offline  andeh
Messages: 23
Registered: April 2011
Junior Member
On Monday, 12 May 2014 02:19:10 UTC+1, Chris Torrence wrote:
>>
>
>> Did this happen? I don't see it in 8.3.
>
>>
>
>>
>
>>
>
>> An erase method would be very useful. I find that when I rerun a script that greats a (function graphics) plot it always creates a new window, which steals the focus (and pops up the new window in the wrong place). This drives me crazy. It would be much better if I could erase the old one and reuse the same window. Then my window layout would stay put and focus would stay in the editing window.
>
>>
>
>>
>
>>
>
>> Am I missing something?
>
>>
>
>>
>
>>
>
>> Bob
>
>
>
> Yep...
>
>
>
> http://www.exelisvis.com/docs/Erase_Method.html
>
>
>
> Looks like it got missed in the docs for each graphics function, but it's there!
>
> -Chris



I have a function that works most of the time to deal with this. You pass it to the CURRENT keyword in your fg plotting command.



;+
; NAME:
; current = FG_CURRENT( id )
;
;
; PURPOSE:
; Clear an object graphics window if it exists, so that re-running
; code doesn't created another set of plots in a new window. The
; function is designed to be passed directly to a plotting command
; via the CURRENT keyword.
;
; INPUT:
; id: Object reference for a function graphics plot.
;
;
; OUTPUT:
; Flag to be passed to plotting object. If the output is 1, then
; the object has been successfully cleared and selected so that
; the /CURRENT keyword should be correct.
;
;
; EXAMPLE USE:
;
; ;; Create the same plot twice.
; plot_object_0 = PLOT( [0,5] )
; plot_object_0 = PLOT( [5,0] )
;
; ;; Now use FG_CURRENT to clear instead of creating a new one.
; plot_object_1 = PLOT( [0,5], CURRENT=FG_CURRENT(plot_object_1) )
; plot_object_1 = PLOT( [5,0], CURRENT=FG_CURRENT(plot_object_1) )
;
;
;
; HISTORY:
; 17 FEB 2014 (AJAS) Created.
;
;-
FUNCTION FG_CURRENT, id

;; If there's an error, return current=0.
CATCH, Error_status
IF Error_status NE 0 THEN BEGIN
PRINT, 'FG_CURRENT: ', !ERROR_STATE.MSG
CATCH, /CANCEL
RETURN, 0b
ENDIF


;; Unless the current window is appropriately set,
;; we don't flag it.
current = 0b

;; Check that we are dealing with an object reference.
IF SIZE(/TYPE,id) EQ 11 THEN BEGIN

HELP, id, OUTPUT=help_id

;; If it looks like a plot, then erase the contents and select.
;; This is not an exhaustive check.
IF (STRSPLIT(/EXTRACT,help_id))[1] NE 'OBJREF' THEN BEGIN
wid = id.WINDOW
wid.ERASE
wid.SELECT
current = 1b
ENDIF

ENDIF


RETURN, current
END
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Problem with IDLnetURL Callback Function
Next Topic: how to shade region of 2-D plot

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

Current Time: Wed Oct 08 18:06:59 PDT 2025

Total time taken to generate the page: 0.00517 seconds