Changeset 35 for trunk/ToBeReviewed/PLOTS/DESSINE/tvplus.pro
- Timestamp:
- 05/02/06 16:44:47 (18 years ago)
- File:
-
- 1 copied
Legend:
- Unmodified
- Added
- Removed
-
trunk/ToBeReviewed/PLOTS/DESSINE/tvplus.pro
r33 r35 5 5 ; NAME: tvplus 6 6 ; 7 ; PURPOSE: tvscl ameliore, permet de visualiser un tableau sans interpolation 8 ; 9 ; CATEGORY: pour regarder un tableau au point par point, chaque point 10 ; etant represente par un carre de coefzoom pixels de cote. la couleur 11 ; du carre, representant sa valeur, est une interpolation lineaire 12 ; entre le min du tableau de couleur 0 et le max du tableau de couleur 13 ; !d.n_colors-1 <255 14 ; 15 ; CALLING SEQUENCE:tvplus,z2d [,coefzoom] 16 ; 17 ; INPUTS: z2d le tableau 2d a visualiser 18 ; 19 ; coefzoom : (optionnel) c''est la taille des cotes des carres 20 ; representant un point, mesure en pixel. si cet argument 21 ; n''est pas specifie, la taille des carres est calculee pour 22 ; que la fenetre soit au plus pres de 95% de la taille de l''ecran 7 ; PURPOSE: enhanced version of tvscl 8 ; 9 ; CATEGORY: quick exploration of 2D arrays 10 ; 11 ; CALLING SEQUENCE: tvplus,z2d [,cellsize] 12 ; 13 ; INPUTS: 14 ; 15 ; z2d: 2D array to visualize 16 ; 17 ; cellsize: (optional) this is the size (in pixel) of the square 18 ; representing 1 array element. By default, this size is computed 19 ; automatically in order that the size of the plotting window do 20 ; not exceed the screen size. If the user specify a large value 21 ; of cellsize that forces tvplus to create a window larger than 22 ; the screen, a "scrolling window" will be displayed instead of a 23 ; regular window. Unfortunately the nice fonctionnalities of tvplus 24 ; are not coded for "scrolling window" case... 23 25 ; 24 26 ; KEYWORD PARAMETERS: … … 27 29 ; the bar. default is 0. 28 30 ; 29 ; C_NAN: c'est le numero de la couleur des points a 30 ; !values.f_nan. par defaut c''est !d.n_colors< 256 -1 31 ; 32 ; C_MASK: c'est le numero de la couleur des points a 33 ; la valeur specifiee par MASK. par defaut c''est 0 34 ; 35 ; OFFSET: c''est un vecteur de 2 elements donnant la valeur dont 36 ; il faut decaler la numerotation des points en x et en y. 37 ; Par ex: 38 ; tvplus,sst[x1:x2,y1:y2],offest=[x1,y1] 39 ; 40 ; MASK: la valeur qui sert de mask a l''ecran. si abs(mask) lt 41 ; 1e6 les points egaux a mask seronts en noir, dans le cas 42 ; contraire ce seront les points ge que abs(mask)/10. Ceci est 43 ; nessaire pour eviter les erreurs d''arrondi. 44 ; 45 ; MIN et MAX permet de borner z2d a un min ou a un max, les 46 ; points inferieurs a min etant de la couleur 0 (noir) et ceux 47 ; superieurs a max etant de la couleur (!d.n_colors-1) < 255 (blanc) 31 ; C_NAN: The color number that should be used for the NaN values. 32 ; default value is !d.n_colors < 255 33 ; 34 ; C_MASK: The color number that should be used for the mask values. 35 ; default value is 0 36 ; 37 ; OFFSET: 2 elements vector used by tvplus itself when shoing zoom. 38 ; It is used to shift the ranges of xaxis and yaxis. 39 ; For example: tvplus,sst[x1:x2,y1:y2],offest=[x1,y1] 40 ; 41 ; MASK: The mask value. Note that if abs(mask) < 1.e6, then the 42 ; exact value of the mask is used to find the maskwd point. 43 ; if abs(mask) > 1.e6, the test to find the masked value is ge 44 ; abs(mask)/10. This is necessary to avoid the rounding errors 45 ; 46 ; MIN and MAX: scalars used to specify the min and max values 47 ; of the color bar. default is from 0 to !d.n_colors < 255 48 48 ; 49 49 ; NCOLORS: This is the number of colors in the color 50 50 ; bar. default is !d.n_colors<255 -1 51 51 ; 52 ; NOINTERP: activer si on ne veut pas que les valeurs du tableau 53 ; soient interpoles entre 0 et !d.n_colors-1 < 255 pour obtenir 54 ; les correspondances avec les couleurs. Utile qd on travaille 55 ; avec des tableaux de type byte 56 ; 57 ; WINDOW: numero de la fenetre ou l''on veut faire la visualisation (permet 58 ; d''ouvrir plusieurs fenetres). par defaut on ouvre 'IDL0' 59 ; 60 ; OUTPUTS: affichage de parametres selectionnes a la souris, cf. apres 61 ; 62 ; COMMON BLOCKS: 52 ; NOINTERP: used this keyword if you don't whant that the values 53 ; are interpolated between 0 (or min) and !d.n_colors < 255 (or max). 54 ; This can be for example usefull when working on byte type arrays. 55 ; 56 ; NOUSEINFOS: activite to supress the printed message explaining 57 ; how to use tvplus 58 ; 59 ; WINDOW: Number of the window used to display the array values. 60 ; default is window number 0. 61 ; 62 ; OUTPUTS: no (except the printed finformations, see below) 63 ; 64 ; COMMON BLOCKS: no 63 65 ; 64 66 ; SIDE EFFECTS: 65 ; 1) qd la fenetre qui doit etre ouverte a une dimension -imposee 66 ; par la presence de coefzoom- superieure a 75% de la taille de 67 ; l''ecran, c''est une fenetre avec un scrolling bar qui est 68 ; ouverte. 69 ; 70 ; 2) qd le dessin est realise ds une fenetre normale, le 71 ; programme s''arrete apres le trace pour faire des l'analyses au 72 ; point par point a l''aide de la souris: 73 ; Bouton de gauche: position du curseur et valeur du tableau en ce point 74 ; Bouton du milieu: zoom 75 ; Bouton de droite: quitter 76 ; 77 ; RESTRICTIONS: l''analyse a la souris ne marche pas ds les fenetres 78 ; avec une scrolling bar... 79 ; 80 ; EXAMPLE: IDL> tvplus,nlec('sst'),max=30 67 ; 68 ; use your mouse to scan the array values... 69 ; left button : mouse position and associated array value 70 ; middle button: use it twice to define a zoom box 71 ; right button : quit 72 ; 73 ; RESTRICTIONS: the nice fonctionnalities of tvplus are not coded 74 ; for "scrolling window" case... 75 ; 76 ; EXAMPLE: IDL> tvplus, dist(100) 81 77 ; 82 78 ; MODIFICATION HISTORY: Sebastien Masson (smasson@lodyc.jussieu.fr) 83 79 ; 18/12/98 80 ; Aug 2005: quick cleaning + english 84 81 ;- 85 82 ;------------------------------------------------------------ 86 83 ;------------------------------------------------------------ 87 84 ;------------------------------------------------------------ 88 PRO tvplus, z2d, c oefzoom, BOTTOM = bottom, C_MASK = c_mask, C_NAN = c_nan, WINDOW = window $89 , MIN = min, MAX = max, MASK = mask, OFFSET = offset, PASBLABLA = PASBLABLA$85 PRO tvplus, z2d, cellsize, BOTTOM = bottom, C_MASK = c_mask, C_NAN = c_nan, WINDOW = window $ 86 , MIN = min, MAX = max, MASK = mask, OFFSET = offset, NOUSEINFOS = NOUSEINFOS $ 90 87 , NCOLORS = ncolors, NOINTERP = nointerp, _EXTRA = ex 91 88 ; 92 tab = float(z2d) 93 ;------------------------------------------------------------ 94 ; on verifie la taille de tab 95 ;------------------------------------------------------------ 96 if (size(tab))[0] NE 2 then begin 97 ras = report('le tableau doit etre 2D') 98 return 99 endif 100 ;------------------------------------------------------------ 101 ; on definit au besoin ncoulmax, bottom, topcoul et ncolors 102 ;------------------------------------------------------------ 103 ncoulmax = !d.n_colors < 256 104 IF N_ELEMENTS(bottom) EQ 0 THEN bottom = 0 105 if NOT keyword_set(ncolors) then ncolors = ncoulmax-bottom 106 topcoul = (bottom+ncolors-1) < (ncoulmax-1) 107 ;------------------------------------------------------------ 108 ; on fait le menage 109 ;------------------------------------------------------------ 110 xenvsauve = !x & yenvsauve = !y & penvsauve = !p 111 reinitplt, /z, /invert 112 ;------------------------------------------------------------ 113 ; le tableau contient des valeurs a !values.f_nan ??? 114 ;------------------------------------------------------------ 115 nan = total(finite(z2d,/nan)) < 1 116 if keyword_set(nan) then begin 117 nanindex = where(finite(z2d,/nan) EQ 1) 118 tab[nanindex] = min(tab, /nan) 119 endif 120 ;------------------------------------------------------------ 121 ; on calcule coefzoom ou bien on verifit qu''il n''est pas trop grand 122 ;------------------------------------------------------------ 123 dimensions = GET_SCREEN_SIZE() 124 if n_elements(coefzoom) EQ 0 then BEGIN 125 coefzoom = min(floor(dimensions/(size(z2d))[1: 2]*.85)) 126 ENDIF ELSE $ 127 ; il faudra ouvrir une fenetre avec une scrolling barre 128 if coefzoom GE min(floor(dimensions/(size(z2d))[1: 2]*.85)) then scrolling = 1 129 if coefzoom LT 1 then begin 130 coefzoom = 1 131 scrolling = 1 132 endif 133 ;------------------------------------------------------------ 134 ; on met les valeurs masques au max (sur les points non masques) du tableau 135 ;------------------------------------------------------------ 136 if n_elements(mask) then BEGIN 137 if abs(mask) LT 1e6 then BEGIN 138 terre = where(tab EQ mask) 139 if terre[0] NE -1 then tab(terre) = min(tab(where(tab NE mask))) 140 ENDIF ELSE BEGIN 141 terre = where(abs(tab) GE abs(mask)/10.) 142 if terre[0] NE -1 then tab(terre) = min(tab(where(abs(tab) LT abs(mask)/10.))) 143 ENDELSE 144 ENDIF ELSE terre = -1 145 ;------------------------------------------------------------ 146 ; on borne le tableau a min et max s''il sont declares 147 ;------------------------------------------------------------ 148 if keyword_set(min) then BEGIN 149 tab = min > tab 150 vraimin = min 151 ENDIF ELSE vraimin = min(tab) 152 if keyword_set(max) then BEGIN 153 tab = tab < max 154 vraimax = max 155 ENDIF ELSE vraimax = max(tab) 156 ;------------------------------------------------------------ 157 ; on bidoulle tab 158 ;------------------------------------------------------------ 159 if NOT keyword_set(nointerp) then BEGIN 160 ; on interpole tab entre bottom et bottom+ncolors-1 161 m=1.*(ncolors-1)/(vraimax-vraimin) 162 p=bottom-1.*vraimin*m 163 tab=round(1.*m*tab+p) 164 endif 165 ; on met les point nan a la couleur numero c_nan 166 if keyword_set(nan) then begin 167 if keyword_set(c_nan) THEN tab[nanindex] = c_nan < (ncoulmax -1) $ 168 ELSE tab[nanindex] = topcoul 169 endif 170 ; on met les point terre a la couleur numero c_mask 171 if keyword_set(c_mask) AND terre[0] NE -1 THEN $ 172 tab[terre] = c_mask < (ncoulmax -1) 173 ; on passe le tableau en byte 174 tab = byte(tab) 175 ; on augmente la taille de tab pour pouvoir faire le tv 176 tab = congridseb(tab, (size(tab))[1]*coefzoom,(size(tab))[2]*coefzoom) 177 ;------------------------------------------------------------ 178 ; on ouvre une fenetre a la bonne taille et on dessine 179 ;------------------------------------------------------------ 180 nx = (size(tab))[1] 181 ny = (size(tab))[2] 182 ; marges en pixel 183 rapportaspect = 1.*nx/ny 184 if rapportaspect GE 1 THEN margepix = 1.*[25, 25, 75, 25] ELSE margepix = 1.*[25, 100, 25, 25] 185 ; 186 if n_elements(scrolling) EQ 0 then BEGIN ; on ouvre une fenetre classique 187 if NOT keyword_set(window) then window = 0 188 window,window, xsize = nx+margepix[0]+margepix[1] $ 189 , ysize = ny+margepix[2]+margepix[3] ; ouverture de la fenetre 190 ; qd on utilise des couleurs codees sur 24 bit, je n''arrive pas a stipuler la couleur du 191 ; fond d''une fenetre a l'aide de !p.background, je suis oblige de faire cette bidouille!!! 192 if !d.n_colors gt 256 then BEGIN ; alors les couleurs sont codees sur 24 bit 193 device, decomposed=1 194 !p.background='ffffff'x 195 plot,[0],[0], xstyle = 5, ystyle = 5 196 device, decomposed=0 197 endif 198 tv, tab,margepix[0], margepix[2], _EXTRA = ex ; dessin de tab interpole entre 0 et !d.n_colors-1 < 255 199 ; 200 ; mise en place des axes et du cadre 201 ; 202 ; on recupere en coordonnees normalises la position du tv et donc 203 ; cette du cadre 204 poscadre = fltarr(4) 205 poscadre[0] = margepix[0]/!d.x_size 206 poscadre[2] = 1.-margepix[1]/!d.x_size 207 poscadre[1] = margepix[2]/!d.y_size 208 poscadre[3] = 1-margepix[3]/!d.y_size 209 ; on trace le cadre a l''aide d''un plot 210 if NOT keyword_set(offset) then offset = [0, 0] 211 plot, [0], [0],/noerase, position = poscadre, color = 0 $ 212 , xstyle = 1, ystyle = 1, xticklen = 1, yticklen = 1 $ 213 , xrange = 1.*[0, nx]/coefzoom-.5+offset[0], yrange = 1.*[0, ny]/coefzoom-.5+offset[1] 214 ; 215 ; mise en place de la colorbar 216 ; 217 if rapportaspect ge 1 then $ 218 posbar = [25./!d.x_size, 25./!d.y_size, 1-25./!d.x_size, 50./!d.y_size] $ 219 ELSE posbar = [1-75./!d.x_size, 25./!d.y_size, 1-50./!d.x_size, 1-25./!d.y_size] 220 if keyword_set(nointerp) then BEGIN & vraimin = 0 & vraimax = ncoulmax & endif 221 colorbar, min = vraimin, max = vraimax, division = 10, cb_color = 0, position = posbar $ 222 , vertical = rapportaspect lt 1, /right, BOTTOM = bottom, NCOLORS = ncolors, _EXTRA = ex 223 ENDIF ELSE BEGIN 224 ;------------------------------------------------------------ 225 ; dessin ds une fenetre avec une scrolling barre 226 ;------------------------------------------------------------ 227 ; qd on utilise des couleurs codees sur 24 bit, je n''arrive pas a stipuler la couleur du 228 ; fond d''une fenetre a l'aide de !p.background, je suis oblige de faire cette bidouille!!! 229 if !d.n_colors gt 256 then begin 230 window, /pixmap 231 device, decomposed=1 232 !p.background='ffffff'x 233 plot,[0],[0] 234 device, decomposed=0 235 endif 236 slide_image, tab $ ; on le dessine ds une fenetre avec une scrolling bar 237 , xsize = nx, ysize = ny $ 238 ,xvisible=round(.7*dimensions[0]) < (size(tab))[1] $ 239 ,yvisible=round(.7*dimensions[1]) < (size(tab))[2],/register,congrid=0,show_full=0 240 return 241 ENDELSE 242 ;------------------------------------------------------------ 243 ; on prend des infos a la souris 244 ;------------------------------------------------------------ 245 if NOT keyword_set(pasblabla) then begin 246 print, 'Bouton de gauche: position du curseur et valeur du tableau en ce point' 247 print, 'Bouton du milieu: zoom' 248 print, 'Bouton de droite: quitter' 249 endif 250 cursor,x,y,/device, /down 251 while (!mouse.button ne 4) do BEGIN 252 x = x-margepix[0] & x = 0 > floor(x/coefzoom) < ((size(tab))[1]-1) 253 y = y-margepix[2] & y = 0 > floor(y/coefzoom) < ((size(tab))[2]-1) 254 case !mouse.button of 255 1:BEGIN ; saisie d''une valeur 256 if x LE nx/coefzoom AND y LE ny/coefzoom then begin 257 print,'position: x='+strtrim(x+offset[0],1)+', y= '+strtrim(y+offset[1],1) $ 258 +' valeur: '+strtrim(float(z2d[x,y]), 1) 259 ENDIF 260 cursor,x,y,/device, /down 261 END 262 2:BEGIN ; zoom 263 cursor,x2,y2,/device, /down 264 x2 = x2-margepix[0] & x2 = 0 > floor(x2/coefzoom) < ((size(tab))[1]-1) 265 y2 = y2-margepix[2] & y2 = 0 > floor(y2/coefzoom) < ((size(tab))[2]-1) 266 x = [x, x2] & x = x[sort(x)] 267 y = [y, y2] & y = y[sort(y)] 268 tvplus, z2d[x[0]:x[1],y[0]:y[1] ], WINDOW = window, MIN = min, MAX = max $ 269 , MASK = mask, C_MASK = c_mask, C_NAN = c_nan, /PASBLABLA, OFFSET = [x[0],y[0]] $ 270 , NCOLORS = ncolors, NOINTERP = nointerp, BOTTOM = bottom, _EXTRA = ex 271 return 272 END 273 endcase 274 ENDWHILE 275 ;------------------------------------------------------------ 276 !x = xenvsauve & !y = yenvsauve & !p = penvsauve 277 ;------------------------------------------------------------ 278 return 89 IF n_elements(z2d) EQ 0 THEN return 90 arr = reform(float(z2d)) 91 ;------------------------------------------------------------ 92 ; check the size of the input array 93 ;------------------------------------------------------------ 94 if (size(arr))[0] NE 2 then begin 95 ras = report('Input array must have only 2 dimensions and not '+ strtrim(size(arr, /n_dimensions), 1)) 96 return 97 endif 98 ;------------------------------------------------------------ 99 ; def of ncolmax, bottom, topcol et ncolors 100 ;------------------------------------------------------------ 101 ncolmax = !d.n_colors < 256 102 IF N_ELEMENTS(bottom) EQ 0 THEN bottom = 0 103 if NOT keyword_set(ncolors) then ncolors = ncolmax-bottom 104 topcol = (bottom+ncolors-1) < (ncolmax-1) 105 ;------------------------------------------------------------ 106 ; get default values of !x, !y, !z 107 ;------------------------------------------------------------ 108 ; xenvsauve = !x & yenvsauve = !y & penvsauve = !p 109 reinitplt, /z, /invert 110 ;------------------------------------------------------------ 111 ; Do we have NaN values in arr??? 112 ;------------------------------------------------------------ 113 nan = total(finite(z2d, /nan)) < 1 114 if keyword_set(nan) then begin 115 nanindex = where(finite(z2d, /nan) EQ 1) 116 arr[nanindex] = min(arr, /nan) 117 endif 118 ;------------------------------------------------------------ 119 ; Compute the size (in pixel) of the square representing 1 120 ; point of the input array 121 ;------------------------------------------------------------ 122 dimensions = GET_SCREEN_SIZE() 123 if n_elements(cellsize) EQ 0 then BEGIN 124 cellsize = min(floor(dimensions/(size(z2d))[1: 2]*.75)) 125 ENDIF ELSE $ 126 ; we need to use a scrolling bar window 127 if cellsize GE min(floor(dimensions/(size(z2d))[1: 2]*.75)) then scrolling = 1 128 if cellsize LT 1 then begin 129 cellsize = 1 130 scrolling = 1 131 endif 132 ;------------------------------------------------------------ 133 ; Change the value of the masked value for the min of the non-masked values 134 ;------------------------------------------------------------ 135 if n_elements(mask) then BEGIN 136 if abs(mask) LT 1e6 then BEGIN 137 masked = where(arr EQ mask) 138 if masked[0] NE -1 then arr(masked) = min(arr(where(arr NE mask))) 139 ENDIF ELSE BEGIN 140 masked = where(abs(arr) GE abs(mask)/10.) 141 if masked[0] NE -1 then arr(masked) = min(arr(where(abs(arr) LT abs(mask)/10.))) 142 ENDELSE 143 ENDIF ELSE masked = -1 144 ;------------------------------------------------------------ 145 ; apply min/max keywords 146 ;------------------------------------------------------------ 147 if n_elements(min) NE 0 then BEGIN 148 arr = min > arr 149 truemin = min 150 ENDIF ELSE truemin = min(arr) 151 if n_elements(max) NE 0 then BEGIN 152 arr = arr < max 153 truemax = max 154 ENDIF ELSE truemax = max(arr) 155 ; 156 IF truemin EQ truemax THEN BEGIN 157 dummy = report('constant value everywhere: '+ strtrim(truemin, 1)) 158 return 159 ENDIF 160 ;------------------------------------------------------------ 161 ; apply other keywords (nointerp, c_nan, c_mask) 162 ;------------------------------------------------------------ 163 if NOT keyword_set(nointerp) then BEGIN 164 ; interpolation between bottom and bottom+ncolors-1 165 m = 1.*(ncolors-1)/(truemax-truemin) 166 p = bottom-1.*truemin*m 167 arr = round(1.*m*arr+p) 168 endif 169 ; set c_nan for NaN values 170 if keyword_set(nan) then begin 171 if n_elements(c_nan) NE 0 THEN arr[nanindex] = c_nan < (ncolmax -1) $ 172 ELSE arr[nanindex] = topcol 173 endif 174 ; c_mask for masked values 175 if n_elements(c_mask) NE 0 AND masked[0] NE -1 THEN $ 176 arr[masked] = c_mask < (ncolmax -1) 177 ; use byte type to save memory 178 arr = byte(arr) 179 ; increase the size of the array in order to be displayed 180 ; with the suitable size 181 arr = congridseb(arr, (size(arr))[1]*cellsize, (size(arr))[2]*cellsize) 182 ;------------------------------------------------------------ 183 ; open a window with the correct size 184 ;------------------------------------------------------------ 185 nx = (size(arr))[1] 186 ny = (size(arr))[2] 187 ; margin size (in pixel) 188 xyaspect = 1.*nx/ny 189 if xyaspect GE 1 THEN marginpix = 1.*[25, 25, 75, 25] ELSE marginpix = 1.*[25, 100, 25, 25] 190 ; 191 if n_elements(scrolling) EQ 0 then BEGIN ; open the regular window 192 if NOT keyword_set(window) then window = 0 193 window, window, xsize = nx+marginpix[0]+marginpix[1] $ 194 , ysize = ny+marginpix[2]+marginpix[3] 195 ; for 24 bits colors, make sure thate the background color is the good one... 196 if !d.n_colors gt 256 then BEGIN 197 device, decomposed = 1 198 !p.background = 'ffffff'x 199 plot, [0], [0], xstyle = 5, ystyle = 5 200 device, decomposed = 0 201 endif 202 tv, arr, marginpix[0], marginpix[2], _EXTRA = ex 203 ; 204 ; axis and plot frame 205 ; 206 ; get the normalized position of the tv (we just done above) 207 ; to know where the frame should be drawn 208 poscadre = fltarr(4) 209 poscadre[0] = marginpix[0]/!d.x_size 210 poscadre[2] = 1.-marginpix[1]/!d.x_size 211 poscadre[1] = marginpix[2]/!d.y_size 212 poscadre[3] = 1-marginpix[3]/!d.y_size 213 ; Use plot to draw the frame 214 if NOT keyword_set(offset) then offset = [0, 0] 215 !p.position = poscadre 216 plot, [0], [0], /nodata, /noerase, position = poscadre, color = 0 $ 217 , xstyle = 1, ystyle = 1, xticklen = 1, yticklen = 1 $ 218 , xrange = 1.*[0, nx]/cellsize-.5+offset[0], yrange = 1.*[0, ny]/cellsize-.5+offset[1] 219 xenvsauve = !x & yenvsauve = !y & penvsauve = !p 220 ; 221 ; draw the colorbar 222 ; 223 IF truemin ne truemax THEN BEGIN 224 if xyaspect ge 1 then $ 225 posbar = [25./!d.x_size, 25./!d.y_size, 1-25./!d.x_size, 50./!d.y_size] $ 226 ELSE posbar = [1-75./!d.x_size, 25./!d.y_size, 1-50./!d.x_size, 1-25./!d.y_size] 227 if keyword_set(nointerp) then BEGIN & truemin = 0 & truemax = ncolmax & endif 228 colorbar, min = truemin, max = truemax, division = 10, cb_color = 0, position = posbar $ 229 , vertical = xyaspect lt 1, /right, BOTTOM = bottom, NCOLORS = ncolors, _EXTRA = ex 230 ENDIF 231 ; !p.position = poscadre 232 ENDIF ELSE BEGIN 233 ;------------------------------------------------------------ 234 ; scrolling bar window case... 235 ;------------------------------------------------------------ 236 ; for 24 bits colors, make sure thate the background color is the good one... 237 if !d.n_colors gt 256 then begin 238 window, /pixmap 239 device, decomposed = 1 240 !p.background = 'ffffff'x 241 plot, [0], [0] 242 device, decomposed = 0 243 endif 244 slide_image, arr $ ; on le dessine ds une fenetre avec une scrolling bar 245 , xsize = nx, ysize = ny $ 246 , xvisible = round(.7*dimensions[0]) < (size(arr))[1] $ 247 , yvisible = round(.7*dimensions[1]) < (size(arr))[2], /register, congrid = 0, show_full = 0 248 return 249 ENDELSE 250 ;------------------------------------------------------------ 251 ; Use the mouse to get nice functionalities 252 ;------------------------------------------------------------ 253 ; format to print the mouse position 254 CASE 1 OF 255 nx LT 10:fmt1 = '(i1)' 256 nx LT 100:fmt1 = '(i2)' 257 nx LT 1000:fmt1 = '(i3)' 258 nx LT 10000:fmt1 = '(i4)' 259 ELSE:fmt1 = '' 260 ENDCASE 261 CASE 1 OF 262 ny LT 10:fmt2 = '(i1)' 263 ny LT 100:fmt2 = '(i2)' 264 ny LT 1000:fmt2 = '(i3)' 265 ny LT 10000:fmt2 = '(i4)' 266 ELSE:fmt2 = '' 267 ENDCASE 268 ; 269 if NOT keyword_set(nouseinfos) then begin 270 print, 'left button : mouse position and associated array value' 271 print, 'middle button: use it twice to define a zoom box' 272 print, 'right button : quit' 273 endif 274 cursor, x, y, /device, /down 275 x = x-marginpix[0] & x = 0 > floor(x/cellsize) < ((size(arr))[1]/cellsize-1) 276 y = y-marginpix[2] & y = 0 > floor(y/cellsize) < ((size(arr))[2]/cellsize-1) 277 while (!mouse.button ne 4) do BEGIN 278 case !mouse.button of 279 0:return 280 1:BEGIN ; get value 281 if x LE nx/cellsize AND y LE ny/cellsize then begin 282 print, '(x, y) = (' + string(x+offset[0], format = fmt1) $ 283 + ', ' + string(y+offset[1], format = fmt2) $ 284 + '), value = '+strtrim(float((reform(z2d))[x, y]), 1) 285 ENDIF 286 cursor, x, y, /device, /down 287 x = x-marginpix[0] & x = 0 > floor(x/cellsize) < ((size(arr))[1]/cellsize-1) 288 y = y-marginpix[2] & y = 0 > floor(y/cellsize) < ((size(arr))[2]/cellsize-1) 289 END 290 2:BEGIN ; zoom 291 cursor, x2, y2, /device, /down 292 x2 = x2-marginpix[0] & x2 = 0 > floor(x2/cellsize) < ((size(arr))[1]/cellsize-1) 293 y2 = y2-marginpix[2] & y2 = 0 > floor(y2/cellsize) < ((size(arr))[2]/cellsize-1) 294 x = [x, x2] & x = x[sort(x)] 295 y = [y, y2] & y = y[sort(y)] 296 IF keyword_set(OFFSET) THEN offset = [x[0], y[0]]+offset ELSE offset = [x[0], y[0]] 297 tvplus, z2d[x[0]:x[1], y[0]:y[1] ], WINDOW = window, MIN = min, MAX = max $ 298 , MASK = mask, C_MASK = c_mask, C_NAN = c_nan, /NOUSEINFOS, OFFSET = OFFSET $ 299 , NCOLORS = ncolors, NOINTERP = nointerp, BOTTOM = bottom, _EXTRA = ex 300 return 301 END 302 ELSE: 303 endcase 304 ENDWHILE 305 ;------------------------------------------------------------ 306 !x = xenvsauve & !y = yenvsauve & !p = penvsauve 307 !x.range = 1.*[0, nx]/cellsize-.5+offset[0] 308 !y.range = 1.*[0, ny]/cellsize-.5+offset[1] 309 ;------------------------------------------------------------ 310 return 279 311 end
Note: See TracChangeset
for help on using the changeset viewer.