def Grid(): """Create a grid on a new view""" res=kcs_ui.string_req('请输入格子的长,宽、列数,行数','30,10,8,5') if res[0]==kcs_util.ok(): w,h,m,n=[float(i) for i in res[1].split(',')] pt=Point2D() res=kcs_ui.point2D_req('请选择Grid左上角位置,回车设为原点',pt) if res[0]==kcs_util.ok(): csm=CurrentSubpictureManager() hd=kcs_draft.view_new('') csm.Set(hd) for i in range(n+1): #horizontal line p1=Point2D(pt.X,pt.Y-h*i) p2=Point2D(pt.X+w*m,pt.Y-h*i) kcs_draft.line_new(Rline2D(p1,p2)) for j in range(m+1): #vertical line p1=Point2D(pt.X+j*w,pt.Y) p2=Point2D(pt.X+j*w,pt.Y-h*n) kcs_draft.line_new(Rline2D(p1,p2)) csm.Back() elif res[0]==kcs_util.operation_complete(): pt=Point2D(0,0) csm=CurrentSubpictureManager() hd=kcs_draft.view_new('') csm.Set(hd) for i in range(n+1): #horizontal line p1=Point2D(pt.X,pt.Y-h*i) p2=Point2D(pt.X+w*m,pt.Y-h*i) kcs_draft.line_new(Rline2D(p1,p2)) for j in range(m+1): #vertical line p1=Point2D(pt.X+j*w,pt.Y) p2=Point2D(pt.X+j*w,pt.Y-h*n) kcs_draft.line_new(Rline2D(p1,p2)) csm.Back()
def PrintAll(): msg("ok():%s" % util.ok()) msg("cancel():%s" % util.cancel()) msg("quit():%s" % util.quit()) msg("options():%s" % util.options()) msg("operation_complete():%s" % util.operation_complete()) msg("yes():%s" % util.yes()) msg("no():%s" % util.no()) msg("all():%s" % util.all()) msg("undo():%s" % util.undo()) msg("reject():%s" % util.reject()) msg("exit_function():%s" % util.exit_function())
def Pick2DPoints(number=0,mode="ModeAuto"): """ Pick points until reach the number. number=0 means unlimited number. """ pts=[] index=0 action=kcs_util.ok() while index<number or number==0: pt=Point2D() stp=Stat_point2D_req() stp.SetDefMode(mode) action,pt=kcs_ui.point2D_req('ÇëÑ¡ÔñµÚ%s¸öµã'%(index+1),pt,stp) if action==kcs_util.ok(): pts.append(pt) elif action==kcs_util.operation_complete() and number==0: return pts elif action==kcs_util.cancel(): print 'operation canceled' return None index+=1 return pts
def Pick2DPoints(number=0, mode="ModeAuto"): """ Pick points until reach the number. number=0 means unlimited number. """ pts = [] index = 0 action = kcs_util.ok() while index < number or number == 0: pt = Point2D() stp = Stat_point2D_req() stp.SetDefMode(mode) action, pt = kcs_ui.point2D_req('ÇëÑ¡ÔñµÚ%s¸öµã' % (index + 1), pt, stp) if action == kcs_util.ok(): pts.append(pt) elif action == kcs_util.operation_complete() and number == 0: return pts elif action == kcs_util.cancel(): print 'operation canceled' return None index += 1 return pts