Accueil > Linux / Logiciels Libres > Scilab > Application GUI avec Scilab

Application GUI avec Scilab

jeudi 8 décembre 2011, par Yann

Ce travail à fait l’objet d’une publication dans Linux Pratique 70

 Exemple d’application GUI

Trajectoire et patch 3D
Archive de l’application « Trajectoire et Patch 3D »

Notre application graphique proposer les fonctionnalités suivantes :

  • Chargement d’un fichier patch par l’intermédiaire d’une boite de dialogue ;
  • Prévisualisation du patch 3D dans une zone graphique ;
  • Modification de l’orientation de la prévisualisation du patch suivant 2 angles ;
  • Choix de la couleur du patch ;
  • Définition de la trajectoire 3D à l’aide de 4 vecteurs (t, x, y et z) ;
  • Modification du style de la courbe 3D (couleur, type de trait, épaisseur) ;
  • Animation du patch sur la trajectoire
  • Modification de l’orientation de la visualisation de l’animation suivant 2 angles de vues ;
  • Choix de l’échelle du patch ;

 Patchs 3D disponibles

 Résultats

 Code source de l’application

// This GUI file is generated by guibuilder version 2.2
//////////
f=figure('figure_position',[324,33],'figure_size',[911,920],'auto_resize','on','background',[33],'figure_name','Trajectoire et Patch 3D');
//////////
delmenu(f.figure_id,gettext('File'));
delmenu(f.figure_id,gettext('?'));
delmenu(f.figure_id, gettext("&Edit"));
delmenu(f.figure_id,gettext('Tools'));
toolbar(f.figure_id,'off');
// Add custom menus
appli_menu = uimenu("Parent", f, "Label", gettext("Application"));
quit_menu = uimenu("Parent", appli_menu, "Label", gettext("Quit Application"), "callback", "exit_scilab(handles);");


