Code covered by the BSD License  

Highlights from
CTMSIM - an interactive freeway traffic macrosimulator

image thumbnail
from CTMSIM - an interactive freeway traffic macrosimulator by Alex Kurzhanskiy
Freeway traffic simulation based on Asymmetric Cell Transmission Model

ctmGUIclose()
function ctmGUIclose()
% CTMGUICLOSE - performs cleanup and closes 'ctmGUI' window;
%               this function neither takes nor returns any parameters.
%
% Last modified:   11/10/2006.

%
% Alex Kurzhanskiy   <akurzhan@eecs.berkeley.edu>
%

global g_ctmGUI;

shh     = get(0, 'ShowHiddenHandles');
currFig = get(0, 'CurrentFigure');

if (g_ctmGUI.isStopped == 0) & (g_ctmGUI.isSaved == 0)
  g_ctmGUI.isStopped = 1;
  beep;
  return;
end

if g_ctmGUI.isStopped < 0
  beep;
  return;
end

if g_ctmGUI.isSaved == 0
  pos_size = get(currFig, 'Position');
  res      = save_dialog([pos_size(1)+pos_size(3)/2.5 pos_size(2)+pos_size(4)/2.5], 'Save simulation?');
  if res == 2  % cancel exiting
    return;
  elseif res == 1  % save simulation
    fn = uiputfile('*.mat');
    if ~isa(fn, 'double')
      g_ctmGUI.isSaved = 1;
      ctmGUI_data      = g_ctmGUI;
      if str2num(version('-release')) >= 14
        feval(@save, '-v6', fn, 'ctmGUI_data');
      else
        feval(@save, fn, 'ctmGUI_data');
      end
    end
  end
end

% cleanup
clear global g_ctmGUI;

global CTMSIM_ORC;
clear global CTMSIM_ORC;

% close GUI
set(0, 'ShowHiddenHandles', 'on');
set(0, 'ShowHiddenHandles', shh);
delete(currFig);

return;

Contact us at files@mathworks.com