pro plotphot, edge, CADRE=cadre, LIMB=limb, ANNOTATION=annotation, $
	NOERASE=noerase
;------------------------------------------------------------------------------
; Trace d'un cadre et du bord du disque photospherique
;
; Parametres d'entree:
;			edge	Bords du trace: [est, sud, ouest, nord] 
;				(en rayons solaires)
;
;			cadre	Tracer un cadre delimitant le champ de vue
;			limb	Tracer le limbe photospherique
;			annotation	annoter le cadre
;			noerase	Tracer sans effacer la page
; Procedures requises:
;			circle	(Calcul d'un cercle)
;
; 10 janvier 1997, KLK; derniere modification: 22 mai 1997
;
; Modification history:
;	03 Oct 2000 Correction trace du cadre avec annotation: introduction
;                   mots clefs /xstyle, /ystyle
;------------------------------------------------------------------------------

; Largeur du cadre a tracer
IF !P.MULTI(1) LE 0 THEN nbtrx=1 ELSE nbtrx = !P.MULTI(1)
IF !P.MULTI(2) LE 0 THEN nbtry=1 ELSE nbtry = !P.MULTI(2)
width = !d.x_vsize/nbtrx
height = !d.y_vsize/nbtry

scale = ( edge(2)-edge(0) ) / ( edge(3)-edge(1) )

fract = 0.8	; fraction de la fenetre reservee au trace
xsize = fract * width
IF scale LT 1. THEN xsize = scale * xsize
ysize = xsize / scale

IF ysize GT fract*height THEN BEGIN
	corr = fract*height / ysize
	ysize = fract*height
	xsize = scale*ysize
ENDIF

; Numeros de la ligne et de la colonne du trace
IF !P.MULTI(1) GT 0 OR !P.MULTI(2) GT 0 THEN BEGIN
	IF !P.MULTI(0) EQ 0 THEN ntrace = 0 ELSE $
		ntrace = nbtrx*nbtry - !P.MULTI(0)
	nlig = ntrace / nbtrx
	ncol = ntrace-nlig*nbtrx
ENDIF ELSE BEGIN
	nlig = 0 & ncol = 0
ENDELSE

; positions des coins inferieur gauche et superieur droit du trace
lmargin = .5*(width-xsize)
bmargin = .5*(height-ysize)
x0 = ncol*width + lmargin
y0 = (nbtry-nlig-1)*height + bmargin
position = [x0, y0, x0+xsize, y0+ysize]


; Trace du cadre
;IF NOT KEYWORD_SET(NEWPAGE) THEN !P.MULTI(0) = !P.MULTI(0) + 1
tickann = [' ', ' ']
IF KEYWORD_SET( CADRE ) THEN $	; Tracer le cadre
	PLOT, [edge(0), edge(2)], [edge(1), edge(3)], POSITION = position, $
		/XSTYLE, /YSTYLE, xticks=1, yticks=1, $
		xtickn=tickann, ytickn = tickann, /DEVICE, /NODATA, $
			NOERASE=noerase $
ELSE $				; Etablir coordonnees sans tracer le cadre
	PLOT, [edge(0), edge(2)], [edge(1), edge(3)], POSITION = position, $
		xstyle=5, ystyle=5, xticks=1, yticks=1, xtickn=tickann, $
		ytickn = tickann, /DEVICE, /NODATA, NOERASE=noerase

IF KEYWORD_SET( ANNOTATION) THEN BEGIN
	AXIS, XAXIS=1, TICKLEN=-0.02, xtitle = "East - west [solar radii]",/xstyle
	AXIS, YAXIS=0, ticklen=-0.02, ytitle = "South - north [solar radii]",/ystyle
ENDIF

IF KEYWORD_SET(limb) THEN BEGIN
; Trace du limbe 
	radius = 1.
	COMP_CIRCLE, radius, angle, rayon
	FOR i = 0,1 DO BEGIN
		IF i EQ 0 THEN BEGIN
			colind = !P.BACKGROUND
			thick = 5.
		ENDIF ELSE BEGIN
			colind = !D.N_COLORS-!P.BACKGROUND
			thick = 1.
		ENDELSE 
		oplot, rayon, angle, COLOR=colind, THICK=thick, /polar
		oplot,[0,0], [-1.,-1.1], COLOR=colind, THICK=thick
		oplot,[-1,-1.1], [0,0], COLOR=colind, THICK=thick
		oplot, [0.,0.], [1,1.1], COLOR=colind, THICK=thick
		oplot, [1,1.1], [0.,0.], COLOR=colind, THICK=thick
	ENDFOR
ENDIF

END
