No BSD License  

Highlights from
Stateflow Alignment Tool

image thumbnail
from Stateflow Alignment Tool by Sven Probst
Stateflowalign is a simple GUI to align and modify graphical stateflow objects.

stateflowalign(varargin)
function varargout = stateflowalign(varargin)
% STATEFLOWALIGN M-file for stateflowalign.fig
%      STATEFLOWALIGN, by itself, creates a new STATEFLOWALIGN or raises the existing
%      singleton*.
%
%      H = STATEFLOWALIGN returns the handle to a new STATEFLOWALIGN or the handle to
%      the existing singleton*.
%
%      STATEFLOWALIGN('CALLBACK',hObject,eventData,handles,...) calls the local
%      function named CALLBACK in STATEFLOWALIGN.M with the given input arguments.
%
%      STATEFLOWALIGN('Property','Value',...) creates a new STATEFLOWALIGN or raises the
%      existing singleton*.  Starting from the left, property value pairs are
%      applied to the GUI before stateflowalign_OpeningFunction gets called.  An
%      unrecognized property name or invalid value makes property application
%      stop.  All inputs are passed to stateflowalign_OpeningFcn via varargin.
%
%      *See GUI Options on GUIDE's Tools menu.  Choose "GUI allows only one
%      instance to run (singleton)".
%
% See also: GUIDE, GUIDATA, GUIHANDLES
%
% stateflow align implements three basic functions to align and modify
% graphical stateflow objects:
% 1. Align
%   All selected objects are aligned to the last object in the selection.
%   Therefore at least two objects must be selected. Alignment is done to
%   specific alignment lines. These are left, rigth, top, bottom,
%   horizontal centre and vertical centre for rectangular graphical objects
%   and the centre of junctions.
% 2. Copy Size
%   The size of the last selected object is copied to all other selected
%   objects. This function works only on rectangular objects.
% 3. Distance
%   Bring the selected objects to a specified distance relating to their
%   bounds in x or y direction. In the auto mode the direction of the
%   higher misalignment is used.
%   In non cascaded submode the last selected object is the reference.
%   In cascaded submode the n-th object is the reference of the (n-1)th
%       object. The process starts with the last selected element as first
%       reference.
% REMARKS:
% 1. To select multiple objects hold down the shift key while mouse
% clicking the objets.
% 2. Transitions should not be selected since they loose their connection.
% 3. There is NO UNDO possibility because the stateflow API is unsed. Save
% the file before using this tool!!


% Edit the above text to modify the response to help stateflowalign

% Last Modified by GUIDE v2.5 04-Jan-2005 18:32:27

% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name',       mfilename, ...
                   'gui_Singleton',  gui_Singleton, ...
                   'gui_OpeningFcn', @stateflowalign_OpeningFcn, ...
                   'gui_OutputFcn',  @stateflowalign_OutputFcn, ...
                   'gui_LayoutFcn',  [] , ...
                   'gui_Callback',   []);
if nargin && ischar(varargin{1})
    gui_State.gui_Callback = str2func(varargin{1});
end

if nargout
    [varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});
else
    gui_mainfcn(gui_State, varargin{:});
end
% End initialization code - DO NOT EDIT


% --- Executes just before stateflowalign is made visible.
function stateflowalign_OpeningFcn(hObject, eventdata, handles, varargin)
% This function has no output args, see OutputFcn.
% hObject    handle to figure
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
% varargin   command line arguments to stateflowalign (see VARARGIN)

% Choose default command line output for stateflowalign
handles.output = hObject;

% Update handles structure
guidata(hObject, handles);

% UIWAIT makes stateflowalign wait for user response (see UIRESUME)
% uiwait(handles.figure1);

% move figure to north east position of the screen
movegui(hObject,'northeast');


% --- Outputs from this function are returned to the command line.
function varargout = stateflowalign_OutputFcn(hObject, eventdata, handles) 
% varargout  cell array for returning output args (see VARARGOUT);
% hObject    handle to figure
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Get default command line output from handles structure
varargout{1} = handles.output;


% --- Executes on button press in pushbutton1.
function pushbutton1_Callback(hObject, eventdata, handles)
% hObject    handle to pushbutton1 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% call align function al
try
    al;
catch
    errordlg(lasterr,'Error','modal')
end

% --- Executes on button press in pushbutton2.
function pushbutton2_Callback(hObject, eventdata, handles)
% hObject    handle to pushbutton2 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% call copy size function cs
try
    cs;
catch
    errordlg(lasterr,'Error','modal')
end


function edit1_Callback(hObject, eventdata, handles)
% hObject    handle to edit1 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hints: get(hObject,'String') returns contents of edit1 as text
%        str2double(get(hObject,'String')) returns contents of edit1 as a double
if ~isfinite(str2double(get(hObject,'String')))
    set(hObject,'String','10');
end


% --- Executes during object creation, after setting all properties.
function edit1_CreateFcn(hObject, eventdata, handles)
% hObject    handle to edit1 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: edit controls usually have a white background on Windows.
%       See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor','white');
end


% --- Executes on button press in pushbutton3.
function pushbutton3_Callback(hObject, eventdata, handles)
% hObject    handle to pushbutton3 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

dist=str2double(get(handles.edit1,'String'));
distType=get(handles.popupmenu2,'Value');
% call distance function sf_dist
try
    sf_dist(dist,distType);
catch
    errordlg(lasterr,'Error','modal')
end



% --- Executes on selection change in popupmenu1.
function popupmenu1_Callback(hObject, eventdata, handles)
% hObject    handle to popupmenu1 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hints: contents = get(hObject,'String') returns popupmenu1 contents as cell array
%        contents{get(hObject,'Value')} returns selected item from popupmenu1

contents = get(hObject,'String');
str=contents{get(hObject,'Value')};
set(handles.edit1,'String',str);

% --- Executes during object creation, after setting all properties.
function popupmenu1_CreateFcn(hObject, eventdata, handles)
% hObject    handle to popupmenu1 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: popupmenu controls usually have a white background on Windows.
%       See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor','white');
end

set(hObject,'String',{'10' '20' '30' '40' '50'});




% --- Executes on selection change in popupmenu2.
function popupmenu2_Callback(hObject, eventdata, handles)
% hObject    handle to popupmenu2 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hints: contents = get(hObject,'String') returns popupmenu2 contents as cell array
%        contents{get(hObject,'Value')} returns selected item from popupmenu2


% --- Executes during object creation, after setting all properties.
function popupmenu2_CreateFcn(hObject, eventdata, handles)
% hObject    handle to popupmenu2 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: popupmenu controls usually have a white background on Windows.
%       See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor','white');
end

set(hObject,'String',{'       auto' '  horizontal' '    vertical' ...
    'auto cascade' 'horiz. cascade' 'vert. cascade'});
set(hObject,'Value', 4);


Contact us at files@mathworks.com