Changeset 136 for trunk/SRC/Colors/xpal.pro
- Timestamp:
- 07/10/06 17:20:19 (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/SRC/Colors/xpal.pro
r134 r136 1 1 ;+ 2 2 ; 3 ; @file_comments 4 ; like xpalette but shorter to write and ,moreover,3 ; @file_comments 4 ; like xpalette but shorter to write and, moreover, 5 5 ; possess a hotkey save which (thanks to the newpalette routine) 6 6 ; allows to save the routine that we have just done. Comment: when we 7 ; press the predefined hotkey, it calls xlct instead of xloadct 7 ; press the predefined hotkey, it calls xlct instead of xloadct 8 8 ; No explicit inputs. The current color table is used as a starting point. 9 9 ; 10 10 ; @categories Color tables, widgets. 11 11 ; 12 ; @keyword BLOCK Set this keyword to have XMANAGER block when this13 ; application is registered. By default the Xmanager14 ; keyword NO_BLOCK is set to 1 to provide access to the15 ; command line if active command line processing is available.16 ; Note that setting BLOCK for this application will cause17 ; all widget applications to block, not only this18 ; application. For more information see the NO_BLOCK keyword19 ; to XMANAGER.20 ; @keyword UPDATECALLBACK Set this keyword to a string containing the name of21 ; a user-supplied procedure that will be called when the color22 ; table is updated by XLOADCT. The procedure may optionally23 ; accept a keyword called DATA, which will be automatically24 ; set to the value specified by the optional UPDATECBDATA25 ; keyword.26 ; @keyword UPDATECBDATA Set this keyword to a value of any type. It will be27 ; passed via the DATA keyword to the user-supplied procedure28 ; specified via the UPDATECALLBACK keyword, if any. If the29 ; UPDATECBDATA keyword is not set the value accepted by the30 ; DATA keyword to the procedure specified by UPDATECALLBACK31 ; will be undefined.32 ;33 ; @uses COLORS: Contains the current RGB color tables.34 12 ; @uses XP_COM: Private to this module. 35 13 ; 36 ; @restrictions XPAL uses two colors from the current color table as 37 ; drawing foreground and background colors. These are used 38 ; for the RGB plots on the left, and the current index marker on 39 ; the right. This means that if the user set these two colors 40 ; to the same value, the XPAL display could become unreadable 41 ; (like writing on black paper with black ink). XPAL minimizes 42 ; this possibility by noting changes to the color map and always 43 ; using the brightest available color for the foreground color 44 ; and the darkest for the background. Thus, the only way 45 ; to make XPAL's display unreadable is to set the entire color 46 ; map to a single color, which is highly unlikely. The only side 47 ; effect of this policy is that you may notice XPAL redrawing 48 ; the entire display after you've modified the current color. 49 ; This simply means that the change has made XPAL pick new 50 ; drawing colors. 51 ; 52 ; The new color tables are saved in the COLORS common and loaded 53 ; to the display. 54 ; 55 ; @examples The XPAL widget has the following controls: 14 ; @restrictions 15 ; XPAL uses two colors from the current color table as 16 ; drawing foreground and background colors. These are used 17 ; for the RGB plots on the left, and the current index marker on 18 ; the right. This means that if the user set these two colors 19 ; to the same value, the XPAL display could become unreadable 20 ; (like writing on black paper with black ink). XPAL minimizes 21 ; this possibility by noting changes to the color map and always 22 ; using the brightest available color for the foreground color 23 ; and the darkest for the background. Thus, the only way 24 ; to make XPAL's display unreadable is to set the entire color 25 ; map to a single color, which is highly unlikely. The only side 26 ; effect of this policy is that you may notice XPAL redrawing 27 ; the entire display after you've modified the current color. 28 ; This simply means that the change has made XPAL pick new 29 ; drawing colors. 30 ; 31 ; The new color tables are saved in the COLORS common and loaded 32 ; to the display. 33 ; 34 ; @examples 35 ; The XPAL widget has the following controls: 56 36 ; 57 37 ; Left: Three plots showing the current Red, Green, and Blue vectors. … … 106 86 ; 3) The name of the file containing palettes. 107 87 ; Comment: May follow instructions gave by the prompter. 108 ; 88 ; 109 89 ; 110 90 ; Three sliders (R, G, and B) that allow the user to modify the … … 125 105 ; horizontally. 126 106 ; 127 ; @history ad daptation de xpalette pour ajouter un bouton save par128 ; G ima Nicolas (nglod@ipsl.jussieu.fr) et par Masson129 ; Sebastien (smlod @ipsl.jussieu.fr)107 ; @history adaptation de xpalette pour ajouter un bouton save par 108 ; Grima Nicolas (nglod\@ipsl.jussieu.fr) et par Masson 109 ; Sebastien (smlod\@ipsl.jussieu.fr) 130 110 ; 131 111 ; $Id$ … … 134 114 ; 135 115 ;+ 136 ; @file_comments XP_NEW_COLORS: Choose the best foreground and background colors for the current 137 ; color maps and set !P appropriately. Returns 1 if the colors changed, 138 ; 0 otherwise. 139 ; 140 ; @returns 1 or 0 141 ;- 116 ; @file_comments 117 ; XP_NEW_COLORS: Choose the best foreground and background colors for 118 ; the current color maps and set !P appropriately. 119 ; 120 ; @returns 121 ; 1 if the colors changed, 0 otherwise. 122 ;- 142 123 function XP_NEW_COLORS 143 124 ; … … 162 143 end 163 144 145 ;+ 146 ; @hidden 147 ;- 164 148 pro XP_ALERT_CALLER 165 149 ; … … 187 171 end 188 172 ;+ 189 ; @file_comments XP_XLCTCALLBACK: For visuals with static colormaps, update the graphics 190 ; after a change by XLOADCT. 173 ; @file_comments 174 ; XP_XLCTCALLBACK: For visuals with static colormaps, update the graphics 175 ; after a change by XLOADCT. 191 176 ;- 192 177 pro XP_XLCTCALLBACK … … 201 186 end 202 187 188 ;+ 189 ; @hidden 190 ;- 203 191 pro XP_REDRAW 204 192 ; … … 216 204 217 205 ;+ 218 ; @file_comments XP_REPLOT: Re-draw the RGB plots. Type has the following possible values. 206 ; @file_comments 207 ; XP_REPLOT: Re-draw the RGB plots. Type has the following possible values. 219 208 ; - 'D': Draw the data part of all three plots 220 209 ; - 'F': draw all three plots … … 222 211 ; - 'G': Draw the data part of the Green plot 223 212 ; - 'B': Draw the data part of the Blue plot 224 ;- 213 ;- 225 214 pro XP_REPLOT, color_index, type 226 215 ; … … 240 229 save_x_s = !x.s 241 230 save_y_s = !y.s 242 save_x_type = !x.type 243 save_y_type = !y.type 231 save_x_type = !x.type 232 save_y_type = !y.type 244 233 245 234 !y.margin= [2, 2] … … 435 424 436 425 7: goto, do_copy 437 8: BEGIN 426 8: BEGIN 438 427 COMMON basecommon, bas212, bas222, bas232 439 428 base = WIDGET_BASE(/COLUMN, /FRAME) … … 476 465 THEN BEGIN 477 466 CASE uval OF 478 'ok' :BEGIN 467 'ok' :BEGIN 479 468 WIDGET_CONTROL, bas212, GET_VALUE = palname 480 469 WIDGET_CONTROL, bas222, GET_VALUE = over … … 541 530 ;+ 542 531 ; 543 ; @keyword group 544 ; 545 ; @keyword BLOCK Set this keyword to have XMANAGER block when this 546 ; application is registered. By default the Xmanager 547 ; keyword NO_BLOCK is set to 1 to provide access to the 548 ; command line if active command line processing is available. 549 ; Note that setting BLOCK for this application will cause 550 ; all widget applications to block, not only this 551 ; application. For more information see the NO_BLOCK keyword 552 ; to XMANAGER. 553 ; @keyword UPDATECALLBACK Set this keyword to a string containing the name of 554 ; a user-supplied procedure that will be called when the color 555 ; table is updated by XLOADCT. The procedure may optionally 556 ; accept a keyword called DATA, which will be automatically 557 ; set to the value specified by the optional UPDATECBDATA 558 ; keyword. 559 ; @keyword UPDATECBDATA Set this keyword to a value of any type. It will be 560 ; passed via the DATA keyword to the user-supplied procedure 561 ; specified via the UPDATECALLBACK keyword, if any. If the 562 ; UPDATECBDATA keyword is not set the value accepted by the 563 ; DATA keyword to the procedure specified by UPDATECALLBACK 564 ; will be undefined. 565 ; 566 ;- 567 568 569 532 ; @keyword group 533 ; 534 ; @keyword BLOCK 535 ; Set this keyword to have XMANAGER block when this 536 ; application is registered. By default the Xmanager 537 ; keyword NO_BLOCK is set to 1 to provide access to the 538 ; command line if active command line processing is available. 539 ; Note that setting BLOCK for this application will cause 540 ; all widget applications to block, not only this 541 ; application. For more information see the NO_BLOCK keyword 542 ; to XMANAGER. 543 ; 544 ; @keyword UPDATECALLBACK 545 ; Set this keyword to a string containing the name of 546 ; a user-supplied procedure that will be called when the color 547 ; table is updated by XLOADCT. The procedure may optionally 548 ; accept a keyword called DATA, which will be automatically 549 ; set to the value specified by the optional UPDATECBDATA 550 ; keyword. 551 ; 552 ; @keyword UPDATECBDATA 553 ; Set this keyword to a value of any type. It will be 554 ; passed via the DATA keyword to the user-supplied procedure 555 ; specified via the UPDATECALLBACK keyword, if any. If the 556 ; UPDATECBDATA keyword is not set the value accepted by the 557 ; DATA keyword to the procedure specified by UPDATECALLBACK 558 ; will be undefined. 559 ; 560 ;- 570 561 pro XPAL, group=group, BLOCK=block, UPDATECALLBACK=updt_cb_name, $ 571 562 UPDATECBDATA=updt_cb_data … … 584 575 585 576 xpw = { xp_widgets, base:0L, $ 586 577 colorsel:0L, mark_label:0L, idx_label:0L, button_base:0L, rgb_base:0L} 587 578 588 579 state = {old_p:!p, $ ; Original value of !P 589 590 591 592 593 594 580 mark_idx:0, $ ; Current mark index 581 cur_idx:0, $ ; Current index 582 cur_color_win:0, $ ; Current Color draw window index 583 plot_win:0, $ ; RGB plot draw window index 584 updt_callback: updt_callback, $ ; user-defined callback (optional) 585 p_updt_cb_data:p_updt_cb_data} ; data for callback (optional) 595 586 596 587 if (XREGISTERED('XPAL')) then return ; Only one copy at a time … … 610 601 save_win = !d.window ;Previous window 611 602 612 IF N_ELEMENTS(r_orig) LE 0 THEN BEGIN 613 614 615 616 617 603 IF N_ELEMENTS(r_orig) LE 0 THEN BEGIN ;If no common, use current colors 604 TVLCT, r_orig, g_orig, b_orig, /GET 605 r_curr = r_orig 606 b_curr = b_orig 607 g_curr = g_orig 608 ENDIF 618 609 619 610 ; Create widgets … … 631 622 632 623 c1 = WIDGET_BASE(xpw.base, /COLUMN, space=20) 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 624 status = WIDGET_BASE(c1, /COLUMN, /FRAME) 625 ncw = WIDGET_LABEL(WIDGET_BASE(status), /DYNAMIC_RESIZE) 626 xpw.idx_label = CW_FIELD(status, title='Current Index: ', value='0', $ 627 xsize=20, /STRING) 628 xpw.mark_label = CW_FIELD(status, title='Mark Index: ', value='0', $ 629 xsize=20, /STRING) 630 c1_1 = widget_base(status, /ROW) 631 junk = WIDGET_LABEL(c1_1, value="Current Color: ") 632 cur_color = WIDGET_DRAW(c1_1, xsize = 125, ysize=50, /frame) 633 names = [ 'Done', 'Predefined', 'Help', 'Redraw', 'Set Mark', $ 634 'Switch Mark', 'Copy Current', 'Interpolate', 'save'] 635 xpw.button_base = CW_BGROUP(c1, names, COLUMN=3, /FRAME) 636 xpw.rgb_base = CW_RGBSLIDER(c1, /FRAME, /DRAG) 637 638 junk = WIDGET_BASE(xpw.base) ; Responds to YOFFSET 648 639 if (version.style='Motif') then junk2=30 else junk2 = 50 649 640 xpw.colorsel = CW_COLORSEL(junk, yoffset=junk2) 650 651 641 652 642 state.cur_idx = 0 … … 658 648 659 649 WIDGET_CONTROL, ncw, $ 660 650 set_value='Number Of Colors: ' + strcompress(!d.n_colors, /REMOVE_ALL) 661 651 WIDGET_CONTROL, get_value=tmp, cur_color 662 652 state.cur_color_win = tmp … … 672 662 673 663 XMANAGER, 'Xpal', xpw.base, event_handler='XP_EVENT', group=group, $ 674 675 end 676 664 NO_BLOCK=(NOT(FLOAT(block))) 665 end 666
Note: See TracChangeset
for help on using the changeset viewer.