handles.dummy = 0;
handles.ParentFrame=uicontrol(f,'unit','normalized','BackgroundColor',[0.8,0.8,0.8],'Enable','on','FontAngle','normal','FontName','helvetica','FontSize',[12],'FontUnits','points','FontWeight','normal','ForegroundColor',[0,0,0],'HorizontalAlignment','center','ListboxTop',[],'Max',[1],'Min',[0],'Position',[0,0,0.2715573,0.9718310],'Relief','sunken','SliderStep',[0.01,0.1],'String','Configuration','Style','frame','Value',[0],'VerticalAlignment','middle','Visible','on','Tag','ParentFrame','Callback','InitVariables(handles)')
handles.ParentFrameLabel=uicontrol(f,'unit','normalized','BackgroundColor',[0.8,0.8,0.8],'Enable','on','FontAngle','normal','FontName','helvetica','FontSize',[12],'FontUnits','points','FontWeight','normal','ForegroundColor',[0,0,0],'HorizontalAlignment','center','ListboxTop',[],'Max',[1],'Min',[0],'Position',[0.0012870,0.9281690,0.1106821,0.0267606],'Relief','flat','SliderStep',[0.01,0.1],'String','$\Large\mbox{Configuration}$','Style','text','Value',[0],'VerticalAlignment','middle','Visible','on','Tag','ParentFrameLabel','Callback','')
handles.TridObjFrame=uicontrol(f,'unit','normalized','BackgroundColor',[0.8,0.8,0.8],'Enable','on','FontAngle','normal','FontName','helvetica','FontSize',[12],'FontUnits','points','FontWeight','normal','ForegroundColor',[0,0,0],'HorizontalAlignment','center','ListboxTop',[],'Max',[1],'Min',[0],'Position',[0,0.8211268,0.2471042,0.1028169],'Relief','ridge','SliderStep',[0.01,0.1],'String','Objet 3D','Style','frame','Value',[0],'VerticalAlignment','middle','Visible','on','Tag','TridObjFrame','Callback','')
handles.TridObjFrameLabel=uicontrol(f,'unit','normalized','BackgroundColor',[0.8,0.8,0.8],'Enable','on','FontAngle','normal','FontName','helvetica','FontSize',[12],'FontUnits','points','FontWeight','normal','ForegroundColor',[0,0,0],'HorizontalAlignment','center','ListboxTop',[],'Max',[1],'Min',[0],'Position',[0.0025740,0.8943662,0.0656371,0.0239437],'Relief','flat','SliderStep',[0.01,0.1],'String','$\large\mbox{Objet 3D}$','Style','text','Value',[0],'VerticalAlignment','middle','Visible','on','Tag','TridObjFrameLabel','Callback','')
handles.TridObjLoadBut=uicontrol(f,'unit','normalized','BackgroundColor',[0.6,0.6,0.6],'Enable','on','FontAngle','normal','FontName','helvetica','FontSize',[12],'FontUnits','points','FontWeight','normal','ForegroundColor',[0,0,0],'HorizontalAlignment','center','ListboxTop',[],'Max',[1],'Min',[0],'Position',[0.0772201,0.8957746,0.1621622,0.0253521],'Relief','raised','SliderStep',[0.01,0.1],'String','$\large\mbox{Charger Patch 3D...}$','Style','pushbutton','Value',[0],'VerticalAlignment','middle','Visible','on','Tag','TridObjLoadBut','Callback','TridObjLoadBut_callback(handles)')
handles.TridObjFile=uicontrol(f,'unit','normalized','BackgroundColor',[1,1,1],'Enable','on','FontAngle','normal','FontName','helvetica','FontSize',[12],'FontUnits','points','FontWeight','normal','ForegroundColor',[0,0,0],'HorizontalAlignment','center','ListboxTop',[],'Max',[1],'Min',[0],'Position',[0.0386100,0.8704225,0.1930502,0.0183099],'Relief','flat','SliderStep',[0.01,0.1],'String','','Style','text','Value',[0],'VerticalAlignment','middle','Visible','on','Tag','TridObjFile','Callback','')
handles.TridObjPreview= newaxes();handles.TridObjPreview.margins = [ 0 0 0 0];handles.TridObjPreview.axes_bounds = [0.3020948,0.0291616,0.1786108,0.1923402];
handles.TridObjGraph= newaxes();handles.TridObjGraph.margins = [ 0 0 0 0];handles.TridObjGraph.axes_bounds = [0.35,0.26,0.62,0.7];
handles.TitleRotationPatchFrame=uicontrol(f,'unit','normalized','BackgroundColor',[0.8,0.8,0.8],'Enable','on','FontAngle','normal','FontName','helvetica','FontSize',[12],'FontUnits','points','FontWeight','normal','ForegroundColor',[0,0,0],'HorizontalAlignment','center','ListboxTop',[],'Max',[1],'Min',[0],'Position',[0.4864865,0.8647887,0.4633205,0.0845070],'Relief','ridge','SliderStep',[0.01,0.1],'String','Zone de Titre','Style','frame','Value',[0],'VerticalAlignment','middle','Visible','on','Tag','TitleRotationPatchFrame','Callback','')
handles.TitleRotationGraphFrame=uicontrol(f,'unit','normalized','BackgroundColor',[0.8,0.8,0.8],'Enable','on','FontAngle','normal','FontName','helvetica','FontSize',[12],'FontUnits','points','FontWeight','normal','ForegroundColor',[0,0,0],'HorizontalAlignment','center','ListboxTop',[],'Max',[1],'Min',[0],'Position',[0.4864865,0.7605634,0.4633205,0.0845070],'Relief','ridge','SliderStep',[0.01,0.1],'String','Zone de Titre','Style','frame','Value',[0],'VerticalAlignment','middle','Visible','on','Tag','TitleRotationGraphFrame','Callback','')
handles.ColorLabel=uicontrol(f,'unit','normalized','BackgroundColor',[0.8,0.8,0.8],'Enable','on','FontAngle','normal','FontName','helvetica','FontSize',[12],'FontUnits','points','FontWeight','normal','ForegroundColor',[0,0,0],'HorizontalAlignment','center','ListboxTop',[],'Max',[1],'Min',[0],'Position',[0.0025740,0.8239437,0.0540541,0.0197183],'Relief','flat','SliderStep',[0.01,0.1],'String','$\large\mbox{Couleur}$','Style','text','Value',[0],'VerticalAlignment','middle','Visible','on','Tag','ColorLabel','Callback','')
handles.ColorList=uicontrol(f,'unit','normalized','BackgroundColor',[0.8,0.8,0.8],'Enable','on','FontAngle','normal','FontName','helvetica','FontSize',[12],'FontUnits','points','FontWeight','normal','ForegroundColor',[0,0,0],'HorizontalAlignment','center','ListboxTop',[],'Max',[1],'Min',[0],'Position',[0.0643501,0.8281690,0.1621622,0.0169014],'Relief','flat','SliderStep',[0.01,0.1],'String','noir|bleu|vert|cyan|rouge|violet|jaune|blanc','Style','popupmenu','Value',[1],'VerticalAlignment','middle','Visible','on','Tag','ColorList','Callback','ColorList_callback(handles)')
handles.RotationPreviewLabel=uicontrol(f,'unit','normalized','BackgroundColor',[0.8,0.8,0.8],'Enable','on','FontAngle','normal','FontName','helvetica','FontSize',[12],'FontUnits','points','FontWeight','normal','ForegroundColor',[0,0,0],'HorizontalAlignment','center','ListboxTop',[],'Max',[1],'Min',[0],'Position',[0.4942085,0.9281690,0.1312741,0.0197183],'Relief','flat','SliderStep',[0.01,0.1],'String','$\large \mbox{Rotation Patch 3D}$','Style','text','Value',[0],'VerticalAlignment','middle','Visible','on','Tag','RotationPreviewLabel','Callback','')
handles.RotationGraphLabel=uicontrol(f,'unit','normalized','BackgroundColor',[0.8,0.8,0.8],'Enable','on','FontAngle','normal','FontName','helvetica','FontSize',[12],'FontUnits','points','FontWeight','normal','ForegroundColor',[0,0,0],'HorizontalAlignment','center','ListboxTop',[],'Max',[1],'Min',[0],'Position',[0.4942085,0.8126761,0.1647362,0.0239437],'Relief','flat','SliderStep',[0.01,0.1],'String','$\large \mbox{Rotation Graphique 3D}$','Style','text','Value',[0],'VerticalAlignment','middle','Visible','on','Tag','RotationGraphLabel','Callback','')
handles.LabelPreview3D=uicontrol(f,'unit','normalized','BackgroundColor',[0.8,0.8,0.8],'Enable','on','FontAngle','normal','FontName','helvetica','FontSize',[12],'FontUnits','points','FontWeight','normal','ForegroundColor',[0,0,0],'HorizontalAlignment','center','ListboxTop',[],'Max',[1],'Min',[0],'Position',[0.3088803,0.9690141,0.0501931,0.0239437],'Relief','flat','SliderStep',[0.01,0.1],'String','$\large \mbox{Aperçu}$','Style','text','Value',[0],'VerticalAlignment','middle','Visible','on','Tag','LabelPreview3D','Callback','')
handles.TrajectoryFrame=uicontrol(f,'unit','normalized','BackgroundColor',[0.8,0.8,0.8],'Enable','on','FontAngle','normal','FontName','helvetica','FontSize',[12],'FontUnits','points','FontWeight','normal','ForegroundColor',[0,0,0],'HorizontalAlignment','center','ListboxTop',[],'Max',[1],'Min',[0],'Position',[0,0.4563380,0.2471042,0.3633803],'Relief','ridge','SliderStep',[0.01,0.1],'String','Frame trajectoire','Style','frame','Value',[0],'VerticalAlignment','middle','Visible','on','Tag','TrajectoryFrame','Callback','')
handles.TrajectoryFrameTitle=uicontrol(f,'unit','normalized','BackgroundColor',[0.8,0.8,0.8],'Enable','on','FontAngle','normal','FontName','helvetica','FontSize',[12],'FontUnits','points','FontWeight','normal','ForegroundColor',[0,0,0],'HorizontalAlignment','center','ListboxTop',[],'Max',[1],'Min',[0],'Position',[0.0077220,0.7704225,0.2046332,0.0267606],'Relief','flat','SliderStep',[0.01,0.1],'String','$\Large\mbox{Définition Trajectoire 3D}$','Style','text','Value',[0],'VerticalAlignment','middle','Visible','on','Tag','TrajectoryFrameTitle','Callback','')
handles.TrajectoryEquation=uicontrol(f,'unit','normalized','BackgroundColor',[0.8,0.8,0.8],'Enable','on','FontAngle','normal','FontName','helvetica','FontSize',[12],'FontUnits','points','FontWeight','normal','ForegroundColor',[0,0,0],'HorizontalAlignment','center','ListboxTop',[],'Max',[1],'Min',[0],'Position',[0.0231660,0.6830986,0.1685972,0.0873239],'Relief','flat','SliderStep',[0.01,0.1],'String','$\mbox{Exemple : } \left\{\begin{array}{l}t=[0,10],\\ x=10.sin(t),\\ y=3.t,\\ z=0.2.t^2 \end{array}\right.$','Style','text','Value',[0],'VerticalAlignment','middle','Visible','on','Tag','TrajectoryEquation','Callback','')
handles.LabelT=uicontrol(f,'unit','normalized','BackgroundColor',[0.8,0.8,0.8],'Enable','on','FontAngle','normal','FontName','helvetica','FontSize',[12],'FontUnits','points','FontWeight','normal','ForegroundColor',[0,0,0],'HorizontalAlignment','center','ListboxTop',[],'Max',[1],'Min',[0],'Position',[0.0231660,0.6549296,0.0231660,0.0183099],'Relief','flat','SliderStep',[0.01,0.1],'String','$\large t =$','Style','text','Value',[0],'VerticalAlignment','middle','Visible','on','Tag','LabelT','Callback','')
handles.EditT=uicontrol(f,'unit','normalized','BackgroundColor',[0.8,0.8,0.8],'Enable','on','FontAngle','normal','FontName','helvetica','FontSize',[12],'FontUnits','points','FontWeight','normal','ForegroundColor',[0,0,0],'HorizontalAlignment','center','ListboxTop',[],'Max',[1],'Min',[0],'Position',[0.0540541,0.6676056,0.1621622,0.0169014],'Relief','sunken','SliderStep',[0.01,0.1],'String','0:0.01:10','Style','edit','Value',[0],'VerticalAlignment','middle','Visible','on','Tag','EditT','Callback','')
handles.LabelX=uicontrol(f,'unit','normalized','BackgroundColor',[0.8,0.8,0.8],'Enable','on','FontAngle','normal','FontName','helvetica','FontSize',[12],'FontUnits','points','FontWeight','normal','ForegroundColor',[0,0,0],'HorizontalAlignment','center','ListboxTop',[],'Max',[1],'Min',[0],'Position',[0.0077220,0.6183099,0.0437580,0.0253521],'Relief','flat','SliderStep',[0.01,0.1],'String','$\large x(t) =$','Style','text','Value',[0],'VerticalAlignment','middle','Visible','on','Tag','LabelX','Callback','')
handles.EditX=uicontrol(f,'unit','normalized','BackgroundColor',[0.8,0.8,0.8],'Enable','on','FontAngle','normal','FontName','helvetica','FontSize',[12],'FontUnits','points','FontWeight','normal','ForegroundColor',[0,0,0],'HorizontalAlignment','center','ListboxTop',[],'Max',[1],'Min',[0],'Position',[0.0540541,0.6338028,0.1621622,0.0169014],'Relief','sunken','SliderStep',[0.01,0.1],'String','10*sin(t)','Style','edit','Value',[0],'VerticalAlignment','middle','Visible','on','Tag','EditX','Callback','')
handles.LabelY=uicontrol(f,'unit','normalized','BackgroundColor',[0.8,0.8,0.8],'Enable','on','FontAngle','normal','FontName','helvetica','FontSize',[12],'FontUnits','points','FontWeight','normal','ForegroundColor',[0,0,0],'HorizontalAlignment','center','ListboxTop',[],'Max',[1],'Min',[0],'Position',[0.0025740,0.5901408,0.0424710,0.0253521],'Relief','flat','SliderStep',[0.01,0.1],'String','$\large y(t) =$','Style','text','Value',[0],'VerticalAlignment','middle','Visible','on','Tag','LabelY','Callback','')
handles.EditY=uicontrol(f,'unit','normalized','BackgroundColor',[0.8,0.8,0.8],'Enable','on','FontAngle','normal','FontName','helvetica','FontSize',[12],'FontUnits','points','FontWeight','normal','ForegroundColor',[0,0,0],'HorizontalAlignment','center','ListboxTop',[],'Max',[1],'Min',[0],'Position',[0.0540541,0.6084507,0.1621622,0.0169014],'Relief','sunken','SliderStep',[0.01,0.1],'String','3*t','Style','edit','Value',[0],'VerticalAlignment','middle','Visible','on','Tag','EditY','Callback','')
handles.LabelZ=uicontrol(f,'unit','normalized','BackgroundColor',[0.8,0.8,0.8],'Enable','on','FontAngle','normal','FontName','helvetica','FontSize',[12],'FontUnits','points','FontWeight','normal','ForegroundColor',[0,0,0],'HorizontalAlignment','center','ListboxTop',[],'Max',[1],'Min',[0],'Position',[0.0025740,0.5563380,0.0424710,0.0253521],'Relief','flat','SliderStep',[0.01,0.1],'String','$\large z(t) =$','Style','text','Value',[0],'VerticalAlignment','middle','Visible','on','Tag','LabelZ','Callback','')
handles.EditZ=uicontrol(f,'unit','normalized','BackgroundColor',[0.8,0.8,0.8],'Enable','on','FontAngle','normal','FontName','helvetica','FontSize',[12],'FontUnits','points','FontWeight','normal','ForegroundColor',[0,0,0],'HorizontalAlignment','center','ListboxTop',[],'Max',[1],'Min',[0],'Position',[0.0540541,0.5746479,0.1621622,0.0169014],'Relief','sunken','SliderStep',[0.01,0.1],'String','0.2*t.^2','Style','edit','Value',[0],'VerticalAlignment','middle','Visible','on','Tag','EditZ','Callback','')
handles.CreateTraj=uicontrol(f,'unit','normalized','BackgroundColor',[0.6,0.6,0.6],'Enable','on','FontAngle','normal','FontName','helvetica','FontSize',[12],'FontUnits','points','FontWeight','normal','ForegroundColor',[0,0,0],'HorizontalAlignment','center','ListboxTop',[],'Max',[1],'Min',[0],'Position',[0.0553411,0.5338028,0.1338481,0.0253521],'Relief','raised','SliderStep',[0.01,0.1],'String','$\large\mbox{Trace Trajectoire}$','Style','pushbutton','Value',[0],'VerticalAlignment','middle','Visible','on','Tag','CreateTraj','Callback','CreateTraj_callback(handles)')
handles.ColorTrajLabel=uicontrol(f,'unit','normalized','BackgroundColor',[0.8,0.8,0.8],'Enable','on','FontAngle','normal','FontName','helvetica','FontSize',[12],'FontUnits','points','FontWeight','normal','ForegroundColor',[0,0,0],'HorizontalAlignment','center','ListboxTop',[],'Max',[1],'Min',[0],'Position',[0.0077220,0.5014085,0.0540541,0.0197183],'Relief','flat','SliderStep',[0.01,0.1],'String','$\large\mbox{Couleur}$','Style','text','Value',[0],'VerticalAlignment','middle','Visible','on','Tag','ColorTrajLabel','Callback','')
handles.ColorTrajList=uicontrol(f,'unit','normalized','BackgroundColor',[0.8,0.8,0.8],'Enable','on','FontAngle','normal','FontName','helvetica','FontSize',[12],'FontUnits','points','FontWeight','normal','ForegroundColor',[0,0,0],'HorizontalAlignment','center','ListboxTop',[],'Max',[1],'Min',[0],'Position',[0.0772201,0.5070423,0.1621622,0.0169014],'Relief','flat','SliderStep',[0.01,0.1],'String','noir|bleu|vert|cyan|rouge|violet|jaune|blanc','Style','popupmenu','Value',[1],'VerticalAlignment','middle','Visible','on','Tag','ColorTrajList','Callback','ColorTrajList_callback(handles)')
handles.StyleTrajLabel=uicontrol(f,'unit','normalized','BackgroundColor',[0.8,0.8,0.8],'Enable','on','FontAngle','normal','FontName','helvetica','FontSize',[12],'FontUnits','points','FontWeight','normal','ForegroundColor',[0,0,0],'HorizontalAlignment','center','ListboxTop',[],'Max',[1],'Min',[0],'Position',[0.0077220,0.4746479,0.0347490,0.0239437],'Relief','flat','SliderStep',[0.01,0.1],'String','$\large\mbox{Style}$','Style','text','Value',[0],'VerticalAlignment','middle','Visible','on','Tag','StyleTrajLabel','Callback','')
handles.StyleTrajList=uicontrol(f,'unit','normalized','BackgroundColor',[0.8,0.8,0.8],'Enable','on','FontAngle','normal','FontName','helvetica','FontSize',[12],'FontUnits','points','FontWeight','normal','ForegroundColor',[0,0,0],'HorizontalAlignment','center','ListboxTop',[],'Max',[1],'Min',[0],'Position',[0.0785071,0.4816901,0.1467181,0.0169014],'Relief','flat','SliderStep',[0.01,0.1],'String','solid|dash|dash dot|longdash dot|bigdash dot|bigdash longdash|dot|double dot','Style','popupmenu','Value',[1],'VerticalAlignment','middle','Visible','on','Tag','StyleTrajList','Callback','StyleTrajList_callback(handles)')
handles.ThickTrajLabel=uicontrol(f,'unit','normalized','BackgroundColor',[0.8,0.8,0.8],'Enable','on','FontAngle','normal','FontName','helvetica','FontSize',[12],'FontUnits','points','FontWeight','normal','ForegroundColor',[0,0,0],'HorizontalAlignment','center','ListboxTop',[],'Max',[1],'Min',[0],'Position',[0.0077220,0.4507042,0.0669241,0.0239437],'Relief','flat','SliderStep',[0.01,0.1],'String','$\large\mbox{Epaisseur}$','Style','text','Value',[0],'VerticalAlignment','middle','Visible','on','Tag','ThickTrajLabel','Callback','')
handles.ThickTrajList=uicontrol(f,'unit','normalized','BackgroundColor',[0.8,0.8,0.8],'Enable','on','FontAngle','normal','FontName','helvetica','FontSize',[12],'FontUnits','points','FontWeight','normal','ForegroundColor',[0,0,0],'HorizontalAlignment','center','ListboxTop',[],'Max',[1],'Min',[0],'Position',[0.0785071,0.4563380,0.1621622,0.0169014],'Relief','flat','SliderStep',[0.01,0.1],'String','1|2|3|4|5|6|7|8','Style','popupmenu','Value',[1],'VerticalAlignment','middle','Visible','on','Tag','ThickTrajList','Callback','ThickTrajList_callback(handles)')
handles.ThetaPreview=uicontrol(f,'unit','normalized','BackgroundColor',[0.8,0.8,0.8],'Enable','on','FontAngle','normal','FontName','helvetica','FontSize',[12],'FontUnits','points','FontWeight','normal','ForegroundColor',[0,0,0],'HorizontalAlignment','center','ListboxTop',[],'Max',[360],'Min',[0],'Position',[0.6023166,0.9126761,0.3243243,0.0169014],'Relief','flat','SliderStep',[0.01,0.1],'String','$\theta$','Style','slider','Value',[45],'VerticalAlignment','middle','Visible','on','Tag','ThetaPreview','Callback','ThetaPreview_callback(handles)')
handles.ThetaPreviewLabel=uicontrol(f,'unit','normalized','BackgroundColor',[0.8,0.8,0.8],'Enable','on','FontAngle','normal','FontName','helvetica','FontSize',[12],'FontUnits','points','FontWeight','normal','ForegroundColor',[0,0,0],'HorizontalAlignment','center','ListboxTop',[],'Max',[1],'Min',[0],'Position',[0.4942085,0.9042254,0.0283140,0.0225352],'Relief','flat','SliderStep',[0.01,0.1],'String','$\Large \theta=$','Style','text','Value',[0],'VerticalAlignment','middle','Visible','on','Tag','ThetaPreviewLabel','Callback','')
handles.AlphaPreview=uicontrol(f,'unit','normalized','BackgroundColor',[0.8,0.8,0.8],'Enable','on','FontAngle','normal','FontName','helvetica','FontSize',[12],'FontUnits','points','FontWeight','normal','ForegroundColor',[0,0,0],'HorizontalAlignment','center','ListboxTop',[],'Max',[360],'Min',[0],'Position',[0.6023166,0.8788732,0.3256113,0.0169014],'Relief','flat','SliderStep',[0.01,0.1],'String','$\alpha=$','Style','slider','Value',[45],'VerticalAlignment','middle','Visible','on','Tag','AlphaPreview','Callback','AlphaPreview_callback(handles)')
handles.AlphaPreviewLabel=uicontrol(f,'unit','normalized','BackgroundColor',[0.8,0.8,0.8],'Enable','on','FontAngle','normal','FontName','helvetica','FontSize',[12],'FontUnits','points','FontWeight','normal','ForegroundColor',[0,0,0],'HorizontalAlignment','center','ListboxTop',[],'Max',[1],'Min',[0],'Position',[0.4942085,0.8774648,0.0308880,0.0169014],'Relief','flat','SliderStep',[0.01,0.1],'String','$\Large \alpha=$','Style','text','Value',[0],'VerticalAlignment','middle','Visible','on','Tag','AlphaPreviewLabel','Callback','')
handles.ThetaPreviewEdit=uicontrol(f,'unit','normalized','BackgroundColor',[0.8,0.8,0.8],'Enable','on','FontAngle','normal','FontName','helvetica','FontSize',[12],'FontUnits','points','FontWeight','normal','ForegroundColor',[0,0,0],'HorizontalAlignment','center','ListboxTop',[],'Max',[1],'Min',[0],'Position',[0.5482625,0.9126761,0.0386100,0.0169014],'Relief','sunken','SliderStep',[0.01,0.1],'String','35','Style','edit','Value',[0],'VerticalAlignment','middle','Visible','on','Tag','ThetaPreviewEdit','Callback','')
handles.AlphaPreviewEdit=uicontrol(f,'unit','normalized','BackgroundColor',[0.8,0.8,0.8],'Enable','on','FontAngle','normal','FontName','helvetica','FontSize',[12],'FontUnits','points','FontWeight','normal','ForegroundColor',[0,0,0],'HorizontalAlignment','center','ListboxTop',[],'Max',[1],'Min',[0],'Position',[0.5482625,0.8788732,0.0386100,0.0169014],'Relief','sunken','SliderStep',[0.01,0.1],'String','45','Style','edit','Value',[0],'VerticalAlignment','middle','Visible','on','Tag','AlphaPreviewEdit','Callback','')
handles.ThetaGraph=uicontrol(f,'unit','normalized','BackgroundColor',[0.8,0.8,0.8],'Enable','on','FontAngle','normal','FontName','helvetica','FontSize',[12],'FontUnits','points','FontWeight','normal','ForegroundColor',[0,0,0],'HorizontalAlignment','center','ListboxTop',[],'Max',[360],'Min',[0],'Position',[0.5945946,0.7943662,0.3256113,0.0169014],'Relief','flat','SliderStep',[0.01,0.1],'String','$\theta$','Style','slider','Value',[45],'VerticalAlignment','middle','Visible','on','Tag','ThetaGraph','Callback','ThetaGraph_callback(handles)')
handles.ThetaGraphLabel=uicontrol(f,'unit','normalized','BackgroundColor',[0.8,0.8,0.8],'Enable','on','FontAngle','normal','FontName','helvetica','FontSize',[12],'FontUnits','points','FontWeight','normal','ForegroundColor',[0,0,0],'HorizontalAlignment','center','ListboxTop',[],'Max',[1],'Min',[0],'Position',[0.4967825,0.7873239,0.0283140,0.0225352],'Relief','flat','SliderStep',[0.01,0.1],'String','$\Large \theta=$','Style','text','Value',[0],'VerticalAlignment','middle','Visible','on','Tag','ThetaGraphLabel','Callback','')
handles.AlphaGraph=uicontrol(f,'unit','normalized','BackgroundColor',[0.8,0.8,0.8],'Enable','on','FontAngle','normal','FontName','helvetica','FontSize',[12],'FontUnits','points','FontWeight','normal','ForegroundColor',[0,0,0],'HorizontalAlignment','center','ListboxTop',[],'Max',[360],'Min',[0],'Position',[0.5881596,0.7690141,0.3256113,0.0169014],'Relief','flat','SliderStep',[0.01,0.1],'String','$\alpha=$','Style','slider','Value',[45],'VerticalAlignment','middle','Visible','on','Tag','AlphaGraph','Callback','AlphaGraph_callback(handles)')
handles.AlphaGraphLabel=uicontrol(f,'unit','normalized','BackgroundColor',[0.8,0.8,0.8],'Enable','on','FontAngle','normal','FontName','helvetica','FontSize',[12],'FontUnits','points','FontWeight','normal','ForegroundColor',[0,0,0],'HorizontalAlignment','center','ListboxTop',[],'Max',[1],'Min',[0],'Position',[0.4954955,0.7647887,0.0308880,0.0169014],'Relief','flat','SliderStep',[0.01,0.1],'String','$\Large \alpha=$','Style','text','Value',[0],'VerticalAlignment','middle','Visible','on','Tag','AlphaGraphLabel','Callback','')
handles.ThetaGraphEdit=uicontrol(f,'unit','normalized','BackgroundColor',[0.8,0.8,0.8],'Enable','on','FontAngle','normal','FontName','helvetica','FontSize',[12],'FontUnits','points','FontWeight','normal','ForegroundColor',[0,0,0],'HorizontalAlignment','center','ListboxTop',[],'Max',[1],'Min',[0],'Position',[0.5405405,0.7943662,0.0386100,0.0169014],'Relief','sunken','SliderStep',[0.01,0.1],'String','35','Style','edit','Value',[0],'VerticalAlignment','middle','Visible','on','Tag','ThetaGraphEdit','Callback','')
handles.AlphaGraphEdit=uicontrol(f,'unit','normalized','BackgroundColor',[0.8,0.8,0.8],'Enable','on','FontAngle','normal','FontName','helvetica','FontSize',[12],'FontUnits','points','FontWeight','normal','ForegroundColor',[0,0,0],'HorizontalAlignment','center','ListboxTop',[],'Max',[1],'Min',[0],'Position',[0.5405405,0.7690141,0.0386100,0.0169014],'Relief','sunken','SliderStep',[0.01,0.1],'String','45','Style','edit','Value',[0],'VerticalAlignment','middle','Visible','on','Tag','AlphaGraphEdit','Callback','')
handles.AnimationFrame=uicontrol(f,'unit','normalized','BackgroundColor',[0.8,0.8,0.8],'Enable','on','FontAngle','normal','FontName','helvetica','FontSize',[12],'FontUnits','points','FontWeight','normal','ForegroundColor',[0,0,0],'HorizontalAlignment','center','ListboxTop',[],'Max',[1],'Min',[0],'Position',[0,0.0253521,0.2471042,0.4225352],'Relief','ridge','SliderStep',[0.01,0.1],'String','FrameAnimation','Style','frame','Value',[0],'VerticalAlignment','middle','Visible','on','Tag','AnimationFrame','Callback','')
handles.AnimationFrameTitle=uicontrol(f,'unit','normalized','BackgroundColor',[0.8,0.8,0.8],'Enable','on','FontAngle','normal','FontName','helvetica','FontSize',[12],'FontUnits','points','FontWeight','normal','ForegroundColor',[0,0,0],'HorizontalAlignment','center','ListboxTop',[],'Max',[1],'Min',[0],'Position',[0.0231660,0.3873239,0.2072072,0.0267606],'Relief','flat','SliderStep',[0.01,0.1],'String','$\Large \mbox{Animation sur trajectoire}$','Style','text','Value',[0],'VerticalAlignment','middle','Visible','on','Tag','AnimationFrameTitle','Callback','')
handles.AnimateButton=uicontrol(f,'unit','normalized','BackgroundColor',[0.6,0.6,0.6],'Enable','on','FontAngle','normal','FontName','helvetica','FontSize',[12],'FontUnits','points','FontWeight','normal','ForegroundColor',[0,0,0],'HorizontalAlignment','center','ListboxTop',[],'Max',[1],'Min',[0],'Position',[0.0540541,0.3633803,0.1389961,0.0253521],'Relief','raised','SliderStep',[0.01,0.1],'String','$\large \mbox{Animation Start}$','Style','pushbutton','Value',[0],'VerticalAlignment','middle','Visible','on','Tag','AnimateButton','Callback','AnimateButton_callback(handles)')
handles.AnimateStopBut=uicontrol(f,'unit','normalized','BackgroundColor',[0.6,0.6,0.6],'Enable','on','FontAngle','normal','FontName','helvetica','FontSize',[12],'FontUnits','points','FontWeight','normal','ForegroundColor',[0,0,0],'HorizontalAlignment','center','ListboxTop',[],'Max',[1],'Min',[0],'Position',[0.0540541,0.3211268,0.1389961,0.0253521],'Relief','raised','SliderStep',[0.01,0.1],'String','$\large \mbox{Animation Stop}$','Style','pushbutton','Value',[0],'VerticalAlignment','middle','Visible','on','Tag','AnimateStopBut','Callback','AnimateStopBut_callback(handles)')
handles.ScaleLabel=uicontrol(f,'unit','normalized','BackgroundColor',[0.8,0.8,0.8],'Enable','on','FontAngle','normal','FontName','helvetica','FontSize',[12],'FontUnits','points','FontWeight','normal','ForegroundColor',[0,0,0],'HorizontalAlignment','center','ListboxTop',[],'Max',[1],'Min',[0],'Position',[0.0025740,0.2802817,0.0939511,0.0197183],'Relief','flat','SliderStep',[0.01,0.1],'String','$\large\mbox{Echelle Patch}$','Style','text','Value',[0],'VerticalAlignment','middle','Visible','on','Tag','ScaleLabel','Callback','')
handles.ScaleSlider=uicontrol(f,'unit','normalized','BackgroundColor',[0.8,0.8,0.8],'Enable','on','FontAngle','normal','FontName','helvetica','FontSize',[12],'FontUnits','points','FontWeight','normal','ForegroundColor',[0,0,0],'HorizontalAlignment','center','ListboxTop',[],'Max',[100],'Min',[0],'Position',[0.1081081,0.2873239,0.0772201,0.0169014],'Relief','flat','SliderStep',[0.01,0.1],'String','ScaleSlider','Style','slider','Value',[0],'VerticalAlignment','middle','Visible','on','Tag','ScaleSlider','Callback','ScaleSlider_callback(handles)')
handles.ScaleEdit=uicontrol(f,'unit','normalized','BackgroundColor',[0.8,0.8,0.8],'Enable','on','FontAngle','normal','FontName','helvetica','FontSize',[12],'FontUnits','points','FontWeight','normal','ForegroundColor',[0,0,0],'HorizontalAlignment','center','ListboxTop',[],'Max',[1],'Min',[0],'Position',[0.1956242,0.2788732,0.0244530,0.0253521],'Relief','sunken','SliderStep',[0.01,0.1],'String','50','Style','edit','Value',[0],'VerticalAlignment','middle','Visible','on','Tag','ScaleEdit','Callback','')

