    	SUBROUTINE IFBOXS( XOP, YOP, BARL, BARH, BARW, ANGLE )
C
C  PROGRAMMER: R.S. ZHOU		FEB-1986
C
C  	THIS ROUTINE DRAWS A BAR/BOX WITH ROUND CORNERS.
C
C	XOP ------- CENTER OF BAR IN INCHES (X).
C	YOP ------- CENTER OF BAR IN INCHES (Y).
C	BARL ------ BAR LENGTH IN INCHES IN X-AXIS.
C	BARH ------ BAR HEIGHT IN INCHES IN Y-AXIS.
C	BARW ------ BAR BORDER WIDTH IN INCHES.
C	ANGLE ----- ROTATION ANGLE OF BAR IN DEGREES.
C
     	INCLUDE 'TEKLIB.CBS'

     	IWD = IDW
     	IF( ABS(BARL).LT.0.05 .OR. ABS(BARH).LT.0.05 ) RETURN
     	IF( ITM.EQ.1 ) GOTO 888
C
C  INITIALIZE...
C
     	IDW = 0
     	XPS = XOP
     	YPS = YOP
     	RD1 = 0.5*ABS(BARL)
     	RD2 = 0.5*ABS(BARH)
     	WID = ABS(BARW)
     	IF( WID.GE.RD1 .OR. WID.GE.RD2 ) WID = 0.0
     	ANG = AMOD( ANGLE, 360.0 )
C
C  MOVE ORIGIN TO (XPS,YPS) ...
C
     	CALL IFPLOT( XPS, YPS, -9 )
C
C  SET ROTATION IF AT ALL...
C
     	IF( ANG.NE.0.0 ) THEN
     	    ANGX = XANG
     	    ANGY = YANG
     	    CALL IFROTA( ANG+XANG, ANG+YANG )
     	ENDIF
C
C  GET THE CORNER RADIUS...
C
111	IF( RD1.LT.RD2 ) THEN
     	    CRAD = 0.4*RD1
     	    IF( CRAD.LT..05 ) CRAD = .05
     	    IF( CRAD.GT.RD1 ) CRAD = RD1
     	ELSE
     	    CRAD = 0.4*RD2
     	    IF( CRAD.LT..05 ) CRAD = .05
     	    IF( CRAD.GT.RD2 ) CRAD = RD2
     	ENDIF
C
C  START THE DRAWING...
C
     	CALL IFPLOT( RD1,  0.0, 3 )
     	IF( CRAD.LT.RD2 ) CALL IFPLOT( RD1, RD2-CRAD, 2 )
     	CALL IFBOXS_ARC( RD1-CRAD, RD2-CRAD, CRAD, 0.0  )
     	IF( CRAD.LT.RD1 ) CALL IFPLOT( CRAD-RD1, RD2, 2 )
     	CALL IFBOXS_ARC( CRAD-RD1, RD2-CRAD, CRAD, 90.0 )
     	IF( CRAD.LT.RD2 ) CALL IFPLOT( -RD1, CRAD-RD2, 2 )
     	CALL IFBOXS_ARC( CRAD-RD1, CRAD-RD2, CRAD, 180.0 )
     	IF( CRAD.LT.RD1 ) CALL IFPLOT( RD1-CRAD, -RD2, 2 )
     	CALL IFBOXS_ARC( RD1-CRAD, CRAD-RD2, CRAD, 270.0 )
     	IF( CRAD.LT.RD2 ) CALL IFPLOT( RD1, 0.0, 2 )

     	IF( WID.EQ.0.0 ) GOTO 222
     	RD1 = RD1 - WID
     	RD2 = RD2 - WID
     	WID = 0.0
     	GOTO 111
C
C  RESTORE...
C
222	IF( ANG.NE.0.0 ) CALL IFROTA( ANGX, ANGY )
     	CALL IFPLOT( -XOP, -YOP, -9 )

888	IF( IWD.NE.0 ) THEN
     	    IF( NPPS.GT.0 ) CALL IFPLOT_DUMP
     	    WRITE(IDF,1000) BARL,BARH,BARW, XOP,YOP,ANGLE
     	ENDIF
1000	FORMAT('BOXS:',6F8.3)

     	IDW = IWD

999	RETURN
    	END

     	SUBROUTINE IFBOXS_ARC( XPS, YPS, RAD, ANS )
C
C	THIS ROUTINE DRAWS AN ARC OF A BOX.
C
    	PARAMETER D2R= 0.17453292E-1

     	XPP = XPS
     	YPP = YPS
     	ANG = ANS
     	RDD = RAD
     	DO I=1, 9
     	   ANG = ANG + 10.0
     	   XOP = RDD*COS(ANG*D2R) + XPP
     	   YOP = RDD*SIN(ANG*D2R) + YPP
     	   CALL IFPLOT( XOP, YOP, 2 )
     	ENDDO
     	RETURN
     	END

