Viewing contents of file '../idllib/astron/contrib/varosi/code/allpro/contour_init.pro'
;+
; NAME:
;	contour_init
; PURPOSE:
;	Setup constants and menu for pro contour_mosaic.
; CALLING:
;	menu = contour_init( callers, mosaic_spec )
; INPUTS:
;	callers = strarr
;	mosaic_spec = structure
; OUTPUTS:
;	Function returns string array of menu options.
;	All other output thru common blocks.
; COMMON BLOCKS:
;	common contour_init, site_name
;	common contour_mosaic, Nhc, ArcSec_inch, set_scale
;	common contour_options, TickLen, bitspix
;	common cursor_scale, cmin_y, cmax_y
;	common adjct_map, color_map
;	common HC_color, grey_map, color_trans
;	common PS_Layout, xoff, yoff, xpap, ypap, Left, Right, Top, Bottom
; EXTERNAL CALLS:
;	function the_date
;	function reverse
;	pro check_menu_size	(for Sun386i/SunView only)
; PROCEDURE:
;	Straightforward.
; HISTORY:
;	Written: Frank Varosi NASA/GSFC 1990.
;	F.V.1991, now uses mosaic_spec structure (remembers all settings).
;	F.V.1996, incr. yoff & decr. Bottom by 0.2 to fit new Tek color printer.
;	F.V.1999, added lager paper size options for a newer Tek color printer.
;-

function contour_init, callers, mosaic_spec

  common contour_init, site_name
	if N_elements( site_name ) NE 1 then site_name = "NASA/GSFC"
	mosaic_spec.subtitles(0) = site_name + "  " + the_date()

  common contour_mosaic, Nhc, ArcSec_inch, set_scale
	if N_elements( Nhc ) NE 1 then Nhc = 0
	if N_elements( set_scale ) NE 1 then set_scale = 0

  common contour_options, TickLen, bitspix
	if N_elements( TickLen ) NE 1 then TickLen = -.02
	if N_elements( bitspix ) NE 1 then bitspix = 5

  common cursor_scale, cmin_y, cmax_y
	if N_elements( cmin_y ) NE 1 then cmin_y = 0
	if N_elements( cmax_y ) NE 1 then cmax_y = mosaic_spec.topval

  common adjct_map, color_map
	if N_elements( color_map ) LE 0 then color_map= bindgen( !D.table_size )

  common HC_color, grey_map, color_trans
	grey_map = reverse( bytscl( indgen( N_elements( color_map ) ) ) )

  common PS_Layout, xoff, yoff, xpap, ypap, Left, Right, Top, Bottom

	if N_elements( xoff ) LT 5 then begin

		xpap = [ 8.5, 11., 11., 13., 13. ]	;paper sizes:
		ypap = [ 11., 14., 17., 17., 19. ]
		nsiz = N_elements( xpap )
		xoff = replicate( 0.0, nsiz )	;for position on paper:
		yoff = replicate( 0.4, nsiz )
		Left = replicate( 1.4, nsiz )	;margins in inches...
		Right = replicate( 1.0, nsiz )
		Top = replicate( 1.6, nsiz )
		Bottom = replicate( 1.4, nsiz )

		color_trans = [ [ 1, 0, 0 ] ,$
				[ 0, 1, 0 ] ,$
				[ 0, .7, 1 ] ]
	   endif

	if (mosaic_spec.contour.NLev EQ 0) then begin
		mosaic_spec.contour.NLev = 11
		mosaic_spec.contour.Levels = $
			(mosaic_spec.max - mosaic_spec.min) * $
					findgen(11)/10 + mosaic_spec.min
	   endif

	if (mosaic_spec.contour_Log.NLev EQ 0) then begin
		maxm = aLog10( mosaic_spec.max )
		minm = aLog10( mosaic_spec.min > 0.1 )
		mosaic_spec.contour_Log.NLev = 11
		mosaic_spec.contour_Log.Levels = $
					(maxm-minm)* findgen(11)/10 + minm
	   endif

	if (mosaic_spec.options.show_contours) then $
					menu_cont = "No contours" $
				  else	menu_cont = "overlay contours"

	if (mosaic_spec.options.overlay) then $
				     menu_over = "No overlay of image" $
				else menu_over = "overlay image"

	if (mosaic_spec.options.show_axes) then $
				      menu_axes = "No axes" $
				 else menu_axes = "overlay axes"

	if (mosaic_spec.options.show_titles) then $
				      menu_titles = "No titles" $
				 else menu_titles = "overlay titles"

	if (mosaic_spec.options.show_marks) then $
				      menu_mark = "No marks" $
				 else menu_mark = "overlay marks"

	if (mosaic_spec.options.show_Labels) then $
				      menu_Labs = "No Labels" $
				 else menu_Labs = "overlay Labels"

	Ncall = N_elements( callers )

	if (Ncall LE 0) then  callers = ["calling routine"]

	menu_cont_p0 = ["Contour Options:"		,$
			" "				,$
			"return to " + callers		,$
			" "				]

	menu_cont_p1 = ["use Relative Pixels"		,$
			"use Relative Arcseconds"	,$
			"use Relative Arcminutes"	,$
			"use Relative Degrees"		,$
			"use Absolute R.A., DEC"	,$
			"plate scale"			,$
			" "				,$
			menu_over			,$
			menu_axes			,$
			menu_titles			,$
			menu_cont			,$
			" "				,$
			"magnify image window"		,$
			"zoom mosaic image"		,$
			" "				,$
			"change contour Levels"		,$
			"change scaling (Lin/Log)"	,$
			"change min/max of scale"	,$
			" "				,$
			"filter type"			,$
			"filter width"			,$
			" "				,$
			"CALIBRATE"			,$
			"set contour defaults"		]

	menu_cont_p2 = ["show fluxes"			,$
			" "				,$
			"mark or unmark sources"	,$
			menu_mark			,$
			"mark or delete Labels"		,$
			menu_Labs			,$
			" "				,$
			"enter title (new)"		,$
			"enter subtitle"		,$
			"add text to date line"		,$
			" "				,$
			"color tables"			,$
			"adjust colors"			,$
			" "				,$
			"redraw everything"		,$
			"save window into a file"	,$
			"fix arcsec per inch"		,$
			" "				,$
			"HARD-COPY"			,$
			" "				,$
			"SAVE mosaic and specs"		,$
			" "				,$
			" "				]

	if !D.name EQ "SUN" then begin
		menu_pause = ["pause (to use mouse)",replicate( " ", Ncall+2 ) ]
		menu_cont=[menu_cont_p0, menu_cont_p1, menu_pause, menu_cont_p2]
		check_menu_size, menu_cont
	 endif else menu_cont = [menu_cont_p0, menu_cont_p1, menu_cont_p2]

return, menu_cont
end