1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280
|
function uicontrol_main()
//paramètres global qui seront utilisé plusieurs fois pour différents fenêtres
global margin_x;
global margin_y;
global padding_x;
global padding_y;
global frame_w;
global frame_h;
global plot_w;
global plot_h;
//paramètres généraux qui reviendront tout le temps
//============================================================
frame_w = 300; //largeur fenêtre
frame_h = 550; //hauteur fenêtre
plot_w = 600; //largeur courbe
plot_h = frame_h; //hauteur courbe
margin_x = 15; // espacement horizontal entre chaque fenêtres
margin_y = 15; // espacement vertical entre chaque fenêtre
padding_x = 10; //espace entre chaque marge
padding_y = 10
button_w = 100; //largeur du bouton
button_h = 30; // hauteur du bouton
defaultfont = "arial" //default font...
subframe_font_size = 12; // Title font size (Rotation angle, Colormap, ...)
text_font_size = 11; // Text font size
// Figure creation (main frame ? )
//===================================================================
axes_w = 3*margin_x + frame_w + plot_w; //taille de la largeur de la figure = 3*marge + fenetre + la courbe
axes_h = 2*margin_y + frame_h; //hauteur de l'axe
test_plot2d = scf()
// Remove Scilab graphics menus & toolbar
delmenu(test_plot2d.figure_id, gettext("&File"));
delmenu(test_plot2d.figure_id, gettext("&Tools"));
delmenu(test_plot2d.figure_id, gettext("&Edit"));
delmenu(test_plot2d.figure_id, gettext("&?"));
toolbar(test_plot2d.figure_id, "off");
test_plot2d.background = -2;
test_plot2d.color_map = jetcolormap(128);
test_plot2d.figure_position = [0 0];
test_plot2d.figure_name = gettext("Pendule double : méthode RK2");
// nouveau menu
h = uimenu("parent", test_plot2d,"label",gettext("file")); //création du menu
uimenu("parent",h, "label", gettext("Fermer"),"callback","demo_plot3d=get_figure_handle(100001);delete(demo_plot3d);", "tag","close_menu"); // créatioin du sous menu
test_plot2d.axes_size = [axes_w axes_h]; //on donne la taille de la fenêtre
//création de la frame [Contrôle des paramètres]
//========================================================================
frame_controle = uicontrol(...
"parent",test_plot2d,...
"relief", "groove",...
"style", "frame",...
"units", "pixels",...
"position", [ margin_x margin_y frame_w frame_h],...
"horizontalalignment" , "center", ...
"background" , [1 1 1], ...
"tag" , "panneau de contrôle" ...
);
//création du titre
frame_title = uicontrol( ...
"parent" , test_plot2d,...
"style" , "text",...
"string" , "Panneau de contrôle",...
"units" , "pixels",...
"position" , [ 30+margin_x margin_y+frame_h-10 frame_w-60 20 ],...
"fontname" , defaultfont,...
"fontunits" , "points",...
"fontsize" , 16,...
"horizontalalignment" , "center", ...
"background" , [1 1 1], ...
"tag" , "titre_panneau_contrôle" ...
);
// changement dynamique des paramètres
//======================================================================
cdp_frame_w = frame_w-2*padding_x;
cdp_frame_h = 400;
cdp_frame_pos_x = padding_x+margin_x;
cdp_frame_pos_y = (margin_y+frame_h) - 4*padding_y - cdp_frame_h;
// frame m1,l1, alpha1
cdp_edit_m1_w = cdp_frame_w -20;
cdp_edit_m1_h = 20;
cdp_edit_m1_pos_x = cdp_frame_pos_x +10;
cdp_edit_m1_pos_y = cdp_frame_pos_y + cdp_frame_h - 4*padding_y;
cdp_edit_l1_w = cdp_frame_w -20;
cdp_edit_l1_h = 20;
cdp_edit_l1_pos_x = cdp_frame_pos_x +10;
cdp_edit_l1_pos_y = cdp_frame_pos_y + cdp_frame_h - 7*padding_y;
cdp_edit_alph1_w = cdp_frame_w -20;
cdp_edit_alph1_h = 20;
cdp_edit_alph1_pos_x = cdp_frame_pos_x +10;
cdp_edit_alph1_pos_y = cdp_frame_pos_y + cdp_frame_h - 10*padding_y;
//frame m2,l2,alpha2
cdp_edit_m2_w = cdp_frame_w -20;
cdp_edit_m2_h = 20;
cdp_edit_m2_pos_x = cdp_frame_pos_x +10;
cdp_edit_m2_pos_y = cdp_frame_pos_y + cdp_frame_h - 13*padding_y;
cdp_edit_l2_w = cdp_frame_w -20;
cdp_edit_l2_h = 20;
cdp_edit_l2_pos_x = cdp_frame_pos_x +10;
cdp_edit_l2_pos_y = cdp_frame_pos_y + cdp_frame_h - 16*padding_y;
cdp_edit_alph2_w = cdp_frame_w -20;
cdp_edit_alph2_h = 20;
cdp_edit_alph2_pos_x = cdp_frame_pos_x +10;
cdp_edit_alph2_pos_y = cdp_frame_pos_y + cdp_frame_h - 19*padding_y;
//frame changement dynamique des paramètre
cdp_frame = uicontrol(...
"parent" , test_plot2d,...
"relief", "groove",...
"style", "frame",...
"units" ,"pixels",...
"position", [cdp_frame_pos_x cdp_frame_pos_y cdp_frame_w cdp_frame_h], ...
"horizontalalignment", "center",...
"background", [1 1 1] ...
);
// frame title
cdp_frame_title = uicontrol(...
"parent", test_plot2d,...
"style", "text",...
"string", "choix des paramètres",...
"units","pixels",...
"position",[70+cdp_frame_pos_x cdp_frame_pos_y+cdp_frame_h-9 cdp_frame_w-140 18],...
"fontname",defaultfont,...
"fontunits","points",...
"fontsize",subframe_font_size,...
"horizontalalignment", "center",...
"background",[1 1 1]...
);
//m1,l1,Alph1
cdp_edit_m1 =uicontrol(...
"parent", test_plot2d,...
"style","edit",...
"FontSize", 11, ...
"String", gettext("m1"),...
"BackgroundColor", [1 1 1],...
"position",[cdp_edit_m1_pos_x cdp_edit_m1_pos_y cdp_edit_m1_w cdp_edit_m1_h],...
"callback","m1"...
);
cdp_edit_l1 =uicontrol(...
"parent", test_plot2d,...
"style","edit",...
"FontSize", 11, ...
"String", gettext("l1"),...
"BackgroundColor", [1 1 1],...
"position",[cdp_edit_l1_pos_x cdp_edit_l1_pos_y cdp_edit_l1_w cdp_edit_l1_h],...
"callback","l1"...
);
cdp_edit_alph1 =uicontrol(...
"parent", test_plot2d,...
"style","edit",...
"FontSize", 11, ...
"String", gettext("téhta1"),...
"BackgroundColor", [1 1 1],...
"position",[cdp_edit_alph1_pos_x cdp_edit_alph1_pos_y cdp_edit_alph1_w cdp_edit_alph1_h],...
"callback","alph1"...
);
//m2, l2, Alph2
cdp_edit_m2 =uicontrol(...
"parent", test_plot2d,...
"style","edit",...
"FontSize", 11, ...
"String", gettext("m2"),...
"BackgroundColor", [1 1 1],...
"position",[cdp_edit_m2_pos_x cdp_edit_m2_pos_y cdp_edit_m2_w cdp_edit_m2_h],...
"callback","m2"...
);
cdp_edit_l2 =uicontrol(...
"parent", test_plot2d,...
"style","edit",...
"FontSize", 11, ...
"String", gettext("l2"),...
"BackgroundColor", [1 1 1],...
"position",[cdp_edit_l2_pos_x cdp_edit_l2_pos_y cdp_edit_l2_w cdp_edit_l2_h],...
"callback","l2"...
);
cdp_edit_alph2 =uicontrol(...
"parent", test_plot2d,...
"style","edit",...
"FontSize", 11, ...
"String", gettext("alph2"),...
"BackgroundColor", [1 1 1],...
"position",[cdp_edit_alph2_pos_x cdp_edit_alph2_pos_y cdp_edit_alph2_w cdp_edit_alph2_h],...
"callback","alph2"...
);
//STOP button
//============================================================================
button_frame_w = frame_w - 20* padding_x;
button_frame_h = 65;
button_frame_pos_x = 10*padding_x+margin_x;
button_frame_pos_y = cdp_frame_pos_y - 2*padding_y - button_frame_h;
button_w = 900;
button_h = 50;
button_pos_x = button_frame_pos_x + floor((button_frame_w/2)-(button_w/2));
button_pos_y = button_frame_pos_y + floor((button_frame_h/2)-(button_h/2));
//frame button
button_frame = uicontrol(...
"parent" , test_plot2d ,...
"style","frame",...
"relief","groove",...
"units","pixels",...
"position", [button_frame_pos_x button_frame_pos_y button_frame_w button_frame_h],..
"horizontalalignement", "center",...
"background", [1 1 1],...
);
// titre button
button_frame_title = uicontrol( ...
"parent" , test_plot2d,...
"style" , "text",...
"string" , "Stop",...
"units" , "pixels",...
"position" , [ 70+button_frame_pos_x button_frame_pos_y+button_frame_h-9 button_frame_w-140 18 ],...
"fontname" , defaultfont,...
"fontunits" , "points",...
"fontsize" , subframe_font_size,...
"horizontalalignment" , "center", ...
"background" , [1 1 1], ...
);
// button : pushbuton
button_frame_title = uicontrol( ...
"parent" , test_plot2d,...
"style" , "pushbutton",...
"string" , "STOP",...
"units" , "pixels",...
"position" , [ button_pos_x button_pos_y button_w button_h],...
"background" , [1 1 1], ...
"callback" , "stop_animation",...
);
endfunction
h=uicontrol_main(); |
Partager