| Re: Getting the current color table [message #36928] |
Fri, 14 November 2003 13:21 |
JD Smith
Messages: 850 Registered: December 1999
|
Senior Member |
|
|
On Wed, 12 Nov 2003 05:05:22 -0700, David Fanning wrote:
> df23775@hotmail.com writes:
>
>> Is there a way that I (in the case, the program) can know which is the
>> current color table?
>>
>> The program provides the function XLOADCT in which the user can change
>> the color table. And I would like to know which one is in use. I have a
>> feeling that that has to be somewhere, :). I tried to see if there is
>> any parameter in XLOADCT and LOACT that provides me the number of the
>> color table in the use. I believe that information is somewhere, but
>> where? I looked also in the graphics system variables but I don't find
>> it. Seems to have everything but the index of the color table in use.
>
> The color changing program XCOLORS can do this. But, in general, there
> is no way to tell the index of the color table in use. The best XCOLORS
> can do is tell you the index of the color table it last loaded. :-)
>
> http://www.dfanning.com/programs/xcolors.pro
>
> Cheers,
>
> David
I use a little program like this:
;; load with loadct, but set the !ctabl system variable too. pro
cu_loadct, table_number, NO_RESET=nr, _REF_EXTRA=e
cu_ctdef
if keyword_set(nr) then table_number=!ctabl.cmap if
n_elements(table_number) ne 0 then begin
loadct,table_number,_EXTRA=e
!ctabl.cmap=table_number
if NOT keyword_set(nr) then begin
!ctabl.high=1.
!ctabl.low=0.
!ctabl.gamma=1.
endif
endif else loadct,_EXTRA=e
end
with
pro cu_ctdef,_EXTRA=e
defsysv,'!ctabl',Exists=exi
if exi eq 1 then return
defsysv,'!ctabl',{!ctabl,cmap:0,low:0.,high:1.,gamma:1.0}
end
Notice I also save the low and high stretch, and the gamma value. This
facilitates keeping the same color tables between instances of an
application, but if any program uses its own regular loadct call, !ctabl
will be wrong.
JD
|
|
|
|
| Re: Getting the current color table [message #36964 is a reply to message #36928] |
Wed, 12 November 2003 06:52  |
R.Bauer
Messages: 1424 Registered: November 1998
|
Senior Member |
|
|
Nuno Oliveira wrote:
> Hi, perhaps you can help me here.
>
>
>
> Is there a way that I (in the case, the program) can know which is the
> current color table?
>
>
Dear Nuno
I don't know if there is a systemvar where the table number ist stored. I
believe it isn't stored.
I will do a feature request about this. You should do this too.
xloadct calls loadct. loadct is a source file. My suggestion is to alter
this routine by adding a systemvariable which gets the table_number.
DEFSYSV, '!color_table_number', EXISTS = exist
IF exist THEN !color_table_number=table_number else $
DEFSYSV, '!color_table_number',table_number
Later on rsi could add a parameter to the !D or !P sysvars.
Be carefull with changes of build in idl routines. Normally I would suggest
to rename it but in this case xloadct won't call the changed one.
regards
Reimar
>
> The program provides the function XLOADCT in which the user can change the
> color table. And I would like to know which one is in use. I have a
> feeling that that has to be somewhere, :). I tried to see if there is any
> parameter in XLOADCT and LOACT that provides me the number of the color
> table in the use. I believe that information is somewhere, but where? I
> looked also in the graphics system variables but I don't find it. Seems to
> have everything but the index of the color table in use.
>
>
>
>
>
> Cheers, N.
--
Forschungszentrum Juelich
email: R.Bauer@fz-juelich.de
http://www.fz-juelich.de/icg/icg-i/
============================================================ ======
a IDL library at ForschungsZentrum Juelich
http://www.fz-juelich.de/icg/icg-i/idl_icglib/idl_lib_intro. html
|
|
|
|
| Re: Getting the current color table [message #36966 is a reply to message #36964] |
Wed, 12 November 2003 04:05  |
David Fanning
Messages: 11724 Registered: August 2001
|
Senior Member |
|
|
df23775@hotmail.com writes:
> Is there a way that I (in the case, the program) can know which is the
> current color table?
>
> The program provides the function XLOADCT in which the user can change the
> color table. And I would like to know which one is in use. I have a feeling
> that that has to be somewhere, :). I tried to see if there is any parameter
> in XLOADCT and LOACT that provides me the number of the color table in the
> use. I believe that information is somewhere, but where? I looked also in
> the graphics system variables but I don't find it. Seems to have everything
> but the index of the color table in use.
The color changing program XCOLORS can do this. But, in general,
there is no way to tell the index of the color table in use.
The best XCOLORS can do is tell you the index of the color table
it last loaded. :-)
http://www.dfanning.com/programs/xcolors.pro
Cheers,
David
--
David W. Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http:/www.dfanning.com/
Phone: 970-221-0438, IDL Book Orders: 1-888-461-0155
|
|
|
|