马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有账号?注册
x
procedure(LabelHandleUI() prog((cv) OddEvenField = hiCreateFrameField( ?name 'OddEvenField ?labelText "odo/Even gelect" ) OddButton = hiCreateButton( ?name 'OddButton ?callback "OddEvenSelect(\"odd\")" ?buttonText "Odd" ) EvenButton = hiCreateButton( ?name 'EvenButton ?callback "OddEvenSelect( \"even\")" ?buttonText "Even" ) CaseField = hiCreateFrameField( ?name 'CaseField ?labelText "'a'<->'A'" ) UpCaseButton = hiCreateButton( ?name 'UpCaseButton ?callback "CaseLabel( \"upper\")" ?buttonText "UpCase" ) LowCaseButton = hiCreateButton( ?name 'LowCaseButton ?callback "CaseLabel( \"lower\")" ?buttonText "LowCase" ) ReplaceLabelField = hiCreateFrameField( ?name 'ReplaceLabelField ?labelText "Replace label Text " ) ReplaceLabelInput1 = hiCreateStringField( ?name 'ReplaceLabelInput1 ?prompt "Be Replaced" ) ReplaceLabelInput2 = hiCreateStringField( ?name 'ReplaceLabelInput2 ?prompt "To Replaced" ) ReplaceLabelButton1= hiCreateButton( ?name 'ReplaceLabelButton1 ?callback "Replace(ReplaceLabelInput1~>value ReplaceLabelInput2~>value)" ?buttonText "Replace" ) ReplaceLabelButton2 = hiCreateButton( ?name 'ReplaceLabelButton2 ?callback "UI->ReplaceLabelInput1~>value = \"\" UI->ReplaceLabelInput1~>value = \"\" " ?buttonText "Clean" ) AlignLabelCenter = hiCreateFrameField( ?name 'AlignLabelCenter ?labelText "Align Label Center" ) AlignLabelInput1 = hiCreateFloatField( ?name 'AlignLabelInput1 ?prompt "X Space" ?defValue nil ) AlignLabelInput2 = hiCreateFloatField( ?name 'AlignLabelInput2 ?prompt "Y Space" ?defValue nil ) AlignLabelButton1 = hiCreateButton( ?name 'AlignLabelButton1 ?callback "UI->AlignLabelInput1~>value = 0 UI->AlignLabelInput2~>value = 0" ?buttonText "Clean" ) AlignLabelButton2 = hiCreateButton( ?name 'AlignLabelButton2 ?callback "AlignLabel(\"X\" AlignLabelInput1~>value)" ?buttonText "Align X" ) AlignLabelButton3 = hiCreateButton( ?name 'AlignLabelButton3 ?callback "AlignLabel(\"Y\" AlignLabelInput2~>value)" ?buttonText "Align Y" ) UI = hiCreateAppForm( ?name 'UI ?formTitle "Labels UI" ?fields list( list(OddEvenField 10:10 220:55 10) list(OddButton 20:30 60:25 10 ) list(EvenButton 90:30 60:25 10 ) list(CaseField 10:70 220:55 10 ) list(UpCaseButton 20:90 60:25 10 ) list(LowCaseButton 90:90 60:25 10 ) list(ReplaceLabelField 10:130 220:120 10 ) list(ReplaceLabelInput1 20:150 200:25 75 ) list(ReplaceLabelInput2 20:180 200:25 75 ) list(ReplaceLabelButton1 20:215 60:25 10 ) list(ReplaceLabelButton2 90:215 60:25 10 ) list(AlignLabelCenter 10:255 220:120 10 ) list(AlignLabelInput1 20:275 130:25 75 ) list(AlignLabelInput2 20:305 130:25 75 ) list(AlignLabelButton1 20:340 60:25 10 ) list(AlignLabelButton2 160:280 60:25 10 ) list(AlignLabelButton3 160:310 60:25 10 ) );list ?buttonLayout 'Close ?minSize list(240 450) ?maxSize list(240 450) );UI hiDisplayForm(UI) );prog );procedure procedure(OddEvenSelect(mode) prog((cv) labels = geGetSelSet() points = list() labelsx = list() labelsy = list() foreach(label labels if(label~>objType == "label" then labelsx = cons(car(label~>xy) labelsx) labelsy = cons(cadr(label~>xy) labelsy) else geDeselectObject(label) labels = remove(label labels) );if );foreach if(nth(0 labelsx) == nth(1 labelsx) then prints = sort(labelsy 'lessp) );if if(nth(0 labelsy) == nth(1 labelsy) then prints = sort(labelsx 'lessp) );if mark = 0 mark++ foreach(point points if(mode == "odd" then mark++ if(mod(mark 2) == 1 then points =remove(point points) );if );if if(mode == "even" then mark++ if(mod(mark 2) == 1 then points =remove(point points) );if );if );foreach foreach(label labels mark = 0 foreach(point points if(nth(0 labelsx) == nth(1 labelsx) then if(cadr(label~>xy) == point then mark = 1 );if );if if(nth(0 labelsy) == nth(1 labelsy) then if(cadr(label~>xy) == point then mark = 1 );if );if );foreach if(mark == 0 then geDeselectObject(label) );if );foreach );prog );procedure ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;ChangeLabelCase;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; procedure(CaseLabel(mode) prog((cv) labels = geGetSelSet() foreach(label labels if(label~>objType == "label" then case(mode ("upper" label~>theLabel = upperCase(label~>theLabel) ) ("lower" label~>theLabel = lowerCase(label~>theLabel) ) );case );if );foreach );prog );procedure ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;ReplaceLabelElement;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; procedure(Replace(BeReplace ToReplace) prog((cv) labels = geGetSelSet() foreach(label labels if(label~>objType == "label" then rexCompile(BeReplace) label~>theLabel = rexReplace(label~>theLabel ToReplace 0) );of );foreach );prog );procedure ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; procedure(AlignLabel(mode space) prog((cv) labels = geGetSelSet() labelsx = list() labelsy = list() foreach(label labels if(label~>objType == "label" then labelsx = cons(car(label~>xy) labelsx) labelsy = cons(cadr(label~>xy) labelsy) else geDeselectObject(label) labels = remove(label labels) );if );foreach if(mode =="X" then labelsx= sort(labelsx 'lessp) foreach(label labels if(car(label~>xy) == nth(0 labelsx) then org_x = car(label~>xy) org_y = cadr(label~>xy) );if );foreach foreach(labelx labelsx foreach(label labels if(car(label~>xy) == labelx then print(list(org_x org_y)) label~>xy = list(org_x org_y) org_x = org_x + space labels = remove(label labels) );if );foreach );foreach );if if(mode =="Y" then labelsy= sort(labelsy 'lessp) foreach(label labels if(cadr(label~>xy) == nth(0 labelsy) then org_x = car(label~>xy) org_y = cadr(label~>xy) );if );foreach foreach(labely labelsy foreach(label labels if(cadr(label~>xy) == labely then print(list(org_x org_y)) label~>xy = list(org_x org_y) org_y = org_y + space labels = remove(label labels) );if );foreach );foreach );if );prog );procedure
|