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

波变换

开发平台:

Matlab

  1. function [out1,out2] = dw1dcfsm(option,win_dw1dtool,in3,in4,in5)
  2. %DW1DCFSM Discrete wavelet 1-D show and scroll (stemcfs) mode manager.
  3. %   [OUT1,OUT2] = DW1DCFSM(OPTION,WIN_DW1DTOOL,IN3,IN4,IN5)
  4. %   M. Misiti, Y. Misiti, G. Oppenheim, J.M. Poggi 12-Mar-96.
  5. %   Last Revision: 18-May-2003.
  6. %   Copyright 1995-2004 The MathWorks, Inc.
  7. %   $Revision: 1.10.4.2 $  $Date: 2004/03/15 22:40:13 $
  8. % MemBloc1 of stored values.
  9. %---------------------------
  10. n_param_anal   = 'DWAn1d_Par_Anal';
  11. ind_sig_name   = 1;
  12. ind_sig_size   = 2;
  13. ind_wav_name   = 3;
  14. ind_lev_anal   = 4;
  15. ind_axe_ref    = 5;
  16. ind_act_option = 6;
  17. ind_ssig_type  = 7;
  18. ind_thr_val    = 8;
  19. nb1_stored     = 8;
  20. % MemBloc2 of stored values.
  21. %---------------------------
  22. n_coefs_longs  = 'Coefs_and_Longs';
  23. ind_coefs      = 1;
  24. ind_longs      = 2;
  25. nb2_stored     = 2;
  26. % MemBloc4 of stored values.
  27. %---------------------------
  28. n_miscella     = 'DWAn1d_Miscella';
  29. ind_graph_area =  1;
  30. ind_view_mode  =  2;
  31. ind_savepath   =  3;
  32. nb4_stored     =  3;
  33. % Tag property of objects.
  34. %-------------------------
  35. tag_valapp_scr = 'ValApp_Scr';
  36. tag_txtapp_scr = 'TxtApp_Scr';
  37. tag_valdet_scr = 'ValDet_Scr';
  38. tag_txtdet_scr = 'TxtDet_Scr';
  39. tag_axeappCfs  = 'Axe_AppCfs';
  40. tag_axedetCfs  = 'Axe_DetCfs';
  41. tag_axecfsCfs  = 'Axe_CfsCfs';
  42. tag_s_inapp    = 'Sig_in_App';
  43. tag_ss_inapp   = 'SSig_in_App';
  44. tag_s_indet    = 'Sig_in_Det';
  45. tag_ss_indet   = 'SSig_in_Det';
  46. tag_app        = 'App';
  47. tag_det        = 'Det';
  48. tag_stem       = 'Stems';
  49. children    = get(win_dw1dtool,'Children');
  50. axe_handles = findobj(children,'flat','type','axes');
  51. uic_handles = findobj(children,'flat','type','uicontrol');
  52. txt_handles = findobj(uic_handles,'Style','text');
  53. pop_handles = findobj(uic_handles,'Style','popupmenu');
  54. axe_app_ini = findobj(axe_handles,'flat','Tag',tag_axeappCfs);
  55. axe_det_ini = findobj(axe_handles,'flat','Tag',tag_axedetCfs);
  56. axe_cfs_ini = findobj(axe_handles,'flat','Tag',tag_axecfsCfs);
  57. switch option
  58.     case 'app'
  59.         pop = findobj(pop_handles,'Tag',tag_valapp_scr);
  60.         num = get(pop,'Value');
  61.         old = findobj(axe_app_ini,'Tag',tag_app);
  62.         if ~isempty(old)
  63.             hdl_line = findobj(old,'Userdata',num);
  64.             if ~isempty(hdl_line)
  65.                 ii = find(old==hdl_line);
  66.                 old(ii) = [];
  67.                 num = 0;
  68.                 try , delete(old); end
  69.                 return
  70.             end
  71.         end
  72.         % Begin waiting.
  73.         %---------------
  74.         wwaiting('msg',win_dw1dtool,'Wait ... computing');
  75.         try , delete(old); end
  76.         x = dw1dfile('app',win_dw1dtool,num);
  77.         Level_Anal = wmemtool('rmb',win_dw1dtool,n_param_anal,...
  78.                                                 ind_lev_anal);
  79.         axes(axe_app_ini);
  80.         col_app = wtbutils('colors','app',Level_Anal);
  81.         line('Parent',axe_app_ini,'Xdata',[1:length(x)],'Ydata',x,...
  82.                 'Color',col_app(num,:),'Tag',tag_app,'Userdata',num);
  83.         str_tit = get(get(axe_app_ini,'title'),'String');
  84.         ind = findstr(str_tit,'level');
  85.         str_tit = [str_tit(1:ind+5) sprintf('%.0f',num)];
  86.         wtitle(str_tit,'Parent',axe_app_ini);
  87.         % End waiting.
  88.         %-------------
  89.         wwaiting('off',win_dw1dtool);
  90.     case 'det'
  91.         pop = findobj(pop_handles,'Tag',tag_valdet_scr);
  92.         num = get(pop,'Value');
  93.         old = findobj(axe_det_ini,'Tag',tag_det);
  94.         if ~isempty(old)
  95.             hdl_line = findobj(old,'Userdata',num);
  96.             if ~isempty(hdl_line)
  97.                 ii = find(old==hdl_line);
  98.                 old(ii) = [];
  99.                 num = 0;
  100.                 try , delete(old); end
  101.                 return
  102.             end
  103.         end
  104.         % Begin waiting.
  105.         %---------------
  106.         wwaiting('msg',win_dw1dtool,'Wait ... computing');
  107.         try , delete(old); end
  108.         ll = findobj(axe_det_ini,'type','line','Visible','On');
  109.         if isempty(ll)
  110.             [x,set_ylim,ymin,ymax] = dw1dfile('det',win_dw1dtool,num,1);
  111.         else
  112.             set_ylim = 0;
  113.             x = dw1dfile('det',win_dw1dtool,num);
  114.         end
  115.         Level_Anal = wmemtool('rmb',win_dw1dtool,n_param_anal,ind_lev_anal);
  116.         axes(axe_det_ini);
  117.         col_det = wtbutils('colors','det',Level_Anal);
  118.         line('Parent',axe_det_ini,'Xdata',[1:length(x)],'Ydata',x,...
  119.                 'Color',col_det(num,:),'Tag',tag_det,'Userdata',num);
  120.         if set_ylim , set(axe_det_ini,'Ylim',[ymin,ymax]); end
  121.         str_tit = get(get(axe_det_ini,'title'),'String');
  122.         ind = findstr(str_tit,'level');
  123.         str_tit = [str_tit(1:ind+5) sprintf('%.0f',num)];
  124.         wtitle(str_tit,'Parent',axe_det_ini);
  125.         % End waiting.
  126.         %-------------
  127.         wwaiting('off',win_dw1dtool);
  128.     case 'plot_sig'
  129.         % in3 = signal
  130.         % in4 = display mode
  131.         % in5 = sig  visibility  
  132.         %----------------------
  133.         if      nargin==3 , in4 = 6; in5 = 1;
  134.         elseif  nargin==4 , in5 = 1; 
  135.         end
  136.         if in4==6 , v = 1; else , v = 0; end
  137.         axe_hdl = dw1dcfsm('axes',win_dw1dtool,[1 1 1],1);
  138.         vsig = getonoff(in5);
  139.         set(axe_hdl(1),'Visible',vsig);
  140.         set(axe_hdl(2:3),'Visible',getonoff(v));
  141.         % Drawing.
  142.         %---------
  143.         axeAct  = axe_hdl(1);
  144.         axes(axeAct);
  145.         wtitle('Loaded Signal','Parent',axeAct);
  146.         col_s   = wtbutils('colors','sig');
  147.         line('Parent',axeAct,'Xdata',[1:length(in3)],'Ydata',in3,...
  148.                 'Color',col_s,'Visible',vsig,'Tag',tag_s_inapp);
  149.         axeAct  = axe_hdl(2);
  150.         axes(axeAct);
  151.         xmin = 1;               xmax = length(in3);
  152.         ymin = min(in3)-eps;    ymax = max(in3)+eps;
  153.         line('Parent',axeAct,'Xdata',[xmin:xmax],'Ydata',in3,...
  154.                 'Color',col_s,'Visible','Off','Tag',tag_s_indet);
  155.         set(axe_hdl(1:3),'Xlim',[xmin xmax],'Ylim',[ymin ymax]);
  156.     case 'plot_anal'
  157.         lin_handles     = findobj(axe_handles,'Type','line');
  158.         ss_in_app       = findobj(lin_handles,'Tag',tag_ss_inapp);
  159.         if isempty(ss_in_app)
  160.                 col_ss  = wtbutils('colors','ssig');
  161.                 ss_rec  = dw1dfile('ssig',win_dw1dtool);
  162.                 axes(axe_app_ini);
  163.                 line(...
  164.                         'Parent',axe_app_ini, ...
  165.                         'Xdata',[1:length(ss_rec)],'Ydata',ss_rec, ...
  166.                         'Zdata',2*ones(size(ss_rec)),...
  167.                         'Color',col_ss,'Visible','Off','Tag',tag_ss_inapp);
  168.                 axes(axe_det_ini);
  169.                 line(...
  170.                         'Parent',axe_det_ini, ...
  171.                         'Xdata',[1:length(ss_rec)],'Ydata',ss_rec, ...
  172.                         'Zdata',2*ones(size(ss_rec)), ...
  173.                         'Color',col_ss,'Visible','Off','Tag',tag_ss_indet);
  174.                 clear ss_rec
  175.         end
  176.         Level_Anal = wmemtool('rmb',win_dw1dtool,n_param_anal,ind_lev_anal);
  177.         axes(axe_app_ini);
  178.         [app_rec,set_ylim,ymin,ymax] = dw1dfile('app',win_dw1dtool,1,1);
  179.         ylim = get(axe_app_ini,'Ylim');
  180.         if ylim(1)<ymin , ymin = ylim(1); end
  181.         if ylim(2)>ymax , ymax = ylim(2); end
  182.         col_app = wtbutils('colors','app',Level_Anal);
  183.         line(...
  184.                 'Parent',axe_app_ini,...
  185.                 'Xdata',[1:length(app_rec)],'Ydata',app_rec,...
  186.                 'Color',col_app(1,:),'Tag',tag_app,'Userdata',1);
  187.         wtitle(sprintf('Signal and Approximation at level %.0f',1),...
  188.                 'Parent',axe_app_ini)
  189.         set(axe_app_ini,'Ylim',[ymin,ymax]);
  190.         clear app_rec
  191.         axes(axe_det_ini);
  192.         [det_rec,set_ylim,ymin,ymax] = dw1dfile('det',win_dw1dtool,1,1);
  193.         col_det = wtbutils('colors','det',Level_Anal);
  194.         line(...
  195.                 'Parent',axe_det_ini,...
  196.                 'Xdata',[1:length(det_rec)],'Ydata',det_rec,...
  197.                 'Color',col_det(1,:),'Tag',tag_det,'Userdata',1);
  198.         if set_ylim , set(axe_det_ini,'Ylim',[ymin,ymax]); end
  199.         wtitle(sprintf('Detail at level %.0f',1),...
  200.                 'Parent',axe_det_ini)
  201.         clear det_rec
  202.         [coefs,longs] = wmemtool('rmb',win_dw1dtool,...
  203.                                        n_coefs_longs,ind_coefs,ind_longs);
  204.         axes(axe_cfs_ini);
  205.         levlab  = flipud(int2str([1:Level_Anal]'));
  206.         set(axe_cfs_ini,'YTicklabelMode','manual',...
  207.                         'YTick',[1:Level_Anal], ...
  208.                         'YTickLabel',levlab,      ...
  209.                         'Tag',tag_axecfsCfs       ...
  210.                         );
  211.         wtitle('Details Coefficients','Parent',axe_cfs_ini);
  212.         wylabel('Level number','Parent',axe_cfs_ini)
  213.         clear dec_cfs
  214.         % Reference axes used by stat. & histo & ...
  215.         %-------------------------------------------
  216.         wmemtool('wmb',win_dw1dtool,n_param_anal,ind_axe_ref,axe_app_ini);
  217.         % Axes attachment.
  218.         %-----------------
  219.         dw1dcfsm('dynv',win_dw1dtool);
  220.     case 'plot_cfs'
  221.         % in3 = display mode
  222.         %------------------
  223.         if nargin==2 , in3 = 1; end
  224.         if in3==6 , v = 1; else , v = 0; end
  225.         v = 0;  % force l'affichage des coefficients
  226.         axe_hdl = dw1dcfsm('axes',win_dw1dtool,[1 v 1],1);
  227.         set(axe_hdl(2),'Visible',getonoff(v));
  228.         set(axe_hdl(1,3),'Visible','On');
  229.         Signal_Size = wmemtool('rmb',win_dw1dtool,n_param_anal,ind_sig_size);
  230.         xmin = 1;       xmax = Signal_Size;
  231.         ta3 = 'Loaded Details Coefficients (Colored)';
  232.         if v
  233.             set(axe_hdl(1:3),'Xlim',[xmin xmax]);
  234.         else
  235.             [coefs,longs]   = wmemtool('rmb',win_dw1dtool,...
  236.                                             n_coefs_longs,ind_coefs,ind_longs);
  237.             coefs = coefs(longs(1)+1:end);
  238.             longs = longs(2:end-1);
  239.             nbd   = length(longs);
  240.             ymin = min(coefs);
  241.             ymax = max(coefs);
  242.             if ymin==ymax , dy = 0.001; else ,dy = (ymax-ymin)/20; end
  243.             ymin = ymin-dy; ymax = ymax+dy;
  244.             axe_act = axe_hdl(1);
  245.             set(axe_act,'Xlim',[1 length(coefs)],'Ylim',[ymin ymax]);
  246.             axes(axe_act);
  247.             wtitle(['Loaded Details Coefficients from level '...
  248.                      sprintf('%.0f',nbd) ' to level 1.'],'Parent',axe_act);
  249.             line('Parent',axe_act,'Xdata',[1:length(coefs)],'Ydata',coefs, ...
  250.                  'Color',wtbutils('colors','coefs'));
  251.             x = 0;
  252.             linCOL = wtbutils('colors','dw1d','sepcfs');
  253.             for k = 1:nbd-1
  254.                 x = x+longs(k);
  255.                 line('Parent',axe_act,'Xdata',[x x],'Ydata',[ymin ymax], ...
  256.                      'Color',linCOL);
  257.             end
  258.             drawnow
  259.             set(axe_hdl(2:3),'Xlim',[xmin xmax]);
  260.         end
  261.         axe_act = axe_hdl(3);
  262.         axes(axe_act);
  263.         [det_cfs,xlim1,xlim2,ylim2,ylim1,nb_cla,levs,ccfs_vm] = ...
  264.                                 dw1dmisc('col_cfs',win_dw1dtool);
  265.         levlab  = flipud(int2str(levs(:)));
  266.         wtitle(ta3,'Parent',axe_act);
  267.         wylabel('Level number','Parent',axe_act)
  268.         set(axe_act,'YTicklabelMode','manual',   ...
  269.                         'YTick',[1:length(levs)],...
  270.                         'YTickLabel',levlab,     ...
  271.                         'Tag',tag_axecfsCfs      ...
  272.                         );
  273.         if v==0
  274.             set(axe_hdl(1),'Xlim',[1 length(coefs)],'Ylim',[ymin ymax]);
  275.         end
  276.     case 'plot_synt'
  277.         % Getting  Synthesis parameters.
  278.         %------------------------------
  279.         Level_Anal = wmemtool('rmb',win_dw1dtool,n_param_anal,ind_lev_anal);
  280.         % Computing Decomposition.
  281.         %-------------------------
  282.         col_s   = wtbutils('colors','sig');
  283.         col_ss  = wtbutils('colors','ssig');
  284.         col_app = wtbutils('colors','app',Level_Anal);
  285.         col_det = wtbutils('colors','det',Level_Anal);
  286.         delete(get(axe_app_ini,'Children'));
  287.         axe_hdl = dw1dcfsm('axes',win_dw1dtool,[1 1 1],0);
  288.         set(axe_hdl,'Visible','On');
  289.         axes(axe_app_ini);
  290.         sig_rec = dw1dfile('sig',win_dw1dtool);
  291.         line(...
  292.                 'Parent',axe_app_ini,...
  293.                 'Xdata',[1:length(sig_rec)],'Ydata',sig_rec,...
  294.                 'Color',col_s,'Tag',tag_s_inapp);
  295.         line(...
  296.                 'Parent',axe_app_ini,...
  297.                 'Xdata',[1:length(sig_rec)],'Ydata',sig_rec,'Zdata',2*ones(size(sig_rec)),...
  298.                 'Color',col_ss,'Visible','Off','Tag',tag_ss_inapp);
  299.         app_rec = dw1dfile('app',win_dw1dtool,1);
  300.         line(...
  301.                 'Parent',axe_app_ini,...
  302.                 'Xdata',[1:length(app_rec)],'Ydata',app_rec,...
  303.                 'Color',col_app(1,:),'Tag',tag_app,'Userdata',1);
  304.         wtitle(sprintf('Original Synthesized Signal and Approximation at level %.0f',1),...
  305.                         'Parent',axe_app_ini)
  306.         clear app_rec
  307.         axes(axe_det_ini);
  308.         [det_rec,set_ylim,ymin,ymax] = dw1dfile('det',win_dw1dtool,1,1);
  309.         line(...
  310.                 'Parent',axe_det_ini,...
  311.                 'Xdata',[1:length(sig_rec)],'Ydata',sig_rec,...
  312.                 'Color',col_s,'Visible','Off','Tag',tag_s_indet);
  313.         line(...
  314.                 'Parent',axe_det_ini,...
  315.                 'Xdata',[1:length(sig_rec)],'Ydata',sig_rec,'Zdata',2*ones(size(sig_rec)),...
  316.                 'Color',col_ss,'Visible','Off','Tag',tag_ss_indet);
  317.         line(...
  318.                 'Parent',axe_det_ini,...
  319.                 'Xdata',[1:length(det_rec)],'Ydata',det_rec,...
  320.                 'Color',col_det(1,:),'Tag',tag_det,'Userdata',1);
  321.         if set_ylim , set(axe_det_ini,'Ylim',[ymin ymax]); end
  322.         wtitle(sprintf('Detail at level %.0f',1),'Parent',axe_det_ini)
  323.         axes(axe_cfs_ini);
  324.         wtitle('Details Coefficients','Parent',axe_cfs_ini);
  325.         wylabel('Level number','Parent',axe_cfs_ini);
  326.         % Reference axes used by stat. & histo & ...
  327.         %-------------------------------------------
  328.         wmemtool('wmb',win_dw1dtool,n_param_anal,ind_axe_ref,axe_app_ini);
  329.         % Axes attachment.
  330.         %-----------------
  331.         dw1dcfsm('dynv',win_dw1dtool);
  332.     case 'view'
  333.         % in3 = old_mode or ...
  334.         % in3 = -1 : same mode
  335.         % in3 =  0 : clean
  336.         %-------------------------
  337.         old_mode = in3;
  338.         [flg_axe,flg_sa,flg_app,flg_sd,flg_det,abscfs_m] = ...
  339.                                 dw1dvmod('get_vm',win_dw1dtool,6);
  340.         v_flg = [flg_sa , flg_app , flg_sd , flg_det , flg_axe(3)];
  341.         if flg_axe(1)== 0 , v_flg(1:3) = zeros(1,3); end
  342.         if flg_axe(2)== 0 , v_flg(4:6) = zeros(1,3); end
  343.         if flg_axe(3)== 0 , v_flg(7)   = 0; end
  344.         pop_app   = findobj(pop_handles,'Tag',tag_valapp_scr);
  345.         lev_a     = get(pop_app,'Value');
  346.         pop_det   = findobj(pop_handles,'Tag',tag_valdet_scr);
  347.         lev_d     = get(pop_det,'Value');
  348.         vis_str   = getonoff(v_flg);
  349.         v_s_app   = vis_str(1,:);
  350.         v_ss_app  = vis_str(2,:);
  351.         v_app     = vis_str(3,:);
  352.         v_s_det   = vis_str(4,:);
  353.         v_ss_det  = vis_str(5,:);
  354.         v_det     = vis_str(6,:);
  355.         v_cfs     = vis_str(7,:);
  356.         axe_hdl     = dw1dcfsm('axes',win_dw1dtool,flg_axe);
  357.         lin_handles = findobj(axe_hdl,'Type','line');
  358.         s_in_app    = findobj(lin_handles,'Tag',tag_s_inapp);
  359.         s_in_det    = findobj(lin_handles,'Tag',tag_s_indet);
  360.         app         = findobj(lin_handles,'Tag',tag_app,'Userdata',lev_a);
  361.         ss_in_app   = findobj(lin_handles,'Tag',tag_ss_inapp);
  362.         ss_in_det   = findobj(lin_handles,'Tag',tag_ss_indet);
  363.         det         = findobj(lin_handles,'Tag',tag_det,'Userdata',lev_d);
  364.         [Wave_Name,opt_act,Level_Anal,ss_type] = ...
  365.                 wmemtool('rmb',win_dw1dtool,n_param_anal,...
  366.                           ind_wav_name,ind_act_option,ind_lev_anal,...
  367.                                                       ind_ssig_type);
  368.         if      ss_type=='ss', str_ss = 'Synthesized Signal';
  369.         elseif  ss_type=='ds', str_ss = 'De-noised Signal';
  370.         elseif  ss_type=='cs', str_ss = 'Compressed Signal';
  371.         end
  372.         if strcmp(opt_act,'synt')
  373.             ini_str = 'Orig. Synt. Sig.';
  374.         else
  375.             ini_str = 'Signal';
  376.         end
  377.         if v_flg(1)==1
  378.             if v_flg(2)==1
  379.                 str_tit = [ini_str ', ' str_ss ' and']; 
  380.             else    
  381.                 str_tit = [ini_str ' and'];     
  382.             end
  383.         else
  384.             if v_flg(2)==1
  385.                 str_tit = [str_ss ' and'];      
  386.             else    
  387.                 str_tit = '';   
  388.             end
  389.         end
  390.         axes(axe_hdl(1));
  391.         wtitle([ str_tit ' Approximation at level ' sprintf('%.0f',lev_a)],...
  392.                 'Parent',axe_hdl(1));
  393.         if v_flg(4)==1
  394.             if v_flg(5)==1
  395.                 str_tit = [ini_str ', ' str_ss ' and']; 
  396.             else    
  397.                 str_tit = [ini_str ' and'];     
  398.             end
  399.         else
  400.             if v_flg(5)==1
  401.                 str_tit = [str_ss ' and'];      
  402.             else    
  403.                 str_tit = '';   
  404.             end
  405.         end
  406.         axes(axe_hdl(2));
  407.         wtitle([ str_tit ' Detail at level ' sprintf('%.0f',lev_d)],...
  408.                 'Parent',axe_hdl(2));
  409.         if isempty(s_in_app)
  410.             x = dw1dfile('sig',win_dw1dtool);
  411.             xmin = 1;               xmax = length(x);
  412.             ymin = min(x)-eps;      ymax = max(x)+eps;
  413.             set(axe_hdl(1:3),'Xlim',[xmin xmax]);
  414.             col_s = wtbutils('colors','sig');
  415.             axes(axe_hdl(1));
  416.             line(...
  417.                     'Parent',axe_hdl(1),...
  418.                     'Xdata',[xmin:xmax],'Ydata',x,...
  419.                     'Color',col_s,'Visible',v_s_app,'Tag',tag_s_inapp);
  420.             axes(axe_hdl(2));
  421.             line(...
  422.                     'Parent',axe_hdl(2),...
  423.                     'Xdata',[xmin:xmax],'Ydata',x,...
  424.                     'Color',col_s,'Visible',v_s_det,'Tag',tag_s_indet);
  425.         else
  426.             set(s_in_app,'Visible',v_s_app);
  427.             set(s_in_det,'Visible',v_s_det);
  428.         end
  429.         if isempty(ss_in_app)
  430.             x = dw1dfile('ssig',win_dw1dtool);
  431.             col_ss  = wtbutils('colors','ssig');
  432.             axes(axe_hdl(1));
  433.             line(...
  434.                     'Parent',axe_hdl(1),...
  435.                     'Xdata',[1:length(x)],'Ydata',x,'Zdata',2*ones(size(x)),...
  436.                     'Color',col_ss,'Visible',v_ss_app,'Tag',tag_ss_inapp);
  437.             axes(axe_hdl(2));
  438.             line(...
  439.                     'Parent',axe_hdl(2),...
  440.                     'Xdata',[1:length(x)],'Ydata',x,'Zdata',2*ones(size(x)),...
  441.                     'Color',col_ss,'Visible',v_ss_det,'Tag',tag_ss_indet);
  442.         else
  443.             set(ss_in_app,'Visible',v_ss_app);
  444.             set(ss_in_det,'Visible',v_ss_det);
  445.         end
  446.         if isempty(app)
  447.             x = dw1dfile('app',win_dw1dtool,lev_a);
  448.             col_app = wtbutils('colors','app',Level_Anal);
  449.             axes(axe_hdl(1));
  450.             line(...
  451.                     'Parent',axe_hdl(1),...
  452.                     'Xdata',[1:length(x)],'Ydata',x,...
  453.                     'Color',col_app(lev_a,:),'Visible',v_app, ...
  454.                     'Tag',tag_app,'Userdata',lev_a);
  455.         else
  456.             set(app,'Visible',v_app);
  457.         end
  458.         if isempty(det)
  459.             ll = findobj([s_in_det,ss_in_det], 'Visible','on');
  460.             if isempty(ll)
  461.                 [x,set_ylim,ymin,ymax] = dw1dfile('det',win_dw1dtool,lev_d,1);
  462.             else
  463.                 set_ylim = 0;
  464.                 x = dw1dfile('det',win_dw1dtool,lev_d);
  465.             end
  466.             axes(axe_hdl(2));
  467.             col_det = wtbutils('colors','det',Level_Anal);
  468.             line(...
  469.                     'Parent',axe_hdl(2),...
  470.                     'Xdata',[1:length(x)],'Ydata',x,...
  471.                     'Color',col_det(lev_d,:),'Visible',v_det, ...
  472.                     'Tag',tag_det,'Userdata',lev_d);
  473.             if set_ylim , set(axe_hdl(2),'Ylim',[ymin,ymax]); end
  474.         else
  475.             set(det,'Visible',v_det);
  476.         end
  477.         axe_act = axe_hdl(3);
  478.         axes(axe_act);
  479.         abscfs_m = rem(abscfs_m,2);
  480.         hdl_stem = findobj(axe_act,'tag',tag_stem);
  481.         if isempty(hdl_stem)
  482.             okStem = 1;
  483.         else
  484.             old_abscfs_m = get(hdl_stem(1),'Userdata');
  485.             okStem = ~isequal(old_abscfs_m,abscfs_m);
  486.         end
  487.         if okStem
  488.             [coefs,longs] = wmemtool('rmb',win_dw1dtool,...
  489.                                        n_coefs_longs,ind_coefs,ind_longs);
  490.             hdl_stem = dw1dstem(axe_act,coefs,longs,...
  491.                                 'mode',abscfs_m,'colors','WTBX');
  492.             hdl_stem = hdl_stem(ishandle(hdl_stem));
  493.             set(hdl_stem,'Userdata',abscfs_m,'tag',tag_stem);
  494.         end
  495.         set(hdl_stem,'Visible',v_cfs);
  496.         levlab = int2str([1:Level_Anal]');
  497.         set(axe_act,...
  498.                     'clipping','on',            ...
  499.                     'YTicklabelMode','manual',  ...
  500.                     'YTick',[1:Level_Anal],     ...
  501.                     'YTickLabel',levlab,        ...
  502.                     'Ylim',[0.5 Level_Anal+0.5],...
  503.                     'Visible',v_cfs,            ...
  504.                     'Tag',tag_axecfsCfs         ...
  505.                     );
  506.         wylabel('Level number','Parent',axe_act);
  507.         wtitle('Details Coefficients','Parent',axe_act);
  508.         % Axes attachment.
  509.         %-----------------
  510.         dw1dcfsm('dynv',win_dw1dtool,old_mode);
  511.         % Reference axes used by stat. & histo & ...
  512.         %-------------------------------------------
  513.         wmemtool('wmb',win_dw1dtool,n_param_anal,ind_axe_ref,axe_hdl(1));
  514.     case 'dynv'
  515.         % in3 = -1 : same mode
  516.         % in3 =  0 : clean 
  517.         %--------------------
  518.         % Axes attachment.
  519.         %-----------------
  520.         if nargin==2 , in3 = 0; end
  521.         okNew = dw1dvdrv('test_mode',win_dw1dtool,'cfs',in3);
  522.         if okNew
  523.             dynvtool('get',win_dw1dtool,0,'force');
  524.             Level_Anal = wmemtool('rmb',win_dw1dtool,n_param_anal,...
  525.                                                 ind_lev_anal);
  526.             dynvtool('init',win_dw1dtool,...
  527.                       [],[axe_app_ini axe_det_ini,axe_cfs_ini],[],[1 0], ...
  528.                       '','','dw1dcoor',[win_dw1dtool,axe_cfs_ini,-Level_Anal]);
  529.         end
  530.     case 'axes'
  531.         % in3 flag for axes visibility
  532.         % in4 flag for clearing axes
  533.         % in4 = 1 , clear axes.
  534.         %---------------------------
  535.         switch nargin
  536.             case 2 , flg_axe = [1 1 1]; clear_axes = 1;
  537.             case 3 , flg_axe = in3;     clear_axes = 0;
  538.             case 4 , flg_axe = in3;     clear_axes = in4;
  539.         end
  540.         % Axes Positions.
  541.         %----------------
  542.         nb_axes = sum(flg_axe);
  543.         pos_graph = wmemtool('rmb',win_dw1dtool,n_miscella,ind_graph_area);
  544.         pos_win = get(win_dw1dtool,'Position');
  545.         bdx     = 0.06*pos_win(3);
  546.         bdy     = 0.08*pos_win(4);
  547.         bdy0    = 0.04*pos_win(4);
  548.         bdy1    = 0.04*pos_win(4);
  549.         bdy2    = 0.06*pos_win(4);
  550.         %--------------------- Scale of Colors Axes ----------------------%
  551.         h_col   = 0.02*pos_win(4);
  552.         w_col   = pos_graph(3)/3;
  553.         x_col   = pos_graph(1)+w_col;
  554.         y_col   = pos_graph(2)+bdy0;
  555.         pos_ax      = zeros(4,4);
  556.         pos_ax(4,:) = [x_col , y_col , w_col , h_col];
  557.         %-----------------------------------------------------------------%
  558.         if nb_axes==0 , nb_axes = 3 ;end
  559.         xleft = pos_graph(1)+bdx;
  560.         width = pos_graph(3)-2*bdx;
  561.         hy = pos_graph(4)-(nb_axes-1)*bdy-bdy0-bdy2;
  562.         if flg_axe(3)==1
  563.             ylow        = y_col+h_col+bdy1;
  564.             height      = (hy-bdy1-h_col)/nb_axes;
  565.             pos_ax(3,:) = [xleft , ylow , width , height];
  566.             ylow = ylow+height+bdy;
  567.         else
  568.             ylow = pos_graph(2)+bdy0;
  569.             height  = hy/nb_axes;
  570.         end
  571.         if flg_axe(2)==1
  572.             pos_ax(2,:) = [xleft , ylow , width , height];
  573.             ylow = ylow+height+bdy;
  574.         end
  575.         if flg_axe(1)==1
  576.             pos_ax(1,:) = [xleft , ylow , width , height];      
  577.         end
  578.         axe_hdl = findobj(axe_handles,'flat','Tag',tag_axeappCfs);
  579.         if ~isempty(axe_hdl)
  580.             out1(1) = axe_hdl;
  581.             out1(2) = findobj(axe_handles,'flat','Tag',tag_axedetCfs);
  582.             out1(3) = findobj(axe_handles,'flat','Tag',tag_axecfsCfs);
  583.             if clear_axes , cleanaxe(out1) ; end             
  584.         else
  585.             if ~isequal(get(0,'CurrentFigure'),win_dw1dtool)
  586.                 figure(win_dw1dtool);
  587.             end
  588.             win_units = get(win_dw1dtool,'Units');
  589.             out1(1) = axes(...
  590.                             'Parent',win_dw1dtool,  ...
  591.                             'Units',win_units,      ...
  592.                             'Visible','Off',        ...
  593.                             'DrawMode','Normal',    ...
  594.                             'box','on',             ...
  595.                             'NextPlot','Add',       ...
  596.                             'Tag',tag_axeappCfs     ...
  597.                             );
  598.             out1(2) = axes(...
  599.                             'Parent',win_dw1dtool,  ...
  600.                             'Units',win_units,      ...
  601.                             'Visible','Off',        ...
  602.                             'DrawMode','Normal',    ...
  603.                             'box','on',             ...
  604.                             'NextPlot','Add',       ...
  605.                             'Tag',tag_axedetCfs     ...
  606.                             );
  607.             out1(3) = axes(...
  608.                             'Parent',win_dw1dtool,  ...
  609.                             'Units',win_units,      ...
  610.                             'Visible','Off',        ...
  611.                             'DrawMode','Normal',    ...
  612.                             'box','on',             ...
  613.                             'NextPlot','Add',       ...
  614.                             'Tag',tag_axecfsCfs     ...
  615.                             );
  616.         end
  617.         flg_vis = flg_axe;
  618.         for k =1:3
  619.             if flg_vis(k)==0
  620.                 h = findobj(out1(k));
  621.                 set(h,'Visible','off');
  622.             else
  623.                 set(out1(k),'Visible','on','Position',pos_ax(k,:));
  624.             end
  625.         end
  626.     case 'del_ss'
  627.         lin_handles = findobj(axe_handles,'Type','line');
  628.         ss_app      = findobj(lin_handles,'Tag',tag_ss_inapp);
  629.         ss_det      = findobj(lin_handles,'Tag',tag_ss_indet);
  630.         delete([ss_app ss_det]);
  631.     case 'clear'
  632.         % in3 = 0 : clean 
  633.         %--------------------
  634.         new_mode = in3;
  635.         dynvtool('stop',win_dw1dtool);
  636.         out1 = findobj([axe_app_ini,axe_det_ini,axe_cfs_ini]);
  637.         delete(out1);
  638.     otherwise
  639.         errargt(mfilename,'Unknown Option','msg');
  640.         error('*');
  641. end