txt = generate_palette(lisf,path,nameP)
Add here a paragraph of the function description. Other paragraph can be added
Add here a paragraph of the function description
Add here scilab instructions and comments
//////////////////// //generate_palette //Version 1 - vendredi 10 sept 2004 // //Crée un fichier cosf à partir d'une //liste de fonctions d'interface scicos // //lsh //txt chaine de caractère du fichier cosf // //rsh //lisf : liste de noms de fonction //nameP : nom de la palette (sans extension) // //Lundi 4 avril 2005 //Rajout du chemin où ecrire le fichier cosf : path function txt=generate_palette(lisf,path,nameP) //Affiche un message printf("Generate "+nameP+" palette\n"); //Déclaration variable locale sp_x=30 //espace entre chaque block sp_y=22 //espace entre chaque ligne nb_r=5 //nombre de block par ligne lmax=80; //longeur max d'une ligne txt du fichier j=0; //compteur colonne blk_x=0; //coordonnée x du block blk_y=sp_y; //coordonnée y du block blk_y1=0; //memo de la largeur max d'un block sur une ligne //Charge librairies Scicos load SCI/macros/scicos/lib exec(loadpallibs,-1) //charge une structure vide scs_m=scicos_diagram() //Nomme la fenêtre scs_m.props("title")=nameP //Ecrit en-tête du fichier cosf t=['scicos_ver='"scicos2.7.3'"' 'scs_m=scicos_diagram()'] t1=sci2exp(scs_m.props,lmax); txt=[t;'scs_m.props='+t1(1);t1(2:$)] //Pour chaque fonction for l=1:size(lisf,1) //execute cas define du bloc l ierror=execstr('blk='+lisf(l,1)+'(''define'')','errcatch') //redimensionne block blk.graphics("sz")(1)=blk.graphics("sz")(1)*20 blk.graphics("sz")(2)=blk.graphics("sz")(2)*20 //Mémorise le bloc le plus haut if(blk.graphics("sz")(2)>blk_y1) then blk_y1=blk.graphics("sz")(2) end //incremente compteur colonne j=j+1; //Test début de colonne if j==1 then blk_x=sp_x //position x du bloc colonne 1 end //Position du block dans la palette blk.graphics("orig")=[blk_x blk_y] //Incrémente la position x du block blk_x=blk_x+blk.graphics("sz")(1)+sp_x //Test fin de colonne if j==nb_r j=0 //RAZ compteur colonne blk_y=blk_y+blk_y1+sp_y //Incremente position y blk_y1=0 //RAZ longueur bloc le plus haut end //Ecrit scs_m.objs(l) lhs='scs_m.objs('+string(l)+')=' t1=sci2exp(blk,lmax-length(lhs)) n1=size(t1,1) bl1=' ';bl1=part(bl1,1:length(lhs)) txt=[txt;lhs+t1(1);bl1(ones(n1-1,1))+t1(2:$)] end //Enregistre txt dans nameP.cosf mputl(txt,path+nameP+'.cosf'); endfunction