source: trunk/SRC/Colors/xlct.pro

Last change on this file was 495, checked in by pinsard, 10 years ago

fix thanks to coding rules; typo; dupe empty lines; trailing blanks

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 19.9 KB
Line 
1;+
2;
3; @hidden
4;
5;-
6PRO xlct_psave                 
7; Save/Restore our plotting state.
8; Swaps our state with the current state each time its called.
9;
10  compile_opt idl2, strictarrsubs
11;
12
13COMMON xlct_com, r0, g0, b0, tfun, state, filename, cps, psave, pnt, $
14        top, bot, silent, chop, lock, g_lbl, vbot, vtop, g_slider, $
15        gamma, color, use_values, ncolors, cbot, siz, w_height, show_win, $
16        updt_callback, updt_cb_data
17
18tmp = { xlct_psave, win: !d.window, x: !x.s, y: !y.s , xtype: !x.type, $
19                         ytype: !y.type, clip: !p.clip }
20
21wset, psave.win
22!x.type = psave.xtype
23!y.type = psave.ytype
24!x.s = psave.x
25!y.s = psave.y
26!p.clip = psave.clip
27psave = tmp
28end
29
30;+
31; @hidden
32;-
33pro xlct_alert_caller
34;
35  compile_opt idl2, strictarrsubs
36;
37COMMON xlct_com, r0, g0, b0, tfun, state, filename, cps, psave, pnt, $
38        top, bot, silent, chop, lock, g_lbl, vbot, vtop, g_slider, $
39        gamma, color, use_values, ncolors, cbot, siz, w_height, show_win, $
40        updt_callback, p_updt_cb_data
41
42    ErrorStatus = 0
43    CATCH, ErrorStatus
44    if (ErrorStatus NE 0) then begin
45        CATCH, /CANCEL
46        v = DIALOG_MESSAGE(['Unexpected error in XLCT:', $
47                        '!ERR_STRING = ' + !ERR_STRING], $
48                        /ERROR)
49        return
50    endif
51    if (STRLEN(updt_callback) gt 0) then begin
52        if (PTR_VALID(p_updt_cb_data)) then begin
53            CALL_PROCEDURE, updt_callback, DATA=*(p_updt_cb_data)
54        endif else begin
55            CALL_PROCEDURE, updt_callback
56        endelse
57    endif
58end
59
60; Redraw the ramp image.
61;+
62; @hidden
63;-
64PRO xlct_show
65;
66  compile_opt idl2, strictarrsubs
67;
68COMMON xlct_com, r0, g0, b0, tfun, state, filename, cps, psave, pnt, $
69        top, bot, silent, chop, lock, g_lbl, vbot, vtop, g_slider, $
70        gamma, color, use_values, ncolors, cbot, siz, w_height, show_win, $
71        updt_callback, p_updt_cb_data
72
73    cur_win = !D.WINDOW
74    WSET, show_win
75    TV, BYTE((FLOAT(ncolors)*FINDGEN(siz)/FLOAT(siz-1)) # $
76        REPLICATE(1, w_height)) + BYTE(cbot)
77
78    WSET, cur_win
79
80    ; Let the caller of XLCT know that the color table was modified
81    xlct_alert_caller
82END
83
84;+
85; @hidden
86; @param i
87; ???
88; @param c
89; ???
90;-
91PRO xlct_draw_cps, i, c
92;
93  compile_opt idl2, strictarrsubs
94;
95COMMON colors, r_orig, g_orig, b_orig, r_curr, g_curr, b_curr
96COMMON xlct_com, r0, g0, b0, tfun, state, filename, cps, psave, pnt, $
97        top, bot, silent, chop, lock, g_lbl, vbot, vtop, g_slider, $
98        gamma, color, use_values, ncolors, cbot
99
100tc = color
101if n_elements(c) gt 0 then begin
102        tc = c
103        if c ne 0 then color = c
104        endif
105
106if i[0] eq -1 then j = indgen(n_elements(cps)) else j = i
107
108plots, cps[j], tfun[j], /noclip, color = tc
109plots, cps[j], tfun[j], /noclip, psym=6, color = tc
110end
111
112;+
113; @hidden
114; @keyword UPDATE
115; ???
116;-
117PRO xlct_transfer, UPDATE=update
118;
119  compile_opt idl2, strictarrsubs
120;
121COMMON colors, r_orig, g_orig, b_orig, r_curr, g_curr, b_curr
122COMMON xlct_com, r0, g0, b0, tfun, state, filename, cps, psave, pnt, $
123        top, bot, silent, chop, lock, g_lbl, vbot, vtop, g_slider, $
124        gamma, color, use_values, ncolors, cbot
125
126l = lonarr(ncolors)             ;Subscripts
127m = n_elements(cps)
128for i=0, m-2 do begin
129        n = cps[i+1]-cps[i]             ;Interval
130        b = (tfun[i+1]-tfun[i])/float(n)
131        l[cps[i]] = findgen(n) * b + (tfun[i] + cbot)
132        endfor
133l[ncolors-1] = tfun[m-1]                ;Last point
134if use_values then begin
135  r_curr[cbot] = (r = l[r_orig])
136  g_curr[cbot] = (g = l[g_orig])
137  b_curr[cbot] = (b = l[b_orig])
138endif else begin
139  r_curr[cbot] = (r = r_orig[l])
140  g_curr[cbot] = (g = g_orig[l])
141  b_curr[cbot] = (b = b_orig[l])
142endelse
143
144tvlct, r,g,b, cbot
145if (keyword_set( update )) then $
146  xlct_show
147end
148
149;+
150; @hidden
151; @param event
152; ???
153;-
154PRO xlct_event, event
155;
156  compile_opt idl2, strictarrsubs
157;
158COMMON colors, r_orig, g_orig, b_orig, r_curr, g_curr, b_curr
159COMMON xlct_com, r0, g0, b0, tfun, state, filename, cps, psave, pnt, $
160        top, bot, silent, chop, lock, g_lbl, vbot, vtop, g_slider, $
161        gamma, color, use_values, ncolors, cbot, siz, w_height, show_win, $
162        updt_callback, p_updt_cb_data
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 <proidl>XLOADCT</proidl> but fastest to write and call by default
401; the palette 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;-
469PRO xlct, SILENT=silent_f, GROUP=group, FILE=file, $
470          USE_CURRENT=use_current, NCOLORS=nc, BOTTOM=bottom, $
471          MODAL=modal, BLOCK=block, UPDATECALLBACK=updt_cb_name, $
472          UPDATECBDATA=updt_cb_data
473;
474  compile_opt idl2, strictarrsubs
475;
476
477   COMMON colors, r_orig, g_orig, b_orig, r_curr, g_curr, b_curr
478   COMMON xlct_com, r0, g0, b0, tfun, state, filename, cps, psave, pnt, $
479    top, bot, silent, chop, lock, g_lbl, vbot, vtop, g_slider, $
480    gamma, color, use_values, ncolors, cbot, siz, w_height, show_win, $
481    updt_callback, p_updt_cb_data
482
483   IF(XRegistered("xlct") NE 0) THEN return
484
485   IF N_ELEMENTS(block) EQ 0 THEN block=0
486   IF N_ELEMENTS(updt_cb_name) EQ 0 THEN updt_callback="" $
487   ELSE updt_callback=updt_cb_name
488   IF N_ELEMENTS(updt_cb_data) GT 0 THEN p_updt_cb_data=PTR_NEW(updt_cb_data) $
489   ELSE p_updt_cb_data=PTR_NEW()
490
491   values_button = lonarr(2)
492
493   IF KEYWORD_SET(SILENT_f) THEN silent = SILENT_F ELSE silent = 1
494;-----------------------------------------------------------------------------
495; Changes made by S.Masson
496;-----------------------------------------------------------------------------
497   IF N_ELEMENTS(file) GT 0 THEN filename = file ELSE BEGIN
498      filename = find('palette.tbl', /firstfound, /nopro)
499      if filename EQ 'NOT FOUND' then filename=filepath('colors1.tbl',subdir=['resource', 'colors'])
500   ENDELSE
501   file = filename
502;-----------------------------------------------------------------------------
503   siz = 256                    ;Basic width of tool
504   names = 0
505   LOADCT, GET_NAMES = names, FILE = file ;Get table names
506   w_height = 50                ;Height of ramp
507   cur_win = !D.WINDOW
508   lock = 0
509   chop = 0
510   vbot = 0
511   vtop = 100
512   gamma = 1.0
513   use_values=0
514
515; Bases:
516;  0 = slider base  (stretch bottom, stretch top, gamma)
517;  1 = transfer function drawable + buttons
518;  2 = color table list
519;  3 = options base  (sliders. top, stretch)
520
521   state = { bases: lonarr(4), draw: 0L, name_list: 0L }
522
523; DJC - Added modal keyword.
524; Moved "group_leader" keyword from XMANAGER to WIDGET_BASE.
525; Ignore modal keyword if a group leader is not supplied.
526   if (N_ELEMENTS(group) GT 0L) then $
527    base = WIDGET_BASE(TITLE="Xlct", /COLUMN, GROUP_LEADER=group, $
528                       MODAL=KEYWORD_SET(modal)) $
529   else $
530    base = WIDGET_BASE(TITLE="Xlct", /COLUMN)
531
532; Setting the managed attribute indicates our intention to put this app
533; under the control of XMANAGER, and prevents our draw widgets from
534; becoming candidates for becoming the default window on WSET, -1. XMANAGER
535; sets this, but doing it here prevents our own WSETs at startup from
536; having that problem.
537   WIDGET_CONTROL, /MANAGED, base
538
539   show = WIDGET_DRAW(base, YSIZE=w_height, XSIZE=siz, /FRAME, RETAIN = 2)
540   junk = WIDGET_BASE(base, /ROW)
541   done = WIDGET_BUTTON(junk, VALUE=' Done ', UVALUE = "DONE")
542   junk1 = WIDGET_BUTTON(junk, VALUE=' Help ', UVALUE = "HELP")
543
544   junk = CW_BGROUP(base, /ROW, /EXCLUSIVE, /NO_REL, $
545                    ['Tables', 'Options', 'Function'], $
546                    UVALUE='NEWBASE', SET_VALUE=0)
547
548   junk = widget_base(base)
549   for i=0,1 do state.bases[i] = WIDGET_BASE(junk, /COLUMN)
550
551   sbase=WIDGET_BASE(state.bases[0], /COLUMN)
552   bot = WIDGET_SLIDER(sbase, TITLE = "Stretch Bottom", MINIMUM = 0, $
553                       MAXIMUM = 100, VALUE = 0, /DRAG, UVALUE = "BOTTOM", xsize=siz)
554   top = WIDGET_SLIDER(sbase, TITLE = "Stretch Top", MINIMUM = 0, $
555                       MAXIMUM = 100, VALUE = 100, /DRAG, UVALUE = "TOP", xsize=siz)
556   g_lbl = WIDGET_LABEL(sbase, VALUE = STRING(1.0))
557   g_slider = WIDGET_slider(sbase, TITLE = "Gamma Correction", $
558                            MINIMUM = 0, MAXIMUM = 100, VALUE = 50, UVALUE = "GAMMA", $
559                            /SUPPRESS_VALUE, /DRAG, xsize=siz)
560
561   junk = WIDGET_BASE(sbase)
562   for i=2,3 do state.bases[i] = WIDGET_BASE(junk, /COLUMN)
563   DEVICE, GET_SCREEN = junk
564   if junk[1] le 768 then junk = 8 else junk = 16
565   state.name_list = WIDGET_LIST(state.bases[2], VALUE = names, ysize = junk)
566
567;               Drawable for transfer function
568
569   junk = WIDGET_BASE(state.bases[1], /COLUMN, /FRAME)
570   junk1 = WIDGET_BUTTON(junk, VALUE = 'Reset Transfer Function', $
571                         UVALUE='TFUNR')
572   junk1 = WIDGET_BUTTON(junk, VALUE='Add Control Point', UVALUE='ADDCP')
573   junk1 = WIDGET_BUTTON(junk, VALUE='Remove Control Point', UVALUE='REMCP')
574
575   state.draw = WIDGET_DRAW(state.bases[1], xsize = siz, ysize = siz, $
576                            /BUTTON_EVENTS, /MOTION_EVENTS)
577
578   opt_id = state.bases[3]
579   junk = CW_BGROUP(opt_id, /ROW, LABEL_LEFT='Sliders:', /EXCLUSIVE, /NO_REL, $
580                    ['Independent', 'Gang'], UVALUE='GANG', SET_VALUE=lock)
581   junk = CW_BGROUP(opt_id, /ROW, LABEL_LEFT = 'Top:',  /EXCLUSIVE, /NO_REL, $
582                    ['Clip', 'Chop'], SET_VALUE=chop, UVALUE='CHOP')
583   junk = CW_BGROUP(opt_id, /ROW, LABEL_LEFT='Stretch:',  /EXCLUSIVE, /NO_REL, $
584                    ['Indices', 'Intensity'], UVALUE='VALUES', $
585                    SET_VALUE=use_values)
586   junk = WIDGET_BUTTON(opt_id, VALUE='Reverse Table', $
587                        UVALUE="REVERSE", /NO_REL)
588   junk = WIDGET_BUTTON(opt_id, VALUE='REPLACE Original Table', $
589                        UVALUE = "OVERWRITE", /NO_REL)
590   junk = WIDGET_BUTTON(opt_id, VALUE='RESTORE Original Table', $
591                        UVALUE="RESTORE", /NO_REL)
592
593   WIDGET_CONTROL, state.bases[1], MAP=0 ;Tfun is not visible
594   WIDGET_CONTROL, state.bases[3], MAP=0 ;options are not visible
595
596   WIDGET_CONTROL, base, /REALIZE
597   WIDGET_CONTROL, state.draw, GET_VALUE=tmp
598
599   if n_elements(bottom) gt 0 then cbot = bottom else cbot = 0
600   ncolors = !d.table_size - cbot
601   if n_elements(nc) gt 0 then ncolors = ncolors < nc
602   if ncolors le 0 then message,'Number of colors is 0 or negative'
603
604   psave = { xlct_psave, win: !d.window, x: !x.s, y: !y.s , xtype: !x.type, $
605             ytype: !y.type, clip: !p.clip }
606;Our initial state
607   wset, tmp                    ;Initial graph
608   xlct_psave                   ;Save original scaling & window
609   plot, [0, ncolors-1], [0, ncolors-1], xstyle=3, ystyle=3, $
610    xmargin = [1,1], ymargin=[1,1], ticklen = -0.03, /NODATA
611   xlct_psave                   ;Restore original scaling & window
612
613                                ;If no common, use current colors
614   IF KEYWORD_SET(use_current) or N_ELEMENTS(r_orig) LE 0 THEN BEGIN
615      TVLCT, r_orig, g_orig, b_orig, /GET
616      r_curr = r_orig
617      b_curr = b_orig
618      g_curr = g_orig
619   ENDIF
620
621   r0 = r_curr                  ;Save original colors
622   g0 = g_curr
623   b0 = b_curr
624   color = ncolors + cbot -1
625   cps = [0, ncolors-1]
626   tfun = cps
627   pnt = -1
628
629   WIDGET_CONTROL, show, GET_VALUE=show_win
630   WSET, show_win
631
632; DJC - fixed color bar display bug.
633
634;TVSCL, BYTSCL(INDGEN(siz) # REPLICATE(1, w_height), top = ncolors-1)
635   TV, BYTE((FLOAT(ncolors)*FINDGEN(siz)/FLOAT(siz-1)) # $
636            REPLICATE(1, w_height)) + BYTE(cbot)
637
638   WSET, cur_win
639
640; DJC - moved GROUP_LEADER keyword to WIDGET_BASE.
641   XManager, "xlct", base, NO_BLOCK=(NOT(FLOAT(block))), $
642    MODAL=KEYWORD_SET(modal)
643
644END
Note: See TracBrowser for help on using the repository browser.