view m-toolbox/m/gui/gltpda/g_LoadFromBlockCallback.m @ 43:bc767aaa99a8

CVS Update
author Daniele Nicolodi <nicolodi@science.unitn.it>
date Tue, 06 Dec 2011 11:09:25 +0100
parents f0afece42f48
children
line wrap: on
line source

    function g_LoadFromBlockCallback(currPanel,varargin)   
    % This callback is called whenever the user selects a From block.
    
        global guiFontSize
        panelDimens = get(currPanel, 'Position');
        backColor   = get(currPanel, 'BackgroundColor');
       
      % Button: 'Find origin'
        uicontrol('Parent',currPanel,'Units','pixels','HorizontalAlignment','center','Position',[(panelDimens(4)-200)/2 panelDimens(4)-100 200 30],'String','Find origin','FontSize',guiFontSize+1,'Visible','on','Enable','on','Callback',@FindOriginCallback,'Style','pushbutton');
    
        
        
    %----------------------------------------------------------------------
    function FindOriginCallback(varargin)   
    % This callback is called whenever click on the 'Find Origin' button,
    % having selected a 'From' block.
    
        varName = get(gcbh,'GotoTag');
        origin = utils.prog.find_in_models(bdroot,'LookUnderMasks','all','BlockType','Goto','GotoTag',varName);
        if numel(origin)>1
          % Error text: there are multiple origins.
            uicontrol('Parent',currPanel,'BackgroundColor',backColor,'Units','pixels','HorizontalAlignment','center','Position',[(panelDimens(4)-400)/2 panelDimens(4)-160 400 30],'String','Error: there are multiple sources','Visible','on','Style','text');
        elseif numel(origin)==1
          % Text: full path of the origin.
            uicontrol('Parent',currPanel,'BackgroundColor',backColor,'Units','pixels','HorizontalAlignment','center','Position',[(panelDimens(4)-400)/2 panelDimens(4)-160 400 30],'String',origin{1},'Visible','on','Style','text');
        else
          % Error text: no origin found.
            uicontrol('Parent',currPanel,'BackgroundColor',backColor,'Units','pixels','HorizontalAlignment','center','Position',[(panelDimens(4)-400)/2 panelDimens(4)-160 400 30],'String','Error: no source found','Visible','on','Style','text');
        end
    end
    %----------------------------------------------------------------------
            
    end