from
Sequence Diagram tool
by Eric Ludlam
Create UML style Sequence Diagrams
|
| sequenceaddlink(linkname, nodename) |
function sequenceaddlink(linkname, nodename)
% SEQUENCEADDLINK(LINKNAME, NODENAME) Add a link with LINKNAME from
% the current node to NODENAME. If NODENAME doesn't exist yet,
% create it.
% Author: Eric Ludlam
% Copyright (c) 2006 The MathWorks Inc.
SD = getappdata(gcf,'SD');
% Previous node
if isempty(SD.links)
lastlinkidx = 0;
lastnodeidx = 0;
else
lastlinkidx = length(SD.links);
lastnodeidx = SD.links(lastlinkidx).nodeidx;
end
linkidx = lastlinkidx+1;
loop = false;
if lastnodeidx > 0
createnode(SD.nodes(lastnodeidx).name, linkidx);
if strcmp(SD.nodes(lastnodeidx).name, nodename)
loop = true;
end
end
if ~isempty(nodename)
node = createnode(nodename, linkidx, loop);
SD = getappdata(gcf,'SD');
nodeidx = node.nodeidx;
else
nodeidx = 0;
end
% Check for repeating Ctor/Dtor issues.
if 0 && lastlinkidx > 0 && ...
SD.links(lastlinkidx).lastnodeidx == nodeidx && ...
SD.links(lastlinkidx).nodeidx ~= nodeidx && ...
any(regexp(linkname, '^[CD]tor ')) && ...
strcmp(SD.links(lastlinkidx).name, 'return')
% If the last link is a return from this very object, and
% We are issuing a CTor/DTor, then remove the return
% and replace it with this new link.
delete(SD.links(lastlinkidx).line);
delete(SD.links(lastlinkidx).text);
linkidx = lastlinkidx;
lastnodeidx = nodeidx;
end
% Create the new link.
link = makelink(linkname, linkidx, lastnodeidx, nodeidx);
if isempty(SD.links)
SD.links = link;
else
SD.links(linkidx) = link;
end
%SAVE
setappdata(SD.fig,'SD',SD);
|
|
Contact us at files@mathworks.com