      SUBROUTINE POINTPLT
C PLOTS POINTS, ERROR BARS, AND CALCULATED POINTS ON THE SCREEN

      IMPLICIT UNDEFINED (A-Z)
      INCLUDE 'PARAMETR.INC'
      INCLUDE 'ELLIPSE.INC'
      REAL*4   RA4(MAXPTS),DEC4(MAXPTS)          ! FOR PGPOINT
      REAL*4   RA_EST4(MAXPTS),DEC_EST4(MAXPTS)  ! FOR PGPOINT
      REAL*4   RALINE(2),DECLINE(2)              ! FOR PGPLINE
      INTEGER*2  I, J

D     WRITE(PR,*) ' POINTPLT:  NPTS = ', NPTS

C PLOT THE ERROR BARS
      IF (DISP_ERR) THEN
        CALL PGSLW(ERRLINWD)
        CALL PGSLS(ERRLINTY)
        DO I = 1, NPTS
          IF (DELETE(I)) THEN
              IF(SHOWDEL) THEN
                  CALL PGSCI(4)         ! BLUE ERROR BARS IF DELETED
              ELSE                      !       --- OR ---
                  CALL PGSCI(0)         ! BLACK ERROR BARS IF DELETED
              END IF
          ELSE
              CALL PGSCI(3)             ! OTHERWISE, GREEN ERROR BARS
          END IF
          DO J = 1, 2
              RADRA1(J)   = RADRA(J,I)
              DECDRA1(J)  = DECDRA(J,I)
          END DO     
          CALL PGLINE(2,RADRA1,DECDRA1)
          DO J = 1, 2
              RADDEC1(J)  = RADDEC(J,I)
              DECDDEC1(J) = DECDDEC(J,I)
          END DO
          CALL PGLINE(2,RADDEC1,DECDDEC1)
        END DO
        CALL PGSLW(LINEWD)
        CALL PGSLS(1)
      END IF

C CONNECT OBSERVED POINTS WITH CALCULATED POSITIONS, IF FIT HAS BEEN 
C DONE

      IF (ELLFIT .AND. .NOT.TRUFIT) THEN
          CALL PGSCI(2)                   ! RED
          DO I = 1, NPTS
              RALINE(1) = RA_EST(I)
              RALINE(2) = RA(I)
              DECLINE(1) = DEC_EST(I)
              DECLINE(2) = DEC(I)
              IF (.NOT.DELETE(I) .OR. SHOWDEL) THEN
                  CALL PGLINE(2,RALINE,DECLINE)
              END IF
          END DO
      END IF
      IF (TRUFIT .AND. DISP_CALC) THEN
          CALL PGSCI(2)                   ! RED
          CALL PGSLW(O_CLINWD)
          CALL PGSLS(O_CLINTY)
          DO I = 1, NPTS
              RALINE(1) = R_EST(I)*SIN(THETA_EST(I))
              RALINE(2) = RA(I)
              DECLINE(1) = R_EST(I)*COS(THETA_EST(I))
              DECLINE(2) = DEC(I)
              IF (.NOT.DELETE(I) .OR. SHOWDEL) THEN
                  CALL PGLINE(2,RALINE,DECLINE)
              END IF
          END DO
          CALL PGSLW(LINEWD)
          CALL PGSLS(1)
      END IF

C PLOT THE DATA POINTS 
      CALL PGSCI(1)                     ! 1 = WHITE
      DO I = 1, NPTS
          IF (.NOT.DELETE(I).OR.SHOWDEL) THEN  ! UNDELETED POINTS IN 
              RA4(I)     = RA(I)               ! WHITE
              DEC4(I)    = DEC(I)
              CALL PGPOINT(1,RA4(I),DEC4(I),SYM_DAT)   
          END IF
      END DO

C PLOT CALCULATED POSITIONS OF OBSERVED POINTS IF FIT HAS BEEN DONE
      IF (ELLFIT .AND. .NOT.TRUFIT) THEN
          CALL PGSCI(7)                   ! YELLOW
          DO I = 1, NPTS
              RA_EST4(I) = RA_EST(I)
              DEC_EST4(I)= DEC_EST(I)
              IF (.NOT.DELETE(I) .OR. SHOWDEL) THEN
                  CALL PGPOINT(1,RA_EST4(I),DEC_EST4(I),9)
                  CALL PGPTEXT(RA_EST4(I),DEC_EST4(I),0.,0.,
     1                         ' '//CHAR(I+64))
              END IF
          END DO
      END IF
      IF (TRUFIT .AND. DISP_CALC) THEN
          CALL PGSCI(2)                   ! YELLOW
          DO I = 1, NPTS
              RA_EST4(I) = R_EST(I)*SIN(THETA_EST(I))
              DEC_EST4(I)= R_EST(I)*COS(THETA_EST(I))
              IF (.NOT.DELETE(I) .OR. SHOWDEL) THEN
                  CALL PGPOINT(1,RA_EST4(I),DEC_EST4(I),SYM_MOD)
              END IF
          END DO
      END IF

      RETURN
      END

