FUNCTION traceposiso,x,sb,numero,xrange,yrange,pastempo,$
         COLOR=color,INDICE=indice, WIN = win, LASER =laser
;
; procedure de trace d'une position superposee au trace d'isophotes
;
;     Parametres d'entree :
;                         X ...... Tableau issu de LECP1D contenant les images
;                           X(Num_position,type,indice temporel)
;                                               type = 0 ---> 
;                                               type = 1 ---> 
;			  sb ..... Structure associee a X (voir LECP1D)
;                         numero : numero de position a tracer
;                         xrange,yrange : centrage sur ancienne courbe
;
;* -------------------------------------------- *
;*     Declaration des variables globales       *
;* -------------------------------------------- *
;
   COMMON global,nomfich,FichInfo


IF NOT KEYWORD_SET(color) THEN color = 200

IF NOT KEYWORD_SET(laser) THEN BEGIN
   IF KEYWORD_SET(win) THEN BEGIN
      DEVICE,window_state = openwin
      IF openwin(numero) EQ 1 THEN WSET,win ELSE BEGIN
         print,'superposition sur fenetre fermee'
         RETURN,1
       ENDELSE
   ENDIF
ENDIF

a=x
b=size(a)
IF (numero LT 0) OR (numero GE b(1)) THEN BEGIN
    print,'Il n''y a que',b(1),' positions' 
    RETURN,1 
ENDIF

;--------------------------------------------------------------
;   construction du tableau de temps
;   extraction de la partie du tablau de position a tracer

debutemp = ROUND(sb.tabe(1, numero))		; heure debut source no. numero
npts = ROUND(sb.tabe(2, numero))		; nbre d'instants 
temp = INDGEN(npts)*ROUND(pastempo) + debutemp	; tableau du temps
tab = x(numero, 1, 0:npts-1)			; tableau des canaux

; test
;print, "Pos. no. = ", numero
;print, "Temps: ", min(temp), max(temp)
;help, tab
;print, "Canaux: ", min(tab), max(tab)

;--------------------------------------------------------------
; attention les marges doivent etre identiques a celles de isoph.pro
plot,temp,tab,/noerase,$
	     CHARSIZE = 0.6, XCHARSIZE = 1.0, YCHARSIZE = 1.0, $
	     xrange=xrange,yrange=yrange,COLOR=color,XSTYLE=5,YSTYLE=5, $
		THICK=3

; Annotation du trace des canaux
ideb = MIN(WHERE(temp GT xrange(0)))
IF (KEYWORD_SET(indice) AND ideb GE 0) THEN BEGIN
	annotx = temp(ideb)
	annoty = tab(ideb)
	annot = CONVERT_COORD([annotx, annoty], /DATA, /TO_DEVICE)
	XYOUTS, annot(0), annot(1), STRTRIM(string(numero),1),$
	       COLOR=color,SIZE=0.8, alignment = 1.0, /DEVICE
ENDIF
ifin = MAX(WHERE(temp LT xrange(1)))
IF (KEYWORD_SET(indice) AND ifin GT 0) THEN BEGIN
	annotx = temp(ifin)
	annoty = tab(ifin)
	annot = CONVERT_COORD([annotx, annoty], /DATA, /TO_DEVICE)
	XYOUTS, annot(0), annot(1), STRTRIM(string(numero),1),$
	       COLOR=color,SIZE=0.8, alignment = 1.0, /DEVICE
ENDIF

;--------------------------------------------------------------
;  on update !p.multi a cause du noerase
IF !P.MULTI(0) NE 0 THEN BEGIN
   !P.MULTI(0)=!P.MULTI(0)-1
ENDIF

RETURN,0
END
