sigxtool.m
上传用户:haiyisale
上传日期:2013-01-09
资源大小:3246k
文件大小:57k
源码类别:

波变换

开发平台:

Matlab

  1. function varargout = sigxtool(option,varargin)
  2. %SIGXTOOL Signal extension tool.
  3. %   VARARGOUT = SIGXTOOL(OPTION,VARARGIN)
  4. %
  5. %   GUI oriented tool which allows the construction of a new
  6. %   signal from an original one by truncation or extension.
  7. %   Extension is done by selecting different possible modes:
  8. %   Symmetric, Periodic, Zero Padding, Continuous or Smooth.
  9. %   A special mode is provided to extend a signal in order 
  10. %   to be accepted by the SWT decomposition.
  11. %------------------------------------------------------------
  12. %   Internal options:
  13. %
  14. %   OPTION = 'create'          'load'           'demo'
  15. %            'update_deslen'   'extend_truncate'
  16. %            'draw'            'save'
  17. %            'clear_graphics'  'mode'
  18. %            'close'
  19. %
  20. %   See also WEXTEND.
  21. %   M. Misiti, Y. Misiti, G. Oppenheim, J.M. Poggi 23-Oct-98.
  22. %   Last Revision: 14-Jul-2003.
  23. %   Copyright 1995-2004 The MathWorks, Inc.
  24. %   $Revision: 1.11.4.2 $  $Date: 2004/03/15 22:41:44 $
  25. % Test inputs.
  26. %-------------
  27. if nargin==0 , option = 'create'; end
  28. [option,winAttrb] = utguidiv('ini',option,varargin{:});
  29. % Initialisations for all options excepted 'create'.
  30. %---------------------------------------------------
  31. switch option
  32.   case 'create'
  33.   
  34.   otherwise
  35.     % Get figure handle.
  36.     %-------------------
  37.     win_sigxtool = varargin{1};
  38.     % Get stored structure.
  39.     %----------------------
  40.     Hdls_UIC1 = wfigmngr('getValue',win_sigxtool,'Hdls_UIC1');
  41.     Hdls_UIC2 = wfigmngr('getValue',win_sigxtool,'Hdls_UIC2');
  42.     Hdls_UIC3 = wfigmngr('getValue',win_sigxtool,'Hdls_UIC3');
  43.     Hdls_Axes = wfigmngr('getValue',win_sigxtool,'Hdls_Axes');
  44.     % Get UIC Handles.
  45.     %-----------------
  46.     [m_load,m_save,m_demo,txt_signal,edi_signal,...
  47.      txt_mode,pop_mode,pus_extend] = deal(Hdls_UIC1{:});
  48.  
  49.     [frm_fra1,txt_length,edi_length,txt_nextpow2,edi_nextpow2,   ...
  50.      txt_prevpow2,edi_prevpow2,txt_deslen,edi_deslen,txt_direct, ...
  51.      pop_direct] = deal(Hdls_UIC2{:});
  52.     [frm_fra2,txt_swtdec,pop_swtdec,txt_swtlen,edi_swtlen, ...
  53.      txt_swtclen,edi_swtclen,txt_swtdir,                   ...
  54.      edi_swtdir] = deal(Hdls_UIC3{:});
  55. end
  56. % Process control depending on the calling option.
  57. %-------------------------------------------------
  58. switch option
  59.     case 'create'
  60.     %-------------------------------------------------------%
  61.     % Option: 'CREATE' - Create Figure, Uicontrols and Axes %
  62.     %-------------------------------------------------------%
  63.         % Get Globals.
  64.         %-------------
  65.         [...
  66.         Def_Btn_Height,Def_Btn_Width,Pop_Min_Width,  ...
  67.         X_Graph_Ratio,X_Spacing,Y_Spacing,           ...
  68.         Def_TxtBkColor,Def_EdiBkColor,Def_FraBkColor ...
  69.         ] = ...
  70.             mextglob('get',...
  71.                 'Def_Btn_Height','Def_Btn_Width','Pop_Min_Width',  ...
  72.                 'X_Graph_Ratio','X_Spacing','Y_Spacing',           ...
  73.                 'Def_TxtBkColor','Def_EdiBkColor','Def_FraBkColor' ...
  74.                 );
  75.         % Window initialization.
  76.         %-----------------------
  77.         [win_sigxtool,pos_win,win_units,str_numwin,                         ...
  78.                 frame0,pos_frame0,Pos_Graphic_Area,pus_close] =             ...
  79.                     wfigmngr('create','Signal Extension / Truncation',      ...
  80.                                         winAttrb,'ExtFig_Tool_3',           ...
  81.                                         strvcat(mfilename,'cond'),1,1,0);
  82.         if nargout>0 , varargout{1} = win_sigxtool; end
  83. % Add Help for Tool.
  84. %------------------
  85. wfighelp('addHelpTool',win_sigxtool, ...
  86. 'One-Dimensional &Extension','SIGX_GUI');
  87. % Add Help Item.
  88. %----------------
  89. wfighelp('addHelpItem',win_sigxtool,...
  90. 'Dealing with Border Distortion','BORDER_DIST');
  91.         % Menu construction for current figure.
  92.         %--------------------------------------
  93.         m_files = wfigmngr('getmenus',win_sigxtool,'file');
  94.         m_load  = uimenu(m_files, ...
  95.                          'Label','&Load Signal ',                 ...
  96.                          'Position',1,                            ...
  97.                          'Callback',                              ...
  98.                          [mfilename '(''load'',' str_numwin ');'] ...
  99.                          );
  100.         m_save  = uimenu(m_files,...
  101.                          'Label','&Save Transformed Signal ',     ...
  102.                          'Position',2,                            ...
  103.                          'Enable','Off',                          ...
  104.                          'Callback',                              ...
  105.                          [mfilename '(''save'',' str_numwin ');'] ...
  106.                          );
  107.         m_demo  = uimenu(m_files, ...
  108.                          'Label','&Example Extension','Position',3);
  109.         demoSET = {...
  110.          'noisbloc' , 'ext'   , '{''zpd'' , 1236 , ''both''}'  ; ...
  111.          'noisbloc' , 'trunc' , '{''nul'',   865 , ''both'' }' ; ...
  112.          'cuspamax' , 'ext'   , '{''spd'' , 1400 , ''right''}' ; ...
  113.          'cuspamax' , 'ext'   , '{''spd'' , 1400 , ''left''}'  ; ...
  114.          'cuspamax' , 'ext'   , '{''spd'' , 1400 , ''both''}'  ; ...
  115.          'noisbump' , 'ext'   , '{''sym'' , 1600 , ''both''}'  ; ...
  116.          'freqbrk'  , 'trunc' , '{''nul'',   666 , ''left'' }' ; ...
  117.          'freqbrk'  , 'ext'   , '{''swt'' ,   10 , ''right''}'   ...
  118.          };
  119.        nbDEM = size(demoSET,1);
  120.        beg_call_str = [mfilename '(''demo'',' str_numwin ','''];
  121.    dummy = demoSET(:,1);
  122.    names = strvcat(dummy{:});
  123.    tab   = setstr(9);
  124.        for k = 1:nbDEM
  125.            typ = demoSET{k,2};
  126.            fil = demoSET{k,1};
  127.            par = demoSET{k,3};
  128.            parVal = eval(par);
  129.            switch parVal{1}
  130.              case 'swt' , lenSTR = ' - level: ';
  131.              otherwise  , lenSTR = ' - length: ';
  132.            end
  133.            strPAR = ['mode: ' ,  parVal{1} , lenSTR, int2str(parVal{2})  ...
  134.                      ' - direction: ', parVal{3}];  
  135.            switch  typ
  136.              case 'ext'   , strTYPE = ['Extension  - '];
  137.              case 'trunc' , strTYPE = ['Truncation - ']; 
  138.            end
  139.            libel = [names(k,:) tab '  -  ' strTYPE strPAR];
  140.            action = [beg_call_str fil  ''',''' typ ''',' par ');'];
  141.            uimenu(m_demo,'Label',libel,'Callback',action);
  142.        end
  143.         % Begin waiting.
  144.         %---------------
  145.         wwaiting('msg',win_sigxtool,'Wait ... initialization');
  146.         % Borders and double borders.
  147.         %----------------------------
  148.         dx = X_Spacing;  dx2 = 2*dx;
  149.         dy = Y_Spacing;  dy2 = 2*dy;
  150.         % General graphical parameters initialization.
  151.         %--------------------------------------------
  152.         x_frame0  = pos_frame0(1);
  153.         cmd_width = pos_frame0(3);
  154.         pus_width = cmd_width-4*dx2;
  155.         txt_width = 3*Def_Btn_Width/2;
  156.         edi_width = 3*Def_Btn_Width/4;
  157.         pop_width = 7*Def_Btn_Width/4;
  158.         bdx       = 0.08*pos_win(3);
  159.         bdy       = 0.06*pos_win(4);
  160.         ecy       = 0.03*pos_win(4);
  161.         x_graph   = bdx;
  162.         y_graph   = 2*Def_Btn_Height+dy;
  163.         h_graph   = pos_frame0(4)-y_graph;
  164.         w_graph   = pos_frame0(1);
  165.         % Command part of the window.
  166.         %============================
  167.         % Position property of objects.
  168.         %------------------------------
  169.         xlocINI          = [x_frame0 cmd_width];
  170.         ybottomINI       = pos_win(4)-dy2;
  171.         x_left_INI       = x_frame0+dx2+dx;
  172.         x_left           = x_left_INI;
  173.         y_low            = ybottomINI-Def_Btn_Height-2*dy2;
  174.         pos_txt_signal   = [x_left, y_low, txt_width Def_Btn_Height];
  175.         x_left           = x_left+txt_width/2+3*dx;
  176.         pos_edi_signal   = [x_left, y_low+dy, 2*edi_width , Def_Btn_Height];
  177.         x_left           = x_left_INI;
  178.         y_low            = y_low-1.5*(Def_Btn_Height+2*dy2);
  179.         pos_txt_length   = [x_left, y_low, txt_width Def_Btn_Height];
  180.         x_left           = x_left+txt_width/2+edi_width+3*dx;
  181.         pos_edi_length   = [x_left, y_low+dy, edi_width , Def_Btn_Height];
  182.         x_left           = x_left_INI;
  183.         y_low            = y_low-(Def_Btn_Height+2*dy2);
  184.         pos_txt_nextpow2 = [x_left, y_low, txt_width Def_Btn_Height];
  185.         x_left           = x_left+txt_width/2+edi_width+3*dx;
  186.         pos_edi_nextpow2 = [x_left, y_low+dy, edi_width , Def_Btn_Height];
  187.         x_left           = x_left_INI;
  188.         y_low            = y_low-(Def_Btn_Height+2*dy2);
  189.         pos_txt_prevpow2 = [x_left, y_low, txt_width Def_Btn_Height];
  190.         x_left           = x_left+txt_width/2+edi_width+3*dx;
  191.         pos_edi_prevpow2 = [x_left, y_low+dy, edi_width , Def_Btn_Height];
  192.         x_left           = x_left_INI;
  193.         y_low            = y_low-(Def_Btn_Height+2*dy2);
  194.         pos_txt_deslen   = [x_left, y_low, txt_width Def_Btn_Height];
  195.         x_left           = x_left+txt_width/2+edi_width+3*dx;
  196.         pos_edi_deslen   = [x_left, y_low+dy, edi_width , Def_Btn_Height];
  197.         x_left           = x_left_INI;
  198.         y_low            = y_low-(Def_Btn_Height+2*dy2);
  199.         pos_txt_direct   = [x_left, y_low, txt_width, Def_Btn_Height];
  200.         x_left           = x_left+txt_width/2+edi_width+3*dx;
  201.         pos_pop_direct   = [x_left, y_low+dy, edi_width , Def_Btn_Height];
  202.         
  203.         x_left           = x_left_INI-dx2;
  204.         y_low            = y_low-dy;
  205.         pos_fra1         = [x_left, y_low, cmd_width-dx2, ...
  206.                             5*(Def_Btn_Height+2*dy2)+dy];
  207.         x_left           = x_left_INI;
  208.         y_low            = y_low-(2*Def_Btn_Height+2*dy2);
  209.         pos_txt_mode     = [x_left, y_low, txt_width, Def_Btn_Height];
  210.         x_left           = x_left_INI+dx2;
  211.         pos_pop_mode     = [x_left, y_low-Def_Btn_Height, pus_width, Def_Btn_Height];
  212.         x_left           = x_left_INI+dx2;
  213.         y_low            = y_low-2*(Def_Btn_Height+2*dy2);
  214.         pos_pus_extend   = [x_left, y_low, pus_width, 1.5*Def_Btn_Height];
  215.         
  216.         pos_fra2         = pos_fra1;
  217.         pos_fra2(4)      = 3*(Def_Btn_Height+2*dy2)+dy;
  218.         
  219.         x_left           = x_left_INI-dx2;
  220.         y_low            = pos_fra2(2)+pos_fra2(4)+3*dy2;
  221.         pos_txt_swtdec   = [x_left, y_low, 3*txt_width/2, Def_Btn_Height];
  222.         x_left           = x_left+txt_width/2+edi_width+3*dx+dx2;
  223.         pos_pop_swtdec   = [x_left, y_low+dy, edi_width, Def_Btn_Height];
  224.         
  225.         x_left           = x_left_INI;
  226.         y_low            = pos_fra2(2)+pos_fra2(4)-(Def_Btn_Height+2*dy2);
  227.         pos_txt_swtlen   = [x_left, y_low, txt_width, Def_Btn_Height];
  228.         x_left           = x_left+txt_width/2+edi_width+3*dx;
  229.         pos_edi_swtlen   = [x_left, y_low+dy, edi_width, Def_Btn_Height];
  230.         
  231.         x_left           = x_left_INI;
  232.         y_low            = y_low-(Def_Btn_Height+2*dy2);
  233.         pos_txt_swtclen  = [x_left, y_low, txt_width, Def_Btn_Height];
  234.         x_left           = x_left+txt_width/2+edi_width+3*dx;
  235.         pos_edi_swtclen  = [x_left, y_low+dy, edi_width, Def_Btn_Height];
  236.                   
  237.         x_left           = x_left_INI;
  238.         y_low            = y_low-(Def_Btn_Height+2*dy2);
  239.         pos_txt_swtdir   = [x_left, y_low, txt_width, Def_Btn_Height];
  240.         x_left           = x_left+txt_width/2+edi_width+3*dx;
  241.         pos_edi_swtdir   = [x_left, y_low+dy, edi_width, Def_Btn_Height];
  242.         
  243.         % String property of objects.
  244.         %----------------------------
  245.         str_txt_signal   = 'Signal';
  246.         str_edi_signal   = '';
  247.         str_txt_length   = 'Length';
  248.         str_edi_length   = '';
  249.         str_txt_nextpow2 = 'Next Power of 2';
  250.         str_edi_nextpow2 = '';
  251.         str_txt_prevpow2 = 'Previous Power of 2';
  252.         str_edi_prevpow2 = '';
  253.         str_txt_deslen   = 'Desired Length';
  254.         str_edi_deslen   = '';
  255.         str_txt_direct   = 'Direction to extend';
  256.         str_pop_direct   = ['Both ' ; 'Left ' ; 'Right'];
  257.         str_txt_mode     = 'Extension Mode';
  258.         str_pop_mode     = strvcat(...
  259.                             'Symmetric (Half-Point)', ...
  260.                             'Symmetric (Whole-Point)', ...
  261.                             'Antisymmetric (Half-Point)', ...
  262.                             'Antisymmetric (Whole-Point)', ...                            
  263.                             'Periodic', ... 
  264.                             'Zero Padding', ... 
  265.                             'Continuous', ... 
  266.                             'Smooth', ... 
  267.                             'For SWT'  ... 
  268.                             );
  269.         str_pus_extend   = 'Extend';
  270.         str_txt_swtdec   = 'SWT Decomposition Level';
  271.         str_pop_swtdec   = num2str((1:10)');
  272.         str_txt_swtlen   = 'Length';
  273.         str_edi_swtlen   = '';
  274.         str_txt_swtclen  = 'Computed Length';
  275.         str_edi_swtclen  = '';
  276.         str_txt_swtdir   = 'Direction to extend';
  277.         str_edi_swtdir   = 'Right';
  278.         str_tip_swtclen  = strvcat(['Minimal length of the ',    ...
  279.                                     'periodic extended signal ', ...
  280.                                     'for SWT decomposition']);
  281.         % Construction of uicontrols.
  282.         %----------------------------
  283.         commonProp = {'Parent',win_sigxtool,'Unit',win_units,'Visible','off'};
  284.         comFraProp = {commonProp{:},                              ...
  285.                                 'BackGroundColor',Def_FraBkColor, ...
  286.                                 'Style','frame'                   ...
  287.                                 };
  288.         comPusProp = {commonProp{:},'Style','Pushbutton'};
  289.         comPopProp = {commonProp{:},'Style','Popupmenu'};
  290.         comTxtProp = {commonProp{:},                              ...
  291.                                 'ForeGroundColor','k',            ...
  292.                                 'BackGroundColor',Def_FraBkColor, ...
  293.                                 'HorizontalAlignment','left',     ...
  294.                                 'Style','Text'                    ...
  295.                                 };
  296.         comEdiProp = {commonProp{:},                              ...
  297.                                 'ForeGroundColor','k',            ...
  298.                                 'HorizontalAlignment','center',   ...
  299.                                 'Style','Edit'                    ...
  300.                                 };
  301.  
  302.         txt_signal      = uicontrol(                              ...
  303.                                 comTxtProp{:},                    ...
  304.                                 'Position',pos_txt_signal,        ...
  305.                                 'String',str_txt_signal           ...
  306.                                  );
  307.         edi_signal      = uicontrol(                              ...
  308.                                 comEdiProp{:},                    ...
  309.                                 'Position',pos_edi_signal,        ...
  310.                                 'String',str_edi_signal,          ...
  311.                                 'BackGroundColor',Def_FraBkColor, ...
  312.                                 'Enable','Inactive'               ...
  313.                                 );
  314.         frm_fra1        = uicontrol(                              ...
  315.                                 comFraProp{:},                    ...
  316.                                 'Position',pos_fra1               ...
  317.                                 );
  318.         txt_length      = uicontrol(                              ...
  319.                                 comTxtProp{:},                    ...
  320.                                 'Position',pos_txt_length,        ...
  321.                                 'String',str_txt_length           ...
  322.                                  );
  323.         edi_length      = uicontrol(                              ...
  324.                                 comEdiProp{:},                    ...
  325.                                 'Position',pos_edi_length,        ...
  326.                                 'String',str_edi_length,          ...
  327.                                 'Backgroundcolor',Def_FraBkColor, ...
  328.                                 'Enable','Inactive'               ...
  329.                                  );
  330.         txt_nextpow2    = uicontrol(                              ...
  331.                                 comTxtProp{:},                    ...
  332.                                 'Position',pos_txt_nextpow2,      ...
  333.                                 'String',str_txt_nextpow2         ...
  334.                                  );
  335.         edi_nextpow2    = uicontrol(                              ...
  336.                                 comEdiProp{:},                    ...
  337.                                 'Position',pos_edi_nextpow2,      ...
  338.                                 'String',str_edi_nextpow2,        ...
  339.                                 'Backgroundcolor',Def_FraBkColor, ...
  340.                                 'Enable','Inactive'               ...
  341.                                  );
  342.         txt_prevpow2    = uicontrol(                              ...
  343.                                 comTxtProp{:},                    ...
  344.                                 'Position',pos_txt_prevpow2,      ...
  345.                                 'String',str_txt_prevpow2         ...
  346.                                  );
  347.         edi_prevpow2    = uicontrol(                              ...
  348.                                 comEdiProp{:},                    ...
  349.                                 'Position',pos_edi_prevpow2,      ...
  350.                                 'String',str_edi_prevpow2,        ...
  351.                                 'Backgroundcolor',Def_FraBkColor, ...
  352.                                 'Enable','Inactive'               ...
  353.                                  );
  354.         txt_deslen      = uicontrol(                              ...
  355.                                 comTxtProp{:},                    ...
  356.                                 'Position',pos_txt_deslen,        ...
  357.                                 'String',str_txt_deslen           ...
  358.                                  );
  359.         edi_deslen      = uicontrol(                              ...
  360.                                 comEdiProp{:},                    ...
  361.                                 'Position',pos_edi_deslen,        ...
  362.                                 'String',str_edi_deslen,          ...
  363.                                 'Backgroundcolor',Def_EdiBkColor  ...
  364.                                  );
  365.         txt_direct       = uicontrol(                             ...
  366.                                 comTxtProp{:},                    ...
  367.                                 'Position',pos_txt_direct,        ...
  368.                                 'String',str_txt_direct           ...
  369.                                  );
  370.         pop_direct      = uicontrol(                              ...
  371.                                 comPopProp{:},                    ...
  372.                                 'Position',pos_pop_direct,        ...
  373.                                 'String',str_pop_direct           ...
  374.                                  );
  375.         txt_mode        = uicontrol(                              ...
  376.                                 comTxtProp{:},                    ...
  377.                                 'Position',pos_txt_mode,          ...
  378.                                 'String',str_txt_mode             ...
  379.                                  );
  380.         pop_mode        = uicontrol(                              ...
  381.                                 comPopProp{:},                    ...
  382.                                 'Position',pos_pop_mode,          ...
  383.                                 'String',str_pop_mode             ...
  384.                                  );
  385.         pus_extend      = uicontrol(                              ...
  386.                                 comPusProp{:},                    ...
  387.                                 'Position',pos_pus_extend,        ...
  388.                                 'String',xlate(str_pus_extend),          ...
  389.                                 'Interruptible','On'              ...
  390.                                 );
  391.         frm_fra2        = uicontrol(                              ...
  392.                                 comFraProp{:},                    ...
  393.                                 'Position',pos_fra2               ...
  394.                                 );
  395.         txt_swtdec      = uicontrol(                              ...
  396.                                 comTxtProp{:},                    ...
  397.                                 'Position',pos_txt_swtdec,        ...
  398.                                 'String',str_txt_swtdec           ...
  399.                                  );
  400.         pop_swtdec      = uicontrol(                              ...
  401.                                 comPopProp{:},                    ...
  402.                                 'Position',pos_pop_swtdec,        ...
  403.                                 'String',str_pop_swtdec           ...
  404.                                  );
  405.         txt_swtlen      = uicontrol(                              ...
  406.                                 comTxtProp{:},                    ...
  407.                                 'Position',pos_txt_swtlen,        ...
  408.                                 'String',str_txt_swtlen           ...
  409.                                  );
  410.         edi_swtlen      = uicontrol(                              ...
  411.                                 comEdiProp{:},                    ...
  412.                                 'Position',pos_edi_swtlen,        ...
  413.                                 'String',str_edi_swtlen,          ...
  414.                                 'Backgroundcolor',Def_FraBkColor, ...
  415.                                 'Enable','Inactive'               ...
  416.                                  );
  417.         txt_swtclen     = uicontrol(                              ...
  418.                                 comTxtProp{:},                    ...
  419.                                 'Position',pos_txt_swtclen,       ...
  420.                                 'ToolTipString',str_tip_swtclen,  ...
  421.                                 'String',str_txt_swtclen          ...
  422.                                  );
  423.         edi_swtclen     = uicontrol(                              ...
  424.                                 comEdiProp{:},                    ...
  425.                                 'Position',pos_edi_swtclen,       ...
  426.                                 'String',str_edi_swtclen,         ...
  427.                                 'Backgroundcolor',Def_FraBkColor, ...
  428.                                 'Enable','Inactive'               ...
  429.                                  );
  430.         txt_swtdir      = uicontrol(                              ...
  431.                                 comTxtProp{:},                    ...
  432.                                 'Position',pos_txt_swtdir,        ...
  433.                                 'String',str_txt_swtdir           ...
  434.                                  );
  435.         edi_swtdir      = uicontrol(                              ...
  436.                                 comEdiProp{:},                    ...
  437.                                 'Position',pos_edi_swtdir,        ...
  438.                                 'String',str_edi_swtdir,          ...
  439.                                 'Backgroundcolor',Def_FraBkColor, ...
  440.                                 'Enable','Inactive'               ...
  441.                                  );
  442.                               
  443.         % Callback property of objects.
  444.         %------------------------------
  445.         str_win_sext = num2mstr(win_sigxtool);
  446.         cba_edi_deslen = [mfilename '(''update_deslen'',' str_win_sext ');'];
  447.         cba_pop_swtdec = [mfilename '(''update_swtdec'',' str_win_sext ');'];
  448.         cba_pop_direct = [mfilename '(''clear_GRAPHICS'',' str_win_sext ');'];
  449.         cba_pop_mode   = [mfilename '(''mode'',' str_win_sext ');'];
  450.         cba_pus_extend = [mfilename '(''extend_truncate'',' str_win_sext ');'];
  451.         set(edi_deslen,'Callback',cba_edi_deslen);
  452.         set(pop_swtdec,'Callback',cba_pop_swtdec);
  453.         set(pop_direct,'Callback',cba_pop_direct);
  454.         set(pop_mode,'Callback',cba_pop_mode);
  455.         set(pus_extend,'Callback',cba_pus_extend);
  456.         % Graphic part of the window.
  457.         %============================
  458.         % Axes Construction.
  459.         %-------------------
  460.         commonProp  = {...
  461.            'Parent',win_sigxtool,           ...
  462.            'Visible','off',                 ...
  463.            'Units','pixels',                ...
  464.            'XTicklabelMode','manual',       ...
  465.            'YTicklabelMode','manual',       ...
  466.            'XTicklabel',[],'YTicklabel',[], ...
  467.            'XTick',[],'YTick',[],           ...
  468.            'Box','On'                       ...
  469.            };
  470.         % Signal Axes construction.
  471.         %--------------------------
  472.         x_left      = x_graph;
  473.         x_wide      = w_graph-2*x_left;
  474.         y_low       = y_graph+h_graph/10+2*bdy;
  475.         y_height    = 9*h_graph/10-y_low-bdy;
  476.         Pos_Axe_Sig = [x_left, y_low, x_wide, y_height];
  477.         Axe_Sig     = axes(commonProp{:},'Position',Pos_Axe_Sig);
  478.    
  479.         % Legend Axes construction.
  480.         %--------------------------
  481.         X_Leg       = Pos_Axe_Sig(1);
  482.         Y_Leg       = Pos_Axe_Sig(2) + 11*Pos_Axe_Sig(4)/10;
  483.         W_Leg       = (Pos_Axe_Sig(3) - Pos_Axe_Sig(1)) / 2.5;
  484.         H_Leg       = (Pos_Axe_Sig(4) - Pos_Axe_Sig(2)) / 2;
  485.         Pos_Axe_Leg = [X_Leg Y_Leg W_Leg H_Leg];
  486.         ud.dynvzaxe.enable = 'Off';
  487.         Axe_Leg     = axes(commonProp{:},          ...
  488.                            'Position',Pos_Axe_Leg, ...
  489.                            'Xlim',[0 180],         ...
  490.                            'Ylim',[0 20],          ...
  491.                            'Drawmode','fast',      ...
  492.                            'userdata',ud           ...
  493.                            );
  494.         L1 = line(                            ...
  495.                   'Parent',Axe_Leg,           ...
  496.                   'Xdata',11:30,              ...
  497.                   'Ydata',ones(1,20)*14,      ...
  498.                   'LineWidth',3,              ...
  499.                   'Visible','off',            ...
  500.                   'Color','yellow'            ...
  501.                   );
  502.         L2 = line(                            ...
  503.                   'Parent',Axe_Leg,           ...
  504.                   'Xdata',11:30,              ...
  505.                   'Ydata',ones(1,20)*7,       ...
  506.                   'LineWidth',3,              ...
  507.                   'Visible','off',            ...
  508.                   'Color','red'               ...
  509.                   );
  510.         T1 = text(40,14,xlate('Transformed signal'), ...
  511.                   'Parent',Axe_Leg,           ...
  512.                   'FontWeight','bold',        ...
  513.                   'Visible','off'             ...
  514.                   );
  515.         T2 = text(40,7,xlate('Original signal'),     ...
  516.                   'Parent',Axe_Leg,           ...
  517.                   'FontWeight','bold',        ...
  518.                   'Visible','off'             ...
  519.                   );
  520.         % Setting units to normalized.
  521.         %-----------------------------
  522.         wfigmngr('normalize',win_sigxtool);
  523.         % Store values.
  524.         %--------------
  525.         Hdls_UIC1 = { ...
  526.                      m_load,m_save,m_demo,  ...
  527.                      txt_signal,edi_signal, ...
  528.                      txt_mode,pop_mode,pus_extend ...
  529.                      };
  530.         Hdls_UIC2 = { ...
  531.                      frm_fra1,txt_length,edi_length, ...
  532.                      txt_nextpow2,edi_nextpow2,      ...
  533.                      txt_prevpow2,edi_prevpow2,      ...
  534.                      txt_deslen,edi_deslen,          ...
  535.                      txt_direct,pop_direct           ...
  536.                      };
  537.         Hdls_UIC3 = { ...
  538.                      frm_fra2,txt_swtdec,pop_swtdec, ...
  539.                      txt_swtlen,edi_swtlen,          ...
  540.                      txt_swtclen,edi_swtclen,        ...
  541.                      txt_swtdir,edi_swtdir           ...
  542.                      };
  543.         Hdls_Axes = struct('Axe_Sig',Axe_Sig,'Axe_Leg',Axe_Leg);
  544. % Add Context Sensitive Help (CSHelp).
  545. %-------------------------------------
  546. hdl_BORDER_DIST = [txt_mode,pop_mode];
  547. wfighelp('add_ContextMenu',win_sigxtool,...
  548. hdl_BORDER_DIST,'BORDER_DIST');
  549. %-------------------------------------
  550.         
  551. % Store handles.
  552.         %---------------
  553.         wfigmngr('storeValue',win_sigxtool,'Hdls_UIC1',Hdls_UIC1);
  554.         wfigmngr('storeValue',win_sigxtool,'Hdls_UIC2',Hdls_UIC2);
  555.         wfigmngr('storeValue',win_sigxtool,'Hdls_UIC3',Hdls_UIC3);
  556.         wfigmngr('storeValue',win_sigxtool,'Hdls_Axes',Hdls_Axes);
  557.         % End waiting.
  558.         %---------------
  559.         wwaiting('off',win_sigxtool);
  560.     case 'load'
  561.     %-------------------------------------------%
  562.     % Option: 'LOAD' - Load the original signal %
  563.     %-------------------------------------------%
  564.        
  565.         % Loading file.
  566.         %-------------
  567.         if length(varargin)<2  % LOAD Option
  568.             [sigInfos,Signal_Anal,ok] = ...
  569.                 utguidiv('load_sig',win_sigxtool,'*.mat','Load Signal');
  570.             Signal_Name = sigInfos.name;
  571.         else   % DEMO Option
  572.             Signal_Name  = deblank(varargin{2});
  573.             filename = [Signal_Name '.mat'];
  574.             pathname = utguidiv('WTB_DemoPath',filename);
  575.             [sigInfos,Signal_Anal,ok] = ...
  576.                 utguidiv('load_dem1D',win_sigxtool,pathname,filename);
  577.         end
  578.         if ~ok, return; end
  579.         % Begin waiting.
  580.         %---------------
  581.         wwaiting('msg',win_sigxtool,'Wait ... loading');
  582.         % Cleaning.
  583.         %----------
  584.         sigxtool('clear_GRAPHICS',win_sigxtool,'load');
  585.         % Compute UIC values.
  586.         %--------------------
  587.         Signal_Length = length(Signal_Anal);
  588.         pow           = fix(log(Signal_Length)/log(2));
  589.         Next_Pow2     = 2^(pow+1);
  590.         if isequal(2^pow,Signal_Length)
  591.             Prev_Pow2 = 2^(pow-1);
  592.             swtpow    = pow;
  593.         else
  594.             Prev_Pow2 = 2^pow;
  595.             swtpow    = pow+1;
  596.         end
  597.         % Compute the default level for SWT.
  598.         %-----------------------------------
  599.         def_pow = 1;
  600.         if ~rem(Signal_Length,2)
  601.             while ~rem(Signal_Length,2^def_pow), def_pow = def_pow + 1; end
  602.             def_level = def_pow-1;
  603.         else
  604.             def_level = def_pow;
  605.         end
  606.         % Compute the extended length for SWT.
  607.         %-------------------------------------
  608.         C_Length = Signal_Length;
  609.         while rem(C_Length,2^def_level), C_Length = C_Length + 1; end
  610.         
  611.         % Set UIC values.
  612.         %----------------
  613.         set(edi_signal,'String',sigInfos.name);
  614.         set(edi_length,'String',sprintf('%.0f',Signal_Length));
  615.         set(edi_nextpow2,'String',sprintf('%.0f',Next_Pow2));
  616.         set(edi_prevpow2,'String',sprintf('%.0f',Prev_Pow2));
  617.         set(edi_deslen,'String',sprintf('%.0f',Next_Pow2));
  618.         set(pop_direct,'Value',1);
  619.         set(pop_mode,'Value',1);
  620.         set(pus_extend,'String',xlate('Extend'));
  621.         set(pus_extend,'Enable','On');
  622.         set(pop_swtdec,'String',num2str((1:swtpow)'));
  623.         set(pop_swtdec,'Value',def_level);
  624.         set(edi_swtclen,'String',sprintf('%.0f',C_Length));
  625.         set(edi_swtlen,'String',sprintf('%.0f',Signal_Length));
  626.                 
  627.         % Set UIC visibility.
  628.         %--------------------
  629.         set(cat(1,Hdls_UIC2{:}),'visible','on')
  630.         set(cat(1,Hdls_UIC3{:}),'visible','off')
  631.         set(cat(1,Hdls_UIC1{4:end}),'visible','on')
  632.         % Get Axes Handles.
  633.         %------------------
  634.         Axe_Sig =  Hdls_Axes.Axe_Sig;
  635.         % Drawing.
  636.         %---------
  637.         Line_Sig = line(                         ...
  638.                         'parent',Axe_Sig,        ...
  639.                         'Xdata',1:Signal_Length, ...
  640.                         'Ydata',Signal_Anal,     ...
  641.                         'color','Green'          ...
  642.                         );
  643.         Max_Sig           = max(Signal_Anal);
  644.         Min_Sig           = min(Signal_Anal);
  645.         Amp_Sig           = Max_Sig - Min_Sig;
  646.         Ylim_Min_Sig_Anal = Min_Sig-Amp_Sig/100;
  647.         Ylim_Max_Sig_Anal = Max_Sig-Amp_Sig/100;
  648.         set(Axe_Sig,                                      ...
  649.             'Xlim',[1,Signal_Length],                     ...
  650.             'Ylim',[Ylim_Min_Sig_Anal,Ylim_Max_Sig_Anal], ...
  651.             'Visible','on'                                ...
  652.             );
  653.         set(get(Axe_Sig,'title'),'string',xlate('Original Signal'));
  654.         % Store values.
  655.         %--------------
  656.         wfigmngr('storeValue',win_sigxtool,'Signal_Anal',Signal_Anal);
  657.         wfigmngr('storeValue',win_sigxtool,'Line_Sig',Line_Sig);
  658.         % Update File_Save_Flag.
  659.         %-----------------------
  660.         File_Save_Flag = 0;
  661.         wfigmngr('storeValue',win_sigxtool,'File_Save_Flag',File_Save_Flag);
  662.         
  663.         % Dynvtool Attachement.
  664.         %---------------------
  665.         dynvtool('init',win_sigxtool,[],Axe_Sig,[],[1 0],'','','');
  666.         % End waiting.
  667.         %-------------
  668.         wwaiting('off',win_sigxtool);
  669.     case 'demo'
  670.         sigxtool('load',varargin{:});
  671.         Signal_Name  = deblank(varargin{2});
  672.         ext_OR_trunc = varargin{3};
  673.         if length(varargin)>3  & ~isempty(varargin{4})
  674.             par_Demo = varargin{4};
  675.         else
  676.             return;
  677.         end
  678.         extMode   = par_Demo{1};
  679.         lenSIG    = par_Demo{2};
  680.         direction = lower(par_Demo{3});
  681.         if ~isequal(extMode,'swt')
  682.             set(edi_deslen,'String',sprintf('%.0f',lenSIG));
  683.             sigxtool('update_deslen',win_sigxtool,'noClear');
  684.         else
  685.             set(pop_swtdec,'Value',lenSIG)
  686.             sigxtool('update_swtdec',win_sigxtool)
  687.         end
  688.         switch direction
  689.           case 'both'  , direct = 1;
  690.           case 'left'  , direct = 2;
  691.           case 'right' , direct = 3;
  692.         end
  693.         set(pop_direct,'Value',direct);
  694.         switch ext_OR_trunc
  695.           case 'ext'
  696.             switch extMode
  697.               case 'sym' ,         extVal = 1;
  698.               case 'ppd' ,         extVal = 5;
  699.               case 'zpd' ,         extVal = 6;
  700.               case 'sp0' ,         extVal = 7;
  701.               case {'sp1','spd'} , extVal = 8;
  702.               case 'swt' ,         extVal = 9;
  703.             end
  704.             set(pop_mode,'Value',extVal);
  705.             sigxtool('mode',win_sigxtool,'noClear')
  706.           case 'trunc'
  707.         end
  708.         sigxtool('extend_truncate',win_sigxtool);
  709.     case 'update_swtdec'
  710.     %----------------------------------------------------------------------%
  711.     % Option: 'UPDATE_SWTDEC' - Update values when using popup in SWT case %
  712.     %----------------------------------------------------------------------%
  713.         % Get stored structure.
  714.         %----------------------
  715.         Signal_Anal = wfigmngr('getValue',win_sigxtool,'Signal_Anal');
  716.         % Update the computed length.
  717.         %----------------------------
  718.         Signal_Length = length(Signal_Anal);
  719.         Level         = get(pop_swtdec,'Value');
  720.         remLen        = rem(Signal_Length,2^Level);
  721.         if remLen>0
  722.             Computed_Length = Signal_Length + 2^Level-remLen;
  723.         else
  724.             Computed_Length = Signal_Length;
  725.         end
  726.         set(edi_swtclen,'String',sprintf('%.0f',Computed_Length));
  727.         % Enabling Extend button.
  728.         %------------------------
  729.         set(pus_extend,'String','Extend','Enable','on');
  730.     case 'update_deslen'
  731.     %--------------------------------------------------------------------------%
  732.     % Option: 'UPDATE_DESLEN' - Update values when changing the Desired Length %
  733.     %--------------------------------------------------------------------------%
  734.         % Cleaning.
  735.         %----------
  736.         if nargin<3 , sigxtool('clear_GRAPHICS',win_sigxtool); end
  737.         % Update UIC values.
  738.         %-------------------
  739.         Signal_Length  = wstr2num(get(edi_length,'String'));
  740.         Desired_Length = wstr2num(get(edi_deslen,'String'));
  741.         uic_mode       = [txt_mode;pop_mode];
  742.         if      isequal(Signal_Length,Desired_Length)
  743.                 set(uic_mode,'Enable','off');
  744.                 set(pus_extend,'Enable','off');
  745.         elseif  isempty(Desired_Length) | Desired_Length < 2
  746.                 set(edi_deslen,'String',get(edi_nextpow2,'String'));
  747.                 set(txt_direct,'String','Direction to extend');
  748.                 set(uic_mode,'Enable','on');
  749.                 set(pus_extend,'String',xlate('Extend'),'Enable','on');
  750.         elseif Signal_Length < Desired_Length
  751.                 set(txt_direct,'String','Direction to extend')
  752.                 set(uic_mode,'Visible','On','Enable','on');
  753.                 set(pus_extend,'String',xlate('Extend'),'Enable','on');
  754.         elseif Signal_Length > Desired_Length
  755.                 set(txt_direct,'String','Direction to truncate');
  756.                 set(uic_mode,'Visible','off','Enable','on');
  757.                 set(pus_extend,'String',xlate('Truncate'),'Enable','on');
  758.         end
  759.     case 'mode'
  760.     %------------------------------------------------------------------------%
  761.     % Option: 'MODE' -  Update the command part when changing Extension Mode %
  762.     %------------------------------------------------------------------------%      
  763.         % Cleaning.
  764.         %----------
  765.         if nargin<3 , sigxtool('clear_GRAPHICS',win_sigxtool); end
  766.         % Checking the SWT case for visibility setings.
  767.         %----------------------------------------------
  768.         Mode_str = get(pop_mode,'String');
  769.         Mode_val = get(pop_mode,'Value');
  770.         if  strcmp(deblank(Mode_str(Mode_val,:)),'For SWT')
  771.             set(cat(1,Hdls_UIC2{:}),'visible','off');
  772.             set(cat(1,Hdls_UIC3{:}),'visible','on');
  773.             Signal_Length   = wstr2num(get(edi_swtlen,'String'));
  774.             Computed_Length = wstr2num(get(edi_swtclen,'String'));
  775.             if isequal(Signal_Length,nextpow2(Signal_Length))
  776.                 set(pus_extend,'Enable','off');
  777.                 msg = strvcat(...
  778.                   sprintf('The length of the signal (%s) is a power of 2.',int2str(Signal_Length)),  ...
  779.                   ['The SWT extension is not necessary!']);
  780.                 wwarndlg(msg,'SWT Extension Mode','block');
  781.             elseif Signal_Length < Computed_Length
  782.                 set(pus_extend,'String',xlate('Extend'),'Enable','on');
  783.             end
  784.         else
  785.             set(pus_extend,'Enable','on');
  786.             set(cat(1,Hdls_UIC2{:}),'visible','on');
  787.             set(cat(1,Hdls_UIC3{:}),'visible','off');
  788.         end
  789.         set(cat(1,Hdls_UIC1{4:end}),'visible','on');
  790.     case 'extend_truncate'
  791.     %--------------------------------------------------------------------------%
  792.     % Option: 'EXTEND_TRUNCATE' - Compute the new Extended or Truncated signal %
  793.     %--------------------------------------------------------------------------%
  794.         
  795.         % Begin waiting.
  796.         %---------------
  797.         wwaiting('msg',win_sigxtool,'Wait ... computing');
  798.         % Get stored structure.
  799.         %----------------------
  800.         Signal_Anal = wfigmngr('getValue',win_sigxtool,'Signal_Anal');
  801.                 
  802.         % Get Axes Handles.
  803.         %------------------
  804.         Axe_Sig     =  Hdls_Axes.Axe_Sig;
  805.         % Compute Ylim of Original Signal.
  806.         %---------------------------------
  807.         Max_Sig           = max(Signal_Anal);
  808.         Min_Sig           = min(Signal_Anal);
  809.         Amp_Sig           = Max_Sig - Min_Sig;
  810.         Ylim_Min_Sig_Anal = Min_Sig-Amp_Sig/100;
  811.         Ylim_Max_Sig_Anal = Max_Sig-Amp_Sig/100;
  812.         Axe_Sig_Ylim      = [Ylim_Min_Sig_Anal,Ylim_Max_Sig_Anal];
  813.         % Get UIC values.
  814.         %----------------
  815.         Signal_Length  = wstr2num(get(edi_length,'String'));
  816.         Desired_Length = wstr2num(get(edi_deslen,'String'));
  817.         Str_pop_mode   = get(pop_mode,'String');
  818.         Val_pop_mode   = get(pop_mode,'Value');
  819.         Str_pop_mode   = deblank(Str_pop_mode(Val_pop_mode,:));
  820.         if strcmp(Str_pop_mode,'For SWT')
  821.             Str_direct     = deblank(get(edi_swtdir,'String'));
  822.             Desired_Length = wstr2num(get(edi_swtclen,'String'));
  823.         else
  824.             Str_pop_direct = get(pop_direct,'String');
  825.             Val_pop_direct = get(pop_direct,'Value');
  826.             Str_direct     = deblank(Str_pop_direct(Val_pop_direct,:));
  827.             Desired_Length = wstr2num(get(edi_deslen,'String'));
  828.         end
  829.         % Extension mode conversion.
  830.         %---------------------------
  831.         Mode_Values = {'sym';'symw';'asym';'asymw';'ppd';'zpd';'sp0';'spd';'ppd'};
  832.         Mode        = Mode_Values{Val_pop_mode};
  833.         % Get action to do.
  834.         %------------------
  835.         action = deblank(get(pus_extend,'string'));
  836.         switch action
  837.             case xlate('Truncate')
  838.  
  839.                 switch Str_direct
  840.                   case 'Left'
  841.                         % Computing new signal.
  842.                         %----------------------
  843.                         New_Signal  = wkeep1(Signal_Anal,Desired_Length,'r');
  844.                         % Drawing.
  845.                         %---------
  846.                         Deb_O_S     = 1;
  847.                         Fin_O_S     = Signal_Length;
  848.                         Deb_N_S     = 1 + Signal_Length - Desired_Length;
  849.                         Fin_N_S     = Signal_Length;
  850.                         Signal_Lims = [Deb_O_S Fin_O_S Deb_N_S Fin_N_S];
  851.                         sigxtool('draw',win_sigxtool,Signal_Anal, ...
  852.                                     Signal_Lims,action);
  853.                   case 'Right'
  854.                         % Computing new signal.
  855.                         %----------------------
  856.                         New_Signal = wkeep1(Signal_Anal,Desired_Length,'l');
  857.                         % Drawing.
  858.                         %---------
  859.                         Deb_O_S     = 1;
  860.                         Fin_O_S     = Signal_Length;
  861.                         Deb_N_S     = 1;
  862.                         Fin_N_S     = Desired_Length;
  863.                         Signal_Lims = [Deb_O_S Fin_O_S Deb_N_S Fin_N_S];
  864.                         sigxtool('draw',win_sigxtool,Signal_Anal, ...
  865.                                     Signal_Lims,action);
  866.                   case 'Both'
  867.                         % Computing new signal.
  868.                         %----------------------
  869.                         New_Signal = wkeep1(Signal_Anal,Desired_Length,'c');
  870.                         % Drawing.
  871.                         %---------
  872.                         Deb_O_S     = 1;
  873.                         Fin_O_S     = Signal_Length;
  874.                         Deb_N_S     = fix((Signal_Length - Desired_Length)/2)+1;
  875.                         Fin_N_S     = Deb_N_S + Desired_Length - 1;
  876.                         Signal_Lims = [Deb_O_S Fin_O_S Deb_N_S Fin_N_S];
  877.                         sigxtool('draw',win_sigxtool,Signal_Anal, ...
  878.                                     Signal_Lims,action);
  879.                   otherwise
  880.                         errargt(mfilename,'Unknown Option','msg');
  881.                         error('*');
  882.                 end
  883.             case xlate('Extend')
  884.             
  885.                 switch Str_direct
  886.                     case 'Left'
  887.                         % Computing new signal.
  888.                         %----------------------
  889.                         New_Signal = wextend(1,Mode,Signal_Anal, ...
  890.                                             Desired_Length-Signal_Length,'l');
  891.                         % Drawing.
  892.                         %---------
  893.                         Deb_O_S     = Desired_Length - Signal_Length + 1;
  894.                         Fin_O_S     = Deb_O_S + Signal_Length - 1;
  895.                         Deb_N_S     = 1;
  896.                         Fin_N_S     = Desired_Length;
  897.                         Signal_Lims = [Deb_O_S Fin_O_S Deb_N_S Fin_N_S];
  898.                         sigxtool('draw',win_sigxtool,New_Signal, ...
  899.                                     Signal_Lims,action);
  900.                     case 'Right'
  901.                         % Computing new signal.
  902.                         %----------------------
  903.                         New_Signal = wextend(1,Mode,Signal_Anal, ...
  904.                                             Desired_Length-Signal_Length,'r');
  905.                         % Drawing.
  906.                         %---------
  907.                         Deb_O_S     = 1;
  908.                         Fin_O_S     = Signal_Length;
  909.                         Deb_N_S     = 1;
  910.                         Fin_N_S     = Desired_Length;
  911.                         Signal_Lims = [Deb_O_S Fin_O_S Deb_N_S Fin_N_S];
  912.                         sigxtool('draw',win_sigxtool,New_Signal, ...
  913.                                     Signal_Lims,action);
  914.                     case 'Both'
  915.                         % Computing new signal.
  916.                         %----------------------
  917.                         Diff_Length = Desired_Length-Signal_Length;
  918.                         Ext_Length  = ceil(Diff_Length / 2);
  919.                         New_Signal  = wextend(1,Mode,Signal_Anal,Ext_Length,'b');
  920.                         if rem(Diff_Length,2)
  921.                             New_Signal = wkeep1(New_Signal,Desired_Length,'c',1);
  922.                         end
  923.                         % Drawing.
  924.                         %---------
  925.                         Deb_O_S     = fix(Diff_Length / 2) + 1;
  926.                         Fin_O_S     = Deb_O_S + Signal_Length-1;
  927.                         Deb_N_S     = 1;
  928.                         Fin_N_S     = Desired_Length;
  929.                         Signal_Lims = [Deb_O_S Fin_O_S Deb_N_S Fin_N_S];
  930.                         sigxtool('draw',win_sigxtool,New_Signal, ...
  931.                                     Signal_Lims,action);
  932.                     otherwise
  933.                         errargt(mfilename,'Unknown Option','msg');
  934.                         error('*');
  935.                 end
  936.             otherwise
  937.                 errargt(mfilename,'Unknown Action','msg');
  938.                 error('*');
  939.         end
  940.         % Saving the new signal.
  941.         %-----------------------
  942.         wfigmngr('storeValue',win_sigxtool,'New_Signal',New_Signal);
  943.         % End waiting.
  944.         %-------------
  945.         wwaiting('off',win_sigxtool);
  946.         
  947.     case 'draw'
  948.     %-----------------------------------------------------%
  949.     % Option: 'DRAW' - Plot both new and original signals %
  950.     %-----------------------------------------------------%
  951.         % Get arguments.
  952.         %---------------
  953.         Signal      = varargin{2};
  954.         Signal_Lims = varargin{3};
  955.         action      = varargin{4};
  956.         Deb_O_S     = Signal_Lims(1);
  957.         Fin_O_S     = Signal_Lims(2);
  958.         Deb_N_S     = Signal_Lims(3);
  959.         Fin_N_S     = Signal_Lims(4);
  960.         
  961.         % Begin waiting.
  962.         %---------------
  963.         wwaiting('msg',win_sigxtool,'Wait ... drawing');
  964.         % Get stored structure.
  965.         %----------------------
  966.         Line_Sig    = wfigmngr('getValue',win_sigxtool,'Line_Sig');
  967.         Box_Old_Sig = wfigmngr('getValue',win_sigxtool,'Box_Old_Sig');
  968.         Box_New_Sig = wfigmngr('getValue',win_sigxtool,'Box_New_Sig');
  969.         % Get Axes Handles.
  970.         %------------------
  971.         Axe_Sig =  Hdls_Axes.Axe_Sig;
  972.         Axe_Leg =  Hdls_Axes.Axe_Leg;
  973.         % Clean signals axes.
  974.         %--------------------
  975.         if ~isempty(Box_Old_Sig), delete(Box_Old_Sig); end
  976.         if ~isempty(Box_New_Sig), delete(Box_New_Sig); end
  977.         % Compute Ylim for the Signal.
  978.         %-----------------------------
  979.         Len_Signal = length(Signal);
  980.         Max_Signal = max(Signal);
  981.         Min_Signal = min(Signal);
  982.         Off_Signal = (Max_Signal - Min_Signal) / 100;
  983.         Ylim_Min   = Min_Signal - 10 * Off_Signal;
  984.         Ylim_Max   = Max_Signal + 10 * Off_Signal;
  985.         % Update axes properties.
  986.         %------------------------
  987.         set(Axe_Sig,                    ...
  988.             'Box','on',                 ...
  989.             'Xlim',[1,Len_Signal],      ...
  990.             'Ylim',[Ylim_Min,Ylim_Max], ...
  991.             'Visible','on'              ...
  992.             );
  993.         set(get(Axe_Sig,'title'),'string','');
  994.         % Draw signal.
  995.         %-------------
  996.         X   = 1:Len_Signal;
  997.         Y   = Signal;
  998.         set(Line_Sig,'Xdata',X,'Ydata',Y,'parent',Axe_Sig);
  999.         switch action
  1000.             case xlate('Extend')
  1001.                 % Constant coefs. for box design.
  1002.                 %--------------------------------
  1003.                 C1 = 7;
  1004.                 C2 = 3;
  1005.                 S1 = 3;
  1006.                 S2 = 3;
  1007.                                     
  1008.                 % Draw Box around old signal.
  1009.                 %----------------------------
  1010.                 Y_base      = [Ylim_Min Ylim_Max Ylim_Max Ylim_Min Ylim_Min];
  1011.                 X           = [Deb_O_S Deb_O_S Fin_O_S Fin_O_S Deb_O_S];
  1012.                 Y           = Y_base + [C1 -C1 -C1 C1 C1]*Off_Signal;
  1013.                 Box_Old_Sig = line(X,Y,              ...
  1014.                                    'parent',Axe_Sig, ...
  1015.                                    'color','red',    ...
  1016.                                    'LineWidth',S1    ...
  1017.                                    );
  1018.         
  1019.                 % Draw Box around new signal.
  1020.                 %----------------------------
  1021.                 X        = [Deb_N_S Deb_N_S Fin_N_S Fin_N_S Deb_N_S];
  1022.                 Y           = Y_base + [C2 -C2 -C2 C2 C2]*Off_Signal;
  1023.                 Box_New_Sig = line(X,Y,              ...
  1024.                                    'parent',Axe_Sig, ...
  1025.                                    'color','yellow', ...
  1026.                                    'LineWidth',S2    ...
  1027.                                    );
  1028.             case xlate('Truncate')
  1029.                 % Constant coefs. for box design.
  1030.                 %--------------------------------
  1031.                 C1 = 3;
  1032.                 C2 = 7;
  1033.                 S1 = 3;
  1034.                 S2 = 3;
  1035.                 % Draw Box around old signal.
  1036.                 %----------------------------
  1037.                 Y_base      = [Ylim_Min Ylim_Max Ylim_Max Ylim_Min Ylim_Min];
  1038.                 X        = [Deb_O_S Deb_O_S Fin_O_S Fin_O_S Deb_O_S];
  1039.                 Y           = Y_base + [C1 -C1 -C1 C1 C1] * Off_Signal;
  1040.                 Box_Old_Sig = line(X,Y,              ...
  1041.                                    'parent',Axe_Sig, ...
  1042.                                    'color','red',    ...
  1043.                                    'LineWidth',S1    ...
  1044.                                    );
  1045.                          
  1046.                 % Draw Box around new signal.
  1047.                 %----------------------------
  1048.                 X           = [Deb_N_S Deb_N_S Fin_N_S Fin_N_S Deb_N_S];
  1049.                 Y           = Y_base + [C2 -C2 -C2 C2 C2] * Off_Signal;
  1050.                 Box_New_Sig = line(X,Y,              ...
  1051.                                    'parent',Axe_Sig, ...
  1052.                                    'color','yellow', ...
  1053.                                    'LineWidth',S2    ...
  1054.                                    );
  1055.         end
  1056.         % Display Legend.
  1057.         %----------------
  1058.         set(Axe_Leg,'Visible','on');
  1059.         set(get(Axe_Leg,'Children'),'Visible','on');
  1060.         % Dynvtool Attachement.
  1061.         %----------------------
  1062.         dynvtool('init',win_sigxtool,[],Axe_Sig,[],[1 0],'','','');
  1063.         % Update File_Save_Flag.
  1064.         %-----------------------
  1065.         File_Save_Flag = 0;
  1066.         wfigmngr('storeValue',win_sigxtool,'File_Save_Flag',File_Save_Flag);
  1067.         
  1068.         % Enable save menu On.
  1069.         %---------------------
  1070.         set(m_save,'Enable','on');
  1071.         % Store values.
  1072.         %--------------        
  1073.         wfigmngr('storeValue',win_sigxtool,'Box_Old_Sig',Box_Old_Sig);
  1074.         wfigmngr('storeValue',win_sigxtool,'Box_New_Sig',Box_New_Sig);
  1075.         % End waiting.
  1076.         %-------------
  1077.         wwaiting('off',win_sigxtool);
  1078.         
  1079.     case 'save'
  1080.     %------------------------------------------%
  1081.     % Option: 'SAVE' - Save transformed signal %
  1082.     %------------------------------------------%
  1083.         % Begin waiting.
  1084.         %--------------
  1085.         wwaiting('msg',win_sigxtool,'Wait ... saving');
  1086.         % Restore the new signal.
  1087.         %------------------------
  1088.         New_Signal   = wfigmngr('getValue',win_sigxtool,'New_Signal');
  1089.         % Testing file.
  1090.         %--------------
  1091.         [filename,pathname,ok] = utguidiv('test_save',win_sigxtool, ...
  1092.                                     '*.mat','Save Transformed Signal');
  1093.         if ~ok, return; end
  1094.         % Saving transformed Signal.
  1095.         %---------------------------
  1096.         [name,ext] = strtok(filename,'.');
  1097.         if isempty(ext) | isequal(ext,'.')
  1098.             ext = '.mat'; filename = [name ext];
  1099.         end
  1100.         eval([name ' = New_Signal;']);
  1101. saveStr = name;
  1102.         try
  1103.           save([pathname filename],saveStr);
  1104.         catch
  1105.           errargt(mfilename,'Save FAILED !','msg');
  1106.         end
  1107.         % Update File_Save_Flag.
  1108.         %-----------------------
  1109.         File_Save_Flag = 1;
  1110.         wfigmngr('storeValue',win_sigxtool,'File_Save_Flag',File_Save_Flag);
  1111.         
  1112.         % Enable save menu On.
  1113.         %---------------------
  1114.         set(m_save,'Enable','off');
  1115.                 
  1116.         % End waiting.
  1117.         %-------------
  1118.         wwaiting('off',win_sigxtool);
  1119.     case 'clear_GRAPHICS'
  1120.     %----------------------------------------------------------------------%
  1121.     % Option: 'CLEAR_GRAPHICS' - Clear graphics and redraw original signal %
  1122.     %----------------------------------------------------------------------%
  1123.         % Get arguments.
  1124.         %---------------
  1125.         if length(varargin) > 1 , Draw_flag = 0; else Draw_flag = 1; end
  1126.         % Get stored structure.
  1127.         %----------------------
  1128.         Signal_Anal = wfigmngr('getValue',win_sigxtool,'Signal_Anal');
  1129.         Line_Sig    = wfigmngr('getValue',win_sigxtool,'Line_Sig');
  1130.         % Get Axes Handles.
  1131.         %------------------
  1132.         Axe_Sig = Hdls_Axes.Axe_Sig;
  1133.         Axe_Leg = Hdls_Axes.Axe_Leg;
  1134.         % Set graphics part visible off and redraw original signal if needed.
  1135.         %--------------------------------------------------------------------
  1136.         set(Axe_Leg,'Visible','off');
  1137.         set(get(Axe_Leg,'Children'),'Visible','off');
  1138.         if Draw_flag
  1139.             set(findobj(Axe_Sig,'Type','line'),'Visible','Off');
  1140.             Signal_Length     = length(Signal_Anal);
  1141.             Max_Sig           = max(Signal_Anal);
  1142.             Min_Sig           = min(Signal_Anal);
  1143.             Amp_Sig           = Max_Sig - Min_Sig;
  1144.             Ylim_Min_Sig_Anal = Min_Sig-Amp_Sig/100;
  1145.             Ylim_Max_Sig_Anal = Max_Sig-Amp_Sig/100;
  1146.             set(Axe_Sig,                                      ...
  1147.                 'Xlim',[1,Signal_Length],                     ...
  1148.                 'Ylim',[Ylim_Min_Sig_Anal,Ylim_Max_Sig_Anal], ...
  1149.                 'Visible','on'                                ...
  1150.                 );
  1151.             set(get(Axe_Sig,'title'),'string',xlate('Original Signal'));
  1152.             set(Line_Sig, ...
  1153.                 'parent',Axe_Sig,        ...
  1154.                 'Xdata',1:Signal_Length, ...
  1155.                 'Ydata',Signal_Anal,     ...
  1156.                 'color','Green',         ...
  1157.                 'Visible','on'           ...
  1158.                 );
  1159.             dynvtool('init',win_sigxtool,[],Axe_Sig,[],[1 0],'','','');
  1160.         else
  1161.             set(Axe_Sig,'Visible','off');
  1162.             set(get(Axe_Sig,'Children'),'Visible','off');
  1163.         end
  1164.         % Enable save menu off.
  1165.         %----------------------
  1166.         set(m_save,'Enable','off');
  1167.         % Reset the new signal.
  1168.         %----------------------
  1169.         wfigmngr('storeValue',win_sigxtool,'New_Signal',[]);
  1170.         
  1171.     case 'close'
  1172.     %---------------------------------------%
  1173.     % Option: 'CLOSE' - Close current figure%
  1174.     %---------------------------------------%
  1175.         % Retrieve File_Save_Flag.
  1176.         %-------------------------
  1177.         File_Save_Flag = wfigmngr('getValue',win_sigxtool,'File_Save_Flag');
  1178.         
  1179.         % Retrieve signal values.
  1180.         %------------------------
  1181.         New_Signal  = wfigmngr('getValue',win_sigxtool,'New_Signal');
  1182.         Signal_Anal = wfigmngr('getValue',win_sigxtool,'Signal_Anal');
  1183.         
  1184.         % Test for saving the new signal.
  1185.         %--------------------------------
  1186.         status = 0;
  1187.         if ~isempty(New_Signal) & length(New_Signal)~=length(Signal_Anal) &...
  1188.             ~File_Save_Flag
  1189.             status = wwaitans(win_sigxtool,...
  1190.                      ' Do you want to save the transformed signal ?',2,'cond');
  1191.         end
  1192.         switch status
  1193.           case 1 , sigxtool('save',win_sigxtool)
  1194.           case 0 ,
  1195.         end
  1196.         varargout{1} = status;
  1197.     otherwise
  1198.     %-----------------%
  1199.     % Option: UNKNOWN %
  1200.     %-----------------%    
  1201.         errargt(mfilename,'Unknown Option','msg');
  1202.         error('*');
  1203. end