expmaster

PURPOSE ^

EXPMASTER - allow to create, modify, add, cut, .. segments of domain outline together

SYNOPSIS ^

function expmaster(newfile,varargin)

DESCRIPTION ^

EXPMASTER - allow to create, modify, add, cut, .. segments of domain outline together

   this routine is used to create, modify, cut,... an Argus file (.exp)

   expmaster(newprofile)
      creation of an argus file newprofile

   expmaster(newprofile,oldprofile)
      the modification of the file oldprofile will be saved in newprofile

   expmaster(newprofile,oldprofile1,oldprofile2,...)
      the modification of the files oldprofile* will be saved in newprofile

   Usage:
      expmaster(newfile,varargin)

   See also EXPDOC

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function expmaster(newfile,varargin)
0002 %EXPMASTER - allow to create, modify, add, cut, .. segments of domain outline together
0003 %
0004 %   this routine is used to create, modify, cut,... an Argus file (.exp)
0005 %
0006 %   expmaster(newprofile)
0007 %      creation of an argus file newprofile
0008 %
0009 %   expmaster(newprofile,oldprofile)
0010 %      the modification of the file oldprofile will be saved in newprofile
0011 %
0012 %   expmaster(newprofile,oldprofile1,oldprofile2,...)
0013 %      the modification of the files oldprofile* will be saved in newprofile
0014 %
0015 %   Usage:
0016 %      expmaster(newfile,varargin)
0017 %
0018 %   See also EXPDOC
0019 
0020 %Some checks
0021 if ~nargin | nargout
0022     error('expmaster usage: expmaster(newfile,varargin)')
0023 elseif exist(newfile),
0024     choice=input(['A file ' newfile ' already exists, do you want to modify it? (y/n)'],'s');
0025     if ~strcmpi(choice,'y'),
0026         error('no modification done ... exiting');
0027     end
0028 end
0029 
0030 %put all the argus profiles given in input in one structure A
0031 A=struct([]);
0032 numprofiles=0;
0033 numpoints=0;
0034 closed=[];
0035 if nargin>1,
0036     isexist=1;
0037     for i=1:nargin-1
0038         filename=varargin{i};
0039         if ~exist(filename),
0040             error(['expmaster error message:, ' filename ' does not exist. Exiting...']);
0041         else
0042             %read file
0043             B=expread(filename,1);
0044             %go through all profiles of B
0045             for i=1:size(B,2)
0046                 %plug profile in A
0047                 if numprofiles
0048                     A(numprofiles+1)=B(i);
0049                 else
0050                     A=B(i);
0051                 end
0052                 %update numprofiles and numpoints
0053                 numpoints=numpoints+length(B(i).x);
0054                 numprofiles=numprofiles+1;
0055                 %figure out if the profile is closed or not
0056                 if (B(i).x(1)==B(i).x(end) & B(i).y(1)==B(i).y(end))
0057                     closed(numprofiles)=1;
0058                 else
0059                     closed(numprofiles)=0;
0060                 end
0061             end
0062         end
0063     end
0064 else
0065     isexist=0;
0066 end
0067 
0068 %Get root of newfile
0069 [path root ext ver]=fileparts(newfile);
0070 
0071 %Figure out how nany plots have been done so far
0072 g=get(gca,'children'); 
0073 prevplot=length(g);
0074 prevplot2=prevplot;
0075 
0076 %plot existing profile if any
0077 hold on
0078 if numprofiles
0079     for i=1:numprofiles
0080         plot(A(i).x,A(i).y,'-r','MarkerSize',10);
0081         prevplot2=prevplot2+1;
0082     end
0083 end
0084 
0085 %Build backup structre for do and redo
0086 backup=cell(1,3);
0087 backup{1,1}=A;
0088 backup{1,2}=numprofiles;
0089 backup{1,3}=numpoints;
0090 backup{1,4}=closed;
0091 
0092 loop=1;
0093 counter=1;
0094 while loop
0095 
0096     %is there a profile in A?
0097     if isexist
0098 
0099         %Go through A and rule out the empty profiles
0100         list=[];
0101         for i=1:size(A,2);
0102             if length(A(i).x)==0
0103                 list(end+1)=i;
0104                 numprofiles=numprofiles-1;
0105             end
0106         end
0107         A(list)=[];
0108         closed(list)=[];
0109 
0110         %display menu
0111         title('Main Menu','FontSize',14);
0112         button=menu('Menu','add a profile',...  %1
0113         'remove a profile',...                  %2
0114         'modify the position of a point',...    %3
0115         'add points inside a profile',...       %4
0116         'add points at the end of a profile',...%5
0117         'remove points',...                     %6
0118         'remove several points',...             %7
0119         'cut a segment',...                     %8
0120         'cut a large area',...                  %9
0121         'merge profiles',...                    %10
0122         'close profile',...                     %11
0123         'undo',...                              %12
0124         'redo',...                              %13
0125         'quit');                                %14
0126 
0127 
0128         %UNDO??
0129         if button==12;
0130             if counter==1
0131                 disp('Already at oldest change');
0132             else
0133                 counter=counter-1;
0134                 A=backup{counter,1};
0135                 numprofiles=backup{counter,2};
0136                 numpoints=backup{counter,3};
0137                 closed=backup{counter,4};
0138             end
0139         end
0140 
0141         %REDO??
0142         if button==13
0143             if counter==size(backup,1)
0144                 disp('Already at newest change');
0145             else
0146                 counter=counter+1;
0147                 A=backup{counter,1};
0148                 numprofiles=backup{counter,2};
0149                 numpoints=backup{counter,3};
0150                 closed=backup{counter,4};
0151             end
0152         end
0153 
0154         switch button
0155 
0156         case 1
0157 
0158             [A,numprofiles,numpoints,closed]=addprofile(A,numprofiles,numpoints,closed,prevplot2,root);
0159             counter=counter+1;
0160             backup{counter,1}=A;
0161             backup{counter,2}=numprofiles;
0162             backup{counter,3}=numpoints;
0163             backup{counter,4}=closed;
0164 
0165         case 2
0166 
0167             [A,numprofiles,numpoints,closed]=removeprofile(A,numprofiles,numpoints,closed,prevplot2,root);
0168             counter=counter+1;
0169             backup{counter,1}=A;
0170             backup{counter,2}=numprofiles;
0171             backup{counter,3}=numpoints;
0172             backup{counter,4}=closed;
0173 
0174         case 3
0175 
0176             [A,numprofiles,numpoints,closed]=modifyposition(A,numprofiles,numpoints,closed,prevplot,root);
0177             counter=counter+1;
0178             backup{counter,1}=A;
0179             backup{counter,2}=numprofiles;
0180             backup{counter,3}=numpoints;
0181             backup{counter,4}=closed;
0182 
0183         case 4
0184 
0185             [A,numprofiles,numpoints,closed]=addinsideprofile(A,numprofiles,numpoints,closed,prevplot,root);
0186             counter=counter+1;
0187             backup{counter,1}=A;
0188             backup{counter,2}=numprofiles;
0189             backup{counter,3}=numpoints;
0190             backup{counter,4}=closed;
0191 
0192         case 5
0193 
0194             [A,numprofiles,numpoints,closed]=addendprofile(A,numprofiles,numpoints,closed,prevplot2,root);
0195             counter=counter+1;
0196             backup{counter,1}=A;
0197             backup{counter,2}=numprofiles;
0198             backup{counter,3}=numpoints;
0199             backup{counter,4}=closed;
0200 
0201         case 6
0202 
0203             [A,numprofiles,numpoints,closed]=removepoints(A,numprofiles,numpoints,closed,prevplot,root);
0204             counter=counter+1;
0205             backup{counter,1}=A;
0206             backup{counter,2}=numprofiles;
0207             backup{counter,3}=numpoints;
0208             backup{counter,4}=closed;
0209 
0210         case 7
0211 
0212             [A,numprofiles,numpoints,closed]=removeseveralpoints(A,numprofiles,numpoints,closed,prevplot,root);
0213             counter=counter+1;
0214             backup{counter,1}=A;
0215             backup{counter,2}=numprofiles;
0216             backup{counter,3}=numpoints;
0217             backup{counter,4}=closed;
0218 
0219         case 8
0220 
0221             [A,numprofiles,numpoints,closed]=cutprofile(A,numprofiles,numpoints,closed,prevplot,root);
0222             counter=counter+1;
0223             backup{counter,1}=A;
0224             backup{counter,2}=numprofiles;
0225             backup{counter,3}=numpoints;
0226             backup{counter,4}=closed;
0227 
0228         case 9
0229 
0230             [A,numprofiles,numpoints,closed]=cutarea(A,numprofiles,numpoints,closed,prevplot,root);
0231             counter=counter+1;
0232             backup{counter,1}=A;
0233             backup{counter,2}=numprofiles;
0234             backup{counter,3}=numpoints;
0235             backup{counter,4}=closed;
0236 
0237         case 10
0238 
0239             [A,numprofiles,numpoints,closed]=mergeprofiles(A,numprofiles,numpoints,closed,prevplot,root);
0240             counter=counter+1;
0241             backup{counter,1}=A;
0242             backup{counter,2}=numprofiles;
0243             backup{counter,3}=numpoints;
0244             backup{counter,4}=closed;
0245 
0246 
0247         case 11
0248 
0249             [A,numprofiles,numpoints,closed]=closeprofile(A,numprofiles,numpoints,closed,prevplot,root);
0250             counter=counter+1;
0251             backup{counter,1}=A;
0252             backup{counter,2}=numprofiles;
0253             backup{counter,3}=numpoints;
0254             backup{counter,4}=closed;
0255 
0256         %QUIT
0257         case 14
0258 
0259             loop=0;
0260 
0261         otherwise
0262 
0263             %do nothing
0264 
0265         end
0266 
0267     %no argus file has been given in input, go to addcontour directly
0268     else
0269         [A,numprofiles,numpoints,closed]=addprofile(A,numprofiles,numpoints,closed,prevplot2,root);
0270         counter=counter+1;
0271         backup{counter,1}=A;
0272         backup{counter,2}=numprofiles;
0273         backup{counter,3}=numpoints;
0274         backup{counter,4}=closed;
0275         isexist=1;
0276      end
0277 
0278      %Now erase all that have been done and plot the new structure A as it is
0279      undoplots(prevplot);
0280     if numprofiles
0281         for i=1:numprofiles
0282             plot(A(i).x,A(i).y,'-r','MarkerSize',10);
0283             prevplot2=prevplot2+1;
0284         end
0285     end
0286 end
0287 
0288 hold off
0289 
0290 %write contour using expwrite
0291 title('New file written, exiting','FontSize',14);
0292 if isempty(A)
0293     disp('Profile empty, no file written')
0294 else
0295     expwrite(A,newfile);
0296 end

Generated on Sun 29-Mar-2009 20:22:55 by m2html © 2003