//////////
// Callbacks are defined as below. Please do not delete the comments as it will be used in coming version
//////////

function TridObjLoadBut_callback(handles)
    global xvf yvf zvf vertices1 facelist1 scale_factor vertex_init_scale;
//Write your callback for  TridObjLoadBut  here
[filename,pathname,filterindex] = uigetfile(["*.sce"],"~/Documents/articles_lpmag/article_scilab/scilab_demo_files/","Choisissez un fichier",%f);
exec(pathname+'/'+filename);
//disp(filename);
label_handle = findobj("Tag","TridObjFile");
//set(label_handle, "String", gettext(filename));
set(label_handle, "String", filename);

//the face numbering starts à 1 (not 0 given by lib3ds)
facelist1 = facelist1 + 1;
// The face list indicates which points are composing the patch.        
//some scaling to adjust the size of the patch to the model
//scale_factor = 1.0;
//vertices1 = vertices1 * scale_factor;
//rotation around X axes
  A = cos(%pi/2);
  B = sin(%pi/2);
  C = cos(0);
  D = sin(0);
  E = cos(0);
  F = sin(0);
  //Definition of the rotationmatrix
  M = [ C*E -C*F -D;
        -B*D*E+A*F -B*D*F+A*E -B*C;
        A*D*E+B*F -A*D*F+B*E A*C];
  //new verteces locations
  //vertex_new=vertices1*M; //
  vertices1=vertices1*M; //

