[60] | 1 |
|
---|
| 2 | %'view_field': function associated with the GUI 'view_field.fig' for images and data field visualization
|
---|
| 3 | %------------------------------------------------------------------------
|
---|
| 4 | % function huvmat=view_field(input)
|
---|
| 5 | %
|
---|
| 6 | %OUTPUT
|
---|
| 7 | % huvmat=current handles of the GUI view_field.fig
|
---|
| 8 | %%
|
---|
| 9 | %
|
---|
| 10 | %INPUT:
|
---|
| 11 | % input: input file name (if character chain), or input image matrix to
|
---|
| 12 | % visualize, or Matlab structure representing netcdf fields (with fields
|
---|
| 13 | % ListVarName....)
|
---|
| 14 | %
|
---|
| 15 | %AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
|
---|
| 16 | % Copyright Joel Sommeria, 2008, LEGI / CNRS-UJF-INPG, joel.sommeria@legi.grenoble-inp.fr.
|
---|
| 17 | %AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
|
---|
| 18 | % This open is part of the toolbox VIEW_FIELD.
|
---|
| 19 | %
|
---|
| 20 | % VIEW_FIELD is free software; you can redistribute it and/or modify
|
---|
| 21 | % it under the terms of the GNU General Public License as published by
|
---|
| 22 | % the Free Software Foundation; either version 2 of the License, or
|
---|
| 23 | % (at your option) any later version.
|
---|
| 24 | %
|
---|
| 25 | % VIEW_FIELD is distributed in the hope that it will be useful,
|
---|
| 26 | % but WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
| 27 | % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
---|
| 28 | % GNU General Public License (open VIEW_FIELD/COPYING.txt) for more details.
|
---|
| 29 | %AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
|
---|
| 30 |
|
---|
| 31 | %-------------------------------------------------------------------
|
---|
| 32 | % I - MAIN FUNCTION VIEW_FIELD (DO NOT MODIFY)
|
---|
| 33 | %-------------------------------------------------------------------
|
---|
| 34 | %-------------------------------------------------------------------
|
---|
| 35 | function varargout = view_field(varargin)
|
---|
| 36 |
|
---|
| 37 | % Begin initialization code - DO NOT EDIT
|
---|
| 38 | gui_Singleton = 1;
|
---|
| 39 | gui_State = struct('gui_Name', mfilename, ...
|
---|
| 40 | 'gui_Singleton', gui_Singleton, ...
|
---|
| 41 | 'gui_OpeningFcn', @view_field_OpeningFcn, ...
|
---|
| 42 | 'gui_OutputFcn', @view_field_OutputFcn, ...
|
---|
| 43 | 'gui_LayoutFcn', [], ...
|
---|
| 44 | 'gui_Callback', []);
|
---|
| 45 | if nargin && ischar(varargin{1})
|
---|
| 46 | gui_State.gui_Callback = str2func(varargin{1});
|
---|
| 47 | end
|
---|
| 48 |
|
---|
| 49 | if nargout
|
---|
| 50 | varargout{1:nargout} = gui_mainfcn(gui_State, varargin{:});
|
---|
| 51 | else
|
---|
| 52 | gui_mainfcn(gui_State, varargin{:});
|
---|
| 53 | end
|
---|
| 54 | % End initialization code - DO NOT EDIT
|
---|
| 55 |
|
---|
| 56 | %-------------------------------------------------------------------
|
---|
| 57 | % --- Executes just before view_field is made visible.
|
---|
| 58 | function view_field_OpeningFcn(hObject, eventdata, handles, Field )
|
---|
| 59 | %-------------------------------------------------------------------
|
---|
| 60 |
|
---|
| 61 | % Choose default command menuline output for view_field
|
---|
| 62 | handles.output = handles.axes3;
|
---|
| 63 |
|
---|
| 64 | % Update handles structure
|
---|
| 65 | guidata(hObject, handles);
|
---|
| 66 |
|
---|
| 67 | dircur=pwd; %current working directory
|
---|
| 68 | dir_opening=dircur;
|
---|
| 69 |
|
---|
| 70 | % set the position of colorbar and ancillary GUIs:
|
---|
| 71 | set(hObject,'Units','Normalized')
|
---|
| 72 | handles_mouse=handles;
|
---|
| 73 | huvmat=findobj(allchild(0),'Name','uvmat');
|
---|
| 74 | hhuvmat=guidata(huvmat);
|
---|
[61] | 75 | set(hhuvmat.list_object_2,'Visible','on')
|
---|
| 76 | % handles_mouse.create=hhuvmat.create;
|
---|
[60] | 77 | handles_mouse.edit=hhuvmat.edit;
|
---|
[61] | 78 | pos_uvmat=get(huvmat,'Position');
|
---|
| 79 | pos_view_field(1)=pos_uvmat(1)+pos_uvmat(3)/2;
|
---|
| 80 | pos_view_field(2)=pos_uvmat(2)-pos_uvmat(3)/4;
|
---|
| 81 | pos_view_field(3:4)=pos_uvmat(3:4);
|
---|
| 82 | set(hObject,'Position',pos_view_field)
|
---|
[60] | 83 |
|
---|
[61] | 84 |
|
---|
| 85 |
|
---|
[60] | 86 | %functions for the mouse and keyboard
|
---|
| 87 | set(hObject,'KeyPressFcn',{'keyboard_callback',handles_mouse})%set keyboard action function
|
---|
| 88 | set(hObject,'WindowButtonMotionFcn',{'mouse_motion',handles_mouse})%set mouse action functio
|
---|
| 89 | set(hObject,'WindowButtonDownFcn',{'mouse_down'})%set mouse click action function
|
---|
| 90 | set(hObject,'WindowButtonUpFcn',{'mouse_up',handles_mouse})
|
---|
[67] | 91 | set(hObject,'CloseRequestFcn',{@closefcn})%
|
---|
[60] | 92 |
|
---|
| 93 | [PlotType,PlotParamOut,haxes]= plot_field(Field,handles.axes3)%,PlotParam,KeepLim,PosColorbar)
|
---|
[85] | 94 | 'TEST'
|
---|
| 95 | if isfield(PlotParamOut,'Vectors')
|
---|
| 96 | set(handles.VECT_title,'Visible','on')
|
---|
| 97 | end
|
---|
| 98 | handles
|
---|
| 99 | write_plot_param(handles,PlotParamOut);% update the display of the plotting parameters
|
---|
| 100 |
|
---|
[60] | 101 | %-------------------------------------------------------------------
|
---|
| 102 | % --- Outputs from this function are returned to the command menuline.
|
---|
| 103 | function varargout = view_field_OutputFcn(hObject, eventdata, handles)
|
---|
| 104 | varargout{1} = handles.output;% the only output argument is the handle to the GUI figure
|
---|
| 105 |
|
---|
[61] | 106 |
|
---|
[60] | 107 | %-------------------------------------------------------------------
|
---|
| 108 | %-------------------------------------------------------------------
|
---|
| 109 | % II - FUNCTIONS FOR INTRODUCING THE INPUT FILES
|
---|
| 110 | % automatically sets the global properties when the rootfile name is introduced
|
---|
| 111 | % then activate the view-field action if selected
|
---|
| 112 | % it is activated either by clicking on the RootPath window or by the
|
---|
| 113 | % browser
|
---|
| 114 | %------------------------------------------------------------------
|
---|
| 115 | %------------------------------------------------------------------
|
---|
| 116 |
|
---|
| 117 | %-------------------------------------------------------------------
|
---|
| 118 | function update_mask(handles,num_i1,num_j1)
|
---|
| 119 | %-------------------------------------------------------------------
|
---|
| 120 |
|
---|
| 121 | MaskData=get(handles.mask_test,'UserData');
|
---|
| 122 | if isfield(MaskData,'maskhandle')&& ishandle(MaskData.maskhandle)
|
---|
| 123 | uistack(MaskData.maskhandle,'top');
|
---|
| 124 | end
|
---|
| 125 | num_i1_mask=mod(num_i1-1,MaskData.NbSlice)+1;
|
---|
| 126 | [MaskName,mdetect]=name_generator(MaskData.Base,num_i1_mask,num_j1,'.png',MaskData.NomType);
|
---|
| 127 | huvmat=get(handles.mask_test,'parent');
|
---|
| 128 | UvData=get(huvmat,'UserData');
|
---|
| 129 |
|
---|
| 130 | %update mask image if the mask is new
|
---|
| 131 | if ~ (isfield(UvData,'MaskName') && isequal(UvData.MaskName,MaskName))
|
---|
| 132 | UvData.MaskName=MaskName; %update the recorded name on UvData
|
---|
| 133 | set(huvmat,'UserData',UvData);
|
---|
| 134 | if mdetect==0
|
---|
| 135 | if isfield(MaskData,'maskhandle')&& ishandle(MaskData.maskhandle)
|
---|
| 136 | delete(MaskData.maskhandle)
|
---|
| 137 | end
|
---|
| 138 | else
|
---|
| 139 | %read mask image
|
---|
| 140 | Mask.AName='image';
|
---|
| 141 | Mask.A=imread(MaskName);
|
---|
| 142 | npxy=size(Mask.A);
|
---|
| 143 | Mask.AX=[0.5 npxy(2)-0.5];
|
---|
| 144 | Mask.AY=[npxy(1)-0.5 0.5 ];
|
---|
| 145 | Mask.CoordType='px';
|
---|
| 146 | if isequal(get(handles.slices,'Value'),1)
|
---|
| 147 | NbSlice=str2num(get(handles.nb_slice,'String'));
|
---|
| 148 | num_i1=str2num(get(handles.i1,'String'));
|
---|
| 149 | Mask.ZIndex=mod(num_i1-1,NbSlice)+1;
|
---|
| 150 | end
|
---|
| 151 | %px to phys or other transform on field
|
---|
| 152 | menu_transform=get(handles.transform_fct,'String');
|
---|
| 153 | choice_value=get(handles.transform_fct,'Value');
|
---|
| 154 | transform_name=menu_transform{choice_value};%name of the transform fct given by the menu 'transform_fct'
|
---|
| 155 | transform_list=get(handles.transform_fct,'UserData');
|
---|
| 156 | transform=transform_list{choice_value};
|
---|
| 157 | if ~isequal(transform_name,'') && ~isequal(transform_name,'px')
|
---|
| 158 | if isfield(UvData,'XmlData') && isfield(UvData.XmlData,'GeometryCalib')%use geometry calib recorded from the ImaDoc xml file as first priority
|
---|
| 159 | Calib=UvData.XmlData.GeometryCalib;
|
---|
| 160 | Mask=transform(Mask,UvData.XmlData);
|
---|
| 161 | end
|
---|
| 162 | end
|
---|
| 163 | flagmask=Mask.A < 200;
|
---|
| 164 |
|
---|
| 165 | %make brown color image
|
---|
| 166 | imflag(:,:,1)=0.9*flagmask;
|
---|
| 167 | imflag(:,:,2)=0.7*flagmask;
|
---|
| 168 | imflag(:,:,3)=zeros(size(flagmask));
|
---|
| 169 |
|
---|
| 170 | %update mask image
|
---|
| 171 | hmask=[]; %default
|
---|
| 172 | if isfield(MaskData,'maskhandle')&& ishandle(MaskData.maskhandle)
|
---|
| 173 | hmask=MaskData.maskhandle;
|
---|
| 174 | end
|
---|
| 175 | if ~isempty(hmask)
|
---|
| 176 | set(hmask,'CData',imflag)
|
---|
| 177 | set(hmask,'AlphaData',flagmask*0.6)
|
---|
| 178 | set(hmask,'XData',Mask.AX);
|
---|
| 179 | set(hmask,'YData',Mask.AY);
|
---|
| 180 | % uistack(hmask,'top')
|
---|
| 181 | else
|
---|
| 182 | axes(handles.axes3)
|
---|
| 183 | hold on
|
---|
| 184 | MaskData.maskhandle=image(Mask.AX,Mask.AY,imflag,'Tag','mask','HitTest','off','AlphaData',0.6*flagmask);
|
---|
| 185 | % set(MaskData.maskhandle,'AlphaData',0.6*flagmask)
|
---|
| 186 | set(handles.mask_test,'UserData',MaskData)
|
---|
| 187 | end
|
---|
| 188 | end
|
---|
| 189 | end
|
---|
| 190 |
|
---|
| 191 |
|
---|
| 192 | %-------------------------------------------------------------------
|
---|
| 193 | function MenuExportFigure_Callback(hObject, eventdata, handles)
|
---|
| 194 | %-------------------------------------------------------------------
|
---|
| 195 | huvmat=get(handles.MenuExport,'parent');
|
---|
| 196 | UvData=get(huvmat,'UserData');
|
---|
| 197 | hfig=figure;
|
---|
| 198 | newaxes=copyobj(handles.axes3,hfig);
|
---|
| 199 | map=colormap(handles.axes3);
|
---|
| 200 | colormap(map);%transmit the current colormap to the zoom fig
|
---|
| 201 | colorbar
|
---|
| 202 |
|
---|
| 203 | %-------------------------------------------------------------------
|
---|
| 204 | %-------------------------------------------------------------------
|
---|
| 205 | % III - MAIN REFRESH FUNCTIONS : 'FRAME PLOT'
|
---|
| 206 | %-------------------------------------------------------------------
|
---|
| 207 | %-------------------------------------------------------------------
|
---|
| 208 |
|
---|
| 209 | %Executes on button press in runplus: make one step forward and call
|
---|
| 210 | %run0. The step forward is along the fields series 1 or 2 depending on
|
---|
| 211 | %the scan_i and scan_j check box (exclusive each other)
|
---|
| 212 | %-------------------------------------------------------------------
|
---|
| 213 | function runplus_Callback(hObject, eventdata, handles)
|
---|
| 214 | increment=str2num(get(handles.increment_scan,'String')); %get the field increment d
|
---|
| 215 | runpm(hObject,eventdata,handles,increment)
|
---|
| 216 |
|
---|
| 217 | %-------------------------------------------------------------------
|
---|
| 218 | %Executes on button press in runmin: make one step backward and call
|
---|
| 219 | %run0. The step backward is along the fields series 1 or 2 depending on
|
---|
| 220 | %the scan_i and scan_j check box (exclusive each other)
|
---|
| 221 | %-------------------------------------------------------------------
|
---|
| 222 | function runmin_Callback(hObject, eventdata, handles)
|
---|
| 223 | increment=-str2num(get(handles.increment_scan,'String')); %get the field increment d
|
---|
| 224 | runpm(hObject,eventdata,handles,increment)
|
---|
| 225 |
|
---|
| 226 | %-------------------------------------------------------------------
|
---|
| 227 | %Executes on button press in runmin: make one step backward and call
|
---|
| 228 | %run0. The step backward is along the fields series 1 or 2 depending on
|
---|
| 229 | %the scan_i and scan_j check box (exclusive each other)
|
---|
| 230 | %-------------------------------------------------------------------
|
---|
| 231 | function RunMovie_Callback(hObject, eventdata, handles)
|
---|
| 232 | %------------------------------------------------------------------
|
---|
| 233 | set(handles.RunMovie,'BackgroundColor',[1 1 0])%paint the command button in yellow
|
---|
| 234 | drawnow
|
---|
| 235 | increment=str2num(get(handles.increment_scan,'String')); %get the field increment d
|
---|
| 236 | set(handles.STOP,'Visible','on')
|
---|
| 237 | set(handles.speed,'Visible','on')
|
---|
| 238 | set(handles.speed_txt,'Visible','on')
|
---|
| 239 | set(handles.RunMovie,'BusyAction','queue')
|
---|
| 240 | testavi=0;
|
---|
| 241 | UvData=get(handles.view_field,'UserData');
|
---|
| 242 |
|
---|
| 243 | while get(handles.speed,'Value')~=0 & isequal(get(handles.RunMovie,'BusyAction'),'queue') % enable STOP command
|
---|
| 244 | runpm(hObject,eventdata,handles,increment)
|
---|
| 245 | pause(1.02-get(handles.speed,'Value'))% wait for next image
|
---|
| 246 | end
|
---|
| 247 | if isfield(UvData,'aviobj') && ~isempty( UvData.aviobj),
|
---|
| 248 | UvData.aviobj=close(UvData.aviobj);
|
---|
| 249 | set(handles.view_field,'UserData',UvData);
|
---|
| 250 | end
|
---|
| 251 | set(handles.RunMovie,'BackgroundColor',[1 0 0])%paint the command buttonback to red
|
---|
| 252 |
|
---|
| 253 | %-------------------------------------------------------------------
|
---|
| 254 | function STOP_Callback(hObject, eventdata, handles)
|
---|
| 255 | %-------------------------------------------------------------------
|
---|
| 256 | set(handles.movie_pair,'BusyAction','Cancel')
|
---|
| 257 | set(handles.movie_pair,'value',0)
|
---|
| 258 | set(handles.RunMovie,'BusyAction','Cancel')
|
---|
| 259 | set(handles.MenuExportMovie,'BusyAction','Cancel')
|
---|
| 260 |
|
---|
| 261 |
|
---|
| 262 | %------------------------------------------------------------------
|
---|
| 263 | function runpm(hObject,eventdata,handles,increment)
|
---|
| 264 | %------------------------------------------------------------------
|
---|
| 265 | %check for mùovie pair status
|
---|
| 266 | movie_status=get(handles.movie_pair,'Value');
|
---|
| 267 | if isequal(movie_status,1)
|
---|
| 268 | STOP_Callback(hObject, eventdata, handles)
|
---|
| 269 | end
|
---|
| 270 | %read the data on the current input rootfile(s)
|
---|
| 271 |
|
---|
| 272 | [FileName,RootPath,filebase,FileIndices,FileExt,subdir]=read_file_boxes(handles);
|
---|
| 273 | NomType=get(handles.FileIndex,'UserData');
|
---|
| 274 |
|
---|
| 275 | num1=stra2num(get(handles.i1,'String'));
|
---|
| 276 | num2=stra2num(get(handles.i2,'String'));
|
---|
| 277 | num_a=stra2num(get(handles.j1,'String'));
|
---|
| 278 | num_b=stra2num(get(handles.j2,'String'));
|
---|
| 279 |
|
---|
| 280 | sub_value= get(handles.SubField,'Value');
|
---|
| 281 | if sub_value ==1
|
---|
| 282 | [FileName_1,RootPath_1,filebase_1,FileIndices_1,FileExt_1,SubDir_1]=read_file_boxes_1(handles);
|
---|
| 283 | end
|
---|
| 284 |
|
---|
| 285 | comp_input=get(handles.fix_pair,'Value');
|
---|
| 286 | if isequal(NomType,'_i1-i2')|isequal(NomType,'_i1-i2_j')
|
---|
| 287 | comp_input=1; %impose a fixed pair interval
|
---|
| 288 | set(handles.fix_pair,'Value',1)
|
---|
| 289 | end
|
---|
| 290 |
|
---|
| 291 | %case of scanning along the first direction (rootfile numbers)
|
---|
| 292 | if get(handles.scan_i,'Value')==1% case of scanning along field numbers
|
---|
| 293 | num1=num1+increment;
|
---|
| 294 | num2=num2+increment;
|
---|
| 295 | if comp_input==0% find a free pair
|
---|
| 296 | [filename,num_i1_out,num_j1_out,num_i2_out,num_j2_out]=...
|
---|
| 297 | name_generator(filebase,num1,num_a,FileExt,NomType,0,num2,num_b,subdir);
|
---|
| 298 | if exist(filename,'file')
|
---|
| 299 | num_a=num_j1_out;
|
---|
| 300 | num_b=num_j2_out;
|
---|
| 301 | end
|
---|
| 302 | end
|
---|
| 303 | if sub_value>=2
|
---|
| 304 | num_i1=num_i1+increment;
|
---|
| 305 | num_i2=num_i2+increment;
|
---|
| 306 | end
|
---|
| 307 | else % case of scanning along the second direction (burst numbers)
|
---|
| 308 | lastfield_cell=get(handles.last_j,'String'); % get the last field number
|
---|
| 309 | lastfield=str2num(lastfield_cell{1});
|
---|
| 310 | num_a=num_a+increment;
|
---|
| 311 | num_b=num_b+increment;
|
---|
| 312 | if sub_value >=2
|
---|
| 313 | num_j1=num_j1+increment;
|
---|
| 314 | num_j2=num_j2+increment;
|
---|
| 315 | elseif ~isempty(lastfield) && num_a>lastfield
|
---|
| 316 | num_a=1;
|
---|
| 317 | num1=num1+1;
|
---|
| 318 | num2=num2+1;
|
---|
| 319 | end
|
---|
| 320 | end
|
---|
| 321 |
|
---|
| 322 | % display the new open numbers
|
---|
| 323 | set(handles.i1,'String',num2stra(num1,NomType,1));
|
---|
| 324 | set(handles.i2,'String',num2stra(num2,NomType,1));
|
---|
| 325 | set(handles.j1,'String',num2stra(num_a,NomType,2));
|
---|
| 326 | set(handles.j2,'String',num2stra(num_b,NomType,2));
|
---|
| 327 | [indices]=name_generator('',num1,num_a,'',NomType,1,num2,num_b,'');
|
---|
| 328 | set(handles.FileIndex,'String',indices);
|
---|
| 329 | if sub_value ==1
|
---|
| 330 | NomType_1=get(handles.FileIndex_1,'UserData');
|
---|
| 331 | [indices]=...
|
---|
| 332 | name_generator('',num1,num_a,'',NomType_1,1,num2,num_b,'');
|
---|
| 333 | set(handles.FileIndex_1,'String',indices);
|
---|
| 334 | end
|
---|
| 335 |
|
---|
| 336 | if isequal(movie_status,1)
|
---|
| 337 | set(handles.movie_pair,'Value',1)
|
---|
| 338 | movie_pair_Callback(hObject, eventdata, handles); %run
|
---|
| 339 | else
|
---|
| 340 | % refresh plots
|
---|
| 341 | run0_Callback(hObject, eventdata, handles); %run
|
---|
| 342 | end
|
---|
| 343 |
|
---|
| 344 |
|
---|
| 345 | %-------------------------------------------------------
|
---|
| 346 | % --- Executes on button press in movie_pair: create an alternating movie with two view
|
---|
| 347 | %-------------------------------------------------------
|
---|
| 348 | function movie_pair_Callback(hObject, eventdata, handles)
|
---|
| 349 | status=get(handles.movie_pair,'value');
|
---|
| 350 | if isequal(status,0)
|
---|
| 351 | set(handles.movie_pair,'BusyAction','Cancel')
|
---|
| 352 | return
|
---|
| 353 | else
|
---|
| 354 | set(handles.movie_pair,'BusyAction','queue')
|
---|
| 355 | end
|
---|
| 356 | %initialisation
|
---|
| 357 | set(handles.movie_pair,'BackgroundColor',[1 1 0])%paint the command button in yellow
|
---|
| 358 | drawnow
|
---|
| 359 | list_fields=get(handles.Fields,'String');% list menu fields
|
---|
| 360 | index_fields=get(handles.Fields,'Value');% selected string index
|
---|
| 361 | FieldName=list_fields{index_fields}; % selected field
|
---|
| 362 | if isequal(FieldName,'image')
|
---|
| 363 | run0_Callback(hObject, eventdata, handles)%display the first image
|
---|
| 364 | UvData=get(handles.view_field,'UserData');
|
---|
| 365 | else
|
---|
| 366 | msgbox_view_field('ERROR','an image or movie must be first introduced as input')
|
---|
| 367 | return
|
---|
| 368 | end
|
---|
| 369 | [ff,rr,filebase,xx,Ext,SubDir]=read_file_boxes(handles);
|
---|
| 370 | NomType=get(handles.FileIndex,'UserData');
|
---|
| 371 | num_i1=stra2num(get(handles.i1,'String'));
|
---|
| 372 | num_j1=stra2num(get(handles.j1,'String'));
|
---|
| 373 | num_i2=stra2num(get(handles.i2,'String'));
|
---|
| 374 | num_j2=stra2num(get(handles.j2,'String'));
|
---|
| 375 | if isempty(num_j2)
|
---|
| 376 | if isempty(num_i2)
|
---|
| 377 | msgbox_view_field('ERROR', 'a second image index i2 or j2 is needed to show the pair as a movie')
|
---|
| 378 | return
|
---|
| 379 | else
|
---|
| 380 | num_j2=num_j1;%repeat the index i1 by default
|
---|
| 381 | end
|
---|
| 382 | end
|
---|
| 383 | if isempty(num_i2)
|
---|
| 384 | num_i2=num_i1;%repeat the index i1 by default
|
---|
| 385 | end
|
---|
| 386 | imaname_1=name_generator(filebase,num_i2,num_j2,Ext,NomType);
|
---|
| 387 | if ~exist(imaname_1,'file')
|
---|
| 388 | msgbox_view_field('ERROR',['second input open (-) ' imaname_1 ' not found']);
|
---|
| 389 | return
|
---|
| 390 | end
|
---|
| 391 | % set(handles.i2,'String',''); % indicates that the second index i2 is not used
|
---|
| 392 | % set(handles.j2,'String',''); % indicates that the second index i2 is not used
|
---|
| 393 |
|
---|
| 394 | %read the second image
|
---|
| 395 | Field.AName='image';
|
---|
| 396 | Field.AX=UvData.Field.AX;
|
---|
| 397 | Field.AY=UvData.Field.AY;
|
---|
| 398 | % z index
|
---|
| 399 | nbslice=str2double(get(handles.nb_slice,'String'));
|
---|
| 400 | if ~isempty(nbslice)
|
---|
| 401 | Field.ZIndex=mod(num_i2-1,nbslice)+1;
|
---|
| 402 | end
|
---|
| 403 | Field.CoordType='px';
|
---|
| 404 | %determine the input file type
|
---|
| 405 | if isfield(UvData,'MovieObject')
|
---|
| 406 | FileType='movie';
|
---|
| 407 | elseif isequal(lower(Ext),'.avi')
|
---|
| 408 | FileType='avi';
|
---|
| 409 | elseif isequal(lower(Ext),'.vol')
|
---|
| 410 | FileType='vol';
|
---|
| 411 | else
|
---|
| 412 | form=imformats(Ext([2:end]));
|
---|
| 413 | if ~isempty(form)% if the extension corresponds to an image format recognized by Matlab
|
---|
| 414 | if isequal(NomType,'*');
|
---|
| 415 | FileType='multimage';
|
---|
| 416 | else
|
---|
| 417 | FileType='image';
|
---|
| 418 | end
|
---|
| 419 | end
|
---|
| 420 | end
|
---|
| 421 | switch FileType
|
---|
| 422 | case 'movie'
|
---|
| 423 | Field.A=read(UvData.MovieObject,num_i2);
|
---|
| 424 | case 'avi'
|
---|
| 425 | mov=aviread(imaname_1,num_i2);
|
---|
| 426 | Field.A=frame2im(mov(1));
|
---|
| 427 | case 'vol'
|
---|
| 428 | Field.A=imread(imaname_1);
|
---|
| 429 | case 'multimage'
|
---|
| 430 | Field.A=imread(imaname_1,num_i2);
|
---|
| 431 | case 'image'
|
---|
| 432 | Field.A=imread(imaname_1);
|
---|
| 433 | end
|
---|
| 434 |
|
---|
| 435 | %px to phys or other transform on field
|
---|
| 436 | menu_transform=get(handles.transform_fct,'String');
|
---|
| 437 | choice_value=get(handles.transform_fct,'Value');
|
---|
| 438 | transform_name=menu_transform{choice_value};%name of the transform fct given by the menu 'transform_fct'
|
---|
| 439 | transform_list=get(handles.transform_fct,'UserData');
|
---|
| 440 | transform=transform_list{choice_value};
|
---|
| 441 | if ~isequal(transform_name,'') && ~isequal(transform_name,'px')
|
---|
| 442 | if isfield(UvData,'XmlData') && isfield(UvData.XmlData,'GeometryCalib')%use geometry calib recorded from the ImaDoc xml file as first priority
|
---|
| 443 | Field=transform(Field,UvData.XmlData);
|
---|
| 444 | end
|
---|
| 445 | end
|
---|
| 446 |
|
---|
| 447 | % make movie until movie speed is set to 0 or STOP is activated
|
---|
| 448 | hima=findobj(handles.axes3,'Tag','ima');% %handles.axes3 =main plotting window (A GENERALISER)
|
---|
| 449 | set(handles.STOP,'Visible','on')
|
---|
| 450 | set(handles.speed,'Visible','on')
|
---|
| 451 | set(handles.speed_txt,'Visible','on')
|
---|
| 452 | while get(handles.speed,'Value')~=0 && isequal(get(handles.movie_pair,'BusyAction'),'queue')%isequal(get(handles.run0,'BusyAction'),'queue'); % enable STOP command
|
---|
| 453 | % read and plot the series of images in non erase mode
|
---|
| 454 | set(hima,'CData',Field.A);
|
---|
| 455 | pause(1.02-get(handles.speed,'Value'));% wait for next image
|
---|
| 456 | set(hima,'CData',UvData.Field.A);
|
---|
| 457 | pause(1.02-get(handles.speed,'Value'));% wait for next image
|
---|
| 458 | end
|
---|
| 459 | set(handles.movie_pair,'BackgroundColor',[1 0 0])%paint the command button in red
|
---|
| 460 |
|
---|
| 461 | %-------------------------------------------------------
|
---|
| 462 | % --- Executes on button press in run0.
|
---|
| 463 | %-------------------------------------------------
|
---|
| 464 | function run0_Callback(hObject, eventdata, handles)
|
---|
| 465 |
|
---|
| 466 | %initialisation
|
---|
| 467 | set(handles.run0,'BackgroundColor',[1 1 0])%paint the command button in yellow
|
---|
| 468 | drawnow
|
---|
| 469 | abstime=[];
|
---|
| 470 | abstime_1=[];
|
---|
| 471 | dt=[];
|
---|
| 472 | Field={};
|
---|
| 473 | UvData=get(handles.view_field,'UserData');
|
---|
| 474 | if isfield(UvData,'Txt')
|
---|
| 475 | UvData=rmfield(UvData,'Txt');%erase previous error message
|
---|
| 476 | end
|
---|
| 477 | %set(handles.run0,'BusyAction','queue');
|
---|
| 478 | if ishandle(handles.VIEW_FIELD_title) %remove title panel on view_field
|
---|
| 479 | delete(handles.VIEW_FIELD_title)
|
---|
| 480 | end
|
---|
| 481 |
|
---|
| 482 | % determine the main input file information for action
|
---|
| 483 | TestInputFile=1;%default
|
---|
| 484 | if isfield(UvData,'TestInputFile')&& isequal(UvData.TestInputFile,0),
|
---|
| 485 | TestInputFile=0;
|
---|
| 486 | end
|
---|
| 487 | num_i1=[];%default
|
---|
| 488 | FileType=[];%default
|
---|
| 489 | if TestInputFile
|
---|
| 490 | [filename,RootPath,filebase,xx,Ext]=read_file_boxes(handles);
|
---|
| 491 | if ~exist(filename,'file')
|
---|
| 492 | msgbox_view_field('ERROR',['input file ' filename ' does not exist'])
|
---|
| 493 | return
|
---|
| 494 | end
|
---|
| 495 | num_i1=stra2num(get(handles.i1,'String'));
|
---|
| 496 | num_i2=stra2num(get(handles.i2,'String'));
|
---|
| 497 | num_j1=stra2num(get(handles.j1,'String'));
|
---|
| 498 | num_j2=stra2num(get(handles.j2,'String'));
|
---|
| 499 | NomType=get(handles.FileIndex,'UserData');
|
---|
| 500 | %update the z position index
|
---|
| 501 | nbslice=str2double(get(handles.nb_slice,'String'));
|
---|
| 502 | if ~isnan(nbslice)
|
---|
| 503 | z_index=mod(num_i1-1,nbslice)+1;
|
---|
| 504 | set(handles.z_index,'String',num2str(z_index))
|
---|
| 505 | % refresh menu for save_mask if relevant
|
---|
| 506 | masknumber=get(handles.masklevel,'String');
|
---|
| 507 | if length(masknumber)>=z_index
|
---|
| 508 | set(handles.masklevel,'Value',z_index)
|
---|
| 509 | end
|
---|
| 510 | end
|
---|
| 511 | % determine the input file type
|
---|
| 512 | if isequal(Ext,'.nc')||isequal(Ext,'.cdf')
|
---|
| 513 | FileType='netcdf';
|
---|
| 514 | elseif isfield(UvData,'MovieObject')
|
---|
| 515 | FileType='movie';
|
---|
| 516 | FieldName='image';
|
---|
| 517 | elseif isequal(lower(Ext),'.avi')
|
---|
| 518 | FileType='avi';
|
---|
| 519 | FieldName='image';
|
---|
| 520 | elseif isequal(lower(Ext),'.vol')
|
---|
| 521 | FileType='vol';
|
---|
| 522 | FieldName='image';
|
---|
| 523 | else
|
---|
| 524 | form=imformats(Ext([2:end]));
|
---|
| 525 | if ~isempty(form)% if the extension corresponds to an image format recognized by Matlab
|
---|
| 526 | if isequal(NomType,'*');
|
---|
| 527 | FileType='multimage';
|
---|
| 528 | else
|
---|
| 529 | FileType='image';
|
---|
| 530 | end
|
---|
| 531 | FieldName='image';
|
---|
| 532 | end
|
---|
| 533 | end
|
---|
| 534 | else
|
---|
| 535 | filename=[];
|
---|
| 536 | FileType='netcdf';
|
---|
| 537 | FieldName='get_field...';
|
---|
| 538 | end
|
---|
| 539 | VelType=[];%default
|
---|
| 540 | if isequal(FileType,'netcdf')
|
---|
| 541 | list_fields=get(handles.Fields,'String');% list menu fields
|
---|
| 542 | index_fields=get(handles.Fields,'Value');% selected string index
|
---|
| 543 | FieldName= list_fields{index_fields}; % selected field
|
---|
| 544 | if isequal(FieldName,'get_field...')% read the field names on the interface get_field...
|
---|
| 545 | VelType=get(handles.Fields,'UserData');
|
---|
| 546 | Field{1}=get(handles.Fields,'UserData');
|
---|
| 547 | else
|
---|
| 548 | VelType=setfield(handles);
|
---|
| 549 | end
|
---|
| 550 | end
|
---|
| 551 |
|
---|
| 552 | % choose a second field if Subfield option is 'on'
|
---|
| 553 | filename_1=[];
|
---|
| 554 | FieldName_1=[];
|
---|
| 555 | scal_color=[];
|
---|
| 556 | VelType_1=setfield_1(handles);
|
---|
| 557 | sub_value=get(handles.SubField,'Value');
|
---|
| 558 | FileType_1='none';%default
|
---|
| 559 | if sub_value==1
|
---|
| 560 | filename_1=read_file_boxes_1(handles);
|
---|
| 561 | if ~exist(filename_1,'file')
|
---|
| 562 | msgbox_view_field('ERROR',['second file ' filename_1 ' does not exist'])
|
---|
| 563 | return
|
---|
| 564 | end
|
---|
| 565 | NomType_1=get(handles.FileIndex_1,'UserData');
|
---|
| 566 | Ext_1=get(handles.FileExt_1,'String');
|
---|
| 567 | % determine the input file type
|
---|
| 568 | if isequal(Ext_1,'.nc')||isequal(Ext_1,'.cdf')
|
---|
| 569 | FileType_1='netcdf';
|
---|
| 570 | elseif isfield(UvData,'MovieObject_1')
|
---|
| 571 | FileType_1='movie';
|
---|
| 572 | FieldName_1='image';
|
---|
| 573 | elseif isequal(lower(Ext_1),'.avi')
|
---|
| 574 | FileType='avi';
|
---|
| 575 | FieldName_1='image';
|
---|
| 576 | elseif isequal(lower(Ext_1),'.vol')
|
---|
| 577 | FileType_1='vol';
|
---|
| 578 | FieldName_1='image';
|
---|
| 579 | else
|
---|
| 580 | form=imformats(Ext([2:end]));
|
---|
| 581 | if ~isempty(form)% if the extension corresponds to an image format recognized by Matlab
|
---|
| 582 | if isequal(NomType_1,'*');
|
---|
| 583 | FileType_1='multimage';
|
---|
| 584 | else
|
---|
| 585 | FileType_1='image';
|
---|
| 586 | end
|
---|
| 587 | FieldName_1='image';
|
---|
| 588 | end
|
---|
| 589 | end
|
---|
| 590 | if ~isequal(FieldName_1,'image')
|
---|
| 591 | list_fields=get(handles.Fields_1,'String');% list menu fields
|
---|
| 592 | index_fields=get(handles.Fields_1,'Value');% selected string index
|
---|
| 593 | FieldName_1= list_fields{index_fields}; % selected field
|
---|
| 594 | if isequal(VelType_1,'*')% free veltype choice
|
---|
| 595 | VelType_1=[];
|
---|
| 596 | elseif isequal(VelType_1,'"')% veltype the same as for the first field
|
---|
| 597 | if isempty(VelType)
|
---|
| 598 | VelType_1=[];
|
---|
| 599 | else
|
---|
| 600 | VelType_1=VelType;
|
---|
| 601 | end
|
---|
| 602 | end
|
---|
| 603 | end
|
---|
| 604 | end
|
---|
| 605 |
|
---|
| 606 | % test for keeping the previous stored data if the input files are unchanged
|
---|
| 607 | test_keepdata_1=0;%defautl
|
---|
| 608 | test_keepdata=0;
|
---|
| 609 | if sub_value>=2
|
---|
| 610 | if ~isequal(NomType_1,'*')%in cas of a series of files (not avi movie)
|
---|
| 611 | if isfield(UvData,'filename_1')&& isfield(UvData,'VelType_1') && isfield(UvData,'FieldName_1')
|
---|
| 612 | test_keepdata_1= isequal(filename_1,UvData.filename_1)&&...
|
---|
| 613 | isequal(VelType_1,UvData.filename_1) && isequal(FieldName_1,UvData.FieldName_1);
|
---|
| 614 |
|
---|
| 615 | end
|
---|
| 616 | end
|
---|
| 617 | end
|
---|
| 618 |
|
---|
| 619 | %read the input field(s)
|
---|
| 620 |
|
---|
| 621 | %read images
|
---|
| 622 | if ~isempty(filename) && isequal(FieldName,'image')
|
---|
| 623 | switch FileType
|
---|
| 624 | case 'movie'
|
---|
| 625 | A=read(UvData.MovieObject,num_i1);
|
---|
| 626 | case 'avi'
|
---|
| 627 | mov=aviread(filename,num_i1);
|
---|
| 628 | A=frame2im(mov(1));
|
---|
| 629 | case 'vol'
|
---|
| 630 | A=imread(filename);
|
---|
| 631 | case 'multimage'
|
---|
| 632 | A=imread(filename,num_i1);
|
---|
| 633 | case 'image'
|
---|
| 634 | A=imread(filename);
|
---|
| 635 | end
|
---|
| 636 | npxy=size(A);
|
---|
| 637 | set(handles.npx,'String',num2str(npxy(2)));% display image size on the interface
|
---|
| 638 | set(handles.npy,'String',num2str(npxy(1)));
|
---|
| 639 | Rangx=[0.5 npxy(2)-0.5]; % coordinates of the first and last pixel centers
|
---|
| 640 | Rangy=[npxy(1)-0.5 0.5]; %
|
---|
| 641 | Field{1}.AName='image';
|
---|
| 642 | Field{1}.ListVarName={'AY','AX','A'}; %
|
---|
| 643 | if size(A,3)==3;%color
|
---|
| 644 | Field{1}.VarDimName={'AY','AX',{'AY','AX','rgb'}}; %
|
---|
| 645 | else
|
---|
| 646 | Field{1}.VarDimName={'AY','AX',{'AY','AX'}}; %
|
---|
| 647 | end
|
---|
| 648 | Field{1}.AY=Rangy;
|
---|
| 649 | Field{1}.AX=Rangx;
|
---|
| 650 | Field{1}.A=A;
|
---|
| 651 | Field{1}.CoordType='px'; %used for mouse_motion
|
---|
| 652 | Field{1}.CoordUnit='pixel'; %used for mouse_motion
|
---|
| 653 | end
|
---|
| 654 |
|
---|
| 655 | %read a second image
|
---|
| 656 | if ~isfield(UvData,'Txt')&& ~isempty(filename_1) && isequal(FieldName_1,'image')
|
---|
| 657 | switch FileType_1
|
---|
| 658 | case 'movie'
|
---|
| 659 | A=read(UvData.MovieObject_1,num_i1);
|
---|
| 660 | case 'avi'
|
---|
| 661 | mov=aviread(filename,num_i1);
|
---|
| 662 | A=frame2im(mov(1));
|
---|
| 663 | case 'vol'
|
---|
| 664 | A=imread(filename);
|
---|
| 665 | case 'multimage'
|
---|
| 666 | A=imread(filename,num_i1);
|
---|
| 667 | case 'image'
|
---|
| 668 | A=imread(filename);
|
---|
| 669 | end
|
---|
| 670 | npxy=size(A);
|
---|
| 671 | set(handles.npx,'String',num2str(npxy(2)));% display image size on the interface
|
---|
| 672 | set(handles.npy,'String',num2str(npxy(1)));
|
---|
| 673 | Rangx=[0.5 npxy(2)-0.5]; % coordinates of the first and last pixel centers
|
---|
| 674 | Rangy=[npxy(1)-0.5 0.5]; %
|
---|
| 675 | Field{2}.AName='image';
|
---|
| 676 | Field{2}.ListVarName={'AY','AX','A'}; %
|
---|
| 677 | if size(A,3)==3;%color
|
---|
| 678 | Field{2}.VarDimName={'AY','AX',{'AY','AX','rgb'}}; %
|
---|
| 679 | else
|
---|
| 680 | Field{2}.VarDimName={'AY','AX',{'AY','AX'}}; %
|
---|
| 681 | end
|
---|
| 682 | Field{2}.AY=Rangy;
|
---|
| 683 | Field{2}.AX=Rangx;
|
---|
| 684 | Field{2}.A=A;
|
---|
| 685 | Field{2}.CoordType='px'; %used for mouse_motion
|
---|
| 686 | Field{2}.CoordUnit='px'; %used for move_mou
|
---|
| 687 | end
|
---|
| 688 |
|
---|
| 689 | %read ncfile(s)
|
---|
| 690 | CivStage_1=0;%default
|
---|
| 691 | VelType_out_1=[];
|
---|
| 692 | InputField={FieldName};
|
---|
| 693 | InputField_1={FieldName_1};
|
---|
| 694 | if ~isfield(UvData,'Txt') && ((~isempty(filename)&& isequal(FileType,'netcdf')) || (~isempty(filename_1)&& isequal(FileType,'netcdf'))) ;
|
---|
| 695 | %read the velocity field(s) from netcdf rootfile(s)
|
---|
| 696 | list_code=get(handles.col_vec,'String');% list menu fields
|
---|
| 697 | index_code=get(handles.col_vec,'Value');% selected string index
|
---|
| 698 | scal_color= list_code{index_code(1)}; % selected field
|
---|
| 699 | if isequal(FieldName,'velocity')&& ~isequal(scal_color,'black') && ~isequal(scal_color,'white')
|
---|
| 700 | InputField=[InputField scal_color];
|
---|
| 701 | end
|
---|
| 702 | if isequal(FieldName_1,'velocity') && ~isequal(scal_color,'black') && ~isequal(scal_color,'white')
|
---|
| 703 | InputField_1=[InputField_1 scal_color];
|
---|
| 704 | end
|
---|
| 705 | if isequal(FileType,'netcdf') %read the first nc field
|
---|
| 706 | if isequal(FieldName,'get_field...')% read the field names on the interface get_field.
|
---|
| 707 | VelType=get(handles.Fields,'UserData');
|
---|
| 708 | hget_field=findobj(allchild(0),'Name','get_field');%find the get_field... GUI
|
---|
| 709 | if isempty(hget_field)
|
---|
| 710 | hget_field= get_field(filename);%open the get_field GUI
|
---|
| 711 | end
|
---|
| 712 | hhget_field=guidata(hget_field);
|
---|
| 713 | set(hhget_field.inputfile,'String',filename)% update the list of input fields in get_field
|
---|
| 714 | set(hhget_field.ACTION,'Value',1)% PLOT option selected
|
---|
| 715 | set(hhget_field.list_fig,'Value',2)% plotting axes =view_field selected
|
---|
| 716 | [Field{1},errormsg]=read_get_field(hget_field); %read the names of the variables to plot in the get_field GUI
|
---|
| 717 | if ~isempty(errormsg)
|
---|
| 718 | msgbox_view_field('ERROR',['error in view_field/run0_Callback/read_get_field: ' errormsg])
|
---|
| 719 | return
|
---|
| 720 | end
|
---|
| 721 | CivStage=0;
|
---|
| 722 | VelType_out=[];
|
---|
| 723 | else
|
---|
| 724 | [Field{1},VelType_out]=read_civxdata(filename,InputField,VelType);
|
---|
| 725 | if isfield(Field{1},'Txt')
|
---|
| 726 | msgbox_view_field('ERROR',Field{1}.Txt)
|
---|
| 727 | return
|
---|
| 728 | end
|
---|
| 729 | CivStage=Field{1}.CivStage;
|
---|
| 730 | UvData.NbDim=Field{1}.nb_dim;
|
---|
| 731 | end
|
---|
| 732 | end
|
---|
| 733 | if ~isempty(filename_1) && isequal(FileType_1,'netcdf') %read the second file
|
---|
| 734 | if isequal(FieldName_1,'get_field...')% read the field names on the interface get_field.
|
---|
| 735 | hget_field=findobj(allchild(0),'Name','get_field_1');%find the get_field... GUI
|
---|
| 736 | if isempty(hget_field)
|
---|
| 737 | hget_field= get_field(filename_1);%open the get_field GUI
|
---|
| 738 | set(hget_field,'name','get_field_1')
|
---|
| 739 | % enable_transform(handles,'off')% no field transform (possible transform in the GUI get_field)
|
---|
| 740 | end
|
---|
| 741 | hhget_field=guidata(hget_field);%handles of GUI elements in get_field
|
---|
| 742 | SubField=get_field('read_var_names',hObject,eventdata,hhget_field); %read the names of the variables to plot in the get_field GUI
|
---|
| 743 | [Field{2},var_detect]=nc2struct(filename_1,SubField.ListVarName); %read the corresponding input data
|
---|
| 744 | Field{2}.VarAttribute=SubField.VarAttribute;
|
---|
| 745 | %update the display on get_field
|
---|
| 746 | set(hhget_field.inputfile,'String',filename_1)
|
---|
| 747 | set(hhget_field.variables,'Value',1)
|
---|
| 748 | Tabchar={''};%default
|
---|
| 749 | Tabcell=[];
|
---|
| 750 | if isfield(Field{2},'ListGlobalAttribute')& ~isempty(Field{2}.ListGlobalAttribute)
|
---|
| 751 | for iline=1:length(Field{2}.ListGlobalAttribute)
|
---|
| 752 | Tabcell{iline,1}=Field{2}.ListGlobalAttribute{iline};
|
---|
| 753 | if isfield(Field{2}, Field{2}.ListGlobalAttribute{iline})
|
---|
| 754 | eval(['val=Field{2}.' Field{2}.ListGlobalAttribute{iline} ';'])
|
---|
| 755 | if ischar(val);
|
---|
| 756 | Tabcell{iline,2}=val;
|
---|
| 757 | else
|
---|
| 758 | Tabcell{iline,2}=num2str(val);
|
---|
| 759 | end
|
---|
| 760 | end
|
---|
| 761 | end
|
---|
| 762 | if ~isempty(Tabcell)
|
---|
| 763 | Tabchar=cell2tab(Tabcell,'=');
|
---|
| 764 | Tabchar=[{''};Tabchar];
|
---|
| 765 | end
|
---|
| 766 | end
|
---|
| 767 | set(hhget_field.attributes,'String',Tabchar);%update list of global attributes in get_field
|
---|
| 768 | else
|
---|
| 769 | [Field{2},VelType_out_1]=read_civxdata(filename_1,[],VelType_1);
|
---|
| 770 | CivStage_1=Field{2}.CivStage;
|
---|
| 771 | end
|
---|
| 772 | if ~isequal(FileType,'netcdf')
|
---|
| 773 | VelType_out=VelType_out_1;
|
---|
| 774 | end
|
---|
| 775 | end
|
---|
| 776 | end
|
---|
| 777 |
|
---|
| 778 | %update the display buttons for the first velocity type (first menuline)
|
---|
| 779 | veltype_handles=[handles.civ1 handles.interp1 handles.filter1 handles.civ2 handles.interp2 handles.filter2];
|
---|
| 780 | if ~isequal(FileType,'netcdf')
|
---|
| 781 | reset_vel_type(veltype_handles)
|
---|
| 782 | elseif isempty(VelType)
|
---|
| 783 | set_veltype_display(veltype_handles,CivStage)%update the display of available velocity types for the first field
|
---|
| 784 | if isempty(VelType_out)
|
---|
| 785 | reset_vel_type(veltype_handles)
|
---|
| 786 | else
|
---|
| 787 | handle1=eval(['handles.' VelType_out]);
|
---|
| 788 | reset_vel_type(veltype_handles,handle1)
|
---|
| 789 | end
|
---|
| 790 | end
|
---|
| 791 |
|
---|
| 792 | %update the display buttons for the second velocity type (second menuline)
|
---|
| 793 | veltype_handles_1=[handles.civ1_1 handles.interp1_1 handles.filter1_1 handles.civ2_1 handles.interp2_1 handles.filter2_1];
|
---|
| 794 | if ~isequal(FileType_1,'netcdf')
|
---|
| 795 | reset_vel_type(veltype_handles_1)
|
---|
| 796 | elseif isempty(VelType_1)
|
---|
| 797 | set_veltype_display(veltype_handles_1,CivStage_1)%update the display of available velocity types for the first field
|
---|
| 798 | if isempty(VelType_out_1)
|
---|
| 799 | reset_vel_type(veltype_handles_1)
|
---|
| 800 | else
|
---|
| 801 | handle1=eval(['handles.' VelType_out_1 '_1']);
|
---|
| 802 | reset_vel_type(veltype_handles_1,handle1)
|
---|
| 803 | end
|
---|
| 804 | end
|
---|
| 805 |
|
---|
| 806 | %introduce w as background image by default for a new series (only for nbdim=2)
|
---|
| 807 | if ~isfield(UvData,'NewSeries')
|
---|
| 808 | UvData.NewSeries=1;
|
---|
| 809 | end
|
---|
| 810 | %put W as background image by default if NbDim=2:
|
---|
| 811 | if ~isfield(UvData,'NbDim')||isempty(UvData.NbDim)||~isequal(UvData.NbDim,3)
|
---|
| 812 | if UvData.NewSeries && isequal(get(handles.SubField,'Value'),0) && isfield(Field{1},'W') && ~isempty(Field{1}.W);
|
---|
| 813 | set(handles.SubField,'Value',1);
|
---|
| 814 | %menu=update_menu(handles.Fields_1,'w');%update the menu for the background scalar nd set the choice to 'w'
|
---|
| 815 | set(handles.RootPath_1,'String','"')
|
---|
| 816 | set(handles.RootFile_1,'String','"')
|
---|
| 817 | set(handles.SubDir_1,'String','"');
|
---|
| 818 | [indices]=name_generator('',num_i1,num_j1,'',NomType,1,num_i2,num_j2,'');
|
---|
| 819 | set(handles.FileIndex_1,'String',indices)
|
---|
| 820 | set(handles.FileExt_1,'String','"');
|
---|
| 821 | set(handles.Fields_1,'Visible','on');
|
---|
| 822 | set(handles.Fields_1,'Visible','on');
|
---|
| 823 | set(handles.RootPath_1,'Visible','on')
|
---|
| 824 | set(handles.RootFile_1,'Visible','on')
|
---|
| 825 | set(handles.SubDir_1,'Visible','on');
|
---|
| 826 | set(handles.FileIndex_1,'Visible','on');
|
---|
| 827 | set(handles.FileExt_1,'Visible','on');
|
---|
| 828 | set(handles.Fields_1,'Visible','on');
|
---|
| 829 | Field{1}.AName='w';
|
---|
| 830 | testscal=1;
|
---|
| 831 | end
|
---|
| 832 | end
|
---|
| 833 |
|
---|
| 834 | %multislice case
|
---|
| 835 | if TestInputFile &&(~isfield(UvData,'NbDim') || isequal(UvData.NbDim,2))&&...%2D case
|
---|
| 836 | isfield(UvData,'XmlData') && isfield(UvData.XmlData,'GeometryCalib')&& isfield(UvData.XmlData.GeometryCalib,'SliceCoord')
|
---|
| 837 | % nbfield2=str2num(get(handles.last_j,'String'));
|
---|
| 838 | siz=size(UvData.XmlData.GeometryCalib.SliceCoord);
|
---|
| 839 | if siz(1)>1
|
---|
| 840 | NbSlice=siz(1);
|
---|
| 841 | set(handles.slices,'Visible','on')
|
---|
| 842 | set(handles.slices,'Value',1)
|
---|
| 843 | else
|
---|
| 844 | NbSlice=1;
|
---|
| 845 | end
|
---|
| 846 | set(handles.nb_slice,'String',num2str(NbSlice))
|
---|
| 847 | slices_Callback(hObject, eventdata, handles)
|
---|
| 848 | % Coord=UvData.XmlData.GeometryCalib.SliceCoord;
|
---|
| 849 | % ZIndex=num_i1-NbSlice*(floor((num_i1-1)/NbSlice));
|
---|
| 850 | % Field{1}.Z=ZIndex;
|
---|
| 851 | end
|
---|
| 852 |
|
---|
| 853 | %store the current open names, fields and vel types in view_field interface
|
---|
| 854 | UvData.filename=filename;
|
---|
| 855 | UvData.filename_1=filename_1;
|
---|
| 856 | UvData.VelType=VelType;
|
---|
| 857 | UvData.VelType_1=VelType_1;
|
---|
| 858 | UvData.FieldName=FieldName;
|
---|
| 859 | UvData.FieldName_1=FieldName_1;
|
---|
| 860 | if ~isempty(scal_color)
|
---|
| 861 | UvData.CName=scal_color;
|
---|
| 862 | end
|
---|
| 863 |
|
---|
| 864 | %coordinate transform or user fct
|
---|
| 865 | XmlData=[];%default
|
---|
| 866 | if isfield(UvData,'XmlData')%use geometry calib recorded from the ImaDoc xml file as first priority
|
---|
| 867 | XmlData=UvData.XmlData;
|
---|
| 868 | end
|
---|
| 869 | XmlData_1=[];%default
|
---|
| 870 | if isfield(UvData,'XmlData_1')
|
---|
| 871 | XmlData_1=UvData.XmlData_1;
|
---|
| 872 | end
|
---|
| 873 | menu_transform=get(handles.transform_fct,'String');
|
---|
| 874 | choice_value=get(handles.transform_fct,'Value');
|
---|
| 875 | %transform=menu_transform{choice_value};%name of the transform fct given by the menu 'transform_fct'
|
---|
| 876 | transform_list=get(handles.transform_fct,'UserData');
|
---|
| 877 | transform=transform_list{choice_value};%selected function handles
|
---|
| 878 |
|
---|
| 879 | % z index
|
---|
| 880 | if TestInputFile
|
---|
| 881 | Field{1}.ZIndex=mod(num_i1-1,nbslice)+1;
|
---|
| 882 | end
|
---|
| 883 | %px to phys or other transform on field
|
---|
| 884 | if ~isempty(transform)
|
---|
| 885 | if length(Field)>=2
|
---|
| 886 | Field{2}.ZIndex=mod(num_i1-1,nbslice)+1;
|
---|
| 887 | [Field{1},Field{2}]=transform(Field{1},XmlData,Field{2},XmlData_1);
|
---|
| 888 | if isempty(Field{2})
|
---|
| 889 | Field(2)=[];
|
---|
| 890 | end
|
---|
| 891 | else
|
---|
| 892 | Field{1}=transform(Field{1},XmlData);
|
---|
| 893 | end
|
---|
| 894 | end
|
---|
| 895 |
|
---|
| 896 | %calculate scalar
|
---|
| 897 | if isequal(FileType,'netcdf') && ~isequal(FieldName,'get_field...')%
|
---|
| 898 | Field{1}=calc_field(InputField,Field{1});
|
---|
| 899 | end
|
---|
| 900 | if length(Field)==2 && isequal(FileType_1,'netcdf') && ~isequal(FieldName_1,'get_field...')
|
---|
| 901 | Field{2}=calc_field(InputField_1,Field{2});
|
---|
| 902 | end
|
---|
| 903 |
|
---|
| 904 | % combine the two input fields (e.g. substract velocity fields)
|
---|
| 905 | if numel(Field)==2
|
---|
| 906 | if ~(isequal(get(handles.movie_pair,'Value'),1) && isequal(FieldName,'image') && isequal(FieldName_1,'image')) %combine fields if not viewing image pairs
|
---|
| 907 | UvData.Field=sub_field(Field{1},Field{2}); %TO UPDATE FOR MORE GENERAL INPUT
|
---|
| 908 | end
|
---|
| 909 | else
|
---|
| 910 | UvData.Field=Field{1};
|
---|
| 911 | end
|
---|
| 912 | UvData.NewSeries=0;% put to 0 the test for a new field series (set by RootPath_callback)
|
---|
| 913 | % test 3D , default projection menuplane and typical mesh (needed to menuopen set_object)
|
---|
| 914 | test_x=0;
|
---|
| 915 | test_z=0;% test for unstructured z coordinate
|
---|
| 916 | UvData.ZMax=0;
|
---|
| 917 | UvData.ZMin=0;%default
|
---|
| 918 | UvData.Mesh=1; %default
|
---|
| 919 | [UvData.Field,errormsg]=check_field_structure(UvData.Field);
|
---|
| 920 | if ~isempty(errormsg)
|
---|
| 921 | msgbox_view_field('ERROR',['error in view_field/run0_Callback/check_field_structure: ' errormsg])
|
---|
| 922 | return
|
---|
| 923 | end
|
---|
| 924 | [CellVarIndex,NbDim,VarType]=find_field_indices(UvData.Field);
|
---|
| 925 | [NbDim,imax]=max(NbDim);
|
---|
| 926 | if isempty(imax)
|
---|
| 927 | % DimVarIndex=0;
|
---|
| 928 | coord_x=[];
|
---|
| 929 | else
|
---|
| 930 | % VarIndex=CellVarIndex{imax};
|
---|
| 931 | coord_x=VarType{imax}.coord_x;
|
---|
| 932 | end
|
---|
| 933 | if isfield(UvData,'NbDim') && ~isempty(UvData.NbDim)
|
---|
| 934 | NbDim=UvData.NbDim;
|
---|
| 935 | else
|
---|
| 936 | UvData.NbDim=NbDim;
|
---|
| 937 | end
|
---|
| 938 | if ~isempty(CellVarIndex) && ~isempty(VarType{imax}.coord_x) && ~isempty(VarType{imax}.coord_y) %unstructured coordinate z
|
---|
| 939 | XName=UvData.Field.ListVarName{VarType{imax}.coord_x};
|
---|
| 940 | YName=UvData.Field.ListVarName{VarType{imax}.coord_y};
|
---|
| 941 | test_x=1;
|
---|
| 942 | elseif isfield(UvData.Field,'X') && isfield(UvData.Field,'Y')
|
---|
| 943 | XName='X';
|
---|
| 944 | YName='Y';
|
---|
| 945 | test_x=1;
|
---|
| 946 | end
|
---|
| 947 | if test_x
|
---|
| 948 | eval(['UvData.XMax=max(UvData.Field.' XName ');'])
|
---|
| 949 | eval(['UvData.XMin=min(UvData.Field.' XName ');'])
|
---|
| 950 | eval(['UvData.YMax=max(UvData.Field.' YName ');'])
|
---|
| 951 | eval(['UvData.YMin=min(UvData.Field.' YName ');'])
|
---|
| 952 | eval(['nbvec=length(UvData.Field.' XName ');'])
|
---|
| 953 | if NbDim==3%
|
---|
| 954 | if ~isempty(CellVarIndex) && ~isempty(VarType{imax}.coord_z)%unstructured coordinate z
|
---|
| 955 | ZName=UvData.Field.ListVarName{VarType{imax}.coord_z};
|
---|
| 956 | eval(['UvData.ZMax=max(UvData.Field.' ZName ');'])
|
---|
| 957 | eval(['UvData.ZMin=min(UvData.Field.' ZName ');'])
|
---|
| 958 | test_z=1;
|
---|
| 959 | elseif isfield(UvData,'Z')% usual civ data
|
---|
| 960 | UvData.ZMax=max(UvData.Z);
|
---|
| 961 | UvData.ZMin=min(UvData.Z);
|
---|
| 962 | test_z=1;
|
---|
| 963 | end
|
---|
| 964 | end
|
---|
| 965 | if isequal(UvData.ZMin,UvData.ZMax)%no z dependency
|
---|
| 966 | NbDim=2;
|
---|
| 967 | test_z=0;
|
---|
| 968 | end
|
---|
| 969 | if test_z
|
---|
| 970 | UvData.Mesh=((UvData.XMax-UvData.XMin)*(UvData.YMax-UvData.YMin)*(UvData.ZMax-UvData.ZMin))/nbvec;% volume per vector
|
---|
| 971 | UvData.Mesh=(UvData.Mesh)^(1/3);
|
---|
| 972 | else
|
---|
| 973 | UvData.Mesh=sqrt((UvData.XMax-UvData.XMin)*(UvData.YMax-UvData.YMin)/nbvec);%2D
|
---|
| 974 | end
|
---|
| 975 | end
|
---|
| 976 | %case of structured coordinates
|
---|
| 977 | if isfield(UvData.Field,'AX') & isfield(UvData.Field,'AY')& isfield(UvData.Field,'A')
|
---|
| 978 | UvData.XMax=max(UvData.Field.AX);
|
---|
| 979 | UvData.XMin=min(UvData.Field.AX);
|
---|
| 980 | UvData.YMax=max(UvData.Field.AY);
|
---|
| 981 | UvData.YMin=min(UvData.Field.AY);
|
---|
| 982 | np_A=size(UvData.Field.A);
|
---|
| 983 | UvData.Mesh=sqrt((UvData.XMax-UvData.XMin)*(UvData.YMax-UvData.YMin)/((np_A(1)-1) * (np_A(2)-1))) ;
|
---|
| 984 | end
|
---|
| 985 | if isempty(coord_x)&~isempty(CellVarIndex)
|
---|
| 986 | VarIndex=CellVarIndex{imax}; % list of variable indices
|
---|
| 987 | DimIndex=UvData.Field.VarDimIndex{VarIndex(1)}; %list of dim indices for the variable
|
---|
| 988 | if NbDim==3
|
---|
| 989 | nbpoints=UvData.Field.DimValue(DimIndex(1));
|
---|
| 990 | %Zvar=DimVarIndex(DimIndex(1));
|
---|
| 991 | %Zvar=DimVarIndex(1);
|
---|
| 992 | Zvar=VarType{imax}.coord_3;
|
---|
| 993 | if Zvar~=0 % z is a dimension variable
|
---|
| 994 | ZName=UvData.Field.ListVarName{Zvar};
|
---|
| 995 | eval(['UvData.ZMax=max(UvData.Field.' ZName ');'])
|
---|
| 996 | eval(['UvData.ZMin=min(UvData.Field.' ZName ');'])
|
---|
| 997 | else
|
---|
| 998 | testcoord_z=0;
|
---|
| 999 | if length(UvData.Field.VarAttribute)>=VarIndex(1)
|
---|
| 1000 | if isfield(UvData.Field.VarAttribute{VarIndex(1)},'Coord_1')%regular grid
|
---|
| 1001 | Coord_z=UvData.Field.VarAttribute{VarIndex(1)}.Coord_1;
|
---|
| 1002 | UvData.ZMax=max(Coord_z);
|
---|
| 1003 | UvData.ZMin=min(Coord_z);
|
---|
| 1004 | testcoord_z=1;
|
---|
| 1005 | end
|
---|
| 1006 | end
|
---|
| 1007 | if ~testcoord_z
|
---|
| 1008 | UvData.ZMin=1;
|
---|
| 1009 | UvData.ZMax=UvData.Field.DimValue(DimIndex(1));
|
---|
| 1010 | end
|
---|
| 1011 | end
|
---|
| 1012 | UvData.Mesh=(UvData.ZMax-UvData.ZMin)/(nbpoints-1);
|
---|
| 1013 | elseif NbDim==2
|
---|
| 1014 | nbpoints_y=UvData.Field.DimValue(DimIndex(1));
|
---|
| 1015 | Yvar=VarType{imax}.coord_y;
|
---|
| 1016 | if Yvar~=0 % x is a dimension variable
|
---|
| 1017 | YName=UvData.Field.ListVarName{Yvar};
|
---|
| 1018 | eval(['UvData.YMax=max(UvData.Field.' YName ');'])
|
---|
| 1019 | eval(['UvData.YMin=min(UvData.Field.' YName ');'])
|
---|
| 1020 | else
|
---|
| 1021 | testcoord_y=0;
|
---|
| 1022 | if ~testcoord_y
|
---|
| 1023 | UvData.YMin=1;
|
---|
| 1024 | UvData.YMax=UvData.Field.DimValue(DimIndex(1));
|
---|
| 1025 | end
|
---|
| 1026 | end
|
---|
| 1027 | DY=(UvData.YMax-UvData.YMin)/(nbpoints_y-1);
|
---|
| 1028 | nbpoints_x=UvData.Field.DimValue(DimIndex(2));
|
---|
| 1029 | Xvar=VarType{imax}.coord_x;
|
---|
| 1030 | if Xvar~=0 % x is a dimension variable
|
---|
| 1031 | XName=UvData.Field.ListVarName{Xvar};
|
---|
| 1032 | eval(['UvData.XMax=max(UvData.Field.' XName ');'])
|
---|
| 1033 | eval(['UvData.XMin=min(UvData.Field.' XName ');'])
|
---|
| 1034 | else
|
---|
| 1035 | testcoord_x=0;
|
---|
| 1036 | if ~testcoord_x
|
---|
| 1037 | UvData.XMin=1;
|
---|
| 1038 | UvData.XMax=UvData.Field.DimValue(DimIndex(2));
|
---|
| 1039 | end
|
---|
| 1040 | end
|
---|
| 1041 | DX=(UvData.XMax-UvData.XMin)/(nbpoints_x-1);
|
---|
| 1042 | UvData.Mesh= sqrt(DX*DY);
|
---|
| 1043 | end
|
---|
| 1044 | end
|
---|
| 1045 |
|
---|
| 1046 | %create a default projection menuplane
|
---|
| 1047 | UvData.Object{1}.Style='plane';%main plotting plane
|
---|
| 1048 | UvData.Object{1}.ProjMode='projection';%main plotting plane
|
---|
| 1049 | if ~isfield(UvData.Object{1},'plotaxes')
|
---|
| 1050 | UvData.Object{1}.plotaxes=handles.axes3;%default plotting axis
|
---|
| 1051 | set(handles.list_object,'String',{'1-PLANE';'...'});
|
---|
| 1052 | set(handles.list_object,'Value',1);
|
---|
| 1053 | end
|
---|
| 1054 |
|
---|
| 1055 | %3D case (menuvolume)
|
---|
| 1056 | if NbDim==3
|
---|
| 1057 | UvData.Object{1}.NbDim=UvData.NbDim;%test for 3D objects
|
---|
| 1058 | UvData.Object{1}.RangeZ=UvData.Mesh;%main plotting plane
|
---|
| 1059 | UvData.Object{1}.Coord(1,3)=(UvData.ZMin+UvData.ZMax)/2;%section at a middle plane chosen
|
---|
| 1060 | UvData.Object{1}.Phi=0;
|
---|
| 1061 | UvData.Object{1}.Theta=0;
|
---|
| 1062 | UvData.Object{1}.Psi=0;
|
---|
| 1063 | UvData.Object{1}.HandlesDisplay=plot(0,0,'Tag','proj_object');% A REVOIR
|
---|
| 1064 | PlotHandles=get_plot_handles(handles);
|
---|
| 1065 | ZBounds(1)=UvData.ZMin; %minimum for the Z slider
|
---|
| 1066 | ZBounds(2)=UvData.ZMax;%maximum for the Z slider
|
---|
| 1067 | set_object(UvData.Object{1},PlotHandles,ZBounds);
|
---|
| 1068 | set(handles.list_object,'Value',1);
|
---|
| 1069 | %multilevel case (single menuplane in a 3D space)
|
---|
| 1070 | elseif isfield(UvData,'Z')
|
---|
| 1071 | if isfield(UvData,'CoordType')& isequal(UvData.CoordType,'phys') & isfield(UvData,'XmlData')
|
---|
| 1072 | XmlData=UvData.XmlData;
|
---|
| 1073 | if isfield(XmlData,'PlanePos')
|
---|
| 1074 | UvData.Object{1}.Coord=XmlData.PlanePos(UvData.ZIndex,:);
|
---|
| 1075 | end
|
---|
| 1076 | if isfield(XmlData,'PlaneAngle')
|
---|
| 1077 | siz=size(XmlData.PlaneAngle);
|
---|
| 1078 | indangle=min(siz(1),UvData.ZIndex);%take first angle if a single angle is defined (translating scanning)
|
---|
| 1079 | UvData.Object{1}.Phi=XmlData.PlaneAngle(indangle,1);
|
---|
| 1080 | UvData.Object{1}.Theta=XmlData.PlaneAngle(indangle,2);
|
---|
| 1081 | UvData.Object{1}.Psi=XmlData.PlaneAngle(indangle,3);
|
---|
| 1082 | end
|
---|
| 1083 | elseif isfield(UvData,'ZIndex')
|
---|
| 1084 | UvData.Object{1}.ZObject=UvData.ZIndex;
|
---|
| 1085 | end
|
---|
| 1086 | end
|
---|
| 1087 |
|
---|
| 1088 | %Plot the projections on all existing projection objects
|
---|
| 1089 | keeplim=get(handles.FixedLimits,'Value');
|
---|
| 1090 | %reset the min and max of scalar if only the mask is displayed
|
---|
| 1091 | if isfield(UvData,'Mask')&~isfield(UvData,'A')
|
---|
| 1092 | set(handles.MinA,'String','0')
|
---|
| 1093 | set(handles.MaxA,'String','255')
|
---|
| 1094 | end
|
---|
| 1095 |
|
---|
| 1096 | Object=UvData.Object;
|
---|
| 1097 | for iobj=1:length(Object)
|
---|
| 1098 | if ~isempty(Object{iobj})%& isfield(Object{iobj},'plotaxes')& ishandle(Object{iobj}.plotaxes)
|
---|
| 1099 | %Projeter les champs sur l'objet:*
|
---|
| 1100 | ObjectData=proj_field(UvData.Field,Object{iobj},iobj);
|
---|
| 1101 |
|
---|
| 1102 | %use of mask
|
---|
| 1103 | if isfield(ObjectData,'NbDim')&isequal(ObjectData.NbDim,2)
|
---|
| 1104 | if isfield(ObjectData,'Mask') & isfield(ObjectData,'A')
|
---|
| 1105 | flag_mask=double(ObjectData.Mask>200);%=0 for masked regions
|
---|
| 1106 | AX=ObjectData.AX;
|
---|
| 1107 | AY=ObjectData.AY;
|
---|
| 1108 | MaskX=ObjectData.MaskX;
|
---|
| 1109 | MaskY=ObjectData.MaskY;
|
---|
| 1110 | if ~isequal(MaskX,AX)|~isequal(MaskY,AY)
|
---|
| 1111 | nxy=size(flag_mask);
|
---|
| 1112 | sizpx=(ObjectData.MaskX(end)-ObjectData.MaskX(1))/(nxy(2)-1);%size of a mask pixel
|
---|
| 1113 | sizpy=(ObjectData.MaskY(1)-ObjectData.MaskY(end))/(nxy(1)-1);
|
---|
| 1114 | x_mask=[ObjectData.MaskX(1):sizpx:ObjectData.MaskX(end)]; % pixel x coordinates for image display
|
---|
| 1115 | y_mask=[ObjectData.MaskY(1):-sizpy:ObjectData.MaskY(end)];% pixel x coordinates for image display
|
---|
| 1116 | %project on the positions of the scalar
|
---|
| 1117 | npxy=size(ObjectData.A);
|
---|
| 1118 | dxy(1)=(ObjectData.AY(end)-ObjectData.AY(1))/(npxy(1)-1);%grid mesh in y
|
---|
| 1119 | dxy(2)=(ObjectData.AX(end)-ObjectData.AX(1))/(npxy(2)-1);%grid mesh in x
|
---|
| 1120 | xi=[ObjectData.AX(1):dxy(2):ObjectData.AX(end)];
|
---|
| 1121 | yi=[ObjectData.AY(1):dxy(1):ObjectData.AY(end)];
|
---|
| 1122 | [XI,YI]=meshgrid(xi,yi);% creates the matrix of regular coordinates
|
---|
| 1123 | flag_mask = interp2(x_mask,y_mask,flag_mask,XI,YI);
|
---|
| 1124 | end
|
---|
| 1125 | AClass=class(ObjectData.A);
|
---|
| 1126 | ObjectData.A=flag_mask.*double(ObjectData.A);
|
---|
| 1127 | ObjectData.A=feval(AClass,ObjectData.A);
|
---|
| 1128 | ind_off=[];
|
---|
| 1129 | if isfield(ObjectData,'ListVarName')
|
---|
| 1130 | for ilist=1:length(ObjectData.ListVarName)
|
---|
| 1131 | if isequal(ObjectData.ListVarName{ilist},'Mask')|isequal(ObjectData.ListVarName{ilist},'MaskX')|isequal(ObjectData.ListVarName{ilist},'MaskY')
|
---|
| 1132 | ind_off=[ind_off ilist];
|
---|
| 1133 | end
|
---|
| 1134 | end
|
---|
| 1135 | ObjectData.ListVarName(ind_off)=[];
|
---|
| 1136 | ObjectData.VarDimIndex(ind_off)=[];
|
---|
| 1137 | ind_off=[];
|
---|
| 1138 | for ilist=1:length(ObjectData.ListDimName)
|
---|
| 1139 | if isequal(ObjectData.ListDimName{ilist},'MaskX')|isequal(ObjectData.ListDimName{ilist},'MaskY')
|
---|
| 1140 | ind_off=[ind_off ilist];
|
---|
| 1141 | end
|
---|
| 1142 | end
|
---|
| 1143 | ObjectData.ListDimName(ind_off)=[];
|
---|
| 1144 | ObjectData.DimValue(ind_off)=[];
|
---|
| 1145 | end
|
---|
| 1146 | end
|
---|
| 1147 | end
|
---|
| 1148 | if ~isempty(ObjectData)
|
---|
| 1149 | haxes=[];%default
|
---|
| 1150 | if isfield(Object{iobj},'plotaxes')
|
---|
| 1151 | haxes=Object{iobj}.plotaxes;%axes used for representing the projection on the object
|
---|
| 1152 | end
|
---|
| 1153 | PosColorbar=[];%default: no colorbar
|
---|
| 1154 | if ishandle(haxes) & isequal(get(haxes,'Tag'),'axes3')& isfield(UvData,'PosColorbar')
|
---|
| 1155 | PosColorbar=UvData.PosColorbar;%prescribe the colorbar position on the view_field interface
|
---|
| 1156 | else
|
---|
| 1157 | PosColorbar='*';%default position
|
---|
| 1158 | end
|
---|
| 1159 | PlotParam=read_plot_param(handles);%read plotting parameters on the view_field interface
|
---|
| 1160 | [PlotType,ScalOut,UvData.Object{iobj}.plotaxes]=plot_field(ObjectData,haxes,PlotParam,keeplim,PosColorbar);
|
---|
| 1161 | if isequal(PlotType,'none')
|
---|
| 1162 | hget_field=findobj(allchild(0),'name','get_field');
|
---|
| 1163 | if isempty(hget_field)
|
---|
| 1164 | get_field([],ObjectData)% the projected field cannot be automatically plotted: use get_field to specify the variablesdelete(hget_field)
|
---|
| 1165 | else
|
---|
| 1166 | msgbox_view_field('ERROR','The field defined by get_field cannot be plotted')
|
---|
| 1167 | end
|
---|
| 1168 | end
|
---|
| 1169 | UvData.Object{iobj}.PlotParam=ScalOut; %record the plotting parameters
|
---|
| 1170 | end
|
---|
| 1171 |
|
---|
| 1172 | end
|
---|
| 1173 | end
|
---|
| 1174 |
|
---|
| 1175 | %display the updated plotting parameters for the base menuplane
|
---|
| 1176 | write_plot_param(handles,UvData.Object{1}.PlotParam);% update the display of the plotting parameters
|
---|
| 1177 | set(handles.view_field,'UserData',UvData)
|
---|
| 1178 |
|
---|
| 1179 | %update the mask
|
---|
| 1180 | if isequal(get(handles.mask_test,'Value'),1)%if the mask option is on
|
---|
| 1181 | update_mask(handles,num_i1,num_i2);
|
---|
| 1182 | end
|
---|
| 1183 |
|
---|
| 1184 | %prepare the menus of histograms (for the whole menuvolume in 3D case)
|
---|
| 1185 | menu_histo=(UvData.Field.ListVarName)';
|
---|
| 1186 | ind_bad=[];
|
---|
| 1187 | nb_histo=1;
|
---|
| 1188 | for ivar=1:numel(menu_histo)
|
---|
| 1189 | if isfield(UvData.Field,'VarAttribute') && numel(UvData.Field.VarAttribute)>=ivar && isfield(UvData.Field.VarAttribute{ivar},'Role')
|
---|
| 1190 | Role=UvData.Field.VarAttribute{ivar}.Role;
|
---|
| 1191 | switch Role
|
---|
| 1192 | case {'coord_x','coord_y','coord_z','dimvar'}
|
---|
| 1193 | ind_bad=[ind_bad ivar];
|
---|
| 1194 | case {'vector_y'}
|
---|
| 1195 | nb_histo=nb_histo+1;
|
---|
| 1196 | end
|
---|
| 1197 | end
|
---|
| 1198 | DimCell=UvData.Field.VarDimName{ivar};
|
---|
| 1199 | DimName='';
|
---|
| 1200 | if ischar(DimCell)
|
---|
| 1201 | DimName=DimCell;
|
---|
| 1202 | elseif iscell(DimCell)&& numel(DimCell)==1
|
---|
| 1203 | DimName=DimCell{1};
|
---|
| 1204 | end
|
---|
| 1205 | if strcmp(DimName,menu_histo{ivar})
|
---|
| 1206 | ind_bad=[ind_bad ivar];
|
---|
| 1207 | end
|
---|
| 1208 | end
|
---|
| 1209 | menu_histo(ind_bad)=[];
|
---|
| 1210 | test_v=0;
|
---|
| 1211 | if ~isempty(menu_histo)
|
---|
| 1212 | set(handles.histo1_menu,'Value',1)
|
---|
| 1213 | set(handles.histo1_menu,'String',menu_histo)
|
---|
| 1214 | histo1_menu_Callback(hObject, eventdata, handles)
|
---|
| 1215 | if nb_histo > 1
|
---|
| 1216 | test_v=1;
|
---|
| 1217 | set(handles.histo2_menu,'Visible','on')
|
---|
| 1218 | set(handles.histo_v,'Visible','on')
|
---|
| 1219 | set(handles.histo2_menu,'String',menu_histo)
|
---|
| 1220 | set(handles.histo2_menu,'Value',2)
|
---|
| 1221 | histo2_menu_Callback(hObject, eventdata, handles)
|
---|
| 1222 | end
|
---|
| 1223 | end
|
---|
| 1224 | if ~test_v
|
---|
| 1225 | set(handles.histo2_menu,'Visible','off')
|
---|
| 1226 | set(handles.histo_v,'Visible','off')
|
---|
| 1227 | cla(handles.histo_v)
|
---|
| 1228 | set(handles.histo2_menu,'Value',1)
|
---|
| 1229 | end
|
---|
| 1230 |
|
---|
| 1231 | %display time
|
---|
| 1232 | testimedoc=0;
|
---|
| 1233 | if isfield(UvData,'XmlData') && isfield(UvData.XmlData,'Time')
|
---|
| 1234 | if isempty(num_i2)
|
---|
| 1235 | num_i2=num_i1;
|
---|
| 1236 | end
|
---|
| 1237 | if isempty(num_j1)
|
---|
| 1238 | num_j1=1;
|
---|
| 1239 | end
|
---|
| 1240 | if isempty(num_j2)
|
---|
| 1241 | num_j2=num_j1;
|
---|
| 1242 | end
|
---|
| 1243 | siz=size(UvData.XmlData.Time);
|
---|
| 1244 | if siz(1)>=max(num_i1,num_i2) & siz(2)>=max(num_j1,num_j2)
|
---|
| 1245 | abstime=(UvData.XmlData.Time(num_i1,num_j1)+UvData.XmlData.Time(num_i2,num_j2))/2;%overset the time read from files
|
---|
| 1246 | dt=(UvData.XmlData.Time(num_i2,num_j2)-UvData.XmlData.Time(num_i1,num_j1));
|
---|
| 1247 | testimedoc=1;
|
---|
| 1248 | end
|
---|
| 1249 | end
|
---|
| 1250 | if isfield(UvData,'XmlData_1') && isfield(UvData.XmlData_1,'Time')
|
---|
| 1251 | [P,F,str1,str2,str_a,str_b,E,NomType]=name2display(['xx' get(handles.FileIndex_1,'String') get(handles.FileExt_1,'String')]);
|
---|
| 1252 | num_i2=str2num(str2);
|
---|
| 1253 | if isempty(num_i2)
|
---|
| 1254 | num_i2=num_i1;
|
---|
| 1255 | end
|
---|
| 1256 | num_j1=str2num(str_a);
|
---|
| 1257 | if isempty(num_j1)
|
---|
| 1258 | num_j1=1;
|
---|
| 1259 | end
|
---|
| 1260 | num_j2=str2num(str_b);
|
---|
| 1261 | if isempty(num_j2)
|
---|
| 1262 | num_j2=num_j1;
|
---|
| 1263 | end
|
---|
| 1264 | num_i1=str2num(str1);
|
---|
| 1265 | siz=size(UvData.XmlData_1.Time);
|
---|
| 1266 | if siz(1)>=max(num_i1,num_i2) & siz(2)>=max(num_j1,num_j2)
|
---|
| 1267 | abstime_1=(UvData.XmlData_1.Time(num_i1,num_j1)+UvData.XmlData_1.Time(num_i2,num_j2))/2;%overset the time read from files
|
---|
| 1268 | end
|
---|
| 1269 | end
|
---|
| 1270 | set(handles.abs_time,'String',num2str(abstime,4))
|
---|
| 1271 | set(handles.abs_time_1,'String',num2str(abstime_1,4))
|
---|
| 1272 | if testimedoc && isfield(UvData,'dt')
|
---|
| 1273 | dt=UvData.dt;
|
---|
| 1274 | end
|
---|
| 1275 | if isequal(dt,0)
|
---|
| 1276 | set(handles.Dt_txt,'String','')
|
---|
| 1277 | else
|
---|
| 1278 | if ~(isfield(UvData,'TimeUnit') && ~isempty(UvData.TimeUnit))
|
---|
| 1279 | set(handles.Dt_txt,'String',['Dt=' num2str(1000*dt,3) ' 10^(-3)'] )
|
---|
| 1280 | else
|
---|
| 1281 | set(handles.Dt_txt,'String',['Dt=' num2str(1000*dt,3) ' m' UvData.TimeUnit] )
|
---|
| 1282 | end
|
---|
| 1283 | end
|
---|
| 1284 | set(handles.run0,'BackgroundColor',[1 0 0])
|
---|
| 1285 |
|
---|
| 1286 |
|
---|
| 1287 |
|
---|
| 1288 | %-------------------------------------------------------------------
|
---|
| 1289 | % --- translate coordinate to matrix index
|
---|
| 1290 | %-------------------------------------------------------------------
|
---|
| 1291 | function [indx,indy]=pos2ind(x0,rangx0,nxy)
|
---|
| 1292 | indx=1+round((nxy(2)-1)*(x0-rangx0(1))/(rangx0(2)-rangx0(1)));% index x of pixel
|
---|
| 1293 | indy=1+round((nxy(1)-1)*(y12-rangy0(1))/(rangy0(2)-rangy0(1)));% index y of pixel
|
---|
| 1294 |
|
---|
| 1295 | %-------------------------------------------------------------------
|
---|
| 1296 | % --- Executes on button press in 'FixedLimits'.
|
---|
| 1297 | %-------------------------------------------------------------------
|
---|
| 1298 | function FixedLimits_Callback(hObject, eventdata, handles)
|
---|
| 1299 | test=get(handles.FixedLimits,'Value');
|
---|
| 1300 | if test
|
---|
| 1301 | set(handles.FixedLimits,'BackgroundColor',[1 1 0])
|
---|
| 1302 | else
|
---|
| 1303 | set(handles.FixedLimits,'BackgroundColor',[0.7 0.7 0.7])
|
---|
| 1304 | end
|
---|
| 1305 |
|
---|
| 1306 | %-------------------------------------------------------------------
|
---|
| 1307 | % --- Executes on button press in auto_xy.
|
---|
| 1308 | function auto_xy_Callback(hObject, eventdata, handles)
|
---|
| 1309 | test=get(handles.auto_xy,'Value');
|
---|
| 1310 | if test
|
---|
| 1311 | set(handles.auto_xy,'BackgroundColor',[1 1 0])
|
---|
| 1312 | cla(handles.axes3)
|
---|
| 1313 | update_plot(handles)
|
---|
| 1314 | else
|
---|
| 1315 | set(handles.auto_xy,'BackgroundColor',[0.7 0.7 0.7])
|
---|
| 1316 | update_plot(handles)
|
---|
| 1317 | % axis(handles.axes3,'image')
|
---|
| 1318 | end
|
---|
| 1319 |
|
---|
| 1320 |
|
---|
| 1321 | %-------------------------------------------------------------------
|
---|
| 1322 |
|
---|
| 1323 | %-------------------------------------------------------------------
|
---|
| 1324 | % --- Executes on button press in 'zoom'.
|
---|
| 1325 | %-------------------------------------------------------------------
|
---|
| 1326 | function zoom_Callback(hObject, eventdata, handles)
|
---|
| 1327 | if (get(handles.zoom,'Value') == 1);
|
---|
| 1328 | set(handles.zoom,'BackgroundColor',[1 1 0])
|
---|
| 1329 | set(handles.FixedLimits,'Value',1)% propose by default fixed limits for the plotting axes
|
---|
| 1330 | set(handles.FixedLimits,'BackgroundColor',[1 1 0])
|
---|
| 1331 | else
|
---|
| 1332 | set(handles.zoom,'BackgroundColor',[0.7 0.7 0.7])
|
---|
| 1333 | end
|
---|
| 1334 |
|
---|
| 1335 | %-------------------------------------------------------------------
|
---|
| 1336 | %----Executes on button press in 'record': records the current flags of manual correction.
|
---|
| 1337 | %-------------------------------------------------------------------
|
---|
| 1338 | function record_Callback(hObject, eventdata, handles)
|
---|
| 1339 | % [filebase,num_i1,num_j1,num_i2,num_j2,Ext,NomType,SubDir]=read_input_file(handles);
|
---|
| 1340 | filename=read_file_boxes(handles);
|
---|
| 1341 | AxeData=get(gca,'UserData');
|
---|
| 1342 | [erread,message]=fileattrib(filename);
|
---|
| 1343 | if ~isempty(message) && ~isequal(message.UserWrite,1)
|
---|
| 1344 | msgbox_view_field('ERROR',['no writting access to ' filename])
|
---|
| 1345 | return
|
---|
| 1346 | end
|
---|
| 1347 | test_civ2=isequal(get(handles.civ2,'BackgroundColor'),[1 1 0]);
|
---|
| 1348 | test_civ1=isequal(get(handles.civ1,'BackgroundColor'),[1 1 0]);
|
---|
| 1349 | if ~test_civ2 && ~test_civ1
|
---|
| 1350 | msgbox_view_field('ERROR','manual correction only possible for CIV1 or CIV2 velocity fields')
|
---|
| 1351 | end
|
---|
| 1352 | if test_civ2
|
---|
| 1353 | nbname='nb_vectors2';
|
---|
| 1354 | flagname='vec2_FixFlag';
|
---|
| 1355 | attrname='fix2';
|
---|
| 1356 | end
|
---|
| 1357 | if test_civ1
|
---|
| 1358 | nbname='nb_vectors';
|
---|
| 1359 | flagname='vec_FixFlag';
|
---|
| 1360 | attrname='fix';
|
---|
| 1361 | end
|
---|
| 1362 | %write fix flags in the netcdf file
|
---|
| 1363 | hhh=which('netcdf.open');% look for built-in matlab netcdf library
|
---|
| 1364 | if ~isequal(hhh,'')% case of new builtin Matlab netcdf library
|
---|
| 1365 | nc=netcdf.open(filename,'NC_WRITE');
|
---|
| 1366 | netcdf.reDef(nc)
|
---|
| 1367 | netcdf.putAtt(nc,netcdf.getConstant('NC_GLOBAL'),attrname,1)
|
---|
| 1368 | dimid = netcdf.inqDimID(nc,nbname);
|
---|
| 1369 | try
|
---|
| 1370 | varid = netcdf.inqVarID(nc,flagname);% look for already existing fixflag variable
|
---|
| 1371 | catch
|
---|
| 1372 | varid=netcdf.defVar(nc,flagname,'double',dimid);%create fixflag variable if it does not exist
|
---|
| 1373 | end
|
---|
| 1374 | netcdf.endDef(nc)
|
---|
| 1375 | netcdf.putVar(nc,varid,AxeData.FF);
|
---|
| 1376 | netcdf.close(nc)
|
---|
| 1377 | else %old netcdf library
|
---|
| 1378 | netcdf_toolbox(filename,AxeData,attrname,nbname,flagname)
|
---|
| 1379 | end
|
---|
| 1380 |
|
---|
| 1381 | function netcdf_toolbox(filename,AxeData,attrname,nbname,flagname)
|
---|
| 1382 | nc=netcdf(filename,'write'); %open netcdf file
|
---|
| 1383 | result=redef(nc);
|
---|
| 1384 | eval(['nc.' attrname '=1;']);
|
---|
| 1385 | theDim=nc(nbname) ;% get the number of velocity vectors
|
---|
| 1386 | nb_vectors=size(theDim);
|
---|
| 1387 | var_FixFlag=ncvar(flagname,nc);% var_FixFlag will be written as the netcdf variable vec_FixFlag
|
---|
| 1388 | var_FixFlag(1:nb_vectors)=AxeData.FF;%
|
---|
| 1389 | fin=close(nc);
|
---|
| 1390 |
|
---|
| 1391 |
|
---|
| 1392 | %-------------------------------------------------------------------
|
---|
| 1393 | %determines the fields to read from the interface
|
---|
| 1394 | %------------------------------------------------------------------
|
---|
| 1395 | function [VelType,civ]=setfield(handles)
|
---|
| 1396 |
|
---|
| 1397 | VelType=[]; %default
|
---|
| 1398 | if (get(handles.civ1,'Value') == 1);
|
---|
| 1399 | VelType='civ1';
|
---|
| 1400 | % interp1
|
---|
| 1401 | elseif (get(handles.interp1,'Value') == 1);
|
---|
| 1402 | VelType='interp1';
|
---|
| 1403 | % filter1
|
---|
| 1404 | elseif (get(handles.filter1,'Value') == 1);
|
---|
| 1405 | VelType='filter1';
|
---|
| 1406 | % CIV2
|
---|
| 1407 | elseif (get(handles.civ2,'Value') == 1);
|
---|
| 1408 | VelType='civ2';
|
---|
| 1409 | % interp2
|
---|
| 1410 | elseif (get(handles.interp2,'Value') == 1);
|
---|
| 1411 | VelType='interp2';
|
---|
| 1412 | % filter2
|
---|
| 1413 | elseif (get(handles.filter2,'Value') == 1);
|
---|
| 1414 | VelType='filter2';
|
---|
| 1415 | end
|
---|
| 1416 |
|
---|
| 1417 | if isequal(get(handles.filter2,'Visible'),'on');
|
---|
| 1418 | civ=6;
|
---|
| 1419 | % interp1
|
---|
| 1420 | elseif isequal(get(handles.interp2,'Visible'),'on');
|
---|
| 1421 | civ=5;
|
---|
| 1422 | % filter1
|
---|
| 1423 | elseif isequal(get(handles.civ2,'Visible'),'on');
|
---|
| 1424 | civ=4;
|
---|
| 1425 | % CIV2
|
---|
| 1426 | elseif isequal(get(handles.filter1,'Visible'),'on');
|
---|
| 1427 | civ=3;
|
---|
| 1428 | % interp2
|
---|
| 1429 | elseif isequal(get(handles.interp1,'Visible'),'on');
|
---|
| 1430 | civ=2;
|
---|
| 1431 | % filter2
|
---|
| 1432 | elseif isequal(get(handles.civ1,'Visible'),'on');
|
---|
| 1433 | civ=1;
|
---|
| 1434 | else
|
---|
| 1435 | civ=0;
|
---|
| 1436 | end
|
---|
| 1437 |
|
---|
| 1438 | %-------------------------------------------------------------------
|
---|
| 1439 | %determines the veltype of the second field to read from the iinterface
|
---|
| 1440 | %------------------------------------------------------------------
|
---|
| 1441 | function VelType=setfield_1(handles)
|
---|
| 1442 |
|
---|
| 1443 | VelType=[]; %default
|
---|
| 1444 | if (get(handles.civ1_1,'Value') == 1);
|
---|
| 1445 | VelType='civ1';
|
---|
| 1446 | % interp1
|
---|
| 1447 | elseif (get(handles.interp1_1,'Value') == 1);
|
---|
| 1448 | VelType='interp1';
|
---|
| 1449 | % filter1
|
---|
| 1450 | elseif (get(handles.filter1_1,'Value') == 1);
|
---|
| 1451 | VelType='filter1';
|
---|
| 1452 | % CIV2
|
---|
| 1453 | elseif (get(handles.civ2_1,'Value') == 1);
|
---|
| 1454 | VelType='civ2';
|
---|
| 1455 | % interp2
|
---|
| 1456 | elseif (get(handles.interp2_1,'Value') == 1);
|
---|
| 1457 | VelType='interp2';
|
---|
| 1458 | % filter2
|
---|
| 1459 | elseif (get(handles.filter2_1,'Value') == 1);
|
---|
| 1460 | VelType='filter2';
|
---|
| 1461 | end
|
---|
| 1462 |
|
---|
| 1463 |
|
---|
| 1464 | %---------------------------------------------------
|
---|
| 1465 | % --- Executes on button press in SubField
|
---|
| 1466 | function SubField_Callback(hObject, eventdata, handles)
|
---|
| 1467 | huvmat=get(handles.run0,'parent');
|
---|
| 1468 | UvData=get(huvmat,'UserData');
|
---|
| 1469 | if get(handles.SubField,'Value')==0% if the subfield button is desactivated
|
---|
| 1470 | set(handles.RootPath_1,'String','')
|
---|
| 1471 | set(handles.RootFile_1,'String','')
|
---|
| 1472 | set(handles.SubDir_1,'String','');
|
---|
| 1473 | set(handles.FileIndex_1,'String','');
|
---|
| 1474 | set(handles.FileExt_1,'String','');
|
---|
| 1475 | set(handles.RootPath_1,'Visible','off')
|
---|
| 1476 | set(handles.RootFile_1,'Visible','off')
|
---|
| 1477 | set(handles.SubDir_1,'Visible','off');
|
---|
| 1478 | set(handles.FileIndex_1,'Visible','off');
|
---|
| 1479 | set(handles.FileExt_1,'Visible','off');
|
---|
| 1480 | set(handles.Fields_1,'Value',1);%set to blank state
|
---|
| 1481 | set_veltype_display([handles.civ1_1 handles.interp1_1 handles.filter1_1 ...
|
---|
| 1482 | handles.civ2_1 handles.interp2_1 handles.filter2_1],0)
|
---|
| 1483 | if isfield(UvData,'XmlData_1')
|
---|
| 1484 | UvData=rmfield(UvData,'XmlData_1');
|
---|
| 1485 | end
|
---|
| 1486 | set(huvmat,'UserData',UvData);
|
---|
| 1487 | run0_Callback(hObject, eventdata, handles); %run
|
---|
| 1488 | else
|
---|
| 1489 | MenuBrowse_1_Callback(hObject, eventdata, handles)
|
---|
| 1490 | end
|
---|
| 1491 |
|
---|
| 1492 | % %----------------------------------------------
|
---|
| 1493 | % %read the data displayed for the input rootfile windows (new)
|
---|
| 1494 | % %-------------------------------------------------
|
---|
| 1495 | function [FileName,RootPath,FileBase,FileIndices,FileExt,SubDir]=read_file_boxes(handles)
|
---|
| 1496 | RootPath=get(handles.RootPath,'String');
|
---|
| 1497 | FileName=RootPath; %default
|
---|
| 1498 | SubDir=get(handles.SubDir,'String');
|
---|
| 1499 | if ~isempty(SubDir) && ~isequal(SubDir,'')
|
---|
| 1500 | if (isequal(SubDir(1),'/')|| isequal(SubDir(1),'\'))
|
---|
| 1501 | SubDir(1)=[]; %suppress possible / or \ separator
|
---|
| 1502 | end
|
---|
| 1503 | FileName=fullfile(RootPath,SubDir);
|
---|
| 1504 | end
|
---|
| 1505 | RootFile=get(handles.RootFile,'String');
|
---|
| 1506 | if ~isempty(RootFile) && ~isequal(RootFile,'')
|
---|
| 1507 | if (isequal(RootFile(1),'/')|| isequal(RootFile(1),'\'))
|
---|
| 1508 | RootFile(1)=[]; %suppress possible / or \ separator
|
---|
| 1509 | end
|
---|
| 1510 | FileName=fullfile(FileName,RootFile);
|
---|
| 1511 | end
|
---|
| 1512 | FileBase=fullfile(RootPath,RootFile);
|
---|
| 1513 | FileIndices=get(handles.FileIndex,'String');
|
---|
| 1514 | FileExt=get(handles.FileExt,'String');
|
---|
| 1515 | FileName=[FileName FileIndices FileExt];
|
---|
| 1516 |
|
---|
| 1517 | %----------------------------------------------
|
---|
| 1518 | %read the data displayed for the second input rootfile windows
|
---|
| 1519 | %-------------------------------------------------
|
---|
| 1520 | function [FileName_1,RootPath_1,FileBase_1,FileIndices_1,FileExt_1,SubDir_1]=read_file_boxes_1(handles)
|
---|
| 1521 | RootPath_1=get(handles.RootPath_1,'String'); % read the data from the file1_input window
|
---|
| 1522 | if isequal(RootPath_1,'"'),RootPath_1=get(handles.RootPath,'String'); end;
|
---|
| 1523 | FileName_1=RootPath_1; %default
|
---|
| 1524 | SubDir_1=get(handles.SubDir_1,'String');
|
---|
| 1525 | if isequal(SubDir_1,'"')
|
---|
| 1526 | SubDir_1=get(handles.SubDir,'String');
|
---|
| 1527 | end
|
---|
| 1528 | if ~isempty(SubDir_1) && ~isequal(SubDir_1,'')
|
---|
| 1529 | if (isequal(SubDir_1(1),'/')|| isequal(SubDir_1(1),'\'))
|
---|
| 1530 | SubDir_1(1)=[]; %suppress possible / or \ separator
|
---|
| 1531 | end
|
---|
| 1532 | FileName_1=fullfile(RootPath_1,SubDir_1);
|
---|
| 1533 | end
|
---|
| 1534 | RootFile_1=get(handles.RootFile_1,'String');
|
---|
| 1535 | if isequal(RootFile_1,'"'),RootFile_1=get(handles.RootFile,'String'); end;
|
---|
| 1536 | if ~isempty(RootFile_1) && ~isequal(RootFile_1,'')
|
---|
| 1537 | if ~(isequal(RootFile_1(1),'/')|isequal(RootFile_1(1),'\'))
|
---|
| 1538 | RootFile_1(1)=[];%suppress possible / or \ separator
|
---|
| 1539 | end
|
---|
| 1540 | FileName_1=fullfile(FileName_1,RootFile_1);
|
---|
| 1541 | end
|
---|
| 1542 | FileBase_1=fullfile(RootPath_1,RootFile_1);
|
---|
| 1543 | FileIndices_1=get(handles.FileIndex_1,'String');
|
---|
| 1544 | FileExt_1=get(handles.FileExt_1,'String');
|
---|
| 1545 | if isequal(FileExt_1,'"'),FileExt_1=get(handles.FileExt,'String'); end;
|
---|
| 1546 | FileName_1=[FileName_1 FileIndices_1 FileExt_1];
|
---|
| 1547 |
|
---|
| 1548 | %---------------------------------------------------
|
---|
| 1549 | % --- Executes on menu selection Fields
|
---|
| 1550 | function Fields_Callback(hObject, eventdata, handles)
|
---|
| 1551 | %-------------------------------------------------
|
---|
| 1552 | huvmat=get(handles.Fields,'parent');
|
---|
| 1553 | list_fields=get(handles.Fields,'String');% list menu fields
|
---|
| 1554 | index_fields=get(handles.Fields,'Value');% selected string index
|
---|
| 1555 | field= list_fields{index_fields(1)}; % selected string
|
---|
| 1556 | if isequal(field,'get_field...')
|
---|
| 1557 | veltype_handles=[handles.civ1 handles.interp1 handles.filter1 handles.civ2 handles.interp2 handles.filter2];
|
---|
| 1558 | set_veltype_display(veltype_handles,0) % unvisible civ buttons
|
---|
| 1559 | filename=read_file_boxes(handles);
|
---|
| 1560 | hget_field=findobj(allchild(0),'name','get_field');
|
---|
| 1561 | if ~isempty(hget_field)
|
---|
| 1562 | delete(hget_field)
|
---|
| 1563 | end
|
---|
| 1564 | get_field(filename)
|
---|
| 1565 | return %no action
|
---|
| 1566 | end
|
---|
| 1567 | list_fields=get(handles.Fields_1,'String');% list menu fields
|
---|
| 1568 | index_fields=get(handles.Fields_1,'Value');% selected string index
|
---|
| 1569 | field_1= list_fields{index_fields(1)}; % selected string
|
---|
| 1570 | UvData=get(huvmat,'UserData');
|
---|
| 1571 |
|
---|
| 1572 | %read the rootfile input display
|
---|
| 1573 | FileExt=get(handles.FileExt,'String');
|
---|
| 1574 | [P,F,str1,str2,str_a,str_b,E,NomType]=name2display(['xxx' get(handles.FileIndex,'String') FileExt]);
|
---|
| 1575 | NomTypeNew=NomType;%default
|
---|
| 1576 | if isequal(field,'image')
|
---|
| 1577 | % transform netc type to the corresponding image type
|
---|
| 1578 | if isequal(NomType,'_i1-i2_j')||isequal(NomType,'_i_j1-j2')|| isequal(NomType,'#_ab')|| isequal(NomType,'_i1-i2')
|
---|
| 1579 | UvData.SubDir=get(handles.SubDir,'String'); %preserve the subdir in memory
|
---|
| 1580 | if ~isempty(UvData.SubDir) && (isequal(UvData.SubDir(1),'/')||isequal(UvData.SubDir(1),'/'))
|
---|
| 1581 | UvData.SubDir(1)=[];
|
---|
| 1582 | end
|
---|
| 1583 | set(handles.SubDir,'String','')
|
---|
| 1584 | set(handles.FileExt,'String','.png');
|
---|
| 1585 | if isequal(NomType,'_i1-i2_j')||isequal(NomType,'_i_j1-j2')
|
---|
| 1586 | NomTypeNew='_i_j';
|
---|
| 1587 | elseif isequal(NomType,'#_ab')
|
---|
| 1588 | NomTypeNew='#a';
|
---|
| 1589 | elseif isequal(NomType,'_i1-i2')
|
---|
| 1590 | NomTypeNew='_i';
|
---|
| 1591 | end
|
---|
| 1592 | end
|
---|
| 1593 | veltype_handles=[handles.civ1 handles.interp1 handles.filter1 handles.civ2 handles.interp2 handles.filter2];
|
---|
| 1594 | set_veltype_display(veltype_handles,0) % unvisible civ buttons
|
---|
| 1595 | else
|
---|
| 1596 | ext=get(handles.FileExt,'String');
|
---|
| 1597 | if ~isequal(ext,'.nc') %find the new NomType if the previous display was not already a netcdf file
|
---|
| 1598 | MenuBrowse_Callback(hObject, eventdata, handles)
|
---|
| 1599 | end
|
---|
| 1600 | if isequal(field,'vort') || isequal(field,'div') || isequal(field,'strain')
|
---|
| 1601 | set(handles.civ1,'BackgroundColor',[0.702 0.702 0.702]) % put their color to grey
|
---|
| 1602 | set(handles.civ2,'BackgroundColor',[0.702 0.702 0.702])
|
---|
| 1603 | set(handles.interp1,'BackgroundColor',[0.702 0.702 0.702])
|
---|
| 1604 | set(handles.interp2,'BackgroundColor',[0.702 0.702 0.702])
|
---|
| 1605 | elseif isequal(field,'more...');
|
---|
| 1606 | set(handles.civ1,'BackgroundColor',[0.702 0.702 0.702]) % put their color to grey
|
---|
| 1607 | set(handles.civ2,'BackgroundColor',[0.702 0.702 0.702])
|
---|
| 1608 | str=calc_field;%get the list of available scalars by the function calc_scal
|
---|
| 1609 | [ind_answer] = listdlg('PromptString','Select a file:',...
|
---|
| 1610 | 'SelectionMode','single',...
|
---|
| 1611 | 'ListString',str);
|
---|
| 1612 | % edit the choice in the field and action menu
|
---|
| 1613 | scalar=cell2mat(str(ind_answer));
|
---|
| 1614 | menu=update_menu(handles.Fields,scalar);
|
---|
| 1615 | menu=[{''};menu];
|
---|
| 1616 | set(handles.Fields_1,'String',menu);% store the selected scalar type
|
---|
| 1617 | end
|
---|
| 1618 | end
|
---|
| 1619 | indices=name_generator('',str2double(str1),str2double(str_a),'',NomTypeNew,1,str2double(str2),str2double(str_b),'');
|
---|
| 1620 | set(handles.FileIndex,'String',indices)
|
---|
| 1621 | set(handles.FileIndex,'UserData',NomTypeNew)
|
---|
| 1622 | %common to Fields_1_Callback
|
---|
| 1623 | if isequal(field,'image')||isequal(field_1,'image')
|
---|
| 1624 | set(handles.npx_title,'Visible','on')% visible npx,pxcm... buttons
|
---|
| 1625 | set(handles.npy_title,'Visible','on')
|
---|
| 1626 | set(handles.npx,'Visible','on')
|
---|
| 1627 | set(handles.npy,'Visible','on')
|
---|
| 1628 | set(handles.fix_pair,'Value',0)
|
---|
| 1629 | else
|
---|
| 1630 | set(handles.npx_title,'Visible','off')% visible npx,pxcm... buttons
|
---|
| 1631 | set(handles.npy_title,'Visible','off')
|
---|
| 1632 | set(handles.npx,'Visible','off')
|
---|
| 1633 | set(handles.npy,'Visible','off')
|
---|
| 1634 | set(handles.fix_pair,'Value',1)
|
---|
| 1635 | end
|
---|
| 1636 | % if isequal(field,'velocity')|isequal(field_1,'velocity');
|
---|
| 1637 | % state_vect='on';
|
---|
| 1638 | % else
|
---|
| 1639 | % state_vect='off';
|
---|
| 1640 | % end
|
---|
| 1641 | % if ~isequal(field,'velocity')|(~isequal(field_1,'velocity'));
|
---|
| 1642 | % state_scal='on';
|
---|
| 1643 | % else
|
---|
| 1644 | % state_scal='off';
|
---|
| 1645 | % end
|
---|
| 1646 | setfield(handles);% update the field structure ('civ1'....)
|
---|
| 1647 |
|
---|
| 1648 | if ~isfield(UvData,'NewSeries')||isequal(UvData.NewSeries,0)
|
---|
| 1649 | run0_Callback(hObject, eventdata, handles)
|
---|
| 1650 | end
|
---|
| 1651 |
|
---|
| 1652 | %---------------------------------------------------
|
---|
| 1653 | % --- Executes on menu selection Fields
|
---|
| 1654 | function Fields_1_Callback(hObject, eventdata, handles)
|
---|
| 1655 | %-------------------------------------------------
|
---|
| 1656 | huvmat=get(handles.Fields_1,'parent');
|
---|
| 1657 | list_fields=get(handles.Fields,'String');% list menu fields
|
---|
| 1658 | index_fields=get(handles.Fields,'Value');% selected string index
|
---|
| 1659 | field= list_fields{index_fields(1)}; % selected string
|
---|
| 1660 | list_fields=get(handles.Fields_1,'String');% list menu fields
|
---|
| 1661 | index_fields=get(handles.Fields_1,'Value');% selected string index
|
---|
| 1662 | field_1= list_fields{index_fields(1)}; % selected string for the second field
|
---|
| 1663 | if isequal(field_1,'') %remove second field if 'blank' field is selected
|
---|
| 1664 | set(handles.SubField,'Value',0)
|
---|
| 1665 | SubField_Callback(hObject, eventdata, handles)
|
---|
| 1666 | return
|
---|
| 1667 | end
|
---|
| 1668 | UvData=get(huvmat,'UserData');
|
---|
| 1669 |
|
---|
| 1670 | %read the rootfile input display
|
---|
| 1671 | FileExt_prev=get(handles.FileExt_1,'String');
|
---|
| 1672 | if isempty(FileExt_prev)|isequal(FileExt_prev,'')
|
---|
| 1673 | FileExt_1=get(handles.FileExt,'String');
|
---|
| 1674 | else
|
---|
| 1675 | FileExt_1=FileExt_prev;
|
---|
| 1676 | end
|
---|
| 1677 | NomType_1=get(handles.FileIndex_1,'UserData');
|
---|
| 1678 | if isempty(NomType_1)|isequal(NomType_1,'')
|
---|
| 1679 | NomType_1=get(handles.FileIndex,'UserData');
|
---|
| 1680 | end
|
---|
| 1681 | NomTypeNew=NomType_1;%default
|
---|
| 1682 |
|
---|
| 1683 | set(handles.SubField,'Value',1)%introduce second field
|
---|
| 1684 | if isfield(UvData,'XmlData')
|
---|
| 1685 | UvData.XmlData_1=UvData.XmlData;
|
---|
| 1686 | end
|
---|
| 1687 | set(handles.FileIndex_1,'Visible','on')
|
---|
| 1688 | set(handles.FileExt_1,'Visible','on')
|
---|
| 1689 | RootPath_1=get(handles.RootPath_1,'String');
|
---|
| 1690 | RootFile_1=get(handles.RootFile_1,'String');
|
---|
| 1691 | if isempty(RootPath_1)|isequal(RootPath_1,'')
|
---|
| 1692 | set(handles.RootPath_1,'String','"')
|
---|
| 1693 | end
|
---|
| 1694 | if isempty(RootFile_1) | isequal(RootFile_1,'')
|
---|
| 1695 | set(handles.RootFile_1,'String','"')
|
---|
| 1696 | end
|
---|
| 1697 | if ~isempty(RootFile_1)&(isequal(RootFile_1(1),'/')|isequal(RootFile_1(1),'\'))
|
---|
| 1698 | RootFile_1(1)=[];
|
---|
| 1699 | end
|
---|
| 1700 |
|
---|
| 1701 | if isequal(field_1,'get_field...')
|
---|
| 1702 | veltype_handles=[handles.civ1 handles.interp1 handles.filter1 handles.civ2 handles.interp2 handles.filter2];
|
---|
| 1703 | set_veltype_display(veltype_handles,0) % unvisible civ buttons
|
---|
| 1704 | filename=read_file_boxes_1(handles);
|
---|
| 1705 | hget_field=findobj(allchild(0),'name','get_field_1');
|
---|
| 1706 | if ~isempty(hget_field)
|
---|
| 1707 | delete(hget_field)
|
---|
| 1708 | end
|
---|
| 1709 | hget_field=get_field(filename);
|
---|
| 1710 | set(hget_field,'name','get_field_1')
|
---|
| 1711 | return %no action
|
---|
| 1712 | end
|
---|
| 1713 | if isequal(field_1,'image')
|
---|
| 1714 | % transform netc type to the corresponding image type
|
---|
| 1715 | set(handles.FileExt_1,'String','.png');
|
---|
| 1716 | if isequal(NomType_1,'_i1-i2_j')|isequal(NomType_1,'_i_j1-j2')| isequal(NomType_1,'#_ab')| isequal(NomType_1,'_i1-i2')
|
---|
| 1717 | UvData.SubDir_1=get(handles.SubDir_1,'String'); %preserve the subdir in memory
|
---|
| 1718 | set(handles.SubDir_1,'String','')
|
---|
| 1719 | % set(handles.FileExt_1,'String','.png');
|
---|
| 1720 | if isequal(NomType_1,'_i1-i2_j')|isequal(NomType_1,'_i_j1-j2')
|
---|
| 1721 | NomTypeNew='_i_j';
|
---|
| 1722 | elseif isequal(NomType_1,'#_ab')
|
---|
| 1723 | NomTypeNew='#a';
|
---|
| 1724 | elseif isequal(NomType_1,'_i1-i2')
|
---|
| 1725 | NomTypeNew='_i';
|
---|
| 1726 | end
|
---|
| 1727 | end
|
---|
| 1728 | veltype_handles=[handles.civ1_1 handles.interp1_1 handles.filter1_1 handles.civ2_1 handles.interp2_1 handles.filter2_1];
|
---|
| 1729 | set_veltype_display(veltype_handles,0) % unvisible civ buttons
|
---|
| 1730 | else
|
---|
| 1731 | set(handles.SubDir_1,'Visible','on')
|
---|
| 1732 | if ~isequal(FileExt_prev,'.nc') %find the new NomType if the previous display was not already a netcdf file
|
---|
| 1733 | veltype_handles=[handles.civ1_1 handles.interp1_1 handles.filter1_1 handles.civ2_1 handles.interp2_1 handles.filter2_1];
|
---|
| 1734 | set_veltype_display(veltype_handles,6); % make all civ buttons visible
|
---|
| 1735 | RootPath_1=get(handles.RootPath_1,'String');
|
---|
| 1736 | RootFile_1=get(handles.RootFile_1,'String');
|
---|
| 1737 | if isempty(RootPath_1)|isequal(RootPath_1,'')
|
---|
| 1738 | set(handles.RootPath_1,'String','"')
|
---|
| 1739 | end
|
---|
| 1740 | if isempty(RootFile_1) | isequal(RootFile_1,'')
|
---|
| 1741 | set(handles.RootFile_1,'String','"')
|
---|
| 1742 | end
|
---|
| 1743 | if ~isempty(RootFile_1)&(isequal(RootFile_1(1),'/')|isequal(RootFile_1(1),'\'))
|
---|
| 1744 | RootFile_1(1)=[];
|
---|
| 1745 | end
|
---|
| 1746 | filebase_1=fullfile(RootPath_1,RootFile_1);
|
---|
| 1747 | SubDir_1=get(handles.SubDir,'String');
|
---|
| 1748 | if isempty(SubDir_1)|isequal(SubDir_1,'')
|
---|
| 1749 | if isfield(UvData,'SubDir_1')
|
---|
| 1750 | SubDir_1=UvData.SubDir_1;%retrieve previous subdir
|
---|
| 1751 | else
|
---|
| 1752 | SubDir_1='?';
|
---|
| 1753 | end
|
---|
| 1754 | end
|
---|
| 1755 | if isequal(NomType_1,'#_ab')|isequal(NomType_1,'_i1-i2_j')|isequal(NomType_1,'_i_j1-j2')|isequal(NomType_1,'_i1-i2')
|
---|
| 1756 | NomTypeNew=NomType_1;
|
---|
| 1757 | elseif isequal(NomType_1,'#a')
|
---|
| 1758 | [filename,idetect,n1,na,n2,nb,SubDir_1]=name_generator(filebase_1, str2num(str1),str2num(str_a),'.nc','#_ab',0,[],[],SubDir_1);
|
---|
| 1759 | NomTypeNew='#_ab';
|
---|
| 1760 | elseif isequal(NomType_1,'_i_j')
|
---|
| 1761 | [filename,idetect,n1,na,n2,nb,SubDir_1]=name_generator(filebase_1,str2num(str1),str2num(str_a),'.nc','_i1-i2_j',0,str2num(str1),[],SubDir_1);
|
---|
| 1762 | if idetect==1
|
---|
| 1763 | NomTypeNew='_i1-i2_j';
|
---|
| 1764 | else
|
---|
| 1765 | NomTypeNew='_i_j1-j2';
|
---|
| 1766 | end
|
---|
| 1767 | else %for instance avi files or any ima_num series
|
---|
| 1768 | [filename,idetect,n1,na,n2,nb,SubDir_1]=name_generator(filebase_1,str2num(str1),str2num(str_a),'.nc','_i1-i2',0,str2num(str1),[],SubDir_1);
|
---|
| 1769 | NomTypeNew='_i1-i2';
|
---|
| 1770 | end
|
---|
| 1771 | [Path,Name]=fileparts(filebase_1);
|
---|
| 1772 | set(handles.FileExt_1,'String','.nc');
|
---|
| 1773 | if ~isempty(SubDir_1) & ~isequal(SubDir_1,'''')& ~isequal(SubDir_1,'"')
|
---|
| 1774 | SubDir_1=['/' SubDir_1];
|
---|
| 1775 | end
|
---|
| 1776 | set(handles.SubDir_1,'String',SubDir_1);
|
---|
| 1777 | end
|
---|
| 1778 | if isequal(field,'vort') | isequal(field,'div') | isequal(field,'strain')
|
---|
| 1779 | set(handles.civ1_1,'BackgroundColor',[0.702 0.702 0.702]) % put their color to grey
|
---|
| 1780 | set(handles.civ2_1,'BackgroundColor',[0.702 0.702 0.702])
|
---|
| 1781 | set(handles.interp1_1,'BackgroundColor',[0.702 0.702 0.702])
|
---|
| 1782 | set(handles.interp2_1,'BackgroundColor',[0.702 0.702 0.702])
|
---|
| 1783 | elseif isequal(field_1,'more...'); %add new item to the menu
|
---|
| 1784 | set(handles.civ1_1,'BackgroundColor',[0.702 0.702 0.702]) % put their color to grey
|
---|
| 1785 | set(handles.civ2_1,'BackgroundColor',[0.702 0.702 0.702])
|
---|
| 1786 | str=calc_field;%get the list of available scalars by the function calc_scal
|
---|
| 1787 | [ind_answer,v] = listdlg('PromptString','Select a file:',...
|
---|
| 1788 | 'SelectionMode','single',...
|
---|
| 1789 | 'ListString',str);
|
---|
| 1790 | % edit the choice in the field and action menu
|
---|
| 1791 | scalar=cell2mat(str(ind_answer));
|
---|
| 1792 | menu=update_menu(handles.Fields_1,scalar);
|
---|
| 1793 | set(handles.Fields_1,'String',menu);% store the selected scalar type
|
---|
| 1794 | end
|
---|
| 1795 | end
|
---|
| 1796 | str1=get(handles.i1,'String');
|
---|
| 1797 | str2=get(handles.i2,'String');
|
---|
| 1798 | str_a=get(handles.j1,'String');
|
---|
| 1799 | str_b=get(handles.j2,'String');
|
---|
| 1800 | indices=name_generator('',str2num(str1),stra2num(str_a),'',NomTypeNew,1,str2num(str2),stra2num(str_b),'');
|
---|
| 1801 | set(handles.FileIndex_1,'String',indices)
|
---|
| 1802 | set(handles.FileIndex_1,'UserData',NomTypeNew)
|
---|
| 1803 |
|
---|
| 1804 | %common to Fields_Callback
|
---|
| 1805 | if isequal(field,'image')|isequal(field_1,'image')
|
---|
| 1806 | set(handles.npx_title,'Visible','on')% visible npx,pxcm... buttons
|
---|
| 1807 | set(handles.npy_title,'Visible','on')
|
---|
| 1808 | set(handles.npx,'Visible','on')
|
---|
| 1809 | set(handles.npy,'Visible','on')
|
---|
| 1810 | set(handles.fix_pair,'Value',0)
|
---|
| 1811 | else
|
---|
| 1812 | set(handles.npx_title,'Visible','off')% visible npx,pxcm... buttons
|
---|
| 1813 | set(handles.npy_title,'Visible','off')
|
---|
| 1814 | set(handles.npx,'Visible','off')
|
---|
| 1815 | set(handles.npy,'Visible','off')
|
---|
| 1816 | set(handles.fix_pair,'Value',1)
|
---|
| 1817 | end
|
---|
| 1818 | if isequal(field,'velocity')|isequal(field_1,'velocity');
|
---|
| 1819 | state_vect='on';
|
---|
| 1820 | else
|
---|
| 1821 | state_vect='off';
|
---|
| 1822 | end
|
---|
| 1823 | if ~isequal(field,'velocity')|(~isequal(field_1,'velocity')&~isequal(field_1,''));
|
---|
| 1824 | state_scal='on';
|
---|
| 1825 | else
|
---|
| 1826 | state_scal='off';
|
---|
| 1827 | end
|
---|
| 1828 | set(huvmat,'UserData',UvData)
|
---|
| 1829 | setfield(handles);% update the field structure ('civ1'....)
|
---|
| 1830 | if ~isfield(UvData,'NewSeries')|isequal(UvData.NewSeries,0)
|
---|
| 1831 | run0_Callback(hObject, eventdata, handles)
|
---|
| 1832 | end
|
---|
| 1833 |
|
---|
| 1834 | %------------------------------------------------------------------------
|
---|
| 1835 | % --- set the visibility of relevant velocity type menus:
|
---|
| 1836 | function set_veltype_display(handles,Civ)
|
---|
| 1837 | %------------------------------------------------------------------------
|
---|
| 1838 | %Civ=0; all states 'off'
|
---|
| 1839 | %Civ=6; all states 'on'
|
---|
| 1840 | if isequal(Civ,0)
|
---|
| 1841 | imax=0;
|
---|
| 1842 | % set(handles(1),'Visible','on') % unvisible civ buttons
|
---|
| 1843 | % else
|
---|
| 1844 | % set(handles(1),'String','civ1')
|
---|
| 1845 | % end
|
---|
| 1846 | elseif isequal(Civ,1) || isequal(Civ,2)
|
---|
| 1847 | imax=1;
|
---|
| 1848 | elseif isequal(Civ,3)
|
---|
| 1849 | imax=3;
|
---|
| 1850 | elseif isequal(Civ,4) || isequal(Civ,5)
|
---|
| 1851 | imax=4;
|
---|
| 1852 | elseif isequal(Civ,6) %patch2
|
---|
| 1853 | imax=6;
|
---|
| 1854 | end
|
---|
| 1855 | for ibutton=1:imax;
|
---|
| 1856 | set(handles(ibutton),'Visible','on') % unvisible civ buttons
|
---|
| 1857 | end
|
---|
| 1858 | % for ibutton=max(imax+1,2):6;
|
---|
| 1859 | for ibutton=imax+1:6;
|
---|
| 1860 | set(handles(ibutton),'Visible','off') % unvisible civ buttons
|
---|
| 1861 | set(handles(ibutton),'Value',0)%unactivate unvisible buttons
|
---|
| 1862 | end
|
---|
| 1863 |
|
---|
| 1864 | %-------------------------------------------------------------------
|
---|
| 1865 | % --- Executes on button press in civ1.
|
---|
| 1866 | function civ1_Callback(hObject, eventdata, handles)
|
---|
| 1867 | %-------------------------------------------------------------------
|
---|
| 1868 | if get(handles.civ1,'Value')==1
|
---|
| 1869 | reset_vel_type([handles.interp1 handles.civ2 handles.filter1 handles.interp1 handles.interp2 handles.filter2],handles.civ1)
|
---|
| 1870 | else
|
---|
| 1871 | reset_vel_type([handles.civ1 handles.filter1 handles.interp1 handles.civ2 handles.interp2 handles.filter2])
|
---|
| 1872 | end
|
---|
| 1873 | run0_Callback(hObject, eventdata, handles)
|
---|
| 1874 |
|
---|
| 1875 | %-------------------------------------------------------------------
|
---|
| 1876 | % --- Executes on button press in interp1.
|
---|
| 1877 | function interp1_Callback(hObject, eventdata, handles)
|
---|
| 1878 | %-------------------------------------------------------------------
|
---|
| 1879 | if get(handles.interp1,'Value')==1
|
---|
| 1880 | reset_vel_type([handles.civ1 handles.civ2 handles.filter1 handles.interp2 handles.filter2],handles.interp1)
|
---|
| 1881 | else
|
---|
| 1882 | reset_vel_type([handles.civ1 handles.filter1 handles.interp1 handles.civ2 handles.interp2 handles.filter2])
|
---|
| 1883 | end
|
---|
| 1884 | run0_Callback(hObject, eventdata, handles)
|
---|
| 1885 |
|
---|
| 1886 | %-------------------------------------------------------------------
|
---|
| 1887 | % --- Executes on button press in filter1.
|
---|
| 1888 | function filter1_Callback(hObject, eventdata, handles)
|
---|
| 1889 | %-------------------------------------------------------------------
|
---|
| 1890 | if get(handles.filter1,'Value')==1
|
---|
| 1891 | reset_vel_type([handles.civ1 handles.civ2 handles.interp1 handles.interp2 handles.filter2],handles.filter1)
|
---|
| 1892 | else
|
---|
| 1893 | reset_vel_type([handles.civ1 handles.filter1 handles.interp1 handles.civ2 handles.interp2 handles.filter2])
|
---|
| 1894 | end
|
---|
| 1895 | run0_Callback(hObject, eventdata, handles)
|
---|
| 1896 |
|
---|
| 1897 | %-------------------------------------------------------------------
|
---|
| 1898 | % --- Executes on button press in civ2.
|
---|
| 1899 | function civ2_Callback(hObject, eventdata, handles)
|
---|
| 1900 | %-------------------------------------------------------------------
|
---|
| 1901 | if get(handles.civ2,'Value')==1
|
---|
| 1902 | reset_vel_type([handles.civ1 handles.filter1 handles.interp1 handles.interp2 handles.filter2],handles.civ2)
|
---|
| 1903 | else
|
---|
| 1904 | reset_vel_type([handles.civ1 handles.filter1 handles.interp1 handles.civ2 handles.interp2 handles.filter2])
|
---|
| 1905 | end
|
---|
| 1906 | run0_Callback(hObject, eventdata, handles)
|
---|
| 1907 |
|
---|
| 1908 | %-----------------------------------------
|
---|
| 1909 | % --- Executes on button press in interp2.
|
---|
| 1910 | %-------------------------------------------
|
---|
| 1911 | function interp2_Callback(hObject, eventdata, handles)
|
---|
| 1912 | if get(handles.interp2,'Value')==1
|
---|
| 1913 | reset_vel_type([handles.civ1 handles.filter1 handles.interp1 handles.civ2 handles.filter2],handles.interp2)
|
---|
| 1914 | else
|
---|
| 1915 | reset_vel_type([handles.civ1 handles.filter1 handles.interp1 handles.civ2 handles.interp2 handles.filter2])
|
---|
| 1916 | end
|
---|
| 1917 | run0_Callback(hObject, eventdata, handles)
|
---|
| 1918 | %---------------------------------------------
|
---|
| 1919 | % --- Executes on button press in filter2.
|
---|
| 1920 | %-------------------------------------------
|
---|
| 1921 | function filter2_Callback(hObject, eventdata, handles)
|
---|
| 1922 | if get(handles.filter2,'Value')==1
|
---|
| 1923 | reset_vel_type([handles.civ1 handles.filter1 handles.interp1 handles.civ2 handles.interp2],handles.filter2)
|
---|
| 1924 | else
|
---|
| 1925 | reset_vel_type([handles.civ1 handles.filter1 handles.interp1 handles.civ2 handles.interp2 handles.filter2])
|
---|
| 1926 | end
|
---|
| 1927 | run0_Callback(hObject, eventdata, handles)
|
---|
| 1928 |
|
---|
| 1929 | %---------------------------------------------
|
---|
| 1930 | function civ1_1_Callback(hObject, eventdata, handles)
|
---|
| 1931 | %---------------------------------------------
|
---|
| 1932 | if get(handles.civ1_1,'Value')==1
|
---|
| 1933 | reset_vel_type([handles.interp1_1 handles.civ2_1 handles.filter1_1 handles.interp1_1 handles.interp2_1 handles.filter2_1],handles.civ1_1)
|
---|
| 1934 | else
|
---|
| 1935 | reset_vel_type([handles.civ1_1 handles.filter1_1 handles.interp1_1 handles.civ2_1 handles.interp2_1 handles.filter2_1])
|
---|
| 1936 | end
|
---|
| 1937 | run0_Callback(hObject, eventdata, handles)
|
---|
| 1938 |
|
---|
| 1939 | %--------------------------------------------
|
---|
| 1940 | function interp1_1_Callback(hObject, eventdata, handles)
|
---|
| 1941 | %--------------------------------------------
|
---|
| 1942 | if get(handles.interp1_1,'Value')==1
|
---|
| 1943 | reset_vel_type([handles.civ1_1 handles.civ2_1 handles.filter1_1 handles.interp2_1 handles.filter2_1],handles.interp1_1)
|
---|
| 1944 | else
|
---|
| 1945 | reset_vel_type([handles.civ1_1 handles.filter1_1 handles.interp1_1 handles.civ2_1 handles.interp2_1 handles.filter2_1])
|
---|
| 1946 | end
|
---|
| 1947 | run0_Callback(hObject, eventdata, handles)
|
---|
| 1948 |
|
---|
| 1949 | %--------------------------------------------
|
---|
| 1950 | function filter1_1_Callback(hObject, eventdata, handles)
|
---|
| 1951 | %--------------------------------------------
|
---|
| 1952 | if get(handles.filter1_1,'Value')==1
|
---|
| 1953 | reset_vel_type([handles.interp1_1 handles.civ2_1 handles.interp1_1 handles.interp2_1 handles.filter2_1],handles.filter1_1)
|
---|
| 1954 | else
|
---|
| 1955 | reset_vel_type([handles.civ1_1 handles.filter1_1 handles.interp1_1 handles.civ2_1 handles.interp2_1 handles.filter2_1])
|
---|
| 1956 | end
|
---|
| 1957 | run0_Callback(hObject, eventdata, handles)
|
---|
| 1958 |
|
---|
| 1959 | %--------------------------------------------
|
---|
| 1960 | function civ2_1_Callback(hObject, eventdata, handles)
|
---|
| 1961 | %--------------------------------------------
|
---|
| 1962 | if get(handles.civ2_1,'Value')==1
|
---|
| 1963 | reset_vel_type([handles.civ1_1 handles.interp1_1 handles.filter1_1 handles.interp2_1 handles.filter2_1],handles.civ2_1)
|
---|
| 1964 | else
|
---|
| 1965 | reset_vel_type([handles.civ1_1 handles.filter1_1 handles.interp1_1 handles.civ2_1 handles.interp2_1 handles.filter2_1])
|
---|
| 1966 | end
|
---|
| 1967 | run0_Callback(hObject, eventdata, handles)
|
---|
| 1968 |
|
---|
| 1969 | %--------------------------------------------
|
---|
| 1970 | function interp2_1_Callback(hObject, eventdata, handles)
|
---|
| 1971 | %--------------------------------------------
|
---|
| 1972 | if get(handles.interp2_1,'Value')==1
|
---|
| 1973 | reset_vel_type([handles.civ1_1 handles.civ2_1 handles.filter1_1 handles.interp1_1 handles.filter2_1],handles.interp2_1)
|
---|
| 1974 | else
|
---|
| 1975 | reset_vel_type([handles.civ1_1 handles.filter1_1 handles.interp1_1 handles.civ2_1 handles.interp2_1 handles.filter2_1])
|
---|
| 1976 | end
|
---|
| 1977 | run0_Callback(hObject, eventdata, handles)
|
---|
| 1978 |
|
---|
| 1979 | %--------------------------------------------
|
---|
| 1980 | function filter2_1_Callback(hObject, eventdata, handles)
|
---|
| 1981 | %--------------------------------------------
|
---|
| 1982 | if get(handles.filter2_1,'Value')==1
|
---|
| 1983 | reset_vel_type([handles.civ1_1 handles.interp1_1 handles.civ2_1 handles.filter1_1 handles.interp1_1 handles.interp2_1],handles.filter2_1)
|
---|
| 1984 | else
|
---|
| 1985 | reset_vel_type([handles.civ1_1 handles.filter1_1 handles.interp1_1 handles.civ2_1 handles.interp2_1 handles.filter2_1])
|
---|
| 1986 | end
|
---|
| 1987 | run0_Callback(hObject, eventdata, handles)
|
---|
| 1988 |
|
---|
| 1989 | %-----------------------------------------------
|
---|
| 1990 | % --- reset civ buttons
|
---|
| 1991 | function reset_vel_type(handles_civ0,handle1)
|
---|
| 1992 | for ibutton=1:length(handles_civ0)
|
---|
| 1993 | set(handles_civ0(ibutton),'BackgroundColor',[0.831 0.816 0.784])
|
---|
| 1994 | set(handles_civ0(ibutton),'Value',0)
|
---|
| 1995 | end
|
---|
| 1996 | if exist('handle1','var')%handles of selected button
|
---|
| 1997 | set(handle1,'BackgroundColor',[1 1 0])
|
---|
| 1998 | end
|
---|
| 1999 |
|
---|
| 2000 |
|
---|
| 2001 | %-------------------------------------------------------------------
|
---|
| 2002 | %-------------------------------------------------------------------
|
---|
| 2003 | % - FUNCTIONS FOR SETTING PLOTTING PARAMETERS
|
---|
| 2004 |
|
---|
| 2005 | %------------------------------------------------------------------
|
---|
| 2006 |
|
---|
| 2007 |
|
---|
| 2008 |
|
---|
| 2009 | %------------------------------------------------------------------
|
---|
| 2010 | % --- Executes on selection change in col_vec: choice of the color code.
|
---|
| 2011 | %
|
---|
| 2012 | function col_vec_Callback(hObject, eventdata, handles)
|
---|
| 2013 | %------------------------------------------------------------------
|
---|
| 2014 | % edit the choice for color code
|
---|
| 2015 | list_code=get(handles.col_vec,'String');% list menu fields
|
---|
| 2016 | index_code=get(handles.col_vec,'Value');% selected string index
|
---|
| 2017 | col_code= list_code{index_code(1)}; % selected field
|
---|
| 2018 | if isequal(col_code,'black') | isequal(col_code,'white')
|
---|
| 2019 | set(handles.slider1,'Visible','off')
|
---|
| 2020 | set(handles.slider2,'Visible','off')
|
---|
| 2021 | set(handles.colcode1,'Visible','off')
|
---|
| 2022 | set(handles.colcode2,'Visible','off')
|
---|
| 2023 | set(handles.AutoVecColor,'Visible','off')
|
---|
| 2024 | set_vec_col_bar(handles)
|
---|
| 2025 | else
|
---|
| 2026 | set(handles.slider1,'Visible','on')
|
---|
| 2027 | set(handles.slider2,'Visible','on')
|
---|
| 2028 | set(handles.colcode1,'Visible','on')
|
---|
| 2029 | set(handles.colcode2,'Visible','on')
|
---|
| 2030 | set(handles.AutoVecColor,'Visible','on')
|
---|
| 2031 | if isequal(col_code,'ima_cor')
|
---|
| 2032 | set(handles.AutoVecColor,'Value',0)%fixed scale by default
|
---|
| 2033 | set(handles.vec_col_bar,'Value',0)% 3 colors r,g,b by default
|
---|
| 2034 | set(handles.slider1,'Min',0);
|
---|
| 2035 | set(handles.slider1,'Max',1);
|
---|
| 2036 | set(handles.slider2,'Min',0);
|
---|
| 2037 | set(handles.slider2,'Max',1);
|
---|
[85] | 2038 | % set(handles.min_C_title_vec,'String','0')
|
---|
[60] | 2039 | set(handles.max_vec,'String','1')
|
---|
| 2040 | set(handles.colcode1,'String','0.333')
|
---|
| 2041 | colcode1_Callback(hObject, eventdata, handles)
|
---|
| 2042 | set(handles.colcode2,'String','0.666')
|
---|
| 2043 | colcode2_Callback(hObject, eventdata, handles)
|
---|
| 2044 | else
|
---|
| 2045 | set(handles.AutoVecColor,'Value',1)%auto scale between min,max by default
|
---|
| 2046 | set(handles.vec_col_bar,'Value',1)% colormap 'jet' by default
|
---|
| 2047 | minval=get(handles.slider1,'Min');
|
---|
| 2048 | maxval=get(handles.slider1,'Max');
|
---|
| 2049 | set(handles.slider1,'Value',minval)
|
---|
| 2050 | set(handles.slider2,'Value',maxval)
|
---|
| 2051 | set_vec_col_bar(handles)
|
---|
| 2052 | end
|
---|
| 2053 | % slider_update(handles)
|
---|
| 2054 | end
|
---|
| 2055 | %replot the current graph
|
---|
| 2056 | run0_Callback(hObject, eventdata, handles)
|
---|
| 2057 |
|
---|
| 2058 |
|
---|
| 2059 | %----------------------------------------------------------------
|
---|
| 2060 | % -- Executes on slider movement to set the color code
|
---|
| 2061 | %
|
---|
| 2062 | function slider1_Callback(hObject, eventdata, handles)
|
---|
| 2063 | %------------------------------------------------------------------
|
---|
| 2064 | slider1=get(handles.slider1,'Value');
|
---|
| 2065 | min_val=str2num(get(handles.min_vec,'String'));
|
---|
| 2066 | max_val=str2num(get(handles.max_vec,'String'));
|
---|
| 2067 | col=min_val+(max_val-min_val)*slider1;
|
---|
| 2068 | set(handles.colcode1,'String',num2str(col))
|
---|
| 2069 | if(get(handles.slider2,'Value') < col)%move also the second slider at the same value if needed
|
---|
| 2070 | set(handles.slider2,'Value',col)
|
---|
| 2071 | set(handles.colcode2,'String',num2str(col))
|
---|
| 2072 | end
|
---|
| 2073 | colcode1_Callback(hObject, eventdata, handles)
|
---|
| 2074 |
|
---|
| 2075 | %----------------------------------------------------------------
|
---|
| 2076 | % Executes on slider movement to set the color code
|
---|
| 2077 | %----------------------------------------------------------------
|
---|
| 2078 | function slider2_Callback(hObject, eventdata, handles)
|
---|
| 2079 | slider2=get(handles.slider2,'Value');
|
---|
| 2080 | min_val=str2num(get(handles.min_vec,'String'));
|
---|
| 2081 | max_val=str2num(get(handles.max_vec,'String'));
|
---|
| 2082 | col=min_val+(max_val-min_val)*slider2;
|
---|
| 2083 | set(handles.colcode2,'String',num2str(col))
|
---|
| 2084 | if(get(handles.slider1,'Value') > col)%move also the first slider at the same value if needed
|
---|
| 2085 | set(handles.slider1,'Value',col)
|
---|
| 2086 | set(handles.colcode1,'String',num2str(col))
|
---|
| 2087 | end
|
---|
| 2088 | colcode2_Callback(hObject, eventdata, handles)
|
---|
| 2089 |
|
---|
| 2090 | %----------------------------------------------------------------
|
---|
| 2091 | %execute on return carriage on the edit box corresponding to slider 1
|
---|
| 2092 | %----------------------------------------------------------------
|
---|
| 2093 | function colcode1_Callback(hObject, eventdata, handles)
|
---|
| 2094 | % col=str2num(get(handles.colcode1,'String'));
|
---|
| 2095 | % set(handles.slider1,'Value',col)
|
---|
| 2096 | set_vec_col_bar(handles)
|
---|
| 2097 | update_plot(handles)
|
---|
| 2098 |
|
---|
| 2099 | %----------------------------------------------------------------
|
---|
| 2100 | %execute on return carriage on the edit box corresponding to slider 2
|
---|
| 2101 | %----------------------------------------------------------------
|
---|
| 2102 | function colcode2_Callback(hObject, eventdata, handles)
|
---|
| 2103 | % col=str2num(get(handles.colcode2,'String'));
|
---|
| 2104 | % set(handles.slider2,'Value',col)
|
---|
| 2105 | % slider2_Callback(hObject, eventdata, handles)
|
---|
| 2106 | set_vec_col_bar(handles)
|
---|
| 2107 | update_plot(handles)
|
---|
| 2108 | %------------------------------------------------------------
|
---|
| 2109 | %update the slider values after displaying vectors
|
---|
| 2110 | %--------------------------------------------------------
|
---|
| 2111 | % function slider_update(handles,auto,minC,colcode1,colcode2,maxC)
|
---|
| 2112 | % set(handles.slider1,'Min',minC)
|
---|
| 2113 | % set(handles.slider1,'Max',maxC)
|
---|
| 2114 | % set(handles.slider2,'Min',minC)
|
---|
| 2115 | % set(handles.slider2,'Max',maxC)
|
---|
[85] | 2116 | % set(handles.min_C_title_vec,'String',num2str(minC))
|
---|
[60] | 2117 | % set(handles.max_vec,'String',num2str(maxC))
|
---|
| 2118 | % if auto
|
---|
| 2119 | % set(handles.colcode1,'String',num2str(colcode1,3))%update display
|
---|
| 2120 | % set(handles.colcode2,'String',num2str(colcode2,3))
|
---|
| 2121 | % end
|
---|
| 2122 | % set(handles.slider1,'Value',colcode1)%update slider with constant display
|
---|
| 2123 | % set(handles.slider2,'Value',colcode2)
|
---|
| 2124 | % set_vec_col_bar(handles)
|
---|
| 2125 |
|
---|
| 2126 |
|
---|
| 2127 | %-------------------------------------------------------
|
---|
| 2128 | % --- Executes on button press in AutoVecColor.
|
---|
| 2129 | %-------------------------------------------------------
|
---|
| 2130 | function vec_col_bar_Callback(hObject, eventdata, handles)
|
---|
| 2131 | set_vec_col_bar(handles)
|
---|
| 2132 |
|
---|
| 2133 | % %--------------------------------------------
|
---|
| 2134 | % %update the display of color code for vectors
|
---|
| 2135 | % %--------------------------------------------
|
---|
| 2136 | % function set_vec_col_bar(handles)
|
---|
| 2137 | % %get the image of the color display button 'vec_col_bar' in pixels
|
---|
| 2138 | % uni=get(handles.vec_col_bar,'Unit');
|
---|
| 2139 | % set(handles.vec_col_bar,'Unit','pixel')
|
---|
| 2140 | % pos_vert=get(handles.vec_col_bar,'Position');
|
---|
| 2141 | % set(handles.vec_col_bar,'Unit','Normalized')
|
---|
| 2142 | % width=ceil(pos_vert(3));
|
---|
| 2143 | % height=ceil(pos_vert(4));
|
---|
| 2144 | % %get slider indications
|
---|
| 2145 | % colcode.min=get(handles.slider1,'Min');
|
---|
| 2146 | % colcode.max=get(handles.slider1,'Max');
|
---|
| 2147 | % colcode.colcode1=get(handles.slider1,'Value');
|
---|
| 2148 | % colcode.colcode2=get(handles.slider2,'Value');
|
---|
| 2149 | % colcode.option=get(handles.vec_col_bar,'Value');
|
---|
| 2150 | % colcode.auto=1;
|
---|
| 2151 | % list_code=get(handles.col_vec,'String');% list menu fields
|
---|
| 2152 | % index_code=get(handles.col_vec,'Value');% selected string index
|
---|
| 2153 | % colcode.CName= list_code{index_code(1)}; % selected field used for vector color
|
---|
| 2154 | % vec_C=colcode.min+(colcode.max-colcode.min)*[0.5:width-0.5]/width;%sample of vec_C values from min to max
|
---|
| 2155 | % [colorlist,col_vec]=set_col_vec(colcode,vec_C);
|
---|
| 2156 | % oneheight=ones(1,height);
|
---|
| 2157 | % A1=colorlist(col_vec,1)*oneheight;
|
---|
| 2158 | % A2=colorlist(col_vec,2)*oneheight;
|
---|
| 2159 | % A3=colorlist(col_vec,3)*oneheight;
|
---|
| 2160 | % A(:,:,1)=A1';
|
---|
| 2161 | % A(:,:,2)=A2';
|
---|
| 2162 | % A(:,:,3)=A3';
|
---|
| 2163 | % set(handles.vec_col_bar,'Cdata',A)
|
---|
| 2164 |
|
---|
| 2165 |
|
---|
| 2166 | %------------------------------------------------
|
---|
| 2167 | %CALLBACKS FOR PLOTTING PARAMETERS
|
---|
| 2168 | %-------------------------------------------------
|
---|
| 2169 |
|
---|
| 2170 | %-----------------------------------------------------------------
|
---|
| 2171 | function MinA_Callback(hObject, eventdata, handles)
|
---|
| 2172 | %------------------------------------------
|
---|
| 2173 | set(handles.AutoScal,'Value',1) %suppress auto mode
|
---|
| 2174 | set(handles.AutoScal,'BackgroundColor',[1 1 0])
|
---|
| 2175 | update_plot(handles)
|
---|
| 2176 |
|
---|
| 2177 | %-----------------------------------------------------------------
|
---|
| 2178 | function MaxA_Callback(hObject, eventdata, handles)
|
---|
| 2179 | %--------------------------------------------
|
---|
| 2180 | set(handles.AutoScal,'Value',1) %suppress auto mode
|
---|
| 2181 | set(handles.AutoScal,'BackgroundColor',[1 1 0])
|
---|
| 2182 | update_plot(handles)
|
---|
| 2183 |
|
---|
| 2184 | %-----------------------------------------------
|
---|
| 2185 | function AutoScal_Callback(hObject, eventdata, handles)
|
---|
| 2186 | %--------------------------------------------
|
---|
| 2187 | test=get(handles.AutoScal,'Value');
|
---|
| 2188 | if test
|
---|
| 2189 | set(handles.AutoScal,'BackgroundColor',[1 1 0])
|
---|
| 2190 | else
|
---|
| 2191 | set(handles.AutoScal,'BackgroundColor',[0.7 0.7 0.7])
|
---|
| 2192 | update_plot(handles);
|
---|
| 2193 | % set(handles.MinA,'String',num2str(ScalOut.MinA,3))
|
---|
| 2194 | % set(handles.MaxA,'String',num2str(ScalOut.MaxA,3))
|
---|
| 2195 | end
|
---|
| 2196 |
|
---|
| 2197 | %-------------------------------------------------------------------
|
---|
| 2198 | function BW_Callback(hObject, eventdata, handles)
|
---|
| 2199 | %-------------------------------------------------------------------
|
---|
| 2200 | update_plot(handles)
|
---|
| 2201 |
|
---|
| 2202 | %-------------------------------------------------------------------
|
---|
| 2203 | function Contours_Callback(hObject, eventdata, handles)
|
---|
| 2204 | %-------------------------------------------------------------------
|
---|
| 2205 | val=get(handles.Contours,'Value');
|
---|
| 2206 | if val==2
|
---|
| 2207 | set(handles.interval_txt,'Visible','on')
|
---|
| 2208 | set(handles.IncrA,'Visible','on')
|
---|
| 2209 | else
|
---|
| 2210 | set(handles.interval_txt,'Visible','off')
|
---|
| 2211 | set(handles.IncrA,'Visible','off')
|
---|
| 2212 | end
|
---|
| 2213 | update_plot(handles)
|
---|
| 2214 |
|
---|
| 2215 | %-------------------------------------------------------------------
|
---|
| 2216 | function IncrA_Callback(hObject, eventdata, handles)
|
---|
| 2217 | %-------------------------------------------------------------------
|
---|
| 2218 | update_plot(handles)
|
---|
| 2219 |
|
---|
| 2220 | %-------------------------------------------------------------------
|
---|
| 2221 | function HideWarning_Callback(hObject, eventdata, handles)
|
---|
| 2222 | %-------------------------------------------------------------------
|
---|
| 2223 | update_plot(handles)
|
---|
| 2224 |
|
---|
| 2225 | %-------------------------------------------------------------------
|
---|
| 2226 | function HideFalse_Callback(hObject, eventdata, handles)
|
---|
| 2227 | %-------------------------------------------------------------------
|
---|
| 2228 | update_plot(handles)
|
---|
| 2229 |
|
---|
| 2230 | %-------------------------------------------------------------------
|
---|
| 2231 | function VecScale_Callback(hObject, eventdata, handles)
|
---|
| 2232 | %-------------------------------------------------------------------
|
---|
| 2233 | set(handles.AutoVec,'Value',1);
|
---|
| 2234 | set(handles.AutoVec,'BackgroundColor',[1 1 0])
|
---|
| 2235 | update_plot(handles)
|
---|
| 2236 |
|
---|
| 2237 | %-------------------------------------------------------------------
|
---|
| 2238 | function AutoVec_Callback(hObject, eventdata, handles)
|
---|
| 2239 | %-------------------------------------------------------------------
|
---|
| 2240 | test=get(handles.AutoVec,'Value');
|
---|
| 2241 | if test
|
---|
| 2242 | set(handles.AutoVec,'BackgroundColor',[1 1 0])
|
---|
| 2243 | else
|
---|
| 2244 | update_plot(handles);
|
---|
| 2245 | %set(handles.VecScale,'String',num2str(ScalOut.VecScale,3))
|
---|
| 2246 | set(handles.AutoVec,'BackgroundColor',[0.7 0.7 0.7])
|
---|
| 2247 | end
|
---|
| 2248 |
|
---|
| 2249 | %-------------------------------------------------------
|
---|
| 2250 | % --- Executes on selection change in decimate4 (nb_vec/4).
|
---|
| 2251 | %-------------------------------------------------------
|
---|
| 2252 | function decimate4_Callback(hObject, eventdata, handles)
|
---|
| 2253 | update_plot(handles)
|
---|
| 2254 |
|
---|
| 2255 |
|
---|
| 2256 | %-------------------------------------------------------
|
---|
| 2257 | % --- Executes on selection change in color_code menu
|
---|
| 2258 | %-------------------------------------------------------
|
---|
| 2259 | function color_code_Callback(hObject, eventdata, handles)
|
---|
| 2260 | set_vec_col_bar(handles)
|
---|
| 2261 | update_plot(handles);
|
---|
| 2262 |
|
---|
| 2263 | %-------------------------------------------------------
|
---|
| 2264 | % --- Executes on button press in AutoVecColor.
|
---|
| 2265 | %-------------------------------------------------------
|
---|
| 2266 | function AutoVecColor_Callback(hObject, eventdata, handles)
|
---|
| 2267 | test=get(handles.AutoVecColor,'Value');
|
---|
| 2268 | if test
|
---|
| 2269 | set(handles.AutoVecColor,'BackgroundColor',[1 1 0])
|
---|
| 2270 | else
|
---|
| 2271 | update_plot(handles);
|
---|
| 2272 | %set(handles.VecScale,'String',num2str(ScalOut.VecScale,3))
|
---|
| 2273 | set(handles.AutoVecColor,'BackgroundColor',[0.7 0.7 0.7])
|
---|
| 2274 | end
|
---|
| 2275 | %set_vec_col_bar(handles)
|
---|
| 2276 |
|
---|
| 2277 | %-------------------------------------------------------
|
---|
| 2278 | % --- Executes on selection change in max_vec.
|
---|
| 2279 | %-------------------------------------------------------
|
---|
| 2280 | function min_vec_Callback(hObject, eventdata, handles)
|
---|
| 2281 | max_vec_Callback(hObject, eventdata, handles)
|
---|
| 2282 |
|
---|
| 2283 | % --- Executes on selection change in max_vec.
|
---|
| 2284 | function max_vec_Callback(hObject, eventdata, handles)
|
---|
| 2285 | set(handles.AutoVecColor,'Value',1)
|
---|
| 2286 | AutoVecColor_Callback(hObject, eventdata, handles)
|
---|
| 2287 | min_val=str2num(get(handles.min_vec,'String'));
|
---|
| 2288 | max_val=str2num(get(handles.max_vec,'String'));
|
---|
| 2289 | slider1=get(handles.slider1,'Value');
|
---|
| 2290 | slider2=get(handles.slider2,'Value');
|
---|
| 2291 | colcode1=min_val+(max_val-min_val)*slider1;
|
---|
| 2292 | colcode2=min_val+(max_val-min_val)*slider2;
|
---|
| 2293 | set(handles.colcode1,'String',num2str(colcode1))
|
---|
| 2294 | set(handles.colcode2,'String',num2str(colcode2))
|
---|
| 2295 | update_plot(handles);
|
---|
| 2296 |
|
---|
| 2297 | %-------------------------------------------------------------------
|
---|
| 2298 | %update the display of color code for vectors
|
---|
| 2299 | function set_vec_col_bar(handles)
|
---|
| 2300 | %-------------------------------------------------------------------
|
---|
| 2301 | %get the image of the color display button 'vec_col_bar' in pixels
|
---|
| 2302 | set(handles.vec_col_bar,'Unit','pixel');
|
---|
| 2303 | pos_vert=get(handles.vec_col_bar,'Position');
|
---|
| 2304 | set(handles.vec_col_bar,'Unit','Normalized');
|
---|
| 2305 | width=ceil(pos_vert(3));
|
---|
| 2306 | height=ceil(pos_vert(4));
|
---|
| 2307 |
|
---|
| 2308 | %get slider indications
|
---|
| 2309 | list=get(handles.color_code,'String');
|
---|
| 2310 | ichoice=get(handles.color_code,'Value');
|
---|
| 2311 | colcode.ColorCode=list{ichoice};
|
---|
| 2312 | colcode.MinC=str2num(get(handles.min_vec,'String'));
|
---|
| 2313 | colcode.MaxC=str2num(get(handles.max_vec,'String'));
|
---|
| 2314 | test3color=strcmp(colcode.ColorCode,'rgb') || strcmp(colcode.ColorCode,'bgr');
|
---|
| 2315 | if test3color
|
---|
| 2316 | colcode.colcode1=str2num(get(handles.colcode1,'String'));
|
---|
| 2317 | colcode.colcode2=str2num(get(handles.colcode2,'String'));
|
---|
| 2318 | end
|
---|
| 2319 | % colcode.option=get(handles.vec_col_bar,'Value');
|
---|
| 2320 | colcode.FixedCbounds=0;
|
---|
| 2321 | % list_code=get(handles.col_vec,'String');% list menu fields
|
---|
| 2322 | % index_code=get(handles.col_vec,'Value');% selected string index
|
---|
| 2323 | % colcode.CName= list_code{index_code(1)}; % selected field used for vector color
|
---|
| 2324 | colcode.FixedCbounds=1;
|
---|
| 2325 | vec_C=colcode.MinC+(colcode.MaxC-colcode.MinC)*[0.5:width-0.5]/width;%sample of vec_C values from min to max
|
---|
| 2326 | [colorlist,col_vec]=set_col_vec(colcode,vec_C);
|
---|
| 2327 | oneheight=ones(1,height);
|
---|
| 2328 | A1=colorlist(col_vec,1)*oneheight;
|
---|
| 2329 | A2=colorlist(col_vec,2)*oneheight;
|
---|
| 2330 | A3=colorlist(col_vec,3)*oneheight;
|
---|
| 2331 | A(:,:,1)=A1';
|
---|
| 2332 | A(:,:,2)=A2';
|
---|
| 2333 | A(:,:,3)=A3';
|
---|
| 2334 | set(handles.vec_col_bar,'Cdata',A)
|
---|
| 2335 |
|
---|
| 2336 |
|
---|
| 2337 | %-------------------------------------------------------------------
|
---|
| 2338 | function [PlotType,ScalOut]=update_plot(handles)
|
---|
| 2339 | %-------------------------------------------------------------------
|
---|
| 2340 | haxes= handles.axes3;
|
---|
[85] | 2341 | huvmat=findobj(allchild(0),'tag','uvmat');
|
---|
| 2342 | UvData=get(huvmat,'UserData');
|
---|
| 2343 | %
|
---|
| 2344 | % AxeData=get(haxes,'UserData');
|
---|
[60] | 2345 | PlotParam=read_plot_param(handles);
|
---|
[85] | 2346 | [PlotType,PlotParamOut]= plot_field(UvData.ProjField_2,haxes,PlotParam,1);
|
---|
[60] | 2347 | write_plot_param(handles,PlotParamOut); %update the auto plot parameters
|
---|
| 2348 |
|
---|
| 2349 | %------------------------------------------------------
|
---|
| 2350 | % --- Executes on button press in Menu/Export/field in workspace.
|
---|
| 2351 | %------------------------------------------------------
|
---|
| 2352 | function MenuExportField_Callback(hObject, eventdata, handles)
|
---|
| 2353 |
|
---|
| 2354 | global CurData
|
---|
| 2355 | huvmat=findobj(allchild(0),'Name','uvmat');
|
---|
[71] | 2356 | UvData=get(huvmat,'UserData');
|
---|
| 2357 | CurData=UvData.ProjField_2;
|
---|
[60] | 2358 | evalin('base','global CurData')%make CurData global in the workspace
|
---|
| 2359 | display(['UserData of view_field :'])
|
---|
| 2360 | evalin('base','CurData') %display CurData in the workspace
|
---|
| 2361 | commandwindow;
|
---|
| 2362 |
|
---|
| 2363 | %------------------------------------------------------
|
---|
| 2364 | % --- Executes on button press in Menu/Export/extract figure.
|
---|
| 2365 | %------------------------------------------------------
|
---|
| 2366 | function MenuExport_plot_Callback(hObject, eventdata, handles)
|
---|
| 2367 | huvmat=get(handles.MenuExport_plot,'parent');
|
---|
| 2368 | UvData=get(huvmat,'UserData');
|
---|
| 2369 | hfig=figure;
|
---|
| 2370 | newaxes=copyobj(handles.axes3,hfig);
|
---|
| 2371 | map=colormap(handles.axes3);
|
---|
| 2372 | colormap(map);%transmit the current colormap to the zoom fig
|
---|
| 2373 | colorbar
|
---|
| 2374 |
|
---|
| 2375 |
|
---|
| 2376 |
|
---|
[61] | 2377 | function npx_Callback(hObject, eventdata, handles)
|
---|
[60] | 2378 |
|
---|
| 2379 |
|
---|
| 2380 |
|
---|
[61] | 2381 | function npy_Callback(hObject, eventdata, handles)
|
---|
[60] | 2382 |
|
---|
| 2383 |
|
---|
| 2384 | function edit86_Callback(hObject, eventdata, handles)
|
---|
| 2385 |
|
---|
| 2386 |
|
---|
| 2387 | function edit87_Callback(hObject, eventdata, handles)
|
---|
| 2388 |
|
---|
| 2389 |
|
---|
[61] | 2390 | % --- Executes on button press in auto_sclar.
|
---|
| 2391 | function auto_sclar_Callback(hObject, eventdata, handles)
|
---|
| 2392 | % hObject handle to auto_sclar (see GCBO)
|
---|
[60] | 2393 | % eventdata reserved - to be defined in a future version of MATLAB
|
---|
| 2394 | % handles structure with handles and user data (see GUIDATA)
|
---|
| 2395 |
|
---|
[61] | 2396 | % Hint: get(hObject,'Value') returns toggle state of auto_sclar
|
---|
[60] | 2397 |
|
---|
| 2398 |
|
---|
| 2399 | function edit88_Callback(hObject, eventdata, handles)
|
---|
| 2400 |
|
---|
| 2401 |
|
---|
| 2402 |
|
---|
[61] | 2403 | % --- Executes on button press in AutoScal.
|
---|
[60] | 2404 | function checkbox40_Callback(hObject, eventdata, handles)
|
---|
[61] | 2405 | % hObject handle to AutoScal (see GCBO)
|
---|
[60] | 2406 | % eventdata reserved - to be defined in a future version of MATLAB
|
---|
| 2407 | % handles structure with handles and user data (see GUIDATA)
|
---|
| 2408 |
|
---|
[61] | 2409 | % Hint: get(hObject,'Value') returns toggle state of AutoScal
|
---|
[60] | 2410 |
|
---|
| 2411 |
|
---|
| 2412 |
|
---|
| 2413 | function edit82_Callback(hObject, eventdata, handles)
|
---|
| 2414 |
|
---|
| 2415 |
|
---|
| 2416 |
|
---|
| 2417 | function edit83_Callback(hObject, eventdata, handles)
|
---|
[61] | 2418 | % hObject handle to min_vec (see GCBO)
|
---|
[60] | 2419 | % eventdata reserved - to be defined in a future version of MATLAB
|
---|
| 2420 | % handles structure with handles and user data (see GUIDATA)
|
---|
| 2421 |
|
---|
[61] | 2422 | % Hints: get(hObject,'String') returns contents of min_vec as text
|
---|
| 2423 | % str2double(get(hObject,'String')) returns contents of min_vec as a double
|
---|
[60] | 2424 |
|
---|
| 2425 |
|
---|
| 2426 | % --- Executes on slider movement.
|
---|
| 2427 | function slider9_Callback(hObject, eventdata, handles)
|
---|
[67] | 2428 | % hObject handle to slider2 (see GCBO)
|
---|
[60] | 2429 | % eventdata reserved - to be defined in a future version of MATLAB
|
---|
| 2430 | % handles structure with handles and user data (see GUIDATA)
|
---|
| 2431 |
|
---|
| 2432 | % Hints: get(hObject,'Value') returns position of slider
|
---|
| 2433 | % get(hObject,'Min') and get(hObject,'Max') to determine range of slider
|
---|
| 2434 |
|
---|
| 2435 |
|
---|
| 2436 | % --- Executes on slider movement.
|
---|
| 2437 | function slider10_Callback(hObject, eventdata, handles)
|
---|
[67] | 2438 | % hObject handle to slider1 (see GCBO)
|
---|
[60] | 2439 | % eventdata reserved - to be defined in a future version of MATLAB
|
---|
| 2440 | % handles structure with handles and user data (see GUIDATA)
|
---|
| 2441 |
|
---|
| 2442 | % Hints: get(hObject,'Value') returns position of slider
|
---|
[67] | 2443 | % get(hObject,'Min') and get(hObject,'Max') to determine range of
|
---|
| 2444 | % slider
|
---|
[60] | 2445 |
|
---|
| 2446 |
|
---|
[61] | 2447 | % --- Executes on button press in AutoVecColor.
|
---|
[60] | 2448 | function checkbox41_Callback(hObject, eventdata, handles)
|
---|
[61] | 2449 | % hObject handle to AutoVecColor (see GCBO)
|
---|
[60] | 2450 | % eventdata reserved - to be defined in a future version of MATLAB
|
---|
| 2451 | % handles structure with handles and user data (see GUIDATA)
|
---|
| 2452 |
|
---|
[61] | 2453 | % Hint: get(hObject,'Value') returns toggle state of AutoVecColor
|
---|
[60] | 2454 |
|
---|
| 2455 |
|
---|
| 2456 | function edit89_Callback(hObject, eventdata, handles)
|
---|
[61] | 2457 | % hObject handle to max_vec (see GCBO)
|
---|
[60] | 2458 | % eventdata reserved - to be defined in a future version of MATLAB
|
---|
| 2459 | % handles structure with handles and user data (see GUIDATA)
|
---|
| 2460 |
|
---|
[61] | 2461 | % Hints: get(hObject,'String') returns contents of max_vec as text
|
---|
| 2462 | % str2double(get(hObject,'String')) returns contents of max_vec as a double
|
---|
[60] | 2463 |
|
---|
| 2464 |
|
---|
| 2465 | function edit90_Callback(hObject, eventdata, handles)
|
---|
[67] | 2466 | % hObject handle to colcode2 (see GCBO)
|
---|
[60] | 2467 | % eventdata reserved - to be defined in a future version of MATLAB
|
---|
| 2468 | % handles structure with handles and user data (see GUIDATA)
|
---|
| 2469 |
|
---|
[67] | 2470 | % Hints: get(hObject,'String') returns contents of colcode2 as text
|
---|
| 2471 | % str2double(get(hObject,'String')) returns contents of colcode2 as a double
|
---|
[60] | 2472 |
|
---|
| 2473 |
|
---|
| 2474 |
|
---|
| 2475 |
|
---|
[67] | 2476 | function closefcn(hObject, eventdata, handles)
|
---|
[61] | 2477 | huvmat=findobj(allchild(0),'Name','uvmat');
|
---|
| 2478 | hhuvmat=guidata(huvmat);
|
---|
[67] | 2479 | list_object_2=get(hhuvmat.list_object_2,'String');
|
---|
| 2480 | set(hhuvmat.list_object_2,'Value',numel(list_object_2))%select the last value ('...')
|
---|
| 2481 | delete(hObject)
|
---|
[71] | 2482 |
|
---|
| 2483 |
|
---|
| 2484 |
|
---|
| 2485 | % --- Executes on button press in checkbox42.
|
---|
| 2486 | function checkbox42_Callback(hObject, eventdata, handles)
|
---|
| 2487 | % hObject handle to checkbox42 (see GCBO)
|
---|
| 2488 | % eventdata reserved - to be defined in a future version of MATLAB
|
---|
| 2489 | % handles structure with handles and user data (see GUIDATA)
|
---|
| 2490 |
|
---|
| 2491 | % Hint: get(hObject,'Value') returns toggle state of checkbox42
|
---|
| 2492 |
|
---|
| 2493 |
|
---|
| 2494 | % --- Executes on button press in checkbox43.
|
---|
| 2495 | function checkbox43_Callback(hObject, eventdata, handles)
|
---|
| 2496 | % hObject handle to checkbox43 (see GCBO)
|
---|
| 2497 | % eventdata reserved - to be defined in a future version of MATLAB
|
---|
| 2498 | % handles structure with handles and user data (see GUIDATA)
|
---|
| 2499 |
|
---|
| 2500 | % Hint: get(hObject,'Value') returns toggle state of checkbox43
|
---|
| 2501 |
|
---|
| 2502 |
|
---|
| 2503 | % --- Executes on button press in checkbox44.
|
---|
| 2504 | function checkbox44_Callback(hObject, eventdata, handles)
|
---|
| 2505 | % hObject handle to checkbox44 (see GCBO)
|
---|
| 2506 | % eventdata reserved - to be defined in a future version of MATLAB
|
---|
| 2507 | % handles structure with handles and user data (see GUIDATA)
|
---|
| 2508 |
|
---|
| 2509 | % Hint: get(hObject,'Value') returns toggle state of checkbox44
|
---|
| 2510 |
|
---|
| 2511 |
|
---|
| 2512 | % --- Executes on selection change in popupmenu18.
|
---|
| 2513 | function popupmenu18_Callback(hObject, eventdata, handles)
|
---|
| 2514 |
|
---|
| 2515 |
|
---|
| 2516 | function edit91_Callback(hObject, eventdata, handles)
|
---|
| 2517 | % hObject handle to edit91 (see GCBO)
|
---|
| 2518 | % eventdata reserved - to be defined in a future version of MATLAB
|
---|
| 2519 | % handles structure with handles and user data (see GUIDATA)
|
---|
| 2520 |
|
---|
| 2521 | % Hints: get(hObject,'String') returns contents of edit91 as text
|
---|
| 2522 | % str2double(get(hObject,'String')) returns contents of edit91 as a double
|
---|
| 2523 |
|
---|
| 2524 |
|
---|
| 2525 | % --- Executes on button press in checkbox45.
|
---|
| 2526 | function checkbox45_Callback(hObject, eventdata, handles)
|
---|
| 2527 | % hObject handle to checkbox45 (see GCBO)
|
---|
| 2528 | % eventdata reserved - to be defined in a future version of MATLAB
|
---|
| 2529 | % handles structure with handles and user data (see GUIDATA)
|
---|
| 2530 |
|
---|
| 2531 | % Hint: get(hObject,'Value') returns toggle state of checkbox45
|
---|
| 2532 |
|
---|
| 2533 |
|
---|
| 2534 | % --- Executes on selection change in popupmenu19.
|
---|
| 2535 | function popupmenu19_Callback(hObject, eventdata, handles)
|
---|
| 2536 | % hObject handle to popupmenu19 (see GCBO)
|
---|
| 2537 | % eventdata reserved - to be defined in a future version of MATLAB
|
---|
| 2538 | % handles structure with handles and user data (see GUIDATA)
|
---|
| 2539 |
|
---|
| 2540 | % Hints: contents = get(hObject,'String') returns popupmenu19 contents as cell array
|
---|
| 2541 | % contents{get(hObject,'Value')} returns selected item from popupmenu19
|
---|
| 2542 |
|
---|
| 2543 |
|
---|
| 2544 |
|
---|
| 2545 |
|
---|
[85] | 2546 |
|
---|
| 2547 |
|
---|
| 2548 |
|
---|
| 2549 | function text_display_Callback(hObject, eventdata, handles)
|
---|
| 2550 | % hObject handle to text_display (see GCBO)
|
---|
| 2551 | % eventdata reserved - to be defined in a future version of MATLAB
|
---|
| 2552 | % handles structure with handles and user data (see GUIDATA)
|
---|
| 2553 |
|
---|
| 2554 | % Hints: get(hObject,'String') returns contents of text_display as text
|
---|
| 2555 | % str2double(get(hObject,'String')) returns contents of text_display as a double
|
---|
| 2556 |
|
---|
| 2557 |
|
---|
| 2558 | % --- Executes during object creation, after setting all properties.
|
---|
| 2559 | function text_display_CreateFcn(hObject, eventdata, handles)
|
---|
| 2560 | % hObject handle to text_display (see GCBO)
|
---|
| 2561 | % eventdata reserved - to be defined in a future version of MATLAB
|
---|
| 2562 | % handles empty - handles not created until after all CreateFcns called
|
---|
| 2563 |
|
---|
| 2564 | % Hint: edit controls usually have a white background on Windows.
|
---|
| 2565 | % See ISPC and COMPUTER.
|
---|
| 2566 | if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
|
---|
| 2567 | set(hObject,'BackgroundColor','white');
|
---|
| 2568 | end
|
---|
| 2569 |
|
---|
| 2570 |
|
---|