	SUBROUTINE GSDRW2(X0,Y0,IVIS0,X1,Y1,IVIS1)
C
C	CLIP LINE TO CLIPPING BOX.   PASS ON ONLY VISIBLE LINE SEGMENTS TO
C	 GSDRW3 TO BE DRAWN IN THE CURRENT LINE TYPE.   THIS SUBROUTINE ALSO
C	 WORRIES ABOUT WHETHER THE GRAPHICS DEVICE WILL REQUIRE A "MOVE"
C	 BEFORE THE "DRAW" IS DONE.
C
	COMMON /GCCLIP/ XCM0, XCM1, YCM0, YCM1
	LOGICAL*1 LINILT, LPOSND
	COMMON /GCLTYP/ ILNTYP, DLEFT, DIST(4,3), LINILT, LPOSND
C
	LOGICAL*1 LDID1
C
D	TYPE *,'CLIPPING (',X0,',',Y0,')  IVIS=',IVIS0
D	TYPE *,' TO (',X1,',',Y1,')  IVIS=',IVIS1
	IF (IAND(IVIS0,IVIS1) .NE. 0) RETURN
	IF (IVIS0 .EQ. 0) GO TO 10
		LPOSND = .FALSE.
		LINILT = .TRUE.
10	CONTINUE
C
C	CALCULATE THE NUMBER OF CLIPS NECESSARY
C
	NCLIPS = 0
	IF (IVIS0 .NE. 0) NCLIPS = 1
	IF (IVIS1 .NE. 0) NCLIPS = NCLIPS + 1
	IF (NCLIPS .NE. 0) GO TO 100
C
C	LINE TOTALLY VISIBLE, JUST DRAW IT
C
	CALL GSDRW3(X0,Y0,X1,Y1)
	RETURN
C
C	FIND THE INTERSECTION(S) WITH THE CLIPPING BOX EDGES
C
100	CONTINUE
D	TYPE *,'NCLIPS=',NCLIPS
	LDID1 = .FALSE.
	IST = 1
	DX = X1-X0
	IF (DX .EQ. 0.0) IST = 3
	IFN = 4
	DY = Y1-Y0
	IF (DY .EQ. 0.0) IFN = 2
	IF (IST .GT. IFN) RETURN
	IVISC = IOR(IVIS0,IVIS1)
	IBIT = 2**(IST-1)
D	TYPE *,'IST=',IST,'   IFN=',IFN
	DO 210 I = IST, IFN
	IF (IAND(IVISC,IBIT) .EQ. 0) GO TO 200
	IF (I .GT. 2) GO TO 110
		XI = XCM0
		IF (I .EQ. 2) XI = XCM1
		YI = Y0 + (XI-X0)*DY/DX
		IF (YI .LT. YCM0 .OR. YI .GT. YCM1) GO TO 200
		GO TO 120
110	    CONTINUE
		YI = YCM0
		IF (I .EQ. 4) YI = YCM1
		XI = X0 + (YI-Y0)*DX/DY
D		TYPE *,'Y INTERSECTION',XI,YI
		IF (XI .LT. XCM0 .OR. XI .GT. XCM1) GO TO 200
120	CONTINUE
C
C	GOT AN INTERSECTION.   IF IT'S THE ONLY ONE, THE DRAW THE LINE.
C
	IF (NCLIPS .GT. 1) GO TO 140
		IF (IVIS0 .EQ. 0) GO TO 130
			CALL GSDRW3(XI,YI,X1,Y1)
			RETURN
130		   CONTINUE
			CALL GSDRW3(X0,Y0,XI,YI)
			RETURN
140	    CONTINUE
C
C	TWO CLIPS NECESSARY.   IF WE ALREADY HAVE ONE, DRAW THE DOUBLE CLIPPED
C	 LINE, ELSE SAVE FIRST CLIP AND WAIT FOR LAST.
C	 NOTE, IF DOUBLE CLIPPED, IT DOESN'T MATTER IN WHICH DIRECTION IT
C	 IS DRAWN.
C
		IF (.NOT. LDID1) GO TO 180
			CALL GSDRW3(X2,Y2,XI,YI)
			RETURN
180		    CONTINUE
			X2 = XI
			Y2 = YI
			LDID1 = .TRUE.
200		CONTINUE
	IBIT = 2*IBIT
210	CONTINUE
C
C	SEGMENT IS NOT VISIBLE IF WE DROP THRU TO HERE
C
	RETURN
	END
