[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;
|
---|
| 167 | %-------------------------------------------------------------------
|
---|
| 168 | %-------------------------------------------------------------------
|
---|
| 169 | % I - MAIN FUNCTION UVMAT (DO NOT MODIFY)
|
---|
| 170 | %-------------------------------------------------------------------
|
---|
| 171 | %-------------------------------------------------------------------
|
---|
| 172 | function varargout = uvmat(varargin)
|
---|
| 173 |
|
---|
| 174 | % Begin initialization code - DO NOT EDIT
|
---|
| 175 | gui_Singleton = 1;
|
---|
| 176 | gui_State = struct('gui_Name', mfilename, ...
|
---|
| 177 | 'gui_Singleton', gui_Singleton, ...
|
---|
| 178 | 'gui_OpeningFcn', @uvmat_OpeningFcn, ...
|
---|
| 179 | 'gui_OutputFcn', @uvmat_OutputFcn, ...
|
---|
| 180 | 'gui_LayoutFcn', [], ...
|
---|
| 181 | 'gui_Callback', []);
|
---|
| 182 | if nargin && ischar(varargin{1})
|
---|
| 183 | gui_State.gui_Callback = str2func(varargin{1});
|
---|
| 184 | end
|
---|
| 185 |
|
---|
| 186 | if nargout
|
---|
| 187 | varargout{1:nargout} = gui_mainfcn(gui_State, varargin{:});
|
---|
| 188 | else
|
---|
| 189 | gui_mainfcn(gui_State, varargin{:});
|
---|
| 190 | end
|
---|
| 191 | % End initialization code - DO NOT EDIT
|
---|
| 192 |
|
---|
| 193 | %-------------------------------------------------------------------
|
---|
| 194 | % --- Executes just before uvmat is made visible.
|
---|
| 195 | function uvmat_OpeningFcn(hObject, eventdata, handles, input )
|
---|
| 196 | %-------------------------------------------------------------------
|
---|
[71] | 197 | global nb_builtin
|
---|
| 198 |
|
---|
[2] | 199 | % Choose default command menuline output for uvmat
|
---|
| 200 | handles.output = hObject;
|
---|
| 201 |
|
---|
| 202 | % Update handles structure
|
---|
| 203 | guidata(hObject, handles);
|
---|
| 204 |
|
---|
| 205 | % set the position of colorbar and ancillary GUIs:
|
---|
| 206 | set(hObject,'Units','Normalized')
|
---|
| 207 | movegui(hObject,'center')
|
---|
| 208 | UvData.PosColorbar=[0.805 0.022 0.019 0.445];
|
---|
| 209 | UvData.SetObjectOrigin=[-0.05 -0.03]; %position for set_object
|
---|
| 210 | UvData.SetObjectSize=[0.3 0.7];
|
---|
| 211 | UvData.CalOrigin=[0.95 -0.03];%position for geometry_calib (TO IMPROVE)
|
---|
| 212 | UvData.CalSize=[0.28 1];
|
---|
| 213 |
|
---|
| 214 | %functions for the mouse and keyboard
|
---|
| 215 | set(handles.histo_u,'NextPlot','replacechildren');
|
---|
| 216 | set(handles.histo_v,'NextPlot','replacechildren');
|
---|
| 217 | set(hObject,'KeyPressFcn',{'keyboard_callback',handles})%set keyboard action function
|
---|
| 218 | set(hObject,'WindowButtonMotionFcn',{'mouse_motion',handles})%set mouse action functio
|
---|
| 219 | set(hObject,'WindowButtonDownFcn',{'mouse_down'})%set mouse click action function
|
---|
| 220 | set(hObject,'WindowButtonUpFcn',{'mouse_up',handles})
|
---|
[67] | 221 | set(hObject,'DeleteFcn',{@closefcn})%
|
---|
[2] | 222 |
|
---|
[39] | 223 | %TRANSFORM menu: loads the information stored in prefdir to initiate the browser and the list of functions
|
---|
| 224 | menu_str={'';'phys';'px';'phys_polar'};
|
---|
| 225 | nb_builtin=numel(menu_str); %number of functions
|
---|
[45] | 226 | path_uvmat=fileparts(which('uvmat'));
|
---|
[39] | 227 | addpath(fullfile(path_uvmat,'transform_field'))
|
---|
| 228 | fct_handle{1,1}=[];
|
---|
[60] | 229 | testexist=zeros(size(menu_str'));%default
|
---|
[39] | 230 | testexist(1)=1;
|
---|
| 231 | for ilist=2:length(menu_str)
|
---|
| 232 | if exist(menu_str{ilist},'file')
|
---|
| 233 | fct_handle{ilist,1}=str2func(menu_str{ilist});
|
---|
| 234 | testexist(ilist)=1;
|
---|
| 235 | else
|
---|
| 236 | testexist(ilist)=0;
|
---|
| 237 | end
|
---|
| 238 | end
|
---|
| 239 | rmpath(fullfile(path_uvmat,'transform_field'))
|
---|
| 240 |
|
---|
[60] | 241 | %refresh projection plane
|
---|
| 242 | UvData.Object{1}.Style='plane';%main plotting plane
|
---|
| 243 | UvData.Object{1}.ProjMode='projection';%main plotting plane
|
---|
| 244 | if ~isfield(UvData.Object{1},'plotaxes')
|
---|
| 245 | UvData.Object{1}.plotaxes=handles.axes3;%default plotting axis
|
---|
[71] | 246 | set(handles.list_object_1,'Value',1);
|
---|
[61] | 247 | set(handles.list_object_1,'String',{'1-PLANE'});
|
---|
[60] | 248 | end
|
---|
| 249 |
|
---|
[2] | 250 | %load the list of previously browsed files in menus Open and Open_1
|
---|
[40] | 251 | dir_perso=prefdir; % path to the directory .matlab for personal data
|
---|
| 252 | profil_perso=fullfile(dir_perso,'uvmat_perso.mat');% personal data file uvmauvmat_perso.mat' in .matlab
|
---|
[2] | 253 | if exist(profil_perso,'file')
|
---|
| 254 | h=load (profil_perso);
|
---|
| 255 | if isfield(h,'MenuFile_1')
|
---|
| 256 | set(handles.MenuFile_1,'Label',h.MenuFile_1);
|
---|
| 257 | set(handles.MenuFile_1_1,'Label',h.MenuFile_1);
|
---|
| 258 | end
|
---|
| 259 | if isfield(h,'MenuFile_1')
|
---|
| 260 | set(handles.MenuFile_2,'Label',h.MenuFile_2);
|
---|
| 261 | set(handles.MenuFile_2_1,'Label',h.MenuFile_2);
|
---|
| 262 | end
|
---|
| 263 | if isfield(h,'MenuFile_1')
|
---|
| 264 | set(handles.MenuFile_3,'Label',h.MenuFile_3);
|
---|
| 265 | set(handles.MenuFile_3_1,'Label',h.MenuFile_3);
|
---|
| 266 | end
|
---|
| 267 | if isfield(h,'MenuFile_1')
|
---|
| 268 | set(handles.MenuFile_4,'Label',h.MenuFile_4);
|
---|
| 269 | set(handles.MenuFile_4_1,'Label',h.MenuFile_4);
|
---|
| 270 | end
|
---|
| 271 | if isfield(h,'MenuFile_1')
|
---|
| 272 | set(handles.MenuFile_5,'Label',h.MenuFile_5);
|
---|
| 273 | set(handles.MenuFile_5_1,'Label',h.MenuFile_5);
|
---|
[39] | 274 | end
|
---|
| 275 | if isfield(h,'transform_fct') && iscell(h.transform_fct)
|
---|
| 276 | for ilist=1:length(h.transform_fct);
|
---|
| 277 | [path,file]=fileparts(h.transform_fct{ilist});
|
---|
| 278 | addpath(path)
|
---|
| 279 | if exist(file,'file')
|
---|
| 280 | h_func=str2func(file);
|
---|
[45] | 281 | testexist=[testexist 1]; %#ok<AGROW>
|
---|
[39] | 282 | else
|
---|
| 283 | h_func=[];
|
---|
[45] | 284 | testexist=[testexist 0]; %#ok<AGROW>
|
---|
[39] | 285 | end
|
---|
[45] | 286 | fct_handle=[fct_handle; {h_func}];%#ok<AGROW> %concatene the list of paths
|
---|
[39] | 287 | rmpath(path)
|
---|
[45] | 288 | menu_str=[menu_str; {file}]; %#ok<AGROW>
|
---|
[39] | 289 | end
|
---|
| 290 | end
|
---|
[2] | 291 | end
|
---|
[45] | 292 | menu_str=menu_str(testexist==1);%=menu_str(testexist~=0)
|
---|
| 293 | fct_handle=fct_handle(testexist==1);
|
---|
[39] | 294 | menu_str=[menu_str;{'more...'}];
|
---|
| 295 | set(handles.transform_fct,'String',menu_str)
|
---|
| 296 | set(handles.transform_fct,'UserData',fct_handle)% store the list of path in UserData of ACTION
|
---|
[2] | 297 |
|
---|
| 298 | %initiates menu of vector colors
|
---|
| 299 | list_menu=calc_field;
|
---|
| 300 | %list_menu=[{'ima_cor'};{'black'};{'white'};list_menu(3:end)];
|
---|
| 301 | set(handles.col_vec,'String',list_menu)
|
---|
| 302 |
|
---|
| 303 | %check the path and date of modification of all functions in uvmat
|
---|
| 304 | path_to_uvmat=which ('uvmat');% check the path detected for source file uvmat
|
---|
| 305 | [errormsg,date_str]=check_functions;%check the path of the functions called by uvmat.m
|
---|
[45] | 306 | date_str=['last modification: ' date_str];
|
---|
[2] | 307 | %case of an input argument for uvmat
|
---|
| 308 | testinputfield=0;
|
---|
| 309 | inputfile=[];
|
---|
| 310 | Field=[];
|
---|
| 311 | if exist('input','var')
|
---|
| 312 | if ~isempty(errormsg)
|
---|
[38] | 313 | msgbox_uvmat('WARNING',errormsg)
|
---|
[2] | 314 | end
|
---|
| 315 | if ishandle(handles.UVMAT_title)
|
---|
| 316 | delete(handles.UVMAT_title)
|
---|
| 317 | end
|
---|
| 318 | if isstruct(input)
|
---|
| 319 | if isfield(input,'InputFile')
|
---|
| 320 | inputfile=input.InputFile;
|
---|
| 321 | end
|
---|
| 322 | Field=input;
|
---|
| 323 | elseif ischar(input)% file name introduced as input
|
---|
| 324 | inputfile=input;
|
---|
[59] | 325 | elseif isnumeric(input)%simple matrix introduced as input
|
---|
[2] | 326 | sizinput=size(input);
|
---|
| 327 | if sizinput(1)<=1 || sizinput(2)<=1
|
---|
[38] | 328 | msgbox_uvmat('ERROR','bad input for uvmat: file name, structure or numerical matrix accepted')
|
---|
[2] | 329 | return
|
---|
| 330 | end
|
---|
[59] | 331 | Field.ListVarName={'A','coord_y','coord_x'};
|
---|
| 332 | Field.VarDimName={{'coord_y','coord_x'},'cord_y','coord_x'};
|
---|
[2] | 333 | Field.A=input;
|
---|
[59] | 334 | Field.coord_x=[0.5 size(input,2)-0.5];
|
---|
| 335 | Field.coord_y=[size(input,1)-0.5 0.5];
|
---|
[2] | 336 | end
|
---|
| 337 | if ~isempty(inputfile)
|
---|
| 338 | display_file_name(hObject, eventdata, handles,inputfile)
|
---|
| 339 | testinputfield=1;
|
---|
| 340 | else
|
---|
| 341 | UvData.TestInputFile=0;
|
---|
| 342 | end
|
---|
| 343 | if ~isempty(Field)
|
---|
| 344 | set(handles.Fields,'Value',1)
|
---|
[39] | 345 | set(handles.Fields,'String',{'get_field...'})
|
---|
[59] | 346 | % set(handles.Fields,'UserData',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');
|
---|
[71] | 579 | FileName_1=name_generator(FileBase_1,stra2num(i1),stra2num(i2),FileExt_1,NomType_1,1,stra2num(str_a),stra2num(str_b),SubDir_1);
|
---|
| 580 | if exist(FileName_1,'file')
|
---|
[2] | 581 | FileIndex_1=name_generator('',stra2num(i1),stra2num(i2),'',NomType_1,1,stra2num(str_a),stra2num(str_b),'');
|
---|
| 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 |
|
---|
| 610 | %-------------------------------------------------------------------
|
---|
| 611 | function RootPath_Callback(hObject,eventdata,handles)
|
---|
| 612 | update_rootinfo(hObject,eventdata,handles);
|
---|
| 613 |
|
---|
| 614 | %-------------------------------------------------------------------
|
---|
| 615 | %-- called by action in RootFile edit box
|
---|
| 616 | %-------------------------------------------------------------------
|
---|
| 617 | function SubDir_Callback(hObject, eventdata, handles)
|
---|
| 618 | %refresh the menu of input fields
|
---|
| 619 | Fields_Callback(hObject, eventdata, handles);
|
---|
| 620 | % refresh the current field
|
---|
| 621 | run0_Callback(hObject, eventdata, handles);
|
---|
| 622 |
|
---|
| 623 |
|
---|
| 624 | %-------------------------------------------------------------------
|
---|
| 625 | %-- called by action in RootFile edit box
|
---|
| 626 | %-------------------------------------------------------------------
|
---|
| 627 | function RootFile_Callback(hObject, eventdata, handles)
|
---|
| 628 | update_rootinfo(hObject,eventdata,handles)
|
---|
| 629 |
|
---|
| 630 |
|
---|
[65] | 631 |
|
---|
| 632 |
|
---|
| 633 |
|
---|
| 634 |
|
---|
[2] | 635 | %-------------------------------------------------------------------
|
---|
| 636 | % -- update information about a new field series (indices to scan, timing, calibration from an xml file, then refresh current plots
|
---|
| 637 | %-------------------------------------------------------------------
|
---|
| 638 | function update_rootinfo(hObject,eventdata,handles)
|
---|
| 639 |
|
---|
| 640 | set(handles.RootPath,'BackgroundColor',[1 1 0])
|
---|
| 641 | drawnow
|
---|
| 642 | set(handles.Fields,'UserData',[])% reinialize data from uvmat opening
|
---|
[59] | 643 | UvData=get(handles.uvmat,'UserData');%huvmat=handles of the uvmat interface
|
---|
[2] | 644 | UvData.NewSeries=1; %flag for run0: begin a new series
|
---|
| 645 | UvData.TestInputFile=1;
|
---|
| 646 | set(handles.fix_pair,'Value',0) % desactivate by default the comp_input '-'input window
|
---|
| 647 | %FileIndex_Callback(hObject, eventdata, handles)% update field counters
|
---|
| 648 |
|
---|
| 649 | [FileName,RootPath,FileBase,FileIndices,FileExt,SubDir]=read_file_boxes(handles);
|
---|
| 650 | if ~exist(FileName,'file')
|
---|
| 651 | msgbox_uvmat('ERROR',['input file ' FileName ' not found']);
|
---|
| 652 | return
|
---|
| 653 | end
|
---|
| 654 | nbfield=[];%default
|
---|
| 655 | nburst=[];%default
|
---|
| 656 |
|
---|
| 657 | % read timing and total frame number from the current file (movie files) !! may be overrid by xml file
|
---|
| 658 | XmlData.Time=[];%default
|
---|
| 659 | XmlData.GeometryCalib=[];%default
|
---|
| 660 | TimeUnit=[];%default
|
---|
| 661 | testima=0; %test for image input
|
---|
| 662 | if isequal(lower(FileExt),'.avi') %.avi file
|
---|
| 663 | testima=1;
|
---|
| 664 | info=aviinfo([FileBase FileIndices FileExt]);
|
---|
| 665 | nbfield=info.NumFrames;
|
---|
| 666 | nburst=1;
|
---|
| 667 | set(handles.Dt_txt,'String',['Dt=' num2str(1000/info.FramesPerSecond) 'ms']);%display the elementary time interval in millisec
|
---|
[59] | 668 | XmlData.Time=(0:1/info.FramesPerSecond:(info.NumFrames-1)/info.FramesPerSecond)';
|
---|
[2] | 669 | TimeUnit='s';
|
---|
| 670 | set(handles.npx,'String',num2str(info.Width));%fills nbre of pixels x box
|
---|
| 671 | set(handles.npy,'String',num2str(info.Height));%fills nbre of pixels y box
|
---|
| 672 | hhh=which('mmreader');
|
---|
| 673 | if ~isequal(hhh,'')&& mmreader.isPlatformSupported()% if the function is found (recent version of matlab)
|
---|
| 674 | UvData.MovieObject=mmreader([FileBase FileIndices FileExt]);
|
---|
| 675 | end
|
---|
| 676 | elseif ~isempty(imformats(FileExt(2:end))) || isequal(FileExt,'.vol')%&& isequal(NomType,'*')% multi-frame image
|
---|
| 677 | testima=1;
|
---|
| 678 | if ~isequal(SubDir,'')
|
---|
| 679 | RootFile=get(handles.RootFile,'String');
|
---|
| 680 | imainfo=imfinfo([fullfile(RootPath,SubDir,RootFile) FileIndices FileExt]);
|
---|
| 681 | else
|
---|
| 682 | imainfo=imfinfo([FileBase FileIndices FileExt]);
|
---|
| 683 | end
|
---|
| 684 | if length(imainfo) >1 %case of image with multiple frames
|
---|
| 685 | nbfield=length(imainfo);
|
---|
| 686 | nburst=1;
|
---|
| 687 | end
|
---|
| 688 | if isfield(UvData,'MovieObject')
|
---|
| 689 | UvData=rmfield(UvData,'MovieObject');
|
---|
| 690 | end
|
---|
| 691 | else
|
---|
| 692 | %set(handles.last_i,'String','');%fills last_field box
|
---|
| 693 | set(handles.npx,'String','');%fills nbre of pixels x box
|
---|
| 694 | set(handles.npy,'String','');%fills nbre of pixels y box
|
---|
| 695 | if isfield(UvData,'MovieObject')
|
---|
| 696 | UvData=rmfield(UvData,'MovieObject');
|
---|
| 697 | end
|
---|
| 698 | end
|
---|
| 699 |
|
---|
| 700 | % read parameters (time, geometric calibration..) from a documentation file (.xml advised)
|
---|
| 701 | filexml=[FileBase '.xml'];
|
---|
| 702 | fileciv=[FileBase '.civ'];
|
---|
| 703 | warntext='';%default warning message
|
---|
| 704 | NbSlice=1;%default
|
---|
| 705 |
|
---|
| 706 | if exist(filexml,'file')
|
---|
| 707 | set(handles.view_xml,'Visible','on')
|
---|
| 708 | set(handles.view_xml,'BackgroundColor',[1 1 0])
|
---|
| 709 | set(handles.RootPath,'BackgroundColor',[1 1 1])
|
---|
| 710 | set(handles.view_xml,'String','view .xml')
|
---|
| 711 | drawnow
|
---|
| 712 | [XmlData,warntext]=imadoc2struct(filexml);
|
---|
| 713 | if ~isempty(warntext)
|
---|
| 714 | msgbox_uvmat('WARNING',warntext)
|
---|
| 715 | end
|
---|
| 716 | if isfield(XmlData,'TimeUnit')
|
---|
| 717 | if isfield(XmlData,'TimeUnit')&& ~isempty(XmlData.TimeUnit)
|
---|
| 718 | TimeUnit=XmlData.TimeUnit;
|
---|
| 719 | end
|
---|
| 720 | end
|
---|
| 721 | set(handles.view_xml,'BackgroundColor',[1 1 1])
|
---|
| 722 | drawnow
|
---|
| 723 | elseif exist(fileciv,'file')% if .civ file found
|
---|
| 724 | [error,XmlData.Time,TimeUnit,mode,npx,npy,pxcmx,pxcmy]=read_imatext([FileBase '.civ']);
|
---|
| 725 | GeometryCalib.R=[pxcmx 0 0; 0 pxcmy 0;0 0 0];
|
---|
| 726 | GeometryCalib.Tx=0;
|
---|
| 727 | GeometryCalib.Ty=0;
|
---|
| 728 | GeometryCalib.Tz=1;
|
---|
| 729 | GeometryCalib.dpx=1;
|
---|
| 730 | GeometryCalib.dpy=1;
|
---|
| 731 | GeometryCalib.sx=1;
|
---|
| 732 | GeometryCalib.Cx=0;
|
---|
| 733 | GeometryCalib.Cy=0;
|
---|
| 734 | GeometryCalib.f=1;
|
---|
| 735 | GeometryCalib.kappa1=0;
|
---|
| 736 | GeometryCalib.CoordUnit='cm';
|
---|
| 737 | XmlData.GeometryCalib=GeometryCalib;
|
---|
| 738 | if error==2, warntext=['no file ' FileBase '.civ'];
|
---|
| 739 | elseif error==1, warntext='inconsistent number of fields in the .civ file';
|
---|
| 740 | end
|
---|
| 741 | set(handles.npx,'String',num2str(npx));%fills nbre of pixels x box
|
---|
| 742 | set(handles.npy,'String',num2str(npy));%fills nbre of pixels y box
|
---|
| 743 | set(handles.pxcm,'String',num2str(pxcmx));%fills scale x (pixel/cm) box
|
---|
| 744 | set(handles.pycm,'String',num2str(pxcmy));%fills scale y (pixel/cm) box
|
---|
| 745 | set(handles.pxcm,'Visible','on');%fills scale x (pixel/cm) box
|
---|
| 746 | set(handles.pycm,'Visible','on');%fills scale y (pixel/cm) box
|
---|
| 747 | set(handles.view_xml,'Visible','on')
|
---|
| 748 | set(handles.view_xml,'String','view .civ')
|
---|
| 749 | else
|
---|
| 750 | set(handles.view_xml,'Visible','off')
|
---|
| 751 | end
|
---|
| 752 |
|
---|
| 753 | % store last index in handles.lat_i and .last_j
|
---|
| 754 | if ~isempty(XmlData.Time)
|
---|
| 755 | nbfield=size(XmlData.Time,1);
|
---|
| 756 | nburst=size(XmlData.Time,2);
|
---|
| 757 | end
|
---|
| 758 | last_i_cell=get(handles.last_i,'String');
|
---|
| 759 | if isempty(nbfield)
|
---|
| 760 | last_i_cell{1}='';
|
---|
| 761 | else
|
---|
| 762 | last_i_cell{1}=num2str(nbfield);
|
---|
| 763 | end
|
---|
| 764 | set(handles.last_i,'String',last_i_cell)
|
---|
| 765 | last_j_cell=get(handles.last_j,'String');
|
---|
| 766 | if isempty(nburst)
|
---|
| 767 | last_j_cell{1}='';
|
---|
| 768 | else
|
---|
| 769 | last_j_cell{1}=num2str(nburst);
|
---|
| 770 | end
|
---|
| 771 | set(handles.last_j,'String',last_j_cell);
|
---|
| 772 |
|
---|
| 773 | % store geometric calibration in UvData
|
---|
| 774 | if isfield(XmlData,'GeometryCalib')
|
---|
| 775 | GeometryCalib=XmlData.GeometryCalib;
|
---|
| 776 | if isempty(GeometryCalib)
|
---|
| 777 | set(handles.pxcm,'String','')
|
---|
| 778 | set(handles.pycm,'String','')
|
---|
[39] | 779 | set(handles.transform_fct,'Value',1); % no transform by default
|
---|
[2] | 780 | else
|
---|
| 781 | if (isfield(GeometryCalib,'R')& ~isequal(GeometryCalib.R(2,1),0) & ~isequal(GeometryCalib.R(1,2),0)) |...
|
---|
| 782 | (isfield(GeometryCalib,'kappa1')& ~isequal(GeometryCalib.kappa1,0))
|
---|
| 783 | set(handles.pxcm,'String','var')
|
---|
| 784 | set(handles.pycm,'String','var')
|
---|
| 785 | else
|
---|
| 786 | pixcmx=GeometryCalib.f*GeometryCalib.R(1,1)*GeometryCalib.sx/(GeometryCalib.Tz*GeometryCalib.dpx);
|
---|
| 787 | pixcmy=GeometryCalib.f*GeometryCalib.R(2,2)/(GeometryCalib.Tz*GeometryCalib.dpy);
|
---|
| 788 | set(handles.pxcm,'String',num2str(pixcmx))
|
---|
| 789 | set(handles.pycm,'String',num2str(pixcmy))
|
---|
| 790 | end
|
---|
[39] | 791 | set(handles.transform_fct,'Value',2); % phys transform by default
|
---|
[2] | 792 | if isfield(GeometryCalib,'SliceCoord')
|
---|
| 793 | siz=size(GeometryCalib.SliceCoord);
|
---|
| 794 | if siz(1)>1
|
---|
| 795 | NbSlice=siz(1);
|
---|
| 796 | set(handles.slices,'Visible','on')
|
---|
| 797 | set(handles.slices,'Value',1)
|
---|
| 798 | end
|
---|
[73] | 799 | if isfield(GeometryCalib,'NbSlice') && isequal(GeometryCalib.NbSlice,'volume')
|
---|
[60] | 800 | set(handles.nb_slice,'String','volume')
|
---|
| 801 | else
|
---|
| 802 | set(handles.nb_slice,'String',num2str(NbSlice))
|
---|
| 803 | end
|
---|
[2] | 804 | slices_Callback(hObject, eventdata, handles)
|
---|
| 805 | % Coord=UvData.XmlData.GeometryCalib.SliceCoord;
|
---|
| 806 | % ZIndex=num_i1-NbSlice*(floor((num_i1-1)/NbSlice));
|
---|
| 807 | end
|
---|
[60] | 808 |
|
---|
| 809 |
|
---|
[2] | 810 | end
|
---|
| 811 | end
|
---|
| 812 |
|
---|
| 813 | %update the data attached to the uvmat interface
|
---|
[60] | 814 | % set(handles.nb_slice,'String',num2str(NbSlice))
|
---|
[2] | 815 | if ~isempty(TimeUnit)
|
---|
| 816 | set(handles.time_txt,'String',['time (' TimeUnit ')'])
|
---|
| 817 | end
|
---|
| 818 | %set(handles.DtUnit,'String',['10^(-3)' TimeUnit])
|
---|
| 819 | UvData.TimeUnit=TimeUnit;
|
---|
| 820 | UvData.XmlData=XmlData;
|
---|
| 821 | UvData.NewSeries=1;
|
---|
[59] | 822 | set(handles.uvmat,'UserData',UvData)
|
---|
[2] | 823 |
|
---|
| 824 | %display warning message
|
---|
| 825 | if ~isequal(warntext,'')
|
---|
| 826 | msgbox_uvmat('WARNING',warntext);
|
---|
| 827 | end
|
---|
| 828 |
|
---|
| 829 | % set default options in menu 'Fields'
|
---|
| 830 | if testima
|
---|
| 831 | set(handles.Fields,'Value',1) % set menu to 'image'
|
---|
| 832 | set(handles.Fields,'String',{'image';'get_field...';'velocity';'vort';'div';'more...'})
|
---|
[45] | 833 | elseif isequal(FileExt,'.nc')||isequal(FileExt,'.cdf')
|
---|
[56] | 834 | Data=nc2struct(FileName,'ListGlobalAttribute','absolut_time_T0','civ');
|
---|
[2] | 835 | col_vec=get(handles.col_vec,'String');
|
---|
[59] | 836 | if ~isempty(Data.absolut_time_T0)&& ~isequal(Data.civ,0)
|
---|
[2] | 837 | set(handles.Fields,'String',{'image';'get_field...';'velocity';'vort';'div';'more...'})
|
---|
| 838 | set(handles.Fields,'Value',3) % set menu to 'velocity'
|
---|
| 839 | col_vec{1}='ima_cor';
|
---|
[45] | 840 | else %general netcdf file (not civx)
|
---|
[2] | 841 | set(handles.Fields,'Value',1) % set menu to 'get_field...
|
---|
| 842 | set(handles.Fields,'String',{'get_field...'})
|
---|
| 843 | col_vec{1}='get_field...';
|
---|
| 844 | end
|
---|
| 845 | set(handles.col_vec,'String',col_vec)
|
---|
| 846 | else
|
---|
| 847 | msgbox_uvmat('ERROR',['invalid input file extension ' FileExt])
|
---|
| 848 | return
|
---|
| 849 | end
|
---|
| 850 |
|
---|
| 851 | % set index navigation options and refresh plots
|
---|
| 852 | set(handles.RootPath,'BackgroundColor',[1 1 1])
|
---|
| 853 | drawnow
|
---|
| 854 | set_scan_options(hObject, eventdata, handles)
|
---|
| 855 |
|
---|
| 856 |
|
---|
| 857 | %-------------------------------------------------------------------
|
---|
| 858 | %-- set index navigation options for new series input and refresh plot
|
---|
| 859 | %-------------------------------------------------------------------
|
---|
| 860 | function set_scan_options(hObject, eventdata, handles)
|
---|
| 861 |
|
---|
| 862 | % set the corresponding index navigation options (TO CHECK WITH THE SECOND FIELD)
|
---|
| 863 | NomType=get(handles.FileIndex,'UserData');
|
---|
| 864 | NomType_1=get(handles.FileIndex_1,'UserData');
|
---|
| 865 | state_j='off'; %default
|
---|
| 866 | scan_option='i';
|
---|
| 867 | switch NomType
|
---|
| 868 | case {'_i_j','_i_j1-j2','_i1-i2_j','#_ab'},% two navigation indices
|
---|
| 869 | state_j='on';
|
---|
| 870 | if exist('nbfield','var') && isequal(nbfield,1)
|
---|
| 871 | scan_option='j';
|
---|
| 872 | else
|
---|
| 873 | scan_option='i';
|
---|
| 874 | end
|
---|
| 875 | end
|
---|
| 876 | if ~isempty(NomType_1)
|
---|
| 877 | switch NomType_1
|
---|
| 878 | case {'_i_j','_i_j1-j2','_i1-i2_j','#_ab'},% two navigation indices
|
---|
| 879 | state_j='on';
|
---|
| 880 | if exist('nbfield','var') && isequal(nbfield,1)
|
---|
| 881 | scan_option='j';
|
---|
| 882 | else
|
---|
| 883 | scan_option='i';
|
---|
| 884 | end
|
---|
| 885 | end
|
---|
| 886 | end
|
---|
| 887 | if isequal(scan_option,'i')
|
---|
| 888 | set(handles.scan_i,'Value',1)
|
---|
| 889 | scan_i_Callback(hObject, eventdata, handles);
|
---|
| 890 | else
|
---|
| 891 | set(handles.scan_j,'Value',1)
|
---|
| 892 | scan_j_Callback(hObject, eventdata, handles);
|
---|
| 893 | end
|
---|
| 894 | set(handles.scan_j,'Visible',state_j)
|
---|
| 895 | set(handles.j1,'Visible',state_j)
|
---|
| 896 | set(handles.j2,'Visible',state_j)
|
---|
| 897 | set(handles.last_j,'Visible',state_j);
|
---|
| 898 | set(handles.frame_j,'Visible',state_j);
|
---|
| 899 | set(handles.j_text,'Visible',state_j);
|
---|
| 900 |
|
---|
| 901 | % view the field
|
---|
| 902 | run0_Callback(hObject, eventdata, handles); %view field
|
---|
| 903 | mask_test=get(handles.mask_test,'value');
|
---|
| 904 | if mask_test
|
---|
| 905 | MaskData=get(handles.mask_test,'UserData');
|
---|
| 906 | if isfield(MaskData,'maskhandle') && ishandle(MaskData.maskhandle)
|
---|
| 907 | delete(MaskData.maskhandle) %delete old mask
|
---|
| 908 | end
|
---|
| 909 | mask_test_Callback(hObject, eventdata, handles)
|
---|
| 910 | end
|
---|
[59] | 911 |
|
---|
[2] | 912 | %-------------------------------------------------------------------
|
---|
| 913 | function MenuBrowse_1_Callback(hObject, eventdata, handles)
|
---|
| 914 | %-------------------------------------------------------------------
|
---|
[61] | 915 | % huvmat=get(handles.run0,'parent');
|
---|
| 916 | UvData=get(handles.uvmat,'UserData');
|
---|
[2] | 917 |
|
---|
| 918 | RootPath=get(handles.RootPath,'String');
|
---|
| 919 | [FileName, PathName, filterindex] = uigetfile( ...
|
---|
| 920 | {'*.xml;*.xls;*.civ;*.jpg;*.png;*.avi;*.AVI;*.nc;*.cmx;*.fig;*.log;*.dat', ' (*.xml,*.xls,*.civ, *.jpg,*.png, *.avi,*.nc,*.cmx ,*.fig,*.log,*.dat)';
|
---|
| 921 | '*.xml', '.xml files '; ...
|
---|
| 922 | '*.xls', '.xls files '; ...
|
---|
| 923 | '*.civ', '.civ files '; ...
|
---|
| 924 | '*.jpg','.jpg image files'; ...
|
---|
| 925 | '*.png','.png image files'; ...
|
---|
| 926 | '*.avi;*.AVI','.avi movie files'; ...
|
---|
| 927 | '*.nc','.netcdf files'; ...
|
---|
| 928 | '*.cdf','.netcdf files'; ...
|
---|
| 929 | '*.cmx','.cmx text files';...
|
---|
| 930 | '*.cmx2','.cmx2 text files';...
|
---|
| 931 | '*.fig','.fig files (matlab fig)';...
|
---|
| 932 | '*.log','.log text files ';...
|
---|
| 933 | '*.dat','.dat text files ';...
|
---|
| 934 | '*.*', 'All Files (*.*)'}, ...
|
---|
| 935 | 'Pick a file',RootPath);
|
---|
| 936 | fileinput_1=[PathName FileName];%complete file name
|
---|
| 937 | testblank=findstr(fileinput_1,' ');%look for blanks
|
---|
| 938 | if ~isempty(testblank)
|
---|
[38] | 939 | msgbox_uvmat('ERROR',['The input file name ' fileinput_1 ' contains blank character : This is not allowed. Please change name'])
|
---|
[2] | 940 | return
|
---|
| 941 | end
|
---|
| 942 | sizf=size(fileinput_1);
|
---|
| 943 | if (~ischar(fileinput_1)|~isequal(sizf(1),1)),return;end
|
---|
| 944 |
|
---|
| 945 | % refresh the current displayed field
|
---|
| 946 | display_file_name_1(hObject,eventdata,handles,fileinput_1)
|
---|
| 947 |
|
---|
| 948 | %update list of recent files in the menubar
|
---|
| 949 | MenuFile_1=fileinput_1;
|
---|
| 950 | MenuFile_2=get(handles.MenuFile_1,'Label');
|
---|
| 951 | MenuFile_3=get(handles.MenuFile_2,'Label');
|
---|
| 952 | MenuFile_4=get(handles.MenuFile_3,'Label');
|
---|
| 953 | MenuFile_5=get(handles.MenuFile_4,'Label');
|
---|
| 954 | set(handles.MenuFile_1,'Label',MenuFile_1)
|
---|
| 955 | set(handles.MenuFile_2,'Label',MenuFile_2)
|
---|
| 956 | set(handles.MenuFile_3,'Label',MenuFile_3)
|
---|
| 957 | set(handles.MenuFile_4,'Label',MenuFile_4)
|
---|
| 958 | set(handles.MenuFile_5,'Label',MenuFile_5)
|
---|
| 959 | set(handles.MenuFile_1_1,'Label',MenuFile_1)
|
---|
| 960 | set(handles.MenuFile_2_1,'Label',MenuFile_2)
|
---|
| 961 | set(handles.MenuFile_3_1,'Label',MenuFile_3)
|
---|
| 962 | set(handles.MenuFile_4_1,'Label',MenuFile_4)
|
---|
| 963 | set(handles.MenuFile_5_1,'Label',MenuFile_5)
|
---|
| 964 | dir_perso=prefdir;
|
---|
| 965 | profil_perso=fullfile(dir_perso,'uvmat_perso.mat');
|
---|
| 966 | if exist(profil_perso,'file')
|
---|
| 967 | save (profil_perso,'MenuFile_1','MenuFile_2','MenuFile_3','MenuFile_4', 'MenuFile_5','-append'); %store the file names for future opening of uvmat
|
---|
| 968 | else
|
---|
| 969 | txt=ver;
|
---|
| 970 | Release=txt(1).Release;
|
---|
| 971 | relnumb=str2num(Release(3:4));
|
---|
| 972 | if relnumb >= 14
|
---|
| 973 | save (profil_perso,'MenuFile_1','MenuFile_2','MenuFile_3','MenuFile_4', 'MenuFile_5','-V6'); %store the file names for future opening of uvmat
|
---|
| 974 | else
|
---|
| 975 | save (profil_perso,'MenuFile_1','MenuFile_2','MenuFile_3','MenuFile_4', 'MenuFile_5'); %store the file names for future opening of uvmat
|
---|
| 976 | end
|
---|
| 977 | end
|
---|
| 978 |
|
---|
| 979 | % --------------------------------------------------------------------
|
---|
| 980 | function MenuFile_1_1_Callback(hObject, eventdata, handles)
|
---|
| 981 | fileinput_1=get(handles.MenuFile_1_1,'Label');
|
---|
| 982 | display_file_name_1(hObject,eventdata,handles,fileinput_1)
|
---|
| 983 |
|
---|
| 984 | % --------------------------------------------------------------------
|
---|
| 985 | function MenuFile_2_1_Callback(hObject, eventdata, handles)
|
---|
| 986 | fileinput_1=get(handles.MenuFile_2_1,'Label');
|
---|
| 987 | display_file_name_1(hObject,eventdata,handles,fileinput_1)
|
---|
| 988 |
|
---|
| 989 | % --------------------------------------------------------------------
|
---|
| 990 | function MenuFile_3_1_Callback(hObject, eventdata, handles)
|
---|
| 991 | fileinput_1=get(handles.MenuFile_3_1,'Label');
|
---|
| 992 | display_file_name_1(hObject,eventdata,handles,fileinput_1)
|
---|
| 993 |
|
---|
| 994 | % --------------------------------------------------------------------
|
---|
| 995 | function MenuFile_4_1_Callback(hObject, eventdata, handles)
|
---|
| 996 | fileinput_1=get(handles.MenuFile_4_1,'Label');
|
---|
| 997 | display_file_name_1(hObject,eventdata,handles,fileinput_1)
|
---|
| 998 |
|
---|
| 999 | % --------------------------------------------------------------------
|
---|
| 1000 | function MenuFile_5_1_Callback(hObject, eventdata, handles)
|
---|
| 1001 | fileinput_1=get(handles.MenuFile_5_1,'Label');
|
---|
| 1002 | display_file_name_1(hObject,eventdata,handles,fileinput_1)
|
---|
| 1003 |
|
---|
| 1004 | %-----------------------------------------------------------------
|
---|
| 1005 | % fills the edit boxes RootPath, RootFile,NomType...from an input file name 'fileinput'
|
---|
| 1006 | %----------------------------------------------------------------
|
---|
| 1007 | function display_file_name_1(hObject,eventdata,handles,fileinput_1)
|
---|
| 1008 |
|
---|
| 1009 | %[path,name,ext]=fileparts(fileinput_1);
|
---|
| 1010 | [RootPath_1,RootFile_1,field_count,str2,str_a,str_b,FileExt_1,NomType_1,SubDir_1]=name2display(fileinput_1);
|
---|
| 1011 | nbfield_1=1; %default
|
---|
| 1012 | ext_test=FileExt_1;%default
|
---|
| 1013 | form=imformats(FileExt_1(2:end));
|
---|
| 1014 | if ~isempty(form) % if the extension corresponds to an image format recognized by Matlab
|
---|
| 1015 | imainfo=imfinfo(fileinput_1);
|
---|
| 1016 | nbfield_1=length(imainfo);
|
---|
| 1017 | ext_test='.image';
|
---|
| 1018 | elseif isequal(lower(FileExt_1),'.avi')
|
---|
| 1019 | info=aviinfo(fileinput_1);
|
---|
| 1020 | nbfield_1=info.NumFrames;
|
---|
| 1021 | ext_test='.image';
|
---|
| 1022 | end
|
---|
| 1023 |
|
---|
| 1024 | %open directly fig or text files
|
---|
| 1025 | switch ext_test
|
---|
| 1026 | case {'.civ','.log','.cmx','.cmx2','.txt'} %display text file
|
---|
| 1027 | edit(fileinput)
|
---|
| 1028 | return
|
---|
| 1029 | case '.fig' %display matlab figure
|
---|
| 1030 | hfig=open(fileinput);
|
---|
| 1031 | set(hfig,'WindowButtonMotionFcn','mouse_motion')%set mouse action functio
|
---|
| 1032 | set(hfig,'WindowButtonUpFcn','mouse_up')%set mouse click action function
|
---|
| 1033 | set(hfig,'WindowButtonUpFcn','mouse_down')%set mouse click action function
|
---|
| 1034 | return
|
---|
| 1035 | case {'.xml','.xls'} % edit xml or Excel files
|
---|
| 1036 | heditxml=editxml(fileinput);
|
---|
| 1037 | return
|
---|
| 1038 | case {'.image','.nc','.cdf'}
|
---|
| 1039 | % set(handles.FileIndex,'UserData',NomType_1);
|
---|
| 1040 | otherwise
|
---|
[38] | 1041 | msgbox_uvmat(['invalid input file extension ' FileExt_1 ' for uvmat'],'ERROR')
|
---|
[2] | 1042 | return
|
---|
| 1043 | end
|
---|
| 1044 |
|
---|
| 1045 | % test for image series in a single file and synchronise file indices of the two series
|
---|
| 1046 | if nbfield_1 >1 %case of image with multiple frames
|
---|
| 1047 | if nbfield_1 < num_i1
|
---|
[38] | 1048 | msgbox_uvmat('ERROR','current frame index beyond the input movie length')
|
---|
[2] | 1049 | return
|
---|
| 1050 | else
|
---|
| 1051 | NomType_1='*'; %indicate a set of indexed frames within a single file
|
---|
| 1052 | filename_new=fileinput_1;
|
---|
| 1053 | end
|
---|
| 1054 | else % cases of data files
|
---|
| 1055 | RootPath=get(handles.RootPath,'String');
|
---|
| 1056 | RootFile=get(handles.RootFile,'String');
|
---|
| 1057 | FileBase=fullfile(RootPath,RootFile);
|
---|
| 1058 | FileBase_1=fullfile(RootPath_1,RootFile_1);
|
---|
| 1059 | if isequal(FileBase,FileBase_1)
|
---|
| 1060 | filename_new=fileinput_1;
|
---|
| 1061 | else
|
---|
| 1062 | num_i1=stra2num(get(handles.i1,'String'));%get the current file indices from counters
|
---|
| 1063 | num_j1=stra2num(get(handles.j1,'String'));
|
---|
| 1064 | num_i2=stra2num(get(handles.i2,'String'));
|
---|
| 1065 | num_j2=stra2num(get(handles.j2,'String'));
|
---|
| 1066 | [filename_new,idetect]=...
|
---|
| 1067 | 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
|
---|
| 1068 | indices=''; %default
|
---|
| 1069 | if ~idetect
|
---|
[38] | 1070 | msgbox_uvmat('ERROR','second input file with indices corresponding to the first one does not exist')
|
---|
[2] | 1071 | return
|
---|
| 1072 | end
|
---|
| 1073 | end
|
---|
| 1074 | end
|
---|
| 1075 | set(handles.FileIndex,'UserData',NomType_1);
|
---|
| 1076 |
|
---|
| 1077 | % make visible and fill the second raw of edit boxes
|
---|
| 1078 | set(handles.RootPath_1,'Visible','on')
|
---|
| 1079 | set(handles.RootFile_1,'Visible','on')
|
---|
| 1080 | set(handles.SubDir_1,'Visible','on');
|
---|
| 1081 | set(handles.FileIndex_1,'Visible','on');
|
---|
| 1082 | set(handles.FileExt_1,'Visible','on');
|
---|
| 1083 | [FileName,RootPath,FileBase,FileIndices,FileExt,SubDir]=read_file_boxes(handles);
|
---|
| 1084 | if isequal(FileBase,FileBase_1)
|
---|
| 1085 | set(handles.RootPath_1,'String','"')
|
---|
| 1086 | set(handles.RootFile_1,'String','"');
|
---|
| 1087 | else
|
---|
| 1088 | set(handles.RootPath_1,'String',RootPath_1)
|
---|
| 1089 | set(handles.RootFile_1,'String',['/' RootFile_1]);
|
---|
| 1090 | end
|
---|
| 1091 | if isequal(SubDir_1,'')
|
---|
| 1092 | set(handles.SubDir_1,'String','');
|
---|
| 1093 | FileBaseSub_1=FileBase_1;
|
---|
| 1094 | else
|
---|
| 1095 | set(handles.SubDir_1,'String',['/' SubDir_1]);
|
---|
| 1096 | FileBaseSub_1=fullfile(FileBase_1,SubDir_1);
|
---|
| 1097 | end
|
---|
| 1098 | indices=filename_new(length(FileBaseSub_1)+1:end);
|
---|
| 1099 | indices(end-length(FileExt_1)+1:end)=[]; %remove extension
|
---|
| 1100 | set(handles.FileIndex_1,'String',indices)
|
---|
| 1101 | set(handles.FileIndex_1,'UserData',NomType_1)
|
---|
| 1102 | set(handles.FileExt_1,'String',FileExt_1);
|
---|
| 1103 |
|
---|
| 1104 | % default choice of fields
|
---|
| 1105 | if isequal(ext_test,'.image')
|
---|
| 1106 | set(handles.Fields_1,'String',{'';'image';'get_field...';'velocity';'vort';'div';'more...'})
|
---|
| 1107 | set(handles.Fields_1,'Value',2) % set menu to 'image'
|
---|
| 1108 | elseif isequal(FileExt_1,'.nc')|isequal(FileExt_1,'.cdf')
|
---|
| 1109 | Data=nc2struct(fileinput_1,[]);
|
---|
| 1110 | if isfield(Data,'absolut_time_T0')
|
---|
| 1111 | set(handles.Fields_1,'String',{'';'image';'get_field...';'velocity';'vort';'div';'more...'})
|
---|
| 1112 | set(handles.Fields_1,'Value',4) % set menu to 'velocity'
|
---|
| 1113 | else
|
---|
| 1114 | set(handles.Fields_1,'Value',2) % set menu to 'get_field...'
|
---|
| 1115 | set(handles.Fields_1,'String',{'';'get_field...'});
|
---|
| 1116 | end
|
---|
| 1117 | end
|
---|
| 1118 | set(handles.SubField,'Visible','on')
|
---|
| 1119 | set(handles.SubField,'Value',1)
|
---|
| 1120 | RootPath_1_Callback(hObject,eventdata,handles);
|
---|
| 1121 |
|
---|
| 1122 |
|
---|
| 1123 | %-----------------------------------------------------
|
---|
| 1124 | function RootPath_1_Callback(hObject,eventdata,handles)
|
---|
| 1125 | update_rootinfo_1(hObject,eventdata,handles)
|
---|
| 1126 |
|
---|
| 1127 | %-------------------------------------------------------------------
|
---|
| 1128 | function RootFile_1_Callback(hObject, eventdata, handles)
|
---|
| 1129 | update_rootinfo_1(hObject,eventdata,handles)
|
---|
| 1130 | %-------------------------------------------------------------------
|
---|
| 1131 |
|
---|
| 1132 | %-------------------------------------------------------------------
|
---|
| 1133 | function update_rootinfo_1(hObject,eventdata,handles) %A REVOIR
|
---|
| 1134 |
|
---|
| 1135 | set(handles.RootPath_1,'BackgroundColor',[1 1 0])% indicate active program by yellow color
|
---|
| 1136 | drawnow
|
---|
[61] | 1137 | %huvmat=get(handles.RootPath,'parent');
|
---|
| 1138 | UvData=get(handles.uvmat,'UserData');%huvmat=handles of the uvmat interface
|
---|
[2] | 1139 | UvData.NewSeries=1; %flag for run0: begin a new series
|
---|
| 1140 |
|
---|
| 1141 | [FileName,RootPath,FileBase,FileIndices,FileExt]=read_file_boxes_1(handles);
|
---|
| 1142 | if ~exist(FileName,'file')
|
---|
| 1143 | msgbox_uvmat('ERROR',['input file ' FileName ' not found']);
|
---|
| 1144 | end
|
---|
| 1145 | nbfield_1=[];%default
|
---|
| 1146 | nburst_1=[];%default
|
---|
| 1147 | XmlData.Time=[];
|
---|
| 1148 | XmlData.GeometryCalib=[];%default
|
---|
| 1149 | TimeUnit=[];
|
---|
| 1150 | if isfield(UvData,'TimeUnit')
|
---|
| 1151 | TimeUnit=UvData.TimeUnit;
|
---|
| 1152 | end
|
---|
| 1153 | TimeUnit_1=[];
|
---|
[71] | 1154 | % testima=0; %test for image input
|
---|
[2] | 1155 | if isequal(lower(FileExt),'.avi') %.avi file
|
---|
[71] | 1156 | % testima=1;
|
---|
[2] | 1157 | info=aviinfo([FileBase FileIndices FileExt]);
|
---|
| 1158 | nbfield_1=info.NumFrames;
|
---|
| 1159 | nburst_1=1;
|
---|
| 1160 | %set(handles.last_i,'String',num2str(info.NumFrames));%fills last_field box
|
---|
| 1161 | set(handles.Dt_txt,'String',['Dt=' num2str(1000/info.FramesPerSecond) 'ms']);%display the elementary time interval in millisec
|
---|
| 1162 | % set(handles.dt,'UserData',info.FramesPerSecond);
|
---|
| 1163 | time=[0:1/info.FramesPerSecond:(info.NumFrames-1)/info.FramesPerSecond]';
|
---|
| 1164 | npx=get(handles.npx,'String');
|
---|
| 1165 | npy=get(handles.npy,'String');
|
---|
| 1166 | if isequal(npx,'') || isequal(npy,'')
|
---|
| 1167 | set(handles.npx,'String',num2str(info.Width));%fills nbre of pixels x box
|
---|
| 1168 | set(handles.npy,'String',num2str(info.Height));%fills nbre of pixels y box
|
---|
| 1169 | end
|
---|
| 1170 | elseif ~isempty(imformats(FileExt(2:end))) %&& isequal(NomType,'*')% multi-frame image
|
---|
| 1171 | testima=1;
|
---|
| 1172 | imainfo=imfinfo([FileBase FileIndices FileExt]);
|
---|
| 1173 | if length(imainfo) >1 %case of image with multiple frames
|
---|
| 1174 | nbfield_1=length(imainfo);
|
---|
| 1175 | nburst_1=1;
|
---|
| 1176 | %set(handles.last_i,'String',num2str(length(imainfo)));%fills last_field box
|
---|
| 1177 | end
|
---|
| 1178 | else
|
---|
| 1179 | %set(handles.last_i,'String','');%fills last_field box
|
---|
| 1180 | set(handles.npx,'String','');%fills nbre of pixels x box
|
---|
| 1181 | set(handles.npy,'String','');%fills nbre of pixels y box
|
---|
| 1182 | end
|
---|
| 1183 |
|
---|
| 1184 | % find scaling parameters
|
---|
| 1185 | filexml=[FileBase '.xml'];
|
---|
| 1186 | fileciv=[FileBase '.civ'];
|
---|
| 1187 | warntext='';%default warning text
|
---|
| 1188 | if exist(filexml,'file')
|
---|
| 1189 | [XmlData,warntext]=imadoc2struct(filexml);
|
---|
| 1190 | if ~isempty(warntext)
|
---|
| 1191 | msgbox_uvmat('WARNING',warntext)
|
---|
| 1192 | end
|
---|
| 1193 | if isfield(XmlData,'Camera')
|
---|
| 1194 | % if isfield(XmlData.Camera,'NbSlice')&& ~isempty(XmlData.Camera.NbSlice)
|
---|
| 1195 | % NbSlice=XmlData.Camera.NbSlice;
|
---|
| 1196 | % end
|
---|
| 1197 | if isfield(XmlData.Camera,'TimeUnit')&& ~isempty(XmlData.Camera.TimeUnit)
|
---|
| 1198 | TimeUnit=XmlData.Camera.TimeUnit;
|
---|
| 1199 | end
|
---|
| 1200 | end
|
---|
| 1201 | elseif exist(fileciv,'file')% if .civ file found
|
---|
| 1202 | [error,XmlData.Time,TimeUnit,mode,npx,npy,pxcmx,pxcmy]=read_imatext([FileBase '.civ']);
|
---|
| 1203 | GeometryCalib.R=[pxcmx 0 0; 0 pxcmy 0;0 0 0];
|
---|
| 1204 | GeometryCalib.Tx=0;
|
---|
| 1205 | GeometryCalib.Ty=0;
|
---|
| 1206 | GeometryCalib.Tz=1;
|
---|
| 1207 | GeometryCalib.dpx=1;
|
---|
| 1208 | GeometryCalib.dpy=1;
|
---|
| 1209 | GeometryCalib.sx=1;
|
---|
| 1210 | GeometryCalib.Cx=0;
|
---|
| 1211 | GeometryCalib.Cy=0;
|
---|
| 1212 | GeometryCalib.f=1;
|
---|
| 1213 | GeometryCalib.kappa1=0;
|
---|
| 1214 | GeometryCalib.CoordUnit='cm';
|
---|
| 1215 | XmlData.GeometryCalib=GeometryCalib;
|
---|
| 1216 | if error==2, warntext=['no file ' FileBase '.civ'];
|
---|
| 1217 | elseif error==1, warntext='inconsistent number of fields in the .civ file';
|
---|
| 1218 | end
|
---|
| 1219 |
|
---|
| 1220 | set(handles.npx,'String',num2str(npx));%fills nbre of pixels x box
|
---|
| 1221 | set(handles.npy,'String',num2str(npy));%fills nbre of pixels y box
|
---|
| 1222 | set(handles.pxcm,'String',num2str(pxcmx));%fills scale x (pixel/cm) box
|
---|
| 1223 | set(handles.pycm,'String',num2str(pxcmy));%fills scale y (pixel/cm) box
|
---|
| 1224 | set(handles.pxcm,'Visible','on');%fills scale x (pixel/cm) box
|
---|
| 1225 | set(handles.pycm,'Visible','on');%fills scale y (pixel/cm) box
|
---|
| 1226 | end
|
---|
| 1227 | if ~isempty(TimeUnit_1) && ~isequal(TimeUnit_1,TimeUnit)
|
---|
[38] | 1228 | msgbox_uvmat('WARNING','the time units for the second series differs from the first one')
|
---|
[2] | 1229 | end
|
---|
| 1230 |
|
---|
| 1231 | % store last index in handles.lat_i and .last_j
|
---|
| 1232 | if ~isempty(XmlData.Time)
|
---|
| 1233 | nbfield_1=size(XmlData.Time,1);
|
---|
| 1234 | nburst_1=size(XmlData.Time,2);
|
---|
| 1235 | end
|
---|
| 1236 | last_i_cell=get(handles.last_i,'String');
|
---|
| 1237 | if isempty(nbfield_1)
|
---|
| 1238 | last_i_cell{2}='';
|
---|
| 1239 | else
|
---|
| 1240 | last_i_cell{2}=num2str(nbfield_1);
|
---|
| 1241 | end
|
---|
| 1242 | set(handles.last_i,'String',last_i_cell)
|
---|
| 1243 | last_j_cell=get(handles.last_j,'String');
|
---|
| 1244 | if isempty(nburst_1)
|
---|
| 1245 | last_j_cell{2}='';
|
---|
| 1246 | else
|
---|
| 1247 | last_j_cell{2}=num2str(nburst_1);
|
---|
| 1248 | end
|
---|
| 1249 | set(handles.last_j,'String',last_j_cell);
|
---|
| 1250 | if ~isequal(last_i_cell{1},last_i_cell{2}) || ~isequal(last_j_cell{1},last_j_cell{2})
|
---|
[38] | 1251 | msgbox_uvmat('WARNING','the numbers of input file of the second series differs from the first one')
|
---|
[2] | 1252 | end
|
---|
| 1253 |
|
---|
| 1254 | % store calibration data
|
---|
| 1255 | GeometryCalib=XmlData.GeometryCalib;
|
---|
| 1256 | if isempty(GeometryCalib)
|
---|
| 1257 | if isfield(UvData, 'GeometryCalib_1')
|
---|
| 1258 | UvData=rmfield(UvData,'GeometryCalib_1');
|
---|
| 1259 | end
|
---|
| 1260 | else
|
---|
| 1261 | UvData.GeometryCalib_1=GeometryCalib;
|
---|
| 1262 | if (isfield(GeometryCalib,'R')& ~isequal(GeometryCalib.R(2,1),0) & ~isequal(GeometryCalib.R(1,2),0)) |...
|
---|
| 1263 | (isfield(GeometryCalib,'kappa1')& ~isequal(GeometryCalib.kappa1,0))
|
---|
| 1264 | set(handles.pxcm,'String','var')
|
---|
| 1265 | set(handles.pycm,'String','var')
|
---|
| 1266 | else
|
---|
| 1267 | pixcmx=GeometryCalib.f*GeometryCalib.R(1,1)*GeometryCalib.sx/(GeometryCalib.Tz*GeometryCalib.dpx);
|
---|
| 1268 | pixcmy=GeometryCalib.f*GeometryCalib.R(2,2)/(GeometryCalib.Tz*GeometryCalib.dpy);
|
---|
| 1269 | set(handles.pxcm,'String',num2str(pixcmx))
|
---|
| 1270 | set(handles.pycm,'String',num2str(pixcmy))
|
---|
| 1271 | end
|
---|
| 1272 | end
|
---|
| 1273 | UvData.XmlData_1=XmlData;
|
---|
[61] | 1274 | set(handles.uvmat,'UserData',UvData)%update the data attached to the uvmat interface
|
---|
[2] | 1275 |
|
---|
| 1276 | if ~isequal(warntext,'')
|
---|
[38] | 1277 | msgbox_uvmat('WARNING',warntext)
|
---|
[2] | 1278 | end
|
---|
| 1279 |
|
---|
| 1280 | set(handles.RootPath_1,'BackgroundColor',[1 1 1])% signa the end the input operation
|
---|
| 1281 | drawnow
|
---|
| 1282 |
|
---|
| 1283 | set_scan_options(hObject, eventdata, handles)
|
---|
| 1284 |
|
---|
| 1285 | %---------------------------------------------------
|
---|
| 1286 | % switch file index scanning options scan_i and scan_j in an exclusive way
|
---|
| 1287 | function scan_i_Callback(hObject, eventdata, handles)
|
---|
| 1288 | %---------------------------------------------------
|
---|
| 1289 | if get(handles.scan_i,'Value')==1
|
---|
| 1290 | set(handles.scan_i,'BackgroundColor',[1 1 0])
|
---|
| 1291 | set(handles.scan_j,'Value',0)
|
---|
| 1292 | set(handles.scan_j,'BackgroundColor',[0.831 0.816 0.784])
|
---|
| 1293 | else
|
---|
| 1294 | set(handles.scan_i,'BackgroundColor',[0.831 0.816 0.784])
|
---|
| 1295 | set(handles.scan_j,'Value',1)
|
---|
| 1296 | set(handles.scan_j,'BackgroundColor',[1 1 0])
|
---|
| 1297 | end
|
---|
[45] | 1298 |
|
---|
[2] | 1299 | %-------------------------------------------------------------------
|
---|
| 1300 | % switch file index scanning options scan_i and scan_j in an exclusive way
|
---|
| 1301 | function scan_j_Callback(hObject, eventdata, handles)
|
---|
| 1302 | %-------------------------------------------------------------------
|
---|
| 1303 | if get(handles.scan_j,'Value')==1
|
---|
| 1304 | set(handles.scan_j,'BackgroundColor',[1 1 0])
|
---|
| 1305 | set(handles.scan_i,'Value',0)
|
---|
| 1306 | set(handles.scan_i,'BackgroundColor',[0.831 0.816 0.784])
|
---|
| 1307 | else
|
---|
| 1308 | set(handles.scan_j,'BackgroundColor',[0.831 0.816 0.784])
|
---|
| 1309 | set(handles.scan_i,'Value',1)
|
---|
| 1310 | set(handles.scan_i,'BackgroundColor',[1 1 0])
|
---|
| 1311 | end
|
---|
| 1312 |
|
---|
| 1313 | %-------------------------------------------------------------------
|
---|
| 1314 | function i1_Callback(hObject, eventdata, handles)
|
---|
| 1315 | %-------------------------------------------------------------------
|
---|
| 1316 | % [filebase,num1,num_a,num2,num_b,ext,NomType,subdir]=read_input_file(handles);
|
---|
[45] | 1317 | %[FileName,RootPath,filebase,xx,FileExt]=read_file_boxes(handles);
|
---|
[2] | 1318 | NomType=get(handles.FileIndex,'UserData');
|
---|
| 1319 | num1=stra2num(get(handles.i1,'String'));
|
---|
| 1320 | num2=stra2num(get(handles.i2,'String'));
|
---|
| 1321 | num_a=stra2num(get(handles.j1,'String'));
|
---|
| 1322 | num_b=stra2num(get(handles.j2,'String'));
|
---|
| 1323 | indices=name_generator('',num1,num_a,'',NomType,1,num2,num_b,'');
|
---|
| 1324 | set(handles.FileIndex,'String',indices)
|
---|
| 1325 | if get(handles.SubField,'Value')==1
|
---|
| 1326 | NomType_1=get(handles.FileIndex_1,'String');
|
---|
| 1327 | FileExt_1=get(handles.FileExt_1,'String');
|
---|
| 1328 | [P,F,str1,str2,str_a,str_b,Ext,NomType_1]=name2display(['xx' NomType_1 FileExt_1]);
|
---|
| 1329 | indices=name_generator('',num1,num_a,'',NomType_1,1,num2,num_b,'');
|
---|
| 1330 | set(handles.FileIndex_1,'String',indices)
|
---|
| 1331 | end
|
---|
| 1332 | run0_Callback(hObject, eventdata, handles)
|
---|
| 1333 |
|
---|
| 1334 | %-------------------------------------------------------------------
|
---|
| 1335 | function i2_Callback(hObject, eventdata, handles)
|
---|
| 1336 | i1_Callback(hObject, eventdata, handles)
|
---|
| 1337 | %-------------------------------------------------------------------
|
---|
| 1338 |
|
---|
| 1339 | %-------------------------------------------------------------------
|
---|
| 1340 | function j1_Callback(hObject, eventdata, handles)
|
---|
| 1341 | i1_Callback(hObject, eventdata, handles)
|
---|
| 1342 | %-------------------------------------------------------------------
|
---|
| 1343 |
|
---|
| 1344 | %-------------------------------------------------------------------
|
---|
| 1345 | function j2_Callback(hObject, eventdata, handles)
|
---|
| 1346 | i1_Callback(hObject, eventdata, handles)
|
---|
| 1347 | %-------------------------------------------------------------------
|
---|
| 1348 |
|
---|
| 1349 | %-------------------------------------------------------------------
|
---|
| 1350 | function slices_Callback(hObject, eventdata, handles)
|
---|
| 1351 | %-------------------------------------------------------------------
|
---|
| 1352 | if get(handles.slices,'Value')==1
|
---|
| 1353 | set(handles.slices,'BackgroundColor',[1 1 0])
|
---|
| 1354 | set(handles.nb_slice,'Visible','on')
|
---|
| 1355 | set(handles.z_text,'Visible','on')
|
---|
| 1356 | set(handles.z_index,'Visible','on')
|
---|
| 1357 | nb_slice_Callback(hObject, eventdata, handles)
|
---|
| 1358 | else
|
---|
| 1359 | set(handles.nb_slice,'Visible','off')
|
---|
| 1360 | set(handles.slices,'BackgroundColor',[0.7 0.7 0.7])
|
---|
| 1361 | set(handles.z_text,'Visible','off')
|
---|
| 1362 | set(handles.z_index,'Visible','off')
|
---|
| 1363 | set(handles.masklevel,'Value',1)
|
---|
| 1364 | set(handles.masklevel,'String',{'1'})
|
---|
| 1365 | end
|
---|
| 1366 |
|
---|
| 1367 | %-------------------------------------------------------------------
|
---|
| 1368 | function nb_slice_Callback(hObject, eventdata, handles)
|
---|
| 1369 | %-------------------------------------------------------------------
|
---|
[71] | 1370 | nb_slice_str=get(handles.nb_slice,'String');
|
---|
[60] | 1371 | if isequal(nb_slice_str,'volume')
|
---|
| 1372 | num=stra2num(get(handles.j1,'String'));
|
---|
| 1373 | last_j=get(handles.last_j,'String');
|
---|
| 1374 | nbslice=str2double(last_j{1});
|
---|
| 1375 | else
|
---|
| 1376 | num=str2double(get(handles.i1,'String'));
|
---|
| 1377 | nbslice=str2double(get(handles.nb_slice,'String'));
|
---|
| 1378 | end
|
---|
| 1379 | z=mod(num-1,nbslice)+1;
|
---|
[2] | 1380 | set(handles.z_index,'String',num2str(z))
|
---|
| 1381 | for ilist=1:nbslice
|
---|
| 1382 | list_index{ilist,1}=num2str(ilist);
|
---|
| 1383 | end
|
---|
| 1384 | set(handles.masklevel,'String',list_index)
|
---|
| 1385 | set(handles.masklevel,'Value',z)
|
---|
| 1386 |
|
---|
| 1387 |
|
---|
| 1388 | %-------------------------------------------------------------------
|
---|
| 1389 | % --- Executes on button press in view_xml.
|
---|
| 1390 | function view_xml_Callback(hObject, eventdata, handles)
|
---|
| 1391 | [FileName,RootPath,FileBase,FileIndices,FileExt]=read_file_boxes(handles);
|
---|
| 1392 | option=get(handles.view_xml,'String');
|
---|
| 1393 | if isequal(option,'view .xml')
|
---|
| 1394 | FileXml=[FileBase '.xml'];
|
---|
| 1395 | heditxml=editxml(FileXml);
|
---|
| 1396 | end
|
---|
| 1397 |
|
---|
| 1398 | %-------------------------------------------------------------------
|
---|
| 1399 | % --- Executes on button press in mask_test.
|
---|
| 1400 | function mask_test_Callback(hObject, eventdata, handles)
|
---|
| 1401 | %-------------------------------------------------------------------
|
---|
| 1402 | if isequal(get(handles.mask_test,'Value'),1)
|
---|
| 1403 | [FF,RootPath,FileBase]=read_file_boxes(handles);
|
---|
| 1404 | num_i1=stra2num(get(handles.i1,'String'));
|
---|
| 1405 | num_j1=stra2num(get(handles.j1,'String'));
|
---|
| 1406 | currentdir=pwd;
|
---|
| 1407 | cd(RootPath);
|
---|
| 1408 | maskfiles=dir('*_*mask_*.png');%look for a mask file
|
---|
| 1409 | cd(currentdir);%come back to the working directory
|
---|
| 1410 | mdetect=0;
|
---|
| 1411 | if isempty(maskfiles)
|
---|
| 1412 | msgbox_uvmat('ERROR','no mask file detected (format ..._xxmask_ii.png needed), use the menu bar Tools/Make mask')
|
---|
| 1413 | return
|
---|
| 1414 | end
|
---|
| 1415 | for ilist=1:length(maskfiles)
|
---|
| 1416 | maskname=maskfiles(ilist).name;% take the first mask file in the list
|
---|
| 1417 | [rr,ff,x1,x2,xa,xb,xext,Mask_NomType{ilist}]=name2display(maskname);
|
---|
| 1418 | if ~strcmp(Mask_NomType{ilist},Mask_NomType{1})
|
---|
| 1419 | msgbox_uvmat('ERROR',['inconsistent mask types ' Mask_NomType{1} Mask_NomType{ilist } ' coexist in the current image directory'])
|
---|
| 1420 | return
|
---|
| 1421 | end
|
---|
| 1422 | [Path2,Name,ext]=fileparts(maskname);
|
---|
| 1423 | Namedouble=double(Name);
|
---|
| 1424 | val=(48>Namedouble)|(Namedouble>57);% select the non-numerical characters
|
---|
| 1425 | ind_mask=findstr('mask',Name);
|
---|
| 1426 | i=ind_mask-1;
|
---|
| 1427 | while val(i)==0 & i>0
|
---|
| 1428 | i=i-1;
|
---|
| 1429 | end
|
---|
| 1430 | nbmask_str=str2num(Name(i+1:ind_mask-1));
|
---|
| 1431 | if ~isempty(nbmask_str)
|
---|
| 1432 | nbslice(ilist)=nbmask_str; % number of different masks (slices)
|
---|
| 1433 | end
|
---|
| 1434 | end
|
---|
| 1435 | if isequal(min(nbslice),max(nbslice))
|
---|
| 1436 | nbslice=nbslice(1);
|
---|
| 1437 | else
|
---|
| 1438 | msgbox_uvmat('ERROR','several inconsistent mask sets coexist in the current image directory')
|
---|
| 1439 | return
|
---|
| 1440 | end
|
---|
| 1441 | if ~isempty(nbslice) && Name(i)=='_'
|
---|
| 1442 | Mask.Base=[FileBase Name(i:ind_mask+3)];
|
---|
| 1443 | Mask.NbSlice=nbslice;
|
---|
[55] | 1444 | num_i1=mod(num_i1-1,nbslice)+1;
|
---|
[2] | 1445 | Mask.NomType=Mask_NomType{1};
|
---|
[55] | 1446 | [maskname,mdetect]=name_generator(Mask.Base,num_i1,num_j1,'.png',Mask.NomType);%
|
---|
| 1447 | mdetect=exist(maskname,'file');
|
---|
[2] | 1448 | if mdetect
|
---|
| 1449 | set(handles.nb_slice,'String',Name(i+1:ind_mask-1));
|
---|
| 1450 | set(handles.nb_slice,'BackgroundColor',[1 1 0])
|
---|
| 1451 | set(handles.mask_test,'UserData',Mask);
|
---|
| 1452 | set(handles.mask_test,'BackgroundColor',[1 1 0])
|
---|
| 1453 | if nbslice > 1
|
---|
| 1454 | set(handles.slices,'value',1)
|
---|
| 1455 | slices_Callback(hObject, eventdata, handles)
|
---|
| 1456 | end
|
---|
| 1457 | end
|
---|
| 1458 | end
|
---|
| 1459 | if mdetect==0
|
---|
| 1460 | msgbox_uvmat('ERROR','no mask file detected (format ..._xxmask_ii.png needed), use the menu bar Tools/Make mask')
|
---|
| 1461 | set(handles.mask_test,'Value',0)
|
---|
| 1462 | return
|
---|
| 1463 | end
|
---|
| 1464 | update_mask(handles,num_i1,num_j1);
|
---|
| 1465 | else
|
---|
| 1466 | MaskData=get(handles.mask_test,'UserData');
|
---|
| 1467 | if isfield(MaskData,'maskhandle') && ishandle(MaskData.maskhandle)
|
---|
| 1468 | delete(MaskData.maskhandle)
|
---|
| 1469 | end
|
---|
| 1470 | set(handles.mask_test,'UserData',[])
|
---|
[61] | 1471 | %huvmat=get(handles.mask_test,'parent');
|
---|
| 1472 | UvData=get(handles.uvmat,'UserData');
|
---|
[2] | 1473 | if isfield(UvData,'MaskName')
|
---|
| 1474 | UvData=rmfield(UvData,'MaskName');
|
---|
[61] | 1475 | set(handles.uvmat,'UserData',UvData)
|
---|
[2] | 1476 | end
|
---|
| 1477 | set(handles.mask_test,'BackgroundColor',[0.7 0.7 0.7])
|
---|
| 1478 | end
|
---|
| 1479 |
|
---|
| 1480 | %-------------------------------------------------------------------
|
---|
| 1481 | function update_mask(handles,num_i1,num_j1)
|
---|
| 1482 | %-------------------------------------------------------------------
|
---|
| 1483 |
|
---|
| 1484 | MaskData=get(handles.mask_test,'UserData');
|
---|
| 1485 | if isfield(MaskData,'maskhandle')&& ishandle(MaskData.maskhandle)
|
---|
| 1486 | uistack(MaskData.maskhandle,'top');
|
---|
| 1487 | end
|
---|
| 1488 | num_i1_mask=mod(num_i1-1,MaskData.NbSlice)+1;
|
---|
| 1489 | [MaskName,mdetect]=name_generator(MaskData.Base,num_i1_mask,num_j1,'.png',MaskData.NomType);
|
---|
| 1490 | huvmat=get(handles.mask_test,'parent');
|
---|
| 1491 | UvData=get(huvmat,'UserData');
|
---|
| 1492 |
|
---|
| 1493 | %update mask image if the mask is new
|
---|
| 1494 | if ~ (isfield(UvData,'MaskName') && isequal(UvData.MaskName,MaskName))
|
---|
| 1495 | UvData.MaskName=MaskName; %update the recorded name on UvData
|
---|
| 1496 | set(huvmat,'UserData',UvData);
|
---|
| 1497 | if mdetect==0
|
---|
| 1498 | if isfield(MaskData,'maskhandle')&& ishandle(MaskData.maskhandle)
|
---|
| 1499 | delete(MaskData.maskhandle)
|
---|
| 1500 | end
|
---|
| 1501 | else
|
---|
| 1502 | %read mask image
|
---|
| 1503 | Mask.AName='image';
|
---|
| 1504 | Mask.A=imread(MaskName);
|
---|
| 1505 | npxy=size(Mask.A);
|
---|
| 1506 | Mask.AX=[0.5 npxy(2)-0.5];
|
---|
| 1507 | Mask.AY=[npxy(1)-0.5 0.5 ];
|
---|
| 1508 | Mask.CoordType='px';
|
---|
| 1509 | if isequal(get(handles.slices,'Value'),1)
|
---|
| 1510 | NbSlice=str2num(get(handles.nb_slice,'String'));
|
---|
| 1511 | num_i1=str2num(get(handles.i1,'String'));
|
---|
| 1512 | Mask.ZIndex=mod(num_i1-1,NbSlice)+1;
|
---|
| 1513 | end
|
---|
| 1514 | %px to phys or other transform on field
|
---|
[39] | 1515 | menu_transform=get(handles.transform_fct,'String');
|
---|
| 1516 | choice_value=get(handles.transform_fct,'Value');
|
---|
| 1517 | transform_name=menu_transform{choice_value};%name of the transform fct given by the menu 'transform_fct'
|
---|
| 1518 | transform_list=get(handles.transform_fct,'UserData');
|
---|
[38] | 1519 | transform=transform_list{choice_value};
|
---|
| 1520 | if ~isequal(transform_name,'') && ~isequal(transform_name,'px')
|
---|
[2] | 1521 | if isfield(UvData,'XmlData') && isfield(UvData.XmlData,'GeometryCalib')%use geometry calib recorded from the ImaDoc xml file as first priority
|
---|
| 1522 | Calib=UvData.XmlData.GeometryCalib;
|
---|
[38] | 1523 | Mask=transform(Mask,UvData.XmlData);
|
---|
[2] | 1524 | end
|
---|
| 1525 | end
|
---|
| 1526 | flagmask=Mask.A < 200;
|
---|
| 1527 |
|
---|
| 1528 | %make brown color image
|
---|
| 1529 | imflag(:,:,1)=0.9*flagmask;
|
---|
| 1530 | imflag(:,:,2)=0.7*flagmask;
|
---|
| 1531 | imflag(:,:,3)=zeros(size(flagmask));
|
---|
| 1532 |
|
---|
| 1533 | %update mask image
|
---|
| 1534 | hmask=[]; %default
|
---|
| 1535 | if isfield(MaskData,'maskhandle')&& ishandle(MaskData.maskhandle)
|
---|
| 1536 | hmask=MaskData.maskhandle;
|
---|
| 1537 | end
|
---|
| 1538 | if ~isempty(hmask)
|
---|
| 1539 | set(hmask,'CData',imflag)
|
---|
| 1540 | set(hmask,'AlphaData',flagmask*0.6)
|
---|
| 1541 | set(hmask,'XData',Mask.AX);
|
---|
| 1542 | set(hmask,'YData',Mask.AY);
|
---|
| 1543 | % uistack(hmask,'top')
|
---|
| 1544 | else
|
---|
| 1545 | axes(handles.axes3)
|
---|
| 1546 | hold on
|
---|
| 1547 | MaskData.maskhandle=image(Mask.AX,Mask.AY,imflag,'Tag','mask','HitTest','off','AlphaData',0.6*flagmask);
|
---|
| 1548 | % set(MaskData.maskhandle,'AlphaData',0.6*flagmask)
|
---|
| 1549 | set(handles.mask_test,'UserData',MaskData)
|
---|
| 1550 | end
|
---|
| 1551 | end
|
---|
| 1552 | end
|
---|
| 1553 |
|
---|
| 1554 |
|
---|
| 1555 | %-------------------------------------------------------------------
|
---|
| 1556 | function MenuExportFigure_Callback(hObject, eventdata, handles)
|
---|
| 1557 | %-------------------------------------------------------------------
|
---|
| 1558 | huvmat=get(handles.MenuExport,'parent');
|
---|
| 1559 | UvData=get(huvmat,'UserData');
|
---|
| 1560 | hfig=figure;
|
---|
| 1561 | newaxes=copyobj(handles.axes3,hfig);
|
---|
| 1562 | map=colormap(handles.axes3);
|
---|
| 1563 | colormap(map);%transmit the current colormap to the zoom fig
|
---|
| 1564 | colorbar
|
---|
| 1565 |
|
---|
| 1566 | %-------------------------------------------------------------------
|
---|
| 1567 | %-------------------------------------------------------------------
|
---|
| 1568 | % III - MAIN REFRESH FUNCTIONS : 'FRAME PLOT'
|
---|
| 1569 | %-------------------------------------------------------------------
|
---|
| 1570 | %-------------------------------------------------------------------
|
---|
| 1571 |
|
---|
| 1572 | %Executes on button press in runplus: make one step forward and call
|
---|
| 1573 | %run0. The step forward is along the fields series 1 or 2 depending on
|
---|
| 1574 | %the scan_i and scan_j check box (exclusive each other)
|
---|
| 1575 | %-------------------------------------------------------------------
|
---|
| 1576 | function runplus_Callback(hObject, eventdata, handles)
|
---|
| 1577 | increment=str2num(get(handles.increment_scan,'String')); %get the field increment d
|
---|
| 1578 | runpm(hObject,eventdata,handles,increment)
|
---|
| 1579 |
|
---|
| 1580 | %-------------------------------------------------------------------
|
---|
| 1581 | %Executes on button press in runmin: make one step backward and call
|
---|
| 1582 | %run0. The step backward is along the fields series 1 or 2 depending on
|
---|
| 1583 | %the scan_i and scan_j check box (exclusive each other)
|
---|
| 1584 | %-------------------------------------------------------------------
|
---|
| 1585 | function runmin_Callback(hObject, eventdata, handles)
|
---|
| 1586 | increment=-str2num(get(handles.increment_scan,'String')); %get the field increment d
|
---|
| 1587 | runpm(hObject,eventdata,handles,increment)
|
---|
| 1588 |
|
---|
| 1589 | %-------------------------------------------------------------------
|
---|
| 1590 | %Executes on button press in runmin: make one step backward and call
|
---|
| 1591 | %run0. The step backward is along the fields series 1 or 2 depending on
|
---|
| 1592 | %the scan_i and scan_j check box (exclusive each other)
|
---|
| 1593 | %-------------------------------------------------------------------
|
---|
| 1594 | function RunMovie_Callback(hObject, eventdata, handles)
|
---|
| 1595 | %------------------------------------------------------------------
|
---|
| 1596 | set(handles.RunMovie,'BackgroundColor',[1 1 0])%paint the command button in yellow
|
---|
| 1597 | drawnow
|
---|
| 1598 | increment=str2num(get(handles.increment_scan,'String')); %get the field increment d
|
---|
| 1599 | set(handles.STOP,'Visible','on')
|
---|
| 1600 | set(handles.speed,'Visible','on')
|
---|
| 1601 | set(handles.speed_txt,'Visible','on')
|
---|
| 1602 | set(handles.RunMovie,'BusyAction','queue')
|
---|
| 1603 | testavi=0;
|
---|
[57] | 1604 | UvData=get(handles.uvmat,'UserData');
|
---|
[2] | 1605 |
|
---|
| 1606 | while get(handles.speed,'Value')~=0 & isequal(get(handles.RunMovie,'BusyAction'),'queue') % enable STOP command
|
---|
[72] | 1607 | errormsg=runpm(hObject,eventdata,handles,increment);
|
---|
| 1608 | if ~isempty(errormsg)
|
---|
| 1609 | return
|
---|
| 1610 | end
|
---|
[2] | 1611 | pause(1.02-get(handles.speed,'Value'))% wait for next image
|
---|
| 1612 | end
|
---|
| 1613 | if isfield(UvData,'aviobj') && ~isempty( UvData.aviobj),
|
---|
| 1614 | UvData.aviobj=close(UvData.aviobj);
|
---|
[57] | 1615 | set(handles.uvmat,'UserData',UvData);
|
---|
[2] | 1616 | end
|
---|
| 1617 | set(handles.RunMovie,'BackgroundColor',[1 0 0])%paint the command buttonback to red
|
---|
| 1618 |
|
---|
| 1619 | %-------------------------------------------------------------------
|
---|
| 1620 | function STOP_Callback(hObject, eventdata, handles)
|
---|
| 1621 | %-------------------------------------------------------------------
|
---|
[57] | 1622 | set(handles.movie_pair,'BusyAction','Cancel')
|
---|
| 1623 | set(handles.movie_pair,'value',0)
|
---|
[2] | 1624 | set(handles.RunMovie,'BusyAction','Cancel')
|
---|
| 1625 | set(handles.MenuExportMovie,'BusyAction','Cancel')
|
---|
| 1626 |
|
---|
| 1627 |
|
---|
| 1628 | %------------------------------------------------------------------
|
---|
[72] | 1629 | function errormsg=runpm(hObject,eventdata,handles,increment)
|
---|
[2] | 1630 | %------------------------------------------------------------------
|
---|
[57] | 1631 | %check for mùovie pair status
|
---|
| 1632 | movie_status=get(handles.movie_pair,'Value');
|
---|
| 1633 | if isequal(movie_status,1)
|
---|
[59] | 1634 | STOP_Callback(hObject, eventdata, handles)%interrupt movie pair if active
|
---|
[57] | 1635 | end
|
---|
[2] | 1636 | %read the data on the current input rootfile(s)
|
---|
| 1637 |
|
---|
| 1638 | [FileName,RootPath,filebase,FileIndices,FileExt,subdir]=read_file_boxes(handles);
|
---|
| 1639 | NomType=get(handles.FileIndex,'UserData');
|
---|
| 1640 |
|
---|
| 1641 | num1=stra2num(get(handles.i1,'String'));
|
---|
| 1642 | num2=stra2num(get(handles.i2,'String'));
|
---|
| 1643 | num_a=stra2num(get(handles.j1,'String'));
|
---|
| 1644 | num_b=stra2num(get(handles.j2,'String'));
|
---|
| 1645 |
|
---|
| 1646 | sub_value= get(handles.SubField,'Value');
|
---|
[59] | 1647 | if sub_value % a second input file has been entered
|
---|
[2] | 1648 | [FileName_1,RootPath_1,filebase_1,FileIndices_1,FileExt_1,SubDir_1]=read_file_boxes_1(handles);
|
---|
[59] | 1649 | [pp,ff,str1,str2,str_a,str_b]=name2display(FileIndices_1);
|
---|
| 1650 | num1_1=stra2num(str1);%current set of indices for the second field (may be set different than the main indices)
|
---|
| 1651 | num2_1=stra2num(str2);
|
---|
| 1652 | num_a_1=stra2num(str_a);
|
---|
| 1653 | num_b_1=stra2num(str_b);
|
---|
| 1654 | NomType_1=get(handles.FileIndex_1,'UserData');
|
---|
| 1655 | else
|
---|
| 1656 | filename_1=[];
|
---|
[2] | 1657 | end
|
---|
| 1658 |
|
---|
| 1659 | comp_input=get(handles.fix_pair,'Value');
|
---|
[59] | 1660 | if isequal(NomType,'_i1-i2')||isequal(NomType,'_i1-i2_j')
|
---|
| 1661 | comp_input=1; %impose a fixed pair
|
---|
[2] | 1662 | set(handles.fix_pair,'Value',1)
|
---|
| 1663 | end
|
---|
| 1664 |
|
---|
| 1665 | %case of scanning along the first direction (rootfile numbers)
|
---|
[59] | 1666 | if get(handles.scan_i,'Value')==1% case of scanning along index i
|
---|
[2] | 1667 | num1=num1+increment;
|
---|
| 1668 | num2=num2+increment;
|
---|
[71] | 1669 | [filename,num1,num_a,num2,num_b]=name_generator(filebase,num1,num_a,FileExt,NomType,comp_input,num2,num_b,subdir);
|
---|
[59] | 1670 | if sub_value% set the second field name and indices
|
---|
| 1671 | num1_1=num1_1+increment;
|
---|
| 1672 | num2_1=num2_1+increment;
|
---|
| 1673 | filename_1=name_generator(filebase_1,num1_1,num_a_1,FileExt_1,NomType_1,1,num2_1,num_b_1,SubDir_1);
|
---|
| 1674 | end
|
---|
| 1675 | else % case of scanning along index j (burst numbers)
|
---|
[2] | 1676 | num_a=num_a+increment;
|
---|
| 1677 | num_b=num_b+increment;
|
---|
[59] | 1678 | if sub_value
|
---|
| 1679 | num_a_1=num_a_1+increment;
|
---|
| 1680 | num_b_1=num_b_1+increment;
|
---|
| 1681 | filename_1=name_generator(filebase_1,num1_1,num_a_1,FileExt_1,NomType_1,1,num2_1,num_b_1,SubDir_1);
|
---|
| 1682 | % else % redefine the j index if it exceeds its upper bound (only in the absence of a second field)
|
---|
| 1683 | % lastfield_cell=get(handles.last_j,'String'); % get the last field number
|
---|
| 1684 | % lastfield=str2double(lastfield_cell{1});
|
---|
| 1685 | % if num_a>lastfield && ~isnan(lastfield)
|
---|
| 1686 | % num_a=mod(num_a,lastfield);
|
---|
| 1687 | % num_b=mod(num_b,lastfield)
|
---|
| 1688 | % end
|
---|
[2] | 1689 | end
|
---|
[65] | 1690 | [filename,num1,num_a,num2,num_b]=name_generator(filebase,num1,num_a,FileExt,NomType,comp_input,num2,num_b,subdir);
|
---|
[2] | 1691 | end
|
---|
| 1692 |
|
---|
[59] | 1693 | % refresh plots
|
---|
| 1694 | errormsg=refresh_field(handles,filename,filename_1,num1,num2,num_a,num_b);
|
---|
[2] | 1695 |
|
---|
[59] | 1696 | if isempty(errormsg) %update the index counters
|
---|
| 1697 | set(handles.i1,'String',num2stra(num1,NomType,1));
|
---|
| 1698 | if isequal(num2,num1)
|
---|
| 1699 | set(handles.i2,'String','');
|
---|
| 1700 | else
|
---|
| 1701 | set(handles.i2,'String',num2stra(num2,NomType,1));
|
---|
| 1702 | end
|
---|
| 1703 | set(handles.j1,'String',num2stra(num_a,NomType,2));
|
---|
| 1704 | if isequal(num_b,num_a)
|
---|
| 1705 | set(handles.j2,'String','');
|
---|
| 1706 | else
|
---|
| 1707 | set(handles.j2,'String',num2stra(num_b,NomType,2));
|
---|
| 1708 | end
|
---|
| 1709 | [indices]=name_generator('',num1,num_a,'',NomType,1,num2,num_b,'');
|
---|
| 1710 | set(handles.FileIndex,'String',indices);
|
---|
| 1711 | if sub_value
|
---|
| 1712 | indices_1=name_generator('',num1_1,num_a_1,'',NomType_1,1,num2_1,num_b_1,'');
|
---|
| 1713 | set(handles.FileIndex_1,'String',indices_1);
|
---|
| 1714 | end
|
---|
| 1715 | if isequal(movie_status,1)
|
---|
| 1716 | set(handles.movie_pair,'Value',1)
|
---|
| 1717 | movie_pair_Callback(hObject, eventdata, handles); %reactivate moviepair if it was activated
|
---|
| 1718 | end
|
---|
[57] | 1719 | else
|
---|
[59] | 1720 | msgbox_uvmat('ERROR',errormsg);
|
---|
[57] | 1721 | end
|
---|
[2] | 1722 |
|
---|
| 1723 |
|
---|
[59] | 1724 |
|
---|
[2] | 1725 | %-------------------------------------------------------
|
---|
[57] | 1726 | % --- Executes on button press in movie_pair: create an alternating movie with two view
|
---|
[2] | 1727 | %-------------------------------------------------------
|
---|
| 1728 | function movie_pair_Callback(hObject, eventdata, handles)
|
---|
[57] | 1729 | status=get(handles.movie_pair,'value');
|
---|
| 1730 | if isequal(status,0)
|
---|
[59] | 1731 | set(handles.movie_pair,'BusyAction','Cancel')%stop movie pair if button is 'off'
|
---|
| 1732 | set(handles.i2,'String','')
|
---|
| 1733 | set(handles.j2,'String','')
|
---|
[57] | 1734 | return
|
---|
| 1735 | else
|
---|
| 1736 | set(handles.movie_pair,'BusyAction','queue')
|
---|
| 1737 | end
|
---|
[2] | 1738 | %initialisation
|
---|
| 1739 | set(handles.movie_pair,'BackgroundColor',[1 1 0])%paint the command button in yellow
|
---|
| 1740 | drawnow
|
---|
| 1741 | list_fields=get(handles.Fields,'String');% list menu fields
|
---|
| 1742 | index_fields=get(handles.Fields,'Value');% selected string index
|
---|
| 1743 | FieldName=list_fields{index_fields}; % selected field
|
---|
[65] | 1744 | UvData=get(handles.uvmat,'UserData');
|
---|
[2] | 1745 | if isequal(FieldName,'image')
|
---|
[65] | 1746 | test_1=0;
|
---|
| 1747 | [ff,rr,filebase,xx,Ext,SubDir]=read_file_boxes(handles);
|
---|
| 1748 | NomType=get(handles.FileIndex,'UserData');
|
---|
[2] | 1749 | else
|
---|
[65] | 1750 | list_fields=get(handles.Fields_1,'String');% list menu fields
|
---|
| 1751 | index_fields=get(handles.Fields_1,'Value');% selected string index
|
---|
| 1752 | FieldName=list_fields{index_fields}; % selected field
|
---|
| 1753 | if isequal(FieldName,'image')
|
---|
| 1754 | test_1=1;
|
---|
| 1755 | [ff,rr,filebase,xx,Ext,SubDir]=read_file_boxes_1(handles);
|
---|
| 1756 | NomType=get(handles.FileIndex_1,'UserData');
|
---|
| 1757 | else
|
---|
| 1758 | msgbox_uvmat('ERROR','an image or movie must be first introduced as input')
|
---|
| 1759 | return
|
---|
| 1760 | end
|
---|
[2] | 1761 | end
|
---|
[65] | 1762 |
|
---|
[57] | 1763 | num_i1=stra2num(get(handles.i1,'String'));
|
---|
| 1764 | num_j1=stra2num(get(handles.j1,'String'));
|
---|
| 1765 | num_i2=stra2num(get(handles.i2,'String'));
|
---|
| 1766 | num_j2=stra2num(get(handles.j2,'String'));
|
---|
| 1767 | if isempty(num_j2)
|
---|
| 1768 | if isempty(num_i2)
|
---|
| 1769 | msgbox_uvmat('ERROR', 'a second image index i2 or j2 is needed to show the pair as a movie')
|
---|
[2] | 1770 | return
|
---|
[57] | 1771 | else
|
---|
| 1772 | num_j2=num_j1;%repeat the index i1 by default
|
---|
[2] | 1773 | end
|
---|
[57] | 1774 | end
|
---|
| 1775 | if isempty(num_i2)
|
---|
| 1776 | num_i2=num_i1;%repeat the index i1 by default
|
---|
| 1777 | end
|
---|
| 1778 | imaname_1=name_generator(filebase,num_i2,num_j2,Ext,NomType);
|
---|
| 1779 | if ~exist(imaname_1,'file')
|
---|
| 1780 | msgbox_uvmat('ERROR',['second input open (-) ' imaname_1 ' not found']);
|
---|
| 1781 | return
|
---|
| 1782 | end
|
---|
| 1783 | % set(handles.i2,'String',''); % indicates that the second index i2 is not used
|
---|
| 1784 | % set(handles.j2,'String',''); % indicates that the second index i2 is not used
|
---|
[2] | 1785 |
|
---|
| 1786 | %read the second image
|
---|
| 1787 | Field.AName='image';
|
---|
[65] | 1788 | if test_1
|
---|
| 1789 | Field_a=UvData.Field_1;
|
---|
| 1790 | else
|
---|
| 1791 | Field_a=UvData.Field;
|
---|
| 1792 | end
|
---|
| 1793 | Field_b.AX=Field_a.AX;
|
---|
| 1794 | Field_b.AY=Field_a.AY;
|
---|
[57] | 1795 | % z index
|
---|
| 1796 | nbslice=str2double(get(handles.nb_slice,'String'));
|
---|
| 1797 | if ~isempty(nbslice)
|
---|
[65] | 1798 | Field_b.ZIndex=mod(num_i2-1,nbslice)+1;
|
---|
[57] | 1799 | end
|
---|
[65] | 1800 | Field_b.CoordType='px';
|
---|
[45] | 1801 | %determine the input file type
|
---|
[65] | 1802 | if (test_1 && isfield(UvData,'MovieObject_1'))||(~test_1 && isfield(UvData,'MovieObject'))
|
---|
[45] | 1803 | FileType='movie';
|
---|
| 1804 | elseif isequal(lower(Ext),'.avi')
|
---|
| 1805 | FileType='avi';
|
---|
| 1806 | elseif isequal(lower(Ext),'.vol')
|
---|
| 1807 | FileType='vol';
|
---|
| 1808 | else
|
---|
| 1809 | form=imformats(Ext([2:end]));
|
---|
| 1810 | if ~isempty(form)% if the extension corresponds to an image format recognized by Matlab
|
---|
| 1811 | if isequal(NomType,'*');
|
---|
| 1812 | FileType='multimage';
|
---|
| 1813 | else
|
---|
| 1814 | FileType='image';
|
---|
| 1815 | end
|
---|
| 1816 | end
|
---|
| 1817 | end
|
---|
| 1818 | switch FileType
|
---|
| 1819 | case 'movie'
|
---|
[65] | 1820 | if test_1
|
---|
| 1821 | Field_b.A=read(UvData.MovieObject_1,num_i2);
|
---|
| 1822 | else
|
---|
| 1823 | Field_b.A=read(UvData.MovieObject,num_i2);
|
---|
| 1824 | end
|
---|
[45] | 1825 | case 'avi'
|
---|
| 1826 | mov=aviread(imaname_1,num_i2);
|
---|
[65] | 1827 | Field_b.A=frame2im(mov(1));
|
---|
[45] | 1828 | case 'vol'
|
---|
[65] | 1829 | Field_b.A=imread(imaname_1);
|
---|
[45] | 1830 | case 'multimage'
|
---|
[65] | 1831 | Field_b.A=imread(imaname_1,num_i2);
|
---|
[45] | 1832 | case 'image'
|
---|
[65] | 1833 | Field_b.A=imread(imaname_1);
|
---|
[45] | 1834 | end
|
---|
[60] | 1835 | if get(handles.slices,'Value')
|
---|
| 1836 | Field.ZIndex=str2double(get(handles.z_index,'String'));
|
---|
| 1837 | end
|
---|
[2] | 1838 |
|
---|
| 1839 | %px to phys or other transform on field
|
---|
[39] | 1840 | menu_transform=get(handles.transform_fct,'String');
|
---|
| 1841 | choice_value=get(handles.transform_fct,'Value');
|
---|
| 1842 | transform_name=menu_transform{choice_value};%name of the transform fct given by the menu 'transform_fct'
|
---|
| 1843 | transform_list=get(handles.transform_fct,'UserData');
|
---|
[38] | 1844 | transform=transform_list{choice_value};
|
---|
| 1845 | if ~isequal(transform_name,'') && ~isequal(transform_name,'px')
|
---|
[65] | 1846 | 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] | 1847 | Field_a=transform(Field_a,UvData.XmlData_1);%the first field has been stored without transform
|
---|
[65] | 1848 | Field_b=transform(Field_b,UvData.XmlData_1);
|
---|
| 1849 | elseif ~test_1 && isfield(UvData,'XmlData') && isfield(UvData.XmlData,'GeometryCalib')%use geometry calib
|
---|
| 1850 | Field_b=transform(Field_b,UvData.XmlData);
|
---|
[2] | 1851 | end
|
---|
| 1852 | end
|
---|
| 1853 |
|
---|
| 1854 | % make movie until movie speed is set to 0 or STOP is activated
|
---|
| 1855 | hima=findobj(handles.axes3,'Tag','ima');% %handles.axes3 =main plotting window (A GENERALISER)
|
---|
| 1856 | set(handles.STOP,'Visible','on')
|
---|
| 1857 | set(handles.speed,'Visible','on')
|
---|
| 1858 | set(handles.speed_txt,'Visible','on')
|
---|
[57] | 1859 | while get(handles.speed,'Value')~=0 && isequal(get(handles.movie_pair,'BusyAction'),'queue')%isequal(get(handles.run0,'BusyAction'),'queue'); % enable STOP command
|
---|
[2] | 1860 | % read and plot the series of images in non erase mode
|
---|
[65] | 1861 | set(hima,'CData',Field_b.A);
|
---|
[2] | 1862 | pause(1.02-get(handles.speed,'Value'));% wait for next image
|
---|
[65] | 1863 | set(hima,'CData',Field_a.A);
|
---|
[2] | 1864 | pause(1.02-get(handles.speed,'Value'));% wait for next image
|
---|
| 1865 | end
|
---|
| 1866 | set(handles.movie_pair,'BackgroundColor',[1 0 0])%paint the command button in red
|
---|
| 1867 |
|
---|
[59] | 1868 | %------------------------------------------------------------------------
|
---|
[2] | 1869 | % --- Executes on button press in run0.
|
---|
| 1870 | function run0_Callback(hObject, eventdata, handles)
|
---|
[59] | 1871 | %------------------------------------------------------------------------
|
---|
| 1872 | filename=read_file_boxes(handles);
|
---|
[2] | 1873 |
|
---|
[59] | 1874 | filename_1=[];%default
|
---|
| 1875 | if get(handles.SubField,'Value')
|
---|
| 1876 | filename_1=read_file_boxes_1(handles);
|
---|
| 1877 | end
|
---|
| 1878 | num_i1=stra2num(get(handles.i1,'String'));
|
---|
| 1879 | num_i2=stra2num(get(handles.i2,'String'));
|
---|
| 1880 | num_j1=stra2num(get(handles.j1,'String'));
|
---|
| 1881 | num_j2=stra2num(get(handles.j2,'String'));
|
---|
| 1882 | errormsg=refresh_field(handles,filename,filename_1,num_i1,num_i2,num_j1,num_j2);
|
---|
| 1883 | if ~isempty(errormsg)
|
---|
| 1884 | msgbox_uvmat('ERROR',errormsg);
|
---|
| 1885 | end
|
---|
| 1886 |
|
---|
| 1887 | %------------------------------------------------------------------------
|
---|
| 1888 | % --- read the input files and refresh all the plots, including projection.
|
---|
| 1889 | % OUTPUT:
|
---|
| 1890 | % errormsg: error message char string =[] by default
|
---|
| 1891 | % INPUT:
|
---|
| 1892 | % filename: first input file (=[] in the absence of input file)
|
---|
| 1893 | % filename_1: second input file (=[] in the asbsenc of secodn input file)
|
---|
| 1894 | % num_i1,num_i2,num_j1,num_j2; frame indices
|
---|
| 1895 | % Field: structure describing an optional input field (then replace the input file)
|
---|
| 1896 |
|
---|
| 1897 | function errormsg=refresh_field(handles,filename,filename_1,num_i1,num_i2,num_j1,num_j2,Field)
|
---|
| 1898 | %------------------------------------------------------------------------
|
---|
[2] | 1899 | %initialisation
|
---|
| 1900 | set(handles.run0,'BackgroundColor',[1 1 0])%paint the command button in yellow
|
---|
| 1901 | drawnow
|
---|
[59] | 1902 | errormsg=[]; % default error message
|
---|
[2] | 1903 | abstime=[];
|
---|
| 1904 | abstime_1=[];
|
---|
| 1905 | dt=[];
|
---|
[59] | 1906 | if ~exist('Field','var')
|
---|
| 1907 | Field={};
|
---|
| 1908 | end
|
---|
[45] | 1909 | UvData=get(handles.uvmat,'UserData');
|
---|
[59] | 1910 | % if isfield(UvData,'Txt')
|
---|
| 1911 | % UvData=rmfield(UvData,'Txt');%erase previous error message
|
---|
| 1912 | % end
|
---|
[2] | 1913 | if ishandle(handles.UVMAT_title) %remove title panel on uvmat
|
---|
| 1914 | delete(handles.UVMAT_title)
|
---|
| 1915 | end
|
---|
| 1916 |
|
---|
| 1917 | % determine the main input file information for action
|
---|
[45] | 1918 | FileType=[];%default
|
---|
[59] | 1919 | if ~isempty(filename)
|
---|
| 1920 | % [filename,RootPath,filebase,xx,Ext]=read_file_boxes(handles);
|
---|
[2] | 1921 | if ~exist(filename,'file')
|
---|
[59] | 1922 | errormsg=['input file ' filename ' does not exist'];
|
---|
[2] | 1923 | return
|
---|
| 1924 | end
|
---|
[59] | 1925 | Ext=get(handles.FileExt,'String');
|
---|
[2] | 1926 | NomType=get(handles.FileIndex,'UserData');
|
---|
| 1927 | %update the z position index
|
---|
[60] | 1928 | nbslice_str=get(handles.nb_slice,'String');
|
---|
| 1929 | z_index=1;%default
|
---|
| 1930 | if isequal(nbslice_str,'volume')
|
---|
| 1931 | z_index=num_j1;
|
---|
| 1932 | set(handles.z_index,'String',num2str(z_index))
|
---|
| 1933 | else
|
---|
| 1934 | nbslice=str2num(nbslice_str);
|
---|
[2] | 1935 | z_index=mod(num_i1-1,nbslice)+1;
|
---|
| 1936 | set(handles.z_index,'String',num2str(z_index))
|
---|
| 1937 | end
|
---|
[60] | 1938 | % refresh menu for save_mask if relevant
|
---|
| 1939 | masknumber=get(handles.masklevel,'String');
|
---|
| 1940 | if length(masknumber)>=z_index
|
---|
| 1941 | set(handles.masklevel,'Value',z_index)
|
---|
| 1942 | end
|
---|
| 1943 |
|
---|
[45] | 1944 | % determine the input file type
|
---|
| 1945 | if isequal(Ext,'.nc')||isequal(Ext,'.cdf')
|
---|
| 1946 | FileType='netcdf';
|
---|
| 1947 | elseif isfield(UvData,'MovieObject')
|
---|
| 1948 | FileType='movie';
|
---|
| 1949 | FieldName='image';
|
---|
| 1950 | elseif isequal(lower(Ext),'.avi')
|
---|
| 1951 | FileType='avi';
|
---|
| 1952 | FieldName='image';
|
---|
| 1953 | elseif isequal(lower(Ext),'.vol')
|
---|
| 1954 | FileType='vol';
|
---|
| 1955 | FieldName='image';
|
---|
[2] | 1956 | else
|
---|
| 1957 | form=imformats(Ext([2:end]));
|
---|
| 1958 | if ~isempty(form)% if the extension corresponds to an image format recognized by Matlab
|
---|
[45] | 1959 | if isequal(NomType,'*');
|
---|
| 1960 | FileType='multimage';
|
---|
| 1961 | else
|
---|
| 1962 | FileType='image';
|
---|
| 1963 | end
|
---|
[2] | 1964 | FieldName='image';
|
---|
| 1965 | end
|
---|
| 1966 | end
|
---|
| 1967 | else
|
---|
[45] | 1968 | FileType='netcdf';
|
---|
[2] | 1969 | FieldName='get_field...';
|
---|
| 1970 | end
|
---|
| 1971 | VelType=[];%default
|
---|
[45] | 1972 | if isequal(FileType,'netcdf')
|
---|
[2] | 1973 | list_fields=get(handles.Fields,'String');% list menu fields
|
---|
| 1974 | index_fields=get(handles.Fields,'Value');% selected string index
|
---|
| 1975 | FieldName= list_fields{index_fields}; % selected field
|
---|
[59] | 1976 | if ~isequal(FieldName,'get_field...')% read the field names on the interface get_field...
|
---|
[2] | 1977 | VelType=setfield(handles);
|
---|
| 1978 | end
|
---|
| 1979 | end
|
---|
| 1980 |
|
---|
| 1981 | % choose a second field if Subfield option is 'on'
|
---|
| 1982 | FieldName_1=[];
|
---|
| 1983 | scal_color=[];
|
---|
| 1984 | VelType_1=setfield_1(handles);
|
---|
| 1985 | sub_value=get(handles.SubField,'Value');
|
---|
[45] | 1986 | FileType_1='none';%default
|
---|
[59] | 1987 | if ~isempty(filename_1)
|
---|
| 1988 | % test for a constant second field (comparison with a fixed field)
|
---|
[2] | 1989 | NomType_1=get(handles.FileIndex_1,'UserData');
|
---|
[71] | 1990 | Ext_1=get(handles.FileExt_1,'String');
|
---|
[45] | 1991 | % determine the input file type
|
---|
| 1992 | if isequal(Ext_1,'.nc')||isequal(Ext_1,'.cdf')
|
---|
| 1993 | FileType_1='netcdf';
|
---|
| 1994 | elseif isfield(UvData,'MovieObject_1')
|
---|
| 1995 | FileType_1='movie';
|
---|
| 1996 | FieldName_1='image';
|
---|
| 1997 | elseif isequal(lower(Ext_1),'.avi')
|
---|
| 1998 | FileType='avi';
|
---|
| 1999 | FieldName_1='image';
|
---|
| 2000 | elseif isequal(lower(Ext_1),'.vol')
|
---|
| 2001 | FileType_1='vol';
|
---|
| 2002 | FieldName_1='image';
|
---|
| 2003 | else
|
---|
[65] | 2004 | form=imformats(Ext_1([2:end]));
|
---|
[45] | 2005 | if ~isempty(form)% if the extension corresponds to an image format recognized by Matlab
|
---|
| 2006 | if isequal(NomType_1,'*');
|
---|
| 2007 | FileType_1='multimage';
|
---|
| 2008 | else
|
---|
| 2009 | FileType_1='image';
|
---|
| 2010 | end
|
---|
| 2011 | FieldName_1='image';
|
---|
| 2012 | end
|
---|
| 2013 | end
|
---|
| 2014 | if ~isequal(FieldName_1,'image')
|
---|
| 2015 | list_fields=get(handles.Fields_1,'String');% list menu fields
|
---|
| 2016 | index_fields=get(handles.Fields_1,'Value');% selected string index
|
---|
| 2017 | FieldName_1= list_fields{index_fields}; % selected field
|
---|
| 2018 | if isequal(VelType_1,'*')% free veltype choice
|
---|
[2] | 2019 | VelType_1=[];
|
---|
[45] | 2020 | elseif isequal(VelType_1,'"')% veltype the same as for the first field
|
---|
| 2021 | if isempty(VelType)
|
---|
| 2022 | VelType_1=[];
|
---|
| 2023 | else
|
---|
| 2024 | VelType_1=VelType;
|
---|
| 2025 | end
|
---|
[2] | 2026 | end
|
---|
| 2027 | end
|
---|
[59] | 2028 | test_keepdata_1=0;% test for keeping the previous stored data if the input files are unchanged
|
---|
| 2029 | if ~isequal(NomType_1,'*')%in case of a series of files (not avi movie)
|
---|
[45] | 2030 | if isfield(UvData,'filename_1')&& isfield(UvData,'VelType_1') && isfield(UvData,'FieldName_1')
|
---|
| 2031 | test_keepdata_1= isequal(filename_1,UvData.filename_1)&&...
|
---|
| 2032 | isequal(VelType_1,UvData.filename_1) && isequal(FieldName_1,UvData.FieldName_1);
|
---|
[2] | 2033 | end
|
---|
| 2034 | end
|
---|
[59] | 2035 | if test_keepdata_1
|
---|
| 2036 | Field{2}=UvData.Field_1;
|
---|
| 2037 | elseif ~exist(filename_1,'file')
|
---|
| 2038 | errormsg=['second file ' filename_1 ' does not exist'];
|
---|
| 2039 | return
|
---|
| 2040 | end
|
---|
[2] | 2041 | end
|
---|
| 2042 |
|
---|
| 2043 | %read the input field(s)
|
---|
| 2044 | %read images
|
---|
[45] | 2045 | if ~isempty(filename) && isequal(FieldName,'image')
|
---|
| 2046 | switch FileType
|
---|
| 2047 | case 'movie'
|
---|
| 2048 | A=read(UvData.MovieObject,num_i1);
|
---|
| 2049 | case 'avi'
|
---|
| 2050 | mov=aviread(filename,num_i1);
|
---|
| 2051 | A=frame2im(mov(1));
|
---|
| 2052 | case 'vol'
|
---|
| 2053 | A=imread(filename);
|
---|
| 2054 | case 'multimage'
|
---|
| 2055 | A=imread(filename,num_i1);
|
---|
| 2056 | case 'image'
|
---|
| 2057 | A=imread(filename);
|
---|
[2] | 2058 | end
|
---|
| 2059 | npxy=size(A);
|
---|
| 2060 | set(handles.npx,'String',num2str(npxy(2)));% display image size on the interface
|
---|
| 2061 | set(handles.npy,'String',num2str(npxy(1)));
|
---|
| 2062 | Rangx=[0.5 npxy(2)-0.5]; % coordinates of the first and last pixel centers
|
---|
| 2063 | Rangy=[npxy(1)-0.5 0.5]; %
|
---|
| 2064 | Field{1}.AName='image';
|
---|
| 2065 | Field{1}.ListVarName={'AY','AX','A'}; %
|
---|
| 2066 | if size(A,3)==3;%color
|
---|
| 2067 | Field{1}.VarDimName={'AY','AX',{'AY','AX','rgb'}}; %
|
---|
| 2068 | else
|
---|
| 2069 | Field{1}.VarDimName={'AY','AX',{'AY','AX'}}; %
|
---|
| 2070 | end
|
---|
| 2071 | Field{1}.AY=Rangy;
|
---|
| 2072 | Field{1}.AX=Rangx;
|
---|
| 2073 | Field{1}.A=A;
|
---|
| 2074 | Field{1}.CoordType='px'; %used for mouse_motion
|
---|
| 2075 | Field{1}.CoordUnit='pixel'; %used for mouse_motion
|
---|
| 2076 | end
|
---|
[56] | 2077 |
|
---|
| 2078 | %read a second image
|
---|
[59] | 2079 | if ~isempty(filename_1) && ~test_keepdata_1 && isequal(FieldName_1,'image')
|
---|
[45] | 2080 | switch FileType_1
|
---|
| 2081 | case 'movie'
|
---|
| 2082 | A=read(UvData.MovieObject_1,num_i1);
|
---|
| 2083 | case 'avi'
|
---|
[65] | 2084 | mov=aviread(filename_1,num_i1);
|
---|
[45] | 2085 | A=frame2im(mov(1));
|
---|
| 2086 | case 'vol'
|
---|
[65] | 2087 | A=imread(filename_1);
|
---|
[45] | 2088 | case 'multimage'
|
---|
[65] | 2089 | A=imread(filename_1,num_i1);
|
---|
[45] | 2090 | case 'image'
|
---|
[65] | 2091 | A=imread(filename_1);
|
---|
| 2092 | case 'netcdf'
|
---|
| 2093 | otherwise
|
---|
| 2094 | errormsg=['unknown input file type ' filename_1];
|
---|
[45] | 2095 | end
|
---|
[2] | 2096 | npxy=size(A);
|
---|
| 2097 | set(handles.npx,'String',num2str(npxy(2)));% display image size on the interface
|
---|
| 2098 | set(handles.npy,'String',num2str(npxy(1)));
|
---|
| 2099 | Rangx=[0.5 npxy(2)-0.5]; % coordinates of the first and last pixel centers
|
---|
| 2100 | Rangy=[npxy(1)-0.5 0.5]; %
|
---|
| 2101 | Field{2}.AName='image';
|
---|
| 2102 | Field{2}.ListVarName={'AY','AX','A'}; %
|
---|
| 2103 | if size(A,3)==3;%color
|
---|
| 2104 | Field{2}.VarDimName={'AY','AX',{'AY','AX','rgb'}}; %
|
---|
| 2105 | else
|
---|
| 2106 | Field{2}.VarDimName={'AY','AX',{'AY','AX'}}; %
|
---|
| 2107 | end
|
---|
| 2108 | Field{2}.AY=Rangy;
|
---|
| 2109 | Field{2}.AX=Rangx;
|
---|
| 2110 | Field{2}.A=A;
|
---|
| 2111 | Field{2}.CoordType='px'; %used for mouse_motion
|
---|
| 2112 | Field{2}.CoordUnit='px'; %used for move_mou
|
---|
| 2113 | end
|
---|
| 2114 |
|
---|
| 2115 | %read ncfile(s)
|
---|
| 2116 | CivStage_1=0;%default
|
---|
| 2117 | VelType_out_1=[];
|
---|
| 2118 | InputField={FieldName};
|
---|
| 2119 | InputField_1={FieldName_1};
|
---|
[59] | 2120 | if (~isempty(filename)&& isequal(FileType,'netcdf')) || (~isempty(filename_1)&& isequal(FileType_1,'netcdf')) ;
|
---|
[2] | 2121 | %read the velocity field(s) from netcdf rootfile(s)
|
---|
| 2122 | list_code=get(handles.col_vec,'String');% list menu fields
|
---|
| 2123 | index_code=get(handles.col_vec,'Value');% selected string index
|
---|
| 2124 | scal_color= list_code{index_code(1)}; % selected field
|
---|
| 2125 | if isequal(FieldName,'velocity')&& ~isequal(scal_color,'black') && ~isequal(scal_color,'white')
|
---|
| 2126 | InputField=[InputField scal_color];
|
---|
| 2127 | end
|
---|
| 2128 | if isequal(FieldName_1,'velocity') && ~isequal(scal_color,'black') && ~isequal(scal_color,'white')
|
---|
| 2129 | InputField_1=[InputField_1 scal_color];
|
---|
| 2130 | end
|
---|
[45] | 2131 | if isequal(FileType,'netcdf') %read the first nc field
|
---|
[2] | 2132 | if isequal(FieldName,'get_field...')% read the field names on the interface get_field.
|
---|
[59] | 2133 | %VelType=get(handles.Fields,'UserData');
|
---|
[2] | 2134 | hget_field=findobj(allchild(0),'Name','get_field');%find the get_field... GUI
|
---|
| 2135 | if isempty(hget_field)
|
---|
| 2136 | hget_field= get_field(filename);%open the get_field GUI
|
---|
| 2137 | end
|
---|
| 2138 | hhget_field=guidata(hget_field);
|
---|
| 2139 | set(hhget_field.inputfile,'String',filename)% update the list of input fields in get_field
|
---|
| 2140 | set(hhget_field.ACTION,'Value',1)% PLOT option selected
|
---|
| 2141 | set(hhget_field.list_fig,'Value',2)% plotting axes =uvmat selected
|
---|
| 2142 | [Field{1},errormsg]=read_get_field(hget_field); %read the names of the variables to plot in the get_field GUI
|
---|
| 2143 | if ~isempty(errormsg)
|
---|
[59] | 2144 | errormsg=['error in uvmat/run0_Callback/read_get_field: ' errormsg];
|
---|
[2] | 2145 | return
|
---|
| 2146 | end
|
---|
| 2147 | CivStage=0;
|
---|
| 2148 | VelType_out=[];
|
---|
| 2149 | else
|
---|
| 2150 | [Field{1},VelType_out]=read_civxdata(filename,InputField,VelType);
|
---|
| 2151 | if isfield(Field{1},'Txt')
|
---|
[59] | 2152 | errormsg=Field{1}.Txt;
|
---|
[2] | 2153 | return
|
---|
| 2154 | end
|
---|
| 2155 | CivStage=Field{1}.CivStage;
|
---|
| 2156 | UvData.NbDim=Field{1}.nb_dim;
|
---|
| 2157 | end
|
---|
| 2158 | end
|
---|
[59] | 2159 | if ~isempty(filename_1) && ~test_keepdata_1 && isequal(FileType_1,'netcdf') %read the second file
|
---|
[2] | 2160 | if isequal(FieldName_1,'get_field...')% read the field names on the interface get_field.
|
---|
| 2161 | hget_field=findobj(allchild(0),'Name','get_field_1');%find the get_field... GUI
|
---|
| 2162 | if isempty(hget_field)
|
---|
| 2163 | hget_field= get_field(filename_1);%open the get_field GUI
|
---|
| 2164 | set(hget_field,'name','get_field_1')
|
---|
| 2165 | % enable_transform(handles,'off')% no field transform (possible transform in the GUI get_field)
|
---|
| 2166 | end
|
---|
| 2167 | hhget_field=guidata(hget_field);%handles of GUI elements in get_field
|
---|
| 2168 | SubField=get_field('read_var_names',hObject,eventdata,hhget_field); %read the names of the variables to plot in the get_field GUI
|
---|
| 2169 | [Field{2},var_detect]=nc2struct(filename_1,SubField.ListVarName); %read the corresponding input data
|
---|
| 2170 | Field{2}.VarAttribute=SubField.VarAttribute;
|
---|
| 2171 | %update the display on get_field
|
---|
| 2172 | set(hhget_field.inputfile,'String',filename_1)
|
---|
| 2173 | set(hhget_field.variables,'Value',1)
|
---|
| 2174 | Tabchar={''};%default
|
---|
| 2175 | Tabcell=[];
|
---|
| 2176 | if isfield(Field{2},'ListGlobalAttribute')& ~isempty(Field{2}.ListGlobalAttribute)
|
---|
| 2177 | for iline=1:length(Field{2}.ListGlobalAttribute)
|
---|
| 2178 | Tabcell{iline,1}=Field{2}.ListGlobalAttribute{iline};
|
---|
| 2179 | if isfield(Field{2}, Field{2}.ListGlobalAttribute{iline})
|
---|
| 2180 | eval(['val=Field{2}.' Field{2}.ListGlobalAttribute{iline} ';'])
|
---|
| 2181 | if ischar(val);
|
---|
| 2182 | Tabcell{iline,2}=val;
|
---|
| 2183 | else
|
---|
| 2184 | Tabcell{iline,2}=num2str(val);
|
---|
| 2185 | end
|
---|
| 2186 | end
|
---|
| 2187 | end
|
---|
| 2188 | if ~isempty(Tabcell)
|
---|
| 2189 | Tabchar=cell2tab(Tabcell,'=');
|
---|
| 2190 | Tabchar=[{''};Tabchar];
|
---|
| 2191 | end
|
---|
| 2192 | end
|
---|
| 2193 | set(hhget_field.attributes,'String',Tabchar);%update list of global attributes in get_field
|
---|
| 2194 | else
|
---|
| 2195 | [Field{2},VelType_out_1]=read_civxdata(filename_1,[],VelType_1);
|
---|
| 2196 | CivStage_1=Field{2}.CivStage;
|
---|
| 2197 | end
|
---|
[45] | 2198 | if ~isequal(FileType,'netcdf')
|
---|
[2] | 2199 | VelType_out=VelType_out_1;
|
---|
| 2200 | end
|
---|
| 2201 | end
|
---|
| 2202 | end
|
---|
| 2203 |
|
---|
[59] | 2204 | %store the second field for possible latter use
|
---|
| 2205 | if numel(Field)==2
|
---|
| 2206 | UvData.Field_1=Field{2};
|
---|
| 2207 | end
|
---|
| 2208 |
|
---|
[2] | 2209 | %update the display buttons for the first velocity type (first menuline)
|
---|
| 2210 | veltype_handles=[handles.civ1 handles.interp1 handles.filter1 handles.civ2 handles.interp2 handles.filter2];
|
---|
[45] | 2211 | if ~isequal(FileType,'netcdf')
|
---|
[2] | 2212 | reset_vel_type(veltype_handles)
|
---|
[59] | 2213 | elseif isempty(VelType) && ~isequal(FieldName,'get_field...')
|
---|
[2] | 2214 | set_veltype_display(veltype_handles,CivStage)%update the display of available velocity types for the first field
|
---|
| 2215 | if isempty(VelType_out)
|
---|
| 2216 | reset_vel_type(veltype_handles)
|
---|
| 2217 | else
|
---|
| 2218 | handle1=eval(['handles.' VelType_out]);
|
---|
| 2219 | reset_vel_type(veltype_handles,handle1)
|
---|
| 2220 | end
|
---|
| 2221 | end
|
---|
| 2222 |
|
---|
| 2223 | %update the display buttons for the second velocity type (second menuline)
|
---|
| 2224 | veltype_handles_1=[handles.civ1_1 handles.interp1_1 handles.filter1_1 handles.civ2_1 handles.interp2_1 handles.filter2_1];
|
---|
[45] | 2225 | if ~isequal(FileType_1,'netcdf')
|
---|
[2] | 2226 | reset_vel_type(veltype_handles_1)
|
---|
[59] | 2227 | elseif isempty(VelType_1) && ~isequal(FieldName_1,'get_field...')
|
---|
[2] | 2228 | set_veltype_display(veltype_handles_1,CivStage_1)%update the display of available velocity types for the first field
|
---|
| 2229 | if isempty(VelType_out_1)
|
---|
| 2230 | reset_vel_type(veltype_handles_1)
|
---|
| 2231 | else
|
---|
| 2232 | handle1=eval(['handles.' VelType_out_1 '_1']);
|
---|
| 2233 | reset_vel_type(veltype_handles_1,handle1)
|
---|
| 2234 | end
|
---|
| 2235 | end
|
---|
| 2236 |
|
---|
| 2237 | %introduce w as background image by default for a new series (only for nbdim=2)
|
---|
| 2238 | if ~isfield(UvData,'NewSeries')
|
---|
| 2239 | UvData.NewSeries=1;
|
---|
| 2240 | end
|
---|
| 2241 | %put W as background image by default if NbDim=2:
|
---|
[45] | 2242 | if ~isfield(UvData,'NbDim')||isempty(UvData.NbDim)||~isequal(UvData.NbDim,3)
|
---|
[2] | 2243 | if UvData.NewSeries && isequal(get(handles.SubField,'Value'),0) && isfield(Field{1},'W') && ~isempty(Field{1}.W);
|
---|
| 2244 | set(handles.SubField,'Value',1);
|
---|
[45] | 2245 | %menu=update_menu(handles.Fields_1,'w');%update the menu for the background scalar nd set the choice to 'w'
|
---|
[2] | 2246 | set(handles.RootPath_1,'String','"')
|
---|
| 2247 | set(handles.RootFile_1,'String','"')
|
---|
| 2248 | set(handles.SubDir_1,'String','"');
|
---|
| 2249 | [indices]=name_generator('',num_i1,num_j1,'',NomType,1,num_i2,num_j2,'');
|
---|
| 2250 | set(handles.FileIndex_1,'String',indices)
|
---|
| 2251 | set(handles.FileExt_1,'String','"');
|
---|
| 2252 | set(handles.Fields_1,'Visible','on');
|
---|
| 2253 | set(handles.Fields_1,'Visible','on');
|
---|
| 2254 | set(handles.RootPath_1,'Visible','on')
|
---|
| 2255 | set(handles.RootFile_1,'Visible','on')
|
---|
| 2256 | set(handles.SubDir_1,'Visible','on');
|
---|
| 2257 | set(handles.FileIndex_1,'Visible','on');
|
---|
| 2258 | set(handles.FileExt_1,'Visible','on');
|
---|
| 2259 | set(handles.Fields_1,'Visible','on');
|
---|
| 2260 | Field{1}.AName='w';
|
---|
| 2261 | testscal=1;
|
---|
| 2262 | end
|
---|
| 2263 | end
|
---|
| 2264 |
|
---|
| 2265 | %multislice case
|
---|
[59] | 2266 | if ~isempty(filename) &&(~isfield(UvData,'NbDim') || isequal(UvData.NbDim,2))&&...%2D case
|
---|
[2] | 2267 | isfield(UvData,'XmlData') && isfield(UvData.XmlData,'GeometryCalib')&& isfield(UvData.XmlData.GeometryCalib,'SliceCoord')
|
---|
| 2268 | siz=size(UvData.XmlData.GeometryCalib.SliceCoord);
|
---|
| 2269 | if siz(1)>1
|
---|
| 2270 | NbSlice=siz(1);
|
---|
[60] | 2271 | % set(handles.slices,'Visible','on')
|
---|
| 2272 | % set(handles.slices,'Value',1)
|
---|
[2] | 2273 | else
|
---|
| 2274 | NbSlice=1;
|
---|
| 2275 | end
|
---|
[60] | 2276 | %set(handles.nb_slice,'String',num2str(NbSlice))
|
---|
| 2277 | % slices_Callback(handles.uvmat, [], handles)
|
---|
[2] | 2278 | end
|
---|
| 2279 |
|
---|
| 2280 | %store the current open names, fields and vel types in uvmat interface
|
---|
| 2281 | UvData.filename=filename;
|
---|
| 2282 | UvData.filename_1=filename_1;
|
---|
| 2283 | UvData.VelType=VelType;
|
---|
| 2284 | UvData.VelType_1=VelType_1;
|
---|
| 2285 | UvData.FieldName=FieldName;
|
---|
| 2286 | UvData.FieldName_1=FieldName_1;
|
---|
| 2287 | if ~isempty(scal_color)
|
---|
| 2288 | UvData.CName=scal_color;
|
---|
| 2289 | end
|
---|
| 2290 |
|
---|
| 2291 | %coordinate transform or user fct
|
---|
| 2292 | XmlData=[];%default
|
---|
| 2293 | if isfield(UvData,'XmlData')%use geometry calib recorded from the ImaDoc xml file as first priority
|
---|
| 2294 | XmlData=UvData.XmlData;
|
---|
| 2295 | end
|
---|
| 2296 | XmlData_1=[];%default
|
---|
| 2297 | if isfield(UvData,'XmlData_1')
|
---|
| 2298 | XmlData_1=UvData.XmlData_1;
|
---|
| 2299 | end
|
---|
[39] | 2300 | menu_transform=get(handles.transform_fct,'String');
|
---|
| 2301 | choice_value=get(handles.transform_fct,'Value');
|
---|
| 2302 | transform_list=get(handles.transform_fct,'UserData');
|
---|
| 2303 | transform=transform_list{choice_value};%selected function handles
|
---|
[2] | 2304 |
|
---|
| 2305 | % z index
|
---|
[59] | 2306 | if ~isempty(filename)
|
---|
[60] | 2307 | Field{1}.ZIndex=z_index;
|
---|
[2] | 2308 | end
|
---|
[59] | 2309 |
|
---|
[2] | 2310 | %px to phys or other transform on field
|
---|
[59] | 2311 | if ~isempty(transform)
|
---|
[2] | 2312 | if length(Field)>=2
|
---|
[60] | 2313 | Field{2}.ZIndex=z_index;
|
---|
[38] | 2314 | [Field{1},Field{2}]=transform(Field{1},XmlData,Field{2},XmlData_1);
|
---|
[2] | 2315 | if isempty(Field{2})
|
---|
| 2316 | Field(2)=[];
|
---|
| 2317 | end
|
---|
| 2318 | else
|
---|
[38] | 2319 | Field{1}=transform(Field{1},XmlData);
|
---|
[2] | 2320 | end
|
---|
| 2321 | end
|
---|
| 2322 |
|
---|
| 2323 | %calculate scalar
|
---|
[45] | 2324 | if isequal(FileType,'netcdf') && ~isequal(FieldName,'get_field...')%
|
---|
[2] | 2325 | Field{1}=calc_field(InputField,Field{1});
|
---|
| 2326 | end
|
---|
[59] | 2327 | if length(Field)==2 && ~test_keepdata_1 && isequal(FileType_1,'netcdf') && ~isequal(FieldName_1,'get_field...')
|
---|
[2] | 2328 | Field{2}=calc_field(InputField_1,Field{2});
|
---|
| 2329 | end
|
---|
| 2330 |
|
---|
| 2331 | % combine the two input fields (e.g. substract velocity fields)
|
---|
| 2332 | if numel(Field)==2
|
---|
[59] | 2333 | UvData.Field=sub_field(Field{1},Field{2}); %TO UPDATE FOR MORE GENERAL INPUT
|
---|
[2] | 2334 | else
|
---|
| 2335 | UvData.Field=Field{1};
|
---|
| 2336 | end
|
---|
[59] | 2337 |
|
---|
[2] | 2338 | UvData.NewSeries=0;% put to 0 the test for a new field series (set by RootPath_callback)
|
---|
| 2339 | % test 3D , default projection menuplane and typical mesh (needed to menuopen set_object)
|
---|
| 2340 | test_x=0;
|
---|
| 2341 | test_z=0;% test for unstructured z coordinate
|
---|
| 2342 | UvData.ZMax=0;
|
---|
| 2343 | UvData.ZMin=0;%default
|
---|
| 2344 | UvData.Mesh=1; %default
|
---|
| 2345 | [UvData.Field,errormsg]=check_field_structure(UvData.Field);
|
---|
| 2346 | if ~isempty(errormsg)
|
---|
[59] | 2347 | errormsg=['error in uvmat/run0_Callback/check_field_structure: ' errormsg];
|
---|
[2] | 2348 | return
|
---|
| 2349 | end
|
---|
| 2350 | [CellVarIndex,NbDim,VarType]=find_field_indices(UvData.Field);
|
---|
| 2351 | [NbDim,imax]=max(NbDim);
|
---|
| 2352 | if isempty(imax)
|
---|
[45] | 2353 | % DimVarIndex=0;
|
---|
[2] | 2354 | coord_x=[];
|
---|
| 2355 | else
|
---|
[45] | 2356 | % VarIndex=CellVarIndex{imax};
|
---|
[2] | 2357 | coord_x=VarType{imax}.coord_x;
|
---|
| 2358 | end
|
---|
[45] | 2359 | if isfield(UvData,'NbDim') && ~isempty(UvData.NbDim)
|
---|
[2] | 2360 | NbDim=UvData.NbDim;
|
---|
| 2361 | else
|
---|
| 2362 | UvData.NbDim=NbDim;
|
---|
| 2363 | end
|
---|
[45] | 2364 | if ~isempty(CellVarIndex) && ~isempty(VarType{imax}.coord_x) && ~isempty(VarType{imax}.coord_y) %unstructured coordinate z
|
---|
[2] | 2365 | XName=UvData.Field.ListVarName{VarType{imax}.coord_x};
|
---|
| 2366 | YName=UvData.Field.ListVarName{VarType{imax}.coord_y};
|
---|
| 2367 | test_x=1;
|
---|
[45] | 2368 | elseif isfield(UvData.Field,'X') && isfield(UvData.Field,'Y')
|
---|
[2] | 2369 | XName='X';
|
---|
| 2370 | YName='Y';
|
---|
| 2371 | test_x=1;
|
---|
| 2372 | end
|
---|
| 2373 | if test_x
|
---|
| 2374 | eval(['UvData.XMax=max(UvData.Field.' XName ');'])
|
---|
| 2375 | eval(['UvData.XMin=min(UvData.Field.' XName ');'])
|
---|
| 2376 | eval(['UvData.YMax=max(UvData.Field.' YName ');'])
|
---|
| 2377 | eval(['UvData.YMin=min(UvData.Field.' YName ');'])
|
---|
| 2378 | eval(['nbvec=length(UvData.Field.' XName ');'])
|
---|
| 2379 | if NbDim==3%
|
---|
[45] | 2380 | if ~isempty(CellVarIndex) && ~isempty(VarType{imax}.coord_z)%unstructured coordinate z
|
---|
[42] | 2381 | ZName=UvData.Field.ListVarName{VarType{imax}.coord_z};
|
---|
[2] | 2382 | eval(['UvData.ZMax=max(UvData.Field.' ZName ');'])
|
---|
| 2383 | eval(['UvData.ZMin=min(UvData.Field.' ZName ');'])
|
---|
| 2384 | test_z=1;
|
---|
| 2385 | elseif isfield(UvData,'Z')% usual civ data
|
---|
| 2386 | UvData.ZMax=max(UvData.Z);
|
---|
| 2387 | UvData.ZMin=min(UvData.Z);
|
---|
| 2388 | test_z=1;
|
---|
| 2389 | end
|
---|
| 2390 | end
|
---|
| 2391 | if isequal(UvData.ZMin,UvData.ZMax)%no z dependency
|
---|
| 2392 | NbDim=2;
|
---|
| 2393 | test_z=0;
|
---|
| 2394 | end
|
---|
| 2395 | if test_z
|
---|
| 2396 | UvData.Mesh=((UvData.XMax-UvData.XMin)*(UvData.YMax-UvData.YMin)*(UvData.ZMax-UvData.ZMin))/nbvec;% volume per vector
|
---|
| 2397 | UvData.Mesh=(UvData.Mesh)^(1/3);
|
---|
| 2398 | else
|
---|
| 2399 | UvData.Mesh=sqrt((UvData.XMax-UvData.XMin)*(UvData.YMax-UvData.YMin)/nbvec);%2D
|
---|
| 2400 | end
|
---|
| 2401 | end
|
---|
| 2402 | %case of structured coordinates
|
---|
| 2403 | if isfield(UvData.Field,'AX') & isfield(UvData.Field,'AY')& isfield(UvData.Field,'A')
|
---|
| 2404 | UvData.XMax=max(UvData.Field.AX);
|
---|
| 2405 | UvData.XMin=min(UvData.Field.AX);
|
---|
| 2406 | UvData.YMax=max(UvData.Field.AY);
|
---|
| 2407 | UvData.YMin=min(UvData.Field.AY);
|
---|
| 2408 | np_A=size(UvData.Field.A);
|
---|
| 2409 | UvData.Mesh=sqrt((UvData.XMax-UvData.XMin)*(UvData.YMax-UvData.YMin)/((np_A(1)-1) * (np_A(2)-1))) ;
|
---|
| 2410 | end
|
---|
| 2411 | if isempty(coord_x)&~isempty(CellVarIndex)
|
---|
| 2412 | VarIndex=CellVarIndex{imax}; % list of variable indices
|
---|
| 2413 | DimIndex=UvData.Field.VarDimIndex{VarIndex(1)}; %list of dim indices for the variable
|
---|
| 2414 | if NbDim==3
|
---|
| 2415 | nbpoints=UvData.Field.DimValue(DimIndex(1));
|
---|
| 2416 | %Zvar=DimVarIndex(DimIndex(1));
|
---|
| 2417 | %Zvar=DimVarIndex(1);
|
---|
[72] | 2418 | % Zvar=VarType{imax}.coord_3;
|
---|
| 2419 | if isfield(VarType{imax},'coord_3')&& ~isequal(VarType{imax}.coord_3,0) % z is a dimension variable
|
---|
| 2420 | ZName=UvData.Field.ListVarName{VarType{imax}.coord_3}
|
---|
[2] | 2421 | eval(['UvData.ZMax=max(UvData.Field.' ZName ');'])
|
---|
| 2422 | eval(['UvData.ZMin=min(UvData.Field.' ZName ');'])
|
---|
| 2423 | else
|
---|
| 2424 | testcoord_z=0;
|
---|
| 2425 | if length(UvData.Field.VarAttribute)>=VarIndex(1)
|
---|
| 2426 | if isfield(UvData.Field.VarAttribute{VarIndex(1)},'Coord_1')%regular grid
|
---|
| 2427 | Coord_z=UvData.Field.VarAttribute{VarIndex(1)}.Coord_1;
|
---|
| 2428 | UvData.ZMax=max(Coord_z);
|
---|
| 2429 | UvData.ZMin=min(Coord_z);
|
---|
| 2430 | testcoord_z=1;
|
---|
| 2431 | end
|
---|
| 2432 | end
|
---|
| 2433 | if ~testcoord_z
|
---|
| 2434 | UvData.ZMin=1;
|
---|
| 2435 | UvData.ZMax=UvData.Field.DimValue(DimIndex(1));
|
---|
| 2436 | end
|
---|
| 2437 | end
|
---|
| 2438 | UvData.Mesh=(UvData.ZMax-UvData.ZMin)/(nbpoints-1);
|
---|
| 2439 | elseif NbDim==2
|
---|
| 2440 | nbpoints_y=UvData.Field.DimValue(DimIndex(1));
|
---|
| 2441 | Yvar=VarType{imax}.coord_y;
|
---|
| 2442 | if Yvar~=0 % x is a dimension variable
|
---|
| 2443 | YName=UvData.Field.ListVarName{Yvar};
|
---|
| 2444 | eval(['UvData.YMax=max(UvData.Field.' YName ');'])
|
---|
| 2445 | eval(['UvData.YMin=min(UvData.Field.' YName ');'])
|
---|
| 2446 | else
|
---|
| 2447 | testcoord_y=0;
|
---|
| 2448 | if ~testcoord_y
|
---|
| 2449 | UvData.YMin=1;
|
---|
| 2450 | UvData.YMax=UvData.Field.DimValue(DimIndex(1));
|
---|
| 2451 | end
|
---|
| 2452 | end
|
---|
| 2453 | DY=(UvData.YMax-UvData.YMin)/(nbpoints_y-1);
|
---|
| 2454 | nbpoints_x=UvData.Field.DimValue(DimIndex(2));
|
---|
| 2455 | Xvar=VarType{imax}.coord_x;
|
---|
| 2456 | if Xvar~=0 % x is a dimension variable
|
---|
| 2457 | XName=UvData.Field.ListVarName{Xvar};
|
---|
| 2458 | eval(['UvData.XMax=max(UvData.Field.' XName ');'])
|
---|
| 2459 | eval(['UvData.XMin=min(UvData.Field.' XName ');'])
|
---|
| 2460 | else
|
---|
| 2461 | testcoord_x=0;
|
---|
| 2462 | if ~testcoord_x
|
---|
| 2463 | UvData.XMin=1;
|
---|
| 2464 | UvData.XMax=UvData.Field.DimValue(DimIndex(2));
|
---|
| 2465 | end
|
---|
| 2466 | end
|
---|
| 2467 | DX=(UvData.XMax-UvData.XMin)/(nbpoints_x-1);
|
---|
| 2468 | UvData.Mesh= sqrt(DX*DY);
|
---|
| 2469 | end
|
---|
| 2470 | end
|
---|
| 2471 |
|
---|
| 2472 | %create a default projection menuplane
|
---|
| 2473 | UvData.Object{1}.Style='plane';%main plotting plane
|
---|
| 2474 | UvData.Object{1}.ProjMode='projection';%main plotting plane
|
---|
| 2475 | if ~isfield(UvData.Object{1},'plotaxes')
|
---|
| 2476 | UvData.Object{1}.plotaxes=handles.axes3;%default plotting axis
|
---|
[61] | 2477 | set(handles.list_object_1,'Value',1);
|
---|
[71] | 2478 | set(handles.list_object_1,'String',{'1-PLANE'});
|
---|
[2] | 2479 | end
|
---|
| 2480 |
|
---|
| 2481 | %3D case (menuvolume)
|
---|
| 2482 | if NbDim==3
|
---|
| 2483 | UvData.Object{1}.NbDim=UvData.NbDim;%test for 3D objects
|
---|
| 2484 | UvData.Object{1}.RangeZ=UvData.Mesh;%main plotting plane
|
---|
| 2485 | UvData.Object{1}.Coord(1,3)=(UvData.ZMin+UvData.ZMax)/2;%section at a middle plane chosen
|
---|
| 2486 | UvData.Object{1}.Phi=0;
|
---|
| 2487 | UvData.Object{1}.Theta=0;
|
---|
| 2488 | UvData.Object{1}.Psi=0;
|
---|
| 2489 | UvData.Object{1}.HandlesDisplay=plot(0,0,'Tag','proj_object');% A REVOIR
|
---|
| 2490 | PlotHandles=get_plot_handles(handles);
|
---|
| 2491 | ZBounds(1)=UvData.ZMin; %minimum for the Z slider
|
---|
| 2492 | ZBounds(2)=UvData.ZMax;%maximum for the Z slider
|
---|
[72] | 2493 | UvData.Object{1}.Name='1-PLANE';
|
---|
| 2494 | UvData.Object{1}.enable_plot=1;
|
---|
[2] | 2495 | set_object(UvData.Object{1},PlotHandles,ZBounds);
|
---|
[61] | 2496 | set(handles.list_object_1,'Value',1);
|
---|
[2] | 2497 | %multilevel case (single menuplane in a 3D space)
|
---|
| 2498 | elseif isfield(UvData,'Z')
|
---|
| 2499 | if isfield(UvData,'CoordType')& isequal(UvData.CoordType,'phys') & isfield(UvData,'XmlData')
|
---|
| 2500 | XmlData=UvData.XmlData;
|
---|
| 2501 | if isfield(XmlData,'PlanePos')
|
---|
| 2502 | UvData.Object{1}.Coord=XmlData.PlanePos(UvData.ZIndex,:);
|
---|
| 2503 | end
|
---|
| 2504 | if isfield(XmlData,'PlaneAngle')
|
---|
| 2505 | siz=size(XmlData.PlaneAngle);
|
---|
| 2506 | indangle=min(siz(1),UvData.ZIndex);%take first angle if a single angle is defined (translating scanning)
|
---|
| 2507 | UvData.Object{1}.Phi=XmlData.PlaneAngle(indangle,1);
|
---|
| 2508 | UvData.Object{1}.Theta=XmlData.PlaneAngle(indangle,2);
|
---|
| 2509 | UvData.Object{1}.Psi=XmlData.PlaneAngle(indangle,3);
|
---|
| 2510 | end
|
---|
| 2511 | elseif isfield(UvData,'ZIndex')
|
---|
| 2512 | UvData.Object{1}.ZObject=UvData.ZIndex;
|
---|
| 2513 | end
|
---|
| 2514 | end
|
---|
| 2515 |
|
---|
| 2516 | %Plot the projections on all existing projection objects
|
---|
| 2517 | keeplim=get(handles.FixedLimits,'Value');
|
---|
| 2518 | %reset the min and max of scalar if only the mask is displayed
|
---|
| 2519 | if isfield(UvData,'Mask')&~isfield(UvData,'A')
|
---|
| 2520 | set(handles.MinA,'String','0')
|
---|
| 2521 | set(handles.MaxA,'String','255')
|
---|
| 2522 | end
|
---|
[65] | 2523 | IndexObj(1)=get(handles.list_object_1,'Value');
|
---|
| 2524 | if IndexObj(1)> numel(UvData.Object)
|
---|
| 2525 | IndexObj(1)=1;
|
---|
| 2526 | end
|
---|
| 2527 | IndexObj_2=get(handles.list_object_2,'Value');
|
---|
| 2528 | if IndexObj_2 <= numel(UvData.Object)
|
---|
| 2529 | IndexObj(2)=IndexObj_2;
|
---|
| 2530 | end
|
---|
[71] | 2531 | for imap=1:numel(IndexObj)
|
---|
| 2532 | iobj=IndexObj(imap);
|
---|
[65] | 2533 | if ~isempty(UvData.Object{iobj})%& isfield(Object{iobj},'plotaxes')& ishandle(Object{iobj}.plotaxes)
|
---|
[2] | 2534 | %Projeter les champs sur l'objet:*
|
---|
[65] | 2535 | ObjectData=proj_field(UvData.Field,UvData.Object{iobj},iobj);
|
---|
[71] | 2536 | if imap==2
|
---|
| 2537 | UvData.ProjField_2=ObjectData;%store the projection field on uvmat: ***** WILL REPLACE THE FIELD SORED ON THE AXES: AxeData *****
|
---|
| 2538 | else
|
---|
| 2539 | UvData.ProjField_1=ObjectData;%store the projection field on view_field
|
---|
| 2540 | end
|
---|
[2] | 2541 | %use of mask
|
---|
| 2542 | if isfield(ObjectData,'NbDim')&isequal(ObjectData.NbDim,2)
|
---|
| 2543 | if isfield(ObjectData,'Mask') & isfield(ObjectData,'A')
|
---|
| 2544 | flag_mask=double(ObjectData.Mask>200);%=0 for masked regions
|
---|
| 2545 | AX=ObjectData.AX;
|
---|
| 2546 | AY=ObjectData.AY;
|
---|
| 2547 | MaskX=ObjectData.MaskX;
|
---|
| 2548 | MaskY=ObjectData.MaskY;
|
---|
| 2549 | if ~isequal(MaskX,AX)|~isequal(MaskY,AY)
|
---|
| 2550 | nxy=size(flag_mask);
|
---|
| 2551 | sizpx=(ObjectData.MaskX(end)-ObjectData.MaskX(1))/(nxy(2)-1);%size of a mask pixel
|
---|
| 2552 | sizpy=(ObjectData.MaskY(1)-ObjectData.MaskY(end))/(nxy(1)-1);
|
---|
| 2553 | x_mask=[ObjectData.MaskX(1):sizpx:ObjectData.MaskX(end)]; % pixel x coordinates for image display
|
---|
| 2554 | y_mask=[ObjectData.MaskY(1):-sizpy:ObjectData.MaskY(end)];% pixel x coordinates for image display
|
---|
| 2555 | %project on the positions of the scalar
|
---|
| 2556 | npxy=size(ObjectData.A);
|
---|
| 2557 | dxy(1)=(ObjectData.AY(end)-ObjectData.AY(1))/(npxy(1)-1);%grid mesh in y
|
---|
| 2558 | dxy(2)=(ObjectData.AX(end)-ObjectData.AX(1))/(npxy(2)-1);%grid mesh in x
|
---|
| 2559 | xi=[ObjectData.AX(1):dxy(2):ObjectData.AX(end)];
|
---|
| 2560 | yi=[ObjectData.AY(1):dxy(1):ObjectData.AY(end)];
|
---|
| 2561 | [XI,YI]=meshgrid(xi,yi);% creates the matrix of regular coordinates
|
---|
| 2562 | flag_mask = interp2(x_mask,y_mask,flag_mask,XI,YI);
|
---|
| 2563 | end
|
---|
| 2564 | AClass=class(ObjectData.A);
|
---|
| 2565 | ObjectData.A=flag_mask.*double(ObjectData.A);
|
---|
| 2566 | ObjectData.A=feval(AClass,ObjectData.A);
|
---|
| 2567 | ind_off=[];
|
---|
| 2568 | if isfield(ObjectData,'ListVarName')
|
---|
| 2569 | for ilist=1:length(ObjectData.ListVarName)
|
---|
| 2570 | if isequal(ObjectData.ListVarName{ilist},'Mask')|isequal(ObjectData.ListVarName{ilist},'MaskX')|isequal(ObjectData.ListVarName{ilist},'MaskY')
|
---|
| 2571 | ind_off=[ind_off ilist];
|
---|
| 2572 | end
|
---|
| 2573 | end
|
---|
| 2574 | ObjectData.ListVarName(ind_off)=[];
|
---|
| 2575 | ObjectData.VarDimIndex(ind_off)=[];
|
---|
| 2576 | ind_off=[];
|
---|
| 2577 | for ilist=1:length(ObjectData.ListDimName)
|
---|
| 2578 | if isequal(ObjectData.ListDimName{ilist},'MaskX')|isequal(ObjectData.ListDimName{ilist},'MaskY')
|
---|
| 2579 | ind_off=[ind_off ilist];
|
---|
| 2580 | end
|
---|
| 2581 | end
|
---|
| 2582 | ObjectData.ListDimName(ind_off)=[];
|
---|
| 2583 | ObjectData.DimValue(ind_off)=[];
|
---|
| 2584 | end
|
---|
| 2585 | end
|
---|
| 2586 | end
|
---|
| 2587 | if ~isempty(ObjectData)
|
---|
| 2588 | haxes=[];%default
|
---|
[65] | 2589 | if isfield(UvData.Object{iobj},'plotaxes')
|
---|
| 2590 | haxes=UvData.Object{iobj}.plotaxes;%axes used for representing the projection on the object
|
---|
[2] | 2591 | end
|
---|
| 2592 | PosColorbar=[];%default: no colorbar
|
---|
| 2593 | if ishandle(haxes) & isequal(get(haxes,'Tag'),'axes3')& isfield(UvData,'PosColorbar')
|
---|
| 2594 | PosColorbar=UvData.PosColorbar;%prescribe the colorbar position on the uvmat interface
|
---|
| 2595 | else
|
---|
| 2596 | PosColorbar='*';%default position
|
---|
| 2597 | end
|
---|
| 2598 | PlotParam=read_plot_param(handles);%read plotting parameters on the uvmat interface
|
---|
| 2599 | [PlotType,ScalOut,UvData.Object{iobj}.plotaxes]=plot_field(ObjectData,haxes,PlotParam,keeplim,PosColorbar);
|
---|
| 2600 | if isequal(PlotType,'none')
|
---|
| 2601 | hget_field=findobj(allchild(0),'name','get_field');
|
---|
| 2602 | if isempty(hget_field)
|
---|
| 2603 | get_field([],ObjectData)% the projected field cannot be automatically plotted: use get_field to specify the variablesdelete(hget_field)
|
---|
| 2604 | else
|
---|
[59] | 2605 | errormsg='The field defined by get_field cannot be plotted';
|
---|
| 2606 | return
|
---|
[2] | 2607 | end
|
---|
| 2608 | end
|
---|
| 2609 | UvData.Object{iobj}.PlotParam=ScalOut; %record the plotting parameters
|
---|
[59] | 2610 | end
|
---|
[2] | 2611 | end
|
---|
| 2612 | end
|
---|
| 2613 |
|
---|
| 2614 | %display the updated plotting parameters for the base menuplane
|
---|
| 2615 | write_plot_param(handles,UvData.Object{1}.PlotParam);% update the display of the plotting parameters
|
---|
[45] | 2616 | set(handles.uvmat,'UserData',UvData)
|
---|
[2] | 2617 |
|
---|
| 2618 | %update the mask
|
---|
| 2619 | if isequal(get(handles.mask_test,'Value'),1)%if the mask option is on
|
---|
| 2620 | update_mask(handles,num_i1,num_i2);
|
---|
| 2621 | end
|
---|
| 2622 |
|
---|
| 2623 | %prepare the menus of histograms (for the whole menuvolume in 3D case)
|
---|
| 2624 | menu_histo=(UvData.Field.ListVarName)';
|
---|
| 2625 | ind_bad=[];
|
---|
| 2626 | nb_histo=1;
|
---|
| 2627 | for ivar=1:numel(menu_histo)
|
---|
| 2628 | if isfield(UvData.Field,'VarAttribute') && numel(UvData.Field.VarAttribute)>=ivar && isfield(UvData.Field.VarAttribute{ivar},'Role')
|
---|
| 2629 | Role=UvData.Field.VarAttribute{ivar}.Role;
|
---|
| 2630 | switch Role
|
---|
| 2631 | case {'coord_x','coord_y','coord_z','dimvar'}
|
---|
| 2632 | ind_bad=[ind_bad ivar];
|
---|
| 2633 | case {'vector_y'}
|
---|
| 2634 | nb_histo=nb_histo+1;
|
---|
| 2635 | end
|
---|
| 2636 | end
|
---|
| 2637 | DimCell=UvData.Field.VarDimName{ivar};
|
---|
| 2638 | DimName='';
|
---|
| 2639 | if ischar(DimCell)
|
---|
| 2640 | DimName=DimCell;
|
---|
| 2641 | elseif iscell(DimCell)&& numel(DimCell)==1
|
---|
| 2642 | DimName=DimCell{1};
|
---|
| 2643 | end
|
---|
| 2644 | if strcmp(DimName,menu_histo{ivar})
|
---|
| 2645 | ind_bad=[ind_bad ivar];
|
---|
| 2646 | end
|
---|
| 2647 | end
|
---|
| 2648 | menu_histo(ind_bad)=[];
|
---|
| 2649 | test_v=0;
|
---|
| 2650 | if ~isempty(menu_histo)
|
---|
| 2651 | set(handles.histo1_menu,'Value',1)
|
---|
| 2652 | set(handles.histo1_menu,'String',menu_histo)
|
---|
[59] | 2653 | histo1_menu_Callback(handles.histo1_menu, [], handles)
|
---|
[2] | 2654 | if nb_histo > 1
|
---|
| 2655 | test_v=1;
|
---|
| 2656 | set(handles.histo2_menu,'Visible','on')
|
---|
| 2657 | set(handles.histo_v,'Visible','on')
|
---|
| 2658 | set(handles.histo2_menu,'String',menu_histo)
|
---|
| 2659 | set(handles.histo2_menu,'Value',2)
|
---|
[59] | 2660 | histo2_menu_Callback(handles.histo2_menu,[], handles)
|
---|
[2] | 2661 | end
|
---|
| 2662 | end
|
---|
| 2663 | if ~test_v
|
---|
| 2664 | set(handles.histo2_menu,'Visible','off')
|
---|
| 2665 | set(handles.histo_v,'Visible','off')
|
---|
| 2666 | cla(handles.histo_v)
|
---|
| 2667 | set(handles.histo2_menu,'Value',1)
|
---|
| 2668 | end
|
---|
| 2669 |
|
---|
| 2670 | %display time
|
---|
| 2671 | testimedoc=0;
|
---|
| 2672 | if isfield(UvData,'XmlData') && isfield(UvData.XmlData,'Time')
|
---|
| 2673 | if isempty(num_i2)
|
---|
| 2674 | num_i2=num_i1;
|
---|
| 2675 | end
|
---|
| 2676 | if isempty(num_j1)
|
---|
| 2677 | num_j1=1;
|
---|
| 2678 | end
|
---|
| 2679 | if isempty(num_j2)
|
---|
| 2680 | num_j2=num_j1;
|
---|
| 2681 | end
|
---|
| 2682 | siz=size(UvData.XmlData.Time);
|
---|
| 2683 | if siz(1)>=max(num_i1,num_i2) & siz(2)>=max(num_j1,num_j2)
|
---|
| 2684 | abstime=(UvData.XmlData.Time(num_i1,num_j1)+UvData.XmlData.Time(num_i2,num_j2))/2;%overset the time read from files
|
---|
| 2685 | dt=(UvData.XmlData.Time(num_i2,num_j2)-UvData.XmlData.Time(num_i1,num_j1));
|
---|
| 2686 | testimedoc=1;
|
---|
| 2687 | end
|
---|
| 2688 | end
|
---|
| 2689 | if isfield(UvData,'XmlData_1') && isfield(UvData.XmlData_1,'Time')
|
---|
| 2690 | [P,F,str1,str2,str_a,str_b,E,NomType]=name2display(['xx' get(handles.FileIndex_1,'String') get(handles.FileExt_1,'String')]);
|
---|
| 2691 | num_i2=str2num(str2);
|
---|
| 2692 | if isempty(num_i2)
|
---|
| 2693 | num_i2=num_i1;
|
---|
| 2694 | end
|
---|
| 2695 | num_j1=str2num(str_a);
|
---|
| 2696 | if isempty(num_j1)
|
---|
| 2697 | num_j1=1;
|
---|
| 2698 | end
|
---|
| 2699 | num_j2=str2num(str_b);
|
---|
| 2700 | if isempty(num_j2)
|
---|
| 2701 | num_j2=num_j1;
|
---|
| 2702 | end
|
---|
| 2703 | num_i1=str2num(str1);
|
---|
| 2704 | siz=size(UvData.XmlData_1.Time);
|
---|
| 2705 | if siz(1)>=max(num_i1,num_i2) & siz(2)>=max(num_j1,num_j2)
|
---|
| 2706 | 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
|
---|
| 2707 | end
|
---|
| 2708 | end
|
---|
| 2709 | set(handles.abs_time,'String',num2str(abstime,4))
|
---|
| 2710 | set(handles.abs_time_1,'String',num2str(abstime_1,4))
|
---|
| 2711 | if testimedoc && isfield(UvData,'dt')
|
---|
| 2712 | dt=UvData.dt;
|
---|
| 2713 | end
|
---|
| 2714 | if isequal(dt,0)
|
---|
| 2715 | set(handles.Dt_txt,'String','')
|
---|
| 2716 | else
|
---|
| 2717 | if ~(isfield(UvData,'TimeUnit') && ~isempty(UvData.TimeUnit))
|
---|
| 2718 | set(handles.Dt_txt,'String',['Dt=' num2str(1000*dt,3) ' 10^(-3)'] )
|
---|
| 2719 | else
|
---|
| 2720 | set(handles.Dt_txt,'String',['Dt=' num2str(1000*dt,3) ' m' UvData.TimeUnit] )
|
---|
| 2721 | end
|
---|
| 2722 | end
|
---|
| 2723 | set(handles.run0,'BackgroundColor',[1 0 0])
|
---|
| 2724 |
|
---|
| 2725 |
|
---|
| 2726 |
|
---|
| 2727 | %-------------------------------------------------------------------
|
---|
| 2728 | % --- translate coordinate to matrix index
|
---|
| 2729 | %-------------------------------------------------------------------
|
---|
| 2730 | function [indx,indy]=pos2ind(x0,rangx0,nxy)
|
---|
| 2731 | indx=1+round((nxy(2)-1)*(x0-rangx0(1))/(rangx0(2)-rangx0(1)));% index x of pixel
|
---|
| 2732 | indy=1+round((nxy(1)-1)*(y12-rangy0(1))/(rangy0(2)-rangy0(1)));% index y of pixel
|
---|
| 2733 |
|
---|
| 2734 | %-------------------------------------------------------------------
|
---|
| 2735 | % --- Executes on button press in 'FixedLimits'.
|
---|
| 2736 | %-------------------------------------------------------------------
|
---|
| 2737 | function FixedLimits_Callback(hObject, eventdata, handles)
|
---|
| 2738 | test=get(handles.FixedLimits,'Value');
|
---|
| 2739 | if test
|
---|
| 2740 | set(handles.FixedLimits,'BackgroundColor',[1 1 0])
|
---|
| 2741 | else
|
---|
| 2742 | set(handles.FixedLimits,'BackgroundColor',[0.7 0.7 0.7])
|
---|
| 2743 | end
|
---|
| 2744 |
|
---|
| 2745 | %-------------------------------------------------------------------
|
---|
| 2746 | % --- Executes on button press in auto_xy.
|
---|
| 2747 | function auto_xy_Callback(hObject, eventdata, handles)
|
---|
| 2748 | test=get(handles.auto_xy,'Value');
|
---|
| 2749 | if test
|
---|
| 2750 | set(handles.auto_xy,'BackgroundColor',[1 1 0])
|
---|
| 2751 | cla(handles.axes3)
|
---|
| 2752 | update_plot(handles)
|
---|
| 2753 | else
|
---|
| 2754 | set(handles.auto_xy,'BackgroundColor',[0.7 0.7 0.7])
|
---|
| 2755 | update_plot(handles)
|
---|
| 2756 | % axis(handles.axes3,'image')
|
---|
| 2757 | end
|
---|
| 2758 |
|
---|
| 2759 |
|
---|
| 2760 | %-------------------------------------------------------------------
|
---|
| 2761 |
|
---|
| 2762 | %-------------------------------------------------------------------
|
---|
| 2763 | % --- Executes on button press in 'zoom'.
|
---|
| 2764 | %-------------------------------------------------------------------
|
---|
| 2765 | function zoom_Callback(hObject, eventdata, handles)
|
---|
[60] | 2766 |
|
---|
[2] | 2767 | if (get(handles.zoom,'Value') == 1);
|
---|
| 2768 | set(handles.zoom,'BackgroundColor',[1 1 0])
|
---|
| 2769 | set(handles.FixedLimits,'Value',1)% propose by default fixed limits for the plotting axes
|
---|
[60] | 2770 | set(handles.FixedLimits,'BackgroundColor',[1 1 0])
|
---|
[2] | 2771 | else
|
---|
| 2772 | set(handles.zoom,'BackgroundColor',[0.7 0.7 0.7])
|
---|
| 2773 | end
|
---|
| 2774 |
|
---|
[60] | 2775 |
|
---|
[2] | 2776 | %-------------------------------------------------------------------
|
---|
| 2777 | %----Executes on button press in 'record': records the current flags of manual correction.
|
---|
| 2778 | %-------------------------------------------------------------------
|
---|
| 2779 | function record_Callback(hObject, eventdata, handles)
|
---|
| 2780 | % [filebase,num_i1,num_j1,num_i2,num_j2,Ext,NomType,SubDir]=read_input_file(handles);
|
---|
| 2781 | filename=read_file_boxes(handles);
|
---|
| 2782 | AxeData=get(gca,'UserData');
|
---|
| 2783 | [erread,message]=fileattrib(filename);
|
---|
[55] | 2784 | if ~isempty(message) && ~isequal(message.UserWrite,1)
|
---|
[2] | 2785 | msgbox_uvmat('ERROR',['no writting access to ' filename])
|
---|
| 2786 | return
|
---|
| 2787 | end
|
---|
| 2788 | test_civ2=isequal(get(handles.civ2,'BackgroundColor'),[1 1 0]);
|
---|
[55] | 2789 | test_civ1=isequal(get(handles.civ1,'BackgroundColor'),[1 1 0]);
|
---|
| 2790 | if ~test_civ2 && ~test_civ1
|
---|
| 2791 | msgbox_uvmat('ERROR','manual correction only possible for CIV1 or CIV2 velocity fields')
|
---|
[2] | 2792 | end
|
---|
[55] | 2793 | if test_civ2
|
---|
| 2794 | nbname='nb_vectors2';
|
---|
| 2795 | flagname='vec2_FixFlag';
|
---|
| 2796 | attrname='fix2';
|
---|
| 2797 | end
|
---|
| 2798 | if test_civ1
|
---|
| 2799 | nbname='nb_vectors';
|
---|
| 2800 | flagname='vec_FixFlag';
|
---|
| 2801 | attrname='fix';
|
---|
| 2802 | end
|
---|
| 2803 | %write fix flags in the netcdf file
|
---|
| 2804 | hhh=which('netcdf.open');% look for built-in matlab netcdf library
|
---|
| 2805 | if ~isequal(hhh,'')% case of new builtin Matlab netcdf library
|
---|
| 2806 | nc=netcdf.open(filename,'NC_WRITE');
|
---|
| 2807 | netcdf.reDef(nc)
|
---|
| 2808 | netcdf.putAtt(nc,netcdf.getConstant('NC_GLOBAL'),attrname,1)
|
---|
| 2809 | dimid = netcdf.inqDimID(nc,nbname);
|
---|
| 2810 | try
|
---|
| 2811 | varid = netcdf.inqVarID(nc,flagname);% look for already existing fixflag variable
|
---|
| 2812 | catch
|
---|
| 2813 | varid=netcdf.defVar(nc,flagname,'double',dimid);%create fixflag variable if it does not exist
|
---|
| 2814 | end
|
---|
| 2815 | netcdf.endDef(nc)
|
---|
| 2816 | netcdf.putVar(nc,varid,AxeData.FF);
|
---|
| 2817 | netcdf.close(nc)
|
---|
| 2818 | else %old netcdf library
|
---|
[56] | 2819 | netcdf_toolbox(filename,AxeData,attrname,nbname,flagname)
|
---|
[55] | 2820 | end
|
---|
[2] | 2821 |
|
---|
[56] | 2822 | function netcdf_toolbox(filename,AxeData,attrname,nbname,flagname)
|
---|
| 2823 | nc=netcdf(filename,'write'); %open netcdf file
|
---|
| 2824 | result=redef(nc);
|
---|
| 2825 | eval(['nc.' attrname '=1;']);
|
---|
| 2826 | theDim=nc(nbname) ;% get the number of velocity vectors
|
---|
| 2827 | nb_vectors=size(theDim);
|
---|
| 2828 | var_FixFlag=ncvar(flagname,nc);% var_FixFlag will be written as the netcdf variable vec_FixFlag
|
---|
| 2829 | var_FixFlag(1:nb_vectors)=AxeData.FF;%
|
---|
| 2830 | fin=close(nc);
|
---|
[2] | 2831 |
|
---|
| 2832 |
|
---|
| 2833 | %-------------------------------------------------------------------
|
---|
| 2834 | %determines the fields to read from the interface
|
---|
| 2835 | %------------------------------------------------------------------
|
---|
| 2836 | function [VelType,civ]=setfield(handles)
|
---|
| 2837 |
|
---|
| 2838 | VelType=[]; %default
|
---|
| 2839 | if (get(handles.civ1,'Value') == 1);
|
---|
| 2840 | VelType='civ1';
|
---|
| 2841 | % interp1
|
---|
| 2842 | elseif (get(handles.interp1,'Value') == 1);
|
---|
| 2843 | VelType='interp1';
|
---|
| 2844 | % filter1
|
---|
| 2845 | elseif (get(handles.filter1,'Value') == 1);
|
---|
| 2846 | VelType='filter1';
|
---|
| 2847 | % CIV2
|
---|
| 2848 | elseif (get(handles.civ2,'Value') == 1);
|
---|
| 2849 | VelType='civ2';
|
---|
| 2850 | % interp2
|
---|
| 2851 | elseif (get(handles.interp2,'Value') == 1);
|
---|
| 2852 | VelType='interp2';
|
---|
| 2853 | % filter2
|
---|
| 2854 | elseif (get(handles.filter2,'Value') == 1);
|
---|
| 2855 | VelType='filter2';
|
---|
| 2856 | end
|
---|
| 2857 |
|
---|
| 2858 | if isequal(get(handles.filter2,'Visible'),'on');
|
---|
| 2859 | civ=6;
|
---|
| 2860 | % interp1
|
---|
| 2861 | elseif isequal(get(handles.interp2,'Visible'),'on');
|
---|
| 2862 | civ=5;
|
---|
| 2863 | % filter1
|
---|
| 2864 | elseif isequal(get(handles.civ2,'Visible'),'on');
|
---|
| 2865 | civ=4;
|
---|
| 2866 | % CIV2
|
---|
| 2867 | elseif isequal(get(handles.filter1,'Visible'),'on');
|
---|
| 2868 | civ=3;
|
---|
| 2869 | % interp2
|
---|
| 2870 | elseif isequal(get(handles.interp1,'Visible'),'on');
|
---|
| 2871 | civ=2;
|
---|
| 2872 | % filter2
|
---|
| 2873 | elseif isequal(get(handles.civ1,'Visible'),'on');
|
---|
| 2874 | civ=1;
|
---|
| 2875 | else
|
---|
| 2876 | civ=0;
|
---|
| 2877 | end
|
---|
| 2878 |
|
---|
| 2879 | %-------------------------------------------------------------------
|
---|
| 2880 | %determines the veltype of the second field to read from the iinterface
|
---|
| 2881 | %------------------------------------------------------------------
|
---|
| 2882 | function VelType=setfield_1(handles)
|
---|
| 2883 |
|
---|
| 2884 | VelType=[]; %default
|
---|
| 2885 | if (get(handles.civ1_1,'Value') == 1);
|
---|
| 2886 | VelType='civ1';
|
---|
| 2887 | % interp1
|
---|
| 2888 | elseif (get(handles.interp1_1,'Value') == 1);
|
---|
| 2889 | VelType='interp1';
|
---|
| 2890 | % filter1
|
---|
| 2891 | elseif (get(handles.filter1_1,'Value') == 1);
|
---|
| 2892 | VelType='filter1';
|
---|
| 2893 | % CIV2
|
---|
| 2894 | elseif (get(handles.civ2_1,'Value') == 1);
|
---|
| 2895 | VelType='civ2';
|
---|
| 2896 | % interp2
|
---|
| 2897 | elseif (get(handles.interp2_1,'Value') == 1);
|
---|
| 2898 | VelType='interp2';
|
---|
| 2899 | % filter2
|
---|
| 2900 | elseif (get(handles.filter2_1,'Value') == 1);
|
---|
| 2901 | VelType='filter2';
|
---|
| 2902 | end
|
---|
| 2903 |
|
---|
| 2904 |
|
---|
| 2905 | %---------------------------------------------------
|
---|
| 2906 | % --- Executes on button press in SubField
|
---|
| 2907 | function SubField_Callback(hObject, eventdata, handles)
|
---|
| 2908 | huvmat=get(handles.run0,'parent');
|
---|
| 2909 | UvData=get(huvmat,'UserData');
|
---|
| 2910 | if get(handles.SubField,'Value')==0% if the subfield button is desactivated
|
---|
| 2911 | set(handles.RootPath_1,'String','')
|
---|
| 2912 | set(handles.RootFile_1,'String','')
|
---|
| 2913 | set(handles.SubDir_1,'String','');
|
---|
| 2914 | set(handles.FileIndex_1,'String','');
|
---|
| 2915 | set(handles.FileExt_1,'String','');
|
---|
| 2916 | set(handles.RootPath_1,'Visible','off')
|
---|
| 2917 | set(handles.RootFile_1,'Visible','off')
|
---|
| 2918 | set(handles.SubDir_1,'Visible','off');
|
---|
| 2919 | set(handles.FileIndex_1,'Visible','off');
|
---|
| 2920 | set(handles.FileExt_1,'Visible','off');
|
---|
| 2921 | set(handles.Fields_1,'Value',1);%set to blank state
|
---|
| 2922 | set_veltype_display([handles.civ1_1 handles.interp1_1 handles.filter1_1 ...
|
---|
| 2923 | handles.civ2_1 handles.interp2_1 handles.filter2_1],0)
|
---|
| 2924 | if isfield(UvData,'XmlData_1')
|
---|
| 2925 | UvData=rmfield(UvData,'XmlData_1');
|
---|
| 2926 | end
|
---|
| 2927 | set(huvmat,'UserData',UvData);
|
---|
| 2928 | run0_Callback(hObject, eventdata, handles); %run
|
---|
| 2929 | else
|
---|
| 2930 | MenuBrowse_1_Callback(hObject, eventdata, handles)
|
---|
| 2931 | end
|
---|
| 2932 |
|
---|
| 2933 | % %----------------------------------------------
|
---|
| 2934 | % %read the data displayed for the input rootfile windows (new)
|
---|
| 2935 | % %-------------------------------------------------
|
---|
| 2936 | function [FileName,RootPath,FileBase,FileIndices,FileExt,SubDir]=read_file_boxes(handles)
|
---|
| 2937 | RootPath=get(handles.RootPath,'String');
|
---|
| 2938 | FileName=RootPath; %default
|
---|
| 2939 | SubDir=get(handles.SubDir,'String');
|
---|
| 2940 | if ~isempty(SubDir) && ~isequal(SubDir,'')
|
---|
| 2941 | if (isequal(SubDir(1),'/')|| isequal(SubDir(1),'\'))
|
---|
| 2942 | SubDir(1)=[]; %suppress possible / or \ separator
|
---|
| 2943 | end
|
---|
| 2944 | FileName=fullfile(RootPath,SubDir);
|
---|
| 2945 | end
|
---|
| 2946 | RootFile=get(handles.RootFile,'String');
|
---|
| 2947 | if ~isempty(RootFile) && ~isequal(RootFile,'')
|
---|
| 2948 | if (isequal(RootFile(1),'/')|| isequal(RootFile(1),'\'))
|
---|
| 2949 | RootFile(1)=[]; %suppress possible / or \ separator
|
---|
| 2950 | end
|
---|
| 2951 | FileName=fullfile(FileName,RootFile);
|
---|
| 2952 | end
|
---|
| 2953 | FileBase=fullfile(RootPath,RootFile);
|
---|
| 2954 | FileIndices=get(handles.FileIndex,'String');
|
---|
| 2955 | FileExt=get(handles.FileExt,'String');
|
---|
| 2956 | FileName=[FileName FileIndices FileExt];
|
---|
| 2957 |
|
---|
| 2958 | %----------------------------------------------
|
---|
| 2959 | %read the data displayed for the second input rootfile windows
|
---|
| 2960 | %-------------------------------------------------
|
---|
| 2961 | function [FileName_1,RootPath_1,FileBase_1,FileIndices_1,FileExt_1,SubDir_1]=read_file_boxes_1(handles)
|
---|
| 2962 | RootPath_1=get(handles.RootPath_1,'String'); % read the data from the file1_input window
|
---|
| 2963 | if isequal(RootPath_1,'"'),RootPath_1=get(handles.RootPath,'String'); end;
|
---|
| 2964 | FileName_1=RootPath_1; %default
|
---|
| 2965 | SubDir_1=get(handles.SubDir_1,'String');
|
---|
| 2966 | if isequal(SubDir_1,'"')
|
---|
| 2967 | SubDir_1=get(handles.SubDir,'String');
|
---|
| 2968 | end
|
---|
| 2969 | if ~isempty(SubDir_1) && ~isequal(SubDir_1,'')
|
---|
| 2970 | if (isequal(SubDir_1(1),'/')|| isequal(SubDir_1(1),'\'))
|
---|
| 2971 | SubDir_1(1)=[]; %suppress possible / or \ separator
|
---|
| 2972 | end
|
---|
| 2973 | FileName_1=fullfile(RootPath_1,SubDir_1);
|
---|
| 2974 | end
|
---|
| 2975 | RootFile_1=get(handles.RootFile_1,'String');
|
---|
| 2976 | if isequal(RootFile_1,'"'),RootFile_1=get(handles.RootFile,'String'); end;
|
---|
| 2977 | if ~isempty(RootFile_1) && ~isequal(RootFile_1,'')
|
---|
| 2978 | if ~(isequal(RootFile_1(1),'/')|isequal(RootFile_1(1),'\'))
|
---|
| 2979 | RootFile_1(1)=[];%suppress possible / or \ separator
|
---|
| 2980 | end
|
---|
| 2981 | FileName_1=fullfile(FileName_1,RootFile_1);
|
---|
| 2982 | end
|
---|
| 2983 | FileBase_1=fullfile(RootPath_1,RootFile_1);
|
---|
| 2984 | FileIndices_1=get(handles.FileIndex_1,'String');
|
---|
| 2985 | FileExt_1=get(handles.FileExt_1,'String');
|
---|
| 2986 | if isequal(FileExt_1,'"'),FileExt_1=get(handles.FileExt,'String'); end;
|
---|
| 2987 | FileName_1=[FileName_1 FileIndices_1 FileExt_1];
|
---|
| 2988 |
|
---|
| 2989 | %---------------------------------------------------
|
---|
| 2990 | % --- Executes on menu selection Fields
|
---|
| 2991 | function Fields_Callback(hObject, eventdata, handles)
|
---|
| 2992 | %-------------------------------------------------
|
---|
[59] | 2993 |
|
---|
[2] | 2994 | list_fields=get(handles.Fields,'String');% list menu fields
|
---|
| 2995 | index_fields=get(handles.Fields,'Value');% selected string index
|
---|
| 2996 | field= list_fields{index_fields(1)}; % selected string
|
---|
| 2997 | if isequal(field,'get_field...')
|
---|
| 2998 | veltype_handles=[handles.civ1 handles.interp1 handles.filter1 handles.civ2 handles.interp2 handles.filter2];
|
---|
| 2999 | set_veltype_display(veltype_handles,0) % unvisible civ buttons
|
---|
| 3000 | filename=read_file_boxes(handles);
|
---|
| 3001 | hget_field=findobj(allchild(0),'name','get_field');
|
---|
| 3002 | if ~isempty(hget_field)
|
---|
| 3003 | delete(hget_field)
|
---|
| 3004 | end
|
---|
| 3005 | get_field(filename)
|
---|
| 3006 | return %no action
|
---|
| 3007 | end
|
---|
| 3008 | list_fields=get(handles.Fields_1,'String');% list menu fields
|
---|
| 3009 | index_fields=get(handles.Fields_1,'Value');% selected string index
|
---|
| 3010 | field_1= list_fields{index_fields(1)}; % selected string
|
---|
[59] | 3011 | UvData=get(handles.uvmat,'UserData');
|
---|
[2] | 3012 |
|
---|
| 3013 | %read the rootfile input display
|
---|
| 3014 | FileExt=get(handles.FileExt,'String');
|
---|
| 3015 | [P,F,str1,str2,str_a,str_b,E,NomType]=name2display(['xxx' get(handles.FileIndex,'String') FileExt]);
|
---|
| 3016 | NomTypeNew=NomType;%default
|
---|
| 3017 | if isequal(field,'image')
|
---|
| 3018 | % transform netc type to the corresponding image type
|
---|
| 3019 | if isequal(NomType,'_i1-i2_j')||isequal(NomType,'_i_j1-j2')|| isequal(NomType,'#_ab')|| isequal(NomType,'_i1-i2')
|
---|
| 3020 | UvData.SubDir=get(handles.SubDir,'String'); %preserve the subdir in memory
|
---|
[45] | 3021 | if ~isempty(UvData.SubDir) && (isequal(UvData.SubDir(1),'/')||isequal(UvData.SubDir(1),'/'))
|
---|
[2] | 3022 | UvData.SubDir(1)=[];
|
---|
| 3023 | end
|
---|
| 3024 | set(handles.SubDir,'String','')
|
---|
| 3025 | set(handles.FileExt,'String','.png');
|
---|
[45] | 3026 | if isequal(NomType,'_i1-i2_j')||isequal(NomType,'_i_j1-j2')
|
---|
[2] | 3027 | NomTypeNew='_i_j';
|
---|
| 3028 | elseif isequal(NomType,'#_ab')
|
---|
| 3029 | NomTypeNew='#a';
|
---|
| 3030 | elseif isequal(NomType,'_i1-i2')
|
---|
| 3031 | NomTypeNew='_i';
|
---|
| 3032 | end
|
---|
| 3033 | end
|
---|
| 3034 | veltype_handles=[handles.civ1 handles.interp1 handles.filter1 handles.civ2 handles.interp2 handles.filter2];
|
---|
| 3035 | set_veltype_display(veltype_handles,0) % unvisible civ buttons
|
---|
| 3036 | else
|
---|
| 3037 | ext=get(handles.FileExt,'String');
|
---|
| 3038 | if ~isequal(ext,'.nc') %find the new NomType if the previous display was not already a netcdf file
|
---|
| 3039 | MenuBrowse_Callback(hObject, eventdata, handles)
|
---|
| 3040 | end
|
---|
| 3041 | if isequal(field,'vort') || isequal(field,'div') || isequal(field,'strain')
|
---|
| 3042 | set(handles.civ1,'BackgroundColor',[0.702 0.702 0.702]) % put their color to grey
|
---|
| 3043 | set(handles.civ2,'BackgroundColor',[0.702 0.702 0.702])
|
---|
| 3044 | set(handles.interp1,'BackgroundColor',[0.702 0.702 0.702])
|
---|
| 3045 | set(handles.interp2,'BackgroundColor',[0.702 0.702 0.702])
|
---|
| 3046 | elseif isequal(field,'more...');
|
---|
| 3047 | set(handles.civ1,'BackgroundColor',[0.702 0.702 0.702]) % put their color to grey
|
---|
| 3048 | set(handles.civ2,'BackgroundColor',[0.702 0.702 0.702])
|
---|
| 3049 | str=calc_field;%get the list of available scalars by the function calc_scal
|
---|
[45] | 3050 | [ind_answer] = listdlg('PromptString','Select a file:',...
|
---|
[2] | 3051 | 'SelectionMode','single',...
|
---|
| 3052 | 'ListString',str);
|
---|
| 3053 | % edit the choice in the field and action menu
|
---|
| 3054 | scalar=cell2mat(str(ind_answer));
|
---|
| 3055 | menu=update_menu(handles.Fields,scalar);
|
---|
| 3056 | menu=[{''};menu];
|
---|
| 3057 | set(handles.Fields_1,'String',menu);% store the selected scalar type
|
---|
| 3058 | end
|
---|
| 3059 | end
|
---|
[45] | 3060 | indices=name_generator('',str2double(str1),str2double(str_a),'',NomTypeNew,1,str2double(str2),str2double(str_b),'');
|
---|
[2] | 3061 | set(handles.FileIndex,'String',indices)
|
---|
| 3062 | set(handles.FileIndex,'UserData',NomTypeNew)
|
---|
| 3063 | %common to Fields_1_Callback
|
---|
[45] | 3064 | if isequal(field,'image')||isequal(field_1,'image')
|
---|
[2] | 3065 | set(handles.npx_title,'Visible','on')% visible npx,pxcm... buttons
|
---|
| 3066 | set(handles.npy_title,'Visible','on')
|
---|
| 3067 | set(handles.npx,'Visible','on')
|
---|
| 3068 | set(handles.npy,'Visible','on')
|
---|
| 3069 | set(handles.fix_pair,'Value',0)
|
---|
| 3070 | else
|
---|
| 3071 | set(handles.npx_title,'Visible','off')% visible npx,pxcm... buttons
|
---|
| 3072 | set(handles.npy_title,'Visible','off')
|
---|
| 3073 | set(handles.npx,'Visible','off')
|
---|
| 3074 | set(handles.npy,'Visible','off')
|
---|
| 3075 | set(handles.fix_pair,'Value',1)
|
---|
| 3076 | end
|
---|
| 3077 | setfield(handles);% update the field structure ('civ1'....)
|
---|
| 3078 |
|
---|
[45] | 3079 | if ~isfield(UvData,'NewSeries')||isequal(UvData.NewSeries,0)
|
---|
[2] | 3080 | run0_Callback(hObject, eventdata, handles)
|
---|
| 3081 | end
|
---|
| 3082 |
|
---|
| 3083 | %---------------------------------------------------
|
---|
| 3084 | % --- Executes on menu selection Fields
|
---|
| 3085 | function Fields_1_Callback(hObject, eventdata, handles)
|
---|
| 3086 | %-------------------------------------------------
|
---|
| 3087 | list_fields=get(handles.Fields,'String');% list menu fields
|
---|
| 3088 | index_fields=get(handles.Fields,'Value');% selected string index
|
---|
| 3089 | field= list_fields{index_fields(1)}; % selected string
|
---|
| 3090 | list_fields=get(handles.Fields_1,'String');% list menu fields
|
---|
| 3091 | index_fields=get(handles.Fields_1,'Value');% selected string index
|
---|
| 3092 | field_1= list_fields{index_fields(1)}; % selected string for the second field
|
---|
| 3093 | if isequal(field_1,'') %remove second field if 'blank' field is selected
|
---|
| 3094 | set(handles.SubField,'Value',0)
|
---|
| 3095 | SubField_Callback(hObject, eventdata, handles)
|
---|
| 3096 | return
|
---|
| 3097 | end
|
---|
[59] | 3098 | UvData=get(handles.uvmat,'UserData');
|
---|
[2] | 3099 |
|
---|
| 3100 | %read the rootfile input display
|
---|
| 3101 | FileExt_prev=get(handles.FileExt_1,'String');
|
---|
| 3102 | if isempty(FileExt_prev)|isequal(FileExt_prev,'')
|
---|
| 3103 | FileExt_1=get(handles.FileExt,'String');
|
---|
| 3104 | else
|
---|
| 3105 | FileExt_1=FileExt_prev;
|
---|
| 3106 | end
|
---|
| 3107 | NomType_1=get(handles.FileIndex_1,'UserData');
|
---|
| 3108 | if isempty(NomType_1)|isequal(NomType_1,'')
|
---|
| 3109 | NomType_1=get(handles.FileIndex,'UserData');
|
---|
| 3110 | end
|
---|
| 3111 | NomTypeNew=NomType_1;%default
|
---|
| 3112 |
|
---|
| 3113 | set(handles.SubField,'Value',1)%introduce second field
|
---|
| 3114 | if isfield(UvData,'XmlData')
|
---|
| 3115 | UvData.XmlData_1=UvData.XmlData;
|
---|
| 3116 | end
|
---|
| 3117 | set(handles.FileIndex_1,'Visible','on')
|
---|
| 3118 | set(handles.FileExt_1,'Visible','on')
|
---|
| 3119 | RootPath_1=get(handles.RootPath_1,'String');
|
---|
| 3120 | RootFile_1=get(handles.RootFile_1,'String');
|
---|
| 3121 | if isempty(RootPath_1)|isequal(RootPath_1,'')
|
---|
| 3122 | set(handles.RootPath_1,'String','"')
|
---|
| 3123 | end
|
---|
| 3124 | if isempty(RootFile_1) | isequal(RootFile_1,'')
|
---|
| 3125 | set(handles.RootFile_1,'String','"')
|
---|
| 3126 | end
|
---|
| 3127 | if ~isempty(RootFile_1)&(isequal(RootFile_1(1),'/')|isequal(RootFile_1(1),'\'))
|
---|
| 3128 | RootFile_1(1)=[];
|
---|
| 3129 | end
|
---|
| 3130 |
|
---|
| 3131 | if isequal(field_1,'get_field...')
|
---|
| 3132 | veltype_handles=[handles.civ1 handles.interp1 handles.filter1 handles.civ2 handles.interp2 handles.filter2];
|
---|
| 3133 | set_veltype_display(veltype_handles,0) % unvisible civ buttons
|
---|
| 3134 | filename=read_file_boxes_1(handles);
|
---|
| 3135 | hget_field=findobj(allchild(0),'name','get_field_1');
|
---|
| 3136 | if ~isempty(hget_field)
|
---|
| 3137 | delete(hget_field)
|
---|
| 3138 | end
|
---|
| 3139 | hget_field=get_field(filename);
|
---|
| 3140 | set(hget_field,'name','get_field_1')
|
---|
| 3141 | return %no action
|
---|
| 3142 | end
|
---|
| 3143 | if isequal(field_1,'image')
|
---|
| 3144 | % transform netc type to the corresponding image type
|
---|
| 3145 | set(handles.FileExt_1,'String','.png');
|
---|
| 3146 | if isequal(NomType_1,'_i1-i2_j')|isequal(NomType_1,'_i_j1-j2')| isequal(NomType_1,'#_ab')| isequal(NomType_1,'_i1-i2')
|
---|
| 3147 | UvData.SubDir_1=get(handles.SubDir_1,'String'); %preserve the subdir in memory
|
---|
| 3148 | set(handles.SubDir_1,'String','')
|
---|
| 3149 | % set(handles.FileExt_1,'String','.png');
|
---|
| 3150 | if isequal(NomType_1,'_i1-i2_j')|isequal(NomType_1,'_i_j1-j2')
|
---|
| 3151 | NomTypeNew='_i_j';
|
---|
| 3152 | elseif isequal(NomType_1,'#_ab')
|
---|
| 3153 | NomTypeNew='#a';
|
---|
| 3154 | elseif isequal(NomType_1,'_i1-i2')
|
---|
| 3155 | NomTypeNew='_i';
|
---|
| 3156 | end
|
---|
| 3157 | end
|
---|
| 3158 | veltype_handles=[handles.civ1_1 handles.interp1_1 handles.filter1_1 handles.civ2_1 handles.interp2_1 handles.filter2_1];
|
---|
| 3159 | set_veltype_display(veltype_handles,0) % unvisible civ buttons
|
---|
| 3160 | else
|
---|
| 3161 | set(handles.SubDir_1,'Visible','on')
|
---|
| 3162 | if ~isequal(FileExt_prev,'.nc') %find the new NomType if the previous display was not already a netcdf file
|
---|
| 3163 | veltype_handles=[handles.civ1_1 handles.interp1_1 handles.filter1_1 handles.civ2_1 handles.interp2_1 handles.filter2_1];
|
---|
| 3164 | set_veltype_display(veltype_handles,6); % make all civ buttons visible
|
---|
| 3165 | RootPath_1=get(handles.RootPath_1,'String');
|
---|
| 3166 | RootFile_1=get(handles.RootFile_1,'String');
|
---|
| 3167 | if isempty(RootPath_1)|isequal(RootPath_1,'')
|
---|
| 3168 | set(handles.RootPath_1,'String','"')
|
---|
| 3169 | end
|
---|
| 3170 | if isempty(RootFile_1) | isequal(RootFile_1,'')
|
---|
| 3171 | set(handles.RootFile_1,'String','"')
|
---|
| 3172 | end
|
---|
| 3173 | if ~isempty(RootFile_1)&(isequal(RootFile_1(1),'/')|isequal(RootFile_1(1),'\'))
|
---|
| 3174 | RootFile_1(1)=[];
|
---|
| 3175 | end
|
---|
| 3176 | filebase_1=fullfile(RootPath_1,RootFile_1);
|
---|
| 3177 | SubDir_1=get(handles.SubDir,'String');
|
---|
| 3178 | if isempty(SubDir_1)|isequal(SubDir_1,'')
|
---|
| 3179 | if isfield(UvData,'SubDir_1')
|
---|
| 3180 | SubDir_1=UvData.SubDir_1;%retrieve previous subdir
|
---|
| 3181 | else
|
---|
| 3182 | SubDir_1='?';
|
---|
| 3183 | end
|
---|
| 3184 | end
|
---|
| 3185 | if isequal(NomType_1,'#_ab')|isequal(NomType_1,'_i1-i2_j')|isequal(NomType_1,'_i_j1-j2')|isequal(NomType_1,'_i1-i2')
|
---|
| 3186 | NomTypeNew=NomType_1;
|
---|
| 3187 | elseif isequal(NomType_1,'#a')
|
---|
| 3188 | [filename,idetect,n1,na,n2,nb,SubDir_1]=name_generator(filebase_1, str2num(str1),str2num(str_a),'.nc','#_ab',0,[],[],SubDir_1);
|
---|
| 3189 | NomTypeNew='#_ab';
|
---|
| 3190 | elseif isequal(NomType_1,'_i_j')
|
---|
| 3191 | [filename,idetect,n1,na,n2,nb,SubDir_1]=name_generator(filebase_1,str2num(str1),str2num(str_a),'.nc','_i1-i2_j',0,str2num(str1),[],SubDir_1);
|
---|
| 3192 | if idetect==1
|
---|
| 3193 | NomTypeNew='_i1-i2_j';
|
---|
| 3194 | else
|
---|
| 3195 | NomTypeNew='_i_j1-j2';
|
---|
| 3196 | end
|
---|
| 3197 | else %for instance avi files or any ima_num series
|
---|
| 3198 | [filename,idetect,n1,na,n2,nb,SubDir_1]=name_generator(filebase_1,str2num(str1),str2num(str_a),'.nc','_i1-i2',0,str2num(str1),[],SubDir_1);
|
---|
| 3199 | NomTypeNew='_i1-i2';
|
---|
| 3200 | end
|
---|
| 3201 | [Path,Name]=fileparts(filebase_1);
|
---|
| 3202 | set(handles.FileExt_1,'String','.nc');
|
---|
| 3203 | if ~isempty(SubDir_1) & ~isequal(SubDir_1,'''')& ~isequal(SubDir_1,'"')
|
---|
| 3204 | SubDir_1=['/' SubDir_1];
|
---|
| 3205 | end
|
---|
| 3206 | set(handles.SubDir_1,'String',SubDir_1);
|
---|
| 3207 | end
|
---|
| 3208 | if isequal(field,'vort') | isequal(field,'div') | isequal(field,'strain')
|
---|
| 3209 | set(handles.civ1_1,'BackgroundColor',[0.702 0.702 0.702]) % put their color to grey
|
---|
| 3210 | set(handles.civ2_1,'BackgroundColor',[0.702 0.702 0.702])
|
---|
| 3211 | set(handles.interp1_1,'BackgroundColor',[0.702 0.702 0.702])
|
---|
| 3212 | set(handles.interp2_1,'BackgroundColor',[0.702 0.702 0.702])
|
---|
| 3213 | elseif isequal(field_1,'more...'); %add new item to the menu
|
---|
| 3214 | set(handles.civ1_1,'BackgroundColor',[0.702 0.702 0.702]) % put their color to grey
|
---|
| 3215 | set(handles.civ2_1,'BackgroundColor',[0.702 0.702 0.702])
|
---|
| 3216 | str=calc_field;%get the list of available scalars by the function calc_scal
|
---|
| 3217 | [ind_answer,v] = listdlg('PromptString','Select a file:',...
|
---|
| 3218 | 'SelectionMode','single',...
|
---|
| 3219 | 'ListString',str);
|
---|
| 3220 | % edit the choice in the field and action menu
|
---|
| 3221 | scalar=cell2mat(str(ind_answer));
|
---|
| 3222 | menu=update_menu(handles.Fields_1,scalar);
|
---|
| 3223 | set(handles.Fields_1,'String',menu);% store the selected scalar type
|
---|
| 3224 | end
|
---|
| 3225 | end
|
---|
| 3226 | str1=get(handles.i1,'String');
|
---|
| 3227 | str2=get(handles.i2,'String');
|
---|
| 3228 | str_a=get(handles.j1,'String');
|
---|
| 3229 | str_b=get(handles.j2,'String');
|
---|
| 3230 | indices=name_generator('',str2num(str1),stra2num(str_a),'',NomTypeNew,1,str2num(str2),stra2num(str_b),'');
|
---|
| 3231 | set(handles.FileIndex_1,'String',indices)
|
---|
| 3232 | set(handles.FileIndex_1,'UserData',NomTypeNew)
|
---|
| 3233 |
|
---|
| 3234 | %common to Fields_Callback
|
---|
| 3235 | if isequal(field,'image')|isequal(field_1,'image')
|
---|
| 3236 | set(handles.npx_title,'Visible','on')% visible npx,pxcm... buttons
|
---|
| 3237 | set(handles.npy_title,'Visible','on')
|
---|
| 3238 | set(handles.npx,'Visible','on')
|
---|
| 3239 | set(handles.npy,'Visible','on')
|
---|
| 3240 | set(handles.fix_pair,'Value',0)
|
---|
| 3241 | else
|
---|
| 3242 | set(handles.npx_title,'Visible','off')% visible npx,pxcm... buttons
|
---|
| 3243 | set(handles.npy_title,'Visible','off')
|
---|
| 3244 | set(handles.npx,'Visible','off')
|
---|
| 3245 | set(handles.npy,'Visible','off')
|
---|
| 3246 | set(handles.fix_pair,'Value',1)
|
---|
| 3247 | end
|
---|
| 3248 | if isequal(field,'velocity')|isequal(field_1,'velocity');
|
---|
| 3249 | state_vect='on';
|
---|
| 3250 | else
|
---|
| 3251 | state_vect='off';
|
---|
| 3252 | end
|
---|
| 3253 | if ~isequal(field,'velocity')|(~isequal(field_1,'velocity')&~isequal(field_1,''));
|
---|
| 3254 | state_scal='on';
|
---|
| 3255 | else
|
---|
| 3256 | state_scal='off';
|
---|
| 3257 | end
|
---|
[59] | 3258 | set(handles.uvmat,'UserData',UvData)
|
---|
[2] | 3259 | setfield(handles);% update the field structure ('civ1'....)
|
---|
| 3260 | if ~isfield(UvData,'NewSeries')|isequal(UvData.NewSeries,0)
|
---|
| 3261 | run0_Callback(hObject, eventdata, handles)
|
---|
| 3262 | end
|
---|
| 3263 |
|
---|
[57] | 3264 | %------------------------------------------------------------------------
|
---|
| 3265 | % --- set the visibility of relevant velocity type menus:
|
---|
| 3266 | function set_veltype_display(handles,Civ)
|
---|
| 3267 | %------------------------------------------------------------------------
|
---|
[2] | 3268 | %Civ=0; all states 'off'
|
---|
| 3269 | %Civ=6; all states 'on'
|
---|
| 3270 | if isequal(Civ,0)
|
---|
| 3271 | imax=0;
|
---|
| 3272 | % set(handles(1),'Visible','on') % unvisible civ buttons
|
---|
| 3273 | % else
|
---|
| 3274 | % set(handles(1),'String','civ1')
|
---|
| 3275 | % end
|
---|
[57] | 3276 | elseif isequal(Civ,1) || isequal(Civ,2)
|
---|
[2] | 3277 | imax=1;
|
---|
[57] | 3278 | elseif isequal(Civ,3)
|
---|
[2] | 3279 | imax=3;
|
---|
[57] | 3280 | elseif isequal(Civ,4) || isequal(Civ,5)
|
---|
[2] | 3281 | imax=4;
|
---|
[57] | 3282 | elseif isequal(Civ,6) %patch2
|
---|
[2] | 3283 | imax=6;
|
---|
| 3284 | end
|
---|
| 3285 | for ibutton=1:imax;
|
---|
| 3286 | set(handles(ibutton),'Visible','on') % unvisible civ buttons
|
---|
| 3287 | end
|
---|
| 3288 | % for ibutton=max(imax+1,2):6;
|
---|
| 3289 | for ibutton=imax+1:6;
|
---|
| 3290 | set(handles(ibutton),'Visible','off') % unvisible civ buttons
|
---|
| 3291 | set(handles(ibutton),'Value',0)%unactivate unvisible buttons
|
---|
| 3292 | end
|
---|
| 3293 |
|
---|
| 3294 | %-------------------------------------------------------------------
|
---|
| 3295 | % --- Executes on button press in civ1.
|
---|
| 3296 | function civ1_Callback(hObject, eventdata, handles)
|
---|
| 3297 | %-------------------------------------------------------------------
|
---|
| 3298 | if get(handles.civ1,'Value')==1
|
---|
| 3299 | reset_vel_type([handles.interp1 handles.civ2 handles.filter1 handles.interp1 handles.interp2 handles.filter2],handles.civ1)
|
---|
| 3300 | else
|
---|
| 3301 | reset_vel_type([handles.civ1 handles.filter1 handles.interp1 handles.civ2 handles.interp2 handles.filter2])
|
---|
| 3302 | end
|
---|
| 3303 | run0_Callback(hObject, eventdata, handles)
|
---|
| 3304 |
|
---|
| 3305 | %-------------------------------------------------------------------
|
---|
| 3306 | % --- Executes on button press in interp1.
|
---|
| 3307 | function interp1_Callback(hObject, eventdata, handles)
|
---|
| 3308 | %-------------------------------------------------------------------
|
---|
| 3309 | if get(handles.interp1,'Value')==1
|
---|
| 3310 | reset_vel_type([handles.civ1 handles.civ2 handles.filter1 handles.interp2 handles.filter2],handles.interp1)
|
---|
| 3311 | else
|
---|
| 3312 | reset_vel_type([handles.civ1 handles.filter1 handles.interp1 handles.civ2 handles.interp2 handles.filter2])
|
---|
| 3313 | end
|
---|
| 3314 | run0_Callback(hObject, eventdata, handles)
|
---|
| 3315 |
|
---|
| 3316 | %-------------------------------------------------------------------
|
---|
| 3317 | % --- Executes on button press in filter1.
|
---|
| 3318 | function filter1_Callback(hObject, eventdata, handles)
|
---|
| 3319 | %-------------------------------------------------------------------
|
---|
| 3320 | if get(handles.filter1,'Value')==1
|
---|
| 3321 | reset_vel_type([handles.civ1 handles.civ2 handles.interp1 handles.interp2 handles.filter2],handles.filter1)
|
---|
| 3322 | else
|
---|
| 3323 | reset_vel_type([handles.civ1 handles.filter1 handles.interp1 handles.civ2 handles.interp2 handles.filter2])
|
---|
| 3324 | end
|
---|
| 3325 | run0_Callback(hObject, eventdata, handles)
|
---|
| 3326 |
|
---|
| 3327 | %-------------------------------------------------------------------
|
---|
| 3328 | % --- Executes on button press in civ2.
|
---|
| 3329 | function civ2_Callback(hObject, eventdata, handles)
|
---|
| 3330 | %-------------------------------------------------------------------
|
---|
| 3331 | if get(handles.civ2,'Value')==1
|
---|
| 3332 | reset_vel_type([handles.civ1 handles.filter1 handles.interp1 handles.interp2 handles.filter2],handles.civ2)
|
---|
| 3333 | else
|
---|
| 3334 | reset_vel_type([handles.civ1 handles.filter1 handles.interp1 handles.civ2 handles.interp2 handles.filter2])
|
---|
| 3335 | end
|
---|
| 3336 | run0_Callback(hObject, eventdata, handles)
|
---|
| 3337 |
|
---|
| 3338 | %-----------------------------------------
|
---|
| 3339 | % --- Executes on button press in interp2.
|
---|
| 3340 | %-------------------------------------------
|
---|
| 3341 | function interp2_Callback(hObject, eventdata, handles)
|
---|
| 3342 | if get(handles.interp2,'Value')==1
|
---|
| 3343 | reset_vel_type([handles.civ1 handles.filter1 handles.interp1 handles.civ2 handles.filter2],handles.interp2)
|
---|
| 3344 | else
|
---|
| 3345 | reset_vel_type([handles.civ1 handles.filter1 handles.interp1 handles.civ2 handles.interp2 handles.filter2])
|
---|
| 3346 | end
|
---|
| 3347 | run0_Callback(hObject, eventdata, handles)
|
---|
| 3348 | %---------------------------------------------
|
---|
| 3349 | % --- Executes on button press in filter2.
|
---|
| 3350 | %-------------------------------------------
|
---|
| 3351 | function filter2_Callback(hObject, eventdata, handles)
|
---|
| 3352 | if get(handles.filter2,'Value')==1
|
---|
| 3353 | reset_vel_type([handles.civ1 handles.filter1 handles.interp1 handles.civ2 handles.interp2],handles.filter2)
|
---|
| 3354 | else
|
---|
| 3355 | reset_vel_type([handles.civ1 handles.filter1 handles.interp1 handles.civ2 handles.interp2 handles.filter2])
|
---|
| 3356 | end
|
---|
| 3357 | run0_Callback(hObject, eventdata, handles)
|
---|
| 3358 |
|
---|
| 3359 | %---------------------------------------------
|
---|
| 3360 | function civ1_1_Callback(hObject, eventdata, handles)
|
---|
| 3361 | %---------------------------------------------
|
---|
| 3362 | if get(handles.civ1_1,'Value')==1
|
---|
| 3363 | reset_vel_type([handles.interp1_1 handles.civ2_1 handles.filter1_1 handles.interp1_1 handles.interp2_1 handles.filter2_1],handles.civ1_1)
|
---|
| 3364 | else
|
---|
| 3365 | reset_vel_type([handles.civ1_1 handles.filter1_1 handles.interp1_1 handles.civ2_1 handles.interp2_1 handles.filter2_1])
|
---|
| 3366 | end
|
---|
| 3367 | run0_Callback(hObject, eventdata, handles)
|
---|
| 3368 |
|
---|
| 3369 | %--------------------------------------------
|
---|
| 3370 | function interp1_1_Callback(hObject, eventdata, handles)
|
---|
| 3371 | %--------------------------------------------
|
---|
| 3372 | if get(handles.interp1_1,'Value')==1
|
---|
| 3373 | reset_vel_type([handles.civ1_1 handles.civ2_1 handles.filter1_1 handles.interp2_1 handles.filter2_1],handles.interp1_1)
|
---|
| 3374 | else
|
---|
| 3375 | reset_vel_type([handles.civ1_1 handles.filter1_1 handles.interp1_1 handles.civ2_1 handles.interp2_1 handles.filter2_1])
|
---|
| 3376 | end
|
---|
| 3377 | run0_Callback(hObject, eventdata, handles)
|
---|
| 3378 |
|
---|
| 3379 | %--------------------------------------------
|
---|
| 3380 | function filter1_1_Callback(hObject, eventdata, handles)
|
---|
| 3381 | %--------------------------------------------
|
---|
| 3382 | if get(handles.filter1_1,'Value')==1
|
---|
| 3383 | reset_vel_type([handles.interp1_1 handles.civ2_1 handles.interp1_1 handles.interp2_1 handles.filter2_1],handles.filter1_1)
|
---|
| 3384 | else
|
---|
| 3385 | reset_vel_type([handles.civ1_1 handles.filter1_1 handles.interp1_1 handles.civ2_1 handles.interp2_1 handles.filter2_1])
|
---|
| 3386 | end
|
---|
| 3387 | run0_Callback(hObject, eventdata, handles)
|
---|
| 3388 |
|
---|
| 3389 | %--------------------------------------------
|
---|
| 3390 | function civ2_1_Callback(hObject, eventdata, handles)
|
---|
| 3391 | %--------------------------------------------
|
---|
| 3392 | if get(handles.civ2_1,'Value')==1
|
---|
| 3393 | reset_vel_type([handles.civ1_1 handles.interp1_1 handles.filter1_1 handles.interp2_1 handles.filter2_1],handles.civ2_1)
|
---|
| 3394 | else
|
---|
| 3395 | reset_vel_type([handles.civ1_1 handles.filter1_1 handles.interp1_1 handles.civ2_1 handles.interp2_1 handles.filter2_1])
|
---|
| 3396 | end
|
---|
| 3397 | run0_Callback(hObject, eventdata, handles)
|
---|
| 3398 |
|
---|
| 3399 | %--------------------------------------------
|
---|
| 3400 | function interp2_1_Callback(hObject, eventdata, handles)
|
---|
| 3401 | %--------------------------------------------
|
---|
| 3402 | if get(handles.interp2_1,'Value')==1
|
---|
| 3403 | reset_vel_type([handles.civ1_1 handles.civ2_1 handles.filter1_1 handles.interp1_1 handles.filter2_1],handles.interp2_1)
|
---|
| 3404 | else
|
---|
| 3405 | reset_vel_type([handles.civ1_1 handles.filter1_1 handles.interp1_1 handles.civ2_1 handles.interp2_1 handles.filter2_1])
|
---|
| 3406 | end
|
---|
| 3407 | run0_Callback(hObject, eventdata, handles)
|
---|
| 3408 |
|
---|
| 3409 | %--------------------------------------------
|
---|
| 3410 | function filter2_1_Callback(hObject, eventdata, handles)
|
---|
| 3411 | %--------------------------------------------
|
---|
| 3412 | if get(handles.filter2_1,'Value')==1
|
---|
| 3413 | reset_vel_type([handles.civ1_1 handles.interp1_1 handles.civ2_1 handles.filter1_1 handles.interp1_1 handles.interp2_1],handles.filter2_1)
|
---|
| 3414 | else
|
---|
| 3415 | reset_vel_type([handles.civ1_1 handles.filter1_1 handles.interp1_1 handles.civ2_1 handles.interp2_1 handles.filter2_1])
|
---|
| 3416 | end
|
---|
| 3417 | run0_Callback(hObject, eventdata, handles)
|
---|
| 3418 |
|
---|
| 3419 | %-----------------------------------------------
|
---|
| 3420 | % --- reset civ buttons
|
---|
| 3421 | function reset_vel_type(handles_civ0,handle1)
|
---|
| 3422 | for ibutton=1:length(handles_civ0)
|
---|
| 3423 | set(handles_civ0(ibutton),'BackgroundColor',[0.831 0.816 0.784])
|
---|
| 3424 | set(handles_civ0(ibutton),'Value',0)
|
---|
| 3425 | end
|
---|
| 3426 | if exist('handle1','var')%handles of selected button
|
---|
| 3427 | set(handle1,'BackgroundColor',[1 1 0])
|
---|
| 3428 | end
|
---|
| 3429 |
|
---|
| 3430 | %-------------------------------------------------------
|
---|
| 3431 | % --- Executes on button press in MENUVOLUME.
|
---|
| 3432 | %-------------------------------------------------------
|
---|
| 3433 | function VOLUME_Callback(hObject, eventdata, handles)
|
---|
| 3434 | %errordlg('command VOL not implemented yet')
|
---|
| 3435 | if ishandle(handles.UVMAT_title)
|
---|
| 3436 | delete(handles.UVMAT_title)
|
---|
| 3437 | end
|
---|
[61] | 3438 | UvData=get(handles.uvmat,'UserData');%read UvData properties stored on the uvmat interface
|
---|
[2] | 3439 | if isequal(get(handles.VOLUME,'Value'),1)
|
---|
| 3440 | set(handles.zoom,'Value',0)
|
---|
| 3441 | set(handles.zoom,'BackgroundColor',[0.7 0.7 0.7])
|
---|
| 3442 | set(handles.edit_vect,'Value',0)
|
---|
| 3443 | edit_vect_Callback(hObject, eventdata, handles)
|
---|
| 3444 | set(handles.edit,'Value',0)
|
---|
| 3445 | set(handles.edit,'BackgroundColor',[0.7 0.7 0.7])
|
---|
[61] | 3446 | % set(handles.cal,'Value',0)
|
---|
| 3447 | % set(handles.cal,'BackgroundColor',[0 1 0])
|
---|
[2] | 3448 | set(handles.edit_vect,'Value',0)
|
---|
| 3449 | edit_vect_Callback(hObject, eventdata, handles)
|
---|
| 3450 | %initiate set_object GUI
|
---|
| 3451 | data.TITLE='VOLUME';
|
---|
| 3452 | if isfield(UvData,'CoordType')
|
---|
| 3453 | data.CoordType=UvData.CoordType;
|
---|
| 3454 | end
|
---|
| 3455 | if isfield(UvData,'Mesh')&~isempty(UvData.Mesh)
|
---|
| 3456 | data.RangeY=UvData.Mesh;
|
---|
| 3457 | data.RangeX=UvData.Mesh;
|
---|
| 3458 | data.DX=UvData.Mesh;
|
---|
| 3459 | data.DY=UvData.Mesh;
|
---|
| 3460 | elseif isfield(UvData.Field,'AX')&isfield(UvData.Field,'AY')& isfield(UvData.Field,'A')%only image
|
---|
| 3461 | np=size(UvData.Field.A);
|
---|
| 3462 | meshx=(UvData.Field.AX(end)-UvData.Field.AX(1))/np(2);
|
---|
| 3463 | meshy=abs(UvData.Field.AY(end)-UvData.Field.AY(1))/np(1);
|
---|
| 3464 | data.RangeY=max(meshx,meshy);
|
---|
| 3465 | data.RangeX=max(meshx,meshy);
|
---|
| 3466 | data.DX=max(meshx,meshy);
|
---|
| 3467 | end
|
---|
| 3468 | data.ParentButton=handles.VOLUME;
|
---|
| 3469 | PlotHandles=get_plot_handles(handles);%get the handles of the interface elements setting the plotting parameters
|
---|
| 3470 | [hset_object,UvData.sethandles]=set_object(data,PlotHandles);% call the set_object interface with action on haxes,
|
---|
| 3471 | % associate the set_edit interface handle to the plotting axes
|
---|
| 3472 | if isfield(UvData,'SetObjectOrigin')
|
---|
| 3473 | pos_uvmat=get(huvmat,'Position');
|
---|
| 3474 | pos_set_object(1:2)=UvData.SetObjectOrigin + pos_uvmat(1:2);
|
---|
| 3475 | pos_set_object(3:4)=UvData.SetObjectSize .* pos_uvmat(3:4);
|
---|
| 3476 | set(hset_object,'Position',pos_set_object)
|
---|
| 3477 | end
|
---|
| 3478 | UvData.MouseAction='create_object';
|
---|
| 3479 | else
|
---|
| 3480 | set(handles.VOLUME,'BackgroundColor',[0 1 0])
|
---|
| 3481 | UvData.MouseAction='none';
|
---|
| 3482 | end
|
---|
| 3483 | set(huvmat,'UserData',UvData)
|
---|
| 3484 |
|
---|
| 3485 | %-------------------------------------------------------
|
---|
| 3486 | function edit_vect_Callback(hObject, eventdata, handles)
|
---|
| 3487 | %-------------------------------------------------------
|
---|
[55] | 3488 |
|
---|
| 3489 | UvData=get(handles.uvmat,'UserData');%read UvData properties stored on the uvmat interface
|
---|
[2] | 3490 | if isequal(get(handles.edit_vect,'Value'),1)
|
---|
[55] | 3491 | test_civ2=isequal(get(handles.civ2,'BackgroundColor'),[1 1 0]);
|
---|
| 3492 | test_civ1=isequal(get(handles.civ1,'BackgroundColor'),[1 1 0]);
|
---|
| 3493 | if ~test_civ2 && ~test_civ1
|
---|
| 3494 | msgbox_uvmat('ERROR','manual correction only possible for CIV1 or CIV2 velocity fields')
|
---|
| 3495 | end
|
---|
[2] | 3496 | set(handles.record,'Visible','on')
|
---|
| 3497 | set(handles.edit_vect,'BackgroundColor',[1 1 0])
|
---|
| 3498 | set(handles.edit,'Value',0)
|
---|
[61] | 3499 | set(handles.zoom,'Value',0)
|
---|
| 3500 | set(handles.zoom,'BackgroundColor',[0.7 0.7 0.7])
|
---|
| 3501 | % set(handles.create,'Value',0)
|
---|
| 3502 | % set(handles.create,'BackgroundColor',[0 1 0])
|
---|
[2] | 3503 | set(handles.edit,'BackgroundColor',[0.7 0.7 0.7])
|
---|
| 3504 | set(gcf,'Pointer','arrow')
|
---|
| 3505 | UvData.MouseAction='edit_vect';
|
---|
| 3506 | else
|
---|
| 3507 | set(handles.record,'Visible','off')
|
---|
| 3508 | set(handles.edit_vect,'BackgroundColor',[0.7 0.7 0.7])
|
---|
| 3509 | UvData.MouseAction='none';
|
---|
| 3510 | end
|
---|
[55] | 3511 | set(handles.uvmat,'UserData',UvData)
|
---|
[2] | 3512 |
|
---|
| 3513 | %----------------------------------------------
|
---|
| 3514 | function save_mask_Callback(hObject, eventdata, handles)
|
---|
| 3515 | %-----------------------------------------------------------------------
|
---|
| 3516 | huvmat=get(handles.save_mask,'parent');
|
---|
| 3517 | UvData=get(huvmat,'UserData');
|
---|
| 3518 |
|
---|
| 3519 | hpatch=findobj(huvmat,'Type','patch');
|
---|
| 3520 | flag=1;
|
---|
| 3521 | npx=size(UvData.Field.A,2);
|
---|
| 3522 | npy=size(UvData.Field.A,1);
|
---|
| 3523 | xi=[0.5:npx-0.5];
|
---|
| 3524 | yi=[0.5:npy-0.5];
|
---|
| 3525 | [Xi,Yi]=meshgrid(xi,yi);
|
---|
| 3526 | if isfield(UvData,'Object')
|
---|
| 3527 | for iobj=1:length(UvData.Object)
|
---|
| 3528 | ObjectData=UvData.Object{iobj};
|
---|
| 3529 | if isfield(ObjectData,'ProjMode') &&(isequal(ObjectData.ProjMode,'mask_inside')||isequal(ObjectData.ProjMode,'mask_outside'));
|
---|
| 3530 | flagobj=1;
|
---|
| 3531 | testphys=0; %coordinates in pixels by default
|
---|
| 3532 | if isfield(ObjectData,'CoordType') && isequal(ObjectData.CoordType,'phys')
|
---|
| 3533 | if isfield(UvData,'XmlData')&& isfield(UvData.XmlData,'GeometryCalib')
|
---|
| 3534 | Calib=UvData.XmlData.GeometryCalib;
|
---|
| 3535 | testphys=1;
|
---|
| 3536 | end
|
---|
| 3537 | end
|
---|
| 3538 | if isfield(ObjectData,'Coord')& isfield(ObjectData,'Style')
|
---|
| 3539 | if isequal(ObjectData.Style,'polygon')
|
---|
| 3540 | X=ObjectData.Coord(:,1);
|
---|
| 3541 | Y=ObjectData.Coord(:,2);
|
---|
| 3542 | if testphys
|
---|
| 3543 | [X,Y]=px_XYZ(Calib,X,Y,0);% to generalise with 3D cases
|
---|
| 3544 | end
|
---|
| 3545 | flagobj=~inpolygon(Xi,Yi,X,Y);%=0 inside the polygon, 1 outside
|
---|
| 3546 | elseif isequal(ObjectData.Style,'ellipse')
|
---|
| 3547 | if testphys
|
---|
| 3548 | %[X,Y]=px_XYZ(Calib,X,Y,0);% TODO:create a polygon boundary and transform to phys
|
---|
| 3549 | end
|
---|
| 3550 | RangeX=max(ObjectData.RangeX);
|
---|
| 3551 | RangeY=max(ObjectData.RangeY);
|
---|
| 3552 | X2Max=RangeX*RangeX;
|
---|
| 3553 | Y2Max=RangeY*RangeY;
|
---|
| 3554 | distX=(Xi-ObjectData.Coord(1,1));
|
---|
| 3555 | distY=(Yi-ObjectData.Coord(1,2));
|
---|
| 3556 | flagobj=(distX.*distX/X2Max+distY.*distY/Y2Max)>1;
|
---|
| 3557 | elseif isequal(ObjectData.Style,'rectangle')
|
---|
| 3558 | if testphys
|
---|
| 3559 | %[X,Y]=px_XYZ(Calib,X,Y,0);% TODO:create a polygon boundary and transform to phys
|
---|
| 3560 | end
|
---|
| 3561 | distX=abs(Xi-ObjectData.Coord(1,1));
|
---|
| 3562 | distY=abs(Yi-ObjectData.Coord(1,2));
|
---|
| 3563 | flagobj=distX>max(ObjectData.RangeX) | distY>max(ObjectData.RangeY);
|
---|
| 3564 | end
|
---|
| 3565 | if isequal(ObjectData.ProjMode,'mask_outside')
|
---|
| 3566 | flagobj=~flagobj;
|
---|
| 3567 | end
|
---|
| 3568 | flag=flag & flagobj;
|
---|
| 3569 | end
|
---|
| 3570 | end
|
---|
| 3571 | end
|
---|
| 3572 | end
|
---|
| 3573 | % flag=~flag;
|
---|
| 3574 | %mask name
|
---|
| 3575 | RootPath=get(handles.RootPath,'String');
|
---|
| 3576 | RootFile=get(handles.RootFile,'String');
|
---|
| 3577 | if ~isempty(RootFile)&(isequal(RootFile(1),'/')| isequal(RootFile(1),'\'))
|
---|
| 3578 | RootFile(1)=[];
|
---|
| 3579 | end
|
---|
| 3580 | filebase=fullfile(RootPath,RootFile);
|
---|
| 3581 | list=get(handles.masklevel,'String');
|
---|
| 3582 | masknumber=num2str(length(list));
|
---|
| 3583 | maskindex=get(handles.masklevel,'Value');
|
---|
| 3584 | mask_name=name_generator([filebase '_' masknumber 'mask'],maskindex,1,'.png','_i');
|
---|
| 3585 | imflag=uint8(255*(0.392+0.608*flag));% =100 for flag=0 (vectors not computed when 20<imflag<200)
|
---|
| 3586 | imflag=flipdim(imflag,1);
|
---|
| 3587 | % imflag=uint8(255*flag);% =0 for flag=0 (vectors=0 when 20<imflag<200)
|
---|
[38] | 3588 | msgbox_uvmat('CONFIRMATION',[mask_name ' saved'])
|
---|
[2] | 3589 | imwrite(imflag,mask_name,'BitDepth',8);
|
---|
| 3590 |
|
---|
| 3591 | %display the mask
|
---|
| 3592 | %update_mask(handles,num_i1,num_j1)
|
---|
| 3593 | figure;
|
---|
| 3594 | vec=linspace(0,1,256);%define a linear greyscale colormap
|
---|
| 3595 | map=[vec' vec' vec'];
|
---|
| 3596 | colormap(map)
|
---|
| 3597 |
|
---|
| 3598 | image(imflag);
|
---|
| 3599 |
|
---|
| 3600 | %-------------------------------------------------------------------
|
---|
| 3601 | %-------------------------------------------------------------------
|
---|
| 3602 | % - FUNCTIONS FOR SETTING PLOTTING PARAMETERS
|
---|
| 3603 |
|
---|
| 3604 | %------------------------------------------------------------------
|
---|
| 3605 |
|
---|
| 3606 |
|
---|
| 3607 |
|
---|
| 3608 | %------------------------------------------------------------------
|
---|
| 3609 | % --- Executes on selection change in col_vec: choice of the color code.
|
---|
| 3610 | %
|
---|
| 3611 | function col_vec_Callback(hObject, eventdata, handles)
|
---|
| 3612 | %------------------------------------------------------------------
|
---|
| 3613 | % edit the choice for color code
|
---|
| 3614 | list_code=get(handles.col_vec,'String');% list menu fields
|
---|
| 3615 | index_code=get(handles.col_vec,'Value');% selected string index
|
---|
| 3616 | col_code= list_code{index_code(1)}; % selected field
|
---|
| 3617 | if isequal(col_code,'black') | isequal(col_code,'white')
|
---|
| 3618 | set(handles.slider1,'Visible','off')
|
---|
| 3619 | set(handles.slider2,'Visible','off')
|
---|
| 3620 | set(handles.colcode1,'Visible','off')
|
---|
| 3621 | set(handles.colcode2,'Visible','off')
|
---|
| 3622 | set(handles.AutoVecColor,'Visible','off')
|
---|
| 3623 | set_vec_col_bar(handles)
|
---|
| 3624 | else
|
---|
| 3625 | set(handles.slider1,'Visible','on')
|
---|
| 3626 | set(handles.slider2,'Visible','on')
|
---|
| 3627 | set(handles.colcode1,'Visible','on')
|
---|
| 3628 | set(handles.colcode2,'Visible','on')
|
---|
| 3629 | set(handles.AutoVecColor,'Visible','on')
|
---|
| 3630 | if isequal(col_code,'ima_cor')
|
---|
| 3631 | set(handles.AutoVecColor,'Value',0)%fixed scale by default
|
---|
| 3632 | set(handles.vec_col_bar,'Value',0)% 3 colors r,g,b by default
|
---|
| 3633 | set(handles.slider1,'Min',0);
|
---|
| 3634 | set(handles.slider1,'Max',1);
|
---|
| 3635 | set(handles.slider2,'Min',0);
|
---|
| 3636 | set(handles.slider2,'Max',1);
|
---|
| 3637 | % set(handles.min_title_vec,'String','0')
|
---|
| 3638 | set(handles.max_vec,'String','1')
|
---|
| 3639 | set(handles.colcode1,'String','0.333')
|
---|
| 3640 | colcode1_Callback(hObject, eventdata, handles)
|
---|
| 3641 | set(handles.colcode2,'String','0.666')
|
---|
| 3642 | colcode2_Callback(hObject, eventdata, handles)
|
---|
| 3643 | else
|
---|
| 3644 | set(handles.AutoVecColor,'Value',1)%auto scale between min,max by default
|
---|
| 3645 | set(handles.vec_col_bar,'Value',1)% colormap 'jet' by default
|
---|
| 3646 | minval=get(handles.slider1,'Min');
|
---|
| 3647 | maxval=get(handles.slider1,'Max');
|
---|
| 3648 | set(handles.slider1,'Value',minval)
|
---|
| 3649 | set(handles.slider2,'Value',maxval)
|
---|
| 3650 | set_vec_col_bar(handles)
|
---|
| 3651 | end
|
---|
| 3652 | % slider_update(handles)
|
---|
| 3653 | end
|
---|
| 3654 | %replot the current graph
|
---|
| 3655 | run0_Callback(hObject, eventdata, handles)
|
---|
| 3656 |
|
---|
| 3657 |
|
---|
| 3658 | %----------------------------------------------------------------
|
---|
| 3659 | % -- Executes on slider movement to set the color code
|
---|
| 3660 | %
|
---|
| 3661 | function slider1_Callback(hObject, eventdata, handles)
|
---|
| 3662 | %------------------------------------------------------------------
|
---|
| 3663 | slider1=get(handles.slider1,'Value');
|
---|
| 3664 | min_val=str2num(get(handles.min_vec,'String'));
|
---|
| 3665 | max_val=str2num(get(handles.max_vec,'String'));
|
---|
| 3666 | col=min_val+(max_val-min_val)*slider1;
|
---|
| 3667 | set(handles.colcode1,'String',num2str(col))
|
---|
| 3668 | if(get(handles.slider2,'Value') < col)%move also the second slider at the same value if needed
|
---|
| 3669 | set(handles.slider2,'Value',col)
|
---|
| 3670 | set(handles.colcode2,'String',num2str(col))
|
---|
| 3671 | end
|
---|
| 3672 | colcode1_Callback(hObject, eventdata, handles)
|
---|
| 3673 |
|
---|
| 3674 | %----------------------------------------------------------------
|
---|
| 3675 | % Executes on slider movement to set the color code
|
---|
| 3676 | %----------------------------------------------------------------
|
---|
| 3677 | function slider2_Callback(hObject, eventdata, handles)
|
---|
| 3678 | slider2=get(handles.slider2,'Value');
|
---|
| 3679 | min_val=str2num(get(handles.min_vec,'String'));
|
---|
| 3680 | max_val=str2num(get(handles.max_vec,'String'));
|
---|
| 3681 | col=min_val+(max_val-min_val)*slider2;
|
---|
| 3682 | set(handles.colcode2,'String',num2str(col))
|
---|
| 3683 | if(get(handles.slider1,'Value') > col)%move also the first slider at the same value if needed
|
---|
| 3684 | set(handles.slider1,'Value',col)
|
---|
| 3685 | set(handles.colcode1,'String',num2str(col))
|
---|
| 3686 | end
|
---|
| 3687 | colcode2_Callback(hObject, eventdata, handles)
|
---|
| 3688 |
|
---|
| 3689 | %----------------------------------------------------------------
|
---|
| 3690 | %execute on return carriage on the edit box corresponding to slider 1
|
---|
| 3691 | %----------------------------------------------------------------
|
---|
| 3692 | function colcode1_Callback(hObject, eventdata, handles)
|
---|
| 3693 | % col=str2num(get(handles.colcode1,'String'));
|
---|
| 3694 | % set(handles.slider1,'Value',col)
|
---|
| 3695 | set_vec_col_bar(handles)
|
---|
| 3696 | update_plot(handles)
|
---|
| 3697 |
|
---|
| 3698 | %----------------------------------------------------------------
|
---|
| 3699 | %execute on return carriage on the edit box corresponding to slider 2
|
---|
| 3700 | %----------------------------------------------------------------
|
---|
| 3701 | function colcode2_Callback(hObject, eventdata, handles)
|
---|
| 3702 | % col=str2num(get(handles.colcode2,'String'));
|
---|
| 3703 | % set(handles.slider2,'Value',col)
|
---|
| 3704 | % slider2_Callback(hObject, eventdata, handles)
|
---|
| 3705 | set_vec_col_bar(handles)
|
---|
| 3706 | update_plot(handles)
|
---|
| 3707 | %------------------------------------------------------------
|
---|
| 3708 | %update the slider values after displaying vectors
|
---|
| 3709 | %--------------------------------------------------------
|
---|
| 3710 | % function slider_update(handles,auto,minC,colcode1,colcode2,maxC)
|
---|
| 3711 | % set(handles.slider1,'Min',minC)
|
---|
| 3712 | % set(handles.slider1,'Max',maxC)
|
---|
| 3713 | % set(handles.slider2,'Min',minC)
|
---|
| 3714 | % set(handles.slider2,'Max',maxC)
|
---|
| 3715 | % set(handles.min_title_vec,'String',num2str(minC))
|
---|
| 3716 | % set(handles.max_vec,'String',num2str(maxC))
|
---|
| 3717 | % if auto
|
---|
| 3718 | % set(handles.colcode1,'String',num2str(colcode1,3))%update display
|
---|
| 3719 | % set(handles.colcode2,'String',num2str(colcode2,3))
|
---|
| 3720 | % end
|
---|
| 3721 | % set(handles.slider1,'Value',colcode1)%update slider with constant display
|
---|
| 3722 | % set(handles.slider2,'Value',colcode2)
|
---|
| 3723 | % set_vec_col_bar(handles)
|
---|
| 3724 |
|
---|
| 3725 |
|
---|
| 3726 | %-------------------------------------------------------
|
---|
| 3727 | % --- Executes on button press in AutoVecColor.
|
---|
| 3728 | %-------------------------------------------------------
|
---|
| 3729 | function vec_col_bar_Callback(hObject, eventdata, handles)
|
---|
| 3730 | set_vec_col_bar(handles)
|
---|
| 3731 |
|
---|
| 3732 | % %--------------------------------------------
|
---|
| 3733 | % %update the display of color code for vectors
|
---|
| 3734 | % %--------------------------------------------
|
---|
| 3735 | % function set_vec_col_bar(handles)
|
---|
| 3736 | % %get the image of the color display button 'vec_col_bar' in pixels
|
---|
| 3737 | % uni=get(handles.vec_col_bar,'Unit');
|
---|
| 3738 | % set(handles.vec_col_bar,'Unit','pixel')
|
---|
| 3739 | % pos_vert=get(handles.vec_col_bar,'Position');
|
---|
| 3740 | % set(handles.vec_col_bar,'Unit','Normalized')
|
---|
| 3741 | % width=ceil(pos_vert(3));
|
---|
| 3742 | % height=ceil(pos_vert(4));
|
---|
| 3743 | % %get slider indications
|
---|
| 3744 | % colcode.min=get(handles.slider1,'Min');
|
---|
| 3745 | % colcode.max=get(handles.slider1,'Max');
|
---|
| 3746 | % colcode.colcode1=get(handles.slider1,'Value');
|
---|
| 3747 | % colcode.colcode2=get(handles.slider2,'Value');
|
---|
| 3748 | % colcode.option=get(handles.vec_col_bar,'Value');
|
---|
| 3749 | % colcode.auto=1;
|
---|
| 3750 | % list_code=get(handles.col_vec,'String');% list menu fields
|
---|
| 3751 | % index_code=get(handles.col_vec,'Value');% selected string index
|
---|
| 3752 | % colcode.CName= list_code{index_code(1)}; % selected field used for vector color
|
---|
| 3753 | % vec_C=colcode.min+(colcode.max-colcode.min)*[0.5:width-0.5]/width;%sample of vec_C values from min to max
|
---|
| 3754 | % [colorlist,col_vec]=set_col_vec(colcode,vec_C);
|
---|
| 3755 | % oneheight=ones(1,height);
|
---|
| 3756 | % A1=colorlist(col_vec,1)*oneheight;
|
---|
| 3757 | % A2=colorlist(col_vec,2)*oneheight;
|
---|
| 3758 | % A3=colorlist(col_vec,3)*oneheight;
|
---|
| 3759 | % A(:,:,1)=A1';
|
---|
| 3760 | % A(:,:,2)=A2';
|
---|
| 3761 | % A(:,:,3)=A3';
|
---|
| 3762 | % set(handles.vec_col_bar,'Cdata',A)
|
---|
| 3763 |
|
---|
| 3764 | %--------------------------------------------------------
|
---|
| 3765 | % --- Executes on button press in cal.
|
---|
| 3766 | function cal_Callback(hObject, eventdata, handles)
|
---|
| 3767 |
|
---|
| 3768 |
|
---|
[61] | 3769 |
|
---|
[2] | 3770 | %-------------------------------------------------------------
|
---|
[39] | 3771 | % --- Executes on selection change in transform_fct.
|
---|
| 3772 | function transform_fct_Callback(hObject, eventdata, handles)
|
---|
[2] | 3773 | %-------------------------------------------------------------
|
---|
[39] | 3774 | global nb_builtin
|
---|
| 3775 |
|
---|
| 3776 | huvmat=get(handles.transform_fct,'parent');
|
---|
| 3777 | menu=get(handles.transform_fct,'String');
|
---|
| 3778 | ind_coord=get(handles.transform_fct,'Value');
|
---|
[2] | 3779 | coord_option=menu{ind_coord};
|
---|
[39] | 3780 | list_transform=get(handles.transform_fct,'UserData');
|
---|
[40] | 3781 | ff=functions(list_transform{end});
|
---|
[2] | 3782 | if isequal(coord_option,'more...');
|
---|
| 3783 | coord_fct='';
|
---|
| 3784 | prompt = {'Enter the name of the transform function'};
|
---|
| 3785 | dlg_title = 'user defined transform';
|
---|
| 3786 | num_lines= 1;
|
---|
| 3787 | [FileName, PathName, filterindex] = uigetfile( ...
|
---|
| 3788 | {'*.m', ' (*.m)';
|
---|
| 3789 | '*.m', '.m files '; ...
|
---|
| 3790 | '*.*', 'All Files (*.*)'}, ...
|
---|
[39] | 3791 | 'Pick a file', ff.file);
|
---|
[2] | 3792 | if isequal(PathName(end),'/')||isequal(PathName(end),'\')
|
---|
| 3793 | PathName(end)=[];
|
---|
| 3794 | end
|
---|
[39] | 3795 | transform_selected =fullfile(PathName,FileName);
|
---|
| 3796 | if ~exist(transform_selected,'file')
|
---|
| 3797 | return
|
---|
| 3798 | end
|
---|
| 3799 | [ppp,transform,ext_fct]=fileparts(FileName);% removes extension .m
|
---|
| 3800 | if ~isequal(ext_fct,'.m')
|
---|
| 3801 | msgbox_uvmat('ERROR','a Matlab function .m must be introduced');
|
---|
| 3802 | return
|
---|
| 3803 | end
|
---|
| 3804 | menu=update_menu(handles.transform_fct,transform);%add the selected fct to the menu
|
---|
| 3805 | ind_coord=get(handles.transform_fct,'Value');
|
---|
| 3806 | addpath(PathName)
|
---|
| 3807 | list_transform{ind_coord}=str2func(transform);% create the function handle corresponding to the newly seleced function
|
---|
| 3808 | set(handles.transform_fct,'UserData',list_transform)
|
---|
| 3809 | rmpath(PathName)
|
---|
| 3810 | % save the new menu in the personal file 'uvmat_perso.mat'
|
---|
| 3811 | dir_perso=prefdir;%personal Matalb directory
|
---|
| 3812 | profil_perso=fullfile(dir_perso,'uvmat_perso.mat');
|
---|
| 3813 | if exist(profil_perso,'file')
|
---|
| 3814 | for ilist=nb_builtin+1:numel(list_transform)
|
---|
| 3815 | ff=functions(list_transform{ilist});
|
---|
| 3816 | transform_fct{ilist-nb_builtin}=ff.file;
|
---|
| 3817 | end
|
---|
| 3818 | save (profil_perso,'transform_fct','-append'); %store the root name for future opening of uvmat
|
---|
| 3819 | end
|
---|
[2] | 3820 | end
|
---|
| 3821 |
|
---|
| 3822 | %check the current path to the selected function
|
---|
[40] | 3823 | if isa(list_transform{ind_coord},'function_handle')
|
---|
| 3824 | func=functions(list_transform{ind_coord});
|
---|
| 3825 | set(handles.path_transform,'String',fileparts(func.file)); %show the path to the senlected function
|
---|
| 3826 | else
|
---|
| 3827 | set(handles.path_transform,'String','')
|
---|
| 3828 | end
|
---|
[71] | 3829 |
|
---|
[2] | 3830 | set(handles.FixedLimits,'Value',0)
|
---|
| 3831 | set(handles.FixedLimits,'BackgroundColor',[0.7 0.7 0.7])
|
---|
| 3832 |
|
---|
| 3833 | UvData=get(huvmat,'UserData');
|
---|
| 3834 |
|
---|
| 3835 | %delete drawn objects
|
---|
| 3836 | hother=findobj('Tag','proj_object');%find all the proj objects
|
---|
| 3837 | for iobj=1:length(hother)
|
---|
| 3838 | delete_object(hother(iobj))
|
---|
| 3839 | end
|
---|
| 3840 | hother=findobj('Tag','DeformPoint');%find all the proj objects
|
---|
| 3841 | for iobj=1:length(hother)
|
---|
| 3842 | delete_object(hother(iobj))
|
---|
| 3843 | end
|
---|
| 3844 | hh=findobj('Tag','calib_points');
|
---|
| 3845 | if ~isempty(hh)
|
---|
| 3846 | delete(hh)
|
---|
| 3847 | end
|
---|
| 3848 | hhh=findobj('Tag','calib_marker');
|
---|
| 3849 | if ~isempty(hhh)
|
---|
| 3850 | delete(hhh)
|
---|
| 3851 | end
|
---|
| 3852 | if isfield(UvData,'Object')
|
---|
[71] | 3853 | UvData.Object=UvData.Object(1);
|
---|
[2] | 3854 | end
|
---|
[71] | 3855 | list_object=get(handles.list_object_1,'String');
|
---|
| 3856 | set(handles.list_object_1,'Value',1)
|
---|
| 3857 | set(handles.list_object_1,'String',list_object(1))
|
---|
| 3858 | set(handles.list_object_2,'Value',2)
|
---|
| 3859 | set(handles.list_object_2,'String',[list_object(1);{'...'}])
|
---|
| 3860 | list_object_2_Callback(hObject, eventdata, handles)
|
---|
[2] | 3861 |
|
---|
[71] | 3862 |
|
---|
| 3863 |
|
---|
[2] | 3864 | %delete mask if it is displayed
|
---|
| 3865 | if isequal(get(handles.mask_test,'Value'),1)%if the mask option is on
|
---|
| 3866 | UvData=rmfield(UvData,'MaskName'); %will impose mask refresh
|
---|
| 3867 | end
|
---|
| 3868 | set(huvmat,'UserData',UvData)
|
---|
| 3869 | run0_Callback(hObject, eventdata, handles)
|
---|
| 3870 |
|
---|
| 3871 | %--------------------------------------------
|
---|
| 3872 | function histo1_menu_Callback(hObject, eventdata, handles)
|
---|
| 3873 | %--------------------------------------------
|
---|
| 3874 | %plot first histo
|
---|
| 3875 | huvmat=get(handles.histo1_menu,'parent');
|
---|
| 3876 | histo_menu=get(handles.histo1_menu,'String');
|
---|
| 3877 | histo_value=get(handles.histo1_menu,'Value');
|
---|
| 3878 | FieldName=histo_menu{histo_value};
|
---|
| 3879 | UvData=get(huvmat,'UserData');
|
---|
| 3880 | update_histo(handles.histo_u,huvmat,FieldName)
|
---|
| 3881 |
|
---|
| 3882 | %----------------------------------------------
|
---|
| 3883 | function histo2_menu_Callback(hObject, eventdata, handles)
|
---|
| 3884 | %----------------------------------------------
|
---|
| 3885 | %plot second histo
|
---|
| 3886 | huvmat=get(handles.histo2_menu,'parent');
|
---|
| 3887 | histo_menu=get(handles.histo2_menu,'String');
|
---|
| 3888 | histo_value=get(handles.histo2_menu,'Value');
|
---|
| 3889 | FieldName=histo_menu{histo_value};
|
---|
| 3890 | UvData=get(huvmat,'UserData');
|
---|
| 3891 | update_histo(handles.histo_v,huvmat,FieldName)
|
---|
| 3892 |
|
---|
| 3893 |
|
---|
| 3894 | %--------------------------------------------
|
---|
| 3895 | %read the field .Fieldname stored in UvData and plot its histogram
|
---|
| 3896 | function update_histo(haxes,huvmat,FieldName)
|
---|
| 3897 | UvData=get(huvmat,'UserData');
|
---|
| 3898 |
|
---|
| 3899 | if ~isfield(UvData.Field,FieldName)
|
---|
| 3900 | msgbox_uvmat('ERROR',['no field ' FieldName ' for histogram'])
|
---|
| 3901 | return
|
---|
| 3902 | end
|
---|
| 3903 | Field=UvData.Field;
|
---|
| 3904 | FieldHisto=eval(['Field.' FieldName]);
|
---|
| 3905 | if isfield(Field,'FF') & ~isempty(Field.FF) & isequal(size(Field.FF),size(FieldHisto))
|
---|
| 3906 | indsel=find(Field.FF==0);%find values marked as false
|
---|
| 3907 | if ~isempty(indsel)
|
---|
| 3908 | FieldHisto=FieldHisto(indsel);
|
---|
| 3909 | end
|
---|
| 3910 | end
|
---|
| 3911 | if isempty(Field)
|
---|
| 3912 | msgbox_uvmat('ERROR',['empty field ' FieldName])
|
---|
| 3913 | else
|
---|
| 3914 | nxy=size(FieldHisto);
|
---|
| 3915 | Amin=double(min(min(min(FieldHisto))));%min of image
|
---|
| 3916 | Amax=double(max(max(max(FieldHisto))));%max of image
|
---|
| 3917 | if isequal(Amin,Amax)
|
---|
| 3918 | Histo.Txt=['uniform field =' num2str(Amin)];
|
---|
| 3919 | else
|
---|
| 3920 | Histo.ListVarName={FieldName,'histo'};
|
---|
| 3921 | if numel(nxy)==2
|
---|
| 3922 | Histo.VarDimName={FieldName,FieldName}; %dimensions for the histogram
|
---|
| 3923 | else %color images
|
---|
| 3924 | Histo.VarDimName={FieldName,{FieldName,'rgb'}}; %dimensions for the histogram
|
---|
| 3925 | end
|
---|
| 3926 | %unit
|
---|
| 3927 | units=[]; %default
|
---|
| 3928 | for ivar=1:numel(Field.ListVarName)
|
---|
| 3929 | if strcmp(Field.ListVarName{ivar},FieldName)
|
---|
| 3930 | if isfield(Field,'VarAttribute') && numel(Field.VarAttribute)>=ivar && isfield(Field.VarAttribute{ivar},'units')
|
---|
| 3931 | units=Field.VarAttribute{ivar}.units;
|
---|
| 3932 | break
|
---|
| 3933 | end
|
---|
| 3934 | end
|
---|
| 3935 | end
|
---|
| 3936 | if ~isempty(units)
|
---|
| 3937 | Histo.VarAttribute{1}.units=units;
|
---|
| 3938 | end
|
---|
| 3939 | eval(['Histo.' FieldName '=linspace(Amin,Amax,50);'])%absissa values for histo
|
---|
| 3940 | for col=1:size(FieldHisto,3)
|
---|
| 3941 | B=FieldHisto(:,:,col);
|
---|
| 3942 | C=reshape(double(B),1,nxy(1)*nxy(2));% reshape in a vector
|
---|
| 3943 | eval(['Histo.histo(:,col)=hist(C, Histo.' FieldName ');']); %calculate histogram
|
---|
| 3944 | end
|
---|
| 3945 | set(haxes,'XLimMode','auto')%reset auto mode (after zoom effect)
|
---|
| 3946 | set(haxes,'YLimMode','auto')
|
---|
| 3947 | plot_field(Histo,haxes);
|
---|
| 3948 | end
|
---|
| 3949 | end
|
---|
| 3950 |
|
---|
| 3951 |
|
---|
| 3952 |
|
---|
| 3953 | %------------------------------------------------
|
---|
| 3954 | %CALLBACKS FOR PLOTTING PARAMETERS
|
---|
| 3955 | %-------------------------------------------------
|
---|
| 3956 |
|
---|
| 3957 | %-----------------------------------------------------------------
|
---|
| 3958 | function MinA_Callback(hObject, eventdata, handles)
|
---|
| 3959 | %------------------------------------------
|
---|
| 3960 | set(handles.AutoScal,'Value',1) %suppress auto mode
|
---|
| 3961 | set(handles.AutoScal,'BackgroundColor',[1 1 0])
|
---|
| 3962 | update_plot(handles)
|
---|
| 3963 |
|
---|
| 3964 | %-----------------------------------------------------------------
|
---|
| 3965 | function MaxA_Callback(hObject, eventdata, handles)
|
---|
| 3966 | %--------------------------------------------
|
---|
| 3967 | set(handles.AutoScal,'Value',1) %suppress auto mode
|
---|
| 3968 | set(handles.AutoScal,'BackgroundColor',[1 1 0])
|
---|
| 3969 | update_plot(handles)
|
---|
| 3970 |
|
---|
| 3971 | %-----------------------------------------------
|
---|
| 3972 | function AutoScal_Callback(hObject, eventdata, handles)
|
---|
| 3973 | %--------------------------------------------
|
---|
| 3974 | test=get(handles.AutoScal,'Value');
|
---|
| 3975 | if test
|
---|
| 3976 | set(handles.AutoScal,'BackgroundColor',[1 1 0])
|
---|
| 3977 | else
|
---|
| 3978 | set(handles.AutoScal,'BackgroundColor',[0.7 0.7 0.7])
|
---|
| 3979 | update_plot(handles);
|
---|
| 3980 | % set(handles.MinA,'String',num2str(ScalOut.MinA,3))
|
---|
| 3981 | % set(handles.MaxA,'String',num2str(ScalOut.MaxA,3))
|
---|
| 3982 | end
|
---|
| 3983 |
|
---|
| 3984 | %-------------------------------------------------------------------
|
---|
| 3985 | function BW_Callback(hObject, eventdata, handles)
|
---|
| 3986 | %-------------------------------------------------------------------
|
---|
| 3987 | update_plot(handles)
|
---|
| 3988 |
|
---|
| 3989 | %-------------------------------------------------------------------
|
---|
| 3990 | function Contours_Callback(hObject, eventdata, handles)
|
---|
| 3991 | %-------------------------------------------------------------------
|
---|
| 3992 | val=get(handles.Contours,'Value');
|
---|
| 3993 | if val==2
|
---|
| 3994 | set(handles.interval_txt,'Visible','on')
|
---|
| 3995 | set(handles.IncrA,'Visible','on')
|
---|
| 3996 | else
|
---|
| 3997 | set(handles.interval_txt,'Visible','off')
|
---|
| 3998 | set(handles.IncrA,'Visible','off')
|
---|
| 3999 | end
|
---|
| 4000 | update_plot(handles)
|
---|
| 4001 |
|
---|
| 4002 | %-------------------------------------------------------------------
|
---|
| 4003 | function IncrA_Callback(hObject, eventdata, handles)
|
---|
| 4004 | %-------------------------------------------------------------------
|
---|
| 4005 | update_plot(handles)
|
---|
| 4006 |
|
---|
| 4007 | %-------------------------------------------------------------------
|
---|
| 4008 | function HideWarning_Callback(hObject, eventdata, handles)
|
---|
| 4009 | %-------------------------------------------------------------------
|
---|
| 4010 | update_plot(handles)
|
---|
| 4011 |
|
---|
| 4012 | %-------------------------------------------------------------------
|
---|
| 4013 | function HideFalse_Callback(hObject, eventdata, handles)
|
---|
| 4014 | %-------------------------------------------------------------------
|
---|
| 4015 | update_plot(handles)
|
---|
| 4016 |
|
---|
| 4017 | %-------------------------------------------------------------------
|
---|
| 4018 | function VecScale_Callback(hObject, eventdata, handles)
|
---|
| 4019 | %-------------------------------------------------------------------
|
---|
| 4020 | set(handles.AutoVec,'Value',1);
|
---|
| 4021 | set(handles.AutoVec,'BackgroundColor',[1 1 0])
|
---|
| 4022 | update_plot(handles)
|
---|
| 4023 |
|
---|
| 4024 | %-------------------------------------------------------------------
|
---|
| 4025 | function AutoVec_Callback(hObject, eventdata, handles)
|
---|
| 4026 | %-------------------------------------------------------------------
|
---|
| 4027 | test=get(handles.AutoVec,'Value');
|
---|
| 4028 | if test
|
---|
| 4029 | set(handles.AutoVec,'BackgroundColor',[1 1 0])
|
---|
| 4030 | else
|
---|
| 4031 | update_plot(handles);
|
---|
| 4032 | %set(handles.VecScale,'String',num2str(ScalOut.VecScale,3))
|
---|
| 4033 | set(handles.AutoVec,'BackgroundColor',[0.7 0.7 0.7])
|
---|
| 4034 | end
|
---|
| 4035 |
|
---|
| 4036 | %-------------------------------------------------------
|
---|
| 4037 | % --- Executes on selection change in decimate4 (nb_vec/4).
|
---|
| 4038 | %-------------------------------------------------------
|
---|
| 4039 | function decimate4_Callback(hObject, eventdata, handles)
|
---|
| 4040 | update_plot(handles)
|
---|
| 4041 |
|
---|
| 4042 |
|
---|
| 4043 | %-------------------------------------------------------
|
---|
| 4044 | % --- Executes on selection change in color_code menu
|
---|
| 4045 | %-------------------------------------------------------
|
---|
| 4046 | function color_code_Callback(hObject, eventdata, handles)
|
---|
| 4047 | set_vec_col_bar(handles)
|
---|
| 4048 | update_plot(handles);
|
---|
| 4049 |
|
---|
| 4050 | %-------------------------------------------------------
|
---|
| 4051 | % --- Executes on button press in AutoVecColor.
|
---|
| 4052 | %-------------------------------------------------------
|
---|
| 4053 | function AutoVecColor_Callback(hObject, eventdata, handles)
|
---|
| 4054 | test=get(handles.AutoVecColor,'Value');
|
---|
| 4055 | if test
|
---|
| 4056 | set(handles.AutoVecColor,'BackgroundColor',[1 1 0])
|
---|
| 4057 | else
|
---|
| 4058 | update_plot(handles);
|
---|
| 4059 | %set(handles.VecScale,'String',num2str(ScalOut.VecScale,3))
|
---|
| 4060 | set(handles.AutoVecColor,'BackgroundColor',[0.7 0.7 0.7])
|
---|
| 4061 | end
|
---|
| 4062 | %set_vec_col_bar(handles)
|
---|
| 4063 |
|
---|
| 4064 | %-------------------------------------------------------
|
---|
| 4065 | % --- Executes on selection change in max_vec.
|
---|
| 4066 | %-------------------------------------------------------
|
---|
| 4067 | function min_vec_Callback(hObject, eventdata, handles)
|
---|
| 4068 | max_vec_Callback(hObject, eventdata, handles)
|
---|
| 4069 |
|
---|
| 4070 | % --- Executes on selection change in max_vec.
|
---|
| 4071 | function max_vec_Callback(hObject, eventdata, handles)
|
---|
| 4072 | set(handles.AutoVecColor,'Value',1)
|
---|
| 4073 | AutoVecColor_Callback(hObject, eventdata, handles)
|
---|
| 4074 | min_val=str2num(get(handles.min_vec,'String'));
|
---|
| 4075 | max_val=str2num(get(handles.max_vec,'String'));
|
---|
| 4076 | slider1=get(handles.slider1,'Value');
|
---|
| 4077 | slider2=get(handles.slider2,'Value');
|
---|
| 4078 | colcode1=min_val+(max_val-min_val)*slider1;
|
---|
| 4079 | colcode2=min_val+(max_val-min_val)*slider2;
|
---|
| 4080 | set(handles.colcode1,'String',num2str(colcode1))
|
---|
| 4081 | set(handles.colcode2,'String',num2str(colcode2))
|
---|
| 4082 | update_plot(handles);
|
---|
| 4083 |
|
---|
| 4084 | %-------------------------------------------------------------------
|
---|
| 4085 | %update the display of color code for vectors
|
---|
| 4086 | function set_vec_col_bar(handles)
|
---|
| 4087 | %-------------------------------------------------------------------
|
---|
| 4088 | %get the image of the color display button 'vec_col_bar' in pixels
|
---|
| 4089 | set(handles.vec_col_bar,'Unit','pixel');
|
---|
| 4090 | pos_vert=get(handles.vec_col_bar,'Position');
|
---|
| 4091 | set(handles.vec_col_bar,'Unit','Normalized');
|
---|
| 4092 | width=ceil(pos_vert(3));
|
---|
| 4093 | height=ceil(pos_vert(4));
|
---|
| 4094 |
|
---|
| 4095 | %get slider indications
|
---|
| 4096 | list=get(handles.color_code,'String');
|
---|
| 4097 | ichoice=get(handles.color_code,'Value');
|
---|
| 4098 | colcode.ColorCode=list{ichoice};
|
---|
| 4099 | colcode.MinC=str2num(get(handles.min_vec,'String'));
|
---|
| 4100 | colcode.MaxC=str2num(get(handles.max_vec,'String'));
|
---|
| 4101 | test3color=strcmp(colcode.ColorCode,'rgb') || strcmp(colcode.ColorCode,'bgr');
|
---|
| 4102 | if test3color
|
---|
| 4103 | colcode.colcode1=str2num(get(handles.colcode1,'String'));
|
---|
| 4104 | colcode.colcode2=str2num(get(handles.colcode2,'String'));
|
---|
| 4105 | end
|
---|
| 4106 | % colcode.option=get(handles.vec_col_bar,'Value');
|
---|
| 4107 | colcode.FixedCbounds=0;
|
---|
| 4108 | % list_code=get(handles.col_vec,'String');% list menu fields
|
---|
| 4109 | % index_code=get(handles.col_vec,'Value');% selected string index
|
---|
| 4110 | % colcode.CName= list_code{index_code(1)}; % selected field used for vector color
|
---|
| 4111 | colcode.FixedCbounds=1;
|
---|
| 4112 | vec_C=colcode.MinC+(colcode.MaxC-colcode.MinC)*[0.5:width-0.5]/width;%sample of vec_C values from min to max
|
---|
| 4113 | [colorlist,col_vec]=set_col_vec(colcode,vec_C);
|
---|
| 4114 | oneheight=ones(1,height);
|
---|
| 4115 | A1=colorlist(col_vec,1)*oneheight;
|
---|
| 4116 | A2=colorlist(col_vec,2)*oneheight;
|
---|
| 4117 | A3=colorlist(col_vec,3)*oneheight;
|
---|
| 4118 | A(:,:,1)=A1';
|
---|
| 4119 | A(:,:,2)=A2';
|
---|
| 4120 | A(:,:,3)=A3';
|
---|
| 4121 | set(handles.vec_col_bar,'Cdata',A)
|
---|
| 4122 |
|
---|
| 4123 |
|
---|
| 4124 | %-------------------------------------------------------------------
|
---|
| 4125 | function [PlotType,ScalOut]=update_plot(handles)
|
---|
| 4126 | %-------------------------------------------------------------------
|
---|
| 4127 | haxes= handles.axes3;
|
---|
| 4128 | AxeData=get(haxes,'UserData');
|
---|
| 4129 | PlotParam=read_plot_param(handles);
|
---|
| 4130 | [PlotType,PlotParamOut]= plot_field(AxeData,haxes,PlotParam,1);
|
---|
| 4131 | write_plot_param(handles,PlotParamOut); %update the auto plot parameters
|
---|
| 4132 |
|
---|
| 4133 | %-------------------------------------------------------------------
|
---|
| 4134 | % --- Executes on button press in grid.
|
---|
| 4135 | function grid_Callback(hObject, eventdata, handles)
|
---|
| 4136 | %-------------------------------------------------------------------
|
---|
| 4137 |
|
---|
[61] | 4138 | UvData=get(handles.uvmat,'UserData');%read UvData properties stored on the uvmat interface
|
---|
| 4139 |
|
---|
[2] | 4140 | %suppress the other options if grid is chosen
|
---|
| 4141 | set(handles.edit_vect,'Value',0)
|
---|
| 4142 | edit_vect_Callback(hObject, eventdata, handles)
|
---|
| 4143 | set(handles.edit,'BackgroundColor',[0.7 0.7 0.7])
|
---|
| 4144 | set(handles.edit_vect,'Value',0)
|
---|
| 4145 | edit_vect_Callback(hObject, eventdata, handles)
|
---|
| 4146 | set(handles.edit,'BackgroundColor',[0.7 0.7 0.7])
|
---|
[61] | 4147 | set(handles.list_object_1,'Value',1)
|
---|
[2] | 4148 |
|
---|
| 4149 | %prepare display of the set_grid GUI
|
---|
| 4150 | data.fixedtitle=1;
|
---|
| 4151 | FileName=read_file_boxes(handles);
|
---|
| 4152 | [hset_object,UvData.sethandles]=set_grid(FileName);% call the set_object interface
|
---|
[73] | 4153 | set(handles.uvmat,'UserData',UvData);
|
---|
[2] | 4154 |
|
---|
| 4155 |
|
---|
| 4156 | %-------------------------------------------------------------------
|
---|
| 4157 | % --- Executes on selection change in edit.
|
---|
| 4158 | function edit_Callback(hObject, eventdata, handles)
|
---|
| 4159 | %-------------------------------------------------------------------
|
---|
[61] | 4160 | UvData=get(handles.uvmat,'UserData');%read UvData properties stored on the uvmat interface
|
---|
[2] | 4161 | test=get(handles.edit,'Value');
|
---|
| 4162 | if test
|
---|
| 4163 | UvData.MouseAction='edit_object';
|
---|
| 4164 | set(handles.edit,'BackgroundColor',[1,1,0])
|
---|
| 4165 | %suppress the other options
|
---|
| 4166 | set(handles.zoom,'Value',0)
|
---|
| 4167 | zoom_Callback(hObject, eventdata, handles)
|
---|
| 4168 | set(handles.edit_vect,'Value',0)
|
---|
| 4169 | edit_vect_Callback(hObject, eventdata, handles)
|
---|
[61] | 4170 | %list_object_Callback(hObject, eventdata, handles)
|
---|
[2] | 4171 | else
|
---|
| 4172 | UvData.MouseAction='none';
|
---|
| 4173 | set(handles.edit,'BackgroundColor',[0.7,0.7,0.7])
|
---|
| 4174 | end
|
---|
[61] | 4175 | set(handles.uvmat,'UserData',UvData);
|
---|
| 4176 | hset_object=findobj(allchild(0),'Tag','set_object');
|
---|
| 4177 | if ~isempty(hset_object)
|
---|
| 4178 | hhset_object=guidata(hset_object);
|
---|
| 4179 | if test
|
---|
[71] | 4180 | set(hhset_object.PLOT,'enable','on');
|
---|
[61] | 4181 | else
|
---|
[71] | 4182 | set(hhset_object.PLOT,'enable','off');
|
---|
[61] | 4183 | end
|
---|
| 4184 | end
|
---|
[2] | 4185 |
|
---|
[61] | 4186 | %------------------------------------------------------------------------
|
---|
| 4187 | % --- Executes on selection change in list_object_1.
|
---|
| 4188 | function list_object_1_Callback(hObject, eventdata, handles)
|
---|
| 4189 | %------------------------------------------------------------------------
|
---|
| 4190 | list_str=get(handles.list_object_1,'String');
|
---|
| 4191 | IndexObj=get(handles.list_object_1,'Value');
|
---|
| 4192 | str_1=list_str{IndexObj};
|
---|
| 4193 | val_2=get(handles.list_object_2,'Value');
|
---|
| 4194 | str_2=get(handles.list_object_2,'String');
|
---|
[71] | 4195 | if isequal(val_2,IndexObj)% if the first selection is equal to the second, it will suppress the second
|
---|
| 4196 | set(handles.list_object_2,'Value',numel(str_2))%select the end of the list ('...')
|
---|
[61] | 4197 | list_object_2_Callback(hObject, eventdata, handles)
|
---|
| 4198 | end
|
---|
[71] | 4199 | update_object(handles,IndexObj,1,str_1)
|
---|
[61] | 4200 |
|
---|
| 4201 | %------------------------------------------------------------------------
|
---|
| 4202 | % --- Executes on selection change in list_object_1.
|
---|
| 4203 | function list_object_2_Callback(hObject, eventdata, handles)
|
---|
| 4204 | %------------------------------------------------------------------------
|
---|
| 4205 | list_str=get(handles.list_object_2,'String');
|
---|
| 4206 | IndexObj=get(handles.list_object_2,'Value');
|
---|
| 4207 | if isequal(list_str{IndexObj},'...')
|
---|
[71] | 4208 | hview_field=findobj(allchild(0),'Tag','view_field');
|
---|
[61] | 4209 | if ~isempty(hview_field)
|
---|
| 4210 | delete(hview_field)
|
---|
| 4211 | end
|
---|
| 4212 | else
|
---|
[71] | 4213 | update_object(handles,IndexObj,2,list_str{IndexObj})
|
---|
[61] | 4214 | end
|
---|
| 4215 |
|
---|
| 4216 | %------------------------------------------------------------------------
|
---|
[71] | 4217 | function update_object(handles,IndexObj,option,ObjectName)
|
---|
[61] | 4218 | %------------------------------------------------------------------------
|
---|
[60] | 4219 | UvData=get(handles.uvmat,'UserData');%read UvData properties stored on the uvmat interface
|
---|
[2] | 4220 | if ~(length(UvData.Object)>=IndexObj);
|
---|
| 4221 | return
|
---|
| 4222 | end
|
---|
| 4223 | ObjectData=UvData.Object{IndexObj};
|
---|
[71] | 4224 | ObjectData.Name=ObjectName;
|
---|
| 4225 | if isequal(get(handles.edit,'Value'),1)
|
---|
| 4226 | ObjectData.enable_plot=1; % desable the PLOT option in the set_object GUI (editing mode
|
---|
[2] | 4227 | end
|
---|
| 4228 | PlotHandles=get_plot_handles(handles);%get the handles of the interface elements setting the plotting parameters
|
---|
| 4229 | ZBounds=0; % default
|
---|
| 4230 | if isfield(UvData,'ZMin') && isfield(UvData,'ZMax')
|
---|
| 4231 | ZBounds(1)=UvData.ZMin; %minimum for the Z slider
|
---|
| 4232 | ZBounds(2)=UvData.ZMax;%maximum for the Z slider
|
---|
| 4233 | end
|
---|
[71] | 4234 | hset_object=findobj(allchild(0),'tag','set_object');
|
---|
[61] | 4235 | if ~isempty(hset_object)
|
---|
| 4236 | delete(hset_object)% delete existing version of set_object
|
---|
| 4237 | end
|
---|
| 4238 | hset_object=set_object(ObjectData,PlotHandles,ZBounds);% call the set_object interface,
|
---|
[71] | 4239 | set(hset_object,'name',ObjectName)
|
---|
[60] | 4240 | pos_uvmat=get(handles.uvmat,'Position');
|
---|
[61] | 4241 | %position the set_object GUI with respect to uvmat
|
---|
[2] | 4242 | if isfield(UvData,'SetObjectOrigin')
|
---|
[61] | 4243 | pos_set_object(1:2)=UvData.SetObjectOrigin + pos_uvmat(1:2);
|
---|
| 4244 | pos_set_object(3:4)=UvData.SetObjectSize .* pos_uvmat(3:4);
|
---|
| 4245 | set(hset_object,'Position',pos_set_object)
|
---|
[2] | 4246 | end
|
---|
[60] | 4247 |
|
---|
| 4248 | %project the current field on the object and plot it
|
---|
| 4249 | ProjData= proj_field(UvData.Field,ObjectData,IndexObj);%project the current interface field on ObjectData
|
---|
[61] | 4250 | if option==1%length(UvData.Object)>= IndexObj && isfield(UvData.Object{IndexObj},'plotaxes')&& ishandle(UvData.Object{IndexObj}.plotaxes)
|
---|
| 4251 | plot_field(ProjData,handles.axes3,PlotHandles);
|
---|
| 4252 | UvData.Object{IndexObj}.plotaxes=handles.axes3;
|
---|
[60] | 4253 | else
|
---|
[61] | 4254 | UvData.Object{IndexObj}.plotaxes=view_field(ProjData);
|
---|
[60] | 4255 | end
|
---|
| 4256 |
|
---|
[2] | 4257 | hother=findobj('Tag','proj_object');%find all the proj objects
|
---|
| 4258 | for iobj=1:length(hother)
|
---|
| 4259 | if isequal(get(hother(iobj),'Type'),'rectangle')|isequal(get(hother(iobj),'Type'),'patch')
|
---|
| 4260 | set(hother(iobj),'EdgeColor','b')
|
---|
| 4261 | if isequal(get(hother(iobj),'FaceColor'),'m')
|
---|
| 4262 | set(hother(iobj),'FaceColor','b')
|
---|
| 4263 | end
|
---|
| 4264 | elseif isequal(get(hother(iobj),'Type'),'image')
|
---|
| 4265 | Acolor=get(hother(iobj),'CData');
|
---|
| 4266 | Acolor(:,:,1)=zeros(size(Acolor,1),size(Acolor,2));
|
---|
| 4267 | set(hother(iobj),'CData',Acolor);
|
---|
| 4268 | else
|
---|
| 4269 | set(hother(iobj),'Color','b')
|
---|
| 4270 | end
|
---|
| 4271 | set(hother(iobj),'Selected','off')
|
---|
| 4272 | end
|
---|
| 4273 | hother=findobj('Tag','DeformPoint');
|
---|
| 4274 | set(hother,'Color','b');
|
---|
| 4275 | set(hother,'Selected','off')
|
---|
| 4276 | if isfield(ObjectData,'HandlesDisplay')
|
---|
| 4277 | for iview=1:length(ObjectData.HandlesDisplay)
|
---|
| 4278 | if ishandle(ObjectData.HandlesDisplay(iview))
|
---|
| 4279 | uistack(ObjectData.HandlesDisplay(iview),'top')
|
---|
| 4280 | linetype=get(ObjectData.HandlesDisplay(iview),'Type');
|
---|
| 4281 | if isequal(linetype,'line')
|
---|
| 4282 | set(ObjectData.HandlesDisplay(iview),'Color','m'); %set the selected object to magenta color
|
---|
| 4283 | elseif isequal(linetype,'rectangle')
|
---|
| 4284 | set(ObjectData.HandlesDisplay(iview),'EdgeColor','m'); %set the selected object to magenta color
|
---|
| 4285 | elseif isequal(linetype,'patch')
|
---|
| 4286 | set(ObjectData.HandlesDisplay(iview),'FaceColor','m'); %set the selected object to magenta color
|
---|
| 4287 | end
|
---|
| 4288 | SubObjectData=get(ObjectData.HandlesDisplay(iview),'UserData');
|
---|
| 4289 | if isfield(SubObjectData,'SubObject')& ishandle(SubObjectData.SubObject)
|
---|
| 4290 | uistack(SubObjectData.SubObject,'top')
|
---|
| 4291 | for iobj=1:length(SubObjectData.SubObject)
|
---|
| 4292 | hsub=SubObjectData.SubObject(iobj);
|
---|
| 4293 | if isequal(get(hsub,'Type'),'rectangle')
|
---|
| 4294 | set(hsub,'EdgeColor','m'); %set the selected object to magenta color
|
---|
| 4295 | elseif isequal(get(hsub,'Type'),'image')
|
---|
| 4296 | Acolor=get(hsub,'CData');
|
---|
| 4297 | Acolor(:,:,1)=Acolor(:,:,3);
|
---|
| 4298 | set(hsub,'CData',Acolor);
|
---|
| 4299 | else
|
---|
| 4300 | set(hsub,'Color','m')
|
---|
| 4301 | end
|
---|
| 4302 | end
|
---|
| 4303 | end
|
---|
| 4304 | if isfield(SubObjectData,'DeformPoint')& ishandle(SubObjectData.DeformPoint)
|
---|
| 4305 | set(SubObjectData.DeformPoint,'Color','m')
|
---|
| 4306 | end
|
---|
| 4307 | end
|
---|
| 4308 | end
|
---|
| 4309 | end
|
---|
[61] | 4310 | pause(0.1)
|
---|
| 4311 | figure(hset_object)%put set_object in front
|
---|
[2] | 4312 |
|
---|
| 4313 | %------------------------------------------------------
|
---|
| 4314 | % --- Executes on button press in Menu/Export/field in workspace.
|
---|
| 4315 | %------------------------------------------------------
|
---|
| 4316 | function MenuExportField_Callback(hObject, eventdata, handles)
|
---|
| 4317 | global CurData
|
---|
[71] | 4318 | huvmat=findobj(allchild(0),'Name','uvmat');
|
---|
| 4319 | UvData=get(huvmat,'UserData');
|
---|
| 4320 | CurData=UvData.ProjField_1;
|
---|
[2] | 4321 | evalin('base','global CurData')%make CurData global in the workspace
|
---|
[71] | 4322 | display(['UserData of view_field :'])
|
---|
[2] | 4323 | evalin('base','CurData') %display CurData in the workspace
|
---|
| 4324 | commandwindow;
|
---|
| 4325 |
|
---|
| 4326 | %------------------------------------------------------
|
---|
| 4327 | % --- Executes on button press in Menu/Export/extract figure.
|
---|
| 4328 | %------------------------------------------------------
|
---|
| 4329 | function MenuExport_plot_Callback(hObject, eventdata, handles)
|
---|
| 4330 | huvmat=get(handles.MenuExport_plot,'parent');
|
---|
| 4331 | UvData=get(huvmat,'UserData');
|
---|
| 4332 | hfig=figure;
|
---|
| 4333 | newaxes=copyobj(handles.axes3,hfig);
|
---|
| 4334 | map=colormap(handles.axes3);
|
---|
| 4335 | colormap(map);%transmit the current colormap to the zoom fig
|
---|
| 4336 | colorbar
|
---|
| 4337 |
|
---|
| 4338 |
|
---|
| 4339 | % --------------------------------------------------------------------
|
---|
| 4340 | function Insert_Callback(hObject, eventdata, handles)
|
---|
| 4341 |
|
---|
| 4342 |
|
---|
| 4343 | % --------------------------------------------------------------------
|
---|
| 4344 | function MenuHelp_Callback(hObject, eventdata, handles)
|
---|
| 4345 | % --------------------------------------------------------------------
|
---|
| 4346 | path_to_uvmat=which ('uvmat');% check the path of uvmat
|
---|
| 4347 | pathelp=fileparts(path_to_uvmat);
|
---|
[36] | 4348 | helpfile=fullfile(pathelp,'uvmat_doc','uvmat_doc.html');
|
---|
| 4349 | 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] | 4350 | else
|
---|
[36] | 4351 | addpath (fullfile(pathelp,'uvmat_doc'))
|
---|
[2] | 4352 | web(helpfile);
|
---|
| 4353 | end
|
---|
| 4354 |
|
---|
| 4355 |
|
---|
| 4356 | % --------------------------------------------------------------------
|
---|
| 4357 | function MenuExportMovie_Callback(hObject, eventdata, handles)
|
---|
| 4358 | % --------------------------------------------------------------------
|
---|
| 4359 | set(handles.MenuExportMovie,'BusyAction','queue')% activate the button
|
---|
| 4360 | huvmat=get(handles.run0,'parent');
|
---|
| 4361 | UvData=get(huvmat,'UserData');
|
---|
| 4362 | [xx,xx,FileBase]=read_file_boxes(handles);
|
---|
| 4363 | %read the current input file name
|
---|
| 4364 | 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)'};
|
---|
| 4365 | dlg_title = 'select properties of the output avi movie';
|
---|
| 4366 | num_lines= 1;
|
---|
| 4367 | nbfield_cell=get(handles.last_i,'String');
|
---|
| 4368 | def = {[FileBase '_out.avi'];'10';'1';'[0.03 0.05 0.95 0.92]';'10'};
|
---|
| 4369 | answer = inputdlg(prompt,dlg_title,num_lines,def,'on');
|
---|
| 4370 | aviname=answer{1};
|
---|
| 4371 | fps=str2num(answer{2});
|
---|
| 4372 | % check for existing file with output name aviname
|
---|
| 4373 | if exist(aviname,'file')
|
---|
| 4374 | backup=aviname;
|
---|
| 4375 | testexist=2;
|
---|
| 4376 | while testexist==2
|
---|
| 4377 | backup=[backup '~'];
|
---|
| 4378 | testexist=exist(backup,'file');
|
---|
| 4379 | end
|
---|
| 4380 | [success,message]=copyfile(aviname,backup);%make backup of the existing file
|
---|
| 4381 | if isequal(success,1)
|
---|
| 4382 | delete(aviname)%delete existing file
|
---|
| 4383 | else
|
---|
| 4384 | msgbox_uvmat('ERROR',message)
|
---|
| 4385 | return
|
---|
| 4386 | end
|
---|
| 4387 | end
|
---|
| 4388 | %create avi open
|
---|
| 4389 | aviobj=avifile(aviname,'Compression','None','fps',fps);
|
---|
| 4390 |
|
---|
| 4391 | %display first view for tests
|
---|
| 4392 | newfig=figure;
|
---|
| 4393 | newaxes=copyobj(handles.axes3,newfig);%new plotting axes in the new figure
|
---|
| 4394 | set(newaxes,'Tag','movieaxes')
|
---|
| 4395 | nbpix=[512 384]*str2num(answer{3});
|
---|
| 4396 | set(gcf,'Position',[1 1 nbpix])% resolution XVGA
|
---|
| 4397 | set(newaxes,'Position',eval(answer{4}));
|
---|
| 4398 | map=colormap(handles.axes3);
|
---|
| 4399 | colormap(map);%transmit the current colormap to the zoom fig
|
---|
| 4400 | msgbox_uvmat('INPUT_Y-N',{['adjust figure ' num2str(newfig) ' with its matlab edit menu '] ;...
|
---|
| 4401 | ['then press OK to get the avi movie as a copy of figure ' num2str(newfig) ' display']});
|
---|
| 4402 | UvData.Object{1}.plotaxes=newaxes;% the axis in the new figure becomes the current main plotting axes
|
---|
| 4403 | set(huvmat,'UserData',UvData);
|
---|
| 4404 | increment=str2num(get(handles.increment_scan,'String')); %get the field increment d
|
---|
| 4405 | set(handles.STOP,'Visible','on')
|
---|
| 4406 | set(handles.speed,'Visible','on')
|
---|
| 4407 | set(handles.speed_txt,'Visible','on')
|
---|
| 4408 | set(handles.RunMovie,'BusyAction','queue')
|
---|
| 4409 |
|
---|
| 4410 | imin=str2num(get(handles.i1,'String'));
|
---|
| 4411 | imax=str2num(answer{5});
|
---|
| 4412 | % if isfield(UvData,'Time')
|
---|
| 4413 | htitle=get(newaxes,'Title');
|
---|
| 4414 | xlim=get(newaxes,'XLim');
|
---|
| 4415 | ylim=get(newaxes,'YLim');
|
---|
| 4416 | set(htitle,'Position',[xlim(2)+0.07*(xlim(2)-xlim(1)) ylim(2)-0.05*(ylim(2)-ylim(1)) 0])
|
---|
| 4417 | time_str=get(handles.abs_time,'String');
|
---|
| 4418 | set(htitle,'String',['t=' time_str])
|
---|
| 4419 | set(handles.speed,'Value',1)
|
---|
| 4420 | for i=1:imax
|
---|
| 4421 | if get(handles.speed,'Value')~=0 & isequal(get(handles.MenuExportMovie,'BusyAction'),'queue') % enable STOP command
|
---|
| 4422 | runpm(hObject,eventdata,handles,increment)
|
---|
| 4423 | drawnow
|
---|
| 4424 | time_str=get(handles.abs_time,'String');
|
---|
| 4425 | if ishandle(htitle)
|
---|
| 4426 | set(htitle,'String',['t=' time_str])
|
---|
| 4427 | end
|
---|
| 4428 | mov=getframe(newfig);
|
---|
| 4429 | aviobj=addframe(aviobj,mov);
|
---|
| 4430 | end
|
---|
| 4431 | end
|
---|
| 4432 | aviobj=close(aviobj);
|
---|
| 4433 | UvData.Object{1}.plotaxes=handles.axes3;
|
---|
| 4434 | set(huvmat,'UserData',UvData);
|
---|
| 4435 | msgbox_uvmat('CONFIRMATION',{['movie ' aviname ' created '];['with ' num2str(imax) ' frames']})
|
---|
| 4436 |
|
---|
| 4437 |
|
---|
| 4438 | % ------------------------------------------------------------------
|
---|
| 4439 | function MenuCalib_Callback(hObject, eventdata, handles)
|
---|
[71] | 4440 |
|
---|
[61] | 4441 | UvData=get(handles.uvmat,'UserData');%read UvData properties stored on the uvmat interface
|
---|
[71] | 4442 |
|
---|
| 4443 | %suppress competing options
|
---|
[61] | 4444 | set(handles.zoom,'Value',0)
|
---|
| 4445 | set(handles.zoom,'BackgroundColor',[0.7 0.7 0.7])
|
---|
[71] | 4446 | set(handles.MenuMask,'enable','off')
|
---|
| 4447 | set(handles.MenuGrid,'enable','off')
|
---|
[67] | 4448 | set(handles.MenuObject,'enable','off')
|
---|
| 4449 | set(handles.MenuEdit,'enable','off')
|
---|
[61] | 4450 | set(handles.list_object_1,'Value',1)
|
---|
| 4451 | % initiate display of GUI geometry_calib
|
---|
| 4452 | data=[]; %default
|
---|
| 4453 | if isfield(UvData,'CoordType')
|
---|
| 4454 | data.CoordType=UvData.CoordType;
|
---|
| 4455 | end
|
---|
| 4456 | pos=get(handles.uvmat,'Position');
|
---|
| 4457 | pos(1)=pos(1)+pos(3)-0.311+0.04; %0.311= width of the geometry_calib interface (units relative to the srcreen)
|
---|
| 4458 | pos(2)=pos(2)-0.02;
|
---|
| 4459 | [FileName,RootPath,FileBase,FileIndices,FileExt,SubDir]=read_file_boxes(handles);
|
---|
| 4460 | [UvData.hset_object,UvData.sethandles]=geometry_calib(handles,pos,FileName);% call the set_object interface
|
---|
| 4461 | pos_uvmat=get(handles.uvmat,'Position');
|
---|
[71] | 4462 |
|
---|
[61] | 4463 | if isfield(UvData,'CalOrigin')
|
---|
| 4464 | pos_cal(1)=pos_uvmat(1)+UvData.CalOrigin(1)*pos_uvmat(3);
|
---|
| 4465 | pos_cal(2)=pos_uvmat(2)+UvData.CalOrigin(2)*pos_uvmat(4);
|
---|
| 4466 | pos_cal(3:4)=UvData.CalSize .* pos_uvmat(3:4);
|
---|
| 4467 | set(UvData.hset_object,'Position',pos_cal)
|
---|
| 4468 | end
|
---|
| 4469 | UvData.MouseAction='calib';
|
---|
| 4470 | set(handles.uvmat,'UserData',UvData);
|
---|
[2] | 4471 |
|
---|
[61] | 4472 |
|
---|
[2] | 4473 | % ------------------------------------------------------------------
|
---|
| 4474 | function MenuMask_Callback(hObject, eventdata, handles)
|
---|
| 4475 | set(handles.TOOLS_txt,'Visible','on')
|
---|
| 4476 | set(handles.frame_tools,'Visible','on')
|
---|
[61] | 4477 | % set(handles.create,'Visible','on')
|
---|
| 4478 | % set(handles.create,'Value',1)
|
---|
| 4479 | % set(handles.create,'BackgroundColor',[1 1 0]) %visualise in yellow
|
---|
[2] | 4480 | set(handles.save_mask,'Visible','on')
|
---|
| 4481 | set(handles.masklevel,'Visible','on')
|
---|
| 4482 | if isequal(get(handles.z_index,'Visible'),'on')
|
---|
| 4483 | nb_slice=str2num(get(handles.nb_slice,'String'));
|
---|
| 4484 | for ilist=1:nb_slice
|
---|
| 4485 | list_index{ilist,1}=num2str(ilist);
|
---|
| 4486 | end
|
---|
| 4487 | set(handles.masklevel,'String',list_index)
|
---|
| 4488 | val=str2num(get(handles.z_index,'String'));
|
---|
| 4489 | if val<=nb_slice
|
---|
| 4490 | set(handles.masklevel,'Value',val)
|
---|
| 4491 | end
|
---|
| 4492 | else
|
---|
| 4493 | set(handles.masklevel,'String',{'1'})
|
---|
| 4494 | set(handles.masklevel,'Value',1)
|
---|
| 4495 | end
|
---|
| 4496 | if ishandle(handles.UVMAT_title)
|
---|
| 4497 | delete(handles.UVMAT_title)
|
---|
| 4498 | end
|
---|
[61] | 4499 | % huvmat=get(handles.create,'parent');
|
---|
| 4500 | UvData=get(handles.uvmat,'UserData');%read UvData properties stored on the uvmat interface
|
---|
[2] | 4501 | set(handles.zoom,'Value',0)
|
---|
| 4502 | set(handles.zoom,'BackgroundColor',[0.7 0.7 0.7])
|
---|
| 4503 | set(handles.edit_vect,'Value',0)
|
---|
| 4504 | edit_vect_Callback(hObject, eventdata, handles)
|
---|
| 4505 | set(handles.edit,'Value',0)
|
---|
| 4506 | set(handles.edit,'BackgroundColor',[0.7 0.7 0.7])
|
---|
| 4507 | set(handles.edit_vect,'Value',0)
|
---|
| 4508 | edit_vect_Callback(hObject, eventdata, handles)
|
---|
[61] | 4509 | % set(handles.cal,'Value',0)
|
---|
| 4510 | % set(handles.cal,'BackgroundColor',[0 1 0])
|
---|
[2] | 4511 |
|
---|
| 4512 | %initiate the GUI set_object
|
---|
| 4513 | data.TITLE='MASK';
|
---|
| 4514 | if isfield(UvData,'CoordType')
|
---|
| 4515 | data.CoordType=UvData.CoordType;
|
---|
| 4516 | end
|
---|
| 4517 | if isfield(UvData,'Mesh')&&~isempty(UvData.Mesh)
|
---|
| 4518 | data.YMax=UvData.Mesh;
|
---|
| 4519 | elseif isfield(UvData.Field,'AX')&&isfield(UvData.Field,'AY')&& isfield(UvData.Field,'A')%only image
|
---|
| 4520 | np=size(UvData.Field.A);
|
---|
| 4521 | meshx=(UvData.Field.AX(end)-UvData.Field.AX(1))/(np(2)-1);
|
---|
| 4522 | meshy=abs(UvData.Field.AY(end)-UvData.Field.AY(1))/(np(1)-1);
|
---|
| 4523 | data.YMax=max(meshx,meshy);
|
---|
| 4524 | data.DX=max(meshx,meshy);
|
---|
| 4525 | end
|
---|
| 4526 | data.Coord=[0 0 0]; %default
|
---|
| 4527 | PlotHandles=get_plot_handles(handles);%get the handles of the graphic objects setting the plotting parameters
|
---|
| 4528 | [hset_object,UvData.sethandles]=set_object(data,PlotHandles);% call the set_object interface
|
---|
[61] | 4529 | pos_uvmat=get(handles.huvmat,'Position');
|
---|
[2] | 4530 | if isfield(UvData,'SetObjectOrigin')
|
---|
| 4531 | pos_set_object(1:2)=UvData.SetObjectOrigin + pos_uvmat(1:2);
|
---|
| 4532 | pos_set_object(3:4)=UvData.SetObjectSize .* pos_uvmat(3:4);
|
---|
| 4533 | set(hset_object,'Position',pos_set_object)
|
---|
| 4534 | end
|
---|
[61] | 4535 | list_object=get(handles.list_object_1,'String');
|
---|
[2] | 4536 | if ~isempty(list_object)
|
---|
[61] | 4537 | set(handles.list_object_1,'Value',length(list_object))
|
---|
[2] | 4538 | end
|
---|
| 4539 | UvData.MouseAction='create_object';
|
---|
[61] | 4540 | set(handles.uvmat,'UserData',UvData);
|
---|
[2] | 4541 |
|
---|
| 4542 | % ------------------------------------------------------------------
|
---|
| 4543 | %-- open the GUI set_grid.fig to create grid
|
---|
| 4544 | function MenuGrid_Callback(hObject, eventdata, handles)
|
---|
| 4545 | set(handles.TOOLS_txt,'Visible','on')
|
---|
| 4546 | set(handles.frame_tools,'Visible','on')
|
---|
| 4547 | grid_Callback(hObject,eventdata,handles)
|
---|
| 4548 |
|
---|
| 4549 | %----------------------------------------------------------------
|
---|
| 4550 | % open the GUI 'series'
|
---|
| 4551 | %----------------------------------------------------------------
|
---|
| 4552 | function MenuSeries_Callback(hObject, eventdata, handles)
|
---|
[40] | 4553 | %-------------------------------------------------------------------
|
---|
[2] | 4554 |
|
---|
| 4555 | [param.FileName]=read_file_boxes(handles);
|
---|
| 4556 | if isequal(get(handles.SubField,'Value'),1)
|
---|
| 4557 | FileName_1=read_file_boxes_1(handles);%
|
---|
| 4558 | if ~isequal(FileName_1,param.FileName)
|
---|
| 4559 | param.FileName_1=FileName_1;
|
---|
| 4560 | end
|
---|
| 4561 | end
|
---|
| 4562 | param.NomType=get(handles.FileIndex,'UserData');
|
---|
| 4563 | param.NomType_1=get(handles.FileIndex_1,'UserData');
|
---|
| 4564 | param.comp_input=get(handles.fix_pair,'Value');
|
---|
| 4565 | huvmat=get(handles.MenuSeries,'parent');
|
---|
| 4566 | UvData=get(huvmat,'UserData');
|
---|
| 4567 | if isfield(UvData,'Time')
|
---|
| 4568 | param.Time=UvData.XmlData.Time;
|
---|
| 4569 | end
|
---|
| 4570 | if isequal(get(handles.scan_i,'Value'),1)
|
---|
| 4571 | param.incr_i=str2num(get(handles.increment_scan,'String'));
|
---|
| 4572 | elseif isequal(get(handles.scan_j,'Value'),1)
|
---|
| 4573 | param.incr_j=str2num(get(handles.increment_scan,'String'));
|
---|
| 4574 | end
|
---|
| 4575 | param.list_fields=get(handles.Fields,'String');% list menu fields
|
---|
| 4576 | param.list_fields(1)=[]; %suppress 'image' option
|
---|
| 4577 | param.index_fields=get(handles.Fields,'Value');% selected string index
|
---|
| 4578 | if param.index_fields>1
|
---|
| 4579 | param.index_fields=param.index_fields-1;
|
---|
| 4580 | end
|
---|
| 4581 | param.list_fields_1=get(handles.Fields_1,'String');% list menu fields
|
---|
| 4582 | param.list_fields_1(1)=[]; %suppress 'image' option
|
---|
| 4583 | param.index_fields_1=get(handles.Fields_1,'Value')-1;% selected string index
|
---|
| 4584 | if param.index_fields_1>1
|
---|
| 4585 | param.index_fields_1=param.index_fields_1-1;
|
---|
| 4586 | end
|
---|
| 4587 | param.civ1=get(handles.civ1,'Value');
|
---|
| 4588 | param.civ2=get(handles.civ2,'Value');
|
---|
| 4589 | param.interp1=get(handles.interp1,'Value');
|
---|
| 4590 | param.interp2=get(handles.interp2,'Value');
|
---|
| 4591 | param.filter1=get(handles.filter1,'Value');
|
---|
| 4592 | param.filter2=get(handles.filter2,'Value');
|
---|
[39] | 4593 | param.menu_coord_str=get(handles.transform_fct,'String');
|
---|
| 4594 | param.menu_coord_val=get(handles.transform_fct,'Value');
|
---|
[2] | 4595 |
|
---|
| 4596 | series(param); %run the series interface
|
---|
| 4597 |
|
---|
| 4598 | % ------------------------------------------------------------------
|
---|
| 4599 | % -- open the GUI civ.fig for civx (PIV)
|
---|
| 4600 | % ------------------------------------------------------------------
|
---|
| 4601 | function MenuPIV_Callback(hObject, eventdata, handles)
|
---|
| 4602 |
|
---|
| 4603 | [FileName,RootPath,filebase,FileIndices,ext,SubDir]=read_file_boxes(handles);
|
---|
[45] | 4604 | num1=stra2num(get(handles.i1,'String'));
|
---|
| 4605 | num2=stra2num(get(handles.i2,'String'));
|
---|
| 4606 | num_a=stra2num(get(handles.j1,'String'));
|
---|
| 4607 | num_b=stra2num(get(handles.j2,'String'));
|
---|
[2] | 4608 | NomType=get(handles.FileIndex,'UserData');
|
---|
| 4609 | ind_opening=1; % default (images): will advice civ1 option by default in the civ interface
|
---|
| 4610 | if isequal(ext,'.nc') || isequal(ext,'.cdf')% netcdf files
|
---|
| 4611 | ind_opening=2;% propose 'fix' as the default option
|
---|
| 4612 | % +read the current netcdf rootfile
|
---|
| 4613 | Data=nc2struct(FileName,[]);
|
---|
| 4614 | if isfield(Data,'fix') & isequal(Data.fix,1)
|
---|
| 4615 | ind_opening=3;
|
---|
| 4616 | end
|
---|
| 4617 | if isfield(Data,'patch') & isequal(Data.patch,1)
|
---|
| 4618 | ind_opening=4;
|
---|
| 4619 | end
|
---|
| 4620 | if isfield(Data,'civ2') & isequal(Data.civ2,1)
|
---|
| 4621 | ind_opening=5;
|
---|
| 4622 | end
|
---|
| 4623 | if isfield(Data,'fix2') & isequal(Data.fix2,1)
|
---|
| 4624 | ind_opening=6;
|
---|
| 4625 | end
|
---|
| 4626 | end
|
---|
[71] | 4627 | param.RootName=filebase;
|
---|
| 4628 | param.NomType=NomType;
|
---|
| 4629 | param.num1=num1;
|
---|
| 4630 | param.num2=num2;
|
---|
| 4631 | param.num_a=num_a;
|
---|
| 4632 | param.num_b=num_b;
|
---|
| 4633 | param.SubDir=SubDir;
|
---|
| 4634 | param.IndOpening=ind_opening;% A REVOIR +TRANSMETTRE IMADOC INFO
|
---|
| 4635 | param.ImaExt=ext;
|
---|
| 4636 | civ(param);% interface de civ(not in the uvmat file)
|
---|
[2] | 4637 |
|
---|
| 4638 | % ------------------------------------------------------------------
|
---|
| 4639 | function MenuTools_Callback(hObject, eventdata, handles)
|
---|
| 4640 |
|
---|
| 4641 | % ------------------------------------------------------------------
|
---|
[67] | 4642 | function MenuEditObject_Callback(hObject, eventdata, handles)
|
---|
| 4643 | set(handles.edit,'Value',1)
|
---|
| 4644 | edit_Callback(hObject, eventdata, handles)
|
---|
[2] | 4645 |
|
---|
| 4646 | %--------------------------------------------------------------------------
|
---|
| 4647 | function enable_transform(handles,state)
|
---|
[39] | 4648 | set(handles.transform_fct,'Visible',state)
|
---|
[2] | 4649 | set(handles.TRANSFORM_txt,'Visible',state)
|
---|
[39] | 4650 | set(handles.transform_fct,'Visible',state)
|
---|
[2] | 4651 | set(handles.path_transform,'Visible',state)
|
---|
| 4652 | set(handles.pxcmx_txt,'Visible',state)
|
---|
| 4653 | set(handles.pxcmy_txt,'Visible',state)
|
---|
| 4654 | set(handles.pxcm,'Visible',state)
|
---|
| 4655 | set(handles.pycm,'Visible',state)
|
---|
| 4656 |
|
---|
[40] | 4657 | %------------------------------------------------------------------------
|
---|
[2] | 4658 | function MenuEditVectors_Callback(hObject, eventdata, handles)
|
---|
[40] | 4659 | %------------------------------------------------------------------------
|
---|
[2] | 4660 | set(handles.edit_vect,'Visible','on')
|
---|
| 4661 | set(handles.edit_vect,'Value',1)
|
---|
| 4662 | edit_vect_Callback(hObject, eventdata, handles)
|
---|
| 4663 |
|
---|
[40] | 4664 | % --------------------------------------------------------------------
|
---|
| 4665 | function Menupoints_Callback(hObject, eventdata, handles)
|
---|
| 4666 | data.Style='points';
|
---|
| 4667 | data.ProjMode='projection';%default
|
---|
[55] | 4668 | create_object(data,handles)
|
---|
[2] | 4669 |
|
---|
[40] | 4670 | % --------------------------------------------------------------------
|
---|
| 4671 | function Menuline_Callback(hObject, eventdata, handles)
|
---|
| 4672 | % set(handles.create,'Visible','on')
|
---|
| 4673 | % set(handles.create,'Value',1)
|
---|
| 4674 | % LINE_Callback(hObject,eventdata,handles)
|
---|
| 4675 | data.Style='line';
|
---|
| 4676 | data.ProjMode='projection';%default
|
---|
[55] | 4677 | create_object(data,handles)
|
---|
[2] | 4678 |
|
---|
[40] | 4679 | %------------------------------------------------------------------------
|
---|
| 4680 | function Menupolyline_Callback(hObject, eventdata, handles)
|
---|
| 4681 | %------------------------------------------------------------------------
|
---|
| 4682 | data.Style='polyline';
|
---|
| 4683 | data.ProjMode='projection';%default
|
---|
[55] | 4684 | create_object(data,handles)
|
---|
[2] | 4685 |
|
---|
[55] | 4686 | %------------------------------------------------------------------------
|
---|
[40] | 4687 | function Menupolygon_Callback(hObject, eventdata, handles)
|
---|
[55] | 4688 | %------------------------------------------------------------------------
|
---|
[45] | 4689 | data.Style='polygon';
|
---|
| 4690 | data.ProjMode='inside';%default
|
---|
[55] | 4691 | create_object(data,handles)
|
---|
[40] | 4692 |
|
---|
| 4693 | %------------------------------------------------------------------------
|
---|
| 4694 | function Menurectangle_Callback(hObject, eventdata, handles)
|
---|
| 4695 | %------------------------------------------------------------------------
|
---|
| 4696 | data.Style='rectangle';
|
---|
| 4697 | data.ProjMode='inside';%default
|
---|
[55] | 4698 | create_object(data,handles)
|
---|
[40] | 4699 |
|
---|
| 4700 | %------------------------------------------------------------------------
|
---|
| 4701 | function Menuellipse_Callback(hObject, eventdata, handles)
|
---|
| 4702 | %------------------------------------------------------------------------
|
---|
| 4703 | data.Style='ellipse';
|
---|
| 4704 | data.ProjMode='inside';%default
|
---|
[55] | 4705 | create_object(data,handles)
|
---|
[40] | 4706 |
|
---|
| 4707 | % ------------------------------------------------------------------
|
---|
| 4708 | function Menuplane_Callback(hObject, eventdata, handles)
|
---|
| 4709 | % set(handles.create,'Visible','on')
|
---|
| 4710 | % set(handles.create,'Value',1)
|
---|
| 4711 | % PLANE_Callback(hObject,eventdata,handles)
|
---|
| 4712 | data.Style='plane';
|
---|
| 4713 | data.ProjMode='projection';%default
|
---|
| 4714 |
|
---|
[55] | 4715 | create_object(data,handles)
|
---|
| 4716 |
|
---|
[40] | 4717 | % ------------------------------------------------------------------
|
---|
| 4718 | function Menuvolume_Callback(hObject, eventdata, handles)
|
---|
[61] | 4719 | % set(handles.create,'Visible','on')
|
---|
| 4720 | % set(handles.create,'Value',1)
|
---|
[40] | 4721 | VOLUME_Callback(hObject,eventdata,handles)
|
---|
| 4722 |
|
---|
| 4723 | %------------------------------------------------------------------------
|
---|
| 4724 | function MenuBrowseObject_Callback(hObject, eventdata, handles)
|
---|
| 4725 | %------------------------------------------------------------------------
|
---|
| 4726 | %get the object file
|
---|
| 4727 | [FileName, PathName, filterindex] = uigetfile( ...
|
---|
| 4728 | {'*.xml;*.mat', ' (*.xml,*.mat)';
|
---|
| 4729 | '*.xml', '.xml files '; ...
|
---|
| 4730 | '*.mat', '.mat matlab files '}, ...
|
---|
| 4731 | 'Pick a file',get(handles.RootPath,'String'));
|
---|
| 4732 | fileinput=[PathName FileName];%complete file name
|
---|
| 4733 | testblank=findstr(fileinput,' ');%look for blanks
|
---|
| 4734 | if ~isempty(testblank)
|
---|
| 4735 | msgbox_uvmat('ERROR','forbidden input file name: contain blanks')
|
---|
| 4736 | return
|
---|
| 4737 | end
|
---|
| 4738 | sizf=size(fileinput);
|
---|
| 4739 | if (~ischar(fileinput)||~isequal(sizf(1),1)),return;end
|
---|
| 4740 |
|
---|
| 4741 | %read the file
|
---|
[55] | 4742 | t=xmltree(fileinput);
|
---|
| 4743 | data=convert(t);
|
---|
[71] | 4744 | data.enable_plot=1;
|
---|
| 4745 | [pp,data.Name]=fileparts(FileName);
|
---|
| 4746 | %PlotHandles=get_plot_handles(handles);%get the handles of the interface elements setting the plotting parameters
|
---|
[55] | 4747 | hset_object=findobj(allchild(0),'Name','set_object');
|
---|
| 4748 | if ~isempty(hset_object)
|
---|
| 4749 | delete(hset_object)% delete existing version of set_object
|
---|
| 4750 | end
|
---|
[71] | 4751 | UvData=get(handles.uvmat,'UserData');
|
---|
| 4752 | [hset_object,UvData.sethandles]=set_object(data);% call the set_object interface
|
---|
[61] | 4753 | %position the set_object GUI with respect to uvmat
|
---|
| 4754 | pos_uvmat=get(handles.uvmat,'Position');
|
---|
| 4755 | if isfield(UvData,'SetObjectOrigin')
|
---|
| 4756 | pos_set_object(1:2)=UvData.SetObjectOrigin + pos_uvmat(1:2);
|
---|
| 4757 | pos_set_object(3:4)=UvData.SetObjectSize .* pos_uvmat(3:4);
|
---|
| 4758 | set(hset_object,'Position',pos_set_object)
|
---|
| 4759 | end
|
---|
| 4760 | set(handles.edit,'Value',0); %suppress the object edit mode
|
---|
| 4761 | set(handles.edit,'BackgroundColor',[0.7,0.7,0.7])
|
---|
[55] | 4762 | UvData.MouseAction='create_object';
|
---|
| 4763 | set(handles.uvmat,'UserData',UvData)
|
---|
[72] | 4764 | set(handles.delete_object,'Visible','on')
|
---|
| 4765 | set(handles.uvmat_title,'Visible','on')
|
---|
| 4766 | set(handles.viw_field_title,'Visible','on')
|
---|
[40] | 4767 |
|
---|
| 4768 | %------------------------------------------------------------------------
|
---|
[71] | 4769 | % --- generic function used for the creation of a projection object
|
---|
[55] | 4770 | function create_object(data,handles)
|
---|
[40] | 4771 | %------------------------------------------------------------------------
|
---|
[55] | 4772 | hset_object=findobj(allchild(0),'Name','set_object');
|
---|
[40] | 4773 | if ~isempty(hset_object)
|
---|
| 4774 | delete(hset_object)% delete existing version of set_object
|
---|
| 4775 | end
|
---|
[55] | 4776 | UvData=get(handles.uvmat,'UserData');
|
---|
[61] | 4777 | set(handles.edit,'Value',0); %suppress the object edit mode
|
---|
| 4778 | set(handles.edit,'BackgroundColor',[0.7,0.7,0.7])
|
---|
[71] | 4779 | data.enable_plot=1;
|
---|
[40] | 4780 | if isfield(UvData,'CoordType')
|
---|
| 4781 | data.CoordType=UvData.CoordType;
|
---|
| 4782 | end
|
---|
[55] | 4783 | if isfield(UvData,'Mesh')&&~isempty(UvData.Mesh)
|
---|
[40] | 4784 | data.RangeX=UvData.Mesh;
|
---|
| 4785 | data.RangeY=UvData.Mesh;
|
---|
| 4786 | data.DX=UvData.Mesh;
|
---|
| 4787 | data.DY=UvData.Mesh;
|
---|
[55] | 4788 | elseif isfield(UvData.Field,'AX')&& isfield(UvData.Field,'AY')&& isfield(UvData.Field,'A')%only image
|
---|
[40] | 4789 | np=size(UvData.Field.A);
|
---|
| 4790 | meshx=(UvData.Field.AX(end)-UvData.Field.AX(1))/np(2);
|
---|
| 4791 | meshy=abs(UvData.Field.AY(end)-UvData.Field.AY(1))/np(1);
|
---|
| 4792 | data.RangeY=max(meshx,meshy);
|
---|
| 4793 | data.RangeX=max(meshx,meshy);
|
---|
| 4794 | data.DX=max(meshx,meshy);
|
---|
| 4795 | end
|
---|
[55] | 4796 | data.Coord=[0 0 0]; %default
|
---|
| 4797 | if isfield(data,'Style') && isequal(data.Style,'line')
|
---|
| 4798 | if isfield(data,'DX')
|
---|
| 4799 | data.Coord=[[0 0 0];[data.DX 0 0]]; %default
|
---|
| 4800 | else
|
---|
| 4801 | data.Coord=[[0 0 0];[1 0 0]]; %default
|
---|
| 4802 | end
|
---|
[40] | 4803 | end
|
---|
| 4804 | %data.ParentButton=handles.create;
|
---|
[55] | 4805 | if ishandle(handles.UVMAT_title)
|
---|
| 4806 | delete(handles.UVMAT_title)%delete the initial display of uvmat if no field has been entered
|
---|
| 4807 | end
|
---|
| 4808 | PlotHandles=get_plot_handles(handles);%get the handles of the interface elements setting the plotting parameters
|
---|
[40] | 4809 | [hset_object,UvData.sethandles]=set_object(data,PlotHandles);% call the set_object interface
|
---|
[61] | 4810 |
|
---|
[72] | 4811 | % pos_uvmat=get(handles.uvmat,'Position');
|
---|
| 4812 | % %position the set_object GUI with respect to uvmat
|
---|
| 4813 | % if isfield(UvData,'SetObjectOrigin')
|
---|
| 4814 | % pos_set_object(1:2)=UvData.SetObjectOrigin + pos_uvmat(1:2);
|
---|
| 4815 | % pos_set_object(3:4)=UvData.SetObjectSize .* pos_uvmat(3:4);
|
---|
| 4816 | % set(hset_object,'Position',pos_set_object)
|
---|
| 4817 | % end
|
---|
[61] | 4818 |
|
---|
[40] | 4819 | UvData.MouseAction='create_object';
|
---|
[55] | 4820 | set(handles.uvmat,'UserData',UvData)
|
---|
| 4821 | set(handles.zoom,'Value',0)
|
---|
| 4822 | zoom_Callback(handles.uvmat, [], handles)
|
---|
[72] | 4823 | set(handles.delete_object,'Visible','on')
|
---|
| 4824 | set(handles.uvmat_title,'Visible','on')
|
---|
| 4825 | set(handles.viw_field_title,'Visible','on')
|
---|
[40] | 4826 |
|
---|
[71] | 4827 | %------------------------------------------------------------------------
|
---|
[60] | 4828 | function MenuRuler_Callback(hObject, eventdata, handles)
|
---|
[71] | 4829 | %------------------------------------------------------------------------
|
---|
[60] | 4830 | set(handles.zoom,'Value',0)
|
---|
| 4831 | zoom_Callback(handles.uvmat, [], handles)
|
---|
| 4832 | UvData=get(handles.uvmat,'UserData');
|
---|
| 4833 | UvData.MouseAction='ruler';
|
---|
| 4834 | set(handles.uvmat,'UserData',UvData);
|
---|
| 4835 |
|
---|
[67] | 4836 | %------------------------------------------------------------------------
|
---|
[71] | 4837 | % --- executed when closing: set the parent interface button to value 0
|
---|
[67] | 4838 | function closefcn(gcbo,eventdata)
|
---|
| 4839 | %------------------------------------------------------------------------
|
---|
| 4840 | %delete all the associated figures if exist
|
---|
| 4841 | hh=findobj(allchild(0),'tag','view_field');
|
---|
| 4842 | if ~isempty(hh)
|
---|
| 4843 | delete(hh)
|
---|
| 4844 | end
|
---|
| 4845 | hh=findobj(allchild(0),'name','geometry_calib');
|
---|
| 4846 | if ~isempty(hh)
|
---|
| 4847 | delete(hh)
|
---|
| 4848 | end
|
---|
| 4849 | hh=findobj(allchild(0),'tag','set_object');
|
---|
| 4850 | if ~isempty(hh)
|
---|
| 4851 | hhh=findobj(hh,'tag','PLOT');
|
---|
| 4852 | set(hhh,'enable','off')
|
---|
[71] | 4853 | end
|
---|
| 4854 |
|
---|
| 4855 |
|
---|
| 4856 | % --- Executes on button press in delete_object.
|
---|
| 4857 | function delete_object_Callback(hObject, eventdata, handles)
|
---|
| 4858 | IndexObj=get(handles.list_object_2,'Value');
|
---|
| 4859 | if IndexObj>1
|
---|
| 4860 | delete_object(IndexObj)
|
---|
| 4861 | end
|
---|
| 4862 |
|
---|
| 4863 |
|
---|