[2] | 1 | %'uvmat': function associated with the GUI 'uvmat.fig' for images and data field visualization
|
---|
| 2 | %------------------------------------------------------------------------
|
---|
| 3 | % function huvmat=uvmat(input)
|
---|
| 4 | %
|
---|
| 5 | %OUTPUT
|
---|
| 6 | % huvmat=current handles of the GUI uvmat.fig
|
---|
[45] | 7 | %%
|
---|
[2] | 8 | %
|
---|
| 9 | %INPUT:
|
---|
| 10 | % input: input file name (if character chain), or input image matrix to
|
---|
| 11 | % visualize, or Matlab structure representing netcdf fields (with fields
|
---|
| 12 | % ListVarName....)
|
---|
| 13 | %
|
---|
| 14 | %AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
|
---|
[38] | 15 | % Copyright Joel Sommeria, 2008, LEGI / CNRS-UJF-INPG, joel.sommeria@legi.grenoble-inp.fr.
|
---|
[2] | 16 | %AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
|
---|
| 17 | % This open is part of the toolbox UVMAT.
|
---|
| 18 | %
|
---|
| 19 | % UVMAT is free software; you can redistribute it and/or modify
|
---|
| 20 | % it under the terms of the GNU General Public License as published by
|
---|
| 21 | % the Free Software Foundation; either version 2 of the License, or
|
---|
| 22 | % (at your option) any later version.
|
---|
| 23 | %
|
---|
| 24 | % UVMAT is distributed in the hope that it will be useful,
|
---|
| 25 | % but WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
| 26 | % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
---|
| 27 | % GNU General Public License (open UVMAT/COPYING.txt) for more details.
|
---|
| 28 | %AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
|
---|
| 29 | %
|
---|
| 30 | % Information stored on the interface:
|
---|
| 31 | % 'Strings' of all edit boxes and menus: get(handles.Tag,'String')
|
---|
| 32 | % 'Values' of all menus and toggle buttons: get(handles.Tag,'Value')
|
---|
| 33 | % Matlab structure stored as 'UserData' of the figure uvmat.fig,(can be obtained by right mouse click on the interface).
|
---|
| 34 | % It contains the following fields:
|
---|
| 35 | % - Fixed specifiacation of plotting figures and axes (defined bu uvmat_OpeningFcn)
|
---|
| 36 | % .PosColorbar: [0.8210 0.4710 0.0190 0.4450]; specified position of the colorbar on figures
|
---|
| 37 | % - Information read in the documentation open of a series (activated by RootPath_Callback) :
|
---|
| 38 | % .XmlData, with fields:
|
---|
| 39 | % .Time: matrix of times of the images with index i and j
|
---|
| 40 | % .GeometryCalib: [1x1 struct]
|
---|
| 41 | % - Information defined from the interface:
|
---|
| 42 | % .NewSeries: =1 when the first view of a new field series is displayed, else 0
|
---|
| 43 | % .filename:(char string)
|
---|
| 44 | % .VelType:(char string) type of velocity field selected
|
---|
| 45 | % .VelType_1:(char string) REMPLACER LE CELL ACTUEL
|
---|
| 46 | % .FieldName: (char string) main field selected('image', 'velocity'...)
|
---|
| 47 | % .FieldName_1:(char string) second field selected('image', 'velocity'...)
|
---|
| 48 | % .CName: (char string)name of the scalar used for vector colors
|
---|
| 49 | % .CoordType: (char string) coordinate transform: e.g. 'phys' or 'px'
|
---|
| 50 | % .MouseAction: store the current effect of mouse button (create or edit objects)
|
---|
| 51 | % - Information on projection objects
|
---|
| 52 | % .Object: {[1x1 struct]}
|
---|
| 53 | % .CurrentObjectIndex: index of the projection object .Object currently selected for editing
|
---|
| 54 | % -Information on the current field (Field{i})
|
---|
| 55 | % .Txt : text information to display (e.g. error message)
|
---|
| 56 | % .NbDim: number of dimensions (=0 by default)
|
---|
| 57 | % .NbCoord: number of vector components
|
---|
| 58 | % .CoordType: expresses the type of coordinate ('px' for image, 'sig' for instruments, or 'phys')
|
---|
| 59 | % .dt: time interval for the corresponding image pair
|
---|
| 60 | % .Mesh: estimated typical distance between vectors
|
---|
| 61 | % .ZMax:
|
---|
| 62 | % .ZMin:
|
---|
| 63 | % .X, .Y, .Z: set of vector coordinates
|
---|
| 64 | % .U,.V,.W: corresponding set of vector components
|
---|
| 65 | % .F: corresponding set of warning flags
|
---|
| 66 | % .FF: corresponding set of false flags, =0 for good vectors
|
---|
| 67 | % .C: corresponding values of the scalar used for vector color
|
---|
| 68 | % (.X, .Y, .Z,.U,.V,.W,.F,.FF,.C are matlab vectors of the same length,
|
---|
| 69 | % equal to the number of vectors stored in the input open)
|
---|
| 70 | % .CName: name of the scalar .C
|
---|
| 71 | % .CType: type of the scalar .C, setting how the scalar is obtained (see 'Scalars' below)
|
---|
| 72 | % .A image or scalar
|
---|
| 73 | % .AX: vector of dimension 2 representing the first and last values
|
---|
| 74 | % of the X coordinates for the image or scalar known on a regular grid,
|
---|
| 75 | % or vector of dimension .A for a scaler defined on irregular grid.
|
---|
| 76 | % .AY: same as .AX along the Y direction
|
---|
| 77 | % .AName: name of the scalar, ='image' for an image
|
---|
| 78 |
|
---|
| 79 | % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%% DATA FLOW (for run0_Callback) %%%%%%%%%%%%%%%%%%%%:
|
---|
| 80 | %
|
---|
| 81 | % Main input open second input open(_1) second image (pair animation)
|
---|
| 82 | % read_ncfield.m | |
|
---|
[45] | 83 | % read image.m | |
|
---|
[2] | 84 | % Field{1} Field{2}
|
---|
| 85 | % |
|
---|
| 86 | % coord transform (phys.m) or other user defined fct acting on Field{i} |
|
---|
| 87 | % Field{i}
|
---|
| 88 | % |
|
---|
| 89 | % calc_field.m: calculate scalar or other derived fields (vort, div..).
|
---|
| 90 | %
|
---|
| 91 | % sub_field.m: combine the input Field{i} in a single set of fields (vector + scalar):
|
---|
| 92 | % Field{i=1->3}.X --> UvData.X |
|
---|
| 93 | % |
|
---|
| 94 | % UvData
|
---|
| 95 | % |
|
---|
| 96 | % plot histograms of the whole field
|
---|
| 97 | % proj_field.m: project the set of fields on the current projection objects defined by UvData.Object
|
---|
| 98 | % | |
|
---|
| 99 | % ObjectData
|
---|
| 100 | % |
|
---|
| 101 | % plot_field.m: plot the projected fields and store them as user |
|
---|
| 102 | % data of the plotting axes |
|
---|
| 103 | % |
|
---|
| 104 | % AxeData
|
---|
| 105 | %
|
---|
[15] | 106 | %%%%%%%%%%%%%% SCALARS: %%%%%%%%%%%%??%%%
|
---|
[2] | 107 | % scalars are displayed either as an image or countour plot, either as a color of
|
---|
| 108 | % velocity vectors. The scalar values in the first case is represented by
|
---|
| 109 | % UvData.Field.A, and by UvData.Field.C in the second case. The corresponding set of X
|
---|
| 110 | % and Y coordinates are represented by UvData.Field.AX and UvData.Field.AY, and .X and
|
---|
| 111 | % .Y for C (the same as velocity vectors). If A is a nxxny matrix (scalar
|
---|
| 112 | % on a regtular grid), then .AX andf.AY contains only two elements, represneting the
|
---|
| 113 | % coordinates of the four image corners. The scalar name is represented by
|
---|
| 114 | % the strings .AName and/or .CName.
|
---|
| 115 | % If the scalar exists in an input open (image or scalar stored under its
|
---|
| 116 | % name in a netcdf open), it is directly read at the level of Field{1}or Field{2}.
|
---|
| 117 | % Else only its name AName is recorded in Field{i}, and its field is then calculated
|
---|
| 118 | %by the fuction calc_scal after the coordinate transform or after projection on an edit
|
---|
| 119 |
|
---|
| 120 | % Properties attached to plotting figures (standard Matlab properties):
|
---|
| 121 | % 'CurrentAxes'= gca or get(gcf,'CurrentAxes');
|
---|
| 122 | % 'CurrentPoint'=get(gcf,'CurrentPoint'): figure coordinates of the point over which the mouse is positioned
|
---|
| 123 | % 'CurrentCharacter'=get(gcf,'CurrentCharacter'): last character typed over the figure where the mouse is positioned
|
---|
| 124 | % 'WindowButtonMotionFcn': function permanently called by mouse motion over the figure
|
---|
| 125 | % 'KeyPressFcn': function called by pressing a key on the key board
|
---|
| 126 | % 'WindowButtonDownFcn': function called by pressing the mouse over the figure
|
---|
| 127 | % 'WindowButtonUpFcn': function called by releasing the mouse pressure over the figure
|
---|
| 128 |
|
---|
| 129 | % Properties attached to plotting axes:
|
---|
| 130 | % 'CurrentPoint'=get(gca,'CurrentPoint'); (standard Matlab) same as for the figure, but position in plot coordinates.
|
---|
| 131 | % AxeData:=get(gca,'UserData');
|
---|
| 132 | % AxeData.Drawing = create: create a new edit
|
---|
| 133 | % = deform: modify an existing edit by moving its defining create
|
---|
| 134 | % = off: no current drawing action
|
---|
| 135 | % = translate: translate an existing edit
|
---|
| 136 | % = zoom: isolate a subregion for zoom in=1 if an edit is being currently drawn, 0 else (set to 0 by releasing mouse button)
|
---|
| 137 | % .hset_edit=handle of the set_edit interface (if a projection edit is edited);
|
---|
| 138 | % .CurrentOrigin: Origin of a curently drawn edit
|
---|
| 139 | % .CurrentLine: currently drawn menuline (A REVOIR)
|
---|
| 140 | % .CurrentObject: handle of the currently drawn edit
|
---|
| 141 | % .CurrentRectZoom: current rectangle used for zoom
|
---|
| 142 | % .zoomon : zoom state (a revoir)
|
---|
| 143 | % .X, .Y, .Z: array of coordinates defining the position of the vector: ASSOCIER AU PLAN (OBJET) PLUTOT QU'A L'AXE ?
|
---|
| 144 | % .U, .V, .W: array of components of the vector
|
---|
| 145 | % .C:
|
---|
| 146 | % .F:
|
---|
| 147 | % .FF:
|
---|
| 148 | % .A
|
---|
| 149 |
|
---|
| 150 | % Properties attached to projection objects (create, menuline, menuplane...):
|
---|
| 151 | % 'Tag'='proj_edit': for all projection objects
|
---|
| 152 | % ObjectData.Style=...: style of projection edit:
|
---|
| 153 | % .ProjMode
|
---|
| 154 | % .Coord: defines the position of the edit
|
---|
| 155 | % .XMin,YMin....
|
---|
| 156 | % .XMax,YMax....
|
---|
| 157 | % .DX,DY,DZ
|
---|
| 158 | % .Phi, .Theta, .Psi : Euler angles
|
---|
| 159 | % .X,.Y,.U,.V.... : field data projected on the edit
|
---|
| 160 | % .IndexObj: index in the list of UvData.Object
|
---|
| 161 | %during plotting
|
---|
| 162 | % .plotaxes: handles of the current axes used to plot the result of field projection on the object
|
---|
| 163 | % .plothandle: vector of handle(s) of the object graphic represnetation in all the opened plotting axes
|
---|
| 164 | % To each projection object #iobj, corresponds an axis
|
---|
| 165 | % Object{iobj}.plotaxes and nbobj representation graphs Object{iobj}.plothandles(:) (where nbobj is the
|
---|
| 166 | % nbre of current objects opened in uvmat. Note that Object{iobj}.plothandles(iobj)=[] : an object is not represented in its own projection field;
|
---|
[89] | 167 |
|
---|
| 168 | %------------------------------------------------------------------------
|
---|
| 169 | %------------------------------------------------------------------------
|
---|
[2] | 170 | % I - MAIN FUNCTION UVMAT (DO NOT MODIFY)
|
---|
[89] | 171 | %------------------------------------------------------------------------
|
---|
| 172 | %------------------------------------------------------------------------
|
---|
[2] | 173 | function varargout = uvmat(varargin)
|
---|
| 174 |
|
---|
| 175 | % Begin initialization code - DO NOT EDIT
|
---|
| 176 | gui_Singleton = 1;
|
---|
| 177 | gui_State = struct('gui_Name', mfilename, ...
|
---|
| 178 | 'gui_Singleton', gui_Singleton, ...
|
---|
| 179 | 'gui_OpeningFcn', @uvmat_OpeningFcn, ...
|
---|
| 180 | 'gui_OutputFcn', @uvmat_OutputFcn, ...
|
---|
| 181 | 'gui_LayoutFcn', [], ...
|
---|
| 182 | 'gui_Callback', []);
|
---|
| 183 | if nargin && ischar(varargin{1})
|
---|
| 184 | gui_State.gui_Callback = str2func(varargin{1});
|
---|
| 185 | end
|
---|
| 186 |
|
---|
| 187 | if nargout
|
---|
| 188 | varargout{1:nargout} = gui_mainfcn(gui_State, varargin{:});
|
---|
| 189 | else
|
---|
| 190 | gui_mainfcn(gui_State, varargin{:});
|
---|
| 191 | end
|
---|
| 192 | % End initialization code - DO NOT EDIT
|
---|
| 193 |
|
---|
[89] | 194 | %------------------------------------------------------------------------
|
---|
[2] | 195 | % --- Executes just before uvmat is made visible.
|
---|
| 196 | function uvmat_OpeningFcn(hObject, eventdata, handles, input )
|
---|
[89] | 197 | %------------------------------------------------------------------------
|
---|
[71] | 198 | global nb_builtin
|
---|
| 199 |
|
---|
[2] | 200 | % Choose default command menuline output for uvmat
|
---|
| 201 | handles.output = hObject;
|
---|
| 202 |
|
---|
| 203 | % Update handles structure
|
---|
| 204 | guidata(hObject, handles);
|
---|
| 205 |
|
---|
| 206 | % set the position of colorbar and ancillary GUIs:
|
---|
| 207 | set(hObject,'Units','Normalized')
|
---|
| 208 | movegui(hObject,'center')
|
---|
| 209 | UvData.PosColorbar=[0.805 0.022 0.019 0.445];
|
---|
| 210 | UvData.SetObjectOrigin=[-0.05 -0.03]; %position for set_object
|
---|
| 211 | UvData.SetObjectSize=[0.3 0.7];
|
---|
| 212 | UvData.CalOrigin=[0.95 -0.03];%position for geometry_calib (TO IMPROVE)
|
---|
| 213 | UvData.CalSize=[0.28 1];
|
---|
| 214 |
|
---|
| 215 | %functions for the mouse and keyboard
|
---|
| 216 | set(handles.histo_u,'NextPlot','replacechildren');
|
---|
| 217 | set(handles.histo_v,'NextPlot','replacechildren');
|
---|
| 218 | set(hObject,'KeyPressFcn',{'keyboard_callback',handles})%set keyboard action function
|
---|
| 219 | set(hObject,'WindowButtonMotionFcn',{'mouse_motion',handles})%set mouse action functio
|
---|
| 220 | set(hObject,'WindowButtonDownFcn',{'mouse_down'})%set mouse click action function
|
---|
| 221 | set(hObject,'WindowButtonUpFcn',{'mouse_up',handles})
|
---|
[67] | 222 | set(hObject,'DeleteFcn',{@closefcn})%
|
---|
[2] | 223 |
|
---|
[89] | 224 | %refresh projection plane
|
---|
| 225 | UvData.Object{1}.Style='plane';%main plotting plane
|
---|
| 226 | UvData.Object{1}.ProjMode='projection';%main plotting plane
|
---|
| 227 | if ~isfield(UvData.Object{1},'plotaxes')
|
---|
| 228 | UvData.Object{1}.plotaxes=handles.axes3;%default plotting axis
|
---|
| 229 | set(handles.list_object_1,'Value',1);
|
---|
| 230 | set(handles.list_object_1,'String',{'1-PLANE'});
|
---|
| 231 | end
|
---|
| 232 |
|
---|
| 233 | %TRANSFORM menu: builtin fcts
|
---|
[39] | 234 | menu_str={'';'phys';'px';'phys_polar'};
|
---|
| 235 | nb_builtin=numel(menu_str); %number of functions
|
---|
[45] | 236 | path_uvmat=fileparts(which('uvmat'));
|
---|
[39] | 237 | addpath(fullfile(path_uvmat,'transform_field'))
|
---|
| 238 | fct_handle{1,1}=[];
|
---|
[60] | 239 | testexist=zeros(size(menu_str'));%default
|
---|
[39] | 240 | testexist(1)=1;
|
---|
| 241 | for ilist=2:length(menu_str)
|
---|
| 242 | if exist(menu_str{ilist},'file')
|
---|
| 243 | fct_handle{ilist,1}=str2func(menu_str{ilist});
|
---|
| 244 | testexist(ilist)=1;
|
---|
| 245 | else
|
---|
| 246 | testexist(ilist)=0;
|
---|
| 247 | end
|
---|
| 248 | end
|
---|
| 249 | rmpath(fullfile(path_uvmat,'transform_field'))
|
---|
| 250 |
|
---|
[2] | 251 | %load the list of previously browsed files in menus Open and Open_1
|
---|
[40] | 252 | dir_perso=prefdir; % path to the directory .matlab for personal data
|
---|
| 253 | profil_perso=fullfile(dir_perso,'uvmat_perso.mat');% personal data file uvmauvmat_perso.mat' in .matlab
|
---|
[2] | 254 | if exist(profil_perso,'file')
|
---|
| 255 | h=load (profil_perso);
|
---|
| 256 | if isfield(h,'MenuFile_1')
|
---|
| 257 | set(handles.MenuFile_1,'Label',h.MenuFile_1);
|
---|
| 258 | set(handles.MenuFile_1_1,'Label',h.MenuFile_1);
|
---|
| 259 | end
|
---|
| 260 | if isfield(h,'MenuFile_1')
|
---|
| 261 | set(handles.MenuFile_2,'Label',h.MenuFile_2);
|
---|
| 262 | set(handles.MenuFile_2_1,'Label',h.MenuFile_2);
|
---|
| 263 | end
|
---|
| 264 | if isfield(h,'MenuFile_1')
|
---|
| 265 | set(handles.MenuFile_3,'Label',h.MenuFile_3);
|
---|
| 266 | set(handles.MenuFile_3_1,'Label',h.MenuFile_3);
|
---|
| 267 | end
|
---|
| 268 | if isfield(h,'MenuFile_1')
|
---|
| 269 | set(handles.MenuFile_4,'Label',h.MenuFile_4);
|
---|
| 270 | set(handles.MenuFile_4_1,'Label',h.MenuFile_4);
|
---|
| 271 | end
|
---|
| 272 | if isfield(h,'MenuFile_1')
|
---|
| 273 | set(handles.MenuFile_5,'Label',h.MenuFile_5);
|
---|
| 274 | set(handles.MenuFile_5_1,'Label',h.MenuFile_5);
|
---|
[39] | 275 | end
|
---|
| 276 | if isfield(h,'transform_fct') && iscell(h.transform_fct)
|
---|
| 277 | for ilist=1:length(h.transform_fct);
|
---|
| 278 | [path,file]=fileparts(h.transform_fct{ilist});
|
---|
| 279 | addpath(path)
|
---|
| 280 | if exist(file,'file')
|
---|
| 281 | h_func=str2func(file);
|
---|
[89] | 282 | testexist=[testexist 1];
|
---|
[39] | 283 | else
|
---|
| 284 | h_func=[];
|
---|
[89] | 285 | testexist=[testexist 0];
|
---|
[39] | 286 | end
|
---|
[89] | 287 | fct_handle=[fct_handle; {h_func}]; %concatene the list of paths
|
---|
[39] | 288 | rmpath(path)
|
---|
[89] | 289 | menu_str=[menu_str; {file}];
|
---|
[39] | 290 | end
|
---|
| 291 | end
|
---|
[2] | 292 | end
|
---|
[45] | 293 | menu_str=menu_str(testexist==1);%=menu_str(testexist~=0)
|
---|
| 294 | fct_handle=fct_handle(testexist==1);
|
---|
[39] | 295 | menu_str=[menu_str;{'more...'}];
|
---|
| 296 | set(handles.transform_fct,'String',menu_str)
|
---|
| 297 | set(handles.transform_fct,'UserData',fct_handle)% store the list of path in UserData of ACTION
|
---|
[2] | 298 |
|
---|
| 299 | %initiates menu of vector colors
|
---|
| 300 | list_menu=calc_field;
|
---|
| 301 | %list_menu=[{'ima_cor'};{'black'};{'white'};list_menu(3:end)];
|
---|
| 302 | set(handles.col_vec,'String',list_menu)
|
---|
| 303 |
|
---|
| 304 | %check the path and date of modification of all functions in uvmat
|
---|
| 305 | path_to_uvmat=which ('uvmat');% check the path detected for source file uvmat
|
---|
| 306 | [errormsg,date_str]=check_functions;%check the path of the functions called by uvmat.m
|
---|
[45] | 307 | date_str=['last modification: ' date_str];
|
---|
[2] | 308 | %case of an input argument for uvmat
|
---|
| 309 | testinputfield=0;
|
---|
| 310 | inputfile=[];
|
---|
| 311 | Field=[];
|
---|
| 312 | if exist('input','var')
|
---|
| 313 | if ~isempty(errormsg)
|
---|
[38] | 314 | msgbox_uvmat('WARNING',errormsg)
|
---|
[2] | 315 | end
|
---|
| 316 | if ishandle(handles.UVMAT_title)
|
---|
| 317 | delete(handles.UVMAT_title)
|
---|
| 318 | end
|
---|
| 319 | if isstruct(input)
|
---|
| 320 | if isfield(input,'InputFile')
|
---|
| 321 | inputfile=input.InputFile;
|
---|
| 322 | end
|
---|
| 323 | Field=input;
|
---|
| 324 | elseif ischar(input)% file name introduced as input
|
---|
| 325 | inputfile=input;
|
---|
[59] | 326 | elseif isnumeric(input)%simple matrix introduced as input
|
---|
[2] | 327 | sizinput=size(input);
|
---|
| 328 | if sizinput(1)<=1 || sizinput(2)<=1
|
---|
[38] | 329 | msgbox_uvmat('ERROR','bad input for uvmat: file name, structure or numerical matrix accepted')
|
---|
[2] | 330 | return
|
---|
| 331 | end
|
---|
[59] | 332 | Field.ListVarName={'A','coord_y','coord_x'};
|
---|
| 333 | Field.VarDimName={{'coord_y','coord_x'},'cord_y','coord_x'};
|
---|
[2] | 334 | Field.A=input;
|
---|
[59] | 335 | Field.coord_x=[0.5 size(input,2)-0.5];
|
---|
| 336 | Field.coord_y=[size(input,1)-0.5 0.5];
|
---|
[2] | 337 | end
|
---|
| 338 | if ~isempty(inputfile)
|
---|
| 339 | display_file_name(hObject, eventdata, handles,inputfile)
|
---|
| 340 | testinputfield=1;
|
---|
| 341 | else
|
---|
| 342 | UvData.TestInputFile=0;
|
---|
| 343 | end
|
---|
| 344 | if ~isempty(Field)
|
---|
| 345 | set(handles.Fields,'Value',1)
|
---|
[39] | 346 | set(handles.Fields,'String',{'get_field...'})
|
---|
[2] | 347 | testinputfield=1;
|
---|
| 348 |
|
---|
| 349 | % set the colorbar position on the interface:
|
---|
| 350 | UvData.PosColorbar=[0.805 0.022 0.019 0.445];
|
---|
| 351 | elseif ischar(input)
|
---|
| 352 | scan_i_Callback(handles.scan_i, eventdata, handles);
|
---|
| 353 | end
|
---|
| 354 | else
|
---|
| 355 | if ishandle(handles.UVMAT_title)
|
---|
[34] | 356 | fid=fopen('revision.log');
|
---|
[33] | 357 | if fid~=-1
|
---|
[30] | 358 | a=textscan(fid,'%s%s%s',1,'HeaderLines',1,'Delimiter','|');
|
---|
[45] | 359 | set(handles.UVMAT_title,'String',[{'Copyright Joel Sommeria, 2008, Coriolis/ LEGI / CNRS-UJF-INPG';'GNU General Public License'; path_to_uvmat; ['at revision ' a{1}{1}]};a{3}{1};date_str;errormsg]);
|
---|
[30] | 360 | fclose(fid);
|
---|
| 361 | else
|
---|
[31] | 362 | set(handles.UVMAT_title,'String',[{'Copyright Joel Sommeria, 2008, Coriolis/ LEGI / CNRS-UJF-INPG';'GNU General Public License'; path_to_uvmat;date_str};errormsg]);
|
---|
[30] | 363 | end
|
---|
[2] | 364 | end
|
---|
| 365 | end
|
---|
| 366 | UvData.NewSeries=1;
|
---|
| 367 | set(hObject,'UserData',UvData)
|
---|
| 368 | if testinputfield
|
---|
| 369 | %delete drawn objects
|
---|
| 370 | hother=findobj(handles.axes3,'Tag','proj_object');%find all the proj objects
|
---|
| 371 | for iobj=1:length(hother)
|
---|
| 372 | delete_object(hother(iobj))
|
---|
| 373 | end
|
---|
| 374 | if isempty(inputfile)
|
---|
[59] | 375 | errormsg=refresh_field(handles,[],[],[],[],[],[],{Field});
|
---|
[2] | 376 | set(handles.MenuTools,'Enable','on')
|
---|
| 377 | set(handles.OBJECT_txt,'Visible','on')
|
---|
| 378 | set(handles.edit,'Visible','on')
|
---|
[61] | 379 | set(handles.list_object_1,'Visible','on')
|
---|
[2] | 380 | set(handles.frame_object,'Visible','on')
|
---|
[71] | 381 | if ~isempty(errormsg)
|
---|
| 382 | msgbox_uvmat('ERROR',errormsg)
|
---|
| 383 | end
|
---|
[2] | 384 | else
|
---|
| 385 | update_rootinfo(hObject,eventdata,handles);
|
---|
| 386 | end
|
---|
| 387 | end
|
---|
[40] | 388 | set_vec_col_bar(handles) %update the display of color code for vectors
|
---|
[38] | 389 |
|
---|
[2] | 390 | %-------------------------------------------------------------------
|
---|
| 391 | % --- Outputs from this function are returned to the command menuline.
|
---|
| 392 | function varargout = uvmat_OutputFcn(hObject, eventdata, handles)
|
---|
| 393 | varargout{1} = handles.output;% the only output argument is the handle to the GUI figure
|
---|
| 394 |
|
---|
| 395 | %-------------------------------------------------------------------
|
---|
| 396 | %-------------------------------------------------------------------
|
---|
| 397 | % II - FUNCTIONS FOR INTRODUCING THE INPUT FILES
|
---|
| 398 | % automatically sets the global properties when the rootfile name is introduced
|
---|
| 399 | % then activate the view-field action if selected
|
---|
| 400 | % it is activated either by clicking on the RootPath window or by the
|
---|
| 401 | % browser
|
---|
| 402 | %------------------------------------------------------------------
|
---|
| 403 | %------------------------------------------------------------------
|
---|
| 404 |
|
---|
| 405 | % --- Executes on the menu Open/Browse...
|
---|
| 406 | % search the files, recognize their type according to their name and fill the rootfile input windows
|
---|
| 407 | function MenuBrowse_Callback(hObject, eventdata, handles)
|
---|
| 408 | oldfile=read_file_boxes(handles);
|
---|
| 409 |
|
---|
| 410 | if isempty(oldfile)||isequal(oldfile,'') %loads the previously stored file name and set it as default in the file_input box
|
---|
| 411 | dir_perso=prefdir;
|
---|
| 412 | profil_perso=fullfile(dir_perso,'uvmat_perso.mat');
|
---|
| 413 | if exist(profil_perso,'file')
|
---|
| 414 | h=load (profil_perso);
|
---|
| 415 | if isfield(h,'MenuFile_1')
|
---|
| 416 | oldfile=h.MenuFile_1;
|
---|
| 417 | end
|
---|
| 418 | end
|
---|
| 419 | end
|
---|
| 420 | [FileName, PathName] = uigetfile( ...
|
---|
[73] | 421 | {'*.xml;*.xls;*.civ;*.png;*.jpg;*.tif;*.avi;*.AVI;*.vol;*.nc;*.cmx;*.fig;*.log;*.dat;*.bat;', ' (*.xml,*.xls,*.civ,*.jpg ,*.png, .tif, *.avi,*.vol,*.nc,*.cmx ,*.fig,*.log,*.dat,*.bat)';
|
---|
[2] | 422 | '*.xml', '.xml files '; ...
|
---|
| 423 | '*.xls', '.xls files '; ...
|
---|
| 424 | '*.civ', '.civ files '; ...
|
---|
| 425 | '*.jpg',' jpeg image files'; ...
|
---|
| 426 | '*.png','.png image files'; ...
|
---|
| 427 | '*.tif','.tif image files'; ...
|
---|
| 428 | '*.avi;*.AVI','.avi movie files'; ...
|
---|
[73] | 429 | '*.vol','.volume images (png)'; ...
|
---|
[2] | 430 | '*.nc','.netcdf files'; ...
|
---|
| 431 | '*.cdf','.netcdf files'; ...
|
---|
| 432 | '*.cmx','.cmx text files';...
|
---|
| 433 | '*.cmx2','.cmx2 text files';...
|
---|
| 434 | '*.fig','.fig files (matlab fig)';...
|
---|
| 435 | '*.log','.log text files ';...
|
---|
| 436 | '*.dat','.dat text files ';...
|
---|
[73] | 437 | '*.bat','.bat system command text files';...
|
---|
[2] | 438 | '*.*', 'All Files (*.*)'}, ...
|
---|
| 439 | 'Pick a file',oldfile);
|
---|
| 440 | %global filebase
|
---|
| 441 | fileinput=[PathName FileName];%complete file name
|
---|
| 442 | testblank=findstr(fileinput,' ');%look for blanks
|
---|
| 443 | if ~isempty(testblank)
|
---|
[38] | 444 | msgbox_uvmat('ERROR',['The input file name ' fileinput ' contains blank character : This is not allowed. Please change name'])
|
---|
[2] | 445 | return
|
---|
| 446 | end
|
---|
| 447 | sizf=size(fileinput);
|
---|
| 448 | if (~ischar(fileinput)||~isequal(sizf(1),1)),return;end
|
---|
| 449 |
|
---|
| 450 | % display the selected field and related information
|
---|
| 451 | display_file_name(hObject, eventdata, handles,fileinput)
|
---|
| 452 |
|
---|
| 453 | %update list of recent files in the menubar
|
---|
| 454 | MenuFile_1=fileinput;
|
---|
| 455 | MenuFile_2=get(handles.MenuFile_1,'Label');
|
---|
| 456 | MenuFile_3=get(handles.MenuFile_2,'Label');
|
---|
| 457 | MenuFile_4=get(handles.MenuFile_3,'Label');
|
---|
| 458 | MenuFile_5=get(handles.MenuFile_4,'Label');
|
---|
| 459 | set(handles.MenuFile_1,'Label',MenuFile_1)
|
---|
| 460 | set(handles.MenuFile_2,'Label',MenuFile_2)
|
---|
| 461 | set(handles.MenuFile_3,'Label',MenuFile_3)
|
---|
| 462 | set(handles.MenuFile_4,'Label',MenuFile_4)
|
---|
| 463 | set(handles.MenuFile_5,'Label',MenuFile_5)
|
---|
| 464 | set(handles.MenuFile_1_1,'Label',MenuFile_1)
|
---|
| 465 | set(handles.MenuFile_2_1,'Label',MenuFile_2)
|
---|
| 466 | set(handles.MenuFile_3_1,'Label',MenuFile_3)
|
---|
| 467 | set(handles.MenuFile_4_1,'Label',MenuFile_4)
|
---|
| 468 | set(handles.MenuFile_5_1,'Label',MenuFile_5)
|
---|
| 469 | dir_perso=prefdir;
|
---|
| 470 | profil_perso=fullfile(dir_perso,'uvmat_perso.mat');
|
---|
| 471 | if exist(profil_perso,'file')
|
---|
| 472 | save (profil_perso,'MenuFile_1','MenuFile_2','MenuFile_3','MenuFile_4', 'MenuFile_5','-append'); %store the file names for future opening of uvmat
|
---|
| 473 | else
|
---|
| 474 | txt=ver;
|
---|
| 475 | Release=txt(1).Release;
|
---|
| 476 | relnumb=str2double(Release(3:4));
|
---|
| 477 | if relnumb >= 14
|
---|
| 478 | save (profil_perso,'MenuFile_1','MenuFile_2','MenuFile_3','MenuFile_4', 'MenuFile_5','-V6'); %store the file names for future opening of uvmat
|
---|
| 479 | else
|
---|
| 480 | save (profil_perso,'MenuFile_1','MenuFile_2','MenuFile_3','MenuFile_4', 'MenuFile_5'); %store the file names for future opening of uvmat
|
---|
| 481 | end
|
---|
| 482 | end
|
---|
| 483 |
|
---|
| 484 | % --------------------------------------------------------------------
|
---|
| 485 | function MenuFile_1_Callback(hObject, eventdata, handles)
|
---|
| 486 | fileinput=get(handles.MenuFile_1,'Label');
|
---|
| 487 | display_file_name(hObject, eventdata, handles,fileinput)
|
---|
| 488 |
|
---|
| 489 | % --------------------------------------------------------------------
|
---|
| 490 | function MenuFile_2_Callback(hObject, eventdata, handles)
|
---|
| 491 | fileinput=get(handles.MenuFile_2,'Label');
|
---|
| 492 | display_file_name(hObject, eventdata, handles,fileinput)
|
---|
| 493 |
|
---|
| 494 | % --------------------------------------------------------------------
|
---|
| 495 | function MenuFile_3_Callback(hObject, eventdata, handles)
|
---|
| 496 | fileinput=get(handles.MenuFile_3,'Label');
|
---|
| 497 | display_file_name(hObject, eventdata, handles,fileinput)
|
---|
| 498 |
|
---|
| 499 | % --------------------------------------------------------------------
|
---|
| 500 | function MenuFile_4_Callback(hObject, eventdata, handles)
|
---|
| 501 | fileinput=get(handles.MenuFile_4,'Label');
|
---|
| 502 | display_file_name(hObject, eventdata, handles,fileinput)
|
---|
| 503 |
|
---|
| 504 | % --------------------------------------------------------------------
|
---|
| 505 | function MenuFile_5_Callback(hObject, eventdata, handles)
|
---|
| 506 | fileinput=get(handles.MenuFile_5,'Label');
|
---|
| 507 | display_file_name(hObject, eventdata, handles,fileinput)
|
---|
| 508 |
|
---|
| 509 | %-----------------------------------------------------------------
|
---|
| 510 | % fills the edit boxes RootPath, RootFile,NomType...from an input file name 'fileinput'
|
---|
| 511 | %----------------------------------------------------------------
|
---|
| 512 | function display_file_name(hObject, eventdata, handles,fileinput)
|
---|
[29] | 513 | if ~exist(fileinput,'file')
|
---|
| 514 | msgbox_uvmat('ERROR',['input file ' fileinput ' does not exist'])
|
---|
| 515 | return
|
---|
| 516 | end
|
---|
[2] | 517 | [RootPath,RootFile,i1,i2,str_a,str_b,ext,NomType,SubDir]=name2display(fileinput);
|
---|
[29] | 518 | ext_test=''; %default
|
---|
| 519 | if ~isempty(ext)
|
---|
| 520 | form=imformats(ext(2:end));%test valid Matlab image formats
|
---|
| 521 | if ~isempty(form)
|
---|
| 522 | ext_test='.image';
|
---|
| 523 | imainfo=imfinfo(fileinput);
|
---|
| 524 | if length(imainfo) >1 %case of image with multiple frames
|
---|
| 525 | i1='1'; % set the frame counter to 1 by default
|
---|
| 526 | i2='';
|
---|
| 527 | str_a='';
|
---|
| 528 | str_b='';
|
---|
| 529 | NomType='*'; %indicate a set of indexed frames within a single file
|
---|
| 530 | [RootPath,RootFile]=fileparts(fileinput); %include the indices in the root file
|
---|
| 531 | end
|
---|
| 532 | elseif isequal(lower(ext),'.avi')
|
---|
| 533 | ext_test='.image';
|
---|
[2] | 534 | i1='1'; % set the frame counter to 1 by default
|
---|
| 535 | i2='';
|
---|
| 536 | str_a='';
|
---|
| 537 | str_b='';
|
---|
| 538 | NomType='*'; %indicate a set of indexed frames within a single file
|
---|
| 539 | [RootPath,RootFile]=fileparts(fileinput); %include the indices in the root file
|
---|
[29] | 540 | else
|
---|
| 541 | ext_test=lower(ext);
|
---|
[2] | 542 | end
|
---|
| 543 | end
|
---|
| 544 | switch ext_test
|
---|
[73] | 545 | case {'.civ','.log','.cmx','.cmx2','.txt','.bat'} %display text file
|
---|
[2] | 546 | edit(fileinput)
|
---|
| 547 | case '.fig' %display matlab figure
|
---|
| 548 | hfig=open(fileinput);
|
---|
| 549 | set(hfig,'WindowButtonMotionFcn','mouse_motion')%set mouse action functio
|
---|
| 550 | set(hfig,'WindowButtonUpFcn','mouse_up')%set mouse click action function
|
---|
| 551 | set(hfig,'WindowButtonUpFcn','mouse_down')%set mouse click action function
|
---|
| 552 | case {'.xml','.xls'} % edit xml or Excel files
|
---|
| 553 | editxml(fileinput);
|
---|
| 554 | case {'.avi','.image','.vol','.nc','.cdf'}
|
---|
| 555 | set(handles.RootPath,'String',RootPath);
|
---|
| 556 | if isequal(SubDir,'')
|
---|
| 557 | rootname=fullfile(RootPath,RootFile);
|
---|
| 558 | else
|
---|
| 559 | rootname=fullfile(RootPath,SubDir,RootFile);
|
---|
| 560 | SubDir=['/' SubDir]; %display the separator
|
---|
| 561 | end
|
---|
| 562 | set(handles.SubDir,'String',SubDir);
|
---|
| 563 | set(handles.RootFile,'String',['/' RootFile]); %display the separator
|
---|
| 564 | indices=fileinput(length(rootname)+1:end);
|
---|
| 565 | indices(end-length(ext)+1:end)=[]; %remove extension
|
---|
| 566 | set(handles.FileIndex,'String',indices);
|
---|
| 567 | set(handles.FileIndex,'UserData',NomType);
|
---|
| 568 | set(handles.FileExt,'String',ext);
|
---|
| 569 | % fill file index counters
|
---|
[71] | 570 | set(handles.i1,'String',i1);
|
---|
[2] | 571 | set(handles.i2,'String',i2);
|
---|
| 572 | set(handles.j1,'String',str_a);
|
---|
| 573 | set(handles.j2,'String',str_b);
|
---|
| 574 |
|
---|
| 575 | % synchronise indices of the second input file if it exists
|
---|
| 576 | if get(handles.SubField,'Value')==1% if the subfield button is activated, update the field numbers
|
---|
[71] | 577 | [ff,rr,FileBase_1,ii,FileExt_1,SubDir_1]=read_file_boxes_1(handles);
|
---|
[2] | 578 | NomType_1=get(handles.FileIndex_1,'UserData');
|
---|
[89] | 579 | FileName_1=name_generator(FileBase_1,str2double(i1),str2double(i2),FileExt_1,NomType_1,1,stra2num(str_a),stra2num(str_b),SubDir_1);
|
---|
[71] | 580 | if exist(FileName_1,'file')
|
---|
[89] | 581 | FileIndex_1=name_generator('',str2double(i1),str2double(i2),'',NomType_1,1,stra2num(str_a),stra2num(str_b),'');
|
---|
[2] | 582 | set(handles.FileIndex_1,'String',FileIndex_1)
|
---|
| 583 | else
|
---|
| 584 | set(handles.SubField,'Value',0)
|
---|
| 585 | SubField_Callback(hObject, eventdata, handles)
|
---|
| 586 | end
|
---|
| 587 | end
|
---|
| 588 |
|
---|
| 589 | %enable other menus
|
---|
| 590 | set(handles.MenuOpen_1,'Enable','on')
|
---|
| 591 | set(handles.MenuFile_1_1,'Enable','on')
|
---|
| 592 | set(handles.MenuFile_2_1,'Enable','on')
|
---|
| 593 | set(handles.MenuFile_3_1,'Enable','on')
|
---|
| 594 | set(handles.MenuFile_4_1,'Enable','on')
|
---|
| 595 | set(handles.MenuFile_5_1,'Enable','on')
|
---|
| 596 | set(handles.MenuExport,'Enable','on')
|
---|
| 597 | set(handles.MenuExportFigure,'Enable','on')
|
---|
| 598 | set(handles.MenuExportMovie,'Enable','on')
|
---|
| 599 | set(handles.MenuTools,'Enable','on')
|
---|
| 600 | set(handles.OBJECT_txt,'Visible','on')
|
---|
| 601 | set(handles.edit,'Visible','on')
|
---|
[61] | 602 | set(handles.list_object_1,'Visible','on')
|
---|
[2] | 603 | set(handles.frame_object,'Visible','on')
|
---|
| 604 | % initiate input file:
|
---|
| 605 | update_rootinfo(hObject,eventdata,handles);
|
---|
| 606 | otherwise
|
---|
| 607 | msgbox_uvmat('ERROR',['invalid input file extension' ext])
|
---|
| 608 | end
|
---|
| 609 |
|
---|
[89] | 610 | %------------------------------------------------------------------------
|
---|
[2] | 611 | function RootPath_Callback(hObject,eventdata,handles)
|
---|
[89] | 612 | %------------------------------------------------------------------------
|
---|
[2] | 613 | update_rootinfo(hObject,eventdata,handles);
|
---|
| 614 |
|
---|
[89] | 615 | %------------------------------------------------------------------------
|
---|
[2] | 616 | %-- called by action in RootFile edit box
|
---|
| 617 | function SubDir_Callback(hObject, eventdata, handles)
|
---|
[89] | 618 | %------------------------------------------------------------------------
|
---|
[2] | 619 | %refresh the menu of input fields
|
---|
| 620 | Fields_Callback(hObject, eventdata, handles);
|
---|
| 621 | % refresh the current field
|
---|
| 622 | run0_Callback(hObject, eventdata, handles);
|
---|
| 623 |
|
---|
[89] | 624 | %------------------------------------------------------------------------
|
---|
| 625 | % --- called by action in RootFile edit box
|
---|
[2] | 626 | function RootFile_Callback(hObject, eventdata, handles)
|
---|
[89] | 627 | %------------------------------------------------------------------------
|
---|
[2] | 628 | update_rootinfo(hObject,eventdata,handles)
|
---|
| 629 |
|
---|
[89] | 630 | %------------------------------------------------------------------------
|
---|
| 631 | % --- called by action in FileIndex edit box
|
---|
[81] | 632 | function FileIndex_Callback(hObject, eventdata, handles)
|
---|
[89] | 633 | %------------------------------------------------------------------------
|
---|
[81] | 634 | FileIndices=get(handles.FileIndex,'String');
|
---|
| 635 | if isempty(str2num(FileIndices))
|
---|
| 636 | [pp,ff,str1,str2,str_a,str_b]=name2display(FileIndices);
|
---|
| 637 | else
|
---|
| 638 | str1=FileIndices;
|
---|
| 639 | str2='';
|
---|
| 640 | str_a='';
|
---|
| 641 | str_b='';
|
---|
| 642 | end
|
---|
| 643 | set(handles.i1,'String',str1);
|
---|
| 644 | set(handles.i2,'String',str2);
|
---|
| 645 | set(handles.j1,'String',str_a);
|
---|
| 646 | set(handles.j2,'String',str_b);
|
---|
| 647 | run0_Callback(hObject, eventdata, handles)
|
---|
[2] | 648 |
|
---|
[89] | 649 | %------------------------------------------------------------------------
|
---|
| 650 | % --- called by action in FileIndex_1 edit box
|
---|
[81] | 651 | function FileIndex_1_Callback(hObject, eventdata, handles)
|
---|
[89] | 652 | %------------------------------------------------------------------------
|
---|
[81] | 653 | run0_Callback(hObject, eventdata, handles)
|
---|
[65] | 654 |
|
---|
[89] | 655 | %------------------------------------------------------------------------
|
---|
| 656 | % --- update information about a new field series (indices to scan, timing, calibration from an xml file, then refresh current plots
|
---|
[2] | 657 | function update_rootinfo(hObject,eventdata,handles)
|
---|
[89] | 658 | %------------------------------------------------------------------------
|
---|
[2] | 659 | set(handles.RootPath,'BackgroundColor',[1 1 0])
|
---|
| 660 | drawnow
|
---|
| 661 | set(handles.Fields,'UserData',[])% reinialize data from uvmat opening
|
---|
[59] | 662 | UvData=get(handles.uvmat,'UserData');%huvmat=handles of the uvmat interface
|
---|
[2] | 663 | UvData.NewSeries=1; %flag for run0: begin a new series
|
---|
| 664 | UvData.TestInputFile=1;
|
---|
[81] | 665 | set(handles.fix_pair,'Value',1) % activate by default the comp_input '-'input window
|
---|
[2] | 666 |
|
---|
| 667 | [FileName,RootPath,FileBase,FileIndices,FileExt,SubDir]=read_file_boxes(handles);
|
---|
| 668 | if ~exist(FileName,'file')
|
---|
| 669 | msgbox_uvmat('ERROR',['input file ' FileName ' not found']);
|
---|
| 670 | return
|
---|
| 671 | end
|
---|
| 672 | nbfield=[];%default
|
---|
| 673 | nburst=[];%default
|
---|
| 674 |
|
---|
| 675 | % read timing and total frame number from the current file (movie files) !! may be overrid by xml file
|
---|
| 676 | XmlData.Time=[];%default
|
---|
| 677 | XmlData.GeometryCalib=[];%default
|
---|
| 678 | TimeUnit=[];%default
|
---|
| 679 | testima=0; %test for image input
|
---|
[89] | 680 | imainfo=[];
|
---|
| 681 | ColorType='falsecolor'; %default
|
---|
| 682 | hhh='';
|
---|
[2] | 683 | if isequal(lower(FileExt),'.avi') %.avi file
|
---|
| 684 | testima=1;
|
---|
[89] | 685 | imainfo=aviinfo([FileBase FileIndices FileExt]);
|
---|
| 686 | nbfield=imainfo.NumFrames;
|
---|
[2] | 687 | nburst=1;
|
---|
[89] | 688 | set(handles.Dt_txt,'String',['Dt=' num2str(1000/imainfo.FramesPerSecond) 'ms']);%display the elementary time interval in millisec
|
---|
| 689 | XmlData.Time=(0:1/imainfo.FramesPerSecond:(imainfo.NumFrames-1)/imainfo.FramesPerSecond)';
|
---|
[2] | 690 | TimeUnit='s';
|
---|
| 691 | hhh=which('mmreader');
|
---|
[89] | 692 | ColorType=imainfo.ImageType;%='truecolor' for color images
|
---|
[2] | 693 | elseif ~isempty(imformats(FileExt(2:end))) || isequal(FileExt,'.vol')%&& isequal(NomType,'*')% multi-frame image
|
---|
| 694 | testima=1;
|
---|
| 695 | if ~isequal(SubDir,'')
|
---|
| 696 | RootFile=get(handles.RootFile,'String');
|
---|
| 697 | imainfo=imfinfo([fullfile(RootPath,SubDir,RootFile) FileIndices FileExt]);
|
---|
| 698 | else
|
---|
| 699 | imainfo=imfinfo([FileBase FileIndices FileExt]);
|
---|
| 700 | end
|
---|
[89] | 701 | ColorType=imainfo.ColorType;%='truecolor' for color images
|
---|
[2] | 702 | if length(imainfo) >1 %case of image with multiple frames
|
---|
| 703 | nbfield=length(imainfo);
|
---|
| 704 | nburst=1;
|
---|
| 705 | end
|
---|
[89] | 706 | end
|
---|
| 707 | if ~strcmp(hhh,'')&& mmreader.isPlatformSupported()% if the function is found (recent version of matlab)
|
---|
| 708 | UvData.MovieObject=mmreader([FileBase FileIndices FileExt]);
|
---|
| 709 | elseif isfield(UvData,'MovieObject')
|
---|
| 710 | UvData=rmfield(UvData,'MovieObject');
|
---|
| 711 | end
|
---|
| 712 | if isfield(imainfo,'Width') && isfield(imainfo,'Height')
|
---|
| 713 | set(handles.npx,'String',num2str(imainfo.Width));%fills nbre of pixels x box
|
---|
| 714 | set(handles.npy,'String',num2str(imainfo.Height));%fills nbre of pixels x box
|
---|
| 715 | else
|
---|
[2] | 716 | set(handles.npx,'String','');%fills nbre of pixels x box
|
---|
[89] | 717 | set(handles.npy,'String','');%fills nbre of pixels x box
|
---|
[2] | 718 | end
|
---|
[89] | 719 | set(handles.BW,'Value',strcmp(ColorType,'grayscale'))% select handles.BW if grayscale image
|
---|
[2] | 720 |
|
---|
| 721 | % read parameters (time, geometric calibration..) from a documentation file (.xml advised)
|
---|
| 722 | filexml=[FileBase '.xml'];
|
---|
| 723 | fileciv=[FileBase '.civ'];
|
---|
| 724 | warntext='';%default warning message
|
---|
| 725 | NbSlice=1;%default
|
---|
| 726 |
|
---|
| 727 | if exist(filexml,'file')
|
---|
| 728 | set(handles.view_xml,'Visible','on')
|
---|
| 729 | set(handles.view_xml,'BackgroundColor',[1 1 0])
|
---|
| 730 | set(handles.RootPath,'BackgroundColor',[1 1 1])
|
---|
| 731 | set(handles.view_xml,'String','view .xml')
|
---|
| 732 | drawnow
|
---|
| 733 | [XmlData,warntext]=imadoc2struct(filexml);
|
---|
| 734 | if ~isempty(warntext)
|
---|
| 735 | msgbox_uvmat('WARNING',warntext)
|
---|
| 736 | end
|
---|
| 737 | if isfield(XmlData,'TimeUnit')
|
---|
| 738 | if isfield(XmlData,'TimeUnit')&& ~isempty(XmlData.TimeUnit)
|
---|
| 739 | TimeUnit=XmlData.TimeUnit;
|
---|
| 740 | end
|
---|
| 741 | end
|
---|
| 742 | set(handles.view_xml,'BackgroundColor',[1 1 1])
|
---|
| 743 | drawnow
|
---|
| 744 | elseif exist(fileciv,'file')% if .civ file found
|
---|
| 745 | [error,XmlData.Time,TimeUnit,mode,npx,npy,pxcmx,pxcmy]=read_imatext([FileBase '.civ']);
|
---|
| 746 | GeometryCalib.R=[pxcmx 0 0; 0 pxcmy 0;0 0 0];
|
---|
| 747 | GeometryCalib.Tx=0;
|
---|
| 748 | GeometryCalib.Ty=0;
|
---|
| 749 | GeometryCalib.Tz=1;
|
---|
| 750 | GeometryCalib.dpx=1;
|
---|
| 751 | GeometryCalib.dpy=1;
|
---|
| 752 | GeometryCalib.sx=1;
|
---|
| 753 | GeometryCalib.Cx=0;
|
---|
| 754 | GeometryCalib.Cy=0;
|
---|
| 755 | GeometryCalib.f=1;
|
---|
| 756 | GeometryCalib.kappa1=0;
|
---|
| 757 | GeometryCalib.CoordUnit='cm';
|
---|
| 758 | XmlData.GeometryCalib=GeometryCalib;
|
---|
| 759 | if error==2, warntext=['no file ' FileBase '.civ'];
|
---|
| 760 | elseif error==1, warntext='inconsistent number of fields in the .civ file';
|
---|
| 761 | end
|
---|
| 762 | set(handles.npx,'String',num2str(npx));%fills nbre of pixels x box
|
---|
| 763 | set(handles.npy,'String',num2str(npy));%fills nbre of pixels y box
|
---|
| 764 | set(handles.pxcm,'String',num2str(pxcmx));%fills scale x (pixel/cm) box
|
---|
| 765 | set(handles.pycm,'String',num2str(pxcmy));%fills scale y (pixel/cm) box
|
---|
| 766 | set(handles.pxcm,'Visible','on');%fills scale x (pixel/cm) box
|
---|
| 767 | set(handles.pycm,'Visible','on');%fills scale y (pixel/cm) box
|
---|
| 768 | set(handles.view_xml,'Visible','on')
|
---|
| 769 | set(handles.view_xml,'String','view .civ')
|
---|
| 770 | else
|
---|
| 771 | set(handles.view_xml,'Visible','off')
|
---|
| 772 | end
|
---|
| 773 |
|
---|
| 774 | % store last index in handles.lat_i and .last_j
|
---|
| 775 | if ~isempty(XmlData.Time)
|
---|
| 776 | nbfield=size(XmlData.Time,1);
|
---|
| 777 | nburst=size(XmlData.Time,2);
|
---|
[84] | 778 | %transform .Time to a column vector if it is a line vector the nomenclature uses a single index
|
---|
| 779 | if isequal(nbfield,1) && ~isequal(nburst,1)% .Time is a line vector
|
---|
| 780 | NomType=get(handles.FileIndex,'UserData');
|
---|
| 781 | if numel(NomType)>=2 &&(strcmp(NomType,'_i')||strcmp(NomType(1:2),'%0')||strcmp(NomType(1:2),'_%'))
|
---|
| 782 | XmlData.Time=(XmlData.Time)';
|
---|
| 783 | nbfield=nburst;
|
---|
| 784 | nburst=1;
|
---|
| 785 | end
|
---|
| 786 | end
|
---|
[2] | 787 | end
|
---|
| 788 | last_i_cell=get(handles.last_i,'String');
|
---|
| 789 | if isempty(nbfield)
|
---|
| 790 | last_i_cell{1}='';
|
---|
| 791 | else
|
---|
| 792 | last_i_cell{1}=num2str(nbfield);
|
---|
| 793 | end
|
---|
| 794 | set(handles.last_i,'String',last_i_cell)
|
---|
| 795 | last_j_cell=get(handles.last_j,'String');
|
---|
| 796 | if isempty(nburst)
|
---|
| 797 | last_j_cell{1}='';
|
---|
| 798 | else
|
---|
| 799 | last_j_cell{1}=num2str(nburst);
|
---|
| 800 | end
|
---|
| 801 | set(handles.last_j,'String',last_j_cell);
|
---|
| 802 |
|
---|
| 803 | % store geometric calibration in UvData
|
---|
| 804 | if isfield(XmlData,'GeometryCalib')
|
---|
| 805 | GeometryCalib=XmlData.GeometryCalib;
|
---|
| 806 | if isempty(GeometryCalib)
|
---|
| 807 | set(handles.pxcm,'String','')
|
---|
| 808 | set(handles.pycm,'String','')
|
---|
[39] | 809 | set(handles.transform_fct,'Value',1); % no transform by default
|
---|
[2] | 810 | else
|
---|
[89] | 811 | if (isfield(GeometryCalib,'R')&& ~isequal(GeometryCalib.R(2,1),0) && ~isequal(GeometryCalib.R(1,2),0)) |...
|
---|
| 812 | (isfield(GeometryCalib,'kappa1')&& ~isequal(GeometryCalib.kappa1,0))
|
---|
[2] | 813 | set(handles.pxcm,'String','var')
|
---|
| 814 | set(handles.pycm,'String','var')
|
---|
| 815 | else
|
---|
| 816 | pixcmx=GeometryCalib.f*GeometryCalib.R(1,1)*GeometryCalib.sx/(GeometryCalib.Tz*GeometryCalib.dpx);
|
---|
| 817 | pixcmy=GeometryCalib.f*GeometryCalib.R(2,2)/(GeometryCalib.Tz*GeometryCalib.dpy);
|
---|
| 818 | set(handles.pxcm,'String',num2str(pixcmx))
|
---|
| 819 | set(handles.pycm,'String',num2str(pixcmy))
|
---|
| 820 | end
|
---|
[84] | 821 | if ~get(handles.FixedLimits,'Value')
|
---|
| 822 | set(handles.transform_fct,'Value',2); % phys transform by default if fixedLimits is off
|
---|
| 823 | end
|
---|
[2] | 824 | if isfield(GeometryCalib,'SliceCoord')
|
---|
[89] | 825 |
|
---|
[2] | 826 | siz=size(GeometryCalib.SliceCoord);
|
---|
| 827 | if siz(1)>1
|
---|
| 828 | NbSlice=siz(1);
|
---|
| 829 | set(handles.slices,'Visible','on')
|
---|
| 830 | set(handles.slices,'Value',1)
|
---|
| 831 | end
|
---|
[73] | 832 | if isfield(GeometryCalib,'NbSlice') && isequal(GeometryCalib.NbSlice,'volume')
|
---|
[60] | 833 | set(handles.nb_slice,'String','volume')
|
---|
| 834 | else
|
---|
| 835 | set(handles.nb_slice,'String',num2str(NbSlice))
|
---|
| 836 | end
|
---|
[2] | 837 | slices_Callback(hObject, eventdata, handles)
|
---|
[89] | 838 | end
|
---|
[2] | 839 | end
|
---|
| 840 | end
|
---|
| 841 |
|
---|
| 842 | %update the data attached to the uvmat interface
|
---|
| 843 | if ~isempty(TimeUnit)
|
---|
| 844 | set(handles.time_txt,'String',['time (' TimeUnit ')'])
|
---|
| 845 | end
|
---|
| 846 | UvData.TimeUnit=TimeUnit;
|
---|
| 847 | UvData.XmlData=XmlData;
|
---|
| 848 | UvData.NewSeries=1;
|
---|
[59] | 849 | set(handles.uvmat,'UserData',UvData)
|
---|
[2] | 850 |
|
---|
| 851 | %display warning message
|
---|
| 852 | if ~isequal(warntext,'')
|
---|
| 853 | msgbox_uvmat('WARNING',warntext);
|
---|
| 854 | end
|
---|
| 855 |
|
---|
| 856 | % set default options in menu 'Fields'
|
---|
| 857 | if testima
|
---|
| 858 | set(handles.Fields,'Value',1) % set menu to 'image'
|
---|
| 859 | set(handles.Fields,'String',{'image';'get_field...';'velocity';'vort';'div';'more...'})
|
---|
[45] | 860 | elseif isequal(FileExt,'.nc')||isequal(FileExt,'.cdf')
|
---|
[56] | 861 | Data=nc2struct(FileName,'ListGlobalAttribute','absolut_time_T0','civ');
|
---|
[2] | 862 | col_vec=get(handles.col_vec,'String');
|
---|
[59] | 863 | if ~isempty(Data.absolut_time_T0)&& ~isequal(Data.civ,0)
|
---|
[2] | 864 | set(handles.Fields,'String',{'image';'get_field...';'velocity';'vort';'div';'more...'})
|
---|
| 865 | set(handles.Fields,'Value',3) % set menu to 'velocity'
|
---|
| 866 | col_vec{1}='ima_cor';
|
---|
[45] | 867 | else %general netcdf file (not civx)
|
---|
[2] | 868 | set(handles.Fields,'Value',1) % set menu to 'get_field...
|
---|
| 869 | set(handles.Fields,'String',{'get_field...'})
|
---|
| 870 | col_vec{1}='get_field...';
|
---|
| 871 | end
|
---|
| 872 | set(handles.col_vec,'String',col_vec)
|
---|
| 873 | else
|
---|
| 874 | msgbox_uvmat('ERROR',['invalid input file extension ' FileExt])
|
---|
| 875 | return
|
---|
| 876 | end
|
---|
| 877 |
|
---|
| 878 | % set index navigation options and refresh plots
|
---|
| 879 | set(handles.RootPath,'BackgroundColor',[1 1 1])
|
---|
| 880 | drawnow
|
---|
| 881 | set_scan_options(hObject, eventdata, handles)
|
---|
| 882 |
|
---|
| 883 |
|
---|
| 884 | %-------------------------------------------------------------------
|
---|
| 885 | %-- set index navigation options for new series input and refresh plot
|
---|
| 886 | %-------------------------------------------------------------------
|
---|
| 887 | function set_scan_options(hObject, eventdata, handles)
|
---|
| 888 |
|
---|
[81] | 889 | % set the corresponding index navigation options
|
---|
| 890 | NomType=get(handles.FileIndex,'UserData');
|
---|
[2] | 891 | NomType_1=get(handles.FileIndex_1,'UserData');
|
---|
[81] | 892 | last_i_str=get(handles.last_i,'String');
|
---|
| 893 | nbfield=str2num(last_i_str{1});
|
---|
| 894 | if numel(last_i_str)==2
|
---|
| 895 | nbfield=min(nbfield,str2num(last_i_str{2}));
|
---|
| 896 | end
|
---|
[2] | 897 | state_j='off'; %default
|
---|
[81] | 898 | scan_option='i';%default
|
---|
[2] | 899 | switch NomType
|
---|
| 900 | case {'_i_j','_i_j1-j2','_i1-i2_j','#_ab'},% two navigation indices
|
---|
| 901 | state_j='on';
|
---|
[81] | 902 | if isequal(nbfield,1)
|
---|
| 903 | scan_option='j';
|
---|
[2] | 904 | end
|
---|
| 905 | end
|
---|
| 906 | if ~isempty(NomType_1)
|
---|
| 907 | switch NomType_1
|
---|
| 908 | case {'_i_j','_i_j1-j2','_i1-i2_j','#_ab'},% two navigation indices
|
---|
| 909 | state_j='on';
|
---|
[81] | 910 | if isequal(nbfield,1)
|
---|
| 911 | scan_option='j';
|
---|
| 912 | end
|
---|
[2] | 913 | end
|
---|
| 914 | end
|
---|
| 915 | if isequal(scan_option,'i')
|
---|
| 916 | set(handles.scan_i,'Value',1)
|
---|
| 917 | scan_i_Callback(hObject, eventdata, handles);
|
---|
| 918 | else
|
---|
| 919 | set(handles.scan_j,'Value',1)
|
---|
| 920 | scan_j_Callback(hObject, eventdata, handles);
|
---|
| 921 | end
|
---|
| 922 | set(handles.scan_j,'Visible',state_j)
|
---|
| 923 | set(handles.j1,'Visible',state_j)
|
---|
| 924 | set(handles.j2,'Visible',state_j)
|
---|
| 925 | set(handles.last_j,'Visible',state_j);
|
---|
| 926 | set(handles.frame_j,'Visible',state_j);
|
---|
| 927 | set(handles.j_text,'Visible',state_j);
|
---|
| 928 |
|
---|
| 929 | % view the field
|
---|
| 930 | run0_Callback(hObject, eventdata, handles); %view field
|
---|
| 931 | mask_test=get(handles.mask_test,'value');
|
---|
| 932 | if mask_test
|
---|
| 933 | MaskData=get(handles.mask_test,'UserData');
|
---|
| 934 | if isfield(MaskData,'maskhandle') && ishandle(MaskData.maskhandle)
|
---|
| 935 | delete(MaskData.maskhandle) %delete old mask
|
---|
| 936 | end
|
---|
| 937 | mask_test_Callback(hObject, eventdata, handles)
|
---|
| 938 | end
|
---|
[59] | 939 |
|
---|
[2] | 940 | %-------------------------------------------------------------------
|
---|
| 941 | function MenuBrowse_1_Callback(hObject, eventdata, handles)
|
---|
| 942 | %-------------------------------------------------------------------
|
---|
[61] | 943 | % huvmat=get(handles.run0,'parent');
|
---|
| 944 | UvData=get(handles.uvmat,'UserData');
|
---|
[2] | 945 |
|
---|
| 946 | RootPath=get(handles.RootPath,'String');
|
---|
| 947 | [FileName, PathName, filterindex] = uigetfile( ...
|
---|
| 948 | {'*.xml;*.xls;*.civ;*.jpg;*.png;*.avi;*.AVI;*.nc;*.cmx;*.fig;*.log;*.dat', ' (*.xml,*.xls,*.civ, *.jpg,*.png, *.avi,*.nc,*.cmx ,*.fig,*.log,*.dat)';
|
---|
| 949 | '*.xml', '.xml files '; ...
|
---|
| 950 | '*.xls', '.xls files '; ...
|
---|
| 951 | '*.civ', '.civ files '; ...
|
---|
| 952 | '*.jpg','.jpg image files'; ...
|
---|
| 953 | '*.png','.png image files'; ...
|
---|
| 954 | '*.avi;*.AVI','.avi movie files'; ...
|
---|
| 955 | '*.nc','.netcdf files'; ...
|
---|
| 956 | '*.cdf','.netcdf files'; ...
|
---|
| 957 | '*.cmx','.cmx text files';...
|
---|
| 958 | '*.cmx2','.cmx2 text files';...
|
---|
| 959 | '*.fig','.fig files (matlab fig)';...
|
---|
| 960 | '*.log','.log text files ';...
|
---|
| 961 | '*.dat','.dat text files ';...
|
---|
| 962 | '*.*', 'All Files (*.*)'}, ...
|
---|
| 963 | 'Pick a file',RootPath);
|
---|
| 964 | fileinput_1=[PathName FileName];%complete file name
|
---|
| 965 | testblank=findstr(fileinput_1,' ');%look for blanks
|
---|
| 966 | if ~isempty(testblank)
|
---|
[38] | 967 | msgbox_uvmat('ERROR',['The input file name ' fileinput_1 ' contains blank character : This is not allowed. Please change name'])
|
---|
[2] | 968 | return
|
---|
| 969 | end
|
---|
| 970 | sizf=size(fileinput_1);
|
---|
[89] | 971 | if (~ischar(fileinput_1)||~isequal(sizf(1),1)),return;end
|
---|
[2] | 972 |
|
---|
| 973 | % refresh the current displayed field
|
---|
| 974 | display_file_name_1(hObject,eventdata,handles,fileinput_1)
|
---|
| 975 |
|
---|
| 976 | %update list of recent files in the menubar
|
---|
| 977 | MenuFile_1=fileinput_1;
|
---|
| 978 | MenuFile_2=get(handles.MenuFile_1,'Label');
|
---|
| 979 | MenuFile_3=get(handles.MenuFile_2,'Label');
|
---|
| 980 | MenuFile_4=get(handles.MenuFile_3,'Label');
|
---|
| 981 | MenuFile_5=get(handles.MenuFile_4,'Label');
|
---|
| 982 | set(handles.MenuFile_1,'Label',MenuFile_1)
|
---|
| 983 | set(handles.MenuFile_2,'Label',MenuFile_2)
|
---|
| 984 | set(handles.MenuFile_3,'Label',MenuFile_3)
|
---|
| 985 | set(handles.MenuFile_4,'Label',MenuFile_4)
|
---|
| 986 | set(handles.MenuFile_5,'Label',MenuFile_5)
|
---|
| 987 | set(handles.MenuFile_1_1,'Label',MenuFile_1)
|
---|
| 988 | set(handles.MenuFile_2_1,'Label',MenuFile_2)
|
---|
| 989 | set(handles.MenuFile_3_1,'Label',MenuFile_3)
|
---|
| 990 | set(handles.MenuFile_4_1,'Label',MenuFile_4)
|
---|
| 991 | set(handles.MenuFile_5_1,'Label',MenuFile_5)
|
---|
| 992 | dir_perso=prefdir;
|
---|
| 993 | profil_perso=fullfile(dir_perso,'uvmat_perso.mat');
|
---|
| 994 | if exist(profil_perso,'file')
|
---|
| 995 | save (profil_perso,'MenuFile_1','MenuFile_2','MenuFile_3','MenuFile_4', 'MenuFile_5','-append'); %store the file names for future opening of uvmat
|
---|
| 996 | else
|
---|
| 997 | txt=ver;
|
---|
| 998 | Release=txt(1).Release;
|
---|
| 999 | relnumb=str2num(Release(3:4));
|
---|
| 1000 | if relnumb >= 14
|
---|
| 1001 | save (profil_perso,'MenuFile_1','MenuFile_2','MenuFile_3','MenuFile_4', 'MenuFile_5','-V6'); %store the file names for future opening of uvmat
|
---|
| 1002 | else
|
---|
| 1003 | save (profil_perso,'MenuFile_1','MenuFile_2','MenuFile_3','MenuFile_4', 'MenuFile_5'); %store the file names for future opening of uvmat
|
---|
| 1004 | end
|
---|
| 1005 | end
|
---|
| 1006 |
|
---|
| 1007 | % --------------------------------------------------------------------
|
---|
| 1008 | function MenuFile_1_1_Callback(hObject, eventdata, handles)
|
---|
| 1009 | fileinput_1=get(handles.MenuFile_1_1,'Label');
|
---|
| 1010 | display_file_name_1(hObject,eventdata,handles,fileinput_1)
|
---|
| 1011 |
|
---|
| 1012 | % --------------------------------------------------------------------
|
---|
| 1013 | function MenuFile_2_1_Callback(hObject, eventdata, handles)
|
---|
| 1014 | fileinput_1=get(handles.MenuFile_2_1,'Label');
|
---|
| 1015 | display_file_name_1(hObject,eventdata,handles,fileinput_1)
|
---|
| 1016 |
|
---|
| 1017 | % --------------------------------------------------------------------
|
---|
| 1018 | function MenuFile_3_1_Callback(hObject, eventdata, handles)
|
---|
| 1019 | fileinput_1=get(handles.MenuFile_3_1,'Label');
|
---|
| 1020 | display_file_name_1(hObject,eventdata,handles,fileinput_1)
|
---|
| 1021 |
|
---|
| 1022 | % --------------------------------------------------------------------
|
---|
| 1023 | function MenuFile_4_1_Callback(hObject, eventdata, handles)
|
---|
| 1024 | fileinput_1=get(handles.MenuFile_4_1,'Label');
|
---|
| 1025 | display_file_name_1(hObject,eventdata,handles,fileinput_1)
|
---|
| 1026 |
|
---|
| 1027 | % --------------------------------------------------------------------
|
---|
| 1028 | function MenuFile_5_1_Callback(hObject, eventdata, handles)
|
---|
| 1029 | fileinput_1=get(handles.MenuFile_5_1,'Label');
|
---|
| 1030 | display_file_name_1(hObject,eventdata,handles,fileinput_1)
|
---|
| 1031 |
|
---|
| 1032 | %-----------------------------------------------------------------
|
---|
| 1033 | % fills the edit boxes RootPath, RootFile,NomType...from an input file name 'fileinput'
|
---|
| 1034 | %----------------------------------------------------------------
|
---|
| 1035 | function display_file_name_1(hObject,eventdata,handles,fileinput_1)
|
---|
| 1036 |
|
---|
| 1037 | %[path,name,ext]=fileparts(fileinput_1);
|
---|
| 1038 | [RootPath_1,RootFile_1,field_count,str2,str_a,str_b,FileExt_1,NomType_1,SubDir_1]=name2display(fileinput_1);
|
---|
| 1039 | nbfield_1=1; %default
|
---|
| 1040 | ext_test=FileExt_1;%default
|
---|
| 1041 | form=imformats(FileExt_1(2:end));
|
---|
| 1042 | if ~isempty(form) % if the extension corresponds to an image format recognized by Matlab
|
---|
| 1043 | imainfo=imfinfo(fileinput_1);
|
---|
| 1044 | nbfield_1=length(imainfo);
|
---|
| 1045 | ext_test='.image';
|
---|
| 1046 | elseif isequal(lower(FileExt_1),'.avi')
|
---|
| 1047 | info=aviinfo(fileinput_1);
|
---|
| 1048 | nbfield_1=info.NumFrames;
|
---|
| 1049 | ext_test='.image';
|
---|
| 1050 | end
|
---|
| 1051 |
|
---|
| 1052 | %open directly fig or text files
|
---|
| 1053 | switch ext_test
|
---|
| 1054 | case {'.civ','.log','.cmx','.cmx2','.txt'} %display text file
|
---|
| 1055 | edit(fileinput)
|
---|
| 1056 | return
|
---|
| 1057 | case '.fig' %display matlab figure
|
---|
| 1058 | hfig=open(fileinput);
|
---|
| 1059 | set(hfig,'WindowButtonMotionFcn','mouse_motion')%set mouse action functio
|
---|
| 1060 | set(hfig,'WindowButtonUpFcn','mouse_up')%set mouse click action function
|
---|
| 1061 | set(hfig,'WindowButtonUpFcn','mouse_down')%set mouse click action function
|
---|
| 1062 | return
|
---|
| 1063 | case {'.xml','.xls'} % edit xml or Excel files
|
---|
| 1064 | heditxml=editxml(fileinput);
|
---|
| 1065 | return
|
---|
| 1066 | case {'.image','.nc','.cdf'}
|
---|
| 1067 | % set(handles.FileIndex,'UserData',NomType_1);
|
---|
| 1068 | otherwise
|
---|
[38] | 1069 | msgbox_uvmat(['invalid input file extension ' FileExt_1 ' for uvmat'],'ERROR')
|
---|
[2] | 1070 | return
|
---|
| 1071 | end
|
---|
| 1072 |
|
---|
| 1073 | % test for image series in a single file and synchronise file indices of the two series
|
---|
| 1074 | if nbfield_1 >1 %case of image with multiple frames
|
---|
| 1075 | if nbfield_1 < num_i1
|
---|
[38] | 1076 | msgbox_uvmat('ERROR','current frame index beyond the input movie length')
|
---|
[2] | 1077 | return
|
---|
| 1078 | else
|
---|
| 1079 | NomType_1='*'; %indicate a set of indexed frames within a single file
|
---|
| 1080 | filename_new=fileinput_1;
|
---|
| 1081 | end
|
---|
| 1082 | else % cases of data files
|
---|
| 1083 | RootPath=get(handles.RootPath,'String');
|
---|
| 1084 | RootFile=get(handles.RootFile,'String');
|
---|
| 1085 | FileBase=fullfile(RootPath,RootFile);
|
---|
| 1086 | FileBase_1=fullfile(RootPath_1,RootFile_1);
|
---|
| 1087 | if isequal(FileBase,FileBase_1)
|
---|
| 1088 | filename_new=fileinput_1;
|
---|
| 1089 | else
|
---|
| 1090 | num_i1=stra2num(get(handles.i1,'String'));%get the current file indices from counters
|
---|
| 1091 | num_j1=stra2num(get(handles.j1,'String'));
|
---|
| 1092 | num_i2=stra2num(get(handles.i2,'String'));
|
---|
| 1093 | num_j2=stra2num(get(handles.j2,'String'));
|
---|
| 1094 | [filename_new,idetect]=...
|
---|
| 1095 | 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
|
---|
| 1096 | indices=''; %default
|
---|
| 1097 | if ~idetect
|
---|
[38] | 1098 | msgbox_uvmat('ERROR','second input file with indices corresponding to the first one does not exist')
|
---|
[2] | 1099 | return
|
---|
| 1100 | end
|
---|
| 1101 | end
|
---|
| 1102 | end
|
---|
[81] | 1103 | set(handles.FileIndex_1,'UserData',NomType_1);
|
---|
[2] | 1104 |
|
---|
| 1105 | % make visible and fill the second raw of edit boxes
|
---|
| 1106 | set(handles.RootPath_1,'Visible','on')
|
---|
| 1107 | set(handles.RootFile_1,'Visible','on')
|
---|
| 1108 | set(handles.SubDir_1,'Visible','on');
|
---|
| 1109 | set(handles.FileIndex_1,'Visible','on');
|
---|
| 1110 | set(handles.FileExt_1,'Visible','on');
|
---|
| 1111 | [FileName,RootPath,FileBase,FileIndices,FileExt,SubDir]=read_file_boxes(handles);
|
---|
| 1112 | if isequal(FileBase,FileBase_1)
|
---|
| 1113 | set(handles.RootPath_1,'String','"')
|
---|
| 1114 | set(handles.RootFile_1,'String','"');
|
---|
| 1115 | else
|
---|
| 1116 | set(handles.RootPath_1,'String',RootPath_1)
|
---|
| 1117 | set(handles.RootFile_1,'String',['/' RootFile_1]);
|
---|
| 1118 | end
|
---|
| 1119 | if isequal(SubDir_1,'')
|
---|
| 1120 | set(handles.SubDir_1,'String','');
|
---|
| 1121 | FileBaseSub_1=FileBase_1;
|
---|
| 1122 | else
|
---|
| 1123 | set(handles.SubDir_1,'String',['/' SubDir_1]);
|
---|
| 1124 | FileBaseSub_1=fullfile(FileBase_1,SubDir_1);
|
---|
| 1125 | end
|
---|
| 1126 | indices=filename_new(length(FileBaseSub_1)+1:end);
|
---|
| 1127 | indices(end-length(FileExt_1)+1:end)=[]; %remove extension
|
---|
| 1128 | set(handles.FileIndex_1,'String',indices)
|
---|
| 1129 | set(handles.FileIndex_1,'UserData',NomType_1)
|
---|
| 1130 | set(handles.FileExt_1,'String',FileExt_1);
|
---|
| 1131 |
|
---|
| 1132 | % default choice of fields
|
---|
| 1133 | if isequal(ext_test,'.image')
|
---|
| 1134 | set(handles.Fields_1,'String',{'';'image';'get_field...';'velocity';'vort';'div';'more...'})
|
---|
| 1135 | set(handles.Fields_1,'Value',2) % set menu to 'image'
|
---|
| 1136 | elseif isequal(FileExt_1,'.nc')|isequal(FileExt_1,'.cdf')
|
---|
| 1137 | Data=nc2struct(fileinput_1,[]);
|
---|
| 1138 | if isfield(Data,'absolut_time_T0')
|
---|
| 1139 | set(handles.Fields_1,'String',{'';'image';'get_field...';'velocity';'vort';'div';'more...'})
|
---|
| 1140 | set(handles.Fields_1,'Value',4) % set menu to 'velocity'
|
---|
| 1141 | else
|
---|
| 1142 | set(handles.Fields_1,'Value',2) % set menu to 'get_field...'
|
---|
| 1143 | set(handles.Fields_1,'String',{'';'get_field...'});
|
---|
| 1144 | end
|
---|
| 1145 | end
|
---|
| 1146 | set(handles.SubField,'Visible','on')
|
---|
| 1147 | set(handles.SubField,'Value',1)
|
---|
| 1148 | RootPath_1_Callback(hObject,eventdata,handles);
|
---|
| 1149 |
|
---|
| 1150 |
|
---|
| 1151 | %-----------------------------------------------------
|
---|
| 1152 | function RootPath_1_Callback(hObject,eventdata,handles)
|
---|
| 1153 | update_rootinfo_1(hObject,eventdata,handles)
|
---|
| 1154 |
|
---|
| 1155 | %-------------------------------------------------------------------
|
---|
| 1156 | function RootFile_1_Callback(hObject, eventdata, handles)
|
---|
| 1157 | update_rootinfo_1(hObject,eventdata,handles)
|
---|
| 1158 | %-------------------------------------------------------------------
|
---|
| 1159 |
|
---|
| 1160 | %-------------------------------------------------------------------
|
---|
| 1161 | function update_rootinfo_1(hObject,eventdata,handles) %A REVOIR
|
---|
| 1162 |
|
---|
| 1163 | set(handles.RootPath_1,'BackgroundColor',[1 1 0])% indicate active program by yellow color
|
---|
| 1164 | drawnow
|
---|
[61] | 1165 | %huvmat=get(handles.RootPath,'parent');
|
---|
| 1166 | UvData=get(handles.uvmat,'UserData');%huvmat=handles of the uvmat interface
|
---|
[2] | 1167 | UvData.NewSeries=1; %flag for run0: begin a new series
|
---|
| 1168 |
|
---|
| 1169 | [FileName,RootPath,FileBase,FileIndices,FileExt]=read_file_boxes_1(handles);
|
---|
| 1170 | if ~exist(FileName,'file')
|
---|
| 1171 | msgbox_uvmat('ERROR',['input file ' FileName ' not found']);
|
---|
| 1172 | end
|
---|
| 1173 | nbfield_1=[];%default
|
---|
| 1174 | nburst_1=[];%default
|
---|
| 1175 | XmlData.Time=[];
|
---|
| 1176 | XmlData.GeometryCalib=[];%default
|
---|
| 1177 | TimeUnit=[];
|
---|
| 1178 | if isfield(UvData,'TimeUnit')
|
---|
| 1179 | TimeUnit=UvData.TimeUnit;
|
---|
| 1180 | end
|
---|
| 1181 | TimeUnit_1=[];
|
---|
[89] | 1182 | hhh='';%default, test for movie reading with mmreader
|
---|
| 1183 | imainfo=[];
|
---|
[2] | 1184 | if isequal(lower(FileExt),'.avi') %.avi file
|
---|
[89] | 1185 | imainfo=aviinfo([FileBase FileIndices FileExt]);
|
---|
| 1186 | nbfield_1=imainfo.NumFrames;
|
---|
[2] | 1187 | nburst_1=1;
|
---|
| 1188 | set(handles.Dt_txt,'String',['Dt=' num2str(1000/info.FramesPerSecond) 'ms']);%display the elementary time interval in millisec
|
---|
[89] | 1189 | time=[0:1/imainfo.FramesPerSecond:(imainfo.NumFrames-1)/imainfo.FramesPerSecond]';
|
---|
| 1190 | ColorType=imainfo.ImageType;%='truecolor' for color images
|
---|
| 1191 | hhh=which('mmreader');
|
---|
| 1192 | elseif ~isempty(imformats(FileExt(2:end)))|| isequal(FileExt,'.vol')
|
---|
| 1193 | testima=1;
|
---|
| 1194 | if ~isequal(SubDir,'')
|
---|
| 1195 | RootFile=get(handles.RootFile,'String');
|
---|
| 1196 | imainfo=imfinfo([fullfile(RootPath,SubDir,RootFile) FileIndices FileExt]);
|
---|
| 1197 | else
|
---|
| 1198 | imainfo=imfinfo([FileBase FileIndices FileExt]);
|
---|
[2] | 1199 | end
|
---|
[89] | 1200 | ColorType=imainfo.ColorType;%='truecolor' for color images
|
---|
[2] | 1201 | if length(imainfo) >1 %case of image with multiple frames
|
---|
| 1202 | nbfield_1=length(imainfo);
|
---|
| 1203 | nburst_1=1;
|
---|
[89] | 1204 | end
|
---|
[2] | 1205 | end
|
---|
[89] | 1206 | if ~strcmp(hhh,'')&& mmreader.isPlatformSupported()% if the function is found (recent version of matlab)
|
---|
| 1207 | UvData.MovieObject_1=mmreader([FileBase FileIndices FileExt]);
|
---|
| 1208 | elseif isfield(UvData,'MovieObject_1')
|
---|
| 1209 | UvData=rmfield(UvData,'MovieObject_1');
|
---|
| 1210 | end
|
---|
| 1211 | 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
|
---|
| 1212 | if isfield(imainfo,'Width') && isfield(imainfo,'Height')
|
---|
| 1213 | set(handles.npx,'String',num2str(imainfo.Width));%fills nbre of pixels x box
|
---|
| 1214 | set(handles.npy,'String',num2str(imainfo.Height));%fills nbre of pixels x box
|
---|
| 1215 | else
|
---|
| 1216 | set(handles.npx,'String','');%fills nbre of pixels x box
|
---|
| 1217 | set(handles.npy,'String','');%fills nbre of pixels x box
|
---|
| 1218 | end
|
---|
| 1219 | set(handles.BW,'Value',strcmp(ColorType,'grayscale'))% select handles.BW if grayscale image
|
---|
| 1220 | end
|
---|
[2] | 1221 |
|
---|
| 1222 | % find scaling parameters
|
---|
| 1223 | filexml=[FileBase '.xml'];
|
---|
| 1224 | fileciv=[FileBase '.civ'];
|
---|
| 1225 | warntext='';%default warning text
|
---|
| 1226 | if exist(filexml,'file')
|
---|
| 1227 | [XmlData,warntext]=imadoc2struct(filexml);
|
---|
| 1228 | if ~isempty(warntext)
|
---|
| 1229 | msgbox_uvmat('WARNING',warntext)
|
---|
| 1230 | end
|
---|
| 1231 | if isfield(XmlData,'Camera')
|
---|
| 1232 | % if isfield(XmlData.Camera,'NbSlice')&& ~isempty(XmlData.Camera.NbSlice)
|
---|
| 1233 | % NbSlice=XmlData.Camera.NbSlice;
|
---|
| 1234 | % end
|
---|
| 1235 | if isfield(XmlData.Camera,'TimeUnit')&& ~isempty(XmlData.Camera.TimeUnit)
|
---|
| 1236 | TimeUnit=XmlData.Camera.TimeUnit;
|
---|
| 1237 | end
|
---|
| 1238 | end
|
---|
| 1239 | elseif exist(fileciv,'file')% if .civ file found
|
---|
| 1240 | [error,XmlData.Time,TimeUnit,mode,npx,npy,pxcmx,pxcmy]=read_imatext([FileBase '.civ']);
|
---|
| 1241 | GeometryCalib.R=[pxcmx 0 0; 0 pxcmy 0;0 0 0];
|
---|
| 1242 | GeometryCalib.Tx=0;
|
---|
| 1243 | GeometryCalib.Ty=0;
|
---|
| 1244 | GeometryCalib.Tz=1;
|
---|
| 1245 | GeometryCalib.dpx=1;
|
---|
| 1246 | GeometryCalib.dpy=1;
|
---|
| 1247 | GeometryCalib.sx=1;
|
---|
| 1248 | GeometryCalib.Cx=0;
|
---|
| 1249 | GeometryCalib.Cy=0;
|
---|
| 1250 | GeometryCalib.f=1;
|
---|
| 1251 | GeometryCalib.kappa1=0;
|
---|
| 1252 | GeometryCalib.CoordUnit='cm';
|
---|
| 1253 | XmlData.GeometryCalib=GeometryCalib;
|
---|
| 1254 | if error==2, warntext=['no file ' FileBase '.civ'];
|
---|
| 1255 | elseif error==1, warntext='inconsistent number of fields in the .civ file';
|
---|
| 1256 | end
|
---|
| 1257 |
|
---|
| 1258 | set(handles.npx,'String',num2str(npx));%fills nbre of pixels x box
|
---|
| 1259 | set(handles.npy,'String',num2str(npy));%fills nbre of pixels y box
|
---|
| 1260 | set(handles.pxcm,'String',num2str(pxcmx));%fills scale x (pixel/cm) box
|
---|
| 1261 | set(handles.pycm,'String',num2str(pxcmy));%fills scale y (pixel/cm) box
|
---|
| 1262 | set(handles.pxcm,'Visible','on');%fills scale x (pixel/cm) box
|
---|
| 1263 | set(handles.pycm,'Visible','on');%fills scale y (pixel/cm) box
|
---|
| 1264 | end
|
---|
| 1265 | if ~isempty(TimeUnit_1) && ~isequal(TimeUnit_1,TimeUnit)
|
---|
[38] | 1266 | msgbox_uvmat('WARNING','the time units for the second series differs from the first one')
|
---|
[2] | 1267 | end
|
---|
| 1268 |
|
---|
| 1269 | % store last index in handles.lat_i and .last_j
|
---|
| 1270 | if ~isempty(XmlData.Time)
|
---|
| 1271 | nbfield_1=size(XmlData.Time,1);
|
---|
| 1272 | nburst_1=size(XmlData.Time,2);
|
---|
| 1273 | end
|
---|
| 1274 | last_i_cell=get(handles.last_i,'String');
|
---|
| 1275 | if isempty(nbfield_1)
|
---|
| 1276 | last_i_cell{2}='';
|
---|
| 1277 | else
|
---|
| 1278 | last_i_cell{2}=num2str(nbfield_1);
|
---|
| 1279 | end
|
---|
| 1280 | set(handles.last_i,'String',last_i_cell)
|
---|
| 1281 | last_j_cell=get(handles.last_j,'String');
|
---|
| 1282 | if isempty(nburst_1)
|
---|
| 1283 | last_j_cell{2}='';
|
---|
| 1284 | else
|
---|
| 1285 | last_j_cell{2}=num2str(nburst_1);
|
---|
| 1286 | end
|
---|
| 1287 | set(handles.last_j,'String',last_j_cell);
|
---|
| 1288 | if ~isequal(last_i_cell{1},last_i_cell{2}) || ~isequal(last_j_cell{1},last_j_cell{2})
|
---|
[38] | 1289 | msgbox_uvmat('WARNING','the numbers of input file of the second series differs from the first one')
|
---|
[2] | 1290 | end
|
---|
| 1291 |
|
---|
| 1292 | % store calibration data
|
---|
| 1293 | GeometryCalib=XmlData.GeometryCalib;
|
---|
| 1294 | if isempty(GeometryCalib)
|
---|
| 1295 | if isfield(UvData, 'GeometryCalib_1')
|
---|
| 1296 | UvData=rmfield(UvData,'GeometryCalib_1');
|
---|
| 1297 | end
|
---|
| 1298 | else
|
---|
| 1299 | UvData.GeometryCalib_1=GeometryCalib;
|
---|
| 1300 | if (isfield(GeometryCalib,'R')& ~isequal(GeometryCalib.R(2,1),0) & ~isequal(GeometryCalib.R(1,2),0)) |...
|
---|
| 1301 | (isfield(GeometryCalib,'kappa1')& ~isequal(GeometryCalib.kappa1,0))
|
---|
| 1302 | set(handles.pxcm,'String','var')
|
---|
| 1303 | set(handles.pycm,'String','var')
|
---|
| 1304 | else
|
---|
| 1305 | pixcmx=GeometryCalib.f*GeometryCalib.R(1,1)*GeometryCalib.sx/(GeometryCalib.Tz*GeometryCalib.dpx);
|
---|
| 1306 | pixcmy=GeometryCalib.f*GeometryCalib.R(2,2)/(GeometryCalib.Tz*GeometryCalib.dpy);
|
---|
| 1307 | set(handles.pxcm,'String',num2str(pixcmx))
|
---|
| 1308 | set(handles.pycm,'String',num2str(pixcmy))
|
---|
| 1309 | end
|
---|
| 1310 | end
|
---|
| 1311 | UvData.XmlData_1=XmlData;
|
---|
[61] | 1312 | set(handles.uvmat,'UserData',UvData)%update the data attached to the uvmat interface
|
---|
[2] | 1313 |
|
---|
| 1314 | if ~isequal(warntext,'')
|
---|
[38] | 1315 | msgbox_uvmat('WARNING',warntext)
|
---|
[2] | 1316 | end
|
---|
| 1317 |
|
---|
| 1318 | set(handles.RootPath_1,'BackgroundColor',[1 1 1])% signa the end the input operation
|
---|
| 1319 | drawnow
|
---|
| 1320 |
|
---|
| 1321 | set_scan_options(hObject, eventdata, handles)
|
---|
| 1322 |
|
---|
| 1323 | %---------------------------------------------------
|
---|
| 1324 | % switch file index scanning options scan_i and scan_j in an exclusive way
|
---|
| 1325 | function scan_i_Callback(hObject, eventdata, handles)
|
---|
| 1326 | %---------------------------------------------------
|
---|
| 1327 | if get(handles.scan_i,'Value')==1
|
---|
| 1328 | set(handles.scan_i,'BackgroundColor',[1 1 0])
|
---|
| 1329 | set(handles.scan_j,'Value',0)
|
---|
[81] | 1330 | % set(handles.scan_j,'BackgroundColor',[0.831 0.816 0.784])
|
---|
[2] | 1331 | else
|
---|
| 1332 | set(handles.scan_i,'BackgroundColor',[0.831 0.816 0.784])
|
---|
| 1333 | set(handles.scan_j,'Value',1)
|
---|
[81] | 1334 | % set(handles.scan_j,'BackgroundColor',[1 1 0])
|
---|
[2] | 1335 | end
|
---|
[81] | 1336 | scan_j_Callback(hObject, eventdata, handles)
|
---|
[45] | 1337 |
|
---|
[2] | 1338 | %-------------------------------------------------------------------
|
---|
| 1339 | % switch file index scanning options scan_i and scan_j in an exclusive way
|
---|
| 1340 | function scan_j_Callback(hObject, eventdata, handles)
|
---|
| 1341 | %-------------------------------------------------------------------
|
---|
| 1342 | if get(handles.scan_j,'Value')==1
|
---|
| 1343 | set(handles.scan_j,'BackgroundColor',[1 1 0])
|
---|
| 1344 | set(handles.scan_i,'Value',0)
|
---|
| 1345 | set(handles.scan_i,'BackgroundColor',[0.831 0.816 0.784])
|
---|
[81] | 1346 | NomType=get(handles.FileIndex,'UserData');
|
---|
| 1347 | switch NomType
|
---|
| 1348 | case {'_i_j1-j2','#_ab','%3dab'},% pair with j index
|
---|
| 1349 | set(handles.fix_pair,'Visible','on')% option fixed pair on/off made visible (choice of avaible pair with buttons + and - if ='off')
|
---|
| 1350 | otherwise
|
---|
| 1351 | set(handles.fix_pair,'Visible','off')
|
---|
| 1352 | end
|
---|
[2] | 1353 | else
|
---|
| 1354 | set(handles.scan_j,'BackgroundColor',[0.831 0.816 0.784])
|
---|
| 1355 | set(handles.scan_i,'Value',1)
|
---|
| 1356 | set(handles.scan_i,'BackgroundColor',[1 1 0])
|
---|
[81] | 1357 | set(handles.fix_pair,'Visible','off')
|
---|
[2] | 1358 | end
|
---|
| 1359 |
|
---|
| 1360 | %-------------------------------------------------------------------
|
---|
| 1361 | function i1_Callback(hObject, eventdata, handles)
|
---|
| 1362 | %-------------------------------------------------------------------
|
---|
| 1363 | % [filebase,num1,num_a,num2,num_b,ext,NomType,subdir]=read_input_file(handles);
|
---|
[45] | 1364 | %[FileName,RootPath,filebase,xx,FileExt]=read_file_boxes(handles);
|
---|
[2] | 1365 | NomType=get(handles.FileIndex,'UserData');
|
---|
| 1366 | num1=stra2num(get(handles.i1,'String'));
|
---|
| 1367 | num2=stra2num(get(handles.i2,'String'));
|
---|
| 1368 | num_a=stra2num(get(handles.j1,'String'));
|
---|
| 1369 | num_b=stra2num(get(handles.j2,'String'));
|
---|
| 1370 | indices=name_generator('',num1,num_a,'',NomType,1,num2,num_b,'');
|
---|
| 1371 | set(handles.FileIndex,'String',indices)
|
---|
| 1372 | if get(handles.SubField,'Value')==1
|
---|
| 1373 | NomType_1=get(handles.FileIndex_1,'String');
|
---|
| 1374 | FileExt_1=get(handles.FileExt_1,'String');
|
---|
| 1375 | [P,F,str1,str2,str_a,str_b,Ext,NomType_1]=name2display(['xx' NomType_1 FileExt_1]);
|
---|
| 1376 | indices=name_generator('',num1,num_a,'',NomType_1,1,num2,num_b,'');
|
---|
| 1377 | set(handles.FileIndex_1,'String',indices)
|
---|
| 1378 | end
|
---|
| 1379 | run0_Callback(hObject, eventdata, handles)
|
---|
| 1380 |
|
---|
| 1381 | %-------------------------------------------------------------------
|
---|
| 1382 | function i2_Callback(hObject, eventdata, handles)
|
---|
| 1383 | i1_Callback(hObject, eventdata, handles)
|
---|
| 1384 | %-------------------------------------------------------------------
|
---|
| 1385 |
|
---|
| 1386 | %-------------------------------------------------------------------
|
---|
| 1387 | function j1_Callback(hObject, eventdata, handles)
|
---|
| 1388 | i1_Callback(hObject, eventdata, handles)
|
---|
| 1389 | %-------------------------------------------------------------------
|
---|
| 1390 |
|
---|
| 1391 | %-------------------------------------------------------------------
|
---|
| 1392 | function j2_Callback(hObject, eventdata, handles)
|
---|
| 1393 | i1_Callback(hObject, eventdata, handles)
|
---|
| 1394 | %-------------------------------------------------------------------
|
---|
| 1395 |
|
---|
| 1396 | %-------------------------------------------------------------------
|
---|
| 1397 | function slices_Callback(hObject, eventdata, handles)
|
---|
| 1398 | %-------------------------------------------------------------------
|
---|
| 1399 | if get(handles.slices,'Value')==1
|
---|
| 1400 | set(handles.slices,'BackgroundColor',[1 1 0])
|
---|
| 1401 | set(handles.nb_slice,'Visible','on')
|
---|
| 1402 | set(handles.z_text,'Visible','on')
|
---|
| 1403 | set(handles.z_index,'Visible','on')
|
---|
| 1404 | nb_slice_Callback(hObject, eventdata, handles)
|
---|
| 1405 | else
|
---|
| 1406 | set(handles.nb_slice,'Visible','off')
|
---|
| 1407 | set(handles.slices,'BackgroundColor',[0.7 0.7 0.7])
|
---|
| 1408 | set(handles.z_text,'Visible','off')
|
---|
| 1409 | set(handles.z_index,'Visible','off')
|
---|
| 1410 | set(handles.masklevel,'Value',1)
|
---|
| 1411 | set(handles.masklevel,'String',{'1'})
|
---|
| 1412 | end
|
---|
| 1413 |
|
---|
| 1414 | %-------------------------------------------------------------------
|
---|
| 1415 | function nb_slice_Callback(hObject, eventdata, handles)
|
---|
| 1416 | %-------------------------------------------------------------------
|
---|
[71] | 1417 | nb_slice_str=get(handles.nb_slice,'String');
|
---|
[60] | 1418 | if isequal(nb_slice_str,'volume')
|
---|
| 1419 | num=stra2num(get(handles.j1,'String'));
|
---|
| 1420 | last_j=get(handles.last_j,'String');
|
---|
| 1421 | nbslice=str2double(last_j{1});
|
---|
| 1422 | else
|
---|
| 1423 | num=str2double(get(handles.i1,'String'));
|
---|
| 1424 | nbslice=str2double(get(handles.nb_slice,'String'));
|
---|
| 1425 | end
|
---|
| 1426 | z=mod(num-1,nbslice)+1;
|
---|
[2] | 1427 | set(handles.z_index,'String',num2str(z))
|
---|
| 1428 | for ilist=1:nbslice
|
---|
| 1429 | list_index{ilist,1}=num2str(ilist);
|
---|
| 1430 | end
|
---|
| 1431 | set(handles.masklevel,'String',list_index)
|
---|
| 1432 | set(handles.masklevel,'Value',z)
|
---|
| 1433 |
|
---|
| 1434 |
|
---|
| 1435 | %-------------------------------------------------------------------
|
---|
| 1436 | % --- Executes on button press in view_xml.
|
---|
| 1437 | function view_xml_Callback(hObject, eventdata, handles)
|
---|
| 1438 | [FileName,RootPath,FileBase,FileIndices,FileExt]=read_file_boxes(handles);
|
---|
| 1439 | option=get(handles.view_xml,'String');
|
---|
| 1440 | if isequal(option,'view .xml')
|
---|
| 1441 | FileXml=[FileBase '.xml'];
|
---|
| 1442 | heditxml=editxml(FileXml);
|
---|
| 1443 | end
|
---|
| 1444 |
|
---|
| 1445 | %-------------------------------------------------------------------
|
---|
| 1446 | % --- Executes on button press in mask_test.
|
---|
| 1447 | function mask_test_Callback(hObject, eventdata, handles)
|
---|
| 1448 | %-------------------------------------------------------------------
|
---|
| 1449 | if isequal(get(handles.mask_test,'Value'),1)
|
---|
| 1450 | [FF,RootPath,FileBase]=read_file_boxes(handles);
|
---|
| 1451 | num_i1=stra2num(get(handles.i1,'String'));
|
---|
| 1452 | num_j1=stra2num(get(handles.j1,'String'));
|
---|
| 1453 | currentdir=pwd;
|
---|
| 1454 | cd(RootPath);
|
---|
| 1455 | maskfiles=dir('*_*mask_*.png');%look for a mask file
|
---|
| 1456 | cd(currentdir);%come back to the working directory
|
---|
| 1457 | mdetect=0;
|
---|
| 1458 | if isempty(maskfiles)
|
---|
| 1459 | msgbox_uvmat('ERROR','no mask file detected (format ..._xxmask_ii.png needed), use the menu bar Tools/Make mask')
|
---|
| 1460 | return
|
---|
| 1461 | end
|
---|
| 1462 | for ilist=1:length(maskfiles)
|
---|
| 1463 | maskname=maskfiles(ilist).name;% take the first mask file in the list
|
---|
| 1464 | [rr,ff,x1,x2,xa,xb,xext,Mask_NomType{ilist}]=name2display(maskname);
|
---|
| 1465 | if ~strcmp(Mask_NomType{ilist},Mask_NomType{1})
|
---|
| 1466 | msgbox_uvmat('ERROR',['inconsistent mask types ' Mask_NomType{1} Mask_NomType{ilist } ' coexist in the current image directory'])
|
---|
| 1467 | return
|
---|
| 1468 | end
|
---|
| 1469 | [Path2,Name,ext]=fileparts(maskname);
|
---|
| 1470 | Namedouble=double(Name);
|
---|
| 1471 | val=(48>Namedouble)|(Namedouble>57);% select the non-numerical characters
|
---|
| 1472 | ind_mask=findstr('mask',Name);
|
---|
| 1473 | i=ind_mask-1;
|
---|
| 1474 | while val(i)==0 & i>0
|
---|
| 1475 | i=i-1;
|
---|
| 1476 | end
|
---|
| 1477 | nbmask_str=str2num(Name(i+1:ind_mask-1));
|
---|
| 1478 | if ~isempty(nbmask_str)
|
---|
| 1479 | nbslice(ilist)=nbmask_str; % number of different masks (slices)
|
---|
| 1480 | end
|
---|
| 1481 | end
|
---|
| 1482 | if isequal(min(nbslice),max(nbslice))
|
---|
| 1483 | nbslice=nbslice(1);
|
---|
| 1484 | else
|
---|
| 1485 | msgbox_uvmat('ERROR','several inconsistent mask sets coexist in the current image directory')
|
---|
| 1486 | return
|
---|
| 1487 | end
|
---|
| 1488 | if ~isempty(nbslice) && Name(i)=='_'
|
---|
| 1489 | Mask.Base=[FileBase Name(i:ind_mask+3)];
|
---|
| 1490 | Mask.NbSlice=nbslice;
|
---|
[55] | 1491 | num_i1=mod(num_i1-1,nbslice)+1;
|
---|
[2] | 1492 | Mask.NomType=Mask_NomType{1};
|
---|
[55] | 1493 | [maskname,mdetect]=name_generator(Mask.Base,num_i1,num_j1,'.png',Mask.NomType);%
|
---|
| 1494 | mdetect=exist(maskname,'file');
|
---|
[2] | 1495 | if mdetect
|
---|
| 1496 | set(handles.nb_slice,'String',Name(i+1:ind_mask-1));
|
---|
| 1497 | set(handles.nb_slice,'BackgroundColor',[1 1 0])
|
---|
| 1498 | set(handles.mask_test,'UserData',Mask);
|
---|
| 1499 | set(handles.mask_test,'BackgroundColor',[1 1 0])
|
---|
| 1500 | if nbslice > 1
|
---|
| 1501 | set(handles.slices,'value',1)
|
---|
| 1502 | slices_Callback(hObject, eventdata, handles)
|
---|
| 1503 | end
|
---|
| 1504 | end
|
---|
| 1505 | end
|
---|
| 1506 | if mdetect==0
|
---|
| 1507 | msgbox_uvmat('ERROR','no mask file detected (format ..._xxmask_ii.png needed), use the menu bar Tools/Make mask')
|
---|
| 1508 | set(handles.mask_test,'Value',0)
|
---|
| 1509 | return
|
---|
| 1510 | end
|
---|
| 1511 | update_mask(handles,num_i1,num_j1);
|
---|
| 1512 | else
|
---|
| 1513 | MaskData=get(handles.mask_test,'UserData');
|
---|
| 1514 | if isfield(MaskData,'maskhandle') && ishandle(MaskData.maskhandle)
|
---|
| 1515 | delete(MaskData.maskhandle)
|
---|
| 1516 | end
|
---|
| 1517 | set(handles.mask_test,'UserData',[])
|
---|
[61] | 1518 | %huvmat=get(handles.mask_test,'parent');
|
---|
| 1519 | UvData=get(handles.uvmat,'UserData');
|
---|
[2] | 1520 | if isfield(UvData,'MaskName')
|
---|
| 1521 | UvData=rmfield(UvData,'MaskName');
|
---|
[61] | 1522 | set(handles.uvmat,'UserData',UvData)
|
---|
[2] | 1523 | end
|
---|
| 1524 | set(handles.mask_test,'BackgroundColor',[0.7 0.7 0.7])
|
---|
| 1525 | end
|
---|
| 1526 |
|
---|
| 1527 | %-------------------------------------------------------------------
|
---|
| 1528 | function update_mask(handles,num_i1,num_j1)
|
---|
| 1529 | %-------------------------------------------------------------------
|
---|
| 1530 |
|
---|
| 1531 | MaskData=get(handles.mask_test,'UserData');
|
---|
| 1532 | if isfield(MaskData,'maskhandle')&& ishandle(MaskData.maskhandle)
|
---|
| 1533 | uistack(MaskData.maskhandle,'top');
|
---|
| 1534 | end
|
---|
| 1535 | num_i1_mask=mod(num_i1-1,MaskData.NbSlice)+1;
|
---|
| 1536 | [MaskName,mdetect]=name_generator(MaskData.Base,num_i1_mask,num_j1,'.png',MaskData.NomType);
|
---|
| 1537 | huvmat=get(handles.mask_test,'parent');
|
---|
| 1538 | UvData=get(huvmat,'UserData');
|
---|
| 1539 |
|
---|
| 1540 | %update mask image if the mask is new
|
---|
| 1541 | if ~ (isfield(UvData,'MaskName') && isequal(UvData.MaskName,MaskName))
|
---|
| 1542 | UvData.MaskName=MaskName; %update the recorded name on UvData
|
---|
| 1543 | set(huvmat,'UserData',UvData);
|
---|
| 1544 | if mdetect==0
|
---|
| 1545 | if isfield(MaskData,'maskhandle')&& ishandle(MaskData.maskhandle)
|
---|
| 1546 | delete(MaskData.maskhandle)
|
---|
| 1547 | end
|
---|
| 1548 | else
|
---|
| 1549 | %read mask image
|
---|
| 1550 | Mask.AName='image';
|
---|
| 1551 | Mask.A=imread(MaskName);
|
---|
| 1552 | npxy=size(Mask.A);
|
---|
| 1553 | Mask.AX=[0.5 npxy(2)-0.5];
|
---|
| 1554 | Mask.AY=[npxy(1)-0.5 0.5 ];
|
---|
| 1555 | Mask.CoordType='px';
|
---|
| 1556 | if isequal(get(handles.slices,'Value'),1)
|
---|
| 1557 | NbSlice=str2num(get(handles.nb_slice,'String'));
|
---|
| 1558 | num_i1=str2num(get(handles.i1,'String'));
|
---|
| 1559 | Mask.ZIndex=mod(num_i1-1,NbSlice)+1;
|
---|
| 1560 | end
|
---|
| 1561 | %px to phys or other transform on field
|
---|
[39] | 1562 | menu_transform=get(handles.transform_fct,'String');
|
---|
| 1563 | choice_value=get(handles.transform_fct,'Value');
|
---|
| 1564 | transform_name=menu_transform{choice_value};%name of the transform fct given by the menu 'transform_fct'
|
---|
| 1565 | transform_list=get(handles.transform_fct,'UserData');
|
---|
[38] | 1566 | transform=transform_list{choice_value};
|
---|
| 1567 | if ~isequal(transform_name,'') && ~isequal(transform_name,'px')
|
---|
[2] | 1568 | if isfield(UvData,'XmlData') && isfield(UvData.XmlData,'GeometryCalib')%use geometry calib recorded from the ImaDoc xml file as first priority
|
---|
| 1569 | Calib=UvData.XmlData.GeometryCalib;
|
---|
[38] | 1570 | Mask=transform(Mask,UvData.XmlData);
|
---|
[2] | 1571 | end
|
---|
| 1572 | end
|
---|
| 1573 | flagmask=Mask.A < 200;
|
---|
| 1574 |
|
---|
| 1575 | %make brown color image
|
---|
| 1576 | imflag(:,:,1)=0.9*flagmask;
|
---|
| 1577 | imflag(:,:,2)=0.7*flagmask;
|
---|
| 1578 | imflag(:,:,3)=zeros(size(flagmask));
|
---|
| 1579 |
|
---|
| 1580 | %update mask image
|
---|
| 1581 | hmask=[]; %default
|
---|
| 1582 | if isfield(MaskData,'maskhandle')&& ishandle(MaskData.maskhandle)
|
---|
| 1583 | hmask=MaskData.maskhandle;
|
---|
| 1584 | end
|
---|
| 1585 | if ~isempty(hmask)
|
---|
| 1586 | set(hmask,'CData',imflag)
|
---|
| 1587 | set(hmask,'AlphaData',flagmask*0.6)
|
---|
| 1588 | set(hmask,'XData',Mask.AX);
|
---|
| 1589 | set(hmask,'YData',Mask.AY);
|
---|
| 1590 | % uistack(hmask,'top')
|
---|
| 1591 | else
|
---|
| 1592 | axes(handles.axes3)
|
---|
| 1593 | hold on
|
---|
| 1594 | MaskData.maskhandle=image(Mask.AX,Mask.AY,imflag,'Tag','mask','HitTest','off','AlphaData',0.6*flagmask);
|
---|
| 1595 | % set(MaskData.maskhandle,'AlphaData',0.6*flagmask)
|
---|
| 1596 | set(handles.mask_test,'UserData',MaskData)
|
---|
| 1597 | end
|
---|
| 1598 | end
|
---|
| 1599 | end
|
---|
| 1600 |
|
---|
| 1601 |
|
---|
| 1602 | %-------------------------------------------------------------------
|
---|
| 1603 | function MenuExportFigure_Callback(hObject, eventdata, handles)
|
---|
| 1604 | %-------------------------------------------------------------------
|
---|
| 1605 | huvmat=get(handles.MenuExport,'parent');
|
---|
| 1606 | UvData=get(huvmat,'UserData');
|
---|
| 1607 | hfig=figure;
|
---|
| 1608 | newaxes=copyobj(handles.axes3,hfig);
|
---|
| 1609 | map=colormap(handles.axes3);
|
---|
| 1610 | colormap(map);%transmit the current colormap to the zoom fig
|
---|
| 1611 | colorbar
|
---|
| 1612 |
|
---|
| 1613 | %-------------------------------------------------------------------
|
---|
| 1614 | %-------------------------------------------------------------------
|
---|
| 1615 | % III - MAIN REFRESH FUNCTIONS : 'FRAME PLOT'
|
---|
| 1616 | %-------------------------------------------------------------------
|
---|
| 1617 |
|
---|
| 1618 | %-------------------------------------------------------------------
|
---|
[85] | 1619 | % --- Executes on button press in runplus: make one step forward and call
|
---|
| 1620 | % --- run0. The step forward is along the fields series 1 or 2 depending on
|
---|
| 1621 | % --- the scan_i and scan_j check box (exclusive each other)
|
---|
[2] | 1622 | function runplus_Callback(hObject, eventdata, handles)
|
---|
[85] | 1623 | %-------------------------------------------------------------------
|
---|
| 1624 | set(handles.runplus,'BackgroundColor',[1 1 0])%paint the command button in yellow
|
---|
| 1625 | drawnow
|
---|
[2] | 1626 | increment=str2num(get(handles.increment_scan,'String')); %get the field increment d
|
---|
| 1627 | runpm(hObject,eventdata,handles,increment)
|
---|
[85] | 1628 | set(handles.runplus,'BackgroundColor',[1 0 0])%paint the command button in yellow
|
---|
[2] | 1629 |
|
---|
| 1630 | %-------------------------------------------------------------------
|
---|
[85] | 1631 | % --- Executes on button press in runmin: make one step backward and call
|
---|
| 1632 | % --- run0. The step backward is along the fields series 1 or 2 depending on
|
---|
| 1633 | % --- the scan_i and scan_j check box (exclusive each other)
|
---|
| 1634 | function runmin_Callback(hObject, eventdata, handles)
|
---|
[2] | 1635 | %-------------------------------------------------------------------
|
---|
[85] | 1636 | set(handles.runmin,'BackgroundColor',[1 1 0])%paint the command button in yellow
|
---|
| 1637 | drawnow
|
---|
[2] | 1638 | increment=-str2num(get(handles.increment_scan,'String')); %get the field increment d
|
---|
| 1639 | runpm(hObject,eventdata,handles,increment)
|
---|
[85] | 1640 | set(handles.runmin,'BackgroundColor',[1 0 0])%paint the command button in yellow
|
---|
[2] | 1641 |
|
---|
| 1642 | %-------------------------------------------------------------------
|
---|
[81] | 1643 | % -- Executes on button press in Movie: make a series of +> steps
|
---|
| 1644 | function Movie_Callback(hObject, eventdata, handles)
|
---|
[2] | 1645 | %------------------------------------------------------------------
|
---|
[81] | 1646 | set(handles.Movie,'BackgroundColor',[1 1 0])%paint the command button in yellow
|
---|
[2] | 1647 | drawnow
|
---|
| 1648 | increment=str2num(get(handles.increment_scan,'String')); %get the field increment d
|
---|
| 1649 | set(handles.STOP,'Visible','on')
|
---|
| 1650 | set(handles.speed,'Visible','on')
|
---|
| 1651 | set(handles.speed_txt,'Visible','on')
|
---|
[81] | 1652 | set(handles.Movie,'BusyAction','queue')
|
---|
[2] | 1653 | testavi=0;
|
---|
[57] | 1654 | UvData=get(handles.uvmat,'UserData');
|
---|
[2] | 1655 |
|
---|
[81] | 1656 | while get(handles.speed,'Value')~=0 & isequal(get(handles.Movie,'BusyAction'),'queue') % enable STOP command
|
---|
[72] | 1657 | errormsg=runpm(hObject,eventdata,handles,increment);
|
---|
| 1658 | if ~isempty(errormsg)
|
---|
| 1659 | return
|
---|
| 1660 | end
|
---|
[2] | 1661 | pause(1.02-get(handles.speed,'Value'))% wait for next image
|
---|
| 1662 | end
|
---|
| 1663 | if isfield(UvData,'aviobj') && ~isempty( UvData.aviobj),
|
---|
| 1664 | UvData.aviobj=close(UvData.aviobj);
|
---|
[57] | 1665 | set(handles.uvmat,'UserData',UvData);
|
---|
[2] | 1666 | end
|
---|
[81] | 1667 | set(handles.Movie,'BackgroundColor',[1 0 0])%paint the command buttonback to red
|
---|
[2] | 1668 |
|
---|
| 1669 | %-------------------------------------------------------------------
|
---|
[81] | 1670 | % -- Executes on button press in Movie: make a series of <- steps
|
---|
| 1671 | function MovieBackward_Callback(hObject, eventdata, handles)
|
---|
| 1672 | %------------------------------------------------------------------
|
---|
| 1673 | set(handles.MovieBackward,'BackgroundColor',[1 1 0])%paint the command button in yellow
|
---|
| 1674 | drawnow
|
---|
| 1675 | increment=-str2num(get(handles.increment_scan,'String')); %get the field increment d
|
---|
| 1676 | set(handles.STOP,'Visible','on')
|
---|
| 1677 | set(handles.speed,'Visible','on')
|
---|
| 1678 | set(handles.speed_txt,'Visible','on')
|
---|
| 1679 | set(handles.MovieBackward,'BusyAction','queue')
|
---|
| 1680 | testavi=0;
|
---|
| 1681 | UvData=get(handles.uvmat,'UserData');
|
---|
| 1682 |
|
---|
| 1683 | while get(handles.speed,'Value')~=0 & isequal(get(handles.MovieBackward,'BusyAction'),'queue') % enable STOP command
|
---|
| 1684 | errormsg=runpm(hObject,eventdata,handles,increment);
|
---|
| 1685 | if ~isempty(errormsg)
|
---|
| 1686 | return
|
---|
| 1687 | end
|
---|
| 1688 | pause(1.02-get(handles.speed,'Value'))% wait for next image
|
---|
| 1689 | end
|
---|
| 1690 | if isfield(UvData,'aviobj') && ~isempty( UvData.aviobj),
|
---|
| 1691 | UvData.aviobj=close(UvData.aviobj);
|
---|
| 1692 | set(handles.uvmat,'UserData',UvData);
|
---|
| 1693 | end
|
---|
| 1694 | set(handles.MovieBackward,'BackgroundColor',[1 0 0])%paint the command buttonback to red
|
---|
| 1695 |
|
---|
| 1696 | %-------------------------------------------------------------------
|
---|
[2] | 1697 | function STOP_Callback(hObject, eventdata, handles)
|
---|
| 1698 | %-------------------------------------------------------------------
|
---|
[57] | 1699 | set(handles.movie_pair,'BusyAction','Cancel')
|
---|
| 1700 | set(handles.movie_pair,'value',0)
|
---|
[81] | 1701 | set(handles.Movie,'BusyAction','Cancel')
|
---|
| 1702 | set(handles.MovieBackward,'BusyAction','Cancel')
|
---|
[2] | 1703 | set(handles.MenuExportMovie,'BusyAction','Cancel')
|
---|
[85] | 1704 | set(handles.movie_pair,'BackgroundColor',[1 0 0])%paint the command buttonback to red
|
---|
| 1705 | set(handles.Movie,'BackgroundColor',[1 0 0])%paint the command buttonback to red
|
---|
| 1706 | set(handles.MovieBackward,'BackgroundColor',[1 0 0])%paint the command buttonback to red
|
---|
[2] | 1707 |
|
---|
| 1708 | %------------------------------------------------------------------
|
---|
[72] | 1709 | function errormsg=runpm(hObject,eventdata,handles,increment)
|
---|
[2] | 1710 | %------------------------------------------------------------------
|
---|
[57] | 1711 | %check for mùovie pair status
|
---|
| 1712 | movie_status=get(handles.movie_pair,'Value');
|
---|
| 1713 | if isequal(movie_status,1)
|
---|
[59] | 1714 | STOP_Callback(hObject, eventdata, handles)%interrupt movie pair if active
|
---|
[57] | 1715 | end
|
---|
[2] | 1716 | %read the data on the current input rootfile(s)
|
---|
| 1717 |
|
---|
| 1718 | [FileName,RootPath,filebase,FileIndices,FileExt,subdir]=read_file_boxes(handles);
|
---|
| 1719 | NomType=get(handles.FileIndex,'UserData');
|
---|
| 1720 |
|
---|
| 1721 | num1=stra2num(get(handles.i1,'String'));
|
---|
| 1722 | num2=stra2num(get(handles.i2,'String'));
|
---|
| 1723 | num_a=stra2num(get(handles.j1,'String'));
|
---|
| 1724 | num_b=stra2num(get(handles.j2,'String'));
|
---|
| 1725 |
|
---|
| 1726 | sub_value= get(handles.SubField,'Value');
|
---|
[59] | 1727 | if sub_value % a second input file has been entered
|
---|
[2] | 1728 | [FileName_1,RootPath_1,filebase_1,FileIndices_1,FileExt_1,SubDir_1]=read_file_boxes_1(handles);
|
---|
[59] | 1729 | [pp,ff,str1,str2,str_a,str_b]=name2display(FileIndices_1);
|
---|
| 1730 | num1_1=stra2num(str1);%current set of indices for the second field (may be set different than the main indices)
|
---|
| 1731 | num2_1=stra2num(str2);
|
---|
| 1732 | num_a_1=stra2num(str_a);
|
---|
| 1733 | num_b_1=stra2num(str_b);
|
---|
| 1734 | NomType_1=get(handles.FileIndex_1,'UserData');
|
---|
| 1735 | else
|
---|
| 1736 | filename_1=[];
|
---|
[2] | 1737 | end
|
---|
| 1738 |
|
---|
| 1739 | comp_input=get(handles.fix_pair,'Value');
|
---|
[81] | 1740 | % if isequal(NomType,'_i1-i2')||isequal(NomType,'_i1-i2_j')
|
---|
| 1741 | % comp_input=1; %impose a fixed pair
|
---|
| 1742 | % set(handles.fix_pair,'Value',1)
|
---|
| 1743 | % end
|
---|
[2] | 1744 |
|
---|
| 1745 | %case of scanning along the first direction (rootfile numbers)
|
---|
[59] | 1746 | if get(handles.scan_i,'Value')==1% case of scanning along index i
|
---|
[2] | 1747 | num1=num1+increment;
|
---|
| 1748 | num2=num2+increment;
|
---|
[71] | 1749 | [filename,num1,num_a,num2,num_b]=name_generator(filebase,num1,num_a,FileExt,NomType,comp_input,num2,num_b,subdir);
|
---|
[59] | 1750 | if sub_value% set the second field name and indices
|
---|
| 1751 | num1_1=num1_1+increment;
|
---|
| 1752 | num2_1=num2_1+increment;
|
---|
| 1753 | filename_1=name_generator(filebase_1,num1_1,num_a_1,FileExt_1,NomType_1,1,num2_1,num_b_1,SubDir_1);
|
---|
| 1754 | end
|
---|
| 1755 | else % case of scanning along index j (burst numbers)
|
---|
[2] | 1756 | num_a=num_a+increment;
|
---|
| 1757 | num_b=num_b+increment;
|
---|
[59] | 1758 | if sub_value
|
---|
| 1759 | num_a_1=num_a_1+increment;
|
---|
| 1760 | num_b_1=num_b_1+increment;
|
---|
| 1761 | filename_1=name_generator(filebase_1,num1_1,num_a_1,FileExt_1,NomType_1,1,num2_1,num_b_1,SubDir_1);
|
---|
| 1762 | % else % redefine the j index if it exceeds its upper bound (only in the absence of a second field)
|
---|
| 1763 | % lastfield_cell=get(handles.last_j,'String'); % get the last field number
|
---|
| 1764 | % lastfield=str2double(lastfield_cell{1});
|
---|
| 1765 | % if num_a>lastfield && ~isnan(lastfield)
|
---|
| 1766 | % num_a=mod(num_a,lastfield);
|
---|
| 1767 | % num_b=mod(num_b,lastfield)
|
---|
| 1768 | % end
|
---|
[2] | 1769 | end
|
---|
[65] | 1770 | [filename,num1,num_a,num2,num_b]=name_generator(filebase,num1,num_a,FileExt,NomType,comp_input,num2,num_b,subdir);
|
---|
[2] | 1771 | end
|
---|
| 1772 |
|
---|
[59] | 1773 | % refresh plots
|
---|
| 1774 | errormsg=refresh_field(handles,filename,filename_1,num1,num2,num_a,num_b);
|
---|
[2] | 1775 |
|
---|
[59] | 1776 | if isempty(errormsg) %update the index counters
|
---|
| 1777 | set(handles.i1,'String',num2stra(num1,NomType,1));
|
---|
| 1778 | if isequal(num2,num1)
|
---|
| 1779 | set(handles.i2,'String','');
|
---|
| 1780 | else
|
---|
| 1781 | set(handles.i2,'String',num2stra(num2,NomType,1));
|
---|
| 1782 | end
|
---|
| 1783 | set(handles.j1,'String',num2stra(num_a,NomType,2));
|
---|
| 1784 | if isequal(num_b,num_a)
|
---|
| 1785 | set(handles.j2,'String','');
|
---|
| 1786 | else
|
---|
| 1787 | set(handles.j2,'String',num2stra(num_b,NomType,2));
|
---|
| 1788 | end
|
---|
| 1789 | [indices]=name_generator('',num1,num_a,'',NomType,1,num2,num_b,'');
|
---|
| 1790 | set(handles.FileIndex,'String',indices);
|
---|
[81] | 1791 | if ~isempty(filename_1)
|
---|
[59] | 1792 | indices_1=name_generator('',num1_1,num_a_1,'',NomType_1,1,num2_1,num_b_1,'');
|
---|
| 1793 | set(handles.FileIndex_1,'String',indices_1);
|
---|
| 1794 | end
|
---|
| 1795 | if isequal(movie_status,1)
|
---|
| 1796 | set(handles.movie_pair,'Value',1)
|
---|
| 1797 | movie_pair_Callback(hObject, eventdata, handles); %reactivate moviepair if it was activated
|
---|
| 1798 | end
|
---|
[57] | 1799 | else
|
---|
[59] | 1800 | msgbox_uvmat('ERROR',errormsg);
|
---|
[57] | 1801 | end
|
---|
[2] | 1802 |
|
---|
| 1803 |
|
---|
[59] | 1804 |
|
---|
[2] | 1805 | %-------------------------------------------------------
|
---|
[57] | 1806 | % --- Executes on button press in movie_pair: create an alternating movie with two view
|
---|
[2] | 1807 | %-------------------------------------------------------
|
---|
| 1808 | function movie_pair_Callback(hObject, eventdata, handles)
|
---|
[57] | 1809 | status=get(handles.movie_pair,'value');
|
---|
| 1810 | if isequal(status,0)
|
---|
[59] | 1811 | set(handles.movie_pair,'BusyAction','Cancel')%stop movie pair if button is 'off'
|
---|
| 1812 | set(handles.i2,'String','')
|
---|
| 1813 | set(handles.j2,'String','')
|
---|
[57] | 1814 | return
|
---|
| 1815 | else
|
---|
| 1816 | set(handles.movie_pair,'BusyAction','queue')
|
---|
| 1817 | end
|
---|
[2] | 1818 | %initialisation
|
---|
| 1819 | set(handles.movie_pair,'BackgroundColor',[1 1 0])%paint the command button in yellow
|
---|
| 1820 | drawnow
|
---|
| 1821 | list_fields=get(handles.Fields,'String');% list menu fields
|
---|
| 1822 | index_fields=get(handles.Fields,'Value');% selected string index
|
---|
| 1823 | FieldName=list_fields{index_fields}; % selected field
|
---|
[65] | 1824 | UvData=get(handles.uvmat,'UserData');
|
---|
[2] | 1825 | if isequal(FieldName,'image')
|
---|
[65] | 1826 | test_1=0;
|
---|
| 1827 | [ff,rr,filebase,xx,Ext,SubDir]=read_file_boxes(handles);
|
---|
| 1828 | NomType=get(handles.FileIndex,'UserData');
|
---|
[2] | 1829 | else
|
---|
[65] | 1830 | list_fields=get(handles.Fields_1,'String');% list menu fields
|
---|
| 1831 | index_fields=get(handles.Fields_1,'Value');% selected string index
|
---|
| 1832 | FieldName=list_fields{index_fields}; % selected field
|
---|
| 1833 | if isequal(FieldName,'image')
|
---|
| 1834 | test_1=1;
|
---|
| 1835 | [ff,rr,filebase,xx,Ext,SubDir]=read_file_boxes_1(handles);
|
---|
| 1836 | NomType=get(handles.FileIndex_1,'UserData');
|
---|
| 1837 | else
|
---|
| 1838 | msgbox_uvmat('ERROR','an image or movie must be first introduced as input')
|
---|
[85] | 1839 | set(handles.movie_pair,'BackgroundColor',[1 0 0])%paint the command button in red
|
---|
[65] | 1840 | return
|
---|
| 1841 | end
|
---|
[2] | 1842 | end
|
---|
[65] | 1843 |
|
---|
[89] | 1844 | num_i1=str2double(get(handles.i1,'String'));
|
---|
[57] | 1845 | num_j1=stra2num(get(handles.j1,'String'));
|
---|
[89] | 1846 | num_i2=str2double(get(handles.i2,'String'));
|
---|
[57] | 1847 | num_j2=stra2num(get(handles.j2,'String'));
|
---|
[89] | 1848 | if isnan(num_j2)
|
---|
[57] | 1849 | if isempty(num_i2)
|
---|
| 1850 | msgbox_uvmat('ERROR', 'a second image index i2 or j2 is needed to show the pair as a movie')
|
---|
[85] | 1851 | set(handles.movie_pair,'BackgroundColor',[1 0 0])%paint the command button in red
|
---|
[2] | 1852 | return
|
---|
[57] | 1853 | else
|
---|
| 1854 | num_j2=num_j1;%repeat the index i1 by default
|
---|
[2] | 1855 | end
|
---|
[57] | 1856 | end
|
---|
[89] | 1857 | if isnan(num_i2)
|
---|
[57] | 1858 | num_i2=num_i1;%repeat the index i1 by default
|
---|
| 1859 | end
|
---|
| 1860 | imaname_1=name_generator(filebase,num_i2,num_j2,Ext,NomType);
|
---|
| 1861 | if ~exist(imaname_1,'file')
|
---|
| 1862 | msgbox_uvmat('ERROR',['second input open (-) ' imaname_1 ' not found']);
|
---|
[85] | 1863 | set(handles.movie_pair,'BackgroundColor',[1 0 0])%paint the command button in red
|
---|
[57] | 1864 | return
|
---|
| 1865 | end
|
---|
[2] | 1866 |
|
---|
| 1867 | %read the second image
|
---|
| 1868 | Field.AName='image';
|
---|
[65] | 1869 | if test_1
|
---|
| 1870 | Field_a=UvData.Field_1;
|
---|
| 1871 | else
|
---|
| 1872 | Field_a=UvData.Field;
|
---|
| 1873 | end
|
---|
| 1874 | Field_b.AX=Field_a.AX;
|
---|
| 1875 | Field_b.AY=Field_a.AY;
|
---|
[57] | 1876 | % z index
|
---|
| 1877 | nbslice=str2double(get(handles.nb_slice,'String'));
|
---|
| 1878 | if ~isempty(nbslice)
|
---|
[65] | 1879 | Field_b.ZIndex=mod(num_i2-1,nbslice)+1;
|
---|
[57] | 1880 | end
|
---|
[65] | 1881 | Field_b.CoordType='px';
|
---|
[45] | 1882 | %determine the input file type
|
---|
[65] | 1883 | if (test_1 && isfield(UvData,'MovieObject_1'))||(~test_1 && isfield(UvData,'MovieObject'))
|
---|
[45] | 1884 | FileType='movie';
|
---|
| 1885 | elseif isequal(lower(Ext),'.avi')
|
---|
| 1886 | FileType='avi';
|
---|
| 1887 | elseif isequal(lower(Ext),'.vol')
|
---|
| 1888 | FileType='vol';
|
---|
| 1889 | else
|
---|
| 1890 | form=imformats(Ext([2:end]));
|
---|
| 1891 | if ~isempty(form)% if the extension corresponds to an image format recognized by Matlab
|
---|
| 1892 | if isequal(NomType,'*');
|
---|
| 1893 | FileType='multimage';
|
---|
| 1894 | else
|
---|
| 1895 | FileType='image';
|
---|
| 1896 | end
|
---|
| 1897 | end
|
---|
| 1898 | end
|
---|
| 1899 | switch FileType
|
---|
| 1900 | case 'movie'
|
---|
[65] | 1901 | if test_1
|
---|
| 1902 | Field_b.A=read(UvData.MovieObject_1,num_i2);
|
---|
| 1903 | else
|
---|
| 1904 | Field_b.A=read(UvData.MovieObject,num_i2);
|
---|
| 1905 | end
|
---|
[45] | 1906 | case 'avi'
|
---|
| 1907 | mov=aviread(imaname_1,num_i2);
|
---|
[65] | 1908 | Field_b.A=frame2im(mov(1));
|
---|
[45] | 1909 | case 'vol'
|
---|
[65] | 1910 | Field_b.A=imread(imaname_1);
|
---|
[45] | 1911 | case 'multimage'
|
---|
[65] | 1912 | Field_b.A=imread(imaname_1,num_i2);
|
---|
[45] | 1913 | case 'image'
|
---|
[65] | 1914 | Field_b.A=imread(imaname_1);
|
---|
[45] | 1915 | end
|
---|
[60] | 1916 | if get(handles.slices,'Value')
|
---|
| 1917 | Field.ZIndex=str2double(get(handles.z_index,'String'));
|
---|
| 1918 | end
|
---|
[2] | 1919 |
|
---|
| 1920 | %px to phys or other transform on field
|
---|
[39] | 1921 | menu_transform=get(handles.transform_fct,'String');
|
---|
| 1922 | choice_value=get(handles.transform_fct,'Value');
|
---|
| 1923 | transform_name=menu_transform{choice_value};%name of the transform fct given by the menu 'transform_fct'
|
---|
| 1924 | transform_list=get(handles.transform_fct,'UserData');
|
---|
[38] | 1925 | transform=transform_list{choice_value};
|
---|
| 1926 | if ~isequal(transform_name,'') && ~isequal(transform_name,'px')
|
---|
[65] | 1927 | if test_1 && isfield(UvData,'XmlData_1') && isfield(UvData.XmlData_1,'GeometryCalib')%use geometry calib recorded from the ImaDoc xml file as first priority
|
---|
[67] | 1928 | Field_a=transform(Field_a,UvData.XmlData_1);%the first field has been stored without transform
|
---|
[65] | 1929 | Field_b=transform(Field_b,UvData.XmlData_1);
|
---|
| 1930 | elseif ~test_1 && isfield(UvData,'XmlData') && isfield(UvData.XmlData,'GeometryCalib')%use geometry calib
|
---|
| 1931 | Field_b=transform(Field_b,UvData.XmlData);
|
---|
[2] | 1932 | end
|
---|
| 1933 | end
|
---|
| 1934 |
|
---|
| 1935 | % make movie until movie speed is set to 0 or STOP is activated
|
---|
| 1936 | hima=findobj(handles.axes3,'Tag','ima');% %handles.axes3 =main plotting window (A GENERALISER)
|
---|
| 1937 | set(handles.STOP,'Visible','on')
|
---|
| 1938 | set(handles.speed,'Visible','on')
|
---|
| 1939 | set(handles.speed_txt,'Visible','on')
|
---|
[57] | 1940 | while get(handles.speed,'Value')~=0 && isequal(get(handles.movie_pair,'BusyAction'),'queue')%isequal(get(handles.run0,'BusyAction'),'queue'); % enable STOP command
|
---|
[2] | 1941 | % read and plot the series of images in non erase mode
|
---|
[65] | 1942 | set(hima,'CData',Field_b.A);
|
---|
[2] | 1943 | pause(1.02-get(handles.speed,'Value'));% wait for next image
|
---|
[65] | 1944 | set(hima,'CData',Field_a.A);
|
---|
[2] | 1945 | pause(1.02-get(handles.speed,'Value'));% wait for next image
|
---|
| 1946 | end
|
---|
| 1947 | set(handles.movie_pair,'BackgroundColor',[1 0 0])%paint the command button in red
|
---|
| 1948 |
|
---|
[59] | 1949 | %------------------------------------------------------------------------
|
---|
[2] | 1950 | % --- Executes on button press in run0.
|
---|
| 1951 | function run0_Callback(hObject, eventdata, handles)
|
---|
[59] | 1952 | %------------------------------------------------------------------------
|
---|
[85] | 1953 | set(handles.run0,'BackgroundColor',[1 1 0])%paint the command button in yellow
|
---|
| 1954 | drawnow
|
---|
[59] | 1955 | filename=read_file_boxes(handles);
|
---|
[2] | 1956 |
|
---|
[59] | 1957 | filename_1=[];%default
|
---|
| 1958 | if get(handles.SubField,'Value')
|
---|
| 1959 | filename_1=read_file_boxes_1(handles);
|
---|
| 1960 | end
|
---|
| 1961 | num_i1=stra2num(get(handles.i1,'String'));
|
---|
| 1962 | num_i2=stra2num(get(handles.i2,'String'));
|
---|
| 1963 | num_j1=stra2num(get(handles.j1,'String'));
|
---|
| 1964 | num_j2=stra2num(get(handles.j2,'String'));
|
---|
| 1965 | errormsg=refresh_field(handles,filename,filename_1,num_i1,num_i2,num_j1,num_j2);
|
---|
| 1966 | if ~isempty(errormsg)
|
---|
| 1967 | msgbox_uvmat('ERROR',errormsg);
|
---|
| 1968 | end
|
---|
[85] | 1969 | set(handles.run0,'BackgroundColor',[1 0 0])
|
---|
[59] | 1970 | %------------------------------------------------------------------------
|
---|
| 1971 | % --- read the input files and refresh all the plots, including projection.
|
---|
| 1972 | % OUTPUT:
|
---|
| 1973 | % errormsg: error message char string =[] by default
|
---|
| 1974 | % INPUT:
|
---|
| 1975 | % filename: first input file (=[] in the absence of input file)
|
---|
| 1976 | % filename_1: second input file (=[] in the asbsenc of secodn input file)
|
---|
| 1977 | % num_i1,num_i2,num_j1,num_j2; frame indices
|
---|
| 1978 | % Field: structure describing an optional input field (then replace the input file)
|
---|
| 1979 |
|
---|
| 1980 | function errormsg=refresh_field(handles,filename,filename_1,num_i1,num_i2,num_j1,num_j2,Field)
|
---|
| 1981 | %------------------------------------------------------------------------
|
---|
[81] | 1982 |
|
---|
[2] | 1983 | %initialisation
|
---|
[85] | 1984 |
|
---|
[59] | 1985 | errormsg=[]; % default error message
|
---|
[2] | 1986 | abstime=[];
|
---|
| 1987 | abstime_1=[];
|
---|
| 1988 | dt=[];
|
---|
[59] | 1989 | if ~exist('Field','var')
|
---|
| 1990 | Field={};
|
---|
| 1991 | end
|
---|
[45] | 1992 | UvData=get(handles.uvmat,'UserData');
|
---|
[75] | 1993 | %UvData =structure containing information stored outside the uicontrol of uvmat
|
---|
| 1994 | % .NewSeries: =1 for a new series (new root fiel introduced), 0 else
|
---|
| 1995 | % .MovieObject: movie object representing an input movie
|
---|
| 1996 | % .MovieObject_1: idem for a second input series (_1)
|
---|
| 1997 | % .filename_1 : last second input file name (to deal with a constant second input without reading again the file)
|
---|
| 1998 | % .VelType_1: last velocity type (civ1, civ2...) for the second input series
|
---|
| 1999 | % .FieldName_1: last field name(velocity, vorticity...) for the second input series
|
---|
| 2000 | % .NbDim: number of space dimensions of the input field
|
---|
| 2001 | % .ZMin, .ZMax: range of the z coordinate
|
---|
| 2002 | %..... to complement
|
---|
| 2003 |
|
---|
[2] | 2004 | if ishandle(handles.UVMAT_title) %remove title panel on uvmat
|
---|
| 2005 | delete(handles.UVMAT_title)
|
---|
| 2006 | end
|
---|
| 2007 |
|
---|
| 2008 | % determine the main input file information for action
|
---|
[45] | 2009 | FileType=[];%default
|
---|
[59] | 2010 | if ~isempty(filename)
|
---|
[2] | 2011 | if ~exist(filename,'file')
|
---|
[59] | 2012 | errormsg=['input file ' filename ' does not exist'];
|
---|
[2] | 2013 | return
|
---|
| 2014 | end
|
---|
[59] | 2015 | Ext=get(handles.FileExt,'String');
|
---|
[2] | 2016 | NomType=get(handles.FileIndex,'UserData');
|
---|
| 2017 | %update the z position index
|
---|
[60] | 2018 | nbslice_str=get(handles.nb_slice,'String');
|
---|
| 2019 | z_index=1;%default
|
---|
| 2020 | if isequal(nbslice_str,'volume')
|
---|
| 2021 | z_index=num_j1;
|
---|
| 2022 | set(handles.z_index,'String',num2str(z_index))
|
---|
| 2023 | else
|
---|
| 2024 | nbslice=str2num(nbslice_str);
|
---|
[2] | 2025 | z_index=mod(num_i1-1,nbslice)+1;
|
---|
| 2026 | set(handles.z_index,'String',num2str(z_index))
|
---|
| 2027 | end
|
---|
[60] | 2028 | % refresh menu for save_mask if relevant
|
---|
| 2029 | masknumber=get(handles.masklevel,'String');
|
---|
| 2030 | if length(masknumber)>=z_index
|
---|
| 2031 | set(handles.masklevel,'Value',z_index)
|
---|
| 2032 | end
|
---|
| 2033 |
|
---|
[45] | 2034 | % determine the input file type
|
---|
| 2035 | if isequal(Ext,'.nc')||isequal(Ext,'.cdf')
|
---|
| 2036 | FileType='netcdf';
|
---|
| 2037 | elseif isfield(UvData,'MovieObject')
|
---|
| 2038 | FileType='movie';
|
---|
| 2039 | FieldName='image';
|
---|
| 2040 | elseif isequal(lower(Ext),'.avi')
|
---|
| 2041 | FileType='avi';
|
---|
| 2042 | FieldName='image';
|
---|
| 2043 | elseif isequal(lower(Ext),'.vol')
|
---|
| 2044 | FileType='vol';
|
---|
| 2045 | FieldName='image';
|
---|
[2] | 2046 | else
|
---|
| 2047 | form=imformats(Ext([2:end]));
|
---|
| 2048 | if ~isempty(form)% if the extension corresponds to an image format recognized by Matlab
|
---|
[45] | 2049 | if isequal(NomType,'*');
|
---|
| 2050 | FileType='multimage';
|
---|
| 2051 | else
|
---|
| 2052 | FileType='image';
|
---|
| 2053 | end
|
---|
[2] | 2054 | FieldName='image';
|
---|
| 2055 | end
|
---|
| 2056 | end
|
---|
| 2057 | else
|
---|
[45] | 2058 | FileType='netcdf';
|
---|
[2] | 2059 | FieldName='get_field...';
|
---|
| 2060 | end
|
---|
| 2061 | VelType=[];%default
|
---|
[45] | 2062 | if isequal(FileType,'netcdf')
|
---|
[2] | 2063 | list_fields=get(handles.Fields,'String');% list menu fields
|
---|
| 2064 | index_fields=get(handles.Fields,'Value');% selected string index
|
---|
| 2065 | FieldName= list_fields{index_fields}; % selected field
|
---|
[59] | 2066 | if ~isequal(FieldName,'get_field...')% read the field names on the interface get_field...
|
---|
[2] | 2067 | VelType=setfield(handles);
|
---|
| 2068 | end
|
---|
| 2069 | end
|
---|
| 2070 |
|
---|
| 2071 | % choose a second field if Subfield option is 'on'
|
---|
| 2072 | FieldName_1=[];
|
---|
| 2073 | scal_color=[];
|
---|
| 2074 | VelType_1=setfield_1(handles);
|
---|
| 2075 | sub_value=get(handles.SubField,'Value');
|
---|
[45] | 2076 | FileType_1='none';%default
|
---|
[59] | 2077 | if ~isempty(filename_1)
|
---|
| 2078 | % test for a constant second field (comparison with a fixed field)
|
---|
[2] | 2079 | NomType_1=get(handles.FileIndex_1,'UserData');
|
---|
[71] | 2080 | Ext_1=get(handles.FileExt_1,'String');
|
---|
[45] | 2081 | % determine the input file type
|
---|
| 2082 | if isequal(Ext_1,'.nc')||isequal(Ext_1,'.cdf')
|
---|
| 2083 | FileType_1='netcdf';
|
---|
| 2084 | elseif isfield(UvData,'MovieObject_1')
|
---|
| 2085 | FileType_1='movie';
|
---|
| 2086 | FieldName_1='image';
|
---|
| 2087 | elseif isequal(lower(Ext_1),'.avi')
|
---|
| 2088 | FileType='avi';
|
---|
| 2089 | FieldName_1='image';
|
---|
| 2090 | elseif isequal(lower(Ext_1),'.vol')
|
---|
| 2091 | FileType_1='vol';
|
---|
| 2092 | FieldName_1='image';
|
---|
| 2093 | else
|
---|
[65] | 2094 | form=imformats(Ext_1([2:end]));
|
---|
[45] | 2095 | if ~isempty(form)% if the extension corresponds to an image format recognized by Matlab
|
---|
| 2096 | if isequal(NomType_1,'*');
|
---|
| 2097 | FileType_1='multimage';
|
---|
| 2098 | else
|
---|
| 2099 | FileType_1='image';
|
---|
| 2100 | end
|
---|
| 2101 | FieldName_1='image';
|
---|
| 2102 | end
|
---|
| 2103 | end
|
---|
| 2104 | if ~isequal(FieldName_1,'image')
|
---|
| 2105 | list_fields=get(handles.Fields_1,'String');% list menu fields
|
---|
| 2106 | index_fields=get(handles.Fields_1,'Value');% selected string index
|
---|
| 2107 | FieldName_1= list_fields{index_fields}; % selected field
|
---|
| 2108 | if isequal(VelType_1,'*')% free veltype choice
|
---|
[2] | 2109 | VelType_1=[];
|
---|
[45] | 2110 | elseif isequal(VelType_1,'"')% veltype the same as for the first field
|
---|
| 2111 | if isempty(VelType)
|
---|
| 2112 | VelType_1=[];
|
---|
| 2113 | else
|
---|
| 2114 | VelType_1=VelType;
|
---|
| 2115 | end
|
---|
[2] | 2116 | end
|
---|
| 2117 | end
|
---|
[59] | 2118 | test_keepdata_1=0;% test for keeping the previous stored data if the input files are unchanged
|
---|
| 2119 | if ~isequal(NomType_1,'*')%in case of a series of files (not avi movie)
|
---|
[45] | 2120 | if isfield(UvData,'filename_1')&& isfield(UvData,'VelType_1') && isfield(UvData,'FieldName_1')
|
---|
| 2121 | test_keepdata_1= isequal(filename_1,UvData.filename_1)&&...
|
---|
| 2122 | isequal(VelType_1,UvData.filename_1) && isequal(FieldName_1,UvData.FieldName_1);
|
---|
[2] | 2123 | end
|
---|
| 2124 | end
|
---|
[59] | 2125 | if test_keepdata_1
|
---|
| 2126 | Field{2}=UvData.Field_1;
|
---|
| 2127 | elseif ~exist(filename_1,'file')
|
---|
| 2128 | errormsg=['second file ' filename_1 ' does not exist'];
|
---|
| 2129 | return
|
---|
| 2130 | end
|
---|
[2] | 2131 | end
|
---|
| 2132 |
|
---|
| 2133 | %read the input field(s)
|
---|
| 2134 | %read images
|
---|
[45] | 2135 | if ~isempty(filename) && isequal(FieldName,'image')
|
---|
| 2136 | switch FileType
|
---|
| 2137 | case 'movie'
|
---|
[84] | 2138 | try
|
---|
| 2139 | A=read(UvData.MovieObject,num_i1);
|
---|
| 2140 | catch
|
---|
| 2141 | errormsg=lasterr;
|
---|
| 2142 | return
|
---|
| 2143 | end
|
---|
[45] | 2144 | case 'avi'
|
---|
[84] | 2145 | try
|
---|
| 2146 | mov=aviread(filename,num_i1);
|
---|
| 2147 | catch
|
---|
| 2148 | errormsg=lasterr;
|
---|
| 2149 | return
|
---|
| 2150 | end
|
---|
[45] | 2151 | A=frame2im(mov(1));
|
---|
| 2152 | case 'vol'
|
---|
| 2153 | A=imread(filename);
|
---|
| 2154 | case 'multimage'
|
---|
| 2155 | A=imread(filename,num_i1);
|
---|
| 2156 | case 'image'
|
---|
| 2157 | A=imread(filename);
|
---|
[2] | 2158 | end
|
---|
| 2159 | npxy=size(A);
|
---|
| 2160 | set(handles.npx,'String',num2str(npxy(2)));% display image size on the interface
|
---|
| 2161 | set(handles.npy,'String',num2str(npxy(1)));
|
---|
| 2162 | Rangx=[0.5 npxy(2)-0.5]; % coordinates of the first and last pixel centers
|
---|
| 2163 | Rangy=[npxy(1)-0.5 0.5]; %
|
---|
| 2164 | Field{1}.AName='image';
|
---|
| 2165 | Field{1}.ListVarName={'AY','AX','A'}; %
|
---|
| 2166 | if size(A,3)==3;%color
|
---|
| 2167 | Field{1}.VarDimName={'AY','AX',{'AY','AX','rgb'}}; %
|
---|
| 2168 | else
|
---|
| 2169 | Field{1}.VarDimName={'AY','AX',{'AY','AX'}}; %
|
---|
| 2170 | end
|
---|
| 2171 | Field{1}.AY=Rangy;
|
---|
| 2172 | Field{1}.AX=Rangx;
|
---|
| 2173 | Field{1}.A=A;
|
---|
| 2174 | Field{1}.CoordType='px'; %used for mouse_motion
|
---|
| 2175 | Field{1}.CoordUnit='pixel'; %used for mouse_motion
|
---|
| 2176 | end
|
---|
[56] | 2177 |
|
---|
| 2178 | %read a second image
|
---|
[59] | 2179 | if ~isempty(filename_1) && ~test_keepdata_1 && isequal(FieldName_1,'image')
|
---|
[45] | 2180 | switch FileType_1
|
---|
| 2181 | case 'movie'
|
---|
| 2182 | A=read(UvData.MovieObject_1,num_i1);
|
---|
| 2183 | case 'avi'
|
---|
[65] | 2184 | mov=aviread(filename_1,num_i1);
|
---|
[45] | 2185 | A=frame2im(mov(1));
|
---|
| 2186 | case 'vol'
|
---|
[65] | 2187 | A=imread(filename_1);
|
---|
[45] | 2188 | case 'multimage'
|
---|
[65] | 2189 | A=imread(filename_1,num_i1);
|
---|
[45] | 2190 | case 'image'
|
---|
[65] | 2191 | A=imread(filename_1);
|
---|
| 2192 | case 'netcdf'
|
---|
| 2193 | otherwise
|
---|
| 2194 | errormsg=['unknown input file type ' filename_1];
|
---|
[45] | 2195 | end
|
---|
[2] | 2196 | npxy=size(A);
|
---|
| 2197 | set(handles.npx,'String',num2str(npxy(2)));% display image size on the interface
|
---|
| 2198 | set(handles.npy,'String',num2str(npxy(1)));
|
---|
| 2199 | Rangx=[0.5 npxy(2)-0.5]; % coordinates of the first and last pixel centers
|
---|
| 2200 | Rangy=[npxy(1)-0.5 0.5]; %
|
---|
| 2201 | Field{2}.AName='image';
|
---|
| 2202 | Field{2}.ListVarName={'AY','AX','A'}; %
|
---|
| 2203 | if size(A,3)==3;%color
|
---|
| 2204 | Field{2}.VarDimName={'AY','AX',{'AY','AX','rgb'}}; %
|
---|
| 2205 | else
|
---|
| 2206 | Field{2}.VarDimName={'AY','AX',{'AY','AX'}}; %
|
---|
| 2207 | end
|
---|
| 2208 | Field{2}.AY=Rangy;
|
---|
| 2209 | Field{2}.AX=Rangx;
|
---|
| 2210 | Field{2}.A=A;
|
---|
| 2211 | Field{2}.CoordType='px'; %used for mouse_motion
|
---|
| 2212 | Field{2}.CoordUnit='px'; %used for move_mou
|
---|
| 2213 | end
|
---|
| 2214 |
|
---|
| 2215 | %read ncfile(s)
|
---|
| 2216 | CivStage_1=0;%default
|
---|
| 2217 | VelType_out_1=[];
|
---|
| 2218 | InputField={FieldName};
|
---|
| 2219 | InputField_1={FieldName_1};
|
---|
[59] | 2220 | if (~isempty(filename)&& isequal(FileType,'netcdf')) || (~isempty(filename_1)&& isequal(FileType_1,'netcdf')) ;
|
---|
[2] | 2221 | %read the velocity field(s) from netcdf rootfile(s)
|
---|
| 2222 | list_code=get(handles.col_vec,'String');% list menu fields
|
---|
| 2223 | index_code=get(handles.col_vec,'Value');% selected string index
|
---|
| 2224 | scal_color= list_code{index_code(1)}; % selected field
|
---|
| 2225 | if isequal(FieldName,'velocity')&& ~isequal(scal_color,'black') && ~isequal(scal_color,'white')
|
---|
| 2226 | InputField=[InputField scal_color];
|
---|
| 2227 | end
|
---|
| 2228 | if isequal(FieldName_1,'velocity') && ~isequal(scal_color,'black') && ~isequal(scal_color,'white')
|
---|
| 2229 | InputField_1=[InputField_1 scal_color];
|
---|
| 2230 | end
|
---|
[45] | 2231 | if isequal(FileType,'netcdf') %read the first nc field
|
---|
[2] | 2232 | if isequal(FieldName,'get_field...')% read the field names on the interface get_field.
|
---|
[89] | 2233 | hget_field=findobj(allchild(0),'Name','uvmat_field');%find the get_field... GUI
|
---|
[2] | 2234 | if isempty(hget_field)
|
---|
[89] | 2235 | hget_field= get_field(filename);%open the get_field GUI
|
---|
| 2236 | set(hget_field,'name','uvmat_field')
|
---|
| 2237 | elseif UvData.NewSeries
|
---|
| 2238 | delete(hget_field)
|
---|
| 2239 | hget_field= get_field(filename);%open the get_field GUI
|
---|
| 2240 | set(hget_field,'name','uvmat_field')
|
---|
[2] | 2241 | end
|
---|
| 2242 | hhget_field=guidata(hget_field);
|
---|
[89] | 2243 | funct_list=get(hhget_field.ACTION,'UserData');
|
---|
| 2244 | funct_index=get(hhget_field.ACTION,'Value');
|
---|
| 2245 | funct=funct_list{funct_index};
|
---|
| 2246 | Field{1}=funct(hget_field); %read the names of the variables to plot in the get_field GUI
|
---|
[2] | 2247 | CivStage=0;
|
---|
[89] | 2248 | VelType_out=[];
|
---|
[2] | 2249 | else
|
---|
| 2250 | [Field{1},VelType_out]=read_civxdata(filename,InputField,VelType);
|
---|
| 2251 | if isfield(Field{1},'Txt')
|
---|
[59] | 2252 | errormsg=Field{1}.Txt;
|
---|
[2] | 2253 | return
|
---|
| 2254 | end
|
---|
| 2255 | CivStage=Field{1}.CivStage;
|
---|
| 2256 | UvData.NbDim=Field{1}.nb_dim;
|
---|
| 2257 | end
|
---|
| 2258 | end
|
---|
[59] | 2259 | if ~isempty(filename_1) && ~test_keepdata_1 && isequal(FileType_1,'netcdf') %read the second file
|
---|
[2] | 2260 | if isequal(FieldName_1,'get_field...')% read the field names on the interface get_field.
|
---|
[89] | 2261 | hget_field_1=findobj(allchild(0),'Name','uvmat_field_1');%find the get_field... GUI
|
---|
| 2262 | if isempty(hget_field_1)
|
---|
| 2263 | hget_field_1= get_field(filename_1);%open the get_field GUI
|
---|
| 2264 | set(hget_field_1,'name','uvmat_field_1')
|
---|
[2] | 2265 | end
|
---|
[89] | 2266 | hhget_field_1=guidata(hget_field_1);%handles of GUI elements in get_field
|
---|
| 2267 | funct_list=get(hhget_field_1.ACTION,'UserData');
|
---|
| 2268 | funct_index=get(hhget_field_1.ACTION,'Value');
|
---|
| 2269 | funct=funct_list{funct_index};
|
---|
| 2270 | Field{2}=funct(hget_field_1); %read the names of the variables to plot in the get_field GUI
|
---|
[2] | 2271 | else
|
---|
[86] | 2272 | [Field{2},VelType_out_1]=read_civxdata(filename_1,InputField_1,VelType_1);
|
---|
[2] | 2273 | CivStage_1=Field{2}.CivStage;
|
---|
| 2274 | end
|
---|
[45] | 2275 | if ~isequal(FileType,'netcdf')
|
---|
[2] | 2276 | VelType_out=VelType_out_1;
|
---|
| 2277 | end
|
---|
| 2278 | end
|
---|
| 2279 | end
|
---|
| 2280 |
|
---|
[59] | 2281 | %store the second field for possible latter use
|
---|
| 2282 | if numel(Field)==2
|
---|
| 2283 | UvData.Field_1=Field{2};
|
---|
| 2284 | end
|
---|
| 2285 |
|
---|
[2] | 2286 | %update the display buttons for the first velocity type (first menuline)
|
---|
| 2287 | veltype_handles=[handles.civ1 handles.interp1 handles.filter1 handles.civ2 handles.interp2 handles.filter2];
|
---|
[45] | 2288 | if ~isequal(FileType,'netcdf')
|
---|
[2] | 2289 | reset_vel_type(veltype_handles)
|
---|
[59] | 2290 | elseif isempty(VelType) && ~isequal(FieldName,'get_field...')
|
---|
[2] | 2291 | set_veltype_display(veltype_handles,CivStage)%update the display of available velocity types for the first field
|
---|
| 2292 | if isempty(VelType_out)
|
---|
| 2293 | reset_vel_type(veltype_handles)
|
---|
| 2294 | else
|
---|
| 2295 | handle1=eval(['handles.' VelType_out]);
|
---|
| 2296 | reset_vel_type(veltype_handles,handle1)
|
---|
| 2297 | end
|
---|
| 2298 | end
|
---|
| 2299 |
|
---|
| 2300 | %update the display buttons for the second velocity type (second menuline)
|
---|
| 2301 | veltype_handles_1=[handles.civ1_1 handles.interp1_1 handles.filter1_1 handles.civ2_1 handles.interp2_1 handles.filter2_1];
|
---|
[45] | 2302 | if ~isequal(FileType_1,'netcdf')
|
---|
[2] | 2303 | reset_vel_type(veltype_handles_1)
|
---|
[59] | 2304 | elseif isempty(VelType_1) && ~isequal(FieldName_1,'get_field...')
|
---|
[2] | 2305 | set_veltype_display(veltype_handles_1,CivStage_1)%update the display of available velocity types for the first field
|
---|
| 2306 | if isempty(VelType_out_1)
|
---|
| 2307 | reset_vel_type(veltype_handles_1)
|
---|
| 2308 | else
|
---|
| 2309 | handle1=eval(['handles.' VelType_out_1 '_1']);
|
---|
| 2310 | reset_vel_type(veltype_handles_1,handle1)
|
---|
| 2311 | end
|
---|
| 2312 | end
|
---|
| 2313 |
|
---|
| 2314 | %introduce w as background image by default for a new series (only for nbdim=2)
|
---|
| 2315 | if ~isfield(UvData,'NewSeries')
|
---|
| 2316 | UvData.NewSeries=1;
|
---|
| 2317 | end
|
---|
| 2318 | %put W as background image by default if NbDim=2:
|
---|
[45] | 2319 | if ~isfield(UvData,'NbDim')||isempty(UvData.NbDim)||~isequal(UvData.NbDim,3)
|
---|
[2] | 2320 | if UvData.NewSeries && isequal(get(handles.SubField,'Value'),0) && isfield(Field{1},'W') && ~isempty(Field{1}.W);
|
---|
| 2321 | set(handles.SubField,'Value',1);
|
---|
[45] | 2322 | %menu=update_menu(handles.Fields_1,'w');%update the menu for the background scalar nd set the choice to 'w'
|
---|
[2] | 2323 | set(handles.RootPath_1,'String','"')
|
---|
| 2324 | set(handles.RootFile_1,'String','"')
|
---|
| 2325 | set(handles.SubDir_1,'String','"');
|
---|
| 2326 | [indices]=name_generator('',num_i1,num_j1,'',NomType,1,num_i2,num_j2,'');
|
---|
| 2327 | set(handles.FileIndex_1,'String',indices)
|
---|
| 2328 | set(handles.FileExt_1,'String','"');
|
---|
| 2329 | set(handles.Fields_1,'Visible','on');
|
---|
| 2330 | set(handles.Fields_1,'Visible','on');
|
---|
| 2331 | set(handles.RootPath_1,'Visible','on')
|
---|
| 2332 | set(handles.RootFile_1,'Visible','on')
|
---|
| 2333 | set(handles.SubDir_1,'Visible','on');
|
---|
| 2334 | set(handles.FileIndex_1,'Visible','on');
|
---|
| 2335 | set(handles.FileExt_1,'Visible','on');
|
---|
| 2336 | set(handles.Fields_1,'Visible','on');
|
---|
| 2337 | Field{1}.AName='w';
|
---|
| 2338 | testscal=1;
|
---|
| 2339 | end
|
---|
| 2340 | end
|
---|
| 2341 |
|
---|
| 2342 | %multislice case
|
---|
[59] | 2343 | if ~isempty(filename) &&(~isfield(UvData,'NbDim') || isequal(UvData.NbDim,2))&&...%2D case
|
---|
[2] | 2344 | isfield(UvData,'XmlData') && isfield(UvData.XmlData,'GeometryCalib')&& isfield(UvData.XmlData.GeometryCalib,'SliceCoord')
|
---|
| 2345 | siz=size(UvData.XmlData.GeometryCalib.SliceCoord);
|
---|
| 2346 | if siz(1)>1
|
---|
| 2347 | NbSlice=siz(1);
|
---|
| 2348 | else
|
---|
| 2349 | NbSlice=1;
|
---|
| 2350 | end
|
---|
| 2351 | end
|
---|
| 2352 |
|
---|
| 2353 | %store the current open names, fields and vel types in uvmat interface
|
---|
| 2354 | UvData.filename=filename;
|
---|
| 2355 | UvData.filename_1=filename_1;
|
---|
| 2356 | UvData.VelType=VelType;
|
---|
| 2357 | UvData.VelType_1=VelType_1;
|
---|
| 2358 | UvData.FieldName=FieldName;
|
---|
| 2359 | UvData.FieldName_1=FieldName_1;
|
---|
| 2360 | if ~isempty(scal_color)
|
---|
| 2361 | UvData.CName=scal_color;
|
---|
| 2362 | end
|
---|
| 2363 |
|
---|
| 2364 | %coordinate transform or user fct
|
---|
| 2365 | XmlData=[];%default
|
---|
| 2366 | if isfield(UvData,'XmlData')%use geometry calib recorded from the ImaDoc xml file as first priority
|
---|
| 2367 | XmlData=UvData.XmlData;
|
---|
| 2368 | end
|
---|
| 2369 | XmlData_1=[];%default
|
---|
| 2370 | if isfield(UvData,'XmlData_1')
|
---|
| 2371 | XmlData_1=UvData.XmlData_1;
|
---|
| 2372 | end
|
---|
[39] | 2373 | menu_transform=get(handles.transform_fct,'String');
|
---|
| 2374 | choice_value=get(handles.transform_fct,'Value');
|
---|
| 2375 | transform_list=get(handles.transform_fct,'UserData');
|
---|
| 2376 | transform=transform_list{choice_value};%selected function handles
|
---|
[2] | 2377 |
|
---|
| 2378 | % z index
|
---|
[59] | 2379 | if ~isempty(filename)
|
---|
[60] | 2380 | Field{1}.ZIndex=z_index;
|
---|
[2] | 2381 | end
|
---|
[59] | 2382 |
|
---|
[2] | 2383 | %px to phys or other transform on field
|
---|
[59] | 2384 | if ~isempty(transform)
|
---|
[2] | 2385 | if length(Field)>=2
|
---|
[60] | 2386 | Field{2}.ZIndex=z_index;
|
---|
[38] | 2387 | [Field{1},Field{2}]=transform(Field{1},XmlData,Field{2},XmlData_1);
|
---|
[2] | 2388 | if isempty(Field{2})
|
---|
| 2389 | Field(2)=[];
|
---|
| 2390 | end
|
---|
| 2391 | else
|
---|
[38] | 2392 | Field{1}=transform(Field{1},XmlData);
|
---|
[2] | 2393 | end
|
---|
| 2394 | end
|
---|
| 2395 |
|
---|
| 2396 | %calculate scalar
|
---|
[45] | 2397 | if isequal(FileType,'netcdf') && ~isequal(FieldName,'get_field...')%
|
---|
[2] | 2398 | Field{1}=calc_field(InputField,Field{1});
|
---|
| 2399 | end
|
---|
[59] | 2400 | if length(Field)==2 && ~test_keepdata_1 && isequal(FileType_1,'netcdf') && ~isequal(FieldName_1,'get_field...')
|
---|
[2] | 2401 | Field{2}=calc_field(InputField_1,Field{2});
|
---|
| 2402 | end
|
---|
| 2403 |
|
---|
| 2404 | % combine the two input fields (e.g. substract velocity fields)
|
---|
| 2405 | if numel(Field)==2
|
---|
[59] | 2406 | UvData.Field=sub_field(Field{1},Field{2}); %TO UPDATE FOR MORE GENERAL INPUT
|
---|
[2] | 2407 | else
|
---|
| 2408 | UvData.Field=Field{1};
|
---|
| 2409 | end
|
---|
[59] | 2410 |
|
---|
[2] | 2411 | % test 3D , default projection menuplane and typical mesh (needed to menuopen set_object)
|
---|
| 2412 | test_x=0;
|
---|
| 2413 | test_z=0;% test for unstructured z coordinate
|
---|
| 2414 | UvData.ZMax=0;
|
---|
| 2415 | UvData.ZMin=0;%default
|
---|
| 2416 | UvData.Mesh=1; %default
|
---|
| 2417 | [UvData.Field,errormsg]=check_field_structure(UvData.Field);
|
---|
| 2418 | if ~isempty(errormsg)
|
---|
[59] | 2419 | errormsg=['error in uvmat/run0_Callback/check_field_structure: ' errormsg];
|
---|
[2] | 2420 | return
|
---|
| 2421 | end
|
---|
| 2422 | [CellVarIndex,NbDim,VarType]=find_field_indices(UvData.Field);
|
---|
| 2423 | [NbDim,imax]=max(NbDim);
|
---|
| 2424 | if isempty(imax)
|
---|
[45] | 2425 | % DimVarIndex=0;
|
---|
[2] | 2426 | coord_x=[];
|
---|
| 2427 | else
|
---|
[45] | 2428 | % VarIndex=CellVarIndex{imax};
|
---|
[2] | 2429 | coord_x=VarType{imax}.coord_x;
|
---|
| 2430 | end
|
---|
[45] | 2431 | if isfield(UvData,'NbDim') && ~isempty(UvData.NbDim)
|
---|
[2] | 2432 | NbDim=UvData.NbDim;
|
---|
| 2433 | else
|
---|
| 2434 | UvData.NbDim=NbDim;
|
---|
| 2435 | end
|
---|
[45] | 2436 | if ~isempty(CellVarIndex) && ~isempty(VarType{imax}.coord_x) && ~isempty(VarType{imax}.coord_y) %unstructured coordinate z
|
---|
[2] | 2437 | XName=UvData.Field.ListVarName{VarType{imax}.coord_x};
|
---|
| 2438 | YName=UvData.Field.ListVarName{VarType{imax}.coord_y};
|
---|
| 2439 | test_x=1;
|
---|
[45] | 2440 | elseif isfield(UvData.Field,'X') && isfield(UvData.Field,'Y')
|
---|
[2] | 2441 | XName='X';
|
---|
| 2442 | YName='Y';
|
---|
| 2443 | test_x=1;
|
---|
| 2444 | end
|
---|
| 2445 | if test_x
|
---|
| 2446 | eval(['UvData.XMax=max(UvData.Field.' XName ');'])
|
---|
| 2447 | eval(['UvData.XMin=min(UvData.Field.' XName ');'])
|
---|
| 2448 | eval(['UvData.YMax=max(UvData.Field.' YName ');'])
|
---|
| 2449 | eval(['UvData.YMin=min(UvData.Field.' YName ');'])
|
---|
| 2450 | eval(['nbvec=length(UvData.Field.' XName ');'])
|
---|
| 2451 | if NbDim==3%
|
---|
[45] | 2452 | if ~isempty(CellVarIndex) && ~isempty(VarType{imax}.coord_z)%unstructured coordinate z
|
---|
[42] | 2453 | ZName=UvData.Field.ListVarName{VarType{imax}.coord_z};
|
---|
[2] | 2454 | eval(['UvData.ZMax=max(UvData.Field.' ZName ');'])
|
---|
| 2455 | eval(['UvData.ZMin=min(UvData.Field.' ZName ');'])
|
---|
| 2456 | test_z=1;
|
---|
| 2457 | elseif isfield(UvData,'Z')% usual civ data
|
---|
| 2458 | UvData.ZMax=max(UvData.Z);
|
---|
| 2459 | UvData.ZMin=min(UvData.Z);
|
---|
| 2460 | test_z=1;
|
---|
| 2461 | end
|
---|
| 2462 | end
|
---|
| 2463 | if isequal(UvData.ZMin,UvData.ZMax)%no z dependency
|
---|
| 2464 | NbDim=2;
|
---|
| 2465 | test_z=0;
|
---|
| 2466 | end
|
---|
| 2467 | if test_z
|
---|
| 2468 | UvData.Mesh=((UvData.XMax-UvData.XMin)*(UvData.YMax-UvData.YMin)*(UvData.ZMax-UvData.ZMin))/nbvec;% volume per vector
|
---|
| 2469 | UvData.Mesh=(UvData.Mesh)^(1/3);
|
---|
| 2470 | else
|
---|
| 2471 | UvData.Mesh=sqrt((UvData.XMax-UvData.XMin)*(UvData.YMax-UvData.YMin)/nbvec);%2D
|
---|
| 2472 | end
|
---|
| 2473 | end
|
---|
| 2474 | %case of structured coordinates
|
---|
[89] | 2475 | if isfield(UvData.Field,'AX') && isfield(UvData.Field,'AY')&& isfield(UvData.Field,'A')
|
---|
[2] | 2476 | UvData.XMax=max(UvData.Field.AX);
|
---|
| 2477 | UvData.XMin=min(UvData.Field.AX);
|
---|
| 2478 | UvData.YMax=max(UvData.Field.AY);
|
---|
| 2479 | UvData.YMin=min(UvData.Field.AY);
|
---|
| 2480 | np_A=size(UvData.Field.A);
|
---|
| 2481 | UvData.Mesh=sqrt((UvData.XMax-UvData.XMin)*(UvData.YMax-UvData.YMin)/((np_A(1)-1) * (np_A(2)-1))) ;
|
---|
| 2482 | end
|
---|
[89] | 2483 | if isempty(coord_x) && ~isempty(CellVarIndex)
|
---|
[2] | 2484 | VarIndex=CellVarIndex{imax}; % list of variable indices
|
---|
| 2485 | DimIndex=UvData.Field.VarDimIndex{VarIndex(1)}; %list of dim indices for the variable
|
---|
| 2486 | if NbDim==3
|
---|
| 2487 | nbpoints=UvData.Field.DimValue(DimIndex(1));
|
---|
[72] | 2488 | if isfield(VarType{imax},'coord_3')&& ~isequal(VarType{imax}.coord_3,0) % z is a dimension variable
|
---|
[81] | 2489 | ZName=UvData.Field.ListVarName{VarType{imax}.coord_3};
|
---|
[2] | 2490 | eval(['UvData.ZMax=max(UvData.Field.' ZName ');'])
|
---|
| 2491 | eval(['UvData.ZMin=min(UvData.Field.' ZName ');'])
|
---|
| 2492 | else
|
---|
| 2493 | testcoord_z=0;
|
---|
| 2494 | if length(UvData.Field.VarAttribute)>=VarIndex(1)
|
---|
| 2495 | if isfield(UvData.Field.VarAttribute{VarIndex(1)},'Coord_1')%regular grid
|
---|
| 2496 | Coord_z=UvData.Field.VarAttribute{VarIndex(1)}.Coord_1;
|
---|
| 2497 | UvData.ZMax=max(Coord_z);
|
---|
| 2498 | UvData.ZMin=min(Coord_z);
|
---|
| 2499 | testcoord_z=1;
|
---|
| 2500 | end
|
---|
| 2501 | end
|
---|
| 2502 | if ~testcoord_z
|
---|
| 2503 | UvData.ZMin=1;
|
---|
| 2504 | UvData.ZMax=UvData.Field.DimValue(DimIndex(1));
|
---|
| 2505 | end
|
---|
| 2506 | end
|
---|
| 2507 | UvData.Mesh=(UvData.ZMax-UvData.ZMin)/(nbpoints-1);
|
---|
| 2508 | elseif NbDim==2
|
---|
| 2509 | nbpoints_y=UvData.Field.DimValue(DimIndex(1));
|
---|
| 2510 | Yvar=VarType{imax}.coord_y;
|
---|
| 2511 | if Yvar~=0 % x is a dimension variable
|
---|
| 2512 | YName=UvData.Field.ListVarName{Yvar};
|
---|
| 2513 | eval(['UvData.YMax=max(UvData.Field.' YName ');'])
|
---|
| 2514 | eval(['UvData.YMin=min(UvData.Field.' YName ');'])
|
---|
| 2515 | else
|
---|
| 2516 | testcoord_y=0;
|
---|
| 2517 | if ~testcoord_y
|
---|
| 2518 | UvData.YMin=1;
|
---|
| 2519 | UvData.YMax=UvData.Field.DimValue(DimIndex(1));
|
---|
| 2520 | end
|
---|
| 2521 | end
|
---|
| 2522 | DY=(UvData.YMax-UvData.YMin)/(nbpoints_y-1);
|
---|
| 2523 | nbpoints_x=UvData.Field.DimValue(DimIndex(2));
|
---|
| 2524 | Xvar=VarType{imax}.coord_x;
|
---|
| 2525 | if Xvar~=0 % x is a dimension variable
|
---|
| 2526 | XName=UvData.Field.ListVarName{Xvar};
|
---|
| 2527 | eval(['UvData.XMax=max(UvData.Field.' XName ');'])
|
---|
| 2528 | eval(['UvData.XMin=min(UvData.Field.' XName ');'])
|
---|
| 2529 | else
|
---|
| 2530 | testcoord_x=0;
|
---|
| 2531 | if ~testcoord_x
|
---|
| 2532 | UvData.XMin=1;
|
---|
| 2533 | UvData.XMax=UvData.Field.DimValue(DimIndex(2));
|
---|
| 2534 | end
|
---|
| 2535 | end
|
---|
| 2536 | DX=(UvData.XMax-UvData.XMin)/(nbpoints_x-1);
|
---|
| 2537 | UvData.Mesh= sqrt(DX*DY);
|
---|
| 2538 | end
|
---|
| 2539 | end
|
---|
| 2540 |
|
---|
| 2541 | %create a default projection menuplane
|
---|
| 2542 | UvData.Object{1}.Style='plane';%main plotting plane
|
---|
| 2543 | UvData.Object{1}.ProjMode='projection';%main plotting plane
|
---|
| 2544 | if ~isfield(UvData.Object{1},'plotaxes')
|
---|
| 2545 | UvData.Object{1}.plotaxes=handles.axes3;%default plotting axis
|
---|
[61] | 2546 | set(handles.list_object_1,'Value',1);
|
---|
[71] | 2547 | set(handles.list_object_1,'String',{'1-PLANE'});
|
---|
[2] | 2548 | end
|
---|
| 2549 |
|
---|
| 2550 | %3D case (menuvolume)
|
---|
[74] | 2551 | if NbDim==3 && UvData.NewSeries
|
---|
[2] | 2552 | UvData.Object{1}.NbDim=UvData.NbDim;%test for 3D objects
|
---|
| 2553 | UvData.Object{1}.RangeZ=UvData.Mesh;%main plotting plane
|
---|
| 2554 | UvData.Object{1}.Coord(1,3)=(UvData.ZMin+UvData.ZMax)/2;%section at a middle plane chosen
|
---|
| 2555 | UvData.Object{1}.Phi=0;
|
---|
| 2556 | UvData.Object{1}.Theta=0;
|
---|
| 2557 | UvData.Object{1}.Psi=0;
|
---|
| 2558 | UvData.Object{1}.HandlesDisplay=plot(0,0,'Tag','proj_object');% A REVOIR
|
---|
| 2559 | PlotHandles=get_plot_handles(handles);
|
---|
| 2560 | ZBounds(1)=UvData.ZMin; %minimum for the Z slider
|
---|
| 2561 | ZBounds(2)=UvData.ZMax;%maximum for the Z slider
|
---|
[72] | 2562 | UvData.Object{1}.Name='1-PLANE';
|
---|
| 2563 | UvData.Object{1}.enable_plot=1;
|
---|
[2] | 2564 | set_object(UvData.Object{1},PlotHandles,ZBounds);
|
---|
[61] | 2565 | set(handles.list_object_1,'Value',1);
|
---|
[2] | 2566 | %multilevel case (single menuplane in a 3D space)
|
---|
| 2567 | elseif isfield(UvData,'Z')
|
---|
| 2568 | if isfield(UvData,'CoordType')& isequal(UvData.CoordType,'phys') & isfield(UvData,'XmlData')
|
---|
| 2569 | XmlData=UvData.XmlData;
|
---|
| 2570 | if isfield(XmlData,'PlanePos')
|
---|
| 2571 | UvData.Object{1}.Coord=XmlData.PlanePos(UvData.ZIndex,:);
|
---|
| 2572 | end
|
---|
| 2573 | if isfield(XmlData,'PlaneAngle')
|
---|
| 2574 | siz=size(XmlData.PlaneAngle);
|
---|
| 2575 | indangle=min(siz(1),UvData.ZIndex);%take first angle if a single angle is defined (translating scanning)
|
---|
| 2576 | UvData.Object{1}.Phi=XmlData.PlaneAngle(indangle,1);
|
---|
| 2577 | UvData.Object{1}.Theta=XmlData.PlaneAngle(indangle,2);
|
---|
| 2578 | UvData.Object{1}.Psi=XmlData.PlaneAngle(indangle,3);
|
---|
| 2579 | end
|
---|
| 2580 | elseif isfield(UvData,'ZIndex')
|
---|
| 2581 | UvData.Object{1}.ZObject=UvData.ZIndex;
|
---|
| 2582 | end
|
---|
| 2583 | end
|
---|
| 2584 |
|
---|
| 2585 | %Plot the projections on all existing projection objects
|
---|
| 2586 | keeplim=get(handles.FixedLimits,'Value');
|
---|
| 2587 | %reset the min and max of scalar if only the mask is displayed
|
---|
| 2588 | if isfield(UvData,'Mask')&~isfield(UvData,'A')
|
---|
| 2589 | set(handles.MinA,'String','0')
|
---|
| 2590 | set(handles.MaxA,'String','255')
|
---|
| 2591 | end
|
---|
[65] | 2592 | IndexObj(1)=get(handles.list_object_1,'Value');
|
---|
| 2593 | if IndexObj(1)> numel(UvData.Object)
|
---|
| 2594 | IndexObj(1)=1;
|
---|
| 2595 | end
|
---|
| 2596 | IndexObj_2=get(handles.list_object_2,'Value');
|
---|
| 2597 | if IndexObj_2 <= numel(UvData.Object)
|
---|
| 2598 | IndexObj(2)=IndexObj_2;
|
---|
| 2599 | end
|
---|
[71] | 2600 | for imap=1:numel(IndexObj)
|
---|
| 2601 | iobj=IndexObj(imap);
|
---|
[65] | 2602 | if ~isempty(UvData.Object{iobj})%& isfield(Object{iobj},'plotaxes')& ishandle(Object{iobj}.plotaxes)
|
---|
[2] | 2603 | %Projeter les champs sur l'objet:*
|
---|
[65] | 2604 | ObjectData=proj_field(UvData.Field,UvData.Object{iobj},iobj);
|
---|
[2] | 2605 | %use of mask
|
---|
| 2606 | if isfield(ObjectData,'NbDim')&isequal(ObjectData.NbDim,2)
|
---|
| 2607 | if isfield(ObjectData,'Mask') & isfield(ObjectData,'A')
|
---|
| 2608 | flag_mask=double(ObjectData.Mask>200);%=0 for masked regions
|
---|
| 2609 | AX=ObjectData.AX;
|
---|
| 2610 | AY=ObjectData.AY;
|
---|
| 2611 | MaskX=ObjectData.MaskX;
|
---|
| 2612 | MaskY=ObjectData.MaskY;
|
---|
| 2613 | if ~isequal(MaskX,AX)|~isequal(MaskY,AY)
|
---|
| 2614 | nxy=size(flag_mask);
|
---|
| 2615 | sizpx=(ObjectData.MaskX(end)-ObjectData.MaskX(1))/(nxy(2)-1);%size of a mask pixel
|
---|
| 2616 | sizpy=(ObjectData.MaskY(1)-ObjectData.MaskY(end))/(nxy(1)-1);
|
---|
| 2617 | x_mask=[ObjectData.MaskX(1):sizpx:ObjectData.MaskX(end)]; % pixel x coordinates for image display
|
---|
| 2618 | y_mask=[ObjectData.MaskY(1):-sizpy:ObjectData.MaskY(end)];% pixel x coordinates for image display
|
---|
| 2619 | %project on the positions of the scalar
|
---|
| 2620 | npxy=size(ObjectData.A);
|
---|
| 2621 | dxy(1)=(ObjectData.AY(end)-ObjectData.AY(1))/(npxy(1)-1);%grid mesh in y
|
---|
| 2622 | dxy(2)=(ObjectData.AX(end)-ObjectData.AX(1))/(npxy(2)-1);%grid mesh in x
|
---|
| 2623 | xi=[ObjectData.AX(1):dxy(2):ObjectData.AX(end)];
|
---|
| 2624 | yi=[ObjectData.AY(1):dxy(1):ObjectData.AY(end)];
|
---|
| 2625 | [XI,YI]=meshgrid(xi,yi);% creates the matrix of regular coordinates
|
---|
| 2626 | flag_mask = interp2(x_mask,y_mask,flag_mask,XI,YI);
|
---|
| 2627 | end
|
---|
| 2628 | AClass=class(ObjectData.A);
|
---|
| 2629 | ObjectData.A=flag_mask.*double(ObjectData.A);
|
---|
| 2630 | ObjectData.A=feval(AClass,ObjectData.A);
|
---|
| 2631 | ind_off=[];
|
---|
| 2632 | if isfield(ObjectData,'ListVarName')
|
---|
| 2633 | for ilist=1:length(ObjectData.ListVarName)
|
---|
| 2634 | if isequal(ObjectData.ListVarName{ilist},'Mask')|isequal(ObjectData.ListVarName{ilist},'MaskX')|isequal(ObjectData.ListVarName{ilist},'MaskY')
|
---|
| 2635 | ind_off=[ind_off ilist];
|
---|
| 2636 | end
|
---|
| 2637 | end
|
---|
| 2638 | ObjectData.ListVarName(ind_off)=[];
|
---|
| 2639 | ObjectData.VarDimIndex(ind_off)=[];
|
---|
| 2640 | ind_off=[];
|
---|
| 2641 | for ilist=1:length(ObjectData.ListDimName)
|
---|
| 2642 | if isequal(ObjectData.ListDimName{ilist},'MaskX')|isequal(ObjectData.ListDimName{ilist},'MaskY')
|
---|
| 2643 | ind_off=[ind_off ilist];
|
---|
| 2644 | end
|
---|
| 2645 | end
|
---|
| 2646 | ObjectData.ListDimName(ind_off)=[];
|
---|
| 2647 | ObjectData.DimValue(ind_off)=[];
|
---|
| 2648 | end
|
---|
| 2649 | end
|
---|
| 2650 | end
|
---|
| 2651 | if ~isempty(ObjectData)
|
---|
| 2652 | haxes=[];%default
|
---|
[65] | 2653 | if isfield(UvData.Object{iobj},'plotaxes')
|
---|
| 2654 | haxes=UvData.Object{iobj}.plotaxes;%axes used for representing the projection on the object
|
---|
[2] | 2655 | end
|
---|
| 2656 | PosColorbar=[];%default: no colorbar
|
---|
| 2657 | if ishandle(haxes) & isequal(get(haxes,'Tag'),'axes3')& isfield(UvData,'PosColorbar')
|
---|
| 2658 | PosColorbar=UvData.PosColorbar;%prescribe the colorbar position on the uvmat interface
|
---|
| 2659 | else
|
---|
| 2660 | PosColorbar='*';%default position
|
---|
| 2661 | end
|
---|
| 2662 | PlotParam=read_plot_param(handles);%read plotting parameters on the uvmat interface
|
---|
| 2663 | [PlotType,ScalOut,UvData.Object{iobj}.plotaxes]=plot_field(ObjectData,haxes,PlotParam,keeplim,PosColorbar);
|
---|
| 2664 | if isequal(PlotType,'none')
|
---|
| 2665 | hget_field=findobj(allchild(0),'name','get_field');
|
---|
| 2666 | if isempty(hget_field)
|
---|
| 2667 | get_field([],ObjectData)% the projected field cannot be automatically plotted: use get_field to specify the variablesdelete(hget_field)
|
---|
| 2668 | else
|
---|
[59] | 2669 | errormsg='The field defined by get_field cannot be plotted';
|
---|
| 2670 | return
|
---|
[2] | 2671 | end
|
---|
| 2672 | end
|
---|
| 2673 | UvData.Object{iobj}.PlotParam=ScalOut; %record the plotting parameters
|
---|
[59] | 2674 | end
|
---|
[2] | 2675 | end
|
---|
| 2676 | end
|
---|
| 2677 |
|
---|
| 2678 | %display the updated plotting parameters for the base menuplane
|
---|
| 2679 | write_plot_param(handles,UvData.Object{1}.PlotParam);% update the display of the plotting parameters
|
---|
[74] | 2680 | UvData.NewSeries=0;% put to 0 the test for a new field series (set by RootPath_callback)
|
---|
[45] | 2681 | set(handles.uvmat,'UserData',UvData)
|
---|
[2] | 2682 |
|
---|
| 2683 | %update the mask
|
---|
| 2684 | if isequal(get(handles.mask_test,'Value'),1)%if the mask option is on
|
---|
| 2685 | update_mask(handles,num_i1,num_i2);
|
---|
| 2686 | end
|
---|
| 2687 |
|
---|
| 2688 | %prepare the menus of histograms (for the whole menuvolume in 3D case)
|
---|
| 2689 | menu_histo=(UvData.Field.ListVarName)';
|
---|
| 2690 | ind_bad=[];
|
---|
| 2691 | nb_histo=1;
|
---|
| 2692 | for ivar=1:numel(menu_histo)
|
---|
| 2693 | if isfield(UvData.Field,'VarAttribute') && numel(UvData.Field.VarAttribute)>=ivar && isfield(UvData.Field.VarAttribute{ivar},'Role')
|
---|
| 2694 | Role=UvData.Field.VarAttribute{ivar}.Role;
|
---|
| 2695 | switch Role
|
---|
| 2696 | case {'coord_x','coord_y','coord_z','dimvar'}
|
---|
| 2697 | ind_bad=[ind_bad ivar];
|
---|
| 2698 | case {'vector_y'}
|
---|
| 2699 | nb_histo=nb_histo+1;
|
---|
| 2700 | end
|
---|
| 2701 | end
|
---|
| 2702 | DimCell=UvData.Field.VarDimName{ivar};
|
---|
| 2703 | DimName='';
|
---|
| 2704 | if ischar(DimCell)
|
---|
| 2705 | DimName=DimCell;
|
---|
| 2706 | elseif iscell(DimCell)&& numel(DimCell)==1
|
---|
| 2707 | DimName=DimCell{1};
|
---|
| 2708 | end
|
---|
| 2709 | if strcmp(DimName,menu_histo{ivar})
|
---|
| 2710 | ind_bad=[ind_bad ivar];
|
---|
| 2711 | end
|
---|
| 2712 | end
|
---|
| 2713 | menu_histo(ind_bad)=[];
|
---|
| 2714 | test_v=0;
|
---|
| 2715 | if ~isempty(menu_histo)
|
---|
| 2716 | set(handles.histo1_menu,'Value',1)
|
---|
| 2717 | set(handles.histo1_menu,'String',menu_histo)
|
---|
[59] | 2718 | histo1_menu_Callback(handles.histo1_menu, [], handles)
|
---|
[2] | 2719 | if nb_histo > 1
|
---|
| 2720 | test_v=1;
|
---|
| 2721 | set(handles.histo2_menu,'Visible','on')
|
---|
| 2722 | set(handles.histo_v,'Visible','on')
|
---|
| 2723 | set(handles.histo2_menu,'String',menu_histo)
|
---|
| 2724 | set(handles.histo2_menu,'Value',2)
|
---|
[59] | 2725 | histo2_menu_Callback(handles.histo2_menu,[], handles)
|
---|
[2] | 2726 | end
|
---|
| 2727 | end
|
---|
| 2728 | if ~test_v
|
---|
| 2729 | set(handles.histo2_menu,'Visible','off')
|
---|
| 2730 | set(handles.histo_v,'Visible','off')
|
---|
| 2731 | cla(handles.histo_v)
|
---|
| 2732 | set(handles.histo2_menu,'Value',1)
|
---|
| 2733 | end
|
---|
| 2734 |
|
---|
| 2735 | %display time
|
---|
| 2736 | testimedoc=0;
|
---|
| 2737 | if isfield(UvData,'XmlData') && isfield(UvData.XmlData,'Time')
|
---|
[89] | 2738 | if isempty(num_i2)||isnan(num_i2)
|
---|
[2] | 2739 | num_i2=num_i1;
|
---|
| 2740 | end
|
---|
[89] | 2741 | if isempty(num_j1)||isnan(num_j1)
|
---|
[2] | 2742 | num_j1=1;
|
---|
| 2743 | end
|
---|
[89] | 2744 | if isempty(num_j2)||isnan(num_j2)
|
---|
[2] | 2745 | num_j2=num_j1;
|
---|
| 2746 | end
|
---|
| 2747 | siz=size(UvData.XmlData.Time);
|
---|
| 2748 | if siz(1)>=max(num_i1,num_i2) & siz(2)>=max(num_j1,num_j2)
|
---|
| 2749 | abstime=(UvData.XmlData.Time(num_i1,num_j1)+UvData.XmlData.Time(num_i2,num_j2))/2;%overset the time read from files
|
---|
| 2750 | dt=(UvData.XmlData.Time(num_i2,num_j2)-UvData.XmlData.Time(num_i1,num_j1));
|
---|
| 2751 | testimedoc=1;
|
---|
| 2752 | end
|
---|
| 2753 | end
|
---|
| 2754 | if isfield(UvData,'XmlData_1') && isfield(UvData.XmlData_1,'Time')
|
---|
| 2755 | [P,F,str1,str2,str_a,str_b,E,NomType]=name2display(['xx' get(handles.FileIndex_1,'String') get(handles.FileExt_1,'String')]);
|
---|
| 2756 | num_i2=str2num(str2);
|
---|
| 2757 | if isempty(num_i2)
|
---|
| 2758 | num_i2=num_i1;
|
---|
| 2759 | end
|
---|
| 2760 | num_j1=str2num(str_a);
|
---|
| 2761 | if isempty(num_j1)
|
---|
| 2762 | num_j1=1;
|
---|
| 2763 | end
|
---|
| 2764 | num_j2=str2num(str_b);
|
---|
| 2765 | if isempty(num_j2)
|
---|
| 2766 | num_j2=num_j1;
|
---|
| 2767 | end
|
---|
| 2768 | num_i1=str2num(str1);
|
---|
| 2769 | siz=size(UvData.XmlData_1.Time);
|
---|
| 2770 | if siz(1)>=max(num_i1,num_i2) & siz(2)>=max(num_j1,num_j2)
|
---|
| 2771 | 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
|
---|
| 2772 | end
|
---|
| 2773 | end
|
---|
| 2774 | set(handles.abs_time,'String',num2str(abstime,4))
|
---|
| 2775 | set(handles.abs_time_1,'String',num2str(abstime_1,4))
|
---|
| 2776 | if testimedoc && isfield(UvData,'dt')
|
---|
| 2777 | dt=UvData.dt;
|
---|
| 2778 | end
|
---|
| 2779 | if isequal(dt,0)
|
---|
| 2780 | set(handles.Dt_txt,'String','')
|
---|
| 2781 | else
|
---|
| 2782 | if ~(isfield(UvData,'TimeUnit') && ~isempty(UvData.TimeUnit))
|
---|
| 2783 | set(handles.Dt_txt,'String',['Dt=' num2str(1000*dt,3) ' 10^(-3)'] )
|
---|
| 2784 | else
|
---|
| 2785 | set(handles.Dt_txt,'String',['Dt=' num2str(1000*dt,3) ' m' UvData.TimeUnit] )
|
---|
| 2786 | end
|
---|
| 2787 | end
|
---|
[89] | 2788 | %update the input file name in the get_field GUI
|
---|
| 2789 | if isequal(FieldName,'get_field...')
|
---|
| 2790 | set(hhget_field.inputfile,'String',filename)
|
---|
| 2791 | Tabchar={''};%default
|
---|
| 2792 | Tabcell=[];
|
---|
| 2793 | if isfield(Field{1},'ListGlobalAttribute')& ~isempty(Field{1}.ListGlobalAttribute)
|
---|
| 2794 | for iline=1:length(Field{1}.ListGlobalAttribute)
|
---|
| 2795 | Tabcell{iline,1}=Field{1}.ListGlobalAttribute{iline};
|
---|
| 2796 | if isfield(Field{1}, Field{1}.ListGlobalAttribute{iline})
|
---|
| 2797 | eval(['val=Field{1}.' Field{1}.ListGlobalAttribute{iline} ';'])
|
---|
| 2798 | if ischar(val);
|
---|
| 2799 | Tabcell{iline,2}=val;
|
---|
| 2800 | else
|
---|
| 2801 | Tabcell{iline,2}=num2str(val);
|
---|
| 2802 | end
|
---|
| 2803 | end
|
---|
| 2804 | end
|
---|
| 2805 | if ~isempty(Tabcell)
|
---|
| 2806 | Tabchar=cell2tab(Tabcell,'=');
|
---|
| 2807 | Tabchar=[{''};Tabchar];
|
---|
| 2808 | end
|
---|
| 2809 | end
|
---|
| 2810 | set(hhget_field.attributes,'String',Tabchar);%update list of global attributes in get_field
|
---|
| 2811 | end
|
---|
| 2812 | if isequal(FieldName_1,'get_field...')
|
---|
| 2813 | set(hhget_field_1.inputfile,'String',filename_1)
|
---|
| 2814 | Tabchar={''};%default
|
---|
| 2815 | Tabcell=[];
|
---|
| 2816 | if isfield(Field{2},'ListGlobalAttribute')& ~isempty(Field{2}.ListGlobalAttribute)
|
---|
| 2817 | for iline=1:length(Field{2}.ListGlobalAttribute)
|
---|
| 2818 | Tabcell{iline,1}=Field{2}.ListGlobalAttribute{iline};
|
---|
| 2819 | if isfield(Field{2}, Field{2}.ListGlobalAttribute{iline})
|
---|
| 2820 | eval(['val=Field{2}.' Field{2}.ListGlobalAttribute{iline} ';'])
|
---|
| 2821 | if ischar(val);
|
---|
| 2822 | Tabcell{iline,2}=val;
|
---|
| 2823 | else
|
---|
| 2824 | Tabcell{iline,2}=num2str(val);
|
---|
| 2825 | end
|
---|
| 2826 | end
|
---|
| 2827 | end
|
---|
| 2828 | if ~isempty(Tabcell)
|
---|
| 2829 | Tabchar=cell2tab(Tabcell,'=');
|
---|
| 2830 | Tabchar=[{''};Tabchar];
|
---|
| 2831 | end
|
---|
| 2832 | end
|
---|
| 2833 | set(hhget_field_1.attributes,'String',Tabchar);%update list of global attributes in get_field
|
---|
| 2834 | end
|
---|
[2] | 2835 |
|
---|
| 2836 |
|
---|
| 2837 |
|
---|
| 2838 | %-------------------------------------------------------------------
|
---|
| 2839 | % --- translate coordinate to matrix index
|
---|
| 2840 | %-------------------------------------------------------------------
|
---|
| 2841 | function [indx,indy]=pos2ind(x0,rangx0,nxy)
|
---|
| 2842 | indx=1+round((nxy(2)-1)*(x0-rangx0(1))/(rangx0(2)-rangx0(1)));% index x of pixel
|
---|
| 2843 | indy=1+round((nxy(1)-1)*(y12-rangy0(1))/(rangy0(2)-rangy0(1)));% index y of pixel
|
---|
| 2844 |
|
---|
| 2845 | %-------------------------------------------------------------------
|
---|
| 2846 | % --- Executes on button press in 'FixedLimits'.
|
---|
| 2847 | %-------------------------------------------------------------------
|
---|
| 2848 | function FixedLimits_Callback(hObject, eventdata, handles)
|
---|
| 2849 | test=get(handles.FixedLimits,'Value');
|
---|
| 2850 | if test
|
---|
| 2851 | set(handles.FixedLimits,'BackgroundColor',[1 1 0])
|
---|
| 2852 | else
|
---|
| 2853 | set(handles.FixedLimits,'BackgroundColor',[0.7 0.7 0.7])
|
---|
[84] | 2854 | update_plot(handles);
|
---|
[2] | 2855 | end
|
---|
| 2856 |
|
---|
| 2857 | %-------------------------------------------------------------------
|
---|
| 2858 | % --- Executes on button press in auto_xy.
|
---|
| 2859 | function auto_xy_Callback(hObject, eventdata, handles)
|
---|
| 2860 | test=get(handles.auto_xy,'Value');
|
---|
| 2861 | if test
|
---|
| 2862 | set(handles.auto_xy,'BackgroundColor',[1 1 0])
|
---|
| 2863 | cla(handles.axes3)
|
---|
[89] | 2864 | update_plot(handles);
|
---|
[2] | 2865 | else
|
---|
| 2866 | set(handles.auto_xy,'BackgroundColor',[0.7 0.7 0.7])
|
---|
[89] | 2867 | update_plot(handles);
|
---|
[2] | 2868 | % axis(handles.axes3,'image')
|
---|
| 2869 | end
|
---|
| 2870 |
|
---|
| 2871 |
|
---|
| 2872 | %-------------------------------------------------------------------
|
---|
| 2873 |
|
---|
| 2874 | %-------------------------------------------------------------------
|
---|
| 2875 | % --- Executes on button press in 'zoom'.
|
---|
| 2876 | %-------------------------------------------------------------------
|
---|
| 2877 | function zoom_Callback(hObject, eventdata, handles)
|
---|
[60] | 2878 |
|
---|
[2] | 2879 | if (get(handles.zoom,'Value') == 1);
|
---|
| 2880 | set(handles.zoom,'BackgroundColor',[1 1 0])
|
---|
| 2881 | set(handles.FixedLimits,'Value',1)% propose by default fixed limits for the plotting axes
|
---|
[60] | 2882 | set(handles.FixedLimits,'BackgroundColor',[1 1 0])
|
---|
[2] | 2883 | else
|
---|
| 2884 | set(handles.zoom,'BackgroundColor',[0.7 0.7 0.7])
|
---|
| 2885 | end
|
---|
| 2886 |
|
---|
[60] | 2887 |
|
---|
[2] | 2888 | %-------------------------------------------------------------------
|
---|
| 2889 | %----Executes on button press in 'record': records the current flags of manual correction.
|
---|
| 2890 | %-------------------------------------------------------------------
|
---|
| 2891 | function record_Callback(hObject, eventdata, handles)
|
---|
| 2892 | % [filebase,num_i1,num_j1,num_i2,num_j2,Ext,NomType,SubDir]=read_input_file(handles);
|
---|
| 2893 | filename=read_file_boxes(handles);
|
---|
| 2894 | AxeData=get(gca,'UserData');
|
---|
| 2895 | [erread,message]=fileattrib(filename);
|
---|
[55] | 2896 | if ~isempty(message) && ~isequal(message.UserWrite,1)
|
---|
[2] | 2897 | msgbox_uvmat('ERROR',['no writting access to ' filename])
|
---|
| 2898 | return
|
---|
| 2899 | end
|
---|
| 2900 | test_civ2=isequal(get(handles.civ2,'BackgroundColor'),[1 1 0]);
|
---|
[55] | 2901 | test_civ1=isequal(get(handles.civ1,'BackgroundColor'),[1 1 0]);
|
---|
| 2902 | if ~test_civ2 && ~test_civ1
|
---|
| 2903 | msgbox_uvmat('ERROR','manual correction only possible for CIV1 or CIV2 velocity fields')
|
---|
[2] | 2904 | end
|
---|
[55] | 2905 | if test_civ2
|
---|
| 2906 | nbname='nb_vectors2';
|
---|
| 2907 | flagname='vec2_FixFlag';
|
---|
| 2908 | attrname='fix2';
|
---|
| 2909 | end
|
---|
| 2910 | if test_civ1
|
---|
| 2911 | nbname='nb_vectors';
|
---|
| 2912 | flagname='vec_FixFlag';
|
---|
| 2913 | attrname='fix';
|
---|
| 2914 | end
|
---|
| 2915 | %write fix flags in the netcdf file
|
---|
| 2916 | hhh=which('netcdf.open');% look for built-in matlab netcdf library
|
---|
| 2917 | if ~isequal(hhh,'')% case of new builtin Matlab netcdf library
|
---|
| 2918 | nc=netcdf.open(filename,'NC_WRITE');
|
---|
| 2919 | netcdf.reDef(nc)
|
---|
| 2920 | netcdf.putAtt(nc,netcdf.getConstant('NC_GLOBAL'),attrname,1)
|
---|
| 2921 | dimid = netcdf.inqDimID(nc,nbname);
|
---|
| 2922 | try
|
---|
| 2923 | varid = netcdf.inqVarID(nc,flagname);% look for already existing fixflag variable
|
---|
| 2924 | catch
|
---|
| 2925 | varid=netcdf.defVar(nc,flagname,'double',dimid);%create fixflag variable if it does not exist
|
---|
| 2926 | end
|
---|
| 2927 | netcdf.endDef(nc)
|
---|
| 2928 | netcdf.putVar(nc,varid,AxeData.FF);
|
---|
| 2929 | netcdf.close(nc)
|
---|
| 2930 | else %old netcdf library
|
---|
[56] | 2931 | netcdf_toolbox(filename,AxeData,attrname,nbname,flagname)
|
---|
[55] | 2932 | end
|
---|
[2] | 2933 |
|
---|
[56] | 2934 | function netcdf_toolbox(filename,AxeData,attrname,nbname,flagname)
|
---|
| 2935 | nc=netcdf(filename,'write'); %open netcdf file
|
---|
| 2936 | result=redef(nc);
|
---|
| 2937 | eval(['nc.' attrname '=1;']);
|
---|
| 2938 | theDim=nc(nbname) ;% get the number of velocity vectors
|
---|
| 2939 | nb_vectors=size(theDim);
|
---|
| 2940 | var_FixFlag=ncvar(flagname,nc);% var_FixFlag will be written as the netcdf variable vec_FixFlag
|
---|
| 2941 | var_FixFlag(1:nb_vectors)=AxeData.FF;%
|
---|
| 2942 | fin=close(nc);
|
---|
[2] | 2943 |
|
---|
| 2944 |
|
---|
| 2945 | %-------------------------------------------------------------------
|
---|
| 2946 | %determines the fields to read from the interface
|
---|
| 2947 | %------------------------------------------------------------------
|
---|
| 2948 | function [VelType,civ]=setfield(handles)
|
---|
| 2949 |
|
---|
| 2950 | VelType=[]; %default
|
---|
| 2951 | if (get(handles.civ1,'Value') == 1);
|
---|
| 2952 | VelType='civ1';
|
---|
| 2953 | % interp1
|
---|
| 2954 | elseif (get(handles.interp1,'Value') == 1);
|
---|
| 2955 | VelType='interp1';
|
---|
| 2956 | % filter1
|
---|
| 2957 | elseif (get(handles.filter1,'Value') == 1);
|
---|
| 2958 | VelType='filter1';
|
---|
| 2959 | % CIV2
|
---|
| 2960 | elseif (get(handles.civ2,'Value') == 1);
|
---|
| 2961 | VelType='civ2';
|
---|
| 2962 | % interp2
|
---|
| 2963 | elseif (get(handles.interp2,'Value') == 1);
|
---|
| 2964 | VelType='interp2';
|
---|
| 2965 | % filter2
|
---|
| 2966 | elseif (get(handles.filter2,'Value') == 1);
|
---|
| 2967 | VelType='filter2';
|
---|
| 2968 | end
|
---|
| 2969 |
|
---|
| 2970 | if isequal(get(handles.filter2,'Visible'),'on');
|
---|
| 2971 | civ=6;
|
---|
| 2972 | % interp1
|
---|
| 2973 | elseif isequal(get(handles.interp2,'Visible'),'on');
|
---|
| 2974 | civ=5;
|
---|
| 2975 | % filter1
|
---|
| 2976 | elseif isequal(get(handles.civ2,'Visible'),'on');
|
---|
| 2977 | civ=4;
|
---|
| 2978 | % CIV2
|
---|
| 2979 | elseif isequal(get(handles.filter1,'Visible'),'on');
|
---|
| 2980 | civ=3;
|
---|
| 2981 | % interp2
|
---|
| 2982 | elseif isequal(get(handles.interp1,'Visible'),'on');
|
---|
| 2983 | civ=2;
|
---|
| 2984 | % filter2
|
---|
| 2985 | elseif isequal(get(handles.civ1,'Visible'),'on');
|
---|
| 2986 | civ=1;
|
---|
| 2987 | else
|
---|
| 2988 | civ=0;
|
---|
| 2989 | end
|
---|
| 2990 |
|
---|
| 2991 | %-------------------------------------------------------------------
|
---|
| 2992 | %determines the veltype of the second field to read from the iinterface
|
---|
| 2993 | %------------------------------------------------------------------
|
---|
| 2994 | function VelType=setfield_1(handles)
|
---|
| 2995 |
|
---|
| 2996 | VelType=[]; %default
|
---|
| 2997 | if (get(handles.civ1_1,'Value') == 1);
|
---|
| 2998 | VelType='civ1';
|
---|
| 2999 | % interp1
|
---|
| 3000 | elseif (get(handles.interp1_1,'Value') == 1);
|
---|
| 3001 | VelType='interp1';
|
---|
| 3002 | % filter1
|
---|
| 3003 | elseif (get(handles.filter1_1,'Value') == 1);
|
---|
| 3004 | VelType='filter1';
|
---|
| 3005 | % CIV2
|
---|
| 3006 | elseif (get(handles.civ2_1,'Value') == 1);
|
---|
| 3007 | VelType='civ2';
|
---|
| 3008 | % interp2
|
---|
| 3009 | elseif (get(handles.interp2_1,'Value') == 1);
|
---|
| 3010 | VelType='interp2';
|
---|
| 3011 | % filter2
|
---|
| 3012 | elseif (get(handles.filter2_1,'Value') == 1);
|
---|
| 3013 | VelType='filter2';
|
---|
| 3014 | end
|
---|
| 3015 |
|
---|
| 3016 |
|
---|
| 3017 | %---------------------------------------------------
|
---|
| 3018 | % --- Executes on button press in SubField
|
---|
| 3019 | function SubField_Callback(hObject, eventdata, handles)
|
---|
| 3020 | huvmat=get(handles.run0,'parent');
|
---|
| 3021 | UvData=get(huvmat,'UserData');
|
---|
| 3022 | if get(handles.SubField,'Value')==0% if the subfield button is desactivated
|
---|
| 3023 | set(handles.RootPath_1,'String','')
|
---|
| 3024 | set(handles.RootFile_1,'String','')
|
---|
| 3025 | set(handles.SubDir_1,'String','');
|
---|
| 3026 | set(handles.FileIndex_1,'String','');
|
---|
| 3027 | set(handles.FileExt_1,'String','');
|
---|
| 3028 | set(handles.RootPath_1,'Visible','off')
|
---|
| 3029 | set(handles.RootFile_1,'Visible','off')
|
---|
| 3030 | set(handles.SubDir_1,'Visible','off');
|
---|
| 3031 | set(handles.FileIndex_1,'Visible','off');
|
---|
| 3032 | set(handles.FileExt_1,'Visible','off');
|
---|
| 3033 | set(handles.Fields_1,'Value',1);%set to blank state
|
---|
| 3034 | set_veltype_display([handles.civ1_1 handles.interp1_1 handles.filter1_1 ...
|
---|
| 3035 | handles.civ2_1 handles.interp2_1 handles.filter2_1],0)
|
---|
| 3036 | if isfield(UvData,'XmlData_1')
|
---|
| 3037 | UvData=rmfield(UvData,'XmlData_1');
|
---|
| 3038 | end
|
---|
| 3039 | set(huvmat,'UserData',UvData);
|
---|
| 3040 | run0_Callback(hObject, eventdata, handles); %run
|
---|
| 3041 | else
|
---|
| 3042 | MenuBrowse_1_Callback(hObject, eventdata, handles)
|
---|
| 3043 | end
|
---|
| 3044 |
|
---|
[89] | 3045 | %------------------------------------------------------------------------
|
---|
| 3046 | % --- read the data displayed for the input rootfile windows (new)
|
---|
[2] | 3047 | function [FileName,RootPath,FileBase,FileIndices,FileExt,SubDir]=read_file_boxes(handles)
|
---|
[89] | 3048 | %------------------------------------------------------------------------
|
---|
[2] | 3049 | RootPath=get(handles.RootPath,'String');
|
---|
| 3050 | FileName=RootPath; %default
|
---|
| 3051 | SubDir=get(handles.SubDir,'String');
|
---|
| 3052 | if ~isempty(SubDir) && ~isequal(SubDir,'')
|
---|
| 3053 | if (isequal(SubDir(1),'/')|| isequal(SubDir(1),'\'))
|
---|
| 3054 | SubDir(1)=[]; %suppress possible / or \ separator
|
---|
| 3055 | end
|
---|
| 3056 | FileName=fullfile(RootPath,SubDir);
|
---|
| 3057 | end
|
---|
| 3058 | RootFile=get(handles.RootFile,'String');
|
---|
| 3059 | if ~isempty(RootFile) && ~isequal(RootFile,'')
|
---|
| 3060 | if (isequal(RootFile(1),'/')|| isequal(RootFile(1),'\'))
|
---|
| 3061 | RootFile(1)=[]; %suppress possible / or \ separator
|
---|
| 3062 | end
|
---|
| 3063 | FileName=fullfile(FileName,RootFile);
|
---|
| 3064 | end
|
---|
| 3065 | FileBase=fullfile(RootPath,RootFile);
|
---|
| 3066 | FileIndices=get(handles.FileIndex,'String');
|
---|
| 3067 | FileExt=get(handles.FileExt,'String');
|
---|
| 3068 | FileName=[FileName FileIndices FileExt];
|
---|
| 3069 |
|
---|
[85] | 3070 | %------------------------------------------------------------------------
|
---|
| 3071 | % ---- read the data displayed for the second input rootfile windows
|
---|
[2] | 3072 | function [FileName_1,RootPath_1,FileBase_1,FileIndices_1,FileExt_1,SubDir_1]=read_file_boxes_1(handles)
|
---|
[85] | 3073 | %------------------------------------------------------------------------
|
---|
[86] | 3074 | RootPath_1=get(handles.RootPath_1,'String'); % read the data from the file1_input window
|
---|
[85] | 3075 | if isequal(get(handles.RootPath_1,'Visible'),'off') || isequal(RootPath_1,'"')
|
---|
| 3076 | RootPath_1=get(handles.RootPath,'String');
|
---|
| 3077 | end;
|
---|
[2] | 3078 | FileName_1=RootPath_1; %default
|
---|
| 3079 | SubDir_1=get(handles.SubDir_1,'String');
|
---|
[85] | 3080 | if isequal(get(handles.SubDir_1,'Visible'),'off')|| isequal(SubDir_1,'"')
|
---|
[2] | 3081 | SubDir_1=get(handles.SubDir,'String');
|
---|
| 3082 | end
|
---|
[85] | 3083 | if numel(SubDir_1)>=1
|
---|
[2] | 3084 | if (isequal(SubDir_1(1),'/')|| isequal(SubDir_1(1),'\'))
|
---|
| 3085 | SubDir_1(1)=[]; %suppress possible / or \ separator
|
---|
| 3086 | end
|
---|
| 3087 | FileName_1=fullfile(RootPath_1,SubDir_1);
|
---|
| 3088 | end
|
---|
| 3089 | RootFile_1=get(handles.RootFile_1,'String');
|
---|
[85] | 3090 | if isequal(get(handles.RootFile_1,'Visible'),'off') || isequal(RootFile_1,'"')
|
---|
| 3091 | RootFile_1=get(handles.RootFile,'String');
|
---|
| 3092 | end
|
---|
| 3093 | if numel(RootFile_1)>=1
|
---|
[2] | 3094 | if ~(isequal(RootFile_1(1),'/')|isequal(RootFile_1(1),'\'))
|
---|
| 3095 | RootFile_1(1)=[];%suppress possible / or \ separator
|
---|
| 3096 | end
|
---|
| 3097 | FileName_1=fullfile(FileName_1,RootFile_1);
|
---|
| 3098 | end
|
---|
| 3099 | FileBase_1=fullfile(RootPath_1,RootFile_1);
|
---|
[85] | 3100 | if isequal(get(handles.FileIndex_1,'Visible'),'off')
|
---|
| 3101 | FileIndices_1=get(handles.FileIndex,'String');
|
---|
| 3102 | else
|
---|
| 3103 | FileIndices_1=get(handles.FileIndex_1,'String');
|
---|
| 3104 | end
|
---|
[2] | 3105 | FileExt_1=get(handles.FileExt_1,'String');
|
---|
| 3106 | if isequal(FileExt_1,'"'),FileExt_1=get(handles.FileExt,'String'); end;
|
---|
| 3107 | FileName_1=[FileName_1 FileIndices_1 FileExt_1];
|
---|
| 3108 |
|
---|
[85] | 3109 | %------------------------------------------------------------------------
|
---|
[2] | 3110 | % --- Executes on menu selection Fields
|
---|
| 3111 | function Fields_Callback(hObject, eventdata, handles)
|
---|
[85] | 3112 | %------------------------------------------------------------------------
|
---|
[2] | 3113 | list_fields=get(handles.Fields,'String');% list menu fields
|
---|
| 3114 | index_fields=get(handles.Fields,'Value');% selected string index
|
---|
| 3115 | field= list_fields{index_fields(1)}; % selected string
|
---|
| 3116 | if isequal(field,'get_field...')
|
---|
| 3117 | veltype_handles=[handles.civ1 handles.interp1 handles.filter1 handles.civ2 handles.interp2 handles.filter2];
|
---|
| 3118 | set_veltype_display(veltype_handles,0) % unvisible civ buttons
|
---|
| 3119 | filename=read_file_boxes(handles);
|
---|
[89] | 3120 | hget_field=findobj(allchild(0),'name','uvmat_field');
|
---|
| 3121 | if isempty(hget_field)
|
---|
| 3122 | hget_field=get_field(filename);
|
---|
| 3123 | set(hget_field,'Name','uvmat_field')
|
---|
[2] | 3124 | end
|
---|
| 3125 | return %no action
|
---|
| 3126 | end
|
---|
| 3127 | list_fields=get(handles.Fields_1,'String');% list menu fields
|
---|
| 3128 | index_fields=get(handles.Fields_1,'Value');% selected string index
|
---|
| 3129 | field_1= list_fields{index_fields(1)}; % selected string
|
---|
[59] | 3130 | UvData=get(handles.uvmat,'UserData');
|
---|
[2] | 3131 |
|
---|
| 3132 | %read the rootfile input display
|
---|
[82] | 3133 | [FileName,RootPath,FileBase,FileIndices,FileExt]=read_file_boxes(handles);
|
---|
[2] | 3134 | [P,F,str1,str2,str_a,str_b,E,NomType]=name2display(['xxx' get(handles.FileIndex,'String') FileExt]);
|
---|
| 3135 | NomTypeNew=NomType;%default
|
---|
| 3136 | if isequal(field,'image')
|
---|
| 3137 | % transform netc type to the corresponding image type
|
---|
[85] | 3138 | % if isequal(NomType,'_i1-i2_j')||isequal(NomType,'_i_j1-j2')|| isequal(NomType,'#_ab')|| isequal(NomType,'_i1-i2')
|
---|
| 3139 | % UvData.SubDir=get(handles.SubDir,'String'); %preserve the subdir in memory
|
---|
| 3140 | % if ~isempty(UvData.SubDir) && (isequal(UvData.SubDir(1),'/')||isequal(UvData.SubDir(1),'/'))
|
---|
| 3141 | % UvData.SubDir(1)=[];
|
---|
| 3142 | % end
|
---|
| 3143 | % set(handles.SubDir,'String','')
|
---|
| 3144 | % set(handles.FileExt,'String','.png');
|
---|
[45] | 3145 | if isequal(NomType,'_i1-i2_j')||isequal(NomType,'_i_j1-j2')
|
---|
[2] | 3146 | NomTypeNew='_i_j';
|
---|
| 3147 | elseif isequal(NomType,'#_ab')
|
---|
| 3148 | NomTypeNew='#a';
|
---|
| 3149 | elseif isequal(NomType,'_i1-i2')
|
---|
| 3150 | NomTypeNew='_i';
|
---|
| 3151 | end
|
---|
[86] | 3152 | imagename=name_generator(FileBase,str2double(str1),str2double(str_a),'.png',NomTypeNew,1,str2double(str2),str2double(str_b),'');
|
---|
[85] | 3153 | if ~exist(imagename,'file')
|
---|
| 3154 | [FileName,PathName] = uigetfile( ...
|
---|
| 3155 | {'*.png;*.jpg;*.tif;*.avi;*.AVI;*.vol', ' (*.png, .tif, *.avi,*.vol)';
|
---|
| 3156 | '*.jpg',' jpeg image files'; ...
|
---|
| 3157 | '*.png','.png image files'; ...
|
---|
| 3158 | '*.tif','.tif image files'; ...
|
---|
| 3159 | '*.avi;*.AVI','.avi movie files'; ...
|
---|
| 3160 | '*.vol','.volume images (png)'; ...
|
---|
| 3161 | '*.*', 'All Files (*.*)'}, ...
|
---|
[86] | 3162 | 'Pick an image',imagename);
|
---|
[85] | 3163 | % display the selected field and related information
|
---|
| 3164 | imagename=[PathName FileName];
|
---|
| 3165 | end
|
---|
| 3166 | display_file_name(hObject, eventdata, handles,imagename)%display the image
|
---|
| 3167 | return
|
---|
| 3168 | % end
|
---|
| 3169 | % veltype_handles=[handles.civ1 handles.interp1 handles.filter1 handles.civ2 handles.interp2 handles.filter2];
|
---|
| 3170 | % set_veltype_display(veltype_handles,0) % unvisible civ buttons
|
---|
[2] | 3171 | else
|
---|
| 3172 | ext=get(handles.FileExt,'String');
|
---|
| 3173 | if ~isequal(ext,'.nc') %find the new NomType if the previous display was not already a netcdf file
|
---|
[85] | 3174 | [FileName,PathName] = uigetfile( ...
|
---|
| 3175 | {'*.nc', ' (*.nc)';
|
---|
| 3176 | '*.nc',' netcdf files'; ...
|
---|
| 3177 | '*.*', 'All Files (*.*)'}, ...
|
---|
[86] | 3178 | 'Pick a netcdf file',FileBase);
|
---|
[85] | 3179 | % display the selected field and related information
|
---|
| 3180 | filename=[PathName FileName];
|
---|
| 3181 | display_file_name(hObject, eventdata, handles,filename)
|
---|
| 3182 | return
|
---|
| 3183 | % MenuBrowse_Callback(hObject, eventdata, handles)
|
---|
[2] | 3184 | end
|
---|
| 3185 | if isequal(field,'vort') || isequal(field,'div') || isequal(field,'strain')
|
---|
| 3186 | set(handles.civ1,'BackgroundColor',[0.702 0.702 0.702]) % put their color to grey
|
---|
| 3187 | set(handles.civ2,'BackgroundColor',[0.702 0.702 0.702])
|
---|
| 3188 | set(handles.interp1,'BackgroundColor',[0.702 0.702 0.702])
|
---|
| 3189 | set(handles.interp2,'BackgroundColor',[0.702 0.702 0.702])
|
---|
| 3190 | elseif isequal(field,'more...');
|
---|
| 3191 | set(handles.civ1,'BackgroundColor',[0.702 0.702 0.702]) % put their color to grey
|
---|
| 3192 | set(handles.civ2,'BackgroundColor',[0.702 0.702 0.702])
|
---|
| 3193 | str=calc_field;%get the list of available scalars by the function calc_scal
|
---|
[45] | 3194 | [ind_answer] = listdlg('PromptString','Select a file:',...
|
---|
[2] | 3195 | 'SelectionMode','single',...
|
---|
| 3196 | 'ListString',str);
|
---|
| 3197 | % edit the choice in the field and action menu
|
---|
| 3198 | scalar=cell2mat(str(ind_answer));
|
---|
| 3199 | menu=update_menu(handles.Fields,scalar);
|
---|
| 3200 | menu=[{''};menu];
|
---|
| 3201 | set(handles.Fields_1,'String',menu);% store the selected scalar type
|
---|
| 3202 | end
|
---|
| 3203 | end
|
---|
[45] | 3204 | indices=name_generator('',str2double(str1),str2double(str_a),'',NomTypeNew,1,str2double(str2),str2double(str_b),'');
|
---|
[2] | 3205 | set(handles.FileIndex,'String',indices)
|
---|
| 3206 | set(handles.FileIndex,'UserData',NomTypeNew)
|
---|
| 3207 | %common to Fields_1_Callback
|
---|
[45] | 3208 | if isequal(field,'image')||isequal(field_1,'image')
|
---|
[2] | 3209 | set(handles.npx_title,'Visible','on')% visible npx,pxcm... buttons
|
---|
| 3210 | set(handles.npy_title,'Visible','on')
|
---|
| 3211 | set(handles.npx,'Visible','on')
|
---|
| 3212 | set(handles.npy,'Visible','on')
|
---|
| 3213 | else
|
---|
| 3214 | set(handles.npx_title,'Visible','off')% visible npx,pxcm... buttons
|
---|
| 3215 | set(handles.npy_title,'Visible','off')
|
---|
| 3216 | set(handles.npx,'Visible','off')
|
---|
| 3217 | set(handles.npy,'Visible','off')
|
---|
| 3218 | end
|
---|
| 3219 | setfield(handles);% update the field structure ('civ1'....)
|
---|
| 3220 |
|
---|
[45] | 3221 | if ~isfield(UvData,'NewSeries')||isequal(UvData.NewSeries,0)
|
---|
[2] | 3222 | run0_Callback(hObject, eventdata, handles)
|
---|
| 3223 | end
|
---|
| 3224 |
|
---|
| 3225 | %---------------------------------------------------
|
---|
| 3226 | % --- Executes on menu selection Fields
|
---|
| 3227 | function Fields_1_Callback(hObject, eventdata, handles)
|
---|
| 3228 | %-------------------------------------------------
|
---|
| 3229 | list_fields=get(handles.Fields,'String');% list menu fields
|
---|
| 3230 | index_fields=get(handles.Fields,'Value');% selected string index
|
---|
| 3231 | field= list_fields{index_fields(1)}; % selected string
|
---|
| 3232 | list_fields=get(handles.Fields_1,'String');% list menu fields
|
---|
| 3233 | index_fields=get(handles.Fields_1,'Value');% selected string index
|
---|
| 3234 | field_1= list_fields{index_fields(1)}; % selected string for the second field
|
---|
| 3235 | if isequal(field_1,'') %remove second field if 'blank' field is selected
|
---|
| 3236 | set(handles.SubField,'Value',0)
|
---|
| 3237 | SubField_Callback(hObject, eventdata, handles)
|
---|
| 3238 | return
|
---|
| 3239 | end
|
---|
[59] | 3240 | UvData=get(handles.uvmat,'UserData');
|
---|
[2] | 3241 |
|
---|
| 3242 | %read the rootfile input display
|
---|
[85] | 3243 | [FileName,RootPath,FileBase,FileIndices,FileExt_prev]=read_file_boxes_1(handles);
|
---|
| 3244 | [P,F,str1,str2,str_a,str_b,E,NomType]=name2display(['xxx' get(handles.FileIndex,'String') FileExt_prev]);
|
---|
[2] | 3245 | if isempty(FileExt_prev)|isequal(FileExt_prev,'')
|
---|
| 3246 | FileExt_1=get(handles.FileExt,'String');
|
---|
| 3247 | else
|
---|
| 3248 | FileExt_1=FileExt_prev;
|
---|
| 3249 | end
|
---|
| 3250 | NomType_1=get(handles.FileIndex_1,'UserData');
|
---|
| 3251 | if isempty(NomType_1)|isequal(NomType_1,'')
|
---|
| 3252 | NomType_1=get(handles.FileIndex,'UserData');
|
---|
| 3253 | end
|
---|
| 3254 | NomTypeNew=NomType_1;%default
|
---|
| 3255 |
|
---|
| 3256 | set(handles.SubField,'Value',1)%introduce second field
|
---|
| 3257 | if isfield(UvData,'XmlData')
|
---|
| 3258 | UvData.XmlData_1=UvData.XmlData;
|
---|
| 3259 | end
|
---|
| 3260 | set(handles.FileIndex_1,'Visible','on')
|
---|
| 3261 | set(handles.FileExt_1,'Visible','on')
|
---|
| 3262 | RootPath_1=get(handles.RootPath_1,'String');
|
---|
| 3263 | RootFile_1=get(handles.RootFile_1,'String');
|
---|
[82] | 3264 | if isempty(RootPath_1)||isequal(RootPath_1,'')
|
---|
[2] | 3265 | set(handles.RootPath_1,'String','"')
|
---|
| 3266 | end
|
---|
[82] | 3267 | if isempty(RootFile_1) || isequal(RootFile_1,'')
|
---|
[2] | 3268 | set(handles.RootFile_1,'String','"')
|
---|
| 3269 | end
|
---|
[82] | 3270 | if ~isempty(RootFile_1)&&(isequal(RootFile_1(1),'/')||isequal(RootFile_1(1),'\'))
|
---|
[2] | 3271 | RootFile_1(1)=[];
|
---|
| 3272 | end
|
---|
| 3273 |
|
---|
| 3274 | if isequal(field_1,'get_field...')
|
---|
| 3275 | veltype_handles=[handles.civ1 handles.interp1 handles.filter1 handles.civ2 handles.interp2 handles.filter2];
|
---|
| 3276 | set_veltype_display(veltype_handles,0) % unvisible civ buttons
|
---|
| 3277 | filename=read_file_boxes_1(handles);
|
---|
| 3278 | hget_field=findobj(allchild(0),'name','get_field_1');
|
---|
| 3279 | if ~isempty(hget_field)
|
---|
| 3280 | delete(hget_field)
|
---|
| 3281 | end
|
---|
| 3282 | hget_field=get_field(filename);
|
---|
| 3283 | set(hget_field,'name','get_field_1')
|
---|
| 3284 | return %no action
|
---|
| 3285 | end
|
---|
| 3286 | if isequal(field_1,'image')
|
---|
| 3287 | % transform netc type to the corresponding image type
|
---|
[85] | 3288 | % set(handles.FileExt_1,'String','.png');
|
---|
[2] | 3289 | if isequal(NomType_1,'_i1-i2_j')|isequal(NomType_1,'_i_j1-j2')| isequal(NomType_1,'#_ab')| isequal(NomType_1,'_i1-i2')
|
---|
| 3290 | UvData.SubDir_1=get(handles.SubDir_1,'String'); %preserve the subdir in memory
|
---|
[85] | 3291 | % set(handles.SubDir_1,'String','')
|
---|
[2] | 3292 | % set(handles.FileExt_1,'String','.png');
|
---|
| 3293 | if isequal(NomType_1,'_i1-i2_j')|isequal(NomType_1,'_i_j1-j2')
|
---|
| 3294 | NomTypeNew='_i_j';
|
---|
| 3295 | elseif isequal(NomType_1,'#_ab')
|
---|
| 3296 | NomTypeNew='#a';
|
---|
| 3297 | elseif isequal(NomType_1,'_i1-i2')
|
---|
| 3298 | NomTypeNew='_i';
|
---|
| 3299 | end
|
---|
| 3300 | end
|
---|
[85] | 3301 | imagename=name_generator(FileBase,str2double(str1),str2double(str_a),'.png',NomTypeNew,1,str2double(str2),str2double(str_b),'');
|
---|
| 3302 | if ~exist(imagename,'file')
|
---|
| 3303 | [FileName,PathName] = uigetfile( ...
|
---|
| 3304 | {'*.png;*.jpg;*.tif;*.avi;*.AVI;*.vol', ' (*.png, .tif, *.avi,*.vol)';
|
---|
| 3305 | '*.jpg',' jpeg image files'; ...
|
---|
| 3306 | '*.png','.png image files'; ...
|
---|
| 3307 | '*.tif','.tif image files'; ...
|
---|
| 3308 | '*.avi;*.AVI','.avi movie files'; ...
|
---|
| 3309 | '*.vol','.volume images (png)'; ...
|
---|
| 3310 | '*.*', 'All Files (*.*)'}, ...
|
---|
[86] | 3311 | 'Pick an image',imagename);
|
---|
[85] | 3312 | % display the selected field and related information
|
---|
| 3313 | imagename=[PathName FileName];
|
---|
| 3314 | end
|
---|
| 3315 | display_file_name_1(hObject, eventdata, handles,imagename)%display the image
|
---|
| 3316 | return
|
---|
| 3317 | % veltype_handles=[handles.civ1_1 handles.interp1_1 handles.filter1_1 handles.civ2_1 handles.interp2_1 handles.filter2_1];
|
---|
| 3318 | % set_veltype_display(veltype_handles,0) % unvisible civ buttons
|
---|
[2] | 3319 | else
|
---|
| 3320 | set(handles.SubDir_1,'Visible','on')
|
---|
| 3321 | if ~isequal(FileExt_prev,'.nc') %find the new NomType if the previous display was not already a netcdf file
|
---|
| 3322 | veltype_handles=[handles.civ1_1 handles.interp1_1 handles.filter1_1 handles.civ2_1 handles.interp2_1 handles.filter2_1];
|
---|
| 3323 | set_veltype_display(veltype_handles,6); % make all civ buttons visible
|
---|
| 3324 | RootPath_1=get(handles.RootPath_1,'String');
|
---|
| 3325 | RootFile_1=get(handles.RootFile_1,'String');
|
---|
| 3326 | if isempty(RootPath_1)|isequal(RootPath_1,'')
|
---|
| 3327 | set(handles.RootPath_1,'String','"')
|
---|
| 3328 | end
|
---|
| 3329 | if isempty(RootFile_1) | isequal(RootFile_1,'')
|
---|
| 3330 | set(handles.RootFile_1,'String','"')
|
---|
| 3331 | end
|
---|
| 3332 | if ~isempty(RootFile_1)&(isequal(RootFile_1(1),'/')|isequal(RootFile_1(1),'\'))
|
---|
| 3333 | RootFile_1(1)=[];
|
---|
| 3334 | end
|
---|
| 3335 | filebase_1=fullfile(RootPath_1,RootFile_1);
|
---|
| 3336 | SubDir_1=get(handles.SubDir,'String');
|
---|
[82] | 3337 | if isempty(SubDir_1)||isequal(SubDir_1,'')
|
---|
[2] | 3338 | if isfield(UvData,'SubDir_1')
|
---|
| 3339 | SubDir_1=UvData.SubDir_1;%retrieve previous subdir
|
---|
| 3340 | else
|
---|
| 3341 | SubDir_1='?';
|
---|
| 3342 | end
|
---|
| 3343 | end
|
---|
[82] | 3344 | str1=get(handles.i1,'String');
|
---|
| 3345 | str_a=get(handles.j1,'String');
|
---|
| 3346 | if isequal(NomType_1,'#_ab')||isequal(NomType_1,'_i1-i2_j')||isequal(NomType_1,'_i_j1-j2')||isequal(NomType_1,'_i1-i2')
|
---|
[2] | 3347 | NomTypeNew=NomType_1;
|
---|
| 3348 | elseif isequal(NomType_1,'#a')
|
---|
[82] | 3349 | [filename, n1,na,n2,nb,SubDir_1]=name_generator(filebase_1, str2num(str1),stra2num(str_a),'.nc','#_ab',0,[],[],SubDir_1);
|
---|
[2] | 3350 | NomTypeNew='#_ab';
|
---|
| 3351 | elseif isequal(NomType_1,'_i_j')
|
---|
[82] | 3352 | [filename,n1,na,n2,nb,SubDir_1]=name_generator(filebase_1,str2num(str1),stra2num(str_a),'.nc','_i1-i2_j',0,str2num(str1),[],SubDir_1);
|
---|
[2] | 3353 | if idetect==1
|
---|
| 3354 | NomTypeNew='_i1-i2_j';
|
---|
| 3355 | else
|
---|
| 3356 | NomTypeNew='_i_j1-j2';
|
---|
| 3357 | end
|
---|
| 3358 | else %for instance avi files or any ima_num series
|
---|
[82] | 3359 | [filename,n1,na,n2,nb,SubDir_1]=name_generator(filebase_1,str2num(str1),stra2num(str_a),'.nc','_i1-i2',0,str2num(str1),[],SubDir_1);
|
---|
[2] | 3360 | NomTypeNew='_i1-i2';
|
---|
| 3361 | end
|
---|
| 3362 | [Path,Name]=fileparts(filebase_1);
|
---|
| 3363 | set(handles.FileExt_1,'String','.nc');
|
---|
[86] | 3364 | if ~isempty(SubDir_1) && ~strcmp(SubDir_1,'''')&& ~strcmp(SubDir_1,'"')&& ~strcmp(SubDir_1(1),'/')
|
---|
[2] | 3365 | SubDir_1=['/' SubDir_1];
|
---|
| 3366 | end
|
---|
| 3367 | set(handles.SubDir_1,'String',SubDir_1);
|
---|
| 3368 | end
|
---|
| 3369 | if isequal(field,'vort') | isequal(field,'div') | isequal(field,'strain')
|
---|
| 3370 | set(handles.civ1_1,'BackgroundColor',[0.702 0.702 0.702]) % put their color to grey
|
---|
| 3371 | set(handles.civ2_1,'BackgroundColor',[0.702 0.702 0.702])
|
---|
| 3372 | set(handles.interp1_1,'BackgroundColor',[0.702 0.702 0.702])
|
---|
| 3373 | set(handles.interp2_1,'BackgroundColor',[0.702 0.702 0.702])
|
---|
| 3374 | elseif isequal(field_1,'more...'); %add new item to the menu
|
---|
| 3375 | set(handles.civ1_1,'BackgroundColor',[0.702 0.702 0.702]) % put their color to grey
|
---|
| 3376 | set(handles.civ2_1,'BackgroundColor',[0.702 0.702 0.702])
|
---|
| 3377 | str=calc_field;%get the list of available scalars by the function calc_scal
|
---|
| 3378 | [ind_answer,v] = listdlg('PromptString','Select a file:',...
|
---|
| 3379 | 'SelectionMode','single',...
|
---|
| 3380 | 'ListString',str);
|
---|
| 3381 | % edit the choice in the field and action menu
|
---|
| 3382 | scalar=cell2mat(str(ind_answer));
|
---|
| 3383 | menu=update_menu(handles.Fields_1,scalar);
|
---|
| 3384 | set(handles.Fields_1,'String',menu);% store the selected scalar type
|
---|
| 3385 | end
|
---|
| 3386 | end
|
---|
| 3387 | str1=get(handles.i1,'String');
|
---|
| 3388 | str2=get(handles.i2,'String');
|
---|
| 3389 | str_a=get(handles.j1,'String');
|
---|
| 3390 | str_b=get(handles.j2,'String');
|
---|
| 3391 | indices=name_generator('',str2num(str1),stra2num(str_a),'',NomTypeNew,1,str2num(str2),stra2num(str_b),'');
|
---|
| 3392 | set(handles.FileIndex_1,'String',indices)
|
---|
| 3393 | set(handles.FileIndex_1,'UserData',NomTypeNew)
|
---|
| 3394 |
|
---|
| 3395 | %common to Fields_Callback
|
---|
| 3396 | if isequal(field,'image')|isequal(field_1,'image')
|
---|
| 3397 | set(handles.npx_title,'Visible','on')% visible npx,pxcm... buttons
|
---|
| 3398 | set(handles.npy_title,'Visible','on')
|
---|
| 3399 | set(handles.npx,'Visible','on')
|
---|
| 3400 | set(handles.npy,'Visible','on')
|
---|
[81] | 3401 | % set(handles.fix_pair,'Value',0)
|
---|
[2] | 3402 | else
|
---|
| 3403 | set(handles.npx_title,'Visible','off')% visible npx,pxcm... buttons
|
---|
| 3404 | set(handles.npy_title,'Visible','off')
|
---|
| 3405 | set(handles.npx,'Visible','off')
|
---|
| 3406 | set(handles.npy,'Visible','off')
|
---|
[81] | 3407 | % set(handles.fix_pair,'Value',1)
|
---|
[2] | 3408 | end
|
---|
| 3409 | if isequal(field,'velocity')|isequal(field_1,'velocity');
|
---|
| 3410 | state_vect='on';
|
---|
| 3411 | else
|
---|
| 3412 | state_vect='off';
|
---|
| 3413 | end
|
---|
| 3414 | if ~isequal(field,'velocity')|(~isequal(field_1,'velocity')&~isequal(field_1,''));
|
---|
| 3415 | state_scal='on';
|
---|
| 3416 | else
|
---|
| 3417 | state_scal='off';
|
---|
| 3418 | end
|
---|
[59] | 3419 | set(handles.uvmat,'UserData',UvData)
|
---|
[2] | 3420 | setfield(handles);% update the field structure ('civ1'....)
|
---|
| 3421 | if ~isfield(UvData,'NewSeries')|isequal(UvData.NewSeries,0)
|
---|
| 3422 | run0_Callback(hObject, eventdata, handles)
|
---|
| 3423 | end
|
---|
| 3424 |
|
---|
[57] | 3425 | %------------------------------------------------------------------------
|
---|
| 3426 | % --- set the visibility of relevant velocity type menus:
|
---|
| 3427 | function set_veltype_display(handles,Civ)
|
---|
| 3428 | %------------------------------------------------------------------------
|
---|
[2] | 3429 | %Civ=0; all states 'off'
|
---|
| 3430 | %Civ=6; all states 'on'
|
---|
| 3431 | if isequal(Civ,0)
|
---|
| 3432 | imax=0;
|
---|
| 3433 | % set(handles(1),'Visible','on') % unvisible civ buttons
|
---|
| 3434 | % else
|
---|
| 3435 | % set(handles(1),'String','civ1')
|
---|
| 3436 | % end
|
---|
[57] | 3437 | elseif isequal(Civ,1) || isequal(Civ,2)
|
---|
[2] | 3438 | imax=1;
|
---|
[57] | 3439 | elseif isequal(Civ,3)
|
---|
[2] | 3440 | imax=3;
|
---|
[57] | 3441 | elseif isequal(Civ,4) || isequal(Civ,5)
|
---|
[2] | 3442 | imax=4;
|
---|
[57] | 3443 | elseif isequal(Civ,6) %patch2
|
---|
[2] | 3444 | imax=6;
|
---|
| 3445 | end
|
---|
| 3446 | for ibutton=1:imax;
|
---|
| 3447 | set(handles(ibutton),'Visible','on') % unvisible civ buttons
|
---|
| 3448 | end
|
---|
| 3449 | % for ibutton=max(imax+1,2):6;
|
---|
| 3450 | for ibutton=imax+1:6;
|
---|
| 3451 | set(handles(ibutton),'Visible','off') % unvisible civ buttons
|
---|
| 3452 | set(handles(ibutton),'Value',0)%unactivate unvisible buttons
|
---|
| 3453 | end
|
---|
| 3454 |
|
---|
| 3455 | %-------------------------------------------------------------------
|
---|
| 3456 | % --- Executes on button press in civ1.
|
---|
| 3457 | function civ1_Callback(hObject, eventdata, handles)
|
---|
| 3458 | %-------------------------------------------------------------------
|
---|
| 3459 | if get(handles.civ1,'Value')==1
|
---|
| 3460 | reset_vel_type([handles.interp1 handles.civ2 handles.filter1 handles.interp1 handles.interp2 handles.filter2],handles.civ1)
|
---|
| 3461 | else
|
---|
| 3462 | reset_vel_type([handles.civ1 handles.filter1 handles.interp1 handles.civ2 handles.interp2 handles.filter2])
|
---|
| 3463 | end
|
---|
| 3464 | run0_Callback(hObject, eventdata, handles)
|
---|
| 3465 |
|
---|
| 3466 | %-------------------------------------------------------------------
|
---|
| 3467 | % --- Executes on button press in interp1.
|
---|
| 3468 | function interp1_Callback(hObject, eventdata, handles)
|
---|
| 3469 | %-------------------------------------------------------------------
|
---|
| 3470 | if get(handles.interp1,'Value')==1
|
---|
| 3471 | reset_vel_type([handles.civ1 handles.civ2 handles.filter1 handles.interp2 handles.filter2],handles.interp1)
|
---|
| 3472 | else
|
---|
| 3473 | reset_vel_type([handles.civ1 handles.filter1 handles.interp1 handles.civ2 handles.interp2 handles.filter2])
|
---|
| 3474 | end
|
---|
| 3475 | run0_Callback(hObject, eventdata, handles)
|
---|
| 3476 |
|
---|
| 3477 | %-------------------------------------------------------------------
|
---|
| 3478 | % --- Executes on button press in filter1.
|
---|
| 3479 | function filter1_Callback(hObject, eventdata, handles)
|
---|
| 3480 | %-------------------------------------------------------------------
|
---|
| 3481 | if get(handles.filter1,'Value')==1
|
---|
| 3482 | reset_vel_type([handles.civ1 handles.civ2 handles.interp1 handles.interp2 handles.filter2],handles.filter1)
|
---|
| 3483 | else
|
---|
| 3484 | reset_vel_type([handles.civ1 handles.filter1 handles.interp1 handles.civ2 handles.interp2 handles.filter2])
|
---|
| 3485 | end
|
---|
| 3486 | run0_Callback(hObject, eventdata, handles)
|
---|
| 3487 |
|
---|
| 3488 | %-------------------------------------------------------------------
|
---|
| 3489 | % --- Executes on button press in civ2.
|
---|
| 3490 | function civ2_Callback(hObject, eventdata, handles)
|
---|
| 3491 | %-------------------------------------------------------------------
|
---|
| 3492 | if get(handles.civ2,'Value')==1
|
---|
| 3493 | reset_vel_type([handles.civ1 handles.filter1 handles.interp1 handles.interp2 handles.filter2],handles.civ2)
|
---|
| 3494 | else
|
---|
| 3495 | reset_vel_type([handles.civ1 handles.filter1 handles.interp1 handles.civ2 handles.interp2 handles.filter2])
|
---|
| 3496 | end
|
---|
| 3497 | run0_Callback(hObject, eventdata, handles)
|
---|
| 3498 |
|
---|
| 3499 | %-----------------------------------------
|
---|
| 3500 | % --- Executes on button press in interp2.
|
---|
| 3501 | %-------------------------------------------
|
---|
| 3502 | function interp2_Callback(hObject, eventdata, handles)
|
---|
| 3503 | if get(handles.interp2,'Value')==1
|
---|
| 3504 | reset_vel_type([handles.civ1 handles.filter1 handles.interp1 handles.civ2 handles.filter2],handles.interp2)
|
---|
| 3505 | else
|
---|
| 3506 | reset_vel_type([handles.civ1 handles.filter1 handles.interp1 handles.civ2 handles.interp2 handles.filter2])
|
---|
| 3507 | end
|
---|
| 3508 | run0_Callback(hObject, eventdata, handles)
|
---|
| 3509 | %---------------------------------------------
|
---|
| 3510 | % --- Executes on button press in filter2.
|
---|
| 3511 | %-------------------------------------------
|
---|
| 3512 | function filter2_Callback(hObject, eventdata, handles)
|
---|
| 3513 | if get(handles.filter2,'Value')==1
|
---|
| 3514 | reset_vel_type([handles.civ1 handles.filter1 handles.interp1 handles.civ2 handles.interp2],handles.filter2)
|
---|
| 3515 | else
|
---|
| 3516 | reset_vel_type([handles.civ1 handles.filter1 handles.interp1 handles.civ2 handles.interp2 handles.filter2])
|
---|
| 3517 | end
|
---|
| 3518 | run0_Callback(hObject, eventdata, handles)
|
---|
| 3519 |
|
---|
| 3520 | %---------------------------------------------
|
---|
| 3521 | function civ1_1_Callback(hObject, eventdata, handles)
|
---|
| 3522 | %---------------------------------------------
|
---|
| 3523 | if get(handles.civ1_1,'Value')==1
|
---|
| 3524 | reset_vel_type([handles.interp1_1 handles.civ2_1 handles.filter1_1 handles.interp1_1 handles.interp2_1 handles.filter2_1],handles.civ1_1)
|
---|
| 3525 | else
|
---|
| 3526 | reset_vel_type([handles.civ1_1 handles.filter1_1 handles.interp1_1 handles.civ2_1 handles.interp2_1 handles.filter2_1])
|
---|
| 3527 | end
|
---|
| 3528 | run0_Callback(hObject, eventdata, handles)
|
---|
| 3529 |
|
---|
| 3530 | %--------------------------------------------
|
---|
| 3531 | function interp1_1_Callback(hObject, eventdata, handles)
|
---|
| 3532 | %--------------------------------------------
|
---|
| 3533 | if get(handles.interp1_1,'Value')==1
|
---|
| 3534 | reset_vel_type([handles.civ1_1 handles.civ2_1 handles.filter1_1 handles.interp2_1 handles.filter2_1],handles.interp1_1)
|
---|
| 3535 | else
|
---|
| 3536 | reset_vel_type([handles.civ1_1 handles.filter1_1 handles.interp1_1 handles.civ2_1 handles.interp2_1 handles.filter2_1])
|
---|
| 3537 | end
|
---|
| 3538 | run0_Callback(hObject, eventdata, handles)
|
---|
| 3539 |
|
---|
| 3540 | %--------------------------------------------
|
---|
| 3541 | function filter1_1_Callback(hObject, eventdata, handles)
|
---|
| 3542 | %--------------------------------------------
|
---|
| 3543 | if get(handles.filter1_1,'Value')==1
|
---|
| 3544 | reset_vel_type([handles.interp1_1 handles.civ2_1 handles.interp1_1 handles.interp2_1 handles.filter2_1],handles.filter1_1)
|
---|
| 3545 | else
|
---|
| 3546 | reset_vel_type([handles.civ1_1 handles.filter1_1 handles.interp1_1 handles.civ2_1 handles.interp2_1 handles.filter2_1])
|
---|
| 3547 | end
|
---|
| 3548 | run0_Callback(hObject, eventdata, handles)
|
---|
| 3549 |
|
---|
| 3550 | %--------------------------------------------
|
---|
| 3551 | function civ2_1_Callback(hObject, eventdata, handles)
|
---|
| 3552 | %--------------------------------------------
|
---|
| 3553 | if get(handles.civ2_1,'Value')==1
|
---|
| 3554 | reset_vel_type([handles.civ1_1 handles.interp1_1 handles.filter1_1 handles.interp2_1 handles.filter2_1],handles.civ2_1)
|
---|
| 3555 | else
|
---|
| 3556 | reset_vel_type([handles.civ1_1 handles.filter1_1 handles.interp1_1 handles.civ2_1 handles.interp2_1 handles.filter2_1])
|
---|
| 3557 | end
|
---|
| 3558 | run0_Callback(hObject, eventdata, handles)
|
---|
| 3559 |
|
---|
| 3560 | %--------------------------------------------
|
---|
| 3561 | function interp2_1_Callback(hObject, eventdata, handles)
|
---|
| 3562 | %--------------------------------------------
|
---|
| 3563 | if get(handles.interp2_1,'Value')==1
|
---|
| 3564 | reset_vel_type([handles.civ1_1 handles.civ2_1 handles.filter1_1 handles.interp1_1 handles.filter2_1],handles.interp2_1)
|
---|
| 3565 | else
|
---|
| 3566 | reset_vel_type([handles.civ1_1 handles.filter1_1 handles.interp1_1 handles.civ2_1 handles.interp2_1 handles.filter2_1])
|
---|
| 3567 | end
|
---|
| 3568 | run0_Callback(hObject, eventdata, handles)
|
---|
| 3569 |
|
---|
| 3570 | %--------------------------------------------
|
---|
| 3571 | function filter2_1_Callback(hObject, eventdata, handles)
|
---|
| 3572 | %--------------------------------------------
|
---|
| 3573 | if get(handles.filter2_1,'Value')==1
|
---|
| 3574 | reset_vel_type([handles.civ1_1 handles.interp1_1 handles.civ2_1 handles.filter1_1 handles.interp1_1 handles.interp2_1],handles.filter2_1)
|
---|
| 3575 | else
|
---|
| 3576 | reset_vel_type([handles.civ1_1 handles.filter1_1 handles.interp1_1 handles.civ2_1 handles.interp2_1 handles.filter2_1])
|
---|
| 3577 | end
|
---|
| 3578 | run0_Callback(hObject, eventdata, handles)
|
---|
| 3579 |
|
---|
| 3580 | %-----------------------------------------------
|
---|
| 3581 | % --- reset civ buttons
|
---|
| 3582 | function reset_vel_type(handles_civ0,handle1)
|
---|
| 3583 | for ibutton=1:length(handles_civ0)
|
---|
| 3584 | set(handles_civ0(ibutton),'BackgroundColor',[0.831 0.816 0.784])
|
---|
| 3585 | set(handles_civ0(ibutton),'Value',0)
|
---|
| 3586 | end
|
---|
| 3587 | if exist('handle1','var')%handles of selected button
|
---|
| 3588 | set(handle1,'BackgroundColor',[1 1 0])
|
---|
| 3589 | end
|
---|
| 3590 |
|
---|
| 3591 | %-------------------------------------------------------
|
---|
| 3592 | % --- Executes on button press in MENUVOLUME.
|
---|
| 3593 | %-------------------------------------------------------
|
---|
| 3594 | function VOLUME_Callback(hObject, eventdata, handles)
|
---|
| 3595 | %errordlg('command VOL not implemented yet')
|
---|
| 3596 | if ishandle(handles.UVMAT_title)
|
---|
| 3597 | delete(handles.UVMAT_title)
|
---|
| 3598 | end
|
---|
[61] | 3599 | UvData=get(handles.uvmat,'UserData');%read UvData properties stored on the uvmat interface
|
---|
[2] | 3600 | if isequal(get(handles.VOLUME,'Value'),1)
|
---|
| 3601 | set(handles.zoom,'Value',0)
|
---|
| 3602 | set(handles.zoom,'BackgroundColor',[0.7 0.7 0.7])
|
---|
| 3603 | set(handles.edit_vect,'Value',0)
|
---|
| 3604 | edit_vect_Callback(hObject, eventdata, handles)
|
---|
| 3605 | set(handles.edit,'Value',0)
|
---|
| 3606 | set(handles.edit,'BackgroundColor',[0.7 0.7 0.7])
|
---|
[61] | 3607 | % set(handles.cal,'Value',0)
|
---|
| 3608 | % set(handles.cal,'BackgroundColor',[0 1 0])
|
---|
[2] | 3609 | set(handles.edit_vect,'Value',0)
|
---|
| 3610 | edit_vect_Callback(hObject, eventdata, handles)
|
---|
| 3611 | %initiate set_object GUI
|
---|
| 3612 | data.TITLE='VOLUME';
|
---|
| 3613 | if isfield(UvData,'CoordType')
|
---|
| 3614 | data.CoordType=UvData.CoordType;
|
---|
| 3615 | end
|
---|
| 3616 | if isfield(UvData,'Mesh')&~isempty(UvData.Mesh)
|
---|
| 3617 | data.RangeY=UvData.Mesh;
|
---|
| 3618 | data.RangeX=UvData.Mesh;
|
---|
| 3619 | data.DX=UvData.Mesh;
|
---|
| 3620 | data.DY=UvData.Mesh;
|
---|
| 3621 | elseif isfield(UvData.Field,'AX')&isfield(UvData.Field,'AY')& isfield(UvData.Field,'A')%only image
|
---|
| 3622 | np=size(UvData.Field.A);
|
---|
| 3623 | meshx=(UvData.Field.AX(end)-UvData.Field.AX(1))/np(2);
|
---|
| 3624 | meshy=abs(UvData.Field.AY(end)-UvData.Field.AY(1))/np(1);
|
---|
| 3625 | data.RangeY=max(meshx,meshy);
|
---|
| 3626 | data.RangeX=max(meshx,meshy);
|
---|
| 3627 | data.DX=max(meshx,meshy);
|
---|
| 3628 | end
|
---|
| 3629 | data.ParentButton=handles.VOLUME;
|
---|
| 3630 | PlotHandles=get_plot_handles(handles);%get the handles of the interface elements setting the plotting parameters
|
---|
| 3631 | [hset_object,UvData.sethandles]=set_object(data,PlotHandles);% call the set_object interface with action on haxes,
|
---|
| 3632 | % associate the set_edit interface handle to the plotting axes
|
---|
| 3633 | if isfield(UvData,'SetObjectOrigin')
|
---|
| 3634 | pos_uvmat=get(huvmat,'Position');
|
---|
| 3635 | pos_set_object(1:2)=UvData.SetObjectOrigin + pos_uvmat(1:2);
|
---|
| 3636 | pos_set_object(3:4)=UvData.SetObjectSize .* pos_uvmat(3:4);
|
---|
| 3637 | set(hset_object,'Position',pos_set_object)
|
---|
| 3638 | end
|
---|
| 3639 | UvData.MouseAction='create_object';
|
---|
| 3640 | else
|
---|
| 3641 | set(handles.VOLUME,'BackgroundColor',[0 1 0])
|
---|
| 3642 | UvData.MouseAction='none';
|
---|
| 3643 | end
|
---|
| 3644 | set(huvmat,'UserData',UvData)
|
---|
| 3645 |
|
---|
| 3646 | %-------------------------------------------------------
|
---|
| 3647 | function edit_vect_Callback(hObject, eventdata, handles)
|
---|
| 3648 | %-------------------------------------------------------
|
---|
[55] | 3649 |
|
---|
| 3650 | UvData=get(handles.uvmat,'UserData');%read UvData properties stored on the uvmat interface
|
---|
[2] | 3651 | if isequal(get(handles.edit_vect,'Value'),1)
|
---|
[55] | 3652 | test_civ2=isequal(get(handles.civ2,'BackgroundColor'),[1 1 0]);
|
---|
| 3653 | test_civ1=isequal(get(handles.civ1,'BackgroundColor'),[1 1 0]);
|
---|
| 3654 | if ~test_civ2 && ~test_civ1
|
---|
| 3655 | msgbox_uvmat('ERROR','manual correction only possible for CIV1 or CIV2 velocity fields')
|
---|
| 3656 | end
|
---|
[2] | 3657 | set(handles.record,'Visible','on')
|
---|
| 3658 | set(handles.edit_vect,'BackgroundColor',[1 1 0])
|
---|
| 3659 | set(handles.edit,'Value',0)
|
---|
[61] | 3660 | set(handles.zoom,'Value',0)
|
---|
| 3661 | set(handles.zoom,'BackgroundColor',[0.7 0.7 0.7])
|
---|
| 3662 | % set(handles.create,'Value',0)
|
---|
| 3663 | % set(handles.create,'BackgroundColor',[0 1 0])
|
---|
[2] | 3664 | set(handles.edit,'BackgroundColor',[0.7 0.7 0.7])
|
---|
| 3665 | set(gcf,'Pointer','arrow')
|
---|
| 3666 | UvData.MouseAction='edit_vect';
|
---|
| 3667 | else
|
---|
| 3668 | set(handles.record,'Visible','off')
|
---|
| 3669 | set(handles.edit_vect,'BackgroundColor',[0.7 0.7 0.7])
|
---|
| 3670 | UvData.MouseAction='none';
|
---|
| 3671 | end
|
---|
[55] | 3672 | set(handles.uvmat,'UserData',UvData)
|
---|
[2] | 3673 |
|
---|
| 3674 | %----------------------------------------------
|
---|
| 3675 | function save_mask_Callback(hObject, eventdata, handles)
|
---|
| 3676 | %-----------------------------------------------------------------------
|
---|
[82] | 3677 | UvData=get(handles.uvmat,'UserData');
|
---|
[2] | 3678 |
|
---|
| 3679 | flag=1;
|
---|
| 3680 | npx=size(UvData.Field.A,2);
|
---|
| 3681 | npy=size(UvData.Field.A,1);
|
---|
| 3682 | xi=[0.5:npx-0.5];
|
---|
| 3683 | yi=[0.5:npy-0.5];
|
---|
| 3684 | [Xi,Yi]=meshgrid(xi,yi);
|
---|
| 3685 | if isfield(UvData,'Object')
|
---|
| 3686 | for iobj=1:length(UvData.Object)
|
---|
| 3687 | ObjectData=UvData.Object{iobj};
|
---|
| 3688 | if isfield(ObjectData,'ProjMode') &&(isequal(ObjectData.ProjMode,'mask_inside')||isequal(ObjectData.ProjMode,'mask_outside'));
|
---|
| 3689 | flagobj=1;
|
---|
| 3690 | testphys=0; %coordinates in pixels by default
|
---|
| 3691 | if isfield(ObjectData,'CoordType') && isequal(ObjectData.CoordType,'phys')
|
---|
| 3692 | if isfield(UvData,'XmlData')&& isfield(UvData.XmlData,'GeometryCalib')
|
---|
| 3693 | Calib=UvData.XmlData.GeometryCalib;
|
---|
| 3694 | testphys=1;
|
---|
| 3695 | end
|
---|
| 3696 | end
|
---|
| 3697 | if isfield(ObjectData,'Coord')& isfield(ObjectData,'Style')
|
---|
| 3698 | if isequal(ObjectData.Style,'polygon')
|
---|
| 3699 | X=ObjectData.Coord(:,1);
|
---|
| 3700 | Y=ObjectData.Coord(:,2);
|
---|
| 3701 | if testphys
|
---|
| 3702 | [X,Y]=px_XYZ(Calib,X,Y,0);% to generalise with 3D cases
|
---|
| 3703 | end
|
---|
[82] | 3704 | flagobj=~inpolygon(Xi,Yi,X',Y');%=0 inside the polygon, 1 outside
|
---|
[2] | 3705 | elseif isequal(ObjectData.Style,'ellipse')
|
---|
| 3706 | if testphys
|
---|
| 3707 | %[X,Y]=px_XYZ(Calib,X,Y,0);% TODO:create a polygon boundary and transform to phys
|
---|
| 3708 | end
|
---|
| 3709 | RangeX=max(ObjectData.RangeX);
|
---|
| 3710 | RangeY=max(ObjectData.RangeY);
|
---|
| 3711 | X2Max=RangeX*RangeX;
|
---|
| 3712 | Y2Max=RangeY*RangeY;
|
---|
| 3713 | distX=(Xi-ObjectData.Coord(1,1));
|
---|
| 3714 | distY=(Yi-ObjectData.Coord(1,2));
|
---|
| 3715 | flagobj=(distX.*distX/X2Max+distY.*distY/Y2Max)>1;
|
---|
| 3716 | elseif isequal(ObjectData.Style,'rectangle')
|
---|
| 3717 | if testphys
|
---|
| 3718 | %[X,Y]=px_XYZ(Calib,X,Y,0);% TODO:create a polygon boundary and transform to phys
|
---|
| 3719 | end
|
---|
| 3720 | distX=abs(Xi-ObjectData.Coord(1,1));
|
---|
| 3721 | distY=abs(Yi-ObjectData.Coord(1,2));
|
---|
| 3722 | flagobj=distX>max(ObjectData.RangeX) | distY>max(ObjectData.RangeY);
|
---|
| 3723 | end
|
---|
| 3724 | if isequal(ObjectData.ProjMode,'mask_outside')
|
---|
| 3725 | flagobj=~flagobj;
|
---|
| 3726 | end
|
---|
| 3727 | flag=flag & flagobj;
|
---|
| 3728 | end
|
---|
| 3729 | end
|
---|
| 3730 | end
|
---|
| 3731 | end
|
---|
| 3732 | % flag=~flag;
|
---|
| 3733 | %mask name
|
---|
| 3734 | RootPath=get(handles.RootPath,'String');
|
---|
| 3735 | RootFile=get(handles.RootFile,'String');
|
---|
| 3736 | if ~isempty(RootFile)&(isequal(RootFile(1),'/')| isequal(RootFile(1),'\'))
|
---|
| 3737 | RootFile(1)=[];
|
---|
| 3738 | end
|
---|
| 3739 | filebase=fullfile(RootPath,RootFile);
|
---|
| 3740 | list=get(handles.masklevel,'String');
|
---|
| 3741 | masknumber=num2str(length(list));
|
---|
| 3742 | maskindex=get(handles.masklevel,'Value');
|
---|
| 3743 | mask_name=name_generator([filebase '_' masknumber 'mask'],maskindex,1,'.png','_i');
|
---|
| 3744 | imflag=uint8(255*(0.392+0.608*flag));% =100 for flag=0 (vectors not computed when 20<imflag<200)
|
---|
| 3745 | imflag=flipdim(imflag,1);
|
---|
| 3746 | % imflag=uint8(255*flag);% =0 for flag=0 (vectors=0 when 20<imflag<200)
|
---|
[38] | 3747 | msgbox_uvmat('CONFIRMATION',[mask_name ' saved'])
|
---|
[2] | 3748 | imwrite(imflag,mask_name,'BitDepth',8);
|
---|
| 3749 |
|
---|
| 3750 | %display the mask
|
---|
| 3751 | %update_mask(handles,num_i1,num_j1)
|
---|
| 3752 | figure;
|
---|
| 3753 | vec=linspace(0,1,256);%define a linear greyscale colormap
|
---|
| 3754 | map=[vec' vec' vec'];
|
---|
| 3755 | colormap(map)
|
---|
| 3756 |
|
---|
| 3757 | image(imflag);
|
---|
| 3758 |
|
---|
| 3759 | %-------------------------------------------------------------------
|
---|
| 3760 | %-------------------------------------------------------------------
|
---|
| 3761 | % - FUNCTIONS FOR SETTING PLOTTING PARAMETERS
|
---|
| 3762 |
|
---|
| 3763 | %------------------------------------------------------------------
|
---|
| 3764 |
|
---|
| 3765 |
|
---|
| 3766 |
|
---|
| 3767 | %------------------------------------------------------------------
|
---|
| 3768 | % --- Executes on selection change in col_vec: choice of the color code.
|
---|
| 3769 | %
|
---|
| 3770 | function col_vec_Callback(hObject, eventdata, handles)
|
---|
| 3771 | %------------------------------------------------------------------
|
---|
| 3772 | % edit the choice for color code
|
---|
| 3773 | list_code=get(handles.col_vec,'String');% list menu fields
|
---|
| 3774 | index_code=get(handles.col_vec,'Value');% selected string index
|
---|
| 3775 | col_code= list_code{index_code(1)}; % selected field
|
---|
| 3776 | if isequal(col_code,'black') | isequal(col_code,'white')
|
---|
| 3777 | set(handles.slider1,'Visible','off')
|
---|
| 3778 | set(handles.slider2,'Visible','off')
|
---|
| 3779 | set(handles.colcode1,'Visible','off')
|
---|
| 3780 | set(handles.colcode2,'Visible','off')
|
---|
| 3781 | set(handles.AutoVecColor,'Visible','off')
|
---|
| 3782 | set_vec_col_bar(handles)
|
---|
| 3783 | else
|
---|
| 3784 | set(handles.slider1,'Visible','on')
|
---|
| 3785 | set(handles.slider2,'Visible','on')
|
---|
| 3786 | set(handles.colcode1,'Visible','on')
|
---|
| 3787 | set(handles.colcode2,'Visible','on')
|
---|
| 3788 | set(handles.AutoVecColor,'Visible','on')
|
---|
| 3789 | if isequal(col_code,'ima_cor')
|
---|
| 3790 | set(handles.AutoVecColor,'Value',0)%fixed scale by default
|
---|
| 3791 | set(handles.vec_col_bar,'Value',0)% 3 colors r,g,b by default
|
---|
| 3792 | set(handles.slider1,'Min',0);
|
---|
| 3793 | set(handles.slider1,'Max',1);
|
---|
| 3794 | set(handles.slider2,'Min',0);
|
---|
| 3795 | set(handles.slider2,'Max',1);
|
---|
| 3796 | % set(handles.min_title_vec,'String','0')
|
---|
| 3797 | set(handles.max_vec,'String','1')
|
---|
| 3798 | set(handles.colcode1,'String','0.333')
|
---|
| 3799 | colcode1_Callback(hObject, eventdata, handles)
|
---|
| 3800 | set(handles.colcode2,'String','0.666')
|
---|
| 3801 | colcode2_Callback(hObject, eventdata, handles)
|
---|
| 3802 | else
|
---|
| 3803 | set(handles.AutoVecColor,'Value',1)%auto scale between min,max by default
|
---|
| 3804 | set(handles.vec_col_bar,'Value',1)% colormap 'jet' by default
|
---|
| 3805 | minval=get(handles.slider1,'Min');
|
---|
| 3806 | maxval=get(handles.slider1,'Max');
|
---|
| 3807 | set(handles.slider1,'Value',minval)
|
---|
| 3808 | set(handles.slider2,'Value',maxval)
|
---|
| 3809 | set_vec_col_bar(handles)
|
---|
| 3810 | end
|
---|
| 3811 | % slider_update(handles)
|
---|
| 3812 | end
|
---|
| 3813 | %replot the current graph
|
---|
| 3814 | run0_Callback(hObject, eventdata, handles)
|
---|
| 3815 |
|
---|
| 3816 |
|
---|
| 3817 | %----------------------------------------------------------------
|
---|
| 3818 | % -- Executes on slider movement to set the color code
|
---|
| 3819 | %
|
---|
| 3820 | function slider1_Callback(hObject, eventdata, handles)
|
---|
| 3821 | %------------------------------------------------------------------
|
---|
| 3822 | slider1=get(handles.slider1,'Value');
|
---|
| 3823 | min_val=str2num(get(handles.min_vec,'String'));
|
---|
| 3824 | max_val=str2num(get(handles.max_vec,'String'));
|
---|
| 3825 | col=min_val+(max_val-min_val)*slider1;
|
---|
| 3826 | set(handles.colcode1,'String',num2str(col))
|
---|
| 3827 | if(get(handles.slider2,'Value') < col)%move also the second slider at the same value if needed
|
---|
| 3828 | set(handles.slider2,'Value',col)
|
---|
| 3829 | set(handles.colcode2,'String',num2str(col))
|
---|
| 3830 | end
|
---|
| 3831 | colcode1_Callback(hObject, eventdata, handles)
|
---|
| 3832 |
|
---|
| 3833 | %----------------------------------------------------------------
|
---|
| 3834 | % Executes on slider movement to set the color code
|
---|
| 3835 | %----------------------------------------------------------------
|
---|
| 3836 | function slider2_Callback(hObject, eventdata, handles)
|
---|
| 3837 | slider2=get(handles.slider2,'Value');
|
---|
| 3838 | min_val=str2num(get(handles.min_vec,'String'));
|
---|
| 3839 | max_val=str2num(get(handles.max_vec,'String'));
|
---|
| 3840 | col=min_val+(max_val-min_val)*slider2;
|
---|
| 3841 | set(handles.colcode2,'String',num2str(col))
|
---|
| 3842 | if(get(handles.slider1,'Value') > col)%move also the first slider at the same value if needed
|
---|
| 3843 | set(handles.slider1,'Value',col)
|
---|
| 3844 | set(handles.colcode1,'String',num2str(col))
|
---|
| 3845 | end
|
---|
| 3846 | colcode2_Callback(hObject, eventdata, handles)
|
---|
| 3847 |
|
---|
| 3848 | %----------------------------------------------------------------
|
---|
| 3849 | %execute on return carriage on the edit box corresponding to slider 1
|
---|
| 3850 | %----------------------------------------------------------------
|
---|
| 3851 | function colcode1_Callback(hObject, eventdata, handles)
|
---|
| 3852 | % col=str2num(get(handles.colcode1,'String'));
|
---|
| 3853 | % set(handles.slider1,'Value',col)
|
---|
| 3854 | set_vec_col_bar(handles)
|
---|
[89] | 3855 | update_plot(handles);
|
---|
[2] | 3856 |
|
---|
| 3857 | %----------------------------------------------------------------
|
---|
| 3858 | %execute on return carriage on the edit box corresponding to slider 2
|
---|
| 3859 | %----------------------------------------------------------------
|
---|
| 3860 | function colcode2_Callback(hObject, eventdata, handles)
|
---|
| 3861 | % col=str2num(get(handles.colcode2,'String'));
|
---|
| 3862 | % set(handles.slider2,'Value',col)
|
---|
| 3863 | % slider2_Callback(hObject, eventdata, handles)
|
---|
| 3864 | set_vec_col_bar(handles)
|
---|
[89] | 3865 | update_plot(handles);
|
---|
[2] | 3866 | %------------------------------------------------------------
|
---|
| 3867 | %update the slider values after displaying vectors
|
---|
| 3868 | %--------------------------------------------------------
|
---|
| 3869 | % function slider_update(handles,auto,minC,colcode1,colcode2,maxC)
|
---|
| 3870 | % set(handles.slider1,'Min',minC)
|
---|
| 3871 | % set(handles.slider1,'Max',maxC)
|
---|
| 3872 | % set(handles.slider2,'Min',minC)
|
---|
| 3873 | % set(handles.slider2,'Max',maxC)
|
---|
| 3874 | % set(handles.min_title_vec,'String',num2str(minC))
|
---|
| 3875 | % set(handles.max_vec,'String',num2str(maxC))
|
---|
| 3876 | % if auto
|
---|
| 3877 | % set(handles.colcode1,'String',num2str(colcode1,3))%update display
|
---|
| 3878 | % set(handles.colcode2,'String',num2str(colcode2,3))
|
---|
| 3879 | % end
|
---|
| 3880 | % set(handles.slider1,'Value',colcode1)%update slider with constant display
|
---|
| 3881 | % set(handles.slider2,'Value',colcode2)
|
---|
| 3882 | % set_vec_col_bar(handles)
|
---|
| 3883 |
|
---|
| 3884 |
|
---|
| 3885 | %-------------------------------------------------------
|
---|
| 3886 | % --- Executes on button press in AutoVecColor.
|
---|
| 3887 | %-------------------------------------------------------
|
---|
| 3888 | function vec_col_bar_Callback(hObject, eventdata, handles)
|
---|
| 3889 | set_vec_col_bar(handles)
|
---|
| 3890 |
|
---|
| 3891 | %-------------------------------------------------------------
|
---|
[39] | 3892 | % --- Executes on selection change in transform_fct.
|
---|
| 3893 | function transform_fct_Callback(hObject, eventdata, handles)
|
---|
[2] | 3894 | %-------------------------------------------------------------
|
---|
[39] | 3895 | global nb_builtin
|
---|
| 3896 |
|
---|
| 3897 | huvmat=get(handles.transform_fct,'parent');
|
---|
| 3898 | menu=get(handles.transform_fct,'String');
|
---|
| 3899 | ind_coord=get(handles.transform_fct,'Value');
|
---|
[2] | 3900 | coord_option=menu{ind_coord};
|
---|
[39] | 3901 | list_transform=get(handles.transform_fct,'UserData');
|
---|
[40] | 3902 | ff=functions(list_transform{end});
|
---|
[2] | 3903 | if isequal(coord_option,'more...');
|
---|
| 3904 | coord_fct='';
|
---|
| 3905 | prompt = {'Enter the name of the transform function'};
|
---|
| 3906 | dlg_title = 'user defined transform';
|
---|
| 3907 | num_lines= 1;
|
---|
[89] | 3908 | [FileName, PathName] = uigetfile( ...
|
---|
[2] | 3909 | {'*.m', ' (*.m)';
|
---|
| 3910 | '*.m', '.m files '; ...
|
---|
| 3911 | '*.*', 'All Files (*.*)'}, ...
|
---|
[39] | 3912 | 'Pick a file', ff.file);
|
---|
[2] | 3913 | if isequal(PathName(end),'/')||isequal(PathName(end),'\')
|
---|
| 3914 | PathName(end)=[];
|
---|
| 3915 | end
|
---|
[39] | 3916 | transform_selected =fullfile(PathName,FileName);
|
---|
| 3917 | if ~exist(transform_selected,'file')
|
---|
| 3918 | return
|
---|
| 3919 | end
|
---|
| 3920 | [ppp,transform,ext_fct]=fileparts(FileName);% removes extension .m
|
---|
| 3921 | if ~isequal(ext_fct,'.m')
|
---|
| 3922 | msgbox_uvmat('ERROR','a Matlab function .m must be introduced');
|
---|
| 3923 | return
|
---|
| 3924 | end
|
---|
| 3925 | menu=update_menu(handles.transform_fct,transform);%add the selected fct to the menu
|
---|
| 3926 | ind_coord=get(handles.transform_fct,'Value');
|
---|
| 3927 | addpath(PathName)
|
---|
| 3928 | list_transform{ind_coord}=str2func(transform);% create the function handle corresponding to the newly seleced function
|
---|
| 3929 | set(handles.transform_fct,'UserData',list_transform)
|
---|
| 3930 | rmpath(PathName)
|
---|
| 3931 | % save the new menu in the personal file 'uvmat_perso.mat'
|
---|
| 3932 | dir_perso=prefdir;%personal Matalb directory
|
---|
| 3933 | profil_perso=fullfile(dir_perso,'uvmat_perso.mat');
|
---|
| 3934 | if exist(profil_perso,'file')
|
---|
| 3935 | for ilist=nb_builtin+1:numel(list_transform)
|
---|
| 3936 | ff=functions(list_transform{ilist});
|
---|
| 3937 | transform_fct{ilist-nb_builtin}=ff.file;
|
---|
| 3938 | end
|
---|
| 3939 | save (profil_perso,'transform_fct','-append'); %store the root name for future opening of uvmat
|
---|
| 3940 | end
|
---|
[2] | 3941 | end
|
---|
| 3942 |
|
---|
| 3943 | %check the current path to the selected function
|
---|
[40] | 3944 | if isa(list_transform{ind_coord},'function_handle')
|
---|
| 3945 | func=functions(list_transform{ind_coord});
|
---|
| 3946 | set(handles.path_transform,'String',fileparts(func.file)); %show the path to the senlected function
|
---|
| 3947 | else
|
---|
| 3948 | set(handles.path_transform,'String','')
|
---|
| 3949 | end
|
---|
[71] | 3950 |
|
---|
[2] | 3951 | set(handles.FixedLimits,'Value',0)
|
---|
| 3952 | set(handles.FixedLimits,'BackgroundColor',[0.7 0.7 0.7])
|
---|
| 3953 |
|
---|
| 3954 | UvData=get(huvmat,'UserData');
|
---|
| 3955 |
|
---|
| 3956 | %delete drawn objects
|
---|
| 3957 | hother=findobj('Tag','proj_object');%find all the proj objects
|
---|
| 3958 | for iobj=1:length(hother)
|
---|
| 3959 | delete_object(hother(iobj))
|
---|
| 3960 | end
|
---|
| 3961 | hother=findobj('Tag','DeformPoint');%find all the proj objects
|
---|
| 3962 | for iobj=1:length(hother)
|
---|
| 3963 | delete_object(hother(iobj))
|
---|
| 3964 | end
|
---|
| 3965 | hh=findobj('Tag','calib_points');
|
---|
| 3966 | if ~isempty(hh)
|
---|
| 3967 | delete(hh)
|
---|
| 3968 | end
|
---|
| 3969 | hhh=findobj('Tag','calib_marker');
|
---|
| 3970 | if ~isempty(hhh)
|
---|
| 3971 | delete(hhh)
|
---|
| 3972 | end
|
---|
| 3973 | if isfield(UvData,'Object')
|
---|
[71] | 3974 | UvData.Object=UvData.Object(1);
|
---|
[2] | 3975 | end
|
---|
[71] | 3976 | list_object=get(handles.list_object_1,'String');
|
---|
| 3977 | set(handles.list_object_1,'Value',1)
|
---|
| 3978 | set(handles.list_object_1,'String',list_object(1))
|
---|
| 3979 | set(handles.list_object_2,'Value',2)
|
---|
| 3980 | set(handles.list_object_2,'String',[list_object(1);{'...'}])
|
---|
| 3981 | list_object_2_Callback(hObject, eventdata, handles)
|
---|
[2] | 3982 |
|
---|
| 3983 | %delete mask if it is displayed
|
---|
| 3984 | if isequal(get(handles.mask_test,'Value'),1)%if the mask option is on
|
---|
| 3985 | UvData=rmfield(UvData,'MaskName'); %will impose mask refresh
|
---|
| 3986 | end
|
---|
| 3987 | set(huvmat,'UserData',UvData)
|
---|
| 3988 | run0_Callback(hObject, eventdata, handles)
|
---|
| 3989 |
|
---|
| 3990 | %--------------------------------------------
|
---|
| 3991 | function histo1_menu_Callback(hObject, eventdata, handles)
|
---|
| 3992 | %--------------------------------------------
|
---|
| 3993 | %plot first histo
|
---|
| 3994 | huvmat=get(handles.histo1_menu,'parent');
|
---|
| 3995 | histo_menu=get(handles.histo1_menu,'String');
|
---|
| 3996 | histo_value=get(handles.histo1_menu,'Value');
|
---|
| 3997 | FieldName=histo_menu{histo_value};
|
---|
| 3998 | UvData=get(huvmat,'UserData');
|
---|
| 3999 | update_histo(handles.histo_u,huvmat,FieldName)
|
---|
| 4000 |
|
---|
| 4001 | %----------------------------------------------
|
---|
| 4002 | function histo2_menu_Callback(hObject, eventdata, handles)
|
---|
| 4003 | %----------------------------------------------
|
---|
| 4004 | %plot second histo
|
---|
| 4005 | huvmat=get(handles.histo2_menu,'parent');
|
---|
| 4006 | histo_menu=get(handles.histo2_menu,'String');
|
---|
| 4007 | histo_value=get(handles.histo2_menu,'Value');
|
---|
| 4008 | FieldName=histo_menu{histo_value};
|
---|
| 4009 | UvData=get(huvmat,'UserData');
|
---|
| 4010 | update_histo(handles.histo_v,huvmat,FieldName)
|
---|
| 4011 |
|
---|
| 4012 |
|
---|
| 4013 | %--------------------------------------------
|
---|
| 4014 | %read the field .Fieldname stored in UvData and plot its histogram
|
---|
| 4015 | function update_histo(haxes,huvmat,FieldName)
|
---|
| 4016 | UvData=get(huvmat,'UserData');
|
---|
| 4017 |
|
---|
| 4018 | if ~isfield(UvData.Field,FieldName)
|
---|
| 4019 | msgbox_uvmat('ERROR',['no field ' FieldName ' for histogram'])
|
---|
| 4020 | return
|
---|
| 4021 | end
|
---|
| 4022 | Field=UvData.Field;
|
---|
| 4023 | FieldHisto=eval(['Field.' FieldName]);
|
---|
| 4024 | if isfield(Field,'FF') & ~isempty(Field.FF) & isequal(size(Field.FF),size(FieldHisto))
|
---|
| 4025 | indsel=find(Field.FF==0);%find values marked as false
|
---|
| 4026 | if ~isempty(indsel)
|
---|
| 4027 | FieldHisto=FieldHisto(indsel);
|
---|
| 4028 | end
|
---|
| 4029 | end
|
---|
| 4030 | if isempty(Field)
|
---|
| 4031 | msgbox_uvmat('ERROR',['empty field ' FieldName])
|
---|
| 4032 | else
|
---|
| 4033 | nxy=size(FieldHisto);
|
---|
| 4034 | Amin=double(min(min(min(FieldHisto))));%min of image
|
---|
| 4035 | Amax=double(max(max(max(FieldHisto))));%max of image
|
---|
| 4036 | if isequal(Amin,Amax)
|
---|
| 4037 | Histo.Txt=['uniform field =' num2str(Amin)];
|
---|
| 4038 | else
|
---|
| 4039 | Histo.ListVarName={FieldName,'histo'};
|
---|
| 4040 | if numel(nxy)==2
|
---|
| 4041 | Histo.VarDimName={FieldName,FieldName}; %dimensions for the histogram
|
---|
| 4042 | else %color images
|
---|
| 4043 | Histo.VarDimName={FieldName,{FieldName,'rgb'}}; %dimensions for the histogram
|
---|
| 4044 | end
|
---|
| 4045 | %unit
|
---|
| 4046 | units=[]; %default
|
---|
| 4047 | for ivar=1:numel(Field.ListVarName)
|
---|
| 4048 | if strcmp(Field.ListVarName{ivar},FieldName)
|
---|
| 4049 | if isfield(Field,'VarAttribute') && numel(Field.VarAttribute)>=ivar && isfield(Field.VarAttribute{ivar},'units')
|
---|
| 4050 | units=Field.VarAttribute{ivar}.units;
|
---|
| 4051 | break
|
---|
| 4052 | end
|
---|
| 4053 | end
|
---|
| 4054 | end
|
---|
| 4055 | if ~isempty(units)
|
---|
| 4056 | Histo.VarAttribute{1}.units=units;
|
---|
| 4057 | end
|
---|
| 4058 | eval(['Histo.' FieldName '=linspace(Amin,Amax,50);'])%absissa values for histo
|
---|
| 4059 | for col=1:size(FieldHisto,3)
|
---|
| 4060 | B=FieldHisto(:,:,col);
|
---|
| 4061 | C=reshape(double(B),1,nxy(1)*nxy(2));% reshape in a vector
|
---|
| 4062 | eval(['Histo.histo(:,col)=hist(C, Histo.' FieldName ');']); %calculate histogram
|
---|
| 4063 | end
|
---|
| 4064 | set(haxes,'XLimMode','auto')%reset auto mode (after zoom effect)
|
---|
| 4065 | set(haxes,'YLimMode','auto')
|
---|
| 4066 | plot_field(Histo,haxes);
|
---|
| 4067 | end
|
---|
| 4068 | end
|
---|
| 4069 |
|
---|
| 4070 |
|
---|
| 4071 |
|
---|
| 4072 | %------------------------------------------------
|
---|
| 4073 | %CALLBACKS FOR PLOTTING PARAMETERS
|
---|
| 4074 | %-------------------------------------------------
|
---|
| 4075 |
|
---|
| 4076 | %-----------------------------------------------------------------
|
---|
| 4077 | function MinA_Callback(hObject, eventdata, handles)
|
---|
| 4078 | %------------------------------------------
|
---|
| 4079 | set(handles.AutoScal,'Value',1) %suppress auto mode
|
---|
| 4080 | set(handles.AutoScal,'BackgroundColor',[1 1 0])
|
---|
[89] | 4081 | update_plot(handles);
|
---|
[2] | 4082 |
|
---|
| 4083 | %-----------------------------------------------------------------
|
---|
| 4084 | function MaxA_Callback(hObject, eventdata, handles)
|
---|
| 4085 | %--------------------------------------------
|
---|
| 4086 | set(handles.AutoScal,'Value',1) %suppress auto mode
|
---|
| 4087 | set(handles.AutoScal,'BackgroundColor',[1 1 0])
|
---|
[89] | 4088 | update_plot(handles);
|
---|
[2] | 4089 |
|
---|
| 4090 | %-----------------------------------------------
|
---|
| 4091 | function AutoScal_Callback(hObject, eventdata, handles)
|
---|
| 4092 | %--------------------------------------------
|
---|
| 4093 | test=get(handles.AutoScal,'Value');
|
---|
| 4094 | if test
|
---|
| 4095 | set(handles.AutoScal,'BackgroundColor',[1 1 0])
|
---|
| 4096 | else
|
---|
| 4097 | set(handles.AutoScal,'BackgroundColor',[0.7 0.7 0.7])
|
---|
| 4098 | update_plot(handles);
|
---|
| 4099 | end
|
---|
| 4100 |
|
---|
| 4101 | %-------------------------------------------------------------------
|
---|
| 4102 | function BW_Callback(hObject, eventdata, handles)
|
---|
| 4103 | %-------------------------------------------------------------------
|
---|
[89] | 4104 | update_plot(handles);
|
---|
[2] | 4105 |
|
---|
| 4106 | %-------------------------------------------------------------------
|
---|
| 4107 | function Contours_Callback(hObject, eventdata, handles)
|
---|
| 4108 | %-------------------------------------------------------------------
|
---|
| 4109 | val=get(handles.Contours,'Value');
|
---|
| 4110 | if val==2
|
---|
| 4111 | set(handles.interval_txt,'Visible','on')
|
---|
| 4112 | set(handles.IncrA,'Visible','on')
|
---|
| 4113 | else
|
---|
| 4114 | set(handles.interval_txt,'Visible','off')
|
---|
| 4115 | set(handles.IncrA,'Visible','off')
|
---|
| 4116 | end
|
---|
[89] | 4117 | update_plot(handles);
|
---|
[2] | 4118 |
|
---|
| 4119 | %-------------------------------------------------------------------
|
---|
| 4120 | function IncrA_Callback(hObject, eventdata, handles)
|
---|
| 4121 | %-------------------------------------------------------------------
|
---|
[89] | 4122 | update_plot(handles);
|
---|
[2] | 4123 |
|
---|
| 4124 | %-------------------------------------------------------------------
|
---|
| 4125 | function HideWarning_Callback(hObject, eventdata, handles)
|
---|
| 4126 | %-------------------------------------------------------------------
|
---|
[89] | 4127 | update_plot(handles);
|
---|
[2] | 4128 |
|
---|
| 4129 | %-------------------------------------------------------------------
|
---|
| 4130 | function HideFalse_Callback(hObject, eventdata, handles)
|
---|
| 4131 | %-------------------------------------------------------------------
|
---|
[89] | 4132 | update_plot(handles);
|
---|
[2] | 4133 |
|
---|
| 4134 | %-------------------------------------------------------------------
|
---|
| 4135 | function VecScale_Callback(hObject, eventdata, handles)
|
---|
| 4136 | %-------------------------------------------------------------------
|
---|
| 4137 | set(handles.AutoVec,'Value',1);
|
---|
| 4138 | set(handles.AutoVec,'BackgroundColor',[1 1 0])
|
---|
[89] | 4139 | update_plot(handles);
|
---|
[2] | 4140 |
|
---|
| 4141 | %-------------------------------------------------------------------
|
---|
| 4142 | function AutoVec_Callback(hObject, eventdata, handles)
|
---|
| 4143 | %-------------------------------------------------------------------
|
---|
| 4144 | test=get(handles.AutoVec,'Value');
|
---|
| 4145 | if test
|
---|
| 4146 | set(handles.AutoVec,'BackgroundColor',[1 1 0])
|
---|
| 4147 | else
|
---|
| 4148 | update_plot(handles);
|
---|
| 4149 | %set(handles.VecScale,'String',num2str(ScalOut.VecScale,3))
|
---|
| 4150 | set(handles.AutoVec,'BackgroundColor',[0.7 0.7 0.7])
|
---|
| 4151 | end
|
---|
| 4152 |
|
---|
[89] | 4153 | %------------------------------------------------------------------------
|
---|
[2] | 4154 | % --- Executes on selection change in decimate4 (nb_vec/4).
|
---|
| 4155 | function decimate4_Callback(hObject, eventdata, handles)
|
---|
[89] | 4156 | %------------------------------------------------------------------------
|
---|
| 4157 | update_plot(handles);
|
---|
[2] | 4158 |
|
---|
[89] | 4159 | %------------------------------------------------------------------------
|
---|
[2] | 4160 | % --- Executes on selection change in color_code menu
|
---|
| 4161 | function color_code_Callback(hObject, eventdata, handles)
|
---|
[89] | 4162 | %------------------------------------------------------------------------
|
---|
[2] | 4163 | set_vec_col_bar(handles)
|
---|
| 4164 | update_plot(handles);
|
---|
| 4165 |
|
---|
[89] | 4166 | %------------------------------------------------------------------------
|
---|
[2] | 4167 | % --- Executes on button press in AutoVecColor.
|
---|
| 4168 | function AutoVecColor_Callback(hObject, eventdata, handles)
|
---|
[89] | 4169 | %------------------------------------------------------------------------
|
---|
[2] | 4170 | test=get(handles.AutoVecColor,'Value');
|
---|
| 4171 | if test
|
---|
| 4172 | set(handles.AutoVecColor,'BackgroundColor',[1 1 0])
|
---|
| 4173 | else
|
---|
| 4174 | update_plot(handles);
|
---|
| 4175 | %set(handles.VecScale,'String',num2str(ScalOut.VecScale,3))
|
---|
| 4176 | set(handles.AutoVecColor,'BackgroundColor',[0.7 0.7 0.7])
|
---|
| 4177 | end
|
---|
| 4178 |
|
---|
[89] | 4179 | %------------------------------------------------------------------------
|
---|
[2] | 4180 | % --- Executes on selection change in max_vec.
|
---|
| 4181 | function min_vec_Callback(hObject, eventdata, handles)
|
---|
[89] | 4182 | %------------------------------------------------------------------------
|
---|
[2] | 4183 | max_vec_Callback(hObject, eventdata, handles)
|
---|
| 4184 |
|
---|
[89] | 4185 | %------------------------------------------------------------------------
|
---|
[2] | 4186 | % --- Executes on selection change in max_vec.
|
---|
| 4187 | function max_vec_Callback(hObject, eventdata, handles)
|
---|
[89] | 4188 | %------------------------------------------------------------------------
|
---|
[2] | 4189 | set(handles.AutoVecColor,'Value',1)
|
---|
| 4190 | AutoVecColor_Callback(hObject, eventdata, handles)
|
---|
| 4191 | min_val=str2num(get(handles.min_vec,'String'));
|
---|
| 4192 | max_val=str2num(get(handles.max_vec,'String'));
|
---|
| 4193 | slider1=get(handles.slider1,'Value');
|
---|
| 4194 | slider2=get(handles.slider2,'Value');
|
---|
| 4195 | colcode1=min_val+(max_val-min_val)*slider1;
|
---|
| 4196 | colcode2=min_val+(max_val-min_val)*slider2;
|
---|
| 4197 | set(handles.colcode1,'String',num2str(colcode1))
|
---|
| 4198 | set(handles.colcode2,'String',num2str(colcode2))
|
---|
| 4199 | update_plot(handles);
|
---|
| 4200 |
|
---|
[89] | 4201 | %------------------------------------------------------------------------
|
---|
| 4202 | % --- update the display of color code for vectors
|
---|
[2] | 4203 | function set_vec_col_bar(handles)
|
---|
[89] | 4204 | %------------------------------------------------------------------------
|
---|
[2] | 4205 | %get the image of the color display button 'vec_col_bar' in pixels
|
---|
| 4206 | set(handles.vec_col_bar,'Unit','pixel');
|
---|
| 4207 | pos_vert=get(handles.vec_col_bar,'Position');
|
---|
| 4208 | set(handles.vec_col_bar,'Unit','Normalized');
|
---|
| 4209 | width=ceil(pos_vert(3));
|
---|
| 4210 | height=ceil(pos_vert(4));
|
---|
| 4211 |
|
---|
| 4212 | %get slider indications
|
---|
| 4213 | list=get(handles.color_code,'String');
|
---|
| 4214 | ichoice=get(handles.color_code,'Value');
|
---|
| 4215 | colcode.ColorCode=list{ichoice};
|
---|
| 4216 | colcode.MinC=str2num(get(handles.min_vec,'String'));
|
---|
| 4217 | colcode.MaxC=str2num(get(handles.max_vec,'String'));
|
---|
| 4218 | test3color=strcmp(colcode.ColorCode,'rgb') || strcmp(colcode.ColorCode,'bgr');
|
---|
| 4219 | if test3color
|
---|
| 4220 | colcode.colcode1=str2num(get(handles.colcode1,'String'));
|
---|
| 4221 | colcode.colcode2=str2num(get(handles.colcode2,'String'));
|
---|
| 4222 | end
|
---|
| 4223 | % colcode.option=get(handles.vec_col_bar,'Value');
|
---|
| 4224 | colcode.FixedCbounds=0;
|
---|
| 4225 | % list_code=get(handles.col_vec,'String');% list menu fields
|
---|
| 4226 | % index_code=get(handles.col_vec,'Value');% selected string index
|
---|
| 4227 | % colcode.CName= list_code{index_code(1)}; % selected field used for vector color
|
---|
| 4228 | colcode.FixedCbounds=1;
|
---|
| 4229 | vec_C=colcode.MinC+(colcode.MaxC-colcode.MinC)*[0.5:width-0.5]/width;%sample of vec_C values from min to max
|
---|
| 4230 | [colorlist,col_vec]=set_col_vec(colcode,vec_C);
|
---|
| 4231 | oneheight=ones(1,height);
|
---|
| 4232 | A1=colorlist(col_vec,1)*oneheight;
|
---|
| 4233 | A2=colorlist(col_vec,2)*oneheight;
|
---|
| 4234 | A3=colorlist(col_vec,3)*oneheight;
|
---|
| 4235 | A(:,:,1)=A1';
|
---|
| 4236 | A(:,:,2)=A2';
|
---|
| 4237 | A(:,:,3)=A3';
|
---|
| 4238 | set(handles.vec_col_bar,'Cdata',A)
|
---|
| 4239 |
|
---|
| 4240 |
|
---|
| 4241 | %-------------------------------------------------------------------
|
---|
| 4242 | function [PlotType,ScalOut]=update_plot(handles)
|
---|
| 4243 | %-------------------------------------------------------------------
|
---|
| 4244 | haxes= handles.axes3;
|
---|
| 4245 | AxeData=get(haxes,'UserData');
|
---|
| 4246 | PlotParam=read_plot_param(handles);
|
---|
[89] | 4247 | PlotParam.Scalar
|
---|
[2] | 4248 | [PlotType,PlotParamOut]= plot_field(AxeData,haxes,PlotParam,1);
|
---|
| 4249 | write_plot_param(handles,PlotParamOut); %update the auto plot parameters
|
---|
| 4250 |
|
---|
| 4251 | %-------------------------------------------------------------------
|
---|
| 4252 | % --- Executes on button press in grid.
|
---|
| 4253 | function grid_Callback(hObject, eventdata, handles)
|
---|
| 4254 |
|
---|
[61] | 4255 |
|
---|
[2] | 4256 |
|
---|
| 4257 | %-------------------------------------------------------------------
|
---|
| 4258 | % --- Executes on selection change in edit.
|
---|
| 4259 | function edit_Callback(hObject, eventdata, handles)
|
---|
| 4260 | %-------------------------------------------------------------------
|
---|
[61] | 4261 | UvData=get(handles.uvmat,'UserData');%read UvData properties stored on the uvmat interface
|
---|
[2] | 4262 | test=get(handles.edit,'Value');
|
---|
| 4263 | if test
|
---|
| 4264 | UvData.MouseAction='edit_object';
|
---|
| 4265 | set(handles.edit,'BackgroundColor',[1,1,0])
|
---|
| 4266 | %suppress the other options
|
---|
| 4267 | set(handles.zoom,'Value',0)
|
---|
| 4268 | zoom_Callback(hObject, eventdata, handles)
|
---|
| 4269 | set(handles.edit_vect,'Value',0)
|
---|
| 4270 | edit_vect_Callback(hObject, eventdata, handles)
|
---|
[61] | 4271 | %list_object_Callback(hObject, eventdata, handles)
|
---|
[2] | 4272 | else
|
---|
| 4273 | UvData.MouseAction='none';
|
---|
| 4274 | set(handles.edit,'BackgroundColor',[0.7,0.7,0.7])
|
---|
| 4275 | end
|
---|
[61] | 4276 | set(handles.uvmat,'UserData',UvData);
|
---|
| 4277 | hset_object=findobj(allchild(0),'Tag','set_object');
|
---|
| 4278 | if ~isempty(hset_object)
|
---|
| 4279 | hhset_object=guidata(hset_object);
|
---|
| 4280 | if test
|
---|
[71] | 4281 | set(hhset_object.PLOT,'enable','on');
|
---|
[61] | 4282 | else
|
---|
[71] | 4283 | set(hhset_object.PLOT,'enable','off');
|
---|
[61] | 4284 | end
|
---|
| 4285 | end
|
---|
[2] | 4286 |
|
---|
[61] | 4287 | %------------------------------------------------------------------------
|
---|
| 4288 | % --- Executes on selection change in list_object_1.
|
---|
| 4289 | function list_object_1_Callback(hObject, eventdata, handles)
|
---|
| 4290 | %------------------------------------------------------------------------
|
---|
| 4291 | list_str=get(handles.list_object_1,'String');
|
---|
| 4292 | IndexObj=get(handles.list_object_1,'Value');
|
---|
| 4293 | str_1=list_str{IndexObj};
|
---|
| 4294 | val_2=get(handles.list_object_2,'Value');
|
---|
| 4295 | str_2=get(handles.list_object_2,'String');
|
---|
[71] | 4296 | if isequal(val_2,IndexObj)% if the first selection is equal to the second, it will suppress the second
|
---|
| 4297 | set(handles.list_object_2,'Value',numel(str_2))%select the end of the list ('...')
|
---|
[61] | 4298 | list_object_2_Callback(hObject, eventdata, handles)
|
---|
| 4299 | end
|
---|
[71] | 4300 | update_object(handles,IndexObj,1,str_1)
|
---|
[61] | 4301 |
|
---|
| 4302 | %------------------------------------------------------------------------
|
---|
| 4303 | % --- Executes on selection change in list_object_1.
|
---|
| 4304 | function list_object_2_Callback(hObject, eventdata, handles)
|
---|
| 4305 | %------------------------------------------------------------------------
|
---|
| 4306 | list_str=get(handles.list_object_2,'String');
|
---|
| 4307 | IndexObj=get(handles.list_object_2,'Value');
|
---|
| 4308 | if isequal(list_str{IndexObj},'...')
|
---|
[71] | 4309 | hview_field=findobj(allchild(0),'Tag','view_field');
|
---|
[61] | 4310 | if ~isempty(hview_field)
|
---|
| 4311 | delete(hview_field)
|
---|
| 4312 | end
|
---|
| 4313 | else
|
---|
[71] | 4314 | update_object(handles,IndexObj,2,list_str{IndexObj})
|
---|
[61] | 4315 | end
|
---|
| 4316 |
|
---|
| 4317 | %------------------------------------------------------------------------
|
---|
[71] | 4318 | function update_object(handles,IndexObj,option,ObjectName)
|
---|
[61] | 4319 | %------------------------------------------------------------------------
|
---|
[60] | 4320 | UvData=get(handles.uvmat,'UserData');%read UvData properties stored on the uvmat interface
|
---|
[2] | 4321 | if ~(length(UvData.Object)>=IndexObj);
|
---|
| 4322 | return
|
---|
| 4323 | end
|
---|
| 4324 | ObjectData=UvData.Object{IndexObj};
|
---|
[71] | 4325 | ObjectData.Name=ObjectName;
|
---|
| 4326 | if isequal(get(handles.edit,'Value'),1)
|
---|
| 4327 | ObjectData.enable_plot=1; % desable the PLOT option in the set_object GUI (editing mode
|
---|
[2] | 4328 | end
|
---|
| 4329 | PlotHandles=get_plot_handles(handles);%get the handles of the interface elements setting the plotting parameters
|
---|
| 4330 | ZBounds=0; % default
|
---|
| 4331 | if isfield(UvData,'ZMin') && isfield(UvData,'ZMax')
|
---|
| 4332 | ZBounds(1)=UvData.ZMin; %minimum for the Z slider
|
---|
| 4333 | ZBounds(2)=UvData.ZMax;%maximum for the Z slider
|
---|
| 4334 | end
|
---|
[71] | 4335 | hset_object=findobj(allchild(0),'tag','set_object');
|
---|
[61] | 4336 | if ~isempty(hset_object)
|
---|
| 4337 | delete(hset_object)% delete existing version of set_object
|
---|
| 4338 | end
|
---|
| 4339 | hset_object=set_object(ObjectData,PlotHandles,ZBounds);% call the set_object interface,
|
---|
[71] | 4340 | set(hset_object,'name',ObjectName)
|
---|
[82] | 4341 |
|
---|
| 4342 | % %project the current field on the object and plot it
|
---|
| 4343 | % ProjData= proj_field(UvData.Field,ObjectData,IndexObj);%project the current interface field on ObjectData
|
---|
| 4344 | % if option==1%length(UvData.Object)>= IndexObj && isfield(UvData.Object{IndexObj},'plotaxes')&& ishandle(UvData.Object{IndexObj}.plotaxes)
|
---|
| 4345 | % plot_field(ProjData,handles.axes3,PlotHandles);
|
---|
| 4346 | % UvData.Object{IndexObj}.plotaxes=handles.axes3;
|
---|
| 4347 | % else
|
---|
| 4348 | % UvData.Object{IndexObj}.plotaxes=view_field(ProjData);
|
---|
[76] | 4349 | % end
|
---|
[82] | 4350 | % set(handles.uvmat,'UserData',UvData)
|
---|
| 4351 | % hother=findobj('Tag','proj_object');%find all the proj objects
|
---|
| 4352 | % for iobj=1:length(hother)
|
---|
| 4353 | % if isequal(get(hother(iobj),'Type'),'rectangle')|isequal(get(hother(iobj),'Type'),'patch')
|
---|
| 4354 | % set(hother(iobj),'EdgeColor','b')
|
---|
| 4355 | % if isequal(get(hother(iobj),'FaceColor'),'m')
|
---|
| 4356 | % set(hother(iobj),'FaceColor','b')
|
---|
| 4357 | % end
|
---|
| 4358 | % elseif isequal(get(hother(iobj),'Type'),'image')
|
---|
| 4359 | % Acolor=get(hother(iobj),'CData');
|
---|
| 4360 | % Acolor(:,:,1)=zeros(size(Acolor,1),size(Acolor,2));
|
---|
| 4361 | % set(hother(iobj),'CData',Acolor);
|
---|
| 4362 | % else
|
---|
| 4363 | % set(hother(iobj),'Color','b')
|
---|
| 4364 | % end
|
---|
| 4365 | % set(hother(iobj),'Selected','off')
|
---|
| 4366 | % end
|
---|
[2] | 4367 | hother=findobj('Tag','DeformPoint');
|
---|
| 4368 | set(hother,'Color','b');
|
---|
| 4369 | set(hother,'Selected','off')
|
---|
| 4370 | if isfield(ObjectData,'HandlesDisplay')
|
---|
| 4371 | for iview=1:length(ObjectData.HandlesDisplay)
|
---|
| 4372 | if ishandle(ObjectData.HandlesDisplay(iview))
|
---|
| 4373 | uistack(ObjectData.HandlesDisplay(iview),'top')
|
---|
| 4374 | linetype=get(ObjectData.HandlesDisplay(iview),'Type');
|
---|
| 4375 | if isequal(linetype,'line')
|
---|
| 4376 | set(ObjectData.HandlesDisplay(iview),'Color','m'); %set the selected object to magenta color
|
---|
| 4377 | elseif isequal(linetype,'rectangle')
|
---|
| 4378 | set(ObjectData.HandlesDisplay(iview),'EdgeColor','m'); %set the selected object to magenta color
|
---|
| 4379 | elseif isequal(linetype,'patch')
|
---|
| 4380 | set(ObjectData.HandlesDisplay(iview),'FaceColor','m'); %set the selected object to magenta color
|
---|
| 4381 | end
|
---|
| 4382 | SubObjectData=get(ObjectData.HandlesDisplay(iview),'UserData');
|
---|
| 4383 | if isfield(SubObjectData,'SubObject')& ishandle(SubObjectData.SubObject)
|
---|
| 4384 | uistack(SubObjectData.SubObject,'top')
|
---|
| 4385 | for iobj=1:length(SubObjectData.SubObject)
|
---|
| 4386 | hsub=SubObjectData.SubObject(iobj);
|
---|
| 4387 | if isequal(get(hsub,'Type'),'rectangle')
|
---|
| 4388 | set(hsub,'EdgeColor','m'); %set the selected object to magenta color
|
---|
| 4389 | elseif isequal(get(hsub,'Type'),'image')
|
---|
| 4390 | Acolor=get(hsub,'CData');
|
---|
| 4391 | Acolor(:,:,1)=Acolor(:,:,3);
|
---|
| 4392 | set(hsub,'CData',Acolor);
|
---|
| 4393 | else
|
---|
| 4394 | set(hsub,'Color','m')
|
---|
| 4395 | end
|
---|
| 4396 | end
|
---|
| 4397 | end
|
---|
| 4398 | if isfield(SubObjectData,'DeformPoint')& ishandle(SubObjectData.DeformPoint)
|
---|
| 4399 | set(SubObjectData.DeformPoint,'Color','m')
|
---|
| 4400 | end
|
---|
| 4401 | end
|
---|
| 4402 | end
|
---|
| 4403 | end
|
---|
[61] | 4404 | pause(0.1)
|
---|
| 4405 | figure(hset_object)%put set_object in front
|
---|
[2] | 4406 |
|
---|
| 4407 | %------------------------------------------------------
|
---|
| 4408 | % --- Executes on button press in Menu/Export/field in workspace.
|
---|
| 4409 | %------------------------------------------------------
|
---|
| 4410 | function MenuExportField_Callback(hObject, eventdata, handles)
|
---|
[89] | 4411 | global Data_uvmat
|
---|
| 4412 | Data_uvmat=get(handles.uvmat,'UserData');
|
---|
| 4413 | evalin('base','global Data_uvmat')%make CurData global in the workspace
|
---|
[82] | 4414 | display(['current field :'])
|
---|
[89] | 4415 | evalin('base','Data_uvmat') %display CurData in the workspace
|
---|
[82] | 4416 | commandwindow; %brings the Matlab command window to the front
|
---|
[2] | 4417 |
|
---|
| 4418 | %------------------------------------------------------
|
---|
| 4419 | % --- Executes on button press in Menu/Export/extract figure.
|
---|
| 4420 | %------------------------------------------------------
|
---|
| 4421 | function MenuExport_plot_Callback(hObject, eventdata, handles)
|
---|
| 4422 | huvmat=get(handles.MenuExport_plot,'parent');
|
---|
| 4423 | UvData=get(huvmat,'UserData');
|
---|
| 4424 | hfig=figure;
|
---|
| 4425 | newaxes=copyobj(handles.axes3,hfig);
|
---|
| 4426 | map=colormap(handles.axes3);
|
---|
| 4427 | colormap(map);%transmit the current colormap to the zoom fig
|
---|
| 4428 | colorbar
|
---|
| 4429 |
|
---|
| 4430 |
|
---|
| 4431 | % --------------------------------------------------------------------
|
---|
| 4432 | function Insert_Callback(hObject, eventdata, handles)
|
---|
| 4433 |
|
---|
| 4434 |
|
---|
| 4435 | % --------------------------------------------------------------------
|
---|
| 4436 | function MenuHelp_Callback(hObject, eventdata, handles)
|
---|
| 4437 | % --------------------------------------------------------------------
|
---|
| 4438 | path_to_uvmat=which ('uvmat');% check the path of uvmat
|
---|
| 4439 | pathelp=fileparts(path_to_uvmat);
|
---|
[36] | 4440 | helpfile=fullfile(pathelp,'uvmat_doc','uvmat_doc.html');
|
---|
| 4441 | if isempty(dir(helpfile)), msgbox_uvmat('ERROR','Please put the help file uvmat_doc.html in the sub-directory /uvmat_doc of the UVMAT package')
|
---|
[2] | 4442 | else
|
---|
[36] | 4443 | addpath (fullfile(pathelp,'uvmat_doc'))
|
---|
[2] | 4444 | web(helpfile);
|
---|
| 4445 | end
|
---|
| 4446 |
|
---|
| 4447 |
|
---|
| 4448 | % --------------------------------------------------------------------
|
---|
| 4449 | function MenuExportMovie_Callback(hObject, eventdata, handles)
|
---|
| 4450 | % --------------------------------------------------------------------
|
---|
| 4451 | set(handles.MenuExportMovie,'BusyAction','queue')% activate the button
|
---|
| 4452 | huvmat=get(handles.run0,'parent');
|
---|
| 4453 | UvData=get(huvmat,'UserData');
|
---|
| 4454 | [xx,xx,FileBase]=read_file_boxes(handles);
|
---|
| 4455 | %read the current input file name
|
---|
| 4456 | 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)'};
|
---|
| 4457 | dlg_title = 'select properties of the output avi movie';
|
---|
| 4458 | num_lines= 1;
|
---|
| 4459 | nbfield_cell=get(handles.last_i,'String');
|
---|
| 4460 | def = {[FileBase '_out.avi'];'10';'1';'[0.03 0.05 0.95 0.92]';'10'};
|
---|
| 4461 | answer = inputdlg(prompt,dlg_title,num_lines,def,'on');
|
---|
| 4462 | aviname=answer{1};
|
---|
| 4463 | fps=str2num(answer{2});
|
---|
| 4464 | % check for existing file with output name aviname
|
---|
| 4465 | if exist(aviname,'file')
|
---|
| 4466 | backup=aviname;
|
---|
| 4467 | testexist=2;
|
---|
| 4468 | while testexist==2
|
---|
| 4469 | backup=[backup '~'];
|
---|
| 4470 | testexist=exist(backup,'file');
|
---|
| 4471 | end
|
---|
| 4472 | [success,message]=copyfile(aviname,backup);%make backup of the existing file
|
---|
| 4473 | if isequal(success,1)
|
---|
| 4474 | delete(aviname)%delete existing file
|
---|
| 4475 | else
|
---|
| 4476 | msgbox_uvmat('ERROR',message)
|
---|
| 4477 | return
|
---|
| 4478 | end
|
---|
| 4479 | end
|
---|
| 4480 | %create avi open
|
---|
| 4481 | aviobj=avifile(aviname,'Compression','None','fps',fps);
|
---|
| 4482 |
|
---|
| 4483 | %display first view for tests
|
---|
| 4484 | newfig=figure;
|
---|
| 4485 | newaxes=copyobj(handles.axes3,newfig);%new plotting axes in the new figure
|
---|
| 4486 | set(newaxes,'Tag','movieaxes')
|
---|
| 4487 | nbpix=[512 384]*str2num(answer{3});
|
---|
| 4488 | set(gcf,'Position',[1 1 nbpix])% resolution XVGA
|
---|
| 4489 | set(newaxes,'Position',eval(answer{4}));
|
---|
| 4490 | map=colormap(handles.axes3);
|
---|
| 4491 | colormap(map);%transmit the current colormap to the zoom fig
|
---|
| 4492 | msgbox_uvmat('INPUT_Y-N',{['adjust figure ' num2str(newfig) ' with its matlab edit menu '] ;...
|
---|
| 4493 | ['then press OK to get the avi movie as a copy of figure ' num2str(newfig) ' display']});
|
---|
| 4494 | UvData.Object{1}.plotaxes=newaxes;% the axis in the new figure becomes the current main plotting axes
|
---|
| 4495 | set(huvmat,'UserData',UvData);
|
---|
| 4496 | increment=str2num(get(handles.increment_scan,'String')); %get the field increment d
|
---|
| 4497 | set(handles.STOP,'Visible','on')
|
---|
| 4498 | set(handles.speed,'Visible','on')
|
---|
| 4499 | set(handles.speed_txt,'Visible','on')
|
---|
[81] | 4500 | set(handles.Movie,'BusyAction','queue')
|
---|
[2] | 4501 |
|
---|
| 4502 | imin=str2num(get(handles.i1,'String'));
|
---|
| 4503 | imax=str2num(answer{5});
|
---|
| 4504 | % if isfield(UvData,'Time')
|
---|
| 4505 | htitle=get(newaxes,'Title');
|
---|
| 4506 | xlim=get(newaxes,'XLim');
|
---|
| 4507 | ylim=get(newaxes,'YLim');
|
---|
| 4508 | set(htitle,'Position',[xlim(2)+0.07*(xlim(2)-xlim(1)) ylim(2)-0.05*(ylim(2)-ylim(1)) 0])
|
---|
| 4509 | time_str=get(handles.abs_time,'String');
|
---|
| 4510 | set(htitle,'String',['t=' time_str])
|
---|
| 4511 | set(handles.speed,'Value',1)
|
---|
| 4512 | for i=1:imax
|
---|
| 4513 | if get(handles.speed,'Value')~=0 & isequal(get(handles.MenuExportMovie,'BusyAction'),'queue') % enable STOP command
|
---|
| 4514 | runpm(hObject,eventdata,handles,increment)
|
---|
| 4515 | drawnow
|
---|
| 4516 | time_str=get(handles.abs_time,'String');
|
---|
| 4517 | if ishandle(htitle)
|
---|
| 4518 | set(htitle,'String',['t=' time_str])
|
---|
| 4519 | end
|
---|
| 4520 | mov=getframe(newfig);
|
---|
| 4521 | aviobj=addframe(aviobj,mov);
|
---|
| 4522 | end
|
---|
| 4523 | end
|
---|
| 4524 | aviobj=close(aviobj);
|
---|
| 4525 | UvData.Object{1}.plotaxes=handles.axes3;
|
---|
| 4526 | set(huvmat,'UserData',UvData);
|
---|
| 4527 | msgbox_uvmat('CONFIRMATION',{['movie ' aviname ' created '];['with ' num2str(imax) ' frames']})
|
---|
| 4528 |
|
---|
| 4529 |
|
---|
| 4530 | % ------------------------------------------------------------------
|
---|
| 4531 | function MenuCalib_Callback(hObject, eventdata, handles)
|
---|
[71] | 4532 |
|
---|
[61] | 4533 | UvData=get(handles.uvmat,'UserData');%read UvData properties stored on the uvmat interface
|
---|
[71] | 4534 |
|
---|
| 4535 | %suppress competing options
|
---|
[61] | 4536 | set(handles.zoom,'Value',0)
|
---|
| 4537 | set(handles.zoom,'BackgroundColor',[0.7 0.7 0.7])
|
---|
[71] | 4538 | set(handles.MenuMask,'enable','off')
|
---|
| 4539 | set(handles.MenuGrid,'enable','off')
|
---|
[67] | 4540 | set(handles.MenuObject,'enable','off')
|
---|
| 4541 | set(handles.MenuEdit,'enable','off')
|
---|
[61] | 4542 | set(handles.list_object_1,'Value',1)
|
---|
| 4543 | % initiate display of GUI geometry_calib
|
---|
| 4544 | data=[]; %default
|
---|
| 4545 | if isfield(UvData,'CoordType')
|
---|
| 4546 | data.CoordType=UvData.CoordType;
|
---|
| 4547 | end
|
---|
| 4548 | pos=get(handles.uvmat,'Position');
|
---|
| 4549 | pos(1)=pos(1)+pos(3)-0.311+0.04; %0.311= width of the geometry_calib interface (units relative to the srcreen)
|
---|
| 4550 | pos(2)=pos(2)-0.02;
|
---|
| 4551 | [FileName,RootPath,FileBase,FileIndices,FileExt,SubDir]=read_file_boxes(handles);
|
---|
| 4552 | [UvData.hset_object,UvData.sethandles]=geometry_calib(handles,pos,FileName);% call the set_object interface
|
---|
| 4553 | pos_uvmat=get(handles.uvmat,'Position');
|
---|
[71] | 4554 |
|
---|
[61] | 4555 | if isfield(UvData,'CalOrigin')
|
---|
| 4556 | pos_cal(1)=pos_uvmat(1)+UvData.CalOrigin(1)*pos_uvmat(3);
|
---|
| 4557 | pos_cal(2)=pos_uvmat(2)+UvData.CalOrigin(2)*pos_uvmat(4);
|
---|
| 4558 | pos_cal(3:4)=UvData.CalSize .* pos_uvmat(3:4);
|
---|
| 4559 | set(UvData.hset_object,'Position',pos_cal)
|
---|
| 4560 | end
|
---|
| 4561 | UvData.MouseAction='calib';
|
---|
| 4562 | set(handles.uvmat,'UserData',UvData);
|
---|
[2] | 4563 |
|
---|
[61] | 4564 |
|
---|
[2] | 4565 | % ------------------------------------------------------------------
|
---|
| 4566 | function MenuMask_Callback(hObject, eventdata, handles)
|
---|
[82] | 4567 | % set(handles.TOOLS_txt,'Visible','on')
|
---|
| 4568 | % set(handles.frame_tools,'Visible','on')
|
---|
| 4569 | % % set(handles.create,'Visible','on')
|
---|
| 4570 | % % set(handles.create,'Value',1)
|
---|
| 4571 | % % set(handles.create,'BackgroundColor',[1 1 0]) %visualise in yellow
|
---|
| 4572 | % set(handles.save_mask,'Visible','on')
|
---|
| 4573 | % set(handles.masklevel,'Visible','on')
|
---|
| 4574 | % if isequal(get(handles.z_index,'Visible'),'on')
|
---|
| 4575 | % nb_slice=str2num(get(handles.nb_slice,'String'));
|
---|
| 4576 | % for ilist=1:nb_slice
|
---|
| 4577 | % list_index{ilist,1}=num2str(ilist);
|
---|
| 4578 | % end
|
---|
| 4579 | % set(handles.masklevel,'String',list_index)
|
---|
| 4580 | % val=str2num(get(handles.z_index,'String'));
|
---|
| 4581 | % if val<=nb_slice
|
---|
| 4582 | % set(handles.masklevel,'Value',val)
|
---|
| 4583 | % end
|
---|
| 4584 | % else
|
---|
| 4585 | % set(handles.masklevel,'String',{'1'})
|
---|
| 4586 | % set(handles.masklevel,'Value',1)
|
---|
| 4587 | % end
|
---|
| 4588 | % if ishandle(handles.UVMAT_title)
|
---|
| 4589 | % delete(handles.UVMAT_title)
|
---|
| 4590 | % end
|
---|
[61] | 4591 | UvData=get(handles.uvmat,'UserData');%read UvData properties stored on the uvmat interface
|
---|
[82] | 4592 | % set(handles.zoom,'Value',0)
|
---|
| 4593 | % set(handles.zoom,'BackgroundColor',[0.7 0.7 0.7])
|
---|
| 4594 | % set(handles.edit_vect,'Value',0)
|
---|
| 4595 | % edit_vect_Callback(hObject, eventdata, handles)
|
---|
| 4596 | % set(handles.edit,'Value',0)
|
---|
| 4597 | % set(handles.edit,'BackgroundColor',[0.7 0.7 0.7])
|
---|
| 4598 | % set(handles.edit_vect,'Value',0)
|
---|
| 4599 | % edit_vect_Callback(hObject, eventdata, handles)
|
---|
[61] | 4600 | % set(handles.cal,'Value',0)
|
---|
| 4601 | % set(handles.cal,'BackgroundColor',[0 1 0])
|
---|
[2] | 4602 |
|
---|
| 4603 | %initiate the GUI set_object
|
---|
[82] | 4604 | % data.TITLE='MASK';
|
---|
| 4605 | % if isfield(UvData,'CoordType')
|
---|
| 4606 | % data.CoordType=UvData.CoordType;
|
---|
| 4607 | % end
|
---|
| 4608 | % if isfield(UvData,'Mesh')&&~isempty(UvData.Mesh)
|
---|
| 4609 | % data.YMax=UvData.Mesh;
|
---|
| 4610 | % elseif isfield(UvData.Field,'AX')&&isfield(UvData.Field,'AY')&& isfield(UvData.Field,'A')%only image
|
---|
| 4611 | % np=size(UvData.Field.A);
|
---|
| 4612 | % meshx=(UvData.Field.AX(end)-UvData.Field.AX(1))/(np(2)-1);
|
---|
| 4613 | % meshy=abs(UvData.Field.AY(end)-UvData.Field.AY(1))/(np(1)-1);
|
---|
| 4614 | % data.YMax=max(meshx,meshy);
|
---|
| 4615 | % data.DX=max(meshx,meshy);
|
---|
| 4616 | % end
|
---|
| 4617 | % data.Coord=[0 0 0]; %default
|
---|
| 4618 | % PlotHandles=get_plot_handles(handles);%get the handles of the graphic objects setting the plotting parameters
|
---|
| 4619 | % [hset_object,UvData.sethandles]=set_object(data,PlotHandles);% call the set_object interface
|
---|
| 4620 | % pos_uvmat=get(handles.uvmat,'Position');
|
---|
| 4621 | % if isfield(UvData,'SetObjectOrigin')
|
---|
| 4622 | % pos_set_object(1:2)=UvData.SetObjectOrigin + pos_uvmat(1:2);
|
---|
| 4623 | % pos_set_object(3:4)=UvData.SetObjectSize .* pos_uvmat(3:4);
|
---|
| 4624 | % set(hset_object,'Position',pos_set_object)
|
---|
| 4625 | % end
|
---|
| 4626 | ListObj=UvData.Object;
|
---|
| 4627 | select=zeros(1,numel(ListObj));
|
---|
| 4628 | for iobj=1:numel(ListObj);
|
---|
| 4629 | if strcmp(ListObj{iobj}.ProjMode,'mask_inside')||strcmp(ListObj{iobj}.ProjMode,'mask_outside')
|
---|
| 4630 | select(iobj)=1;
|
---|
| 4631 | end
|
---|
[2] | 4632 | end
|
---|
[82] | 4633 | val=find(select);
|
---|
| 4634 | if isempty(val)
|
---|
| 4635 | msgbox_uvmat('ERROR','polygons must be first created by Projection object/mask polygon in the menu bar');
|
---|
| 4636 | return
|
---|
| 4637 | else
|
---|
| 4638 | set(handles.list_object_1,'Max',2);%allow multiple selection
|
---|
| 4639 | set(handles.list_object_1,'Value',val);
|
---|
| 4640 | % answer=msgbox_uvmat('INPUT_Y-N',['make the mask image from ' num2str(numel(val)) ' polygons']);
|
---|
| 4641 | % if ~isempty(answer)
|
---|
| 4642 | flag=1;
|
---|
| 4643 | npx=size(UvData.Field.A,2);
|
---|
| 4644 | npy=size(UvData.Field.A,1);
|
---|
| 4645 | xi=[0.5:npx-0.5];
|
---|
| 4646 | yi=[0.5:npy-0.5];
|
---|
| 4647 | [Xi,Yi]=meshgrid(xi,yi);
|
---|
| 4648 | if isfield(UvData,'Object')
|
---|
| 4649 | for iobj=1:length(UvData.Object)
|
---|
| 4650 | ObjectData=UvData.Object{iobj};
|
---|
| 4651 | if isfield(ObjectData,'ProjMode') &&(isequal(ObjectData.ProjMode,'mask_inside')||isequal(ObjectData.ProjMode,'mask_outside'));
|
---|
| 4652 | flagobj=1;
|
---|
| 4653 | testphys=0; %coordinates in pixels by default
|
---|
| 4654 | if isfield(ObjectData,'CoordType') && isequal(ObjectData.CoordType,'phys')
|
---|
| 4655 | if isfield(UvData,'XmlData')&& isfield(UvData.XmlData,'GeometryCalib')
|
---|
| 4656 | Calib=UvData.XmlData.GeometryCalib;
|
---|
| 4657 | testphys=1;
|
---|
| 4658 | end
|
---|
| 4659 | end
|
---|
| 4660 | if isfield(ObjectData,'Coord')& isfield(ObjectData,'Style')
|
---|
| 4661 | if isequal(ObjectData.Style,'polygon')
|
---|
| 4662 | X=ObjectData.Coord(:,1);
|
---|
| 4663 | Y=ObjectData.Coord(:,2);
|
---|
| 4664 | if testphys
|
---|
| 4665 | [X,Y]=px_XYZ(Calib,X,Y,0);% to generalise with 3D cases
|
---|
| 4666 | end
|
---|
| 4667 | flagobj=~inpolygon(Xi,Yi,X',Y');%=0 inside the polygon, 1 outside
|
---|
| 4668 | elseif isequal(ObjectData.Style,'ellipse')
|
---|
| 4669 | if testphys
|
---|
| 4670 | %[X,Y]=px_XYZ(Calib,X,Y,0);% TODO:create a polygon boundary and transform to phys
|
---|
| 4671 | end
|
---|
| 4672 | RangeX=max(ObjectData.RangeX);
|
---|
| 4673 | RangeY=max(ObjectData.RangeY);
|
---|
| 4674 | X2Max=RangeX*RangeX;
|
---|
| 4675 | Y2Max=RangeY*RangeY;
|
---|
| 4676 | distX=(Xi-ObjectData.Coord(1,1));
|
---|
| 4677 | distY=(Yi-ObjectData.Coord(1,2));
|
---|
| 4678 | flagobj=(distX.*distX/X2Max+distY.*distY/Y2Max)>1;
|
---|
| 4679 | elseif isequal(ObjectData.Style,'rectangle')
|
---|
| 4680 | if testphys
|
---|
| 4681 | %[X,Y]=px_XYZ(Calib,X,Y,0);% TODO:create a polygon boundary and transform to phys
|
---|
| 4682 | end
|
---|
| 4683 | distX=abs(Xi-ObjectData.Coord(1,1));
|
---|
| 4684 | distY=abs(Yi-ObjectData.Coord(1,2));
|
---|
| 4685 | flagobj=distX>max(ObjectData.RangeX) | distY>max(ObjectData.RangeY);
|
---|
| 4686 | end
|
---|
| 4687 | if isequal(ObjectData.ProjMode,'mask_outside')
|
---|
| 4688 | flagobj=~flagobj;
|
---|
| 4689 | end
|
---|
| 4690 | flag=flag & flagobj;
|
---|
| 4691 | end
|
---|
| 4692 | end
|
---|
| 4693 | end
|
---|
| 4694 | end
|
---|
| 4695 | % flag=~flag;
|
---|
| 4696 | %mask name
|
---|
| 4697 | RootPath=get(handles.RootPath,'String');
|
---|
| 4698 | RootFile=get(handles.RootFile,'String');
|
---|
| 4699 | if ~isempty(RootFile)&(isequal(RootFile(1),'/')| isequal(RootFile(1),'\'))
|
---|
| 4700 | RootFile(1)=[];
|
---|
| 4701 | end
|
---|
| 4702 | filebase=fullfile(RootPath,RootFile);
|
---|
| 4703 | list=get(handles.masklevel,'String');
|
---|
| 4704 | masknumber=num2str(length(list));
|
---|
| 4705 | maskindex=get(handles.masklevel,'Value');
|
---|
| 4706 | mask_name=name_generator([filebase '_' masknumber 'mask'],maskindex,1,'.png','_i');
|
---|
| 4707 | imflag=uint8(255*(0.392+0.608*flag));% =100 for flag=0 (vectors not computed when 20<imflag<200)
|
---|
| 4708 | imflag=flipdim(imflag,1);
|
---|
| 4709 | % imflag=uint8(255*flag);% =0 for flag=0 (vectors=0 when
|
---|
| 4710 | % 20<imflag<200)
|
---|
| 4711 |
|
---|
| 4712 | %display the mask
|
---|
| 4713 | %update_mask(handles,num_i1,num_j1)
|
---|
| 4714 | figure;
|
---|
| 4715 | vec=linspace(0,1,256);%define a linear greyscale colormap
|
---|
| 4716 | map=[vec' vec' vec'];
|
---|
| 4717 | colormap(map)
|
---|
| 4718 | image(imflag);
|
---|
[86] | 4719 | answer=msgbox_uvmat('INPUT_TXT','mask file name:', mask_name);
|
---|
[82] | 4720 | if ~strcmp(answer,'Cancel')
|
---|
| 4721 | imwrite(imflag,answer,'BitDepth',8);
|
---|
| 4722 | end
|
---|
| 4723 | set(list_object_1,'Value',1)
|
---|
| 4724 | set(list_object_1,'Max',1)
|
---|
| 4725 | % end
|
---|
| 4726 | end
|
---|
| 4727 |
|
---|
| 4728 |
|
---|
| 4729 | % UvData.MouseAction='create_object';
|
---|
[61] | 4730 | set(handles.uvmat,'UserData',UvData);
|
---|
[2] | 4731 |
|
---|
| 4732 | % ------------------------------------------------------------------
|
---|
| 4733 | %-- open the GUI set_grid.fig to create grid
|
---|
| 4734 | function MenuGrid_Callback(hObject, eventdata, handles)
|
---|
[84] | 4735 | %UvData=get(handles.uvmat,'UserData');%read UvData properties stored on the uvmat interface
|
---|
[2] | 4736 |
|
---|
[84] | 4737 | %suppress the other options if grid is chosen
|
---|
| 4738 | set(handles.edit_vect,'Value',0)
|
---|
| 4739 | edit_vect_Callback(hObject, eventdata, handles)
|
---|
| 4740 | set(handles.edit,'BackgroundColor',[0.7 0.7 0.7])
|
---|
| 4741 | set(handles.list_object_1,'Value',1)
|
---|
| 4742 |
|
---|
| 4743 | %prepare display of the set_grid GUI
|
---|
| 4744 | FileName=read_file_boxes(handles);
|
---|
| 4745 | CoordList=get(handles.transform_fct,'String');
|
---|
| 4746 | val=get(handles.transform_fct,'Value');
|
---|
| 4747 | set_grid(FileName,CoordList{val});% call the set_object interface
|
---|
| 4748 | %set(handles.uvmat,'UserData',UvData);
|
---|
| 4749 |
|
---|
[2] | 4750 | %----------------------------------------------------------------
|
---|
| 4751 | % open the GUI 'series'
|
---|
| 4752 | %----------------------------------------------------------------
|
---|
| 4753 | function MenuSeries_Callback(hObject, eventdata, handles)
|
---|
[40] | 4754 | %-------------------------------------------------------------------
|
---|
[2] | 4755 |
|
---|
| 4756 | [param.FileName]=read_file_boxes(handles);
|
---|
| 4757 | if isequal(get(handles.SubField,'Value'),1)
|
---|
| 4758 | FileName_1=read_file_boxes_1(handles);%
|
---|
| 4759 | if ~isequal(FileName_1,param.FileName)
|
---|
| 4760 | param.FileName_1=FileName_1;
|
---|
| 4761 | end
|
---|
| 4762 | end
|
---|
| 4763 | param.NomType=get(handles.FileIndex,'UserData');
|
---|
| 4764 | param.NomType_1=get(handles.FileIndex_1,'UserData');
|
---|
| 4765 | param.comp_input=get(handles.fix_pair,'Value');
|
---|
| 4766 | huvmat=get(handles.MenuSeries,'parent');
|
---|
| 4767 | UvData=get(huvmat,'UserData');
|
---|
| 4768 | if isfield(UvData,'Time')
|
---|
| 4769 | param.Time=UvData.XmlData.Time;
|
---|
| 4770 | end
|
---|
| 4771 | if isequal(get(handles.scan_i,'Value'),1)
|
---|
| 4772 | param.incr_i=str2num(get(handles.increment_scan,'String'));
|
---|
| 4773 | elseif isequal(get(handles.scan_j,'Value'),1)
|
---|
| 4774 | param.incr_j=str2num(get(handles.increment_scan,'String'));
|
---|
| 4775 | end
|
---|
| 4776 | param.list_fields=get(handles.Fields,'String');% list menu fields
|
---|
| 4777 | param.list_fields(1)=[]; %suppress 'image' option
|
---|
| 4778 | param.index_fields=get(handles.Fields,'Value');% selected string index
|
---|
| 4779 | if param.index_fields>1
|
---|
| 4780 | param.index_fields=param.index_fields-1;
|
---|
| 4781 | end
|
---|
| 4782 | param.list_fields_1=get(handles.Fields_1,'String');% list menu fields
|
---|
| 4783 | param.list_fields_1(1)=[]; %suppress 'image' option
|
---|
| 4784 | param.index_fields_1=get(handles.Fields_1,'Value')-1;% selected string index
|
---|
| 4785 | if param.index_fields_1>1
|
---|
| 4786 | param.index_fields_1=param.index_fields_1-1;
|
---|
| 4787 | end
|
---|
| 4788 | param.civ1=get(handles.civ1,'Value');
|
---|
| 4789 | param.civ2=get(handles.civ2,'Value');
|
---|
| 4790 | param.interp1=get(handles.interp1,'Value');
|
---|
| 4791 | param.interp2=get(handles.interp2,'Value');
|
---|
| 4792 | param.filter1=get(handles.filter1,'Value');
|
---|
| 4793 | param.filter2=get(handles.filter2,'Value');
|
---|
[39] | 4794 | param.menu_coord_str=get(handles.transform_fct,'String');
|
---|
| 4795 | param.menu_coord_val=get(handles.transform_fct,'Value');
|
---|
[2] | 4796 |
|
---|
| 4797 | series(param); %run the series interface
|
---|
| 4798 |
|
---|
| 4799 | % ------------------------------------------------------------------
|
---|
| 4800 | % -- open the GUI civ.fig for civx (PIV)
|
---|
| 4801 | % ------------------------------------------------------------------
|
---|
| 4802 | function MenuPIV_Callback(hObject, eventdata, handles)
|
---|
| 4803 |
|
---|
| 4804 | [FileName,RootPath,filebase,FileIndices,ext,SubDir]=read_file_boxes(handles);
|
---|
[45] | 4805 | num1=stra2num(get(handles.i1,'String'));
|
---|
| 4806 | num2=stra2num(get(handles.i2,'String'));
|
---|
| 4807 | num_a=stra2num(get(handles.j1,'String'));
|
---|
| 4808 | num_b=stra2num(get(handles.j2,'String'));
|
---|
[2] | 4809 | NomType=get(handles.FileIndex,'UserData');
|
---|
| 4810 | ind_opening=1; % default (images): will advice civ1 option by default in the civ interface
|
---|
| 4811 | if isequal(ext,'.nc') || isequal(ext,'.cdf')% netcdf files
|
---|
| 4812 | ind_opening=2;% propose 'fix' as the default option
|
---|
| 4813 | % +read the current netcdf rootfile
|
---|
| 4814 | Data=nc2struct(FileName,[]);
|
---|
| 4815 | if isfield(Data,'fix') & isequal(Data.fix,1)
|
---|
| 4816 | ind_opening=3;
|
---|
| 4817 | end
|
---|
| 4818 | if isfield(Data,'patch') & isequal(Data.patch,1)
|
---|
| 4819 | ind_opening=4;
|
---|
| 4820 | end
|
---|
| 4821 | if isfield(Data,'civ2') & isequal(Data.civ2,1)
|
---|
| 4822 | ind_opening=5;
|
---|
| 4823 | end
|
---|
| 4824 | if isfield(Data,'fix2') & isequal(Data.fix2,1)
|
---|
| 4825 | ind_opening=6;
|
---|
| 4826 | end
|
---|
| 4827 | end
|
---|
[71] | 4828 | param.RootName=filebase;
|
---|
| 4829 | param.NomType=NomType;
|
---|
| 4830 | param.num1=num1;
|
---|
| 4831 | param.num2=num2;
|
---|
| 4832 | param.num_a=num_a;
|
---|
| 4833 | param.num_b=num_b;
|
---|
| 4834 | param.SubDir=SubDir;
|
---|
| 4835 | param.IndOpening=ind_opening;% A REVOIR +TRANSMETTRE IMADOC INFO
|
---|
| 4836 | param.ImaExt=ext;
|
---|
| 4837 | civ(param);% interface de civ(not in the uvmat file)
|
---|
[2] | 4838 |
|
---|
| 4839 | % ------------------------------------------------------------------
|
---|
| 4840 | function MenuTools_Callback(hObject, eventdata, handles)
|
---|
| 4841 |
|
---|
| 4842 | % ------------------------------------------------------------------
|
---|
[67] | 4843 | function MenuEditObject_Callback(hObject, eventdata, handles)
|
---|
| 4844 | set(handles.edit,'Value',1)
|
---|
| 4845 | edit_Callback(hObject, eventdata, handles)
|
---|
[2] | 4846 |
|
---|
| 4847 | %--------------------------------------------------------------------------
|
---|
| 4848 | function enable_transform(handles,state)
|
---|
[39] | 4849 | set(handles.transform_fct,'Visible',state)
|
---|
[2] | 4850 | set(handles.TRANSFORM_txt,'Visible',state)
|
---|
[39] | 4851 | set(handles.transform_fct,'Visible',state)
|
---|
[2] | 4852 | set(handles.path_transform,'Visible',state)
|
---|
| 4853 | set(handles.pxcmx_txt,'Visible',state)
|
---|
| 4854 | set(handles.pxcmy_txt,'Visible',state)
|
---|
| 4855 | set(handles.pxcm,'Visible',state)
|
---|
| 4856 | set(handles.pycm,'Visible',state)
|
---|
| 4857 |
|
---|
[40] | 4858 | %------------------------------------------------------------------------
|
---|
[2] | 4859 | function MenuEditVectors_Callback(hObject, eventdata, handles)
|
---|
[40] | 4860 | %------------------------------------------------------------------------
|
---|
[2] | 4861 | set(handles.edit_vect,'Visible','on')
|
---|
| 4862 | set(handles.edit_vect,'Value',1)
|
---|
| 4863 | edit_vect_Callback(hObject, eventdata, handles)
|
---|
| 4864 |
|
---|
[40] | 4865 | % --------------------------------------------------------------------
|
---|
| 4866 | function Menupoints_Callback(hObject, eventdata, handles)
|
---|
| 4867 | data.Style='points';
|
---|
| 4868 | data.ProjMode='projection';%default
|
---|
[55] | 4869 | create_object(data,handles)
|
---|
[2] | 4870 |
|
---|
[40] | 4871 | % --------------------------------------------------------------------
|
---|
| 4872 | function Menuline_Callback(hObject, eventdata, handles)
|
---|
| 4873 | % set(handles.create,'Visible','on')
|
---|
| 4874 | % set(handles.create,'Value',1)
|
---|
| 4875 | % LINE_Callback(hObject,eventdata,handles)
|
---|
| 4876 | data.Style='line';
|
---|
| 4877 | data.ProjMode='projection';%default
|
---|
[55] | 4878 | create_object(data,handles)
|
---|
[2] | 4879 |
|
---|
[40] | 4880 | %------------------------------------------------------------------------
|
---|
| 4881 | function Menupolyline_Callback(hObject, eventdata, handles)
|
---|
| 4882 | %------------------------------------------------------------------------
|
---|
| 4883 | data.Style='polyline';
|
---|
| 4884 | data.ProjMode='projection';%default
|
---|
[55] | 4885 | create_object(data,handles)
|
---|
[2] | 4886 |
|
---|
[55] | 4887 | %------------------------------------------------------------------------
|
---|
[40] | 4888 | function Menupolygon_Callback(hObject, eventdata, handles)
|
---|
[55] | 4889 | %------------------------------------------------------------------------
|
---|
[45] | 4890 | data.Style='polygon';
|
---|
| 4891 | data.ProjMode='inside';%default
|
---|
[55] | 4892 | create_object(data,handles)
|
---|
[40] | 4893 |
|
---|
| 4894 | %------------------------------------------------------------------------
|
---|
| 4895 | function Menurectangle_Callback(hObject, eventdata, handles)
|
---|
| 4896 | %------------------------------------------------------------------------
|
---|
| 4897 | data.Style='rectangle';
|
---|
| 4898 | data.ProjMode='inside';%default
|
---|
[55] | 4899 | create_object(data,handles)
|
---|
[40] | 4900 |
|
---|
| 4901 | %------------------------------------------------------------------------
|
---|
| 4902 | function Menuellipse_Callback(hObject, eventdata, handles)
|
---|
| 4903 | %------------------------------------------------------------------------
|
---|
| 4904 | data.Style='ellipse';
|
---|
| 4905 | data.ProjMode='inside';%default
|
---|
[55] | 4906 | create_object(data,handles)
|
---|
[40] | 4907 |
|
---|
[82] | 4908 | %------------------------------------------------------------------------
|
---|
| 4909 | function MenuMaskObject_Callback(hObject, eventdata, handles)
|
---|
| 4910 | %------------------------------------------------------------------------
|
---|
| 4911 | data.Style='polygon';
|
---|
| 4912 | data.StyleMenu={'polygon'};
|
---|
| 4913 | data.ProjMode='mask_inside';%default
|
---|
| 4914 | data.ProjMenu={'mask_inside';'mask_outside'};
|
---|
| 4915 | create_object(data,handles)
|
---|
| 4916 |
|
---|
[40] | 4917 | % ------------------------------------------------------------------
|
---|
| 4918 | function Menuplane_Callback(hObject, eventdata, handles)
|
---|
| 4919 | data.Style='plane';
|
---|
| 4920 | data.ProjMode='projection';%default
|
---|
| 4921 |
|
---|
[55] | 4922 | create_object(data,handles)
|
---|
| 4923 |
|
---|
[40] | 4924 | % ------------------------------------------------------------------
|
---|
| 4925 | function Menuvolume_Callback(hObject, eventdata, handles)
|
---|
[77] | 4926 | data.Style='volume';
|
---|
| 4927 | data.ProjMode='interp';%default
|
---|
[61] | 4928 | % set(handles.create,'Visible','on')
|
---|
| 4929 | % set(handles.create,'Value',1)
|
---|
[77] | 4930 | % VOLUME_Callback(hObject,eventdata,handles)
|
---|
| 4931 | create_object(data,handles)
|
---|
[40] | 4932 |
|
---|
| 4933 | %------------------------------------------------------------------------
|
---|
| 4934 | function MenuBrowseObject_Callback(hObject, eventdata, handles)
|
---|
| 4935 | %------------------------------------------------------------------------
|
---|
| 4936 | %get the object file
|
---|
| 4937 | [FileName, PathName, filterindex] = uigetfile( ...
|
---|
| 4938 | {'*.xml;*.mat', ' (*.xml,*.mat)';
|
---|
| 4939 | '*.xml', '.xml files '; ...
|
---|
| 4940 | '*.mat', '.mat matlab files '}, ...
|
---|
[89] | 4941 | 'Pick an xml Object file',get(handles.RootPath,'String'));
|
---|
[40] | 4942 | fileinput=[PathName FileName];%complete file name
|
---|
| 4943 | testblank=findstr(fileinput,' ');%look for blanks
|
---|
| 4944 | if ~isempty(testblank)
|
---|
| 4945 | msgbox_uvmat('ERROR','forbidden input file name: contain blanks')
|
---|
| 4946 | return
|
---|
| 4947 | end
|
---|
| 4948 | sizf=size(fileinput);
|
---|
| 4949 | if (~ischar(fileinput)||~isequal(sizf(1),1)),return;end
|
---|
| 4950 |
|
---|
| 4951 | %read the file
|
---|
[55] | 4952 | t=xmltree(fileinput);
|
---|
| 4953 | data=convert(t);
|
---|
[71] | 4954 | data.enable_plot=1;
|
---|
| 4955 | [pp,data.Name]=fileparts(FileName);
|
---|
| 4956 | %PlotHandles=get_plot_handles(handles);%get the handles of the interface elements setting the plotting parameters
|
---|
[55] | 4957 | hset_object=findobj(allchild(0),'Name','set_object');
|
---|
| 4958 | if ~isempty(hset_object)
|
---|
| 4959 | delete(hset_object)% delete existing version of set_object
|
---|
| 4960 | end
|
---|
[71] | 4961 | UvData=get(handles.uvmat,'UserData');
|
---|
[81] | 4962 | [hset_object,UvData.sethandles]=set_object(data);% call the set_object interface
|
---|
[75] | 4963 | % %position the set_object GUI with respect to uvmat
|
---|
| 4964 | % pos_uvmat=get(handles.uvmat,'Position');
|
---|
| 4965 | % if isfield(UvData,'SetObjectOrigin')
|
---|
| 4966 | % pos_set_object(1:2)=UvData.SetObjectOrigin + pos_uvmat(1:2);
|
---|
| 4967 | % pos_set_object(3:4)=UvData.SetObjectSize .* pos_uvmat(3:4);
|
---|
| 4968 | % set(hset_object,'Position',pos_set_object)
|
---|
| 4969 | % end
|
---|
[61] | 4970 | set(handles.edit,'Value',0); %suppress the object edit mode
|
---|
| 4971 | set(handles.edit,'BackgroundColor',[0.7,0.7,0.7])
|
---|
[55] | 4972 | UvData.MouseAction='create_object';
|
---|
| 4973 | set(handles.uvmat,'UserData',UvData)
|
---|
[72] | 4974 | set(handles.delete_object,'Visible','on')
|
---|
| 4975 | set(handles.uvmat_title,'Visible','on')
|
---|
[75] | 4976 | set(handles.view_field_title,'Visible','on')
|
---|
[40] | 4977 |
|
---|
| 4978 | %------------------------------------------------------------------------
|
---|
[71] | 4979 | % --- generic function used for the creation of a projection object
|
---|
[55] | 4980 | function create_object(data,handles)
|
---|
[40] | 4981 | %------------------------------------------------------------------------
|
---|
[75] | 4982 | hset_object=findobj(allchild(0),'tag','set_object');
|
---|
[40] | 4983 | if ~isempty(hset_object)
|
---|
| 4984 | delete(hset_object)% delete existing version of set_object
|
---|
| 4985 | end
|
---|
[55] | 4986 | UvData=get(handles.uvmat,'UserData');
|
---|
[61] | 4987 | set(handles.edit,'Value',0); %suppress the object edit mode
|
---|
| 4988 | set(handles.edit,'BackgroundColor',[0.7,0.7,0.7])
|
---|
[71] | 4989 | data.enable_plot=1;
|
---|
[82] | 4990 | transform_list=get(handles.transform_fct,'String');
|
---|
| 4991 | val=get(handles.transform_fct,'Value');
|
---|
| 4992 | data.CoordType=transform_list{val};
|
---|
| 4993 | % if isfield(UvData,'CoordType')
|
---|
| 4994 | % data.CoordType=UvData.CoordType;
|
---|
| 4995 | % end
|
---|
[55] | 4996 | if isfield(UvData,'Mesh')&&~isempty(UvData.Mesh)
|
---|
[40] | 4997 | data.RangeX=UvData.Mesh;
|
---|
| 4998 | data.RangeY=UvData.Mesh;
|
---|
| 4999 | data.DX=UvData.Mesh;
|
---|
| 5000 | data.DY=UvData.Mesh;
|
---|
[55] | 5001 | elseif isfield(UvData.Field,'AX')&& isfield(UvData.Field,'AY')&& isfield(UvData.Field,'A')%only image
|
---|
[40] | 5002 | np=size(UvData.Field.A);
|
---|
| 5003 | meshx=(UvData.Field.AX(end)-UvData.Field.AX(1))/np(2);
|
---|
| 5004 | meshy=abs(UvData.Field.AY(end)-UvData.Field.AY(1))/np(1);
|
---|
| 5005 | data.RangeY=max(meshx,meshy);
|
---|
| 5006 | data.RangeX=max(meshx,meshy);
|
---|
| 5007 | data.DX=max(meshx,meshy);
|
---|
| 5008 | end
|
---|
[75] | 5009 | if isfield(UvData,'NbDim')
|
---|
| 5010 | data.NbDim=UvData.NbDim;
|
---|
| 5011 | end
|
---|
[55] | 5012 | data.Coord=[0 0 0]; %default
|
---|
| 5013 | if isfield(data,'Style') && isequal(data.Style,'line')
|
---|
| 5014 | if isfield(data,'DX')
|
---|
| 5015 | data.Coord=[[0 0 0];[data.DX 0 0]]; %default
|
---|
| 5016 | else
|
---|
| 5017 | data.Coord=[[0 0 0];[1 0 0]]; %default
|
---|
| 5018 | end
|
---|
[40] | 5019 | end
|
---|
| 5020 | %data.ParentButton=handles.create;
|
---|
[55] | 5021 | if ishandle(handles.UVMAT_title)
|
---|
| 5022 | delete(handles.UVMAT_title)%delete the initial display of uvmat if no field has been entered
|
---|
| 5023 | end
|
---|
| 5024 | PlotHandles=get_plot_handles(handles);%get the handles of the interface elements setting the plotting parameters
|
---|
[40] | 5025 | [hset_object,UvData.sethandles]=set_object(data,PlotHandles);% call the set_object interface
|
---|
[61] | 5026 |
|
---|
[40] | 5027 | UvData.MouseAction='create_object';
|
---|
[55] | 5028 | set(handles.uvmat,'UserData',UvData)
|
---|
| 5029 | set(handles.zoom,'Value',0)
|
---|
| 5030 | zoom_Callback(handles.uvmat, [], handles)
|
---|
[72] | 5031 | set(handles.delete_object,'Visible','on')
|
---|
| 5032 | set(handles.uvmat_title,'Visible','on')
|
---|
[75] | 5033 | set(handles.view_field_title,'Visible','on')
|
---|
[40] | 5034 |
|
---|
[71] | 5035 | %------------------------------------------------------------------------
|
---|
[60] | 5036 | function MenuRuler_Callback(hObject, eventdata, handles)
|
---|
[71] | 5037 | %------------------------------------------------------------------------
|
---|
[60] | 5038 | set(handles.zoom,'Value',0)
|
---|
| 5039 | zoom_Callback(handles.uvmat, [], handles)
|
---|
| 5040 | UvData=get(handles.uvmat,'UserData');
|
---|
| 5041 | UvData.MouseAction='ruler';
|
---|
| 5042 | set(handles.uvmat,'UserData',UvData);
|
---|
| 5043 |
|
---|
[67] | 5044 | %------------------------------------------------------------------------
|
---|
[71] | 5045 | % --- executed when closing: set the parent interface button to value 0
|
---|
[67] | 5046 | function closefcn(gcbo,eventdata)
|
---|
| 5047 | %------------------------------------------------------------------------
|
---|
| 5048 | %delete all the associated figures if exist
|
---|
| 5049 | hh=findobj(allchild(0),'tag','view_field');
|
---|
| 5050 | if ~isempty(hh)
|
---|
| 5051 | delete(hh)
|
---|
| 5052 | end
|
---|
| 5053 | hh=findobj(allchild(0),'name','geometry_calib');
|
---|
| 5054 | if ~isempty(hh)
|
---|
| 5055 | delete(hh)
|
---|
| 5056 | end
|
---|
| 5057 | hh=findobj(allchild(0),'tag','set_object');
|
---|
| 5058 | if ~isempty(hh)
|
---|
| 5059 | hhh=findobj(hh,'tag','PLOT');
|
---|
| 5060 | set(hhh,'enable','off')
|
---|
[71] | 5061 | end
|
---|
| 5062 |
|
---|
| 5063 |
|
---|
| 5064 | % --- Executes on button press in delete_object.
|
---|
| 5065 | function delete_object_Callback(hObject, eventdata, handles)
|
---|
| 5066 | IndexObj=get(handles.list_object_2,'Value');
|
---|
| 5067 | if IndexObj>1
|
---|
| 5068 | delete_object(IndexObj)
|
---|
| 5069 | end
|
---|
| 5070 |
|
---|
| 5071 |
|
---|
[81] | 5072 |
|
---|
| 5073 |
|
---|
| 5074 |
|
---|