		// Plot Power and Phase Spectra of Alignment
		// and Angular Position Difference (APD)
		// and Direction of Mean Body (DMB)
		// and Systemic Direction on Mean Body (SDM)

		if (_is.AlDataExist && pAlFou != NULL &&
			  (PlotAlPow || PlotAlAmp || PlotAlPha))
		{
			 double a, b, m, Tg ;
			    int d  ;
			 b = pa->loAlOrd ;
			 d = pa->max_order_index ;
			 m = pa->Maxamp ;
			Tg = align->period ;  // grand period
			os = pa->OrderStep ;

//*******************************************************************
//
//			ALIGNMENT SPECTRA
//
//*******************************************************************

		 if (PlotAlPow)  // Alignment Power Spectrum
		 {
			 static long start ;

			for (     i = 0,
				  start = 0L ;
			         i <= d ; 
					 i++ )
			{
			 or = b + os * (double)i ; // this ought to be the true order

		      xp = (int)((double)wd * (or - lo_f) / fspan) + xlmar ;

			 if (xp >= D.left && xp <= D.right) // keep in bounds
			 {
			   start++ ;
			   SelectObject(hdc, greenPen) ;

			   a = pa->amp[i] ;

		// if we are also showing sin and cos amplitude spectra,
		
			if (PlotSinCos)	 // move the x-axis up to mid-plot height
			  yp = rcArc.bottom -
				   ((int)((double)ht * (m*m + a*a)/(2.0 * m*m)) + ylmar) ;
			else // leave it at the bottom of the plot
			  yp = rcArc.bottom -
				   ((int)((double)ht * a*a/(m*m)) + ylmar) ;

			   if (start == 1L)		// plot of first point is a move
				 MoveToEx(hdc, xp , yp, NULL) ;
			 else
				   LineTo(hdc, xp, yp) ;
			 }
			}
		 }

//*******************************************************************
		 if (PlotAlAmp)  // Alignment Amplitude spectrum
		 {
			 static long start ;

		 if (PlotSinCos) 
			 {	
				// we are showing sin and cos.
				// plot the x-axis at middle height

				 SelectObject(hdc, blackPen) ;
				 xp = xlmar ;
				 yp = rcArc.bottom - ((int)((double)ht / 2.0) + ylmar) ;
				 MoveToEx(hdc, xp, yp, NULL) ;
				 xp = wd + xlmar ;
				 LineTo(hdc, xp, yp) ;
			 }

			   SelectObject(hdc, dkgreenPen) ;
			for (     i = 0,
				  start = 0L ;
			         i <= d ; 
					 i++ )
			{
			 or = b + os * (double)i ; // this ought to be the true order

		      xp = (int)((double)wd * (or - lo_f)/fspan) + xlmar ;

			 if (xp >= D.left && xp <= D.right)
			 {
			   start++ ;

			   a = pa->amp[i] ;

			   if (PlotSinCos) // we are showing sin and cos: move amp plot up
			  yp = rcArc.bottom -
				  ((int)((double)ht * (a + m) /(2.0 * m)) + ylmar) ;
			  else			   // leave it at the bottom
			  yp = rcArc.bottom -
				  ((int)((double)ht * a / m) + ylmar) ;

			   if (start == 1L)
				 MoveToEx(hdc, xp , yp, NULL) ;
			 else
				   LineTo(hdc, xp, yp) ;
			 }
			}

			  SelectObject(hdc, dkgreenPen) ;

			 for ( i = 0 ; i < pa->Peaks ; i++ )
			 {
		      xp = (int)((double)wd * (pa->ordPeak[i] - lo_f)/fspan) + xlmar ;

			   if (PlotSinCos) // we are showing sin and cos: move plot up
			  yp = rcArc.bottom -
				  ((int)((double)ht * (pa->spcPeak[i] + m) /(2.0 * m)) + ylmar) ;
			  else			   // leave it at the bottom
			  yp = rcArc.bottom -
				  ((int)((double)ht * pa->spcPeak[i] / m) + ylmar) ;

			  //DrawMark(hWnd, xp, yp, 5, dkgreenPen) ;
			  Ellipse(hdc, xp - 2, yp - 2, xp + 2, yp + 2) ;
			//invisible rect. for detection of mouse presence
			  SetRect(&(pa->rcPeak[i]), xp - 3, yp - 3, xp + 3, yp + 3) ;
			 }

		if (PlotSinCos) // show the sine and cosine alignment spectra too
		{

			   SelectObject(hdc, redPen) ;
			for (     i = 0,
				  start = 0L ;
			         i <= d ; 
					 i++ )
			{
			 or = b + os * (double)i ; // this ought to be the true order

		      xp = (int)((double)wd * (or - lo_f)/fspan) + xlmar ;

			 if (xp >= xlmar && xp <= (xlmar + wd))
			 {
			   start++ ;

			   a = pa->Ac[i] ;

			  yp = rcArc.bottom -
				  ((int)((double)ht * (a + m) /(2.0 * m)) + ylmar) ;

			   if (start == 1L)
				 MoveToEx(hdc, xp , yp, NULL) ;
			 else
				   LineTo(hdc, xp, yp) ;
			 }
			}
		 
			   SelectObject(hdc, bluePen) ;
			for (     i = 0,
				  start = 0L ;
			         i <= d ; 
					 i++ )
			{
			 or = b + os * (double)i ; // this ought to be the true order

		      xp = (int)((double)wd * (or - lo_f)/fspan) + xlmar ;

			 if (xp >= xlmar && xp <= (xlmar + wd))
			 {
			   start++ ;

			   a = pa->Bs[i] ;

			  yp = rcArc.bottom -
				  ((int)((double)ht * (a + m) /(2.0 * m)) + ylmar) ;

			   if (start == 1L)
				 MoveToEx(hdc, xp , yp, NULL) ;
			 else
				   LineTo(hdc, xp, yp) ;
			 }
			}
		} // if (PlotSinCos)
		 
       } // End if (PlotAlAmp)

//*******************************************************************
		 if (PlotAlPha)   // Alignment phase spectrum
		 {
			 static long start ;

			   SelectObject(hdc, dkgreenPen) ;

			for (      i = 0,
				  oldang = pa->phase[0],
				   start = 0L ;
			          i <= d ;
				      i++ )
			{
			 or = b + os * (double)i ; // this ought to be the true order

		      xp = (int)((double)wd * (or - lo_f) / fspan) + xlmar ;

			 if (xp >= D.left && xp <= D.right)
			 {
		       static spill, oldxp, oldyp, ixp, iyp ;

			   start++ ;

			 newang = pa->phase[i] ;
			     yp = rcArc.bottom -
				  (int)((double)ht * newang / twopi + (double)ylmar ) ;
			   spill = 0 ;
		   if (!i) { oldxp = xp ; oldyp = yp ; oldang = newang ;}
		   if ((ang = oldang + adiff(newang, oldang)) > twopi)
			   spill = 1 ;
		   if  (ang < 0.0)
			   spill = 2 ;
		     transit = FullPhase(hdc, dkgreenPen,
							     oldang, newang,
							     spill,
								 xp, yp,
								 oldxp, oldyp,
								 D.top, D.bottom) ;
			 oldang = newang ;
			 oldxp = xp ;
			 oldyp = yp ;

			 if (start == 1L || transit)
				 MoveToEx(hdc, xp , yp, NULL) ;
			 else
				   LineTo(hdc, xp, yp) ;
			 }
			}

			// mark phase shifts at spectral peaks
			for ( i = 0 ; i < pa->Peaks ; i++)
			{
		      xp = (int)((double)wd * (pa->ordPeak[i] - lo_f)/fspan) + xlmar ;
			  yp = rcArc.bottom -
				   (int)((double)ht * pa->phaPeak[i] / twopi + (double)ylmar ) ;

			  DrawCross(hWnd, invert, xp, yp, 5, greenPen) ;
			}
		 } // End if (PlotAlPha)


	} // End of if (_is.AlDataExist .....