vertex_init_scale = vertices1;
         
// The formula used to translate the vertex / face representation into x, y, z lists
xvf = matrix(vertices1(facelist1,1),size(facelist1,1),length(vertices1(facelist1,1))/size(facelist1,1))';
yvf = matrix(vertices1(facelist1,2),size(facelist1,1),length(vertices1(facelist1,1))/size(facelist1,1))';
zvf = matrix(vertices1(facelist1,3),size(facelist1,1),length(vertices1(facelist1,1))/size(facelist1,1))';

if (~isempty(handles.TridObjPreview.children(1))) then
    delete(handles.TridObjPreview.children(1));
//    delete(handles.TridObjPreview.data_bounds);
end
//set('current_entity',h) or set('hdl',h) sets a new entity as current
set('current_axes',handles.TridObjPreview) 
plot3d(xvf,yvf,zvf,flag=[1,4,4]);
set(handles.TridObjPreview,"grid",[1 1]);

endfunction


function ColorList_callback(handles)
//Write your callback for  ColorList  here
drawlater(); 
pop = findobj("Tag", "ColorList");
items = get(pop, "String");
selected = get(pop, "Value");
disp(selected)
//disp(items)
//disp(pop)
//msg = msprintf(gettext("You selected ''%s''."), items(selected));
//messagebox(msg, gettext("Popupmenu selection"), "info", "modal");
set('current_axes',handles.TridObjPreview) 
if (~isempty(handles.TridObjPreview.children(1))) then
    handles.TridObjPreview.children(1).color_mode = selected;
    handles.TridObjPreview.children(1).hiddencolor = selected;
    draw(handles.TridObjPreview);
