[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');
|
---|
| 80 | else
|
---|
| 81 | figure
|
---|
| 82 | end
|
---|
[1] | 83 |
|
---|
| 84 | %plot existing profile if any
|
---|
[33] | 85 | prevplot=1;
|
---|
| 86 | prevplot2=1;
|
---|
[1] | 87 | hold on
|
---|
| 88 | if numprofiles
|
---|
| 89 | for i=1:numprofiles
|
---|
| 90 | plot(A(i).x,A(i).y,'-r','MarkerSize',10);
|
---|
| 91 | end
|
---|
| 92 | end
|
---|
| 93 |
|
---|
| 94 | %Build backup structre for do and redo
|
---|
| 95 | backup=cell(1,3);
|
---|
| 96 | backup{1,1}=A;
|
---|
| 97 | backup{1,2}=numprofiles;
|
---|
| 98 | backup{1,3}=numpoints;
|
---|
| 99 | backup{1,4}=closed;
|
---|
| 100 |
|
---|
| 101 | loop=1;
|
---|
| 102 | counter=1;
|
---|
| 103 | while loop
|
---|
| 104 |
|
---|
[33] | 105 | %Go through A and rule out the empty profiles
|
---|
| 106 | list=[];
|
---|
| 107 | for i=1:size(A,2);
|
---|
| 108 | if length(A(i).x)==0
|
---|
| 109 | list(end+1)=i;
|
---|
| 110 | numprofiles=numprofiles-1;
|
---|
[1] | 111 | end
|
---|
[33] | 112 | end
|
---|
| 113 | A(list)=[];
|
---|
| 114 | closed(list)=[];
|
---|
[1] | 115 |
|
---|
[33] | 116 | %display menu
|
---|
| 117 | title('Main Menu','FontSize',14);
|
---|
| 118 | button=menu('Menu','add a profile (open)',...%1
|
---|
| 119 | 'add a contour (closed)',... %2
|
---|
| 120 | 'remove a profile',... %3
|
---|
| 121 | 'modify the position of a point',... %4
|
---|
| 122 | 'add points inside a profile',... %5
|
---|
| 123 | 'add points at the end of a profile',... %6
|
---|
| 124 | 'remove points',... %7
|
---|
| 125 | 'remove several points',... %8
|
---|
| 126 | 'cut a segment',... %9
|
---|
| 127 | 'cut a large area',... %10
|
---|
| 128 | 'merge profiles',... %11
|
---|
| 129 | 'close profile',... %12
|
---|
| 130 | 'undo',... %13
|
---|
| 131 | 'redo',... %14
|
---|
| 132 | 'quit'); %15
|
---|
[1] | 133 |
|
---|
| 134 |
|
---|
[33] | 135 | %UNDO??
|
---|
| 136 | if button==13;
|
---|
| 137 | if counter==1
|
---|
| 138 | disp('Already at oldest change');
|
---|
| 139 | else
|
---|
| 140 | counter=counter-1;
|
---|
| 141 | A=backup{counter,1};
|
---|
| 142 | numprofiles=backup{counter,2};
|
---|
| 143 | numpoints=backup{counter,3};
|
---|
| 144 | closed=backup{counter,4};
|
---|
[1] | 145 | end
|
---|
[33] | 146 | end
|
---|
[1] | 147 |
|
---|
[33] | 148 | %REDO??
|
---|
| 149 | if button==14
|
---|
| 150 | if counter==size(backup,1)
|
---|
| 151 | disp('Already at newest change');
|
---|
| 152 | else
|
---|
| 153 | counter=counter+1;
|
---|
| 154 | A=backup{counter,1};
|
---|
| 155 | numprofiles=backup{counter,2};
|
---|
| 156 | numpoints=backup{counter,3};
|
---|
| 157 | closed=backup{counter,4};
|
---|
[1] | 158 | end
|
---|
[33] | 159 | end
|
---|
[1] | 160 |
|
---|
[33] | 161 | switch button
|
---|
[1] | 162 |
|
---|
| 163 | case 1
|
---|
| 164 |
|
---|
| 165 | [A,numprofiles,numpoints,closed]=addprofile(A,numprofiles,numpoints,closed,prevplot2,root);
|
---|
| 166 | counter=counter+1;
|
---|
| 167 | backup{counter,1}=A;
|
---|
| 168 | backup{counter,2}=numprofiles;
|
---|
| 169 | backup{counter,3}=numpoints;
|
---|
| 170 | backup{counter,4}=closed;
|
---|
| 171 |
|
---|
| 172 | case 2
|
---|
| 173 |
|
---|
[33] | 174 | [A,numprofiles,numpoints,closed]=addcontour(A,numprofiles,numpoints,closed,prevplot2,root);
|
---|
[1] | 175 | counter=counter+1;
|
---|
| 176 | backup{counter,1}=A;
|
---|
| 177 | backup{counter,2}=numprofiles;
|
---|
| 178 | backup{counter,3}=numpoints;
|
---|
| 179 | backup{counter,4}=closed;
|
---|
| 180 |
|
---|
| 181 | case 3
|
---|
| 182 |
|
---|
[33] | 183 | [A,numprofiles,numpoints,closed]=removeprofile(A,numprofiles,numpoints,closed,prevplot2,root);
|
---|
[1] | 184 | counter=counter+1;
|
---|
| 185 | backup{counter,1}=A;
|
---|
| 186 | backup{counter,2}=numprofiles;
|
---|
| 187 | backup{counter,3}=numpoints;
|
---|
| 188 | backup{counter,4}=closed;
|
---|
| 189 |
|
---|
| 190 | case 4
|
---|
| 191 |
|
---|
[33] | 192 | [A,numprofiles,numpoints,closed]=modifyposition(A,numprofiles,numpoints,closed,prevplot,root);
|
---|
[1] | 193 | counter=counter+1;
|
---|
| 194 | backup{counter,1}=A;
|
---|
| 195 | backup{counter,2}=numprofiles;
|
---|
| 196 | backup{counter,3}=numpoints;
|
---|
| 197 | backup{counter,4}=closed;
|
---|
| 198 |
|
---|
| 199 | case 5
|
---|
| 200 |
|
---|
[33] | 201 | [A,numprofiles,numpoints,closed]=addinsideprofile(A,numprofiles,numpoints,closed,prevplot,root);
|
---|
[1] | 202 | counter=counter+1;
|
---|
| 203 | backup{counter,1}=A;
|
---|
| 204 | backup{counter,2}=numprofiles;
|
---|
| 205 | backup{counter,3}=numpoints;
|
---|
| 206 | backup{counter,4}=closed;
|
---|
| 207 |
|
---|
| 208 | case 6
|
---|
| 209 |
|
---|
[33] | 210 | [A,numprofiles,numpoints,closed]=addendprofile(A,numprofiles,numpoints,closed,prevplot2,root);
|
---|
[1] | 211 | counter=counter+1;
|
---|
| 212 | backup{counter,1}=A;
|
---|
| 213 | backup{counter,2}=numprofiles;
|
---|
| 214 | backup{counter,3}=numpoints;
|
---|
| 215 | backup{counter,4}=closed;
|
---|
| 216 |
|
---|
| 217 | case 7
|
---|
| 218 |
|
---|
[33] | 219 | [A,numprofiles,numpoints,closed]=removepoints(A,numprofiles,numpoints,closed,prevplot,root);
|
---|
[1] | 220 | counter=counter+1;
|
---|
| 221 | backup{counter,1}=A;
|
---|
| 222 | backup{counter,2}=numprofiles;
|
---|
| 223 | backup{counter,3}=numpoints;
|
---|
| 224 | backup{counter,4}=closed;
|
---|
| 225 |
|
---|
| 226 | case 8
|
---|
| 227 |
|
---|
[33] | 228 | [A,numprofiles,numpoints,closed]=removeseveralpoints(A,numprofiles,numpoints,closed,prevplot,root);
|
---|
[1] | 229 | counter=counter+1;
|
---|
| 230 | backup{counter,1}=A;
|
---|
| 231 | backup{counter,2}=numprofiles;
|
---|
| 232 | backup{counter,3}=numpoints;
|
---|
| 233 | backup{counter,4}=closed;
|
---|
| 234 |
|
---|
| 235 | case 9
|
---|
| 236 |
|
---|
[33] | 237 | [A,numprofiles,numpoints,closed]=cutprofile(A,numprofiles,numpoints,closed,prevplot,root);
|
---|
[1] | 238 | counter=counter+1;
|
---|
| 239 | backup{counter,1}=A;
|
---|
| 240 | backup{counter,2}=numprofiles;
|
---|
| 241 | backup{counter,3}=numpoints;
|
---|
| 242 | backup{counter,4}=closed;
|
---|
| 243 |
|
---|
| 244 | case 10
|
---|
| 245 |
|
---|
[33] | 246 | [A,numprofiles,numpoints,closed]=cutarea(A,numprofiles,numpoints,closed,prevplot,root);
|
---|
| 247 | counter=counter+1;
|
---|
| 248 | backup{counter,1}=A;
|
---|
| 249 | backup{counter,2}=numprofiles;
|
---|
| 250 | backup{counter,3}=numpoints;
|
---|
| 251 | backup{counter,4}=closed;
|
---|
| 252 |
|
---|
| 253 | case 11
|
---|
| 254 |
|
---|
[1] | 255 | [A,numprofiles,numpoints,closed]=mergeprofiles(A,numprofiles,numpoints,closed,prevplot,root);
|
---|
| 256 | counter=counter+1;
|
---|
| 257 | backup{counter,1}=A;
|
---|
| 258 | backup{counter,2}=numprofiles;
|
---|
| 259 | backup{counter,3}=numpoints;
|
---|
| 260 | backup{counter,4}=closed;
|
---|
| 261 |
|
---|
| 262 |
|
---|
[33] | 263 | case 12
|
---|
[1] | 264 |
|
---|
| 265 | [A,numprofiles,numpoints,closed]=closeprofile(A,numprofiles,numpoints,closed,prevplot,root);
|
---|
| 266 | counter=counter+1;
|
---|
| 267 | backup{counter,1}=A;
|
---|
| 268 | backup{counter,2}=numprofiles;
|
---|
| 269 | backup{counter,3}=numpoints;
|
---|
| 270 | backup{counter,4}=closed;
|
---|
| 271 |
|
---|
[33] | 272 | %QUIT
|
---|
| 273 | case 15
|
---|
[1] | 274 |
|
---|
| 275 | loop=0;
|
---|
| 276 |
|
---|
| 277 | otherwise
|
---|
| 278 |
|
---|
| 279 | %do nothing
|
---|
| 280 |
|
---|
[33] | 281 | end
|
---|
[1] | 282 |
|
---|
[33] | 283 | %Now erase all that have been done and plot the new structure A as it is
|
---|
| 284 | undoplots(prevplot);
|
---|
[1] | 285 | if numprofiles
|
---|
[33] | 286 | prevplot2=1;
|
---|
[1] | 287 | for i=1:numprofiles
|
---|
| 288 | plot(A(i).x,A(i).y,'-r','MarkerSize',10);
|
---|
| 289 | prevplot2=prevplot2+1;
|
---|
| 290 | end
|
---|
| 291 | end
|
---|
| 292 | end
|
---|
| 293 |
|
---|
| 294 | hold off
|
---|
| 295 |
|
---|
| 296 | %write contour using expwrite
|
---|
[33] | 297 | title('New file written, exiting...','FontSize',14);
|
---|
[1] | 298 | if isempty(A)
|
---|
| 299 | disp('Profile empty, no file written')
|
---|
| 300 | else
|
---|
| 301 | expwrite(A,newfile);
|
---|
| 302 | end
|
---|
[33] | 303 |
|
---|
| 304 | %close window
|
---|
| 305 | close;
|
---|