[1] | 1 | function expmaster(newfile,varargin)
|
---|
| 2 | %EXPMASTER - allow to create, modify, add, cut, .. segments of domain outline together
|
---|
| 3 | %
|
---|
| 4 | % this routine is used to create, modify, cut,... an Argus file (.exp)
|
---|
| 5 | %
|
---|
| 6 | % expmaster(newprofile)
|
---|
| 7 | % creation of an argus file newprofile
|
---|
| 8 | %
|
---|
| 9 | % expmaster(newprofile,oldprofile)
|
---|
| 10 | % the modification of the file oldprofile will be saved in newprofile
|
---|
| 11 | %
|
---|
| 12 | % expmaster(newprofile,oldprofile1,oldprofile2,...)
|
---|
| 13 | % the modification of the files oldprofile* will be saved in newprofile
|
---|
| 14 | %
|
---|
| 15 | % Usage:
|
---|
| 16 | % expmaster(newfile,varargin)
|
---|
| 17 | %
|
---|
| 18 | % See also EXPDOC
|
---|
| 19 |
|
---|
| 20 | %Some checks
|
---|
| 21 | if ~nargin | nargout
|
---|
| 22 | error('expmaster usage: expmaster(newfile,varargin)')
|
---|
| 23 | elseif exist(newfile),
|
---|
| 24 | choice=input(['A file ' newfile ' already exists, do you want to modify it? (y/n)'],'s');
|
---|
| 25 | if ~strcmpi(choice,'y'),
|
---|
| 26 | error('no modification done ... exiting');
|
---|
| 27 | end
|
---|
| 28 | end
|
---|
| 29 |
|
---|
| 30 | %put all the argus profiles given in input in one structure A
|
---|
| 31 | A=struct([]);
|
---|
| 32 | numprofiles=0;
|
---|
| 33 | numpoints=0;
|
---|
| 34 | closed=[];
|
---|
[33] | 35 | for i=1:nargin-1
|
---|
| 36 | filename=varargin{i};
|
---|
| 37 | if ~exist(filename),
|
---|
| 38 | error(['expmaster error message:, ' filename ' does not exist. Exiting...']);
|
---|
| 39 | else
|
---|
| 40 | %read file
|
---|
| 41 | B=expread(filename,1);
|
---|
| 42 | %go through all profiles of B
|
---|
| 43 | for i=1:size(B,2)
|
---|
| 44 | %plug profile in A
|
---|
| 45 | if numprofiles
|
---|
| 46 | A(numprofiles+1)=B(i);
|
---|
| 47 | else
|
---|
| 48 | A=B(i);
|
---|
[1] | 49 | end
|
---|
[33] | 50 | %update numprofiles and numpoints
|
---|
| 51 | numpoints=numpoints+length(B(i).x);
|
---|
| 52 | numprofiles=numprofiles+1;
|
---|
| 53 | %figure out if the profile is closed or not
|
---|
| 54 | if (B(i).x(1)==B(i).x(end) & B(i).y(1)==B(i).y(end))
|
---|
| 55 | closed(numprofiles)=1;
|
---|
| 56 | else
|
---|
| 57 | closed(numprofiles)=0;
|
---|
| 58 | end
|
---|
[1] | 59 | end
|
---|
| 60 | end
|
---|
| 61 | end
|
---|
| 62 |
|
---|
| 63 | %Get root of newfile
|
---|
| 64 | [path root ext ver]=fileparts(newfile);
|
---|
| 65 |
|
---|
[33] | 66 | %get current figure
|
---|
[285] | 67 | if ~isempty(get(0,'children')),%if there is already a figure (return the number of opened figures)
|
---|
| 68 | set(gcf,'Renderer','zbuffer'); %fixes a bug on Mac OS X (not needed in future Matlab version)
|
---|
| 69 | F=getframe(gca);
|
---|
| 70 | F=F.cdata;
|
---|
| 71 | %get current axis
|
---|
| 72 | xlim=get(gca,'Xlim');
|
---|
| 73 | ylim=get(gca,'Ylim');
|
---|
| 74 | %recreate x_m and y_m
|
---|
| 75 | x_m=linspace(xlim(1),xlim(2),size(F,2));
|
---|
| 76 | y_m=linspace(ylim(2),ylim(1),size(F,1)); %getframe reverse axis...
|
---|
| 77 | %plot the data in another figure
|
---|
| 78 | figure
|
---|
| 79 | imagesc(x_m,y_m,F); set(gca,'Ydir','normal');
|
---|
[897] | 80 | prevplot=1;
|
---|
| 81 | prevplot2=1;
|
---|
[285] | 82 | else
|
---|
| 83 | figure
|
---|
[897] | 84 | prevplot=0;
|
---|
| 85 | prevplot2=0;
|
---|
[285] | 86 | end
|
---|
[1] | 87 |
|
---|
| 88 | %plot existing profile if any
|
---|
[897] | 89 |
|
---|
[1] | 90 | hold on
|
---|
| 91 | if numprofiles
|
---|
| 92 | for i=1:numprofiles
|
---|
| 93 | plot(A(i).x,A(i).y,'-r','MarkerSize',10);
|
---|
| 94 | end
|
---|
| 95 | end
|
---|
| 96 |
|
---|
| 97 | %Build backup structre for do and redo
|
---|
| 98 | backup=cell(1,3);
|
---|
| 99 | backup{1,1}=A;
|
---|
| 100 | backup{1,2}=numprofiles;
|
---|
| 101 | backup{1,3}=numpoints;
|
---|
| 102 | backup{1,4}=closed;
|
---|
| 103 |
|
---|
| 104 | loop=1;
|
---|
| 105 | counter=1;
|
---|
| 106 | while loop
|
---|
| 107 |
|
---|
[33] | 108 | %Go through A and rule out the empty profiles
|
---|
| 109 | list=[];
|
---|
| 110 | for i=1:size(A,2);
|
---|
| 111 | if length(A(i).x)==0
|
---|
| 112 | list(end+1)=i;
|
---|
| 113 | numprofiles=numprofiles-1;
|
---|
[1] | 114 | end
|
---|
[33] | 115 | end
|
---|
| 116 | A(list)=[];
|
---|
| 117 | closed(list)=[];
|
---|
[1] | 118 |
|
---|
[33] | 119 | %display menu
|
---|
| 120 | title('Main Menu','FontSize',14);
|
---|
| 121 | button=menu('Menu','add a profile (open)',...%1
|
---|
| 122 | 'add a contour (closed)',... %2
|
---|
| 123 | 'remove a profile',... %3
|
---|
| 124 | 'modify the position of a point',... %4
|
---|
| 125 | 'add points inside a profile',... %5
|
---|
| 126 | 'add points at the end of a profile',... %6
|
---|
| 127 | 'remove points',... %7
|
---|
| 128 | 'remove several points',... %8
|
---|
| 129 | 'cut a segment',... %9
|
---|
| 130 | 'cut a large area',... %10
|
---|
| 131 | 'merge profiles',... %11
|
---|
| 132 | 'close profile',... %12
|
---|
| 133 | 'undo',... %13
|
---|
| 134 | 'redo',... %14
|
---|
| 135 | 'quit'); %15
|
---|
[1] | 136 |
|
---|
| 137 |
|
---|
[33] | 138 | %UNDO??
|
---|
| 139 | if button==13;
|
---|
| 140 | if counter==1
|
---|
| 141 | disp('Already at oldest change');
|
---|
| 142 | else
|
---|
| 143 | counter=counter-1;
|
---|
| 144 | A=backup{counter,1};
|
---|
| 145 | numprofiles=backup{counter,2};
|
---|
| 146 | numpoints=backup{counter,3};
|
---|
| 147 | closed=backup{counter,4};
|
---|
[1] | 148 | end
|
---|
[33] | 149 | end
|
---|
[1] | 150 |
|
---|
[33] | 151 | %REDO??
|
---|
| 152 | if button==14
|
---|
| 153 | if counter==size(backup,1)
|
---|
| 154 | disp('Already at newest change');
|
---|
| 155 | else
|
---|
| 156 | counter=counter+1;
|
---|
| 157 | A=backup{counter,1};
|
---|
| 158 | numprofiles=backup{counter,2};
|
---|
| 159 | numpoints=backup{counter,3};
|
---|
| 160 | closed=backup{counter,4};
|
---|
[1] | 161 | end
|
---|
[33] | 162 | end
|
---|
[1] | 163 |
|
---|
[33] | 164 | switch button
|
---|
[1] | 165 |
|
---|
| 166 | case 1
|
---|
| 167 |
|
---|
| 168 | [A,numprofiles,numpoints,closed]=addprofile(A,numprofiles,numpoints,closed,prevplot2,root);
|
---|
| 169 | counter=counter+1;
|
---|
| 170 | backup{counter,1}=A;
|
---|
| 171 | backup{counter,2}=numprofiles;
|
---|
| 172 | backup{counter,3}=numpoints;
|
---|
| 173 | backup{counter,4}=closed;
|
---|
| 174 |
|
---|
| 175 | case 2
|
---|
| 176 |
|
---|
[33] | 177 | [A,numprofiles,numpoints,closed]=addcontour(A,numprofiles,numpoints,closed,prevplot2,root);
|
---|
[1] | 178 | counter=counter+1;
|
---|
| 179 | backup{counter,1}=A;
|
---|
| 180 | backup{counter,2}=numprofiles;
|
---|
| 181 | backup{counter,3}=numpoints;
|
---|
| 182 | backup{counter,4}=closed;
|
---|
| 183 |
|
---|
| 184 | case 3
|
---|
| 185 |
|
---|
[33] | 186 | [A,numprofiles,numpoints,closed]=removeprofile(A,numprofiles,numpoints,closed,prevplot2,root);
|
---|
[1] | 187 | counter=counter+1;
|
---|
| 188 | backup{counter,1}=A;
|
---|
| 189 | backup{counter,2}=numprofiles;
|
---|
| 190 | backup{counter,3}=numpoints;
|
---|
| 191 | backup{counter,4}=closed;
|
---|
| 192 |
|
---|
| 193 | case 4
|
---|
| 194 |
|
---|
[33] | 195 | [A,numprofiles,numpoints,closed]=modifyposition(A,numprofiles,numpoints,closed,prevplot,root);
|
---|
[1] | 196 | counter=counter+1;
|
---|
| 197 | backup{counter,1}=A;
|
---|
| 198 | backup{counter,2}=numprofiles;
|
---|
| 199 | backup{counter,3}=numpoints;
|
---|
| 200 | backup{counter,4}=closed;
|
---|
| 201 |
|
---|
| 202 | case 5
|
---|
| 203 |
|
---|
[33] | 204 | [A,numprofiles,numpoints,closed]=addinsideprofile(A,numprofiles,numpoints,closed,prevplot,root);
|
---|
[1] | 205 | counter=counter+1;
|
---|
| 206 | backup{counter,1}=A;
|
---|
| 207 | backup{counter,2}=numprofiles;
|
---|
| 208 | backup{counter,3}=numpoints;
|
---|
| 209 | backup{counter,4}=closed;
|
---|
| 210 |
|
---|
| 211 | case 6
|
---|
| 212 |
|
---|
[33] | 213 | [A,numprofiles,numpoints,closed]=addendprofile(A,numprofiles,numpoints,closed,prevplot2,root);
|
---|
[1] | 214 | counter=counter+1;
|
---|
| 215 | backup{counter,1}=A;
|
---|
| 216 | backup{counter,2}=numprofiles;
|
---|
| 217 | backup{counter,3}=numpoints;
|
---|
| 218 | backup{counter,4}=closed;
|
---|
| 219 |
|
---|
| 220 | case 7
|
---|
| 221 |
|
---|
[33] | 222 | [A,numprofiles,numpoints,closed]=removepoints(A,numprofiles,numpoints,closed,prevplot,root);
|
---|
[1] | 223 | counter=counter+1;
|
---|
| 224 | backup{counter,1}=A;
|
---|
| 225 | backup{counter,2}=numprofiles;
|
---|
| 226 | backup{counter,3}=numpoints;
|
---|
| 227 | backup{counter,4}=closed;
|
---|
| 228 |
|
---|
| 229 | case 8
|
---|
| 230 |
|
---|
[33] | 231 | [A,numprofiles,numpoints,closed]=removeseveralpoints(A,numprofiles,numpoints,closed,prevplot,root);
|
---|
[1] | 232 | counter=counter+1;
|
---|
| 233 | backup{counter,1}=A;
|
---|
| 234 | backup{counter,2}=numprofiles;
|
---|
| 235 | backup{counter,3}=numpoints;
|
---|
| 236 | backup{counter,4}=closed;
|
---|
| 237 |
|
---|
| 238 | case 9
|
---|
| 239 |
|
---|
[33] | 240 | [A,numprofiles,numpoints,closed]=cutprofile(A,numprofiles,numpoints,closed,prevplot,root);
|
---|
[1] | 241 | counter=counter+1;
|
---|
| 242 | backup{counter,1}=A;
|
---|
| 243 | backup{counter,2}=numprofiles;
|
---|
| 244 | backup{counter,3}=numpoints;
|
---|
| 245 | backup{counter,4}=closed;
|
---|
| 246 |
|
---|
| 247 | case 10
|
---|
| 248 |
|
---|
[33] | 249 | [A,numprofiles,numpoints,closed]=cutarea(A,numprofiles,numpoints,closed,prevplot,root);
|
---|
| 250 | counter=counter+1;
|
---|
| 251 | backup{counter,1}=A;
|
---|
| 252 | backup{counter,2}=numprofiles;
|
---|
| 253 | backup{counter,3}=numpoints;
|
---|
| 254 | backup{counter,4}=closed;
|
---|
| 255 |
|
---|
| 256 | case 11
|
---|
| 257 |
|
---|
[1] | 258 | [A,numprofiles,numpoints,closed]=mergeprofiles(A,numprofiles,numpoints,closed,prevplot,root);
|
---|
| 259 | counter=counter+1;
|
---|
| 260 | backup{counter,1}=A;
|
---|
| 261 | backup{counter,2}=numprofiles;
|
---|
| 262 | backup{counter,3}=numpoints;
|
---|
| 263 | backup{counter,4}=closed;
|
---|
| 264 |
|
---|
| 265 |
|
---|
[33] | 266 | case 12
|
---|
[1] | 267 |
|
---|
| 268 | [A,numprofiles,numpoints,closed]=closeprofile(A,numprofiles,numpoints,closed,prevplot,root);
|
---|
| 269 | counter=counter+1;
|
---|
| 270 | backup{counter,1}=A;
|
---|
| 271 | backup{counter,2}=numprofiles;
|
---|
| 272 | backup{counter,3}=numpoints;
|
---|
| 273 | backup{counter,4}=closed;
|
---|
| 274 |
|
---|
[33] | 275 | %QUIT
|
---|
| 276 | case 15
|
---|
[1] | 277 |
|
---|
| 278 | loop=0;
|
---|
| 279 |
|
---|
| 280 | otherwise
|
---|
| 281 |
|
---|
| 282 | %do nothing
|
---|
| 283 |
|
---|
[33] | 284 | end
|
---|
[1] | 285 |
|
---|
[33] | 286 | %Now erase all that have been done and plot the new structure A as it is
|
---|
| 287 | undoplots(prevplot);
|
---|
[1] | 288 | if numprofiles
|
---|
[33] | 289 | prevplot2=1;
|
---|
[1] | 290 | for i=1:numprofiles
|
---|
| 291 | plot(A(i).x,A(i).y,'-r','MarkerSize',10);
|
---|
| 292 | prevplot2=prevplot2+1;
|
---|
| 293 | end
|
---|
| 294 | end
|
---|
| 295 | end
|
---|
| 296 |
|
---|
| 297 | hold off
|
---|
| 298 |
|
---|
| 299 | %write contour using expwrite
|
---|
[33] | 300 | title('New file written, exiting...','FontSize',14);
|
---|
[1] | 301 | if isempty(A)
|
---|
| 302 | disp('Profile empty, no file written')
|
---|
| 303 | else
|
---|
| 304 | expwrite(A,newfile);
|
---|
| 305 | end
|
---|
[33] | 306 |
|
---|
| 307 | %close window
|
---|
| 308 | close;
|
---|