end
drawnow();
endfunction


function CreateTraj_callback(handles)
//Write your callback for  CreateTrajectory  here
global x y z t IterMax;
drawlater(); 
obj = findobj("Tag", "EditT");
execstr(strcat(['t=',get(obj, "String")]));
obj = findobj("Tag", "EditX");
execstr(strcat(['x=',get(obj, "String")]));
obj = findobj("Tag", "EditY");
execstr(strcat(['y=',get(obj, "String")]));
obj = findobj("Tag", "EditZ");
execstr(strcat(['z=',get(obj, "String")]));
if (~isempty(handles.TridObjGraph.children(1))) then
    delete(handles.TridObjGraph.children(1));
end

IterMax = size(t,2)-1;
//set('current_entity',h) or set('hdl',h) sets a new entity as current
set('current_axes',handles.TridObjGraph) 
// set 3D boundaries with 10% larger
handles.TridObjGraph.data_bounds=[min(x) min(y) min(z); max(x)  max(y)  max(z)]*1.1;
param3d(x,y,z,flag=[0,4]);
set(handles.TridObjGraph,"grid",[1 1]);
drawnow();

endfunction

function UpdatePreviewAngles(handles)
 
    theta = get(findobj("Tag", "ThetaPreview"), "Value");
    alpha = get(findobj("Tag", "AlphaPreview"), "Value");    
    set('current_axes',handles.TridObjPreview) 
    if (~isempty(handles.TridObjPreview.children(1))) then
        handles.TridObjPreview.rotation_angles = [theta ; alpha];
        draw(handles.TridObjPreview);
    end
