File "dev_skill02.il"

Full Path: /home/analogde/www/SKILL/dev_skill02.il
File size: 15.36 KB
MIME-type: text/plain
Charset: utf-8


;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
procedure(selection_pins()

	if(Form_appli~>selection_pins~>value == "Toutes" then
		for(i 0 length(pins)-1
		    sprintf(indice "Form_appli~>bouton_%d~>value = t" i)
		    exp= evalstring(indice) 
		)
		printf("[info]: All selected \n")
	else
		for(i 0 length(pins)-1
		    sprintf(indice "Form_appli~>bouton_%d~>value = nil" i)
		    exp= evalstring(indice) 
		)
		printf("[info]: All Unselected \n")
	)

)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
procedure(ordonner(liste)

   prog( ()	
		liste_classer = '()

		for(j 0 length(liste)-1
	        	if(j == 0 then  
	 		   a = nth(j liste)
			   b = nth(j+1 liste)
			   val = min(a b)
			)
			if(j > 0 then  
			   a = nth(j liste)
			   val = min(val a)
			)
	   	)
	
		min = val  
		declare(tab[length(liste)])

		for(i 0 length(liste)-1
		    tab[i] = nth(i liste)
	        )

		for(j 0 length(liste)-1-1
 	            for(i 0 length(liste)-1-1
	  	        a = tab[i]
	  	        b = tab[i+1]
	                if(b<a then
	                   tab[i] = b
		           tab[i+1] = a
                        )
	            )
                ) 

		for(i 0 length(liste)-1
		    liste_classer = append1(liste_classer tab[i])
		)		

		return(liste_classer)

    );prog	

)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
procedure(ponderation(caractere)
	
prog( ()

	caractere = lowerCase(caractere)

	case( caractere
	     
		("0"
		  valeur = 0 	
		)
		("1"
		  valeur = 1 	
		)
		("2"
		  valeur = 2 	
		)
		("3"
		  valeur = 3 	
		)
		("4"
		  valeur = 4 	
		)
		("5"
		  valeur = 5 	
		)
		("6"
		  valeur = 6 	
		)
		("7"
		  valeur = 7 	
		)
		("8"
		  valeur = 8 	
		)
		("9"
		  valeur = 9 	
		)

		("a"
		  valeur = 21 	
		)
		("b"
		  valeur = 22 	
		)
		("c"
		  valeur = 23 	
		)
		("d"
		  valeur = 24 	
		)
		("e"
		  valeur = 25 	
		)
		("f"
		  valeur = 26 	
		)
		("g"
		  valeur = 27 	
		)
		("h"
		  valeur = 28 	
		)
		("i"
		  valeur = 29 	
		)
		("j"
		  valeur = 30 	
		)
		("k"
		  valeur = 31 	
		)
		("l"
		  valeur = 32 	
		)
		("m"
		  valeur = 33 	
		)
		("n"
		  valeur = 34 	
		)
		("o"
		  valeur = 35 	
		)
		("p"
		  valeur = 36 	
		)
		("q"
		  valeur = 37 	
		)
		("r"
		  valeur = 38 	
		)
		("s"
		  valeur = 39 	
		)
		("t"
		  valeur = 40 	
		)
		("u"
		  valeur = 41 	
		)
		("v"
		  valeur = 42 	
		)
		("w"
		  valeur = 43 	
		)
		("x"
		  valeur = 44 	
		)
		("y"
		  valeur = 45 	
		)
		("z"
		  valeur = 46 	
		)
		("z"
		  valeur = 46 	
		)

		("-"
		  valeur = 50 	
		)
		("_"
		  valeur = 51 	
		)

		(">"
		  valeur = 60 	
		)
		(">"
		  valeur = 61 	
		)


	)

	return(valeur)

   );prog	

)

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
procedure(classement()

	
	cv = geGetWindowCellView()
	terminal_list = cv~>terminals~>name  

	pins_simple = '()
	pins_bus = '()	

	; détecter les bus
	for(i 0 length(terminal_list)-1
	    flag = rexMatchp("[<>]" nth(i terminal_list) )
	    if(flag == nil then
	       pins_simple = append1(pins_simple nth(i terminal_list))		
	    else		
	       pins_bus = append1(pins_bus nth(i terminal_list))
	    )	
	)

	pins_simple_ordonner = '()
	pins_simple_ordonner = sort(pins_simple nil) 

	poids = '()

	for(i 0 length(pins_bus)-1
	    chaine = '()
	    total = 0	
	    chaine = parseString( nth(i pins_bus) ":_<>")	
	    for(i 0 length(chaine)-1
	          test=atoi(nth(i chaine))
	          if(test != nil then
		      total = total + test
	          ) 	
    	          if(test == nil then
	             val = ""	
	             str = nth(i chaine)
	             for(k 1 strlen(str)
		         val = substring(str k 1)
		         total = total + ponderation(val)
	               )
	          )
	     )
	;printf(" Total : %d \n" total)
	poids = append1(poids total)		
	)


	classement_poids = '()
	classement_poids = ordonner(poids) 

	tmp3 = '()

	for(i 0 length(pins_bus)-1
	    for(j 0 length(pins_bus)-1
		if( nth(i classement_poids) == nth(j poids) then
		    tmp3 = append1(tmp3 j)	
		    j= 100
		)

	    )	
	)


	bus_ordonner = '()

	for(i 0 length(pins_bus)-1
		position = nth(i tmp3) 
		;;printf(" ** : %s \n" nth(position pins_bus) )
		bus_ordonner = append1(bus_ordonner nth(position pins_bus) )

	)


	pins = '()

	pins = pins_simple_ordonner

	for(i 0 length(bus_ordonner)-1
	    pins = append1(pins nth(i bus_ordonner) )	
	)

	tmp2 = '()

	for(i 0 length(pins)-1
	    ;id = leSearchHierarchy(cv cv~>bBox 0 "label" list(list("text" "==" nth(i pins) ))) 
	    id = leSearchHierarchy(cv cv~>bBox 0 "pin" list(list("term name" "==" nth(i pins) ))) 
	    tmp2 = append1(tmp2 car(id))	
	)

	longueur = length(pins)	

	champs_datas = '()
	

		y = 0
			id_champs = hiCreateLabel( ?name 'champs	
						   ?labelText "Nom pin           Largeur         Hauteur            Selection          Position             Couche Pin       Couche Label"  
		 			      )
			champs_datas = append1(champs_datas list(id_champs 10:y 20:50 ))
		


		y=0

		for(i 0 longueur-1
			nom = nth(i tmp2)~>net~>name
			id_nom = stringToSymbol(sprintf(nil "nom_%d" i))		 
			id_nom = hiCreateLabel(  ?name stringToSymbol(sprintf(nil "nom_pin_%d" i))	
						 ?labelText nom   
		 			      )
			champs_datas = append1(champs_datas list(id_nom 10:y+30 20:50 ))
			y = y + 30
		  )

		y=0

		for(i 0 longueur-1

			box = nth(i tmp2)~>bBox
			x1 = car(car(box)) 
		        y1 = cadr(car(box)) 
		        x2 = car(cadr(box)) 
		        y2 = cadr(cadr(box)) 

			largeur = abs(abs(x2) - abs(x1) )
			hauteur = abs(abs(y2) - abs(y1) )

			id_largeur = stringToSymbol(sprintf(nil "largeur_%d" i))		 
			id_largeur = hiCreateFloatField(
							?name stringToSymbol(sprintf(nil "largeur_pin_%d" i)) 
							?prompt "" 
						        ?value largeur
							?defValue 10.0 
						        ?callback "check_champ( Form_sec )" ;hiGetCurrentForm() 
							;"println(\"float changed\" )" 
						      ?range list(0 100)
						) 
			champs_datas = append1(champs_datas list(id_largeur 100:y+30 60:50 ))
			y = y + 30

		  )	
		
	y=0
		for(i 0 longueur-1

			box = nth(i tmp2)~>bBox
			x1 = car(car(box)) 
		        y1 = cadr(car(box)) 
		        x2 = car(cadr(box)) 
		        y2 = cadr(cadr(box)) 

			largeur = abs(abs(x2) - abs(x1))
			hauteur = abs(abs(y2) - abs(y1))

			id_hauteur = stringToSymbol(sprintf(nil "hauteur_%d" i))		 
			id_hauteur = hiCreateFloatField(
							?name stringToSymbol(sprintf(nil "hauteur_pin_%d" i)) 
							?prompt "" 
						        ?value hauteur
							?defValue 10.0 
						      ?callback "check_champ( Form_sec )" 
						      ?range list(0 100)
						) 
			champs_datas = append1(champs_datas list(id_hauteur 180:y+30 60:50 ))
			y = y + 30

		  )	

		y = 0

		for(i 0 longueur-1

			id_bouton = hiCreateBooleanButton( 
							   ?name        stringToSymbol(sprintf(nil "bouton_%d" i))
							   ?buttonText  " " 
							   ?value        t 
							   ?defValue     nil 
							   ;?callback    "println("toto")" 
						 	 )
			champs_datas = append1(champs_datas list(id_bouton 250:y+30 60:50 ))
			y = y + 30

		   )

		
		y=0

		for(i 0 longueur-1

			position = "left"
			
			id_position = stringToSymbol(sprintf(nil "position_%d" i))	
			id_position = hiCreateCyclicField(
							?name stringToSymbol(sprintf(nil "position_pin_%d" i))	
							?prompt " " 
						     	?choices list("left" "right" "top" "bottom") 
						     	?value position
						     	?callback "println( \"position change\" )"
						) 
				champs_datas = append1(champs_datas list(id_position 350:y+40 200:50 10))
				y = y + 30 
		)

		y=0
		for(i 0 longueur-1
			
			couche = "METAL1"
			
			id_couche = stringToSymbol(sprintf(nil "couche_%d" i))	
			id_couche = hiCreateCyclicField(
							?name stringToSymbol(sprintf(nil "couche_pin_%d" i))	
							?prompt " " 
						     	?choices list("METAL1" "METAL2" "METAL3" "METAL4") 
						     	?value couche 
						     	?callback "println( \"couche change\" )"
						) 
				champs_datas = append1(champs_datas list(id_couche 450:y+40 200:50 10))
				y = y + 30 
		)


		y=0
		for(i 0 longueur-1
			
			couche = "METAL1"
			
			id_label = hiCreateCyclicField(
							?name stringToSymbol(sprintf(nil "label_pin_%d" i))	
							?prompt " " 
						     	?choices list("METAL1" "METAL2" "METAL3" "METAL4") 
						     	?value couche 
						     	?callback "println( \"couche change\" )"
						) 
				champs_datas = append1(champs_datas list(id_label 550:y+40 200:50 10))
				y = y + 30 
		)


			separateur =   hiCreateSeparatorField(
								?name     'sep2
							     )
			y = y + 50 

			champs_datas = append1(champs_datas list(separateur 0:y 635:0))

	
			id_space = hiCreateFloatField(
							?name 'spacing 
							?prompt "Espace:" 
						        ?value 0.28
							?defValue 0.28 
						        ?range list(0 100)
							) 

			champs_datas = append1(champs_datas list(id_space 10:y 130:80 50))

			y = y + 70

			id_style =  hiCreateCyclicField(
							     ?name        'text_style
							     ?choices     '("stick" "roman" "gothic")
							     ?prompt      "Style :"
							     ?value       "stick"
							     ?defValue    "stick"
			  				)

			champs_datas = append1(champs_datas list(id_style 10:y 10:100 50))

			
			

			id_frame = hiCreateFrameField(
				                        ?name 'frame
							
			                      ) 


			champs_datas = append1(champs_datas list(id_frame 150:y 400:200 ))

			
			ze =hiCreateLabel(
	                        ?name 'sourceBoxLabel
        	                ?labelText " Commum "
                	      ) 

			champs_datas = append1(champs_datas list(ze 180:y-10 50:25 ))
	
			
			position_commune = hiCreateCyclicField(
							?name 'position_commune
							?prompt " " 
						     	?choices list("left" "right" "top" "bottom") 
						     	?value position
						     	?callback "println( \"position change\" )"
						) 



			champs_datas = append1(champs_datas list(position_commune 180:y+20 180:240 50))

			pin_commune =  hiCreateCyclicField(
							     ?name        'pin_commune
							     ?choices     '("stick" "roman" "gothic")
							     ?prompt      " "
							     ?value       "stick"
							     ?defValue    "stick"
			 				)

			champs_datas = append1(champs_datas list(pin_commune 300:y+20 300:360 50))

			label_commun =  hiCreateCyclicField(
							     ?name        'label_commun
							     ?choices     '("stick" "roman" "gothic")
							     ?prompt      " "
							     ?value       "stick"
							     ?defValue    "stick"
			  				)

			champs_datas = append1(champs_datas list(label_commun 400:y+20 400:460 50))


			id_taille = hiCreateFloatField(
							?name 'taille 
							?prompt "Taille:" 
						        ?value 0.28
							?defValue 0.28 
						        ?range list(0 10000)
							) 	

			champs_datas = append1(champs_datas list(id_taille 10:y+20 130:80 50))

			y = y + 60 

			
			selection = hiCreateRadioField(
						   ?name      'selection_pins
						   ?prompt    "Selection: " 
						   ?choices   list( "Toutes" "Aucunes" ) 
						   ?value     "Toutes" 
						   ?defValue  "Toutes" 
						   ?callback   list("selection_pins()")	
						)

			champs_datas = append1(champs_datas list(selection 200:y+20 130:80 80))

			btn_place = hiCreateButton(  ?name 'btn_place
						     ?buttonText "Placer pins" 
						     ?callback "placer()"
						) 
	
			champs_datas = append1(champs_datas list(btn_place 200:y+50 110:30 10))


			

			Form_appli = hiCreateAppForm(
                        			         ?name 'Form_sec
			                                 ?formTitle "PIN Definition : @ patrice.delpy"
			                                 ?fields champs_datas
			                                 ?callback 'verifier_focus
			                                 ?initialSize    t
							 ?buttonLayout 'OKCancelApply
			                                 ?unmapAfterCB   nil
		                                 )
			
			hiDisplayForm(Form_appli) 

)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
procedure(placer()

	
	cpt_gauche=0
	cpt_droite=0
	cpt_haut=0 
	cpt_bas=0
	espace = 0.0
	
	H_precedent = 0.0
	L_precedent = 0.0

	minX=0
	minY=0

	maxX=100
	maxY=100

	decalage_left = 0
	decalage_right = 0
        decalage_top = 0
	decalage_bottom = 0

	tmp3 = '()

	espace = Form_appli~>spacing~>value
	style = Form_appli~>text_style~>value

	liste_orient = '()

	for(i 0 length(pins)-1

		sprintf(largeur "Form_appli~>largeur_pin_%d~>value" i)
		L = evalstring(largeur)
		sprintf(hauteur "Form_appli~>hauteur_pin_%d~>value" i)
		H = evalstring(hauteur)
		sprintf(position "Form_appli~>position_pin_%d~>value" i)
		pos = evalstring(position)
		sprintf(couche "Form_appli~>couche_pin_%d~>value" i)
		layer = evalstring(couche)
		sprintf(etat_bouton "Form_appli~>bouton_%d~>value" i)
		check_etat = evalstring(etat_bouton)

		if(check_etat == t then

			case( pos
	     
					("left"
					  ;printf(" LEFT  \n"  )
					   angle = "R0"
						if(cpt_gauche==0 then
					       		x1=minX 
							y1=minY + decalage_bottom 
							cpt_gauche++
							H_precedent=H
							decalage_left = L + espace
						else
							x1=x1
							y1=y1+H_precedent+espace
							cpt_gauche++	
							H_precedent=H	
				                );if	
					)
				
					("right"
  					  ;printf(" right  \n"  )
					  angle = "R0" 
						if(cpt_droite==0 then
					       		x1=maxX-L
					       		y1=minY
					       		cpt_droite++
					       		H_precedent=H
							decalage_right = 1
					    	else
				       			x1=x1
							y1=y1+H_precedent+espace
		 				        cpt_droite++
						        H_precedent=H	
					        );if	
	      				)

					("top"
					  ;printf(" top  \n"  )
				          angle = "R90"
						if(cpt_haut==0 then
				        		x1=minX
 				        		y1=maxY-H
					        	cpt_haut++
				       			L_precedent=L
							decalage_top = 1
				    		else
						        x1=x1+L_precedent+espace
				       			y1=maxY-H	
  				       			cpt_haut++       
				       			L_precedent=L	
				      		);if	
	      				)

					("bottom"
					 angle = "R90"
					  ;printf(" bottom  \n"  )
						if(cpt_bas==0 then
						       x1=minX + decalage_left
						       y1=minY
						       L_precedent=L
						       cpt_bas++
						       decalage_bottom = H + espace
					    	else
						       x1=x1+L_precedent+espace
					       	       y1=y1				       
						       L_precedent=L	
						       cpt_bas++
						);if	
	      				)
				    ); case

				delta_x=x1+L	;x0
				delta_y=y1+H	;y0
				couple=list(x1:y1 delta_x:delta_y)
				;printf(" nouvelle taille %L \n"  couple)
				nth(i tmp2)~>bBox=couple
				nth(i tmp2)~>lpp=list(layer "pin")

				liste_orient = append1(liste_orient angle)	
		)
	)

	tmp3 = '()

	for(i 0 length(pins)-1
	    id = leSearchHierarchy(cv cv~>bBox 0 "label" list(list("text" "==" nth(i pins) ))) 
	    tmp3 = append1(tmp3 car(id))	
	)


	taille = Form_appli~>taille~>value

	for(i 0 length(pins)-1
		if(check_etat == t then

			sprintf(couche "Form_appli~>label_pin_%d~>value" i)
			layer = evalstring(couche)

			box = nth(i tmp2)~>bBox
			centreX=((caadr(box) - caar(box))/2.0) + caar(box)
			centreY=((cadadr(box) - cadar(box))/2.0) + cadar(box)
			nth(i tmp3)~>xy=list(centreX centreY)
			nth(i tmp3)~>lpp = list(layer "pin")
		        nth(i tmp3)~>height = taille ;0.2 
			nth(i tmp3)~>font = style 
			if(nth(i liste_orient) == "R0" then
				nth(i tmp3)~>orient = "R0" 
			else
				nth(i tmp3)~>orient = "R90" 
			)

			;printf(" Centre %L %L\n" centreX centreY)
		)
        )	

	    printf(" Placement is done ...  \n"  )
	

)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;