⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 cconvdemo_callbacks.m

📁 这是一个基于matlab开发的关于c语言的图形转换程序,可实现直方图的生成和传输
💻 M
📖 第 1 页 / 共 2 页
字号:
function cconvdemo_callbacks(action)%CCONVDEMO_CALLBACKS
%   This file contains the main code and callbacks for the CCONVDEMO
%   program.% Jordan Rosenthal, 03-Nov-1999 : Adapted from CONVDEMO for discrete signals.
%        Rev. 1.01, 10-Nov-1999 : Fixed a bug in multiplypatch code
%        Rev. 1.02, 26-Mar-2000 : Added a simple installation check
%                               : Added try block to initialization code. 
%                               : Fixed 'Close' case to handle multiple instances
%                                 of GUI correctly.
%        Rev. 2.00, 26-Oct-2000 : Renamed to CCONVDEMO
%                               : Renamed class files to avoid conflicts with 
%                                 discrete convdemo classes.
%        Rev. 2.01  06-Nov-2000 : Fixed for SIGGENDLG to CSIGGENDLG name change.
%                               : Fixed for CCONVDEMO to CCONVDEMO_CALLBACKS name change.
%                               : Modified for better path handling.
%        Rev. 2.02  17-Nov-2000 : Fixed bug when creating delayed signals.
NO = 0; YES = 1; OFF = 0; ON = 1;if nargin == 0
   action = 'Initialize';
else   h = get(gcbf, 'UserData');endswitch(action)
   %-----------------------------------------------------------
case 'Initialize'
   %-----------------------------------------------------------
   
   try
      % All error checking moved to the CCONVDEMO function.  Keep this here as
      % well because we need the Matlab version number for some of the bug
      % workarounds.
      h.MATLABVER = versioncheck(5.2);     % Check Matlab Version
      
      %---  Set up GUI  ---%      convgui;
      strVersion = '2.02';           % Version string for figure title
      set(gcf, 'Name', ['Continuous Convolution Demo v' strVersion]);
      h.LineWidth = 0.5;
      h.FigPos = get(gcf,'Pos');
      
      SCALE = getfontscale;          % Platform dependent code to determine SCALE parameter
      setfonts(gcf,SCALE);           % Setup fonts: override default fonts used in ltigui
      configresize(gcf);             % Change all 'units'/'font units' to normalized
      
      h = gethandles(h);             % Get GUI graphic handles
      h = defaultplots(h);           % Create default plots
      
      set(gcf,'UserData',h);
      set(gcf, 'WindowButtonMotionFcn', [mfilename ' WindowButtonMotionFcn']);      
      set(gcf,'HandleVisibility','callback');    % Make figure inaccessible from command line      
      
   catch
      %---  Delete any GUI figures  --%
      delete(findall(0,'type','figure','tag','CCONVDEMO'));
      
      %---  Display the error to the user and exit  ---%
      errordlg(lasterr,'Error Initializing Figure');
      return;
   end

   %-----------------------------------------------------------
case 'SetFigureSize'   
   %-----------------------------------------------------------
   
   % Center figure on screen
   OldUnits = get([0; gcf], 'units');
   set([0; gcf],'units','pixels');
   ScreenSize = get(0,'ScreenSize');
   FigPos = get(gcf,'Position');
   newFigPos = round([ (ScreenSize(3)-FigPos(3))/2  (ScreenSize(4)-FigPos(4))/2  FigPos(3:4) ]);
   %   set(gcf,'ResizeFcn','');
   set(gcf,'Pos',newFigPos);
   %   set(gcf,'ResizeFcn',[mfilename ' ResizeFcn']);
   set([0; gcf],{'units'},OldUnits);
   
   %-----------------------------------------------------------
case 'ResizeFcn'   
   %-----------------------------------------------------------
   % For Matlab 5.1, this will not be called because 'Resize' = 'off'
   % Fix for bugs in normalized fontunits in Matlab 5.2.  
   % Force constant figure aspect ratio if in Matlab 5.3.
   FigPos = resizefcn(h.FigPos,gcbo,h.MATLABVER);  % Version dependent resize code
   switch computer
   case {'MAC2','PCWIN'}
      % On MAC, baseline of text inside edit boxes remains at same
      % vertical position irregardless of change in font size.
      % To properly align text, here the old edit boxes are deleted
      % and new ones created with the proper size.
      hEd = findall(gcbf,'type','uicontrol','style','edit');
      OldFontUnits = get(hEd,'FontUnits');
      set(hEd,'FontUnits','Pixels');
      hEdNew = zeros(size(hEd));
      relHeightChange = FigPos(4)/h.FigPos(4);
      for i = 1:length(hEd)
         Props = get(hEd(i));
         FontSize = relHeightChange*Props.FontSize;
         Props = rmfield(Props,{'Extent','Type','FontSize','FontUnits'});
         delete(hEd(i));
         hEdNew(i) = uicontrol('FontUnits','Pixels', ...
            'FontSize',FontSize,Props);
      end
      set(hEdNew,{'FontUnits'},OldFontUnits);
      h = gethandles(h);
      set(gcbf,'UserData',h);
   end
   h.FigPos = FigPos;         % Store old position
   set(gcbf,'UserData',h);
   
   %-----------------------------------------------------------
