[198] | 1 | %'view_field': function associated with the GUI 'view_field.fig' for images and data field visualization
|
---|
| 2 | %------------------------------------------------------------------------
|
---|
| 3 | % function huvmat=view_field(input)
|
---|
| 4 | %
|
---|
| 5 | %OUTPUT
|
---|
| 6 | % huvmat=current handles of the GUI view_field.fig
|
---|
| 7 | %%
|
---|
| 8 | %
|
---|
| 9 | %INPUT:
|
---|
| 10 | % input: input file name (if character chain), or input image matrix to
|
---|
| 11 | % visualize, or Matlab structure representing netcdf fields (with fields
|
---|
| 12 | % ListVarName....)
|
---|
| 13 | %
|
---|
| 14 | %AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
|
---|
| 15 | % Copyright Joel Sommeria, 2008, LEGI / CNRS-UJF-INPG, joel.sommeria@legi.grenoble-inp.fr.
|
---|
| 16 | %AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
|
---|
| 17 | % This open is part of the toolbox VIEW_FIELD.
|
---|
| 18 | %
|
---|
| 19 | % VIEW_FIELD is free software; you can redistribute it and/or modify
|
---|
| 20 | % it under the terms of the GNU General Public License as published by
|
---|
| 21 | % the Free Software Foundation; either version 2 of the License, or
|
---|
| 22 | % (at your option) any later version.
|
---|
| 23 | %
|
---|
| 24 | % VIEW_FIELD is distributed in the hope that it will be useful,
|
---|
| 25 | % but WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
| 26 | % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
---|
| 27 | % GNU General Public License (open VIEW_FIELD/COPYING.txt) for more details.
|
---|
| 28 | %AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
|
---|
| 29 |
|
---|
| 30 | %-------------------------------------------------------------------
|
---|
| 31 | % I - MAIN FUNCTION VIEW_FIELD (DO NOT MODIFY)
|
---|
| 32 | %-------------------------------------------------------------------
|
---|
| 33 | %-------------------------------------------------------------------
|
---|
| 34 | function varargout = view_field(varargin)
|
---|
| 35 |
|
---|
| 36 | % Begin initialization code - DO NOT EDIT
|
---|
| 37 | gui_Singleton = 1;
|
---|
| 38 | gui_State = struct('gui_Name', mfilename, ...
|
---|
| 39 | 'gui_Singleton', gui_Singleton, ...
|
---|
| 40 | 'gui_OpeningFcn', @view_field_OpeningFcn, ...
|
---|
| 41 | 'gui_OutputFcn', @view_field_OutputFcn, ...
|
---|
| 42 | 'gui_LayoutFcn', [], ...
|
---|
| 43 | 'gui_Callback', []);
|
---|
| 44 | if nargin && ischar(varargin{1})
|
---|
| 45 | gui_State.gui_Callback = str2func(varargin{1});
|
---|
| 46 | end
|
---|
| 47 |
|
---|
| 48 | if nargout
|
---|
| 49 | varargout{1:nargout} = gui_mainfcn(gui_State, varargin{:});
|
---|
| 50 | else
|
---|
| 51 | gui_mainfcn(gui_State, varargin{:});
|
---|
| 52 | end
|
---|
| 53 | % End initialization code - DO NOT EDIT
|
---|
| 54 |
|
---|
| 55 | %-------------------------------------------------------------------
|
---|
| 56 | % --- Executes just before view_field is made visible.
|
---|
| 57 | function view_field_OpeningFcn(hObject, eventdata, handles, Field )
|
---|
| 58 | %-------------------------------------------------------------------
|
---|
| 59 |
|
---|
| 60 | % Choose default command menuline output for view_field
|
---|
| 61 | handles.output = handles.view_field;
|
---|
| 62 |
|
---|
| 63 | % Update handles structure
|
---|
| 64 | guidata(hObject, handles);
|
---|
| 65 |
|
---|
| 66 | dircur=pwd; %current working directory
|
---|
| 67 | dir_opening=dircur;
|
---|
| 68 |
|
---|
| 69 | % set the position of colorbar and ancillary GUIs:
|
---|
| 70 | set(hObject,'Units','Normalized')
|
---|
| 71 | handles_mouse=handles;
|
---|
| 72 | huvmat=findobj(allchild(0),'Name','uvmat');
|
---|
| 73 | if ~isempty(huvmat)
|
---|
| 74 | hhuvmat=guidata(huvmat);
|
---|
| 75 | set(hhuvmat.list_object_2,'Visible','on')
|
---|
| 76 | set(hhuvmat.view_field_title,'Visible','on')
|
---|
| 77 | % handles_mouse.create=hhuvmat.create;
|
---|
| 78 | handles_mouse.edit=hhuvmat.edit_object;
|
---|
| 79 | pos_uvmat=get(huvmat,'Position');
|
---|
| 80 | pos_view_field(1)=pos_uvmat(1)+pos_uvmat(3)/2;
|
---|
| 81 | pos_view_field(2)=pos_uvmat(2)-pos_uvmat(3)/4;
|
---|
| 82 | pos_view_field(3:4)=pos_uvmat(3:4);
|
---|
| 83 | set(hObject,'Position',pos_view_field)
|
---|
| 84 | end
|
---|
| 85 |
|
---|
| 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})
|
---|
| 91 | set(hObject,'CloseRequestFcn',{@closefcn})%
|
---|
| 92 | ViewFieldData.axes3=[];%initiates the record of the current field (will be updated by plot_field)
|
---|
| 93 | set(handles.view_field,'UserData',ViewFieldData);%store the current field
|
---|
| 94 | AxeData.LimEditBox=1; %initialise AxeData, the parent figure sets plot parameters
|
---|
| 95 | set(handles.axes3,'UserData',AxeData)
|
---|
| 96 | if ~exist('Field','var')
|
---|
| 97 | return
|
---|
| 98 | end
|
---|
| 99 | [PlotType,PlotParamOut]= plot_field(Field,handles.axes3);%,PlotParam,KeepLim,PosColorbar)
|
---|
| 100 |
|
---|
| 101 | if isfield(PlotParamOut,'Vectors')
|
---|
[292] | 102 | set(handles.Vectors,'Visible','on')
|
---|
[198] | 103 | end
|
---|
| 104 | write_plot_param(handles,PlotParamOut);% update the display of the plotting parameters
|
---|
| 105 |
|
---|
| 106 | %-------------------------------------------------------------------
|
---|
| 107 | % --- Outputs from this function are returned to the command menuline.
|
---|
| 108 | function varargout = view_field_OutputFcn(hObject, eventdata, handles)
|
---|
| 109 | varargout{1} = handles.output;% the only output argument is the handle to the GUI figure
|
---|
| 110 |
|
---|
| 111 |
|
---|
| 112 | %-------------------------------------------------------------------
|
---|
| 113 | %-------------------------------------------------------------------
|
---|
| 114 | % II - FUNCTIONS FOR INTRODUCING THE INPUT FILES
|
---|
| 115 | % automatically sets the global properties when the rootfile name is introduced
|
---|
| 116 | % then activate the view-field action if selected
|
---|
| 117 | % it is activated either by clicking on the RootPath window or by the
|
---|
| 118 | % browser
|
---|
| 119 | %------------------------------------------------------------------
|
---|
| 120 | %------------------------------------------------------------------
|
---|
| 121 |
|
---|
| 122 | %-------------------------------------------------------------------
|
---|
| 123 | function update_mask(handles,num_i1,num_j1)
|
---|
| 124 | %-------------------------------------------------------------------
|
---|
| 125 |
|
---|
| 126 | MaskData=get(handles.mask_test,'UserData');
|
---|
| 127 | if isfield(MaskData,'maskhandle')&& ishandle(MaskData.maskhandle)
|
---|
| 128 | uistack(MaskData.maskhandle,'top');
|
---|
| 129 | end
|
---|
| 130 | num_i1_mask=mod(num_i1-1,MaskData.NbSlice)+1;
|
---|
| 131 | [MaskName,mdetect]=name_generator(MaskData.Base,num_i1_mask,num_j1,'.png',MaskData.NomType);
|
---|
| 132 | huvmat=get(handles.mask_test,'parent');
|
---|
| 133 | UvData=get(huvmat,'UserData');
|
---|
| 134 |
|
---|
| 135 | %update mask image if the mask is new
|
---|
| 136 | if ~ (isfield(UvData,'MaskName') && isequal(UvData.MaskName,MaskName))
|
---|
| 137 | UvData.MaskName=MaskName; %update the recorded name on UvData
|
---|
| 138 | set(huvmat,'UserData',UvData);
|
---|
| 139 | if mdetect==0
|
---|
| 140 | if isfield(MaskData,'maskhandle')&& ishandle(MaskData.maskhandle)
|
---|
| 141 | delete(MaskData.maskhandle)
|
---|
| 142 | end
|
---|
| 143 | else
|
---|
| 144 | %read mask image
|
---|
| 145 | Mask.AName='image';
|
---|
| 146 | Mask.A=imread(MaskName);
|
---|
| 147 | npxy=size(Mask.A);
|
---|
| 148 | Mask.AX=[0.5 npxy(2)-0.5];
|
---|
| 149 | Mask.AY=[npxy(1)-0.5 0.5 ];
|
---|
| 150 | Mask.CoordUnit='pixel';
|
---|
| 151 | if isequal(get(handles.slices,'Value'),1)
|
---|
| 152 | NbSlice=str2num(get(handles.nb_slice,'String'));
|
---|
| 153 | num_i1=str2num(get(handles.i1,'String'));
|
---|
| 154 | Mask.ZIndex=mod(num_i1-1,NbSlice)+1;
|
---|
| 155 | end
|
---|
| 156 | %px to phys or other transform on field
|
---|
| 157 | menu_transform=get(handles.transform_fct,'String');
|
---|
| 158 | choice_value=get(handles.transform_fct,'Value');
|
---|
| 159 | transform_name=menu_transform{choice_value};%name of the transform fct given by the menu 'transform_fct'
|
---|
| 160 | transform_list=get(handles.transform_fct,'UserData');
|
---|
| 161 | transform=transform_list{choice_value};
|
---|
| 162 | if ~isequal(transform_name,'') && ~isequal(transform_name,'px')
|
---|
| 163 | if isfield(UvData,'XmlData') && isfield(UvData.XmlData,'GeometryCalib')%use geometry calib recorded from the ImaDoc xml file as first priority
|
---|
| 164 | Calib=UvData.XmlData.GeometryCalib;
|
---|
| 165 | Mask=transform(Mask,UvData.XmlData);
|
---|
| 166 | end
|
---|
| 167 | end
|
---|
| 168 | flagmask=Mask.A < 200;
|
---|
| 169 |
|
---|
| 170 | %make brown color image
|
---|
| 171 | imflag(:,:,1)=0.9*flagmask;
|
---|
| 172 | imflag(:,:,2)=0.7*flagmask;
|
---|
| 173 | imflag(:,:,3)=zeros(size(flagmask));
|
---|
| 174 |
|
---|
| 175 | %update mask image
|
---|
| 176 | hmask=[]; %default
|
---|
| 177 | if isfield(MaskData,'maskhandle')&& ishandle(MaskData.maskhandle)
|
---|
| 178 | hmask=MaskData.maskhandle;
|
---|
| 179 | end
|
---|
| 180 | if ~isempty(hmask)
|
---|
| 181 | set(hmask,'CData',imflag)
|
---|
| 182 | set(hmask,'AlphaData',flagmask*0.6)
|
---|
| 183 | set(hmask,'XData',Mask.AX);
|
---|
| 184 | set(hmask,'YData',Mask.AY);
|
---|
| 185 | % uistack(hmask,'top')
|
---|
| 186 | else
|
---|
| 187 | axes(handles.axes3)
|
---|
| 188 | hold on
|
---|
| 189 | MaskData.maskhandle=image(Mask.AX,Mask.AY,imflag,'Tag','mask','HitTest','off','AlphaData',0.6*flagmask);
|
---|
| 190 | % set(MaskData.maskhandle,'AlphaData',0.6*flagmask)
|
---|
| 191 | set(handles.mask_test,'UserData',MaskData)
|
---|
| 192 | end
|
---|
| 193 | end
|
---|
| 194 | end
|
---|
| 195 |
|
---|
| 196 |
|
---|
| 197 | %-------------------------------------------------------------------
|
---|
| 198 | function MenuExportFigure_Callback(hObject, eventdata, handles)
|
---|
| 199 | %-------------------------------------------------------------------
|
---|
| 200 | huvmat=get(handles.MenuExport,'parent');
|
---|
| 201 | UvData=get(huvmat,'UserData');
|
---|
| 202 | hfig=figure;
|
---|
| 203 | newaxes=copyobj(handles.axes3,hfig);
|
---|
| 204 | map=colormap(handles.axes3);
|
---|
| 205 | colormap(map);%transmit the current colormap to the zoom fig
|
---|
| 206 | colorbar
|
---|
| 207 |
|
---|
| 208 | %-------------------------------------------------------------------
|
---|
| 209 | %-------------------------------------------------------------------
|
---|
| 210 | % III - MAIN REFRESH FUNCTIONS : 'FRAME PLOT'
|
---|
| 211 | %-------------------------------------------------------------------
|
---|
| 212 | %-------------------------------------------------------------------
|
---|
| 213 |
|
---|
| 214 | %Executes on button press in runplus: make one step forward and call
|
---|
| 215 | %run0. The step forward is along the fields series 1 or 2 depending on
|
---|
| 216 | %the scan_i and scan_j check box (exclusive each other)
|
---|
| 217 | %-------------------------------------------------------------------
|
---|
| 218 | function runplus_Callback(hObject, eventdata, handles)
|
---|
| 219 | increment=str2num(get(handles.increment_scan,'String')); %get the field increment d
|
---|
| 220 | runpm(hObject,eventdata,handles,increment)
|
---|
| 221 |
|
---|
| 222 | %-------------------------------------------------------------------
|
---|
| 223 | %Executes on button press in runmin: make one step backward and call
|
---|
| 224 | %run0. The step backward is along the fields series 1 or 2 depending on
|
---|
| 225 | %the scan_i and scan_j check box (exclusive each other)
|
---|
| 226 | %-------------------------------------------------------------------
|
---|
| 227 | function runmin_Callback(hObject, eventdata, handles)
|
---|
| 228 | increment=-str2num(get(handles.increment_scan,'String')); %get the field increment d
|
---|
| 229 | runpm(hObject,eventdata,handles,increment)
|
---|
| 230 |
|
---|
| 231 | %-------------------------------------------------------------------
|
---|
| 232 | %Executes on button press in runmin: make one step backward and call
|
---|
| 233 | %run0. The step backward is along the fields series 1 or 2 depending on
|
---|
| 234 | %the scan_i and scan_j check box (exclusive each other)
|
---|
| 235 | %-------------------------------------------------------------------
|
---|
| 236 | function RunMovie_Callback(hObject, eventdata, handles)
|
---|
| 237 | %------------------------------------------------------------------
|
---|
| 238 | set(handles.RunMovie,'BackgroundColor',[1 1 0])%paint the command button in yellow
|
---|
| 239 | drawnow
|
---|
| 240 | increment=str2num(get(handles.increment_scan,'String')); %get the field increment d
|
---|
| 241 | set(handles.STOP,'Visible','on')
|
---|
| 242 | set(handles.speed,'Visible','on')
|
---|
| 243 | set(handles.speed_txt,'Visible','on')
|
---|
| 244 | set(handles.RunMovie,'BusyAction','queue')
|
---|
| 245 | testavi=0;
|
---|
| 246 | UvData=get(handles.view_field,'UserData');
|
---|
| 247 |
|
---|
| 248 | while get(handles.speed,'Value')~=0 & isequal(get(handles.RunMovie,'BusyAction'),'queue') % enable STOP command
|
---|
| 249 | runpm(hObject,eventdata,handles,increment)
|
---|
| 250 | pause(1.02-get(handles.speed,'Value'))% wait for next image
|
---|
| 251 | end
|
---|
| 252 | if isfield(UvData,'aviobj') && ~isempty( UvData.aviobj),
|
---|
| 253 | UvData.aviobj=close(UvData.aviobj);
|
---|
| 254 | set(handles.view_field,'UserData',UvData);
|
---|
| 255 | end
|
---|
| 256 | set(handles.RunMovie,'BackgroundColor',[1 0 0])%paint the command buttonback to red
|
---|
| 257 |
|
---|
| 258 |
|
---|
| 259 |
|
---|
| 260 | %-------------------------------------------------------------------
|
---|
| 261 | % --- translate coordinate to matrix index
|
---|
| 262 | %-------------------------------------------------------------------
|
---|
| 263 | function [indx,indy]=pos2ind(x0,rangx0,nxy)
|
---|
| 264 | indx=1+round((nxy(2)-1)*(x0-rangx0(1))/(rangx0(2)-rangx0(1)));% index x of pixel
|
---|
| 265 | indy=1+round((nxy(1)-1)*(y12-rangy0(1))/(rangy0(2)-rangy0(1)));% index y of pixel
|
---|
| 266 |
|
---|
| 267 | %-------------------------------------------------------------------
|
---|
| 268 | % --- Executes on button press in 'FixLimits'.
|
---|
| 269 | %-------------------------------------------------------------------
|
---|
[295] | 270 | function CheckFixLimits_Callback(hObject, eventdata, handles)
|
---|
| 271 | test=get(handles.CheckFixLimits,'Value');
|
---|
[198] | 272 | if test
|
---|
[295] | 273 | set(handles.CheckFixLimits,'BackgroundColor',[1 1 0])
|
---|
[198] | 274 | else
|
---|
[295] | 275 | set(handles.CheckFixLimits,'BackgroundColor',[0.7 0.7 0.7])
|
---|
[198] | 276 | end
|
---|
[295] | 277 | update_plot(handles)
|
---|
[198] | 278 |
|
---|
| 279 | %-------------------------------------------------------------------
|
---|
| 280 | % --- Executes on button press in FixEqual.
|
---|
[295] | 281 | function CheckFixEqual_Callback(hObject, eventdata, handles)
|
---|
[198] | 282 | test=get(handles.FixEqual,'Value');
|
---|
| 283 | if test
|
---|
[295] | 284 | set(handles.CheckFixEqual,'BackgroundColor',[1 1 0])
|
---|
[198] | 285 | cla(handles.axes3)
|
---|
| 286 | else
|
---|
[295] | 287 | set(handles.CheckFixEqual,'BackgroundColor',[0.7 0.7 0.7])
|
---|
[198] | 288 | end
|
---|
[295] | 289 | update_plot(handles)
|
---|
[198] | 290 |
|
---|
| 291 | %-------------------------------------------------------------------
|
---|
| 292 |
|
---|
| 293 | %-------------------------------------------------------------------
|
---|
| 294 | % --- Executes on button press in 'zoom'.
|
---|
| 295 | %-------------------------------------------------------------------
|
---|
| 296 | function zoom_Callback(hObject, eventdata, handles)
|
---|
| 297 | if (get(handles.zoom,'Value') == 1);
|
---|
| 298 | set(handles.zoom,'BackgroundColor',[1 1 0])
|
---|
| 299 | set(handles.FixLimits,'Value',1)% propose by default fixed limits for the plotting axes
|
---|
| 300 | set(handles.FixLimits,'BackgroundColor',[1 1 0])
|
---|
| 301 | else
|
---|
| 302 | set(handles.zoom,'BackgroundColor',[0.7 0.7 0.7])
|
---|
| 303 | end
|
---|
| 304 |
|
---|
| 305 | %-------------------------------------------------------------------
|
---|
| 306 | %----Executes on button press in 'record': records the current flags of manual correction.
|
---|
| 307 | %-------------------------------------------------------------------
|
---|
| 308 | function record_Callback(hObject, eventdata, handles)
|
---|
| 309 | % [filebase,num_i1,num_j1,num_i2,num_j2,Ext,NomType,SubDir]=read_input_file(handles);
|
---|
| 310 | filename=read_file_boxes(handles);
|
---|
| 311 | AxeData=get(gca,'UserData');
|
---|
| 312 | [erread,message]=fileattrib(filename);
|
---|
| 313 | if ~isempty(message) && ~isequal(message.UserWrite,1)
|
---|
| 314 | msgbox_view_field('ERROR',['no writting access to ' filename])
|
---|
| 315 | return
|
---|
| 316 | end
|
---|
| 317 | test_civ2=isequal(get(handles.civ2,'BackgroundColor'),[1 1 0]);
|
---|
| 318 | test_civ1=isequal(get(handles.civ1,'BackgroundColor'),[1 1 0]);
|
---|
| 319 | if ~test_civ2 && ~test_civ1
|
---|
| 320 | msgbox_view_field('ERROR','manual correction only possible for CIV1 or CIV2 velocity fields')
|
---|
| 321 | end
|
---|
| 322 | if test_civ2
|
---|
| 323 | nbname='nb_vectors2';
|
---|
| 324 | flagname='vec2_FixFlag';
|
---|
| 325 | attrname='fix2';
|
---|
| 326 | end
|
---|
| 327 | if test_civ1
|
---|
| 328 | nbname='nb_vectors';
|
---|
| 329 | flagname='vec_FixFlag';
|
---|
| 330 | attrname='fix';
|
---|
| 331 | end
|
---|
| 332 | %write fix flags in the netcdf file
|
---|
| 333 | hhh=which('netcdf.open');% look for built-in matlab netcdf library
|
---|
| 334 | if ~isequal(hhh,'')% case of new builtin Matlab netcdf library
|
---|
| 335 | nc=netcdf.open(filename,'NC_WRITE');
|
---|
| 336 | netcdf.reDef(nc)
|
---|
| 337 | netcdf.putAtt(nc,netcdf.getConstant('NC_GLOBAL'),attrname,1)
|
---|
| 338 | dimid = netcdf.inqDimID(nc,nbname);
|
---|
| 339 | try
|
---|
| 340 | varid = netcdf.inqVarID(nc,flagname);% look for already existing fixflag variable
|
---|
| 341 | catch
|
---|
| 342 | varid=netcdf.defVar(nc,flagname,'double',dimid);%create fixflag variable if it does not exist
|
---|
| 343 | end
|
---|
| 344 | netcdf.endDef(nc)
|
---|
| 345 | netcdf.putVar(nc,varid,AxeData.FF);
|
---|
| 346 | netcdf.close(nc)
|
---|
| 347 | else %old netcdf library
|
---|
| 348 | netcdf_toolbox(filename,AxeData,attrname,nbname,flagname)
|
---|
| 349 | end
|
---|
| 350 |
|
---|
| 351 | function netcdf_toolbox(filename,AxeData,attrname,nbname,flagname)
|
---|
| 352 | nc=netcdf(filename,'write'); %open netcdf file
|
---|
| 353 | result=redef(nc);
|
---|
| 354 | eval(['nc.' attrname '=1;']);
|
---|
| 355 | theDim=nc(nbname) ;% get the number of velocity vectors
|
---|
| 356 | nb_vectors=size(theDim);
|
---|
| 357 | var_FixFlag=ncvar(flagname,nc);% var_FixFlag will be written as the netcdf variable vec_FixFlag
|
---|
| 358 | var_FixFlag(1:nb_vectors)=AxeData.FF;%
|
---|
| 359 | fin=close(nc);
|
---|
| 360 |
|
---|
| 361 |
|
---|
| 362 | %-------------------------------------------------------------------
|
---|
| 363 | %-------------------------------------------------------------------
|
---|
| 364 | % - FUNCTIONS FOR SETTING PLOTTING PARAMETERS
|
---|
| 365 |
|
---|
| 366 | %------------------------------------------------------------------
|
---|
| 367 |
|
---|
| 368 |
|
---|
| 369 | %------------------------------------------------------------------
|
---|
| 370 | % --- Executes on selection change in col_vec: choice of the color code.
|
---|
| 371 | %
|
---|
| 372 | function col_vec_Callback(hObject, eventdata, handles)
|
---|
| 373 | %------------------------------------------------------------------
|
---|
| 374 | % edit the choice for color code
|
---|
| 375 | list_code=get(handles.col_vec,'String');% list menu fields
|
---|
| 376 | index_code=get(handles.col_vec,'Value');% selected string index
|
---|
| 377 | col_code= list_code{index_code(1)}; % selected field
|
---|
| 378 | if isequal(col_code,'black') | isequal(col_code,'white')
|
---|
| 379 | set(handles.slider1,'Visible','off')
|
---|
| 380 | set(handles.slider2,'Visible','off')
|
---|
| 381 | set(handles.colcode1,'Visible','off')
|
---|
| 382 | set(handles.colcode2,'Visible','off')
|
---|
| 383 | set(handles.AutoVecColor,'Visible','off')
|
---|
| 384 | set_vec_col_bar(handles)
|
---|
| 385 | else
|
---|
| 386 | set(handles.slider1,'Visible','on')
|
---|
| 387 | set(handles.slider2,'Visible','on')
|
---|
| 388 | set(handles.colcode1,'Visible','on')
|
---|
| 389 | set(handles.colcode2,'Visible','on')
|
---|
| 390 | set(handles.AutoVecColor,'Visible','on')
|
---|
| 391 | if isequal(col_code,'ima_cor')
|
---|
| 392 | set(handles.AutoVecColor,'Value',0)%fixed scale by default
|
---|
| 393 | set(handles.vec_col_bar,'Value',0)% 3 colors r,g,b by default
|
---|
| 394 | set(handles.slider1,'Min',0);
|
---|
| 395 | set(handles.slider1,'Max',1);
|
---|
| 396 | set(handles.slider2,'Min',0);
|
---|
| 397 | set(handles.slider2,'Max',1);
|
---|
| 398 | % set(handles.min_C_title_vec,'String','0')
|
---|
| 399 | set(handles.max_vec,'String','1')
|
---|
| 400 | set(handles.colcode1,'String','0.333')
|
---|
| 401 | colcode1_Callback(hObject, eventdata, handles)
|
---|
| 402 | set(handles.colcode2,'String','0.666')
|
---|
| 403 | colcode2_Callback(hObject, eventdata, handles)
|
---|
| 404 | else
|
---|
| 405 | set(handles.AutoVecColor,'Value',1)%auto scale between min,max by default
|
---|
| 406 | set(handles.vec_col_bar,'Value',1)% colormap 'jet' by default
|
---|
| 407 | minval=get(handles.slider1,'Min');
|
---|
| 408 | maxval=get(handles.slider1,'Max');
|
---|
| 409 | set(handles.slider1,'Value',minval)
|
---|
| 410 | set(handles.slider2,'Value',maxval)
|
---|
| 411 | set_vec_col_bar(handles)
|
---|
| 412 | end
|
---|
| 413 | % slider_update(handles)
|
---|
| 414 | end
|
---|
| 415 | %replot the current graph
|
---|
| 416 | run0_Callback(hObject, eventdata, handles)
|
---|
| 417 |
|
---|
| 418 |
|
---|
| 419 | %----------------------------------------------------------------
|
---|
| 420 | % -- Executes on slider movement to set the color code
|
---|
| 421 | %
|
---|
| 422 | function slider1_Callback(hObject, eventdata, handles)
|
---|
| 423 | %------------------------------------------------------------------
|
---|
| 424 | slider1=get(handles.slider1,'Value');
|
---|
| 425 | min_val=str2num(get(handles.min_vec,'String'));
|
---|
| 426 | max_val=str2num(get(handles.max_vec,'String'));
|
---|
| 427 | col=min_val+(max_val-min_val)*slider1;
|
---|
| 428 | set(handles.colcode1,'String',num2str(col))
|
---|
| 429 | if(get(handles.slider2,'Value') < col)%move also the second slider at the same value if needed
|
---|
| 430 | set(handles.slider2,'Value',col)
|
---|
| 431 | set(handles.colcode2,'String',num2str(col))
|
---|
| 432 | end
|
---|
| 433 | colcode1_Callback(hObject, eventdata, handles)
|
---|
| 434 |
|
---|
| 435 | %----------------------------------------------------------------
|
---|
| 436 | % Executes on slider movement to set the color code
|
---|
| 437 | %----------------------------------------------------------------
|
---|
| 438 | function slider2_Callback(hObject, eventdata, handles)
|
---|
| 439 | slider2=get(handles.slider2,'Value');
|
---|
| 440 | min_val=str2num(get(handles.min_vec,'String'));
|
---|
| 441 | max_val=str2num(get(handles.max_vec,'String'));
|
---|
| 442 | col=min_val+(max_val-min_val)*slider2;
|
---|
| 443 | set(handles.colcode2,'String',num2str(col))
|
---|
| 444 | if(get(handles.slider1,'Value') > col)%move also the first slider at the same value if needed
|
---|
| 445 | set(handles.slider1,'Value',col)
|
---|
| 446 | set(handles.colcode1,'String',num2str(col))
|
---|
| 447 | end
|
---|
| 448 | colcode2_Callback(hObject, eventdata, handles)
|
---|
| 449 |
|
---|
| 450 | %----------------------------------------------------------------
|
---|
| 451 | %execute on return carriage on the edit box corresponding to slider 1
|
---|
| 452 | %----------------------------------------------------------------
|
---|
| 453 | function colcode1_Callback(hObject, eventdata, handles)
|
---|
| 454 | % col=str2num(get(handles.colcode1,'String'));
|
---|
| 455 | % set(handles.slider1,'Value',col)
|
---|
| 456 | set_vec_col_bar(handles)
|
---|
| 457 | update_plot(handles)
|
---|
| 458 |
|
---|
| 459 | %----------------------------------------------------------------
|
---|
| 460 | %execute on return carriage on the edit box corresponding to slider 2
|
---|
| 461 | %----------------------------------------------------------------
|
---|
| 462 | function colcode2_Callback(hObject, eventdata, handles)
|
---|
| 463 | % col=str2num(get(handles.colcode2,'String'));
|
---|
| 464 | % set(handles.slider2,'Value',col)
|
---|
| 465 | % slider2_Callback(hObject, eventdata, handles)
|
---|
| 466 | set_vec_col_bar(handles)
|
---|
| 467 | update_plot(handles)
|
---|
| 468 | %------------------------------------------------------------
|
---|
| 469 | %update the slider values after displaying vectors
|
---|
| 470 | %--------------------------------------------------------
|
---|
| 471 | % function slider_update(handles,auto,minC,colcode1,colcode2,maxC)
|
---|
| 472 | % set(handles.slider1,'Min',minC)
|
---|
| 473 | % set(handles.slider1,'Max',maxC)
|
---|
| 474 | % set(handles.slider2,'Min',minC)
|
---|
| 475 | % set(handles.slider2,'Max',maxC)
|
---|
| 476 | % set(handles.min_C_title_vec,'String',num2str(minC))
|
---|
| 477 | % set(handles.max_vec,'String',num2str(maxC))
|
---|
| 478 | % if auto
|
---|
| 479 | % set(handles.colcode1,'String',num2str(colcode1,3))%update display
|
---|
| 480 | % set(handles.colcode2,'String',num2str(colcode2,3))
|
---|
| 481 | % end
|
---|
| 482 | % set(handles.slider1,'Value',colcode1)%update slider with constant display
|
---|
| 483 | % set(handles.slider2,'Value',colcode2)
|
---|
| 484 | % set_vec_col_bar(handles)
|
---|
| 485 |
|
---|
| 486 |
|
---|
| 487 | %-------------------------------------------------------
|
---|
| 488 | % --- Executes on button press in AutoVecColor.
|
---|
| 489 | %-------------------------------------------------------
|
---|
| 490 | function vec_col_bar_Callback(hObject, eventdata, handles)
|
---|
| 491 | set_vec_col_bar(handles)
|
---|
| 492 |
|
---|
| 493 | %------------------------------------------------
|
---|
| 494 | %CALLBACKS FOR PLOTTING PARAMETERS
|
---|
| 495 | %-------------------------------------------------
|
---|
| 496 |
|
---|
| 497 | %------------------------------------------------------------------------
|
---|
[295] | 498 | function num_MinX_Callback(hObject, eventdata, handles)
|
---|
[198] | 499 | %------------------------------------------------------------------------
|
---|
[295] | 500 | set(handles.CheckFixLimits,'Value',1) %suppress auto mode
|
---|
| 501 | set(handles.CheckFixLimits,'BackgroundColor',[1 1 0])
|
---|
[198] | 502 | update_plot(handles);
|
---|
| 503 |
|
---|
| 504 | %------------------------------------------------------------------------
|
---|
[295] | 505 | function num_MaxX_Callback(hObject, eventdata, handles)
|
---|
[198] | 506 | %------------------------------------------------------------------------
|
---|
[295] | 507 | set(handles.CheckFixLimits,'Value',1) %suppress auto mode
|
---|
| 508 | set(handles.CheckFixLimits,'BackgroundColor',[1 1 0])
|
---|
[198] | 509 | update_plot(handles);
|
---|
| 510 |
|
---|
| 511 | %------------------------------------------------------------------------
|
---|
[295] | 512 | function num_MinY_Callback(hObject, eventdata, handles)
|
---|
[198] | 513 | %------------------------------------------
|
---|
[295] | 514 | set(handles.CheckFixLimits,'Value',1) %suppress auto mode
|
---|
| 515 | set(handles.CheckFixLimits,'BackgroundColor',[1 1 0])
|
---|
[198] | 516 | update_plot(handles);
|
---|
| 517 |
|
---|
| 518 | %------------------------------------------------------------------------
|
---|
[295] | 519 | function num_MaxY_Callback(hObject, eventdata, handles)
|
---|
[198] | 520 | %------------------------------------------------------------------------
|
---|
[295] | 521 | set(handles.CheckFixLimits,'Value',1) %suppress auto mode
|
---|
| 522 | set(handles.CheckFixLimits,'BackgroundColor',[1 1 0])
|
---|
[198] | 523 | update_plot(handles);
|
---|
| 524 |
|
---|
| 525 | %-----------------------------------------------------------------
|
---|
[295] | 526 | function num_MinA_Callback(hObject, eventdata, handles)
|
---|
[198] | 527 | %------------------------------------------
|
---|
[295] | 528 | set(handles.CheckFixScalar,'Value',1) %suppress auto mode
|
---|
| 529 | set(handles.CheckFixScalar,'BackgroundColor',[1 1 0])
|
---|
[198] | 530 | update_plot(handles)
|
---|
| 531 |
|
---|
| 532 | %-----------------------------------------------------------------
|
---|
[295] | 533 | function num_MaxA_Callback(hObject, eventdata, handles)
|
---|
[198] | 534 | %--------------------------------------------
|
---|
[295] | 535 | set(handles.CheckFixScalar,'Value',1) %suppress auto mode
|
---|
| 536 | set(handles.CheckFixScalar,'BackgroundColor',[1 1 0])
|
---|
[198] | 537 | update_plot(handles)
|
---|
| 538 |
|
---|
| 539 | %-----------------------------------------------
|
---|
[295] | 540 | function CheckFixScalar_Callback(hObject, eventdata, handles)
|
---|
[198] | 541 | %--------------------------------------------
|
---|
[295] | 542 | test=get(handles.CheckFixScalar,'Value');
|
---|
[198] | 543 | if test
|
---|
[295] | 544 | set(handles.CheckFixScalar,'BackgroundColor',[1 1 0])
|
---|
[198] | 545 | else
|
---|
[295] | 546 | set(handles.CheckFixScalar,'BackgroundColor',[0.7 0.7 0.7])
|
---|
[198] | 547 | update_plot(handles);
|
---|
| 548 | % set(handles.MinA,'String',num2str(ScalOut.MinA,3))
|
---|
| 549 | % set(handles.MaxA,'String',num2str(ScalOut.MaxA,3))
|
---|
| 550 | end
|
---|
| 551 |
|
---|
| 552 | %-------------------------------------------------------------------
|
---|
[295] | 553 | function CheckBW_Callback(hObject, eventdata, handles)
|
---|
[198] | 554 | %-------------------------------------------------------------------
|
---|
| 555 | update_plot(handles)
|
---|
| 556 |
|
---|
| 557 | %-------------------------------------------------------------------
|
---|
[295] | 558 | function ListContour_Callback(hObject, eventdata, handles)
|
---|
[198] | 559 | %-------------------------------------------------------------------
|
---|
| 560 | val=get(handles.Contours,'Value');
|
---|
| 561 | if val==2
|
---|
| 562 | set(handles.interval_txt,'Visible','on')
|
---|
| 563 | set(handles.IncrA,'Visible','on')
|
---|
| 564 | else
|
---|
| 565 | set(handles.interval_txt,'Visible','off')
|
---|
| 566 | set(handles.IncrA,'Visible','off')
|
---|
| 567 | end
|
---|
| 568 | update_plot(handles)
|
---|
| 569 |
|
---|
| 570 | %-------------------------------------------------------------------
|
---|
| 571 | function IncrA_Callback(hObject, eventdata, handles)
|
---|
| 572 | %-------------------------------------------------------------------
|
---|
| 573 | update_plot(handles)
|
---|
| 574 |
|
---|
| 575 | %-------------------------------------------------------------------
|
---|
| 576 | function HideWarning_Callback(hObject, eventdata, handles)
|
---|
| 577 | %-------------------------------------------------------------------
|
---|
| 578 | update_plot(handles)
|
---|
| 579 |
|
---|
| 580 | %-------------------------------------------------------------------
|
---|
| 581 | function HideFalse_Callback(hObject, eventdata, handles)
|
---|
| 582 | %-------------------------------------------------------------------
|
---|
| 583 | update_plot(handles)
|
---|
| 584 |
|
---|
| 585 | %-------------------------------------------------------------------
|
---|
| 586 | function VecScale_Callback(hObject, eventdata, handles)
|
---|
| 587 | %-------------------------------------------------------------------
|
---|
| 588 | set(handles.FixVec,'Value',1);
|
---|
| 589 | set(handles.FixVec,'BackgroundColor',[1 1 0])
|
---|
| 590 | update_plot(handles)
|
---|
| 591 |
|
---|
| 592 | %-------------------------------------------------------------------
|
---|
| 593 | function FixVec_Callback(hObject, eventdata, handles)
|
---|
| 594 | %-------------------------------------------------------------------
|
---|
| 595 | test=get(handles.FixVec,'Value');
|
---|
| 596 | if test
|
---|
| 597 | set(handles.FixVec,'BackgroundColor',[1 1 0])
|
---|
| 598 | else
|
---|
| 599 | update_plot(handles);
|
---|
| 600 | %set(handles.VecScale,'String',num2str(ScalOut.VecScale,3))
|
---|
| 601 | set(handles.FixVec,'BackgroundColor',[0.7 0.7 0.7])
|
---|
| 602 | end
|
---|
| 603 |
|
---|
| 604 | %-------------------------------------------------------
|
---|
| 605 | % --- Executes on selection change in decimate4 (nb_vec/4).
|
---|
| 606 | %-------------------------------------------------------
|
---|
[295] | 607 | function CheckDecimate4_Callback(hObject, eventdata, handles)
|
---|
[198] | 608 | update_plot(handles)
|
---|
| 609 |
|
---|
| 610 |
|
---|
| 611 | %-------------------------------------------------------
|
---|
| 612 | % --- Executes on selection change in color_code menu
|
---|
| 613 | %-------------------------------------------------------
|
---|
| 614 | function color_code_Callback(hObject, eventdata, handles)
|
---|
| 615 | set_vec_col_bar(handles)
|
---|
| 616 | update_plot(handles);
|
---|
| 617 |
|
---|
| 618 | %-------------------------------------------------------
|
---|
| 619 | % --- Executes on button press in AutoVecColor.
|
---|
| 620 | %-------------------------------------------------------
|
---|
| 621 | function AutoVecColor_Callback(hObject, eventdata, handles)
|
---|
| 622 | test=get(handles.AutoVecColor,'Value');
|
---|
| 623 | if test
|
---|
| 624 | set(handles.AutoVecColor,'BackgroundColor',[1 1 0])
|
---|
| 625 | else
|
---|
| 626 | update_plot(handles);
|
---|
| 627 | %set(handles.VecScale,'String',num2str(ScalOut.VecScale,3))
|
---|
| 628 | set(handles.AutoVecColor,'BackgroundColor',[0.7 0.7 0.7])
|
---|
| 629 | end
|
---|
| 630 | %set_vec_col_bar(handles)
|
---|
| 631 |
|
---|
| 632 | %-------------------------------------------------------
|
---|
| 633 | % --- Executes on selection change in max_vec.
|
---|
| 634 | %-------------------------------------------------------
|
---|
| 635 | function min_vec_Callback(hObject, eventdata, handles)
|
---|
| 636 | max_vec_Callback(hObject, eventdata, handles)
|
---|
| 637 |
|
---|
| 638 | % --- Executes on selection change in max_vec.
|
---|
| 639 | function max_vec_Callback(hObject, eventdata, handles)
|
---|
| 640 | set(handles.AutoVecColor,'Value',1)
|
---|
| 641 | AutoVecColor_Callback(hObject, eventdata, handles)
|
---|
| 642 | min_val=str2num(get(handles.min_vec,'String'));
|
---|
| 643 | max_val=str2num(get(handles.max_vec,'String'));
|
---|
| 644 | slider1=get(handles.slider1,'Value');
|
---|
| 645 | slider2=get(handles.slider2,'Value');
|
---|
| 646 | colcode1=min_val+(max_val-min_val)*slider1;
|
---|
| 647 | colcode2=min_val+(max_val-min_val)*slider2;
|
---|
| 648 | set(handles.colcode1,'String',num2str(colcode1))
|
---|
| 649 | set(handles.colcode2,'String',num2str(colcode2))
|
---|
| 650 | update_plot(handles);
|
---|
| 651 |
|
---|
| 652 | %-------------------------------------------------------------------
|
---|
| 653 | %update the display of color code for vectors
|
---|
| 654 | function set_vec_col_bar(handles)
|
---|
| 655 | %-------------------------------------------------------------------
|
---|
| 656 | %get the image of the color display button 'vec_col_bar' in pixels
|
---|
| 657 | set(handles.vec_col_bar,'Unit','pixel');
|
---|
| 658 | pos_vert=get(handles.vec_col_bar,'Position');
|
---|
| 659 | set(handles.vec_col_bar,'Unit','Normalized');
|
---|
| 660 | width=ceil(pos_vert(3));
|
---|
| 661 | height=ceil(pos_vert(4));
|
---|
| 662 |
|
---|
| 663 | %get slider indications
|
---|
| 664 | list=get(handles.color_code,'String');
|
---|
| 665 | ichoice=get(handles.color_code,'Value');
|
---|
| 666 | colcode.ColorCode=list{ichoice};
|
---|
| 667 | colcode.MinC=str2num(get(handles.min_vec,'String'));
|
---|
| 668 | colcode.MaxC=str2num(get(handles.max_vec,'String'));
|
---|
| 669 | test3color=strcmp(colcode.ColorCode,'rgb') || strcmp(colcode.ColorCode,'bgr');
|
---|
| 670 | if test3color
|
---|
| 671 | colcode.colcode1=str2num(get(handles.colcode1,'String'));
|
---|
| 672 | colcode.colcode2=str2num(get(handles.colcode2,'String'));
|
---|
| 673 | end
|
---|
| 674 | colcode.FixedCbounds=0;
|
---|
| 675 | colcode.FixedCbounds=1;
|
---|
| 676 | vec_C=colcode.MinC+(colcode.MaxC-colcode.MinC)*[0.5:width-0.5]/width;%sample of vec_C values from min to max
|
---|
| 677 | [colorlist,col_vec]=set_col_vec(colcode,vec_C);
|
---|
| 678 | oneheight=ones(1,height);
|
---|
| 679 | A1=colorlist(col_vec,1)*oneheight;
|
---|
| 680 | A2=colorlist(col_vec,2)*oneheight;
|
---|
| 681 | A3=colorlist(col_vec,3)*oneheight;
|
---|
| 682 | A(:,:,1)=A1';
|
---|
| 683 | A(:,:,2)=A2';
|
---|
| 684 | A(:,:,3)=A3';
|
---|
| 685 | set(handles.vec_col_bar,'Cdata',A)
|
---|
| 686 |
|
---|
[295] | 687 | % %------------------------------------------------------------------------
|
---|
| 688 | % function PlotType=update_plot(handles)
|
---|
| 689 | % %------------------------------------------------------------------------
|
---|
| 690 | % haxes= handles.axes3;
|
---|
| 691 | %
|
---|
| 692 | % %ProjField=get(haxes,'UserData');
|
---|
| 693 | % ViewFieldData=get(handles.view_field,'UserData');
|
---|
| 694 | % ProjField=ViewFieldData.axes3;
|
---|
| 695 | % %ProjField=get(haxes,'UserData');
|
---|
| 696 | % PlotParam=read_GUI(handles.view_field);
|
---|
| 697 | % [PlotType,PlotParamOut]= plot_field(ProjField,haxes,PlotParam,1);
|
---|
| 698 | % write_plot_param(handles,PlotParamOut); %update the auto plot parameters
|
---|
[198] | 699 |
|
---|
[295] | 700 | %-------------------------------------------------------------------
|
---|
| 701 | function update_plot(handles)
|
---|
| 702 | %-------------------------------------------------------------------
|
---|
| 703 | Data=get(handles.view_field,'UserData');
|
---|
| 704 | AxeData=Data.axes3;% retrieve the current plotted data
|
---|
[292] | 705 | PlotParam=read_GUI(handles.view_field);
|
---|
[295] | 706 | [PP,PlotParamOut]= plot_field(AxeData,handles.axes3,PlotParam);
|
---|
[198] | 707 | write_plot_param(handles,PlotParamOut); %update the auto plot parameters
|
---|
| 708 |
|
---|
[220] | 709 | %------------------------------------------------------------------------
|
---|
[198] | 710 | % --- Executes on button press in Menu/Export/field in workspace.
|
---|
| 711 | function MenuExportField_Callback(hObject, eventdata, handles)
|
---|
[220] | 712 | %------------------------------------------------------------------------
|
---|
[198] | 713 | global Data_view_field
|
---|
| 714 | % huvmat=findobj(allchild(0),'Name','uvmat');
|
---|
| 715 | Data_view_field=get(handles.view_field,'UserData');
|
---|
| 716 | Data_view_field=Data_view_field.axes3;
|
---|
| 717 | % Data_view_field=UvData.ProjField_2;
|
---|
| 718 | evalin('base','global Data_view_field')%make CurData global in the workspace
|
---|
| 719 | display(['UserData of view_field :'])
|
---|
| 720 | evalin('base','Data_view_field') %display CurData in the workspace
|
---|
| 721 | commandwindow;
|
---|
| 722 |
|
---|
[220] | 723 | %------------------------------------------------------------------------
|
---|
[198] | 724 | % --- Executes on button press in Menu/Export/extract figure.
|
---|
| 725 | function MenuExport_plot_Callback(hObject, eventdata, handles)
|
---|
[220] | 726 | %------------------------------------------------------------------------
|
---|
[198] | 727 | huvmat=get(handles.MenuExport_plot,'parent');
|
---|
| 728 | UvData=get(huvmat,'UserData');
|
---|
| 729 | hfig=figure;
|
---|
| 730 | newaxes=copyobj(handles.axes3,hfig);
|
---|
| 731 | map=colormap(handles.axes3);
|
---|
| 732 | colormap(map);%transmit the current colormap to the zoom fig
|
---|
| 733 | colorbar
|
---|
| 734 |
|
---|
[220] | 735 | %------------------------------------------------------------------------
|
---|
[198] | 736 | function closefcn(hObject, eventdata, handles)
|
---|
[220] | 737 | %------------------------------------------------------------------------
|
---|
[198] | 738 | huvmat=findobj(allchild(0),'Name','uvmat');
|
---|
| 739 | if ~isempty(huvmat)
|
---|
| 740 | hhuvmat=guidata(huvmat);
|
---|
| 741 | list_object_2=get(hhuvmat.list_object_2,'String');
|
---|
[231] | 742 | set(hhuvmat.list_object_2,'Value',1)%select the last value ('...')
|
---|
[198] | 743 | end
|
---|
| 744 | delete(hObject)
|
---|
| 745 |
|
---|