Code covered by the BSD License  

Highlights from
SAE Paper Demo: Model-Based Design of Hybrid Electric Vehicles

image thumbnail

SAE Paper Demo: Model-Based Design of Hybrid Electric Vehicles

by

 

07 Nov 2010 (Updated )

Demo files to accompany the paper by the same name

callbackinfo_get_selection(h)
function objs = callbackinfo_get_selection(h)

% Copyright 2004-2005 The MathWorks, Inc.

switch class(h.uiObject),
    %
    % Stateflow Editor cases
    %
    case 'Stateflow.Chart',
        objs = sf_get_selection_from_chart_l(h.uiObject.id);
    case 'Stateflow.State', % this should only happen for subcharts.
        if (h.uiObject.isSubchart),
            objs = sf_get_selection_from_chart_l(h.uiObject.chart.id);
        end;
        
    %
    % Simulink Editor cases
    %
    case {'Simulink.BlockDiagram', 'Simulink.SubSystem'},
        tmpObjs = find_system( h.uiObject.handle, 'SearchDepth', 1, 'Selected','on'); 
        
        if length(tmpObjs) ~= 0
            for i=1:length(tmpObjs) 
                objs(i) = get_param( tmpObjs(i), 'Object' );
            end
        
            objs( objs==h.uiObject ) = []; % remove yourself as you are the context.
        else
            objs = [];
        end
    %
    % Model Explorer
    %
    case 'DAStudio.Explorer'
        imME = DAStudio.imExplorer(h.uiObject);
        objs = imME.getSelectedListNodes;
        
    otherwise
        objs = [];
end;


    
function objs = sf_get_selection_from_chart_l(chart),
       r = sfroot;
       selectedIds = sf('SelectedObjectsIn', chart);
       if ~isempty(selectedIds),
           objs = r.idToHandle(selectedIds);
       else,
           objs = [];
       end;

Contact us