case 'Get x(t)'   %-----------------------------------------------------------
   getsignal('x(t)',h);
   
   %-----------------------------------------------------------case 'Get h(t)'   %-----------------------------------------------------------
   getsignal('h(t)',h);
   
   case 'FlipButton'   set( h.Button.Radio, 'Value', OFF);   if strcmp( get(gcbo, 'type'), 'uicontrol' )      set( gcbo, 'Value', ON);      SignalToFlip = get(gcbo, 'String');   else      MenuLabel = get(gcbo,'Label');      switch MenuLabel      case '&Flip x(t)'         SignalToFlip = 'Flip x(t)';         set(gcbo, 'Label', '&Flip h(t)');         set( findobj(gcbf,'Style','radiobutton','String','Flip x(t)'), 'Value', ON);      case '&Flip h(t)'         SignalToFlip = 'Flip h(t)';         set(gcbo, 'Label', '&Flip x(t)');         set( findobj(gcbf,'Style','radiobutton','String','Flip h(t)'), 'Value', ON);      end   end   h = sethandles(h,'State.SignalToFlip', SignalToFlip);   if h.State.DataInitialized      initialize(h);   end
   case 'WindowButtonMotionFcn'
   if h.State.DataInitialized
      [Mouse_x,Mouse_y] = mousepos;      [x,y,w,ht] = arrowpos(h);      if strcmp( lower( get(h.Button.Tutorial, 'Visible')), 'on')         x = x(1);         y = y(1);         w = w(1);         ht = ht(1);      end      if any( (x<Mouse_x) & (Mouse_x<x+w) & (y<Mouse_y) & (Mouse_y<y+ht) )         setptr(gcbf, 'hand');      else         setptr(gcbf, 'arrow');      end   end
   
case 'KeyPressFcn'   if h.State.DataInitialized      CurrentChar = str2num( get(gcbf,'CurrentCharacter') );      if ~isempty(CurrentChar) & any( CurrentChar == [4 6] )         set(gcbf, 'KeyPressFcn', 'figure(gcbf)');         if CurrentChar == 4            DistanceMoved = -1/2;         else            DistanceMoved = 1/2;         end         movesignal(DistanceMoved);         set(gcbf, 'KeyPressFcn', [mfilename ' KeyPressFcn']);      end   end
   case 'SignalStartMove'   setptr(gcbf, 'closedhand');   currentPoint = get(gca, 'CurrentPoint');   setuprop(gcbf, 'StartPos', currentPoint(1,1) );   set(gcbf, 'WindowButtonMotionFcn', [mfilename ' SignalMove']);   set(gcbf, 'WindowButtonUpFcn', [mfilename ' SignalStopMove']);
   case 'SignalMove'   currentPoint = get(gca, 'CurrentPoint');   DistanceMoved = currentPoint(1,1) - getuprop(gcbf, 'StartPos');
   DistanceMoved = round(DistanceMoved*100)/100;   movesignal(DistanceMoved);   setuprop(gcbf, 'StartPos', currentPoint(1,1));
   case 'SignalStopMove'   set(gcbf, 'WindowButtonMotionFcn', [mfilename ' WindowButtonMotionFcn']);   set(gcbf, 'WindowButtonUpFcn', '');   setptr(gcbf,'hand');
   case 'Tutorial Mode'   hOutputPlots = findobj(h.Axis.Output);   hText = h.Text.OutputLabel;   OnText = {'Convolution','Click to hide plot'};   OffText = 'Convolution';   if umtoggle(gcbo)      h = sethandles(h,'State.TutorialMode',ON);      set(hOutputPlots, 'Visible', 'off', ...         'ButtonDownFcn', [mfilename ' TutorialPlotClick']);      set(h.Text.Arrows,'ButtonDownFcn',[mfilename ' SignalStartMove']);      set(hText,'String',OnText);      set(h.Button.Tutorial,'Visible','on');   else      h = sethandles(h,'State.TutorialMode',OFF);      set(h.Button.Tutorial,'Visible','off');      set(hText,'String',OffText);      set(hOutputPlots,'ButtonDownFcn','');      set(h.Text.Arrows, 'ButtonDownFcn', [mfilename ' SignalStartMove']);      set(findobj(h.Axis.Output),'visible','on');   endcase 'TutorialPlotClick'   set(h.Button.Tutorial,'Visible','on');   set(findobj(h.Axis.Output),'Visible','off');case 'TutorialButtonPush'   set(h.Button.Tutorial, 'Visible', 'off');   set(findobj(h.Axis.Output), 'Visible', 'on');

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -