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

波变换

开发平台:

Matlab

  1. function [out1,out2,out3] = dw1dhist(option,in2,in3,in4,in5,in6,in7,in8)
  2. %DW1DHIST Discrete wavelet 1-D histograms.
  3. %   [OUT1,OUT2,OUT3] = DW1DHIST(OPTION,IN2,IN3,IN4,IN5,IN6,IN7,IN8)
  4. %   M. Misiti, Y. Misiti, G. Oppenheim, J.M. Poggi 12-Mar-96.
  5. %   Last Revision: 12-Dec-2000.
  6. %   Copyright 1995-2002 The MathWorks, Inc.
  7. %   $Revision: 1.20 $
  8. % Memory Blocks of stored values.
  9. %================================
  10. % MB1.
  11. %-----
  12. n_param_anal   = 'DWAn1d_Par_Anal';
  13. ind_sig_name   = 1;
  14. ind_sig_size   = 2;
  15. ind_wav_name   = 3;
  16. ind_lev_anal   = 4;
  17. ind_axe_ref    = 5;
  18. ind_act_option = 6;
  19. ind_ssig_type  = 7;
  20. ind_thr_val    = 8;
  21. nb1_stored     = 8;
  22. % MB2.
  23. %-----
  24. n_coefs_longs = 'Coefs_and_Longs';
  25. ind_coefs     = 1;
  26. ind_longs     = 2;
  27. nb2_stored    = 2;
  28. % MB4.
  29. %-----
  30. n_miscella     = 'DWAn1d_Miscella';
  31. ind_graph_area = 1;
  32. ind_view_mode  = 2;
  33. ind_savepath   = 3;
  34. nb4_stored     = 3;
  35. % MB1 (local).
  36. %-------------
  37. n_chk_lev_lst   = 'Chk_Lev_Lst';
  38. ind_Chk_App_Lst = 1;
  39. ind_Chk_Det_Lst = 2;
  40. nbLOC_1_stored  = 2;
  41. % Tag property of objects.
  42. %-------------------------
  43. tag_cmd_frame = 'Cmd_Frame';
  44. tag_orig_sig  = 'Orig_sig';
  45. tag_synt_sig  = 'Synt_sig';
  46. tag_app_sig   = 'App_sig';
  47. tag_det_sig   = 'Det_sig';
  48. tag_app_txt   = 'App_Txt';
  49. tag_app_all   = 'App_All';
  50. tag_app_none  = 'App_None';
  51. tag_det_txt   = 'Det_Txt';
  52. tag_det_all   = 'Det_All';
  53. tag_det_none  = 'Det_None';
  54. tag_sel_cfs   = 'Sel_Cfs';
  55. tag_sel_rec   = 'Sel_Rec';
  56. tag_bins_txt  = 'Bins_Txt';
  57. tag_bins_data = 'Bins_Data';
  58. tag_show_hist = 'Show_Hist';
  59. % Tag property of objects.
  60. %-------------------------
  61. tag_sephis_fra  = 'Dw1dhist_Level';
  62. tag_sigtype_txt = 'Dw1dhist_Sigtype';
  63. if ~isequal(option,'create') , win_dw1dhist = in2; end
  64. switch option
  65.     case 'create'
  66.         % Get Globals.
  67.         %-------------
  68.         [Def_Txt_Height,Def_Btn_Height,Def_Btn_Width,Pop_Min_Width, ...
  69.          X_Spacing,Y_Spacing,Def_EdiBkColor,Def_FraBkColor] = ...
  70.             mextglob('get',...
  71.                 'Def_Txt_Height','Def_Btn_Height', ...
  72.                 'Def_Btn_Width','Pop_Min_Width',   ...
  73.                 'X_Spacing','Y_Spacing','Def_EdiBkColor','Def_FraBkColor' ...
  74.                 );
  75.         % Calling figure.
  76.         %----------------
  77.         win_dw1dtool = in2;
  78.         str_win_dw1dtool = sprintf('%.0f',win_dw1dtool);
  79.         % Window initialization.
  80.         %----------------------
  81.         win_name = 'Wavelet 1-D  --  Histograms';
  82.         [win_dw1dhist,pos_win,win_units,str_numwin,...
  83.                 frame0,pos_frame0,Pos_Graphic_Area,pus_close] = ...
  84.                     wfigmngr('create',win_name,'','ExtFig_HistStat',mfilename,0);
  85.         out1 = win_dw1dhist;
  86.         % Begin waiting.
  87.         %---------------
  88.         set(wfindobj('figure'),'Pointer','watch');
  89.         % Getting variables from dw1dtool figure memory block.
  90.         %-----------------------------------------------------
  91.         [Sig_Name,Wav_Name,Lev_Anal,Sig_Size,Axe_Ref] = ...
  92.             wmemtool('rmb',win_dw1dtool,n_param_anal,   ...
  93.                            ind_sig_name,ind_wav_name,   ...
  94.                            ind_lev_anal,ind_sig_size,ind_axe_ref);
  95.         % General parameters initialization.
  96.         %-----------------------------------
  97.         dx = X_Spacing;  dx2 = 2*dx;
  98.         dy = Y_Spacing;  dy2 = 2*dy;
  99.         d_txt = (Def_Btn_Height-Def_Txt_Height);
  100.         x_frame0   = pos_frame0(1);
  101.         cmd_width  = pos_frame0(3);
  102.         push_width = (cmd_width-4*dx)/2;
  103.         txt_width  = Def_Btn_Width;
  104.         pop_width  = Pop_Min_Width;
  105.         nb_inline = 3;
  106.         nb_lines  = max(2,ceil(Lev_Anal/nb_inline))+1;
  107.         [h_sigs,btn_height,chk_height,hshow] = ...
  108.                 depOfMachine(Def_Btn_Height,Lev_Anal);
  109.         default_bins    = 30;
  110.         % Position property of objects.
  111.         %------------------------------
  112.         xlocINI    = pos_frame0([1 3]);
  113.         ybottomINI = pos_win(4)-3.5*Def_Btn_Height-dy2;
  114.         % Selection on signals.
  115.         y_low         = ybottomINI-dy2;
  116.         w_uic         = 7*push_width/4;
  117.         px            = x_frame0+(cmd_width-w_uic)/2;
  118.         pos_orig_sig  = [px, y_low-4*h_sigs/3, w_uic, h_sigs];
  119.         y_low         = pos_orig_sig(2)-4*h_sigs/3;
  120.         pos_synt_sig  = [px, y_low , w_uic, h_sigs];
  121.         y_low         = pos_synt_sig(2)-4*h_sigs/3;
  122.         pos_app_sig   = [px, y_low , w_uic, h_sigs];
  123.         y_low         = pos_app_sig(2)-4*h_sigs/3;
  124.         pos_det_sig   = [px, y_low , w_uic, h_sigs];
  125.         px            = x_frame0+(cmd_width-3*push_width/2)/2;
  126.         y_low         = pos_det_sig(2)-btn_height/2-Def_Btn_Height;
  127.         pos_app_txt   = [px , y_low+d_txt/2, 3*push_width/2, Def_Txt_Height];
  128.         nb            = nb_inline+1;
  129.         wx            = (cmd_width-nb*txt_width/2)/(nb+1);
  130.         y_low         = pos_app_txt(2)-6*btn_height/5;
  131.         pos_app_all   = [x_frame0+wx, y_low, txt_width/2, btn_height];
  132.         y_low         = pos_app_all(2)-6*btn_height/5;
  133.         pos_app_none  = [x_frame0+wx, y_low, txt_width/2, btn_height];
  134.         hx            = nb_lines*(6*btn_height/5);
  135.         y_low         = pos_app_txt(2)-d_txt/2-hx;
  136.         pos_det_txt   = [px , y_low+d_txt/2 , 3*push_width/2, Def_Txt_Height];
  137.         y_low         = pos_det_txt(2)-6*btn_height/5;
  138.         pos_det_all   = [x_frame0+wx, y_low, txt_width/2, btn_height];
  139.         y_low         = pos_det_all(2)-6*btn_height/5;
  140.         pos_det_none  = [x_frame0+wx, y_low, txt_width/2, btn_height];
  141.         px            = x_frame0+(cmd_width-5*push_width/4)/2;
  142.         y_low         = pos_det_txt(2)-hx-btn_height/2;
  143.         pos_sel_cfs   = [px, y_low, 5*push_width/4, Def_Btn_Height];
  144.         y_low         = pos_sel_cfs(2)-Def_Btn_Height-dy;
  145.         pos_sel_rec   = [px, y_low, 5*push_width/4, Def_Btn_Height];
  146.         px            = x_frame0+(cmd_width-3*pop_width)/2;
  147.         y_low         = pos_sel_rec(2)-2*Def_Btn_Height;
  148.         pos_bins_txt  = [px, y_low+d_txt/2, 2*pop_width, Def_Txt_Height];
  149.         pos_bins_data = [px+2*pop_width+dx, y_low, pop_width, Def_Btn_Height];
  150.  
  151.         px            = x_frame0+(cmd_width-3*push_width/2)/2;
  152.         y_low         = pos_bins_data(2)-Def_Btn_Height-hshow;
  153.         pos_show_hist = [px, y_low, 3*push_width/2, hshow];
  154.         % String property of objects.
  155.         %----------------------------
  156.         ss_type = wmemtool('rmb',win_dw1dtool,n_param_anal,ind_ssig_type);
  157.         switch ss_type
  158.             case 'ss', str_ss = 'Synthesized signal';
  159.             case 'ds', str_ss = 'De-noised signal';
  160.             case 'cs', str_ss = 'Compressed signal';
  161.         end
  162.         str_synt_sig  = str_ss;
  163.         str_orig_sig  = 'Original signal';
  164.         str_app_sig   = 'Approximations';
  165.         str_det_sig   = 'Details';
  166.         str_app_txt   = 'Approximation levels';
  167.         str_app_all   = 'All';
  168.         str_app_none  = 'None';
  169.         str_det_txt   = 'Detail levels';
  170.         str_det_all   = 'All';
  171.         str_det_none  = 'None';
  172.         str_sel_cfs   = 'Coefficients';
  173.         str_sel_rec   = 'Reconstructed';
  174.         str_bins_txt  = 'Number of bins';
  175.         str_bins_data = sprintf('%.0f',default_bins);
  176.         str_show_hist = 'Show histograms';
  177.         % Command part construction of the window.
  178.         %-----------------------------------------
  179.         if ~isequal(get(0,'CurrentFigure'),win_dw1dhist)
  180.             figure(win_dw1dhist);
  181.         end
  182.         utanapar('create_copy',win_dw1dhist, ...
  183.                  {'xloc',xlocINI,'bottom',ybottomINI},...
  184.                  {'n_s',{Sig_Name,Sig_Size},'wav',Wav_Name,'lev',Lev_Anal} ...
  185.                  );
  186.         commonProp = {'Parent',win_dw1dhist,'Unit',win_units};
  187.         comChkProp = {commonProp{:},'Style','Checkbox','Enable','off'};
  188.         chk_orig_sig = uicontrol(comChkProp{:},...
  189.                                  'Position',pos_orig_sig,...
  190.                                  'String',str_orig_sig,...
  191.                                  'UserData',0,...
  192.                                  'Tag',tag_orig_sig...
  193.                                  );
  194.         chk_synt_sig = uicontrol(comChkProp{:},...
  195.                                  'Position',pos_synt_sig,...
  196.                                  'String',str_synt_sig,...
  197.                                  'UserData',0,...
  198.                                  'Tag',tag_synt_sig...
  199.                                  );
  200.         chk_app_sig  = uicontrol(comChkProp{:},...
  201.                                  'Position',pos_app_sig,...
  202.                                  'String',str_app_sig,...
  203.                                  'UserData',0,...
  204.                                  'Tag',tag_app_sig...
  205.                                  );
  206.         chk_det_sig  = uicontrol(comChkProp{:},...
  207.                                  'Position',pos_det_sig,...
  208.                                  'String',str_det_sig,...
  209.                                  'UserData',0,...
  210.                                  'Tag',tag_det_sig...
  211.                                  );
  212.  
  213.         % Approximations checkboxes construction.
  214.         txt_app_txt  = uicontrol(commonProp{:},...
  215.                                  'Style','Text',...
  216.                                  'Position',pos_app_txt,...
  217.                                  'String',str_app_txt,...
  218.                                  'Backgroundcolor',Def_FraBkColor,...
  219.                                  'Visible','off',...
  220.                                  'Tag',tag_app_txt...
  221.                                  );
  222.         pus_app_all  = uicontrol(commonProp{:},...
  223.                                  'Style','PushButton',...
  224.                                  'Position',pos_app_all,...
  225.                                  'String',xlate(str_app_all),...
  226.                                  'Visible','off',...
  227.                                  'Tag',tag_app_all...
  228.                                  );
  229.         pus_app_none = uicontrol(commonProp{:},...
  230.                                  'Style','PushButton',...
  231.                                  'Position',pos_app_none,...
  232.                                  'String',xlate(str_app_none),...
  233.                                  'Visible','off',...
  234.                                  'Tag',tag_app_none...
  235.                                  );
  236.         wx          = (cmd_width-nb*txt_width/2)/(nb+1);
  237.         xbtchk0     = x_frame0+txt_width/2+2*wx;
  238.         ybtchk0     = pos_app_txt(2)-6*btn_height/5;
  239.         xbtchk      = xbtchk0;
  240.         ybtchk      = ybtchk0;
  241.         Chk_App_Lst = zeros(Lev_Anal,1);
  242.         for i=1:Lev_Anal
  243.             pos_app_i = [xbtchk ybtchk txt_width/2 chk_height];
  244.             str_app_i = sprintf('%.0f',i);
  245.             tag_app_i = ['App' str_app_i];
  246.             chk_app_i = uicontrol(commonProp{:},...
  247.                                   'Style','Checkbox',...
  248.                                   'Position',pos_app_i,...
  249.                                   'String',str_app_i,...
  250.                                   'Visible','off',...
  251.                                   'Tag',tag_app_i...
  252.                                   );
  253.             Chk_App_Lst(i) = chk_app_i;
  254.             if rem(i,nb_inline)==0
  255.                 xbtchk = xbtchk0;
  256.                 ybtchk = ybtchk-6*btn_height/5;
  257.             else
  258.                 xbtchk = xbtchk+txt_width/2+wx;
  259.             end
  260.         end
  261.         % Details checkboxes construction.
  262.         txt_det_txt  = uicontrol(commonProp{:},...
  263.                                  'Style','Text',...
  264.                                  'Position',pos_det_txt,...
  265.                                  'String',str_det_txt,...
  266.                                  'Backgroundcolor',Def_FraBkColor,...
  267.                                  'Visible','off',...
  268.                                  'Tag',tag_det_txt...
  269.                                  );
  270.         pus_det_all  = uicontrol(commonProp{:},...
  271.                                  'Style','PushButton',...
  272.                                  'Position',pos_det_all,...
  273.                                  'String',xlate(str_det_all),...
  274.                                  'Visible','off',...
  275.                                  'Tag',tag_det_all...
  276.                                  );
  277.         pus_det_none = uicontrol(commonProp{:},...
  278.                                  'Style','PushButton',...
  279.                                  'Position',pos_det_none,...
  280.                                  'String',xlate(str_det_none),...
  281.                                  'Visible','off',...
  282.                                  'Tag',tag_det_none...
  283.                                  );
  284.         ybtchk0     = pos_det_txt(2)-6*btn_height/5;
  285.         xbtchk      = xbtchk0;
  286.         ybtchk      = ybtchk0;
  287.         Chk_Det_Lst = zeros(Lev_Anal,1);
  288.         for i=1:Lev_Anal
  289.             pos_det_i = [xbtchk ybtchk txt_width/2 chk_height];
  290.             str_det_i = sprintf('%.0f',i);
  291.             tag_det_i = ['Det' str_det_i];
  292.             chk_det_i = uicontrol(commonProp{:},...
  293.                                   'Style','Checkbox',...
  294.                                   'Position',pos_det_i,...
  295.                                   'String',str_det_i,...
  296.                                   'Visible','off',...
  297.                                   'Tag',tag_det_i...
  298.                                   );
  299.             Chk_Det_Lst(i) = chk_det_i;
  300.             if rem(i,nb_inline)==0
  301.                 xbtchk = xbtchk0;
  302.                 ybtchk = ybtchk-6*btn_height/5;
  303.             else
  304.                 xbtchk = xbtchk+txt_width/2+wx;
  305.             end
  306.         end
  307.         rad_sel_cfs   = uicontrol(commonProp{:},...
  308.                                   'Style','Radiobutton',...
  309.                                   'Position',pos_sel_cfs,...
  310.                                   'String',str_sel_cfs,...
  311.                                   'Visible','off',...
  312.                                   'Tag',tag_sel_cfs,...
  313.                                   'Value',0);
  314.         rad_sel_rec   = uicontrol(commonProp{:},...
  315.                                   'Style','Radiobutton',...
  316.                                   'Position',pos_sel_rec,...
  317.                                   'String',str_sel_rec,...
  318.                                   'Visible','off',...
  319.                                   'Tag',tag_sel_rec,...
  320.                                   'Value',1);
  321.         txt_bins_txt  = uicontrol(commonProp{:},...
  322.                                   'Style','Text',...
  323.                                   'Position',pos_bins_txt,...
  324.                                   'String',str_bins_txt,...
  325.                                   'Backgroundcolor',Def_FraBkColor,...
  326.                                   'Visible','off',...
  327.                                   'Tag',tag_bins_txt...
  328.                                   );
  329.         edi_bins_data = uicontrol(commonProp{:},...
  330.                                   'Style','Edit',...
  331.                                   'Position',pos_bins_data,...
  332.                                   'String',str_bins_data,...
  333.                                   'Backgroundcolor',Def_EdiBkColor,...
  334.                                   'Visible','off',...
  335.                                   'Tag',tag_bins_data...
  336.                                   );
  337.         pus_show_hist = uicontrol(commonProp{:},...
  338.                                   'Style','Pushbutton',...
  339.                                   'Position',pos_show_hist,...
  340.                                   'String',xlate(str_show_hist),...
  341.                                   'Interruptible','On',...
  342.                                   'Visible','off',...
  343.                                   'Userdata',[],...
  344.                                   'Tag',tag_show_hist...
  345.                                   );
  346.         drawnow
  347.         % Sets of handles.
  348.         %-----------------
  349.         set1_hdls = [txt_app_txt; pus_app_all; pus_app_none; Chk_App_Lst];
  350.         set2_hdls = [txt_det_txt; pus_det_all; pus_det_none; Chk_Det_Lst];
  351.         set3_hdls = [rad_sel_cfs; rad_sel_rec];
  352.         set4_hdls = [txt_bins_txt; edi_bins_data; pus_show_hist; pus_close];
  353.         % Selected box limits.
  354.         %---------------------
  355.         xlim_selbox = mngmbtn('getbox',win_dw1dtool); 
  356.         if ~isempty(xlim_selbox)
  357.             xlim_selbox = [min(xlim_selbox) max(xlim_selbox)];
  358.         else
  359.             xlim_selbox = get(Axe_Ref,'XLim');
  360.         end
  361.         xlim_selbox = round(xlim_selbox);
  362.         xlim1       = xlim_selbox(1);
  363.         xlim2       = xlim_selbox(2);
  364.         if xlim1<1,        xlim1 = 1;        end
  365.         if xlim2>Sig_Size, xlim2 = Sig_Size; end
  366.         if (xlim2<1) | (xlim1>Sig_Size) , return, end
  367.         selbox = [xlim1 xlim2];
  368.         % Callbacks update.
  369.         %------------------
  370.         str_set1_hdls     = num2mstr(set1_hdls);
  371.         str_set2_hdls     = num2mstr(set2_hdls);
  372.         str_set3_hdls     = num2mstr(set3_hdls);
  373.         str_set4_hdls     = num2mstr(set4_hdls);
  374.         str_group_hdls    = num2mstr([set1_hdls;set2_hdls;set3_hdls;set4_hdls]);
  375.         str_chk_orig_sig  = num2mstr(chk_orig_sig);
  376.         str_chk_synt_sig  = num2mstr(chk_synt_sig);
  377.         str_chk_app_sig   = num2mstr(chk_app_sig);
  378.         str_chk_det_sig   = num2mstr(chk_det_sig);
  379.         str_Chk_App_Lst   = num2mstr(Chk_App_Lst);
  380.         str_Chk_Det_Lst   = num2mstr(Chk_Det_Lst);
  381.         str_rad_sel_rec   = num2mstr(rad_sel_rec);
  382.         str_rad_sel_cfs   = num2mstr(rad_sel_cfs);
  383.         str_edi_bins_data = num2mstr(edi_bins_data);
  384.         str_selbox        = num2mstr(selbox);
  385.         tmp_txt           = [str_set1_hdls ',' ...
  386.                              str_set2_hdls ',' ...
  387.                              str_set3_hdls ',' ...
  388.                              str_set4_hdls ',' ...
  389.                              str_group_hdls];
  390.         cba_orig_sig  = [mfilename '(''select'',' ...
  391.                               str_numwin ',' ...
  392.                               str_chk_orig_sig ',' ...
  393.                               tmp_txt ...
  394.                               ');'];
  395.         cba_synt_sig  = [mfilename '(''select'',' ...
  396.                               str_numwin ',' ...
  397.                               str_chk_synt_sig ',' ...
  398.                               tmp_txt ...
  399.                               ');'];
  400.         cba_app_sig   = [mfilename '(''select'',' ...
  401.                               str_numwin ',' ...
  402.                               str_chk_app_sig ',' ...
  403.                               tmp_txt ...
  404.                               ');'];
  405.         cba_det_sig   = [mfilename '(''select'',' ...
  406.                               str_numwin ',' ...
  407.                               str_chk_det_sig ',' ...
  408.                               tmp_txt ...
  409.                               ');'];
  410.         cba_bins_data = [mfilename '(''update_bins'',' ...
  411.                               str_numwin ',' ...
  412.                               str_edi_bins_data ...
  413.                               ');'];
  414.         cba_app_all   = ['set(' str_Chk_App_Lst ',''Value'',1);'];
  415.         cba_app_none  = ['set(' str_Chk_App_Lst ',''Value'',0);'];
  416.         cba_det_all   = ['set(' str_Chk_Det_Lst ',''Value'',1);'];
  417.         cba_det_none  = ['set(' str_Chk_Det_Lst ',''Value'',0);'];
  418.         cba_sel_rec   = ['set(' str_rad_sel_rec ',''Value'',1);' ...
  419.                          'set(' str_rad_sel_cfs ',''Value'',0);'];
  420.         cba_sel_cfs   = ['set(' str_rad_sel_cfs ',''Value'',1);' ...
  421.                          'set(' str_rad_sel_rec ',''Value'',0);'];
  422.         cba_show_hist = [mfilename '(''draw'',' ...
  423.                               str_numwin ',' ...
  424.                               str_win_dw1dtool ',' ...
  425.                               str_selbox ');'];
  426.         set(chk_orig_sig,'Callback',cba_orig_sig);
  427.         set(chk_synt_sig,'Callback',cba_synt_sig);
  428.         set(chk_app_sig,'Callback',cba_app_sig);
  429.         set(chk_det_sig,'Callback',cba_det_sig);
  430.         set(pus_app_all,'Callback',cba_app_all);
  431.         set(pus_app_none,'Callback',cba_app_none);
  432.         set(pus_det_all,'Callback',cba_det_all);
  433.         set(pus_det_none,'Callback',cba_det_none);
  434.         set(rad_sel_rec,'Callback',cba_sel_rec);
  435.         set(rad_sel_cfs,'Callback',cba_sel_cfs);
  436.         set(edi_bins_data,'Callback',cba_bins_data);
  437.         set(pus_show_hist,'Callback',cba_show_hist);
  438.         % Memory blocks update.
  439.         %----------------------
  440.         wmemtool('ini',win_dw1dhist,n_chk_lev_lst,nbLOC_1_stored);
  441.         wmemtool('wmb',win_dw1dhist,n_chk_lev_lst,...
  442.                        ind_Chk_App_Lst,Chk_App_Lst,ind_Chk_Det_Lst,Chk_Det_Lst);
  443.         % Displaying the window title.
  444.         %-----------------------------
  445.         str_nb_val   = [' (' sprintf('%.0f',Sig_Size) ' values)'];
  446.         str_wintitle = [Sig_Name,str_nb_val,' analyzed at level ',...
  447.                         sprintf('%.0f',Lev_Anal),' with ',Wav_Name];
  448.         str_wintitle = [str_wintitle '.  Components :   ' ,...
  449.                         sprintf('%.0f',selbox(1)) ' --> ' ...
  450.                         sprintf('%.0f',selbox(2))];
  451.         wfigtitl('string',win_dw1dhist,str_wintitle,'off');
  452.         % Setting units to normalized.
  453.         %-----------------------------
  454.         wfigmngr('normalize',win_dw1dhist);
  455. % Initialization with signal histogram (31/08/2000).
  456. %---------------------------------------------------
  457. set(chk_orig_sig,'Value',1);
  458. group_hdls = [set1_hdls;set2_hdls;set3_hdls;set4_hdls];
  459. dw1dhist('select',win_dw1dhist,chk_orig_sig,...
  460.      set1_hdls,set2_hdls,set3_hdls,set4_hdls,group_hdls);
  461. dw1dhist('draw',win_dw1dhist,win_dw1dtool,selbox);
  462. % End waiting.
  463.         %-------------
  464.         set(wfindobj('figure'),'Pointer','arrow');
  465.         set([chk_orig_sig chk_synt_sig chk_app_sig chk_det_sig],'Enable','on');
  466.     case 'select'
  467.         %***********************************************%
  468.         %** OPTION = 'select' - SIGNAL TYPE SELECTION **%
  469.         %***********************************************%
  470.         sel_chk_btn = in3;
  471.         set1_hdls   = in4;
  472.         set2_hdls   = in5;
  473.         set3_hdls   = in6;
  474.         set4_hdls   = in7;
  475.         group_hdls  = in8;
  476.         group_hdls  = group_hdls(1:end-1);
  477.         % Handles of tagged objects.
  478.         %---------------------------
  479.         uic_handles  = findobj(win_dw1dhist,'type','uicontrol');
  480.         chk_handles  = findobj(uic_handles,'Style','checkbox');
  481.         txt_handles  = findobj(uic_handles,'Style','text');
  482.         fra_handles  = findobj(uic_handles,'Style','frame');
  483.         axe_handles  = findobj(get(win_dw1dhist,'Children'),'flat','type','axes');
  484.         chk_orig_sig = findobj(chk_handles,'Tag',tag_orig_sig);
  485.         chk_synt_sig = findobj(chk_handles,'Tag',tag_synt_sig);
  486.         chk_app_sig  = findobj(chk_handles,'Tag',tag_app_sig);
  487.         chk_det_sig  = findobj(chk_handles,'Tag',tag_det_sig);
  488.         hdl1         = findobj(fra_handles,'Tag',tag_sephis_fra);
  489.         hdl2         = findobj(txt_handles,'Tag',tag_sigtype_txt);
  490.         hdl3         = findobj(axe_handles,'flat','Visible','on');
  491.         % Cleaning the graphical part.
  492.         %-----------------------------
  493.         delete([hdl1; hdl2; hdl3]);
  494.         % Get the current selection.
  495.         %---------------------------
  496.         orig_sig = (get(chk_orig_sig,'Userdata')~=0);
  497.         synt_sig = (get(chk_synt_sig,'Userdata')~=0);
  498.         app_sig  = (get(chk_app_sig,'Userdata')~=0);
  499.         det_sig  = (get(chk_det_sig,'Userdata')~=0);
  500.         % Get to the current positions.
  501.         %------------------------------
  502.         pos_det_sig   = get(chk_det_sig,'Position');
  503.         pos_app_txt   = get(set1_hdls(1),'Position');
  504.         pos_app_all   = get(set1_hdls(2),'Position');
  505.         pos_app_none  = get(set1_hdls(3),'Position');
  506.         pos_det_txt   = get(set2_hdls(1),'Position');
  507.         pos_det_all   = get(set2_hdls(2),'Position');
  508.         pos_det_none  = get(set2_hdls(3),'Position');
  509.         pos_sel_cfs   = get(set3_hdls(1),'Position');
  510.         pos_sel_rec   = get(set3_hdls(2),'Position');
  511.         pos_bins_txt  = get(set4_hdls(1),'Position');
  512.         pos_bins_data = get(set4_hdls(2),'Position');
  513.         pos_show_hist = get(set4_hdls(3),'Position');
  514.         pos_close     = get(set4_hdls(4),'Position');
  515.         % Redefine heigth of buttons depending on levels.
  516.         %------------------------------------------------
  517.         levels    = length(set1_hdls)-3;
  518.         nb_inline = 3;
  519.         nbl       = max(2,ceil(levels/nb_inline))+1;
  520.         hbtn1     = pos_bins_data(4);
  521.         hbtn2     = hbtn1;
  522.         hbtn3     = hbtn1;
  523.         if levels>6, hbtn2 = 4*hbtn2/5; end
  524.         if levels>9, hbtn3 = hbtn2/2;   end
  525.         % Redraw the command part depending on the current selection.
  526.         %------------------------------------------------------------
  527.         switch sel_chk_btn
  528.             case chk_orig_sig
  529.                 if orig_sig
  530.                     set(chk_orig_sig,'Value',0,'Userdata',0)
  531.                     if ~(synt_sig | app_sig | det_sig) 
  532.                         set(group_hdls,'Visible','off');
  533.                     end
  534.                 else
  535.                     set(chk_orig_sig,'Value',1,'Userdata',1)
  536.                     if ~(synt_sig | app_sig | det_sig)
  537.                         pos_bins_txt(2) = pos_det_sig(2)-2*hbtn1;
  538.                         pos_bins_data(2)= pos_bins_txt(2);
  539.                         pos_show_hist(2)= pos_bins_data(2)-3*hbtn1;
  540.                         set(set4_hdls(1),'Position',pos_bins_txt);
  541.                         set(set4_hdls(2),'Position',pos_bins_data);
  542.                         set(set4_hdls(3),'Position',pos_show_hist);
  543.                         set(set4_hdls,'Visible','on');
  544.                     end
  545.                 end
  546.             case chk_synt_sig
  547.                 if synt_sig
  548.                     set(chk_synt_sig,'Value',0,'Userdata',0)
  549.                     if ~(orig_sig | app_sig | det_sig) 
  550.                         set(group_hdls,'Visible','off');
  551.                     end
  552.                 else
  553.                     set(chk_synt_sig,'Value',1,'Userdata',1)
  554.                     if ~(orig_sig | app_sig | det_sig)
  555.                         pos_bins_txt(2) = pos_det_sig(2)-2*hbtn1;
  556.                         pos_bins_data(2)= pos_bins_txt(2);
  557.                         pos_show_hist(2)= pos_bins_data(2)-3*hbtn1;
  558.                         set(set4_hdls(1),'Position',pos_bins_txt);
  559.                         set(set4_hdls(2),'Position',pos_bins_data);
  560.                         set(set4_hdls(3),'Position',pos_show_hist);
  561.                         set(set4_hdls,'Visible','on');
  562.                     end
  563.                 end
  564.             case chk_app_sig
  565.                 set(group_hdls,'Visible','off');
  566.                 if app_sig
  567.                     set(chk_app_sig,'Value',0,'Userdata',0)
  568.                     if (orig_sig | synt_sig) & ~det_sig
  569.                         pos_bins_txt(2) = pos_det_sig(2)-2*hbtn1;
  570.                         pos_bins_data(2)= pos_bins_txt(2);
  571.                         pos_show_hist(2)= pos_bins_data(2)-3*hbtn1;
  572.                         set(set4_hdls(1),'Position',pos_bins_txt);
  573.                         set(set4_hdls(2),'Position',pos_bins_data);
  574.                         set(set4_hdls(3),'Position',pos_show_hist);
  575.                         set(set4_hdls,'Visible','on');
  576.                     elseif det_sig
  577.                         pos_det_txt(2)  = pos_det_sig(2)-3*hbtn2/2;
  578.                         pos_det_all(2)  = pos_det_txt(2)-6*hbtn2/5;
  579.                         pos_det_none(2) = pos_det_all(2)-6*hbtn2/5;
  580.                         set(set2_hdls(1),'Position',pos_det_txt);
  581.                         set(set2_hdls(2),'Position',pos_det_all);
  582.                         set(set2_hdls(3),'Position',pos_det_none);
  583.                         pos_chk_det     = zeros(levels,4);
  584.                         for i=1:levels
  585.                             j=i+3;
  586.                             k=ceil(i/nb_inline);
  587.                             pos_chk_det(j,:) = get(set2_hdls(j),'Position');
  588.                             pos_chk_det(j,2) = pos_det_txt(2)-k*(6*hbtn2/5);
  589.                             set(set2_hdls(j),'Position',pos_chk_det(j,:));
  590.                         end
  591.                         pos_sel_cfs(2)  = pos_det_txt(2)-nbl*(6*hbtn2/5)-hbtn2/2;
  592.                         pos_sel_rec(2)  = pos_sel_cfs(2)-3*hbtn1/2;
  593.                         set(set3_hdls(1),'Position',pos_sel_cfs);
  594.                         set(set3_hdls(2),'Position',pos_sel_rec);
  595.                         pos_bins_txt(2) = pos_sel_rec(2)-hbtn1-hbtn3;
  596.                         pos_bins_data(2)= pos_bins_txt(2);
  597.                         pos_show_hist(2)= pos_bins_data(2)-2*hbtn1-hbtn3;
  598.                         set(set4_hdls(1),'Position',pos_bins_txt);
  599.                         set(set4_hdls(2),'Position',pos_bins_data);
  600.                         set(set4_hdls(3),'Position',pos_show_hist);
  601.                         set([set2_hdls;set3_hdls;set4_hdls],'Visible','on');
  602.                     end
  603.                 else
  604.                     set(chk_app_sig,'Value',1,'Userdata',1)
  605.                     if det_sig
  606.                         pos_app_txt(2)  = pos_det_sig(2)-3*hbtn2/2;
  607.                         pos_app_all(2)  = pos_app_txt(2)-6*hbtn2/5;
  608.                         pos_app_none(2) = pos_app_all(2)-6*hbtn2/5;
  609.                         set(set1_hdls(1),'Position',pos_app_txt);
  610.                         set(set1_hdls(2),'Position',pos_app_all);
  611.                         set(set1_hdls(3),'Position',pos_app_none);
  612.                         pos_det_txt(2)  = pos_app_txt(2)-nbl*(6*hbtn2/5);
  613.                         pos_det_all(2)  = pos_det_txt(2)-6*hbtn2/5;
  614.                         pos_det_none(2) = pos_det_all(2)-6*hbtn2/5;
  615.                         set(set2_hdls(1),'Position',pos_det_txt);
  616.                         set(set2_hdls(2),'Position',pos_det_all);
  617.                         set(set2_hdls(3),'Position',pos_det_none);
  618.                         pos_chk_det     = zeros(levels,4);
  619.                         for i=1:levels
  620.                             j=i+3;
  621.                             k=ceil(i/nb_inline);
  622.                             pos_chk_det(j,:) = get(set2_hdls(j),'Position');
  623.                             pos_chk_det(j,2) = pos_det_txt(2)-k*(6*hbtn2/5);
  624.                             set(set2_hdls(j),'Position',pos_chk_det(j,:));
  625.                         end
  626.                         pos_sel_cfs(2)  = pos_det_txt(2)-nbl*(6*hbtn2/5)-hbtn2/2;
  627.                         pos_sel_rec(2)  = pos_sel_cfs(2)-3*hbtn1/2;
  628.                         set(set3_hdls(1),'Position',pos_sel_cfs);
  629.                         set(set3_hdls(2),'Position',pos_sel_rec);
  630.                         pos_bins_txt(2) = pos_sel_rec(2)-hbtn1-hbtn3;
  631.                         pos_bins_data(2)= pos_bins_txt(2);
  632.                         yl              = pos_close(2)+pos_close(4);
  633.                         dy              = pos_bins_data(2)-yl-pos_show_hist(4);
  634.                         pos_show_hist(2)= yl+dy/2;
  635.                         set(set4_hdls(1),'Position',pos_bins_txt);
  636.                         set(set4_hdls(2),'Position',pos_bins_data);
  637.                         set(set4_hdls(3),'Position',pos_show_hist);
  638.                         set([set1_hdls;set2_hdls;set3_hdls;set4_hdls],'Visible','on');
  639.                     else
  640.                         pos_app_txt(2)  = pos_det_sig(2)-3*hbtn2/2;
  641.                         pos_app_all(2)  = pos_app_txt(2)-6*hbtn2/5;
  642.                         pos_app_none(2) = pos_app_all(2)-6*hbtn2/5;
  643.                         set(set1_hdls(1),'Position',pos_app_txt);
  644.                         set(set1_hdls(2),'Position',pos_app_all);
  645.                         set(set1_hdls(3),'Position',pos_app_none);
  646.                         pos_sel_cfs(2)  = pos_app_txt(2)...
  647.                                         -nbl*(6*hbtn2/5)-hbtn2/2;
  648.                         pos_sel_rec(2)  = pos_sel_cfs(2)-3*hbtn1/2;
  649.                         set(set3_hdls(1),'Position',pos_sel_cfs);
  650.                         set(set3_hdls(2),'Position',pos_sel_rec);
  651.                         pos_bins_txt(2) = pos_sel_rec(2)-2*hbtn1;
  652.                         pos_bins_data(2)= pos_bins_txt(2);
  653.                         pos_show_hist(2)= pos_bins_data(2)-3*hbtn1;
  654.                         set(set4_hdls(1),'Position',pos_bins_txt);
  655.                         set(set4_hdls(2),'Position',pos_bins_data);
  656.                         set(set4_hdls(3),'Position',pos_show_hist);
  657.                         set([set1_hdls;set3_hdls;set4_hdls],'Visible','on');
  658.                     end
  659.                 end
  660.             case chk_det_sig
  661.                 set(group_hdls,'Visible','off');
  662.                 if det_sig
  663.                     set(chk_det_sig,'Value',0,'Userdata',0)
  664.                     if (orig_sig | synt_sig) & ~app_sig
  665.                         pos_bins_txt(2) = pos_det_sig(2)-2*hbtn1;
  666.                         pos_bins_data(2)= pos_bins_txt(2);
  667.                         pos_show_hist(2)= pos_bins_data(2)-3*hbtn1;
  668.                         set(set4_hdls(1),'Position',pos_bins_txt);
  669.                         set(set4_hdls(2),'Position',pos_bins_data);
  670.                         set(set4_hdls(3),'Position',pos_show_hist);
  671.                         set(set4_hdls,'Visible','on');
  672.                     elseif app_sig
  673.                         pos_app_txt(2)  = pos_det_sig(2)-3*hbtn2/2;
  674.                         pos_app_all(2)  = pos_app_txt(2)-6*hbtn2/5;
  675.                         pos_app_none(2) = pos_app_all(2)-6*hbtn2/5;
  676.                         set(set1_hdls(1),'Position',pos_app_txt);
  677.                         set(set1_hdls(2),'Position',pos_app_all);
  678.                         set(set1_hdls(3),'Position',pos_app_none);
  679.                         pos_sel_cfs(2)  = pos_app_txt(2)-nbl*(6*hbtn2/5)-hbtn2/2;
  680.                         pos_sel_rec(2)  = pos_sel_cfs(2)-3*hbtn1/2;
  681.                         set(set3_hdls(1),'Position',pos_sel_cfs);
  682.                         set(set3_hdls(2),'Position',pos_sel_rec);
  683.                         pos_bins_txt(2) = pos_sel_rec(2)-2*hbtn1;
  684.                         pos_bins_data(2)= pos_bins_txt(2);
  685.                         pos_show_hist(2)= pos_bins_data(2)-3*hbtn1;
  686.                         set(set4_hdls(1),'Position',pos_bins_txt);
  687.                         set(set4_hdls(2),'Position',pos_bins_data);
  688.                         set(set4_hdls(3),'Position',pos_show_hist);
  689.                         set([set1_hdls;set3_hdls;set4_hdls],'Visible','on');
  690.                     end
  691.                 else
  692.                     set(chk_det_sig,'Value',1,'Userdata',1)
  693.                     if app_sig
  694.                         pos_app_txt(2)  = pos_det_sig(2)-3*hbtn2/2;
  695.                         pos_app_all(2)  = pos_app_txt(2)-6*hbtn2/5;
  696.                         pos_app_none(2) = pos_app_all(2)-6*hbtn2/5;
  697.                         set(set1_hdls(1),'Position',pos_app_txt);
  698.                         set(set1_hdls(2),'Position',pos_app_all);
  699.                         set(set1_hdls(3),'Position',pos_app_none);
  700.                         pos_det_txt(2)  = pos_app_txt(2)-nbl*(6*hbtn2/5);
  701.                         pos_det_all(2)  = pos_det_txt(2)-6*hbtn2/5;
  702.                         pos_det_none(2) = pos_det_all(2)-6*hbtn2/5;
  703.                         set(set2_hdls(1),'Position',pos_det_txt);
  704.                         set(set2_hdls(2),'Position',pos_det_all);
  705.                         set(set2_hdls(3),'Position',pos_det_none);
  706.                         pos_chk_det     = zeros(levels,4);
  707.                         for i=1:levels
  708.                             j=i+3;
  709.                             k=ceil(i/nb_inline);
  710.                             pos_chk_det(j,:) = get(set2_hdls(j),'Position');
  711.                             pos_chk_det(j,2) = pos_det_txt(2)-k*(6*hbtn2/5);
  712.                             set(set2_hdls(j),'Position',pos_chk_det(j,:));
  713.                         end
  714.                         pos_sel_cfs(2)  = pos_det_txt(2)-nbl*(6*hbtn2/5)-hbtn2/2;
  715.                         pos_sel_rec(2)  = pos_sel_cfs(2)-3*hbtn1/2;
  716.                         set(set3_hdls(1),'Position',pos_sel_cfs);
  717.                         set(set3_hdls(2),'Position',pos_sel_rec);
  718.                         pos_bins_txt(2) = pos_sel_rec(2)-hbtn1-hbtn3;
  719.                         pos_bins_data(2)= pos_bins_txt(2);
  720.                         yl              = pos_close(2)+pos_close(4);
  721.                         dy              = pos_bins_data(2)-yl-pos_show_hist(4);                 
  722.                         pos_show_hist(2)= yl+dy/2;
  723.                         set(set4_hdls(1),'Position',pos_bins_txt);
  724.                         set(set4_hdls(2),'Position',pos_bins_data);
  725.                         set(set4_hdls(3),'Position',pos_show_hist);
  726.                         set([set1_hdls;set2_hdls;set3_hdls;set4_hdls],'Visible','on');
  727.                     else
  728.                         pos_det_txt(2)  = pos_det_sig(2)-3*hbtn2/2;
  729.                         pos_det_all(2)  = pos_det_txt(2)-6*hbtn2/5;
  730.                         pos_det_none(2) = pos_det_all(2)-6*hbtn2/5;
  731.                         set(set2_hdls(1),'Position',pos_det_txt);
  732.                         set(set2_hdls(2),'Position',pos_det_all);
  733.                         set(set2_hdls(3),'Position',pos_det_none);
  734.                         pos_chk_det     = zeros(levels,4);
  735.                         for i=1:levels
  736.                             j=i+3;
  737.                             k=ceil(i/nb_inline);
  738.                             pos_chk_det(j,:) = get(set2_hdls(j),'Position');
  739.                             pos_chk_det(j,2) = pos_det_txt(2)-k*(6*hbtn2/5);
  740.                             set(set2_hdls(j),'Position',pos_chk_det(j,:));
  741.                         end
  742.                         pos_sel_cfs(2)  = pos_det_txt(2)-nbl*(6*hbtn2/5)-hbtn2/2;
  743.                         pos_sel_rec(2)  = pos_sel_cfs(2)-3*hbtn1/2;
  744.                         set(set3_hdls(1),'Position',pos_sel_cfs);
  745.                         set(set3_hdls(2),'Position',pos_sel_rec);
  746.                         pos_bins_txt(2) = pos_sel_rec(2)-2*hbtn1;
  747.                         pos_bins_data(2)= pos_bins_txt(2);
  748.                         pos_show_hist(2)= pos_bins_data(2)-3*hbtn1;
  749.                         set(set4_hdls(1),'Position',pos_bins_txt);
  750.                         set(set4_hdls(2),'Position',pos_bins_data);
  751.                         set(set4_hdls(3),'Position',pos_show_hist);
  752.                         set([set2_hdls;set3_hdls;set4_hdls],'Visible','on');
  753.                     end
  754.                 end
  755.         end
  756.     case 'draw'
  757.         %*********************************%
  758.         %** OPTION = 'draw' - DRAW AXES **%
  759.         %*********************************%
  760.         win_dw1dtool = in3;
  761.         selbox_orig  = in4;
  762.         % Get Globals.
  763.         %-------------
  764.         [Def_Btn_Height,Def_TxtBkColor,Def_FraBkColor] = ...
  765.             mextglob('get','Def_Btn_Height','Def_TxtBkColor','Def_FraBkColor');
  766.         % Handles of tagged objects.
  767.         %---------------------------
  768.         uic_handles   = findobj(win_dw1dhist,'type','uicontrol');
  769.         chk_handles   = findobj(uic_handles,'Style','checkbox');
  770.         rad_handles   = findobj(uic_handles,'Style','radiobutton');
  771.         pus_handles   = findobj(uic_handles,'Style','pushbutton');
  772.         pus_show_hist = findobj(pus_handles,...
  773.                                       'Style','pushbutton',...
  774.                                       'Tag',tag_show_hist...
  775.                                       );
  776.         txt_handles   = findobj(uic_handles,'Style','text');
  777.         fra_handles   = findobj(uic_handles,'Style','frame');
  778.         axe_handles   = findobj(get(win_dw1dhist,'Children'),'flat','type','axes');
  779.         hdl1          = findobj(fra_handles,'Tag',tag_sephis_fra);
  780.         hdl2          = findobj(txt_handles,'Tag',tag_sigtype_txt);
  781.         hdl3          = findobj(axe_handles,'flat','Visible','on');
  782.         hdl_frame0    = findobj(fra_handles,'Tag',tag_cmd_frame);
  783.         % Handles of tagged objects continuing.
  784.         %-------------------------------------
  785.         chk_orig_sig  = findobj(chk_handles,'Tag',tag_orig_sig);
  786.         chk_synt_sig  = findobj(chk_handles,'Tag',tag_synt_sig);
  787.         chk_app_sig   = findobj(chk_handles,'Tag',tag_app_sig);
  788.         chk_det_sig   = findobj(chk_handles,'Tag',tag_det_sig);
  789.         rad_sel_cfs   = findobj(win_dw1dhist,'Style','radiobutton',...
  790.                                       'Tag',tag_sel_cfs);
  791.         edi_bins_data = findobj(win_dw1dhist,'Style','edit',...
  792.                                       'Tag',tag_bins_data);
  793.         % Check the bins number.
  794.         %-----------------------
  795.         default_bins    = 30;
  796.         old_params      = get(pus_show_hist,'Userdata');
  797.         if ~isempty(old_params)
  798.             default_bins = old_params(1);
  799.         end
  800.         nb_bins = wstr2num(get(edi_bins_data,'String'));
  801.         if isempty(nb_bins) | nb_bins<2
  802.             nb_bins = default_bins;   
  803.             set(edi_bins_data,'String',sprintf('%.0f',default_bins))
  804.         end
  805.         % Getting memory blocks.
  806.         %-----------------------
  807.         Lev_Anal = wmemtool('rmb',win_dw1dtool,n_param_anal,ind_lev_anal);
  808.         [Chk_App_Lst,Chk_Det_Lst] = wmemtool('rmb',win_dw1dhist,n_chk_lev_lst,...
  809.                                         ind_Chk_App_Lst,ind_Chk_Det_Lst);
  810.         % Main parameters selection before drawing.
  811.         %------------------------------------------
  812.         sel_cfs  = (get(rad_sel_cfs,'Value')~=0);
  813.         orig_sig = (get(chk_orig_sig,'Value')~=0);
  814.         synt_sig = (get(chk_synt_sig,'Value')~=0);
  815.         app_sig  = (get(chk_app_sig,'Value')~=0);
  816.         det_sig  = (get(chk_det_sig,'Value')~=0);
  817.         % Actives apps and dets lists construction.
  818.         %------------------------------------------
  819.         if app_sig
  820.             tmp = get(Chk_App_Lst(1:Lev_Anal),'Value');
  821.             if ~iscell(tmp) , tmp = {tmp}; end
  822.             app_lst = find(cat(2,tmp{:})~=0);
  823.         else
  824.             app_lst = [];
  825.         end
  826.         if det_sig
  827.             tmp = get(Chk_Det_Lst(1:Lev_Anal),'Value');
  828.             if ~iscell(tmp) , tmp = {tmp}; end
  829.             det_lst = find(cat(2,tmp{:})~=0);
  830.         else
  831.             det_lst = [];
  832.         end
  833.         new_params = [nb_bins sel_cfs orig_sig synt_sig ...
  834.                       app_sig det_sig app_lst det_lst   ...
  835.                       ];
  836.         if ~isempty(hdl3) & isequal(new_params,old_params) , return; end
  837.         % Deseable new selection.
  838.         %-------------------------
  839.         set([chk_handles;pus_handles;rad_handles],'Enable','off');
  840.         % Updating parameters.
  841.         %--------------------- 
  842.         set(pus_show_hist,'Userdata',new_params);
  843.         % Show the status line.
  844.         %----------------------
  845.         wfigtitl('vis',win_dw1dhist,'on');
  846.         % Waiting message.
  847.         %-----------------
  848.         set(wfindobj('figure'),'Pointer','watch');
  849.  
  850.         % Cleaning the graphical part.
  851.         %-----------------------------
  852.         delete([hdl1; hdl2; hdl3]);
  853.         drawnow;
  854.         
  855.         % Getting memory blocks continuing.
  856.         %----------------------------------
  857.         [Sig_Name,Wav_Name,Sig_Size,Axe_Ref] = ...
  858.                 wmemtool('rmb',win_dw1dtool,n_param_anal,               ...
  859.                         ind_sig_name,ind_wav_name,ind_sig_size,ind_axe_ref);
  860.         [coefs,longs]   = wmemtool('rmb',win_dw1dtool,n_coefs_longs,...
  861.                                                 ind_coefs,ind_longs);
  862.         % Sort and get length of apps. and dets. lists.
  863.         %----------------------------------------------
  864.         app_lst     = sort(app_lst);
  865.         app_lst_len = length(app_lst);
  866.         det_lst     = sort(det_lst);
  867.         det_lst_len = length(det_lst);
  868.         % General graphical parameters initialization.
  869.         %--------------------------------------------
  870.         win_units  = get(win_dw1dtool,'Units');
  871.         btn_height = Def_Btn_Height;
  872.         if ~strcmp(win_units,'pixels')
  873.             [nul,btn_height] = wfigutil('prop_size',win_dw1dhist,1,btn_height);
  874.         end
  875.         pos_win      = get(win_dw1dtool,'Position');
  876.         bdx          = 0.1*pos_win(3);
  877.         bdy          = 0.05*pos_win(4);
  878.         ecy          = 0.03*pos_win(4);
  879.         pos_graph    = wmemtool('rmb',win_dw1dtool,n_miscella,...
  880.                                      ind_graph_area);
  881.         h_graph      = pos_graph(4);
  882.         w_graph      = pos_graph(3);
  883.         pos_graph(2) = pos_graph(2)-btn_height;
  884.         fontsize     = wmachdep('fontsize','normal',9,app_lst_len);
  885.         % Axes construction.
  886.         %-------------------
  887.         n_axeleft  = app_lst_len;
  888.         n_axeright = det_lst_len;
  889.         if orig_sig, n_axeleft = n_axeleft+1; end
  890.         if synt_sig, n_axeleft = n_axeleft+1; end
  891.         if n_axeleft*n_axeright~=0
  892.             w_left  = (w_graph-3*bdx)/2;
  893.             x_left  = pos_graph(1)+bdx;
  894.             w_right = w_left;
  895.             x_right = x_left+w_left+bdx+bdx/5;
  896.             w_fra   = 0.01*pos_win(3);
  897.             x_fra   = pos_graph(1)+(w_graph-w_fra)/2;
  898.             y_fra   = btn_height;
  899.             h_fra   = 1-2*btn_height;
  900.         elseif n_axeleft~=0
  901.             w_left  = w_graph-2*bdx;
  902.             x_left  = pos_graph(1)+bdx;
  903.         elseif n_axeright~=0
  904.             w_right = w_graph-2*bdx;
  905.             x_right = pos_graph(1)+bdx;
  906.         end
  907.         if ~isequal(get(0,'CurrentFigure'),win_dw1dhist)
  908.             figure(win_dw1dhist);
  909.         end
  910.         % Building axes on the left part.
  911.         %--------------------------------
  912.         comAxeProp = {...
  913.            'Parent',win_dw1dhist,...
  914.            'Unit',win_units,...
  915.            'Drawmode','fast',...
  916.            'Box','On'...
  917.            };
  918.         if n_axeleft~=0
  919.             h_left = (pos_graph(4)-2*bdy-(n_axeleft-1)*ecy)/n_axeleft;
  920.             y_left = pos_graph(2)+bdy;
  921.             axe_left = zeros(1,n_axeleft);
  922.             pos_left = [x_left y_left w_left h_left];
  923.             for k = 1:n_axeleft
  924.                 axe_left(k) = axes(comAxeProp{:},'Position',pos_left);
  925.                 pos_left(2) = pos_left(2)+pos_left(4)+ecy;
  926.             end
  927.         end
  928.         % Building axes on the right part.
  929.         %---------------------------------
  930.         if n_axeright~=0
  931.             h_right = (pos_graph(4)-2*bdy-(n_axeright-1)*ecy)/n_axeright;
  932.             y_right = pos_graph(2)+bdy;
  933.             axe_right = zeros(1,n_axeright);
  934.             pos_right = [x_right y_right w_right h_right];
  935.             for k = 1:n_axeright
  936.                 axe_right(k) = axes(comAxeProp{:},'Position',pos_right);
  937.                 pos_right(2) = pos_right(2)+pos_right(4)+ecy;
  938.             end
  939.         end
  940.         ind_left  = n_axeleft;
  941.         ind_right = n_axeright;
  942.         % Definition of the complete selection box.
  943.         %-----------------------------------------
  944.         selbox_orig = selbox_orig(1):selbox_orig(2);
  945.         % Displaying the signal histogram.
  946.         %---------------------------------
  947.         if orig_sig
  948.             curr_sig   = dw1dfile('sig',win_dw1dtool);
  949.             curr_sig   = curr_sig(selbox_orig);
  950.             curr_color = wtbutils('colors','sig');
  951.             axes(axe_left(ind_left));
  952.             his      = wgethist(curr_sig,nb_bins);
  953.             his(2,:) = his(2,:)/length(curr_sig);
  954.             wplothis(axe_left(ind_left),his,curr_color);
  955.             set(axe_left(ind_left),'Tag','s');
  956.             set(axe_left(ind_left),'Userdata',curr_sig);
  957.             h = txtinaxe('create','s',axe_left(ind_left),'left',...
  958.                                     'on','bold',fontsize);
  959.             set(h,'Units',win_units);
  960.             ind_left = ind_left-1;
  961.         end
  962.         % Displaying the synthesized signal histogram.
  963.         %---------------------------------------------
  964.         ss_type = wmemtool('rmb',win_dw1dtool,n_param_anal,...
  965.                                         ind_ssig_type);
  966.         if     ss_type=='ss', str_ss = 'synthesized signal';
  967.         elseif ss_type=='ds', str_ss = 'de_noised signal';
  968.         elseif ss_type=='cs', str_ss = 'compressed signal';
  969.         end
  970.         if synt_sig
  971.             curr_sig   = dw1dfile('ssig',win_dw1dtool);
  972.             curr_sig   = curr_sig(selbox_orig);
  973.             curr_color = wtbutils('colors','ssig');
  974.             axes(axe_left(ind_left));
  975.             his      = wgethist(curr_sig,nb_bins);
  976.             his(2,:) = his(2,:)/length(curr_sig);
  977.             wplothis(axe_left(ind_left),his,curr_color);
  978.             set(axe_left(ind_left),'Tag','ss');
  979.             h = txtinaxe('create',ss_type,axe_left(ind_left),'left',...
  980.                                     'on','bold',fontsize);
  981.             set(h,'Units',win_units);
  982.             set(axe_left(ind_left),'Userdata',curr_sig);
  983.             ind_left = ind_left-1;
  984.         end
  985.         % Displaying the approximations histograms.
  986.         %------------------------------------------
  987.         col_app = wtbutils('colors','app',Lev_Anal);
  988.         if app_lst_len~=0 & ~sel_cfs
  989.             rec_apps = dw1dfile('app',win_dw1dtool,1:Lev_Anal);
  990.         end
  991.         for k = app_lst_len:-1:1
  992.             level = app_lst(k);
  993.             ind_coef = 1;
  994.             if sel_cfs
  995.                 curr_sig   = appcoef(coefs,longs,Wav_Name,level);
  996.                 selbox_cfs = selbox_orig;
  997.                 min_box    = ceil(min(selbox_cfs)/2^level);
  998.                 max_box    = ceil(max(selbox_cfs)/2^level);
  999.                 selbox_cfs = min_box:max_box;
  1000.                 if length(selbox_cfs)>2
  1001.                     curr_sig = curr_sig(selbox_cfs);
  1002.                 else
  1003.                     f = wwarndlg(['   Not enough approximation ' ...
  1004.                              'coefficients remaining at level ' ...
  1005.                              sprintf('%.0f',level)],...
  1006.                             'Wavelet 1-D -- Histograms','block');
  1007.                     ind_coef = 0;
  1008.                 end
  1009.             else
  1010.                 curr_sig = rec_apps(level,:);
  1011.                 curr_sig = curr_sig(selbox_orig);
  1012.             end
  1013.             axes(axe_left(ind_left));
  1014.             if ind_coef
  1015.                 curr_color = col_app(level,:);
  1016.                 his        = wgethist(curr_sig,nb_bins);
  1017.                 his(2,:)   = his(2,:)/length(curr_sig);
  1018.                 wplothis(axe_left(ind_left),his,curr_color);
  1019.                 set(axe_left(ind_left),'Userdata',curr_sig);
  1020.             end
  1021.             set(axe_left(ind_left),'Tag',['a' sprintf('%.0f',level)]);
  1022.             h = txtinaxe('create',['a' wnsubstr(level)],...
  1023.                                     axe_left(ind_left),'left',...
  1024.                                     'on','bold',fontsize);
  1025.             set(h,'Units',win_units);
  1026.             ind_left = ind_left-1;
  1027.         end
  1028.         % Displaying the details histograms.
  1029.         %-----------------------------------
  1030.         col_det = wtbutils('colors','det',Lev_Anal);
  1031.         if det_lst_len~=0 & ~sel_cfs
  1032.             rec_dets = dw1dfile('det',win_dw1dtool,1:Lev_Anal);
  1033.         end
  1034.         for k = det_lst_len:-1:1
  1035.             level = det_lst(k);
  1036.             ind_coef = 1;
  1037.             if sel_cfs
  1038.                 curr_sig   = detcoef(coefs,longs,level);
  1039.                 selbox_cfs = selbox_orig;
  1040.                 min_box    = ceil(min(selbox_cfs)/2^level);
  1041.                 max_box    = ceil(max(selbox_cfs)/2^level);
  1042.                 selbox_cfs = min_box:max_box;
  1043.                 if length(selbox_cfs)>2
  1044.                     curr_sig = curr_sig(selbox_cfs);
  1045.                 else
  1046.                     f = wwarndlg(['     Not enough detail ' ...
  1047.                              'coefficients remaining at level ' ...
  1048.                              sprintf('%.0f',level)],...
  1049.                             'Wavelet 1-D -- Histograms','block');
  1050.                     ind_coef = 0;
  1051.                 end
  1052.             else
  1053.                 curr_sig = rec_dets(level,:);
  1054.                 curr_sig = curr_sig(selbox_orig);
  1055.             end
  1056.             axes(axe_right(ind_right));
  1057.             if ind_coef
  1058.                 curr_color = col_det(level,:);
  1059.                 his        = wgethist(curr_sig,nb_bins);
  1060.                 his(2,:)   = his(2,:)/length(curr_sig);
  1061.                 wplothis(axe_right(ind_right),his,curr_color);
  1062.                 set(axe_right(ind_right),'Userdata',curr_sig);
  1063.             end
  1064.             set(axe_right(ind_right),'Tag',['d' sprintf('%.0f',level)]);
  1065.             h = txtinaxe('create',['d' wnsubstr(level)],...
  1066.                                     axe_right(ind_right),'right',...
  1067.                                     'on','bold',fontsize);
  1068.             set(h,'Units',win_units);
  1069.             ind_right = ind_right-1;
  1070.         end
  1071.         % Vertical separation.
  1072.         %---------------------
  1073.         if n_axeleft*n_axeright~=0
  1074.             uicontrol(...
  1075.                     'Parent',win_dw1dhist, ...
  1076.                     'Style','frame',...
  1077.                     'Unit',win_units,...
  1078.                     'Position',[x_fra,y_fra,w_fra,h_fra],...
  1079.                     'Visible','On',...
  1080.                     'Backgroundcolor',Def_FraBkColor,...
  1081.                     'Tag',tag_sephis_fra...
  1082.                     );
  1083.         end
  1084.         % Signals type for the status line display.
  1085.         %------------------------------------------
  1086.         str_sig_type = [];
  1087.         if orig_sig
  1088.             str_sig_type = [str_sig_type 'original signal - '];
  1089.         end
  1090.         if synt_sig
  1091.             str_sig_type = [str_sig_type str_ss ' - '];
  1092.         end
  1093.         if (app_sig & ~isempty(app_lst)) | (det_sig & ~isempty(det_lst))
  1094.             if ~sel_cfs
  1095.                 str_sig_type = [str_sig_type 'reconstructed '];
  1096.             end
  1097.             if app_sig & ~isempty(app_lst) & det_sig & ~isempty(det_lst)
  1098.                 str_sig_type = [str_sig_type 'approximations and details'];
  1099.             elseif (app_sig & ~isempty(app_lst)) & (~det_sig | isempty(det_lst))
  1100.                 str_sig_type = [str_sig_type 'approximations'];
  1101.             elseif (~app_sig | isempty(app_lst)) & (det_sig & ~isempty(det_lst))
  1102.                 str_sig_type = [str_sig_type 'details'];
  1103.             end
  1104.             if sel_cfs
  1105.                 str_sig_type = [str_sig_type ' coefficients'];
  1106.             end
  1107.         end
  1108.         if ~orig_sig & ~synt_sig         & ...
  1109.            (~app_sig | isempty(app_lst)) & ...
  1110.            (~det_sig | isempty(det_lst))
  1111.             str_sig_type = 'Nothing selected';
  1112.         end
  1113.         txt_sig_type = uicontrol(...
  1114.                                  'Parent',win_dw1dhist, ...
  1115.                                  'Style','text',...
  1116.                                  'Unit',win_units,...
  1117.                                  'Position',[0,0,w_graph,btn_height],...
  1118.                                  'Visible','On',...
  1119.                                  'Backgroundcolor',Def_TxtBkColor,...
  1120.                                  'String',str_sig_type,...
  1121.                                  'Tag',tag_sigtype_txt...
  1122.                                  );
  1123.         % Setting units to normalized.
  1124.         %-----------------------------
  1125.         set(findobj(win_dw1dhist,'Units','pixels'),'Units','normalized');
  1126.         % End waiting.
  1127.         %-------------
  1128.         set(wfindobj('figure'),'Pointer','arrow');
  1129.         % wwaiting('off',win_dw1dhist);
  1130.         % Enable new selection.
  1131.         %-------------------------
  1132.         set([chk_handles;pus_handles;rad_handles],'Enable','on');
  1133.     case 'update_bins'
  1134.         %**************************************************************%
  1135.         %** OPTION = 'update_bins' - UPDATE HISTOGRAMS WITH NEW BINS **%
  1136.         %**************************************************************%
  1137.         edi_bins_data   = in3;
  1138.         % Handles of tagged objects.
  1139.         %---------------------------
  1140.         axes_hdls = findobj(get(win_dw1dhist,'Children'),'flat','type','axes');
  1141.         if isempty(axes_hdls) , return; end
  1142.         uic = findobj(get(win_dw1dhist,'Children'),'flat','type','uicontrol');
  1143.         pus_show_hist = findobj(uic,'Style','pushbutton',...
  1144.                                     'Tag',tag_show_hist...
  1145.                                     );
  1146.         Sigtype_hdl = findobj(uic,'Style','text','Tag',tag_sigtype_txt);
  1147.         % Check the bins number.
  1148.         %-----------------------
  1149.         default_bins = 30;
  1150.         old_params   = get(pus_show_hist,'Userdata');
  1151.         if ~isempty(old_params)
  1152.             default_bins = old_params(1);
  1153.         end
  1154.         nb_bins = wstr2num(get(edi_bins_data,'String'));
  1155.         if isempty(nb_bins)
  1156.             nb_bins = default_bins;   
  1157.             set(edi_bins_data,'String',sprintf('%.0f',default_bins))
  1158.         elseif nb_bins<2
  1159.             nb_bins = default_bins;
  1160.             set(edi_bins_data,'String',sprintf('%.0f',default_bins))
  1161.         end
  1162.         if default_bins==nb_bins , return; end
  1163.         % Waiting message.
  1164.         %-----------------
  1165.         set(Sigtype_hdl,'Visible','off');
  1166.         set(wfindobj('figure'),'Pointer','watch');
  1167.         % Updating histograms.
  1168.         %---------------------
  1169.         old_params(1) = nb_bins;
  1170.         set(pus_show_hist,'Userdata',old_params);
  1171.         nb_axes  = length(axes_hdls);
  1172.         fontsize = wmachdep('fontsize','normal',9,nb_axes);
  1173.         for i=1:nb_axes
  1174.             curr_axe = axes_hdls(i);
  1175.             curr_sig = get(curr_axe,'Userdata');
  1176.             if ~isempty(curr_sig)
  1177.                 axes(curr_axe);
  1178.                 curr_child = findobj(get(curr_axe,'Children'),'type','patch');
  1179.                 axe_col    = get(curr_child,'FaceColor');
  1180.                 his        = wgethist(curr_sig,nb_bins);
  1181.                 his(2,:)   = his(2,:)/length(curr_sig);
  1182.                 wplothis(curr_axe,his,axe_col);
  1183.                 curr_txt   = get(curr_axe,'tag');
  1184.                 switch curr_txt(1)
  1185.                   case {'a','d'}
  1186.                     curr_txt = [curr_txt(1), wnsubstr(curr_txt(2:end))];
  1187.                 end
  1188.                 if curr_txt(1)=='d', side = 'right'; else , side = 'left'; end
  1189.                 txtinaxe('create',curr_txt,curr_axe,side,'on','bold',fontsize);
  1190.                 set(curr_axe,'Userdata',curr_sig)
  1191.             end
  1192.         end
  1193.         % End waiting.
  1194.         %-------------
  1195.         set(wfindobj('figure'),'Pointer','arrow');
  1196.         set(Sigtype_hdl,'Visible','on');
  1197.     case 'demo'
  1198.         %****************************************%
  1199.         %** OPTION = 'demo' -  DEMOS or TESTS  **%
  1200.         %****************************************%
  1201.         chk_handles   = findobj(win_dw1dhist,'Style','checkbox');
  1202.         chk_orig_sig  = findobj(chk_handles,'Tag',tag_orig_sig);
  1203.         chk_synt_sig  = findobj(chk_handles,'Tag',tag_synt_sig);
  1204.         chk_app_sig   = findobj(chk_handles,'Tag',tag_app_sig);
  1205.         chk_det_sig   = findobj(chk_handles,'Tag',tag_det_sig);
  1206.         pus_show_hist = findobj(win_dw1dhist,...
  1207.                                    'Style','pushbutton',...
  1208.                                    'Tag',tag_show_hist...
  1209.                                    );
  1210.         set(chk_handles,'Value',1);
  1211.         eval(get(chk_orig_sig,'Callback'));
  1212.         eval(get(chk_synt_sig,'Callback'));
  1213.         eval(get(chk_app_sig,'Callback'));
  1214.         eval(get(chk_det_sig,'Callback'));
  1215.         eval(get(pus_show_hist,'Callback'));
  1216.     case 'close'
  1217.     otherwise
  1218.         errargt(mfilename,'Unknown Option','msg');
  1219.         error('*');
  1220. end
  1221. %-------------------------------------------------
  1222. function varargout = depOfMachine(varargin)
  1223. Def_Btn_Height = varargin{1};
  1224. Lev_Anal       = varargin{2};
  1225. scrSize = get(0,'ScreenSize');
  1226. if scrSize(4) <= 700
  1227.     h_sigs = Def_Btn_Height;
  1228. else
  1229.     if (Lev_Anal>9)
  1230.         h_sigs = 5*Def_Btn_Height/4;
  1231.     else
  1232.         h_sigs = 3*Def_Btn_Height/2;
  1233.     end
  1234. end
  1235. if Lev_Anal>6
  1236.     btn_height = 4*Def_Btn_Height/5;
  1237.     if scrSize(4)<600
  1238.         chk_height = Def_Btn_Height;
  1239.     else
  1240.         chk_height = btn_height;
  1241.     end
  1242. else
  1243.     btn_height = Def_Btn_Height;
  1244.     chk_height = Def_Btn_Height;
  1245. end
  1246. hshow = 2*Def_Btn_Height;
  1247. if  (Lev_Anal>9)
  1248.     if (scrSize(4)<600)
  1249.        hshow = Def_Btn_Height;
  1250.     else
  1251.        hshow = 1.5*Def_Btn_Height;
  1252.     end
  1253. end
  1254. varargout = {h_sigs,btn_height,chk_height,hshow};
  1255. %-------------------------------------------------