[2] | 1 | %'uvmat': function associated with the GUI 'uvmat.fig' for images and data field visualization
|
---|
| 2 | %------------------------------------------------------------------------
|
---|
| 3 | % function huvmat=uvmat(input)
|
---|
| 4 | %
|
---|
| 5 | %OUTPUT
|
---|
| 6 | % huvmat=current handles of the GUI uvmat.fig
|
---|
[45] | 7 | %%
|
---|
[2] | 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
|
---|
[38] | 15 | % Copyright Joel Sommeria, 2008, LEGI / CNRS-UJF-INPG, joel.sommeria@legi.grenoble-inp.fr.
|
---|
[2] | 16 | %AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
|
---|
| 17 | % This open is part of the toolbox UVMAT.
|
---|
| 18 | %
|
---|
| 19 | % UVMAT 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 | % UVMAT 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 UVMAT/COPYING.txt) for more details.
|
---|
| 28 | %AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
|
---|
| 29 | %
|
---|
| 30 | % Information stored on the interface:
|
---|
| 31 | % 'Strings' of all edit boxes and menus: get(handles.Tag,'String')
|
---|
| 32 | % 'Values' of all menus and toggle buttons: get(handles.Tag,'Value')
|
---|
| 33 | % Matlab structure stored as 'UserData' of the figure uvmat.fig,(can be obtained by right mouse click on the interface).
|
---|
| 34 | % It contains the following fields:
|
---|
| 35 | % - Fixed specifiacation of plotting figures and axes (defined bu uvmat_OpeningFcn)
|
---|
| 36 | % .PosColorbar: [0.8210 0.4710 0.0190 0.4450]; specified position of the colorbar on figures
|
---|
| 37 | % - Information read in the documentation open of a series (activated by RootPath_Callback) :
|
---|
| 38 | % .XmlData, with fields:
|
---|
| 39 | % .Time: matrix of times of the images with index i and j
|
---|
| 40 | % .GeometryCalib: [1x1 struct]
|
---|
| 41 | % - Information defined from the interface:
|
---|
| 42 | % .NewSeries: =1 when the first view of a new field series is displayed, else 0
|
---|
| 43 | % .filename:(char string)
|
---|
| 44 | % .VelType:(char string) type of velocity field selected
|
---|
| 45 | % .VelType_1:(char string) REMPLACER LE CELL ACTUEL
|
---|
| 46 | % .FieldName: (char string) main field selected('image', 'velocity'...)
|
---|
| 47 | % .FieldName_1:(char string) second field selected('image', 'velocity'...)
|
---|
| 48 | % .CName: (char string)name of the scalar used for vector colors
|
---|
| 49 | % .CoordType: (char string) coordinate transform: e.g. 'phys' or 'px'
|
---|
| 50 | % .MouseAction: store the current effect of mouse button (create or edit objects)
|
---|
| 51 | % - Information on projection objects
|
---|
| 52 | % .Object: {[1x1 struct]}
|
---|
| 53 | % .CurrentObjectIndex: index of the projection object .Object currently selected for editing
|
---|
| 54 | % -Information on the current field (Field{i})
|
---|
| 55 | % .Txt : text information to display (e.g. error message)
|
---|
| 56 | % .NbDim: number of dimensions (=0 by default)
|
---|
| 57 | % .NbCoord: number of vector components
|
---|
| 58 | % .CoordType: expresses the type of coordinate ('px' for image, 'sig' for instruments, or 'phys')
|
---|
| 59 | % .dt: time interval for the corresponding image pair
|
---|
| 60 | % .Mesh: estimated typical distance between vectors
|
---|
| 61 | % .ZMax:
|
---|
| 62 | % .ZMin:
|
---|
| 63 | % .X, .Y, .Z: set of vector coordinates
|
---|
| 64 | % .U,.V,.W: corresponding set of vector components
|
---|
| 65 | % .F: corresponding set of warning flags
|
---|
| 66 | % .FF: corresponding set of false flags, =0 for good vectors
|
---|
| 67 | % .C: corresponding values of the scalar used for vector color
|
---|
| 68 | % (.X, .Y, .Z,.U,.V,.W,.F,.FF,.C are matlab vectors of the same length,
|
---|
| 69 | % equal to the number of vectors stored in the input open)
|
---|
| 70 | % .CName: name of the scalar .C
|
---|
| 71 | % .CType: type of the scalar .C, setting how the scalar is obtained (see 'Scalars' below)
|
---|
| 72 | % .A image or scalar
|
---|
| 73 | % .AX: vector of dimension 2 representing the first and last values
|
---|
| 74 | % of the X coordinates for the image or scalar known on a regular grid,
|
---|
| 75 | % or vector of dimension .A for a scaler defined on irregular grid.
|
---|
| 76 | % .AY: same as .AX along the Y direction
|
---|
| 77 | % .AName: name of the scalar, ='image' for an image
|
---|
| 78 |
|
---|
| 79 | % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%% DATA FLOW (for run0_Callback) %%%%%%%%%%%%%%%%%%%%:
|
---|
| 80 | %
|
---|
| 81 | % Main input open second input open(_1) second image (pair animation)
|
---|
| 82 | % read_ncfield.m | |
|
---|
[45] | 83 | % read image.m | |
|
---|
[2] | 84 | % Field{1} Field{2}
|
---|
| 85 | % |
|
---|
| 86 | % coord transform (phys.m) or other user defined fct acting on Field{i} |
|
---|
| 87 | % Field{i}
|
---|
| 88 | % |
|
---|
| 89 | % calc_field.m: calculate scalar or other derived fields (vort, div..).
|
---|
| 90 | %
|
---|
| 91 | % sub_field.m: combine the input Field{i} in a single set of fields (vector + scalar):
|
---|
| 92 | % Field{i=1->3}.X --> UvData.X |
|
---|
| 93 | % |
|
---|
| 94 | % UvData
|
---|
| 95 | % |
|
---|
| 96 | % plot histograms of the whole field
|
---|
| 97 | % proj_field.m: project the set of fields on the current projection objects defined by UvData.Object
|
---|
| 98 | % | |
|
---|
| 99 | % ObjectData
|
---|
| 100 | % |
|
---|
| 101 | % plot_field.m: plot the projected fields and store them as user |
|
---|
| 102 | % data of the plotting axes |
|
---|
| 103 | % |
|
---|
| 104 | % AxeData
|
---|
| 105 | %
|
---|
[15] | 106 | %%%%%%%%%%%%%% SCALARS: %%%%%%%%%%%%??%%%
|
---|
[2] | 107 | % scalars are displayed either as an image or countour plot, either as a color of
|
---|
| 108 | % velocity vectors. The scalar values in the first case is represented by
|
---|
| 109 | % UvData.Field.A, and by UvData.Field.C in the second case. The corresponding set of X
|
---|
| 110 | % and Y coordinates are represented by UvData.Field.AX and UvData.Field.AY, and .X and
|
---|
| 111 | % .Y for C (the same as velocity vectors). If A is a nxxny matrix (scalar
|
---|
| 112 | % on a regtular grid), then .AX andf.AY contains only two elements, represneting the
|
---|
| 113 | % coordinates of the four image corners. The scalar name is represented by
|
---|
| 114 | % the strings .AName and/or .CName.
|
---|
| 115 | % If the scalar exists in an input open (image or scalar stored under its
|
---|
| 116 | % name in a netcdf open), it is directly read at the level of Field{1}or Field{2}.
|
---|
| 117 | % Else only its name AName is recorded in Field{i}, and its field is then calculated
|
---|
| 118 | %by the fuction calc_scal after the coordinate transform or after projection on an edit
|
---|
| 119 |
|
---|
| 120 | % Properties attached to plotting figures (standard Matlab properties):
|
---|
| 121 | % 'CurrentAxes'= gca or get(gcf,'CurrentAxes');
|
---|
| 122 | % 'CurrentPoint'=get(gcf,'CurrentPoint'): figure coordinates of the point over which the mouse is positioned
|
---|
| 123 | % 'CurrentCharacter'=get(gcf,'CurrentCharacter'): last character typed over the figure where the mouse is positioned
|
---|
| 124 | % 'WindowButtonMotionFcn': function permanently called by mouse motion over the figure
|
---|
| 125 | % 'KeyPressFcn': function called by pressing a key on the key board
|
---|
| 126 | % 'WindowButtonDownFcn': function called by pressing the mouse over the figure
|
---|
| 127 | % 'WindowButtonUpFcn': function called by releasing the mouse pressure over the figure
|
---|
| 128 |
|
---|
| 129 | % Properties attached to plotting axes:
|
---|
| 130 | % 'CurrentPoint'=get(gca,'CurrentPoint'); (standard Matlab) same as for the figure, but position in plot coordinates.
|
---|
| 131 | % AxeData:=get(gca,'UserData');
|
---|
| 132 | % AxeData.Drawing = create: create a new edit
|
---|
| 133 | % = deform: modify an existing edit by moving its defining create
|
---|
| 134 | % = off: no current drawing action
|
---|
| 135 | % = translate: translate an existing edit
|
---|
| 136 | % = zoom: isolate a subregion for zoom in=1 if an edit is being currently drawn, 0 else (set to 0 by releasing mouse button)
|
---|
| 137 | % .hset_edit=handle of the set_edit interface (if a projection edit is edited);
|
---|
| 138 | % .CurrentOrigin: Origin of a curently drawn edit
|
---|
| 139 | % .CurrentLine: currently drawn menuline (A REVOIR)
|
---|
| 140 | % .CurrentObject: handle of the currently drawn edit
|
---|
| 141 | % .CurrentRectZoom: current rectangle used for zoom
|
---|
| 142 | % .zoomon : zoom state (a revoir)
|
---|
| 143 | % .X, .Y, .Z: array of coordinates defining the position of the vector: ASSOCIER AU PLAN (OBJET) PLUTOT QU'A L'AXE ?
|
---|
| 144 | % .U, .V, .W: array of components of the vector
|
---|
| 145 | % .C:
|
---|
| 146 | % .F:
|
---|
| 147 | % .FF:
|
---|
| 148 | % .A
|
---|
| 149 |
|
---|
| 150 | % Properties attached to projection objects (create, menuline, menuplane...):
|
---|
| 151 | % 'Tag'='proj_edit': for all projection objects
|
---|
| 152 | % ObjectData.Style=...: style of projection edit:
|
---|
| 153 | % .ProjMode
|
---|
| 154 | % .Coord: defines the position of the edit
|
---|
| 155 | % .XMin,YMin....
|
---|
| 156 | % .XMax,YMax....
|
---|
| 157 | % .DX,DY,DZ
|
---|
| 158 | % .Phi, .Theta, .Psi : Euler angles
|
---|
| 159 | % .X,.Y,.U,.V.... : field data projected on the edit
|
---|
| 160 | % .IndexObj: index in the list of UvData.Object
|
---|
| 161 | %during plotting
|
---|
| 162 | % .plotaxes: handles of the current axes used to plot the result of field projection on the object
|
---|
| 163 | % .plothandle: vector of handle(s) of the object graphic represnetation in all the opened plotting axes
|
---|
| 164 | % To each projection object #iobj, corresponds an axis
|
---|
| 165 | % Object{iobj}.plotaxes and nbobj representation graphs Object{iobj}.plothandles(:) (where nbobj is the
|
---|
| 166 | % nbre of current objects opened in uvmat. Note that Object{iobj}.plothandles(iobj)=[] : an object is not represented in its own projection field;
|
---|
| 167 | %-------------------------------------------------------------------
|
---|
| 168 | %-------------------------------------------------------------------
|
---|
| 169 | % I - MAIN FUNCTION UVMAT (DO NOT MODIFY)
|
---|
| 170 | %-------------------------------------------------------------------
|
---|
| 171 | %-------------------------------------------------------------------
|
---|
| 172 | function varargout = uvmat(varargin)
|
---|
| 173 |
|
---|
| 174 | % Begin initialization code - DO NOT EDIT
|
---|
| 175 | gui_Singleton = 1;
|
---|
| 176 | gui_State = struct('gui_Name', mfilename, ...
|
---|
| 177 | 'gui_Singleton', gui_Singleton, ...
|
---|
| 178 | 'gui_OpeningFcn', @uvmat_OpeningFcn, ...
|
---|
| 179 | 'gui_OutputFcn', @uvmat_OutputFcn, ...
|
---|
| 180 | 'gui_LayoutFcn', [], ...
|
---|
| 181 | 'gui_Callback', []);
|
---|
| 182 | if nargin && ischar(varargin{1})
|
---|
| 183 | gui_State.gui_Callback = str2func(varargin{1});
|
---|
| 184 | end
|
---|
| 185 |
|
---|
| 186 | if nargout
|
---|
| 187 | varargout{1:nargout} = gui_mainfcn(gui_State, varargin{:});
|
---|
| 188 | else
|
---|
| 189 | gui_mainfcn(gui_State, varargin{:});
|
---|
| 190 | end
|
---|
| 191 | % End initialization code - DO NOT EDIT
|
---|
| 192 |
|
---|
| 193 | %-------------------------------------------------------------------
|
---|
| 194 | % --- Executes just before uvmat is made visible.
|
---|
| 195 | function uvmat_OpeningFcn(hObject, eventdata, handles, input )
|
---|
| 196 | %-------------------------------------------------------------------
|
---|
[71] | 197 | global nb_builtin
|
---|
| 198 |
|
---|
[2] | 199 | % Choose default command menuline output for uvmat
|
---|
| 200 | handles.output = hObject;
|
---|
| 201 |
|
---|
| 202 | % Update handles structure
|
---|
| 203 | guidata(hObject, handles);
|
---|
| 204 |
|
---|
| 205 | % set the position of colorbar and ancillary GUIs:
|
---|
| 206 | set(hObject,'Units','Normalized')
|
---|
| 207 | movegui(hObject,'center')
|
---|
| 208 | UvData.PosColorbar=[0.805 0.022 0.019 0.445];
|
---|
| 209 | UvData.SetObjectOrigin=[-0.05 -0.03]; %position for set_object
|
---|
| 210 | UvData.SetObjectSize=[0.3 0.7];
|
---|
| 211 | UvData.CalOrigin=[0.95 -0.03];%position for geometry_calib (TO IMPROVE)
|
---|
| 212 | UvData.CalSize=[0.28 1];
|
---|
| 213 |
|
---|
| 214 | %functions for the mouse and keyboard
|
---|
| 215 | set(handles.histo_u,'NextPlot','replacechildren');
|
---|
| 216 | set(handles.histo_v,'NextPlot','replacechildren');
|
---|
| 217 | set(hObject,'KeyPressFcn',{'keyboard_callback',handles})%set keyboard action function
|
---|
| 218 | set(hObject,'WindowButtonMotionFcn',{'mouse_motion',handles})%set mouse action functio
|
---|
| 219 | set(hObject,'WindowButtonDownFcn',{'mouse_down'})%set mouse click action function
|
---|
| 220 | set(hObject,'WindowButtonUpFcn',{'mouse_up',handles})
|
---|
[67] | 221 | set(hObject,'DeleteFcn',{@closefcn})%
|
---|
[2] | 222 |
|
---|
[39] | 223 | %TRANSFORM menu: loads the information stored in prefdir to initiate the browser and the list of functions
|
---|
| 224 | menu_str={'';'phys';'px';'phys_polar'};
|
---|
| 225 | nb_builtin=numel(menu_str); %number of functions
|
---|
[45] | 226 | path_uvmat=fileparts(which('uvmat'));
|
---|
[39] | 227 | addpath(fullfile(path_uvmat,'transform_field'))
|
---|
| 228 | fct_handle{1,1}=[];
|
---|
[60] | 229 | testexist=zeros(size(menu_str'));%default
|
---|
[39] | 230 | testexist(1)=1;
|
---|
| 231 | for ilist=2:length(menu_str)
|
---|
| 232 | if exist(menu_str{ilist},'file')
|
---|
| 233 | fct_handle{ilist,1}=str2func(menu_str{ilist});
|
---|
| 234 | testexist(ilist)=1;
|
---|
| 235 | else
|
---|
| 236 | testexist(ilist)=0;
|
---|
| 237 | end
|
---|
| 238 | end
|
---|
| 239 | rmpath(fullfile(path_uvmat,'transform_field'))
|
---|
| 240 |
|
---|
[60] | 241 | %refresh projection plane
|
---|
| 242 | UvData.Object{1}.Style='plane';%main plotting plane
|
---|
| 243 | UvData.Object{1}.ProjMode='projection';%main plotting plane
|
---|
| 244 | if ~isfield(UvData.Object{1},'plotaxes')
|
---|
| 245 | UvData.Object{1}.plotaxes=handles.axes3;%default plotting axis
|
---|
[71] | 246 | set(handles.list_object_1,'Value',1);
|
---|
[61] | 247 | set(handles.list_object_1,'String',{'1-PLANE'});
|
---|
[60] | 248 | end
|
---|
| 249 |
|
---|
[2] | 250 | %load the list of previously browsed files in menus Open and Open_1
|
---|
[40] | 251 | dir_perso=prefdir; % path to the directory .matlab for personal data
|
---|
| 252 | profil_perso=fullfile(dir_perso,'uvmat_perso.mat');% personal data file uvmauvmat_perso.mat' in .matlab
|
---|
[2] | 253 | if exist(profil_perso,'file')
|
---|
| 254 | h=load (profil_perso);
|
---|
| 255 | if isfield(h,'MenuFile_1')
|
---|
| 256 | set(handles.MenuFile_1,'Label',h.MenuFile_1);
|
---|
| 257 | set(handles.MenuFile_1_1,'Label',h.MenuFile_1);
|
---|
| 258 | end
|
---|
| 259 | if isfield(h,'MenuFile_1')
|
---|
| 260 | set(handles.MenuFile_2,'Label',h.MenuFile_2);
|
---|
| 261 | set(handles.MenuFile_2_1,'Label',h.MenuFile_2);
|
---|
| 262 | end
|
---|
| 263 | if isfield(h,'MenuFile_1')
|
---|
| 264 | set(handles.MenuFile_3,'Label',h.MenuFile_3);
|
---|
| 265 | set(handles.MenuFile_3_1,'Label',h.MenuFile_3);
|
---|
| 266 | end
|
---|
| 267 | if isfield(h,'MenuFile_1')
|
---|
| 268 | set(handles.MenuFile_4,'Label',h.MenuFile_4);
|
---|
| 269 | set(handles.MenuFile_4_1,'Label',h.MenuFile_4);
|
---|
| 270 | end
|
---|
| 271 | if isfield(h,'MenuFile_1')
|
---|
| 272 | set(handles.MenuFile_5,'Label',h.MenuFile_5);
|
---|
| 273 | set(handles.MenuFile_5_1,'Label',h.MenuFile_5);
|
---|
[39] | 274 | end
|
---|
| 275 | if isfield(h,'transform_fct') && iscell(h.transform_fct)
|
---|
| 276 | for ilist=1:length(h.transform_fct);
|
---|
| 277 | [path,file]=fileparts(h.transform_fct{ilist});
|
---|
| 278 | addpath(path)
|
---|
| 279 | if exist(file,'file')
|
---|
| 280 | h_func=str2func(file);
|
---|
[45] | 281 | testexist=[testexist 1]; %#ok<AGROW>
|
---|
[39] | 282 | else
|
---|
| 283 | h_func=[];
|
---|
[45] | 284 | testexist=[testexist 0]; %#ok<AGROW>
|
---|
[39] | 285 | end
|
---|
[45] | 286 | fct_handle=[fct_handle; {h_func}];%#ok<AGROW> %concatene the list of paths
|
---|
[39] | 287 | rmpath(path)
|
---|
[45] | 288 | menu_str=[menu_str; {file}]; %#ok<AGROW>
|
---|
[39] | 289 | end
|
---|
| 290 | end
|
---|
[2] | 291 | end
|
---|
[45] | 292 | menu_str=menu_str(testexist==1);%=menu_str(testexist~=0)
|
---|
| 293 | fct_handle=fct_handle(testexist==1);
|
---|
[39] | 294 | menu_str=[menu_str;{'more...'}];
|
---|
| 295 | set(handles.transform_fct,'String',menu_str)
|
---|
| 296 | set(handles.transform_fct,'UserData',fct_handle)% store the list of path in UserData of ACTION
|
---|
[2] | 297 |
|
---|
| 298 | %initiates menu of vector colors
|
---|
| 299 | list_menu=calc_field;
|
---|
| 300 | %list_menu=[{'ima_cor'};{'black'};{'white'};list_menu(3:end)];
|
---|
| 301 | set(handles.col_vec,'String',list_menu)
|
---|
| 302 |
|
---|
| 303 | %check the path and date of modification of all functions in uvmat
|
---|
| 304 | path_to_uvmat=which ('uvmat');% check the path detected for source file uvmat
|
---|
| 305 | [errormsg,date_str]=check_functions;%check the path of the functions called by uvmat.m
|
---|
[45] | 306 | date_str=['last modification: ' date_str];
|
---|
[2] | 307 | %case of an input argument for uvmat
|
---|
| 308 | testinputfield=0;
|
---|
| 309 | inputfile=[];
|
---|
| 310 | Field=[];
|
---|
| 311 | if exist('input','var')
|
---|
| 312 | if ~isempty(errormsg)
|
---|
[38] | 313 | msgbox_uvmat('WARNING',errormsg)
|
---|
[2] | 314 | end
|
---|
| 315 | if ishandle(handles.UVMAT_title)
|
---|
| 316 | delete(handles.UVMAT_title)
|
---|
| 317 | end
|
---|
| 318 | if isstruct(input)
|
---|
| 319 | if isfield(input,'InputFile')
|
---|
| 320 | inputfile=input.InputFile;
|
---|
| 321 | end
|
---|
| 322 | Field=input;
|
---|
| 323 | elseif ischar(input)% file name introduced as input
|
---|
| 324 | inputfile=input;
|
---|
[59] | 325 | elseif isnumeric(input)%simple matrix introduced as input
|
---|
[2] | 326 | sizinput=size(input);
|
---|
| 327 | if sizinput(1)<=1 || sizinput(2)<=1
|
---|
[38] | 328 | msgbox_uvmat('ERROR','bad input for uvmat: file name, structure or numerical matrix accepted')
|
---|
[2] | 329 | return
|
---|
| 330 | end
|
---|
[59] | 331 | Field.ListVarName={'A','coord_y','coord_x'};
|
---|
| 332 | Field.VarDimName={{'coord_y','coord_x'},'cord_y','coord_x'};
|
---|
[2] | 333 | Field.A=input;
|
---|
[59] | 334 | Field.coord_x=[0.5 size(input,2)-0.5];
|
---|
| 335 | Field.coord_y=[size(input,1)-0.5 0.5];
|
---|
[2] | 336 | end
|
---|
| 337 | if ~isempty(inputfile)
|
---|
| 338 | display_file_name(hObject, eventdata, handles,inputfile)
|
---|
| 339 | testinputfield=1;
|
---|
| 340 | else
|
---|
| 341 | UvData.TestInputFile=0;
|
---|
| 342 | end
|
---|
| 343 | if ~isempty(Field)
|
---|
| 344 | set(handles.Fields,'Value',1)
|
---|
[39] | 345 | set(handles.Fields,'String',{'get_field...'})
|
---|
[59] | 346 | % set(handles.Fields,'UserData',Field)
|
---|
[2] | 347 | testinputfield=1;
|
---|
| 348 |
|
---|
| 349 | % set the colorbar position on the interface:
|
---|
| 350 | UvData.PosColorbar=[0.805 0.022 0.019 0.445];
|
---|
| 351 | elseif ischar(input)
|
---|
| 352 | scan_i_Callback(handles.scan_i, eventdata, handles);
|
---|
| 353 | end
|
---|
| 354 | else
|
---|
| 355 | if ishandle(handles.UVMAT_title)
|
---|
[34] | 356 | fid=fopen('revision.log');
|
---|
[33] | 357 | if fid~=-1
|
---|
[30] | 358 | a=textscan(fid,'%s%s%s',1,'HeaderLines',1,'Delimiter','|');
|
---|
[45] | 359 | set(handles.UVMAT_title,'String',[{'Copyright Joel Sommeria, 2008, Coriolis/ LEGI / CNRS-UJF-INPG';'GNU General Public License'; path_to_uvmat; ['at revision ' a{1}{1}]};a{3}{1};date_str;errormsg]);
|
---|
[30] | 360 | fclose(fid);
|
---|
| 361 | else
|
---|
[31] | 362 | set(handles.UVMAT_title,'String',[{'Copyright Joel Sommeria, 2008, Coriolis/ LEGI / CNRS-UJF-INPG';'GNU General Public License'; path_to_uvmat;date_str};errormsg]);
|
---|
[30] | 363 | end
|
---|
[2] | 364 | end
|
---|
| 365 | end
|
---|
| 366 | UvData.NewSeries=1;
|
---|
| 367 | set(hObject,'UserData',UvData)
|
---|
| 368 | if testinputfield
|
---|
| 369 | %delete drawn objects
|
---|
| 370 | hother=findobj(handles.axes3,'Tag','proj_object');%find all the proj objects
|
---|
| 371 | for iobj=1:length(hother)
|
---|
| 372 | delete_object(hother(iobj))
|
---|
| 373 | end
|
---|
| 374 | if isempty(inputfile)
|
---|
[59] | 375 | errormsg=refresh_field(handles,[],[],[],[],[],[],{Field});
|
---|
[2] | 376 | set(handles.MenuTools,'Enable','on')
|
---|
| 377 | set(handles.OBJECT_txt,'Visible','on')
|
---|
| 378 | set(handles.edit,'Visible','on')
|
---|
[61] | 379 | set(handles.list_object_1,'Visible','on')
|
---|
[2] | 380 | set(handles.frame_object,'Visible','on')
|
---|
[71] | 381 | if ~isempty(errormsg)
|
---|
| 382 | msgbox_uvmat('ERROR',errormsg)
|
---|
| 383 | end
|
---|
[2] | 384 | else
|
---|
| 385 | update_rootinfo(hObject,eventdata,handles);
|
---|
| 386 | end
|
---|
| 387 | end
|
---|
[40] | 388 | set_vec_col_bar(handles) %update the display of color code for vectors
|
---|
[38] | 389 |
|
---|
[2] | 390 | %-------------------------------------------------------------------
|
---|
| 391 | % --- Outputs from this function are returned to the command menuline.
|
---|
| 392 | function varargout = uvmat_OutputFcn(hObject, eventdata, handles)
|
---|
| 393 | varargout{1} = handles.output;% the only output argument is the handle to the GUI figure
|
---|
| 394 |
|
---|
| 395 | %-------------------------------------------------------------------
|
---|
| 396 | %-------------------------------------------------------------------
|
---|
| 397 | % II - FUNCTIONS FOR INTRODUCING THE INPUT FILES
|
---|
| 398 | % automatically sets the global properties when the rootfile name is introduced
|
---|
| 399 | % then activate the view-field action if selected
|
---|
| 400 | % it is activated either by clicking on the RootPath window or by the
|
---|
| 401 | % browser
|
---|
| 402 | %------------------------------------------------------------------
|
---|
| 403 | %------------------------------------------------------------------
|
---|
| 404 |
|
---|
| 405 | % --- Executes on the menu Open/Browse...
|
---|
| 406 | % search the files, recognize their type according to their name and fill the rootfile input windows
|
---|
| 407 | function MenuBrowse_Callback(hObject, eventdata, handles)
|
---|
| 408 | oldfile=read_file_boxes(handles);
|
---|
| 409 |
|
---|
| 410 | if isempty(oldfile)||isequal(oldfile,'') %loads the previously stored file name and set it as default in the file_input box
|
---|
| 411 | dir_perso=prefdir;
|
---|
| 412 | profil_perso=fullfile(dir_perso,'uvmat_perso.mat');
|
---|
| 413 | if exist(profil_perso,'file')
|
---|
| 414 | h=load (profil_perso);
|
---|
| 415 | if isfield(h,'MenuFile_1')
|
---|
| 416 | oldfile=h.MenuFile_1;
|
---|
| 417 | end
|
---|
| 418 | end
|
---|
| 419 | end
|
---|
| 420 | [FileName, PathName] = uigetfile( ...
|
---|
[73] | 421 | {'*.xml;*.xls;*.civ;*.png;*.jpg;*.tif;*.avi;*.AVI;*.vol;*.nc;*.cmx;*.fig;*.log;*.dat;*.bat;', ' (*.xml,*.xls,*.civ,*.jpg ,*.png, .tif, *.avi,*.vol,*.nc,*.cmx ,*.fig,*.log,*.dat,*.bat)';
|
---|
[2] | 422 | '*.xml', '.xml files '; ...
|
---|
| 423 | '*.xls', '.xls files '; ...
|
---|
| 424 | '*.civ', '.civ files '; ...
|
---|
| 425 | '*.jpg',' jpeg image files'; ...
|
---|
| 426 | '*.png','.png image files'; ...
|
---|
| 427 | '*.tif','.tif image files'; ...
|
---|
| 428 | '*.avi;*.AVI','.avi movie files'; ...
|
---|
[73] | 429 | '*.vol','.volume images (png)'; ...
|
---|
[2] | 430 | '*.nc','.netcdf files'; ...
|
---|
| 431 | '*.cdf','.netcdf files'; ...
|
---|
| 432 | '*.cmx','.cmx text files';...
|
---|
| 433 | '*.cmx2','.cmx2 text files';...
|
---|
| 434 | '*.fig','.fig files (matlab fig)';...
|
---|
| 435 | '*.log','.log text files ';...
|
---|
| 436 | '*.dat','.dat text files ';...
|
---|
[73] | 437 | '*.bat','.bat system command text files';...
|
---|
[2] | 438 | '*.*', 'All Files (*.*)'}, ...
|
---|
| 439 | 'Pick a file',oldfile);
|
---|
| 440 | %global filebase
|
---|
| 441 | fileinput=[PathName FileName];%complete file name
|
---|
| 442 | testblank=findstr(fileinput,' ');%look for blanks
|
---|
| 443 | if ~isempty(testblank)
|
---|
[38] | 444 | msgbox_uvmat('ERROR',['The input file name ' fileinput ' contains blank character : This is not allowed. Please change name'])
|
---|
[2] | 445 | return
|
---|
| 446 | end
|
---|
| 447 | sizf=size(fileinput);
|
---|
| 448 | if (~ischar(fileinput)||~isequal(sizf(1),1)),return;end
|
---|
| 449 |
|
---|
| 450 | % display the selected field and related information
|
---|
| 451 | display_file_name(hObject, eventdata, handles,fileinput)
|
---|
| 452 |
|
---|
| 453 | %update list of recent files in the menubar
|
---|
| 454 | MenuFile_1=fileinput;
|
---|
| 455 | MenuFile_2=get(handles.MenuFile_1,'Label');
|
---|
| 456 | MenuFile_3=get(handles.MenuFile_2,'Label');
|
---|
| 457 | MenuFile_4=get(handles.MenuFile_3,'Label');
|
---|
| 458 | MenuFile_5=get(handles.MenuFile_4,'Label');
|
---|
| 459 | set(handles.MenuFile_1,'Label',MenuFile_1)
|
---|
| 460 | set(handles.MenuFile_2,'Label',MenuFile_2)
|
---|
| 461 | set(handles.MenuFile_3,'Label',MenuFile_3)
|
---|
| 462 | set(handles.MenuFile_4,'Label',MenuFile_4)
|
---|
| 463 | set(handles.MenuFile_5,'Label',MenuFile_5)
|
---|
| 464 | set(handles.MenuFile_1_1,'Label',MenuFile_1)
|
---|
| 465 | set(handles.MenuFile_2_1,'Label',MenuFile_2)
|
---|
| 466 | set(handles.MenuFile_3_1,'Label',MenuFile_3)
|
---|
| 467 | set(handles.MenuFile_4_1,'Label',MenuFile_4)
|
---|
| 468 | set(handles.MenuFile_5_1,'Label',MenuFile_5)
|
---|
| 469 | dir_perso=prefdir;
|
---|
| 470 | profil_perso=fullfile(dir_perso,'uvmat_perso.mat');
|
---|
| 471 | if exist(profil_perso,'file')
|
---|
| 472 | save (profil_perso,'MenuFile_1','MenuFile_2','MenuFile_3','MenuFile_4', 'MenuFile_5','-append'); %store the file names for future opening of uvmat
|
---|
| 473 | else
|
---|
| 474 | txt=ver;
|
---|
| 475 | Release=txt(1).Release;
|
---|
| 476 | relnumb=str2double(Release(3:4));
|
---|
| 477 | if relnumb >= 14
|
---|
| 478 | save (profil_perso,'MenuFile_1','MenuFile_2','MenuFile_3','MenuFile_4', 'MenuFile_5','-V6'); %store the file names for future opening of uvmat
|
---|
| 479 | else
|
---|
| 480 | save (profil_perso,'MenuFile_1','MenuFile_2','MenuFile_3','MenuFile_4', 'MenuFile_5'); %store the file names for future opening of uvmat
|
---|
| 481 | end
|
---|
| 482 | end
|
---|
| 483 |
|
---|
| 484 | % --------------------------------------------------------------------
|
---|
| 485 | function MenuFile_1_Callback(hObject, eventdata, handles)
|
---|
| 486 | fileinput=get(handles.MenuFile_1,'Label');
|
---|
| 487 | display_file_name(hObject, eventdata, handles,fileinput)
|
---|
| 488 |
|
---|
| 489 | % --------------------------------------------------------------------
|
---|
| 490 | function MenuFile_2_Callback(hObject, eventdata, handles)
|
---|
| 491 | fileinput=get(handles.MenuFile_2,'Label');
|
---|
| 492 | display_file_name(hObject, eventdata, handles,fileinput)
|
---|
| 493 |
|
---|
| 494 | % --------------------------------------------------------------------
|
---|
| 495 | function MenuFile_3_Callback(hObject, eventdata, handles)
|
---|
| 496 | fileinput=get(handles.MenuFile_3,'Label');
|
---|
| 497 | display_file_name(hObject, eventdata, handles,fileinput)
|
---|
| 498 |
|
---|
| 499 | % --------------------------------------------------------------------
|
---|
| 500 | function MenuFile_4_Callback(hObject, eventdata, handles)
|
---|
| 501 | fileinput=get(handles.MenuFile_4,'Label');
|
---|
| 502 | display_file_name(hObject, eventdata, handles,fileinput)
|
---|
| 503 |
|
---|
| 504 | % --------------------------------------------------------------------
|
---|
| 505 | function MenuFile_5_Callback(hObject, eventdata, handles)
|
---|
| 506 | fileinput=get(handles.MenuFile_5,'Label');
|
---|
| 507 | display_file_name(hObject, eventdata, handles,fileinput)
|
---|
| 508 |
|
---|
| 509 | %-----------------------------------------------------------------
|
---|
| 510 | % fills the edit boxes RootPath, RootFile,NomType...from an input file name 'fileinput'
|
---|
| 511 | %----------------------------------------------------------------
|
---|
| 512 | function display_file_name(hObject, eventdata, handles,fileinput)
|
---|
[29] | 513 | if ~exist(fileinput,'file')
|
---|
| 514 | msgbox_uvmat('ERROR',['input file ' fileinput ' does not exist'])
|
---|
| 515 | return
|
---|
| 516 | end
|
---|
[2] | 517 | [RootPath,RootFile,i1,i2,str_a,str_b,ext,NomType,SubDir]=name2display(fileinput);
|
---|
[29] | 518 | ext_test=''; %default
|
---|
| 519 | if ~isempty(ext)
|
---|
| 520 | form=imformats(ext(2:end));%test valid Matlab image formats
|
---|
| 521 | if ~isempty(form)
|
---|
| 522 | ext_test='.image';
|
---|
| 523 | imainfo=imfinfo(fileinput);
|
---|
| 524 | if length(imainfo) >1 %case of image with multiple frames
|
---|
| 525 | i1='1'; % set the frame counter to 1 by default
|
---|
| 526 | i2='';
|
---|
| 527 | str_a='';
|
---|
| 528 | str_b='';
|
---|
| 529 | NomType='*'; %indicate a set of indexed frames within a single file
|
---|
| 530 | [RootPath,RootFile]=fileparts(fileinput); %include the indices in the root file
|
---|
| 531 | end
|
---|
| 532 | elseif isequal(lower(ext),'.avi')
|
---|
| 533 | ext_test='.image';
|
---|
[2] | 534 | i1='1'; % set the frame counter to 1 by default
|
---|
| 535 | i2='';
|
---|
| 536 | str_a='';
|
---|
| 537 | str_b='';
|
---|
| 538 | NomType='*'; %indicate a set of indexed frames within a single file
|
---|
| 539 | [RootPath,RootFile]=fileparts(fileinput); %include the indices in the root file
|
---|
[29] | 540 | else
|
---|
| 541 | ext_test=lower(ext);
|
---|
[2] | 542 | end
|
---|
| 543 | end
|
---|
| 544 | switch ext_test
|
---|
[73] | 545 | case {'.civ','.log','.cmx','.cmx2','.txt','.bat'} %display text file
|
---|
[2] | 546 | edit(fileinput)
|
---|
| 547 | case '.fig' %display matlab figure
|
---|
| 548 | hfig=open(fileinput);
|
---|
| 549 | set(hfig,'WindowButtonMotionFcn','mouse_motion')%set mouse action functio
|
---|
| 550 | set(hfig,'WindowButtonUpFcn','mouse_up')%set mouse click action function
|
---|
| 551 | set(hfig,'WindowButtonUpFcn','mouse_down')%set mouse click action function
|
---|
| 552 | case {'.xml','.xls'} % edit xml or Excel files
|
---|
| 553 | editxml(fileinput);
|
---|
| 554 | case {'.avi','.image','.vol','.nc','.cdf'}
|
---|
| 555 | set(handles.RootPath,'String',RootPath);
|
---|
| 556 | if isequal(SubDir,'')
|
---|
| 557 | rootname=fullfile(RootPath,RootFile);
|
---|
| 558 | else
|
---|
| 559 | rootname=fullfile(RootPath,SubDir,RootFile);
|
---|
| 560 | SubDir=['/' SubDir]; %display the separator
|
---|
| 561 | end
|
---|
| 562 | set(handles.SubDir,'String',SubDir);
|
---|
| 563 | set(handles.RootFile,'String',['/' RootFile]); %display the separator
|
---|
| 564 | indices=fileinput(length(rootname)+1:end);
|
---|
| 565 | indices(end-length(ext)+1:end)=[]; %remove extension
|
---|
| 566 | set(handles.FileIndex,'String',indices);
|
---|
| 567 | set(handles.FileIndex,'UserData',NomType);
|
---|
| 568 | set(handles.FileExt,'String',ext);
|
---|
| 569 | % fill file index counters
|
---|
[71] | 570 | set(handles.i1,'String',i1);
|
---|
[2] | 571 | set(handles.i2,'String',i2);
|
---|
| 572 | set(handles.j1,'String',str_a);
|
---|
| 573 | set(handles.j2,'String',str_b);
|
---|
| 574 |
|
---|
| 575 | % synchronise indices of the second input file if it exists
|
---|
| 576 | if get(handles.SubField,'Value')==1% if the subfield button is activated, update the field numbers
|
---|
[71] | 577 | [ff,rr,FileBase_1,ii,FileExt_1,SubDir_1]=read_file_boxes_1(handles);
|
---|
[2] | 578 | NomType_1=get(handles.FileIndex_1,'UserData');
|
---|
[71] | 579 | FileName_1=name_generator(FileBase_1,stra2num(i1),stra2num(i2),FileExt_1,NomType_1,1,stra2num(str_a),stra2num(str_b),SubDir_1);
|
---|
| 580 | if exist(FileName_1,'file')
|
---|
[2] | 581 | FileIndex_1=name_generator('',stra2num(i1),stra2num(i2),'',NomType_1,1,stra2num(str_a),stra2num(str_b),'');
|
---|
| 582 | set(handles.FileIndex_1,'String',FileIndex_1)
|
---|
| 583 | else
|
---|
| 584 | set(handles.SubField,'Value',0)
|
---|
| 585 | SubField_Callback(hObject, eventdata, handles)
|
---|
| 586 | end
|
---|
| 587 | end
|
---|
| 588 |
|
---|
| 589 | %enable other menus
|
---|
| 590 | set(handles.MenuOpen_1,'Enable','on')
|
---|
| 591 | set(handles.MenuFile_1_1,'Enable','on')
|
---|
| 592 | set(handles.MenuFile_2_1,'Enable','on')
|
---|
| 593 | set(handles.MenuFile_3_1,'Enable','on')
|
---|
| 594 | set(handles.MenuFile_4_1,'Enable','on')
|
---|
| 595 | set(handles.MenuFile_5_1,'Enable','on')
|
---|
| 596 | set(handles.MenuExport,'Enable','on')
|
---|
| 597 | set(handles.MenuExportFigure,'Enable','on')
|
---|
| 598 | set(handles.MenuExportMovie,'Enable','on')
|
---|
| 599 | set(handles.MenuTools,'Enable','on')
|
---|
| 600 | set(handles.OBJECT_txt,'Visible','on')
|
---|
| 601 | set(handles.edit,'Visible','on')
|
---|
[61] | 602 | set(handles.list_object_1,'Visible','on')
|
---|
[2] | 603 | set(handles.frame_object,'Visible','on')
|
---|
| 604 | % initiate input file:
|
---|
| 605 | update_rootinfo(hObject,eventdata,handles);
|
---|
| 606 | otherwise
|
---|
| 607 | msgbox_uvmat('ERROR',['invalid input file extension' ext])
|
---|
| 608 | end
|
---|
| 609 |
|
---|
| 610 | %-------------------------------------------------------------------
|
---|
| 611 | function RootPath_Callback(hObject,eventdata,handles)
|
---|
| 612 | update_rootinfo(hObject,eventdata,handles);
|
---|
| 613 |
|
---|
| 614 | %-------------------------------------------------------------------
|
---|
| 615 | %-- called by action in RootFile edit box
|
---|
| 616 | %-------------------------------------------------------------------
|
---|
| 617 | function SubDir_Callback(hObject, eventdata, handles)
|
---|
| 618 | %refresh the menu of input fields
|
---|
| 619 | Fields_Callback(hObject, eventdata, handles);
|
---|
| 620 | % refresh the current field
|
---|
| 621 | run0_Callback(hObject, eventdata, handles);
|
---|
| 622 |
|
---|
| 623 |
|
---|
| 624 | %-------------------------------------------------------------------
|
---|
| 625 | %-- called by action in RootFile edit box
|
---|
| 626 | %-------------------------------------------------------------------
|
---|
| 627 | function RootFile_Callback(hObject, eventdata, handles)
|
---|
| 628 | update_rootinfo(hObject,eventdata,handles)
|
---|
| 629 |
|
---|
[81] | 630 | %-------------------------------------------------------------------
|
---|
| 631 | %-- called by action in FileIndex edit box
|
---|
| 632 | %-------------------------------------------------------------------
|
---|
| 633 | function FileIndex_Callback(hObject, eventdata, handles)
|
---|
| 634 | FileIndices=get(handles.FileIndex,'String');
|
---|
| 635 | if isempty(str2num(FileIndices))
|
---|
| 636 | [pp,ff,str1,str2,str_a,str_b]=name2display(FileIndices);
|
---|
| 637 | else
|
---|
| 638 | str1=FileIndices;
|
---|
| 639 | str2='';
|
---|
| 640 | str_a='';
|
---|
| 641 | str_b='';
|
---|
| 642 | end
|
---|
| 643 | set(handles.i1,'String',str1);
|
---|
| 644 | set(handles.i2,'String',str2);
|
---|
| 645 | set(handles.j1,'String',str_a);
|
---|
| 646 | set(handles.j2,'String',str_b);
|
---|
| 647 | run0_Callback(hObject, eventdata, handles)
|
---|
[2] | 648 |
|
---|
[81] | 649 | %-------------------------------------------------------------------
|
---|
| 650 | %-- called by action in FileIndex_1 edit box
|
---|
| 651 | %-------------------------------------------------------------------
|
---|
| 652 | function FileIndex_1_Callback(hObject, eventdata, handles)
|
---|
| 653 | % FileIndices=get(handles.FileIndex_1,'String');
|
---|
| 654 | % if isempty(str2num(FileIndices))
|
---|
| 655 | % [pp,ff,str1,str2,str_a,str_b]=name2display(FileIndices)
|
---|
| 656 | % else
|
---|
| 657 | % str1=FileIndices;
|
---|
| 658 | % str2='';
|
---|
| 659 | % str_a='';
|
---|
| 660 | % str_b='';
|
---|
| 661 | % end
|
---|
| 662 | % set(handles.i1,'String',str1);
|
---|
| 663 | % set(handles.i2,'String',str2);
|
---|
| 664 | % set(handles.j1,'String',str_a);
|
---|
| 665 | % set(handles.j2,'String',str_b);
|
---|
| 666 | run0_Callback(hObject, eventdata, handles)
|
---|
[65] | 667 |
|
---|
[2] | 668 | %-------------------------------------------------------------------
|
---|
| 669 | % -- update information about a new field series (indices to scan, timing, calibration from an xml file, then refresh current plots
|
---|
| 670 | %-------------------------------------------------------------------
|
---|
| 671 | function update_rootinfo(hObject,eventdata,handles)
|
---|
| 672 |
|
---|
| 673 | set(handles.RootPath,'BackgroundColor',[1 1 0])
|
---|
| 674 | drawnow
|
---|
| 675 | set(handles.Fields,'UserData',[])% reinialize data from uvmat opening
|
---|
[59] | 676 | UvData=get(handles.uvmat,'UserData');%huvmat=handles of the uvmat interface
|
---|
[2] | 677 | UvData.NewSeries=1; %flag for run0: begin a new series
|
---|
| 678 | UvData.TestInputFile=1;
|
---|
[81] | 679 | set(handles.fix_pair,'Value',1) % activate by default the comp_input '-'input window
|
---|
[2] | 680 | %FileIndex_Callback(hObject, eventdata, handles)% update field counters
|
---|
| 681 |
|
---|
| 682 | [FileName,RootPath,FileBase,FileIndices,FileExt,SubDir]=read_file_boxes(handles);
|
---|
| 683 | if ~exist(FileName,'file')
|
---|
| 684 | msgbox_uvmat('ERROR',['input file ' FileName ' not found']);
|
---|
| 685 | return
|
---|
| 686 | end
|
---|
| 687 | nbfield=[];%default
|
---|
| 688 | nburst=[];%default
|
---|
| 689 |
|
---|
| 690 | % read timing and total frame number from the current file (movie files) !! may be overrid by xml file
|
---|
| 691 | XmlData.Time=[];%default
|
---|
| 692 | XmlData.GeometryCalib=[];%default
|
---|
| 693 | TimeUnit=[];%default
|
---|
| 694 | testima=0; %test for image input
|
---|
| 695 | if isequal(lower(FileExt),'.avi') %.avi file
|
---|
| 696 | testima=1;
|
---|
| 697 | info=aviinfo([FileBase FileIndices FileExt]);
|
---|
| 698 | nbfield=info.NumFrames;
|
---|
| 699 | nburst=1;
|
---|
| 700 | set(handles.Dt_txt,'String',['Dt=' num2str(1000/info.FramesPerSecond) 'ms']);%display the elementary time interval in millisec
|
---|
[59] | 701 | XmlData.Time=(0:1/info.FramesPerSecond:(info.NumFrames-1)/info.FramesPerSecond)';
|
---|
[2] | 702 | TimeUnit='s';
|
---|
| 703 | set(handles.npx,'String',num2str(info.Width));%fills nbre of pixels x box
|
---|
| 704 | set(handles.npy,'String',num2str(info.Height));%fills nbre of pixels y box
|
---|
| 705 | hhh=which('mmreader');
|
---|
| 706 | if ~isequal(hhh,'')&& mmreader.isPlatformSupported()% if the function is found (recent version of matlab)
|
---|
| 707 | UvData.MovieObject=mmreader([FileBase FileIndices FileExt]);
|
---|
| 708 | end
|
---|
| 709 | elseif ~isempty(imformats(FileExt(2:end))) || isequal(FileExt,'.vol')%&& isequal(NomType,'*')% multi-frame image
|
---|
| 710 | testima=1;
|
---|
| 711 | if ~isequal(SubDir,'')
|
---|
| 712 | RootFile=get(handles.RootFile,'String');
|
---|
| 713 | imainfo=imfinfo([fullfile(RootPath,SubDir,RootFile) FileIndices FileExt]);
|
---|
| 714 | else
|
---|
| 715 | imainfo=imfinfo([FileBase FileIndices FileExt]);
|
---|
| 716 | end
|
---|
| 717 | if length(imainfo) >1 %case of image with multiple frames
|
---|
| 718 | nbfield=length(imainfo);
|
---|
| 719 | nburst=1;
|
---|
| 720 | end
|
---|
| 721 | if isfield(UvData,'MovieObject')
|
---|
| 722 | UvData=rmfield(UvData,'MovieObject');
|
---|
| 723 | end
|
---|
| 724 | else
|
---|
| 725 | %set(handles.last_i,'String','');%fills last_field box
|
---|
| 726 | set(handles.npx,'String','');%fills nbre of pixels x box
|
---|
| 727 | set(handles.npy,'String','');%fills nbre of pixels y box
|
---|
| 728 | if isfield(UvData,'MovieObject')
|
---|
| 729 | UvData=rmfield(UvData,'MovieObject');
|
---|
| 730 | end
|
---|
| 731 | end
|
---|
| 732 |
|
---|
| 733 | % read parameters (time, geometric calibration..) from a documentation file (.xml advised)
|
---|
| 734 | filexml=[FileBase '.xml'];
|
---|
| 735 | fileciv=[FileBase '.civ'];
|
---|
| 736 | warntext='';%default warning message
|
---|
| 737 | NbSlice=1;%default
|
---|
| 738 |
|
---|
| 739 | if exist(filexml,'file')
|
---|
| 740 | set(handles.view_xml,'Visible','on')
|
---|
| 741 | set(handles.view_xml,'BackgroundColor',[1 1 0])
|
---|
| 742 | set(handles.RootPath,'BackgroundColor',[1 1 1])
|
---|
| 743 | set(handles.view_xml,'String','view .xml')
|
---|
| 744 | drawnow
|
---|
| 745 | [XmlData,warntext]=imadoc2struct(filexml);
|
---|
| 746 | if ~isempty(warntext)
|
---|
| 747 | msgbox_uvmat('WARNING',warntext)
|
---|
| 748 | end
|
---|
| 749 | if isfield(XmlData,'TimeUnit')
|
---|
| 750 | if isfield(XmlData,'TimeUnit')&& ~isempty(XmlData.TimeUnit)
|
---|
| 751 | TimeUnit=XmlData.TimeUnit;
|
---|
| 752 | end
|
---|
| 753 | end
|
---|
| 754 | set(handles.view_xml,'BackgroundColor',[1 1 1])
|
---|
| 755 | drawnow
|
---|
| 756 | elseif exist(fileciv,'file')% if .civ file found
|
---|
| 757 | [error,XmlData.Time,TimeUnit,mode,npx,npy,pxcmx,pxcmy]=read_imatext([FileBase '.civ']);
|
---|
| 758 | GeometryCalib.R=[pxcmx 0 0; 0 pxcmy 0;0 0 0];
|
---|
| 759 | GeometryCalib.Tx=0;
|
---|
| 760 | GeometryCalib.Ty=0;
|
---|
| 761 | GeometryCalib.Tz=1;
|
---|
| 762 | GeometryCalib.dpx=1;
|
---|
| 763 | GeometryCalib.dpy=1;
|
---|
| 764 | GeometryCalib.sx=1;
|
---|
| 765 | GeometryCalib.Cx=0;
|
---|
| 766 | GeometryCalib.Cy=0;
|
---|
| 767 | GeometryCalib.f=1;
|
---|
| 768 | GeometryCalib.kappa1=0;
|
---|
| 769 | GeometryCalib.CoordUnit='cm';
|
---|
| 770 | XmlData.GeometryCalib=GeometryCalib;
|
---|
| 771 | if error==2, warntext=['no file ' FileBase '.civ'];
|
---|
| 772 | elseif error==1, warntext='inconsistent number of fields in the .civ file';
|
---|
| 773 | end
|
---|
| 774 | set(handles.npx,'String',num2str(npx));%fills nbre of pixels x box
|
---|
| 775 | set(handles.npy,'String',num2str(npy));%fills nbre of pixels y box
|
---|
| 776 | set(handles.pxcm,'String',num2str(pxcmx));%fills scale x (pixel/cm) box
|
---|
| 777 | set(handles.pycm,'String',num2str(pxcmy));%fills scale y (pixel/cm) box
|
---|
| 778 | set(handles.pxcm,'Visible','on');%fills scale x (pixel/cm) box
|
---|
| 779 | set(handles.pycm,'Visible','on');%fills scale y (pixel/cm) box
|
---|
| 780 | set(handles.view_xml,'Visible','on')
|
---|
| 781 | set(handles.view_xml,'String','view .civ')
|
---|
| 782 | else
|
---|
| 783 | set(handles.view_xml,'Visible','off')
|
---|
| 784 | end
|
---|
| 785 |
|
---|
| 786 | % store last index in handles.lat_i and .last_j
|
---|
| 787 | if ~isempty(XmlData.Time)
|
---|
| 788 | nbfield=size(XmlData.Time,1);
|
---|
| 789 | nburst=size(XmlData.Time,2);
|
---|
[84] | 790 | %transform .Time to a column vector if it is a line vector the nomenclature uses a single index
|
---|
| 791 | if isequal(nbfield,1) && ~isequal(nburst,1)% .Time is a line vector
|
---|
| 792 | NomType=get(handles.FileIndex,'UserData');
|
---|
| 793 | if numel(NomType)>=2 &&(strcmp(NomType,'_i')||strcmp(NomType(1:2),'%0')||strcmp(NomType(1:2),'_%'))
|
---|
| 794 | XmlData.Time=(XmlData.Time)';
|
---|
| 795 | nbfield=nburst;
|
---|
| 796 | nburst=1;
|
---|
| 797 | end
|
---|
| 798 | end
|
---|
[2] | 799 | end
|
---|
| 800 | last_i_cell=get(handles.last_i,'String');
|
---|
| 801 | if isempty(nbfield)
|
---|
| 802 | last_i_cell{1}='';
|
---|
| 803 | else
|
---|
| 804 | last_i_cell{1}=num2str(nbfield);
|
---|
| 805 | end
|
---|
| 806 | set(handles.last_i,'String',last_i_cell)
|
---|
| 807 | last_j_cell=get(handles.last_j,'String');
|
---|
| 808 | if isempty(nburst)
|
---|
| 809 | last_j_cell{1}='';
|
---|
| 810 | else
|
---|
| 811 | last_j_cell{1}=num2str(nburst);
|
---|
| 812 | end
|
---|
| 813 | set(handles.last_j,'String',last_j_cell);
|
---|
| 814 |
|
---|
| 815 | % store geometric calibration in UvData
|
---|
| 816 | if isfield(XmlData,'GeometryCalib')
|
---|
| 817 | GeometryCalib=XmlData.GeometryCalib;
|
---|
| 818 | if isempty(GeometryCalib)
|
---|
| 819 | set(handles.pxcm,'String','')
|
---|
| 820 | set(handles.pycm,'String','')
|
---|
[39] | 821 | set(handles.transform_fct,'Value',1); % no transform by default
|
---|
[2] | 822 | else
|
---|
| 823 | if (isfield(GeometryCalib,'R')& ~isequal(GeometryCalib.R(2,1),0) & ~isequal(GeometryCalib.R(1,2),0)) |...
|
---|
| 824 | (isfield(GeometryCalib,'kappa1')& ~isequal(GeometryCalib.kappa1,0))
|
---|
| 825 | set(handles.pxcm,'String','var')
|
---|
| 826 | set(handles.pycm,'String','var')
|
---|
| 827 | else
|
---|
| 828 | pixcmx=GeometryCalib.f*GeometryCalib.R(1,1)*GeometryCalib.sx/(GeometryCalib.Tz*GeometryCalib.dpx);
|
---|
| 829 | pixcmy=GeometryCalib.f*GeometryCalib.R(2,2)/(GeometryCalib.Tz*GeometryCalib.dpy);
|
---|
| 830 | set(handles.pxcm,'String',num2str(pixcmx))
|
---|
| 831 | set(handles.pycm,'String',num2str(pixcmy))
|
---|
| 832 | end
|
---|
[84] | 833 | if ~get(handles.FixedLimits,'Value')
|
---|
| 834 | set(handles.transform_fct,'Value',2); % phys transform by default if fixedLimits is off
|
---|
| 835 | end
|
---|
[2] | 836 | if isfield(GeometryCalib,'SliceCoord')
|
---|
| 837 | siz=size(GeometryCalib.SliceCoord);
|
---|
| 838 | if siz(1)>1
|
---|
| 839 | NbSlice=siz(1);
|
---|
| 840 | set(handles.slices,'Visible','on')
|
---|
| 841 | set(handles.slices,'Value',1)
|
---|
| 842 | end
|
---|
[73] | 843 | if isfield(GeometryCalib,'NbSlice') && isequal(GeometryCalib.NbSlice,'volume')
|
---|
[60] | 844 | set(handles.nb_slice,'String','volume')
|
---|
| 845 | else
|
---|
| 846 | set(handles.nb_slice,'String',num2str(NbSlice))
|
---|
| 847 | end
|
---|
[2] | 848 | slices_Callback(hObject, eventdata, handles)
|
---|
| 849 | % Coord=UvData.XmlData.GeometryCalib.SliceCoord;
|
---|
| 850 | % ZIndex=num_i1-NbSlice*(floor((num_i1-1)/NbSlice));
|
---|
| 851 | end
|
---|
[60] | 852 |
|
---|
| 853 |
|
---|
[2] | 854 | end
|
---|
| 855 | end
|
---|
| 856 |
|
---|
| 857 | %update the data attached to the uvmat interface
|
---|
[60] | 858 | % set(handles.nb_slice,'String',num2str(NbSlice))
|
---|
[2] | 859 | if ~isempty(TimeUnit)
|
---|
| 860 | set(handles.time_txt,'String',['time (' TimeUnit ')'])
|
---|
| 861 | end
|
---|
| 862 | %set(handles.DtUnit,'String',['10^(-3)' TimeUnit])
|
---|
| 863 | UvData.TimeUnit=TimeUnit;
|
---|
| 864 | UvData.XmlData=XmlData;
|
---|
| 865 | UvData.NewSeries=1;
|
---|
[59] | 866 | set(handles.uvmat,'UserData',UvData)
|
---|
[2] | 867 |
|
---|
| 868 | %display warning message
|
---|
| 869 | if ~isequal(warntext,'')
|
---|
| 870 | msgbox_uvmat('WARNING',warntext);
|
---|
| 871 | end
|
---|
| 872 |
|
---|
| 873 | % set default options in menu 'Fields'
|
---|
| 874 | if testima
|
---|
| 875 | set(handles.Fields,'Value',1) % set menu to 'image'
|
---|
| 876 | set(handles.Fields,'String',{'image';'get_field...';'velocity';'vort';'div';'more...'})
|
---|
[45] | 877 | elseif isequal(FileExt,'.nc')||isequal(FileExt,'.cdf')
|
---|
[56] | 878 | Data=nc2struct(FileName,'ListGlobalAttribute','absolut_time_T0','civ');
|
---|
[2] | 879 | col_vec=get(handles.col_vec,'String');
|
---|
[59] | 880 | if ~isempty(Data.absolut_time_T0)&& ~isequal(Data.civ,0)
|
---|
[2] | 881 | set(handles.Fields,'String',{'image';'get_field...';'velocity';'vort';'div';'more...'})
|
---|
| 882 | set(handles.Fields,'Value',3) % set menu to 'velocity'
|
---|
| 883 | col_vec{1}='ima_cor';
|
---|
[45] | 884 | else %general netcdf file (not civx)
|
---|
[2] | 885 | set(handles.Fields,'Value',1) % set menu to 'get_field...
|
---|
| 886 | set(handles.Fields,'String',{'get_field...'})
|
---|
| 887 | col_vec{1}='get_field...';
|
---|
| 888 | end
|
---|
| 889 | set(handles.col_vec,'String',col_vec)
|
---|
| 890 | else
|
---|
| 891 | msgbox_uvmat('ERROR',['invalid input file extension ' FileExt])
|
---|
| 892 | return
|
---|
| 893 | end
|
---|
| 894 |
|
---|
| 895 | % set index navigation options and refresh plots
|
---|
| 896 | set(handles.RootPath,'BackgroundColor',[1 1 1])
|
---|
| 897 | drawnow
|
---|
| 898 | set_scan_options(hObject, eventdata, handles)
|
---|
| 899 |
|
---|
| 900 |
|
---|
| 901 | %-------------------------------------------------------------------
|
---|
| 902 | %-- set index navigation options for new series input and refresh plot
|
---|
| 903 | %-------------------------------------------------------------------
|
---|
| 904 | function set_scan_options(hObject, eventdata, handles)
|
---|
| 905 |
|
---|
[81] | 906 | % set the corresponding index navigation options
|
---|
| 907 | NomType=get(handles.FileIndex,'UserData');
|
---|
[2] | 908 | NomType_1=get(handles.FileIndex_1,'UserData');
|
---|
[81] | 909 | last_i_str=get(handles.last_i,'String');
|
---|
| 910 | nbfield=str2num(last_i_str{1});
|
---|
| 911 | if numel(last_i_str)==2
|
---|
| 912 | nbfield=min(nbfield,str2num(last_i_str{2}));
|
---|
| 913 | end
|
---|
[2] | 914 | state_j='off'; %default
|
---|
[81] | 915 | scan_option='i';%default
|
---|
[2] | 916 | switch NomType
|
---|
| 917 | case {'_i_j','_i_j1-j2','_i1-i2_j','#_ab'},% two navigation indices
|
---|
| 918 | state_j='on';
|
---|
[81] | 919 | if isequal(nbfield,1)
|
---|
| 920 | scan_option='j';
|
---|
[2] | 921 | end
|
---|
| 922 | end
|
---|
| 923 | if ~isempty(NomType_1)
|
---|
| 924 | switch NomType_1
|
---|
| 925 | case {'_i_j','_i_j1-j2','_i1-i2_j','#_ab'},% two navigation indices
|
---|
| 926 | state_j='on';
|
---|
[81] | 927 | if isequal(nbfield,1)
|
---|
| 928 | scan_option='j';
|
---|
| 929 | end
|
---|
[2] | 930 | end
|
---|
| 931 | end
|
---|
| 932 | if isequal(scan_option,'i')
|
---|
| 933 | set(handles.scan_i,'Value',1)
|
---|
| 934 | scan_i_Callback(hObject, eventdata, handles);
|
---|
| 935 | else
|
---|
| 936 | set(handles.scan_j,'Value',1)
|
---|
| 937 | scan_j_Callback(hObject, eventdata, handles);
|
---|
| 938 | end
|
---|
| 939 | set(handles.scan_j,'Visible',state_j)
|
---|
| 940 | set(handles.j1,'Visible',state_j)
|
---|
| 941 | set(handles.j2,'Visible',state_j)
|
---|
| 942 | set(handles.last_j,'Visible',state_j);
|
---|
| 943 | set(handles.frame_j,'Visible',state_j);
|
---|
| 944 | set(handles.j_text,'Visible',state_j);
|
---|
| 945 |
|
---|
| 946 | % view the field
|
---|
| 947 | run0_Callback(hObject, eventdata, handles); %view field
|
---|
| 948 | mask_test=get(handles.mask_test,'value');
|
---|
| 949 | if mask_test
|
---|
| 950 | MaskData=get(handles.mask_test,'UserData');
|
---|
| 951 | if isfield(MaskData,'maskhandle') && ishandle(MaskData.maskhandle)
|
---|
| 952 | delete(MaskData.maskhandle) %delete old mask
|
---|
| 953 | end
|
---|
| 954 | mask_test_Callback(hObject, eventdata, handles)
|
---|
| 955 | end
|
---|
[59] | 956 |
|
---|
[2] | 957 | %-------------------------------------------------------------------
|
---|
| 958 | function MenuBrowse_1_Callback(hObject, eventdata, handles)
|
---|
| 959 | %-------------------------------------------------------------------
|
---|
[61] | 960 | % huvmat=get(handles.run0,'parent');
|
---|
| 961 | UvData=get(handles.uvmat,'UserData');
|
---|
[2] | 962 |
|
---|
| 963 | RootPath=get(handles.RootPath,'String');
|
---|
| 964 | [FileName, PathName, filterindex] = uigetfile( ...
|
---|
| 965 | {'*.xml;*.xls;*.civ;*.jpg;*.png;*.avi;*.AVI;*.nc;*.cmx;*.fig;*.log;*.dat', ' (*.xml,*.xls,*.civ, *.jpg,*.png, *.avi,*.nc,*.cmx ,*.fig,*.log,*.dat)';
|
---|
| 966 | '*.xml', '.xml files '; ...
|
---|
| 967 | '*.xls', '.xls files '; ...
|
---|
| 968 | '*.civ', '.civ files '; ...
|
---|
| 969 | '*.jpg','.jpg image files'; ...
|
---|
| 970 | '*.png','.png image files'; ...
|
---|
| 971 | '*.avi;*.AVI','.avi movie files'; ...
|
---|
| 972 | '*.nc','.netcdf files'; ...
|
---|
| 973 | '*.cdf','.netcdf files'; ...
|
---|
| 974 | '*.cmx','.cmx text files';...
|
---|
| 975 | '*.cmx2','.cmx2 text files';...
|
---|
| 976 | '*.fig','.fig files (matlab fig)';...
|
---|
| 977 | '*.log','.log text files ';...
|
---|
| 978 | '*.dat','.dat text files ';...
|
---|
| 979 | '*.*', 'All Files (*.*)'}, ...
|
---|
| 980 | 'Pick a file',RootPath);
|
---|
| 981 | fileinput_1=[PathName FileName];%complete file name
|
---|
| 982 | testblank=findstr(fileinput_1,' ');%look for blanks
|
---|
| 983 | if ~isempty(testblank)
|
---|
[38] | 984 | msgbox_uvmat('ERROR',['The input file name ' fileinput_1 ' contains blank character : This is not allowed. Please change name'])
|
---|
[2] | 985 | return
|
---|
| 986 | end
|
---|
| 987 | sizf=size(fileinput_1);
|
---|
| 988 | if (~ischar(fileinput_1)|~isequal(sizf(1),1)),return;end
|
---|
| 989 |
|
---|
| 990 | % refresh the current displayed field
|
---|
| 991 | display_file_name_1(hObject,eventdata,handles,fileinput_1)
|
---|
| 992 |
|
---|
| 993 | %update list of recent files in the menubar
|
---|
| 994 | MenuFile_1=fileinput_1;
|
---|
| 995 | MenuFile_2=get(handles.MenuFile_1,'Label');
|
---|
| 996 | MenuFile_3=get(handles.MenuFile_2,'Label');
|
---|
| 997 | MenuFile_4=get(handles.MenuFile_3,'Label');
|
---|
| 998 | MenuFile_5=get(handles.MenuFile_4,'Label');
|
---|
| 999 | set(handles.MenuFile_1,'Label',MenuFile_1)
|
---|
| 1000 | set(handles.MenuFile_2,'Label',MenuFile_2)
|
---|
| 1001 | set(handles.MenuFile_3,'Label',MenuFile_3)
|
---|
| 1002 | set(handles.MenuFile_4,'Label',MenuFile_4)
|
---|
| 1003 | set(handles.MenuFile_5,'Label',MenuFile_5)
|
---|
| 1004 | set(handles.MenuFile_1_1,'Label',MenuFile_1)
|
---|
| 1005 | set(handles.MenuFile_2_1,'Label',MenuFile_2)
|
---|
| 1006 | set(handles.MenuFile_3_1,'Label',MenuFile_3)
|
---|
| 1007 | set(handles.MenuFile_4_1,'Label',MenuFile_4)
|
---|
| 1008 | set(handles.MenuFile_5_1,'Label',MenuFile_5)
|
---|
| 1009 | dir_perso=prefdir;
|
---|
| 1010 | profil_perso=fullfile(dir_perso,'uvmat_perso.mat');
|
---|
| 1011 | if exist(profil_perso,'file')
|
---|
| 1012 | save (profil_perso,'MenuFile_1','MenuFile_2','MenuFile_3','MenuFile_4', 'MenuFile_5','-append'); %store the file names for future opening of uvmat
|
---|
| 1013 | else
|
---|
| 1014 | txt=ver;
|
---|
| 1015 | Release=txt(1).Release;
|
---|
| 1016 | relnumb=str2num(Release(3:4));
|
---|
| 1017 | if relnumb >= 14
|
---|
| 1018 | save (profil_perso,'MenuFile_1','MenuFile_2','MenuFile_3','MenuFile_4', 'MenuFile_5','-V6'); %store the file names for future opening of uvmat
|
---|
| 1019 | else
|
---|
| 1020 | save (profil_perso,'MenuFile_1','MenuFile_2','MenuFile_3','MenuFile_4', 'MenuFile_5'); %store the file names for future opening of uvmat
|
---|
| 1021 | end
|
---|
| 1022 | end
|
---|
| 1023 |
|
---|
| 1024 | % --------------------------------------------------------------------
|
---|
| 1025 | function MenuFile_1_1_Callback(hObject, eventdata, handles)
|
---|
| 1026 | fileinput_1=get(handles.MenuFile_1_1,'Label');
|
---|
| 1027 | display_file_name_1(hObject,eventdata,handles,fileinput_1)
|
---|
| 1028 |
|
---|
| 1029 | % --------------------------------------------------------------------
|
---|
| 1030 | function MenuFile_2_1_Callback(hObject, eventdata, handles)
|
---|
| 1031 | fileinput_1=get(handles.MenuFile_2_1,'Label');
|
---|
| 1032 | display_file_name_1(hObject,eventdata,handles,fileinput_1)
|
---|
| 1033 |
|
---|
| 1034 | % --------------------------------------------------------------------
|
---|
| 1035 | function MenuFile_3_1_Callback(hObject, eventdata, handles)
|
---|
| 1036 | fileinput_1=get(handles.MenuFile_3_1,'Label');
|
---|
| 1037 | display_file_name_1(hObject,eventdata,handles,fileinput_1)
|
---|
| 1038 |
|
---|
| 1039 | % --------------------------------------------------------------------
|
---|
| 1040 | function MenuFile_4_1_Callback(hObject, eventdata, handles)
|
---|
| 1041 | fileinput_1=get(handles.MenuFile_4_1,'Label');
|
---|
| 1042 | display_file_name_1(hObject,eventdata,handles,fileinput_1)
|
---|
| 1043 |
|
---|
| 1044 | % --------------------------------------------------------------------
|
---|
| 1045 | function MenuFile_5_1_Callback(hObject, eventdata, handles)
|
---|
| 1046 | fileinput_1=get(handles.MenuFile_5_1,'Label');
|
---|
| 1047 | display_file_name_1(hObject,eventdata,handles,fileinput_1)
|
---|
| 1048 |
|
---|
| 1049 | %-----------------------------------------------------------------
|
---|
| 1050 | % fills the edit boxes RootPath, RootFile,NomType...from an input file name 'fileinput'
|
---|
| 1051 | %----------------------------------------------------------------
|
---|
| 1052 | function display_file_name_1(hObject,eventdata,handles,fileinput_1)
|
---|
| 1053 |
|
---|
| 1054 | %[path,name,ext]=fileparts(fileinput_1);
|
---|
| 1055 | [RootPath_1,RootFile_1,field_count,str2,str_a,str_b,FileExt_1,NomType_1,SubDir_1]=name2display(fileinput_1);
|
---|
| 1056 | nbfield_1=1; %default
|
---|
| 1057 | ext_test=FileExt_1;%default
|
---|
| 1058 | form=imformats(FileExt_1(2:end));
|
---|
| 1059 | if ~isempty(form) % if the extension corresponds to an image format recognized by Matlab
|
---|
| 1060 | imainfo=imfinfo(fileinput_1);
|
---|
| 1061 | nbfield_1=length(imainfo);
|
---|
| 1062 | ext_test='.image';
|
---|
| 1063 | elseif isequal(lower(FileExt_1),'.avi')
|
---|
| 1064 | info=aviinfo(fileinput_1);
|
---|
| 1065 | nbfield_1=info.NumFrames;
|
---|
| 1066 | ext_test='.image';
|
---|
| 1067 | end
|
---|
| 1068 |
|
---|
| 1069 | %open directly fig or text files
|
---|
| 1070 | switch ext_test
|
---|
| 1071 | case {'.civ','.log','.cmx','.cmx2','.txt'} %display text file
|
---|
| 1072 | edit(fileinput)
|
---|
| 1073 | return
|
---|
| 1074 | case '.fig' %display matlab figure
|
---|
| 1075 | hfig=open(fileinput);
|
---|
| 1076 | set(hfig,'WindowButtonMotionFcn','mouse_motion')%set mouse action functio
|
---|
| 1077 | set(hfig,'WindowButtonUpFcn','mouse_up')%set mouse click action function
|
---|
| 1078 | set(hfig,'WindowButtonUpFcn','mouse_down')%set mouse click action function
|
---|
| 1079 | return
|
---|
| 1080 | case {'.xml','.xls'} % edit xml or Excel files
|
---|
| 1081 | heditxml=editxml(fileinput);
|
---|
| 1082 | return
|
---|
| 1083 | case {'.image','.nc','.cdf'}
|
---|
| 1084 | % set(handles.FileIndex,'UserData',NomType_1);
|
---|
| 1085 | otherwise
|
---|
[38] | 1086 | msgbox_uvmat(['invalid input file extension ' FileExt_1 ' for uvmat'],'ERROR')
|
---|
[2] | 1087 | return
|
---|
| 1088 | end
|
---|
| 1089 |
|
---|
| 1090 | % test for image series in a single file and synchronise file indices of the two series
|
---|
| 1091 | if nbfield_1 >1 %case of image with multiple frames
|
---|
| 1092 | if nbfield_1 < num_i1
|
---|
[38] | 1093 | msgbox_uvmat('ERROR','current frame index beyond the input movie length')
|
---|
[2] | 1094 | return
|
---|
| 1095 | else
|
---|
| 1096 | NomType_1='*'; %indicate a set of indexed frames within a single file
|
---|
| 1097 | filename_new=fileinput_1;
|
---|
| 1098 | end
|
---|
| 1099 | else % cases of data files
|
---|
| 1100 | RootPath=get(handles.RootPath,'String');
|
---|
| 1101 | RootFile=get(handles.RootFile,'String');
|
---|
| 1102 | FileBase=fullfile(RootPath,RootFile);
|
---|
| 1103 | FileBase_1=fullfile(RootPath_1,RootFile_1);
|
---|
| 1104 | if isequal(FileBase,FileBase_1)
|
---|
| 1105 | filename_new=fileinput_1;
|
---|
| 1106 | else
|
---|
| 1107 | num_i1=stra2num(get(handles.i1,'String'));%get the current file indices from counters
|
---|
| 1108 | num_j1=stra2num(get(handles.j1,'String'));
|
---|
| 1109 | num_i2=stra2num(get(handles.i2,'String'));
|
---|
| 1110 | num_j2=stra2num(get(handles.j2,'String'));
|
---|
| 1111 | [filename_new,idetect]=...
|
---|
| 1112 | name_generator(FileBase_1,num_i1,num_j1,FileExt_1,NomType_1,1,num_i2,num_j2,SubDir_1);%create name with indices synchronised with the first file
|
---|
| 1113 | indices=''; %default
|
---|
| 1114 | if ~idetect
|
---|
[38] | 1115 | msgbox_uvmat('ERROR','second input file with indices corresponding to the first one does not exist')
|
---|
[2] | 1116 | return
|
---|
| 1117 | end
|
---|
| 1118 | end
|
---|
| 1119 | end
|
---|
[81] | 1120 | set(handles.FileIndex_1,'UserData',NomType_1);
|
---|
[2] | 1121 |
|
---|
| 1122 | % make visible and fill the second raw of edit boxes
|
---|
| 1123 | set(handles.RootPath_1,'Visible','on')
|
---|
| 1124 | set(handles.RootFile_1,'Visible','on')
|
---|
| 1125 | set(handles.SubDir_1,'Visible','on');
|
---|
| 1126 | set(handles.FileIndex_1,'Visible','on');
|
---|
| 1127 | set(handles.FileExt_1,'Visible','on');
|
---|
| 1128 | [FileName,RootPath,FileBase,FileIndices,FileExt,SubDir]=read_file_boxes(handles);
|
---|
| 1129 | if isequal(FileBase,FileBase_1)
|
---|
| 1130 | set(handles.RootPath_1,'String','"')
|
---|
| 1131 | set(handles.RootFile_1,'String','"');
|
---|
| 1132 | else
|
---|
| 1133 | set(handles.RootPath_1,'String',RootPath_1)
|
---|
| 1134 | set(handles.RootFile_1,'String',['/' RootFile_1]);
|
---|
| 1135 | end
|
---|
| 1136 | if isequal(SubDir_1,'')
|
---|
| 1137 | set(handles.SubDir_1,'String','');
|
---|
| 1138 | FileBaseSub_1=FileBase_1;
|
---|
| 1139 | else
|
---|
| 1140 | set(handles.SubDir_1,'String',['/' SubDir_1]);
|
---|
| 1141 | FileBaseSub_1=fullfile(FileBase_1,SubDir_1);
|
---|
| 1142 | end
|
---|
| 1143 | indices=filename_new(length(FileBaseSub_1)+1:end);
|
---|
| 1144 | indices(end-length(FileExt_1)+1:end)=[]; %remove extension
|
---|
| 1145 | set(handles.FileIndex_1,'String',indices)
|
---|
| 1146 | set(handles.FileIndex_1,'UserData',NomType_1)
|
---|
| 1147 | set(handles.FileExt_1,'String',FileExt_1);
|
---|
| 1148 |
|
---|
| 1149 | % default choice of fields
|
---|
| 1150 | if isequal(ext_test,'.image')
|
---|
| 1151 | set(handles.Fields_1,'String',{'';'image';'get_field...';'velocity';'vort';'div';'more...'})
|
---|
| 1152 | set(handles.Fields_1,'Value',2) % set menu to 'image'
|
---|
| 1153 | elseif isequal(FileExt_1,'.nc')|isequal(FileExt_1,'.cdf')
|
---|
| 1154 | Data=nc2struct(fileinput_1,[]);
|
---|
| 1155 | if isfield(Data,'absolut_time_T0')
|
---|
| 1156 | set(handles.Fields_1,'String',{'';'image';'get_field...';'velocity';'vort';'div';'more...'})
|
---|
| 1157 | set(handles.Fields_1,'Value',4) % set menu to 'velocity'
|
---|
| 1158 | else
|
---|
| 1159 | set(handles.Fields_1,'Value',2) % set menu to 'get_field...'
|
---|
| 1160 | set(handles.Fields_1,'String',{'';'get_field...'});
|
---|
| 1161 | end
|
---|
| 1162 | end
|
---|
| 1163 | set(handles.SubField,'Visible','on')
|
---|
| 1164 | set(handles.SubField,'Value',1)
|
---|
| 1165 | RootPath_1_Callback(hObject,eventdata,handles);
|
---|
| 1166 |
|
---|
| 1167 |
|
---|
| 1168 | %-----------------------------------------------------
|
---|
| 1169 | function RootPath_1_Callback(hObject,eventdata,handles)
|
---|
| 1170 | update_rootinfo_1(hObject,eventdata,handles)
|
---|
| 1171 |
|
---|
| 1172 | %-------------------------------------------------------------------
|
---|
| 1173 | function RootFile_1_Callback(hObject, eventdata, handles)
|
---|
| 1174 | update_rootinfo_1(hObject,eventdata,handles)
|
---|
| 1175 | %-------------------------------------------------------------------
|
---|
| 1176 |
|
---|
| 1177 | %-------------------------------------------------------------------
|
---|
| 1178 | function update_rootinfo_1(hObject,eventdata,handles) %A REVOIR
|
---|
| 1179 |
|
---|
| 1180 | set(handles.RootPath_1,'BackgroundColor',[1 1 0])% indicate active program by yellow color
|
---|
| 1181 | drawnow
|
---|
[61] | 1182 | %huvmat=get(handles.RootPath,'parent');
|
---|
| 1183 | UvData=get(handles.uvmat,'UserData');%huvmat=handles of the uvmat interface
|
---|
[2] | 1184 | UvData.NewSeries=1; %flag for run0: begin a new series
|
---|
| 1185 |
|
---|
| 1186 | [FileName,RootPath,FileBase,FileIndices,FileExt]=read_file_boxes_1(handles);
|
---|
| 1187 | if ~exist(FileName,'file')
|
---|
| 1188 | msgbox_uvmat('ERROR',['input file ' FileName ' not found']);
|
---|
| 1189 | end
|
---|
| 1190 | nbfield_1=[];%default
|
---|
| 1191 | nburst_1=[];%default
|
---|
| 1192 | XmlData.Time=[];
|
---|
| 1193 | XmlData.GeometryCalib=[];%default
|
---|
| 1194 | TimeUnit=[];
|
---|
| 1195 | if isfield(UvData,'TimeUnit')
|
---|
| 1196 | TimeUnit=UvData.TimeUnit;
|
---|
| 1197 | end
|
---|
| 1198 | TimeUnit_1=[];
|
---|
[71] | 1199 | % testima=0; %test for image input
|
---|
[2] | 1200 | if isequal(lower(FileExt),'.avi') %.avi file
|
---|
[71] | 1201 | % testima=1;
|
---|
[2] | 1202 | info=aviinfo([FileBase FileIndices FileExt]);
|
---|
| 1203 | nbfield_1=info.NumFrames;
|
---|
| 1204 | nburst_1=1;
|
---|
| 1205 | %set(handles.last_i,'String',num2str(info.NumFrames));%fills last_field box
|
---|
| 1206 | set(handles.Dt_txt,'String',['Dt=' num2str(1000/info.FramesPerSecond) 'ms']);%display the elementary time interval in millisec
|
---|
| 1207 | % set(handles.dt,'UserData',info.FramesPerSecond);
|
---|
| 1208 | time=[0:1/info.FramesPerSecond:(info.NumFrames-1)/info.FramesPerSecond]';
|
---|
| 1209 | npx=get(handles.npx,'String');
|
---|
| 1210 | npy=get(handles.npy,'String');
|
---|
| 1211 | if isequal(npx,'') || isequal(npy,'')
|
---|
| 1212 | set(handles.npx,'String',num2str(info.Width));%fills nbre of pixels x box
|
---|
| 1213 | set(handles.npy,'String',num2str(info.Height));%fills nbre of pixels y box
|
---|
| 1214 | end
|
---|
| 1215 | elseif ~isempty(imformats(FileExt(2:end))) %&& isequal(NomType,'*')% multi-frame image
|
---|
| 1216 | testima=1;
|
---|
| 1217 | imainfo=imfinfo([FileBase FileIndices FileExt]);
|
---|
| 1218 | if length(imainfo) >1 %case of image with multiple frames
|
---|
| 1219 | nbfield_1=length(imainfo);
|
---|
| 1220 | nburst_1=1;
|
---|
| 1221 | %set(handles.last_i,'String',num2str(length(imainfo)));%fills last_field box
|
---|
| 1222 | end
|
---|
| 1223 | else
|
---|
| 1224 | %set(handles.last_i,'String','');%fills last_field box
|
---|
| 1225 | set(handles.npx,'String','');%fills nbre of pixels x box
|
---|
| 1226 | set(handles.npy,'String','');%fills nbre of pixels y box
|
---|
| 1227 | end
|
---|
| 1228 |
|
---|
| 1229 | % find scaling parameters
|
---|
| 1230 | filexml=[FileBase '.xml'];
|
---|
| 1231 | fileciv=[FileBase '.civ'];
|
---|
| 1232 | warntext='';%default warning text
|
---|
| 1233 | if exist(filexml,'file')
|
---|
| 1234 | [XmlData,warntext]=imadoc2struct(filexml);
|
---|
| 1235 | if ~isempty(warntext)
|
---|
| 1236 | msgbox_uvmat('WARNING',warntext)
|
---|
| 1237 | end
|
---|
| 1238 | if isfield(XmlData,'Camera')
|
---|
| 1239 | % if isfield(XmlData.Camera,'NbSlice')&& ~isempty(XmlData.Camera.NbSlice)
|
---|
| 1240 | % NbSlice=XmlData.Camera.NbSlice;
|
---|
| 1241 | % end
|
---|
| 1242 | if isfield(XmlData.Camera,'TimeUnit')&& ~isempty(XmlData.Camera.TimeUnit)
|
---|
| 1243 | TimeUnit=XmlData.Camera.TimeUnit;
|
---|
| 1244 | end
|
---|
| 1245 | end
|
---|
| 1246 | elseif exist(fileciv,'file')% if .civ file found
|
---|
| 1247 | [error,XmlData.Time,TimeUnit,mode,npx,npy,pxcmx,pxcmy]=read_imatext([FileBase '.civ']);
|
---|
| 1248 | GeometryCalib.R=[pxcmx 0 0; 0 pxcmy 0;0 0 0];
|
---|
| 1249 | GeometryCalib.Tx=0;
|
---|
| 1250 | GeometryCalib.Ty=0;
|
---|
| 1251 | GeometryCalib.Tz=1;
|
---|
| 1252 | GeometryCalib.dpx=1;
|
---|
| 1253 | GeometryCalib.dpy=1;
|
---|
| 1254 | GeometryCalib.sx=1;
|
---|
| 1255 | GeometryCalib.Cx=0;
|
---|
| 1256 | GeometryCalib.Cy=0;
|
---|
| 1257 | GeometryCalib.f=1;
|
---|
| 1258 | GeometryCalib.kappa1=0;
|
---|
| 1259 | GeometryCalib.CoordUnit='cm';
|
---|
| 1260 | XmlData.GeometryCalib=GeometryCalib;
|
---|
| 1261 | if error==2, warntext=['no file ' FileBase '.civ'];
|
---|
| 1262 | elseif error==1, warntext='inconsistent number of fields in the .civ file';
|
---|
| 1263 | end
|
---|
| 1264 |
|
---|
| 1265 | set(handles.npx,'String',num2str(npx));%fills nbre of pixels x box
|
---|
| 1266 | set(handles.npy,'String',num2str(npy));%fills nbre of pixels y box
|
---|
| 1267 | set(handles.pxcm,'String',num2str(pxcmx));%fills scale x (pixel/cm) box
|
---|
| 1268 | set(handles.pycm,'String',num2str(pxcmy));%fills scale y (pixel/cm) box
|
---|
| 1269 | set(handles.pxcm,'Visible','on');%fills scale x (pixel/cm) box
|
---|
| 1270 | set(handles.pycm,'Visible','on');%fills scale y (pixel/cm) box
|
---|
| 1271 | end
|
---|
| 1272 | if ~isempty(TimeUnit_1) && ~isequal(TimeUnit_1,TimeUnit)
|
---|
[38] | 1273 | msgbox_uvmat('WARNING','the time units for the second series differs from the first one')
|
---|
[2] | 1274 | end
|
---|
| 1275 |
|
---|
| 1276 | % store last index in handles.lat_i and .last_j
|
---|
| 1277 | if ~isempty(XmlData.Time)
|
---|
| 1278 | nbfield_1=size(XmlData.Time,1);
|
---|
| 1279 | nburst_1=size(XmlData.Time,2);
|
---|
| 1280 | end
|
---|
| 1281 | last_i_cell=get(handles.last_i,'String');
|
---|
| 1282 | if isempty(nbfield_1)
|
---|
| 1283 | last_i_cell{2}='';
|
---|
| 1284 | else
|
---|
| 1285 | last_i_cell{2}=num2str(nbfield_1);
|
---|
| 1286 | end
|
---|
| 1287 | set(handles.last_i,'String',last_i_cell)
|
---|
| 1288 | last_j_cell=get(handles.last_j,'String');
|
---|
| 1289 | if isempty(nburst_1)
|
---|
| 1290 | last_j_cell{2}='';
|
---|
| 1291 | else
|
---|
| 1292 | last_j_cell{2}=num2str(nburst_1);
|
---|
| 1293 | end
|
---|
| 1294 | set(handles.last_j,'String',last_j_cell);
|
---|
| 1295 | if ~isequal(last_i_cell{1},last_i_cell{2}) || ~isequal(last_j_cell{1},last_j_cell{2})
|
---|
[38] | 1296 | msgbox_uvmat('WARNING','the numbers of input file of the second series differs from the first one')
|
---|
[2] | 1297 | end
|
---|
| 1298 |
|
---|
| 1299 | % store calibration data
|
---|
| 1300 | GeometryCalib=XmlData.GeometryCalib;
|
---|
| 1301 | if isempty(GeometryCalib)
|
---|
| 1302 | if isfield(UvData, 'GeometryCalib_1')
|
---|
| 1303 | UvData=rmfield(UvData,'GeometryCalib_1');
|
---|
| 1304 | end
|
---|
| 1305 | else
|
---|
| 1306 | UvData.GeometryCalib_1=GeometryCalib;
|
---|
| 1307 | if (isfield(GeometryCalib,'R')& ~isequal(GeometryCalib.R(2,1),0) & ~isequal(GeometryCalib.R(1,2),0)) |...
|
---|
| 1308 | (isfield(GeometryCalib,'kappa1')& ~isequal(GeometryCalib.kappa1,0))
|
---|
| 1309 | set(handles.pxcm,'String','var')
|
---|
| 1310 | set(handles.pycm,'String','var')
|
---|
| 1311 | else
|
---|
| 1312 | pixcmx=GeometryCalib.f*GeometryCalib.R(1,1)*GeometryCalib.sx/(GeometryCalib.Tz*GeometryCalib.dpx);
|
---|
| 1313 | pixcmy=GeometryCalib.f*GeometryCalib.R(2,2)/(GeometryCalib.Tz*GeometryCalib.dpy);
|
---|
| 1314 | set(handles.pxcm,'String',num2str(pixcmx))
|
---|
| 1315 | set(handles.pycm,'String',num2str(pixcmy))
|
---|
| 1316 | end
|
---|
| 1317 | end
|
---|
| 1318 | UvData.XmlData_1=XmlData;
|
---|
[61] | 1319 | set(handles.uvmat,'UserData',UvData)%update the data attached to the uvmat interface
|
---|
[2] | 1320 |
|
---|
| 1321 | if ~isequal(warntext,'')
|
---|
[38] | 1322 | msgbox_uvmat('WARNING',warntext)
|
---|
[2] | 1323 | end
|
---|
| 1324 |
|
---|
| 1325 | set(handles.RootPath_1,'BackgroundColor',[1 1 1])% signa the end the input operation
|
---|
| 1326 | drawnow
|
---|
| 1327 |
|
---|
| 1328 | set_scan_options(hObject, eventdata, handles)
|
---|
| 1329 |
|
---|
| 1330 | %---------------------------------------------------
|
---|
| 1331 | % switch file index scanning options scan_i and scan_j in an exclusive way
|
---|
| 1332 | function scan_i_Callback(hObject, eventdata, handles)
|
---|
| 1333 | %---------------------------------------------------
|
---|
| 1334 | if get(handles.scan_i,'Value')==1
|
---|
| 1335 | set(handles.scan_i,'BackgroundColor',[1 1 0])
|
---|
| 1336 | set(handles.scan_j,'Value',0)
|
---|
[81] | 1337 | % set(handles.scan_j,'BackgroundColor',[0.831 0.816 0.784])
|
---|
[2] | 1338 | else
|
---|
| 1339 | set(handles.scan_i,'BackgroundColor',[0.831 0.816 0.784])
|
---|
| 1340 | set(handles.scan_j,'Value',1)
|
---|
[81] | 1341 | % set(handles.scan_j,'BackgroundColor',[1 1 0])
|
---|
[2] | 1342 | end
|
---|
[81] | 1343 | scan_j_Callback(hObject, eventdata, handles)
|
---|
[45] | 1344 |
|
---|
[2] | 1345 | %-------------------------------------------------------------------
|
---|
| 1346 | % switch file index scanning options scan_i and scan_j in an exclusive way
|
---|
| 1347 | function scan_j_Callback(hObject, eventdata, handles)
|
---|
| 1348 | %-------------------------------------------------------------------
|
---|
| 1349 | if get(handles.scan_j,'Value')==1
|
---|
| 1350 | set(handles.scan_j,'BackgroundColor',[1 1 0])
|
---|
| 1351 | set(handles.scan_i,'Value',0)
|
---|
| 1352 | set(handles.scan_i,'BackgroundColor',[0.831 0.816 0.784])
|
---|
[81] | 1353 | NomType=get(handles.FileIndex,'UserData');
|
---|
| 1354 | switch NomType
|
---|
| 1355 | case {'_i_j1-j2','#_ab','%3dab'},% pair with j index
|
---|
| 1356 | set(handles.fix_pair,'Visible','on')% option fixed pair on/off made visible (choice of avaible pair with buttons + and - if ='off')
|
---|
| 1357 | otherwise
|
---|
| 1358 | set(handles.fix_pair,'Visible','off')
|
---|
| 1359 | end
|
---|
[2] | 1360 | else
|
---|
| 1361 | set(handles.scan_j,'BackgroundColor',[0.831 0.816 0.784])
|
---|
| 1362 | set(handles.scan_i,'Value',1)
|
---|
| 1363 | set(handles.scan_i,'BackgroundColor',[1 1 0])
|
---|
[81] | 1364 | set(handles.fix_pair,'Visible','off')
|
---|
[2] | 1365 | end
|
---|
| 1366 |
|
---|
| 1367 | %-------------------------------------------------------------------
|
---|
| 1368 | function i1_Callback(hObject, eventdata, handles)
|
---|
| 1369 | %-------------------------------------------------------------------
|
---|
| 1370 | % [filebase,num1,num_a,num2,num_b,ext,NomType,subdir]=read_input_file(handles);
|
---|
[45] | 1371 | %[FileName,RootPath,filebase,xx,FileExt]=read_file_boxes(handles);
|
---|
[2] | 1372 | NomType=get(handles.FileIndex,'UserData');
|
---|
| 1373 | num1=stra2num(get(handles.i1,'String'));
|
---|
| 1374 | num2=stra2num(get(handles.i2,'String'));
|
---|
| 1375 | num_a=stra2num(get(handles.j1,'String'));
|
---|
| 1376 | num_b=stra2num(get(handles.j2,'String'));
|
---|
| 1377 | indices=name_generator('',num1,num_a,'',NomType,1,num2,num_b,'');
|
---|
| 1378 | set(handles.FileIndex,'String',indices)
|
---|
| 1379 | if get(handles.SubField,'Value')==1
|
---|
| 1380 | NomType_1=get(handles.FileIndex_1,'String');
|
---|
| 1381 | FileExt_1=get(handles.FileExt_1,'String');
|
---|
| 1382 | [P,F,str1,str2,str_a,str_b,Ext,NomType_1]=name2display(['xx' NomType_1 FileExt_1]);
|
---|
| 1383 | indices=name_generator('',num1,num_a,'',NomType_1,1,num2,num_b,'');
|
---|
| 1384 | set(handles.FileIndex_1,'String',indices)
|
---|
| 1385 | end
|
---|
| 1386 | run0_Callback(hObject, eventdata, handles)
|
---|
| 1387 |
|
---|
| 1388 | %-------------------------------------------------------------------
|
---|
| 1389 | function i2_Callback(hObject, eventdata, handles)
|
---|
| 1390 | i1_Callback(hObject, eventdata, handles)
|
---|
| 1391 | %-------------------------------------------------------------------
|
---|
| 1392 |
|
---|
| 1393 | %-------------------------------------------------------------------
|
---|
| 1394 | function j1_Callback(hObject, eventdata, handles)
|
---|
| 1395 | i1_Callback(hObject, eventdata, handles)
|
---|
| 1396 | %-------------------------------------------------------------------
|
---|
| 1397 |
|
---|
| 1398 | %-------------------------------------------------------------------
|
---|
| 1399 | function j2_Callback(hObject, eventdata, handles)
|
---|
| 1400 | i1_Callback(hObject, eventdata, handles)
|
---|
| 1401 | %-------------------------------------------------------------------
|
---|
| 1402 |
|
---|
| 1403 | %-------------------------------------------------------------------
|
---|
| 1404 | function slices_Callback(hObject, eventdata, handles)
|
---|
| 1405 | %-------------------------------------------------------------------
|
---|
| 1406 | if get(handles.slices,'Value')==1
|
---|
| 1407 | set(handles.slices,'BackgroundColor',[1 1 0])
|
---|
| 1408 | set(handles.nb_slice,'Visible','on')
|
---|
| 1409 | set(handles.z_text,'Visible','on')
|
---|
| 1410 | set(handles.z_index,'Visible','on')
|
---|
| 1411 | nb_slice_Callback(hObject, eventdata, handles)
|
---|
| 1412 | else
|
---|
| 1413 | set(handles.nb_slice,'Visible','off')
|
---|
| 1414 | set(handles.slices,'BackgroundColor',[0.7 0.7 0.7])
|
---|
| 1415 | set(handles.z_text,'Visible','off')
|
---|
| 1416 | set(handles.z_index,'Visible','off')
|
---|
| 1417 | set(handles.masklevel,'Value',1)
|
---|
| 1418 | set(handles.masklevel,'String',{'1'})
|
---|
| 1419 | end
|
---|
| 1420 |
|
---|
| 1421 | %-------------------------------------------------------------------
|
---|
| 1422 | function nb_slice_Callback(hObject, eventdata, handles)
|
---|
| 1423 | %-------------------------------------------------------------------
|
---|
[71] | 1424 | nb_slice_str=get(handles.nb_slice,'String');
|
---|
[60] | 1425 | if isequal(nb_slice_str,'volume')
|
---|
| 1426 | num=stra2num(get(handles.j1,'String'));
|
---|
| 1427 | last_j=get(handles.last_j,'String');
|
---|
| 1428 | nbslice=str2double(last_j{1});
|
---|
| 1429 | else
|
---|
| 1430 | num=str2double(get(handles.i1,'String'));
|
---|
| 1431 | nbslice=str2double(get(handles.nb_slice,'String'));
|
---|
| 1432 | end
|
---|
| 1433 | z=mod(num-1,nbslice)+1;
|
---|
[2] | 1434 | set(handles.z_index,'String',num2str(z))
|
---|
| 1435 | for ilist=1:nbslice
|
---|
| 1436 | list_index{ilist,1}=num2str(ilist);
|
---|
| 1437 | end
|
---|
| 1438 | set(handles.masklevel,'String',list_index)
|
---|
| 1439 | set(handles.masklevel,'Value',z)
|
---|
| 1440 |
|
---|
| 1441 |
|
---|
| 1442 | %-------------------------------------------------------------------
|
---|
| 1443 | % --- Executes on button press in view_xml.
|
---|
| 1444 | function view_xml_Callback(hObject, eventdata, handles)
|
---|
| 1445 | [FileName,RootPath,FileBase,FileIndices,FileExt]=read_file_boxes(handles);
|
---|
| 1446 | option=get(handles.view_xml,'String');
|
---|
| 1447 | if isequal(option,'view .xml')
|
---|
| 1448 | FileXml=[FileBase '.xml'];
|
---|
| 1449 | heditxml=editxml(FileXml);
|
---|
| 1450 | end
|
---|
| 1451 |
|
---|
| 1452 | %-------------------------------------------------------------------
|
---|
| 1453 | % --- Executes on button press in mask_test.
|
---|
| 1454 | function mask_test_Callback(hObject, eventdata, handles)
|
---|
| 1455 | %-------------------------------------------------------------------
|
---|
| 1456 | if isequal(get(handles.mask_test,'Value'),1)
|
---|
| 1457 | [FF,RootPath,FileBase]=read_file_boxes(handles);
|
---|
| 1458 | num_i1=stra2num(get(handles.i1,'String'));
|
---|
| 1459 | num_j1=stra2num(get(handles.j1,'String'));
|
---|
| 1460 | currentdir=pwd;
|
---|
| 1461 | cd(RootPath);
|
---|
| 1462 | maskfiles=dir('*_*mask_*.png');%look for a mask file
|
---|
| 1463 | cd(currentdir);%come back to the working directory
|
---|
| 1464 | mdetect=0;
|
---|
| 1465 | if isempty(maskfiles)
|
---|
| 1466 | msgbox_uvmat('ERROR','no mask file detected (format ..._xxmask_ii.png needed), use the menu bar Tools/Make mask')
|
---|
| 1467 | return
|
---|
| 1468 | end
|
---|
| 1469 | for ilist=1:length(maskfiles)
|
---|
| 1470 | maskname=maskfiles(ilist).name;% take the first mask file in the list
|
---|
| 1471 | [rr,ff,x1,x2,xa,xb,xext,Mask_NomType{ilist}]=name2display(maskname);
|
---|
| 1472 | if ~strcmp(Mask_NomType{ilist},Mask_NomType{1})
|
---|
| 1473 | msgbox_uvmat('ERROR',['inconsistent mask types ' Mask_NomType{1} Mask_NomType{ilist } ' coexist in the current image directory'])
|
---|
| 1474 | return
|
---|
| 1475 | end
|
---|
| 1476 | [Path2,Name,ext]=fileparts(maskname);
|
---|
| 1477 | Namedouble=double(Name);
|
---|
| 1478 | val=(48>Namedouble)|(Namedouble>57);% select the non-numerical characters
|
---|
| 1479 | ind_mask=findstr('mask',Name);
|
---|
| 1480 | i=ind_mask-1;
|
---|
| 1481 | while val(i)==0 & i>0
|
---|
| 1482 | i=i-1;
|
---|
| 1483 | end
|
---|
| 1484 | nbmask_str=str2num(Name(i+1:ind_mask-1));
|
---|
| 1485 | if ~isempty(nbmask_str)
|
---|
| 1486 | nbslice(ilist)=nbmask_str; % number of different masks (slices)
|
---|
| 1487 | end
|
---|
| 1488 | end
|
---|
| 1489 | if isequal(min(nbslice),max(nbslice))
|
---|
| 1490 | nbslice=nbslice(1);
|
---|
| 1491 | else
|
---|
| 1492 | msgbox_uvmat('ERROR','several inconsistent mask sets coexist in the current image directory')
|
---|
| 1493 | return
|
---|
| 1494 | end
|
---|
| 1495 | if ~isempty(nbslice) && Name(i)=='_'
|
---|
| 1496 | Mask.Base=[FileBase Name(i:ind_mask+3)];
|
---|
| 1497 | Mask.NbSlice=nbslice;
|
---|
[55] | 1498 | num_i1=mod(num_i1-1,nbslice)+1;
|
---|
[2] | 1499 | Mask.NomType=Mask_NomType{1};
|
---|
[55] | 1500 | [maskname,mdetect]=name_generator(Mask.Base,num_i1,num_j1,'.png',Mask.NomType);%
|
---|
| 1501 | mdetect=exist(maskname,'file');
|
---|
[2] | 1502 | if mdetect
|
---|
| 1503 | set(handles.nb_slice,'String',Name(i+1:ind_mask-1));
|
---|
| 1504 | set(handles.nb_slice,'BackgroundColor',[1 1 0])
|
---|
| 1505 | set(handles.mask_test,'UserData',Mask);
|
---|
| 1506 | set(handles.mask_test,'BackgroundColor',[1 1 0])
|
---|
| 1507 | if nbslice > 1
|
---|
| 1508 | set(handles.slices,'value',1)
|
---|
| 1509 | slices_Callback(hObject, eventdata, handles)
|
---|
| 1510 | end
|
---|
| 1511 | end
|
---|
| 1512 | end
|
---|
| 1513 | if mdetect==0
|
---|
| 1514 | msgbox_uvmat('ERROR','no mask file detected (format ..._xxmask_ii.png needed), use the menu bar Tools/Make mask')
|
---|
| 1515 | set(handles.mask_test,'Value',0)
|
---|
| 1516 | return
|
---|
| 1517 | end
|
---|
| 1518 | update_mask(handles,num_i1,num_j1);
|
---|
| 1519 | else
|
---|
| 1520 | MaskData=get(handles.mask_test,'UserData');
|
---|
| 1521 | if isfield(MaskData,'maskhandle') && ishandle(MaskData.maskhandle)
|
---|
| 1522 | delete(MaskData.maskhandle)
|
---|
| 1523 | end
|
---|
| 1524 | set(handles.mask_test,'UserData',[])
|
---|
[61] | 1525 | %huvmat=get(handles.mask_test,'parent');
|
---|
| 1526 | UvData=get(handles.uvmat,'UserData');
|
---|
[2] | 1527 | if isfield(UvData,'MaskName')
|
---|
| 1528 | UvData=rmfield(UvData,'MaskName');
|
---|
[61] | 1529 | set(handles.uvmat,'UserData',UvData)
|
---|
[2] | 1530 | end
|
---|
| 1531 | set(handles.mask_test,'BackgroundColor',[0.7 0.7 0.7])
|
---|
| 1532 | end
|
---|
| 1533 |
|
---|
| 1534 | %-------------------------------------------------------------------
|
---|
| 1535 | function update_mask(handles,num_i1,num_j1)
|
---|
| 1536 | %-------------------------------------------------------------------
|
---|
| 1537 |
|
---|
| 1538 | MaskData=get(handles.mask_test,'UserData');
|
---|
| 1539 | if isfield(MaskData,'maskhandle')&& ishandle(MaskData.maskhandle)
|
---|
| 1540 | uistack(MaskData.maskhandle,'top');
|
---|
| 1541 | end
|
---|
| 1542 | num_i1_mask=mod(num_i1-1,MaskData.NbSlice)+1;
|
---|
| 1543 | [MaskName,mdetect]=name_generator(MaskData.Base,num_i1_mask,num_j1,'.png',MaskData.NomType);
|
---|
| 1544 | huvmat=get(handles.mask_test,'parent');
|
---|
| 1545 | UvData=get(huvmat,'UserData');
|
---|
| 1546 |
|
---|
| 1547 | %update mask image if the mask is new
|
---|
| 1548 | if ~ (isfield(UvData,'MaskName') && isequal(UvData.MaskName,MaskName))
|
---|
| 1549 | UvData.MaskName=MaskName; %update the recorded name on UvData
|
---|
| 1550 | set(huvmat,'UserData',UvData);
|
---|
| 1551 | if mdetect==0
|
---|
| 1552 | if isfield(MaskData,'maskhandle')&& ishandle(MaskData.maskhandle)
|
---|
| 1553 | delete(MaskData.maskhandle)
|
---|
| 1554 | end
|
---|
| 1555 | else
|
---|
| 1556 | %read mask image
|
---|
| 1557 | Mask.AName='image';
|
---|
| 1558 | Mask.A=imread(MaskName);
|
---|
| 1559 | npxy=size(Mask.A);
|
---|
| 1560 | Mask.AX=[0.5 npxy(2)-0.5];
|
---|
| 1561 | Mask.AY=[npxy(1)-0.5 0.5 ];
|
---|
| 1562 | Mask.CoordType='px';
|
---|
| 1563 | if isequal(get(handles.slices,'Value'),1)
|
---|
| 1564 | NbSlice=str2num(get(handles.nb_slice,'String'));
|
---|
| 1565 | num_i1=str2num(get(handles.i1,'String'));
|
---|
| 1566 | Mask.ZIndex=mod(num_i1-1,NbSlice)+1;
|
---|
| 1567 | end
|
---|
| 1568 | %px to phys or other transform on field
|
---|
[39] | 1569 | menu_transform=get(handles.transform_fct,'String');
|
---|
| 1570 | choice_value=get(handles.transform_fct,'Value');
|
---|
| 1571 | transform_name=menu_transform{choice_value};%name of the transform fct given by the menu 'transform_fct'
|
---|
| 1572 | transform_list=get(handles.transform_fct,'UserData');
|
---|
[38] | 1573 | transform=transform_list{choice_value};
|
---|
| 1574 | if ~isequal(transform_name,'') && ~isequal(transform_name,'px')
|
---|
[2] | 1575 | if isfield(UvData,'XmlData') && isfield(UvData.XmlData,'GeometryCalib')%use geometry calib recorded from the ImaDoc xml file as first priority
|
---|
| 1576 | Calib=UvData.XmlData.GeometryCalib;
|
---|
[38] | 1577 | Mask=transform(Mask,UvData.XmlData);
|
---|
[2] | 1578 | end
|
---|
| 1579 | end
|
---|
| 1580 | flagmask=Mask.A < 200;
|
---|
| 1581 |
|
---|
| 1582 | %make brown color image
|
---|
| 1583 | imflag(:,:,1)=0.9*flagmask;
|
---|
| 1584 | imflag(:,:,2)=0.7*flagmask;
|
---|
| 1585 | imflag(:,:,3)=zeros(size(flagmask));
|
---|
| 1586 |
|
---|
| 1587 | %update mask image
|
---|
| 1588 | hmask=[]; %default
|
---|
| 1589 | if isfield(MaskData,'maskhandle')&& ishandle(MaskData.maskhandle)
|
---|
| 1590 | hmask=MaskData.maskhandle;
|
---|
| 1591 | end
|
---|
| 1592 | if ~isempty(hmask)
|
---|
| 1593 | set(hmask,'CData',imflag)
|
---|
| 1594 | set(hmask,'AlphaData',flagmask*0.6)
|
---|
| 1595 | set(hmask,'XData',Mask.AX);
|
---|
| 1596 | set(hmask,'YData',Mask.AY);
|
---|
| 1597 | % uistack(hmask,'top')
|
---|
| 1598 | else
|
---|
| 1599 | axes(handles.axes3)
|
---|
| 1600 | hold on
|
---|
| 1601 | MaskData.maskhandle=image(Mask.AX,Mask.AY,imflag,'Tag','mask','HitTest','off','AlphaData',0.6*flagmask);
|
---|
| 1602 | % set(MaskData.maskhandle,'AlphaData',0.6*flagmask)
|
---|
| 1603 | set(handles.mask_test,'UserData',MaskData)
|
---|
| 1604 | end
|
---|
| 1605 | end
|
---|
| 1606 | end
|
---|
| 1607 |
|
---|
| 1608 |
|
---|
| 1609 | %-------------------------------------------------------------------
|
---|
| 1610 | function MenuExportFigure_Callback(hObject, eventdata, handles)
|
---|
| 1611 | %-------------------------------------------------------------------
|
---|
| 1612 | huvmat=get(handles.MenuExport,'parent');
|
---|
| 1613 | UvData=get(huvmat,'UserData');
|
---|
| 1614 | hfig=figure;
|
---|
| 1615 | newaxes=copyobj(handles.axes3,hfig);
|
---|
| 1616 | map=colormap(handles.axes3);
|
---|
| 1617 | colormap(map);%transmit the current colormap to the zoom fig
|
---|
| 1618 | colorbar
|
---|
| 1619 |
|
---|
| 1620 | %-------------------------------------------------------------------
|
---|
| 1621 | %-------------------------------------------------------------------
|
---|
| 1622 | % III - MAIN REFRESH FUNCTIONS : 'FRAME PLOT'
|
---|
| 1623 | %-------------------------------------------------------------------
|
---|
| 1624 |
|
---|
| 1625 | %-------------------------------------------------------------------
|
---|
[85] | 1626 | % --- Executes on button press in runplus: make one step forward and call
|
---|
| 1627 | % --- run0. The step forward is along the fields series 1 or 2 depending on
|
---|
| 1628 | % --- the scan_i and scan_j check box (exclusive each other)
|
---|
[2] | 1629 | function runplus_Callback(hObject, eventdata, handles)
|
---|
[85] | 1630 | %-------------------------------------------------------------------
|
---|
| 1631 | set(handles.runplus,'BackgroundColor',[1 1 0])%paint the command button in yellow
|
---|
| 1632 | drawnow
|
---|
[2] | 1633 | increment=str2num(get(handles.increment_scan,'String')); %get the field increment d
|
---|
| 1634 | runpm(hObject,eventdata,handles,increment)
|
---|
[85] | 1635 | set(handles.runplus,'BackgroundColor',[1 0 0])%paint the command button in yellow
|
---|
[2] | 1636 |
|
---|
| 1637 | %-------------------------------------------------------------------
|
---|
[85] | 1638 | % --- Executes on button press in runmin: make one step backward and call
|
---|
| 1639 | % --- run0. The step backward is along the fields series 1 or 2 depending on
|
---|
| 1640 | % --- the scan_i and scan_j check box (exclusive each other)
|
---|
| 1641 | function runmin_Callback(hObject, eventdata, handles)
|
---|
[2] | 1642 | %-------------------------------------------------------------------
|
---|
[85] | 1643 | set(handles.runmin,'BackgroundColor',[1 1 0])%paint the command button in yellow
|
---|
| 1644 | drawnow
|
---|
[2] | 1645 | increment=-str2num(get(handles.increment_scan,'String')); %get the field increment d
|
---|
| 1646 | runpm(hObject,eventdata,handles,increment)
|
---|
[85] | 1647 | set(handles.runmin,'BackgroundColor',[1 0 0])%paint the command button in yellow
|
---|
[2] | 1648 |
|
---|
| 1649 | %-------------------------------------------------------------------
|
---|
[81] | 1650 | % -- Executes on button press in Movie: make a series of +> steps
|
---|
| 1651 | function Movie_Callback(hObject, eventdata, handles)
|
---|
[2] | 1652 | %------------------------------------------------------------------
|
---|
[81] | 1653 | set(handles.Movie,'BackgroundColor',[1 1 0])%paint the command button in yellow
|
---|
[2] | 1654 | drawnow
|
---|
| 1655 | increment=str2num(get(handles.increment_scan,'String')); %get the field increment d
|
---|
| 1656 | set(handles.STOP,'Visible','on')
|
---|
| 1657 | set(handles.speed,'Visible','on')
|
---|
| 1658 | set(handles.speed_txt,'Visible','on')
|
---|
[81] | 1659 | set(handles.Movie,'BusyAction','queue')
|
---|
[2] | 1660 | testavi=0;
|
---|
[57] | 1661 | UvData=get(handles.uvmat,'UserData');
|
---|
[2] | 1662 |
|
---|
[81] | 1663 | while get(handles.speed,'Value')~=0 & isequal(get(handles.Movie,'BusyAction'),'queue') % enable STOP command
|
---|
[72] | 1664 | errormsg=runpm(hObject,eventdata,handles,increment);
|
---|
| 1665 | if ~isempty(errormsg)
|
---|
| 1666 | return
|
---|
| 1667 | end
|
---|
[2] | 1668 | pause(1.02-get(handles.speed,'Value'))% wait for next image
|
---|
| 1669 | end
|
---|
| 1670 | if isfield(UvData,'aviobj') && ~isempty( UvData.aviobj),
|
---|
| 1671 | UvData.aviobj=close(UvData.aviobj);
|
---|
[57] | 1672 | set(handles.uvmat,'UserData',UvData);
|
---|
[2] | 1673 | end
|
---|
[81] | 1674 | set(handles.Movie,'BackgroundColor',[1 0 0])%paint the command buttonback to red
|
---|
[2] | 1675 |
|
---|
| 1676 | %-------------------------------------------------------------------
|
---|
[81] | 1677 | % -- Executes on button press in Movie: make a series of <- steps
|
---|
| 1678 | function MovieBackward_Callback(hObject, eventdata, handles)
|
---|
| 1679 | %------------------------------------------------------------------
|
---|
| 1680 | set(handles.MovieBackward,'BackgroundColor',[1 1 0])%paint the command button in yellow
|
---|
| 1681 | drawnow
|
---|
| 1682 | increment=-str2num(get(handles.increment_scan,'String')); %get the field increment d
|
---|
| 1683 | set(handles.STOP,'Visible','on')
|
---|
| 1684 | set(handles.speed,'Visible','on')
|
---|
| 1685 | set(handles.speed_txt,'Visible','on')
|
---|
| 1686 | set(handles.MovieBackward,'BusyAction','queue')
|
---|
| 1687 | testavi=0;
|
---|
| 1688 | UvData=get(handles.uvmat,'UserData');
|
---|
| 1689 |
|
---|
| 1690 | while get(handles.speed,'Value')~=0 & isequal(get(handles.MovieBackward,'BusyAction'),'queue') % enable STOP command
|
---|
| 1691 | errormsg=runpm(hObject,eventdata,handles,increment);
|
---|
| 1692 | if ~isempty(errormsg)
|
---|
| 1693 | return
|
---|
| 1694 | end
|
---|
| 1695 | pause(1.02-get(handles.speed,'Value'))% wait for next image
|
---|
| 1696 | end
|
---|
| 1697 | if isfield(UvData,'aviobj') && ~isempty( UvData.aviobj),
|
---|
| 1698 | UvData.aviobj=close(UvData.aviobj);
|
---|
| 1699 | set(handles.uvmat,'UserData',UvData);
|
---|
| 1700 | end
|
---|
| 1701 | set(handles.MovieBackward,'BackgroundColor',[1 0 0])%paint the command buttonback to red
|
---|
| 1702 |
|
---|
| 1703 | %-------------------------------------------------------------------
|
---|
[2] | 1704 | function STOP_Callback(hObject, eventdata, handles)
|
---|
| 1705 | %-------------------------------------------------------------------
|
---|
[57] | 1706 | set(handles.movie_pair,'BusyAction','Cancel')
|
---|
| 1707 | set(handles.movie_pair,'value',0)
|
---|
[81] | 1708 | set(handles.Movie,'BusyAction','Cancel')
|
---|
| 1709 | set(handles.MovieBackward,'BusyAction','Cancel')
|
---|
[2] | 1710 | set(handles.MenuExportMovie,'BusyAction','Cancel')
|
---|
[85] | 1711 | set(handles.movie_pair,'BackgroundColor',[1 0 0])%paint the command buttonback to red
|
---|
| 1712 | set(handles.Movie,'BackgroundColor',[1 0 0])%paint the command buttonback to red
|
---|
| 1713 | set(handles.MovieBackward,'BackgroundColor',[1 0 0])%paint the command buttonback to red
|
---|
[2] | 1714 |
|
---|
| 1715 | %------------------------------------------------------------------
|
---|
[72] | 1716 | function errormsg=runpm(hObject,eventdata,handles,increment)
|
---|
[2] | 1717 | %------------------------------------------------------------------
|
---|
[57] | 1718 | %check for mùovie pair status
|
---|
| 1719 | movie_status=get(handles.movie_pair,'Value');
|
---|
| 1720 | if isequal(movie_status,1)
|
---|
[59] | 1721 | STOP_Callback(hObject, eventdata, handles)%interrupt movie pair if active
|
---|
[57] | 1722 | end
|
---|
[2] | 1723 | %read the data on the current input rootfile(s)
|
---|
| 1724 |
|
---|
| 1725 | [FileName,RootPath,filebase,FileIndices,FileExt,subdir]=read_file_boxes(handles);
|
---|
| 1726 | NomType=get(handles.FileIndex,'UserData');
|
---|
| 1727 |
|
---|
| 1728 | num1=stra2num(get(handles.i1,'String'));
|
---|
| 1729 | num2=stra2num(get(handles.i2,'String'));
|
---|
| 1730 | num_a=stra2num(get(handles.j1,'String'));
|
---|
| 1731 | num_b=stra2num(get(handles.j2,'String'));
|
---|
| 1732 |
|
---|
| 1733 | sub_value= get(handles.SubField,'Value');
|
---|
[59] | 1734 | if sub_value % a second input file has been entered
|
---|
[2] | 1735 | [FileName_1,RootPath_1,filebase_1,FileIndices_1,FileExt_1,SubDir_1]=read_file_boxes_1(handles);
|
---|
[59] | 1736 | [pp,ff,str1,str2,str_a,str_b]=name2display(FileIndices_1);
|
---|
| 1737 | num1_1=stra2num(str1);%current set of indices for the second field (may be set different than the main indices)
|
---|
| 1738 | num2_1=stra2num(str2);
|
---|
| 1739 | num_a_1=stra2num(str_a);
|
---|
| 1740 | num_b_1=stra2num(str_b);
|
---|
| 1741 | NomType_1=get(handles.FileIndex_1,'UserData');
|
---|
| 1742 | else
|
---|
| 1743 | filename_1=[];
|
---|
[2] | 1744 | end
|
---|
| 1745 |
|
---|
| 1746 | comp_input=get(handles.fix_pair,'Value');
|
---|
[81] | 1747 | % if isequal(NomType,'_i1-i2')||isequal(NomType,'_i1-i2_j')
|
---|
| 1748 | % comp_input=1; %impose a fixed pair
|
---|
| 1749 | % set(handles.fix_pair,'Value',1)
|
---|
| 1750 | % end
|
---|
[2] | 1751 |
|
---|
| 1752 | %case of scanning along the first direction (rootfile numbers)
|
---|
[59] | 1753 | if get(handles.scan_i,'Value')==1% case of scanning along index i
|
---|
[2] | 1754 | num1=num1+increment;
|
---|
| 1755 | num2=num2+increment;
|
---|
[71] | 1756 | [filename,num1,num_a,num2,num_b]=name_generator(filebase,num1,num_a,FileExt,NomType,comp_input,num2,num_b,subdir);
|
---|
[59] | 1757 | if sub_value% set the second field name and indices
|
---|
| 1758 | num1_1=num1_1+increment;
|
---|
| 1759 | num2_1=num2_1+increment;
|
---|
| 1760 | filename_1=name_generator(filebase_1,num1_1,num_a_1,FileExt_1,NomType_1,1,num2_1,num_b_1,SubDir_1);
|
---|
| 1761 | end
|
---|
| 1762 | else % case of scanning along index j (burst numbers)
|
---|
[2] | 1763 | num_a=num_a+increment;
|
---|
| 1764 | num_b=num_b+increment;
|
---|
[59] | 1765 | if sub_value
|
---|
| 1766 | num_a_1=num_a_1+increment;
|
---|
| 1767 | num_b_1=num_b_1+increment;
|
---|
| 1768 | filename_1=name_generator(filebase_1,num1_1,num_a_1,FileExt_1,NomType_1,1,num2_1,num_b_1,SubDir_1);
|
---|
| 1769 | % else % redefine the j index if it exceeds its upper bound (only in the absence of a second field)
|
---|
| 1770 | % lastfield_cell=get(handles.last_j,'String'); % get the last field number
|
---|
| 1771 | % lastfield=str2double(lastfield_cell{1});
|
---|
| 1772 | % if num_a>lastfield && ~isnan(lastfield)
|
---|
| 1773 | % num_a=mod(num_a,lastfield);
|
---|
| 1774 | % num_b=mod(num_b,lastfield)
|
---|
| 1775 | % end
|
---|
[2] | 1776 | end
|
---|
[65] | 1777 | [filename,num1,num_a,num2,num_b]=name_generator(filebase,num1,num_a,FileExt,NomType,comp_input,num2,num_b,subdir);
|
---|
[2] | 1778 | end
|
---|
| 1779 |
|
---|
[59] | 1780 | % refresh plots
|
---|
| 1781 | errormsg=refresh_field(handles,filename,filename_1,num1,num2,num_a,num_b);
|
---|
[2] | 1782 |
|
---|
[59] | 1783 | if isempty(errormsg) %update the index counters
|
---|
| 1784 | set(handles.i1,'String',num2stra(num1,NomType,1));
|
---|
| 1785 | if isequal(num2,num1)
|
---|
| 1786 | set(handles.i2,'String','');
|
---|
| 1787 | else
|
---|
| 1788 | set(handles.i2,'String',num2stra(num2,NomType,1));
|
---|
| 1789 | end
|
---|
| 1790 | set(handles.j1,'String',num2stra(num_a,NomType,2));
|
---|
| 1791 | if isequal(num_b,num_a)
|
---|
| 1792 | set(handles.j2,'String','');
|
---|
| 1793 | else
|
---|
| 1794 | set(handles.j2,'String',num2stra(num_b,NomType,2));
|
---|
| 1795 | end
|
---|
| 1796 | [indices]=name_generator('',num1,num_a,'',NomType,1,num2,num_b,'');
|
---|
| 1797 | set(handles.FileIndex,'String',indices);
|
---|
[81] | 1798 | if ~isempty(filename_1)
|
---|
[59] | 1799 | indices_1=name_generator('',num1_1,num_a_1,'',NomType_1,1,num2_1,num_b_1,'');
|
---|
| 1800 | set(handles.FileIndex_1,'String',indices_1);
|
---|
| 1801 | end
|
---|
| 1802 | if isequal(movie_status,1)
|
---|
| 1803 | set(handles.movie_pair,'Value',1)
|
---|
| 1804 | movie_pair_Callback(hObject, eventdata, handles); %reactivate moviepair if it was activated
|
---|
| 1805 | end
|
---|
[57] | 1806 | else
|
---|
[59] | 1807 | msgbox_uvmat('ERROR',errormsg);
|
---|
[57] | 1808 | end
|
---|
[2] | 1809 |
|
---|
| 1810 |
|
---|
[59] | 1811 |
|
---|
[2] | 1812 | %-------------------------------------------------------
|
---|
[57] | 1813 | % --- Executes on button press in movie_pair: create an alternating movie with two view
|
---|
[2] | 1814 | %-------------------------------------------------------
|
---|
| 1815 | function movie_pair_Callback(hObject, eventdata, handles)
|
---|
[57] | 1816 | status=get(handles.movie_pair,'value');
|
---|
| 1817 | if isequal(status,0)
|
---|
[59] | 1818 | set(handles.movie_pair,'BusyAction','Cancel')%stop movie pair if button is 'off'
|
---|
| 1819 | set(handles.i2,'String','')
|
---|
| 1820 | set(handles.j2,'String','')
|
---|
[57] | 1821 | return
|
---|
| 1822 | else
|
---|
| 1823 | set(handles.movie_pair,'BusyAction','queue')
|
---|
| 1824 | end
|
---|
[2] | 1825 | %initialisation
|
---|
| 1826 | set(handles.movie_pair,'BackgroundColor',[1 1 0])%paint the command button in yellow
|
---|
| 1827 | drawnow
|
---|
| 1828 | list_fields=get(handles.Fields,'String');% list menu fields
|
---|
| 1829 | index_fields=get(handles.Fields,'Value');% selected string index
|
---|
| 1830 | FieldName=list_fields{index_fields}; % selected field
|
---|
[65] | 1831 | UvData=get(handles.uvmat,'UserData');
|
---|
[2] | 1832 | if isequal(FieldName,'image')
|
---|
[65] | 1833 | test_1=0;
|
---|
| 1834 | [ff,rr,filebase,xx,Ext,SubDir]=read_file_boxes(handles);
|
---|
| 1835 | NomType=get(handles.FileIndex,'UserData');
|
---|
[2] | 1836 | else
|
---|
[65] | 1837 | list_fields=get(handles.Fields_1,'String');% list menu fields
|
---|
| 1838 | index_fields=get(handles.Fields_1,'Value');% selected string index
|
---|
| 1839 | FieldName=list_fields{index_fields}; % selected field
|
---|
| 1840 | if isequal(FieldName,'image')
|
---|
| 1841 | test_1=1;
|
---|
| 1842 | [ff,rr,filebase,xx,Ext,SubDir]=read_file_boxes_1(handles);
|
---|
| 1843 | NomType=get(handles.FileIndex_1,'UserData');
|
---|
| 1844 | else
|
---|
| 1845 | msgbox_uvmat('ERROR','an image or movie must be first introduced as input')
|
---|
[85] | 1846 | set(handles.movie_pair,'BackgroundColor',[1 0 0])%paint the command button in red
|
---|
[65] | 1847 | return
|
---|
| 1848 | end
|
---|
[2] | 1849 | end
|
---|
[65] | 1850 |
|
---|
[57] | 1851 | num_i1=stra2num(get(handles.i1,'String'));
|
---|
| 1852 | num_j1=stra2num(get(handles.j1,'String'));
|
---|
| 1853 | num_i2=stra2num(get(handles.i2,'String'));
|
---|
| 1854 | num_j2=stra2num(get(handles.j2,'String'));
|
---|
| 1855 | if isempty(num_j2)
|
---|
| 1856 | if isempty(num_i2)
|
---|
| 1857 | msgbox_uvmat('ERROR', 'a second image index i2 or j2 is needed to show the pair as a movie')
|
---|
[85] | 1858 | set(handles.movie_pair,'BackgroundColor',[1 0 0])%paint the command button in red
|
---|
[2] | 1859 | return
|
---|
[57] | 1860 | else
|
---|
| 1861 | num_j2=num_j1;%repeat the index i1 by default
|
---|
[2] | 1862 | end
|
---|
[57] | 1863 | end
|
---|
| 1864 | if isempty(num_i2)
|
---|
| 1865 | num_i2=num_i1;%repeat the index i1 by default
|
---|
| 1866 | end
|
---|
| 1867 | imaname_1=name_generator(filebase,num_i2,num_j2,Ext,NomType);
|
---|
| 1868 | if ~exist(imaname_1,'file')
|
---|
| 1869 | msgbox_uvmat('ERROR',['second input open (-) ' imaname_1 ' not found']);
|
---|
[85] | 1870 | set(handles.movie_pair,'BackgroundColor',[1 0 0])%paint the command button in red
|
---|
[57] | 1871 | return
|
---|
| 1872 | end
|
---|
[2] | 1873 |
|
---|
| 1874 | %read the second image
|
---|
| 1875 | Field.AName='image';
|
---|
[65] | 1876 | if test_1
|
---|
| 1877 | Field_a=UvData.Field_1;
|
---|
| 1878 | else
|
---|
| 1879 | Field_a=UvData.Field;
|
---|
| 1880 | end
|
---|
| 1881 | Field_b.AX=Field_a.AX;
|
---|
| 1882 | Field_b.AY=Field_a.AY;
|
---|
[57] | 1883 | % z index
|
---|
| 1884 | nbslice=str2double(get(handles.nb_slice,'String'));
|
---|
| 1885 | if ~isempty(nbslice)
|
---|
[65] | 1886 | Field_b.ZIndex=mod(num_i2-1,nbslice)+1;
|
---|
[57] | 1887 | end
|
---|
[65] | 1888 | Field_b.CoordType='px';
|
---|
[45] | 1889 | %determine the input file type
|
---|
[65] | 1890 | if (test_1 && isfield(UvData,'MovieObject_1'))||(~test_1 && isfield(UvData,'MovieObject'))
|
---|
[45] | 1891 | FileType='movie';
|
---|
| 1892 | elseif isequal(lower(Ext),'.avi')
|
---|
| 1893 | FileType='avi';
|
---|
| 1894 | elseif isequal(lower(Ext),'.vol')
|
---|
| 1895 | FileType='vol';
|
---|
| 1896 | else
|
---|
| 1897 | form=imformats(Ext([2:end]));
|
---|
| 1898 | if ~isempty(form)% if the extension corresponds to an image format recognized by Matlab
|
---|
| 1899 | if isequal(NomType,'*');
|
---|
| 1900 | FileType='multimage';
|
---|
| 1901 | else
|
---|
| 1902 | FileType='image';
|
---|
| 1903 | end
|
---|
| 1904 | end
|
---|
| 1905 | end
|
---|
| 1906 | switch FileType
|
---|
| 1907 | case 'movie'
|
---|
[65] | 1908 | if test_1
|
---|
| 1909 | Field_b.A=read(UvData.MovieObject_1,num_i2);
|
---|
| 1910 | else
|
---|
| 1911 | Field_b.A=read(UvData.MovieObject,num_i2);
|
---|
| 1912 | end
|
---|
[45] | 1913 | case 'avi'
|
---|
| 1914 | mov=aviread(imaname_1,num_i2);
|
---|
[65] | 1915 | Field_b.A=frame2im(mov(1));
|
---|
[45] | 1916 | case 'vol'
|
---|
[65] | 1917 | Field_b.A=imread(imaname_1);
|
---|
[45] | 1918 | case 'multimage'
|
---|
[65] | 1919 | Field_b.A=imread(imaname_1,num_i2);
|
---|
[45] | 1920 | case 'image'
|
---|
[65] | 1921 | Field_b.A=imread(imaname_1);
|
---|
[45] | 1922 | end
|
---|
[60] | 1923 | if get(handles.slices,'Value')
|
---|
| 1924 | Field.ZIndex=str2double(get(handles.z_index,'String'));
|
---|
| 1925 | end
|
---|
[2] | 1926 |
|
---|
| 1927 | %px to phys or other transform on field
|
---|
[39] | 1928 | menu_transform=get(handles.transform_fct,'String');
|
---|
| 1929 | choice_value=get(handles.transform_fct,'Value');
|
---|
| 1930 | transform_name=menu_transform{choice_value};%name of the transform fct given by the menu 'transform_fct'
|
---|
| 1931 | transform_list=get(handles.transform_fct,'UserData');
|
---|
[38] | 1932 | transform=transform_list{choice_value};
|
---|
| 1933 | if ~isequal(transform_name,'') && ~isequal(transform_name,'px')
|
---|
[65] | 1934 | if test_1 && isfield(UvData,'XmlData_1') && isfield(UvData.XmlData_1,'GeometryCalib')%use geometry calib recorded from the ImaDoc xml file as first priority
|
---|
[67] | 1935 | Field_a=transform(Field_a,UvData.XmlData_1);%the first field has been stored without transform
|
---|
[65] | 1936 | Field_b=transform(Field_b,UvData.XmlData_1);
|
---|
| 1937 | elseif ~test_1 && isfield(UvData,'XmlData') && isfield(UvData.XmlData,'GeometryCalib')%use geometry calib
|
---|
| 1938 | Field_b=transform(Field_b,UvData.XmlData);
|
---|
[2] | 1939 | end
|
---|
| 1940 | end
|
---|
| 1941 |
|
---|
| 1942 | % make movie until movie speed is set to 0 or STOP is activated
|
---|
| 1943 | hima=findobj(handles.axes3,'Tag','ima');% %handles.axes3 =main plotting window (A GENERALISER)
|
---|
| 1944 | set(handles.STOP,'Visible','on')
|
---|
| 1945 | set(handles.speed,'Visible','on')
|
---|
| 1946 | set(handles.speed_txt,'Visible','on')
|
---|
[57] | 1947 | while get(handles.speed,'Value')~=0 && isequal(get(handles.movie_pair,'BusyAction'),'queue')%isequal(get(handles.run0,'BusyAction'),'queue'); % enable STOP command
|
---|
[2] | 1948 | % read and plot the series of images in non erase mode
|
---|
[65] | 1949 | set(hima,'CData',Field_b.A);
|
---|
[2] | 1950 | pause(1.02-get(handles.speed,'Value'));% wait for next image
|
---|
[65] | 1951 | set(hima,'CData',Field_a.A);
|
---|
[2] | 1952 | pause(1.02-get(handles.speed,'Value'));% wait for next image
|
---|
| 1953 | end
|
---|
| 1954 | set(handles.movie_pair,'BackgroundColor',[1 0 0])%paint the command button in red
|
---|
| 1955 |
|
---|
[59] | 1956 | %------------------------------------------------------------------------
|
---|
[2] | 1957 | % --- Executes on button press in run0.
|
---|
| 1958 | function run0_Callback(hObject, eventdata, handles)
|
---|
[59] | 1959 | %------------------------------------------------------------------------
|
---|
[85] | 1960 | set(handles.run0,'BackgroundColor',[1 1 0])%paint the command button in yellow
|
---|
| 1961 | drawnow
|
---|
[59] | 1962 | filename=read_file_boxes(handles);
|
---|
[2] | 1963 |
|
---|
[59] | 1964 | filename_1=[];%default
|
---|
| 1965 | if get(handles.SubField,'Value')
|
---|
| 1966 | filename_1=read_file_boxes_1(handles);
|
---|
| 1967 | end
|
---|
| 1968 | num_i1=stra2num(get(handles.i1,'String'));
|
---|
| 1969 | num_i2=stra2num(get(handles.i2,'String'));
|
---|
| 1970 | num_j1=stra2num(get(handles.j1,'String'));
|
---|
| 1971 | num_j2=stra2num(get(handles.j2,'String'));
|
---|
| 1972 | errormsg=refresh_field(handles,filename,filename_1,num_i1,num_i2,num_j1,num_j2);
|
---|
| 1973 | if ~isempty(errormsg)
|
---|
| 1974 | msgbox_uvmat('ERROR',errormsg);
|
---|
| 1975 | end
|
---|
[85] | 1976 | set(handles.run0,'BackgroundColor',[1 0 0])
|
---|
[59] | 1977 | %------------------------------------------------------------------------
|
---|
| 1978 | % --- read the input files and refresh all the plots, including projection.
|
---|
| 1979 | % OUTPUT:
|
---|
| 1980 | % errormsg: error message char string =[] by default
|
---|
| 1981 | % INPUT:
|
---|
| 1982 | % filename: first input file (=[] in the absence of input file)
|
---|
| 1983 | % filename_1: second input file (=[] in the asbsenc of secodn input file)
|
---|
| 1984 | % num_i1,num_i2,num_j1,num_j2; frame indices
|
---|
| 1985 | % Field: structure describing an optional input field (then replace the input file)
|
---|
| 1986 |
|
---|
| 1987 | function errormsg=refresh_field(handles,filename,filename_1,num_i1,num_i2,num_j1,num_j2,Field)
|
---|
| 1988 | %------------------------------------------------------------------------
|
---|
[81] | 1989 |
|
---|
[2] | 1990 | %initialisation
|
---|
[85] | 1991 |
|
---|
[59] | 1992 | errormsg=[]; % default error message
|
---|
[2] | 1993 | abstime=[];
|
---|
| 1994 | abstime_1=[];
|
---|
| 1995 | dt=[];
|
---|
[59] | 1996 | if ~exist('Field','var')
|
---|
| 1997 | Field={};
|
---|
| 1998 | end
|
---|
[45] | 1999 | UvData=get(handles.uvmat,'UserData');
|
---|
[75] | 2000 | %UvData =structure containing information stored outside the uicontrol of uvmat
|
---|
| 2001 | % .NewSeries: =1 for a new series (new root fiel introduced), 0 else
|
---|
| 2002 | % .MovieObject: movie object representing an input movie
|
---|
| 2003 | % .MovieObject_1: idem for a second input series (_1)
|
---|
| 2004 | % .filename_1 : last second input file name (to deal with a constant second input without reading again the file)
|
---|
| 2005 | % .VelType_1: last velocity type (civ1, civ2...) for the second input series
|
---|
| 2006 | % .FieldName_1: last field name(velocity, vorticity...) for the second input series
|
---|
| 2007 | % .NbDim: number of space dimensions of the input field
|
---|
| 2008 | % .ZMin, .ZMax: range of the z coordinate
|
---|
| 2009 | %..... to complement
|
---|
| 2010 |
|
---|
[2] | 2011 | if ishandle(handles.UVMAT_title) %remove title panel on uvmat
|
---|
| 2012 | delete(handles.UVMAT_title)
|
---|
| 2013 | end
|
---|
| 2014 |
|
---|
| 2015 | % determine the main input file information for action
|
---|
[45] | 2016 | FileType=[];%default
|
---|
[59] | 2017 | if ~isempty(filename)
|
---|
[2] | 2018 | if ~exist(filename,'file')
|
---|
[59] | 2019 | errormsg=['input file ' filename ' does not exist'];
|
---|
[2] | 2020 | return
|
---|
| 2021 | end
|
---|
[59] | 2022 | Ext=get(handles.FileExt,'String');
|
---|
[2] | 2023 | NomType=get(handles.FileIndex,'UserData');
|
---|
| 2024 | %update the z position index
|
---|
[60] | 2025 | nbslice_str=get(handles.nb_slice,'String');
|
---|
| 2026 | z_index=1;%default
|
---|
| 2027 | if isequal(nbslice_str,'volume')
|
---|
| 2028 | z_index=num_j1;
|
---|
| 2029 | set(handles.z_index,'String',num2str(z_index))
|
---|
| 2030 | else
|
---|
| 2031 | nbslice=str2num(nbslice_str);
|
---|
[2] | 2032 | z_index=mod(num_i1-1,nbslice)+1;
|
---|
| 2033 | set(handles.z_index,'String',num2str(z_index))
|
---|
| 2034 | end
|
---|
[60] | 2035 | % refresh menu for save_mask if relevant
|
---|
| 2036 | masknumber=get(handles.masklevel,'String');
|
---|
| 2037 | if length(masknumber)>=z_index
|
---|
| 2038 | set(handles.masklevel,'Value',z_index)
|
---|
| 2039 | end
|
---|
| 2040 |
|
---|
[45] | 2041 | % determine the input file type
|
---|
| 2042 | if isequal(Ext,'.nc')||isequal(Ext,'.cdf')
|
---|
| 2043 | FileType='netcdf';
|
---|
| 2044 | elseif isfield(UvData,'MovieObject')
|
---|
| 2045 | FileType='movie';
|
---|
| 2046 | FieldName='image';
|
---|
| 2047 | elseif isequal(lower(Ext),'.avi')
|
---|
| 2048 | FileType='avi';
|
---|
| 2049 | FieldName='image';
|
---|
| 2050 | elseif isequal(lower(Ext),'.vol')
|
---|
| 2051 | FileType='vol';
|
---|
| 2052 | FieldName='image';
|
---|
[2] | 2053 | else
|
---|
| 2054 | form=imformats(Ext([2:end]));
|
---|
| 2055 | if ~isempty(form)% if the extension corresponds to an image format recognized by Matlab
|
---|
[45] | 2056 | if isequal(NomType,'*');
|
---|
| 2057 | FileType='multimage';
|
---|
| 2058 | else
|
---|
| 2059 | FileType='image';
|
---|
| 2060 | end
|
---|
[2] | 2061 | FieldName='image';
|
---|
| 2062 | end
|
---|
| 2063 | end
|
---|
| 2064 | else
|
---|
[45] | 2065 | FileType='netcdf';
|
---|
[2] | 2066 | FieldName='get_field...';
|
---|
| 2067 | end
|
---|
| 2068 | VelType=[];%default
|
---|
[45] | 2069 | if isequal(FileType,'netcdf')
|
---|
[2] | 2070 | list_fields=get(handles.Fields,'String');% list menu fields
|
---|
| 2071 | index_fields=get(handles.Fields,'Value');% selected string index
|
---|
| 2072 | FieldName= list_fields{index_fields}; % selected field
|
---|
[59] | 2073 | if ~isequal(FieldName,'get_field...')% read the field names on the interface get_field...
|
---|
[2] | 2074 | VelType=setfield(handles);
|
---|
| 2075 | end
|
---|
| 2076 | end
|
---|
| 2077 |
|
---|
| 2078 | % choose a second field if Subfield option is 'on'
|
---|
| 2079 | FieldName_1=[];
|
---|
| 2080 | scal_color=[];
|
---|
| 2081 | VelType_1=setfield_1(handles);
|
---|
| 2082 | sub_value=get(handles.SubField,'Value');
|
---|
[45] | 2083 | FileType_1='none';%default
|
---|
[59] | 2084 | if ~isempty(filename_1)
|
---|
| 2085 | % test for a constant second field (comparison with a fixed field)
|
---|
[2] | 2086 | NomType_1=get(handles.FileIndex_1,'UserData');
|
---|
[71] | 2087 | Ext_1=get(handles.FileExt_1,'String');
|
---|
[45] | 2088 | % determine the input file type
|
---|
| 2089 | if isequal(Ext_1,'.nc')||isequal(Ext_1,'.cdf')
|
---|
| 2090 | FileType_1='netcdf';
|
---|
| 2091 | elseif isfield(UvData,'MovieObject_1')
|
---|
| 2092 | FileType_1='movie';
|
---|
| 2093 | FieldName_1='image';
|
---|
| 2094 | elseif isequal(lower(Ext_1),'.avi')
|
---|
| 2095 | FileType='avi';
|
---|
| 2096 | FieldName_1='image';
|
---|
| 2097 | elseif isequal(lower(Ext_1),'.vol')
|
---|
| 2098 | FileType_1='vol';
|
---|
| 2099 | FieldName_1='image';
|
---|
| 2100 | else
|
---|
[65] | 2101 | form=imformats(Ext_1([2:end]));
|
---|
[45] | 2102 | if ~isempty(form)% if the extension corresponds to an image format recognized by Matlab
|
---|
| 2103 | if isequal(NomType_1,'*');
|
---|
| 2104 | FileType_1='multimage';
|
---|
| 2105 | else
|
---|
| 2106 | FileType_1='image';
|
---|
| 2107 | end
|
---|
| 2108 | FieldName_1='image';
|
---|
| 2109 | end
|
---|
| 2110 | end
|
---|
| 2111 | if ~isequal(FieldName_1,'image')
|
---|
| 2112 | list_fields=get(handles.Fields_1,'String');% list menu fields
|
---|
| 2113 | index_fields=get(handles.Fields_1,'Value');% selected string index
|
---|
| 2114 | FieldName_1= list_fields{index_fields}; % selected field
|
---|
| 2115 | if isequal(VelType_1,'*')% free veltype choice
|
---|
[2] | 2116 | VelType_1=[];
|
---|
[45] | 2117 | elseif isequal(VelType_1,'"')% veltype the same as for the first field
|
---|
| 2118 | if isempty(VelType)
|
---|
| 2119 | VelType_1=[];
|
---|
| 2120 | else
|
---|
| 2121 | VelType_1=VelType;
|
---|
| 2122 | end
|
---|
[2] | 2123 | end
|
---|
| 2124 | end
|
---|
[59] | 2125 | test_keepdata_1=0;% test for keeping the previous stored data if the input files are unchanged
|
---|
| 2126 | if ~isequal(NomType_1,'*')%in case of a series of files (not avi movie)
|
---|
[45] | 2127 | if isfield(UvData,'filename_1')&& isfield(UvData,'VelType_1') && isfield(UvData,'FieldName_1')
|
---|
| 2128 | test_keepdata_1= isequal(filename_1,UvData.filename_1)&&...
|
---|
| 2129 | isequal(VelType_1,UvData.filename_1) && isequal(FieldName_1,UvData.FieldName_1);
|
---|
[2] | 2130 | end
|
---|
| 2131 | end
|
---|
[59] | 2132 | if test_keepdata_1
|
---|
| 2133 | Field{2}=UvData.Field_1;
|
---|
| 2134 | elseif ~exist(filename_1,'file')
|
---|
| 2135 | errormsg=['second file ' filename_1 ' does not exist'];
|
---|
| 2136 | return
|
---|
| 2137 | end
|
---|
[2] | 2138 | end
|
---|
| 2139 |
|
---|
| 2140 | %read the input field(s)
|
---|
| 2141 | %read images
|
---|
[45] | 2142 | if ~isempty(filename) && isequal(FieldName,'image')
|
---|
| 2143 | switch FileType
|
---|
| 2144 | case 'movie'
|
---|
[84] | 2145 | try
|
---|
| 2146 | A=read(UvData.MovieObject,num_i1);
|
---|
| 2147 | catch
|
---|
| 2148 | errormsg=lasterr;
|
---|
| 2149 | return
|
---|
| 2150 | end
|
---|
[45] | 2151 | case 'avi'
|
---|
[84] | 2152 | try
|
---|
| 2153 | mov=aviread(filename,num_i1);
|
---|
| 2154 | catch
|
---|
| 2155 | errormsg=lasterr;
|
---|
| 2156 | return
|
---|
| 2157 | end
|
---|
[45] | 2158 | A=frame2im(mov(1));
|
---|
| 2159 | case 'vol'
|
---|
| 2160 | A=imread(filename);
|
---|
| 2161 | case 'multimage'
|
---|
| 2162 | A=imread(filename,num_i1);
|
---|
| 2163 | case 'image'
|
---|
| 2164 | A=imread(filename);
|
---|
[2] | 2165 | end
|
---|
| 2166 | npxy=size(A);
|
---|
| 2167 | set(handles.npx,'String',num2str(npxy(2)));% display image size on the interface
|
---|
| 2168 | set(handles.npy,'String',num2str(npxy(1)));
|
---|
| 2169 | Rangx=[0.5 npxy(2)-0.5]; % coordinates of the first and last pixel centers
|
---|
| 2170 | Rangy=[npxy(1)-0.5 0.5]; %
|
---|
| 2171 | Field{1}.AName='image';
|
---|
| 2172 | Field{1}.ListVarName={'AY','AX','A'}; %
|
---|
| 2173 | if size(A,3)==3;%color
|
---|
| 2174 | Field{1}.VarDimName={'AY','AX',{'AY','AX','rgb'}}; %
|
---|
| 2175 | else
|
---|
| 2176 | Field{1}.VarDimName={'AY','AX',{'AY','AX'}}; %
|
---|
| 2177 | end
|
---|
| 2178 | Field{1}.AY=Rangy;
|
---|
| 2179 | Field{1}.AX=Rangx;
|
---|
| 2180 | Field{1}.A=A;
|
---|
| 2181 | Field{1}.CoordType='px'; %used for mouse_motion
|
---|
| 2182 | Field{1}.CoordUnit='pixel'; %used for mouse_motion
|
---|
| 2183 | end
|
---|
[56] | 2184 |
|
---|
| 2185 | %read a second image
|
---|
[59] | 2186 | if ~isempty(filename_1) && ~test_keepdata_1 && isequal(FieldName_1,'image')
|
---|
[45] | 2187 | switch FileType_1
|
---|
| 2188 | case 'movie'
|
---|
| 2189 | A=read(UvData.MovieObject_1,num_i1);
|
---|
| 2190 | case 'avi'
|
---|
[65] | 2191 | mov=aviread(filename_1,num_i1);
|
---|
[45] | 2192 | A=frame2im(mov(1));
|
---|
| 2193 | case 'vol'
|
---|
[65] | 2194 | A=imread(filename_1);
|
---|
[45] | 2195 | case 'multimage'
|
---|
[65] | 2196 | A=imread(filename_1,num_i1);
|
---|
[45] | 2197 | case 'image'
|
---|
[65] | 2198 | A=imread(filename_1);
|
---|
| 2199 | case 'netcdf'
|
---|
| 2200 | otherwise
|
---|
| 2201 | errormsg=['unknown input file type ' filename_1];
|
---|
[45] | 2202 | end
|
---|
[2] | 2203 | npxy=size(A);
|
---|
| 2204 | set(handles.npx,'String',num2str(npxy(2)));% display image size on the interface
|
---|
| 2205 | set(handles.npy,'String',num2str(npxy(1)));
|
---|
| 2206 | Rangx=[0.5 npxy(2)-0.5]; % coordinates of the first and last pixel centers
|
---|
| 2207 | Rangy=[npxy(1)-0.5 0.5]; %
|
---|
| 2208 | Field{2}.AName='image';
|
---|
| 2209 | Field{2}.ListVarName={'AY','AX','A'}; %
|
---|
| 2210 | if size(A,3)==3;%color
|
---|
| 2211 | Field{2}.VarDimName={'AY','AX',{'AY','AX','rgb'}}; %
|
---|
| 2212 | else
|
---|
| 2213 | Field{2}.VarDimName={'AY','AX',{'AY','AX'}}; %
|
---|
| 2214 | end
|
---|
| 2215 | Field{2}.AY=Rangy;
|
---|
| 2216 | Field{2}.AX=Rangx;
|
---|
| 2217 | Field{2}.A=A;
|
---|
| 2218 | Field{2}.CoordType='px'; %used for mouse_motion
|
---|
| 2219 | Field{2}.CoordUnit='px'; %used for move_mou
|
---|
| 2220 | end
|
---|
| 2221 |
|
---|
| 2222 | %read ncfile(s)
|
---|
| 2223 | CivStage_1=0;%default
|
---|
| 2224 | VelType_out_1=[];
|
---|
| 2225 | InputField={FieldName};
|
---|
| 2226 | InputField_1={FieldName_1};
|
---|
[59] | 2227 | if (~isempty(filename)&& isequal(FileType,'netcdf')) || (~isempty(filename_1)&& isequal(FileType_1,'netcdf')) ;
|
---|
[2] | 2228 | %read the velocity field(s) from netcdf rootfile(s)
|
---|
| 2229 | list_code=get(handles.col_vec,'String');% list menu fields
|
---|
| 2230 | index_code=get(handles.col_vec,'Value');% selected string index
|
---|
| 2231 | scal_color= list_code{index_code(1)}; % selected field
|
---|
| 2232 | if isequal(FieldName,'velocity')&& ~isequal(scal_color,'black') && ~isequal(scal_color,'white')
|
---|
| 2233 | InputField=[InputField scal_color];
|
---|
| 2234 | end
|
---|
| 2235 | if isequal(FieldName_1,'velocity') && ~isequal(scal_color,'black') && ~isequal(scal_color,'white')
|
---|
| 2236 | InputField_1=[InputField_1 scal_color];
|
---|
| 2237 | end
|
---|
[45] | 2238 | if isequal(FileType,'netcdf') %read the first nc field
|
---|
[2] | 2239 | if isequal(FieldName,'get_field...')% read the field names on the interface get_field.
|
---|
[59] | 2240 | %VelType=get(handles.Fields,'UserData');
|
---|
[2] | 2241 | hget_field=findobj(allchild(0),'Name','get_field');%find the get_field... GUI
|
---|
| 2242 | if isempty(hget_field)
|
---|
| 2243 | hget_field= get_field(filename);%open the get_field GUI
|
---|
| 2244 | end
|
---|
| 2245 | hhget_field=guidata(hget_field);
|
---|
| 2246 | set(hhget_field.inputfile,'String',filename)% update the list of input fields in get_field
|
---|
| 2247 | set(hhget_field.ACTION,'Value',1)% PLOT option selected
|
---|
| 2248 | set(hhget_field.list_fig,'Value',2)% plotting axes =uvmat selected
|
---|
| 2249 | [Field{1},errormsg]=read_get_field(hget_field); %read the names of the variables to plot in the get_field GUI
|
---|
| 2250 | if ~isempty(errormsg)
|
---|
[59] | 2251 | errormsg=['error in uvmat/run0_Callback/read_get_field: ' errormsg];
|
---|
[2] | 2252 | return
|
---|
| 2253 | end
|
---|
| 2254 | CivStage=0;
|
---|
| 2255 | VelType_out=[];
|
---|
| 2256 | else
|
---|
| 2257 | [Field{1},VelType_out]=read_civxdata(filename,InputField,VelType);
|
---|
| 2258 | if isfield(Field{1},'Txt')
|
---|
[59] | 2259 | errormsg=Field{1}.Txt;
|
---|
[2] | 2260 | return
|
---|
| 2261 | end
|
---|
| 2262 | CivStage=Field{1}.CivStage;
|
---|
| 2263 | UvData.NbDim=Field{1}.nb_dim;
|
---|
| 2264 | end
|
---|
| 2265 | end
|
---|
[59] | 2266 | if ~isempty(filename_1) && ~test_keepdata_1 && isequal(FileType_1,'netcdf') %read the second file
|
---|
[2] | 2267 | if isequal(FieldName_1,'get_field...')% read the field names on the interface get_field.
|
---|
| 2268 | hget_field=findobj(allchild(0),'Name','get_field_1');%find the get_field... GUI
|
---|
| 2269 | if isempty(hget_field)
|
---|
| 2270 | hget_field= get_field(filename_1);%open the get_field GUI
|
---|
| 2271 | set(hget_field,'name','get_field_1')
|
---|
| 2272 | % enable_transform(handles,'off')% no field transform (possible transform in the GUI get_field)
|
---|
| 2273 | end
|
---|
| 2274 | hhget_field=guidata(hget_field);%handles of GUI elements in get_field
|
---|
| 2275 | SubField=get_field('read_var_names',hObject,eventdata,hhget_field); %read the names of the variables to plot in the get_field GUI
|
---|
| 2276 | [Field{2},var_detect]=nc2struct(filename_1,SubField.ListVarName); %read the corresponding input data
|
---|
| 2277 | Field{2}.VarAttribute=SubField.VarAttribute;
|
---|
| 2278 | %update the display on get_field
|
---|
| 2279 | set(hhget_field.inputfile,'String',filename_1)
|
---|
| 2280 | set(hhget_field.variables,'Value',1)
|
---|
| 2281 | Tabchar={''};%default
|
---|
| 2282 | Tabcell=[];
|
---|
| 2283 | if isfield(Field{2},'ListGlobalAttribute')& ~isempty(Field{2}.ListGlobalAttribute)
|
---|
| 2284 | for iline=1:length(Field{2}.ListGlobalAttribute)
|
---|
| 2285 | Tabcell{iline,1}=Field{2}.ListGlobalAttribute{iline};
|
---|
| 2286 | if isfield(Field{2}, Field{2}.ListGlobalAttribute{iline})
|
---|
| 2287 | eval(['val=Field{2}.' Field{2}.ListGlobalAttribute{iline} ';'])
|
---|
| 2288 | if ischar(val);
|
---|
| 2289 | Tabcell{iline,2}=val;
|
---|
| 2290 | else
|
---|
| 2291 | Tabcell{iline,2}=num2str(val);
|
---|
| 2292 | end
|
---|
| 2293 | end
|
---|
| 2294 | end
|
---|
| 2295 | if ~isempty(Tabcell)
|
---|
| 2296 | Tabchar=cell2tab(Tabcell,'=');
|
---|
| 2297 | Tabchar=[{''};Tabchar];
|
---|
| 2298 | end
|
---|
| 2299 | end
|
---|
| 2300 | set(hhget_field.attributes,'String',Tabchar);%update list of global attributes in get_field
|
---|
| 2301 | else
|
---|
[86] | 2302 | [Field{2},VelType_out_1]=read_civxdata(filename_1,InputField_1,VelType_1);
|
---|
[2] | 2303 | CivStage_1=Field{2}.CivStage;
|
---|
| 2304 | end
|
---|
[45] | 2305 | if ~isequal(FileType,'netcdf')
|
---|
[2] | 2306 | VelType_out=VelType_out_1;
|
---|
| 2307 | end
|
---|
| 2308 | end
|
---|
| 2309 | end
|
---|
| 2310 |
|
---|
[59] | 2311 | %store the second field for possible latter use
|
---|
| 2312 | if numel(Field)==2
|
---|
| 2313 | UvData.Field_1=Field{2};
|
---|
| 2314 | end
|
---|
| 2315 |
|
---|
[2] | 2316 | %update the display buttons for the first velocity type (first menuline)
|
---|
| 2317 | veltype_handles=[handles.civ1 handles.interp1 handles.filter1 handles.civ2 handles.interp2 handles.filter2];
|
---|
[45] | 2318 | if ~isequal(FileType,'netcdf')
|
---|
[2] | 2319 | reset_vel_type(veltype_handles)
|
---|
[59] | 2320 | elseif isempty(VelType) && ~isequal(FieldName,'get_field...')
|
---|
[2] | 2321 | set_veltype_display(veltype_handles,CivStage)%update the display of available velocity types for the first field
|
---|
| 2322 | if isempty(VelType_out)
|
---|
| 2323 | reset_vel_type(veltype_handles)
|
---|
| 2324 | else
|
---|
| 2325 | handle1=eval(['handles.' VelType_out]);
|
---|
| 2326 | reset_vel_type(veltype_handles,handle1)
|
---|
| 2327 | end
|
---|
| 2328 | end
|
---|
| 2329 |
|
---|
| 2330 | %update the display buttons for the second velocity type (second menuline)
|
---|
| 2331 | veltype_handles_1=[handles.civ1_1 handles.interp1_1 handles.filter1_1 handles.civ2_1 handles.interp2_1 handles.filter2_1];
|
---|
[45] | 2332 | if ~isequal(FileType_1,'netcdf')
|
---|
[2] | 2333 | reset_vel_type(veltype_handles_1)
|
---|
[59] | 2334 | elseif isempty(VelType_1) && ~isequal(FieldName_1,'get_field...')
|
---|
[2] | 2335 | set_veltype_display(veltype_handles_1,CivStage_1)%update the display of available velocity types for the first field
|
---|
| 2336 | if isempty(VelType_out_1)
|
---|
| 2337 | reset_vel_type(veltype_handles_1)
|
---|
| 2338 | else
|
---|
| 2339 | handle1=eval(['handles.' VelType_out_1 '_1']);
|
---|
| 2340 | reset_vel_type(veltype_handles_1,handle1)
|
---|
| 2341 | end
|
---|
| 2342 | end
|
---|
| 2343 |
|
---|
| 2344 | %introduce w as background image by default for a new series (only for nbdim=2)
|
---|
| 2345 | if ~isfield(UvData,'NewSeries')
|
---|
| 2346 | UvData.NewSeries=1;
|
---|
| 2347 | end
|
---|
| 2348 | %put W as background image by default if NbDim=2:
|
---|
[45] | 2349 | if ~isfield(UvData,'NbDim')||isempty(UvData.NbDim)||~isequal(UvData.NbDim,3)
|
---|
[2] | 2350 | if UvData.NewSeries && isequal(get(handles.SubField,'Value'),0) && isfield(Field{1},'W') && ~isempty(Field{1}.W);
|
---|
| 2351 | set(handles.SubField,'Value',1);
|
---|
[45] | 2352 | %menu=update_menu(handles.Fields_1,'w');%update the menu for the background scalar nd set the choice to 'w'
|
---|
[2] | 2353 | set(handles.RootPath_1,'String','"')
|
---|
| 2354 | set(handles.RootFile_1,'String','"')
|
---|
| 2355 | set(handles.SubDir_1,'String','"');
|
---|
| 2356 | [indices]=name_generator('',num_i1,num_j1,'',NomType,1,num_i2,num_j2,'');
|
---|
| 2357 | set(handles.FileIndex_1,'String',indices)
|
---|
| 2358 | set(handles.FileExt_1,'String','"');
|
---|
| 2359 | set(handles.Fields_1,'Visible','on');
|
---|
| 2360 | set(handles.Fields_1,'Visible','on');
|
---|
| 2361 | set(handles.RootPath_1,'Visible','on')
|
---|
| 2362 | set(handles.RootFile_1,'Visible','on')
|
---|
| 2363 | set(handles.SubDir_1,'Visible','on');
|
---|
| 2364 | set(handles.FileIndex_1,'Visible','on');
|
---|
| 2365 | set(handles.FileExt_1,'Visible','on');
|
---|
| 2366 | set(handles.Fields_1,'Visible','on');
|
---|
| 2367 | Field{1}.AName='w';
|
---|
| 2368 | testscal=1;
|
---|
| 2369 | end
|
---|
| 2370 | end
|
---|
| 2371 |
|
---|
| 2372 | %multislice case
|
---|
[59] | 2373 | if ~isempty(filename) &&(~isfield(UvData,'NbDim') || isequal(UvData.NbDim,2))&&...%2D case
|
---|
[2] | 2374 | isfield(UvData,'XmlData') && isfield(UvData.XmlData,'GeometryCalib')&& isfield(UvData.XmlData.GeometryCalib,'SliceCoord')
|
---|
| 2375 | siz=size(UvData.XmlData.GeometryCalib.SliceCoord);
|
---|
| 2376 | if siz(1)>1
|
---|
| 2377 | NbSlice=siz(1);
|
---|
[60] | 2378 | % set(handles.slices,'Visible','on')
|
---|
| 2379 | % set(handles.slices,'Value',1)
|
---|
[2] | 2380 | else
|
---|
| 2381 | NbSlice=1;
|
---|
| 2382 | end
|
---|
[60] | 2383 | %set(handles.nb_slice,'String',num2str(NbSlice))
|
---|
| 2384 | % slices_Callback(handles.uvmat, [], handles)
|
---|
[2] | 2385 | end
|
---|
| 2386 |
|
---|
| 2387 | %store the current open names, fields and vel types in uvmat interface
|
---|
| 2388 | UvData.filename=filename;
|
---|
| 2389 | UvData.filename_1=filename_1;
|
---|
| 2390 | UvData.VelType=VelType;
|
---|
| 2391 | UvData.VelType_1=VelType_1;
|
---|
| 2392 | UvData.FieldName=FieldName;
|
---|
| 2393 | UvData.FieldName_1=FieldName_1;
|
---|
| 2394 | if ~isempty(scal_color)
|
---|
| 2395 | UvData.CName=scal_color;
|
---|
| 2396 | end
|
---|
| 2397 |
|
---|
| 2398 | %coordinate transform or user fct
|
---|
| 2399 | XmlData=[];%default
|
---|
| 2400 | if isfield(UvData,'XmlData')%use geometry calib recorded from the ImaDoc xml file as first priority
|
---|
| 2401 | XmlData=UvData.XmlData;
|
---|
| 2402 | end
|
---|
| 2403 | XmlData_1=[];%default
|
---|
| 2404 | if isfield(UvData,'XmlData_1')
|
---|
| 2405 | XmlData_1=UvData.XmlData_1;
|
---|
| 2406 | end
|
---|
[39] | 2407 | menu_transform=get(handles.transform_fct,'String');
|
---|
| 2408 | choice_value=get(handles.transform_fct,'Value');
|
---|
| 2409 | transform_list=get(handles.transform_fct,'UserData');
|
---|
| 2410 | transform=transform_list{choice_value};%selected function handles
|
---|
[2] | 2411 |
|
---|
| 2412 | % z index
|
---|
[59] | 2413 | if ~isempty(filename)
|
---|
[60] | 2414 | Field{1}.ZIndex=z_index;
|
---|
[2] | 2415 | end
|
---|
[59] | 2416 |
|
---|
[2] | 2417 | %px to phys or other transform on field
|
---|
[59] | 2418 | if ~isempty(transform)
|
---|
[2] | 2419 | if length(Field)>=2
|
---|
[60] | 2420 | Field{2}.ZIndex=z_index;
|
---|
[38] | 2421 | [Field{1},Field{2}]=transform(Field{1},XmlData,Field{2},XmlData_1);
|
---|
[2] | 2422 | if isempty(Field{2})
|
---|
| 2423 | Field(2)=[];
|
---|
| 2424 | end
|
---|
| 2425 | else
|
---|
[38] | 2426 | Field{1}=transform(Field{1},XmlData);
|
---|
[2] | 2427 | end
|
---|
| 2428 | end
|
---|
| 2429 |
|
---|
| 2430 | %calculate scalar
|
---|
[45] | 2431 | if isequal(FileType,'netcdf') && ~isequal(FieldName,'get_field...')%
|
---|
[2] | 2432 | Field{1}=calc_field(InputField,Field{1});
|
---|
| 2433 | end
|
---|
[59] | 2434 | if length(Field)==2 && ~test_keepdata_1 && isequal(FileType_1,'netcdf') && ~isequal(FieldName_1,'get_field...')
|
---|
[2] | 2435 | Field{2}=calc_field(InputField_1,Field{2});
|
---|
| 2436 | end
|
---|
| 2437 |
|
---|
| 2438 | % combine the two input fields (e.g. substract velocity fields)
|
---|
| 2439 | if numel(Field)==2
|
---|
[59] | 2440 | UvData.Field=sub_field(Field{1},Field{2}); %TO UPDATE FOR MORE GENERAL INPUT
|
---|
[2] | 2441 | else
|
---|
| 2442 | UvData.Field=Field{1};
|
---|
| 2443 | end
|
---|
[59] | 2444 |
|
---|
[2] | 2445 | % test 3D , default projection menuplane and typical mesh (needed to menuopen set_object)
|
---|
| 2446 | test_x=0;
|
---|
| 2447 | test_z=0;% test for unstructured z coordinate
|
---|
| 2448 | UvData.ZMax=0;
|
---|
| 2449 | UvData.ZMin=0;%default
|
---|
| 2450 | UvData.Mesh=1; %default
|
---|
| 2451 | [UvData.Field,errormsg]=check_field_structure(UvData.Field);
|
---|
| 2452 | if ~isempty(errormsg)
|
---|
[59] | 2453 | errormsg=['error in uvmat/run0_Callback/check_field_structure: ' errormsg];
|
---|
[2] | 2454 | return
|
---|
| 2455 | end
|
---|
| 2456 | [CellVarIndex,NbDim,VarType]=find_field_indices(UvData.Field);
|
---|
| 2457 | [NbDim,imax]=max(NbDim);
|
---|
| 2458 | if isempty(imax)
|
---|
[45] | 2459 | % DimVarIndex=0;
|
---|
[2] | 2460 | coord_x=[];
|
---|
| 2461 | else
|
---|
[45] | 2462 | % VarIndex=CellVarIndex{imax};
|
---|
[2] | 2463 | coord_x=VarType{imax}.coord_x;
|
---|
| 2464 | end
|
---|
[45] | 2465 | if isfield(UvData,'NbDim') && ~isempty(UvData.NbDim)
|
---|
[2] | 2466 | NbDim=UvData.NbDim;
|
---|
| 2467 | else
|
---|
| 2468 | UvData.NbDim=NbDim;
|
---|
| 2469 | end
|
---|
[45] | 2470 | if ~isempty(CellVarIndex) && ~isempty(VarType{imax}.coord_x) && ~isempty(VarType{imax}.coord_y) %unstructured coordinate z
|
---|
[2] | 2471 | XName=UvData.Field.ListVarName{VarType{imax}.coord_x};
|
---|
| 2472 | YName=UvData.Field.ListVarName{VarType{imax}.coord_y};
|
---|
| 2473 | test_x=1;
|
---|
[45] | 2474 | elseif isfield(UvData.Field,'X') && isfield(UvData.Field,'Y')
|
---|
[2] | 2475 | XName='X';
|
---|
| 2476 | YName='Y';
|
---|
| 2477 | test_x=1;
|
---|
| 2478 | end
|
---|
| 2479 | if test_x
|
---|
| 2480 | eval(['UvData.XMax=max(UvData.Field.' XName ');'])
|
---|
| 2481 | eval(['UvData.XMin=min(UvData.Field.' XName ');'])
|
---|
| 2482 | eval(['UvData.YMax=max(UvData.Field.' YName ');'])
|
---|
| 2483 | eval(['UvData.YMin=min(UvData.Field.' YName ');'])
|
---|
| 2484 | eval(['nbvec=length(UvData.Field.' XName ');'])
|
---|
| 2485 | if NbDim==3%
|
---|
[45] | 2486 | if ~isempty(CellVarIndex) && ~isempty(VarType{imax}.coord_z)%unstructured coordinate z
|
---|
[42] | 2487 | ZName=UvData.Field.ListVarName{VarType{imax}.coord_z};
|
---|
[2] | 2488 | eval(['UvData.ZMax=max(UvData.Field.' ZName ');'])
|
---|
| 2489 | eval(['UvData.ZMin=min(UvData.Field.' ZName ');'])
|
---|
| 2490 | test_z=1;
|
---|
| 2491 | elseif isfield(UvData,'Z')% usual civ data
|
---|
| 2492 | UvData.ZMax=max(UvData.Z);
|
---|
| 2493 | UvData.ZMin=min(UvData.Z);
|
---|
| 2494 | test_z=1;
|
---|
| 2495 | end
|
---|
| 2496 | end
|
---|
| 2497 | if isequal(UvData.ZMin,UvData.ZMax)%no z dependency
|
---|
| 2498 | NbDim=2;
|
---|
| 2499 | test_z=0;
|
---|
| 2500 | end
|
---|
| 2501 | if test_z
|
---|
| 2502 | UvData.Mesh=((UvData.XMax-UvData.XMin)*(UvData.YMax-UvData.YMin)*(UvData.ZMax-UvData.ZMin))/nbvec;% volume per vector
|
---|
| 2503 | UvData.Mesh=(UvData.Mesh)^(1/3);
|
---|
| 2504 | else
|
---|
| 2505 | UvData.Mesh=sqrt((UvData.XMax-UvData.XMin)*(UvData.YMax-UvData.YMin)/nbvec);%2D
|
---|
| 2506 | end
|
---|
| 2507 | end
|
---|
| 2508 | %case of structured coordinates
|
---|
| 2509 | if isfield(UvData.Field,'AX') & isfield(UvData.Field,'AY')& isfield(UvData.Field,'A')
|
---|
| 2510 | UvData.XMax=max(UvData.Field.AX);
|
---|
| 2511 | UvData.XMin=min(UvData.Field.AX);
|
---|
| 2512 | UvData.YMax=max(UvData.Field.AY);
|
---|
| 2513 | UvData.YMin=min(UvData.Field.AY);
|
---|
| 2514 | np_A=size(UvData.Field.A);
|
---|
| 2515 | UvData.Mesh=sqrt((UvData.XMax-UvData.XMin)*(UvData.YMax-UvData.YMin)/((np_A(1)-1) * (np_A(2)-1))) ;
|
---|
| 2516 | end
|
---|
| 2517 | if isempty(coord_x)&~isempty(CellVarIndex)
|
---|
| 2518 | VarIndex=CellVarIndex{imax}; % list of variable indices
|
---|
| 2519 | DimIndex=UvData.Field.VarDimIndex{VarIndex(1)}; %list of dim indices for the variable
|
---|
| 2520 | if NbDim==3
|
---|
| 2521 | nbpoints=UvData.Field.DimValue(DimIndex(1));
|
---|
[72] | 2522 | if isfield(VarType{imax},'coord_3')&& ~isequal(VarType{imax}.coord_3,0) % z is a dimension variable
|
---|
[81] | 2523 | ZName=UvData.Field.ListVarName{VarType{imax}.coord_3};
|
---|
[2] | 2524 | eval(['UvData.ZMax=max(UvData.Field.' ZName ');'])
|
---|
| 2525 | eval(['UvData.ZMin=min(UvData.Field.' ZName ');'])
|
---|
| 2526 | else
|
---|
| 2527 | testcoord_z=0;
|
---|
| 2528 | if length(UvData.Field.VarAttribute)>=VarIndex(1)
|
---|
| 2529 | if isfield(UvData.Field.VarAttribute{VarIndex(1)},'Coord_1')%regular grid
|
---|
| 2530 | Coord_z=UvData.Field.VarAttribute{VarIndex(1)}.Coord_1;
|
---|
| 2531 | UvData.ZMax=max(Coord_z);
|
---|
| 2532 | UvData.ZMin=min(Coord_z);
|
---|
| 2533 | testcoord_z=1;
|
---|
| 2534 | end
|
---|
| 2535 | end
|
---|
| 2536 | if ~testcoord_z
|
---|
| 2537 | UvData.ZMin=1;
|
---|
| 2538 | UvData.ZMax=UvData.Field.DimValue(DimIndex(1));
|
---|
| 2539 | end
|
---|
| 2540 | end
|
---|
| 2541 | UvData.Mesh=(UvData.ZMax-UvData.ZMin)/(nbpoints-1);
|
---|
| 2542 | elseif NbDim==2
|
---|
| 2543 | nbpoints_y=UvData.Field.DimValue(DimIndex(1));
|
---|
| 2544 | Yvar=VarType{imax}.coord_y;
|
---|
| 2545 | if Yvar~=0 % x is a dimension variable
|
---|
| 2546 | YName=UvData.Field.ListVarName{Yvar};
|
---|
| 2547 | eval(['UvData.YMax=max(UvData.Field.' YName ');'])
|
---|
| 2548 | eval(['UvData.YMin=min(UvData.Field.' YName ');'])
|
---|
| 2549 | else
|
---|
| 2550 | testcoord_y=0;
|
---|
| 2551 | if ~testcoord_y
|
---|
| 2552 | UvData.YMin=1;
|
---|
| 2553 | UvData.YMax=UvData.Field.DimValue(DimIndex(1));
|
---|
| 2554 | end
|
---|
| 2555 | end
|
---|
| 2556 | DY=(UvData.YMax-UvData.YMin)/(nbpoints_y-1);
|
---|
| 2557 | nbpoints_x=UvData.Field.DimValue(DimIndex(2));
|
---|
| 2558 | Xvar=VarType{imax}.coord_x;
|
---|
| 2559 | if Xvar~=0 % x is a dimension variable
|
---|
| 2560 | XName=UvData.Field.ListVarName{Xvar};
|
---|
| 2561 | eval(['UvData.XMax=max(UvData.Field.' XName ');'])
|
---|
| 2562 | eval(['UvData.XMin=min(UvData.Field.' XName ');'])
|
---|
| 2563 | else
|
---|
| 2564 | testcoord_x=0;
|
---|
| 2565 | if ~testcoord_x
|
---|
| 2566 | UvData.XMin=1;
|
---|
| 2567 | UvData.XMax=UvData.Field.DimValue(DimIndex(2));
|
---|
| 2568 | end
|
---|
| 2569 | end
|
---|
| 2570 | DX=(UvData.XMax-UvData.XMin)/(nbpoints_x-1);
|
---|
| 2571 | UvData.Mesh= sqrt(DX*DY);
|
---|
| 2572 | end
|
---|
| 2573 | end
|
---|
| 2574 |
|
---|
| 2575 | %create a default projection menuplane
|
---|
| 2576 | UvData.Object{1}.Style='plane';%main plotting plane
|
---|
| 2577 | UvData.Object{1}.ProjMode='projection';%main plotting plane
|
---|
| 2578 | if ~isfield(UvData.Object{1},'plotaxes')
|
---|
| 2579 | UvData.Object{1}.plotaxes=handles.axes3;%default plotting axis
|
---|
[61] | 2580 | set(handles.list_object_1,'Value',1);
|
---|
[71] | 2581 | set(handles.list_object_1,'String',{'1-PLANE'});
|
---|
[2] | 2582 | end
|
---|
| 2583 |
|
---|
| 2584 | %3D case (menuvolume)
|
---|
[74] | 2585 | if NbDim==3 && UvData.NewSeries
|
---|
[2] | 2586 | UvData.Object{1}.NbDim=UvData.NbDim;%test for 3D objects
|
---|
| 2587 | UvData.Object{1}.RangeZ=UvData.Mesh;%main plotting plane
|
---|
| 2588 | UvData.Object{1}.Coord(1,3)=(UvData.ZMin+UvData.ZMax)/2;%section at a middle plane chosen
|
---|
| 2589 | UvData.Object{1}.Phi=0;
|
---|
| 2590 | UvData.Object{1}.Theta=0;
|
---|
| 2591 | UvData.Object{1}.Psi=0;
|
---|
| 2592 | UvData.Object{1}.HandlesDisplay=plot(0,0,'Tag','proj_object');% A REVOIR
|
---|
| 2593 | PlotHandles=get_plot_handles(handles);
|
---|
| 2594 | ZBounds(1)=UvData.ZMin; %minimum for the Z slider
|
---|
| 2595 | ZBounds(2)=UvData.ZMax;%maximum for the Z slider
|
---|
[72] | 2596 | UvData.Object{1}.Name='1-PLANE';
|
---|
| 2597 | UvData.Object{1}.enable_plot=1;
|
---|
[2] | 2598 | set_object(UvData.Object{1},PlotHandles,ZBounds);
|
---|
[61] | 2599 | set(handles.list_object_1,'Value',1);
|
---|
[2] | 2600 | %multilevel case (single menuplane in a 3D space)
|
---|
| 2601 | elseif isfield(UvData,'Z')
|
---|
| 2602 | if isfield(UvData,'CoordType')& isequal(UvData.CoordType,'phys') & isfield(UvData,'XmlData')
|
---|
| 2603 | XmlData=UvData.XmlData;
|
---|
| 2604 | if isfield(XmlData,'PlanePos')
|
---|
| 2605 | UvData.Object{1}.Coord=XmlData.PlanePos(UvData.ZIndex,:);
|
---|
| 2606 | end
|
---|
| 2607 | if isfield(XmlData,'PlaneAngle')
|
---|
| 2608 | siz=size(XmlData.PlaneAngle);
|
---|
| 2609 | indangle=min(siz(1),UvData.ZIndex);%take first angle if a single angle is defined (translating scanning)
|
---|
| 2610 | UvData.Object{1}.Phi=XmlData.PlaneAngle(indangle,1);
|
---|
| 2611 | UvData.Object{1}.Theta=XmlData.PlaneAngle(indangle,2);
|
---|
| 2612 | UvData.Object{1}.Psi=XmlData.PlaneAngle(indangle,3);
|
---|
| 2613 | end
|
---|
| 2614 | elseif isfield(UvData,'ZIndex')
|
---|
| 2615 | UvData.Object{1}.ZObject=UvData.ZIndex;
|
---|
| 2616 | end
|
---|
| 2617 | end
|
---|
| 2618 |
|
---|
| 2619 | %Plot the projections on all existing projection objects
|
---|
| 2620 | keeplim=get(handles.FixedLimits,'Value');
|
---|
| 2621 | %reset the min and max of scalar if only the mask is displayed
|
---|
| 2622 | if isfield(UvData,'Mask')&~isfield(UvData,'A')
|
---|
| 2623 | set(handles.MinA,'String','0')
|
---|
| 2624 | set(handles.MaxA,'String','255')
|
---|
| 2625 | end
|
---|
[65] | 2626 | IndexObj(1)=get(handles.list_object_1,'Value');
|
---|
| 2627 | if IndexObj(1)> numel(UvData.Object)
|
---|
| 2628 | IndexObj(1)=1;
|
---|
| 2629 | end
|
---|
| 2630 | IndexObj_2=get(handles.list_object_2,'Value');
|
---|
| 2631 | if IndexObj_2 <= numel(UvData.Object)
|
---|
| 2632 | IndexObj(2)=IndexObj_2;
|
---|
| 2633 | end
|
---|
[71] | 2634 | for imap=1:numel(IndexObj)
|
---|
| 2635 | iobj=IndexObj(imap);
|
---|
[65] | 2636 | if ~isempty(UvData.Object{iobj})%& isfield(Object{iobj},'plotaxes')& ishandle(Object{iobj}.plotaxes)
|
---|
[2] | 2637 | %Projeter les champs sur l'objet:*
|
---|
[65] | 2638 | ObjectData=proj_field(UvData.Field,UvData.Object{iobj},iobj);
|
---|
[71] | 2639 | if imap==2
|
---|
| 2640 | UvData.ProjField_2=ObjectData;%store the projection field on uvmat: ***** WILL REPLACE THE FIELD SORED ON THE AXES: AxeData *****
|
---|
| 2641 | else
|
---|
| 2642 | UvData.ProjField_1=ObjectData;%store the projection field on view_field
|
---|
| 2643 | end
|
---|
[2] | 2644 | %use of mask
|
---|
| 2645 | if isfield(ObjectData,'NbDim')&isequal(ObjectData.NbDim,2)
|
---|
| 2646 | if isfield(ObjectData,'Mask') & isfield(ObjectData,'A')
|
---|
| 2647 | flag_mask=double(ObjectData.Mask>200);%=0 for masked regions
|
---|
| 2648 | AX=ObjectData.AX;
|
---|
| 2649 | AY=ObjectData.AY;
|
---|
| 2650 | MaskX=ObjectData.MaskX;
|
---|
| 2651 | MaskY=ObjectData.MaskY;
|
---|
| 2652 | if ~isequal(MaskX,AX)|~isequal(MaskY,AY)
|
---|
| 2653 | nxy=size(flag_mask);
|
---|
| 2654 | sizpx=(ObjectData.MaskX(end)-ObjectData.MaskX(1))/(nxy(2)-1);%size of a mask pixel
|
---|
| 2655 | sizpy=(ObjectData.MaskY(1)-ObjectData.MaskY(end))/(nxy(1)-1);
|
---|
| 2656 | x_mask=[ObjectData.MaskX(1):sizpx:ObjectData.MaskX(end)]; % pixel x coordinates for image display
|
---|
| 2657 | y_mask=[ObjectData.MaskY(1):-sizpy:ObjectData.MaskY(end)];% pixel x coordinates for image display
|
---|
| 2658 | %project on the positions of the scalar
|
---|
| 2659 | npxy=size(ObjectData.A);
|
---|
| 2660 | dxy(1)=(ObjectData.AY(end)-ObjectData.AY(1))/(npxy(1)-1);%grid mesh in y
|
---|
| 2661 | dxy(2)=(ObjectData.AX(end)-ObjectData.AX(1))/(npxy(2)-1);%grid mesh in x
|
---|
| 2662 | xi=[ObjectData.AX(1):dxy(2):ObjectData.AX(end)];
|
---|
| 2663 | yi=[ObjectData.AY(1):dxy(1):ObjectData.AY(end)];
|
---|
| 2664 | [XI,YI]=meshgrid(xi,yi);% creates the matrix of regular coordinates
|
---|
| 2665 | flag_mask = interp2(x_mask,y_mask,flag_mask,XI,YI);
|
---|
| 2666 | end
|
---|
| 2667 | AClass=class(ObjectData.A);
|
---|
| 2668 | ObjectData.A=flag_mask.*double(ObjectData.A);
|
---|
| 2669 | ObjectData.A=feval(AClass,ObjectData.A);
|
---|
| 2670 | ind_off=[];
|
---|
| 2671 | if isfield(ObjectData,'ListVarName')
|
---|
| 2672 | for ilist=1:length(ObjectData.ListVarName)
|
---|
| 2673 | if isequal(ObjectData.ListVarName{ilist},'Mask')|isequal(ObjectData.ListVarName{ilist},'MaskX')|isequal(ObjectData.ListVarName{ilist},'MaskY')
|
---|
| 2674 | ind_off=[ind_off ilist];
|
---|
| 2675 | end
|
---|
| 2676 | end
|
---|
| 2677 | ObjectData.ListVarName(ind_off)=[];
|
---|
| 2678 | ObjectData.VarDimIndex(ind_off)=[];
|
---|
| 2679 | ind_off=[];
|
---|
| 2680 | for ilist=1:length(ObjectData.ListDimName)
|
---|
| 2681 | if isequal(ObjectData.ListDimName{ilist},'MaskX')|isequal(ObjectData.ListDimName{ilist},'MaskY')
|
---|
| 2682 | ind_off=[ind_off ilist];
|
---|
| 2683 | end
|
---|
| 2684 | end
|
---|
| 2685 | ObjectData.ListDimName(ind_off)=[];
|
---|
| 2686 | ObjectData.DimValue(ind_off)=[];
|
---|
| 2687 | end
|
---|
| 2688 | end
|
---|
| 2689 | end
|
---|
| 2690 | if ~isempty(ObjectData)
|
---|
| 2691 | haxes=[];%default
|
---|
[65] | 2692 | if isfield(UvData.Object{iobj},'plotaxes')
|
---|
| 2693 | haxes=UvData.Object{iobj}.plotaxes;%axes used for representing the projection on the object
|
---|
[2] | 2694 | end
|
---|
| 2695 | PosColorbar=[];%default: no colorbar
|
---|
| 2696 | if ishandle(haxes) & isequal(get(haxes,'Tag'),'axes3')& isfield(UvData,'PosColorbar')
|
---|
| 2697 | PosColorbar=UvData.PosColorbar;%prescribe the colorbar position on the uvmat interface
|
---|
| 2698 | else
|
---|
| 2699 | PosColorbar='*';%default position
|
---|
| 2700 | end
|
---|
| 2701 | PlotParam=read_plot_param(handles);%read plotting parameters on the uvmat interface
|
---|
| 2702 | [PlotType,ScalOut,UvData.Object{iobj}.plotaxes]=plot_field(ObjectData,haxes,PlotParam,keeplim,PosColorbar);
|
---|
| 2703 | if isequal(PlotType,'none')
|
---|
| 2704 | hget_field=findobj(allchild(0),'name','get_field');
|
---|
| 2705 | if isempty(hget_field)
|
---|
| 2706 | get_field([],ObjectData)% the projected field cannot be automatically plotted: use get_field to specify the variablesdelete(hget_field)
|
---|
| 2707 | else
|
---|
[59] | 2708 | errormsg='The field defined by get_field cannot be plotted';
|
---|
| 2709 | return
|
---|
[2] | 2710 | end
|
---|
| 2711 | end
|
---|
| 2712 | UvData.Object{iobj}.PlotParam=ScalOut; %record the plotting parameters
|
---|
[59] | 2713 | end
|
---|
[2] | 2714 | end
|
---|
| 2715 | end
|
---|
| 2716 |
|
---|
| 2717 | %display the updated plotting parameters for the base menuplane
|
---|
| 2718 | write_plot_param(handles,UvData.Object{1}.PlotParam);% update the display of the plotting parameters
|
---|
[74] | 2719 | UvData.NewSeries=0;% put to 0 the test for a new field series (set by RootPath_callback)
|
---|
[45] | 2720 | set(handles.uvmat,'UserData',UvData)
|
---|
[2] | 2721 |
|
---|
| 2722 | %update the mask
|
---|
| 2723 | if isequal(get(handles.mask_test,'Value'),1)%if the mask option is on
|
---|
| 2724 | update_mask(handles,num_i1,num_i2);
|
---|
| 2725 | end
|
---|
| 2726 |
|
---|
| 2727 | %prepare the menus of histograms (for the whole menuvolume in 3D case)
|
---|
| 2728 | menu_histo=(UvData.Field.ListVarName)';
|
---|
| 2729 | ind_bad=[];
|
---|
| 2730 | nb_histo=1;
|
---|
| 2731 | for ivar=1:numel(menu_histo)
|
---|
| 2732 | if isfield(UvData.Field,'VarAttribute') && numel(UvData.Field.VarAttribute)>=ivar && isfield(UvData.Field.VarAttribute{ivar},'Role')
|
---|
| 2733 | Role=UvData.Field.VarAttribute{ivar}.Role;
|
---|
| 2734 | switch Role
|
---|
| 2735 | case {'coord_x','coord_y','coord_z','dimvar'}
|
---|
| 2736 | ind_bad=[ind_bad ivar];
|
---|
| 2737 | case {'vector_y'}
|
---|
| 2738 | nb_histo=nb_histo+1;
|
---|
| 2739 | end
|
---|
| 2740 | end
|
---|
| 2741 | DimCell=UvData.Field.VarDimName{ivar};
|
---|
| 2742 | DimName='';
|
---|
| 2743 | if ischar(DimCell)
|
---|
| 2744 | DimName=DimCell;
|
---|
| 2745 | elseif iscell(DimCell)&& numel(DimCell)==1
|
---|
| 2746 | DimName=DimCell{1};
|
---|
| 2747 | end
|
---|
| 2748 | if strcmp(DimName,menu_histo{ivar})
|
---|
| 2749 | ind_bad=[ind_bad ivar];
|
---|
| 2750 | end
|
---|
| 2751 | end
|
---|
| 2752 | menu_histo(ind_bad)=[];
|
---|
| 2753 | test_v=0;
|
---|
| 2754 | if ~isempty(menu_histo)
|
---|
| 2755 | set(handles.histo1_menu,'Value',1)
|
---|
| 2756 | set(handles.histo1_menu,'String',menu_histo)
|
---|
[59] | 2757 | histo1_menu_Callback(handles.histo1_menu, [], handles)
|
---|
[2] | 2758 | if nb_histo > 1
|
---|
| 2759 | test_v=1;
|
---|
| 2760 | set(handles.histo2_menu,'Visible','on')
|
---|
| 2761 | set(handles.histo_v,'Visible','on')
|
---|
| 2762 | set(handles.histo2_menu,'String',menu_histo)
|
---|
| 2763 | set(handles.histo2_menu,'Value',2)
|
---|
[59] | 2764 | histo2_menu_Callback(handles.histo2_menu,[], handles)
|
---|
[2] | 2765 | end
|
---|
| 2766 | end
|
---|
| 2767 | if ~test_v
|
---|
| 2768 | set(handles.histo2_menu,'Visible','off')
|
---|
| 2769 | set(handles.histo_v,'Visible','off')
|
---|
| 2770 | cla(handles.histo_v)
|
---|
| 2771 | set(handles.histo2_menu,'Value',1)
|
---|
| 2772 | end
|
---|
| 2773 |
|
---|
| 2774 | %display time
|
---|
| 2775 | testimedoc=0;
|
---|
| 2776 | if isfield(UvData,'XmlData') && isfield(UvData.XmlData,'Time')
|
---|
| 2777 | if isempty(num_i2)
|
---|
| 2778 | num_i2=num_i1;
|
---|
| 2779 | end
|
---|
| 2780 | if isempty(num_j1)
|
---|
| 2781 | num_j1=1;
|
---|
| 2782 | end
|
---|
| 2783 | if isempty(num_j2)
|
---|
| 2784 | num_j2=num_j1;
|
---|
| 2785 | end
|
---|
| 2786 | siz=size(UvData.XmlData.Time);
|
---|
| 2787 | if siz(1)>=max(num_i1,num_i2) & siz(2)>=max(num_j1,num_j2)
|
---|
| 2788 | abstime=(UvData.XmlData.Time(num_i1,num_j1)+UvData.XmlData.Time(num_i2,num_j2))/2;%overset the time read from files
|
---|
| 2789 | dt=(UvData.XmlData.Time(num_i2,num_j2)-UvData.XmlData.Time(num_i1,num_j1));
|
---|
| 2790 | testimedoc=1;
|
---|
| 2791 | end
|
---|
| 2792 | end
|
---|
| 2793 | if isfield(UvData,'XmlData_1') && isfield(UvData.XmlData_1,'Time')
|
---|
| 2794 | [P,F,str1,str2,str_a,str_b,E,NomType]=name2display(['xx' get(handles.FileIndex_1,'String') get(handles.FileExt_1,'String')]);
|
---|
| 2795 | num_i2=str2num(str2);
|
---|
| 2796 | if isempty(num_i2)
|
---|
| 2797 | num_i2=num_i1;
|
---|
| 2798 | end
|
---|
| 2799 | num_j1=str2num(str_a);
|
---|
| 2800 | if isempty(num_j1)
|
---|
| 2801 | num_j1=1;
|
---|
| 2802 | end
|
---|
| 2803 | num_j2=str2num(str_b);
|
---|
| 2804 | if isempty(num_j2)
|
---|
| 2805 | num_j2=num_j1;
|
---|
| 2806 | end
|
---|
| 2807 | num_i1=str2num(str1);
|
---|
| 2808 | siz=size(UvData.XmlData_1.Time);
|
---|
| 2809 | if siz(1)>=max(num_i1,num_i2) & siz(2)>=max(num_j1,num_j2)
|
---|
| 2810 | 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
|
---|
| 2811 | end
|
---|
| 2812 | end
|
---|
| 2813 | set(handles.abs_time,'String',num2str(abstime,4))
|
---|
| 2814 | set(handles.abs_time_1,'String',num2str(abstime_1,4))
|
---|
| 2815 | if testimedoc && isfield(UvData,'dt')
|
---|
| 2816 | dt=UvData.dt;
|
---|
| 2817 | end
|
---|
| 2818 | if isequal(dt,0)
|
---|
| 2819 | set(handles.Dt_txt,'String','')
|
---|
| 2820 | else
|
---|
| 2821 | if ~(isfield(UvData,'TimeUnit') && ~isempty(UvData.TimeUnit))
|
---|
| 2822 | set(handles.Dt_txt,'String',['Dt=' num2str(1000*dt,3) ' 10^(-3)'] )
|
---|
| 2823 | else
|
---|
| 2824 | set(handles.Dt_txt,'String',['Dt=' num2str(1000*dt,3) ' m' UvData.TimeUnit] )
|
---|
| 2825 | end
|
---|
| 2826 | end
|
---|
| 2827 |
|
---|
| 2828 |
|
---|
| 2829 |
|
---|
[85] | 2830 |
|
---|
[2] | 2831 | %-------------------------------------------------------------------
|
---|
| 2832 | % --- translate coordinate to matrix index
|
---|
| 2833 | %-------------------------------------------------------------------
|
---|
| 2834 | function [indx,indy]=pos2ind(x0,rangx0,nxy)
|
---|
| 2835 | indx=1+round((nxy(2)-1)*(x0-rangx0(1))/(rangx0(2)-rangx0(1)));% index x of pixel
|
---|
| 2836 | indy=1+round((nxy(1)-1)*(y12-rangy0(1))/(rangy0(2)-rangy0(1)));% index y of pixel
|
---|
| 2837 |
|
---|
| 2838 | %-------------------------------------------------------------------
|
---|
| 2839 | % --- Executes on button press in 'FixedLimits'.
|
---|
| 2840 | %-------------------------------------------------------------------
|
---|
| 2841 | function FixedLimits_Callback(hObject, eventdata, handles)
|
---|
| 2842 | test=get(handles.FixedLimits,'Value');
|
---|
| 2843 | if test
|
---|
| 2844 | set(handles.FixedLimits,'BackgroundColor',[1 1 0])
|
---|
| 2845 | else
|
---|
| 2846 | set(handles.FixedLimits,'BackgroundColor',[0.7 0.7 0.7])
|
---|
[84] | 2847 | update_plot(handles);
|
---|
[2] | 2848 | end
|
---|
| 2849 |
|
---|
| 2850 | %-------------------------------------------------------------------
|
---|
| 2851 | % --- Executes on button press in auto_xy.
|
---|
| 2852 | function auto_xy_Callback(hObject, eventdata, handles)
|
---|
| 2853 | test=get(handles.auto_xy,'Value');
|
---|
| 2854 | if test
|
---|
| 2855 | set(handles.auto_xy,'BackgroundColor',[1 1 0])
|
---|
| 2856 | cla(handles.axes3)
|
---|
| 2857 | update_plot(handles)
|
---|
| 2858 | else
|
---|
| 2859 | set(handles.auto_xy,'BackgroundColor',[0.7 0.7 0.7])
|
---|
| 2860 | update_plot(handles)
|
---|
| 2861 | % axis(handles.axes3,'image')
|
---|
| 2862 | end
|
---|
| 2863 |
|
---|
| 2864 |
|
---|
| 2865 | %-------------------------------------------------------------------
|
---|
| 2866 |
|
---|
| 2867 | %-------------------------------------------------------------------
|
---|
| 2868 | % --- Executes on button press in 'zoom'.
|
---|
| 2869 | %-------------------------------------------------------------------
|
---|
| 2870 | function zoom_Callback(hObject, eventdata, handles)
|
---|
[60] | 2871 |
|
---|
[2] | 2872 | if (get(handles.zoom,'Value') == 1);
|
---|
| 2873 | set(handles.zoom,'BackgroundColor',[1 1 0])
|
---|
| 2874 | set(handles.FixedLimits,'Value',1)% propose by default fixed limits for the plotting axes
|
---|
[60] | 2875 | set(handles.FixedLimits,'BackgroundColor',[1 1 0])
|
---|
[2] | 2876 | else
|
---|
| 2877 | set(handles.zoom,'BackgroundColor',[0.7 0.7 0.7])
|
---|
| 2878 | end
|
---|
| 2879 |
|
---|
[60] | 2880 |
|
---|
[2] | 2881 | %-------------------------------------------------------------------
|
---|
| 2882 | %----Executes on button press in 'record': records the current flags of manual correction.
|
---|
| 2883 | %-------------------------------------------------------------------
|
---|
| 2884 | function record_Callback(hObject, eventdata, handles)
|
---|
| 2885 | % [filebase,num_i1,num_j1,num_i2,num_j2,Ext,NomType,SubDir]=read_input_file(handles);
|
---|
| 2886 | filename=read_file_boxes(handles);
|
---|
| 2887 | AxeData=get(gca,'UserData');
|
---|
| 2888 | [erread,message]=fileattrib(filename);
|
---|
[55] | 2889 | if ~isempty(message) && ~isequal(message.UserWrite,1)
|
---|
[2] | 2890 | msgbox_uvmat('ERROR',['no writting access to ' filename])
|
---|
| 2891 | return
|
---|
| 2892 | end
|
---|
| 2893 | test_civ2=isequal(get(handles.civ2,'BackgroundColor'),[1 1 0]);
|
---|
[55] | 2894 | test_civ1=isequal(get(handles.civ1,'BackgroundColor'),[1 1 0]);
|
---|
| 2895 | if ~test_civ2 && ~test_civ1
|
---|
| 2896 | msgbox_uvmat('ERROR','manual correction only possible for CIV1 or CIV2 velocity fields')
|
---|
[2] | 2897 | end
|
---|
[55] | 2898 | if test_civ2
|
---|
| 2899 | nbname='nb_vectors2';
|
---|
| 2900 | flagname='vec2_FixFlag';
|
---|
| 2901 | attrname='fix2';
|
---|
| 2902 | end
|
---|
| 2903 | if test_civ1
|
---|
| 2904 | nbname='nb_vectors';
|
---|
| 2905 | flagname='vec_FixFlag';
|
---|
| 2906 | attrname='fix';
|
---|
| 2907 | end
|
---|
| 2908 | %write fix flags in the netcdf file
|
---|
| 2909 | hhh=which('netcdf.open');% look for built-in matlab netcdf library
|
---|
| 2910 | if ~isequal(hhh,'')% case of new builtin Matlab netcdf library
|
---|
| 2911 | nc=netcdf.open(filename,'NC_WRITE');
|
---|
| 2912 | netcdf.reDef(nc)
|
---|
| 2913 | netcdf.putAtt(nc,netcdf.getConstant('NC_GLOBAL'),attrname,1)
|
---|
| 2914 | dimid = netcdf.inqDimID(nc,nbname);
|
---|
| 2915 | try
|
---|
| 2916 | varid = netcdf.inqVarID(nc,flagname);% look for already existing fixflag variable
|
---|
| 2917 | catch
|
---|
| 2918 | varid=netcdf.defVar(nc,flagname,'double',dimid);%create fixflag variable if it does not exist
|
---|
| 2919 | end
|
---|
| 2920 | netcdf.endDef(nc)
|
---|
| 2921 | netcdf.putVar(nc,varid,AxeData.FF);
|
---|
| 2922 | netcdf.close(nc)
|
---|
| 2923 | else %old netcdf library
|
---|
[56] | 2924 | netcdf_toolbox(filename,AxeData,attrname,nbname,flagname)
|
---|
[55] | 2925 | end
|
---|
[2] | 2926 |
|
---|
[56] | 2927 | function netcdf_toolbox(filename,AxeData,attrname,nbname,flagname)
|
---|
| 2928 | nc=netcdf(filename,'write'); %open netcdf file
|
---|
| 2929 | result=redef(nc);
|
---|
| 2930 | eval(['nc.' attrname '=1;']);
|
---|
| 2931 | theDim=nc(nbname) ;% get the number of velocity vectors
|
---|
| 2932 | nb_vectors=size(theDim);
|
---|
| 2933 | var_FixFlag=ncvar(flagname,nc);% var_FixFlag will be written as the netcdf variable vec_FixFlag
|
---|
| 2934 | var_FixFlag(1:nb_vectors)=AxeData.FF;%
|
---|
| 2935 | fin=close(nc);
|
---|
[2] | 2936 |
|
---|
| 2937 |
|
---|
| 2938 | %-------------------------------------------------------------------
|
---|
| 2939 | %determines the fields to read from the interface
|
---|
| 2940 | %------------------------------------------------------------------
|
---|
| 2941 | function [VelType,civ]=setfield(handles)
|
---|
| 2942 |
|
---|
| 2943 | VelType=[]; %default
|
---|
| 2944 | if (get(handles.civ1,'Value') == 1);
|
---|
| 2945 | VelType='civ1';
|
---|
| 2946 | % interp1
|
---|
| 2947 | elseif (get(handles.interp1,'Value') == 1);
|
---|
| 2948 | VelType='interp1';
|
---|
| 2949 | % filter1
|
---|
| 2950 | elseif (get(handles.filter1,'Value') == 1);
|
---|
| 2951 | VelType='filter1';
|
---|
| 2952 | % CIV2
|
---|
| 2953 | elseif (get(handles.civ2,'Value') == 1);
|
---|
| 2954 | VelType='civ2';
|
---|
| 2955 | % interp2
|
---|
| 2956 | elseif (get(handles.interp2,'Value') == 1);
|
---|
| 2957 | VelType='interp2';
|
---|
| 2958 | % filter2
|
---|
| 2959 | elseif (get(handles.filter2,'Value') == 1);
|
---|
| 2960 | VelType='filter2';
|
---|
| 2961 | end
|
---|
| 2962 |
|
---|
| 2963 | if isequal(get(handles.filter2,'Visible'),'on');
|
---|
| 2964 | civ=6;
|
---|
| 2965 | % interp1
|
---|
| 2966 | elseif isequal(get(handles.interp2,'Visible'),'on');
|
---|
| 2967 | civ=5;
|
---|
| 2968 | % filter1
|
---|
| 2969 | elseif isequal(get(handles.civ2,'Visible'),'on');
|
---|
| 2970 | civ=4;
|
---|
| 2971 | % CIV2
|
---|
| 2972 | elseif isequal(get(handles.filter1,'Visible'),'on');
|
---|
| 2973 | civ=3;
|
---|
| 2974 | % interp2
|
---|
| 2975 | elseif isequal(get(handles.interp1,'Visible'),'on');
|
---|
| 2976 | civ=2;
|
---|
| 2977 | % filter2
|
---|
| 2978 | elseif isequal(get(handles.civ1,'Visible'),'on');
|
---|
| 2979 | civ=1;
|
---|
| 2980 | else
|
---|
| 2981 | civ=0;
|
---|
| 2982 | end
|
---|
| 2983 |
|
---|
| 2984 | %-------------------------------------------------------------------
|
---|
| 2985 | %determines the veltype of the second field to read from the iinterface
|
---|
| 2986 | %------------------------------------------------------------------
|
---|
| 2987 | function VelType=setfield_1(handles)
|
---|
| 2988 |
|
---|
| 2989 | VelType=[]; %default
|
---|
| 2990 | if (get(handles.civ1_1,'Value') == 1);
|
---|
| 2991 | VelType='civ1';
|
---|
| 2992 | % interp1
|
---|
| 2993 | elseif (get(handles.interp1_1,'Value') == 1);
|
---|
| 2994 | VelType='interp1';
|
---|
| 2995 | % filter1
|
---|
| 2996 | elseif (get(handles.filter1_1,'Value') == 1);
|
---|
| 2997 | VelType='filter1';
|
---|
| 2998 | % CIV2
|
---|
| 2999 | elseif (get(handles.civ2_1,'Value') == 1);
|
---|
| 3000 | VelType='civ2';
|
---|
| 3001 | % interp2
|
---|
| 3002 | elseif (get(handles.interp2_1,'Value') == 1);
|
---|
| 3003 | VelType='interp2';
|
---|
| 3004 | % filter2
|
---|
| 3005 | elseif (get(handles.filter2_1,'Value') == 1);
|
---|
| 3006 | VelType='filter2';
|
---|
| 3007 | end
|
---|
| 3008 |
|
---|
| 3009 |
|
---|
| 3010 | %---------------------------------------------------
|
---|
| 3011 | % --- Executes on button press in SubField
|
---|
| 3012 | function SubField_Callback(hObject, eventdata, handles)
|
---|
| 3013 | huvmat=get(handles.run0,'parent');
|
---|
| 3014 | UvData=get(huvmat,'UserData');
|
---|
| 3015 | if get(handles.SubField,'Value')==0% if the subfield button is desactivated
|
---|
| 3016 | set(handles.RootPath_1,'String','')
|
---|
| 3017 | set(handles.RootFile_1,'String','')
|
---|
| 3018 | set(handles.SubDir_1,'String','');
|
---|
| 3019 | set(handles.FileIndex_1,'String','');
|
---|
| 3020 | set(handles.FileExt_1,'String','');
|
---|
| 3021 | set(handles.RootPath_1,'Visible','off')
|
---|
| 3022 | set(handles.RootFile_1,'Visible','off')
|
---|
| 3023 | set(handles.SubDir_1,'Visible','off');
|
---|
| 3024 | set(handles.FileIndex_1,'Visible','off');
|
---|
| 3025 | set(handles.FileExt_1,'Visible','off');
|
---|
| 3026 | set(handles.Fields_1,'Value',1);%set to blank state
|
---|
| 3027 | set_veltype_display([handles.civ1_1 handles.interp1_1 handles.filter1_1 ...
|
---|
| 3028 | handles.civ2_1 handles.interp2_1 handles.filter2_1],0)
|
---|
| 3029 | if isfield(UvData,'XmlData_1')
|
---|
| 3030 | UvData=rmfield(UvData,'XmlData_1');
|
---|
| 3031 | end
|
---|
| 3032 | set(huvmat,'UserData',UvData);
|
---|
| 3033 | run0_Callback(hObject, eventdata, handles); %run
|
---|
| 3034 | else
|
---|
| 3035 | MenuBrowse_1_Callback(hObject, eventdata, handles)
|
---|
| 3036 | end
|
---|
| 3037 |
|
---|
| 3038 | % %----------------------------------------------
|
---|
| 3039 | % %read the data displayed for the input rootfile windows (new)
|
---|
| 3040 | % %-------------------------------------------------
|
---|
| 3041 | function [FileName,RootPath,FileBase,FileIndices,FileExt,SubDir]=read_file_boxes(handles)
|
---|
| 3042 | RootPath=get(handles.RootPath,'String');
|
---|
| 3043 | FileName=RootPath; %default
|
---|
| 3044 | SubDir=get(handles.SubDir,'String');
|
---|
| 3045 | if ~isempty(SubDir) && ~isequal(SubDir,'')
|
---|
| 3046 | if (isequal(SubDir(1),'/')|| isequal(SubDir(1),'\'))
|
---|
| 3047 | SubDir(1)=[]; %suppress possible / or \ separator
|
---|
| 3048 | end
|
---|
| 3049 | FileName=fullfile(RootPath,SubDir);
|
---|
| 3050 | end
|
---|
| 3051 | RootFile=get(handles.RootFile,'String');
|
---|
| 3052 | if ~isempty(RootFile) && ~isequal(RootFile,'')
|
---|
| 3053 | if (isequal(RootFile(1),'/')|| isequal(RootFile(1),'\'))
|
---|
| 3054 | RootFile(1)=[]; %suppress possible / or \ separator
|
---|
| 3055 | end
|
---|
| 3056 | FileName=fullfile(FileName,RootFile);
|
---|
| 3057 | end
|
---|
| 3058 | FileBase=fullfile(RootPath,RootFile);
|
---|
| 3059 | FileIndices=get(handles.FileIndex,'String');
|
---|
| 3060 | FileExt=get(handles.FileExt,'String');
|
---|
| 3061 | FileName=[FileName FileIndices FileExt];
|
---|
| 3062 |
|
---|
[85] | 3063 | %------------------------------------------------------------------------
|
---|
| 3064 | % ---- read the data displayed for the second input rootfile windows
|
---|
[2] | 3065 | function [FileName_1,RootPath_1,FileBase_1,FileIndices_1,FileExt_1,SubDir_1]=read_file_boxes_1(handles)
|
---|
[85] | 3066 | %------------------------------------------------------------------------
|
---|
[86] | 3067 | RootPath_1=get(handles.RootPath_1,'String'); % read the data from the file1_input window
|
---|
[85] | 3068 | if isequal(get(handles.RootPath_1,'Visible'),'off') || isequal(RootPath_1,'"')
|
---|
| 3069 | RootPath_1=get(handles.RootPath,'String');
|
---|
| 3070 | end;
|
---|
[2] | 3071 | FileName_1=RootPath_1; %default
|
---|
| 3072 | SubDir_1=get(handles.SubDir_1,'String');
|
---|
[85] | 3073 | if isequal(get(handles.SubDir_1,'Visible'),'off')|| isequal(SubDir_1,'"')
|
---|
[2] | 3074 | SubDir_1=get(handles.SubDir,'String');
|
---|
| 3075 | end
|
---|
[85] | 3076 | if numel(SubDir_1)>=1
|
---|
[2] | 3077 | if (isequal(SubDir_1(1),'/')|| isequal(SubDir_1(1),'\'))
|
---|
| 3078 | SubDir_1(1)=[]; %suppress possible / or \ separator
|
---|
| 3079 | end
|
---|
| 3080 | FileName_1=fullfile(RootPath_1,SubDir_1);
|
---|
| 3081 | end
|
---|
| 3082 | RootFile_1=get(handles.RootFile_1,'String');
|
---|
[85] | 3083 | if isequal(get(handles.RootFile_1,'Visible'),'off') || isequal(RootFile_1,'"')
|
---|
| 3084 | RootFile_1=get(handles.RootFile,'String');
|
---|
| 3085 | end
|
---|
| 3086 | if numel(RootFile_1)>=1
|
---|
[2] | 3087 | if ~(isequal(RootFile_1(1),'/')|isequal(RootFile_1(1),'\'))
|
---|
| 3088 | RootFile_1(1)=[];%suppress possible / or \ separator
|
---|
| 3089 | end
|
---|
| 3090 | FileName_1=fullfile(FileName_1,RootFile_1);
|
---|
| 3091 | end
|
---|
| 3092 | FileBase_1=fullfile(RootPath_1,RootFile_1);
|
---|
[85] | 3093 | if isequal(get(handles.FileIndex_1,'Visible'),'off')
|
---|
| 3094 | FileIndices_1=get(handles.FileIndex,'String');
|
---|
| 3095 | else
|
---|
| 3096 | FileIndices_1=get(handles.FileIndex_1,'String');
|
---|
| 3097 | end
|
---|
[2] | 3098 | FileExt_1=get(handles.FileExt_1,'String');
|
---|
| 3099 | if isequal(FileExt_1,'"'),FileExt_1=get(handles.FileExt,'String'); end;
|
---|
| 3100 | FileName_1=[FileName_1 FileIndices_1 FileExt_1];
|
---|
| 3101 |
|
---|
[85] | 3102 | %------------------------------------------------------------------------
|
---|
[2] | 3103 | % --- Executes on menu selection Fields
|
---|
| 3104 | function Fields_Callback(hObject, eventdata, handles)
|
---|
[85] | 3105 | %------------------------------------------------------------------------
|
---|
[2] | 3106 | list_fields=get(handles.Fields,'String');% list menu fields
|
---|
| 3107 | index_fields=get(handles.Fields,'Value');% selected string index
|
---|
| 3108 | field= list_fields{index_fields(1)}; % selected string
|
---|
| 3109 | if isequal(field,'get_field...')
|
---|
| 3110 | veltype_handles=[handles.civ1 handles.interp1 handles.filter1 handles.civ2 handles.interp2 handles.filter2];
|
---|
| 3111 | set_veltype_display(veltype_handles,0) % unvisible civ buttons
|
---|
| 3112 | filename=read_file_boxes(handles);
|
---|
| 3113 | hget_field=findobj(allchild(0),'name','get_field');
|
---|
| 3114 | if ~isempty(hget_field)
|
---|
| 3115 | delete(hget_field)
|
---|
| 3116 | end
|
---|
| 3117 | get_field(filename)
|
---|
| 3118 | return %no action
|
---|
| 3119 | end
|
---|
| 3120 | list_fields=get(handles.Fields_1,'String');% list menu fields
|
---|
| 3121 | index_fields=get(handles.Fields_1,'Value');% selected string index
|
---|
| 3122 | field_1= list_fields{index_fields(1)}; % selected string
|
---|
[59] | 3123 | UvData=get(handles.uvmat,'UserData');
|
---|
[2] | 3124 |
|
---|
| 3125 | %read the rootfile input display
|
---|
[82] | 3126 | [FileName,RootPath,FileBase,FileIndices,FileExt]=read_file_boxes(handles);
|
---|
[2] | 3127 | [P,F,str1,str2,str_a,str_b,E,NomType]=name2display(['xxx' get(handles.FileIndex,'String') FileExt]);
|
---|
| 3128 | NomTypeNew=NomType;%default
|
---|
| 3129 | if isequal(field,'image')
|
---|
| 3130 | % transform netc type to the corresponding image type
|
---|
[85] | 3131 | % if isequal(NomType,'_i1-i2_j')||isequal(NomType,'_i_j1-j2')|| isequal(NomType,'#_ab')|| isequal(NomType,'_i1-i2')
|
---|
| 3132 | % UvData.SubDir=get(handles.SubDir,'String'); %preserve the subdir in memory
|
---|
| 3133 | % if ~isempty(UvData.SubDir) && (isequal(UvData.SubDir(1),'/')||isequal(UvData.SubDir(1),'/'))
|
---|
| 3134 | % UvData.SubDir(1)=[];
|
---|
| 3135 | % end
|
---|
| 3136 | % set(handles.SubDir,'String','')
|
---|
| 3137 | % set(handles.FileExt,'String','.png');
|
---|
[45] | 3138 | if isequal(NomType,'_i1-i2_j')||isequal(NomType,'_i_j1-j2')
|
---|
[2] | 3139 | NomTypeNew='_i_j';
|
---|
| 3140 | elseif isequal(NomType,'#_ab')
|
---|
| 3141 | NomTypeNew='#a';
|
---|
| 3142 | elseif isequal(NomType,'_i1-i2')
|
---|
| 3143 | NomTypeNew='_i';
|
---|
| 3144 | end
|
---|
[86] | 3145 | imagename=name_generator(FileBase,str2double(str1),str2double(str_a),'.png',NomTypeNew,1,str2double(str2),str2double(str_b),'');
|
---|
[85] | 3146 | if ~exist(imagename,'file')
|
---|
| 3147 | [FileName,PathName] = uigetfile( ...
|
---|
| 3148 | {'*.png;*.jpg;*.tif;*.avi;*.AVI;*.vol', ' (*.png, .tif, *.avi,*.vol)';
|
---|
| 3149 | '*.jpg',' jpeg image files'; ...
|
---|
| 3150 | '*.png','.png image files'; ...
|
---|
| 3151 | '*.tif','.tif image files'; ...
|
---|
| 3152 | '*.avi;*.AVI','.avi movie files'; ...
|
---|
| 3153 | '*.vol','.volume images (png)'; ...
|
---|
| 3154 | '*.*', 'All Files (*.*)'}, ...
|
---|
[86] | 3155 | 'Pick an image',imagename);
|
---|
[85] | 3156 | % display the selected field and related information
|
---|
| 3157 | imagename=[PathName FileName];
|
---|
| 3158 | end
|
---|
| 3159 | display_file_name(hObject, eventdata, handles,imagename)%display the image
|
---|
| 3160 | return
|
---|
| 3161 | % end
|
---|
| 3162 | % veltype_handles=[handles.civ1 handles.interp1 handles.filter1 handles.civ2 handles.interp2 handles.filter2];
|
---|
| 3163 | % set_veltype_display(veltype_handles,0) % unvisible civ buttons
|
---|
[2] | 3164 | else
|
---|
| 3165 | ext=get(handles.FileExt,'String');
|
---|
| 3166 | if ~isequal(ext,'.nc') %find the new NomType if the previous display was not already a netcdf file
|
---|
[85] | 3167 | [FileName,PathName] = uigetfile( ...
|
---|
| 3168 | {'*.nc', ' (*.nc)';
|
---|
| 3169 | '*.nc',' netcdf files'; ...
|
---|
| 3170 | '*.*', 'All Files (*.*)'}, ...
|
---|
[86] | 3171 | 'Pick a netcdf file',FileBase);
|
---|
[85] | 3172 | % display the selected field and related information
|
---|
| 3173 | filename=[PathName FileName];
|
---|
| 3174 | display_file_name(hObject, eventdata, handles,filename)
|
---|
| 3175 | return
|
---|
| 3176 | % MenuBrowse_Callback(hObject, eventdata, handles)
|
---|
[2] | 3177 | end
|
---|
| 3178 | if isequal(field,'vort') || isequal(field,'div') || isequal(field,'strain')
|
---|
| 3179 | set(handles.civ1,'BackgroundColor',[0.702 0.702 0.702]) % put their color to grey
|
---|
| 3180 | set(handles.civ2,'BackgroundColor',[0.702 0.702 0.702])
|
---|
| 3181 | set(handles.interp1,'BackgroundColor',[0.702 0.702 0.702])
|
---|
| 3182 | set(handles.interp2,'BackgroundColor',[0.702 0.702 0.702])
|
---|
| 3183 | elseif isequal(field,'more...');
|
---|
| 3184 | set(handles.civ1,'BackgroundColor',[0.702 0.702 0.702]) % put their color to grey
|
---|
| 3185 | set(handles.civ2,'BackgroundColor',[0.702 0.702 0.702])
|
---|
| 3186 | str=calc_field;%get the list of available scalars by the function calc_scal
|
---|
[45] | 3187 | [ind_answer] = listdlg('PromptString','Select a file:',...
|
---|
[2] | 3188 | 'SelectionMode','single',...
|
---|
| 3189 | 'ListString',str);
|
---|
| 3190 | % edit the choice in the field and action menu
|
---|
| 3191 | scalar=cell2mat(str(ind_answer));
|
---|
| 3192 | menu=update_menu(handles.Fields,scalar);
|
---|
| 3193 | menu=[{''};menu];
|
---|
| 3194 | set(handles.Fields_1,'String',menu);% store the selected scalar type
|
---|
| 3195 | end
|
---|
| 3196 | end
|
---|
[45] | 3197 | indices=name_generator('',str2double(str1),str2double(str_a),'',NomTypeNew,1,str2double(str2),str2double(str_b),'');
|
---|
[2] | 3198 | set(handles.FileIndex,'String',indices)
|
---|
| 3199 | set(handles.FileIndex,'UserData',NomTypeNew)
|
---|
| 3200 | %common to Fields_1_Callback
|
---|
[45] | 3201 | if isequal(field,'image')||isequal(field_1,'image')
|
---|
[2] | 3202 | set(handles.npx_title,'Visible','on')% visible npx,pxcm... buttons
|
---|
| 3203 | set(handles.npy_title,'Visible','on')
|
---|
| 3204 | set(handles.npx,'Visible','on')
|
---|
| 3205 | set(handles.npy,'Visible','on')
|
---|
| 3206 | else
|
---|
| 3207 | set(handles.npx_title,'Visible','off')% visible npx,pxcm... buttons
|
---|
| 3208 | set(handles.npy_title,'Visible','off')
|
---|
| 3209 | set(handles.npx,'Visible','off')
|
---|
| 3210 | set(handles.npy,'Visible','off')
|
---|
| 3211 | end
|
---|
| 3212 | setfield(handles);% update the field structure ('civ1'....)
|
---|
| 3213 |
|
---|
[45] | 3214 | if ~isfield(UvData,'NewSeries')||isequal(UvData.NewSeries,0)
|
---|
[2] | 3215 | run0_Callback(hObject, eventdata, handles)
|
---|
| 3216 | end
|
---|
| 3217 |
|
---|
| 3218 | %---------------------------------------------------
|
---|
| 3219 | % --- Executes on menu selection Fields
|
---|
| 3220 | function Fields_1_Callback(hObject, eventdata, handles)
|
---|
| 3221 | %-------------------------------------------------
|
---|
| 3222 | list_fields=get(handles.Fields,'String');% list menu fields
|
---|
| 3223 | index_fields=get(handles.Fields,'Value');% selected string index
|
---|
| 3224 | field= list_fields{index_fields(1)}; % selected string
|
---|
| 3225 | list_fields=get(handles.Fields_1,'String');% list menu fields
|
---|
| 3226 | index_fields=get(handles.Fields_1,'Value');% selected string index
|
---|
| 3227 | field_1= list_fields{index_fields(1)}; % selected string for the second field
|
---|
| 3228 | if isequal(field_1,'') %remove second field if 'blank' field is selected
|
---|
| 3229 | set(handles.SubField,'Value',0)
|
---|
| 3230 | SubField_Callback(hObject, eventdata, handles)
|
---|
| 3231 | return
|
---|
| 3232 | end
|
---|
[59] | 3233 | UvData=get(handles.uvmat,'UserData');
|
---|
[2] | 3234 |
|
---|
| 3235 | %read the rootfile input display
|
---|
[85] | 3236 | [FileName,RootPath,FileBase,FileIndices,FileExt_prev]=read_file_boxes_1(handles);
|
---|
| 3237 | [P,F,str1,str2,str_a,str_b,E,NomType]=name2display(['xxx' get(handles.FileIndex,'String') FileExt_prev]);
|
---|
[2] | 3238 | if isempty(FileExt_prev)|isequal(FileExt_prev,'')
|
---|
| 3239 | FileExt_1=get(handles.FileExt,'String');
|
---|
| 3240 | else
|
---|
| 3241 | FileExt_1=FileExt_prev;
|
---|
| 3242 | end
|
---|
| 3243 | NomType_1=get(handles.FileIndex_1,'UserData');
|
---|
| 3244 | if isempty(NomType_1)|isequal(NomType_1,'')
|
---|
| 3245 | NomType_1=get(handles.FileIndex,'UserData');
|
---|
| 3246 | end
|
---|
| 3247 | NomTypeNew=NomType_1;%default
|
---|
| 3248 |
|
---|
| 3249 | set(handles.SubField,'Value',1)%introduce second field
|
---|
| 3250 | if isfield(UvData,'XmlData')
|
---|
| 3251 | UvData.XmlData_1=UvData.XmlData;
|
---|
| 3252 | end
|
---|
| 3253 | set(handles.FileIndex_1,'Visible','on')
|
---|
| 3254 | set(handles.FileExt_1,'Visible','on')
|
---|
| 3255 | RootPath_1=get(handles.RootPath_1,'String');
|
---|
| 3256 | RootFile_1=get(handles.RootFile_1,'String');
|
---|
[82] | 3257 | if isempty(RootPath_1)||isequal(RootPath_1,'')
|
---|
[2] | 3258 | set(handles.RootPath_1,'String','"')
|
---|
| 3259 | end
|
---|
[82] | 3260 | if isempty(RootFile_1) || isequal(RootFile_1,'')
|
---|
[2] | 3261 | set(handles.RootFile_1,'String','"')
|
---|
| 3262 | end
|
---|
[82] | 3263 | if ~isempty(RootFile_1)&&(isequal(RootFile_1(1),'/')||isequal(RootFile_1(1),'\'))
|
---|
[2] | 3264 | RootFile_1(1)=[];
|
---|
| 3265 | end
|
---|
| 3266 |
|
---|
| 3267 | if isequal(field_1,'get_field...')
|
---|
| 3268 | veltype_handles=[handles.civ1 handles.interp1 handles.filter1 handles.civ2 handles.interp2 handles.filter2];
|
---|
| 3269 | set_veltype_display(veltype_handles,0) % unvisible civ buttons
|
---|
| 3270 | filename=read_file_boxes_1(handles);
|
---|
| 3271 | hget_field=findobj(allchild(0),'name','get_field_1');
|
---|
| 3272 | if ~isempty(hget_field)
|
---|
| 3273 | delete(hget_field)
|
---|
| 3274 | end
|
---|
| 3275 | hget_field=get_field(filename);
|
---|
| 3276 | set(hget_field,'name','get_field_1')
|
---|
| 3277 | return %no action
|
---|
| 3278 | end
|
---|
| 3279 | if isequal(field_1,'image')
|
---|
| 3280 | % transform netc type to the corresponding image type
|
---|
[85] | 3281 | % set(handles.FileExt_1,'String','.png');
|
---|
[2] | 3282 | if isequal(NomType_1,'_i1-i2_j')|isequal(NomType_1,'_i_j1-j2')| isequal(NomType_1,'#_ab')| isequal(NomType_1,'_i1-i2')
|
---|
| 3283 | UvData.SubDir_1=get(handles.SubDir_1,'String'); %preserve the subdir in memory
|
---|
[85] | 3284 | % set(handles.SubDir_1,'String','')
|
---|
[2] | 3285 | % set(handles.FileExt_1,'String','.png');
|
---|
| 3286 | if isequal(NomType_1,'_i1-i2_j')|isequal(NomType_1,'_i_j1-j2')
|
---|
| 3287 | NomTypeNew='_i_j';
|
---|
| 3288 | elseif isequal(NomType_1,'#_ab')
|
---|
| 3289 | NomTypeNew='#a';
|
---|
| 3290 | elseif isequal(NomType_1,'_i1-i2')
|
---|
| 3291 | NomTypeNew='_i';
|
---|
| 3292 | end
|
---|
| 3293 | end
|
---|
[85] | 3294 | imagename=name_generator(FileBase,str2double(str1),str2double(str_a),'.png',NomTypeNew,1,str2double(str2),str2double(str_b),'');
|
---|
| 3295 | if ~exist(imagename,'file')
|
---|
| 3296 | [FileName,PathName] = uigetfile( ...
|
---|
| 3297 | {'*.png;*.jpg;*.tif;*.avi;*.AVI;*.vol', ' (*.png, .tif, *.avi,*.vol)';
|
---|
| 3298 | '*.jpg',' jpeg image files'; ...
|
---|
| 3299 | '*.png','.png image files'; ...
|
---|
| 3300 | '*.tif','.tif image files'; ...
|
---|
| 3301 | '*.avi;*.AVI','.avi movie files'; ...
|
---|
| 3302 | '*.vol','.volume images (png)'; ...
|
---|
| 3303 | '*.*', 'All Files (*.*)'}, ...
|
---|
[86] | 3304 | 'Pick an image',imagename);
|
---|
[85] | 3305 | % display the selected field and related information
|
---|
| 3306 | imagename=[PathName FileName];
|
---|
| 3307 | end
|
---|
| 3308 | display_file_name_1(hObject, eventdata, handles,imagename)%display the image
|
---|
| 3309 | return
|
---|
| 3310 | % veltype_handles=[handles.civ1_1 handles.interp1_1 handles.filter1_1 handles.civ2_1 handles.interp2_1 handles.filter2_1];
|
---|
| 3311 | % set_veltype_display(veltype_handles,0) % unvisible civ buttons
|
---|
[2] | 3312 | else
|
---|
| 3313 | set(handles.SubDir_1,'Visible','on')
|
---|
| 3314 | if ~isequal(FileExt_prev,'.nc') %find the new NomType if the previous display was not already a netcdf file
|
---|
| 3315 | veltype_handles=[handles.civ1_1 handles.interp1_1 handles.filter1_1 handles.civ2_1 handles.interp2_1 handles.filter2_1];
|
---|
| 3316 | set_veltype_display(veltype_handles,6); % make all civ buttons visible
|
---|
| 3317 | RootPath_1=get(handles.RootPath_1,'String');
|
---|
| 3318 | RootFile_1=get(handles.RootFile_1,'String');
|
---|
| 3319 | if isempty(RootPath_1)|isequal(RootPath_1,'')
|
---|
| 3320 | set(handles.RootPath_1,'String','"')
|
---|
| 3321 | end
|
---|
| 3322 | if isempty(RootFile_1) | isequal(RootFile_1,'')
|
---|
| 3323 | set(handles.RootFile_1,'String','"')
|
---|
| 3324 | end
|
---|
| 3325 | if ~isempty(RootFile_1)&(isequal(RootFile_1(1),'/')|isequal(RootFile_1(1),'\'))
|
---|
| 3326 | RootFile_1(1)=[];
|
---|
| 3327 | end
|
---|
| 3328 | filebase_1=fullfile(RootPath_1,RootFile_1);
|
---|
| 3329 | SubDir_1=get(handles.SubDir,'String');
|
---|
[82] | 3330 | if isempty(SubDir_1)||isequal(SubDir_1,'')
|
---|
[2] | 3331 | if isfield(UvData,'SubDir_1')
|
---|
| 3332 | SubDir_1=UvData.SubDir_1;%retrieve previous subdir
|
---|
| 3333 | else
|
---|
| 3334 | SubDir_1='?';
|
---|
| 3335 | end
|
---|
| 3336 | end
|
---|
[82] | 3337 | str1=get(handles.i1,'String');
|
---|
| 3338 | str_a=get(handles.j1,'String');
|
---|
| 3339 | if isequal(NomType_1,'#_ab')||isequal(NomType_1,'_i1-i2_j')||isequal(NomType_1,'_i_j1-j2')||isequal(NomType_1,'_i1-i2')
|
---|
[2] | 3340 | NomTypeNew=NomType_1;
|
---|
| 3341 | elseif isequal(NomType_1,'#a')
|
---|
[82] | 3342 | [filename, n1,na,n2,nb,SubDir_1]=name_generator(filebase_1, str2num(str1),stra2num(str_a),'.nc','#_ab',0,[],[],SubDir_1);
|
---|
[2] | 3343 | NomTypeNew='#_ab';
|
---|
| 3344 | elseif isequal(NomType_1,'_i_j')
|
---|
[82] | 3345 | [filename,n1,na,n2,nb,SubDir_1]=name_generator(filebase_1,str2num(str1),stra2num(str_a),'.nc','_i1-i2_j',0,str2num(str1),[],SubDir_1);
|
---|
[2] | 3346 | if idetect==1
|
---|
| 3347 | NomTypeNew='_i1-i2_j';
|
---|
| 3348 | else
|
---|
| 3349 | NomTypeNew='_i_j1-j2';
|
---|
| 3350 | end
|
---|
| 3351 | else %for instance avi files or any ima_num series
|
---|
[82] | 3352 | [filename,n1,na,n2,nb,SubDir_1]=name_generator(filebase_1,str2num(str1),stra2num(str_a),'.nc','_i1-i2',0,str2num(str1),[],SubDir_1);
|
---|
[2] | 3353 | NomTypeNew='_i1-i2';
|
---|
| 3354 | end
|
---|
| 3355 | [Path,Name]=fileparts(filebase_1);
|
---|
| 3356 | set(handles.FileExt_1,'String','.nc');
|
---|
[86] | 3357 | if ~isempty(SubDir_1) && ~strcmp(SubDir_1,'''')&& ~strcmp(SubDir_1,'"')&& ~strcmp(SubDir_1(1),'/')
|
---|
[2] | 3358 | SubDir_1=['/' SubDir_1];
|
---|
| 3359 | end
|
---|
| 3360 | set(handles.SubDir_1,'String',SubDir_1);
|
---|
| 3361 | end
|
---|
| 3362 | if isequal(field,'vort') | isequal(field,'div') | isequal(field,'strain')
|
---|
| 3363 | set(handles.civ1_1,'BackgroundColor',[0.702 0.702 0.702]) % put their color to grey
|
---|
| 3364 | set(handles.civ2_1,'BackgroundColor',[0.702 0.702 0.702])
|
---|
| 3365 | set(handles.interp1_1,'BackgroundColor',[0.702 0.702 0.702])
|
---|
| 3366 | set(handles.interp2_1,'BackgroundColor',[0.702 0.702 0.702])
|
---|
| 3367 | elseif isequal(field_1,'more...'); %add new item to the menu
|
---|
| 3368 | set(handles.civ1_1,'BackgroundColor',[0.702 0.702 0.702]) % put their color to grey
|
---|
| 3369 | set(handles.civ2_1,'BackgroundColor',[0.702 0.702 0.702])
|
---|
| 3370 | str=calc_field;%get the list of available scalars by the function calc_scal
|
---|
| 3371 | [ind_answer,v] = listdlg('PromptString','Select a file:',...
|
---|
| 3372 | 'SelectionMode','single',...
|
---|
| 3373 | 'ListString',str);
|
---|
| 3374 | % edit the choice in the field and action menu
|
---|
| 3375 | scalar=cell2mat(str(ind_answer));
|
---|
| 3376 | menu=update_menu(handles.Fields_1,scalar);
|
---|
| 3377 | set(handles.Fields_1,'String',menu);% store the selected scalar type
|
---|
| 3378 | end
|
---|
| 3379 | end
|
---|
| 3380 | str1=get(handles.i1,'String');
|
---|
| 3381 | str2=get(handles.i2,'String');
|
---|
| 3382 | str_a=get(handles.j1,'String');
|
---|
| 3383 | str_b=get(handles.j2,'String');
|
---|
| 3384 | indices=name_generator('',str2num(str1),stra2num(str_a),'',NomTypeNew,1,str2num(str2),stra2num(str_b),'');
|
---|
| 3385 | set(handles.FileIndex_1,'String',indices)
|
---|
| 3386 | set(handles.FileIndex_1,'UserData',NomTypeNew)
|
---|
| 3387 |
|
---|
| 3388 | %common to Fields_Callback
|
---|
| 3389 | if isequal(field,'image')|isequal(field_1,'image')
|
---|
| 3390 | set(handles.npx_title,'Visible','on')% visible npx,pxcm... buttons
|
---|
| 3391 | set(handles.npy_title,'Visible','on')
|
---|
| 3392 | set(handles.npx,'Visible','on')
|
---|
| 3393 | set(handles.npy,'Visible','on')
|
---|
[81] | 3394 | % set(handles.fix_pair,'Value',0)
|
---|
[2] | 3395 | else
|
---|
| 3396 | set(handles.npx_title,'Visible','off')% visible npx,pxcm... buttons
|
---|
| 3397 | set(handles.npy_title,'Visible','off')
|
---|
| 3398 | set(handles.npx,'Visible','off')
|
---|
| 3399 | set(handles.npy,'Visible','off')
|
---|
[81] | 3400 | % set(handles.fix_pair,'Value',1)
|
---|
[2] | 3401 | end
|
---|
| 3402 | if isequal(field,'velocity')|isequal(field_1,'velocity');
|
---|
| 3403 | state_vect='on';
|
---|
| 3404 | else
|
---|
| 3405 | state_vect='off';
|
---|
| 3406 | end
|
---|
| 3407 | if ~isequal(field,'velocity')|(~isequal(field_1,'velocity')&~isequal(field_1,''));
|
---|
| 3408 | state_scal='on';
|
---|
| 3409 | else
|
---|
| 3410 | state_scal='off';
|
---|
| 3411 | end
|
---|
[59] | 3412 | set(handles.uvmat,'UserData',UvData)
|
---|
[2] | 3413 | setfield(handles);% update the field structure ('civ1'....)
|
---|
| 3414 | if ~isfield(UvData,'NewSeries')|isequal(UvData.NewSeries,0)
|
---|
| 3415 | run0_Callback(hObject, eventdata, handles)
|
---|
| 3416 | end
|
---|
| 3417 |
|
---|
[57] | 3418 | %------------------------------------------------------------------------
|
---|
| 3419 | % --- set the visibility of relevant velocity type menus:
|
---|
| 3420 | function set_veltype_display(handles,Civ)
|
---|
| 3421 | %------------------------------------------------------------------------
|
---|
[2] | 3422 | %Civ=0; all states 'off'
|
---|
| 3423 | %Civ=6; all states 'on'
|
---|
| 3424 | if isequal(Civ,0)
|
---|
| 3425 | imax=0;
|
---|
| 3426 | % set(handles(1),'Visible','on') % unvisible civ buttons
|
---|
| 3427 | % else
|
---|
| 3428 | % set(handles(1),'String','civ1')
|
---|
| 3429 | % end
|
---|
[57] | 3430 | elseif isequal(Civ,1) || isequal(Civ,2)
|
---|
[2] | 3431 | imax=1;
|
---|
[57] | 3432 | elseif isequal(Civ,3)
|
---|
[2] | 3433 | imax=3;
|
---|
[57] | 3434 | elseif isequal(Civ,4) || isequal(Civ,5)
|
---|
[2] | 3435 | imax=4;
|
---|
[57] | 3436 | elseif isequal(Civ,6) %patch2
|
---|
[2] | 3437 | imax=6;
|
---|
| 3438 | end
|
---|
| 3439 | for ibutton=1:imax;
|
---|
| 3440 | set(handles(ibutton),'Visible','on') % unvisible civ buttons
|
---|
| 3441 | end
|
---|
| 3442 | % for ibutton=max(imax+1,2):6;
|
---|
| 3443 | for ibutton=imax+1:6;
|
---|
| 3444 | set(handles(ibutton),'Visible','off') % unvisible civ buttons
|
---|
| 3445 | set(handles(ibutton),'Value',0)%unactivate unvisible buttons
|
---|
| 3446 | end
|
---|
| 3447 |
|
---|
| 3448 | %-------------------------------------------------------------------
|
---|
| 3449 | % --- Executes on button press in civ1.
|
---|
| 3450 | function civ1_Callback(hObject, eventdata, handles)
|
---|
| 3451 | %-------------------------------------------------------------------
|
---|
| 3452 | if get(handles.civ1,'Value')==1
|
---|
| 3453 | reset_vel_type([handles.interp1 handles.civ2 handles.filter1 handles.interp1 handles.interp2 handles.filter2],handles.civ1)
|
---|
| 3454 | else
|
---|
| 3455 | reset_vel_type([handles.civ1 handles.filter1 handles.interp1 handles.civ2 handles.interp2 handles.filter2])
|
---|
| 3456 | end
|
---|
| 3457 | run0_Callback(hObject, eventdata, handles)
|
---|
| 3458 |
|
---|
| 3459 | %-------------------------------------------------------------------
|
---|
| 3460 | % --- Executes on button press in interp1.
|
---|
| 3461 | function interp1_Callback(hObject, eventdata, handles)
|
---|
| 3462 | %-------------------------------------------------------------------
|
---|
| 3463 | if get(handles.interp1,'Value')==1
|
---|
| 3464 | reset_vel_type([handles.civ1 handles.civ2 handles.filter1 handles.interp2 handles.filter2],handles.interp1)
|
---|
| 3465 | else
|
---|
| 3466 | reset_vel_type([handles.civ1 handles.filter1 handles.interp1 handles.civ2 handles.interp2 handles.filter2])
|
---|
| 3467 | end
|
---|
| 3468 | run0_Callback(hObject, eventdata, handles)
|
---|
| 3469 |
|
---|
| 3470 | %-------------------------------------------------------------------
|
---|
| 3471 | % --- Executes on button press in filter1.
|
---|
| 3472 | function filter1_Callback(hObject, eventdata, handles)
|
---|
| 3473 | %-------------------------------------------------------------------
|
---|
| 3474 | if get(handles.filter1,'Value')==1
|
---|
| 3475 | reset_vel_type([handles.civ1 handles.civ2 handles.interp1 handles.interp2 handles.filter2],handles.filter1)
|
---|
| 3476 | else
|
---|
| 3477 | reset_vel_type([handles.civ1 handles.filter1 handles.interp1 handles.civ2 handles.interp2 handles.filter2])
|
---|
| 3478 | end
|
---|
| 3479 | run0_Callback(hObject, eventdata, handles)
|
---|
| 3480 |
|
---|
| 3481 | %-------------------------------------------------------------------
|
---|
| 3482 | % --- Executes on button press in civ2.
|
---|
| 3483 | function civ2_Callback(hObject, eventdata, handles)
|
---|
| 3484 | %-------------------------------------------------------------------
|
---|
| 3485 | if get(handles.civ2,'Value')==1
|
---|
| 3486 | reset_vel_type([handles.civ1 handles.filter1 handles.interp1 handles.interp2 handles.filter2],handles.civ2)
|
---|
| 3487 | else
|
---|
| 3488 | reset_vel_type([handles.civ1 handles.filter1 handles.interp1 handles.civ2 handles.interp2 handles.filter2])
|
---|
| 3489 | end
|
---|
| 3490 | run0_Callback(hObject, eventdata, handles)
|
---|
| 3491 |
|
---|
| 3492 | %-----------------------------------------
|
---|
| 3493 | % --- Executes on button press in interp2.
|
---|
| 3494 | %-------------------------------------------
|
---|
| 3495 | function interp2_Callback(hObject, eventdata, handles)
|
---|
| 3496 | if get(handles.interp2,'Value')==1
|
---|
| 3497 | reset_vel_type([handles.civ1 handles.filter1 handles.interp1 handles.civ2 handles.filter2],handles.interp2)
|
---|
| 3498 | else
|
---|
| 3499 | reset_vel_type([handles.civ1 handles.filter1 handles.interp1 handles.civ2 handles.interp2 handles.filter2])
|
---|
| 3500 | end
|
---|
| 3501 | run0_Callback(hObject, eventdata, handles)
|
---|
| 3502 | %---------------------------------------------
|
---|
| 3503 | % --- Executes on button press in filter2.
|
---|
| 3504 | %-------------------------------------------
|
---|
| 3505 | function filter2_Callback(hObject, eventdata, handles)
|
---|
| 3506 | if get(handles.filter2,'Value')==1
|
---|
| 3507 | reset_vel_type([handles.civ1 handles.filter1 handles.interp1 handles.civ2 handles.interp2],handles.filter2)
|
---|
| 3508 | else
|
---|
| 3509 | reset_vel_type([handles.civ1 handles.filter1 handles.interp1 handles.civ2 handles.interp2 handles.filter2])
|
---|
| 3510 | end
|
---|
| 3511 | run0_Callback(hObject, eventdata, handles)
|
---|
| 3512 |
|
---|
| 3513 | %---------------------------------------------
|
---|
| 3514 | function civ1_1_Callback(hObject, eventdata, handles)
|
---|
| 3515 | %---------------------------------------------
|
---|
| 3516 | if get(handles.civ1_1,'Value')==1
|
---|
| 3517 | reset_vel_type([handles.interp1_1 handles.civ2_1 handles.filter1_1 handles.interp1_1 handles.interp2_1 handles.filter2_1],handles.civ1_1)
|
---|
| 3518 | else
|
---|
| 3519 | reset_vel_type([handles.civ1_1 handles.filter1_1 handles.interp1_1 handles.civ2_1 handles.interp2_1 handles.filter2_1])
|
---|
| 3520 | end
|
---|
| 3521 | run0_Callback(hObject, eventdata, handles)
|
---|
| 3522 |
|
---|
| 3523 | %--------------------------------------------
|
---|
| 3524 | function interp1_1_Callback(hObject, eventdata, handles)
|
---|
| 3525 | %--------------------------------------------
|
---|
| 3526 | if get(handles.interp1_1,'Value')==1
|
---|
| 3527 | reset_vel_type([handles.civ1_1 handles.civ2_1 handles.filter1_1 handles.interp2_1 handles.filter2_1],handles.interp1_1)
|
---|
| 3528 | else
|
---|
| 3529 | reset_vel_type([handles.civ1_1 handles.filter1_1 handles.interp1_1 handles.civ2_1 handles.interp2_1 handles.filter2_1])
|
---|
| 3530 | end
|
---|
| 3531 | run0_Callback(hObject, eventdata, handles)
|
---|
| 3532 |
|
---|
| 3533 | %--------------------------------------------
|
---|
| 3534 | function filter1_1_Callback(hObject, eventdata, handles)
|
---|
| 3535 | %--------------------------------------------
|
---|
| 3536 | if get(handles.filter1_1,'Value')==1
|
---|
| 3537 | reset_vel_type([handles.interp1_1 handles.civ2_1 handles.interp1_1 handles.interp2_1 handles.filter2_1],handles.filter1_1)
|
---|
| 3538 | else
|
---|
| 3539 | reset_vel_type([handles.civ1_1 handles.filter1_1 handles.interp1_1 handles.civ2_1 handles.interp2_1 handles.filter2_1])
|
---|
| 3540 | end
|
---|
| 3541 | run0_Callback(hObject, eventdata, handles)
|
---|
| 3542 |
|
---|
| 3543 | %--------------------------------------------
|
---|
| 3544 | function civ2_1_Callback(hObject, eventdata, handles)
|
---|
| 3545 | %--------------------------------------------
|
---|
| 3546 | if get(handles.civ2_1,'Value')==1
|
---|
| 3547 | reset_vel_type([handles.civ1_1 handles.interp1_1 handles.filter1_1 handles.interp2_1 handles.filter2_1],handles.civ2_1)
|
---|
| 3548 | else
|
---|
| 3549 | reset_vel_type([handles.civ1_1 handles.filter1_1 handles.interp1_1 handles.civ2_1 handles.interp2_1 handles.filter2_1])
|
---|
| 3550 | end
|
---|
| 3551 | run0_Callback(hObject, eventdata, handles)
|
---|
| 3552 |
|
---|
| 3553 | %--------------------------------------------
|
---|
| 3554 | function interp2_1_Callback(hObject, eventdata, handles)
|
---|
| 3555 | %--------------------------------------------
|
---|
| 3556 | if get(handles.interp2_1,'Value')==1
|
---|
| 3557 | reset_vel_type([handles.civ1_1 handles.civ2_1 handles.filter1_1 handles.interp1_1 handles.filter2_1],handles.interp2_1)
|
---|
| 3558 | else
|
---|
| 3559 | reset_vel_type([handles.civ1_1 handles.filter1_1 handles.interp1_1 handles.civ2_1 handles.interp2_1 handles.filter2_1])
|
---|
| 3560 | end
|
---|
| 3561 | run0_Callback(hObject, eventdata, handles)
|
---|
| 3562 |
|
---|
| 3563 | %--------------------------------------------
|
---|
| 3564 | function filter2_1_Callback(hObject, eventdata, handles)
|
---|
| 3565 | %--------------------------------------------
|
---|
| 3566 | if get(handles.filter2_1,'Value')==1
|
---|
| 3567 | reset_vel_type([handles.civ1_1 handles.interp1_1 handles.civ2_1 handles.filter1_1 handles.interp1_1 handles.interp2_1],handles.filter2_1)
|
---|
| 3568 | else
|
---|
| 3569 | reset_vel_type([handles.civ1_1 handles.filter1_1 handles.interp1_1 handles.civ2_1 handles.interp2_1 handles.filter2_1])
|
---|
| 3570 | end
|
---|
| 3571 | run0_Callback(hObject, eventdata, handles)
|
---|
| 3572 |
|
---|
| 3573 | %-----------------------------------------------
|
---|
| 3574 | % --- reset civ buttons
|
---|
| 3575 | function reset_vel_type(handles_civ0,handle1)
|
---|
| 3576 | for ibutton=1:length(handles_civ0)
|
---|
| 3577 | set(handles_civ0(ibutton),'BackgroundColor',[0.831 0.816 0.784])
|
---|
| 3578 | set(handles_civ0(ibutton),'Value',0)
|
---|
| 3579 | end
|
---|
| 3580 | if exist('handle1','var')%handles of selected button
|
---|
| 3581 | set(handle1,'BackgroundColor',[1 1 0])
|
---|
| 3582 | end
|
---|
| 3583 |
|
---|
| 3584 | %-------------------------------------------------------
|
---|
| 3585 | % --- Executes on button press in MENUVOLUME.
|
---|
| 3586 | %-------------------------------------------------------
|
---|
| 3587 | function VOLUME_Callback(hObject, eventdata, handles)
|
---|
| 3588 | %errordlg('command VOL not implemented yet')
|
---|
| 3589 | if ishandle(handles.UVMAT_title)
|
---|
| 3590 | delete(handles.UVMAT_title)
|
---|
| 3591 | end
|
---|
[61] | 3592 | UvData=get(handles.uvmat,'UserData');%read UvData properties stored on the uvmat interface
|
---|
[2] | 3593 | if isequal(get(handles.VOLUME,'Value'),1)
|
---|
| 3594 | set(handles.zoom,'Value',0)
|
---|
| 3595 | set(handles.zoom,'BackgroundColor',[0.7 0.7 0.7])
|
---|
| 3596 | set(handles.edit_vect,'Value',0)
|
---|
| 3597 | edit_vect_Callback(hObject, eventdata, handles)
|
---|
| 3598 | set(handles.edit,'Value',0)
|
---|
| 3599 | set(handles.edit,'BackgroundColor',[0.7 0.7 0.7])
|
---|
[61] | 3600 | % set(handles.cal,'Value',0)
|
---|
| 3601 | % set(handles.cal,'BackgroundColor',[0 1 0])
|
---|
[2] | 3602 | set(handles.edit_vect,'Value',0)
|
---|
| 3603 | edit_vect_Callback(hObject, eventdata, handles)
|
---|
| 3604 | %initiate set_object GUI
|
---|
| 3605 | data.TITLE='VOLUME';
|
---|
| 3606 | if isfield(UvData,'CoordType')
|
---|
| 3607 | data.CoordType=UvData.CoordType;
|
---|
| 3608 | end
|
---|
| 3609 | if isfield(UvData,'Mesh')&~isempty(UvData.Mesh)
|
---|
| 3610 | data.RangeY=UvData.Mesh;
|
---|
| 3611 | data.RangeX=UvData.Mesh;
|
---|
| 3612 | data.DX=UvData.Mesh;
|
---|
| 3613 | data.DY=UvData.Mesh;
|
---|
| 3614 | elseif isfield(UvData.Field,'AX')&isfield(UvData.Field,'AY')& isfield(UvData.Field,'A')%only image
|
---|
| 3615 | np=size(UvData.Field.A);
|
---|
| 3616 | meshx=(UvData.Field.AX(end)-UvData.Field.AX(1))/np(2);
|
---|
| 3617 | meshy=abs(UvData.Field.AY(end)-UvData.Field.AY(1))/np(1);
|
---|
| 3618 | data.RangeY=max(meshx,meshy);
|
---|
| 3619 | data.RangeX=max(meshx,meshy);
|
---|
| 3620 | data.DX=max(meshx,meshy);
|
---|
| 3621 | end
|
---|
| 3622 | data.ParentButton=handles.VOLUME;
|
---|
| 3623 | PlotHandles=get_plot_handles(handles);%get the handles of the interface elements setting the plotting parameters
|
---|
| 3624 | [hset_object,UvData.sethandles]=set_object(data,PlotHandles);% call the set_object interface with action on haxes,
|
---|
| 3625 | % associate the set_edit interface handle to the plotting axes
|
---|
| 3626 | if isfield(UvData,'SetObjectOrigin')
|
---|
| 3627 | pos_uvmat=get(huvmat,'Position');
|
---|
| 3628 | pos_set_object(1:2)=UvData.SetObjectOrigin + pos_uvmat(1:2);
|
---|
| 3629 | pos_set_object(3:4)=UvData.SetObjectSize .* pos_uvmat(3:4);
|
---|
| 3630 | set(hset_object,'Position',pos_set_object)
|
---|
| 3631 | end
|
---|
| 3632 | UvData.MouseAction='create_object';
|
---|
| 3633 | else
|
---|
| 3634 | set(handles.VOLUME,'BackgroundColor',[0 1 0])
|
---|
| 3635 | UvData.MouseAction='none';
|
---|
| 3636 | end
|
---|
| 3637 | set(huvmat,'UserData',UvData)
|
---|
| 3638 |
|
---|
| 3639 | %-------------------------------------------------------
|
---|
| 3640 | function edit_vect_Callback(hObject, eventdata, handles)
|
---|
| 3641 | %-------------------------------------------------------
|
---|
[55] | 3642 |
|
---|
| 3643 | UvData=get(handles.uvmat,'UserData');%read UvData properties stored on the uvmat interface
|
---|
[2] | 3644 | if isequal(get(handles.edit_vect,'Value'),1)
|
---|
[55] | 3645 | test_civ2=isequal(get(handles.civ2,'BackgroundColor'),[1 1 0]);
|
---|
| 3646 | test_civ1=isequal(get(handles.civ1,'BackgroundColor'),[1 1 0]);
|
---|
| 3647 | if ~test_civ2 && ~test_civ1
|
---|
| 3648 | msgbox_uvmat('ERROR','manual correction only possible for CIV1 or CIV2 velocity fields')
|
---|
| 3649 | end
|
---|
[2] | 3650 | set(handles.record,'Visible','on')
|
---|
| 3651 | set(handles.edit_vect,'BackgroundColor',[1 1 0])
|
---|
| 3652 | set(handles.edit,'Value',0)
|
---|
[61] | 3653 | set(handles.zoom,'Value',0)
|
---|
| 3654 | set(handles.zoom,'BackgroundColor',[0.7 0.7 0.7])
|
---|
| 3655 | % set(handles.create,'Value',0)
|
---|
| 3656 | % set(handles.create,'BackgroundColor',[0 1 0])
|
---|
[2] | 3657 | set(handles.edit,'BackgroundColor',[0.7 0.7 0.7])
|
---|
| 3658 | set(gcf,'Pointer','arrow')
|
---|
| 3659 | UvData.MouseAction='edit_vect';
|
---|
| 3660 | else
|
---|
| 3661 | set(handles.record,'Visible','off')
|
---|
| 3662 | set(handles.edit_vect,'BackgroundColor',[0.7 0.7 0.7])
|
---|
| 3663 | UvData.MouseAction='none';
|
---|
| 3664 | end
|
---|
[55] | 3665 | set(handles.uvmat,'UserData',UvData)
|
---|
[2] | 3666 |
|
---|
| 3667 | %----------------------------------------------
|
---|
| 3668 | function save_mask_Callback(hObject, eventdata, handles)
|
---|
| 3669 | %-----------------------------------------------------------------------
|
---|
[82] | 3670 | UvData=get(handles.uvmat,'UserData');
|
---|
[2] | 3671 |
|
---|
| 3672 | flag=1;
|
---|
| 3673 | npx=size(UvData.Field.A,2);
|
---|
| 3674 | npy=size(UvData.Field.A,1);
|
---|
| 3675 | xi=[0.5:npx-0.5];
|
---|
| 3676 | yi=[0.5:npy-0.5];
|
---|
| 3677 | [Xi,Yi]=meshgrid(xi,yi);
|
---|
| 3678 | if isfield(UvData,'Object')
|
---|
| 3679 | for iobj=1:length(UvData.Object)
|
---|
| 3680 | ObjectData=UvData.Object{iobj};
|
---|
| 3681 | if isfield(ObjectData,'ProjMode') &&(isequal(ObjectData.ProjMode,'mask_inside')||isequal(ObjectData.ProjMode,'mask_outside'));
|
---|
| 3682 | flagobj=1;
|
---|
| 3683 | testphys=0; %coordinates in pixels by default
|
---|
| 3684 | if isfield(ObjectData,'CoordType') && isequal(ObjectData.CoordType,'phys')
|
---|
| 3685 | if isfield(UvData,'XmlData')&& isfield(UvData.XmlData,'GeometryCalib')
|
---|
| 3686 | Calib=UvData.XmlData.GeometryCalib;
|
---|
| 3687 | testphys=1;
|
---|
| 3688 | end
|
---|
| 3689 | end
|
---|
| 3690 | if isfield(ObjectData,'Coord')& isfield(ObjectData,'Style')
|
---|
| 3691 | if isequal(ObjectData.Style,'polygon')
|
---|
| 3692 | X=ObjectData.Coord(:,1);
|
---|
| 3693 | Y=ObjectData.Coord(:,2);
|
---|
| 3694 | if testphys
|
---|
| 3695 | [X,Y]=px_XYZ(Calib,X,Y,0);% to generalise with 3D cases
|
---|
| 3696 | end
|
---|
[82] | 3697 | flagobj=~inpolygon(Xi,Yi,X',Y');%=0 inside the polygon, 1 outside
|
---|
[2] | 3698 | elseif isequal(ObjectData.Style,'ellipse')
|
---|
| 3699 | if testphys
|
---|
| 3700 | %[X,Y]=px_XYZ(Calib,X,Y,0);% TODO:create a polygon boundary and transform to phys
|
---|
| 3701 | end
|
---|
| 3702 | RangeX=max(ObjectData.RangeX);
|
---|
| 3703 | RangeY=max(ObjectData.RangeY);
|
---|
| 3704 | X2Max=RangeX*RangeX;
|
---|
| 3705 | Y2Max=RangeY*RangeY;
|
---|
| 3706 | distX=(Xi-ObjectData.Coord(1,1));
|
---|
| 3707 | distY=(Yi-ObjectData.Coord(1,2));
|
---|
| 3708 | flagobj=(distX.*distX/X2Max+distY.*distY/Y2Max)>1;
|
---|
| 3709 | elseif isequal(ObjectData.Style,'rectangle')
|
---|
| 3710 | if testphys
|
---|
| 3711 | %[X,Y]=px_XYZ(Calib,X,Y,0);% TODO:create a polygon boundary and transform to phys
|
---|
| 3712 | end
|
---|
| 3713 | distX=abs(Xi-ObjectData.Coord(1,1));
|
---|
| 3714 | distY=abs(Yi-ObjectData.Coord(1,2));
|
---|
| 3715 | flagobj=distX>max(ObjectData.RangeX) | distY>max(ObjectData.RangeY);
|
---|
| 3716 | end
|
---|
| 3717 | if isequal(ObjectData.ProjMode,'mask_outside')
|
---|
| 3718 | flagobj=~flagobj;
|
---|
| 3719 | end
|
---|
| 3720 | flag=flag & flagobj;
|
---|
| 3721 | end
|
---|
| 3722 | end
|
---|
| 3723 | end
|
---|
| 3724 | end
|
---|
| 3725 | % flag=~flag;
|
---|
| 3726 | %mask name
|
---|
| 3727 | RootPath=get(handles.RootPath,'String');
|
---|
| 3728 | RootFile=get(handles.RootFile,'String');
|
---|
| 3729 | if ~isempty(RootFile)&(isequal(RootFile(1),'/')| isequal(RootFile(1),'\'))
|
---|
| 3730 | RootFile(1)=[];
|
---|
| 3731 | end
|
---|
| 3732 | filebase=fullfile(RootPath,RootFile);
|
---|
| 3733 | list=get(handles.masklevel,'String');
|
---|
| 3734 | masknumber=num2str(length(list));
|
---|
| 3735 | maskindex=get(handles.masklevel,'Value');
|
---|
| 3736 | mask_name=name_generator([filebase '_' masknumber 'mask'],maskindex,1,'.png','_i');
|
---|
| 3737 | imflag=uint8(255*(0.392+0.608*flag));% =100 for flag=0 (vectors not computed when 20<imflag<200)
|
---|
| 3738 | imflag=flipdim(imflag,1);
|
---|
| 3739 | % imflag=uint8(255*flag);% =0 for flag=0 (vectors=0 when 20<imflag<200)
|
---|
[38] | 3740 | msgbox_uvmat('CONFIRMATION',[mask_name ' saved'])
|
---|
[2] | 3741 | imwrite(imflag,mask_name,'BitDepth',8);
|
---|
| 3742 |
|
---|
| 3743 | %display the mask
|
---|
| 3744 | %update_mask(handles,num_i1,num_j1)
|
---|
| 3745 | figure;
|
---|
| 3746 | vec=linspace(0,1,256);%define a linear greyscale colormap
|
---|
| 3747 | map=[vec' vec' vec'];
|
---|
| 3748 | colormap(map)
|
---|
| 3749 |
|
---|
| 3750 | image(imflag);
|
---|
| 3751 |
|
---|
| 3752 | %-------------------------------------------------------------------
|
---|
| 3753 | %-------------------------------------------------------------------
|
---|
| 3754 | % - FUNCTIONS FOR SETTING PLOTTING PARAMETERS
|
---|
| 3755 |
|
---|
| 3756 | %------------------------------------------------------------------
|
---|
| 3757 |
|
---|
| 3758 |
|
---|
| 3759 |
|
---|
| 3760 | %------------------------------------------------------------------
|
---|
| 3761 | % --- Executes on selection change in col_vec: choice of the color code.
|
---|
| 3762 | %
|
---|
| 3763 | function col_vec_Callback(hObject, eventdata, handles)
|
---|
| 3764 | %------------------------------------------------------------------
|
---|
| 3765 | % edit the choice for color code
|
---|
| 3766 | list_code=get(handles.col_vec,'String');% list menu fields
|
---|
| 3767 | index_code=get(handles.col_vec,'Value');% selected string index
|
---|
| 3768 | col_code= list_code{index_code(1)}; % selected field
|
---|
| 3769 | if isequal(col_code,'black') | isequal(col_code,'white')
|
---|
| 3770 | set(handles.slider1,'Visible','off')
|
---|
| 3771 | set(handles.slider2,'Visible','off')
|
---|
| 3772 | set(handles.colcode1,'Visible','off')
|
---|
| 3773 | set(handles.colcode2,'Visible','off')
|
---|
| 3774 | set(handles.AutoVecColor,'Visible','off')
|
---|
| 3775 | set_vec_col_bar(handles)
|
---|
| 3776 | else
|
---|
| 3777 | set(handles.slider1,'Visible','on')
|
---|
| 3778 | set(handles.slider2,'Visible','on')
|
---|
| 3779 | set(handles.colcode1,'Visible','on')
|
---|
| 3780 | set(handles.colcode2,'Visible','on')
|
---|
| 3781 | set(handles.AutoVecColor,'Visible','on')
|
---|
| 3782 | if isequal(col_code,'ima_cor')
|
---|
| 3783 | set(handles.AutoVecColor,'Value',0)%fixed scale by default
|
---|
| 3784 | set(handles.vec_col_bar,'Value',0)% 3 colors r,g,b by default
|
---|
| 3785 | set(handles.slider1,'Min',0);
|
---|
| 3786 | set(handles.slider1,'Max',1);
|
---|
| 3787 | set(handles.slider2,'Min',0);
|
---|
| 3788 | set(handles.slider2,'Max',1);
|
---|
| 3789 | % set(handles.min_title_vec,'String','0')
|
---|
| 3790 | set(handles.max_vec,'String','1')
|
---|
| 3791 | set(handles.colcode1,'String','0.333')
|
---|
| 3792 | colcode1_Callback(hObject, eventdata, handles)
|
---|
| 3793 | set(handles.colcode2,'String','0.666')
|
---|
| 3794 | colcode2_Callback(hObject, eventdata, handles)
|
---|
| 3795 | else
|
---|
| 3796 | set(handles.AutoVecColor,'Value',1)%auto scale between min,max by default
|
---|
| 3797 | set(handles.vec_col_bar,'Value',1)% colormap 'jet' by default
|
---|
| 3798 | minval=get(handles.slider1,'Min');
|
---|
| 3799 | maxval=get(handles.slider1,'Max');
|
---|
| 3800 | set(handles.slider1,'Value',minval)
|
---|
| 3801 | set(handles.slider2,'Value',maxval)
|
---|
| 3802 | set_vec_col_bar(handles)
|
---|
| 3803 | end
|
---|
| 3804 | % slider_update(handles)
|
---|
| 3805 | end
|
---|
| 3806 | %replot the current graph
|
---|
| 3807 | run0_Callback(hObject, eventdata, handles)
|
---|
| 3808 |
|
---|
| 3809 |
|
---|
| 3810 | %----------------------------------------------------------------
|
---|
| 3811 | % -- Executes on slider movement to set the color code
|
---|
| 3812 | %
|
---|
| 3813 | function slider1_Callback(hObject, eventdata, handles)
|
---|
| 3814 | %------------------------------------------------------------------
|
---|
| 3815 | slider1=get(handles.slider1,'Value');
|
---|
| 3816 | min_val=str2num(get(handles.min_vec,'String'));
|
---|
| 3817 | max_val=str2num(get(handles.max_vec,'String'));
|
---|
| 3818 | col=min_val+(max_val-min_val)*slider1;
|
---|
| 3819 | set(handles.colcode1,'String',num2str(col))
|
---|
| 3820 | if(get(handles.slider2,'Value') < col)%move also the second slider at the same value if needed
|
---|
| 3821 | set(handles.slider2,'Value',col)
|
---|
| 3822 | set(handles.colcode2,'String',num2str(col))
|
---|
| 3823 | end
|
---|
| 3824 | colcode1_Callback(hObject, eventdata, handles)
|
---|
| 3825 |
|
---|
| 3826 | %----------------------------------------------------------------
|
---|
| 3827 | % Executes on slider movement to set the color code
|
---|
| 3828 | %----------------------------------------------------------------
|
---|
| 3829 | function slider2_Callback(hObject, eventdata, handles)
|
---|
| 3830 | slider2=get(handles.slider2,'Value');
|
---|
| 3831 | min_val=str2num(get(handles.min_vec,'String'));
|
---|
| 3832 | max_val=str2num(get(handles.max_vec,'String'));
|
---|
| 3833 | col=min_val+(max_val-min_val)*slider2;
|
---|
| 3834 | set(handles.colcode2,'String',num2str(col))
|
---|
| 3835 | if(get(handles.slider1,'Value') > col)%move also the first slider at the same value if needed
|
---|
| 3836 | set(handles.slider1,'Value',col)
|
---|
| 3837 | set(handles.colcode1,'String',num2str(col))
|
---|
| 3838 | end
|
---|
| 3839 | colcode2_Callback(hObject, eventdata, handles)
|
---|
| 3840 |
|
---|
| 3841 | %----------------------------------------------------------------
|
---|
| 3842 | %execute on return carriage on the edit box corresponding to slider 1
|
---|
| 3843 | %----------------------------------------------------------------
|
---|
| 3844 | function colcode1_Callback(hObject, eventdata, handles)
|
---|
| 3845 | % col=str2num(get(handles.colcode1,'String'));
|
---|
| 3846 | % set(handles.slider1,'Value',col)
|
---|
| 3847 | set_vec_col_bar(handles)
|
---|
| 3848 | update_plot(handles)
|
---|
| 3849 |
|
---|
| 3850 | %----------------------------------------------------------------
|
---|
| 3851 | %execute on return carriage on the edit box corresponding to slider 2
|
---|
| 3852 | %----------------------------------------------------------------
|
---|
| 3853 | function colcode2_Callback(hObject, eventdata, handles)
|
---|
| 3854 | % col=str2num(get(handles.colcode2,'String'));
|
---|
| 3855 | % set(handles.slider2,'Value',col)
|
---|
| 3856 | % slider2_Callback(hObject, eventdata, handles)
|
---|
| 3857 | set_vec_col_bar(handles)
|
---|
| 3858 | update_plot(handles)
|
---|
| 3859 | %------------------------------------------------------------
|
---|
| 3860 | %update the slider values after displaying vectors
|
---|
| 3861 | %--------------------------------------------------------
|
---|
| 3862 | % function slider_update(handles,auto,minC,colcode1,colcode2,maxC)
|
---|
| 3863 | % set(handles.slider1,'Min',minC)
|
---|
| 3864 | % set(handles.slider1,'Max',maxC)
|
---|
| 3865 | % set(handles.slider2,'Min',minC)
|
---|
| 3866 | % set(handles.slider2,'Max',maxC)
|
---|
| 3867 | % set(handles.min_title_vec,'String',num2str(minC))
|
---|
| 3868 | % set(handles.max_vec,'String',num2str(maxC))
|
---|
| 3869 | % if auto
|
---|
| 3870 | % set(handles.colcode1,'String',num2str(colcode1,3))%update display
|
---|
| 3871 | % set(handles.colcode2,'String',num2str(colcode2,3))
|
---|
| 3872 | % end
|
---|
| 3873 | % set(handles.slider1,'Value',colcode1)%update slider with constant display
|
---|
| 3874 | % set(handles.slider2,'Value',colcode2)
|
---|
| 3875 | % set_vec_col_bar(handles)
|
---|
| 3876 |
|
---|
| 3877 |
|
---|
| 3878 | %-------------------------------------------------------
|
---|
| 3879 | % --- Executes on button press in AutoVecColor.
|
---|
| 3880 | %-------------------------------------------------------
|
---|
| 3881 | function vec_col_bar_Callback(hObject, eventdata, handles)
|
---|
| 3882 | set_vec_col_bar(handles)
|
---|
| 3883 |
|
---|
| 3884 | % %--------------------------------------------
|
---|
| 3885 | % %update the display of color code for vectors
|
---|
| 3886 | % %--------------------------------------------
|
---|
| 3887 | % function set_vec_col_bar(handles)
|
---|
| 3888 | % %get the image of the color display button 'vec_col_bar' in pixels
|
---|
| 3889 | % uni=get(handles.vec_col_bar,'Unit');
|
---|
| 3890 | % set(handles.vec_col_bar,'Unit','pixel')
|
---|
| 3891 | % pos_vert=get(handles.vec_col_bar,'Position');
|
---|
| 3892 | % set(handles.vec_col_bar,'Unit','Normalized')
|
---|
| 3893 | % width=ceil(pos_vert(3));
|
---|
| 3894 | % height=ceil(pos_vert(4));
|
---|
| 3895 | % %get slider indications
|
---|
| 3896 | % colcode.min=get(handles.slider1,'Min');
|
---|
| 3897 | % colcode.max=get(handles.slider1,'Max');
|
---|
| 3898 | % colcode.colcode1=get(handles.slider1,'Value');
|
---|
| 3899 | % colcode.colcode2=get(handles.slider2,'Value');
|
---|
| 3900 | % colcode.option=get(handles.vec_col_bar,'Value');
|
---|
| 3901 | % colcode.auto=1;
|
---|
| 3902 | % list_code=get(handles.col_vec,'String');% list menu fields
|
---|
| 3903 | % index_code=get(handles.col_vec,'Value');% selected string index
|
---|
| 3904 | % colcode.CName= list_code{index_code(1)}; % selected field used for vector color
|
---|
| 3905 | % vec_C=colcode.min+(colcode.max-colcode.min)*[0.5:width-0.5]/width;%sample of vec_C values from min to max
|
---|
| 3906 | % [colorlist,col_vec]=set_col_vec(colcode,vec_C);
|
---|
| 3907 | % oneheight=ones(1,height);
|
---|
| 3908 | % A1=colorlist(col_vec,1)*oneheight;
|
---|
| 3909 | % A2=colorlist(col_vec,2)*oneheight;
|
---|
| 3910 | % A3=colorlist(col_vec,3)*oneheight;
|
---|
| 3911 | % A(:,:,1)=A1';
|
---|
| 3912 | % A(:,:,2)=A2';
|
---|
| 3913 | % A(:,:,3)=A3';
|
---|
| 3914 | % set(handles.vec_col_bar,'Cdata',A)
|
---|
| 3915 |
|
---|
| 3916 | %--------------------------------------------------------
|
---|
| 3917 | % --- Executes on button press in cal.
|
---|
| 3918 | function cal_Callback(hObject, eventdata, handles)
|
---|
| 3919 |
|
---|
| 3920 |
|
---|
[61] | 3921 |
|
---|
[2] | 3922 | %-------------------------------------------------------------
|
---|
[39] | 3923 | % --- Executes on selection change in transform_fct.
|
---|
| 3924 | function transform_fct_Callback(hObject, eventdata, handles)
|
---|
[2] | 3925 | %-------------------------------------------------------------
|
---|
[39] | 3926 | global nb_builtin
|
---|
| 3927 |
|
---|
| 3928 | huvmat=get(handles.transform_fct,'parent');
|
---|
| 3929 | menu=get(handles.transform_fct,'String');
|
---|
| 3930 | ind_coord=get(handles.transform_fct,'Value');
|
---|
[2] | 3931 | coord_option=menu{ind_coord};
|
---|
[39] | 3932 | list_transform=get(handles.transform_fct,'UserData');
|
---|
[40] | 3933 | ff=functions(list_transform{end});
|
---|
[2] | 3934 | if isequal(coord_option,'more...');
|
---|
| 3935 | coord_fct='';
|
---|
| 3936 | prompt = {'Enter the name of the transform function'};
|
---|
| 3937 | dlg_title = 'user defined transform';
|
---|
| 3938 | num_lines= 1;
|
---|
| 3939 | [FileName, PathName, filterindex] = uigetfile( ...
|
---|
| 3940 | {'*.m', ' (*.m)';
|
---|
| 3941 | '*.m', '.m files '; ...
|
---|
| 3942 | '*.*', 'All Files (*.*)'}, ...
|
---|
[39] | 3943 | 'Pick a file', ff.file);
|
---|
[2] | 3944 | if isequal(PathName(end),'/')||isequal(PathName(end),'\')
|
---|
| 3945 | PathName(end)=[];
|
---|
| 3946 | end
|
---|
[39] | 3947 | transform_selected =fullfile(PathName,FileName);
|
---|
| 3948 | if ~exist(transform_selected,'file')
|
---|
| 3949 | return
|
---|
| 3950 | end
|
---|
| 3951 | [ppp,transform,ext_fct]=fileparts(FileName);% removes extension .m
|
---|
| 3952 | if ~isequal(ext_fct,'.m')
|
---|
| 3953 | msgbox_uvmat('ERROR','a Matlab function .m must be introduced');
|
---|
| 3954 | return
|
---|
| 3955 | end
|
---|
| 3956 | menu=update_menu(handles.transform_fct,transform);%add the selected fct to the menu
|
---|
| 3957 | ind_coord=get(handles.transform_fct,'Value');
|
---|
| 3958 | addpath(PathName)
|
---|
| 3959 | list_transform{ind_coord}=str2func(transform);% create the function handle corresponding to the newly seleced function
|
---|
| 3960 | set(handles.transform_fct,'UserData',list_transform)
|
---|
| 3961 | rmpath(PathName)
|
---|
| 3962 | % save the new menu in the personal file 'uvmat_perso.mat'
|
---|
| 3963 | dir_perso=prefdir;%personal Matalb directory
|
---|
| 3964 | profil_perso=fullfile(dir_perso,'uvmat_perso.mat');
|
---|
| 3965 | if exist(profil_perso,'file')
|
---|
| 3966 | for ilist=nb_builtin+1:numel(list_transform)
|
---|
| 3967 | ff=functions(list_transform{ilist});
|
---|
| 3968 | transform_fct{ilist-nb_builtin}=ff.file;
|
---|
| 3969 | end
|
---|
| 3970 | save (profil_perso,'transform_fct','-append'); %store the root name for future opening of uvmat
|
---|
| 3971 | end
|
---|
[2] | 3972 | end
|
---|
| 3973 |
|
---|
| 3974 | %check the current path to the selected function
|
---|
[40] | 3975 | if isa(list_transform{ind_coord},'function_handle')
|
---|
| 3976 | func=functions(list_transform{ind_coord});
|
---|
| 3977 | set(handles.path_transform,'String',fileparts(func.file)); %show the path to the senlected function
|
---|
| 3978 | else
|
---|
| 3979 | set(handles.path_transform,'String','')
|
---|
| 3980 | end
|
---|
[71] | 3981 |
|
---|
[2] | 3982 | set(handles.FixedLimits,'Value',0)
|
---|
| 3983 | set(handles.FixedLimits,'BackgroundColor',[0.7 0.7 0.7])
|
---|
| 3984 |
|
---|
| 3985 | UvData=get(huvmat,'UserData');
|
---|
| 3986 |
|
---|
| 3987 | %delete drawn objects
|
---|
| 3988 | hother=findobj('Tag','proj_object');%find all the proj objects
|
---|
| 3989 | for iobj=1:length(hother)
|
---|
| 3990 | delete_object(hother(iobj))
|
---|
| 3991 | end
|
---|
| 3992 | hother=findobj('Tag','DeformPoint');%find all the proj objects
|
---|
| 3993 | for iobj=1:length(hother)
|
---|
| 3994 | delete_object(hother(iobj))
|
---|
| 3995 | end
|
---|
| 3996 | hh=findobj('Tag','calib_points');
|
---|
| 3997 | if ~isempty(hh)
|
---|
| 3998 | delete(hh)
|
---|
| 3999 | end
|
---|
| 4000 | hhh=findobj('Tag','calib_marker');
|
---|
| 4001 | if ~isempty(hhh)
|
---|
| 4002 | delete(hhh)
|
---|
| 4003 | end
|
---|
| 4004 | if isfield(UvData,'Object')
|
---|
[71] | 4005 | UvData.Object=UvData.Object(1);
|
---|
[2] | 4006 | end
|
---|
[71] | 4007 | list_object=get(handles.list_object_1,'String');
|
---|
| 4008 | set(handles.list_object_1,'Value',1)
|
---|
| 4009 | set(handles.list_object_1,'String',list_object(1))
|
---|
| 4010 | set(handles.list_object_2,'Value',2)
|
---|
| 4011 | set(handles.list_object_2,'String',[list_object(1);{'...'}])
|
---|
| 4012 | list_object_2_Callback(hObject, eventdata, handles)
|
---|
[2] | 4013 |
|
---|
[71] | 4014 |
|
---|
| 4015 |
|
---|
[2] | 4016 | %delete mask if it is displayed
|
---|
| 4017 | if isequal(get(handles.mask_test,'Value'),1)%if the mask option is on
|
---|
| 4018 | UvData=rmfield(UvData,'MaskName'); %will impose mask refresh
|
---|
| 4019 | end
|
---|
| 4020 | set(huvmat,'UserData',UvData)
|
---|
| 4021 | run0_Callback(hObject, eventdata, handles)
|
---|
| 4022 |
|
---|
| 4023 | %--------------------------------------------
|
---|
| 4024 | function histo1_menu_Callback(hObject, eventdata, handles)
|
---|
| 4025 | %--------------------------------------------
|
---|
| 4026 | %plot first histo
|
---|
| 4027 | huvmat=get(handles.histo1_menu,'parent');
|
---|
| 4028 | histo_menu=get(handles.histo1_menu,'String');
|
---|
| 4029 | histo_value=get(handles.histo1_menu,'Value');
|
---|
| 4030 | FieldName=histo_menu{histo_value};
|
---|
| 4031 | UvData=get(huvmat,'UserData');
|
---|
| 4032 | update_histo(handles.histo_u,huvmat,FieldName)
|
---|
| 4033 |
|
---|
| 4034 | %----------------------------------------------
|
---|
| 4035 | function histo2_menu_Callback(hObject, eventdata, handles)
|
---|
| 4036 | %----------------------------------------------
|
---|
| 4037 | %plot second histo
|
---|
| 4038 | huvmat=get(handles.histo2_menu,'parent');
|
---|
| 4039 | histo_menu=get(handles.histo2_menu,'String');
|
---|
| 4040 | histo_value=get(handles.histo2_menu,'Value');
|
---|
| 4041 | FieldName=histo_menu{histo_value};
|
---|
| 4042 | UvData=get(huvmat,'UserData');
|
---|
| 4043 | update_histo(handles.histo_v,huvmat,FieldName)
|
---|
| 4044 |
|
---|
| 4045 |
|
---|
| 4046 | %--------------------------------------------
|
---|
| 4047 | %read the field .Fieldname stored in UvData and plot its histogram
|
---|
| 4048 | function update_histo(haxes,huvmat,FieldName)
|
---|
| 4049 | UvData=get(huvmat,'UserData');
|
---|
| 4050 |
|
---|
| 4051 | if ~isfield(UvData.Field,FieldName)
|
---|
| 4052 | msgbox_uvmat('ERROR',['no field ' FieldName ' for histogram'])
|
---|
| 4053 | return
|
---|
| 4054 | end
|
---|
| 4055 | Field=UvData.Field;
|
---|
| 4056 | FieldHisto=eval(['Field.' FieldName]);
|
---|
| 4057 | if isfield(Field,'FF') & ~isempty(Field.FF) & isequal(size(Field.FF),size(FieldHisto))
|
---|
| 4058 | indsel=find(Field.FF==0);%find values marked as false
|
---|
| 4059 | if ~isempty(indsel)
|
---|
| 4060 | FieldHisto=FieldHisto(indsel);
|
---|
| 4061 | end
|
---|
| 4062 | end
|
---|
| 4063 | if isempty(Field)
|
---|
| 4064 | msgbox_uvmat('ERROR',['empty field ' FieldName])
|
---|
| 4065 | else
|
---|
| 4066 | nxy=size(FieldHisto);
|
---|
| 4067 | Amin=double(min(min(min(FieldHisto))));%min of image
|
---|
| 4068 | Amax=double(max(max(max(FieldHisto))));%max of image
|
---|
| 4069 | if isequal(Amin,Amax)
|
---|
| 4070 | Histo.Txt=['uniform field =' num2str(Amin)];
|
---|
| 4071 | else
|
---|
| 4072 | Histo.ListVarName={FieldName,'histo'};
|
---|
| 4073 | if numel(nxy)==2
|
---|
| 4074 | Histo.VarDimName={FieldName,FieldName}; %dimensions for the histogram
|
---|
| 4075 | else %color images
|
---|
| 4076 | Histo.VarDimName={FieldName,{FieldName,'rgb'}}; %dimensions for the histogram
|
---|
| 4077 | end
|
---|
| 4078 | %unit
|
---|
| 4079 | units=[]; %default
|
---|
| 4080 | for ivar=1:numel(Field.ListVarName)
|
---|
| 4081 | if strcmp(Field.ListVarName{ivar},FieldName)
|
---|
| 4082 | if isfield(Field,'VarAttribute') && numel(Field.VarAttribute)>=ivar && isfield(Field.VarAttribute{ivar},'units')
|
---|
| 4083 | units=Field.VarAttribute{ivar}.units;
|
---|
| 4084 | break
|
---|
| 4085 | end
|
---|
| 4086 | end
|
---|
| 4087 | end
|
---|
| 4088 | if ~isempty(units)
|
---|
| 4089 | Histo.VarAttribute{1}.units=units;
|
---|
| 4090 | end
|
---|
| 4091 | eval(['Histo.' FieldName '=linspace(Amin,Amax,50);'])%absissa values for histo
|
---|
| 4092 | for col=1:size(FieldHisto,3)
|
---|
| 4093 | B=FieldHisto(:,:,col);
|
---|
| 4094 | C=reshape(double(B),1,nxy(1)*nxy(2));% reshape in a vector
|
---|
| 4095 | eval(['Histo.histo(:,col)=hist(C, Histo.' FieldName ');']); %calculate histogram
|
---|
| 4096 | end
|
---|
| 4097 | set(haxes,'XLimMode','auto')%reset auto mode (after zoom effect)
|
---|
| 4098 | set(haxes,'YLimMode','auto')
|
---|
| 4099 | plot_field(Histo,haxes);
|
---|
| 4100 | end
|
---|
| 4101 | end
|
---|
| 4102 |
|
---|
| 4103 |
|
---|
| 4104 |
|
---|
| 4105 | %------------------------------------------------
|
---|
| 4106 | %CALLBACKS FOR PLOTTING PARAMETERS
|
---|
| 4107 | %-------------------------------------------------
|
---|
| 4108 |
|
---|
| 4109 | %-----------------------------------------------------------------
|
---|
| 4110 | function MinA_Callback(hObject, eventdata, handles)
|
---|
| 4111 | %------------------------------------------
|
---|
| 4112 | set(handles.AutoScal,'Value',1) %suppress auto mode
|
---|
| 4113 | set(handles.AutoScal,'BackgroundColor',[1 1 0])
|
---|
| 4114 | update_plot(handles)
|
---|
| 4115 |
|
---|
| 4116 | %-----------------------------------------------------------------
|
---|
| 4117 | function MaxA_Callback(hObject, eventdata, handles)
|
---|
| 4118 | %--------------------------------------------
|
---|
| 4119 | set(handles.AutoScal,'Value',1) %suppress auto mode
|
---|
| 4120 | set(handles.AutoScal,'BackgroundColor',[1 1 0])
|
---|
| 4121 | update_plot(handles)
|
---|
| 4122 |
|
---|
| 4123 | %-----------------------------------------------
|
---|
| 4124 | function AutoScal_Callback(hObject, eventdata, handles)
|
---|
| 4125 | %--------------------------------------------
|
---|
| 4126 | test=get(handles.AutoScal,'Value');
|
---|
| 4127 | if test
|
---|
| 4128 | set(handles.AutoScal,'BackgroundColor',[1 1 0])
|
---|
| 4129 | else
|
---|
| 4130 | set(handles.AutoScal,'BackgroundColor',[0.7 0.7 0.7])
|
---|
| 4131 | update_plot(handles);
|
---|
| 4132 | % set(handles.MinA,'String',num2str(ScalOut.MinA,3))
|
---|
| 4133 | % set(handles.MaxA,'String',num2str(ScalOut.MaxA,3))
|
---|
| 4134 | end
|
---|
| 4135 |
|
---|
| 4136 | %-------------------------------------------------------------------
|
---|
| 4137 | function BW_Callback(hObject, eventdata, handles)
|
---|
| 4138 | %-------------------------------------------------------------------
|
---|
| 4139 | update_plot(handles)
|
---|
| 4140 |
|
---|
| 4141 | %-------------------------------------------------------------------
|
---|
| 4142 | function Contours_Callback(hObject, eventdata, handles)
|
---|
| 4143 | %-------------------------------------------------------------------
|
---|
| 4144 | val=get(handles.Contours,'Value');
|
---|
| 4145 | if val==2
|
---|
| 4146 | set(handles.interval_txt,'Visible','on')
|
---|
| 4147 | set(handles.IncrA,'Visible','on')
|
---|
| 4148 | else
|
---|
| 4149 | set(handles.interval_txt,'Visible','off')
|
---|
| 4150 | set(handles.IncrA,'Visible','off')
|
---|
| 4151 | end
|
---|
| 4152 | update_plot(handles)
|
---|
| 4153 |
|
---|
| 4154 | %-------------------------------------------------------------------
|
---|
| 4155 | function IncrA_Callback(hObject, eventdata, handles)
|
---|
| 4156 | %-------------------------------------------------------------------
|
---|
| 4157 | update_plot(handles)
|
---|
| 4158 |
|
---|
| 4159 | %-------------------------------------------------------------------
|
---|
| 4160 | function HideWarning_Callback(hObject, eventdata, handles)
|
---|
| 4161 | %-------------------------------------------------------------------
|
---|
| 4162 | update_plot(handles)
|
---|
| 4163 |
|
---|
| 4164 | %-------------------------------------------------------------------
|
---|
| 4165 | function HideFalse_Callback(hObject, eventdata, handles)
|
---|
| 4166 | %-------------------------------------------------------------------
|
---|
| 4167 | update_plot(handles)
|
---|
| 4168 |
|
---|
| 4169 | %-------------------------------------------------------------------
|
---|
| 4170 | function VecScale_Callback(hObject, eventdata, handles)
|
---|
| 4171 | %-------------------------------------------------------------------
|
---|
| 4172 | set(handles.AutoVec,'Value',1);
|
---|
| 4173 | set(handles.AutoVec,'BackgroundColor',[1 1 0])
|
---|
| 4174 | update_plot(handles)
|
---|
| 4175 |
|
---|
| 4176 | %-------------------------------------------------------------------
|
---|
| 4177 | function AutoVec_Callback(hObject, eventdata, handles)
|
---|
| 4178 | %-------------------------------------------------------------------
|
---|
| 4179 | test=get(handles.AutoVec,'Value');
|
---|
| 4180 | if test
|
---|
| 4181 | set(handles.AutoVec,'BackgroundColor',[1 1 0])
|
---|
| 4182 | else
|
---|
| 4183 | update_plot(handles);
|
---|
| 4184 | %set(handles.VecScale,'String',num2str(ScalOut.VecScale,3))
|
---|
| 4185 | set(handles.AutoVec,'BackgroundColor',[0.7 0.7 0.7])
|
---|
| 4186 | end
|
---|
| 4187 |
|
---|
| 4188 | %-------------------------------------------------------
|
---|
| 4189 | % --- Executes on selection change in decimate4 (nb_vec/4).
|
---|
| 4190 | %-------------------------------------------------------
|
---|
| 4191 | function decimate4_Callback(hObject, eventdata, handles)
|
---|
| 4192 | update_plot(handles)
|
---|
| 4193 |
|
---|
| 4194 |
|
---|
| 4195 | %-------------------------------------------------------
|
---|
| 4196 | % --- Executes on selection change in color_code menu
|
---|
| 4197 | %-------------------------------------------------------
|
---|
| 4198 | function color_code_Callback(hObject, eventdata, handles)
|
---|
| 4199 | set_vec_col_bar(handles)
|
---|
| 4200 | update_plot(handles);
|
---|
| 4201 |
|
---|
| 4202 | %-------------------------------------------------------
|
---|
| 4203 | % --- Executes on button press in AutoVecColor.
|
---|
| 4204 | %-------------------------------------------------------
|
---|
| 4205 | function AutoVecColor_Callback(hObject, eventdata, handles)
|
---|
| 4206 | test=get(handles.AutoVecColor,'Value');
|
---|
| 4207 | if test
|
---|
| 4208 | set(handles.AutoVecColor,'BackgroundColor',[1 1 0])
|
---|
| 4209 | else
|
---|
| 4210 | update_plot(handles);
|
---|
| 4211 | %set(handles.VecScale,'String',num2str(ScalOut.VecScale,3))
|
---|
| 4212 | set(handles.AutoVecColor,'BackgroundColor',[0.7 0.7 0.7])
|
---|
| 4213 | end
|
---|
| 4214 | %set_vec_col_bar(handles)
|
---|
| 4215 |
|
---|
| 4216 | %-------------------------------------------------------
|
---|
| 4217 | % --- Executes on selection change in max_vec.
|
---|
| 4218 | %-------------------------------------------------------
|
---|
| 4219 | function min_vec_Callback(hObject, eventdata, handles)
|
---|
| 4220 | max_vec_Callback(hObject, eventdata, handles)
|
---|
| 4221 |
|
---|
| 4222 | % --- Executes on selection change in max_vec.
|
---|
| 4223 | function max_vec_Callback(hObject, eventdata, handles)
|
---|
| 4224 | set(handles.AutoVecColor,'Value',1)
|
---|
| 4225 | AutoVecColor_Callback(hObject, eventdata, handles)
|
---|
| 4226 | min_val=str2num(get(handles.min_vec,'String'));
|
---|
| 4227 | max_val=str2num(get(handles.max_vec,'String'));
|
---|
| 4228 | slider1=get(handles.slider1,'Value');
|
---|
| 4229 | slider2=get(handles.slider2,'Value');
|
---|
| 4230 | colcode1=min_val+(max_val-min_val)*slider1;
|
---|
| 4231 | colcode2=min_val+(max_val-min_val)*slider2;
|
---|
| 4232 | set(handles.colcode1,'String',num2str(colcode1))
|
---|
| 4233 | set(handles.colcode2,'String',num2str(colcode2))
|
---|
| 4234 | update_plot(handles);
|
---|
| 4235 |
|
---|
| 4236 | %-------------------------------------------------------------------
|
---|
| 4237 | %update the display of color code for vectors
|
---|
| 4238 | function set_vec_col_bar(handles)
|
---|
| 4239 | %-------------------------------------------------------------------
|
---|
| 4240 | %get the image of the color display button 'vec_col_bar' in pixels
|
---|
| 4241 | set(handles.vec_col_bar,'Unit','pixel');
|
---|
| 4242 | pos_vert=get(handles.vec_col_bar,'Position');
|
---|
| 4243 | set(handles.vec_col_bar,'Unit','Normalized');
|
---|
| 4244 | width=ceil(pos_vert(3));
|
---|
| 4245 | height=ceil(pos_vert(4));
|
---|
| 4246 |
|
---|
| 4247 | %get slider indications
|
---|
| 4248 | list=get(handles.color_code,'String');
|
---|
| 4249 | ichoice=get(handles.color_code,'Value');
|
---|
| 4250 | colcode.ColorCode=list{ichoice};
|
---|
| 4251 | colcode.MinC=str2num(get(handles.min_vec,'String'));
|
---|
| 4252 | colcode.MaxC=str2num(get(handles.max_vec,'String'));
|
---|
| 4253 | test3color=strcmp(colcode.ColorCode,'rgb') || strcmp(colcode.ColorCode,'bgr');
|
---|
| 4254 | if test3color
|
---|
| 4255 | colcode.colcode1=str2num(get(handles.colcode1,'String'));
|
---|
| 4256 | colcode.colcode2=str2num(get(handles.colcode2,'String'));
|
---|
| 4257 | end
|
---|
| 4258 | % colcode.option=get(handles.vec_col_bar,'Value');
|
---|
| 4259 | colcode.FixedCbounds=0;
|
---|
| 4260 | % list_code=get(handles.col_vec,'String');% list menu fields
|
---|
| 4261 | % index_code=get(handles.col_vec,'Value');% selected string index
|
---|
| 4262 | % colcode.CName= list_code{index_code(1)}; % selected field used for vector color
|
---|
| 4263 | colcode.FixedCbounds=1;
|
---|
| 4264 | vec_C=colcode.MinC+(colcode.MaxC-colcode.MinC)*[0.5:width-0.5]/width;%sample of vec_C values from min to max
|
---|
| 4265 | [colorlist,col_vec]=set_col_vec(colcode,vec_C);
|
---|
| 4266 | oneheight=ones(1,height);
|
---|
| 4267 | A1=colorlist(col_vec,1)*oneheight;
|
---|
| 4268 | A2=colorlist(col_vec,2)*oneheight;
|
---|
| 4269 | A3=colorlist(col_vec,3)*oneheight;
|
---|
| 4270 | A(:,:,1)=A1';
|
---|
| 4271 | A(:,:,2)=A2';
|
---|
| 4272 | A(:,:,3)=A3';
|
---|
| 4273 | set(handles.vec_col_bar,'Cdata',A)
|
---|
| 4274 |
|
---|
| 4275 |
|
---|
| 4276 | %-------------------------------------------------------------------
|
---|
| 4277 | function [PlotType,ScalOut]=update_plot(handles)
|
---|
| 4278 | %-------------------------------------------------------------------
|
---|
| 4279 | haxes= handles.axes3;
|
---|
| 4280 | AxeData=get(haxes,'UserData');
|
---|
| 4281 | PlotParam=read_plot_param(handles);
|
---|
| 4282 | [PlotType,PlotParamOut]= plot_field(AxeData,haxes,PlotParam,1);
|
---|
| 4283 | write_plot_param(handles,PlotParamOut); %update the auto plot parameters
|
---|
| 4284 |
|
---|
| 4285 | %-------------------------------------------------------------------
|
---|
| 4286 | % --- Executes on button press in grid.
|
---|
| 4287 | function grid_Callback(hObject, eventdata, handles)
|
---|
| 4288 |
|
---|
[61] | 4289 |
|
---|
[2] | 4290 |
|
---|
| 4291 | %-------------------------------------------------------------------
|
---|
| 4292 | % --- Executes on selection change in edit.
|
---|
| 4293 | function edit_Callback(hObject, eventdata, handles)
|
---|
| 4294 | %-------------------------------------------------------------------
|
---|
[61] | 4295 | UvData=get(handles.uvmat,'UserData');%read UvData properties stored on the uvmat interface
|
---|
[2] | 4296 | test=get(handles.edit,'Value');
|
---|
| 4297 | if test
|
---|
| 4298 | UvData.MouseAction='edit_object';
|
---|
| 4299 | set(handles.edit,'BackgroundColor',[1,1,0])
|
---|
| 4300 | %suppress the other options
|
---|
| 4301 | set(handles.zoom,'Value',0)
|
---|
| 4302 | zoom_Callback(hObject, eventdata, handles)
|
---|
| 4303 | set(handles.edit_vect,'Value',0)
|
---|
| 4304 | edit_vect_Callback(hObject, eventdata, handles)
|
---|
[61] | 4305 | %list_object_Callback(hObject, eventdata, handles)
|
---|
[2] | 4306 | else
|
---|
| 4307 | UvData.MouseAction='none';
|
---|
| 4308 | set(handles.edit,'BackgroundColor',[0.7,0.7,0.7])
|
---|
| 4309 | end
|
---|
[61] | 4310 | set(handles.uvmat,'UserData',UvData);
|
---|
| 4311 | hset_object=findobj(allchild(0),'Tag','set_object');
|
---|
| 4312 | if ~isempty(hset_object)
|
---|
| 4313 | hhset_object=guidata(hset_object);
|
---|
| 4314 | if test
|
---|
[71] | 4315 | set(hhset_object.PLOT,'enable','on');
|
---|
[61] | 4316 | else
|
---|
[71] | 4317 | set(hhset_object.PLOT,'enable','off');
|
---|
[61] | 4318 | end
|
---|
| 4319 | end
|
---|
[2] | 4320 |
|
---|
[61] | 4321 | %------------------------------------------------------------------------
|
---|
| 4322 | % --- Executes on selection change in list_object_1.
|
---|
| 4323 | function list_object_1_Callback(hObject, eventdata, handles)
|
---|
| 4324 | %------------------------------------------------------------------------
|
---|
| 4325 | list_str=get(handles.list_object_1,'String');
|
---|
| 4326 | IndexObj=get(handles.list_object_1,'Value');
|
---|
| 4327 | str_1=list_str{IndexObj};
|
---|
| 4328 | val_2=get(handles.list_object_2,'Value');
|
---|
| 4329 | str_2=get(handles.list_object_2,'String');
|
---|
[71] | 4330 | if isequal(val_2,IndexObj)% if the first selection is equal to the second, it will suppress the second
|
---|
| 4331 | set(handles.list_object_2,'Value',numel(str_2))%select the end of the list ('...')
|
---|
[61] | 4332 | list_object_2_Callback(hObject, eventdata, handles)
|
---|
| 4333 | end
|
---|
[71] | 4334 | update_object(handles,IndexObj,1,str_1)
|
---|
[61] | 4335 |
|
---|
| 4336 | %------------------------------------------------------------------------
|
---|
| 4337 | % --- Executes on selection change in list_object_1.
|
---|
| 4338 | function list_object_2_Callback(hObject, eventdata, handles)
|
---|
| 4339 | %------------------------------------------------------------------------
|
---|
| 4340 | list_str=get(handles.list_object_2,'String');
|
---|
| 4341 | IndexObj=get(handles.list_object_2,'Value');
|
---|
| 4342 | if isequal(list_str{IndexObj},'...')
|
---|
[71] | 4343 | hview_field=findobj(allchild(0),'Tag','view_field');
|
---|
[61] | 4344 | if ~isempty(hview_field)
|
---|
| 4345 | delete(hview_field)
|
---|
| 4346 | end
|
---|
| 4347 | else
|
---|
[71] | 4348 | update_object(handles,IndexObj,2,list_str{IndexObj})
|
---|
[61] | 4349 | end
|
---|
| 4350 |
|
---|
| 4351 | %------------------------------------------------------------------------
|
---|
[71] | 4352 | function update_object(handles,IndexObj,option,ObjectName)
|
---|
[61] | 4353 | %------------------------------------------------------------------------
|
---|
[60] | 4354 | UvData=get(handles.uvmat,'UserData');%read UvData properties stored on the uvmat interface
|
---|
[2] | 4355 | if ~(length(UvData.Object)>=IndexObj);
|
---|
| 4356 | return
|
---|
| 4357 | end
|
---|
| 4358 | ObjectData=UvData.Object{IndexObj};
|
---|
[71] | 4359 | ObjectData.Name=ObjectName;
|
---|
| 4360 | if isequal(get(handles.edit,'Value'),1)
|
---|
| 4361 | ObjectData.enable_plot=1; % desable the PLOT option in the set_object GUI (editing mode
|
---|
[2] | 4362 | end
|
---|
| 4363 | PlotHandles=get_plot_handles(handles);%get the handles of the interface elements setting the plotting parameters
|
---|
| 4364 | ZBounds=0; % default
|
---|
| 4365 | if isfield(UvData,'ZMin') && isfield(UvData,'ZMax')
|
---|
| 4366 | ZBounds(1)=UvData.ZMin; %minimum for the Z slider
|
---|
| 4367 | ZBounds(2)=UvData.ZMax;%maximum for the Z slider
|
---|
| 4368 | end
|
---|
[71] | 4369 | hset_object=findobj(allchild(0),'tag','set_object');
|
---|
[61] | 4370 | if ~isempty(hset_object)
|
---|
| 4371 | delete(hset_object)% delete existing version of set_object
|
---|
| 4372 | end
|
---|
| 4373 | hset_object=set_object(ObjectData,PlotHandles,ZBounds);% call the set_object interface,
|
---|
[71] | 4374 | set(hset_object,'name',ObjectName)
|
---|
[82] | 4375 |
|
---|
| 4376 | % %project the current field on the object and plot it
|
---|
| 4377 | % ProjData= proj_field(UvData.Field,ObjectData,IndexObj);%project the current interface field on ObjectData
|
---|
| 4378 | % if option==1%length(UvData.Object)>= IndexObj && isfield(UvData.Object{IndexObj},'plotaxes')&& ishandle(UvData.Object{IndexObj}.plotaxes)
|
---|
| 4379 | % plot_field(ProjData,handles.axes3,PlotHandles);
|
---|
| 4380 | % UvData.Object{IndexObj}.plotaxes=handles.axes3;
|
---|
| 4381 | % else
|
---|
| 4382 | % UvData.Object{IndexObj}.plotaxes=view_field(ProjData);
|
---|
[76] | 4383 | % end
|
---|
[82] | 4384 | % set(handles.uvmat,'UserData',UvData)
|
---|
| 4385 | % hother=findobj('Tag','proj_object');%find all the proj objects
|
---|
| 4386 | % for iobj=1:length(hother)
|
---|
| 4387 | % if isequal(get(hother(iobj),'Type'),'rectangle')|isequal(get(hother(iobj),'Type'),'patch')
|
---|
| 4388 | % set(hother(iobj),'EdgeColor','b')
|
---|
| 4389 | % if isequal(get(hother(iobj),'FaceColor'),'m')
|
---|
| 4390 | % set(hother(iobj),'FaceColor','b')
|
---|
| 4391 | % end
|
---|
| 4392 | % elseif isequal(get(hother(iobj),'Type'),'image')
|
---|
| 4393 | % Acolor=get(hother(iobj),'CData');
|
---|
| 4394 | % Acolor(:,:,1)=zeros(size(Acolor,1),size(Acolor,2));
|
---|
| 4395 | % set(hother(iobj),'CData',Acolor);
|
---|
| 4396 | % else
|
---|
| 4397 | % set(hother(iobj),'Color','b')
|
---|
| 4398 | % end
|
---|
| 4399 | % set(hother(iobj),'Selected','off')
|
---|
| 4400 | % end
|
---|
[2] | 4401 | hother=findobj('Tag','DeformPoint');
|
---|
| 4402 | set(hother,'Color','b');
|
---|
| 4403 | set(hother,'Selected','off')
|
---|
| 4404 | if isfield(ObjectData,'HandlesDisplay')
|
---|
| 4405 | for iview=1:length(ObjectData.HandlesDisplay)
|
---|
| 4406 | if ishandle(ObjectData.HandlesDisplay(iview))
|
---|
| 4407 | uistack(ObjectData.HandlesDisplay(iview),'top')
|
---|
| 4408 | linetype=get(ObjectData.HandlesDisplay(iview),'Type');
|
---|
| 4409 | if isequal(linetype,'line')
|
---|
| 4410 | set(ObjectData.HandlesDisplay(iview),'Color','m'); %set the selected object to magenta color
|
---|
| 4411 | elseif isequal(linetype,'rectangle')
|
---|
| 4412 | set(ObjectData.HandlesDisplay(iview),'EdgeColor','m'); %set the selected object to magenta color
|
---|
| 4413 | elseif isequal(linetype,'patch')
|
---|
| 4414 | set(ObjectData.HandlesDisplay(iview),'FaceColor','m'); %set the selected object to magenta color
|
---|
| 4415 | end
|
---|
| 4416 | SubObjectData=get(ObjectData.HandlesDisplay(iview),'UserData');
|
---|
| 4417 | if isfield(SubObjectData,'SubObject')& ishandle(SubObjectData.SubObject)
|
---|
| 4418 | uistack(SubObjectData.SubObject,'top')
|
---|
| 4419 | for iobj=1:length(SubObjectData.SubObject)
|
---|
| 4420 | hsub=SubObjectData.SubObject(iobj);
|
---|
| 4421 | if isequal(get(hsub,'Type'),'rectangle')
|
---|
| 4422 | set(hsub,'EdgeColor','m'); %set the selected object to magenta color
|
---|
| 4423 | elseif isequal(get(hsub,'Type'),'image')
|
---|
| 4424 | Acolor=get(hsub,'CData');
|
---|
| 4425 | Acolor(:,:,1)=Acolor(:,:,3);
|
---|
| 4426 | set(hsub,'CData',Acolor);
|
---|
| 4427 | else
|
---|
| 4428 | set(hsub,'Color','m')
|
---|
| 4429 | end
|
---|
| 4430 | end
|
---|
| 4431 | end
|
---|
| 4432 | if isfield(SubObjectData,'DeformPoint')& ishandle(SubObjectData.DeformPoint)
|
---|
| 4433 | set(SubObjectData.DeformPoint,'Color','m')
|
---|
| 4434 | end
|
---|
| 4435 | end
|
---|
| 4436 | end
|
---|
| 4437 | end
|
---|
[61] | 4438 | pause(0.1)
|
---|
| 4439 | figure(hset_object)%put set_object in front
|
---|
[2] | 4440 |
|
---|
| 4441 | %------------------------------------------------------
|
---|
| 4442 | % --- Executes on button press in Menu/Export/field in workspace.
|
---|
| 4443 | %------------------------------------------------------
|
---|
| 4444 | function MenuExportField_Callback(hObject, eventdata, handles)
|
---|
| 4445 | global CurData
|
---|
[77] | 4446 | CurData=get(handles.uvmat,'UserData');
|
---|
[82] | 4447 | evalin('base','global CurData')%make CurData global in the workspace
|
---|
| 4448 | display(['current field :'])
|
---|
[2] | 4449 | evalin('base','CurData') %display CurData in the workspace
|
---|
[82] | 4450 | commandwindow; %brings the Matlab command window to the front
|
---|
[2] | 4451 |
|
---|
| 4452 | %------------------------------------------------------
|
---|
| 4453 | % --- Executes on button press in Menu/Export/extract figure.
|
---|
| 4454 | %------------------------------------------------------
|
---|
| 4455 | function MenuExport_plot_Callback(hObject, eventdata, handles)
|
---|
| 4456 | huvmat=get(handles.MenuExport_plot,'parent');
|
---|
| 4457 | UvData=get(huvmat,'UserData');
|
---|
| 4458 | hfig=figure;
|
---|
| 4459 | newaxes=copyobj(handles.axes3,hfig);
|
---|
| 4460 | map=colormap(handles.axes3);
|
---|
| 4461 | colormap(map);%transmit the current colormap to the zoom fig
|
---|
| 4462 | colorbar
|
---|
| 4463 |
|
---|
| 4464 |
|
---|
| 4465 | % --------------------------------------------------------------------
|
---|
| 4466 | function Insert_Callback(hObject, eventdata, handles)
|
---|
| 4467 |
|
---|
| 4468 |
|
---|
| 4469 | % --------------------------------------------------------------------
|
---|
| 4470 | function MenuHelp_Callback(hObject, eventdata, handles)
|
---|
| 4471 | % --------------------------------------------------------------------
|
---|
| 4472 | path_to_uvmat=which ('uvmat');% check the path of uvmat
|
---|
| 4473 | pathelp=fileparts(path_to_uvmat);
|
---|
[36] | 4474 | helpfile=fullfile(pathelp,'uvmat_doc','uvmat_doc.html');
|
---|
| 4475 | if isempty(dir(helpfile)), msgbox_uvmat('ERROR','Please put the help file uvmat_doc.html in the sub-directory /uvmat_doc of the UVMAT package')
|
---|
[2] | 4476 | else
|
---|
[36] | 4477 | addpath (fullfile(pathelp,'uvmat_doc'))
|
---|
[2] | 4478 | web(helpfile);
|
---|
| 4479 | end
|
---|
| 4480 |
|
---|
| 4481 |
|
---|
| 4482 | % --------------------------------------------------------------------
|
---|
| 4483 | function MenuExportMovie_Callback(hObject, eventdata, handles)
|
---|
| 4484 | % --------------------------------------------------------------------
|
---|
| 4485 | set(handles.MenuExportMovie,'BusyAction','queue')% activate the button
|
---|
| 4486 | huvmat=get(handles.run0,'parent');
|
---|
| 4487 | UvData=get(huvmat,'UserData');
|
---|
| 4488 | [xx,xx,FileBase]=read_file_boxes(handles);
|
---|
| 4489 | %read the current input file name
|
---|
| 4490 | prompt = {'movie file name';'frames per second';'frame resolution (*[512x384] pixels)';'axis position relative to the frame';'total frame number (starting from the current uvmat display)'};
|
---|
| 4491 | dlg_title = 'select properties of the output avi movie';
|
---|
| 4492 | num_lines= 1;
|
---|
| 4493 | nbfield_cell=get(handles.last_i,'String');
|
---|
| 4494 | def = {[FileBase '_out.avi'];'10';'1';'[0.03 0.05 0.95 0.92]';'10'};
|
---|
| 4495 | answer = inputdlg(prompt,dlg_title,num_lines,def,'on');
|
---|
| 4496 | aviname=answer{1};
|
---|
| 4497 | fps=str2num(answer{2});
|
---|
| 4498 | % check for existing file with output name aviname
|
---|
| 4499 | if exist(aviname,'file')
|
---|
| 4500 | backup=aviname;
|
---|
| 4501 | testexist=2;
|
---|
| 4502 | while testexist==2
|
---|
| 4503 | backup=[backup '~'];
|
---|
| 4504 | testexist=exist(backup,'file');
|
---|
| 4505 | end
|
---|
| 4506 | [success,message]=copyfile(aviname,backup);%make backup of the existing file
|
---|
| 4507 | if isequal(success,1)
|
---|
| 4508 | delete(aviname)%delete existing file
|
---|
| 4509 | else
|
---|
| 4510 | msgbox_uvmat('ERROR',message)
|
---|
| 4511 | return
|
---|
| 4512 | end
|
---|
| 4513 | end
|
---|
| 4514 | %create avi open
|
---|
| 4515 | aviobj=avifile(aviname,'Compression','None','fps',fps);
|
---|
| 4516 |
|
---|
| 4517 | %display first view for tests
|
---|
| 4518 | newfig=figure;
|
---|
| 4519 | newaxes=copyobj(handles.axes3,newfig);%new plotting axes in the new figure
|
---|
| 4520 | set(newaxes,'Tag','movieaxes')
|
---|
| 4521 | nbpix=[512 384]*str2num(answer{3});
|
---|
| 4522 | set(gcf,'Position',[1 1 nbpix])% resolution XVGA
|
---|
| 4523 | set(newaxes,'Position',eval(answer{4}));
|
---|
| 4524 | map=colormap(handles.axes3);
|
---|
| 4525 | colormap(map);%transmit the current colormap to the zoom fig
|
---|
| 4526 | msgbox_uvmat('INPUT_Y-N',{['adjust figure ' num2str(newfig) ' with its matlab edit menu '] ;...
|
---|
| 4527 | ['then press OK to get the avi movie as a copy of figure ' num2str(newfig) ' display']});
|
---|
| 4528 | UvData.Object{1}.plotaxes=newaxes;% the axis in the new figure becomes the current main plotting axes
|
---|
| 4529 | set(huvmat,'UserData',UvData);
|
---|
| 4530 | increment=str2num(get(handles.increment_scan,'String')); %get the field increment d
|
---|
| 4531 | set(handles.STOP,'Visible','on')
|
---|
| 4532 | set(handles.speed,'Visible','on')
|
---|
| 4533 | set(handles.speed_txt,'Visible','on')
|
---|
[81] | 4534 | set(handles.Movie,'BusyAction','queue')
|
---|
[2] | 4535 |
|
---|
| 4536 | imin=str2num(get(handles.i1,'String'));
|
---|
| 4537 | imax=str2num(answer{5});
|
---|
| 4538 | % if isfield(UvData,'Time')
|
---|
| 4539 | htitle=get(newaxes,'Title');
|
---|
| 4540 | xlim=get(newaxes,'XLim');
|
---|
| 4541 | ylim=get(newaxes,'YLim');
|
---|
| 4542 | set(htitle,'Position',[xlim(2)+0.07*(xlim(2)-xlim(1)) ylim(2)-0.05*(ylim(2)-ylim(1)) 0])
|
---|
| 4543 | time_str=get(handles.abs_time,'String');
|
---|
| 4544 | set(htitle,'String',['t=' time_str])
|
---|
| 4545 | set(handles.speed,'Value',1)
|
---|
| 4546 | for i=1:imax
|
---|
| 4547 | if get(handles.speed,'Value')~=0 & isequal(get(handles.MenuExportMovie,'BusyAction'),'queue') % enable STOP command
|
---|
| 4548 | runpm(hObject,eventdata,handles,increment)
|
---|
| 4549 | drawnow
|
---|
| 4550 | time_str=get(handles.abs_time,'String');
|
---|
| 4551 | if ishandle(htitle)
|
---|
| 4552 | set(htitle,'String',['t=' time_str])
|
---|
| 4553 | end
|
---|
| 4554 | mov=getframe(newfig);
|
---|
| 4555 | aviobj=addframe(aviobj,mov);
|
---|
| 4556 | end
|
---|
| 4557 | end
|
---|
| 4558 | aviobj=close(aviobj);
|
---|
| 4559 | UvData.Object{1}.plotaxes=handles.axes3;
|
---|
| 4560 | set(huvmat,'UserData',UvData);
|
---|
| 4561 | msgbox_uvmat('CONFIRMATION',{['movie ' aviname ' created '];['with ' num2str(imax) ' frames']})
|
---|
| 4562 |
|
---|
| 4563 |
|
---|
| 4564 | % ------------------------------------------------------------------
|
---|
| 4565 | function MenuCalib_Callback(hObject, eventdata, handles)
|
---|
[71] | 4566 |
|
---|
[61] | 4567 | UvData=get(handles.uvmat,'UserData');%read UvData properties stored on the uvmat interface
|
---|
[71] | 4568 |
|
---|
| 4569 | %suppress competing options
|
---|
[61] | 4570 | set(handles.zoom,'Value',0)
|
---|
| 4571 | set(handles.zoom,'BackgroundColor',[0.7 0.7 0.7])
|
---|
[71] | 4572 | set(handles.MenuMask,'enable','off')
|
---|
| 4573 | set(handles.MenuGrid,'enable','off')
|
---|
[67] | 4574 | set(handles.MenuObject,'enable','off')
|
---|
| 4575 | set(handles.MenuEdit,'enable','off')
|
---|
[61] | 4576 | set(handles.list_object_1,'Value',1)
|
---|
| 4577 | % initiate display of GUI geometry_calib
|
---|
| 4578 | data=[]; %default
|
---|
| 4579 | if isfield(UvData,'CoordType')
|
---|
| 4580 | data.CoordType=UvData.CoordType;
|
---|
| 4581 | end
|
---|
| 4582 | pos=get(handles.uvmat,'Position');
|
---|
| 4583 | pos(1)=pos(1)+pos(3)-0.311+0.04; %0.311= width of the geometry_calib interface (units relative to the srcreen)
|
---|
| 4584 | pos(2)=pos(2)-0.02;
|
---|
| 4585 | [FileName,RootPath,FileBase,FileIndices,FileExt,SubDir]=read_file_boxes(handles);
|
---|
| 4586 | [UvData.hset_object,UvData.sethandles]=geometry_calib(handles,pos,FileName);% call the set_object interface
|
---|
| 4587 | pos_uvmat=get(handles.uvmat,'Position');
|
---|
[71] | 4588 |
|
---|
[61] | 4589 | if isfield(UvData,'CalOrigin')
|
---|
| 4590 | pos_cal(1)=pos_uvmat(1)+UvData.CalOrigin(1)*pos_uvmat(3);
|
---|
| 4591 | pos_cal(2)=pos_uvmat(2)+UvData.CalOrigin(2)*pos_uvmat(4);
|
---|
| 4592 | pos_cal(3:4)=UvData.CalSize .* pos_uvmat(3:4);
|
---|
| 4593 | set(UvData.hset_object,'Position',pos_cal)
|
---|
| 4594 | end
|
---|
| 4595 | UvData.MouseAction='calib';
|
---|
| 4596 | set(handles.uvmat,'UserData',UvData);
|
---|
[2] | 4597 |
|
---|
[61] | 4598 |
|
---|
[2] | 4599 | % ------------------------------------------------------------------
|
---|
| 4600 | function MenuMask_Callback(hObject, eventdata, handles)
|
---|
[82] | 4601 | % set(handles.TOOLS_txt,'Visible','on')
|
---|
| 4602 | % set(handles.frame_tools,'Visible','on')
|
---|
| 4603 | % % set(handles.create,'Visible','on')
|
---|
| 4604 | % % set(handles.create,'Value',1)
|
---|
| 4605 | % % set(handles.create,'BackgroundColor',[1 1 0]) %visualise in yellow
|
---|
| 4606 | % set(handles.save_mask,'Visible','on')
|
---|
| 4607 | % set(handles.masklevel,'Visible','on')
|
---|
| 4608 | % if isequal(get(handles.z_index,'Visible'),'on')
|
---|
| 4609 | % nb_slice=str2num(get(handles.nb_slice,'String'));
|
---|
| 4610 | % for ilist=1:nb_slice
|
---|
| 4611 | % list_index{ilist,1}=num2str(ilist);
|
---|
| 4612 | % end
|
---|
| 4613 | % set(handles.masklevel,'String',list_index)
|
---|
| 4614 | % val=str2num(get(handles.z_index,'String'));
|
---|
| 4615 | % if val<=nb_slice
|
---|
| 4616 | % set(handles.masklevel,'Value',val)
|
---|
| 4617 | % end
|
---|
| 4618 | % else
|
---|
| 4619 | % set(handles.masklevel,'String',{'1'})
|
---|
| 4620 | % set(handles.masklevel,'Value',1)
|
---|
| 4621 | % end
|
---|
| 4622 | % if ishandle(handles.UVMAT_title)
|
---|
| 4623 | % delete(handles.UVMAT_title)
|
---|
| 4624 | % end
|
---|
[61] | 4625 | UvData=get(handles.uvmat,'UserData');%read UvData properties stored on the uvmat interface
|
---|
[82] | 4626 | % set(handles.zoom,'Value',0)
|
---|
| 4627 | % set(handles.zoom,'BackgroundColor',[0.7 0.7 0.7])
|
---|
| 4628 | % set(handles.edit_vect,'Value',0)
|
---|
| 4629 | % edit_vect_Callback(hObject, eventdata, handles)
|
---|
| 4630 | % set(handles.edit,'Value',0)
|
---|
| 4631 | % set(handles.edit,'BackgroundColor',[0.7 0.7 0.7])
|
---|
| 4632 | % set(handles.edit_vect,'Value',0)
|
---|
| 4633 | % edit_vect_Callback(hObject, eventdata, handles)
|
---|
[61] | 4634 | % set(handles.cal,'Value',0)
|
---|
| 4635 | % set(handles.cal,'BackgroundColor',[0 1 0])
|
---|
[2] | 4636 |
|
---|
| 4637 | %initiate the GUI set_object
|
---|
[82] | 4638 | % data.TITLE='MASK';
|
---|
| 4639 | % if isfield(UvData,'CoordType')
|
---|
| 4640 | % data.CoordType=UvData.CoordType;
|
---|
| 4641 | % end
|
---|
| 4642 | % if isfield(UvData,'Mesh')&&~isempty(UvData.Mesh)
|
---|
| 4643 | % data.YMax=UvData.Mesh;
|
---|
| 4644 | % elseif isfield(UvData.Field,'AX')&&isfield(UvData.Field,'AY')&& isfield(UvData.Field,'A')%only image
|
---|
| 4645 | % np=size(UvData.Field.A);
|
---|
| 4646 | % meshx=(UvData.Field.AX(end)-UvData.Field.AX(1))/(np(2)-1);
|
---|
| 4647 | % meshy=abs(UvData.Field.AY(end)-UvData.Field.AY(1))/(np(1)-1);
|
---|
| 4648 | % data.YMax=max(meshx,meshy);
|
---|
| 4649 | % data.DX=max(meshx,meshy);
|
---|
| 4650 | % end
|
---|
| 4651 | % data.Coord=[0 0 0]; %default
|
---|
| 4652 | % PlotHandles=get_plot_handles(handles);%get the handles of the graphic objects setting the plotting parameters
|
---|
| 4653 | % [hset_object,UvData.sethandles]=set_object(data,PlotHandles);% call the set_object interface
|
---|
| 4654 | % pos_uvmat=get(handles.uvmat,'Position');
|
---|
| 4655 | % if isfield(UvData,'SetObjectOrigin')
|
---|
| 4656 | % pos_set_object(1:2)=UvData.SetObjectOrigin + pos_uvmat(1:2);
|
---|
| 4657 | % pos_set_object(3:4)=UvData.SetObjectSize .* pos_uvmat(3:4);
|
---|
| 4658 | % set(hset_object,'Position',pos_set_object)
|
---|
| 4659 | % end
|
---|
| 4660 | ListObj=UvData.Object;
|
---|
| 4661 | select=zeros(1,numel(ListObj));
|
---|
| 4662 | for iobj=1:numel(ListObj);
|
---|
| 4663 | if strcmp(ListObj{iobj}.ProjMode,'mask_inside')||strcmp(ListObj{iobj}.ProjMode,'mask_outside')
|
---|
| 4664 | select(iobj)=1;
|
---|
| 4665 | end
|
---|
[2] | 4666 | end
|
---|
[82] | 4667 | val=find(select);
|
---|
| 4668 | if isempty(val)
|
---|
| 4669 | msgbox_uvmat('ERROR','polygons must be first created by Projection object/mask polygon in the menu bar');
|
---|
| 4670 | return
|
---|
| 4671 | else
|
---|
| 4672 | set(handles.list_object_1,'Max',2);%allow multiple selection
|
---|
| 4673 | set(handles.list_object_1,'Value',val);
|
---|
| 4674 | % answer=msgbox_uvmat('INPUT_Y-N',['make the mask image from ' num2str(numel(val)) ' polygons']);
|
---|
| 4675 | % if ~isempty(answer)
|
---|
| 4676 | flag=1;
|
---|
| 4677 | npx=size(UvData.Field.A,2);
|
---|
| 4678 | npy=size(UvData.Field.A,1);
|
---|
| 4679 | xi=[0.5:npx-0.5];
|
---|
| 4680 | yi=[0.5:npy-0.5];
|
---|
| 4681 | [Xi,Yi]=meshgrid(xi,yi);
|
---|
| 4682 | if isfield(UvData,'Object')
|
---|
| 4683 | for iobj=1:length(UvData.Object)
|
---|
| 4684 | ObjectData=UvData.Object{iobj};
|
---|
| 4685 | if isfield(ObjectData,'ProjMode') &&(isequal(ObjectData.ProjMode,'mask_inside')||isequal(ObjectData.ProjMode,'mask_outside'));
|
---|
| 4686 | flagobj=1;
|
---|
| 4687 | testphys=0; %coordinates in pixels by default
|
---|
| 4688 | if isfield(ObjectData,'CoordType') && isequal(ObjectData.CoordType,'phys')
|
---|
| 4689 | if isfield(UvData,'XmlData')&& isfield(UvData.XmlData,'GeometryCalib')
|
---|
| 4690 | Calib=UvData.XmlData.GeometryCalib;
|
---|
| 4691 | testphys=1;
|
---|
| 4692 | end
|
---|
| 4693 | end
|
---|
| 4694 | if isfield(ObjectData,'Coord')& isfield(ObjectData,'Style')
|
---|
| 4695 | if isequal(ObjectData.Style,'polygon')
|
---|
| 4696 | X=ObjectData.Coord(:,1);
|
---|
| 4697 | Y=ObjectData.Coord(:,2);
|
---|
| 4698 | if testphys
|
---|
| 4699 | [X,Y]=px_XYZ(Calib,X,Y,0);% to generalise with 3D cases
|
---|
| 4700 | end
|
---|
| 4701 | flagobj=~inpolygon(Xi,Yi,X',Y');%=0 inside the polygon, 1 outside
|
---|
| 4702 | elseif isequal(ObjectData.Style,'ellipse')
|
---|
| 4703 | if testphys
|
---|
| 4704 | %[X,Y]=px_XYZ(Calib,X,Y,0);% TODO:create a polygon boundary and transform to phys
|
---|
| 4705 | end
|
---|
| 4706 | RangeX=max(ObjectData.RangeX);
|
---|
| 4707 | RangeY=max(ObjectData.RangeY);
|
---|
| 4708 | X2Max=RangeX*RangeX;
|
---|
| 4709 | Y2Max=RangeY*RangeY;
|
---|
| 4710 | distX=(Xi-ObjectData.Coord(1,1));
|
---|
| 4711 | distY=(Yi-ObjectData.Coord(1,2));
|
---|
| 4712 | flagobj=(distX.*distX/X2Max+distY.*distY/Y2Max)>1;
|
---|
| 4713 | elseif isequal(ObjectData.Style,'rectangle')
|
---|
| 4714 | if testphys
|
---|
| 4715 | %[X,Y]=px_XYZ(Calib,X,Y,0);% TODO:create a polygon boundary and transform to phys
|
---|
| 4716 | end
|
---|
| 4717 | distX=abs(Xi-ObjectData.Coord(1,1));
|
---|
| 4718 | distY=abs(Yi-ObjectData.Coord(1,2));
|
---|
| 4719 | flagobj=distX>max(ObjectData.RangeX) | distY>max(ObjectData.RangeY);
|
---|
| 4720 | end
|
---|
| 4721 | if isequal(ObjectData.ProjMode,'mask_outside')
|
---|
| 4722 | flagobj=~flagobj;
|
---|
| 4723 | end
|
---|
| 4724 | flag=flag & flagobj;
|
---|
| 4725 | end
|
---|
| 4726 | end
|
---|
| 4727 | end
|
---|
| 4728 | end
|
---|
| 4729 | % flag=~flag;
|
---|
| 4730 | %mask name
|
---|
| 4731 | RootPath=get(handles.RootPath,'String');
|
---|
| 4732 | RootFile=get(handles.RootFile,'String');
|
---|
| 4733 | if ~isempty(RootFile)&(isequal(RootFile(1),'/')| isequal(RootFile(1),'\'))
|
---|
| 4734 | RootFile(1)=[];
|
---|
| 4735 | end
|
---|
| 4736 | filebase=fullfile(RootPath,RootFile);
|
---|
| 4737 | list=get(handles.masklevel,'String');
|
---|
| 4738 | masknumber=num2str(length(list));
|
---|
| 4739 | maskindex=get(handles.masklevel,'Value');
|
---|
| 4740 | mask_name=name_generator([filebase '_' masknumber 'mask'],maskindex,1,'.png','_i');
|
---|
| 4741 | imflag=uint8(255*(0.392+0.608*flag));% =100 for flag=0 (vectors not computed when 20<imflag<200)
|
---|
| 4742 | imflag=flipdim(imflag,1);
|
---|
| 4743 | % imflag=uint8(255*flag);% =0 for flag=0 (vectors=0 when
|
---|
| 4744 | % 20<imflag<200)
|
---|
| 4745 |
|
---|
| 4746 | %display the mask
|
---|
| 4747 | %update_mask(handles,num_i1,num_j1)
|
---|
| 4748 | figure;
|
---|
| 4749 | vec=linspace(0,1,256);%define a linear greyscale colormap
|
---|
| 4750 | map=[vec' vec' vec'];
|
---|
| 4751 | colormap(map)
|
---|
| 4752 | image(imflag);
|
---|
[86] | 4753 | answer=msgbox_uvmat('INPUT_TXT','mask file name:', mask_name);
|
---|
[82] | 4754 | if ~strcmp(answer,'Cancel')
|
---|
| 4755 | imwrite(imflag,answer,'BitDepth',8);
|
---|
| 4756 | end
|
---|
| 4757 | set(list_object_1,'Value',1)
|
---|
| 4758 | set(list_object_1,'Max',1)
|
---|
| 4759 | % end
|
---|
| 4760 | end
|
---|
| 4761 |
|
---|
| 4762 |
|
---|
| 4763 | % UvData.MouseAction='create_object';
|
---|
[61] | 4764 | set(handles.uvmat,'UserData',UvData);
|
---|
[2] | 4765 |
|
---|
| 4766 | % ------------------------------------------------------------------
|
---|
| 4767 | %-- open the GUI set_grid.fig to create grid
|
---|
| 4768 | function MenuGrid_Callback(hObject, eventdata, handles)
|
---|
[84] | 4769 | %UvData=get(handles.uvmat,'UserData');%read UvData properties stored on the uvmat interface
|
---|
[2] | 4770 |
|
---|
[84] | 4771 | %suppress the other options if grid is chosen
|
---|
| 4772 | set(handles.edit_vect,'Value',0)
|
---|
| 4773 | edit_vect_Callback(hObject, eventdata, handles)
|
---|
| 4774 | set(handles.edit,'BackgroundColor',[0.7 0.7 0.7])
|
---|
| 4775 | set(handles.list_object_1,'Value',1)
|
---|
| 4776 |
|
---|
| 4777 | %prepare display of the set_grid GUI
|
---|
| 4778 | FileName=read_file_boxes(handles);
|
---|
| 4779 | CoordList=get(handles.transform_fct,'String');
|
---|
| 4780 | val=get(handles.transform_fct,'Value');
|
---|
| 4781 | set_grid(FileName,CoordList{val});% call the set_object interface
|
---|
| 4782 | %set(handles.uvmat,'UserData',UvData);
|
---|
| 4783 |
|
---|
[2] | 4784 | %----------------------------------------------------------------
|
---|
| 4785 | % open the GUI 'series'
|
---|
| 4786 | %----------------------------------------------------------------
|
---|
| 4787 | function MenuSeries_Callback(hObject, eventdata, handles)
|
---|
[40] | 4788 | %-------------------------------------------------------------------
|
---|
[2] | 4789 |
|
---|
| 4790 | [param.FileName]=read_file_boxes(handles);
|
---|
| 4791 | if isequal(get(handles.SubField,'Value'),1)
|
---|
| 4792 | FileName_1=read_file_boxes_1(handles);%
|
---|
| 4793 | if ~isequal(FileName_1,param.FileName)
|
---|
| 4794 | param.FileName_1=FileName_1;
|
---|
| 4795 | end
|
---|
| 4796 | end
|
---|
| 4797 | param.NomType=get(handles.FileIndex,'UserData');
|
---|
| 4798 | param.NomType_1=get(handles.FileIndex_1,'UserData');
|
---|
| 4799 | param.comp_input=get(handles.fix_pair,'Value');
|
---|
| 4800 | huvmat=get(handles.MenuSeries,'parent');
|
---|
| 4801 | UvData=get(huvmat,'UserData');
|
---|
| 4802 | if isfield(UvData,'Time')
|
---|
| 4803 | param.Time=UvData.XmlData.Time;
|
---|
| 4804 | end
|
---|
| 4805 | if isequal(get(handles.scan_i,'Value'),1)
|
---|
| 4806 | param.incr_i=str2num(get(handles.increment_scan,'String'));
|
---|
| 4807 | elseif isequal(get(handles.scan_j,'Value'),1)
|
---|
| 4808 | param.incr_j=str2num(get(handles.increment_scan,'String'));
|
---|
| 4809 | end
|
---|
| 4810 | param.list_fields=get(handles.Fields,'String');% list menu fields
|
---|
| 4811 | param.list_fields(1)=[]; %suppress 'image' option
|
---|
| 4812 | param.index_fields=get(handles.Fields,'Value');% selected string index
|
---|
| 4813 | if param.index_fields>1
|
---|
| 4814 | param.index_fields=param.index_fields-1;
|
---|
| 4815 | end
|
---|
| 4816 | param.list_fields_1=get(handles.Fields_1,'String');% list menu fields
|
---|
| 4817 | param.list_fields_1(1)=[]; %suppress 'image' option
|
---|
| 4818 | param.index_fields_1=get(handles.Fields_1,'Value')-1;% selected string index
|
---|
| 4819 | if param.index_fields_1>1
|
---|
| 4820 | param.index_fields_1=param.index_fields_1-1;
|
---|
| 4821 | end
|
---|
| 4822 | param.civ1=get(handles.civ1,'Value');
|
---|
| 4823 | param.civ2=get(handles.civ2,'Value');
|
---|
| 4824 | param.interp1=get(handles.interp1,'Value');
|
---|
| 4825 | param.interp2=get(handles.interp2,'Value');
|
---|
| 4826 | param.filter1=get(handles.filter1,'Value');
|
---|
| 4827 | param.filter2=get(handles.filter2,'Value');
|
---|
[39] | 4828 | param.menu_coord_str=get(handles.transform_fct,'String');
|
---|
| 4829 | param.menu_coord_val=get(handles.transform_fct,'Value');
|
---|
[2] | 4830 |
|
---|
| 4831 | series(param); %run the series interface
|
---|
| 4832 |
|
---|
| 4833 | % ------------------------------------------------------------------
|
---|
| 4834 | % -- open the GUI civ.fig for civx (PIV)
|
---|
| 4835 | % ------------------------------------------------------------------
|
---|
| 4836 | function MenuPIV_Callback(hObject, eventdata, handles)
|
---|
| 4837 |
|
---|
| 4838 | [FileName,RootPath,filebase,FileIndices,ext,SubDir]=read_file_boxes(handles);
|
---|
[45] | 4839 | num1=stra2num(get(handles.i1,'String'));
|
---|
| 4840 | num2=stra2num(get(handles.i2,'String'));
|
---|
| 4841 | num_a=stra2num(get(handles.j1,'String'));
|
---|
| 4842 | num_b=stra2num(get(handles.j2,'String'));
|
---|
[2] | 4843 | NomType=get(handles.FileIndex,'UserData');
|
---|
| 4844 | ind_opening=1; % default (images): will advice civ1 option by default in the civ interface
|
---|
| 4845 | if isequal(ext,'.nc') || isequal(ext,'.cdf')% netcdf files
|
---|
| 4846 | ind_opening=2;% propose 'fix' as the default option
|
---|
| 4847 | % +read the current netcdf rootfile
|
---|
| 4848 | Data=nc2struct(FileName,[]);
|
---|
| 4849 | if isfield(Data,'fix') & isequal(Data.fix,1)
|
---|
| 4850 | ind_opening=3;
|
---|
| 4851 | end
|
---|
| 4852 | if isfield(Data,'patch') & isequal(Data.patch,1)
|
---|
| 4853 | ind_opening=4;
|
---|
| 4854 | end
|
---|
| 4855 | if isfield(Data,'civ2') & isequal(Data.civ2,1)
|
---|
| 4856 | ind_opening=5;
|
---|
| 4857 | end
|
---|
| 4858 | if isfield(Data,'fix2') & isequal(Data.fix2,1)
|
---|
| 4859 | ind_opening=6;
|
---|
| 4860 | end
|
---|
| 4861 | end
|
---|
[71] | 4862 | param.RootName=filebase;
|
---|
| 4863 | param.NomType=NomType;
|
---|
| 4864 | param.num1=num1;
|
---|
| 4865 | param.num2=num2;
|
---|
| 4866 | param.num_a=num_a;
|
---|
| 4867 | param.num_b=num_b;
|
---|
| 4868 | param.SubDir=SubDir;
|
---|
| 4869 | param.IndOpening=ind_opening;% A REVOIR +TRANSMETTRE IMADOC INFO
|
---|
| 4870 | param.ImaExt=ext;
|
---|
| 4871 | civ(param);% interface de civ(not in the uvmat file)
|
---|
[2] | 4872 |
|
---|
| 4873 | % ------------------------------------------------------------------
|
---|
| 4874 | function MenuTools_Callback(hObject, eventdata, handles)
|
---|
| 4875 |
|
---|
| 4876 | % ------------------------------------------------------------------
|
---|
[67] | 4877 | function MenuEditObject_Callback(hObject, eventdata, handles)
|
---|
| 4878 | set(handles.edit,'Value',1)
|
---|
| 4879 | edit_Callback(hObject, eventdata, handles)
|
---|
[2] | 4880 |
|
---|
| 4881 | %--------------------------------------------------------------------------
|
---|
| 4882 | function enable_transform(handles,state)
|
---|
[39] | 4883 | set(handles.transform_fct,'Visible',state)
|
---|
[2] | 4884 | set(handles.TRANSFORM_txt,'Visible',state)
|
---|
[39] | 4885 | set(handles.transform_fct,'Visible',state)
|
---|
[2] | 4886 | set(handles.path_transform,'Visible',state)
|
---|
| 4887 | set(handles.pxcmx_txt,'Visible',state)
|
---|
| 4888 | set(handles.pxcmy_txt,'Visible',state)
|
---|
| 4889 | set(handles.pxcm,'Visible',state)
|
---|
| 4890 | set(handles.pycm,'Visible',state)
|
---|
| 4891 |
|
---|
[40] | 4892 | %------------------------------------------------------------------------
|
---|
[2] | 4893 | function MenuEditVectors_Callback(hObject, eventdata, handles)
|
---|
[40] | 4894 | %------------------------------------------------------------------------
|
---|
[2] | 4895 | set(handles.edit_vect,'Visible','on')
|
---|
| 4896 | set(handles.edit_vect,'Value',1)
|
---|
| 4897 | edit_vect_Callback(hObject, eventdata, handles)
|
---|
| 4898 |
|
---|
[40] | 4899 | % --------------------------------------------------------------------
|
---|
| 4900 | function Menupoints_Callback(hObject, eventdata, handles)
|
---|
| 4901 | data.Style='points';
|
---|
| 4902 | data.ProjMode='projection';%default
|
---|
[55] | 4903 | create_object(data,handles)
|
---|
[2] | 4904 |
|
---|
[40] | 4905 | % --------------------------------------------------------------------
|
---|
| 4906 | function Menuline_Callback(hObject, eventdata, handles)
|
---|
| 4907 | % set(handles.create,'Visible','on')
|
---|
| 4908 | % set(handles.create,'Value',1)
|
---|
| 4909 | % LINE_Callback(hObject,eventdata,handles)
|
---|
| 4910 | data.Style='line';
|
---|
| 4911 | data.ProjMode='projection';%default
|
---|
[55] | 4912 | create_object(data,handles)
|
---|
[2] | 4913 |
|
---|
[40] | 4914 | %------------------------------------------------------------------------
|
---|
| 4915 | function Menupolyline_Callback(hObject, eventdata, handles)
|
---|
| 4916 | %------------------------------------------------------------------------
|
---|
| 4917 | data.Style='polyline';
|
---|
| 4918 | data.ProjMode='projection';%default
|
---|
[55] | 4919 | create_object(data,handles)
|
---|
[2] | 4920 |
|
---|
[55] | 4921 | %------------------------------------------------------------------------
|
---|
[40] | 4922 | function Menupolygon_Callback(hObject, eventdata, handles)
|
---|
[55] | 4923 | %------------------------------------------------------------------------
|
---|
[45] | 4924 | data.Style='polygon';
|
---|
| 4925 | data.ProjMode='inside';%default
|
---|
[55] | 4926 | create_object(data,handles)
|
---|
[40] | 4927 |
|
---|
| 4928 | %------------------------------------------------------------------------
|
---|
| 4929 | function Menurectangle_Callback(hObject, eventdata, handles)
|
---|
| 4930 | %------------------------------------------------------------------------
|
---|
| 4931 | data.Style='rectangle';
|
---|
| 4932 | data.ProjMode='inside';%default
|
---|
[55] | 4933 | create_object(data,handles)
|
---|
[40] | 4934 |
|
---|
| 4935 | %------------------------------------------------------------------------
|
---|
| 4936 | function Menuellipse_Callback(hObject, eventdata, handles)
|
---|
| 4937 | %------------------------------------------------------------------------
|
---|
| 4938 | data.Style='ellipse';
|
---|
| 4939 | data.ProjMode='inside';%default
|
---|
[55] | 4940 | create_object(data,handles)
|
---|
[40] | 4941 |
|
---|
[82] | 4942 | %------------------------------------------------------------------------
|
---|
| 4943 | function MenuMaskObject_Callback(hObject, eventdata, handles)
|
---|
| 4944 | %------------------------------------------------------------------------
|
---|
| 4945 | data.Style='polygon';
|
---|
| 4946 | data.StyleMenu={'polygon'};
|
---|
| 4947 | data.ProjMode='mask_inside';%default
|
---|
| 4948 | data.ProjMenu={'mask_inside';'mask_outside'};
|
---|
| 4949 | create_object(data,handles)
|
---|
| 4950 |
|
---|
[40] | 4951 | % ------------------------------------------------------------------
|
---|
| 4952 | function Menuplane_Callback(hObject, eventdata, handles)
|
---|
| 4953 | data.Style='plane';
|
---|
| 4954 | data.ProjMode='projection';%default
|
---|
| 4955 |
|
---|
[55] | 4956 | create_object(data,handles)
|
---|
| 4957 |
|
---|
[40] | 4958 | % ------------------------------------------------------------------
|
---|
| 4959 | function Menuvolume_Callback(hObject, eventdata, handles)
|
---|
[77] | 4960 | data.Style='volume';
|
---|
| 4961 | data.ProjMode='interp';%default
|
---|
[61] | 4962 | % set(handles.create,'Visible','on')
|
---|
| 4963 | % set(handles.create,'Value',1)
|
---|
[77] | 4964 | % VOLUME_Callback(hObject,eventdata,handles)
|
---|
| 4965 | create_object(data,handles)
|
---|
[40] | 4966 |
|
---|
| 4967 | %------------------------------------------------------------------------
|
---|
| 4968 | function MenuBrowseObject_Callback(hObject, eventdata, handles)
|
---|
| 4969 | %------------------------------------------------------------------------
|
---|
| 4970 | %get the object file
|
---|
| 4971 | [FileName, PathName, filterindex] = uigetfile( ...
|
---|
| 4972 | {'*.xml;*.mat', ' (*.xml,*.mat)';
|
---|
| 4973 | '*.xml', '.xml files '; ...
|
---|
| 4974 | '*.mat', '.mat matlab files '}, ...
|
---|
| 4975 | 'Pick a file',get(handles.RootPath,'String'));
|
---|
| 4976 | fileinput=[PathName FileName];%complete file name
|
---|
| 4977 | testblank=findstr(fileinput,' ');%look for blanks
|
---|
| 4978 | if ~isempty(testblank)
|
---|
| 4979 | msgbox_uvmat('ERROR','forbidden input file name: contain blanks')
|
---|
| 4980 | return
|
---|
| 4981 | end
|
---|
| 4982 | sizf=size(fileinput);
|
---|
| 4983 | if (~ischar(fileinput)||~isequal(sizf(1),1)),return;end
|
---|
| 4984 |
|
---|
| 4985 | %read the file
|
---|
[55] | 4986 | t=xmltree(fileinput);
|
---|
| 4987 | data=convert(t);
|
---|
[71] | 4988 | data.enable_plot=1;
|
---|
| 4989 | [pp,data.Name]=fileparts(FileName);
|
---|
| 4990 | %PlotHandles=get_plot_handles(handles);%get the handles of the interface elements setting the plotting parameters
|
---|
[55] | 4991 | hset_object=findobj(allchild(0),'Name','set_object');
|
---|
| 4992 | if ~isempty(hset_object)
|
---|
| 4993 | delete(hset_object)% delete existing version of set_object
|
---|
| 4994 | end
|
---|
[71] | 4995 | UvData=get(handles.uvmat,'UserData');
|
---|
[81] | 4996 | [hset_object,UvData.sethandles]=set_object(data);% call the set_object interface
|
---|
[75] | 4997 | % %position the set_object GUI with respect to uvmat
|
---|
| 4998 | % pos_uvmat=get(handles.uvmat,'Position');
|
---|
| 4999 | % if isfield(UvData,'SetObjectOrigin')
|
---|
| 5000 | % pos_set_object(1:2)=UvData.SetObjectOrigin + pos_uvmat(1:2);
|
---|
| 5001 | % pos_set_object(3:4)=UvData.SetObjectSize .* pos_uvmat(3:4);
|
---|
| 5002 | % set(hset_object,'Position',pos_set_object)
|
---|
| 5003 | % end
|
---|
[61] | 5004 | set(handles.edit,'Value',0); %suppress the object edit mode
|
---|
| 5005 | set(handles.edit,'BackgroundColor',[0.7,0.7,0.7])
|
---|
[55] | 5006 | UvData.MouseAction='create_object';
|
---|
| 5007 | set(handles.uvmat,'UserData',UvData)
|
---|
[72] | 5008 | set(handles.delete_object,'Visible','on')
|
---|
| 5009 | set(handles.uvmat_title,'Visible','on')
|
---|
[75] | 5010 | set(handles.view_field_title,'Visible','on')
|
---|
[40] | 5011 |
|
---|
| 5012 | %------------------------------------------------------------------------
|
---|
[71] | 5013 | % --- generic function used for the creation of a projection object
|
---|
[55] | 5014 | function create_object(data,handles)
|
---|
[40] | 5015 | %------------------------------------------------------------------------
|
---|
[75] | 5016 | hset_object=findobj(allchild(0),'tag','set_object');
|
---|
[40] | 5017 | if ~isempty(hset_object)
|
---|
| 5018 | delete(hset_object)% delete existing version of set_object
|
---|
| 5019 | end
|
---|
[55] | 5020 | UvData=get(handles.uvmat,'UserData');
|
---|
[61] | 5021 | set(handles.edit,'Value',0); %suppress the object edit mode
|
---|
| 5022 | set(handles.edit,'BackgroundColor',[0.7,0.7,0.7])
|
---|
[71] | 5023 | data.enable_plot=1;
|
---|
[82] | 5024 | transform_list=get(handles.transform_fct,'String');
|
---|
| 5025 | val=get(handles.transform_fct,'Value');
|
---|
| 5026 | data.CoordType=transform_list{val};
|
---|
| 5027 | % if isfield(UvData,'CoordType')
|
---|
| 5028 | % data.CoordType=UvData.CoordType;
|
---|
| 5029 | % end
|
---|
[55] | 5030 | if isfield(UvData,'Mesh')&&~isempty(UvData.Mesh)
|
---|
[40] | 5031 | data.RangeX=UvData.Mesh;
|
---|
| 5032 | data.RangeY=UvData.Mesh;
|
---|
| 5033 | data.DX=UvData.Mesh;
|
---|
| 5034 | data.DY=UvData.Mesh;
|
---|
[55] | 5035 | elseif isfield(UvData.Field,'AX')&& isfield(UvData.Field,'AY')&& isfield(UvData.Field,'A')%only image
|
---|
[40] | 5036 | np=size(UvData.Field.A);
|
---|
| 5037 | meshx=(UvData.Field.AX(end)-UvData.Field.AX(1))/np(2);
|
---|
| 5038 | meshy=abs(UvData.Field.AY(end)-UvData.Field.AY(1))/np(1);
|
---|
| 5039 | data.RangeY=max(meshx,meshy);
|
---|
| 5040 | data.RangeX=max(meshx,meshy);
|
---|
| 5041 | data.DX=max(meshx,meshy);
|
---|
| 5042 | end
|
---|
[75] | 5043 | if isfield(UvData,'NbDim')
|
---|
| 5044 | data.NbDim=UvData.NbDim;
|
---|
| 5045 | end
|
---|
[55] | 5046 | data.Coord=[0 0 0]; %default
|
---|
| 5047 | if isfield(data,'Style') && isequal(data.Style,'line')
|
---|
| 5048 | if isfield(data,'DX')
|
---|
| 5049 | data.Coord=[[0 0 0];[data.DX 0 0]]; %default
|
---|
| 5050 | else
|
---|
| 5051 | data.Coord=[[0 0 0];[1 0 0]]; %default
|
---|
| 5052 | end
|
---|
[40] | 5053 | end
|
---|
| 5054 | %data.ParentButton=handles.create;
|
---|
[55] | 5055 | if ishandle(handles.UVMAT_title)
|
---|
| 5056 | delete(handles.UVMAT_title)%delete the initial display of uvmat if no field has been entered
|
---|
| 5057 | end
|
---|
| 5058 | PlotHandles=get_plot_handles(handles);%get the handles of the interface elements setting the plotting parameters
|
---|
[40] | 5059 | [hset_object,UvData.sethandles]=set_object(data,PlotHandles);% call the set_object interface
|
---|
[61] | 5060 |
|
---|
[40] | 5061 | UvData.MouseAction='create_object';
|
---|
[55] | 5062 | set(handles.uvmat,'UserData',UvData)
|
---|
| 5063 | set(handles.zoom,'Value',0)
|
---|
| 5064 | zoom_Callback(handles.uvmat, [], handles)
|
---|
[72] | 5065 | set(handles.delete_object,'Visible','on')
|
---|
| 5066 | set(handles.uvmat_title,'Visible','on')
|
---|
[75] | 5067 | set(handles.view_field_title,'Visible','on')
|
---|
[40] | 5068 |
|
---|
[71] | 5069 | %------------------------------------------------------------------------
|
---|
[60] | 5070 | function MenuRuler_Callback(hObject, eventdata, handles)
|
---|
[71] | 5071 | %------------------------------------------------------------------------
|
---|
[60] | 5072 | set(handles.zoom,'Value',0)
|
---|
| 5073 | zoom_Callback(handles.uvmat, [], handles)
|
---|
| 5074 | UvData=get(handles.uvmat,'UserData');
|
---|
| 5075 | UvData.MouseAction='ruler';
|
---|
| 5076 | set(handles.uvmat,'UserData',UvData);
|
---|
| 5077 |
|
---|
[67] | 5078 | %------------------------------------------------------------------------
|
---|
[71] | 5079 | % --- executed when closing: set the parent interface button to value 0
|
---|
[67] | 5080 | function closefcn(gcbo,eventdata)
|
---|
| 5081 | %------------------------------------------------------------------------
|
---|
| 5082 | %delete all the associated figures if exist
|
---|
| 5083 | hh=findobj(allchild(0),'tag','view_field');
|
---|
| 5084 | if ~isempty(hh)
|
---|
| 5085 | delete(hh)
|
---|
| 5086 | end
|
---|
| 5087 | hh=findobj(allchild(0),'name','geometry_calib');
|
---|
| 5088 | if ~isempty(hh)
|
---|
| 5089 | delete(hh)
|
---|
| 5090 | end
|
---|
| 5091 | hh=findobj(allchild(0),'tag','set_object');
|
---|
| 5092 | if ~isempty(hh)
|
---|
| 5093 | hhh=findobj(hh,'tag','PLOT');
|
---|
| 5094 | set(hhh,'enable','off')
|
---|
[71] | 5095 | end
|
---|
| 5096 |
|
---|
| 5097 |
|
---|
| 5098 | % --- Executes on button press in delete_object.
|
---|
| 5099 | function delete_object_Callback(hObject, eventdata, handles)
|
---|
| 5100 | IndexObj=get(handles.list_object_2,'Value');
|
---|
| 5101 | if IndexObj>1
|
---|
| 5102 | delete_object(IndexObj)
|
---|
| 5103 | end
|
---|
| 5104 |
|
---|
| 5105 |
|
---|
[81] | 5106 |
|
---|
| 5107 |
|
---|
| 5108 |
|
---|