home *** CD-ROM | disk | FTP | other *** search
- Procedure DowelPin;
- {
- (Windows version)
- ⌐1996, Diehl Graphsoft, Inc.
- Developed by Tom Urie
-
- This procedure draws a dowel pin.
- }
-
- LABEL 20,30,99;
- CONST
- Bk=0.97; {Used to calculate chamfer}
- Theta=15; {Angle of chamfer.}
- CF=0.33333; {Used to determind radius of round end.}
- VAR
- A1,A2,B,C,D,L,SF,x0,y0 : REAL;
- View : INTEGER;
- RFlag : ARRAY[1..2] OF INTEGER;
- Abort,OK,Inch : BOOLEAN;
- UPI : REAL;
- Fmt : INTEGER;
- UM,UM2 : STRING;
- UName,DA : LONGINT;
-
- Procedure PinDialog;
- {
- This procedure defines the dialog box.
- }
- 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=135; scnw=280;
- h=30;
- BEGIN
- AlignScr(scnw,x1,x2);
- y2:=y1+scnh;
- px1:=scnw-160;
- px2:=scnw-100;
- px3:=scnw-80;
- px4:=scnw-20;
- py1:=scnh-40;
- py2:=scnh-20;
-
- BeginDialog(1,1,x1,y1,x2,y2);
- AddButton('OK',1,1,px1,py1,px2,py2);
- AddButton('Cancel',2,1,px3,py1,px4,py2);
- AddField('Diameter:',4,1,20,45-h,90,60-h);
- AddField('',5,2,100,45-h,150,60-h);
- AddField('Length:',6,1,20,80-h,80,95-h);
- AddField('',7,2,100,80-h,150,95-h);
- AddField('View:',8,1,210,40-h,265,55-h);
- AddButton('Top',9,3,210,80-h,250,95-h);
- AddButton('Side',10,3,210,60-h,260,75-h);
- AddField('',12,1,160,45-h,185,60-h);
- AddField('',13,1,160,80-h,185,95-h);
- EndDialog;
- END;
-
- BEGIN
- MakeDialog;
- END;
-
- Procedure SetRButton(i,Item : INTEGER);
- BEGIN
- IF RFlag[i] <> Item THEN BEGIN
- SetItem(RFlag[i],FALSE);
- SetItem(Item,TRUE);
- RFlag[i]:=Item;
- END;
- END;
-
- Procedure GetInfo;
- {
- This procedure displays the dialog box and retrieves the information.
- }
- LABEL 10,99;
- VAR
- Done:Boolean;
- Item:Integer;
-
- BEGIN
- View:=2;
- Done:=FALSE;
- Abort:=FALSE;
- RFlag[1]:=10;
- GetDialog(1);
- SetTitle('Dowel Pins');
- SetItem(RFlag[1],TRUE);
- SelField(5);
- IF Inch THEN BEGIN
- SetField(12,'in');
- SetField(13,'in');
- END
- ELSE BEGIN
- SetField(12,'mm');
- SetField(13,'mm');
- END;
- 10:REPEAT
- DialogEvent(Item);
- IF Item=1 THEN
- Done:=True;
- IF Item=2 THEN BEGIN
- Done:=TRUE;
- Abort:=TRUE;
- END;
- IF (Item = 9) OR (Item = 10) THEN BEGIN
- SetRButton(1,Item);
- View:=Item-8;
- END;
- UNTIL Done;
- IF Abort THEN GOTO 99;
- OK:=ValidNumStr(GetField(5),D);
- OK:=ValidNumStr(GetField(7),L);
- IF (D <= 0) OR ((VIEW = 2) AND (L <= 0)) THEN BEGIN
- Sysbeep;
- Done:=FALSE;
- GOTO 10;
- END;
- 99:ClrDialog;
- END;
-
- {
- Main program.
- }
- BEGIN
- DselectAll;
- {
- Get units/inch. Determine if units are inches or metric.
- }
- GetUnits(UName,DA,Fmt,UPI,UM,UM2);
- IF (UPI=25.4) OR (UPI=2.54) OR (UPI=0.0254) THEN BEGIN
- SF:=UPI/25.4;
- Inch:=FALSE;
- END
- ELSE BEGIN
- SF:=UPI;
- Inch:=TRUE;
- END;
- {
- Display the dialog box and get the information.
- }
- PinDialog;
- SetCursor(ArrowC);
- GetInfo;
- IF Abort THEN GoTo 99;
- {
- Calculate the variables needed to draw the dowel pin.
- }
- B:=D*Bk;
- A1:=(D-B)/2;
- A2:=A1/Tan(Deg2Rad(Theta));
- C:=CF*D;
- {
- Adjust variables for units.
- }
- D:=D*SF;
- L:=L*SF;
- B:=B*SF;
- A1:=A1*SF;
- A2:=A2*SF;
- C:=C*SF;
- {
- Get the insertion point.
- }
- GetPt(x0,y0);
- Absolute;
- MoveTo(x0,y0);
- Relative;
- IF View = 1 THEN GOTO 20;
- {
- Draw Side View.
- }
- MoveTo(L-A2,D/2);
- OpenPoly;
- BeginPoly;
- LineTo(0,0);
- LineTo(A2,-A1);
- LineTo(0,-B);
- LineTo(-A2,-A1);
- ArcTo(-(L-A2),0,C);
- ArcTo(0,D,C);
- LineTo(L-A2,0);
- EndPoly;
- LineTo(0,-D);
- Move(-(L-A2-C),0);
- LineTo(0,D);
- GOTO 30;
- {
- Draw Top View.
- }
- 20:Arc(-D/2,D/2,D/2,-D/2,0,360);
- 30:Group;
- 99:END;
-
- Run(DowelPin);
-