PRO Shift_Plot, x, status, INTERACTIVE = interactive

;+
; NAME
; 	 Shift_Plot
; PURPOSE
;	Shifts a plot by a given constant, in x-direction,
;	left for negative
;	values, right for positive values. This procedure
;	is a part of the mdisp analyser.
; CATEGORY:
;	1D
; CALLING SEQUENCE:
;	Shift_Plot, x, [ status ]
; INPUT:
;	x: the x axis which will be shifted. Can be 1D or 2D.
; OUTPUTS:
;	x: the shifted x-axis.
;	status: 'Done' or 'Not Done'
; KEYWORD:
;	/INTERACTIVE: when present, the plot is
;	displayed and the user defines the shift term by giving
;	a reference point and its new placement in the window.
; SIDE EFFECTS:
;	The terminal window is used.
; -
; MODIFICATION HISTORY
;	Created: June 91, A.Csillaghy


IF NOT Keyword_Set(INTERACTIVE) THEN $
  Read_Test,'Please enter the  x-shift ',0.0, sh $
ELSE IF !d.name EQ 'X' THEN BEGIN
  plotWin = !d.window
  msgWinNr = WMesg('Click on the x-reference point  ', $
	'Shift Plots', 200, 500 )
  WSet, plotWin
  Cursor, xOld, dummy, /UP
  WDelete, msgWinNr
  msgWinNr = WMesg('Click on the new x-point  ', $
	'Shift Plots', 200, 500 )
  WSet, plotWin
  Cursor, xNew, dummy, /UP
  WDelete, msgWinNr
  sh = xNew - xOld
  msgWinNr = WMesg('The shift distance is:' + StrTrim(sh,2), $
	'Shift Plots', 200, 500 )
  Wait, 3
  WDelete, msgWinNr
ENDIF ELSE BEGIN
  Print, $
    'Move the cursor to the reference point and press <return>'
  Cursor, xOld, dummy
  Print, $
    'Move the cursor to the new x-point and press <return>....'
  Cursor, xNew, dummy
  sh = xNew - xOld
  Print, 'The shift distance is '+StrTrim(sh,2)
  Wait, 5
ENDELSE
  
IF N_Elements(sh) NE 0 THEN BEGIN
  x = x + sh 
  status = "Done"
ENDIF ELSE status = "Not Done"

END