endfunction

function ThetaPreview_callback(handles)
//Write your callback for  ThetaPreview  here

sl = findobj("Tag", "ThetaPreview");
txt = findobj("Tag", "ThetaPreviewEdit");
set(txt, "String", string(get(sl, "Value")));
UpdatePreviewAngles(handles);
endfunction

function AlphaPreview_callback(handles)
//Write your callback for  AlphaPreview  here
sl = findobj("Tag", "AlphaPreview");
txt = findobj("Tag", "AlphaPreviewEdit");
set(txt, "String", string(get(sl, "Value")));
UpdatePreviewAngles(handles);
endfunction

function UpdateGraphAngles(handles)
    theta = get(findobj("Tag", "ThetaGraph"), "Value");
    alpha = get(findobj("Tag", "AlphaGraph"), "Value");    
    set('current_axes',handles.TridObjGraph) 
    if (~isempty(handles.TridObjGraph.children(1))) then
        handles.TridObjGraph.rotation_angles = [theta ; alpha];
    end
endfunction

function ThetaGraph_callback(handles)
//Write your callback for  ThetaPreview  here

sl = findobj("Tag", "ThetaGraph");
txt = findobj("Tag", "ThetaGraphEdit");
set(txt, "String", string(get(sl, "Value")));
UpdateGraphAngles(handles);
endfunction

