source: trunk/SRC/Colors/xlct.pro @ 231

Last change on this file since 231 was 231, checked in by pinsard, 17 years ago

improvements/corrections of some *.pro headers

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 19.9 KB
Line 
1;+
2; @hidden
3;-
4;
5PRO xlct_psave                  ;Save/Restore our plotting state.
6;  Swaps our state with the current state each time its called.
7;
8  compile_opt idl2, strictarrsubs
9;
10
11COMMON xlct_com, r0, g0, b0, tfun, state, filename, cps, psave, pnt, $
12        top, bot, silent, chop, lock, g_lbl, vbot, vtop, g_slider, $
13        gamma, color, use_values, ncolors, cbot, siz, w_height, show_win, $
14        updt_callback, updt_cb_data
15
16tmp = { xlct_psave, win: !d.window, x: !x.s, y: !y.s , xtype: !x.type, $
17                         ytype: !y.type, clip: !p.clip }
18
19wset, psave.win
20!x.type = psave.xtype
21!y.type = psave.ytype
22!x.s = psave.x
23!y.s = psave.y
24!p.clip = psave.clip
25psave = tmp
26end
27
28;+
29; @hidden
30;-
31pro xlct_alert_caller
32;
33  compile_opt idl2, strictarrsubs
34;
35COMMON xlct_com, r0, g0, b0, tfun, state, filename, cps, psave, pnt, $
36        top, bot, silent, chop, lock, g_lbl, vbot, vtop, g_slider, $
37        gamma, color, use_values, ncolors, cbot, siz, w_height, show_win, $
38        updt_callback, p_updt_cb_data
39
40    ErrorStatus = 0
41    CATCH, ErrorStatus
42    if (ErrorStatus NE 0) then begin
43        CATCH, /CANCEL
44        v = DIALOG_MESSAGE(['Unexpected error in XLCT:', $
45                        '!ERR_STRING = ' + !ERR_STRING], $
46                        /ERROR)
47        return
48    endif
49    if (STRLEN(updt_callback) gt 0) then begin
50        if (PTR_VALID(p_updt_cb_data)) then begin
51            CALL_PROCEDURE, updt_callback, DATA=*(p_updt_cb_data)
52        endif else begin
53            CALL_PROCEDURE, updt_callback
54        endelse
55    endif
56end
57
58
59; Redraw the ramp image.
60;+
61; @hidden
62;-
63PRO xlct_show
64;
65  compile_opt idl2, strictarrsubs
66;
67COMMON xlct_com, r0, g0, b0, tfun, state, filename, cps, psave, pnt, $
68        top, bot, silent, chop, lock, g_lbl, vbot, vtop, g_slider, $
69        gamma, color, use_values, ncolors, cbot, siz, w_height, show_win, $
70        updt_callback, p_updt_cb_data
71
72    cur_win = !D.WINDOW
73    WSET, show_win
74    TV, BYTE((FLOAT(ncolors)*FINDGEN(siz)/FLOAT(siz-1)) # $
75        REPLICATE(1, w_height)) + BYTE(cbot)
76
77    WSET, cur_win
78
79    ; Let the caller of XLCT know that the color table was modified
80    xlct_alert_caller
81END
82
83;+
84; @hidden
85; @param i
86; ???
87; @param c
88; ???
89;-
90PRO xlct_draw_cps, i, c
91;
92  compile_opt idl2, strictarrsubs
93;
94COMMON colors, r_orig, g_orig, b_orig, r_curr, g_curr, b_curr
95COMMON xlct_com, r0, g0, b0, tfun, state, filename, cps, psave, pnt, $
96        top, bot, silent, chop, lock, g_lbl, vbot, vtop, g_slider, $
97        gamma, color, use_values, ncolors, cbot
98
99tc = color
100if n_elements(c) gt 0 then begin
101        tc = c
102        if c ne 0 then color = c
103        endif
104
105if i[0] eq -1 then j = indgen(n_elements(cps)) else j = i
106
107plots, cps[j], tfun[j], /noclip, color = tc
108plots, cps[j], tfun[j], /noclip, psym=6, color = tc
109end
110
111;+
112; @hidden
113; @keyword UPDATE
114; ???
115;-
116PRO xlct_transfer, UPDATE=update
117;
118  compile_opt idl2, strictarrsubs
119;
120COMMON colors, r_orig, g_orig, b_orig, r_curr, g_curr, b_curr
121COMMON xlct_com, r0, g0, b0, tfun, state, filename, cps, psave, pnt, $
122        top, bot, silent, chop, lock, g_lbl, vbot, vtop, g_slider, $
123        gamma, color, use_values, ncolors, cbot
124
125l = lonarr(ncolors)             ;Subscripts
126m = n_elements(cps)
127for i=0, m-2 do begin
128        n = cps[i+1]-cps[i]             ;Interval
129        b = (tfun[i+1]-tfun[i])/float(n)
130        l[cps[i]] = findgen(n) * b + (tfun[i] + cbot)
131        endfor
132l[ncolors-1] = tfun[m-1]                ;Last point
133if use_values then begin
134  r_curr[cbot] = (r = l[r_orig])
135  g_curr[cbot] = (g = l[g_orig])
136  b_curr[cbot] = (b = l[b_orig])
137endif else begin
138  r_curr[cbot] = (r = r_orig[l])
139  g_curr[cbot] = (g = g_orig[l])
140  b_curr[cbot] = (b = b_orig[l])
141endelse
142
143tvlct, r,g,b, cbot
144if (keyword_set( update )) then $
145  xlct_show
146end
147
148;+
149; @hidden
150; @param event
151; ???
152;-
153PRO xlct_event, event
154;
155  compile_opt idl2, strictarrsubs
156;
157COMMON colors, r_orig, g_orig, b_orig, r_curr, g_curr, b_curr
158COMMON xlct_com, r0, g0, b0, tfun, state, filename, cps, psave, pnt, $
159        top, bot, silent, chop, lock, g_lbl, vbot, vtop, g_slider, $
160        gamma, color, use_values, ncolors, cbot, siz, w_height, show_win, $
161        updt_callback, p_updt_cb_data
162
163
164IF event.id eq state.draw THEN BEGIN    ;** PROCESS DRAWABLE EVENTS **
165        if event.press ne 0 then begin          ;Pressed button?
166                dmin = 1.0e8            ;Find closest control pnt
167                xlct_psave              ;Remove old
168                p = convert_coord(event.x, event.y, /TO_DATA, /DEVICE)
169                xlct_psave              ;Restore old
170                x = fix(p[0])
171                y = fix(p[1])
172                for i=0, n_elements(cps)-1 do begin
173                        d = (p[0]-cps[i])^2 + (p[1]-tfun[i])^2  ; dist ^ 2
174                        if d lt dmin then begin
175                                dmin = d
176                                pnt = i
177                                endif
178                        endfor
179                return
180                endif
181        if event.release ne 0 then begin        ;Released button?
182                pnt = -1
183                xlct_transfer, /update
184                return
185                endif
186        if pnt lt 0 then return                 ;Don't care here...
187
188        xlct_psave                              ;Remove old
189        ; For visuals with static colormaps, erase plot before drawing new
190        if ((COLORMAP_APPLICABLE(redrawRequired) GT 0) and $
191            (redrawRequired GT 0)) then begin
192           ERASE, color=0
193        endif
194        p = convert_coord(event.x, event.y, /TO_DATA, /DEVICE)  ;Coord of mouse
195        n = ncolors -1          ;Into range....
196        m = n_elements(cps)-1
197        x = fix(p[0]) > 0 < n
198        if pnt eq 0 then x = 0 else $           ;1st & last are fixed
199        if pnt eq m then x = n else $
200        x = x > (cps[pnt-1] + 1) < (cps[pnt+1]-1)  ;Others must be between
201
202        if pnt eq 0 then xlct_draw_cps, [0, 1],0 $  ;Erase old segment
203        else if pnt eq m then xlct_draw_cps, [m-1, m],0 $
204        else xlct_draw_cps, [pnt-1, pnt, pnt+1],0
205        cps[pnt] = x
206        tfun[pnt] = fix(p[1]) > 0 < n
207        xlct_transfer
208
209        b = r_curr * .3 + g_curr * .586 + b_curr * .114 ;Ntsc colors
210        c = max(abs(b-b[cbot]), j)  ; *** J is color index furthest from 0
211
212        if pnt eq 0 then xlct_draw_cps, [0, 1], j $
213        else if pnt eq m then xlct_draw_cps, [m-1, m], j $
214        else xlct_draw_cps, [pnt-1, pnt, pnt+1], j
215
216        xlct_psave              ;Remove old
217        return
218        ENDIF
219
220WIDGET_CONTROL, event.id, GET_UVALUE = eventval
221
222abstop = NCOLORS -1
223
224if event.id eq state.name_list then begin
225        LOADCT, silent=silent, event.index, FILE=filename, NCOLORS=ncolors, $
226                BOTTOM=cbot
227        goto, set_gamma
228        ENDIF
229
230CASE eventval OF
231    "TOP":    BEGIN
232                WIDGET_CONTROL, top, GET_VALUE = vtop
233                if lock ne 0 then begin
234                        vbot = (vtop - lock) > 0 < 100
235                        widget_control, bot, SET_VALUE=vbot
236                        endif
237                GOTO, set_gamma
238              END
239
240    "BOTTOM": BEGIN
241                WIDGET_CONTROL, bot, GET_value = vbot
242                if lock ne 0 then begin
243                        vtop = (vbot + lock) > 0 < 100
244                        widget_control, top, SET_VALUE=vtop
245                        ENDIF
246   set_gamma:
247        if use_values then nc = 256 else nc = ncolors
248        s = (nc-1)/100.
249        x0 = vbot * s
250        x1 = vtop * s
251        if x0 ne x1 then s = (nc-1.0)/(x1 - x0) else s = 1.0
252        int = -s * x0
253        if gamma eq 1.0 then s = round(findgen(nc) * s + int > 0.0) $
254        else s = ((findgen(nc) * (s/nc) + (int/nc) > 0.0) ^ gamma) * nc
255        if chop ne 0 then begin
256            too_high = where(s ge nc, n)
257            if n gt 0 then s[too_high] = 0L
258            endif
259        if use_values then begin
260            s = s < 255L
261            l = lindgen(ncolors) + cbot
262            r_curr[cbot] = (r = s[r_orig[l]])
263            g_curr[cbot] = (g = s[g_orig[l]])
264            b_curr[cbot] = (b = s[b_orig[l]])
265        endif else begin
266            s = s + cbot
267            r_curr[cbot] = (r = r_orig[s])
268            g_curr[cbot] = (g = g_orig[s])
269            b_curr[cbot] = (b = b_orig[s])
270        endelse
271        tvlct, r,g,b, cbot
272        xlct_show
273        ENDCASE
274
275    "GAMMA": BEGIN
276                WIDGET_CONTROL, g_slider, GET_VALUE = gamma
277                gamma = 10^((gamma/50.) - 1)
278                WIDGET_CONTROL, g_lbl, SET_VALUE = $
279                        STRING(gamma, format='(f6.3)')
280                goto, set_gamma
281             ENDCASE
282
283    "GANG" : IF event.value eq 0 then lock = 0 else lock = vtop - vbot
284
285    "CHOP" : BEGIN
286        chop = event.value
287        goto, set_gamma         ;And redraw
288        ENDCASE
289
290    "VALUES": BEGIN
291        use_values = event.value
292        ENDCASE
293
294    "HELP" : XDisplayFile, FILEPATH("xlct.txt", subdir=['help', 'widget']), $
295                TITLE = "Xlct Help", $
296                GROUP = event.top, $
297                WIDTH = 55, $
298                HEIGHT = 16
299
300    "RESTORE" : BEGIN                   ;Restore the original tables
301        r_curr = (r_orig = r0)
302        g_curr = (g_orig = g0)
303        b_curr = (b_orig = b0)
304        tvlct, r_curr, g_curr, b_curr
305        xlct_show
306        ENDCASE
307
308    "OVERWRITE" : BEGIN                 ;overwrite original tables
309        r0 = (r_orig = r_curr)
310        g0 = (g_orig = g_curr)
311        b0 = (b_orig = b_curr)
312    reset_all:
313        WIDGET_CONTROL, top, SET_VALUE = 100
314        WIDGET_CONTROL, bot, SET_VALUE = 0
315        WIDGET_CONTROL, g_slider, SET_VALUE = 50
316        vbot = 0
317        vtop = 100
318        gamma = 1.0
319        GOTO, set_gamma
320        ENDCASE
321
322    "REVERSE" : BEGIN                   ;Reverse the table
323        l = lindgen(ncolors) + cbot
324        r_orig[cbot] = reverse(r_orig[l])
325        g_orig[cbot] = reverse(g_orig[l])
326        b_orig[cbot] = reverse(b_orig[l])
327        goto, set_gamma                 ;And redraw
328        ENDCASE
329
330    "DONE": BEGIN
331        WIDGET_CONTROL, event.top, /DESTROY
332        r0 = 0 & g0 = 0 & b0 = 0  ;Free common
333        if PTR_VALID(p_updt_cb_data) then PTR_FREE, p_updt_cb_data
334        ENDCASE
335
336    "NEWBASE": BEGIN
337        mode = event.value
338        b = ([0, 0, 1])[mode]           ;Top base to map: 0 or 1.
339        for i=0,1 do WIDGET_CONTROL, state.bases[i], MAP=i eq b
340        if b eq 0 then begin            ;table or option mode?
341           b = ([2,3,0])[mode]          ;bottom base to map (mode eq 0 or 1)
342           for i=2,3 do WIDGET_CONTROL, state.bases[i], MAP=i eq b
343           endif
344        if mode eq 2 then begin
345            reset_all = 1
346            xlct_psave                  ;Save old state
347            plot, [0, ncolors-1], [0, ncolors-1], xstyle=3, $
348                ystyle=3, xmargin = [1,1], ymargin=[1,1], ticklen = -0.03, $
349                /NODATA, $
350                xtickname = replicate(' ', 10), ytickname = replicate(' ', 10)
351            goto, interp_cps
352            endif
353       
354        ENDCASE
355
356    "TFUNR": BEGIN
357     reset_tfun:
358        xlct_psave
359        xlct_draw_cps, -1, 0    ;Erase all
360        tfun = cps              ;Linear ramp
361        goto, interp_cps
362        ENDCASE
363
364    "REMCP": BEGIN
365        n = n_elements(cps)
366        if n gt 2 then begin
367          xlct_psave
368          xlct_draw_cps, -1, 0
369          igap = 0
370          for i=0, n-2 do $
371                if (cps[i+1] - cps[i]) lt (cps[igap+1]-cps[igap]) then $
372                        igap = i
373          keep = where(indgen(n) ne (igap > 1))
374          cps = cps[keep]
375          tfun = tfun[keep]
376          goto, interp_cps
377          ENDIF
378        ENDCASE
379    "ADDCP": BEGIN
380        xlct_psave
381        xlct_draw_cps, -1, 0
382        igap = 0                        ;Find largest gap
383        for i=0, n_elements(cps)-2 do $
384                if (cps[i+1] - cps[i]) gt (cps[igap+1]-cps[igap]) then $
385                        igap = i
386        cps = [ cps[0:igap], (cps[igap]+cps[igap+1])/2, cps[igap+1:*]]
387        tfun = [ tfun[0:igap], (tfun[igap]+tfun[igap+1])/2, tfun[igap+1:*]]
388      interp_cps:  xlct_draw_cps, -1  ;Redraw new
389        xlct_transfer, /update
390        xlct_psave              ;Restore old points
391        if n_elements(reset_all) then goto, reset_all
392        ENDCASE
393ENDCASE
394
395END
396
397
398;+
399; @file_comments
400; Like xloadct but fastest to write and call by default the palette
401; palette.tbl which can be in any directory
402;
403; @categories
404; Widget, Color
405;
406; @keyword FILE {default='palette.tbl'}
407; If this keyword is set, the file by the given name is used
408; instead of the file colors1.tbl in the IDL directory.  This
409; allows multiple IDL users to have their own color table file.
410;
411; @keyword GROUP
412; The widget ID of the widget that calls Xlct. When  this ID is
413; specified, a death of the caller results in a death of Xlct
414
415; @keyword NCOLORS {default=!D.TABLE_SIZE = all available colors}
416; number of colors to use. Use color indexes from BOTTOM to the
417; smaller of !D.TABLE_SIZE-1 and NCOLORS-1.
418;
419; @keyword BOTTOM {default=0.}
420; first color index to use. Use color indexes from BOTTOM to
421; BOTTOM+NCOLORS-1.
422;
423; @keyword SILENT
424; Normally, no informational message is printed when a color map
425; is loaded. If this keyword is present and zero, this message is printed.
426;
427; @keyword USE_CURRENT
428; If set, use the current color tables, regardless of
429; the contents of the COMMON block COLORS.
430;
431; @keyword MODAL {default=not run in modal mode}
432; If set, then XLCT runs in "modal" mode, meaning that
433; all other widgets are blocked until the user quits XLCT.
434; A group leader must be specified (via the GROUP keyword)
435; for the MODAL keyword to have any effect.
436;
437; @keyword BLOCK
438; Set this keyword to have XMANAGER block when this
439; application is registered.  By default the Xmanager
440; keyword NO_BLOCK is set to 1 to provide access to the
441; command line if active command line processing is available.
442; Note that setting BLOCK for this application will cause
443; all widget applications to block, not only this
444; application.  For more information see the NO_BLOCK keyword
445; to XMANAGER.
446;
447; @keyword UPDATECALLBACK
448; Set this keyword to a string containing the name of
449; a user-supplied procedure that will be called when the color
450; table is updated by XLCT.  The procedure may optionally
451; accept a keyword called DATA, which will be automatically
452; set to the value specified by the optional UPDATECBDATA keyword.
453;
454; @keyword UPDATECBDATA
455; Set this keyword to a value of any type. It will be
456; passed via the DATA keyword to the user-supplied procedure
457; specified via the UPDATECALLBACK keyword, if any. If the
458; UPDATECBDATA keyword is not set the value accepted by the
459; DATA keyword to the procedure specified by UPDATECALLBACK
460; will be undefined.
461;
462; @history
463; 5/5/1999 copy of xloadct par Sebastien Masson (smasson\@lodyc.jussieu.fr)
464;
465; @version
466; $Id$
467;
468;-
469
470PRO xlct, SILENT=silent_f, GROUP=group, FILE=file, $
471          USE_CURRENT=use_current, NCOLORS = nc, BOTTOM=bottom, $
472          MODAL=modal, BLOCK=block, UPDATECALLBACK=updt_cb_name, $
473          UPDATECBDATA=updt_cb_data
474;
475  compile_opt idl2, strictarrsubs
476;
477
478   COMMON colors, r_orig, g_orig, b_orig, r_curr, g_curr, b_curr
479   COMMON xlct_com, r0, g0, b0, tfun, state, filename, cps, psave, pnt, $
480    top, bot, silent, chop, lock, g_lbl, vbot, vtop, g_slider, $
481    gamma, color, use_values, ncolors, cbot, siz, w_height, show_win, $
482    updt_callback, p_updt_cb_data
483
484
485   IF(XRegistered("xlct") NE 0) THEN return
486
487   IF N_ELEMENTS(block) EQ 0 THEN block=0
488   IF N_ELEMENTS(updt_cb_name) EQ 0 THEN updt_callback="" $
489   ELSE updt_callback=updt_cb_name
490   IF N_ELEMENTS(updt_cb_data) GT 0 THEN p_updt_cb_data=PTR_NEW(updt_cb_data) $
491   ELSE p_updt_cb_data=PTR_NEW()
492
493   values_button = lonarr(2)
494
495   IF KEYWORD_SET(SILENT_f) THEN silent = SILENT_F ELSE silent = 1
496;-----------------------------------------------------------------------------
497; Changes made by S.Masson
498;-----------------------------------------------------------------------------
499   IF N_ELEMENTS(file) GT 0 THEN filename = file ELSE BEGIN
500      filename = find('palette.tbl')
501      filename = filename[0]
502      if filename EQ 'NOT FOUND' then filename=filepath('colors1.tbl',subdir=['resource', 'colors'])
503   ENDELSE
504   file = filename
505;-----------------------------------------------------------------------------
506   siz = 256                    ;Basic width of tool
507   names = 0
508   LOADCT, GET_NAMES = names, FILE = file ;Get table names
509   w_height = 50                ;Height of ramp
510   cur_win = !D.WINDOW
511   lock = 0
512   chop = 0
513   vbot = 0
514   vtop = 100
515   gamma = 1.0
516   use_values=0
517
518
519; Bases:
520;  0 = slider base  (stretch bottom, stretch top, gamma)
521;  1 = transfer function drawable + buttons
522;  2 = color table list
523;  3 = options base  (sliders. top, stretch)
524
525   state = { bases: lonarr(4), draw: 0L, name_list: 0L }
526
527; DJC - Added modal keyword.
528; Moved "group_leader" keyword from XMANAGER to WIDGET_BASE.
529; Ignore modal keyword if a group leader is not supplied.
530   if (N_ELEMENTS(group) GT 0L) then $
531    base = WIDGET_BASE(TITLE="Xlct", /COLUMN, GROUP_LEADER=group, $
532                       MODAL=KEYWORD_SET(modal)) $
533   else $
534    base = WIDGET_BASE(TITLE="Xlct", /COLUMN)
535
536
537; Setting the managed attribute indicates our intention to put this app
538; under the control of XMANAGER, and prevents our draw widgets from
539; becoming candidates for becoming the default window on WSET, -1. XMANAGER
540; sets this, but doing it here prevents our own WSETs at startup from
541; having that problem.
542   WIDGET_CONTROL, /MANAGED, base
543
544
545   show = WIDGET_DRAW(base, YSIZE=w_height, XSIZE=siz, /FRAME, RETAIN = 2)
546   junk = WIDGET_BASE(base, /ROW)
547   done = WIDGET_BUTTON(junk, VALUE=' Done ', UVALUE = "DONE")
548   junk1 = WIDGET_BUTTON(junk, VALUE=' Help ', UVALUE = "HELP")
549
550   junk = CW_BGROUP(base, /ROW, /EXCLUSIVE, /NO_REL, $
551                    ['Tables', 'Options', 'Function'], $
552                    UVALUE='NEWBASE', SET_VALUE=0)
553
554   junk = widget_base(base)
555   for i=0,1 do state.bases[i] = WIDGET_BASE(junk, /COLUMN)
556
557   sbase=WIDGET_BASE(state.bases[0], /COLUMN)
558   bot = WIDGET_SLIDER(sbase, TITLE = "Stretch Bottom", MINIMUM = 0, $
559                       MAXIMUM = 100, VALUE = 0, /DRAG, UVALUE = "BOTTOM", xsize=siz)
560   top = WIDGET_SLIDER(sbase, TITLE = "Stretch Top", MINIMUM = 0, $
561                       MAXIMUM = 100, VALUE = 100, /DRAG, UVALUE = "TOP", xsize=siz)
562   g_lbl = WIDGET_LABEL(sbase, VALUE = STRING(1.0))
563   g_slider = WIDGET_slider(sbase, TITLE = "Gamma Correction", $
564                            MINIMUM = 0, MAXIMUM = 100, VALUE = 50, UVALUE = "GAMMA", $
565                            /SUPPRESS_VALUE, /DRAG, xsize=siz)
566
567   junk = WIDGET_BASE(sbase)
568   for i=2,3 do state.bases[i] = WIDGET_BASE(junk, /COLUMN)
569   DEVICE, GET_SCREEN = junk
570   if junk[1] le 768 then junk = 8 else junk = 16
571   state.name_list = WIDGET_LIST(state.bases[2], VALUE = names, ysize = junk)
572
573
574;               Drawable for transfer function
575
576   junk = WIDGET_BASE(state.bases[1], /COLUMN, /FRAME)
577   junk1 = WIDGET_BUTTON(junk, VALUE = 'Reset Transfer Function', $
578                         UVALUE='TFUNR')
579   junk1 = WIDGET_BUTTON(junk, VALUE='Add Control Point', UVALUE='ADDCP')
580   junk1 = WIDGET_BUTTON(junk, VALUE='Remove Control Point', UVALUE='REMCP')
581
582   state.draw = WIDGET_DRAW(state.bases[1], xsize = siz, ysize = siz, $
583                            /BUTTON_EVENTS, /MOTION_EVENTS)
584
585
586   opt_id = state.bases[3]
587   junk = CW_BGROUP(opt_id, /ROW, LABEL_LEFT='Sliders:', /EXCLUSIVE, /NO_REL, $
588                    ['Independent', 'Gang'], UVALUE='GANG', SET_VALUE=lock)
589   junk = CW_BGROUP(opt_id, /ROW, LABEL_LEFT = 'Top:',  /EXCLUSIVE, /NO_REL, $
590                    ['Clip', 'Chop'], SET_VALUE=chop, UVALUE='CHOP')
591   junk = CW_BGROUP(opt_id, /ROW, LABEL_LEFT='Stretch:',  /EXCLUSIVE, /NO_REL, $
592                    ['Indices', 'Intensity'], UVALUE='VALUES', $
593                    SET_VALUE=use_values)
594   junk = WIDGET_BUTTON(opt_id, VALUE='Reverse Table', $
595                        UVALUE="REVERSE", /NO_REL)
596   junk = WIDGET_BUTTON(opt_id, VALUE='REPLACE Original Table', $
597                        UVALUE = "OVERWRITE", /NO_REL)
598   junk = WIDGET_BUTTON(opt_id, VALUE='RESTORE Original Table', $
599                        UVALUE="RESTORE", /NO_REL)
600
601   WIDGET_CONTROL, state.bases[1], MAP=0 ;Tfun is not visible
602   WIDGET_CONTROL, state.bases[3], MAP=0 ;options are not visible
603
604   WIDGET_CONTROL, base, /REALIZE
605   WIDGET_CONTROL, state.draw, GET_VALUE=tmp
606
607   if n_elements(bottom) gt 0 then cbot = bottom else cbot = 0
608   ncolors = !d.table_size - cbot
609   if n_elements(nc) gt 0 then ncolors = ncolors < nc
610   if ncolors le 0 then message,'Number of colors is 0 or negative'
611
612   psave = { xlct_psave, win: !d.window, x: !x.s, y: !y.s , xtype: !x.type, $
613             ytype: !y.type, clip: !p.clip }
614;Our initial state
615   wset, tmp                    ;Initial graph
616   xlct_psave                   ;Save original scaling & window
617   plot, [0, ncolors-1], [0, ncolors-1], xstyle=3, ystyle=3, $
618    xmargin = [1,1], ymargin=[1,1], ticklen = -0.03, /NODATA
619   xlct_psave                   ;Restore original scaling & window
620
621                                ;If no common, use current colors
622   IF KEYWORD_SET(use_current) or N_ELEMENTS(r_orig) LE 0 THEN BEGIN
623      TVLCT, r_orig, g_orig, b_orig, /GET
624      r_curr = r_orig
625      b_curr = b_orig
626      g_curr = g_orig
627   ENDIF
628
629   r0 = r_curr                  ;Save original colors
630   g0 = g_curr
631   b0 = b_curr
632   color = ncolors + cbot -1
633   cps = [0, ncolors-1]
634   tfun = cps
635   pnt = -1
636
637   WIDGET_CONTROL, show, GET_VALUE=show_win
638   WSET, show_win
639
640; DJC - fixed color bar display bug.
641
642;TVSCL, BYTSCL(INDGEN(siz) # REPLICATE(1, w_height), top = ncolors-1)
643   TV, BYTE((FLOAT(ncolors)*FINDGEN(siz)/FLOAT(siz-1)) # $
644            REPLICATE(1, w_height)) + BYTE(cbot)
645
646   WSET, cur_win
647
648; DJC - moved GROUP_LEADER keyword to WIDGET_BASE.
649   XManager, "xlct", base, NO_BLOCK=(NOT(FLOAT(block))), $
650    MODAL=KEYWORD_SET(modal)
651
652END
Note: See TracBrowser for help on using the repository browser.