
;+ ***********************************************************************
; NAME:
;	SEL_FICPOINT
;
; PURPOSE:
;	Cette Fonction saisit par widget l'indice de la ligne contenant
;	les donnees correspondant a un point dans un tableau de points
;
; CATEGORY:
;	Fichiers de points
;
; CALLING SEQUENCE:
;	Indice = SEL_FICPOINT( TAB ), GROUP=Group
;
; INPUTS:
;	TAB	Tableau resultant de la lecture d'un fichier de points
;

; KEYWORD PARAMETERS:
;	GROUP	Identifieur du widget appelant
;
; OUTPUTS:
;	INDICE	Indice le la ligne contenant les donnees du point
;
; COMMON BLOCKS:
;	Non
;

; PROCEDURE:
;	
;
; EXAMPLE:
;	Please provide a simple example here
;
; MODIFICATION HISTORY:
;	Ecrit par: J Bonmartin (obspm.fr) le 04/07/98
;-*******************************************************************


PRO SEL_FICPOINT_EVENT, event
COMMON SEL_FICPOINT,Indsel

	Indsel = event.Index
	WIDGET_CONTROL, event.top,/DESTROY

END

FUNCTION SEL_FICPOINT, TAB, GROUP=Group

COMMON SEL_FICPOINT,Indsel
INDSEL = 0
;affichage par WIDGET_LIST

IF N_ELEMENTS(Group) EQ 0 THEN Group=0

Base = WIDGET_BASE(GROUP_LEADER=group,/align_center,Title='Positions')
s=size(tab)
b= WIDGET_LIST(base,VALUE=Tab,ysize=s(1))

WIDGET_CONTROL,Base,/REALIZE
XMANAGER,'SEL_FICPOINT',base

Return, Indsel

END

;+ ***********************************************************************
; NAME:
;	DCD_FICPOINT
;
; PURPOSE:
;	Cette fonction decode le contenu d'une ligne correspondant a un point
;
; CATEGORY:
;	Traitement des points
;
; CALLING SEQUENCE:
;	Str_point = DCD_FICPOINT( LIGNE )
;
; INPUTS:
;	LIGNE	Chaine correspondant a une ligne d'un fichier de point
;	
; KEYWORD PARAMETERS:
;	Non
;
; OUTPUTS:
;	STR_POINT Structure contenant les information d'un point de mesure
;			definie par NRH_STR_COORD__DEFINE
;
; COMMON BLOCKS:
;	Non
;
; PROCEDURE:
;	Cette fonction cree la structure correspondante et remplit les
;	valeurs a partir de la LIGNE
;	Cette structure est utilisee ensuite pour reporter le point sur une 
;	image tracee par nrh_imageref
;
; EXAMPLE:
;	RD_FICPOINT (Fichier, Tab)
;	Indic = SEL_FICPOINT ( Tab)
;	Str_coord = DCD_FICPOINT ( Tab(Indic) )
;
; MODIFICATION HISTORY:
;	Ecrit par: J Bonmartin (obspm.fr) le 04/09/98
;-*******************************************************************

FUNCTION DCD_FICPOINT, LIGNE

str_point = {nrh_str_coord}	;structure definie dans str_coor__define

	Year = STRPOS(Ligne, '/')			;ancien format
	IF Year EQ -1 THEN Year = STRPOS(ligne, '-')	;nouveau format
		Position = 8				;Champ instrument
	Str_point.date = STRMID(Ligne, 8, 10)
		Position = position + 11		;champ date
	Str_point.time = STRMID(ligne, Position,11)
		Position = Position + 13		;champ heure
	Str_point.freq = STRMID(Ligne, Position,6)
		Position = position + 7		; champ frequence
	VAL= STRMID(Ligne, Position, 20)
	READS,Val , I, J, V
	Str_point.Xcoord= i & Str_point.Ycoord= J & Str_point.Inten= V

Return, Str_point

END

;+ ***********************************************************************
; NAME:
;	RD_FICPOINT
;
; PURPOSE:
;	Cette procedure lit le contenu d'un fichier de points de mesure
;
; CATEGORY:
;	Fichier de points.
;
; CALLING SEQUENCE:
;	RD_FICPOINT, FILE, TAB
;
; INPUTS:
;	FILE	Nom du fichier contenant les poins de mesure
;
; KEYWORD PARAMETERS:
;	Non
;
; OUTPUTS:
;	TAB	Tableau de chaine resultant de la lecture du fichier
;
; COMMON BLOCKS:
;	Non
;
; PROCEDURE:
;	Cette procedure transfere le contenu du fichier dans un tableau 
;	de chaines
;
; EXAMPLE:
;	Please provide a simple example here
;
; MODIFICATION HISTORY:
;	Ecrit par: J Bonmartin ( obspm.fr) le 04/09/98
;-*******************************************************************


PRO RD_FICPOINT, FILE, TAB

	GET_LUN, UNIT
	OPENR, Unit, File
A=''
LIG = 0
	WHILE NOT EOF(Unit) DO BEGIN
		READF, Unit, A 
		Lig = Lig + 1
	END
	CLOSE, Unit

	TAB = STRARR(Lig)

	OPENR, Unit, File

	READF, Unit, TAB
	FREE_LUN,Unit

END
