     	SUBROUTINE IFPLOT( XOP, YOP, IPF )
C
C  PROGRAMMER: R.S. ZHOU,	SEP-1986
C
C    	IPF =  2: DRAW TO (XOP,YOP)
C	IPF =  3: MOVE TO (XOP,YOP)
C	IPF = -3: REORIGIN AND MOVE TO (XOP,YOP)
C	IPF = -9: REORIGIN TO (XOP,YOP) ONLY
C
    	INCLUDE 'TEKLIB.CBS'
	SAVE IPP
C
C  QUIT ON CTRL/C...
C
     	IF( CTRL_C ) RETURN
C
C  START NEW PANEL UPON PEN-DOWN FOR POLYGON FILL...
C
    	IPN = IABS(IPF)
     	IF( ITM.EQ.1 .OR. IFP.EQ.0 .OR. IPN.EQ.9 ) GOTO 111
     	IF( IPP.EQ.3 .AND. IPN.EQ.2 ) THEN
     	    IF( IFF.EQ.0 ) THEN
     		IFF = 1
     		CALL IFFILL_INIT(1)
     	    ELSE
     		IF( NEW.NE.0 ) CALL IFFILL_INIT(1)
     	    ENDIF
     	ENDIF
C
C  CONVERT COORDINATES TO ABSOLUTE PLOTTER UNITS...
C
111	IF( XANG.NE.0.0 .OR. YANG.NE.0.0 ) THEN
     	    XPS = XOP*XCTH-YOP*YSTH
     	    YPS = XOP*XSTH+YOP*YCTH
     	ELSE
     	    XPS = XOP
     	    YPS = YOP
     	ENDIF
     	XPS = XPS*XSCL + XORS
     	YPS = YPS*YSCL + YORS
     	IF( ITM.EQ.1 .OR. IPN.EQ.9 ) GOTO 888
     	IXL = IXO+INT(FUNI*XPS)
     	IYL = IYO+INT(FUNI*YPS)
     	IF( IXL.LT.0 ) IXL = 0
     	IF( IYL.LT.0 ) IYL = 0
     	IF( ITM.EQ.2 ) THEN			!TEK-4100
C
C  SKIP PEN-UP ACTION IF NEW-PANEL POLYGON FILL IS ACTIVE...
C
     	IF( IPN.EQ.3.AND.IFP.NE.0.AND.IFF.NE.0.AND.NEW.NE.0 ) GOTO 888

     	    IF( IPL.GT.NBS-IPK-8 ) CALL IFINIT_DUMP
    	    IPB(IPL+1) = 27
    	    IPB(IPL+2) = 'L'
    	    IPL = IPL + 3
    	    IF( IPN.EQ.2 ) IPB(IPL) = 'G'
    	    IF( IPN.EQ.3 ) IPB(IPL) = 'F'
    	    CALL IFPACK_TEKXY( IXL, IYL )
    	ENDIF

     	IF( ITM.EQ.3 ) THEN			!REGIS
     	    IF( IPL.GT.NBS-IPK-12 ) CALL IFINIT_DUMP
    	    IPL = IPL + 1
    	    IF( IPN.EQ.2 ) IPB(IPL) = 'V'
    	    IF( IPN.EQ.3 ) IPB(IPL) = 'P'
    	    IPL = IPL + 1
    	    IPB(IPL) = '['
    	    CALL IFPACK_REGIS( IXL )
    	    IPL = IPL + 1
    	    IPB(IPL) = ','
     	    III = 530-IYL
     	    IF( III.GT.479 ) III = 479
    	    CALL IFPACK_REGIS( III )
    	    IPL = IPL + 1
    	    IPB(IPL) = ']'
    	ENDIF

888	IF( IDW.NE.0 ) THEN
     	    IF( NPPS.EQ.MPPS ) CALL IFPLOT_DUMP
     	    NPPS = NPPS + 1
     	    XPPS(NPPS) = XOP
     	    YPPS(NPPS) = YOP
     	    IPPS(NPPS) = IPF
     	ENDIF
     	IF( IPF.LT.0 ) THEN
     	    XORS = XPS
     	    YORS = YPS
     	ENDIF
	IPP = IPN

999	RETURN
    	END

     	SUBROUTINE IFPLOT_DUMP
C
C	THIS ROUTINE DUMPS THE "PLOT" BUFFER.
C
     	INCLUDE 'TEKLIB.CBS'

     	WRITE(IDF,1000) (XPPS(I),YPPS(I),IPPS(I),I=1,NPPS)
1000	FORMAT('PLOT:',<NPPS>(2F6.3,I2))
     	NPPS = 0

     	RETURN
     	END

     	SUBROUTINE IFPLOT_LAST( XPS, YPS )
C
C	THIS ROUTINE REPORTS THE LAST PEN LOCATION
C	RELATIVE TO ACTIVE GRAPH ORIGIN IN INCHES.
C
     	INCLUDE 'TEKLIB.CBS'

     	XPL = XSCL*(FLOAT(IXL-IXO)/FUNI-XORS)
     	YPL = YSCL*(FLOAT(IYL-IYO)/FUNI-YORS)
     	IF( XANG.NE.0.0 .OR. YANG.NE.0.0 ) THEN
     	    DET = XCTH*YCTH + XSTH*YSTH
     	    XPS = (XPL*YCTH+YPL*YSTH) / DET
     	    YPS = (YPL*XCTH-XPL*XSTH) / DET
     	ELSE
     	    XPS = XPL
     	    YPS = YPL
     	ENDIF

     	RETURN
     	END

