home *** CD-ROM | disk | FTP | other *** search
- Procedure BreakLine;
- {
- (Windows version)
- ⌐1996, Diehl Graphsoft, Inc.
- Developed by Tom Urie
-
- This procedure creates a break line.
- }
- LABEL 99;
- CONST
- A1C=0.25; {Length of zig-zag for type #1}
- f=0.25; {Ratio of zig-zag to length of line for type #2}
- Alpha=15; {Angle of zig-zag relative to line}
- LDivC=1.5; {Used to determine the number of zig-zags for type #3}
- VAR
- A,A1,x1,y1,x2,y2,xt,yt,Theta,Theta2,L,L1,LDiv,LScale : REAL;
- i,NDiv,Type : INTEGER;
- Abort : BOOLEAN;
- LayerH : HANDLE;
- UPI,SF : REAL;
- Fmt : INTEGER;
- UM,UM2 : STRING;
- UName,DA : LONGINT;
-
- Procedure Dialog;
- VAR
- Width,x1,y1,x2,y2,px1,px2,px3,px4,py1,py2 : INTEGER;
-
- Procedure AlignScr(Width:INTEGER; VAR x1,x2:INTEGER);
- VAR
- scrx1,scry1,scrx2,scry2:INTEGER;
- BEGIN
- GetScreen(scrx1,scry1,scrx2,scry2);
- x1:=((scrx1+scrx2) div 2)-(Width div 2);
- x2:=x1+Width;
- END;
-
- Procedure MakeDialog;
- CONST
- y1=100;
- scnh=160; scnw=230;
- h=30;
- BEGIN
- AlignScr(scnw,x1,x2);
- y2:=y1+scnh;
- px3:=(scnw div 2) - 70;
- px4:=(scnw div 2) - 10;
- px1:=(scnw div 2) + 10;
- px2:=(scnw div 2) + 70;
- py1:=scnh-40;
- py2:=scnh-20;
- BeginDialog(1,1,x1,y1,x2,y2);
- AddButton('OK',1,1,px3,py1,px4,py2);
- AddButton('Cancel',2,1,px1,py1,px2,py2);
- AddField('Type:',5,1,20,40-h,185,55-h);
- AddButton('Single - fixed size',6,3,20,65-h,160,80-h);
- AddButton('Single - proportional',7,3,20,90-h,175,105-h);
- AddButton('Multiple - fixed size',8,3,20,115-h,173,130-h);
- EndDialog;
- END;
-
- BEGIN
- MakeDialog;
- END;
-
- Procedure GetInfo;
- VAR
- Item,RFlag1 : INTEGER;
- Done : BOOLEAN;
-
- BEGIN
- Done:=FALSE;
- Abort:=FALSE;
- Type:=1;
- RFlag1:=6;
- GetDialog(1);
- SetTitle('Break Line');
- SetItem(RFlag1,TRUE);
- REPEAT
- DialogEvent(Item);
- IF Item=1 THEN
- Done:=TRUE;
- IF Item=2 THEN BEGIN
- Done:=TRUE;
- Abort:=TRUE;
- END;
- IF (Item > 5) AND (Item < 9) THEN BEGIN
- SetItem(RFlag1,FALSE);
- SetItem(Item,TRUE);
- RFlag1:=Item;
- Type:=Item-5;
- END;
- UNTIL Done;
- ClrDialog;
- END;
- {
- Main Program
- }
- BEGIN
- DselectAll;
- AngleVar;
- Dialog;
- SetCursor(ArrowC);
- GetInfo;
- IF Abort THEN GOTO 99;
- {
- Get units per inch and layer scale
- }
- GetUnits(UName,DA,Fmt,UPI,UM,UM2);
- LayerH:=ActLayer;
- LScale:=GetLScale(LayerH);
- {
- Adjust constants for units and scale
- }
- A1:=A1C*LScale*UPI;
- LDiv:=LDivC*LScale*UPI;
- {
- Get the end points of the line and determine length and angle
- }
- GetLine(x1,y1,x2,y2);
- IF (x1=x2) AND (y1=y2) THEN BEGIN
- Sysbeep;
- GOTO 99;
- END;
- L:=Sqrt((y2-y1)^2 + (x2-x1)^2);
- IF x2 <> x1 THEN
- Theta:=Rad2Deg(ArcTan((y2-y1)/(x2-x1)))
- ELSE IF y2 > y1 THEN
- Theta:=90
- ELSE Theta:=-90;
- IF x2 < x1 THEN BEGIN
- xt:=x1; yt:=y1;
- x1:=x2; y1:=y2;
- x2:=xt; y2:=yt;
- END;
- IF Type=2 THEN
- A:=f*L
- ELSE
- A:=A1;
- IF Type=3 THEN
- NDiv:=L/LDiv
- ELSE
- NDiv:=2;
- L1:=(L-2*(NDiv-1)*A*Tan(Deg2Rad(Alpha)))/NDiv;
- MoveTo(x1,y1);
- Relative;
- FOR i:=1 TO NDiv-1 DO BEGIN
- Line(L1,#Theta);
- Line(A,#(Theta-90));
- Line(2*A/Cos(Deg2Rad(Alpha)), #(90+Theta-Alpha));
- Line(A,#(Theta-90));
- END;
- Line(L1,#Theta);
- Group;
- 99:END;
-
- Run(BreakLine);
-