0001 function buildLibrary(varargin)
0002
0003
0004
0005
0006 clear all
0007 bdclose('all');
0008
0009 classes = ltpda_classes;
0010
0011 load_system libraryBase.mdl
0012 open ltpda_library.mdl
0013 set(get_param(gcs,'Handle'),'Lock','off')
0014
0015
0016 allblocks= find_system(gcs,'LookUnderMasks','all');
0017 for i=1:numel(allblocks)
0018 blockHandle = get_param(allblocks{i},'Handle');
0019 try set(blockHandle,'ForegroundColor','black'); catch end
0020 try set(blockHandle,'Screencolor','white'); catch end
0021 end
0022
0023
0024 methBlock = find_system(gcs,'Name','Methods');
0025 methPos = get(get_param(methBlock{1},'Handle'),'Position');
0026 delete_block(methBlock);
0027 MethodBlock = add_block('libraryBase/SubSystName','ltpda_library/Methods');
0028 disp('Methods subsystem updated')
0029 if ~isempty(methBlock), set(MethodBlock,'Position',methPos); end
0030 set(MethodBlock,'LinkStatus','inactive')
0031 set(MethodBlock,'MaskDisplay','disp(''Methods'')')
0032 clear methPos MethBlock MethodBlock
0033
0034
0035 for i=1:numel(classes)
0036 methodlist=methods(classes{i});
0037 methodcategory={};
0038 for j=1:numel(methodlist)
0039 try
0040 if ~strcmp(methodlist{j},'Contents')
0041 methodcategory{j,1} = eval(sprintf([methodlist{j},'(%s,''Category'')'],classes{i}));
0042 end
0043 catch
0044 methodcategory{j,1} = 0;
0045 disp(['================= Error in the method ''',methodlist{j},''' of class ''',classes{i},''' ================= '])
0046 end
0047 end
0048
0049
0050 classFolder = add_block('libraryBase/SubSystName',['ltpda_library/Methods/',classes{i}]);
0051 set(classFolder,'LinkStatus','inactive')
0052 set(classFolder,'MaskDisplay',['disp(''',classes{i},''')'])
0053
0054 x=1;y=1;
0055 while ~isempty(find_system('ltpda_library/Methods','SearchDepth',1,'Position',[30+80*(y-1) , 30+80*(x-1) , 80+80*(y-1) , 80+80*(x-1)]))
0056 y=y+1;
0057 if y==6, x=x+1; y=1; end
0058 end
0059 set(classFolder,'Position',[30+80*(y-1) , 30+80*(x-1) , 80+80*(y-1) , 80+80*(x-1)])
0060
0061
0062 for j=1:numel(methodlist)
0063 if isa(methodcategory{j},'char') && numel(methodcategory{j})<20 && ~isempty(methodcategory{j}) && ~strcmp(methodcategory{j},'Internal')
0064 currCateg = methodcategory{j};
0065
0066
0067 categFolder = find_system(['ltpda_library/Methods/',classes{i}],'SearchDepth',1,'Name',currCateg);
0068 try categFolder = categFolder{1}; catch end
0069 if isempty(categFolder)
0070 categFolder = add_block('libraryBase/SubSystName',['ltpda_library/Methods/',classes{i},'/',currCateg]);
0071 set(categFolder,'LinkStatus','inactive')
0072 set(categFolder,'MaskDisplay',['disp(''',currCateg,''')'])
0073
0074 x=1;y=1;
0075 while ~isempty(find_system(['ltpda_library/Methods/',classes{i}],'SearchDepth',1,'Position',[30+80*(y-1) , 30+80*(x-1) , 80+80*(y-1) , 80+80*(x-1)]))
0076 aaa = find_system(['ltpda_library/Methods/',classes{i}],'SearchDepth',1,'Position',[30+80*(y-1) , 30+80*(x-1) , 80+80*(y-1) , 80+80*(x-1)]);
0077 if (strcmp(aaa{1},['ltpda_library/Methods/',classes{i}]) && numel(aaa)==1), break; end
0078 y=y+1;
0079 if y==5, x=x+1; y=1; end
0080 end
0081 set(categFolder,'Position',[30+80*(y-1) , 30+80*(x-1) , 80+80*(y-1) , 80+80*(x-1)])
0082 end
0083
0084 if strcmp(currCateg,'Constructor')
0085 blockH = add_block('libraryBase/constructor',['ltpda_library/Methods/',classes{i},'/',currCateg,'/',methodlist{j}]);
0086 elseif strcmp(currCateg,'Output')
0087 blockH = add_block('libraryBase/output',['ltpda_library/Methods/',classes{i},'/',currCateg,'/',methodlist{j}]);
0088 elseif ~strcmp(methodlist{j},'Contents')
0089 blockH = add_block('libraryBase/function',['ltpda_library/Methods/',classes{i},'/',currCateg,'/',methodlist{j}]);
0090 end
0091
0092
0093 x=1;y=1;
0094 while ~isempty(find_system(['ltpda_library/Methods/',classes{i},'/',currCateg],'SearchDepth',1,'Position',[30+70*(y-1) , 30+70*(x-1) , 80+70*(y-1) , 60+70*(x-1)]))
0095 aaa = find_system(['ltpda_library/Methods/',classes{i},'/',currCateg],'SearchDepth',1,'Position',[30+70*(y-1) , 30+70*(x-1) , 80+70*(y-1) , 60+70*(x-1)]);
0096 if (strcmp(aaa{1},['ltpda_library/Methods/',classes{i},'/',currCateg]) && numel(aaa)==1), break; end
0097 y=y+1;
0098 if y==5, x=x+1; y=1; end
0099 end
0100 set(blockH,'Position',[30+70*(y-1) , 30+70*(x-1) , 80+70*(y-1) , 60+70*(x-1)])
0101
0102 set(blockH,'LinkStatus','inactive')
0103 set(blockH,'MaskDisplay',['disp(''',methodlist{j},''')'])
0104 set(blockH,'Tag',['method ',classes{i}])
0105 set(blockH,'Description','')
0106 maskText = eval(['help(''',classes{i},'/',methodlist{j},''');']);
0107 maskText = strtok(maskText,'%%');
0108 set(blockH,'MaskDescription',maskText);
0109 set(blockH,'OpenFcn','ltpdagui(''callback'',1,''redraw'',2);if (~strcmp(bdroot,''ltpda_library'') && ~isempty(findobj(''Tag'',''LTPDAGUI''))), figure(findobj(''Tag'',''LTPDAGUI'')); end');
0110 childpath = find_system(blockH,'LookUnderMasks','all','BlockType','M-S-Function');
0111 set(childpath,'Tag',methodlist{j})
0112 set(childpath,'Name',methodlist{j})
0113 set(childpath,'Description','')
0114
0115 end
0116 end
0117
0118 end
0119
0120 close_system libraryBase.mdl
0121
0122
0123
0124 annotationHandle = find_system(gcs, 'FindAll', 'on', 'type', 'annotation');
0125 caption1 = 'LTPDA Library';
0126 caption2 = ['v2.0 - ',datestr(now,1)];
0127 caption = strvcat(caption1,caption2);
0128 set_param(annotationHandle, 'HorizontalAlignment','center','Text',caption)
0129
0130 save_system ltpda_library.mdl
0131 close_system ltpda_library.mdl
0132
0133 end
0134