[199] | 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
|
---|
| 7 | %%
|
---|
| 8 | %
|
---|
| 9 | %INPUT:
|
---|
| 10 | % input: input file name (if character chain), or input image matrix to
|
---|
| 11 | % visualize, or Matlab structure representing netcdf fields (with fields
|
---|
| 12 | % ListVarName....)
|
---|
| 13 | %
|
---|
| 14 | %AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
|
---|
| 15 | % Copyright Joel Sommeria, 2008, LEGI / CNRS-UJF-INPG, joel.sommeria@legi.grenoble-inp.fr.
|
---|
| 16 | %AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
|
---|
| 17 | % This open is part of the toolbox UVMAT.
|
---|
| 18 | %
|
---|
| 19 | % UVMAT is free software; you can redistribute it and/or modify
|
---|
| 20 | % it under the terms of the GNU General Public License as published by
|
---|
| 21 | % the Free Software Foundation; either version 2 of the License, or
|
---|
| 22 | % (at your option) any later version.
|
---|
| 23 | %
|
---|
| 24 | % UVMAT is distributed in the hope that it will be useful,
|
---|
| 25 | % but WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
| 26 | % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
---|
| 27 | % GNU General Public License (open UVMAT/COPYING.txt) for more details.
|
---|
| 28 | %AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
|
---|
| 29 | %
|
---|
| 30 | % Information stored on the interface:
|
---|
| 31 | % 'Strings' of all edit boxes and menus: get(handles.Tag,'String')
|
---|
| 32 | % 'Values' of all menus and toggle buttons: get(handles.Tag,'Value')
|
---|
| 33 | % Matlab structure called UvData stored as 'UserData' of the figure uvmat.fig,(can be obtained by right mouse click on the interface).
|
---|
| 34 | % It contains the following fields:
|
---|
| 35 | % - Fixed specifiacation of plotting figures and axes (defined bu uvmat_OpeningFcn)
|
---|
| 36 | % .PosColorbar: [0.8210 0.4710 0.0190 0.4450]; specified position of the colorbar on figures
|
---|
| 37 | % - Information read in the documentation open of a series (activated by RootPath_Callback) :
|
---|
| 38 | % .XmlData, with fields:
|
---|
| 39 | % .Time: matrix of times of the images with index i and j
|
---|
| 40 | % .GeometryCalib: [1x1 struct]
|
---|
| 41 | % - Information defined from the interface:
|
---|
| 42 | % .NewSeries: =1 when the first view of a new field series is displayed, else 0
|
---|
| 43 | % .filename:(char string)
|
---|
| 44 | % .VelType:(char string) type of velocity field selected
|
---|
| 45 | % .VelType_1:(char string) REMPLACER LE CELL ACTUEL
|
---|
| 46 | % .FieldName: (char string) main field selected('image', 'velocity'...)
|
---|
| 47 | % .FieldName_1:(char string) second field selected('image', 'velocity'...)
|
---|
| 48 | % .CName: (char string)name of the scalar used for vector colors
|
---|
| 49 | % .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)
|
---|
[236] | 52 | % .VelType_1: last velocity type (VelType, civ2...) for the second input series
|
---|
[199] | 53 | % .FieldName_1: last field name(velocity, vorticity...) for the second input series
|
---|
| 54 | % .ZMin, .ZMax: range of the z coordinate
|
---|
| 55 | %..... to complement
|
---|
| 56 | % - Information on projection objects
|
---|
| 57 | % .Object: {[1x1 struct]}
|
---|
| 58 | % .CurrentObjectIndex: index of the projection object .Object currently selected for editing
|
---|
| 59 | % -Information on the current field (Field{i})
|
---|
| 60 | % .Txt : text information to display (e.g. error message)
|
---|
| 61 | % .NbDim: number of dimensions (=0 by default)
|
---|
| 62 | % .NbCoord: number of vector components
|
---|
| 63 | % .CoordType: expresses the type of coordinate ('px' for image, 'sig' for instruments, or 'phys')
|
---|
| 64 | % .dt: time interval for the corresponding image pair
|
---|
| 65 | % .Mesh: estimated typical distance between vectors
|
---|
| 66 | % .ZMax:
|
---|
| 67 | % .ZMin:
|
---|
| 68 | % .X, .Y, .Z: set of vector coordinates
|
---|
| 69 | % .U,.V,.W: corresponding set of vector components
|
---|
| 70 | % .F: corresponding set of warning flags
|
---|
| 71 | % .FF: corresponding set of false flags, =0 for good vectors
|
---|
| 72 | % .C: corresponding values of the scalar used for vector color
|
---|
| 73 | % (.X, .Y, .Z,.U,.V,.W,.F,.FF,.C are matlab vectors of the same length,
|
---|
| 74 | % equal to the number of vectors stored in the input open)
|
---|
| 75 | % .CName: name of the scalar .C
|
---|
| 76 | % .CType: type of the scalar .C, setting how the scalar is obtained (see 'Scalars' below)
|
---|
| 77 | % .A image or scalar
|
---|
| 78 | % .AX: vector of dimension 2 representing the first and last values
|
---|
| 79 | % of the X coordinates for the image or scalar known on a regular grid,
|
---|
| 80 | % or vector of dimension .A for a scaler defined on irregular grid.
|
---|
| 81 | % .AY: same as .AX along the Y direction
|
---|
| 82 | % .AName: name of the scalar, ='image' for an image
|
---|
| 83 |
|
---|
| 84 | % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%% DATA FLOW (for run0_Callback) %%%%%%%%%%%%%%%%%%%%:
|
---|
| 85 | %
|
---|
| 86 | % fields are opened and visualised by the sub-function refresh_field.m
|
---|
| 87 | % (called by uvmat_opening, RUN0, runp and runm)
|
---|
| 88 | % The function first reads the name of the input file from the edit boxes of the GUI
|
---|
| 89 | % A second input file can be introduced for filed comparison
|
---|
| 90 | % It then reads the input file(s) with the appropriate function, read for
|
---|
| 91 | % images, read_civxdata.m for CIVx PIV data, nc2struct for other netcdf
|
---|
| 92 | % files.
|
---|
| 93 | % Main input open second input open(_1) second image (pair animation)
|
---|
| 94 | % | |
|
---|
| 95 | % | |
|
---|
| 96 | % Field{1} Field{2}
|
---|
| 97 | % |
|
---|
| 98 | % coord transform (phys.m) or other user defined fct acting on Field{i} |
|
---|
| 99 | % Field{i}
|
---|
| 100 | % |
|
---|
| 101 | % calc_field.m: calculate scalar or other derived fields (vort, div..).
|
---|
| 102 | %
|
---|
| 103 | % sub_field.m: combine the input Field{i} in a single set of fields (vector + scalar):
|
---|
| 104 | % Field{i=1->3}.X --> UvData.X |
|
---|
| 105 | % |
|
---|
| 106 | % UvData
|
---|
| 107 | % |
|
---|
| 108 | % plot histograms of the whole field
|
---|
| 109 | % proj_field.m: project the set of fields on the current projection objects defined by UvData.Object
|
---|
| 110 | % | |
|
---|
| 111 | % ObjectData
|
---|
| 112 | % |
|
---|
| 113 | % plot_field.m: plot the projected fields and store them as |
|
---|
| 114 | % UvData.axes3 |
|
---|
| 115 | % |
|
---|
| 116 | % AxeData
|
---|
| 117 | %
|
---|
| 118 | %%%%%%%%%%%%%% SCALARS: %%%%%%%%%%%%??%%%
|
---|
| 119 | % scalars are displayed either as an image or countour plot, either as a color of
|
---|
| 120 | % velocity vectors. The scalar values in the first case is represented by
|
---|
| 121 | % UvData.Field.A, and by UvData.Field.C in the second case. The corresponding set of X
|
---|
| 122 | % and Y coordinates are represented by UvData.Field.AX and UvData.Field.AY, and .X and
|
---|
| 123 | % .Y for C (the same as velocity vectors). If A is a nxxny matrix (scalar
|
---|
| 124 | % on a regtular grid), then .AX andf.AY contains only two elements, represneting the
|
---|
| 125 | % coordinates of the four image corners. The scalar name is represented by
|
---|
| 126 | % the strings .AName and/or .CName.
|
---|
| 127 | % If the scalar exists in an input open (image or scalar stored under its
|
---|
| 128 | % name in a netcdf open), it is directly read at the level of Field{1}or Field{2}.
|
---|
| 129 | % Else only its name AName is recorded in Field{i}, and its field is then calculated
|
---|
| 130 | %by the fuction calc_scal after the coordinate transform or after projection on an edit_object
|
---|
| 131 |
|
---|
| 132 | % Properties attached to plotting figures (standard Matlab properties):
|
---|
| 133 | % 'CurrentAxes'= gca or get(gcf,'CurrentAxes');
|
---|
| 134 | % 'CurrentPoint'=get(gcf,'CurrentPoint'): figure coordinates of the point over which the mouse is positioned
|
---|
| 135 | % 'CurrentCharacter'=get(gcf,'CurrentCharacter'): last character typed over the figure where the mouse is positioned
|
---|
| 136 | % 'WindowButtonMotionFcn': function permanently called by mouse motion over the figure
|
---|
| 137 | % 'KeyPressFcn': function called by pressing a key on the key board
|
---|
| 138 | % 'WindowButtonDownFcn': function called by pressing the mouse over the figure
|
---|
| 139 | % 'WindowButtonUpFcn': function called by releasing the mouse pressure over the figure
|
---|
| 140 |
|
---|
| 141 | % Properties attached to plotting axes:
|
---|
| 142 | % 'CurrentPoint'=get(gca,'CurrentPoint'); (standard Matlab) same as for the figure, but position in plot coordinates.
|
---|
| 143 | % AxeData:=get(gca,'UserData');
|
---|
| 144 | % AxeData.Drawing = create: create a new object
|
---|
| 145 | % = deform: modify an existing object by moving its defining create
|
---|
| 146 | % = off: no current drawing action
|
---|
| 147 | % = translate: translate an existing object
|
---|
| 148 | % = calibration: move a calibration point
|
---|
| 149 | % = zoom: isolate a subregion for zoom in=1 if an object is being currently drawn, 0 else (set to 0 by releasing mouse button)
|
---|
| 150 | % .CurrentOrigin: Origin of a curently drawn edit_object
|
---|
| 151 | % .CurrentLine: currently drawn menuline (A REVOIR)
|
---|
| 152 | % .CurrentObject: handle of the currently drawn edit_object
|
---|
| 153 | % .CurrentRectZoom: current rectangle used for zoom
|
---|
| 154 |
|
---|
| 155 | % Properties attached to projection objects (create, menuline, menuplane...):
|
---|
| 156 | % 'Tag'='proj_object': for all projection objects
|
---|
| 157 | % ObjectData.Style=...: style of projection object:
|
---|
| 158 | % .ProjMode
|
---|
| 159 | % .Coord: defines the position of the object
|
---|
| 160 | % .XMin,YMin....
|
---|
| 161 | % .XMax,YMax....
|
---|
| 162 | % .DX,DY,DZ
|
---|
| 163 | % .Phi, .Theta, .Psi : Euler angles
|
---|
| 164 | % .X,.Y,.U,.V.... : field data projected on the object
|
---|
| 165 | % .IndexObj: index in the list of UvData.Object
|
---|
| 166 | %during plotting
|
---|
| 167 | % .plotaxes: handles of the current axes used to plot the result of field projection on the object
|
---|
| 168 | % .plothandle: vector of handle(s) of the object graphic represnetation in all the opened plotting axes
|
---|
| 169 | % To each projection object #iobj, corresponds an axis
|
---|
| 170 | % Object{iobj}.plotaxes and nbobj representation graphs Object{iobj}.plothandles(:) (where nbobj is the
|
---|
| 171 | % nbre of current objects opened in uvmat. Note that Object{iobj}.plothandles(iobj)=[] : an object is not represented in its own projection field;
|
---|
| 172 |
|
---|
| 173 | %------------------------------------------------------------------------
|
---|
| 174 | %------------------------------------------------------------------------
|
---|
| 175 | % I - MAIN FUNCTION UVMAT (DO NOT MODIFY)
|
---|
| 176 | %------------------------------------------------------------------------
|
---|
| 177 | %------------------------------------------------------------------------
|
---|
| 178 | function varargout = uvmat(varargin)
|
---|
| 179 |
|
---|
| 180 | % Begin initialization code - DO NOT EDIT
|
---|
| 181 | gui_Singleton = 1;
|
---|
| 182 | gui_State = struct('gui_Name', mfilename, ...
|
---|
| 183 | 'gui_Singleton', gui_Singleton, ...
|
---|
| 184 | 'gui_OpeningFcn', @uvmat_OpeningFcn, ...
|
---|
| 185 | 'gui_OutputFcn', @uvmat_OutputFcn, ...
|
---|
| 186 | 'gui_LayoutFcn', [], ...
|
---|
| 187 | 'gui_Callback', []);
|
---|
| 188 | if nargin && ischar(varargin{1})&& ~isempty(regexp(varargin{1},'_Callback','once'))
|
---|
| 189 | gui_State.gui_Callback = str2func(varargin{1});
|
---|
| 190 | end
|
---|
| 191 |
|
---|
| 192 | if nargout
|
---|
| 193 | varargout{1:nargout} = gui_mainfcn(gui_State, varargin{:});
|
---|
| 194 | else
|
---|
| 195 | gui_mainfcn(gui_State, varargin{:});
|
---|
| 196 | end
|
---|
| 197 | % End initialization code - DO NOT EDIT
|
---|
| 198 |
|
---|
| 199 | %------------------------------------------------------------------------
|
---|
| 200 | % --- Executes just before the GUI uvmat is made visible.
|
---|
| 201 | function uvmat_OpeningFcn(hObject, eventdata, handles, input )
|
---|
| 202 | %------------------------------------------------------------------------
|
---|
| 203 |
|
---|
| 204 | %% Choose default command menuline output for uvmat (standard GUI)
|
---|
| 205 | handles.output = hObject;
|
---|
| 206 |
|
---|
| 207 | %% Update handles structure (standard GUI)
|
---|
| 208 | guidata(hObject, handles);
|
---|
| 209 |
|
---|
[277] | 210 | %% check the path and date of modification of all functions in uvmat
|
---|
| 211 | path_to_uvmat=which ('uvmat');% check the path detected for source file uvmat
|
---|
| 212 | [errormsg,date_str,svn_info]=check_files;%check the path of the functions called by uvmat.m
|
---|
| 213 | date_str=['last modification: ' date_str];
|
---|
| 214 |
|
---|
| 215 |
|
---|
[199] | 216 | %% set the position of colorbar and ancillary GUIs:
|
---|
| 217 | set(hObject,'Units','Normalized')
|
---|
| 218 | movegui(hObject,'center')
|
---|
| 219 | UvData.OpenParam.PosColorbar=[0.805 0.022 0.019 0.445];
|
---|
| 220 | UvData.OpenParam.SetObjectOrigin=[-0.05 -0.03]; %position for set_object
|
---|
| 221 | UvData.OpenParam.SetObjectSize=[0.3 0.7];
|
---|
| 222 | UvData.OpenParam.CalOrigin=[0.95 -0.03];%position for geometry_calib (TO IMPROVE)
|
---|
| 223 | UvData.OpenParam.CalSize=[0.28 1];
|
---|
| 224 | UvData.axes3=[];%initiate the record of plotted field
|
---|
| 225 | UvData.axes2=[];
|
---|
| 226 | UvData.axes1=[];
|
---|
| 227 | AxeData.LimEditBox=1; %initialise AxeData
|
---|
| 228 | set(handles.axes3,'UserData',AxeData)
|
---|
| 229 |
|
---|
| 230 | %% set functions for the mouse and keyboard
|
---|
| 231 | set(handles.histo_u,'NextPlot','replacechildren');
|
---|
| 232 | set(handles.histo_v,'NextPlot','replacechildren');
|
---|
| 233 | set(hObject,'KeyPressFcn',{'keyboard_callback',handles})%set keyboard action function
|
---|
| 234 | set(hObject,'WindowButtonMotionFcn',{'mouse_motion',handles})%set mouse action functio
|
---|
| 235 | set(hObject,'WindowButtonDownFcn',{'mouse_down'})%set mouse click action function
|
---|
| 236 | set(hObject,'WindowButtonUpFcn',{'mouse_up',handles})
|
---|
| 237 | set(hObject,'DeleteFcn',{@closefcn})%
|
---|
[252] | 238 | set(handles.list_object_1,'ButtonDownFcn',{@list_object_1_Callback,handles})% allows activation of lis_object_1_callback with right mouse click
|
---|
| 239 | set(handles.list_object_2,'ButtonDownFcn',{@list_object_2_Callback,handles})
|
---|
[199] | 240 |
|
---|
| 241 | %% refresh projection plane
|
---|
| 242 | UvData.Object{1}.ProjMode='projection';%main plotting plane
|
---|
| 243 | set(handles.Fields,'Value',1)
|
---|
| 244 | set(handles.Fields,'string',{''})
|
---|
| 245 |
|
---|
| 246 | %% TRANSFORM menu: builtin fcts
|
---|
| 247 | menu_str={'';'phys';'px';'phys_polar'};
|
---|
| 248 | UvData.OpenParam.NbBuiltin=numel(menu_str); %number of functions
|
---|
| 249 | path_uvmat=fileparts(which('uvmat'));
|
---|
[276] | 250 | addpath (path_uvmat) ; %add the path to UVMAT, (useful in case of change of working directory after civ has been s opened in the working directory)
|
---|
| 251 | addpath(fullfile(path_uvmat,'transform_field'))%add the path to transform functions,
|
---|
[199] | 252 | fct_handle{1,1}=[];
|
---|
| 253 | testexist=zeros(size(menu_str'));%default
|
---|
| 254 | testexist(1)=1;
|
---|
| 255 | for ilist=2:length(menu_str)
|
---|
| 256 | if exist(menu_str{ilist},'file')
|
---|
| 257 | fct_handle{ilist,1}=str2func(menu_str{ilist});
|
---|
| 258 | testexist(ilist)=1;
|
---|
| 259 | else
|
---|
| 260 | testexist(ilist)=0;
|
---|
| 261 | end
|
---|
| 262 | end
|
---|
| 263 | rmpath(fullfile(path_uvmat,'transform_field'))
|
---|
| 264 |
|
---|
| 265 | %% load the list of previously browsed files in menus Open and Open_1
|
---|
| 266 | dir_perso=prefdir; % path to the directory .matlab for personal data
|
---|
| 267 | profil_perso=fullfile(dir_perso,'uvmat_perso.mat');% personal data file uvmauvmat_perso.mat' in .matlab
|
---|
| 268 | if exist(profil_perso,'file')
|
---|
| 269 | h=load (profil_perso);
|
---|
| 270 | if isfield(h,'MenuFile_1')
|
---|
| 271 | set(handles.MenuFile_1,'Label',h.MenuFile_1);
|
---|
| 272 | set(handles.MenuFile_1_1,'Label',h.MenuFile_1);
|
---|
| 273 | end
|
---|
| 274 | if isfield(h,'MenuFile_2')
|
---|
| 275 | set(handles.MenuFile_2,'Label',h.MenuFile_2);
|
---|
| 276 | set(handles.MenuFile_2_1,'Label',h.MenuFile_2);
|
---|
| 277 | end
|
---|
| 278 | if isfield(h,'MenuFile_3')
|
---|
| 279 | set(handles.MenuFile_3,'Label',h.MenuFile_3);
|
---|
| 280 | set(handles.MenuFile_3_1,'Label',h.MenuFile_3);
|
---|
| 281 | end
|
---|
| 282 | if isfield(h,'MenuFile_4')
|
---|
| 283 | set(handles.MenuFile_4,'Label',h.MenuFile_4);
|
---|
| 284 | set(handles.MenuFile_4_1,'Label',h.MenuFile_4);
|
---|
| 285 | end
|
---|
| 286 | if isfield(h,'MenuFile_5')
|
---|
| 287 | set(handles.MenuFile_5,'Label',h.MenuFile_5);
|
---|
| 288 | set(handles.MenuFile_5_1,'Label',h.MenuFile_5);
|
---|
| 289 | end
|
---|
| 290 | if isfield(h,'transform_fct') && iscell(h.transform_fct)
|
---|
| 291 | for ilist=1:length(h.transform_fct);
|
---|
| 292 | if exist(h.transform_fct{ilist},'file')
|
---|
| 293 | [path,file]=fileparts(h.transform_fct{ilist});
|
---|
| 294 | addpath(path)
|
---|
| 295 | h_func=str2func(file);
|
---|
| 296 | rmpath(path)
|
---|
| 297 | testexist=[testexist 1];
|
---|
| 298 | else
|
---|
| 299 | file='';
|
---|
| 300 | h_func=[];
|
---|
| 301 | testexist=[testexist 0];
|
---|
| 302 | end
|
---|
| 303 | fct_handle=[fct_handle; {h_func}]; %concatene the list of paths
|
---|
| 304 | menu_str=[menu_str; {file}];
|
---|
| 305 | end
|
---|
| 306 | end
|
---|
| 307 | end
|
---|
| 308 | menu_str=menu_str(testexist==1);%=menu_str(testexist~=0)
|
---|
| 309 | fct_handle=fct_handle(testexist==1);
|
---|
| 310 | menu_str=[menu_str;{'more...'}];
|
---|
| 311 | set(handles.transform_fct,'String',menu_str)
|
---|
| 312 | set(handles.transform_fct,'UserData',fct_handle)% store the list of path in UserData of ACTION
|
---|
| 313 |
|
---|
[231] | 314 |
|
---|
[199] | 315 |
|
---|
| 316 | %% case of an input argument for uvmat
|
---|
| 317 | testinputfield=0;
|
---|
| 318 | inputfile=[];
|
---|
| 319 | Field=[];
|
---|
| 320 | if exist('input','var')
|
---|
| 321 | if ~isempty(errormsg)
|
---|
| 322 | msgbox_uvmat('WARNING',errormsg)
|
---|
| 323 | end
|
---|
| 324 | if ishandle(handles.UVMAT_title)
|
---|
| 325 | delete(handles.UVMAT_title)
|
---|
| 326 | end
|
---|
| 327 | if isstruct(input)
|
---|
| 328 | if isfield(input,'InputFile')
|
---|
| 329 | inputfile=input.InputFile;
|
---|
| 330 | end
|
---|
[231] | 331 | if isfield(input,'TimeIndex')
|
---|
| 332 | set(handles.i1,num2str(input.TimeIndex))
|
---|
[227] | 333 | end
|
---|
[231] | 334 | if isfield(input,'FieldsString')
|
---|
| 335 | % set(handles.Fields,'Value',1)
|
---|
| 336 | UvData.FieldsString=input.FieldsString;
|
---|
| 337 | end
|
---|
[199] | 338 | elseif ischar(input)% file name introduced as input
|
---|
| 339 | inputfile=input;
|
---|
| 340 | elseif isnumeric(input)%simple matrix introduced as input
|
---|
| 341 | sizinput=size(input);
|
---|
| 342 | if sizinput(1)<=1 || sizinput(2)<=1
|
---|
| 343 | msgbox_uvmat('ERROR','bad input for uvmat: file name, structure or numerical matrix accepted')
|
---|
| 344 | return
|
---|
| 345 | end
|
---|
[231] | 346 | UvData.Field.ListVarName={'A','coord_y','coord_x'};
|
---|
| 347 | UvData.Field.VarDimName={{'coord_y','coord_x'},'cord_y','coord_x'};
|
---|
| 348 | UvData.Field.A=input;
|
---|
| 349 | UvData.Field.coord_x=[0.5 size(input,2)-0.5];
|
---|
| 350 | UvData.Field.coord_y=[size(input,1)-0.5 0.5];
|
---|
[199] | 351 | testinputfield=1;
|
---|
| 352 | end
|
---|
| 353 | else
|
---|
| 354 | if ishandle(handles.UVMAT_title)
|
---|
[277] | 355 | set(handles.UVMAT_title,'String',...
|
---|
| 356 | [{'Copyright LEGI UMR 5519 /CNRS-UJF-Grenoble INP, 2010'};...
|
---|
| 357 | {'GNU General Public License'};...
|
---|
| 358 | {path_to_uvmat};...
|
---|
| 359 | {date_str};...
|
---|
[278] | 360 | {['SVN revision : ' num2str(svn_info.cur_rev)]};...
|
---|
[277] | 361 | errormsg]);
|
---|
[199] | 362 | end
|
---|
| 363 | end
|
---|
[231] | 364 | set(handles.uvmat,'UserData',UvData)
|
---|
| 365 | if ~isempty(inputfile)
|
---|
| 366 | %%%%% display the input field %%%%%%%
|
---|
| 367 | display_file_name(hObject, eventdata, handles,inputfile)
|
---|
| 368 | %%%%%%%
|
---|
| 369 | testinputfield=1;
|
---|
| 370 | end
|
---|
[199] | 371 |
|
---|
| 372 | %% plot input field if exists
|
---|
| 373 | if testinputfield
|
---|
| 374 | %delete drawn objects
|
---|
| 375 | hother=findobj(handles.axes3,'Tag','proj_object');%find all the proj objects
|
---|
| 376 | for iobj=1:length(hother)
|
---|
| 377 | delete_object(hother(iobj))
|
---|
| 378 | end
|
---|
| 379 | if isempty(inputfile)
|
---|
| 380 | errormsg=refresh_field(handles,[],[],[],[],[],[],{Field});
|
---|
| 381 | set(handles.MenuTools,'Enable','on')
|
---|
| 382 | set(handles.OBJECT_txt,'Visible','on')
|
---|
| 383 | set(handles.edit_object,'Visible','on')
|
---|
| 384 | set(handles.list_object_1,'Visible','on')
|
---|
| 385 | set(handles.frame_object,'Visible','on')
|
---|
| 386 | if ~isempty(errormsg)
|
---|
| 387 | msgbox_uvmat('ERROR',errormsg)
|
---|
| 388 | end
|
---|
| 389 | end
|
---|
| 390 | end
|
---|
[236] | 391 |
|
---|
[199] | 392 | set_vec_col_bar(handles) %update the display of color code for vectors
|
---|
| 393 |
|
---|
| 394 | %------------------------------------------------------------------------
|
---|
| 395 | % --- Outputs from this function are returned to the command menuline.
|
---|
| 396 | function varargout = uvmat_OutputFcn(hObject, eventdata, handles)
|
---|
| 397 | varargout{1} = handles.output;% the only output argument is the handle to the GUI figure
|
---|
| 398 |
|
---|
| 399 | %------------------------------------------------------------------------
|
---|
| 400 | %------------------------------------------------------------------------
|
---|
| 401 | % II - FUNCTIONS FOR INTRODUCING THE INPUT FILES
|
---|
| 402 | % automatically sets the global properties when the rootfile name is introduced
|
---|
| 403 | % then activate the view-field action if selected
|
---|
| 404 | % it is activated either by clicking on the RootPath window or by the
|
---|
| 405 | % browser
|
---|
| 406 | %------------------------------------------------------------------------
|
---|
| 407 | %------------------------------------------------------------------------
|
---|
| 408 | % --- Executes on the menu Open/Browse...
|
---|
| 409 | % search the files, recognize their type according to their name and fill the rootfile input windows
|
---|
| 410 | function MenuBrowse_Callback(hObject, eventdata, handles)
|
---|
| 411 | oldfile=read_file_boxes(handles);
|
---|
| 412 |
|
---|
| 413 | if isempty(oldfile)||isequal(oldfile,'') %loads the previously stored file name and set it as default in the file_input box
|
---|
| 414 | dir_perso=prefdir;
|
---|
| 415 | profil_perso=fullfile(dir_perso,'uvmat_perso.mat');
|
---|
| 416 | if exist(profil_perso,'file')
|
---|
| 417 | h=load (profil_perso);
|
---|
| 418 | if isfield(h,'MenuFile_1')
|
---|
| 419 | oldfile=h.MenuFile_1;
|
---|
| 420 | end
|
---|
| 421 | end
|
---|
| 422 | end
|
---|
| 423 | [FileName, PathName] = uigetfile( ...
|
---|
| 424 | {'*.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)';
|
---|
| 425 | '*.xml', '.xml files '; ...
|
---|
| 426 | '*.xls', '.xls files '; ...
|
---|
| 427 | '*.civ', '.civ files '; ...
|
---|
| 428 | '*.jpg',' jpeg image files'; ...
|
---|
| 429 | '*.png','.png image files'; ...
|
---|
| 430 | '*.tif','.tif image files'; ...
|
---|
| 431 | '*.avi;*.AVI','.avi movie files'; ...
|
---|
| 432 | '*.vol','.volume images (png)'; ...
|
---|
| 433 | '*.nc','.netcdf files'; ...
|
---|
| 434 | '*.cdf','.netcdf files'; ...
|
---|
| 435 | '*.cmx','.cmx text files ';...
|
---|
| 436 | '*.fig','.fig files (matlab fig)';...
|
---|
| 437 | '*.log','.log text files ';...
|
---|
| 438 | '*.dat','.dat text files ';...
|
---|
| 439 | '*.bat','.bat system command text files';...
|
---|
| 440 | '*.*', 'All Files (*.*)'}, ...
|
---|
| 441 | 'Pick a file',oldfile);
|
---|
| 442 | fileinput=[PathName FileName];%complete file name
|
---|
| 443 | sizf=size(fileinput);
|
---|
| 444 | if (~ischar(fileinput)||~isequal(sizf(1),1)),return;end
|
---|
| 445 |
|
---|
| 446 | % display the selected field and related information
|
---|
| 447 | display_file_name(hObject, eventdata, handles,fileinput)
|
---|
| 448 |
|
---|
| 449 | %update list of recent files in the menubar
|
---|
| 450 | MenuFile_1=fileinput;
|
---|
| 451 | MenuFile_2=get(handles.MenuFile_1,'Label');
|
---|
| 452 | MenuFile_3=get(handles.MenuFile_2,'Label');
|
---|
| 453 | MenuFile_4=get(handles.MenuFile_3,'Label');
|
---|
| 454 | MenuFile_5=get(handles.MenuFile_4,'Label');
|
---|
| 455 | set(handles.MenuFile_1,'Label',MenuFile_1)
|
---|
| 456 | set(handles.MenuFile_2,'Label',MenuFile_2)
|
---|
| 457 | set(handles.MenuFile_3,'Label',MenuFile_3)
|
---|
| 458 | set(handles.MenuFile_4,'Label',MenuFile_4)
|
---|
| 459 | set(handles.MenuFile_5,'Label',MenuFile_5)
|
---|
| 460 | set(handles.MenuFile_1_1,'Label',MenuFile_1)
|
---|
| 461 | set(handles.MenuFile_2_1,'Label',MenuFile_2)
|
---|
| 462 | set(handles.MenuFile_3_1,'Label',MenuFile_3)
|
---|
| 463 | set(handles.MenuFile_4_1,'Label',MenuFile_4)
|
---|
| 464 | set(handles.MenuFile_5_1,'Label',MenuFile_5)
|
---|
| 465 | dir_perso=prefdir;
|
---|
| 466 | profil_perso=fullfile(dir_perso,'uvmat_perso.mat');
|
---|
| 467 | if exist(profil_perso,'file')
|
---|
| 468 | save (profil_perso,'MenuFile_1','MenuFile_2','MenuFile_3','MenuFile_4', 'MenuFile_5','-append'); %store the file names for future opening of uvmat
|
---|
| 469 | else
|
---|
| 470 | txt=ver('MATLAB');
|
---|
| 471 | Release=txt.Release;
|
---|
| 472 | relnumb=str2double(Release(3:4));
|
---|
| 473 | if relnumb >= 14
|
---|
| 474 | save (profil_perso,'MenuFile_1','MenuFile_2','MenuFile_3','MenuFile_4', 'MenuFile_5','-V6'); %store the file names for future opening of uvmat
|
---|
| 475 | else
|
---|
| 476 | save (profil_perso,'MenuFile_1','MenuFile_2','MenuFile_3','MenuFile_4', 'MenuFile_5'); %store the file names for future opening of uvmat
|
---|
| 477 | end
|
---|
| 478 | end
|
---|
| 479 |
|
---|
| 480 | % -----------------------------------------------------------------------
|
---|
| 481 | % --- Open again the file whose name has been recorded in MenuFile_1
|
---|
| 482 | function MenuFile_1_Callback(hObject, eventdata, handles)
|
---|
[227] | 483 | %------------------------------------------------------------------------
|
---|
[199] | 484 | fileinput=get(handles.MenuFile_1,'Label');
|
---|
| 485 | display_file_name(hObject, eventdata, handles,fileinput)
|
---|
| 486 |
|
---|
| 487 | % -----------------------------------------------------------------------
|
---|
| 488 | % --- Open again the file whose name has been recorded in MenuFile_2
|
---|
| 489 | function MenuFile_2_Callback(hObject, eventdata, handles)
|
---|
[227] | 490 | %------------------------------------------------------------------------
|
---|
[199] | 491 | fileinput=get(handles.MenuFile_2,'Label');
|
---|
| 492 | display_file_name(hObject, eventdata, handles,fileinput)
|
---|
| 493 |
|
---|
| 494 | % -----------------------------------------------------------------------
|
---|
| 495 | % --- Open again the file whose name has been recorded in MenuFile_3
|
---|
| 496 | function MenuFile_3_Callback(hObject, eventdata, handles)
|
---|
[227] | 497 | %------------------------------------------------------------------------
|
---|
[199] | 498 | fileinput=get(handles.MenuFile_3,'Label');
|
---|
| 499 | display_file_name(hObject, eventdata, handles,fileinput)
|
---|
| 500 |
|
---|
| 501 | % -----------------------------------------------------------------------
|
---|
| 502 | % --- Open again the file whose name has been recorded in MenuFile_4
|
---|
| 503 | function MenuFile_4_Callback(hObject, eventdata, handles)
|
---|
[227] | 504 | %------------------------------------------------------------------------
|
---|
[199] | 505 | fileinput=get(handles.MenuFile_4,'Label');
|
---|
| 506 | display_file_name(hObject, eventdata, handles,fileinput)
|
---|
| 507 |
|
---|
| 508 | % -----------------------------------------------------------------------
|
---|
| 509 | % --- Open again the file whose name has been recorded in MenuFile_5
|
---|
| 510 | function MenuFile_5_Callback(hObject, eventdata, handles)
|
---|
[227] | 511 | %------------------------------------------------------------------------
|
---|
[199] | 512 | fileinput=get(handles.MenuFile_5,'Label');
|
---|
| 513 | display_file_name(hObject, eventdata, handles,fileinput)
|
---|
| 514 |
|
---|
| 515 | %------------------------------------------------------------------------
|
---|
| 516 | % --- Fills the edit boxes RootPath, RootFile,NomType...from an input file name 'fileinput'
|
---|
| 517 | function display_file_name(hObject, eventdata, handles,fileinput)
|
---|
[227] | 518 | %------------------------------------------------------------------------
|
---|
[199] | 519 | if ~exist(fileinput,'file')
|
---|
| 520 | msgbox_uvmat('ERROR',['input file ' fileinput ' does not exist'])
|
---|
| 521 | return
|
---|
| 522 | end
|
---|
[236] | 523 | [RootPath,RootFile,i1,i2,str_a,str_b,ext,NomType,SubDir]=name2display(fileinput);%extract information from the file name
|
---|
[199] | 524 | ext_test=''; %default
|
---|
[236] | 525 | if ~isempty(ext) % if a file extension is detected
|
---|
[199] | 526 | form=imformats(ext(2:end));%test valid Matlab image formats
|
---|
| 527 | if ~isempty(form)
|
---|
| 528 | ext_test='.image';
|
---|
| 529 | imainfo=imfinfo(fileinput);
|
---|
| 530 | if length(imainfo) >1 %case of image with multiple frames
|
---|
| 531 | i1='1'; % set the frame counter to 1 by default
|
---|
| 532 | i2='';
|
---|
| 533 | str_a='';
|
---|
| 534 | str_b='';
|
---|
| 535 | NomType='*'; %indicate a set of indexed frames within a single file
|
---|
| 536 | [RootPath,RootFile]=fileparts(fileinput); %include the indices in the root file
|
---|
| 537 | end
|
---|
[236] | 538 | elseif isequal(lower(ext),'.avi')%case of avi movie file
|
---|
[199] | 539 | ext_test='.image';
|
---|
| 540 | i1='1'; % set the frame counter to 1 by default
|
---|
| 541 | i2='';
|
---|
| 542 | str_a='';
|
---|
| 543 | str_b='';
|
---|
| 544 | NomType='*'; %indicate a set of indexed frames within a single file
|
---|
| 545 | [RootPath,RootFile]=fileparts(fileinput); %include the indices in the root file
|
---|
| 546 | else
|
---|
| 547 | ext_test=lower(ext);
|
---|
| 548 | end
|
---|
| 549 | end
|
---|
| 550 | switch ext_test
|
---|
| 551 | case {'.civ','.log','.cmx','.cmx2','.txt','.bat'} %display text file
|
---|
| 552 | edit(fileinput)
|
---|
| 553 | case '.fig' %display matlab figure
|
---|
| 554 | hfig=open(fileinput);
|
---|
| 555 | set(hfig,'WindowButtonMotionFcn','mouse_motion')%set mouse action functio
|
---|
| 556 | set(hfig,'WindowButtonUpFcn','mouse_up')%set mouse click action function
|
---|
| 557 | set(hfig,'WindowButtonUpFcn','mouse_down')%set mouse click action function
|
---|
| 558 | case {'.xml','.xls'} % edit xml or Excel files
|
---|
| 559 | editxml(fileinput);
|
---|
| 560 | case {'.avi','.image','.vol','.nc','.cdf'}
|
---|
| 561 | set(handles.RootPath,'String',RootPath);
|
---|
| 562 | if isequal(SubDir,'')
|
---|
| 563 | rootname=fullfile(RootPath,RootFile);
|
---|
| 564 | else
|
---|
| 565 | rootname=fullfile(RootPath,SubDir,RootFile);
|
---|
| 566 | SubDir=['/' SubDir]; %display the separator
|
---|
| 567 | end
|
---|
| 568 | set(handles.SubDir,'String',SubDir);
|
---|
| 569 | set(handles.RootFile,'String',['/' RootFile]); %display the separator
|
---|
| 570 | indices=fileinput(length(rootname)+1:end);
|
---|
| 571 | indices(end-length(ext)+1:end)=[]; %remove extension
|
---|
| 572 | set(handles.FileIndex,'String',indices);
|
---|
| 573 | set(handles.FileIndex,'UserData',NomType);
|
---|
| 574 | set(handles.FileExt,'String',ext);
|
---|
| 575 | % fill file index counters
|
---|
| 576 | set(handles.i1,'String',i1);
|
---|
| 577 | set(handles.i2,'String',i2);
|
---|
| 578 | set(handles.j1,'String',str_a);
|
---|
| 579 | set(handles.j2,'String',str_b);
|
---|
| 580 |
|
---|
| 581 | % synchronise indices of the second input file if it exists
|
---|
| 582 | if get(handles.SubField,'Value')==1% if the subfield button is activated, update the field numbers
|
---|
| 583 | [ff,rr,FileBase_1,ii,FileExt_1,SubDir_1]=read_file_boxes_1(handles);
|
---|
| 584 | NomType_1=get(handles.FileIndex_1,'UserData');
|
---|
| 585 | FileName_1=name_generator(FileBase_1,str2double(i1),str2double(i2),FileExt_1,NomType_1,1,stra2num(str_a),stra2num(str_b),SubDir_1);
|
---|
| 586 | if exist(FileName_1,'file')
|
---|
| 587 | FileIndex_1=name_generator('',str2double(i1),str2double(i2),'',NomType_1,1,stra2num(str_a),stra2num(str_b),'');
|
---|
| 588 | set(handles.FileIndex_1,'String',FileIndex_1)
|
---|
| 589 | else
|
---|
| 590 | set(handles.SubField,'Value',0)
|
---|
| 591 | SubField_Callback(hObject, eventdata, handles)
|
---|
| 592 | end
|
---|
| 593 | end
|
---|
| 594 |
|
---|
| 595 | %enable other menus
|
---|
| 596 | set(handles.MenuOpen_1,'Enable','on')
|
---|
| 597 | set(handles.MenuFile_1_1,'Enable','on')
|
---|
| 598 | set(handles.MenuFile_2_1,'Enable','on')
|
---|
| 599 | set(handles.MenuFile_3_1,'Enable','on')
|
---|
| 600 | set(handles.MenuFile_4_1,'Enable','on')
|
---|
| 601 | set(handles.MenuFile_5_1,'Enable','on')
|
---|
| 602 | set(handles.MenuExport,'Enable','on')
|
---|
| 603 | set(handles.MenuExportFigure,'Enable','on')
|
---|
| 604 | set(handles.MenuExportMovie,'Enable','on')
|
---|
| 605 | set(handles.MenuTools,'Enable','on')
|
---|
| 606 | set(handles.OBJECT_txt,'Visible','on')
|
---|
| 607 | set(handles.edit_object,'Visible','on')
|
---|
| 608 | set(handles.list_object_1,'Visible','on')
|
---|
| 609 | set(handles.frame_object,'Visible','on')
|
---|
| 610 | %%%%%% initiate input file:
|
---|
| 611 | update_rootinfo(hObject,eventdata,handles);
|
---|
| 612 | otherwise
|
---|
| 613 | msgbox_uvmat('ERROR',['invalid input file extension' ext])
|
---|
| 614 | end
|
---|
| 615 |
|
---|
| 616 | %------------------------------------------------------------------------
|
---|
| 617 | % --- Called by action in RootPath edit box
|
---|
| 618 | function RootPath_Callback(hObject,eventdata,handles)
|
---|
| 619 | %------------------------------------------------------------------------
|
---|
| 620 | update_rootinfo(hObject,eventdata,handles);
|
---|
| 621 |
|
---|
| 622 | %------------------------------------------------------------------------
|
---|
| 623 | % --- Called by action in RootFile edit box
|
---|
| 624 | function SubDir_Callback(hObject, eventdata, handles)
|
---|
| 625 | %------------------------------------------------------------------------
|
---|
| 626 | %refresh the menu of input fields
|
---|
| 627 | Fields_Callback(hObject, eventdata, handles);
|
---|
| 628 | % refresh the current field
|
---|
| 629 | run0_Callback(hObject, eventdata, handles);
|
---|
| 630 |
|
---|
| 631 | %------------------------------------------------------------------------
|
---|
| 632 | % --- Called by action in RootFile edit box
|
---|
| 633 | function RootFile_Callback(hObject, eventdata, handles)
|
---|
| 634 | %------------------------------------------------------------------------
|
---|
| 635 | update_rootinfo(hObject,eventdata,handles)
|
---|
| 636 |
|
---|
| 637 | %------------------------------------------------------------------------
|
---|
| 638 | % --- Called by action in FileIndex edit box
|
---|
| 639 | function FileIndex_Callback(hObject, eventdata, handles)
|
---|
| 640 | %------------------------------------------------------------------------
|
---|
| 641 | FileIndices=get(handles.FileIndex,'String');
|
---|
| 642 | if isempty(str2num(FileIndices))
|
---|
| 643 | [pp,ff,str1,str2,str_a,str_b]=name2display(FileIndices);
|
---|
| 644 | else
|
---|
| 645 | str1=FileIndices;
|
---|
| 646 | str2='';
|
---|
| 647 | str_a='';
|
---|
| 648 | str_b='';
|
---|
| 649 | end
|
---|
| 650 | set(handles.i1,'String',str1);
|
---|
| 651 | set(handles.i2,'String',str2);
|
---|
| 652 | set(handles.j1,'String',str_a);
|
---|
| 653 | set(handles.j2,'String',str_b);
|
---|
| 654 | run0_Callback(hObject, eventdata, handles)
|
---|
| 655 |
|
---|
| 656 | %------------------------------------------------------------------------
|
---|
| 657 | % --- Update information about a new field series (indices to scan, timing,
|
---|
| 658 | % calibration from an xml file, then refresh current plots
|
---|
| 659 | function update_rootinfo(hObject,eventdata,handles)
|
---|
| 660 | %------------------------------------------------------------------------
|
---|
| 661 | set(handles.RootPath,'BackgroundColor',[1 1 0])
|
---|
| 662 | drawnow
|
---|
| 663 | set(handles.Fields,'UserData',[])% reinialize data from uvmat opening
|
---|
| 664 | UvData=get(handles.uvmat,'UserData');%huvmat=handles of the uvmat interface
|
---|
| 665 | UvData.NewSeries=1; %flag for run0: begin a new series
|
---|
| 666 | UvData.TestInputFile=1;
|
---|
| 667 | set(handles.fix_pair,'Value',1) % activate by default the comp_input '-'input window
|
---|
[236] | 668 | set(handles.FixVelType,'Value',0); %desactivate fixed veltype
|
---|
[199] | 669 | [FileName,RootPath,FileBase,FileIndices,FileExt,SubDir]=read_file_boxes(handles);
|
---|
| 670 | if ~exist(FileName,'file')
|
---|
| 671 | msgbox_uvmat('ERROR',['input file ' FileName ' not found']);
|
---|
| 672 | return
|
---|
| 673 | end
|
---|
| 674 | nbfield=[];%default
|
---|
| 675 | nburst=[];%default
|
---|
| 676 |
|
---|
| 677 | % read timing and total frame number from the current file (movie files) !! may be overrid by xml file
|
---|
| 678 | XmlData.Time=[];%default
|
---|
| 679 | XmlData.GeometryCalib=[];%default
|
---|
| 680 | TimeUnit=[];%default
|
---|
| 681 | testima=0; %test for image input
|
---|
| 682 | imainfo=[];
|
---|
| 683 | ColorType='falsecolor'; %default
|
---|
| 684 | hhh='';
|
---|
| 685 | if isequal(lower(FileExt),'.avi') %.avi file
|
---|
| 686 | testima=1;
|
---|
| 687 | imainfo=aviinfo([FileBase FileIndices FileExt]);
|
---|
| 688 | nbfield=imainfo.NumFrames;
|
---|
| 689 | nburst=1;
|
---|
| 690 | set(handles.Dt_txt,'String',['Dt=' num2str(1000/imainfo.FramesPerSecond) 'ms']);%display the elementary time interval in millisec
|
---|
| 691 | XmlData.Time=(0:1/imainfo.FramesPerSecond:(imainfo.NumFrames-1)/imainfo.FramesPerSecond)';
|
---|
| 692 | TimeUnit='s';
|
---|
| 693 | hhh=which('mmreader');
|
---|
| 694 | ColorType=imainfo.ImageType;%='truecolor' for color images
|
---|
| 695 | elseif ~isempty(FileExt(2:end))&&(~isempty(imformats(FileExt(2:end))) || isequal(FileExt,'.vol'))%&& isequal(NomType,'*')% multi-frame image
|
---|
| 696 | testima=1;
|
---|
| 697 | if ~isequal(SubDir,'')
|
---|
| 698 | RootFile=get(handles.RootFile,'String');
|
---|
| 699 | imainfo=imfinfo([fullfile(RootPath,SubDir,RootFile) FileIndices FileExt]);
|
---|
| 700 | else
|
---|
| 701 | imainfo=imfinfo([FileBase FileIndices FileExt]);
|
---|
| 702 | end
|
---|
| 703 | ColorType=imainfo.ColorType;%='truecolor' for color images
|
---|
| 704 | if length(imainfo) >1 %case of image with multiple frames
|
---|
| 705 | nbfield=length(imainfo);
|
---|
| 706 | nburst=1;
|
---|
| 707 | end
|
---|
| 708 | end
|
---|
| 709 | if ~strcmp(hhh,'')&& mmreader.isPlatformSupported()% if the function is found (recent version of matlab)
|
---|
| 710 | UvData.MovieObject=mmreader([FileBase FileIndices FileExt]);
|
---|
| 711 | elseif isfield(UvData,'MovieObject')
|
---|
| 712 | UvData=rmfield(UvData,'MovieObject');
|
---|
| 713 | end
|
---|
| 714 | if isfield(imainfo,'Width') && isfield(imainfo,'Height')
|
---|
[271] | 715 | if length(imainfo)>1
|
---|
| 716 | set(handles.npx,'String',num2str(imainfo(1).Width));%fills nbre of pixels x box
|
---|
| 717 | set(handles.npy,'String',num2str(imainfo(1).Height));%fills nbre of pixels x box
|
---|
| 718 | else
|
---|
| 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 | end
|
---|
[199] | 722 | else
|
---|
| 723 | set(handles.npx,'String','');%fills nbre of pixels x box
|
---|
| 724 | set(handles.npy,'String','');%fills nbre of pixels x box
|
---|
| 725 | end
|
---|
| 726 | set(handles.BW,'Value',strcmp(ColorType,'grayscale'))% select handles.BW if grayscale image
|
---|
| 727 |
|
---|
| 728 | % read parameters (time, geometric calibration..) from a documentation file (.xml advised)
|
---|
| 729 | filexml=[FileBase '.xml'];
|
---|
| 730 | fileciv=[FileBase '.civ'];
|
---|
| 731 | warntext='';%default warning message
|
---|
| 732 | NbSlice=1;%default
|
---|
| 733 |
|
---|
| 734 | if exist(filexml,'file')
|
---|
| 735 | set(handles.view_xml,'Visible','on')
|
---|
| 736 | set(handles.view_xml,'BackgroundColor',[1 1 0])
|
---|
| 737 | set(handles.RootPath,'BackgroundColor',[1 1 1])
|
---|
| 738 | set(handles.view_xml,'String','view .xml')
|
---|
| 739 | drawnow
|
---|
| 740 | [XmlData,warntext]=imadoc2struct(filexml);
|
---|
| 741 | if ~isempty(warntext)
|
---|
| 742 | msgbox_uvmat('WARNING',warntext)
|
---|
| 743 | end
|
---|
| 744 | if isfield(XmlData,'TimeUnit')
|
---|
| 745 | if isfield(XmlData,'TimeUnit')&& ~isempty(XmlData.TimeUnit)
|
---|
| 746 | TimeUnit=XmlData.TimeUnit;
|
---|
| 747 | end
|
---|
| 748 | end
|
---|
| 749 | set(handles.view_xml,'BackgroundColor',[1 1 1])
|
---|
| 750 | drawnow
|
---|
| 751 | if isfield(XmlData, 'GeometryCalib') && ~isempty(XmlData.GeometryCalib)
|
---|
| 752 | XmlData.GeometryCalib
|
---|
| 753 | if isfield(XmlData.GeometryCalib,'VolumeScan') && isequal(XmlData.GeometryCalib.VolumeScan,'y')
|
---|
| 754 | set (handles.nb_slice,'String','volume')
|
---|
| 755 | end
|
---|
| 756 | hgeometry_calib=findobj('tag','geometry_calib');
|
---|
| 757 | if ~isempty(hgeometry_calib)
|
---|
| 758 | GUserData=get(hgeometry_calib,'UserData');
|
---|
| 759 | if ~(isfield(GUserData,'XmlInputFile') && strcmp(GUserData.XmlInputFile,filexml))
|
---|
| 760 | answer=msgbox_uvmat('INPUT_Y-N','replace the display of geometry_calib with the new input data?');
|
---|
| 761 | if strcmp(answer,'Yes')
|
---|
| 762 | geometry_calib(filexml);%diplay the new calibration points and parameters in geometry_calib
|
---|
| 763 | end
|
---|
| 764 | end
|
---|
| 765 | end
|
---|
| 766 | end
|
---|
| 767 | elseif exist(fileciv,'file')% if .civ file found
|
---|
| 768 | [error,XmlData.Time,TimeUnit,mode,npx,npy,pxcmx,pxcmy]=read_imatext([FileBase '.civ']);
|
---|
| 769 | GeometryCalib.R=[pxcmx 0 0; 0 pxcmy 0;0 0 0];
|
---|
| 770 | GeometryCalib.Tx=0;
|
---|
| 771 | GeometryCalib.Ty=0;
|
---|
| 772 | GeometryCalib.Tz=1;
|
---|
| 773 | GeometryCalib.dpx=1;
|
---|
| 774 | GeometryCalib.dpy=1;
|
---|
| 775 | GeometryCalib.sx=1;
|
---|
| 776 | GeometryCalib.Cx=0;
|
---|
| 777 | GeometryCalib.Cy=0;
|
---|
| 778 | GeometryCalib.f=1;
|
---|
| 779 | GeometryCalib.kappa1=0;
|
---|
| 780 | GeometryCalib.CoordUnit='cm';
|
---|
| 781 | XmlData.GeometryCalib=GeometryCalib;
|
---|
| 782 | if error==2, warntext=['no file ' FileBase '.civ'];
|
---|
| 783 | elseif error==1, warntext='inconsistent number of fields in the .civ file';
|
---|
| 784 | end
|
---|
| 785 | set(handles.npx,'String',num2str(npx));%fills nbre of pixels x box
|
---|
| 786 | set(handles.npy,'String',num2str(npy));%fills nbre of pixels y box
|
---|
| 787 | set(handles.pxcm,'String',num2str(pxcmx));%fills scale x (pixel/cm) box
|
---|
| 788 | set(handles.pycm,'String',num2str(pxcmy));%fills scale y (pixel/cm) box
|
---|
| 789 | set(handles.pxcm,'Visible','on');%fills scale x (pixel/cm) box
|
---|
| 790 | set(handles.pycm,'Visible','on');%fills scale y (pixel/cm) box
|
---|
| 791 | set(handles.view_xml,'Visible','on')
|
---|
| 792 | set(handles.view_xml,'String','view .civ')
|
---|
| 793 | else
|
---|
| 794 | set(handles.view_xml,'Visible','off')
|
---|
| 795 | end
|
---|
| 796 |
|
---|
| 797 | % store last index in handles.lat_i and .last_j
|
---|
| 798 | if ~isempty(XmlData.Time)
|
---|
| 799 | nbfield=size(XmlData.Time,1);
|
---|
| 800 | nburst=size(XmlData.Time,2);
|
---|
| 801 | %transform .Time to a column vector if it is a line vector the nomenclature uses a single index
|
---|
| 802 | if isequal(nbfield,1) && ~isequal(nburst,1)% .Time is a line vector
|
---|
| 803 | NomType=get(handles.FileIndex,'UserData');
|
---|
| 804 | if numel(NomType)>=2 &&(strcmp(NomType,'_i')||strcmp(NomType(1:2),'%0')||strcmp(NomType(1:2),'_%'))
|
---|
| 805 | XmlData.Time=(XmlData.Time)';
|
---|
| 806 | nbfield=nburst;
|
---|
| 807 | nburst=1;
|
---|
| 808 | end
|
---|
| 809 | end
|
---|
| 810 | end
|
---|
| 811 | last_i_cell=get(handles.last_i,'String');
|
---|
| 812 | if isempty(nbfield)
|
---|
| 813 | last_i_cell{1}='';
|
---|
| 814 | else
|
---|
| 815 | last_i_cell{1}=num2str(nbfield);
|
---|
| 816 | end
|
---|
| 817 | set(handles.last_i,'String',last_i_cell)
|
---|
| 818 | last_j_cell=get(handles.last_j,'String');
|
---|
| 819 | if isempty(nburst)
|
---|
| 820 | last_j_cell{1}='';
|
---|
| 821 | else
|
---|
| 822 | last_j_cell{1}=num2str(nburst);
|
---|
| 823 | end
|
---|
| 824 | set(handles.last_j,'String',last_j_cell);
|
---|
| 825 |
|
---|
| 826 | % store geometric calibration in UvData
|
---|
| 827 | if isfield(XmlData,'GeometryCalib')
|
---|
| 828 | GeometryCalib=XmlData.GeometryCalib;
|
---|
| 829 | if isempty(GeometryCalib)
|
---|
| 830 | set(handles.pxcm,'String','')
|
---|
| 831 | set(handles.pycm,'String','')
|
---|
| 832 | set(handles.transform_fct,'Value',1); % no transform by default
|
---|
| 833 | else
|
---|
| 834 | if (isfield(GeometryCalib,'R')&& ~isequal(GeometryCalib.R(2,1),0) && ~isequal(GeometryCalib.R(1,2),0)) ||...
|
---|
| 835 | (isfield(GeometryCalib,'kappa1')&& ~isequal(GeometryCalib.kappa1,0))
|
---|
| 836 | set(handles.pxcm,'String','var')
|
---|
| 837 | set(handles.pycm,'String','var')
|
---|
| 838 | elseif isfield(GeometryCalib,'fx_fy')
|
---|
| 839 | pixcmx=GeometryCalib.fx_fy(1);%*GeometryCalib.R(1,1)*GeometryCalib.sx/(GeometryCalib.Tz*GeometryCalib.dpx);
|
---|
| 840 | pixcmy=GeometryCalib.fx_fy(2);%*GeometryCalib.R(2,2)/(GeometryCalib.Tz*GeometryCalib.dpy);
|
---|
| 841 | set(handles.pxcm,'String',num2str(pixcmx))
|
---|
| 842 | set(handles.pycm,'String',num2str(pixcmy))
|
---|
| 843 | end
|
---|
| 844 | if ~get(handles.FixLimits,'Value')
|
---|
| 845 | set(handles.transform_fct,'Value',2); % phys transform by default if fixedLimits is off
|
---|
| 846 | end
|
---|
| 847 | if isfield(GeometryCalib,'SliceCoord')
|
---|
| 848 |
|
---|
| 849 | siz=size(GeometryCalib.SliceCoord);
|
---|
| 850 | if siz(1)>1
|
---|
| 851 | NbSlice=siz(1);
|
---|
| 852 | set(handles.slices,'Visible','on')
|
---|
| 853 | set(handles.slices,'Value',1)
|
---|
| 854 | end
|
---|
| 855 | if isfield(GeometryCalib,'VolumeScan') && isequal(GeometryCalib.VolumeScan,'y')
|
---|
| 856 | set(handles.nb_slice,'String','volume')
|
---|
| 857 | else
|
---|
| 858 | set(handles.nb_slice,'String',num2str(NbSlice))
|
---|
| 859 | end
|
---|
| 860 | slices_Callback(hObject, eventdata, handles)
|
---|
| 861 | end
|
---|
| 862 | end
|
---|
| 863 | end
|
---|
| 864 |
|
---|
| 865 | %update the data attached to the uvmat interface
|
---|
| 866 | if ~isempty(TimeUnit)
|
---|
| 867 | set(handles.time_txt,'String',['time (' TimeUnit ')'])
|
---|
| 868 | end
|
---|
| 869 | UvData.TimeUnit=TimeUnit;
|
---|
| 870 | UvData.XmlData=XmlData;
|
---|
| 871 | UvData.NewSeries=1;
|
---|
| 872 |
|
---|
[231] | 873 |
|
---|
[199] | 874 | %display warning message
|
---|
| 875 | if ~isequal(warntext,'')
|
---|
| 876 | msgbox_uvmat('WARNING',warntext);
|
---|
| 877 | end
|
---|
| 878 |
|
---|
| 879 | % set default options in menu 'Fields'
|
---|
| 880 |
|
---|
[227] | 881 | if ~testima
|
---|
| 882 | testcivx=0;
|
---|
[231] | 883 | if isfield(UvData,'FieldsString') && isequal(UvData.FieldsString,{'get_field...'})% field menu defined as input (from get_field)
|
---|
| 884 | set(handles.Fields,'Value',1)
|
---|
| 885 | set(handles.Fields,'String',{'get_field...'})
|
---|
| 886 | UvData=rmfield(UvData,'FieldsString');
|
---|
| 887 | else
|
---|
[236] | 888 | Data=nc2struct(FileName,'ListGlobalAttribute','Conventions','absolut_time_T0','civ');
|
---|
| 889 | if strcmp(Data.Conventions,'uvmat/civdata') ||( ~isempty(Data.absolut_time_T0)&& ~isequal(Data.civ,0))%if the new input is Civx
|
---|
[227] | 890 | FieldList=calc_field;
|
---|
| 891 | set(handles.Fields,'String',[{'image'};FieldList;{'get_field...'}]);%standard menu for civx data
|
---|
| 892 | set(handles.Fields,'Value',2) % set menu to 'velocity'
|
---|
| 893 | col_vec=FieldList;
|
---|
| 894 | col_vec(1)=[];%remove 'velocity' option for vector color (must be a scalar)
|
---|
| 895 | testcivx=1;
|
---|
| 896 | end
|
---|
[231] | 897 | if ~testcivx
|
---|
[227] | 898 | set(handles.Fields,'Value',1) % set menu to 'get_field...
|
---|
| 899 | set(handles.Fields,'String',{'get_field...'})
|
---|
[231] | 900 | col_vec={'get_field...'};
|
---|
| 901 | end
|
---|
| 902 | set(handles.col_vec,'String',col_vec)
|
---|
| 903 | end
|
---|
[227] | 904 | end
|
---|
[231] | 905 | set(handles.uvmat,'UserData',UvData)
|
---|
[199] | 906 |
|
---|
| 907 | %% set index navigation options and refresh plots
|
---|
| 908 | set(handles.RootPath,'BackgroundColor',[1 1 1])
|
---|
| 909 | drawnow
|
---|
| 910 | set_scan_options(hObject, eventdata, handles)
|
---|
| 911 |
|
---|
| 912 | %------------------------------------------------------------------------
|
---|
| 913 | %--- Set index navigation options for new series input and refresh plot
|
---|
| 914 | %------------------------------------------------------------------------
|
---|
| 915 | function set_scan_options(hObject, eventdata, handles)
|
---|
| 916 |
|
---|
| 917 | % set the corresponding index navigation options
|
---|
| 918 | NomType=get(handles.FileIndex,'UserData');
|
---|
| 919 | NomType_1=get(handles.FileIndex_1,'UserData');
|
---|
| 920 | last_i_str=get(handles.last_i,'String');
|
---|
| 921 | nbfield=str2num(last_i_str{1});
|
---|
| 922 | if numel(last_i_str)==2
|
---|
| 923 | nbfield=min(nbfield,str2num(last_i_str{2}));
|
---|
| 924 | end
|
---|
| 925 | state_j='off'; %default
|
---|
| 926 | scan_option='i';%default
|
---|
| 927 | NomTypeRaw=regexprep(NomType(2:end), '-', '');
|
---|
| 928 | if numel(regexp(NomTypeRaw,'\D'))>=1
|
---|
| 929 | state_j='on';
|
---|
| 930 | if isequal(nbfield,1)
|
---|
| 931 | scan_option='j'; %scan j index by default if nbfield=1
|
---|
| 932 | end
|
---|
| 933 | end
|
---|
| 934 | if ~isempty(NomType_1)
|
---|
| 935 | NomTypeRaw=regexprep(NomType_1(2:end), '-', '');
|
---|
| 936 | if numel(regexp(NomTypeRaw,'\D'))>=1
|
---|
| 937 | state_j='on';
|
---|
| 938 | if isequal(nbfield,1)
|
---|
| 939 | scan_option='j';
|
---|
| 940 | end
|
---|
| 941 | end
|
---|
| 942 | end
|
---|
| 943 | if isequal(scan_option,'i')
|
---|
| 944 | set(handles.scan_i,'Value',1)
|
---|
| 945 | scan_i_Callback(hObject, eventdata, handles);
|
---|
| 946 | else
|
---|
| 947 | set(handles.scan_j,'Value',1)
|
---|
| 948 | scan_j_Callback(hObject, eventdata, handles);
|
---|
| 949 | end
|
---|
| 950 | set(handles.scan_j,'Visible',state_j)
|
---|
| 951 | set(handles.j1,'Visible',state_j)
|
---|
| 952 | set(handles.j2,'Visible',state_j)
|
---|
| 953 | set(handles.last_j,'Visible',state_j);
|
---|
| 954 | set(handles.frame_j,'Visible',state_j);
|
---|
| 955 | set(handles.j_text,'Visible',state_j);
|
---|
[221] | 956 | if strcmp(state_j,'on')
|
---|
| 957 | set(handles.fix_pair,'Visible','on')
|
---|
| 958 | else
|
---|
| 959 | set(handles.fix_pair,'Visible','off')
|
---|
| 960 | end
|
---|
[199] | 961 |
|
---|
| 962 | %% view the field
|
---|
| 963 | run0_Callback(hObject, eventdata, handles); %view field
|
---|
| 964 | mask_test=get(handles.mask_test,'value');
|
---|
| 965 | if mask_test
|
---|
| 966 | MaskData=get(handles.mask_test,'UserData');
|
---|
| 967 | if isfield(MaskData,'maskhandle') && ishandle(MaskData.maskhandle)
|
---|
| 968 | delete(MaskData.maskhandle) %delete old mask
|
---|
| 969 | end
|
---|
| 970 | mask_test_Callback(hObject, eventdata, handles)
|
---|
| 971 | end
|
---|
| 972 |
|
---|
| 973 | %------------------------------------------------------------------------
|
---|
| 974 | % --- Executes on the menu Open/Browse_1 for the second input field,
|
---|
| 975 | % search the files, recognize their type according to their name and fill the rootfile input windows
|
---|
| 976 | function MenuBrowse_1_Callback(hObject, eventdata, handles)
|
---|
| 977 | %------------------------------------------------------------------------
|
---|
| 978 | % huvmat=get(handles.run0,'parent');
|
---|
| 979 | UvData=get(handles.uvmat,'UserData');
|
---|
| 980 |
|
---|
| 981 | RootPath=get(handles.RootPath,'String');
|
---|
| 982 | [FileName, PathName, filterindex] = uigetfile( ...
|
---|
| 983 | {'*.xml;*.xls;*.civ;*.jpg;*.png;*.avi;*.AVI;*.nc;*.cmx;*.fig;*.log;*.dat', ' (*.xml,*.xls,*.civ, *.jpg,*.png, *.avi,*.nc,*.cmx ,*.fig,*.log,*.dat)';
|
---|
| 984 | '*.xml', '.xml files '; ...
|
---|
| 985 | '*.xls', '.xls files '; ...
|
---|
| 986 | '*.civ', '.civ files '; ...
|
---|
| 987 | '*.jpg','.jpg image files'; ...
|
---|
| 988 | '*.png','.png image files'; ...
|
---|
| 989 | '*.avi;*.AVI','.avi movie files'; ...
|
---|
| 990 | '*.nc','.netcdf files'; ...
|
---|
| 991 | '*.cdf','.netcdf files'; ...
|
---|
| 992 | '*.cmx','.cmx text files';...
|
---|
| 993 | '*.cmx2','.cmx2 text files';...
|
---|
| 994 | '*.fig','.fig files (matlab fig)';...
|
---|
| 995 | '*.log','.log text files ';...
|
---|
| 996 | '*.dat','.dat text files ';...
|
---|
| 997 | '*.*', 'All Files (*.*)'}, ...
|
---|
[236] | 998 | 'Pick a second file for comparison',RootPath);
|
---|
[199] | 999 | fileinput_1=[PathName FileName];%complete file name
|
---|
| 1000 | sizf=size(fileinput_1);
|
---|
| 1001 | if (~ischar(fileinput_1)||~isequal(sizf(1),1)),return;end
|
---|
| 1002 |
|
---|
| 1003 | % refresh the current displayed field
|
---|
| 1004 | display_file_name_1(hObject,eventdata,handles,fileinput_1)
|
---|
| 1005 |
|
---|
| 1006 | %update list of recent files in the menubar
|
---|
| 1007 | MenuFile_1=fileinput_1;
|
---|
| 1008 | MenuFile_2=get(handles.MenuFile_1,'Label');
|
---|
| 1009 | MenuFile_3=get(handles.MenuFile_2,'Label');
|
---|
| 1010 | MenuFile_4=get(handles.MenuFile_3,'Label');
|
---|
| 1011 | MenuFile_5=get(handles.MenuFile_4,'Label');
|
---|
| 1012 | set(handles.MenuFile_1,'Label',MenuFile_1)
|
---|
| 1013 | set(handles.MenuFile_2,'Label',MenuFile_2)
|
---|
| 1014 | set(handles.MenuFile_3,'Label',MenuFile_3)
|
---|
| 1015 | set(handles.MenuFile_4,'Label',MenuFile_4)
|
---|
| 1016 | set(handles.MenuFile_5,'Label',MenuFile_5)
|
---|
| 1017 | set(handles.MenuFile_1_1,'Label',MenuFile_1)
|
---|
| 1018 | set(handles.MenuFile_2_1,'Label',MenuFile_2)
|
---|
| 1019 | set(handles.MenuFile_3_1,'Label',MenuFile_3)
|
---|
| 1020 | set(handles.MenuFile_4_1,'Label',MenuFile_4)
|
---|
| 1021 | set(handles.MenuFile_5_1,'Label',MenuFile_5)
|
---|
| 1022 | dir_perso=prefdir;
|
---|
| 1023 | profil_perso=fullfile(dir_perso,'uvmat_perso.mat');
|
---|
| 1024 | if exist(profil_perso,'file')
|
---|
| 1025 | save (profil_perso,'MenuFile_1','MenuFile_2','MenuFile_3','MenuFile_4', 'MenuFile_5','-append'); %store the file names for future opening of uvmat
|
---|
| 1026 | else
|
---|
| 1027 | txt=ver('MATLAB');
|
---|
| 1028 | Release=txt.Release;
|
---|
| 1029 | relnumb=str2double(Release(3:4));
|
---|
| 1030 | if relnumb >= 14
|
---|
| 1031 | save (profil_perso,'MenuFile_1','MenuFile_2','MenuFile_3','MenuFile_4', 'MenuFile_5','-V6'); %store the file names for future opening of uvmat
|
---|
| 1032 | else
|
---|
| 1033 | save (profil_perso,'MenuFile_1','MenuFile_2','MenuFile_3','MenuFile_4', 'MenuFile_5'); %store the file names for future opening of uvmat
|
---|
| 1034 | end
|
---|
| 1035 | end
|
---|
| 1036 |
|
---|
| 1037 | % -----------------------------------------------------------------------
|
---|
| 1038 | % --- Open again as second field the file whose name has been recorded in MenuFile_1
|
---|
| 1039 | function MenuFile_1_1_Callback(hObject, eventdata, handles)
|
---|
| 1040 | % -----------------------------------------------------------------------
|
---|
| 1041 | fileinput_1=get(handles.MenuFile_1_1,'Label');
|
---|
| 1042 | display_file_name_1(hObject,eventdata,handles,fileinput_1)
|
---|
| 1043 |
|
---|
| 1044 | % -----------------------------------------------------------------------
|
---|
| 1045 | % --- Open again as second field the file whose name has been recorded in MenuFile_2
|
---|
| 1046 | function MenuFile_2_1_Callback(hObject, eventdata, handles)
|
---|
| 1047 | % -----------------------------------------------------------------------
|
---|
| 1048 | fileinput_1=get(handles.MenuFile_2_1,'Label');
|
---|
| 1049 | display_file_name_1(hObject,eventdata,handles,fileinput_1)
|
---|
| 1050 |
|
---|
| 1051 | % -----------------------------------------------------------------------
|
---|
| 1052 | % --- Open again as second field the file whose name has been recorded in MenuFile_3
|
---|
| 1053 | function MenuFile_3_1_Callback(hObject, eventdata, handles)
|
---|
| 1054 | % -----------------------------------------------------------------------
|
---|
| 1055 | fileinput_1=get(handles.MenuFile_3_1,'Label');
|
---|
| 1056 | display_file_name_1(hObject,eventdata,handles,fileinput_1)
|
---|
| 1057 |
|
---|
| 1058 | % -----------------------------------------------------------------------
|
---|
| 1059 | % --- Open again as second field the file whose name has been recorded in MenuFile_4
|
---|
| 1060 | function MenuFile_4_1_Callback(hObject, eventdata, handles)
|
---|
| 1061 | % -----------------------------------------------------------------------
|
---|
| 1062 | fileinput_1=get(handles.MenuFile_4_1,'Label');
|
---|
| 1063 | display_file_name_1(hObject,eventdata,handles,fileinput_1)
|
---|
| 1064 |
|
---|
| 1065 | % -----------------------------------------------------------------------
|
---|
| 1066 | % --- Open again as second field the file whose name has been recorded in MenuFile_5
|
---|
| 1067 | function MenuFile_5_1_Callback(hObject, eventdata, handles)
|
---|
| 1068 | % -----------------------------------------------------------------------
|
---|
| 1069 | fileinput_1=get(handles.MenuFile_5_1,'Label');
|
---|
| 1070 | display_file_name_1(hObject,eventdata,handles,fileinput_1)
|
---|
| 1071 |
|
---|
| 1072 | %------------------------------------------------------------------------
|
---|
| 1073 | % fills the edit boxes RootPath_1, RootFile_1,NomType_1...from an input file name 'fileinput_1'
|
---|
| 1074 | %------------------------------------------------------------------------
|
---|
| 1075 | function display_file_name_1(hObject,eventdata,handles,fileinput_1)
|
---|
| 1076 |
|
---|
| 1077 | %[path,name,ext]=fileparts(fileinput_1);
|
---|
| 1078 | [RootPath_1,RootFile_1,field_count,str2,str_a,str_b,FileExt_1,NomType_1,SubDir_1]=name2display(fileinput_1);
|
---|
| 1079 | nbfield_1=1; %default
|
---|
| 1080 | ext_test=FileExt_1;%default
|
---|
| 1081 | form=imformats(FileExt_1(2:end));
|
---|
| 1082 | if ~isempty(form) % if the extension corresponds to an image format recognized by Matlab
|
---|
| 1083 | imainfo=imfinfo(fileinput_1);
|
---|
| 1084 | nbfield_1=length(imainfo);
|
---|
| 1085 | ext_test='.image';
|
---|
| 1086 | elseif isequal(lower(FileExt_1),'.avi')
|
---|
| 1087 | info=aviinfo(fileinput_1);
|
---|
| 1088 | nbfield_1=info.NumFrames;
|
---|
| 1089 | ext_test='.image';
|
---|
| 1090 | end
|
---|
| 1091 |
|
---|
| 1092 | %open directly fig or text files
|
---|
| 1093 | switch ext_test
|
---|
| 1094 | case {'.civ','.log','.cmx','.cmx2','.txt'} %display text file
|
---|
| 1095 | edit(fileinput)
|
---|
| 1096 | return
|
---|
| 1097 | case '.fig' %display matlab figure
|
---|
| 1098 | hfig=open(fileinput);
|
---|
| 1099 | set(hfig,'WindowButtonMotionFcn','mouse_motion')%set mouse action functio
|
---|
| 1100 | set(hfig,'WindowButtonUpFcn','mouse_up')%set mouse click action function
|
---|
| 1101 | set(hfig,'WindowButtonUpFcn','mouse_down')%set mouse click action function
|
---|
| 1102 | return
|
---|
| 1103 | case {'.xml','.xls'} % edit xml or Excel files
|
---|
| 1104 | heditxml=editxml(fileinput);
|
---|
| 1105 | return
|
---|
| 1106 | case {'.image','.nc','.cdf'}
|
---|
| 1107 | % set(handles.FileIndex,'UserData',NomType_1);
|
---|
| 1108 | otherwise
|
---|
| 1109 | msgbox_uvmat(['invalid input file extension ' FileExt_1 ' for uvmat'],'ERROR')
|
---|
| 1110 | return
|
---|
| 1111 | end
|
---|
| 1112 |
|
---|
| 1113 | % test for image series in a single file and synchronise file indices of the two series
|
---|
| 1114 | if nbfield_1 >1 %case of image with multiple frames
|
---|
| 1115 | if nbfield_1 < num_i1
|
---|
| 1116 | msgbox_uvmat('ERROR','current frame index beyond the input movie length')
|
---|
| 1117 | return
|
---|
| 1118 | else
|
---|
| 1119 | NomType_1='*'; %indicate a set of indexed frames within a single file
|
---|
| 1120 | filename_new=fileinput_1;
|
---|
| 1121 | end
|
---|
| 1122 | else % cases of data files
|
---|
| 1123 | RootPath=get(handles.RootPath,'String');
|
---|
| 1124 | RootFile=get(handles.RootFile,'String');
|
---|
| 1125 | FileBase=fullfile(RootPath,RootFile);
|
---|
| 1126 | FileBase_1=fullfile(RootPath_1,RootFile_1);
|
---|
| 1127 | if isequal(FileBase,FileBase_1)
|
---|
| 1128 | filename_new=fileinput_1;
|
---|
| 1129 | else
|
---|
| 1130 | num_i1=stra2num(get(handles.i1,'String'));%get the current file indices from counters
|
---|
| 1131 | num_j1=stra2num(get(handles.j1,'String'));
|
---|
| 1132 | num_i2=stra2num(get(handles.i2,'String'));
|
---|
| 1133 | num_j2=stra2num(get(handles.j2,'String'));
|
---|
| 1134 | [filename_new,idetect]=...
|
---|
| 1135 | 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
|
---|
| 1136 | indices=''; %default
|
---|
| 1137 | if ~idetect
|
---|
| 1138 | msgbox_uvmat('ERROR','second input file with indices corresponding to the first one does not exist')
|
---|
| 1139 | return
|
---|
| 1140 | end
|
---|
| 1141 | end
|
---|
| 1142 | end
|
---|
| 1143 | set(handles.FileIndex_1,'UserData',NomType_1);
|
---|
| 1144 |
|
---|
| 1145 | % make visible and fill the second raw of edit boxes
|
---|
| 1146 | set(handles.RootPath_1,'Visible','on')
|
---|
| 1147 | set(handles.RootFile_1,'Visible','on')
|
---|
| 1148 | set(handles.SubDir_1,'Visible','on');
|
---|
| 1149 | set(handles.FileIndex_1,'Visible','on');
|
---|
| 1150 | set(handles.FileExt_1,'Visible','on');
|
---|
| 1151 | [FileName,RootPath,FileBase,FileIndices,FileExt,SubDir]=read_file_boxes(handles);
|
---|
| 1152 | if isequal(FileBase,FileBase_1)
|
---|
| 1153 | set(handles.RootPath_1,'String','"')
|
---|
| 1154 | set(handles.RootFile_1,'String','"');
|
---|
| 1155 | else
|
---|
| 1156 | set(handles.RootPath_1,'String',RootPath_1)
|
---|
| 1157 | set(handles.RootFile_1,'String',['/' RootFile_1]);
|
---|
| 1158 | end
|
---|
| 1159 | if isequal(SubDir_1,'')
|
---|
| 1160 | set(handles.SubDir_1,'String','');
|
---|
| 1161 | FileBaseSub_1=FileBase_1;
|
---|
| 1162 | else
|
---|
| 1163 | set(handles.SubDir_1,'String',['/' SubDir_1]);
|
---|
| 1164 | FileBaseSub_1=fullfile(FileBase_1,SubDir_1);
|
---|
| 1165 | end
|
---|
| 1166 | indices=filename_new(length(FileBaseSub_1)+1:end);
|
---|
| 1167 | indices(end-length(FileExt_1)+1:end)=[]; %remove extension
|
---|
| 1168 | set(handles.FileIndex_1,'String',indices)
|
---|
| 1169 | set(handles.FileIndex_1,'UserData',NomType_1)
|
---|
| 1170 | set(handles.FileExt_1,'String',FileExt_1);
|
---|
| 1171 |
|
---|
| 1172 | % % default choice of fields
|
---|
[236] | 1173 | %set(handles.SubField,'Visible','on')
|
---|
[199] | 1174 | set(handles.SubField,'Value',1)
|
---|
| 1175 | RootPath_1_Callback(hObject,eventdata,handles);
|
---|
| 1176 |
|
---|
| 1177 | %-----------------------------------------------------------------------
|
---|
| 1178 | % --- Called by action in RootPath_1 edit box
|
---|
| 1179 | function RootPath_1_Callback(hObject,eventdata,handles)
|
---|
| 1180 | % -----------------------------------------------------------------------
|
---|
| 1181 | update_rootinfo_1(hObject,eventdata,handles)
|
---|
| 1182 |
|
---|
| 1183 | %-----------------------------------------------------------------------
|
---|
| 1184 | % --- Called by action in RootFile_1 edit box
|
---|
| 1185 | function RootFile_1_Callback(hObject, eventdata, handles)
|
---|
| 1186 | % -----------------------------------------------------------------------
|
---|
| 1187 | update_rootinfo_1(hObject,eventdata,handles)
|
---|
| 1188 |
|
---|
| 1189 | %------------------------------------------------------------------------
|
---|
| 1190 | % --- Called by action in FileIndex_1 edit box
|
---|
| 1191 | function FileIndex_1_Callback(hObject, eventdata, handles)
|
---|
| 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
|
---|
| 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
|
---|
| 1202 | UvData=get(handles.uvmat,'UserData');%huvmat=handles of the uvmat interface
|
---|
| 1203 | UvData.NewSeries=1; %flag for run0: begin a new series
|
---|
| 1204 |
|
---|
| 1205 | [FileName,RootPath,FileBase,FileIndices,FileExt,SubDir]=read_file_boxes_1(handles);
|
---|
| 1206 | if ~exist(FileName,'file')
|
---|
| 1207 | msgbox_uvmat('ERROR',['input file ' FileName ' not found']);
|
---|
| 1208 | end
|
---|
[236] | 1209 | set(handles.FixVelType,'Value',0); %desactivate fixed veltype
|
---|
[199] | 1210 | nbfield_1=[];%default
|
---|
| 1211 | nburst_1=[];%default
|
---|
| 1212 | XmlData.Time=[];
|
---|
| 1213 | XmlData.GeometryCalib=[];%default
|
---|
| 1214 | TimeUnit=[];
|
---|
| 1215 | if isfield(UvData,'TimeUnit')
|
---|
| 1216 | TimeUnit=UvData.TimeUnit;
|
---|
| 1217 | end
|
---|
| 1218 | TimeUnit_1=[];
|
---|
| 1219 | hhh='';%default, test for movie reading with mmreader
|
---|
| 1220 | imainfo=[];
|
---|
| 1221 | if isequal(lower(FileExt),'.avi') %.avi file
|
---|
| 1222 | imainfo=aviinfo([FileBase FileIndices FileExt]);
|
---|
| 1223 | nbfield_1=imainfo.NumFrames;
|
---|
| 1224 | nburst_1=1;
|
---|
| 1225 | set(handles.Dt_txt,'String',['Dt=' num2str(1000/info.FramesPerSecond) 'ms']);%display the elementary time interval in millisec
|
---|
| 1226 | time=(0:1/imainfo.FramesPerSecond:(imainfo.NumFrames-1)/imainfo.FramesPerSecond)';
|
---|
| 1227 | ColorType=imainfo.ImageType;%='truecolor' for color images
|
---|
| 1228 | hhh=which('mmreader');
|
---|
| 1229 | elseif ~isempty(imformats(FileExt(2:end)))|| isequal(FileExt,'.vol')
|
---|
| 1230 | if ~isequal(SubDir,'')
|
---|
| 1231 | RootFile=get(handles.RootFile,'String');
|
---|
| 1232 | imainfo=imfinfo([fullfile(RootPath,SubDir,RootFile) FileIndices FileExt]);
|
---|
| 1233 | else
|
---|
| 1234 | imainfo=imfinfo([FileBase FileIndices FileExt]);
|
---|
| 1235 | end
|
---|
| 1236 | ColorType=imainfo.ColorType;%='truecolor' for color images
|
---|
| 1237 | if length(imainfo) >1 %case of image with multiple frames
|
---|
| 1238 | nbfield_1=length(imainfo);
|
---|
| 1239 | nburst_1=1;
|
---|
| 1240 | end
|
---|
| 1241 | end
|
---|
| 1242 | if ~strcmp(hhh,'')&& mmreader.isPlatformSupported()% if the function is found (recent version of matlab)
|
---|
| 1243 | UvData.MovieObject_1=mmreader([FileBase FileIndices FileExt]);
|
---|
| 1244 | elseif isfield(UvData,'MovieObject_1')
|
---|
| 1245 | UvData=rmfield(UvData,'MovieObject_1');
|
---|
| 1246 | end
|
---|
| 1247 | if ~isempty(imainfo)% (an image has been introduced as second fierld input)
|
---|
| 1248 | 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
|
---|
| 1249 | if isfield(imainfo,'Width') && isfield(imainfo,'Height')
|
---|
| 1250 | set(handles.npx,'String',num2str(imainfo.Width));%fills nbre of pixels x box
|
---|
| 1251 | set(handles.npy,'String',num2str(imainfo.Height));%fills nbre of pixels x box
|
---|
| 1252 | else
|
---|
| 1253 | set(handles.npx,'String','');%fills nbre of pixels x box
|
---|
| 1254 | set(handles.npy,'String','');%fills nbre of pixels x box
|
---|
| 1255 | end
|
---|
| 1256 | set(handles.BW,'Value',strcmp(ColorType,'grayscale'))% select handles.BW if grayscale image
|
---|
| 1257 | end
|
---|
| 1258 | end
|
---|
| 1259 | % find scaling parameters
|
---|
| 1260 | filexml=[FileBase '.xml'];
|
---|
| 1261 | fileciv=[FileBase '.civ'];
|
---|
| 1262 | warntext='';%default warning text
|
---|
| 1263 | if exist(filexml,'file')
|
---|
| 1264 | [XmlData,warntext]=imadoc2struct(filexml);
|
---|
| 1265 | if ~isempty(warntext)
|
---|
| 1266 | msgbox_uvmat('WARNING',warntext)
|
---|
| 1267 | end
|
---|
| 1268 | if isfield(XmlData,'Camera')
|
---|
| 1269 | if isfield(XmlData.Camera,'TimeUnit')&& ~isempty(XmlData.Camera.TimeUnit)
|
---|
| 1270 | TimeUnit=XmlData.Camera.TimeUnit;
|
---|
| 1271 | end
|
---|
| 1272 | end
|
---|
| 1273 | elseif exist(fileciv,'file')% if .civ file found
|
---|
| 1274 | [error,XmlData.Time,TimeUnit,mode,npx,npy,pxcmx,pxcmy]=read_imatext([FileBase '.civ']);
|
---|
| 1275 | GeometryCalib.R=[pxcmx 0 0; 0 pxcmy 0;0 0 0];
|
---|
| 1276 | GeometryCalib.Tx=0;
|
---|
| 1277 | GeometryCalib.Ty=0;
|
---|
| 1278 | GeometryCalib.Tz=1;
|
---|
| 1279 | GeometryCalib.dpx=1;
|
---|
| 1280 | GeometryCalib.dpy=1;
|
---|
| 1281 | GeometryCalib.sx=1;
|
---|
| 1282 | GeometryCalib.Cx=0;
|
---|
| 1283 | GeometryCalib.Cy=0;
|
---|
| 1284 | GeometryCalib.f=1;
|
---|
| 1285 | GeometryCalib.kappa1=0;
|
---|
| 1286 | GeometryCalib.CoordUnit='cm';
|
---|
| 1287 | XmlData.GeometryCalib=GeometryCalib;
|
---|
| 1288 | if error==2, warntext=['no file ' FileBase '.civ'];
|
---|
| 1289 | elseif error==1, warntext='inconsistent number of fields in the .civ file';
|
---|
| 1290 | end
|
---|
| 1291 |
|
---|
| 1292 | set(handles.npx,'String',num2str(npx));%fills nbre of pixels x box
|
---|
| 1293 | set(handles.npy,'String',num2str(npy));%fills nbre of pixels y box
|
---|
| 1294 | set(handles.pxcm,'String',num2str(pxcmx));%fills scale x (pixel/cm) box
|
---|
| 1295 | set(handles.pycm,'String',num2str(pxcmy));%fills scale y (pixel/cm) box
|
---|
| 1296 | set(handles.pxcm,'Visible','on');%fills scale x (pixel/cm) box
|
---|
| 1297 | set(handles.pycm,'Visible','on');%fills scale y (pixel/cm) box
|
---|
| 1298 | end
|
---|
| 1299 | if ~isempty(TimeUnit_1) && ~isequal(TimeUnit_1,TimeUnit)
|
---|
| 1300 | msgbox_uvmat('WARNING','the time units for the second series differs from the first one')
|
---|
| 1301 | end
|
---|
| 1302 |
|
---|
| 1303 | % store last index in handles.lat_i and .last_j
|
---|
| 1304 | if ~isempty(XmlData.Time)
|
---|
| 1305 | nbfield_1=size(XmlData.Time,1);
|
---|
| 1306 | nburst_1=size(XmlData.Time,2);
|
---|
| 1307 | end
|
---|
| 1308 | last_i_cell=get(handles.last_i,'String');
|
---|
| 1309 | if isempty(nbfield_1)
|
---|
| 1310 | last_i_cell{2}='';
|
---|
| 1311 | else
|
---|
| 1312 | last_i_cell{2}=num2str(nbfield_1);
|
---|
| 1313 | end
|
---|
| 1314 | set(handles.last_i,'String',last_i_cell)
|
---|
| 1315 | last_j_cell=get(handles.last_j,'String');
|
---|
| 1316 | if isempty(nburst_1)
|
---|
| 1317 | last_j_cell{2}='';
|
---|
| 1318 | else
|
---|
| 1319 | last_j_cell{2}=num2str(nburst_1);
|
---|
| 1320 | end
|
---|
| 1321 | set(handles.last_j,'String',last_j_cell);
|
---|
| 1322 | if ~isequal(last_i_cell{1},last_i_cell{2}) || ~isequal(last_j_cell{1},last_j_cell{2})
|
---|
| 1323 | msgbox_uvmat('WARNING','the numbers of input file of the second series differs from the first one')
|
---|
| 1324 | end
|
---|
| 1325 |
|
---|
| 1326 | % store calibration data
|
---|
| 1327 | GeometryCalib=XmlData.GeometryCalib;
|
---|
| 1328 | if isempty(GeometryCalib)
|
---|
| 1329 | if isfield(UvData, 'GeometryCalib_1')
|
---|
| 1330 | UvData=rmfield(UvData,'GeometryCalib_1');
|
---|
| 1331 | end
|
---|
| 1332 | else
|
---|
| 1333 | UvData.GeometryCalib_1=GeometryCalib;
|
---|
| 1334 | if (isfield(GeometryCalib,'R')&& ~isequal(GeometryCalib.R(2,1),0) && ~isequal(GeometryCalib.R(1,2),0)) ||...
|
---|
| 1335 | (isfield(GeometryCalib,'kappa1')&& ~isequal(GeometryCalib.kappa1,0))
|
---|
| 1336 | set(handles.pxcm,'String','var')
|
---|
| 1337 | set(handles.pycm,'String','var')
|
---|
| 1338 | else
|
---|
| 1339 | if isfield(GeometryCalib,'fx_fy')
|
---|
| 1340 | pixcmx=GeometryCalib.fx_fy(1);
|
---|
| 1341 | pixcmy=GeometryCalib.fx_fy(2);
|
---|
| 1342 | set(handles.pxcm,'String',num2str(pixcmx))
|
---|
| 1343 | set(handles.pycm,'String',num2str(pixcmy))
|
---|
| 1344 | end
|
---|
| 1345 | end
|
---|
| 1346 | end
|
---|
| 1347 | UvData.XmlData_1=XmlData;
|
---|
| 1348 | set(handles.uvmat,'UserData',UvData)%update the data attached to the uvmat interface
|
---|
| 1349 |
|
---|
| 1350 | if ~isequal(warntext,'')
|
---|
| 1351 | msgbox_uvmat('WARNING',warntext)
|
---|
| 1352 | end
|
---|
| 1353 |
|
---|
| 1354 | set(handles.RootPath_1,'BackgroundColor',[1 1 1])% signa the end the input operation
|
---|
| 1355 | drawnow
|
---|
| 1356 |
|
---|
| 1357 | set_scan_options(hObject, eventdata, handles)
|
---|
| 1358 |
|
---|
| 1359 | %---------------------------------------------------
|
---|
| 1360 | % switch file index scanning options scan_i and scan_j in an exclusive way
|
---|
| 1361 | function scan_i_Callback(hObject, eventdata, handles)
|
---|
| 1362 | %---------------------------------------------------
|
---|
| 1363 | if get(handles.scan_i,'Value')==1
|
---|
| 1364 | set(handles.scan_i,'BackgroundColor',[1 1 0])
|
---|
| 1365 | set(handles.scan_j,'Value',0)
|
---|
| 1366 | % set(handles.scan_j,'BackgroundColor',[0.831 0.816 0.784])
|
---|
| 1367 | else
|
---|
| 1368 | set(handles.scan_i,'BackgroundColor',[0.831 0.816 0.784])
|
---|
| 1369 | set(handles.scan_j,'Value',1)
|
---|
| 1370 | % set(handles.scan_j,'BackgroundColor',[1 1 0])
|
---|
| 1371 | end
|
---|
| 1372 | scan_j_Callback(hObject, eventdata, handles)
|
---|
| 1373 |
|
---|
| 1374 | %-------------------------------------------------------------------
|
---|
| 1375 | % switch file index scanning options scan_i and scan_j in an exclusive way
|
---|
| 1376 | function scan_j_Callback(hObject, eventdata, handles)
|
---|
| 1377 | %-------------------------------------------------------------------
|
---|
| 1378 | if get(handles.scan_j,'Value')==1
|
---|
| 1379 | set(handles.scan_j,'BackgroundColor',[1 1 0])
|
---|
| 1380 | set(handles.scan_i,'Value',0)
|
---|
| 1381 | set(handles.scan_i,'BackgroundColor',[0.831 0.816 0.784])
|
---|
[227] | 1382 | NomType=get(handles.FileIndex,'UserData');
|
---|
[199] | 1383 | switch NomType
|
---|
| 1384 | case {'_i_j1-j2','#_ab','%3dab'},% pair with j index
|
---|
| 1385 | set(handles.fix_pair,'Visible','on')% option fixed pair on/off made visible (choice of avaible pair with buttons + and - if ='off')
|
---|
| 1386 | otherwise
|
---|
| 1387 | set(handles.fix_pair,'Visible','off')
|
---|
| 1388 | end
|
---|
| 1389 | else
|
---|
| 1390 | set(handles.scan_j,'BackgroundColor',[0.831 0.816 0.784])
|
---|
| 1391 | set(handles.scan_i,'Value',1)
|
---|
| 1392 | set(handles.scan_i,'BackgroundColor',[1 1 0])
|
---|
| 1393 | set(handles.fix_pair,'Visible','off')
|
---|
| 1394 | end
|
---|
| 1395 |
|
---|
| 1396 | %-------------------------------------------------------------------
|
---|
| 1397 | function i1_Callback(hObject, eventdata, handles)
|
---|
| 1398 | %-------------------------------------------------------------------
|
---|
| 1399 | set(handles.i1,'BackgroundColor',[0.7 0.7 0.7])
|
---|
| 1400 | NomType=get(handles.FileIndex,'UserData');
|
---|
| 1401 | num1=stra2num(get(handles.i1,'String'));
|
---|
| 1402 | num2=stra2num(get(handles.i2,'String'));
|
---|
| 1403 | num_a=stra2num(get(handles.j1,'String'));
|
---|
| 1404 | num_b=stra2num(get(handles.j2,'String'));
|
---|
| 1405 | indices=name_generator('',num1,num_a,'',NomType,1,num2,num_b,'');
|
---|
| 1406 | set(handles.FileIndex,'String',indices)
|
---|
| 1407 | set(handles.FileIndex,'BackgroundColor',[0.7 0.7 0.7])
|
---|
| 1408 | if get(handles.SubField,'Value')==1
|
---|
| 1409 | NomType_1=get(handles.FileIndex_1,'String');
|
---|
| 1410 | FileExt_1=get(handles.FileExt_1,'String');
|
---|
| 1411 | [P,F,str1,str2,str_a,str_b,Ext,NomType_1]=name2display(['xx' NomType_1 FileExt_1]);
|
---|
| 1412 | indices=name_generator('',num1,num_a,'',NomType_1,1,num2,num_b,'');
|
---|
| 1413 | set(handles.FileIndex_1,'String',indices)
|
---|
| 1414 | set(handles.FileIndex_1,'BackgroundColor',[0.7 0.7 0.7])
|
---|
| 1415 | end
|
---|
| 1416 | %Run0_Callback(hObject, eventdata, handles)
|
---|
| 1417 |
|
---|
| 1418 | %-------------------------------------------------------------------
|
---|
| 1419 | function i2_Callback(hObject, eventdata, handles)
|
---|
| 1420 | set(handles.i2,'BackgroundColor',[0.7 0.7 0.7])
|
---|
| 1421 | i1_Callback(hObject, eventdata, handles)
|
---|
| 1422 | %-------------------------------------------------------------------
|
---|
| 1423 |
|
---|
| 1424 | %-------------------------------------------------------------------
|
---|
| 1425 | function j1_Callback(hObject, eventdata, handles)
|
---|
| 1426 | set(handles.j1,'BackgroundColor',[0.7 0.7 0.7])
|
---|
| 1427 | i1_Callback(hObject, eventdata, handles)
|
---|
| 1428 | %-------------------------------------------------------------------
|
---|
| 1429 |
|
---|
| 1430 | %-------------------------------------------------------------------
|
---|
| 1431 | function j2_Callback(hObject, eventdata, handles)
|
---|
| 1432 | set(handles.j2,'BackgroundColor',[0.7 0.7 0.7])
|
---|
| 1433 | i1_Callback(hObject, eventdata, handles)
|
---|
| 1434 | %-------------------------------------------------------------------
|
---|
| 1435 |
|
---|
| 1436 | %-------------------------------------------------------------------
|
---|
| 1437 | function slices_Callback(hObject, eventdata, handles)
|
---|
| 1438 | %-------------------------------------------------------------------
|
---|
| 1439 | if get(handles.slices,'Value')==1
|
---|
| 1440 | set(handles.slices,'BackgroundColor',[1 1 0])
|
---|
| 1441 | set(handles.nb_slice,'Visible','on')
|
---|
| 1442 | set(handles.z_text,'Visible','on')
|
---|
| 1443 | set(handles.z_index,'Visible','on')
|
---|
| 1444 | nb_slice_Callback(hObject, eventdata, handles)
|
---|
| 1445 | else
|
---|
| 1446 | set(handles.nb_slice,'Visible','off')
|
---|
| 1447 | set(handles.slices,'BackgroundColor',[0.7 0.7 0.7])
|
---|
| 1448 | set(handles.z_text,'Visible','off')
|
---|
| 1449 | set(handles.z_index,'Visible','off')
|
---|
| 1450 | set(handles.masklevel,'Value',1)
|
---|
| 1451 | set(handles.masklevel,'String',{'1'})
|
---|
| 1452 | end
|
---|
| 1453 |
|
---|
| 1454 | %-------------------------------------------------------------------
|
---|
| 1455 | function nb_slice_Callback(hObject, eventdata, handles)
|
---|
| 1456 | %-------------------------------------------------------------------
|
---|
| 1457 | nb_slice_str=get(handles.nb_slice,'String');
|
---|
| 1458 | if isequal(nb_slice_str,'volume')
|
---|
| 1459 | num=stra2num(get(handles.j1,'String'));
|
---|
| 1460 | last_j=get(handles.last_j,'String');
|
---|
| 1461 | nbslice=str2double(last_j{1});
|
---|
| 1462 | else
|
---|
| 1463 | num=str2double(get(handles.i1,'String'));
|
---|
| 1464 | nbslice=str2double(get(handles.nb_slice,'String'));
|
---|
| 1465 | end
|
---|
| 1466 | z=mod(num-1,nbslice)+1;
|
---|
| 1467 | set(handles.z_index,'String',num2str(z))
|
---|
| 1468 | for ilist=1:nbslice
|
---|
| 1469 | list_index{ilist,1}=num2str(ilist);
|
---|
| 1470 | end
|
---|
| 1471 | set(handles.masklevel,'String',list_index)
|
---|
| 1472 | set(handles.masklevel,'Value',z)
|
---|
| 1473 |
|
---|
| 1474 | %------------------------------------------------------------------------
|
---|
| 1475 | % --- Executes on button press in view_xml.
|
---|
| 1476 | function view_xml_Callback(hObject, eventdata, handles)
|
---|
| 1477 | %------------------------------------------------------------------------
|
---|
| 1478 | [FileName,RootPath,FileBase,FileIndices,FileExt]=read_file_boxes(handles);
|
---|
| 1479 | option=get(handles.view_xml,'String');
|
---|
| 1480 | if isequal(option,'view .xml')
|
---|
| 1481 | FileXml=[FileBase '.xml'];
|
---|
| 1482 | heditxml=editxml(FileXml);
|
---|
| 1483 | end
|
---|
| 1484 |
|
---|
| 1485 | %------------------------------------------------------------------------
|
---|
| 1486 | % --- Executes on button press in mask_test.
|
---|
| 1487 | function mask_test_Callback(hObject, eventdata, handles)
|
---|
| 1488 | %------------------------------------------------------------------------
|
---|
| 1489 | %case of view mask selection
|
---|
| 1490 | if isequal(get(handles.mask_test,'Value'),1)
|
---|
| 1491 | [FF,RootPath,FileBase]=read_file_boxes(handles);
|
---|
| 1492 | num_i1=stra2num(get(handles.i1,'String'));
|
---|
| 1493 | num_j1=stra2num(get(handles.j1,'String'));
|
---|
| 1494 | currentdir=pwd;
|
---|
| 1495 | cd(RootPath);
|
---|
| 1496 | maskfiles=dir('*_*mask_*.png');%look for a mask file
|
---|
| 1497 | cd(currentdir);%come back to the working directory
|
---|
| 1498 | mdetect=0;
|
---|
| 1499 | if ~isempty(maskfiles)
|
---|
| 1500 | for ilist=1:length(maskfiles)
|
---|
| 1501 | maskname=maskfiles(ilist).name;% take the first mask file in the list
|
---|
| 1502 | [rr,ff,x1,x2,xa,xb,xext,Mask_NomType{ilist}]=name2display(maskname);
|
---|
| 1503 | [Path2,Name,ext]=fileparts(maskname);
|
---|
| 1504 | Namedouble=double(Name);
|
---|
| 1505 | val=(48>Namedouble)|(Namedouble>57);% select the non-numerical characters
|
---|
| 1506 | ind_mask=findstr('mask',Name);
|
---|
| 1507 | i=ind_mask-1;
|
---|
| 1508 | while val(i)==0 && i>0
|
---|
| 1509 | i=i-1;
|
---|
| 1510 | end
|
---|
| 1511 | nbmask_str=str2num(Name(i+1:ind_mask-1));
|
---|
| 1512 | if ~isempty(nbmask_str)
|
---|
| 1513 | nbslice(ilist)=nbmask_str; % number of different masks (slices)
|
---|
| 1514 | end
|
---|
| 1515 | end
|
---|
| 1516 | if isequal(min(nbslice),max(nbslice))
|
---|
| 1517 | nbslice=nbslice(1);
|
---|
| 1518 | else
|
---|
| 1519 | msgbox_uvmat('ERROR','several inconsistent mask sets coexist in the current image directory')
|
---|
| 1520 | return
|
---|
| 1521 | end
|
---|
| 1522 | if ~isempty(nbslice) && Name(i)=='_'
|
---|
| 1523 | Mask.Base=[FileBase Name(i:ind_mask+3)];
|
---|
| 1524 | Mask.NbSlice=nbslice;
|
---|
| 1525 | num_i1=mod(num_i1-1,nbslice)+1;
|
---|
[248] | 1526 | Mask.NomType=regexprep(Mask_NomType{1},'0','');%remove '0' in nom type for masks
|
---|
[251] | 1527 | maskname=name_generator(Mask.Base,num_i1,num_j1,'.png',Mask.NomType);%
|
---|
[199] | 1528 | mdetect=exist(maskname,'file');
|
---|
| 1529 | if mdetect
|
---|
| 1530 | set(handles.nb_slice,'String',Name(i+1:ind_mask-1));
|
---|
| 1531 | set(handles.nb_slice,'BackgroundColor',[1 1 0])
|
---|
| 1532 | set(handles.mask_test,'UserData',Mask);
|
---|
| 1533 | set(handles.mask_test,'BackgroundColor',[1 1 0])
|
---|
| 1534 | if nbslice > 1
|
---|
| 1535 | set(handles.slices,'value',1)
|
---|
| 1536 | slices_Callback(hObject, eventdata, handles)
|
---|
| 1537 | end
|
---|
| 1538 | end
|
---|
| 1539 | end
|
---|
| 1540 | end
|
---|
| 1541 | errormsg=[];%default
|
---|
| 1542 | if mdetect==0
|
---|
| 1543 | [FileName, PathName, filterindex] = uigetfile( ...
|
---|
| 1544 | {'*.png', ' (*.png)';
|
---|
| 1545 | '*.png', '.png files '; ...
|
---|
| 1546 | '*.*', 'All Files (*.*)'}, ...
|
---|
| 1547 | 'Pick a mask file *.png',FileBase);
|
---|
| 1548 | maskname=fullfile(PathName,FileName);
|
---|
| 1549 | if ~exist(maskname,'file')
|
---|
| 1550 | errormsg='no file browsed';
|
---|
| 1551 | end
|
---|
| 1552 | [RootDir,RootFile,x1,x2,xa,xb,xext,Mask.NomType]=name2display(maskname);
|
---|
| 1553 | Mask.Base=fullfile(RootDir,RootFile);
|
---|
| 1554 | Mask.NbSlice=1;
|
---|
| 1555 | set(handles.mask_test,'UserData',Mask);
|
---|
| 1556 | set(handles.mask_test,'BackgroundColor',[1 1 0])
|
---|
| 1557 | end
|
---|
| 1558 | if isempty(errormsg)
|
---|
| 1559 | errormsg=update_mask(handles,num_i1,num_j1);
|
---|
| 1560 | end
|
---|
| 1561 | if ~isempty(errormsg)
|
---|
| 1562 | set(handles.mask_test,'Value',0)
|
---|
| 1563 | set(handles.mask_test,'BackgroundColor',[0.7 0.7 0.7])
|
---|
| 1564 | end
|
---|
| 1565 | else
|
---|
| 1566 | MaskData=get(handles.mask_test,'UserData');
|
---|
| 1567 | if isfield(MaskData,'maskhandle') && ishandle(MaskData.maskhandle)
|
---|
| 1568 | delete(MaskData.maskhandle)
|
---|
| 1569 | end
|
---|
| 1570 | set(handles.mask_test,'UserData',[])
|
---|
| 1571 | %huvmat=get(handles.mask_test,'parent');
|
---|
| 1572 | UvData=get(handles.uvmat,'UserData');
|
---|
| 1573 | if isfield(UvData,'MaskName')
|
---|
| 1574 | UvData=rmfield(UvData,'MaskName');
|
---|
| 1575 | set(handles.uvmat,'UserData',UvData)
|
---|
| 1576 | end
|
---|
| 1577 | set(handles.mask_test,'BackgroundColor',[0.7 0.7 0.7])
|
---|
| 1578 | end
|
---|
| 1579 |
|
---|
| 1580 | %-------------------------------------------------------------------
|
---|
| 1581 | function errormsg=update_mask(handles,num_i1,num_j1)
|
---|
| 1582 | %-------------------------------------------------------------------
|
---|
| 1583 | errormsg=[];%default
|
---|
| 1584 | MaskData=get(handles.mask_test,'UserData');
|
---|
| 1585 | if isfield(MaskData,'maskhandle')&& ishandle(MaskData.maskhandle)
|
---|
| 1586 | uistack(MaskData.maskhandle,'top');
|
---|
| 1587 | end
|
---|
| 1588 | num_i1_mask=mod(num_i1-1,MaskData.NbSlice)+1;
|
---|
| 1589 | MaskName=name_generator(MaskData.Base,num_i1_mask,num_j1,'.png',MaskData.NomType);
|
---|
| 1590 | huvmat=get(handles.mask_test,'parent');
|
---|
| 1591 | UvData=get(huvmat,'UserData');
|
---|
| 1592 |
|
---|
| 1593 | %update mask image if the mask is new
|
---|
| 1594 | if ~ (isfield(UvData,'MaskName') && isequal(UvData.MaskName,MaskName))
|
---|
| 1595 | UvData.MaskName=MaskName; %update the recorded name on UvData
|
---|
| 1596 | set(huvmat,'UserData',UvData);
|
---|
| 1597 | if ~exist(MaskName,'file')
|
---|
| 1598 | if isfield(MaskData,'maskhandle')&& ishandle(MaskData.maskhandle)
|
---|
| 1599 | delete(MaskData.maskhandle)
|
---|
| 1600 | end
|
---|
| 1601 | else
|
---|
| 1602 | %read mask image
|
---|
| 1603 | Mask.AName='image';
|
---|
| 1604 | Mask.A=imread(MaskName);
|
---|
| 1605 | npxy=size(Mask.A);
|
---|
| 1606 | test_error=0;
|
---|
| 1607 | if length(npxy)>2
|
---|
| 1608 | errormsg=[MaskName ' is not a grey scale image'];
|
---|
| 1609 | return
|
---|
| 1610 | elseif ~isa(Mask.A,'uint8')
|
---|
| 1611 | errormsg=[MaskName ' is not a 8 bit grey level image'];
|
---|
| 1612 | return
|
---|
| 1613 | end
|
---|
| 1614 | Mask.AX=[0.5 npxy(2)-0.5];
|
---|
| 1615 | Mask.AY=[npxy(1)-0.5 0.5 ];
|
---|
| 1616 | Mask.CoordUnit='pixel';
|
---|
| 1617 | if isequal(get(handles.slices,'Value'),1)
|
---|
| 1618 | NbSlice=str2num(get(handles.nb_slice,'String'));
|
---|
| 1619 | num_i1=str2num(get(handles.i1,'String'));
|
---|
| 1620 | Mask.ZIndex=mod(num_i1-1,NbSlice)+1;
|
---|
| 1621 | end
|
---|
| 1622 | %px to phys or other transform on field
|
---|
| 1623 | menu_transform=get(handles.transform_fct,'String');
|
---|
| 1624 | choice_value=get(handles.transform_fct,'Value');
|
---|
| 1625 | transform_name=menu_transform{choice_value};%name of the transform fct given by the menu 'transform_fct'
|
---|
| 1626 | transform_list=get(handles.transform_fct,'UserData');
|
---|
| 1627 | transform=transform_list{choice_value};
|
---|
| 1628 | if ~isequal(transform_name,'') && ~isequal(transform_name,'px')
|
---|
| 1629 | if isfield(UvData,'XmlData') && isfield(UvData.XmlData,'GeometryCalib')%use geometry calib recorded from the ImaDoc xml file as first priority
|
---|
| 1630 | Calib=UvData.XmlData.GeometryCalib;
|
---|
| 1631 | Mask=transform(Mask,UvData.XmlData);
|
---|
| 1632 | end
|
---|
| 1633 | end
|
---|
| 1634 | flagmask=Mask.A < 200;
|
---|
| 1635 |
|
---|
| 1636 | %make brown color image
|
---|
| 1637 | imflag(:,:,1)=0.9*flagmask;
|
---|
| 1638 | imflag(:,:,2)=0.7*flagmask;
|
---|
| 1639 | imflag(:,:,3)=zeros(size(flagmask));
|
---|
| 1640 |
|
---|
| 1641 | %update mask image
|
---|
| 1642 | hmask=[]; %default
|
---|
| 1643 | if isfield(MaskData,'maskhandle')&& ishandle(MaskData.maskhandle)
|
---|
| 1644 | hmask=MaskData.maskhandle;
|
---|
| 1645 | end
|
---|
| 1646 | if ~isempty(hmask)
|
---|
| 1647 | set(hmask,'CData',imflag)
|
---|
| 1648 | set(hmask,'AlphaData',flagmask*0.6)
|
---|
| 1649 | set(hmask,'XData',Mask.AX);
|
---|
| 1650 | set(hmask,'YData',Mask.AY);
|
---|
| 1651 | % uistack(hmask,'top')
|
---|
| 1652 | else
|
---|
| 1653 | axes(handles.axes3)
|
---|
| 1654 | hold on
|
---|
| 1655 | MaskData.maskhandle=image(Mask.AX,Mask.AY,imflag,'Tag','mask','HitTest','off','AlphaData',0.6*flagmask);
|
---|
| 1656 | % set(MaskData.maskhandle,'AlphaData',0.6*flagmask)
|
---|
| 1657 | set(handles.mask_test,'UserData',MaskData)
|
---|
| 1658 | end
|
---|
| 1659 | end
|
---|
| 1660 | end
|
---|
| 1661 |
|
---|
| 1662 |
|
---|
| 1663 | %-------------------------------------------------------------------
|
---|
| 1664 | function MenuExportFigure_Callback(hObject, eventdata, handles)
|
---|
| 1665 | %-------------------------------------------------------------------
|
---|
| 1666 | huvmat=get(handles.MenuExport,'parent');
|
---|
| 1667 | %UvData=get(huvmat,'UserData');
|
---|
| 1668 | hfig=figure;
|
---|
| 1669 | copyobj(handles.axes3,hfig);
|
---|
| 1670 | map=colormap(handles.axes3);
|
---|
| 1671 | colormap(map);%transmit the current colormap to the zoom fig
|
---|
| 1672 | colorbar
|
---|
| 1673 |
|
---|
| 1674 | %-------------------------------------------------------------------
|
---|
| 1675 | %-------------------------------------------------------------------
|
---|
| 1676 | % III - MAIN REFRESH FUNCTIONS : 'FRAME PLOT'
|
---|
| 1677 | %-------------------------------------------------------------------
|
---|
| 1678 |
|
---|
| 1679 | %-------------------------------------------------------------------
|
---|
| 1680 | % --- Executes on button press in runplus: make one step forward and call
|
---|
| 1681 | % --- run0. The step forward is along the fields series 1 or 2 depending on
|
---|
| 1682 | % --- the scan_i and scan_j check box (exclusive each other)
|
---|
| 1683 | function runplus_Callback(hObject, eventdata, handles)
|
---|
| 1684 | %-------------------------------------------------------------------
|
---|
[252] | 1685 | eventdata
|
---|
[199] | 1686 | set(handles.runplus,'BackgroundColor',[1 1 0])%paint the command button in yellow
|
---|
| 1687 | drawnow
|
---|
| 1688 | %TODO: introduce the option: increment ='*' to move to the next available view
|
---|
| 1689 | increment=str2double(get(handles.increment_scan,'String')); %get the field increment d
|
---|
| 1690 | if isnan(increment)
|
---|
| 1691 | set(handles.increment_scan,'String','1')%default value
|
---|
| 1692 | increment=1;
|
---|
| 1693 | end
|
---|
| 1694 | errormsg=runpm(hObject,eventdata,handles,increment);
|
---|
| 1695 | if ~isempty(errormsg)
|
---|
| 1696 | msgbox_uvmat('ERROR',errormsg);
|
---|
| 1697 | end
|
---|
| 1698 | set(handles.runplus,'BackgroundColor',[1 0 0])%paint the command button back to red
|
---|
| 1699 |
|
---|
| 1700 | %-------------------------------------------------------------------
|
---|
| 1701 | % --- Executes on button press in runmin: make one step backward and call
|
---|
| 1702 | % --- run0. The step backward is along the fields series 1 or 2 depending on
|
---|
| 1703 | % --- the scan_i and scan_j check box (exclusive each other)
|
---|
| 1704 | function runmin_Callback(hObject, eventdata, handles)
|
---|
| 1705 | %-------------------------------------------------------------------
|
---|
| 1706 | set(handles.runmin,'BackgroundColor',[1 1 0])%paint the command button in yellow
|
---|
| 1707 | drawnow
|
---|
| 1708 | increment=-str2double(get(handles.increment_scan,'String')); %get the field increment d
|
---|
| 1709 | if isnan(increment)
|
---|
| 1710 | set(handles.increment_scan,'String','1')%default value
|
---|
| 1711 | increment=1;
|
---|
| 1712 | end
|
---|
| 1713 | errormsg=runpm(hObject,eventdata,handles,increment);
|
---|
| 1714 | if ~isempty(errormsg)
|
---|
| 1715 | msgbox_uvmat('ERROR',errormsg);
|
---|
| 1716 | end
|
---|
| 1717 | set(handles.runmin,'BackgroundColor',[1 0 0])%paint the command button back to red
|
---|
| 1718 |
|
---|
| 1719 | %-------------------------------------------------------------------
|
---|
| 1720 | % -- Executes on button press in Movie: make a series of +> steps
|
---|
| 1721 | function Movie_Callback(hObject, eventdata, handles)
|
---|
| 1722 | %------------------------------------------------------------------
|
---|
| 1723 | set(handles.Movie,'BackgroundColor',[1 1 0])%paint the command button in yellow
|
---|
| 1724 | drawnow
|
---|
| 1725 | increment=str2double(get(handles.increment_scan,'String')); %get the field increment d
|
---|
| 1726 | if isnan(increment)
|
---|
| 1727 | set(handles.increment_scan,'String','1')%default value
|
---|
| 1728 | increment=1;
|
---|
| 1729 | end
|
---|
| 1730 | set(handles.STOP,'Visible','on')
|
---|
| 1731 | set(handles.speed,'Visible','on')
|
---|
| 1732 | set(handles.speed_txt,'Visible','on')
|
---|
| 1733 | set(handles.Movie,'BusyAction','queue')
|
---|
| 1734 | UvData=get(handles.uvmat,'UserData');
|
---|
| 1735 |
|
---|
| 1736 | while get(handles.speed,'Value')~=0 && isequal(get(handles.Movie,'BusyAction'),'queue') % enable STOP command
|
---|
| 1737 | errormsg=runpm(hObject,eventdata,handles,increment);
|
---|
| 1738 | if ~isempty(errormsg)
|
---|
| 1739 | set(handles.Movie,'BackgroundColor',[1 0 0])%paint the command buttonback to red
|
---|
| 1740 | return
|
---|
| 1741 | end
|
---|
| 1742 | pause(1.02-get(handles.speed,'Value'))% wait for next image
|
---|
| 1743 | end
|
---|
| 1744 | if isfield(UvData,'aviobj') && ~isempty( UvData.aviobj),
|
---|
| 1745 | UvData.aviobj=close(UvData.aviobj);
|
---|
| 1746 | set(handles.uvmat,'UserData',UvData);
|
---|
| 1747 | end
|
---|
| 1748 | set(handles.Movie,'BackgroundColor',[1 0 0])%paint the command buttonback to red
|
---|
| 1749 |
|
---|
| 1750 | %-------------------------------------------------------------------
|
---|
| 1751 | % -- Executes on button press in Movie: make a series of <- steps
|
---|
| 1752 | function MovieBackward_Callback(hObject, eventdata, handles)
|
---|
| 1753 | %------------------------------------------------------------------
|
---|
| 1754 | set(handles.MovieBackward,'BackgroundColor',[1 1 0])%paint the command button in yellow
|
---|
| 1755 | drawnow
|
---|
| 1756 | increment=-str2double(get(handles.increment_scan,'String')); %get the field increment d
|
---|
| 1757 | if isnan(increment)
|
---|
| 1758 | set(handles.increment_scan,'String','1')%default value
|
---|
| 1759 | increment=1;
|
---|
| 1760 | end
|
---|
| 1761 | set(handles.STOP,'Visible','on')
|
---|
| 1762 | set(handles.speed,'Visible','on')
|
---|
| 1763 | set(handles.speed_txt,'Visible','on')
|
---|
| 1764 | set(handles.MovieBackward,'BusyAction','queue')
|
---|
| 1765 | UvData=get(handles.uvmat,'UserData');
|
---|
| 1766 |
|
---|
| 1767 | while get(handles.speed,'Value')~=0 && isequal(get(handles.MovieBackward,'BusyAction'),'queue') % enable STOP command
|
---|
| 1768 | errormsg=runpm(hObject,eventdata,handles,increment);
|
---|
| 1769 | if ~isempty(errormsg)
|
---|
| 1770 | set(handles.MovieBackward,'BackgroundColor',[1 0 0])%paint the command buttonback to red
|
---|
| 1771 | return
|
---|
| 1772 | end
|
---|
| 1773 | pause(1.02-get(handles.speed,'Value'))% wait for next image
|
---|
| 1774 | end
|
---|
| 1775 | if isfield(UvData,'aviobj') && ~isempty( UvData.aviobj),
|
---|
| 1776 | UvData.aviobj=close(UvData.aviobj);
|
---|
| 1777 | set(handles.uvmat,'UserData',UvData);
|
---|
| 1778 | end
|
---|
| 1779 | set(handles.MovieBackward,'BackgroundColor',[1 0 0])%paint the command buttonback to red
|
---|
| 1780 |
|
---|
| 1781 | %-------------------------------------------------------------------
|
---|
| 1782 | function STOP_Callback(hObject, eventdata, handles)
|
---|
| 1783 | %-------------------------------------------------------------------
|
---|
| 1784 | set(handles.movie_pair,'BusyAction','Cancel')
|
---|
| 1785 | set(handles.movie_pair,'value',0)
|
---|
| 1786 | set(handles.Movie,'BusyAction','Cancel')
|
---|
| 1787 | set(handles.MovieBackward,'BusyAction','Cancel')
|
---|
| 1788 | set(handles.MenuExportMovie,'BusyAction','Cancel')
|
---|
| 1789 | set(handles.movie_pair,'BackgroundColor',[1 0 0])%paint the command buttonback to red
|
---|
| 1790 | set(handles.Movie,'BackgroundColor',[1 0 0])%paint the command buttonback to red
|
---|
| 1791 | set(handles.MovieBackward,'BackgroundColor',[1 0 0])%paint the command buttonback to red
|
---|
| 1792 |
|
---|
| 1793 | %------------------------------------------------------------------
|
---|
| 1794 | function errormsg=runpm(hObject,eventdata,handles,increment)
|
---|
| 1795 | %------------------------------------------------------------------
|
---|
| 1796 | %check for mï¿œovie pair status
|
---|
| 1797 | movie_status=get(handles.movie_pair,'Value');
|
---|
| 1798 | if isequal(movie_status,1)
|
---|
| 1799 | STOP_Callback(hObject, eventdata, handles)%interrupt movie pair if active
|
---|
| 1800 | end
|
---|
| 1801 | %read the data on the current input rootfile(s)
|
---|
| 1802 |
|
---|
| 1803 | [FileName,RootPath,filebase,FileIndices,FileExt,subdir]=read_file_boxes(handles);
|
---|
| 1804 | NomType=get(handles.FileIndex,'UserData');
|
---|
| 1805 |
|
---|
| 1806 | num1=stra2num(get(handles.i1,'String'));
|
---|
| 1807 | num2=stra2num(get(handles.i2,'String'));
|
---|
| 1808 | num_a=stra2num(get(handles.j1,'String'));
|
---|
| 1809 | num_b=stra2num(get(handles.j2,'String'));
|
---|
| 1810 |
|
---|
| 1811 | sub_value= get(handles.SubField,'Value');
|
---|
| 1812 | if sub_value % a second input file has been entered
|
---|
| 1813 | [FileName_1,RootPath_1,filebase_1,FileIndices_1,FileExt_1,SubDir_1]=read_file_boxes_1(handles);
|
---|
| 1814 | [pp,ff,str1,str2,str_a,str_b]=name2display(FileIndices_1);
|
---|
| 1815 | num1_1=stra2num(str1);%current set of indices for the second field (may be set different than the main indices)
|
---|
| 1816 | num2_1=stra2num(str2);
|
---|
| 1817 | num_a_1=stra2num(str_a);
|
---|
| 1818 | num_b_1=stra2num(str_b);
|
---|
| 1819 | NomType_1=get(handles.FileIndex_1,'UserData');
|
---|
| 1820 | else
|
---|
| 1821 | filename_1=[];
|
---|
| 1822 | end
|
---|
| 1823 |
|
---|
| 1824 | comp_input=get(handles.fix_pair,'Value');
|
---|
| 1825 |
|
---|
| 1826 | %case of scanning along the first direction (rootfile numbers)
|
---|
| 1827 | if get(handles.scan_i,'Value')==1% case of scanning along index i
|
---|
| 1828 | num1=num1+increment;
|
---|
| 1829 | num2=num2+increment;
|
---|
| 1830 | [filename,num1,num_a,num2,num_b]=name_generator(filebase,num1,num_a,FileExt,NomType,comp_input,num2,num_b,subdir);
|
---|
| 1831 | if sub_value% set the second field name and indices
|
---|
| 1832 | num1_1=num1_1+increment;
|
---|
| 1833 | num2_1=num2_1+increment;
|
---|
| 1834 | filename_1=name_generator(filebase_1,num1_1,num_a_1,FileExt_1,NomType_1,1,num2_1,num_b_1,SubDir_1);
|
---|
| 1835 | end
|
---|
| 1836 | else % case of scanning along index j (burst numbers)
|
---|
| 1837 | num_a=num_a+increment;
|
---|
| 1838 | num_b=num_b+increment;
|
---|
| 1839 | [filename,num1,num_a,num2,num_b]=name_generator(filebase,num1,num_a,FileExt,NomType,comp_input,num2,num_b,subdir);
|
---|
| 1840 | if sub_value
|
---|
| 1841 | num_a_1=num_a_1+increment;
|
---|
| 1842 | num_b_1=num_b_1+increment;
|
---|
| 1843 | filename_1=name_generator(filebase_1,num1_1,num_a_1,FileExt_1,NomType_1,1,num2_1,num_b_1,SubDir_1);
|
---|
| 1844 | end
|
---|
| 1845 | end
|
---|
| 1846 |
|
---|
| 1847 | % refresh plots
|
---|
| 1848 | errormsg=refresh_field(handles,filename,filename_1,num1,num2,num_a,num_b);
|
---|
| 1849 | if isempty(errormsg) %update the index counters
|
---|
| 1850 | set(handles.i1,'String',num2stra(num1,NomType,1));
|
---|
| 1851 | if isequal(num2,num1)
|
---|
| 1852 | set(handles.i2,'String','');
|
---|
| 1853 | else
|
---|
| 1854 | set(handles.i2,'String',num2stra(num2,NomType,1));
|
---|
| 1855 | end
|
---|
| 1856 | set(handles.j1,'String',num2stra(num_a,NomType,2));
|
---|
| 1857 | if isequal(num_b,num_a)
|
---|
| 1858 | set(handles.j2,'String','');
|
---|
| 1859 | else
|
---|
| 1860 | set(handles.j2,'String',num2stra(num_b,NomType,2));
|
---|
| 1861 | end
|
---|
| 1862 | [indices]=name_generator('',num1,num_a,'',NomType,1,num2,num_b,'');
|
---|
| 1863 | set(handles.FileIndex,'String',indices);
|
---|
| 1864 | if ~isempty(filename_1)
|
---|
| 1865 | indices_1=name_generator('',num1_1,num_a_1,'',NomType_1,1,num2_1,num_b_1,'');
|
---|
| 1866 | set(handles.FileIndex_1,'String',indices_1);
|
---|
| 1867 | end
|
---|
| 1868 | if isequal(movie_status,1)
|
---|
| 1869 | set(handles.movie_pair,'Value',1)
|
---|
| 1870 | movie_pair_Callback(hObject, eventdata, handles); %reactivate moviepair if it was activated
|
---|
| 1871 | end
|
---|
| 1872 | end
|
---|
| 1873 |
|
---|
| 1874 |
|
---|
| 1875 | %-------------------------------------------------------
|
---|
| 1876 | % --- Executes on button press in movie_pair: create an alternating movie with two view
|
---|
| 1877 | %-------------------------------------------------------
|
---|
| 1878 | function movie_pair_Callback(hObject, eventdata, handles)
|
---|
| 1879 | status=get(handles.movie_pair,'value');
|
---|
| 1880 | if isequal(status,0)
|
---|
| 1881 | set(handles.movie_pair,'BusyAction','Cancel')%stop movie pair if button is 'off'
|
---|
| 1882 | set(handles.i2,'String','')
|
---|
| 1883 | set(handles.j2,'String','')
|
---|
| 1884 | return
|
---|
| 1885 | else
|
---|
| 1886 | set(handles.movie_pair,'BusyAction','queue')
|
---|
| 1887 | end
|
---|
| 1888 | %initialisation
|
---|
| 1889 | set(handles.movie_pair,'BackgroundColor',[1 1 0])%paint the command button in yellow
|
---|
| 1890 | drawnow
|
---|
| 1891 | list_fields=get(handles.Fields,'String');% list menu fields
|
---|
| 1892 | index_fields=get(handles.Fields,'Value');% selected string index
|
---|
| 1893 | FieldName=list_fields{index_fields}; % selected field
|
---|
| 1894 | UvData=get(handles.uvmat,'UserData');
|
---|
| 1895 | if isequal(FieldName,'image')
|
---|
| 1896 | test_1=0;
|
---|
| 1897 | [ff,rr,filebase,xx,Ext,SubDir]=read_file_boxes(handles);
|
---|
| 1898 | NomType=get(handles.FileIndex,'UserData');
|
---|
| 1899 | else
|
---|
| 1900 | list_fields=get(handles.Fields_1,'String');% list menu fields
|
---|
| 1901 | index_fields=get(handles.Fields_1,'Value');% selected string index
|
---|
| 1902 | FieldName=list_fields{index_fields}; % selected field
|
---|
| 1903 | if isequal(FieldName,'image')
|
---|
| 1904 | test_1=1;
|
---|
| 1905 | [ff,rr,filebase,xx,Ext,SubDir]=read_file_boxes_1(handles);
|
---|
| 1906 | NomType=get(handles.FileIndex_1,'UserData');
|
---|
| 1907 | else
|
---|
| 1908 | msgbox_uvmat('ERROR','an image or movie must be first introduced as input')
|
---|
| 1909 | set(handles.movie_pair,'BackgroundColor',[1 0 0])%paint the command button in red
|
---|
| 1910 | return
|
---|
| 1911 | end
|
---|
| 1912 | end
|
---|
| 1913 |
|
---|
| 1914 | num_i1=str2double(get(handles.i1,'String'));
|
---|
| 1915 | num_j1=stra2num(get(handles.j1,'String'));
|
---|
| 1916 | num_i2=str2double(get(handles.i2,'String'));
|
---|
| 1917 | num_j2=stra2num(get(handles.j2,'String'));
|
---|
| 1918 | if isnan(num_j2)
|
---|
| 1919 | if isempty(num_i2)
|
---|
| 1920 | msgbox_uvmat('ERROR', 'a second image index i2 or j2 is needed to show the pair as a movie')
|
---|
| 1921 | set(handles.movie_pair,'BackgroundColor',[1 0 0])%paint the command button in red
|
---|
| 1922 | return
|
---|
| 1923 | else
|
---|
| 1924 | num_j2=num_j1;%repeat the index i1 by default
|
---|
| 1925 | end
|
---|
| 1926 | end
|
---|
| 1927 | if isnan(num_i2)
|
---|
| 1928 | num_i2=num_i1;%repeat the index i1 by default
|
---|
| 1929 | end
|
---|
| 1930 | imaname_1=name_generator(filebase,num_i2,num_j2,Ext,NomType);
|
---|
| 1931 | if ~exist(imaname_1,'file')
|
---|
| 1932 | msgbox_uvmat('ERROR',['second input open (-) ' imaname_1 ' not found']);
|
---|
| 1933 | set(handles.movie_pair,'BackgroundColor',[1 0 0])%paint the command button in red
|
---|
| 1934 | return
|
---|
| 1935 | end
|
---|
| 1936 |
|
---|
| 1937 | %read the second image
|
---|
| 1938 | Field.AName='image';
|
---|
| 1939 | if test_1
|
---|
| 1940 | Field_a=UvData.Field_1;
|
---|
| 1941 | else
|
---|
| 1942 | Field_a=UvData.Field;
|
---|
| 1943 | end
|
---|
| 1944 | Field_b.AX=Field_a.AX;
|
---|
| 1945 | Field_b.AY=Field_a.AY;
|
---|
| 1946 | % z index
|
---|
| 1947 | nbslice=str2double(get(handles.nb_slice,'String'));
|
---|
| 1948 | if ~isempty(nbslice)
|
---|
| 1949 | Field_b.ZIndex=mod(num_i2-1,nbslice)+1;
|
---|
| 1950 | end
|
---|
| 1951 | Field_b.CoordUnit='pixel';
|
---|
| 1952 | %determine the input file type
|
---|
| 1953 | if (test_1 && isfield(UvData,'MovieObject_1'))||(~test_1 && isfield(UvData,'MovieObject'))
|
---|
| 1954 | FileType='movie';
|
---|
| 1955 | elseif isequal(lower(Ext),'.avi')
|
---|
| 1956 | FileType='avi';
|
---|
| 1957 | elseif isequal(lower(Ext),'.vol')
|
---|
| 1958 | FileType='vol';
|
---|
| 1959 | else
|
---|
| 1960 | form=imformats(Ext(2:end));
|
---|
| 1961 | if ~isempty(form)% if the extension corresponds to an image format recognized by Matlab
|
---|
| 1962 | if isequal(NomType,'*');
|
---|
| 1963 | FileType='multimage';
|
---|
| 1964 | else
|
---|
| 1965 | FileType='image';
|
---|
| 1966 | end
|
---|
| 1967 | end
|
---|
| 1968 | end
|
---|
| 1969 | switch FileType
|
---|
| 1970 | case 'movie'
|
---|
| 1971 | if test_1
|
---|
| 1972 | Field_b.A=read(UvData.MovieObject_1,num_i2);
|
---|
| 1973 | else
|
---|
| 1974 | Field_b.A=read(UvData.MovieObject,num_i2);
|
---|
| 1975 | end
|
---|
| 1976 | case 'avi'
|
---|
| 1977 | mov=aviread(imaname_1,num_i2);
|
---|
| 1978 | Field_b.A=frame2im(mov(1));
|
---|
| 1979 | case 'vol'
|
---|
| 1980 | Field_b.A=imread(imaname_1);
|
---|
| 1981 | case 'multimage'
|
---|
| 1982 | Field_b.A=imread(imaname_1,num_i2);
|
---|
| 1983 | case 'image'
|
---|
| 1984 | Field_b.A=imread(imaname_1);
|
---|
| 1985 | end
|
---|
| 1986 | if get(handles.slices,'Value')
|
---|
| 1987 | Field.ZIndex=str2double(get(handles.z_index,'String'));
|
---|
| 1988 | end
|
---|
| 1989 |
|
---|
| 1990 | %px to phys or other transform on field
|
---|
| 1991 | menu_transform=get(handles.transform_fct,'String');
|
---|
| 1992 | choice_value=get(handles.transform_fct,'Value');
|
---|
| 1993 | transform_name=menu_transform{choice_value};%name of the transform fct given by the menu 'transform_fct'
|
---|
| 1994 | transform_list=get(handles.transform_fct,'UserData');
|
---|
| 1995 | transform=transform_list{choice_value};
|
---|
| 1996 | if ~isequal(transform_name,'') && ~isequal(transform_name,'px')
|
---|
| 1997 | if test_1 && isfield(UvData,'XmlData_1') && isfield(UvData.XmlData_1,'GeometryCalib')%use geometry calib recorded from the ImaDoc xml file as first priority
|
---|
| 1998 | Field_a=transform(Field_a,UvData.XmlData_1);%the first field has been stored without transform
|
---|
| 1999 | Field_b=transform(Field_b,UvData.XmlData_1);
|
---|
| 2000 | elseif ~test_1 && isfield(UvData,'XmlData') && isfield(UvData.XmlData,'GeometryCalib')%use geometry calib
|
---|
| 2001 | Field_b=transform(Field_b,UvData.XmlData);
|
---|
| 2002 | end
|
---|
| 2003 | end
|
---|
| 2004 |
|
---|
| 2005 | % make movie until movie speed is set to 0 or STOP is activated
|
---|
| 2006 | hima=findobj(handles.axes3,'Tag','ima');% %handles.axes3 =main plotting window (A GENERALISER)
|
---|
| 2007 | set(handles.STOP,'Visible','on')
|
---|
| 2008 | set(handles.speed,'Visible','on')
|
---|
| 2009 | set(handles.speed_txt,'Visible','on')
|
---|
| 2010 | while get(handles.speed,'Value')~=0 && isequal(get(handles.movie_pair,'BusyAction'),'queue')%isequal(get(handles.run0,'BusyAction'),'queue'); % enable STOP command
|
---|
| 2011 | % read and plot the series of images in non erase mode
|
---|
| 2012 | set(hima,'CData',Field_b.A);
|
---|
| 2013 | pause(1.02-get(handles.speed,'Value'));% wait for next image
|
---|
| 2014 | set(hima,'CData',Field_a.A);
|
---|
| 2015 | pause(1.02-get(handles.speed,'Value'));% wait for next image
|
---|
| 2016 | end
|
---|
| 2017 | set(handles.movie_pair,'BackgroundColor',[1 0 0])%paint the command button in red
|
---|
| 2018 |
|
---|
| 2019 | %------------------------------------------------------------------------
|
---|
| 2020 | % --- Executes on button press in run0.
|
---|
| 2021 | function run0_Callback(hObject, eventdata, handles)
|
---|
| 2022 | %------------------------------------------------------------------------
|
---|
| 2023 | set(handles.run0,'BackgroundColor',[1 1 0])%paint the command button in yellow
|
---|
| 2024 | drawnow
|
---|
| 2025 | filename=read_file_boxes(handles);
|
---|
| 2026 |
|
---|
| 2027 | filename_1=[];%default
|
---|
| 2028 | if get(handles.SubField,'Value')
|
---|
| 2029 | filename_1=read_file_boxes_1(handles);
|
---|
| 2030 | end
|
---|
| 2031 | num_i1=stra2num(get(handles.i1,'String'));
|
---|
| 2032 | num_i2=stra2num(get(handles.i2,'String'));
|
---|
| 2033 | num_j1=stra2num(get(handles.j1,'String'));
|
---|
| 2034 | num_j2=stra2num(get(handles.j2,'String'));
|
---|
[227] | 2035 |
|
---|
[199] | 2036 | errormsg=refresh_field(handles,filename,filename_1,num_i1,num_i2,num_j1,num_j2);
|
---|
[227] | 2037 |
|
---|
[199] | 2038 | if ~isempty(errormsg)
|
---|
| 2039 | msgbox_uvmat('ERROR',errormsg);
|
---|
| 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])
|
---|
| 2047 | end
|
---|
| 2048 | set(handles.run0,'BackgroundColor',[1 0 0])
|
---|
| 2049 |
|
---|
| 2050 |
|
---|
| 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 | %------------------------------------------------------------------------
|
---|
| 2062 |
|
---|
| 2063 | %% initialisation
|
---|
| 2064 | abstime=[];
|
---|
| 2065 | abstime_1=[];
|
---|
| 2066 | dt=[];
|
---|
| 2067 | if ~exist('Field','var')
|
---|
| 2068 | Field={};
|
---|
| 2069 | end
|
---|
| 2070 | UvData=get(handles.uvmat,'UserData');
|
---|
| 2071 | if ishandle(handles.UVMAT_title) %remove title panel on uvmat
|
---|
| 2072 | delete(handles.UVMAT_title)
|
---|
| 2073 | end
|
---|
| 2074 |
|
---|
| 2075 | %% determine the main input file information for action
|
---|
| 2076 | FileType=[];%default
|
---|
| 2077 | if ~exist(filename,'file')
|
---|
| 2078 | errormsg=['input file ' filename ' does not exist'];
|
---|
| 2079 | return
|
---|
| 2080 | end
|
---|
| 2081 | %Ext=get(handles.FileExt,'String');
|
---|
| 2082 | NomType=get(handles.FileIndex,'UserData');
|
---|
| 2083 | %update the z position index
|
---|
| 2084 | nbslice_str=get(handles.nb_slice,'String');
|
---|
| 2085 | if isequal(nbslice_str,'volume')%NOT USED
|
---|
| 2086 | z_index=num_j1;
|
---|
| 2087 | set(handles.z_index,'String',num2str(z_index))
|
---|
| 2088 | else
|
---|
| 2089 | nbslice=str2num(nbslice_str);
|
---|
| 2090 | z_index=mod(num_i1-1,nbslice)+1;
|
---|
| 2091 | set(handles.z_index,'String',num2str(z_index))
|
---|
| 2092 | end
|
---|
| 2093 | % refresh menu for save_mask if relevant
|
---|
| 2094 | masknumber=get(handles.masklevel,'String');
|
---|
| 2095 | if length(masknumber)>=z_index
|
---|
| 2096 | set(handles.masklevel,'Value',z_index)
|
---|
| 2097 | end
|
---|
| 2098 |
|
---|
| 2099 | %% read the first input field if a filename has been introduced
|
---|
| 2100 | if ~isempty(filename)
|
---|
| 2101 | ObjectName=filename;
|
---|
| 2102 | FieldName=[];%default
|
---|
| 2103 | VelType=[];%default
|
---|
| 2104 | Ext=get(handles.FileExt,'String');
|
---|
| 2105 | if strcmp(Ext,'.nc')||strcmp(Ext,'.cdf')
|
---|
| 2106 | FileType='netcdf';
|
---|
| 2107 | list_fields=get(handles.Fields,'String');% list menu fields
|
---|
| 2108 | index_fields=get(handles.Fields,'Value');% selected string index
|
---|
| 2109 | FieldName= list_fields{index_fields}; % selected field
|
---|
[221] | 2110 | if ~strcmp(FieldName,'get_field...')
|
---|
[236] | 2111 | TestVelType=get(handles.FixVelType,'Value');
|
---|
| 2112 | if TestVelType
|
---|
| 2113 | VelType=setfield(handles);% read the velocity type.
|
---|
| 2114 | end
|
---|
[199] | 2115 | end
|
---|
| 2116 | if strcmp(FieldName,'velocity')
|
---|
| 2117 | list_code=get(handles.color_code,'String');% list menu fields
|
---|
| 2118 | index_code=get(handles.color_code,'Value');% selected string index
|
---|
| 2119 | if ~strcmp(list_code{index_code},'black') && ~strcmp(list_code{index_code},'white')
|
---|
| 2120 | list_code=get(handles.col_vec,'String');% list menu fields
|
---|
| 2121 | index_code=get(handles.col_vec,'Value');% selected string index
|
---|
| 2122 | ParamIn.ColorVar= list_code{index_code}; % selected field
|
---|
| 2123 | end
|
---|
| 2124 | end
|
---|
| 2125 | elseif isfield(UvData,'MovieObject')
|
---|
| 2126 | ObjectName=UvData.MovieObject;
|
---|
| 2127 | FileType='movie';
|
---|
| 2128 | elseif isequal(lower(Ext),'.avi')
|
---|
| 2129 | FileType='avi';
|
---|
| 2130 | elseif isequal(lower(Ext),'.vol')
|
---|
| 2131 | FileType='vol';
|
---|
| 2132 | if isfield(UvData.XmlData,'Npy') && isfield(UvData.XmlData,'Npx')
|
---|
| 2133 | ParamIn.Npy=UvData.XmlData.Npy;
|
---|
| 2134 | ParamIn.Npx=UvData.XmlData.Npx;
|
---|
| 2135 | else
|
---|
| 2136 | errormsg='Npx and Npy need to be defined in the xml file for volume images .vol';
|
---|
| 2137 | return
|
---|
| 2138 | end
|
---|
| 2139 | else
|
---|
| 2140 | form=imformats(Ext(2:end));
|
---|
| 2141 | if ~isempty(form)% if the extension corresponds to an image format recognized by Matlab
|
---|
| 2142 | if isequal(NomType,'*');
|
---|
| 2143 | FileType='multimage';
|
---|
| 2144 | else
|
---|
| 2145 | FileType='image';
|
---|
| 2146 | end
|
---|
| 2147 | end
|
---|
| 2148 | end
|
---|
| 2149 | ParamIn.FieldName=FieldName;
|
---|
| 2150 | ParamIn.VelType=VelType;
|
---|
| 2151 | ParamIn.GUIName='get_field';
|
---|
| 2152 | [Field{1},ParamOut,errormsg] = read_field(ObjectName,FileType,ParamIn,num_i1);
|
---|
| 2153 | if ~isempty(errormsg)
|
---|
| 2154 | errormsg=['error in reading ' filename ': ' errormsg];
|
---|
| 2155 | return
|
---|
[246] | 2156 | end
|
---|
[199] | 2157 | if isfield(ParamOut,'Npx')&& isfield(ParamOut,'Npy')
|
---|
| 2158 | set(handles.npx,'String',num2str(ParamOut.Npx));% display image size on the interface
|
---|
| 2159 | set(handles.npy,'String',num2str(ParamOut.Npy));
|
---|
| 2160 | end
|
---|
[227] | 2161 | if isfield(ParamOut,'TimeIndex')
|
---|
| 2162 | set(handles.i1,'String',num2str(ParamOut.TimeIndex))
|
---|
| 2163 | end
|
---|
| 2164 | if isfield(ParamOut,'TimeValue')
|
---|
| 2165 | Field{1}.Time=ParamOut.TimeValue;
|
---|
| 2166 | end
|
---|
[199] | 2167 | end
|
---|
| 2168 |
|
---|
[236] | 2169 | %% choose a second field filename_1 if defined
|
---|
[199] | 2170 | VelType_1=[];%default
|
---|
| 2171 | FieldName_1=[];
|
---|
| 2172 | ParamOut_1=[];
|
---|
| 2173 | if ~isempty(filename_1)
|
---|
| 2174 | if ~exist(filename_1,'file')
|
---|
| 2175 | errormsg=['second file ' filename_1 ' does not exist'];
|
---|
| 2176 | return
|
---|
| 2177 | else
|
---|
| 2178 | Name=filename_1;
|
---|
| 2179 | FieldName_1=[];%default
|
---|
| 2180 | VelType_1=[];%default
|
---|
[236] | 2181 | if strcmp(get(handles.FileExt_1,'Visible'),'on')
|
---|
| 2182 | Ext_1=get(handles.FileExt_1,'String');
|
---|
| 2183 | else
|
---|
| 2184 | Ext_1=get(handles.FileExt,'String');%read the file extension for the first series (case of veltype comparison within a single file)
|
---|
| 2185 | end
|
---|
[199] | 2186 | NomType_1=get(handles.FileIndex_1,'UserData');
|
---|
| 2187 | if isequal(Ext_1,'.nc')||isequal(Ext_1,'.cdf')
|
---|
| 2188 | FileType_1='netcdf';
|
---|
| 2189 | elseif isfield(UvData,'MovieObject_1')
|
---|
| 2190 | Name=UvData.MovieObject_1;
|
---|
| 2191 | FileType_1='movie';
|
---|
| 2192 | elseif isequal(lower(Ext_1),'.avi')
|
---|
| 2193 | FileType_1='avi';
|
---|
| 2194 | elseif isequal(lower(Ext_1),'.vol')
|
---|
| 2195 | FileType_1='vol';
|
---|
| 2196 | if isfield(UvData.XmlData_1,'Npy') && isfield(UvData.XmlData_1,'Npx')
|
---|
| 2197 | ParamIn.Npy=UvData.XmlData_1.Npy;
|
---|
| 2198 | ParamIn.Npx=UvData.XmlData_1.Npx;
|
---|
| 2199 | else
|
---|
| 2200 | errormsg='Npx and Npy need to be defined in the xml file for volume images .vol';
|
---|
| 2201 | return
|
---|
| 2202 | end
|
---|
| 2203 | else
|
---|
[236] | 2204 | if length(Ext_1)>=2
|
---|
[199] | 2205 | form=imformats(Ext_1(2:end));
|
---|
| 2206 | if ~isempty(form)% if the extension corresponds to an image format recognized by Matlab
|
---|
| 2207 | if isequal(NomType_1,'*');
|
---|
| 2208 | FileType_1='multimage';
|
---|
| 2209 | else
|
---|
| 2210 | FileType_1='image';
|
---|
| 2211 | end
|
---|
| 2212 | end
|
---|
[236] | 2213 | end
|
---|
[199] | 2214 | end
|
---|
| 2215 | if strcmp(FileType_1,'netcdf')
|
---|
| 2216 | list_fields=get(handles.Fields_1,'String');% list menu fields
|
---|
| 2217 | index_fields=get(handles.Fields_1,'Value');% selected string index
|
---|
| 2218 | FieldName_1= list_fields{index_fields}; % selected field
|
---|
| 2219 | if ~isequal(FieldName_1,'get_field...')% read the field names on the interface get_field...
|
---|
[236] | 2220 | VelType_1='';
|
---|
| 2221 | if get(handles.FixVelType,'Value')
|
---|
| 2222 | VelTypeList=get(handles.VelType_1,'String');
|
---|
| 2223 | index=get(handles.VelType_1,'Value');
|
---|
| 2224 | VelType_1=VelTypeList{index};
|
---|
| 2225 | end
|
---|
[199] | 2226 | end
|
---|
| 2227 | if strcmp(VelType_1,'*')% free veltype choice
|
---|
| 2228 | VelType_1=[];
|
---|
| 2229 | elseif strcmp(VelType_1,'"')% veltype the same as for the first field
|
---|
| 2230 | if isempty(VelType)
|
---|
| 2231 | VelType_1=[];
|
---|
| 2232 | else
|
---|
| 2233 | VelType_1=VelType;
|
---|
| 2234 | end
|
---|
| 2235 | end
|
---|
| 2236 | if strcmp(FieldName_1,'velocity')
|
---|
| 2237 | list_code=get(handles.color_code,'String');% list menu fields
|
---|
| 2238 | index_code=get(handles.color_code,'Value');% selected string index
|
---|
| 2239 | if ~strcmp(list_code{index_code},'black') && ~strcmp(list_code{index_code},'white')
|
---|
| 2240 | list_code=get(handles.col_vec,'String');% list menu fields
|
---|
| 2241 | index_code=get(handles.col_vec,'Value');% selected string index
|
---|
| 2242 | ParamIn.ColorVar= list_code{index_code}; % selected field
|
---|
| 2243 | end
|
---|
| 2244 | end
|
---|
| 2245 | end
|
---|
| 2246 | test_keepdata_1=0;% test for keeping the previous stored data if the input files are unchanged
|
---|
| 2247 | if ~isequal(NomType_1,'*')%in case of a series of files (not avi movie)
|
---|
| 2248 | if isfield(UvData,'filename_1')&& isfield(UvData,'VelType_1') && isfield(UvData,'FieldName_1')
|
---|
| 2249 | test_keepdata_1= strcmp(filename_1,UvData.filename_1) && strcmp(VelType_1,UvData.VelType_1) && strcmp(FieldName_1,UvData.FieldName_1);
|
---|
| 2250 | end
|
---|
| 2251 | end
|
---|
| 2252 | if test_keepdata_1
|
---|
| 2253 | Field{2}=UvData.Field_1;
|
---|
| 2254 | else
|
---|
| 2255 | ParamIn.FieldName=FieldName_1;
|
---|
| 2256 | ParamIn.VelType=VelType_1;
|
---|
| 2257 | ParamIn.GUIName='get_field_1';
|
---|
| 2258 | [Field{2},ParamOut_1,errormsg] = read_field(Name,FileType_1,ParamIn,num_i1);
|
---|
| 2259 | if ~isempty(errormsg)
|
---|
[236] | 2260 | errormsg=['error in reading ' FieldName_1 ' in ' filename_1 ': ' errormsg];
|
---|
[199] | 2261 | return
|
---|
| 2262 | end
|
---|
| 2263 | UvData.Field_1=Field{2}; %store the second field for possible use at next RUN
|
---|
| 2264 | end
|
---|
| 2265 | end
|
---|
| 2266 | end
|
---|
| 2267 |
|
---|
| 2268 | %% update uvmat interface
|
---|
| 2269 | if isfield(ParamOut,'Npx')
|
---|
| 2270 | set(handles.npx,'String',num2str(ParamOut.Npx));% display image size on the interface
|
---|
| 2271 | set(handles.npy,'String',num2str(ParamOut.Npy));
|
---|
| 2272 | elseif isfield(ParamOut_1,'Npx')
|
---|
| 2273 | set(handles.npx,'String',num2str(ParamOut_1.Npx));% display image size on the interface
|
---|
| 2274 | set(handles.npy,'String',num2str(ParamOut_1.Npy));
|
---|
| 2275 | end
|
---|
| 2276 |
|
---|
[236] | 2277 | %% update the display menu for the first velocity type (first menuline)
|
---|
| 2278 | % veltype_handles=[handles.VelType handles.interp1 handles.filter1 handles.civ2 handles.interp2 handles.filter2];
|
---|
| 2279 | % if ~isequal(FileType,'netcdf')|| isequal(FieldName,'get_field...')
|
---|
| 2280 | % set(veltype_handles,'Visible','off')
|
---|
| 2281 | % else% if isempty(ParamOut.VelType) && ~isequal(FieldName,'get_field...')
|
---|
| 2282 | % set_veltype_display(veltype_handles,ParamOut.CivStage)%update the display of available velocity types for the first field
|
---|
| 2283 | % if isempty(ParamOut.VelType)
|
---|
| 2284 | % reset_vel_type(veltype_handles)
|
---|
| 2285 | % else
|
---|
| 2286 | % handle1=eval(['handles.' ParamOut.VelType]);
|
---|
| 2287 | % reset_vel_type(veltype_handles,handle1)
|
---|
| 2288 | % end
|
---|
| 2289 | % end
|
---|
| 2290 | test_veltype=0;
|
---|
[199] | 2291 | if ~isequal(FileType,'netcdf')|| isequal(FieldName,'get_field...')
|
---|
[236] | 2292 | set(handles.VelType,'Visible','off')
|
---|
| 2293 | else
|
---|
| 2294 | test_veltype=1;
|
---|
| 2295 | set(handles.VelType,'Visible','on')
|
---|
| 2296 | set(handles.VelType_1,'Visible','on')
|
---|
| 2297 | set(handles.FixVelType,'Visible','on')
|
---|
| 2298 | menu=set_veltype_display(ParamOut.CivStage);
|
---|
| 2299 | index_menu=strcmp(ParamOut.VelType,menu);
|
---|
| 2300 | set(handles.VelType,'Value',find(index_menu,1))
|
---|
[246] | 2301 | if ~get(handles.SubField,'value')
|
---|
[236] | 2302 | set(handles.VelType,'String',menu)
|
---|
[246] | 2303 | set(handles.VelType_1,'Value',1)
|
---|
| 2304 | set(handles.VelType_1,'String',[{''};menu])
|
---|
| 2305 | end
|
---|
[199] | 2306 | end
|
---|
| 2307 | field_index=strcmp(ParamOut.FieldName,ParamOut.FieldList);
|
---|
| 2308 | set(handles.Fields,'String',ParamOut.FieldList); %update the field menu
|
---|
| 2309 | set(handles.Fields,'Value',find(field_index,1))
|
---|
| 2310 |
|
---|
[236] | 2311 | %% update the display menu for the second velocity type (second menuline)
|
---|
| 2312 | % if ~isempty(filename_1)
|
---|
| 2313 | % veltype_handles_1=[handles.VelType_1 handles.interp1_1 handles.filter1_1 handles.civ2_1 handles.interp2_1 handles.filter2_1];
|
---|
| 2314 | % if ~isequal(FileType_1,'netcdf')|| isequal(FieldName_1,'get_field...')
|
---|
| 2315 | % set(veltype_handles_1,'Visible','off')
|
---|
| 2316 | % %reset_vel_type(veltype_handles_1)
|
---|
| 2317 | % else %if isempty(VelType_1) && ~isequal(FieldName_1,'get_field...')
|
---|
| 2318 | % set_veltype_display(veltype_handles_1,ParamOut_1.CivStage)%update the display of available velocity types for the first field
|
---|
| 2319 | % if isempty(ParamOut_1.VelType)
|
---|
| 2320 | % reset_vel_type(veltype_handles_1)
|
---|
| 2321 | % else
|
---|
| 2322 | % handle1=eval(['handles.' ParamOut_1.VelType '_1']);
|
---|
| 2323 | % reset_vel_type(veltype_handles_1,handle1)
|
---|
| 2324 | % end
|
---|
| 2325 | % end
|
---|
| 2326 | % field_index=strcmp(ParamOut_1.FieldName,ParamOut_1.FieldList);
|
---|
| 2327 | % set(handles.Fields_1,'String',ParamOut_1.FieldList); %update the field menu
|
---|
| 2328 | % set(handles.Fields_1,'Value',find(field_index,1))
|
---|
| 2329 | % end
|
---|
| 2330 | test_veltype_1=0;
|
---|
| 2331 | if isempty(filename_1)
|
---|
| 2332 | set(handles.Fields_1,'Value',1); %update the field menu
|
---|
| 2333 | set(handles.Fields_1,'String',[{''};ParamOut.FieldList]); %update the field menu
|
---|
| 2334 | else
|
---|
[199] | 2335 | if ~isequal(FileType_1,'netcdf')|| isequal(FieldName_1,'get_field...')
|
---|
[236] | 2336 | set(handles.VelType_1,'Visible','off')
|
---|
| 2337 | else
|
---|
| 2338 | test_veltype_1=1;
|
---|
| 2339 | set(handles.VelType_1,'Visible','on')
|
---|
| 2340 | if ~get(handles.FixVelType,'Value')
|
---|
| 2341 | menu=set_veltype_display(ParamOut_1.CivStage);
|
---|
| 2342 | index_menu=strcmp(ParamOut_1.VelType,menu);
|
---|
| 2343 | set(handles.VelType_1,'Value',1+find(index_menu,1))
|
---|
| 2344 | set(handles.VelType_1,'String',[{''};menu])
|
---|
[199] | 2345 | end
|
---|
| 2346 | end
|
---|
| 2347 | end
|
---|
[236] | 2348 | if test_veltype||test_veltype_1
|
---|
| 2349 | set(handles.FixVelType,'Visible','on')
|
---|
| 2350 | else
|
---|
| 2351 | set(handles.FixVelType,'Visible','off')
|
---|
| 2352 | end
|
---|
| 2353 |
|
---|
[199] | 2354 | %% introduce w as background image by default for a new series (only for nbdim=2)
|
---|
| 2355 | if ~isfield(UvData,'NewSeries')
|
---|
| 2356 | UvData.NewSeries=1;
|
---|
| 2357 | end
|
---|
| 2358 | %put W as background image by default if NbDim=2:
|
---|
| 2359 | if UvData.NewSeries && isequal(get(handles.SubField,'Value'),0) && isfield(Field{1},'W') && ~isempty(Field{1}.W) && ~isequal(Field{1}.NbDim,3);
|
---|
| 2360 | set(handles.SubField,'Value',1);
|
---|
| 2361 | %menu=update_menu(handles.Fields_1,'w');%update the menu for the background scalar nd set the choice to 'w'
|
---|
| 2362 | set(handles.RootPath_1,'String','"')
|
---|
| 2363 | set(handles.RootFile_1,'String','"')
|
---|
| 2364 | set(handles.SubDir_1,'String','"');
|
---|
| 2365 | [indices]=name_generator('',num_i1,num_j1,'',NomType,1,num_i2,num_j2,'');
|
---|
| 2366 | set(handles.FileIndex_1,'String',indices)
|
---|
| 2367 | set(handles.FileExt_1,'String','"');
|
---|
| 2368 | set(handles.Fields_1,'Visible','on');
|
---|
| 2369 | set(handles.Fields_1,'Visible','on');
|
---|
| 2370 | set(handles.RootPath_1,'Visible','on')
|
---|
| 2371 | set(handles.RootFile_1,'Visible','on')
|
---|
| 2372 | set(handles.SubDir_1,'Visible','on');
|
---|
| 2373 | set(handles.FileIndex_1,'Visible','on');
|
---|
| 2374 | set(handles.FileExt_1,'Visible','on');
|
---|
| 2375 | set(handles.Fields_1,'Visible','on');
|
---|
| 2376 | Field{1}.AName='w';
|
---|
| 2377 | end
|
---|
| 2378 |
|
---|
| 2379 | %% store the current open names, fields and vel types in uvmat interface
|
---|
| 2380 | UvData.filename_1=filename_1;
|
---|
| 2381 | UvData.VelType_1=[];%default
|
---|
| 2382 | UvData.FieldName_1=[];
|
---|
| 2383 | if isfield(ParamOut_1,VelType)
|
---|
| 2384 | UvData.VelType_1=ParamOut_1.VelType;
|
---|
| 2385 | end
|
---|
| 2386 | if isfield(ParamOut_1,FieldName)
|
---|
| 2387 | UvData.FieldName_1=ParamOut_1.FieldName;
|
---|
| 2388 | end
|
---|
| 2389 |
|
---|
| 2390 | %% apply coordinate transform or other user fct
|
---|
| 2391 | XmlData=[];%default
|
---|
| 2392 | if isfield(UvData,'XmlData')%use geometry calib recorded from the ImaDoc xml file as first priority
|
---|
| 2393 | XmlData=UvData.XmlData;
|
---|
| 2394 | end
|
---|
| 2395 | XmlData_1=[];%default
|
---|
| 2396 | if isfield(UvData,'XmlData_1')
|
---|
| 2397 | XmlData_1=UvData.XmlData_1;
|
---|
| 2398 | end
|
---|
| 2399 | % menu_transform=get(handles.transform_fct,'String');
|
---|
| 2400 | choice_value=get(handles.transform_fct,'Value');
|
---|
| 2401 | transform_list=get(handles.transform_fct,'UserData');
|
---|
| 2402 | transform=transform_list{choice_value};%selected function handles
|
---|
| 2403 | % z index
|
---|
| 2404 | if ~isempty(filename)
|
---|
| 2405 | Field{1}.ZIndex=z_index;
|
---|
| 2406 | end
|
---|
| 2407 | %px to phys or other transform on field
|
---|
| 2408 | if ~isempty(transform)
|
---|
| 2409 | if length(Field)>=2
|
---|
| 2410 | Field{2}.ZIndex=z_index;
|
---|
| 2411 | [Field{1},Field{2}]=transform(Field{1},XmlData,Field{2},XmlData_1);
|
---|
| 2412 | if isempty(Field{2})
|
---|
| 2413 | Field(2)=[];
|
---|
| 2414 | end
|
---|
| 2415 | else
|
---|
| 2416 | Field{1}=transform(Field{1},XmlData);
|
---|
| 2417 | end
|
---|
| 2418 | end
|
---|
| 2419 |
|
---|
| 2420 | %% calculate scalar
|
---|
| 2421 | if isequal(FileType,'netcdf') && ~isequal(ParamOut.CivStage,0)%&&~isempty(FieldName)%
|
---|
| 2422 | Field{1}=calc_field([{ParamOut.FieldName} {ParamOut.ColorVar}],Field{1});
|
---|
| 2423 | end
|
---|
[246] | 2424 | if numel(Field)==2 && ~test_keepdata_1 && isequal(FileType_1,'netcdf') && ~isequal(ParamOut_1.FieldName,'get_field...')%&&~isempty(FieldName_1)
|
---|
[199] | 2425 | Field{2}=calc_field([{ParamOut_1.FieldName} {ParamOut_1.ColorVar}],Field{2});
|
---|
| 2426 | end
|
---|
| 2427 |
|
---|
| 2428 | %% combine the two input fields (e.g. substract velocity fields)
|
---|
| 2429 | if numel(Field)==2
|
---|
| 2430 | UvData.Field=sub_field(Field{1},Field{2});
|
---|
| 2431 | else
|
---|
| 2432 | UvData.Field=Field{1};
|
---|
| 2433 | end
|
---|
[243] | 2434 |
|
---|
[199] | 2435 | %% get bounds and mesh (needed for mouse action and to open set_object)
|
---|
| 2436 | test_x=0;
|
---|
| 2437 | test_z=0;% test for unstructured z coordinate
|
---|
| 2438 | [UvData.Field,errormsg]=check_field_structure(UvData.Field);
|
---|
| 2439 | if ~isempty(errormsg)
|
---|
| 2440 | errormsg=['error in uvmat/refresh_field/check_field_structure: ' errormsg];
|
---|
| 2441 | return
|
---|
| 2442 | end
|
---|
[210] | 2443 | [CellVarIndex,NbDim,VarType,errormsg]=find_field_indices(UvData.Field);
|
---|
[199] | 2444 | if ~isempty(errormsg)
|
---|
| 2445 | errormsg=['error in uvmat/refresh_field/find_field_indices: ' errormsg];
|
---|
| 2446 | return
|
---|
| 2447 | end
|
---|
| 2448 | [NbDim,imax]=max(NbDim);
|
---|
[210] | 2449 | if isfield(UvData.Field,'NbDim')
|
---|
| 2450 | NbDim=UvData.Field.NbDim;% deal with plane fields containing z coordinates
|
---|
| 2451 | end
|
---|
[199] | 2452 | if ~isempty(VarType{imax}.coord_x) && ~isempty(VarType{imax}.coord_y) %unstructured coordinates
|
---|
| 2453 | XName=UvData.Field.ListVarName{VarType{imax}.coord_x};
|
---|
| 2454 | YName=UvData.Field.ListVarName{VarType{imax}.coord_y};
|
---|
| 2455 | eval(['nbvec=length(UvData.Field.' XName ');'])%nbre of measurement points (e.g. vectors)
|
---|
| 2456 | test_x=1;%test for unstructured coordinates
|
---|
[206] | 2457 | if ~isempty(VarType{imax}.coord_z)
|
---|
| 2458 | ZName=UvData.Field.ListVarName{VarType{imax}.coord_z};
|
---|
| 2459 | else
|
---|
| 2460 | NbDim=2;
|
---|
| 2461 | end
|
---|
[236] | 2462 | elseif numel(VarType)>=imax && numel(VarType{imax}.coord)>=NbDim && VarType{imax}.coord(NbDim)>0 %structured coordinate
|
---|
[199] | 2463 | XName=UvData.Field.ListVarName{VarType{imax}.coord(NbDim)};
|
---|
| 2464 | if NbDim>1
|
---|
| 2465 | YName=UvData.Field.ListVarName{VarType{imax}.coord(NbDim-1)}; %structured coordinates
|
---|
| 2466 | end
|
---|
[236] | 2467 | else
|
---|
[247] | 2468 | % errormsg='input field coordinates not defined';
|
---|
| 2469 | % return
|
---|
[199] | 2470 | end
|
---|
| 2471 | if NbDim==3
|
---|
[206] | 2472 | if ~test_x
|
---|
| 2473 | ZName=UvData.Field.ListVarName{VarType{imax}.coord(1)};%structured coordinates in 3D
|
---|
| 2474 | end
|
---|
[199] | 2475 | eval(['ZMax=max(UvData.Field.' ZName ');'])
|
---|
| 2476 | eval(['ZMin=min(UvData.Field.' ZName ');'])
|
---|
[206] | 2477 | UvData.Field.ZMax=ZMax;
|
---|
| 2478 | UvData.Field.ZMin=ZMin;
|
---|
[199] | 2479 | test_z=1;
|
---|
| 2480 | if isequal(ZMin,ZMax)%no z dependency
|
---|
| 2481 | NbDim=2;
|
---|
| 2482 | test_z=0;
|
---|
| 2483 | end
|
---|
| 2484 | end
|
---|
| 2485 | if exist('XName','var')
|
---|
[227] | 2486 | eval(['XMax=max(max(UvData.Field.' XName '));'])
|
---|
| 2487 | eval(['XMin=min(min(UvData.Field.' XName '));'])
|
---|
[206] | 2488 | UvData.Field.NbDim=NbDim;
|
---|
| 2489 | UvData.Field.XMax=XMax;
|
---|
| 2490 | UvData.Field.XMin=XMin;
|
---|
[199] | 2491 | if NbDim >1
|
---|
[227] | 2492 | eval(['YMax=max(max(UvData.Field.' YName '));'])
|
---|
| 2493 | eval(['YMin=min(min(UvData.Field.' YName '));'])
|
---|
[206] | 2494 | UvData.Field.YMax=YMax;
|
---|
| 2495 | UvData.Field.YMin=YMin;
|
---|
[199] | 2496 | end
|
---|
[206] | 2497 | eval(['nbvec=length(UvData.Field.' XName ');'])
|
---|
| 2498 | if test_x %unstructured coordinates
|
---|
| 2499 | if test_z
|
---|
| 2500 | UvData.Field.Mesh=((XMax-XMin)*(YMax-YMin)*(ZMax-ZMin))/nbvec;% volume per vector
|
---|
| 2501 | UvData.Field.Mesh=(UvData.Field.Mesh)^(1/3);
|
---|
| 2502 | else
|
---|
| 2503 | UvData.Field.Mesh=sqrt((XMax-XMin)*(YMax-YMin)/nbvec);%2D
|
---|
| 2504 | end
|
---|
[199] | 2505 | else
|
---|
[206] | 2506 | VarIndex=CellVarIndex{imax}; % list of variable indices
|
---|
| 2507 | DimIndex=UvData.Field.VarDimIndex{VarIndex(1)}; %list of dim indices for the variable
|
---|
| 2508 | nbpoints_x=UvData.Field.DimValue(DimIndex(NbDim));
|
---|
| 2509 | DX=(XMax-XMin)/(nbpoints_x-1);
|
---|
| 2510 | if NbDim >1
|
---|
| 2511 | nbpoints_y=UvData.Field.DimValue(DimIndex(NbDim-1));
|
---|
| 2512 | DY=(YMax-YMin)/(nbpoints_y-1);
|
---|
| 2513 | end
|
---|
| 2514 | if NbDim==3
|
---|
| 2515 | nbpoints_z=UvData.Field.DimValue(DimIndex(1));
|
---|
| 2516 | DZ=(ZMax-ZMin)/(nbpoints_z-1);
|
---|
[246] | 2517 | UvData.Field.Mesh=(DX*DY*DZ)^(1/3);
|
---|
[206] | 2518 | UvData.Field.ZMax=ZMax;
|
---|
| 2519 | UvData.Field.ZMin=ZMin;
|
---|
| 2520 | else
|
---|
[221] | 2521 | UvData.Field.Mesh=DX;%sqrt(DX*DY);
|
---|
[206] | 2522 | end
|
---|
[199] | 2523 | end
|
---|
| 2524 | end
|
---|
| 2525 |
|
---|
| 2526 | %% 3D case (menuvolume)
|
---|
| 2527 | if NbDim==3% && UvData.NewSeries
|
---|
| 2528 | test_set_object=1;
|
---|
| 2529 | hset_object=findobj(allchild(0),'tag','set_object');% look for the set_object GUI
|
---|
| 2530 | ZBounds(1)=UvData.Field.ZMin; %minimum for the Z slider
|
---|
| 2531 | ZBounds(2)=UvData.Field.ZMax;%maximum for the Z slider
|
---|
| 2532 | if ~isempty(hset_object) %if set_object is detected
|
---|
| 2533 | % hhset_object=guidata(hset_object);
|
---|
| 2534 | % % ZBounds_old(1)=get(hhset_object.z_slider,'Min');
|
---|
| 2535 | % % ZBounds_old(2)=get(hhset_object.z_slider,'Max');
|
---|
| 2536 | % % if isequal(ZBounds_old,ZBounds)
|
---|
| 2537 | % test_set_object=0;% do not refresh the GUI set_object
|
---|
| 2538 | % else
|
---|
| 2539 | delete(hset_object);% delete the GUI set_object if it does not fit
|
---|
| 2540 | % end
|
---|
| 2541 | end
|
---|
| 2542 | if test_set_object% reinitiate the GUI set_object
|
---|
| 2543 | delete_object(1);% delete the current projection object in the list UvData.Object, delete its graphic representations and update the list displayed in handles.list_object_1 and 2
|
---|
| 2544 | UvData.Object{1}.Style='plane';%main plotting plane
|
---|
| 2545 | UvData.Object{1}.ProjMode='projection';%main plotting plane
|
---|
| 2546 | UvData.Object{1}.DisplayHandle_uvmat=[]; %plane not visible in uvmat
|
---|
| 2547 | UvData.Object{1}.NbDim=NbDim;%test for 3D objects
|
---|
| 2548 | UvData.Object{1}.RangeZ=UvData.Field.Mesh;%main plotting plane
|
---|
| 2549 | UvData.Object{1}.Coord(1,3)=(UvData.Field.ZMin+UvData.Field.ZMax)/2;%section at a middle plane chosen
|
---|
[206] | 2550 | UvData.Object{1}.Angle=[0 0 0];
|
---|
| 2551 | % UvData.Object{1}.Theta=0;
|
---|
| 2552 | % UvData.Object{1}.Psi=0;
|
---|
[199] | 2553 | UvData.Object{1}.HandlesDisplay=plot(0,0,'Tag','proj_object');% A REVOIR
|
---|
[206] | 2554 | % PlotHandles=get_plot_handles(handles);
|
---|
[199] | 2555 | UvData.Object{1}.Name='1-PLANE';
|
---|
| 2556 | UvData.Object{1}.enable_plot=1;
|
---|
[206] | 2557 | set_object(UvData.Object{1},handles,ZBounds);
|
---|
[199] | 2558 | set(handles.list_object_1,'Value',1);
|
---|
| 2559 | set(handles.list_object_1,'String',{'1-PLANE'});
|
---|
| 2560 | set(handles.edit_object,'Value',1)% put the plane in edit mode to enable the z cursor
|
---|
| 2561 | edit_object_Callback([],[], handles)
|
---|
| 2562 | end
|
---|
| 2563 | %multilevel case (single menuplane in a 3D space)
|
---|
| 2564 | elseif isfield(UvData,'Z')
|
---|
| 2565 | if isfield(UvData,'CoordType')&& isequal(UvData.CoordType,'phys') && isfield(UvData,'XmlData')
|
---|
| 2566 | XmlData=UvData.XmlData;
|
---|
| 2567 | if isfield(XmlData,'PlanePos')
|
---|
| 2568 | UvData.Object{1}.Coord=XmlData.PlanePos(UvData.ZIndex,:);
|
---|
| 2569 | end
|
---|
| 2570 | if isfield(XmlData,'PlaneAngle')
|
---|
| 2571 | siz=size(XmlData.PlaneAngle);
|
---|
| 2572 | indangle=min(siz(1),UvData.ZIndex);%take first angle if a single angle is defined (translating scanning)
|
---|
[206] | 2573 | UvData.Object{1}.PlaneAngle=XmlData.PlaneAngle(indangle,:);
|
---|
[199] | 2574 | end
|
---|
| 2575 | elseif isfield(UvData,'ZIndex')
|
---|
| 2576 | UvData.Object{1}.ZObject=UvData.ZIndex;
|
---|
| 2577 | end
|
---|
| 2578 | else
|
---|
[231] | 2579 | % create a default projection
|
---|
[252] | 2580 | UvData.Object{1}.ProjMode='projection';%main plotting plane
|
---|
| 2581 | UvData.Object{1}.DisplayHandle_uvmat=[]; %plane not visible in uvmat
|
---|
| 2582 | set(handles.list_object_1,'Value',1);
|
---|
| 2583 | list_object=get(handles.list_object_1,'String')
|
---|
| 2584 | if isempty(list_object)
|
---|
| 2585 | list_object={''};
|
---|
| 2586 | elseif ~isempty(list_object{1})
|
---|
| 2587 | list_object=[{''};list_object];
|
---|
| 2588 | end
|
---|
| 2589 | set(handles.list_object_1,'String',list_object);
|
---|
| 2590 | set(handles.list_object_2,'String',list_object);
|
---|
[199] | 2591 | end
|
---|
[215] | 2592 | % if ~isfield(UvData.Object{1},'plotaxes')
|
---|
| 2593 | % UvData.Object{1}.plotaxes=handles.axes3;%default plotting axis
|
---|
| 2594 | % end
|
---|
[199] | 2595 | testnewseries=UvData.NewSeries;
|
---|
| 2596 | UvData.NewSeries=0;% put to 0 the test for a new field series (set by RootPath_callback)
|
---|
| 2597 | set(handles.uvmat,'UserData',UvData)
|
---|
| 2598 |
|
---|
| 2599 | %% reset the min and max of scalar if only the mask is displayed(TODO: check the need)
|
---|
| 2600 | if isfield(UvData,'Mask')&& ~isfield(UvData,'A')
|
---|
| 2601 | set(handles.MinA,'String','0')
|
---|
| 2602 | set(handles.MaxA,'String','255')
|
---|
| 2603 | end
|
---|
| 2604 |
|
---|
| 2605 | %% Plot the projections on the selected projection objects
|
---|
[248] | 2606 |
|
---|
[199] | 2607 | % main projection object (uvmat display)
|
---|
[236] | 2608 | list_object=get(handles.list_object_1,'String');
|
---|
| 2609 | if isequal(list_object,{''})%refresh list of objects if the menu is empty
|
---|
| 2610 | UvData.Object={[]};
|
---|
| 2611 | set(handles.list_object_1,'Value',1)
|
---|
| 2612 | set(handles.list_object_2,'Value',1)
|
---|
| 2613 | set(handles.list_object_2,'String',{''})
|
---|
| 2614 | set(handles.list_object_2,'Visible','off')
|
---|
| 2615 | end
|
---|
[199] | 2616 | IndexObj(1)=get(handles.list_object_1,'Value');%selected projection object for main view
|
---|
| 2617 | if IndexObj(1)> numel(UvData.Object)
|
---|
| 2618 | IndexObj(1)=1;%select the first object if the selected one does not exist
|
---|
| 2619 | set(handles.list_object_1,'Value',1)
|
---|
| 2620 | end
|
---|
| 2621 | plot_handles{1}=handles;
|
---|
[215] | 2622 | if isfield(UvData,'plotaxes')%case of movies
|
---|
| 2623 | haxes(1)=UvData.plotaxes;
|
---|
| 2624 | else
|
---|
| 2625 | haxes(1)=handles.axes3;
|
---|
| 2626 | end
|
---|
[199] | 2627 | PlotParam{1}=read_plot_param(handles);%read plotting parameters on the uvmat interfac
|
---|
| 2628 | keeplim(1)=get(handles.FixLimits,'Value');% test for fixed graph limits
|
---|
| 2629 | PosColorbar{1}=UvData.OpenParam.PosColorbar;%prescribe the colorbar position on the uvmat interface
|
---|
| 2630 |
|
---|
| 2631 | % second projection object (view_field display)
|
---|
| 2632 | IndexObj_2=get(handles.list_object_2,'Value');%selected projection object for the second view
|
---|
[231] | 2633 | if IndexObj_2==0
|
---|
| 2634 | IndexObj_2=1;
|
---|
| 2635 | end
|
---|
[199] | 2636 | if isequal(get(handles.list_object_2,'Visible'),'on') && IndexObj_2 <= numel(UvData.Object)&& ~isempty(UvData.Object{IndexObj_2})
|
---|
| 2637 | IndexObj(2)=IndexObj_2;
|
---|
| 2638 | view_field_handle=findobj(allchild(0),'tag','view_field');%handles of the view_field GUI
|
---|
| 2639 | if ~isempty(view_field_handle)
|
---|
| 2640 | plot_handles{2}=guidata(view_field_handle);
|
---|
| 2641 | haxes(2)=plot_handles{2}.axes3;
|
---|
| 2642 | PlotParam{2}=read_plot_param(plot_handles{2});%read plotting parameters on the uvmat interface
|
---|
| 2643 | keeplim(2)=get(plot_handles{2}.FixLimits,'Value');
|
---|
| 2644 | PosColorbar{2}='*'; %TODO: deal with colorbar position on view_field
|
---|
| 2645 | end
|
---|
| 2646 | end
|
---|
| 2647 |
|
---|
| 2648 | %loop on the projection objects: one or two
|
---|
| 2649 | for imap=1:numel(IndexObj)
|
---|
[206] | 2650 | iobj=IndexObj(imap);
|
---|
[199] | 2651 | [ObjectData,errormsg]=proj_field(UvData.Field,UvData.Object{iobj});% project field on the object
|
---|
| 2652 | if testnewseries && isfield(ObjectData,'CoordUnit')
|
---|
| 2653 | PlotParam{imap}=rmfield(PlotParam{imap},'FixEqual'); %set FixEqual to depend on the field (=1 if Data.CoordUnit=1 in plot_field)
|
---|
| 2654 | end
|
---|
| 2655 | if ~isempty(errormsg)
|
---|
| 2656 | return
|
---|
| 2657 | end
|
---|
| 2658 | %use of mask (TODO: check)
|
---|
| 2659 | if isfield(ObjectData,'NbDim') && isequal(ObjectData.NbDim,2) && isfield(ObjectData,'Mask') && isfield(ObjectData,'A')
|
---|
| 2660 | flag_mask=double(ObjectData.Mask>200);%=0 for masked regions
|
---|
| 2661 | AX=ObjectData.AX;%x coordiantes for the scalar field
|
---|
| 2662 | AY=ObjectData.AY;%y coordinates for the scalar field
|
---|
| 2663 | MaskX=ObjectData.MaskX;%x coordiantes for the mask
|
---|
| 2664 | MaskY=ObjectData.MaskY;%y coordiantes for the mask
|
---|
| 2665 | if ~isequal(MaskX,AX)||~isequal(MaskY,AY)
|
---|
| 2666 | nxy=size(flag_mask);
|
---|
| 2667 | sizpx=(ObjectData.MaskX(end)-ObjectData.MaskX(1))/(nxy(2)-1);%size of a mask pixel
|
---|
| 2668 | sizpy=(ObjectData.MaskY(1)-ObjectData.MaskY(end))/(nxy(1)-1);
|
---|
| 2669 | x_mask=ObjectData.MaskX(1):sizpx:ObjectData.MaskX(end); % pixel x coordinates for image display
|
---|
| 2670 | y_mask=ObjectData.MaskY(1):-sizpy:ObjectData.MaskY(end);% pixel x coordinates for image display
|
---|
| 2671 | %project on the positions of the scalar
|
---|
| 2672 | npxy=size(ObjectData.A);
|
---|
| 2673 | dxy(1)=(ObjectData.AY(end)-ObjectData.AY(1))/(npxy(1)-1);%grid mesh in y
|
---|
| 2674 | dxy(2)=(ObjectData.AX(end)-ObjectData.AX(1))/(npxy(2)-1);%grid mesh in x
|
---|
| 2675 | xi=ObjectData.AX(1):dxy(2):ObjectData.AX(end);
|
---|
| 2676 | yi=ObjectData.AY(1):dxy(1):ObjectData.AY(end);
|
---|
| 2677 | [XI,YI]=meshgrid(xi,yi);% creates the matrix of regular coordinates
|
---|
| 2678 | flag_mask = interp2(x_mask,y_mask,flag_mask,XI,YI);
|
---|
| 2679 | end
|
---|
| 2680 | AClass=class(ObjectData.A);
|
---|
| 2681 | ObjectData.A=flag_mask.*double(ObjectData.A);
|
---|
| 2682 | ObjectData.A=feval(AClass,ObjectData.A);
|
---|
| 2683 | ind_off=[];
|
---|
| 2684 | if isfield(ObjectData,'ListVarName')
|
---|
| 2685 | for ilist=1:length(ObjectData.ListVarName)
|
---|
| 2686 | if isequal(ObjectData.ListVarName{ilist},'Mask')||isequal(ObjectData.ListVarName{ilist},'MaskX')||isequal(ObjectData.ListVarName{ilist},'MaskY')
|
---|
| 2687 | ind_off=[ind_off ilist];
|
---|
| 2688 | end
|
---|
| 2689 | end
|
---|
| 2690 | ObjectData.ListVarName(ind_off)=[];
|
---|
| 2691 | ObjectData.VarDimIndex(ind_off)=[];
|
---|
| 2692 | ind_off=[];
|
---|
| 2693 | for ilist=1:length(ObjectData.ListDimName)
|
---|
| 2694 | if isequal(ObjectData.ListDimName{ilist},'MaskX') || isequal(ObjectData.ListDimName{ilist},'MaskY')
|
---|
| 2695 | ind_off=[ind_off ilist];
|
---|
| 2696 | end
|
---|
| 2697 | end
|
---|
| 2698 | ObjectData.ListDimName(ind_off)=[];
|
---|
| 2699 | ObjectData.DimValue(ind_off)=[];
|
---|
| 2700 | end
|
---|
| 2701 | end
|
---|
| 2702 | if ~isempty(ObjectData)
|
---|
| 2703 | PlotType='none'; %default
|
---|
| 2704 | if imap==2 && isempty(view_field_handle)
|
---|
| 2705 | view_field(ObjectData)
|
---|
| 2706 | else
|
---|
| 2707 | [PlotType,PlotParamOut]=plot_field(ObjectData,haxes(imap),PlotParam{imap},PosColorbar{imap});
|
---|
| 2708 | write_plot_param(plot_handles{imap},PlotParamOut) %update the auto plot parameters
|
---|
| 2709 | if isfield(Field,'Mesh')&&~isempty(Field.Mesh)
|
---|
| 2710 | ObjectData.Mesh=Field.Mesh; % gives an estimated mesh size (useful for mouse action on the plot)
|
---|
| 2711 | end
|
---|
| 2712 | end
|
---|
| 2713 | if isequal(PlotType,'none')
|
---|
| 2714 | hget_field=findobj(allchild(0),'name','get_field');
|
---|
| 2715 | if isempty(hget_field)
|
---|
| 2716 | get_field(filename)% the projected field cannot be automatically plotted: use get_field to specify the variablesdelete(hget_field)
|
---|
| 2717 | end
|
---|
| 2718 | errormsg='The field defined by get_field cannot be plotted';
|
---|
| 2719 | return
|
---|
| 2720 | end
|
---|
| 2721 | end
|
---|
| 2722 | end
|
---|
| 2723 |
|
---|
| 2724 | %% update the mask
|
---|
| 2725 | if isequal(get(handles.mask_test,'Value'),1)%if the mask option is on
|
---|
| 2726 | update_mask(handles,num_i1,num_i2);
|
---|
| 2727 | end
|
---|
| 2728 |
|
---|
| 2729 | %% prepare the menus of histograms and plot them (histogram of the whole volume in 3D case)
|
---|
| 2730 | menu_histo=(UvData.Field.ListVarName)';%list of field variables to be displayed for the menu of histogram display
|
---|
| 2731 | ind_bad=[];
|
---|
| 2732 | nb_histo=1;
|
---|
| 2733 |
|
---|
| 2734 | % suppress coordinates from the histogram menu
|
---|
| 2735 | for ivar=1:numel(menu_histo)%l loop on field variables:
|
---|
| 2736 | if isfield(UvData.Field,'VarAttribute') && numel(UvData.Field.VarAttribute)>=ivar && isfield(UvData.Field.VarAttribute{ivar},'Role')
|
---|
| 2737 | Role=UvData.Field.VarAttribute{ivar}.Role;
|
---|
| 2738 | switch Role
|
---|
| 2739 | case {'coord_x','coord_y','coord_z','dimvar'}
|
---|
| 2740 | ind_bad=[ind_bad ivar];
|
---|
| 2741 | case {'vector_y'}
|
---|
| 2742 | nb_histo=nb_histo+1;
|
---|
| 2743 | end
|
---|
| 2744 | end
|
---|
| 2745 | DimCell=UvData.Field.VarDimName{ivar};
|
---|
| 2746 | DimName='';
|
---|
| 2747 | if ischar(DimCell)
|
---|
| 2748 | DimName=DimCell;
|
---|
| 2749 | elseif iscell(DimCell)&& numel(DimCell)==1
|
---|
| 2750 | DimName=DimCell{1};
|
---|
| 2751 | end
|
---|
| 2752 | if strcmp(DimName,menu_histo{ivar})
|
---|
| 2753 | ind_bad=[ind_bad ivar];
|
---|
| 2754 | end
|
---|
| 2755 | end
|
---|
| 2756 | menu_histo(ind_bad)=[];
|
---|
| 2757 |
|
---|
| 2758 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
---|
| 2759 | % display menus and plot histograms
|
---|
| 2760 | test_v=0;
|
---|
| 2761 | if ~isempty(menu_histo)
|
---|
| 2762 | set(handles.histo1_menu,'Value',1)
|
---|
| 2763 | set(handles.histo1_menu,'String',menu_histo)
|
---|
| 2764 | histo1_menu_Callback(handles.histo1_menu, [], handles)% plot first histogram
|
---|
| 2765 | % case of more than one variables (eg vector components)
|
---|
| 2766 | if nb_histo > 1
|
---|
| 2767 | test_v=1;
|
---|
| 2768 | set(handles.histo2_menu,'Visible','on')
|
---|
| 2769 | set(handles.histo_v,'Visible','on')
|
---|
| 2770 | set(handles.histo2_menu,'String',menu_histo)
|
---|
| 2771 | set(handles.histo2_menu,'Value',2)
|
---|
| 2772 | histo2_menu_Callback(handles.histo2_menu,[], handles)% plot second histogram
|
---|
| 2773 | end
|
---|
| 2774 | end
|
---|
| 2775 | if ~test_v
|
---|
| 2776 | set(handles.histo2_menu,'Visible','off')
|
---|
| 2777 | set(handles.histo_v,'Visible','off')
|
---|
| 2778 | cla(handles.histo_v)
|
---|
| 2779 | set(handles.histo2_menu,'Value',1)
|
---|
| 2780 | end
|
---|
| 2781 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
---|
| 2782 |
|
---|
| 2783 | %% display time
|
---|
| 2784 | testimedoc=0;
|
---|
[221] | 2785 | TimeUnit='';
|
---|
| 2786 | if isfield(UvData.Field,'Time')
|
---|
| 2787 | abstime=UvData.Field.Time;%time read from the netcdf input file
|
---|
| 2788 | end
|
---|
| 2789 | if isfield(UvData,'Field_1') && isfield(UvData.Field_1,'Time')
|
---|
| 2790 | abstime_1=UvData.Field_1.Time;%time read from the netcdf input file
|
---|
| 2791 | end
|
---|
| 2792 | if isfield(UvData.Field,'dt')
|
---|
| 2793 | dt=UvData.Field.dt;%dt read from the netcdf input file
|
---|
| 2794 | if isfield(UvData.Field,'TimeUnit')
|
---|
| 2795 | TimeUnit=UvData.Field.TimeUnit;
|
---|
| 2796 | end
|
---|
| 2797 | elseif isfield(UvData,'Field_1') && isfield(UvData.Field_1,'dt')%dt obtained from the second field if not defined in the first
|
---|
| 2798 | dt=UvData.Field_1.dt;%dt read from the netcdf input file
|
---|
| 2799 | if isfield(UvData.Field_1,'TimeUnit')
|
---|
| 2800 | TimeUnit=UvData.Field_1.TimeUnit;
|
---|
| 2801 | end
|
---|
| 2802 | end
|
---|
| 2803 | % time from xml file overset previous result
|
---|
[199] | 2804 | if isfield(UvData,'XmlData') && isfield(UvData.XmlData,'Time')
|
---|
| 2805 | if isempty(num_i2)||isnan(num_i2)
|
---|
| 2806 | num_i2=num_i1;
|
---|
| 2807 | end
|
---|
| 2808 | if isempty(num_j1)||isnan(num_j1)
|
---|
| 2809 | num_j1=1;
|
---|
| 2810 | end
|
---|
| 2811 | if isempty(num_j2)||isnan(num_j2)
|
---|
| 2812 | num_j2=num_j1;
|
---|
| 2813 | end
|
---|
| 2814 | siz=size(UvData.XmlData.Time);
|
---|
| 2815 | if siz(1)>=max(num_i1,num_i2) && siz(2)>=max(num_j1,num_j2)
|
---|
| 2816 | abstime=(UvData.XmlData.Time(num_i1,num_j1)+UvData.XmlData.Time(num_i2,num_j2))/2;%overset the time read from files
|
---|
| 2817 | dt=(UvData.XmlData.Time(num_i2,num_j2)-UvData.XmlData.Time(num_i1,num_j1));
|
---|
| 2818 | testimedoc=1;
|
---|
[221] | 2819 | if isfield(UvData.XmlData,'TimeUnit')
|
---|
| 2820 | TimeUnit=UvData.XmlData.TimeUnit;
|
---|
| 2821 | end
|
---|
[199] | 2822 | end
|
---|
| 2823 | end
|
---|
| 2824 | if isfield(UvData,'XmlData_1') && isfield(UvData.XmlData_1,'Time')
|
---|
| 2825 | [P,F,str1,str2,str_a,str_b,E]=name2display(['xx' get(handles.FileIndex_1,'String') get(handles.FileExt_1,'String')]);
|
---|
| 2826 | num_i2=str2double(str2);
|
---|
| 2827 | if isnan(num_i2)
|
---|
| 2828 | num_i2=num_i1;
|
---|
| 2829 | end
|
---|
| 2830 | num_j1=str2double(str_a);
|
---|
| 2831 | if isnan(num_j1)
|
---|
| 2832 | num_j1=1;
|
---|
| 2833 | end
|
---|
| 2834 | num_j2=str2double(str_b);
|
---|
| 2835 | if isnan(num_j2)
|
---|
| 2836 | num_j2=num_j1;
|
---|
| 2837 | end
|
---|
| 2838 | num_i1=str2double(str1);
|
---|
| 2839 | siz=size(UvData.XmlData_1.Time);
|
---|
| 2840 | if siz(1)>=max(num_i1,num_i2) && siz(2)>=max(num_j1,num_j2)
|
---|
| 2841 | 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
|
---|
| 2842 | end
|
---|
| 2843 | end
|
---|
[258] | 2844 | if ~isequal(numel(abstime),1)
|
---|
| 2845 | abstime=[];
|
---|
| 2846 | end
|
---|
| 2847 | if ~isequal(numel(abstime_1),1)
|
---|
| 2848 | abstime_1=[];
|
---|
| 2849 | end
|
---|
[199] | 2850 | set(handles.abs_time,'String',num2str(abstime,4))
|
---|
| 2851 | set(handles.abs_time_1,'String',num2str(abstime_1,4))
|
---|
| 2852 | if testimedoc && isfield(UvData,'dt')
|
---|
| 2853 | dt=UvData.dt;
|
---|
| 2854 | end
|
---|
| 2855 | if isempty(dt)||isequal(dt,0)
|
---|
| 2856 | set(handles.Dt_txt,'String','')
|
---|
| 2857 | else
|
---|
[221] | 2858 | if isempty(TimeUnit)
|
---|
[199] | 2859 | set(handles.Dt_txt,'String',['Dt=' num2str(1000*dt,3) ' 10^(-3)'] )
|
---|
| 2860 | else
|
---|
[221] | 2861 | set(handles.Dt_txt,'String',['Dt=' num2str(1000*dt,3) ' m' TimeUnit] )
|
---|
[199] | 2862 | end
|
---|
| 2863 | end
|
---|
| 2864 |
|
---|
| 2865 |
|
---|
| 2866 | %-------------------------------------------------------------------
|
---|
| 2867 | % --- translate coordinate to matrix index
|
---|
| 2868 | %-------------------------------------------------------------------
|
---|
| 2869 | function [indx,indy]=pos2ind(x0,rangx0,nxy)
|
---|
| 2870 | indx=1+round((nxy(2)-1)*(x0-rangx0(1))/(rangx0(2)-rangx0(1)));% index x of pixel
|
---|
| 2871 | indy=1+round((nxy(1)-1)*(y12-rangy0(1))/(rangy0(2)-rangy0(1)));% index y of pixel
|
---|
| 2872 |
|
---|
| 2873 | %-------------------------------------------------------------------
|
---|
| 2874 | % --- Executes on button press in 'FixLimits'.
|
---|
| 2875 | %-------------------------------------------------------------------
|
---|
| 2876 | function FixLimits_Callback(hObject, eventdata, handles)
|
---|
| 2877 | test=get(handles.FixLimits,'Value');
|
---|
| 2878 | if test
|
---|
| 2879 | set(handles.FixLimits,'BackgroundColor',[1 1 0])
|
---|
| 2880 | else
|
---|
| 2881 | set(handles.FixLimits,'BackgroundColor',[0.7 0.7 0.7])
|
---|
| 2882 | update_plot(handles);
|
---|
| 2883 | end
|
---|
| 2884 |
|
---|
| 2885 | %-------------------------------------------------------------------
|
---|
| 2886 | % --- Executes on button press in FixEqual.
|
---|
| 2887 | function FixEqual_Callback(hObject, eventdata, handles)
|
---|
| 2888 | test=get(handles.FixEqual,'Value');
|
---|
| 2889 | if test
|
---|
| 2890 | set(handles.FixEqual,'BackgroundColor',[1 1 0])
|
---|
| 2891 | cla(handles.axes3)
|
---|
| 2892 | update_plot(handles);
|
---|
| 2893 | else
|
---|
| 2894 | set(handles.FixEqual,'BackgroundColor',[0.7 0.7 0.7])
|
---|
| 2895 | update_plot(handles);
|
---|
| 2896 | % axis(handles.axes3,'image')
|
---|
| 2897 | end
|
---|
| 2898 |
|
---|
| 2899 |
|
---|
| 2900 | %-------------------------------------------------------------------
|
---|
| 2901 |
|
---|
| 2902 | %-------------------------------------------------------------------
|
---|
| 2903 | % --- Executes on button press in 'zoom'.
|
---|
| 2904 | %-------------------------------------------------------------------
|
---|
| 2905 | function zoom_Callback(hObject, eventdata, handles)
|
---|
| 2906 |
|
---|
| 2907 | if (get(handles.zoom,'Value') == 1);
|
---|
| 2908 | set(handles.zoom,'BackgroundColor',[1 1 0])
|
---|
| 2909 | set(handles.FixLimits,'Value',1)% propose by default fixed limits for the plotting axes
|
---|
| 2910 | set(handles.FixLimits,'BackgroundColor',[1 1 0])
|
---|
| 2911 | else
|
---|
| 2912 | set(handles.zoom,'BackgroundColor',[0.7 0.7 0.7])
|
---|
| 2913 | end
|
---|
| 2914 |
|
---|
| 2915 |
|
---|
| 2916 | %-------------------------------------------------------------------
|
---|
| 2917 | %----Executes on button press in 'record': records the current flags of manual correction.
|
---|
| 2918 | %-------------------------------------------------------------------
|
---|
| 2919 | function record_Callback(hObject, eventdata, handles)
|
---|
| 2920 | % [filebase,num_i1,num_j1,num_i2,num_j2,Ext,NomType,SubDir]=read_input_file(handles);
|
---|
| 2921 | filename=read_file_boxes(handles);
|
---|
| 2922 | [erread,message]=fileattrib(filename);
|
---|
| 2923 | if ~isempty(message) && ~isequal(message.UserWrite,1)
|
---|
| 2924 | msgbox_uvmat('ERROR',['no writting access to ' filename])
|
---|
| 2925 | return
|
---|
| 2926 | end
|
---|
| 2927 | test_civ2=isequal(get(handles.civ2,'BackgroundColor'),[1 1 0]);
|
---|
[236] | 2928 | test_civ1=isequal(get(handles.VelType,'BackgroundColor'),[1 1 0]);
|
---|
[199] | 2929 | if ~test_civ2 && ~test_civ1
|
---|
| 2930 | msgbox_uvmat('ERROR','manual correction only possible for CIV1 or CIV2 velocity fields')
|
---|
| 2931 | end
|
---|
| 2932 | if test_civ2
|
---|
| 2933 | nbname='nb_vectors2';
|
---|
| 2934 | flagname='vec2_FixFlag';
|
---|
| 2935 | attrname='fix2';
|
---|
| 2936 | end
|
---|
| 2937 | if test_civ1
|
---|
| 2938 | nbname='nb_vectors';
|
---|
| 2939 | flagname='vec_FixFlag';
|
---|
| 2940 | attrname='fix';
|
---|
| 2941 | end
|
---|
| 2942 | %write fix flags in the netcdf file
|
---|
| 2943 | UvData=get(handles.uvmat,'UserData');
|
---|
| 2944 | hhh=which('netcdf.open');% look for built-in matlab netcdf library
|
---|
| 2945 | if ~isequal(hhh,'')% case of new builtin Matlab netcdf library
|
---|
| 2946 | nc=netcdf.open(filename,'NC_WRITE');
|
---|
| 2947 | netcdf.reDef(nc);
|
---|
| 2948 | netcdf.putAtt(nc,netcdf.getConstant('NC_GLOBAL'),attrname,1);
|
---|
| 2949 | dimid = netcdf.inqDimID(nc,nbname);
|
---|
| 2950 | try
|
---|
| 2951 | varid = netcdf.inqVarID(nc,flagname);% look for already existing fixflag variable
|
---|
| 2952 | catch
|
---|
| 2953 | varid=netcdf.defVar(nc,flagname,'double',dimid);%create fixflag variable if it does not exist
|
---|
| 2954 | end
|
---|
| 2955 | netcdf.endDef(nc);
|
---|
| 2956 | netcdf.putVar(nc,varid,UvData.axes3.FF);
|
---|
| 2957 | netcdf.close(nc);
|
---|
| 2958 | else %old netcdf library
|
---|
| 2959 | netcdf_toolbox(filename,AxeData,attrname,nbname,flagname)
|
---|
| 2960 | end
|
---|
| 2961 |
|
---|
| 2962 | %-------------------------------------------------------------------
|
---|
| 2963 | %----Correct the netcdf file, using toolbox (old versions of Matlab).
|
---|
| 2964 | %-------------------------------------------------------------------
|
---|
| 2965 | function netcdf_toolbox(filename,AxeData,attrname,nbname,flagname)
|
---|
| 2966 | nc=netcdf(filename,'write'); %open netcdf file
|
---|
| 2967 | result=redef(nc);
|
---|
| 2968 | eval(['nc.' attrname '=1;']);
|
---|
| 2969 | theDim=nc(nbname) ;% get the number of velocity vectors
|
---|
| 2970 | nb_vectors=size(theDim);
|
---|
| 2971 | var_FixFlag=ncvar(flagname,nc);% var_FixFlag will be written as the netcdf variable vec_FixFlag
|
---|
| 2972 | var_FixFlag(1:nb_vectors)=AxeData.FF;%
|
---|
| 2973 | fin=close(nc);
|
---|
| 2974 |
|
---|
| 2975 |
|
---|
| 2976 | %-------------------------------------------------------------------
|
---|
| 2977 | %determines the fields to read from the interface
|
---|
| 2978 | %------------------------------------------------------------------
|
---|
[236] | 2979 | function VelType=setfield(handles)
|
---|
| 2980 | VelTypeList=get(handles.VelType,'String');
|
---|
| 2981 | index=get(handles.VelType,'Value');
|
---|
| 2982 | VelType=VelTypeList{index};
|
---|
[199] | 2983 |
|
---|
[236] | 2984 | % VelType=[]; %default
|
---|
| 2985 | % if (get(handles.VelType,'Value') == 1);
|
---|
| 2986 | % VelType='civ1';
|
---|
| 2987 | % % interp1
|
---|
| 2988 | % elseif (get(handles.interp1,'Value') == 1);
|
---|
| 2989 | % VelType='interp1';
|
---|
| 2990 | % % filter1
|
---|
| 2991 | % elseif (get(handles.filter1,'Value') == 1);
|
---|
| 2992 | % VelType='filter1';
|
---|
| 2993 | % % CIV2
|
---|
| 2994 | % elseif (get(handles.civ2,'Value') == 1);
|
---|
| 2995 | % VelType='civ2';
|
---|
| 2996 | % % interp2
|
---|
| 2997 | % elseif (get(handles.interp2,'Value') == 1);
|
---|
| 2998 | % VelType='interp2';
|
---|
| 2999 | % % filter2
|
---|
| 3000 | % elseif (get(handles.filter2,'Value') == 1);
|
---|
| 3001 | % VelType='filter2';
|
---|
| 3002 | % end
|
---|
| 3003 | %
|
---|
| 3004 | % if isequal(get(handles.filter2,'Visible'),'on');
|
---|
| 3005 | % civ=6;
|
---|
| 3006 | % % interp1
|
---|
| 3007 | % elseif isequal(get(handles.interp2,'Visible'),'on');
|
---|
| 3008 | % civ=5;
|
---|
| 3009 | % % filter1
|
---|
| 3010 | % elseif isequal(get(handles.civ2,'Visible'),'on');
|
---|
| 3011 | % civ=4;
|
---|
| 3012 | % % CIV2
|
---|
| 3013 | % elseif isequal(get(handles.filter1,'Visible'),'on');
|
---|
| 3014 | % civ=3;
|
---|
| 3015 | % % interp2
|
---|
| 3016 | % elseif isequal(get(handles.interp1,'Visible'),'on');
|
---|
| 3017 | % civ=2;
|
---|
| 3018 | % % filter2
|
---|
| 3019 | % elseif isequal(get(handles.VelType,'Visible'),'on');
|
---|
| 3020 | % civ=1;
|
---|
| 3021 | % else
|
---|
| 3022 | % civ=0;
|
---|
| 3023 | % end
|
---|
[199] | 3024 |
|
---|
| 3025 | %-------------------------------------------------------------------
|
---|
| 3026 | %determines the veltype of the second field to read from the iinterface
|
---|
| 3027 | %------------------------------------------------------------------
|
---|
| 3028 | function VelType=setfield_1(handles)
|
---|
[236] | 3029 | VelTypeList=get(handles.VelType_1,'String');
|
---|
| 3030 | index=get(handles.VelType_1,'Value');
|
---|
| 3031 | VelType=VelTypeList{index};
|
---|
| 3032 | % VelType=[]; %default
|
---|
| 3033 | % if (get(handles.VelType_1,'Value') == 1);
|
---|
| 3034 | % VelType='civ1';
|
---|
| 3035 | % % interp1
|
---|
| 3036 | % elseif (get(handles.interp1_1,'Value') == 1);
|
---|
| 3037 | % VelType='interp1';
|
---|
| 3038 | % % filter1
|
---|
| 3039 | % elseif (get(handles.filter1_1,'Value') == 1);
|
---|
| 3040 | % VelType='filter1';
|
---|
| 3041 | % % CIV2
|
---|
| 3042 | % elseif (get(handles.civ2_1,'Value') == 1);
|
---|
| 3043 | % VelType='civ2';
|
---|
| 3044 | % % interp2
|
---|
| 3045 | % elseif (get(handles.interp2_1,'Value') == 1);
|
---|
| 3046 | % VelType='interp2';
|
---|
| 3047 | % % filter2
|
---|
| 3048 | % elseif (get(handles.filter2_1,'Value') == 1);
|
---|
| 3049 | % VelType='filter2';
|
---|
| 3050 | % end
|
---|
[199] | 3051 |
|
---|
| 3052 |
|
---|
| 3053 | %---------------------------------------------------
|
---|
| 3054 | % --- Executes on button press in SubField
|
---|
| 3055 | function SubField_Callback(hObject, eventdata, handles)
|
---|
[236] | 3056 | % huvmat=get(handles.run0,'parent');
|
---|
| 3057 | UvData=get(handles.uvmat,'UserData');
|
---|
[199] | 3058 | if get(handles.SubField,'Value')==0% if the subfield button is desactivated
|
---|
| 3059 | set(handles.RootPath_1,'String','')
|
---|
| 3060 | set(handles.RootFile_1,'String','')
|
---|
| 3061 | set(handles.SubDir_1,'String','');
|
---|
| 3062 | set(handles.FileIndex_1,'String','');
|
---|
| 3063 | set(handles.FileExt_1,'String','');
|
---|
| 3064 | set(handles.RootPath_1,'Visible','off')
|
---|
| 3065 | set(handles.RootFile_1,'Visible','off')
|
---|
| 3066 | set(handles.SubDir_1,'Visible','off');
|
---|
| 3067 | set(handles.FileIndex_1,'Visible','off');
|
---|
| 3068 | set(handles.FileExt_1,'Visible','off');
|
---|
| 3069 | set(handles.Fields_1,'Value',1);%set to blank state
|
---|
[236] | 3070 | set(handles.VelType_1,'Value',1);%set to blank state
|
---|
| 3071 | if ~strcmp(get(handles.VelType,'Visible'),'on')
|
---|
| 3072 | set(handles.VelType_1,'Visible','off')
|
---|
| 3073 | end
|
---|
| 3074 | % set_veltype_display([handles.VelType_1 handles.interp1_1 handles.filter1_1 ...
|
---|
| 3075 | % handles.civ2_1 handles.interp2_1 handles.filter2_1],0)
|
---|
[199] | 3076 | if isfield(UvData,'XmlData_1')
|
---|
| 3077 | UvData=rmfield(UvData,'XmlData_1');
|
---|
| 3078 | end
|
---|
[236] | 3079 | set(handles.uvmat,'UserData',UvData);
|
---|
[199] | 3080 | run0_Callback(hObject, eventdata, handles); %run
|
---|
| 3081 | else
|
---|
| 3082 | MenuBrowse_1_Callback(hObject, eventdata, handles)
|
---|
| 3083 | end
|
---|
| 3084 |
|
---|
| 3085 | %------------------------------------------------------------------------
|
---|
| 3086 | % --- read the data displayed for the input rootfile windows (new)
|
---|
| 3087 | function [FileName,RootPath,FileBase,FileIndices,FileExt,SubDir]=read_file_boxes(handles)
|
---|
| 3088 | %------------------------------------------------------------------------
|
---|
| 3089 | RootPath=get(handles.RootPath,'String');
|
---|
| 3090 | FileName=RootPath; %default
|
---|
| 3091 | SubDir=get(handles.SubDir,'String');
|
---|
| 3092 | if ~isempty(SubDir) && ~isequal(SubDir,'')
|
---|
| 3093 | if (isequal(SubDir(1),'/')|| isequal(SubDir(1),'\'))
|
---|
| 3094 | SubDir(1)=[]; %suppress possible / or \ separator
|
---|
| 3095 | end
|
---|
| 3096 | FileName=fullfile(RootPath,SubDir);
|
---|
| 3097 | end
|
---|
| 3098 | RootFile=get(handles.RootFile,'String');
|
---|
| 3099 | if ~isempty(RootFile) && ~isequal(RootFile,'')
|
---|
| 3100 | if (isequal(RootFile(1),'/')|| isequal(RootFile(1),'\'))
|
---|
| 3101 | RootFile(1)=[]; %suppress possible / or \ separator
|
---|
| 3102 | end
|
---|
| 3103 | FileName=fullfile(FileName,RootFile);
|
---|
| 3104 | end
|
---|
| 3105 | FileBase=fullfile(RootPath,RootFile);
|
---|
| 3106 | FileIndices=get(handles.FileIndex,'String');
|
---|
| 3107 | FileExt=get(handles.FileExt,'String');
|
---|
| 3108 | FileName=[FileName FileIndices FileExt];
|
---|
| 3109 |
|
---|
| 3110 | %------------------------------------------------------------------------
|
---|
| 3111 | % ---- read the data displayed for the second input rootfile windows
|
---|
| 3112 | function [FileName_1,RootPath_1,FileBase_1,FileIndices_1,FileExt_1,SubDir_1]=read_file_boxes_1(handles)
|
---|
| 3113 | %------------------------------------------------------------------------
|
---|
| 3114 | RootPath_1=get(handles.RootPath_1,'String'); % read the data from the file1_input window
|
---|
| 3115 | if isequal(get(handles.RootPath_1,'Visible'),'off') || isequal(RootPath_1,'"')
|
---|
| 3116 | RootPath_1=get(handles.RootPath,'String');
|
---|
| 3117 | end;
|
---|
| 3118 | FileName_1=RootPath_1; %default
|
---|
| 3119 | SubDir_1=get(handles.SubDir_1,'String');
|
---|
| 3120 | if isequal(get(handles.SubDir_1,'Visible'),'off')|| isequal(SubDir_1,'"')
|
---|
| 3121 | SubDir_1=get(handles.SubDir,'String');
|
---|
| 3122 | end
|
---|
| 3123 | if numel(SubDir_1)>=1
|
---|
| 3124 | if (isequal(SubDir_1(1),'/')|| isequal(SubDir_1(1),'\'))
|
---|
| 3125 | SubDir_1(1)=[]; %suppress possible / or \ separator
|
---|
| 3126 | end
|
---|
| 3127 | FileName_1=fullfile(RootPath_1,SubDir_1);
|
---|
| 3128 | end
|
---|
| 3129 | RootFile_1=get(handles.RootFile_1,'String');
|
---|
| 3130 | if isequal(get(handles.RootFile_1,'Visible'),'off') || isequal(RootFile_1,'"')
|
---|
| 3131 | RootFile_1=get(handles.RootFile,'String');
|
---|
| 3132 | end
|
---|
| 3133 | if numel(RootFile_1)>=1
|
---|
[210] | 3134 | if ~(isequal(RootFile_1(1),'/')||isequal(RootFile_1(1),'\'))
|
---|
[199] | 3135 | RootFile_1(1)=[];%suppress possible / or \ separator
|
---|
| 3136 | end
|
---|
| 3137 | FileName_1=fullfile(FileName_1,RootFile_1);
|
---|
| 3138 | end
|
---|
| 3139 | FileBase_1=fullfile(RootPath_1,RootFile_1);
|
---|
| 3140 | if isequal(get(handles.FileIndex_1,'Visible'),'off')
|
---|
| 3141 | FileIndices_1=get(handles.FileIndex,'String');
|
---|
| 3142 | else
|
---|
| 3143 | FileIndices_1=get(handles.FileIndex_1,'String');
|
---|
| 3144 | end
|
---|
| 3145 | FileExt_1=get(handles.FileExt_1,'String');
|
---|
[246] | 3146 | if isequal(get(handles.FileExt_1,'Visible'),'off') || isequal(FileExt_1,'"')
|
---|
| 3147 | FileExt_1=get(handles.FileExt,'String');%read FileExt by default
|
---|
| 3148 | end
|
---|
[199] | 3149 | FileName_1=[FileName_1 FileIndices_1 FileExt_1];
|
---|
| 3150 |
|
---|
| 3151 | %------------------------------------------------------------------------
|
---|
| 3152 | % --- Executes on menu selection Fields
|
---|
| 3153 | function Fields_Callback(hObject, eventdata, handles)
|
---|
| 3154 | %------------------------------------------------------------------------
|
---|
| 3155 | list_fields=get(handles.Fields,'String');% list menu fields
|
---|
| 3156 | index_fields=get(handles.Fields,'Value');% selected string index
|
---|
| 3157 | field= list_fields{index_fields(1)}; % selected string
|
---|
| 3158 | if isequal(field,'get_field...')
|
---|
[236] | 3159 | set(handles.FixVelType,'visible','off')
|
---|
| 3160 | set(handles.VelType,'visible','off')
|
---|
| 3161 | set(handles.VelType_1,'visible','off')
|
---|
| 3162 | % veltype_handles=[handles.VelType handles.interp1 handles.filter1 handles.civ2 handles.interp2 handles.filter2];
|
---|
| 3163 | % set_veltype_display(veltype_handles,0) % unvisible civ buttons
|
---|
[199] | 3164 | filename=read_file_boxes(handles);
|
---|
| 3165 | hget_field=findobj(allchild(0),'name','get_field');
|
---|
| 3166 | if ~isempty(hget_field)
|
---|
| 3167 | delete(hget_field)
|
---|
| 3168 | end
|
---|
| 3169 | hget_field=get_field(filename);
|
---|
| 3170 | set(hget_field,'Name','get_field')
|
---|
| 3171 | hhget_field=guidata(hget_field);
|
---|
| 3172 | set(hhget_field.list_fig,'Value',1)
|
---|
| 3173 | set(hhget_field.list_fig,'String',{'uvmat'})
|
---|
| 3174 | set(handles.transform_fct,'Value',1)% no transform by default
|
---|
| 3175 | set(handles.path_transform,'String','')
|
---|
| 3176 | return %no action
|
---|
| 3177 | end
|
---|
| 3178 | list_fields=get(handles.Fields_1,'String');% list menu fields
|
---|
| 3179 | index_fields=get(handles.Fields_1,'Value');% selected string index
|
---|
| 3180 | field_1= list_fields{index_fields(1)}; % selected string
|
---|
| 3181 | UvData=get(handles.uvmat,'UserData');
|
---|
| 3182 |
|
---|
| 3183 | %read the rootfile input display
|
---|
| 3184 | [FileName,RootPath,FileBase,FileIndices,FileExt]=read_file_boxes(handles);
|
---|
| 3185 | [P,F,str1,str2,str_a,str_b,E,NomType]=name2display(['xxx' get(handles.FileIndex,'String') FileExt]);
|
---|
| 3186 | NomTypeNew=NomType;%default
|
---|
| 3187 | if isequal(field,'image')
|
---|
| 3188 | % transform netc type to the corresponding image type
|
---|
| 3189 | % if isequal(NomType,'_i1-i2_j')||isequal(NomType,'_i_j1-j2')|| isequal(NomType,'#_ab')|| isequal(NomType,'_i1-i2')
|
---|
| 3190 | % UvData.SubDir=get(handles.SubDir,'String'); %preserve the subdir in memory
|
---|
| 3191 | % if ~isempty(UvData.SubDir) && (isequal(UvData.SubDir(1),'/')||isequal(UvData.SubDir(1),'/'))
|
---|
| 3192 | % UvData.SubDir(1)=[];
|
---|
| 3193 | % end
|
---|
| 3194 | % set(handles.SubDir,'String','')
|
---|
| 3195 | % set(handles.FileExt,'String','.png');
|
---|
| 3196 | if isequal(NomType,'_i1-i2_j')||isequal(NomType,'_i_j1-j2')
|
---|
| 3197 | NomTypeNew='_i_j';
|
---|
| 3198 | elseif isequal(NomType,'#_ab')
|
---|
| 3199 | NomTypeNew='#a';
|
---|
| 3200 | elseif isequal(NomType,'_i1-i2')
|
---|
| 3201 | NomTypeNew='_i';
|
---|
| 3202 | end
|
---|
| 3203 | imagename=name_generator(FileBase,str2double(str1),str2double(str_a),'.png',NomTypeNew,1,str2double(str2),str2double(str_b),'');
|
---|
| 3204 | if ~exist(imagename,'file')
|
---|
| 3205 | [FileName,PathName] = uigetfile( ...
|
---|
| 3206 | {'*.png;*.jpg;*.tif;*.avi;*.AVI;*.vol', ' (*.png, .tif, *.avi,*.vol)';
|
---|
| 3207 | '*.jpg',' jpeg image files'; ...
|
---|
| 3208 | '*.png','.png image files'; ...
|
---|
| 3209 | '*.tif','.tif image files'; ...
|
---|
| 3210 | '*.avi;*.AVI','.avi movie files'; ...
|
---|
| 3211 | '*.vol','.volume images (png)'; ...
|
---|
| 3212 | '*.*', 'All Files (*.*)'}, ...
|
---|
| 3213 | 'Pick an image',imagename);
|
---|
| 3214 | % display the selected field and related information
|
---|
| 3215 | imagename=[PathName FileName];
|
---|
| 3216 | end
|
---|
| 3217 | display_file_name(hObject, eventdata, handles,imagename)%display the image
|
---|
| 3218 | return
|
---|
| 3219 | % end
|
---|
[236] | 3220 | % veltype_handles=[handles.VelType handles.interp1 handles.filter1 handles.civ2 handles.interp2 handles.filter2];
|
---|
[199] | 3221 | % set_veltype_display(veltype_handles,0) % unvisible civ buttons
|
---|
| 3222 | else
|
---|
| 3223 | ext=get(handles.FileExt,'String');
|
---|
| 3224 | if ~isequal(ext,'.nc') %find the new NomType if the previous display was not already a netcdf file
|
---|
| 3225 | [FileName,PathName] = uigetfile( ...
|
---|
| 3226 | {'*.nc', ' (*.nc)';
|
---|
| 3227 | '*.nc',' netcdf files'; ...
|
---|
| 3228 | '*.*', 'All Files (*.*)'}, ...
|
---|
| 3229 | 'Pick a netcdf file',FileBase);
|
---|
| 3230 | % display the selected field and related information
|
---|
| 3231 | filename=[PathName FileName];
|
---|
| 3232 | display_file_name(hObject, eventdata, handles,filename)
|
---|
| 3233 | return
|
---|
| 3234 | % MenuBrowse_Callback(hObject, eventdata, handles)
|
---|
| 3235 | end
|
---|
[236] | 3236 | % if isequal(field,'vort') || isequal(field,'div') || isequal(field,'strain')
|
---|
| 3237 | % % set(handles.VelType,'BackgroundColor',[0.702 0.702 0.702]) % put their color to grey
|
---|
| 3238 | % % set(handles.civ2,'BackgroundColor',[0.702 0.702 0.702])
|
---|
| 3239 | % % set(handles.interp1,'BackgroundColor',[0.702 0.702 0.702])
|
---|
| 3240 | % % set(handles.interp2,'BackgroundColor',[0.702 0.702 0.702])
|
---|
| 3241 | % elseif isequal(field,'more...');
|
---|
| 3242 | % set(handles.VelType,'BackgroundColor',[0.702 0.702 0.702]) % put their color to grey
|
---|
| 3243 | % set(handles.civ2,'BackgroundColor',[0.702 0.702 0.702])
|
---|
| 3244 | % str=calc_field;%get the list of available scalars by the function calc_scal
|
---|
| 3245 | % [ind_answer] = listdlg('PromptString','Select a file:',...
|
---|
| 3246 | % 'SelectionMode','single',...
|
---|
| 3247 | % 'ListString',str);
|
---|
| 3248 | % % edit the choice in the field and action menu
|
---|
| 3249 | % scalar=cell2mat(str(ind_answer));
|
---|
| 3250 | % menu=update_menu(handles.Fields,scalar);
|
---|
| 3251 | % menu=[{''};menu];
|
---|
| 3252 | % set(handles.Fields_1,'String',menu);% store the selected scalar type
|
---|
| 3253 | % end
|
---|
[199] | 3254 | end
|
---|
| 3255 | indices=name_generator('',str2double(str1),str2double(str_a),'',NomTypeNew,1,str2double(str2),str2double(str_b),'');
|
---|
| 3256 | set(handles.FileIndex,'String',indices)
|
---|
| 3257 | set(handles.FileIndex,'UserData',NomTypeNew)
|
---|
| 3258 | %common to Fields_1_Callback
|
---|
| 3259 | if isequal(field,'image')||isequal(field_1,'image')
|
---|
| 3260 | set(handles.npx_title,'Visible','on')% visible npx,pxcm... buttons
|
---|
| 3261 | set(handles.npy_title,'Visible','on')
|
---|
| 3262 | set(handles.npx,'Visible','on')
|
---|
| 3263 | set(handles.npy,'Visible','on')
|
---|
| 3264 | else
|
---|
| 3265 | set(handles.npx_title,'Visible','off')% visible npx,pxcm... buttons
|
---|
| 3266 | set(handles.npy_title,'Visible','off')
|
---|
| 3267 | set(handles.npx,'Visible','off')
|
---|
| 3268 | set(handles.npy,'Visible','off')
|
---|
| 3269 | end
|
---|
| 3270 | setfield(handles);% update the field structure ('civ1'....)
|
---|
| 3271 |
|
---|
| 3272 | if ~(isfield(UvData,'NewSeries')&&isequal(UvData.NewSeries,1))
|
---|
| 3273 | run0_Callback(hObject, eventdata, handles)
|
---|
| 3274 | end
|
---|
| 3275 |
|
---|
| 3276 | %---------------------------------------------------
|
---|
| 3277 | % --- Executes on menu selection Fields
|
---|
| 3278 | function Fields_1_Callback(hObject, eventdata, handles)
|
---|
| 3279 | %-------------------------------------------------
|
---|
| 3280 | list_fields=get(handles.Fields,'String');% list menu fields
|
---|
| 3281 | index_fields=get(handles.Fields,'Value');% selected string index
|
---|
| 3282 | field= list_fields{index_fields(1)}; % selected string
|
---|
| 3283 | list_fields=get(handles.Fields_1,'String');% list menu fields
|
---|
| 3284 | index_fields=get(handles.Fields_1,'Value');% selected string index
|
---|
| 3285 | field_1= list_fields{index_fields(1)}; % selected string for the second field
|
---|
| 3286 | if isequal(field_1,'') %remove second field if 'blank' field is selected
|
---|
| 3287 | set(handles.SubField,'Value',0)
|
---|
| 3288 | SubField_Callback(hObject, eventdata, handles)
|
---|
| 3289 | return
|
---|
| 3290 | end
|
---|
| 3291 | UvData=get(handles.uvmat,'UserData');
|
---|
| 3292 |
|
---|
| 3293 | %read the rootfile input display
|
---|
[246] | 3294 | [FileName,RootPath,FileBase,FileIndices,FileExt_1]=read_file_boxes_1(handles);
|
---|
| 3295 | [P,F,str1,str2,str_a,str_b,E,NomType]=name2display(['xxx' get(handles.FileIndex,'String') FileExt_1]);
|
---|
| 3296 | % if isempty(FileExt_prev)|| strcmp(FileExt_prev,'')
|
---|
| 3297 | % FileExt_1=get(handles.FileExt,'String');
|
---|
| 3298 | % else
|
---|
| 3299 | % FileExt_1=FileExt_prev;
|
---|
| 3300 | % end
|
---|
[199] | 3301 | NomType_1=get(handles.FileIndex_1,'UserData');
|
---|
[210] | 3302 | if isempty(NomType_1)|| strcmp(NomType_1,'')
|
---|
[199] | 3303 | NomType_1=get(handles.FileIndex,'UserData');
|
---|
| 3304 | end
|
---|
| 3305 | NomTypeNew=NomType_1;%default
|
---|
| 3306 |
|
---|
| 3307 | set(handles.SubField,'Value',1)%introduce second field
|
---|
| 3308 | if isfield(UvData,'XmlData')
|
---|
| 3309 | UvData.XmlData_1=UvData.XmlData;
|
---|
| 3310 | end
|
---|
| 3311 | set(handles.FileIndex_1,'Visible','on')
|
---|
| 3312 | set(handles.FileExt_1,'Visible','on')
|
---|
| 3313 | RootPath_1=get(handles.RootPath_1,'String');
|
---|
| 3314 | RootFile_1=get(handles.RootFile_1,'String');
|
---|
| 3315 | if isempty(RootPath_1)||isequal(RootPath_1,'')
|
---|
| 3316 | set(handles.RootPath_1,'String','"')
|
---|
| 3317 | end
|
---|
| 3318 | if isempty(RootFile_1) || isequal(RootFile_1,'')
|
---|
| 3319 | set(handles.RootFile_1,'String','"')
|
---|
| 3320 | end
|
---|
| 3321 | if ~isempty(RootFile_1)&&(isequal(RootFile_1(1),'/')||isequal(RootFile_1(1),'\'))
|
---|
| 3322 | RootFile_1(1)=[];
|
---|
| 3323 | end
|
---|
| 3324 |
|
---|
| 3325 | if isequal(field_1,'get_field...')
|
---|
[236] | 3326 | veltype_handles=[handles.VelType handles.interp1 handles.filter1 handles.civ2 handles.interp2 handles.filter2];
|
---|
[199] | 3327 | set_veltype_display(veltype_handles,0) % unvisible civ buttons
|
---|
| 3328 | filename=read_file_boxes_1(handles);
|
---|
| 3329 | hget_field=findobj(allchild(0),'name','get_field_1');
|
---|
| 3330 | if ~isempty(hget_field)
|
---|
| 3331 | delete(hget_field)
|
---|
| 3332 | end
|
---|
| 3333 | hget_field=get_field(filename);
|
---|
| 3334 | set(hget_field,'name','get_field_1')
|
---|
| 3335 | hhget_field=guidata(hget_field);
|
---|
| 3336 | set(hhget_field.list_fig,'Value',1)
|
---|
| 3337 | set(hhget_field.list_fig,'String',{'uvmat'})
|
---|
| 3338 | set(handles.transform_fct,'Value',1)% no transform by default
|
---|
| 3339 | set(handles.path_transform,'String','')
|
---|
| 3340 | return %no action
|
---|
| 3341 | end
|
---|
| 3342 | if isequal(field_1,'image')
|
---|
| 3343 | % transform netc type to the corresponding image type
|
---|
[227] | 3344 | if isequal(NomType_1,'_i1-i2_j')||isequal(NomType_1,'_i_j1-j2')|| isequal(NomType_1,'#_ab')|| isequal(NomType_1,'_i1-i2')
|
---|
[236] | 3345 | UvData.SubDir_1=get(handles.SubDir_1,'String'); %preserve the subdir in memory
|
---|
[227] | 3346 | if isequal(NomType_1,'_i1-i2_j')||isequal(NomType_1,'_i_j1-j2')
|
---|
[199] | 3347 | NomTypeNew='_i_j';
|
---|
| 3348 | elseif isequal(NomType_1,'#_ab')
|
---|
| 3349 | NomTypeNew='#a';
|
---|
| 3350 | elseif isequal(NomType_1,'_i1-i2')
|
---|
| 3351 | NomTypeNew='_i';
|
---|
| 3352 | end
|
---|
| 3353 | end
|
---|
| 3354 | imagename=name_generator(FileBase,str2double(str1),str2double(str_a),'.png',NomTypeNew,1,str2double(str2),str2double(str_b),'');
|
---|
| 3355 | if ~exist(imagename,'file')
|
---|
| 3356 | [FileName,PathName] = uigetfile( ...
|
---|
| 3357 | {'*.png;*.jpg;*.tif;*.avi;*.AVI;*.vol', ' (*.png, .tif, *.avi,*.vol)';
|
---|
| 3358 | '*.jpg',' jpeg image files'; ...
|
---|
| 3359 | '*.png','.png image files'; ...
|
---|
| 3360 | '*.tif','.tif image files'; ...
|
---|
| 3361 | '*.avi;*.AVI','.avi movie files'; ...
|
---|
| 3362 | '*.vol','.volume images (png)'; ...
|
---|
| 3363 | '*.*', 'All Files (*.*)'}, ...
|
---|
| 3364 | 'Pick an image',imagename);
|
---|
| 3365 | % display the selected field and related information
|
---|
| 3366 | imagename=[PathName FileName];
|
---|
| 3367 | end
|
---|
| 3368 | display_file_name_1(hObject, eventdata, handles,imagename)%display the image
|
---|
| 3369 | return
|
---|
| 3370 | else
|
---|
| 3371 | set(handles.SubDir_1,'Visible','on')
|
---|
[246] | 3372 | if ~isequal(FileExt_1,'.nc') %find the new NomType if the previous display was not already a netcdf file
|
---|
[236] | 3373 | % veltype_handles=[handles.VelType_1 handles.interp1_1 handles.filter1_1 handles.civ2_1 handles.interp2_1 handles.filter2_1];
|
---|
| 3374 | % set_veltype_display(veltype_handles,6); % make all civ buttons visible
|
---|
[199] | 3375 | RootPath_1=get(handles.RootPath_1,'String');
|
---|
| 3376 | RootFile_1=get(handles.RootFile_1,'String');
|
---|
[236] | 3377 | if isempty(RootPath_1)||isequal(RootPath_1,'')
|
---|
[199] | 3378 | set(handles.RootPath_1,'String','"')
|
---|
| 3379 | end
|
---|
[236] | 3380 | if isempty(RootFile_1) || isequal(RootFile_1,'')
|
---|
[199] | 3381 | set(handles.RootFile_1,'String','"')
|
---|
| 3382 | end
|
---|
[236] | 3383 | if ~isempty(RootFile_1)&&(isequal(RootFile_1(1),'/')||isequal(RootFile_1(1),'\'))
|
---|
[199] | 3384 | RootFile_1(1)=[];
|
---|
| 3385 | end
|
---|
| 3386 | filebase_1=fullfile(RootPath_1,RootFile_1);
|
---|
| 3387 | SubDir_1=get(handles.SubDir,'String');
|
---|
| 3388 | if isempty(SubDir_1)||isequal(SubDir_1,'')
|
---|
| 3389 | if isfield(UvData,'SubDir_1')
|
---|
| 3390 | SubDir_1=UvData.SubDir_1;%retrieve previous subdir
|
---|
| 3391 | else
|
---|
| 3392 | SubDir_1='?';
|
---|
| 3393 | end
|
---|
| 3394 | end
|
---|
| 3395 | str1=get(handles.i1,'String');
|
---|
| 3396 | str_a=get(handles.j1,'String');
|
---|
| 3397 | if isequal(NomType_1,'#_ab')||isequal(NomType_1,'_i1-i2_j')||isequal(NomType_1,'_i_j1-j2')||isequal(NomType_1,'_i1-i2')
|
---|
| 3398 | NomTypeNew=NomType_1;
|
---|
| 3399 | elseif isequal(NomType_1,'#a')
|
---|
| 3400 | [filename, n1,na,n2,nb,SubDir_1]=name_generator(filebase_1, str2num(str1),stra2num(str_a),'.nc','#_ab',0,[],[],SubDir_1);
|
---|
| 3401 | NomTypeNew='#_ab';
|
---|
| 3402 | elseif isequal(NomType_1,'_i_j')
|
---|
| 3403 | [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);
|
---|
| 3404 | if idetect==1
|
---|
| 3405 | NomTypeNew='_i1-i2_j';
|
---|
| 3406 | else
|
---|
| 3407 | NomTypeNew='_i_j1-j2';
|
---|
| 3408 | end
|
---|
| 3409 | else %for instance avi files or any ima_num series
|
---|
| 3410 | [filename,n1,na,n2,nb,SubDir_1]=name_generator(filebase_1,str2num(str1),stra2num(str_a),'.nc','_i1-i2',0,str2num(str1),[],SubDir_1);
|
---|
| 3411 | NomTypeNew='_i1-i2';
|
---|
| 3412 | end
|
---|
| 3413 | [Path,Name]=fileparts(filebase_1);
|
---|
| 3414 | set(handles.FileExt_1,'String','.nc');
|
---|
| 3415 | if ~isempty(SubDir_1) && ~strcmp(SubDir_1,'''')&& ~strcmp(SubDir_1,'"')&& ~strcmp(SubDir_1(1),'/')
|
---|
| 3416 | SubDir_1=['/' SubDir_1];
|
---|
| 3417 | end
|
---|
| 3418 | set(handles.SubDir_1,'String',SubDir_1);
|
---|
| 3419 | end
|
---|
[236] | 3420 | if isequal(field,'vort') || isequal(field,'div') || isequal(field,'strain')
|
---|
| 3421 | set(handles.VelType_1,'BackgroundColor',[0.702 0.702 0.702]) % put their color to grey
|
---|
[199] | 3422 | set(handles.civ2_1,'BackgroundColor',[0.702 0.702 0.702])
|
---|
| 3423 | set(handles.interp1_1,'BackgroundColor',[0.702 0.702 0.702])
|
---|
| 3424 | set(handles.interp2_1,'BackgroundColor',[0.702 0.702 0.702])
|
---|
| 3425 | elseif isequal(field_1,'more...'); %add new item to the menu
|
---|
[236] | 3426 | set(handles.VelType_1,'BackgroundColor',[0.702 0.702 0.702]) % put their color to grey
|
---|
[199] | 3427 | set(handles.civ2_1,'BackgroundColor',[0.702 0.702 0.702])
|
---|
| 3428 | str=calc_field;%get the list of available scalars by the function calc_scal
|
---|
| 3429 | [ind_answer,v] = listdlg('PromptString','Select a file:',...
|
---|
| 3430 | 'SelectionMode','single',...
|
---|
| 3431 | 'ListString',str);
|
---|
| 3432 | % edit the choice in the field and action menu
|
---|
| 3433 | scalar=cell2mat(str(ind_answer));
|
---|
| 3434 | menu=update_menu(handles.Fields_1,scalar);
|
---|
| 3435 | set(handles.Fields_1,'String',menu);% store the selected scalar type
|
---|
| 3436 | end
|
---|
| 3437 | end
|
---|
| 3438 | str1=get(handles.i1,'String');
|
---|
| 3439 | str2=get(handles.i2,'String');
|
---|
| 3440 | str_a=get(handles.j1,'String');
|
---|
| 3441 | str_b=get(handles.j2,'String');
|
---|
| 3442 | indices=name_generator('',str2num(str1),stra2num(str_a),'',NomTypeNew,1,str2num(str2),stra2num(str_b),'');
|
---|
| 3443 | set(handles.FileIndex_1,'String',indices)
|
---|
| 3444 | set(handles.FileIndex_1,'UserData',NomTypeNew)
|
---|
| 3445 |
|
---|
| 3446 | %common to Fields_Callback
|
---|
[236] | 3447 | if isequal(field,'image')||isequal(field_1,'image')
|
---|
[199] | 3448 | set(handles.npx_title,'Visible','on')% visible npx,pxcm... buttons
|
---|
| 3449 | set(handles.npy_title,'Visible','on')
|
---|
| 3450 | set(handles.npx,'Visible','on')
|
---|
| 3451 | set(handles.npy,'Visible','on')
|
---|
| 3452 | % set(handles.fix_pair,'Value',0)
|
---|
| 3453 | else
|
---|
| 3454 | set(handles.npx_title,'Visible','off')% visible npx,pxcm... buttons
|
---|
| 3455 | set(handles.npy_title,'Visible','off')
|
---|
| 3456 | set(handles.npx,'Visible','off')
|
---|
| 3457 | set(handles.npy,'Visible','off')
|
---|
| 3458 | % set(handles.fix_pair,'Value',1)
|
---|
| 3459 | end
|
---|
[236] | 3460 | if isequal(field,'velocity')||isequal(field_1,'velocity');
|
---|
[199] | 3461 | state_vect='on';
|
---|
| 3462 | else
|
---|
| 3463 | state_vect='off';
|
---|
| 3464 | end
|
---|
[236] | 3465 | if ~isequal(field,'velocity')||(~isequal(field_1,'velocity')&~isequal(field_1,''));
|
---|
[199] | 3466 | state_scal='on';
|
---|
| 3467 | else
|
---|
| 3468 | state_scal='off';
|
---|
| 3469 | end
|
---|
| 3470 | set(handles.uvmat,'UserData',UvData)
|
---|
| 3471 | setfield(handles);% update the field structure ('civ1'....)
|
---|
| 3472 | if ~(isfield(UvData,'NewSeries')&&isequal(UvData.NewSeries,1))
|
---|
| 3473 | run0_Callback(hObject, eventdata, handles)
|
---|
| 3474 | end
|
---|
| 3475 |
|
---|
| 3476 | %------------------------------------------------------------------------
|
---|
| 3477 | % --- set the visibility of relevant velocity type menus:
|
---|
[236] | 3478 | function menu=set_veltype_display(Civ)
|
---|
[199] | 3479 | %------------------------------------------------------------------------
|
---|
| 3480 | if isequal(Civ,0)
|
---|
| 3481 | imax=0;
|
---|
| 3482 | elseif isequal(Civ,1) || isequal(Civ,2)
|
---|
| 3483 | imax=1;
|
---|
| 3484 | elseif isequal(Civ,3)
|
---|
| 3485 | imax=3;
|
---|
| 3486 | elseif isequal(Civ,4) || isequal(Civ,5)
|
---|
| 3487 | imax=4;
|
---|
| 3488 | elseif isequal(Civ,6) %patch2
|
---|
| 3489 | imax=6;
|
---|
| 3490 | end
|
---|
[236] | 3491 | menu={'civ1';'interp1';'filter1';'civ2';'interp2';'filter2'};
|
---|
| 3492 | menu=menu(1:imax);
|
---|
| 3493 | % for ibutton=1:imax;
|
---|
| 3494 | % set(handles(ibutton),'Visible','on') % unvisible civ buttons
|
---|
| 3495 | % end
|
---|
| 3496 | % % for ibutton=max(imax+1,2):6;
|
---|
| 3497 | % for ibutton=imax+1:6;
|
---|
| 3498 | % set(handles(ibutton),'Visible','off') % unvisible civ buttons
|
---|
| 3499 | % set(handles(ibutton),'Value',0)%unactivate unvisible buttons
|
---|
| 3500 | % end
|
---|
[199] | 3501 |
|
---|
| 3502 | %-------------------------------------------------------------------
|
---|
[236] | 3503 | % --- Executes on button press in VelType.
|
---|
| 3504 | function VelType_Callback(hObject, eventdata, handles)
|
---|
[199] | 3505 | %-------------------------------------------------------------------
|
---|
[236] | 3506 | % if get(handles.VelType,'Value')==1
|
---|
| 3507 | % reset_vel_type([handles.interp1 handles.civ2 handles.filter1 handles.interp1 handles.interp2 handles.filter2],handles.VelType)
|
---|
| 3508 | % else
|
---|
| 3509 | % reset_vel_type([handles.VelType handles.filter1 handles.interp1 handles.civ2 handles.interp2 handles.filter2])
|
---|
| 3510 | % end
|
---|
| 3511 | set(handles.FixVelType,'Value',1)
|
---|
[199] | 3512 | run0_Callback(hObject, eventdata, handles)
|
---|
| 3513 |
|
---|
| 3514 | %---------------------------------------------
|
---|
[236] | 3515 | function VelType_1_Callback(hObject, eventdata, handles)
|
---|
[199] | 3516 | %---------------------------------------------
|
---|
[236] | 3517 |
|
---|
[246] | 3518 | set(handles.FixVelType,'Value',1)% the velocity type is now imposed by the GUI (not automatic)
|
---|
[236] | 3519 | %refresh field with a second filename=first fiel name
|
---|
| 3520 | set(handles.run0,'BackgroundColor',[1 1 0])%paint the command button in yellow
|
---|
[246] | 3521 | drawnow
|
---|
[236] | 3522 | filename=read_file_boxes(handles);
|
---|
[246] | 3523 |
|
---|
| 3524 | index=get(handles.VelType_1,'Value');
|
---|
| 3525 | if index==1
|
---|
| 3526 | filename_1='';% we plot the current field without the second field
|
---|
| 3527 | set(handles.SubField,'Value',0)
|
---|
| 3528 | SubField_Callback(hObject, eventdata, handles)
|
---|
| 3529 | elseif get(handles.SubField,'Value')% if subfield is already 'on'
|
---|
| 3530 | filename_1=read_file_boxes_1(handles); %read the current second field
|
---|
[199] | 3531 | else
|
---|
[246] | 3532 | filename_1=filename;% we compare two fields in the same file
|
---|
| 3533 | set(handles.SubField,'Value',1)
|
---|
[199] | 3534 | end
|
---|
[246] | 3535 |
|
---|
[236] | 3536 | num_i1=stra2num(get(handles.i1,'String'));
|
---|
| 3537 | num_i2=stra2num(get(handles.i2,'String'));
|
---|
| 3538 | num_j1=stra2num(get(handles.j1,'String'));
|
---|
| 3539 | num_j2=stra2num(get(handles.j2,'String'));
|
---|
[199] | 3540 |
|
---|
[236] | 3541 | errormsg=refresh_field(handles,filename,filename_1,num_i1,num_i2,num_j1,num_j2);
|
---|
[199] | 3542 |
|
---|
[236] | 3543 | if ~isempty(errormsg)
|
---|
| 3544 | msgbox_uvmat('ERROR',errormsg);
|
---|
[199] | 3545 | else
|
---|
[236] | 3546 | set(handles.i1,'BackgroundColor',[1 1 1])
|
---|
| 3547 | set(handles.i2,'BackgroundColor',[1 1 1])
|
---|
| 3548 | set(handles.j1,'BackgroundColor',[1 1 1])
|
---|
| 3549 | set(handles.j2,'BackgroundColor',[1 1 1])
|
---|
| 3550 | set(handles.FileIndex,'BackgroundColor',[1 1 1])
|
---|
| 3551 | set(handles.FileIndex_1,'BackgroundColor',[1 1 1])
|
---|
[199] | 3552 | end
|
---|
[236] | 3553 | set(handles.run0,'BackgroundColor',[1 0 0])
|
---|
[199] | 3554 |
|
---|
| 3555 | %-----------------------------------------------
|
---|
| 3556 | % --- reset civ buttons
|
---|
| 3557 | function reset_vel_type(handles_civ0,handle1)
|
---|
| 3558 | for ibutton=1:length(handles_civ0)
|
---|
| 3559 | set(handles_civ0(ibutton),'BackgroundColor',[0.831 0.816 0.784])
|
---|
| 3560 | set(handles_civ0(ibutton),'Value',0)
|
---|
| 3561 | end
|
---|
| 3562 | if exist('handle1','var')%handles of selected button
|
---|
| 3563 | set(handle1,'BackgroundColor',[1 1 0])
|
---|
| 3564 | end
|
---|
| 3565 |
|
---|
| 3566 | %-------------------------------------------------------
|
---|
| 3567 | % --- Executes on button press in MENUVOLUME.
|
---|
| 3568 | %-------------------------------------------------------
|
---|
| 3569 | function VOLUME_Callback(hObject, eventdata, handles)
|
---|
| 3570 | %errordlg('command VOL not implemented yet')
|
---|
| 3571 | if ishandle(handles.UVMAT_title)
|
---|
| 3572 | delete(handles.UVMAT_title)
|
---|
| 3573 | end
|
---|
| 3574 | UvData=get(handles.uvmat,'UserData');%read UvData properties stored on the uvmat interface
|
---|
| 3575 | if isequal(get(handles.VOLUME,'Value'),1)
|
---|
| 3576 | set(handles.zoom,'Value',0)
|
---|
| 3577 | set(handles.zoom,'BackgroundColor',[0.7 0.7 0.7])
|
---|
| 3578 | set(handles.edit_vect,'Value',0)
|
---|
| 3579 | edit_vect_Callback(hObject, eventdata, handles)
|
---|
| 3580 | set(handles.edit_object,'Value',0)
|
---|
| 3581 | set(handles.edit_object,'BackgroundColor',[0.7 0.7 0.7])
|
---|
| 3582 | % set(handles.cal,'Value',0)
|
---|
| 3583 | % set(handles.cal,'BackgroundColor',[0 1 0])
|
---|
| 3584 | set(handles.edit_vect,'Value',0)
|
---|
| 3585 | edit_vect_Callback(hObject, eventdata, handles)
|
---|
| 3586 | %initiate set_object GUI
|
---|
| 3587 | data.TITLE='VOLUME';
|
---|
| 3588 | if isfield(UvData,'CoordType')
|
---|
| 3589 | data.CoordType=UvData.CoordType;
|
---|
| 3590 | end
|
---|
| 3591 | if isfield(UvData,'Mesh')&~isempty(UvData.Mesh)
|
---|
| 3592 | data.RangeY=UvData.Mesh;
|
---|
| 3593 | data.RangeX=UvData.Mesh;
|
---|
| 3594 | data.DX=UvData.Mesh;
|
---|
| 3595 | data.DY=UvData.Mesh;
|
---|
| 3596 | elseif isfield(UvData.Field,'AX')&isfield(UvData.Field,'AY')& isfield(UvData.Field,'A')%only image
|
---|
| 3597 | np=size(UvData.Field.A);
|
---|
| 3598 | meshx=(UvData.Field.AX(end)-UvData.Field.AX(1))/np(2);
|
---|
| 3599 | meshy=abs(UvData.Field.AY(end)-UvData.Field.AY(1))/np(1);
|
---|
| 3600 | data.RangeY=max(meshx,meshy);
|
---|
| 3601 | data.RangeX=max(meshx,meshy);
|
---|
| 3602 | data.DX=max(meshx,meshy);
|
---|
| 3603 | end
|
---|
| 3604 | data.ParentButton=handles.VOLUME;
|
---|
| 3605 | PlotHandles=get_plot_handles(handles);%get the handles of the interface elements setting the plotting parameters
|
---|
| 3606 | [hset_object,UvData.sethandles]=set_object(data,PlotHandles);% call the set_object interface with action on haxes,
|
---|
| 3607 | % associate the set_object interface handle to the plotting axes
|
---|
| 3608 | if isfield(UvData.OpenParam,'SetObjectOrigin')
|
---|
| 3609 | pos_uvmat=get(huvmat,'Position');
|
---|
| 3610 | pos_set_object(1:2)=UvData.OpenParam.SetObjectOrigin + pos_uvmat(1:2);
|
---|
| 3611 | pos_set_object(3:4)=UvData.OpenParam.SetObjectSize .* pos_uvmat(3:4);
|
---|
| 3612 | set(hset_object,'Position',pos_set_object)
|
---|
| 3613 | end
|
---|
| 3614 | UvData.MouseAction='create_object';
|
---|
| 3615 | else
|
---|
| 3616 | set(handles.VOLUME,'BackgroundColor',[0 1 0])
|
---|
| 3617 | UvData.MouseAction='none';
|
---|
| 3618 | end
|
---|
| 3619 | set(huvmat,'UserData',UvData)
|
---|
| 3620 |
|
---|
| 3621 | %-------------------------------------------------------
|
---|
| 3622 | function edit_vect_Callback(hObject, eventdata, handles)
|
---|
| 3623 | %-------------------------------------------------------
|
---|
| 3624 | %
|
---|
| 3625 | % UvData=get(handles.uvmat,'UserData');%read UvData properties stored on the uvmat interface
|
---|
| 3626 | if isequal(get(handles.edit_vect,'Value'),1)
|
---|
| 3627 | test_civ2=isequal(get(handles.civ2,'BackgroundColor'),[1 1 0]);
|
---|
[236] | 3628 | test_civ1=isequal(get(handles.VelType,'BackgroundColor'),[1 1 0]);
|
---|
[199] | 3629 | if ~test_civ2 && ~test_civ1
|
---|
| 3630 | msgbox_uvmat('ERROR','manual correction only possible for CIV1 or CIV2 velocity fields')
|
---|
| 3631 | end
|
---|
| 3632 | set(handles.record,'Visible','on')
|
---|
| 3633 | set(handles.edit_vect,'BackgroundColor',[1 1 0])
|
---|
| 3634 | set(handles.edit_object,'Value',0)
|
---|
| 3635 | set(handles.zoom,'Value',0)
|
---|
| 3636 | set(handles.zoom,'BackgroundColor',[0.7 0.7 0.7])
|
---|
| 3637 | % set(handles.create,'Value',0)
|
---|
| 3638 | % set(handles.create,'BackgroundColor',[0 1 0])
|
---|
| 3639 | set(handles.edit_object,'BackgroundColor',[0.7 0.7 0.7])
|
---|
| 3640 | set(gcf,'Pointer','arrow')
|
---|
| 3641 | % UvData.MouseAction='edit_vect';
|
---|
| 3642 | else
|
---|
| 3643 | set(handles.record,'Visible','off')
|
---|
| 3644 | set(handles.edit_vect,'BackgroundColor',[0.7 0.7 0.7])
|
---|
| 3645 | % UvData.MouseAction='none';
|
---|
| 3646 | end
|
---|
| 3647 | % set(handles.uvmat,'UserData',UvData)
|
---|
| 3648 |
|
---|
| 3649 | %----------------------------------------------
|
---|
| 3650 | function save_mask_Callback(hObject, eventdata, handles)
|
---|
| 3651 | %-----------------------------------------------------------------------
|
---|
| 3652 | UvData=get(handles.uvmat,'UserData');
|
---|
| 3653 |
|
---|
| 3654 | flag=1;
|
---|
| 3655 | npx=size(UvData.Field.A,2);
|
---|
| 3656 | npy=size(UvData.Field.A,1);
|
---|
| 3657 | xi=0.5:npx-0.5;
|
---|
| 3658 | yi=0.5:npy-0.5;
|
---|
| 3659 | [Xi,Yi]=meshgrid(xi,yi);
|
---|
| 3660 | if isfield(UvData,'Object')
|
---|
| 3661 | for iobj=1:length(UvData.Object)
|
---|
| 3662 | ObjectData=UvData.Object{iobj};
|
---|
| 3663 | if isfield(ObjectData,'ProjMode') &&(isequal(ObjectData.ProjMode,'mask_inside')||isequal(ObjectData.ProjMode,'mask_outside'));
|
---|
| 3664 | flagobj=1;
|
---|
| 3665 | testphys=0; %coordinates in pixels by default
|
---|
| 3666 | if isfield(ObjectData,'CoordType') && isequal(ObjectData.CoordType,'phys')
|
---|
| 3667 | if isfield(UvData,'XmlData')&& isfield(UvData.XmlData,'GeometryCalib')
|
---|
| 3668 | Calib=UvData.XmlData.GeometryCalib;
|
---|
| 3669 | testphys=1;
|
---|
| 3670 | end
|
---|
| 3671 | end
|
---|
| 3672 | if isfield(ObjectData,'Coord')& isfield(ObjectData,'Style')
|
---|
| 3673 | if isequal(ObjectData.Style,'polygon')
|
---|
| 3674 | X=ObjectData.Coord(:,1);
|
---|
| 3675 | Y=ObjectData.Coord(:,2);
|
---|
| 3676 | if testphys
|
---|
| 3677 | [X,Y]=px_XYZ(Calib,X,Y,0);% to generalise with 3D cases
|
---|
| 3678 | end
|
---|
| 3679 | flagobj=~inpolygon(Xi,Yi,X',Y');%=0 inside the polygon, 1 outside
|
---|
| 3680 | elseif isequal(ObjectData.Style,'ellipse')
|
---|
| 3681 | if testphys
|
---|
| 3682 | %[X,Y]=px_XYZ(Calib,X,Y,0);% TODO:create a polygon boundary and transform to phys
|
---|
| 3683 | end
|
---|
| 3684 | RangeX=max(ObjectData.RangeX);
|
---|
| 3685 | RangeY=max(ObjectData.RangeY);
|
---|
| 3686 | X2Max=RangeX*RangeX;
|
---|
| 3687 | Y2Max=RangeY*RangeY;
|
---|
| 3688 | distX=(Xi-ObjectData.Coord(1,1));
|
---|
| 3689 | distY=(Yi-ObjectData.Coord(1,2));
|
---|
| 3690 | flagobj=(distX.*distX/X2Max+distY.*distY/Y2Max)>1;
|
---|
| 3691 | elseif isequal(ObjectData.Style,'rectangle')
|
---|
| 3692 | if testphys
|
---|
| 3693 | %[X,Y]=px_XYZ(Calib,X,Y,0);% TODO:create a polygon boundary and transform to phys
|
---|
| 3694 | end
|
---|
| 3695 | distX=abs(Xi-ObjectData.Coord(1,1));
|
---|
| 3696 | distY=abs(Yi-ObjectData.Coord(1,2));
|
---|
| 3697 | flagobj=distX>max(ObjectData.RangeX) | distY>max(ObjectData.RangeY);
|
---|
| 3698 | end
|
---|
| 3699 | if isequal(ObjectData.ProjMode,'mask_outside')
|
---|
| 3700 | flagobj=~flagobj;
|
---|
| 3701 | end
|
---|
| 3702 | flag=flag & flagobj;
|
---|
| 3703 | end
|
---|
| 3704 | end
|
---|
| 3705 | end
|
---|
| 3706 | end
|
---|
| 3707 | % flag=~flag;
|
---|
| 3708 | %mask name
|
---|
| 3709 | RootPath=get(handles.RootPath,'String');
|
---|
| 3710 | RootFile=get(handles.RootFile,'String');
|
---|
| 3711 | if ~isempty(RootFile)&&(isequal(RootFile(1),'/')|| isequal(RootFile(1),'\'))
|
---|
| 3712 | RootFile(1)=[];
|
---|
| 3713 | end
|
---|
| 3714 | filebase=fullfile(RootPath,RootFile);
|
---|
| 3715 | list=get(handles.masklevel,'String');
|
---|
| 3716 | masknumber=num2str(length(list));
|
---|
| 3717 | maskindex=get(handles.masklevel,'Value');
|
---|
| 3718 | mask_name=name_generator([filebase '_' masknumber 'mask'],maskindex,1,'.png','_i');
|
---|
| 3719 | imflag=uint8(255*(0.392+0.608*flag));% =100 for flag=0 (vectors not computed when 20<imflag<200)
|
---|
| 3720 | imflag=flipdim(imflag,1);
|
---|
| 3721 | % imflag=uint8(255*flag);% =0 for flag=0 (vectors=0 when 20<imflag<200)
|
---|
| 3722 | msgbox_uvmat('CONFIRMATION',[mask_name ' saved'])
|
---|
| 3723 | imwrite(imflag,mask_name,'BitDepth',8);
|
---|
| 3724 |
|
---|
| 3725 | %display the mask
|
---|
| 3726 | %update_mask(handles,num_i1,num_j1)
|
---|
| 3727 | figure;
|
---|
| 3728 | vec=linspace(0,1,256);%define a linear greyscale colormap
|
---|
| 3729 | map=[vec' vec' vec'];
|
---|
| 3730 | colormap(map)
|
---|
| 3731 |
|
---|
| 3732 | image(imflag);
|
---|
| 3733 |
|
---|
| 3734 | %-------------------------------------------------------------------
|
---|
| 3735 | %-------------------------------------------------------------------
|
---|
| 3736 | % - FUNCTIONS FOR SETTING PLOTTING PARAMETERS
|
---|
| 3737 |
|
---|
| 3738 | %------------------------------------------------------------------
|
---|
| 3739 |
|
---|
| 3740 |
|
---|
| 3741 |
|
---|
| 3742 | %------------------------------------------------------------------
|
---|
| 3743 | % --- Executes on selection change in col_vec: choice of the color code.
|
---|
| 3744 | %
|
---|
| 3745 | function col_vec_Callback(hObject, eventdata, handles)
|
---|
| 3746 | %------------------------------------------------------------------
|
---|
| 3747 | % edit the choice for color code
|
---|
| 3748 | list_code=get(handles.col_vec,'String');% list menu fields
|
---|
| 3749 | index_code=get(handles.col_vec,'Value');% selected string index
|
---|
| 3750 | col_code= list_code{index_code(1)}; % selected field
|
---|
| 3751 | if isequal(col_code,'black') || isequal(col_code,'white')
|
---|
| 3752 | set(handles.slider1,'Visible','off')
|
---|
| 3753 | set(handles.slider2,'Visible','off')
|
---|
| 3754 | set(handles.colcode1,'Visible','off')
|
---|
| 3755 | set(handles.colcode2,'Visible','off')
|
---|
| 3756 | set(handles.AutoVecColor,'Visible','off')
|
---|
| 3757 | set_vec_col_bar(handles)
|
---|
| 3758 | else
|
---|
| 3759 | set(handles.slider1,'Visible','on')
|
---|
| 3760 | set(handles.slider2,'Visible','on')
|
---|
| 3761 | set(handles.colcode1,'Visible','on')
|
---|
| 3762 | set(handles.colcode2,'Visible','on')
|
---|
| 3763 | set(handles.AutoVecColor,'Visible','on')
|
---|
| 3764 | if isequal(col_code,'ima_cor')
|
---|
| 3765 | set(handles.AutoVecColor,'Value',0)%fixed scale by default
|
---|
| 3766 | set(handles.vec_col_bar,'Value',0)% 3 colors r,g,b by default
|
---|
| 3767 | set(handles.slider1,'Min',0);
|
---|
| 3768 | set(handles.slider1,'Max',1);
|
---|
| 3769 | set(handles.slider2,'Min',0);
|
---|
| 3770 | set(handles.slider2,'Max',1);
|
---|
| 3771 | % set(handles.min_title_vec,'String','0')
|
---|
| 3772 | set(handles.max_vec,'String','1')
|
---|
| 3773 | set(handles.colcode1,'String','0.333')
|
---|
| 3774 | colcode1_Callback(hObject, eventdata, handles)
|
---|
| 3775 | set(handles.colcode2,'String','0.666')
|
---|
| 3776 | colcode2_Callback(hObject, eventdata, handles)
|
---|
| 3777 | else
|
---|
| 3778 | set(handles.AutoVecColor,'Value',1)%auto scale between min,max by default
|
---|
| 3779 | set(handles.vec_col_bar,'Value',1)% colormap 'jet' by default
|
---|
| 3780 | minval=get(handles.slider1,'Min');
|
---|
| 3781 | maxval=get(handles.slider1,'Max');
|
---|
| 3782 | set(handles.slider1,'Value',minval)
|
---|
| 3783 | set(handles.slider2,'Value',maxval)
|
---|
| 3784 | set_vec_col_bar(handles)
|
---|
| 3785 | end
|
---|
| 3786 | % slider_update(handles)
|
---|
| 3787 | end
|
---|
| 3788 | %replot the current graph
|
---|
| 3789 | run0_Callback(hObject, eventdata, handles)
|
---|
| 3790 |
|
---|
| 3791 |
|
---|
| 3792 | %----------------------------------------------------------------
|
---|
| 3793 | % -- Executes on slider movement to set the color code
|
---|
| 3794 | %
|
---|
| 3795 | function slider1_Callback(hObject, eventdata, handles)
|
---|
| 3796 | %------------------------------------------------------------------
|
---|
| 3797 | slider1=get(handles.slider1,'Value');
|
---|
| 3798 | min_val=str2num(get(handles.min_vec,'String'));
|
---|
| 3799 | max_val=str2num(get(handles.max_vec,'String'));
|
---|
| 3800 | col=min_val+(max_val-min_val)*slider1;
|
---|
| 3801 | set(handles.colcode1,'String',num2str(col))
|
---|
| 3802 | if(get(handles.slider2,'Value') < col)%move also the second slider at the same value if needed
|
---|
| 3803 | set(handles.slider2,'Value',col)
|
---|
| 3804 | set(handles.colcode2,'String',num2str(col))
|
---|
| 3805 | end
|
---|
| 3806 | colcode1_Callback(hObject, eventdata, handles)
|
---|
| 3807 |
|
---|
| 3808 | %----------------------------------------------------------------
|
---|
| 3809 | % Executes on slider movement to set the color code
|
---|
| 3810 | %----------------------------------------------------------------
|
---|
| 3811 | function slider2_Callback(hObject, eventdata, handles)
|
---|
| 3812 | slider2=get(handles.slider2,'Value');
|
---|
| 3813 | min_val=str2num(get(handles.min_vec,'String'));
|
---|
| 3814 | max_val=str2num(get(handles.max_vec,'String'));
|
---|
| 3815 | col=min_val+(max_val-min_val)*slider2;
|
---|
| 3816 | set(handles.colcode2,'String',num2str(col))
|
---|
| 3817 | if(get(handles.slider1,'Value') > col)%move also the first slider at the same value if needed
|
---|
| 3818 | set(handles.slider1,'Value',col)
|
---|
| 3819 | set(handles.colcode1,'String',num2str(col))
|
---|
| 3820 | end
|
---|
| 3821 | colcode2_Callback(hObject, eventdata, handles)
|
---|
| 3822 |
|
---|
| 3823 | %----------------------------------------------------------------
|
---|
| 3824 | %execute on return carriage on the edit box corresponding to slider 1
|
---|
| 3825 | %----------------------------------------------------------------
|
---|
| 3826 | function colcode1_Callback(hObject, eventdata, handles)
|
---|
| 3827 | % col=str2num(get(handles.colcode1,'String'));
|
---|
| 3828 | % set(handles.slider1,'Value',col)
|
---|
| 3829 | set_vec_col_bar(handles)
|
---|
| 3830 | update_plot(handles);
|
---|
| 3831 |
|
---|
| 3832 | %----------------------------------------------------------------
|
---|
| 3833 | %execute on return carriage on the edit box corresponding to slider 2
|
---|
| 3834 | %----------------------------------------------------------------
|
---|
| 3835 | function colcode2_Callback(hObject, eventdata, handles)
|
---|
| 3836 | % col=str2num(get(handles.colcode2,'String'));
|
---|
| 3837 | % set(handles.slider2,'Value',col)
|
---|
| 3838 | % slider2_Callback(hObject, eventdata, handles)
|
---|
| 3839 | set_vec_col_bar(handles)
|
---|
| 3840 | update_plot(handles);
|
---|
| 3841 | %------------------------------------------------------------
|
---|
| 3842 | %update the slider values after displaying vectors
|
---|
| 3843 | %--------------------------------------------------------
|
---|
| 3844 | % function slider_update(handles,auto,minC,colcode1,colcode2,maxC)
|
---|
| 3845 | % set(handles.slider1,'Min',minC)
|
---|
| 3846 | % set(handles.slider1,'Max',maxC)
|
---|
| 3847 | % set(handles.slider2,'Min',minC)
|
---|
| 3848 | % set(handles.slider2,'Max',maxC)
|
---|
| 3849 | % set(handles.min_title_vec,'String',num2str(minC))
|
---|
| 3850 | % set(handles.max_vec,'String',num2str(maxC))
|
---|
| 3851 | % if auto
|
---|
| 3852 | % set(handles.colcode1,'String',num2str(colcode1,3))%update display
|
---|
| 3853 | % set(handles.colcode2,'String',num2str(colcode2,3))
|
---|
| 3854 | % end
|
---|
| 3855 | % set(handles.slider1,'Value',colcode1)%update slider with constant display
|
---|
| 3856 | % set(handles.slider2,'Value',colcode2)
|
---|
| 3857 | % set_vec_col_bar(handles)
|
---|
| 3858 |
|
---|
| 3859 |
|
---|
| 3860 | %-------------------------------------------------------
|
---|
| 3861 | % --- Executes on button press in AutoVecColor.
|
---|
| 3862 | %-------------------------------------------------------
|
---|
| 3863 | function vec_col_bar_Callback(hObject, eventdata, handles)
|
---|
| 3864 | set_vec_col_bar(handles)
|
---|
| 3865 |
|
---|
| 3866 | %-------------------------------------------------------------
|
---|
| 3867 | % --- Executes on selection change in transform_fct.
|
---|
| 3868 | function transform_fct_Callback(hObject, eventdata, handles)
|
---|
| 3869 | %-------------------------------------------------------------
|
---|
| 3870 |
|
---|
| 3871 | UvData=get(handles.uvmat,'UserData');
|
---|
| 3872 | menu=get(handles.transform_fct,'String');
|
---|
| 3873 | ind_coord=get(handles.transform_fct,'Value');
|
---|
| 3874 | coord_option=menu{ind_coord};
|
---|
| 3875 | list_transform=get(handles.transform_fct,'UserData');
|
---|
| 3876 | ff=functions(list_transform{end});
|
---|
| 3877 | if isequal(coord_option,'more...');
|
---|
| 3878 | coord_fct='';
|
---|
| 3879 | prompt = {'Enter the name of the transform function'};
|
---|
| 3880 | dlg_title = 'user defined transform';
|
---|
| 3881 | num_lines= 1;
|
---|
| 3882 | [FileName, PathName] = uigetfile( ...
|
---|
| 3883 | {'*.m', ' (*.m)';
|
---|
| 3884 | '*.m', '.m files '; ...
|
---|
| 3885 | '*.*', 'All Files (*.*)'}, ...
|
---|
| 3886 | 'Pick a file', ff.file);
|
---|
| 3887 | if isequal(PathName(end),'/')||isequal(PathName(end),'\')
|
---|
| 3888 | PathName(end)=[];
|
---|
| 3889 | end
|
---|
| 3890 | transform_selected =fullfile(PathName,FileName);
|
---|
| 3891 | if ~exist(transform_selected,'file')
|
---|
| 3892 | return
|
---|
| 3893 | end
|
---|
| 3894 | [ppp,transform,ext_fct]=fileparts(FileName);% removes extension .m
|
---|
| 3895 | if ~isequal(ext_fct,'.m')
|
---|
| 3896 | msgbox_uvmat('ERROR','a Matlab function .m must be introduced');
|
---|
| 3897 | return
|
---|
| 3898 | end
|
---|
| 3899 | menu=update_menu(handles.transform_fct,transform);%add the selected fct to the menu
|
---|
| 3900 | ind_coord=get(handles.transform_fct,'Value');
|
---|
| 3901 | addpath(PathName)
|
---|
| 3902 | list_transform{ind_coord}=str2func(transform);% create the function handle corresponding to the newly seleced function
|
---|
| 3903 | set(handles.transform_fct,'UserData',list_transform)
|
---|
| 3904 | rmpath(PathName)
|
---|
| 3905 | % save the new menu in the personal file 'uvmat_perso.mat'
|
---|
| 3906 | dir_perso=prefdir;%personal Matalb directory
|
---|
| 3907 | profil_perso=fullfile(dir_perso,'uvmat_perso.mat');
|
---|
| 3908 | if exist(profil_perso,'file')
|
---|
| 3909 | nb_builtin=UvData.OpenParam.NbBuiltin;
|
---|
| 3910 | for ilist=nb_builtin+1:numel(list_transform)
|
---|
| 3911 | ff=functions(list_transform{ilist});
|
---|
| 3912 | transform_fct{ilist-nb_builtin}=ff.file;
|
---|
| 3913 | end
|
---|
| 3914 | save (profil_perso,'transform_fct','-append'); %store the root name for future opening of uvmat
|
---|
| 3915 | end
|
---|
| 3916 | end
|
---|
| 3917 |
|
---|
| 3918 | %check the current path to the selected function
|
---|
| 3919 | if isa(list_transform{ind_coord},'function_handle')
|
---|
| 3920 | func=functions(list_transform{ind_coord});
|
---|
| 3921 | set(handles.path_transform,'String',fileparts(func.file)); %show the path to the senlected function
|
---|
| 3922 | else
|
---|
| 3923 | set(handles.path_transform,'String','')
|
---|
| 3924 | end
|
---|
| 3925 |
|
---|
| 3926 | set(handles.FixLimits,'Value',0)
|
---|
| 3927 | set(handles.FixLimits,'BackgroundColor',[0.7 0.7 0.7])
|
---|
| 3928 |
|
---|
| 3929 | %delete drawn objects
|
---|
| 3930 | hother=findobj('Tag','proj_object');%find all the proj objects
|
---|
| 3931 | for iobj=1:length(hother)
|
---|
| 3932 | delete_object(hother(iobj))
|
---|
| 3933 | end
|
---|
| 3934 | hother=findobj('Tag','DeformPoint');%find all the proj objects
|
---|
| 3935 | for iobj=1:length(hother)
|
---|
| 3936 | delete_object(hother(iobj))
|
---|
| 3937 | end
|
---|
| 3938 | hh=findobj('Tag','calib_points');
|
---|
| 3939 | if ~isempty(hh)
|
---|
| 3940 | delete(hh)
|
---|
| 3941 | end
|
---|
| 3942 | hhh=findobj('Tag','calib_marker');
|
---|
| 3943 | if ~isempty(hhh)
|
---|
| 3944 | delete(hhh)
|
---|
| 3945 | end
|
---|
| 3946 | if isfield(UvData,'Object')
|
---|
| 3947 | UvData.Object=UvData.Object(1);
|
---|
| 3948 | end
|
---|
| 3949 | list_object=get(handles.list_object_1,'String');
|
---|
| 3950 | set(handles.list_object_1,'Value',1)
|
---|
[231] | 3951 | set(handles.list_object_1,'String',{''})
|
---|
[238] | 3952 | set(handles.list_object_2,'Value',1)
|
---|
[231] | 3953 | set(handles.list_object_2,'String',{''})
|
---|
[199] | 3954 | list_object_2_Callback(hObject, eventdata, handles)
|
---|
| 3955 |
|
---|
| 3956 | %delete mask if it is displayed
|
---|
| 3957 | if isequal(get(handles.mask_test,'Value'),1)%if the mask option is on
|
---|
| 3958 | UvData=rmfield(UvData,'MaskName'); %will impose mask refresh
|
---|
| 3959 | end
|
---|
| 3960 | set(handles.uvmat,'UserData',UvData)
|
---|
| 3961 | run0_Callback(hObject, eventdata, handles)
|
---|
| 3962 |
|
---|
| 3963 | %--------------------------------------------
|
---|
| 3964 | function histo1_menu_Callback(hObject, eventdata, handles)
|
---|
| 3965 | %--------------------------------------------
|
---|
| 3966 | %plot first histo
|
---|
| 3967 | huvmat=get(handles.histo1_menu,'parent');
|
---|
| 3968 | histo_menu=get(handles.histo1_menu,'String');
|
---|
| 3969 | histo_value=get(handles.histo1_menu,'Value');
|
---|
| 3970 | FieldName=histo_menu{histo_value};
|
---|
| 3971 | update_histo(handles.histo_u,huvmat,FieldName)
|
---|
| 3972 |
|
---|
| 3973 | %----------------------------------------------
|
---|
| 3974 | function histo2_menu_Callback(hObject, eventdata, handles)
|
---|
| 3975 | %----------------------------------------------
|
---|
| 3976 | %plot second histo
|
---|
| 3977 | huvmat=get(handles.histo2_menu,'parent');
|
---|
| 3978 | histo_menu=get(handles.histo2_menu,'String');
|
---|
| 3979 | histo_value=get(handles.histo2_menu,'Value');
|
---|
| 3980 | FieldName=histo_menu{histo_value};
|
---|
| 3981 | update_histo(handles.histo_v,huvmat,FieldName)
|
---|
| 3982 |
|
---|
| 3983 |
|
---|
| 3984 | %--------------------------------------------
|
---|
| 3985 | %read the field .Fieldname stored in UvData and plot its histogram
|
---|
| 3986 | function update_histo(haxes,huvmat,FieldName)
|
---|
| 3987 | UvData=get(huvmat,'UserData');
|
---|
| 3988 | if ~isfield(UvData.Field,FieldName)
|
---|
| 3989 | msgbox_uvmat('ERROR',['no field ' FieldName ' for histogram'])
|
---|
| 3990 | return
|
---|
| 3991 | end
|
---|
| 3992 | Field=UvData.Field;
|
---|
| 3993 | FieldHisto=eval(['Field.' FieldName]);
|
---|
| 3994 | if isfield(Field,'FF') && ~isempty(Field.FF) && isequal(size(Field.FF),size(FieldHisto))
|
---|
| 3995 | indsel=find(Field.FF==0);%find values marked as false
|
---|
| 3996 | if ~isempty(indsel)
|
---|
| 3997 | FieldHisto=FieldHisto(indsel);
|
---|
| 3998 | end
|
---|
| 3999 | end
|
---|
| 4000 | if isempty(Field)
|
---|
| 4001 | msgbox_uvmat('ERROR',['empty field ' FieldName])
|
---|
| 4002 | else
|
---|
| 4003 | nxy=size(FieldHisto);
|
---|
| 4004 | Amin=double(min(min(min(FieldHisto))));%min of image
|
---|
| 4005 | Amax=double(max(max(max(FieldHisto))));%max of image
|
---|
| 4006 | if isequal(Amin,Amax)
|
---|
| 4007 | msgbox_uvmat('WARNING',['uniform field =' num2str(Amin)]);
|
---|
| 4008 | else
|
---|
| 4009 | Histo.ListVarName={FieldName,'histo'};
|
---|
[258] | 4010 | if isfield(Field,'NbDim') && isequal(Field.NbDim,3)
|
---|
[199] | 4011 | Histo.VarDimName={FieldName,FieldName}; %dimensions for the histogram
|
---|
| 4012 | else
|
---|
| 4013 | if numel(nxy)==2
|
---|
| 4014 | Histo.VarDimName={FieldName,FieldName}; %dimensions for the histogram
|
---|
| 4015 | else
|
---|
| 4016 | Histo.VarDimName={FieldName,{FieldName,'rgb'}}; %dimensions for the histogram
|
---|
| 4017 | end
|
---|
| 4018 | end
|
---|
| 4019 | %unit
|
---|
| 4020 | units=[]; %default
|
---|
| 4021 | for ivar=1:numel(Field.ListVarName)
|
---|
| 4022 | if strcmp(Field.ListVarName{ivar},FieldName)
|
---|
| 4023 | if isfield(Field,'VarAttribute') && numel(Field.VarAttribute)>=ivar && isfield(Field.VarAttribute{ivar},'units')
|
---|
| 4024 | units=Field.VarAttribute{ivar}.units;
|
---|
| 4025 | break
|
---|
| 4026 | end
|
---|
| 4027 | end
|
---|
| 4028 | end
|
---|
| 4029 | if ~isempty(units)
|
---|
| 4030 | Histo.VarAttribute{1}.units=units;
|
---|
| 4031 | end
|
---|
| 4032 | eval(['Histo.' FieldName '=linspace(Amin,Amax,50);'])%absissa values for histo
|
---|
[258] | 4033 | if isfield(Field,'NbDim') && isequal(Field.NbDim,3)
|
---|
[199] | 4034 | C=reshape(double(FieldHisto),1,[]);% reshape in a vector
|
---|
| 4035 | eval(['Histo.histo(:,1)=hist(C, Histo.' FieldName ');']); %calculate histogram
|
---|
| 4036 | else
|
---|
| 4037 | for col=1:size(FieldHisto,3)
|
---|
| 4038 | B=FieldHisto(:,:,col);
|
---|
| 4039 | C=reshape(double(B),1,nxy(1)*nxy(2));% reshape in a vector
|
---|
| 4040 | eval(['Histo.histo(:,col)=hist(C, Histo.' FieldName ');']); %calculate histogram
|
---|
| 4041 | end
|
---|
| 4042 | end
|
---|
| 4043 | % set(haxes,'XLimMode','auto')%reset auto mode (after zoom effect)
|
---|
| 4044 | % set(haxes,'YLimMode','auto')
|
---|
| 4045 | % PlotParam.Auto_xy=1;
|
---|
| 4046 | plot_field(Histo,haxes);
|
---|
| 4047 | end
|
---|
| 4048 | end
|
---|
| 4049 |
|
---|
| 4050 | %------------------------------------------------
|
---|
| 4051 | %CALLBACKS FOR PLOTTING PARAMETERS
|
---|
| 4052 | %-------------------------------------------------
|
---|
| 4053 |
|
---|
| 4054 | %------------------------------------------------------------------------
|
---|
| 4055 | function MinX_Callback(hObject, eventdata, handles)
|
---|
| 4056 | %------------------------------------------------------------------------
|
---|
| 4057 | set(handles.FixLimits,'Value',1) %suppress auto mode
|
---|
| 4058 | set(handles.FixLimits,'BackgroundColor',[1 1 0])
|
---|
| 4059 | update_plot(handles);
|
---|
| 4060 |
|
---|
| 4061 | %------------------------------------------------------------------------
|
---|
| 4062 | function MaxX_Callback(hObject, eventdata, handles)
|
---|
| 4063 | %------------------------------------------------------------------------
|
---|
| 4064 | set(handles.FixLimits,'Value',1) %suppress auto mode
|
---|
| 4065 | set(handles.FixLimits,'BackgroundColor',[1 1 0])
|
---|
| 4066 | update_plot(handles);
|
---|
| 4067 |
|
---|
| 4068 | %------------------------------------------------------------------------
|
---|
| 4069 | function MinY_Callback(hObject, eventdata, handles)
|
---|
| 4070 | %------------------------------------------
|
---|
| 4071 | set(handles.FixLimits,'Value',1) %suppress auto mode
|
---|
| 4072 | set(handles.FixLimits,'BackgroundColor',[1 1 0])
|
---|
| 4073 | update_plot(handles);
|
---|
| 4074 |
|
---|
| 4075 | %------------------------------------------------------------------------
|
---|
| 4076 | function MaxY_Callback(hObject, eventdata, handles)
|
---|
| 4077 | %------------------------------------------------------------------------
|
---|
| 4078 | set(handles.FixLimits,'Value',1) %suppress auto mode
|
---|
| 4079 | set(handles.FixLimits,'BackgroundColor',[1 1 0])
|
---|
| 4080 | update_plot(handles);
|
---|
| 4081 |
|
---|
| 4082 | %------------------------------------------------------------------------
|
---|
| 4083 | function MinA_Callback(hObject, eventdata, handles)
|
---|
| 4084 | %------------------------------------------
|
---|
| 4085 | set(handles.FixScal,'Value',1) %suppress auto mode
|
---|
| 4086 | set(handles.FixScal,'BackgroundColor',[1 1 0])
|
---|
[227] | 4087 | MinA=str2double(get(handles.MinA,'String'));
|
---|
| 4088 | MaxA=str2double(get(handles.MaxA,'String'));
|
---|
| 4089 | if MinA>MaxA% switch minA and maxA in case of error
|
---|
| 4090 | MinA_old=MinA;
|
---|
| 4091 | MinA=MaxA;
|
---|
| 4092 | MaxA=MinA_old;
|
---|
| 4093 | set(handles.MinA,'String',num2str(MinA,5));
|
---|
| 4094 | set(handles.MaxA,'String',num2str(MaxA,5));
|
---|
| 4095 | end
|
---|
[199] | 4096 | update_plot(handles);
|
---|
| 4097 |
|
---|
| 4098 | %------------------------------------------------------------------------
|
---|
| 4099 | function MaxA_Callback(hObject, eventdata, handles)
|
---|
| 4100 | %------------------------------------------------------------------------
|
---|
| 4101 | set(handles.FixScal,'Value',1) %suppress auto mode
|
---|
| 4102 | set(handles.FixScal,'BackgroundColor',[1 1 0])
|
---|
[227] | 4103 | MinA=str2double(get(handles.MinA,'String'));
|
---|
| 4104 | MaxA=str2double(get(handles.MaxA,'String'));
|
---|
| 4105 | if MinA>MaxA% switch minA and maxA in case of error
|
---|
| 4106 | MinA_old=MinA;
|
---|
| 4107 | MinA=MaxA;
|
---|
| 4108 | MaxA=MinA_old;
|
---|
| 4109 | set(handles.MinA,'String',num2str(MinA,5));
|
---|
| 4110 | set(handles.MaxA,'String',num2str(MaxA,5));
|
---|
| 4111 | end
|
---|
[199] | 4112 | update_plot(handles);
|
---|
| 4113 |
|
---|
| 4114 | %------------------------------------------------------------------------
|
---|
| 4115 | function FixScal_Callback(hObject, eventdata, handles)
|
---|
| 4116 | %------------------------------------------------------------------------
|
---|
| 4117 | test=get(handles.FixScal,'Value');
|
---|
| 4118 | if test
|
---|
| 4119 | set(handles.FixScal,'BackgroundColor',[1 1 0])
|
---|
| 4120 | else
|
---|
| 4121 | set(handles.FixScal,'BackgroundColor',[0.7 0.7 0.7])
|
---|
| 4122 | update_plot(handles);
|
---|
| 4123 | end
|
---|
| 4124 |
|
---|
| 4125 | %-------------------------------------------------------------------
|
---|
| 4126 | function BW_Callback(hObject, eventdata, handles)
|
---|
| 4127 | %-------------------------------------------------------------------
|
---|
| 4128 | update_plot(handles);
|
---|
| 4129 |
|
---|
| 4130 | %-------------------------------------------------------------------
|
---|
| 4131 | function Contours_Callback(hObject, eventdata, handles)
|
---|
| 4132 | %-------------------------------------------------------------------
|
---|
| 4133 | val=get(handles.Contours,'Value');
|
---|
| 4134 | if val==2
|
---|
| 4135 | set(handles.interval_txt,'Visible','on')
|
---|
| 4136 | set(handles.IncrA,'Visible','on')
|
---|
| 4137 | else
|
---|
| 4138 | set(handles.interval_txt,'Visible','off')
|
---|
| 4139 | set(handles.IncrA,'Visible','off')
|
---|
| 4140 | end
|
---|
| 4141 | update_plot(handles);
|
---|
| 4142 |
|
---|
| 4143 | %-------------------------------------------------------------------
|
---|
| 4144 | function IncrA_Callback(hObject, eventdata, handles)
|
---|
| 4145 | %-------------------------------------------------------------------
|
---|
| 4146 | update_plot(handles);
|
---|
| 4147 |
|
---|
| 4148 | %-------------------------------------------------------------------
|
---|
| 4149 | function HideWarning_Callback(hObject, eventdata, handles)
|
---|
| 4150 | %-------------------------------------------------------------------
|
---|
| 4151 | update_plot(handles);
|
---|
| 4152 |
|
---|
| 4153 | %-------------------------------------------------------------------
|
---|
| 4154 | function HideFalse_Callback(hObject, eventdata, handles)
|
---|
| 4155 | %-------------------------------------------------------------------
|
---|
| 4156 | update_plot(handles);
|
---|
| 4157 |
|
---|
| 4158 | %-------------------------------------------------------------------
|
---|
| 4159 | function VecScale_Callback(hObject, eventdata, handles)
|
---|
| 4160 | %-------------------------------------------------------------------
|
---|
| 4161 | set(handles.FixVec,'Value',1);
|
---|
| 4162 | set(handles.FixVec,'BackgroundColor',[1 1 0])
|
---|
| 4163 | update_plot(handles);
|
---|
| 4164 |
|
---|
| 4165 | %-------------------------------------------------------------------
|
---|
| 4166 | function FixVec_Callback(hObject, eventdata, handles)
|
---|
| 4167 | %-------------------------------------------------------------------
|
---|
| 4168 | test=get(handles.FixVec,'Value');
|
---|
| 4169 | if test
|
---|
| 4170 | set(handles.FixVec,'BackgroundColor',[1 1 0])
|
---|
| 4171 | else
|
---|
| 4172 | update_plot(handles);
|
---|
| 4173 | %set(handles.VecScale,'String',num2str(ScalOut.VecScale,3))
|
---|
| 4174 | set(handles.FixVec,'BackgroundColor',[0.7 0.7 0.7])
|
---|
| 4175 | end
|
---|
| 4176 |
|
---|
| 4177 | %------------------------------------------------------------------------
|
---|
| 4178 | % --- Executes on selection change in decimate4 (nb_vec/4).
|
---|
| 4179 | function decimate4_Callback(hObject, eventdata, handles)
|
---|
| 4180 | %------------------------------------------------------------------------
|
---|
| 4181 | update_plot(handles);
|
---|
| 4182 |
|
---|
| 4183 | %------------------------------------------------------------------------
|
---|
| 4184 | % --- Executes on selection change in color_code menu
|
---|
| 4185 | function color_code_Callback(hObject, eventdata, handles)
|
---|
| 4186 | %------------------------------------------------------------------------
|
---|
| 4187 | set_vec_col_bar(handles)
|
---|
| 4188 | update_plot(handles);
|
---|
| 4189 |
|
---|
| 4190 | %------------------------------------------------------------------------
|
---|
| 4191 | % --- Executes on button press in AutoVecColor.
|
---|
| 4192 | function AutoVecColor_Callback(hObject, eventdata, handles)
|
---|
| 4193 | %------------------------------------------------------------------------
|
---|
| 4194 | test=get(handles.AutoVecColor,'Value');
|
---|
| 4195 | if test
|
---|
| 4196 | set(handles.AutoVecColor,'BackgroundColor',[1 1 0])
|
---|
| 4197 | else
|
---|
| 4198 | update_plot(handles);
|
---|
| 4199 | %set(handles.VecScale,'String',num2str(ScalOut.VecScale,3))
|
---|
| 4200 | set(handles.AutoVecColor,'BackgroundColor',[0.7 0.7 0.7])
|
---|
| 4201 | end
|
---|
| 4202 |
|
---|
| 4203 | %------------------------------------------------------------------------
|
---|
| 4204 | % --- Executes on selection change in max_vec.
|
---|
| 4205 | function min_vec_Callback(hObject, eventdata, handles)
|
---|
| 4206 | %------------------------------------------------------------------------
|
---|
| 4207 | max_vec_Callback(hObject, eventdata, handles)
|
---|
| 4208 |
|
---|
| 4209 | %------------------------------------------------------------------------
|
---|
| 4210 | % --- Executes on selection change in max_vec.
|
---|
| 4211 | function max_vec_Callback(hObject, eventdata, handles)
|
---|
| 4212 | %------------------------------------------------------------------------
|
---|
| 4213 | set(handles.AutoVecColor,'Value',1)
|
---|
| 4214 | AutoVecColor_Callback(hObject, eventdata, handles)
|
---|
| 4215 | min_val=str2num(get(handles.min_vec,'String'));
|
---|
| 4216 | max_val=str2num(get(handles.max_vec,'String'));
|
---|
| 4217 | slider1=get(handles.slider1,'Value');
|
---|
| 4218 | slider2=get(handles.slider2,'Value');
|
---|
| 4219 | colcode1=min_val+(max_val-min_val)*slider1;
|
---|
| 4220 | colcode2=min_val+(max_val-min_val)*slider2;
|
---|
| 4221 | set(handles.colcode1,'String',num2str(colcode1))
|
---|
| 4222 | set(handles.colcode2,'String',num2str(colcode2))
|
---|
| 4223 | update_plot(handles);
|
---|
| 4224 |
|
---|
| 4225 | %------------------------------------------------------------------------
|
---|
| 4226 | % --- update the display of color code for vectors
|
---|
| 4227 | function set_vec_col_bar(handles)
|
---|
| 4228 | %------------------------------------------------------------------------
|
---|
| 4229 | %get the image of the color display button 'vec_col_bar' in pixels
|
---|
| 4230 | set(handles.vec_col_bar,'Unit','pixel');
|
---|
| 4231 | pos_vert=get(handles.vec_col_bar,'Position');
|
---|
| 4232 | set(handles.vec_col_bar,'Unit','Normalized');
|
---|
| 4233 | width=ceil(pos_vert(3));
|
---|
| 4234 | height=ceil(pos_vert(4));
|
---|
| 4235 |
|
---|
| 4236 | %get slider indications
|
---|
| 4237 | list=get(handles.color_code,'String');
|
---|
| 4238 | ichoice=get(handles.color_code,'Value');
|
---|
| 4239 | colcode.ColorCode=list{ichoice};
|
---|
| 4240 | colcode.MinC=str2num(get(handles.min_vec,'String'));
|
---|
| 4241 | colcode.MaxC=str2num(get(handles.max_vec,'String'));
|
---|
| 4242 | test3color=strcmp(colcode.ColorCode,'rgb') || strcmp(colcode.ColorCode,'bgr');
|
---|
| 4243 | if test3color
|
---|
| 4244 | colcode.colcode1=str2num(get(handles.colcode1,'String'));
|
---|
| 4245 | colcode.colcode2=str2num(get(handles.colcode2,'String'));
|
---|
| 4246 | end
|
---|
| 4247 | colcode.FixedCbounds=0;
|
---|
| 4248 | colcode.FixedCbounds=1;
|
---|
| 4249 | vec_C=colcode.MinC+(colcode.MaxC-colcode.MinC)*(0.5:width-0.5)/width;%sample of vec_C values from min to max
|
---|
| 4250 | [colorlist,col_vec]=set_col_vec(colcode,vec_C);
|
---|
| 4251 | oneheight=ones(1,height);
|
---|
| 4252 | A1=colorlist(col_vec,1)*oneheight;
|
---|
| 4253 | A2=colorlist(col_vec,2)*oneheight;
|
---|
| 4254 | A3=colorlist(col_vec,3)*oneheight;
|
---|
| 4255 | A(:,:,1)=A1';
|
---|
| 4256 | A(:,:,2)=A2';
|
---|
| 4257 | A(:,:,3)=A3';
|
---|
| 4258 | set(handles.vec_col_bar,'Cdata',A)
|
---|
| 4259 |
|
---|
| 4260 |
|
---|
| 4261 | %-------------------------------------------------------------------
|
---|
| 4262 | function update_plot(handles)
|
---|
| 4263 | %-------------------------------------------------------------------
|
---|
| 4264 | haxes= handles.axes3;
|
---|
| 4265 | UvData=get(handles.uvmat,'UserData');
|
---|
| 4266 | AxeData=UvData.axes3;
|
---|
| 4267 | PlotParam=read_plot_param(handles);
|
---|
| 4268 | [PP,PlotParamOut]= plot_field(AxeData,haxes,PlotParam);
|
---|
| 4269 | write_plot_param(handles,PlotParamOut); %update the auto plot parameters
|
---|
| 4270 |
|
---|
| 4271 | %-------------------------------------------------------------------
|
---|
| 4272 | % --- Executes on button press in grid.
|
---|
| 4273 | function grid_Callback(hObject, eventdata, handles)
|
---|
| 4274 |
|
---|
| 4275 |
|
---|
| 4276 | %-------------------------------------------------------------------
|
---|
| 4277 | % --- Executes on selection change in edit_object.
|
---|
| 4278 | function edit_object_Callback(hObject, eventdata, handles)
|
---|
| 4279 | %-------------------------------------------------------------------
|
---|
| 4280 | UvData=get(handles.uvmat,'UserData');%read UvData properties stored on the uvmat interface
|
---|
| 4281 | test=get(handles.edit_object,'Value');
|
---|
| 4282 | if test
|
---|
| 4283 | set(handles.edit_object,'BackgroundColor',[1,1,0])
|
---|
| 4284 | %suppress the other options
|
---|
| 4285 | set(handles.zoom,'Value',0)
|
---|
| 4286 | zoom_Callback(hObject, eventdata, handles)
|
---|
| 4287 | hgeometry_calib=findobj(allchild(0),'tag','geometry_calib');
|
---|
| 4288 | if ishandle(hgeometry_calib)
|
---|
| 4289 | hhgeometry_calib=guidata(hgeometry_calib);
|
---|
| 4290 | set(hhgeometry_calib.edit_append,'Value',0)% desactivate mouse action in geometry_calib
|
---|
| 4291 | set(hhgeometry_calib.edit_append,'BackgroundColor',[0.7 0.7 0.7])
|
---|
| 4292 | end
|
---|
| 4293 | else
|
---|
| 4294 | UvData.MouseAction='none';
|
---|
| 4295 | set(handles.edit_object,'BackgroundColor',[0.7,0.7,0.7])
|
---|
| 4296 | hset_object=findobj(allchild(0),'tag','set_object');% look for the set_object GUI
|
---|
| 4297 | if ~isempty(hset_object)
|
---|
| 4298 | delete(hset_object)% delete the current GUI set_object
|
---|
| 4299 | end
|
---|
| 4300 | end
|
---|
| 4301 | set(handles.uvmat,'UserData',UvData);
|
---|
| 4302 | hset_object=findobj(allchild(0),'Tag','set_object');
|
---|
| 4303 | if ~isempty(hset_object)
|
---|
| 4304 | hhset_object=guidata(hset_object);
|
---|
| 4305 | if test
|
---|
| 4306 | set(hhset_object.PLOT,'enable','on');
|
---|
| 4307 | else
|
---|
| 4308 | set(hhset_object.PLOT,'enable','off');
|
---|
| 4309 | end
|
---|
| 4310 | end
|
---|
| 4311 |
|
---|
| 4312 | %------------------------------------------------------------------------
|
---|
| 4313 | % --- Executes on selection change in list_object_1.
|
---|
| 4314 | function list_object_1_Callback(hObject, eventdata, handles)
|
---|
| 4315 | %------------------------------------------------------------------------
|
---|
| 4316 | list_str=get(handles.list_object_1,'String');
|
---|
| 4317 | IndexObj=get(handles.list_object_1,'Value');
|
---|
[252] | 4318 | %IndexObj(2)=get(handles.list_object_2,'Value');
|
---|
| 4319 | update_object(handles,IndexObj,1,list_str{IndexObj})
|
---|
[199] | 4320 |
|
---|
| 4321 | %------------------------------------------------------------------------
|
---|
| 4322 | % --- Executes on selection change in list_object_1.
|
---|
| 4323 | function list_object_2_Callback(hObject, eventdata, handles)
|
---|
| 4324 | %------------------------------------------------------------------------
|
---|
[242] | 4325 | list_str=get(handles.list_object_2,'String');
|
---|
| 4326 | IndexObj=get(handles.list_object_2,'Value');
|
---|
[252] | 4327 | %IndexObj(2)=get(handles.list_object_2,'Value')-1;
|
---|
| 4328 | % if no projection object is selected, close view_field
|
---|
| 4329 | if ischar(list_str) || isempty(list_str{IndexObj})
|
---|
[199] | 4330 | hview_field=findobj(allchild(0),'Tag','view_field');
|
---|
| 4331 | if ~isempty(hview_field)
|
---|
| 4332 | delete(hview_field)
|
---|
| 4333 | end
|
---|
| 4334 | hset_object=findobj(allchild(0),'Tag','set_object');
|
---|
| 4335 | if ~isempty(hset_object)
|
---|
| 4336 | delete(hset_object)
|
---|
| 4337 | end
|
---|
| 4338 | else
|
---|
[252] | 4339 | if isequal(get(handles.uvmat,'SelectionType'),'alt')
|
---|
| 4340 | option=4;%will show object properties on the GUI set_object
|
---|
| 4341 | else
|
---|
| 4342 | option=2; % just update the projection
|
---|
| 4343 | end
|
---|
| 4344 | update_object(handles,IndexObj,option,list_str{IndexObj})
|
---|
[199] | 4345 | end
|
---|
| 4346 |
|
---|
| 4347 | %------------------------------------------------------------------------
|
---|
| 4348 | function update_object(handles,IndexObj,option,ObjectName)
|
---|
| 4349 | %------------------------------------------------------------------------
|
---|
| 4350 | UvData=get(handles.uvmat,'UserData');%read UvData properties stored on the uvmat interface
|
---|
[252] | 4351 | if numel(UvData.Object)<max(IndexObj);
|
---|
[199] | 4352 | return
|
---|
| 4353 | end
|
---|
[252] | 4354 | % if option==1 ||option==3
|
---|
[199] | 4355 | ObjectData=UvData.Object{IndexObj};
|
---|
[252] | 4356 | % else
|
---|
| 4357 | % ObjectData=UvData.Object{IndexObj};
|
---|
| 4358 | % end
|
---|
[199] | 4359 | ObjectData.Name=ObjectName;
|
---|
| 4360 | if isequal(get(handles.edit_object,'Value'),1)
|
---|
| 4361 | ObjectData.enable_plot=1; % desable the PLOT option in the set_object GUI (editing mode
|
---|
| 4362 | end
|
---|
| 4363 | ZBounds=0; % default
|
---|
| 4364 | if isfield(UvData.Field,'ZMin') && isfield(UvData.Field,'ZMax')
|
---|
| 4365 | ZBounds(1)=UvData.Field.ZMin; %minimum for the Z slider
|
---|
| 4366 | ZBounds(2)=UvData.Field.ZMax;%maximum for the Z slider
|
---|
| 4367 | end
|
---|
| 4368 | hset_object=findobj(allchild(0),'tag','set_object');
|
---|
| 4369 | if ~isempty(hset_object)
|
---|
| 4370 | delete(hset_object)% delete existing version of set_object
|
---|
| 4371 | end
|
---|
| 4372 | edit_test=get(handles.edit_object,'Value');
|
---|
| 4373 | if edit_test
|
---|
| 4374 | ObjectData.enable_plot=1;
|
---|
| 4375 | else
|
---|
[210] | 4376 | if isfield(ObjectData,'enable_plot')
|
---|
[199] | 4377 | ObjectData=rmfield(ObjectData,'enable_plot');
|
---|
| 4378 | end
|
---|
| 4379 | end
|
---|
| 4380 |
|
---|
[252] | 4381 | if option==3 ||option==4% right mouse selection, show the GUI set_object:
|
---|
| 4382 | hset_object=set_object(ObjectData,[],ZBounds);
|
---|
| 4383 | end
|
---|
| 4384 |
|
---|
| 4385 | %project on the selected object and update the corresponding plot
|
---|
| 4386 | hview_field=findobj(allchild(0),'tag','view_field');
|
---|
| 4387 | % PlotHandles=guidata(hview_field);
|
---|
| 4388 | if option==1 || option==3%length(UvData.Object)>= IndexObj && isfield(UvData.Object{IndexObj},'plotaxes')&& ishandle(UvData.Object{IndexObj}.plotaxes)
|
---|
[199] | 4389 | PlotHandles=handles;
|
---|
| 4390 | else
|
---|
| 4391 | if isempty(hview_field)
|
---|
| 4392 | hview_field=view_field;
|
---|
| 4393 | end
|
---|
| 4394 | PlotHandles=guidata(hview_field);
|
---|
| 4395 | end
|
---|
[252] | 4396 | if option==1 ||option==2% lefet mouse selection, peroject the field:
|
---|
| 4397 | ProjData= proj_field(UvData.Field,ObjectData);%project the current interface field on ObjectData
|
---|
| 4398 | plot_field(ProjData,PlotHandles.axes3,read_plot_param(PlotHandles));%read plotting parameters on the uvmat interfacPlotHandles);
|
---|
| 4399 | UvData.Object=update_obj(UvData,IndexObj,[]);
|
---|
| 4400 | set(handles.uvmat,'UserData',UvData)
|
---|
| 4401 | end
|
---|
| 4402 |
|
---|
| 4403 |
|
---|
| 4404 | % set(handles.uvmat,'UserData',UvData)
|
---|
| 4405 | hother=[findobj(handles.axes3,'Tag','proj_object') ;findobj(PlotHandles.axes3,'Tag','proj_object')] ;%find all the proj objects
|
---|
| 4406 | hother=[hother ;findobj(handles.axes3,'Tag','DeformPoint'); findobj(PlotHandles.axes3,'Tag','DeformPoint')];
|
---|
[199] | 4407 | for iobj=1:length(hother)
|
---|
| 4408 | if isequal(get(hother(iobj),'Type'),'rectangle')||isequal(get(hother(iobj),'Type'),'patch')
|
---|
| 4409 | set(hother(iobj),'EdgeColor','b')
|
---|
| 4410 | if isequal(get(hother(iobj),'FaceColor'),'m')
|
---|
| 4411 | set(hother(iobj),'FaceColor','b')
|
---|
| 4412 | end
|
---|
| 4413 | elseif isequal(get(hother(iobj),'Type'),'image')
|
---|
| 4414 | Acolor=get(hother(iobj),'CData');
|
---|
| 4415 | Acolor(:,:,1)=zeros(size(Acolor,1),size(Acolor,2));
|
---|
| 4416 | set(hother(iobj),'CData',Acolor);
|
---|
| 4417 | else
|
---|
| 4418 | set(hother(iobj),'Color','b')
|
---|
| 4419 | end
|
---|
| 4420 | set(hother(iobj),'Selected','off')
|
---|
| 4421 | end
|
---|
| 4422 | if isfield(ObjectData,'DisplayHandle_uvmat')
|
---|
| 4423 | if ishandle(ObjectData.DisplayHandle_uvmat)
|
---|
| 4424 | uistack(ObjectData.DisplayHandle_uvmat,'top')
|
---|
| 4425 | linetype=get(ObjectData.DisplayHandle_uvmat,'Type');
|
---|
| 4426 | if isequal(linetype,'line')
|
---|
| 4427 | set(ObjectData.DisplayHandle_uvmat,'Color','m'); %set the selected object to magenta color
|
---|
| 4428 | elseif isequal(linetype,'rectangle')
|
---|
| 4429 | set(ObjectData.DisplayHandle_uvmat,'EdgeColor','m'); %set the selected object to magenta color
|
---|
| 4430 | elseif isequal(linetype,'patch')
|
---|
| 4431 | set(ObjectData.DisplayHandle_uvmat,'FaceColor','m'); %set the selected object to magenta color
|
---|
| 4432 | end
|
---|
| 4433 | SubObjectData=get(ObjectData.DisplayHandle_uvmat,'UserData');
|
---|
| 4434 | if isfield(SubObjectData,'SubObject') & ishandle(SubObjectData.SubObject)
|
---|
| 4435 | uistack(SubObjectData.SubObject,'top')
|
---|
| 4436 | for iobj=1:length(SubObjectData.SubObject)
|
---|
| 4437 | hsub=SubObjectData.SubObject(iobj);
|
---|
| 4438 | if isequal(get(hsub,'Type'),'rectangle')
|
---|
| 4439 | set(hsub,'EdgeColor','m'); %set the selected object to magenta color
|
---|
| 4440 | elseif isequal(get(hsub,'Type'),'image')
|
---|
| 4441 | Acolor=get(hsub,'CData');
|
---|
| 4442 | Acolor(:,:,1)=Acolor(:,:,3);
|
---|
| 4443 | set(hsub,'CData',Acolor);
|
---|
| 4444 | else
|
---|
| 4445 | set(hsub,'Color','m')
|
---|
| 4446 | end
|
---|
| 4447 | end
|
---|
| 4448 | end
|
---|
| 4449 | if isfield(SubObjectData,'DeformPoint') & ishandle(SubObjectData.DeformPoint)
|
---|
| 4450 | set(SubObjectData.DeformPoint,'Color','m')
|
---|
| 4451 | end
|
---|
| 4452 | end
|
---|
| 4453 | end
|
---|
| 4454 |
|
---|
| 4455 | %------------------------------------------------------
|
---|
| 4456 | % --- Executes on button press in Menu/Export/field in workspace.
|
---|
| 4457 | %------------------------------------------------------
|
---|
| 4458 | function MenuExportField_Callback(hObject, eventdata, handles)
|
---|
| 4459 | global Data_uvmat
|
---|
| 4460 | Data_uvmat=get(handles.uvmat,'UserData');
|
---|
| 4461 | evalin('base','global Data_uvmat')%make CurData global in the workspace
|
---|
| 4462 | display('current field :')
|
---|
| 4463 | evalin('base','Data_uvmat') %display CurData in the workspace
|
---|
| 4464 | commandwindow; %brings the Matlab command window to the front
|
---|
| 4465 |
|
---|
| 4466 | %------------------------------------------------------
|
---|
| 4467 | % --- Executes on button press in Menu/Export/extract figure.
|
---|
| 4468 | %------------------------------------------------------
|
---|
| 4469 | function MenuExport_plot_Callback(hObject, eventdata, handles)
|
---|
| 4470 | huvmat=get(handles.MenuExport_plot,'parent');
|
---|
| 4471 | UvData=get(huvmat,'UserData');
|
---|
| 4472 | hfig=figure;
|
---|
| 4473 | newaxes=copyobj(handles.axes3,hfig);
|
---|
| 4474 | map=colormap(handles.axes3);
|
---|
| 4475 | colormap(map);%transmit the current colormap to the zoom fig
|
---|
| 4476 | colorbar
|
---|
| 4477 |
|
---|
| 4478 |
|
---|
| 4479 | % --------------------------------------------------------------------
|
---|
| 4480 | function Insert_Callback(hObject, eventdata, handles)
|
---|
| 4481 |
|
---|
| 4482 |
|
---|
| 4483 | % --------------------------------------------------------------------
|
---|
| 4484 | function MenuHelp_Callback(hObject, eventdata, handles)
|
---|
| 4485 | % --------------------------------------------------------------------
|
---|
| 4486 | path_to_uvmat=which ('uvmat');% check the path of uvmat
|
---|
| 4487 | pathelp=fileparts(path_to_uvmat);
|
---|
| 4488 | helpfile=fullfile(pathelp,'uvmat_doc','uvmat_doc.html');
|
---|
| 4489 | 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')
|
---|
| 4490 | else
|
---|
| 4491 | addpath (fullfile(pathelp,'uvmat_doc'))
|
---|
| 4492 | web(helpfile);
|
---|
| 4493 | end
|
---|
| 4494 |
|
---|
| 4495 | %------------------------------------------------------------------------
|
---|
| 4496 | % --------------------------------------------------------------------
|
---|
| 4497 | function MenuExportMovie_Callback(hObject, eventdata, handles)
|
---|
| 4498 | % --------------------------------------------------------------------
|
---|
| 4499 | set(handles.MenuExportMovie,'BusyAction','queue')% activate the button
|
---|
| 4500 | huvmat=get(handles.run0,'parent');
|
---|
| 4501 | UvData=get(huvmat,'UserData');
|
---|
| 4502 | [xx,xx,FileBase]=read_file_boxes(handles);
|
---|
| 4503 | %read the current input file name
|
---|
| 4504 | 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)'};
|
---|
| 4505 | dlg_title = 'select properties of the output avi movie';
|
---|
| 4506 | num_lines= 1;
|
---|
| 4507 | % nbfield_cell=get(handles.last_i,'String');
|
---|
| 4508 | def = {[FileBase '_out.avi'];'10';'1';'[0.03 0.05 0.95 0.92]';'10'};
|
---|
| 4509 | answer = inputdlg(prompt,dlg_title,num_lines,def,'on');
|
---|
| 4510 | aviname=answer{1};
|
---|
| 4511 | fps=str2double(answer{2});
|
---|
| 4512 | % check for existing file with output name aviname
|
---|
| 4513 | if exist(aviname,'file')
|
---|
| 4514 | backup=aviname;
|
---|
| 4515 | testexist=2;
|
---|
| 4516 | while testexist==2
|
---|
| 4517 | backup=[backup '~'];
|
---|
| 4518 | testexist=exist(backup,'file');
|
---|
| 4519 | end
|
---|
| 4520 | [success,message]=copyfile(aviname,backup);%make backup of the existing file
|
---|
| 4521 | if isequal(success,1)
|
---|
| 4522 | delete(aviname)%delete existing file
|
---|
| 4523 | else
|
---|
| 4524 | msgbox_uvmat('ERROR',message)
|
---|
| 4525 | return
|
---|
| 4526 | end
|
---|
| 4527 | end
|
---|
| 4528 | %create avi open
|
---|
| 4529 | aviobj=avifile(aviname,'Compression','None','fps',fps);
|
---|
| 4530 |
|
---|
| 4531 | %display first view for tests
|
---|
| 4532 | newfig=figure;
|
---|
| 4533 | newaxes=copyobj(handles.axes3,newfig);%new plotting axes in the new figure
|
---|
| 4534 | set(newaxes,'Tag','movieaxes')
|
---|
| 4535 | nbpix=[512 384]*str2double(answer{3});
|
---|
| 4536 | set(gcf,'Position',[1 1 nbpix])% resolution XVGA
|
---|
| 4537 | set(newaxes,'Position',eval(answer{4}));
|
---|
| 4538 | map=colormap(handles.axes3);
|
---|
| 4539 | colormap(map);%transmit the current colormap to the zoom fig
|
---|
| 4540 | msgbox_uvmat('INPUT_Y-N',{['adjust figure ' num2str(newfig) ' with its matlab edit menu '] ;...
|
---|
| 4541 | ['then press OK to get the avi movie as a copy of figure ' num2str(newfig) ' display']});
|
---|
[215] | 4542 | UvData.plotaxes=newaxes;% the axis in the new figure becomes the current main plotting axes
|
---|
[199] | 4543 | set(huvmat,'UserData',UvData);
|
---|
| 4544 | increment=str2double(get(handles.increment_scan,'String')); %get the field increment d
|
---|
| 4545 | if isnan(increment)
|
---|
| 4546 | set(handles.increment_scan,'String','1')%default value
|
---|
| 4547 | increment=1;
|
---|
| 4548 | end
|
---|
| 4549 | set(handles.STOP,'Visible','on')
|
---|
| 4550 | set(handles.speed,'Visible','on')
|
---|
| 4551 | set(handles.speed_txt,'Visible','on')
|
---|
| 4552 | set(handles.Movie,'BusyAction','queue')
|
---|
| 4553 |
|
---|
| 4554 | %imin=str2double(get(handles.i1,'String'));
|
---|
| 4555 | imax=str2double(answer{5});
|
---|
| 4556 | % if isfield(UvData,'Time')
|
---|
| 4557 | htitle=get(newaxes,'Title');
|
---|
| 4558 | xlim=get(newaxes,'XLim');
|
---|
| 4559 | ylim=get(newaxes,'YLim');
|
---|
| 4560 | set(htitle,'Position',[xlim(2)+0.07*(xlim(2)-xlim(1)) ylim(2)-0.05*(ylim(2)-ylim(1)) 0])
|
---|
| 4561 | time_str=get(handles.abs_time,'String');
|
---|
| 4562 | set(htitle,'String',['t=' time_str])
|
---|
| 4563 | set(handles.speed,'Value',1)
|
---|
| 4564 | for i=1:imax
|
---|
| 4565 | if get(handles.speed,'Value')~=0 && isequal(get(handles.MenuExportMovie,'BusyAction'),'queue') % enable STOP command
|
---|
| 4566 | runpm(hObject,eventdata,handles,increment)% run plus
|
---|
| 4567 | drawnow
|
---|
| 4568 | time_str=get(handles.abs_time,'String');
|
---|
| 4569 | if ishandle(htitle)
|
---|
| 4570 | set(htitle,'String',['t=' time_str])
|
---|
| 4571 | end
|
---|
| 4572 | mov=getframe(newfig);
|
---|
| 4573 | aviobj=addframe(aviobj,mov);
|
---|
| 4574 | end
|
---|
| 4575 | end
|
---|
[215] | 4576 | aviobj=close(aviobj);
|
---|
| 4577 | UvData=rmfield(UvData,'plotaxes');
|
---|
| 4578 | %UvData.Object{1}.plotaxes=handles.axes3;
|
---|
[199] | 4579 | set(huvmat,'UserData',UvData);
|
---|
| 4580 | msgbox_uvmat('CONFIRMATION',{['movie ' aviname ' created '];['with ' num2str(imax) ' frames']})
|
---|
| 4581 |
|
---|
| 4582 | %------------------------------------------------------------------------
|
---|
| 4583 | function MenuCalib_Callback(hObject, eventdata, handles)
|
---|
| 4584 | %------------------------------------------------------------------------
|
---|
| 4585 |
|
---|
| 4586 | UvData=get(handles.uvmat,'UserData');%read UvData properties stored on the uvmat interface
|
---|
| 4587 |
|
---|
| 4588 | %suppress competing options
|
---|
| 4589 | set(handles.zoom,'Value',0)
|
---|
| 4590 | set(handles.zoom,'BackgroundColor',[0.7 0.7 0.7])
|
---|
| 4591 | set(handles.list_object_1,'Value',1)
|
---|
| 4592 | % initiate display of GUI geometry_calib
|
---|
| 4593 | data=[]; %default
|
---|
| 4594 | if isfield(UvData,'CoordType')
|
---|
| 4595 | data.CoordType=UvData.CoordType;
|
---|
| 4596 | end
|
---|
| 4597 | pos=get(handles.uvmat,'Position');
|
---|
| 4598 | pos(1)=pos(1)+pos(3)-0.311+0.04; %0.311= width of the geometry_calib interface (units relative to the srcreen)
|
---|
| 4599 | pos(2)=pos(2)-0.02;
|
---|
| 4600 | [FileName,RootPath,FileBase,FileIndices,FileExt,SubDir]=read_file_boxes(handles);
|
---|
| 4601 | set(handles.view_xml,'Backgroundcolor',[1 1 0])%indicate the reading of the current xml file by geometry_calib
|
---|
| 4602 | if isfield(UvData.OpenParam,'CalOrigin')
|
---|
| 4603 | pos_uvmat=get(handles.uvmat,'Position');
|
---|
| 4604 | pos_cal(1)=pos_uvmat(1)+UvData.OpenParam.CalOrigin(1)*pos_uvmat(3);
|
---|
| 4605 | pos_cal(2)=pos_uvmat(2)+UvData.OpenParam.CalOrigin(2)*pos_uvmat(4);
|
---|
| 4606 | pos_cal(3:4)=UvData.OpenParam.CalSize .* pos_uvmat(3:4);
|
---|
| 4607 | end
|
---|
| 4608 | geometry_calib(FileName,pos_cal);% call the geometry_calib interface
|
---|
| 4609 | set(handles.view_xml,'Backgroundcolor',[1 1 1])%indicate the end of reading of the current xml file by geometry_calib
|
---|
| 4610 | set(handles.MenuCalib,'checked','on')% indicate that MenuCalib is activated, test used by mouse action
|
---|
| 4611 |
|
---|
| 4612 | %------------------------------------------------------------------------
|
---|
| 4613 | function MenuMask_Callback(hObject, eventdata, handles)
|
---|
| 4614 | %------------------------------------------------------------------------
|
---|
| 4615 | UvData=get(handles.uvmat,'UserData');%read UvData properties stored on the uvmat interface
|
---|
| 4616 | ListObj=UvData.Object;
|
---|
| 4617 | select=zeros(1,numel(ListObj));
|
---|
| 4618 | for iobj=1:numel(ListObj);
|
---|
| 4619 | if strcmp(ListObj{iobj}.ProjMode,'mask_inside')||strcmp(ListObj{iobj}.ProjMode,'mask_outside')
|
---|
| 4620 | select(iobj)=1;
|
---|
| 4621 | end
|
---|
| 4622 | end
|
---|
| 4623 | val=find(select);
|
---|
| 4624 | if isempty(val)
|
---|
| 4625 | msgbox_uvmat('ERROR','polygons must be first created by Projection object/mask polygon in the menu bar');
|
---|
| 4626 | return
|
---|
| 4627 | else
|
---|
| 4628 | set(handles.list_object_1,'Max',2);%allow multiple selection
|
---|
| 4629 | set(handles.list_object_1,'Value',val);
|
---|
| 4630 | flag=1;
|
---|
| 4631 | npx=size(UvData.Field.A,2);
|
---|
| 4632 | npy=size(UvData.Field.A,1);
|
---|
| 4633 | xi=0.5:npx-0.5;
|
---|
| 4634 | yi=0.5:npy-0.5;
|
---|
| 4635 | [Xi,Yi]=meshgrid(xi,yi);
|
---|
| 4636 | if isfield(UvData,'Object')
|
---|
| 4637 | for iobj=1:length(UvData.Object)
|
---|
| 4638 | ObjectData=UvData.Object{iobj};
|
---|
| 4639 | if isfield(ObjectData,'ProjMode') &&(isequal(ObjectData.ProjMode,'mask_inside')||isequal(ObjectData.ProjMode,'mask_outside'));
|
---|
| 4640 | flagobj=1;
|
---|
| 4641 | testphys=0; %coordinates in pixels by default
|
---|
| 4642 | if isfield(ObjectData,'CoordUnit') && ~isequal(ObjectData.CoordUnit,'pixel')
|
---|
| 4643 | if isfield(UvData,'XmlData')&& isfield(UvData.XmlData,'GeometryCalib')
|
---|
| 4644 | Calib=UvData.XmlData.GeometryCalib;
|
---|
| 4645 | testphys=1;
|
---|
| 4646 | end
|
---|
| 4647 | end
|
---|
| 4648 | if isfield(ObjectData,'Coord')& isfield(ObjectData,'Style')
|
---|
| 4649 | if isequal(ObjectData.Style,'polygon')
|
---|
| 4650 | X=ObjectData.Coord(:,1);
|
---|
| 4651 | Y=ObjectData.Coord(:,2);
|
---|
| 4652 | if testphys
|
---|
| 4653 | [X,Y]=px_XYZ(Calib,X,Y,0);% to generalise with 3D cases
|
---|
| 4654 | end
|
---|
| 4655 | flagobj=~inpolygon(Xi,Yi,X',Y');%=0 inside the polygon, 1 outside
|
---|
| 4656 | elseif isequal(ObjectData.Style,'ellipse')
|
---|
| 4657 | if testphys
|
---|
| 4658 | %[X,Y]=px_XYZ(Calib,X,Y,0);% TODO:create a polygon boundary and transform to phys
|
---|
| 4659 | end
|
---|
| 4660 | RangeX=max(ObjectData.RangeX);
|
---|
| 4661 | RangeY=max(ObjectData.RangeY);
|
---|
| 4662 | X2Max=RangeX*RangeX;
|
---|
| 4663 | Y2Max=RangeY*RangeY;
|
---|
| 4664 | distX=(Xi-ObjectData.Coord(1,1));
|
---|
| 4665 | distY=(Yi-ObjectData.Coord(1,2));
|
---|
| 4666 | flagobj=(distX.*distX/X2Max+distY.*distY/Y2Max)>1;
|
---|
| 4667 | elseif isequal(ObjectData.Style,'rectangle')
|
---|
| 4668 | if testphys
|
---|
| 4669 | %[X,Y]=px_XYZ(Calib,X,Y,0);% TODO:create a polygon boundary and transform to phys
|
---|
| 4670 | end
|
---|
| 4671 | distX=abs(Xi-ObjectData.Coord(1,1));
|
---|
| 4672 | distY=abs(Yi-ObjectData.Coord(1,2));
|
---|
| 4673 | flagobj=distX>max(ObjectData.RangeX) | distY>max(ObjectData.RangeY);
|
---|
| 4674 | end
|
---|
| 4675 | if isequal(ObjectData.ProjMode,'mask_outside')
|
---|
| 4676 | flagobj=~flagobj;
|
---|
| 4677 | end
|
---|
| 4678 | flag=flag & flagobj;
|
---|
| 4679 | end
|
---|
| 4680 | end
|
---|
| 4681 | end
|
---|
[231] | 4682 | end
|
---|
[199] | 4683 | %mask name
|
---|
| 4684 | RootPath=get(handles.RootPath,'String');
|
---|
| 4685 | RootFile=get(handles.RootFile,'String');
|
---|
| 4686 | if ~isempty(RootFile)&&(isequal(RootFile(1),'/')|| isequal(RootFile(1),'\'))
|
---|
| 4687 | RootFile(1)=[];
|
---|
| 4688 | end
|
---|
| 4689 | filebase=fullfile(RootPath,RootFile);
|
---|
| 4690 | list=get(handles.masklevel,'String');
|
---|
| 4691 | masknumber=num2str(length(list));
|
---|
| 4692 | maskindex=get(handles.masklevel,'Value');
|
---|
| 4693 | mask_name=name_generator([filebase '_' masknumber 'mask'],maskindex,1,'.png','_i');
|
---|
| 4694 | imflag=uint8(255*(0.392+0.608*flag));% =100 for flag=0 (vectors not computed when 20<imflag<200)
|
---|
| 4695 | imflag=flipdim(imflag,1);
|
---|
| 4696 |
|
---|
| 4697 | %display the mask
|
---|
[231] | 4698 | hfigmask=figure;
|
---|
| 4699 | set(hfigmask,'Name','mask image')
|
---|
[199] | 4700 | vec=linspace(0,1,256);%define a linear greyscale colormap
|
---|
| 4701 | map=[vec' vec' vec'];
|
---|
| 4702 | colormap(map)
|
---|
| 4703 | image(imflag);
|
---|
| 4704 | answer=msgbox_uvmat('INPUT_TXT','mask file name:', mask_name);
|
---|
| 4705 | if ~strcmp(answer,'Cancel')
|
---|
| 4706 | mask_dir=fileparts(answer);
|
---|
| 4707 | if ~exist(mask_dir,'dir')
|
---|
| 4708 | msgbox_uvmat('ERROR',['directory ' mask_dir ' does not exist'])
|
---|
| 4709 | return
|
---|
| 4710 | end
|
---|
| 4711 | imwrite(imflag,answer,'BitDepth',8);
|
---|
| 4712 | end
|
---|
| 4713 | set(handles.list_object_1,'Value',1)
|
---|
| 4714 | set(handles.list_object_1,'Max',1)
|
---|
| 4715 | end
|
---|
| 4716 |
|
---|
| 4717 | %------------------------------------------------------------------------
|
---|
| 4718 | %-- open the GUI set_grid.fig to create grid
|
---|
| 4719 | function MenuGrid_Callback(hObject, eventdata, handles)
|
---|
| 4720 | %------------------------------------------------------------------------
|
---|
| 4721 | %UvData=get(handles.uvmat,'UserData');%read UvData properties stored on the uvmat interface
|
---|
| 4722 |
|
---|
| 4723 | %suppress the other options if grid is chosen
|
---|
| 4724 | set(handles.edit_vect,'Value',0)
|
---|
| 4725 | edit_vect_Callback(hObject, eventdata, handles)
|
---|
| 4726 | set(handles.edit_object,'BackgroundColor',[0.7 0.7 0.7])
|
---|
| 4727 | set(handles.list_object_1,'Value',1)
|
---|
| 4728 |
|
---|
| 4729 | %prepare display of the set_grid GUI
|
---|
| 4730 | FileName=read_file_boxes(handles);
|
---|
| 4731 | CoordList=get(handles.transform_fct,'String');
|
---|
| 4732 | val=get(handles.transform_fct,'Value');
|
---|
| 4733 | set_grid(FileName,CoordList{val});% call the set_object interface
|
---|
| 4734 | %set(handles.uvmat,'UserData',UvData);
|
---|
| 4735 |
|
---|
| 4736 | %------------------------------------------------------------------------
|
---|
| 4737 | % open the GUI 'series'
|
---|
| 4738 | function MenuSeries_Callback(hObject, eventdata, handles)
|
---|
| 4739 | %------------------------------------------------------------------------
|
---|
| 4740 | series; %first display of the GUI to fill waiting time
|
---|
| 4741 | [param.FileName]=read_file_boxes(handles);
|
---|
| 4742 | if isequal(get(handles.SubField,'Value'),1)
|
---|
| 4743 | FileName_1=read_file_boxes_1(handles);%
|
---|
| 4744 | if ~isequal(FileName_1,param.FileName)
|
---|
| 4745 | param.FileName_1=FileName_1;
|
---|
| 4746 | end
|
---|
| 4747 | end
|
---|
| 4748 | param.NomType=get(handles.FileIndex,'UserData');
|
---|
| 4749 | param.NomType_1=get(handles.FileIndex_1,'UserData');
|
---|
| 4750 | param.comp_input=get(handles.fix_pair,'Value');
|
---|
| 4751 | huvmat=get(handles.MenuSeries,'parent');
|
---|
| 4752 | UvData=get(huvmat,'UserData');
|
---|
| 4753 | if isfield(UvData,'Time')
|
---|
| 4754 | param.Time=UvData.XmlData.Time;
|
---|
| 4755 | end
|
---|
| 4756 | if isequal(get(handles.scan_i,'Value'),1)
|
---|
| 4757 | param.incr_i=str2double(get(handles.increment_scan,'String'));
|
---|
| 4758 | elseif isequal(get(handles.scan_j,'Value'),1)
|
---|
| 4759 | param.incr_j=str2double(get(handles.increment_scan,'String'));
|
---|
| 4760 | end
|
---|
| 4761 | param.list_fields=get(handles.Fields,'String');% list menu fields
|
---|
| 4762 | param.list_fields(1)=[]; %suppress 'image' option
|
---|
| 4763 | param.index_fields=get(handles.Fields,'Value');% selected string index
|
---|
| 4764 | if param.index_fields>1
|
---|
| 4765 | param.index_fields=param.index_fields-1;
|
---|
| 4766 | end
|
---|
| 4767 | param.list_fields_1=get(handles.Fields_1,'String');% list menu fields
|
---|
| 4768 | param.list_fields_1(1)=[]; %suppress 'image' option
|
---|
| 4769 | param.index_fields_1=get(handles.Fields_1,'Value')-1;% selected string index
|
---|
| 4770 | if param.index_fields_1>1
|
---|
| 4771 | param.index_fields_1=param.index_fields_1-1;
|
---|
| 4772 | end
|
---|
[238] | 4773 | % if isequal(get(handles.VelType,'Visible'),'on')
|
---|
| 4774 | % param.VelTypeMenu=get(handles.VelType,'String');
|
---|
| 4775 | % param.VelTypeIndex=get(handles.VelType,'Value');
|
---|
| 4776 | % end
|
---|
| 4777 | % param.civ1=get(handles.VelType,'Value');
|
---|
| 4778 | % param.civ2=get(handles.civ2,'Value');
|
---|
| 4779 | % param.interp1=get(handles.interp1,'Value');
|
---|
| 4780 | % param.interp2=get(handles.interp2,'Value');
|
---|
| 4781 | % param.filter1=get(handles.filter1,'Value');
|
---|
| 4782 | % param.filter2=get(handles.filter2,'Value');
|
---|
[199] | 4783 | param.menu_coord_str=get(handles.transform_fct,'String');
|
---|
| 4784 | param.menu_coord_val=get(handles.transform_fct,'Value');
|
---|
| 4785 |
|
---|
| 4786 | series(param); %run the series interface
|
---|
| 4787 |
|
---|
| 4788 | %------------------------------------------------------------------------
|
---|
| 4789 | % -- open the GUI civ.fig for civx (PIV)
|
---|
| 4790 | function MenuPIV_Callback(hObject, eventdata, handles)
|
---|
| 4791 | %------------------------------------------------------------------------
|
---|
| 4792 |
|
---|
| 4793 | [FileName,RootPath,filebase,FileIndices,ext,SubDir]=read_file_boxes(handles);
|
---|
| 4794 | num1=stra2num(get(handles.i1,'String'));
|
---|
| 4795 | num2=stra2num(get(handles.i2,'String'));
|
---|
| 4796 | num_a=stra2num(get(handles.j1,'String'));
|
---|
| 4797 | num_b=stra2num(get(handles.j2,'String'));
|
---|
| 4798 | NomType=get(handles.FileIndex,'UserData');
|
---|
| 4799 | ind_opening=1; % default (images): will advice civ1 option by default in the civ interface
|
---|
| 4800 | if isequal(ext,'.nc') || isequal(ext,'.cdf')% netcdf files
|
---|
| 4801 | ind_opening=2;% propose 'fix' as the default option
|
---|
| 4802 | % +read the current netcdf rootfile
|
---|
| 4803 | Data=nc2struct(FileName,'ListGlobalAttribute','fix','patch','civ2','fix2');
|
---|
| 4804 | if isfield(Data,'fix') && isequal(Data.fix,1)
|
---|
| 4805 | ind_opening=3;
|
---|
| 4806 | end
|
---|
| 4807 | if isfield(Data,'patch') && isequal(Data.patch,1)
|
---|
| 4808 | ind_opening=4;
|
---|
| 4809 | end
|
---|
| 4810 | if isfield(Data,'civ2') && isequal(Data.civ2,1)
|
---|
| 4811 | ind_opening=5;
|
---|
| 4812 | end
|
---|
| 4813 | if isfield(Data,'fix2') && isequal(Data.fix2,1)
|
---|
| 4814 | ind_opening=6;
|
---|
| 4815 | end
|
---|
| 4816 | end
|
---|
| 4817 | param.RootName=filebase;
|
---|
| 4818 | param.NomType=NomType;
|
---|
| 4819 | param.num1=num1;
|
---|
| 4820 | param.num2=num2;
|
---|
| 4821 | param.num_a=num_a;
|
---|
| 4822 | param.num_b=num_b;
|
---|
| 4823 | param.SubDir=SubDir;
|
---|
| 4824 | param.IndOpening=ind_opening;% A REVOIR +TRANSMETTRE IMADOC INFO
|
---|
| 4825 | param.ImaExt=ext;
|
---|
| 4826 | civ(param);% interface de civ(not in the uvmat file)
|
---|
| 4827 |
|
---|
| 4828 | %------------------------------------------------------------------------
|
---|
| 4829 | function MenuTools_Callback(hObject, eventdata, handles)
|
---|
| 4830 | %------------------------------------------------------------------------
|
---|
| 4831 |
|
---|
| 4832 | %------------------------------------------------------------------------
|
---|
| 4833 | function MenuEditObject_Callback(hObject, eventdata, handles)
|
---|
| 4834 | %------------------------------------------------------------------------
|
---|
| 4835 | set(handles.edit_object,'Value',1)
|
---|
| 4836 | edit_Callback(hObject, eventdata, handles)
|
---|
| 4837 |
|
---|
| 4838 | %------------------------------------------------------------------------
|
---|
| 4839 | function enable_transform(handles,state)
|
---|
| 4840 | %------------------------------------------------------------------------
|
---|
| 4841 | set(handles.transform_fct,'Visible',state)
|
---|
| 4842 | set(handles.TRANSFORM_txt,'Visible',state)
|
---|
| 4843 | set(handles.transform_fct,'Visible',state)
|
---|
| 4844 | set(handles.path_transform,'Visible',state)
|
---|
| 4845 | set(handles.pxcmx_txt,'Visible',state)
|
---|
| 4846 | set(handles.pxcmy_txt,'Visible',state)
|
---|
| 4847 | set(handles.pxcm,'Visible',state)
|
---|
| 4848 | set(handles.pycm,'Visible',state)
|
---|
| 4849 |
|
---|
| 4850 | %------------------------------------------------------------------------
|
---|
| 4851 | function MenuEditVectors_Callback(hObject, eventdata, handles)
|
---|
| 4852 | %------------------------------------------------------------------------
|
---|
| 4853 | set(handles.edit_vect,'Visible','on')
|
---|
| 4854 | set(handles.edit_vect,'Value',1)
|
---|
| 4855 | edit_vect_Callback(hObject, eventdata, handles)
|
---|
| 4856 |
|
---|
| 4857 | % -----------------------------------------------------------------------
|
---|
| 4858 | function Menupoints_Callback(hObject, eventdata, handles)
|
---|
| 4859 | %------------------------------------------------------------------------
|
---|
| 4860 | data.Style='points';
|
---|
| 4861 | data.ProjMode='projection';%default
|
---|
| 4862 | create_object(data,handles)
|
---|
| 4863 |
|
---|
| 4864 | % -----------------------------------------------------------------------
|
---|
| 4865 | function Menuline_Callback(hObject, eventdata, handles)
|
---|
| 4866 | %------------------------------------------------------------------------
|
---|
| 4867 | data.Style='line';
|
---|
| 4868 | data.ProjMode='projection';%default
|
---|
| 4869 | create_object(data,handles)
|
---|
| 4870 |
|
---|
| 4871 | %------------------------------------------------------------------------
|
---|
| 4872 | function Menupolyline_Callback(hObject, eventdata, handles)
|
---|
| 4873 | %------------------------------------------------------------------------
|
---|
| 4874 | data.Style='polyline';
|
---|
| 4875 | data.ProjMode='projection';%default
|
---|
| 4876 | create_object(data,handles)
|
---|
| 4877 |
|
---|
| 4878 | %------------------------------------------------------------------------
|
---|
| 4879 | function Menupolygon_Callback(hObject, eventdata, handles)
|
---|
| 4880 | %------------------------------------------------------------------------
|
---|
| 4881 | data.Style='polygon';
|
---|
| 4882 | data.ProjMode='inside';%default
|
---|
| 4883 | create_object(data,handles)
|
---|
| 4884 |
|
---|
| 4885 | %------------------------------------------------------------------------
|
---|
| 4886 | function Menurectangle_Callback(hObject, eventdata, handles)
|
---|
| 4887 | %------------------------------------------------------------------------
|
---|
| 4888 | data.Style='rectangle';
|
---|
| 4889 | data.ProjMode='inside';%default
|
---|
| 4890 | create_object(data,handles)
|
---|
| 4891 |
|
---|
| 4892 | %------------------------------------------------------------------------
|
---|
| 4893 | function Menuellipse_Callback(hObject, eventdata, handles)
|
---|
| 4894 | %------------------------------------------------------------------------
|
---|
| 4895 | data.Style='ellipse';
|
---|
| 4896 | data.ProjMode='inside';%default
|
---|
| 4897 | create_object(data,handles)
|
---|
| 4898 |
|
---|
| 4899 | %------------------------------------------------------------------------
|
---|
| 4900 | function MenuMaskObject_Callback(hObject, eventdata, handles)
|
---|
| 4901 | %------------------------------------------------------------------------
|
---|
| 4902 | data.Style='polygon';
|
---|
| 4903 | data.StyleMenu={'polygon'};
|
---|
| 4904 | data.ProjMode='mask_inside';%default
|
---|
| 4905 | data.ProjMenu={'mask_inside';'mask_outside'};
|
---|
| 4906 | create_object(data,handles)
|
---|
| 4907 |
|
---|
| 4908 | %------------------------------------------------------------------------
|
---|
| 4909 | function Menuplane_Callback(hObject, eventdata, handles)
|
---|
| 4910 | %------------------------------------------------------------------------
|
---|
| 4911 | data.Style='plane';
|
---|
| 4912 | data.ProjMode='projection';%default
|
---|
| 4913 |
|
---|
| 4914 | create_object(data,handles)
|
---|
| 4915 |
|
---|
| 4916 | %------------------------------------------------------------------------
|
---|
| 4917 | function Menuvolume_Callback(hObject, eventdata, handles)
|
---|
| 4918 | %------------------------------------------------------------------------
|
---|
| 4919 | data.Style='volume';
|
---|
| 4920 | data.ProjMode='interp';%default
|
---|
| 4921 | % set(handles.create,'Visible','on')
|
---|
| 4922 | % set(handles.create,'Value',1)
|
---|
| 4923 | % VOLUME_Callback(hObject,eventdata,handles)
|
---|
| 4924 | create_object(data,handles)
|
---|
| 4925 |
|
---|
| 4926 | %------------------------------------------------------------------------
|
---|
| 4927 | function MenuBrowseObject_Callback(hObject, eventdata, handles)
|
---|
| 4928 | %------------------------------------------------------------------------
|
---|
| 4929 | %get the object file
|
---|
| 4930 | [FileName, PathName, filterindex] = uigetfile( ...
|
---|
| 4931 | {'*.xml;*.mat', ' (*.xml,*.mat)';
|
---|
| 4932 | '*.xml', '.xml files '; ...
|
---|
| 4933 | '*.mat', '.mat matlab files '}, ...
|
---|
| 4934 | 'Pick an xml Object file',get(handles.RootPath,'String'));
|
---|
| 4935 | fileinput=[PathName FileName];%complete file name
|
---|
| 4936 | % testblank=findstr(fileinput,' ');%look for blanks
|
---|
| 4937 | % if ~isempty(testblank)
|
---|
| 4938 | % msgbox_uvmat('ERROR','forbidden input file name: contain blanks')
|
---|
| 4939 | % return
|
---|
| 4940 | % end
|
---|
| 4941 | sizf=size(fileinput);
|
---|
| 4942 | if (~ischar(fileinput)||~isequal(sizf(1),1)),return;end
|
---|
| 4943 |
|
---|
| 4944 | %read the file
|
---|
| 4945 | t=xmltree(fileinput);
|
---|
| 4946 | data=convert(t);
|
---|
| 4947 | data.enable_plot=1;
|
---|
| 4948 | [pp,data.Name]=fileparts(FileName);
|
---|
| 4949 | %PlotHandles=get_plot_handles(handles);%get the handles of the interface elements setting the plotting parameters
|
---|
| 4950 | hset_object=findobj(allchild(0),'tag','set_object');
|
---|
| 4951 | if ~isempty(hset_object)
|
---|
| 4952 | delete(hset_object)% delete existing version of set_object
|
---|
| 4953 | end
|
---|
| 4954 | % UvData=get(handles.uvmat,'UserData');
|
---|
| 4955 | set_object(data);% call the set_object interface
|
---|
| 4956 | % %position the set_object GUI with respect to uvmat
|
---|
| 4957 | % pos_uvmat=get(handles.uvmat,'Position');
|
---|
| 4958 | % if isfield(UvData,'SetObjectOrigin')
|
---|
| 4959 | % pos_set_object(1:2)=UvData.SetObjectOrigin + pos_uvmat(1:2);
|
---|
| 4960 | % pos_set_object(3:4)=UvData.SetObjectSize .* pos_uvmat(3:4);
|
---|
| 4961 | % set(hset_object,'Position',pos_set_object)
|
---|
| 4962 | % end
|
---|
| 4963 | set(handles.edit_object,'Value',0); %suppress the object edit mode
|
---|
| 4964 | set(handles.edit_object,'BackgroundColor',[0.7,0.7,0.7])
|
---|
| 4965 | set(handles.MenuObject,'checked','on')
|
---|
| 4966 | %UvData.MouseAction='create_object';
|
---|
| 4967 | % set(handles.uvmat,'UserData',UvData)
|
---|
| 4968 | set(handles.delete_object,'Visible','on')
|
---|
| 4969 | set(handles.uvmat_title,'Visible','on')
|
---|
| 4970 | set(handles.view_field_title,'Visible','on')
|
---|
| 4971 |
|
---|
| 4972 | %------------------------------------------------------------------------
|
---|
| 4973 | % --- generic function used for the creation of a projection object
|
---|
| 4974 | function create_object(data,handles)
|
---|
| 4975 | %------------------------------------------------------------------------
|
---|
| 4976 | hset_object=findobj(allchild(0),'tag','set_object');
|
---|
| 4977 | if ~isempty(hset_object)
|
---|
| 4978 | delete(hset_object)% delete existing version of set_object
|
---|
| 4979 | end
|
---|
| 4980 | hgeometry_calib=findobj(allchild(0),'tag','geometry_calib');
|
---|
| 4981 | if ishandle(hgeometry_calib)
|
---|
| 4982 | hhgeometry_calib=guidata(hgeometry_calib);
|
---|
| 4983 | set(hhgeometry_calib.edit_append,'Value',0)% desactivate mouse action in geometry_calib
|
---|
| 4984 | set(hhgeometry_calib.edit_append,'BackgroundColor',[0.7 0.7 0.7])
|
---|
| 4985 | end
|
---|
| 4986 | UvData=get(handles.uvmat,'UserData');
|
---|
| 4987 | set(handles.edit_object,'Value',0); %suppress the object edit mode
|
---|
| 4988 | set(handles.edit_object,'BackgroundColor',[0.7,0.7,0.7])
|
---|
| 4989 | data.enable_plot=1;
|
---|
| 4990 | transform_list=get(handles.transform_fct,'String');
|
---|
| 4991 | val=get(handles.transform_fct,'Value');
|
---|
| 4992 | %data.CoordType=transform_list{val};
|
---|
| 4993 | if isfield(UvData,'Field')
|
---|
| 4994 | Field=UvData.Field;
|
---|
| 4995 | if isfield(Field,'Mesh')&&~isempty(Field.Mesh)
|
---|
| 4996 | data.RangeX=Field.Mesh;
|
---|
| 4997 | data.RangeY=Field.Mesh;
|
---|
| 4998 | data.DX=Field.Mesh;
|
---|
| 4999 | data.DY=Field.Mesh;
|
---|
| 5000 | elseif isfield(Field,'AX')&& isfield(Field,'AY')&& isfield(Field,'A')%only image
|
---|
| 5001 | np=size(Field.A);
|
---|
| 5002 | meshx=(Field.AX(end)-Field.AX(1))/np(2);
|
---|
| 5003 | meshy=abs(Field.AY(end)-Field.AY(1))/np(1);
|
---|
| 5004 | data.RangeY=max(meshx,meshy);
|
---|
| 5005 | data.RangeX=max(meshx,meshy);
|
---|
| 5006 | data.DX=max(meshx,meshy);
|
---|
| 5007 | end
|
---|
| 5008 | if isfield(Field,'NbDim')
|
---|
| 5009 | data.NbDim=Field.NbDim;
|
---|
| 5010 | end
|
---|
| 5011 | if isfield(Field,'CoordUnit')
|
---|
| 5012 | data.CoordUnit=Field.CoordUnit;
|
---|
| 5013 | end
|
---|
| 5014 | end
|
---|
| 5015 | data.Coord=[0 0 0]; %default
|
---|
| 5016 | if isfield(data,'Style') && isequal(data.Style,'line')
|
---|
| 5017 | if isfield(data,'DX')
|
---|
| 5018 | data.Coord=[[0 0 0];[data.DX 0 0]]; %default
|
---|
| 5019 | else
|
---|
| 5020 | data.Coord=[[0 0 0];[1 0 0]]; %default
|
---|
| 5021 | end
|
---|
| 5022 | end
|
---|
| 5023 | if ishandle(handles.UVMAT_title)
|
---|
| 5024 | delete(handles.UVMAT_title)%delete the initial display of uvmat if no field has been entered
|
---|
| 5025 | end
|
---|
| 5026 | %PlotHandles=get_plot_handles(handles);%get the handles of the interface elements setting the plotting parameters
|
---|
| 5027 | set_object(data,handles);% call the set_object interface
|
---|
| 5028 | set(handles.MenuObject,'checked','on')
|
---|
| 5029 | set(handles.uvmat,'UserData',UvData)
|
---|
| 5030 | set(handles.zoom,'Value',0)
|
---|
| 5031 | zoom_Callback(handles.uvmat, [], handles)
|
---|
| 5032 | set(handles.delete_object,'Visible','on')
|
---|
| 5033 | set(handles.uvmat_title,'Visible','on')
|
---|
| 5034 | set(handles.view_field_title,'Visible','on')
|
---|
| 5035 |
|
---|
| 5036 | %------------------------------------------------------------------------
|
---|
| 5037 | function MenuRuler_Callback(hObject, eventdata, handles)
|
---|
| 5038 | %------------------------------------------------------------------------
|
---|
| 5039 | set(handles.zoom,'Value',0)
|
---|
| 5040 | zoom_Callback(handles.uvmat, [], handles)
|
---|
| 5041 | set(handles.MenuRuler,'checked','on')
|
---|
| 5042 | UvData=get(handles.uvmat,'UserData');
|
---|
| 5043 | UvData.MouseAction='ruler';
|
---|
| 5044 | set(handles.uvmat,'UserData',UvData);
|
---|
| 5045 |
|
---|
| 5046 | %------------------------------------------------------------------------
|
---|
| 5047 | % --- executed when closing: set the parent interface button to value 0
|
---|
| 5048 | function closefcn(gcbo,eventdata)
|
---|
| 5049 | %------------------------------------------------------------------------
|
---|
| 5050 | %delete all the associated figures if exist
|
---|
| 5051 | hh=findobj(allchild(0),'tag','view_field');
|
---|
| 5052 | if ~isempty(hh)
|
---|
| 5053 | delete(hh)
|
---|
| 5054 | end
|
---|
| 5055 | hh=findobj(allchild(0),'tag','geometry_calib');
|
---|
| 5056 | if ~isempty(hh)
|
---|
| 5057 | delete(hh)
|
---|
| 5058 | end
|
---|
| 5059 | hh=findobj(allchild(0),'tag','set_object');
|
---|
| 5060 | if ~isempty(hh)
|
---|
| 5061 | hhh=findobj(hh,'tag','PLOT');
|
---|
| 5062 | set(hhh,'enable','off')
|
---|
| 5063 | end
|
---|
| 5064 |
|
---|
| 5065 | %------------------------------------------------------------------------
|
---|
| 5066 | % --- Executes on button press in delete_object.
|
---|
| 5067 | function delete_object_Callback(hObject, eventdata, handles)
|
---|
| 5068 | %------------------------------------------------------------------------
|
---|
| 5069 | IndexObj=get(handles.list_object_2,'Value');
|
---|
| 5070 | if IndexObj>1
|
---|
| 5071 | delete_object(IndexObj)
|
---|
| 5072 | end
|
---|
| 5073 |
|
---|
[236] | 5074 | % --- Executes on button press in FixVelType.
|
---|
| 5075 | function FixVelType_Callback(hObject, eventdata, handles)
|
---|
| 5076 | val=get(handles.FixVelType,'Value');
|
---|
| 5077 | if ~val
|
---|
| 5078 | run0_Callback(hObject, eventdata, handles)
|
---|
| 5079 | end
|
---|
[199] | 5080 |
|
---|
[236] | 5081 |
|
---|