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

波变换

开发平台:

Matlab

  1. function out1 = democmdm(option,in2,in3)
  2. %DEMOCMDM Main command-line mode demos menu in the Wavelet Toolbox.
  3. %   DEMOCMDM creates the window for command line mode demos.
  4. %   DEMOCMDM('auto') shows all the command line mode demos
  5. %   in automatic mode.
  6. %
  7. %   DEMOCMDM('gr_auto') shows all the command line mode demos
  8. %   in automatic mode: first in the increasing slide order
  9. %   and then in the decreasing slide order.
  10. %
  11. %   DEMOCMDM('loop') shows all the command line mode demos
  12. %   in loop mode.
  13. %   M. Misiti, Y. Misiti, G. Oppenheim, J.M. Poggi 12-Mar-96.
  14. %   Last Revision: 18-Apr-2001.
  15. %   Copyright 1995-2002 The MathWorks, Inc.
  16. %   $Revision: 1.17 $ $Date: 2002/04/14 19:31:07 $
  17. if nargin==0 , option = 'create'; end
  18. tag_dem_tool  = 'Demo_Tool';
  19. tag_cmdm_tool = 'Cmdm_Tool';
  20. tag_btn_close = 'Demo_Close';
  21. tag_sub_close = 'Cmdm_Close';
  22. switch option
  23.     case 'create'
  24.         win = wfindobj('figure','tag',tag_cmdm_tool);
  25.         if ~isempty(win) , return; end
  26.         % Waiting Frame construction & begin waiting.
  27.         %--------------------------------------------
  28.         mousefrm(0,'watch');
  29.         % CMDM main window initialization.
  30.         %---------------------------------
  31.         name = 'Command line mode demos';
  32.         [win_democmdm,pos_win,defBtnWidth,defBtnHeight,win_units] = ...
  33.                 wdfigutl('menu',name,[13/4 41/2],tag_cmdm_tool);
  34.         if nargout>0 ,out1 = win_democmdm; end
  35.         str_win_democmdm = int2str(win_democmdm);
  36.         % Position property of objects.
  37.         %------------------------------
  38.         btn_width  = 3*defBtnWidth;
  39.         btn_heigth = 3*defBtnHeight/2;
  40.         btn_left   = ceil(pos_win(3)-btn_width)/2;
  41.         btn_low    = pos_win(4)-2*defBtnHeight;
  42.         dif_heigth = 2*defBtnHeight;
  43.         pos_dw1d   = [btn_left , btn_low , btn_width , btn_heigth];
  44.         btn_low    = btn_low-dif_heigth;
  45.         pos_cw1d   = [btn_left , btn_low , btn_width , btn_heigth];
  46.         btn_low    = btn_low-dif_heigth;
  47.         pos_dw2d   = [btn_left , btn_low , btn_width , btn_heigth];
  48.         btn_low    = btn_low-dif_heigth;
  49.         pos_comp   = [btn_left , btn_low , btn_width , btn_heigth];
  50.         btn_low    = btn_low-dif_heigth;
  51.         pos_deno   = [btn_left , btn_low , btn_width , btn_heigth];
  52.         btn_low    = btn_low-dif_heigth;
  53.         pos_wpck   = [btn_left , btn_low , btn_width , btn_heigth];
  54.         btn_low    = btn_low-dif_heigth;
  55.         pos_mala   = [btn_left , btn_low , btn_width , btn_heigth];
  56.         btn_low    = btn_low-dif_heigth;
  57.         pos_casc   = [btn_left , btn_low , btn_width , btn_heigth];
  58.         btn_low    = btn_low-dif_heigth;
  59.         pos_extm   = [btn_left , btn_low , btn_width , btn_heigth];
  60.         btn_low    = btn_low-dif_heigth;
  61.         pos_close  = [btn_left , btn_low , btn_width , btn_heigth];
  62.         % String property of objects.
  63.         %----------------------------
  64.         str_dw1d   = 'Wavelet 1-D';
  65.         str_cw1d   = 'Continuous Wavelet 1-D';
  66.         str_dw2d   = 'Wavelet 2-D';
  67.         str_comp   = 'Compression';
  68.         str_deno   = 'De-noising';
  69.         str_wpck   = 'Wavelet Packets';
  70.         str_mala   = 'Mallat algorithm';
  71.         str_casc   = 'Cascade algorithm';
  72.         str_extm   = 'Border distortion';
  73.         str_close  = 'Close';
  74.         % Callback property of objects.
  75.         %------------------------------
  76.         cba_dw1d  = [mfilename '(''dw1d'',' str_win_democmdm ');'];
  77.         cba_cw1d  = [mfilename '(''cw1d'',' str_win_democmdm ');'];
  78.         cba_dw2d  = [mfilename '(''dw2d'',' str_win_democmdm ');'];
  79.         cba_comp  = [mfilename '(''comp'',' str_win_democmdm ');'];
  80.         cba_deno  = [mfilename '(''deno'',' str_win_democmdm ');'];
  81.         cba_wpck  = [mfilename '(''wpck'',' str_win_democmdm ');'];
  82.         cba_mala  = [mfilename '(''mala'',' str_win_democmdm ');'];
  83.         cba_casc  = [mfilename '(''casc'',' str_win_democmdm ');'];
  84.         cba_extm  = [mfilename '(''extm'',' str_win_democmdm ');'];
  85.         cba_close = [mfilename '(''close'',' str_win_democmdm ');'];
  86.         % Construction of objects.
  87.         %-------------------------
  88.         pus_dw1d   = uicontrol(...
  89.                                    'Style','Pushbutton',...
  90.                                    'Unit',win_units,...
  91.                                    'Position',pos_dw1d,...
  92.                                    'String',str_dw1d,...
  93.                                    'Callback',cba_dw1d...
  94.                                    );
  95.         pus_cw1d   = uicontrol(...
  96.                                    'Style','Pushbutton',...
  97.                                    'Unit',win_units,...
  98.                                    'Position',pos_cw1d,...
  99.                                    'String',str_cw1d,...
  100.                                    'Callback',cba_cw1d...
  101.                                    );
  102.         pus_dw2d   = uicontrol(...
  103.                                    'Style','Pushbutton',...
  104.                                    'Unit',win_units,...
  105.                                    'Position',pos_dw2d,...
  106.                                    'String',str_dw2d,...
  107.                                    'Callback',cba_dw2d...
  108.                                    );
  109.         pus_comp   = uicontrol(...
  110.                                    'Style','Pushbutton',...
  111.                                    'Unit',win_units,...
  112.                                    'Position',pos_comp,...
  113.                                    'String',str_comp,...
  114.                                    'Callback',cba_comp...
  115.                                    );
  116.         pus_deno   = uicontrol(...
  117.                                    'Style','Pushbutton',...
  118.                                    'Unit',win_units,...
  119.                                    'Position',pos_deno,...
  120.                                    'String',str_deno,...
  121.                                    'Callback',cba_deno...
  122.                                    );
  123.         pus_wpck   = uicontrol(...
  124.                                    'Style','Pushbutton',...
  125.                                    'Unit',win_units,...
  126.                                    'Position',pos_wpck,...
  127.                                    'String',str_wpck,...
  128.                                    'Callback',cba_wpck...
  129.                                    );
  130.         pus_mala   = uicontrol(...
  131.                                    'Style','Pushbutton',...
  132.                                    'Unit',win_units,...
  133.                                    'Position',pos_mala,...
  134.                                    'String',str_mala,...
  135.                                    'Callback',cba_mala...
  136.                                    );
  137.         pus_casc   = uicontrol(...
  138.                                    'Style','Pushbutton',...
  139.                                    'Unit',win_units,...
  140.                                    'Position',pos_casc,...
  141.                                    'String',str_casc,...
  142.                                    'Callback',cba_casc...
  143.                                    );
  144.         pus_extm   = uicontrol(...
  145.                                    'Style','Pushbutton',...
  146.                                    'Unit',win_units,...
  147.                                    'Position',pos_extm,...
  148.                                    'String',str_extm,...
  149.                                    'Callback',cba_extm...
  150.                                    );
  151.         pus_close  = uicontrol(...
  152.                                    'Style','Pushbutton',...
  153.                                    'Unit',win_units,...
  154.                                    'Position',pos_close,...
  155.                                    'String',str_close,...
  156.                                    'Callback',cba_close,...
  157.                                    'Tag',tag_btn_close...
  158.                                    );
  159.         % Prevent OS closing.
  160.         %--------------------
  161.         set(win_democmdm,'CloseRequestFcn',cba_close)
  162.         % Setting units to normalized.
  163.         %-----------------------------
  164.         set(findobj(win_democmdm,'Units','pixels'),'Units','Normalized');
  165.         % Hide figure handle.
  166.         %-------------------
  167.         hidegui(win_democmdm,'off');
  168.         % End waiting.
  169.         %---------------
  170.         mousefrm(0,'arrow');
  171.         drawnow
  172.     case 'enable'
  173.         %*************************************************************%
  174.         %** OPTION = 'enable' - Deseable or Enable democmdm window  **%
  175.         %*************************************************************%
  176.         % in2 = win handle
  177.         % in3 = 'on' or 'off'   
  178.         %--------------------
  179.         if in3(1:2)=='of'
  180.             mousefrm(0,'watch');
  181.         else
  182.             mousefrm(0,'arrow');
  183.         end
  184.         set(findobj(in2,'style','pushbutton'),'Enable',in3);
  185.         drawnow;
  186.     case {'dw1d','cw1d','dw2d','comp','deno','wpck','mala','casc','extm'}
  187.         %*****************************************************%
  188.         %** OPTION = 'dw1d' -  demo DW1D                    **%
  189.         %** OPTION = 'cw1d' -  demo CW1D                    **%
  190.         %** OPTION = 'dw2d' -  demo DW2D                    **%
  191.         %** OPTION = 'comp' -  demo Compression             **%
  192.         %** OPTION = 'deno' -  demo De-noising              **%
  193.         %** OPTION = 'wpck' -  demo for Wavelet packets     **%
  194.         %** OPTION = 'mala' -  demo for Mallat algorithm    **%
  195.         %** OPTION = 'casc' -  demo for Cascade algorithm   **%
  196.         %** OPTION = 'extm' -  demo for Boundary distortion **%
  197.         %*****************************************************%
  198.         expo_flag = 0;
  199.         if nargin==1
  200.             win = wfindobj('figure','tag',tag_cmdm_tool);
  201.         else
  202.             win = in2;
  203. if isempty(win) , expo_flag = 1; end
  204.         end
  205.         if ishandle(win) , democmdm('enable',win,'off'); end
  206.         demoname = ['dcmd' option];
  207. addclose = [mfilename '(''endshow'');'];
  208. if expo_flag
  209. addclose = [addclose 'mextglob(''clear''); wtbxmngr(''clear'');'];
  210. end
  211. fig = wshowdrv(demoname,addclose,tag_sub_close);
  212. if nargout>0 , out1 = fig; end
  213. mousefrm(0,'arrow');
  214.     case {'auto','gr_auto'}
  215.         %************************************%
  216.         %** OPTION = 'auto' and 'gr_auto'  **%
  217. %** All demos inautomatic modes.   **%
  218.         %************************************%
  219. lstDEMOS = {'dw1d','cw1d','dw2d','comp','deno','wpck','mala','casc','extm'};
  220.         win = democmdm('create');
  221. democmdm('enable',win,'off');
  222. stop = 0;
  223.         while stop==0
  224. for k=1:length(lstDEMOS)
  225. feval(['dcmd',lstDEMOS{k}],option);
  226. if ~ishandle(win) , stop = 1; break; end
  227. end
  228.             if ~isequal(stop,1) & nargin==2 & isequal(in2,'loop')
  229. stop = 0 ;
  230. else
  231. stop = 1;
  232. end
  233.         end
  234.         democmdm('close',win);
  235.     case 'loop'
  236.         %************************************************************%
  237.         %** OPTION = 'loop' - loop with all demos (automatic mode) **%
  238.         %************************************************************%
  239.         democmdm('auto','loop');
  240. case 'endshow'
  241.         %**************************************************%
  242.         %** OPTION = 'endshow' - used to finish wshowdrv **%
  243.         %**************************************************%
  244.         win = wfindobj('figure','tag',tag_cmdm_tool);
  245.         set(findobj(win,'style','pushbutton'),'Enable','on');
  246.         drawnow;
  247.     case 'close'
  248.         %***********************************************%
  249.         %** OPTION = 'close' - close democmdm window  **%
  250.         %***********************************************%
  251.         mousefrm(0,'watch')
  252.         if nargin==2
  253.             win_democmdm = in2;
  254.         else
  255.             win_democmdm = wfindobj('figure','tag',tag_cmdm_tool);
  256.         end
  257.         % Closing all opened main analysis windows.
  258.         %------------------------------------------
  259.         pus_handles = wfindobj(0,'Style','pushbutton');
  260.         hdls        = findobj(pus_handles,'flat','Tag',tag_sub_close);
  261.         for i=1:length(hdls)
  262.             hdl = hdls(i);
  263.             try
  264.               par = get(hdl,'Parent');
  265.               try
  266.                 eval(get(hdl,'Callback'));
  267.               end
  268.               delete(par);
  269.             end
  270.         end
  271.         % Closing the democmdm window.
  272.         %-----------------------------
  273.         try , delete(win_democmdm); end
  274.         win_ini = wfindobj('figure','tag',tag_dem_tool);
  275.         if ~isempty(win_ini)
  276.             pus_handles = findobj(win_ini,'Style','pushbutton');
  277.             set(pus_handles,'Enable','on');
  278.         else
  279.             mextglob('clear')
  280.             wtbxmngr('clear')
  281.         end
  282.         mousefrm(0,'arrow');
  283.     otherwise
  284.         errargt(mfilename,'Unknown Option','msg');
  285.         error('*');
  286. end