[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')
|
---|
[159] | 33 | % Matlab structure called UvData stored as 'UserData' of the figure uvmat.fig,(can be obtained by right mouse click on the interface).
|
---|
[2] | 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
|
---|
[159] | 49 | % .MovieObject: movie object representing an input movie
|
---|
| 50 | % .MovieObject_1: idem for a second input series (_1)
|
---|
| 51 | % .filename_1 : last second input file name (to deal with a constant second input without reading again the file)
|
---|
| 52 | % .VelType_1: last velocity type (civ1, civ2...) for the second input series
|
---|
| 53 | % .FieldName_1: last field name(velocity, vorticity...) for the second input series
|
---|
| 54 | % .NbDim: number of space dimensions of the input field
|
---|
| 55 | % .ZMin, .ZMax: range of the z coordinate
|
---|
| 56 | %..... to complement
|
---|
[2] | 57 | % - Information on projection objects
|
---|
| 58 | % .Object: {[1x1 struct]}
|
---|
| 59 | % .CurrentObjectIndex: index of the projection object .Object currently selected for editing
|
---|
| 60 | % -Information on the current field (Field{i})
|
---|
| 61 | % .Txt : text information to display (e.g. error message)
|
---|
| 62 | % .NbDim: number of dimensions (=0 by default)
|
---|
| 63 | % .NbCoord: number of vector components
|
---|
| 64 | % .CoordType: expresses the type of coordinate ('px' for image, 'sig' for instruments, or 'phys')
|
---|
| 65 | % .dt: time interval for the corresponding image pair
|
---|
| 66 | % .Mesh: estimated typical distance between vectors
|
---|
| 67 | % .ZMax:
|
---|
| 68 | % .ZMin:
|
---|
| 69 | % .X, .Y, .Z: set of vector coordinates
|
---|
| 70 | % .U,.V,.W: corresponding set of vector components
|
---|
| 71 | % .F: corresponding set of warning flags
|
---|
| 72 | % .FF: corresponding set of false flags, =0 for good vectors
|
---|
| 73 | % .C: corresponding values of the scalar used for vector color
|
---|
| 74 | % (.X, .Y, .Z,.U,.V,.W,.F,.FF,.C are matlab vectors of the same length,
|
---|
| 75 | % equal to the number of vectors stored in the input open)
|
---|
| 76 | % .CName: name of the scalar .C
|
---|
| 77 | % .CType: type of the scalar .C, setting how the scalar is obtained (see 'Scalars' below)
|
---|
| 78 | % .A image or scalar
|
---|
| 79 | % .AX: vector of dimension 2 representing the first and last values
|
---|
| 80 | % of the X coordinates for the image or scalar known on a regular grid,
|
---|
| 81 | % or vector of dimension .A for a scaler defined on irregular grid.
|
---|
| 82 | % .AY: same as .AX along the Y direction
|
---|
| 83 | % .AName: name of the scalar, ='image' for an image
|
---|
| 84 |
|
---|
| 85 | % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%% DATA FLOW (for run0_Callback) %%%%%%%%%%%%%%%%%%%%:
|
---|
| 86 | %
|
---|
[159] | 87 | % fields are opened and visualised by the sub-function refresh_field.m
|
---|
| 88 | % (called by uvmat_opening, RUN0, runp and runm)
|
---|
| 89 | % The function first reads the name of the input file from the edit boxes of the GUI
|
---|
| 90 | % A second input file can be introduced for filed comparison
|
---|
| 91 | % It then reads the input file(s) with the appropriate function, read for
|
---|
| 92 | % images, read_civxdata.m for CIVx PIV data, nc2struct for other netcdf
|
---|
| 93 | % files.
|
---|
[2] | 94 | % Main input open second input open(_1) second image (pair animation)
|
---|
[159] | 95 | % | |
|
---|
| 96 | % | |
|
---|
[2] | 97 | % Field{1} Field{2}
|
---|
| 98 | % |
|
---|
| 99 | % coord transform (phys.m) or other user defined fct acting on Field{i} |
|
---|
| 100 | % Field{i}
|
---|
| 101 | % |
|
---|
| 102 | % calc_field.m: calculate scalar or other derived fields (vort, div..).
|
---|
| 103 | %
|
---|
| 104 | % sub_field.m: combine the input Field{i} in a single set of fields (vector + scalar):
|
---|
| 105 | % Field{i=1->3}.X --> UvData.X |
|
---|
| 106 | % |
|
---|
| 107 | % UvData
|
---|
| 108 | % |
|
---|
| 109 | % plot histograms of the whole field
|
---|
| 110 | % proj_field.m: project the set of fields on the current projection objects defined by UvData.Object
|
---|
| 111 | % | |
|
---|
| 112 | % ObjectData
|
---|
| 113 | % |
|
---|
[155] | 114 | % plot_field.m: plot the projected fields and store them as |
|
---|
| 115 | % UvData.axes3 |
|
---|
[2] | 116 | % |
|
---|
| 117 | % AxeData
|
---|
| 118 | %
|
---|
[15] | 119 | %%%%%%%%%%%%%% SCALARS: %%%%%%%%%%%%??%%%
|
---|
[2] | 120 | % scalars are displayed either as an image or countour plot, either as a color of
|
---|
| 121 | % velocity vectors. The scalar values in the first case is represented by
|
---|
| 122 | % UvData.Field.A, and by UvData.Field.C in the second case. The corresponding set of X
|
---|
| 123 | % and Y coordinates are represented by UvData.Field.AX and UvData.Field.AY, and .X and
|
---|
| 124 | % .Y for C (the same as velocity vectors). If A is a nxxny matrix (scalar
|
---|
| 125 | % on a regtular grid), then .AX andf.AY contains only two elements, represneting the
|
---|
| 126 | % coordinates of the four image corners. The scalar name is represented by
|
---|
| 127 | % the strings .AName and/or .CName.
|
---|
| 128 | % If the scalar exists in an input open (image or scalar stored under its
|
---|
| 129 | % name in a netcdf open), it is directly read at the level of Field{1}or Field{2}.
|
---|
| 130 | % Else only its name AName is recorded in Field{i}, and its field is then calculated
|
---|
[155] | 131 | %by the fuction calc_scal after the coordinate transform or after projection on an edit_object
|
---|
[2] | 132 |
|
---|
| 133 | % Properties attached to plotting figures (standard Matlab properties):
|
---|
| 134 | % 'CurrentAxes'= gca or get(gcf,'CurrentAxes');
|
---|
| 135 | % 'CurrentPoint'=get(gcf,'CurrentPoint'): figure coordinates of the point over which the mouse is positioned
|
---|
| 136 | % 'CurrentCharacter'=get(gcf,'CurrentCharacter'): last character typed over the figure where the mouse is positioned
|
---|
| 137 | % 'WindowButtonMotionFcn': function permanently called by mouse motion over the figure
|
---|
| 138 | % 'KeyPressFcn': function called by pressing a key on the key board
|
---|
| 139 | % 'WindowButtonDownFcn': function called by pressing the mouse over the figure
|
---|
| 140 | % 'WindowButtonUpFcn': function called by releasing the mouse pressure over the figure
|
---|
| 141 |
|
---|
| 142 | % Properties attached to plotting axes:
|
---|
| 143 | % 'CurrentPoint'=get(gca,'CurrentPoint'); (standard Matlab) same as for the figure, but position in plot coordinates.
|
---|
| 144 | % AxeData:=get(gca,'UserData');
|
---|
[155] | 145 | % AxeData.Drawing = create: create a new object
|
---|
| 146 | % = deform: modify an existing object by moving its defining create
|
---|
[2] | 147 | % = off: no current drawing action
|
---|
[155] | 148 | % = translate: translate an existing object
|
---|
| 149 | % = calibration: move a calibration point
|
---|
| 150 | % = zoom: isolate a subregion for zoom in=1 if an object is being currently drawn, 0 else (set to 0 by releasing mouse button)
|
---|
| 151 | % .CurrentOrigin: Origin of a curently drawn edit_object
|
---|
[2] | 152 | % .CurrentLine: currently drawn menuline (A REVOIR)
|
---|
[155] | 153 | % .CurrentObject: handle of the currently drawn edit_object
|
---|
[2] | 154 | % .CurrentRectZoom: current rectangle used for zoom
|
---|
| 155 |
|
---|
| 156 | % Properties attached to projection objects (create, menuline, menuplane...):
|
---|
[155] | 157 | % 'Tag'='proj_object': for all projection objects
|
---|
| 158 | % ObjectData.Style=...: style of projection object:
|
---|
[2] | 159 | % .ProjMode
|
---|
[155] | 160 | % .Coord: defines the position of the object
|
---|
[2] | 161 | % .XMin,YMin....
|
---|
| 162 | % .XMax,YMax....
|
---|
| 163 | % .DX,DY,DZ
|
---|
| 164 | % .Phi, .Theta, .Psi : Euler angles
|
---|
[155] | 165 | % .X,.Y,.U,.V.... : field data projected on the object
|
---|
[2] | 166 | % .IndexObj: index in the list of UvData.Object
|
---|
| 167 | %during plotting
|
---|
| 168 | % .plotaxes: handles of the current axes used to plot the result of field projection on the object
|
---|
| 169 | % .plothandle: vector of handle(s) of the object graphic represnetation in all the opened plotting axes
|
---|
| 170 | % To each projection object #iobj, corresponds an axis
|
---|
| 171 | % Object{iobj}.plotaxes and nbobj representation graphs Object{iobj}.plothandles(:) (where nbobj is the
|
---|
| 172 | % nbre of current objects opened in uvmat. Note that Object{iobj}.plothandles(iobj)=[] : an object is not represented in its own projection field;
|
---|
[89] | 173 |
|
---|
| 174 | %------------------------------------------------------------------------
|
---|
| 175 | %------------------------------------------------------------------------
|
---|
[2] | 176 | % I - MAIN FUNCTION UVMAT (DO NOT MODIFY)
|
---|
[89] | 177 | %------------------------------------------------------------------------
|
---|
| 178 | %------------------------------------------------------------------------
|
---|
[2] | 179 | function varargout = uvmat(varargin)
|
---|
| 180 |
|
---|
| 181 | % Begin initialization code - DO NOT EDIT
|
---|
| 182 | gui_Singleton = 1;
|
---|
| 183 | gui_State = struct('gui_Name', mfilename, ...
|
---|
| 184 | 'gui_Singleton', gui_Singleton, ...
|
---|
| 185 | 'gui_OpeningFcn', @uvmat_OpeningFcn, ...
|
---|
| 186 | 'gui_OutputFcn', @uvmat_OutputFcn, ...
|
---|
| 187 | 'gui_LayoutFcn', [], ...
|
---|
| 188 | 'gui_Callback', []);
|
---|
[128] | 189 | if nargin && ischar(varargin{1})&& ~isempty(regexp(varargin{1},'_Callback','once'))
|
---|
[2] | 190 | gui_State.gui_Callback = str2func(varargin{1});
|
---|
| 191 | end
|
---|
| 192 |
|
---|
| 193 | if nargout
|
---|
| 194 | varargout{1:nargout} = gui_mainfcn(gui_State, varargin{:});
|
---|
| 195 | else
|
---|
| 196 | gui_mainfcn(gui_State, varargin{:});
|
---|
| 197 | end
|
---|
| 198 | % End initialization code - DO NOT EDIT
|
---|
| 199 |
|
---|
[89] | 200 | %------------------------------------------------------------------------
|
---|
[141] | 201 | % --- Executes just before the GUI uvmat is made visible.
|
---|
[2] | 202 | function uvmat_OpeningFcn(hObject, eventdata, handles, input )
|
---|
[89] | 203 | %------------------------------------------------------------------------
|
---|
[71] | 204 | global nb_builtin
|
---|
| 205 |
|
---|
[2] | 206 | % Choose default command menuline output for uvmat
|
---|
| 207 | handles.output = hObject;
|
---|
| 208 |
|
---|
| 209 | % Update handles structure
|
---|
| 210 | guidata(hObject, handles);
|
---|
| 211 |
|
---|
| 212 | % set the position of colorbar and ancillary GUIs:
|
---|
| 213 | set(hObject,'Units','Normalized')
|
---|
| 214 | movegui(hObject,'center')
|
---|
| 215 | UvData.PosColorbar=[0.805 0.022 0.019 0.445];
|
---|
| 216 | UvData.SetObjectOrigin=[-0.05 -0.03]; %position for set_object
|
---|
| 217 | UvData.SetObjectSize=[0.3 0.7];
|
---|
| 218 | UvData.CalOrigin=[0.95 -0.03];%position for geometry_calib (TO IMPROVE)
|
---|
| 219 | UvData.CalSize=[0.28 1];
|
---|
| 220 |
|
---|
| 221 | %functions for the mouse and keyboard
|
---|
| 222 | set(handles.histo_u,'NextPlot','replacechildren');
|
---|
| 223 | set(handles.histo_v,'NextPlot','replacechildren');
|
---|
| 224 | set(hObject,'KeyPressFcn',{'keyboard_callback',handles})%set keyboard action function
|
---|
| 225 | set(hObject,'WindowButtonMotionFcn',{'mouse_motion',handles})%set mouse action functio
|
---|
| 226 | set(hObject,'WindowButtonDownFcn',{'mouse_down'})%set mouse click action function
|
---|
| 227 | set(hObject,'WindowButtonUpFcn',{'mouse_up',handles})
|
---|
[67] | 228 | set(hObject,'DeleteFcn',{@closefcn})%
|
---|
[2] | 229 |
|
---|
[89] | 230 | %refresh projection plane
|
---|
| 231 | UvData.Object{1}.Style='plane';%main plotting plane
|
---|
| 232 | UvData.Object{1}.ProjMode='projection';%main plotting plane
|
---|
| 233 | if ~isfield(UvData.Object{1},'plotaxes')
|
---|
| 234 | UvData.Object{1}.plotaxes=handles.axes3;%default plotting axis
|
---|
| 235 | set(handles.list_object_1,'Value',1);
|
---|
| 236 | set(handles.list_object_1,'String',{'1-PLANE'});
|
---|
| 237 | end
|
---|
| 238 |
|
---|
| 239 | %TRANSFORM menu: builtin fcts
|
---|
[39] | 240 | menu_str={'';'phys';'px';'phys_polar'};
|
---|
| 241 | nb_builtin=numel(menu_str); %number of functions
|
---|
[45] | 242 | path_uvmat=fileparts(which('uvmat'));
|
---|
[39] | 243 | addpath(fullfile(path_uvmat,'transform_field'))
|
---|
| 244 | fct_handle{1,1}=[];
|
---|
[60] | 245 | testexist=zeros(size(menu_str'));%default
|
---|
[39] | 246 | testexist(1)=1;
|
---|
| 247 | for ilist=2:length(menu_str)
|
---|
| 248 | if exist(menu_str{ilist},'file')
|
---|
| 249 | fct_handle{ilist,1}=str2func(menu_str{ilist});
|
---|
| 250 | testexist(ilist)=1;
|
---|
| 251 | else
|
---|
| 252 | testexist(ilist)=0;
|
---|
| 253 | end
|
---|
| 254 | end
|
---|
| 255 | rmpath(fullfile(path_uvmat,'transform_field'))
|
---|
| 256 |
|
---|
[2] | 257 | %load the list of previously browsed files in menus Open and Open_1
|
---|
[40] | 258 | dir_perso=prefdir; % path to the directory .matlab for personal data
|
---|
| 259 | profil_perso=fullfile(dir_perso,'uvmat_perso.mat');% personal data file uvmauvmat_perso.mat' in .matlab
|
---|
[2] | 260 | if exist(profil_perso,'file')
|
---|
| 261 | h=load (profil_perso);
|
---|
| 262 | if isfield(h,'MenuFile_1')
|
---|
| 263 | set(handles.MenuFile_1,'Label',h.MenuFile_1);
|
---|
| 264 | set(handles.MenuFile_1_1,'Label',h.MenuFile_1);
|
---|
| 265 | end
|
---|
| 266 | if isfield(h,'MenuFile_1')
|
---|
| 267 | set(handles.MenuFile_2,'Label',h.MenuFile_2);
|
---|
| 268 | set(handles.MenuFile_2_1,'Label',h.MenuFile_2);
|
---|
| 269 | end
|
---|
| 270 | if isfield(h,'MenuFile_1')
|
---|
| 271 | set(handles.MenuFile_3,'Label',h.MenuFile_3);
|
---|
| 272 | set(handles.MenuFile_3_1,'Label',h.MenuFile_3);
|
---|
| 273 | end
|
---|
| 274 | if isfield(h,'MenuFile_1')
|
---|
| 275 | set(handles.MenuFile_4,'Label',h.MenuFile_4);
|
---|
| 276 | set(handles.MenuFile_4_1,'Label',h.MenuFile_4);
|
---|
| 277 | end
|
---|
| 278 | if isfield(h,'MenuFile_1')
|
---|
| 279 | set(handles.MenuFile_5,'Label',h.MenuFile_5);
|
---|
| 280 | set(handles.MenuFile_5_1,'Label',h.MenuFile_5);
|
---|
[39] | 281 | end
|
---|
| 282 | if isfield(h,'transform_fct') && iscell(h.transform_fct)
|
---|
| 283 | for ilist=1:length(h.transform_fct);
|
---|
| 284 | [path,file]=fileparts(h.transform_fct{ilist});
|
---|
| 285 | addpath(path)
|
---|
| 286 | if exist(file,'file')
|
---|
| 287 | h_func=str2func(file);
|
---|
[89] | 288 | testexist=[testexist 1];
|
---|
[39] | 289 | else
|
---|
| 290 | h_func=[];
|
---|
[89] | 291 | testexist=[testexist 0];
|
---|
[39] | 292 | end
|
---|
[89] | 293 | fct_handle=[fct_handle; {h_func}]; %concatene the list of paths
|
---|
[39] | 294 | rmpath(path)
|
---|
[89] | 295 | menu_str=[menu_str; {file}];
|
---|
[39] | 296 | end
|
---|
| 297 | end
|
---|
[2] | 298 | end
|
---|
[45] | 299 | menu_str=menu_str(testexist==1);%=menu_str(testexist~=0)
|
---|
| 300 | fct_handle=fct_handle(testexist==1);
|
---|
[39] | 301 | menu_str=[menu_str;{'more...'}];
|
---|
| 302 | set(handles.transform_fct,'String',menu_str)
|
---|
| 303 | set(handles.transform_fct,'UserData',fct_handle)% store the list of path in UserData of ACTION
|
---|
[2] | 304 |
|
---|
| 305 | %initiates menu of vector colors
|
---|
| 306 | list_menu=calc_field;
|
---|
| 307 | %list_menu=[{'ima_cor'};{'black'};{'white'};list_menu(3:end)];
|
---|
| 308 | set(handles.col_vec,'String',list_menu)
|
---|
| 309 |
|
---|
| 310 | %check the path and date of modification of all functions in uvmat
|
---|
| 311 | path_to_uvmat=which ('uvmat');% check the path detected for source file uvmat
|
---|
| 312 | [errormsg,date_str]=check_functions;%check the path of the functions called by uvmat.m
|
---|
[45] | 313 | date_str=['last modification: ' date_str];
|
---|
[2] | 314 | %case of an input argument for uvmat
|
---|
| 315 | testinputfield=0;
|
---|
| 316 | inputfile=[];
|
---|
| 317 | Field=[];
|
---|
| 318 | if exist('input','var')
|
---|
| 319 | if ~isempty(errormsg)
|
---|
[38] | 320 | msgbox_uvmat('WARNING',errormsg)
|
---|
[2] | 321 | end
|
---|
| 322 | if ishandle(handles.UVMAT_title)
|
---|
| 323 | delete(handles.UVMAT_title)
|
---|
| 324 | end
|
---|
| 325 | if isstruct(input)
|
---|
| 326 | if isfield(input,'InputFile')
|
---|
| 327 | inputfile=input.InputFile;
|
---|
| 328 | end
|
---|
| 329 | Field=input;
|
---|
| 330 | elseif ischar(input)% file name introduced as input
|
---|
| 331 | inputfile=input;
|
---|
[59] | 332 | elseif isnumeric(input)%simple matrix introduced as input
|
---|
[2] | 333 | sizinput=size(input);
|
---|
| 334 | if sizinput(1)<=1 || sizinput(2)<=1
|
---|
[38] | 335 | msgbox_uvmat('ERROR','bad input for uvmat: file name, structure or numerical matrix accepted')
|
---|
[2] | 336 | return
|
---|
| 337 | end
|
---|
[59] | 338 | Field.ListVarName={'A','coord_y','coord_x'};
|
---|
| 339 | Field.VarDimName={{'coord_y','coord_x'},'cord_y','coord_x'};
|
---|
[2] | 340 | Field.A=input;
|
---|
[59] | 341 | Field.coord_x=[0.5 size(input,2)-0.5];
|
---|
| 342 | Field.coord_y=[size(input,1)-0.5 0.5];
|
---|
[2] | 343 | end
|
---|
| 344 | if ~isempty(inputfile)
|
---|
| 345 | display_file_name(hObject, eventdata, handles,inputfile)
|
---|
| 346 | testinputfield=1;
|
---|
| 347 | else
|
---|
| 348 | UvData.TestInputFile=0;
|
---|
| 349 | end
|
---|
| 350 | if ~isempty(Field)
|
---|
| 351 | set(handles.Fields,'Value',1)
|
---|
[39] | 352 | set(handles.Fields,'String',{'get_field...'})
|
---|
[2] | 353 | testinputfield=1;
|
---|
| 354 |
|
---|
| 355 | % set the colorbar position on the interface:
|
---|
| 356 | UvData.PosColorbar=[0.805 0.022 0.019 0.445];
|
---|
| 357 | elseif ischar(input)
|
---|
| 358 | scan_i_Callback(handles.scan_i, eventdata, handles);
|
---|
| 359 | end
|
---|
| 360 | else
|
---|
| 361 | if ishandle(handles.UVMAT_title)
|
---|
[34] | 362 | fid=fopen('revision.log');
|
---|
[33] | 363 | if fid~=-1
|
---|
[105] | 364 | a=textscan(fid,'%s%s%s',1,'HeaderLines',1,'Delimiter','|');
|
---|
| 365 | set(handles.UVMAT_title,'String',[{'Copyright Joel Sommeria, 2008, Coriolis/ LEGI / CNRS-UJF-INPG'};{'GNU General Public License'}; {path_to_uvmat}; ...
|
---|
| 366 | {['at revision ' a{1}{1}]};a{3}(1);{date_str};errormsg]);
|
---|
| 367 | fclose(fid);
|
---|
[30] | 368 | else
|
---|
[105] | 369 | set(handles.UVMAT_title,'String',[{'Copyright Joel Sommeria, 2008, Coriolis/ LEGI / CNRS-UJF-INPG'};{'GNU General Public License'};{path_to_uvmat};...
|
---|
| 370 | {date_str};errormsg]);
|
---|
[30] | 371 | end
|
---|
[2] | 372 | end
|
---|
| 373 | end
|
---|
| 374 | UvData.NewSeries=1;
|
---|
| 375 | set(hObject,'UserData',UvData)
|
---|
| 376 | if testinputfield
|
---|
| 377 | %delete drawn objects
|
---|
| 378 | hother=findobj(handles.axes3,'Tag','proj_object');%find all the proj objects
|
---|
| 379 | for iobj=1:length(hother)
|
---|
| 380 | delete_object(hother(iobj))
|
---|
| 381 | end
|
---|
| 382 | if isempty(inputfile)
|
---|
[59] | 383 | errormsg=refresh_field(handles,[],[],[],[],[],[],{Field});
|
---|
[2] | 384 | set(handles.MenuTools,'Enable','on')
|
---|
| 385 | set(handles.OBJECT_txt,'Visible','on')
|
---|
[155] | 386 | set(handles.edit_object,'Visible','on')
|
---|
[61] | 387 | set(handles.list_object_1,'Visible','on')
|
---|
[2] | 388 | set(handles.frame_object,'Visible','on')
|
---|
[71] | 389 | if ~isempty(errormsg)
|
---|
| 390 | msgbox_uvmat('ERROR',errormsg)
|
---|
| 391 | end
|
---|
[2] | 392 | else
|
---|
| 393 | update_rootinfo(hObject,eventdata,handles);
|
---|
| 394 | end
|
---|
| 395 | end
|
---|
[40] | 396 | set_vec_col_bar(handles) %update the display of color code for vectors
|
---|
[38] | 397 |
|
---|
[141] | 398 | %------------------------------------------------------------------------
|
---|
[2] | 399 | % --- Outputs from this function are returned to the command menuline.
|
---|
| 400 | function varargout = uvmat_OutputFcn(hObject, eventdata, handles)
|
---|
| 401 | varargout{1} = handles.output;% the only output argument is the handle to the GUI figure
|
---|
| 402 |
|
---|
[141] | 403 | %------------------------------------------------------------------------
|
---|
| 404 | %------------------------------------------------------------------------
|
---|
| 405 | % II - FUNCTIONS FOR INTRODUCING THE INPUT FILES
|
---|
[2] | 406 | % automatically sets the global properties when the rootfile name is introduced
|
---|
| 407 | % then activate the view-field action if selected
|
---|
| 408 | % it is activated either by clicking on the RootPath window or by the
|
---|
| 409 | % browser
|
---|
[141] | 410 | %------------------------------------------------------------------------
|
---|
| 411 | %------------------------------------------------------------------------
|
---|
[2] | 412 | % --- Executes on the menu Open/Browse...
|
---|
| 413 | % search the files, recognize their type according to their name and fill the rootfile input windows
|
---|
| 414 | function MenuBrowse_Callback(hObject, eventdata, handles)
|
---|
| 415 | oldfile=read_file_boxes(handles);
|
---|
| 416 |
|
---|
| 417 | if isempty(oldfile)||isequal(oldfile,'') %loads the previously stored file name and set it as default in the file_input box
|
---|
| 418 | dir_perso=prefdir;
|
---|
| 419 | profil_perso=fullfile(dir_perso,'uvmat_perso.mat');
|
---|
| 420 | if exist(profil_perso,'file')
|
---|
| 421 | h=load (profil_perso);
|
---|
| 422 | if isfield(h,'MenuFile_1')
|
---|
| 423 | oldfile=h.MenuFile_1;
|
---|
| 424 | end
|
---|
| 425 | end
|
---|
| 426 | end
|
---|
| 427 | [FileName, PathName] = uigetfile( ...
|
---|
[174] | 428 | {'*.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] | 429 | '*.xml', '.xml files '; ...
|
---|
| 430 | '*.xls', '.xls files '; ...
|
---|
| 431 | '*.civ', '.civ files '; ...
|
---|
| 432 | '*.jpg',' jpeg image files'; ...
|
---|
| 433 | '*.png','.png image files'; ...
|
---|
| 434 | '*.tif','.tif image files'; ...
|
---|
| 435 | '*.avi;*.AVI','.avi movie files'; ...
|
---|
[73] | 436 | '*.vol','.volume images (png)'; ...
|
---|
[2] | 437 | '*.nc','.netcdf files'; ...
|
---|
| 438 | '*.cdf','.netcdf files'; ...
|
---|
[174] | 439 | '*.cmx','.cmx text files ';...
|
---|
[2] | 440 | '*.fig','.fig files (matlab fig)';...
|
---|
| 441 | '*.log','.log text files ';...
|
---|
| 442 | '*.dat','.dat text files ';...
|
---|
[73] | 443 | '*.bat','.bat system command text files';...
|
---|
[2] | 444 | '*.*', 'All Files (*.*)'}, ...
|
---|
| 445 | 'Pick a file',oldfile);
|
---|
| 446 | %global filebase
|
---|
| 447 | fileinput=[PathName FileName];%complete file name
|
---|
[163] | 448 | % testblank=findstr(fileinput,' ');%look for blanks
|
---|
| 449 | % if ~isempty(testblank)
|
---|
| 450 | % msgbox_uvmat('ERROR',['The input file name ' fileinput ' contains blank character : This is not allowed. Please change name'])
|
---|
| 451 | % return
|
---|
| 452 | % end
|
---|
[2] | 453 | sizf=size(fileinput);
|
---|
| 454 | if (~ischar(fileinput)||~isequal(sizf(1),1)),return;end
|
---|
| 455 |
|
---|
| 456 | % display the selected field and related information
|
---|
| 457 | display_file_name(hObject, eventdata, handles,fileinput)
|
---|
| 458 |
|
---|
| 459 | %update list of recent files in the menubar
|
---|
| 460 | MenuFile_1=fileinput;
|
---|
| 461 | MenuFile_2=get(handles.MenuFile_1,'Label');
|
---|
| 462 | MenuFile_3=get(handles.MenuFile_2,'Label');
|
---|
| 463 | MenuFile_4=get(handles.MenuFile_3,'Label');
|
---|
| 464 | MenuFile_5=get(handles.MenuFile_4,'Label');
|
---|
| 465 | set(handles.MenuFile_1,'Label',MenuFile_1)
|
---|
| 466 | set(handles.MenuFile_2,'Label',MenuFile_2)
|
---|
| 467 | set(handles.MenuFile_3,'Label',MenuFile_3)
|
---|
| 468 | set(handles.MenuFile_4,'Label',MenuFile_4)
|
---|
| 469 | set(handles.MenuFile_5,'Label',MenuFile_5)
|
---|
| 470 | set(handles.MenuFile_1_1,'Label',MenuFile_1)
|
---|
| 471 | set(handles.MenuFile_2_1,'Label',MenuFile_2)
|
---|
| 472 | set(handles.MenuFile_3_1,'Label',MenuFile_3)
|
---|
| 473 | set(handles.MenuFile_4_1,'Label',MenuFile_4)
|
---|
| 474 | set(handles.MenuFile_5_1,'Label',MenuFile_5)
|
---|
| 475 | dir_perso=prefdir;
|
---|
| 476 | profil_perso=fullfile(dir_perso,'uvmat_perso.mat');
|
---|
| 477 | if exist(profil_perso,'file')
|
---|
| 478 | save (profil_perso,'MenuFile_1','MenuFile_2','MenuFile_3','MenuFile_4', 'MenuFile_5','-append'); %store the file names for future opening of uvmat
|
---|
| 479 | else
|
---|
[147] | 480 | txt=ver('MATLAB');
|
---|
| 481 | Release=txt.Release;
|
---|
[2] | 482 | relnumb=str2double(Release(3:4));
|
---|
| 483 | if relnumb >= 14
|
---|
| 484 | save (profil_perso,'MenuFile_1','MenuFile_2','MenuFile_3','MenuFile_4', 'MenuFile_5','-V6'); %store the file names for future opening of uvmat
|
---|
| 485 | else
|
---|
| 486 | save (profil_perso,'MenuFile_1','MenuFile_2','MenuFile_3','MenuFile_4', 'MenuFile_5'); %store the file names for future opening of uvmat
|
---|
| 487 | end
|
---|
| 488 | end
|
---|
| 489 |
|
---|
[141] | 490 | % -----------------------------------------------------------------------
|
---|
| 491 | % --- Open again the file whose name has been recorded in MenuFile_1
|
---|
[2] | 492 | function MenuFile_1_Callback(hObject, eventdata, handles)
|
---|
| 493 | fileinput=get(handles.MenuFile_1,'Label');
|
---|
| 494 | display_file_name(hObject, eventdata, handles,fileinput)
|
---|
| 495 |
|
---|
[141] | 496 | % -----------------------------------------------------------------------
|
---|
| 497 | % --- Open again the file whose name has been recorded in MenuFile_2
|
---|
[2] | 498 | function MenuFile_2_Callback(hObject, eventdata, handles)
|
---|
| 499 | fileinput=get(handles.MenuFile_2,'Label');
|
---|
| 500 | display_file_name(hObject, eventdata, handles,fileinput)
|
---|
| 501 |
|
---|
[141] | 502 | % -----------------------------------------------------------------------
|
---|
| 503 | % --- Open again the file whose name has been recorded in MenuFile_3
|
---|
[2] | 504 | function MenuFile_3_Callback(hObject, eventdata, handles)
|
---|
| 505 | fileinput=get(handles.MenuFile_3,'Label');
|
---|
| 506 | display_file_name(hObject, eventdata, handles,fileinput)
|
---|
| 507 |
|
---|
[141] | 508 | % -----------------------------------------------------------------------
|
---|
| 509 | % --- Open again the file whose name has been recorded in MenuFile_4
|
---|
[2] | 510 | function MenuFile_4_Callback(hObject, eventdata, handles)
|
---|
| 511 | fileinput=get(handles.MenuFile_4,'Label');
|
---|
| 512 | display_file_name(hObject, eventdata, handles,fileinput)
|
---|
| 513 |
|
---|
[141] | 514 | % -----------------------------------------------------------------------
|
---|
| 515 | % --- Open again the file whose name has been recorded in MenuFile_5
|
---|
[2] | 516 | function MenuFile_5_Callback(hObject, eventdata, handles)
|
---|
| 517 | fileinput=get(handles.MenuFile_5,'Label');
|
---|
| 518 | display_file_name(hObject, eventdata, handles,fileinput)
|
---|
| 519 |
|
---|
[141] | 520 | %------------------------------------------------------------------------
|
---|
| 521 | % --- Fills the edit boxes RootPath, RootFile,NomType...from an input file name 'fileinput'
|
---|
[2] | 522 | function display_file_name(hObject, eventdata, handles,fileinput)
|
---|
[29] | 523 | if ~exist(fileinput,'file')
|
---|
| 524 | msgbox_uvmat('ERROR',['input file ' fileinput ' does not exist'])
|
---|
| 525 | return
|
---|
| 526 | end
|
---|
[2] | 527 | [RootPath,RootFile,i1,i2,str_a,str_b,ext,NomType,SubDir]=name2display(fileinput);
|
---|
[29] | 528 | ext_test=''; %default
|
---|
| 529 | if ~isempty(ext)
|
---|
| 530 | form=imformats(ext(2:end));%test valid Matlab image formats
|
---|
| 531 | if ~isempty(form)
|
---|
| 532 | ext_test='.image';
|
---|
| 533 | imainfo=imfinfo(fileinput);
|
---|
| 534 | if length(imainfo) >1 %case of image with multiple frames
|
---|
| 535 | i1='1'; % set the frame counter to 1 by default
|
---|
| 536 | i2='';
|
---|
| 537 | str_a='';
|
---|
| 538 | str_b='';
|
---|
| 539 | NomType='*'; %indicate a set of indexed frames within a single file
|
---|
| 540 | [RootPath,RootFile]=fileparts(fileinput); %include the indices in the root file
|
---|
| 541 | end
|
---|
| 542 | elseif isequal(lower(ext),'.avi')
|
---|
| 543 | ext_test='.image';
|
---|
[2] | 544 | i1='1'; % set the frame counter to 1 by default
|
---|
| 545 | i2='';
|
---|
| 546 | str_a='';
|
---|
| 547 | str_b='';
|
---|
| 548 | NomType='*'; %indicate a set of indexed frames within a single file
|
---|
| 549 | [RootPath,RootFile]=fileparts(fileinput); %include the indices in the root file
|
---|
[29] | 550 | else
|
---|
| 551 | ext_test=lower(ext);
|
---|
[2] | 552 | end
|
---|
| 553 | end
|
---|
| 554 | switch ext_test
|
---|
[73] | 555 | case {'.civ','.log','.cmx','.cmx2','.txt','.bat'} %display text file
|
---|
[2] | 556 | edit(fileinput)
|
---|
| 557 | case '.fig' %display matlab figure
|
---|
| 558 | hfig=open(fileinput);
|
---|
| 559 | set(hfig,'WindowButtonMotionFcn','mouse_motion')%set mouse action functio
|
---|
| 560 | set(hfig,'WindowButtonUpFcn','mouse_up')%set mouse click action function
|
---|
| 561 | set(hfig,'WindowButtonUpFcn','mouse_down')%set mouse click action function
|
---|
| 562 | case {'.xml','.xls'} % edit xml or Excel files
|
---|
| 563 | editxml(fileinput);
|
---|
| 564 | case {'.avi','.image','.vol','.nc','.cdf'}
|
---|
| 565 | set(handles.RootPath,'String',RootPath);
|
---|
| 566 | if isequal(SubDir,'')
|
---|
| 567 | rootname=fullfile(RootPath,RootFile);
|
---|
| 568 | else
|
---|
| 569 | rootname=fullfile(RootPath,SubDir,RootFile);
|
---|
| 570 | SubDir=['/' SubDir]; %display the separator
|
---|
| 571 | end
|
---|
| 572 | set(handles.SubDir,'String',SubDir);
|
---|
| 573 | set(handles.RootFile,'String',['/' RootFile]); %display the separator
|
---|
| 574 | indices=fileinput(length(rootname)+1:end);
|
---|
| 575 | indices(end-length(ext)+1:end)=[]; %remove extension
|
---|
| 576 | set(handles.FileIndex,'String',indices);
|
---|
| 577 | set(handles.FileIndex,'UserData',NomType);
|
---|
| 578 | set(handles.FileExt,'String',ext);
|
---|
| 579 | % fill file index counters
|
---|
[71] | 580 | set(handles.i1,'String',i1);
|
---|
[2] | 581 | set(handles.i2,'String',i2);
|
---|
| 582 | set(handles.j1,'String',str_a);
|
---|
| 583 | set(handles.j2,'String',str_b);
|
---|
| 584 |
|
---|
| 585 | % synchronise indices of the second input file if it exists
|
---|
| 586 | if get(handles.SubField,'Value')==1% if the subfield button is activated, update the field numbers
|
---|
[71] | 587 | [ff,rr,FileBase_1,ii,FileExt_1,SubDir_1]=read_file_boxes_1(handles);
|
---|
[2] | 588 | NomType_1=get(handles.FileIndex_1,'UserData');
|
---|
[89] | 589 | FileName_1=name_generator(FileBase_1,str2double(i1),str2double(i2),FileExt_1,NomType_1,1,stra2num(str_a),stra2num(str_b),SubDir_1);
|
---|
[71] | 590 | if exist(FileName_1,'file')
|
---|
[89] | 591 | FileIndex_1=name_generator('',str2double(i1),str2double(i2),'',NomType_1,1,stra2num(str_a),stra2num(str_b),'');
|
---|
[2] | 592 | set(handles.FileIndex_1,'String',FileIndex_1)
|
---|
| 593 | else
|
---|
| 594 | set(handles.SubField,'Value',0)
|
---|
| 595 | SubField_Callback(hObject, eventdata, handles)
|
---|
| 596 | end
|
---|
| 597 | end
|
---|
| 598 |
|
---|
| 599 | %enable other menus
|
---|
| 600 | set(handles.MenuOpen_1,'Enable','on')
|
---|
| 601 | set(handles.MenuFile_1_1,'Enable','on')
|
---|
| 602 | set(handles.MenuFile_2_1,'Enable','on')
|
---|
| 603 | set(handles.MenuFile_3_1,'Enable','on')
|
---|
| 604 | set(handles.MenuFile_4_1,'Enable','on')
|
---|
| 605 | set(handles.MenuFile_5_1,'Enable','on')
|
---|
| 606 | set(handles.MenuExport,'Enable','on')
|
---|
| 607 | set(handles.MenuExportFigure,'Enable','on')
|
---|
| 608 | set(handles.MenuExportMovie,'Enable','on')
|
---|
| 609 | set(handles.MenuTools,'Enable','on')
|
---|
| 610 | set(handles.OBJECT_txt,'Visible','on')
|
---|
[155] | 611 | set(handles.edit_object,'Visible','on')
|
---|
[61] | 612 | set(handles.list_object_1,'Visible','on')
|
---|
[2] | 613 | set(handles.frame_object,'Visible','on')
|
---|
| 614 | % initiate input file:
|
---|
| 615 | update_rootinfo(hObject,eventdata,handles);
|
---|
| 616 | otherwise
|
---|
| 617 | msgbox_uvmat('ERROR',['invalid input file extension' ext])
|
---|
| 618 | end
|
---|
| 619 |
|
---|
[89] | 620 | %------------------------------------------------------------------------
|
---|
[141] | 621 | % --- Called by action in RootPath edit box
|
---|
[2] | 622 | function RootPath_Callback(hObject,eventdata,handles)
|
---|
[89] | 623 | %------------------------------------------------------------------------
|
---|
[2] | 624 | update_rootinfo(hObject,eventdata,handles);
|
---|
| 625 |
|
---|
[89] | 626 | %------------------------------------------------------------------------
|
---|
[141] | 627 | % --- Called by action in RootFile edit box
|
---|
[2] | 628 | function SubDir_Callback(hObject, eventdata, handles)
|
---|
[89] | 629 | %------------------------------------------------------------------------
|
---|
[2] | 630 | %refresh the menu of input fields
|
---|
| 631 | Fields_Callback(hObject, eventdata, handles);
|
---|
| 632 | % refresh the current field
|
---|
| 633 | run0_Callback(hObject, eventdata, handles);
|
---|
| 634 |
|
---|
[89] | 635 | %------------------------------------------------------------------------
|
---|
[141] | 636 | % --- Called by action in RootFile edit box
|
---|
[2] | 637 | function RootFile_Callback(hObject, eventdata, handles)
|
---|
[89] | 638 | %------------------------------------------------------------------------
|
---|
[2] | 639 | update_rootinfo(hObject,eventdata,handles)
|
---|
| 640 |
|
---|
[89] | 641 | %------------------------------------------------------------------------
|
---|
[141] | 642 | % --- Called by action in FileIndex edit box
|
---|
[81] | 643 | function FileIndex_Callback(hObject, eventdata, handles)
|
---|
[89] | 644 | %------------------------------------------------------------------------
|
---|
[81] | 645 | FileIndices=get(handles.FileIndex,'String');
|
---|
| 646 | if isempty(str2num(FileIndices))
|
---|
| 647 | [pp,ff,str1,str2,str_a,str_b]=name2display(FileIndices);
|
---|
| 648 | else
|
---|
| 649 | str1=FileIndices;
|
---|
| 650 | str2='';
|
---|
| 651 | str_a='';
|
---|
| 652 | str_b='';
|
---|
| 653 | end
|
---|
| 654 | set(handles.i1,'String',str1);
|
---|
| 655 | set(handles.i2,'String',str2);
|
---|
| 656 | set(handles.j1,'String',str_a);
|
---|
| 657 | set(handles.j2,'String',str_b);
|
---|
| 658 | run0_Callback(hObject, eventdata, handles)
|
---|
[2] | 659 |
|
---|
[89] | 660 | %------------------------------------------------------------------------
|
---|
[141] | 661 | % --- Update information about a new field series (indices to scan, timing,
|
---|
| 662 | % calibration from an xml file, then refresh current plots
|
---|
[2] | 663 | function update_rootinfo(hObject,eventdata,handles)
|
---|
[89] | 664 | %------------------------------------------------------------------------
|
---|
[2] | 665 | set(handles.RootPath,'BackgroundColor',[1 1 0])
|
---|
| 666 | drawnow
|
---|
| 667 | set(handles.Fields,'UserData',[])% reinialize data from uvmat opening
|
---|
[59] | 668 | UvData=get(handles.uvmat,'UserData');%huvmat=handles of the uvmat interface
|
---|
[2] | 669 | UvData.NewSeries=1; %flag for run0: begin a new series
|
---|
| 670 | UvData.TestInputFile=1;
|
---|
[81] | 671 | set(handles.fix_pair,'Value',1) % activate by default the comp_input '-'input window
|
---|
[2] | 672 |
|
---|
| 673 | [FileName,RootPath,FileBase,FileIndices,FileExt,SubDir]=read_file_boxes(handles);
|
---|
| 674 | if ~exist(FileName,'file')
|
---|
| 675 | msgbox_uvmat('ERROR',['input file ' FileName ' not found']);
|
---|
| 676 | return
|
---|
| 677 | end
|
---|
| 678 | nbfield=[];%default
|
---|
| 679 | nburst=[];%default
|
---|
| 680 |
|
---|
| 681 | % read timing and total frame number from the current file (movie files) !! may be overrid by xml file
|
---|
| 682 | XmlData.Time=[];%default
|
---|
| 683 | XmlData.GeometryCalib=[];%default
|
---|
| 684 | TimeUnit=[];%default
|
---|
| 685 | testima=0; %test for image input
|
---|
[89] | 686 | imainfo=[];
|
---|
| 687 | ColorType='falsecolor'; %default
|
---|
| 688 | hhh='';
|
---|
[2] | 689 | if isequal(lower(FileExt),'.avi') %.avi file
|
---|
| 690 | testima=1;
|
---|
[89] | 691 | imainfo=aviinfo([FileBase FileIndices FileExt]);
|
---|
| 692 | nbfield=imainfo.NumFrames;
|
---|
[2] | 693 | nburst=1;
|
---|
[89] | 694 | set(handles.Dt_txt,'String',['Dt=' num2str(1000/imainfo.FramesPerSecond) 'ms']);%display the elementary time interval in millisec
|
---|
| 695 | XmlData.Time=(0:1/imainfo.FramesPerSecond:(imainfo.NumFrames-1)/imainfo.FramesPerSecond)';
|
---|
[2] | 696 | TimeUnit='s';
|
---|
| 697 | hhh=which('mmreader');
|
---|
[89] | 698 | ColorType=imainfo.ImageType;%='truecolor' for color images
|
---|
[139] | 699 | elseif ~isempty(FileExt(2:end))&&(~isempty(imformats(FileExt(2:end))) || isequal(FileExt,'.vol'))%&& isequal(NomType,'*')% multi-frame image
|
---|
[2] | 700 | testima=1;
|
---|
| 701 | if ~isequal(SubDir,'')
|
---|
| 702 | RootFile=get(handles.RootFile,'String');
|
---|
| 703 | imainfo=imfinfo([fullfile(RootPath,SubDir,RootFile) FileIndices FileExt]);
|
---|
| 704 | else
|
---|
| 705 | imainfo=imfinfo([FileBase FileIndices FileExt]);
|
---|
| 706 | end
|
---|
[89] | 707 | ColorType=imainfo.ColorType;%='truecolor' for color images
|
---|
[2] | 708 | if length(imainfo) >1 %case of image with multiple frames
|
---|
| 709 | nbfield=length(imainfo);
|
---|
| 710 | nburst=1;
|
---|
| 711 | end
|
---|
[89] | 712 | end
|
---|
| 713 | if ~strcmp(hhh,'')&& mmreader.isPlatformSupported()% if the function is found (recent version of matlab)
|
---|
| 714 | UvData.MovieObject=mmreader([FileBase FileIndices FileExt]);
|
---|
| 715 | elseif isfield(UvData,'MovieObject')
|
---|
| 716 | UvData=rmfield(UvData,'MovieObject');
|
---|
| 717 | end
|
---|
| 718 | if isfield(imainfo,'Width') && isfield(imainfo,'Height')
|
---|
| 719 | set(handles.npx,'String',num2str(imainfo.Width));%fills nbre of pixels x box
|
---|
| 720 | set(handles.npy,'String',num2str(imainfo.Height));%fills nbre of pixels x box
|
---|
| 721 | else
|
---|
[2] | 722 | set(handles.npx,'String','');%fills nbre of pixels x box
|
---|
[89] | 723 | set(handles.npy,'String','');%fills nbre of pixels x box
|
---|
[2] | 724 | end
|
---|
[89] | 725 | set(handles.BW,'Value',strcmp(ColorType,'grayscale'))% select handles.BW if grayscale image
|
---|
[2] | 726 |
|
---|
| 727 | % read parameters (time, geometric calibration..) from a documentation file (.xml advised)
|
---|
| 728 | filexml=[FileBase '.xml'];
|
---|
| 729 | fileciv=[FileBase '.civ'];
|
---|
| 730 | warntext='';%default warning message
|
---|
| 731 | NbSlice=1;%default
|
---|
| 732 |
|
---|
| 733 | if exist(filexml,'file')
|
---|
| 734 | set(handles.view_xml,'Visible','on')
|
---|
| 735 | set(handles.view_xml,'BackgroundColor',[1 1 0])
|
---|
| 736 | set(handles.RootPath,'BackgroundColor',[1 1 1])
|
---|
| 737 | set(handles.view_xml,'String','view .xml')
|
---|
| 738 | drawnow
|
---|
| 739 | [XmlData,warntext]=imadoc2struct(filexml);
|
---|
| 740 | if ~isempty(warntext)
|
---|
| 741 | msgbox_uvmat('WARNING',warntext)
|
---|
| 742 | end
|
---|
| 743 | if isfield(XmlData,'TimeUnit')
|
---|
| 744 | if isfield(XmlData,'TimeUnit')&& ~isempty(XmlData.TimeUnit)
|
---|
| 745 | TimeUnit=XmlData.TimeUnit;
|
---|
| 746 | end
|
---|
| 747 | end
|
---|
| 748 | set(handles.view_xml,'BackgroundColor',[1 1 1])
|
---|
| 749 | drawnow
|
---|
[116] | 750 | if isfield(XmlData, 'GeometryCalib') && ~isempty(XmlData.GeometryCalib)
|
---|
| 751 | hgeometry_calib=findobj('tag','geometry_calib');
|
---|
| 752 | if ~isempty(hgeometry_calib)
|
---|
| 753 | GUserData=get(hgeometry_calib,'UserData');
|
---|
| 754 | if ~(isfield(GUserData,'XmlInputFile') && strcmp(GUserData.XmlInputFile,filexml))
|
---|
| 755 | answer=msgbox_uvmat('INPUT_Y-N','replace the display of geometry_calib with the new input data?');
|
---|
| 756 | if strcmp(answer,'Yes')
|
---|
| 757 | geometry_calib(filexml);%diplay the new calibration points and parameters in geometry_calib
|
---|
| 758 | end
|
---|
| 759 | end
|
---|
| 760 | end
|
---|
| 761 | end
|
---|
[2] | 762 | elseif exist(fileciv,'file')% if .civ file found
|
---|
| 763 | [error,XmlData.Time,TimeUnit,mode,npx,npy,pxcmx,pxcmy]=read_imatext([FileBase '.civ']);
|
---|
| 764 | GeometryCalib.R=[pxcmx 0 0; 0 pxcmy 0;0 0 0];
|
---|
| 765 | GeometryCalib.Tx=0;
|
---|
| 766 | GeometryCalib.Ty=0;
|
---|
| 767 | GeometryCalib.Tz=1;
|
---|
| 768 | GeometryCalib.dpx=1;
|
---|
| 769 | GeometryCalib.dpy=1;
|
---|
| 770 | GeometryCalib.sx=1;
|
---|
| 771 | GeometryCalib.Cx=0;
|
---|
| 772 | GeometryCalib.Cy=0;
|
---|
| 773 | GeometryCalib.f=1;
|
---|
| 774 | GeometryCalib.kappa1=0;
|
---|
| 775 | GeometryCalib.CoordUnit='cm';
|
---|
| 776 | XmlData.GeometryCalib=GeometryCalib;
|
---|
| 777 | if error==2, warntext=['no file ' FileBase '.civ'];
|
---|
| 778 | elseif error==1, warntext='inconsistent number of fields in the .civ file';
|
---|
| 779 | end
|
---|
| 780 | set(handles.npx,'String',num2str(npx));%fills nbre of pixels x box
|
---|
| 781 | set(handles.npy,'String',num2str(npy));%fills nbre of pixels y box
|
---|
| 782 | set(handles.pxcm,'String',num2str(pxcmx));%fills scale x (pixel/cm) box
|
---|
| 783 | set(handles.pycm,'String',num2str(pxcmy));%fills scale y (pixel/cm) box
|
---|
| 784 | set(handles.pxcm,'Visible','on');%fills scale x (pixel/cm) box
|
---|
| 785 | set(handles.pycm,'Visible','on');%fills scale y (pixel/cm) box
|
---|
| 786 | set(handles.view_xml,'Visible','on')
|
---|
| 787 | set(handles.view_xml,'String','view .civ')
|
---|
| 788 | else
|
---|
| 789 | set(handles.view_xml,'Visible','off')
|
---|
| 790 | end
|
---|
| 791 |
|
---|
| 792 | % store last index in handles.lat_i and .last_j
|
---|
| 793 | if ~isempty(XmlData.Time)
|
---|
| 794 | nbfield=size(XmlData.Time,1);
|
---|
| 795 | nburst=size(XmlData.Time,2);
|
---|
[84] | 796 | %transform .Time to a column vector if it is a line vector the nomenclature uses a single index
|
---|
| 797 | if isequal(nbfield,1) && ~isequal(nburst,1)% .Time is a line vector
|
---|
| 798 | NomType=get(handles.FileIndex,'UserData');
|
---|
| 799 | if numel(NomType)>=2 &&(strcmp(NomType,'_i')||strcmp(NomType(1:2),'%0')||strcmp(NomType(1:2),'_%'))
|
---|
| 800 | XmlData.Time=(XmlData.Time)';
|
---|
| 801 | nbfield=nburst;
|
---|
| 802 | nburst=1;
|
---|
| 803 | end
|
---|
| 804 | end
|
---|
[2] | 805 | end
|
---|
| 806 | last_i_cell=get(handles.last_i,'String');
|
---|
| 807 | if isempty(nbfield)
|
---|
| 808 | last_i_cell{1}='';
|
---|
| 809 | else
|
---|
| 810 | last_i_cell{1}=num2str(nbfield);
|
---|
| 811 | end
|
---|
| 812 | set(handles.last_i,'String',last_i_cell)
|
---|
| 813 | last_j_cell=get(handles.last_j,'String');
|
---|
| 814 | if isempty(nburst)
|
---|
| 815 | last_j_cell{1}='';
|
---|
| 816 | else
|
---|
| 817 | last_j_cell{1}=num2str(nburst);
|
---|
| 818 | end
|
---|
| 819 | set(handles.last_j,'String',last_j_cell);
|
---|
| 820 |
|
---|
| 821 | % store geometric calibration in UvData
|
---|
| 822 | if isfield(XmlData,'GeometryCalib')
|
---|
| 823 | GeometryCalib=XmlData.GeometryCalib;
|
---|
| 824 | if isempty(GeometryCalib)
|
---|
| 825 | set(handles.pxcm,'String','')
|
---|
| 826 | set(handles.pycm,'String','')
|
---|
[39] | 827 | set(handles.transform_fct,'Value',1); % no transform by default
|
---|
[2] | 828 | else
|
---|
[122] | 829 | if (isfield(GeometryCalib,'R')&& ~isequal(GeometryCalib.R(2,1),0) && ~isequal(GeometryCalib.R(1,2),0)) ||...
|
---|
[89] | 830 | (isfield(GeometryCalib,'kappa1')&& ~isequal(GeometryCalib.kappa1,0))
|
---|
[2] | 831 | set(handles.pxcm,'String','var')
|
---|
| 832 | set(handles.pycm,'String','var')
|
---|
[114] | 833 | elseif isfield(GeometryCalib,'fx_fy')
|
---|
[122] | 834 | pixcmx=GeometryCalib.fx_fy(1);%*GeometryCalib.R(1,1)*GeometryCalib.sx/(GeometryCalib.Tz*GeometryCalib.dpx);
|
---|
| 835 | pixcmy=GeometryCalib.fx_fy(2);%*GeometryCalib.R(2,2)/(GeometryCalib.Tz*GeometryCalib.dpy);
|
---|
[2] | 836 | set(handles.pxcm,'String',num2str(pixcmx))
|
---|
| 837 | set(handles.pycm,'String',num2str(pixcmy))
|
---|
| 838 | end
|
---|
[84] | 839 | if ~get(handles.FixedLimits,'Value')
|
---|
| 840 | set(handles.transform_fct,'Value',2); % phys transform by default if fixedLimits is off
|
---|
| 841 | end
|
---|
[2] | 842 | if isfield(GeometryCalib,'SliceCoord')
|
---|
[89] | 843 |
|
---|
[2] | 844 | siz=size(GeometryCalib.SliceCoord);
|
---|
| 845 | if siz(1)>1
|
---|
| 846 | NbSlice=siz(1);
|
---|
| 847 | set(handles.slices,'Visible','on')
|
---|
| 848 | set(handles.slices,'Value',1)
|
---|
| 849 | end
|
---|
[73] | 850 | if isfield(GeometryCalib,'NbSlice') && isequal(GeometryCalib.NbSlice,'volume')
|
---|
[60] | 851 | set(handles.nb_slice,'String','volume')
|
---|
| 852 | else
|
---|
| 853 | set(handles.nb_slice,'String',num2str(NbSlice))
|
---|
| 854 | end
|
---|
[2] | 855 | slices_Callback(hObject, eventdata, handles)
|
---|
[89] | 856 | end
|
---|
[2] | 857 | end
|
---|
| 858 | end
|
---|
| 859 |
|
---|
| 860 | %update the data attached to the uvmat interface
|
---|
| 861 | if ~isempty(TimeUnit)
|
---|
| 862 | set(handles.time_txt,'String',['time (' TimeUnit ')'])
|
---|
| 863 | end
|
---|
| 864 | UvData.TimeUnit=TimeUnit;
|
---|
| 865 | UvData.XmlData=XmlData;
|
---|
| 866 | UvData.NewSeries=1;
|
---|
[59] | 867 | set(handles.uvmat,'UserData',UvData)
|
---|
[2] | 868 |
|
---|
| 869 | %display warning message
|
---|
| 870 | if ~isequal(warntext,'')
|
---|
| 871 | msgbox_uvmat('WARNING',warntext);
|
---|
| 872 | end
|
---|
| 873 |
|
---|
| 874 | % set default options in menu 'Fields'
|
---|
| 875 | if testima
|
---|
| 876 | set(handles.Fields,'Value',1) % set menu to 'image'
|
---|
| 877 | set(handles.Fields,'String',{'image';'get_field...';'velocity';'vort';'div';'more...'})
|
---|
[45] | 878 | elseif isequal(FileExt,'.nc')||isequal(FileExt,'.cdf')
|
---|
[56] | 879 | Data=nc2struct(FileName,'ListGlobalAttribute','absolut_time_T0','civ');
|
---|
[2] | 880 | col_vec=get(handles.col_vec,'String');
|
---|
[59] | 881 | if ~isempty(Data.absolut_time_T0)&& ~isequal(Data.civ,0)
|
---|
[2] | 882 | set(handles.Fields,'String',{'image';'get_field...';'velocity';'vort';'div';'more...'})
|
---|
| 883 | set(handles.Fields,'Value',3) % set menu to 'velocity'
|
---|
| 884 | col_vec{1}='ima_cor';
|
---|
[45] | 885 | else %general netcdf file (not civx)
|
---|
[2] | 886 | set(handles.Fields,'Value',1) % set menu to 'get_field...
|
---|
| 887 | set(handles.Fields,'String',{'get_field...'})
|
---|
| 888 | col_vec{1}='get_field...';
|
---|
| 889 | end
|
---|
| 890 | set(handles.col_vec,'String',col_vec)
|
---|
| 891 | else
|
---|
| 892 | msgbox_uvmat('ERROR',['invalid input file extension ' FileExt])
|
---|
| 893 | return
|
---|
| 894 | end
|
---|
| 895 |
|
---|
| 896 | % set index navigation options and refresh plots
|
---|
| 897 | set(handles.RootPath,'BackgroundColor',[1 1 1])
|
---|
| 898 | drawnow
|
---|
| 899 | set_scan_options(hObject, eventdata, handles)
|
---|
| 900 |
|
---|
[141] | 901 | %------------------------------------------------------------------------
|
---|
| 902 | %--- Set index navigation options for new series input and refresh plot
|
---|
| 903 | %------------------------------------------------------------------------
|
---|
[2] | 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
|
---|
[122] | 916 | NomTypeRaw=regexprep(NomType(2:end), '-', '');
|
---|
| 917 | if numel(regexp(NomTypeRaw,'\D'))>=1
|
---|
| 918 | % case {'_i_j','_i_j1-j2','_i1-i2_j','#_ab','#A','%01dA','%02dA','%03dA','%04dA'},% two navigation indices
|
---|
[2] | 919 | state_j='on';
|
---|
[81] | 920 | if isequal(nbfield,1)
|
---|
[122] | 921 | scan_option='j'; %scan j index by default if nbfield=1
|
---|
[2] | 922 | end
|
---|
| 923 | end
|
---|
| 924 | if ~isempty(NomType_1)
|
---|
[122] | 925 | NomTypeRaw=regexprep(NomType_1(2:end), '-', '');
|
---|
| 926 | if numel(regexp(NomTypeRaw,'\D'))>=1
|
---|
| 927 | % switch NomType_1
|
---|
| 928 | % case {'_i_j','_i_j1-j2','_i1-i2_j','#_ab'},% two navigation indices
|
---|
[2] | 929 | state_j='on';
|
---|
[81] | 930 | if isequal(nbfield,1)
|
---|
| 931 | scan_option='j';
|
---|
| 932 | end
|
---|
[2] | 933 | end
|
---|
| 934 | end
|
---|
| 935 | if isequal(scan_option,'i')
|
---|
| 936 | set(handles.scan_i,'Value',1)
|
---|
| 937 | scan_i_Callback(hObject, eventdata, handles);
|
---|
| 938 | else
|
---|
| 939 | set(handles.scan_j,'Value',1)
|
---|
| 940 | scan_j_Callback(hObject, eventdata, handles);
|
---|
| 941 | end
|
---|
| 942 | set(handles.scan_j,'Visible',state_j)
|
---|
| 943 | set(handles.j1,'Visible',state_j)
|
---|
| 944 | set(handles.j2,'Visible',state_j)
|
---|
| 945 | set(handles.last_j,'Visible',state_j);
|
---|
| 946 | set(handles.frame_j,'Visible',state_j);
|
---|
| 947 | set(handles.j_text,'Visible',state_j);
|
---|
| 948 |
|
---|
| 949 | % view the field
|
---|
| 950 | run0_Callback(hObject, eventdata, handles); %view field
|
---|
| 951 | mask_test=get(handles.mask_test,'value');
|
---|
| 952 | if mask_test
|
---|
| 953 | MaskData=get(handles.mask_test,'UserData');
|
---|
| 954 | if isfield(MaskData,'maskhandle') && ishandle(MaskData.maskhandle)
|
---|
| 955 | delete(MaskData.maskhandle) %delete old mask
|
---|
| 956 | end
|
---|
| 957 | mask_test_Callback(hObject, eventdata, handles)
|
---|
| 958 | end
|
---|
[59] | 959 |
|
---|
[141] | 960 | %------------------------------------------------------------------------
|
---|
| 961 | % --- Executes on the menu Open/Browse_1 for the second input field,
|
---|
| 962 | % search the files, recognize their type according to their name and fill the rootfile input windows
|
---|
[2] | 963 | function MenuBrowse_1_Callback(hObject, eventdata, handles)
|
---|
| 964 | %-------------------------------------------------------------------
|
---|
[61] | 965 | % huvmat=get(handles.run0,'parent');
|
---|
| 966 | UvData=get(handles.uvmat,'UserData');
|
---|
[2] | 967 |
|
---|
| 968 | RootPath=get(handles.RootPath,'String');
|
---|
| 969 | [FileName, PathName, filterindex] = uigetfile( ...
|
---|
| 970 | {'*.xml;*.xls;*.civ;*.jpg;*.png;*.avi;*.AVI;*.nc;*.cmx;*.fig;*.log;*.dat', ' (*.xml,*.xls,*.civ, *.jpg,*.png, *.avi,*.nc,*.cmx ,*.fig,*.log,*.dat)';
|
---|
| 971 | '*.xml', '.xml files '; ...
|
---|
| 972 | '*.xls', '.xls files '; ...
|
---|
| 973 | '*.civ', '.civ files '; ...
|
---|
| 974 | '*.jpg','.jpg image files'; ...
|
---|
| 975 | '*.png','.png image files'; ...
|
---|
| 976 | '*.avi;*.AVI','.avi movie files'; ...
|
---|
| 977 | '*.nc','.netcdf files'; ...
|
---|
| 978 | '*.cdf','.netcdf files'; ...
|
---|
| 979 | '*.cmx','.cmx text files';...
|
---|
| 980 | '*.cmx2','.cmx2 text files';...
|
---|
| 981 | '*.fig','.fig files (matlab fig)';...
|
---|
| 982 | '*.log','.log text files ';...
|
---|
| 983 | '*.dat','.dat text files ';...
|
---|
| 984 | '*.*', 'All Files (*.*)'}, ...
|
---|
| 985 | 'Pick a file',RootPath);
|
---|
| 986 | fileinput_1=[PathName FileName];%complete file name
|
---|
[163] | 987 | % testblank=findstr(fileinput_1,' ');%look for blanks
|
---|
| 988 | % if ~isempty(testblank)
|
---|
| 989 | % msgbox_uvmat('ERROR',['The input file name ' fileinput_1 ' contains blank character : This is not allowed. Please change name'])
|
---|
| 990 | % return
|
---|
| 991 | % end
|
---|
[2] | 992 | sizf=size(fileinput_1);
|
---|
[89] | 993 | if (~ischar(fileinput_1)||~isequal(sizf(1),1)),return;end
|
---|
[2] | 994 |
|
---|
| 995 | % refresh the current displayed field
|
---|
| 996 | display_file_name_1(hObject,eventdata,handles,fileinput_1)
|
---|
| 997 |
|
---|
| 998 | %update list of recent files in the menubar
|
---|
| 999 | MenuFile_1=fileinput_1;
|
---|
| 1000 | MenuFile_2=get(handles.MenuFile_1,'Label');
|
---|
| 1001 | MenuFile_3=get(handles.MenuFile_2,'Label');
|
---|
| 1002 | MenuFile_4=get(handles.MenuFile_3,'Label');
|
---|
| 1003 | MenuFile_5=get(handles.MenuFile_4,'Label');
|
---|
| 1004 | set(handles.MenuFile_1,'Label',MenuFile_1)
|
---|
| 1005 | set(handles.MenuFile_2,'Label',MenuFile_2)
|
---|
| 1006 | set(handles.MenuFile_3,'Label',MenuFile_3)
|
---|
| 1007 | set(handles.MenuFile_4,'Label',MenuFile_4)
|
---|
| 1008 | set(handles.MenuFile_5,'Label',MenuFile_5)
|
---|
| 1009 | set(handles.MenuFile_1_1,'Label',MenuFile_1)
|
---|
| 1010 | set(handles.MenuFile_2_1,'Label',MenuFile_2)
|
---|
| 1011 | set(handles.MenuFile_3_1,'Label',MenuFile_3)
|
---|
| 1012 | set(handles.MenuFile_4_1,'Label',MenuFile_4)
|
---|
| 1013 | set(handles.MenuFile_5_1,'Label',MenuFile_5)
|
---|
| 1014 | dir_perso=prefdir;
|
---|
| 1015 | profil_perso=fullfile(dir_perso,'uvmat_perso.mat');
|
---|
| 1016 | if exist(profil_perso,'file')
|
---|
| 1017 | save (profil_perso,'MenuFile_1','MenuFile_2','MenuFile_3','MenuFile_4', 'MenuFile_5','-append'); %store the file names for future opening of uvmat
|
---|
| 1018 | else
|
---|
[147] | 1019 | txt=ver('MATLAB');
|
---|
| 1020 | Release=txt.Release;
|
---|
[150] | 1021 | relnumb=str2double(Release(3:4));
|
---|
[2] | 1022 | if relnumb >= 14
|
---|
| 1023 | save (profil_perso,'MenuFile_1','MenuFile_2','MenuFile_3','MenuFile_4', 'MenuFile_5','-V6'); %store the file names for future opening of uvmat
|
---|
| 1024 | else
|
---|
| 1025 | save (profil_perso,'MenuFile_1','MenuFile_2','MenuFile_3','MenuFile_4', 'MenuFile_5'); %store the file names for future opening of uvmat
|
---|
| 1026 | end
|
---|
| 1027 | end
|
---|
| 1028 |
|
---|
[141] | 1029 | % -----------------------------------------------------------------------
|
---|
| 1030 | % --- Open again as second field the file whose name has been recorded in MenuFile_1
|
---|
[2] | 1031 | function MenuFile_1_1_Callback(hObject, eventdata, handles)
|
---|
| 1032 | fileinput_1=get(handles.MenuFile_1_1,'Label');
|
---|
| 1033 | display_file_name_1(hObject,eventdata,handles,fileinput_1)
|
---|
| 1034 |
|
---|
[141] | 1035 | % -----------------------------------------------------------------------
|
---|
| 1036 | % --- Open again as second field the file whose name has been recorded in MenuFile_2
|
---|
[2] | 1037 | function MenuFile_2_1_Callback(hObject, eventdata, handles)
|
---|
| 1038 | fileinput_1=get(handles.MenuFile_2_1,'Label');
|
---|
| 1039 | display_file_name_1(hObject,eventdata,handles,fileinput_1)
|
---|
| 1040 |
|
---|
[141] | 1041 | % -----------------------------------------------------------------------
|
---|
| 1042 | % --- Open again as second field the file whose name has been recorded in MenuFile_3
|
---|
[2] | 1043 | function MenuFile_3_1_Callback(hObject, eventdata, handles)
|
---|
| 1044 | fileinput_1=get(handles.MenuFile_3_1,'Label');
|
---|
| 1045 | display_file_name_1(hObject,eventdata,handles,fileinput_1)
|
---|
| 1046 |
|
---|
[141] | 1047 | % -----------------------------------------------------------------------
|
---|
| 1048 | % --- Open again as second field the file whose name has been recorded in MenuFile_4
|
---|
[2] | 1049 | function MenuFile_4_1_Callback(hObject, eventdata, handles)
|
---|
| 1050 | fileinput_1=get(handles.MenuFile_4_1,'Label');
|
---|
| 1051 | display_file_name_1(hObject,eventdata,handles,fileinput_1)
|
---|
| 1052 |
|
---|
[141] | 1053 | % -----------------------------------------------------------------------
|
---|
| 1054 | % --- Open again as second field the file whose name has been recorded in MenuFile_5
|
---|
[2] | 1055 | function MenuFile_5_1_Callback(hObject, eventdata, handles)
|
---|
| 1056 | fileinput_1=get(handles.MenuFile_5_1,'Label');
|
---|
| 1057 | display_file_name_1(hObject,eventdata,handles,fileinput_1)
|
---|
| 1058 |
|
---|
[141] | 1059 | %------------------------------------------------------------------------
|
---|
| 1060 | % fills the edit boxes RootPath_1, RootFile_1,NomType_1...from an input file name 'fileinput_1'
|
---|
| 1061 | %------------------------------------------------------------------------
|
---|
[2] | 1062 | function display_file_name_1(hObject,eventdata,handles,fileinput_1)
|
---|
| 1063 |
|
---|
| 1064 | %[path,name,ext]=fileparts(fileinput_1);
|
---|
| 1065 | [RootPath_1,RootFile_1,field_count,str2,str_a,str_b,FileExt_1,NomType_1,SubDir_1]=name2display(fileinput_1);
|
---|
| 1066 | nbfield_1=1; %default
|
---|
| 1067 | ext_test=FileExt_1;%default
|
---|
| 1068 | form=imformats(FileExt_1(2:end));
|
---|
| 1069 | if ~isempty(form) % if the extension corresponds to an image format recognized by Matlab
|
---|
| 1070 | imainfo=imfinfo(fileinput_1);
|
---|
| 1071 | nbfield_1=length(imainfo);
|
---|
| 1072 | ext_test='.image';
|
---|
| 1073 | elseif isequal(lower(FileExt_1),'.avi')
|
---|
| 1074 | info=aviinfo(fileinput_1);
|
---|
| 1075 | nbfield_1=info.NumFrames;
|
---|
| 1076 | ext_test='.image';
|
---|
| 1077 | end
|
---|
| 1078 |
|
---|
| 1079 | %open directly fig or text files
|
---|
| 1080 | switch ext_test
|
---|
| 1081 | case {'.civ','.log','.cmx','.cmx2','.txt'} %display text file
|
---|
| 1082 | edit(fileinput)
|
---|
| 1083 | return
|
---|
| 1084 | case '.fig' %display matlab figure
|
---|
| 1085 | hfig=open(fileinput);
|
---|
| 1086 | set(hfig,'WindowButtonMotionFcn','mouse_motion')%set mouse action functio
|
---|
| 1087 | set(hfig,'WindowButtonUpFcn','mouse_up')%set mouse click action function
|
---|
| 1088 | set(hfig,'WindowButtonUpFcn','mouse_down')%set mouse click action function
|
---|
| 1089 | return
|
---|
| 1090 | case {'.xml','.xls'} % edit xml or Excel files
|
---|
| 1091 | heditxml=editxml(fileinput);
|
---|
| 1092 | return
|
---|
| 1093 | case {'.image','.nc','.cdf'}
|
---|
| 1094 | % set(handles.FileIndex,'UserData',NomType_1);
|
---|
| 1095 | otherwise
|
---|
[38] | 1096 | msgbox_uvmat(['invalid input file extension ' FileExt_1 ' for uvmat'],'ERROR')
|
---|
[2] | 1097 | return
|
---|
| 1098 | end
|
---|
| 1099 |
|
---|
| 1100 | % test for image series in a single file and synchronise file indices of the two series
|
---|
| 1101 | if nbfield_1 >1 %case of image with multiple frames
|
---|
| 1102 | if nbfield_1 < num_i1
|
---|
[38] | 1103 | msgbox_uvmat('ERROR','current frame index beyond the input movie length')
|
---|
[2] | 1104 | return
|
---|
| 1105 | else
|
---|
| 1106 | NomType_1='*'; %indicate a set of indexed frames within a single file
|
---|
| 1107 | filename_new=fileinput_1;
|
---|
| 1108 | end
|
---|
| 1109 | else % cases of data files
|
---|
| 1110 | RootPath=get(handles.RootPath,'String');
|
---|
| 1111 | RootFile=get(handles.RootFile,'String');
|
---|
| 1112 | FileBase=fullfile(RootPath,RootFile);
|
---|
| 1113 | FileBase_1=fullfile(RootPath_1,RootFile_1);
|
---|
| 1114 | if isequal(FileBase,FileBase_1)
|
---|
| 1115 | filename_new=fileinput_1;
|
---|
| 1116 | else
|
---|
| 1117 | num_i1=stra2num(get(handles.i1,'String'));%get the current file indices from counters
|
---|
| 1118 | num_j1=stra2num(get(handles.j1,'String'));
|
---|
| 1119 | num_i2=stra2num(get(handles.i2,'String'));
|
---|
| 1120 | num_j2=stra2num(get(handles.j2,'String'));
|
---|
| 1121 | [filename_new,idetect]=...
|
---|
| 1122 | 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
|
---|
| 1123 | indices=''; %default
|
---|
| 1124 | if ~idetect
|
---|
[38] | 1125 | msgbox_uvmat('ERROR','second input file with indices corresponding to the first one does not exist')
|
---|
[2] | 1126 | return
|
---|
| 1127 | end
|
---|
| 1128 | end
|
---|
| 1129 | end
|
---|
[81] | 1130 | set(handles.FileIndex_1,'UserData',NomType_1);
|
---|
[2] | 1131 |
|
---|
| 1132 | % make visible and fill the second raw of edit boxes
|
---|
| 1133 | set(handles.RootPath_1,'Visible','on')
|
---|
| 1134 | set(handles.RootFile_1,'Visible','on')
|
---|
| 1135 | set(handles.SubDir_1,'Visible','on');
|
---|
| 1136 | set(handles.FileIndex_1,'Visible','on');
|
---|
| 1137 | set(handles.FileExt_1,'Visible','on');
|
---|
| 1138 | [FileName,RootPath,FileBase,FileIndices,FileExt,SubDir]=read_file_boxes(handles);
|
---|
| 1139 | if isequal(FileBase,FileBase_1)
|
---|
| 1140 | set(handles.RootPath_1,'String','"')
|
---|
| 1141 | set(handles.RootFile_1,'String','"');
|
---|
| 1142 | else
|
---|
| 1143 | set(handles.RootPath_1,'String',RootPath_1)
|
---|
| 1144 | set(handles.RootFile_1,'String',['/' RootFile_1]);
|
---|
| 1145 | end
|
---|
| 1146 | if isequal(SubDir_1,'')
|
---|
| 1147 | set(handles.SubDir_1,'String','');
|
---|
| 1148 | FileBaseSub_1=FileBase_1;
|
---|
| 1149 | else
|
---|
| 1150 | set(handles.SubDir_1,'String',['/' SubDir_1]);
|
---|
| 1151 | FileBaseSub_1=fullfile(FileBase_1,SubDir_1);
|
---|
| 1152 | end
|
---|
| 1153 | indices=filename_new(length(FileBaseSub_1)+1:end);
|
---|
| 1154 | indices(end-length(FileExt_1)+1:end)=[]; %remove extension
|
---|
| 1155 | set(handles.FileIndex_1,'String',indices)
|
---|
| 1156 | set(handles.FileIndex_1,'UserData',NomType_1)
|
---|
| 1157 | set(handles.FileExt_1,'String',FileExt_1);
|
---|
| 1158 |
|
---|
| 1159 | % default choice of fields
|
---|
| 1160 | if isequal(ext_test,'.image')
|
---|
| 1161 | set(handles.Fields_1,'String',{'';'image';'get_field...';'velocity';'vort';'div';'more...'})
|
---|
| 1162 | set(handles.Fields_1,'Value',2) % set menu to 'image'
|
---|
[128] | 1163 | elseif strcmp(FileExt_1,'.nc')||strcmp(FileExt_1,'.cdf')
|
---|
[2] | 1164 | Data=nc2struct(fileinput_1,[]);
|
---|
| 1165 | if isfield(Data,'absolut_time_T0')
|
---|
| 1166 | set(handles.Fields_1,'String',{'';'image';'get_field...';'velocity';'vort';'div';'more...'})
|
---|
| 1167 | set(handles.Fields_1,'Value',4) % set menu to 'velocity'
|
---|
| 1168 | else
|
---|
| 1169 | set(handles.Fields_1,'Value',2) % set menu to 'get_field...'
|
---|
| 1170 | set(handles.Fields_1,'String',{'';'get_field...'});
|
---|
| 1171 | end
|
---|
| 1172 | end
|
---|
| 1173 | set(handles.SubField,'Visible','on')
|
---|
| 1174 | set(handles.SubField,'Value',1)
|
---|
| 1175 | RootPath_1_Callback(hObject,eventdata,handles);
|
---|
| 1176 |
|
---|
[141] | 1177 | %-----------------------------------------------------------------------
|
---|
| 1178 | % --- Called by action in RootPath_1 edit box
|
---|
[2] | 1179 | function RootPath_1_Callback(hObject,eventdata,handles)
|
---|
| 1180 | update_rootinfo_1(hObject,eventdata,handles)
|
---|
| 1181 |
|
---|
[141] | 1182 | %-----------------------------------------------------------------------
|
---|
| 1183 | % --- Called by action in RootFile_1 edit box
|
---|
[2] | 1184 | function RootFile_1_Callback(hObject, eventdata, handles)
|
---|
| 1185 | update_rootinfo_1(hObject,eventdata,handles)
|
---|
[141] | 1186 | %-----------------------------------------------------------------------
|
---|
[2] | 1187 |
|
---|
[141] | 1188 | %------------------------------------------------------------------------
|
---|
| 1189 | % --- Called by action in FileIndex_1 edit box
|
---|
| 1190 | function FileIndex_1_Callback(hObject, eventdata, handles)
|
---|
| 1191 | %------------------------------------------------------------------------
|
---|
| 1192 |
|
---|
| 1193 | run0_Callback(hObject, eventdata, handles)
|
---|
| 1194 |
|
---|
| 1195 | %------------------------------------------------------------------------
|
---|
| 1196 | % --- Update information about a new second field series (indices to scan, timing,
|
---|
| 1197 | % calibration from an xml file, then refresh current plots
|
---|
[2] | 1198 | function update_rootinfo_1(hObject,eventdata,handles) %A REVOIR
|
---|
| 1199 |
|
---|
| 1200 | set(handles.RootPath_1,'BackgroundColor',[1 1 0])% indicate active program by yellow color
|
---|
| 1201 | drawnow
|
---|
[61] | 1202 | UvData=get(handles.uvmat,'UserData');%huvmat=handles of the uvmat interface
|
---|
[2] | 1203 | UvData.NewSeries=1; %flag for run0: begin a new series
|
---|
| 1204 |
|
---|
[93] | 1205 | [FileName,RootPath,FileBase,FileIndices,FileExt,SubDir]=read_file_boxes_1(handles);
|
---|
[2] | 1206 | if ~exist(FileName,'file')
|
---|
| 1207 | msgbox_uvmat('ERROR',['input file ' FileName ' not found']);
|
---|
| 1208 | end
|
---|
| 1209 | nbfield_1=[];%default
|
---|
| 1210 | nburst_1=[];%default
|
---|
| 1211 | XmlData.Time=[];
|
---|
| 1212 | XmlData.GeometryCalib=[];%default
|
---|
| 1213 | TimeUnit=[];
|
---|
| 1214 | if isfield(UvData,'TimeUnit')
|
---|
| 1215 | TimeUnit=UvData.TimeUnit;
|
---|
| 1216 | end
|
---|
| 1217 | TimeUnit_1=[];
|
---|
[89] | 1218 | hhh='';%default, test for movie reading with mmreader
|
---|
| 1219 | imainfo=[];
|
---|
[2] | 1220 | if isequal(lower(FileExt),'.avi') %.avi file
|
---|
[89] | 1221 | imainfo=aviinfo([FileBase FileIndices FileExt]);
|
---|
| 1222 | nbfield_1=imainfo.NumFrames;
|
---|
[2] | 1223 | nburst_1=1;
|
---|
| 1224 | set(handles.Dt_txt,'String',['Dt=' num2str(1000/info.FramesPerSecond) 'ms']);%display the elementary time interval in millisec
|
---|
[89] | 1225 | time=[0:1/imainfo.FramesPerSecond:(imainfo.NumFrames-1)/imainfo.FramesPerSecond]';
|
---|
| 1226 | ColorType=imainfo.ImageType;%='truecolor' for color images
|
---|
| 1227 | hhh=which('mmreader');
|
---|
| 1228 | elseif ~isempty(imformats(FileExt(2:end)))|| isequal(FileExt,'.vol')
|
---|
| 1229 | if ~isequal(SubDir,'')
|
---|
| 1230 | RootFile=get(handles.RootFile,'String');
|
---|
| 1231 | imainfo=imfinfo([fullfile(RootPath,SubDir,RootFile) FileIndices FileExt]);
|
---|
| 1232 | else
|
---|
| 1233 | imainfo=imfinfo([FileBase FileIndices FileExt]);
|
---|
[2] | 1234 | end
|
---|
[89] | 1235 | ColorType=imainfo.ColorType;%='truecolor' for color images
|
---|
[2] | 1236 | if length(imainfo) >1 %case of image with multiple frames
|
---|
| 1237 | nbfield_1=length(imainfo);
|
---|
| 1238 | nburst_1=1;
|
---|
[89] | 1239 | end
|
---|
[2] | 1240 | end
|
---|
[89] | 1241 | if ~strcmp(hhh,'')&& mmreader.isPlatformSupported()% if the function is found (recent version of matlab)
|
---|
| 1242 | UvData.MovieObject_1=mmreader([FileBase FileIndices FileExt]);
|
---|
| 1243 | elseif isfield(UvData,'MovieObject_1')
|
---|
| 1244 | UvData=rmfield(UvData,'MovieObject_1');
|
---|
| 1245 | end
|
---|
[141] | 1246 | if ~isempty(imainfo)% (an image has been introduced as second fierld input)
|
---|
| 1247 | if strcmp(get(handles.npx,'String'),'') || strcmp(get(handles.npy,'String'),'')%update npx and npy if it is not already filled by the first input field
|
---|
| 1248 | if isfield(imainfo,'Width') && isfield(imainfo,'Height')
|
---|
| 1249 | set(handles.npx,'String',num2str(imainfo.Width));%fills nbre of pixels x box
|
---|
| 1250 | set(handles.npy,'String',num2str(imainfo.Height));%fills nbre of pixels x box
|
---|
| 1251 | else
|
---|
| 1252 | set(handles.npx,'String','');%fills nbre of pixels x box
|
---|
| 1253 | set(handles.npy,'String','');%fills nbre of pixels x box
|
---|
| 1254 | end
|
---|
| 1255 | set(handles.BW,'Value',strcmp(ColorType,'grayscale'))% select handles.BW if grayscale image
|
---|
[89] | 1256 | end
|
---|
| 1257 | end
|
---|
[2] | 1258 | % find scaling parameters
|
---|
| 1259 | filexml=[FileBase '.xml'];
|
---|
| 1260 | fileciv=[FileBase '.civ'];
|
---|
| 1261 | warntext='';%default warning text
|
---|
| 1262 | if exist(filexml,'file')
|
---|
| 1263 | [XmlData,warntext]=imadoc2struct(filexml);
|
---|
| 1264 | if ~isempty(warntext)
|
---|
| 1265 | msgbox_uvmat('WARNING',warntext)
|
---|
| 1266 | end
|
---|
| 1267 | if isfield(XmlData,'Camera')
|
---|
| 1268 | if isfield(XmlData.Camera,'TimeUnit')&& ~isempty(XmlData.Camera.TimeUnit)
|
---|
| 1269 | TimeUnit=XmlData.Camera.TimeUnit;
|
---|
| 1270 | end
|
---|
| 1271 | end
|
---|
| 1272 | elseif exist(fileciv,'file')% if .civ file found
|
---|
| 1273 | [error,XmlData.Time,TimeUnit,mode,npx,npy,pxcmx,pxcmy]=read_imatext([FileBase '.civ']);
|
---|
| 1274 | GeometryCalib.R=[pxcmx 0 0; 0 pxcmy 0;0 0 0];
|
---|
| 1275 | GeometryCalib.Tx=0;
|
---|
| 1276 | GeometryCalib.Ty=0;
|
---|
| 1277 | GeometryCalib.Tz=1;
|
---|
| 1278 | GeometryCalib.dpx=1;
|
---|
| 1279 | GeometryCalib.dpy=1;
|
---|
| 1280 | GeometryCalib.sx=1;
|
---|
| 1281 | GeometryCalib.Cx=0;
|
---|
| 1282 | GeometryCalib.Cy=0;
|
---|
| 1283 | GeometryCalib.f=1;
|
---|
| 1284 | GeometryCalib.kappa1=0;
|
---|
| 1285 | GeometryCalib.CoordUnit='cm';
|
---|
| 1286 | XmlData.GeometryCalib=GeometryCalib;
|
---|
| 1287 | if error==2, warntext=['no file ' FileBase '.civ'];
|
---|
| 1288 | elseif error==1, warntext='inconsistent number of fields in the .civ file';
|
---|
| 1289 | end
|
---|
| 1290 |
|
---|
| 1291 | set(handles.npx,'String',num2str(npx));%fills nbre of pixels x box
|
---|
| 1292 | set(handles.npy,'String',num2str(npy));%fills nbre of pixels y box
|
---|
| 1293 | set(handles.pxcm,'String',num2str(pxcmx));%fills scale x (pixel/cm) box
|
---|
| 1294 | set(handles.pycm,'String',num2str(pxcmy));%fills scale y (pixel/cm) box
|
---|
| 1295 | set(handles.pxcm,'Visible','on');%fills scale x (pixel/cm) box
|
---|
| 1296 | set(handles.pycm,'Visible','on');%fills scale y (pixel/cm) box
|
---|
| 1297 | end
|
---|
| 1298 | if ~isempty(TimeUnit_1) && ~isequal(TimeUnit_1,TimeUnit)
|
---|
[38] | 1299 | msgbox_uvmat('WARNING','the time units for the second series differs from the first one')
|
---|
[2] | 1300 | end
|
---|
| 1301 |
|
---|
| 1302 | % store last index in handles.lat_i and .last_j
|
---|
| 1303 | if ~isempty(XmlData.Time)
|
---|
| 1304 | nbfield_1=size(XmlData.Time,1);
|
---|
| 1305 | nburst_1=size(XmlData.Time,2);
|
---|
| 1306 | end
|
---|
| 1307 | last_i_cell=get(handles.last_i,'String');
|
---|
| 1308 | if isempty(nbfield_1)
|
---|
| 1309 | last_i_cell{2}='';
|
---|
| 1310 | else
|
---|
| 1311 | last_i_cell{2}=num2str(nbfield_1);
|
---|
| 1312 | end
|
---|
| 1313 | set(handles.last_i,'String',last_i_cell)
|
---|
| 1314 | last_j_cell=get(handles.last_j,'String');
|
---|
| 1315 | if isempty(nburst_1)
|
---|
| 1316 | last_j_cell{2}='';
|
---|
| 1317 | else
|
---|
| 1318 | last_j_cell{2}=num2str(nburst_1);
|
---|
| 1319 | end
|
---|
| 1320 | set(handles.last_j,'String',last_j_cell);
|
---|
| 1321 | if ~isequal(last_i_cell{1},last_i_cell{2}) || ~isequal(last_j_cell{1},last_j_cell{2})
|
---|
[38] | 1322 | msgbox_uvmat('WARNING','the numbers of input file of the second series differs from the first one')
|
---|
[2] | 1323 | end
|
---|
| 1324 |
|
---|
| 1325 | % store calibration data
|
---|
| 1326 | GeometryCalib=XmlData.GeometryCalib;
|
---|
| 1327 | if isempty(GeometryCalib)
|
---|
| 1328 | if isfield(UvData, 'GeometryCalib_1')
|
---|
| 1329 | UvData=rmfield(UvData,'GeometryCalib_1');
|
---|
| 1330 | end
|
---|
| 1331 | else
|
---|
| 1332 | UvData.GeometryCalib_1=GeometryCalib;
|
---|
| 1333 | if (isfield(GeometryCalib,'R')& ~isequal(GeometryCalib.R(2,1),0) & ~isequal(GeometryCalib.R(1,2),0)) |...
|
---|
| 1334 | (isfield(GeometryCalib,'kappa1')& ~isequal(GeometryCalib.kappa1,0))
|
---|
| 1335 | set(handles.pxcm,'String','var')
|
---|
| 1336 | set(handles.pycm,'String','var')
|
---|
| 1337 | else
|
---|
[155] | 1338 | if isfield(GeometryCalib,'fx_fy')
|
---|
| 1339 | pixcmx=GeometryCalib.fx_fy(1);
|
---|
| 1340 | pixcmy=GeometryCalib.fx_fy(2);
|
---|
| 1341 | set(handles.pxcm,'String',num2str(pixcmx))
|
---|
| 1342 | set(handles.pycm,'String',num2str(pixcmy))
|
---|
| 1343 | end
|
---|
[2] | 1344 | end
|
---|
| 1345 | end
|
---|
| 1346 | UvData.XmlData_1=XmlData;
|
---|
[61] | 1347 | set(handles.uvmat,'UserData',UvData)%update the data attached to the uvmat interface
|
---|
[2] | 1348 |
|
---|
| 1349 | if ~isequal(warntext,'')
|
---|
[38] | 1350 | msgbox_uvmat('WARNING',warntext)
|
---|
[2] | 1351 | end
|
---|
| 1352 |
|
---|
| 1353 | set(handles.RootPath_1,'BackgroundColor',[1 1 1])% signa the end the input operation
|
---|
| 1354 | drawnow
|
---|
| 1355 |
|
---|
| 1356 | set_scan_options(hObject, eventdata, handles)
|
---|
| 1357 |
|
---|
| 1358 | %---------------------------------------------------
|
---|
| 1359 | % switch file index scanning options scan_i and scan_j in an exclusive way
|
---|
| 1360 | function scan_i_Callback(hObject, eventdata, handles)
|
---|
| 1361 | %---------------------------------------------------
|
---|
| 1362 | if get(handles.scan_i,'Value')==1
|
---|
| 1363 | set(handles.scan_i,'BackgroundColor',[1 1 0])
|
---|
| 1364 | set(handles.scan_j,'Value',0)
|
---|
[81] | 1365 | % set(handles.scan_j,'BackgroundColor',[0.831 0.816 0.784])
|
---|
[2] | 1366 | else
|
---|
| 1367 | set(handles.scan_i,'BackgroundColor',[0.831 0.816 0.784])
|
---|
| 1368 | set(handles.scan_j,'Value',1)
|
---|
[81] | 1369 | % set(handles.scan_j,'BackgroundColor',[1 1 0])
|
---|
[2] | 1370 | end
|
---|
[81] | 1371 | scan_j_Callback(hObject, eventdata, handles)
|
---|
[45] | 1372 |
|
---|
[2] | 1373 | %-------------------------------------------------------------------
|
---|
| 1374 | % switch file index scanning options scan_i and scan_j in an exclusive way
|
---|
| 1375 | function scan_j_Callback(hObject, eventdata, handles)
|
---|
| 1376 | %-------------------------------------------------------------------
|
---|
| 1377 | if get(handles.scan_j,'Value')==1
|
---|
| 1378 | set(handles.scan_j,'BackgroundColor',[1 1 0])
|
---|
| 1379 | set(handles.scan_i,'Value',0)
|
---|
| 1380 | set(handles.scan_i,'BackgroundColor',[0.831 0.816 0.784])
|
---|
[81] | 1381 | NomType=get(handles.FileIndex,'UserData');
|
---|
| 1382 | switch NomType
|
---|
| 1383 | case {'_i_j1-j2','#_ab','%3dab'},% pair with j index
|
---|
| 1384 | set(handles.fix_pair,'Visible','on')% option fixed pair on/off made visible (choice of avaible pair with buttons + and - if ='off')
|
---|
| 1385 | otherwise
|
---|
| 1386 | set(handles.fix_pair,'Visible','off')
|
---|
| 1387 | end
|
---|
[2] | 1388 | else
|
---|
| 1389 | set(handles.scan_j,'BackgroundColor',[0.831 0.816 0.784])
|
---|
| 1390 | set(handles.scan_i,'Value',1)
|
---|
| 1391 | set(handles.scan_i,'BackgroundColor',[1 1 0])
|
---|
[81] | 1392 | set(handles.fix_pair,'Visible','off')
|
---|
[2] | 1393 | end
|
---|
| 1394 |
|
---|
| 1395 | %-------------------------------------------------------------------
|
---|
| 1396 | function i1_Callback(hObject, eventdata, handles)
|
---|
| 1397 | %-------------------------------------------------------------------
|
---|
[139] | 1398 | set(handles.i1,'BackgroundColor',[0.7 0.7 0.7])
|
---|
[2] | 1399 | NomType=get(handles.FileIndex,'UserData');
|
---|
| 1400 | num1=stra2num(get(handles.i1,'String'));
|
---|
| 1401 | num2=stra2num(get(handles.i2,'String'));
|
---|
| 1402 | num_a=stra2num(get(handles.j1,'String'));
|
---|
| 1403 | num_b=stra2num(get(handles.j2,'String'));
|
---|
| 1404 | indices=name_generator('',num1,num_a,'',NomType,1,num2,num_b,'');
|
---|
| 1405 | set(handles.FileIndex,'String',indices)
|
---|
[139] | 1406 | set(handles.FileIndex,'BackgroundColor',[0.7 0.7 0.7])
|
---|
[2] | 1407 | if get(handles.SubField,'Value')==1
|
---|
| 1408 | NomType_1=get(handles.FileIndex_1,'String');
|
---|
| 1409 | FileExt_1=get(handles.FileExt_1,'String');
|
---|
| 1410 | [P,F,str1,str2,str_a,str_b,Ext,NomType_1]=name2display(['xx' NomType_1 FileExt_1]);
|
---|
| 1411 | indices=name_generator('',num1,num_a,'',NomType_1,1,num2,num_b,'');
|
---|
| 1412 | set(handles.FileIndex_1,'String',indices)
|
---|
[139] | 1413 | set(handles.FileIndex_1,'BackgroundColor',[0.7 0.7 0.7])
|
---|
[2] | 1414 | end
|
---|
[139] | 1415 | %Run0_Callback(hObject, eventdata, handles)
|
---|
[2] | 1416 |
|
---|
| 1417 | %-------------------------------------------------------------------
|
---|
| 1418 | function i2_Callback(hObject, eventdata, handles)
|
---|
[139] | 1419 | set(handles.i2,'BackgroundColor',[0.7 0.7 0.7])
|
---|
[2] | 1420 | i1_Callback(hObject, eventdata, handles)
|
---|
| 1421 | %-------------------------------------------------------------------
|
---|
| 1422 |
|
---|
| 1423 | %-------------------------------------------------------------------
|
---|
| 1424 | function j1_Callback(hObject, eventdata, handles)
|
---|
[139] | 1425 | set(handles.j1,'BackgroundColor',[0.7 0.7 0.7])
|
---|
[2] | 1426 | i1_Callback(hObject, eventdata, handles)
|
---|
| 1427 | %-------------------------------------------------------------------
|
---|
| 1428 |
|
---|
| 1429 | %-------------------------------------------------------------------
|
---|
| 1430 | function j2_Callback(hObject, eventdata, handles)
|
---|
[139] | 1431 | set(handles.j2,'BackgroundColor',[0.7 0.7 0.7])
|
---|
[2] | 1432 | i1_Callback(hObject, eventdata, handles)
|
---|
| 1433 | %-------------------------------------------------------------------
|
---|
| 1434 |
|
---|
| 1435 | %-------------------------------------------------------------------
|
---|
| 1436 | function slices_Callback(hObject, eventdata, handles)
|
---|
| 1437 | %-------------------------------------------------------------------
|
---|
| 1438 | if get(handles.slices,'Value')==1
|
---|
| 1439 | set(handles.slices,'BackgroundColor',[1 1 0])
|
---|
| 1440 | set(handles.nb_slice,'Visible','on')
|
---|
| 1441 | set(handles.z_text,'Visible','on')
|
---|
| 1442 | set(handles.z_index,'Visible','on')
|
---|
| 1443 | nb_slice_Callback(hObject, eventdata, handles)
|
---|
| 1444 | else
|
---|
| 1445 | set(handles.nb_slice,'Visible','off')
|
---|
| 1446 | set(handles.slices,'BackgroundColor',[0.7 0.7 0.7])
|
---|
| 1447 | set(handles.z_text,'Visible','off')
|
---|
| 1448 | set(handles.z_index,'Visible','off')
|
---|
| 1449 | set(handles.masklevel,'Value',1)
|
---|
| 1450 | set(handles.masklevel,'String',{'1'})
|
---|
| 1451 | end
|
---|
| 1452 |
|
---|
| 1453 | %-------------------------------------------------------------------
|
---|
| 1454 | function nb_slice_Callback(hObject, eventdata, handles)
|
---|
| 1455 | %-------------------------------------------------------------------
|
---|
[71] | 1456 | nb_slice_str=get(handles.nb_slice,'String');
|
---|
[60] | 1457 | if isequal(nb_slice_str,'volume')
|
---|
| 1458 | num=stra2num(get(handles.j1,'String'));
|
---|
| 1459 | last_j=get(handles.last_j,'String');
|
---|
| 1460 | nbslice=str2double(last_j{1});
|
---|
| 1461 | else
|
---|
| 1462 | num=str2double(get(handles.i1,'String'));
|
---|
| 1463 | nbslice=str2double(get(handles.nb_slice,'String'));
|
---|
| 1464 | end
|
---|
| 1465 | z=mod(num-1,nbslice)+1;
|
---|
[2] | 1466 | set(handles.z_index,'String',num2str(z))
|
---|
| 1467 | for ilist=1:nbslice
|
---|
| 1468 | list_index{ilist,1}=num2str(ilist);
|
---|
| 1469 | end
|
---|
| 1470 | set(handles.masklevel,'String',list_index)
|
---|
| 1471 | set(handles.masklevel,'Value',z)
|
---|
| 1472 |
|
---|
| 1473 | %-------------------------------------------------------------------
|
---|
| 1474 | % --- Executes on button press in view_xml.
|
---|
| 1475 | function view_xml_Callback(hObject, eventdata, handles)
|
---|
| 1476 | [FileName,RootPath,FileBase,FileIndices,FileExt]=read_file_boxes(handles);
|
---|
| 1477 | option=get(handles.view_xml,'String');
|
---|
| 1478 | if isequal(option,'view .xml')
|
---|
| 1479 | FileXml=[FileBase '.xml'];
|
---|
| 1480 | heditxml=editxml(FileXml);
|
---|
| 1481 | end
|
---|
| 1482 |
|
---|
| 1483 | %-------------------------------------------------------------------
|
---|
| 1484 | % --- Executes on button press in mask_test.
|
---|
| 1485 | function mask_test_Callback(hObject, eventdata, handles)
|
---|
| 1486 | %-------------------------------------------------------------------
|
---|
[139] | 1487 | %case of view mask selection
|
---|
[2] | 1488 | if isequal(get(handles.mask_test,'Value'),1)
|
---|
| 1489 | [FF,RootPath,FileBase]=read_file_boxes(handles);
|
---|
| 1490 | num_i1=stra2num(get(handles.i1,'String'));
|
---|
| 1491 | num_j1=stra2num(get(handles.j1,'String'));
|
---|
| 1492 | currentdir=pwd;
|
---|
| 1493 | cd(RootPath);
|
---|
| 1494 | maskfiles=dir('*_*mask_*.png');%look for a mask file
|
---|
| 1495 | cd(currentdir);%come back to the working directory
|
---|
| 1496 | mdetect=0;
|
---|
[139] | 1497 | if ~isempty(maskfiles)
|
---|
| 1498 | for ilist=1:length(maskfiles)
|
---|
| 1499 | maskname=maskfiles(ilist).name;% take the first mask file in the list
|
---|
| 1500 | [rr,ff,x1,x2,xa,xb,xext,Mask_NomType{ilist}]=name2display(maskname);
|
---|
| 1501 | if ~strcmp(Mask_NomType{ilist},Mask_NomType{1})
|
---|
| 1502 | msgbox_uvmat('ERROR',['inconsistent mask types ' Mask_NomType{1} Mask_NomType{ilist } ' coexist in the current image directory'])
|
---|
| 1503 | return
|
---|
| 1504 | end
|
---|
| 1505 | [Path2,Name,ext]=fileparts(maskname);
|
---|
| 1506 | Namedouble=double(Name);
|
---|
| 1507 | val=(48>Namedouble)|(Namedouble>57);% select the non-numerical characters
|
---|
| 1508 | ind_mask=findstr('mask',Name);
|
---|
| 1509 | i=ind_mask-1;
|
---|
| 1510 | while val(i)==0 && i>0
|
---|
| 1511 | i=i-1;
|
---|
| 1512 | end
|
---|
| 1513 | nbmask_str=str2num(Name(i+1:ind_mask-1));
|
---|
| 1514 | if ~isempty(nbmask_str)
|
---|
| 1515 | nbslice(ilist)=nbmask_str; % number of different masks (slices)
|
---|
| 1516 | end
|
---|
| 1517 | end
|
---|
| 1518 | if isequal(min(nbslice),max(nbslice))
|
---|
| 1519 | nbslice=nbslice(1);
|
---|
| 1520 | else
|
---|
| 1521 | msgbox_uvmat('ERROR','several inconsistent mask sets coexist in the current image directory')
|
---|
[2] | 1522 | return
|
---|
| 1523 | end
|
---|
[139] | 1524 | if ~isempty(nbslice) && Name(i)=='_'
|
---|
| 1525 | Mask.Base=[FileBase Name(i:ind_mask+3)];
|
---|
| 1526 | Mask.NbSlice=nbslice;
|
---|
| 1527 | num_i1=mod(num_i1-1,nbslice)+1;
|
---|
| 1528 | Mask.NomType=Mask_NomType{1};
|
---|
| 1529 | [maskname,mdetect]=name_generator(Mask.Base,num_i1,num_j1,'.png',Mask.NomType);%
|
---|
| 1530 | mdetect=exist(maskname,'file');
|
---|
| 1531 | if mdetect
|
---|
| 1532 | set(handles.nb_slice,'String',Name(i+1:ind_mask-1));
|
---|
| 1533 | set(handles.nb_slice,'BackgroundColor',[1 1 0])
|
---|
| 1534 | set(handles.mask_test,'UserData',Mask);
|
---|
| 1535 | set(handles.mask_test,'BackgroundColor',[1 1 0])
|
---|
| 1536 | if nbslice > 1
|
---|
| 1537 | set(handles.slices,'value',1)
|
---|
| 1538 | slices_Callback(hObject, eventdata, handles)
|
---|
| 1539 | end
|
---|
| 1540 | end
|
---|
[2] | 1541 | end
|
---|
[139] | 1542 | end
|
---|
| 1543 | errormsg=[];%default
|
---|
| 1544 | if mdetect==0
|
---|
| 1545 | [FileName, PathName, filterindex] = uigetfile( ...
|
---|
| 1546 | {'*.png', ' (*.png)';
|
---|
| 1547 | '*.png', '.png files '; ...
|
---|
| 1548 | '*.*', 'All Files (*.*)'}, ...
|
---|
| 1549 | 'Pick a mask file *.png',FileBase);
|
---|
| 1550 | maskname=fullfile(PathName,FileName);
|
---|
| 1551 | if ~exist(maskname,'file')
|
---|
| 1552 | errormsg='no file browsed';
|
---|
[2] | 1553 | end
|
---|
[139] | 1554 | [RootDir,RootFile,x1,x2,xa,xb,xext,Mask.NomType]=name2display(maskname);
|
---|
| 1555 | Mask.Base=fullfile(RootDir,RootFile);
|
---|
| 1556 | Mask.NbSlice=1;
|
---|
| 1557 | set(handles.mask_test,'UserData',Mask);
|
---|
| 1558 | set(handles.mask_test,'BackgroundColor',[1 1 0])
|
---|
[2] | 1559 | end
|
---|
[139] | 1560 | if isempty(errormsg)
|
---|
| 1561 | errormsg=update_mask(handles,num_i1,num_j1);
|
---|
[2] | 1562 | end
|
---|
[139] | 1563 | if ~isempty(errormsg)
|
---|
| 1564 | set(handles.mask_test,'Value',0)
|
---|
| 1565 | set(handles.mask_test,'BackgroundColor',[0.7 0.7 0.7])
|
---|
| 1566 | end
|
---|
| 1567 | else
|
---|
[2] | 1568 | MaskData=get(handles.mask_test,'UserData');
|
---|
| 1569 | if isfield(MaskData,'maskhandle') && ishandle(MaskData.maskhandle)
|
---|
| 1570 | delete(MaskData.maskhandle)
|
---|
| 1571 | end
|
---|
| 1572 | set(handles.mask_test,'UserData',[])
|
---|
[61] | 1573 | %huvmat=get(handles.mask_test,'parent');
|
---|
| 1574 | UvData=get(handles.uvmat,'UserData');
|
---|
[2] | 1575 | if isfield(UvData,'MaskName')
|
---|
| 1576 | UvData=rmfield(UvData,'MaskName');
|
---|
[61] | 1577 | set(handles.uvmat,'UserData',UvData)
|
---|
[2] | 1578 | end
|
---|
| 1579 | set(handles.mask_test,'BackgroundColor',[0.7 0.7 0.7])
|
---|
| 1580 | end
|
---|
| 1581 |
|
---|
| 1582 | %-------------------------------------------------------------------
|
---|
[139] | 1583 | function errormsg=update_mask(handles,num_i1,num_j1)
|
---|
[2] | 1584 | %-------------------------------------------------------------------
|
---|
[139] | 1585 | errormsg=[];%default
|
---|
[2] | 1586 | MaskData=get(handles.mask_test,'UserData');
|
---|
| 1587 | if isfield(MaskData,'maskhandle')&& ishandle(MaskData.maskhandle)
|
---|
| 1588 | uistack(MaskData.maskhandle,'top');
|
---|
| 1589 | end
|
---|
| 1590 | num_i1_mask=mod(num_i1-1,MaskData.NbSlice)+1;
|
---|
[139] | 1591 | MaskData.NomType
|
---|
| 1592 | MaskName=name_generator(MaskData.Base,num_i1_mask,num_j1,'.png',MaskData.NomType);
|
---|
[2] | 1593 | huvmat=get(handles.mask_test,'parent');
|
---|
| 1594 | UvData=get(huvmat,'UserData');
|
---|
| 1595 |
|
---|
| 1596 | %update mask image if the mask is new
|
---|
| 1597 | if ~ (isfield(UvData,'MaskName') && isequal(UvData.MaskName,MaskName))
|
---|
| 1598 | UvData.MaskName=MaskName; %update the recorded name on UvData
|
---|
| 1599 | set(huvmat,'UserData',UvData);
|
---|
[139] | 1600 | if ~exist(MaskName,'file')
|
---|
[2] | 1601 | if isfield(MaskData,'maskhandle')&& ishandle(MaskData.maskhandle)
|
---|
| 1602 | delete(MaskData.maskhandle)
|
---|
| 1603 | end
|
---|
| 1604 | else
|
---|
| 1605 | %read mask image
|
---|
| 1606 | Mask.AName='image';
|
---|
| 1607 | Mask.A=imread(MaskName);
|
---|
| 1608 | npxy=size(Mask.A);
|
---|
[139] | 1609 | test_error=0;
|
---|
| 1610 | if length(npxy)>2
|
---|
| 1611 | errormsg=[MaskName ' is not a grey scale image'];
|
---|
| 1612 | return
|
---|
| 1613 | elseif ~isa(Mask.A,'uint8')
|
---|
| 1614 | errormsg=[MaskName ' is not a 8 bit grey level image'];
|
---|
| 1615 | return
|
---|
| 1616 | end
|
---|
[2] | 1617 | Mask.AX=[0.5 npxy(2)-0.5];
|
---|
| 1618 | Mask.AY=[npxy(1)-0.5 0.5 ];
|
---|
[158] | 1619 | Mask.CoordUnit='pixel';
|
---|
[2] | 1620 | if isequal(get(handles.slices,'Value'),1)
|
---|
| 1621 | NbSlice=str2num(get(handles.nb_slice,'String'));
|
---|
| 1622 | num_i1=str2num(get(handles.i1,'String'));
|
---|
| 1623 | Mask.ZIndex=mod(num_i1-1,NbSlice)+1;
|
---|
| 1624 | end
|
---|
| 1625 | %px to phys or other transform on field
|
---|
[39] | 1626 | menu_transform=get(handles.transform_fct,'String');
|
---|
| 1627 | choice_value=get(handles.transform_fct,'Value');
|
---|
| 1628 | transform_name=menu_transform{choice_value};%name of the transform fct given by the menu 'transform_fct'
|
---|
| 1629 | transform_list=get(handles.transform_fct,'UserData');
|
---|
[38] | 1630 | transform=transform_list{choice_value};
|
---|
| 1631 | if ~isequal(transform_name,'') && ~isequal(transform_name,'px')
|
---|
[2] | 1632 | if isfield(UvData,'XmlData') && isfield(UvData.XmlData,'GeometryCalib')%use geometry calib recorded from the ImaDoc xml file as first priority
|
---|
| 1633 | Calib=UvData.XmlData.GeometryCalib;
|
---|
[38] | 1634 | Mask=transform(Mask,UvData.XmlData);
|
---|
[2] | 1635 | end
|
---|
| 1636 | end
|
---|
| 1637 | flagmask=Mask.A < 200;
|
---|
| 1638 |
|
---|
| 1639 | %make brown color image
|
---|
| 1640 | imflag(:,:,1)=0.9*flagmask;
|
---|
| 1641 | imflag(:,:,2)=0.7*flagmask;
|
---|
| 1642 | imflag(:,:,3)=zeros(size(flagmask));
|
---|
| 1643 |
|
---|
| 1644 | %update mask image
|
---|
| 1645 | hmask=[]; %default
|
---|
| 1646 | if isfield(MaskData,'maskhandle')&& ishandle(MaskData.maskhandle)
|
---|
| 1647 | hmask=MaskData.maskhandle;
|
---|
| 1648 | end
|
---|
| 1649 | if ~isempty(hmask)
|
---|
| 1650 | set(hmask,'CData',imflag)
|
---|
| 1651 | set(hmask,'AlphaData',flagmask*0.6)
|
---|
| 1652 | set(hmask,'XData',Mask.AX);
|
---|
| 1653 | set(hmask,'YData',Mask.AY);
|
---|
| 1654 | % uistack(hmask,'top')
|
---|
| 1655 | else
|
---|
| 1656 | axes(handles.axes3)
|
---|
| 1657 | hold on
|
---|
| 1658 | MaskData.maskhandle=image(Mask.AX,Mask.AY,imflag,'Tag','mask','HitTest','off','AlphaData',0.6*flagmask);
|
---|
| 1659 | % set(MaskData.maskhandle,'AlphaData',0.6*flagmask)
|
---|
| 1660 | set(handles.mask_test,'UserData',MaskData)
|
---|
| 1661 | end
|
---|
| 1662 | end
|
---|
| 1663 | end
|
---|
| 1664 |
|
---|
| 1665 |
|
---|
| 1666 | %-------------------------------------------------------------------
|
---|
| 1667 | function MenuExportFigure_Callback(hObject, eventdata, handles)
|
---|
| 1668 | %-------------------------------------------------------------------
|
---|
| 1669 | huvmat=get(handles.MenuExport,'parent');
|
---|
[128] | 1670 | %UvData=get(huvmat,'UserData');
|
---|
[2] | 1671 | hfig=figure;
|
---|
[128] | 1672 | copyobj(handles.axes3,hfig);
|
---|
[2] | 1673 | map=colormap(handles.axes3);
|
---|
| 1674 | colormap(map);%transmit the current colormap to the zoom fig
|
---|
| 1675 | colorbar
|
---|
| 1676 |
|
---|
| 1677 | %-------------------------------------------------------------------
|
---|
| 1678 | %-------------------------------------------------------------------
|
---|
| 1679 | % III - MAIN REFRESH FUNCTIONS : 'FRAME PLOT'
|
---|
| 1680 | %-------------------------------------------------------------------
|
---|
| 1681 |
|
---|
| 1682 | %-------------------------------------------------------------------
|
---|
[85] | 1683 | % --- Executes on button press in runplus: make one step forward and call
|
---|
| 1684 | % --- run0. The step forward is along the fields series 1 or 2 depending on
|
---|
| 1685 | % --- the scan_i and scan_j check box (exclusive each other)
|
---|
[2] | 1686 | function runplus_Callback(hObject, eventdata, handles)
|
---|
[85] | 1687 | %-------------------------------------------------------------------
|
---|
| 1688 | set(handles.runplus,'BackgroundColor',[1 1 0])%paint the command button in yellow
|
---|
| 1689 | drawnow
|
---|
[128] | 1690 | %TODO: introduce the option: increment ='*' to move to the next available view
|
---|
| 1691 | increment=str2double(get(handles.increment_scan,'String')); %get the field increment d
|
---|
| 1692 | if isnan(increment)
|
---|
| 1693 | set(handles.increment_scan,'String','1')%default value
|
---|
| 1694 | increment=1;
|
---|
| 1695 | end
|
---|
| 1696 | errormsg=runpm(hObject,eventdata,handles,increment);
|
---|
| 1697 | if ~isempty(errormsg)
|
---|
| 1698 | msgbox_uvmat('ERROR',errormsg);
|
---|
| 1699 | end
|
---|
| 1700 | set(handles.runplus,'BackgroundColor',[1 0 0])%paint the command button back to red
|
---|
[2] | 1701 |
|
---|
| 1702 | %-------------------------------------------------------------------
|
---|
[85] | 1703 | % --- Executes on button press in runmin: make one step backward and call
|
---|
| 1704 | % --- run0. The step backward is along the fields series 1 or 2 depending on
|
---|
| 1705 | % --- the scan_i and scan_j check box (exclusive each other)
|
---|
| 1706 | function runmin_Callback(hObject, eventdata, handles)
|
---|
[2] | 1707 | %-------------------------------------------------------------------
|
---|
[85] | 1708 | set(handles.runmin,'BackgroundColor',[1 1 0])%paint the command button in yellow
|
---|
| 1709 | drawnow
|
---|
[128] | 1710 | increment=-str2double(get(handles.increment_scan,'String')); %get the field increment d
|
---|
| 1711 | if isnan(increment)
|
---|
| 1712 | set(handles.increment_scan,'String','1')%default value
|
---|
| 1713 | increment=1;
|
---|
| 1714 | end
|
---|
| 1715 | errormsg=runpm(hObject,eventdata,handles,increment);
|
---|
| 1716 | if ~isempty(errormsg)
|
---|
| 1717 | msgbox_uvmat('ERROR',errormsg);
|
---|
| 1718 | end
|
---|
| 1719 | set(handles.runmin,'BackgroundColor',[1 0 0])%paint the command button back to red
|
---|
[2] | 1720 |
|
---|
| 1721 | %-------------------------------------------------------------------
|
---|
[81] | 1722 | % -- Executes on button press in Movie: make a series of +> steps
|
---|
| 1723 | function Movie_Callback(hObject, eventdata, handles)
|
---|
[2] | 1724 | %------------------------------------------------------------------
|
---|
[81] | 1725 | set(handles.Movie,'BackgroundColor',[1 1 0])%paint the command button in yellow
|
---|
[2] | 1726 | drawnow
|
---|
[128] | 1727 | increment=str2double(get(handles.increment_scan,'String')); %get the field increment d
|
---|
| 1728 | if isnan(increment)
|
---|
| 1729 | set(handles.increment_scan,'String','1')%default value
|
---|
| 1730 | increment=1;
|
---|
| 1731 | end
|
---|
[2] | 1732 | set(handles.STOP,'Visible','on')
|
---|
| 1733 | set(handles.speed,'Visible','on')
|
---|
| 1734 | set(handles.speed_txt,'Visible','on')
|
---|
[81] | 1735 | set(handles.Movie,'BusyAction','queue')
|
---|
[57] | 1736 | UvData=get(handles.uvmat,'UserData');
|
---|
[2] | 1737 |
|
---|
[122] | 1738 | while get(handles.speed,'Value')~=0 && isequal(get(handles.Movie,'BusyAction'),'queue') % enable STOP command
|
---|
[72] | 1739 | errormsg=runpm(hObject,eventdata,handles,increment);
|
---|
| 1740 | if ~isempty(errormsg)
|
---|
[128] | 1741 | set(handles.Movie,'BackgroundColor',[1 0 0])%paint the command buttonback to red
|
---|
[72] | 1742 | return
|
---|
| 1743 | end
|
---|
[2] | 1744 | pause(1.02-get(handles.speed,'Value'))% wait for next image
|
---|
| 1745 | end
|
---|
| 1746 | if isfield(UvData,'aviobj') && ~isempty( UvData.aviobj),
|
---|
| 1747 | UvData.aviobj=close(UvData.aviobj);
|
---|
[57] | 1748 | set(handles.uvmat,'UserData',UvData);
|
---|
[2] | 1749 | end
|
---|
[81] | 1750 | set(handles.Movie,'BackgroundColor',[1 0 0])%paint the command buttonback to red
|
---|
[2] | 1751 |
|
---|
| 1752 | %-------------------------------------------------------------------
|
---|
[81] | 1753 | % -- Executes on button press in Movie: make a series of <- steps
|
---|
| 1754 | function MovieBackward_Callback(hObject, eventdata, handles)
|
---|
| 1755 | %------------------------------------------------------------------
|
---|
| 1756 | set(handles.MovieBackward,'BackgroundColor',[1 1 0])%paint the command button in yellow
|
---|
| 1757 | drawnow
|
---|
[128] | 1758 | increment=-str2double(get(handles.increment_scan,'String')); %get the field increment d
|
---|
| 1759 | if isnan(increment)
|
---|
| 1760 | set(handles.increment_scan,'String','1')%default value
|
---|
| 1761 | increment=1;
|
---|
| 1762 | end
|
---|
[81] | 1763 | set(handles.STOP,'Visible','on')
|
---|
| 1764 | set(handles.speed,'Visible','on')
|
---|
| 1765 | set(handles.speed_txt,'Visible','on')
|
---|
| 1766 | set(handles.MovieBackward,'BusyAction','queue')
|
---|
| 1767 | UvData=get(handles.uvmat,'UserData');
|
---|
| 1768 |
|
---|
[128] | 1769 | while get(handles.speed,'Value')~=0 && isequal(get(handles.MovieBackward,'BusyAction'),'queue') % enable STOP command
|
---|
[81] | 1770 | errormsg=runpm(hObject,eventdata,handles,increment);
|
---|
| 1771 | if ~isempty(errormsg)
|
---|
[128] | 1772 | set(handles.MovieBackward,'BackgroundColor',[1 0 0])%paint the command buttonback to red
|
---|
[81] | 1773 | return
|
---|
| 1774 | end
|
---|
| 1775 | pause(1.02-get(handles.speed,'Value'))% wait for next image
|
---|
| 1776 | end
|
---|
| 1777 | if isfield(UvData,'aviobj') && ~isempty( UvData.aviobj),
|
---|
| 1778 | UvData.aviobj=close(UvData.aviobj);
|
---|
| 1779 | set(handles.uvmat,'UserData',UvData);
|
---|
| 1780 | end
|
---|
| 1781 | set(handles.MovieBackward,'BackgroundColor',[1 0 0])%paint the command buttonback to red
|
---|
| 1782 |
|
---|
| 1783 | %-------------------------------------------------------------------
|
---|
[2] | 1784 | function STOP_Callback(hObject, eventdata, handles)
|
---|
| 1785 | %-------------------------------------------------------------------
|
---|
[57] | 1786 | set(handles.movie_pair,'BusyAction','Cancel')
|
---|
| 1787 | set(handles.movie_pair,'value',0)
|
---|
[81] | 1788 | set(handles.Movie,'BusyAction','Cancel')
|
---|
| 1789 | set(handles.MovieBackward,'BusyAction','Cancel')
|
---|
[2] | 1790 | set(handles.MenuExportMovie,'BusyAction','Cancel')
|
---|
[85] | 1791 | set(handles.movie_pair,'BackgroundColor',[1 0 0])%paint the command buttonback to red
|
---|
| 1792 | set(handles.Movie,'BackgroundColor',[1 0 0])%paint the command buttonback to red
|
---|
| 1793 | set(handles.MovieBackward,'BackgroundColor',[1 0 0])%paint the command buttonback to red
|
---|
[2] | 1794 |
|
---|
| 1795 | %------------------------------------------------------------------
|
---|
[72] | 1796 | function errormsg=runpm(hObject,eventdata,handles,increment)
|
---|
[2] | 1797 | %------------------------------------------------------------------
|
---|
[120] | 1798 | %check for mï¿œovie pair status
|
---|
[57] | 1799 | movie_status=get(handles.movie_pair,'Value');
|
---|
| 1800 | if isequal(movie_status,1)
|
---|
[59] | 1801 | STOP_Callback(hObject, eventdata, handles)%interrupt movie pair if active
|
---|
[57] | 1802 | end
|
---|
[2] | 1803 | %read the data on the current input rootfile(s)
|
---|
| 1804 |
|
---|
| 1805 | [FileName,RootPath,filebase,FileIndices,FileExt,subdir]=read_file_boxes(handles);
|
---|
| 1806 | NomType=get(handles.FileIndex,'UserData');
|
---|
| 1807 |
|
---|
| 1808 | num1=stra2num(get(handles.i1,'String'));
|
---|
| 1809 | num2=stra2num(get(handles.i2,'String'));
|
---|
| 1810 | num_a=stra2num(get(handles.j1,'String'));
|
---|
| 1811 | num_b=stra2num(get(handles.j2,'String'));
|
---|
| 1812 |
|
---|
| 1813 | sub_value= get(handles.SubField,'Value');
|
---|
[59] | 1814 | if sub_value % a second input file has been entered
|
---|
[2] | 1815 | [FileName_1,RootPath_1,filebase_1,FileIndices_1,FileExt_1,SubDir_1]=read_file_boxes_1(handles);
|
---|
[59] | 1816 | [pp,ff,str1,str2,str_a,str_b]=name2display(FileIndices_1);
|
---|
| 1817 | num1_1=stra2num(str1);%current set of indices for the second field (may be set different than the main indices)
|
---|
| 1818 | num2_1=stra2num(str2);
|
---|
| 1819 | num_a_1=stra2num(str_a);
|
---|
| 1820 | num_b_1=stra2num(str_b);
|
---|
| 1821 | NomType_1=get(handles.FileIndex_1,'UserData');
|
---|
| 1822 | else
|
---|
| 1823 | filename_1=[];
|
---|
[2] | 1824 | end
|
---|
| 1825 |
|
---|
| 1826 | comp_input=get(handles.fix_pair,'Value');
|
---|
| 1827 |
|
---|
| 1828 | %case of scanning along the first direction (rootfile numbers)
|
---|
[59] | 1829 | if get(handles.scan_i,'Value')==1% case of scanning along index i
|
---|
[2] | 1830 | num1=num1+increment;
|
---|
| 1831 | num2=num2+increment;
|
---|
[128] | 1832 | [filename,num1,num_a,num2,num_b]=name_generator(filebase,num1,num_a,FileExt,NomType,comp_input,num2,num_b,subdir);
|
---|
[59] | 1833 | if sub_value% set the second field name and indices
|
---|
| 1834 | num1_1=num1_1+increment;
|
---|
| 1835 | num2_1=num2_1+increment;
|
---|
| 1836 | filename_1=name_generator(filebase_1,num1_1,num_a_1,FileExt_1,NomType_1,1,num2_1,num_b_1,SubDir_1);
|
---|
| 1837 | end
|
---|
| 1838 | else % case of scanning along index j (burst numbers)
|
---|
[2] | 1839 | num_a=num_a+increment;
|
---|
| 1840 | num_b=num_b+increment;
|
---|
[127] | 1841 | [filename,num1,num_a,num2,num_b]=name_generator(filebase,num1,num_a,FileExt,NomType,comp_input,num2,num_b,subdir);
|
---|
[59] | 1842 | if sub_value
|
---|
| 1843 | num_a_1=num_a_1+increment;
|
---|
| 1844 | num_b_1=num_b_1+increment;
|
---|
| 1845 | filename_1=name_generator(filebase_1,num1_1,num_a_1,FileExt_1,NomType_1,1,num2_1,num_b_1,SubDir_1);
|
---|
[127] | 1846 | end
|
---|
[2] | 1847 | end
|
---|
| 1848 |
|
---|
[59] | 1849 | % refresh plots
|
---|
| 1850 | errormsg=refresh_field(handles,filename,filename_1,num1,num2,num_a,num_b);
|
---|
| 1851 | if isempty(errormsg) %update the index counters
|
---|
| 1852 | set(handles.i1,'String',num2stra(num1,NomType,1));
|
---|
| 1853 | if isequal(num2,num1)
|
---|
| 1854 | set(handles.i2,'String','');
|
---|
| 1855 | else
|
---|
| 1856 | set(handles.i2,'String',num2stra(num2,NomType,1));
|
---|
| 1857 | end
|
---|
| 1858 | set(handles.j1,'String',num2stra(num_a,NomType,2));
|
---|
| 1859 | if isequal(num_b,num_a)
|
---|
| 1860 | set(handles.j2,'String','');
|
---|
| 1861 | else
|
---|
| 1862 | set(handles.j2,'String',num2stra(num_b,NomType,2));
|
---|
| 1863 | end
|
---|
| 1864 | [indices]=name_generator('',num1,num_a,'',NomType,1,num2,num_b,'');
|
---|
| 1865 | set(handles.FileIndex,'String',indices);
|
---|
[81] | 1866 | if ~isempty(filename_1)
|
---|
[59] | 1867 | indices_1=name_generator('',num1_1,num_a_1,'',NomType_1,1,num2_1,num_b_1,'');
|
---|
| 1868 | set(handles.FileIndex_1,'String',indices_1);
|
---|
| 1869 | end
|
---|
| 1870 | if isequal(movie_status,1)
|
---|
| 1871 | set(handles.movie_pair,'Value',1)
|
---|
| 1872 | movie_pair_Callback(hObject, eventdata, handles); %reactivate moviepair if it was activated
|
---|
| 1873 | end
|
---|
[57] | 1874 | end
|
---|
[2] | 1875 |
|
---|
| 1876 |
|
---|
| 1877 | %-------------------------------------------------------
|
---|
[57] | 1878 | % --- Executes on button press in movie_pair: create an alternating movie with two view
|
---|
[2] | 1879 | %-------------------------------------------------------
|
---|
| 1880 | function movie_pair_Callback(hObject, eventdata, handles)
|
---|
[57] | 1881 | status=get(handles.movie_pair,'value');
|
---|
| 1882 | if isequal(status,0)
|
---|
[59] | 1883 | set(handles.movie_pair,'BusyAction','Cancel')%stop movie pair if button is 'off'
|
---|
| 1884 | set(handles.i2,'String','')
|
---|
| 1885 | set(handles.j2,'String','')
|
---|
[57] | 1886 | return
|
---|
| 1887 | else
|
---|
| 1888 | set(handles.movie_pair,'BusyAction','queue')
|
---|
| 1889 | end
|
---|
[2] | 1890 | %initialisation
|
---|
| 1891 | set(handles.movie_pair,'BackgroundColor',[1 1 0])%paint the command button in yellow
|
---|
| 1892 | drawnow
|
---|
| 1893 | list_fields=get(handles.Fields,'String');% list menu fields
|
---|
| 1894 | index_fields=get(handles.Fields,'Value');% selected string index
|
---|
| 1895 | FieldName=list_fields{index_fields}; % selected field
|
---|
[65] | 1896 | UvData=get(handles.uvmat,'UserData');
|
---|
[2] | 1897 | if isequal(FieldName,'image')
|
---|
[65] | 1898 | test_1=0;
|
---|
| 1899 | [ff,rr,filebase,xx,Ext,SubDir]=read_file_boxes(handles);
|
---|
| 1900 | NomType=get(handles.FileIndex,'UserData');
|
---|
[2] | 1901 | else
|
---|
[65] | 1902 | list_fields=get(handles.Fields_1,'String');% list menu fields
|
---|
| 1903 | index_fields=get(handles.Fields_1,'Value');% selected string index
|
---|
| 1904 | FieldName=list_fields{index_fields}; % selected field
|
---|
| 1905 | if isequal(FieldName,'image')
|
---|
| 1906 | test_1=1;
|
---|
| 1907 | [ff,rr,filebase,xx,Ext,SubDir]=read_file_boxes_1(handles);
|
---|
| 1908 | NomType=get(handles.FileIndex_1,'UserData');
|
---|
| 1909 | else
|
---|
| 1910 | msgbox_uvmat('ERROR','an image or movie must be first introduced as input')
|
---|
[85] | 1911 | set(handles.movie_pair,'BackgroundColor',[1 0 0])%paint the command button in red
|
---|
[65] | 1912 | return
|
---|
| 1913 | end
|
---|
[2] | 1914 | end
|
---|
[65] | 1915 |
|
---|
[89] | 1916 | num_i1=str2double(get(handles.i1,'String'));
|
---|
[57] | 1917 | num_j1=stra2num(get(handles.j1,'String'));
|
---|
[89] | 1918 | num_i2=str2double(get(handles.i2,'String'));
|
---|
[57] | 1919 | num_j2=stra2num(get(handles.j2,'String'));
|
---|
[89] | 1920 | if isnan(num_j2)
|
---|
[57] | 1921 | if isempty(num_i2)
|
---|
| 1922 | msgbox_uvmat('ERROR', 'a second image index i2 or j2 is needed to show the pair as a movie')
|
---|
[85] | 1923 | set(handles.movie_pair,'BackgroundColor',[1 0 0])%paint the command button in red
|
---|
[2] | 1924 | return
|
---|
[57] | 1925 | else
|
---|
| 1926 | num_j2=num_j1;%repeat the index i1 by default
|
---|
[2] | 1927 | end
|
---|
[57] | 1928 | end
|
---|
[89] | 1929 | if isnan(num_i2)
|
---|
[57] | 1930 | num_i2=num_i1;%repeat the index i1 by default
|
---|
| 1931 | end
|
---|
| 1932 | imaname_1=name_generator(filebase,num_i2,num_j2,Ext,NomType);
|
---|
| 1933 | if ~exist(imaname_1,'file')
|
---|
| 1934 | msgbox_uvmat('ERROR',['second input open (-) ' imaname_1 ' not found']);
|
---|
[85] | 1935 | set(handles.movie_pair,'BackgroundColor',[1 0 0])%paint the command button in red
|
---|
[57] | 1936 | return
|
---|
| 1937 | end
|
---|
[2] | 1938 |
|
---|
| 1939 | %read the second image
|
---|
| 1940 | Field.AName='image';
|
---|
[65] | 1941 | if test_1
|
---|
| 1942 | Field_a=UvData.Field_1;
|
---|
| 1943 | else
|
---|
| 1944 | Field_a=UvData.Field;
|
---|
| 1945 | end
|
---|
| 1946 | Field_b.AX=Field_a.AX;
|
---|
| 1947 | Field_b.AY=Field_a.AY;
|
---|
[57] | 1948 | % z index
|
---|
| 1949 | nbslice=str2double(get(handles.nb_slice,'String'));
|
---|
| 1950 | if ~isempty(nbslice)
|
---|
[65] | 1951 | Field_b.ZIndex=mod(num_i2-1,nbslice)+1;
|
---|
[57] | 1952 | end
|
---|
[158] | 1953 | Field_b.CoordUnit='pixel';
|
---|
[45] | 1954 | %determine the input file type
|
---|
[65] | 1955 | if (test_1 && isfield(UvData,'MovieObject_1'))||(~test_1 && isfield(UvData,'MovieObject'))
|
---|
[45] | 1956 | FileType='movie';
|
---|
| 1957 | elseif isequal(lower(Ext),'.avi')
|
---|
| 1958 | FileType='avi';
|
---|
| 1959 | elseif isequal(lower(Ext),'.vol')
|
---|
| 1960 | FileType='vol';
|
---|
| 1961 | else
|
---|
[122] | 1962 | form=imformats(Ext(2:end));
|
---|
[45] | 1963 | if ~isempty(form)% if the extension corresponds to an image format recognized by Matlab
|
---|
| 1964 | if isequal(NomType,'*');
|
---|
| 1965 | FileType='multimage';
|
---|
| 1966 | else
|
---|
| 1967 | FileType='image';
|
---|
| 1968 | end
|
---|
| 1969 | end
|
---|
| 1970 | end
|
---|
| 1971 | switch FileType
|
---|
| 1972 | case 'movie'
|
---|
[65] | 1973 | if test_1
|
---|
| 1974 | Field_b.A=read(UvData.MovieObject_1,num_i2);
|
---|
| 1975 | else
|
---|
| 1976 | Field_b.A=read(UvData.MovieObject,num_i2);
|
---|
| 1977 | end
|
---|
[45] | 1978 | case 'avi'
|
---|
| 1979 | mov=aviread(imaname_1,num_i2);
|
---|
[65] | 1980 | Field_b.A=frame2im(mov(1));
|
---|
[45] | 1981 | case 'vol'
|
---|
[65] | 1982 | Field_b.A=imread(imaname_1);
|
---|
[45] | 1983 | case 'multimage'
|
---|
[65] | 1984 | Field_b.A=imread(imaname_1,num_i2);
|
---|
[45] | 1985 | case 'image'
|
---|
[65] | 1986 | Field_b.A=imread(imaname_1);
|
---|
[45] | 1987 | end
|
---|
[60] | 1988 | if get(handles.slices,'Value')
|
---|
| 1989 | Field.ZIndex=str2double(get(handles.z_index,'String'));
|
---|
| 1990 | end
|
---|
[2] | 1991 |
|
---|
| 1992 | %px to phys or other transform on field
|
---|
[39] | 1993 | menu_transform=get(handles.transform_fct,'String');
|
---|
| 1994 | choice_value=get(handles.transform_fct,'Value');
|
---|
| 1995 | transform_name=menu_transform{choice_value};%name of the transform fct given by the menu 'transform_fct'
|
---|
| 1996 | transform_list=get(handles.transform_fct,'UserData');
|
---|
[38] | 1997 | transform=transform_list{choice_value};
|
---|
| 1998 | if ~isequal(transform_name,'') && ~isequal(transform_name,'px')
|
---|
[65] | 1999 | 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] | 2000 | Field_a=transform(Field_a,UvData.XmlData_1);%the first field has been stored without transform
|
---|
[65] | 2001 | Field_b=transform(Field_b,UvData.XmlData_1);
|
---|
| 2002 | elseif ~test_1 && isfield(UvData,'XmlData') && isfield(UvData.XmlData,'GeometryCalib')%use geometry calib
|
---|
| 2003 | Field_b=transform(Field_b,UvData.XmlData);
|
---|
[2] | 2004 | end
|
---|
| 2005 | end
|
---|
| 2006 |
|
---|
| 2007 | % make movie until movie speed is set to 0 or STOP is activated
|
---|
| 2008 | hima=findobj(handles.axes3,'Tag','ima');% %handles.axes3 =main plotting window (A GENERALISER)
|
---|
| 2009 | set(handles.STOP,'Visible','on')
|
---|
| 2010 | set(handles.speed,'Visible','on')
|
---|
| 2011 | set(handles.speed_txt,'Visible','on')
|
---|
[57] | 2012 | while get(handles.speed,'Value')~=0 && isequal(get(handles.movie_pair,'BusyAction'),'queue')%isequal(get(handles.run0,'BusyAction'),'queue'); % enable STOP command
|
---|
[2] | 2013 | % read and plot the series of images in non erase mode
|
---|
[65] | 2014 | set(hima,'CData',Field_b.A);
|
---|
[2] | 2015 | pause(1.02-get(handles.speed,'Value'));% wait for next image
|
---|
[65] | 2016 | set(hima,'CData',Field_a.A);
|
---|
[2] | 2017 | pause(1.02-get(handles.speed,'Value'));% wait for next image
|
---|
| 2018 | end
|
---|
| 2019 | set(handles.movie_pair,'BackgroundColor',[1 0 0])%paint the command button in red
|
---|
| 2020 |
|
---|
[59] | 2021 | %------------------------------------------------------------------------
|
---|
[2] | 2022 | % --- Executes on button press in run0.
|
---|
| 2023 | function run0_Callback(hObject, eventdata, handles)
|
---|
[59] | 2024 | %------------------------------------------------------------------------
|
---|
[85] | 2025 | set(handles.run0,'BackgroundColor',[1 1 0])%paint the command button in yellow
|
---|
| 2026 | drawnow
|
---|
[59] | 2027 | filename=read_file_boxes(handles);
|
---|
[2] | 2028 |
|
---|
[59] | 2029 | filename_1=[];%default
|
---|
| 2030 | if get(handles.SubField,'Value')
|
---|
| 2031 | filename_1=read_file_boxes_1(handles);
|
---|
| 2032 | end
|
---|
| 2033 | num_i1=stra2num(get(handles.i1,'String'));
|
---|
| 2034 | num_i2=stra2num(get(handles.i2,'String'));
|
---|
| 2035 | num_j1=stra2num(get(handles.j1,'String'));
|
---|
| 2036 | num_j2=stra2num(get(handles.j2,'String'));
|
---|
| 2037 | errormsg=refresh_field(handles,filename,filename_1,num_i1,num_i2,num_j1,num_j2);
|
---|
| 2038 | if ~isempty(errormsg)
|
---|
| 2039 | msgbox_uvmat('ERROR',errormsg);
|
---|
[139] | 2040 | else
|
---|
| 2041 | set(handles.i1,'BackgroundColor',[1 1 1])
|
---|
| 2042 | set(handles.i2,'BackgroundColor',[1 1 1])
|
---|
| 2043 | set(handles.j1,'BackgroundColor',[1 1 1])
|
---|
| 2044 | set(handles.j2,'BackgroundColor',[1 1 1])
|
---|
| 2045 | set(handles.FileIndex,'BackgroundColor',[1 1 1])
|
---|
| 2046 | set(handles.FileIndex_1,'BackgroundColor',[1 1 1])
|
---|
[59] | 2047 | end
|
---|
[85] | 2048 | set(handles.run0,'BackgroundColor',[1 0 0])
|
---|
[128] | 2049 |
|
---|
[139] | 2050 |
|
---|
[59] | 2051 | %------------------------------------------------------------------------
|
---|
| 2052 | % --- read the input files and refresh all the plots, including projection.
|
---|
| 2053 | % OUTPUT:
|
---|
| 2054 | % errormsg: error message char string =[] by default
|
---|
| 2055 | % INPUT:
|
---|
| 2056 | % filename: first input file (=[] in the absence of input file)
|
---|
| 2057 | % filename_1: second input file (=[] in the asbsenc of secodn input file)
|
---|
| 2058 | % num_i1,num_i2,num_j1,num_j2; frame indices
|
---|
| 2059 | % Field: structure describing an optional input field (then replace the input file)
|
---|
| 2060 | function errormsg=refresh_field(handles,filename,filename_1,num_i1,num_i2,num_j1,num_j2,Field)
|
---|
| 2061 | %------------------------------------------------------------------------
|
---|
[81] | 2062 |
|
---|
[2] | 2063 | %initialisation
|
---|
[128] | 2064 | % errormsg=[]; % default error message
|
---|
[2] | 2065 | abstime=[];
|
---|
| 2066 | abstime_1=[];
|
---|
| 2067 | dt=[];
|
---|
[59] | 2068 | if ~exist('Field','var')
|
---|
| 2069 | Field={};
|
---|
| 2070 | end
|
---|
[45] | 2071 | UvData=get(handles.uvmat,'UserData');
|
---|
[75] | 2072 |
|
---|
[159] | 2073 |
|
---|
[2] | 2074 | if ishandle(handles.UVMAT_title) %remove title panel on uvmat
|
---|
| 2075 | delete(handles.UVMAT_title)
|
---|
| 2076 | end
|
---|
| 2077 |
|
---|
[128] | 2078 | %% determine the main input file information for action
|
---|
[45] | 2079 | FileType=[];%default
|
---|
[59] | 2080 | if ~isempty(filename)
|
---|
[2] | 2081 | if ~exist(filename,'file')
|
---|
[59] | 2082 | errormsg=['input file ' filename ' does not exist'];
|
---|
[2] | 2083 | return
|
---|
| 2084 | end
|
---|
[59] | 2085 | Ext=get(handles.FileExt,'String');
|
---|
[2] | 2086 | NomType=get(handles.FileIndex,'UserData');
|
---|
| 2087 | %update the z position index
|
---|
[60] | 2088 | nbslice_str=get(handles.nb_slice,'String');
|
---|
[128] | 2089 | % z_index=1;%default
|
---|
[60] | 2090 | if isequal(nbslice_str,'volume')
|
---|
| 2091 | z_index=num_j1;
|
---|
| 2092 | set(handles.z_index,'String',num2str(z_index))
|
---|
| 2093 | else
|
---|
| 2094 | nbslice=str2num(nbslice_str);
|
---|
[2] | 2095 | z_index=mod(num_i1-1,nbslice)+1;
|
---|
| 2096 | set(handles.z_index,'String',num2str(z_index))
|
---|
| 2097 | end
|
---|
[60] | 2098 | % refresh menu for save_mask if relevant
|
---|
| 2099 | masknumber=get(handles.masklevel,'String');
|
---|
| 2100 | if length(masknumber)>=z_index
|
---|
| 2101 | set(handles.masklevel,'Value',z_index)
|
---|
| 2102 | end
|
---|
| 2103 |
|
---|
[45] | 2104 | % determine the input file type
|
---|
| 2105 | if isequal(Ext,'.nc')||isequal(Ext,'.cdf')
|
---|
| 2106 | FileType='netcdf';
|
---|
| 2107 | elseif isfield(UvData,'MovieObject')
|
---|
| 2108 | FileType='movie';
|
---|
| 2109 | FieldName='image';
|
---|
| 2110 | elseif isequal(lower(Ext),'.avi')
|
---|
| 2111 | FileType='avi';
|
---|
| 2112 | FieldName='image';
|
---|
| 2113 | elseif isequal(lower(Ext),'.vol')
|
---|
| 2114 | FileType='vol';
|
---|
| 2115 | FieldName='image';
|
---|
[2] | 2116 | else
|
---|
[122] | 2117 | form=imformats(Ext(2:end));
|
---|
[2] | 2118 | if ~isempty(form)% if the extension corresponds to an image format recognized by Matlab
|
---|
[45] | 2119 | if isequal(NomType,'*');
|
---|
| 2120 | FileType='multimage';
|
---|
| 2121 | else
|
---|
| 2122 | FileType='image';
|
---|
| 2123 | end
|
---|
[2] | 2124 | FieldName='image';
|
---|
| 2125 | end
|
---|
| 2126 | end
|
---|
| 2127 | else
|
---|
[45] | 2128 | FileType='netcdf';
|
---|
[2] | 2129 | FieldName='get_field...';
|
---|
| 2130 | end
|
---|
| 2131 | VelType=[];%default
|
---|
[45] | 2132 | if isequal(FileType,'netcdf')
|
---|
[2] | 2133 | list_fields=get(handles.Fields,'String');% list menu fields
|
---|
| 2134 | index_fields=get(handles.Fields,'Value');% selected string index
|
---|
| 2135 | FieldName= list_fields{index_fields}; % selected field
|
---|
[59] | 2136 | if ~isequal(FieldName,'get_field...')% read the field names on the interface get_field...
|
---|
[2] | 2137 | VelType=setfield(handles);
|
---|
| 2138 | end
|
---|
| 2139 | end
|
---|
[159] | 2140 |
|
---|
[128] | 2141 | %% choose a second field if Subfield option is 'on'
|
---|
[2] | 2142 | FieldName_1=[];
|
---|
| 2143 | scal_color=[];
|
---|
| 2144 | VelType_1=setfield_1(handles);
|
---|
[128] | 2145 | % sub_value=get(handles.SubField,'Value');
|
---|
[45] | 2146 | FileType_1='none';%default
|
---|
[59] | 2147 | if ~isempty(filename_1)
|
---|
| 2148 | % test for a constant second field (comparison with a fixed field)
|
---|
[2] | 2149 | NomType_1=get(handles.FileIndex_1,'UserData');
|
---|
[71] | 2150 | Ext_1=get(handles.FileExt_1,'String');
|
---|
[45] | 2151 | % determine the input file type
|
---|
| 2152 | if isequal(Ext_1,'.nc')||isequal(Ext_1,'.cdf')
|
---|
| 2153 | FileType_1='netcdf';
|
---|
| 2154 | elseif isfield(UvData,'MovieObject_1')
|
---|
| 2155 | FileType_1='movie';
|
---|
| 2156 | FieldName_1='image';
|
---|
| 2157 | elseif isequal(lower(Ext_1),'.avi')
|
---|
| 2158 | FileType='avi';
|
---|
| 2159 | FieldName_1='image';
|
---|
| 2160 | elseif isequal(lower(Ext_1),'.vol')
|
---|
| 2161 | FileType_1='vol';
|
---|
| 2162 | FieldName_1='image';
|
---|
[150] | 2163 | elseif length(Ext_1)>1
|
---|
[122] | 2164 | form=imformats(Ext_1(2:end));
|
---|
[45] | 2165 | if ~isempty(form)% if the extension corresponds to an image format recognized by Matlab
|
---|
| 2166 | if isequal(NomType_1,'*');
|
---|
| 2167 | FileType_1='multimage';
|
---|
| 2168 | else
|
---|
| 2169 | FileType_1='image';
|
---|
| 2170 | end
|
---|
| 2171 | FieldName_1='image';
|
---|
| 2172 | end
|
---|
| 2173 | end
|
---|
| 2174 | if ~isequal(FieldName_1,'image')
|
---|
| 2175 | list_fields=get(handles.Fields_1,'String');% list menu fields
|
---|
| 2176 | index_fields=get(handles.Fields_1,'Value');% selected string index
|
---|
| 2177 | FieldName_1= list_fields{index_fields}; % selected field
|
---|
| 2178 | if isequal(VelType_1,'*')% free veltype choice
|
---|
[2] | 2179 | VelType_1=[];
|
---|
[45] | 2180 | elseif isequal(VelType_1,'"')% veltype the same as for the first field
|
---|
| 2181 | if isempty(VelType)
|
---|
| 2182 | VelType_1=[];
|
---|
| 2183 | else
|
---|
| 2184 | VelType_1=VelType;
|
---|
| 2185 | end
|
---|
[2] | 2186 | end
|
---|
| 2187 | end
|
---|
[59] | 2188 | test_keepdata_1=0;% test for keeping the previous stored data if the input files are unchanged
|
---|
| 2189 | if ~isequal(NomType_1,'*')%in case of a series of files (not avi movie)
|
---|
[45] | 2190 | if isfield(UvData,'filename_1')&& isfield(UvData,'VelType_1') && isfield(UvData,'FieldName_1')
|
---|
| 2191 | test_keepdata_1= isequal(filename_1,UvData.filename_1)&&...
|
---|
| 2192 | isequal(VelType_1,UvData.filename_1) && isequal(FieldName_1,UvData.FieldName_1);
|
---|
[2] | 2193 | end
|
---|
| 2194 | end
|
---|
[59] | 2195 | if test_keepdata_1
|
---|
| 2196 | Field{2}=UvData.Field_1;
|
---|
| 2197 | elseif ~exist(filename_1,'file')
|
---|
| 2198 | errormsg=['second file ' filename_1 ' does not exist'];
|
---|
| 2199 | return
|
---|
| 2200 | end
|
---|
[2] | 2201 | end
|
---|
| 2202 |
|
---|
[128] | 2203 | %% read the input field(s)
|
---|
[2] | 2204 | %read images
|
---|
[45] | 2205 | if ~isempty(filename) && isequal(FieldName,'image')
|
---|
[174] | 2206 | Npz=1;%default
|
---|
[45] | 2207 | switch FileType
|
---|
| 2208 | case 'movie'
|
---|
[84] | 2209 | try
|
---|
| 2210 | A=read(UvData.MovieObject,num_i1);
|
---|
| 2211 | catch
|
---|
| 2212 | errormsg=lasterr;
|
---|
| 2213 | return
|
---|
| 2214 | end
|
---|
[45] | 2215 | case 'avi'
|
---|
[84] | 2216 | try
|
---|
| 2217 | mov=aviread(filename,num_i1);
|
---|
| 2218 | catch
|
---|
| 2219 | errormsg=lasterr;
|
---|
| 2220 | return
|
---|
| 2221 | end
|
---|
[45] | 2222 | A=frame2im(mov(1));
|
---|
| 2223 | case 'vol'
|
---|
| 2224 | A=imread(filename);
|
---|
[174] | 2225 | if isfield(UvData.XmlData,'Npy')
|
---|
| 2226 | Npz=size(A,1)/UvData.XmlData.Npy;
|
---|
| 2227 | A=reshape(A,Npz,UvData.XmlData.Npy,UvData.XmlData.Npx);
|
---|
| 2228 | end
|
---|
[45] | 2229 | case 'multimage'
|
---|
| 2230 | A=imread(filename,num_i1);
|
---|
| 2231 | case 'image'
|
---|
| 2232 | A=imread(filename);
|
---|
[2] | 2233 | end
|
---|
| 2234 | npxy=size(A);
|
---|
| 2235 | set(handles.npx,'String',num2str(npxy(2)));% display image size on the interface
|
---|
| 2236 | set(handles.npy,'String',num2str(npxy(1)));
|
---|
| 2237 | Rangx=[0.5 npxy(2)-0.5]; % coordinates of the first and last pixel centers
|
---|
| 2238 | Rangy=[npxy(1)-0.5 0.5]; %
|
---|
| 2239 | Field{1}.AName='image';
|
---|
| 2240 | Field{1}.ListVarName={'AY','AX','A'}; %
|
---|
[174] | 2241 | if ndims(A)==3
|
---|
| 2242 | if Npz==1;%color
|
---|
| 2243 | Field{1}.VarDimName={'AY','AX',{'AY','AX','rgb'}}; %
|
---|
| 2244 | Field{1}.AY=[npxy(1)-0.5 0.5];
|
---|
| 2245 | Field{1}.AX=[0.5 npxy(2)-0.5]; % coordinates of the first and last pixel centers
|
---|
| 2246 | else
|
---|
| 2247 | Field{1}.ListVarName=['AZ' Field{1}.ListVarName];
|
---|
| 2248 | Field{1}.VarDimName={'AZ','AY','AX',{'AZ','AY','AX'}};
|
---|
| 2249 | Field{1}.AZ=[0.5 npxy(1)-0.5];
|
---|
| 2250 | Field{1}.AY=[npxy(2)-0.5 0.5];
|
---|
| 2251 | Field{1}.AX=[0.5 npxy(3)-0.5]; % coordinates of the first and last pixel centers
|
---|
| 2252 | end
|
---|
[2] | 2253 | else
|
---|
| 2254 | Field{1}.VarDimName={'AY','AX',{'AY','AX'}}; %
|
---|
[174] | 2255 | Field{1}.AY=[npxy(1)-0.5 0.5];
|
---|
| 2256 | Field{1}.AX=[0.5 npxy(2)-0.5]; % coordinates of the first and last pixel centers
|
---|
[2] | 2257 | end
|
---|
| 2258 | Field{1}.A=A;
|
---|
| 2259 | Field{1}.CoordUnit='pixel'; %used for mouse_motion
|
---|
| 2260 | end
|
---|
[56] | 2261 |
|
---|
| 2262 | %read a second image
|
---|
[59] | 2263 | if ~isempty(filename_1) && ~test_keepdata_1 && isequal(FieldName_1,'image')
|
---|
[45] | 2264 | switch FileType_1
|
---|
| 2265 | case 'movie'
|
---|
| 2266 | A=read(UvData.MovieObject_1,num_i1);
|
---|
| 2267 | case 'avi'
|
---|
[65] | 2268 | mov=aviread(filename_1,num_i1);
|
---|
[45] | 2269 | A=frame2im(mov(1));
|
---|
| 2270 | case 'vol'
|
---|
[65] | 2271 | A=imread(filename_1);
|
---|
[45] | 2272 | case 'multimage'
|
---|
[65] | 2273 | A=imread(filename_1,num_i1);
|
---|
[45] | 2274 | case 'image'
|
---|
[65] | 2275 | A=imread(filename_1);
|
---|
| 2276 | case 'netcdf'
|
---|
| 2277 | otherwise
|
---|
| 2278 | errormsg=['unknown input file type ' filename_1];
|
---|
[45] | 2279 | end
|
---|
[2] | 2280 | npxy=size(A);
|
---|
| 2281 | set(handles.npx,'String',num2str(npxy(2)));% display image size on the interface
|
---|
| 2282 | set(handles.npy,'String',num2str(npxy(1)));
|
---|
| 2283 | Rangx=[0.5 npxy(2)-0.5]; % coordinates of the first and last pixel centers
|
---|
| 2284 | Rangy=[npxy(1)-0.5 0.5]; %
|
---|
| 2285 | Field{2}.AName='image';
|
---|
| 2286 | Field{2}.ListVarName={'AY','AX','A'}; %
|
---|
| 2287 | if size(A,3)==3;%color
|
---|
| 2288 | Field{2}.VarDimName={'AY','AX',{'AY','AX','rgb'}}; %
|
---|
| 2289 | else
|
---|
| 2290 | Field{2}.VarDimName={'AY','AX',{'AY','AX'}}; %
|
---|
| 2291 | end
|
---|
| 2292 | Field{2}.AY=Rangy;
|
---|
| 2293 | Field{2}.AX=Rangx;
|
---|
| 2294 | Field{2}.A=A;
|
---|
| 2295 | Field{2}.CoordType='px'; %used for mouse_motion
|
---|
| 2296 | Field{2}.CoordUnit='px'; %used for move_mou
|
---|
| 2297 | end
|
---|
| 2298 |
|
---|
| 2299 | %read ncfile(s)
|
---|
| 2300 | CivStage_1=0;%default
|
---|
| 2301 | VelType_out_1=[];
|
---|
| 2302 | InputField={FieldName};
|
---|
| 2303 | InputField_1={FieldName_1};
|
---|
[59] | 2304 | if (~isempty(filename)&& isequal(FileType,'netcdf')) || (~isempty(filename_1)&& isequal(FileType_1,'netcdf')) ;
|
---|
[2] | 2305 | %read the velocity field(s) from netcdf rootfile(s)
|
---|
| 2306 | list_code=get(handles.col_vec,'String');% list menu fields
|
---|
| 2307 | index_code=get(handles.col_vec,'Value');% selected string index
|
---|
| 2308 | scal_color= list_code{index_code(1)}; % selected field
|
---|
| 2309 | if isequal(FieldName,'velocity')&& ~isequal(scal_color,'black') && ~isequal(scal_color,'white')
|
---|
| 2310 | InputField=[InputField scal_color];
|
---|
| 2311 | end
|
---|
| 2312 | if isequal(FieldName_1,'velocity') && ~isequal(scal_color,'black') && ~isequal(scal_color,'white')
|
---|
| 2313 | InputField_1=[InputField_1 scal_color];
|
---|
| 2314 | end
|
---|
[45] | 2315 | if isequal(FileType,'netcdf') %read the first nc field
|
---|
[2] | 2316 | if isequal(FieldName,'get_field...')% read the field names on the interface get_field.
|
---|
[144] | 2317 | hget_field=findobj(allchild(0),'Name','get_field');%find the get_field... GUI
|
---|
[2] | 2318 | if isempty(hget_field)
|
---|
[89] | 2319 | hget_field= get_field(filename);%open the get_field GUI
|
---|
[144] | 2320 | % set(hget_field,'name','get_field')
|
---|
[128] | 2321 | elseif UvData.NewSeries% refresh the fet_field GUI for a new series
|
---|
[89] | 2322 | delete(hget_field)
|
---|
| 2323 | hget_field= get_field(filename);%open the get_field GUI
|
---|
[144] | 2324 | set(hget_field,'name','get_field')%rename get_field GUI for the 'slave' mode
|
---|
[2] | 2325 | end
|
---|
| 2326 | hhget_field=guidata(hget_field);
|
---|
[144] | 2327 | set(hhget_field.list_fig,'Value',1)
|
---|
| 2328 | set(hhget_field.list_fig,'String',{'uvmat'})
|
---|
[89] | 2329 | funct_list=get(hhget_field.ACTION,'UserData');
|
---|
| 2330 | funct_index=get(hhget_field.ACTION,'Value');
|
---|
[128] | 2331 | funct=funct_list{funct_index};%select the current action in get_field, e;g. PLOT
|
---|
| 2332 | Field{1}=funct(hget_field); %%activate the current action selected in get_field, e;g.read the names of the variables to plot
|
---|
[2] | 2333 | CivStage=0;
|
---|
[89] | 2334 | VelType_out=[];
|
---|
[2] | 2335 | else
|
---|
| 2336 | [Field{1},VelType_out]=read_civxdata(filename,InputField,VelType);
|
---|
| 2337 | if isfield(Field{1},'Txt')
|
---|
[59] | 2338 | errormsg=Field{1}.Txt;
|
---|
[2] | 2339 | return
|
---|
| 2340 | end
|
---|
| 2341 | CivStage=Field{1}.CivStage;
|
---|
| 2342 | UvData.NbDim=Field{1}.nb_dim;
|
---|
| 2343 | end
|
---|
| 2344 | end
|
---|
[59] | 2345 | if ~isempty(filename_1) && ~test_keepdata_1 && isequal(FileType_1,'netcdf') %read the second file
|
---|
[2] | 2346 | if isequal(FieldName_1,'get_field...')% read the field names on the interface get_field.
|
---|
[144] | 2347 | hget_field_1=findobj(allchild(0),'Name','get_field_1');%find the get_field... GUI
|
---|
[89] | 2348 | if isempty(hget_field_1)
|
---|
| 2349 | hget_field_1= get_field(filename_1);%open the get_field GUI
|
---|
[144] | 2350 | set(hget_field_1,'name','get_field_1')
|
---|
| 2351 | elseif UvData.NewSeries% refresh the fet_field GUI for a new series
|
---|
| 2352 | delete(hget_field_1)
|
---|
| 2353 | hget_field_1= get_field(filename);%open the get_field GUI
|
---|
| 2354 | set(hget_field_1,'name','get_field_1')%rename get_field GUI for the 'slave' mode
|
---|
[2] | 2355 | end
|
---|
[89] | 2356 | hhget_field_1=guidata(hget_field_1);%handles of GUI elements in get_field
|
---|
[144] | 2357 | set(hhget_field_1.list_fig,'Value',1)
|
---|
| 2358 | set(hhget_field_1.list_fig,'String',{'uvmat'})
|
---|
[89] | 2359 | funct_list=get(hhget_field_1.ACTION,'UserData');
|
---|
| 2360 | funct_index=get(hhget_field_1.ACTION,'Value');
|
---|
| 2361 | funct=funct_list{funct_index};
|
---|
| 2362 | Field{2}=funct(hget_field_1); %read the names of the variables to plot in the get_field GUI
|
---|
[2] | 2363 | else
|
---|
[86] | 2364 | [Field{2},VelType_out_1]=read_civxdata(filename_1,InputField_1,VelType_1);
|
---|
[2] | 2365 | CivStage_1=Field{2}.CivStage;
|
---|
| 2366 | end
|
---|
[45] | 2367 | if ~isequal(FileType,'netcdf')
|
---|
[2] | 2368 | VelType_out=VelType_out_1;
|
---|
| 2369 | end
|
---|
| 2370 | end
|
---|
| 2371 | end
|
---|
| 2372 |
|
---|
[59] | 2373 | %store the second field for possible latter use
|
---|
| 2374 | if numel(Field)==2
|
---|
| 2375 | UvData.Field_1=Field{2};
|
---|
| 2376 | end
|
---|
| 2377 |
|
---|
[128] | 2378 | %% update the display buttons for the first velocity type (first menuline)
|
---|
[2] | 2379 | veltype_handles=[handles.civ1 handles.interp1 handles.filter1 handles.civ2 handles.interp2 handles.filter2];
|
---|
[45] | 2380 | if ~isequal(FileType,'netcdf')
|
---|
[2] | 2381 | reset_vel_type(veltype_handles)
|
---|
[59] | 2382 | elseif isempty(VelType) && ~isequal(FieldName,'get_field...')
|
---|
[2] | 2383 | set_veltype_display(veltype_handles,CivStage)%update the display of available velocity types for the first field
|
---|
| 2384 | if isempty(VelType_out)
|
---|
| 2385 | reset_vel_type(veltype_handles)
|
---|
| 2386 | else
|
---|
| 2387 | handle1=eval(['handles.' VelType_out]);
|
---|
| 2388 | reset_vel_type(veltype_handles,handle1)
|
---|
| 2389 | end
|
---|
| 2390 | end
|
---|
| 2391 |
|
---|
[128] | 2392 | %% update the display buttons for the second velocity type (second menuline)
|
---|
[2] | 2393 | veltype_handles_1=[handles.civ1_1 handles.interp1_1 handles.filter1_1 handles.civ2_1 handles.interp2_1 handles.filter2_1];
|
---|
[45] | 2394 | if ~isequal(FileType_1,'netcdf')
|
---|
[2] | 2395 | reset_vel_type(veltype_handles_1)
|
---|
[59] | 2396 | elseif isempty(VelType_1) && ~isequal(FieldName_1,'get_field...')
|
---|
[2] | 2397 | set_veltype_display(veltype_handles_1,CivStage_1)%update the display of available velocity types for the first field
|
---|
| 2398 | if isempty(VelType_out_1)
|
---|
| 2399 | reset_vel_type(veltype_handles_1)
|
---|
| 2400 | else
|
---|
| 2401 | handle1=eval(['handles.' VelType_out_1 '_1']);
|
---|
| 2402 | reset_vel_type(veltype_handles_1,handle1)
|
---|
| 2403 | end
|
---|
| 2404 | end
|
---|
| 2405 |
|
---|
[128] | 2406 | %% introduce w as background image by default for a new series (only for nbdim=2)
|
---|
[2] | 2407 | if ~isfield(UvData,'NewSeries')
|
---|
| 2408 | UvData.NewSeries=1;
|
---|
| 2409 | end
|
---|
| 2410 | %put W as background image by default if NbDim=2:
|
---|
[45] | 2411 | if ~isfield(UvData,'NbDim')||isempty(UvData.NbDim)||~isequal(UvData.NbDim,3)
|
---|
[2] | 2412 | if UvData.NewSeries && isequal(get(handles.SubField,'Value'),0) && isfield(Field{1},'W') && ~isempty(Field{1}.W);
|
---|
| 2413 | set(handles.SubField,'Value',1);
|
---|
[45] | 2414 | %menu=update_menu(handles.Fields_1,'w');%update the menu for the background scalar nd set the choice to 'w'
|
---|
[2] | 2415 | set(handles.RootPath_1,'String','"')
|
---|
| 2416 | set(handles.RootFile_1,'String','"')
|
---|
| 2417 | set(handles.SubDir_1,'String','"');
|
---|
| 2418 | [indices]=name_generator('',num_i1,num_j1,'',NomType,1,num_i2,num_j2,'');
|
---|
| 2419 | set(handles.FileIndex_1,'String',indices)
|
---|
| 2420 | set(handles.FileExt_1,'String','"');
|
---|
| 2421 | set(handles.Fields_1,'Visible','on');
|
---|
| 2422 | set(handles.Fields_1,'Visible','on');
|
---|
| 2423 | set(handles.RootPath_1,'Visible','on')
|
---|
| 2424 | set(handles.RootFile_1,'Visible','on')
|
---|
| 2425 | set(handles.SubDir_1,'Visible','on');
|
---|
| 2426 | set(handles.FileIndex_1,'Visible','on');
|
---|
| 2427 | set(handles.FileExt_1,'Visible','on');
|
---|
| 2428 | set(handles.Fields_1,'Visible','on');
|
---|
| 2429 | Field{1}.AName='w';
|
---|
[128] | 2430 | % testscal=1;
|
---|
[2] | 2431 | end
|
---|
| 2432 | end
|
---|
| 2433 |
|
---|
| 2434 | %multislice case
|
---|
[59] | 2435 | if ~isempty(filename) &&(~isfield(UvData,'NbDim') || isequal(UvData.NbDim,2))&&...%2D case
|
---|
[2] | 2436 | isfield(UvData,'XmlData') && isfield(UvData.XmlData,'GeometryCalib')&& isfield(UvData.XmlData.GeometryCalib,'SliceCoord')
|
---|
| 2437 | siz=size(UvData.XmlData.GeometryCalib.SliceCoord);
|
---|
[128] | 2438 | % if siz(1)>1
|
---|
| 2439 | % NbSlice=siz(1);
|
---|
| 2440 | % else
|
---|
| 2441 | % NbSlice=1;
|
---|
| 2442 | % end
|
---|
[2] | 2443 | end
|
---|
| 2444 |
|
---|
| 2445 | %store the current open names, fields and vel types in uvmat interface
|
---|
| 2446 | UvData.filename=filename;
|
---|
| 2447 | UvData.filename_1=filename_1;
|
---|
| 2448 | UvData.VelType=VelType;
|
---|
| 2449 | UvData.VelType_1=VelType_1;
|
---|
| 2450 | UvData.FieldName=FieldName;
|
---|
| 2451 | UvData.FieldName_1=FieldName_1;
|
---|
| 2452 | if ~isempty(scal_color)
|
---|
| 2453 | UvData.CName=scal_color;
|
---|
| 2454 | end
|
---|
| 2455 |
|
---|
[128] | 2456 | %% coordinate transform or user fct
|
---|
[2] | 2457 | XmlData=[];%default
|
---|
| 2458 | if isfield(UvData,'XmlData')%use geometry calib recorded from the ImaDoc xml file as first priority
|
---|
| 2459 | XmlData=UvData.XmlData;
|
---|
| 2460 | end
|
---|
| 2461 | XmlData_1=[];%default
|
---|
| 2462 | if isfield(UvData,'XmlData_1')
|
---|
| 2463 | XmlData_1=UvData.XmlData_1;
|
---|
| 2464 | end
|
---|
[128] | 2465 | % menu_transform=get(handles.transform_fct,'String');
|
---|
[39] | 2466 | choice_value=get(handles.transform_fct,'Value');
|
---|
| 2467 | transform_list=get(handles.transform_fct,'UserData');
|
---|
| 2468 | transform=transform_list{choice_value};%selected function handles
|
---|
[2] | 2469 | % z index
|
---|
[59] | 2470 | if ~isempty(filename)
|
---|
[60] | 2471 | Field{1}.ZIndex=z_index;
|
---|
[2] | 2472 | end
|
---|
| 2473 | %px to phys or other transform on field
|
---|
[59] | 2474 | if ~isempty(transform)
|
---|
[2] | 2475 | if length(Field)>=2
|
---|
[60] | 2476 | Field{2}.ZIndex=z_index;
|
---|
[38] | 2477 | [Field{1},Field{2}]=transform(Field{1},XmlData,Field{2},XmlData_1);
|
---|
[2] | 2478 | if isempty(Field{2})
|
---|
| 2479 | Field(2)=[];
|
---|
| 2480 | end
|
---|
| 2481 | else
|
---|
[38] | 2482 | Field{1}=transform(Field{1},XmlData);
|
---|
[2] | 2483 | end
|
---|
| 2484 | end
|
---|
| 2485 |
|
---|
[128] | 2486 | %% calculate scalar
|
---|
[45] | 2487 | if isequal(FileType,'netcdf') && ~isequal(FieldName,'get_field...')%
|
---|
[2] | 2488 | Field{1}=calc_field(InputField,Field{1});
|
---|
| 2489 | end
|
---|
[59] | 2490 | if length(Field)==2 && ~test_keepdata_1 && isequal(FileType_1,'netcdf') && ~isequal(FieldName_1,'get_field...')
|
---|
[2] | 2491 | Field{2}=calc_field(InputField_1,Field{2});
|
---|
| 2492 | end
|
---|
| 2493 | % combine the two input fields (e.g. substract velocity fields)
|
---|
| 2494 | if numel(Field)==2
|
---|
[59] | 2495 | UvData.Field=sub_field(Field{1},Field{2}); %TO UPDATE FOR MORE GENERAL INPUT
|
---|
[2] | 2496 | else
|
---|
| 2497 | UvData.Field=Field{1};
|
---|
| 2498 | end
|
---|
[59] | 2499 |
|
---|
[128] | 2500 | %% test 3D , default projection menuplane and typical mesh (needed to menuopen set_object)
|
---|
[2] | 2501 | test_x=0;
|
---|
| 2502 | test_z=0;% test for unstructured z coordinate
|
---|
[174] | 2503 | % UvData.ZMax=0;
|
---|
| 2504 | % UvData.ZMin=0;%default
|
---|
[158] | 2505 | %UvData.Mesh=1; %default
|
---|
[2] | 2506 | [UvData.Field,errormsg]=check_field_structure(UvData.Field);
|
---|
| 2507 | if ~isempty(errormsg)
|
---|
[59] | 2508 | errormsg=['error in uvmat/run0_Callback/check_field_structure: ' errormsg];
|
---|
[2] | 2509 | return
|
---|
| 2510 | end
|
---|
| 2511 | [CellVarIndex,NbDim,VarType]=find_field_indices(UvData.Field);
|
---|
| 2512 | [NbDim,imax]=max(NbDim);
|
---|
[159] | 2513 | % if isempty(imax)
|
---|
| 2514 | % % DimVarIndex=0;
|
---|
| 2515 | % coord_x=[];
|
---|
| 2516 | % else
|
---|
| 2517 | % % VarIndex=CellVarIndex{imax};
|
---|
| 2518 | % coord_x=VarType{imax}.coord_x;
|
---|
| 2519 | % end
|
---|
| 2520 | % if isfield(UvData,'NbDim') && ~isempty(UvData.NbDim)
|
---|
| 2521 | % NbDim=UvData.NbDim;
|
---|
| 2522 | % else
|
---|
| 2523 | UvData.NbDim=NbDim;
|
---|
| 2524 | % end
|
---|
| 2525 | if ~isempty(VarType{imax}.coord_x) && ~isempty(VarType{imax}.coord_y) %unstructured coordinates
|
---|
[2] | 2526 | XName=UvData.Field.ListVarName{VarType{imax}.coord_x};
|
---|
| 2527 | YName=UvData.Field.ListVarName{VarType{imax}.coord_y};
|
---|
[159] | 2528 | eval(['nbvec=length(UvData.Field.' XName ');'])%nbre of measurement points (e.g. vectors)
|
---|
| 2529 | test_x=1;%test for unstructured coordinates
|
---|
| 2530 | elseif NbDim==2
|
---|
| 2531 | YName=UvData.Field.ListVarName{VarType{imax}.coord(1)}; %structured coordinates
|
---|
| 2532 | XName=UvData.Field.ListVarName{VarType{imax}.coord(2)};
|
---|
| 2533 | elseif NbDim==3
|
---|
| 2534 | ZName=UvData.Field.ListVarName{VarType{imax}.coord(1)};%structured coordinates in 3D
|
---|
| 2535 | YName=UvData.Field.ListVarName{VarType{imax}.coord(2)};
|
---|
| 2536 | XName=UvData.Field.ListVarName{VarType{imax}.coord(3)};
|
---|
[174] | 2537 | eval(['ZMax=max(UvData.Field.' ZName ');'])
|
---|
| 2538 | eval(['ZMin=min(UvData.Field.' ZName ');'])
|
---|
[2] | 2539 | end
|
---|
[159] | 2540 | eval(['XMax=max(UvData.Field.' XName ');'])
|
---|
| 2541 | eval(['XMin=min(UvData.Field.' XName ');'])
|
---|
| 2542 | eval(['YMax=max(UvData.Field.' YName ');'])
|
---|
| 2543 | eval(['YMin=min(UvData.Field.' YName ');'])
|
---|
| 2544 | eval(['nbvec=length(UvData.Field.' XName ');'])
|
---|
| 2545 | if NbDim==3%
|
---|
| 2546 | if ~isempty(CellVarIndex) && ~isempty(VarType{imax}.coord_z)%unstructured coordinate z
|
---|
| 2547 | % ZName=UvData.Field.ListVarName{VarType{imax}.coord_z};
|
---|
| 2548 | eval(['ZMax=max(UvData.Field.' ZName ');'])
|
---|
| 2549 | eval(['ZMin=min(UvData.Field.' ZName ');'])
|
---|
| 2550 | test_z=1;
|
---|
| 2551 | elseif isfield(UvData,'Z')% usual civ data
|
---|
| 2552 | ZMax=max(UvData.Z);
|
---|
| 2553 | ZMin=min(UvData.Z);
|
---|
| 2554 | test_z=1;
|
---|
[2] | 2555 | end
|
---|
[159] | 2556 | if isequal(ZMin,ZMax)%no z dependency
|
---|
[2] | 2557 | NbDim=2;
|
---|
| 2558 | test_z=0;
|
---|
[159] | 2559 | end
|
---|
| 2560 | end
|
---|
| 2561 | if test_x
|
---|
[2] | 2562 | if test_z
|
---|
[159] | 2563 | UvData.Field.Mesh=((XMax-XMin)*(YMax-YMin)*(ZMax-ZMin))/nbvec;% volume per vector
|
---|
| 2564 | UvData.Field.Mesh=(UvData.Field.Mesh)^(1/3);
|
---|
[2] | 2565 | else
|
---|
[159] | 2566 | UvData.Field.Mesh=sqrt((XMax-XMin)*(YMax-YMin)/nbvec);%2D
|
---|
[2] | 2567 | end
|
---|
[159] | 2568 | else
|
---|
[2] | 2569 | VarIndex=CellVarIndex{imax}; % list of variable indices
|
---|
| 2570 | DimIndex=UvData.Field.VarDimIndex{VarIndex(1)}; %list of dim indices for the variable
|
---|
[159] | 2571 | nbpoints_y=UvData.Field.DimValue(DimIndex(1));
|
---|
| 2572 | nbpoints_x=UvData.Field.DimValue(DimIndex(2));
|
---|
| 2573 | DX=(XMax-XMin)/nbpoints_x;
|
---|
| 2574 | DY=(YMax-YMin)/nbpoints_y;
|
---|
| 2575 | UvData.Field.Mesh=sqrt(DX*DY);
|
---|
[2] | 2576 | end
|
---|
[159] | 2577 | UvData.Field.XMax=XMax;
|
---|
| 2578 | UvData.Field.XMin=XMin;
|
---|
| 2579 | UvData.Field.YMax=XMax;
|
---|
| 2580 | UvData.Field.YMin=XMin;
|
---|
[174] | 2581 | if NbDim==3
|
---|
[159] | 2582 | UvData.Field.ZMax=ZMax;
|
---|
| 2583 | UvData.Field.ZMin=ZMin;
|
---|
| 2584 | end
|
---|
[2] | 2585 |
|
---|
[159] | 2586 | %case of structured coordinates
|
---|
| 2587 |
|
---|
| 2588 | % if isempty(coord_x) && ~isempty(CellVarIndex)
|
---|
| 2589 | % VarIndex=CellVarIndex{imax}; % list of variable indices
|
---|
| 2590 | % DimIndex=UvData.Field.VarDimIndex{VarIndex(1)}; %list of dim indices for the variable
|
---|
| 2591 | % if NbDim==3
|
---|
| 2592 | % nbpoints=UvData.Field.DimValue(DimIndex(1));
|
---|
| 2593 | % if isfield(VarType{imax},'coord_3')&& ~isequal(VarType{imax}.coord_3,0) % z is a dimension variable
|
---|
| 2594 | % ZName=UvData.Field.ListVarName{VarType{imax}.coord_3};
|
---|
| 2595 | % eval(['UvData.ZMax=max(UvData.Field.' ZName ');'])
|
---|
| 2596 | % eval(['UvData.ZMin=min(UvData.Field.' ZName ');'])
|
---|
| 2597 | % else
|
---|
| 2598 | % testcoord_z=0;
|
---|
| 2599 | % if length(UvData.Field.VarAttribute)>=VarIndex(1)
|
---|
| 2600 | % if isfield(UvData.Field.VarAttribute{VarIndex(1)},'Coord_1')%regular grid
|
---|
| 2601 | % Coord_z=UvData.Field.VarAttribute{VarIndex(1)}.Coord_1;
|
---|
| 2602 | % UvData.ZMax=max(Coord_z);
|
---|
| 2603 | % UvData.ZMin=min(Coord_z);
|
---|
| 2604 | % testcoord_z=1;
|
---|
| 2605 | % end
|
---|
| 2606 | % end
|
---|
| 2607 | % if ~testcoord_z
|
---|
| 2608 | % UvData.ZMin=1;
|
---|
| 2609 | % UvData.ZMax=UvData.Field.DimValue(DimIndex(1));
|
---|
| 2610 | % end
|
---|
| 2611 | % end
|
---|
| 2612 | % Field.Mesh=(UvData.ZMax-UvData.ZMin)/(nbpoints-1);
|
---|
| 2613 | % elseif NbDim==2
|
---|
| 2614 | % nbpoints_y=UvData.Field.DimValue(DimIndex(1));
|
---|
| 2615 | % Yvar=VarType{imax}.coord_y;
|
---|
| 2616 | % if Yvar~=0 % x is a dimension variable
|
---|
| 2617 | % YName=UvData.Field.ListVarName{Yvar};
|
---|
| 2618 | % eval(['UvData.YMax=max(UvData.Field.' YName ');'])
|
---|
| 2619 | % eval(['UvData.YMin=min(UvData.Field.' YName ');'])
|
---|
| 2620 | % else
|
---|
| 2621 | % testcoord_y=0;
|
---|
| 2622 | % if ~testcoord_y
|
---|
| 2623 | % UvData.YMin=1;
|
---|
| 2624 | % UvData.YMax=UvData.Field.DimValue(DimIndex(1));
|
---|
| 2625 | % end
|
---|
| 2626 | % end
|
---|
| 2627 | % DY=(UvData.YMax-UvData.YMin)/(nbpoints_y-1);
|
---|
| 2628 | % nbpoints_x=UvData.Field.DimValue(DimIndex(2));
|
---|
| 2629 | % Xvar=VarType{imax}.coord_x;
|
---|
| 2630 | % if Xvar~=0 % x is a dimension variable
|
---|
| 2631 | % XName=UvData.Field.ListVarName{Xvar};
|
---|
| 2632 | % eval(['UvData.XMax=max(UvData.Field.' XName ');'])
|
---|
| 2633 | % eval(['UvData.XMin=min(UvData.Field.' XName ');'])
|
---|
| 2634 | % else
|
---|
| 2635 | % testcoord_x=0;
|
---|
| 2636 | % if ~testcoord_x
|
---|
| 2637 | % UvData.XMin=1;
|
---|
| 2638 | % UvData.XMax=UvData.Field.DimValue(DimIndex(2));
|
---|
| 2639 | % end
|
---|
| 2640 | % end
|
---|
| 2641 | % DX=(UvData.XMax-UvData.XMin)/(nbpoints_x-1);
|
---|
| 2642 | % Field.Mesh= sqrt(DX*DY);
|
---|
| 2643 | % end
|
---|
| 2644 | % end
|
---|
| 2645 |
|
---|
[2] | 2646 | %create a default projection menuplane
|
---|
| 2647 | UvData.Object{1}.Style='plane';%main plotting plane
|
---|
| 2648 | UvData.Object{1}.ProjMode='projection';%main plotting plane
|
---|
| 2649 | if ~isfield(UvData.Object{1},'plotaxes')
|
---|
| 2650 | UvData.Object{1}.plotaxes=handles.axes3;%default plotting axis
|
---|
[61] | 2651 | set(handles.list_object_1,'Value',1);
|
---|
[71] | 2652 | set(handles.list_object_1,'String',{'1-PLANE'});
|
---|
[2] | 2653 | end
|
---|
| 2654 |
|
---|
| 2655 | %3D case (menuvolume)
|
---|
[74] | 2656 | if NbDim==3 && UvData.NewSeries
|
---|
[2] | 2657 | UvData.Object{1}.NbDim=UvData.NbDim;%test for 3D objects
|
---|
[174] | 2658 | UvData.Object{1}.RangeZ=UvData.Field.Mesh;%main plotting plane
|
---|
| 2659 | UvData.Object{1}.Coord(1,3)=(UvData.Field.ZMin+UvData.Field.ZMax)/2;%section at a middle plane chosen
|
---|
[2] | 2660 | UvData.Object{1}.Phi=0;
|
---|
| 2661 | UvData.Object{1}.Theta=0;
|
---|
| 2662 | UvData.Object{1}.Psi=0;
|
---|
| 2663 | UvData.Object{1}.HandlesDisplay=plot(0,0,'Tag','proj_object');% A REVOIR
|
---|
| 2664 | PlotHandles=get_plot_handles(handles);
|
---|
[174] | 2665 | ZBounds(1)=UvData.Field.ZMin; %minimum for the Z slider
|
---|
| 2666 | ZBounds(2)=UvData.Field.ZMax;%maximum for the Z slider
|
---|
[72] | 2667 | UvData.Object{1}.Name='1-PLANE';
|
---|
| 2668 | UvData.Object{1}.enable_plot=1;
|
---|
[2] | 2669 | set_object(UvData.Object{1},PlotHandles,ZBounds);
|
---|
[61] | 2670 | set(handles.list_object_1,'Value',1);
|
---|
[2] | 2671 | %multilevel case (single menuplane in a 3D space)
|
---|
| 2672 | elseif isfield(UvData,'Z')
|
---|
[128] | 2673 | if isfield(UvData,'CoordType')&& isequal(UvData.CoordType,'phys') && isfield(UvData,'XmlData')
|
---|
[2] | 2674 | XmlData=UvData.XmlData;
|
---|
| 2675 | if isfield(XmlData,'PlanePos')
|
---|
| 2676 | UvData.Object{1}.Coord=XmlData.PlanePos(UvData.ZIndex,:);
|
---|
| 2677 | end
|
---|
| 2678 | if isfield(XmlData,'PlaneAngle')
|
---|
| 2679 | siz=size(XmlData.PlaneAngle);
|
---|
| 2680 | indangle=min(siz(1),UvData.ZIndex);%take first angle if a single angle is defined (translating scanning)
|
---|
| 2681 | UvData.Object{1}.Phi=XmlData.PlaneAngle(indangle,1);
|
---|
| 2682 | UvData.Object{1}.Theta=XmlData.PlaneAngle(indangle,2);
|
---|
| 2683 | UvData.Object{1}.Psi=XmlData.PlaneAngle(indangle,3);
|
---|
| 2684 | end
|
---|
| 2685 | elseif isfield(UvData,'ZIndex')
|
---|
| 2686 | UvData.Object{1}.ZObject=UvData.ZIndex;
|
---|
| 2687 | end
|
---|
| 2688 | end
|
---|
| 2689 |
|
---|
[128] | 2690 | %% reset the min and max of scalar if only the mask is displayed(TODO: check the need)
|
---|
| 2691 | if isfield(UvData,'Mask')&& ~isfield(UvData,'A')
|
---|
[2] | 2692 | set(handles.MinA,'String','0')
|
---|
| 2693 | set(handles.MaxA,'String','255')
|
---|
| 2694 | end
|
---|
[128] | 2695 |
|
---|
| 2696 | %% Plot the projections on the selected projection objects
|
---|
| 2697 |
|
---|
| 2698 | % main projection object (uvmat display)
|
---|
| 2699 | IndexObj(1)=get(handles.list_object_1,'Value');%selected projection object for main view
|
---|
[65] | 2700 | if IndexObj(1)> numel(UvData.Object)
|
---|
[128] | 2701 | IndexObj(1)=1;%select the first object if the selected one does not exist
|
---|
| 2702 | set(handles.list_object_1,'Value',1)
|
---|
[65] | 2703 | end
|
---|
[128] | 2704 | plot_handles{1}=handles;
|
---|
| 2705 | haxes(1)=handles.axes3;
|
---|
| 2706 | PlotParam{1}=read_plot_param(handles);%read plotting parameters on the uvmat interfac
|
---|
| 2707 | keeplim(1)=get(handles.FixedLimits,'Value');% test for fixed graph limits
|
---|
| 2708 | PosColorbar{1}=UvData.PosColorbar;%prescribe the colorbar position on the uvmat interface
|
---|
| 2709 |
|
---|
| 2710 | % second projection object (view_field display)
|
---|
| 2711 | IndexObj_2=get(handles.list_object_2,'Value');%selected projection object for the second view
|
---|
| 2712 | if isequal(get(handles.list_object_2,'Visible'),'on') && IndexObj_2 <= numel(UvData.Object)&& ~isempty(UvData.Object{IndexObj_2})
|
---|
[65] | 2713 | IndexObj(2)=IndexObj_2;
|
---|
[128] | 2714 | view_field_handle=findobj(allchild(0),'tag','view_field');%handles of the view_field GUI
|
---|
| 2715 | if ~isempty(view_field_handle)
|
---|
| 2716 | plot_handles{2}=guidata(view_field_handle);
|
---|
| 2717 | haxes(2)=plot_handles{2}.axes3;
|
---|
| 2718 | PlotParam{2}=read_plot_param(plot_handles{2});%read plotting parameters on the uvmat interface
|
---|
| 2719 | keeplim(2)=get(plot_handles{2}.FixedLimits,'Value');
|
---|
| 2720 | PosColorbar{2}='*'; %TODO: deal with colorbar position on view_field
|
---|
| 2721 | end
|
---|
[65] | 2722 | end
|
---|
[128] | 2723 |
|
---|
| 2724 | %loop on the projection objects: one or two
|
---|
[71] | 2725 | for imap=1:numel(IndexObj)
|
---|
[128] | 2726 | iobj=IndexObj(imap);
|
---|
[155] | 2727 | [ObjectData,errormsg]=proj_field(UvData.Field,UvData.Object{iobj});% project field on the object
|
---|
[150] | 2728 | if ~isempty(errormsg)
|
---|
| 2729 | return
|
---|
| 2730 | end
|
---|
[128] | 2731 | %use of mask (TODO: check)
|
---|
| 2732 | if isfield(ObjectData,'NbDim') && isequal(ObjectData.NbDim,2) && isfield(ObjectData,'Mask') && isfield(ObjectData,'A')
|
---|
| 2733 | flag_mask=double(ObjectData.Mask>200);%=0 for masked regions
|
---|
| 2734 | AX=ObjectData.AX;%x coordiantes for the scalar field
|
---|
| 2735 | AY=ObjectData.AY;%y coordinates for the scalar field
|
---|
| 2736 | MaskX=ObjectData.MaskX;%x coordiantes for the mask
|
---|
| 2737 | MaskY=ObjectData.MaskY;%y coordiantes for the mask
|
---|
| 2738 | if ~isequal(MaskX,AX)||~isequal(MaskY,AY)
|
---|
| 2739 | nxy=size(flag_mask);
|
---|
| 2740 | sizpx=(ObjectData.MaskX(end)-ObjectData.MaskX(1))/(nxy(2)-1);%size of a mask pixel
|
---|
| 2741 | sizpy=(ObjectData.MaskY(1)-ObjectData.MaskY(end))/(nxy(1)-1);
|
---|
| 2742 | x_mask=ObjectData.MaskX(1):sizpx:ObjectData.MaskX(end); % pixel x coordinates for image display
|
---|
| 2743 | y_mask=ObjectData.MaskY(1):-sizpy:ObjectData.MaskY(end);% pixel x coordinates for image display
|
---|
| 2744 | %project on the positions of the scalar
|
---|
| 2745 | npxy=size(ObjectData.A);
|
---|
| 2746 | dxy(1)=(ObjectData.AY(end)-ObjectData.AY(1))/(npxy(1)-1);%grid mesh in y
|
---|
| 2747 | dxy(2)=(ObjectData.AX(end)-ObjectData.AX(1))/(npxy(2)-1);%grid mesh in x
|
---|
| 2748 | xi=ObjectData.AX(1):dxy(2):ObjectData.AX(end);
|
---|
| 2749 | yi=ObjectData.AY(1):dxy(1):ObjectData.AY(end);
|
---|
| 2750 | [XI,YI]=meshgrid(xi,yi);% creates the matrix of regular coordinates
|
---|
| 2751 | flag_mask = interp2(x_mask,y_mask,flag_mask,XI,YI);
|
---|
[2] | 2752 | end
|
---|
[128] | 2753 | AClass=class(ObjectData.A);
|
---|
| 2754 | ObjectData.A=flag_mask.*double(ObjectData.A);
|
---|
| 2755 | ObjectData.A=feval(AClass,ObjectData.A);
|
---|
| 2756 | ind_off=[];
|
---|
| 2757 | if isfield(ObjectData,'ListVarName')
|
---|
| 2758 | for ilist=1:length(ObjectData.ListVarName)
|
---|
| 2759 | if isequal(ObjectData.ListVarName{ilist},'Mask')||isequal(ObjectData.ListVarName{ilist},'MaskX')||isequal(ObjectData.ListVarName{ilist},'MaskY')
|
---|
| 2760 | ind_off=[ind_off ilist];
|
---|
| 2761 | end
|
---|
[2] | 2762 | end
|
---|
[128] | 2763 | ObjectData.ListVarName(ind_off)=[];
|
---|
| 2764 | ObjectData.VarDimIndex(ind_off)=[];
|
---|
| 2765 | ind_off=[];
|
---|
| 2766 | for ilist=1:length(ObjectData.ListDimName)
|
---|
| 2767 | if isequal(ObjectData.ListDimName{ilist},'MaskX') || isequal(ObjectData.ListDimName{ilist},'MaskY')
|
---|
| 2768 | ind_off=[ind_off ilist];
|
---|
| 2769 | end
|
---|
| 2770 | end
|
---|
| 2771 | ObjectData.ListDimName(ind_off)=[];
|
---|
| 2772 | ObjectData.DimValue(ind_off)=[];
|
---|
| 2773 | end
|
---|
| 2774 | end
|
---|
| 2775 |
|
---|
| 2776 | if ~isempty(ObjectData)
|
---|
| 2777 | PlotType='none'; %default
|
---|
| 2778 | if imap==2 && isempty(view_field_handle)
|
---|
| 2779 | view_field(ObjectData)
|
---|
| 2780 | else
|
---|
| 2781 | [PlotType,PlotParamOut]=plot_field(ObjectData,haxes(imap),PlotParam{imap},keeplim(imap),PosColorbar{imap});
|
---|
[132] | 2782 | write_plot_param(plot_handles{imap},PlotParamOut) %update the auto plot parameters
|
---|
[158] | 2783 | if isfield(Field,'Mesh')&&~isempty(Field.Mesh)
|
---|
| 2784 | ObjectData.Mesh=Field.Mesh; % gives an estimated mesh size (useful for mouse action on the plot)
|
---|
[150] | 2785 | end
|
---|
| 2786 | if imap==1
|
---|
| 2787 | UvData.axes3=ObjectData;
|
---|
[132] | 2788 | else
|
---|
| 2789 | ViewFieldData=get(view_field_handle,'UserData');
|
---|
[150] | 2790 | ViewFieldData.axes3=ObjectData;
|
---|
[132] | 2791 | set(view_field_handle,'UserData',ViewFieldData)
|
---|
| 2792 | end
|
---|
[128] | 2793 | end
|
---|
| 2794 | if isequal(PlotType,'none')
|
---|
| 2795 | hget_field=findobj(allchild(0),'name','get_field');
|
---|
| 2796 | if isempty(hget_field)
|
---|
| 2797 | get_field([],ObjectData)% the projected field cannot be automatically plotted: use get_field to specify the variablesdelete(hget_field)
|
---|
[101] | 2798 | else
|
---|
[128] | 2799 | errormsg='The field defined by get_field cannot be plotted';
|
---|
| 2800 | return
|
---|
[101] | 2801 | end
|
---|
[128] | 2802 | end
|
---|
[2] | 2803 | end
|
---|
| 2804 | end
|
---|
| 2805 |
|
---|
[128] | 2806 | %write_plot_param(handles,UvData.Object{1}.PlotParam);% update the display of the plotting parameters
|
---|
[74] | 2807 | UvData.NewSeries=0;% put to 0 the test for a new field series (set by RootPath_callback)
|
---|
[45] | 2808 | set(handles.uvmat,'UserData',UvData)
|
---|
[2] | 2809 |
|
---|
[128] | 2810 | %% update the mask
|
---|
[2] | 2811 | if isequal(get(handles.mask_test,'Value'),1)%if the mask option is on
|
---|
| 2812 | update_mask(handles,num_i1,num_i2);
|
---|
| 2813 | end
|
---|
| 2814 |
|
---|
[128] | 2815 | %% prepare the menus of histograms and plot them (histogram of the whole volume in 3D case)
|
---|
| 2816 | menu_histo=(UvData.Field.ListVarName)';%list of field variables to be displayed for the menu of histogram display
|
---|
[2] | 2817 | ind_bad=[];
|
---|
| 2818 | nb_histo=1;
|
---|
[128] | 2819 |
|
---|
| 2820 | % suppress coordinates from the histogram menu
|
---|
| 2821 | for ivar=1:numel(menu_histo)%l loop on field variables:
|
---|
[2] | 2822 | if isfield(UvData.Field,'VarAttribute') && numel(UvData.Field.VarAttribute)>=ivar && isfield(UvData.Field.VarAttribute{ivar},'Role')
|
---|
| 2823 | Role=UvData.Field.VarAttribute{ivar}.Role;
|
---|
| 2824 | switch Role
|
---|
| 2825 | case {'coord_x','coord_y','coord_z','dimvar'}
|
---|
| 2826 | ind_bad=[ind_bad ivar];
|
---|
| 2827 | case {'vector_y'}
|
---|
| 2828 | nb_histo=nb_histo+1;
|
---|
| 2829 | end
|
---|
| 2830 | end
|
---|
| 2831 | DimCell=UvData.Field.VarDimName{ivar};
|
---|
| 2832 | DimName='';
|
---|
| 2833 | if ischar(DimCell)
|
---|
| 2834 | DimName=DimCell;
|
---|
| 2835 | elseif iscell(DimCell)&& numel(DimCell)==1
|
---|
| 2836 | DimName=DimCell{1};
|
---|
| 2837 | end
|
---|
| 2838 | if strcmp(DimName,menu_histo{ivar})
|
---|
| 2839 | ind_bad=[ind_bad ivar];
|
---|
| 2840 | end
|
---|
| 2841 | end
|
---|
| 2842 | menu_histo(ind_bad)=[];
|
---|
[128] | 2843 |
|
---|
| 2844 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
---|
| 2845 | % display menus and plot histograms
|
---|
[2] | 2846 | test_v=0;
|
---|
| 2847 | if ~isempty(menu_histo)
|
---|
| 2848 | set(handles.histo1_menu,'Value',1)
|
---|
| 2849 | set(handles.histo1_menu,'String',menu_histo)
|
---|
[128] | 2850 | histo1_menu_Callback(handles.histo1_menu, [], handles)% plot first histogram
|
---|
| 2851 | % case of more than one variables (eg vector components)
|
---|
| 2852 | if nb_histo > 1
|
---|
[2] | 2853 | test_v=1;
|
---|
| 2854 | set(handles.histo2_menu,'Visible','on')
|
---|
| 2855 | set(handles.histo_v,'Visible','on')
|
---|
| 2856 | set(handles.histo2_menu,'String',menu_histo)
|
---|
| 2857 | set(handles.histo2_menu,'Value',2)
|
---|
[128] | 2858 | histo2_menu_Callback(handles.histo2_menu,[], handles)% plot second histogram
|
---|
[2] | 2859 | end
|
---|
| 2860 | end
|
---|
| 2861 | if ~test_v
|
---|
| 2862 | set(handles.histo2_menu,'Visible','off')
|
---|
| 2863 | set(handles.histo_v,'Visible','off')
|
---|
| 2864 | cla(handles.histo_v)
|
---|
| 2865 | set(handles.histo2_menu,'Value',1)
|
---|
| 2866 | end
|
---|
[128] | 2867 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
---|
[2] | 2868 |
|
---|
[128] | 2869 | %% display time
|
---|
[2] | 2870 | testimedoc=0;
|
---|
| 2871 | if isfield(UvData,'XmlData') && isfield(UvData.XmlData,'Time')
|
---|
[89] | 2872 | if isempty(num_i2)||isnan(num_i2)
|
---|
[2] | 2873 | num_i2=num_i1;
|
---|
| 2874 | end
|
---|
[89] | 2875 | if isempty(num_j1)||isnan(num_j1)
|
---|
[2] | 2876 | num_j1=1;
|
---|
| 2877 | end
|
---|
[89] | 2878 | if isempty(num_j2)||isnan(num_j2)
|
---|
[2] | 2879 | num_j2=num_j1;
|
---|
| 2880 | end
|
---|
| 2881 | siz=size(UvData.XmlData.Time);
|
---|
[128] | 2882 | if siz(1)>=max(num_i1,num_i2) && siz(2)>=max(num_j1,num_j2)
|
---|
[2] | 2883 | abstime=(UvData.XmlData.Time(num_i1,num_j1)+UvData.XmlData.Time(num_i2,num_j2))/2;%overset the time read from files
|
---|
| 2884 | dt=(UvData.XmlData.Time(num_i2,num_j2)-UvData.XmlData.Time(num_i1,num_j1));
|
---|
| 2885 | testimedoc=1;
|
---|
| 2886 | end
|
---|
| 2887 | end
|
---|
| 2888 | if isfield(UvData,'XmlData_1') && isfield(UvData.XmlData_1,'Time')
|
---|
[128] | 2889 | [P,F,str1,str2,str_a,str_b,E]=name2display(['xx' get(handles.FileIndex_1,'String') get(handles.FileExt_1,'String')]);
|
---|
| 2890 | num_i2=str2double(str2);
|
---|
[155] | 2891 | if isnan(num_i2)
|
---|
[2] | 2892 | num_i2=num_i1;
|
---|
| 2893 | end
|
---|
[128] | 2894 | num_j1=str2double(str_a);
|
---|
[155] | 2895 | if isnan(num_j1)
|
---|
[2] | 2896 | num_j1=1;
|
---|
| 2897 | end
|
---|
[128] | 2898 | num_j2=str2double(str_b);
|
---|
[155] | 2899 | if isnan(num_j2)
|
---|
[2] | 2900 | num_j2=num_j1;
|
---|
| 2901 | end
|
---|
[128] | 2902 | num_i1=str2double(str1);
|
---|
[2] | 2903 | siz=size(UvData.XmlData_1.Time);
|
---|
[128] | 2904 | if siz(1)>=max(num_i1,num_i2) && siz(2)>=max(num_j1,num_j2)
|
---|
[2] | 2905 | 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
|
---|
| 2906 | end
|
---|
| 2907 | end
|
---|
| 2908 | set(handles.abs_time,'String',num2str(abstime,4))
|
---|
| 2909 | set(handles.abs_time_1,'String',num2str(abstime_1,4))
|
---|
| 2910 | if testimedoc && isfield(UvData,'dt')
|
---|
| 2911 | dt=UvData.dt;
|
---|
| 2912 | end
|
---|
[121] | 2913 | if isempty(dt)||isequal(dt,0)
|
---|
[2] | 2914 | set(handles.Dt_txt,'String','')
|
---|
| 2915 | else
|
---|
| 2916 | if ~(isfield(UvData,'TimeUnit') && ~isempty(UvData.TimeUnit))
|
---|
| 2917 | set(handles.Dt_txt,'String',['Dt=' num2str(1000*dt,3) ' 10^(-3)'] )
|
---|
| 2918 | else
|
---|
| 2919 | set(handles.Dt_txt,'String',['Dt=' num2str(1000*dt,3) ' m' UvData.TimeUnit] )
|
---|
| 2920 | end
|
---|
| 2921 | end
|
---|
[128] | 2922 |
|
---|
| 2923 | %% update the input file name in the get_field GUI
|
---|
[89] | 2924 | if isequal(FieldName,'get_field...')
|
---|
| 2925 | set(hhget_field.inputfile,'String',filename)
|
---|
| 2926 | Tabchar={''};%default
|
---|
| 2927 | Tabcell=[];
|
---|
[128] | 2928 | if isfield(Field{1},'ListGlobalAttribute')&& ~isempty(Field{1}.ListGlobalAttribute)
|
---|
[89] | 2929 | for iline=1:length(Field{1}.ListGlobalAttribute)
|
---|
| 2930 | Tabcell{iline,1}=Field{1}.ListGlobalAttribute{iline};
|
---|
| 2931 | if isfield(Field{1}, Field{1}.ListGlobalAttribute{iline})
|
---|
| 2932 | eval(['val=Field{1}.' Field{1}.ListGlobalAttribute{iline} ';'])
|
---|
| 2933 | if ischar(val);
|
---|
| 2934 | Tabcell{iline,2}=val;
|
---|
| 2935 | else
|
---|
| 2936 | Tabcell{iline,2}=num2str(val);
|
---|
| 2937 | end
|
---|
| 2938 | end
|
---|
| 2939 | end
|
---|
| 2940 | if ~isempty(Tabcell)
|
---|
| 2941 | Tabchar=cell2tab(Tabcell,'=');
|
---|
| 2942 | Tabchar=[{''};Tabchar];
|
---|
| 2943 | end
|
---|
| 2944 | end
|
---|
| 2945 | set(hhget_field.attributes,'String',Tabchar);%update list of global attributes in get_field
|
---|
| 2946 | end
|
---|
| 2947 | if isequal(FieldName_1,'get_field...')
|
---|
| 2948 | set(hhget_field_1.inputfile,'String',filename_1)
|
---|
| 2949 | Tabchar={''};%default
|
---|
| 2950 | Tabcell=[];
|
---|
[122] | 2951 | if isfield(Field{2},'ListGlobalAttribute')&& ~isempty(Field{2}.ListGlobalAttribute)
|
---|
[89] | 2952 | for iline=1:length(Field{2}.ListGlobalAttribute)
|
---|
| 2953 | Tabcell{iline,1}=Field{2}.ListGlobalAttribute{iline};
|
---|
| 2954 | if isfield(Field{2}, Field{2}.ListGlobalAttribute{iline})
|
---|
| 2955 | eval(['val=Field{2}.' Field{2}.ListGlobalAttribute{iline} ';'])
|
---|
| 2956 | if ischar(val);
|
---|
| 2957 | Tabcell{iline,2}=val;
|
---|
| 2958 | else
|
---|
| 2959 | Tabcell{iline,2}=num2str(val);
|
---|
| 2960 | end
|
---|
| 2961 | end
|
---|
| 2962 | end
|
---|
| 2963 | if ~isempty(Tabcell)
|
---|
| 2964 | Tabchar=cell2tab(Tabcell,'=');
|
---|
| 2965 | Tabchar=[{''};Tabchar];
|
---|
| 2966 | end
|
---|
| 2967 | end
|
---|
| 2968 | set(hhget_field_1.attributes,'String',Tabchar);%update list of global attributes in get_field
|
---|
| 2969 | end
|
---|
[2] | 2970 |
|
---|
| 2971 |
|
---|
| 2972 | %-------------------------------------------------------------------
|
---|
| 2973 | % --- translate coordinate to matrix index
|
---|
| 2974 | %-------------------------------------------------------------------
|
---|
| 2975 | function [indx,indy]=pos2ind(x0,rangx0,nxy)
|
---|
| 2976 | indx=1+round((nxy(2)-1)*(x0-rangx0(1))/(rangx0(2)-rangx0(1)));% index x of pixel
|
---|
| 2977 | indy=1+round((nxy(1)-1)*(y12-rangy0(1))/(rangy0(2)-rangy0(1)));% index y of pixel
|
---|
| 2978 |
|
---|
| 2979 | %-------------------------------------------------------------------
|
---|
| 2980 | % --- Executes on button press in 'FixedLimits'.
|
---|
| 2981 | %-------------------------------------------------------------------
|
---|
| 2982 | function FixedLimits_Callback(hObject, eventdata, handles)
|
---|
| 2983 | test=get(handles.FixedLimits,'Value');
|
---|
| 2984 | if test
|
---|
| 2985 | set(handles.FixedLimits,'BackgroundColor',[1 1 0])
|
---|
| 2986 | else
|
---|
| 2987 | set(handles.FixedLimits,'BackgroundColor',[0.7 0.7 0.7])
|
---|
[84] | 2988 | update_plot(handles);
|
---|
[2] | 2989 | end
|
---|
| 2990 |
|
---|
| 2991 | %-------------------------------------------------------------------
|
---|
| 2992 | % --- Executes on button press in auto_xy.
|
---|
| 2993 | function auto_xy_Callback(hObject, eventdata, handles)
|
---|
| 2994 | test=get(handles.auto_xy,'Value');
|
---|
| 2995 | if test
|
---|
| 2996 | set(handles.auto_xy,'BackgroundColor',[1 1 0])
|
---|
| 2997 | cla(handles.axes3)
|
---|
[89] | 2998 | update_plot(handles);
|
---|
[2] | 2999 | else
|
---|
| 3000 | set(handles.auto_xy,'BackgroundColor',[0.7 0.7 0.7])
|
---|
[89] | 3001 | update_plot(handles);
|
---|
[2] | 3002 | % axis(handles.axes3,'image')
|
---|
| 3003 | end
|
---|
| 3004 |
|
---|
| 3005 |
|
---|
| 3006 | %-------------------------------------------------------------------
|
---|
| 3007 |
|
---|
| 3008 | %-------------------------------------------------------------------
|
---|
| 3009 | % --- Executes on button press in 'zoom'.
|
---|
| 3010 | %-------------------------------------------------------------------
|
---|
| 3011 | function zoom_Callback(hObject, eventdata, handles)
|
---|
[60] | 3012 |
|
---|
[2] | 3013 | if (get(handles.zoom,'Value') == 1);
|
---|
| 3014 | set(handles.zoom,'BackgroundColor',[1 1 0])
|
---|
| 3015 | set(handles.FixedLimits,'Value',1)% propose by default fixed limits for the plotting axes
|
---|
[60] | 3016 | set(handles.FixedLimits,'BackgroundColor',[1 1 0])
|
---|
[2] | 3017 | else
|
---|
| 3018 | set(handles.zoom,'BackgroundColor',[0.7 0.7 0.7])
|
---|
| 3019 | end
|
---|
| 3020 |
|
---|
[60] | 3021 |
|
---|
[2] | 3022 | %-------------------------------------------------------------------
|
---|
| 3023 | %----Executes on button press in 'record': records the current flags of manual correction.
|
---|
| 3024 | %-------------------------------------------------------------------
|
---|
| 3025 | function record_Callback(hObject, eventdata, handles)
|
---|
| 3026 | % [filebase,num_i1,num_j1,num_i2,num_j2,Ext,NomType,SubDir]=read_input_file(handles);
|
---|
| 3027 | filename=read_file_boxes(handles);
|
---|
| 3028 | [erread,message]=fileattrib(filename);
|
---|
[55] | 3029 | if ~isempty(message) && ~isequal(message.UserWrite,1)
|
---|
[2] | 3030 | msgbox_uvmat('ERROR',['no writting access to ' filename])
|
---|
| 3031 | return
|
---|
| 3032 | end
|
---|
| 3033 | test_civ2=isequal(get(handles.civ2,'BackgroundColor'),[1 1 0]);
|
---|
[55] | 3034 | test_civ1=isequal(get(handles.civ1,'BackgroundColor'),[1 1 0]);
|
---|
| 3035 | if ~test_civ2 && ~test_civ1
|
---|
| 3036 | msgbox_uvmat('ERROR','manual correction only possible for CIV1 or CIV2 velocity fields')
|
---|
[2] | 3037 | end
|
---|
[55] | 3038 | if test_civ2
|
---|
| 3039 | nbname='nb_vectors2';
|
---|
| 3040 | flagname='vec2_FixFlag';
|
---|
| 3041 | attrname='fix2';
|
---|
| 3042 | end
|
---|
| 3043 | if test_civ1
|
---|
| 3044 | nbname='nb_vectors';
|
---|
| 3045 | flagname='vec_FixFlag';
|
---|
| 3046 | attrname='fix';
|
---|
| 3047 | end
|
---|
| 3048 | %write fix flags in the netcdf file
|
---|
[155] | 3049 | UvData=get(handles.uvmat,'UserData');
|
---|
[55] | 3050 | hhh=which('netcdf.open');% look for built-in matlab netcdf library
|
---|
| 3051 | if ~isequal(hhh,'')% case of new builtin Matlab netcdf library
|
---|
| 3052 | nc=netcdf.open(filename,'NC_WRITE');
|
---|
| 3053 | netcdf.reDef(nc)
|
---|
| 3054 | netcdf.putAtt(nc,netcdf.getConstant('NC_GLOBAL'),attrname,1)
|
---|
| 3055 | dimid = netcdf.inqDimID(nc,nbname);
|
---|
| 3056 | try
|
---|
| 3057 | varid = netcdf.inqVarID(nc,flagname);% look for already existing fixflag variable
|
---|
| 3058 | catch
|
---|
| 3059 | varid=netcdf.defVar(nc,flagname,'double',dimid);%create fixflag variable if it does not exist
|
---|
| 3060 | end
|
---|
| 3061 | netcdf.endDef(nc)
|
---|
[155] | 3062 | netcdf.putVar(nc,varid,UvData.axes3.FF);
|
---|
[55] | 3063 | netcdf.close(nc)
|
---|
| 3064 | else %old netcdf library
|
---|
[56] | 3065 | netcdf_toolbox(filename,AxeData,attrname,nbname,flagname)
|
---|
[55] | 3066 | end
|
---|
[2] | 3067 |
|
---|
[155] | 3068 | %-------------------------------------------------------------------
|
---|
| 3069 | %----Correct the netcdf file, using toolbox (old versions of Matlab).
|
---|
| 3070 | %-------------------------------------------------------------------
|
---|
[56] | 3071 | function netcdf_toolbox(filename,AxeData,attrname,nbname,flagname)
|
---|
| 3072 | nc=netcdf(filename,'write'); %open netcdf file
|
---|
| 3073 | result=redef(nc);
|
---|
| 3074 | eval(['nc.' attrname '=1;']);
|
---|
| 3075 | theDim=nc(nbname) ;% get the number of velocity vectors
|
---|
| 3076 | nb_vectors=size(theDim);
|
---|
| 3077 | var_FixFlag=ncvar(flagname,nc);% var_FixFlag will be written as the netcdf variable vec_FixFlag
|
---|
| 3078 | var_FixFlag(1:nb_vectors)=AxeData.FF;%
|
---|
| 3079 | fin=close(nc);
|
---|
[2] | 3080 |
|
---|
| 3081 |
|
---|
| 3082 | %-------------------------------------------------------------------
|
---|
| 3083 | %determines the fields to read from the interface
|
---|
| 3084 | %------------------------------------------------------------------
|
---|
| 3085 | function [VelType,civ]=setfield(handles)
|
---|
| 3086 |
|
---|
| 3087 | VelType=[]; %default
|
---|
| 3088 | if (get(handles.civ1,'Value') == 1);
|
---|
| 3089 | VelType='civ1';
|
---|
| 3090 | % interp1
|
---|
| 3091 | elseif (get(handles.interp1,'Value') == 1);
|
---|
| 3092 | VelType='interp1';
|
---|
| 3093 | % filter1
|
---|
| 3094 | elseif (get(handles.filter1,'Value') == 1);
|
---|
| 3095 | VelType='filter1';
|
---|
| 3096 | % CIV2
|
---|
| 3097 | elseif (get(handles.civ2,'Value') == 1);
|
---|
| 3098 | VelType='civ2';
|
---|
| 3099 | % interp2
|
---|
| 3100 | elseif (get(handles.interp2,'Value') == 1);
|
---|
| 3101 | VelType='interp2';
|
---|
| 3102 | % filter2
|
---|
| 3103 | elseif (get(handles.filter2,'Value') == 1);
|
---|
| 3104 | VelType='filter2';
|
---|
| 3105 | end
|
---|
| 3106 |
|
---|
| 3107 | if isequal(get(handles.filter2,'Visible'),'on');
|
---|
| 3108 | civ=6;
|
---|
| 3109 | % interp1
|
---|
| 3110 | elseif isequal(get(handles.interp2,'Visible'),'on');
|
---|
| 3111 | civ=5;
|
---|
| 3112 | % filter1
|
---|
| 3113 | elseif isequal(get(handles.civ2,'Visible'),'on');
|
---|
| 3114 | civ=4;
|
---|
| 3115 | % CIV2
|
---|
| 3116 | elseif isequal(get(handles.filter1,'Visible'),'on');
|
---|
| 3117 | civ=3;
|
---|
| 3118 | % interp2
|
---|
| 3119 | elseif isequal(get(handles.interp1,'Visible'),'on');
|
---|
| 3120 | civ=2;
|
---|
| 3121 | % filter2
|
---|
| 3122 | elseif isequal(get(handles.civ1,'Visible'),'on');
|
---|
| 3123 | civ=1;
|
---|
| 3124 | else
|
---|
| 3125 | civ=0;
|
---|
| 3126 | end
|
---|
| 3127 |
|
---|
| 3128 | %-------------------------------------------------------------------
|
---|
| 3129 | %determines the veltype of the second field to read from the iinterface
|
---|
| 3130 | %------------------------------------------------------------------
|
---|
| 3131 | function VelType=setfield_1(handles)
|
---|
| 3132 |
|
---|
| 3133 | VelType=[]; %default
|
---|
| 3134 | if (get(handles.civ1_1,'Value') == 1);
|
---|
| 3135 | VelType='civ1';
|
---|
| 3136 | % interp1
|
---|
| 3137 | elseif (get(handles.interp1_1,'Value') == 1);
|
---|
| 3138 | VelType='interp1';
|
---|
| 3139 | % filter1
|
---|
| 3140 | elseif (get(handles.filter1_1,'Value') == 1);
|
---|
| 3141 | VelType='filter1';
|
---|
| 3142 | % CIV2
|
---|
| 3143 | elseif (get(handles.civ2_1,'Value') == 1);
|
---|
| 3144 | VelType='civ2';
|
---|
| 3145 | % interp2
|
---|
| 3146 | elseif (get(handles.interp2_1,'Value') == 1);
|
---|
| 3147 | VelType='interp2';
|
---|
| 3148 | % filter2
|
---|
| 3149 | elseif (get(handles.filter2_1,'Value') == 1);
|
---|
| 3150 | VelType='filter2';
|
---|
| 3151 | end
|
---|
| 3152 |
|
---|
| 3153 |
|
---|
| 3154 | %---------------------------------------------------
|
---|
| 3155 | % --- Executes on button press in SubField
|
---|
| 3156 | function SubField_Callback(hObject, eventdata, handles)
|
---|
| 3157 | huvmat=get(handles.run0,'parent');
|
---|
| 3158 | UvData=get(huvmat,'UserData');
|
---|
| 3159 | if get(handles.SubField,'Value')==0% if the subfield button is desactivated
|
---|
| 3160 | set(handles.RootPath_1,'String','')
|
---|
| 3161 | set(handles.RootFile_1,'String','')
|
---|
| 3162 | set(handles.SubDir_1,'String','');
|
---|
| 3163 | set(handles.FileIndex_1,'String','');
|
---|
| 3164 | set(handles.FileExt_1,'String','');
|
---|
| 3165 | set(handles.RootPath_1,'Visible','off')
|
---|
| 3166 | set(handles.RootFile_1,'Visible','off')
|
---|
| 3167 | set(handles.SubDir_1,'Visible','off');
|
---|
| 3168 | set(handles.FileIndex_1,'Visible','off');
|
---|
| 3169 | set(handles.FileExt_1,'Visible','off');
|
---|
| 3170 | set(handles.Fields_1,'Value',1);%set to blank state
|
---|
| 3171 | set_veltype_display([handles.civ1_1 handles.interp1_1 handles.filter1_1 ...
|
---|
| 3172 | handles.civ2_1 handles.interp2_1 handles.filter2_1],0)
|
---|
| 3173 | if isfield(UvData,'XmlData_1')
|
---|
| 3174 | UvData=rmfield(UvData,'XmlData_1');
|
---|
| 3175 | end
|
---|
| 3176 | set(huvmat,'UserData',UvData);
|
---|
| 3177 | run0_Callback(hObject, eventdata, handles); %run
|
---|
| 3178 | else
|
---|
| 3179 | MenuBrowse_1_Callback(hObject, eventdata, handles)
|
---|
| 3180 | end
|
---|
| 3181 |
|
---|
[89] | 3182 | %------------------------------------------------------------------------
|
---|
| 3183 | % --- read the data displayed for the input rootfile windows (new)
|
---|
[2] | 3184 | function [FileName,RootPath,FileBase,FileIndices,FileExt,SubDir]=read_file_boxes(handles)
|
---|
[89] | 3185 | %------------------------------------------------------------------------
|
---|
[2] | 3186 | RootPath=get(handles.RootPath,'String');
|
---|
| 3187 | FileName=RootPath; %default
|
---|
| 3188 | SubDir=get(handles.SubDir,'String');
|
---|
| 3189 | if ~isempty(SubDir) && ~isequal(SubDir,'')
|
---|
| 3190 | if (isequal(SubDir(1),'/')|| isequal(SubDir(1),'\'))
|
---|
| 3191 | SubDir(1)=[]; %suppress possible / or \ separator
|
---|
| 3192 | end
|
---|
| 3193 | FileName=fullfile(RootPath,SubDir);
|
---|
| 3194 | end
|
---|
| 3195 | RootFile=get(handles.RootFile,'String');
|
---|
| 3196 | if ~isempty(RootFile) && ~isequal(RootFile,'')
|
---|
| 3197 | if (isequal(RootFile(1),'/')|| isequal(RootFile(1),'\'))
|
---|
| 3198 | RootFile(1)=[]; %suppress possible / or \ separator
|
---|
| 3199 | end
|
---|
| 3200 | FileName=fullfile(FileName,RootFile);
|
---|
| 3201 | end
|
---|
| 3202 | FileBase=fullfile(RootPath,RootFile);
|
---|
| 3203 | FileIndices=get(handles.FileIndex,'String');
|
---|
| 3204 | FileExt=get(handles.FileExt,'String');
|
---|
| 3205 | FileName=[FileName FileIndices FileExt];
|
---|
| 3206 |
|
---|
[85] | 3207 | %------------------------------------------------------------------------
|
---|
| 3208 | % ---- read the data displayed for the second input rootfile windows
|
---|
[2] | 3209 | function [FileName_1,RootPath_1,FileBase_1,FileIndices_1,FileExt_1,SubDir_1]=read_file_boxes_1(handles)
|
---|
[85] | 3210 | %------------------------------------------------------------------------
|
---|
[86] | 3211 | RootPath_1=get(handles.RootPath_1,'String'); % read the data from the file1_input window
|
---|
[85] | 3212 | if isequal(get(handles.RootPath_1,'Visible'),'off') || isequal(RootPath_1,'"')
|
---|
| 3213 | RootPath_1=get(handles.RootPath,'String');
|
---|
| 3214 | end;
|
---|
[2] | 3215 | FileName_1=RootPath_1; %default
|
---|
| 3216 | SubDir_1=get(handles.SubDir_1,'String');
|
---|
[85] | 3217 | if isequal(get(handles.SubDir_1,'Visible'),'off')|| isequal(SubDir_1,'"')
|
---|
[2] | 3218 | SubDir_1=get(handles.SubDir,'String');
|
---|
| 3219 | end
|
---|
[85] | 3220 | if numel(SubDir_1)>=1
|
---|
[2] | 3221 | if (isequal(SubDir_1(1),'/')|| isequal(SubDir_1(1),'\'))
|
---|
| 3222 | SubDir_1(1)=[]; %suppress possible / or \ separator
|
---|
| 3223 | end
|
---|
| 3224 | FileName_1=fullfile(RootPath_1,SubDir_1);
|
---|
| 3225 | end
|
---|
| 3226 | RootFile_1=get(handles.RootFile_1,'String');
|
---|
[85] | 3227 | if isequal(get(handles.RootFile_1,'Visible'),'off') || isequal(RootFile_1,'"')
|
---|
| 3228 | RootFile_1=get(handles.RootFile,'String');
|
---|
| 3229 | end
|
---|
| 3230 | if numel(RootFile_1)>=1
|
---|
[2] | 3231 | if ~(isequal(RootFile_1(1),'/')|isequal(RootFile_1(1),'\'))
|
---|
| 3232 | RootFile_1(1)=[];%suppress possible / or \ separator
|
---|
| 3233 | end
|
---|
| 3234 | FileName_1=fullfile(FileName_1,RootFile_1);
|
---|
| 3235 | end
|
---|
| 3236 | FileBase_1=fullfile(RootPath_1,RootFile_1);
|
---|
[85] | 3237 | if isequal(get(handles.FileIndex_1,'Visible'),'off')
|
---|
| 3238 | FileIndices_1=get(handles.FileIndex,'String');
|
---|
| 3239 | else
|
---|
| 3240 | FileIndices_1=get(handles.FileIndex_1,'String');
|
---|
| 3241 | end
|
---|
[2] | 3242 | FileExt_1=get(handles.FileExt_1,'String');
|
---|
| 3243 | if isequal(FileExt_1,'"'),FileExt_1=get(handles.FileExt,'String'); end;
|
---|
| 3244 | FileName_1=[FileName_1 FileIndices_1 FileExt_1];
|
---|
| 3245 |
|
---|
[85] | 3246 | %------------------------------------------------------------------------
|
---|
[2] | 3247 | % --- Executes on menu selection Fields
|
---|
| 3248 | function Fields_Callback(hObject, eventdata, handles)
|
---|
[85] | 3249 | %------------------------------------------------------------------------
|
---|
[2] | 3250 | list_fields=get(handles.Fields,'String');% list menu fields
|
---|
| 3251 | index_fields=get(handles.Fields,'Value');% selected string index
|
---|
| 3252 | field= list_fields{index_fields(1)}; % selected string
|
---|
| 3253 | if isequal(field,'get_field...')
|
---|
| 3254 | veltype_handles=[handles.civ1 handles.interp1 handles.filter1 handles.civ2 handles.interp2 handles.filter2];
|
---|
| 3255 | set_veltype_display(veltype_handles,0) % unvisible civ buttons
|
---|
| 3256 | filename=read_file_boxes(handles);
|
---|
[144] | 3257 | hget_field=findobj(allchild(0),'name','get_field');
|
---|
| 3258 | if ~isempty(hget_field)
|
---|
| 3259 | delete(hget_field)
|
---|
[2] | 3260 | end
|
---|
[144] | 3261 | hget_field=get_field(filename);
|
---|
| 3262 | set(hget_field,'Name','get_field')
|
---|
| 3263 | hhget_field=guidata(hget_field);
|
---|
| 3264 | set(hhget_field.list_fig,'Value',1)
|
---|
| 3265 | set(hhget_field.list_fig,'String',{'uvmat'})
|
---|
| 3266 | set(handles.transform_fct,'Value',1)% no transform by default
|
---|
| 3267 | set(handles.path_transform,'String','')
|
---|
[2] | 3268 | return %no action
|
---|
| 3269 | end
|
---|
| 3270 | list_fields=get(handles.Fields_1,'String');% list menu fields
|
---|
| 3271 | index_fields=get(handles.Fields_1,'Value');% selected string index
|
---|
| 3272 | field_1= list_fields{index_fields(1)}; % selected string
|
---|
[59] | 3273 | UvData=get(handles.uvmat,'UserData');
|
---|
[2] | 3274 |
|
---|
| 3275 | %read the rootfile input display
|
---|
[82] | 3276 | [FileName,RootPath,FileBase,FileIndices,FileExt]=read_file_boxes(handles);
|
---|
[2] | 3277 | [P,F,str1,str2,str_a,str_b,E,NomType]=name2display(['xxx' get(handles.FileIndex,'String') FileExt]);
|
---|
| 3278 | NomTypeNew=NomType;%default
|
---|
| 3279 | if isequal(field,'image')
|
---|
| 3280 | % transform netc type to the corresponding image type
|
---|
[85] | 3281 | % if isequal(NomType,'_i1-i2_j')||isequal(NomType,'_i_j1-j2')|| isequal(NomType,'#_ab')|| isequal(NomType,'_i1-i2')
|
---|
| 3282 | % UvData.SubDir=get(handles.SubDir,'String'); %preserve the subdir in memory
|
---|
| 3283 | % if ~isempty(UvData.SubDir) && (isequal(UvData.SubDir(1),'/')||isequal(UvData.SubDir(1),'/'))
|
---|
| 3284 | % UvData.SubDir(1)=[];
|
---|
| 3285 | % end
|
---|
| 3286 | % set(handles.SubDir,'String','')
|
---|
| 3287 | % set(handles.FileExt,'String','.png');
|
---|
[45] | 3288 | if isequal(NomType,'_i1-i2_j')||isequal(NomType,'_i_j1-j2')
|
---|
[2] | 3289 | NomTypeNew='_i_j';
|
---|
| 3290 | elseif isequal(NomType,'#_ab')
|
---|
| 3291 | NomTypeNew='#a';
|
---|
| 3292 | elseif isequal(NomType,'_i1-i2')
|
---|
| 3293 | NomTypeNew='_i';
|
---|
| 3294 | end
|
---|
[86] | 3295 | imagename=name_generator(FileBase,str2double(str1),str2double(str_a),'.png',NomTypeNew,1,str2double(str2),str2double(str_b),'');
|
---|
[85] | 3296 | if ~exist(imagename,'file')
|
---|
| 3297 | [FileName,PathName] = uigetfile( ...
|
---|
| 3298 | {'*.png;*.jpg;*.tif;*.avi;*.AVI;*.vol', ' (*.png, .tif, *.avi,*.vol)';
|
---|
| 3299 | '*.jpg',' jpeg image files'; ...
|
---|
| 3300 | '*.png','.png image files'; ...
|
---|
| 3301 | '*.tif','.tif image files'; ...
|
---|
| 3302 | '*.avi;*.AVI','.avi movie files'; ...
|
---|
| 3303 | '*.vol','.volume images (png)'; ...
|
---|
| 3304 | '*.*', 'All Files (*.*)'}, ...
|
---|
[86] | 3305 | 'Pick an image',imagename);
|
---|
[85] | 3306 | % display the selected field and related information
|
---|
| 3307 | imagename=[PathName FileName];
|
---|
| 3308 | end
|
---|
| 3309 | display_file_name(hObject, eventdata, handles,imagename)%display the image
|
---|
| 3310 | return
|
---|
| 3311 | % end
|
---|
| 3312 | % veltype_handles=[handles.civ1 handles.interp1 handles.filter1 handles.civ2 handles.interp2 handles.filter2];
|
---|
| 3313 | % set_veltype_display(veltype_handles,0) % unvisible civ buttons
|
---|
[2] | 3314 | else
|
---|
| 3315 | ext=get(handles.FileExt,'String');
|
---|
| 3316 | if ~isequal(ext,'.nc') %find the new NomType if the previous display was not already a netcdf file
|
---|
[85] | 3317 | [FileName,PathName] = uigetfile( ...
|
---|
| 3318 | {'*.nc', ' (*.nc)';
|
---|
| 3319 | '*.nc',' netcdf files'; ...
|
---|
| 3320 | '*.*', 'All Files (*.*)'}, ...
|
---|
[86] | 3321 | 'Pick a netcdf file',FileBase);
|
---|
[85] | 3322 | % display the selected field and related information
|
---|
| 3323 | filename=[PathName FileName];
|
---|
| 3324 | display_file_name(hObject, eventdata, handles,filename)
|
---|
| 3325 | return
|
---|
| 3326 | % MenuBrowse_Callback(hObject, eventdata, handles)
|
---|
[2] | 3327 | end
|
---|
| 3328 | if isequal(field,'vort') || isequal(field,'div') || isequal(field,'strain')
|
---|
| 3329 | set(handles.civ1,'BackgroundColor',[0.702 0.702 0.702]) % put their color to grey
|
---|
| 3330 | set(handles.civ2,'BackgroundColor',[0.702 0.702 0.702])
|
---|
| 3331 | set(handles.interp1,'BackgroundColor',[0.702 0.702 0.702])
|
---|
| 3332 | set(handles.interp2,'BackgroundColor',[0.702 0.702 0.702])
|
---|
| 3333 | elseif isequal(field,'more...');
|
---|
| 3334 | set(handles.civ1,'BackgroundColor',[0.702 0.702 0.702]) % put their color to grey
|
---|
| 3335 | set(handles.civ2,'BackgroundColor',[0.702 0.702 0.702])
|
---|
| 3336 | str=calc_field;%get the list of available scalars by the function calc_scal
|
---|
[45] | 3337 | [ind_answer] = listdlg('PromptString','Select a file:',...
|
---|
[2] | 3338 | 'SelectionMode','single',...
|
---|
| 3339 | 'ListString',str);
|
---|
| 3340 | % edit the choice in the field and action menu
|
---|
| 3341 | scalar=cell2mat(str(ind_answer));
|
---|
| 3342 | menu=update_menu(handles.Fields,scalar);
|
---|
| 3343 | menu=[{''};menu];
|
---|
| 3344 | set(handles.Fields_1,'String',menu);% store the selected scalar type
|
---|
| 3345 | end
|
---|
| 3346 | end
|
---|
[45] | 3347 | indices=name_generator('',str2double(str1),str2double(str_a),'',NomTypeNew,1,str2double(str2),str2double(str_b),'');
|
---|
[2] | 3348 | set(handles.FileIndex,'String',indices)
|
---|
| 3349 | set(handles.FileIndex,'UserData',NomTypeNew)
|
---|
| 3350 | %common to Fields_1_Callback
|
---|
[45] | 3351 | if isequal(field,'image')||isequal(field_1,'image')
|
---|
[2] | 3352 | set(handles.npx_title,'Visible','on')% visible npx,pxcm... buttons
|
---|
| 3353 | set(handles.npy_title,'Visible','on')
|
---|
| 3354 | set(handles.npx,'Visible','on')
|
---|
| 3355 | set(handles.npy,'Visible','on')
|
---|
| 3356 | else
|
---|
| 3357 | set(handles.npx_title,'Visible','off')% visible npx,pxcm... buttons
|
---|
| 3358 | set(handles.npy_title,'Visible','off')
|
---|
| 3359 | set(handles.npx,'Visible','off')
|
---|
| 3360 | set(handles.npy,'Visible','off')
|
---|
| 3361 | end
|
---|
| 3362 | setfield(handles);% update the field structure ('civ1'....)
|
---|
| 3363 |
|
---|
[45] | 3364 | if ~isfield(UvData,'NewSeries')||isequal(UvData.NewSeries,0)
|
---|
[2] | 3365 | run0_Callback(hObject, eventdata, handles)
|
---|
| 3366 | end
|
---|
| 3367 |
|
---|
| 3368 | %---------------------------------------------------
|
---|
| 3369 | % --- Executes on menu selection Fields
|
---|
| 3370 | function Fields_1_Callback(hObject, eventdata, handles)
|
---|
| 3371 | %-------------------------------------------------
|
---|
| 3372 | list_fields=get(handles.Fields,'String');% list menu fields
|
---|
| 3373 | index_fields=get(handles.Fields,'Value');% selected string index
|
---|
| 3374 | field= list_fields{index_fields(1)}; % selected string
|
---|
| 3375 | list_fields=get(handles.Fields_1,'String');% list menu fields
|
---|
| 3376 | index_fields=get(handles.Fields_1,'Value');% selected string index
|
---|
| 3377 | field_1= list_fields{index_fields(1)}; % selected string for the second field
|
---|
| 3378 | if isequal(field_1,'') %remove second field if 'blank' field is selected
|
---|
| 3379 | set(handles.SubField,'Value',0)
|
---|
| 3380 | SubField_Callback(hObject, eventdata, handles)
|
---|
| 3381 | return
|
---|
| 3382 | end
|
---|
[59] | 3383 | UvData=get(handles.uvmat,'UserData');
|
---|
[2] | 3384 |
|
---|
| 3385 | %read the rootfile input display
|
---|
[85] | 3386 | [FileName,RootPath,FileBase,FileIndices,FileExt_prev]=read_file_boxes_1(handles);
|
---|
| 3387 | [P,F,str1,str2,str_a,str_b,E,NomType]=name2display(['xxx' get(handles.FileIndex,'String') FileExt_prev]);
|
---|
[2] | 3388 | if isempty(FileExt_prev)|isequal(FileExt_prev,'')
|
---|
| 3389 | FileExt_1=get(handles.FileExt,'String');
|
---|
| 3390 | else
|
---|
| 3391 | FileExt_1=FileExt_prev;
|
---|
| 3392 | end
|
---|
| 3393 | NomType_1=get(handles.FileIndex_1,'UserData');
|
---|
| 3394 | if isempty(NomType_1)|isequal(NomType_1,'')
|
---|
| 3395 | NomType_1=get(handles.FileIndex,'UserData');
|
---|
| 3396 | end
|
---|
| 3397 | NomTypeNew=NomType_1;%default
|
---|
| 3398 |
|
---|
| 3399 | set(handles.SubField,'Value',1)%introduce second field
|
---|
| 3400 | if isfield(UvData,'XmlData')
|
---|
| 3401 | UvData.XmlData_1=UvData.XmlData;
|
---|
| 3402 | end
|
---|
| 3403 | set(handles.FileIndex_1,'Visible','on')
|
---|
| 3404 | set(handles.FileExt_1,'Visible','on')
|
---|
| 3405 | RootPath_1=get(handles.RootPath_1,'String');
|
---|
| 3406 | RootFile_1=get(handles.RootFile_1,'String');
|
---|
[82] | 3407 | if isempty(RootPath_1)||isequal(RootPath_1,'')
|
---|
[2] | 3408 | set(handles.RootPath_1,'String','"')
|
---|
| 3409 | end
|
---|
[82] | 3410 | if isempty(RootFile_1) || isequal(RootFile_1,'')
|
---|
[2] | 3411 | set(handles.RootFile_1,'String','"')
|
---|
| 3412 | end
|
---|
[82] | 3413 | if ~isempty(RootFile_1)&&(isequal(RootFile_1(1),'/')||isequal(RootFile_1(1),'\'))
|
---|
[2] | 3414 | RootFile_1(1)=[];
|
---|
| 3415 | end
|
---|
| 3416 |
|
---|
| 3417 | if isequal(field_1,'get_field...')
|
---|
| 3418 | veltype_handles=[handles.civ1 handles.interp1 handles.filter1 handles.civ2 handles.interp2 handles.filter2];
|
---|
| 3419 | set_veltype_display(veltype_handles,0) % unvisible civ buttons
|
---|
| 3420 | filename=read_file_boxes_1(handles);
|
---|
| 3421 | hget_field=findobj(allchild(0),'name','get_field_1');
|
---|
| 3422 | if ~isempty(hget_field)
|
---|
| 3423 | delete(hget_field)
|
---|
| 3424 | end
|
---|
| 3425 | hget_field=get_field(filename);
|
---|
| 3426 | set(hget_field,'name','get_field_1')
|
---|
[144] | 3427 | hhget_field=guidata(hget_field);
|
---|
| 3428 | set(hhget_field.list_fig,'Value',1)
|
---|
| 3429 | set(hhget_field.list_fig,'String',{'uvmat'})
|
---|
| 3430 | set(handles.transform_fct,'Value',1)% no transform by default
|
---|
| 3431 | set(handles.path_transform,'String','')
|
---|
[2] | 3432 | return %no action
|
---|
| 3433 | end
|
---|
| 3434 | if isequal(field_1,'image')
|
---|
| 3435 | % transform netc type to the corresponding image type
|
---|
[85] | 3436 | % set(handles.FileExt_1,'String','.png');
|
---|
[2] | 3437 | if isequal(NomType_1,'_i1-i2_j')|isequal(NomType_1,'_i_j1-j2')| isequal(NomType_1,'#_ab')| isequal(NomType_1,'_i1-i2')
|
---|
| 3438 | UvData.SubDir_1=get(handles.SubDir_1,'String'); %preserve the subdir in memory
|
---|
[85] | 3439 | % set(handles.SubDir_1,'String','')
|
---|
[2] | 3440 | % set(handles.FileExt_1,'String','.png');
|
---|
| 3441 | if isequal(NomType_1,'_i1-i2_j')|isequal(NomType_1,'_i_j1-j2')
|
---|
| 3442 | NomTypeNew='_i_j';
|
---|
| 3443 | elseif isequal(NomType_1,'#_ab')
|
---|
| 3444 | NomTypeNew='#a';
|
---|
| 3445 | elseif isequal(NomType_1,'_i1-i2')
|
---|
| 3446 | NomTypeNew='_i';
|
---|
| 3447 | end
|
---|
| 3448 | end
|
---|
[85] | 3449 | imagename=name_generator(FileBase,str2double(str1),str2double(str_a),'.png',NomTypeNew,1,str2double(str2),str2double(str_b),'');
|
---|
| 3450 | if ~exist(imagename,'file')
|
---|
| 3451 | [FileName,PathName] = uigetfile( ...
|
---|
| 3452 | {'*.png;*.jpg;*.tif;*.avi;*.AVI;*.vol', ' (*.png, .tif, *.avi,*.vol)';
|
---|
| 3453 | '*.jpg',' jpeg image files'; ...
|
---|
| 3454 | '*.png','.png image files'; ...
|
---|
| 3455 | '*.tif','.tif image files'; ...
|
---|
| 3456 | '*.avi;*.AVI','.avi movie files'; ...
|
---|
| 3457 | '*.vol','.volume images (png)'; ...
|
---|
| 3458 | '*.*', 'All Files (*.*)'}, ...
|
---|
[86] | 3459 | 'Pick an image',imagename);
|
---|
[85] | 3460 | % display the selected field and related information
|
---|
| 3461 | imagename=[PathName FileName];
|
---|
| 3462 | end
|
---|
| 3463 | display_file_name_1(hObject, eventdata, handles,imagename)%display the image
|
---|
| 3464 | return
|
---|
| 3465 | % veltype_handles=[handles.civ1_1 handles.interp1_1 handles.filter1_1 handles.civ2_1 handles.interp2_1 handles.filter2_1];
|
---|
| 3466 | % set_veltype_display(veltype_handles,0) % unvisible civ buttons
|
---|
[2] | 3467 | else
|
---|
| 3468 | set(handles.SubDir_1,'Visible','on')
|
---|
| 3469 | if ~isequal(FileExt_prev,'.nc') %find the new NomType if the previous display was not already a netcdf file
|
---|
| 3470 | veltype_handles=[handles.civ1_1 handles.interp1_1 handles.filter1_1 handles.civ2_1 handles.interp2_1 handles.filter2_1];
|
---|
| 3471 | set_veltype_display(veltype_handles,6); % make all civ buttons visible
|
---|
| 3472 | RootPath_1=get(handles.RootPath_1,'String');
|
---|
| 3473 | RootFile_1=get(handles.RootFile_1,'String');
|
---|
| 3474 | if isempty(RootPath_1)|isequal(RootPath_1,'')
|
---|
| 3475 | set(handles.RootPath_1,'String','"')
|
---|
| 3476 | end
|
---|
| 3477 | if isempty(RootFile_1) | isequal(RootFile_1,'')
|
---|
| 3478 | set(handles.RootFile_1,'String','"')
|
---|
| 3479 | end
|
---|
| 3480 | if ~isempty(RootFile_1)&(isequal(RootFile_1(1),'/')|isequal(RootFile_1(1),'\'))
|
---|
| 3481 | RootFile_1(1)=[];
|
---|
| 3482 | end
|
---|
| 3483 | filebase_1=fullfile(RootPath_1,RootFile_1);
|
---|
| 3484 | SubDir_1=get(handles.SubDir,'String');
|
---|
[82] | 3485 | if isempty(SubDir_1)||isequal(SubDir_1,'')
|
---|
[2] | 3486 | if isfield(UvData,'SubDir_1')
|
---|
| 3487 | SubDir_1=UvData.SubDir_1;%retrieve previous subdir
|
---|
| 3488 | else
|
---|
| 3489 | SubDir_1='?';
|
---|
| 3490 | end
|
---|
| 3491 | end
|
---|
[82] | 3492 | str1=get(handles.i1,'String');
|
---|
| 3493 | str_a=get(handles.j1,'String');
|
---|
| 3494 | if isequal(NomType_1,'#_ab')||isequal(NomType_1,'_i1-i2_j')||isequal(NomType_1,'_i_j1-j2')||isequal(NomType_1,'_i1-i2')
|
---|
[2] | 3495 | NomTypeNew=NomType_1;
|
---|
| 3496 | elseif isequal(NomType_1,'#a')
|
---|
[82] | 3497 | [filename, n1,na,n2,nb,SubDir_1]=name_generator(filebase_1, str2num(str1),stra2num(str_a),'.nc','#_ab',0,[],[],SubDir_1);
|
---|
[2] | 3498 | NomTypeNew='#_ab';
|
---|
| 3499 | elseif isequal(NomType_1,'_i_j')
|
---|
[82] | 3500 | [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] | 3501 | if idetect==1
|
---|
| 3502 | NomTypeNew='_i1-i2_j';
|
---|
| 3503 | else
|
---|
| 3504 | NomTypeNew='_i_j1-j2';
|
---|
| 3505 | end
|
---|
| 3506 | else %for instance avi files or any ima_num series
|
---|
[82] | 3507 | [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] | 3508 | NomTypeNew='_i1-i2';
|
---|
| 3509 | end
|
---|
| 3510 | [Path,Name]=fileparts(filebase_1);
|
---|
| 3511 | set(handles.FileExt_1,'String','.nc');
|
---|
[86] | 3512 | if ~isempty(SubDir_1) && ~strcmp(SubDir_1,'''')&& ~strcmp(SubDir_1,'"')&& ~strcmp(SubDir_1(1),'/')
|
---|
[2] | 3513 | SubDir_1=['/' SubDir_1];
|
---|
| 3514 | end
|
---|
| 3515 | set(handles.SubDir_1,'String',SubDir_1);
|
---|
| 3516 | end
|
---|
| 3517 | if isequal(field,'vort') | isequal(field,'div') | isequal(field,'strain')
|
---|
| 3518 | set(handles.civ1_1,'BackgroundColor',[0.702 0.702 0.702]) % put their color to grey
|
---|
| 3519 | set(handles.civ2_1,'BackgroundColor',[0.702 0.702 0.702])
|
---|
| 3520 | set(handles.interp1_1,'BackgroundColor',[0.702 0.702 0.702])
|
---|
| 3521 | set(handles.interp2_1,'BackgroundColor',[0.702 0.702 0.702])
|
---|
| 3522 | elseif isequal(field_1,'more...'); %add new item to the menu
|
---|
| 3523 | set(handles.civ1_1,'BackgroundColor',[0.702 0.702 0.702]) % put their color to grey
|
---|
| 3524 | set(handles.civ2_1,'BackgroundColor',[0.702 0.702 0.702])
|
---|
| 3525 | str=calc_field;%get the list of available scalars by the function calc_scal
|
---|
| 3526 | [ind_answer,v] = listdlg('PromptString','Select a file:',...
|
---|
| 3527 | 'SelectionMode','single',...
|
---|
| 3528 | 'ListString',str);
|
---|
| 3529 | % edit the choice in the field and action menu
|
---|
| 3530 | scalar=cell2mat(str(ind_answer));
|
---|
| 3531 | menu=update_menu(handles.Fields_1,scalar);
|
---|
| 3532 | set(handles.Fields_1,'String',menu);% store the selected scalar type
|
---|
| 3533 | end
|
---|
| 3534 | end
|
---|
| 3535 | str1=get(handles.i1,'String');
|
---|
| 3536 | str2=get(handles.i2,'String');
|
---|
| 3537 | str_a=get(handles.j1,'String');
|
---|
| 3538 | str_b=get(handles.j2,'String');
|
---|
| 3539 | indices=name_generator('',str2num(str1),stra2num(str_a),'',NomTypeNew,1,str2num(str2),stra2num(str_b),'');
|
---|
| 3540 | set(handles.FileIndex_1,'String',indices)
|
---|
| 3541 | set(handles.FileIndex_1,'UserData',NomTypeNew)
|
---|
| 3542 |
|
---|
| 3543 | %common to Fields_Callback
|
---|
| 3544 | if isequal(field,'image')|isequal(field_1,'image')
|
---|
| 3545 | set(handles.npx_title,'Visible','on')% visible npx,pxcm... buttons
|
---|
| 3546 | set(handles.npy_title,'Visible','on')
|
---|
| 3547 | set(handles.npx,'Visible','on')
|
---|
| 3548 | set(handles.npy,'Visible','on')
|
---|
[81] | 3549 | % set(handles.fix_pair,'Value',0)
|
---|
[2] | 3550 | else
|
---|
| 3551 | set(handles.npx_title,'Visible','off')% visible npx,pxcm... buttons
|
---|
| 3552 | set(handles.npy_title,'Visible','off')
|
---|
| 3553 | set(handles.npx,'Visible','off')
|
---|
| 3554 | set(handles.npy,'Visible','off')
|
---|
[81] | 3555 | % set(handles.fix_pair,'Value',1)
|
---|
[2] | 3556 | end
|
---|
| 3557 | if isequal(field,'velocity')|isequal(field_1,'velocity');
|
---|
| 3558 | state_vect='on';
|
---|
| 3559 | else
|
---|
| 3560 | state_vect='off';
|
---|
| 3561 | end
|
---|
| 3562 | if ~isequal(field,'velocity')|(~isequal(field_1,'velocity')&~isequal(field_1,''));
|
---|
| 3563 | state_scal='on';
|
---|
| 3564 | else
|
---|
| 3565 | state_scal='off';
|
---|
| 3566 | end
|
---|
[59] | 3567 | set(handles.uvmat,'UserData',UvData)
|
---|
[2] | 3568 | setfield(handles);% update the field structure ('civ1'....)
|
---|
| 3569 | if ~isfield(UvData,'NewSeries')|isequal(UvData.NewSeries,0)
|
---|
| 3570 | run0_Callback(hObject, eventdata, handles)
|
---|
| 3571 | end
|
---|
| 3572 |
|
---|
[57] | 3573 | %------------------------------------------------------------------------
|
---|
| 3574 | % --- set the visibility of relevant velocity type menus:
|
---|
| 3575 | function set_veltype_display(handles,Civ)
|
---|
| 3576 | %------------------------------------------------------------------------
|
---|
[2] | 3577 | %Civ=0; all states 'off'
|
---|
| 3578 | %Civ=6; all states 'on'
|
---|
| 3579 | if isequal(Civ,0)
|
---|
| 3580 | imax=0;
|
---|
| 3581 | % set(handles(1),'Visible','on') % unvisible civ buttons
|
---|
| 3582 | % else
|
---|
| 3583 | % set(handles(1),'String','civ1')
|
---|
| 3584 | % end
|
---|
[57] | 3585 | elseif isequal(Civ,1) || isequal(Civ,2)
|
---|
[2] | 3586 | imax=1;
|
---|
[57] | 3587 | elseif isequal(Civ,3)
|
---|
[2] | 3588 | imax=3;
|
---|
[57] | 3589 | elseif isequal(Civ,4) || isequal(Civ,5)
|
---|
[2] | 3590 | imax=4;
|
---|
[57] | 3591 | elseif isequal(Civ,6) %patch2
|
---|
[2] | 3592 | imax=6;
|
---|
| 3593 | end
|
---|
| 3594 | for ibutton=1:imax;
|
---|
| 3595 | set(handles(ibutton),'Visible','on') % unvisible civ buttons
|
---|
| 3596 | end
|
---|
| 3597 | % for ibutton=max(imax+1,2):6;
|
---|
| 3598 | for ibutton=imax+1:6;
|
---|
| 3599 | set(handles(ibutton),'Visible','off') % unvisible civ buttons
|
---|
| 3600 | set(handles(ibutton),'Value',0)%unactivate unvisible buttons
|
---|
| 3601 | end
|
---|
| 3602 |
|
---|
| 3603 | %-------------------------------------------------------------------
|
---|
| 3604 | % --- Executes on button press in civ1.
|
---|
| 3605 | function civ1_Callback(hObject, eventdata, handles)
|
---|
| 3606 | %-------------------------------------------------------------------
|
---|
| 3607 | if get(handles.civ1,'Value')==1
|
---|
| 3608 | reset_vel_type([handles.interp1 handles.civ2 handles.filter1 handles.interp1 handles.interp2 handles.filter2],handles.civ1)
|
---|
| 3609 | else
|
---|
| 3610 | reset_vel_type([handles.civ1 handles.filter1 handles.interp1 handles.civ2 handles.interp2 handles.filter2])
|
---|
| 3611 | end
|
---|
| 3612 | run0_Callback(hObject, eventdata, handles)
|
---|
| 3613 |
|
---|
| 3614 | %-------------------------------------------------------------------
|
---|
| 3615 | % --- Executes on button press in interp1.
|
---|
| 3616 | function interp1_Callback(hObject, eventdata, handles)
|
---|
| 3617 | %-------------------------------------------------------------------
|
---|
| 3618 | if get(handles.interp1,'Value')==1
|
---|
| 3619 | reset_vel_type([handles.civ1 handles.civ2 handles.filter1 handles.interp2 handles.filter2],handles.interp1)
|
---|
| 3620 | else
|
---|
| 3621 | reset_vel_type([handles.civ1 handles.filter1 handles.interp1 handles.civ2 handles.interp2 handles.filter2])
|
---|
| 3622 | end
|
---|
| 3623 | run0_Callback(hObject, eventdata, handles)
|
---|
| 3624 |
|
---|
| 3625 | %-------------------------------------------------------------------
|
---|
| 3626 | % --- Executes on button press in filter1.
|
---|
| 3627 | function filter1_Callback(hObject, eventdata, handles)
|
---|
| 3628 | %-------------------------------------------------------------------
|
---|
| 3629 | if get(handles.filter1,'Value')==1
|
---|
| 3630 | reset_vel_type([handles.civ1 handles.civ2 handles.interp1 handles.interp2 handles.filter2],handles.filter1)
|
---|
| 3631 | else
|
---|
| 3632 | reset_vel_type([handles.civ1 handles.filter1 handles.interp1 handles.civ2 handles.interp2 handles.filter2])
|
---|
| 3633 | end
|
---|
| 3634 | run0_Callback(hObject, eventdata, handles)
|
---|
| 3635 |
|
---|
| 3636 | %-------------------------------------------------------------------
|
---|
| 3637 | % --- Executes on button press in civ2.
|
---|
| 3638 | function civ2_Callback(hObject, eventdata, handles)
|
---|
| 3639 | %-------------------------------------------------------------------
|
---|
| 3640 | if get(handles.civ2,'Value')==1
|
---|
| 3641 | reset_vel_type([handles.civ1 handles.filter1 handles.interp1 handles.interp2 handles.filter2],handles.civ2)
|
---|
| 3642 | else
|
---|
| 3643 | reset_vel_type([handles.civ1 handles.filter1 handles.interp1 handles.civ2 handles.interp2 handles.filter2])
|
---|
| 3644 | end
|
---|
| 3645 | run0_Callback(hObject, eventdata, handles)
|
---|
| 3646 |
|
---|
| 3647 | %-----------------------------------------
|
---|
| 3648 | % --- Executes on button press in interp2.
|
---|
| 3649 | %-------------------------------------------
|
---|
| 3650 | function interp2_Callback(hObject, eventdata, handles)
|
---|
| 3651 | if get(handles.interp2,'Value')==1
|
---|
| 3652 | reset_vel_type([handles.civ1 handles.filter1 handles.interp1 handles.civ2 handles.filter2],handles.interp2)
|
---|
| 3653 | else
|
---|
| 3654 | reset_vel_type([handles.civ1 handles.filter1 handles.interp1 handles.civ2 handles.interp2 handles.filter2])
|
---|
| 3655 | end
|
---|
| 3656 | run0_Callback(hObject, eventdata, handles)
|
---|
| 3657 | %---------------------------------------------
|
---|
| 3658 | % --- Executes on button press in filter2.
|
---|
| 3659 | %-------------------------------------------
|
---|
| 3660 | function filter2_Callback(hObject, eventdata, handles)
|
---|
| 3661 | if get(handles.filter2,'Value')==1
|
---|
| 3662 | reset_vel_type([handles.civ1 handles.filter1 handles.interp1 handles.civ2 handles.interp2],handles.filter2)
|
---|
| 3663 | else
|
---|
| 3664 | reset_vel_type([handles.civ1 handles.filter1 handles.interp1 handles.civ2 handles.interp2 handles.filter2])
|
---|
| 3665 | end
|
---|
| 3666 | run0_Callback(hObject, eventdata, handles)
|
---|
| 3667 |
|
---|
| 3668 | %---------------------------------------------
|
---|
| 3669 | function civ1_1_Callback(hObject, eventdata, handles)
|
---|
| 3670 | %---------------------------------------------
|
---|
| 3671 | if get(handles.civ1_1,'Value')==1
|
---|
| 3672 | reset_vel_type([handles.interp1_1 handles.civ2_1 handles.filter1_1 handles.interp1_1 handles.interp2_1 handles.filter2_1],handles.civ1_1)
|
---|
| 3673 | else
|
---|
| 3674 | reset_vel_type([handles.civ1_1 handles.filter1_1 handles.interp1_1 handles.civ2_1 handles.interp2_1 handles.filter2_1])
|
---|
| 3675 | end
|
---|
| 3676 | run0_Callback(hObject, eventdata, handles)
|
---|
| 3677 |
|
---|
| 3678 | %--------------------------------------------
|
---|
| 3679 | function interp1_1_Callback(hObject, eventdata, handles)
|
---|
| 3680 | %--------------------------------------------
|
---|
| 3681 | if get(handles.interp1_1,'Value')==1
|
---|
| 3682 | reset_vel_type([handles.civ1_1 handles.civ2_1 handles.filter1_1 handles.interp2_1 handles.filter2_1],handles.interp1_1)
|
---|
| 3683 | else
|
---|
| 3684 | reset_vel_type([handles.civ1_1 handles.filter1_1 handles.interp1_1 handles.civ2_1 handles.interp2_1 handles.filter2_1])
|
---|
| 3685 | end
|
---|
| 3686 | run0_Callback(hObject, eventdata, handles)
|
---|
| 3687 |
|
---|
| 3688 | %--------------------------------------------
|
---|
| 3689 | function filter1_1_Callback(hObject, eventdata, handles)
|
---|
| 3690 | %--------------------------------------------
|
---|
| 3691 | if get(handles.filter1_1,'Value')==1
|
---|
| 3692 | reset_vel_type([handles.interp1_1 handles.civ2_1 handles.interp1_1 handles.interp2_1 handles.filter2_1],handles.filter1_1)
|
---|
| 3693 | else
|
---|
| 3694 | reset_vel_type([handles.civ1_1 handles.filter1_1 handles.interp1_1 handles.civ2_1 handles.interp2_1 handles.filter2_1])
|
---|
| 3695 | end
|
---|
| 3696 | run0_Callback(hObject, eventdata, handles)
|
---|
| 3697 |
|
---|
| 3698 | %--------------------------------------------
|
---|
| 3699 | function civ2_1_Callback(hObject, eventdata, handles)
|
---|
| 3700 | %--------------------------------------------
|
---|
| 3701 | if get(handles.civ2_1,'Value')==1
|
---|
| 3702 | reset_vel_type([handles.civ1_1 handles.interp1_1 handles.filter1_1 handles.interp2_1 handles.filter2_1],handles.civ2_1)
|
---|
| 3703 | else
|
---|
| 3704 | reset_vel_type([handles.civ1_1 handles.filter1_1 handles.interp1_1 handles.civ2_1 handles.interp2_1 handles.filter2_1])
|
---|
| 3705 | end
|
---|
| 3706 | run0_Callback(hObject, eventdata, handles)
|
---|
| 3707 |
|
---|
| 3708 | %--------------------------------------------
|
---|
| 3709 | function interp2_1_Callback(hObject, eventdata, handles)
|
---|
| 3710 | %--------------------------------------------
|
---|
| 3711 | if get(handles.interp2_1,'Value')==1
|
---|
| 3712 | reset_vel_type([handles.civ1_1 handles.civ2_1 handles.filter1_1 handles.interp1_1 handles.filter2_1],handles.interp2_1)
|
---|
| 3713 | else
|
---|
| 3714 | reset_vel_type([handles.civ1_1 handles.filter1_1 handles.interp1_1 handles.civ2_1 handles.interp2_1 handles.filter2_1])
|
---|
| 3715 | end
|
---|
| 3716 | run0_Callback(hObject, eventdata, handles)
|
---|
| 3717 |
|
---|
| 3718 | %--------------------------------------------
|
---|
| 3719 | function filter2_1_Callback(hObject, eventdata, handles)
|
---|
| 3720 | %--------------------------------------------
|
---|
| 3721 | if get(handles.filter2_1,'Value')==1
|
---|
| 3722 | reset_vel_type([handles.civ1_1 handles.interp1_1 handles.civ2_1 handles.filter1_1 handles.interp1_1 handles.interp2_1],handles.filter2_1)
|
---|
| 3723 | else
|
---|
| 3724 | reset_vel_type([handles.civ1_1 handles.filter1_1 handles.interp1_1 handles.civ2_1 handles.interp2_1 handles.filter2_1])
|
---|
| 3725 | end
|
---|
| 3726 | run0_Callback(hObject, eventdata, handles)
|
---|
| 3727 |
|
---|
| 3728 | %-----------------------------------------------
|
---|
| 3729 | % --- reset civ buttons
|
---|
| 3730 | function reset_vel_type(handles_civ0,handle1)
|
---|
| 3731 | for ibutton=1:length(handles_civ0)
|
---|
| 3732 | set(handles_civ0(ibutton),'BackgroundColor',[0.831 0.816 0.784])
|
---|
| 3733 | set(handles_civ0(ibutton),'Value',0)
|
---|
| 3734 | end
|
---|
| 3735 | if exist('handle1','var')%handles of selected button
|
---|
| 3736 | set(handle1,'BackgroundColor',[1 1 0])
|
---|
| 3737 | end
|
---|
| 3738 |
|
---|
| 3739 | %-------------------------------------------------------
|
---|
| 3740 | % --- Executes on button press in MENUVOLUME.
|
---|
| 3741 | %-------------------------------------------------------
|
---|
| 3742 | function VOLUME_Callback(hObject, eventdata, handles)
|
---|
| 3743 | %errordlg('command VOL not implemented yet')
|
---|
| 3744 | if ishandle(handles.UVMAT_title)
|
---|
| 3745 | delete(handles.UVMAT_title)
|
---|
| 3746 | end
|
---|
[61] | 3747 | UvData=get(handles.uvmat,'UserData');%read UvData properties stored on the uvmat interface
|
---|
[2] | 3748 | if isequal(get(handles.VOLUME,'Value'),1)
|
---|
| 3749 | set(handles.zoom,'Value',0)
|
---|
| 3750 | set(handles.zoom,'BackgroundColor',[0.7 0.7 0.7])
|
---|
| 3751 | set(handles.edit_vect,'Value',0)
|
---|
| 3752 | edit_vect_Callback(hObject, eventdata, handles)
|
---|
[155] | 3753 | set(handles.edit_object,'Value',0)
|
---|
| 3754 | set(handles.edit_object,'BackgroundColor',[0.7 0.7 0.7])
|
---|
[61] | 3755 | % set(handles.cal,'Value',0)
|
---|
| 3756 | % set(handles.cal,'BackgroundColor',[0 1 0])
|
---|
[2] | 3757 | set(handles.edit_vect,'Value',0)
|
---|
| 3758 | edit_vect_Callback(hObject, eventdata, handles)
|
---|
| 3759 | %initiate set_object GUI
|
---|
| 3760 | data.TITLE='VOLUME';
|
---|
| 3761 | if isfield(UvData,'CoordType')
|
---|
| 3762 | data.CoordType=UvData.CoordType;
|
---|
| 3763 | end
|
---|
| 3764 | if isfield(UvData,'Mesh')&~isempty(UvData.Mesh)
|
---|
| 3765 | data.RangeY=UvData.Mesh;
|
---|
| 3766 | data.RangeX=UvData.Mesh;
|
---|
| 3767 | data.DX=UvData.Mesh;
|
---|
| 3768 | data.DY=UvData.Mesh;
|
---|
| 3769 | elseif isfield(UvData.Field,'AX')&isfield(UvData.Field,'AY')& isfield(UvData.Field,'A')%only image
|
---|
| 3770 | np=size(UvData.Field.A);
|
---|
| 3771 | meshx=(UvData.Field.AX(end)-UvData.Field.AX(1))/np(2);
|
---|
| 3772 | meshy=abs(UvData.Field.AY(end)-UvData.Field.AY(1))/np(1);
|
---|
| 3773 | data.RangeY=max(meshx,meshy);
|
---|
| 3774 | data.RangeX=max(meshx,meshy);
|
---|
| 3775 | data.DX=max(meshx,meshy);
|
---|
| 3776 | end
|
---|
| 3777 | data.ParentButton=handles.VOLUME;
|
---|
| 3778 | PlotHandles=get_plot_handles(handles);%get the handles of the interface elements setting the plotting parameters
|
---|
| 3779 | [hset_object,UvData.sethandles]=set_object(data,PlotHandles);% call the set_object interface with action on haxes,
|
---|
[155] | 3780 | % associate the set_object interface handle to the plotting axes
|
---|
[2] | 3781 | if isfield(UvData,'SetObjectOrigin')
|
---|
| 3782 | pos_uvmat=get(huvmat,'Position');
|
---|
| 3783 | pos_set_object(1:2)=UvData.SetObjectOrigin + pos_uvmat(1:2);
|
---|
| 3784 | pos_set_object(3:4)=UvData.SetObjectSize .* pos_uvmat(3:4);
|
---|
| 3785 | set(hset_object,'Position',pos_set_object)
|
---|
| 3786 | end
|
---|
| 3787 | UvData.MouseAction='create_object';
|
---|
| 3788 | else
|
---|
| 3789 | set(handles.VOLUME,'BackgroundColor',[0 1 0])
|
---|
| 3790 | UvData.MouseAction='none';
|
---|
| 3791 | end
|
---|
| 3792 | set(huvmat,'UserData',UvData)
|
---|
| 3793 |
|
---|
| 3794 | %-------------------------------------------------------
|
---|
| 3795 | function edit_vect_Callback(hObject, eventdata, handles)
|
---|
| 3796 | %-------------------------------------------------------
|
---|
[155] | 3797 | %
|
---|
| 3798 | % UvData=get(handles.uvmat,'UserData');%read UvData properties stored on the uvmat interface
|
---|
[2] | 3799 | if isequal(get(handles.edit_vect,'Value'),1)
|
---|
[55] | 3800 | test_civ2=isequal(get(handles.civ2,'BackgroundColor'),[1 1 0]);
|
---|
| 3801 | test_civ1=isequal(get(handles.civ1,'BackgroundColor'),[1 1 0]);
|
---|
| 3802 | if ~test_civ2 && ~test_civ1
|
---|
| 3803 | msgbox_uvmat('ERROR','manual correction only possible for CIV1 or CIV2 velocity fields')
|
---|
| 3804 | end
|
---|
[2] | 3805 | set(handles.record,'Visible','on')
|
---|
| 3806 | set(handles.edit_vect,'BackgroundColor',[1 1 0])
|
---|
[155] | 3807 | set(handles.edit_object,'Value',0)
|
---|
[61] | 3808 | set(handles.zoom,'Value',0)
|
---|
| 3809 | set(handles.zoom,'BackgroundColor',[0.7 0.7 0.7])
|
---|
| 3810 | % set(handles.create,'Value',0)
|
---|
| 3811 | % set(handles.create,'BackgroundColor',[0 1 0])
|
---|
[155] | 3812 | set(handles.edit_object,'BackgroundColor',[0.7 0.7 0.7])
|
---|
[2] | 3813 | set(gcf,'Pointer','arrow')
|
---|
[155] | 3814 | % UvData.MouseAction='edit_vect';
|
---|
[2] | 3815 | else
|
---|
| 3816 | set(handles.record,'Visible','off')
|
---|
| 3817 | set(handles.edit_vect,'BackgroundColor',[0.7 0.7 0.7])
|
---|
[155] | 3818 | % UvData.MouseAction='none';
|
---|
[2] | 3819 | end
|
---|
[155] | 3820 | % set(handles.uvmat,'UserData',UvData)
|
---|
[2] | 3821 |
|
---|
| 3822 | %----------------------------------------------
|
---|
| 3823 | function save_mask_Callback(hObject, eventdata, handles)
|
---|
| 3824 | %-----------------------------------------------------------------------
|
---|
[82] | 3825 | UvData=get(handles.uvmat,'UserData');
|
---|
[2] | 3826 |
|
---|
| 3827 | flag=1;
|
---|
| 3828 | npx=size(UvData.Field.A,2);
|
---|
| 3829 | npy=size(UvData.Field.A,1);
|
---|
| 3830 | xi=[0.5:npx-0.5];
|
---|
| 3831 | yi=[0.5:npy-0.5];
|
---|
| 3832 | [Xi,Yi]=meshgrid(xi,yi);
|
---|
| 3833 | if isfield(UvData,'Object')
|
---|
| 3834 | for iobj=1:length(UvData.Object)
|
---|
| 3835 | ObjectData=UvData.Object{iobj};
|
---|
| 3836 | if isfield(ObjectData,'ProjMode') &&(isequal(ObjectData.ProjMode,'mask_inside')||isequal(ObjectData.ProjMode,'mask_outside'));
|
---|
| 3837 | flagobj=1;
|
---|
| 3838 | testphys=0; %coordinates in pixels by default
|
---|
| 3839 | if isfield(ObjectData,'CoordType') && isequal(ObjectData.CoordType,'phys')
|
---|
| 3840 | if isfield(UvData,'XmlData')&& isfield(UvData.XmlData,'GeometryCalib')
|
---|
| 3841 | Calib=UvData.XmlData.GeometryCalib;
|
---|
| 3842 | testphys=1;
|
---|
| 3843 | end
|
---|
| 3844 | end
|
---|
| 3845 | if isfield(ObjectData,'Coord')& isfield(ObjectData,'Style')
|
---|
| 3846 | if isequal(ObjectData.Style,'polygon')
|
---|
| 3847 | X=ObjectData.Coord(:,1);
|
---|
| 3848 | Y=ObjectData.Coord(:,2);
|
---|
| 3849 | if testphys
|
---|
| 3850 | [X,Y]=px_XYZ(Calib,X,Y,0);% to generalise with 3D cases
|
---|
| 3851 | end
|
---|
[82] | 3852 | flagobj=~inpolygon(Xi,Yi,X',Y');%=0 inside the polygon, 1 outside
|
---|
[2] | 3853 | elseif isequal(ObjectData.Style,'ellipse')
|
---|
| 3854 | if testphys
|
---|
| 3855 | %[X,Y]=px_XYZ(Calib,X,Y,0);% TODO:create a polygon boundary and transform to phys
|
---|
| 3856 | end
|
---|
| 3857 | RangeX=max(ObjectData.RangeX);
|
---|
| 3858 | RangeY=max(ObjectData.RangeY);
|
---|
| 3859 | X2Max=RangeX*RangeX;
|
---|
| 3860 | Y2Max=RangeY*RangeY;
|
---|
| 3861 | distX=(Xi-ObjectData.Coord(1,1));
|
---|
| 3862 | distY=(Yi-ObjectData.Coord(1,2));
|
---|
| 3863 | flagobj=(distX.*distX/X2Max+distY.*distY/Y2Max)>1;
|
---|
| 3864 | elseif isequal(ObjectData.Style,'rectangle')
|
---|
| 3865 | if testphys
|
---|
| 3866 | %[X,Y]=px_XYZ(Calib,X,Y,0);% TODO:create a polygon boundary and transform to phys
|
---|
| 3867 | end
|
---|
| 3868 | distX=abs(Xi-ObjectData.Coord(1,1));
|
---|
| 3869 | distY=abs(Yi-ObjectData.Coord(1,2));
|
---|
| 3870 | flagobj=distX>max(ObjectData.RangeX) | distY>max(ObjectData.RangeY);
|
---|
| 3871 | end
|
---|
| 3872 | if isequal(ObjectData.ProjMode,'mask_outside')
|
---|
| 3873 | flagobj=~flagobj;
|
---|
| 3874 | end
|
---|
| 3875 | flag=flag & flagobj;
|
---|
| 3876 | end
|
---|
| 3877 | end
|
---|
| 3878 | end
|
---|
| 3879 | end
|
---|
| 3880 | % flag=~flag;
|
---|
| 3881 | %mask name
|
---|
| 3882 | RootPath=get(handles.RootPath,'String');
|
---|
| 3883 | RootFile=get(handles.RootFile,'String');
|
---|
| 3884 | if ~isempty(RootFile)&(isequal(RootFile(1),'/')| isequal(RootFile(1),'\'))
|
---|
| 3885 | RootFile(1)=[];
|
---|
| 3886 | end
|
---|
| 3887 | filebase=fullfile(RootPath,RootFile);
|
---|
| 3888 | list=get(handles.masklevel,'String');
|
---|
| 3889 | masknumber=num2str(length(list));
|
---|
| 3890 | maskindex=get(handles.masklevel,'Value');
|
---|
| 3891 | mask_name=name_generator([filebase '_' masknumber 'mask'],maskindex,1,'.png','_i');
|
---|
| 3892 | imflag=uint8(255*(0.392+0.608*flag));% =100 for flag=0 (vectors not computed when 20<imflag<200)
|
---|
| 3893 | imflag=flipdim(imflag,1);
|
---|
| 3894 | % imflag=uint8(255*flag);% =0 for flag=0 (vectors=0 when 20<imflag<200)
|
---|
[38] | 3895 | msgbox_uvmat('CONFIRMATION',[mask_name ' saved'])
|
---|
[2] | 3896 | imwrite(imflag,mask_name,'BitDepth',8);
|
---|
| 3897 |
|
---|
| 3898 | %display the mask
|
---|
| 3899 | %update_mask(handles,num_i1,num_j1)
|
---|
| 3900 | figure;
|
---|
| 3901 | vec=linspace(0,1,256);%define a linear greyscale colormap
|
---|
| 3902 | map=[vec' vec' vec'];
|
---|
| 3903 | colormap(map)
|
---|
| 3904 |
|
---|
| 3905 | image(imflag);
|
---|
| 3906 |
|
---|
| 3907 | %-------------------------------------------------------------------
|
---|
| 3908 | %-------------------------------------------------------------------
|
---|
| 3909 | % - FUNCTIONS FOR SETTING PLOTTING PARAMETERS
|
---|
| 3910 |
|
---|
| 3911 | %------------------------------------------------------------------
|
---|
| 3912 |
|
---|
| 3913 |
|
---|
| 3914 |
|
---|
| 3915 | %------------------------------------------------------------------
|
---|
| 3916 | % --- Executes on selection change in col_vec: choice of the color code.
|
---|
| 3917 | %
|
---|
| 3918 | function col_vec_Callback(hObject, eventdata, handles)
|
---|
| 3919 | %------------------------------------------------------------------
|
---|
| 3920 | % edit the choice for color code
|
---|
| 3921 | list_code=get(handles.col_vec,'String');% list menu fields
|
---|
| 3922 | index_code=get(handles.col_vec,'Value');% selected string index
|
---|
| 3923 | col_code= list_code{index_code(1)}; % selected field
|
---|
[122] | 3924 | if isequal(col_code,'black') || isequal(col_code,'white')
|
---|
[2] | 3925 | set(handles.slider1,'Visible','off')
|
---|
| 3926 | set(handles.slider2,'Visible','off')
|
---|
| 3927 | set(handles.colcode1,'Visible','off')
|
---|
| 3928 | set(handles.colcode2,'Visible','off')
|
---|
| 3929 | set(handles.AutoVecColor,'Visible','off')
|
---|
| 3930 | set_vec_col_bar(handles)
|
---|
| 3931 | else
|
---|
| 3932 | set(handles.slider1,'Visible','on')
|
---|
| 3933 | set(handles.slider2,'Visible','on')
|
---|
| 3934 | set(handles.colcode1,'Visible','on')
|
---|
| 3935 | set(handles.colcode2,'Visible','on')
|
---|
| 3936 | set(handles.AutoVecColor,'Visible','on')
|
---|
| 3937 | if isequal(col_code,'ima_cor')
|
---|
| 3938 | set(handles.AutoVecColor,'Value',0)%fixed scale by default
|
---|
| 3939 | set(handles.vec_col_bar,'Value',0)% 3 colors r,g,b by default
|
---|
| 3940 | set(handles.slider1,'Min',0);
|
---|
| 3941 | set(handles.slider1,'Max',1);
|
---|
| 3942 | set(handles.slider2,'Min',0);
|
---|
| 3943 | set(handles.slider2,'Max',1);
|
---|
| 3944 | % set(handles.min_title_vec,'String','0')
|
---|
| 3945 | set(handles.max_vec,'String','1')
|
---|
| 3946 | set(handles.colcode1,'String','0.333')
|
---|
| 3947 | colcode1_Callback(hObject, eventdata, handles)
|
---|
| 3948 | set(handles.colcode2,'String','0.666')
|
---|
| 3949 | colcode2_Callback(hObject, eventdata, handles)
|
---|
| 3950 | else
|
---|
| 3951 | set(handles.AutoVecColor,'Value',1)%auto scale between min,max by default
|
---|
| 3952 | set(handles.vec_col_bar,'Value',1)% colormap 'jet' by default
|
---|
| 3953 | minval=get(handles.slider1,'Min');
|
---|
| 3954 | maxval=get(handles.slider1,'Max');
|
---|
| 3955 | set(handles.slider1,'Value',minval)
|
---|
| 3956 | set(handles.slider2,'Value',maxval)
|
---|
| 3957 | set_vec_col_bar(handles)
|
---|
| 3958 | end
|
---|
| 3959 | % slider_update(handles)
|
---|
| 3960 | end
|
---|
| 3961 | %replot the current graph
|
---|
| 3962 | run0_Callback(hObject, eventdata, handles)
|
---|
| 3963 |
|
---|
| 3964 |
|
---|
| 3965 | %----------------------------------------------------------------
|
---|
| 3966 | % -- Executes on slider movement to set the color code
|
---|
| 3967 | %
|
---|
| 3968 | function slider1_Callback(hObject, eventdata, handles)
|
---|
| 3969 | %------------------------------------------------------------------
|
---|
| 3970 | slider1=get(handles.slider1,'Value');
|
---|
| 3971 | min_val=str2num(get(handles.min_vec,'String'));
|
---|
| 3972 | max_val=str2num(get(handles.max_vec,'String'));
|
---|
| 3973 | col=min_val+(max_val-min_val)*slider1;
|
---|
| 3974 | set(handles.colcode1,'String',num2str(col))
|
---|
| 3975 | if(get(handles.slider2,'Value') < col)%move also the second slider at the same value if needed
|
---|
| 3976 | set(handles.slider2,'Value',col)
|
---|
| 3977 | set(handles.colcode2,'String',num2str(col))
|
---|
| 3978 | end
|
---|
| 3979 | colcode1_Callback(hObject, eventdata, handles)
|
---|
| 3980 |
|
---|
| 3981 | %----------------------------------------------------------------
|
---|
| 3982 | % Executes on slider movement to set the color code
|
---|
| 3983 | %----------------------------------------------------------------
|
---|
| 3984 | function slider2_Callback(hObject, eventdata, handles)
|
---|
| 3985 | slider2=get(handles.slider2,'Value');
|
---|
| 3986 | min_val=str2num(get(handles.min_vec,'String'));
|
---|
| 3987 | max_val=str2num(get(handles.max_vec,'String'));
|
---|
| 3988 | col=min_val+(max_val-min_val)*slider2;
|
---|
| 3989 | set(handles.colcode2,'String',num2str(col))
|
---|
| 3990 | if(get(handles.slider1,'Value') > col)%move also the first slider at the same value if needed
|
---|
| 3991 | set(handles.slider1,'Value',col)
|
---|
| 3992 | set(handles.colcode1,'String',num2str(col))
|
---|
| 3993 | end
|
---|
| 3994 | colcode2_Callback(hObject, eventdata, handles)
|
---|
| 3995 |
|
---|
| 3996 | %----------------------------------------------------------------
|
---|
| 3997 | %execute on return carriage on the edit box corresponding to slider 1
|
---|
| 3998 | %----------------------------------------------------------------
|
---|
| 3999 | function colcode1_Callback(hObject, eventdata, handles)
|
---|
| 4000 | % col=str2num(get(handles.colcode1,'String'));
|
---|
| 4001 | % set(handles.slider1,'Value',col)
|
---|
| 4002 | set_vec_col_bar(handles)
|
---|
[89] | 4003 | update_plot(handles);
|
---|
[2] | 4004 |
|
---|
| 4005 | %----------------------------------------------------------------
|
---|
| 4006 | %execute on return carriage on the edit box corresponding to slider 2
|
---|
| 4007 | %----------------------------------------------------------------
|
---|
| 4008 | function colcode2_Callback(hObject, eventdata, handles)
|
---|
| 4009 | % col=str2num(get(handles.colcode2,'String'));
|
---|
| 4010 | % set(handles.slider2,'Value',col)
|
---|
| 4011 | % slider2_Callback(hObject, eventdata, handles)
|
---|
| 4012 | set_vec_col_bar(handles)
|
---|
[89] | 4013 | update_plot(handles);
|
---|
[2] | 4014 | %------------------------------------------------------------
|
---|
| 4015 | %update the slider values after displaying vectors
|
---|
| 4016 | %--------------------------------------------------------
|
---|
| 4017 | % function slider_update(handles,auto,minC,colcode1,colcode2,maxC)
|
---|
| 4018 | % set(handles.slider1,'Min',minC)
|
---|
| 4019 | % set(handles.slider1,'Max',maxC)
|
---|
| 4020 | % set(handles.slider2,'Min',minC)
|
---|
| 4021 | % set(handles.slider2,'Max',maxC)
|
---|
| 4022 | % set(handles.min_title_vec,'String',num2str(minC))
|
---|
| 4023 | % set(handles.max_vec,'String',num2str(maxC))
|
---|
| 4024 | % if auto
|
---|
| 4025 | % set(handles.colcode1,'String',num2str(colcode1,3))%update display
|
---|
| 4026 | % set(handles.colcode2,'String',num2str(colcode2,3))
|
---|
| 4027 | % end
|
---|
| 4028 | % set(handles.slider1,'Value',colcode1)%update slider with constant display
|
---|
| 4029 | % set(handles.slider2,'Value',colcode2)
|
---|
| 4030 | % set_vec_col_bar(handles)
|
---|
| 4031 |
|
---|
| 4032 |
|
---|
| 4033 | %-------------------------------------------------------
|
---|
| 4034 | % --- Executes on button press in AutoVecColor.
|
---|
| 4035 | %-------------------------------------------------------
|
---|
| 4036 | function vec_col_bar_Callback(hObject, eventdata, handles)
|
---|
| 4037 | set_vec_col_bar(handles)
|
---|
| 4038 |
|
---|
| 4039 | %-------------------------------------------------------------
|
---|
[39] | 4040 | % --- Executes on selection change in transform_fct.
|
---|
| 4041 | function transform_fct_Callback(hObject, eventdata, handles)
|
---|
[2] | 4042 | %-------------------------------------------------------------
|
---|
[39] | 4043 | global nb_builtin
|
---|
| 4044 |
|
---|
| 4045 | huvmat=get(handles.transform_fct,'parent');
|
---|
| 4046 | menu=get(handles.transform_fct,'String');
|
---|
| 4047 | ind_coord=get(handles.transform_fct,'Value');
|
---|
[2] | 4048 | coord_option=menu{ind_coord};
|
---|
[39] | 4049 | list_transform=get(handles.transform_fct,'UserData');
|
---|
[40] | 4050 | ff=functions(list_transform{end});
|
---|
[2] | 4051 | if isequal(coord_option,'more...');
|
---|
| 4052 | coord_fct='';
|
---|
| 4053 | prompt = {'Enter the name of the transform function'};
|
---|
| 4054 | dlg_title = 'user defined transform';
|
---|
| 4055 | num_lines= 1;
|
---|
[89] | 4056 | [FileName, PathName] = uigetfile( ...
|
---|
[2] | 4057 | {'*.m', ' (*.m)';
|
---|
| 4058 | '*.m', '.m files '; ...
|
---|
| 4059 | '*.*', 'All Files (*.*)'}, ...
|
---|
[39] | 4060 | 'Pick a file', ff.file);
|
---|
[2] | 4061 | if isequal(PathName(end),'/')||isequal(PathName(end),'\')
|
---|
| 4062 | PathName(end)=[];
|
---|
| 4063 | end
|
---|
[39] | 4064 | transform_selected =fullfile(PathName,FileName);
|
---|
| 4065 | if ~exist(transform_selected,'file')
|
---|
| 4066 | return
|
---|
| 4067 | end
|
---|
| 4068 | [ppp,transform,ext_fct]=fileparts(FileName);% removes extension .m
|
---|
| 4069 | if ~isequal(ext_fct,'.m')
|
---|
| 4070 | msgbox_uvmat('ERROR','a Matlab function .m must be introduced');
|
---|
| 4071 | return
|
---|
| 4072 | end
|
---|
| 4073 | menu=update_menu(handles.transform_fct,transform);%add the selected fct to the menu
|
---|
| 4074 | ind_coord=get(handles.transform_fct,'Value');
|
---|
| 4075 | addpath(PathName)
|
---|
| 4076 | list_transform{ind_coord}=str2func(transform);% create the function handle corresponding to the newly seleced function
|
---|
| 4077 | set(handles.transform_fct,'UserData',list_transform)
|
---|
| 4078 | rmpath(PathName)
|
---|
| 4079 | % save the new menu in the personal file 'uvmat_perso.mat'
|
---|
| 4080 | dir_perso=prefdir;%personal Matalb directory
|
---|
| 4081 | profil_perso=fullfile(dir_perso,'uvmat_perso.mat');
|
---|
| 4082 | if exist(profil_perso,'file')
|
---|
| 4083 | for ilist=nb_builtin+1:numel(list_transform)
|
---|
| 4084 | ff=functions(list_transform{ilist});
|
---|
| 4085 | transform_fct{ilist-nb_builtin}=ff.file;
|
---|
| 4086 | end
|
---|
| 4087 | save (profil_perso,'transform_fct','-append'); %store the root name for future opening of uvmat
|
---|
| 4088 | end
|
---|
[2] | 4089 | end
|
---|
| 4090 |
|
---|
| 4091 | %check the current path to the selected function
|
---|
[40] | 4092 | if isa(list_transform{ind_coord},'function_handle')
|
---|
| 4093 | func=functions(list_transform{ind_coord});
|
---|
| 4094 | set(handles.path_transform,'String',fileparts(func.file)); %show the path to the senlected function
|
---|
| 4095 | else
|
---|
| 4096 | set(handles.path_transform,'String','')
|
---|
| 4097 | end
|
---|
[71] | 4098 |
|
---|
[2] | 4099 | set(handles.FixedLimits,'Value',0)
|
---|
| 4100 | set(handles.FixedLimits,'BackgroundColor',[0.7 0.7 0.7])
|
---|
| 4101 |
|
---|
| 4102 | UvData=get(huvmat,'UserData');
|
---|
| 4103 |
|
---|
| 4104 | %delete drawn objects
|
---|
| 4105 | hother=findobj('Tag','proj_object');%find all the proj objects
|
---|
| 4106 | for iobj=1:length(hother)
|
---|
| 4107 | delete_object(hother(iobj))
|
---|
| 4108 | end
|
---|
| 4109 | hother=findobj('Tag','DeformPoint');%find all the proj objects
|
---|
| 4110 | for iobj=1:length(hother)
|
---|
| 4111 | delete_object(hother(iobj))
|
---|
| 4112 | end
|
---|
| 4113 | hh=findobj('Tag','calib_points');
|
---|
| 4114 | if ~isempty(hh)
|
---|
| 4115 | delete(hh)
|
---|
| 4116 | end
|
---|
| 4117 | hhh=findobj('Tag','calib_marker');
|
---|
| 4118 | if ~isempty(hhh)
|
---|
| 4119 | delete(hhh)
|
---|
| 4120 | end
|
---|
| 4121 | if isfield(UvData,'Object')
|
---|
[71] | 4122 | UvData.Object=UvData.Object(1);
|
---|
[2] | 4123 | end
|
---|
[71] | 4124 | list_object=get(handles.list_object_1,'String');
|
---|
| 4125 | set(handles.list_object_1,'Value',1)
|
---|
| 4126 | set(handles.list_object_1,'String',list_object(1))
|
---|
| 4127 | set(handles.list_object_2,'Value',2)
|
---|
| 4128 | set(handles.list_object_2,'String',[list_object(1);{'...'}])
|
---|
| 4129 | list_object_2_Callback(hObject, eventdata, handles)
|
---|
[2] | 4130 |
|
---|
| 4131 | %delete mask if it is displayed
|
---|
| 4132 | if isequal(get(handles.mask_test,'Value'),1)%if the mask option is on
|
---|
| 4133 | UvData=rmfield(UvData,'MaskName'); %will impose mask refresh
|
---|
| 4134 | end
|
---|
| 4135 | set(huvmat,'UserData',UvData)
|
---|
| 4136 | run0_Callback(hObject, eventdata, handles)
|
---|
| 4137 |
|
---|
| 4138 | %--------------------------------------------
|
---|
| 4139 | function histo1_menu_Callback(hObject, eventdata, handles)
|
---|
| 4140 | %--------------------------------------------
|
---|
| 4141 | %plot first histo
|
---|
| 4142 | huvmat=get(handles.histo1_menu,'parent');
|
---|
| 4143 | histo_menu=get(handles.histo1_menu,'String');
|
---|
| 4144 | histo_value=get(handles.histo1_menu,'Value');
|
---|
| 4145 | FieldName=histo_menu{histo_value};
|
---|
[128] | 4146 | % UvData=get(huvmat,'UserData');
|
---|
[2] | 4147 | update_histo(handles.histo_u,huvmat,FieldName)
|
---|
| 4148 |
|
---|
| 4149 | %----------------------------------------------
|
---|
| 4150 | function histo2_menu_Callback(hObject, eventdata, handles)
|
---|
| 4151 | %----------------------------------------------
|
---|
| 4152 | %plot second histo
|
---|
| 4153 | huvmat=get(handles.histo2_menu,'parent');
|
---|
| 4154 | histo_menu=get(handles.histo2_menu,'String');
|
---|
| 4155 | histo_value=get(handles.histo2_menu,'Value');
|
---|
| 4156 | FieldName=histo_menu{histo_value};
|
---|
[128] | 4157 | % UvData=get(huvmat,'UserData');
|
---|
[2] | 4158 | update_histo(handles.histo_v,huvmat,FieldName)
|
---|
| 4159 |
|
---|
| 4160 |
|
---|
| 4161 | %--------------------------------------------
|
---|
| 4162 | %read the field .Fieldname stored in UvData and plot its histogram
|
---|
| 4163 | function update_histo(haxes,huvmat,FieldName)
|
---|
| 4164 | UvData=get(huvmat,'UserData');
|
---|
| 4165 | if ~isfield(UvData.Field,FieldName)
|
---|
| 4166 | msgbox_uvmat('ERROR',['no field ' FieldName ' for histogram'])
|
---|
| 4167 | return
|
---|
| 4168 | end
|
---|
| 4169 | Field=UvData.Field;
|
---|
| 4170 | FieldHisto=eval(['Field.' FieldName]);
|
---|
[128] | 4171 | if isfield(Field,'FF') && ~isempty(Field.FF) && isequal(size(Field.FF),size(FieldHisto))
|
---|
[2] | 4172 | indsel=find(Field.FF==0);%find values marked as false
|
---|
| 4173 | if ~isempty(indsel)
|
---|
| 4174 | FieldHisto=FieldHisto(indsel);
|
---|
| 4175 | end
|
---|
| 4176 | end
|
---|
| 4177 | if isempty(Field)
|
---|
| 4178 | msgbox_uvmat('ERROR',['empty field ' FieldName])
|
---|
| 4179 | else
|
---|
| 4180 | nxy=size(FieldHisto);
|
---|
| 4181 | Amin=double(min(min(min(FieldHisto))));%min of image
|
---|
| 4182 | Amax=double(max(max(max(FieldHisto))));%max of image
|
---|
| 4183 | if isequal(Amin,Amax)
|
---|
| 4184 | Histo.Txt=['uniform field =' num2str(Amin)];
|
---|
| 4185 | else
|
---|
| 4186 | Histo.ListVarName={FieldName,'histo'};
|
---|
| 4187 | if numel(nxy)==2
|
---|
| 4188 | Histo.VarDimName={FieldName,FieldName}; %dimensions for the histogram
|
---|
| 4189 | else %color images
|
---|
| 4190 | Histo.VarDimName={FieldName,{FieldName,'rgb'}}; %dimensions for the histogram
|
---|
| 4191 | end
|
---|
| 4192 | %unit
|
---|
| 4193 | units=[]; %default
|
---|
| 4194 | for ivar=1:numel(Field.ListVarName)
|
---|
| 4195 | if strcmp(Field.ListVarName{ivar},FieldName)
|
---|
| 4196 | if isfield(Field,'VarAttribute') && numel(Field.VarAttribute)>=ivar && isfield(Field.VarAttribute{ivar},'units')
|
---|
| 4197 | units=Field.VarAttribute{ivar}.units;
|
---|
| 4198 | break
|
---|
| 4199 | end
|
---|
| 4200 | end
|
---|
| 4201 | end
|
---|
| 4202 | if ~isempty(units)
|
---|
| 4203 | Histo.VarAttribute{1}.units=units;
|
---|
| 4204 | end
|
---|
| 4205 | eval(['Histo.' FieldName '=linspace(Amin,Amax,50);'])%absissa values for histo
|
---|
| 4206 | for col=1:size(FieldHisto,3)
|
---|
| 4207 | B=FieldHisto(:,:,col);
|
---|
| 4208 | C=reshape(double(B),1,nxy(1)*nxy(2));% reshape in a vector
|
---|
| 4209 | eval(['Histo.histo(:,col)=hist(C, Histo.' FieldName ');']); %calculate histogram
|
---|
| 4210 | end
|
---|
| 4211 | set(haxes,'XLimMode','auto')%reset auto mode (after zoom effect)
|
---|
| 4212 | set(haxes,'YLimMode','auto')
|
---|
| 4213 | plot_field(Histo,haxes);
|
---|
| 4214 | end
|
---|
| 4215 | end
|
---|
| 4216 |
|
---|
| 4217 |
|
---|
| 4218 |
|
---|
| 4219 | %------------------------------------------------
|
---|
| 4220 | %CALLBACKS FOR PLOTTING PARAMETERS
|
---|
| 4221 | %-------------------------------------------------
|
---|
| 4222 |
|
---|
| 4223 | %-----------------------------------------------------------------
|
---|
| 4224 | function MinA_Callback(hObject, eventdata, handles)
|
---|
| 4225 | %------------------------------------------
|
---|
| 4226 | set(handles.AutoScal,'Value',1) %suppress auto mode
|
---|
| 4227 | set(handles.AutoScal,'BackgroundColor',[1 1 0])
|
---|
[89] | 4228 | update_plot(handles);
|
---|
[2] | 4229 |
|
---|
| 4230 | %-----------------------------------------------------------------
|
---|
| 4231 | function MaxA_Callback(hObject, eventdata, handles)
|
---|
| 4232 | %--------------------------------------------
|
---|
| 4233 | set(handles.AutoScal,'Value',1) %suppress auto mode
|
---|
| 4234 | set(handles.AutoScal,'BackgroundColor',[1 1 0])
|
---|
[89] | 4235 | update_plot(handles);
|
---|
[2] | 4236 |
|
---|
| 4237 | %-----------------------------------------------
|
---|
| 4238 | function AutoScal_Callback(hObject, eventdata, handles)
|
---|
| 4239 | %--------------------------------------------
|
---|
| 4240 | test=get(handles.AutoScal,'Value');
|
---|
| 4241 | if test
|
---|
| 4242 | set(handles.AutoScal,'BackgroundColor',[1 1 0])
|
---|
| 4243 | else
|
---|
| 4244 | set(handles.AutoScal,'BackgroundColor',[0.7 0.7 0.7])
|
---|
| 4245 | update_plot(handles);
|
---|
| 4246 | end
|
---|
| 4247 |
|
---|
| 4248 | %-------------------------------------------------------------------
|
---|
| 4249 | function BW_Callback(hObject, eventdata, handles)
|
---|
| 4250 | %-------------------------------------------------------------------
|
---|
[89] | 4251 | update_plot(handles);
|
---|
[2] | 4252 |
|
---|
| 4253 | %-------------------------------------------------------------------
|
---|
| 4254 | function Contours_Callback(hObject, eventdata, handles)
|
---|
| 4255 | %-------------------------------------------------------------------
|
---|
| 4256 | val=get(handles.Contours,'Value');
|
---|
| 4257 | if val==2
|
---|
| 4258 | set(handles.interval_txt,'Visible','on')
|
---|
| 4259 | set(handles.IncrA,'Visible','on')
|
---|
| 4260 | else
|
---|
| 4261 | set(handles.interval_txt,'Visible','off')
|
---|
| 4262 | set(handles.IncrA,'Visible','off')
|
---|
| 4263 | end
|
---|
[89] | 4264 | update_plot(handles);
|
---|
[2] | 4265 |
|
---|
| 4266 | %-------------------------------------------------------------------
|
---|
| 4267 | function IncrA_Callback(hObject, eventdata, handles)
|
---|
| 4268 | %-------------------------------------------------------------------
|
---|
[89] | 4269 | update_plot(handles);
|
---|
[2] | 4270 |
|
---|
| 4271 | %-------------------------------------------------------------------
|
---|
| 4272 | function HideWarning_Callback(hObject, eventdata, handles)
|
---|
| 4273 | %-------------------------------------------------------------------
|
---|
[89] | 4274 | update_plot(handles);
|
---|
[2] | 4275 |
|
---|
| 4276 | %-------------------------------------------------------------------
|
---|
| 4277 | function HideFalse_Callback(hObject, eventdata, handles)
|
---|
| 4278 | %-------------------------------------------------------------------
|
---|
[89] | 4279 | update_plot(handles);
|
---|
[2] | 4280 |
|
---|
| 4281 | %-------------------------------------------------------------------
|
---|
| 4282 | function VecScale_Callback(hObject, eventdata, handles)
|
---|
| 4283 | %-------------------------------------------------------------------
|
---|
| 4284 | set(handles.AutoVec,'Value',1);
|
---|
| 4285 | set(handles.AutoVec,'BackgroundColor',[1 1 0])
|
---|
[89] | 4286 | update_plot(handles);
|
---|
[2] | 4287 |
|
---|
| 4288 | %-------------------------------------------------------------------
|
---|
| 4289 | function AutoVec_Callback(hObject, eventdata, handles)
|
---|
| 4290 | %-------------------------------------------------------------------
|
---|
| 4291 | test=get(handles.AutoVec,'Value');
|
---|
| 4292 | if test
|
---|
| 4293 | set(handles.AutoVec,'BackgroundColor',[1 1 0])
|
---|
| 4294 | else
|
---|
| 4295 | update_plot(handles);
|
---|
| 4296 | %set(handles.VecScale,'String',num2str(ScalOut.VecScale,3))
|
---|
| 4297 | set(handles.AutoVec,'BackgroundColor',[0.7 0.7 0.7])
|
---|
| 4298 | end
|
---|
| 4299 |
|
---|
[89] | 4300 | %------------------------------------------------------------------------
|
---|
[2] | 4301 | % --- Executes on selection change in decimate4 (nb_vec/4).
|
---|
| 4302 | function decimate4_Callback(hObject, eventdata, handles)
|
---|
[89] | 4303 | %------------------------------------------------------------------------
|
---|
| 4304 | update_plot(handles);
|
---|
[2] | 4305 |
|
---|
[89] | 4306 | %------------------------------------------------------------------------
|
---|
[2] | 4307 | % --- Executes on selection change in color_code menu
|
---|
| 4308 | function color_code_Callback(hObject, eventdata, handles)
|
---|
[89] | 4309 | %------------------------------------------------------------------------
|
---|
[2] | 4310 | set_vec_col_bar(handles)
|
---|
| 4311 | update_plot(handles);
|
---|
| 4312 |
|
---|
[89] | 4313 | %------------------------------------------------------------------------
|
---|
[2] | 4314 | % --- Executes on button press in AutoVecColor.
|
---|
| 4315 | function AutoVecColor_Callback(hObject, eventdata, handles)
|
---|
[89] | 4316 | %------------------------------------------------------------------------
|
---|
[2] | 4317 | test=get(handles.AutoVecColor,'Value');
|
---|
| 4318 | if test
|
---|
| 4319 | set(handles.AutoVecColor,'BackgroundColor',[1 1 0])
|
---|
| 4320 | else
|
---|
| 4321 | update_plot(handles);
|
---|
| 4322 | %set(handles.VecScale,'String',num2str(ScalOut.VecScale,3))
|
---|
| 4323 | set(handles.AutoVecColor,'BackgroundColor',[0.7 0.7 0.7])
|
---|
| 4324 | end
|
---|
| 4325 |
|
---|
[89] | 4326 | %------------------------------------------------------------------------
|
---|
[2] | 4327 | % --- Executes on selection change in max_vec.
|
---|
| 4328 | function min_vec_Callback(hObject, eventdata, handles)
|
---|
[89] | 4329 | %------------------------------------------------------------------------
|
---|
[2] | 4330 | max_vec_Callback(hObject, eventdata, handles)
|
---|
| 4331 |
|
---|
[89] | 4332 | %------------------------------------------------------------------------
|
---|
[2] | 4333 | % --- Executes on selection change in max_vec.
|
---|
| 4334 | function max_vec_Callback(hObject, eventdata, handles)
|
---|
[89] | 4335 | %------------------------------------------------------------------------
|
---|
[2] | 4336 | set(handles.AutoVecColor,'Value',1)
|
---|
| 4337 | AutoVecColor_Callback(hObject, eventdata, handles)
|
---|
| 4338 | min_val=str2num(get(handles.min_vec,'String'));
|
---|
| 4339 | max_val=str2num(get(handles.max_vec,'String'));
|
---|
| 4340 | slider1=get(handles.slider1,'Value');
|
---|
| 4341 | slider2=get(handles.slider2,'Value');
|
---|
| 4342 | colcode1=min_val+(max_val-min_val)*slider1;
|
---|
| 4343 | colcode2=min_val+(max_val-min_val)*slider2;
|
---|
| 4344 | set(handles.colcode1,'String',num2str(colcode1))
|
---|
| 4345 | set(handles.colcode2,'String',num2str(colcode2))
|
---|
| 4346 | update_plot(handles);
|
---|
| 4347 |
|
---|
[89] | 4348 | %------------------------------------------------------------------------
|
---|
| 4349 | % --- update the display of color code for vectors
|
---|
[2] | 4350 | function set_vec_col_bar(handles)
|
---|
[89] | 4351 | %------------------------------------------------------------------------
|
---|
[2] | 4352 | %get the image of the color display button 'vec_col_bar' in pixels
|
---|
| 4353 | set(handles.vec_col_bar,'Unit','pixel');
|
---|
| 4354 | pos_vert=get(handles.vec_col_bar,'Position');
|
---|
| 4355 | set(handles.vec_col_bar,'Unit','Normalized');
|
---|
| 4356 | width=ceil(pos_vert(3));
|
---|
| 4357 | height=ceil(pos_vert(4));
|
---|
| 4358 |
|
---|
| 4359 | %get slider indications
|
---|
| 4360 | list=get(handles.color_code,'String');
|
---|
| 4361 | ichoice=get(handles.color_code,'Value');
|
---|
| 4362 | colcode.ColorCode=list{ichoice};
|
---|
| 4363 | colcode.MinC=str2num(get(handles.min_vec,'String'));
|
---|
| 4364 | colcode.MaxC=str2num(get(handles.max_vec,'String'));
|
---|
| 4365 | test3color=strcmp(colcode.ColorCode,'rgb') || strcmp(colcode.ColorCode,'bgr');
|
---|
| 4366 | if test3color
|
---|
| 4367 | colcode.colcode1=str2num(get(handles.colcode1,'String'));
|
---|
| 4368 | colcode.colcode2=str2num(get(handles.colcode2,'String'));
|
---|
| 4369 | end
|
---|
| 4370 | % colcode.option=get(handles.vec_col_bar,'Value');
|
---|
| 4371 | colcode.FixedCbounds=0;
|
---|
| 4372 | % list_code=get(handles.col_vec,'String');% list menu fields
|
---|
| 4373 | % index_code=get(handles.col_vec,'Value');% selected string index
|
---|
| 4374 | % colcode.CName= list_code{index_code(1)}; % selected field used for vector color
|
---|
| 4375 | colcode.FixedCbounds=1;
|
---|
| 4376 | vec_C=colcode.MinC+(colcode.MaxC-colcode.MinC)*[0.5:width-0.5]/width;%sample of vec_C values from min to max
|
---|
| 4377 | [colorlist,col_vec]=set_col_vec(colcode,vec_C);
|
---|
| 4378 | oneheight=ones(1,height);
|
---|
| 4379 | A1=colorlist(col_vec,1)*oneheight;
|
---|
| 4380 | A2=colorlist(col_vec,2)*oneheight;
|
---|
| 4381 | A3=colorlist(col_vec,3)*oneheight;
|
---|
| 4382 | A(:,:,1)=A1';
|
---|
| 4383 | A(:,:,2)=A2';
|
---|
| 4384 | A(:,:,3)=A3';
|
---|
| 4385 | set(handles.vec_col_bar,'Cdata',A)
|
---|
| 4386 |
|
---|
| 4387 |
|
---|
| 4388 | %-------------------------------------------------------------------
|
---|
[132] | 4389 | function update_plot(handles)
|
---|
[2] | 4390 | %-------------------------------------------------------------------
|
---|
| 4391 | haxes= handles.axes3;
|
---|
[150] | 4392 | UvData=get(handles.uvmat,'UserData');
|
---|
| 4393 | AxeData=UvData.axes3;
|
---|
[2] | 4394 | PlotParam=read_plot_param(handles);
|
---|
| 4395 | [PlotType,PlotParamOut]= plot_field(AxeData,haxes,PlotParam,1);
|
---|
| 4396 | write_plot_param(handles,PlotParamOut); %update the auto plot parameters
|
---|
| 4397 |
|
---|
| 4398 | %-------------------------------------------------------------------
|
---|
| 4399 | % --- Executes on button press in grid.
|
---|
| 4400 | function grid_Callback(hObject, eventdata, handles)
|
---|
| 4401 |
|
---|
[61] | 4402 |
|
---|
[2] | 4403 |
|
---|
| 4404 | %-------------------------------------------------------------------
|
---|
[155] | 4405 | % --- Executes on selection change in edit_object.
|
---|
| 4406 | function edit_object_Callback(hObject, eventdata, handles)
|
---|
[2] | 4407 | %-------------------------------------------------------------------
|
---|
[61] | 4408 | UvData=get(handles.uvmat,'UserData');%read UvData properties stored on the uvmat interface
|
---|
[155] | 4409 | test=get(handles.edit_object,'Value');
|
---|
[2] | 4410 | if test
|
---|
[155] | 4411 | set(handles.edit_object,'BackgroundColor',[1,1,0])
|
---|
[2] | 4412 | %suppress the other options
|
---|
| 4413 | set(handles.zoom,'Value',0)
|
---|
| 4414 | zoom_Callback(hObject, eventdata, handles)
|
---|
| 4415 | else
|
---|
| 4416 | UvData.MouseAction='none';
|
---|
[155] | 4417 | set(handles.edit_object,'BackgroundColor',[0.7,0.7,0.7])
|
---|
[2] | 4418 | end
|
---|
[61] | 4419 | set(handles.uvmat,'UserData',UvData);
|
---|
| 4420 | hset_object=findobj(allchild(0),'Tag','set_object');
|
---|
| 4421 | if ~isempty(hset_object)
|
---|
| 4422 | hhset_object=guidata(hset_object);
|
---|
| 4423 | if test
|
---|
[71] | 4424 | set(hhset_object.PLOT,'enable','on');
|
---|
[61] | 4425 | else
|
---|
[71] | 4426 | set(hhset_object.PLOT,'enable','off');
|
---|
[61] | 4427 | end
|
---|
| 4428 | end
|
---|
[2] | 4429 |
|
---|
[61] | 4430 | %------------------------------------------------------------------------
|
---|
| 4431 | % --- Executes on selection change in list_object_1.
|
---|
| 4432 | function list_object_1_Callback(hObject, eventdata, handles)
|
---|
| 4433 | %------------------------------------------------------------------------
|
---|
| 4434 | list_str=get(handles.list_object_1,'String');
|
---|
| 4435 | IndexObj=get(handles.list_object_1,'Value');
|
---|
| 4436 | str_1=list_str{IndexObj};
|
---|
| 4437 | val_2=get(handles.list_object_2,'Value');
|
---|
| 4438 | str_2=get(handles.list_object_2,'String');
|
---|
[71] | 4439 | if isequal(val_2,IndexObj)% if the first selection is equal to the second, it will suppress the second
|
---|
| 4440 | set(handles.list_object_2,'Value',numel(str_2))%select the end of the list ('...')
|
---|
[61] | 4441 | list_object_2_Callback(hObject, eventdata, handles)
|
---|
| 4442 | end
|
---|
[71] | 4443 | update_object(handles,IndexObj,1,str_1)
|
---|
[61] | 4444 |
|
---|
| 4445 | %------------------------------------------------------------------------
|
---|
| 4446 | % --- Executes on selection change in list_object_1.
|
---|
| 4447 | function list_object_2_Callback(hObject, eventdata, handles)
|
---|
| 4448 | %------------------------------------------------------------------------
|
---|
| 4449 | list_str=get(handles.list_object_2,'String');
|
---|
| 4450 | IndexObj=get(handles.list_object_2,'Value');
|
---|
[159] | 4451 | if ischar(list_str) || strcmp(list_str{IndexObj},'...')
|
---|
[71] | 4452 | hview_field=findobj(allchild(0),'Tag','view_field');
|
---|
[61] | 4453 | if ~isempty(hview_field)
|
---|
| 4454 | delete(hview_field)
|
---|
| 4455 | end
|
---|
| 4456 | else
|
---|
[71] | 4457 | update_object(handles,IndexObj,2,list_str{IndexObj})
|
---|
[61] | 4458 | end
|
---|
| 4459 |
|
---|
| 4460 | %------------------------------------------------------------------------
|
---|
[71] | 4461 | function update_object(handles,IndexObj,option,ObjectName)
|
---|
[61] | 4462 | %------------------------------------------------------------------------
|
---|
[60] | 4463 | UvData=get(handles.uvmat,'UserData');%read UvData properties stored on the uvmat interface
|
---|
[153] | 4464 | if numel(UvData.Object)<IndexObj;
|
---|
[2] | 4465 | return
|
---|
| 4466 | end
|
---|
| 4467 | ObjectData=UvData.Object{IndexObj};
|
---|
[71] | 4468 | ObjectData.Name=ObjectName;
|
---|
[155] | 4469 | if isequal(get(handles.edit_object,'Value'),1)
|
---|
[71] | 4470 | ObjectData.enable_plot=1; % desable the PLOT option in the set_object GUI (editing mode
|
---|
[2] | 4471 | end
|
---|
| 4472 | ZBounds=0; % default
|
---|
| 4473 | if isfield(UvData,'ZMin') && isfield(UvData,'ZMax')
|
---|
| 4474 | ZBounds(1)=UvData.ZMin; %minimum for the Z slider
|
---|
| 4475 | ZBounds(2)=UvData.ZMax;%maximum for the Z slider
|
---|
| 4476 | end
|
---|
[71] | 4477 | hset_object=findobj(allchild(0),'tag','set_object');
|
---|
[61] | 4478 | if ~isempty(hset_object)
|
---|
| 4479 | delete(hset_object)% delete existing version of set_object
|
---|
| 4480 | end
|
---|
[155] | 4481 | hset_object=set_object(ObjectData,[],ZBounds);% call the set_object interface,
|
---|
[82] | 4482 |
|
---|
| 4483 | % %project the current field on the object and plot it
|
---|
[155] | 4484 | ProjData= proj_field(UvData.Field,ObjectData);%project the current interface field on ObjectData
|
---|
[153] | 4485 | if option==1%length(UvData.Object)>= IndexObj && isfield(UvData.Object{IndexObj},'plotaxes')&& ishandle(UvData.Object{IndexObj}.plotaxes)
|
---|
[155] | 4486 | PlotHandles=handles;
|
---|
| 4487 | % UvData.Object{IndexObj}.plotaxes=handles.axes3;
|
---|
[153] | 4488 | else
|
---|
[155] | 4489 | hview_field=findobj(allchild(0),'tag','view_field');
|
---|
| 4490 | if isempty(hview_field)
|
---|
| 4491 | hview_field=view_field;
|
---|
| 4492 | end
|
---|
| 4493 | PlotHandles=guidata(hview_field);
|
---|
| 4494 | % hview_field=view_field(ProjData);
|
---|
| 4495 | % hhviewfield=guidata(hviewfield);
|
---|
| 4496 | % UvData.Object{IndexObj}.plotaxes=hhviewfield.axes3;
|
---|
[153] | 4497 | end
|
---|
[155] | 4498 | if ~isempty(ProjData)
|
---|
| 4499 | plot_field(ProjData,PlotHandles.axes3,PlotHandles);
|
---|
| 4500 | end
|
---|
[153] | 4501 | set(handles.uvmat,'UserData',UvData)
|
---|
[102] | 4502 | hother=findobj('Tag','proj_object');%find all the proj objects
|
---|
| 4503 | for iobj=1:length(hother)
|
---|
| 4504 | if isequal(get(hother(iobj),'Type'),'rectangle')|isequal(get(hother(iobj),'Type'),'patch')
|
---|
| 4505 | set(hother(iobj),'EdgeColor','b')
|
---|
| 4506 | if isequal(get(hother(iobj),'FaceColor'),'m')
|
---|
| 4507 | set(hother(iobj),'FaceColor','b')
|
---|
| 4508 | end
|
---|
| 4509 | elseif isequal(get(hother(iobj),'Type'),'image')
|
---|
| 4510 | Acolor=get(hother(iobj),'CData');
|
---|
| 4511 | Acolor(:,:,1)=zeros(size(Acolor,1),size(Acolor,2));
|
---|
| 4512 | set(hother(iobj),'CData',Acolor);
|
---|
| 4513 | else
|
---|
| 4514 | set(hother(iobj),'Color','b')
|
---|
| 4515 | end
|
---|
| 4516 | set(hother(iobj),'Selected','off')
|
---|
| 4517 | end
|
---|
[2] | 4518 | hother=findobj('Tag','DeformPoint');
|
---|
| 4519 | set(hother,'Color','b');
|
---|
| 4520 | set(hother,'Selected','off')
|
---|
[155] | 4521 | if isfield(ObjectData,'DisplayHandle_uvmat')
|
---|
| 4522 | % for iview=1:length(ObjectData.HandlesDisplay)
|
---|
| 4523 | if ishandle(ObjectData.DisplayHandle_uvmat)
|
---|
| 4524 | uistack(ObjectData.DisplayHandle_uvmat,'top')
|
---|
| 4525 | linetype=get(ObjectData.DisplayHandle_uvmat,'Type');
|
---|
[2] | 4526 | if isequal(linetype,'line')
|
---|
[155] | 4527 | set(ObjectData.DisplayHandle_uvmat,'Color','m'); %set the selected object to magenta color
|
---|
[2] | 4528 | elseif isequal(linetype,'rectangle')
|
---|
[155] | 4529 | set(ObjectData.DisplayHandle_uvmat,'EdgeColor','m'); %set the selected object to magenta color
|
---|
[2] | 4530 | elseif isequal(linetype,'patch')
|
---|
[155] | 4531 | set(ObjectData.DisplayHandle_uvmat,'FaceColor','m'); %set the selected object to magenta color
|
---|
[2] | 4532 | end
|
---|
[155] | 4533 | SubObjectData=get(ObjectData.DisplayHandle_uvmat,'UserData');
|
---|
| 4534 | if isfield(SubObjectData,'SubObject') & ishandle(SubObjectData.SubObject)
|
---|
[2] | 4535 | uistack(SubObjectData.SubObject,'top')
|
---|
| 4536 | for iobj=1:length(SubObjectData.SubObject)
|
---|
| 4537 | hsub=SubObjectData.SubObject(iobj);
|
---|
| 4538 | if isequal(get(hsub,'Type'),'rectangle')
|
---|
| 4539 | set(hsub,'EdgeColor','m'); %set the selected object to magenta color
|
---|
| 4540 | elseif isequal(get(hsub,'Type'),'image')
|
---|
| 4541 | Acolor=get(hsub,'CData');
|
---|
| 4542 | Acolor(:,:,1)=Acolor(:,:,3);
|
---|
| 4543 | set(hsub,'CData',Acolor);
|
---|
| 4544 | else
|
---|
| 4545 | set(hsub,'Color','m')
|
---|
| 4546 | end
|
---|
| 4547 | end
|
---|
| 4548 | end
|
---|
[155] | 4549 | if isfield(SubObjectData,'DeformPoint') & ishandle(SubObjectData.DeformPoint)
|
---|
[2] | 4550 | set(SubObjectData.DeformPoint,'Color','m')
|
---|
| 4551 | end
|
---|
| 4552 | end
|
---|
[155] | 4553 | % end
|
---|
[2] | 4554 | end
|
---|
[61] | 4555 | pause(0.1)
|
---|
| 4556 | figure(hset_object)%put set_object in front
|
---|
[2] | 4557 |
|
---|
| 4558 | %------------------------------------------------------
|
---|
| 4559 | % --- Executes on button press in Menu/Export/field in workspace.
|
---|
| 4560 | %------------------------------------------------------
|
---|
| 4561 | function MenuExportField_Callback(hObject, eventdata, handles)
|
---|
[89] | 4562 | global Data_uvmat
|
---|
| 4563 | Data_uvmat=get(handles.uvmat,'UserData');
|
---|
| 4564 | evalin('base','global Data_uvmat')%make CurData global in the workspace
|
---|
[122] | 4565 | display('current field :')
|
---|
[89] | 4566 | evalin('base','Data_uvmat') %display CurData in the workspace
|
---|
[82] | 4567 | commandwindow; %brings the Matlab command window to the front
|
---|
[2] | 4568 |
|
---|
| 4569 | %------------------------------------------------------
|
---|
| 4570 | % --- Executes on button press in Menu/Export/extract figure.
|
---|
| 4571 | %------------------------------------------------------
|
---|
| 4572 | function MenuExport_plot_Callback(hObject, eventdata, handles)
|
---|
| 4573 | huvmat=get(handles.MenuExport_plot,'parent');
|
---|
| 4574 | UvData=get(huvmat,'UserData');
|
---|
| 4575 | hfig=figure;
|
---|
| 4576 | newaxes=copyobj(handles.axes3,hfig);
|
---|
| 4577 | map=colormap(handles.axes3);
|
---|
| 4578 | colormap(map);%transmit the current colormap to the zoom fig
|
---|
| 4579 | colorbar
|
---|
| 4580 |
|
---|
| 4581 |
|
---|
| 4582 | % --------------------------------------------------------------------
|
---|
| 4583 | function Insert_Callback(hObject, eventdata, handles)
|
---|
| 4584 |
|
---|
| 4585 |
|
---|
| 4586 | % --------------------------------------------------------------------
|
---|
| 4587 | function MenuHelp_Callback(hObject, eventdata, handles)
|
---|
| 4588 | % --------------------------------------------------------------------
|
---|
| 4589 | path_to_uvmat=which ('uvmat');% check the path of uvmat
|
---|
| 4590 | pathelp=fileparts(path_to_uvmat);
|
---|
[36] | 4591 | helpfile=fullfile(pathelp,'uvmat_doc','uvmat_doc.html');
|
---|
| 4592 | 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] | 4593 | else
|
---|
[36] | 4594 | addpath (fullfile(pathelp,'uvmat_doc'))
|
---|
[2] | 4595 | web(helpfile);
|
---|
| 4596 | end
|
---|
| 4597 |
|
---|
| 4598 |
|
---|
| 4599 | % --------------------------------------------------------------------
|
---|
| 4600 | function MenuExportMovie_Callback(hObject, eventdata, handles)
|
---|
| 4601 | % --------------------------------------------------------------------
|
---|
| 4602 | set(handles.MenuExportMovie,'BusyAction','queue')% activate the button
|
---|
| 4603 | huvmat=get(handles.run0,'parent');
|
---|
| 4604 | UvData=get(huvmat,'UserData');
|
---|
| 4605 | [xx,xx,FileBase]=read_file_boxes(handles);
|
---|
| 4606 | %read the current input file name
|
---|
| 4607 | 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)'};
|
---|
| 4608 | dlg_title = 'select properties of the output avi movie';
|
---|
| 4609 | num_lines= 1;
|
---|
[128] | 4610 | % nbfield_cell=get(handles.last_i,'String');
|
---|
[2] | 4611 | def = {[FileBase '_out.avi'];'10';'1';'[0.03 0.05 0.95 0.92]';'10'};
|
---|
| 4612 | answer = inputdlg(prompt,dlg_title,num_lines,def,'on');
|
---|
| 4613 | aviname=answer{1};
|
---|
[128] | 4614 | fps=str2double(answer{2});
|
---|
[2] | 4615 | % check for existing file with output name aviname
|
---|
| 4616 | if exist(aviname,'file')
|
---|
| 4617 | backup=aviname;
|
---|
| 4618 | testexist=2;
|
---|
| 4619 | while testexist==2
|
---|
| 4620 | backup=[backup '~'];
|
---|
| 4621 | testexist=exist(backup,'file');
|
---|
| 4622 | end
|
---|
| 4623 | [success,message]=copyfile(aviname,backup);%make backup of the existing file
|
---|
| 4624 | if isequal(success,1)
|
---|
| 4625 | delete(aviname)%delete existing file
|
---|
| 4626 | else
|
---|
| 4627 | msgbox_uvmat('ERROR',message)
|
---|
| 4628 | return
|
---|
| 4629 | end
|
---|
| 4630 | end
|
---|
| 4631 | %create avi open
|
---|
| 4632 | aviobj=avifile(aviname,'Compression','None','fps',fps);
|
---|
| 4633 |
|
---|
| 4634 | %display first view for tests
|
---|
| 4635 | newfig=figure;
|
---|
| 4636 | newaxes=copyobj(handles.axes3,newfig);%new plotting axes in the new figure
|
---|
| 4637 | set(newaxes,'Tag','movieaxes')
|
---|
[128] | 4638 | nbpix=[512 384]*str2double(answer{3});
|
---|
[2] | 4639 | set(gcf,'Position',[1 1 nbpix])% resolution XVGA
|
---|
| 4640 | set(newaxes,'Position',eval(answer{4}));
|
---|
| 4641 | map=colormap(handles.axes3);
|
---|
| 4642 | colormap(map);%transmit the current colormap to the zoom fig
|
---|
| 4643 | msgbox_uvmat('INPUT_Y-N',{['adjust figure ' num2str(newfig) ' with its matlab edit menu '] ;...
|
---|
| 4644 | ['then press OK to get the avi movie as a copy of figure ' num2str(newfig) ' display']});
|
---|
| 4645 | UvData.Object{1}.plotaxes=newaxes;% the axis in the new figure becomes the current main plotting axes
|
---|
| 4646 | set(huvmat,'UserData',UvData);
|
---|
[128] | 4647 | increment=str2double(get(handles.increment_scan,'String')); %get the field increment d
|
---|
| 4648 | if isnan(increment)
|
---|
| 4649 | set(handles.increment_scan,'String','1')%default value
|
---|
| 4650 | increment=1;
|
---|
| 4651 | end
|
---|
[2] | 4652 | set(handles.STOP,'Visible','on')
|
---|
| 4653 | set(handles.speed,'Visible','on')
|
---|
| 4654 | set(handles.speed_txt,'Visible','on')
|
---|
[81] | 4655 | set(handles.Movie,'BusyAction','queue')
|
---|
[2] | 4656 |
|
---|
[128] | 4657 | %imin=str2double(get(handles.i1,'String'));
|
---|
| 4658 | imax=str2double(answer{5});
|
---|
[2] | 4659 | % if isfield(UvData,'Time')
|
---|
| 4660 | htitle=get(newaxes,'Title');
|
---|
| 4661 | xlim=get(newaxes,'XLim');
|
---|
| 4662 | ylim=get(newaxes,'YLim');
|
---|
| 4663 | set(htitle,'Position',[xlim(2)+0.07*(xlim(2)-xlim(1)) ylim(2)-0.05*(ylim(2)-ylim(1)) 0])
|
---|
| 4664 | time_str=get(handles.abs_time,'String');
|
---|
| 4665 | set(htitle,'String',['t=' time_str])
|
---|
| 4666 | set(handles.speed,'Value',1)
|
---|
| 4667 | for i=1:imax
|
---|
[128] | 4668 | if get(handles.speed,'Value')~=0 && isequal(get(handles.MenuExportMovie,'BusyAction'),'queue') % enable STOP command
|
---|
| 4669 | runpm(hObject,eventdata,handles,increment)% run plus
|
---|
[2] | 4670 | drawnow
|
---|
| 4671 | time_str=get(handles.abs_time,'String');
|
---|
| 4672 | if ishandle(htitle)
|
---|
| 4673 | set(htitle,'String',['t=' time_str])
|
---|
| 4674 | end
|
---|
| 4675 | mov=getframe(newfig);
|
---|
| 4676 | aviobj=addframe(aviobj,mov);
|
---|
| 4677 | end
|
---|
| 4678 | end
|
---|
[128] | 4679 | close(aviobj);
|
---|
[2] | 4680 | UvData.Object{1}.plotaxes=handles.axes3;
|
---|
| 4681 | set(huvmat,'UserData',UvData);
|
---|
| 4682 | msgbox_uvmat('CONFIRMATION',{['movie ' aviname ' created '];['with ' num2str(imax) ' frames']})
|
---|
| 4683 |
|
---|
| 4684 |
|
---|
| 4685 | % ------------------------------------------------------------------
|
---|
| 4686 | function MenuCalib_Callback(hObject, eventdata, handles)
|
---|
[71] | 4687 |
|
---|
[61] | 4688 | UvData=get(handles.uvmat,'UserData');%read UvData properties stored on the uvmat interface
|
---|
[71] | 4689 |
|
---|
| 4690 | %suppress competing options
|
---|
[61] | 4691 | set(handles.zoom,'Value',0)
|
---|
| 4692 | set(handles.zoom,'BackgroundColor',[0.7 0.7 0.7])
|
---|
| 4693 | set(handles.list_object_1,'Value',1)
|
---|
| 4694 | % initiate display of GUI geometry_calib
|
---|
| 4695 | data=[]; %default
|
---|
| 4696 | if isfield(UvData,'CoordType')
|
---|
| 4697 | data.CoordType=UvData.CoordType;
|
---|
| 4698 | end
|
---|
| 4699 | pos=get(handles.uvmat,'Position');
|
---|
| 4700 | pos(1)=pos(1)+pos(3)-0.311+0.04; %0.311= width of the geometry_calib interface (units relative to the srcreen)
|
---|
| 4701 | pos(2)=pos(2)-0.02;
|
---|
| 4702 | [FileName,RootPath,FileBase,FileIndices,FileExt,SubDir]=read_file_boxes(handles);
|
---|
[155] | 4703 | set(handles.view_xml,'Backgroundcolor',[1 1 0])%indicate the reading of the current xml file by geometry_calib
|
---|
[61] | 4704 | if isfield(UvData,'CalOrigin')
|
---|
[155] | 4705 | pos_uvmat=get(handles.uvmat,'Position');
|
---|
[61] | 4706 | pos_cal(1)=pos_uvmat(1)+UvData.CalOrigin(1)*pos_uvmat(3);
|
---|
| 4707 | pos_cal(2)=pos_uvmat(2)+UvData.CalOrigin(2)*pos_uvmat(4);
|
---|
| 4708 | pos_cal(3:4)=UvData.CalSize .* pos_uvmat(3:4);
|
---|
| 4709 | end
|
---|
[155] | 4710 | geometry_calib(FileName,pos_cal);% call the geometry_calib interface
|
---|
| 4711 | set(handles.view_xml,'Backgroundcolor',[1 1 1])%indicate the end of reading of the current xml file by geometry_calib
|
---|
| 4712 | set(handles.MenuCalib,'checked','on')% indicate that MenuCalib is activated, test used by mouse action
|
---|
[2] | 4713 |
|
---|
[61] | 4714 |
|
---|
[2] | 4715 | % ------------------------------------------------------------------
|
---|
| 4716 | function MenuMask_Callback(hObject, eventdata, handles)
|
---|
[61] | 4717 | UvData=get(handles.uvmat,'UserData');%read UvData properties stored on the uvmat interface
|
---|
[82] | 4718 | ListObj=UvData.Object;
|
---|
| 4719 | select=zeros(1,numel(ListObj));
|
---|
| 4720 | for iobj=1:numel(ListObj);
|
---|
| 4721 | if strcmp(ListObj{iobj}.ProjMode,'mask_inside')||strcmp(ListObj{iobj}.ProjMode,'mask_outside')
|
---|
| 4722 | select(iobj)=1;
|
---|
| 4723 | end
|
---|
[2] | 4724 | end
|
---|
[82] | 4725 | val=find(select);
|
---|
| 4726 | if isempty(val)
|
---|
| 4727 | msgbox_uvmat('ERROR','polygons must be first created by Projection object/mask polygon in the menu bar');
|
---|
| 4728 | return
|
---|
| 4729 | else
|
---|
| 4730 | set(handles.list_object_1,'Max',2);%allow multiple selection
|
---|
| 4731 | set(handles.list_object_1,'Value',val);
|
---|
[155] | 4732 | flag=1;
|
---|
| 4733 | npx=size(UvData.Field.A,2);
|
---|
| 4734 | npy=size(UvData.Field.A,1);
|
---|
| 4735 | xi=0.5:npx-0.5;
|
---|
| 4736 | yi=0.5:npy-0.5;
|
---|
| 4737 | [Xi,Yi]=meshgrid(xi,yi);
|
---|
| 4738 | if isfield(UvData,'Object')
|
---|
| 4739 | for iobj=1:length(UvData.Object)
|
---|
| 4740 | ObjectData=UvData.Object{iobj};
|
---|
| 4741 | if isfield(ObjectData,'ProjMode') &&(isequal(ObjectData.ProjMode,'mask_inside')||isequal(ObjectData.ProjMode,'mask_outside'));
|
---|
| 4742 | flagobj=1;
|
---|
| 4743 | testphys=0; %coordinates in pixels by default
|
---|
[159] | 4744 | if isfield(ObjectData,'CoordUnit') && ~isequal(ObjectData.CoordUnit,'pixel')
|
---|
[155] | 4745 | if isfield(UvData,'XmlData')&& isfield(UvData.XmlData,'GeometryCalib')
|
---|
| 4746 | Calib=UvData.XmlData.GeometryCalib;
|
---|
| 4747 | testphys=1;
|
---|
[82] | 4748 | end
|
---|
[155] | 4749 | end
|
---|
| 4750 | if isfield(ObjectData,'Coord')& isfield(ObjectData,'Style')
|
---|
| 4751 | if isequal(ObjectData.Style,'polygon')
|
---|
| 4752 | X=ObjectData.Coord(:,1);
|
---|
| 4753 | Y=ObjectData.Coord(:,2);
|
---|
| 4754 | if testphys
|
---|
| 4755 | [X,Y]=px_XYZ(Calib,X,Y,0);% to generalise with 3D cases
|
---|
[82] | 4756 | end
|
---|
[155] | 4757 | flagobj=~inpolygon(Xi,Yi,X',Y');%=0 inside the polygon, 1 outside
|
---|
| 4758 | elseif isequal(ObjectData.Style,'ellipse')
|
---|
| 4759 | if testphys
|
---|
| 4760 | %[X,Y]=px_XYZ(Calib,X,Y,0);% TODO:create a polygon boundary and transform to phys
|
---|
[82] | 4761 | end
|
---|
[155] | 4762 | RangeX=max(ObjectData.RangeX);
|
---|
| 4763 | RangeY=max(ObjectData.RangeY);
|
---|
| 4764 | X2Max=RangeX*RangeX;
|
---|
| 4765 | Y2Max=RangeY*RangeY;
|
---|
| 4766 | distX=(Xi-ObjectData.Coord(1,1));
|
---|
| 4767 | distY=(Yi-ObjectData.Coord(1,2));
|
---|
| 4768 | flagobj=(distX.*distX/X2Max+distY.*distY/Y2Max)>1;
|
---|
| 4769 | elseif isequal(ObjectData.Style,'rectangle')
|
---|
| 4770 | if testphys
|
---|
| 4771 | %[X,Y]=px_XYZ(Calib,X,Y,0);% TODO:create a polygon boundary and transform to phys
|
---|
| 4772 | end
|
---|
| 4773 | distX=abs(Xi-ObjectData.Coord(1,1));
|
---|
| 4774 | distY=abs(Yi-ObjectData.Coord(1,2));
|
---|
| 4775 | flagobj=distX>max(ObjectData.RangeX) | distY>max(ObjectData.RangeY);
|
---|
[82] | 4776 | end
|
---|
[155] | 4777 | if isequal(ObjectData.ProjMode,'mask_outside')
|
---|
| 4778 | flagobj=~flagobj;
|
---|
| 4779 | end
|
---|
| 4780 | flag=flag & flagobj;
|
---|
[82] | 4781 | end
|
---|
| 4782 | end
|
---|
| 4783 | end
|
---|
[155] | 4784 | end
|
---|
| 4785 | % flag=~flag;
|
---|
| 4786 | %mask name
|
---|
| 4787 | RootPath=get(handles.RootPath,'String');
|
---|
| 4788 | RootFile=get(handles.RootFile,'String');
|
---|
| 4789 | if ~isempty(RootFile)&(isequal(RootFile(1),'/')| isequal(RootFile(1),'\'))
|
---|
| 4790 | RootFile(1)=[];
|
---|
| 4791 | end
|
---|
| 4792 | filebase=fullfile(RootPath,RootFile);
|
---|
| 4793 | list=get(handles.masklevel,'String');
|
---|
| 4794 | masknumber=num2str(length(list));
|
---|
| 4795 | maskindex=get(handles.masklevel,'Value');
|
---|
| 4796 | mask_name=name_generator([filebase '_' masknumber 'mask'],maskindex,1,'.png','_i');
|
---|
| 4797 | imflag=uint8(255*(0.392+0.608*flag));% =100 for flag=0 (vectors not computed when 20<imflag<200)
|
---|
| 4798 | imflag=flipdim(imflag,1);
|
---|
[82] | 4799 |
|
---|
[155] | 4800 | %display the mask
|
---|
| 4801 | figure;
|
---|
| 4802 | vec=linspace(0,1,256);%define a linear greyscale colormap
|
---|
| 4803 | map=[vec' vec' vec'];
|
---|
| 4804 | colormap(map)
|
---|
| 4805 | image(imflag);
|
---|
| 4806 | answer=msgbox_uvmat('INPUT_TXT','mask file name:', mask_name);
|
---|
| 4807 | if ~strcmp(answer,'Cancel')
|
---|
| 4808 | mask_dir=fileparts(answer);
|
---|
| 4809 | if ~exist(mask_dir,'dir')
|
---|
| 4810 | msgbox_uvmat('ERROR',['directory ' mask_dir ' does not exist'])
|
---|
| 4811 | return
|
---|
[82] | 4812 | end
|
---|
[155] | 4813 | imwrite(imflag,answer,'BitDepth',8);
|
---|
| 4814 | end
|
---|
| 4815 | set(handles.list_object_1,'Value',1)
|
---|
| 4816 | set(handles.list_object_1,'Max',1)
|
---|
| 4817 | end
|
---|
[82] | 4818 |
|
---|
[155] | 4819 | %set(handles.uvmat,'UserData',UvData);
|
---|
[2] | 4820 |
|
---|
| 4821 | % ------------------------------------------------------------------
|
---|
| 4822 | %-- open the GUI set_grid.fig to create grid
|
---|
| 4823 | function MenuGrid_Callback(hObject, eventdata, handles)
|
---|
[84] | 4824 | %UvData=get(handles.uvmat,'UserData');%read UvData properties stored on the uvmat interface
|
---|
[2] | 4825 |
|
---|
[84] | 4826 | %suppress the other options if grid is chosen
|
---|
| 4827 | set(handles.edit_vect,'Value',0)
|
---|
| 4828 | edit_vect_Callback(hObject, eventdata, handles)
|
---|
[155] | 4829 | set(handles.edit_object,'BackgroundColor',[0.7 0.7 0.7])
|
---|
[84] | 4830 | set(handles.list_object_1,'Value',1)
|
---|
| 4831 |
|
---|
| 4832 | %prepare display of the set_grid GUI
|
---|
| 4833 | FileName=read_file_boxes(handles);
|
---|
| 4834 | CoordList=get(handles.transform_fct,'String');
|
---|
| 4835 | val=get(handles.transform_fct,'Value');
|
---|
| 4836 | set_grid(FileName,CoordList{val});% call the set_object interface
|
---|
| 4837 | %set(handles.uvmat,'UserData',UvData);
|
---|
| 4838 |
|
---|
[2] | 4839 | %----------------------------------------------------------------
|
---|
| 4840 | % open the GUI 'series'
|
---|
| 4841 | %----------------------------------------------------------------
|
---|
| 4842 | function MenuSeries_Callback(hObject, eventdata, handles)
|
---|
[40] | 4843 | %-------------------------------------------------------------------
|
---|
[155] | 4844 | series; %first display of the GUI to fill waiting time
|
---|
[2] | 4845 | [param.FileName]=read_file_boxes(handles);
|
---|
| 4846 | if isequal(get(handles.SubField,'Value'),1)
|
---|
| 4847 | FileName_1=read_file_boxes_1(handles);%
|
---|
| 4848 | if ~isequal(FileName_1,param.FileName)
|
---|
| 4849 | param.FileName_1=FileName_1;
|
---|
| 4850 | end
|
---|
| 4851 | end
|
---|
| 4852 | param.NomType=get(handles.FileIndex,'UserData');
|
---|
| 4853 | param.NomType_1=get(handles.FileIndex_1,'UserData');
|
---|
| 4854 | param.comp_input=get(handles.fix_pair,'Value');
|
---|
| 4855 | huvmat=get(handles.MenuSeries,'parent');
|
---|
| 4856 | UvData=get(huvmat,'UserData');
|
---|
| 4857 | if isfield(UvData,'Time')
|
---|
| 4858 | param.Time=UvData.XmlData.Time;
|
---|
| 4859 | end
|
---|
| 4860 | if isequal(get(handles.scan_i,'Value'),1)
|
---|
[128] | 4861 | param.incr_i=str2double(get(handles.increment_scan,'String'));
|
---|
[2] | 4862 | elseif isequal(get(handles.scan_j,'Value'),1)
|
---|
[128] | 4863 | param.incr_j=str2double(get(handles.increment_scan,'String'));
|
---|
[2] | 4864 | end
|
---|
| 4865 | param.list_fields=get(handles.Fields,'String');% list menu fields
|
---|
| 4866 | param.list_fields(1)=[]; %suppress 'image' option
|
---|
| 4867 | param.index_fields=get(handles.Fields,'Value');% selected string index
|
---|
| 4868 | if param.index_fields>1
|
---|
| 4869 | param.index_fields=param.index_fields-1;
|
---|
| 4870 | end
|
---|
| 4871 | param.list_fields_1=get(handles.Fields_1,'String');% list menu fields
|
---|
| 4872 | param.list_fields_1(1)=[]; %suppress 'image' option
|
---|
| 4873 | param.index_fields_1=get(handles.Fields_1,'Value')-1;% selected string index
|
---|
| 4874 | if param.index_fields_1>1
|
---|
| 4875 | param.index_fields_1=param.index_fields_1-1;
|
---|
| 4876 | end
|
---|
| 4877 | param.civ1=get(handles.civ1,'Value');
|
---|
| 4878 | param.civ2=get(handles.civ2,'Value');
|
---|
| 4879 | param.interp1=get(handles.interp1,'Value');
|
---|
| 4880 | param.interp2=get(handles.interp2,'Value');
|
---|
| 4881 | param.filter1=get(handles.filter1,'Value');
|
---|
| 4882 | param.filter2=get(handles.filter2,'Value');
|
---|
[39] | 4883 | param.menu_coord_str=get(handles.transform_fct,'String');
|
---|
| 4884 | param.menu_coord_val=get(handles.transform_fct,'Value');
|
---|
[2] | 4885 |
|
---|
| 4886 | series(param); %run the series interface
|
---|
| 4887 |
|
---|
| 4888 | % ------------------------------------------------------------------
|
---|
| 4889 | % -- open the GUI civ.fig for civx (PIV)
|
---|
| 4890 | % ------------------------------------------------------------------
|
---|
| 4891 | function MenuPIV_Callback(hObject, eventdata, handles)
|
---|
| 4892 |
|
---|
| 4893 | [FileName,RootPath,filebase,FileIndices,ext,SubDir]=read_file_boxes(handles);
|
---|
[45] | 4894 | num1=stra2num(get(handles.i1,'String'));
|
---|
| 4895 | num2=stra2num(get(handles.i2,'String'));
|
---|
| 4896 | num_a=stra2num(get(handles.j1,'String'));
|
---|
| 4897 | num_b=stra2num(get(handles.j2,'String'));
|
---|
[2] | 4898 | NomType=get(handles.FileIndex,'UserData');
|
---|
| 4899 | ind_opening=1; % default (images): will advice civ1 option by default in the civ interface
|
---|
| 4900 | if isequal(ext,'.nc') || isequal(ext,'.cdf')% netcdf files
|
---|
| 4901 | ind_opening=2;% propose 'fix' as the default option
|
---|
| 4902 | % +read the current netcdf rootfile
|
---|
[150] | 4903 | Data=nc2struct(FileName,'ListGlobalAttribute','fix','patch','civ2','fix2');
|
---|
| 4904 | if isfield(Data,'fix') && isequal(Data.fix,1)
|
---|
[2] | 4905 | ind_opening=3;
|
---|
| 4906 | end
|
---|
[150] | 4907 | if isfield(Data,'patch') && isequal(Data.patch,1)
|
---|
[2] | 4908 | ind_opening=4;
|
---|
| 4909 | end
|
---|
[150] | 4910 | if isfield(Data,'civ2') && isequal(Data.civ2,1)
|
---|
[2] | 4911 | ind_opening=5;
|
---|
| 4912 | end
|
---|
[150] | 4913 | if isfield(Data,'fix2') && isequal(Data.fix2,1)
|
---|
[2] | 4914 | ind_opening=6;
|
---|
| 4915 | end
|
---|
| 4916 | end
|
---|
[71] | 4917 | param.RootName=filebase;
|
---|
| 4918 | param.NomType=NomType;
|
---|
| 4919 | param.num1=num1;
|
---|
| 4920 | param.num2=num2;
|
---|
| 4921 | param.num_a=num_a;
|
---|
| 4922 | param.num_b=num_b;
|
---|
| 4923 | param.SubDir=SubDir;
|
---|
| 4924 | param.IndOpening=ind_opening;% A REVOIR +TRANSMETTRE IMADOC INFO
|
---|
| 4925 | param.ImaExt=ext;
|
---|
| 4926 | civ(param);% interface de civ(not in the uvmat file)
|
---|
[150] | 4927 |
|
---|
[2] | 4928 | % ------------------------------------------------------------------
|
---|
| 4929 | function MenuTools_Callback(hObject, eventdata, handles)
|
---|
| 4930 |
|
---|
| 4931 | % ------------------------------------------------------------------
|
---|
[67] | 4932 | function MenuEditObject_Callback(hObject, eventdata, handles)
|
---|
[155] | 4933 | set(handles.edit_object,'Value',1)
|
---|
[67] | 4934 | edit_Callback(hObject, eventdata, handles)
|
---|
[2] | 4935 |
|
---|
| 4936 | %--------------------------------------------------------------------------
|
---|
| 4937 | function enable_transform(handles,state)
|
---|
[39] | 4938 | set(handles.transform_fct,'Visible',state)
|
---|
[2] | 4939 | set(handles.TRANSFORM_txt,'Visible',state)
|
---|
[39] | 4940 | set(handles.transform_fct,'Visible',state)
|
---|
[2] | 4941 | set(handles.path_transform,'Visible',state)
|
---|
| 4942 | set(handles.pxcmx_txt,'Visible',state)
|
---|
| 4943 | set(handles.pxcmy_txt,'Visible',state)
|
---|
| 4944 | set(handles.pxcm,'Visible',state)
|
---|
| 4945 | set(handles.pycm,'Visible',state)
|
---|
| 4946 |
|
---|
[40] | 4947 | %------------------------------------------------------------------------
|
---|
[2] | 4948 | function MenuEditVectors_Callback(hObject, eventdata, handles)
|
---|
[40] | 4949 | %------------------------------------------------------------------------
|
---|
[155] | 4950 | % set(handles.MenuEditVectors,'checked','on')
|
---|
[2] | 4951 | set(handles.edit_vect,'Visible','on')
|
---|
| 4952 | set(handles.edit_vect,'Value',1)
|
---|
| 4953 | edit_vect_Callback(hObject, eventdata, handles)
|
---|
| 4954 |
|
---|
[40] | 4955 | % --------------------------------------------------------------------
|
---|
| 4956 | function Menupoints_Callback(hObject, eventdata, handles)
|
---|
| 4957 | data.Style='points';
|
---|
| 4958 | data.ProjMode='projection';%default
|
---|
[55] | 4959 | create_object(data,handles)
|
---|
[2] | 4960 |
|
---|
[40] | 4961 | % --------------------------------------------------------------------
|
---|
| 4962 | function Menuline_Callback(hObject, eventdata, handles)
|
---|
| 4963 | % set(handles.create,'Visible','on')
|
---|
| 4964 | % set(handles.create,'Value',1)
|
---|
| 4965 | % LINE_Callback(hObject,eventdata,handles)
|
---|
| 4966 | data.Style='line';
|
---|
| 4967 | data.ProjMode='projection';%default
|
---|
[55] | 4968 | create_object(data,handles)
|
---|
[2] | 4969 |
|
---|
[40] | 4970 | %------------------------------------------------------------------------
|
---|
| 4971 | function Menupolyline_Callback(hObject, eventdata, handles)
|
---|
| 4972 | %------------------------------------------------------------------------
|
---|
| 4973 | data.Style='polyline';
|
---|
| 4974 | data.ProjMode='projection';%default
|
---|
[55] | 4975 | create_object(data,handles)
|
---|
[2] | 4976 |
|
---|
[55] | 4977 | %------------------------------------------------------------------------
|
---|
[40] | 4978 | function Menupolygon_Callback(hObject, eventdata, handles)
|
---|
[55] | 4979 | %------------------------------------------------------------------------
|
---|
[45] | 4980 | data.Style='polygon';
|
---|
| 4981 | data.ProjMode='inside';%default
|
---|
[55] | 4982 | create_object(data,handles)
|
---|
[40] | 4983 |
|
---|
| 4984 | %------------------------------------------------------------------------
|
---|
| 4985 | function Menurectangle_Callback(hObject, eventdata, handles)
|
---|
| 4986 | %------------------------------------------------------------------------
|
---|
| 4987 | data.Style='rectangle';
|
---|
| 4988 | data.ProjMode='inside';%default
|
---|
[55] | 4989 | create_object(data,handles)
|
---|
[40] | 4990 |
|
---|
| 4991 | %------------------------------------------------------------------------
|
---|
| 4992 | function Menuellipse_Callback(hObject, eventdata, handles)
|
---|
| 4993 | %------------------------------------------------------------------------
|
---|
| 4994 | data.Style='ellipse';
|
---|
| 4995 | data.ProjMode='inside';%default
|
---|
[55] | 4996 | create_object(data,handles)
|
---|
[40] | 4997 |
|
---|
[82] | 4998 | %------------------------------------------------------------------------
|
---|
| 4999 | function MenuMaskObject_Callback(hObject, eventdata, handles)
|
---|
| 5000 | %------------------------------------------------------------------------
|
---|
| 5001 | data.Style='polygon';
|
---|
| 5002 | data.StyleMenu={'polygon'};
|
---|
| 5003 | data.ProjMode='mask_inside';%default
|
---|
| 5004 | data.ProjMenu={'mask_inside';'mask_outside'};
|
---|
| 5005 | create_object(data,handles)
|
---|
| 5006 |
|
---|
[40] | 5007 | % ------------------------------------------------------------------
|
---|
| 5008 | function Menuplane_Callback(hObject, eventdata, handles)
|
---|
| 5009 | data.Style='plane';
|
---|
| 5010 | data.ProjMode='projection';%default
|
---|
| 5011 |
|
---|
[55] | 5012 | create_object(data,handles)
|
---|
| 5013 |
|
---|
[40] | 5014 | % ------------------------------------------------------------------
|
---|
| 5015 | function Menuvolume_Callback(hObject, eventdata, handles)
|
---|
[77] | 5016 | data.Style='volume';
|
---|
| 5017 | data.ProjMode='interp';%default
|
---|
[61] | 5018 | % set(handles.create,'Visible','on')
|
---|
| 5019 | % set(handles.create,'Value',1)
|
---|
[77] | 5020 | % VOLUME_Callback(hObject,eventdata,handles)
|
---|
| 5021 | create_object(data,handles)
|
---|
[40] | 5022 |
|
---|
| 5023 | %------------------------------------------------------------------------
|
---|
| 5024 | function MenuBrowseObject_Callback(hObject, eventdata, handles)
|
---|
| 5025 | %------------------------------------------------------------------------
|
---|
| 5026 | %get the object file
|
---|
| 5027 | [FileName, PathName, filterindex] = uigetfile( ...
|
---|
| 5028 | {'*.xml;*.mat', ' (*.xml,*.mat)';
|
---|
| 5029 | '*.xml', '.xml files '; ...
|
---|
| 5030 | '*.mat', '.mat matlab files '}, ...
|
---|
[89] | 5031 | 'Pick an xml Object file',get(handles.RootPath,'String'));
|
---|
[40] | 5032 | fileinput=[PathName FileName];%complete file name
|
---|
[163] | 5033 | % testblank=findstr(fileinput,' ');%look for blanks
|
---|
| 5034 | % if ~isempty(testblank)
|
---|
| 5035 | % msgbox_uvmat('ERROR','forbidden input file name: contain blanks')
|
---|
| 5036 | % return
|
---|
| 5037 | % end
|
---|
[40] | 5038 | sizf=size(fileinput);
|
---|
| 5039 | if (~ischar(fileinput)||~isequal(sizf(1),1)),return;end
|
---|
| 5040 |
|
---|
| 5041 | %read the file
|
---|
[55] | 5042 | t=xmltree(fileinput);
|
---|
| 5043 | data=convert(t);
|
---|
[71] | 5044 | data.enable_plot=1;
|
---|
| 5045 | [pp,data.Name]=fileparts(FileName);
|
---|
| 5046 | %PlotHandles=get_plot_handles(handles);%get the handles of the interface elements setting the plotting parameters
|
---|
[99] | 5047 | hset_object=findobj(allchild(0),'tag','set_object');
|
---|
[55] | 5048 | if ~isempty(hset_object)
|
---|
| 5049 | delete(hset_object)% delete existing version of set_object
|
---|
| 5050 | end
|
---|
[155] | 5051 | % UvData=get(handles.uvmat,'UserData');
|
---|
| 5052 | set_object(data);% call the set_object interface
|
---|
[75] | 5053 | % %position the set_object GUI with respect to uvmat
|
---|
| 5054 | % pos_uvmat=get(handles.uvmat,'Position');
|
---|
| 5055 | % if isfield(UvData,'SetObjectOrigin')
|
---|
| 5056 | % pos_set_object(1:2)=UvData.SetObjectOrigin + pos_uvmat(1:2);
|
---|
| 5057 | % pos_set_object(3:4)=UvData.SetObjectSize .* pos_uvmat(3:4);
|
---|
| 5058 | % set(hset_object,'Position',pos_set_object)
|
---|
| 5059 | % end
|
---|
[155] | 5060 | set(handles.edit_object,'Value',0); %suppress the object edit mode
|
---|
| 5061 | set(handles.edit_object,'BackgroundColor',[0.7,0.7,0.7])
|
---|
| 5062 | set(handles.MenuObject,'checked','on')
|
---|
| 5063 | %UvData.MouseAction='create_object';
|
---|
| 5064 | % set(handles.uvmat,'UserData',UvData)
|
---|
[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 |
|
---|
| 5069 | %------------------------------------------------------------------------
|
---|
[71] | 5070 | % --- generic function used for the creation of a projection object
|
---|
[55] | 5071 | function create_object(data,handles)
|
---|
[40] | 5072 | %------------------------------------------------------------------------
|
---|
[75] | 5073 | hset_object=findobj(allchild(0),'tag','set_object');
|
---|
[40] | 5074 | if ~isempty(hset_object)
|
---|
| 5075 | delete(hset_object)% delete existing version of set_object
|
---|
| 5076 | end
|
---|
[55] | 5077 | UvData=get(handles.uvmat,'UserData');
|
---|
[155] | 5078 | set(handles.edit_object,'Value',0); %suppress the object edit mode
|
---|
| 5079 | set(handles.edit_object,'BackgroundColor',[0.7,0.7,0.7])
|
---|
[71] | 5080 | data.enable_plot=1;
|
---|
[82] | 5081 | transform_list=get(handles.transform_fct,'String');
|
---|
| 5082 | val=get(handles.transform_fct,'Value');
|
---|
[158] | 5083 | %data.CoordType=transform_list{val};
|
---|
| 5084 | if isfield(UvData,'Field')
|
---|
| 5085 | Field=UvData.Field;
|
---|
| 5086 | if isfield(Field,'Mesh')&&~isempty(Field.Mesh)
|
---|
| 5087 | data.RangeX=Field.Mesh;
|
---|
| 5088 | data.RangeY=Field.Mesh;
|
---|
| 5089 | data.DX=Field.Mesh;
|
---|
| 5090 | data.DY=Field.Mesh;
|
---|
| 5091 | elseif isfield(Field,'AX')&& isfield(Field,'AY')&& isfield(Field,'A')%only image
|
---|
| 5092 | np=size(Field.A);
|
---|
| 5093 | meshx=(Field.AX(end)-Field.AX(1))/np(2);
|
---|
| 5094 | meshy=abs(Field.AY(end)-Field.AY(1))/np(1);
|
---|
| 5095 | data.RangeY=max(meshx,meshy);
|
---|
| 5096 | data.RangeX=max(meshx,meshy);
|
---|
| 5097 | data.DX=max(meshx,meshy);
|
---|
| 5098 | end
|
---|
| 5099 | if isfield(Field,'NbDim')
|
---|
| 5100 | data.NbDim=Field.NbDim;
|
---|
| 5101 | end
|
---|
| 5102 | if isfield(Field,'CoordUnit')
|
---|
| 5103 | data.CoordUnit=Field.CoordUnit;
|
---|
| 5104 | end
|
---|
[75] | 5105 | end
|
---|
[55] | 5106 | data.Coord=[0 0 0]; %default
|
---|
| 5107 | if isfield(data,'Style') && isequal(data.Style,'line')
|
---|
| 5108 | if isfield(data,'DX')
|
---|
| 5109 | data.Coord=[[0 0 0];[data.DX 0 0]]; %default
|
---|
| 5110 | else
|
---|
| 5111 | data.Coord=[[0 0 0];[1 0 0]]; %default
|
---|
| 5112 | end
|
---|
[40] | 5113 | end
|
---|
[55] | 5114 | if ishandle(handles.UVMAT_title)
|
---|
| 5115 | delete(handles.UVMAT_title)%delete the initial display of uvmat if no field has been entered
|
---|
| 5116 | end
|
---|
| 5117 | PlotHandles=get_plot_handles(handles);%get the handles of the interface elements setting the plotting parameters
|
---|
[155] | 5118 | set_object(data,PlotHandles);% call the set_object interface
|
---|
| 5119 | set(handles.MenuObject,'checked','on')
|
---|
[55] | 5120 | set(handles.uvmat,'UserData',UvData)
|
---|
| 5121 | set(handles.zoom,'Value',0)
|
---|
| 5122 | zoom_Callback(handles.uvmat, [], handles)
|
---|
[72] | 5123 | set(handles.delete_object,'Visible','on')
|
---|
| 5124 | set(handles.uvmat_title,'Visible','on')
|
---|
[75] | 5125 | set(handles.view_field_title,'Visible','on')
|
---|
[40] | 5126 |
|
---|
[71] | 5127 | %------------------------------------------------------------------------
|
---|
[60] | 5128 | function MenuRuler_Callback(hObject, eventdata, handles)
|
---|
[71] | 5129 | %------------------------------------------------------------------------
|
---|
[60] | 5130 | set(handles.zoom,'Value',0)
|
---|
| 5131 | zoom_Callback(handles.uvmat, [], handles)
|
---|
[155] | 5132 | set(handles.MenuRuler,'checked','on')
|
---|
[60] | 5133 | UvData=get(handles.uvmat,'UserData');
|
---|
| 5134 | UvData.MouseAction='ruler';
|
---|
| 5135 | set(handles.uvmat,'UserData',UvData);
|
---|
| 5136 |
|
---|
[67] | 5137 | %------------------------------------------------------------------------
|
---|
[71] | 5138 | % --- executed when closing: set the parent interface button to value 0
|
---|
[67] | 5139 | function closefcn(gcbo,eventdata)
|
---|
| 5140 | %------------------------------------------------------------------------
|
---|
| 5141 | %delete all the associated figures if exist
|
---|
| 5142 | hh=findobj(allchild(0),'tag','view_field');
|
---|
| 5143 | if ~isempty(hh)
|
---|
| 5144 | delete(hh)
|
---|
| 5145 | end
|
---|
[99] | 5146 | hh=findobj(allchild(0),'tag','geometry_calib');
|
---|
[67] | 5147 | if ~isempty(hh)
|
---|
| 5148 | delete(hh)
|
---|
| 5149 | end
|
---|
| 5150 | hh=findobj(allchild(0),'tag','set_object');
|
---|
| 5151 | if ~isempty(hh)
|
---|
| 5152 | hhh=findobj(hh,'tag','PLOT');
|
---|
| 5153 | set(hhh,'enable','off')
|
---|
[71] | 5154 | end
|
---|
| 5155 |
|
---|
| 5156 |
|
---|
| 5157 | % --- Executes on button press in delete_object.
|
---|
| 5158 | function delete_object_Callback(hObject, eventdata, handles)
|
---|
| 5159 | IndexObj=get(handles.list_object_2,'Value');
|
---|
| 5160 | if IndexObj>1
|
---|
| 5161 | delete_object(IndexObj)
|
---|
| 5162 | end
|
---|
| 5163 |
|
---|
| 5164 |
|
---|
[81] | 5165 |
|
---|
| 5166 |
|
---|
| 5167 |
|
---|