     	SUBROUTINE LAYOUT_COPY( TEXT )
C
C  PROGRAMMER:  R.S. ZHOU
C		ALFRED UNIVERSITY, MARCH-1987
C
C	THIS ROUTINE MAKES COPIES OF THE PICKED LAYOUT SEGMENTS.
C
C	COMMAND SYNTAX: COPY #, px, py, Angle1, Angle2
C
C	Make # copies of the picked entries. #=0 implies 1 copy.
C	If Angle1 = 0.0, px, py are the offsets inches in x, y
C	between copies, or else copies are generated in circular
C	manner with incremental Angle1 around the pivot (px,py) and
C	Angle2 specifies the entry rotation about its own position.
C
C	Example: COPY 3 1 1 90 90<CR>
C
     	INCLUDE		'LAYOUT.CBS'
     	CHARACTER	TEXT*(*)
     	DIMENSION	RP(5), KP(5)

     	IF( NLC.EQ.MNN ) GOTO 999
C
C  DECODE COMMAND PARAMETERS...
C
     	NCH = IFMISC_NEXT( TEXT )
     	IF( NCH.EQ.0 ) THEN
     	    CALL LAYOUT_ERROR(3)
     	    RETURN
     	ELSE
    	    NCH = IFMISC_DECODE( TEXT, 5, RP, KP )
    	    IF( NCH.EQ.0 ) THEN
     		CALL LAYOUT_ERROR(2)
     		RETURN
     	    ENDIF
     	ENDIF
C
C  START COPYING...
C
     	NSP = RP(1)
     	IF( NSP.LT.1 ) NSP = 1
     	DO  IC = 1, NSP			!LOOP FOR NUMBER OF COPIES

     	IF( NLC.EQ.MNN ) GOTO 999
C
C  GET THE OFFSET FOR THIS COPY...
C
    	IF( RP(4).EQ.0.0 ) THEN
     	    XOFF = RP(2)*IC
     	    YOFF = RP(3)*IC
     	    ANG0 = 0.0
     	    ANG1 = 0.0
     	ELSE
    	    XOFF = RP(2) + XORS
    	    YOFF = RP(3) + YORS
     	    ANG0 = IC*AMOD( RP(4), 360.0 )
     	    ANG1 = IC*AMOD( RP(5), 360.0 )
        ENDIF
C
C  GENERATE THE COPY...
C
     	CALL LAYOUT_COPY_ONE( XOFF, YOFF, ANG0, ANG1 )

    	ENDDO
     	RETURN
999	CALL LAYOUT_ERROR(12) 	!MAX ENTRY COUNT HIT
     	RETURN
     	END

    	SUBROUTINE LAYOUT_COPY_ONE( XADD, YADD, ANGLE0, ANGLE1 )
C
C  PROGRAMMER: R.S. ZHOU		JUNE-1986
C
C	THIS ROUTINE MAKES ONE COPY OF THE PICKED SEGMENTS
C	WITH AN OFFSET TO XADD,YADD.
C
    	INCLUDE		'LAYOUT.CBS'
     	LOGICAL		FIRST
     	DIMENSION	IR(9)
     	DATA		IR/ 6, 6, 6, 6, 5, 6, 4, 5, 6 /

    	XAD = XADD
    	YAD = YADD
     	AN0 = ANGLE0
     	AN1 = ANGLE1

    	DO  555 I= 1, NLG
    	    IF( NLC.EQ.MNN ) GOTO 111
    	    IS = NLS(I)
     	    FIRST = .TRUE.
     	    DO  444 J= 1, NLC
     		IF( NSN(J).NE.IS ) GOTO 444
     		NLC = NLC + 1
     		IDD = NID(J)
     		NID(NLC) = IDD
     		PEN(NLC) = PEN(J)
     		IF( AN0.EQ.0.0 ) THEN
     		    XPS = P00(1,J) + XAD
     		    YPS = P00(2,J) + YAD
     		ELSE
     		    XPS = P00(1,J)
     		    YPS = P00(2,J)
     		    ANGLE = 0.0
     		    DIST = SQRT((XPS-XAD)**2+(YPS-YAD)**2)
     		    IF( DIST.GT.0.0 ) THEN
     			ANGLE = ASIN((YPS-YAD)/DIST)/D2R
     			IF(XPS.LT.XAD) ANGLE = 180.0-ANGLE
     		    ENDIF
     		    ANGLE = D2R*AMOD(ANGLE+AN0,360.0)
     		    XPS = XAD + DIST*COS(ANGLE)
     		    YPS = YAD + DIST*SIN(ANGLE)
     		ENDIF
     		P00(1,NLC) = XPS
     		P00(2,NLC) = YPS
     		DO  K= 3, MNS
     		    P00(K,NLC) = P00(K,J)
     		ENDDO
     		IF( AN1.NE.0.0 ) THEN
     		    K = IR(IDD)
     		    P00(K,NLC) = P00(K,NLC) + AN1
     		ENDIF
     		IF( IDD.EQ.8 ) THEN			!TEXT ENTRY
     		    IF( NTX.EQ.MNT ) GOTO 222
     		    NTX = NTX + 1
     		    LDT(NTX) = NLC
     		    IDD = LAYOUT_LDT(J)
     		    TXT(NTX) = TXT(IDD)
     		ENDIF
     		IF( IDD.EQ.9 .AND. P00(3,NLC).NE.2.0 ) THEN	!LINE ENTRY
     		    IF( NCU.EQ.MNC ) GOTO 333
     		    NCU = NCU + 1
     		    LID(NCU) = NLC
     		    IDD = LAYOUT_LID(J)
     		    DO  K= 1, MNP
     			XSC(K,NCU) = XSC(K,IDD)
     			YSC(K,NCU) = YSC(K,IDD)
     		    ENDDO
     		ENDIF
     		IF( NFL(J).EQ.0 ) THEN
     		    NFL(NLC) = 0
     		    CALL LAYOUT_DRAW( NLC, 1 )
     		    GOTO 555
     		ELSE IF( NFG.EQ.MNF ) THEN
     		    NFL(NLC) = 0
     		    CALL LAYOUT_DRAW( NLC, 1 )
     		    CALL LAYOUT_ERROR( 17 )
     		    GOTO 555
     		ELSE
     		    IF( FIRST ) THEN
     			FIRST = .FALSE.
     			NFG = NFG + 1
     			KSG = KSG + 1
     			CALL IFSEG_PIVOT( XPS, YPS )
     			CALL IFSEG_OPEN( KSG )
     			NFP(NFG) = NFP(NFL(J))
     			CALL IFFILL( NFG )
     		    ENDIF
     		    CALL LAYOUT_DRAW( -NLC, 0 )
     		    NFL(NLC) = NFG
     		    NSN(NLC) = KSG
     		ENDIF
444	    CONTINUE
     	    IF( .NOT.FIRST ) THEN
     		CALL IFFILL( 0 )
     		CALL IFSEG_OPEN( 0 )
     	    ENDIF
555	CONTINUE
     	GOTO 999
111	CALL LAYOUT_ERROR(12)			!MAX ENTRY COUNT HIT
     	GOTO 999
222	NLC = NLC - 1
     	CALL LAYOUT_ERROR(15)			!MAX TEXT ENTRY COUNT HIT
     	GOTO 999
333	NLC = NLC - 1
     	CALL LAYOUT_ERROR(16)			!MAX LINE ENTRY COUNT HIT

999	CALL IFINIT_DUMP
     	IF( KSG.GT.2*MNN ) CALL LAYOUT_PACK_SEG	!REPACK SEGMENT NUMBERS
     	RETURN
    	END

