home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Chip 1998 March
/
Chip_1998-03_cd.bin
/
tema
/
MINICAD
/
MC7DEMO
/
MINICAD.1
/
CRE_DTS.MPC
< prev
next >
Wrap
Text File
|
1997-04-30
|
5KB
|
297 lines
Procedure DatumTarget;
{
⌐1997, Diehl Graphsoft, Inc.
Developed by Tom Urie
This procedure creates a Datum Target Symbol.
}
LABEL 10,99;
CONST
{The following constant determines the default symbol size for 10 pt. text}
SDiaC=0.4375;
{The following four constants are used to determine the location of the text within in the symbol.}
TextOff1C=0.180;
TextOff2C=0.062;
TextOff3C=0.011;
TextOff4C=0.072;
VAR
x0,y0,xs,ys,xt,yt,h : REAL;
TextOff1,TextOff2,TextOff3,TextOff4,SDia,LScale : REAL;
TxtSize : INTEGER;
DatumID,TASize,TargetNo : STRING;
DiaChar : CHAR;
TDia,Abort : BOOLEAN;
LayerH : HANDLE;
UPI : REAL;
Fmt : INTEGER;
UM,UM2 : STRING;
UName,DA : LONGINT;
Procedure DatumTargetDialog;
{
This procedure defines the dialog box.
}
VAR
Width,x1,y1,x2,y2,px1,px2,px3,px4,py1,py2,py3,py4 : 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 LocateButtons2(scnh,scnw : INTEGER);
{
This procedure locates the 'OK' and 'Cancel' buttons at the lower left hand corner of the dialog box.
}
VAR
v1,v2,v3,v4 : INTEGER;
Procedure Swap(VAR m1,m2,m3,m4 : INTEGER);
VAR
Temp : INTEGER;
BEGIN
Temp:=m1;
m1:=m3;
m3:=Temp;
Temp:=m2;
m2:=m4;
m4:=Temp;
END; {of Swap}
BEGIN
px1:=scnw - 180;
px2:=scnw - 110;
px3:=scnw - 90;
px4:=scnw - 20;
py1:=scnh-40;
py2:=scnh-20;
py3:=py1;
py4:=py2;
GetVersion(v1,v2,v3,v4);
IF v4 = 1 THEN Swap(px1,px2,px3,px4);
END; {of Locate Buttons1}
Procedure MakeDatumTargetDialog;
LABEL 99;
CONST
y1=100;
scnh=160;
scnw=300;
VAR
h : INTEGER;
BEGIN
AlignScr(scnw,x1,x2);
y2:=y1+scnh;
LocateButtons2(scnh,scnw);
h:=30;
BeginDialog(1,1,x1,y1,x2,y2);
AddButton('OK',1,1,px1,py1,px2,py2);
AddButton('Cancel',2,1,px3,py3,px4,py4);
AddField('Target Area Size:',5,1,20,44-h,130,60-h);
AddField('6',6,2,135,45-h,190,60-h);
AddButton('Diameter',7,3,200,45-h,275,60-h);
AddField('Datum ID Letter:',8,1,20,74-h,130,90-h);
AddField('A',9,2,135,75-h,190,90-h);
AddField('Target Number:',10,1,20,104-h,130,120-h);
AddField('8',11,2,135,105-h,190,120-h);
EndDialog;
END;
BEGIN
MakeDatumTargetDialog;
END;
Procedure GetInfo;
{
This procedure displays the dialog box and retrieves the information.
}
VAR
Done:Boolean;
Item:Integer;
BEGIN
Done:=FALSE;
Abort:=FALSE;
TDia:=FALSE;
TASize:=' ';
DatumID:=' ';
TargetNo:=' ';
GetDialog(1);
SetTitle('Datum Target Symbol');
SelField(6);
REPEAT
DialogEvent(Item);
IF Item=1 THEN
Done:=TRUE;
IF Item=2 THEN
BEGIN
Done:=TRUE;
Abort:=TRUE;
END;
IF Item=7 THEN
BEGIN
TDia:=NOT TDia;
SetItem(7,TDia);
END;
UNTIL Done;
TASize:=GetField(6);
DatumID:=GetField(9);
TargetNo:=GetField(11);
ClrDialog;
END;
Function GetActTextSize : INTEGER;
{
This function returns the active text size.
}
VAR
a : INTEGER;
TextH : HANDLE;
BEGIN
DSelectAll;
TextOrigin(0,0);
BeginText;
' '
EndText;
TextH:=FSActLayer;
GetActTextSize:=GetSize(TextH);
DelObject(TextH);
END;
{
Main program.
}
BEGIN
{
Display dialog box and get info.
}
DatumTargetDialog;
SetCursor(ArrowC);
GetInfo;
IF Abort THEN GOTO 99;
TextJust(2);
TextSpace(2);
{
Get text size.
}
TxtSize:=GetActTextSize;
DiaChar:=Chr(175);
{
Get units per inch and layer scale.
}
LayerH:=ActLayer;
LScale:=GetLScale(LayerH);
GetUnits(UName,DA,Fmt,UPI,UM,UM2);
{
Adjust constants for layer scale, units per inch, and text size.
}
h:=TxtSize/10;
LScale:=h*LScale;
SDia:=SDiaC*UPI*LScale;
TextOff1:=TextOff1C*UPI*LScale;
TextOff3:=TextOff3C*UPI*LScale;
TextOff4:=TextOff4C*UPI*LScale;
TextOff2:=TextOff2C*UPI*LScale;
{
Get datum target symbol location and draw circle.
}
DSelectAll;
GetPt(x0,y0);
FillPat(1);
BeginGroup;
Absolute;
MoveTo(x0,y0);
Relative;
Arc(-SDia/2,SDia/2,SDia/2,-SDia/2,0,360);
Move(-SDia/2,0);
Line(SDia,0);
Absolute;
FillPat(0);
{
Add diameter character, if needed and determine location of target area size.
}
IF TDia THEN
TASize:=Concat(DiaChar,TASize);
xt:=x0;
yt:=y0+TextOff1;
{
Enter target area size.
}
IF TASize <> '' THEN
BEGIN
TextOrigin(xt,yt);
BeginText;
TASize
EndText;
END;
{
Determine location of datum ID letter and enter into symbol.
}
yt:=y0-TextOff3;
IF DatumID <> '' THEN
BEGIN
xt:=x0-TextOff4;
TextOrigin(xt,yt);
BeginText;
DatumID
EndText;
END;
{
Determine location of target number and enter into symbol.
}
IF TargetNo <> '' THEN
BEGIN
xt:=x0+TextOff2;
TextOrigin(xt,yt);
BeginText;
TargetNo
EndText;
END;
EndGroup;
PopAttrs;
99:END;
RUN(DatumTarget);