
;+ ***********************************************************************
; NAME:
;	NRH_COORDPIX
;
; PURPOSE:
;	Cette fonction affiche une image, demande la selection d'un point
;	par le curseur et calcule les coordonnees en rayon solaire
;
; CATEGORY:
;	Images du NRH
;
; CALLING SEQUENCE:
;	COORD = NRH_COORDPIX (Data, Str_im, Str_lim, Str_Visu, Type)
;
; INPUTS:
;	DATA	Tableau contenant l'imade
;
;	STR_IM	Structure d'information de l'image
;
;	STR_LIM	Structure contenant les limites de visualisation 
;		(voir VISU_NRH)
;
;	STR_VISU Structure contenant les parametres de visualisation
;
;	TYPE	'I' pour image 'C' pour contour 
;
; KEYWORDS:
;	DIALOG_PARENT Identificqtion du widget appelent pour positionner
;		le message sur le widget
; OUTPUTS:
;	COORD	Tableau de 3 flotants contenant
;			Coord(0) : Position en X en rayon solaire
;			Coord(1) : Position en Y 
;			Coord(2) : Intensite du point
;
; PROCEDURE:
;	Cette procedure affiche l'image en tenant compte des parametres
;	donnes dans STRLIM
;	La dimension de la fenetre d'affichage est calcule de facon a faire
;	tenir la partie d'image selectionnee dans la fenetre, tout en 
;	respectant la dimension contenue dans la variable DIM
;
; EXAMPLE:
;	COORD = COORDPIX_NRH(Data, Sr_im, Str_lim, STR_VISU, 'C')
;		le contenu de STR_LIM etant defini dans RH_2D
;	PRINT, COORD
;		affiche la position en X et Y et l'intensite du point
;		selectionne
;
; MODIFICATION HISTORY:
;	Ecrit par: J Bonmartin le 27/02/98 (bonmartin@obspm.fr)
;		Le 09/08/00 rajoute keyword DIALOG_PARENT (JB)
;		Le 17/10/00 Releve de point sur Image ou Contour (JB)
;			remplace NRH_DISPLAY_IM par NRH_IMAGE
;-*******************************************************************

FUNCTION NRH_COORDPIX, Data, Str_im,Str_lim,Str_Visu, Type, $
		 DIALOG_PARENT= Dialog_parent

	IF NOT KEYWORD_SET(DIALOG_PARENT) THEN Dialog_parent=0

                Xcen = Str_im.crpixx
                Ycen = Str_im.crpixy
                Ray = Str_im.ray

		Interpx = FLOAT(Str_Visu.Dim) / FLOAT( str_lim.xf - str_lim.xd)
		Interpy = FLOAT(Str_Visu.Dim) / FLOAT( str_lim.yf - str_lim.yd)
		Interp= interpx
		IF Interpx gt interpy THEN Interp = interpy

; calcul du nombre de points de l'image
                NBIX = str_lim.xf - str_lim.xd + 1
		NBPX = FIX(Nbix * interp)
                NBIY = str_lim.yf - str_lim.yd + 1
		NBPY = FIX(Nbiy * interp)

	NRH_IMAGE,Data,Str_im,str_lim,Str_Visu, Type
      R = Widget_message('Select one point', DIALOG_PARENT=Dialog_parent)

POINT = {nrh_str_coord}
	IF Type EQ 'I' THEN BEGIN
		Cursor, XP, YP, /UP, /NORMAL
		XP= str_lim.xd + (xp * Nbix)
		YP= str_lim.yd + (yp * Nbiy)
		Point.Xcoord = ind_rs( Xp, Xcen, Ray)
		Point.Ycoord = ind_rs( Yp, Ycen, Ray)
		Point.Inten  = Data(xp,yp)
	ENDIF ELSE BEGIN
		Cursor, XP, YP, /UP, /DATA
		Point.Xcoord = Xp
		Point.Ycoord = Yp
		X = RS_IND(Xp,Xcen,Ray)
		Y = RS_IND(Yp,Ycen,Ray)
		Point.Inten  = Data(x,y)
	ENDELSE


		Point.time = Str_im.time
		Point.Date = Str_im.date
		Point.Freq = Str_im.Freq
		Point.Instrume = Str_im.Instrume

Return, Point 

END