[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)
|
---|
| 52 | % .VelType_1: last velocity type (civ1, civ2...) for the second input series
|
---|
| 53 | % .FieldName_1: last field name(velocity, vorticity...) for the second input series
|
---|
| 54 | % .ZMin, .ZMax: range of the z coordinate
|
---|
| 55 | %..... to complement
|
---|
| 56 | % - Information on projection objects
|
---|
| 57 | % .Object: {[1x1 struct]}
|
---|
| 58 | % .CurrentObjectIndex: index of the projection object .Object currently selected for editing
|
---|
| 59 | % -Information on the current field (Field{i})
|
---|
| 60 | % .Txt : text information to display (e.g. error message)
|
---|
| 61 | % .NbDim: number of dimensions (=0 by default)
|
---|
| 62 | % .NbCoord: number of vector components
|
---|
| 63 | % .CoordType: expresses the type of coordinate ('px' for image, 'sig' for instruments, or 'phys')
|
---|
| 64 | % .dt: time interval for the corresponding image pair
|
---|
| 65 | % .Mesh: estimated typical distance between vectors
|
---|
| 66 | % .ZMax:
|
---|
| 67 | % .ZMin:
|
---|
| 68 | % .X, .Y, .Z: set of vector coordinates
|
---|
| 69 | % .U,.V,.W: corresponding set of vector components
|
---|
| 70 | % .F: corresponding set of warning flags
|
---|
| 71 | % .FF: corresponding set of false flags, =0 for good vectors
|
---|
| 72 | % .C: corresponding values of the scalar used for vector color
|
---|
| 73 | % (.X, .Y, .Z,.U,.V,.W,.F,.FF,.C are matlab vectors of the same length,
|
---|
| 74 | % equal to the number of vectors stored in the input open)
|
---|
| 75 | % .CName: name of the scalar .C
|
---|
| 76 | % .CType: type of the scalar .C, setting how the scalar is obtained (see 'Scalars' below)
|
---|
| 77 | % .A image or scalar
|
---|
| 78 | % .AX: vector of dimension 2 representing the first and last values
|
---|
| 79 | % of the X coordinates for the image or scalar known on a regular grid,
|
---|
| 80 | % or vector of dimension .A for a scaler defined on irregular grid.
|
---|
| 81 | % .AY: same as .AX along the Y direction
|
---|
| 82 | % .AName: name of the scalar, ='image' for an image
|
---|
| 83 |
|
---|
| 84 | % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%% DATA FLOW (for run0_Callback) %%%%%%%%%%%%%%%%%%%%:
|
---|
| 85 | %
|
---|
| 86 | % fields are opened and visualised by the sub-function refresh_field.m
|
---|
| 87 | % (called by uvmat_opening, RUN0, runp and runm)
|
---|
| 88 | % The function first reads the name of the input file from the edit boxes of the GUI
|
---|
| 89 | % A second input file can be introduced for filed comparison
|
---|
| 90 | % It then reads the input file(s) with the appropriate function, read for
|
---|
| 91 | % images, read_civxdata.m for CIVx PIV data, nc2struct for other netcdf
|
---|
| 92 | % files.
|
---|
| 93 | % Main input open second input open(_1) second image (pair animation)
|
---|
| 94 | % | |
|
---|
| 95 | % | |
|
---|
| 96 | % Field{1} Field{2}
|
---|
| 97 | % |
|
---|
| 98 | % coord transform (phys.m) or other user defined fct acting on Field{i} |
|
---|
| 99 | % Field{i}
|
---|
| 100 | % |
|
---|
| 101 | % calc_field.m: calculate scalar or other derived fields (vort, div..).
|
---|
| 102 | %
|
---|
| 103 | % sub_field.m: combine the input Field{i} in a single set of fields (vector + scalar):
|
---|
| 104 | % Field{i=1->3}.X --> UvData.X |
|
---|
| 105 | % |
|
---|
| 106 | % UvData
|
---|
| 107 | % |
|
---|
| 108 | % plot histograms of the whole field
|
---|
| 109 | % proj_field.m: project the set of fields on the current projection objects defined by UvData.Object
|
---|
| 110 | % | |
|
---|
| 111 | % ObjectData
|
---|
| 112 | % |
|
---|
| 113 | % plot_field.m: plot the projected fields and store them as |
|
---|
| 114 | % UvData.axes3 |
|
---|
| 115 | % |
|
---|
| 116 | % AxeData
|
---|
| 117 | %
|
---|
| 118 | %%%%%%%%%%%%%% SCALARS: %%%%%%%%%%%%??%%%
|
---|
| 119 | % scalars are displayed either as an image or countour plot, either as a color of
|
---|
| 120 | % velocity vectors. The scalar values in the first case is represented by
|
---|
| 121 | % UvData.Field.A, and by UvData.Field.C in the second case. The corresponding set of X
|
---|
| 122 | % and Y coordinates are represented by UvData.Field.AX and UvData.Field.AY, and .X and
|
---|
| 123 | % .Y for C (the same as velocity vectors). If A is a nxxny matrix (scalar
|
---|
| 124 | % on a regtular grid), then .AX andf.AY contains only two elements, represneting the
|
---|
| 125 | % coordinates of the four image corners. The scalar name is represented by
|
---|
| 126 | % the strings .AName and/or .CName.
|
---|
| 127 | % If the scalar exists in an input open (image or scalar stored under its
|
---|
| 128 | % name in a netcdf open), it is directly read at the level of Field{1}or Field{2}.
|
---|
| 129 | % Else only its name AName is recorded in Field{i}, and its field is then calculated
|
---|
| 130 | %by the fuction calc_scal after the coordinate transform or after projection on an edit_object
|
---|
| 131 |
|
---|
| 132 | % Properties attached to plotting figures (standard Matlab properties):
|
---|
| 133 | % 'CurrentAxes'= gca or get(gcf,'CurrentAxes');
|
---|
| 134 | % 'CurrentPoint'=get(gcf,'CurrentPoint'): figure coordinates of the point over which the mouse is positioned
|
---|
| 135 | % 'CurrentCharacter'=get(gcf,'CurrentCharacter'): last character typed over the figure where the mouse is positioned
|
---|
| 136 | % 'WindowButtonMotionFcn': function permanently called by mouse motion over the figure
|
---|
| 137 | % 'KeyPressFcn': function called by pressing a key on the key board
|
---|
| 138 | % 'WindowButtonDownFcn': function called by pressing the mouse over the figure
|
---|
| 139 | % 'WindowButtonUpFcn': function called by releasing the mouse pressure over the figure
|
---|
| 140 |
|
---|
| 141 | % Properties attached to plotting axes:
|
---|
| 142 | % 'CurrentPoint'=get(gca,'CurrentPoint'); (standard Matlab) same as for the figure, but position in plot coordinates.
|
---|
| 143 | % AxeData:=get(gca,'UserData');
|
---|
| 144 | % AxeData.Drawing = create: create a new object
|
---|
| 145 | % = deform: modify an existing object by moving its defining create
|
---|
| 146 | % = off: no current drawing action
|
---|
| 147 | % = translate: translate an existing object
|
---|
| 148 | % = calibration: move a calibration point
|
---|
| 149 | % = zoom: isolate a subregion for zoom in=1 if an object is being currently drawn, 0 else (set to 0 by releasing mouse button)
|
---|
| 150 | % .CurrentOrigin: Origin of a curently drawn edit_object
|
---|
| 151 | % .CurrentLine: currently drawn menuline (A REVOIR)
|
---|
| 152 | % .CurrentObject: handle of the currently drawn edit_object
|
---|
| 153 | % .CurrentRectZoom: current rectangle used for zoom
|
---|
| 154 |
|
---|
| 155 | % Properties attached to projection objects (create, menuline, menuplane...):
|
---|
| 156 | % 'Tag'='proj_object': for all projection objects
|
---|
| 157 | % ObjectData.Style=...: style of projection object:
|
---|
| 158 | % .ProjMode
|
---|
| 159 | % .Coord: defines the position of the object
|
---|
| 160 | % .XMin,YMin....
|
---|
| 161 | % .XMax,YMax....
|
---|
| 162 | % .DX,DY,DZ
|
---|
| 163 | % .Phi, .Theta, .Psi : Euler angles
|
---|
| 164 | % .X,.Y,.U,.V.... : field data projected on the object
|
---|
| 165 | % .IndexObj: index in the list of UvData.Object
|
---|
| 166 | %during plotting
|
---|
| 167 | % .plotaxes: handles of the current axes used to plot the result of field projection on the object
|
---|
| 168 | % .plothandle: vector of handle(s) of the object graphic represnetation in all the opened plotting axes
|
---|
| 169 | % To each projection object #iobj, corresponds an axis
|
---|
| 170 | % Object{iobj}.plotaxes and nbobj representation graphs Object{iobj}.plothandles(:) (where nbobj is the
|
---|
| 171 | % nbre of current objects opened in uvmat. Note that Object{iobj}.plothandles(iobj)=[] : an object is not represented in its own projection field;
|
---|
| 172 |
|
---|
| 173 | %------------------------------------------------------------------------
|
---|
| 174 | %------------------------------------------------------------------------
|
---|
| 175 | % I - MAIN FUNCTION UVMAT (DO NOT MODIFY)
|
---|
| 176 | %------------------------------------------------------------------------
|
---|
| 177 | %------------------------------------------------------------------------
|
---|
| 178 | function varargout = uvmat(varargin)
|
---|
| 179 |
|
---|
| 180 | % Begin initialization code - DO NOT EDIT
|
---|
| 181 | gui_Singleton = 1;
|
---|
| 182 | gui_State = struct('gui_Name', mfilename, ...
|
---|
| 183 | 'gui_Singleton', gui_Singleton, ...
|
---|
| 184 | 'gui_OpeningFcn', @uvmat_OpeningFcn, ...
|
---|
| 185 | 'gui_OutputFcn', @uvmat_OutputFcn, ...
|
---|
| 186 | 'gui_LayoutFcn', [], ...
|
---|
| 187 | 'gui_Callback', []);
|
---|
| 188 | if nargin && ischar(varargin{1})&& ~isempty(regexp(varargin{1},'_Callback','once'))
|
---|
| 189 | gui_State.gui_Callback = str2func(varargin{1});
|
---|
| 190 | end
|
---|
| 191 |
|
---|
| 192 | if nargout
|
---|
| 193 | varargout{1:nargout} = gui_mainfcn(gui_State, varargin{:});
|
---|
| 194 | else
|
---|
| 195 | gui_mainfcn(gui_State, varargin{:});
|
---|
| 196 | end
|
---|
| 197 | % End initialization code - DO NOT EDIT
|
---|
| 198 |
|
---|
| 199 | %------------------------------------------------------------------------
|
---|
| 200 | % --- Executes just before the GUI uvmat is made visible.
|
---|
| 201 | function uvmat_OpeningFcn(hObject, eventdata, handles, input )
|
---|
| 202 | %------------------------------------------------------------------------
|
---|
| 203 |
|
---|
| 204 | %% Choose default command menuline output for uvmat (standard GUI)
|
---|
| 205 | handles.output = hObject;
|
---|
| 206 |
|
---|
| 207 | %% Update handles structure (standard GUI)
|
---|
| 208 | guidata(hObject, handles);
|
---|
| 209 |
|
---|
| 210 | %% set the position of colorbar and ancillary GUIs:
|
---|
| 211 | set(hObject,'Units','Normalized')
|
---|
| 212 | movegui(hObject,'center')
|
---|
| 213 | UvData.OpenParam.PosColorbar=[0.805 0.022 0.019 0.445];
|
---|
| 214 | UvData.OpenParam.SetObjectOrigin=[-0.05 -0.03]; %position for set_object
|
---|
| 215 | UvData.OpenParam.SetObjectSize=[0.3 0.7];
|
---|
| 216 | UvData.OpenParam.CalOrigin=[0.95 -0.03];%position for geometry_calib (TO IMPROVE)
|
---|
| 217 | UvData.OpenParam.CalSize=[0.28 1];
|
---|
| 218 | UvData.axes3=[];%initiate the record of plotted field
|
---|
| 219 | UvData.axes2=[];
|
---|
| 220 | UvData.axes1=[];
|
---|
| 221 | AxeData.LimEditBox=1; %initialise AxeData
|
---|
| 222 | set(handles.axes3,'UserData',AxeData)
|
---|
| 223 |
|
---|
| 224 | %% set functions for the mouse and keyboard
|
---|
| 225 | set(handles.histo_u,'NextPlot','replacechildren');
|
---|
| 226 | set(handles.histo_v,'NextPlot','replacechildren');
|
---|
| 227 | set(hObject,'KeyPressFcn',{'keyboard_callback',handles})%set keyboard action function
|
---|
| 228 | set(hObject,'WindowButtonMotionFcn',{'mouse_motion',handles})%set mouse action functio
|
---|
| 229 | set(hObject,'WindowButtonDownFcn',{'mouse_down'})%set mouse click action function
|
---|
| 230 | set(hObject,'WindowButtonUpFcn',{'mouse_up',handles})
|
---|
| 231 | set(hObject,'DeleteFcn',{@closefcn})%
|
---|
| 232 |
|
---|
| 233 | %% refresh projection plane
|
---|
| 234 | UvData.Object{1}.ProjMode='projection';%main plotting plane
|
---|
| 235 | set(handles.Fields,'Value',1)
|
---|
| 236 | set(handles.Fields,'string',{''})
|
---|
| 237 |
|
---|
| 238 | %% TRANSFORM menu: builtin fcts
|
---|
| 239 | menu_str={'';'phys';'px';'phys_polar'};
|
---|
| 240 | UvData.OpenParam.NbBuiltin=numel(menu_str); %number of functions
|
---|
| 241 | path_uvmat=fileparts(which('uvmat'));
|
---|
| 242 | addpath(fullfile(path_uvmat,'transform_field'))
|
---|
| 243 | fct_handle{1,1}=[];
|
---|
| 244 | testexist=zeros(size(menu_str'));%default
|
---|
| 245 | testexist(1)=1;
|
---|
| 246 | for ilist=2:length(menu_str)
|
---|
| 247 | if exist(menu_str{ilist},'file')
|
---|
| 248 | fct_handle{ilist,1}=str2func(menu_str{ilist});
|
---|
| 249 | testexist(ilist)=1;
|
---|
| 250 | else
|
---|
| 251 | testexist(ilist)=0;
|
---|
| 252 | end
|
---|
| 253 | end
|
---|
| 254 | rmpath(fullfile(path_uvmat,'transform_field'))
|
---|
| 255 |
|
---|
| 256 | %% load the list of previously browsed files in menus Open and Open_1
|
---|
| 257 | dir_perso=prefdir; % path to the directory .matlab for personal data
|
---|
| 258 | profil_perso=fullfile(dir_perso,'uvmat_perso.mat');% personal data file uvmauvmat_perso.mat' in .matlab
|
---|
| 259 | if exist(profil_perso,'file')
|
---|
| 260 | h=load (profil_perso);
|
---|
| 261 | if isfield(h,'MenuFile_1')
|
---|
| 262 | set(handles.MenuFile_1,'Label',h.MenuFile_1);
|
---|
| 263 | set(handles.MenuFile_1_1,'Label',h.MenuFile_1);
|
---|
| 264 | end
|
---|
| 265 | if isfield(h,'MenuFile_2')
|
---|
| 266 | set(handles.MenuFile_2,'Label',h.MenuFile_2);
|
---|
| 267 | set(handles.MenuFile_2_1,'Label',h.MenuFile_2);
|
---|
| 268 | end
|
---|
| 269 | if isfield(h,'MenuFile_3')
|
---|
| 270 | set(handles.MenuFile_3,'Label',h.MenuFile_3);
|
---|
| 271 | set(handles.MenuFile_3_1,'Label',h.MenuFile_3);
|
---|
| 272 | end
|
---|
| 273 | if isfield(h,'MenuFile_4')
|
---|
| 274 | set(handles.MenuFile_4,'Label',h.MenuFile_4);
|
---|
| 275 | set(handles.MenuFile_4_1,'Label',h.MenuFile_4);
|
---|
| 276 | end
|
---|
| 277 | if isfield(h,'MenuFile_5')
|
---|
| 278 | set(handles.MenuFile_5,'Label',h.MenuFile_5);
|
---|
| 279 | set(handles.MenuFile_5_1,'Label',h.MenuFile_5);
|
---|
| 280 | end
|
---|
| 281 | if isfield(h,'transform_fct') && iscell(h.transform_fct)
|
---|
| 282 | for ilist=1:length(h.transform_fct);
|
---|
| 283 | if exist(h.transform_fct{ilist},'file')
|
---|
| 284 | [path,file]=fileparts(h.transform_fct{ilist});
|
---|
| 285 | addpath(path)
|
---|
| 286 | h_func=str2func(file);
|
---|
| 287 | rmpath(path)
|
---|
| 288 | testexist=[testexist 1];
|
---|
| 289 | else
|
---|
| 290 | file='';
|
---|
| 291 | h_func=[];
|
---|
| 292 | testexist=[testexist 0];
|
---|
| 293 | end
|
---|
| 294 | fct_handle=[fct_handle; {h_func}]; %concatene the list of paths
|
---|
| 295 | menu_str=[menu_str; {file}];
|
---|
| 296 | end
|
---|
| 297 | end
|
---|
| 298 | end
|
---|
| 299 | menu_str=menu_str(testexist==1);%=menu_str(testexist~=0)
|
---|
| 300 | fct_handle=fct_handle(testexist==1);
|
---|
| 301 | menu_str=[menu_str;{'more...'}];
|
---|
| 302 | set(handles.transform_fct,'String',menu_str)
|
---|
| 303 | set(handles.transform_fct,'UserData',fct_handle)% store the list of path in UserData of ACTION
|
---|
| 304 | set(handles.uvmat,'UserData',UvData)
|
---|
| 305 |
|
---|
| 306 | %% check the path and date of modification of all functions in uvmat
|
---|
| 307 | path_to_uvmat=which ('uvmat');% check the path detected for source file uvmat
|
---|
| 308 | [errormsg,date_str]=check_functions;%check the path of the functions called by uvmat.m
|
---|
| 309 | date_str=['last modification: ' date_str];
|
---|
| 310 |
|
---|
| 311 | %% case of an input argument for uvmat
|
---|
| 312 | testinputfield=0;
|
---|
| 313 | inputfile=[];
|
---|
| 314 | Field=[];
|
---|
| 315 | if exist('input','var')
|
---|
| 316 | if ~isempty(errormsg)
|
---|
| 317 | msgbox_uvmat('WARNING',errormsg)
|
---|
| 318 | end
|
---|
| 319 | if ishandle(handles.UVMAT_title)
|
---|
| 320 | delete(handles.UVMAT_title)
|
---|
| 321 | end
|
---|
| 322 | if isstruct(input)
|
---|
| 323 | if isfield(input,'InputFile')
|
---|
| 324 | inputfile=input.InputFile;
|
---|
| 325 | end
|
---|
[227] | 326 | if isfield(Field,'TimeIndex')
|
---|
| 327 | set(handles.i1,num2str(Field.TimeIndex))
|
---|
| 328 | end
|
---|
[199] | 329 | elseif ischar(input)% file name introduced as input
|
---|
| 330 | inputfile=input;
|
---|
| 331 | elseif isnumeric(input)%simple matrix introduced as input
|
---|
| 332 | sizinput=size(input);
|
---|
| 333 | if sizinput(1)<=1 || sizinput(2)<=1
|
---|
| 334 | msgbox_uvmat('ERROR','bad input for uvmat: file name, structure or numerical matrix accepted')
|
---|
| 335 | return
|
---|
| 336 | end
|
---|
| 337 | Field.ListVarName={'A','coord_y','coord_x'};
|
---|
| 338 | Field.VarDimName={{'coord_y','coord_x'},'cord_y','coord_x'};
|
---|
| 339 | Field.A=input;
|
---|
| 340 | Field.coord_x=[0.5 size(input,2)-0.5];
|
---|
| 341 | Field.coord_y=[size(input,1)-0.5 0.5];
|
---|
| 342 | end
|
---|
| 343 | if ~isempty(inputfile)
|
---|
[227] | 344 | %%%%% display the input field %%%%%%%
|
---|
[199] | 345 | display_file_name(hObject, eventdata, handles,inputfile)
|
---|
| 346 | %%%%%%%
|
---|
| 347 | testinputfield=1;
|
---|
| 348 | end
|
---|
| 349 | else
|
---|
| 350 | if ishandle(handles.UVMAT_title)
|
---|
| 351 | fid=fopen('revision.log');
|
---|
| 352 | if fid~=-1
|
---|
| 353 | a=textscan(fid,'%s%s%s',1,'HeaderLines',1,'Delimiter','|');
|
---|
| 354 | set(handles.UVMAT_title,'String',[{'Copyright Joel Sommeria, 2008, Coriolis/ LEGI / CNRS-UJF-INPG'};{'GNU General Public License'}; {path_to_uvmat}; ...
|
---|
| 355 | {['at revision ' a{1}{1}]};a{3}(1);{date_str};errormsg]);
|
---|
| 356 | fclose(fid);
|
---|
| 357 | else
|
---|
| 358 | set(handles.UVMAT_title,'String',[{'Copyright Joel Sommeria, 2008, Coriolis/ LEGI / CNRS-UJF-INPG'};{'GNU General Public License'};{path_to_uvmat};...
|
---|
| 359 | {date_str};errormsg]);
|
---|
| 360 | end
|
---|
| 361 | end
|
---|
| 362 | end
|
---|
| 363 |
|
---|
| 364 | %% plot input field if exists
|
---|
| 365 | if testinputfield
|
---|
| 366 | %delete drawn objects
|
---|
| 367 | hother=findobj(handles.axes3,'Tag','proj_object');%find all the proj objects
|
---|
| 368 | for iobj=1:length(hother)
|
---|
| 369 | delete_object(hother(iobj))
|
---|
| 370 | end
|
---|
| 371 | if isempty(inputfile)
|
---|
| 372 | errormsg=refresh_field(handles,[],[],[],[],[],[],{Field});
|
---|
| 373 | set(handles.MenuTools,'Enable','on')
|
---|
| 374 | set(handles.OBJECT_txt,'Visible','on')
|
---|
| 375 | set(handles.edit_object,'Visible','on')
|
---|
| 376 | set(handles.list_object_1,'Visible','on')
|
---|
| 377 | set(handles.frame_object,'Visible','on')
|
---|
| 378 | if ~isempty(errormsg)
|
---|
| 379 | msgbox_uvmat('ERROR',errormsg)
|
---|
| 380 | end
|
---|
| 381 | end
|
---|
| 382 | end
|
---|
| 383 | set_vec_col_bar(handles) %update the display of color code for vectors
|
---|
| 384 |
|
---|
| 385 | %------------------------------------------------------------------------
|
---|
| 386 | % --- Outputs from this function are returned to the command menuline.
|
---|
| 387 | function varargout = uvmat_OutputFcn(hObject, eventdata, handles)
|
---|
| 388 | varargout{1} = handles.output;% the only output argument is the handle to the GUI figure
|
---|
| 389 |
|
---|
| 390 | %------------------------------------------------------------------------
|
---|
| 391 | %------------------------------------------------------------------------
|
---|
| 392 | % II - FUNCTIONS FOR INTRODUCING THE INPUT FILES
|
---|
| 393 | % automatically sets the global properties when the rootfile name is introduced
|
---|
| 394 | % then activate the view-field action if selected
|
---|
| 395 | % it is activated either by clicking on the RootPath window or by the
|
---|
| 396 | % browser
|
---|
| 397 | %------------------------------------------------------------------------
|
---|
| 398 | %------------------------------------------------------------------------
|
---|
| 399 | % --- Executes on the menu Open/Browse...
|
---|
| 400 | % search the files, recognize their type according to their name and fill the rootfile input windows
|
---|
| 401 | function MenuBrowse_Callback(hObject, eventdata, handles)
|
---|
| 402 | oldfile=read_file_boxes(handles);
|
---|
| 403 |
|
---|
| 404 | if isempty(oldfile)||isequal(oldfile,'') %loads the previously stored file name and set it as default in the file_input box
|
---|
| 405 | dir_perso=prefdir;
|
---|
| 406 | profil_perso=fullfile(dir_perso,'uvmat_perso.mat');
|
---|
| 407 | if exist(profil_perso,'file')
|
---|
| 408 | h=load (profil_perso);
|
---|
| 409 | if isfield(h,'MenuFile_1')
|
---|
| 410 | oldfile=h.MenuFile_1;
|
---|
| 411 | end
|
---|
| 412 | end
|
---|
| 413 | end
|
---|
| 414 | [FileName, PathName] = uigetfile( ...
|
---|
| 415 | {'*.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)';
|
---|
| 416 | '*.xml', '.xml files '; ...
|
---|
| 417 | '*.xls', '.xls files '; ...
|
---|
| 418 | '*.civ', '.civ files '; ...
|
---|
| 419 | '*.jpg',' jpeg image files'; ...
|
---|
| 420 | '*.png','.png image files'; ...
|
---|
| 421 | '*.tif','.tif image files'; ...
|
---|
| 422 | '*.avi;*.AVI','.avi movie files'; ...
|
---|
| 423 | '*.vol','.volume images (png)'; ...
|
---|
| 424 | '*.nc','.netcdf files'; ...
|
---|
| 425 | '*.cdf','.netcdf files'; ...
|
---|
| 426 | '*.cmx','.cmx text files ';...
|
---|
| 427 | '*.fig','.fig files (matlab fig)';...
|
---|
| 428 | '*.log','.log text files ';...
|
---|
| 429 | '*.dat','.dat text files ';...
|
---|
| 430 | '*.bat','.bat system command text files';...
|
---|
| 431 | '*.*', 'All Files (*.*)'}, ...
|
---|
| 432 | 'Pick a file',oldfile);
|
---|
| 433 | fileinput=[PathName FileName];%complete file name
|
---|
| 434 | sizf=size(fileinput);
|
---|
| 435 | if (~ischar(fileinput)||~isequal(sizf(1),1)),return;end
|
---|
| 436 |
|
---|
| 437 | % display the selected field and related information
|
---|
| 438 | display_file_name(hObject, eventdata, handles,fileinput)
|
---|
| 439 |
|
---|
| 440 | %update list of recent files in the menubar
|
---|
| 441 | MenuFile_1=fileinput;
|
---|
| 442 | MenuFile_2=get(handles.MenuFile_1,'Label');
|
---|
| 443 | MenuFile_3=get(handles.MenuFile_2,'Label');
|
---|
| 444 | MenuFile_4=get(handles.MenuFile_3,'Label');
|
---|
| 445 | MenuFile_5=get(handles.MenuFile_4,'Label');
|
---|
| 446 | set(handles.MenuFile_1,'Label',MenuFile_1)
|
---|
| 447 | set(handles.MenuFile_2,'Label',MenuFile_2)
|
---|
| 448 | set(handles.MenuFile_3,'Label',MenuFile_3)
|
---|
| 449 | set(handles.MenuFile_4,'Label',MenuFile_4)
|
---|
| 450 | set(handles.MenuFile_5,'Label',MenuFile_5)
|
---|
| 451 | set(handles.MenuFile_1_1,'Label',MenuFile_1)
|
---|
| 452 | set(handles.MenuFile_2_1,'Label',MenuFile_2)
|
---|
| 453 | set(handles.MenuFile_3_1,'Label',MenuFile_3)
|
---|
| 454 | set(handles.MenuFile_4_1,'Label',MenuFile_4)
|
---|
| 455 | set(handles.MenuFile_5_1,'Label',MenuFile_5)
|
---|
| 456 | dir_perso=prefdir;
|
---|
| 457 | profil_perso=fullfile(dir_perso,'uvmat_perso.mat');
|
---|
| 458 | if exist(profil_perso,'file')
|
---|
| 459 | save (profil_perso,'MenuFile_1','MenuFile_2','MenuFile_3','MenuFile_4', 'MenuFile_5','-append'); %store the file names for future opening of uvmat
|
---|
| 460 | else
|
---|
| 461 | txt=ver('MATLAB');
|
---|
| 462 | Release=txt.Release;
|
---|
| 463 | relnumb=str2double(Release(3:4));
|
---|
| 464 | if relnumb >= 14
|
---|
| 465 | save (profil_perso,'MenuFile_1','MenuFile_2','MenuFile_3','MenuFile_4', 'MenuFile_5','-V6'); %store the file names for future opening of uvmat
|
---|
| 466 | else
|
---|
| 467 | save (profil_perso,'MenuFile_1','MenuFile_2','MenuFile_3','MenuFile_4', 'MenuFile_5'); %store the file names for future opening of uvmat
|
---|
| 468 | end
|
---|
| 469 | end
|
---|
| 470 |
|
---|
| 471 | % -----------------------------------------------------------------------
|
---|
| 472 | % --- Open again the file whose name has been recorded in MenuFile_1
|
---|
| 473 | function MenuFile_1_Callback(hObject, eventdata, handles)
|
---|
[227] | 474 | %------------------------------------------------------------------------
|
---|
[199] | 475 | fileinput=get(handles.MenuFile_1,'Label');
|
---|
| 476 | display_file_name(hObject, eventdata, handles,fileinput)
|
---|
| 477 |
|
---|
| 478 | % -----------------------------------------------------------------------
|
---|
| 479 | % --- Open again the file whose name has been recorded in MenuFile_2
|
---|
| 480 | function MenuFile_2_Callback(hObject, eventdata, handles)
|
---|
[227] | 481 | %------------------------------------------------------------------------
|
---|
[199] | 482 | fileinput=get(handles.MenuFile_2,'Label');
|
---|
| 483 | display_file_name(hObject, eventdata, handles,fileinput)
|
---|
| 484 |
|
---|
| 485 | % -----------------------------------------------------------------------
|
---|
| 486 | % --- Open again the file whose name has been recorded in MenuFile_3
|
---|
| 487 | function MenuFile_3_Callback(hObject, eventdata, handles)
|
---|
[227] | 488 | %------------------------------------------------------------------------
|
---|
[199] | 489 | fileinput=get(handles.MenuFile_3,'Label');
|
---|
| 490 | display_file_name(hObject, eventdata, handles,fileinput)
|
---|
| 491 |
|
---|
| 492 | % -----------------------------------------------------------------------
|
---|
| 493 | % --- Open again the file whose name has been recorded in MenuFile_4
|
---|
| 494 | function MenuFile_4_Callback(hObject, eventdata, handles)
|
---|
[227] | 495 | %------------------------------------------------------------------------
|
---|
[199] | 496 | fileinput=get(handles.MenuFile_4,'Label');
|
---|
| 497 | display_file_name(hObject, eventdata, handles,fileinput)
|
---|
| 498 |
|
---|
| 499 | % -----------------------------------------------------------------------
|
---|
| 500 | % --- Open again the file whose name has been recorded in MenuFile_5
|
---|
| 501 | function MenuFile_5_Callback(hObject, eventdata, handles)
|
---|
[227] | 502 | %------------------------------------------------------------------------
|
---|
[199] | 503 | fileinput=get(handles.MenuFile_5,'Label');
|
---|
| 504 | display_file_name(hObject, eventdata, handles,fileinput)
|
---|
| 505 |
|
---|
| 506 | %------------------------------------------------------------------------
|
---|
| 507 | % --- Fills the edit boxes RootPath, RootFile,NomType...from an input file name 'fileinput'
|
---|
| 508 | function display_file_name(hObject, eventdata, handles,fileinput)
|
---|
[227] | 509 | %------------------------------------------------------------------------
|
---|
[199] | 510 | if ~exist(fileinput,'file')
|
---|
| 511 | msgbox_uvmat('ERROR',['input file ' fileinput ' does not exist'])
|
---|
| 512 | return
|
---|
| 513 | end
|
---|
| 514 | [RootPath,RootFile,i1,i2,str_a,str_b,ext,NomType,SubDir]=name2display(fileinput);
|
---|
| 515 | ext_test=''; %default
|
---|
| 516 | if ~isempty(ext)
|
---|
| 517 | form=imformats(ext(2:end));%test valid Matlab image formats
|
---|
| 518 | if ~isempty(form)
|
---|
| 519 | ext_test='.image';
|
---|
| 520 | imainfo=imfinfo(fileinput);
|
---|
| 521 | if length(imainfo) >1 %case of image with multiple frames
|
---|
| 522 | i1='1'; % set the frame counter to 1 by default
|
---|
| 523 | i2='';
|
---|
| 524 | str_a='';
|
---|
| 525 | str_b='';
|
---|
| 526 | NomType='*'; %indicate a set of indexed frames within a single file
|
---|
| 527 | [RootPath,RootFile]=fileparts(fileinput); %include the indices in the root file
|
---|
| 528 | end
|
---|
| 529 | elseif isequal(lower(ext),'.avi')
|
---|
| 530 | ext_test='.image';
|
---|
| 531 | i1='1'; % set the frame counter to 1 by default
|
---|
| 532 | i2='';
|
---|
| 533 | str_a='';
|
---|
| 534 | str_b='';
|
---|
| 535 | NomType='*'; %indicate a set of indexed frames within a single file
|
---|
| 536 | [RootPath,RootFile]=fileparts(fileinput); %include the indices in the root file
|
---|
| 537 | else
|
---|
| 538 | ext_test=lower(ext);
|
---|
| 539 | end
|
---|
| 540 | end
|
---|
| 541 | switch ext_test
|
---|
| 542 | case {'.civ','.log','.cmx','.cmx2','.txt','.bat'} %display text file
|
---|
| 543 | edit(fileinput)
|
---|
| 544 | case '.fig' %display matlab figure
|
---|
| 545 | hfig=open(fileinput);
|
---|
| 546 | set(hfig,'WindowButtonMotionFcn','mouse_motion')%set mouse action functio
|
---|
| 547 | set(hfig,'WindowButtonUpFcn','mouse_up')%set mouse click action function
|
---|
| 548 | set(hfig,'WindowButtonUpFcn','mouse_down')%set mouse click action function
|
---|
| 549 | case {'.xml','.xls'} % edit xml or Excel files
|
---|
| 550 | editxml(fileinput);
|
---|
| 551 | case {'.avi','.image','.vol','.nc','.cdf'}
|
---|
| 552 | set(handles.RootPath,'String',RootPath);
|
---|
| 553 | if isequal(SubDir,'')
|
---|
| 554 | rootname=fullfile(RootPath,RootFile);
|
---|
| 555 | else
|
---|
| 556 | rootname=fullfile(RootPath,SubDir,RootFile);
|
---|
| 557 | SubDir=['/' SubDir]; %display the separator
|
---|
| 558 | end
|
---|
| 559 | set(handles.SubDir,'String',SubDir);
|
---|
| 560 | set(handles.RootFile,'String',['/' RootFile]); %display the separator
|
---|
| 561 | indices=fileinput(length(rootname)+1:end);
|
---|
| 562 | indices(end-length(ext)+1:end)=[]; %remove extension
|
---|
| 563 | set(handles.FileIndex,'String',indices);
|
---|
| 564 | set(handles.FileIndex,'UserData',NomType);
|
---|
| 565 | set(handles.FileExt,'String',ext);
|
---|
| 566 | % fill file index counters
|
---|
| 567 | set(handles.i1,'String',i1);
|
---|
| 568 | set(handles.i2,'String',i2);
|
---|
| 569 | set(handles.j1,'String',str_a);
|
---|
| 570 | set(handles.j2,'String',str_b);
|
---|
| 571 |
|
---|
| 572 | % synchronise indices of the second input file if it exists
|
---|
| 573 | if get(handles.SubField,'Value')==1% if the subfield button is activated, update the field numbers
|
---|
| 574 | [ff,rr,FileBase_1,ii,FileExt_1,SubDir_1]=read_file_boxes_1(handles);
|
---|
| 575 | NomType_1=get(handles.FileIndex_1,'UserData');
|
---|
| 576 | FileName_1=name_generator(FileBase_1,str2double(i1),str2double(i2),FileExt_1,NomType_1,1,stra2num(str_a),stra2num(str_b),SubDir_1);
|
---|
| 577 | if exist(FileName_1,'file')
|
---|
| 578 | FileIndex_1=name_generator('',str2double(i1),str2double(i2),'',NomType_1,1,stra2num(str_a),stra2num(str_b),'');
|
---|
| 579 | set(handles.FileIndex_1,'String',FileIndex_1)
|
---|
| 580 | else
|
---|
| 581 | set(handles.SubField,'Value',0)
|
---|
| 582 | SubField_Callback(hObject, eventdata, handles)
|
---|
| 583 | end
|
---|
| 584 | end
|
---|
| 585 |
|
---|
| 586 | %enable other menus
|
---|
| 587 | set(handles.MenuOpen_1,'Enable','on')
|
---|
| 588 | set(handles.MenuFile_1_1,'Enable','on')
|
---|
| 589 | set(handles.MenuFile_2_1,'Enable','on')
|
---|
| 590 | set(handles.MenuFile_3_1,'Enable','on')
|
---|
| 591 | set(handles.MenuFile_4_1,'Enable','on')
|
---|
| 592 | set(handles.MenuFile_5_1,'Enable','on')
|
---|
| 593 | set(handles.MenuExport,'Enable','on')
|
---|
| 594 | set(handles.MenuExportFigure,'Enable','on')
|
---|
| 595 | set(handles.MenuExportMovie,'Enable','on')
|
---|
| 596 | set(handles.MenuTools,'Enable','on')
|
---|
| 597 | set(handles.OBJECT_txt,'Visible','on')
|
---|
| 598 | set(handles.edit_object,'Visible','on')
|
---|
| 599 | set(handles.list_object_1,'Visible','on')
|
---|
| 600 | set(handles.frame_object,'Visible','on')
|
---|
| 601 | %%%%%% initiate input file:
|
---|
| 602 | update_rootinfo(hObject,eventdata,handles);
|
---|
| 603 | otherwise
|
---|
| 604 | msgbox_uvmat('ERROR',['invalid input file extension' ext])
|
---|
| 605 | end
|
---|
| 606 |
|
---|
| 607 | %------------------------------------------------------------------------
|
---|
| 608 | % --- Called by action in RootPath edit box
|
---|
| 609 | function RootPath_Callback(hObject,eventdata,handles)
|
---|
| 610 | %------------------------------------------------------------------------
|
---|
| 611 | update_rootinfo(hObject,eventdata,handles);
|
---|
| 612 |
|
---|
| 613 | %------------------------------------------------------------------------
|
---|
| 614 | % --- Called by action in RootFile edit box
|
---|
| 615 | function SubDir_Callback(hObject, eventdata, handles)
|
---|
| 616 | %------------------------------------------------------------------------
|
---|
| 617 | %refresh the menu of input fields
|
---|
| 618 | Fields_Callback(hObject, eventdata, handles);
|
---|
| 619 | % refresh the current field
|
---|
| 620 | run0_Callback(hObject, eventdata, handles);
|
---|
| 621 |
|
---|
| 622 | %------------------------------------------------------------------------
|
---|
| 623 | % --- Called by action in RootFile edit box
|
---|
| 624 | function RootFile_Callback(hObject, eventdata, handles)
|
---|
| 625 | %------------------------------------------------------------------------
|
---|
| 626 | update_rootinfo(hObject,eventdata,handles)
|
---|
| 627 |
|
---|
| 628 | %------------------------------------------------------------------------
|
---|
| 629 | % --- Called by action in FileIndex edit box
|
---|
| 630 | function FileIndex_Callback(hObject, eventdata, handles)
|
---|
| 631 | %------------------------------------------------------------------------
|
---|
| 632 | FileIndices=get(handles.FileIndex,'String');
|
---|
| 633 | if isempty(str2num(FileIndices))
|
---|
| 634 | [pp,ff,str1,str2,str_a,str_b]=name2display(FileIndices);
|
---|
| 635 | else
|
---|
| 636 | str1=FileIndices;
|
---|
| 637 | str2='';
|
---|
| 638 | str_a='';
|
---|
| 639 | str_b='';
|
---|
| 640 | end
|
---|
| 641 | set(handles.i1,'String',str1);
|
---|
| 642 | set(handles.i2,'String',str2);
|
---|
| 643 | set(handles.j1,'String',str_a);
|
---|
| 644 | set(handles.j2,'String',str_b);
|
---|
| 645 | run0_Callback(hObject, eventdata, handles)
|
---|
| 646 |
|
---|
| 647 | %------------------------------------------------------------------------
|
---|
| 648 | % --- Update information about a new field series (indices to scan, timing,
|
---|
| 649 | % calibration from an xml file, then refresh current plots
|
---|
| 650 | function update_rootinfo(hObject,eventdata,handles)
|
---|
| 651 | %------------------------------------------------------------------------
|
---|
| 652 | set(handles.RootPath,'BackgroundColor',[1 1 0])
|
---|
| 653 | drawnow
|
---|
| 654 | set(handles.Fields,'UserData',[])% reinialize data from uvmat opening
|
---|
| 655 | UvData=get(handles.uvmat,'UserData');%huvmat=handles of the uvmat interface
|
---|
| 656 | UvData.NewSeries=1; %flag for run0: begin a new series
|
---|
| 657 | UvData.TestInputFile=1;
|
---|
| 658 | set(handles.fix_pair,'Value',1) % activate by default the comp_input '-'input window
|
---|
| 659 |
|
---|
| 660 | [FileName,RootPath,FileBase,FileIndices,FileExt,SubDir]=read_file_boxes(handles);
|
---|
| 661 | if ~exist(FileName,'file')
|
---|
| 662 | msgbox_uvmat('ERROR',['input file ' FileName ' not found']);
|
---|
| 663 | return
|
---|
| 664 | end
|
---|
| 665 | nbfield=[];%default
|
---|
| 666 | nburst=[];%default
|
---|
| 667 |
|
---|
| 668 | % read timing and total frame number from the current file (movie files) !! may be overrid by xml file
|
---|
| 669 | XmlData.Time=[];%default
|
---|
| 670 | XmlData.GeometryCalib=[];%default
|
---|
| 671 | TimeUnit=[];%default
|
---|
| 672 | testima=0; %test for image input
|
---|
| 673 | imainfo=[];
|
---|
| 674 | ColorType='falsecolor'; %default
|
---|
| 675 | hhh='';
|
---|
| 676 | if isequal(lower(FileExt),'.avi') %.avi file
|
---|
| 677 | testima=1;
|
---|
| 678 | imainfo=aviinfo([FileBase FileIndices FileExt]);
|
---|
| 679 | nbfield=imainfo.NumFrames;
|
---|
| 680 | nburst=1;
|
---|
| 681 | set(handles.Dt_txt,'String',['Dt=' num2str(1000/imainfo.FramesPerSecond) 'ms']);%display the elementary time interval in millisec
|
---|
| 682 | XmlData.Time=(0:1/imainfo.FramesPerSecond:(imainfo.NumFrames-1)/imainfo.FramesPerSecond)';
|
---|
| 683 | TimeUnit='s';
|
---|
| 684 | hhh=which('mmreader');
|
---|
| 685 | ColorType=imainfo.ImageType;%='truecolor' for color images
|
---|
| 686 | elseif ~isempty(FileExt(2:end))&&(~isempty(imformats(FileExt(2:end))) || isequal(FileExt,'.vol'))%&& isequal(NomType,'*')% multi-frame image
|
---|
| 687 | testima=1;
|
---|
| 688 | if ~isequal(SubDir,'')
|
---|
| 689 | RootFile=get(handles.RootFile,'String');
|
---|
| 690 | imainfo=imfinfo([fullfile(RootPath,SubDir,RootFile) FileIndices FileExt]);
|
---|
| 691 | else
|
---|
| 692 | imainfo=imfinfo([FileBase FileIndices FileExt]);
|
---|
| 693 | end
|
---|
| 694 | ColorType=imainfo.ColorType;%='truecolor' for color images
|
---|
| 695 | if length(imainfo) >1 %case of image with multiple frames
|
---|
| 696 | nbfield=length(imainfo);
|
---|
| 697 | nburst=1;
|
---|
| 698 | end
|
---|
| 699 | end
|
---|
| 700 | if ~strcmp(hhh,'')&& mmreader.isPlatformSupported()% if the function is found (recent version of matlab)
|
---|
| 701 | UvData.MovieObject=mmreader([FileBase FileIndices FileExt]);
|
---|
| 702 | elseif isfield(UvData,'MovieObject')
|
---|
| 703 | UvData=rmfield(UvData,'MovieObject');
|
---|
| 704 | end
|
---|
| 705 | if isfield(imainfo,'Width') && isfield(imainfo,'Height')
|
---|
| 706 | set(handles.npx,'String',num2str(imainfo.Width));%fills nbre of pixels x box
|
---|
| 707 | set(handles.npy,'String',num2str(imainfo.Height));%fills nbre of pixels x box
|
---|
| 708 | else
|
---|
| 709 | set(handles.npx,'String','');%fills nbre of pixels x box
|
---|
| 710 | set(handles.npy,'String','');%fills nbre of pixels x box
|
---|
| 711 | end
|
---|
| 712 | set(handles.BW,'Value',strcmp(ColorType,'grayscale'))% select handles.BW if grayscale image
|
---|
| 713 |
|
---|
| 714 | % read parameters (time, geometric calibration..) from a documentation file (.xml advised)
|
---|
| 715 | filexml=[FileBase '.xml'];
|
---|
| 716 | fileciv=[FileBase '.civ'];
|
---|
| 717 | warntext='';%default warning message
|
---|
| 718 | NbSlice=1;%default
|
---|
| 719 |
|
---|
| 720 | if exist(filexml,'file')
|
---|
| 721 | set(handles.view_xml,'Visible','on')
|
---|
| 722 | set(handles.view_xml,'BackgroundColor',[1 1 0])
|
---|
| 723 | set(handles.RootPath,'BackgroundColor',[1 1 1])
|
---|
| 724 | set(handles.view_xml,'String','view .xml')
|
---|
| 725 | drawnow
|
---|
| 726 | [XmlData,warntext]=imadoc2struct(filexml);
|
---|
| 727 | if ~isempty(warntext)
|
---|
| 728 | msgbox_uvmat('WARNING',warntext)
|
---|
| 729 | end
|
---|
| 730 | if isfield(XmlData,'TimeUnit')
|
---|
| 731 | if isfield(XmlData,'TimeUnit')&& ~isempty(XmlData.TimeUnit)
|
---|
| 732 | TimeUnit=XmlData.TimeUnit;
|
---|
| 733 | end
|
---|
| 734 | end
|
---|
| 735 | set(handles.view_xml,'BackgroundColor',[1 1 1])
|
---|
| 736 | drawnow
|
---|
| 737 | if isfield(XmlData, 'GeometryCalib') && ~isempty(XmlData.GeometryCalib)
|
---|
| 738 | XmlData.GeometryCalib
|
---|
| 739 | if isfield(XmlData.GeometryCalib,'VolumeScan') && isequal(XmlData.GeometryCalib.VolumeScan,'y')
|
---|
| 740 | set (handles.nb_slice,'String','volume')
|
---|
| 741 | end
|
---|
| 742 | hgeometry_calib=findobj('tag','geometry_calib');
|
---|
| 743 | if ~isempty(hgeometry_calib)
|
---|
| 744 | GUserData=get(hgeometry_calib,'UserData');
|
---|
| 745 | if ~(isfield(GUserData,'XmlInputFile') && strcmp(GUserData.XmlInputFile,filexml))
|
---|
| 746 | answer=msgbox_uvmat('INPUT_Y-N','replace the display of geometry_calib with the new input data?');
|
---|
| 747 | if strcmp(answer,'Yes')
|
---|
| 748 | geometry_calib(filexml);%diplay the new calibration points and parameters in geometry_calib
|
---|
| 749 | end
|
---|
| 750 | end
|
---|
| 751 | end
|
---|
| 752 | end
|
---|
| 753 | elseif exist(fileciv,'file')% if .civ file found
|
---|
| 754 | [error,XmlData.Time,TimeUnit,mode,npx,npy,pxcmx,pxcmy]=read_imatext([FileBase '.civ']);
|
---|
| 755 | GeometryCalib.R=[pxcmx 0 0; 0 pxcmy 0;0 0 0];
|
---|
| 756 | GeometryCalib.Tx=0;
|
---|
| 757 | GeometryCalib.Ty=0;
|
---|
| 758 | GeometryCalib.Tz=1;
|
---|
| 759 | GeometryCalib.dpx=1;
|
---|
| 760 | GeometryCalib.dpy=1;
|
---|
| 761 | GeometryCalib.sx=1;
|
---|
| 762 | GeometryCalib.Cx=0;
|
---|
| 763 | GeometryCalib.Cy=0;
|
---|
| 764 | GeometryCalib.f=1;
|
---|
| 765 | GeometryCalib.kappa1=0;
|
---|
| 766 | GeometryCalib.CoordUnit='cm';
|
---|
| 767 | XmlData.GeometryCalib=GeometryCalib;
|
---|
| 768 | if error==2, warntext=['no file ' FileBase '.civ'];
|
---|
| 769 | elseif error==1, warntext='inconsistent number of fields in the .civ file';
|
---|
| 770 | end
|
---|
| 771 | set(handles.npx,'String',num2str(npx));%fills nbre of pixels x box
|
---|
| 772 | set(handles.npy,'String',num2str(npy));%fills nbre of pixels y box
|
---|
| 773 | set(handles.pxcm,'String',num2str(pxcmx));%fills scale x (pixel/cm) box
|
---|
| 774 | set(handles.pycm,'String',num2str(pxcmy));%fills scale y (pixel/cm) box
|
---|
| 775 | set(handles.pxcm,'Visible','on');%fills scale x (pixel/cm) box
|
---|
| 776 | set(handles.pycm,'Visible','on');%fills scale y (pixel/cm) box
|
---|
| 777 | set(handles.view_xml,'Visible','on')
|
---|
| 778 | set(handles.view_xml,'String','view .civ')
|
---|
| 779 | else
|
---|
| 780 | set(handles.view_xml,'Visible','off')
|
---|
| 781 | end
|
---|
| 782 |
|
---|
| 783 | % store last index in handles.lat_i and .last_j
|
---|
| 784 | if ~isempty(XmlData.Time)
|
---|
| 785 | nbfield=size(XmlData.Time,1);
|
---|
| 786 | nburst=size(XmlData.Time,2);
|
---|
| 787 | %transform .Time to a column vector if it is a line vector the nomenclature uses a single index
|
---|
| 788 | if isequal(nbfield,1) && ~isequal(nburst,1)% .Time is a line vector
|
---|
| 789 | NomType=get(handles.FileIndex,'UserData');
|
---|
| 790 | if numel(NomType)>=2 &&(strcmp(NomType,'_i')||strcmp(NomType(1:2),'%0')||strcmp(NomType(1:2),'_%'))
|
---|
| 791 | XmlData.Time=(XmlData.Time)';
|
---|
| 792 | nbfield=nburst;
|
---|
| 793 | nburst=1;
|
---|
| 794 | end
|
---|
| 795 | end
|
---|
| 796 | end
|
---|
| 797 | last_i_cell=get(handles.last_i,'String');
|
---|
| 798 | if isempty(nbfield)
|
---|
| 799 | last_i_cell{1}='';
|
---|
| 800 | else
|
---|
| 801 | last_i_cell{1}=num2str(nbfield);
|
---|
| 802 | end
|
---|
| 803 | set(handles.last_i,'String',last_i_cell)
|
---|
| 804 | last_j_cell=get(handles.last_j,'String');
|
---|
| 805 | if isempty(nburst)
|
---|
| 806 | last_j_cell{1}='';
|
---|
| 807 | else
|
---|
| 808 | last_j_cell{1}=num2str(nburst);
|
---|
| 809 | end
|
---|
| 810 | set(handles.last_j,'String',last_j_cell);
|
---|
| 811 |
|
---|
| 812 | % store geometric calibration in UvData
|
---|
| 813 | if isfield(XmlData,'GeometryCalib')
|
---|
| 814 | GeometryCalib=XmlData.GeometryCalib;
|
---|
| 815 | if isempty(GeometryCalib)
|
---|
| 816 | set(handles.pxcm,'String','')
|
---|
| 817 | set(handles.pycm,'String','')
|
---|
| 818 | set(handles.transform_fct,'Value',1); % no transform by default
|
---|
| 819 | else
|
---|
| 820 | if (isfield(GeometryCalib,'R')&& ~isequal(GeometryCalib.R(2,1),0) && ~isequal(GeometryCalib.R(1,2),0)) ||...
|
---|
| 821 | (isfield(GeometryCalib,'kappa1')&& ~isequal(GeometryCalib.kappa1,0))
|
---|
| 822 | set(handles.pxcm,'String','var')
|
---|
| 823 | set(handles.pycm,'String','var')
|
---|
| 824 | elseif isfield(GeometryCalib,'fx_fy')
|
---|
| 825 | pixcmx=GeometryCalib.fx_fy(1);%*GeometryCalib.R(1,1)*GeometryCalib.sx/(GeometryCalib.Tz*GeometryCalib.dpx);
|
---|
| 826 | pixcmy=GeometryCalib.fx_fy(2);%*GeometryCalib.R(2,2)/(GeometryCalib.Tz*GeometryCalib.dpy);
|
---|
| 827 | set(handles.pxcm,'String',num2str(pixcmx))
|
---|
| 828 | set(handles.pycm,'String',num2str(pixcmy))
|
---|
| 829 | end
|
---|
| 830 | if ~get(handles.FixLimits,'Value')
|
---|
| 831 | set(handles.transform_fct,'Value',2); % phys transform by default if fixedLimits is off
|
---|
| 832 | end
|
---|
| 833 | if isfield(GeometryCalib,'SliceCoord')
|
---|
| 834 |
|
---|
| 835 | siz=size(GeometryCalib.SliceCoord);
|
---|
| 836 | if siz(1)>1
|
---|
| 837 | NbSlice=siz(1);
|
---|
| 838 | set(handles.slices,'Visible','on')
|
---|
| 839 | set(handles.slices,'Value',1)
|
---|
| 840 | end
|
---|
| 841 | if isfield(GeometryCalib,'VolumeScan') && isequal(GeometryCalib.VolumeScan,'y')
|
---|
| 842 | set(handles.nb_slice,'String','volume')
|
---|
| 843 | else
|
---|
| 844 | set(handles.nb_slice,'String',num2str(NbSlice))
|
---|
| 845 | end
|
---|
| 846 | slices_Callback(hObject, eventdata, handles)
|
---|
| 847 | end
|
---|
| 848 | end
|
---|
| 849 | end
|
---|
| 850 |
|
---|
| 851 | %update the data attached to the uvmat interface
|
---|
| 852 | if ~isempty(TimeUnit)
|
---|
| 853 | set(handles.time_txt,'String',['time (' TimeUnit ')'])
|
---|
| 854 | end
|
---|
| 855 | UvData.TimeUnit=TimeUnit;
|
---|
| 856 | UvData.XmlData=XmlData;
|
---|
| 857 | UvData.NewSeries=1;
|
---|
| 858 | set(handles.uvmat,'UserData',UvData)
|
---|
| 859 |
|
---|
| 860 | %display warning message
|
---|
| 861 | if ~isequal(warntext,'')
|
---|
| 862 | msgbox_uvmat('WARNING',warntext);
|
---|
| 863 | end
|
---|
| 864 |
|
---|
| 865 | % set default options in menu 'Fields'
|
---|
| 866 |
|
---|
[227] | 867 | if ~testima
|
---|
| 868 | testcivx=0;
|
---|
| 869 | hget_field=findobj('Name','get_field');
|
---|
| 870 | % if isequal(FileExt,'.nc')||isequal(FileExt,'.cdf')
|
---|
| 871 | if isempty(hget_field)
|
---|
| 872 | Data=nc2struct(FileName,'ListGlobalAttribute','absolut_time_T0','civ');
|
---|
| 873 | if ~isempty(Data.absolut_time_T0)&& ~isequal(Data.civ,0)%if the new input is Civx
|
---|
| 874 | FieldList=calc_field;
|
---|
| 875 | set(handles.Fields,'String',[{'image'};FieldList;{'get_field...'}]);%standard menu for civx data
|
---|
| 876 | set(handles.Fields,'Value',2) % set menu to 'velocity'
|
---|
| 877 | col_vec=FieldList;
|
---|
| 878 | col_vec(1)=[];%remove 'velocity' option for vector color (must be a scalar)
|
---|
| 879 | testcivx=1;
|
---|
| 880 | end
|
---|
| 881 | else
|
---|
| 882 | hhget_field=guidata(hget_field);
|
---|
| 883 | if ~strcmp(get(hhget_field.inputfile,'String'),FileName)%delete any existing get_field GUI with file name different than the input
|
---|
| 884 | delete(hget_field)
|
---|
| 885 | end
|
---|
| 886 | end
|
---|
| 887 | if ~testcivx
|
---|
| 888 | set(handles.Fields,'Value',1) % set menu to 'get_field...
|
---|
| 889 | set(handles.Fields,'String',{'get_field...'})
|
---|
| 890 | col_vec={'get_field...'};
|
---|
| 891 | end
|
---|
| 892 | set(handles.col_vec,'String',col_vec)
|
---|
| 893 | % else
|
---|
| 894 | % msgbox_uvmat('ERROR',['invalid input file extension ' FileExt])
|
---|
| 895 | % return
|
---|
| 896 | % end
|
---|
| 897 | end
|
---|
[199] | 898 |
|
---|
| 899 | %% set index navigation options and refresh plots
|
---|
| 900 | set(handles.RootPath,'BackgroundColor',[1 1 1])
|
---|
| 901 | drawnow
|
---|
| 902 | set_scan_options(hObject, eventdata, handles)
|
---|
| 903 |
|
---|
| 904 | %------------------------------------------------------------------------
|
---|
| 905 | %--- Set index navigation options for new series input and refresh plot
|
---|
| 906 | %------------------------------------------------------------------------
|
---|
| 907 | function set_scan_options(hObject, eventdata, handles)
|
---|
| 908 |
|
---|
| 909 | % set the corresponding index navigation options
|
---|
| 910 | NomType=get(handles.FileIndex,'UserData');
|
---|
| 911 | NomType_1=get(handles.FileIndex_1,'UserData');
|
---|
| 912 | last_i_str=get(handles.last_i,'String');
|
---|
| 913 | nbfield=str2num(last_i_str{1});
|
---|
| 914 | if numel(last_i_str)==2
|
---|
| 915 | nbfield=min(nbfield,str2num(last_i_str{2}));
|
---|
| 916 | end
|
---|
| 917 | state_j='off'; %default
|
---|
| 918 | scan_option='i';%default
|
---|
| 919 | NomTypeRaw=regexprep(NomType(2:end), '-', '');
|
---|
| 920 | if numel(regexp(NomTypeRaw,'\D'))>=1
|
---|
| 921 | state_j='on';
|
---|
| 922 | if isequal(nbfield,1)
|
---|
| 923 | scan_option='j'; %scan j index by default if nbfield=1
|
---|
| 924 | end
|
---|
| 925 | end
|
---|
| 926 | if ~isempty(NomType_1)
|
---|
| 927 | NomTypeRaw=regexprep(NomType_1(2:end), '-', '');
|
---|
| 928 | if numel(regexp(NomTypeRaw,'\D'))>=1
|
---|
| 929 | state_j='on';
|
---|
| 930 | if isequal(nbfield,1)
|
---|
| 931 | scan_option='j';
|
---|
| 932 | end
|
---|
| 933 | end
|
---|
| 934 | end
|
---|
| 935 | if isequal(scan_option,'i')
|
---|
| 936 | set(handles.scan_i,'Value',1)
|
---|
| 937 | scan_i_Callback(hObject, eventdata, handles);
|
---|
| 938 | else
|
---|
| 939 | set(handles.scan_j,'Value',1)
|
---|
| 940 | scan_j_Callback(hObject, eventdata, handles);
|
---|
| 941 | end
|
---|
| 942 | set(handles.scan_j,'Visible',state_j)
|
---|
| 943 | set(handles.j1,'Visible',state_j)
|
---|
| 944 | set(handles.j2,'Visible',state_j)
|
---|
| 945 | set(handles.last_j,'Visible',state_j);
|
---|
| 946 | set(handles.frame_j,'Visible',state_j);
|
---|
| 947 | set(handles.j_text,'Visible',state_j);
|
---|
[221] | 948 | if strcmp(state_j,'on')
|
---|
| 949 | set(handles.fix_pair,'Visible','on')
|
---|
| 950 | else
|
---|
| 951 | set(handles.fix_pair,'Visible','off')
|
---|
| 952 | end
|
---|
[199] | 953 |
|
---|
| 954 | %% view the field
|
---|
| 955 | run0_Callback(hObject, eventdata, handles); %view field
|
---|
| 956 | mask_test=get(handles.mask_test,'value');
|
---|
| 957 | if mask_test
|
---|
| 958 | MaskData=get(handles.mask_test,'UserData');
|
---|
| 959 | if isfield(MaskData,'maskhandle') && ishandle(MaskData.maskhandle)
|
---|
| 960 | delete(MaskData.maskhandle) %delete old mask
|
---|
| 961 | end
|
---|
| 962 | mask_test_Callback(hObject, eventdata, handles)
|
---|
| 963 | end
|
---|
| 964 |
|
---|
| 965 | %------------------------------------------------------------------------
|
---|
| 966 | % --- Executes on the menu Open/Browse_1 for the second input field,
|
---|
| 967 | % search the files, recognize their type according to their name and fill the rootfile input windows
|
---|
| 968 | function MenuBrowse_1_Callback(hObject, eventdata, handles)
|
---|
| 969 | %------------------------------------------------------------------------
|
---|
| 970 | % huvmat=get(handles.run0,'parent');
|
---|
| 971 | UvData=get(handles.uvmat,'UserData');
|
---|
| 972 |
|
---|
| 973 | RootPath=get(handles.RootPath,'String');
|
---|
| 974 | [FileName, PathName, filterindex] = uigetfile( ...
|
---|
| 975 | {'*.xml;*.xls;*.civ;*.jpg;*.png;*.avi;*.AVI;*.nc;*.cmx;*.fig;*.log;*.dat', ' (*.xml,*.xls,*.civ, *.jpg,*.png, *.avi,*.nc,*.cmx ,*.fig,*.log,*.dat)';
|
---|
| 976 | '*.xml', '.xml files '; ...
|
---|
| 977 | '*.xls', '.xls files '; ...
|
---|
| 978 | '*.civ', '.civ files '; ...
|
---|
| 979 | '*.jpg','.jpg image files'; ...
|
---|
| 980 | '*.png','.png image files'; ...
|
---|
| 981 | '*.avi;*.AVI','.avi movie files'; ...
|
---|
| 982 | '*.nc','.netcdf files'; ...
|
---|
| 983 | '*.cdf','.netcdf files'; ...
|
---|
| 984 | '*.cmx','.cmx text files';...
|
---|
| 985 | '*.cmx2','.cmx2 text files';...
|
---|
| 986 | '*.fig','.fig files (matlab fig)';...
|
---|
| 987 | '*.log','.log text files ';...
|
---|
| 988 | '*.dat','.dat text files ';...
|
---|
| 989 | '*.*', 'All Files (*.*)'}, ...
|
---|
| 990 | 'Pick a file',RootPath);
|
---|
| 991 | fileinput_1=[PathName FileName];%complete file name
|
---|
| 992 | % testblank=findstr(fileinput_1,' ');%look for blanks
|
---|
| 993 | % if ~isempty(testblank)
|
---|
| 994 | % msgbox_uvmat('ERROR',['The input file name ' fileinput_1 ' contains blank character : This is not allowed. Please change name'])
|
---|
| 995 | % return
|
---|
| 996 | % end
|
---|
| 997 | sizf=size(fileinput_1);
|
---|
| 998 | if (~ischar(fileinput_1)||~isequal(sizf(1),1)),return;end
|
---|
| 999 |
|
---|
| 1000 | % refresh the current displayed field
|
---|
| 1001 | display_file_name_1(hObject,eventdata,handles,fileinput_1)
|
---|
| 1002 |
|
---|
| 1003 | %update list of recent files in the menubar
|
---|
| 1004 | MenuFile_1=fileinput_1;
|
---|
| 1005 | MenuFile_2=get(handles.MenuFile_1,'Label');
|
---|
| 1006 | MenuFile_3=get(handles.MenuFile_2,'Label');
|
---|
| 1007 | MenuFile_4=get(handles.MenuFile_3,'Label');
|
---|
| 1008 | MenuFile_5=get(handles.MenuFile_4,'Label');
|
---|
| 1009 | set(handles.MenuFile_1,'Label',MenuFile_1)
|
---|
| 1010 | set(handles.MenuFile_2,'Label',MenuFile_2)
|
---|
| 1011 | set(handles.MenuFile_3,'Label',MenuFile_3)
|
---|
| 1012 | set(handles.MenuFile_4,'Label',MenuFile_4)
|
---|
| 1013 | set(handles.MenuFile_5,'Label',MenuFile_5)
|
---|
| 1014 | set(handles.MenuFile_1_1,'Label',MenuFile_1)
|
---|
| 1015 | set(handles.MenuFile_2_1,'Label',MenuFile_2)
|
---|
| 1016 | set(handles.MenuFile_3_1,'Label',MenuFile_3)
|
---|
| 1017 | set(handles.MenuFile_4_1,'Label',MenuFile_4)
|
---|
| 1018 | set(handles.MenuFile_5_1,'Label',MenuFile_5)
|
---|
| 1019 | dir_perso=prefdir;
|
---|
| 1020 | profil_perso=fullfile(dir_perso,'uvmat_perso.mat');
|
---|
| 1021 | if exist(profil_perso,'file')
|
---|
| 1022 | save (profil_perso,'MenuFile_1','MenuFile_2','MenuFile_3','MenuFile_4', 'MenuFile_5','-append'); %store the file names for future opening of uvmat
|
---|
| 1023 | else
|
---|
| 1024 | txt=ver('MATLAB');
|
---|
| 1025 | Release=txt.Release;
|
---|
| 1026 | relnumb=str2double(Release(3:4));
|
---|
| 1027 | if relnumb >= 14
|
---|
| 1028 | save (profil_perso,'MenuFile_1','MenuFile_2','MenuFile_3','MenuFile_4', 'MenuFile_5','-V6'); %store the file names for future opening of uvmat
|
---|
| 1029 | else
|
---|
| 1030 | save (profil_perso,'MenuFile_1','MenuFile_2','MenuFile_3','MenuFile_4', 'MenuFile_5'); %store the file names for future opening of uvmat
|
---|
| 1031 | end
|
---|
| 1032 | end
|
---|
| 1033 |
|
---|
| 1034 | % -----------------------------------------------------------------------
|
---|
| 1035 | % --- Open again as second field the file whose name has been recorded in MenuFile_1
|
---|
| 1036 | function MenuFile_1_1_Callback(hObject, eventdata, handles)
|
---|
| 1037 | % -----------------------------------------------------------------------
|
---|
| 1038 | fileinput_1=get(handles.MenuFile_1_1,'Label');
|
---|
| 1039 | display_file_name_1(hObject,eventdata,handles,fileinput_1)
|
---|
| 1040 |
|
---|
| 1041 | % -----------------------------------------------------------------------
|
---|
| 1042 | % --- Open again as second field the file whose name has been recorded in MenuFile_2
|
---|
| 1043 | function MenuFile_2_1_Callback(hObject, eventdata, handles)
|
---|
| 1044 | % -----------------------------------------------------------------------
|
---|
| 1045 | fileinput_1=get(handles.MenuFile_2_1,'Label');
|
---|
| 1046 | display_file_name_1(hObject,eventdata,handles,fileinput_1)
|
---|
| 1047 |
|
---|
| 1048 | % -----------------------------------------------------------------------
|
---|
| 1049 | % --- Open again as second field the file whose name has been recorded in MenuFile_3
|
---|
| 1050 | function MenuFile_3_1_Callback(hObject, eventdata, handles)
|
---|
| 1051 | % -----------------------------------------------------------------------
|
---|
| 1052 | fileinput_1=get(handles.MenuFile_3_1,'Label');
|
---|
| 1053 | display_file_name_1(hObject,eventdata,handles,fileinput_1)
|
---|
| 1054 |
|
---|
| 1055 | % -----------------------------------------------------------------------
|
---|
| 1056 | % --- Open again as second field the file whose name has been recorded in MenuFile_4
|
---|
| 1057 | function MenuFile_4_1_Callback(hObject, eventdata, handles)
|
---|
| 1058 | % -----------------------------------------------------------------------
|
---|
| 1059 | fileinput_1=get(handles.MenuFile_4_1,'Label');
|
---|
| 1060 | display_file_name_1(hObject,eventdata,handles,fileinput_1)
|
---|
| 1061 |
|
---|
| 1062 | % -----------------------------------------------------------------------
|
---|
| 1063 | % --- Open again as second field the file whose name has been recorded in MenuFile_5
|
---|
| 1064 | function MenuFile_5_1_Callback(hObject, eventdata, handles)
|
---|
| 1065 | % -----------------------------------------------------------------------
|
---|
| 1066 | fileinput_1=get(handles.MenuFile_5_1,'Label');
|
---|
| 1067 | display_file_name_1(hObject,eventdata,handles,fileinput_1)
|
---|
| 1068 |
|
---|
| 1069 | %------------------------------------------------------------------------
|
---|
| 1070 | % fills the edit boxes RootPath_1, RootFile_1,NomType_1...from an input file name 'fileinput_1'
|
---|
| 1071 | %------------------------------------------------------------------------
|
---|
| 1072 | function display_file_name_1(hObject,eventdata,handles,fileinput_1)
|
---|
| 1073 |
|
---|
| 1074 | %[path,name,ext]=fileparts(fileinput_1);
|
---|
| 1075 | [RootPath_1,RootFile_1,field_count,str2,str_a,str_b,FileExt_1,NomType_1,SubDir_1]=name2display(fileinput_1);
|
---|
| 1076 | nbfield_1=1; %default
|
---|
| 1077 | ext_test=FileExt_1;%default
|
---|
| 1078 | form=imformats(FileExt_1(2:end));
|
---|
| 1079 | if ~isempty(form) % if the extension corresponds to an image format recognized by Matlab
|
---|
| 1080 | imainfo=imfinfo(fileinput_1);
|
---|
| 1081 | nbfield_1=length(imainfo);
|
---|
| 1082 | ext_test='.image';
|
---|
| 1083 | elseif isequal(lower(FileExt_1),'.avi')
|
---|
| 1084 | info=aviinfo(fileinput_1);
|
---|
| 1085 | nbfield_1=info.NumFrames;
|
---|
| 1086 | ext_test='.image';
|
---|
| 1087 | end
|
---|
| 1088 |
|
---|
| 1089 | %open directly fig or text files
|
---|
| 1090 | switch ext_test
|
---|
| 1091 | case {'.civ','.log','.cmx','.cmx2','.txt'} %display text file
|
---|
| 1092 | edit(fileinput)
|
---|
| 1093 | return
|
---|
| 1094 | case '.fig' %display matlab figure
|
---|
| 1095 | hfig=open(fileinput);
|
---|
| 1096 | set(hfig,'WindowButtonMotionFcn','mouse_motion')%set mouse action functio
|
---|
| 1097 | set(hfig,'WindowButtonUpFcn','mouse_up')%set mouse click action function
|
---|
| 1098 | set(hfig,'WindowButtonUpFcn','mouse_down')%set mouse click action function
|
---|
| 1099 | return
|
---|
| 1100 | case {'.xml','.xls'} % edit xml or Excel files
|
---|
| 1101 | heditxml=editxml(fileinput);
|
---|
| 1102 | return
|
---|
| 1103 | case {'.image','.nc','.cdf'}
|
---|
| 1104 | % set(handles.FileIndex,'UserData',NomType_1);
|
---|
| 1105 | otherwise
|
---|
| 1106 | msgbox_uvmat(['invalid input file extension ' FileExt_1 ' for uvmat'],'ERROR')
|
---|
| 1107 | return
|
---|
| 1108 | end
|
---|
| 1109 |
|
---|
| 1110 | % test for image series in a single file and synchronise file indices of the two series
|
---|
| 1111 | if nbfield_1 >1 %case of image with multiple frames
|
---|
| 1112 | if nbfield_1 < num_i1
|
---|
| 1113 | msgbox_uvmat('ERROR','current frame index beyond the input movie length')
|
---|
| 1114 | return
|
---|
| 1115 | else
|
---|
| 1116 | NomType_1='*'; %indicate a set of indexed frames within a single file
|
---|
| 1117 | filename_new=fileinput_1;
|
---|
| 1118 | end
|
---|
| 1119 | else % cases of data files
|
---|
| 1120 | RootPath=get(handles.RootPath,'String');
|
---|
| 1121 | RootFile=get(handles.RootFile,'String');
|
---|
| 1122 | FileBase=fullfile(RootPath,RootFile);
|
---|
| 1123 | FileBase_1=fullfile(RootPath_1,RootFile_1);
|
---|
| 1124 | if isequal(FileBase,FileBase_1)
|
---|
| 1125 | filename_new=fileinput_1;
|
---|
| 1126 | else
|
---|
| 1127 | num_i1=stra2num(get(handles.i1,'String'));%get the current file indices from counters
|
---|
| 1128 | num_j1=stra2num(get(handles.j1,'String'));
|
---|
| 1129 | num_i2=stra2num(get(handles.i2,'String'));
|
---|
| 1130 | num_j2=stra2num(get(handles.j2,'String'));
|
---|
| 1131 | [filename_new,idetect]=...
|
---|
| 1132 | 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
|
---|
| 1133 | indices=''; %default
|
---|
| 1134 | if ~idetect
|
---|
| 1135 | msgbox_uvmat('ERROR','second input file with indices corresponding to the first one does not exist')
|
---|
| 1136 | return
|
---|
| 1137 | end
|
---|
| 1138 | end
|
---|
| 1139 | end
|
---|
| 1140 | set(handles.FileIndex_1,'UserData',NomType_1);
|
---|
| 1141 |
|
---|
| 1142 | % make visible and fill the second raw of edit boxes
|
---|
| 1143 | set(handles.RootPath_1,'Visible','on')
|
---|
| 1144 | set(handles.RootFile_1,'Visible','on')
|
---|
| 1145 | set(handles.SubDir_1,'Visible','on');
|
---|
| 1146 | set(handles.FileIndex_1,'Visible','on');
|
---|
| 1147 | set(handles.FileExt_1,'Visible','on');
|
---|
| 1148 | [FileName,RootPath,FileBase,FileIndices,FileExt,SubDir]=read_file_boxes(handles);
|
---|
| 1149 | if isequal(FileBase,FileBase_1)
|
---|
| 1150 | set(handles.RootPath_1,'String','"')
|
---|
| 1151 | set(handles.RootFile_1,'String','"');
|
---|
| 1152 | else
|
---|
| 1153 | set(handles.RootPath_1,'String',RootPath_1)
|
---|
| 1154 | set(handles.RootFile_1,'String',['/' RootFile_1]);
|
---|
| 1155 | end
|
---|
| 1156 | if isequal(SubDir_1,'')
|
---|
| 1157 | set(handles.SubDir_1,'String','');
|
---|
| 1158 | FileBaseSub_1=FileBase_1;
|
---|
| 1159 | else
|
---|
| 1160 | set(handles.SubDir_1,'String',['/' SubDir_1]);
|
---|
| 1161 | FileBaseSub_1=fullfile(FileBase_1,SubDir_1);
|
---|
| 1162 | end
|
---|
| 1163 | indices=filename_new(length(FileBaseSub_1)+1:end);
|
---|
| 1164 | indices(end-length(FileExt_1)+1:end)=[]; %remove extension
|
---|
| 1165 | set(handles.FileIndex_1,'String',indices)
|
---|
| 1166 | set(handles.FileIndex_1,'UserData',NomType_1)
|
---|
| 1167 | set(handles.FileExt_1,'String',FileExt_1);
|
---|
| 1168 |
|
---|
| 1169 | % % default choice of fields
|
---|
| 1170 | % if isequal(ext_test,'.image')
|
---|
| 1171 | % % set(handles.Fields_1,'String',{'';'image';'get_field...';'velocity';'vort';'div';'more...'})
|
---|
| 1172 | % % set(handles.Fields_1,'Value',2) % set menu to 'image'
|
---|
| 1173 | % elseif strcmp(FileExt_1,'.nc')||strcmp(FileExt_1,'.cdf')
|
---|
| 1174 | % Data=nc2struct(fileinput_1,[]);
|
---|
| 1175 | % % if isfield(Data,'absolut_time_T0')
|
---|
| 1176 | % % set(handles.Fields_1,'String',{'';'image';'get_field...';'velocity';'vort';'div';'more...'})
|
---|
| 1177 | % % set(handles.Fields_1,'Value',4) % set menu to 'velocity'
|
---|
| 1178 | % % else
|
---|
| 1179 | % % set(handles.Fields_1,'Value',2) % set menu to 'get_field...'
|
---|
| 1180 | % % set(handles.Fields_1,'String',{'';'get_field...'});
|
---|
| 1181 | % % end
|
---|
| 1182 | % end
|
---|
| 1183 | set(handles.SubField,'Visible','on')
|
---|
| 1184 | set(handles.SubField,'Value',1)
|
---|
| 1185 | RootPath_1_Callback(hObject,eventdata,handles);
|
---|
| 1186 |
|
---|
| 1187 | %-----------------------------------------------------------------------
|
---|
| 1188 | % --- Called by action in RootPath_1 edit box
|
---|
| 1189 | function RootPath_1_Callback(hObject,eventdata,handles)
|
---|
| 1190 | % -----------------------------------------------------------------------
|
---|
| 1191 | update_rootinfo_1(hObject,eventdata,handles)
|
---|
| 1192 |
|
---|
| 1193 | %-----------------------------------------------------------------------
|
---|
| 1194 | % --- Called by action in RootFile_1 edit box
|
---|
| 1195 | function RootFile_1_Callback(hObject, eventdata, handles)
|
---|
| 1196 | % -----------------------------------------------------------------------
|
---|
| 1197 | update_rootinfo_1(hObject,eventdata,handles)
|
---|
| 1198 |
|
---|
| 1199 | %------------------------------------------------------------------------
|
---|
| 1200 | % --- Called by action in FileIndex_1 edit box
|
---|
| 1201 | function FileIndex_1_Callback(hObject, eventdata, handles)
|
---|
| 1202 | %------------------------------------------------------------------------
|
---|
| 1203 | run0_Callback(hObject, eventdata, handles)
|
---|
| 1204 |
|
---|
| 1205 | %------------------------------------------------------------------------
|
---|
| 1206 | % --- Update information about a new second field series (indices to scan, timing,
|
---|
| 1207 | % calibration from an xml file, then refresh current plots
|
---|
| 1208 | function update_rootinfo_1(hObject,eventdata,handles) %A REVOIR
|
---|
| 1209 | % -----------------------------------------------------------------------
|
---|
| 1210 | set(handles.RootPath_1,'BackgroundColor',[1 1 0])% indicate active program by yellow color
|
---|
| 1211 | drawnow
|
---|
| 1212 | UvData=get(handles.uvmat,'UserData');%huvmat=handles of the uvmat interface
|
---|
| 1213 | UvData.NewSeries=1; %flag for run0: begin a new series
|
---|
| 1214 |
|
---|
| 1215 | [FileName,RootPath,FileBase,FileIndices,FileExt,SubDir]=read_file_boxes_1(handles);
|
---|
| 1216 | if ~exist(FileName,'file')
|
---|
| 1217 | msgbox_uvmat('ERROR',['input file ' FileName ' not found']);
|
---|
| 1218 | end
|
---|
| 1219 | nbfield_1=[];%default
|
---|
| 1220 | nburst_1=[];%default
|
---|
| 1221 | XmlData.Time=[];
|
---|
| 1222 | XmlData.GeometryCalib=[];%default
|
---|
| 1223 | TimeUnit=[];
|
---|
| 1224 | if isfield(UvData,'TimeUnit')
|
---|
| 1225 | TimeUnit=UvData.TimeUnit;
|
---|
| 1226 | end
|
---|
| 1227 | TimeUnit_1=[];
|
---|
| 1228 | hhh='';%default, test for movie reading with mmreader
|
---|
| 1229 | imainfo=[];
|
---|
| 1230 | if isequal(lower(FileExt),'.avi') %.avi file
|
---|
| 1231 | imainfo=aviinfo([FileBase FileIndices FileExt]);
|
---|
| 1232 | nbfield_1=imainfo.NumFrames;
|
---|
| 1233 | nburst_1=1;
|
---|
| 1234 | set(handles.Dt_txt,'String',['Dt=' num2str(1000/info.FramesPerSecond) 'ms']);%display the elementary time interval in millisec
|
---|
| 1235 | time=(0:1/imainfo.FramesPerSecond:(imainfo.NumFrames-1)/imainfo.FramesPerSecond)';
|
---|
| 1236 | ColorType=imainfo.ImageType;%='truecolor' for color images
|
---|
| 1237 | hhh=which('mmreader');
|
---|
| 1238 | elseif ~isempty(imformats(FileExt(2:end)))|| isequal(FileExt,'.vol')
|
---|
| 1239 | if ~isequal(SubDir,'')
|
---|
| 1240 | RootFile=get(handles.RootFile,'String');
|
---|
| 1241 | imainfo=imfinfo([fullfile(RootPath,SubDir,RootFile) FileIndices FileExt]);
|
---|
| 1242 | else
|
---|
| 1243 | imainfo=imfinfo([FileBase FileIndices FileExt]);
|
---|
| 1244 | end
|
---|
| 1245 | ColorType=imainfo.ColorType;%='truecolor' for color images
|
---|
| 1246 | if length(imainfo) >1 %case of image with multiple frames
|
---|
| 1247 | nbfield_1=length(imainfo);
|
---|
| 1248 | nburst_1=1;
|
---|
| 1249 | end
|
---|
| 1250 | end
|
---|
| 1251 | if ~strcmp(hhh,'')&& mmreader.isPlatformSupported()% if the function is found (recent version of matlab)
|
---|
| 1252 | UvData.MovieObject_1=mmreader([FileBase FileIndices FileExt]);
|
---|
| 1253 | elseif isfield(UvData,'MovieObject_1')
|
---|
| 1254 | UvData=rmfield(UvData,'MovieObject_1');
|
---|
| 1255 | end
|
---|
| 1256 | if ~isempty(imainfo)% (an image has been introduced as second fierld input)
|
---|
| 1257 | if strcmp(get(handles.npx,'String'),'') || strcmp(get(handles.npy,'String'),'')%update npx and npy if it is not already filled by the first input field
|
---|
| 1258 | if isfield(imainfo,'Width') && isfield(imainfo,'Height')
|
---|
| 1259 | set(handles.npx,'String',num2str(imainfo.Width));%fills nbre of pixels x box
|
---|
| 1260 | set(handles.npy,'String',num2str(imainfo.Height));%fills nbre of pixels x box
|
---|
| 1261 | else
|
---|
| 1262 | set(handles.npx,'String','');%fills nbre of pixels x box
|
---|
| 1263 | set(handles.npy,'String','');%fills nbre of pixels x box
|
---|
| 1264 | end
|
---|
| 1265 | set(handles.BW,'Value',strcmp(ColorType,'grayscale'))% select handles.BW if grayscale image
|
---|
| 1266 | end
|
---|
| 1267 | end
|
---|
| 1268 | % find scaling parameters
|
---|
| 1269 | filexml=[FileBase '.xml'];
|
---|
| 1270 | fileciv=[FileBase '.civ'];
|
---|
| 1271 | warntext='';%default warning text
|
---|
| 1272 | if exist(filexml,'file')
|
---|
| 1273 | [XmlData,warntext]=imadoc2struct(filexml);
|
---|
| 1274 | if ~isempty(warntext)
|
---|
| 1275 | msgbox_uvmat('WARNING',warntext)
|
---|
| 1276 | end
|
---|
| 1277 | if isfield(XmlData,'Camera')
|
---|
| 1278 | if isfield(XmlData.Camera,'TimeUnit')&& ~isempty(XmlData.Camera.TimeUnit)
|
---|
| 1279 | TimeUnit=XmlData.Camera.TimeUnit;
|
---|
| 1280 | end
|
---|
| 1281 | end
|
---|
| 1282 | elseif exist(fileciv,'file')% if .civ file found
|
---|
| 1283 | [error,XmlData.Time,TimeUnit,mode,npx,npy,pxcmx,pxcmy]=read_imatext([FileBase '.civ']);
|
---|
| 1284 | GeometryCalib.R=[pxcmx 0 0; 0 pxcmy 0;0 0 0];
|
---|
| 1285 | GeometryCalib.Tx=0;
|
---|
| 1286 | GeometryCalib.Ty=0;
|
---|
| 1287 | GeometryCalib.Tz=1;
|
---|
| 1288 | GeometryCalib.dpx=1;
|
---|
| 1289 | GeometryCalib.dpy=1;
|
---|
| 1290 | GeometryCalib.sx=1;
|
---|
| 1291 | GeometryCalib.Cx=0;
|
---|
| 1292 | GeometryCalib.Cy=0;
|
---|
| 1293 | GeometryCalib.f=1;
|
---|
| 1294 | GeometryCalib.kappa1=0;
|
---|
| 1295 | GeometryCalib.CoordUnit='cm';
|
---|
| 1296 | XmlData.GeometryCalib=GeometryCalib;
|
---|
| 1297 | if error==2, warntext=['no file ' FileBase '.civ'];
|
---|
| 1298 | elseif error==1, warntext='inconsistent number of fields in the .civ file';
|
---|
| 1299 | end
|
---|
| 1300 |
|
---|
| 1301 | set(handles.npx,'String',num2str(npx));%fills nbre of pixels x box
|
---|
| 1302 | set(handles.npy,'String',num2str(npy));%fills nbre of pixels y box
|
---|
| 1303 | set(handles.pxcm,'String',num2str(pxcmx));%fills scale x (pixel/cm) box
|
---|
| 1304 | set(handles.pycm,'String',num2str(pxcmy));%fills scale y (pixel/cm) box
|
---|
| 1305 | set(handles.pxcm,'Visible','on');%fills scale x (pixel/cm) box
|
---|
| 1306 | set(handles.pycm,'Visible','on');%fills scale y (pixel/cm) box
|
---|
| 1307 | end
|
---|
| 1308 | if ~isempty(TimeUnit_1) && ~isequal(TimeUnit_1,TimeUnit)
|
---|
| 1309 | msgbox_uvmat('WARNING','the time units for the second series differs from the first one')
|
---|
| 1310 | end
|
---|
| 1311 |
|
---|
| 1312 | % store last index in handles.lat_i and .last_j
|
---|
| 1313 | if ~isempty(XmlData.Time)
|
---|
| 1314 | nbfield_1=size(XmlData.Time,1);
|
---|
| 1315 | nburst_1=size(XmlData.Time,2);
|
---|
| 1316 | end
|
---|
| 1317 | last_i_cell=get(handles.last_i,'String');
|
---|
| 1318 | if isempty(nbfield_1)
|
---|
| 1319 | last_i_cell{2}='';
|
---|
| 1320 | else
|
---|
| 1321 | last_i_cell{2}=num2str(nbfield_1);
|
---|
| 1322 | end
|
---|
| 1323 | set(handles.last_i,'String',last_i_cell)
|
---|
| 1324 | last_j_cell=get(handles.last_j,'String');
|
---|
| 1325 | if isempty(nburst_1)
|
---|
| 1326 | last_j_cell{2}='';
|
---|
| 1327 | else
|
---|
| 1328 | last_j_cell{2}=num2str(nburst_1);
|
---|
| 1329 | end
|
---|
| 1330 | set(handles.last_j,'String',last_j_cell);
|
---|
| 1331 | if ~isequal(last_i_cell{1},last_i_cell{2}) || ~isequal(last_j_cell{1},last_j_cell{2})
|
---|
| 1332 | msgbox_uvmat('WARNING','the numbers of input file of the second series differs from the first one')
|
---|
| 1333 | end
|
---|
| 1334 |
|
---|
| 1335 | % store calibration data
|
---|
| 1336 | GeometryCalib=XmlData.GeometryCalib;
|
---|
| 1337 | if isempty(GeometryCalib)
|
---|
| 1338 | if isfield(UvData, 'GeometryCalib_1')
|
---|
| 1339 | UvData=rmfield(UvData,'GeometryCalib_1');
|
---|
| 1340 | end
|
---|
| 1341 | else
|
---|
| 1342 | UvData.GeometryCalib_1=GeometryCalib;
|
---|
| 1343 | if (isfield(GeometryCalib,'R')&& ~isequal(GeometryCalib.R(2,1),0) && ~isequal(GeometryCalib.R(1,2),0)) ||...
|
---|
| 1344 | (isfield(GeometryCalib,'kappa1')&& ~isequal(GeometryCalib.kappa1,0))
|
---|
| 1345 | set(handles.pxcm,'String','var')
|
---|
| 1346 | set(handles.pycm,'String','var')
|
---|
| 1347 | else
|
---|
| 1348 | if isfield(GeometryCalib,'fx_fy')
|
---|
| 1349 | pixcmx=GeometryCalib.fx_fy(1);
|
---|
| 1350 | pixcmy=GeometryCalib.fx_fy(2);
|
---|
| 1351 | set(handles.pxcm,'String',num2str(pixcmx))
|
---|
| 1352 | set(handles.pycm,'String',num2str(pixcmy))
|
---|
| 1353 | end
|
---|
| 1354 | end
|
---|
| 1355 | end
|
---|
| 1356 | UvData.XmlData_1=XmlData;
|
---|
| 1357 | set(handles.uvmat,'UserData',UvData)%update the data attached to the uvmat interface
|
---|
| 1358 |
|
---|
| 1359 | if ~isequal(warntext,'')
|
---|
| 1360 | msgbox_uvmat('WARNING',warntext)
|
---|
| 1361 | end
|
---|
| 1362 |
|
---|
| 1363 | set(handles.RootPath_1,'BackgroundColor',[1 1 1])% signa the end the input operation
|
---|
| 1364 | drawnow
|
---|
| 1365 |
|
---|
| 1366 | set_scan_options(hObject, eventdata, handles)
|
---|
| 1367 |
|
---|
| 1368 | %---------------------------------------------------
|
---|
| 1369 | % switch file index scanning options scan_i and scan_j in an exclusive way
|
---|
| 1370 | function scan_i_Callback(hObject, eventdata, handles)
|
---|
| 1371 | %---------------------------------------------------
|
---|
| 1372 | if get(handles.scan_i,'Value')==1
|
---|
| 1373 | set(handles.scan_i,'BackgroundColor',[1 1 0])
|
---|
| 1374 | set(handles.scan_j,'Value',0)
|
---|
| 1375 | % set(handles.scan_j,'BackgroundColor',[0.831 0.816 0.784])
|
---|
| 1376 | else
|
---|
| 1377 | set(handles.scan_i,'BackgroundColor',[0.831 0.816 0.784])
|
---|
| 1378 | set(handles.scan_j,'Value',1)
|
---|
| 1379 | % set(handles.scan_j,'BackgroundColor',[1 1 0])
|
---|
| 1380 | end
|
---|
| 1381 | scan_j_Callback(hObject, eventdata, handles)
|
---|
| 1382 |
|
---|
| 1383 | %-------------------------------------------------------------------
|
---|
| 1384 | % switch file index scanning options scan_i and scan_j in an exclusive way
|
---|
| 1385 | function scan_j_Callback(hObject, eventdata, handles)
|
---|
| 1386 | %-------------------------------------------------------------------
|
---|
| 1387 | if get(handles.scan_j,'Value')==1
|
---|
| 1388 | set(handles.scan_j,'BackgroundColor',[1 1 0])
|
---|
| 1389 | set(handles.scan_i,'Value',0)
|
---|
| 1390 | set(handles.scan_i,'BackgroundColor',[0.831 0.816 0.784])
|
---|
[227] | 1391 | NomType=get(handles.FileIndex,'UserData');
|
---|
[199] | 1392 | switch NomType
|
---|
| 1393 | case {'_i_j1-j2','#_ab','%3dab'},% pair with j index
|
---|
| 1394 | set(handles.fix_pair,'Visible','on')% option fixed pair on/off made visible (choice of avaible pair with buttons + and - if ='off')
|
---|
| 1395 | otherwise
|
---|
| 1396 | set(handles.fix_pair,'Visible','off')
|
---|
| 1397 | end
|
---|
| 1398 | else
|
---|
| 1399 | set(handles.scan_j,'BackgroundColor',[0.831 0.816 0.784])
|
---|
| 1400 | set(handles.scan_i,'Value',1)
|
---|
| 1401 | set(handles.scan_i,'BackgroundColor',[1 1 0])
|
---|
| 1402 | set(handles.fix_pair,'Visible','off')
|
---|
| 1403 | end
|
---|
| 1404 |
|
---|
| 1405 | %-------------------------------------------------------------------
|
---|
| 1406 | function i1_Callback(hObject, eventdata, handles)
|
---|
| 1407 | %-------------------------------------------------------------------
|
---|
| 1408 | set(handles.i1,'BackgroundColor',[0.7 0.7 0.7])
|
---|
| 1409 | NomType=get(handles.FileIndex,'UserData');
|
---|
| 1410 | num1=stra2num(get(handles.i1,'String'));
|
---|
| 1411 | num2=stra2num(get(handles.i2,'String'));
|
---|
| 1412 | num_a=stra2num(get(handles.j1,'String'));
|
---|
| 1413 | num_b=stra2num(get(handles.j2,'String'));
|
---|
| 1414 | indices=name_generator('',num1,num_a,'',NomType,1,num2,num_b,'');
|
---|
| 1415 | set(handles.FileIndex,'String',indices)
|
---|
| 1416 | set(handles.FileIndex,'BackgroundColor',[0.7 0.7 0.7])
|
---|
| 1417 | if get(handles.SubField,'Value')==1
|
---|
| 1418 | NomType_1=get(handles.FileIndex_1,'String');
|
---|
| 1419 | FileExt_1=get(handles.FileExt_1,'String');
|
---|
| 1420 | [P,F,str1,str2,str_a,str_b,Ext,NomType_1]=name2display(['xx' NomType_1 FileExt_1]);
|
---|
| 1421 | indices=name_generator('',num1,num_a,'',NomType_1,1,num2,num_b,'');
|
---|
| 1422 | set(handles.FileIndex_1,'String',indices)
|
---|
| 1423 | set(handles.FileIndex_1,'BackgroundColor',[0.7 0.7 0.7])
|
---|
| 1424 | end
|
---|
| 1425 | %Run0_Callback(hObject, eventdata, handles)
|
---|
| 1426 |
|
---|
| 1427 | %-------------------------------------------------------------------
|
---|
| 1428 | function i2_Callback(hObject, eventdata, handles)
|
---|
| 1429 | set(handles.i2,'BackgroundColor',[0.7 0.7 0.7])
|
---|
| 1430 | i1_Callback(hObject, eventdata, handles)
|
---|
| 1431 | %-------------------------------------------------------------------
|
---|
| 1432 |
|
---|
| 1433 | %-------------------------------------------------------------------
|
---|
| 1434 | function j1_Callback(hObject, eventdata, handles)
|
---|
| 1435 | set(handles.j1,'BackgroundColor',[0.7 0.7 0.7])
|
---|
| 1436 | i1_Callback(hObject, eventdata, handles)
|
---|
| 1437 | %-------------------------------------------------------------------
|
---|
| 1438 |
|
---|
| 1439 | %-------------------------------------------------------------------
|
---|
| 1440 | function j2_Callback(hObject, eventdata, handles)
|
---|
| 1441 | set(handles.j2,'BackgroundColor',[0.7 0.7 0.7])
|
---|
| 1442 | i1_Callback(hObject, eventdata, handles)
|
---|
| 1443 | %-------------------------------------------------------------------
|
---|
| 1444 |
|
---|
| 1445 | %-------------------------------------------------------------------
|
---|
| 1446 | function slices_Callback(hObject, eventdata, handles)
|
---|
| 1447 | %-------------------------------------------------------------------
|
---|
| 1448 | if get(handles.slices,'Value')==1
|
---|
| 1449 | set(handles.slices,'BackgroundColor',[1 1 0])
|
---|
| 1450 | set(handles.nb_slice,'Visible','on')
|
---|
| 1451 | set(handles.z_text,'Visible','on')
|
---|
| 1452 | set(handles.z_index,'Visible','on')
|
---|
| 1453 | nb_slice_Callback(hObject, eventdata, handles)
|
---|
| 1454 | else
|
---|
| 1455 | set(handles.nb_slice,'Visible','off')
|
---|
| 1456 | set(handles.slices,'BackgroundColor',[0.7 0.7 0.7])
|
---|
| 1457 | set(handles.z_text,'Visible','off')
|
---|
| 1458 | set(handles.z_index,'Visible','off')
|
---|
| 1459 | set(handles.masklevel,'Value',1)
|
---|
| 1460 | set(handles.masklevel,'String',{'1'})
|
---|
| 1461 | end
|
---|
| 1462 |
|
---|
| 1463 | %-------------------------------------------------------------------
|
---|
| 1464 | function nb_slice_Callback(hObject, eventdata, handles)
|
---|
| 1465 | %-------------------------------------------------------------------
|
---|
| 1466 | nb_slice_str=get(handles.nb_slice,'String');
|
---|
| 1467 | if isequal(nb_slice_str,'volume')
|
---|
| 1468 | num=stra2num(get(handles.j1,'String'));
|
---|
| 1469 | last_j=get(handles.last_j,'String');
|
---|
| 1470 | nbslice=str2double(last_j{1});
|
---|
| 1471 | else
|
---|
| 1472 | num=str2double(get(handles.i1,'String'));
|
---|
| 1473 | nbslice=str2double(get(handles.nb_slice,'String'));
|
---|
| 1474 | end
|
---|
| 1475 | z=mod(num-1,nbslice)+1;
|
---|
| 1476 | set(handles.z_index,'String',num2str(z))
|
---|
| 1477 | for ilist=1:nbslice
|
---|
| 1478 | list_index{ilist,1}=num2str(ilist);
|
---|
| 1479 | end
|
---|
| 1480 | set(handles.masklevel,'String',list_index)
|
---|
| 1481 | set(handles.masklevel,'Value',z)
|
---|
| 1482 |
|
---|
| 1483 | %------------------------------------------------------------------------
|
---|
| 1484 | % --- Executes on button press in view_xml.
|
---|
| 1485 | function view_xml_Callback(hObject, eventdata, handles)
|
---|
| 1486 | %------------------------------------------------------------------------
|
---|
| 1487 | [FileName,RootPath,FileBase,FileIndices,FileExt]=read_file_boxes(handles);
|
---|
| 1488 | option=get(handles.view_xml,'String');
|
---|
| 1489 | if isequal(option,'view .xml')
|
---|
| 1490 | FileXml=[FileBase '.xml'];
|
---|
| 1491 | heditxml=editxml(FileXml);
|
---|
| 1492 | end
|
---|
| 1493 |
|
---|
| 1494 | %------------------------------------------------------------------------
|
---|
| 1495 | % --- Executes on button press in mask_test.
|
---|
| 1496 | function mask_test_Callback(hObject, eventdata, handles)
|
---|
| 1497 | %------------------------------------------------------------------------
|
---|
| 1498 | %case of view mask selection
|
---|
| 1499 | if isequal(get(handles.mask_test,'Value'),1)
|
---|
| 1500 | [FF,RootPath,FileBase]=read_file_boxes(handles);
|
---|
| 1501 | num_i1=stra2num(get(handles.i1,'String'));
|
---|
| 1502 | num_j1=stra2num(get(handles.j1,'String'));
|
---|
| 1503 | currentdir=pwd;
|
---|
| 1504 | cd(RootPath);
|
---|
| 1505 | maskfiles=dir('*_*mask_*.png');%look for a mask file
|
---|
| 1506 | cd(currentdir);%come back to the working directory
|
---|
| 1507 | mdetect=0;
|
---|
| 1508 | if ~isempty(maskfiles)
|
---|
| 1509 | for ilist=1:length(maskfiles)
|
---|
| 1510 | maskname=maskfiles(ilist).name;% take the first mask file in the list
|
---|
| 1511 | [rr,ff,x1,x2,xa,xb,xext,Mask_NomType{ilist}]=name2display(maskname);
|
---|
| 1512 | if ~strcmp(Mask_NomType{ilist},Mask_NomType{1})
|
---|
| 1513 | msgbox_uvmat('ERROR',['inconsistent mask types ' Mask_NomType{1} Mask_NomType{ilist } ' coexist in the current image directory'])
|
---|
| 1514 | return
|
---|
| 1515 | end
|
---|
| 1516 | [Path2,Name,ext]=fileparts(maskname);
|
---|
| 1517 | Namedouble=double(Name);
|
---|
| 1518 | val=(48>Namedouble)|(Namedouble>57);% select the non-numerical characters
|
---|
| 1519 | ind_mask=findstr('mask',Name);
|
---|
| 1520 | i=ind_mask-1;
|
---|
| 1521 | while val(i)==0 && i>0
|
---|
| 1522 | i=i-1;
|
---|
| 1523 | end
|
---|
| 1524 | nbmask_str=str2num(Name(i+1:ind_mask-1));
|
---|
| 1525 | if ~isempty(nbmask_str)
|
---|
| 1526 | nbslice(ilist)=nbmask_str; % number of different masks (slices)
|
---|
| 1527 | end
|
---|
| 1528 | end
|
---|
| 1529 | if isequal(min(nbslice),max(nbslice))
|
---|
| 1530 | nbslice=nbslice(1);
|
---|
| 1531 | else
|
---|
| 1532 | msgbox_uvmat('ERROR','several inconsistent mask sets coexist in the current image directory')
|
---|
| 1533 | return
|
---|
| 1534 | end
|
---|
| 1535 | if ~isempty(nbslice) && Name(i)=='_'
|
---|
| 1536 | Mask.Base=[FileBase Name(i:ind_mask+3)];
|
---|
| 1537 | Mask.NbSlice=nbslice;
|
---|
| 1538 | num_i1=mod(num_i1-1,nbslice)+1;
|
---|
| 1539 | Mask.NomType=Mask_NomType{1};
|
---|
| 1540 | [maskname,mdetect]=name_generator(Mask.Base,num_i1,num_j1,'.png',Mask.NomType);%
|
---|
| 1541 | mdetect=exist(maskname,'file');
|
---|
| 1542 | if mdetect
|
---|
| 1543 | set(handles.nb_slice,'String',Name(i+1:ind_mask-1));
|
---|
| 1544 | set(handles.nb_slice,'BackgroundColor',[1 1 0])
|
---|
| 1545 | set(handles.mask_test,'UserData',Mask);
|
---|
| 1546 | set(handles.mask_test,'BackgroundColor',[1 1 0])
|
---|
| 1547 | if nbslice > 1
|
---|
| 1548 | set(handles.slices,'value',1)
|
---|
| 1549 | slices_Callback(hObject, eventdata, handles)
|
---|
| 1550 | end
|
---|
| 1551 | end
|
---|
| 1552 | end
|
---|
| 1553 | end
|
---|
| 1554 | errormsg=[];%default
|
---|
| 1555 | if mdetect==0
|
---|
| 1556 | [FileName, PathName, filterindex] = uigetfile( ...
|
---|
| 1557 | {'*.png', ' (*.png)';
|
---|
| 1558 | '*.png', '.png files '; ...
|
---|
| 1559 | '*.*', 'All Files (*.*)'}, ...
|
---|
| 1560 | 'Pick a mask file *.png',FileBase);
|
---|
| 1561 | maskname=fullfile(PathName,FileName);
|
---|
| 1562 | if ~exist(maskname,'file')
|
---|
| 1563 | errormsg='no file browsed';
|
---|
| 1564 | end
|
---|
| 1565 | [RootDir,RootFile,x1,x2,xa,xb,xext,Mask.NomType]=name2display(maskname);
|
---|
| 1566 | Mask.Base=fullfile(RootDir,RootFile);
|
---|
| 1567 | Mask.NbSlice=1;
|
---|
| 1568 | set(handles.mask_test,'UserData',Mask);
|
---|
| 1569 | set(handles.mask_test,'BackgroundColor',[1 1 0])
|
---|
| 1570 | end
|
---|
| 1571 | if isempty(errormsg)
|
---|
| 1572 | errormsg=update_mask(handles,num_i1,num_j1);
|
---|
| 1573 | end
|
---|
| 1574 | if ~isempty(errormsg)
|
---|
| 1575 | set(handles.mask_test,'Value',0)
|
---|
| 1576 | set(handles.mask_test,'BackgroundColor',[0.7 0.7 0.7])
|
---|
| 1577 | end
|
---|
| 1578 | else
|
---|
| 1579 | MaskData=get(handles.mask_test,'UserData');
|
---|
| 1580 | if isfield(MaskData,'maskhandle') && ishandle(MaskData.maskhandle)
|
---|
| 1581 | delete(MaskData.maskhandle)
|
---|
| 1582 | end
|
---|
| 1583 | set(handles.mask_test,'UserData',[])
|
---|
| 1584 | %huvmat=get(handles.mask_test,'parent');
|
---|
| 1585 | UvData=get(handles.uvmat,'UserData');
|
---|
| 1586 | if isfield(UvData,'MaskName')
|
---|
| 1587 | UvData=rmfield(UvData,'MaskName');
|
---|
| 1588 | set(handles.uvmat,'UserData',UvData)
|
---|
| 1589 | end
|
---|
| 1590 | set(handles.mask_test,'BackgroundColor',[0.7 0.7 0.7])
|
---|
| 1591 | end
|
---|
| 1592 |
|
---|
| 1593 | %-------------------------------------------------------------------
|
---|
| 1594 | function errormsg=update_mask(handles,num_i1,num_j1)
|
---|
| 1595 | %-------------------------------------------------------------------
|
---|
| 1596 | errormsg=[];%default
|
---|
| 1597 | MaskData=get(handles.mask_test,'UserData');
|
---|
| 1598 | if isfield(MaskData,'maskhandle')&& ishandle(MaskData.maskhandle)
|
---|
| 1599 | uistack(MaskData.maskhandle,'top');
|
---|
| 1600 | end
|
---|
| 1601 | num_i1_mask=mod(num_i1-1,MaskData.NbSlice)+1;
|
---|
| 1602 | MaskName=name_generator(MaskData.Base,num_i1_mask,num_j1,'.png',MaskData.NomType);
|
---|
| 1603 | huvmat=get(handles.mask_test,'parent');
|
---|
| 1604 | UvData=get(huvmat,'UserData');
|
---|
| 1605 |
|
---|
| 1606 | %update mask image if the mask is new
|
---|
| 1607 | if ~ (isfield(UvData,'MaskName') && isequal(UvData.MaskName,MaskName))
|
---|
| 1608 | UvData.MaskName=MaskName; %update the recorded name on UvData
|
---|
| 1609 | set(huvmat,'UserData',UvData);
|
---|
| 1610 | if ~exist(MaskName,'file')
|
---|
| 1611 | if isfield(MaskData,'maskhandle')&& ishandle(MaskData.maskhandle)
|
---|
| 1612 | delete(MaskData.maskhandle)
|
---|
| 1613 | end
|
---|
| 1614 | else
|
---|
| 1615 | %read mask image
|
---|
| 1616 | Mask.AName='image';
|
---|
| 1617 | Mask.A=imread(MaskName);
|
---|
| 1618 | npxy=size(Mask.A);
|
---|
| 1619 | test_error=0;
|
---|
| 1620 | if length(npxy)>2
|
---|
| 1621 | errormsg=[MaskName ' is not a grey scale image'];
|
---|
| 1622 | return
|
---|
| 1623 | elseif ~isa(Mask.A,'uint8')
|
---|
| 1624 | errormsg=[MaskName ' is not a 8 bit grey level image'];
|
---|
| 1625 | return
|
---|
| 1626 | end
|
---|
| 1627 | Mask.AX=[0.5 npxy(2)-0.5];
|
---|
| 1628 | Mask.AY=[npxy(1)-0.5 0.5 ];
|
---|
| 1629 | Mask.CoordUnit='pixel';
|
---|
| 1630 | if isequal(get(handles.slices,'Value'),1)
|
---|
| 1631 | NbSlice=str2num(get(handles.nb_slice,'String'));
|
---|
| 1632 | num_i1=str2num(get(handles.i1,'String'));
|
---|
| 1633 | Mask.ZIndex=mod(num_i1-1,NbSlice)+1;
|
---|
| 1634 | end
|
---|
| 1635 | %px to phys or other transform on field
|
---|
| 1636 | menu_transform=get(handles.transform_fct,'String');
|
---|
| 1637 | choice_value=get(handles.transform_fct,'Value');
|
---|
| 1638 | transform_name=menu_transform{choice_value};%name of the transform fct given by the menu 'transform_fct'
|
---|
| 1639 | transform_list=get(handles.transform_fct,'UserData');
|
---|
| 1640 | transform=transform_list{choice_value};
|
---|
| 1641 | if ~isequal(transform_name,'') && ~isequal(transform_name,'px')
|
---|
| 1642 | if isfield(UvData,'XmlData') && isfield(UvData.XmlData,'GeometryCalib')%use geometry calib recorded from the ImaDoc xml file as first priority
|
---|
| 1643 | Calib=UvData.XmlData.GeometryCalib;
|
---|
| 1644 | Mask=transform(Mask,UvData.XmlData);
|
---|
| 1645 | end
|
---|
| 1646 | end
|
---|
| 1647 | flagmask=Mask.A < 200;
|
---|
| 1648 |
|
---|
| 1649 | %make brown color image
|
---|
| 1650 | imflag(:,:,1)=0.9*flagmask;
|
---|
| 1651 | imflag(:,:,2)=0.7*flagmask;
|
---|
| 1652 | imflag(:,:,3)=zeros(size(flagmask));
|
---|
| 1653 |
|
---|
| 1654 | %update mask image
|
---|
| 1655 | hmask=[]; %default
|
---|
| 1656 | if isfield(MaskData,'maskhandle')&& ishandle(MaskData.maskhandle)
|
---|
| 1657 | hmask=MaskData.maskhandle;
|
---|
| 1658 | end
|
---|
| 1659 | if ~isempty(hmask)
|
---|
| 1660 | set(hmask,'CData',imflag)
|
---|
| 1661 | set(hmask,'AlphaData',flagmask*0.6)
|
---|
| 1662 | set(hmask,'XData',Mask.AX);
|
---|
| 1663 | set(hmask,'YData',Mask.AY);
|
---|
| 1664 | % uistack(hmask,'top')
|
---|
| 1665 | else
|
---|
| 1666 | axes(handles.axes3)
|
---|
| 1667 | hold on
|
---|
| 1668 | MaskData.maskhandle=image(Mask.AX,Mask.AY,imflag,'Tag','mask','HitTest','off','AlphaData',0.6*flagmask);
|
---|
| 1669 | % set(MaskData.maskhandle,'AlphaData',0.6*flagmask)
|
---|
| 1670 | set(handles.mask_test,'UserData',MaskData)
|
---|
| 1671 | end
|
---|
| 1672 | end
|
---|
| 1673 | end
|
---|
| 1674 |
|
---|
| 1675 |
|
---|
| 1676 | %-------------------------------------------------------------------
|
---|
| 1677 | function MenuExportFigure_Callback(hObject, eventdata, handles)
|
---|
| 1678 | %-------------------------------------------------------------------
|
---|
| 1679 | huvmat=get(handles.MenuExport,'parent');
|
---|
| 1680 | %UvData=get(huvmat,'UserData');
|
---|
| 1681 | hfig=figure;
|
---|
| 1682 | copyobj(handles.axes3,hfig);
|
---|
| 1683 | map=colormap(handles.axes3);
|
---|
| 1684 | colormap(map);%transmit the current colormap to the zoom fig
|
---|
| 1685 | colorbar
|
---|
| 1686 |
|
---|
| 1687 | %-------------------------------------------------------------------
|
---|
| 1688 | %-------------------------------------------------------------------
|
---|
| 1689 | % III - MAIN REFRESH FUNCTIONS : 'FRAME PLOT'
|
---|
| 1690 | %-------------------------------------------------------------------
|
---|
| 1691 |
|
---|
| 1692 | %-------------------------------------------------------------------
|
---|
| 1693 | % --- Executes on button press in runplus: make one step forward and call
|
---|
| 1694 | % --- run0. The step forward is along the fields series 1 or 2 depending on
|
---|
| 1695 | % --- the scan_i and scan_j check box (exclusive each other)
|
---|
| 1696 | function runplus_Callback(hObject, eventdata, handles)
|
---|
| 1697 | %-------------------------------------------------------------------
|
---|
| 1698 | set(handles.runplus,'BackgroundColor',[1 1 0])%paint the command button in yellow
|
---|
| 1699 | drawnow
|
---|
| 1700 | %TODO: introduce the option: increment ='*' to move to the next available view
|
---|
| 1701 | increment=str2double(get(handles.increment_scan,'String')); %get the field increment d
|
---|
| 1702 | if isnan(increment)
|
---|
| 1703 | set(handles.increment_scan,'String','1')%default value
|
---|
| 1704 | increment=1;
|
---|
| 1705 | end
|
---|
| 1706 | errormsg=runpm(hObject,eventdata,handles,increment);
|
---|
| 1707 | if ~isempty(errormsg)
|
---|
| 1708 | msgbox_uvmat('ERROR',errormsg);
|
---|
| 1709 | end
|
---|
| 1710 | set(handles.runplus,'BackgroundColor',[1 0 0])%paint the command button back to red
|
---|
| 1711 |
|
---|
| 1712 | %-------------------------------------------------------------------
|
---|
| 1713 | % --- Executes on button press in runmin: make one step backward and call
|
---|
| 1714 | % --- run0. The step backward is along the fields series 1 or 2 depending on
|
---|
| 1715 | % --- the scan_i and scan_j check box (exclusive each other)
|
---|
| 1716 | function runmin_Callback(hObject, eventdata, handles)
|
---|
| 1717 | %-------------------------------------------------------------------
|
---|
| 1718 | set(handles.runmin,'BackgroundColor',[1 1 0])%paint the command button in yellow
|
---|
| 1719 | drawnow
|
---|
| 1720 | increment=-str2double(get(handles.increment_scan,'String')); %get the field increment d
|
---|
| 1721 | if isnan(increment)
|
---|
| 1722 | set(handles.increment_scan,'String','1')%default value
|
---|
| 1723 | increment=1;
|
---|
| 1724 | end
|
---|
| 1725 | errormsg=runpm(hObject,eventdata,handles,increment);
|
---|
| 1726 | if ~isempty(errormsg)
|
---|
| 1727 | msgbox_uvmat('ERROR',errormsg);
|
---|
| 1728 | end
|
---|
| 1729 | set(handles.runmin,'BackgroundColor',[1 0 0])%paint the command button back to red
|
---|
| 1730 |
|
---|
| 1731 | %-------------------------------------------------------------------
|
---|
| 1732 | % -- Executes on button press in Movie: make a series of +> steps
|
---|
| 1733 | function Movie_Callback(hObject, eventdata, handles)
|
---|
| 1734 | %------------------------------------------------------------------
|
---|
| 1735 | set(handles.Movie,'BackgroundColor',[1 1 0])%paint the command button in yellow
|
---|
| 1736 | drawnow
|
---|
| 1737 | increment=str2double(get(handles.increment_scan,'String')); %get the field increment d
|
---|
| 1738 | if isnan(increment)
|
---|
| 1739 | set(handles.increment_scan,'String','1')%default value
|
---|
| 1740 | increment=1;
|
---|
| 1741 | end
|
---|
| 1742 | set(handles.STOP,'Visible','on')
|
---|
| 1743 | set(handles.speed,'Visible','on')
|
---|
| 1744 | set(handles.speed_txt,'Visible','on')
|
---|
| 1745 | set(handles.Movie,'BusyAction','queue')
|
---|
| 1746 | UvData=get(handles.uvmat,'UserData');
|
---|
| 1747 |
|
---|
| 1748 | while get(handles.speed,'Value')~=0 && isequal(get(handles.Movie,'BusyAction'),'queue') % enable STOP command
|
---|
| 1749 | errormsg=runpm(hObject,eventdata,handles,increment);
|
---|
| 1750 | if ~isempty(errormsg)
|
---|
| 1751 | set(handles.Movie,'BackgroundColor',[1 0 0])%paint the command buttonback to red
|
---|
| 1752 | return
|
---|
| 1753 | end
|
---|
| 1754 | pause(1.02-get(handles.speed,'Value'))% wait for next image
|
---|
| 1755 | end
|
---|
| 1756 | if isfield(UvData,'aviobj') && ~isempty( UvData.aviobj),
|
---|
| 1757 | UvData.aviobj=close(UvData.aviobj);
|
---|
| 1758 | set(handles.uvmat,'UserData',UvData);
|
---|
| 1759 | end
|
---|
| 1760 | set(handles.Movie,'BackgroundColor',[1 0 0])%paint the command buttonback to red
|
---|
| 1761 |
|
---|
| 1762 | %-------------------------------------------------------------------
|
---|
| 1763 | % -- Executes on button press in Movie: make a series of <- steps
|
---|
| 1764 | function MovieBackward_Callback(hObject, eventdata, handles)
|
---|
| 1765 | %------------------------------------------------------------------
|
---|
| 1766 | set(handles.MovieBackward,'BackgroundColor',[1 1 0])%paint the command button in yellow
|
---|
| 1767 | drawnow
|
---|
| 1768 | increment=-str2double(get(handles.increment_scan,'String')); %get the field increment d
|
---|
| 1769 | if isnan(increment)
|
---|
| 1770 | set(handles.increment_scan,'String','1')%default value
|
---|
| 1771 | increment=1;
|
---|
| 1772 | end
|
---|
| 1773 | set(handles.STOP,'Visible','on')
|
---|
| 1774 | set(handles.speed,'Visible','on')
|
---|
| 1775 | set(handles.speed_txt,'Visible','on')
|
---|
| 1776 | set(handles.MovieBackward,'BusyAction','queue')
|
---|
| 1777 | UvData=get(handles.uvmat,'UserData');
|
---|
| 1778 |
|
---|
| 1779 | while get(handles.speed,'Value')~=0 && isequal(get(handles.MovieBackward,'BusyAction'),'queue') % enable STOP command
|
---|
| 1780 | errormsg=runpm(hObject,eventdata,handles,increment);
|
---|
| 1781 | if ~isempty(errormsg)
|
---|
| 1782 | set(handles.MovieBackward,'BackgroundColor',[1 0 0])%paint the command buttonback to red
|
---|
| 1783 | return
|
---|
| 1784 | end
|
---|
| 1785 | pause(1.02-get(handles.speed,'Value'))% wait for next image
|
---|
| 1786 | end
|
---|
| 1787 | if isfield(UvData,'aviobj') && ~isempty( UvData.aviobj),
|
---|
| 1788 | UvData.aviobj=close(UvData.aviobj);
|
---|
| 1789 | set(handles.uvmat,'UserData',UvData);
|
---|
| 1790 | end
|
---|
| 1791 | set(handles.MovieBackward,'BackgroundColor',[1 0 0])%paint the command buttonback to red
|
---|
| 1792 |
|
---|
| 1793 | %-------------------------------------------------------------------
|
---|
| 1794 | function STOP_Callback(hObject, eventdata, handles)
|
---|
| 1795 | %-------------------------------------------------------------------
|
---|
| 1796 | set(handles.movie_pair,'BusyAction','Cancel')
|
---|
| 1797 | set(handles.movie_pair,'value',0)
|
---|
| 1798 | set(handles.Movie,'BusyAction','Cancel')
|
---|
| 1799 | set(handles.MovieBackward,'BusyAction','Cancel')
|
---|
| 1800 | set(handles.MenuExportMovie,'BusyAction','Cancel')
|
---|
| 1801 | set(handles.movie_pair,'BackgroundColor',[1 0 0])%paint the command buttonback to red
|
---|
| 1802 | set(handles.Movie,'BackgroundColor',[1 0 0])%paint the command buttonback to red
|
---|
| 1803 | set(handles.MovieBackward,'BackgroundColor',[1 0 0])%paint the command buttonback to red
|
---|
| 1804 |
|
---|
| 1805 | %------------------------------------------------------------------
|
---|
| 1806 | function errormsg=runpm(hObject,eventdata,handles,increment)
|
---|
| 1807 | %------------------------------------------------------------------
|
---|
| 1808 | %check for mï¿œovie pair status
|
---|
| 1809 | movie_status=get(handles.movie_pair,'Value');
|
---|
| 1810 | if isequal(movie_status,1)
|
---|
| 1811 | STOP_Callback(hObject, eventdata, handles)%interrupt movie pair if active
|
---|
| 1812 | end
|
---|
| 1813 | %read the data on the current input rootfile(s)
|
---|
| 1814 |
|
---|
| 1815 | [FileName,RootPath,filebase,FileIndices,FileExt,subdir]=read_file_boxes(handles);
|
---|
| 1816 | NomType=get(handles.FileIndex,'UserData');
|
---|
| 1817 |
|
---|
| 1818 | num1=stra2num(get(handles.i1,'String'));
|
---|
| 1819 | num2=stra2num(get(handles.i2,'String'));
|
---|
| 1820 | num_a=stra2num(get(handles.j1,'String'));
|
---|
| 1821 | num_b=stra2num(get(handles.j2,'String'));
|
---|
| 1822 |
|
---|
| 1823 | sub_value= get(handles.SubField,'Value');
|
---|
| 1824 | if sub_value % a second input file has been entered
|
---|
| 1825 | [FileName_1,RootPath_1,filebase_1,FileIndices_1,FileExt_1,SubDir_1]=read_file_boxes_1(handles);
|
---|
| 1826 | [pp,ff,str1,str2,str_a,str_b]=name2display(FileIndices_1);
|
---|
| 1827 | num1_1=stra2num(str1);%current set of indices for the second field (may be set different than the main indices)
|
---|
| 1828 | num2_1=stra2num(str2);
|
---|
| 1829 | num_a_1=stra2num(str_a);
|
---|
| 1830 | num_b_1=stra2num(str_b);
|
---|
| 1831 | NomType_1=get(handles.FileIndex_1,'UserData');
|
---|
| 1832 | else
|
---|
| 1833 | filename_1=[];
|
---|
| 1834 | end
|
---|
| 1835 |
|
---|
| 1836 | comp_input=get(handles.fix_pair,'Value');
|
---|
| 1837 |
|
---|
| 1838 | %case of scanning along the first direction (rootfile numbers)
|
---|
| 1839 | if get(handles.scan_i,'Value')==1% case of scanning along index i
|
---|
| 1840 | num1=num1+increment;
|
---|
| 1841 | num2=num2+increment;
|
---|
| 1842 | [filename,num1,num_a,num2,num_b]=name_generator(filebase,num1,num_a,FileExt,NomType,comp_input,num2,num_b,subdir);
|
---|
| 1843 | if sub_value% set the second field name and indices
|
---|
| 1844 | num1_1=num1_1+increment;
|
---|
| 1845 | num2_1=num2_1+increment;
|
---|
| 1846 | filename_1=name_generator(filebase_1,num1_1,num_a_1,FileExt_1,NomType_1,1,num2_1,num_b_1,SubDir_1);
|
---|
| 1847 | end
|
---|
| 1848 | else % case of scanning along index j (burst numbers)
|
---|
| 1849 | num_a=num_a+increment;
|
---|
| 1850 | num_b=num_b+increment;
|
---|
| 1851 | [filename,num1,num_a,num2,num_b]=name_generator(filebase,num1,num_a,FileExt,NomType,comp_input,num2,num_b,subdir);
|
---|
| 1852 | if sub_value
|
---|
| 1853 | num_a_1=num_a_1+increment;
|
---|
| 1854 | num_b_1=num_b_1+increment;
|
---|
| 1855 | filename_1=name_generator(filebase_1,num1_1,num_a_1,FileExt_1,NomType_1,1,num2_1,num_b_1,SubDir_1);
|
---|
| 1856 | end
|
---|
| 1857 | end
|
---|
| 1858 |
|
---|
| 1859 | % refresh plots
|
---|
| 1860 | errormsg=refresh_field(handles,filename,filename_1,num1,num2,num_a,num_b);
|
---|
| 1861 | if isempty(errormsg) %update the index counters
|
---|
| 1862 | set(handles.i1,'String',num2stra(num1,NomType,1));
|
---|
| 1863 | if isequal(num2,num1)
|
---|
| 1864 | set(handles.i2,'String','');
|
---|
| 1865 | else
|
---|
| 1866 | set(handles.i2,'String',num2stra(num2,NomType,1));
|
---|
| 1867 | end
|
---|
| 1868 | set(handles.j1,'String',num2stra(num_a,NomType,2));
|
---|
| 1869 | if isequal(num_b,num_a)
|
---|
| 1870 | set(handles.j2,'String','');
|
---|
| 1871 | else
|
---|
| 1872 | set(handles.j2,'String',num2stra(num_b,NomType,2));
|
---|
| 1873 | end
|
---|
| 1874 | [indices]=name_generator('',num1,num_a,'',NomType,1,num2,num_b,'');
|
---|
| 1875 | set(handles.FileIndex,'String',indices);
|
---|
| 1876 | if ~isempty(filename_1)
|
---|
| 1877 | indices_1=name_generator('',num1_1,num_a_1,'',NomType_1,1,num2_1,num_b_1,'');
|
---|
| 1878 | set(handles.FileIndex_1,'String',indices_1);
|
---|
| 1879 | end
|
---|
| 1880 | if isequal(movie_status,1)
|
---|
| 1881 | set(handles.movie_pair,'Value',1)
|
---|
| 1882 | movie_pair_Callback(hObject, eventdata, handles); %reactivate moviepair if it was activated
|
---|
| 1883 | end
|
---|
| 1884 | end
|
---|
| 1885 |
|
---|
| 1886 |
|
---|
| 1887 | %-------------------------------------------------------
|
---|
| 1888 | % --- Executes on button press in movie_pair: create an alternating movie with two view
|
---|
| 1889 | %-------------------------------------------------------
|
---|
| 1890 | function movie_pair_Callback(hObject, eventdata, handles)
|
---|
| 1891 | status=get(handles.movie_pair,'value');
|
---|
| 1892 | if isequal(status,0)
|
---|
| 1893 | set(handles.movie_pair,'BusyAction','Cancel')%stop movie pair if button is 'off'
|
---|
| 1894 | set(handles.i2,'String','')
|
---|
| 1895 | set(handles.j2,'String','')
|
---|
| 1896 | return
|
---|
| 1897 | else
|
---|
| 1898 | set(handles.movie_pair,'BusyAction','queue')
|
---|
| 1899 | end
|
---|
| 1900 | %initialisation
|
---|
| 1901 | set(handles.movie_pair,'BackgroundColor',[1 1 0])%paint the command button in yellow
|
---|
| 1902 | drawnow
|
---|
| 1903 | list_fields=get(handles.Fields,'String');% list menu fields
|
---|
| 1904 | index_fields=get(handles.Fields,'Value');% selected string index
|
---|
| 1905 | FieldName=list_fields{index_fields}; % selected field
|
---|
| 1906 | UvData=get(handles.uvmat,'UserData');
|
---|
| 1907 | if isequal(FieldName,'image')
|
---|
| 1908 | test_1=0;
|
---|
| 1909 | [ff,rr,filebase,xx,Ext,SubDir]=read_file_boxes(handles);
|
---|
| 1910 | NomType=get(handles.FileIndex,'UserData');
|
---|
| 1911 | else
|
---|
| 1912 | list_fields=get(handles.Fields_1,'String');% list menu fields
|
---|
| 1913 | index_fields=get(handles.Fields_1,'Value');% selected string index
|
---|
| 1914 | FieldName=list_fields{index_fields}; % selected field
|
---|
| 1915 | if isequal(FieldName,'image')
|
---|
| 1916 | test_1=1;
|
---|
| 1917 | [ff,rr,filebase,xx,Ext,SubDir]=read_file_boxes_1(handles);
|
---|
| 1918 | NomType=get(handles.FileIndex_1,'UserData');
|
---|
| 1919 | else
|
---|
| 1920 | msgbox_uvmat('ERROR','an image or movie must be first introduced as input')
|
---|
| 1921 | set(handles.movie_pair,'BackgroundColor',[1 0 0])%paint the command button in red
|
---|
| 1922 | return
|
---|
| 1923 | end
|
---|
| 1924 | end
|
---|
| 1925 |
|
---|
| 1926 | num_i1=str2double(get(handles.i1,'String'));
|
---|
| 1927 | num_j1=stra2num(get(handles.j1,'String'));
|
---|
| 1928 | num_i2=str2double(get(handles.i2,'String'));
|
---|
| 1929 | num_j2=stra2num(get(handles.j2,'String'));
|
---|
| 1930 | if isnan(num_j2)
|
---|
| 1931 | if isempty(num_i2)
|
---|
| 1932 | msgbox_uvmat('ERROR', 'a second image index i2 or j2 is needed to show the pair as a movie')
|
---|
| 1933 | set(handles.movie_pair,'BackgroundColor',[1 0 0])%paint the command button in red
|
---|
| 1934 | return
|
---|
| 1935 | else
|
---|
| 1936 | num_j2=num_j1;%repeat the index i1 by default
|
---|
| 1937 | end
|
---|
| 1938 | end
|
---|
| 1939 | if isnan(num_i2)
|
---|
| 1940 | num_i2=num_i1;%repeat the index i1 by default
|
---|
| 1941 | end
|
---|
| 1942 | imaname_1=name_generator(filebase,num_i2,num_j2,Ext,NomType);
|
---|
| 1943 | if ~exist(imaname_1,'file')
|
---|
| 1944 | msgbox_uvmat('ERROR',['second input open (-) ' imaname_1 ' not found']);
|
---|
| 1945 | set(handles.movie_pair,'BackgroundColor',[1 0 0])%paint the command button in red
|
---|
| 1946 | return
|
---|
| 1947 | end
|
---|
| 1948 |
|
---|
| 1949 | %read the second image
|
---|
| 1950 | Field.AName='image';
|
---|
| 1951 | if test_1
|
---|
| 1952 | Field_a=UvData.Field_1;
|
---|
| 1953 | else
|
---|
| 1954 | Field_a=UvData.Field;
|
---|
| 1955 | end
|
---|
| 1956 | Field_b.AX=Field_a.AX;
|
---|
| 1957 | Field_b.AY=Field_a.AY;
|
---|
| 1958 | % z index
|
---|
| 1959 | nbslice=str2double(get(handles.nb_slice,'String'));
|
---|
| 1960 | if ~isempty(nbslice)
|
---|
| 1961 | Field_b.ZIndex=mod(num_i2-1,nbslice)+1;
|
---|
| 1962 | end
|
---|
| 1963 | Field_b.CoordUnit='pixel';
|
---|
| 1964 | %determine the input file type
|
---|
| 1965 | if (test_1 && isfield(UvData,'MovieObject_1'))||(~test_1 && isfield(UvData,'MovieObject'))
|
---|
| 1966 | FileType='movie';
|
---|
| 1967 | elseif isequal(lower(Ext),'.avi')
|
---|
| 1968 | FileType='avi';
|
---|
| 1969 | elseif isequal(lower(Ext),'.vol')
|
---|
| 1970 | FileType='vol';
|
---|
| 1971 | else
|
---|
| 1972 | form=imformats(Ext(2:end));
|
---|
| 1973 | if ~isempty(form)% if the extension corresponds to an image format recognized by Matlab
|
---|
| 1974 | if isequal(NomType,'*');
|
---|
| 1975 | FileType='multimage';
|
---|
| 1976 | else
|
---|
| 1977 | FileType='image';
|
---|
| 1978 | end
|
---|
| 1979 | end
|
---|
| 1980 | end
|
---|
| 1981 | switch FileType
|
---|
| 1982 | case 'movie'
|
---|
| 1983 | if test_1
|
---|
| 1984 | Field_b.A=read(UvData.MovieObject_1,num_i2);
|
---|
| 1985 | else
|
---|
| 1986 | Field_b.A=read(UvData.MovieObject,num_i2);
|
---|
| 1987 | end
|
---|
| 1988 | case 'avi'
|
---|
| 1989 | mov=aviread(imaname_1,num_i2);
|
---|
| 1990 | Field_b.A=frame2im(mov(1));
|
---|
| 1991 | case 'vol'
|
---|
| 1992 | Field_b.A=imread(imaname_1);
|
---|
| 1993 | case 'multimage'
|
---|
| 1994 | Field_b.A=imread(imaname_1,num_i2);
|
---|
| 1995 | case 'image'
|
---|
| 1996 | Field_b.A=imread(imaname_1);
|
---|
| 1997 | end
|
---|
| 1998 | if get(handles.slices,'Value')
|
---|
| 1999 | Field.ZIndex=str2double(get(handles.z_index,'String'));
|
---|
| 2000 | end
|
---|
| 2001 |
|
---|
| 2002 | %px to phys or other transform on field
|
---|
| 2003 | menu_transform=get(handles.transform_fct,'String');
|
---|
| 2004 | choice_value=get(handles.transform_fct,'Value');
|
---|
| 2005 | transform_name=menu_transform{choice_value};%name of the transform fct given by the menu 'transform_fct'
|
---|
| 2006 | transform_list=get(handles.transform_fct,'UserData');
|
---|
| 2007 | transform=transform_list{choice_value};
|
---|
| 2008 | if ~isequal(transform_name,'') && ~isequal(transform_name,'px')
|
---|
| 2009 | if test_1 && isfield(UvData,'XmlData_1') && isfield(UvData.XmlData_1,'GeometryCalib')%use geometry calib recorded from the ImaDoc xml file as first priority
|
---|
| 2010 | Field_a=transform(Field_a,UvData.XmlData_1);%the first field has been stored without transform
|
---|
| 2011 | Field_b=transform(Field_b,UvData.XmlData_1);
|
---|
| 2012 | elseif ~test_1 && isfield(UvData,'XmlData') && isfield(UvData.XmlData,'GeometryCalib')%use geometry calib
|
---|
| 2013 | Field_b=transform(Field_b,UvData.XmlData);
|
---|
| 2014 | end
|
---|
| 2015 | end
|
---|
| 2016 |
|
---|
| 2017 | % make movie until movie speed is set to 0 or STOP is activated
|
---|
| 2018 | hima=findobj(handles.axes3,'Tag','ima');% %handles.axes3 =main plotting window (A GENERALISER)
|
---|
| 2019 | set(handles.STOP,'Visible','on')
|
---|
| 2020 | set(handles.speed,'Visible','on')
|
---|
| 2021 | set(handles.speed_txt,'Visible','on')
|
---|
| 2022 | while get(handles.speed,'Value')~=0 && isequal(get(handles.movie_pair,'BusyAction'),'queue')%isequal(get(handles.run0,'BusyAction'),'queue'); % enable STOP command
|
---|
| 2023 | % read and plot the series of images in non erase mode
|
---|
| 2024 | set(hima,'CData',Field_b.A);
|
---|
| 2025 | pause(1.02-get(handles.speed,'Value'));% wait for next image
|
---|
| 2026 | set(hima,'CData',Field_a.A);
|
---|
| 2027 | pause(1.02-get(handles.speed,'Value'));% wait for next image
|
---|
| 2028 | end
|
---|
| 2029 | set(handles.movie_pair,'BackgroundColor',[1 0 0])%paint the command button in red
|
---|
| 2030 |
|
---|
| 2031 | %------------------------------------------------------------------------
|
---|
| 2032 | % --- Executes on button press in run0.
|
---|
| 2033 | function run0_Callback(hObject, eventdata, handles)
|
---|
| 2034 | %------------------------------------------------------------------------
|
---|
| 2035 | set(handles.run0,'BackgroundColor',[1 1 0])%paint the command button in yellow
|
---|
| 2036 | drawnow
|
---|
| 2037 | filename=read_file_boxes(handles);
|
---|
| 2038 |
|
---|
| 2039 | filename_1=[];%default
|
---|
| 2040 | if get(handles.SubField,'Value')
|
---|
| 2041 | filename_1=read_file_boxes_1(handles);
|
---|
| 2042 | end
|
---|
| 2043 | num_i1=stra2num(get(handles.i1,'String'));
|
---|
| 2044 | num_i2=stra2num(get(handles.i2,'String'));
|
---|
| 2045 | num_j1=stra2num(get(handles.j1,'String'));
|
---|
| 2046 | num_j2=stra2num(get(handles.j2,'String'));
|
---|
[227] | 2047 |
|
---|
[199] | 2048 | errormsg=refresh_field(handles,filename,filename_1,num_i1,num_i2,num_j1,num_j2);
|
---|
[227] | 2049 |
|
---|
[199] | 2050 | if ~isempty(errormsg)
|
---|
| 2051 | msgbox_uvmat('ERROR',errormsg);
|
---|
| 2052 | else
|
---|
| 2053 | set(handles.i1,'BackgroundColor',[1 1 1])
|
---|
| 2054 | set(handles.i2,'BackgroundColor',[1 1 1])
|
---|
| 2055 | set(handles.j1,'BackgroundColor',[1 1 1])
|
---|
| 2056 | set(handles.j2,'BackgroundColor',[1 1 1])
|
---|
| 2057 | set(handles.FileIndex,'BackgroundColor',[1 1 1])
|
---|
| 2058 | set(handles.FileIndex_1,'BackgroundColor',[1 1 1])
|
---|
| 2059 | end
|
---|
| 2060 | set(handles.run0,'BackgroundColor',[1 0 0])
|
---|
| 2061 |
|
---|
| 2062 |
|
---|
| 2063 | %------------------------------------------------------------------------
|
---|
| 2064 | % --- read the input files and refresh all the plots, including projection.
|
---|
| 2065 | % OUTPUT:
|
---|
| 2066 | % errormsg: error message char string =[] by default
|
---|
| 2067 | % INPUT:
|
---|
| 2068 | % filename: first input file (=[] in the absence of input file)
|
---|
| 2069 | % filename_1: second input file (=[] in the asbsenc of secodn input file)
|
---|
| 2070 | % num_i1,num_i2,num_j1,num_j2; frame indices
|
---|
| 2071 | % Field: structure describing an optional input field (then replace the input file)
|
---|
| 2072 | function errormsg=refresh_field(handles,filename,filename_1,num_i1,num_i2,num_j1,num_j2,Field)
|
---|
| 2073 | %------------------------------------------------------------------------
|
---|
| 2074 |
|
---|
| 2075 | %% initialisation
|
---|
| 2076 | abstime=[];
|
---|
| 2077 | abstime_1=[];
|
---|
| 2078 | dt=[];
|
---|
| 2079 | if ~exist('Field','var')
|
---|
| 2080 | Field={};
|
---|
| 2081 | end
|
---|
| 2082 | UvData=get(handles.uvmat,'UserData');
|
---|
| 2083 | if ishandle(handles.UVMAT_title) %remove title panel on uvmat
|
---|
| 2084 | delete(handles.UVMAT_title)
|
---|
| 2085 | end
|
---|
| 2086 |
|
---|
| 2087 | %% determine the main input file information for action
|
---|
| 2088 | FileType=[];%default
|
---|
| 2089 | if ~exist(filename,'file')
|
---|
| 2090 | errormsg=['input file ' filename ' does not exist'];
|
---|
| 2091 | return
|
---|
| 2092 | end
|
---|
| 2093 | %Ext=get(handles.FileExt,'String');
|
---|
| 2094 | NomType=get(handles.FileIndex,'UserData');
|
---|
| 2095 | %update the z position index
|
---|
| 2096 | nbslice_str=get(handles.nb_slice,'String');
|
---|
| 2097 | if isequal(nbslice_str,'volume')%NOT USED
|
---|
| 2098 | z_index=num_j1;
|
---|
| 2099 | set(handles.z_index,'String',num2str(z_index))
|
---|
| 2100 | else
|
---|
| 2101 | nbslice=str2num(nbslice_str);
|
---|
| 2102 | z_index=mod(num_i1-1,nbslice)+1;
|
---|
| 2103 | set(handles.z_index,'String',num2str(z_index))
|
---|
| 2104 | end
|
---|
| 2105 | % refresh menu for save_mask if relevant
|
---|
| 2106 | masknumber=get(handles.masklevel,'String');
|
---|
| 2107 | if length(masknumber)>=z_index
|
---|
| 2108 | set(handles.masklevel,'Value',z_index)
|
---|
| 2109 | end
|
---|
| 2110 |
|
---|
| 2111 | %% read the first input field if a filename has been introduced
|
---|
| 2112 | if ~isempty(filename)
|
---|
| 2113 | ObjectName=filename;
|
---|
| 2114 | FieldName=[];%default
|
---|
| 2115 | VelType=[];%default
|
---|
| 2116 | Ext=get(handles.FileExt,'String');
|
---|
| 2117 | if strcmp(Ext,'.nc')||strcmp(Ext,'.cdf')
|
---|
| 2118 | FileType='netcdf';
|
---|
| 2119 | list_fields=get(handles.Fields,'String');% list menu fields
|
---|
| 2120 | index_fields=get(handles.Fields,'Value');% selected string index
|
---|
| 2121 | FieldName= list_fields{index_fields}; % selected field
|
---|
[221] | 2122 | if ~strcmp(FieldName,'get_field...')
|
---|
| 2123 | VelType=setfield(handles);% read the velocity type.
|
---|
[199] | 2124 | end
|
---|
| 2125 | if strcmp(FieldName,'velocity')
|
---|
| 2126 | list_code=get(handles.color_code,'String');% list menu fields
|
---|
| 2127 | index_code=get(handles.color_code,'Value');% selected string index
|
---|
| 2128 | if ~strcmp(list_code{index_code},'black') && ~strcmp(list_code{index_code},'white')
|
---|
| 2129 | list_code=get(handles.col_vec,'String');% list menu fields
|
---|
| 2130 | index_code=get(handles.col_vec,'Value');% selected string index
|
---|
| 2131 | ParamIn.ColorVar= list_code{index_code}; % selected field
|
---|
| 2132 | end
|
---|
| 2133 | end
|
---|
| 2134 | elseif isfield(UvData,'MovieObject')
|
---|
| 2135 | ObjectName=UvData.MovieObject;
|
---|
| 2136 | FileType='movie';
|
---|
| 2137 | elseif isequal(lower(Ext),'.avi')
|
---|
| 2138 | FileType='avi';
|
---|
| 2139 | elseif isequal(lower(Ext),'.vol')
|
---|
| 2140 | FileType='vol';
|
---|
| 2141 | if isfield(UvData.XmlData,'Npy') && isfield(UvData.XmlData,'Npx')
|
---|
| 2142 | ParamIn.Npy=UvData.XmlData.Npy;
|
---|
| 2143 | ParamIn.Npx=UvData.XmlData.Npx;
|
---|
| 2144 | else
|
---|
| 2145 | errormsg='Npx and Npy need to be defined in the xml file for volume images .vol';
|
---|
| 2146 | return
|
---|
| 2147 | end
|
---|
| 2148 | else
|
---|
| 2149 | form=imformats(Ext(2:end));
|
---|
| 2150 | if ~isempty(form)% if the extension corresponds to an image format recognized by Matlab
|
---|
| 2151 | if isequal(NomType,'*');
|
---|
| 2152 | FileType='multimage';
|
---|
| 2153 | else
|
---|
| 2154 | FileType='image';
|
---|
| 2155 | end
|
---|
| 2156 | end
|
---|
| 2157 | end
|
---|
| 2158 | ParamIn.FieldName=FieldName;
|
---|
| 2159 | ParamIn.VelType=VelType;
|
---|
| 2160 | ParamIn.GUIName='get_field';
|
---|
| 2161 | [Field{1},ParamOut,errormsg] = read_field(ObjectName,FileType,ParamIn,num_i1);
|
---|
| 2162 | if ~isempty(errormsg)
|
---|
| 2163 | errormsg=['error in reading ' filename ': ' errormsg];
|
---|
| 2164 | return
|
---|
| 2165 | end
|
---|
| 2166 | if isfield(ParamOut,'Npx')&& isfield(ParamOut,'Npy')
|
---|
| 2167 | set(handles.npx,'String',num2str(ParamOut.Npx));% display image size on the interface
|
---|
| 2168 | set(handles.npy,'String',num2str(ParamOut.Npy));
|
---|
| 2169 | end
|
---|
[227] | 2170 | if isfield(ParamOut,'TimeIndex')
|
---|
| 2171 | set(handles.i1,'String',num2str(ParamOut.TimeIndex))
|
---|
| 2172 | end
|
---|
| 2173 | if isfield(ParamOut,'TimeValue')
|
---|
| 2174 | Field{1}.Time=ParamOut.TimeValue;
|
---|
| 2175 | end
|
---|
[199] | 2176 | end
|
---|
| 2177 |
|
---|
| 2178 | %% choose a second field if Subfield option is 'on', and if the field has changed
|
---|
| 2179 | VelType_1=[];%default
|
---|
| 2180 | FieldName_1=[];
|
---|
| 2181 | ParamOut_1=[];
|
---|
| 2182 | if ~isempty(filename_1)
|
---|
| 2183 | if ~exist(filename_1,'file')
|
---|
| 2184 | errormsg=['second file ' filename_1 ' does not exist'];
|
---|
| 2185 | return
|
---|
| 2186 | else
|
---|
| 2187 | Name=filename_1;
|
---|
| 2188 | FieldName_1=[];%default
|
---|
| 2189 | VelType_1=[];%default
|
---|
| 2190 | Ext_1=get(handles.FileExt_1,'String');
|
---|
| 2191 | NomType_1=get(handles.FileIndex_1,'UserData');
|
---|
| 2192 | if isequal(Ext_1,'.nc')||isequal(Ext_1,'.cdf')
|
---|
| 2193 | FileType_1='netcdf';
|
---|
| 2194 | elseif isfield(UvData,'MovieObject_1')
|
---|
| 2195 | Name=UvData.MovieObject_1;
|
---|
| 2196 | FileType_1='movie';
|
---|
| 2197 | elseif isequal(lower(Ext_1),'.avi')
|
---|
| 2198 | FileType_1='avi';
|
---|
| 2199 | elseif isequal(lower(Ext_1),'.vol')
|
---|
| 2200 | FileType_1='vol';
|
---|
| 2201 | if isfield(UvData.XmlData_1,'Npy') && isfield(UvData.XmlData_1,'Npx')
|
---|
| 2202 | ParamIn.Npy=UvData.XmlData_1.Npy;
|
---|
| 2203 | ParamIn.Npx=UvData.XmlData_1.Npx;
|
---|
| 2204 | else
|
---|
| 2205 | errormsg='Npx and Npy need to be defined in the xml file for volume images .vol';
|
---|
| 2206 | return
|
---|
| 2207 | end
|
---|
| 2208 | else
|
---|
| 2209 | form=imformats(Ext_1(2:end));
|
---|
| 2210 | if ~isempty(form)% if the extension corresponds to an image format recognized by Matlab
|
---|
| 2211 | if isequal(NomType_1,'*');
|
---|
| 2212 | FileType_1='multimage';
|
---|
| 2213 | else
|
---|
| 2214 | FileType_1='image';
|
---|
| 2215 | end
|
---|
| 2216 | end
|
---|
| 2217 | end
|
---|
| 2218 | if strcmp(FileType_1,'netcdf')
|
---|
| 2219 | list_fields=get(handles.Fields_1,'String');% list menu fields
|
---|
| 2220 | index_fields=get(handles.Fields_1,'Value');% selected string index
|
---|
| 2221 | FieldName_1= list_fields{index_fields}; % selected field
|
---|
| 2222 | if ~isequal(FieldName_1,'get_field...')% read the field names on the interface get_field...
|
---|
| 2223 | VelType_1=setfield_1(handles);
|
---|
| 2224 | end
|
---|
| 2225 | if strcmp(VelType_1,'*')% free veltype choice
|
---|
| 2226 | VelType_1=[];
|
---|
| 2227 | elseif strcmp(VelType_1,'"')% veltype the same as for the first field
|
---|
| 2228 | if isempty(VelType)
|
---|
| 2229 | VelType_1=[];
|
---|
| 2230 | else
|
---|
| 2231 | VelType_1=VelType;
|
---|
| 2232 | end
|
---|
| 2233 | end
|
---|
| 2234 | if strcmp(FieldName_1,'velocity')
|
---|
| 2235 | list_code=get(handles.color_code,'String');% list menu fields
|
---|
| 2236 | index_code=get(handles.color_code,'Value');% selected string index
|
---|
| 2237 | if ~strcmp(list_code{index_code},'black') && ~strcmp(list_code{index_code},'white')
|
---|
| 2238 | list_code=get(handles.col_vec,'String');% list menu fields
|
---|
| 2239 | index_code=get(handles.col_vec,'Value');% selected string index
|
---|
| 2240 | ParamIn.ColorVar= list_code{index_code}; % selected field
|
---|
| 2241 | end
|
---|
| 2242 | end
|
---|
| 2243 | end
|
---|
| 2244 | test_keepdata_1=0;% test for keeping the previous stored data if the input files are unchanged
|
---|
| 2245 | if ~isequal(NomType_1,'*')%in case of a series of files (not avi movie)
|
---|
| 2246 | if isfield(UvData,'filename_1')&& isfield(UvData,'VelType_1') && isfield(UvData,'FieldName_1')
|
---|
| 2247 | test_keepdata_1= strcmp(filename_1,UvData.filename_1) && strcmp(VelType_1,UvData.VelType_1) && strcmp(FieldName_1,UvData.FieldName_1);
|
---|
| 2248 | end
|
---|
| 2249 | end
|
---|
| 2250 | if test_keepdata_1
|
---|
| 2251 | Field{2}=UvData.Field_1;
|
---|
| 2252 | else
|
---|
| 2253 | ParamIn.FieldName=FieldName_1;
|
---|
| 2254 | ParamIn.VelType=VelType_1;
|
---|
| 2255 | ParamIn.GUIName='get_field_1';
|
---|
| 2256 | [Field{2},ParamOut_1,errormsg] = read_field(Name,FileType_1,ParamIn,num_i1);
|
---|
| 2257 | if ~isempty(errormsg)
|
---|
| 2258 | errormsg=['error in reading ' filename_1 ': ' errormsg];
|
---|
| 2259 | return
|
---|
| 2260 | end
|
---|
| 2261 | UvData.Field_1=Field{2}; %store the second field for possible use at next RUN
|
---|
| 2262 | end
|
---|
| 2263 | end
|
---|
| 2264 | end
|
---|
| 2265 |
|
---|
| 2266 | %% update uvmat interface
|
---|
| 2267 | if isfield(ParamOut,'Npx')
|
---|
| 2268 | set(handles.npx,'String',num2str(ParamOut.Npx));% display image size on the interface
|
---|
| 2269 | set(handles.npy,'String',num2str(ParamOut.Npy));
|
---|
| 2270 | elseif isfield(ParamOut_1,'Npx')
|
---|
| 2271 | set(handles.npx,'String',num2str(ParamOut_1.Npx));% display image size on the interface
|
---|
| 2272 | set(handles.npy,'String',num2str(ParamOut_1.Npy));
|
---|
| 2273 | end
|
---|
| 2274 |
|
---|
| 2275 | %% update the display buttons for the first velocity type (first menuline)
|
---|
| 2276 | veltype_handles=[handles.civ1 handles.interp1 handles.filter1 handles.civ2 handles.interp2 handles.filter2];
|
---|
| 2277 | if ~isequal(FileType,'netcdf')|| isequal(FieldName,'get_field...')
|
---|
| 2278 | % reset_vel_type(veltype_handles)
|
---|
| 2279 | set(veltype_handles,'Visible','off')
|
---|
| 2280 | else% if isempty(ParamOut.VelType) && ~isequal(FieldName,'get_field...')
|
---|
| 2281 | set_veltype_display(veltype_handles,ParamOut.CivStage)%update the display of available velocity types for the first field
|
---|
| 2282 | if isempty(ParamOut.VelType)
|
---|
| 2283 | reset_vel_type(veltype_handles)
|
---|
| 2284 | else
|
---|
| 2285 | handle1=eval(['handles.' ParamOut.VelType]);
|
---|
| 2286 | reset_vel_type(veltype_handles,handle1)
|
---|
| 2287 | end
|
---|
| 2288 | end
|
---|
| 2289 | field_index=strcmp(ParamOut.FieldName,ParamOut.FieldList);
|
---|
| 2290 | set(handles.Fields,'String',ParamOut.FieldList); %update the field menu
|
---|
| 2291 | set(handles.Fields,'Value',find(field_index,1))
|
---|
| 2292 |
|
---|
| 2293 | %% update the display buttons for the second velocity type (second menuline)
|
---|
| 2294 | if ~isempty(filename_1)
|
---|
| 2295 | veltype_handles_1=[handles.civ1_1 handles.interp1_1 handles.filter1_1 handles.civ2_1 handles.interp2_1 handles.filter2_1];
|
---|
| 2296 | if ~isequal(FileType_1,'netcdf')|| isequal(FieldName_1,'get_field...')
|
---|
| 2297 | set(veltype_handles_1,'Visible','off')
|
---|
| 2298 | %reset_vel_type(veltype_handles_1)
|
---|
| 2299 | else %if isempty(VelType_1) && ~isequal(FieldName_1,'get_field...')
|
---|
| 2300 | set_veltype_display(veltype_handles_1,ParamOut_1.CivStage)%update the display of available velocity types for the first field
|
---|
| 2301 | if isempty(ParamOut_1.VelType)
|
---|
| 2302 | reset_vel_type(veltype_handles_1)
|
---|
| 2303 | else
|
---|
| 2304 | handle1=eval(['handles.' ParamOut_1.VelType '_1']);
|
---|
| 2305 | reset_vel_type(veltype_handles_1,handle1)
|
---|
| 2306 | end
|
---|
| 2307 | end
|
---|
| 2308 | field_index=strcmp(ParamOut_1.FieldName,ParamOut_1.FieldList);
|
---|
| 2309 | set(handles.Fields_1,'String',ParamOut_1.FieldList); %update the field menu
|
---|
| 2310 | set(handles.Fields_1,'Value',find(field_index,1))
|
---|
| 2311 | end
|
---|
| 2312 |
|
---|
| 2313 | %% introduce w as background image by default for a new series (only for nbdim=2)
|
---|
| 2314 | if ~isfield(UvData,'NewSeries')
|
---|
| 2315 | UvData.NewSeries=1;
|
---|
| 2316 | end
|
---|
| 2317 | %put W as background image by default if NbDim=2:
|
---|
| 2318 | if UvData.NewSeries && isequal(get(handles.SubField,'Value'),0) && isfield(Field{1},'W') && ~isempty(Field{1}.W) && ~isequal(Field{1}.NbDim,3);
|
---|
| 2319 | set(handles.SubField,'Value',1);
|
---|
| 2320 | %menu=update_menu(handles.Fields_1,'w');%update the menu for the background scalar nd set the choice to 'w'
|
---|
| 2321 | set(handles.RootPath_1,'String','"')
|
---|
| 2322 | set(handles.RootFile_1,'String','"')
|
---|
| 2323 | set(handles.SubDir_1,'String','"');
|
---|
| 2324 | [indices]=name_generator('',num_i1,num_j1,'',NomType,1,num_i2,num_j2,'');
|
---|
| 2325 | set(handles.FileIndex_1,'String',indices)
|
---|
| 2326 | set(handles.FileExt_1,'String','"');
|
---|
| 2327 | set(handles.Fields_1,'Visible','on');
|
---|
| 2328 | set(handles.Fields_1,'Visible','on');
|
---|
| 2329 | set(handles.RootPath_1,'Visible','on')
|
---|
| 2330 | set(handles.RootFile_1,'Visible','on')
|
---|
| 2331 | set(handles.SubDir_1,'Visible','on');
|
---|
| 2332 | set(handles.FileIndex_1,'Visible','on');
|
---|
| 2333 | set(handles.FileExt_1,'Visible','on');
|
---|
| 2334 | set(handles.Fields_1,'Visible','on');
|
---|
| 2335 | Field{1}.AName='w';
|
---|
| 2336 | end
|
---|
| 2337 |
|
---|
| 2338 | %% store the current open names, fields and vel types in uvmat interface
|
---|
| 2339 | UvData.filename_1=filename_1;
|
---|
| 2340 | UvData.VelType_1=[];%default
|
---|
| 2341 | UvData.FieldName_1=[];
|
---|
| 2342 | if isfield(ParamOut_1,VelType)
|
---|
| 2343 | UvData.VelType_1=ParamOut_1.VelType;
|
---|
| 2344 | end
|
---|
| 2345 | if isfield(ParamOut_1,FieldName)
|
---|
| 2346 | UvData.FieldName_1=ParamOut_1.FieldName;
|
---|
| 2347 | end
|
---|
| 2348 |
|
---|
| 2349 | %% apply coordinate transform or other user fct
|
---|
| 2350 | XmlData=[];%default
|
---|
| 2351 | if isfield(UvData,'XmlData')%use geometry calib recorded from the ImaDoc xml file as first priority
|
---|
| 2352 | XmlData=UvData.XmlData;
|
---|
| 2353 | end
|
---|
| 2354 | XmlData_1=[];%default
|
---|
| 2355 | if isfield(UvData,'XmlData_1')
|
---|
| 2356 | XmlData_1=UvData.XmlData_1;
|
---|
| 2357 | end
|
---|
| 2358 | % menu_transform=get(handles.transform_fct,'String');
|
---|
| 2359 | choice_value=get(handles.transform_fct,'Value');
|
---|
| 2360 | transform_list=get(handles.transform_fct,'UserData');
|
---|
| 2361 | transform=transform_list{choice_value};%selected function handles
|
---|
| 2362 | % z index
|
---|
| 2363 | if ~isempty(filename)
|
---|
| 2364 | Field{1}.ZIndex=z_index;
|
---|
| 2365 | end
|
---|
| 2366 | %px to phys or other transform on field
|
---|
| 2367 | if ~isempty(transform)
|
---|
| 2368 | if length(Field)>=2
|
---|
| 2369 | Field{2}.ZIndex=z_index;
|
---|
| 2370 | [Field{1},Field{2}]=transform(Field{1},XmlData,Field{2},XmlData_1);
|
---|
| 2371 | if isempty(Field{2})
|
---|
| 2372 | Field(2)=[];
|
---|
| 2373 | end
|
---|
| 2374 | else
|
---|
| 2375 | Field{1}=transform(Field{1},XmlData);
|
---|
| 2376 | end
|
---|
| 2377 | end
|
---|
| 2378 |
|
---|
| 2379 | %% calculate scalar
|
---|
| 2380 | if isequal(FileType,'netcdf') && ~isequal(ParamOut.CivStage,0)%&&~isempty(FieldName)%
|
---|
| 2381 | Field{1}=calc_field([{ParamOut.FieldName} {ParamOut.ColorVar}],Field{1});
|
---|
| 2382 | end
|
---|
| 2383 | if length(Field)==2 && ~test_keepdata_1 && isequal(FileType_1,'netcdf') && ~isequal(ParamOut_1.FieldName,'get_field...')%&&~isempty(FieldName_1)
|
---|
| 2384 | Field{2}=calc_field([{ParamOut_1.FieldName} {ParamOut_1.ColorVar}],Field{2});
|
---|
| 2385 | end
|
---|
| 2386 |
|
---|
| 2387 | %% combine the two input fields (e.g. substract velocity fields)
|
---|
| 2388 | if numel(Field)==2
|
---|
| 2389 | UvData.Field=sub_field(Field{1},Field{2});
|
---|
| 2390 | else
|
---|
| 2391 | UvData.Field=Field{1};
|
---|
| 2392 | end
|
---|
| 2393 |
|
---|
| 2394 | %% get bounds and mesh (needed for mouse action and to open set_object)
|
---|
| 2395 | test_x=0;
|
---|
| 2396 | test_z=0;% test for unstructured z coordinate
|
---|
| 2397 | [UvData.Field,errormsg]=check_field_structure(UvData.Field);
|
---|
| 2398 | if ~isempty(errormsg)
|
---|
| 2399 | errormsg=['error in uvmat/refresh_field/check_field_structure: ' errormsg];
|
---|
| 2400 | return
|
---|
| 2401 | end
|
---|
[210] | 2402 | [CellVarIndex,NbDim,VarType,errormsg]=find_field_indices(UvData.Field);
|
---|
[199] | 2403 | if ~isempty(errormsg)
|
---|
| 2404 | errormsg=['error in uvmat/refresh_field/find_field_indices: ' errormsg];
|
---|
| 2405 | return
|
---|
| 2406 | end
|
---|
| 2407 | [NbDim,imax]=max(NbDim);
|
---|
[210] | 2408 | if isfield(UvData.Field,'NbDim')
|
---|
| 2409 | NbDim=UvData.Field.NbDim;% deal with plane fields containing z coordinates
|
---|
| 2410 | end
|
---|
[199] | 2411 | if ~isempty(VarType{imax}.coord_x) && ~isempty(VarType{imax}.coord_y) %unstructured coordinates
|
---|
| 2412 | XName=UvData.Field.ListVarName{VarType{imax}.coord_x};
|
---|
| 2413 | YName=UvData.Field.ListVarName{VarType{imax}.coord_y};
|
---|
| 2414 | eval(['nbvec=length(UvData.Field.' XName ');'])%nbre of measurement points (e.g. vectors)
|
---|
| 2415 | test_x=1;%test for unstructured coordinates
|
---|
[206] | 2416 | if ~isempty(VarType{imax}.coord_z)
|
---|
| 2417 | ZName=UvData.Field.ListVarName{VarType{imax}.coord_z};
|
---|
| 2418 | else
|
---|
| 2419 | NbDim=2;
|
---|
| 2420 | end
|
---|
[199] | 2421 | elseif VarType{imax}.coord(NbDim)>0 %structured coordinate
|
---|
| 2422 | XName=UvData.Field.ListVarName{VarType{imax}.coord(NbDim)};
|
---|
| 2423 | if NbDim>1
|
---|
| 2424 | YName=UvData.Field.ListVarName{VarType{imax}.coord(NbDim-1)}; %structured coordinates
|
---|
| 2425 | end
|
---|
| 2426 | end
|
---|
| 2427 | if NbDim==3
|
---|
[206] | 2428 | if ~test_x
|
---|
| 2429 | ZName=UvData.Field.ListVarName{VarType{imax}.coord(1)};%structured coordinates in 3D
|
---|
| 2430 | end
|
---|
[199] | 2431 | eval(['ZMax=max(UvData.Field.' ZName ');'])
|
---|
| 2432 | eval(['ZMin=min(UvData.Field.' ZName ');'])
|
---|
[206] | 2433 | UvData.Field.ZMax=ZMax;
|
---|
| 2434 | UvData.Field.ZMin=ZMin;
|
---|
[199] | 2435 | test_z=1;
|
---|
| 2436 | if isequal(ZMin,ZMax)%no z dependency
|
---|
| 2437 | NbDim=2;
|
---|
| 2438 | test_z=0;
|
---|
| 2439 | end
|
---|
| 2440 | end
|
---|
| 2441 | if exist('XName','var')
|
---|
[227] | 2442 | eval(['XMax=max(max(UvData.Field.' XName '));'])
|
---|
| 2443 | eval(['XMin=min(min(UvData.Field.' XName '));'])
|
---|
[206] | 2444 | UvData.Field.NbDim=NbDim;
|
---|
| 2445 | UvData.Field.XMax=XMax;
|
---|
| 2446 | UvData.Field.XMin=XMin;
|
---|
[199] | 2447 | if NbDim >1
|
---|
[227] | 2448 | eval(['YMax=max(max(UvData.Field.' YName '));'])
|
---|
| 2449 | eval(['YMin=min(min(UvData.Field.' YName '));'])
|
---|
[206] | 2450 | UvData.Field.YMax=YMax;
|
---|
| 2451 | UvData.Field.YMin=YMin;
|
---|
[199] | 2452 | end
|
---|
[206] | 2453 | eval(['nbvec=length(UvData.Field.' XName ');'])
|
---|
| 2454 | if test_x %unstructured coordinates
|
---|
| 2455 | if test_z
|
---|
| 2456 | UvData.Field.Mesh=((XMax-XMin)*(YMax-YMin)*(ZMax-ZMin))/nbvec;% volume per vector
|
---|
| 2457 | UvData.Field.Mesh=(UvData.Field.Mesh)^(1/3);
|
---|
| 2458 | else
|
---|
| 2459 | UvData.Field.Mesh=sqrt((XMax-XMin)*(YMax-YMin)/nbvec);%2D
|
---|
| 2460 | end
|
---|
[199] | 2461 | else
|
---|
[206] | 2462 | VarIndex=CellVarIndex{imax}; % list of variable indices
|
---|
| 2463 | DimIndex=UvData.Field.VarDimIndex{VarIndex(1)}; %list of dim indices for the variable
|
---|
| 2464 | nbpoints_x=UvData.Field.DimValue(DimIndex(NbDim));
|
---|
| 2465 | DX=(XMax-XMin)/(nbpoints_x-1);
|
---|
| 2466 | if NbDim >1
|
---|
| 2467 | nbpoints_y=UvData.Field.DimValue(DimIndex(NbDim-1));
|
---|
| 2468 | DY=(YMax-YMin)/(nbpoints_y-1);
|
---|
| 2469 | end
|
---|
| 2470 | if NbDim==3
|
---|
| 2471 | nbpoints_z=UvData.Field.DimValue(DimIndex(1));
|
---|
| 2472 | DZ=(ZMax-ZMin)/(nbpoints_z-1);
|
---|
| 2473 | UvData.Field.Mesh=sqrt(DX*DY*DZ);
|
---|
| 2474 | UvData.Field.ZMax=ZMax;
|
---|
| 2475 | UvData.Field.ZMin=ZMin;
|
---|
| 2476 | else
|
---|
[221] | 2477 | UvData.Field.Mesh=DX;%sqrt(DX*DY);
|
---|
[206] | 2478 | end
|
---|
[199] | 2479 | end
|
---|
| 2480 | end
|
---|
| 2481 |
|
---|
| 2482 | %% 3D case (menuvolume)
|
---|
| 2483 | if NbDim==3% && UvData.NewSeries
|
---|
| 2484 | test_set_object=1;
|
---|
| 2485 | hset_object=findobj(allchild(0),'tag','set_object');% look for the set_object GUI
|
---|
| 2486 | ZBounds(1)=UvData.Field.ZMin; %minimum for the Z slider
|
---|
| 2487 | ZBounds(2)=UvData.Field.ZMax;%maximum for the Z slider
|
---|
| 2488 | if ~isempty(hset_object) %if set_object is detected
|
---|
| 2489 | % hhset_object=guidata(hset_object);
|
---|
| 2490 | % % ZBounds_old(1)=get(hhset_object.z_slider,'Min');
|
---|
| 2491 | % % ZBounds_old(2)=get(hhset_object.z_slider,'Max');
|
---|
| 2492 | % % if isequal(ZBounds_old,ZBounds)
|
---|
| 2493 | % test_set_object=0;% do not refresh the GUI set_object
|
---|
| 2494 | % else
|
---|
| 2495 | delete(hset_object);% delete the GUI set_object if it does not fit
|
---|
| 2496 | % end
|
---|
| 2497 | end
|
---|
| 2498 | if test_set_object% reinitiate the GUI set_object
|
---|
| 2499 | delete_object(1);% delete the current projection object in the list UvData.Object, delete its graphic representations and update the list displayed in handles.list_object_1 and 2
|
---|
| 2500 | UvData.Object{1}.Style='plane';%main plotting plane
|
---|
| 2501 | UvData.Object{1}.ProjMode='projection';%main plotting plane
|
---|
| 2502 | UvData.Object{1}.DisplayHandle_uvmat=[]; %plane not visible in uvmat
|
---|
| 2503 | UvData.Object{1}.NbDim=NbDim;%test for 3D objects
|
---|
| 2504 | UvData.Object{1}.RangeZ=UvData.Field.Mesh;%main plotting plane
|
---|
| 2505 | UvData.Object{1}.Coord(1,3)=(UvData.Field.ZMin+UvData.Field.ZMax)/2;%section at a middle plane chosen
|
---|
[206] | 2506 | UvData.Object{1}.Angle=[0 0 0];
|
---|
| 2507 | % UvData.Object{1}.Theta=0;
|
---|
| 2508 | % UvData.Object{1}.Psi=0;
|
---|
[199] | 2509 | UvData.Object{1}.HandlesDisplay=plot(0,0,'Tag','proj_object');% A REVOIR
|
---|
[206] | 2510 | % PlotHandles=get_plot_handles(handles);
|
---|
[199] | 2511 | UvData.Object{1}.Name='1-PLANE';
|
---|
| 2512 | UvData.Object{1}.enable_plot=1;
|
---|
[206] | 2513 | set_object(UvData.Object{1},handles,ZBounds);
|
---|
[199] | 2514 | set(handles.list_object_1,'Value',1);
|
---|
| 2515 | set(handles.list_object_1,'String',{'1-PLANE'});
|
---|
| 2516 | set(handles.edit_object,'Value',1)% put the plane in edit mode to enable the z cursor
|
---|
| 2517 | edit_object_Callback([],[], handles)
|
---|
| 2518 | end
|
---|
| 2519 | %multilevel case (single menuplane in a 3D space)
|
---|
| 2520 | elseif isfield(UvData,'Z')
|
---|
| 2521 | if isfield(UvData,'CoordType')&& isequal(UvData.CoordType,'phys') && isfield(UvData,'XmlData')
|
---|
| 2522 | XmlData=UvData.XmlData;
|
---|
| 2523 | if isfield(XmlData,'PlanePos')
|
---|
| 2524 | UvData.Object{1}.Coord=XmlData.PlanePos(UvData.ZIndex,:);
|
---|
| 2525 | end
|
---|
| 2526 | if isfield(XmlData,'PlaneAngle')
|
---|
| 2527 | siz=size(XmlData.PlaneAngle);
|
---|
| 2528 | indangle=min(siz(1),UvData.ZIndex);%take first angle if a single angle is defined (translating scanning)
|
---|
[206] | 2529 | UvData.Object{1}.PlaneAngle=XmlData.PlaneAngle(indangle,:);
|
---|
[199] | 2530 | end
|
---|
| 2531 | elseif isfield(UvData,'ZIndex')
|
---|
| 2532 | UvData.Object{1}.ZObject=UvData.ZIndex;
|
---|
| 2533 | end
|
---|
| 2534 | else
|
---|
| 2535 | % create a default projection menuplane
|
---|
| 2536 | %UvData.Object{1}.Style='none';%main plotting plane
|
---|
| 2537 | UvData.Object{1}.ProjMode='projection';%main plotting plane
|
---|
| 2538 | UvData.Object{1}.DisplayHandle_uvmat=[]; %plane not visible in uvmat
|
---|
| 2539 | set(handles.list_object_1,'Value',1);
|
---|
| 2540 | set(handles.list_object_1,'String',{''});
|
---|
| 2541 | end
|
---|
[215] | 2542 | % if ~isfield(UvData.Object{1},'plotaxes')
|
---|
| 2543 | % UvData.Object{1}.plotaxes=handles.axes3;%default plotting axis
|
---|
| 2544 | % end
|
---|
[199] | 2545 | testnewseries=UvData.NewSeries;
|
---|
| 2546 | UvData.NewSeries=0;% put to 0 the test for a new field series (set by RootPath_callback)
|
---|
| 2547 | set(handles.uvmat,'UserData',UvData)
|
---|
| 2548 |
|
---|
| 2549 | %% reset the min and max of scalar if only the mask is displayed(TODO: check the need)
|
---|
| 2550 | if isfield(UvData,'Mask')&& ~isfield(UvData,'A')
|
---|
| 2551 | set(handles.MinA,'String','0')
|
---|
| 2552 | set(handles.MaxA,'String','255')
|
---|
| 2553 | end
|
---|
| 2554 |
|
---|
| 2555 | %% Plot the projections on the selected projection objects
|
---|
| 2556 |
|
---|
| 2557 | % main projection object (uvmat display)
|
---|
| 2558 | IndexObj(1)=get(handles.list_object_1,'Value');%selected projection object for main view
|
---|
| 2559 | if IndexObj(1)> numel(UvData.Object)
|
---|
| 2560 | IndexObj(1)=1;%select the first object if the selected one does not exist
|
---|
| 2561 | set(handles.list_object_1,'Value',1)
|
---|
| 2562 | end
|
---|
| 2563 | plot_handles{1}=handles;
|
---|
[215] | 2564 | if isfield(UvData,'plotaxes')%case of movies
|
---|
| 2565 | haxes(1)=UvData.plotaxes;
|
---|
| 2566 | else
|
---|
| 2567 | haxes(1)=handles.axes3;
|
---|
| 2568 | end
|
---|
[199] | 2569 | PlotParam{1}=read_plot_param(handles);%read plotting parameters on the uvmat interfac
|
---|
| 2570 | keeplim(1)=get(handles.FixLimits,'Value');% test for fixed graph limits
|
---|
| 2571 | PosColorbar{1}=UvData.OpenParam.PosColorbar;%prescribe the colorbar position on the uvmat interface
|
---|
| 2572 |
|
---|
| 2573 | % second projection object (view_field display)
|
---|
| 2574 | IndexObj_2=get(handles.list_object_2,'Value');%selected projection object for the second view
|
---|
| 2575 | if isequal(get(handles.list_object_2,'Visible'),'on') && IndexObj_2 <= numel(UvData.Object)&& ~isempty(UvData.Object{IndexObj_2})
|
---|
| 2576 | IndexObj(2)=IndexObj_2;
|
---|
| 2577 | view_field_handle=findobj(allchild(0),'tag','view_field');%handles of the view_field GUI
|
---|
| 2578 | if ~isempty(view_field_handle)
|
---|
| 2579 | plot_handles{2}=guidata(view_field_handle);
|
---|
| 2580 | haxes(2)=plot_handles{2}.axes3;
|
---|
| 2581 | PlotParam{2}=read_plot_param(plot_handles{2});%read plotting parameters on the uvmat interface
|
---|
| 2582 | keeplim(2)=get(plot_handles{2}.FixLimits,'Value');
|
---|
| 2583 | PosColorbar{2}='*'; %TODO: deal with colorbar position on view_field
|
---|
| 2584 | end
|
---|
| 2585 | end
|
---|
| 2586 |
|
---|
| 2587 | %loop on the projection objects: one or two
|
---|
| 2588 | for imap=1:numel(IndexObj)
|
---|
[206] | 2589 | iobj=IndexObj(imap);
|
---|
[199] | 2590 | [ObjectData,errormsg]=proj_field(UvData.Field,UvData.Object{iobj});% project field on the object
|
---|
| 2591 | if testnewseries && isfield(ObjectData,'CoordUnit')
|
---|
| 2592 | PlotParam{imap}=rmfield(PlotParam{imap},'FixEqual'); %set FixEqual to depend on the field (=1 if Data.CoordUnit=1 in plot_field)
|
---|
| 2593 | end
|
---|
| 2594 | if ~isempty(errormsg)
|
---|
| 2595 | return
|
---|
| 2596 | end
|
---|
| 2597 | %use of mask (TODO: check)
|
---|
| 2598 | if isfield(ObjectData,'NbDim') && isequal(ObjectData.NbDim,2) && isfield(ObjectData,'Mask') && isfield(ObjectData,'A')
|
---|
| 2599 | flag_mask=double(ObjectData.Mask>200);%=0 for masked regions
|
---|
| 2600 | AX=ObjectData.AX;%x coordiantes for the scalar field
|
---|
| 2601 | AY=ObjectData.AY;%y coordinates for the scalar field
|
---|
| 2602 | MaskX=ObjectData.MaskX;%x coordiantes for the mask
|
---|
| 2603 | MaskY=ObjectData.MaskY;%y coordiantes for the mask
|
---|
| 2604 | if ~isequal(MaskX,AX)||~isequal(MaskY,AY)
|
---|
| 2605 | nxy=size(flag_mask);
|
---|
| 2606 | sizpx=(ObjectData.MaskX(end)-ObjectData.MaskX(1))/(nxy(2)-1);%size of a mask pixel
|
---|
| 2607 | sizpy=(ObjectData.MaskY(1)-ObjectData.MaskY(end))/(nxy(1)-1);
|
---|
| 2608 | x_mask=ObjectData.MaskX(1):sizpx:ObjectData.MaskX(end); % pixel x coordinates for image display
|
---|
| 2609 | y_mask=ObjectData.MaskY(1):-sizpy:ObjectData.MaskY(end);% pixel x coordinates for image display
|
---|
| 2610 | %project on the positions of the scalar
|
---|
| 2611 | npxy=size(ObjectData.A);
|
---|
| 2612 | dxy(1)=(ObjectData.AY(end)-ObjectData.AY(1))/(npxy(1)-1);%grid mesh in y
|
---|
| 2613 | dxy(2)=(ObjectData.AX(end)-ObjectData.AX(1))/(npxy(2)-1);%grid mesh in x
|
---|
| 2614 | xi=ObjectData.AX(1):dxy(2):ObjectData.AX(end);
|
---|
| 2615 | yi=ObjectData.AY(1):dxy(1):ObjectData.AY(end);
|
---|
| 2616 | [XI,YI]=meshgrid(xi,yi);% creates the matrix of regular coordinates
|
---|
| 2617 | flag_mask = interp2(x_mask,y_mask,flag_mask,XI,YI);
|
---|
| 2618 | end
|
---|
| 2619 | AClass=class(ObjectData.A);
|
---|
| 2620 | ObjectData.A=flag_mask.*double(ObjectData.A);
|
---|
| 2621 | ObjectData.A=feval(AClass,ObjectData.A);
|
---|
| 2622 | ind_off=[];
|
---|
| 2623 | if isfield(ObjectData,'ListVarName')
|
---|
| 2624 | for ilist=1:length(ObjectData.ListVarName)
|
---|
| 2625 | if isequal(ObjectData.ListVarName{ilist},'Mask')||isequal(ObjectData.ListVarName{ilist},'MaskX')||isequal(ObjectData.ListVarName{ilist},'MaskY')
|
---|
| 2626 | ind_off=[ind_off ilist];
|
---|
| 2627 | end
|
---|
| 2628 | end
|
---|
| 2629 | ObjectData.ListVarName(ind_off)=[];
|
---|
| 2630 | ObjectData.VarDimIndex(ind_off)=[];
|
---|
| 2631 | ind_off=[];
|
---|
| 2632 | for ilist=1:length(ObjectData.ListDimName)
|
---|
| 2633 | if isequal(ObjectData.ListDimName{ilist},'MaskX') || isequal(ObjectData.ListDimName{ilist},'MaskY')
|
---|
| 2634 | ind_off=[ind_off ilist];
|
---|
| 2635 | end
|
---|
| 2636 | end
|
---|
| 2637 | ObjectData.ListDimName(ind_off)=[];
|
---|
| 2638 | ObjectData.DimValue(ind_off)=[];
|
---|
| 2639 | end
|
---|
| 2640 | end
|
---|
| 2641 | if ~isempty(ObjectData)
|
---|
| 2642 | PlotType='none'; %default
|
---|
| 2643 | if imap==2 && isempty(view_field_handle)
|
---|
| 2644 | view_field(ObjectData)
|
---|
| 2645 | else
|
---|
| 2646 | [PlotType,PlotParamOut]=plot_field(ObjectData,haxes(imap),PlotParam{imap},PosColorbar{imap});
|
---|
| 2647 | write_plot_param(plot_handles{imap},PlotParamOut) %update the auto plot parameters
|
---|
| 2648 | if isfield(Field,'Mesh')&&~isempty(Field.Mesh)
|
---|
| 2649 | ObjectData.Mesh=Field.Mesh; % gives an estimated mesh size (useful for mouse action on the plot)
|
---|
| 2650 | end
|
---|
| 2651 | end
|
---|
| 2652 | if isequal(PlotType,'none')
|
---|
| 2653 | hget_field=findobj(allchild(0),'name','get_field');
|
---|
| 2654 | if isempty(hget_field)
|
---|
| 2655 | get_field(filename)% the projected field cannot be automatically plotted: use get_field to specify the variablesdelete(hget_field)
|
---|
| 2656 | end
|
---|
| 2657 | errormsg='The field defined by get_field cannot be plotted';
|
---|
| 2658 | return
|
---|
| 2659 | end
|
---|
| 2660 | end
|
---|
| 2661 | end
|
---|
| 2662 |
|
---|
| 2663 | %% update the mask
|
---|
| 2664 | if isequal(get(handles.mask_test,'Value'),1)%if the mask option is on
|
---|
| 2665 | update_mask(handles,num_i1,num_i2);
|
---|
| 2666 | end
|
---|
| 2667 |
|
---|
| 2668 | %% prepare the menus of histograms and plot them (histogram of the whole volume in 3D case)
|
---|
| 2669 | menu_histo=(UvData.Field.ListVarName)';%list of field variables to be displayed for the menu of histogram display
|
---|
| 2670 | ind_bad=[];
|
---|
| 2671 | nb_histo=1;
|
---|
| 2672 |
|
---|
| 2673 | % suppress coordinates from the histogram menu
|
---|
| 2674 | for ivar=1:numel(menu_histo)%l loop on field variables:
|
---|
| 2675 | if isfield(UvData.Field,'VarAttribute') && numel(UvData.Field.VarAttribute)>=ivar && isfield(UvData.Field.VarAttribute{ivar},'Role')
|
---|
| 2676 | Role=UvData.Field.VarAttribute{ivar}.Role;
|
---|
| 2677 | switch Role
|
---|
| 2678 | case {'coord_x','coord_y','coord_z','dimvar'}
|
---|
| 2679 | ind_bad=[ind_bad ivar];
|
---|
| 2680 | case {'vector_y'}
|
---|
| 2681 | nb_histo=nb_histo+1;
|
---|
| 2682 | end
|
---|
| 2683 | end
|
---|
| 2684 | DimCell=UvData.Field.VarDimName{ivar};
|
---|
| 2685 | DimName='';
|
---|
| 2686 | if ischar(DimCell)
|
---|
| 2687 | DimName=DimCell;
|
---|
| 2688 | elseif iscell(DimCell)&& numel(DimCell)==1
|
---|
| 2689 | DimName=DimCell{1};
|
---|
| 2690 | end
|
---|
| 2691 | if strcmp(DimName,menu_histo{ivar})
|
---|
| 2692 | ind_bad=[ind_bad ivar];
|
---|
| 2693 | end
|
---|
| 2694 | end
|
---|
| 2695 | menu_histo(ind_bad)=[];
|
---|
| 2696 |
|
---|
| 2697 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
---|
| 2698 | % display menus and plot histograms
|
---|
| 2699 | test_v=0;
|
---|
| 2700 | if ~isempty(menu_histo)
|
---|
| 2701 | set(handles.histo1_menu,'Value',1)
|
---|
| 2702 | set(handles.histo1_menu,'String',menu_histo)
|
---|
| 2703 | histo1_menu_Callback(handles.histo1_menu, [], handles)% plot first histogram
|
---|
| 2704 | % case of more than one variables (eg vector components)
|
---|
| 2705 | if nb_histo > 1
|
---|
| 2706 | test_v=1;
|
---|
| 2707 | set(handles.histo2_menu,'Visible','on')
|
---|
| 2708 | set(handles.histo_v,'Visible','on')
|
---|
| 2709 | set(handles.histo2_menu,'String',menu_histo)
|
---|
| 2710 | set(handles.histo2_menu,'Value',2)
|
---|
| 2711 | histo2_menu_Callback(handles.histo2_menu,[], handles)% plot second histogram
|
---|
| 2712 | end
|
---|
| 2713 | end
|
---|
| 2714 | if ~test_v
|
---|
| 2715 | set(handles.histo2_menu,'Visible','off')
|
---|
| 2716 | set(handles.histo_v,'Visible','off')
|
---|
| 2717 | cla(handles.histo_v)
|
---|
| 2718 | set(handles.histo2_menu,'Value',1)
|
---|
| 2719 | end
|
---|
| 2720 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
---|
| 2721 |
|
---|
| 2722 | %% display time
|
---|
| 2723 | testimedoc=0;
|
---|
[221] | 2724 | TimeUnit='';
|
---|
| 2725 | if isfield(UvData.Field,'Time')
|
---|
| 2726 | abstime=UvData.Field.Time;%time read from the netcdf input file
|
---|
| 2727 | end
|
---|
| 2728 | if isfield(UvData,'Field_1') && isfield(UvData.Field_1,'Time')
|
---|
| 2729 | abstime_1=UvData.Field_1.Time;%time read from the netcdf input file
|
---|
| 2730 | end
|
---|
| 2731 | if isfield(UvData.Field,'dt')
|
---|
| 2732 | dt=UvData.Field.dt;%dt read from the netcdf input file
|
---|
| 2733 | if isfield(UvData.Field,'TimeUnit')
|
---|
| 2734 | TimeUnit=UvData.Field.TimeUnit;
|
---|
| 2735 | end
|
---|
| 2736 | elseif isfield(UvData,'Field_1') && isfield(UvData.Field_1,'dt')%dt obtained from the second field if not defined in the first
|
---|
| 2737 | dt=UvData.Field_1.dt;%dt read from the netcdf input file
|
---|
| 2738 | if isfield(UvData.Field_1,'TimeUnit')
|
---|
| 2739 | TimeUnit=UvData.Field_1.TimeUnit;
|
---|
| 2740 | end
|
---|
| 2741 | end
|
---|
| 2742 | % time from xml file overset previous result
|
---|
[199] | 2743 | if isfield(UvData,'XmlData') && isfield(UvData.XmlData,'Time')
|
---|
| 2744 | if isempty(num_i2)||isnan(num_i2)
|
---|
| 2745 | num_i2=num_i1;
|
---|
| 2746 | end
|
---|
| 2747 | if isempty(num_j1)||isnan(num_j1)
|
---|
| 2748 | num_j1=1;
|
---|
| 2749 | end
|
---|
| 2750 | if isempty(num_j2)||isnan(num_j2)
|
---|
| 2751 | num_j2=num_j1;
|
---|
| 2752 | end
|
---|
| 2753 | siz=size(UvData.XmlData.Time);
|
---|
| 2754 | if siz(1)>=max(num_i1,num_i2) && siz(2)>=max(num_j1,num_j2)
|
---|
| 2755 | abstime=(UvData.XmlData.Time(num_i1,num_j1)+UvData.XmlData.Time(num_i2,num_j2))/2;%overset the time read from files
|
---|
| 2756 | dt=(UvData.XmlData.Time(num_i2,num_j2)-UvData.XmlData.Time(num_i1,num_j1));
|
---|
| 2757 | testimedoc=1;
|
---|
[221] | 2758 | if isfield(UvData.XmlData,'TimeUnit')
|
---|
| 2759 | TimeUnit=UvData.XmlData.TimeUnit;
|
---|
| 2760 | end
|
---|
[199] | 2761 | end
|
---|
| 2762 | end
|
---|
| 2763 | if isfield(UvData,'XmlData_1') && isfield(UvData.XmlData_1,'Time')
|
---|
| 2764 | [P,F,str1,str2,str_a,str_b,E]=name2display(['xx' get(handles.FileIndex_1,'String') get(handles.FileExt_1,'String')]);
|
---|
| 2765 | num_i2=str2double(str2);
|
---|
| 2766 | if isnan(num_i2)
|
---|
| 2767 | num_i2=num_i1;
|
---|
| 2768 | end
|
---|
| 2769 | num_j1=str2double(str_a);
|
---|
| 2770 | if isnan(num_j1)
|
---|
| 2771 | num_j1=1;
|
---|
| 2772 | end
|
---|
| 2773 | num_j2=str2double(str_b);
|
---|
| 2774 | if isnan(num_j2)
|
---|
| 2775 | num_j2=num_j1;
|
---|
| 2776 | end
|
---|
| 2777 | num_i1=str2double(str1);
|
---|
| 2778 | siz=size(UvData.XmlData_1.Time);
|
---|
| 2779 | if siz(1)>=max(num_i1,num_i2) && siz(2)>=max(num_j1,num_j2)
|
---|
| 2780 | 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
|
---|
| 2781 | end
|
---|
| 2782 | end
|
---|
| 2783 | set(handles.abs_time,'String',num2str(abstime,4))
|
---|
| 2784 | set(handles.abs_time_1,'String',num2str(abstime_1,4))
|
---|
| 2785 | if testimedoc && isfield(UvData,'dt')
|
---|
| 2786 | dt=UvData.dt;
|
---|
| 2787 | end
|
---|
| 2788 | if isempty(dt)||isequal(dt,0)
|
---|
| 2789 | set(handles.Dt_txt,'String','')
|
---|
| 2790 | else
|
---|
[221] | 2791 | if isempty(TimeUnit)
|
---|
[199] | 2792 | set(handles.Dt_txt,'String',['Dt=' num2str(1000*dt,3) ' 10^(-3)'] )
|
---|
| 2793 | else
|
---|
[221] | 2794 | set(handles.Dt_txt,'String',['Dt=' num2str(1000*dt,3) ' m' TimeUnit] )
|
---|
[199] | 2795 | end
|
---|
| 2796 | end
|
---|
| 2797 |
|
---|
| 2798 |
|
---|
| 2799 | %-------------------------------------------------------------------
|
---|
| 2800 | % --- translate coordinate to matrix index
|
---|
| 2801 | %-------------------------------------------------------------------
|
---|
| 2802 | function [indx,indy]=pos2ind(x0,rangx0,nxy)
|
---|
| 2803 | indx=1+round((nxy(2)-1)*(x0-rangx0(1))/(rangx0(2)-rangx0(1)));% index x of pixel
|
---|
| 2804 | indy=1+round((nxy(1)-1)*(y12-rangy0(1))/(rangy0(2)-rangy0(1)));% index y of pixel
|
---|
| 2805 |
|
---|
| 2806 | %-------------------------------------------------------------------
|
---|
| 2807 | % --- Executes on button press in 'FixLimits'.
|
---|
| 2808 | %-------------------------------------------------------------------
|
---|
| 2809 | function FixLimits_Callback(hObject, eventdata, handles)
|
---|
| 2810 | test=get(handles.FixLimits,'Value');
|
---|
| 2811 | if test
|
---|
| 2812 | set(handles.FixLimits,'BackgroundColor',[1 1 0])
|
---|
| 2813 | else
|
---|
| 2814 | set(handles.FixLimits,'BackgroundColor',[0.7 0.7 0.7])
|
---|
| 2815 | update_plot(handles);
|
---|
| 2816 | end
|
---|
| 2817 |
|
---|
| 2818 | %-------------------------------------------------------------------
|
---|
| 2819 | % --- Executes on button press in FixEqual.
|
---|
| 2820 | function FixEqual_Callback(hObject, eventdata, handles)
|
---|
| 2821 | test=get(handles.FixEqual,'Value');
|
---|
| 2822 | if test
|
---|
| 2823 | set(handles.FixEqual,'BackgroundColor',[1 1 0])
|
---|
| 2824 | cla(handles.axes3)
|
---|
| 2825 | update_plot(handles);
|
---|
| 2826 | else
|
---|
| 2827 | set(handles.FixEqual,'BackgroundColor',[0.7 0.7 0.7])
|
---|
| 2828 | update_plot(handles);
|
---|
| 2829 | % axis(handles.axes3,'image')
|
---|
| 2830 | end
|
---|
| 2831 |
|
---|
| 2832 |
|
---|
| 2833 | %-------------------------------------------------------------------
|
---|
| 2834 |
|
---|
| 2835 | %-------------------------------------------------------------------
|
---|
| 2836 | % --- Executes on button press in 'zoom'.
|
---|
| 2837 | %-------------------------------------------------------------------
|
---|
| 2838 | function zoom_Callback(hObject, eventdata, handles)
|
---|
| 2839 |
|
---|
| 2840 | if (get(handles.zoom,'Value') == 1);
|
---|
| 2841 | set(handles.zoom,'BackgroundColor',[1 1 0])
|
---|
| 2842 | set(handles.FixLimits,'Value',1)% propose by default fixed limits for the plotting axes
|
---|
| 2843 | set(handles.FixLimits,'BackgroundColor',[1 1 0])
|
---|
| 2844 | else
|
---|
| 2845 | set(handles.zoom,'BackgroundColor',[0.7 0.7 0.7])
|
---|
| 2846 | end
|
---|
| 2847 |
|
---|
| 2848 |
|
---|
| 2849 | %-------------------------------------------------------------------
|
---|
| 2850 | %----Executes on button press in 'record': records the current flags of manual correction.
|
---|
| 2851 | %-------------------------------------------------------------------
|
---|
| 2852 | function record_Callback(hObject, eventdata, handles)
|
---|
| 2853 | % [filebase,num_i1,num_j1,num_i2,num_j2,Ext,NomType,SubDir]=read_input_file(handles);
|
---|
| 2854 | filename=read_file_boxes(handles);
|
---|
| 2855 | [erread,message]=fileattrib(filename);
|
---|
| 2856 | if ~isempty(message) && ~isequal(message.UserWrite,1)
|
---|
| 2857 | msgbox_uvmat('ERROR',['no writting access to ' filename])
|
---|
| 2858 | return
|
---|
| 2859 | end
|
---|
| 2860 | test_civ2=isequal(get(handles.civ2,'BackgroundColor'),[1 1 0]);
|
---|
| 2861 | test_civ1=isequal(get(handles.civ1,'BackgroundColor'),[1 1 0]);
|
---|
| 2862 | if ~test_civ2 && ~test_civ1
|
---|
| 2863 | msgbox_uvmat('ERROR','manual correction only possible for CIV1 or CIV2 velocity fields')
|
---|
| 2864 | end
|
---|
| 2865 | if test_civ2
|
---|
| 2866 | nbname='nb_vectors2';
|
---|
| 2867 | flagname='vec2_FixFlag';
|
---|
| 2868 | attrname='fix2';
|
---|
| 2869 | end
|
---|
| 2870 | if test_civ1
|
---|
| 2871 | nbname='nb_vectors';
|
---|
| 2872 | flagname='vec_FixFlag';
|
---|
| 2873 | attrname='fix';
|
---|
| 2874 | end
|
---|
| 2875 | %write fix flags in the netcdf file
|
---|
| 2876 | UvData=get(handles.uvmat,'UserData');
|
---|
| 2877 | hhh=which('netcdf.open');% look for built-in matlab netcdf library
|
---|
| 2878 | if ~isequal(hhh,'')% case of new builtin Matlab netcdf library
|
---|
| 2879 | nc=netcdf.open(filename,'NC_WRITE');
|
---|
| 2880 | netcdf.reDef(nc);
|
---|
| 2881 | netcdf.putAtt(nc,netcdf.getConstant('NC_GLOBAL'),attrname,1);
|
---|
| 2882 | dimid = netcdf.inqDimID(nc,nbname);
|
---|
| 2883 | try
|
---|
| 2884 | varid = netcdf.inqVarID(nc,flagname);% look for already existing fixflag variable
|
---|
| 2885 | catch
|
---|
| 2886 | varid=netcdf.defVar(nc,flagname,'double',dimid);%create fixflag variable if it does not exist
|
---|
| 2887 | end
|
---|
| 2888 | netcdf.endDef(nc);
|
---|
| 2889 | netcdf.putVar(nc,varid,UvData.axes3.FF);
|
---|
| 2890 | netcdf.close(nc);
|
---|
| 2891 | else %old netcdf library
|
---|
| 2892 | netcdf_toolbox(filename,AxeData,attrname,nbname,flagname)
|
---|
| 2893 | end
|
---|
| 2894 |
|
---|
| 2895 | %-------------------------------------------------------------------
|
---|
| 2896 | %----Correct the netcdf file, using toolbox (old versions of Matlab).
|
---|
| 2897 | %-------------------------------------------------------------------
|
---|
| 2898 | function netcdf_toolbox(filename,AxeData,attrname,nbname,flagname)
|
---|
| 2899 | nc=netcdf(filename,'write'); %open netcdf file
|
---|
| 2900 | result=redef(nc);
|
---|
| 2901 | eval(['nc.' attrname '=1;']);
|
---|
| 2902 | theDim=nc(nbname) ;% get the number of velocity vectors
|
---|
| 2903 | nb_vectors=size(theDim);
|
---|
| 2904 | var_FixFlag=ncvar(flagname,nc);% var_FixFlag will be written as the netcdf variable vec_FixFlag
|
---|
| 2905 | var_FixFlag(1:nb_vectors)=AxeData.FF;%
|
---|
| 2906 | fin=close(nc);
|
---|
| 2907 |
|
---|
| 2908 |
|
---|
| 2909 | %-------------------------------------------------------------------
|
---|
| 2910 | %determines the fields to read from the interface
|
---|
| 2911 | %------------------------------------------------------------------
|
---|
| 2912 | function [VelType,civ]=setfield(handles)
|
---|
| 2913 |
|
---|
| 2914 | VelType=[]; %default
|
---|
| 2915 | if (get(handles.civ1,'Value') == 1);
|
---|
| 2916 | VelType='civ1';
|
---|
| 2917 | % interp1
|
---|
| 2918 | elseif (get(handles.interp1,'Value') == 1);
|
---|
| 2919 | VelType='interp1';
|
---|
| 2920 | % filter1
|
---|
| 2921 | elseif (get(handles.filter1,'Value') == 1);
|
---|
| 2922 | VelType='filter1';
|
---|
| 2923 | % CIV2
|
---|
| 2924 | elseif (get(handles.civ2,'Value') == 1);
|
---|
| 2925 | VelType='civ2';
|
---|
| 2926 | % interp2
|
---|
| 2927 | elseif (get(handles.interp2,'Value') == 1);
|
---|
| 2928 | VelType='interp2';
|
---|
| 2929 | % filter2
|
---|
| 2930 | elseif (get(handles.filter2,'Value') == 1);
|
---|
| 2931 | VelType='filter2';
|
---|
| 2932 | end
|
---|
| 2933 |
|
---|
| 2934 | if isequal(get(handles.filter2,'Visible'),'on');
|
---|
| 2935 | civ=6;
|
---|
| 2936 | % interp1
|
---|
| 2937 | elseif isequal(get(handles.interp2,'Visible'),'on');
|
---|
| 2938 | civ=5;
|
---|
| 2939 | % filter1
|
---|
| 2940 | elseif isequal(get(handles.civ2,'Visible'),'on');
|
---|
| 2941 | civ=4;
|
---|
| 2942 | % CIV2
|
---|
| 2943 | elseif isequal(get(handles.filter1,'Visible'),'on');
|
---|
| 2944 | civ=3;
|
---|
| 2945 | % interp2
|
---|
| 2946 | elseif isequal(get(handles.interp1,'Visible'),'on');
|
---|
| 2947 | civ=2;
|
---|
| 2948 | % filter2
|
---|
| 2949 | elseif isequal(get(handles.civ1,'Visible'),'on');
|
---|
| 2950 | civ=1;
|
---|
| 2951 | else
|
---|
| 2952 | civ=0;
|
---|
| 2953 | end
|
---|
| 2954 |
|
---|
| 2955 | %-------------------------------------------------------------------
|
---|
| 2956 | %determines the veltype of the second field to read from the iinterface
|
---|
| 2957 | %------------------------------------------------------------------
|
---|
| 2958 | function VelType=setfield_1(handles)
|
---|
| 2959 |
|
---|
| 2960 | VelType=[]; %default
|
---|
| 2961 | if (get(handles.civ1_1,'Value') == 1);
|
---|
| 2962 | VelType='civ1';
|
---|
| 2963 | % interp1
|
---|
| 2964 | elseif (get(handles.interp1_1,'Value') == 1);
|
---|
| 2965 | VelType='interp1';
|
---|
| 2966 | % filter1
|
---|
| 2967 | elseif (get(handles.filter1_1,'Value') == 1);
|
---|
| 2968 | VelType='filter1';
|
---|
| 2969 | % CIV2
|
---|
| 2970 | elseif (get(handles.civ2_1,'Value') == 1);
|
---|
| 2971 | VelType='civ2';
|
---|
| 2972 | % interp2
|
---|
| 2973 | elseif (get(handles.interp2_1,'Value') == 1);
|
---|
| 2974 | VelType='interp2';
|
---|
| 2975 | % filter2
|
---|
| 2976 | elseif (get(handles.filter2_1,'Value') == 1);
|
---|
| 2977 | VelType='filter2';
|
---|
| 2978 | end
|
---|
| 2979 |
|
---|
| 2980 |
|
---|
| 2981 | %---------------------------------------------------
|
---|
| 2982 | % --- Executes on button press in SubField
|
---|
| 2983 | function SubField_Callback(hObject, eventdata, handles)
|
---|
| 2984 | huvmat=get(handles.run0,'parent');
|
---|
| 2985 | UvData=get(huvmat,'UserData');
|
---|
| 2986 | if get(handles.SubField,'Value')==0% if the subfield button is desactivated
|
---|
| 2987 | set(handles.RootPath_1,'String','')
|
---|
| 2988 | set(handles.RootFile_1,'String','')
|
---|
| 2989 | set(handles.SubDir_1,'String','');
|
---|
| 2990 | set(handles.FileIndex_1,'String','');
|
---|
| 2991 | set(handles.FileExt_1,'String','');
|
---|
| 2992 | set(handles.RootPath_1,'Visible','off')
|
---|
| 2993 | set(handles.RootFile_1,'Visible','off')
|
---|
| 2994 | set(handles.SubDir_1,'Visible','off');
|
---|
| 2995 | set(handles.FileIndex_1,'Visible','off');
|
---|
| 2996 | set(handles.FileExt_1,'Visible','off');
|
---|
| 2997 | set(handles.Fields_1,'Value',1);%set to blank state
|
---|
| 2998 | set_veltype_display([handles.civ1_1 handles.interp1_1 handles.filter1_1 ...
|
---|
| 2999 | handles.civ2_1 handles.interp2_1 handles.filter2_1],0)
|
---|
| 3000 | if isfield(UvData,'XmlData_1')
|
---|
| 3001 | UvData=rmfield(UvData,'XmlData_1');
|
---|
| 3002 | end
|
---|
| 3003 | set(huvmat,'UserData',UvData);
|
---|
| 3004 | run0_Callback(hObject, eventdata, handles); %run
|
---|
| 3005 | else
|
---|
| 3006 | MenuBrowse_1_Callback(hObject, eventdata, handles)
|
---|
| 3007 | end
|
---|
| 3008 |
|
---|
| 3009 | %------------------------------------------------------------------------
|
---|
| 3010 | % --- read the data displayed for the input rootfile windows (new)
|
---|
| 3011 | function [FileName,RootPath,FileBase,FileIndices,FileExt,SubDir]=read_file_boxes(handles)
|
---|
| 3012 | %------------------------------------------------------------------------
|
---|
| 3013 | RootPath=get(handles.RootPath,'String');
|
---|
| 3014 | FileName=RootPath; %default
|
---|
| 3015 | SubDir=get(handles.SubDir,'String');
|
---|
| 3016 | if ~isempty(SubDir) && ~isequal(SubDir,'')
|
---|
| 3017 | if (isequal(SubDir(1),'/')|| isequal(SubDir(1),'\'))
|
---|
| 3018 | SubDir(1)=[]; %suppress possible / or \ separator
|
---|
| 3019 | end
|
---|
| 3020 | FileName=fullfile(RootPath,SubDir);
|
---|
| 3021 | end
|
---|
| 3022 | RootFile=get(handles.RootFile,'String');
|
---|
| 3023 | if ~isempty(RootFile) && ~isequal(RootFile,'')
|
---|
| 3024 | if (isequal(RootFile(1),'/')|| isequal(RootFile(1),'\'))
|
---|
| 3025 | RootFile(1)=[]; %suppress possible / or \ separator
|
---|
| 3026 | end
|
---|
| 3027 | FileName=fullfile(FileName,RootFile);
|
---|
| 3028 | end
|
---|
| 3029 | FileBase=fullfile(RootPath,RootFile);
|
---|
| 3030 | FileIndices=get(handles.FileIndex,'String');
|
---|
| 3031 | FileExt=get(handles.FileExt,'String');
|
---|
| 3032 | FileName=[FileName FileIndices FileExt];
|
---|
| 3033 |
|
---|
| 3034 | %------------------------------------------------------------------------
|
---|
| 3035 | % ---- read the data displayed for the second input rootfile windows
|
---|
| 3036 | function [FileName_1,RootPath_1,FileBase_1,FileIndices_1,FileExt_1,SubDir_1]=read_file_boxes_1(handles)
|
---|
| 3037 | %------------------------------------------------------------------------
|
---|
| 3038 | RootPath_1=get(handles.RootPath_1,'String'); % read the data from the file1_input window
|
---|
| 3039 | if isequal(get(handles.RootPath_1,'Visible'),'off') || isequal(RootPath_1,'"')
|
---|
| 3040 | RootPath_1=get(handles.RootPath,'String');
|
---|
| 3041 | end;
|
---|
| 3042 | FileName_1=RootPath_1; %default
|
---|
| 3043 | SubDir_1=get(handles.SubDir_1,'String');
|
---|
| 3044 | if isequal(get(handles.SubDir_1,'Visible'),'off')|| isequal(SubDir_1,'"')
|
---|
| 3045 | SubDir_1=get(handles.SubDir,'String');
|
---|
| 3046 | end
|
---|
| 3047 | if numel(SubDir_1)>=1
|
---|
| 3048 | if (isequal(SubDir_1(1),'/')|| isequal(SubDir_1(1),'\'))
|
---|
| 3049 | SubDir_1(1)=[]; %suppress possible / or \ separator
|
---|
| 3050 | end
|
---|
| 3051 | FileName_1=fullfile(RootPath_1,SubDir_1);
|
---|
| 3052 | end
|
---|
| 3053 | RootFile_1=get(handles.RootFile_1,'String');
|
---|
| 3054 | if isequal(get(handles.RootFile_1,'Visible'),'off') || isequal(RootFile_1,'"')
|
---|
| 3055 | RootFile_1=get(handles.RootFile,'String');
|
---|
| 3056 | end
|
---|
| 3057 | if numel(RootFile_1)>=1
|
---|
[210] | 3058 | if ~(isequal(RootFile_1(1),'/')||isequal(RootFile_1(1),'\'))
|
---|
[199] | 3059 | RootFile_1(1)=[];%suppress possible / or \ separator
|
---|
| 3060 | end
|
---|
| 3061 | FileName_1=fullfile(FileName_1,RootFile_1);
|
---|
| 3062 | end
|
---|
| 3063 | FileBase_1=fullfile(RootPath_1,RootFile_1);
|
---|
| 3064 | if isequal(get(handles.FileIndex_1,'Visible'),'off')
|
---|
| 3065 | FileIndices_1=get(handles.FileIndex,'String');
|
---|
| 3066 | else
|
---|
| 3067 | FileIndices_1=get(handles.FileIndex_1,'String');
|
---|
| 3068 | end
|
---|
| 3069 | FileExt_1=get(handles.FileExt_1,'String');
|
---|
| 3070 | if isequal(FileExt_1,'"'),FileExt_1=get(handles.FileExt,'String'); end;
|
---|
| 3071 | FileName_1=[FileName_1 FileIndices_1 FileExt_1];
|
---|
| 3072 |
|
---|
| 3073 | %------------------------------------------------------------------------
|
---|
| 3074 | % --- Executes on menu selection Fields
|
---|
| 3075 | function Fields_Callback(hObject, eventdata, handles)
|
---|
| 3076 | %------------------------------------------------------------------------
|
---|
| 3077 | list_fields=get(handles.Fields,'String');% list menu fields
|
---|
| 3078 | index_fields=get(handles.Fields,'Value');% selected string index
|
---|
| 3079 | field= list_fields{index_fields(1)}; % selected string
|
---|
| 3080 | if isequal(field,'get_field...')
|
---|
| 3081 | veltype_handles=[handles.civ1 handles.interp1 handles.filter1 handles.civ2 handles.interp2 handles.filter2];
|
---|
| 3082 | set_veltype_display(veltype_handles,0) % unvisible civ buttons
|
---|
| 3083 | filename=read_file_boxes(handles);
|
---|
| 3084 | hget_field=findobj(allchild(0),'name','get_field');
|
---|
| 3085 | if ~isempty(hget_field)
|
---|
| 3086 | delete(hget_field)
|
---|
| 3087 | end
|
---|
| 3088 | hget_field=get_field(filename);
|
---|
| 3089 | set(hget_field,'Name','get_field')
|
---|
| 3090 | hhget_field=guidata(hget_field);
|
---|
| 3091 | set(hhget_field.list_fig,'Value',1)
|
---|
| 3092 | set(hhget_field.list_fig,'String',{'uvmat'})
|
---|
| 3093 | set(handles.transform_fct,'Value',1)% no transform by default
|
---|
| 3094 | set(handles.path_transform,'String','')
|
---|
| 3095 | return %no action
|
---|
| 3096 | end
|
---|
| 3097 | list_fields=get(handles.Fields_1,'String');% list menu fields
|
---|
| 3098 | index_fields=get(handles.Fields_1,'Value');% selected string index
|
---|
| 3099 | field_1= list_fields{index_fields(1)}; % selected string
|
---|
| 3100 | UvData=get(handles.uvmat,'UserData');
|
---|
| 3101 |
|
---|
| 3102 | %read the rootfile input display
|
---|
| 3103 | [FileName,RootPath,FileBase,FileIndices,FileExt]=read_file_boxes(handles);
|
---|
| 3104 | [P,F,str1,str2,str_a,str_b,E,NomType]=name2display(['xxx' get(handles.FileIndex,'String') FileExt]);
|
---|
| 3105 | NomTypeNew=NomType;%default
|
---|
| 3106 | if isequal(field,'image')
|
---|
| 3107 | % transform netc type to the corresponding image type
|
---|
| 3108 | % if isequal(NomType,'_i1-i2_j')||isequal(NomType,'_i_j1-j2')|| isequal(NomType,'#_ab')|| isequal(NomType,'_i1-i2')
|
---|
| 3109 | % UvData.SubDir=get(handles.SubDir,'String'); %preserve the subdir in memory
|
---|
| 3110 | % if ~isempty(UvData.SubDir) && (isequal(UvData.SubDir(1),'/')||isequal(UvData.SubDir(1),'/'))
|
---|
| 3111 | % UvData.SubDir(1)=[];
|
---|
| 3112 | % end
|
---|
| 3113 | % set(handles.SubDir,'String','')
|
---|
| 3114 | % set(handles.FileExt,'String','.png');
|
---|
| 3115 | if isequal(NomType,'_i1-i2_j')||isequal(NomType,'_i_j1-j2')
|
---|
| 3116 | NomTypeNew='_i_j';
|
---|
| 3117 | elseif isequal(NomType,'#_ab')
|
---|
| 3118 | NomTypeNew='#a';
|
---|
| 3119 | elseif isequal(NomType,'_i1-i2')
|
---|
| 3120 | NomTypeNew='_i';
|
---|
| 3121 | end
|
---|
| 3122 | imagename=name_generator(FileBase,str2double(str1),str2double(str_a),'.png',NomTypeNew,1,str2double(str2),str2double(str_b),'');
|
---|
| 3123 | if ~exist(imagename,'file')
|
---|
| 3124 | [FileName,PathName] = uigetfile( ...
|
---|
| 3125 | {'*.png;*.jpg;*.tif;*.avi;*.AVI;*.vol', ' (*.png, .tif, *.avi,*.vol)';
|
---|
| 3126 | '*.jpg',' jpeg image files'; ...
|
---|
| 3127 | '*.png','.png image files'; ...
|
---|
| 3128 | '*.tif','.tif image files'; ...
|
---|
| 3129 | '*.avi;*.AVI','.avi movie files'; ...
|
---|
| 3130 | '*.vol','.volume images (png)'; ...
|
---|
| 3131 | '*.*', 'All Files (*.*)'}, ...
|
---|
| 3132 | 'Pick an image',imagename);
|
---|
| 3133 | % display the selected field and related information
|
---|
| 3134 | imagename=[PathName FileName];
|
---|
| 3135 | end
|
---|
| 3136 | display_file_name(hObject, eventdata, handles,imagename)%display the image
|
---|
| 3137 | return
|
---|
| 3138 | % end
|
---|
| 3139 | % veltype_handles=[handles.civ1 handles.interp1 handles.filter1 handles.civ2 handles.interp2 handles.filter2];
|
---|
| 3140 | % set_veltype_display(veltype_handles,0) % unvisible civ buttons
|
---|
| 3141 | else
|
---|
| 3142 | ext=get(handles.FileExt,'String');
|
---|
| 3143 | if ~isequal(ext,'.nc') %find the new NomType if the previous display was not already a netcdf file
|
---|
| 3144 | [FileName,PathName] = uigetfile( ...
|
---|
| 3145 | {'*.nc', ' (*.nc)';
|
---|
| 3146 | '*.nc',' netcdf files'; ...
|
---|
| 3147 | '*.*', 'All Files (*.*)'}, ...
|
---|
| 3148 | 'Pick a netcdf file',FileBase);
|
---|
| 3149 | % display the selected field and related information
|
---|
| 3150 | filename=[PathName FileName];
|
---|
| 3151 | display_file_name(hObject, eventdata, handles,filename)
|
---|
| 3152 | return
|
---|
| 3153 | % MenuBrowse_Callback(hObject, eventdata, handles)
|
---|
| 3154 | end
|
---|
| 3155 | if isequal(field,'vort') || isequal(field,'div') || isequal(field,'strain')
|
---|
| 3156 | set(handles.civ1,'BackgroundColor',[0.702 0.702 0.702]) % put their color to grey
|
---|
| 3157 | set(handles.civ2,'BackgroundColor',[0.702 0.702 0.702])
|
---|
| 3158 | set(handles.interp1,'BackgroundColor',[0.702 0.702 0.702])
|
---|
| 3159 | set(handles.interp2,'BackgroundColor',[0.702 0.702 0.702])
|
---|
| 3160 | elseif isequal(field,'more...');
|
---|
| 3161 | set(handles.civ1,'BackgroundColor',[0.702 0.702 0.702]) % put their color to grey
|
---|
| 3162 | set(handles.civ2,'BackgroundColor',[0.702 0.702 0.702])
|
---|
| 3163 | str=calc_field;%get the list of available scalars by the function calc_scal
|
---|
| 3164 | [ind_answer] = listdlg('PromptString','Select a file:',...
|
---|
| 3165 | 'SelectionMode','single',...
|
---|
| 3166 | 'ListString',str);
|
---|
| 3167 | % edit the choice in the field and action menu
|
---|
| 3168 | scalar=cell2mat(str(ind_answer));
|
---|
| 3169 | menu=update_menu(handles.Fields,scalar);
|
---|
| 3170 | menu=[{''};menu];
|
---|
| 3171 | set(handles.Fields_1,'String',menu);% store the selected scalar type
|
---|
| 3172 | end
|
---|
| 3173 | end
|
---|
| 3174 | indices=name_generator('',str2double(str1),str2double(str_a),'',NomTypeNew,1,str2double(str2),str2double(str_b),'');
|
---|
| 3175 | set(handles.FileIndex,'String',indices)
|
---|
| 3176 | set(handles.FileIndex,'UserData',NomTypeNew)
|
---|
| 3177 | %common to Fields_1_Callback
|
---|
| 3178 | if isequal(field,'image')||isequal(field_1,'image')
|
---|
| 3179 | set(handles.npx_title,'Visible','on')% visible npx,pxcm... buttons
|
---|
| 3180 | set(handles.npy_title,'Visible','on')
|
---|
| 3181 | set(handles.npx,'Visible','on')
|
---|
| 3182 | set(handles.npy,'Visible','on')
|
---|
| 3183 | else
|
---|
| 3184 | set(handles.npx_title,'Visible','off')% visible npx,pxcm... buttons
|
---|
| 3185 | set(handles.npy_title,'Visible','off')
|
---|
| 3186 | set(handles.npx,'Visible','off')
|
---|
| 3187 | set(handles.npy,'Visible','off')
|
---|
| 3188 | end
|
---|
| 3189 | setfield(handles);% update the field structure ('civ1'....)
|
---|
| 3190 |
|
---|
| 3191 | if ~(isfield(UvData,'NewSeries')&&isequal(UvData.NewSeries,1))
|
---|
| 3192 | run0_Callback(hObject, eventdata, handles)
|
---|
| 3193 | end
|
---|
| 3194 |
|
---|
| 3195 | %---------------------------------------------------
|
---|
| 3196 | % --- Executes on menu selection Fields
|
---|
| 3197 | function Fields_1_Callback(hObject, eventdata, handles)
|
---|
| 3198 | %-------------------------------------------------
|
---|
| 3199 | list_fields=get(handles.Fields,'String');% list menu fields
|
---|
| 3200 | index_fields=get(handles.Fields,'Value');% selected string index
|
---|
| 3201 | field= list_fields{index_fields(1)}; % selected string
|
---|
| 3202 | list_fields=get(handles.Fields_1,'String');% list menu fields
|
---|
| 3203 | index_fields=get(handles.Fields_1,'Value');% selected string index
|
---|
| 3204 | field_1= list_fields{index_fields(1)}; % selected string for the second field
|
---|
| 3205 | if isequal(field_1,'') %remove second field if 'blank' field is selected
|
---|
| 3206 | set(handles.SubField,'Value',0)
|
---|
| 3207 | SubField_Callback(hObject, eventdata, handles)
|
---|
| 3208 | return
|
---|
| 3209 | end
|
---|
| 3210 | UvData=get(handles.uvmat,'UserData');
|
---|
| 3211 |
|
---|
| 3212 | %read the rootfile input display
|
---|
| 3213 | [FileName,RootPath,FileBase,FileIndices,FileExt_prev]=read_file_boxes_1(handles);
|
---|
| 3214 | [P,F,str1,str2,str_a,str_b,E,NomType]=name2display(['xxx' get(handles.FileIndex,'String') FileExt_prev]);
|
---|
[210] | 3215 | if isempty(FileExt_prev)|| strcmp(FileExt_prev,'')
|
---|
[199] | 3216 | FileExt_1=get(handles.FileExt,'String');
|
---|
| 3217 | else
|
---|
| 3218 | FileExt_1=FileExt_prev;
|
---|
| 3219 | end
|
---|
| 3220 | NomType_1=get(handles.FileIndex_1,'UserData');
|
---|
[210] | 3221 | if isempty(NomType_1)|| strcmp(NomType_1,'')
|
---|
[199] | 3222 | NomType_1=get(handles.FileIndex,'UserData');
|
---|
| 3223 | end
|
---|
| 3224 | NomTypeNew=NomType_1;%default
|
---|
| 3225 |
|
---|
| 3226 | set(handles.SubField,'Value',1)%introduce second field
|
---|
| 3227 | if isfield(UvData,'XmlData')
|
---|
| 3228 | UvData.XmlData_1=UvData.XmlData;
|
---|
| 3229 | end
|
---|
| 3230 | set(handles.FileIndex_1,'Visible','on')
|
---|
| 3231 | set(handles.FileExt_1,'Visible','on')
|
---|
| 3232 | RootPath_1=get(handles.RootPath_1,'String');
|
---|
| 3233 | RootFile_1=get(handles.RootFile_1,'String');
|
---|
| 3234 | if isempty(RootPath_1)||isequal(RootPath_1,'')
|
---|
| 3235 | set(handles.RootPath_1,'String','"')
|
---|
| 3236 | end
|
---|
| 3237 | if isempty(RootFile_1) || isequal(RootFile_1,'')
|
---|
| 3238 | set(handles.RootFile_1,'String','"')
|
---|
| 3239 | end
|
---|
| 3240 | if ~isempty(RootFile_1)&&(isequal(RootFile_1(1),'/')||isequal(RootFile_1(1),'\'))
|
---|
| 3241 | RootFile_1(1)=[];
|
---|
| 3242 | end
|
---|
| 3243 |
|
---|
| 3244 | if isequal(field_1,'get_field...')
|
---|
| 3245 | veltype_handles=[handles.civ1 handles.interp1 handles.filter1 handles.civ2 handles.interp2 handles.filter2];
|
---|
| 3246 | set_veltype_display(veltype_handles,0) % unvisible civ buttons
|
---|
| 3247 | filename=read_file_boxes_1(handles);
|
---|
| 3248 | hget_field=findobj(allchild(0),'name','get_field_1');
|
---|
| 3249 | if ~isempty(hget_field)
|
---|
| 3250 | delete(hget_field)
|
---|
| 3251 | end
|
---|
| 3252 | hget_field=get_field(filename);
|
---|
| 3253 | set(hget_field,'name','get_field_1')
|
---|
| 3254 | hhget_field=guidata(hget_field);
|
---|
| 3255 | set(hhget_field.list_fig,'Value',1)
|
---|
| 3256 | set(hhget_field.list_fig,'String',{'uvmat'})
|
---|
| 3257 | set(handles.transform_fct,'Value',1)% no transform by default
|
---|
| 3258 | set(handles.path_transform,'String','')
|
---|
| 3259 | return %no action
|
---|
| 3260 | end
|
---|
| 3261 | if isequal(field_1,'image')
|
---|
| 3262 | % transform netc type to the corresponding image type
|
---|
| 3263 | % set(handles.FileExt_1,'String','.png');
|
---|
[227] | 3264 | if isequal(NomType_1,'_i1-i2_j')||isequal(NomType_1,'_i_j1-j2')|| isequal(NomType_1,'#_ab')|| isequal(NomType_1,'_i1-i2')
|
---|
[199] | 3265 | UvData.SubDir_1=get(handles.SubDir_1,'String'); %preserve the subdir in memory
|
---|
| 3266 | % set(handles.SubDir_1,'String','')
|
---|
| 3267 | % set(handles.FileExt_1,'String','.png');
|
---|
[227] | 3268 | if isequal(NomType_1,'_i1-i2_j')||isequal(NomType_1,'_i_j1-j2')
|
---|
[199] | 3269 | NomTypeNew='_i_j';
|
---|
| 3270 | elseif isequal(NomType_1,'#_ab')
|
---|
| 3271 | NomTypeNew='#a';
|
---|
| 3272 | elseif isequal(NomType_1,'_i1-i2')
|
---|
| 3273 | NomTypeNew='_i';
|
---|
| 3274 | end
|
---|
| 3275 | end
|
---|
| 3276 | imagename=name_generator(FileBase,str2double(str1),str2double(str_a),'.png',NomTypeNew,1,str2double(str2),str2double(str_b),'');
|
---|
| 3277 | if ~exist(imagename,'file')
|
---|
| 3278 | [FileName,PathName] = uigetfile( ...
|
---|
| 3279 | {'*.png;*.jpg;*.tif;*.avi;*.AVI;*.vol', ' (*.png, .tif, *.avi,*.vol)';
|
---|
| 3280 | '*.jpg',' jpeg image files'; ...
|
---|
| 3281 | '*.png','.png image files'; ...
|
---|
| 3282 | '*.tif','.tif image files'; ...
|
---|
| 3283 | '*.avi;*.AVI','.avi movie files'; ...
|
---|
| 3284 | '*.vol','.volume images (png)'; ...
|
---|
| 3285 | '*.*', 'All Files (*.*)'}, ...
|
---|
| 3286 | 'Pick an image',imagename);
|
---|
| 3287 | % display the selected field and related information
|
---|
| 3288 | imagename=[PathName FileName];
|
---|
| 3289 | end
|
---|
| 3290 | display_file_name_1(hObject, eventdata, handles,imagename)%display the image
|
---|
| 3291 | return
|
---|
| 3292 | % veltype_handles=[handles.civ1_1 handles.interp1_1 handles.filter1_1 handles.civ2_1 handles.interp2_1 handles.filter2_1];
|
---|
| 3293 | % set_veltype_display(veltype_handles,0) % unvisible civ buttons
|
---|
| 3294 | else
|
---|
| 3295 | set(handles.SubDir_1,'Visible','on')
|
---|
| 3296 | if ~isequal(FileExt_prev,'.nc') %find the new NomType if the previous display was not already a netcdf file
|
---|
| 3297 | veltype_handles=[handles.civ1_1 handles.interp1_1 handles.filter1_1 handles.civ2_1 handles.interp2_1 handles.filter2_1];
|
---|
| 3298 | set_veltype_display(veltype_handles,6); % make all civ buttons visible
|
---|
| 3299 | RootPath_1=get(handles.RootPath_1,'String');
|
---|
| 3300 | RootFile_1=get(handles.RootFile_1,'String');
|
---|
| 3301 | if isempty(RootPath_1)|isequal(RootPath_1,'')
|
---|
| 3302 | set(handles.RootPath_1,'String','"')
|
---|
| 3303 | end
|
---|
| 3304 | if isempty(RootFile_1) | isequal(RootFile_1,'')
|
---|
| 3305 | set(handles.RootFile_1,'String','"')
|
---|
| 3306 | end
|
---|
| 3307 | if ~isempty(RootFile_1)&(isequal(RootFile_1(1),'/')|isequal(RootFile_1(1),'\'))
|
---|
| 3308 | RootFile_1(1)=[];
|
---|
| 3309 | end
|
---|
| 3310 | filebase_1=fullfile(RootPath_1,RootFile_1);
|
---|
| 3311 | SubDir_1=get(handles.SubDir,'String');
|
---|
| 3312 | if isempty(SubDir_1)||isequal(SubDir_1,'')
|
---|
| 3313 | if isfield(UvData,'SubDir_1')
|
---|
| 3314 | SubDir_1=UvData.SubDir_1;%retrieve previous subdir
|
---|
| 3315 | else
|
---|
| 3316 | SubDir_1='?';
|
---|
| 3317 | end
|
---|
| 3318 | end
|
---|
| 3319 | str1=get(handles.i1,'String');
|
---|
| 3320 | str_a=get(handles.j1,'String');
|
---|
| 3321 | if isequal(NomType_1,'#_ab')||isequal(NomType_1,'_i1-i2_j')||isequal(NomType_1,'_i_j1-j2')||isequal(NomType_1,'_i1-i2')
|
---|
| 3322 | NomTypeNew=NomType_1;
|
---|
| 3323 | elseif isequal(NomType_1,'#a')
|
---|
| 3324 | [filename, n1,na,n2,nb,SubDir_1]=name_generator(filebase_1, str2num(str1),stra2num(str_a),'.nc','#_ab',0,[],[],SubDir_1);
|
---|
| 3325 | NomTypeNew='#_ab';
|
---|
| 3326 | elseif isequal(NomType_1,'_i_j')
|
---|
| 3327 | [filename,n1,na,n2,nb,SubDir_1]=name_generator(filebase_1,str2num(str1),stra2num(str_a),'.nc','_i1-i2_j',0,str2num(str1),[],SubDir_1);
|
---|
| 3328 | if idetect==1
|
---|
| 3329 | NomTypeNew='_i1-i2_j';
|
---|
| 3330 | else
|
---|
| 3331 | NomTypeNew='_i_j1-j2';
|
---|
| 3332 | end
|
---|
| 3333 | else %for instance avi files or any ima_num series
|
---|
| 3334 | [filename,n1,na,n2,nb,SubDir_1]=name_generator(filebase_1,str2num(str1),stra2num(str_a),'.nc','_i1-i2',0,str2num(str1),[],SubDir_1);
|
---|
| 3335 | NomTypeNew='_i1-i2';
|
---|
| 3336 | end
|
---|
| 3337 | [Path,Name]=fileparts(filebase_1);
|
---|
| 3338 | set(handles.FileExt_1,'String','.nc');
|
---|
| 3339 | if ~isempty(SubDir_1) && ~strcmp(SubDir_1,'''')&& ~strcmp(SubDir_1,'"')&& ~strcmp(SubDir_1(1),'/')
|
---|
| 3340 | SubDir_1=['/' SubDir_1];
|
---|
| 3341 | end
|
---|
| 3342 | set(handles.SubDir_1,'String',SubDir_1);
|
---|
| 3343 | end
|
---|
| 3344 | if isequal(field,'vort') | isequal(field,'div') | isequal(field,'strain')
|
---|
| 3345 | set(handles.civ1_1,'BackgroundColor',[0.702 0.702 0.702]) % put their color to grey
|
---|
| 3346 | set(handles.civ2_1,'BackgroundColor',[0.702 0.702 0.702])
|
---|
| 3347 | set(handles.interp1_1,'BackgroundColor',[0.702 0.702 0.702])
|
---|
| 3348 | set(handles.interp2_1,'BackgroundColor',[0.702 0.702 0.702])
|
---|
| 3349 | elseif isequal(field_1,'more...'); %add new item to the menu
|
---|
| 3350 | set(handles.civ1_1,'BackgroundColor',[0.702 0.702 0.702]) % put their color to grey
|
---|
| 3351 | set(handles.civ2_1,'BackgroundColor',[0.702 0.702 0.702])
|
---|
| 3352 | str=calc_field;%get the list of available scalars by the function calc_scal
|
---|
| 3353 | [ind_answer,v] = listdlg('PromptString','Select a file:',...
|
---|
| 3354 | 'SelectionMode','single',...
|
---|
| 3355 | 'ListString',str);
|
---|
| 3356 | % edit the choice in the field and action menu
|
---|
| 3357 | scalar=cell2mat(str(ind_answer));
|
---|
| 3358 | menu=update_menu(handles.Fields_1,scalar);
|
---|
| 3359 | set(handles.Fields_1,'String',menu);% store the selected scalar type
|
---|
| 3360 | end
|
---|
| 3361 | end
|
---|
| 3362 | str1=get(handles.i1,'String');
|
---|
| 3363 | str2=get(handles.i2,'String');
|
---|
| 3364 | str_a=get(handles.j1,'String');
|
---|
| 3365 | str_b=get(handles.j2,'String');
|
---|
| 3366 | indices=name_generator('',str2num(str1),stra2num(str_a),'',NomTypeNew,1,str2num(str2),stra2num(str_b),'');
|
---|
| 3367 | set(handles.FileIndex_1,'String',indices)
|
---|
| 3368 | set(handles.FileIndex_1,'UserData',NomTypeNew)
|
---|
| 3369 |
|
---|
| 3370 | %common to Fields_Callback
|
---|
| 3371 | if isequal(field,'image')|isequal(field_1,'image')
|
---|
| 3372 | set(handles.npx_title,'Visible','on')% visible npx,pxcm... buttons
|
---|
| 3373 | set(handles.npy_title,'Visible','on')
|
---|
| 3374 | set(handles.npx,'Visible','on')
|
---|
| 3375 | set(handles.npy,'Visible','on')
|
---|
| 3376 | % set(handles.fix_pair,'Value',0)
|
---|
| 3377 | else
|
---|
| 3378 | set(handles.npx_title,'Visible','off')% visible npx,pxcm... buttons
|
---|
| 3379 | set(handles.npy_title,'Visible','off')
|
---|
| 3380 | set(handles.npx,'Visible','off')
|
---|
| 3381 | set(handles.npy,'Visible','off')
|
---|
| 3382 | % set(handles.fix_pair,'Value',1)
|
---|
| 3383 | end
|
---|
| 3384 | if isequal(field,'velocity')|isequal(field_1,'velocity');
|
---|
| 3385 | state_vect='on';
|
---|
| 3386 | else
|
---|
| 3387 | state_vect='off';
|
---|
| 3388 | end
|
---|
| 3389 | if ~isequal(field,'velocity')|(~isequal(field_1,'velocity')&~isequal(field_1,''));
|
---|
| 3390 | state_scal='on';
|
---|
| 3391 | else
|
---|
| 3392 | state_scal='off';
|
---|
| 3393 | end
|
---|
| 3394 | set(handles.uvmat,'UserData',UvData)
|
---|
| 3395 | setfield(handles);% update the field structure ('civ1'....)
|
---|
| 3396 | if ~(isfield(UvData,'NewSeries')&&isequal(UvData.NewSeries,1))
|
---|
| 3397 | run0_Callback(hObject, eventdata, handles)
|
---|
| 3398 | end
|
---|
| 3399 |
|
---|
| 3400 | %------------------------------------------------------------------------
|
---|
| 3401 | % --- set the visibility of relevant velocity type menus:
|
---|
| 3402 | function set_veltype_display(handles,Civ)
|
---|
| 3403 | %------------------------------------------------------------------------
|
---|
| 3404 | %Civ=0; all states 'off'
|
---|
| 3405 | %Civ=6; all states 'on'
|
---|
| 3406 | if isequal(Civ,0)
|
---|
| 3407 | imax=0;
|
---|
| 3408 | % set(handles(1),'Visible','on') % unvisible civ buttons
|
---|
| 3409 | % else
|
---|
| 3410 | % set(handles(1),'String','civ1')
|
---|
| 3411 | % end
|
---|
| 3412 | elseif isequal(Civ,1) || isequal(Civ,2)
|
---|
| 3413 | imax=1;
|
---|
| 3414 | elseif isequal(Civ,3)
|
---|
| 3415 | imax=3;
|
---|
| 3416 | elseif isequal(Civ,4) || isequal(Civ,5)
|
---|
| 3417 | imax=4;
|
---|
| 3418 | elseif isequal(Civ,6) %patch2
|
---|
| 3419 | imax=6;
|
---|
| 3420 | end
|
---|
| 3421 | for ibutton=1:imax;
|
---|
| 3422 | set(handles(ibutton),'Visible','on') % unvisible civ buttons
|
---|
| 3423 | end
|
---|
| 3424 | % for ibutton=max(imax+1,2):6;
|
---|
| 3425 | for ibutton=imax+1:6;
|
---|
| 3426 | set(handles(ibutton),'Visible','off') % unvisible civ buttons
|
---|
| 3427 | set(handles(ibutton),'Value',0)%unactivate unvisible buttons
|
---|
| 3428 | end
|
---|
| 3429 |
|
---|
| 3430 | %-------------------------------------------------------------------
|
---|
| 3431 | % --- Executes on button press in civ1.
|
---|
| 3432 | function civ1_Callback(hObject, eventdata, handles)
|
---|
| 3433 | %-------------------------------------------------------------------
|
---|
| 3434 | if get(handles.civ1,'Value')==1
|
---|
| 3435 | reset_vel_type([handles.interp1 handles.civ2 handles.filter1 handles.interp1 handles.interp2 handles.filter2],handles.civ1)
|
---|
| 3436 | else
|
---|
| 3437 | reset_vel_type([handles.civ1 handles.filter1 handles.interp1 handles.civ2 handles.interp2 handles.filter2])
|
---|
| 3438 | end
|
---|
| 3439 | run0_Callback(hObject, eventdata, handles)
|
---|
| 3440 |
|
---|
| 3441 | %-------------------------------------------------------------------
|
---|
| 3442 | % --- Executes on button press in interp1.
|
---|
| 3443 | function interp1_Callback(hObject, eventdata, handles)
|
---|
| 3444 | %-------------------------------------------------------------------
|
---|
| 3445 | if get(handles.interp1,'Value')==1
|
---|
| 3446 | reset_vel_type([handles.civ1 handles.civ2 handles.filter1 handles.interp2 handles.filter2],handles.interp1)
|
---|
| 3447 | else
|
---|
| 3448 | reset_vel_type([handles.civ1 handles.filter1 handles.interp1 handles.civ2 handles.interp2 handles.filter2])
|
---|
| 3449 | end
|
---|
| 3450 | run0_Callback(hObject, eventdata, handles)
|
---|
| 3451 |
|
---|
| 3452 | %-------------------------------------------------------------------
|
---|
| 3453 | % --- Executes on button press in filter1.
|
---|
| 3454 | function filter1_Callback(hObject, eventdata, handles)
|
---|
| 3455 | %-------------------------------------------------------------------
|
---|
| 3456 | if get(handles.filter1,'Value')==1
|
---|
| 3457 | reset_vel_type([handles.civ1 handles.civ2 handles.interp1 handles.interp2 handles.filter2],handles.filter1)
|
---|
| 3458 | else
|
---|
| 3459 | reset_vel_type([handles.civ1 handles.filter1 handles.interp1 handles.civ2 handles.interp2 handles.filter2])
|
---|
| 3460 | end
|
---|
| 3461 | run0_Callback(hObject, eventdata, handles)
|
---|
| 3462 |
|
---|
| 3463 | %-------------------------------------------------------------------
|
---|
| 3464 | % --- Executes on button press in civ2.
|
---|
| 3465 | function civ2_Callback(hObject, eventdata, handles)
|
---|
| 3466 | %-------------------------------------------------------------------
|
---|
| 3467 | if get(handles.civ2,'Value')==1
|
---|
| 3468 | reset_vel_type([handles.civ1 handles.filter1 handles.interp1 handles.interp2 handles.filter2],handles.civ2)
|
---|
| 3469 | else
|
---|
| 3470 | reset_vel_type([handles.civ1 handles.filter1 handles.interp1 handles.civ2 handles.interp2 handles.filter2])
|
---|
| 3471 | end
|
---|
| 3472 | run0_Callback(hObject, eventdata, handles)
|
---|
| 3473 |
|
---|
| 3474 | %-----------------------------------------
|
---|
| 3475 | % --- Executes on button press in interp2.
|
---|
| 3476 | %-------------------------------------------
|
---|
| 3477 | function interp2_Callback(hObject, eventdata, handles)
|
---|
| 3478 | if get(handles.interp2,'Value')==1
|
---|
| 3479 | reset_vel_type([handles.civ1 handles.filter1 handles.interp1 handles.civ2 handles.filter2],handles.interp2)
|
---|
| 3480 | else
|
---|
| 3481 | reset_vel_type([handles.civ1 handles.filter1 handles.interp1 handles.civ2 handles.interp2 handles.filter2])
|
---|
| 3482 | end
|
---|
| 3483 | run0_Callback(hObject, eventdata, handles)
|
---|
| 3484 | %---------------------------------------------
|
---|
| 3485 | % --- Executes on button press in filter2.
|
---|
| 3486 | %-------------------------------------------
|
---|
| 3487 | function filter2_Callback(hObject, eventdata, handles)
|
---|
| 3488 | if get(handles.filter2,'Value')==1
|
---|
| 3489 | reset_vel_type([handles.civ1 handles.filter1 handles.interp1 handles.civ2 handles.interp2],handles.filter2)
|
---|
| 3490 | else
|
---|
| 3491 | reset_vel_type([handles.civ1 handles.filter1 handles.interp1 handles.civ2 handles.interp2 handles.filter2])
|
---|
| 3492 | end
|
---|
| 3493 | run0_Callback(hObject, eventdata, handles)
|
---|
| 3494 |
|
---|
| 3495 | %---------------------------------------------
|
---|
| 3496 | function civ1_1_Callback(hObject, eventdata, handles)
|
---|
| 3497 | %---------------------------------------------
|
---|
| 3498 | if get(handles.civ1_1,'Value')==1
|
---|
| 3499 | reset_vel_type([handles.interp1_1 handles.civ2_1 handles.filter1_1 handles.interp1_1 handles.interp2_1 handles.filter2_1],handles.civ1_1)
|
---|
| 3500 | else
|
---|
| 3501 | reset_vel_type([handles.civ1_1 handles.filter1_1 handles.interp1_1 handles.civ2_1 handles.interp2_1 handles.filter2_1])
|
---|
| 3502 | end
|
---|
| 3503 | run0_Callback(hObject, eventdata, handles)
|
---|
| 3504 |
|
---|
| 3505 | %--------------------------------------------
|
---|
| 3506 | function interp1_1_Callback(hObject, eventdata, handles)
|
---|
| 3507 | %--------------------------------------------
|
---|
| 3508 | if get(handles.interp1_1,'Value')==1
|
---|
| 3509 | reset_vel_type([handles.civ1_1 handles.civ2_1 handles.filter1_1 handles.interp2_1 handles.filter2_1],handles.interp1_1)
|
---|
| 3510 | else
|
---|
| 3511 | reset_vel_type([handles.civ1_1 handles.filter1_1 handles.interp1_1 handles.civ2_1 handles.interp2_1 handles.filter2_1])
|
---|
| 3512 | end
|
---|
| 3513 | run0_Callback(hObject, eventdata, handles)
|
---|
| 3514 |
|
---|
| 3515 | %--------------------------------------------
|
---|
| 3516 | function filter1_1_Callback(hObject, eventdata, handles)
|
---|
| 3517 | %--------------------------------------------
|
---|
| 3518 | if get(handles.filter1_1,'Value')==1
|
---|
| 3519 | reset_vel_type([handles.interp1_1 handles.civ2_1 handles.interp1_1 handles.interp2_1 handles.filter2_1],handles.filter1_1)
|
---|
| 3520 | else
|
---|
| 3521 | reset_vel_type([handles.civ1_1 handles.filter1_1 handles.interp1_1 handles.civ2_1 handles.interp2_1 handles.filter2_1])
|
---|
| 3522 | end
|
---|
| 3523 | run0_Callback(hObject, eventdata, handles)
|
---|
| 3524 |
|
---|
| 3525 | %--------------------------------------------
|
---|
| 3526 | function civ2_1_Callback(hObject, eventdata, handles)
|
---|
| 3527 | %--------------------------------------------
|
---|
| 3528 | if get(handles.civ2_1,'Value')==1
|
---|
| 3529 | reset_vel_type([handles.civ1_1 handles.interp1_1 handles.filter1_1 handles.interp2_1 handles.filter2_1],handles.civ2_1)
|
---|
| 3530 | else
|
---|
| 3531 | reset_vel_type([handles.civ1_1 handles.filter1_1 handles.interp1_1 handles.civ2_1 handles.interp2_1 handles.filter2_1])
|
---|
| 3532 | end
|
---|
| 3533 | run0_Callback(hObject, eventdata, handles)
|
---|
| 3534 |
|
---|
| 3535 | %--------------------------------------------
|
---|
| 3536 | function interp2_1_Callback(hObject, eventdata, handles)
|
---|
| 3537 | %--------------------------------------------
|
---|
| 3538 | if get(handles.interp2_1,'Value')==1
|
---|
| 3539 | reset_vel_type([handles.civ1_1 handles.civ2_1 handles.filter1_1 handles.interp1_1 handles.filter2_1],handles.interp2_1)
|
---|
| 3540 | else
|
---|
| 3541 | reset_vel_type([handles.civ1_1 handles.filter1_1 handles.interp1_1 handles.civ2_1 handles.interp2_1 handles.filter2_1])
|
---|
| 3542 | end
|
---|
| 3543 | run0_Callback(hObject, eventdata, handles)
|
---|
| 3544 |
|
---|
| 3545 | %--------------------------------------------
|
---|
| 3546 | function filter2_1_Callback(hObject, eventdata, handles)
|
---|
| 3547 | %--------------------------------------------
|
---|
| 3548 | if get(handles.filter2_1,'Value')==1
|
---|
| 3549 | reset_vel_type([handles.civ1_1 handles.interp1_1 handles.civ2_1 handles.filter1_1 handles.interp1_1 handles.interp2_1],handles.filter2_1)
|
---|
| 3550 | else
|
---|
| 3551 | reset_vel_type([handles.civ1_1 handles.filter1_1 handles.interp1_1 handles.civ2_1 handles.interp2_1 handles.filter2_1])
|
---|
| 3552 | end
|
---|
| 3553 | run0_Callback(hObject, eventdata, handles)
|
---|
| 3554 |
|
---|
| 3555 | %-----------------------------------------------
|
---|
| 3556 | % --- reset civ buttons
|
---|
| 3557 | function reset_vel_type(handles_civ0,handle1)
|
---|
| 3558 | for ibutton=1:length(handles_civ0)
|
---|
| 3559 | set(handles_civ0(ibutton),'BackgroundColor',[0.831 0.816 0.784])
|
---|
| 3560 | set(handles_civ0(ibutton),'Value',0)
|
---|
| 3561 | end
|
---|
| 3562 | if exist('handle1','var')%handles of selected button
|
---|
| 3563 | set(handle1,'BackgroundColor',[1 1 0])
|
---|
| 3564 | end
|
---|
| 3565 |
|
---|
| 3566 | %-------------------------------------------------------
|
---|
| 3567 | % --- Executes on button press in MENUVOLUME.
|
---|
| 3568 | %-------------------------------------------------------
|
---|
| 3569 | function VOLUME_Callback(hObject, eventdata, handles)
|
---|
| 3570 | %errordlg('command VOL not implemented yet')
|
---|
| 3571 | if ishandle(handles.UVMAT_title)
|
---|
| 3572 | delete(handles.UVMAT_title)
|
---|
| 3573 | end
|
---|
| 3574 | UvData=get(handles.uvmat,'UserData');%read UvData properties stored on the uvmat interface
|
---|
| 3575 | if isequal(get(handles.VOLUME,'Value'),1)
|
---|
| 3576 | set(handles.zoom,'Value',0)
|
---|
| 3577 | set(handles.zoom,'BackgroundColor',[0.7 0.7 0.7])
|
---|
| 3578 | set(handles.edit_vect,'Value',0)
|
---|
| 3579 | edit_vect_Callback(hObject, eventdata, handles)
|
---|
| 3580 | set(handles.edit_object,'Value',0)
|
---|
| 3581 | set(handles.edit_object,'BackgroundColor',[0.7 0.7 0.7])
|
---|
| 3582 | % set(handles.cal,'Value',0)
|
---|
| 3583 | % set(handles.cal,'BackgroundColor',[0 1 0])
|
---|
| 3584 | set(handles.edit_vect,'Value',0)
|
---|
| 3585 | edit_vect_Callback(hObject, eventdata, handles)
|
---|
| 3586 | %initiate set_object GUI
|
---|
| 3587 | data.TITLE='VOLUME';
|
---|
| 3588 | if isfield(UvData,'CoordType')
|
---|
| 3589 | data.CoordType=UvData.CoordType;
|
---|
| 3590 | end
|
---|
| 3591 | if isfield(UvData,'Mesh')&~isempty(UvData.Mesh)
|
---|
| 3592 | data.RangeY=UvData.Mesh;
|
---|
| 3593 | data.RangeX=UvData.Mesh;
|
---|
| 3594 | data.DX=UvData.Mesh;
|
---|
| 3595 | data.DY=UvData.Mesh;
|
---|
| 3596 | elseif isfield(UvData.Field,'AX')&isfield(UvData.Field,'AY')& isfield(UvData.Field,'A')%only image
|
---|
| 3597 | np=size(UvData.Field.A);
|
---|
| 3598 | meshx=(UvData.Field.AX(end)-UvData.Field.AX(1))/np(2);
|
---|
| 3599 | meshy=abs(UvData.Field.AY(end)-UvData.Field.AY(1))/np(1);
|
---|
| 3600 | data.RangeY=max(meshx,meshy);
|
---|
| 3601 | data.RangeX=max(meshx,meshy);
|
---|
| 3602 | data.DX=max(meshx,meshy);
|
---|
| 3603 | end
|
---|
| 3604 | data.ParentButton=handles.VOLUME;
|
---|
| 3605 | PlotHandles=get_plot_handles(handles);%get the handles of the interface elements setting the plotting parameters
|
---|
| 3606 | [hset_object,UvData.sethandles]=set_object(data,PlotHandles);% call the set_object interface with action on haxes,
|
---|
| 3607 | % associate the set_object interface handle to the plotting axes
|
---|
| 3608 | if isfield(UvData.OpenParam,'SetObjectOrigin')
|
---|
| 3609 | pos_uvmat=get(huvmat,'Position');
|
---|
| 3610 | pos_set_object(1:2)=UvData.OpenParam.SetObjectOrigin + pos_uvmat(1:2);
|
---|
| 3611 | pos_set_object(3:4)=UvData.OpenParam.SetObjectSize .* pos_uvmat(3:4);
|
---|
| 3612 | set(hset_object,'Position',pos_set_object)
|
---|
| 3613 | end
|
---|
| 3614 | UvData.MouseAction='create_object';
|
---|
| 3615 | else
|
---|
| 3616 | set(handles.VOLUME,'BackgroundColor',[0 1 0])
|
---|
| 3617 | UvData.MouseAction='none';
|
---|
| 3618 | end
|
---|
| 3619 | set(huvmat,'UserData',UvData)
|
---|
| 3620 |
|
---|
| 3621 | %-------------------------------------------------------
|
---|
| 3622 | function edit_vect_Callback(hObject, eventdata, handles)
|
---|
| 3623 | %-------------------------------------------------------
|
---|
| 3624 | %
|
---|
| 3625 | % UvData=get(handles.uvmat,'UserData');%read UvData properties stored on the uvmat interface
|
---|
| 3626 | if isequal(get(handles.edit_vect,'Value'),1)
|
---|
| 3627 | test_civ2=isequal(get(handles.civ2,'BackgroundColor'),[1 1 0]);
|
---|
| 3628 | test_civ1=isequal(get(handles.civ1,'BackgroundColor'),[1 1 0]);
|
---|
| 3629 | if ~test_civ2 && ~test_civ1
|
---|
| 3630 | msgbox_uvmat('ERROR','manual correction only possible for CIV1 or CIV2 velocity fields')
|
---|
| 3631 | end
|
---|
| 3632 | set(handles.record,'Visible','on')
|
---|
| 3633 | set(handles.edit_vect,'BackgroundColor',[1 1 0])
|
---|
| 3634 | set(handles.edit_object,'Value',0)
|
---|
| 3635 | set(handles.zoom,'Value',0)
|
---|
| 3636 | set(handles.zoom,'BackgroundColor',[0.7 0.7 0.7])
|
---|
| 3637 | % set(handles.create,'Value',0)
|
---|
| 3638 | % set(handles.create,'BackgroundColor',[0 1 0])
|
---|
| 3639 | set(handles.edit_object,'BackgroundColor',[0.7 0.7 0.7])
|
---|
| 3640 | set(gcf,'Pointer','arrow')
|
---|
| 3641 | % UvData.MouseAction='edit_vect';
|
---|
| 3642 | else
|
---|
| 3643 | set(handles.record,'Visible','off')
|
---|
| 3644 | set(handles.edit_vect,'BackgroundColor',[0.7 0.7 0.7])
|
---|
| 3645 | % UvData.MouseAction='none';
|
---|
| 3646 | end
|
---|
| 3647 | % set(handles.uvmat,'UserData',UvData)
|
---|
| 3648 |
|
---|
| 3649 | %----------------------------------------------
|
---|
| 3650 | function save_mask_Callback(hObject, eventdata, handles)
|
---|
| 3651 | %-----------------------------------------------------------------------
|
---|
| 3652 | UvData=get(handles.uvmat,'UserData');
|
---|
| 3653 |
|
---|
| 3654 | flag=1;
|
---|
| 3655 | npx=size(UvData.Field.A,2);
|
---|
| 3656 | npy=size(UvData.Field.A,1);
|
---|
| 3657 | xi=0.5:npx-0.5;
|
---|
| 3658 | yi=0.5:npy-0.5;
|
---|
| 3659 | [Xi,Yi]=meshgrid(xi,yi);
|
---|
| 3660 | if isfield(UvData,'Object')
|
---|
| 3661 | for iobj=1:length(UvData.Object)
|
---|
| 3662 | ObjectData=UvData.Object{iobj};
|
---|
| 3663 | if isfield(ObjectData,'ProjMode') &&(isequal(ObjectData.ProjMode,'mask_inside')||isequal(ObjectData.ProjMode,'mask_outside'));
|
---|
| 3664 | flagobj=1;
|
---|
| 3665 | testphys=0; %coordinates in pixels by default
|
---|
| 3666 | if isfield(ObjectData,'CoordType') && isequal(ObjectData.CoordType,'phys')
|
---|
| 3667 | if isfield(UvData,'XmlData')&& isfield(UvData.XmlData,'GeometryCalib')
|
---|
| 3668 | Calib=UvData.XmlData.GeometryCalib;
|
---|
| 3669 | testphys=1;
|
---|
| 3670 | end
|
---|
| 3671 | end
|
---|
| 3672 | if isfield(ObjectData,'Coord')& isfield(ObjectData,'Style')
|
---|
| 3673 | if isequal(ObjectData.Style,'polygon')
|
---|
| 3674 | X=ObjectData.Coord(:,1);
|
---|
| 3675 | Y=ObjectData.Coord(:,2);
|
---|
| 3676 | if testphys
|
---|
| 3677 | [X,Y]=px_XYZ(Calib,X,Y,0);% to generalise with 3D cases
|
---|
| 3678 | end
|
---|
| 3679 | flagobj=~inpolygon(Xi,Yi,X',Y');%=0 inside the polygon, 1 outside
|
---|
| 3680 | elseif isequal(ObjectData.Style,'ellipse')
|
---|
| 3681 | if testphys
|
---|
| 3682 | %[X,Y]=px_XYZ(Calib,X,Y,0);% TODO:create a polygon boundary and transform to phys
|
---|
| 3683 | end
|
---|
| 3684 | RangeX=max(ObjectData.RangeX);
|
---|
| 3685 | RangeY=max(ObjectData.RangeY);
|
---|
| 3686 | X2Max=RangeX*RangeX;
|
---|
| 3687 | Y2Max=RangeY*RangeY;
|
---|
| 3688 | distX=(Xi-ObjectData.Coord(1,1));
|
---|
| 3689 | distY=(Yi-ObjectData.Coord(1,2));
|
---|
| 3690 | flagobj=(distX.*distX/X2Max+distY.*distY/Y2Max)>1;
|
---|
| 3691 | elseif isequal(ObjectData.Style,'rectangle')
|
---|
| 3692 | if testphys
|
---|
| 3693 | %[X,Y]=px_XYZ(Calib,X,Y,0);% TODO:create a polygon boundary and transform to phys
|
---|
| 3694 | end
|
---|
| 3695 | distX=abs(Xi-ObjectData.Coord(1,1));
|
---|
| 3696 | distY=abs(Yi-ObjectData.Coord(1,2));
|
---|
| 3697 | flagobj=distX>max(ObjectData.RangeX) | distY>max(ObjectData.RangeY);
|
---|
| 3698 | end
|
---|
| 3699 | if isequal(ObjectData.ProjMode,'mask_outside')
|
---|
| 3700 | flagobj=~flagobj;
|
---|
| 3701 | end
|
---|
| 3702 | flag=flag & flagobj;
|
---|
| 3703 | end
|
---|
| 3704 | end
|
---|
| 3705 | end
|
---|
| 3706 | end
|
---|
| 3707 | % flag=~flag;
|
---|
| 3708 | %mask name
|
---|
| 3709 | RootPath=get(handles.RootPath,'String');
|
---|
| 3710 | RootFile=get(handles.RootFile,'String');
|
---|
| 3711 | if ~isempty(RootFile)&&(isequal(RootFile(1),'/')|| isequal(RootFile(1),'\'))
|
---|
| 3712 | RootFile(1)=[];
|
---|
| 3713 | end
|
---|
| 3714 | filebase=fullfile(RootPath,RootFile);
|
---|
| 3715 | list=get(handles.masklevel,'String');
|
---|
| 3716 | masknumber=num2str(length(list));
|
---|
| 3717 | maskindex=get(handles.masklevel,'Value');
|
---|
| 3718 | mask_name=name_generator([filebase '_' masknumber 'mask'],maskindex,1,'.png','_i');
|
---|
| 3719 | imflag=uint8(255*(0.392+0.608*flag));% =100 for flag=0 (vectors not computed when 20<imflag<200)
|
---|
| 3720 | imflag=flipdim(imflag,1);
|
---|
| 3721 | % imflag=uint8(255*flag);% =0 for flag=0 (vectors=0 when 20<imflag<200)
|
---|
| 3722 | msgbox_uvmat('CONFIRMATION',[mask_name ' saved'])
|
---|
| 3723 | imwrite(imflag,mask_name,'BitDepth',8);
|
---|
| 3724 |
|
---|
| 3725 | %display the mask
|
---|
| 3726 | %update_mask(handles,num_i1,num_j1)
|
---|
| 3727 | figure;
|
---|
| 3728 | vec=linspace(0,1,256);%define a linear greyscale colormap
|
---|
| 3729 | map=[vec' vec' vec'];
|
---|
| 3730 | colormap(map)
|
---|
| 3731 |
|
---|
| 3732 | image(imflag);
|
---|
| 3733 |
|
---|
| 3734 | %-------------------------------------------------------------------
|
---|
| 3735 | %-------------------------------------------------------------------
|
---|
| 3736 | % - FUNCTIONS FOR SETTING PLOTTING PARAMETERS
|
---|
| 3737 |
|
---|
| 3738 | %------------------------------------------------------------------
|
---|
| 3739 |
|
---|
| 3740 |
|
---|
| 3741 |
|
---|
| 3742 | %------------------------------------------------------------------
|
---|
| 3743 | % --- Executes on selection change in col_vec: choice of the color code.
|
---|
| 3744 | %
|
---|
| 3745 | function col_vec_Callback(hObject, eventdata, handles)
|
---|
| 3746 | %------------------------------------------------------------------
|
---|
| 3747 | % edit the choice for color code
|
---|
| 3748 | list_code=get(handles.col_vec,'String');% list menu fields
|
---|
| 3749 | index_code=get(handles.col_vec,'Value');% selected string index
|
---|
| 3750 | col_code= list_code{index_code(1)}; % selected field
|
---|
| 3751 | if isequal(col_code,'black') || isequal(col_code,'white')
|
---|
| 3752 | set(handles.slider1,'Visible','off')
|
---|
| 3753 | set(handles.slider2,'Visible','off')
|
---|
| 3754 | set(handles.colcode1,'Visible','off')
|
---|
| 3755 | set(handles.colcode2,'Visible','off')
|
---|
| 3756 | set(handles.AutoVecColor,'Visible','off')
|
---|
| 3757 | set_vec_col_bar(handles)
|
---|
| 3758 | else
|
---|
| 3759 | set(handles.slider1,'Visible','on')
|
---|
| 3760 | set(handles.slider2,'Visible','on')
|
---|
| 3761 | set(handles.colcode1,'Visible','on')
|
---|
| 3762 | set(handles.colcode2,'Visible','on')
|
---|
| 3763 | set(handles.AutoVecColor,'Visible','on')
|
---|
| 3764 | if isequal(col_code,'ima_cor')
|
---|
| 3765 | set(handles.AutoVecColor,'Value',0)%fixed scale by default
|
---|
| 3766 | set(handles.vec_col_bar,'Value',0)% 3 colors r,g,b by default
|
---|
| 3767 | set(handles.slider1,'Min',0);
|
---|
| 3768 | set(handles.slider1,'Max',1);
|
---|
| 3769 | set(handles.slider2,'Min',0);
|
---|
| 3770 | set(handles.slider2,'Max',1);
|
---|
| 3771 | % set(handles.min_title_vec,'String','0')
|
---|
| 3772 | set(handles.max_vec,'String','1')
|
---|
| 3773 | set(handles.colcode1,'String','0.333')
|
---|
| 3774 | colcode1_Callback(hObject, eventdata, handles)
|
---|
| 3775 | set(handles.colcode2,'String','0.666')
|
---|
| 3776 | colcode2_Callback(hObject, eventdata, handles)
|
---|
| 3777 | else
|
---|
| 3778 | set(handles.AutoVecColor,'Value',1)%auto scale between min,max by default
|
---|
| 3779 | set(handles.vec_col_bar,'Value',1)% colormap 'jet' by default
|
---|
| 3780 | minval=get(handles.slider1,'Min');
|
---|
| 3781 | maxval=get(handles.slider1,'Max');
|
---|
| 3782 | set(handles.slider1,'Value',minval)
|
---|
| 3783 | set(handles.slider2,'Value',maxval)
|
---|
| 3784 | set_vec_col_bar(handles)
|
---|
| 3785 | end
|
---|
| 3786 | % slider_update(handles)
|
---|
| 3787 | end
|
---|
| 3788 | %replot the current graph
|
---|
| 3789 | run0_Callback(hObject, eventdata, handles)
|
---|
| 3790 |
|
---|
| 3791 |
|
---|
| 3792 | %----------------------------------------------------------------
|
---|
| 3793 | % -- Executes on slider movement to set the color code
|
---|
| 3794 | %
|
---|
| 3795 | function slider1_Callback(hObject, eventdata, handles)
|
---|
| 3796 | %------------------------------------------------------------------
|
---|
| 3797 | slider1=get(handles.slider1,'Value');
|
---|
| 3798 | min_val=str2num(get(handles.min_vec,'String'));
|
---|
| 3799 | max_val=str2num(get(handles.max_vec,'String'));
|
---|
| 3800 | col=min_val+(max_val-min_val)*slider1;
|
---|
| 3801 | set(handles.colcode1,'String',num2str(col))
|
---|
| 3802 | if(get(handles.slider2,'Value') < col)%move also the second slider at the same value if needed
|
---|
| 3803 | set(handles.slider2,'Value',col)
|
---|
| 3804 | set(handles.colcode2,'String',num2str(col))
|
---|
| 3805 | end
|
---|
| 3806 | colcode1_Callback(hObject, eventdata, handles)
|
---|
| 3807 |
|
---|
| 3808 | %----------------------------------------------------------------
|
---|
| 3809 | % Executes on slider movement to set the color code
|
---|
| 3810 | %----------------------------------------------------------------
|
---|
| 3811 | function slider2_Callback(hObject, eventdata, handles)
|
---|
| 3812 | slider2=get(handles.slider2,'Value');
|
---|
| 3813 | min_val=str2num(get(handles.min_vec,'String'));
|
---|
| 3814 | max_val=str2num(get(handles.max_vec,'String'));
|
---|
| 3815 | col=min_val+(max_val-min_val)*slider2;
|
---|
| 3816 | set(handles.colcode2,'String',num2str(col))
|
---|
| 3817 | if(get(handles.slider1,'Value') > col)%move also the first slider at the same value if needed
|
---|
| 3818 | set(handles.slider1,'Value',col)
|
---|
| 3819 | set(handles.colcode1,'String',num2str(col))
|
---|
| 3820 | end
|
---|
| 3821 | colcode2_Callback(hObject, eventdata, handles)
|
---|
| 3822 |
|
---|
| 3823 | %----------------------------------------------------------------
|
---|
| 3824 | %execute on return carriage on the edit box corresponding to slider 1
|
---|
| 3825 | %----------------------------------------------------------------
|
---|
| 3826 | function colcode1_Callback(hObject, eventdata, handles)
|
---|
| 3827 | % col=str2num(get(handles.colcode1,'String'));
|
---|
| 3828 | % set(handles.slider1,'Value',col)
|
---|
| 3829 | set_vec_col_bar(handles)
|
---|
| 3830 | update_plot(handles);
|
---|
| 3831 |
|
---|
| 3832 | %----------------------------------------------------------------
|
---|
| 3833 | %execute on return carriage on the edit box corresponding to slider 2
|
---|
| 3834 | %----------------------------------------------------------------
|
---|
| 3835 | function colcode2_Callback(hObject, eventdata, handles)
|
---|
| 3836 | % col=str2num(get(handles.colcode2,'String'));
|
---|
| 3837 | % set(handles.slider2,'Value',col)
|
---|
| 3838 | % slider2_Callback(hObject, eventdata, handles)
|
---|
| 3839 | set_vec_col_bar(handles)
|
---|
| 3840 | update_plot(handles);
|
---|
| 3841 | %------------------------------------------------------------
|
---|
| 3842 | %update the slider values after displaying vectors
|
---|
| 3843 | %--------------------------------------------------------
|
---|
| 3844 | % function slider_update(handles,auto,minC,colcode1,colcode2,maxC)
|
---|
| 3845 | % set(handles.slider1,'Min',minC)
|
---|
| 3846 | % set(handles.slider1,'Max',maxC)
|
---|
| 3847 | % set(handles.slider2,'Min',minC)
|
---|
| 3848 | % set(handles.slider2,'Max',maxC)
|
---|
| 3849 | % set(handles.min_title_vec,'String',num2str(minC))
|
---|
| 3850 | % set(handles.max_vec,'String',num2str(maxC))
|
---|
| 3851 | % if auto
|
---|
| 3852 | % set(handles.colcode1,'String',num2str(colcode1,3))%update display
|
---|
| 3853 | % set(handles.colcode2,'String',num2str(colcode2,3))
|
---|
| 3854 | % end
|
---|
| 3855 | % set(handles.slider1,'Value',colcode1)%update slider with constant display
|
---|
| 3856 | % set(handles.slider2,'Value',colcode2)
|
---|
| 3857 | % set_vec_col_bar(handles)
|
---|
| 3858 |
|
---|
| 3859 |
|
---|
| 3860 | %-------------------------------------------------------
|
---|
| 3861 | % --- Executes on button press in AutoVecColor.
|
---|
| 3862 | %-------------------------------------------------------
|
---|
| 3863 | function vec_col_bar_Callback(hObject, eventdata, handles)
|
---|
| 3864 | set_vec_col_bar(handles)
|
---|
| 3865 |
|
---|
| 3866 | %-------------------------------------------------------------
|
---|
| 3867 | % --- Executes on selection change in transform_fct.
|
---|
| 3868 | function transform_fct_Callback(hObject, eventdata, handles)
|
---|
| 3869 | %-------------------------------------------------------------
|
---|
| 3870 |
|
---|
| 3871 | UvData=get(handles.uvmat,'UserData');
|
---|
| 3872 | menu=get(handles.transform_fct,'String');
|
---|
| 3873 | ind_coord=get(handles.transform_fct,'Value');
|
---|
| 3874 | coord_option=menu{ind_coord};
|
---|
| 3875 | list_transform=get(handles.transform_fct,'UserData');
|
---|
| 3876 | ff=functions(list_transform{end});
|
---|
| 3877 | if isequal(coord_option,'more...');
|
---|
| 3878 | coord_fct='';
|
---|
| 3879 | prompt = {'Enter the name of the transform function'};
|
---|
| 3880 | dlg_title = 'user defined transform';
|
---|
| 3881 | num_lines= 1;
|
---|
| 3882 | [FileName, PathName] = uigetfile( ...
|
---|
| 3883 | {'*.m', ' (*.m)';
|
---|
| 3884 | '*.m', '.m files '; ...
|
---|
| 3885 | '*.*', 'All Files (*.*)'}, ...
|
---|
| 3886 | 'Pick a file', ff.file);
|
---|
| 3887 | if isequal(PathName(end),'/')||isequal(PathName(end),'\')
|
---|
| 3888 | PathName(end)=[];
|
---|
| 3889 | end
|
---|
| 3890 | transform_selected =fullfile(PathName,FileName);
|
---|
| 3891 | if ~exist(transform_selected,'file')
|
---|
| 3892 | return
|
---|
| 3893 | end
|
---|
| 3894 | [ppp,transform,ext_fct]=fileparts(FileName);% removes extension .m
|
---|
| 3895 | if ~isequal(ext_fct,'.m')
|
---|
| 3896 | msgbox_uvmat('ERROR','a Matlab function .m must be introduced');
|
---|
| 3897 | return
|
---|
| 3898 | end
|
---|
| 3899 | menu=update_menu(handles.transform_fct,transform);%add the selected fct to the menu
|
---|
| 3900 | ind_coord=get(handles.transform_fct,'Value');
|
---|
| 3901 | addpath(PathName)
|
---|
| 3902 | list_transform{ind_coord}=str2func(transform);% create the function handle corresponding to the newly seleced function
|
---|
| 3903 | set(handles.transform_fct,'UserData',list_transform)
|
---|
| 3904 | rmpath(PathName)
|
---|
| 3905 | % save the new menu in the personal file 'uvmat_perso.mat'
|
---|
| 3906 | dir_perso=prefdir;%personal Matalb directory
|
---|
| 3907 | profil_perso=fullfile(dir_perso,'uvmat_perso.mat');
|
---|
| 3908 | if exist(profil_perso,'file')
|
---|
| 3909 | nb_builtin=UvData.OpenParam.NbBuiltin;
|
---|
| 3910 | for ilist=nb_builtin+1:numel(list_transform)
|
---|
| 3911 | ff=functions(list_transform{ilist});
|
---|
| 3912 | transform_fct{ilist-nb_builtin}=ff.file;
|
---|
| 3913 | end
|
---|
| 3914 | save (profil_perso,'transform_fct','-append'); %store the root name for future opening of uvmat
|
---|
| 3915 | end
|
---|
| 3916 | end
|
---|
| 3917 |
|
---|
| 3918 | %check the current path to the selected function
|
---|
| 3919 | if isa(list_transform{ind_coord},'function_handle')
|
---|
| 3920 | func=functions(list_transform{ind_coord});
|
---|
| 3921 | set(handles.path_transform,'String',fileparts(func.file)); %show the path to the senlected function
|
---|
| 3922 | else
|
---|
| 3923 | set(handles.path_transform,'String','')
|
---|
| 3924 | end
|
---|
| 3925 |
|
---|
| 3926 | set(handles.FixLimits,'Value',0)
|
---|
| 3927 | set(handles.FixLimits,'BackgroundColor',[0.7 0.7 0.7])
|
---|
| 3928 |
|
---|
| 3929 | %delete drawn objects
|
---|
| 3930 | hother=findobj('Tag','proj_object');%find all the proj objects
|
---|
| 3931 | for iobj=1:length(hother)
|
---|
| 3932 | delete_object(hother(iobj))
|
---|
| 3933 | end
|
---|
| 3934 | hother=findobj('Tag','DeformPoint');%find all the proj objects
|
---|
| 3935 | for iobj=1:length(hother)
|
---|
| 3936 | delete_object(hother(iobj))
|
---|
| 3937 | end
|
---|
| 3938 | hh=findobj('Tag','calib_points');
|
---|
| 3939 | if ~isempty(hh)
|
---|
| 3940 | delete(hh)
|
---|
| 3941 | end
|
---|
| 3942 | hhh=findobj('Tag','calib_marker');
|
---|
| 3943 | if ~isempty(hhh)
|
---|
| 3944 | delete(hhh)
|
---|
| 3945 | end
|
---|
| 3946 | if isfield(UvData,'Object')
|
---|
| 3947 | UvData.Object=UvData.Object(1);
|
---|
| 3948 | end
|
---|
| 3949 | list_object=get(handles.list_object_1,'String');
|
---|
| 3950 | set(handles.list_object_1,'Value',1)
|
---|
| 3951 | set(handles.list_object_1,'String',list_object(1))
|
---|
| 3952 | set(handles.list_object_2,'Value',2)
|
---|
| 3953 | set(handles.list_object_2,'String',[list_object(1);{'...'}])
|
---|
| 3954 | list_object_2_Callback(hObject, eventdata, handles)
|
---|
| 3955 |
|
---|
| 3956 | %delete mask if it is displayed
|
---|
| 3957 | if isequal(get(handles.mask_test,'Value'),1)%if the mask option is on
|
---|
| 3958 | UvData=rmfield(UvData,'MaskName'); %will impose mask refresh
|
---|
| 3959 | end
|
---|
| 3960 | set(handles.uvmat,'UserData',UvData)
|
---|
| 3961 | run0_Callback(hObject, eventdata, handles)
|
---|
| 3962 |
|
---|
| 3963 | %--------------------------------------------
|
---|
| 3964 | function histo1_menu_Callback(hObject, eventdata, handles)
|
---|
| 3965 | %--------------------------------------------
|
---|
| 3966 | %plot first histo
|
---|
| 3967 | huvmat=get(handles.histo1_menu,'parent');
|
---|
| 3968 | histo_menu=get(handles.histo1_menu,'String');
|
---|
| 3969 | histo_value=get(handles.histo1_menu,'Value');
|
---|
| 3970 | FieldName=histo_menu{histo_value};
|
---|
| 3971 | update_histo(handles.histo_u,huvmat,FieldName)
|
---|
| 3972 |
|
---|
| 3973 | %----------------------------------------------
|
---|
| 3974 | function histo2_menu_Callback(hObject, eventdata, handles)
|
---|
| 3975 | %----------------------------------------------
|
---|
| 3976 | %plot second histo
|
---|
| 3977 | huvmat=get(handles.histo2_menu,'parent');
|
---|
| 3978 | histo_menu=get(handles.histo2_menu,'String');
|
---|
| 3979 | histo_value=get(handles.histo2_menu,'Value');
|
---|
| 3980 | FieldName=histo_menu{histo_value};
|
---|
| 3981 | update_histo(handles.histo_v,huvmat,FieldName)
|
---|
| 3982 |
|
---|
| 3983 |
|
---|
| 3984 | %--------------------------------------------
|
---|
| 3985 | %read the field .Fieldname stored in UvData and plot its histogram
|
---|
| 3986 | function update_histo(haxes,huvmat,FieldName)
|
---|
| 3987 | UvData=get(huvmat,'UserData');
|
---|
| 3988 | if ~isfield(UvData.Field,FieldName)
|
---|
| 3989 | msgbox_uvmat('ERROR',['no field ' FieldName ' for histogram'])
|
---|
| 3990 | return
|
---|
| 3991 | end
|
---|
| 3992 | Field=UvData.Field;
|
---|
| 3993 | FieldHisto=eval(['Field.' FieldName]);
|
---|
| 3994 | if isfield(Field,'FF') && ~isempty(Field.FF) && isequal(size(Field.FF),size(FieldHisto))
|
---|
| 3995 | indsel=find(Field.FF==0);%find values marked as false
|
---|
| 3996 | if ~isempty(indsel)
|
---|
| 3997 | FieldHisto=FieldHisto(indsel);
|
---|
| 3998 | end
|
---|
| 3999 | end
|
---|
| 4000 | if isempty(Field)
|
---|
| 4001 | msgbox_uvmat('ERROR',['empty field ' FieldName])
|
---|
| 4002 | else
|
---|
| 4003 | nxy=size(FieldHisto);
|
---|
| 4004 | Amin=double(min(min(min(FieldHisto))));%min of image
|
---|
| 4005 | Amax=double(max(max(max(FieldHisto))));%max of image
|
---|
| 4006 | if isequal(Amin,Amax)
|
---|
| 4007 | msgbox_uvmat('WARNING',['uniform field =' num2str(Amin)]);
|
---|
| 4008 | else
|
---|
| 4009 | Histo.ListVarName={FieldName,'histo'};
|
---|
| 4010 | if isequal(Field.NbDim,3)
|
---|
| 4011 | Histo.VarDimName={FieldName,FieldName}; %dimensions for the histogram
|
---|
| 4012 | else
|
---|
| 4013 | if numel(nxy)==2
|
---|
| 4014 | Histo.VarDimName={FieldName,FieldName}; %dimensions for the histogram
|
---|
| 4015 | else
|
---|
| 4016 | Histo.VarDimName={FieldName,{FieldName,'rgb'}}; %dimensions for the histogram
|
---|
| 4017 | end
|
---|
| 4018 | end
|
---|
| 4019 | %unit
|
---|
| 4020 | units=[]; %default
|
---|
| 4021 | for ivar=1:numel(Field.ListVarName)
|
---|
| 4022 | if strcmp(Field.ListVarName{ivar},FieldName)
|
---|
| 4023 | if isfield(Field,'VarAttribute') && numel(Field.VarAttribute)>=ivar && isfield(Field.VarAttribute{ivar},'units')
|
---|
| 4024 | units=Field.VarAttribute{ivar}.units;
|
---|
| 4025 | break
|
---|
| 4026 | end
|
---|
| 4027 | end
|
---|
| 4028 | end
|
---|
| 4029 | if ~isempty(units)
|
---|
| 4030 | Histo.VarAttribute{1}.units=units;
|
---|
| 4031 | end
|
---|
| 4032 | eval(['Histo.' FieldName '=linspace(Amin,Amax,50);'])%absissa values for histo
|
---|
| 4033 | if isequal(Field.NbDim,3)
|
---|
| 4034 | C=reshape(double(FieldHisto),1,[]);% reshape in a vector
|
---|
| 4035 | eval(['Histo.histo(:,1)=hist(C, Histo.' FieldName ');']); %calculate histogram
|
---|
| 4036 | else
|
---|
| 4037 | for col=1:size(FieldHisto,3)
|
---|
| 4038 | B=FieldHisto(:,:,col);
|
---|
| 4039 | C=reshape(double(B),1,nxy(1)*nxy(2));% reshape in a vector
|
---|
| 4040 | eval(['Histo.histo(:,col)=hist(C, Histo.' FieldName ');']); %calculate histogram
|
---|
| 4041 | end
|
---|
| 4042 | end
|
---|
| 4043 | % set(haxes,'XLimMode','auto')%reset auto mode (after zoom effect)
|
---|
| 4044 | % set(haxes,'YLimMode','auto')
|
---|
| 4045 | % PlotParam.Auto_xy=1;
|
---|
| 4046 | plot_field(Histo,haxes);
|
---|
| 4047 | end
|
---|
| 4048 | end
|
---|
| 4049 |
|
---|
| 4050 | %------------------------------------------------
|
---|
| 4051 | %CALLBACKS FOR PLOTTING PARAMETERS
|
---|
| 4052 | %-------------------------------------------------
|
---|
| 4053 |
|
---|
| 4054 | %------------------------------------------------------------------------
|
---|
| 4055 | function MinX_Callback(hObject, eventdata, handles)
|
---|
| 4056 | %------------------------------------------------------------------------
|
---|
| 4057 | set(handles.FixLimits,'Value',1) %suppress auto mode
|
---|
| 4058 | set(handles.FixLimits,'BackgroundColor',[1 1 0])
|
---|
| 4059 | update_plot(handles);
|
---|
| 4060 |
|
---|
| 4061 | %------------------------------------------------------------------------
|
---|
| 4062 | function MaxX_Callback(hObject, eventdata, handles)
|
---|
| 4063 | %------------------------------------------------------------------------
|
---|
| 4064 | set(handles.FixLimits,'Value',1) %suppress auto mode
|
---|
| 4065 | set(handles.FixLimits,'BackgroundColor',[1 1 0])
|
---|
| 4066 | update_plot(handles);
|
---|
| 4067 |
|
---|
| 4068 | %------------------------------------------------------------------------
|
---|
| 4069 | function MinY_Callback(hObject, eventdata, handles)
|
---|
| 4070 | %------------------------------------------
|
---|
| 4071 | set(handles.FixLimits,'Value',1) %suppress auto mode
|
---|
| 4072 | set(handles.FixLimits,'BackgroundColor',[1 1 0])
|
---|
| 4073 | update_plot(handles);
|
---|
| 4074 |
|
---|
| 4075 | %------------------------------------------------------------------------
|
---|
| 4076 | function MaxY_Callback(hObject, eventdata, handles)
|
---|
| 4077 | %------------------------------------------------------------------------
|
---|
| 4078 | set(handles.FixLimits,'Value',1) %suppress auto mode
|
---|
| 4079 | set(handles.FixLimits,'BackgroundColor',[1 1 0])
|
---|
| 4080 | update_plot(handles);
|
---|
| 4081 |
|
---|
| 4082 | %------------------------------------------------------------------------
|
---|
| 4083 | function MinA_Callback(hObject, eventdata, handles)
|
---|
| 4084 | %------------------------------------------
|
---|
| 4085 | set(handles.FixScal,'Value',1) %suppress auto mode
|
---|
| 4086 | set(handles.FixScal,'BackgroundColor',[1 1 0])
|
---|
[227] | 4087 | MinA=str2double(get(handles.MinA,'String'));
|
---|
| 4088 | MaxA=str2double(get(handles.MaxA,'String'));
|
---|
| 4089 | if MinA>MaxA% switch minA and maxA in case of error
|
---|
| 4090 | MinA_old=MinA;
|
---|
| 4091 | MinA=MaxA;
|
---|
| 4092 | MaxA=MinA_old;
|
---|
| 4093 | set(handles.MinA,'String',num2str(MinA,5));
|
---|
| 4094 | set(handles.MaxA,'String',num2str(MaxA,5));
|
---|
| 4095 | end
|
---|
[199] | 4096 | update_plot(handles);
|
---|
| 4097 |
|
---|
| 4098 | %------------------------------------------------------------------------
|
---|
| 4099 | function MaxA_Callback(hObject, eventdata, handles)
|
---|
| 4100 | %------------------------------------------------------------------------
|
---|
| 4101 | set(handles.FixScal,'Value',1) %suppress auto mode
|
---|
| 4102 | set(handles.FixScal,'BackgroundColor',[1 1 0])
|
---|
[227] | 4103 | MinA=str2double(get(handles.MinA,'String'));
|
---|
| 4104 | MaxA=str2double(get(handles.MaxA,'String'));
|
---|
| 4105 | if MinA>MaxA% switch minA and maxA in case of error
|
---|
| 4106 | MinA_old=MinA;
|
---|
| 4107 | MinA=MaxA;
|
---|
| 4108 | MaxA=MinA_old;
|
---|
| 4109 | set(handles.MinA,'String',num2str(MinA,5));
|
---|
| 4110 | set(handles.MaxA,'String',num2str(MaxA,5));
|
---|
| 4111 | end
|
---|
[199] | 4112 | update_plot(handles);
|
---|
| 4113 |
|
---|
| 4114 | %------------------------------------------------------------------------
|
---|
| 4115 | function FixScal_Callback(hObject, eventdata, handles)
|
---|
| 4116 | %------------------------------------------------------------------------
|
---|
| 4117 | test=get(handles.FixScal,'Value');
|
---|
| 4118 | if test
|
---|
| 4119 | set(handles.FixScal,'BackgroundColor',[1 1 0])
|
---|
| 4120 | else
|
---|
| 4121 | set(handles.FixScal,'BackgroundColor',[0.7 0.7 0.7])
|
---|
| 4122 | update_plot(handles);
|
---|
| 4123 | end
|
---|
| 4124 |
|
---|
| 4125 | %-------------------------------------------------------------------
|
---|
| 4126 | function BW_Callback(hObject, eventdata, handles)
|
---|
| 4127 | %-------------------------------------------------------------------
|
---|
| 4128 | update_plot(handles);
|
---|
| 4129 |
|
---|
| 4130 | %-------------------------------------------------------------------
|
---|
| 4131 | function Contours_Callback(hObject, eventdata, handles)
|
---|
| 4132 | %-------------------------------------------------------------------
|
---|
| 4133 | val=get(handles.Contours,'Value');
|
---|
| 4134 | if val==2
|
---|
| 4135 | set(handles.interval_txt,'Visible','on')
|
---|
| 4136 | set(handles.IncrA,'Visible','on')
|
---|
| 4137 | else
|
---|
| 4138 | set(handles.interval_txt,'Visible','off')
|
---|
| 4139 | set(handles.IncrA,'Visible','off')
|
---|
| 4140 | end
|
---|
| 4141 | update_plot(handles);
|
---|
| 4142 |
|
---|
| 4143 | %-------------------------------------------------------------------
|
---|
| 4144 | function IncrA_Callback(hObject, eventdata, handles)
|
---|
| 4145 | %-------------------------------------------------------------------
|
---|
| 4146 | update_plot(handles);
|
---|
| 4147 |
|
---|
| 4148 | %-------------------------------------------------------------------
|
---|
| 4149 | function HideWarning_Callback(hObject, eventdata, handles)
|
---|
| 4150 | %-------------------------------------------------------------------
|
---|
| 4151 | update_plot(handles);
|
---|
| 4152 |
|
---|
| 4153 | %-------------------------------------------------------------------
|
---|
| 4154 | function HideFalse_Callback(hObject, eventdata, handles)
|
---|
| 4155 | %-------------------------------------------------------------------
|
---|
| 4156 | update_plot(handles);
|
---|
| 4157 |
|
---|
| 4158 | %-------------------------------------------------------------------
|
---|
| 4159 | function VecScale_Callback(hObject, eventdata, handles)
|
---|
| 4160 | %-------------------------------------------------------------------
|
---|
| 4161 | set(handles.FixVec,'Value',1);
|
---|
| 4162 | set(handles.FixVec,'BackgroundColor',[1 1 0])
|
---|
| 4163 | update_plot(handles);
|
---|
| 4164 |
|
---|
| 4165 | %-------------------------------------------------------------------
|
---|
| 4166 | function FixVec_Callback(hObject, eventdata, handles)
|
---|
| 4167 | %-------------------------------------------------------------------
|
---|
| 4168 | test=get(handles.FixVec,'Value');
|
---|
| 4169 | if test
|
---|
| 4170 | set(handles.FixVec,'BackgroundColor',[1 1 0])
|
---|
| 4171 | else
|
---|
| 4172 | update_plot(handles);
|
---|
| 4173 | %set(handles.VecScale,'String',num2str(ScalOut.VecScale,3))
|
---|
| 4174 | set(handles.FixVec,'BackgroundColor',[0.7 0.7 0.7])
|
---|
| 4175 | end
|
---|
| 4176 |
|
---|
| 4177 | %------------------------------------------------------------------------
|
---|
| 4178 | % --- Executes on selection change in decimate4 (nb_vec/4).
|
---|
| 4179 | function decimate4_Callback(hObject, eventdata, handles)
|
---|
| 4180 | %------------------------------------------------------------------------
|
---|
| 4181 | update_plot(handles);
|
---|
| 4182 |
|
---|
| 4183 | %------------------------------------------------------------------------
|
---|
| 4184 | % --- Executes on selection change in color_code menu
|
---|
| 4185 | function color_code_Callback(hObject, eventdata, handles)
|
---|
| 4186 | %------------------------------------------------------------------------
|
---|
| 4187 | set_vec_col_bar(handles)
|
---|
| 4188 | update_plot(handles);
|
---|
| 4189 |
|
---|
| 4190 | %------------------------------------------------------------------------
|
---|
| 4191 | % --- Executes on button press in AutoVecColor.
|
---|
| 4192 | function AutoVecColor_Callback(hObject, eventdata, handles)
|
---|
| 4193 | %------------------------------------------------------------------------
|
---|
| 4194 | test=get(handles.AutoVecColor,'Value');
|
---|
| 4195 | if test
|
---|
| 4196 | set(handles.AutoVecColor,'BackgroundColor',[1 1 0])
|
---|
| 4197 | else
|
---|
| 4198 | update_plot(handles);
|
---|
| 4199 | %set(handles.VecScale,'String',num2str(ScalOut.VecScale,3))
|
---|
| 4200 | set(handles.AutoVecColor,'BackgroundColor',[0.7 0.7 0.7])
|
---|
| 4201 | end
|
---|
| 4202 |
|
---|
| 4203 | %------------------------------------------------------------------------
|
---|
| 4204 | % --- Executes on selection change in max_vec.
|
---|
| 4205 | function min_vec_Callback(hObject, eventdata, handles)
|
---|
| 4206 | %------------------------------------------------------------------------
|
---|
| 4207 | max_vec_Callback(hObject, eventdata, handles)
|
---|
| 4208 |
|
---|
| 4209 | %------------------------------------------------------------------------
|
---|
| 4210 | % --- Executes on selection change in max_vec.
|
---|
| 4211 | function max_vec_Callback(hObject, eventdata, handles)
|
---|
| 4212 | %------------------------------------------------------------------------
|
---|
| 4213 | set(handles.AutoVecColor,'Value',1)
|
---|
| 4214 | AutoVecColor_Callback(hObject, eventdata, handles)
|
---|
| 4215 | min_val=str2num(get(handles.min_vec,'String'));
|
---|
| 4216 | max_val=str2num(get(handles.max_vec,'String'));
|
---|
| 4217 | slider1=get(handles.slider1,'Value');
|
---|
| 4218 | slider2=get(handles.slider2,'Value');
|
---|
| 4219 | colcode1=min_val+(max_val-min_val)*slider1;
|
---|
| 4220 | colcode2=min_val+(max_val-min_val)*slider2;
|
---|
| 4221 | set(handles.colcode1,'String',num2str(colcode1))
|
---|
| 4222 | set(handles.colcode2,'String',num2str(colcode2))
|
---|
| 4223 | update_plot(handles);
|
---|
| 4224 |
|
---|
| 4225 | %------------------------------------------------------------------------
|
---|
| 4226 | % --- update the display of color code for vectors
|
---|
| 4227 | function set_vec_col_bar(handles)
|
---|
| 4228 | %------------------------------------------------------------------------
|
---|
| 4229 | %get the image of the color display button 'vec_col_bar' in pixels
|
---|
| 4230 | set(handles.vec_col_bar,'Unit','pixel');
|
---|
| 4231 | pos_vert=get(handles.vec_col_bar,'Position');
|
---|
| 4232 | set(handles.vec_col_bar,'Unit','Normalized');
|
---|
| 4233 | width=ceil(pos_vert(3));
|
---|
| 4234 | height=ceil(pos_vert(4));
|
---|
| 4235 |
|
---|
| 4236 | %get slider indications
|
---|
| 4237 | list=get(handles.color_code,'String');
|
---|
| 4238 | ichoice=get(handles.color_code,'Value');
|
---|
| 4239 | colcode.ColorCode=list{ichoice};
|
---|
| 4240 | colcode.MinC=str2num(get(handles.min_vec,'String'));
|
---|
| 4241 | colcode.MaxC=str2num(get(handles.max_vec,'String'));
|
---|
| 4242 | test3color=strcmp(colcode.ColorCode,'rgb') || strcmp(colcode.ColorCode,'bgr');
|
---|
| 4243 | if test3color
|
---|
| 4244 | colcode.colcode1=str2num(get(handles.colcode1,'String'));
|
---|
| 4245 | colcode.colcode2=str2num(get(handles.colcode2,'String'));
|
---|
| 4246 | end
|
---|
| 4247 | colcode.FixedCbounds=0;
|
---|
| 4248 | colcode.FixedCbounds=1;
|
---|
| 4249 | vec_C=colcode.MinC+(colcode.MaxC-colcode.MinC)*(0.5:width-0.5)/width;%sample of vec_C values from min to max
|
---|
| 4250 | [colorlist,col_vec]=set_col_vec(colcode,vec_C);
|
---|
| 4251 | oneheight=ones(1,height);
|
---|
| 4252 | A1=colorlist(col_vec,1)*oneheight;
|
---|
| 4253 | A2=colorlist(col_vec,2)*oneheight;
|
---|
| 4254 | A3=colorlist(col_vec,3)*oneheight;
|
---|
| 4255 | A(:,:,1)=A1';
|
---|
| 4256 | A(:,:,2)=A2';
|
---|
| 4257 | A(:,:,3)=A3';
|
---|
| 4258 | set(handles.vec_col_bar,'Cdata',A)
|
---|
| 4259 |
|
---|
| 4260 |
|
---|
| 4261 | %-------------------------------------------------------------------
|
---|
| 4262 | function update_plot(handles)
|
---|
| 4263 | %-------------------------------------------------------------------
|
---|
| 4264 | haxes= handles.axes3;
|
---|
| 4265 | UvData=get(handles.uvmat,'UserData');
|
---|
| 4266 | AxeData=UvData.axes3;
|
---|
| 4267 | PlotParam=read_plot_param(handles);
|
---|
| 4268 | [PP,PlotParamOut]= plot_field(AxeData,haxes,PlotParam);
|
---|
| 4269 | write_plot_param(handles,PlotParamOut); %update the auto plot parameters
|
---|
| 4270 |
|
---|
| 4271 | %-------------------------------------------------------------------
|
---|
| 4272 | % --- Executes on button press in grid.
|
---|
| 4273 | function grid_Callback(hObject, eventdata, handles)
|
---|
| 4274 |
|
---|
| 4275 |
|
---|
| 4276 | %-------------------------------------------------------------------
|
---|
| 4277 | % --- Executes on selection change in edit_object.
|
---|
| 4278 | function edit_object_Callback(hObject, eventdata, handles)
|
---|
| 4279 | %-------------------------------------------------------------------
|
---|
| 4280 | UvData=get(handles.uvmat,'UserData');%read UvData properties stored on the uvmat interface
|
---|
| 4281 | test=get(handles.edit_object,'Value');
|
---|
| 4282 | if test
|
---|
| 4283 | set(handles.edit_object,'BackgroundColor',[1,1,0])
|
---|
| 4284 | %suppress the other options
|
---|
| 4285 | set(handles.zoom,'Value',0)
|
---|
| 4286 | zoom_Callback(hObject, eventdata, handles)
|
---|
| 4287 | hgeometry_calib=findobj(allchild(0),'tag','geometry_calib');
|
---|
| 4288 | if ishandle(hgeometry_calib)
|
---|
| 4289 | hhgeometry_calib=guidata(hgeometry_calib);
|
---|
| 4290 | set(hhgeometry_calib.edit_append,'Value',0)% desactivate mouse action in geometry_calib
|
---|
| 4291 | set(hhgeometry_calib.edit_append,'BackgroundColor',[0.7 0.7 0.7])
|
---|
| 4292 | end
|
---|
| 4293 | else
|
---|
| 4294 | UvData.MouseAction='none';
|
---|
| 4295 | set(handles.edit_object,'BackgroundColor',[0.7,0.7,0.7])
|
---|
| 4296 | hset_object=findobj(allchild(0),'tag','set_object');% look for the set_object GUI
|
---|
| 4297 | if ~isempty(hset_object)
|
---|
| 4298 | delete(hset_object)% delete the current GUI set_object
|
---|
| 4299 | end
|
---|
| 4300 | end
|
---|
| 4301 | set(handles.uvmat,'UserData',UvData);
|
---|
| 4302 | hset_object=findobj(allchild(0),'Tag','set_object');
|
---|
| 4303 | if ~isempty(hset_object)
|
---|
| 4304 | hhset_object=guidata(hset_object);
|
---|
| 4305 | if test
|
---|
| 4306 | set(hhset_object.PLOT,'enable','on');
|
---|
| 4307 | else
|
---|
| 4308 | set(hhset_object.PLOT,'enable','off');
|
---|
| 4309 | end
|
---|
| 4310 | end
|
---|
| 4311 |
|
---|
| 4312 | %------------------------------------------------------------------------
|
---|
| 4313 | % --- Executes on selection change in list_object_1.
|
---|
| 4314 | function list_object_1_Callback(hObject, eventdata, handles)
|
---|
| 4315 | %------------------------------------------------------------------------
|
---|
| 4316 | list_str=get(handles.list_object_1,'String');
|
---|
| 4317 | IndexObj=get(handles.list_object_1,'Value');
|
---|
| 4318 | str_1=list_str{IndexObj};
|
---|
| 4319 | val_2=get(handles.list_object_2,'Value');
|
---|
| 4320 | str_2=get(handles.list_object_2,'String');
|
---|
| 4321 | if isequal(val_2,IndexObj)% if the first selection is equal to the second, it will suppress the second
|
---|
| 4322 | set(handles.list_object_2,'Value',numel(str_2))%select the end of the list ('...')
|
---|
| 4323 | list_object_2_Callback(hObject, eventdata, handles)
|
---|
| 4324 | end
|
---|
| 4325 | update_object(handles,IndexObj,1,str_1)
|
---|
| 4326 |
|
---|
| 4327 | %------------------------------------------------------------------------
|
---|
| 4328 | % --- Executes on selection change in list_object_1.
|
---|
| 4329 | function list_object_2_Callback(hObject, eventdata, handles)
|
---|
| 4330 | %------------------------------------------------------------------------
|
---|
| 4331 | list_str=get(handles.list_object_2,'String');
|
---|
| 4332 | IndexObj=get(handles.list_object_2,'Value');
|
---|
| 4333 | if ischar(list_str) || strcmp(list_str{IndexObj},'...')
|
---|
| 4334 | hview_field=findobj(allchild(0),'Tag','view_field');
|
---|
| 4335 | if ~isempty(hview_field)
|
---|
| 4336 | delete(hview_field)
|
---|
| 4337 | end
|
---|
| 4338 | hset_object=findobj(allchild(0),'Tag','set_object');
|
---|
| 4339 | if ~isempty(hset_object)
|
---|
| 4340 | delete(hset_object)
|
---|
| 4341 | end
|
---|
| 4342 | else
|
---|
| 4343 | update_object(handles,IndexObj,2,list_str{IndexObj})
|
---|
| 4344 | end
|
---|
| 4345 |
|
---|
| 4346 | %------------------------------------------------------------------------
|
---|
| 4347 | function update_object(handles,IndexObj,option,ObjectName)
|
---|
| 4348 | %------------------------------------------------------------------------
|
---|
| 4349 | UvData=get(handles.uvmat,'UserData');%read UvData properties stored on the uvmat interface
|
---|
| 4350 | if numel(UvData.Object)<IndexObj;
|
---|
| 4351 | return
|
---|
| 4352 | end
|
---|
| 4353 | ObjectData=UvData.Object{IndexObj};
|
---|
| 4354 | ObjectData.Name=ObjectName;
|
---|
| 4355 | if isequal(get(handles.edit_object,'Value'),1)
|
---|
| 4356 | ObjectData.enable_plot=1; % desable the PLOT option in the set_object GUI (editing mode
|
---|
| 4357 | end
|
---|
| 4358 | ZBounds=0; % default
|
---|
| 4359 | if isfield(UvData.Field,'ZMin') && isfield(UvData.Field,'ZMax')
|
---|
| 4360 | ZBounds(1)=UvData.Field.ZMin; %minimum for the Z slider
|
---|
| 4361 | ZBounds(2)=UvData.Field.ZMax;%maximum for the Z slider
|
---|
| 4362 | end
|
---|
| 4363 | hset_object=findobj(allchild(0),'tag','set_object');
|
---|
| 4364 | if ~isempty(hset_object)
|
---|
| 4365 | delete(hset_object)% delete existing version of set_object
|
---|
| 4366 | end
|
---|
| 4367 | edit_test=get(handles.edit_object,'Value');
|
---|
| 4368 | if edit_test
|
---|
| 4369 | ObjectData.enable_plot=1;
|
---|
| 4370 | else
|
---|
[210] | 4371 | if isfield(ObjectData,'enable_plot')
|
---|
[199] | 4372 | ObjectData=rmfield(ObjectData,'enable_plot');
|
---|
| 4373 | end
|
---|
| 4374 | end
|
---|
| 4375 | hset_object=set_object(ObjectData,[],ZBounds);% call the set_object interface,
|
---|
| 4376 |
|
---|
| 4377 | % %project the current field on the object and plot it
|
---|
| 4378 | ProjData= proj_field(UvData.Field,ObjectData);%project the current interface field on ObjectData
|
---|
| 4379 | if option==1%length(UvData.Object)>= IndexObj && isfield(UvData.Object{IndexObj},'plotaxes')&& ishandle(UvData.Object{IndexObj}.plotaxes)
|
---|
| 4380 | PlotHandles=handles;
|
---|
| 4381 | else
|
---|
| 4382 | hview_field=findobj(allchild(0),'tag','view_field');
|
---|
| 4383 | if isempty(hview_field)
|
---|
| 4384 | hview_field=view_field;
|
---|
| 4385 | end
|
---|
| 4386 | PlotHandles=guidata(hview_field);
|
---|
| 4387 | end
|
---|
| 4388 | plot_field(ProjData,PlotHandles.axes3,PlotHandles);
|
---|
| 4389 | set(handles.uvmat,'UserData',UvData)
|
---|
| 4390 | hother=findobj('Tag','proj_object');%find all the proj objects
|
---|
| 4391 | for iobj=1:length(hother)
|
---|
| 4392 | if isequal(get(hother(iobj),'Type'),'rectangle')||isequal(get(hother(iobj),'Type'),'patch')
|
---|
| 4393 | set(hother(iobj),'EdgeColor','b')
|
---|
| 4394 | if isequal(get(hother(iobj),'FaceColor'),'m')
|
---|
| 4395 | set(hother(iobj),'FaceColor','b')
|
---|
| 4396 | end
|
---|
| 4397 | elseif isequal(get(hother(iobj),'Type'),'image')
|
---|
| 4398 | Acolor=get(hother(iobj),'CData');
|
---|
| 4399 | Acolor(:,:,1)=zeros(size(Acolor,1),size(Acolor,2));
|
---|
| 4400 | set(hother(iobj),'CData',Acolor);
|
---|
| 4401 | else
|
---|
| 4402 | set(hother(iobj),'Color','b')
|
---|
| 4403 | end
|
---|
| 4404 | set(hother(iobj),'Selected','off')
|
---|
| 4405 | end
|
---|
| 4406 | hother=findobj('Tag','DeformPoint');
|
---|
| 4407 | set(hother,'Color','b');
|
---|
| 4408 | set(hother,'Selected','off')
|
---|
| 4409 | if isfield(ObjectData,'DisplayHandle_uvmat')
|
---|
| 4410 | if ishandle(ObjectData.DisplayHandle_uvmat)
|
---|
| 4411 | uistack(ObjectData.DisplayHandle_uvmat,'top')
|
---|
| 4412 | linetype=get(ObjectData.DisplayHandle_uvmat,'Type');
|
---|
| 4413 | if isequal(linetype,'line')
|
---|
| 4414 | set(ObjectData.DisplayHandle_uvmat,'Color','m'); %set the selected object to magenta color
|
---|
| 4415 | elseif isequal(linetype,'rectangle')
|
---|
| 4416 | set(ObjectData.DisplayHandle_uvmat,'EdgeColor','m'); %set the selected object to magenta color
|
---|
| 4417 | elseif isequal(linetype,'patch')
|
---|
| 4418 | set(ObjectData.DisplayHandle_uvmat,'FaceColor','m'); %set the selected object to magenta color
|
---|
| 4419 | end
|
---|
| 4420 | SubObjectData=get(ObjectData.DisplayHandle_uvmat,'UserData');
|
---|
| 4421 | if isfield(SubObjectData,'SubObject') & ishandle(SubObjectData.SubObject)
|
---|
| 4422 | uistack(SubObjectData.SubObject,'top')
|
---|
| 4423 | for iobj=1:length(SubObjectData.SubObject)
|
---|
| 4424 | hsub=SubObjectData.SubObject(iobj);
|
---|
| 4425 | if isequal(get(hsub,'Type'),'rectangle')
|
---|
| 4426 | set(hsub,'EdgeColor','m'); %set the selected object to magenta color
|
---|
| 4427 | elseif isequal(get(hsub,'Type'),'image')
|
---|
| 4428 | Acolor=get(hsub,'CData');
|
---|
| 4429 | Acolor(:,:,1)=Acolor(:,:,3);
|
---|
| 4430 | set(hsub,'CData',Acolor);
|
---|
| 4431 | else
|
---|
| 4432 | set(hsub,'Color','m')
|
---|
| 4433 | end
|
---|
| 4434 | end
|
---|
| 4435 | end
|
---|
| 4436 | if isfield(SubObjectData,'DeformPoint') & ishandle(SubObjectData.DeformPoint)
|
---|
| 4437 | set(SubObjectData.DeformPoint,'Color','m')
|
---|
| 4438 | end
|
---|
| 4439 | end
|
---|
| 4440 | % end
|
---|
| 4441 | end
|
---|
| 4442 | % pause(0.1)
|
---|
| 4443 | figure(hset_object)%put set_object in front
|
---|
| 4444 |
|
---|
| 4445 | %------------------------------------------------------
|
---|
| 4446 | % --- Executes on button press in Menu/Export/field in workspace.
|
---|
| 4447 | %------------------------------------------------------
|
---|
| 4448 | function MenuExportField_Callback(hObject, eventdata, handles)
|
---|
| 4449 | global Data_uvmat
|
---|
| 4450 | Data_uvmat=get(handles.uvmat,'UserData');
|
---|
| 4451 | evalin('base','global Data_uvmat')%make CurData global in the workspace
|
---|
| 4452 | display('current field :')
|
---|
| 4453 | evalin('base','Data_uvmat') %display CurData in the workspace
|
---|
| 4454 | commandwindow; %brings the Matlab command window to the front
|
---|
| 4455 |
|
---|
| 4456 | %------------------------------------------------------
|
---|
| 4457 | % --- Executes on button press in Menu/Export/extract figure.
|
---|
| 4458 | %------------------------------------------------------
|
---|
| 4459 | function MenuExport_plot_Callback(hObject, eventdata, handles)
|
---|
| 4460 | huvmat=get(handles.MenuExport_plot,'parent');
|
---|
| 4461 | UvData=get(huvmat,'UserData');
|
---|
| 4462 | hfig=figure;
|
---|
| 4463 | newaxes=copyobj(handles.axes3,hfig);
|
---|
| 4464 | map=colormap(handles.axes3);
|
---|
| 4465 | colormap(map);%transmit the current colormap to the zoom fig
|
---|
| 4466 | colorbar
|
---|
| 4467 |
|
---|
| 4468 |
|
---|
| 4469 | % --------------------------------------------------------------------
|
---|
| 4470 | function Insert_Callback(hObject, eventdata, handles)
|
---|
| 4471 |
|
---|
| 4472 |
|
---|
| 4473 | % --------------------------------------------------------------------
|
---|
| 4474 | function MenuHelp_Callback(hObject, eventdata, handles)
|
---|
| 4475 | % --------------------------------------------------------------------
|
---|
| 4476 | path_to_uvmat=which ('uvmat');% check the path of uvmat
|
---|
| 4477 | pathelp=fileparts(path_to_uvmat);
|
---|
| 4478 | helpfile=fullfile(pathelp,'uvmat_doc','uvmat_doc.html');
|
---|
| 4479 | 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')
|
---|
| 4480 | else
|
---|
| 4481 | addpath (fullfile(pathelp,'uvmat_doc'))
|
---|
| 4482 | web(helpfile);
|
---|
| 4483 | end
|
---|
| 4484 |
|
---|
| 4485 | %------------------------------------------------------------------------
|
---|
| 4486 | % --------------------------------------------------------------------
|
---|
| 4487 | function MenuExportMovie_Callback(hObject, eventdata, handles)
|
---|
| 4488 | % --------------------------------------------------------------------
|
---|
| 4489 | set(handles.MenuExportMovie,'BusyAction','queue')% activate the button
|
---|
| 4490 | huvmat=get(handles.run0,'parent');
|
---|
| 4491 | UvData=get(huvmat,'UserData');
|
---|
| 4492 | [xx,xx,FileBase]=read_file_boxes(handles);
|
---|
| 4493 | %read the current input file name
|
---|
| 4494 | 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)'};
|
---|
| 4495 | dlg_title = 'select properties of the output avi movie';
|
---|
| 4496 | num_lines= 1;
|
---|
| 4497 | % nbfield_cell=get(handles.last_i,'String');
|
---|
| 4498 | def = {[FileBase '_out.avi'];'10';'1';'[0.03 0.05 0.95 0.92]';'10'};
|
---|
| 4499 | answer = inputdlg(prompt,dlg_title,num_lines,def,'on');
|
---|
| 4500 | aviname=answer{1};
|
---|
| 4501 | fps=str2double(answer{2});
|
---|
| 4502 | % check for existing file with output name aviname
|
---|
| 4503 | if exist(aviname,'file')
|
---|
| 4504 | backup=aviname;
|
---|
| 4505 | testexist=2;
|
---|
| 4506 | while testexist==2
|
---|
| 4507 | backup=[backup '~'];
|
---|
| 4508 | testexist=exist(backup,'file');
|
---|
| 4509 | end
|
---|
| 4510 | [success,message]=copyfile(aviname,backup);%make backup of the existing file
|
---|
| 4511 | if isequal(success,1)
|
---|
| 4512 | delete(aviname)%delete existing file
|
---|
| 4513 | else
|
---|
| 4514 | msgbox_uvmat('ERROR',message)
|
---|
| 4515 | return
|
---|
| 4516 | end
|
---|
| 4517 | end
|
---|
| 4518 | %create avi open
|
---|
| 4519 | aviobj=avifile(aviname,'Compression','None','fps',fps);
|
---|
| 4520 |
|
---|
| 4521 | %display first view for tests
|
---|
| 4522 | newfig=figure;
|
---|
| 4523 | newaxes=copyobj(handles.axes3,newfig);%new plotting axes in the new figure
|
---|
| 4524 | set(newaxes,'Tag','movieaxes')
|
---|
| 4525 | nbpix=[512 384]*str2double(answer{3});
|
---|
| 4526 | set(gcf,'Position',[1 1 nbpix])% resolution XVGA
|
---|
| 4527 | set(newaxes,'Position',eval(answer{4}));
|
---|
| 4528 | map=colormap(handles.axes3);
|
---|
| 4529 | colormap(map);%transmit the current colormap to the zoom fig
|
---|
| 4530 | msgbox_uvmat('INPUT_Y-N',{['adjust figure ' num2str(newfig) ' with its matlab edit menu '] ;...
|
---|
| 4531 | ['then press OK to get the avi movie as a copy of figure ' num2str(newfig) ' display']});
|
---|
[215] | 4532 | UvData.plotaxes=newaxes;% the axis in the new figure becomes the current main plotting axes
|
---|
[199] | 4533 | set(huvmat,'UserData',UvData);
|
---|
| 4534 | increment=str2double(get(handles.increment_scan,'String')); %get the field increment d
|
---|
| 4535 | if isnan(increment)
|
---|
| 4536 | set(handles.increment_scan,'String','1')%default value
|
---|
| 4537 | increment=1;
|
---|
| 4538 | end
|
---|
| 4539 | set(handles.STOP,'Visible','on')
|
---|
| 4540 | set(handles.speed,'Visible','on')
|
---|
| 4541 | set(handles.speed_txt,'Visible','on')
|
---|
| 4542 | set(handles.Movie,'BusyAction','queue')
|
---|
| 4543 |
|
---|
| 4544 | %imin=str2double(get(handles.i1,'String'));
|
---|
| 4545 | imax=str2double(answer{5});
|
---|
| 4546 | % if isfield(UvData,'Time')
|
---|
| 4547 | htitle=get(newaxes,'Title');
|
---|
| 4548 | xlim=get(newaxes,'XLim');
|
---|
| 4549 | ylim=get(newaxes,'YLim');
|
---|
| 4550 | set(htitle,'Position',[xlim(2)+0.07*(xlim(2)-xlim(1)) ylim(2)-0.05*(ylim(2)-ylim(1)) 0])
|
---|
| 4551 | time_str=get(handles.abs_time,'String');
|
---|
| 4552 | set(htitle,'String',['t=' time_str])
|
---|
| 4553 | set(handles.speed,'Value',1)
|
---|
| 4554 | for i=1:imax
|
---|
| 4555 | if get(handles.speed,'Value')~=0 && isequal(get(handles.MenuExportMovie,'BusyAction'),'queue') % enable STOP command
|
---|
| 4556 | runpm(hObject,eventdata,handles,increment)% run plus
|
---|
| 4557 | drawnow
|
---|
| 4558 | time_str=get(handles.abs_time,'String');
|
---|
| 4559 | if ishandle(htitle)
|
---|
| 4560 | set(htitle,'String',['t=' time_str])
|
---|
| 4561 | end
|
---|
| 4562 | mov=getframe(newfig);
|
---|
| 4563 | aviobj=addframe(aviobj,mov);
|
---|
| 4564 | end
|
---|
| 4565 | end
|
---|
[215] | 4566 | aviobj=close(aviobj);
|
---|
| 4567 | UvData=rmfield(UvData,'plotaxes');
|
---|
| 4568 | %UvData.Object{1}.plotaxes=handles.axes3;
|
---|
[199] | 4569 | set(huvmat,'UserData',UvData);
|
---|
| 4570 | msgbox_uvmat('CONFIRMATION',{['movie ' aviname ' created '];['with ' num2str(imax) ' frames']})
|
---|
| 4571 |
|
---|
| 4572 | %------------------------------------------------------------------------
|
---|
| 4573 | function MenuCalib_Callback(hObject, eventdata, handles)
|
---|
| 4574 | %------------------------------------------------------------------------
|
---|
| 4575 |
|
---|
| 4576 | UvData=get(handles.uvmat,'UserData');%read UvData properties stored on the uvmat interface
|
---|
| 4577 |
|
---|
| 4578 | %suppress competing options
|
---|
| 4579 | set(handles.zoom,'Value',0)
|
---|
| 4580 | set(handles.zoom,'BackgroundColor',[0.7 0.7 0.7])
|
---|
| 4581 | set(handles.list_object_1,'Value',1)
|
---|
| 4582 | % initiate display of GUI geometry_calib
|
---|
| 4583 | data=[]; %default
|
---|
| 4584 | if isfield(UvData,'CoordType')
|
---|
| 4585 | data.CoordType=UvData.CoordType;
|
---|
| 4586 | end
|
---|
| 4587 | pos=get(handles.uvmat,'Position');
|
---|
| 4588 | pos(1)=pos(1)+pos(3)-0.311+0.04; %0.311= width of the geometry_calib interface (units relative to the srcreen)
|
---|
| 4589 | pos(2)=pos(2)-0.02;
|
---|
| 4590 | [FileName,RootPath,FileBase,FileIndices,FileExt,SubDir]=read_file_boxes(handles);
|
---|
| 4591 | set(handles.view_xml,'Backgroundcolor',[1 1 0])%indicate the reading of the current xml file by geometry_calib
|
---|
| 4592 | if isfield(UvData.OpenParam,'CalOrigin')
|
---|
| 4593 | pos_uvmat=get(handles.uvmat,'Position');
|
---|
| 4594 | pos_cal(1)=pos_uvmat(1)+UvData.OpenParam.CalOrigin(1)*pos_uvmat(3);
|
---|
| 4595 | pos_cal(2)=pos_uvmat(2)+UvData.OpenParam.CalOrigin(2)*pos_uvmat(4);
|
---|
| 4596 | pos_cal(3:4)=UvData.OpenParam.CalSize .* pos_uvmat(3:4);
|
---|
| 4597 | end
|
---|
| 4598 | geometry_calib(FileName,pos_cal);% call the geometry_calib interface
|
---|
| 4599 | set(handles.view_xml,'Backgroundcolor',[1 1 1])%indicate the end of reading of the current xml file by geometry_calib
|
---|
| 4600 | set(handles.MenuCalib,'checked','on')% indicate that MenuCalib is activated, test used by mouse action
|
---|
| 4601 |
|
---|
| 4602 | %------------------------------------------------------------------------
|
---|
| 4603 | function MenuMask_Callback(hObject, eventdata, handles)
|
---|
| 4604 | %------------------------------------------------------------------------
|
---|
| 4605 | UvData=get(handles.uvmat,'UserData');%read UvData properties stored on the uvmat interface
|
---|
| 4606 | ListObj=UvData.Object;
|
---|
| 4607 | select=zeros(1,numel(ListObj));
|
---|
| 4608 | for iobj=1:numel(ListObj);
|
---|
| 4609 | if strcmp(ListObj{iobj}.ProjMode,'mask_inside')||strcmp(ListObj{iobj}.ProjMode,'mask_outside')
|
---|
| 4610 | select(iobj)=1;
|
---|
| 4611 | end
|
---|
| 4612 | end
|
---|
| 4613 | val=find(select);
|
---|
| 4614 | if isempty(val)
|
---|
| 4615 | msgbox_uvmat('ERROR','polygons must be first created by Projection object/mask polygon in the menu bar');
|
---|
| 4616 | return
|
---|
| 4617 | else
|
---|
| 4618 | set(handles.list_object_1,'Max',2);%allow multiple selection
|
---|
| 4619 | set(handles.list_object_1,'Value',val);
|
---|
| 4620 | flag=1;
|
---|
| 4621 | npx=size(UvData.Field.A,2);
|
---|
| 4622 | npy=size(UvData.Field.A,1);
|
---|
| 4623 | xi=0.5:npx-0.5;
|
---|
| 4624 | yi=0.5:npy-0.5;
|
---|
| 4625 | [Xi,Yi]=meshgrid(xi,yi);
|
---|
| 4626 | if isfield(UvData,'Object')
|
---|
| 4627 | for iobj=1:length(UvData.Object)
|
---|
| 4628 | ObjectData=UvData.Object{iobj};
|
---|
| 4629 | if isfield(ObjectData,'ProjMode') &&(isequal(ObjectData.ProjMode,'mask_inside')||isequal(ObjectData.ProjMode,'mask_outside'));
|
---|
| 4630 | flagobj=1;
|
---|
| 4631 | testphys=0; %coordinates in pixels by default
|
---|
| 4632 | if isfield(ObjectData,'CoordUnit') && ~isequal(ObjectData.CoordUnit,'pixel')
|
---|
| 4633 | if isfield(UvData,'XmlData')&& isfield(UvData.XmlData,'GeometryCalib')
|
---|
| 4634 | Calib=UvData.XmlData.GeometryCalib;
|
---|
| 4635 | testphys=1;
|
---|
| 4636 | end
|
---|
| 4637 | end
|
---|
| 4638 | if isfield(ObjectData,'Coord')& isfield(ObjectData,'Style')
|
---|
| 4639 | if isequal(ObjectData.Style,'polygon')
|
---|
| 4640 | X=ObjectData.Coord(:,1);
|
---|
| 4641 | Y=ObjectData.Coord(:,2);
|
---|
| 4642 | if testphys
|
---|
| 4643 | [X,Y]=px_XYZ(Calib,X,Y,0);% to generalise with 3D cases
|
---|
| 4644 | end
|
---|
| 4645 | flagobj=~inpolygon(Xi,Yi,X',Y');%=0 inside the polygon, 1 outside
|
---|
| 4646 | elseif isequal(ObjectData.Style,'ellipse')
|
---|
| 4647 | if testphys
|
---|
| 4648 | %[X,Y]=px_XYZ(Calib,X,Y,0);% TODO:create a polygon boundary and transform to phys
|
---|
| 4649 | end
|
---|
| 4650 | RangeX=max(ObjectData.RangeX);
|
---|
| 4651 | RangeY=max(ObjectData.RangeY);
|
---|
| 4652 | X2Max=RangeX*RangeX;
|
---|
| 4653 | Y2Max=RangeY*RangeY;
|
---|
| 4654 | distX=(Xi-ObjectData.Coord(1,1));
|
---|
| 4655 | distY=(Yi-ObjectData.Coord(1,2));
|
---|
| 4656 | flagobj=(distX.*distX/X2Max+distY.*distY/Y2Max)>1;
|
---|
| 4657 | elseif isequal(ObjectData.Style,'rectangle')
|
---|
| 4658 | if testphys
|
---|
| 4659 | %[X,Y]=px_XYZ(Calib,X,Y,0);% TODO:create a polygon boundary and transform to phys
|
---|
| 4660 | end
|
---|
| 4661 | distX=abs(Xi-ObjectData.Coord(1,1));
|
---|
| 4662 | distY=abs(Yi-ObjectData.Coord(1,2));
|
---|
| 4663 | flagobj=distX>max(ObjectData.RangeX) | distY>max(ObjectData.RangeY);
|
---|
| 4664 | end
|
---|
| 4665 | if isequal(ObjectData.ProjMode,'mask_outside')
|
---|
| 4666 | flagobj=~flagobj;
|
---|
| 4667 | end
|
---|
| 4668 | flag=flag & flagobj;
|
---|
| 4669 | end
|
---|
| 4670 | end
|
---|
| 4671 | end
|
---|
| 4672 | end
|
---|
| 4673 |
|
---|
| 4674 | %mask name
|
---|
| 4675 | RootPath=get(handles.RootPath,'String');
|
---|
| 4676 | RootFile=get(handles.RootFile,'String');
|
---|
| 4677 | if ~isempty(RootFile)&&(isequal(RootFile(1),'/')|| isequal(RootFile(1),'\'))
|
---|
| 4678 | RootFile(1)=[];
|
---|
| 4679 | end
|
---|
| 4680 | filebase=fullfile(RootPath,RootFile);
|
---|
| 4681 | list=get(handles.masklevel,'String');
|
---|
| 4682 | masknumber=num2str(length(list));
|
---|
| 4683 | maskindex=get(handles.masklevel,'Value');
|
---|
| 4684 | mask_name=name_generator([filebase '_' masknumber 'mask'],maskindex,1,'.png','_i');
|
---|
| 4685 | imflag=uint8(255*(0.392+0.608*flag));% =100 for flag=0 (vectors not computed when 20<imflag<200)
|
---|
| 4686 | imflag=flipdim(imflag,1);
|
---|
| 4687 |
|
---|
| 4688 | %display the mask
|
---|
| 4689 | figure;
|
---|
| 4690 | vec=linspace(0,1,256);%define a linear greyscale colormap
|
---|
| 4691 | map=[vec' vec' vec'];
|
---|
| 4692 | colormap(map)
|
---|
| 4693 | image(imflag);
|
---|
| 4694 | answer=msgbox_uvmat('INPUT_TXT','mask file name:', mask_name);
|
---|
| 4695 | if ~strcmp(answer,'Cancel')
|
---|
| 4696 | mask_dir=fileparts(answer);
|
---|
| 4697 | if ~exist(mask_dir,'dir')
|
---|
| 4698 | msgbox_uvmat('ERROR',['directory ' mask_dir ' does not exist'])
|
---|
| 4699 | return
|
---|
| 4700 | end
|
---|
| 4701 | imwrite(imflag,answer,'BitDepth',8);
|
---|
| 4702 | end
|
---|
| 4703 | set(handles.list_object_1,'Value',1)
|
---|
| 4704 | set(handles.list_object_1,'Max',1)
|
---|
| 4705 | end
|
---|
| 4706 |
|
---|
| 4707 | %------------------------------------------------------------------------
|
---|
| 4708 | %-- open the GUI set_grid.fig to create grid
|
---|
| 4709 | function MenuGrid_Callback(hObject, eventdata, handles)
|
---|
| 4710 | %------------------------------------------------------------------------
|
---|
| 4711 | %UvData=get(handles.uvmat,'UserData');%read UvData properties stored on the uvmat interface
|
---|
| 4712 |
|
---|
| 4713 | %suppress the other options if grid is chosen
|
---|
| 4714 | set(handles.edit_vect,'Value',0)
|
---|
| 4715 | edit_vect_Callback(hObject, eventdata, handles)
|
---|
| 4716 | set(handles.edit_object,'BackgroundColor',[0.7 0.7 0.7])
|
---|
| 4717 | set(handles.list_object_1,'Value',1)
|
---|
| 4718 |
|
---|
| 4719 | %prepare display of the set_grid GUI
|
---|
| 4720 | FileName=read_file_boxes(handles);
|
---|
| 4721 | CoordList=get(handles.transform_fct,'String');
|
---|
| 4722 | val=get(handles.transform_fct,'Value');
|
---|
| 4723 | set_grid(FileName,CoordList{val});% call the set_object interface
|
---|
| 4724 | %set(handles.uvmat,'UserData',UvData);
|
---|
| 4725 |
|
---|
| 4726 | %------------------------------------------------------------------------
|
---|
| 4727 | % open the GUI 'series'
|
---|
| 4728 | function MenuSeries_Callback(hObject, eventdata, handles)
|
---|
| 4729 | %------------------------------------------------------------------------
|
---|
| 4730 | series; %first display of the GUI to fill waiting time
|
---|
| 4731 | [param.FileName]=read_file_boxes(handles);
|
---|
| 4732 | if isequal(get(handles.SubField,'Value'),1)
|
---|
| 4733 | FileName_1=read_file_boxes_1(handles);%
|
---|
| 4734 | if ~isequal(FileName_1,param.FileName)
|
---|
| 4735 | param.FileName_1=FileName_1;
|
---|
| 4736 | end
|
---|
| 4737 | end
|
---|
| 4738 | param.NomType=get(handles.FileIndex,'UserData');
|
---|
| 4739 | param.NomType_1=get(handles.FileIndex_1,'UserData');
|
---|
| 4740 | param.comp_input=get(handles.fix_pair,'Value');
|
---|
| 4741 | huvmat=get(handles.MenuSeries,'parent');
|
---|
| 4742 | UvData=get(huvmat,'UserData');
|
---|
| 4743 | if isfield(UvData,'Time')
|
---|
| 4744 | param.Time=UvData.XmlData.Time;
|
---|
| 4745 | end
|
---|
| 4746 | if isequal(get(handles.scan_i,'Value'),1)
|
---|
| 4747 | param.incr_i=str2double(get(handles.increment_scan,'String'));
|
---|
| 4748 | elseif isequal(get(handles.scan_j,'Value'),1)
|
---|
| 4749 | param.incr_j=str2double(get(handles.increment_scan,'String'));
|
---|
| 4750 | end
|
---|
| 4751 | param.list_fields=get(handles.Fields,'String');% list menu fields
|
---|
| 4752 | param.list_fields(1)=[]; %suppress 'image' option
|
---|
| 4753 | param.index_fields=get(handles.Fields,'Value');% selected string index
|
---|
| 4754 | if param.index_fields>1
|
---|
| 4755 | param.index_fields=param.index_fields-1;
|
---|
| 4756 | end
|
---|
| 4757 | param.list_fields_1=get(handles.Fields_1,'String');% list menu fields
|
---|
| 4758 | param.list_fields_1(1)=[]; %suppress 'image' option
|
---|
| 4759 | param.index_fields_1=get(handles.Fields_1,'Value')-1;% selected string index
|
---|
| 4760 | if param.index_fields_1>1
|
---|
| 4761 | param.index_fields_1=param.index_fields_1-1;
|
---|
| 4762 | end
|
---|
| 4763 | param.civ1=get(handles.civ1,'Value');
|
---|
| 4764 | param.civ2=get(handles.civ2,'Value');
|
---|
| 4765 | param.interp1=get(handles.interp1,'Value');
|
---|
| 4766 | param.interp2=get(handles.interp2,'Value');
|
---|
| 4767 | param.filter1=get(handles.filter1,'Value');
|
---|
| 4768 | param.filter2=get(handles.filter2,'Value');
|
---|
| 4769 | param.menu_coord_str=get(handles.transform_fct,'String');
|
---|
| 4770 | param.menu_coord_val=get(handles.transform_fct,'Value');
|
---|
| 4771 |
|
---|
| 4772 | series(param); %run the series interface
|
---|
| 4773 |
|
---|
| 4774 | %------------------------------------------------------------------------
|
---|
| 4775 | % -- open the GUI civ.fig for civx (PIV)
|
---|
| 4776 | function MenuPIV_Callback(hObject, eventdata, handles)
|
---|
| 4777 | %------------------------------------------------------------------------
|
---|
| 4778 |
|
---|
| 4779 | [FileName,RootPath,filebase,FileIndices,ext,SubDir]=read_file_boxes(handles);
|
---|
| 4780 | num1=stra2num(get(handles.i1,'String'));
|
---|
| 4781 | num2=stra2num(get(handles.i2,'String'));
|
---|
| 4782 | num_a=stra2num(get(handles.j1,'String'));
|
---|
| 4783 | num_b=stra2num(get(handles.j2,'String'));
|
---|
| 4784 | NomType=get(handles.FileIndex,'UserData');
|
---|
| 4785 | ind_opening=1; % default (images): will advice civ1 option by default in the civ interface
|
---|
| 4786 | if isequal(ext,'.nc') || isequal(ext,'.cdf')% netcdf files
|
---|
| 4787 | ind_opening=2;% propose 'fix' as the default option
|
---|
| 4788 | % +read the current netcdf rootfile
|
---|
| 4789 | Data=nc2struct(FileName,'ListGlobalAttribute','fix','patch','civ2','fix2');
|
---|
| 4790 | if isfield(Data,'fix') && isequal(Data.fix,1)
|
---|
| 4791 | ind_opening=3;
|
---|
| 4792 | end
|
---|
| 4793 | if isfield(Data,'patch') && isequal(Data.patch,1)
|
---|
| 4794 | ind_opening=4;
|
---|
| 4795 | end
|
---|
| 4796 | if isfield(Data,'civ2') && isequal(Data.civ2,1)
|
---|
| 4797 | ind_opening=5;
|
---|
| 4798 | end
|
---|
| 4799 | if isfield(Data,'fix2') && isequal(Data.fix2,1)
|
---|
| 4800 | ind_opening=6;
|
---|
| 4801 | end
|
---|
| 4802 | end
|
---|
| 4803 | param.RootName=filebase;
|
---|
| 4804 | param.NomType=NomType;
|
---|
| 4805 | param.num1=num1;
|
---|
| 4806 | param.num2=num2;
|
---|
| 4807 | param.num_a=num_a;
|
---|
| 4808 | param.num_b=num_b;
|
---|
| 4809 | param.SubDir=SubDir;
|
---|
| 4810 | param.IndOpening=ind_opening;% A REVOIR +TRANSMETTRE IMADOC INFO
|
---|
| 4811 | param.ImaExt=ext;
|
---|
| 4812 | civ(param);% interface de civ(not in the uvmat file)
|
---|
| 4813 |
|
---|
| 4814 | %------------------------------------------------------------------------
|
---|
| 4815 | function MenuTools_Callback(hObject, eventdata, handles)
|
---|
| 4816 | %------------------------------------------------------------------------
|
---|
| 4817 |
|
---|
| 4818 | %------------------------------------------------------------------------
|
---|
| 4819 | function MenuEditObject_Callback(hObject, eventdata, handles)
|
---|
| 4820 | %------------------------------------------------------------------------
|
---|
| 4821 | set(handles.edit_object,'Value',1)
|
---|
| 4822 | edit_Callback(hObject, eventdata, handles)
|
---|
| 4823 |
|
---|
| 4824 | %------------------------------------------------------------------------
|
---|
| 4825 | function enable_transform(handles,state)
|
---|
| 4826 | %------------------------------------------------------------------------
|
---|
| 4827 | set(handles.transform_fct,'Visible',state)
|
---|
| 4828 | set(handles.TRANSFORM_txt,'Visible',state)
|
---|
| 4829 | set(handles.transform_fct,'Visible',state)
|
---|
| 4830 | set(handles.path_transform,'Visible',state)
|
---|
| 4831 | set(handles.pxcmx_txt,'Visible',state)
|
---|
| 4832 | set(handles.pxcmy_txt,'Visible',state)
|
---|
| 4833 | set(handles.pxcm,'Visible',state)
|
---|
| 4834 | set(handles.pycm,'Visible',state)
|
---|
| 4835 |
|
---|
| 4836 | %------------------------------------------------------------------------
|
---|
| 4837 | function MenuEditVectors_Callback(hObject, eventdata, handles)
|
---|
| 4838 | %------------------------------------------------------------------------
|
---|
| 4839 | set(handles.edit_vect,'Visible','on')
|
---|
| 4840 | set(handles.edit_vect,'Value',1)
|
---|
| 4841 | edit_vect_Callback(hObject, eventdata, handles)
|
---|
| 4842 |
|
---|
| 4843 | % -----------------------------------------------------------------------
|
---|
| 4844 | function Menupoints_Callback(hObject, eventdata, handles)
|
---|
| 4845 | %------------------------------------------------------------------------
|
---|
| 4846 | data.Style='points';
|
---|
| 4847 | data.ProjMode='projection';%default
|
---|
| 4848 | create_object(data,handles)
|
---|
| 4849 |
|
---|
| 4850 | % -----------------------------------------------------------------------
|
---|
| 4851 | function Menuline_Callback(hObject, eventdata, handles)
|
---|
| 4852 | %------------------------------------------------------------------------
|
---|
| 4853 | data.Style='line';
|
---|
| 4854 | data.ProjMode='projection';%default
|
---|
| 4855 | create_object(data,handles)
|
---|
| 4856 |
|
---|
| 4857 | %------------------------------------------------------------------------
|
---|
| 4858 | function Menupolyline_Callback(hObject, eventdata, handles)
|
---|
| 4859 | %------------------------------------------------------------------------
|
---|
| 4860 | data.Style='polyline';
|
---|
| 4861 | data.ProjMode='projection';%default
|
---|
| 4862 | create_object(data,handles)
|
---|
| 4863 |
|
---|
| 4864 | %------------------------------------------------------------------------
|
---|
| 4865 | function Menupolygon_Callback(hObject, eventdata, handles)
|
---|
| 4866 | %------------------------------------------------------------------------
|
---|
| 4867 | data.Style='polygon';
|
---|
| 4868 | data.ProjMode='inside';%default
|
---|
| 4869 | create_object(data,handles)
|
---|
| 4870 |
|
---|
| 4871 | %------------------------------------------------------------------------
|
---|
| 4872 | function Menurectangle_Callback(hObject, eventdata, handles)
|
---|
| 4873 | %------------------------------------------------------------------------
|
---|
| 4874 | data.Style='rectangle';
|
---|
| 4875 | data.ProjMode='inside';%default
|
---|
| 4876 | create_object(data,handles)
|
---|
| 4877 |
|
---|
| 4878 | %------------------------------------------------------------------------
|
---|
| 4879 | function Menuellipse_Callback(hObject, eventdata, handles)
|
---|
| 4880 | %------------------------------------------------------------------------
|
---|
| 4881 | data.Style='ellipse';
|
---|
| 4882 | data.ProjMode='inside';%default
|
---|
| 4883 | create_object(data,handles)
|
---|
| 4884 |
|
---|
| 4885 | %------------------------------------------------------------------------
|
---|
| 4886 | function MenuMaskObject_Callback(hObject, eventdata, handles)
|
---|
| 4887 | %------------------------------------------------------------------------
|
---|
| 4888 | data.Style='polygon';
|
---|
| 4889 | data.StyleMenu={'polygon'};
|
---|
| 4890 | data.ProjMode='mask_inside';%default
|
---|
| 4891 | data.ProjMenu={'mask_inside';'mask_outside'};
|
---|
| 4892 | create_object(data,handles)
|
---|
| 4893 |
|
---|
| 4894 | %------------------------------------------------------------------------
|
---|
| 4895 | function Menuplane_Callback(hObject, eventdata, handles)
|
---|
| 4896 | %------------------------------------------------------------------------
|
---|
| 4897 | data.Style='plane';
|
---|
| 4898 | data.ProjMode='projection';%default
|
---|
| 4899 |
|
---|
| 4900 | create_object(data,handles)
|
---|
| 4901 |
|
---|
| 4902 | %------------------------------------------------------------------------
|
---|
| 4903 | function Menuvolume_Callback(hObject, eventdata, handles)
|
---|
| 4904 | %------------------------------------------------------------------------
|
---|
| 4905 | data.Style='volume';
|
---|
| 4906 | data.ProjMode='interp';%default
|
---|
| 4907 | % set(handles.create,'Visible','on')
|
---|
| 4908 | % set(handles.create,'Value',1)
|
---|
| 4909 | % VOLUME_Callback(hObject,eventdata,handles)
|
---|
| 4910 | create_object(data,handles)
|
---|
| 4911 |
|
---|
| 4912 | %------------------------------------------------------------------------
|
---|
| 4913 | function MenuBrowseObject_Callback(hObject, eventdata, handles)
|
---|
| 4914 | %------------------------------------------------------------------------
|
---|
| 4915 | %get the object file
|
---|
| 4916 | [FileName, PathName, filterindex] = uigetfile( ...
|
---|
| 4917 | {'*.xml;*.mat', ' (*.xml,*.mat)';
|
---|
| 4918 | '*.xml', '.xml files '; ...
|
---|
| 4919 | '*.mat', '.mat matlab files '}, ...
|
---|
| 4920 | 'Pick an xml Object file',get(handles.RootPath,'String'));
|
---|
| 4921 | fileinput=[PathName FileName];%complete file name
|
---|
| 4922 | % testblank=findstr(fileinput,' ');%look for blanks
|
---|
| 4923 | % if ~isempty(testblank)
|
---|
| 4924 | % msgbox_uvmat('ERROR','forbidden input file name: contain blanks')
|
---|
| 4925 | % return
|
---|
| 4926 | % end
|
---|
| 4927 | sizf=size(fileinput);
|
---|
| 4928 | if (~ischar(fileinput)||~isequal(sizf(1),1)),return;end
|
---|
| 4929 |
|
---|
| 4930 | %read the file
|
---|
| 4931 | t=xmltree(fileinput);
|
---|
| 4932 | data=convert(t);
|
---|
| 4933 | data.enable_plot=1;
|
---|
| 4934 | [pp,data.Name]=fileparts(FileName);
|
---|
| 4935 | %PlotHandles=get_plot_handles(handles);%get the handles of the interface elements setting the plotting parameters
|
---|
| 4936 | hset_object=findobj(allchild(0),'tag','set_object');
|
---|
| 4937 | if ~isempty(hset_object)
|
---|
| 4938 | delete(hset_object)% delete existing version of set_object
|
---|
| 4939 | end
|
---|
| 4940 | % UvData=get(handles.uvmat,'UserData');
|
---|
| 4941 | set_object(data);% call the set_object interface
|
---|
| 4942 | % %position the set_object GUI with respect to uvmat
|
---|
| 4943 | % pos_uvmat=get(handles.uvmat,'Position');
|
---|
| 4944 | % if isfield(UvData,'SetObjectOrigin')
|
---|
| 4945 | % pos_set_object(1:2)=UvData.SetObjectOrigin + pos_uvmat(1:2);
|
---|
| 4946 | % pos_set_object(3:4)=UvData.SetObjectSize .* pos_uvmat(3:4);
|
---|
| 4947 | % set(hset_object,'Position',pos_set_object)
|
---|
| 4948 | % end
|
---|
| 4949 | set(handles.edit_object,'Value',0); %suppress the object edit mode
|
---|
| 4950 | set(handles.edit_object,'BackgroundColor',[0.7,0.7,0.7])
|
---|
| 4951 | set(handles.MenuObject,'checked','on')
|
---|
| 4952 | %UvData.MouseAction='create_object';
|
---|
| 4953 | % set(handles.uvmat,'UserData',UvData)
|
---|
| 4954 | set(handles.delete_object,'Visible','on')
|
---|
| 4955 | set(handles.uvmat_title,'Visible','on')
|
---|
| 4956 | set(handles.view_field_title,'Visible','on')
|
---|
| 4957 |
|
---|
| 4958 | %------------------------------------------------------------------------
|
---|
| 4959 | % --- generic function used for the creation of a projection object
|
---|
| 4960 | function create_object(data,handles)
|
---|
| 4961 | %------------------------------------------------------------------------
|
---|
| 4962 | hset_object=findobj(allchild(0),'tag','set_object');
|
---|
| 4963 | if ~isempty(hset_object)
|
---|
| 4964 | delete(hset_object)% delete existing version of set_object
|
---|
| 4965 | end
|
---|
| 4966 | hgeometry_calib=findobj(allchild(0),'tag','geometry_calib');
|
---|
| 4967 | if ishandle(hgeometry_calib)
|
---|
| 4968 | hhgeometry_calib=guidata(hgeometry_calib);
|
---|
| 4969 | set(hhgeometry_calib.edit_append,'Value',0)% desactivate mouse action in geometry_calib
|
---|
| 4970 | set(hhgeometry_calib.edit_append,'BackgroundColor',[0.7 0.7 0.7])
|
---|
| 4971 | end
|
---|
| 4972 | UvData=get(handles.uvmat,'UserData');
|
---|
| 4973 | set(handles.edit_object,'Value',0); %suppress the object edit mode
|
---|
| 4974 | set(handles.edit_object,'BackgroundColor',[0.7,0.7,0.7])
|
---|
| 4975 | data.enable_plot=1;
|
---|
| 4976 | transform_list=get(handles.transform_fct,'String');
|
---|
| 4977 | val=get(handles.transform_fct,'Value');
|
---|
| 4978 | %data.CoordType=transform_list{val};
|
---|
| 4979 | if isfield(UvData,'Field')
|
---|
| 4980 | Field=UvData.Field;
|
---|
| 4981 | if isfield(Field,'Mesh')&&~isempty(Field.Mesh)
|
---|
| 4982 | data.RangeX=Field.Mesh;
|
---|
| 4983 | data.RangeY=Field.Mesh;
|
---|
| 4984 | data.DX=Field.Mesh;
|
---|
| 4985 | data.DY=Field.Mesh;
|
---|
| 4986 | elseif isfield(Field,'AX')&& isfield(Field,'AY')&& isfield(Field,'A')%only image
|
---|
| 4987 | np=size(Field.A);
|
---|
| 4988 | meshx=(Field.AX(end)-Field.AX(1))/np(2);
|
---|
| 4989 | meshy=abs(Field.AY(end)-Field.AY(1))/np(1);
|
---|
| 4990 | data.RangeY=max(meshx,meshy);
|
---|
| 4991 | data.RangeX=max(meshx,meshy);
|
---|
| 4992 | data.DX=max(meshx,meshy);
|
---|
| 4993 | end
|
---|
| 4994 | if isfield(Field,'NbDim')
|
---|
| 4995 | data.NbDim=Field.NbDim;
|
---|
| 4996 | end
|
---|
| 4997 | if isfield(Field,'CoordUnit')
|
---|
| 4998 | data.CoordUnit=Field.CoordUnit;
|
---|
| 4999 | end
|
---|
| 5000 | end
|
---|
| 5001 | data.Coord=[0 0 0]; %default
|
---|
| 5002 | if isfield(data,'Style') && isequal(data.Style,'line')
|
---|
| 5003 | if isfield(data,'DX')
|
---|
| 5004 | data.Coord=[[0 0 0];[data.DX 0 0]]; %default
|
---|
| 5005 | else
|
---|
| 5006 | data.Coord=[[0 0 0];[1 0 0]]; %default
|
---|
| 5007 | end
|
---|
| 5008 | end
|
---|
| 5009 | if ishandle(handles.UVMAT_title)
|
---|
| 5010 | delete(handles.UVMAT_title)%delete the initial display of uvmat if no field has been entered
|
---|
| 5011 | end
|
---|
| 5012 | %PlotHandles=get_plot_handles(handles);%get the handles of the interface elements setting the plotting parameters
|
---|
| 5013 | set_object(data,handles);% call the set_object interface
|
---|
| 5014 | set(handles.MenuObject,'checked','on')
|
---|
| 5015 | set(handles.uvmat,'UserData',UvData)
|
---|
| 5016 | set(handles.zoom,'Value',0)
|
---|
| 5017 | zoom_Callback(handles.uvmat, [], handles)
|
---|
| 5018 | set(handles.delete_object,'Visible','on')
|
---|
| 5019 | set(handles.uvmat_title,'Visible','on')
|
---|
| 5020 | set(handles.view_field_title,'Visible','on')
|
---|
| 5021 |
|
---|
| 5022 | %------------------------------------------------------------------------
|
---|
| 5023 | function MenuRuler_Callback(hObject, eventdata, handles)
|
---|
| 5024 | %------------------------------------------------------------------------
|
---|
| 5025 | set(handles.zoom,'Value',0)
|
---|
| 5026 | zoom_Callback(handles.uvmat, [], handles)
|
---|
| 5027 | set(handles.MenuRuler,'checked','on')
|
---|
| 5028 | UvData=get(handles.uvmat,'UserData');
|
---|
| 5029 | UvData.MouseAction='ruler';
|
---|
| 5030 | set(handles.uvmat,'UserData',UvData);
|
---|
| 5031 |
|
---|
| 5032 | %------------------------------------------------------------------------
|
---|
| 5033 | % --- executed when closing: set the parent interface button to value 0
|
---|
| 5034 | function closefcn(gcbo,eventdata)
|
---|
| 5035 | %------------------------------------------------------------------------
|
---|
| 5036 | %delete all the associated figures if exist
|
---|
| 5037 | hh=findobj(allchild(0),'tag','view_field');
|
---|
| 5038 | if ~isempty(hh)
|
---|
| 5039 | delete(hh)
|
---|
| 5040 | end
|
---|
| 5041 | hh=findobj(allchild(0),'tag','geometry_calib');
|
---|
| 5042 | if ~isempty(hh)
|
---|
| 5043 | delete(hh)
|
---|
| 5044 | end
|
---|
| 5045 | hh=findobj(allchild(0),'tag','set_object');
|
---|
| 5046 | if ~isempty(hh)
|
---|
| 5047 | hhh=findobj(hh,'tag','PLOT');
|
---|
| 5048 | set(hhh,'enable','off')
|
---|
| 5049 | end
|
---|
| 5050 |
|
---|
| 5051 | %------------------------------------------------------------------------
|
---|
| 5052 | % --- Executes on button press in delete_object.
|
---|
| 5053 | function delete_object_Callback(hObject, eventdata, handles)
|
---|
| 5054 | %------------------------------------------------------------------------
|
---|
| 5055 | IndexObj=get(handles.list_object_2,'Value');
|
---|
| 5056 | if IndexObj>1
|
---|
| 5057 | delete_object(IndexObj)
|
---|
| 5058 | end
|
---|
| 5059 |
|
---|
| 5060 |
|
---|