function AlphaGraph_callback(handles)
//Write your callback for  AlphaPreview  here
sl = findobj("Tag", "AlphaGraph");
txt = findobj("Tag", "AlphaGraphEdit");
set(txt, "String", string(get(sl, "Value")));
UpdateGraphAngles(handles);
endfunction

function ColorTrajList_callback(handles)
pop = findobj("Tag", "ColorTrajList");
items = get(pop, "String");
selected = get(pop, "Value");
//disp(selected)
//disp(items)
//disp(pop)
//msg = msprintf(gettext("You selected ''%s''."), items(selected));
//messagebox(msg, gettext("Popupmenu selection"), "info", "modal");
set('current_axes',handles.TridObjGraph) 
if (~isempty(handles.TridObjGraph.children(1))) then
    handles.TridObjGraph.children(1).foreground = selected;
end
endfunction

function StyleTrajList_callback(handles)
pop = findobj("Tag", "StyleTrajList");
items = get(pop, "String");
selected = get(pop, "Value");
//disp(selected)
//disp(items)
//disp(pop)
//msg = msprintf(gettext("You selected ''%s''."), items(selected));
//messagebox(msg, gettext("Popupmenu selection"), "info", "modal");
set('current_axes',handles.TridObjGraph) 
if (~isempty(handles.TridObjGraph.children(1))) then
    handles.TridObjGraph.children(1).line_style = selected;
end
endfunction

function ThickTrajList_callback(handles)
pop = findobj("Tag", "ThickTrajList");
items = get(pop, "String");
selected = get(pop, "Value");
//disp(selected)
//disp(items)
//disp(pop)
//msg = msprintf(gettext("You selected ''%s''."), items(selected));
//messagebox(msg, gettext("Popupmenu selection"), "info", "modal");
set('current_axes',handles.TridObjGraph) 
if (~isempty(handles.TridObjGraph.children(1))) then
    handles.TridObjGraph.children(1).thickness = selected;
end
endfunction
function AnimateButton_callback(handles)
//to access to global variables shared by other functions
    global x y z t IterMax Iteration RunAnimation;
    global xvf yvf zvf vertices1 vertex_init_scale facelist1;
//Write your callback for  AnimateButton  here
//orienting the patch on the curve (tangent)
RunAnimation = %t;
Iteration = 1;
dx = diff(x);
dy = diff(y);
dz = diff(z);
//disp(x);
// from http://fr.wikipedia.org/wiki/Coordonn%C3%A9es_sph%C3%A9riques
// and from http://jeux.developpez.com/faq/math/?page=transformations#Q31
// the next line computes theta_v according to y > 0 or < 0 
//((bool2s(dy > 0)*2) -1) .*  acos(dx./(sqrt(dx.^2+dy.^2))) + bool2s(dy < 0)*2*%pi;
rho_v = sqrt(dx.^2+dy.^2+dz.^2); //distance computing
phi_v = acos(dz./rho_v);         //X Axis Rotation : Pitch is acting about an axis perpendicular to the longitudinal plane of symmetry
theta_v = ((bool2s(dy > 0)*2) -1).*acos(dx./(sqrt(dx.^2+dy.^2))) + bool2s(dy < 0)*2*%pi;
theta_v = - theta_v+ %pi/2; //A rotation axis yaw : The yaw is about the vertical body axis,
psi_v = [0];
psi_v = [ psi_v diff(theta_v)] *2; // roll is acting about the longitudinal axis

drawlater(); // delay the plotting until drawnow() is called
//plot the 3D trajectory
if (~isempty(handles.TridObjGraph.children(1))) then
    delete(handles.TridObjGraph.children(1));
