|
EDA365欢迎您!
您需要 登录 才可以下载或查看,没有帐号?注册
x
; Purpose: This routine is a very simple utility that will create oblong thermal shape
;
; (btw: you can get some idea from Create_Thermal_Flash.il also)
/*---------------------------------
CreateOblThForm()
---------------------------------*/
defun( CreateOblThForm ()
MainFormFile=axlTempFile()
p = outfile(MainFormFile "w")
f_FormBegin(p 35,20,"Create Oblong Thermal - RichardL." "TOOLWINDOW")
f_Bitmap(p "cot" "cot" 0 0 14 14)
;f_Bitmap1()
f_Text(p "Outer diameter(A):",15,0) f_EditFloat(p "A",29,0,5,5,4)
f_Text(p "Inner diameter(B):",15,3) f_EditFloat(p "B",29,3,5,5,4)
f_Text(p "Oblong length(D):", 15,6) f_EditFloat(p "D",29,6,5,5,4)
f_Text(p "Circle spoke(C):", 15,9) f_EditFloat(p "C",29,9,5,5,4)
f_Text(p "Oblong spoke(E):", 15,12) f_EditFloat(p "E",29,12,5,5,4)
f_Group(p "Direction",2,14,32,4)
f_CheckList(p "H", 4,16,"Horizontal","di")
f_CheckList(p "V",18,16,"Vertical","di")
f_Button(p "OK",2,19,10,3)
f_Button(p "Cancel",20,19,10,3)
f_FormEnd(p)
close(p)
MainFormFile
);func
/*---------------------------------
CheckCOTValue()
---------------------------------*/
defun( CheckCOTValue ()
prog( ()
let( ()
if((ot->a>0 && ot->b>0 && ot->c>0 && ot->d>0 && ot->e>0) then
if((ot->a>ot->b && ot->d>ot->e && ot->b>ot->c) return(t)
axlMsgPut("Invalid Value between A,B,C,D,E")
)
);if
axlMsgPut("Invalid Value, check your value carefully.")
return(nil)
]
;global
defstruct( struOblTh a b c d e dirH)
ot=nil
defun( CreateOblongThermal ()
MainFormFile=CreateOblThForm()
fw = axlFormCreate((gensym) MainFormFile '("NE" "msglines" 0) 'OblThCallback t nil)
ot=make_struOblTh(?a 100 ?b 50 ?c 20 ?d 100 ?e 30 ?dirH t)
(axlFormSetField fw "A" ot->a)
(axlFormSetField fw "B" ot->b)
(axlFormSetField fw "C" ot->c)
(axlFormSetField fw "D" ot->d)
(axlFormSetField fw "E" ot->e)
(axlFormSetField fw "A" ot->a)
(axlFormSetField fw "H" ot->dirH)
(axlFormSetField fw "bmp" "cot")
axlFormDisplay(fw)
; return(fw) ; return form handle to caller
)
defun( OblThCallback (fw)
case(fw->curField
("H" ot->dirH=t)
("V" ot->dirH=nil)
("A" ot->a=fw->curValue)
("B" ot->b=fw->curValue)
("C" ot->c=fw->curValue)
("D" ot->d=fw->curValue)
("E" ot->e=fw->curValue)
)
if(fw->doneState==2 || fw->doneState==3 ;cancle & close
then axlFormClose(fw) axlTempFileRemove(MainFormFile))
case(fw->doneState
(1 ;here is the real main thing!
if(CheckCOTValue() then
axlShell("done")
axlSetActiveLayer("etch/top")
axlDBChangeDesignExtents( '((-1000 -1000) (1000 1000)))
if(ot->dirH then
path = axlPathStart( (list -ot->d/2:-ot->a/2))
axlPathLine(path,0,ot->d/2:-ot->a/2) axlPathArcAngle(path,0,ot->d/2t->a/2, nil,180)
axlPathLine(path,0,-ot->d/2t->a/2) axlPathArcAngle(path,0,-ot->d/2:-ot->a/2,nil,180)
else
path = axlPathStart( (list ot->a/2:-ot->d/2))
axlPathLine(path,0,ot->a/2t->d/2) axlPathArcAngle(path,0,-ot->a/2:ot->d/2, nil,180)
axlPathLine(path,0,-ot->a/2:-ot->d/2) axlPathArcAngle(path,0,ot->a/2:-ot->d/2,nil,180)
)
shapeid=axlDBCreateShape(path t)
o_poly = axlPolyFromDB(car(shapeid)) axlDeleteObject(car(shapeid))
i_poly=axlPolyExpand(o_poly -(ot->a-ot->b)/2 'NONE)
if(ot->dirH
shapeid=axlDBCreateRectangle(list(-ot->d/2-ot->a/2:-ot->c/2 ot->d/2+ot->a/2:ot->c/2) t)
shapeid=axlDBCreateRectangle(list(-ot->c/2:-ot->d/2-ot->a/2 ot->c/2:ot->d/2+ot->a/2) t)
)
i_poly=append(i_poly axlPolyFromDB(car(shapeid))) axlDeleteObject(car(shapeid))
if(ot->dirH
shapeid=axlDBCreateRectangle(list(-ot->e/2:-ot->a/2 ot->e/2:ot->a/2) t)
shapeid=axlDBCreateRectangle(list(-ot->a/2:-ot->e/2 ot->a/2:ot->e/2) t)
)
i_poly = append(i_poly axlPolyFromDB(car(shapeid))) axlDeleteObject(car(shapeid))
f_poly = axlPolyOperation(o_poly i_poly 'ANDNOT)
foreach(onepoly f_poly axlDBCreateShape(onepoly t))
axlWindowFit()
)
);CheckCOTValue
);case
)
;CreateOblongThermal()
axlCmdRegister( "COT" `CreateOblongThermal)
;DESCRIPTION: basic form operation with tmpfile support
;AUTHOR: Richard L. fpmontreal@gmail.com
/*---------------------------------
f_FormBegin(p w h title form_opt) TOOLWINDOW / AUTOGREYTEXT / FIXED_FONT / UNIXHGT
---------------------------------*/
defun( f_FormBegin (p w h @optional (form_title "by RichardL.") (form_opt "AUTOGREYTEXT"))
sprintf(dest,"FILE_TYPE=FORM_DEFN VERSION=2\nFORM %s\nFIXED\nPORT %d %d\nHEADER \"%s\"\nTILE\n\n",form_opt,w,h,form_title)
if(p fprintf(p,"%s",dest))
dest
)
/*---------------------------------
f_FormEnd(p flexmode) StandButtons / EdgeGravity / EdgeGravityOne
---------------------------------*/
defun( f_FormEnd (p @optional flexmode)
if(flexmode sprintf(dest,"FLEXMODE %s\nENDTILE\nENDFORM\n",flexmode)
sprintf(dest,"ENDTILE\nENDFORM\n")
)
if(p fprintf(p,"%s",dest))
dest
)
/*---------------------------------
f_CheckList(field x y name group)
---------------------------------*/
defun( f_CheckList (p field x y name @optional (group nil))
if(group==nil
sprintf(dest,"FIELD %s\nFLOC %d %d\nCHECKLIST \"%s\" \nENDFIELD\n\n",field,x,y,name)
sprintf(dest,"FIELD %s\nFLOC %d %d\nCHECKLIST \"%s\" \"%s\"\nENDFIELD\n\n",field,x,y,name,group)
)
if(p fprintf(p,"%s",dest))
dest
)
/*---------------------------------
f_Group(field x y w h)
---------------------------------*/
defun( f_Group (p field x y w h)
sprintf(dest,"GROUP \"%s\"\nFLOC %d %d\nFSIZE %d %d\nENDGROUP\n\n",field,x,y,w,h)
if(p fprintf(p,"%s",dest))
dest
)
/*---------------------------------
f_Text(field x y)
---------------------------------*/
defun( f_Text (p text x y)
sprintf(dest,"TEXT \"%s\"\nFLOC %d %d\nENDTEXT\n\n",text,x,y)
if(p fprintf(p,"%s",dest))
dest
)
/*---------------------------------
f_EditFloat(field x y iw dw dec) (iw-input width) (dw-data width)
---------------------------------*/
defun( f_EditFloat (p field x y iw dw dec)
sprintf(dest,"FIELD %s\nFLOC %d %d\nREALFILLIN %d %d\nDECIMAL %d\nENDFIELD\n\n",field,x,y,iw,dw,dec)
if(p fprintf(p,"%s",dest))
dest
)
/*---------------------------------
f_Button(x y w h)
---------------------------------*/
defun( f_Button (p name x y w h) ;close done/ok cancel help print
sprintf(dest,"FIELD %s\nFLOC %d %d\nMENUBUTTON \"%s\" %d %d\nENDFIELD\n\n",name,x,y,name,w,h)
if(p fprintf(p,"%s",dest))
dest
)
/*---------------------------------
f_Bitmap(name x y w h @optional opt)
---------------------------------*/
defun( f_Bitmap (p field name x y w h @optional (opt nil)) ;[RIGHT | CENTER | BORDER | BOLD | UNDERLINE]
bmppath = axlGetVariable("BMPPATH")
axlSetVariable("BMPPATH" "~/skill/")
if(opt==nil
sprintf(dest,"FIELD %s\nTHUMBNAIL %s\nFLOC %d %d\nFSIZE %d %d\nENDFIELD\n\n",field,name,x,y,w,h)
sprintf(dest,"FIELD %s\nTHUMBNAIL %s\nOPTIONS %s\nFLOC %d %d\nFSIZE %d %d\nENDFIELD\n\n",field,name,opt,x,y,w,h)
)
if(p fprintf(p,"%s",dest))
dest
)
defun(f_Bitmap1 ()
axlSetVariable("BMPPATH" "~/skill/")
bmppath = axlGetVariable("BMPPATH")
printf("%s\n" bmppath)
;FIELD bmp
sprintf(P "FIELD bmp\n")
;THUMBNAIL logo.bmp
sprintf(P "THUMBNAIL cot.bmp\n")
;FLOC 1 3
sprintf(P "FLOC 0 0\n")
;FSIZE 23 5
sprintf(P "FSIZE 14 14\n")
;ENDFIELD
sprintf(P "ENDFIELD\n")
)
/*---------------------------------
f_TreeView(field x y w h)
---------------------------------*/
defun( f_TreeView (p field x y w h)
sprintf(dest,"FIELD %s\nFLOC %d %d\nTREEVIEW %d %d\nENDFIELD\n\n",field,x,y,w,h)
if(p fprintf(p,"%s",dest))
dest
)
/*---------------------------------
example: CreateMainForm()
---------------------------------*/
/*
defun( CreateMainForm ()
MainFormFile=axlTempFile()
p = outfile(MainFormFile "w")
f_FormBegin(p 80,20,"Batch Symbol Creater - Richard L.")
f_Group(p "Select Level",2,2,20,8)
f_CheckList(p "LevelMax", 4,4,"1 - Maximum","rg")
f_CheckList(p "LevelMom", 4,6,"2 - Nominal","rg")
f_CheckList(p "LevelLeast",4,8,"3 - Least", "rg")
f_Text(p "SolderMask Ext:",2,12) f_EditFloat(p "SolderMaskOffset",14,12,7,7,4)
f_Text(p "Silk Gap:", 2,14) f_EditFloat(p "SilkGap", 14,14,7,7,4)
f_Text(p "SilkWidth", 2,16) f_EditFloat(p "SilkWidth", 14,16,7,7,4)
f_Text(p "Choice Symbol(s):",24,2)
f_CheckList(p "AllSym",40,2,"Select All")
f_TreeView(p "SymTree",24,4,56,12)
f_Button(p "Run",2,20,10,3)
f_FormEnd(p)
close(p)
MainFormFile
);func
*/
|
|