      SUBROUTINE ELLPLOT
C PLOTS MAJOR AND MINOR AXES, CENTER, AND ELLIPSE ITSELF ON SCREEN

      IMPLICIT UNDEFINED (A-Z)
      INCLUDE 'PARAMETR.INC'
      INCLUDE 'ELLIPSE.INC'

      REAL*4 RALINE(2),DECLINE(2),RA4(MAXPTS),DEC4(MAXPTS)
      INTEGER*4 I

C      WRITE(PR,*) ' ELLPLOT: '

C CHECK FOR VARIOUS STATES
      IF      (STATE.EQ.'N' .OR. TRUFIT)     THEN   ! NO PLOTTING
          GO TO 100

      ELSE IF (STATE.EQ.'A')   THEN                 ! PLOT MAJ. AX. POINT
        CALL PGSCI(2)                               ! IN RED
        CALL PGPOINT (1, ARA(1), ADEC(1), 3)
        CALL PGPTEXT (ARA(1), ADEC(1), 0., 0., 'A1')

      ELSE IF (STATE.EQ.'B')   THEN                 ! PLOT MIN. AX. POINT
        CALL PGSCI(7)                               ! IN YELLOW
        CALL PGPOINT (1, BRA(1), BDEC(1), 3)
        CALL PGPTEXT (BRA(1), BDEC(1), 0., 0., 'B1')

      ELSE IF (STATE.EQ.'C')   THEN                 ! PLOT CENTER
        CALL PGSCI(2)                               ! IN RED
        CALL PGPOINT (1, CRA,    CDEC,    3)
        CALL PGPTEXT (CRA,    CDEC,    0., 0., 'C' )

      ELSE IF (STATE.EQ.'AB')  THEN                 ! PLOT TWO POINTS
        CALL PGSCI(2)                               ! IN RED
        CALL PGPOINT (1, ARA(1), ADEC(1), 3)
        CALL PGPTEXT (ARA(1), ADEC(1), 0., 0., 'A1')
        CALL PGSCI(7)                               ! AND IN YELLOW
        CALL PGPOINT (1, BRA(1), BDEC(1), 3)
        CALL PGPTEXT (BRA(1), BDEC(1), 0., 0., 'B1')

      ELSE IF (STATE.EQ.'AC')  THEN                 ! PLOT MAJ AXIS, CTR
        CALL PGSCI(2)                               ! IN RED
        CALL PGPOINT (2, ARA,    ADEC,    3)
        CALL PGPTEXT (ARA(1), ADEC(1), 0., 0., 'A1')
        CALL PGPTEXT (ARA(2), ADEC(2), 0., 0., 'A2')
        CALL PGLINE  (2, ARA, ADEC)
        CALL PGPOINT (1, CRA,    CDEC,    3)        ! CENTER
        CALL PGPTEXT (CRA,    CDEC,    0., 0., 'C' )

      ELSE IF (STATE.EQ.'BC')  THEN                 ! PLOT MIN AXIS, CTR
        CALL PGSCI(7)                               ! IN YELLOW
        CALL PGPOINT (2, BRA,    BDEC,    3)
        CALL PGPTEXT (BRA(1), BDEC(1), 0., 0., 'B1')
        CALL PGPTEXT (BRA(2), BDEC(2), 0., 0., 'B2')
        CALL PGLINE  (2, BRA, BDEC)
        CALL PGSCI(2)                               ! CENTER IN RED
        CALL PGPOINT (1, CRA,    CDEC,    3)
        CALL PGPTEXT (CRA,    CDEC,    0., 0., 'C' )

      ELSE IF (STATE.EQ.'ABC')   THEN               ! PLOT ELLIPSE, ALL PTS
        CALL PGSCI(2)                               ! MAJ AXIS IN RED
        CALL PGPOINT (2, ARA,    ADEC,    3)
        CALL PGPTEXT (ARA(1), ADEC(1), 0., 0., 'A1')
        CALL PGPTEXT (ARA(2), ADEC(2), 0., 0., 'A2')
        CALL PGLINE  (2, ARA, ADEC)
        CALL PGPOINT (1, CRA,    CDEC,    3)        ! CENTER
        CALL PGPTEXT (CRA,    CDEC,    0., 0., 'C' )
        CALL PGSCI(7)                               ! MIN AXIS IN YELLOW
        CALL PGPOINT (2, BRA,    BDEC,    3)
        CALL PGPTEXT (BRA(1), BDEC(1), 0., 0., 'B1')
        CALL PGPTEXT (BRA(2), BDEC(2), 0., 0., 'B2')
        CALL PGLINE  (2, BRA, BDEC)
        CALL PGSCI(2)                               ! ELLIPSE IN RED
        CALL CALCELL                                ! CALCULATE ELLIPSE
        CALL PGLINE  (ELLPTS-4,RA_ELL4,DEC_ELL4)    ! AND PLOT IT

      END IF

  100 CONTINUE
      IF (TRUFIT .AND. DISP_ORB) THEN           ! IF TRUE ORBIT HAS BEEN FIT
        CALL PGSCI(7)                           ! PLOT IT IN YELLOW
        IF(.NOT.DISP_CURV) THEN
          CALL PGPOINT (ORBPTS,RA_MOD,DEC_MOD,SYM_ORB)
        ELSE
          CALL PGSLW (ORBLINWD)
          CALL PGSLS (ORBLINTY)
          CALL PGLINE (ORBPTS,RA_MOD,DEC_MOD)
          CALL PGSLW (LINEWD)
          CALL PGSLS (1)
        END IF
      END IF

      RETURN
      END

