;File : enhanced_ruler.il
;Author : ZouJunlin
;Date : 2017/05/25
;Description: create a perpendicular ruler at the middle of current ruler
;step 1 : record the begin point when press the bindkey
;step 2 : create a normal ruler and record the end point
;step 3 : create the perpendicular ruler at the middle
procedure(enhanced_ruler()
prog( (cv begin_point end_point x1 y1 x2 y2 delta_x delta_y mid_x mid_y)
cv = geGetEditCellView()
;step 1 : record the begin point when press the bindkey
infix_origin = envGetVal("ui" "infix")
envSetVal("ui" "infix" 'boolean t) ;set infix to get the begin point
modalCommands_origin = envGetVal("
layout" "modalCommands")
envSetVal("layout" "modalCommands" 'boolean nil)
; set no repeat command so that this skill will excute immediatlyafter create ruler finished.
; aSRP means autoSetRefPoint for short
aSRP_origin = envGetVal("layout" "autoSetRefPoint")
envSetVal("layout" "autoSetRefPoint" 'boolean t) ; set aSRP to get the end point
; begin_point = hiGetDbuPoint(hiGetCurrentWindow())
; x1 = car(begin_point)/1000 ; dbu per unit maybe 1000 or 2000 according to the techfile definition
; y1 = cadr(begin_point)/1000 ; dbu per unit maybe 1000 or 2000 according to the techfile definition
begin_point = hiGetPoint(hiGetCurrentWindow())
x1 = car(begin_point)
y1 = cadr(begin_point)
;step 2 : create a normal ruler and record the end point
; press F3 when create ruler to disable snap function
leHiCreateRuler()
end_point = leGetRefPoint(cv)
;step 3 : create the perpendicular ruler at the middle
x2 = car(end_point)
y2 = cadr(end_point)
delta_x = x2 - x1
delta_y = y2 - y1
mid_x = (x1 + x2)/2
mid_y = (y1 + y2)/2
rulerLength = 1
if(delta_x == 0 then
leCreateRuler(cv list(mid_x:mid_y mid_x-rulerLength:mid_y))
leCreateRuler(cv list(mid_x:mid_y mid_x+rulerLength:mid_y))
);end if
if(delta_y == 0 then
leCreateRuler(cv list(mid_x:mid_y mid_x:mid_y+rulerLength))
leCreateRuler(cv list(mid_x:mid_y mid_x:mid_y-rulerLength))
);end if
if(delta_x * delta_y > 0 then
leCreateRuler(cv list(mid_x:mid_y mid_x-rulerLength:mid_y+rulerLength))
leCreateRuler(cv list(mid_x:mid_y mid_x+rulerLength:mid_y-rulerLength))
);end if
if(delta_x * delta_y < 0 then
leCreateRuler(cv list(mid_x:mid_y mid_x-rulerLength:mid_y-rulerLength))
leCreateRuler(cv list(mid_x:mid_y mid_x+rulerLength:mid_y+rulerLength))
);end if
;restore envioronment value
envSetVal("ui" "infix" 'boolean infix_origin)
envSetVal("layout" "modalCommands" 'boolean modalCommands_origin)
envSetVal("layout" "autoSetRefPoint" 'boolean aSRP_origin)
);end prog
);end procedure
printf("enhanced_ruler.il loaded\n")