Mercurial > hg > ltpda
comparison m-toolbox/m/gui/gltpda/g_copyfcnCallback.m @ 0:f0afece42f48
Import.
author | Daniele Nicolodi <nicolodi@science.unitn.it> |
---|---|
date | Wed, 23 Nov 2011 19:22:13 +0100 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:f0afece42f48 |
---|---|
1 function blk = g_copyfcnCallback(oldSelection,newSelection) | |
2 | |
3 try %#ok<ALIGN> % the try syntax is due to eventual multiple (or no) outports of the parent block | |
4 | |
5 % if numel(newSelection)>1 | |
6 % for ii=1:numel(newSelection), blockPosition(ii,1:4) = get_param(newSelection(ii),'Position'); end | |
7 % if ii>1, delete_block(getfullname(newSelection(ii))); end | |
8 % meanPosition = [mean(blockPosition(:,1)) , mean(blockPosition(:,2)) , blockPosition(1,3) , blockPosition(1,4)]; | |
9 % set_param(newSelection(1),'Position',meanPosition); | |
10 % newSelection(2:end)=[]; | |
11 % end | |
12 | |
13 if numel(newSelection)>1 | |
14 for ii=2:numel(newSelection) | |
15 delete_block(getfullname(newSelection(ii))) | |
16 end | |
17 newSelection(2:end)=[]; | |
18 end | |
19 | |
20 functionName = get_param(find_system(newSelection(1),'LookUnderMasks','all','BlockType','M-S-Function'),'Tag'); | |
21 if isempty(functionName), functionName = 'hollow'; end | |
22 | |
23 % To replace the copied block with the hollow one: | |
24 load_system('ltpda_library'); | |
25 blk = replace_block(gcs,'Name',get(newSelection,'Name'),'ltpda_library/Commonly Used Blocks/hollow','noprompt'); | |
26 blk = get_param(blk{1},'Handle'); | |
27 set(blk,'LinkStatus','inactive','MaskDisplay','disp(''hollow'')') | |
28 set(utils.prog.find_in_models(blk,'LookUnderMasks','all','BlockType','M-S-Function','FunctionName','ltpdasim'),'Tag','','Name','hollow'); | |
29 set(blk,'Selected','on') | |
30 set(blk,'UserData',[functionName,'-',num2str(oldSelection(1),20)]) | |
31 | |
32 % To add the line properly connecting the old block to the new one: | |
33 if numel(oldSelection)>1 | |
34 set(blk,'UserData','none - 1') | |
35 g_numberDataInput('',1,numel(oldSelection)) | |
36 for ii=1:numel(oldSelection) | |
37 add_line(gcs,[get(oldSelection(ii),'Name'),'/1'],[get(blk,'Name'),'/',num2str(ii)],'autorouting','on') | |
38 end | |
39 | |
40 else | |
41 add_line(gcs,[get(oldSelection,'Name'),'/1'],[get(blk,'Name'),'/1'],'autorouting','on') | |
42 end | |
43 | |
44 catch, end; | |
45 | |
46 end |