[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
|
---|
[292] | 149 | % = CheckZoom: isolate a subregion for CheckZoom in=1 if an object is being currently drawn, 0 else (set to 0 by releasing mouse button)
|
---|
[199] | 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
|
---|
[292] | 153 | % .CurrentRectZoom: current rectangle used for CheckZoom
|
---|
[199] | 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})%
|
---|
| 238 |
|
---|
| 239 | %% refresh projection plane
|
---|
| 240 | UvData.Object{1}.ProjMode='projection';%main plotting plane
|
---|
| 241 | set(handles.Fields,'Value',1)
|
---|
| 242 | set(handles.Fields,'string',{''})
|
---|
| 243 |
|
---|
| 244 | %% TRANSFORM menu: builtin fcts
|
---|
| 245 | menu_str={'';'phys';'px';'phys_polar'};
|
---|
| 246 | UvData.OpenParam.NbBuiltin=numel(menu_str); %number of functions
|
---|
| 247 | path_uvmat=fileparts(which('uvmat'));
|
---|
[276] | 248 | 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)
|
---|
| 249 | addpath(fullfile(path_uvmat,'transform_field'))%add the path to transform functions,
|
---|
[199] | 250 | fct_handle{1,1}=[];
|
---|
| 251 | testexist=zeros(size(menu_str'));%default
|
---|
| 252 | testexist(1)=1;
|
---|
| 253 | for ilist=2:length(menu_str)
|
---|
| 254 | if exist(menu_str{ilist},'file')
|
---|
| 255 | fct_handle{ilist,1}=str2func(menu_str{ilist});
|
---|
| 256 | testexist(ilist)=1;
|
---|
| 257 | else
|
---|
| 258 | testexist(ilist)=0;
|
---|
| 259 | end
|
---|
| 260 | end
|
---|
| 261 | rmpath(fullfile(path_uvmat,'transform_field'))
|
---|
| 262 |
|
---|
| 263 | %% load the list of previously browsed files in menus Open and Open_1
|
---|
| 264 | dir_perso=prefdir; % path to the directory .matlab for personal data
|
---|
| 265 | profil_perso=fullfile(dir_perso,'uvmat_perso.mat');% personal data file uvmauvmat_perso.mat' in .matlab
|
---|
| 266 | if exist(profil_perso,'file')
|
---|
| 267 | h=load (profil_perso);
|
---|
[296] | 268 | if isfield(h,'MenuFile')
|
---|
| 269 | for ifile=1:min(length(h.MenuFile),5)
|
---|
| 270 | eval(['set(handles.MenuFile_' num2str(ifile) ',''Label'',h.MenuFile{ifile});'])
|
---|
| 271 | eval(['set(handles.MenuFile_' num2str(ifile) '_1,''Label'',h.MenuFile{ifile});'])
|
---|
| 272 | end
|
---|
[199] | 273 | end
|
---|
| 274 | if isfield(h,'transform_fct') && iscell(h.transform_fct)
|
---|
| 275 | for ilist=1:length(h.transform_fct);
|
---|
| 276 | if exist(h.transform_fct{ilist},'file')
|
---|
| 277 | [path,file]=fileparts(h.transform_fct{ilist});
|
---|
| 278 | addpath(path)
|
---|
| 279 | h_func=str2func(file);
|
---|
| 280 | rmpath(path)
|
---|
| 281 | testexist=[testexist 1];
|
---|
| 282 | else
|
---|
| 283 | file='';
|
---|
| 284 | h_func=[];
|
---|
| 285 | testexist=[testexist 0];
|
---|
| 286 | end
|
---|
| 287 | fct_handle=[fct_handle; {h_func}]; %concatene the list of paths
|
---|
| 288 | menu_str=[menu_str; {file}];
|
---|
| 289 | end
|
---|
| 290 | end
|
---|
| 291 | end
|
---|
| 292 | menu_str=menu_str(testexist==1);%=menu_str(testexist~=0)
|
---|
| 293 | fct_handle=fct_handle(testexist==1);
|
---|
| 294 | menu_str=[menu_str;{'more...'}];
|
---|
| 295 | set(handles.transform_fct,'String',menu_str)
|
---|
| 296 | set(handles.transform_fct,'UserData',fct_handle)% store the list of path in UserData of ACTION
|
---|
| 297 |
|
---|
| 298 | %% case of an input argument for uvmat
|
---|
| 299 | testinputfield=0;
|
---|
| 300 | inputfile=[];
|
---|
| 301 | Field=[];
|
---|
| 302 | if exist('input','var')
|
---|
[299] | 303 | % if ~isempty(errormsg)
|
---|
| 304 | % msgbox_uvmat('WARNING',errormsg)
|
---|
| 305 | % end
|
---|
[199] | 306 | if ishandle(handles.UVMAT_title)
|
---|
| 307 | delete(handles.UVMAT_title)
|
---|
| 308 | end
|
---|
| 309 | if isstruct(input)
|
---|
| 310 | if isfield(input,'InputFile')
|
---|
| 311 | inputfile=input.InputFile;
|
---|
| 312 | end
|
---|
[231] | 313 | if isfield(input,'TimeIndex')
|
---|
| 314 | set(handles.i1,num2str(input.TimeIndex))
|
---|
[227] | 315 | end
|
---|
[231] | 316 | if isfield(input,'FieldsString')
|
---|
| 317 | % set(handles.Fields,'Value',1)
|
---|
| 318 | UvData.FieldsString=input.FieldsString;
|
---|
| 319 | end
|
---|
[199] | 320 | elseif ischar(input)% file name introduced as input
|
---|
| 321 | inputfile=input;
|
---|
| 322 | elseif isnumeric(input)%simple matrix introduced as input
|
---|
| 323 | sizinput=size(input);
|
---|
| 324 | if sizinput(1)<=1 || sizinput(2)<=1
|
---|
| 325 | msgbox_uvmat('ERROR','bad input for uvmat: file name, structure or numerical matrix accepted')
|
---|
| 326 | return
|
---|
| 327 | end
|
---|
[231] | 328 | UvData.Field.ListVarName={'A','coord_y','coord_x'};
|
---|
| 329 | UvData.Field.VarDimName={{'coord_y','coord_x'},'cord_y','coord_x'};
|
---|
| 330 | UvData.Field.A=input;
|
---|
| 331 | UvData.Field.coord_x=[0.5 size(input,2)-0.5];
|
---|
| 332 | UvData.Field.coord_y=[size(input,1)-0.5 0.5];
|
---|
[199] | 333 | testinputfield=1;
|
---|
| 334 | end
|
---|
| 335 | else
|
---|
| 336 | if ishandle(handles.UVMAT_title)
|
---|
[277] | 337 | set(handles.UVMAT_title,'String',...
|
---|
| 338 | [{'Copyright LEGI UMR 5519 /CNRS-UJF-Grenoble INP, 2010'};...
|
---|
| 339 | {'GNU General Public License'};...
|
---|
| 340 | {path_to_uvmat};...
|
---|
| 341 | {date_str};...
|
---|
[278] | 342 | {['SVN revision : ' num2str(svn_info.cur_rev)]};...
|
---|
[277] | 343 | errormsg]);
|
---|
[199] | 344 | end
|
---|
| 345 | end
|
---|
[231] | 346 | set(handles.uvmat,'UserData',UvData)
|
---|
| 347 | if ~isempty(inputfile)
|
---|
| 348 | %%%%% display the input field %%%%%%%
|
---|
| 349 | display_file_name(hObject, eventdata, handles,inputfile)
|
---|
| 350 | %%%%%%%
|
---|
| 351 | testinputfield=1;
|
---|
| 352 | end
|
---|
[199] | 353 |
|
---|
| 354 | %% plot input field if exists
|
---|
| 355 | if testinputfield
|
---|
| 356 | %delete drawn objects
|
---|
| 357 | hother=findobj(handles.axes3,'Tag','proj_object');%find all the proj objects
|
---|
| 358 | for iobj=1:length(hother)
|
---|
| 359 | delete_object(hother(iobj))
|
---|
| 360 | end
|
---|
| 361 | if isempty(inputfile)
|
---|
| 362 | errormsg=refresh_field(handles,[],[],[],[],[],[],{Field});
|
---|
| 363 | set(handles.MenuTools,'Enable','on')
|
---|
| 364 | set(handles.OBJECT_txt,'Visible','on')
|
---|
| 365 | set(handles.edit_object,'Visible','on')
|
---|
[302] | 366 | set(handles.ListObject,'Visible','on')
|
---|
[199] | 367 | set(handles.frame_object,'Visible','on')
|
---|
| 368 | if ~isempty(errormsg)
|
---|
| 369 | msgbox_uvmat('ERROR',errormsg)
|
---|
| 370 | end
|
---|
| 371 | end
|
---|
| 372 | end
|
---|
[236] | 373 |
|
---|
[199] | 374 | set_vec_col_bar(handles) %update the display of color code for vectors
|
---|
| 375 |
|
---|
| 376 | %------------------------------------------------------------------------
|
---|
| 377 | % --- Outputs from this function are returned to the command menuline.
|
---|
| 378 | function varargout = uvmat_OutputFcn(hObject, eventdata, handles)
|
---|
| 379 | varargout{1} = handles.output;% the only output argument is the handle to the GUI figure
|
---|
| 380 |
|
---|
| 381 | %------------------------------------------------------------------------
|
---|
| 382 | %------------------------------------------------------------------------
|
---|
| 383 | % II - FUNCTIONS FOR INTRODUCING THE INPUT FILES
|
---|
| 384 | % automatically sets the global properties when the rootfile name is introduced
|
---|
| 385 | % then activate the view-field action if selected
|
---|
| 386 | % it is activated either by clicking on the RootPath window or by the
|
---|
| 387 | % browser
|
---|
| 388 | %------------------------------------------------------------------------
|
---|
| 389 | %------------------------------------------------------------------------
|
---|
| 390 | % --- Executes on the menu Open/Browse...
|
---|
| 391 | % search the files, recognize their type according to their name and fill the rootfile input windows
|
---|
| 392 | function MenuBrowse_Callback(hObject, eventdata, handles)
|
---|
| 393 | oldfile=read_file_boxes(handles);
|
---|
| 394 |
|
---|
| 395 | if isempty(oldfile)||isequal(oldfile,'') %loads the previously stored file name and set it as default in the file_input box
|
---|
| 396 | dir_perso=prefdir;
|
---|
| 397 | profil_perso=fullfile(dir_perso,'uvmat_perso.mat');
|
---|
| 398 | if exist(profil_perso,'file')
|
---|
| 399 | h=load (profil_perso);
|
---|
| 400 | if isfield(h,'MenuFile_1')
|
---|
| 401 | oldfile=h.MenuFile_1;
|
---|
| 402 | end
|
---|
| 403 | end
|
---|
| 404 | end
|
---|
| 405 | [FileName, PathName] = uigetfile( ...
|
---|
| 406 | {'*.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)';
|
---|
| 407 | '*.xml', '.xml files '; ...
|
---|
| 408 | '*.xls', '.xls files '; ...
|
---|
| 409 | '*.civ', '.civ files '; ...
|
---|
| 410 | '*.jpg',' jpeg image files'; ...
|
---|
| 411 | '*.png','.png image files'; ...
|
---|
| 412 | '*.tif','.tif image files'; ...
|
---|
| 413 | '*.avi;*.AVI','.avi movie files'; ...
|
---|
| 414 | '*.vol','.volume images (png)'; ...
|
---|
| 415 | '*.nc','.netcdf files'; ...
|
---|
| 416 | '*.cdf','.netcdf files'; ...
|
---|
| 417 | '*.cmx','.cmx text files ';...
|
---|
| 418 | '*.fig','.fig files (matlab fig)';...
|
---|
| 419 | '*.log','.log text files ';...
|
---|
| 420 | '*.dat','.dat text files ';...
|
---|
| 421 | '*.bat','.bat system command text files';...
|
---|
| 422 | '*.*', 'All Files (*.*)'}, ...
|
---|
| 423 | 'Pick a file',oldfile);
|
---|
| 424 | fileinput=[PathName FileName];%complete file name
|
---|
| 425 | sizf=size(fileinput);
|
---|
| 426 | if (~ischar(fileinput)||~isequal(sizf(1),1)),return;end
|
---|
| 427 |
|
---|
| 428 | % display the selected field and related information
|
---|
| 429 | display_file_name(hObject, eventdata, handles,fileinput)
|
---|
| 430 |
|
---|
| 431 | % -----------------------------------------------------------------------
|
---|
| 432 | % --- Open again the file whose name has been recorded in MenuFile_1
|
---|
| 433 | function MenuFile_1_Callback(hObject, eventdata, handles)
|
---|
[227] | 434 | %------------------------------------------------------------------------
|
---|
[199] | 435 | fileinput=get(handles.MenuFile_1,'Label');
|
---|
| 436 | display_file_name(hObject, eventdata, handles,fileinput)
|
---|
| 437 |
|
---|
| 438 | % -----------------------------------------------------------------------
|
---|
| 439 | % --- Open again the file whose name has been recorded in MenuFile_2
|
---|
| 440 | function MenuFile_2_Callback(hObject, eventdata, handles)
|
---|
[227] | 441 | %------------------------------------------------------------------------
|
---|
[199] | 442 | fileinput=get(handles.MenuFile_2,'Label');
|
---|
| 443 | display_file_name(hObject, eventdata, handles,fileinput)
|
---|
| 444 |
|
---|
| 445 | % -----------------------------------------------------------------------
|
---|
| 446 | % --- Open again the file whose name has been recorded in MenuFile_3
|
---|
| 447 | function MenuFile_3_Callback(hObject, eventdata, handles)
|
---|
[227] | 448 | %------------------------------------------------------------------------
|
---|
[199] | 449 | fileinput=get(handles.MenuFile_3,'Label');
|
---|
| 450 | display_file_name(hObject, eventdata, handles,fileinput)
|
---|
| 451 |
|
---|
| 452 | % -----------------------------------------------------------------------
|
---|
| 453 | % --- Open again the file whose name has been recorded in MenuFile_4
|
---|
| 454 | function MenuFile_4_Callback(hObject, eventdata, handles)
|
---|
[227] | 455 | %------------------------------------------------------------------------
|
---|
[199] | 456 | fileinput=get(handles.MenuFile_4,'Label');
|
---|
| 457 | display_file_name(hObject, eventdata, handles,fileinput)
|
---|
| 458 |
|
---|
| 459 | % -----------------------------------------------------------------------
|
---|
| 460 | % --- Open again the file whose name has been recorded in MenuFile_5
|
---|
| 461 | function MenuFile_5_Callback(hObject, eventdata, handles)
|
---|
[227] | 462 | %------------------------------------------------------------------------
|
---|
[199] | 463 | fileinput=get(handles.MenuFile_5,'Label');
|
---|
| 464 | display_file_name(hObject, eventdata, handles,fileinput)
|
---|
| 465 |
|
---|
| 466 | %------------------------------------------------------------------------
|
---|
| 467 | % --- Fills the edit boxes RootPath, RootFile,NomType...from an input file name 'fileinput'
|
---|
| 468 | function display_file_name(hObject, eventdata, handles,fileinput)
|
---|
[227] | 469 | %------------------------------------------------------------------------
|
---|
[334] | 470 | %% analyse the input file
|
---|
[199] | 471 | if ~exist(fileinput,'file')
|
---|
| 472 | msgbox_uvmat('ERROR',['input file ' fileinput ' does not exist'])
|
---|
| 473 | return
|
---|
| 474 | end
|
---|
[334] | 475 | % detect root name, nomenclature and indices in the input file name:
|
---|
[339] | 476 | [~,SubDir,~,i1,i2,j1,j2,FileExt]=fileparts_uvmat(fileinput);
|
---|
[334] | 477 | % detect the file type, get the movie object if relevant, and look for the corresponding file series:
|
---|
[339] | 478 | % [i1_series,i2_series,j1_series,j2_series,NomType,FileType,MovieObject]=find_file_series(fileinput);
|
---|
| 479 | [RootPath,RootFile,i1_series,i2_series,j1_series,j2_series,NomType,FileType,MovieObject]=find_file_series(fileinput);
|
---|
[334] | 480 | % open the file or fill the GUI uvmat according to the detected file type
|
---|
| 481 | switch FileType
|
---|
| 482 | case ''
|
---|
| 483 | msgbox_uvmat('ERROR','invalid input file type')
|
---|
| 484 | case 'txt'
|
---|
[199] | 485 | edit(fileinput)
|
---|
[334] | 486 | case 'figure' %display matlab figure
|
---|
[199] | 487 | hfig=open(fileinput);
|
---|
| 488 | set(hfig,'WindowButtonMotionFcn','mouse_motion')%set mouse action functio
|
---|
| 489 | set(hfig,'WindowButtonUpFcn','mouse_up')%set mouse click action function
|
---|
| 490 | set(hfig,'WindowButtonUpFcn','mouse_down')%set mouse click action function
|
---|
[334] | 491 | case {'xml','xls'} % edit xml or Excel files
|
---|
[199] | 492 | editxml(fileinput);
|
---|
[334] | 493 | otherwise
|
---|
[199] | 494 | set(handles.RootPath,'String',RootPath);
|
---|
| 495 | if isequal(SubDir,'')
|
---|
| 496 | rootname=fullfile(RootPath,RootFile);
|
---|
| 497 | else
|
---|
| 498 | rootname=fullfile(RootPath,SubDir,RootFile);
|
---|
| 499 | SubDir=['/' SubDir]; %display the separator
|
---|
| 500 | end
|
---|
| 501 | set(handles.SubDir,'String',SubDir);
|
---|
| 502 | set(handles.RootFile,'String',['/' RootFile]); %display the separator
|
---|
| 503 | indices=fileinput(length(rootname)+1:end);
|
---|
[334] | 504 | indices(end-length(FileExt)+1:end)=[]; %remove extension
|
---|
[199] | 505 | set(handles.FileIndex,'String',indices);
|
---|
[323] | 506 | % set(handles.FileIndex,'UserData',NomType);
|
---|
[334] | 507 | set(handles.NomType,'String',NomType);
|
---|
| 508 | set(handles.FileExt,'String',FileExt);
|
---|
[199] | 509 | % fill file index counters
|
---|
[334] | 510 | set(handles.i1,'String',num2str(i1));
|
---|
| 511 | set(handles.i2,'String',num2str(i2));
|
---|
| 512 | set(handles.j1,'String',num2str(j1));
|
---|
| 513 | set(handles.j2,'String',num2str(j2));
|
---|
[199] | 514 |
|
---|
| 515 | % synchronise indices of the second input file if it exists
|
---|
| 516 | if get(handles.SubField,'Value')==1% if the subfield button is activated, update the field numbers
|
---|
| 517 | [ff,rr,FileBase_1,ii,FileExt_1,SubDir_1]=read_file_boxes_1(handles);
|
---|
[323] | 518 | NomType_1=get(handles.NomType_1,'String');
|
---|
| 519 | % NomType_1=get(handles.FileIndex_1,'UserData');
|
---|
[334] | 520 | FileName_1=name_generator(FileBase_1,i1,i2,FileExt_1,NomType_1,1,j1,j2,SubDir_1);
|
---|
[199] | 521 | if exist(FileName_1,'file')
|
---|
[334] | 522 | FileIndex_1=name_generator('',i1,i2,'',NomType_1,1,j1,j2,'');
|
---|
[199] | 523 | set(handles.FileIndex_1,'String',FileIndex_1)
|
---|
| 524 | else
|
---|
| 525 | set(handles.SubField,'Value',0)
|
---|
| 526 | SubField_Callback(hObject, eventdata, handles)
|
---|
| 527 | end
|
---|
| 528 | end
|
---|
| 529 |
|
---|
| 530 | %enable other menus
|
---|
| 531 | set(handles.MenuOpen_1,'Enable','on')
|
---|
| 532 | set(handles.MenuFile_1_1,'Enable','on')
|
---|
| 533 | set(handles.MenuFile_2_1,'Enable','on')
|
---|
| 534 | set(handles.MenuFile_3_1,'Enable','on')
|
---|
| 535 | set(handles.MenuFile_4_1,'Enable','on')
|
---|
| 536 | set(handles.MenuFile_5_1,'Enable','on')
|
---|
| 537 | set(handles.MenuExport,'Enable','on')
|
---|
| 538 | set(handles.MenuExportFigure,'Enable','on')
|
---|
| 539 | set(handles.MenuExportMovie,'Enable','on')
|
---|
| 540 | set(handles.MenuTools,'Enable','on')
|
---|
| 541 | set(handles.OBJECT_txt,'Visible','on')
|
---|
| 542 | set(handles.edit_object,'Visible','on')
|
---|
[302] | 543 | set(handles.ListObject,'Visible','on')
|
---|
[199] | 544 | set(handles.frame_object,'Visible','on')
|
---|
[334] | 545 |
|
---|
| 546 | % initiate input file series and refresh the current field view:
|
---|
| 547 | update_rootinfo(handles,i1_series,i2_series,j1_series,j2_series,FileType,MovieObject);
|
---|
[199] | 548 | end
|
---|
| 549 |
|
---|
| 550 | %------------------------------------------------------------------------
|
---|
| 551 | % --- Called by action in RootPath edit box
|
---|
| 552 | function RootPath_Callback(hObject,eventdata,handles)
|
---|
| 553 | %------------------------------------------------------------------------
|
---|
[334] | 554 | % read the current input file name:
|
---|
| 555 | fileinput=read_file_boxes(handles);
|
---|
| 556 | % detect the file type, get the movie object if relevant, and look for the corresponding file series:
|
---|
[341] | 557 | [RootPath,RootFile,i1_series,i2_series,j1_series,j2_series,~,FileType,MovieObject]=find_file_series(fileinput);
|
---|
[334] | 558 | % initiate the input file series and refresh the current field view:
|
---|
| 559 | update_rootinfo(handles,i1_series,i2_series,j1_series,j2_series,FileType,MovieObject);
|
---|
[199] | 560 |
|
---|
| 561 | %------------------------------------------------------------------------
|
---|
| 562 | % --- Called by action in RootFile edit box
|
---|
| 563 | function SubDir_Callback(hObject, eventdata, handles)
|
---|
| 564 | %------------------------------------------------------------------------
|
---|
| 565 | %refresh the menu of input fields
|
---|
| 566 | Fields_Callback(hObject, eventdata, handles);
|
---|
[334] | 567 | % refresh the current field view
|
---|
[199] | 568 | run0_Callback(hObject, eventdata, handles);
|
---|
| 569 |
|
---|
| 570 | %------------------------------------------------------------------------
|
---|
| 571 | % --- Called by action in RootFile edit box
|
---|
| 572 | function RootFile_Callback(hObject, eventdata, handles)
|
---|
| 573 | %------------------------------------------------------------------------
|
---|
[334] | 574 | RootPath_Callback(hObject,eventdata,handles)
|
---|
[199] | 575 |
|
---|
| 576 | %------------------------------------------------------------------------
|
---|
| 577 | % --- Called by action in FileIndex edit box
|
---|
| 578 | function FileIndex_Callback(hObject, eventdata, handles)
|
---|
| 579 | %------------------------------------------------------------------------
|
---|
[334] | 580 | [~,~,~,i1,i2,j1,j2]=fileparts_uvmat(get(handles.FileIndex,'String'));
|
---|
| 581 | set(handles.i1,'String',num2str(i1));
|
---|
| 582 | set(handles.i2,'String',num2str(i2));
|
---|
| 583 | set(handles.j1,'String',num2str(j1));
|
---|
| 584 | set(handles.j2,'String',num2str(j2));
|
---|
| 585 |
|
---|
| 586 | % refresh the current field view
|
---|
[199] | 587 | run0_Callback(hObject, eventdata, handles)
|
---|
| 588 |
|
---|
| 589 | %------------------------------------------------------------------------
|
---|
| 590 | % --- Update information about a new field series (indices to scan, timing,
|
---|
| 591 | % calibration from an xml file, then refresh current plots
|
---|
[334] | 592 | function update_rootinfo(handles,i1_series,i2_series,j1_series,j2_series,FileType,MovieObject)
|
---|
[199] | 593 | %------------------------------------------------------------------------
|
---|
| 594 | set(handles.RootPath,'BackgroundColor',[1 1 0])
|
---|
| 595 | drawnow
|
---|
| 596 | set(handles.Fields,'UserData',[])% reinialize data from uvmat opening
|
---|
| 597 | UvData=get(handles.uvmat,'UserData');%huvmat=handles of the uvmat interface
|
---|
| 598 | UvData.NewSeries=1; %flag for run0: begin a new series
|
---|
| 599 | UvData.TestInputFile=1;
|
---|
[334] | 600 | UvData.FileType=FileType;
|
---|
[199] | 601 | set(handles.fix_pair,'Value',1) % activate by default the comp_input '-'input window
|
---|
[236] | 602 | set(handles.FixVelType,'Value',0); %desactivate fixed veltype
|
---|
[199] | 603 | [FileName,RootPath,FileBase,FileIndices,FileExt,SubDir]=read_file_boxes(handles);
|
---|
[334] | 604 |
|
---|
[199] | 605 | if ~exist(FileName,'file')
|
---|
| 606 | msgbox_uvmat('ERROR',['input file ' FileName ' not found']);
|
---|
| 607 | return
|
---|
| 608 | end
|
---|
| 609 | nbfield=[];%default
|
---|
[334] | 610 | nbfield_j=[];%default
|
---|
[199] | 611 |
|
---|
| 612 | % read timing and total frame number from the current file (movie files) !! may be overrid by xml file
|
---|
| 613 | XmlData.Time=[];%default
|
---|
| 614 | XmlData.GeometryCalib=[];%default
|
---|
| 615 | TimeUnit=[];%default
|
---|
| 616 | testima=0; %test for image input
|
---|
| 617 | imainfo=[];
|
---|
| 618 | ColorType='falsecolor'; %default
|
---|
| 619 | hhh='';
|
---|
| 620 | if isequal(lower(FileExt),'.avi') %.avi file
|
---|
| 621 | testima=1;
|
---|
| 622 | imainfo=aviinfo([FileBase FileIndices FileExt]);
|
---|
| 623 | nbfield=imainfo.NumFrames;
|
---|
[334] | 624 | nbfield_j=1;
|
---|
[199] | 625 | set(handles.Dt_txt,'String',['Dt=' num2str(1000/imainfo.FramesPerSecond) 'ms']);%display the elementary time interval in millisec
|
---|
| 626 | XmlData.Time=(0:1/imainfo.FramesPerSecond:(imainfo.NumFrames-1)/imainfo.FramesPerSecond)';
|
---|
| 627 | TimeUnit='s';
|
---|
| 628 | hhh=which('mmreader');
|
---|
| 629 | ColorType=imainfo.ImageType;%='truecolor' for color images
|
---|
| 630 | elseif ~isempty(FileExt(2:end))&&(~isempty(imformats(FileExt(2:end))) || isequal(FileExt,'.vol'))%&& isequal(NomType,'*')% multi-frame image
|
---|
| 631 | testima=1;
|
---|
| 632 | if ~isequal(SubDir,'')
|
---|
| 633 | RootFile=get(handles.RootFile,'String');
|
---|
| 634 | imainfo=imfinfo([fullfile(RootPath,SubDir,RootFile) FileIndices FileExt]);
|
---|
| 635 | else
|
---|
| 636 | imainfo=imfinfo([FileBase FileIndices FileExt]);
|
---|
| 637 | end
|
---|
| 638 | ColorType=imainfo.ColorType;%='truecolor' for color images
|
---|
| 639 | if length(imainfo) >1 %case of image with multiple frames
|
---|
| 640 | nbfield=length(imainfo);
|
---|
[334] | 641 | nbfield_j=1;
|
---|
[199] | 642 | end
|
---|
| 643 | end
|
---|
[332] | 644 | if ~strcmp(hhh,'')% if the function mmreader is found (recent version of matlab)
|
---|
[199] | 645 | UvData.MovieObject=mmreader([FileBase FileIndices FileExt]);
|
---|
| 646 | elseif isfield(UvData,'MovieObject')
|
---|
| 647 | UvData=rmfield(UvData,'MovieObject');
|
---|
| 648 | end
|
---|
| 649 | if isfield(imainfo,'Width') && isfield(imainfo,'Height')
|
---|
[271] | 650 | if length(imainfo)>1
|
---|
[292] | 651 | set(handles.num_Npx,'String',num2str(imainfo(1).Width));%fills nbre of pixels x box
|
---|
| 652 | set(handles.num_Npy,'String',num2str(imainfo(1).Height));%fills nbre of pixels x box
|
---|
[271] | 653 | else
|
---|
[292] | 654 | set(handles.num_Npx,'String',num2str(imainfo.Width));%fills nbre of pixels x box
|
---|
| 655 | set(handles.num_Npy,'String',num2str(imainfo.Height));%fills nbre of pixels x box
|
---|
[271] | 656 | end
|
---|
[199] | 657 | else
|
---|
[292] | 658 | set(handles.num_Npx,'String','');%fills nbre of pixels x box
|
---|
| 659 | set(handles.num_Npy,'String','');%fills nbre of pixels x box
|
---|
[199] | 660 | end
|
---|
[292] | 661 | set(handles.CheckBW,'Value',strcmp(ColorType,'grayscale'))% select handles.CheckBW if grayscale image
|
---|
[199] | 662 |
|
---|
| 663 | % read parameters (time, geometric calibration..) from a documentation file (.xml advised)
|
---|
| 664 | filexml=[FileBase '.xml'];
|
---|
| 665 | fileciv=[FileBase '.civ'];
|
---|
| 666 | warntext='';%default warning message
|
---|
| 667 | NbSlice=1;%default
|
---|
| 668 |
|
---|
| 669 | if exist(filexml,'file')
|
---|
| 670 | set(handles.view_xml,'Visible','on')
|
---|
| 671 | set(handles.view_xml,'BackgroundColor',[1 1 0])
|
---|
| 672 | set(handles.RootPath,'BackgroundColor',[1 1 1])
|
---|
| 673 | set(handles.view_xml,'String','view .xml')
|
---|
| 674 | drawnow
|
---|
| 675 | [XmlData,warntext]=imadoc2struct(filexml);
|
---|
| 676 | if ~isempty(warntext)
|
---|
| 677 | msgbox_uvmat('WARNING',warntext)
|
---|
| 678 | end
|
---|
| 679 | if isfield(XmlData,'TimeUnit')
|
---|
| 680 | if isfield(XmlData,'TimeUnit')&& ~isempty(XmlData.TimeUnit)
|
---|
| 681 | TimeUnit=XmlData.TimeUnit;
|
---|
| 682 | end
|
---|
| 683 | end
|
---|
| 684 | set(handles.view_xml,'BackgroundColor',[1 1 1])
|
---|
| 685 | drawnow
|
---|
| 686 | if isfield(XmlData, 'GeometryCalib') && ~isempty(XmlData.GeometryCalib)
|
---|
| 687 | XmlData.GeometryCalib
|
---|
| 688 | if isfield(XmlData.GeometryCalib,'VolumeScan') && isequal(XmlData.GeometryCalib.VolumeScan,'y')
|
---|
| 689 | set (handles.nb_slice,'String','volume')
|
---|
| 690 | end
|
---|
| 691 | hgeometry_calib=findobj('tag','geometry_calib');
|
---|
| 692 | if ~isempty(hgeometry_calib)
|
---|
| 693 | GUserData=get(hgeometry_calib,'UserData');
|
---|
| 694 | if ~(isfield(GUserData,'XmlInputFile') && strcmp(GUserData.XmlInputFile,filexml))
|
---|
| 695 | answer=msgbox_uvmat('INPUT_Y-N','replace the display of geometry_calib with the new input data?');
|
---|
| 696 | if strcmp(answer,'Yes')
|
---|
| 697 | geometry_calib(filexml);%diplay the new calibration points and parameters in geometry_calib
|
---|
| 698 | end
|
---|
| 699 | end
|
---|
| 700 | end
|
---|
| 701 | end
|
---|
| 702 | elseif exist(fileciv,'file')% if .civ file found
|
---|
| 703 | [error,XmlData.Time,TimeUnit,mode,npx,npy,pxcmx,pxcmy]=read_imatext([FileBase '.civ']);
|
---|
| 704 | GeometryCalib.R=[pxcmx 0 0; 0 pxcmy 0;0 0 0];
|
---|
| 705 | GeometryCalib.Tx=0;
|
---|
| 706 | GeometryCalib.Ty=0;
|
---|
| 707 | GeometryCalib.Tz=1;
|
---|
| 708 | GeometryCalib.dpx=1;
|
---|
| 709 | GeometryCalib.dpy=1;
|
---|
| 710 | GeometryCalib.sx=1;
|
---|
| 711 | GeometryCalib.Cx=0;
|
---|
| 712 | GeometryCalib.Cy=0;
|
---|
| 713 | GeometryCalib.f=1;
|
---|
| 714 | GeometryCalib.kappa1=0;
|
---|
| 715 | GeometryCalib.CoordUnit='cm';
|
---|
| 716 | XmlData.GeometryCalib=GeometryCalib;
|
---|
| 717 | if error==2, warntext=['no file ' FileBase '.civ'];
|
---|
| 718 | elseif error==1, warntext='inconsistent number of fields in the .civ file';
|
---|
| 719 | end
|
---|
[292] | 720 | set(handles.num_Npx,'String',num2str(npx));%fills nbre of pixels x box
|
---|
| 721 | set(handles.num_Npy,'String',num2str(npy));%fills nbre of pixels y box
|
---|
[199] | 722 | set(handles.pxcm,'String',num2str(pxcmx));%fills scale x (pixel/cm) box
|
---|
| 723 | set(handles.pycm,'String',num2str(pxcmy));%fills scale y (pixel/cm) box
|
---|
| 724 | set(handles.pxcm,'Visible','on');%fills scale x (pixel/cm) box
|
---|
| 725 | set(handles.pycm,'Visible','on');%fills scale y (pixel/cm) box
|
---|
| 726 | set(handles.view_xml,'Visible','on')
|
---|
| 727 | set(handles.view_xml,'String','view .civ')
|
---|
| 728 | else
|
---|
| 729 | set(handles.view_xml,'Visible','off')
|
---|
| 730 | end
|
---|
| 731 |
|
---|
[334] | 732 | %% store last index in handles.lat_i and .last_j
|
---|
| 733 | nbfield=max(i2_series);
|
---|
| 734 | if isempty(nbfield)
|
---|
| 735 | nbfield=max(i1_series);
|
---|
| 736 | end
|
---|
| 737 | nbfield_j=max(j2_series);
|
---|
| 738 | if isempty(nbfield_j)
|
---|
| 739 | nbfield_j=max(j1_series);
|
---|
| 740 | end
|
---|
[199] | 741 | if ~isempty(XmlData.Time)
|
---|
| 742 | nbfield=size(XmlData.Time,1);
|
---|
[334] | 743 | nbfield_j=size(XmlData.Time,2);
|
---|
[199] | 744 | %transform .Time to a column vector if it is a line vector the nomenclature uses a single index
|
---|
[334] | 745 | if isequal(nbfield,1) && ~isequal(nbfield_j,1)% .Time is a line vector
|
---|
[323] | 746 | NomType=get(handles.NomType,'String');
|
---|
| 747 | % NomType=get(handles.FileIndex,'UserData');
|
---|
[199] | 748 | if numel(NomType)>=2 &&(strcmp(NomType,'_i')||strcmp(NomType(1:2),'%0')||strcmp(NomType(1:2),'_%'))
|
---|
| 749 | XmlData.Time=(XmlData.Time)';
|
---|
[334] | 750 | nbfield=nbfield_j;
|
---|
| 751 | nbfield_j=1;
|
---|
[199] | 752 | end
|
---|
| 753 | end
|
---|
| 754 | end
|
---|
| 755 | last_i_cell=get(handles.last_i,'String');
|
---|
| 756 | if isempty(nbfield)
|
---|
| 757 | last_i_cell{1}='';
|
---|
| 758 | else
|
---|
| 759 | last_i_cell{1}=num2str(nbfield);
|
---|
| 760 | end
|
---|
| 761 | set(handles.last_i,'String',last_i_cell)
|
---|
| 762 | last_j_cell=get(handles.last_j,'String');
|
---|
[334] | 763 | if isempty(nbfield_j)
|
---|
[199] | 764 | last_j_cell{1}='';
|
---|
| 765 | else
|
---|
[334] | 766 | last_j_cell{1}=num2str(nbfield_j);
|
---|
[199] | 767 | end
|
---|
| 768 | set(handles.last_j,'String',last_j_cell);
|
---|
| 769 |
|
---|
| 770 | % store geometric calibration in UvData
|
---|
| 771 | if isfield(XmlData,'GeometryCalib')
|
---|
| 772 | GeometryCalib=XmlData.GeometryCalib;
|
---|
| 773 | if isempty(GeometryCalib)
|
---|
| 774 | set(handles.pxcm,'String','')
|
---|
| 775 | set(handles.pycm,'String','')
|
---|
| 776 | set(handles.transform_fct,'Value',1); % no transform by default
|
---|
| 777 | else
|
---|
| 778 | if (isfield(GeometryCalib,'R')&& ~isequal(GeometryCalib.R(2,1),0) && ~isequal(GeometryCalib.R(1,2),0)) ||...
|
---|
| 779 | (isfield(GeometryCalib,'kappa1')&& ~isequal(GeometryCalib.kappa1,0))
|
---|
| 780 | set(handles.pxcm,'String','var')
|
---|
| 781 | set(handles.pycm,'String','var')
|
---|
| 782 | elseif isfield(GeometryCalib,'fx_fy')
|
---|
| 783 | pixcmx=GeometryCalib.fx_fy(1);%*GeometryCalib.R(1,1)*GeometryCalib.sx/(GeometryCalib.Tz*GeometryCalib.dpx);
|
---|
| 784 | pixcmy=GeometryCalib.fx_fy(2);%*GeometryCalib.R(2,2)/(GeometryCalib.Tz*GeometryCalib.dpy);
|
---|
| 785 | set(handles.pxcm,'String',num2str(pixcmx))
|
---|
| 786 | set(handles.pycm,'String',num2str(pixcmy))
|
---|
| 787 | end
|
---|
[292] | 788 | if ~get(handles.CheckFixLimits,'Value')
|
---|
[199] | 789 | set(handles.transform_fct,'Value',2); % phys transform by default if fixedLimits is off
|
---|
| 790 | end
|
---|
| 791 | if isfield(GeometryCalib,'SliceCoord')
|
---|
| 792 |
|
---|
| 793 | siz=size(GeometryCalib.SliceCoord);
|
---|
| 794 | if siz(1)>1
|
---|
| 795 | NbSlice=siz(1);
|
---|
| 796 | set(handles.slices,'Visible','on')
|
---|
| 797 | set(handles.slices,'Value',1)
|
---|
| 798 | end
|
---|
| 799 | if isfield(GeometryCalib,'VolumeScan') && isequal(GeometryCalib.VolumeScan,'y')
|
---|
| 800 | set(handles.nb_slice,'String','volume')
|
---|
| 801 | else
|
---|
| 802 | set(handles.nb_slice,'String',num2str(NbSlice))
|
---|
| 803 | end
|
---|
[334] | 804 | slices_Callback([],[], handles)
|
---|
[199] | 805 | end
|
---|
| 806 | end
|
---|
| 807 | end
|
---|
| 808 |
|
---|
| 809 | %update the data attached to the uvmat interface
|
---|
| 810 | if ~isempty(TimeUnit)
|
---|
| 811 | set(handles.time_txt,'String',['time (' TimeUnit ')'])
|
---|
| 812 | end
|
---|
| 813 | UvData.TimeUnit=TimeUnit;
|
---|
| 814 | UvData.XmlData=XmlData;
|
---|
| 815 | UvData.NewSeries=1;
|
---|
[334] | 816 | UvData.MovieObject=MovieObject;
|
---|
[199] | 817 |
|
---|
| 818 | %display warning message
|
---|
| 819 | if ~isequal(warntext,'')
|
---|
| 820 | msgbox_uvmat('WARNING',warntext);
|
---|
| 821 | end
|
---|
| 822 |
|
---|
| 823 | % set default options in menu 'Fields'
|
---|
[227] | 824 | if ~testima
|
---|
| 825 | testcivx=0;
|
---|
[231] | 826 | if isfield(UvData,'FieldsString') && isequal(UvData.FieldsString,{'get_field...'})% field menu defined as input (from get_field)
|
---|
| 827 | set(handles.Fields,'Value',1)
|
---|
| 828 | set(handles.Fields,'String',{'get_field...'})
|
---|
| 829 | UvData=rmfield(UvData,'FieldsString');
|
---|
| 830 | else
|
---|
[236] | 831 | Data=nc2struct(FileName,'ListGlobalAttribute','Conventions','absolut_time_T0','civ');
|
---|
| 832 | if strcmp(Data.Conventions,'uvmat/civdata') ||( ~isempty(Data.absolut_time_T0)&& ~isequal(Data.civ,0))%if the new input is Civx
|
---|
[227] | 833 | FieldList=calc_field;
|
---|
| 834 | set(handles.Fields,'String',[{'image'};FieldList;{'get_field...'}]);%standard menu for civx data
|
---|
| 835 | set(handles.Fields,'Value',2) % set menu to 'velocity'
|
---|
| 836 | col_vec=FieldList;
|
---|
| 837 | col_vec(1)=[];%remove 'velocity' option for vector color (must be a scalar)
|
---|
| 838 | testcivx=1;
|
---|
| 839 | end
|
---|
[231] | 840 | if ~testcivx
|
---|
[227] | 841 | set(handles.Fields,'Value',1) % set menu to 'get_field...
|
---|
| 842 | set(handles.Fields,'String',{'get_field...'})
|
---|
[231] | 843 | col_vec={'get_field...'};
|
---|
| 844 | end
|
---|
[292] | 845 | set(handles.ListColorScalar,'String',col_vec)
|
---|
[231] | 846 | end
|
---|
[227] | 847 | end
|
---|
[231] | 848 | set(handles.uvmat,'UserData',UvData)
|
---|
[199] | 849 |
|
---|
| 850 | %% set index navigation options and refresh plots
|
---|
| 851 | set(handles.RootPath,'BackgroundColor',[1 1 1])
|
---|
| 852 | drawnow
|
---|
[334] | 853 | set_scan_options(handles)
|
---|
[199] | 854 |
|
---|
[296] | 855 | %% update list of recent files in the menubar
|
---|
[302] | 856 | MenuFile=[{get(handles.MenuFile_1,'Label')};{get(handles.MenuFile_2,'Label')};...
|
---|
| 857 | {get(handles.MenuFile_3,'Label')};{get(handles.MenuFile_4,'Label')};{get(handles.MenuFile_5,'Label')}];
|
---|
| 858 | str_find=strcmp(FileName,MenuFile);
|
---|
| 859 | if isempty(find(str_find,1))
|
---|
| 860 | MenuFile=[{FileName};MenuFile];%insert the current file if not already in the list
|
---|
| 861 | end
|
---|
[298] | 862 | for ifile=1:min(length(MenuFile),5)
|
---|
[296] | 863 | eval(['set(handles.MenuFile_' num2str(ifile) ',''Label'',MenuFile{ifile});'])
|
---|
| 864 | eval(['set(handles.MenuFile_' num2str(ifile) '_1,''Label'',MenuFile{ifile});'])
|
---|
| 865 | end
|
---|
| 866 | dir_perso=prefdir;
|
---|
| 867 | profil_perso=fullfile(dir_perso,'uvmat_perso.mat');
|
---|
| 868 | if exist(profil_perso,'file')
|
---|
| 869 | save (profil_perso,'MenuFile','-append'); %store the file names for future opening of uvmat
|
---|
| 870 | else
|
---|
| 871 | save (profil_perso,'MenuFile','-V6'); %store the file names for future opening of uvmat
|
---|
| 872 | end
|
---|
| 873 |
|
---|
[199] | 874 | %------------------------------------------------------------------------
|
---|
| 875 | %--- Set index navigation options for new series input and refresh plot
|
---|
| 876 | %------------------------------------------------------------------------
|
---|
[334] | 877 | function set_scan_options(handles)
|
---|
[199] | 878 |
|
---|
| 879 | % set the corresponding index navigation options
|
---|
[323] | 880 | NomType=get(handles.NomType,'String');
|
---|
| 881 | NomType_1=get(handles.NomType_1,'String');
|
---|
| 882 | % NomType=get(handles.FileIndex,'UserData');
|
---|
| 883 | % NomType_1=get(handles.FileIndex_1,'UserData');
|
---|
[199] | 884 | last_i_str=get(handles.last_i,'String');
|
---|
| 885 | nbfield=str2num(last_i_str{1});
|
---|
| 886 | if numel(last_i_str)==2
|
---|
| 887 | nbfield=min(nbfield,str2num(last_i_str{2}));
|
---|
| 888 | end
|
---|
| 889 | state_j='off'; %default
|
---|
| 890 | scan_option='i';%default
|
---|
| 891 | NomTypeRaw=regexprep(NomType(2:end), '-', '');
|
---|
| 892 | if numel(regexp(NomTypeRaw,'\D'))>=1
|
---|
| 893 | state_j='on';
|
---|
| 894 | if isequal(nbfield,1)
|
---|
| 895 | scan_option='j'; %scan j index by default if nbfield=1
|
---|
| 896 | end
|
---|
| 897 | end
|
---|
| 898 | if ~isempty(NomType_1)
|
---|
| 899 | NomTypeRaw=regexprep(NomType_1(2:end), '-', '');
|
---|
| 900 | if numel(regexp(NomTypeRaw,'\D'))>=1
|
---|
| 901 | state_j='on';
|
---|
| 902 | if isequal(nbfield,1)
|
---|
| 903 | scan_option='j';
|
---|
| 904 | end
|
---|
| 905 | end
|
---|
| 906 | end
|
---|
| 907 | if isequal(scan_option,'i')
|
---|
| 908 | set(handles.scan_i,'Value',1)
|
---|
[334] | 909 | scan_i_Callback([],[], handles);
|
---|
[199] | 910 | else
|
---|
| 911 | set(handles.scan_j,'Value',1)
|
---|
[334] | 912 | scan_j_Callback([],[], handles);
|
---|
[199] | 913 | end
|
---|
| 914 | set(handles.scan_j,'Visible',state_j)
|
---|
| 915 | set(handles.j1,'Visible',state_j)
|
---|
| 916 | set(handles.j2,'Visible',state_j)
|
---|
| 917 | set(handles.last_j,'Visible',state_j);
|
---|
| 918 | set(handles.frame_j,'Visible',state_j);
|
---|
| 919 | set(handles.j_text,'Visible',state_j);
|
---|
[221] | 920 | if strcmp(state_j,'on')
|
---|
| 921 | set(handles.fix_pair,'Visible','on')
|
---|
| 922 | else
|
---|
| 923 | set(handles.fix_pair,'Visible','off')
|
---|
| 924 | end
|
---|
[199] | 925 |
|
---|
| 926 | %% view the field
|
---|
[334] | 927 | run0_Callback([],[], handles); %view field
|
---|
[315] | 928 | mask_test=get(handles.CheckMask,'value');
|
---|
[199] | 929 | if mask_test
|
---|
[315] | 930 | MaskData=get(handles.CheckMask,'UserData');
|
---|
[199] | 931 | if isfield(MaskData,'maskhandle') && ishandle(MaskData.maskhandle)
|
---|
| 932 | delete(MaskData.maskhandle) %delete old mask
|
---|
| 933 | end
|
---|
[334] | 934 | CheckMask_Callback([],[],handles)
|
---|
[199] | 935 | end
|
---|
| 936 |
|
---|
| 937 | %------------------------------------------------------------------------
|
---|
| 938 | % --- Executes on the menu Open/Browse_1 for the second input field,
|
---|
| 939 | % search the files, recognize their type according to their name and fill the rootfile input windows
|
---|
| 940 | function MenuBrowse_1_Callback(hObject, eventdata, handles)
|
---|
| 941 | %------------------------------------------------------------------------
|
---|
| 942 | % huvmat=get(handles.run0,'parent');
|
---|
| 943 | UvData=get(handles.uvmat,'UserData');
|
---|
| 944 |
|
---|
| 945 | RootPath=get(handles.RootPath,'String');
|
---|
| 946 | [FileName, PathName, filterindex] = uigetfile( ...
|
---|
| 947 | {'*.xml;*.xls;*.civ;*.jpg;*.png;*.avi;*.AVI;*.nc;*.cmx;*.fig;*.log;*.dat', ' (*.xml,*.xls,*.civ, *.jpg,*.png, *.avi,*.nc,*.cmx ,*.fig,*.log,*.dat)';
|
---|
| 948 | '*.xml', '.xml files '; ...
|
---|
| 949 | '*.xls', '.xls files '; ...
|
---|
| 950 | '*.civ', '.civ files '; ...
|
---|
| 951 | '*.jpg','.jpg image files'; ...
|
---|
| 952 | '*.png','.png image files'; ...
|
---|
| 953 | '*.avi;*.AVI','.avi movie files'; ...
|
---|
| 954 | '*.nc','.netcdf files'; ...
|
---|
| 955 | '*.cdf','.netcdf files'; ...
|
---|
| 956 | '*.cmx','.cmx text files';...
|
---|
| 957 | '*.cmx2','.cmx2 text files';...
|
---|
| 958 | '*.fig','.fig files (matlab fig)';...
|
---|
| 959 | '*.log','.log text files ';...
|
---|
| 960 | '*.dat','.dat text files ';...
|
---|
| 961 | '*.*', 'All Files (*.*)'}, ...
|
---|
[236] | 962 | 'Pick a second file for comparison',RootPath);
|
---|
[199] | 963 | fileinput_1=[PathName FileName];%complete file name
|
---|
| 964 | sizf=size(fileinput_1);
|
---|
| 965 | if (~ischar(fileinput_1)||~isequal(sizf(1),1)),return;end
|
---|
| 966 |
|
---|
| 967 | % refresh the current displayed field
|
---|
| 968 | display_file_name_1(hObject,eventdata,handles,fileinput_1)
|
---|
| 969 |
|
---|
| 970 | %update list of recent files in the menubar
|
---|
| 971 | MenuFile_1=fileinput_1;
|
---|
| 972 | MenuFile_2=get(handles.MenuFile_1,'Label');
|
---|
| 973 | MenuFile_3=get(handles.MenuFile_2,'Label');
|
---|
| 974 | MenuFile_4=get(handles.MenuFile_3,'Label');
|
---|
| 975 | MenuFile_5=get(handles.MenuFile_4,'Label');
|
---|
| 976 | set(handles.MenuFile_1,'Label',MenuFile_1)
|
---|
| 977 | set(handles.MenuFile_2,'Label',MenuFile_2)
|
---|
| 978 | set(handles.MenuFile_3,'Label',MenuFile_3)
|
---|
| 979 | set(handles.MenuFile_4,'Label',MenuFile_4)
|
---|
| 980 | set(handles.MenuFile_5,'Label',MenuFile_5)
|
---|
| 981 | set(handles.MenuFile_1_1,'Label',MenuFile_1)
|
---|
| 982 | set(handles.MenuFile_2_1,'Label',MenuFile_2)
|
---|
| 983 | set(handles.MenuFile_3_1,'Label',MenuFile_3)
|
---|
| 984 | set(handles.MenuFile_4_1,'Label',MenuFile_4)
|
---|
| 985 | set(handles.MenuFile_5_1,'Label',MenuFile_5)
|
---|
| 986 | dir_perso=prefdir;
|
---|
| 987 | profil_perso=fullfile(dir_perso,'uvmat_perso.mat');
|
---|
| 988 | if exist(profil_perso,'file')
|
---|
| 989 | save (profil_perso,'MenuFile_1','MenuFile_2','MenuFile_3','MenuFile_4', 'MenuFile_5','-append'); %store the file names for future opening of uvmat
|
---|
| 990 | else
|
---|
| 991 | txt=ver('MATLAB');
|
---|
| 992 | Release=txt.Release;
|
---|
| 993 | relnumb=str2double(Release(3:4));
|
---|
| 994 | if relnumb >= 14
|
---|
| 995 | save (profil_perso,'MenuFile_1','MenuFile_2','MenuFile_3','MenuFile_4', 'MenuFile_5','-V6'); %store the file names for future opening of uvmat
|
---|
| 996 | else
|
---|
| 997 | save (profil_perso,'MenuFile_1','MenuFile_2','MenuFile_3','MenuFile_4', 'MenuFile_5'); %store the file names for future opening of uvmat
|
---|
| 998 | end
|
---|
| 999 | end
|
---|
| 1000 |
|
---|
| 1001 | % -----------------------------------------------------------------------
|
---|
| 1002 | % --- Open again as second field the file whose name has been recorded in MenuFile_1
|
---|
| 1003 | function MenuFile_1_1_Callback(hObject, eventdata, handles)
|
---|
| 1004 | % -----------------------------------------------------------------------
|
---|
| 1005 | fileinput_1=get(handles.MenuFile_1_1,'Label');
|
---|
| 1006 | display_file_name_1(hObject,eventdata,handles,fileinput_1)
|
---|
| 1007 |
|
---|
| 1008 | % -----------------------------------------------------------------------
|
---|
| 1009 | % --- Open again as second field the file whose name has been recorded in MenuFile_2
|
---|
| 1010 | function MenuFile_2_1_Callback(hObject, eventdata, handles)
|
---|
| 1011 | % -----------------------------------------------------------------------
|
---|
| 1012 | fileinput_1=get(handles.MenuFile_2_1,'Label');
|
---|
| 1013 | display_file_name_1(hObject,eventdata,handles,fileinput_1)
|
---|
| 1014 |
|
---|
| 1015 | % -----------------------------------------------------------------------
|
---|
| 1016 | % --- Open again as second field the file whose name has been recorded in MenuFile_3
|
---|
| 1017 | function MenuFile_3_1_Callback(hObject, eventdata, handles)
|
---|
| 1018 | % -----------------------------------------------------------------------
|
---|
| 1019 | fileinput_1=get(handles.MenuFile_3_1,'Label');
|
---|
| 1020 | display_file_name_1(hObject,eventdata,handles,fileinput_1)
|
---|
| 1021 |
|
---|
| 1022 | % -----------------------------------------------------------------------
|
---|
| 1023 | % --- Open again as second field the file whose name has been recorded in MenuFile_4
|
---|
| 1024 | function MenuFile_4_1_Callback(hObject, eventdata, handles)
|
---|
| 1025 | % -----------------------------------------------------------------------
|
---|
| 1026 | fileinput_1=get(handles.MenuFile_4_1,'Label');
|
---|
| 1027 | display_file_name_1(hObject,eventdata,handles,fileinput_1)
|
---|
| 1028 |
|
---|
| 1029 | % -----------------------------------------------------------------------
|
---|
| 1030 | % --- Open again as second field the file whose name has been recorded in MenuFile_5
|
---|
| 1031 | function MenuFile_5_1_Callback(hObject, eventdata, handles)
|
---|
| 1032 | % -----------------------------------------------------------------------
|
---|
| 1033 | fileinput_1=get(handles.MenuFile_5_1,'Label');
|
---|
| 1034 | display_file_name_1(hObject,eventdata,handles,fileinput_1)
|
---|
| 1035 |
|
---|
| 1036 | %------------------------------------------------------------------------
|
---|
| 1037 | % fills the edit boxes RootPath_1, RootFile_1,NomType_1...from an input file name 'fileinput_1'
|
---|
| 1038 | %------------------------------------------------------------------------
|
---|
| 1039 | function display_file_name_1(hObject,eventdata,handles,fileinput_1)
|
---|
| 1040 |
|
---|
| 1041 | %[path,name,ext]=fileparts(fileinput_1);
|
---|
[341] | 1042 | [~,SubDir_1,~,i1,i2,j1,j2,FileExt_1]=fileparts_uvmat(fileinput_1);
|
---|
| 1043 | [RootPath_1,RootFile_1,i1_series,i2_series,j1_series,j2_series,NomType,FileType,MovieObject]=find_file_series(fileinput_1);
|
---|
[334] | 1044 | % [RootPath_1,RootFile_1,field_count,str2,str_a,str_b,FileExt_1,NomType_1,SubDir_1]=name2display(fileinput_1);
|
---|
| 1045 | switch FileType
|
---|
| 1046 | case ''
|
---|
| 1047 | msgbox_uvmat('ERROR','invalid input file type')
|
---|
| 1048 | case 'txt'
|
---|
[199] | 1049 | edit(fileinput)
|
---|
[334] | 1050 | case 'figure' %display matlab figure
|
---|
[199] | 1051 | hfig=open(fileinput);
|
---|
| 1052 | set(hfig,'WindowButtonMotionFcn','mouse_motion')%set mouse action functio
|
---|
| 1053 | set(hfig,'WindowButtonUpFcn','mouse_up')%set mouse click action function
|
---|
| 1054 | set(hfig,'WindowButtonUpFcn','mouse_down')%set mouse click action function
|
---|
[334] | 1055 | case {'xml','xls'} % edit xml or Excel files
|
---|
| 1056 | editxml(fileinput);
|
---|
| 1057 | % case {'.avi','.image','.vol','.nc','.cdf'}
|
---|
[199] | 1058 | otherwise
|
---|
[334] | 1059 | set(handles.RootPath,'String',RootPath);
|
---|
| 1060 | if isequal(SubDir,'')
|
---|
| 1061 | rootname=fullfile(RootPath,RootFile);
|
---|
| 1062 | else
|
---|
| 1063 | rootname=fullfile(RootPath,SubDir,RootFile);
|
---|
| 1064 | SubDir=['/' SubDir]; %display the separator
|
---|
| 1065 | end
|
---|
| 1066 | set(handles.SubDir,'String',SubDir);
|
---|
| 1067 | set(handles.RootFile,'String',['/' RootFile]); %display the separator
|
---|
| 1068 | indices=fileinput(length(rootname)+1:end);
|
---|
| 1069 | indices(end-length(FileExt)+1:end)=[]; %remove extension
|
---|
| 1070 | set(handles.FileIndex,'String',indices);
|
---|
| 1071 | % set(handles.FileIndex,'UserData',NomType);
|
---|
| 1072 | set(handles.NomType,'String',NomType);
|
---|
| 1073 | set(handles.FileExt,'String',FileExt);
|
---|
| 1074 | % fill file index counters
|
---|
| 1075 | set(handles.i1,'String',num2str(i1));
|
---|
| 1076 | set(handles.i2,'String',num2str(i2));
|
---|
| 1077 | set(handles.j1,'String',num2str(j1));
|
---|
| 1078 | set(handles.j2,'String',num2str(j2));
|
---|
| 1079 |
|
---|
| 1080 | % synchronise indices of the second input file if it exists
|
---|
| 1081 | if get(handles.SubField,'Value')==1% if the subfield button is activated, update the field numbers
|
---|
| 1082 | [ff,rr,FileBase_1,ii,FileExt_1,SubDir_1]=read_file_boxes_1(handles);
|
---|
| 1083 | NomType_1=get(handles.NomType_1,'String');
|
---|
| 1084 | % NomType_1=get(handles.FileIndex_1,'UserData');
|
---|
| 1085 | FileName_1=name_generator(FileBase_1,i1,i2,FileExt_1,NomType_1,1,j1,j2,SubDir_1);
|
---|
| 1086 | if exist(FileName_1,'file')
|
---|
| 1087 | FileIndex_1=name_generator('',i1,i2,'',NomType_1,1,j1,j2,'');
|
---|
| 1088 | set(handles.FileIndex_1,'String',FileIndex_1)
|
---|
| 1089 | else
|
---|
| 1090 | set(handles.SubField,'Value',0)
|
---|
| 1091 | SubField_Callback(hObject, eventdata, handles)
|
---|
| 1092 | end
|
---|
| 1093 | end
|
---|
[199] | 1094 | end
|
---|
[334] | 1095 | %
|
---|
| 1096 | %
|
---|
| 1097 | % nbfield_1=1; %default
|
---|
| 1098 | % ext_test=FileExt_1;%default
|
---|
| 1099 | % form=imformats(FileExt_1(2:end));
|
---|
| 1100 | % if ~isempty(form) % if the extension corresponds to an image format recognized by Matlab
|
---|
| 1101 | % imainfo=imfinfo(fileinput_1);
|
---|
| 1102 | % nbfield_1=length(imainfo);
|
---|
| 1103 | % ext_test='.image';
|
---|
| 1104 | % elseif isequal(lower(FileExt_1),'.avi')
|
---|
| 1105 | % info=aviinfo(fileinput_1);
|
---|
| 1106 | % nbfield_1=info.NumFrames;
|
---|
| 1107 | % ext_test='.image';
|
---|
| 1108 | % end
|
---|
| 1109 | %
|
---|
| 1110 | % %open directly fig or text files
|
---|
| 1111 | % switch ext_test
|
---|
| 1112 | % case {'.civ','.log','.cmx','.cmx2','.txt'} %display text file
|
---|
| 1113 | % edit(fileinput)
|
---|
| 1114 | % return
|
---|
| 1115 | % case '.fig' %display matlab figure
|
---|
| 1116 | % hfig=open(fileinput);
|
---|
| 1117 | % set(hfig,'WindowButtonMotionFcn','mouse_motion')%set mouse action functio
|
---|
| 1118 | % set(hfig,'WindowButtonUpFcn','mouse_up')%set mouse click action function
|
---|
| 1119 | % set(hfig,'WindowButtonUpFcn','mouse_down')%set mouse click action function
|
---|
| 1120 | % return
|
---|
| 1121 | % case {'.xml','.xls'} % edit xml or Excel files
|
---|
| 1122 | % heditxml=editxml(fileinput);
|
---|
| 1123 | % return
|
---|
| 1124 | % case {'.image','.nc','.cdf'}
|
---|
| 1125 | % % set(handles.FileIndex,'UserData',NomType_1);
|
---|
| 1126 | % otherwise
|
---|
| 1127 | % msgbox_uvmat(['invalid input file extension ' FileExt_1 ' for uvmat'],'ERROR')
|
---|
| 1128 | % return
|
---|
| 1129 | % end
|
---|
[199] | 1130 |
|
---|
| 1131 | % test for image series in a single file and synchronise file indices of the two series
|
---|
| 1132 | if nbfield_1 >1 %case of image with multiple frames
|
---|
| 1133 | if nbfield_1 < num_i1
|
---|
| 1134 | msgbox_uvmat('ERROR','current frame index beyond the input movie length')
|
---|
| 1135 | return
|
---|
| 1136 | else
|
---|
| 1137 | NomType_1='*'; %indicate a set of indexed frames within a single file
|
---|
| 1138 | filename_new=fileinput_1;
|
---|
| 1139 | end
|
---|
| 1140 | else % cases of data files
|
---|
| 1141 | RootPath=get(handles.RootPath,'String');
|
---|
| 1142 | RootFile=get(handles.RootFile,'String');
|
---|
| 1143 | FileBase=fullfile(RootPath,RootFile);
|
---|
| 1144 | FileBase_1=fullfile(RootPath_1,RootFile_1);
|
---|
| 1145 | if isequal(FileBase,FileBase_1)
|
---|
| 1146 | filename_new=fileinput_1;
|
---|
| 1147 | else
|
---|
| 1148 | num_i1=stra2num(get(handles.i1,'String'));%get the current file indices from counters
|
---|
| 1149 | num_j1=stra2num(get(handles.j1,'String'));
|
---|
| 1150 | num_i2=stra2num(get(handles.i2,'String'));
|
---|
| 1151 | num_j2=stra2num(get(handles.j2,'String'));
|
---|
| 1152 | [filename_new,idetect]=...
|
---|
| 1153 | 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
|
---|
| 1154 | indices=''; %default
|
---|
| 1155 | if ~idetect
|
---|
| 1156 | msgbox_uvmat('ERROR','second input file with indices corresponding to the first one does not exist')
|
---|
| 1157 | return
|
---|
| 1158 | end
|
---|
| 1159 | end
|
---|
| 1160 | end
|
---|
[323] | 1161 | set(handles.NomType_1,'String',NomType_1);
|
---|
| 1162 | % set(handles.FileIndex_1,'UserData',NomType_1);
|
---|
[199] | 1163 |
|
---|
| 1164 | % make visible and fill the second raw of edit boxes
|
---|
| 1165 | set(handles.RootPath_1,'Visible','on')
|
---|
| 1166 | set(handles.RootFile_1,'Visible','on')
|
---|
| 1167 | set(handles.SubDir_1,'Visible','on');
|
---|
| 1168 | set(handles.FileIndex_1,'Visible','on');
|
---|
| 1169 | set(handles.FileExt_1,'Visible','on');
|
---|
| 1170 | [FileName,RootPath,FileBase,FileIndices,FileExt,SubDir]=read_file_boxes(handles);
|
---|
| 1171 | if isequal(FileBase,FileBase_1)
|
---|
| 1172 | set(handles.RootPath_1,'String','"')
|
---|
| 1173 | set(handles.RootFile_1,'String','"');
|
---|
| 1174 | else
|
---|
| 1175 | set(handles.RootPath_1,'String',RootPath_1)
|
---|
| 1176 | set(handles.RootFile_1,'String',['/' RootFile_1]);
|
---|
| 1177 | end
|
---|
| 1178 | if isequal(SubDir_1,'')
|
---|
| 1179 | set(handles.SubDir_1,'String','');
|
---|
| 1180 | FileBaseSub_1=FileBase_1;
|
---|
| 1181 | else
|
---|
| 1182 | set(handles.SubDir_1,'String',['/' SubDir_1]);
|
---|
| 1183 | FileBaseSub_1=fullfile(FileBase_1,SubDir_1);
|
---|
| 1184 | end
|
---|
| 1185 | indices=filename_new(length(FileBaseSub_1)+1:end);
|
---|
| 1186 | indices(end-length(FileExt_1)+1:end)=[]; %remove extension
|
---|
| 1187 | set(handles.FileIndex_1,'String',indices)
|
---|
[323] | 1188 | set(handles.NomType_1,'String',NomType_1)
|
---|
| 1189 | % set(handles.FileIndex_1,'UserData',NomType_1)
|
---|
[199] | 1190 | set(handles.FileExt_1,'String',FileExt_1);
|
---|
| 1191 |
|
---|
| 1192 | % % default choice of fields
|
---|
[236] | 1193 | %set(handles.SubField,'Visible','on')
|
---|
[199] | 1194 | set(handles.SubField,'Value',1)
|
---|
| 1195 | RootPath_1_Callback(hObject,eventdata,handles);
|
---|
| 1196 |
|
---|
| 1197 | %-----------------------------------------------------------------------
|
---|
| 1198 | % --- Called by action in RootPath_1 edit box
|
---|
| 1199 | function RootPath_1_Callback(hObject,eventdata,handles)
|
---|
| 1200 | % -----------------------------------------------------------------------
|
---|
| 1201 | update_rootinfo_1(hObject,eventdata,handles)
|
---|
| 1202 |
|
---|
| 1203 | %-----------------------------------------------------------------------
|
---|
| 1204 | % --- Called by action in RootFile_1 edit box
|
---|
| 1205 | function RootFile_1_Callback(hObject, eventdata, handles)
|
---|
| 1206 | % -----------------------------------------------------------------------
|
---|
| 1207 | update_rootinfo_1(hObject,eventdata,handles)
|
---|
| 1208 |
|
---|
| 1209 | %------------------------------------------------------------------------
|
---|
| 1210 | % --- Called by action in FileIndex_1 edit box
|
---|
| 1211 | function FileIndex_1_Callback(hObject, eventdata, handles)
|
---|
| 1212 | %------------------------------------------------------------------------
|
---|
| 1213 | run0_Callback(hObject, eventdata, handles)
|
---|
| 1214 |
|
---|
| 1215 | %------------------------------------------------------------------------
|
---|
| 1216 | % --- Update information about a new second field series (indices to scan, timing,
|
---|
| 1217 | % calibration from an xml file, then refresh current plots
|
---|
| 1218 | function update_rootinfo_1(hObject,eventdata,handles) %A REVOIR
|
---|
| 1219 | % -----------------------------------------------------------------------
|
---|
| 1220 | set(handles.RootPath_1,'BackgroundColor',[1 1 0])% indicate active program by yellow color
|
---|
| 1221 | drawnow
|
---|
| 1222 | UvData=get(handles.uvmat,'UserData');%huvmat=handles of the uvmat interface
|
---|
| 1223 | UvData.NewSeries=1; %flag for run0: begin a new series
|
---|
| 1224 |
|
---|
| 1225 | [FileName,RootPath,FileBase,FileIndices,FileExt,SubDir]=read_file_boxes_1(handles);
|
---|
| 1226 | if ~exist(FileName,'file')
|
---|
| 1227 | msgbox_uvmat('ERROR',['input file ' FileName ' not found']);
|
---|
| 1228 | end
|
---|
[236] | 1229 | set(handles.FixVelType,'Value',0); %desactivate fixed veltype
|
---|
[199] | 1230 | nbfield_1=[];%default
|
---|
[334] | 1231 | nbfield_j_1=[];%default
|
---|
[199] | 1232 | XmlData.Time=[];
|
---|
| 1233 | XmlData.GeometryCalib=[];%default
|
---|
| 1234 | TimeUnit=[];
|
---|
| 1235 | if isfield(UvData,'TimeUnit')
|
---|
| 1236 | TimeUnit=UvData.TimeUnit;
|
---|
| 1237 | end
|
---|
| 1238 | TimeUnit_1=[];
|
---|
| 1239 | hhh='';%default, test for movie reading with mmreader
|
---|
| 1240 | imainfo=[];
|
---|
| 1241 | if isequal(lower(FileExt),'.avi') %.avi file
|
---|
| 1242 | imainfo=aviinfo([FileBase FileIndices FileExt]);
|
---|
| 1243 | nbfield_1=imainfo.NumFrames;
|
---|
[334] | 1244 | nbfield_j_1=1;
|
---|
[199] | 1245 | set(handles.Dt_txt,'String',['Dt=' num2str(1000/info.FramesPerSecond) 'ms']);%display the elementary time interval in millisec
|
---|
| 1246 | time=(0:1/imainfo.FramesPerSecond:(imainfo.NumFrames-1)/imainfo.FramesPerSecond)';
|
---|
| 1247 | ColorType=imainfo.ImageType;%='truecolor' for color images
|
---|
| 1248 | hhh=which('mmreader');
|
---|
| 1249 | elseif ~isempty(imformats(FileExt(2:end)))|| isequal(FileExt,'.vol')
|
---|
| 1250 | if ~isequal(SubDir,'')
|
---|
| 1251 | RootFile=get(handles.RootFile,'String');
|
---|
| 1252 | imainfo=imfinfo([fullfile(RootPath,SubDir,RootFile) FileIndices FileExt]);
|
---|
| 1253 | else
|
---|
| 1254 | imainfo=imfinfo([FileBase FileIndices FileExt]);
|
---|
| 1255 | end
|
---|
| 1256 | ColorType=imainfo.ColorType;%='truecolor' for color images
|
---|
| 1257 | if length(imainfo) >1 %case of image with multiple frames
|
---|
| 1258 | nbfield_1=length(imainfo);
|
---|
[334] | 1259 | nbfield_j_1=1;
|
---|
[199] | 1260 | end
|
---|
| 1261 | end
|
---|
| 1262 | if ~strcmp(hhh,'')&& mmreader.isPlatformSupported()% if the function is found (recent version of matlab)
|
---|
| 1263 | UvData.MovieObject_1=mmreader([FileBase FileIndices FileExt]);
|
---|
| 1264 | elseif isfield(UvData,'MovieObject_1')
|
---|
| 1265 | UvData=rmfield(UvData,'MovieObject_1');
|
---|
| 1266 | end
|
---|
| 1267 | if ~isempty(imainfo)% (an image has been introduced as second fierld input)
|
---|
[292] | 1268 | if strcmp(get(handles.num_Npx,'String'),'') || strcmp(get(handles.num_Npy,'String'),'')%update npx and npy if it is not already filled by the first input field
|
---|
[199] | 1269 | if isfield(imainfo,'Width') && isfield(imainfo,'Height')
|
---|
[292] | 1270 | set(handles.num_Npx,'String',num2str(imainfo.Width));%fills nbre of pixels x box
|
---|
| 1271 | set(handles.num_Npy,'String',num2str(imainfo.Height));%fills nbre of pixels x box
|
---|
[199] | 1272 | else
|
---|
[292] | 1273 | set(handles.num_Npx,'String','');%fills nbre of pixels x box
|
---|
| 1274 | set(handles.num_Npy,'String','');%fills nbre of pixels x box
|
---|
[199] | 1275 | end
|
---|
[292] | 1276 | set(handles.CheckBW,'Value',strcmp(ColorType,'grayscale'))% select handles.CheckBW if grayscale image
|
---|
[199] | 1277 | end
|
---|
| 1278 | end
|
---|
| 1279 | % find scaling parameters
|
---|
| 1280 | filexml=[FileBase '.xml'];
|
---|
| 1281 | fileciv=[FileBase '.civ'];
|
---|
| 1282 | warntext='';%default warning text
|
---|
| 1283 | if exist(filexml,'file')
|
---|
| 1284 | [XmlData,warntext]=imadoc2struct(filexml);
|
---|
| 1285 | if ~isempty(warntext)
|
---|
| 1286 | msgbox_uvmat('WARNING',warntext)
|
---|
| 1287 | end
|
---|
| 1288 | if isfield(XmlData,'Camera')
|
---|
| 1289 | if isfield(XmlData.Camera,'TimeUnit')&& ~isempty(XmlData.Camera.TimeUnit)
|
---|
| 1290 | TimeUnit=XmlData.Camera.TimeUnit;
|
---|
| 1291 | end
|
---|
| 1292 | end
|
---|
| 1293 | elseif exist(fileciv,'file')% if .civ file found
|
---|
| 1294 | [error,XmlData.Time,TimeUnit,mode,npx,npy,pxcmx,pxcmy]=read_imatext([FileBase '.civ']);
|
---|
| 1295 | GeometryCalib.R=[pxcmx 0 0; 0 pxcmy 0;0 0 0];
|
---|
| 1296 | GeometryCalib.Tx=0;
|
---|
| 1297 | GeometryCalib.Ty=0;
|
---|
| 1298 | GeometryCalib.Tz=1;
|
---|
| 1299 | GeometryCalib.dpx=1;
|
---|
| 1300 | GeometryCalib.dpy=1;
|
---|
| 1301 | GeometryCalib.sx=1;
|
---|
| 1302 | GeometryCalib.Cx=0;
|
---|
| 1303 | GeometryCalib.Cy=0;
|
---|
| 1304 | GeometryCalib.f=1;
|
---|
| 1305 | GeometryCalib.kappa1=0;
|
---|
| 1306 | GeometryCalib.CoordUnit='cm';
|
---|
| 1307 | XmlData.GeometryCalib=GeometryCalib;
|
---|
| 1308 | if error==2, warntext=['no file ' FileBase '.civ'];
|
---|
| 1309 | elseif error==1, warntext='inconsistent number of fields in the .civ file';
|
---|
| 1310 | end
|
---|
| 1311 |
|
---|
[292] | 1312 | set(handles.num_Npx,'String',num2str(npx));%fills nbre of pixels x box
|
---|
| 1313 | set(handles.num_Npy,'String',num2str(npy));%fills nbre of pixels y box
|
---|
[199] | 1314 | set(handles.pxcm,'String',num2str(pxcmx));%fills scale x (pixel/cm) box
|
---|
| 1315 | set(handles.pycm,'String',num2str(pxcmy));%fills scale y (pixel/cm) box
|
---|
| 1316 | set(handles.pxcm,'Visible','on');%fills scale x (pixel/cm) box
|
---|
| 1317 | set(handles.pycm,'Visible','on');%fills scale y (pixel/cm) box
|
---|
| 1318 | end
|
---|
| 1319 | if ~isempty(TimeUnit_1) && ~isequal(TimeUnit_1,TimeUnit)
|
---|
| 1320 | msgbox_uvmat('WARNING','the time units for the second series differs from the first one')
|
---|
| 1321 | end
|
---|
| 1322 |
|
---|
| 1323 | % store last index in handles.lat_i and .last_j
|
---|
| 1324 | if ~isempty(XmlData.Time)
|
---|
| 1325 | nbfield_1=size(XmlData.Time,1);
|
---|
[334] | 1326 | nbfield_j_1=size(XmlData.Time,2);
|
---|
[199] | 1327 | end
|
---|
| 1328 | last_i_cell=get(handles.last_i,'String');
|
---|
| 1329 | if isempty(nbfield_1)
|
---|
| 1330 | last_i_cell{2}='';
|
---|
| 1331 | else
|
---|
| 1332 | last_i_cell{2}=num2str(nbfield_1);
|
---|
| 1333 | end
|
---|
| 1334 | set(handles.last_i,'String',last_i_cell)
|
---|
| 1335 | last_j_cell=get(handles.last_j,'String');
|
---|
[334] | 1336 | if isempty(nbfield_j_1)
|
---|
[199] | 1337 | last_j_cell{2}='';
|
---|
| 1338 | else
|
---|
[334] | 1339 | last_j_cell{2}=num2str(nbfield_j_1);
|
---|
[199] | 1340 | end
|
---|
| 1341 | set(handles.last_j,'String',last_j_cell);
|
---|
| 1342 | if ~isequal(last_i_cell{1},last_i_cell{2}) || ~isequal(last_j_cell{1},last_j_cell{2})
|
---|
| 1343 | msgbox_uvmat('WARNING','the numbers of input file of the second series differs from the first one')
|
---|
| 1344 | end
|
---|
| 1345 |
|
---|
| 1346 | % store calibration data
|
---|
| 1347 | GeometryCalib=XmlData.GeometryCalib;
|
---|
| 1348 | if isempty(GeometryCalib)
|
---|
| 1349 | if isfield(UvData, 'GeometryCalib_1')
|
---|
| 1350 | UvData=rmfield(UvData,'GeometryCalib_1');
|
---|
| 1351 | end
|
---|
| 1352 | else
|
---|
| 1353 | UvData.GeometryCalib_1=GeometryCalib;
|
---|
| 1354 | if (isfield(GeometryCalib,'R')&& ~isequal(GeometryCalib.R(2,1),0) && ~isequal(GeometryCalib.R(1,2),0)) ||...
|
---|
| 1355 | (isfield(GeometryCalib,'kappa1')&& ~isequal(GeometryCalib.kappa1,0))
|
---|
| 1356 | set(handles.pxcm,'String','var')
|
---|
| 1357 | set(handles.pycm,'String','var')
|
---|
| 1358 | else
|
---|
| 1359 | if isfield(GeometryCalib,'fx_fy')
|
---|
| 1360 | pixcmx=GeometryCalib.fx_fy(1);
|
---|
| 1361 | pixcmy=GeometryCalib.fx_fy(2);
|
---|
| 1362 | set(handles.pxcm,'String',num2str(pixcmx))
|
---|
| 1363 | set(handles.pycm,'String',num2str(pixcmy))
|
---|
| 1364 | end
|
---|
| 1365 | end
|
---|
| 1366 | end
|
---|
| 1367 | UvData.XmlData_1=XmlData;
|
---|
| 1368 | set(handles.uvmat,'UserData',UvData)%update the data attached to the uvmat interface
|
---|
| 1369 |
|
---|
| 1370 | if ~isequal(warntext,'')
|
---|
| 1371 | msgbox_uvmat('WARNING',warntext)
|
---|
| 1372 | end
|
---|
| 1373 |
|
---|
| 1374 | set(handles.RootPath_1,'BackgroundColor',[1 1 1])% signa the end the input operation
|
---|
| 1375 | drawnow
|
---|
| 1376 |
|
---|
[334] | 1377 | set_scan_options(handles)
|
---|
[199] | 1378 |
|
---|
[309] | 1379 | %------------------------------------------------------------------------
|
---|
| 1380 | % --- switch file index scanning options scan_i and scan_j in an exclusive way
|
---|
[199] | 1381 | function scan_i_Callback(hObject, eventdata, handles)
|
---|
[309] | 1382 | %------------------------------------------------------------------------
|
---|
[199] | 1383 | if get(handles.scan_i,'Value')==1
|
---|
| 1384 | set(handles.scan_i,'BackgroundColor',[1 1 0])
|
---|
| 1385 | set(handles.scan_j,'Value',0)
|
---|
| 1386 | % set(handles.scan_j,'BackgroundColor',[0.831 0.816 0.784])
|
---|
| 1387 | else
|
---|
| 1388 | set(handles.scan_i,'BackgroundColor',[0.831 0.816 0.784])
|
---|
| 1389 | set(handles.scan_j,'Value',1)
|
---|
| 1390 | % set(handles.scan_j,'BackgroundColor',[1 1 0])
|
---|
| 1391 | end
|
---|
| 1392 | scan_j_Callback(hObject, eventdata, handles)
|
---|
| 1393 |
|
---|
[309] | 1394 | %------------------------------------------------------------------------
|
---|
| 1395 | % --- switch file index scanning options scan_i and scan_j in an exclusive way
|
---|
[199] | 1396 | function scan_j_Callback(hObject, eventdata, handles)
|
---|
[309] | 1397 | %------------------------------------------------------------------------
|
---|
[199] | 1398 | if get(handles.scan_j,'Value')==1
|
---|
| 1399 | set(handles.scan_j,'BackgroundColor',[1 1 0])
|
---|
| 1400 | set(handles.scan_i,'Value',0)
|
---|
| 1401 | set(handles.scan_i,'BackgroundColor',[0.831 0.816 0.784])
|
---|
[323] | 1402 | NomType=get(handles.NomType,'String');
|
---|
| 1403 | % NomType=get(handles.FileIndex,'UserData');
|
---|
[199] | 1404 | switch NomType
|
---|
[332] | 1405 | case {'_1_1-2','#_ab','%3dab'},% pair with j index
|
---|
[199] | 1406 | set(handles.fix_pair,'Visible','on')% option fixed pair on/off made visible (choice of avaible pair with buttons + and - if ='off')
|
---|
| 1407 | otherwise
|
---|
| 1408 | set(handles.fix_pair,'Visible','off')
|
---|
| 1409 | end
|
---|
| 1410 | else
|
---|
| 1411 | set(handles.scan_j,'BackgroundColor',[0.831 0.816 0.784])
|
---|
| 1412 | set(handles.scan_i,'Value',1)
|
---|
| 1413 | set(handles.scan_i,'BackgroundColor',[1 1 0])
|
---|
| 1414 | set(handles.fix_pair,'Visible','off')
|
---|
| 1415 | end
|
---|
| 1416 |
|
---|
[309] | 1417 | %------------------------------------------------------------------------
|
---|
[199] | 1418 | function i1_Callback(hObject, eventdata, handles)
|
---|
[309] | 1419 | %------------------------------------------------------------------------
|
---|
[199] | 1420 | set(handles.i1,'BackgroundColor',[0.7 0.7 0.7])
|
---|
[323] | 1421 | NomType=get(handles.NomType,'String');
|
---|
| 1422 | % NomType=get(handles.FileIndex,'UserData');
|
---|
[199] | 1423 | num1=stra2num(get(handles.i1,'String'));
|
---|
| 1424 | num2=stra2num(get(handles.i2,'String'));
|
---|
| 1425 | num_a=stra2num(get(handles.j1,'String'));
|
---|
| 1426 | num_b=stra2num(get(handles.j2,'String'));
|
---|
| 1427 | indices=name_generator('',num1,num_a,'',NomType,1,num2,num_b,'');
|
---|
| 1428 | set(handles.FileIndex,'String',indices)
|
---|
| 1429 | set(handles.FileIndex,'BackgroundColor',[0.7 0.7 0.7])
|
---|
| 1430 | if get(handles.SubField,'Value')==1
|
---|
[334] | 1431 | NomType_1=get(handles.NomType_1,'String');
|
---|
| 1432 | % FileExt_1=get(handles.FileExt_1,'String');
|
---|
| 1433 | % [P,F,str1,str2,str_a,str_b,Ext,NomType_1]=name2display(['xx' NomType_1 FileExt_1]);
|
---|
[199] | 1434 | indices=name_generator('',num1,num_a,'',NomType_1,1,num2,num_b,'');
|
---|
| 1435 | set(handles.FileIndex_1,'String',indices)
|
---|
| 1436 | set(handles.FileIndex_1,'BackgroundColor',[0.7 0.7 0.7])
|
---|
| 1437 | end
|
---|
| 1438 |
|
---|
[309] | 1439 | %------------------------------------------------------------------------
|
---|
[199] | 1440 | function i2_Callback(hObject, eventdata, handles)
|
---|
[309] | 1441 | %------------------------------------------------------------------------
|
---|
[199] | 1442 | set(handles.i2,'BackgroundColor',[0.7 0.7 0.7])
|
---|
| 1443 | i1_Callback(hObject, eventdata, handles)
|
---|
| 1444 |
|
---|
[309] | 1445 | %------------------------------------------------------------------------
|
---|
[199] | 1446 | function j1_Callback(hObject, eventdata, handles)
|
---|
[309] | 1447 | %------------------------------------------------------------------------
|
---|
[199] | 1448 | set(handles.j1,'BackgroundColor',[0.7 0.7 0.7])
|
---|
| 1449 | i1_Callback(hObject, eventdata, handles)
|
---|
| 1450 |
|
---|
[309] | 1451 | %------------------------------------------------------------------------
|
---|
[199] | 1452 | function j2_Callback(hObject, eventdata, handles)
|
---|
[309] | 1453 | %------------------------------------------------------------------------
|
---|
[199] | 1454 | set(handles.j2,'BackgroundColor',[0.7 0.7 0.7])
|
---|
| 1455 | i1_Callback(hObject, eventdata, handles)
|
---|
| 1456 |
|
---|
[309] | 1457 | %------------------------------------------------------------------------
|
---|
[199] | 1458 | function slices_Callback(hObject, eventdata, handles)
|
---|
[309] | 1459 | %------------------------------------------------------------------------
|
---|
[199] | 1460 | if get(handles.slices,'Value')==1
|
---|
| 1461 | set(handles.slices,'BackgroundColor',[1 1 0])
|
---|
| 1462 | set(handles.nb_slice,'Visible','on')
|
---|
| 1463 | set(handles.z_text,'Visible','on')
|
---|
| 1464 | set(handles.z_index,'Visible','on')
|
---|
| 1465 | nb_slice_Callback(hObject, eventdata, handles)
|
---|
| 1466 | else
|
---|
| 1467 | set(handles.nb_slice,'Visible','off')
|
---|
| 1468 | set(handles.slices,'BackgroundColor',[0.7 0.7 0.7])
|
---|
| 1469 | set(handles.z_text,'Visible','off')
|
---|
| 1470 | set(handles.z_index,'Visible','off')
|
---|
| 1471 | set(handles.masklevel,'Value',1)
|
---|
| 1472 | set(handles.masklevel,'String',{'1'})
|
---|
| 1473 | end
|
---|
| 1474 |
|
---|
[309] | 1475 | %------------------------------------------------------------------------
|
---|
[199] | 1476 | function nb_slice_Callback(hObject, eventdata, handles)
|
---|
[309] | 1477 | %------------------------------------------------------------------------
|
---|
[199] | 1478 | nb_slice_str=get(handles.nb_slice,'String');
|
---|
| 1479 | if isequal(nb_slice_str,'volume')
|
---|
| 1480 | num=stra2num(get(handles.j1,'String'));
|
---|
| 1481 | last_j=get(handles.last_j,'String');
|
---|
| 1482 | nbslice=str2double(last_j{1});
|
---|
| 1483 | else
|
---|
| 1484 | num=str2double(get(handles.i1,'String'));
|
---|
| 1485 | nbslice=str2double(get(handles.nb_slice,'String'));
|
---|
| 1486 | end
|
---|
| 1487 | z=mod(num-1,nbslice)+1;
|
---|
| 1488 | set(handles.z_index,'String',num2str(z))
|
---|
| 1489 | for ilist=1:nbslice
|
---|
| 1490 | list_index{ilist,1}=num2str(ilist);
|
---|
| 1491 | end
|
---|
| 1492 | set(handles.masklevel,'String',list_index)
|
---|
| 1493 | set(handles.masklevel,'Value',z)
|
---|
| 1494 |
|
---|
| 1495 | %------------------------------------------------------------------------
|
---|
| 1496 | % --- Executes on button press in view_xml.
|
---|
| 1497 | function view_xml_Callback(hObject, eventdata, handles)
|
---|
| 1498 | %------------------------------------------------------------------------
|
---|
| 1499 | [FileName,RootPath,FileBase,FileIndices,FileExt]=read_file_boxes(handles);
|
---|
| 1500 | option=get(handles.view_xml,'String');
|
---|
| 1501 | if isequal(option,'view .xml')
|
---|
| 1502 | FileXml=[FileBase '.xml'];
|
---|
| 1503 | heditxml=editxml(FileXml);
|
---|
| 1504 | end
|
---|
| 1505 |
|
---|
| 1506 | %------------------------------------------------------------------------
|
---|
[315] | 1507 | % --- Executes on button press in CheckMask.
|
---|
| 1508 | function CheckMask_Callback(hObject, eventdata, handles)
|
---|
[199] | 1509 | %------------------------------------------------------------------------
|
---|
| 1510 | %case of view mask selection
|
---|
[315] | 1511 | if isequal(get(handles.CheckMask,'Value'),1)
|
---|
[199] | 1512 | [FF,RootPath,FileBase]=read_file_boxes(handles);
|
---|
| 1513 | num_i1=stra2num(get(handles.i1,'String'));
|
---|
| 1514 | num_j1=stra2num(get(handles.j1,'String'));
|
---|
| 1515 | currentdir=pwd;
|
---|
| 1516 | cd(RootPath);
|
---|
| 1517 | maskfiles=dir('*_*mask_*.png');%look for a mask file
|
---|
| 1518 | cd(currentdir);%come back to the working directory
|
---|
| 1519 | mdetect=0;
|
---|
| 1520 | if ~isempty(maskfiles)
|
---|
| 1521 | for ilist=1:length(maskfiles)
|
---|
| 1522 | maskname=maskfiles(ilist).name;% take the first mask file in the list
|
---|
[334] | 1523 | [~,~,~,~,~,~,~,MaskExt,Mask_NomType{ilist}]=fileparts_uvmat(maskname);
|
---|
| 1524 | % [rr,ff,x1,x2,xa,xb,xext,Mask_NomType{ilist}]=name2display(maskname);
|
---|
| 1525 | [~,Name]=fileparts(maskname);
|
---|
[199] | 1526 | Namedouble=double(Name);
|
---|
| 1527 | val=(48>Namedouble)|(Namedouble>57);% select the non-numerical characters
|
---|
| 1528 | ind_mask=findstr('mask',Name);
|
---|
| 1529 | i=ind_mask-1;
|
---|
| 1530 | while val(i)==0 && i>0
|
---|
| 1531 | i=i-1;
|
---|
| 1532 | end
|
---|
| 1533 | nbmask_str=str2num(Name(i+1:ind_mask-1));
|
---|
| 1534 | if ~isempty(nbmask_str)
|
---|
| 1535 | nbslice(ilist)=nbmask_str; % number of different masks (slices)
|
---|
| 1536 | end
|
---|
| 1537 | end
|
---|
| 1538 | if isequal(min(nbslice),max(nbslice))
|
---|
| 1539 | nbslice=nbslice(1);
|
---|
| 1540 | else
|
---|
| 1541 | msgbox_uvmat('ERROR','several inconsistent mask sets coexist in the current image directory')
|
---|
| 1542 | return
|
---|
| 1543 | end
|
---|
| 1544 | if ~isempty(nbslice) && Name(i)=='_'
|
---|
| 1545 | Mask.Base=[FileBase Name(i:ind_mask+3)];
|
---|
| 1546 | Mask.NbSlice=nbslice;
|
---|
| 1547 | num_i1=mod(num_i1-1,nbslice)+1;
|
---|
[248] | 1548 | Mask.NomType=regexprep(Mask_NomType{1},'0','');%remove '0' in nom type for masks
|
---|
[251] | 1549 | maskname=name_generator(Mask.Base,num_i1,num_j1,'.png',Mask.NomType);%
|
---|
[199] | 1550 | mdetect=exist(maskname,'file');
|
---|
| 1551 | if mdetect
|
---|
| 1552 | set(handles.nb_slice,'String',Name(i+1:ind_mask-1));
|
---|
| 1553 | set(handles.nb_slice,'BackgroundColor',[1 1 0])
|
---|
[315] | 1554 | set(handles.CheckMask,'UserData',Mask);
|
---|
| 1555 | set(handles.CheckMask,'BackgroundColor',[1 1 0])
|
---|
[199] | 1556 | if nbslice > 1
|
---|
| 1557 | set(handles.slices,'value',1)
|
---|
| 1558 | slices_Callback(hObject, eventdata, handles)
|
---|
| 1559 | end
|
---|
| 1560 | end
|
---|
| 1561 | end
|
---|
| 1562 | end
|
---|
| 1563 | errormsg=[];%default
|
---|
| 1564 | if mdetect==0
|
---|
| 1565 | [FileName, PathName, filterindex] = uigetfile( ...
|
---|
| 1566 | {'*.png', ' (*.png)';
|
---|
| 1567 | '*.png', '.png files '; ...
|
---|
| 1568 | '*.*', 'All Files (*.*)'}, ...
|
---|
| 1569 | 'Pick a mask file *.png',FileBase);
|
---|
| 1570 | maskname=fullfile(PathName,FileName);
|
---|
| 1571 | if ~exist(maskname,'file')
|
---|
| 1572 | errormsg='no file browsed';
|
---|
| 1573 | end
|
---|
[334] | 1574 | [RootDir,~,RootFile,~,~,~,~,~,Mask.NomType]=fileparts_uvmat(maskname);
|
---|
| 1575 | % [RootDir,RootFile,x1,x2,xa,xb,xext,Mask.NomType]=name2display(maskname);
|
---|
[199] | 1576 | Mask.Base=fullfile(RootDir,RootFile);
|
---|
| 1577 | Mask.NbSlice=1;
|
---|
[315] | 1578 | set(handles.CheckMask,'UserData',Mask);
|
---|
| 1579 | set(handles.CheckMask,'BackgroundColor',[1 1 0])
|
---|
[199] | 1580 | end
|
---|
| 1581 | if isempty(errormsg)
|
---|
| 1582 | errormsg=update_mask(handles,num_i1,num_j1);
|
---|
| 1583 | end
|
---|
| 1584 | if ~isempty(errormsg)
|
---|
[315] | 1585 | set(handles.CheckMask,'Value',0)
|
---|
| 1586 | set(handles.CheckMask,'BackgroundColor',[0.7 0.7 0.7])
|
---|
[199] | 1587 | end
|
---|
[315] | 1588 | else % desactivate mask display
|
---|
| 1589 | MaskData=get(handles.CheckMask,'UserData');
|
---|
[199] | 1590 | if isfield(MaskData,'maskhandle') && ishandle(MaskData.maskhandle)
|
---|
| 1591 | delete(MaskData.maskhandle)
|
---|
| 1592 | end
|
---|
[315] | 1593 | set(handles.CheckMask,'UserData',[])
|
---|
[199] | 1594 | UvData=get(handles.uvmat,'UserData');
|
---|
| 1595 | if isfield(UvData,'MaskName')
|
---|
| 1596 | UvData=rmfield(UvData,'MaskName');
|
---|
| 1597 | set(handles.uvmat,'UserData',UvData)
|
---|
| 1598 | end
|
---|
[315] | 1599 | set(handles.CheckMask,'BackgroundColor',[0.7 0.7 0.7])
|
---|
[199] | 1600 | end
|
---|
| 1601 |
|
---|
[309] | 1602 | %------------------------------------------------------------------------
|
---|
[199] | 1603 | function errormsg=update_mask(handles,num_i1,num_j1)
|
---|
[309] | 1604 | %------------------------------------------------------------------------
|
---|
[199] | 1605 | errormsg=[];%default
|
---|
[315] | 1606 | MaskData=get(handles.CheckMask,'UserData');
|
---|
[199] | 1607 | if isfield(MaskData,'maskhandle')&& ishandle(MaskData.maskhandle)
|
---|
| 1608 | uistack(MaskData.maskhandle,'top');
|
---|
| 1609 | end
|
---|
| 1610 | num_i1_mask=mod(num_i1-1,MaskData.NbSlice)+1;
|
---|
| 1611 | MaskName=name_generator(MaskData.Base,num_i1_mask,num_j1,'.png',MaskData.NomType);
|
---|
[315] | 1612 | huvmat=get(handles.CheckMask,'parent');
|
---|
[199] | 1613 | UvData=get(huvmat,'UserData');
|
---|
| 1614 |
|
---|
| 1615 | %update mask image if the mask is new
|
---|
| 1616 | if ~ (isfield(UvData,'MaskName') && isequal(UvData.MaskName,MaskName))
|
---|
| 1617 | UvData.MaskName=MaskName; %update the recorded name on UvData
|
---|
| 1618 | set(huvmat,'UserData',UvData);
|
---|
| 1619 | if ~exist(MaskName,'file')
|
---|
| 1620 | if isfield(MaskData,'maskhandle')&& ishandle(MaskData.maskhandle)
|
---|
| 1621 | delete(MaskData.maskhandle)
|
---|
| 1622 | end
|
---|
| 1623 | else
|
---|
| 1624 | %read mask image
|
---|
| 1625 | Mask.AName='image';
|
---|
| 1626 | Mask.A=imread(MaskName);
|
---|
| 1627 | npxy=size(Mask.A);
|
---|
| 1628 | test_error=0;
|
---|
| 1629 | if length(npxy)>2
|
---|
| 1630 | errormsg=[MaskName ' is not a grey scale image'];
|
---|
| 1631 | return
|
---|
| 1632 | elseif ~isa(Mask.A,'uint8')
|
---|
| 1633 | errormsg=[MaskName ' is not a 8 bit grey level image'];
|
---|
| 1634 | return
|
---|
| 1635 | end
|
---|
| 1636 | Mask.AX=[0.5 npxy(2)-0.5];
|
---|
| 1637 | Mask.AY=[npxy(1)-0.5 0.5 ];
|
---|
| 1638 | Mask.CoordUnit='pixel';
|
---|
| 1639 | if isequal(get(handles.slices,'Value'),1)
|
---|
| 1640 | NbSlice=str2num(get(handles.nb_slice,'String'));
|
---|
| 1641 | num_i1=str2num(get(handles.i1,'String'));
|
---|
| 1642 | Mask.ZIndex=mod(num_i1-1,NbSlice)+1;
|
---|
| 1643 | end
|
---|
| 1644 | %px to phys or other transform on field
|
---|
| 1645 | menu_transform=get(handles.transform_fct,'String');
|
---|
| 1646 | choice_value=get(handles.transform_fct,'Value');
|
---|
| 1647 | transform_name=menu_transform{choice_value};%name of the transform fct given by the menu 'transform_fct'
|
---|
| 1648 | transform_list=get(handles.transform_fct,'UserData');
|
---|
| 1649 | transform=transform_list{choice_value};
|
---|
| 1650 | if ~isequal(transform_name,'') && ~isequal(transform_name,'px')
|
---|
| 1651 | if isfield(UvData,'XmlData') && isfield(UvData.XmlData,'GeometryCalib')%use geometry calib recorded from the ImaDoc xml file as first priority
|
---|
| 1652 | Calib=UvData.XmlData.GeometryCalib;
|
---|
| 1653 | Mask=transform(Mask,UvData.XmlData);
|
---|
| 1654 | end
|
---|
| 1655 | end
|
---|
| 1656 | flagmask=Mask.A < 200;
|
---|
| 1657 |
|
---|
| 1658 | %make brown color image
|
---|
| 1659 | imflag(:,:,1)=0.9*flagmask;
|
---|
| 1660 | imflag(:,:,2)=0.7*flagmask;
|
---|
| 1661 | imflag(:,:,3)=zeros(size(flagmask));
|
---|
| 1662 |
|
---|
| 1663 | %update mask image
|
---|
| 1664 | hmask=[]; %default
|
---|
| 1665 | if isfield(MaskData,'maskhandle')&& ishandle(MaskData.maskhandle)
|
---|
| 1666 | hmask=MaskData.maskhandle;
|
---|
| 1667 | end
|
---|
| 1668 | if ~isempty(hmask)
|
---|
| 1669 | set(hmask,'CData',imflag)
|
---|
| 1670 | set(hmask,'AlphaData',flagmask*0.6)
|
---|
| 1671 | set(hmask,'XData',Mask.AX);
|
---|
| 1672 | set(hmask,'YData',Mask.AY);
|
---|
| 1673 | % uistack(hmask,'top')
|
---|
| 1674 | else
|
---|
| 1675 | axes(handles.axes3)
|
---|
| 1676 | hold on
|
---|
| 1677 | MaskData.maskhandle=image(Mask.AX,Mask.AY,imflag,'Tag','mask','HitTest','off','AlphaData',0.6*flagmask);
|
---|
| 1678 | % set(MaskData.maskhandle,'AlphaData',0.6*flagmask)
|
---|
[315] | 1679 | set(handles.CheckMask,'UserData',MaskData)
|
---|
[199] | 1680 | end
|
---|
| 1681 | end
|
---|
| 1682 | end
|
---|
| 1683 |
|
---|
| 1684 |
|
---|
[309] | 1685 | %------------------------------------------------------------------------
|
---|
[199] | 1686 | function MenuExportFigure_Callback(hObject, eventdata, handles)
|
---|
[309] | 1687 | %------------------------------------------------------------------------
|
---|
[199] | 1688 | huvmat=get(handles.MenuExport,'parent');
|
---|
| 1689 | hfig=figure;
|
---|
| 1690 | copyobj(handles.axes3,hfig);
|
---|
| 1691 | map=colormap(handles.axes3);
|
---|
| 1692 | colormap(map);%transmit the current colormap to the zoom fig
|
---|
| 1693 | colorbar
|
---|
| 1694 |
|
---|
[309] | 1695 | %------------------------------------------------------------------------
|
---|
| 1696 | %------------------------------------------------------------------------
|
---|
[199] | 1697 | % III - MAIN REFRESH FUNCTIONS : 'FRAME PLOT'
|
---|
[309] | 1698 | %------------------------------------------------------------------------
|
---|
[199] | 1699 |
|
---|
[309] | 1700 | %------------------------------------------------------------------------
|
---|
[199] | 1701 | % --- Executes on button press in runplus: make one step forward and call
|
---|
| 1702 | % --- run0. The step forward is along the fields series 1 or 2 depending on
|
---|
| 1703 | % --- the scan_i and scan_j check box (exclusive each other)
|
---|
| 1704 | function runplus_Callback(hObject, eventdata, handles)
|
---|
[309] | 1705 | %------------------------------------------------------------------------
|
---|
[199] | 1706 | set(handles.runplus,'BackgroundColor',[1 1 0])%paint the command button in yellow
|
---|
| 1707 | drawnow
|
---|
| 1708 | %TODO: introduce the option: increment ='*' to move to the next available view
|
---|
| 1709 | increment=str2double(get(handles.increment_scan,'String')); %get the field increment d
|
---|
| 1710 | if isnan(increment)
|
---|
| 1711 | set(handles.increment_scan,'String','1')%default value
|
---|
| 1712 | increment=1;
|
---|
| 1713 | end
|
---|
| 1714 | errormsg=runpm(hObject,eventdata,handles,increment);
|
---|
| 1715 | if ~isempty(errormsg)
|
---|
| 1716 | msgbox_uvmat('ERROR',errormsg);
|
---|
| 1717 | end
|
---|
| 1718 | set(handles.runplus,'BackgroundColor',[1 0 0])%paint the command button back to red
|
---|
| 1719 |
|
---|
[309] | 1720 | %------------------------------------------------------------------------
|
---|
[199] | 1721 | % --- Executes on button press in runmin: make one step backward and call
|
---|
| 1722 | % --- run0. The step backward is along the fields series 1 or 2 depending on
|
---|
| 1723 | % --- the scan_i and scan_j check box (exclusive each other)
|
---|
| 1724 | function runmin_Callback(hObject, eventdata, handles)
|
---|
[309] | 1725 | %------------------------------------------------------------------------
|
---|
[199] | 1726 | set(handles.runmin,'BackgroundColor',[1 1 0])%paint the command button in yellow
|
---|
| 1727 | drawnow
|
---|
| 1728 | increment=-str2double(get(handles.increment_scan,'String')); %get the field increment d
|
---|
| 1729 | if isnan(increment)
|
---|
| 1730 | set(handles.increment_scan,'String','1')%default value
|
---|
| 1731 | increment=1;
|
---|
| 1732 | end
|
---|
| 1733 | errormsg=runpm(hObject,eventdata,handles,increment);
|
---|
| 1734 | if ~isempty(errormsg)
|
---|
| 1735 | msgbox_uvmat('ERROR',errormsg);
|
---|
| 1736 | end
|
---|
| 1737 | set(handles.runmin,'BackgroundColor',[1 0 0])%paint the command button back to red
|
---|
| 1738 |
|
---|
[309] | 1739 | %------------------------------------------------------------------------
|
---|
[199] | 1740 | % -- Executes on button press in Movie: make a series of +> steps
|
---|
| 1741 | function Movie_Callback(hObject, eventdata, handles)
|
---|
[309] | 1742 | %------------------------------------------------------------------------
|
---|
[199] | 1743 | set(handles.Movie,'BackgroundColor',[1 1 0])%paint the command button in yellow
|
---|
| 1744 | drawnow
|
---|
| 1745 | increment=str2double(get(handles.increment_scan,'String')); %get the field increment d
|
---|
| 1746 | if isnan(increment)
|
---|
| 1747 | set(handles.increment_scan,'String','1')%default value
|
---|
| 1748 | increment=1;
|
---|
| 1749 | end
|
---|
| 1750 | set(handles.STOP,'Visible','on')
|
---|
| 1751 | set(handles.speed,'Visible','on')
|
---|
| 1752 | set(handles.speed_txt,'Visible','on')
|
---|
| 1753 | set(handles.Movie,'BusyAction','queue')
|
---|
| 1754 | UvData=get(handles.uvmat,'UserData');
|
---|
| 1755 |
|
---|
| 1756 | while get(handles.speed,'Value')~=0 && isequal(get(handles.Movie,'BusyAction'),'queue') % enable STOP command
|
---|
| 1757 | errormsg=runpm(hObject,eventdata,handles,increment);
|
---|
| 1758 | if ~isempty(errormsg)
|
---|
| 1759 | set(handles.Movie,'BackgroundColor',[1 0 0])%paint the command buttonback to red
|
---|
| 1760 | return
|
---|
| 1761 | end
|
---|
| 1762 | pause(1.02-get(handles.speed,'Value'))% wait for next image
|
---|
| 1763 | end
|
---|
| 1764 | if isfield(UvData,'aviobj') && ~isempty( UvData.aviobj),
|
---|
| 1765 | UvData.aviobj=close(UvData.aviobj);
|
---|
| 1766 | set(handles.uvmat,'UserData',UvData);
|
---|
| 1767 | end
|
---|
| 1768 | set(handles.Movie,'BackgroundColor',[1 0 0])%paint the command buttonback to red
|
---|
| 1769 |
|
---|
[309] | 1770 | %------------------------------------------------------------------------
|
---|
[199] | 1771 | % -- Executes on button press in Movie: make a series of <- steps
|
---|
| 1772 | function MovieBackward_Callback(hObject, eventdata, handles)
|
---|
[309] | 1773 | %------------------------------------------------------------------------
|
---|
[199] | 1774 | set(handles.MovieBackward,'BackgroundColor',[1 1 0])%paint the command button in yellow
|
---|
| 1775 | drawnow
|
---|
| 1776 | increment=-str2double(get(handles.increment_scan,'String')); %get the field increment d
|
---|
| 1777 | if isnan(increment)
|
---|
| 1778 | set(handles.increment_scan,'String','1')%default value
|
---|
| 1779 | increment=1;
|
---|
| 1780 | end
|
---|
| 1781 | set(handles.STOP,'Visible','on')
|
---|
| 1782 | set(handles.speed,'Visible','on')
|
---|
| 1783 | set(handles.speed_txt,'Visible','on')
|
---|
| 1784 | set(handles.MovieBackward,'BusyAction','queue')
|
---|
| 1785 | UvData=get(handles.uvmat,'UserData');
|
---|
| 1786 |
|
---|
| 1787 | while get(handles.speed,'Value')~=0 && isequal(get(handles.MovieBackward,'BusyAction'),'queue') % enable STOP command
|
---|
| 1788 | errormsg=runpm(hObject,eventdata,handles,increment);
|
---|
| 1789 | if ~isempty(errormsg)
|
---|
| 1790 | set(handles.MovieBackward,'BackgroundColor',[1 0 0])%paint the command buttonback to red
|
---|
| 1791 | return
|
---|
| 1792 | end
|
---|
| 1793 | pause(1.02-get(handles.speed,'Value'))% wait for next image
|
---|
| 1794 | end
|
---|
| 1795 | if isfield(UvData,'aviobj') && ~isempty( UvData.aviobj),
|
---|
| 1796 | UvData.aviobj=close(UvData.aviobj);
|
---|
| 1797 | set(handles.uvmat,'UserData',UvData);
|
---|
| 1798 | end
|
---|
| 1799 | set(handles.MovieBackward,'BackgroundColor',[1 0 0])%paint the command buttonback to red
|
---|
| 1800 |
|
---|
[309] | 1801 | %------------------------------------------------------------------------
|
---|
[199] | 1802 | function STOP_Callback(hObject, eventdata, handles)
|
---|
[309] | 1803 | %------------------------------------------------------------------------
|
---|
[199] | 1804 | set(handles.movie_pair,'BusyAction','Cancel')
|
---|
| 1805 | set(handles.movie_pair,'value',0)
|
---|
| 1806 | set(handles.Movie,'BusyAction','Cancel')
|
---|
| 1807 | set(handles.MovieBackward,'BusyAction','Cancel')
|
---|
| 1808 | set(handles.MenuExportMovie,'BusyAction','Cancel')
|
---|
| 1809 | set(handles.movie_pair,'BackgroundColor',[1 0 0])%paint the command buttonback to red
|
---|
| 1810 | set(handles.Movie,'BackgroundColor',[1 0 0])%paint the command buttonback to red
|
---|
| 1811 | set(handles.MovieBackward,'BackgroundColor',[1 0 0])%paint the command buttonback to red
|
---|
| 1812 |
|
---|
[309] | 1813 | %------------------------------------------------------------------------
|
---|
[323] | 1814 | % --- function activated by runplus and run minus
|
---|
[199] | 1815 | function errormsg=runpm(hObject,eventdata,handles,increment)
|
---|
[309] | 1816 | %------------------------------------------------------------------------
|
---|
[323] | 1817 | %% check for movie pair status
|
---|
[199] | 1818 | movie_status=get(handles.movie_pair,'Value');
|
---|
| 1819 | if isequal(movie_status,1)
|
---|
| 1820 | STOP_Callback(hObject, eventdata, handles)%interrupt movie pair if active
|
---|
| 1821 | end
|
---|
| 1822 |
|
---|
[323] | 1823 | %% read the current input file name(s) and field indices
|
---|
| 1824 | InputFile=read_GUI(handles.InputFile);
|
---|
[332] | 1825 | InputFile.RootFile=regexprep(InputFile.RootFile,'^[\\/]|[\\/]$','');%suppress possible / or \ separator at the beginning or the end of the string
|
---|
| 1826 | InputFile.SubDir=regexprep(InputFile.SubDir,'^[\\/]|[\\/]$','');%suppress possible / or \ separator at the beginning or the end of the string
|
---|
[326] | 1827 | if isempty(InputFile.RootFile)
|
---|
| 1828 | filebase=InputFile.RootPath;
|
---|
| 1829 | else
|
---|
| 1830 | filebase=fullfile(InputFile.RootPath,InputFile.RootFile);
|
---|
[323] | 1831 | end
|
---|
| 1832 | FileExt=InputFile.FileExt;
|
---|
| 1833 | % [FileName,RootPath,filebase,FileIndices,FileExt,subdir]=read_file_boxes(handles);
|
---|
| 1834 | NomType=get(handles.NomType,'String');
|
---|
| 1835 | % NomType=get(handles.FileIndex,'UserData');
|
---|
| 1836 | i1=stra2num(get(handles.i1,'String'));%read the field indices (for movie, it is not given by the file name)
|
---|
[319] | 1837 | i2=stra2num(get(handles.i2,'String'));
|
---|
| 1838 | j1=stra2num(get(handles.j1,'String'));
|
---|
| 1839 | j2=stra2num(get(handles.j2,'String'));
|
---|
[199] | 1840 | sub_value= get(handles.SubField,'Value');
|
---|
| 1841 | if sub_value % a second input file has been entered
|
---|
| 1842 | [FileName_1,RootPath_1,filebase_1,FileIndices_1,FileExt_1,SubDir_1]=read_file_boxes_1(handles);
|
---|
[334] | 1843 | [~,~,~,i1_1,i2_1,j1_1,j2_1]=fileparts_uvmat(FileIndices_1);
|
---|
| 1844 | % [pp,ff,i1_1_str,i2_1_str,j1_1_str,j2_1_str]=name2display(FileIndices_1);
|
---|
| 1845 | % i1_1=stra2num(i1_1_str);%current set of indices for the second field (may be set different than the main indices)
|
---|
| 1846 | % i2_1=stra2num(i2_1_str);
|
---|
| 1847 | % j1_1=stra2num(j1_1_str);
|
---|
| 1848 | % j2_1=stra2num(j2_1_str);
|
---|
[323] | 1849 | NomType_1=get(handles.NomType_1,'String');
|
---|
| 1850 | % NomType_1=get(handles.FileIndex_1,'UserData');
|
---|
[199] | 1851 | else
|
---|
| 1852 | filename_1=[];
|
---|
| 1853 | end
|
---|
| 1854 | comp_input=get(handles.fix_pair,'Value');
|
---|
| 1855 |
|
---|
[323] | 1856 | %% increment (or decrement) the field indices and update the input filename(s)
|
---|
[199] | 1857 | if get(handles.scan_i,'Value')==1% case of scanning along index i
|
---|
[319] | 1858 | i1=i1+increment;
|
---|
| 1859 | i2=i2+increment;
|
---|
[326] | 1860 | [filename,i1,j1,i2,j2]=name_generator(filebase,i1,j1,FileExt,NomType,comp_input,i2,j2,InputFile.SubDir);
|
---|
[199] | 1861 | if sub_value% set the second field name and indices
|
---|
[319] | 1862 | i1_1=i1_1+increment;
|
---|
| 1863 | i2_1=i2_1+increment;
|
---|
| 1864 | filename_1=name_generator(filebase_1,i1_1,j1_1,FileExt_1,NomType_1,1,i2_1,j2_1,SubDir_1);
|
---|
[199] | 1865 | end
|
---|
| 1866 | else % case of scanning along index j (burst numbers)
|
---|
[319] | 1867 | j1=j1+increment;
|
---|
| 1868 | j2=j2+increment;
|
---|
[326] | 1869 | [filename,i1,j1,i2,j2]=name_generator(filebase,i1,j1,FileExt,NomType,comp_input,i2,j2,InputFile.SubDir);
|
---|
[199] | 1870 | if sub_value
|
---|
[319] | 1871 | j1_1=j1_1+increment;
|
---|
| 1872 | j2_1=j2_1+increment;
|
---|
| 1873 | filename_1=name_generator(filebase_1,i1_1,j1_1,FileExt_1,NomType_1,1,i2_1,j2_1,SubDir_1);
|
---|
[199] | 1874 | end
|
---|
| 1875 | end
|
---|
| 1876 |
|
---|
[323] | 1877 | %% refresh plots
|
---|
[319] | 1878 | errormsg=refresh_field(handles,filename,filename_1,i1,i2,j1,j2);
|
---|
[323] | 1879 |
|
---|
| 1880 | %% update the index counters if the index move is successfull
|
---|
| 1881 | if isempty(errormsg)
|
---|
| 1882 | set(handles.i1,'String',num2stra(i1,NomType,1));
|
---|
| 1883 | if isequal(i2,i1)
|
---|
| 1884 | set(handles.i2,'String','');
|
---|
[199] | 1885 | else
|
---|
[323] | 1886 | set(handles.i2,'String',num2stra(i2,NomType,1));
|
---|
[199] | 1887 | end
|
---|
[323] | 1888 | set(handles.j1,'String',num2stra(j1,NomType,2));
|
---|
| 1889 | if isequal(j2,j1)
|
---|
| 1890 | set(handles.j2,'String','');
|
---|
| 1891 | else
|
---|
| 1892 | set(handles.j2,'String',num2stra(j2,NomType,2));
|
---|
| 1893 | end
|
---|
| 1894 | [indices]=name_generator('',i1,j1,'',NomType,1,i2,j2,'');
|
---|
| 1895 | set(handles.FileIndex,'String',indices);
|
---|
| 1896 | if ~isempty(filename_1)
|
---|
| 1897 | indices_1=name_generator('',i1_1,j1_1,'',NomType_1,1,i2_1,j2_1,'');
|
---|
| 1898 | set(handles.FileIndex_1,'String',indices_1);
|
---|
| 1899 | end
|
---|
[199] | 1900 | if isequal(movie_status,1)
|
---|
| 1901 | set(handles.movie_pair,'Value',1)
|
---|
| 1902 | movie_pair_Callback(hObject, eventdata, handles); %reactivate moviepair if it was activated
|
---|
| 1903 | end
|
---|
| 1904 | end
|
---|
| 1905 |
|
---|
[309] | 1906 | %------------------------------------------------------------------------
|
---|
[199] | 1907 | % --- Executes on button press in movie_pair: create an alternating movie with two view
|
---|
| 1908 | function movie_pair_Callback(hObject, eventdata, handles)
|
---|
[309] | 1909 | %------------------------------------------------------------------------
|
---|
[339] | 1910 |
|
---|
| 1911 | %% stop movie action if the movie_pair button is off
|
---|
| 1912 | if ~get(handles.movie_pair,'value')
|
---|
[199] | 1913 | set(handles.movie_pair,'BusyAction','Cancel')%stop movie pair if button is 'off'
|
---|
| 1914 | set(handles.i2,'String','')
|
---|
| 1915 | set(handles.j2,'String','')
|
---|
| 1916 | return
|
---|
| 1917 | else
|
---|
| 1918 | set(handles.movie_pair,'BusyAction','queue')
|
---|
| 1919 | end
|
---|
[339] | 1920 |
|
---|
| 1921 | %% initialisation
|
---|
[199] | 1922 | set(handles.movie_pair,'BackgroundColor',[1 1 0])%paint the command button in yellow
|
---|
| 1923 | drawnow
|
---|
| 1924 | list_fields=get(handles.Fields,'String');% list menu fields
|
---|
| 1925 | index_fields=get(handles.Fields,'Value');% selected string index
|
---|
| 1926 | FieldName=list_fields{index_fields}; % selected field
|
---|
| 1927 | UvData=get(handles.uvmat,'UserData');
|
---|
| 1928 | if isequal(FieldName,'image')
|
---|
| 1929 | test_1=0;
|
---|
| 1930 | [ff,rr,filebase,xx,Ext,SubDir]=read_file_boxes(handles);
|
---|
[323] | 1931 | NomType=get(handles.NomType,'String');
|
---|
[199] | 1932 | else
|
---|
| 1933 | list_fields=get(handles.Fields_1,'String');% list menu fields
|
---|
| 1934 | index_fields=get(handles.Fields_1,'Value');% selected string index
|
---|
| 1935 | FieldName=list_fields{index_fields}; % selected field
|
---|
| 1936 | if isequal(FieldName,'image')
|
---|
| 1937 | test_1=1;
|
---|
| 1938 | [ff,rr,filebase,xx,Ext,SubDir]=read_file_boxes_1(handles);
|
---|
[323] | 1939 | NomType=get(handles.NomType_1,'String');
|
---|
| 1940 | % NomType=get(handles.FileIndex_1,'UserData');
|
---|
[199] | 1941 | else
|
---|
| 1942 | msgbox_uvmat('ERROR','an image or movie must be first introduced as input')
|
---|
| 1943 | set(handles.movie_pair,'BackgroundColor',[1 0 0])%paint the command button in red
|
---|
| 1944 | return
|
---|
| 1945 | end
|
---|
| 1946 | end
|
---|
| 1947 |
|
---|
| 1948 | num_i1=str2double(get(handles.i1,'String'));
|
---|
| 1949 | num_j1=stra2num(get(handles.j1,'String'));
|
---|
| 1950 | num_i2=str2double(get(handles.i2,'String'));
|
---|
| 1951 | num_j2=stra2num(get(handles.j2,'String'));
|
---|
| 1952 | if isnan(num_j2)
|
---|
| 1953 | if isempty(num_i2)
|
---|
| 1954 | msgbox_uvmat('ERROR', 'a second image index i2 or j2 is needed to show the pair as a movie')
|
---|
| 1955 | set(handles.movie_pair,'BackgroundColor',[1 0 0])%paint the command button in red
|
---|
| 1956 | return
|
---|
| 1957 | else
|
---|
| 1958 | num_j2=num_j1;%repeat the index i1 by default
|
---|
| 1959 | end
|
---|
| 1960 | end
|
---|
| 1961 | if isnan(num_i2)
|
---|
| 1962 | num_i2=num_i1;%repeat the index i1 by default
|
---|
| 1963 | end
|
---|
| 1964 | imaname_1=name_generator(filebase,num_i2,num_j2,Ext,NomType);
|
---|
| 1965 | if ~exist(imaname_1,'file')
|
---|
| 1966 | msgbox_uvmat('ERROR',['second input open (-) ' imaname_1 ' not found']);
|
---|
| 1967 | set(handles.movie_pair,'BackgroundColor',[1 0 0])%paint the command button in red
|
---|
| 1968 | return
|
---|
| 1969 | end
|
---|
| 1970 |
|
---|
[339] | 1971 | %% read the second image
|
---|
[199] | 1972 | Field.AName='image';
|
---|
| 1973 | if test_1
|
---|
| 1974 | Field_a=UvData.Field_1;
|
---|
| 1975 | else
|
---|
| 1976 | Field_a=UvData.Field;
|
---|
| 1977 | end
|
---|
| 1978 | Field_b.AX=Field_a.AX;
|
---|
| 1979 | Field_b.AY=Field_a.AY;
|
---|
| 1980 | % z index
|
---|
| 1981 | nbslice=str2double(get(handles.nb_slice,'String'));
|
---|
| 1982 | if ~isempty(nbslice)
|
---|
| 1983 | Field_b.ZIndex=mod(num_i2-1,nbslice)+1;
|
---|
| 1984 | end
|
---|
| 1985 | Field_b.CoordUnit='pixel';
|
---|
[339] | 1986 |
|
---|
| 1987 | %% determine the input file type
|
---|
[342] | 1988 | if (test_1 && isfield(UvData,'MovieObject_1'))||(~test_1 && ~isempty(UvData.MovieObject))
|
---|
[199] | 1989 | FileType='movie';
|
---|
| 1990 | elseif isequal(lower(Ext),'.avi')
|
---|
| 1991 | FileType='avi';
|
---|
| 1992 | elseif isequal(lower(Ext),'.vol')
|
---|
| 1993 | FileType='vol';
|
---|
| 1994 | else
|
---|
| 1995 | form=imformats(Ext(2:end));
|
---|
| 1996 | if ~isempty(form)% if the extension corresponds to an image format recognized by Matlab
|
---|
| 1997 | if isequal(NomType,'*');
|
---|
| 1998 | FileType='multimage';
|
---|
| 1999 | else
|
---|
| 2000 | FileType='image';
|
---|
| 2001 | end
|
---|
| 2002 | end
|
---|
| 2003 | end
|
---|
| 2004 | switch FileType
|
---|
| 2005 | case 'movie'
|
---|
| 2006 | if test_1
|
---|
| 2007 | Field_b.A=read(UvData.MovieObject_1,num_i2);
|
---|
| 2008 | else
|
---|
| 2009 | Field_b.A=read(UvData.MovieObject,num_i2);
|
---|
| 2010 | end
|
---|
| 2011 | case 'avi'
|
---|
| 2012 | mov=aviread(imaname_1,num_i2);
|
---|
| 2013 | Field_b.A=frame2im(mov(1));
|
---|
| 2014 | case 'vol'
|
---|
| 2015 | Field_b.A=imread(imaname_1);
|
---|
| 2016 | case 'multimage'
|
---|
| 2017 | Field_b.A=imread(imaname_1,num_i2);
|
---|
| 2018 | case 'image'
|
---|
| 2019 | Field_b.A=imread(imaname_1);
|
---|
| 2020 | end
|
---|
| 2021 | if get(handles.slices,'Value')
|
---|
| 2022 | Field.ZIndex=str2double(get(handles.z_index,'String'));
|
---|
| 2023 | end
|
---|
| 2024 |
|
---|
| 2025 | %px to phys or other transform on field
|
---|
| 2026 | menu_transform=get(handles.transform_fct,'String');
|
---|
| 2027 | choice_value=get(handles.transform_fct,'Value');
|
---|
| 2028 | transform_name=menu_transform{choice_value};%name of the transform fct given by the menu 'transform_fct'
|
---|
| 2029 | transform_list=get(handles.transform_fct,'UserData');
|
---|
| 2030 | transform=transform_list{choice_value};
|
---|
| 2031 | if ~isequal(transform_name,'') && ~isequal(transform_name,'px')
|
---|
| 2032 | if test_1 && isfield(UvData,'XmlData_1') && isfield(UvData.XmlData_1,'GeometryCalib')%use geometry calib recorded from the ImaDoc xml file as first priority
|
---|
| 2033 | Field_a=transform(Field_a,UvData.XmlData_1);%the first field has been stored without transform
|
---|
| 2034 | Field_b=transform(Field_b,UvData.XmlData_1);
|
---|
| 2035 | elseif ~test_1 && isfield(UvData,'XmlData') && isfield(UvData.XmlData,'GeometryCalib')%use geometry calib
|
---|
| 2036 | Field_b=transform(Field_b,UvData.XmlData);
|
---|
| 2037 | end
|
---|
| 2038 | end
|
---|
| 2039 |
|
---|
| 2040 | % make movie until movie speed is set to 0 or STOP is activated
|
---|
| 2041 | hima=findobj(handles.axes3,'Tag','ima');% %handles.axes3 =main plotting window (A GENERALISER)
|
---|
| 2042 | set(handles.STOP,'Visible','on')
|
---|
| 2043 | set(handles.speed,'Visible','on')
|
---|
| 2044 | set(handles.speed_txt,'Visible','on')
|
---|
| 2045 | while get(handles.speed,'Value')~=0 && isequal(get(handles.movie_pair,'BusyAction'),'queue')%isequal(get(handles.run0,'BusyAction'),'queue'); % enable STOP command
|
---|
| 2046 | % read and plot the series of images in non erase mode
|
---|
| 2047 | set(hima,'CData',Field_b.A);
|
---|
| 2048 | pause(1.02-get(handles.speed,'Value'));% wait for next image
|
---|
| 2049 | set(hima,'CData',Field_a.A);
|
---|
| 2050 | pause(1.02-get(handles.speed,'Value'));% wait for next image
|
---|
| 2051 | end
|
---|
| 2052 | set(handles.movie_pair,'BackgroundColor',[1 0 0])%paint the command button in red
|
---|
| 2053 |
|
---|
| 2054 | %------------------------------------------------------------------------
|
---|
| 2055 | % --- Executes on button press in run0.
|
---|
| 2056 | function run0_Callback(hObject, eventdata, handles)
|
---|
| 2057 | %------------------------------------------------------------------------
|
---|
| 2058 | set(handles.run0,'BackgroundColor',[1 1 0])%paint the command button in yellow
|
---|
| 2059 | drawnow
|
---|
| 2060 | filename=read_file_boxes(handles);
|
---|
| 2061 |
|
---|
| 2062 | filename_1=[];%default
|
---|
| 2063 | if get(handles.SubField,'Value')
|
---|
| 2064 | filename_1=read_file_boxes_1(handles);
|
---|
| 2065 | end
|
---|
| 2066 | num_i1=stra2num(get(handles.i1,'String'));
|
---|
| 2067 | num_i2=stra2num(get(handles.i2,'String'));
|
---|
| 2068 | num_j1=stra2num(get(handles.j1,'String'));
|
---|
| 2069 | num_j2=stra2num(get(handles.j2,'String'));
|
---|
[227] | 2070 |
|
---|
[199] | 2071 | errormsg=refresh_field(handles,filename,filename_1,num_i1,num_i2,num_j1,num_j2);
|
---|
[227] | 2072 |
|
---|
[199] | 2073 | if ~isempty(errormsg)
|
---|
| 2074 | msgbox_uvmat('ERROR',errormsg);
|
---|
| 2075 | else
|
---|
| 2076 | set(handles.i1,'BackgroundColor',[1 1 1])
|
---|
| 2077 | set(handles.i2,'BackgroundColor',[1 1 1])
|
---|
| 2078 | set(handles.j1,'BackgroundColor',[1 1 1])
|
---|
| 2079 | set(handles.j2,'BackgroundColor',[1 1 1])
|
---|
| 2080 | set(handles.FileIndex,'BackgroundColor',[1 1 1])
|
---|
| 2081 | set(handles.FileIndex_1,'BackgroundColor',[1 1 1])
|
---|
| 2082 | end
|
---|
| 2083 | set(handles.run0,'BackgroundColor',[1 0 0])
|
---|
| 2084 |
|
---|
| 2085 |
|
---|
| 2086 | %------------------------------------------------------------------------
|
---|
| 2087 | % --- read the input files and refresh all the plots, including projection.
|
---|
| 2088 | % OUTPUT:
|
---|
| 2089 | % errormsg: error message char string =[] by default
|
---|
| 2090 | % INPUT:
|
---|
| 2091 | % filename: first input file (=[] in the absence of input file)
|
---|
| 2092 | % filename_1: second input file (=[] in the asbsenc of secodn input file)
|
---|
| 2093 | % num_i1,num_i2,num_j1,num_j2; frame indices
|
---|
| 2094 | % Field: structure describing an optional input field (then replace the input file)
|
---|
| 2095 | function errormsg=refresh_field(handles,filename,filename_1,num_i1,num_i2,num_j1,num_j2,Field)
|
---|
| 2096 | %------------------------------------------------------------------------
|
---|
| 2097 |
|
---|
| 2098 | %% initialisation
|
---|
| 2099 | abstime=[];
|
---|
| 2100 | abstime_1=[];
|
---|
| 2101 | dt=[];
|
---|
| 2102 | if ~exist('Field','var')
|
---|
| 2103 | Field={};
|
---|
| 2104 | end
|
---|
| 2105 | UvData=get(handles.uvmat,'UserData');
|
---|
| 2106 | if ishandle(handles.UVMAT_title) %remove title panel on uvmat
|
---|
| 2107 | delete(handles.UVMAT_title)
|
---|
| 2108 | end
|
---|
| 2109 |
|
---|
| 2110 | %% determine the main input file information for action
|
---|
| 2111 | FileType=[];%default
|
---|
| 2112 | if ~exist(filename,'file')
|
---|
| 2113 | errormsg=['input file ' filename ' does not exist'];
|
---|
| 2114 | return
|
---|
| 2115 | end
|
---|
[323] | 2116 | NomType=get(handles.NomType,'String');
|
---|
| 2117 | % NomType=get(handles.FileIndex,'UserData');
|
---|
[199] | 2118 | %update the z position index
|
---|
| 2119 | nbslice_str=get(handles.nb_slice,'String');
|
---|
| 2120 | if isequal(nbslice_str,'volume')%NOT USED
|
---|
| 2121 | z_index=num_j1;
|
---|
| 2122 | set(handles.z_index,'String',num2str(z_index))
|
---|
| 2123 | else
|
---|
| 2124 | nbslice=str2num(nbslice_str);
|
---|
| 2125 | z_index=mod(num_i1-1,nbslice)+1;
|
---|
| 2126 | set(handles.z_index,'String',num2str(z_index))
|
---|
| 2127 | end
|
---|
| 2128 | % refresh menu for save_mask if relevant
|
---|
| 2129 | masknumber=get(handles.masklevel,'String');
|
---|
| 2130 | if length(masknumber)>=z_index
|
---|
| 2131 | set(handles.masklevel,'Value',z_index)
|
---|
| 2132 | end
|
---|
| 2133 |
|
---|
| 2134 | %% read the first input field if a filename has been introduced
|
---|
| 2135 | if ~isempty(filename)
|
---|
| 2136 | ObjectName=filename;
|
---|
| 2137 | FieldName=[];%default
|
---|
| 2138 | VelType=[];%default
|
---|
| 2139 | Ext=get(handles.FileExt,'String');
|
---|
[334] | 2140 | FileType=UvData.FileType;
|
---|
| 2141 | switch FileType
|
---|
| 2142 | % if strcmp(Ext,'.nc')||strcmp(Ext,'.cdf')
|
---|
| 2143 | case {'civx','civdata','netcdf'};
|
---|
| 2144 | list_fields=get(handles.Fields,'String');% list menu fields
|
---|
| 2145 | index_fields=get(handles.Fields,'Value');% selected string index
|
---|
| 2146 | FieldName= list_fields{index_fields}; % selected field
|
---|
| 2147 | if ~strcmp(FieldName,'get_field...')
|
---|
| 2148 | TestVelType=get(handles.FixVelType,'Value');
|
---|
| 2149 | if TestVelType
|
---|
| 2150 | VelType=setfield(handles);% read the velocity type.
|
---|
| 2151 | end
|
---|
[199] | 2152 | end
|
---|
[334] | 2153 | if strcmp(FieldName,'velocity')
|
---|
| 2154 | list_code=get(handles.ListColorCode,'String');% list menu fields
|
---|
| 2155 | index_code=get(handles.ListColorCode,'Value');% selected string index
|
---|
| 2156 | if ~strcmp(list_code{index_code},'black') && ~strcmp(list_code{index_code},'white')
|
---|
| 2157 | list_code=get(handles.ListColorScalar,'String');% list menu fields
|
---|
| 2158 | index_code=get(handles.ListColorScalar,'Value');% selected string index
|
---|
| 2159 | ParamIn.ColorVar= list_code{index_code}; % selected field
|
---|
| 2160 | end
|
---|
| 2161 | end
|
---|
| 2162 | case 'video'
|
---|
| 2163 | ObjectName=UvData.MovieObject;
|
---|
| 2164 |
|
---|
| 2165 | case 'vol' %TODO: update
|
---|
| 2166 | if isfield(UvData.XmlData,'Npy') && isfield(UvData.XmlData,'Npx')
|
---|
| 2167 | ParamIn.Npy=UvData.XmlData.Npy;
|
---|
| 2168 | ParamIn.Npx=UvData.XmlData.Npx;
|
---|
| 2169 | else
|
---|
| 2170 | errormsg='Npx and Npy need to be defined in the xml file for volume images .vol';
|
---|
| 2171 | return
|
---|
| 2172 | end
|
---|
[199] | 2173 | end
|
---|
| 2174 | ParamIn.FieldName=FieldName;
|
---|
| 2175 | ParamIn.VelType=VelType;
|
---|
| 2176 | ParamIn.GUIName='get_field';
|
---|
| 2177 | [Field{1},ParamOut,errormsg] = read_field(ObjectName,FileType,ParamIn,num_i1);
|
---|
| 2178 | if ~isempty(errormsg)
|
---|
| 2179 | errormsg=['error in reading ' filename ': ' errormsg];
|
---|
| 2180 | return
|
---|
[246] | 2181 | end
|
---|
[199] | 2182 | if isfield(ParamOut,'Npx')&& isfield(ParamOut,'Npy')
|
---|
[292] | 2183 | set(handles.num_Npx,'String',num2str(ParamOut.Npx));% display image size on the interface
|
---|
| 2184 | set(handles.num_Npy,'String',num2str(ParamOut.Npy));
|
---|
[199] | 2185 | end
|
---|
[227] | 2186 | if isfield(ParamOut,'TimeIndex')
|
---|
| 2187 | set(handles.i1,'String',num2str(ParamOut.TimeIndex))
|
---|
| 2188 | end
|
---|
| 2189 | if isfield(ParamOut,'TimeValue')
|
---|
| 2190 | Field{1}.Time=ParamOut.TimeValue;
|
---|
| 2191 | end
|
---|
[199] | 2192 | end
|
---|
| 2193 |
|
---|
[236] | 2194 | %% choose a second field filename_1 if defined
|
---|
[199] | 2195 | VelType_1=[];%default
|
---|
| 2196 | FieldName_1=[];
|
---|
| 2197 | ParamOut_1=[];
|
---|
| 2198 | if ~isempty(filename_1)
|
---|
| 2199 | if ~exist(filename_1,'file')
|
---|
| 2200 | errormsg=['second file ' filename_1 ' does not exist'];
|
---|
| 2201 | return
|
---|
| 2202 | else
|
---|
| 2203 | Name=filename_1;
|
---|
| 2204 | FieldName_1=[];%default
|
---|
| 2205 | VelType_1=[];%default
|
---|
[236] | 2206 | if strcmp(get(handles.FileExt_1,'Visible'),'on')
|
---|
| 2207 | Ext_1=get(handles.FileExt_1,'String');
|
---|
| 2208 | else
|
---|
| 2209 | Ext_1=get(handles.FileExt,'String');%read the file extension for the first series (case of veltype comparison within a single file)
|
---|
| 2210 | end
|
---|
[323] | 2211 | NomType_1=get(handles.NomType_1,'String');
|
---|
| 2212 | % NomType_1=get(handles.FileIndex_1,'UserData');
|
---|
[199] | 2213 | if isequal(Ext_1,'.nc')||isequal(Ext_1,'.cdf')
|
---|
| 2214 | FileType_1='netcdf';
|
---|
| 2215 | elseif isfield(UvData,'MovieObject_1')
|
---|
| 2216 | Name=UvData.MovieObject_1;
|
---|
| 2217 | FileType_1='movie';
|
---|
| 2218 | elseif isequal(lower(Ext_1),'.avi')
|
---|
| 2219 | FileType_1='avi';
|
---|
| 2220 | elseif isequal(lower(Ext_1),'.vol')
|
---|
| 2221 | FileType_1='vol';
|
---|
| 2222 | if isfield(UvData.XmlData_1,'Npy') && isfield(UvData.XmlData_1,'Npx')
|
---|
| 2223 | ParamIn.Npy=UvData.XmlData_1.Npy;
|
---|
| 2224 | ParamIn.Npx=UvData.XmlData_1.Npx;
|
---|
| 2225 | else
|
---|
| 2226 | errormsg='Npx and Npy need to be defined in the xml file for volume images .vol';
|
---|
| 2227 | return
|
---|
| 2228 | end
|
---|
| 2229 | else
|
---|
[236] | 2230 | if length(Ext_1)>=2
|
---|
[199] | 2231 | form=imformats(Ext_1(2:end));
|
---|
| 2232 | if ~isempty(form)% if the extension corresponds to an image format recognized by Matlab
|
---|
| 2233 | if isequal(NomType_1,'*');
|
---|
| 2234 | FileType_1='multimage';
|
---|
| 2235 | else
|
---|
| 2236 | FileType_1='image';
|
---|
| 2237 | end
|
---|
| 2238 | end
|
---|
[236] | 2239 | end
|
---|
[199] | 2240 | end
|
---|
| 2241 | if strcmp(FileType_1,'netcdf')
|
---|
| 2242 | list_fields=get(handles.Fields_1,'String');% list menu fields
|
---|
| 2243 | index_fields=get(handles.Fields_1,'Value');% selected string index
|
---|
| 2244 | FieldName_1= list_fields{index_fields}; % selected field
|
---|
| 2245 | if ~isequal(FieldName_1,'get_field...')% read the field names on the interface get_field...
|
---|
[236] | 2246 | VelType_1='';
|
---|
| 2247 | if get(handles.FixVelType,'Value')
|
---|
| 2248 | VelTypeList=get(handles.VelType_1,'String');
|
---|
| 2249 | index=get(handles.VelType_1,'Value');
|
---|
| 2250 | VelType_1=VelTypeList{index};
|
---|
| 2251 | end
|
---|
[199] | 2252 | end
|
---|
| 2253 | if strcmp(VelType_1,'*')% free veltype choice
|
---|
| 2254 | VelType_1=[];
|
---|
| 2255 | elseif strcmp(VelType_1,'"')% veltype the same as for the first field
|
---|
| 2256 | if isempty(VelType)
|
---|
| 2257 | VelType_1=[];
|
---|
| 2258 | else
|
---|
| 2259 | VelType_1=VelType;
|
---|
| 2260 | end
|
---|
| 2261 | end
|
---|
| 2262 | if strcmp(FieldName_1,'velocity')
|
---|
[292] | 2263 | list_code=get(handles.ListColorCode,'String');% list menu fields
|
---|
| 2264 | index_code=get(handles.ListColorCode,'Value');% selected string index
|
---|
[199] | 2265 | if ~strcmp(list_code{index_code},'black') && ~strcmp(list_code{index_code},'white')
|
---|
[292] | 2266 | list_code=get(handles.ListColorScalar,'String');% list menu fields
|
---|
| 2267 | index_code=get(handles.ListColorScalar,'Value');% selected string index
|
---|
[199] | 2268 | ParamIn.ColorVar= list_code{index_code}; % selected field
|
---|
| 2269 | end
|
---|
| 2270 | end
|
---|
| 2271 | end
|
---|
| 2272 | test_keepdata_1=0;% test for keeping the previous stored data if the input files are unchanged
|
---|
| 2273 | if ~isequal(NomType_1,'*')%in case of a series of files (not avi movie)
|
---|
| 2274 | if isfield(UvData,'filename_1')&& isfield(UvData,'VelType_1') && isfield(UvData,'FieldName_1')
|
---|
| 2275 | test_keepdata_1= strcmp(filename_1,UvData.filename_1) && strcmp(VelType_1,UvData.VelType_1) && strcmp(FieldName_1,UvData.FieldName_1);
|
---|
| 2276 | end
|
---|
| 2277 | end
|
---|
| 2278 | if test_keepdata_1
|
---|
| 2279 | Field{2}=UvData.Field_1;
|
---|
| 2280 | else
|
---|
| 2281 | ParamIn.FieldName=FieldName_1;
|
---|
| 2282 | ParamIn.VelType=VelType_1;
|
---|
| 2283 | ParamIn.GUIName='get_field_1';
|
---|
| 2284 | [Field{2},ParamOut_1,errormsg] = read_field(Name,FileType_1,ParamIn,num_i1);
|
---|
| 2285 | if ~isempty(errormsg)
|
---|
[236] | 2286 | errormsg=['error in reading ' FieldName_1 ' in ' filename_1 ': ' errormsg];
|
---|
[199] | 2287 | return
|
---|
| 2288 | end
|
---|
| 2289 | UvData.Field_1=Field{2}; %store the second field for possible use at next RUN
|
---|
| 2290 | end
|
---|
| 2291 | end
|
---|
| 2292 | end
|
---|
| 2293 |
|
---|
| 2294 | %% update uvmat interface
|
---|
| 2295 | if isfield(ParamOut,'Npx')
|
---|
[292] | 2296 | set(handles.num_Npx,'String',num2str(ParamOut.Npx));% display image size on the interface
|
---|
| 2297 | set(handles.num_Npy,'String',num2str(ParamOut.Npy));
|
---|
[199] | 2298 | elseif isfield(ParamOut_1,'Npx')
|
---|
[292] | 2299 | set(handles.num_Npx,'String',num2str(ParamOut_1.Npx));% display image size on the interface
|
---|
| 2300 | set(handles.num_Npy,'String',num2str(ParamOut_1.Npy));
|
---|
[199] | 2301 | end
|
---|
| 2302 |
|
---|
[236] | 2303 | %% update the display menu for the first velocity type (first menuline)
|
---|
| 2304 | test_veltype=0;
|
---|
[199] | 2305 | if ~isequal(FileType,'netcdf')|| isequal(FieldName,'get_field...')
|
---|
[236] | 2306 | set(handles.VelType,'Visible','off')
|
---|
| 2307 | else
|
---|
| 2308 | test_veltype=1;
|
---|
| 2309 | set(handles.VelType,'Visible','on')
|
---|
| 2310 | set(handles.VelType_1,'Visible','on')
|
---|
| 2311 | set(handles.FixVelType,'Visible','on')
|
---|
| 2312 | menu=set_veltype_display(ParamOut.CivStage);
|
---|
| 2313 | index_menu=strcmp(ParamOut.VelType,menu);
|
---|
| 2314 | set(handles.VelType,'Value',find(index_menu,1))
|
---|
[246] | 2315 | if ~get(handles.SubField,'value')
|
---|
[236] | 2316 | set(handles.VelType,'String',menu)
|
---|
[246] | 2317 | set(handles.VelType_1,'Value',1)
|
---|
| 2318 | set(handles.VelType_1,'String',[{''};menu])
|
---|
| 2319 | end
|
---|
[199] | 2320 | end
|
---|
| 2321 | field_index=strcmp(ParamOut.FieldName,ParamOut.FieldList);
|
---|
| 2322 | set(handles.Fields,'String',ParamOut.FieldList); %update the field menu
|
---|
| 2323 | set(handles.Fields,'Value',find(field_index,1))
|
---|
| 2324 |
|
---|
[236] | 2325 | %% update the display menu for the second velocity type (second menuline)
|
---|
| 2326 | test_veltype_1=0;
|
---|
| 2327 | if isempty(filename_1)
|
---|
| 2328 | set(handles.Fields_1,'Value',1); %update the field menu
|
---|
| 2329 | set(handles.Fields_1,'String',[{''};ParamOut.FieldList]); %update the field menu
|
---|
| 2330 | else
|
---|
[199] | 2331 | if ~isequal(FileType_1,'netcdf')|| isequal(FieldName_1,'get_field...')
|
---|
[236] | 2332 | set(handles.VelType_1,'Visible','off')
|
---|
| 2333 | else
|
---|
| 2334 | test_veltype_1=1;
|
---|
| 2335 | set(handles.VelType_1,'Visible','on')
|
---|
| 2336 | if ~get(handles.FixVelType,'Value')
|
---|
| 2337 | menu=set_veltype_display(ParamOut_1.CivStage);
|
---|
| 2338 | index_menu=strcmp(ParamOut_1.VelType,menu);
|
---|
| 2339 | set(handles.VelType_1,'Value',1+find(index_menu,1))
|
---|
| 2340 | set(handles.VelType_1,'String',[{''};menu])
|
---|
[199] | 2341 | end
|
---|
| 2342 | end
|
---|
| 2343 | end
|
---|
[236] | 2344 | if test_veltype||test_veltype_1
|
---|
| 2345 | set(handles.FixVelType,'Visible','on')
|
---|
| 2346 | else
|
---|
| 2347 | set(handles.FixVelType,'Visible','off')
|
---|
| 2348 | end
|
---|
| 2349 |
|
---|
[199] | 2350 | %% introduce w as background image by default for a new series (only for nbdim=2)
|
---|
| 2351 | if ~isfield(UvData,'NewSeries')
|
---|
| 2352 | UvData.NewSeries=1;
|
---|
| 2353 | end
|
---|
| 2354 | %put W as background image by default if NbDim=2:
|
---|
| 2355 | if UvData.NewSeries && isequal(get(handles.SubField,'Value'),0) && isfield(Field{1},'W') && ~isempty(Field{1}.W) && ~isequal(Field{1}.NbDim,3);
|
---|
| 2356 | set(handles.SubField,'Value',1);
|
---|
| 2357 | %menu=update_menu(handles.Fields_1,'w');%update the menu for the background scalar nd set the choice to 'w'
|
---|
| 2358 | set(handles.RootPath_1,'String','"')
|
---|
| 2359 | set(handles.RootFile_1,'String','"')
|
---|
| 2360 | set(handles.SubDir_1,'String','"');
|
---|
| 2361 | [indices]=name_generator('',num_i1,num_j1,'',NomType,1,num_i2,num_j2,'');
|
---|
| 2362 | set(handles.FileIndex_1,'String',indices)
|
---|
| 2363 | set(handles.FileExt_1,'String','"');
|
---|
| 2364 | set(handles.Fields_1,'Visible','on');
|
---|
| 2365 | set(handles.Fields_1,'Visible','on');
|
---|
| 2366 | set(handles.RootPath_1,'Visible','on')
|
---|
| 2367 | set(handles.RootFile_1,'Visible','on')
|
---|
| 2368 | set(handles.SubDir_1,'Visible','on');
|
---|
| 2369 | set(handles.FileIndex_1,'Visible','on');
|
---|
| 2370 | set(handles.FileExt_1,'Visible','on');
|
---|
| 2371 | set(handles.Fields_1,'Visible','on');
|
---|
| 2372 | Field{1}.AName='w';
|
---|
| 2373 | end
|
---|
| 2374 |
|
---|
| 2375 | %% store the current open names, fields and vel types in uvmat interface
|
---|
| 2376 | UvData.filename_1=filename_1;
|
---|
| 2377 | UvData.VelType_1=[];%default
|
---|
| 2378 | UvData.FieldName_1=[];
|
---|
| 2379 | if isfield(ParamOut_1,VelType)
|
---|
| 2380 | UvData.VelType_1=ParamOut_1.VelType;
|
---|
| 2381 | end
|
---|
| 2382 | if isfield(ParamOut_1,FieldName)
|
---|
| 2383 | UvData.FieldName_1=ParamOut_1.FieldName;
|
---|
| 2384 | end
|
---|
| 2385 |
|
---|
| 2386 | %% apply coordinate transform or other user fct
|
---|
| 2387 | XmlData=[];%default
|
---|
| 2388 | if isfield(UvData,'XmlData')%use geometry calib recorded from the ImaDoc xml file as first priority
|
---|
| 2389 | XmlData=UvData.XmlData;
|
---|
| 2390 | end
|
---|
| 2391 | XmlData_1=[];%default
|
---|
| 2392 | if isfield(UvData,'XmlData_1')
|
---|
| 2393 | XmlData_1=UvData.XmlData_1;
|
---|
| 2394 | end
|
---|
| 2395 | % menu_transform=get(handles.transform_fct,'String');
|
---|
| 2396 | choice_value=get(handles.transform_fct,'Value');
|
---|
| 2397 | transform_list=get(handles.transform_fct,'UserData');
|
---|
| 2398 | transform=transform_list{choice_value};%selected function handles
|
---|
| 2399 | % z index
|
---|
| 2400 | if ~isempty(filename)
|
---|
| 2401 | Field{1}.ZIndex=z_index;
|
---|
| 2402 | end
|
---|
| 2403 | %px to phys or other transform on field
|
---|
| 2404 | if ~isempty(transform)
|
---|
| 2405 | if length(Field)>=2
|
---|
| 2406 | Field{2}.ZIndex=z_index;
|
---|
| 2407 | [Field{1},Field{2}]=transform(Field{1},XmlData,Field{2},XmlData_1);
|
---|
| 2408 | if isempty(Field{2})
|
---|
| 2409 | Field(2)=[];
|
---|
| 2410 | end
|
---|
| 2411 | else
|
---|
| 2412 | Field{1}=transform(Field{1},XmlData);
|
---|
| 2413 | end
|
---|
| 2414 | end
|
---|
| 2415 |
|
---|
| 2416 | %% calculate scalar
|
---|
| 2417 | if isequal(FileType,'netcdf') && ~isequal(ParamOut.CivStage,0)%&&~isempty(FieldName)%
|
---|
| 2418 | Field{1}=calc_field([{ParamOut.FieldName} {ParamOut.ColorVar}],Field{1});
|
---|
| 2419 | end
|
---|
[246] | 2420 | if numel(Field)==2 && ~test_keepdata_1 && isequal(FileType_1,'netcdf') && ~isequal(ParamOut_1.FieldName,'get_field...')%&&~isempty(FieldName_1)
|
---|
[199] | 2421 | Field{2}=calc_field([{ParamOut_1.FieldName} {ParamOut_1.ColorVar}],Field{2});
|
---|
| 2422 | end
|
---|
| 2423 |
|
---|
| 2424 | %% combine the two input fields (e.g. substract velocity fields)
|
---|
| 2425 | if numel(Field)==2
|
---|
| 2426 | UvData.Field=sub_field(Field{1},Field{2});
|
---|
| 2427 | else
|
---|
| 2428 | UvData.Field=Field{1};
|
---|
| 2429 | end
|
---|
[243] | 2430 |
|
---|
[199] | 2431 | %% get bounds and mesh (needed for mouse action and to open set_object)
|
---|
| 2432 | test_x=0;
|
---|
| 2433 | test_z=0;% test for unstructured z coordinate
|
---|
| 2434 | [UvData.Field,errormsg]=check_field_structure(UvData.Field);
|
---|
| 2435 | if ~isempty(errormsg)
|
---|
| 2436 | errormsg=['error in uvmat/refresh_field/check_field_structure: ' errormsg];
|
---|
| 2437 | return
|
---|
| 2438 | end
|
---|
[210] | 2439 | [CellVarIndex,NbDim,VarType,errormsg]=find_field_indices(UvData.Field);
|
---|
[199] | 2440 | if ~isempty(errormsg)
|
---|
| 2441 | errormsg=['error in uvmat/refresh_field/find_field_indices: ' errormsg];
|
---|
| 2442 | return
|
---|
| 2443 | end
|
---|
| 2444 | [NbDim,imax]=max(NbDim);
|
---|
[210] | 2445 | if isfield(UvData.Field,'NbDim')
|
---|
| 2446 | NbDim=UvData.Field.NbDim;% deal with plane fields containing z coordinates
|
---|
| 2447 | end
|
---|
[199] | 2448 | if ~isempty(VarType{imax}.coord_x) && ~isempty(VarType{imax}.coord_y) %unstructured coordinates
|
---|
| 2449 | XName=UvData.Field.ListVarName{VarType{imax}.coord_x};
|
---|
| 2450 | YName=UvData.Field.ListVarName{VarType{imax}.coord_y};
|
---|
| 2451 | eval(['nbvec=length(UvData.Field.' XName ');'])%nbre of measurement points (e.g. vectors)
|
---|
| 2452 | test_x=1;%test for unstructured coordinates
|
---|
[206] | 2453 | if ~isempty(VarType{imax}.coord_z)
|
---|
| 2454 | ZName=UvData.Field.ListVarName{VarType{imax}.coord_z};
|
---|
| 2455 | else
|
---|
[295] | 2456 | NbDim=2;
|
---|
[206] | 2457 | end
|
---|
[295] | 2458 | elseif numel(VarType)>=imax && numel(VarType{imax}.coord)>=NbDim && VarType{imax}.coord(NbDim)>0 %structured coordinate
|
---|
[199] | 2459 | XName=UvData.Field.ListVarName{VarType{imax}.coord(NbDim)};
|
---|
| 2460 | if NbDim>1
|
---|
| 2461 | YName=UvData.Field.ListVarName{VarType{imax}.coord(NbDim-1)}; %structured coordinates
|
---|
| 2462 | end
|
---|
| 2463 | end
|
---|
| 2464 | if NbDim==3
|
---|
[206] | 2465 | if ~test_x
|
---|
| 2466 | ZName=UvData.Field.ListVarName{VarType{imax}.coord(1)};%structured coordinates in 3D
|
---|
| 2467 | end
|
---|
[199] | 2468 | eval(['ZMax=max(UvData.Field.' ZName ');'])
|
---|
| 2469 | eval(['ZMin=min(UvData.Field.' ZName ');'])
|
---|
[206] | 2470 | UvData.Field.ZMax=ZMax;
|
---|
| 2471 | UvData.Field.ZMin=ZMin;
|
---|
[199] | 2472 | test_z=1;
|
---|
| 2473 | if isequal(ZMin,ZMax)%no z dependency
|
---|
| 2474 | NbDim=2;
|
---|
| 2475 | test_z=0;
|
---|
| 2476 | end
|
---|
| 2477 | end
|
---|
| 2478 | if exist('XName','var')
|
---|
[227] | 2479 | eval(['XMax=max(max(UvData.Field.' XName '));'])
|
---|
| 2480 | eval(['XMin=min(min(UvData.Field.' XName '));'])
|
---|
[206] | 2481 | UvData.Field.NbDim=NbDim;
|
---|
| 2482 | UvData.Field.XMax=XMax;
|
---|
| 2483 | UvData.Field.XMin=XMin;
|
---|
[199] | 2484 | if NbDim >1
|
---|
[227] | 2485 | eval(['YMax=max(max(UvData.Field.' YName '));'])
|
---|
| 2486 | eval(['YMin=min(min(UvData.Field.' YName '));'])
|
---|
[206] | 2487 | UvData.Field.YMax=YMax;
|
---|
| 2488 | UvData.Field.YMin=YMin;
|
---|
[199] | 2489 | end
|
---|
[206] | 2490 | eval(['nbvec=length(UvData.Field.' XName ');'])
|
---|
| 2491 | if test_x %unstructured coordinates
|
---|
| 2492 | if test_z
|
---|
| 2493 | UvData.Field.Mesh=((XMax-XMin)*(YMax-YMin)*(ZMax-ZMin))/nbvec;% volume per vector
|
---|
| 2494 | UvData.Field.Mesh=(UvData.Field.Mesh)^(1/3);
|
---|
| 2495 | else
|
---|
| 2496 | UvData.Field.Mesh=sqrt((XMax-XMin)*(YMax-YMin)/nbvec);%2D
|
---|
| 2497 | end
|
---|
[199] | 2498 | else
|
---|
[206] | 2499 | VarIndex=CellVarIndex{imax}; % list of variable indices
|
---|
| 2500 | DimIndex=UvData.Field.VarDimIndex{VarIndex(1)}; %list of dim indices for the variable
|
---|
| 2501 | nbpoints_x=UvData.Field.DimValue(DimIndex(NbDim));
|
---|
| 2502 | DX=(XMax-XMin)/(nbpoints_x-1);
|
---|
| 2503 | if NbDim >1
|
---|
| 2504 | nbpoints_y=UvData.Field.DimValue(DimIndex(NbDim-1));
|
---|
| 2505 | DY=(YMax-YMin)/(nbpoints_y-1);
|
---|
| 2506 | end
|
---|
| 2507 | if NbDim==3
|
---|
| 2508 | nbpoints_z=UvData.Field.DimValue(DimIndex(1));
|
---|
| 2509 | DZ=(ZMax-ZMin)/(nbpoints_z-1);
|
---|
[246] | 2510 | UvData.Field.Mesh=(DX*DY*DZ)^(1/3);
|
---|
[206] | 2511 | UvData.Field.ZMax=ZMax;
|
---|
| 2512 | UvData.Field.ZMin=ZMin;
|
---|
| 2513 | else
|
---|
[221] | 2514 | UvData.Field.Mesh=DX;%sqrt(DX*DY);
|
---|
[206] | 2515 | end
|
---|
[199] | 2516 | end
|
---|
| 2517 | end
|
---|
| 2518 |
|
---|
| 2519 | %% 3D case (menuvolume)
|
---|
| 2520 | if NbDim==3% && UvData.NewSeries
|
---|
| 2521 | test_set_object=1;
|
---|
| 2522 | hset_object=findobj(allchild(0),'tag','set_object');% look for the set_object GUI
|
---|
| 2523 | ZBounds(1)=UvData.Field.ZMin; %minimum for the Z slider
|
---|
| 2524 | ZBounds(2)=UvData.Field.ZMax;%maximum for the Z slider
|
---|
| 2525 | if ~isempty(hset_object) %if set_object is detected
|
---|
| 2526 | % hhset_object=guidata(hset_object);
|
---|
| 2527 | % % ZBounds_old(1)=get(hhset_object.z_slider,'Min');
|
---|
| 2528 | % % ZBounds_old(2)=get(hhset_object.z_slider,'Max');
|
---|
| 2529 | % % if isequal(ZBounds_old,ZBounds)
|
---|
| 2530 | % test_set_object=0;% do not refresh the GUI set_object
|
---|
| 2531 | % else
|
---|
| 2532 | delete(hset_object);% delete the GUI set_object if it does not fit
|
---|
| 2533 | % end
|
---|
| 2534 | end
|
---|
| 2535 | if test_set_object% reinitiate the GUI set_object
|
---|
[302] | 2536 | delete_object(1);% delete the current projection object in the list UvData.Object, delete its graphic representations and update the list displayed in handles.ListObject and 2
|
---|
[199] | 2537 | UvData.Object{1}.Style='plane';%main plotting plane
|
---|
| 2538 | UvData.Object{1}.ProjMode='projection';%main plotting plane
|
---|
| 2539 | UvData.Object{1}.DisplayHandle_uvmat=[]; %plane not visible in uvmat
|
---|
| 2540 | UvData.Object{1}.NbDim=NbDim;%test for 3D objects
|
---|
| 2541 | UvData.Object{1}.RangeZ=UvData.Field.Mesh;%main plotting plane
|
---|
| 2542 | UvData.Object{1}.Coord(1,3)=(UvData.Field.ZMin+UvData.Field.ZMax)/2;%section at a middle plane chosen
|
---|
[206] | 2543 | UvData.Object{1}.Angle=[0 0 0];
|
---|
| 2544 | % UvData.Object{1}.Theta=0;
|
---|
| 2545 | % UvData.Object{1}.Psi=0;
|
---|
[199] | 2546 | UvData.Object{1}.HandlesDisplay=plot(0,0,'Tag','proj_object');% A REVOIR
|
---|
[206] | 2547 | % PlotHandles=get_plot_handles(handles);
|
---|
[199] | 2548 | UvData.Object{1}.Name='1-PLANE';
|
---|
| 2549 | UvData.Object{1}.enable_plot=1;
|
---|
[206] | 2550 | set_object(UvData.Object{1},handles,ZBounds);
|
---|
[302] | 2551 | set(handles.ListObject,'Value',1);
|
---|
| 2552 | set(handles.ListObject,'String',{'1-PLANE'});
|
---|
[199] | 2553 | set(handles.edit_object,'Value',1)% put the plane in edit mode to enable the z cursor
|
---|
| 2554 | edit_object_Callback([],[], handles)
|
---|
| 2555 | end
|
---|
| 2556 | %multilevel case (single menuplane in a 3D space)
|
---|
| 2557 | elseif isfield(UvData,'Z')
|
---|
| 2558 | if isfield(UvData,'CoordType')&& isequal(UvData.CoordType,'phys') && isfield(UvData,'XmlData')
|
---|
| 2559 | XmlData=UvData.XmlData;
|
---|
| 2560 | if isfield(XmlData,'PlanePos')
|
---|
| 2561 | UvData.Object{1}.Coord=XmlData.PlanePos(UvData.ZIndex,:);
|
---|
| 2562 | end
|
---|
| 2563 | if isfield(XmlData,'PlaneAngle')
|
---|
| 2564 | siz=size(XmlData.PlaneAngle);
|
---|
| 2565 | indangle=min(siz(1),UvData.ZIndex);%take first angle if a single angle is defined (translating scanning)
|
---|
[206] | 2566 | UvData.Object{1}.PlaneAngle=XmlData.PlaneAngle(indangle,:);
|
---|
[199] | 2567 | end
|
---|
| 2568 | elseif isfield(UvData,'ZIndex')
|
---|
| 2569 | UvData.Object{1}.ZObject=UvData.ZIndex;
|
---|
| 2570 | end
|
---|
| 2571 | else
|
---|
[231] | 2572 | % create a default projection
|
---|
[252] | 2573 | UvData.Object{1}.ProjMode='projection';%main plotting plane
|
---|
| 2574 | UvData.Object{1}.DisplayHandle_uvmat=[]; %plane not visible in uvmat
|
---|
[302] | 2575 | set(handles.ListObject,'Value',1);
|
---|
| 2576 | list_object=get(handles.ListObject,'String');
|
---|
[252] | 2577 | if isempty(list_object)
|
---|
| 2578 | list_object={''};
|
---|
| 2579 | elseif ~isempty(list_object{1})
|
---|
| 2580 | list_object=[{''};list_object];
|
---|
| 2581 | end
|
---|
[302] | 2582 | set(handles.ListObject,'String',list_object);
|
---|
| 2583 | % set(handles.list_object_2,'String',list_object);
|
---|
[199] | 2584 | end
|
---|
| 2585 | testnewseries=UvData.NewSeries;
|
---|
| 2586 | UvData.NewSeries=0;% put to 0 the test for a new field series (set by RootPath_callback)
|
---|
| 2587 | set(handles.uvmat,'UserData',UvData)
|
---|
| 2588 |
|
---|
| 2589 | %% reset the min and max of scalar if only the mask is displayed(TODO: check the need)
|
---|
| 2590 | if isfield(UvData,'Mask')&& ~isfield(UvData,'A')
|
---|
[292] | 2591 | set(handles.num_MinA,'String','0')
|
---|
| 2592 | set(handles.num_MaxA,'String','255')
|
---|
[199] | 2593 | end
|
---|
| 2594 |
|
---|
| 2595 | %% Plot the projections on the selected projection objects
|
---|
| 2596 | % main projection object (uvmat display)
|
---|
[302] | 2597 | list_object=get(handles.ListObject,'String');
|
---|
[236] | 2598 | if isequal(list_object,{''})%refresh list of objects if the menu is empty
|
---|
| 2599 | UvData.Object={[]};
|
---|
[302] | 2600 | set(handles.ListObject,'Value',1)
|
---|
| 2601 | % set(handles.list_object_2,'Value',1)
|
---|
| 2602 | % set(handles.list_object_2,'String',{''})
|
---|
| 2603 | % set(handles.list_object_2,'Visible','off')
|
---|
[236] | 2604 | end
|
---|
[302] | 2605 | IndexObj=get(handles.ListObject,'Value');%selected projection object for main view
|
---|
[199] | 2606 | if IndexObj(1)> numel(UvData.Object)
|
---|
| 2607 | IndexObj(1)=1;%select the first object if the selected one does not exist
|
---|
[302] | 2608 | set(handles.ListObject,'Value',1)
|
---|
[199] | 2609 | end
|
---|
| 2610 | plot_handles{1}=handles;
|
---|
[215] | 2611 | if isfield(UvData,'plotaxes')%case of movies
|
---|
| 2612 | haxes(1)=UvData.plotaxes;
|
---|
| 2613 | else
|
---|
| 2614 | haxes(1)=handles.axes3;
|
---|
| 2615 | end
|
---|
[292] | 2616 | %PlotParam{1}=read_plot_param(handles);%read plotting parameters on the uvmat interfac
|
---|
| 2617 | PlotParam{1}=read_GUI(handles.uvmat);
|
---|
[334] | 2618 | PlotParam{1}.Coordinates
|
---|
[316] | 2619 | if ~isfield(PlotParam{1},'Vectors')
|
---|
| 2620 | PlotParam{1}.Vectors.MaxVec=1;
|
---|
| 2621 | PlotParam{1}.Vectors.MinVec=0;
|
---|
| 2622 | PlotParam{1}.Vectors.CheckFixVecColor=1;
|
---|
| 2623 | PlotParam{1}.Vectors.ColCode1=0.33;
|
---|
| 2624 | PlotParam{1}.Vectors.ColCode2=0.66;
|
---|
| 2625 | PlotParam{1}.Vectors.ListColorScalar={'ima_cor'};
|
---|
| 2626 | PlotParam{1}.Vectors.ListColorCode= {'rgb'};
|
---|
| 2627 | end
|
---|
[292] | 2628 | keeplim(1)=get(handles.CheckFixLimits,'Value');% test for fixed graph limits
|
---|
[199] | 2629 | PosColorbar{1}=UvData.OpenParam.PosColorbar;%prescribe the colorbar position on the uvmat interface
|
---|
| 2630 |
|
---|
| 2631 | % second projection object (view_field display)
|
---|
[315] | 2632 | if length( IndexObj)>=2
|
---|
[199] | 2633 | view_field_handle=findobj(allchild(0),'tag','view_field');%handles of the view_field GUI
|
---|
| 2634 | if ~isempty(view_field_handle)
|
---|
| 2635 | plot_handles{2}=guidata(view_field_handle);
|
---|
| 2636 | haxes(2)=plot_handles{2}.axes3;
|
---|
[292] | 2637 | %PlotParam{2}=read_plot_param(plot_handles{2});%read plotting parameters on the viewinterface
|
---|
| 2638 | PlotParam{2}=read_GUI(handles.uvmat);%read plotting parameters on the uvmat interface
|
---|
| 2639 | keeplim(2)=get(plot_handles{2}.CheckFixLimits,'Value');
|
---|
[199] | 2640 | PosColorbar{2}='*'; %TODO: deal with colorbar position on view_field
|
---|
| 2641 | end
|
---|
| 2642 | end
|
---|
| 2643 |
|
---|
| 2644 | %loop on the projection objects: one or two
|
---|
| 2645 | for imap=1:numel(IndexObj)
|
---|
[206] | 2646 | iobj=IndexObj(imap);
|
---|
[199] | 2647 | [ObjectData,errormsg]=proj_field(UvData.Field,UvData.Object{iobj});% project field on the object
|
---|
[316] | 2648 |
|
---|
[199] | 2649 | if ~isempty(errormsg)
|
---|
| 2650 | return
|
---|
| 2651 | end
|
---|
[316] | 2652 | % if testnewseries && isfield(ObjectData,'CoordUnit')&& isfield(PlotParam{imap},'Coordinates')
|
---|
| 2653 | % PlotParam{imap}.Coordinates=rmfield(PlotParam{imap}.Coordinates,'CheckFixEqual'); %set FixEqual to depend on the field (=1 if Data.CoordUnit=1 in plot_field)
|
---|
| 2654 | % end
|
---|
| 2655 | if testnewseries && isfield(ObjectData,'CoordUnit')
|
---|
| 2656 | PlotParam{imap}.Coordinates.CheckFixEqual=1;
|
---|
| 2657 | end
|
---|
[199] | 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
|
---|
[315] | 2725 | if isequal(get(handles.CheckMask,'Value'),1)%if the mask option is on
|
---|
[199] | 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')
|
---|
[334] | 2825 | [~,~,~,num_i1,num_i2,num_j1,num_j2]=fileparts_uvmat(['xx' get(handles.FileIndex_1,'String') get(handles.FileExt_1,'String')]);
|
---|
| 2826 | % [P,F,str1,str2,str_a,str_b,E]=name2display(['xx' get(handles.FileIndex_1,'String') get(handles.FileExt_1,'String')]);
|
---|
| 2827 | if isempty(num_i2)
|
---|
[199] | 2828 | num_i2=num_i1;
|
---|
| 2829 | end
|
---|
[334] | 2830 | if isempty(num_j1)
|
---|
[199] | 2831 | num_j1=1;
|
---|
| 2832 | end
|
---|
[334] | 2833 | if isempty(num_j2)
|
---|
[199] | 2834 | num_j2=num_j1;
|
---|
| 2835 | end
|
---|
| 2836 | siz=size(UvData.XmlData_1.Time);
|
---|
| 2837 | if siz(1)>=max(num_i1,num_i2) && siz(2)>=max(num_j1,num_j2)
|
---|
| 2838 | 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
|
---|
| 2839 | end
|
---|
| 2840 | end
|
---|
[258] | 2841 | if ~isequal(numel(abstime),1)
|
---|
| 2842 | abstime=[];
|
---|
| 2843 | end
|
---|
| 2844 | if ~isequal(numel(abstime_1),1)
|
---|
| 2845 | abstime_1=[];
|
---|
| 2846 | end
|
---|
[199] | 2847 | set(handles.abs_time,'String',num2str(abstime,4))
|
---|
| 2848 | set(handles.abs_time_1,'String',num2str(abstime_1,4))
|
---|
| 2849 | if testimedoc && isfield(UvData,'dt')
|
---|
| 2850 | dt=UvData.dt;
|
---|
| 2851 | end
|
---|
| 2852 | if isempty(dt)||isequal(dt,0)
|
---|
| 2853 | set(handles.Dt_txt,'String','')
|
---|
| 2854 | else
|
---|
[221] | 2855 | if isempty(TimeUnit)
|
---|
[199] | 2856 | set(handles.Dt_txt,'String',['Dt=' num2str(1000*dt,3) ' 10^(-3)'] )
|
---|
| 2857 | else
|
---|
[221] | 2858 | set(handles.Dt_txt,'String',['Dt=' num2str(1000*dt,3) ' m' TimeUnit] )
|
---|
[199] | 2859 | end
|
---|
| 2860 | end
|
---|
| 2861 |
|
---|
| 2862 |
|
---|
| 2863 | %-------------------------------------------------------------------
|
---|
| 2864 | % --- translate coordinate to matrix index
|
---|
| 2865 | %-------------------------------------------------------------------
|
---|
| 2866 | function [indx,indy]=pos2ind(x0,rangx0,nxy)
|
---|
| 2867 | indx=1+round((nxy(2)-1)*(x0-rangx0(1))/(rangx0(2)-rangx0(1)));% index x of pixel
|
---|
| 2868 | indy=1+round((nxy(1)-1)*(y12-rangy0(1))/(rangy0(2)-rangy0(1)));% index y of pixel
|
---|
| 2869 |
|
---|
| 2870 | %-------------------------------------------------------------------
|
---|
[292] | 2871 | % --- Executes on button press in 'CheckFixLimits'.
|
---|
[199] | 2872 | %-------------------------------------------------------------------
|
---|
[292] | 2873 | function CheckFixLimits_Callback(hObject, eventdata, handles)
|
---|
| 2874 | test=get(handles.CheckFixLimits,'Value');
|
---|
[199] | 2875 | if test
|
---|
[292] | 2876 | set(handles.CheckFixLimits,'BackgroundColor',[1 1 0])
|
---|
[199] | 2877 | else
|
---|
[292] | 2878 | set(handles.CheckFixLimits,'BackgroundColor',[0.7 0.7 0.7])
|
---|
[199] | 2879 | update_plot(handles);
|
---|
| 2880 | end
|
---|
| 2881 |
|
---|
| 2882 | %-------------------------------------------------------------------
|
---|
[292] | 2883 | % --- Executes on button press in CheckFixEqual.
|
---|
| 2884 | function CheckFixEqual_Callback(hObject, eventdata, handles)
|
---|
| 2885 | test=get(handles.CheckFixEqual,'Value');
|
---|
[199] | 2886 | if test
|
---|
[292] | 2887 | set(handles.CheckFixEqual,'BackgroundColor',[1 1 0])
|
---|
[199] | 2888 | cla(handles.axes3)
|
---|
| 2889 | update_plot(handles);
|
---|
| 2890 | else
|
---|
[292] | 2891 | set(handles.CheckFixEqual,'BackgroundColor',[0.7 0.7 0.7])
|
---|
[199] | 2892 | update_plot(handles);
|
---|
| 2893 | % axis(handles.axes3,'image')
|
---|
| 2894 | end
|
---|
| 2895 |
|
---|
| 2896 |
|
---|
| 2897 | %-------------------------------------------------------------------
|
---|
| 2898 |
|
---|
| 2899 | %-------------------------------------------------------------------
|
---|
[292] | 2900 | % --- Executes on button press in 'CheckZoom'.
|
---|
[199] | 2901 | %-------------------------------------------------------------------
|
---|
[292] | 2902 | function CheckZoom_Callback(hObject, eventdata, handles)
|
---|
[199] | 2903 |
|
---|
[292] | 2904 | if (get(handles.CheckZoom,'Value') == 1);
|
---|
| 2905 | set(handles.CheckZoom,'BackgroundColor',[1 1 0])
|
---|
| 2906 | set(handles.CheckFixLimits,'Value',1)% propose by default fixed limits for the plotting axes
|
---|
| 2907 | set(handles.CheckFixLimits,'BackgroundColor',[1 1 0])
|
---|
[199] | 2908 | else
|
---|
[292] | 2909 | set(handles.CheckZoom,'BackgroundColor',[0.7 0.7 0.7])
|
---|
[199] | 2910 | end
|
---|
| 2911 |
|
---|
| 2912 |
|
---|
| 2913 | %-------------------------------------------------------------------
|
---|
| 2914 | %----Executes on button press in 'record': records the current flags of manual correction.
|
---|
| 2915 | %-------------------------------------------------------------------
|
---|
| 2916 | function record_Callback(hObject, eventdata, handles)
|
---|
| 2917 | % [filebase,num_i1,num_j1,num_i2,num_j2,Ext,NomType,SubDir]=read_input_file(handles);
|
---|
| 2918 | filename=read_file_boxes(handles);
|
---|
| 2919 | [erread,message]=fileattrib(filename);
|
---|
| 2920 | if ~isempty(message) && ~isequal(message.UserWrite,1)
|
---|
| 2921 | msgbox_uvmat('ERROR',['no writting access to ' filename])
|
---|
| 2922 | return
|
---|
| 2923 | end
|
---|
| 2924 | test_civ2=isequal(get(handles.civ2,'BackgroundColor'),[1 1 0]);
|
---|
[236] | 2925 | test_civ1=isequal(get(handles.VelType,'BackgroundColor'),[1 1 0]);
|
---|
[199] | 2926 | if ~test_civ2 && ~test_civ1
|
---|
| 2927 | msgbox_uvmat('ERROR','manual correction only possible for CIV1 or CIV2 velocity fields')
|
---|
| 2928 | end
|
---|
| 2929 | if test_civ2
|
---|
| 2930 | nbname='nb_vectors2';
|
---|
| 2931 | flagname='vec2_FixFlag';
|
---|
| 2932 | attrname='fix2';
|
---|
| 2933 | end
|
---|
| 2934 | if test_civ1
|
---|
| 2935 | nbname='nb_vectors';
|
---|
| 2936 | flagname='vec_FixFlag';
|
---|
| 2937 | attrname='fix';
|
---|
| 2938 | end
|
---|
| 2939 | %write fix flags in the netcdf file
|
---|
| 2940 | UvData=get(handles.uvmat,'UserData');
|
---|
| 2941 | hhh=which('netcdf.open');% look for built-in matlab netcdf library
|
---|
| 2942 | if ~isequal(hhh,'')% case of new builtin Matlab netcdf library
|
---|
| 2943 | nc=netcdf.open(filename,'NC_WRITE');
|
---|
| 2944 | netcdf.reDef(nc);
|
---|
| 2945 | netcdf.putAtt(nc,netcdf.getConstant('NC_GLOBAL'),attrname,1);
|
---|
| 2946 | dimid = netcdf.inqDimID(nc,nbname);
|
---|
| 2947 | try
|
---|
| 2948 | varid = netcdf.inqVarID(nc,flagname);% look for already existing fixflag variable
|
---|
| 2949 | catch
|
---|
| 2950 | varid=netcdf.defVar(nc,flagname,'double',dimid);%create fixflag variable if it does not exist
|
---|
| 2951 | end
|
---|
| 2952 | netcdf.endDef(nc);
|
---|
| 2953 | netcdf.putVar(nc,varid,UvData.axes3.FF);
|
---|
| 2954 | netcdf.close(nc);
|
---|
| 2955 | else %old netcdf library
|
---|
| 2956 | netcdf_toolbox(filename,AxeData,attrname,nbname,flagname)
|
---|
| 2957 | end
|
---|
| 2958 |
|
---|
| 2959 | %-------------------------------------------------------------------
|
---|
| 2960 | %----Correct the netcdf file, using toolbox (old versions of Matlab).
|
---|
| 2961 | %-------------------------------------------------------------------
|
---|
| 2962 | function netcdf_toolbox(filename,AxeData,attrname,nbname,flagname)
|
---|
| 2963 | nc=netcdf(filename,'write'); %open netcdf file
|
---|
| 2964 | result=redef(nc);
|
---|
| 2965 | eval(['nc.' attrname '=1;']);
|
---|
| 2966 | theDim=nc(nbname) ;% get the number of velocity vectors
|
---|
| 2967 | nb_vectors=size(theDim);
|
---|
| 2968 | var_FixFlag=ncvar(flagname,nc);% var_FixFlag will be written as the netcdf variable vec_FixFlag
|
---|
| 2969 | var_FixFlag(1:nb_vectors)=AxeData.FF;%
|
---|
| 2970 | fin=close(nc);
|
---|
| 2971 |
|
---|
| 2972 |
|
---|
| 2973 | %-------------------------------------------------------------------
|
---|
| 2974 | %determines the fields to read from the interface
|
---|
| 2975 | %------------------------------------------------------------------
|
---|
[236] | 2976 | function VelType=setfield(handles)
|
---|
| 2977 | VelTypeList=get(handles.VelType,'String');
|
---|
| 2978 | index=get(handles.VelType,'Value');
|
---|
| 2979 | VelType=VelTypeList{index};
|
---|
[199] | 2980 |
|
---|
[236] | 2981 | % VelType=[]; %default
|
---|
| 2982 | % if (get(handles.VelType,'Value') == 1);
|
---|
| 2983 | % VelType='civ1';
|
---|
| 2984 | % % interp1
|
---|
| 2985 | % elseif (get(handles.interp1,'Value') == 1);
|
---|
| 2986 | % VelType='interp1';
|
---|
| 2987 | % % filter1
|
---|
| 2988 | % elseif (get(handles.filter1,'Value') == 1);
|
---|
| 2989 | % VelType='filter1';
|
---|
| 2990 | % % CIV2
|
---|
| 2991 | % elseif (get(handles.civ2,'Value') == 1);
|
---|
| 2992 | % VelType='civ2';
|
---|
| 2993 | % % interp2
|
---|
| 2994 | % elseif (get(handles.interp2,'Value') == 1);
|
---|
| 2995 | % VelType='interp2';
|
---|
| 2996 | % % filter2
|
---|
| 2997 | % elseif (get(handles.filter2,'Value') == 1);
|
---|
| 2998 | % VelType='filter2';
|
---|
| 2999 | % end
|
---|
| 3000 | %
|
---|
| 3001 | % if isequal(get(handles.filter2,'Visible'),'on');
|
---|
| 3002 | % civ=6;
|
---|
| 3003 | % % interp1
|
---|
| 3004 | % elseif isequal(get(handles.interp2,'Visible'),'on');
|
---|
| 3005 | % civ=5;
|
---|
| 3006 | % % filter1
|
---|
| 3007 | % elseif isequal(get(handles.civ2,'Visible'),'on');
|
---|
| 3008 | % civ=4;
|
---|
| 3009 | % % CIV2
|
---|
| 3010 | % elseif isequal(get(handles.filter1,'Visible'),'on');
|
---|
| 3011 | % civ=3;
|
---|
| 3012 | % % interp2
|
---|
| 3013 | % elseif isequal(get(handles.interp1,'Visible'),'on');
|
---|
| 3014 | % civ=2;
|
---|
| 3015 | % % filter2
|
---|
| 3016 | % elseif isequal(get(handles.VelType,'Visible'),'on');
|
---|
| 3017 | % civ=1;
|
---|
| 3018 | % else
|
---|
| 3019 | % civ=0;
|
---|
| 3020 | % end
|
---|
[199] | 3021 |
|
---|
| 3022 | %-------------------------------------------------------------------
|
---|
| 3023 | %determines the veltype of the second field to read from the iinterface
|
---|
| 3024 | %------------------------------------------------------------------
|
---|
| 3025 | function VelType=setfield_1(handles)
|
---|
[236] | 3026 | VelTypeList=get(handles.VelType_1,'String');
|
---|
| 3027 | index=get(handles.VelType_1,'Value');
|
---|
| 3028 | VelType=VelTypeList{index};
|
---|
| 3029 | % VelType=[]; %default
|
---|
| 3030 | % if (get(handles.VelType_1,'Value') == 1);
|
---|
| 3031 | % VelType='civ1';
|
---|
| 3032 | % % interp1
|
---|
| 3033 | % elseif (get(handles.interp1_1,'Value') == 1);
|
---|
| 3034 | % VelType='interp1';
|
---|
| 3035 | % % filter1
|
---|
| 3036 | % elseif (get(handles.filter1_1,'Value') == 1);
|
---|
| 3037 | % VelType='filter1';
|
---|
| 3038 | % % CIV2
|
---|
| 3039 | % elseif (get(handles.civ2_1,'Value') == 1);
|
---|
| 3040 | % VelType='civ2';
|
---|
| 3041 | % % interp2
|
---|
| 3042 | % elseif (get(handles.interp2_1,'Value') == 1);
|
---|
| 3043 | % VelType='interp2';
|
---|
| 3044 | % % filter2
|
---|
| 3045 | % elseif (get(handles.filter2_1,'Value') == 1);
|
---|
| 3046 | % VelType='filter2';
|
---|
| 3047 | % end
|
---|
[199] | 3048 |
|
---|
| 3049 |
|
---|
| 3050 | %---------------------------------------------------
|
---|
| 3051 | % --- Executes on button press in SubField
|
---|
| 3052 | function SubField_Callback(hObject, eventdata, handles)
|
---|
[236] | 3053 | % huvmat=get(handles.run0,'parent');
|
---|
| 3054 | UvData=get(handles.uvmat,'UserData');
|
---|
[199] | 3055 | if get(handles.SubField,'Value')==0% if the subfield button is desactivated
|
---|
| 3056 | set(handles.RootPath_1,'String','')
|
---|
| 3057 | set(handles.RootFile_1,'String','')
|
---|
| 3058 | set(handles.SubDir_1,'String','');
|
---|
| 3059 | set(handles.FileIndex_1,'String','');
|
---|
| 3060 | set(handles.FileExt_1,'String','');
|
---|
| 3061 | set(handles.RootPath_1,'Visible','off')
|
---|
| 3062 | set(handles.RootFile_1,'Visible','off')
|
---|
| 3063 | set(handles.SubDir_1,'Visible','off');
|
---|
| 3064 | set(handles.FileIndex_1,'Visible','off');
|
---|
| 3065 | set(handles.FileExt_1,'Visible','off');
|
---|
| 3066 | set(handles.Fields_1,'Value',1);%set to blank state
|
---|
[236] | 3067 | set(handles.VelType_1,'Value',1);%set to blank state
|
---|
| 3068 | if ~strcmp(get(handles.VelType,'Visible'),'on')
|
---|
| 3069 | set(handles.VelType_1,'Visible','off')
|
---|
| 3070 | end
|
---|
| 3071 | % set_veltype_display([handles.VelType_1 handles.interp1_1 handles.filter1_1 ...
|
---|
| 3072 | % handles.civ2_1 handles.interp2_1 handles.filter2_1],0)
|
---|
[199] | 3073 | if isfield(UvData,'XmlData_1')
|
---|
| 3074 | UvData=rmfield(UvData,'XmlData_1');
|
---|
| 3075 | end
|
---|
[236] | 3076 | set(handles.uvmat,'UserData',UvData);
|
---|
[199] | 3077 | run0_Callback(hObject, eventdata, handles); %run
|
---|
| 3078 | else
|
---|
| 3079 | MenuBrowse_1_Callback(hObject, eventdata, handles)
|
---|
| 3080 | end
|
---|
| 3081 |
|
---|
| 3082 | %------------------------------------------------------------------------
|
---|
[323] | 3083 | % --- read the data displayed for the input rootfile windows (new): TODO use read_GUI
|
---|
| 3084 |
|
---|
[199] | 3085 | function [FileName,RootPath,FileBase,FileIndices,FileExt,SubDir]=read_file_boxes(handles)
|
---|
| 3086 | %------------------------------------------------------------------------
|
---|
[323] | 3087 | InputFile=read_GUI(handles.InputFile);
|
---|
| 3088 | RootPath=InputFile.RootPath;
|
---|
| 3089 | FileName=InputFile.RootPath; %default
|
---|
| 3090 | if ~isempty(InputFile.SubDir)
|
---|
| 3091 | InputFile.SubDir=regexprep(InputFile.SubDir,'/|\','');
|
---|
| 3092 | FileName=fullfile(InputFile.RootPath,InputFile.SubDir);
|
---|
[199] | 3093 | end
|
---|
[323] | 3094 | if ~isempty(InputFile.RootFile)
|
---|
| 3095 | InputFile.RootFile=regexprep(InputFile.RootFile,'/|\','');
|
---|
| 3096 | FileName=fullfile(FileName,InputFile.RootFile);
|
---|
[199] | 3097 | end
|
---|
[323] | 3098 | SubDir=InputFile.SubDir;
|
---|
| 3099 | % if ~isempty(SubDir) && ~isequal(SubDir,'')
|
---|
| 3100 | % if (isequal(SubDir(1),'/')|| isequal(SubDir(1),'\'))
|
---|
| 3101 | % SubDir(1)=[]; %suppress possible / or \ separator
|
---|
| 3102 | % end
|
---|
| 3103 | % FileName=fullfile(RootPath,SubDir);
|
---|
| 3104 | % end
|
---|
| 3105 | % RootFile=get(handles.RootFile,'String');
|
---|
| 3106 | % if ~isempty(RootFile) && ~isequal(RootFile,'')
|
---|
| 3107 | % if (isequal(RootFile(1),'/')|| isequal(RootFile(1),'\'))
|
---|
| 3108 | % RootFile(1)=[]; %suppress possible / or \ separator
|
---|
| 3109 | % end
|
---|
| 3110 | % FileName=fullfile(FileName,RootFile);
|
---|
| 3111 | % end
|
---|
| 3112 | FileBase=fullfile(InputFile.RootPath,InputFile.RootFile);
|
---|
| 3113 | FileIndices=InputFile.FileIndex;
|
---|
| 3114 | FileExt=InputFile.FileExt;
|
---|
| 3115 | FileName=[FileName InputFile.FileIndex InputFile.FileExt];
|
---|
[199] | 3116 |
|
---|
| 3117 | %------------------------------------------------------------------------
|
---|
| 3118 | % ---- read the data displayed for the second input rootfile windows
|
---|
| 3119 | function [FileName_1,RootPath_1,FileBase_1,FileIndices_1,FileExt_1,SubDir_1]=read_file_boxes_1(handles)
|
---|
| 3120 | %------------------------------------------------------------------------
|
---|
| 3121 | RootPath_1=get(handles.RootPath_1,'String'); % read the data from the file1_input window
|
---|
| 3122 | if isequal(get(handles.RootPath_1,'Visible'),'off') || isequal(RootPath_1,'"')
|
---|
| 3123 | RootPath_1=get(handles.RootPath,'String');
|
---|
| 3124 | end;
|
---|
| 3125 | FileName_1=RootPath_1; %default
|
---|
| 3126 | SubDir_1=get(handles.SubDir_1,'String');
|
---|
| 3127 | if isequal(get(handles.SubDir_1,'Visible'),'off')|| isequal(SubDir_1,'"')
|
---|
| 3128 | SubDir_1=get(handles.SubDir,'String');
|
---|
| 3129 | end
|
---|
| 3130 | RootFile_1=get(handles.RootFile_1,'String');
|
---|
[326] | 3131 | SubDir_1=regexprep(SubDir_1,'\<[\\/]|[\\/]\>','');%suppress possible / or \ separator at the beginning or the end of the string
|
---|
| 3132 | FileName_1=fullfile(RootPath_1,SubDir_1);
|
---|
[199] | 3133 | if isequal(get(handles.RootFile_1,'Visible'),'off') || isequal(RootFile_1,'"')
|
---|
| 3134 | RootFile_1=get(handles.RootFile,'String');
|
---|
| 3135 | end
|
---|
[326] | 3136 | RootFile_1=regexprep(RootFile_1,'\<[\\/]|[\\/]\>','');%suppress possible / or \ separator at the beginning or the end of the string
|
---|
[199] | 3137 | if numel(RootFile_1)>=1
|
---|
| 3138 | FileName_1=fullfile(FileName_1,RootFile_1);
|
---|
| 3139 | end
|
---|
| 3140 | FileBase_1=fullfile(RootPath_1,RootFile_1);
|
---|
| 3141 | if isequal(get(handles.FileIndex_1,'Visible'),'off')
|
---|
| 3142 | FileIndices_1=get(handles.FileIndex,'String');
|
---|
| 3143 | else
|
---|
| 3144 | FileIndices_1=get(handles.FileIndex_1,'String');
|
---|
| 3145 | end
|
---|
| 3146 | FileExt_1=get(handles.FileExt_1,'String');
|
---|
[246] | 3147 | if isequal(get(handles.FileExt_1,'Visible'),'off') || isequal(FileExt_1,'"')
|
---|
| 3148 | FileExt_1=get(handles.FileExt,'String');%read FileExt by default
|
---|
| 3149 | end
|
---|
[199] | 3150 | FileName_1=[FileName_1 FileIndices_1 FileExt_1];
|
---|
| 3151 |
|
---|
| 3152 | %------------------------------------------------------------------------
|
---|
| 3153 | % --- Executes on menu selection Fields
|
---|
| 3154 | function Fields_Callback(hObject, eventdata, handles)
|
---|
| 3155 | %------------------------------------------------------------------------
|
---|
| 3156 | list_fields=get(handles.Fields,'String');% list menu fields
|
---|
| 3157 | index_fields=get(handles.Fields,'Value');% selected string index
|
---|
| 3158 | field= list_fields{index_fields(1)}; % selected string
|
---|
| 3159 | if isequal(field,'get_field...')
|
---|
[295] | 3160 | set(handles.FixVelType,'visible','off')
|
---|
| 3161 | set(handles.VelType,'visible','off')
|
---|
| 3162 | set(handles.VelType_1,'visible','off')
|
---|
| 3163 | filename=read_file_boxes(handles);
|
---|
| 3164 | hget_field=findobj(allchild(0),'name','get_field');
|
---|
| 3165 | if ~isempty(hget_field)
|
---|
| 3166 | delete(hget_field)
|
---|
| 3167 | end
|
---|
| 3168 | hget_field=get_field(filename);
|
---|
| 3169 | set(hget_field,'Name','get_field')
|
---|
| 3170 | hhget_field=guidata(hget_field);
|
---|
| 3171 | set(hhget_field.list_fig,'Value',1)
|
---|
| 3172 | set(hhget_field.list_fig,'String',{'uvmat'})
|
---|
| 3173 | set(handles.transform_fct,'Value',1)% no transform by default
|
---|
| 3174 | set(handles.path_transform,'String','')
|
---|
[199] | 3175 | return %no action
|
---|
| 3176 | end
|
---|
| 3177 | list_fields=get(handles.Fields_1,'String');% list menu fields
|
---|
| 3178 | index_fields=get(handles.Fields_1,'Value');% selected string index
|
---|
| 3179 | field_1= list_fields{index_fields(1)}; % selected string
|
---|
| 3180 | UvData=get(handles.uvmat,'UserData');
|
---|
| 3181 |
|
---|
| 3182 | %read the rootfile input display
|
---|
| 3183 | [FileName,RootPath,FileBase,FileIndices,FileExt]=read_file_boxes(handles);
|
---|
[334] | 3184 | [~,~,~,i1,i2,j1,j2,~,NomType]=fileparts_uvmat(['xxx' get(handles.FileIndex,'String') FileExt]);
|
---|
| 3185 | % [P,F,str1,str2,str_a,str_b,E,NomType]=name2display(['xxx' get(handles.FileIndex,'String') FileExt]);
|
---|
[199] | 3186 | NomTypeNew=NomType;%default
|
---|
[295] | 3187 | if isequal(field,'image')
|
---|
[332] | 3188 | if isequal(NomType,'_1-2_1')||isequal(NomType,'_1_1-2')
|
---|
| 3189 | NomTypeNew='_1_1';
|
---|
[295] | 3190 | elseif isequal(NomType,'#_ab')
|
---|
| 3191 | NomTypeNew='#a';
|
---|
[332] | 3192 | elseif isequal(NomType,'_1-2')
|
---|
| 3193 | NomTypeNew='_1';
|
---|
[295] | 3194 | end
|
---|
[334] | 3195 | imagename=name_generator(FileBase,i1,j1,'.png',NomTypeNew,1,i2,j2,'');
|
---|
[295] | 3196 | if ~exist(imagename,'file')
|
---|
| 3197 | [FileName,PathName] = uigetfile( ...
|
---|
| 3198 | {'*.png;*.jpg;*.tif;*.avi;*.AVI;*.vol', ' (*.png, .tif, *.avi,*.vol)';
|
---|
[199] | 3199 | '*.jpg',' jpeg image files'; ...
|
---|
| 3200 | '*.png','.png image files'; ...
|
---|
| 3201 | '*.tif','.tif image files'; ...
|
---|
| 3202 | '*.avi;*.AVI','.avi movie files'; ...
|
---|
| 3203 | '*.vol','.volume images (png)'; ...
|
---|
| 3204 | '*.*', 'All Files (*.*)'}, ...
|
---|
[295] | 3205 | 'Pick an image',imagename);
|
---|
| 3206 | imagename=[PathName FileName];
|
---|
| 3207 | end
|
---|
| 3208 | % display the selected field and related information
|
---|
| 3209 | display_file_name(hObject, eventdata, handles,imagename)%display the image
|
---|
| 3210 | return
|
---|
[199] | 3211 | else
|
---|
| 3212 | ext=get(handles.FileExt,'String');
|
---|
| 3213 | if ~isequal(ext,'.nc') %find the new NomType if the previous display was not already a netcdf file
|
---|
[295] | 3214 | [FileName,PathName] = uigetfile( ...
|
---|
| 3215 | {'*.nc', ' (*.nc)';
|
---|
[199] | 3216 | '*.nc',' netcdf files'; ...
|
---|
| 3217 | '*.*', 'All Files (*.*)'}, ...
|
---|
[295] | 3218 | 'Pick a netcdf file',FileBase);
|
---|
| 3219 | filename=[PathName FileName];
|
---|
| 3220 | % display the selected field and related information
|
---|
[199] | 3221 | display_file_name(hObject, eventdata, handles,filename)
|
---|
| 3222 | return
|
---|
| 3223 | end
|
---|
| 3224 | end
|
---|
[334] | 3225 | indices=name_generator('',i1,j1,'',NomTypeNew,1,i2,j2,'');
|
---|
[199] | 3226 | set(handles.FileIndex,'String',indices)
|
---|
[323] | 3227 | set(handles.NomType,'String',NomTypeNew)
|
---|
| 3228 | % set(handles.FileIndex,'UserData',NomTypeNew)
|
---|
[199] | 3229 | %common to Fields_1_Callback
|
---|
| 3230 | if isequal(field,'image')||isequal(field_1,'image')
|
---|
[292] | 3231 | set(handles.TitleNpx,'Visible','on')% visible npx,pxcm... buttons
|
---|
| 3232 | set(handles.TitleNpy,'Visible','on')
|
---|
| 3233 | set(handles.num_Npx,'Visible','on')
|
---|
| 3234 | set(handles.num_Npy,'Visible','on')
|
---|
[199] | 3235 | else
|
---|
[292] | 3236 | set(handles.TitleNpx,'Visible','off')% visible npx,pxcm... buttons
|
---|
| 3237 | set(handles.TitleNpy,'Visible','off')
|
---|
| 3238 | set(handles.num_Npx,'Visible','off')
|
---|
| 3239 | set(handles.num_Npy,'Visible','off')
|
---|
[199] | 3240 | end
|
---|
| 3241 | setfield(handles);% update the field structure ('civ1'....)
|
---|
| 3242 | if ~(isfield(UvData,'NewSeries')&&isequal(UvData.NewSeries,1))
|
---|
| 3243 | run0_Callback(hObject, eventdata, handles)
|
---|
| 3244 | end
|
---|
| 3245 |
|
---|
| 3246 | %---------------------------------------------------
|
---|
| 3247 | % --- Executes on menu selection Fields
|
---|
| 3248 | function Fields_1_Callback(hObject, eventdata, handles)
|
---|
| 3249 | %-------------------------------------------------
|
---|
| 3250 | list_fields=get(handles.Fields,'String');% list menu fields
|
---|
| 3251 | index_fields=get(handles.Fields,'Value');% selected string index
|
---|
| 3252 | field= list_fields{index_fields(1)}; % selected string
|
---|
| 3253 | list_fields=get(handles.Fields_1,'String');% list menu fields
|
---|
| 3254 | index_fields=get(handles.Fields_1,'Value');% selected string index
|
---|
| 3255 | field_1= list_fields{index_fields(1)}; % selected string for the second field
|
---|
| 3256 | if isequal(field_1,'') %remove second field if 'blank' field is selected
|
---|
| 3257 | set(handles.SubField,'Value',0)
|
---|
| 3258 | SubField_Callback(hObject, eventdata, handles)
|
---|
| 3259 | return
|
---|
| 3260 | end
|
---|
| 3261 | UvData=get(handles.uvmat,'UserData');
|
---|
| 3262 |
|
---|
| 3263 | %read the rootfile input display
|
---|
[246] | 3264 | [FileName,RootPath,FileBase,FileIndices,FileExt_1]=read_file_boxes_1(handles);
|
---|
[334] | 3265 | [~,~,~,i1,i2,j1,j2,~,NomType_1]=fileparts_uvmat(['xxx' get(handles.FileIndex,'String') FileExt_1]);
|
---|
| 3266 | % [P,F,str1,str2,str_a,str_b,E,NomType_1]=name2display(['xxx' get(handles.FileIndex,'String') FileExt_1]);
|
---|
[210] | 3267 | if isempty(NomType_1)|| strcmp(NomType_1,'')
|
---|
[295] | 3268 | [FileName,RootPath,FileBase,FileIndices,FileExt_1]=read_file_boxes(handles);
|
---|
[334] | 3269 | [~,~,~,i1,i2,j1,j2,~,NomType_1]=fileparts_uvmat(['xxx' get(handles.FileIndex,'String') FileExt_1]);
|
---|
| 3270 | % [P,F,str1,str2,str_a,str_b,E,NomType_1]=name2display(['xxx' get(handles.FileIndex,'String') FileExt_1]);
|
---|
[199] | 3271 | end
|
---|
| 3272 | NomTypeNew=NomType_1;%default
|
---|
| 3273 |
|
---|
| 3274 | set(handles.SubField,'Value',1)%introduce second field
|
---|
| 3275 | if isfield(UvData,'XmlData')
|
---|
| 3276 | UvData.XmlData_1=UvData.XmlData;
|
---|
| 3277 | end
|
---|
| 3278 | set(handles.FileIndex_1,'Visible','on')
|
---|
| 3279 | set(handles.FileExt_1,'Visible','on')
|
---|
| 3280 | RootPath_1=get(handles.RootPath_1,'String');
|
---|
| 3281 | RootFile_1=get(handles.RootFile_1,'String');
|
---|
| 3282 | if isempty(RootPath_1)||isequal(RootPath_1,'')
|
---|
| 3283 | set(handles.RootPath_1,'String','"')
|
---|
| 3284 | end
|
---|
| 3285 | if isempty(RootFile_1) || isequal(RootFile_1,'')
|
---|
| 3286 | set(handles.RootFile_1,'String','"')
|
---|
| 3287 | end
|
---|
| 3288 | if ~isempty(RootFile_1)&&(isequal(RootFile_1(1),'/')||isequal(RootFile_1(1),'\'))
|
---|
| 3289 | RootFile_1(1)=[];
|
---|
| 3290 | end
|
---|
| 3291 |
|
---|
| 3292 | if isequal(field_1,'get_field...')
|
---|
[236] | 3293 | veltype_handles=[handles.VelType handles.interp1 handles.filter1 handles.civ2 handles.interp2 handles.filter2];
|
---|
[199] | 3294 | set_veltype_display(veltype_handles,0) % unvisible civ buttons
|
---|
| 3295 | filename=read_file_boxes_1(handles);
|
---|
| 3296 | hget_field=findobj(allchild(0),'name','get_field_1');
|
---|
| 3297 | if ~isempty(hget_field)
|
---|
| 3298 | delete(hget_field)
|
---|
| 3299 | end
|
---|
| 3300 | hget_field=get_field(filename);
|
---|
| 3301 | set(hget_field,'name','get_field_1')
|
---|
| 3302 | hhget_field=guidata(hget_field);
|
---|
| 3303 | set(hhget_field.list_fig,'Value',1)
|
---|
| 3304 | set(hhget_field.list_fig,'String',{'uvmat'})
|
---|
| 3305 | set(handles.transform_fct,'Value',1)% no transform by default
|
---|
| 3306 | set(handles.path_transform,'String','')
|
---|
| 3307 | return %no action
|
---|
| 3308 | end
|
---|
| 3309 | if isequal(field_1,'image')
|
---|
| 3310 | % transform netc type to the corresponding image type
|
---|
[332] | 3311 | if isequal(NomType_1,'_1-2_1')||isequal(NomType_1,'_1_1-2')|| isequal(NomType_1,'#_ab')|| isequal(NomType_1,'_1-2')
|
---|
[326] | 3312 | UvData.SubDir_1=get(handles.SubDir_1,'String'); %preserve the InputFile.SubDir in memory
|
---|
[332] | 3313 | if isequal(NomType_1,'_1-2_1')||isequal(NomType_1,'_1_1-2')
|
---|
| 3314 | NomTypeNew='_1_1';
|
---|
[199] | 3315 | elseif isequal(NomType_1,'#_ab')
|
---|
| 3316 | NomTypeNew='#a';
|
---|
[332] | 3317 | elseif isequal(NomType_1,'_1-2')
|
---|
| 3318 | NomTypeNew='_1';
|
---|
[199] | 3319 | end
|
---|
| 3320 | end
|
---|
[334] | 3321 | imagename=name_generator(FileBase,i1,j1,'.png',NomTypeNew,1,i2,j2,'');
|
---|
[199] | 3322 | if ~exist(imagename,'file')
|
---|
| 3323 | [FileName,PathName] = uigetfile( ...
|
---|
| 3324 | {'*.png;*.jpg;*.tif;*.avi;*.AVI;*.vol', ' (*.png, .tif, *.avi,*.vol)';
|
---|
| 3325 | '*.jpg',' jpeg image files'; ...
|
---|
| 3326 | '*.png','.png image files'; ...
|
---|
| 3327 | '*.tif','.tif image files'; ...
|
---|
| 3328 | '*.avi;*.AVI','.avi movie files'; ...
|
---|
| 3329 | '*.vol','.volume images (png)'; ...
|
---|
| 3330 | '*.*', 'All Files (*.*)'}, ...
|
---|
| 3331 | 'Pick an image',imagename);
|
---|
| 3332 | % display the selected field and related information
|
---|
| 3333 | imagename=[PathName FileName];
|
---|
| 3334 | end
|
---|
| 3335 | display_file_name_1(hObject, eventdata, handles,imagename)%display the image
|
---|
| 3336 | return
|
---|
| 3337 | else
|
---|
| 3338 | set(handles.SubDir_1,'Visible','on')
|
---|
[246] | 3339 | if ~isequal(FileExt_1,'.nc') %find the new NomType if the previous display was not already a netcdf file
|
---|
[199] | 3340 | RootPath_1=get(handles.RootPath_1,'String');
|
---|
| 3341 | RootFile_1=get(handles.RootFile_1,'String');
|
---|
[236] | 3342 | if isempty(RootPath_1)||isequal(RootPath_1,'')
|
---|
[199] | 3343 | set(handles.RootPath_1,'String','"')
|
---|
| 3344 | end
|
---|
[236] | 3345 | if isempty(RootFile_1) || isequal(RootFile_1,'')
|
---|
[199] | 3346 | set(handles.RootFile_1,'String','"')
|
---|
| 3347 | end
|
---|
[236] | 3348 | if ~isempty(RootFile_1)&&(isequal(RootFile_1(1),'/')||isequal(RootFile_1(1),'\'))
|
---|
[199] | 3349 | RootFile_1(1)=[];
|
---|
| 3350 | end
|
---|
| 3351 | filebase_1=fullfile(RootPath_1,RootFile_1);
|
---|
| 3352 | SubDir_1=get(handles.SubDir,'String');
|
---|
| 3353 | if isempty(SubDir_1)||isequal(SubDir_1,'')
|
---|
| 3354 | if isfield(UvData,'SubDir_1')
|
---|
| 3355 | SubDir_1=UvData.SubDir_1;%retrieve previous subdir
|
---|
| 3356 | else
|
---|
| 3357 | SubDir_1='?';
|
---|
| 3358 | end
|
---|
| 3359 | end
|
---|
| 3360 | str1=get(handles.i1,'String');
|
---|
| 3361 | str_a=get(handles.j1,'String');
|
---|
[332] | 3362 | if isequal(NomType_1,'#_ab')||isequal(NomType_1,'_1-2_1')||isequal(NomType_1,'_1_1-2')||isequal(NomType_1,'_1-2')
|
---|
[199] | 3363 | NomTypeNew=NomType_1;
|
---|
| 3364 | elseif isequal(NomType_1,'#a')
|
---|
| 3365 | [filename, n1,na,n2,nb,SubDir_1]=name_generator(filebase_1, str2num(str1),stra2num(str_a),'.nc','#_ab',0,[],[],SubDir_1);
|
---|
| 3366 | NomTypeNew='#_ab';
|
---|
[332] | 3367 | elseif isequal(NomType_1,'_1_1')
|
---|
| 3368 | [filename,n1,na,n2,nb,SubDir_1]=name_generator(filebase_1,str2num(str1),stra2num(str_a),'.nc','_1-2_1',0,str2num(str1),[],SubDir_1);
|
---|
[199] | 3369 | if idetect==1
|
---|
[332] | 3370 | NomTypeNew='_1-2_1';
|
---|
[199] | 3371 | else
|
---|
[332] | 3372 | NomTypeNew='_1_1-2';
|
---|
[199] | 3373 | end
|
---|
| 3374 | else %for instance avi files or any ima_num series
|
---|
[332] | 3375 | [filename,n1,na,n2,nb,SubDir_1]=name_generator(filebase_1,str2num(str1),stra2num(str_a),'.nc','_1-2',0,str2num(str1),[],SubDir_1);
|
---|
| 3376 | NomTypeNew='_1-2';
|
---|
[199] | 3377 | end
|
---|
| 3378 | [Path,Name]=fileparts(filebase_1);
|
---|
| 3379 | set(handles.FileExt_1,'String','.nc');
|
---|
| 3380 | if ~isempty(SubDir_1) && ~strcmp(SubDir_1,'''')&& ~strcmp(SubDir_1,'"')&& ~strcmp(SubDir_1(1),'/')
|
---|
| 3381 | SubDir_1=['/' SubDir_1];
|
---|
| 3382 | end
|
---|
| 3383 | set(handles.SubDir_1,'String',SubDir_1);
|
---|
| 3384 | end
|
---|
[236] | 3385 | if isequal(field,'vort') || isequal(field,'div') || isequal(field,'strain')
|
---|
| 3386 | set(handles.VelType_1,'BackgroundColor',[0.702 0.702 0.702]) % put their color to grey
|
---|
[199] | 3387 | set(handles.civ2_1,'BackgroundColor',[0.702 0.702 0.702])
|
---|
| 3388 | set(handles.interp1_1,'BackgroundColor',[0.702 0.702 0.702])
|
---|
| 3389 | set(handles.interp2_1,'BackgroundColor',[0.702 0.702 0.702])
|
---|
| 3390 | elseif isequal(field_1,'more...'); %add new item to the menu
|
---|
[236] | 3391 | set(handles.VelType_1,'BackgroundColor',[0.702 0.702 0.702]) % put their color to grey
|
---|
[199] | 3392 | set(handles.civ2_1,'BackgroundColor',[0.702 0.702 0.702])
|
---|
| 3393 | str=calc_field;%get the list of available scalars by the function calc_scal
|
---|
| 3394 | [ind_answer,v] = listdlg('PromptString','Select a file:',...
|
---|
| 3395 | 'SelectionMode','single',...
|
---|
| 3396 | 'ListString',str);
|
---|
| 3397 | % edit the choice in the field and action menu
|
---|
| 3398 | scalar=cell2mat(str(ind_answer));
|
---|
| 3399 | menu=update_menu(handles.Fields_1,scalar);
|
---|
| 3400 | set(handles.Fields_1,'String',menu);% store the selected scalar type
|
---|
| 3401 | end
|
---|
| 3402 | end
|
---|
| 3403 | str1=get(handles.i1,'String');
|
---|
| 3404 | str2=get(handles.i2,'String');
|
---|
| 3405 | str_a=get(handles.j1,'String');
|
---|
| 3406 | str_b=get(handles.j2,'String');
|
---|
| 3407 | indices=name_generator('',str2num(str1),stra2num(str_a),'',NomTypeNew,1,str2num(str2),stra2num(str_b),'');
|
---|
| 3408 | set(handles.FileIndex_1,'String',indices)
|
---|
[323] | 3409 | set(handles.NomType_1,'String',NomTypeNew)
|
---|
| 3410 | % set(handles.FileIndex_1,'UserData',NomTypeNew)
|
---|
[199] | 3411 |
|
---|
| 3412 | %common to Fields_Callback
|
---|
[236] | 3413 | if isequal(field,'image')||isequal(field_1,'image')
|
---|
[292] | 3414 | set(handles.TitleNpx,'Visible','on')% visible npx,pxcm... buttons
|
---|
| 3415 | set(handles.TitleNpy,'Visible','on')
|
---|
| 3416 | set(handles.num_Npx,'Visible','on')
|
---|
| 3417 | set(handles.num_Npy,'Visible','on')
|
---|
[199] | 3418 | % set(handles.fix_pair,'Value',0)
|
---|
| 3419 | else
|
---|
[292] | 3420 | set(handles.TitleNpx,'Visible','off')% visible npx,pxcm... buttons
|
---|
| 3421 | set(handles.TitleNpy,'Visible','off')
|
---|
| 3422 | set(handles.num_Npx,'Visible','off')
|
---|
| 3423 | set(handles.num_Npy,'Visible','off')
|
---|
[199] | 3424 | % set(handles.fix_pair,'Value',1)
|
---|
| 3425 | end
|
---|
[236] | 3426 | if isequal(field,'velocity')||isequal(field_1,'velocity');
|
---|
[199] | 3427 | state_vect='on';
|
---|
| 3428 | else
|
---|
| 3429 | state_vect='off';
|
---|
| 3430 | end
|
---|
[236] | 3431 | if ~isequal(field,'velocity')||(~isequal(field_1,'velocity')&~isequal(field_1,''));
|
---|
[199] | 3432 | state_scal='on';
|
---|
| 3433 | else
|
---|
| 3434 | state_scal='off';
|
---|
| 3435 | end
|
---|
| 3436 | set(handles.uvmat,'UserData',UvData)
|
---|
| 3437 | setfield(handles);% update the field structure ('civ1'....)
|
---|
| 3438 | if ~(isfield(UvData,'NewSeries')&&isequal(UvData.NewSeries,1))
|
---|
| 3439 | run0_Callback(hObject, eventdata, handles)
|
---|
| 3440 | end
|
---|
| 3441 |
|
---|
| 3442 | %------------------------------------------------------------------------
|
---|
| 3443 | % --- set the visibility of relevant velocity type menus:
|
---|
[236] | 3444 | function menu=set_veltype_display(Civ)
|
---|
[199] | 3445 | %------------------------------------------------------------------------
|
---|
| 3446 | if isequal(Civ,0)
|
---|
| 3447 | imax=0;
|
---|
| 3448 | elseif isequal(Civ,1) || isequal(Civ,2)
|
---|
| 3449 | imax=1;
|
---|
| 3450 | elseif isequal(Civ,3)
|
---|
| 3451 | imax=3;
|
---|
| 3452 | elseif isequal(Civ,4) || isequal(Civ,5)
|
---|
| 3453 | imax=4;
|
---|
| 3454 | elseif isequal(Civ,6) %patch2
|
---|
| 3455 | imax=6;
|
---|
| 3456 | end
|
---|
[236] | 3457 | menu={'civ1';'interp1';'filter1';'civ2';'interp2';'filter2'};
|
---|
| 3458 | menu=menu(1:imax);
|
---|
| 3459 | % for ibutton=1:imax;
|
---|
| 3460 | % set(handles(ibutton),'Visible','on') % unvisible civ buttons
|
---|
| 3461 | % end
|
---|
| 3462 | % % for ibutton=max(imax+1,2):6;
|
---|
| 3463 | % for ibutton=imax+1:6;
|
---|
| 3464 | % set(handles(ibutton),'Visible','off') % unvisible civ buttons
|
---|
| 3465 | % set(handles(ibutton),'Value',0)%unactivate unvisible buttons
|
---|
| 3466 | % end
|
---|
[199] | 3467 |
|
---|
[323] | 3468 | %------------------------------------------------------------------------
|
---|
[236] | 3469 | % --- Executes on button press in VelType.
|
---|
| 3470 | function VelType_Callback(hObject, eventdata, handles)
|
---|
[323] | 3471 | %------------------------------------------------------------------------
|
---|
[236] | 3472 | set(handles.FixVelType,'Value',1)
|
---|
[199] | 3473 | run0_Callback(hObject, eventdata, handles)
|
---|
| 3474 |
|
---|
[323] | 3475 | %------------------------------------------------------------------------
|
---|
| 3476 | % --- Executes on button press in VelType.
|
---|
[236] | 3477 | function VelType_1_Callback(hObject, eventdata, handles)
|
---|
[323] | 3478 | %------------------------------------------------------------------------
|
---|
[236] | 3479 |
|
---|
[246] | 3480 | set(handles.FixVelType,'Value',1)% the velocity type is now imposed by the GUI (not automatic)
|
---|
[236] | 3481 | %refresh field with a second filename=first fiel name
|
---|
| 3482 | set(handles.run0,'BackgroundColor',[1 1 0])%paint the command button in yellow
|
---|
[323] | 3483 | drawnow
|
---|
| 3484 | InputFile=read_GUI(handles.InputFile);
|
---|
[236] | 3485 | filename=read_file_boxes(handles);
|
---|
[246] | 3486 |
|
---|
| 3487 | index=get(handles.VelType_1,'Value');
|
---|
| 3488 | if index==1
|
---|
| 3489 | filename_1='';% we plot the current field without the second field
|
---|
| 3490 | set(handles.SubField,'Value',0)
|
---|
| 3491 | SubField_Callback(hObject, eventdata, handles)
|
---|
| 3492 | elseif get(handles.SubField,'Value')% if subfield is already 'on'
|
---|
| 3493 | filename_1=read_file_boxes_1(handles); %read the current second field
|
---|
[199] | 3494 | else
|
---|
[246] | 3495 | filename_1=filename;% we compare two fields in the same file
|
---|
| 3496 | set(handles.SubField,'Value',1)
|
---|
[199] | 3497 | end
|
---|
[246] | 3498 |
|
---|
[236] | 3499 | num_i1=stra2num(get(handles.i1,'String'));
|
---|
| 3500 | num_i2=stra2num(get(handles.i2,'String'));
|
---|
| 3501 | num_j1=stra2num(get(handles.j1,'String'));
|
---|
| 3502 | num_j2=stra2num(get(handles.j2,'String'));
|
---|
[199] | 3503 |
|
---|
[236] | 3504 | errormsg=refresh_field(handles,filename,filename_1,num_i1,num_i2,num_j1,num_j2);
|
---|
[199] | 3505 |
|
---|
[236] | 3506 | if ~isempty(errormsg)
|
---|
| 3507 | msgbox_uvmat('ERROR',errormsg);
|
---|
[199] | 3508 | else
|
---|
[236] | 3509 | set(handles.i1,'BackgroundColor',[1 1 1])
|
---|
| 3510 | set(handles.i2,'BackgroundColor',[1 1 1])
|
---|
| 3511 | set(handles.j1,'BackgroundColor',[1 1 1])
|
---|
| 3512 | set(handles.j2,'BackgroundColor',[1 1 1])
|
---|
| 3513 | set(handles.FileIndex,'BackgroundColor',[1 1 1])
|
---|
| 3514 | set(handles.FileIndex_1,'BackgroundColor',[1 1 1])
|
---|
[199] | 3515 | end
|
---|
[236] | 3516 | set(handles.run0,'BackgroundColor',[1 0 0])
|
---|
[199] | 3517 |
|
---|
| 3518 | %-----------------------------------------------
|
---|
| 3519 | % --- reset civ buttons
|
---|
| 3520 | function reset_vel_type(handles_civ0,handle1)
|
---|
| 3521 | for ibutton=1:length(handles_civ0)
|
---|
| 3522 | set(handles_civ0(ibutton),'BackgroundColor',[0.831 0.816 0.784])
|
---|
| 3523 | set(handles_civ0(ibutton),'Value',0)
|
---|
| 3524 | end
|
---|
| 3525 | if exist('handle1','var')%handles of selected button
|
---|
| 3526 | set(handle1,'BackgroundColor',[1 1 0])
|
---|
| 3527 | end
|
---|
| 3528 |
|
---|
| 3529 | %-------------------------------------------------------
|
---|
| 3530 | % --- Executes on button press in MENUVOLUME.
|
---|
| 3531 | %-------------------------------------------------------
|
---|
| 3532 | function VOLUME_Callback(hObject, eventdata, handles)
|
---|
| 3533 | %errordlg('command VOL not implemented yet')
|
---|
| 3534 | if ishandle(handles.UVMAT_title)
|
---|
| 3535 | delete(handles.UVMAT_title)
|
---|
| 3536 | end
|
---|
| 3537 | UvData=get(handles.uvmat,'UserData');%read UvData properties stored on the uvmat interface
|
---|
| 3538 | if isequal(get(handles.VOLUME,'Value'),1)
|
---|
[292] | 3539 | set(handles.CheckZoom,'Value',0)
|
---|
| 3540 | set(handles.CheckZoom,'BackgroundColor',[0.7 0.7 0.7])
|
---|
[199] | 3541 | set(handles.edit_vect,'Value',0)
|
---|
| 3542 | edit_vect_Callback(hObject, eventdata, handles)
|
---|
| 3543 | set(handles.edit_object,'Value',0)
|
---|
| 3544 | set(handles.edit_object,'BackgroundColor',[0.7 0.7 0.7])
|
---|
| 3545 | % set(handles.cal,'Value',0)
|
---|
| 3546 | % set(handles.cal,'BackgroundColor',[0 1 0])
|
---|
| 3547 | set(handles.edit_vect,'Value',0)
|
---|
| 3548 | edit_vect_Callback(hObject, eventdata, handles)
|
---|
| 3549 | %initiate set_object GUI
|
---|
| 3550 | data.TITLE='VOLUME';
|
---|
| 3551 | if isfield(UvData,'CoordType')
|
---|
| 3552 | data.CoordType=UvData.CoordType;
|
---|
| 3553 | end
|
---|
| 3554 | if isfield(UvData,'Mesh')&~isempty(UvData.Mesh)
|
---|
| 3555 | data.RangeY=UvData.Mesh;
|
---|
| 3556 | data.RangeX=UvData.Mesh;
|
---|
| 3557 | data.DX=UvData.Mesh;
|
---|
| 3558 | data.DY=UvData.Mesh;
|
---|
| 3559 | elseif isfield(UvData.Field,'AX')&isfield(UvData.Field,'AY')& isfield(UvData.Field,'A')%only image
|
---|
| 3560 | np=size(UvData.Field.A);
|
---|
| 3561 | meshx=(UvData.Field.AX(end)-UvData.Field.AX(1))/np(2);
|
---|
| 3562 | meshy=abs(UvData.Field.AY(end)-UvData.Field.AY(1))/np(1);
|
---|
| 3563 | data.RangeY=max(meshx,meshy);
|
---|
| 3564 | data.RangeX=max(meshx,meshy);
|
---|
| 3565 | data.DX=max(meshx,meshy);
|
---|
| 3566 | end
|
---|
| 3567 | data.ParentButton=handles.VOLUME;
|
---|
| 3568 | PlotHandles=get_plot_handles(handles);%get the handles of the interface elements setting the plotting parameters
|
---|
| 3569 | [hset_object,UvData.sethandles]=set_object(data,PlotHandles);% call the set_object interface with action on haxes,
|
---|
| 3570 | % associate the set_object interface handle to the plotting axes
|
---|
| 3571 | if isfield(UvData.OpenParam,'SetObjectOrigin')
|
---|
| 3572 | pos_uvmat=get(huvmat,'Position');
|
---|
| 3573 | pos_set_object(1:2)=UvData.OpenParam.SetObjectOrigin + pos_uvmat(1:2);
|
---|
| 3574 | pos_set_object(3:4)=UvData.OpenParam.SetObjectSize .* pos_uvmat(3:4);
|
---|
| 3575 | set(hset_object,'Position',pos_set_object)
|
---|
| 3576 | end
|
---|
| 3577 | UvData.MouseAction='create_object';
|
---|
| 3578 | else
|
---|
| 3579 | set(handles.VOLUME,'BackgroundColor',[0 1 0])
|
---|
| 3580 | UvData.MouseAction='none';
|
---|
| 3581 | end
|
---|
| 3582 | set(huvmat,'UserData',UvData)
|
---|
| 3583 |
|
---|
| 3584 | %-------------------------------------------------------
|
---|
| 3585 | function edit_vect_Callback(hObject, eventdata, handles)
|
---|
| 3586 | %-------------------------------------------------------
|
---|
| 3587 | %
|
---|
| 3588 | % UvData=get(handles.uvmat,'UserData');%read UvData properties stored on the uvmat interface
|
---|
| 3589 | if isequal(get(handles.edit_vect,'Value'),1)
|
---|
| 3590 | test_civ2=isequal(get(handles.civ2,'BackgroundColor'),[1 1 0]);
|
---|
[236] | 3591 | test_civ1=isequal(get(handles.VelType,'BackgroundColor'),[1 1 0]);
|
---|
[199] | 3592 | if ~test_civ2 && ~test_civ1
|
---|
| 3593 | msgbox_uvmat('ERROR','manual correction only possible for CIV1 or CIV2 velocity fields')
|
---|
| 3594 | end
|
---|
| 3595 | set(handles.record,'Visible','on')
|
---|
| 3596 | set(handles.edit_vect,'BackgroundColor',[1 1 0])
|
---|
| 3597 | set(handles.edit_object,'Value',0)
|
---|
[292] | 3598 | set(handles.CheckZoom,'Value',0)
|
---|
| 3599 | set(handles.CheckZoom,'BackgroundColor',[0.7 0.7 0.7])
|
---|
[199] | 3600 | % set(handles.create,'Value',0)
|
---|
| 3601 | % set(handles.create,'BackgroundColor',[0 1 0])
|
---|
| 3602 | set(handles.edit_object,'BackgroundColor',[0.7 0.7 0.7])
|
---|
| 3603 | set(gcf,'Pointer','arrow')
|
---|
| 3604 | % UvData.MouseAction='edit_vect';
|
---|
| 3605 | else
|
---|
| 3606 | set(handles.record,'Visible','off')
|
---|
| 3607 | set(handles.edit_vect,'BackgroundColor',[0.7 0.7 0.7])
|
---|
| 3608 | % UvData.MouseAction='none';
|
---|
| 3609 | end
|
---|
| 3610 | % set(handles.uvmat,'UserData',UvData)
|
---|
| 3611 |
|
---|
| 3612 | %----------------------------------------------
|
---|
| 3613 | function save_mask_Callback(hObject, eventdata, handles)
|
---|
| 3614 | %-----------------------------------------------------------------------
|
---|
| 3615 | UvData=get(handles.uvmat,'UserData');
|
---|
| 3616 |
|
---|
| 3617 | flag=1;
|
---|
| 3618 | npx=size(UvData.Field.A,2);
|
---|
| 3619 | npy=size(UvData.Field.A,1);
|
---|
| 3620 | xi=0.5:npx-0.5;
|
---|
| 3621 | yi=0.5:npy-0.5;
|
---|
| 3622 | [Xi,Yi]=meshgrid(xi,yi);
|
---|
| 3623 | if isfield(UvData,'Object')
|
---|
| 3624 | for iobj=1:length(UvData.Object)
|
---|
| 3625 | ObjectData=UvData.Object{iobj};
|
---|
| 3626 | if isfield(ObjectData,'ProjMode') &&(isequal(ObjectData.ProjMode,'mask_inside')||isequal(ObjectData.ProjMode,'mask_outside'));
|
---|
| 3627 | flagobj=1;
|
---|
| 3628 | testphys=0; %coordinates in pixels by default
|
---|
| 3629 | if isfield(ObjectData,'CoordType') && isequal(ObjectData.CoordType,'phys')
|
---|
| 3630 | if isfield(UvData,'XmlData')&& isfield(UvData.XmlData,'GeometryCalib')
|
---|
| 3631 | Calib=UvData.XmlData.GeometryCalib;
|
---|
| 3632 | testphys=1;
|
---|
| 3633 | end
|
---|
| 3634 | end
|
---|
| 3635 | if isfield(ObjectData,'Coord')& isfield(ObjectData,'Style')
|
---|
| 3636 | if isequal(ObjectData.Style,'polygon')
|
---|
| 3637 | X=ObjectData.Coord(:,1);
|
---|
| 3638 | Y=ObjectData.Coord(:,2);
|
---|
| 3639 | if testphys
|
---|
| 3640 | [X,Y]=px_XYZ(Calib,X,Y,0);% to generalise with 3D cases
|
---|
| 3641 | end
|
---|
| 3642 | flagobj=~inpolygon(Xi,Yi,X',Y');%=0 inside the polygon, 1 outside
|
---|
| 3643 | elseif isequal(ObjectData.Style,'ellipse')
|
---|
| 3644 | if testphys
|
---|
| 3645 | %[X,Y]=px_XYZ(Calib,X,Y,0);% TODO:create a polygon boundary and transform to phys
|
---|
| 3646 | end
|
---|
| 3647 | RangeX=max(ObjectData.RangeX);
|
---|
| 3648 | RangeY=max(ObjectData.RangeY);
|
---|
| 3649 | X2Max=RangeX*RangeX;
|
---|
| 3650 | Y2Max=RangeY*RangeY;
|
---|
| 3651 | distX=(Xi-ObjectData.Coord(1,1));
|
---|
| 3652 | distY=(Yi-ObjectData.Coord(1,2));
|
---|
| 3653 | flagobj=(distX.*distX/X2Max+distY.*distY/Y2Max)>1;
|
---|
| 3654 | elseif isequal(ObjectData.Style,'rectangle')
|
---|
| 3655 | if testphys
|
---|
| 3656 | %[X,Y]=px_XYZ(Calib,X,Y,0);% TODO:create a polygon boundary and transform to phys
|
---|
| 3657 | end
|
---|
| 3658 | distX=abs(Xi-ObjectData.Coord(1,1));
|
---|
| 3659 | distY=abs(Yi-ObjectData.Coord(1,2));
|
---|
| 3660 | flagobj=distX>max(ObjectData.RangeX) | distY>max(ObjectData.RangeY);
|
---|
| 3661 | end
|
---|
| 3662 | if isequal(ObjectData.ProjMode,'mask_outside')
|
---|
| 3663 | flagobj=~flagobj;
|
---|
| 3664 | end
|
---|
| 3665 | flag=flag & flagobj;
|
---|
| 3666 | end
|
---|
| 3667 | end
|
---|
| 3668 | end
|
---|
| 3669 | end
|
---|
| 3670 | % flag=~flag;
|
---|
| 3671 | %mask name
|
---|
| 3672 | RootPath=get(handles.RootPath,'String');
|
---|
| 3673 | RootFile=get(handles.RootFile,'String');
|
---|
[326] | 3674 | RootFile=regexprep(RootFile,'\<[\\/]|[\\/]\>','');%suppress possible / or \ separator at the beginning or the end of the string
|
---|
[199] | 3675 | filebase=fullfile(RootPath,RootFile);
|
---|
| 3676 | list=get(handles.masklevel,'String');
|
---|
| 3677 | masknumber=num2str(length(list));
|
---|
| 3678 | maskindex=get(handles.masklevel,'Value');
|
---|
| 3679 | mask_name=name_generator([filebase '_' masknumber 'mask'],maskindex,1,'.png','_i');
|
---|
| 3680 | imflag=uint8(255*(0.392+0.608*flag));% =100 for flag=0 (vectors not computed when 20<imflag<200)
|
---|
| 3681 | imflag=flipdim(imflag,1);
|
---|
| 3682 | % imflag=uint8(255*flag);% =0 for flag=0 (vectors=0 when 20<imflag<200)
|
---|
| 3683 | msgbox_uvmat('CONFIRMATION',[mask_name ' saved'])
|
---|
| 3684 | imwrite(imflag,mask_name,'BitDepth',8);
|
---|
| 3685 |
|
---|
| 3686 | %display the mask
|
---|
| 3687 | figure;
|
---|
| 3688 | vec=linspace(0,1,256);%define a linear greyscale colormap
|
---|
| 3689 | map=[vec' vec' vec'];
|
---|
| 3690 | colormap(map)
|
---|
| 3691 |
|
---|
| 3692 | image(imflag);
|
---|
| 3693 |
|
---|
| 3694 | %-------------------------------------------------------------------
|
---|
| 3695 | %-------------------------------------------------------------------
|
---|
| 3696 | % - FUNCTIONS FOR SETTING PLOTTING PARAMETERS
|
---|
| 3697 |
|
---|
| 3698 | %------------------------------------------------------------------
|
---|
| 3699 |
|
---|
| 3700 | %------------------------------------------------------------------
|
---|
[292] | 3701 | % --- Executes on selection change in ListColorScalar: choice of the color code.
|
---|
| 3702 | function ListColorScalar_Callback(hObject, eventdata, handles)
|
---|
[199] | 3703 | %------------------------------------------------------------------
|
---|
| 3704 | % edit the choice for color code
|
---|
[292] | 3705 | list_code=get(handles.ListColorScalar,'String');% list menu fields
|
---|
| 3706 | index_code=get(handles.ListColorScalar,'Value');% selected string index
|
---|
[199] | 3707 | col_code= list_code{index_code(1)}; % selected field
|
---|
| 3708 | if isequal(col_code,'black') || isequal(col_code,'white')
|
---|
[292] | 3709 | set(handles.Slider1,'Visible','off')
|
---|
| 3710 | set(handles.Slider2,'Visible','off')
|
---|
| 3711 | set(handles.num_ColCode1,'Visible','off')
|
---|
| 3712 | set(handles.num_ColCode2,'Visible','off')
|
---|
| 3713 | set(handles.CheckFixVecColor,'Visible','off')
|
---|
[199] | 3714 | set_vec_col_bar(handles)
|
---|
| 3715 | else
|
---|
[292] | 3716 | set(handles.Slider1,'Visible','on')
|
---|
| 3717 | set(handles.Slider2,'Visible','on')
|
---|
| 3718 | set(handles.num_ColCode1,'Visible','on')
|
---|
| 3719 | set(handles.num_ColCode2,'Visible','on')
|
---|
| 3720 | set(handles.CheckFixVecColor,'Visible','on')
|
---|
[199] | 3721 | if isequal(col_code,'ima_cor')
|
---|
[292] | 3722 | set(handles.CheckFixVecColor,'Value',0)%fixed scale by default
|
---|
| 3723 | set(handles.VecColBar,'Value',0)% 3 colors r,g,b by default
|
---|
| 3724 | set(handles.Slider1,'Min',0);
|
---|
| 3725 | set(handles.Slider1,'Max',1);
|
---|
| 3726 | set(handles.Slider2,'Min',0);
|
---|
| 3727 | set(handles.Slider2,'Max',1);
|
---|
[199] | 3728 | % set(handles.min_title_vec,'String','0')
|
---|
[292] | 3729 | set(handles.num_MaxVec,'String','1')
|
---|
| 3730 | set(handles.num_ColCode1,'String','0.333')
|
---|
[309] | 3731 | num_ColCode1_Callback(hObject, eventdata, handles)
|
---|
[292] | 3732 | set(handles.num_ColCode2,'String','0.666')
|
---|
[309] | 3733 | num_ColCode2_Callback(hObject, eventdata, handles)
|
---|
[199] | 3734 | else
|
---|
[292] | 3735 | set(handles.CheckFixVecColor,'Value',1)%auto scale between min,max by default
|
---|
| 3736 | set(handles.VecColBar,'Value',1)% colormap 'jet' by default
|
---|
| 3737 | minval=get(handles.Slider1,'Min');
|
---|
| 3738 | maxval=get(handles.Slider1,'Max');
|
---|
| 3739 | set(handles.Slider1,'Value',minval)
|
---|
| 3740 | set(handles.Slider2,'Value',maxval)
|
---|
[199] | 3741 | set_vec_col_bar(handles)
|
---|
| 3742 | end
|
---|
| 3743 | % slider_update(handles)
|
---|
| 3744 | end
|
---|
| 3745 | %replot the current graph
|
---|
| 3746 | run0_Callback(hObject, eventdata, handles)
|
---|
| 3747 |
|
---|
| 3748 |
|
---|
| 3749 | %----------------------------------------------------------------
|
---|
| 3750 | % -- Executes on slider movement to set the color code
|
---|
| 3751 | %
|
---|
[292] | 3752 | function Slider1_Callback(hObject, eventdata, handles)
|
---|
[199] | 3753 | %------------------------------------------------------------------
|
---|
[292] | 3754 | slider1=get(handles.Slider1,'Value');
|
---|
| 3755 | min_val=str2num(get(handles.num_MinVec,'String'));
|
---|
| 3756 | max_val=str2num(get(handles.num_MaxVec,'String'));
|
---|
[199] | 3757 | col=min_val+(max_val-min_val)*slider1;
|
---|
[292] | 3758 | set(handles.num_ColCode1,'String',num2str(col))
|
---|
| 3759 | if(get(handles.Slider2,'Value') < col)%move also the second slider at the same value if needed
|
---|
| 3760 | set(handles.Slider2,'Value',col)
|
---|
| 3761 | set(handles.num_ColCode2,'String',num2str(col))
|
---|
[199] | 3762 | end
|
---|
[309] | 3763 | num_ColCode1_Callback(hObject, eventdata, handles)
|
---|
[199] | 3764 |
|
---|
| 3765 | %----------------------------------------------------------------
|
---|
| 3766 | % Executes on slider movement to set the color code
|
---|
| 3767 | %----------------------------------------------------------------
|
---|
[292] | 3768 | function Slider2_Callback(hObject, eventdata, handles)
|
---|
| 3769 | slider2=get(handles.Slider2,'Value');
|
---|
| 3770 | min_val=str2num(get(handles.num_MinVec,'String'));
|
---|
| 3771 | max_val=str2num(get(handles.num_MaxVec,'String'));
|
---|
[199] | 3772 | col=min_val+(max_val-min_val)*slider2;
|
---|
[292] | 3773 | set(handles.num_ColCode2,'String',num2str(col))
|
---|
| 3774 | if(get(handles.Slider1,'Value') > col)%move also the first slider at the same value if needed
|
---|
| 3775 | set(handles.Slider1,'Value',col)
|
---|
| 3776 | set(handles.num_ColCode1,'String',num2str(col))
|
---|
[199] | 3777 | end
|
---|
[309] | 3778 | num_ColCode2_Callback(hObject, eventdata, handles)
|
---|
[199] | 3779 |
|
---|
| 3780 | %----------------------------------------------------------------
|
---|
[309] | 3781 | % --- Execute on return carriage on the edit box corresponding to slider 1
|
---|
[199] | 3782 | %----------------------------------------------------------------
|
---|
[309] | 3783 | function num_ColCode1_Callback(hObject, eventdata, handles)
|
---|
[199] | 3784 | set_vec_col_bar(handles)
|
---|
| 3785 | update_plot(handles);
|
---|
| 3786 |
|
---|
| 3787 | %----------------------------------------------------------------
|
---|
[309] | 3788 | % --- Execute on return carriage on the edit box corresponding to slider 2
|
---|
[199] | 3789 | %----------------------------------------------------------------
|
---|
[292] | 3790 | function num_ColCode2_Callback(hObject, eventdata, handles)
|
---|
[199] | 3791 | set_vec_col_bar(handles)
|
---|
| 3792 | update_plot(handles);
|
---|
[309] | 3793 | %------------------------------------------------------------------------
|
---|
[199] | 3794 | %-------------------------------------------------------
|
---|
[292] | 3795 | % --- Executes on button press in CheckFixVecColor.
|
---|
[199] | 3796 | %-------------------------------------------------------
|
---|
[292] | 3797 | function VecColBar_Callback(hObject, eventdata, handles)
|
---|
[199] | 3798 | set_vec_col_bar(handles)
|
---|
| 3799 |
|
---|
| 3800 | %-------------------------------------------------------------
|
---|
| 3801 | % --- Executes on selection change in transform_fct.
|
---|
| 3802 | function transform_fct_Callback(hObject, eventdata, handles)
|
---|
| 3803 | %-------------------------------------------------------------
|
---|
| 3804 | UvData=get(handles.uvmat,'UserData');
|
---|
| 3805 | menu=get(handles.transform_fct,'String');
|
---|
| 3806 | ind_coord=get(handles.transform_fct,'Value');
|
---|
| 3807 | coord_option=menu{ind_coord};
|
---|
| 3808 | list_transform=get(handles.transform_fct,'UserData');
|
---|
| 3809 | ff=functions(list_transform{end});
|
---|
| 3810 | if isequal(coord_option,'more...');
|
---|
| 3811 | coord_fct='';
|
---|
| 3812 | prompt = {'Enter the name of the transform function'};
|
---|
| 3813 | dlg_title = 'user defined transform';
|
---|
| 3814 | num_lines= 1;
|
---|
| 3815 | [FileName, PathName] = uigetfile( ...
|
---|
| 3816 | {'*.m', ' (*.m)';
|
---|
| 3817 | '*.m', '.m files '; ...
|
---|
| 3818 | '*.*', 'All Files (*.*)'}, ...
|
---|
| 3819 | 'Pick a file', ff.file);
|
---|
| 3820 | if isequal(PathName(end),'/')||isequal(PathName(end),'\')
|
---|
| 3821 | PathName(end)=[];
|
---|
| 3822 | end
|
---|
| 3823 | transform_selected =fullfile(PathName,FileName);
|
---|
| 3824 | if ~exist(transform_selected,'file')
|
---|
| 3825 | return
|
---|
| 3826 | end
|
---|
| 3827 | [ppp,transform,ext_fct]=fileparts(FileName);% removes extension .m
|
---|
| 3828 | if ~isequal(ext_fct,'.m')
|
---|
| 3829 | msgbox_uvmat('ERROR','a Matlab function .m must be introduced');
|
---|
| 3830 | return
|
---|
| 3831 | end
|
---|
| 3832 | menu=update_menu(handles.transform_fct,transform);%add the selected fct to the menu
|
---|
| 3833 | ind_coord=get(handles.transform_fct,'Value');
|
---|
| 3834 | addpath(PathName)
|
---|
| 3835 | list_transform{ind_coord}=str2func(transform);% create the function handle corresponding to the newly seleced function
|
---|
| 3836 | set(handles.transform_fct,'UserData',list_transform)
|
---|
| 3837 | rmpath(PathName)
|
---|
| 3838 | % save the new menu in the personal file 'uvmat_perso.mat'
|
---|
| 3839 | dir_perso=prefdir;%personal Matalb directory
|
---|
| 3840 | profil_perso=fullfile(dir_perso,'uvmat_perso.mat');
|
---|
| 3841 | if exist(profil_perso,'file')
|
---|
| 3842 | nb_builtin=UvData.OpenParam.NbBuiltin;
|
---|
| 3843 | for ilist=nb_builtin+1:numel(list_transform)
|
---|
| 3844 | ff=functions(list_transform{ilist});
|
---|
| 3845 | transform_fct{ilist-nb_builtin}=ff.file;
|
---|
| 3846 | end
|
---|
| 3847 | save (profil_perso,'transform_fct','-append'); %store the root name for future opening of uvmat
|
---|
| 3848 | end
|
---|
| 3849 | end
|
---|
| 3850 |
|
---|
| 3851 | %check the current path to the selected function
|
---|
| 3852 | if isa(list_transform{ind_coord},'function_handle')
|
---|
| 3853 | func=functions(list_transform{ind_coord});
|
---|
| 3854 | set(handles.path_transform,'String',fileparts(func.file)); %show the path to the senlected function
|
---|
| 3855 | else
|
---|
| 3856 | set(handles.path_transform,'String','')
|
---|
| 3857 | end
|
---|
| 3858 |
|
---|
[292] | 3859 | set(handles.CheckFixLimits,'Value',0)
|
---|
| 3860 | set(handles.CheckFixLimits,'BackgroundColor',[0.7 0.7 0.7])
|
---|
[199] | 3861 |
|
---|
| 3862 | %delete drawn objects
|
---|
| 3863 | hother=findobj('Tag','proj_object');%find all the proj objects
|
---|
| 3864 | for iobj=1:length(hother)
|
---|
| 3865 | delete_object(hother(iobj))
|
---|
| 3866 | end
|
---|
| 3867 | hother=findobj('Tag','DeformPoint');%find all the proj objects
|
---|
| 3868 | for iobj=1:length(hother)
|
---|
| 3869 | delete_object(hother(iobj))
|
---|
| 3870 | end
|
---|
| 3871 | hh=findobj('Tag','calib_points');
|
---|
| 3872 | if ~isempty(hh)
|
---|
| 3873 | delete(hh)
|
---|
| 3874 | end
|
---|
| 3875 | hhh=findobj('Tag','calib_marker');
|
---|
| 3876 | if ~isempty(hhh)
|
---|
| 3877 | delete(hhh)
|
---|
| 3878 | end
|
---|
| 3879 | if isfield(UvData,'Object')
|
---|
| 3880 | UvData.Object=UvData.Object(1);
|
---|
| 3881 | end
|
---|
[315] | 3882 | %list_object=get(handles.ListObject,'String');
|
---|
[302] | 3883 | set(handles.ListObject,'Value',1)
|
---|
| 3884 | set(handles.ListObject,'String',{''})
|
---|
| 3885 | %set(handles.list_object_2,'Value',1)
|
---|
| 3886 | %set(handles.list_object_2,'String',{''})
|
---|
| 3887 | %list_object_2_Callback(hObject, eventdata, handles)
|
---|
[199] | 3888 |
|
---|
| 3889 | %delete mask if it is displayed
|
---|
[315] | 3890 | if isequal(get(handles.CheckMask,'Value'),1)%if the mask option is on
|
---|
[199] | 3891 | UvData=rmfield(UvData,'MaskName'); %will impose mask refresh
|
---|
| 3892 | end
|
---|
| 3893 | set(handles.uvmat,'UserData',UvData)
|
---|
| 3894 | run0_Callback(hObject, eventdata, handles)
|
---|
| 3895 |
|
---|
[315] | 3896 | %------------------------------------------------------------------------
|
---|
[199] | 3897 | function histo1_menu_Callback(hObject, eventdata, handles)
|
---|
| 3898 | %--------------------------------------------
|
---|
| 3899 | %plot first histo
|
---|
| 3900 | huvmat=get(handles.histo1_menu,'parent');
|
---|
| 3901 | histo_menu=get(handles.histo1_menu,'String');
|
---|
| 3902 | histo_value=get(handles.histo1_menu,'Value');
|
---|
| 3903 | FieldName=histo_menu{histo_value};
|
---|
| 3904 | update_histo(handles.histo_u,huvmat,FieldName)
|
---|
| 3905 |
|
---|
[315] | 3906 | %------------------------------------------------------------------------
|
---|
[199] | 3907 | function histo2_menu_Callback(hObject, eventdata, handles)
|
---|
[315] | 3908 | %------------------------------------------------------------------------
|
---|
[199] | 3909 | %plot second histo
|
---|
| 3910 | huvmat=get(handles.histo2_menu,'parent');
|
---|
| 3911 | histo_menu=get(handles.histo2_menu,'String');
|
---|
| 3912 | histo_value=get(handles.histo2_menu,'Value');
|
---|
| 3913 | FieldName=histo_menu{histo_value};
|
---|
| 3914 | update_histo(handles.histo_v,huvmat,FieldName)
|
---|
| 3915 |
|
---|
[315] | 3916 | %------------------------------------------------------------------------
|
---|
[199] | 3917 | %read the field .Fieldname stored in UvData and plot its histogram
|
---|
| 3918 | function update_histo(haxes,huvmat,FieldName)
|
---|
[315] | 3919 | %------------------------------------------------------------------------
|
---|
[199] | 3920 | UvData=get(huvmat,'UserData');
|
---|
| 3921 | if ~isfield(UvData.Field,FieldName)
|
---|
| 3922 | msgbox_uvmat('ERROR',['no field ' FieldName ' for histogram'])
|
---|
| 3923 | return
|
---|
| 3924 | end
|
---|
| 3925 | Field=UvData.Field;
|
---|
| 3926 | FieldHisto=eval(['Field.' FieldName]);
|
---|
| 3927 | if isfield(Field,'FF') && ~isempty(Field.FF) && isequal(size(Field.FF),size(FieldHisto))
|
---|
| 3928 | indsel=find(Field.FF==0);%find values marked as false
|
---|
| 3929 | if ~isempty(indsel)
|
---|
| 3930 | FieldHisto=FieldHisto(indsel);
|
---|
| 3931 | end
|
---|
| 3932 | end
|
---|
| 3933 | if isempty(Field)
|
---|
| 3934 | msgbox_uvmat('ERROR',['empty field ' FieldName])
|
---|
| 3935 | else
|
---|
| 3936 | nxy=size(FieldHisto);
|
---|
| 3937 | Amin=double(min(min(min(FieldHisto))));%min of image
|
---|
| 3938 | Amax=double(max(max(max(FieldHisto))));%max of image
|
---|
| 3939 | if isequal(Amin,Amax)
|
---|
[316] | 3940 | %msgbox_uvmat('WARNING',['uniform field =' num2str(Amin)]);
|
---|
| 3941 | cla(haxes)
|
---|
[199] | 3942 | else
|
---|
| 3943 | Histo.ListVarName={FieldName,'histo'};
|
---|
[258] | 3944 | if isfield(Field,'NbDim') && isequal(Field.NbDim,3)
|
---|
[199] | 3945 | Histo.VarDimName={FieldName,FieldName}; %dimensions for the histogram
|
---|
| 3946 | else
|
---|
| 3947 | if numel(nxy)==2
|
---|
| 3948 | Histo.VarDimName={FieldName,FieldName}; %dimensions for the histogram
|
---|
| 3949 | else
|
---|
| 3950 | Histo.VarDimName={FieldName,{FieldName,'rgb'}}; %dimensions for the histogram
|
---|
| 3951 | end
|
---|
| 3952 | end
|
---|
| 3953 | %unit
|
---|
| 3954 | units=[]; %default
|
---|
| 3955 | for ivar=1:numel(Field.ListVarName)
|
---|
| 3956 | if strcmp(Field.ListVarName{ivar},FieldName)
|
---|
| 3957 | if isfield(Field,'VarAttribute') && numel(Field.VarAttribute)>=ivar && isfield(Field.VarAttribute{ivar},'units')
|
---|
| 3958 | units=Field.VarAttribute{ivar}.units;
|
---|
| 3959 | break
|
---|
| 3960 | end
|
---|
| 3961 | end
|
---|
| 3962 | end
|
---|
| 3963 | if ~isempty(units)
|
---|
| 3964 | Histo.VarAttribute{1}.units=units;
|
---|
| 3965 | end
|
---|
| 3966 | eval(['Histo.' FieldName '=linspace(Amin,Amax,50);'])%absissa values for histo
|
---|
[258] | 3967 | if isfield(Field,'NbDim') && isequal(Field.NbDim,3)
|
---|
[199] | 3968 | C=reshape(double(FieldHisto),1,[]);% reshape in a vector
|
---|
| 3969 | eval(['Histo.histo(:,1)=hist(C, Histo.' FieldName ');']); %calculate histogram
|
---|
| 3970 | else
|
---|
| 3971 | for col=1:size(FieldHisto,3)
|
---|
| 3972 | B=FieldHisto(:,:,col);
|
---|
| 3973 | C=reshape(double(B),1,nxy(1)*nxy(2));% reshape in a vector
|
---|
| 3974 | eval(['Histo.histo(:,col)=hist(C, Histo.' FieldName ');']); %calculate histogram
|
---|
| 3975 | end
|
---|
| 3976 | end
|
---|
[292] | 3977 | % set(haxes,'XLimMode','auto')%reset auto mode (after CheckZoom effect)
|
---|
[199] | 3978 | % set(haxes,'YLimMode','auto')
|
---|
| 3979 | % PlotParam.Auto_xy=1;
|
---|
| 3980 | plot_field(Histo,haxes);
|
---|
| 3981 | end
|
---|
| 3982 | end
|
---|
| 3983 |
|
---|
| 3984 | %------------------------------------------------
|
---|
| 3985 | %CALLBACKS FOR PLOTTING PARAMETERS
|
---|
| 3986 | %-------------------------------------------------
|
---|
| 3987 |
|
---|
| 3988 | %------------------------------------------------------------------------
|
---|
[292] | 3989 | function num_MinX_Callback(hObject, eventdata, handles)
|
---|
[199] | 3990 | %------------------------------------------------------------------------
|
---|
[292] | 3991 | set(handles.CheckFixLimits,'Value',1) %suppress auto mode
|
---|
| 3992 | set(handles.CheckFixLimits,'BackgroundColor',[1 1 0])
|
---|
[199] | 3993 | update_plot(handles);
|
---|
| 3994 |
|
---|
| 3995 | %------------------------------------------------------------------------
|
---|
[292] | 3996 | function num_MaxX_Callback(hObject, eventdata, handles)
|
---|
[199] | 3997 | %------------------------------------------------------------------------
|
---|
[292] | 3998 | set(handles.CheckFixLimits,'Value',1) %suppress auto mode
|
---|
| 3999 | set(handles.CheckFixLimits,'BackgroundColor',[1 1 0])
|
---|
[199] | 4000 | update_plot(handles);
|
---|
| 4001 |
|
---|
| 4002 | %------------------------------------------------------------------------
|
---|
[292] | 4003 | function num_MinY_Callback(hObject, eventdata, handles)
|
---|
[199] | 4004 | %------------------------------------------
|
---|
[292] | 4005 | set(handles.CheckFixLimits,'Value',1) %suppress auto mode
|
---|
| 4006 | set(handles.CheckFixLimits,'BackgroundColor',[1 1 0])
|
---|
[199] | 4007 | update_plot(handles);
|
---|
| 4008 |
|
---|
| 4009 | %------------------------------------------------------------------------
|
---|
[292] | 4010 | function num_MaxY_Callback(hObject, eventdata, handles)
|
---|
[199] | 4011 | %------------------------------------------------------------------------
|
---|
[292] | 4012 | set(handles.CheckFixLimits,'Value',1) %suppress auto mode
|
---|
| 4013 | set(handles.CheckFixLimits,'BackgroundColor',[1 1 0])
|
---|
[199] | 4014 | update_plot(handles);
|
---|
| 4015 |
|
---|
| 4016 | %------------------------------------------------------------------------
|
---|
[292] | 4017 | function num_MinA_Callback(hObject, eventdata, handles)
|
---|
[199] | 4018 | %------------------------------------------
|
---|
[292] | 4019 | set(handles.CheckFixScalar,'Value',1) %suppress auto mode
|
---|
| 4020 | set(handles.CheckFixScalar,'BackgroundColor',[1 1 0])
|
---|
| 4021 | MinA=str2double(get(handles.num_MinA,'String'));
|
---|
| 4022 | MaxA=str2double(get(handles.num_MaxA,'String'));
|
---|
[227] | 4023 | if MinA>MaxA% switch minA and maxA in case of error
|
---|
| 4024 | MinA_old=MinA;
|
---|
| 4025 | MinA=MaxA;
|
---|
| 4026 | MaxA=MinA_old;
|
---|
[292] | 4027 | set(handles.num_MinA,'String',num2str(MinA,5));
|
---|
| 4028 | set(handles.num_MaxA,'String',num2str(MaxA,5));
|
---|
[227] | 4029 | end
|
---|
[199] | 4030 | update_plot(handles);
|
---|
| 4031 |
|
---|
| 4032 | %------------------------------------------------------------------------
|
---|
[292] | 4033 | function num_MaxA_Callback(hObject, eventdata, handles)
|
---|
[199] | 4034 | %------------------------------------------------------------------------
|
---|
[292] | 4035 | set(handles.CheckFixScalar,'Value',1) %suppress auto mode
|
---|
| 4036 | set(handles.CheckFixScalar,'BackgroundColor',[1 1 0])
|
---|
| 4037 | MinA=str2double(get(handles.num_MinA,'String'));
|
---|
| 4038 | MaxA=str2double(get(handles.num_MaxA,'String'));
|
---|
[227] | 4039 | if MinA>MaxA% switch minA and maxA in case of error
|
---|
| 4040 | MinA_old=MinA;
|
---|
| 4041 | MinA=MaxA;
|
---|
| 4042 | MaxA=MinA_old;
|
---|
[292] | 4043 | set(handles.num_MinA,'String',num2str(MinA,5));
|
---|
| 4044 | set(handles.num_MaxA,'String',num2str(MaxA,5));
|
---|
[227] | 4045 | end
|
---|
[199] | 4046 | update_plot(handles);
|
---|
| 4047 |
|
---|
| 4048 | %------------------------------------------------------------------------
|
---|
[292] | 4049 | function CheckFixScalar_Callback(hObject, eventdata, handles)
|
---|
[199] | 4050 | %------------------------------------------------------------------------
|
---|
[292] | 4051 | test=get(handles.CheckFixScalar,'Value');
|
---|
[199] | 4052 | if test
|
---|
[292] | 4053 | set(handles.CheckFixScalar,'BackgroundColor',[1 1 0])
|
---|
[199] | 4054 | else
|
---|
[292] | 4055 | set(handles.CheckFixScalar,'BackgroundColor',[0.7 0.7 0.7])
|
---|
[199] | 4056 | update_plot(handles);
|
---|
| 4057 | end
|
---|
| 4058 |
|
---|
| 4059 | %-------------------------------------------------------------------
|
---|
[292] | 4060 | function CheckBW_Callback(hObject, eventdata, handles)
|
---|
[199] | 4061 | %-------------------------------------------------------------------
|
---|
| 4062 | update_plot(handles);
|
---|
| 4063 |
|
---|
| 4064 | %-------------------------------------------------------------------
|
---|
[292] | 4065 | function ListContour_Callback(hObject, eventdata, handles)
|
---|
[199] | 4066 | %-------------------------------------------------------------------
|
---|
[292] | 4067 | val=get(handles.ListContour,'Value');
|
---|
[199] | 4068 | if val==2
|
---|
| 4069 | set(handles.interval_txt,'Visible','on')
|
---|
[292] | 4070 | set(handles.num_IncrA,'Visible','on')
|
---|
[199] | 4071 | else
|
---|
| 4072 | set(handles.interval_txt,'Visible','off')
|
---|
[292] | 4073 | set(handles.num_IncrA,'Visible','off')
|
---|
[199] | 4074 | end
|
---|
| 4075 | update_plot(handles);
|
---|
| 4076 |
|
---|
| 4077 | %-------------------------------------------------------------------
|
---|
[292] | 4078 | function num_IncrA_Callback(hObject, eventdata, handles)
|
---|
[199] | 4079 | %-------------------------------------------------------------------
|
---|
| 4080 | update_plot(handles);
|
---|
| 4081 |
|
---|
| 4082 | %-------------------------------------------------------------------
|
---|
[292] | 4083 | function CheckHideWarning_Callback(hObject, eventdata, handles)
|
---|
[199] | 4084 | %-------------------------------------------------------------------
|
---|
| 4085 | update_plot(handles);
|
---|
| 4086 |
|
---|
| 4087 | %-------------------------------------------------------------------
|
---|
[292] | 4088 | function CheckHideFalse_Callback(hObject, eventdata, handles)
|
---|
[199] | 4089 | %-------------------------------------------------------------------
|
---|
| 4090 | update_plot(handles);
|
---|
| 4091 |
|
---|
| 4092 | %-------------------------------------------------------------------
|
---|
[292] | 4093 | function num_VecScale_Callback(hObject, eventdata, handles)
|
---|
[199] | 4094 | %-------------------------------------------------------------------
|
---|
[292] | 4095 | set(handles.CheckFixVectors,'Value',1);
|
---|
| 4096 | set(handles.CheckFixVectors,'BackgroundColor',[1 1 0])
|
---|
[199] | 4097 | update_plot(handles);
|
---|
| 4098 |
|
---|
| 4099 | %-------------------------------------------------------------------
|
---|
[292] | 4100 | function CheckFixVectors_Callback(hObject, eventdata, handles)
|
---|
[199] | 4101 | %-------------------------------------------------------------------
|
---|
[292] | 4102 | test=get(handles.CheckFixVectors,'Value');
|
---|
[199] | 4103 | if test
|
---|
[292] | 4104 | set(handles.CheckFixVectors,'BackgroundColor',[1 1 0])
|
---|
[199] | 4105 | else
|
---|
| 4106 | update_plot(handles);
|
---|
[292] | 4107 | %set(handles.num_VecScale,'String',num2str(ScalOut.num_VecScale,3))
|
---|
| 4108 | set(handles.CheckFixVectors,'BackgroundColor',[0.7 0.7 0.7])
|
---|
[199] | 4109 | end
|
---|
| 4110 |
|
---|
| 4111 | %------------------------------------------------------------------------
|
---|
[292] | 4112 | % --- Executes on selection change in CheckDecimate4 (nb_vec/4).
|
---|
| 4113 | function CheckDecimate4_Callback(hObject, eventdata, handles)
|
---|
[199] | 4114 | %------------------------------------------------------------------------
|
---|
| 4115 | update_plot(handles);
|
---|
| 4116 |
|
---|
| 4117 | %------------------------------------------------------------------------
|
---|
[292] | 4118 | % --- Executes on selection change in ListColorCode menu
|
---|
| 4119 | function ListColorCode_Callback(hObject, eventdata, handles)
|
---|
[199] | 4120 | %------------------------------------------------------------------------
|
---|
| 4121 | set_vec_col_bar(handles)
|
---|
| 4122 | update_plot(handles);
|
---|
| 4123 |
|
---|
| 4124 | %------------------------------------------------------------------------
|
---|
[292] | 4125 | % --- Executes on button press in CheckFixVecColor.
|
---|
| 4126 | function CheckFixVecColor_Callback(hObject, eventdata, handles)
|
---|
[199] | 4127 | %------------------------------------------------------------------------
|
---|
[292] | 4128 | test=get(handles.CheckFixVecColor,'Value');
|
---|
[199] | 4129 | if test
|
---|
[292] | 4130 | set(handles.CheckFixVecColor,'BackgroundColor',[1 1 0])
|
---|
[199] | 4131 | else
|
---|
| 4132 | update_plot(handles);
|
---|
[292] | 4133 | %set(handles.num_VecScale,'String',num2str(ScalOut.num_VecScale,3))
|
---|
| 4134 | set(handles.CheckFixVecColor,'BackgroundColor',[0.7 0.7 0.7])
|
---|
[199] | 4135 | end
|
---|
| 4136 |
|
---|
| 4137 | %------------------------------------------------------------------------
|
---|
[292] | 4138 | % --- Executes on selection change in num_MaxVec.
|
---|
| 4139 | function num_MinVec_Callback(hObject, eventdata, handles)
|
---|
[199] | 4140 | %------------------------------------------------------------------------
|
---|
| 4141 | max_vec_Callback(hObject, eventdata, handles)
|
---|
| 4142 |
|
---|
| 4143 | %------------------------------------------------------------------------
|
---|
[292] | 4144 | % --- Executes on selection change in num_MaxVec.
|
---|
| 4145 | function num_MaxVec_Callback(hObject, eventdata, handles)
|
---|
[199] | 4146 | %------------------------------------------------------------------------
|
---|
[292] | 4147 | set(handles.CheckFixVecColor,'Value',1)
|
---|
[316] | 4148 | CheckFixVecColor_Callback(hObject, eventdata, handles)
|
---|
[292] | 4149 | min_val=str2num(get(handles.num_MinVec,'String'));
|
---|
| 4150 | max_val=str2num(get(handles.num_MaxVec,'String'));
|
---|
| 4151 | slider1=get(handles.Slider1,'Value');
|
---|
| 4152 | slider2=get(handles.Slider2,'Value');
|
---|
[199] | 4153 | colcode1=min_val+(max_val-min_val)*slider1;
|
---|
| 4154 | colcode2=min_val+(max_val-min_val)*slider2;
|
---|
[292] | 4155 | set(handles.num_ColCode1,'String',num2str(colcode1))
|
---|
| 4156 | set(handles.num_ColCode2,'String',num2str(colcode2))
|
---|
[199] | 4157 | update_plot(handles);
|
---|
| 4158 |
|
---|
| 4159 | %------------------------------------------------------------------------
|
---|
| 4160 | % --- update the display of color code for vectors
|
---|
| 4161 | function set_vec_col_bar(handles)
|
---|
| 4162 | %------------------------------------------------------------------------
|
---|
[292] | 4163 | %get the image of the color display button 'VecColBar' in pixels
|
---|
| 4164 | set(handles.VecColBar,'Unit','pixel');
|
---|
| 4165 | pos_vert=get(handles.VecColBar,'Position');
|
---|
| 4166 | set(handles.VecColBar,'Unit','Normalized');
|
---|
[199] | 4167 | width=ceil(pos_vert(3));
|
---|
| 4168 | height=ceil(pos_vert(4));
|
---|
| 4169 |
|
---|
| 4170 | %get slider indications
|
---|
[292] | 4171 | list=get(handles.ListColorCode,'String');
|
---|
| 4172 | ichoice=get(handles.ListColorCode,'Value');
|
---|
[315] | 4173 | colcode.ListColorCode=list{ichoice};
|
---|
| 4174 | colcode.MinVec=str2num(get(handles.num_MinVec,'String'));
|
---|
| 4175 | colcode.MaxVec=str2num(get(handles.num_MaxVec,'String'));
|
---|
| 4176 | test3color=strcmp(colcode.ListColorCode,'rgb') || strcmp(colcode.ListColorCode,'bgr');
|
---|
[199] | 4177 | if test3color
|
---|
[315] | 4178 | colcode.ColCode1=str2num(get(handles.num_ColCode1,'String'));
|
---|
| 4179 | colcode.ColCode2=str2num(get(handles.num_ColCode2,'String'));
|
---|
[199] | 4180 | end
|
---|
[315] | 4181 | % colcode.FixedCbounds=0;
|
---|
| 4182 | %colcode.CheckFixVecColor=1;
|
---|
| 4183 | vec_C=colcode.MinVec+(colcode.MaxVec-colcode.MinVec)*(0.5:width-0.5)/width;%sample of vec_C values from min to max
|
---|
[199] | 4184 | [colorlist,col_vec]=set_col_vec(colcode,vec_C);
|
---|
| 4185 | oneheight=ones(1,height);
|
---|
| 4186 | A1=colorlist(col_vec,1)*oneheight;
|
---|
| 4187 | A2=colorlist(col_vec,2)*oneheight;
|
---|
| 4188 | A3=colorlist(col_vec,3)*oneheight;
|
---|
| 4189 | A(:,:,1)=A1';
|
---|
| 4190 | A(:,:,2)=A2';
|
---|
| 4191 | A(:,:,3)=A3';
|
---|
[292] | 4192 | set(handles.VecColBar,'Cdata',A)
|
---|
[199] | 4193 |
|
---|
| 4194 | %-------------------------------------------------------------------
|
---|
| 4195 | function update_plot(handles)
|
---|
| 4196 | %-------------------------------------------------------------------
|
---|
| 4197 | UvData=get(handles.uvmat,'UserData');
|
---|
[295] | 4198 | AxeData=UvData.axes3;% retrieve the current plotted data
|
---|
[292] | 4199 | PlotParam=read_GUI(handles.uvmat);
|
---|
[295] | 4200 | [PP,PlotParamOut]= plot_field(AxeData,handles.axes3,PlotParam);
|
---|
[199] | 4201 | write_plot_param(handles,PlotParamOut); %update the auto plot parameters
|
---|
| 4202 |
|
---|
[315] | 4203 | % %-------------------------------------------------------------------
|
---|
| 4204 | % % --- Executes on button press in grid.
|
---|
| 4205 | % function grid_Callback(hObject, eventdata, handles)
|
---|
[199] | 4206 |
|
---|
| 4207 |
|
---|
| 4208 | %-------------------------------------------------------------------
|
---|
| 4209 | % --- Executes on selection change in edit_object.
|
---|
| 4210 | function edit_object_Callback(hObject, eventdata, handles)
|
---|
| 4211 | %-------------------------------------------------------------------
|
---|
| 4212 | UvData=get(handles.uvmat,'UserData');%read UvData properties stored on the uvmat interface
|
---|
| 4213 | test=get(handles.edit_object,'Value');
|
---|
| 4214 | if test
|
---|
| 4215 | set(handles.edit_object,'BackgroundColor',[1,1,0])
|
---|
| 4216 | %suppress the other options
|
---|
[292] | 4217 | set(handles.CheckZoom,'Value',0)
|
---|
[302] | 4218 | CheckZoom_Callback(hObject, eventdata, handles)
|
---|
[199] | 4219 | hgeometry_calib=findobj(allchild(0),'tag','geometry_calib');
|
---|
| 4220 | if ishandle(hgeometry_calib)
|
---|
| 4221 | hhgeometry_calib=guidata(hgeometry_calib);
|
---|
| 4222 | set(hhgeometry_calib.edit_append,'Value',0)% desactivate mouse action in geometry_calib
|
---|
| 4223 | set(hhgeometry_calib.edit_append,'BackgroundColor',[0.7 0.7 0.7])
|
---|
| 4224 | end
|
---|
| 4225 | else
|
---|
| 4226 | UvData.MouseAction='none';
|
---|
| 4227 | set(handles.edit_object,'BackgroundColor',[0.7,0.7,0.7])
|
---|
[302] | 4228 | % hset_object=findobj(allchild(0),'tag','set_object');% look for the set_object GUI
|
---|
| 4229 | % if ~isempty(hset_object)
|
---|
| 4230 | % delete(hset_object)% delete the current GUI set_object
|
---|
| 4231 | % end
|
---|
[199] | 4232 | end
|
---|
| 4233 | set(handles.uvmat,'UserData',UvData);
|
---|
| 4234 | hset_object=findobj(allchild(0),'Tag','set_object');
|
---|
| 4235 | if ~isempty(hset_object)
|
---|
| 4236 | hhset_object=guidata(hset_object);
|
---|
| 4237 | if test
|
---|
| 4238 | set(hhset_object.PLOT,'enable','on');
|
---|
| 4239 | else
|
---|
| 4240 | set(hhset_object.PLOT,'enable','off');
|
---|
| 4241 | end
|
---|
| 4242 | end
|
---|
| 4243 |
|
---|
| 4244 | %------------------------------------------------------------------------
|
---|
[302] | 4245 | % --- Executes on selection change in ListObject.
|
---|
| 4246 | function ListObject_Callback(hObject, eventdata, handles)
|
---|
[199] | 4247 | %------------------------------------------------------------------------
|
---|
| 4248 |
|
---|
[302] | 4249 | list_str=get(handles.ListObject,'String');
|
---|
| 4250 | IndexObj_old=get(handles.ListObject,'UserData');%retrieve previous selection
|
---|
[342] | 4251 | IndexObj=get(handles.ListObject,'Value');%present object selection
|
---|
| 4252 |
|
---|
| 4253 | %% we select two objects or more at once (using the Ctrl key), keep only the last two items: the first is projected on uvmat, the second on view_field
|
---|
[302] | 4254 | if length(IndexObj)>2
|
---|
| 4255 | IndexObj=[IndexObj(end-1) IndexObj(end)];%keeps only the last two selected items at most
|
---|
| 4256 | end
|
---|
[342] | 4257 |
|
---|
| 4258 | %% we select one object
|
---|
| 4259 | if length(IndexObj)==1%
|
---|
| 4260 | if length(IndexObj_old)>=2 && isequal(IndexObj_old(1),IndexObj) % we select the first previously selected object->
|
---|
| 4261 | IndexObj=[1 IndexObj_old(2)];% it desactivates this object and selects the first object for uvmat
|
---|
| 4262 | elseif length(IndexObj_old)>=2 && isequal(IndexObj_old(2),IndexObj) % we select the second previously selected object->
|
---|
| 4263 | IndexObj=IndexObj_old(1);% it desactivates this object and keeps only the first previously selected object (uvmat)
|
---|
| 4264 | else %
|
---|
| 4265 | IndexObj=[IndexObj_old(1) IndexObj];% activates a second object while keeping the first previously selected one
|
---|
[252] | 4266 | end
|
---|
[199] | 4267 | end
|
---|
[342] | 4268 | set(handles.ListObject,'Value',IndexObj); % marks the selected objects in the list
|
---|
| 4269 | set(handles.ListObject,'UserData',IndexObj)% keep the current object selection in memory for next time
|
---|
| 4270 |
|
---|
| 4271 | %% update the object representation
|
---|
| 4272 | set(handles.edit_object,'Value',0) % desactivate the edit object mode
|
---|
[302] | 4273 | edit_object_Callback(hObject, eventdata, handles)
|
---|
| 4274 | UvData=get(handles.uvmat,'UserData');%read UvData properties stored on the uvmat interface
|
---|
| 4275 | if numel(UvData.Object)<max(IndexObj);
|
---|
| 4276 | msgbox_uvmat('ERROR','invalid object list')
|
---|
| 4277 | return
|
---|
| 4278 | end
|
---|
[342] | 4279 | if numel(IndexObj)>=2
|
---|
| 4280 | UvData.Object=update_obj(UvData,IndexObj(1),IndexObj(2));%update the current object graphic representation
|
---|
| 4281 | set(handles.uvmat,'UserData',UvData)
|
---|
| 4282 | end
|
---|
[199] | 4283 |
|
---|
[342] | 4284 | %% project on the selected object and update the corresponding plot
|
---|
| 4285 | % hview_field=findobj(allchild(0),'tag','view_field');
|
---|
| 4286 | % ViewObjectAxes=[];%default
|
---|
[302] | 4287 | if ~isequal(IndexObj(1),IndexObj_old(1))
|
---|
[342] | 4288 | update_object(handles,IndexObj(1),handles.axes3,list_str{IndexObj(1)})%plot the projection in uvmat
|
---|
[302] | 4289 | end
|
---|
[342] | 4290 | hview_field=findobj(allchild(0),'tag','view_field');
|
---|
[302] | 4291 | if length(IndexObj)==2 && (length(IndexObj_old)==1 || ~isequal(IndexObj(2),IndexObj_old(2)))
|
---|
| 4292 | if isempty(hview_field)
|
---|
| 4293 | hview_field=view_field;
|
---|
| 4294 | end
|
---|
| 4295 | PlotHandles=guidata(hview_field);
|
---|
| 4296 | update_object(handles,IndexObj(2),PlotHandles.axes3,list_str{IndexObj(2)})%plot the projection in view_field
|
---|
[342] | 4297 | update_object_color(handles.axes3,PlotHandles.axes3,UvData.Object{IndexObj(2)}.DisplayHandle_uvmat)
|
---|
| 4298 | else
|
---|
| 4299 | if ~isempty(hview_field)
|
---|
| 4300 | delete(hview_field)
|
---|
| 4301 | end
|
---|
| 4302 | hset_object=findobj(allchild(0),'tag','set_object');
|
---|
| 4303 | if ~isempty(hset_object)
|
---|
| 4304 | delete(hset_object)
|
---|
| 4305 | end
|
---|
| 4306 | update_object_color(handles.axes3,handles.axes3,[])
|
---|
[302] | 4307 | end
|
---|
| 4308 |
|
---|
[342] | 4309 | %% update the color of the gfraphic object representation: the selected object in magenta, others in blue
|
---|
| 4310 | % update_object_color(handles.axes3,PlotHandles.axes3,UvData.Object{IndexObj(2)}.DisplayHandle_uvmat)
|
---|
| 4311 |
|
---|
[199] | 4312 | %------------------------------------------------------------------------
|
---|
[302] | 4313 | function update_object(handles,IndexObj,ViewObjectAxes,ObjectName)
|
---|
[199] | 4314 | %------------------------------------------------------------------------
|
---|
| 4315 | UvData=get(handles.uvmat,'UserData');%read UvData properties stored on the uvmat interface
|
---|
| 4316 | ObjectData=UvData.Object{IndexObj};
|
---|
| 4317 | ObjectData.Name=ObjectName;
|
---|
| 4318 | if isequal(get(handles.edit_object,'Value'),1)
|
---|
| 4319 | ObjectData.enable_plot=1; % desable the PLOT option in the set_object GUI (editing mode
|
---|
| 4320 | end
|
---|
| 4321 | ZBounds=0; % default
|
---|
| 4322 | if isfield(UvData.Field,'ZMin') && isfield(UvData.Field,'ZMax')
|
---|
| 4323 | ZBounds(1)=UvData.Field.ZMin; %minimum for the Z slider
|
---|
| 4324 | ZBounds(2)=UvData.Field.ZMax;%maximum for the Z slider
|
---|
| 4325 | end
|
---|
| 4326 | hset_object=findobj(allchild(0),'tag','set_object');
|
---|
| 4327 | if ~isempty(hset_object)
|
---|
| 4328 | delete(hset_object)% delete existing version of set_object
|
---|
[342] | 4329 | end
|
---|
[302] | 4330 | hset_object=set_object(ObjectData,[],ZBounds);
|
---|
[342] | 4331 | % end
|
---|
[199] | 4332 | edit_test=get(handles.edit_object,'Value');
|
---|
| 4333 | if edit_test
|
---|
| 4334 | ObjectData.enable_plot=1;
|
---|
| 4335 | else
|
---|
[210] | 4336 | if isfield(ObjectData,'enable_plot')
|
---|
[199] | 4337 | ObjectData=rmfield(ObjectData,'enable_plot');
|
---|
| 4338 | end
|
---|
| 4339 | end
|
---|
| 4340 |
|
---|
[302] | 4341 | uistack(ViewObjectAxes,'top')% display the plotting axes at the top
|
---|
| 4342 | ProjData= proj_field(UvData.Field,ObjectData);%project the current interface field on ObjectData
|
---|
| 4343 | plot_field(ProjData,ViewObjectAxes,read_GUI(get(ViewObjectAxes,'Parent')));%read plotting parameters on the uvmat interfacPlotHandles);
|
---|
| 4344 | %
|
---|
| 4345 | % UvData.Object=update_obj(UvData,IndexObj(1),IndexObj(2));
|
---|
| 4346 | % set(handles.uvmat,'UserData',UvData)
|
---|
[252] | 4347 |
|
---|
[302] | 4348 | %------------------------------------------------------------------------
|
---|
| 4349 | %--- update the representation of objects
|
---|
| 4350 | function update_object_color(axes_uvmat,axes_view_field,DisplayHandle)
|
---|
| 4351 | %------------------------------------------------------------------------
|
---|
| 4352 | hother=[findobj(axes_uvmat,'Tag','proj_object') ;findobj(axes_view_field,'Tag','proj_object')] ;%find all the proj objects
|
---|
| 4353 | hother=[hother ;findobj(axes_uvmat,'Tag','DeformPoint'); findobj(axes_view_field,'Tag','DeformPoint')];
|
---|
[199] | 4354 | for iobj=1:length(hother)
|
---|
| 4355 | if isequal(get(hother(iobj),'Type'),'rectangle')||isequal(get(hother(iobj),'Type'),'patch')
|
---|
| 4356 | set(hother(iobj),'EdgeColor','b')
|
---|
| 4357 | if isequal(get(hother(iobj),'FaceColor'),'m')
|
---|
| 4358 | set(hother(iobj),'FaceColor','b')
|
---|
| 4359 | end
|
---|
| 4360 | elseif isequal(get(hother(iobj),'Type'),'image')
|
---|
| 4361 | Acolor=get(hother(iobj),'CData');
|
---|
| 4362 | Acolor(:,:,1)=zeros(size(Acolor,1),size(Acolor,2));
|
---|
| 4363 | set(hother(iobj),'CData',Acolor);
|
---|
| 4364 | else
|
---|
| 4365 | set(hother(iobj),'Color','b')
|
---|
| 4366 | end
|
---|
| 4367 | set(hother(iobj),'Selected','off')
|
---|
| 4368 | end
|
---|
[342] | 4369 | if ~isempty(DisplayHandle)
|
---|
[302] | 4370 | linetype=get(DisplayHandle,'Type');
|
---|
| 4371 | if isequal(linetype,'line')
|
---|
| 4372 | set(DisplayHandle,'Color','m'); %set the selected object to magenta color
|
---|
| 4373 | elseif isequal(linetype,'rectangle')
|
---|
| 4374 | set(DisplayHandle,'EdgeColor','m'); %set the selected object to magenta color
|
---|
| 4375 | elseif isequal(linetype,'patch')
|
---|
| 4376 | set(DisplayHandle,'FaceColor','m'); %set the selected object to magenta color
|
---|
| 4377 | end
|
---|
| 4378 | SubObjectData=get(DisplayHandle,'UserData');
|
---|
| 4379 | if isfield(SubObjectData,'SubObject') & ishandle(SubObjectData.SubObject)
|
---|
| 4380 | for iobj=1:length(SubObjectData.SubObject)
|
---|
| 4381 | hsub=SubObjectData.SubObject(iobj);
|
---|
| 4382 | if isequal(get(hsub,'Type'),'rectangle')
|
---|
| 4383 | set(hsub,'EdgeColor','m'); %set the selected object to magenta color
|
---|
| 4384 | elseif isequal(get(hsub,'Type'),'image')
|
---|
| 4385 | Acolor=get(hsub,'CData');
|
---|
| 4386 | Acolor(:,:,1)=Acolor(:,:,3);
|
---|
| 4387 | set(hsub,'CData',Acolor);
|
---|
| 4388 | else
|
---|
| 4389 | set(hsub,'Color','m')
|
---|
[199] | 4390 | end
|
---|
| 4391 | end
|
---|
| 4392 | end
|
---|
[302] | 4393 | if isfield(SubObjectData,'DeformPoint') & ishandle(SubObjectData.DeformPoint)
|
---|
| 4394 | set(SubObjectData.DeformPoint,'Color','m')
|
---|
| 4395 | end
|
---|
[342] | 4396 | end
|
---|
[199] | 4397 |
|
---|
[302] | 4398 | % SubObjectData=get(ObjectData.DisplayHandle_uvmat,'UserData');
|
---|
| 4399 |
|
---|
| 4400 |
|
---|
| 4401 |
|
---|
| 4402 |
|
---|
| 4403 |
|
---|
| 4404 |
|
---|
| 4405 |
|
---|
[199] | 4406 | %------------------------------------------------------
|
---|
| 4407 | % --- Executes on button press in Menu/Export/field in workspace.
|
---|
| 4408 | %------------------------------------------------------
|
---|
| 4409 | function MenuExportField_Callback(hObject, eventdata, handles)
|
---|
| 4410 | global Data_uvmat
|
---|
| 4411 | Data_uvmat=get(handles.uvmat,'UserData');
|
---|
| 4412 | evalin('base','global Data_uvmat')%make CurData global in the workspace
|
---|
| 4413 | display('current field :')
|
---|
| 4414 | evalin('base','Data_uvmat') %display CurData in the workspace
|
---|
| 4415 | commandwindow; %brings the Matlab command window to the front
|
---|
| 4416 |
|
---|
| 4417 | %------------------------------------------------------
|
---|
| 4418 | % --- Executes on button press in Menu/Export/extract figure.
|
---|
| 4419 | %------------------------------------------------------
|
---|
| 4420 | function MenuExport_plot_Callback(hObject, eventdata, handles)
|
---|
| 4421 | huvmat=get(handles.MenuExport_plot,'parent');
|
---|
| 4422 | UvData=get(huvmat,'UserData');
|
---|
| 4423 | hfig=figure;
|
---|
| 4424 | newaxes=copyobj(handles.axes3,hfig);
|
---|
| 4425 | map=colormap(handles.axes3);
|
---|
| 4426 | colormap(map);%transmit the current colormap to the zoom fig
|
---|
| 4427 | colorbar
|
---|
| 4428 |
|
---|
| 4429 |
|
---|
| 4430 | % --------------------------------------------------------------------
|
---|
| 4431 | function Insert_Callback(hObject, eventdata, handles)
|
---|
| 4432 |
|
---|
| 4433 |
|
---|
| 4434 | % --------------------------------------------------------------------
|
---|
| 4435 | function MenuHelp_Callback(hObject, eventdata, handles)
|
---|
| 4436 | % --------------------------------------------------------------------
|
---|
| 4437 | path_to_uvmat=which ('uvmat');% check the path of uvmat
|
---|
| 4438 | pathelp=fileparts(path_to_uvmat);
|
---|
| 4439 | helpfile=fullfile(pathelp,'uvmat_doc','uvmat_doc.html');
|
---|
| 4440 | 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')
|
---|
| 4441 | else
|
---|
| 4442 | addpath (fullfile(pathelp,'uvmat_doc'))
|
---|
| 4443 | web(helpfile);
|
---|
| 4444 | end
|
---|
| 4445 |
|
---|
| 4446 | %------------------------------------------------------------------------
|
---|
| 4447 | % --------------------------------------------------------------------
|
---|
| 4448 | function MenuExportMovie_Callback(hObject, eventdata, handles)
|
---|
| 4449 | % --------------------------------------------------------------------
|
---|
| 4450 | set(handles.MenuExportMovie,'BusyAction','queue')% activate the button
|
---|
| 4451 | huvmat=get(handles.run0,'parent');
|
---|
| 4452 | UvData=get(huvmat,'UserData');
|
---|
| 4453 | [xx,xx,FileBase]=read_file_boxes(handles);
|
---|
| 4454 | %read the current input file name
|
---|
| 4455 | 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)'};
|
---|
| 4456 | dlg_title = 'select properties of the output avi movie';
|
---|
| 4457 | num_lines= 1;
|
---|
| 4458 | % nbfield_cell=get(handles.last_i,'String');
|
---|
| 4459 | def = {[FileBase '_out.avi'];'10';'1';'[0.03 0.05 0.95 0.92]';'10'};
|
---|
| 4460 | answer = inputdlg(prompt,dlg_title,num_lines,def,'on');
|
---|
| 4461 | aviname=answer{1};
|
---|
| 4462 | fps=str2double(answer{2});
|
---|
| 4463 | % check for existing file with output name aviname
|
---|
| 4464 | if exist(aviname,'file')
|
---|
| 4465 | backup=aviname;
|
---|
| 4466 | testexist=2;
|
---|
| 4467 | while testexist==2
|
---|
| 4468 | backup=[backup '~'];
|
---|
| 4469 | testexist=exist(backup,'file');
|
---|
| 4470 | end
|
---|
| 4471 | [success,message]=copyfile(aviname,backup);%make backup of the existing file
|
---|
| 4472 | if isequal(success,1)
|
---|
| 4473 | delete(aviname)%delete existing file
|
---|
| 4474 | else
|
---|
| 4475 | msgbox_uvmat('ERROR',message)
|
---|
| 4476 | return
|
---|
| 4477 | end
|
---|
| 4478 | end
|
---|
| 4479 | %create avi open
|
---|
| 4480 | aviobj=avifile(aviname,'Compression','None','fps',fps);
|
---|
| 4481 |
|
---|
| 4482 | %display first view for tests
|
---|
| 4483 | newfig=figure;
|
---|
| 4484 | newaxes=copyobj(handles.axes3,newfig);%new plotting axes in the new figure
|
---|
| 4485 | set(newaxes,'Tag','movieaxes')
|
---|
| 4486 | nbpix=[512 384]*str2double(answer{3});
|
---|
| 4487 | set(gcf,'Position',[1 1 nbpix])% resolution XVGA
|
---|
| 4488 | set(newaxes,'Position',eval(answer{4}));
|
---|
| 4489 | map=colormap(handles.axes3);
|
---|
| 4490 | colormap(map);%transmit the current colormap to the zoom fig
|
---|
| 4491 | msgbox_uvmat('INPUT_Y-N',{['adjust figure ' num2str(newfig) ' with its matlab edit menu '] ;...
|
---|
| 4492 | ['then press OK to get the avi movie as a copy of figure ' num2str(newfig) ' display']});
|
---|
[215] | 4493 | UvData.plotaxes=newaxes;% the axis in the new figure becomes the current main plotting axes
|
---|
[199] | 4494 | set(huvmat,'UserData',UvData);
|
---|
| 4495 | increment=str2double(get(handles.increment_scan,'String')); %get the field increment d
|
---|
| 4496 | if isnan(increment)
|
---|
| 4497 | set(handles.increment_scan,'String','1')%default value
|
---|
| 4498 | increment=1;
|
---|
| 4499 | end
|
---|
| 4500 | set(handles.STOP,'Visible','on')
|
---|
| 4501 | set(handles.speed,'Visible','on')
|
---|
| 4502 | set(handles.speed_txt,'Visible','on')
|
---|
| 4503 | set(handles.Movie,'BusyAction','queue')
|
---|
| 4504 |
|
---|
| 4505 | %imin=str2double(get(handles.i1,'String'));
|
---|
| 4506 | imax=str2double(answer{5});
|
---|
| 4507 | % if isfield(UvData,'Time')
|
---|
| 4508 | htitle=get(newaxes,'Title');
|
---|
| 4509 | xlim=get(newaxes,'XLim');
|
---|
| 4510 | ylim=get(newaxes,'YLim');
|
---|
| 4511 | set(htitle,'Position',[xlim(2)+0.07*(xlim(2)-xlim(1)) ylim(2)-0.05*(ylim(2)-ylim(1)) 0])
|
---|
| 4512 | time_str=get(handles.abs_time,'String');
|
---|
| 4513 | set(htitle,'String',['t=' time_str])
|
---|
| 4514 | set(handles.speed,'Value',1)
|
---|
| 4515 | for i=1:imax
|
---|
| 4516 | if get(handles.speed,'Value')~=0 && isequal(get(handles.MenuExportMovie,'BusyAction'),'queue') % enable STOP command
|
---|
| 4517 | runpm(hObject,eventdata,handles,increment)% run plus
|
---|
| 4518 | drawnow
|
---|
| 4519 | time_str=get(handles.abs_time,'String');
|
---|
| 4520 | if ishandle(htitle)
|
---|
| 4521 | set(htitle,'String',['t=' time_str])
|
---|
| 4522 | end
|
---|
| 4523 | mov=getframe(newfig);
|
---|
| 4524 | aviobj=addframe(aviobj,mov);
|
---|
| 4525 | end
|
---|
| 4526 | end
|
---|
[215] | 4527 | aviobj=close(aviobj);
|
---|
| 4528 | UvData=rmfield(UvData,'plotaxes');
|
---|
| 4529 | %UvData.Object{1}.plotaxes=handles.axes3;
|
---|
[199] | 4530 | set(huvmat,'UserData',UvData);
|
---|
| 4531 | msgbox_uvmat('CONFIRMATION',{['movie ' aviname ' created '];['with ' num2str(imax) ' frames']})
|
---|
| 4532 |
|
---|
| 4533 | %------------------------------------------------------------------------
|
---|
| 4534 | function MenuCalib_Callback(hObject, eventdata, handles)
|
---|
| 4535 | %------------------------------------------------------------------------
|
---|
| 4536 |
|
---|
| 4537 | UvData=get(handles.uvmat,'UserData');%read UvData properties stored on the uvmat interface
|
---|
| 4538 |
|
---|
| 4539 | %suppress competing options
|
---|
[292] | 4540 | set(handles.CheckZoom,'Value',0)
|
---|
| 4541 | set(handles.CheckZoom,'BackgroundColor',[0.7 0.7 0.7])
|
---|
[302] | 4542 | set(handles.ListObject,'Value',1)
|
---|
[199] | 4543 | % initiate display of GUI geometry_calib
|
---|
| 4544 | data=[]; %default
|
---|
| 4545 | if isfield(UvData,'CoordType')
|
---|
| 4546 | data.CoordType=UvData.CoordType;
|
---|
| 4547 | end
|
---|
| 4548 | pos=get(handles.uvmat,'Position');
|
---|
| 4549 | pos(1)=pos(1)+pos(3)-0.311+0.04; %0.311= width of the geometry_calib interface (units relative to the srcreen)
|
---|
| 4550 | pos(2)=pos(2)-0.02;
|
---|
| 4551 | [FileName,RootPath,FileBase,FileIndices,FileExt,SubDir]=read_file_boxes(handles);
|
---|
| 4552 | set(handles.view_xml,'Backgroundcolor',[1 1 0])%indicate the reading of the current xml file by geometry_calib
|
---|
| 4553 | if isfield(UvData.OpenParam,'CalOrigin')
|
---|
| 4554 | pos_uvmat=get(handles.uvmat,'Position');
|
---|
| 4555 | pos_cal(1)=pos_uvmat(1)+UvData.OpenParam.CalOrigin(1)*pos_uvmat(3);
|
---|
| 4556 | pos_cal(2)=pos_uvmat(2)+UvData.OpenParam.CalOrigin(2)*pos_uvmat(4);
|
---|
| 4557 | pos_cal(3:4)=UvData.OpenParam.CalSize .* pos_uvmat(3:4);
|
---|
| 4558 | end
|
---|
| 4559 | geometry_calib(FileName,pos_cal);% call the geometry_calib interface
|
---|
| 4560 | set(handles.view_xml,'Backgroundcolor',[1 1 1])%indicate the end of reading of the current xml file by geometry_calib
|
---|
| 4561 | set(handles.MenuCalib,'checked','on')% indicate that MenuCalib is activated, test used by mouse action
|
---|
| 4562 |
|
---|
| 4563 | %------------------------------------------------------------------------
|
---|
| 4564 | function MenuMask_Callback(hObject, eventdata, handles)
|
---|
| 4565 | %------------------------------------------------------------------------
|
---|
| 4566 | UvData=get(handles.uvmat,'UserData');%read UvData properties stored on the uvmat interface
|
---|
| 4567 | ListObj=UvData.Object;
|
---|
| 4568 | select=zeros(1,numel(ListObj));
|
---|
| 4569 | for iobj=1:numel(ListObj);
|
---|
| 4570 | if strcmp(ListObj{iobj}.ProjMode,'mask_inside')||strcmp(ListObj{iobj}.ProjMode,'mask_outside')
|
---|
| 4571 | select(iobj)=1;
|
---|
| 4572 | end
|
---|
| 4573 | end
|
---|
| 4574 | val=find(select);
|
---|
| 4575 | if isempty(val)
|
---|
| 4576 | msgbox_uvmat('ERROR','polygons must be first created by Projection object/mask polygon in the menu bar');
|
---|
| 4577 | return
|
---|
| 4578 | else
|
---|
[302] | 4579 | set(handles.ListObject,'Max',2);%allow multiple selection
|
---|
| 4580 | set(handles.ListObject,'Value',val);
|
---|
[199] | 4581 | flag=1;
|
---|
| 4582 | npx=size(UvData.Field.A,2);
|
---|
| 4583 | npy=size(UvData.Field.A,1);
|
---|
| 4584 | xi=0.5:npx-0.5;
|
---|
| 4585 | yi=0.5:npy-0.5;
|
---|
| 4586 | [Xi,Yi]=meshgrid(xi,yi);
|
---|
| 4587 | if isfield(UvData,'Object')
|
---|
| 4588 | for iobj=1:length(UvData.Object)
|
---|
| 4589 | ObjectData=UvData.Object{iobj};
|
---|
| 4590 | if isfield(ObjectData,'ProjMode') &&(isequal(ObjectData.ProjMode,'mask_inside')||isequal(ObjectData.ProjMode,'mask_outside'));
|
---|
| 4591 | flagobj=1;
|
---|
| 4592 | testphys=0; %coordinates in pixels by default
|
---|
| 4593 | if isfield(ObjectData,'CoordUnit') && ~isequal(ObjectData.CoordUnit,'pixel')
|
---|
| 4594 | if isfield(UvData,'XmlData')&& isfield(UvData.XmlData,'GeometryCalib')
|
---|
| 4595 | Calib=UvData.XmlData.GeometryCalib;
|
---|
| 4596 | testphys=1;
|
---|
| 4597 | end
|
---|
| 4598 | end
|
---|
[295] | 4599 | if isfield(ObjectData,'Coord')&& isfield(ObjectData,'Style')
|
---|
[199] | 4600 | if isequal(ObjectData.Style,'polygon')
|
---|
| 4601 | X=ObjectData.Coord(:,1);
|
---|
| 4602 | Y=ObjectData.Coord(:,2);
|
---|
| 4603 | if testphys
|
---|
| 4604 | [X,Y]=px_XYZ(Calib,X,Y,0);% to generalise with 3D cases
|
---|
| 4605 | end
|
---|
| 4606 | flagobj=~inpolygon(Xi,Yi,X',Y');%=0 inside the polygon, 1 outside
|
---|
| 4607 | elseif isequal(ObjectData.Style,'ellipse')
|
---|
| 4608 | if testphys
|
---|
| 4609 | %[X,Y]=px_XYZ(Calib,X,Y,0);% TODO:create a polygon boundary and transform to phys
|
---|
| 4610 | end
|
---|
| 4611 | RangeX=max(ObjectData.RangeX);
|
---|
| 4612 | RangeY=max(ObjectData.RangeY);
|
---|
| 4613 | X2Max=RangeX*RangeX;
|
---|
| 4614 | Y2Max=RangeY*RangeY;
|
---|
| 4615 | distX=(Xi-ObjectData.Coord(1,1));
|
---|
| 4616 | distY=(Yi-ObjectData.Coord(1,2));
|
---|
| 4617 | flagobj=(distX.*distX/X2Max+distY.*distY/Y2Max)>1;
|
---|
| 4618 | elseif isequal(ObjectData.Style,'rectangle')
|
---|
| 4619 | if testphys
|
---|
| 4620 | %[X,Y]=px_XYZ(Calib,X,Y,0);% TODO:create a polygon boundary and transform to phys
|
---|
| 4621 | end
|
---|
| 4622 | distX=abs(Xi-ObjectData.Coord(1,1));
|
---|
| 4623 | distY=abs(Yi-ObjectData.Coord(1,2));
|
---|
| 4624 | flagobj=distX>max(ObjectData.RangeX) | distY>max(ObjectData.RangeY);
|
---|
| 4625 | end
|
---|
| 4626 | if isequal(ObjectData.ProjMode,'mask_outside')
|
---|
| 4627 | flagobj=~flagobj;
|
---|
| 4628 | end
|
---|
| 4629 | flag=flag & flagobj;
|
---|
| 4630 | end
|
---|
| 4631 | end
|
---|
| 4632 | end
|
---|
[231] | 4633 | end
|
---|
[199] | 4634 | %mask name
|
---|
| 4635 | RootPath=get(handles.RootPath,'String');
|
---|
| 4636 | RootFile=get(handles.RootFile,'String');
|
---|
| 4637 | if ~isempty(RootFile)&&(isequal(RootFile(1),'/')|| isequal(RootFile(1),'\'))
|
---|
| 4638 | RootFile(1)=[];
|
---|
| 4639 | end
|
---|
| 4640 | filebase=fullfile(RootPath,RootFile);
|
---|
| 4641 | list=get(handles.masklevel,'String');
|
---|
| 4642 | masknumber=num2str(length(list));
|
---|
| 4643 | maskindex=get(handles.masklevel,'Value');
|
---|
| 4644 | mask_name=name_generator([filebase '_' masknumber 'mask'],maskindex,1,'.png','_i');
|
---|
| 4645 | imflag=uint8(255*(0.392+0.608*flag));% =100 for flag=0 (vectors not computed when 20<imflag<200)
|
---|
| 4646 | imflag=flipdim(imflag,1);
|
---|
| 4647 |
|
---|
| 4648 | %display the mask
|
---|
[231] | 4649 | hfigmask=figure;
|
---|
| 4650 | set(hfigmask,'Name','mask image')
|
---|
[199] | 4651 | vec=linspace(0,1,256);%define a linear greyscale colormap
|
---|
| 4652 | map=[vec' vec' vec'];
|
---|
| 4653 | colormap(map)
|
---|
| 4654 | image(imflag);
|
---|
| 4655 | answer=msgbox_uvmat('INPUT_TXT','mask file name:', mask_name);
|
---|
| 4656 | if ~strcmp(answer,'Cancel')
|
---|
| 4657 | mask_dir=fileparts(answer);
|
---|
| 4658 | if ~exist(mask_dir,'dir')
|
---|
| 4659 | msgbox_uvmat('ERROR',['directory ' mask_dir ' does not exist'])
|
---|
| 4660 | return
|
---|
| 4661 | end
|
---|
| 4662 | imwrite(imflag,answer,'BitDepth',8);
|
---|
| 4663 | end
|
---|
[302] | 4664 | set(handles.ListObject,'Value',1)
|
---|
| 4665 | set(handles.ListObject,'Max',1)
|
---|
[199] | 4666 | end
|
---|
| 4667 |
|
---|
| 4668 | %------------------------------------------------------------------------
|
---|
| 4669 | %-- open the GUI set_grid.fig to create grid
|
---|
| 4670 | function MenuGrid_Callback(hObject, eventdata, handles)
|
---|
| 4671 | %------------------------------------------------------------------------
|
---|
| 4672 | %suppress the other options if grid is chosen
|
---|
| 4673 | set(handles.edit_vect,'Value',0)
|
---|
| 4674 | edit_vect_Callback(hObject, eventdata, handles)
|
---|
| 4675 | set(handles.edit_object,'BackgroundColor',[0.7 0.7 0.7])
|
---|
[302] | 4676 | set(handles.ListObject,'Value',1)
|
---|
[199] | 4677 |
|
---|
| 4678 | %prepare display of the set_grid GUI
|
---|
| 4679 | FileName=read_file_boxes(handles);
|
---|
| 4680 | CoordList=get(handles.transform_fct,'String');
|
---|
| 4681 | val=get(handles.transform_fct,'Value');
|
---|
| 4682 | set_grid(FileName,CoordList{val});% call the set_object interface
|
---|
| 4683 |
|
---|
| 4684 | %------------------------------------------------------------------------
|
---|
| 4685 | % open the GUI 'series'
|
---|
| 4686 | function MenuSeries_Callback(hObject, eventdata, handles)
|
---|
| 4687 | %------------------------------------------------------------------------
|
---|
| 4688 | series; %first display of the GUI to fill waiting time
|
---|
| 4689 | [param.FileName]=read_file_boxes(handles);
|
---|
| 4690 | if isequal(get(handles.SubField,'Value'),1)
|
---|
| 4691 | FileName_1=read_file_boxes_1(handles);%
|
---|
| 4692 | if ~isequal(FileName_1,param.FileName)
|
---|
| 4693 | param.FileName_1=FileName_1;
|
---|
| 4694 | end
|
---|
| 4695 | end
|
---|
[323] | 4696 | param.NomType=get(handles.NomType,'String');
|
---|
| 4697 | % param.NomType=get(handles.FileIndex,'UserData');
|
---|
| 4698 | param.NomType_1=get(handles.NomType_1,'String');
|
---|
| 4699 | % param.NomType_1=get(handles.FileIndex_1,'UserData');
|
---|
[199] | 4700 | param.comp_input=get(handles.fix_pair,'Value');
|
---|
| 4701 | huvmat=get(handles.MenuSeries,'parent');
|
---|
| 4702 | UvData=get(huvmat,'UserData');
|
---|
| 4703 | if isfield(UvData,'Time')
|
---|
| 4704 | param.Time=UvData.XmlData.Time;
|
---|
| 4705 | end
|
---|
| 4706 | if isequal(get(handles.scan_i,'Value'),1)
|
---|
| 4707 | param.incr_i=str2double(get(handles.increment_scan,'String'));
|
---|
| 4708 | elseif isequal(get(handles.scan_j,'Value'),1)
|
---|
| 4709 | param.incr_j=str2double(get(handles.increment_scan,'String'));
|
---|
| 4710 | end
|
---|
| 4711 | param.list_fields=get(handles.Fields,'String');% list menu fields
|
---|
| 4712 | param.list_fields(1)=[]; %suppress 'image' option
|
---|
| 4713 | param.index_fields=get(handles.Fields,'Value');% selected string index
|
---|
| 4714 | if param.index_fields>1
|
---|
| 4715 | param.index_fields=param.index_fields-1;
|
---|
| 4716 | end
|
---|
| 4717 | param.list_fields_1=get(handles.Fields_1,'String');% list menu fields
|
---|
| 4718 | param.list_fields_1(1)=[]; %suppress 'image' option
|
---|
| 4719 | param.index_fields_1=get(handles.Fields_1,'Value')-1;% selected string index
|
---|
| 4720 | if param.index_fields_1>1
|
---|
| 4721 | param.index_fields_1=param.index_fields_1-1;
|
---|
| 4722 | end
|
---|
| 4723 | param.menu_coord_str=get(handles.transform_fct,'String');
|
---|
| 4724 | param.menu_coord_val=get(handles.transform_fct,'Value');
|
---|
| 4725 | series(param); %run the series interface
|
---|
| 4726 |
|
---|
| 4727 | %------------------------------------------------------------------------
|
---|
| 4728 | % -- open the GUI civ.fig for civx (PIV)
|
---|
| 4729 | function MenuPIV_Callback(hObject, eventdata, handles)
|
---|
| 4730 | %------------------------------------------------------------------------
|
---|
[298] | 4731 | FileName=read_file_boxes(handles);
|
---|
| 4732 | %[FileName,RootPath,filebase,FileIndices,ext,SubDir]=read_file_boxes(handles)
|
---|
| 4733 | % num1=stra2num(get(handles.i1,'String'));
|
---|
| 4734 | % num2=stra2num(get(handles.i2,'String'));
|
---|
| 4735 | % num_a=stra2num(get(handles.j1,'String'));
|
---|
| 4736 | % num_b=stra2num(get(handles.j2,'String'));
|
---|
| 4737 | % NomType=get(handles.FileIndex,'UserData');
|
---|
| 4738 | % ind_opening=1; % default (images): will advice civ1 option by default in the civ interface
|
---|
| 4739 | % if isequal(ext,'.nc') || isequal(ext,'.cdf')% netcdf files
|
---|
| 4740 | % ind_opening=2;% propose 'fix' as the default option
|
---|
| 4741 | % % +read the current netcdf rootfile
|
---|
| 4742 | % Data=nc2struct(FileName,'ListGlobalAttribute','fix','patch','civ2','fix2');
|
---|
| 4743 | % if isfield(Data,'fix') && isequal(Data.fix,1)
|
---|
| 4744 | % ind_opening=3;
|
---|
| 4745 | % end
|
---|
| 4746 | % if isfield(Data,'patch') && isequal(Data.patch,1)
|
---|
| 4747 | % ind_opening=4;
|
---|
| 4748 | % end
|
---|
| 4749 | % if isfield(Data,'civ2') && isequal(Data.civ2,1)
|
---|
| 4750 | % ind_opening=5;
|
---|
| 4751 | % end
|
---|
| 4752 | % if isfield(Data,'fix2') && isequal(Data.fix2,1)
|
---|
| 4753 | % ind_opening=6;
|
---|
| 4754 | % end
|
---|
| 4755 | % end
|
---|
| 4756 | % param.RootName=filebase;
|
---|
| 4757 | % param.NomType=NomType;
|
---|
| 4758 | % param.num1=num1;
|
---|
| 4759 | % param.num2=num2;
|
---|
| 4760 | % param.num_a=num_a;
|
---|
| 4761 | % param.num_b=num_b;
|
---|
| 4762 | % param.SubDir=SubDir;
|
---|
| 4763 | % param.IndOpening=ind_opening;% A REVOIR +TRANSMETTRE IMADOC INFO
|
---|
| 4764 | % param.ImaExt=ext;
|
---|
| 4765 | civ(FileName);% interface de civ(not in the uvmat file)
|
---|
[199] | 4766 |
|
---|
| 4767 | %------------------------------------------------------------------------
|
---|
| 4768 | function MenuTools_Callback(hObject, eventdata, handles)
|
---|
| 4769 | %------------------------------------------------------------------------
|
---|
| 4770 |
|
---|
| 4771 | %------------------------------------------------------------------------
|
---|
| 4772 | function MenuEditObject_Callback(hObject, eventdata, handles)
|
---|
| 4773 | %------------------------------------------------------------------------
|
---|
| 4774 | set(handles.edit_object,'Value',1)
|
---|
| 4775 | edit_Callback(hObject, eventdata, handles)
|
---|
| 4776 |
|
---|
| 4777 | %------------------------------------------------------------------------
|
---|
| 4778 | function enable_transform(handles,state)
|
---|
| 4779 | %------------------------------------------------------------------------
|
---|
| 4780 | set(handles.transform_fct,'Visible',state)
|
---|
| 4781 | set(handles.TRANSFORM_txt,'Visible',state)
|
---|
| 4782 | set(handles.transform_fct,'Visible',state)
|
---|
| 4783 | set(handles.path_transform,'Visible',state)
|
---|
| 4784 | set(handles.pxcmx_txt,'Visible',state)
|
---|
| 4785 | set(handles.pxcmy_txt,'Visible',state)
|
---|
| 4786 | set(handles.pxcm,'Visible',state)
|
---|
| 4787 | set(handles.pycm,'Visible',state)
|
---|
| 4788 |
|
---|
| 4789 | %------------------------------------------------------------------------
|
---|
| 4790 | function MenuEditVectors_Callback(hObject, eventdata, handles)
|
---|
| 4791 | %------------------------------------------------------------------------
|
---|
| 4792 | set(handles.edit_vect,'Visible','on')
|
---|
| 4793 | set(handles.edit_vect,'Value',1)
|
---|
| 4794 | edit_vect_Callback(hObject, eventdata, handles)
|
---|
| 4795 |
|
---|
| 4796 | % -----------------------------------------------------------------------
|
---|
| 4797 | function Menupoints_Callback(hObject, eventdata, handles)
|
---|
| 4798 | %------------------------------------------------------------------------
|
---|
| 4799 | data.Style='points';
|
---|
| 4800 | data.ProjMode='projection';%default
|
---|
| 4801 | create_object(data,handles)
|
---|
| 4802 |
|
---|
| 4803 | % -----------------------------------------------------------------------
|
---|
| 4804 | function Menuline_Callback(hObject, eventdata, handles)
|
---|
| 4805 | %------------------------------------------------------------------------
|
---|
| 4806 | data.Style='line';
|
---|
| 4807 | data.ProjMode='projection';%default
|
---|
| 4808 | create_object(data,handles)
|
---|
| 4809 |
|
---|
| 4810 | %------------------------------------------------------------------------
|
---|
| 4811 | function Menupolyline_Callback(hObject, eventdata, handles)
|
---|
| 4812 | %------------------------------------------------------------------------
|
---|
| 4813 | data.Style='polyline';
|
---|
| 4814 | data.ProjMode='projection';%default
|
---|
| 4815 | create_object(data,handles)
|
---|
| 4816 |
|
---|
| 4817 | %------------------------------------------------------------------------
|
---|
| 4818 | function Menupolygon_Callback(hObject, eventdata, handles)
|
---|
| 4819 | %------------------------------------------------------------------------
|
---|
| 4820 | data.Style='polygon';
|
---|
| 4821 | data.ProjMode='inside';%default
|
---|
| 4822 | create_object(data,handles)
|
---|
| 4823 |
|
---|
| 4824 | %------------------------------------------------------------------------
|
---|
| 4825 | function Menurectangle_Callback(hObject, eventdata, handles)
|
---|
| 4826 | %------------------------------------------------------------------------
|
---|
| 4827 | data.Style='rectangle';
|
---|
| 4828 | data.ProjMode='inside';%default
|
---|
| 4829 | create_object(data,handles)
|
---|
| 4830 |
|
---|
| 4831 | %------------------------------------------------------------------------
|
---|
| 4832 | function Menuellipse_Callback(hObject, eventdata, handles)
|
---|
| 4833 | %------------------------------------------------------------------------
|
---|
| 4834 | data.Style='ellipse';
|
---|
| 4835 | data.ProjMode='inside';%default
|
---|
| 4836 | create_object(data,handles)
|
---|
| 4837 |
|
---|
| 4838 | %------------------------------------------------------------------------
|
---|
| 4839 | function MenuMaskObject_Callback(hObject, eventdata, handles)
|
---|
| 4840 | %------------------------------------------------------------------------
|
---|
| 4841 | data.Style='polygon';
|
---|
| 4842 | data.StyleMenu={'polygon'};
|
---|
| 4843 | data.ProjMode='mask_inside';%default
|
---|
| 4844 | data.ProjMenu={'mask_inside';'mask_outside'};
|
---|
| 4845 | create_object(data,handles)
|
---|
| 4846 |
|
---|
| 4847 | %------------------------------------------------------------------------
|
---|
| 4848 | function Menuplane_Callback(hObject, eventdata, handles)
|
---|
| 4849 | %------------------------------------------------------------------------
|
---|
| 4850 | data.Style='plane';
|
---|
| 4851 | data.ProjMode='projection';%default
|
---|
| 4852 |
|
---|
| 4853 | create_object(data,handles)
|
---|
| 4854 |
|
---|
| 4855 | %------------------------------------------------------------------------
|
---|
| 4856 | function Menuvolume_Callback(hObject, eventdata, handles)
|
---|
| 4857 | %------------------------------------------------------------------------
|
---|
| 4858 | data.Style='volume';
|
---|
| 4859 | data.ProjMode='interp';%default
|
---|
| 4860 | % set(handles.create,'Visible','on')
|
---|
| 4861 | % set(handles.create,'Value',1)
|
---|
| 4862 | % VOLUME_Callback(hObject,eventdata,handles)
|
---|
| 4863 | create_object(data,handles)
|
---|
| 4864 |
|
---|
| 4865 | %------------------------------------------------------------------------
|
---|
| 4866 | function MenuBrowseObject_Callback(hObject, eventdata, handles)
|
---|
| 4867 | %------------------------------------------------------------------------
|
---|
| 4868 | %get the object file
|
---|
| 4869 | [FileName, PathName, filterindex] = uigetfile( ...
|
---|
| 4870 | {'*.xml;*.mat', ' (*.xml,*.mat)';
|
---|
| 4871 | '*.xml', '.xml files '; ...
|
---|
| 4872 | '*.mat', '.mat matlab files '}, ...
|
---|
| 4873 | 'Pick an xml Object file',get(handles.RootPath,'String'));
|
---|
| 4874 | fileinput=[PathName FileName];%complete file name
|
---|
| 4875 | % testblank=findstr(fileinput,' ');%look for blanks
|
---|
| 4876 | % if ~isempty(testblank)
|
---|
| 4877 | % msgbox_uvmat('ERROR','forbidden input file name: contain blanks')
|
---|
| 4878 | % return
|
---|
| 4879 | % end
|
---|
| 4880 | sizf=size(fileinput);
|
---|
| 4881 | if (~ischar(fileinput)||~isequal(sizf(1),1)),return;end
|
---|
| 4882 |
|
---|
| 4883 | %read the file
|
---|
| 4884 | t=xmltree(fileinput);
|
---|
| 4885 | data=convert(t);
|
---|
| 4886 | data.enable_plot=1;
|
---|
| 4887 | [pp,data.Name]=fileparts(FileName);
|
---|
| 4888 | %PlotHandles=get_plot_handles(handles);%get the handles of the interface elements setting the plotting parameters
|
---|
| 4889 | hset_object=findobj(allchild(0),'tag','set_object');
|
---|
| 4890 | if ~isempty(hset_object)
|
---|
| 4891 | delete(hset_object)% delete existing version of set_object
|
---|
| 4892 | end
|
---|
| 4893 | % UvData=get(handles.uvmat,'UserData');
|
---|
| 4894 | set_object(data);% call the set_object interface
|
---|
| 4895 | % %position the set_object GUI with respect to uvmat
|
---|
| 4896 | % pos_uvmat=get(handles.uvmat,'Position');
|
---|
| 4897 | % if isfield(UvData,'SetObjectOrigin')
|
---|
| 4898 | % pos_set_object(1:2)=UvData.SetObjectOrigin + pos_uvmat(1:2);
|
---|
| 4899 | % pos_set_object(3:4)=UvData.SetObjectSize .* pos_uvmat(3:4);
|
---|
| 4900 | % set(hset_object,'Position',pos_set_object)
|
---|
| 4901 | % end
|
---|
| 4902 | set(handles.edit_object,'Value',0); %suppress the object edit mode
|
---|
| 4903 | set(handles.edit_object,'BackgroundColor',[0.7,0.7,0.7])
|
---|
| 4904 | set(handles.MenuObject,'checked','on')
|
---|
| 4905 | %UvData.MouseAction='create_object';
|
---|
| 4906 | % set(handles.uvmat,'UserData',UvData)
|
---|
| 4907 | set(handles.delete_object,'Visible','on')
|
---|
[307] | 4908 | % set(handles.uvmat_title,'Visible','on')
|
---|
| 4909 | % set(handles.view_field_title,'Visible','on')
|
---|
[199] | 4910 |
|
---|
| 4911 | %------------------------------------------------------------------------
|
---|
| 4912 | % --- generic function used for the creation of a projection object
|
---|
| 4913 | function create_object(data,handles)
|
---|
| 4914 | %------------------------------------------------------------------------
|
---|
| 4915 | hset_object=findobj(allchild(0),'tag','set_object');
|
---|
| 4916 | if ~isempty(hset_object)
|
---|
| 4917 | delete(hset_object)% delete existing version of set_object
|
---|
| 4918 | end
|
---|
| 4919 | hgeometry_calib=findobj(allchild(0),'tag','geometry_calib');
|
---|
| 4920 | if ishandle(hgeometry_calib)
|
---|
| 4921 | hhgeometry_calib=guidata(hgeometry_calib);
|
---|
| 4922 | set(hhgeometry_calib.edit_append,'Value',0)% desactivate mouse action in geometry_calib
|
---|
| 4923 | set(hhgeometry_calib.edit_append,'BackgroundColor',[0.7 0.7 0.7])
|
---|
| 4924 | end
|
---|
| 4925 | UvData=get(handles.uvmat,'UserData');
|
---|
| 4926 | set(handles.edit_object,'Value',0); %suppress the object edit mode
|
---|
| 4927 | set(handles.edit_object,'BackgroundColor',[0.7,0.7,0.7])
|
---|
| 4928 | data.enable_plot=1;
|
---|
| 4929 | transform_list=get(handles.transform_fct,'String');
|
---|
| 4930 | val=get(handles.transform_fct,'Value');
|
---|
| 4931 | %data.CoordType=transform_list{val};
|
---|
| 4932 | if isfield(UvData,'Field')
|
---|
| 4933 | Field=UvData.Field;
|
---|
| 4934 | if isfield(Field,'Mesh')&&~isempty(Field.Mesh)
|
---|
| 4935 | data.RangeX=Field.Mesh;
|
---|
| 4936 | data.RangeY=Field.Mesh;
|
---|
| 4937 | data.DX=Field.Mesh;
|
---|
| 4938 | data.DY=Field.Mesh;
|
---|
| 4939 | elseif isfield(Field,'AX')&& isfield(Field,'AY')&& isfield(Field,'A')%only image
|
---|
| 4940 | np=size(Field.A);
|
---|
| 4941 | meshx=(Field.AX(end)-Field.AX(1))/np(2);
|
---|
| 4942 | meshy=abs(Field.AY(end)-Field.AY(1))/np(1);
|
---|
| 4943 | data.RangeY=max(meshx,meshy);
|
---|
| 4944 | data.RangeX=max(meshx,meshy);
|
---|
| 4945 | data.DX=max(meshx,meshy);
|
---|
| 4946 | end
|
---|
| 4947 | if isfield(Field,'NbDim')
|
---|
| 4948 | data.NbDim=Field.NbDim;
|
---|
| 4949 | end
|
---|
| 4950 | if isfield(Field,'CoordUnit')
|
---|
| 4951 | data.CoordUnit=Field.CoordUnit;
|
---|
| 4952 | end
|
---|
| 4953 | end
|
---|
| 4954 | data.Coord=[0 0 0]; %default
|
---|
| 4955 | if isfield(data,'Style') && isequal(data.Style,'line')
|
---|
| 4956 | if isfield(data,'DX')
|
---|
| 4957 | data.Coord=[[0 0 0];[data.DX 0 0]]; %default
|
---|
| 4958 | else
|
---|
| 4959 | data.Coord=[[0 0 0];[1 0 0]]; %default
|
---|
| 4960 | end
|
---|
| 4961 | end
|
---|
| 4962 | if ishandle(handles.UVMAT_title)
|
---|
| 4963 | delete(handles.UVMAT_title)%delete the initial display of uvmat if no field has been entered
|
---|
| 4964 | end
|
---|
| 4965 | %PlotHandles=get_plot_handles(handles);%get the handles of the interface elements setting the plotting parameters
|
---|
| 4966 | set_object(data,handles);% call the set_object interface
|
---|
| 4967 | set(handles.MenuObject,'checked','on')
|
---|
| 4968 | set(handles.uvmat,'UserData',UvData)
|
---|
[292] | 4969 | set(handles.CheckZoom,'Value',0)
|
---|
| 4970 | CheckZoom_Callback(handles.uvmat, [], handles)
|
---|
[199] | 4971 | set(handles.delete_object,'Visible','on')
|
---|
[302] | 4972 | % set(handles._title,'Visible','on')
|
---|
| 4973 | % set(handles.view_field_title,'Visible','on')
|
---|
[199] | 4974 |
|
---|
| 4975 | %------------------------------------------------------------------------
|
---|
| 4976 | function MenuRuler_Callback(hObject, eventdata, handles)
|
---|
| 4977 | %------------------------------------------------------------------------
|
---|
[292] | 4978 | set(handles.CheckZoom,'Value',0)
|
---|
| 4979 | CheckZoom_Callback(handles.uvmat, [], handles)
|
---|
[199] | 4980 | set(handles.MenuRuler,'checked','on')
|
---|
| 4981 | UvData=get(handles.uvmat,'UserData');
|
---|
| 4982 | UvData.MouseAction='ruler';
|
---|
| 4983 | set(handles.uvmat,'UserData',UvData);
|
---|
| 4984 |
|
---|
| 4985 | %------------------------------------------------------------------------
|
---|
| 4986 | % --- executed when closing: set the parent interface button to value 0
|
---|
| 4987 | function closefcn(gcbo,eventdata)
|
---|
| 4988 | %------------------------------------------------------------------------
|
---|
| 4989 | %delete all the associated figures if exist
|
---|
| 4990 | hh=findobj(allchild(0),'tag','view_field');
|
---|
| 4991 | if ~isempty(hh)
|
---|
| 4992 | delete(hh)
|
---|
| 4993 | end
|
---|
| 4994 | hh=findobj(allchild(0),'tag','geometry_calib');
|
---|
| 4995 | if ~isempty(hh)
|
---|
| 4996 | delete(hh)
|
---|
| 4997 | end
|
---|
| 4998 | hh=findobj(allchild(0),'tag','set_object');
|
---|
| 4999 | if ~isempty(hh)
|
---|
| 5000 | hhh=findobj(hh,'tag','PLOT');
|
---|
| 5001 | set(hhh,'enable','off')
|
---|
| 5002 | end
|
---|
| 5003 |
|
---|
| 5004 | %------------------------------------------------------------------------
|
---|
| 5005 | % --- Executes on button press in delete_object.
|
---|
| 5006 | function delete_object_Callback(hObject, eventdata, handles)
|
---|
| 5007 | %------------------------------------------------------------------------
|
---|
[302] | 5008 | IndexObj=get(handles.ListObject,'Value');
|
---|
| 5009 | if IndexObj(end)>1
|
---|
| 5010 | delete_object(IndexObj(end))
|
---|
[199] | 5011 | end
|
---|
| 5012 |
|
---|
[236] | 5013 | % --- Executes on button press in FixVelType.
|
---|
| 5014 | function FixVelType_Callback(hObject, eventdata, handles)
|
---|
| 5015 | val=get(handles.FixVelType,'Value');
|
---|
| 5016 | if ~val
|
---|
| 5017 | run0_Callback(hObject, eventdata, handles)
|
---|
| 5018 | end
|
---|
[199] | 5019 |
|
---|
[236] | 5020 |
|
---|
[302] | 5021 | % --- Executes on button press in ViewObject.
|
---|
| 5022 | function ViewObject_Callback(hObject, eventdata, handles)
|
---|
| 5023 | IndexObj=get(handles.ListObject,'Value');
|
---|
| 5024 | IndexObj=IndexObj(end); %keeps only the secodn value
|
---|
| 5025 | UvData=get(handles.uvmat,'UserData');%read UvData properties stored on the uvmat interface
|
---|
| 5026 | if numel(UvData.Object)<IndexObj;% error in UvData
|
---|
| 5027 | msgbox_uvmat('ERROR','invalid object list')
|
---|
| 5028 | return
|
---|
| 5029 | end
|
---|
| 5030 | ObjectData=UvData.Object{IndexObj};
|
---|
| 5031 | ZBounds=0; % default
|
---|
| 5032 | if isfield(UvData.Field,'ZMin') && isfield(UvData.Field,'ZMax')
|
---|
| 5033 | ZBounds(1)=UvData.Field.ZMin; %minimum for the Z slider
|
---|
| 5034 | ZBounds(2)=UvData.Field.ZMax;%maximum for the Z slider
|
---|
| 5035 | end
|
---|
| 5036 | hset_object=findobj(allchild(0),'tag','set_object');
|
---|
| 5037 | if ~isempty(hset_object)
|
---|
| 5038 | delete(hset_object)% delete existing version of set_object
|
---|
| 5039 | end
|
---|
| 5040 | hset_object=set_object(ObjectData,[],ZBounds);
|
---|
[323] | 5041 |
|
---|
| 5042 |
|
---|
| 5043 |
|
---|
| 5044 | function NomType_Callback(hObject, eventdata, handles)
|
---|
| 5045 |
|
---|
| 5046 |
|
---|
| 5047 | function NomType_1_Callback(hObject, eventdata, handles)
|
---|
| 5048 |
|
---|