| ||
procedure(CreatePowerLineForm()
let((wideEdgeField narrowEdgeField widthField autoField stepLengthField stepHeightField stepRadioField myColorArray iconString myIcon_fire iconField fields)
wideEdgeField=hiCreateFloatField(
?name 'wideEdgeField
?prompt "wide edge length"
?defValue 100.0
?range list(1.0 nil)
?focusInCallback "createPowerLineForm->wideEdgeField->range=list(createPowerLineForm->narrowEdgeField->value nil)"
)
narrowEdgeField=hiCreateFloatField(
?name 'narrowEdgeField
?prompt "narrow edge length"
?defValue 20.0
?range list(0 nil)
?focusInCallback "createPowerLineForm->narrowEdgeField->range=list(0 createPowerLineForm->wideEdgeField->value-createPowerLineForm->stepHeightField->value)"
)
widthField=hiCreateFloatField(
?name 'widthField
?prompt "width"
?defValue 100.0
?range list(0 nil)
?focusInCallback
"if(createPowerLineForm->autoField->value==t then
createPowerLineForm->widthField->range=list(createPowerLineForm->wideEdgeField->value nil)
else
createPowerLineForm->widthField->range=list(0 nil)
)"
)
autoField=hiCreateBooleanButton(
?name 'autoField
?buttonText "automatic calculation?"
?callback "AutoField_CB()"
?defValue t
)
stepLengthField=hiCreateFloatField(
?name 'stepLengthField
?prompt "step length"
?defValue 5.0
?editable nil
)
stepHeightField=hiCreateFloatField(
?name 'stepHeightField
?prompt "step height"
?defValue 1.0
)
stepRadioField=hiCreateRadioField(
?name 'stepRadioField
?choices list("stepL" "stepH")
?defValue "stepH"
?callback list("StepRadioField_CB(1)" "StepRadioField_CB(2)")
)
myColorArray=hiCreateColorArray()
myColorArray[0]=hiMatchColorByName("yellow");a
myColorArray[1]=hiMatchColorByName("red");b
myColorArray[2]=hiMatchColorByName("pink");c
myColorArray[3]=hiMatchColorByName("green");d
iconString=
"ddddddddddddddaaaddddddddddddddddddddddddddddaaaaadddddddddddddd\
ddddddddddddaaaaaaaddddddddddddddddddddddddaaaabbaaadddddddddddd\
dddddddddddaaaabbaaaadddddddddddddddddddddaaabbbbaaaaadddddddddd\
dddddddddaaaabbbbbaaaaadddddddddaddddddddaaabbbbbbbaaaaddddddddd\
aadddddaaaabbbbbbbbbaaaaddddddddaaaddddaaabbbbbbbbbbbaaaaddddddd\
aaadddaaaabbbbbbbbbbbbaaaddddddaaaaaddaaabbbbbbbbbbbbbbaaaddddaa\
aaaaddaaabbbbbbbbbbbbbbbaaaddaaaaaaaadaaabbbbbbbbbbbbbbbbaadaaaa\
aabbaaaaabbbbbbbbbbbbbbbbaaaaaaaaabbaaaabbbbbbbbbbbbbbbbbaaaaaaa\
aabbbaaabbbbbbbbbbbbbbbbbbaaabaaaabbbbaabbbbbbbbbbbbbbbbbbaabbaa\
aabbbbbabbbbbbbbbbbbbbbbbbabbbaaaabbbbbbbbbb11bbbbbb11bbbbbbbbaa\
cabbbbbbbbbb11bbbbbb11bbbbbbbbaacaabbbbbbbbbbbbbbbbbbbbbbbbbbbac\
caabbbbbbbbbbbbbbbbbbbbbbbbbbaacccaabbbbbbbb1bbbbbbb1bbbbbbbbaac\
ccaabbbbbbbbb1bbbbb1bbbbbbbbaacccccaabbbbbbbbb11111bbbbbbbbbaccc\
cccaabbbbbbbbbbbbbbbbbbbbbaaccccccccaaaabbbbbbbbbbbbbbbbaaaccccc\
cccccaaaaaaaabbbbbbbaaaaaacccccccccccccaaaaaaaaaaaaaaaaacccccccc\
cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc"
myIcon_fire=hiStringToIcon(myColorArray iconString 32 32)
iconField=hiCreateLabel(
?name 'iconField
?labelIcon myIcon_fire
)
fields=list(
list(wideEdgeField 0:5 200:35 150)
list(narrowEdgeField 0:40 200:35 150)
list(widthField 0:80 200:35 150)
list(autoField 0:120 200:35 150)
list(stepRadioField 200:120 100:35 80)
list(stepLengthField 0:160 200:35 150)
list(stepHeightField 0:200 200:35 150)
list(iconField 270:200 32:35)
)
if(!boundp('createPowerLineForm) || (createPowerLineForm==nil) then
createPowerLineForm=hiCreateAppForm(
?name 'createPowerLineForm
?fields fields
?formTitle "CreatePowerLineForm"
?callback "CreatePowerLineForm_CB()"
?buttonlayout 'OKCancelDefApply
)
);end if
hiDisplayForm(createPowerLineForm)
);end let
);end procedure
procedure(CreatePowerLineForm_CB()
let((wideEdge narrowEdge width auto stepL stepH)
wideEdge=createPowerLineForm->wideEdgeField->value
narrowEdge=createPowerLineForm->narrowEdgeField->value
width=createPowerLineForm->widthField->value
auto=createPowerLineForm->autoField->value
stepL=createPowerLineForm->stepLengthField->value
stepH=createPowerLineForm->stepHeightField->value
CreatePowerLine()
);end let
);end procedure
procedure(AutoField_CB()
if(createPowerLineForm->autoField->value==t then
createPowerLineForm->stepRadioField->invisible=nil
createPowerLineForm->narrowEdgeField->editable=t
if(createPowerLineForm->stepRadioField->value=="stepH" then
createPowerLineForm->stepLengthField->editable=nil
else
createPowerLineForm->stepHeightField->editable=nil
);end if
else
createPowerLineForm->stepLengthField->editable=t
createPowerLineForm->stepHeightField->editable=t
createPowerLineForm->narrowEdgeField->editable=nil
createPowerLineForm->stepRadioField->invisible=t
);end if
);end procedure
procedure(StepRadioField_CB(radio)
if(radio==1 then
createPowerLineForm->stepLengthField->editable=t
createPowerLineForm->stepHeightField->editable=nil
else
createPowerLineForm->stepLengthField->editable=nil
createPowerLineForm->stepHeightField->editable=t
);end if
);end procedure
procedure(CreatePowerLine()
let((cv lpp grid steps points firstPoint time point1 point2 penultPoint dy lastPoint)
cv=geGetEditCellView()
lpp=leGetEntryLayer()
grid=techGetMfgGridResolution(techGetTechFile(cv))
points=nil
points=append1(points list(0 0))
firstPoint=list(0 wideEdge)
points=append1(points firstPoint)
if(auto==t then
if(createPowerLineForm->stepRadioField->value=="stepH" then
steps=round2((wideEdge-narrowEdge)/stepH)
stepL=width/steps-stepH
stepL=round2((stepL/grid))*grid ;fix grid
else
stepH=stepL*(wideEdge-narrowEdge)/(width-(wideEdge-narrowEdge))
stepH=round2((stepH/grid))*grid ;fix grid
steps=round2(width/(stepL+stepH))
);end if
else
steps=round2(width/(stepL+stepH))
);end if
time=1
while(time<=steps && yCoord(firstPoint)>0
point1=list(xCoord(firstPoint)+stepL yCoord(firstPoint))
point2=list(xCoord(firstPoint)+stepL+stepH yCoord(firstPoint)-stepH)
firstPoint=point2
when(xCoord(point2)<=width && yCoord(point2)>=0
points=append1(points point1)
points=append1(points point2)
);end when
time++
);end while
if(auto==t then
when(narrowEdge!=0
lastPoint=car(last(points))
if(xCoord(lastPoint)<width || (xCoord(lastPoint)==width && yCoord(lastPoint)>narrowEdge) then
penultPoint=car(last(remove(car(last(points)) points)))
dy=yCoord(penultPoint)-narrowEdge
penultPoint=list(width-dy yCoord(penultPoint))
lastPoint=list(width narrowEdge)
points=remove(car(last(points)) points)
points=remove(car(last(points)) points)
points=append1(points penultPoint)
points=append1(points lastPoint)
else
lastPoint=list(width narrowEdge)
points=append1(points lastPoint)
);end if
);end when
else
lastPoint=list(width yCoord(car(last(points))))
points=append1(points lastPoint)
);end if
points=append1(points list(width 0))
dbCreatePolygon(cv lpp points)
);end let
);end procedure
hiSetBindKey("Layout" "<Key>KP_8" "CreatePowerLineForm()")