Re: Has USERSYM been defined? [message #29591 is a reply to message #29586] |
Tue, 05 March 2002 13:26   |
Liam E. Gumley
Messages: 378 Registered: January 2000
|
Senior Member |
|
|
Mark Hadfield wrote:
> "David Fanning" <david@dfanning.com> wrote in message
> news:MPG.16eebb31cf80510798982f@news.frii.com...
>> Wayne Landsman (landsman@mpb.gsfc.nasa.gov) writes:
>>
>>> Is there any way to determine if a user-defined plotting symbol has
>>> been created using USERSYM for plotting with PSYM=8? (I suppose it
>>> might also be nice if one could determine what the user-defined
>>> symbol actually is, i.e. fetch the X,Y vectors that were input to
>>> USERSYM, but I don't need that now.)
>>>
>
>>> I want to have my plotting program use the current USERSYM
>>> definition for PSYM=8 if it exists, but to create a default symbol
>>> if no current USERSYM definition exists.
>>
>
>> My impression is that the whole USERSYM business is a hold-over from
>> the way graphics were done in the 70's.
>
> Indeed.
>
>> I'd bet a lot of money the answer is "no". (Or, even more likely,
>> "hell no".)
>
> How much money, David?
>
> How about plotting a test dataset inside a CATCH handler and trapping
> the error? Attempting to display a user symbol that is not yet defined
> results (in IDL 5.5) in an error with name 'IDL_M_PLOT_NOUSERSYM'
The following function returns 1B (true) if the argument (a symbol
number) can be plotted, and 0B otherwise:
FUNCTION SYMBOL_DEFINED, PSYM
current_device = !d.name
catch, status
if (status ne 0) then begin
set_plot, current_device
return, 0B
endif
set_plot, 'NULL'
plots, 0, 0, psym=psym, /device
set_plot, current_device
return, 1B
END
IDL> print, symbol_defined(7)
1
IDL> print, symbol_defined(8)
0
IDL> x = [-6, 0, 6, 0, -6]
IDL> y = [0, 6, 0, -6, 0]
IDL> usersym, x, y
IDL> print, symbol_defined(8)
1
Cheers,
Liam.
Practical IDL Programming
http://www.gumley.com/
|
|
|