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

波变换

开发平台:

Matlab

  1. function wavedemo(option,in2,in3)
  2. %WAVEDEMO Wavelet Toolbox demos.
  3. %   WAVEDEMO brings up a GUI that allows you to choose
  4. %   between several Wavelet Toolbox demos.
  5. %   WAVEDEMO('auto') shows all the demos in automatic mode.
  6. %
  7. %   WAVEDEMO('gr_auto') shows all the demos in automatic mode:
  8. %   first in the increasing slide order and then in the 
  9. %   decreasing slide order.
  10. %
  11. %   WAVEDEMO('loop') shows all the demos in loop mode.
  12. %   M. Misiti, Y. Misiti, G. Oppenheim, J.M. Poggi 12-Mar-96.
  13. %   Last Revision: 10-Apr-2004.
  14. %   Copyright 1995-2004 The MathWorks, Inc.
  15. %   $Revision: 1.15.4.1 $ $Date: 2004/04/01 16:30:41 $
  16. tag_dem_tool  = 'Demo_Tool';
  17. tag_btn_close = 'Demo_Close';       % tag for sub_window
  18. tag_btn_closeBIS = 'Pus_Close_Win'; % tag for sub_window
  19. if nargin==0
  20.     option = 'create';
  21. elseif (nargin==1) & ~ischar(option)
  22.     in2    = option;
  23.     option = 'pref_b';
  24. end
  25. if strcmp(option,'pref') | strcmp(option,'pref_b')
  26.     win = wfindobj('figure','tag',tag_dem_tool);
  27.     if ~isempty(win) , return; end
  28.     if strcmp(option,'pref') & nargin==1 , in2 = 1; end
  29.     if ~wtbxmngr('is_on') , wtbxmngr('ini'); end
  30.     mextglob('pref',in2);
  31.     option = 'create';
  32. end
  33. switch option
  34.     case 'create'
  35.         win = wfindobj('figure','tag',tag_dem_tool);
  36.         if ~isempty(win) , return; end
  37.         % Waiting Frame construction & begin waiting.
  38.         %--------------------------------------------
  39.         mousefrm(0,'watch');
  40.         clc
  41.         disp('Wait ... loading');
  42.         drawnow;
  43.         % WAVEDEMO main window initialization.
  44.         %-------------------------------------
  45.         name = 'Wavelet Toolbox Demo';
  46.         [win_wavedemo,pos_win,defBtnWidth,defBtnHeight,win_units] = ...
  47.                 wdfigutl('menu',name,[11/4 19/2],tag_dem_tool);
  48.         winSTR = sprintf('%25.18f',win_wavedemo);
  49.         set(win_wavedemo,'CloseRequestFcn',...
  50.             [mfilename '(''close'',' winSTR ')'])
  51.         % Position property of objects.
  52.         %------------------------------
  53.         btn_width   = 2.3*defBtnWidth;
  54.         btn_heigth  = 3*defBtnHeight/2;
  55.         btn_left    = ceil((pos_win(3)-btn_width)/2);
  56.         btn_low     = pos_win(4)-5*defBtnHeight/2;
  57.         dif_heigth  = 2*defBtnHeight;
  58.         pos_cmdm    = [btn_left , btn_low , btn_width , btn_heigth];
  59.         btn_low     = btn_low-dif_heigth;
  60.         pos_guim    = [btn_left , btn_low , btn_width , btn_heigth];
  61.         btn_low     = btn_low-dif_heigth;
  62.         pos_sc1d    = [btn_left , btn_low , btn_width , btn_heigth];
  63.         btn_low     = btn_low-dif_heigth;
  64.         pos_close   = [btn_left , btn_low , btn_width , btn_heigth];
  65.         % String property of objects.
  66.         %----------------------------
  67.         str_cmdm    = 'Command line mode';
  68.         str_guim    = 'GUI mode';
  69.         str_sc1d    = 'Short 1D scenario';
  70.         str_close   = 'Close';
  71.         % Callback property of objects.
  72.         %------------------------------
  73.         cba_close   = [mfilename '(''close'');'];
  74.         % Construction of objects.
  75.         %-------------------------
  76.         pus_cmdm  = uicontrol('Parent',win_wavedemo,...
  77.                                         'Style','Pushbutton',...
  78.                                         'Unit',win_units,...
  79.                                         'Position',pos_cmdm,...
  80.                                         'String',str_cmdm...
  81.                                         );
  82.         pus_guim  = uicontrol('Parent',win_wavedemo,...
  83.                                         'Style','Pushbutton',...
  84.                                         'Unit',win_units,...
  85.                                         'Position',pos_guim,...
  86.                                         'String',str_guim...
  87.                                         );
  88.         pus_sc1d  = uicontrol('Parent',win_wavedemo,...
  89.                                         'Style','Pushbutton',...
  90.                                         'Unit',win_units,...
  91.                                         'Position',pos_sc1d,...
  92.                                         'String',str_sc1d...
  93.                                         );
  94.         pus_close = uicontrol('Parent',win_wavedemo,...
  95.                                         'Style','Pushbutton',...
  96.                                         'Unit',win_units,...
  97.                                         'Position',pos_close,...
  98.                                         'String',str_close,...
  99.                                         'Callback',cba_close...
  100.                                         );
  101.         % Callback property of objects.
  102.         %------------------------------
  103.         str_btn   = num2mstr([pus_cmdm;pus_guim;pus_sc1d]);
  104.         cba_cmdm  = [mfilename '(''democmdm'',' str_btn ');'];
  105.         cba_guim  = [mfilename '(''demoguim'',' str_btn ');'];
  106.         cba_sc1d  = [mfilename '(''demoscen'',' str_btn ');'];
  107.         set(pus_cmdm,'Callback',cba_cmdm);
  108.         set(pus_guim,'Callback',cba_guim);
  109.         set(pus_sc1d,'Callback',cba_sc1d);
  110.         % Setting units to normalized.
  111.         %-----------------------------
  112.         set(findobj(win_wavedemo,'Units','pixels'),'Units','Normalized');
  113.         % Hide figure handle.
  114.         %--------------------
  115.         hidegui(win_wavedemo,'off');
  116.         % End waiting.
  117.         %---------------
  118.         clc
  119.         mousefrm(0,'arrow');
  120.         drawnow
  121.     case 'democmdm'
  122.         %****************************************************%
  123.         %** OPTION = 'democmdm' - Command line mode demos  **%
  124.         %****************************************************%
  125.         mousefrm(0,'watch')
  126.         set(in2,'Enable','off')
  127.         mousefrm(0,'arrow');
  128.         feval('democmdm');
  129.     case 'demoguim'
  130.         %*******************************************%
  131.         %** OPTION = 'demoguim' - GUI mode demos  **%
  132.         %*******************************************%
  133.         mousefrm(0,'watch')
  134.         set(in2,'Enable','off')
  135.         mousefrm(0,'arrow');
  136.         feval('demoguim');
  137.     case 'demoscen'
  138.         %**********************************************%
  139.         %** OPTION = 'demoscen' - Short 1D scenario  **%
  140.         %**********************************************%
  141.         % in3 for auto mode
  142.         %-------------------
  143.         mousefrm(0,'watch')
  144.         set(in2,'Enable','off')
  145.         mousefrm(0,'arrow');
  146.         feval('demoscen');
  147.     case {'auto','gr_auto'}
  148.         %************************************%
  149.         %** OPTION = 'auto' and 'gr_auto'  **%
  150. %** All demos inautomatic modes.   **%
  151.         %************************************%
  152.         wavedemo('create');
  153.         win = wfindobj('figure','tag',tag_dem_tool);
  154.         btn = findobj(win,'style','pushbutton');
  155.         mousefrm(0,'watch')
  156.         set(btn,'Enable','off')
  157.         stop = 0;
  158.         while stop==0
  159. stop = ~ishandle(win);
  160. if ~stop , feval('democmdm',option); end
  161. stop = ~ishandle(win);
  162. if ~stop , feval('demoguim',option); end
  163. stop = ~ishandle(win);
  164. if ~stop , feval('demoscen',option); end
  165.             if ~isequal(stop,1) & nargin==2 & isequal(in2,'loop')
  166. stop = 0 ;
  167. else
  168. stop = 1;
  169. end
  170.         end
  171.         if ishandle(btn) , set(btn,'Enable','on'); end
  172.         mousefrm(0,'arrow');
  173.         wavedemo('close');
  174.     case 'loop'
  175.         %************************************************************%
  176.         %** OPTION = 'loop' - loop with all demos (automatic mode) **%
  177.         %************************************************************%
  178.         wavedemo('auto','loop');
  179.     case 'close'
  180.         %***********************************************%
  181.         %** OPTION = 'close' - close wavedemo window  **%
  182.         %***********************************************%
  183.         mousefrm(0,'watch')
  184.         win = wfindobj('figure','tag',tag_dem_tool);
  185.         % Closing all opened main analysis windows.
  186.         %------------------------------------------
  187.         pus_handles = wfindobj(0,'Style','pushbutton');
  188.         hdls        = findobj(pus_handles,'flat','Tag',tag_btn_close);
  189.         for i=1:length(hdls)
  190.             try , eval(get(hdls(i),'Callback')); end
  191.         end
  192.         try
  193.             hdls = findobj(pus_handles,'flat','Tag',tag_btn_closeBIS);
  194.             for k=1:length(hdls)
  195.                 try ,
  196.                     FigChild = get(hdls(k),'Parent');
  197.                     eval(get(FigChild,'CloseRequestFcn'));
  198.                 end
  199.             end
  200.         end
  201.         try
  202.             WfigPROP = wtbxappdata('get',win,'WfigPROP');
  203.             FigChild = WfigPROP.FigChild;
  204.             for k=1:length(FigChild)
  205.                 try ,eval(get(FigChild,'CloseRequestFcn')); end
  206.             end
  207.         end
  208.         % Closing the wavedemo window.
  209.         %-----------------------------
  210.         try ; delete(win); end
  211.         mextglob('clear');
  212.         wtbxmngr('clear');
  213.         mousefrm(0,'arrow');
  214.     otherwise
  215.         errargt(mfilename,'Unknown Option','msg');
  216.         error('*');
  217. end