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

波变换

开发平台:

Matlab

  1. function [out1,out2] = whelpfun(option,in2,in3,in4)
  2. %WHELPFUN Help function.
  3. %   [OUT1,OUT2] = WHELPFUN(OPTION,IN2,IN3,IN4)
  4. %   M. Misiti, Y. Misiti, G. Oppenheim, J.M. Poggi 01-May-96.
  5. %   Last Revision: 09-Dec-2000.
  6. %   Copyright 1995-2002 The MathWorks, Inc.
  7. % $Revision: 1.18 $
  8. % Tag property of objects.
  9. %------------------------
  10. tag_fig_info = 'Whelpfig';
  11. dy0 = 18;
  12. switch option
  13.     case {'movsli','movtxt','page_ud'} , fighelp = in2;
  14.     otherwise
  15.       fighelp = wfindobj('figure','tag',tag_fig_info);
  16. end
  17. if ~isempty(fighelp)
  18.     fra    = findobj(fighelp,'style','frame');
  19.     usr    = get(fra,'Userdata');
  20.     txt    = usr(1:end-6);
  21.     usr    = usr(end-5:end);
  22.     btn_cl = usr(1);
  23.     btn_p1 = usr(2);
  24.     btn_p2 = usr(3);
  25.     btn_p3 = usr(4);
  26.     sli    = usr(5);
  27.     axe    = usr(6);
  28. end
  29. switch option
  30.     case 'movsli'
  31.         val = round(get(sli,'Value'));
  32.         usr = get(sli,'Userdata');
  33.         if val==usr , return; end
  34.         set(sli,'Value',val,'Userdata',val);
  35.         dy  = -(val-usr)*dy0;
  36.         whelpfun('movtxt',fighelp,dy);
  37.     case 'movtxt'
  38.         dy      = in3;
  39.         old_u   = get(axe,'units');
  40.         set([axe txt],'units','pixels');
  41.         p_axe   = get(axe,'Position');
  42.         dim     = length(txt);
  43.         nbt_vis = floor(p_axe(4)/dy0)-1;
  44.         nb_page = ceil(dim/nbt_vis);
  45.         ena1 = 'off'; ena2 = 'off'; ena3 = 'off';
  46.         for k = 1:dim
  47.             p  = get(txt(k),'Position');
  48.             p2 = p(2)+dy;
  49.             p3 = p2+dy0;
  50.             if (p2<dy0/2) | (p3>p_axe(4))
  51.                 vis = 'off';
  52.                 if k<=nbt_vis
  53.                     ena1 = 'on';
  54.                 elseif (nbt_vis<k) & (k<=2*nbt_vis)
  55.                     ena2 = 'on';
  56.                 else
  57.                     ena3 = 'on';
  58.                 end
  59.             else
  60.                 vis = 'on'; 
  61.             end
  62.             set(txt(k),'Position',[p(1) p2],'Visible',vis);
  63.         end
  64.         set(btn_p1,'Enable',ena1);
  65.         set(btn_p2,'Enable',ena2);
  66.         set(btn_p3,'Enable',ena3);    
  67.         set([axe txt],'units',old_u);
  68.     case 'page_ud'
  69.         nump  = in3;
  70.         old_u = get(axe,'units');
  71.         set([axe txt(1)],'units','pixels');
  72.         p_axe = get(axe,'Position');
  73.         p_txt = get(txt(1),'Position');
  74.         set([axe txt(1)],'units',old_u);
  75.         switch nump
  76.           case 1
  77.             dy      = p_axe(4)-dy0-p_txt(2);
  78.             vals    = get(sli,'Max');
  79.           case 2
  80.             nbt_vis = floor(p_axe(4)/dy0)-1;
  81.             dy      = p_axe(4)-dy0-p_txt(2)+dy0*nbt_vis;
  82.             vals    = get(sli,'Max')-nbt_vis;
  83.           case 3
  84.             nbt_vis = floor(p_axe(4)/dy0)-1;
  85.             dy      = p_axe(4)-dy0-p_txt(2)+2*dy0*nbt_vis;
  86.             vals    = get(sli,'Min');
  87.         end
  88.         set(sli,'Value',vals,'Userdata',vals);
  89.         whelpfun('movtxt',fighelp,dy);
  90.     case 'create'
  91.         % Get Globals.
  92.         %-------------
  93.         [...
  94.         ShiftTop_Fig,                           ...
  95.         Def_Btn_Height,Def_Btn_Width,Y_Spacing, ...
  96.         Def_TxtBkColor,Def_FraBkColor,Def_UicFtWeight] = ...
  97.             mextglob('get',...
  98.                 'ShiftTop_Fig',                                     ...
  99.                 'Def_Btn_Height','Def_Btn_Width','Y_Spacing',       ...
  100.                 'Def_TxtBkColor','Def_FraBkColor','Def_UicFtWeight' ...
  101.                 );
  102.         Deffontsize = get(0,'DefaultAxesFontSize');
  103.         if nargin<3
  104.             fname   = '';  
  105.             fontsize = Deffontsize;
  106.         elseif nargin<4
  107.             fname = in3;
  108.             fontsize = Deffontsize;
  109.         else
  110.             fname = in3;
  111.             fontsize = in4;
  112.         end
  113.         fighelp = wfindobj('figure','tag',tag_fig_info);
  114.         if isempty(fighelp)
  115.             win_units   = 'pixels';
  116.             Screen_Size = get(0,'ScreenSize');
  117.             [nul,nul,win_height] = wfigmngr('figsizes');
  118.             btn_width = 3*Def_Btn_Width/4;
  119.             cmd_width = 2*btn_width;
  120.             win_width = round(cmd_width/(1-0.85));
  121.             pos_win   = [ Screen_Size(3)-5-win_width, ...
  122.                           Screen_Size(4)-win_height-ShiftTop_Fig, ...
  123.                           win_width, ...
  124.                           win_height ...
  125.                           ];
  126.             axe_col = Def_TxtBkColor;
  127.             fighelp = colordef('new','none');
  128.             set(fighelp, ...
  129.                   'MenuBar','none',...
  130.                   'DefaultUicontrolBackgroundcolor',Def_FraBkColor,...
  131.                   'DefaultUicontrolFontWeight', Def_UicFtWeight,...
  132.                   'Name','Information window',...
  133.                   'Visible','off',...
  134.                   'Unit',win_units,...
  135.                   'Position',pos_win,...
  136.                   'Color',axe_col,...
  137.                   'DefaultAxesXColor',axe_col,...
  138.                   'DefaultAxesYColor',axe_col,...
  139.                   'DefaultAxesZColor',axe_col,...
  140.                   'NumberTitle','off',...
  141.                   'Tag',tag_fig_info...
  142.                   );
  143. wfigmngr('extfig',fighelp,'ExtFig_WH');
  144.             x_fra   = pos_win(3)-cmd_width+1;
  145.             w_fra   = cmd_width;
  146.             pos_fra = [x_fra , 0 , w_fra , pos_win(4)+5];
  147.             ypos       = pos_fra(2)+pos_fra(4)-5*Def_Btn_Height;
  148.             pos_close  = [ x_fra+btn_width/4 ,...
  149.                            ypos                 ,...
  150.                            3*btn_width/2        ,...
  151.                            2*Def_Btn_Height     ];
  152.             ypos       = ypos-pos_close(4)-2*Def_Btn_Height;
  153.             pos_btn_p1 = pos_close;  pos_btn_p1(2) = ypos;
  154.             ypos       = ypos-pos_close(4)-2*Def_Btn_Height;
  155.             pos_btn_p2 = pos_close;  pos_btn_p2(2) = ypos;
  156.             ypos       = ypos-pos_close(4)-2*Def_Btn_Height;
  157.             pos_btn_p3 = pos_close;  pos_btn_p3(2) = ypos;
  158.             str_close  = 'Close';
  159.             str_btn_p1 = 'Page 1';
  160.             str_btn_p2 = 'Page 2';
  161.             str_btn_p3 = 'Page 3';
  162.             figStr     = sprintf('%.0f',fighelp);
  163.             cba_close  = [mfilename '(''close'',' figStr ');'];
  164.             cba_btn_p1 = [mfilename '(''page_ud'',' figStr ',1);'];
  165.             cba_btn_p2 = [mfilename '(''page_ud'',' figStr ',2);'];
  166.             cba_btn_p3 = [mfilename '(''page_ud'',' figStr ',3);'];
  167.             commonProp = {...
  168.                'Parent',fighelp, ...
  169.                'Visible','off',  ...
  170.                'Unit',win_units  ...
  171.                };
  172.             fra  = uicontrol(...
  173.                              'Parent',fighelp,   ...
  174.                              'Style','frame',    ...
  175.                              'Visible','off',    ...
  176.                              'Unit',win_units,   ...
  177.                              'Position',pos_fra, ...
  178.                              'Backgroundcolor',Def_FraBkColor...
  179.                             );
  180.             btn_cl = uicontrol(...
  181.                                'Parent',fighelp,     ...
  182.                                'Style','Pushbutton', ...
  183.                                'Unit',win_units,     ...
  184.                                'Visible','off',      ...
  185.                                'Position',pos_close, ...
  186.                                'String',str_close,   ...
  187.                                'Interruptible','on', ...
  188.                                'Callback',cba_close  ...
  189.                                );
  190.             set(fighelp,'CloseRequestFcn',cba_close)
  191.             btn_p1 = uicontrol(...
  192.                                'Parent',fighelp,     ...
  193.                                'Style','Pushbutton', ...
  194.                                'Unit',win_units,     ...
  195.                                'Visible','off',      ...
  196.                                'Position',pos_btn_p1,...
  197.                                'String',str_btn_p1,  ...
  198.                                'Interruptible','on', ...
  199.                                'Callback',cba_btn_p1 ...
  200.                                );
  201.             btn_p2 = uicontrol(...
  202.                                'Parent',fighelp,     ...
  203.                                'Style','Pushbutton', ...
  204.                                'Unit',win_units,     ...
  205.                                'Visible','off',      ...
  206.                                'Position',pos_btn_p2,...
  207.                                'String',str_btn_p2,  ...
  208.                                'Interruptible','on', ...
  209.                                'Callback',cba_btn_p2 ...
  210.                                );
  211.             btn_p3 = uicontrol(...
  212.                                'Parent',fighelp,     ...
  213.                                'Style','Pushbutton', ...
  214.                                'Unit',win_units,     ...
  215.                                'Visible','off',      ...
  216.                                'Position',pos_btn_p3,...
  217.                                'String',str_btn_p3,  ...
  218.                                'Interruptible','on', ...
  219.                                'Callback',cba_btn_p3 ...
  220.                                );
  221.             p_axe  = [0 0 win_width-cmd_width win_height];
  222.             axe    = axes(...
  223.                           'Parent',fighelp,               ...
  224.                           'Visible','off',                ...
  225.                           'Units','pixels',               ...
  226.                           'Position',p_axe,               ...
  227.                           'DrawMode','Fast',              ...
  228.                           'XTicklabelMode','manual',      ...
  229.                           'YTicklabelMode','manual',      ...
  230.                           'XTickLabel',[],'YTickLabel',[],...
  231.                           'Box','On',                     ...
  232.                           'XGrid','off','YGrid','off',    ...
  233.                           'color',axe_col                 ...
  234.                          );
  235.             pos_sli = [p_axe(1)+p_axe(3)-15 p_axe(2) 15 p_axe(4)];
  236.             cba_sli = [mfilename '(''movsli'',' sprintf('%.0f',fighelp) ');'];
  237.             sli     = uicontrol(...
  238.                                 'Parent',fighelp,   ...
  239.                                 'style','slider',   ...
  240.                                 'Units','pixels',   ...
  241.                                 'Position',pos_sli, ...
  242.                                 'Visible','off',    ...
  243.                                 'Min',0,            ...
  244.                                 'Max',150,          ...
  245.                                 'Value',150,        ...
  246.                                 'Callback',cba_sli  ...
  247.                                  );
  248.             set([fighelp,fra,btn_cl,btn_p1,btn_p2,btn_p3,sli,axe], ...
  249.                                     'units','normalized');
  250.             set([fighelp,fra,btn_cl,axe,sli],'Visible','on');
  251.             drawnow
  252.         else
  253.             old_name = get(btn_cl,'Userdata');
  254.             if ~isempty(old_name) & strcmp(old_name,fname) , return; end
  255.             delete(txt);
  256.             set([sli,btn_p1,btn_p2,btn_p3],'Visible','off');
  257.             if ~isequal(get(0,'CurrentFigure'),fighelp) , figure(fighelp); end
  258.         end
  259.         set(fighelp,'Name', sprintf('Information window : %s', in2(1,:)));
  260.         set(fra,'Userdata',[btn_cl,btn_p1,btn_p2,btn_p3,sli,axe]);
  261.         set(btn_cl,'Userdata',fname);
  262.         dim     = size(in2,1);
  263.         old_u   = get(axe,'units');
  264.         set(axe,'units','pixels');
  265.         txt_col = [0 0 0];
  266.         p_axe   = get(axe,'Position');
  267.         dy      = dy0;
  268.         dx      = 20;
  269.         y1      = p_axe(4);
  270.         nbt_vis = floor(y1/dy0)-1;
  271.         nb_page = ceil(dim/nbt_vis);
  272.         invis   = 0;
  273.         txt     = zeros(1,dim);
  274.         I124 = find(in2=='|');
  275.         car = '!';
  276.         in2(I124) = car(ones(size(I124)));
  277.         for k = 1:dim
  278.             y1 = y1-dy;
  279.             if y1<dy0/2 , invis = invis+1; end
  280.             txt(k) = text(dx,y1,in2(k,:),           ...
  281.                           'units','pixels',     ...
  282.                           'fontname','FixedWidth', ...
  283.                           'fontsize',fontsize,  ...
  284.                           'Color',txt_col,      ...
  285.                           'Visible','off',      ...
  286.                           'Userdata',k,         ...
  287.                           'Parent',axe          ...
  288.                           );
  289.         end
  290.         if dim-invis>0 , set(txt(1:dim-invis),'Visible','on'); end
  291.      
  292.         set(axe,'units',old_u);
  293.         if nb_page>1
  294.             set(btn_p1,'Visible','on','Enable','off');
  295.             set(btn_p2,'Visible','on','Enable','on');
  296.             if nb_page>2, set(btn_p3,'Visible','on','Enable','on'); end
  297.             val = (nb_page-1)*nbt_vis;
  298.             set(sli,...
  299.                   'Units','pixels',             ...
  300.                   'Max',val,'Value',val,        ...
  301.                   'Userdata',val,'Visible','on' ...
  302.                   );
  303.         else
  304.             set(sli,'Visible','off')
  305.         end
  306.         set([txt sli],'units','normalized');
  307.         set(fra,'Userdata',[txt get(fra,'Userdata')]);
  308.     case 'getflag'
  309.         out1 = [];
  310.         out2 = fighelp;
  311.         if isempty(fighelp) , return; end
  312.         out1 = get(btn_cl,'Userdata');
  313.     case 'close'
  314.         delete(in2)
  315. end