end
set('current_axes',handles.TridObjGraph) 
//param3d(x,y,z,flag=[0,4]);
param3d(x,y,z);
//plot the patch in "initial" position
//plot3d(xvf,yvf,zvf,alpha_view,theta_view,flag=[1,0,4]);
plot3d(xvf,yvf,zvf);
set(handles.TridObjGraph,"grid",[1 1 1]); //put the grid on the figure
// set 3D boundaries
//curAxe.data_bounds=[-11 -6 -6; 11  32  22];
//title("Animation et rotation d''un patch 3d.","fontsize",3);
s=gce(); //the handle on the surface
//curFig.background = -1;                 // black
//curAxe.background    = -1;                 // gray
//curAxe.foreground    = 14;                 // white
//getting the handle on the 3D curve
line=handles.TridObjGraph.children(2); //second plot = curve
//trajectory style
pop = findobj("Tag", "ColorTrajList");
items = get(pop, "String");
selected = get(pop, "Value");
line.foreground = selected;

pop = findobj("Tag", "StyleTrajList");
items = get(pop, "String");
selected = get(pop, "Value");
line.line_style=selected;

pop = findobj("Tag", "ThickTrajList");
items = get(pop, "String");
selected = get(pop, "Value");
line.thickness= selected;

//patch color
pop = findobj("Tag", "ColorList");
items = get(pop, "String");
selected = get(pop, "Value");


//line.line_style=3; //define the line style
//line.thickness=2; //define the thickness of the line
//line.foreground=16; //define the color of the line
//line.polyline_style=3;
//getting the handle on the 3D patch
patch=handles.TridObjGraph.children(1); //first plot = patch
//line.line_style=3; //define the line style
patch.thickness=0.5; //define the thickness of the lines
patch.foreground=1; ////define the color of the lines

patch.color_mode=selected; //define the color of the patch
patch.hiddencolor=selected; //define the color of the patch

//patch.color_mode=1; //define the color of the patch
//patch.hiddencolor=7; //define the color of the patch
winnum=winsid();//getting the window number
//drawnow();
frame_duration = 0.05
realtimeinit(frame_duration); //fix (if possible, regarding to calculus) the duration of one frame 
realtime(0);
//for  Iteration = 1:Itermax //due to the the "diff" computing
while(RunAnimation)
  drawlater();
  //setting the angles 
  theta = theta_v(Iteration); //Yaw
  phi = phi_v(Iteration)-%pi/2;  //Pitch
  psi = psi_v(Iteration); //Roll
  //Definition of rotation matrix terms
  A = cos(phi);
  B = sin(phi);
  C = cos(psi);
  D = sin(psi);
  E = cos(theta);
  F = sin(theta);
  //Definition of the rotationmatrix
  M = [ C*E -C*F -D;
        -B*D*E+A*F -B*D*F+A*E -B*C;
        A*D*E+B*F -A*D*F+B*E A*C];
  //new verteces locations
  //vertex_new=vertices1*M; //
  vertex_new=vertex_init_scale*M; //
  
  //modification of the patch on the figure
  s.data.x = matrix(vertex_new(facelist1,1),size(facelist1,1),length(vertex_new(facelist1,1))/size(facelist1,1))' + x(Iteration);
  s.data.y = matrix(vertex_new(facelist1,2),size(facelist1,1),length(vertex_new(facelist1,1))/size(facelist1,1))' + y(Iteration);
  s.data.z = matrix(vertex_new(facelist1,3),size(facelist1,1),length(vertex_new(facelist1,1))/size(facelist1,1))' + z(Iteration);
  realtime(Iteration); //wait till date frame_duration*i seconds
  drawnow(); //plotting all the stuff on the figure
  Iteration = Iteration +1;
  if (Iteration >= IterMax) then
      RunAnimation = %f;
  end
end
endfunction
function AnimateStopBut_callback(handles)
    global RunAnimation Iteration;
//Write your callback for  AnimateButton  here
RunAnimation = %f;
Iteration = 1;
endfunction


function ScaleSlider_callback(handles)
global scale_factor xvf yvf zvf vertices1 vertex_init_scale facelist1 Iteration x y z t;
//Write your callback for  ScaleSlider  here
sl = findobj("Tag", "ScaleSlider");
txt = findobj("Tag", "ScaleEdit");
scale = get(sl, "Value");
set(txt, "String", string(scale));
scale_factor = scale/100;
IndPatch = find(handles.TridObjGraph.children.type=='Fac3d');
IndLine = find(handles.TridObjGraph.children.type=='Polyline');
drawlater();
if (~isempty(IndPatch)) then

    //new verteces locations
    vertex_init_scale=vertices1*scale_factor;
  
    handles.TridObjGraph.children(IndPatch).data.x = matrix(vertex_init_scale(facelist1,1),size(facelist1,1),length(vertex_init_scale(facelist1,1))/size(facelist1,1))' + x(Iteration);
    handles.TridObjGraph.children(IndPatch).data.y = matrix(vertex_init_scale(facelist1,2),size(facelist1,1),length(vertex_init_scale(facelist1,1))/size(facelist1,1))' + y(Iteration);
    handles.TridObjGraph.children(IndPatch).data.z = matrix(vertex_init_scale(facelist1,3),size(facelist1,1),length(vertex_init_scale(facelist1,1))/size(facelist1,1))' + z(Iteration);

else
    vertex_new = vertices1 * scale_factor;
    // The formula used to translate the vertex / face representation into x, y, z lists
    handles.TridObjPreview.children(1).data.x = matrix(vertex_new(facelist1,1),size(facelist1,1),length(vertex_new(facelist1,1))/size(facelist1,1))';
    handles.TridObjPreview.children(1).data.y = matrix(vertex_new(facelist1,2),size(facelist1,1),length(vertex_new(facelist1,1))/size(facelist1,1))';
    handles.TridObjPreview.children(1).data.z = matrix(vertex_new(facelist1,3),size(facelist1,1),length(vertex_new(facelist1,1))/size(facelist1,1))';

end
drawnow();
endfunction

function InitVariables()
global Iteration RunAnimation
Iteration = 1;
RunAnimation = %f;    
endfunction

InitVariables();
function InitVariables(handles)
//Write your callback for  ParentFrame  here

endfunction

function exit_scilab(handles)
msg = gettext("Do you really want to quit Scilab?");
answ = messagebox(msg, gettext("Quit Scilab"), "quextion", [gettext("Yes") gettext("No")], "modal");
if answ==1 then
  //exit;
  close(f);
end
endfunction