[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
|
---|
| 7 | %
|
---|
| 8 | %INPUT:
|
---|
| 9 | % input: input file name (if character chain), or input image matrix to
|
---|
| 10 | % visualize, or Matlab structure representing netcdf fields (with fields
|
---|
| 11 | % ListVarName....)
|
---|
| 12 | %
|
---|
| 13 | %AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
|
---|
[38] | 14 | % Copyright Joel Sommeria, 2008, LEGI / CNRS-UJF-INPG, joel.sommeria@legi.grenoble-inp.fr.
|
---|
[2] | 15 | %AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
|
---|
| 16 | % This open is part of the toolbox UVMAT.
|
---|
| 17 | %
|
---|
| 18 | % UVMAT is free software; you can redistribute it and/or modify
|
---|
| 19 | % it under the terms of the GNU General Public License as published by
|
---|
| 20 | % the Free Software Foundation; either version 2 of the License, or
|
---|
| 21 | % (at your option) any later version.
|
---|
| 22 | %
|
---|
| 23 | % UVMAT is distributed in the hope that it will be useful,
|
---|
| 24 | % but WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
| 25 | % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
---|
| 26 | % GNU General Public License (open UVMAT/COPYING.txt) for more details.
|
---|
| 27 | %AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
|
---|
| 28 | %
|
---|
| 29 | % Information stored on the interface:
|
---|
| 30 | % 'Strings' of all edit boxes and menus: get(handles.Tag,'String')
|
---|
| 31 | % 'Values' of all menus and toggle buttons: get(handles.Tag,'Value')
|
---|
| 32 | % Matlab structure stored as 'UserData' of the figure uvmat.fig,(can be obtained by right mouse click on the interface).
|
---|
| 33 | % It contains the following fields:
|
---|
| 34 | % - Fixed specifiacation of plotting figures and axes (defined bu uvmat_OpeningFcn)
|
---|
| 35 | % .PosColorbar: [0.8210 0.4710 0.0190 0.4450]; specified position of the colorbar on figures
|
---|
| 36 | % - Information read in the documentation open of a series (activated by RootPath_Callback) :
|
---|
| 37 | % .XmlData, with fields:
|
---|
| 38 | % .Time: matrix of times of the images with index i and j
|
---|
| 39 | % .GeometryCalib: [1x1 struct]
|
---|
| 40 | % - Information defined from the interface:
|
---|
| 41 | % .NewSeries: =1 when the first view of a new field series is displayed, else 0
|
---|
| 42 | % .filename:(char string)
|
---|
| 43 | % .VelType:(char string) type of velocity field selected
|
---|
| 44 | % .VelType_1:(char string) REMPLACER LE CELL ACTUEL
|
---|
| 45 | % .FieldName: (char string) main field selected('image', 'velocity'...)
|
---|
| 46 | % .FieldName_1:(char string) second field selected('image', 'velocity'...)
|
---|
| 47 | % .CName: (char string)name of the scalar used for vector colors
|
---|
| 48 | % .CoordType: (char string) coordinate transform: e.g. 'phys' or 'px'
|
---|
| 49 | % .MouseAction: store the current effect of mouse button (create or edit objects)
|
---|
| 50 | % - Information on projection objects
|
---|
| 51 | % .Object: {[1x1 struct]}
|
---|
| 52 | % .CurrentObjectIndex: index of the projection object .Object currently selected for editing
|
---|
| 53 | % -Information on the current field (Field{i})
|
---|
| 54 | % .Txt : text information to display (e.g. error message)
|
---|
| 55 | % .NbDim: number of dimensions (=0 by default)
|
---|
| 56 | % .NbCoord: number of vector components
|
---|
| 57 | % .CoordType: expresses the type of coordinate ('px' for image, 'sig' for instruments, or 'phys')
|
---|
| 58 | % .dt: time interval for the corresponding image pair
|
---|
| 59 | % .Mesh: estimated typical distance between vectors
|
---|
| 60 | % .ZMax:
|
---|
| 61 | % .ZMin:
|
---|
| 62 | % .X, .Y, .Z: set of vector coordinates
|
---|
| 63 | % .U,.V,.W: corresponding set of vector components
|
---|
| 64 | % .F: corresponding set of warning flags
|
---|
| 65 | % .FF: corresponding set of false flags, =0 for good vectors
|
---|
| 66 | % .C: corresponding values of the scalar used for vector color
|
---|
| 67 | % (.X, .Y, .Z,.U,.V,.W,.F,.FF,.C are matlab vectors of the same length,
|
---|
| 68 | % equal to the number of vectors stored in the input open)
|
---|
| 69 | % .CName: name of the scalar .C
|
---|
| 70 | % .CType: type of the scalar .C, setting how the scalar is obtained (see 'Scalars' below)
|
---|
| 71 | % .A image or scalar
|
---|
| 72 | % .AX: vector of dimension 2 representing the first and last values
|
---|
| 73 | % of the X coordinates for the image or scalar known on a regular grid,
|
---|
| 74 | % or vector of dimension .A for a scaler defined on irregular grid.
|
---|
| 75 | % .AY: same as .AX along the Y direction
|
---|
| 76 | % .AName: name of the scalar, ='image' for an image
|
---|
| 77 |
|
---|
| 78 | % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%% DATA FLOW (for run0_Callback) %%%%%%%%%%%%%%%%%%%%:
|
---|
| 79 | %
|
---|
| 80 | % Main input open second input open(_1) second image (pair animation)
|
---|
| 81 | % read_ncfield.m | |
|
---|
| 82 | % read_image.m | |
|
---|
| 83 | % Field{1} Field{2}
|
---|
| 84 | % |
|
---|
| 85 | % coord transform (phys.m) or other user defined fct acting on Field{i} |
|
---|
| 86 | % Field{i}
|
---|
| 87 | % |
|
---|
| 88 | % calc_field.m: calculate scalar or other derived fields (vort, div..).
|
---|
| 89 | %
|
---|
| 90 | % sub_field.m: combine the input Field{i} in a single set of fields (vector + scalar):
|
---|
| 91 | % Field{i=1->3}.X --> UvData.X |
|
---|
| 92 | % |
|
---|
| 93 | % UvData
|
---|
| 94 | % |
|
---|
| 95 | % plot histograms of the whole field
|
---|
| 96 | % proj_field.m: project the set of fields on the current projection objects defined by UvData.Object
|
---|
| 97 | % | |
|
---|
| 98 | % ObjectData
|
---|
| 99 | % |
|
---|
| 100 | % plot_field.m: plot the projected fields and store them as user |
|
---|
| 101 | % data of the plotting axes |
|
---|
| 102 | % |
|
---|
| 103 | % AxeData
|
---|
| 104 | %
|
---|
[15] | 105 | %%%%%%%%%%%%%% SCALARS: %%%%%%%%%%%%??%%%
|
---|
[2] | 106 | % scalars are displayed either as an image or countour plot, either as a color of
|
---|
| 107 | % velocity vectors. The scalar values in the first case is represented by
|
---|
| 108 | % UvData.Field.A, and by UvData.Field.C in the second case. The corresponding set of X
|
---|
| 109 | % and Y coordinates are represented by UvData.Field.AX and UvData.Field.AY, and .X and
|
---|
| 110 | % .Y for C (the same as velocity vectors). If A is a nxxny matrix (scalar
|
---|
| 111 | % on a regtular grid), then .AX andf.AY contains only two elements, represneting the
|
---|
| 112 | % coordinates of the four image corners. The scalar name is represented by
|
---|
| 113 | % the strings .AName and/or .CName.
|
---|
| 114 | % If the scalar exists in an input open (image or scalar stored under its
|
---|
| 115 | % name in a netcdf open), it is directly read at the level of Field{1}or Field{2}.
|
---|
| 116 | % Else only its name AName is recorded in Field{i}, and its field is then calculated
|
---|
| 117 | %by the fuction calc_scal after the coordinate transform or after projection on an edit
|
---|
| 118 |
|
---|
| 119 | % Properties attached to plotting figures (standard Matlab properties):
|
---|
| 120 | % 'CurrentAxes'= gca or get(gcf,'CurrentAxes');
|
---|
| 121 | % 'CurrentPoint'=get(gcf,'CurrentPoint'): figure coordinates of the point over which the mouse is positioned
|
---|
| 122 | % 'CurrentCharacter'=get(gcf,'CurrentCharacter'): last character typed over the figure where the mouse is positioned
|
---|
| 123 | % 'WindowButtonMotionFcn': function permanently called by mouse motion over the figure
|
---|
| 124 | % 'KeyPressFcn': function called by pressing a key on the key board
|
---|
| 125 | % 'WindowButtonDownFcn': function called by pressing the mouse over the figure
|
---|
| 126 | % 'WindowButtonUpFcn': function called by releasing the mouse pressure over the figure
|
---|
| 127 |
|
---|
| 128 | % Properties attached to plotting axes:
|
---|
| 129 | % 'CurrentPoint'=get(gca,'CurrentPoint'); (standard Matlab) same as for the figure, but position in plot coordinates.
|
---|
| 130 | % AxeData:=get(gca,'UserData');
|
---|
| 131 | % AxeData.Drawing = create: create a new edit
|
---|
| 132 | % = deform: modify an existing edit by moving its defining create
|
---|
| 133 | % = off: no current drawing action
|
---|
| 134 | % = translate: translate an existing edit
|
---|
| 135 | % = zoom: isolate a subregion for zoom in=1 if an edit is being currently drawn, 0 else (set to 0 by releasing mouse button)
|
---|
| 136 | % .hset_edit=handle of the set_edit interface (if a projection edit is edited);
|
---|
| 137 | % .CurrentOrigin: Origin of a curently drawn edit
|
---|
| 138 | % .CurrentLine: currently drawn menuline (A REVOIR)
|
---|
| 139 | % .CurrentObject: handle of the currently drawn edit
|
---|
| 140 | % .CurrentRectZoom: current rectangle used for zoom
|
---|
| 141 | % .zoomon : zoom state (a revoir)
|
---|
| 142 | % .X, .Y, .Z: array of coordinates defining the position of the vector: ASSOCIER AU PLAN (OBJET) PLUTOT QU'A L'AXE ?
|
---|
| 143 | % .U, .V, .W: array of components of the vector
|
---|
| 144 | % .C:
|
---|
| 145 | % .F:
|
---|
| 146 | % .FF:
|
---|
| 147 | % .A
|
---|
| 148 |
|
---|
| 149 | % Properties attached to projection objects (create, menuline, menuplane...):
|
---|
| 150 | % 'Tag'='proj_edit': for all projection objects
|
---|
| 151 | % ObjectData.Style=...: style of projection edit:
|
---|
| 152 | % .ProjMode
|
---|
| 153 | % .Coord: defines the position of the edit
|
---|
| 154 | % .XMin,YMin....
|
---|
| 155 | % .XMax,YMax....
|
---|
| 156 | % .DX,DY,DZ
|
---|
| 157 | % .Phi, .Theta, .Psi : Euler angles
|
---|
| 158 | % .X,.Y,.U,.V.... : field data projected on the edit
|
---|
| 159 | % .IndexObj: index in the list of UvData.Object
|
---|
| 160 | %during plotting
|
---|
| 161 | % .plotaxes: handles of the current axes used to plot the result of field projection on the object
|
---|
| 162 | % .plothandle: vector of handle(s) of the object graphic represnetation in all the opened plotting axes
|
---|
| 163 | % To each projection object #iobj, corresponds an axis
|
---|
| 164 | % Object{iobj}.plotaxes and nbobj representation graphs Object{iobj}.plothandles(:) (where nbobj is the
|
---|
| 165 | % nbre of current objects opened in uvmat. Note that Object{iobj}.plothandles(iobj)=[] : an object is not represented in its own projection field;
|
---|
| 166 | %-------------------------------------------------------------------
|
---|
| 167 | %-------------------------------------------------------------------
|
---|
| 168 | % I - MAIN FUNCTION UVMAT (DO NOT MODIFY)
|
---|
| 169 | %-------------------------------------------------------------------
|
---|
| 170 | %-------------------------------------------------------------------
|
---|
| 171 | function varargout = uvmat(varargin)
|
---|
| 172 |
|
---|
| 173 | % Begin initialization code - DO NOT EDIT
|
---|
| 174 | gui_Singleton = 1;
|
---|
| 175 | gui_State = struct('gui_Name', mfilename, ...
|
---|
| 176 | 'gui_Singleton', gui_Singleton, ...
|
---|
| 177 | 'gui_OpeningFcn', @uvmat_OpeningFcn, ...
|
---|
| 178 | 'gui_OutputFcn', @uvmat_OutputFcn, ...
|
---|
| 179 | 'gui_LayoutFcn', [], ...
|
---|
| 180 | 'gui_Callback', []);
|
---|
| 181 | if nargin && ischar(varargin{1})
|
---|
| 182 | gui_State.gui_Callback = str2func(varargin{1});
|
---|
| 183 | end
|
---|
| 184 |
|
---|
| 185 | if nargout
|
---|
| 186 | varargout{1:nargout} = gui_mainfcn(gui_State, varargin{:});
|
---|
| 187 | else
|
---|
| 188 | gui_mainfcn(gui_State, varargin{:});
|
---|
| 189 | end
|
---|
| 190 | % End initialization code - DO NOT EDIT
|
---|
| 191 |
|
---|
| 192 | %-------------------------------------------------------------------
|
---|
| 193 | % --- Executes just before uvmat is made visible.
|
---|
| 194 | function uvmat_OpeningFcn(hObject, eventdata, handles, input )
|
---|
| 195 | %-------------------------------------------------------------------
|
---|
| 196 | %WARNING: avoid the second input parameter, leads to erros
|
---|
[39] | 197 | global dircur dir_opening nb_builtin
|
---|
[2] | 198 | % Choose default command menuline output for uvmat
|
---|
| 199 | handles.output = hObject;
|
---|
| 200 |
|
---|
| 201 | % Update handles structure
|
---|
| 202 | guidata(hObject, handles);
|
---|
| 203 |
|
---|
[41] | 204 | dircur=pwd; %current working directory
|
---|
[2] | 205 | dir_opening=dircur;
|
---|
| 206 |
|
---|
| 207 | % set the position of colorbar and ancillary GUIs:
|
---|
| 208 | set(hObject,'Units','Normalized')
|
---|
| 209 | movegui(hObject,'center')
|
---|
| 210 | UvData.PosColorbar=[0.805 0.022 0.019 0.445];
|
---|
| 211 | UvData.SetObjectOrigin=[-0.05 -0.03]; %position for set_object
|
---|
| 212 | UvData.SetObjectSize=[0.3 0.7];
|
---|
| 213 | UvData.CalOrigin=[0.95 -0.03];%position for geometry_calib (TO IMPROVE)
|
---|
| 214 | UvData.CalSize=[0.28 1];
|
---|
| 215 |
|
---|
| 216 | %functions for the mouse and keyboard
|
---|
| 217 | set(handles.histo_u,'NextPlot','replacechildren');
|
---|
| 218 | set(handles.histo_v,'NextPlot','replacechildren');
|
---|
| 219 | set(hObject,'KeyPressFcn',{'keyboard_callback',handles})%set keyboard action function
|
---|
| 220 | set(hObject,'WindowButtonMotionFcn',{'mouse_motion',handles})%set mouse action functio
|
---|
| 221 | set(hObject,'WindowButtonDownFcn',{'mouse_down'})%set mouse click action function
|
---|
| 222 | set(hObject,'WindowButtonUpFcn',{'mouse_up',handles})
|
---|
| 223 |
|
---|
[39] | 224 | %TRANSFORM menu: loads the information stored in prefdir to initiate the browser and the list of functions
|
---|
| 225 | menu_str={'';'phys';'px';'phys_polar'};
|
---|
| 226 | nb_builtin=numel(menu_str); %number of functions
|
---|
| 227 | [path_uvmat,name,ext]=fileparts(which('uvmat'));
|
---|
| 228 | addpath(fullfile(path_uvmat,'transform_field'))
|
---|
| 229 | fct_handle{1,1}=[];
|
---|
| 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 |
|
---|
[2] | 241 | %load the list of previously browsed files in menus Open and Open_1
|
---|
[40] | 242 | dir_perso=prefdir; % path to the directory .matlab for personal data
|
---|
| 243 | profil_perso=fullfile(dir_perso,'uvmat_perso.mat');% personal data file uvmauvmat_perso.mat' in .matlab
|
---|
[2] | 244 | if exist(profil_perso,'file')
|
---|
| 245 | h=load (profil_perso);
|
---|
| 246 | if isfield(h,'MenuFile_1')
|
---|
| 247 | set(handles.MenuFile_1,'Label',h.MenuFile_1);
|
---|
| 248 | set(handles.MenuFile_1_1,'Label',h.MenuFile_1);
|
---|
| 249 | end
|
---|
| 250 | if isfield(h,'MenuFile_1')
|
---|
| 251 | set(handles.MenuFile_2,'Label',h.MenuFile_2);
|
---|
| 252 | set(handles.MenuFile_2_1,'Label',h.MenuFile_2);
|
---|
| 253 | end
|
---|
| 254 | if isfield(h,'MenuFile_1')
|
---|
| 255 | set(handles.MenuFile_3,'Label',h.MenuFile_3);
|
---|
| 256 | set(handles.MenuFile_3_1,'Label',h.MenuFile_3);
|
---|
| 257 | end
|
---|
| 258 | if isfield(h,'MenuFile_1')
|
---|
| 259 | set(handles.MenuFile_4,'Label',h.MenuFile_4);
|
---|
| 260 | set(handles.MenuFile_4_1,'Label',h.MenuFile_4);
|
---|
| 261 | end
|
---|
| 262 | if isfield(h,'MenuFile_1')
|
---|
| 263 | set(handles.MenuFile_5,'Label',h.MenuFile_5);
|
---|
| 264 | set(handles.MenuFile_5_1,'Label',h.MenuFile_5);
|
---|
[39] | 265 | end
|
---|
| 266 | if isfield(h,'transform_fct') && iscell(h.transform_fct)
|
---|
| 267 | for ilist=1:length(h.transform_fct);
|
---|
| 268 | [path,file]=fileparts(h.transform_fct{ilist});
|
---|
| 269 | addpath(path)
|
---|
| 270 | if exist(file,'file')
|
---|
| 271 | h_func=str2func(file);
|
---|
| 272 | testexist=[testexist 1];
|
---|
| 273 | else
|
---|
| 274 | h_func=[];
|
---|
| 275 | testexist=[testexist 0];
|
---|
| 276 | end
|
---|
| 277 | fct_handle=[fct_handle; {h_func}];%concatene the list of paths
|
---|
| 278 | rmpath(path)
|
---|
| 279 | menu_str=[menu_str; {file}];
|
---|
| 280 | end
|
---|
| 281 | end
|
---|
[2] | 282 | end
|
---|
[39] | 283 | menu_str=menu_str(find(testexist));
|
---|
| 284 | fct_handle=fct_handle(find(testexist));
|
---|
| 285 | menu_str=[menu_str;{'more...'}];
|
---|
| 286 | set(handles.transform_fct,'String',menu_str)
|
---|
| 287 | set(handles.transform_fct,'UserData',fct_handle)% store the list of path in UserData of ACTION
|
---|
[2] | 288 |
|
---|
| 289 | %initiates menu of vector colors
|
---|
| 290 | list_menu=calc_field;
|
---|
| 291 | %list_menu=[{'ima_cor'};{'black'};{'white'};list_menu(3:end)];
|
---|
| 292 | set(handles.col_vec,'String',list_menu)
|
---|
| 293 |
|
---|
| 294 | %check the path and date of modification of all functions in uvmat
|
---|
| 295 | path_to_uvmat=which ('uvmat');% check the path detected for source file uvmat
|
---|
| 296 | [errormsg,date_str]=check_functions;%check the path of the functions called by uvmat.m
|
---|
| 297 |
|
---|
| 298 | %case of an input argument for uvmat
|
---|
| 299 | testinputfield=0;
|
---|
| 300 | inputfile=[];
|
---|
| 301 | Field=[];
|
---|
| 302 | if exist('input','var')
|
---|
| 303 | if ~isempty(errormsg)
|
---|
[38] | 304 | msgbox_uvmat('WARNING',errormsg)
|
---|
[2] | 305 | end
|
---|
| 306 | if ishandle(handles.UVMAT_title)
|
---|
| 307 | delete(handles.UVMAT_title)
|
---|
| 308 | end
|
---|
| 309 | if isstruct(input)
|
---|
| 310 | if isfield(input,'InputFile')
|
---|
| 311 | inputfile=input.InputFile;
|
---|
| 312 | end
|
---|
| 313 | Field=input;
|
---|
| 314 | elseif ischar(input)% file name introduced as input
|
---|
| 315 | inputfile=input;
|
---|
| 316 | elseif isnumeric(input)
|
---|
| 317 | sizinput=size(input);
|
---|
| 318 | if sizinput(1)<=1 || sizinput(2)<=1
|
---|
[38] | 319 | msgbox_uvmat('ERROR','bad input for uvmat: file name, structure or numerical matrix accepted')
|
---|
[2] | 320 | return
|
---|
| 321 | end
|
---|
| 322 | Field.A=input;
|
---|
| 323 | Field.AX=[0.5 size(input,2)-0.5];
|
---|
| 324 | Field.AY=[size(input,1)-0.5 0.5];
|
---|
| 325 | end
|
---|
| 326 | if ~isempty(inputfile)
|
---|
| 327 | display_file_name(hObject, eventdata, handles,inputfile)
|
---|
| 328 | testinputfield=1;
|
---|
| 329 | else
|
---|
| 330 | UvData.TestInputFile=0;
|
---|
| 331 | end
|
---|
| 332 | if ~isempty(Field)
|
---|
| 333 | set(handles.Fields,'Value',1)
|
---|
[39] | 334 | set(handles.Fields,'String',{'get_field...'})
|
---|
[2] | 335 | set(handles.Fields,'UserData',Field)
|
---|
| 336 | testinputfield=1;
|
---|
| 337 |
|
---|
| 338 | % set the colorbar position on the interface:
|
---|
| 339 | UvData.PosColorbar=[0.805 0.022 0.019 0.445];
|
---|
| 340 | elseif ischar(input)
|
---|
| 341 | scan_i_Callback(handles.scan_i, eventdata, handles);
|
---|
| 342 | end
|
---|
| 343 | else
|
---|
| 344 | if ishandle(handles.UVMAT_title)
|
---|
[34] | 345 | fid=fopen('revision.log');
|
---|
[33] | 346 | if fid~=-1
|
---|
[30] | 347 | a=textscan(fid,'%s%s%s',1,'HeaderLines',1,'Delimiter','|');
|
---|
| 348 | 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};errormsg]);
|
---|
| 349 | fclose(fid);
|
---|
| 350 | else
|
---|
[31] | 351 | 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] | 352 | end
|
---|
[2] | 353 | end
|
---|
| 354 | end
|
---|
| 355 | UvData.NewSeries=1;
|
---|
| 356 | set(hObject,'UserData',UvData)
|
---|
| 357 | if testinputfield
|
---|
| 358 | %delete drawn objects
|
---|
| 359 | hother=findobj(handles.axes3,'Tag','proj_object');%find all the proj objects
|
---|
| 360 | for iobj=1:length(hother)
|
---|
| 361 | delete_object(hother(iobj))
|
---|
| 362 | end
|
---|
| 363 | if isempty(inputfile)
|
---|
| 364 | run0_Callback(hObject, eventdata, handles)
|
---|
| 365 | set(handles.MenuTools,'Enable','on')
|
---|
| 366 | set(handles.OBJECT_txt,'Visible','on')
|
---|
| 367 | set(handles.edit,'Visible','on')
|
---|
| 368 | set(handles.list_object,'Visible','on')
|
---|
| 369 | set(handles.frame_object,'Visible','on')
|
---|
| 370 | else
|
---|
| 371 | update_rootinfo(hObject,eventdata,handles);
|
---|
| 372 | end
|
---|
| 373 | end
|
---|
[40] | 374 | set_vec_col_bar(handles) %update the display of color code for vectors
|
---|
[38] | 375 |
|
---|
[2] | 376 | %-------------------------------------------------------------------
|
---|
| 377 | % --- Outputs from this function are returned to the command menuline.
|
---|
| 378 | function varargout = uvmat_OutputFcn(hObject, eventdata, handles)
|
---|
| 379 | varargout{1} = handles.output;% the only output argument is the handle to the GUI figure
|
---|
| 380 |
|
---|
| 381 | %-------------------------------------------------------------------
|
---|
| 382 | %-------------------------------------------------------------------
|
---|
| 383 | % II - FUNCTIONS FOR INTRODUCING THE INPUT FILES
|
---|
| 384 | % automatically sets the global properties when the rootfile name is introduced
|
---|
| 385 | % then activate the view-field action if selected
|
---|
| 386 | % it is activated either by clicking on the RootPath window or by the
|
---|
| 387 | % browser
|
---|
| 388 | %------------------------------------------------------------------
|
---|
| 389 | %------------------------------------------------------------------
|
---|
| 390 |
|
---|
| 391 | % --- Executes on the menu Open/Browse...
|
---|
| 392 | % search the files, recognize their type according to their name and fill the rootfile input windows
|
---|
| 393 | function MenuBrowse_Callback(hObject, eventdata, handles)
|
---|
| 394 | oldfile=read_file_boxes(handles);
|
---|
| 395 |
|
---|
| 396 | if isempty(oldfile)||isequal(oldfile,'') %loads the previously stored file name and set it as default in the file_input box
|
---|
| 397 | dir_perso=prefdir;
|
---|
| 398 | profil_perso=fullfile(dir_perso,'uvmat_perso.mat');
|
---|
| 399 | if exist(profil_perso,'file')
|
---|
| 400 | h=load (profil_perso);
|
---|
| 401 | if isfield(h,'MenuFile_1')
|
---|
| 402 | oldfile=h.MenuFile_1;
|
---|
| 403 | end
|
---|
| 404 | end
|
---|
| 405 | end
|
---|
| 406 | [FileName, PathName] = uigetfile( ...
|
---|
| 407 | {'*.xml;*.xls;*.civ;*.png;*.jpg;*.tif;*.avi;*.AVI;*.nc;*.cmx;*.fig;*.log;*.dat', ' (*.xml,*.xls,*.civ,*.jpg ,*.png, .tif, *.avi,*.nc,*.cmx ,*.fig,*.log,*.dat)';
|
---|
| 408 | '*.xml', '.xml files '; ...
|
---|
| 409 | '*.xls', '.xls files '; ...
|
---|
| 410 | '*.civ', '.civ files '; ...
|
---|
| 411 | '*.jpg',' jpeg image files'; ...
|
---|
| 412 | '*.png','.png image files'; ...
|
---|
| 413 | '*.tif','.tif image files'; ...
|
---|
| 414 | '*.avi;*.AVI','.avi movie files'; ...
|
---|
| 415 | '*.nc','.netcdf files'; ...
|
---|
| 416 | '*.cdf','.netcdf files'; ...
|
---|
| 417 | '*.cmx','.cmx text files';...
|
---|
| 418 | '*.cmx2','.cmx2 text files';...
|
---|
| 419 | '*.fig','.fig files (matlab fig)';...
|
---|
| 420 | '*.log','.log text files ';...
|
---|
| 421 | '*.dat','.dat text files ';...
|
---|
| 422 | '*.*', 'All Files (*.*)'}, ...
|
---|
| 423 | 'Pick a file',oldfile);
|
---|
| 424 | %global filebase
|
---|
| 425 | fileinput=[PathName FileName];%complete file name
|
---|
| 426 | testblank=findstr(fileinput,' ');%look for blanks
|
---|
| 427 | if ~isempty(testblank)
|
---|
[38] | 428 | msgbox_uvmat('ERROR',['The input file name ' fileinput ' contains blank character : This is not allowed. Please change name'])
|
---|
[2] | 429 | return
|
---|
| 430 | end
|
---|
| 431 | sizf=size(fileinput);
|
---|
| 432 | if (~ischar(fileinput)||~isequal(sizf(1),1)),return;end
|
---|
| 433 |
|
---|
| 434 | % display the selected field and related information
|
---|
| 435 | display_file_name(hObject, eventdata, handles,fileinput)
|
---|
| 436 |
|
---|
| 437 | %update list of recent files in the menubar
|
---|
| 438 | MenuFile_1=fileinput;
|
---|
| 439 | MenuFile_2=get(handles.MenuFile_1,'Label');
|
---|
| 440 | MenuFile_3=get(handles.MenuFile_2,'Label');
|
---|
| 441 | MenuFile_4=get(handles.MenuFile_3,'Label');
|
---|
| 442 | MenuFile_5=get(handles.MenuFile_4,'Label');
|
---|
| 443 | set(handles.MenuFile_1,'Label',MenuFile_1)
|
---|
| 444 | set(handles.MenuFile_2,'Label',MenuFile_2)
|
---|
| 445 | set(handles.MenuFile_3,'Label',MenuFile_3)
|
---|
| 446 | set(handles.MenuFile_4,'Label',MenuFile_4)
|
---|
| 447 | set(handles.MenuFile_5,'Label',MenuFile_5)
|
---|
| 448 | set(handles.MenuFile_1_1,'Label',MenuFile_1)
|
---|
| 449 | set(handles.MenuFile_2_1,'Label',MenuFile_2)
|
---|
| 450 | set(handles.MenuFile_3_1,'Label',MenuFile_3)
|
---|
| 451 | set(handles.MenuFile_4_1,'Label',MenuFile_4)
|
---|
| 452 | set(handles.MenuFile_5_1,'Label',MenuFile_5)
|
---|
| 453 | dir_perso=prefdir;
|
---|
| 454 | profil_perso=fullfile(dir_perso,'uvmat_perso.mat');
|
---|
| 455 | if exist(profil_perso,'file')
|
---|
| 456 | save (profil_perso,'MenuFile_1','MenuFile_2','MenuFile_3','MenuFile_4', 'MenuFile_5','-append'); %store the file names for future opening of uvmat
|
---|
| 457 | else
|
---|
| 458 | txt=ver;
|
---|
| 459 | Release=txt(1).Release;
|
---|
| 460 | relnumb=str2double(Release(3:4));
|
---|
| 461 | if relnumb >= 14
|
---|
| 462 | save (profil_perso,'MenuFile_1','MenuFile_2','MenuFile_3','MenuFile_4', 'MenuFile_5','-V6'); %store the file names for future opening of uvmat
|
---|
| 463 | else
|
---|
| 464 | save (profil_perso,'MenuFile_1','MenuFile_2','MenuFile_3','MenuFile_4', 'MenuFile_5'); %store the file names for future opening of uvmat
|
---|
| 465 | end
|
---|
| 466 | end
|
---|
| 467 |
|
---|
| 468 | % --------------------------------------------------------------------
|
---|
| 469 | function MenuFile_1_Callback(hObject, eventdata, handles)
|
---|
| 470 | fileinput=get(handles.MenuFile_1,'Label');
|
---|
| 471 | display_file_name(hObject, eventdata, handles,fileinput)
|
---|
| 472 |
|
---|
| 473 | % --------------------------------------------------------------------
|
---|
| 474 | function MenuFile_2_Callback(hObject, eventdata, handles)
|
---|
| 475 | fileinput=get(handles.MenuFile_2,'Label');
|
---|
| 476 | display_file_name(hObject, eventdata, handles,fileinput)
|
---|
| 477 |
|
---|
| 478 | % --------------------------------------------------------------------
|
---|
| 479 | function MenuFile_3_Callback(hObject, eventdata, handles)
|
---|
| 480 | fileinput=get(handles.MenuFile_3,'Label');
|
---|
| 481 | display_file_name(hObject, eventdata, handles,fileinput)
|
---|
| 482 |
|
---|
| 483 | % --------------------------------------------------------------------
|
---|
| 484 | function MenuFile_4_Callback(hObject, eventdata, handles)
|
---|
| 485 | fileinput=get(handles.MenuFile_4,'Label');
|
---|
| 486 | display_file_name(hObject, eventdata, handles,fileinput)
|
---|
| 487 |
|
---|
| 488 | % --------------------------------------------------------------------
|
---|
| 489 | function MenuFile_5_Callback(hObject, eventdata, handles)
|
---|
| 490 | fileinput=get(handles.MenuFile_5,'Label');
|
---|
| 491 | display_file_name(hObject, eventdata, handles,fileinput)
|
---|
| 492 |
|
---|
| 493 | %-----------------------------------------------------------------
|
---|
| 494 | % fills the edit boxes RootPath, RootFile,NomType...from an input file name 'fileinput'
|
---|
| 495 | %----------------------------------------------------------------
|
---|
| 496 | function display_file_name(hObject, eventdata, handles,fileinput)
|
---|
[29] | 497 | if ~exist(fileinput,'file')
|
---|
| 498 | msgbox_uvmat('ERROR',['input file ' fileinput ' does not exist'])
|
---|
| 499 | return
|
---|
| 500 | end
|
---|
[2] | 501 | [RootPath,RootFile,i1,i2,str_a,str_b,ext,NomType,SubDir]=name2display(fileinput);
|
---|
[29] | 502 | ext_test=''; %default
|
---|
| 503 | if ~isempty(ext)
|
---|
| 504 | form=imformats(ext(2:end));%test valid Matlab image formats
|
---|
| 505 | if ~isempty(form)
|
---|
| 506 | ext_test='.image';
|
---|
| 507 | imainfo=imfinfo(fileinput);
|
---|
| 508 | if length(imainfo) >1 %case of image with multiple frames
|
---|
| 509 | i1='1'; % set the frame counter to 1 by default
|
---|
| 510 | i2='';
|
---|
| 511 | str_a='';
|
---|
| 512 | str_b='';
|
---|
| 513 | NomType='*'; %indicate a set of indexed frames within a single file
|
---|
| 514 | [RootPath,RootFile]=fileparts(fileinput); %include the indices in the root file
|
---|
| 515 | end
|
---|
| 516 | elseif isequal(lower(ext),'.avi')
|
---|
| 517 | ext_test='.image';
|
---|
[2] | 518 | i1='1'; % set the frame counter to 1 by default
|
---|
| 519 | i2='';
|
---|
| 520 | str_a='';
|
---|
| 521 | str_b='';
|
---|
| 522 | NomType='*'; %indicate a set of indexed frames within a single file
|
---|
| 523 | [RootPath,RootFile]=fileparts(fileinput); %include the indices in the root file
|
---|
[29] | 524 | else
|
---|
| 525 | ext_test=lower(ext);
|
---|
[2] | 526 | end
|
---|
| 527 | end
|
---|
| 528 | switch ext_test
|
---|
| 529 | case {'.civ','.log','.cmx','.cmx2','.txt'} %display text file
|
---|
| 530 | edit(fileinput)
|
---|
| 531 | case '.fig' %display matlab figure
|
---|
| 532 | hfig=open(fileinput);
|
---|
| 533 | set(hfig,'WindowButtonMotionFcn','mouse_motion')%set mouse action functio
|
---|
| 534 | set(hfig,'WindowButtonUpFcn','mouse_up')%set mouse click action function
|
---|
| 535 | set(hfig,'WindowButtonUpFcn','mouse_down')%set mouse click action function
|
---|
| 536 | case {'.xml','.xls'} % edit xml or Excel files
|
---|
| 537 | editxml(fileinput);
|
---|
| 538 | case {'.avi','.image','.vol','.nc','.cdf'}
|
---|
| 539 | set(handles.RootPath,'String',RootPath);
|
---|
| 540 | if isequal(SubDir,'')
|
---|
| 541 | rootname=fullfile(RootPath,RootFile);
|
---|
| 542 | else
|
---|
| 543 | rootname=fullfile(RootPath,SubDir,RootFile);
|
---|
| 544 | SubDir=['/' SubDir]; %display the separator
|
---|
| 545 | end
|
---|
| 546 | set(handles.SubDir,'String',SubDir);
|
---|
| 547 | set(handles.RootFile,'String',['/' RootFile]); %display the separator
|
---|
| 548 | indices=fileinput(length(rootname)+1:end);
|
---|
| 549 | indices(end-length(ext)+1:end)=[]; %remove extension
|
---|
| 550 | set(handles.FileIndex,'String',indices);
|
---|
| 551 | set(handles.FileIndex,'UserData',NomType);
|
---|
| 552 | set(handles.FileExt,'String',ext);
|
---|
| 553 | % fill file index counters
|
---|
| 554 | set(handles.i1,'String',i1);
|
---|
| 555 |
|
---|
| 556 | set(handles.i2,'String',i2);
|
---|
| 557 | set(handles.j1,'String',str_a);
|
---|
| 558 | set(handles.j2,'String',str_b);
|
---|
| 559 |
|
---|
| 560 | % synchronise indices of the second input file if it exists
|
---|
| 561 | if get(handles.SubField,'Value')==1% if the subfield button is activated, update the field numbers
|
---|
| 562 | [FileName_1,RootPath_1,FileBase_1,FileIndices_1,FileExt_1,SubDir_1]=read_file_boxes_1(handles);
|
---|
| 563 | NomType_1=get(handles.FileIndex_1,'UserData');
|
---|
| 564 | [FileName_1,idetect]=name_generator(FileBase_1,stra2num(i1),stra2num(i2),FileExt_1,NomType_1,1,stra2num(str_a),stra2num(str_b),SubDir_1);
|
---|
| 565 | if idetect
|
---|
| 566 | FileIndex_1=name_generator('',stra2num(i1),stra2num(i2),'',NomType_1,1,stra2num(str_a),stra2num(str_b),'');
|
---|
| 567 | set(handles.FileIndex_1,'String',FileIndex_1)
|
---|
| 568 | else
|
---|
| 569 | set(handles.SubField,'Value',0)
|
---|
| 570 | SubField_Callback(hObject, eventdata, handles)
|
---|
| 571 | end
|
---|
| 572 | end
|
---|
| 573 |
|
---|
| 574 | %enable other menus
|
---|
| 575 | set(handles.MenuOpen_1,'Enable','on')
|
---|
| 576 | set(handles.MenuFile_1_1,'Enable','on')
|
---|
| 577 | set(handles.MenuFile_2_1,'Enable','on')
|
---|
| 578 | set(handles.MenuFile_3_1,'Enable','on')
|
---|
| 579 | set(handles.MenuFile_4_1,'Enable','on')
|
---|
| 580 | set(handles.MenuFile_5_1,'Enable','on')
|
---|
| 581 | set(handles.MenuExport,'Enable','on')
|
---|
| 582 | set(handles.MenuExportFigure,'Enable','on')
|
---|
| 583 | set(handles.MenuExportMovie,'Enable','on')
|
---|
| 584 | set(handles.MenuTools,'Enable','on')
|
---|
| 585 | set(handles.OBJECT_txt,'Visible','on')
|
---|
| 586 | set(handles.edit,'Visible','on')
|
---|
| 587 | set(handles.list_object,'Visible','on')
|
---|
| 588 | set(handles.frame_object,'Visible','on')
|
---|
| 589 | % initiate input file:
|
---|
| 590 | update_rootinfo(hObject,eventdata,handles);
|
---|
| 591 | otherwise
|
---|
| 592 | msgbox_uvmat('ERROR',['invalid input file extension' ext])
|
---|
| 593 | end
|
---|
| 594 |
|
---|
| 595 | %-------------------------------------------------------------------
|
---|
| 596 | function RootPath_Callback(hObject,eventdata,handles)
|
---|
| 597 | update_rootinfo(hObject,eventdata,handles);
|
---|
| 598 |
|
---|
| 599 | %-------------------------------------------------------------------
|
---|
| 600 | %-- called by action in RootFile edit box
|
---|
| 601 | %-------------------------------------------------------------------
|
---|
| 602 | function SubDir_Callback(hObject, eventdata, handles)
|
---|
| 603 | %refresh the menu of input fields
|
---|
| 604 | Fields_Callback(hObject, eventdata, handles);
|
---|
| 605 | % refresh the current field
|
---|
| 606 | run0_Callback(hObject, eventdata, handles);
|
---|
| 607 |
|
---|
| 608 |
|
---|
| 609 | %-------------------------------------------------------------------
|
---|
| 610 | %-- called by action in RootFile edit box
|
---|
| 611 | %-------------------------------------------------------------------
|
---|
| 612 | function RootFile_Callback(hObject, eventdata, handles)
|
---|
| 613 | update_rootinfo(hObject,eventdata,handles)
|
---|
| 614 |
|
---|
| 615 | %-------------------------------------------------------------------
|
---|
| 616 | %-- called by action in FileIndex edit box
|
---|
| 617 | %-------------------------------------------------------------------
|
---|
| 618 | function FileIndex_Callback(hObject, eventdata, handles)
|
---|
| 619 | NomType_str=get(handles.FileIndex,'String') ;
|
---|
| 620 | [P,F,str1,str2,str_a,str_b]=name2display(['xx' NomType_str get(handles.FileExt,'String')]);
|
---|
| 621 | % display the new index values on the counters
|
---|
| 622 | set(handles.i1,'String',str1);
|
---|
| 623 | set(handles.i2,'String',str2);
|
---|
| 624 | set(handles.j1,'String',str_a);
|
---|
| 625 | set(handles.j2,'String',str_b);
|
---|
| 626 |
|
---|
| 627 | %-------------------------------------------------------------------
|
---|
| 628 | % -- update information about a new field series (indices to scan, timing, calibration from an xml file, then refresh current plots
|
---|
| 629 | %-------------------------------------------------------------------
|
---|
| 630 | function update_rootinfo(hObject,eventdata,handles)
|
---|
| 631 | global dircur dir_opening
|
---|
| 632 |
|
---|
| 633 | set(handles.RootPath,'BackgroundColor',[1 1 0])
|
---|
| 634 | drawnow
|
---|
| 635 | set(handles.Fields,'UserData',[])% reinialize data from uvmat opening
|
---|
| 636 | huvmat=get(handles.RootPath,'parent');
|
---|
| 637 | UvData=get(huvmat,'UserData');%huvmat=handles of the uvmat interface
|
---|
| 638 | UvData.NewSeries=1; %flag for run0: begin a new series
|
---|
| 639 | UvData.TestInputFile=1;
|
---|
| 640 | set(handles.fix_pair,'Value',0) % desactivate by default the comp_input '-'input window
|
---|
| 641 | %FileIndex_Callback(hObject, eventdata, handles)% update field counters
|
---|
| 642 |
|
---|
| 643 | [FileName,RootPath,FileBase,FileIndices,FileExt,SubDir]=read_file_boxes(handles);
|
---|
| 644 | if ~exist(FileName,'file')
|
---|
| 645 | msgbox_uvmat('ERROR',['input file ' FileName ' not found']);
|
---|
| 646 | return
|
---|
| 647 | end
|
---|
| 648 | nbfield=[];%default
|
---|
| 649 | nburst=[];%default
|
---|
| 650 |
|
---|
| 651 | % read timing and total frame number from the current file (movie files) !! may be overrid by xml file
|
---|
| 652 | XmlData.Time=[];%default
|
---|
| 653 | XmlData.GeometryCalib=[];%default
|
---|
| 654 | TimeUnit=[];%default
|
---|
| 655 | testima=0; %test for image input
|
---|
| 656 | if isequal(lower(FileExt),'.avi') %.avi file
|
---|
| 657 | testima=1;
|
---|
| 658 | info=aviinfo([FileBase FileIndices FileExt]);
|
---|
| 659 | nbfield=info.NumFrames;
|
---|
| 660 | nburst=1;
|
---|
| 661 | set(handles.Dt_txt,'String',['Dt=' num2str(1000/info.FramesPerSecond) 'ms']);%display the elementary time interval in millisec
|
---|
| 662 | XmlData.Time=[0:1/info.FramesPerSecond:(info.NumFrames-1)/info.FramesPerSecond]';
|
---|
| 663 | TimeUnit='s';
|
---|
| 664 | set(handles.npx,'String',num2str(info.Width));%fills nbre of pixels x box
|
---|
| 665 | set(handles.npy,'String',num2str(info.Height));%fills nbre of pixels y box
|
---|
| 666 | hhh=which('mmreader');
|
---|
| 667 | if ~isequal(hhh,'')&& mmreader.isPlatformSupported()% if the function is found (recent version of matlab)
|
---|
| 668 | UvData.MovieObject=mmreader([FileBase FileIndices FileExt]);
|
---|
| 669 | end
|
---|
| 670 | elseif ~isempty(imformats(FileExt(2:end))) || isequal(FileExt,'.vol')%&& isequal(NomType,'*')% multi-frame image
|
---|
| 671 | testima=1;
|
---|
| 672 | if ~isequal(SubDir,'')
|
---|
| 673 | RootFile=get(handles.RootFile,'String');
|
---|
| 674 | imainfo=imfinfo([fullfile(RootPath,SubDir,RootFile) FileIndices FileExt]);
|
---|
| 675 | else
|
---|
| 676 | imainfo=imfinfo([FileBase FileIndices FileExt]);
|
---|
| 677 | end
|
---|
| 678 | if length(imainfo) >1 %case of image with multiple frames
|
---|
| 679 | nbfield=length(imainfo);
|
---|
| 680 | nburst=1;
|
---|
| 681 | end
|
---|
| 682 | if isfield(UvData,'MovieObject')
|
---|
| 683 | UvData=rmfield(UvData,'MovieObject');
|
---|
| 684 | end
|
---|
| 685 | else
|
---|
| 686 | %set(handles.last_i,'String','');%fills last_field box
|
---|
| 687 | set(handles.npx,'String','');%fills nbre of pixels x box
|
---|
| 688 | set(handles.npy,'String','');%fills nbre of pixels y box
|
---|
| 689 | if isfield(UvData,'MovieObject')
|
---|
| 690 | UvData=rmfield(UvData,'MovieObject');
|
---|
| 691 | end
|
---|
| 692 | end
|
---|
| 693 |
|
---|
| 694 | % read parameters (time, geometric calibration..) from a documentation file (.xml advised)
|
---|
| 695 | filexml=[FileBase '.xml'];
|
---|
| 696 | fileciv=[FileBase '.civ'];
|
---|
| 697 | warntext='';%default warning message
|
---|
| 698 | NbSlice=1;%default
|
---|
| 699 |
|
---|
| 700 | if exist(filexml,'file')
|
---|
| 701 | set(handles.view_xml,'Visible','on')
|
---|
| 702 | set(handles.view_xml,'BackgroundColor',[1 1 0])
|
---|
| 703 | set(handles.RootPath,'BackgroundColor',[1 1 1])
|
---|
| 704 | set(handles.view_xml,'String','view .xml')
|
---|
| 705 | drawnow
|
---|
| 706 | [XmlData,warntext]=imadoc2struct(filexml);
|
---|
| 707 | if ~isempty(warntext)
|
---|
| 708 | msgbox_uvmat('WARNING',warntext)
|
---|
| 709 | end
|
---|
| 710 | if isfield(XmlData,'TimeUnit')
|
---|
| 711 | if isfield(XmlData,'TimeUnit')&& ~isempty(XmlData.TimeUnit)
|
---|
| 712 | TimeUnit=XmlData.TimeUnit;
|
---|
| 713 | end
|
---|
| 714 | end
|
---|
| 715 | set(handles.view_xml,'BackgroundColor',[1 1 1])
|
---|
| 716 | drawnow
|
---|
| 717 | elseif exist(fileciv,'file')% if .civ file found
|
---|
| 718 | [error,XmlData.Time,TimeUnit,mode,npx,npy,pxcmx,pxcmy]=read_imatext([FileBase '.civ']);
|
---|
| 719 | GeometryCalib.R=[pxcmx 0 0; 0 pxcmy 0;0 0 0];
|
---|
| 720 | GeometryCalib.Tx=0;
|
---|
| 721 | GeometryCalib.Ty=0;
|
---|
| 722 | GeometryCalib.Tz=1;
|
---|
| 723 | GeometryCalib.dpx=1;
|
---|
| 724 | GeometryCalib.dpy=1;
|
---|
| 725 | GeometryCalib.sx=1;
|
---|
| 726 | GeometryCalib.Cx=0;
|
---|
| 727 | GeometryCalib.Cy=0;
|
---|
| 728 | GeometryCalib.f=1;
|
---|
| 729 | GeometryCalib.kappa1=0;
|
---|
| 730 | GeometryCalib.CoordUnit='cm';
|
---|
| 731 | XmlData.GeometryCalib=GeometryCalib;
|
---|
| 732 | if error==2, warntext=['no file ' FileBase '.civ'];
|
---|
| 733 | elseif error==1, warntext='inconsistent number of fields in the .civ file';
|
---|
| 734 | end
|
---|
| 735 | set(handles.npx,'String',num2str(npx));%fills nbre of pixels x box
|
---|
| 736 | set(handles.npy,'String',num2str(npy));%fills nbre of pixels y box
|
---|
| 737 | set(handles.pxcm,'String',num2str(pxcmx));%fills scale x (pixel/cm) box
|
---|
| 738 | set(handles.pycm,'String',num2str(pxcmy));%fills scale y (pixel/cm) box
|
---|
| 739 | set(handles.pxcm,'Visible','on');%fills scale x (pixel/cm) box
|
---|
| 740 | set(handles.pycm,'Visible','on');%fills scale y (pixel/cm) box
|
---|
| 741 | set(handles.view_xml,'Visible','on')
|
---|
| 742 | set(handles.view_xml,'String','view .civ')
|
---|
| 743 | else
|
---|
| 744 | set(handles.view_xml,'Visible','off')
|
---|
| 745 | end
|
---|
| 746 |
|
---|
| 747 | % store last index in handles.lat_i and .last_j
|
---|
| 748 | if ~isempty(XmlData.Time)
|
---|
| 749 | nbfield=size(XmlData.Time,1);
|
---|
| 750 | nburst=size(XmlData.Time,2);
|
---|
| 751 | end
|
---|
| 752 | last_i_cell=get(handles.last_i,'String');
|
---|
| 753 | if isempty(nbfield)
|
---|
| 754 | last_i_cell{1}='';
|
---|
| 755 | else
|
---|
| 756 | last_i_cell{1}=num2str(nbfield);
|
---|
| 757 | end
|
---|
| 758 | set(handles.last_i,'String',last_i_cell)
|
---|
| 759 | last_j_cell=get(handles.last_j,'String');
|
---|
| 760 | if isempty(nburst)
|
---|
| 761 | last_j_cell{1}='';
|
---|
| 762 | else
|
---|
| 763 | last_j_cell{1}=num2str(nburst);
|
---|
| 764 | end
|
---|
| 765 | set(handles.last_j,'String',last_j_cell);
|
---|
| 766 |
|
---|
| 767 | % store geometric calibration in UvData
|
---|
| 768 | if isfield(XmlData,'GeometryCalib')
|
---|
| 769 | GeometryCalib=XmlData.GeometryCalib;
|
---|
| 770 | if isempty(GeometryCalib)
|
---|
| 771 | set(handles.pxcm,'String','')
|
---|
| 772 | set(handles.pycm,'String','')
|
---|
[39] | 773 | set(handles.transform_fct,'Value',1); % no transform by default
|
---|
[2] | 774 | else
|
---|
| 775 | if (isfield(GeometryCalib,'R')& ~isequal(GeometryCalib.R(2,1),0) & ~isequal(GeometryCalib.R(1,2),0)) |...
|
---|
| 776 | (isfield(GeometryCalib,'kappa1')& ~isequal(GeometryCalib.kappa1,0))
|
---|
| 777 | set(handles.pxcm,'String','var')
|
---|
| 778 | set(handles.pycm,'String','var')
|
---|
| 779 | else
|
---|
| 780 | pixcmx=GeometryCalib.f*GeometryCalib.R(1,1)*GeometryCalib.sx/(GeometryCalib.Tz*GeometryCalib.dpx);
|
---|
| 781 | pixcmy=GeometryCalib.f*GeometryCalib.R(2,2)/(GeometryCalib.Tz*GeometryCalib.dpy);
|
---|
| 782 | set(handles.pxcm,'String',num2str(pixcmx))
|
---|
| 783 | set(handles.pycm,'String',num2str(pixcmy))
|
---|
| 784 | end
|
---|
[39] | 785 | set(handles.transform_fct,'Value',2); % phys transform by default
|
---|
[2] | 786 | if isfield(GeometryCalib,'SliceCoord')
|
---|
| 787 | siz=size(GeometryCalib.SliceCoord);
|
---|
| 788 | if siz(1)>1
|
---|
| 789 | NbSlice=siz(1);
|
---|
| 790 | set(handles.slices,'Visible','on')
|
---|
| 791 | set(handles.slices,'Value',1)
|
---|
| 792 | end
|
---|
| 793 | set(handles.nb_slice,'String',num2str(NbSlice))
|
---|
| 794 | slices_Callback(hObject, eventdata, handles)
|
---|
| 795 | % Coord=UvData.XmlData.GeometryCalib.SliceCoord;
|
---|
| 796 | % ZIndex=num_i1-NbSlice*(floor((num_i1-1)/NbSlice));
|
---|
| 797 | end
|
---|
| 798 | end
|
---|
| 799 | end
|
---|
| 800 |
|
---|
| 801 | %update the data attached to the uvmat interface
|
---|
| 802 | set(handles.nb_slice,'String',num2str(NbSlice))
|
---|
| 803 | if ~isempty(TimeUnit)
|
---|
| 804 | set(handles.time_txt,'String',['time (' TimeUnit ')'])
|
---|
| 805 | end
|
---|
| 806 | %set(handles.DtUnit,'String',['10^(-3)' TimeUnit])
|
---|
| 807 | UvData.TimeUnit=TimeUnit;
|
---|
| 808 | UvData.XmlData=XmlData;
|
---|
| 809 | UvData.NewSeries=1;
|
---|
| 810 | set(huvmat,'UserData',UvData)
|
---|
| 811 |
|
---|
| 812 | %display warning message
|
---|
| 813 | if ~isequal(warntext,'')
|
---|
| 814 | msgbox_uvmat('WARNING',warntext);
|
---|
| 815 | end
|
---|
| 816 |
|
---|
| 817 | % set default options in menu 'Fields'
|
---|
| 818 | if testima
|
---|
| 819 | set(handles.Fields,'Value',1) % set menu to 'image'
|
---|
| 820 | set(handles.Fields,'String',{'image';'get_field...';'velocity';'vort';'div';'more...'})
|
---|
| 821 | elseif isequal(FileExt,'.nc')|isequal(FileExt,'.cdf')
|
---|
| 822 | Data=nc2struct(FileName,[]);
|
---|
| 823 | col_vec=get(handles.col_vec,'String');
|
---|
| 824 | if isfield(Data,'absolut_time_T0')&& (isfield(Data,'civ1')||isfield(Data,'civ'))
|
---|
| 825 | set(handles.Fields,'String',{'image';'get_field...';'velocity';'vort';'div';'more...'})
|
---|
| 826 | set(handles.Fields,'Value',3) % set menu to 'velocity'
|
---|
| 827 | col_vec{1}='ima_cor';
|
---|
| 828 | else
|
---|
| 829 | set(handles.Fields,'Value',1) % set menu to 'get_field...
|
---|
| 830 | set(handles.Fields,'String',{'get_field...'})
|
---|
| 831 | col_vec{1}='get_field...';
|
---|
| 832 | end
|
---|
| 833 | set(handles.col_vec,'String',col_vec)
|
---|
| 834 | else
|
---|
| 835 | msgbox_uvmat('ERROR',['invalid input file extension ' FileExt])
|
---|
| 836 | return
|
---|
| 837 | end
|
---|
| 838 |
|
---|
| 839 | % set index navigation options and refresh plots
|
---|
| 840 | set(handles.RootPath,'BackgroundColor',[1 1 1])
|
---|
| 841 | drawnow
|
---|
| 842 | set_scan_options(hObject, eventdata, handles)
|
---|
| 843 |
|
---|
| 844 |
|
---|
| 845 | %-------------------------------------------------------------------
|
---|
| 846 | %-- set index navigation options for new series input and refresh plot
|
---|
| 847 | %-------------------------------------------------------------------
|
---|
| 848 | function set_scan_options(hObject, eventdata, handles)
|
---|
| 849 |
|
---|
| 850 | % set the corresponding index navigation options (TO CHECK WITH THE SECOND FIELD)
|
---|
| 851 | NomType=get(handles.FileIndex,'UserData');
|
---|
| 852 | NomType_1=get(handles.FileIndex_1,'UserData');
|
---|
| 853 | state_j='off'; %default
|
---|
| 854 | scan_option='i';
|
---|
| 855 | switch NomType
|
---|
| 856 | case {'_i_j','_i_j1-j2','_i1-i2_j','#_ab'},% two navigation indices
|
---|
| 857 | state_j='on';
|
---|
| 858 | if exist('nbfield','var') && isequal(nbfield,1)
|
---|
| 859 | scan_option='j';
|
---|
| 860 | else
|
---|
| 861 | scan_option='i';
|
---|
| 862 | end
|
---|
| 863 | end
|
---|
| 864 | if ~isempty(NomType_1)
|
---|
| 865 | switch NomType_1
|
---|
| 866 | case {'_i_j','_i_j1-j2','_i1-i2_j','#_ab'},% two navigation indices
|
---|
| 867 | state_j='on';
|
---|
| 868 | if exist('nbfield','var') && isequal(nbfield,1)
|
---|
| 869 | scan_option='j';
|
---|
| 870 | else
|
---|
| 871 | scan_option='i';
|
---|
| 872 | end
|
---|
| 873 | end
|
---|
| 874 | end
|
---|
| 875 | if isequal(scan_option,'i')
|
---|
| 876 | set(handles.scan_i,'Value',1)
|
---|
| 877 | scan_i_Callback(hObject, eventdata, handles);
|
---|
| 878 | else
|
---|
| 879 | set(handles.scan_j,'Value',1)
|
---|
| 880 | scan_j_Callback(hObject, eventdata, handles);
|
---|
| 881 | end
|
---|
| 882 | set(handles.scan_j,'Visible',state_j)
|
---|
| 883 | set(handles.j1,'Visible',state_j)
|
---|
| 884 | set(handles.j2,'Visible',state_j)
|
---|
| 885 | set(handles.last_j,'Visible',state_j);
|
---|
| 886 | set(handles.frame_j,'Visible',state_j);
|
---|
| 887 | set(handles.j_text,'Visible',state_j);
|
---|
| 888 |
|
---|
| 889 | % view the field
|
---|
| 890 | run0_Callback(hObject, eventdata, handles); %view field
|
---|
| 891 | mask_test=get(handles.mask_test,'value');
|
---|
| 892 | if mask_test
|
---|
| 893 | MaskData=get(handles.mask_test,'UserData');
|
---|
| 894 | if isfield(MaskData,'maskhandle') && ishandle(MaskData.maskhandle)
|
---|
| 895 | delete(MaskData.maskhandle) %delete old mask
|
---|
| 896 | end
|
---|
| 897 | mask_test_Callback(hObject, eventdata, handles)
|
---|
| 898 | end
|
---|
| 899 | %-------------------------------------------------------------------
|
---|
| 900 | function MenuBrowse_1_Callback(hObject, eventdata, handles)
|
---|
| 901 | %-------------------------------------------------------------------
|
---|
| 902 | huvmat=get(handles.run0,'parent');
|
---|
| 903 | UvData=get(huvmat,'UserData');
|
---|
| 904 |
|
---|
| 905 | RootPath=get(handles.RootPath,'String');
|
---|
| 906 | [FileName, PathName, filterindex] = uigetfile( ...
|
---|
| 907 | {'*.xml;*.xls;*.civ;*.jpg;*.png;*.avi;*.AVI;*.nc;*.cmx;*.fig;*.log;*.dat', ' (*.xml,*.xls,*.civ, *.jpg,*.png, *.avi,*.nc,*.cmx ,*.fig,*.log,*.dat)';
|
---|
| 908 | '*.xml', '.xml files '; ...
|
---|
| 909 | '*.xls', '.xls files '; ...
|
---|
| 910 | '*.civ', '.civ files '; ...
|
---|
| 911 | '*.jpg','.jpg image files'; ...
|
---|
| 912 | '*.png','.png image files'; ...
|
---|
| 913 | '*.avi;*.AVI','.avi movie files'; ...
|
---|
| 914 | '*.nc','.netcdf files'; ...
|
---|
| 915 | '*.cdf','.netcdf files'; ...
|
---|
| 916 | '*.cmx','.cmx text files';...
|
---|
| 917 | '*.cmx2','.cmx2 text files';...
|
---|
| 918 | '*.fig','.fig files (matlab fig)';...
|
---|
| 919 | '*.log','.log text files ';...
|
---|
| 920 | '*.dat','.dat text files ';...
|
---|
| 921 | '*.*', 'All Files (*.*)'}, ...
|
---|
| 922 | 'Pick a file',RootPath);
|
---|
| 923 | fileinput_1=[PathName FileName];%complete file name
|
---|
| 924 | testblank=findstr(fileinput_1,' ');%look for blanks
|
---|
| 925 | if ~isempty(testblank)
|
---|
[38] | 926 | msgbox_uvmat('ERROR',['The input file name ' fileinput_1 ' contains blank character : This is not allowed. Please change name'])
|
---|
[2] | 927 | return
|
---|
| 928 | end
|
---|
| 929 | sizf=size(fileinput_1);
|
---|
| 930 | if (~ischar(fileinput_1)|~isequal(sizf(1),1)),return;end
|
---|
| 931 |
|
---|
| 932 | % refresh the current displayed field
|
---|
| 933 | display_file_name_1(hObject,eventdata,handles,fileinput_1)
|
---|
| 934 |
|
---|
| 935 | %update list of recent files in the menubar
|
---|
| 936 | MenuFile_1=fileinput_1;
|
---|
| 937 | MenuFile_2=get(handles.MenuFile_1,'Label');
|
---|
| 938 | MenuFile_3=get(handles.MenuFile_2,'Label');
|
---|
| 939 | MenuFile_4=get(handles.MenuFile_3,'Label');
|
---|
| 940 | MenuFile_5=get(handles.MenuFile_4,'Label');
|
---|
| 941 | set(handles.MenuFile_1,'Label',MenuFile_1)
|
---|
| 942 | set(handles.MenuFile_2,'Label',MenuFile_2)
|
---|
| 943 | set(handles.MenuFile_3,'Label',MenuFile_3)
|
---|
| 944 | set(handles.MenuFile_4,'Label',MenuFile_4)
|
---|
| 945 | set(handles.MenuFile_5,'Label',MenuFile_5)
|
---|
| 946 | set(handles.MenuFile_1_1,'Label',MenuFile_1)
|
---|
| 947 | set(handles.MenuFile_2_1,'Label',MenuFile_2)
|
---|
| 948 | set(handles.MenuFile_3_1,'Label',MenuFile_3)
|
---|
| 949 | set(handles.MenuFile_4_1,'Label',MenuFile_4)
|
---|
| 950 | set(handles.MenuFile_5_1,'Label',MenuFile_5)
|
---|
| 951 | dir_perso=prefdir;
|
---|
| 952 | profil_perso=fullfile(dir_perso,'uvmat_perso.mat');
|
---|
| 953 | if exist(profil_perso,'file')
|
---|
| 954 | save (profil_perso,'MenuFile_1','MenuFile_2','MenuFile_3','MenuFile_4', 'MenuFile_5','-append'); %store the file names for future opening of uvmat
|
---|
| 955 | else
|
---|
| 956 | txt=ver;
|
---|
| 957 | Release=txt(1).Release;
|
---|
| 958 | relnumb=str2num(Release(3:4));
|
---|
| 959 | if relnumb >= 14
|
---|
| 960 | save (profil_perso,'MenuFile_1','MenuFile_2','MenuFile_3','MenuFile_4', 'MenuFile_5','-V6'); %store the file names for future opening of uvmat
|
---|
| 961 | else
|
---|
| 962 | save (profil_perso,'MenuFile_1','MenuFile_2','MenuFile_3','MenuFile_4', 'MenuFile_5'); %store the file names for future opening of uvmat
|
---|
| 963 | end
|
---|
| 964 | end
|
---|
| 965 |
|
---|
| 966 | % --------------------------------------------------------------------
|
---|
| 967 | function MenuFile_1_1_Callback(hObject, eventdata, handles)
|
---|
| 968 | fileinput_1=get(handles.MenuFile_1_1,'Label');
|
---|
| 969 | display_file_name_1(hObject,eventdata,handles,fileinput_1)
|
---|
| 970 |
|
---|
| 971 | % --------------------------------------------------------------------
|
---|
| 972 | function MenuFile_2_1_Callback(hObject, eventdata, handles)
|
---|
| 973 | fileinput_1=get(handles.MenuFile_2_1,'Label');
|
---|
| 974 | display_file_name_1(hObject,eventdata,handles,fileinput_1)
|
---|
| 975 |
|
---|
| 976 | % --------------------------------------------------------------------
|
---|
| 977 | function MenuFile_3_1_Callback(hObject, eventdata, handles)
|
---|
| 978 | fileinput_1=get(handles.MenuFile_3_1,'Label');
|
---|
| 979 | display_file_name_1(hObject,eventdata,handles,fileinput_1)
|
---|
| 980 |
|
---|
| 981 | % --------------------------------------------------------------------
|
---|
| 982 | function MenuFile_4_1_Callback(hObject, eventdata, handles)
|
---|
| 983 | fileinput_1=get(handles.MenuFile_4_1,'Label');
|
---|
| 984 | display_file_name_1(hObject,eventdata,handles,fileinput_1)
|
---|
| 985 |
|
---|
| 986 | % --------------------------------------------------------------------
|
---|
| 987 | function MenuFile_5_1_Callback(hObject, eventdata, handles)
|
---|
| 988 | fileinput_1=get(handles.MenuFile_5_1,'Label');
|
---|
| 989 | display_file_name_1(hObject,eventdata,handles,fileinput_1)
|
---|
| 990 |
|
---|
| 991 | %-----------------------------------------------------------------
|
---|
| 992 | % fills the edit boxes RootPath, RootFile,NomType...from an input file name 'fileinput'
|
---|
| 993 | %----------------------------------------------------------------
|
---|
| 994 | function display_file_name_1(hObject,eventdata,handles,fileinput_1)
|
---|
| 995 |
|
---|
| 996 | %[path,name,ext]=fileparts(fileinput_1);
|
---|
| 997 | [RootPath_1,RootFile_1,field_count,str2,str_a,str_b,FileExt_1,NomType_1,SubDir_1]=name2display(fileinput_1);
|
---|
| 998 | nbfield_1=1; %default
|
---|
| 999 | ext_test=FileExt_1;%default
|
---|
| 1000 | form=imformats(FileExt_1(2:end));
|
---|
| 1001 | if ~isempty(form) % if the extension corresponds to an image format recognized by Matlab
|
---|
| 1002 | imainfo=imfinfo(fileinput_1);
|
---|
| 1003 | nbfield_1=length(imainfo);
|
---|
| 1004 | ext_test='.image';
|
---|
| 1005 | elseif isequal(lower(FileExt_1),'.avi')
|
---|
| 1006 | info=aviinfo(fileinput_1);
|
---|
| 1007 | nbfield_1=info.NumFrames;
|
---|
| 1008 | ext_test='.image';
|
---|
| 1009 | end
|
---|
| 1010 |
|
---|
| 1011 | %open directly fig or text files
|
---|
| 1012 | switch ext_test
|
---|
| 1013 | case {'.civ','.log','.cmx','.cmx2','.txt'} %display text file
|
---|
| 1014 | edit(fileinput)
|
---|
| 1015 | return
|
---|
| 1016 | case '.fig' %display matlab figure
|
---|
| 1017 | hfig=open(fileinput);
|
---|
| 1018 | set(hfig,'WindowButtonMotionFcn','mouse_motion')%set mouse action functio
|
---|
| 1019 | set(hfig,'WindowButtonUpFcn','mouse_up')%set mouse click action function
|
---|
| 1020 | set(hfig,'WindowButtonUpFcn','mouse_down')%set mouse click action function
|
---|
| 1021 | return
|
---|
| 1022 | case {'.xml','.xls'} % edit xml or Excel files
|
---|
| 1023 | heditxml=editxml(fileinput);
|
---|
| 1024 | return
|
---|
| 1025 | case {'.image','.nc','.cdf'}
|
---|
| 1026 | % set(handles.FileIndex,'UserData',NomType_1);
|
---|
| 1027 | otherwise
|
---|
[38] | 1028 | msgbox_uvmat(['invalid input file extension ' FileExt_1 ' for uvmat'],'ERROR')
|
---|
[2] | 1029 | return
|
---|
| 1030 | end
|
---|
| 1031 |
|
---|
| 1032 | % test for image series in a single file and synchronise file indices of the two series
|
---|
| 1033 | if nbfield_1 >1 %case of image with multiple frames
|
---|
| 1034 | if nbfield_1 < num_i1
|
---|
[38] | 1035 | msgbox_uvmat('ERROR','current frame index beyond the input movie length')
|
---|
[2] | 1036 | return
|
---|
| 1037 | else
|
---|
| 1038 | NomType_1='*'; %indicate a set of indexed frames within a single file
|
---|
| 1039 | filename_new=fileinput_1;
|
---|
| 1040 | end
|
---|
| 1041 | else % cases of data files
|
---|
| 1042 | RootPath=get(handles.RootPath,'String');
|
---|
| 1043 | RootFile=get(handles.RootFile,'String');
|
---|
| 1044 | FileBase=fullfile(RootPath,RootFile);
|
---|
| 1045 | FileBase_1=fullfile(RootPath_1,RootFile_1);
|
---|
| 1046 | if isequal(FileBase,FileBase_1)
|
---|
| 1047 | filename_new=fileinput_1;
|
---|
| 1048 | else
|
---|
| 1049 | num_i1=stra2num(get(handles.i1,'String'));%get the current file indices from counters
|
---|
| 1050 | num_j1=stra2num(get(handles.j1,'String'));
|
---|
| 1051 | num_i2=stra2num(get(handles.i2,'String'));
|
---|
| 1052 | num_j2=stra2num(get(handles.j2,'String'));
|
---|
| 1053 | [filename_new,idetect]=...
|
---|
| 1054 | 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
|
---|
| 1055 | indices=''; %default
|
---|
| 1056 | if ~idetect
|
---|
[38] | 1057 | msgbox_uvmat('ERROR','second input file with indices corresponding to the first one does not exist')
|
---|
[2] | 1058 | return
|
---|
| 1059 | end
|
---|
| 1060 | end
|
---|
| 1061 | end
|
---|
| 1062 | set(handles.FileIndex,'UserData',NomType_1);
|
---|
| 1063 |
|
---|
| 1064 | % make visible and fill the second raw of edit boxes
|
---|
| 1065 | set(handles.RootPath_1,'Visible','on')
|
---|
| 1066 | set(handles.RootFile_1,'Visible','on')
|
---|
| 1067 | set(handles.SubDir_1,'Visible','on');
|
---|
| 1068 | set(handles.FileIndex_1,'Visible','on');
|
---|
| 1069 | set(handles.FileExt_1,'Visible','on');
|
---|
| 1070 | [FileName,RootPath,FileBase,FileIndices,FileExt,SubDir]=read_file_boxes(handles);
|
---|
| 1071 | if isequal(FileBase,FileBase_1)
|
---|
| 1072 | set(handles.RootPath_1,'String','"')
|
---|
| 1073 | set(handles.RootFile_1,'String','"');
|
---|
| 1074 | else
|
---|
| 1075 | set(handles.RootPath_1,'String',RootPath_1)
|
---|
| 1076 | set(handles.RootFile_1,'String',['/' RootFile_1]);
|
---|
| 1077 | end
|
---|
| 1078 | if isequal(SubDir_1,'')
|
---|
| 1079 | set(handles.SubDir_1,'String','');
|
---|
| 1080 | FileBaseSub_1=FileBase_1;
|
---|
| 1081 | else
|
---|
| 1082 | set(handles.SubDir_1,'String',['/' SubDir_1]);
|
---|
| 1083 | FileBaseSub_1=fullfile(FileBase_1,SubDir_1);
|
---|
| 1084 | end
|
---|
| 1085 | indices=filename_new(length(FileBaseSub_1)+1:end);
|
---|
| 1086 | indices(end-length(FileExt_1)+1:end)=[]; %remove extension
|
---|
| 1087 | set(handles.FileIndex_1,'String',indices)
|
---|
| 1088 | set(handles.FileIndex_1,'UserData',NomType_1)
|
---|
| 1089 | set(handles.FileExt_1,'String',FileExt_1);
|
---|
| 1090 |
|
---|
| 1091 | % default choice of fields
|
---|
| 1092 | if isequal(ext_test,'.image')
|
---|
| 1093 | set(handles.Fields_1,'String',{'';'image';'get_field...';'velocity';'vort';'div';'more...'})
|
---|
| 1094 | set(handles.Fields_1,'Value',2) % set menu to 'image'
|
---|
| 1095 | elseif isequal(FileExt_1,'.nc')|isequal(FileExt_1,'.cdf')
|
---|
| 1096 | Data=nc2struct(fileinput_1,[]);
|
---|
| 1097 | if isfield(Data,'absolut_time_T0')
|
---|
| 1098 | set(handles.Fields_1,'String',{'';'image';'get_field...';'velocity';'vort';'div';'more...'})
|
---|
| 1099 | set(handles.Fields_1,'Value',4) % set menu to 'velocity'
|
---|
| 1100 | else
|
---|
| 1101 | set(handles.Fields_1,'Value',2) % set menu to 'get_field...'
|
---|
| 1102 | set(handles.Fields_1,'String',{'';'get_field...'});
|
---|
| 1103 | end
|
---|
| 1104 | end
|
---|
| 1105 | set(handles.SubField,'Visible','on')
|
---|
| 1106 | set(handles.SubField,'Value',1)
|
---|
| 1107 | RootPath_1_Callback(hObject,eventdata,handles);
|
---|
| 1108 |
|
---|
| 1109 |
|
---|
| 1110 | %-----------------------------------------------------
|
---|
| 1111 | function RootPath_1_Callback(hObject,eventdata,handles)
|
---|
| 1112 | update_rootinfo_1(hObject,eventdata,handles)
|
---|
| 1113 |
|
---|
| 1114 | %-------------------------------------------------------------------
|
---|
| 1115 | function RootFile_1_Callback(hObject, eventdata, handles)
|
---|
| 1116 | update_rootinfo_1(hObject,eventdata,handles)
|
---|
| 1117 | %-------------------------------------------------------------------
|
---|
| 1118 |
|
---|
| 1119 | %-------------------------------------------------------------------
|
---|
| 1120 | function update_rootinfo_1(hObject,eventdata,handles) %A REVOIR
|
---|
| 1121 |
|
---|
| 1122 | set(handles.RootPath_1,'BackgroundColor',[1 1 0])% indicate active program by yellow color
|
---|
| 1123 | drawnow
|
---|
| 1124 | huvmat=get(handles.RootPath,'parent');
|
---|
| 1125 | UvData=get(huvmat,'UserData');%huvmat=handles of the uvmat interface
|
---|
| 1126 | UvData.NewSeries=1; %flag for run0: begin a new series
|
---|
| 1127 |
|
---|
| 1128 | [FileName,RootPath,FileBase,FileIndices,FileExt]=read_file_boxes_1(handles);
|
---|
| 1129 | if ~exist(FileName,'file')
|
---|
| 1130 | msgbox_uvmat('ERROR',['input file ' FileName ' not found']);
|
---|
| 1131 | end
|
---|
| 1132 | nbfield_1=[];%default
|
---|
| 1133 | nburst_1=[];%default
|
---|
| 1134 | XmlData.Time=[];
|
---|
| 1135 | XmlData.GeometryCalib=[];%default
|
---|
| 1136 | TimeUnit=[];
|
---|
| 1137 | if isfield(UvData,'TimeUnit')
|
---|
| 1138 | TimeUnit=UvData.TimeUnit;
|
---|
| 1139 | end
|
---|
| 1140 | TimeUnit_1=[];
|
---|
| 1141 | testima=0; %test for image input
|
---|
| 1142 | if isequal(lower(FileExt),'.avi') %.avi file
|
---|
| 1143 | testima=1;
|
---|
| 1144 | info=aviinfo([FileBase FileIndices FileExt]);
|
---|
| 1145 | nbfield_1=info.NumFrames;
|
---|
| 1146 | nburst_1=1;
|
---|
| 1147 | %set(handles.last_i,'String',num2str(info.NumFrames));%fills last_field box
|
---|
| 1148 | set(handles.Dt_txt,'String',['Dt=' num2str(1000/info.FramesPerSecond) 'ms']);%display the elementary time interval in millisec
|
---|
| 1149 | % set(handles.dt,'UserData',info.FramesPerSecond);
|
---|
| 1150 | time=[0:1/info.FramesPerSecond:(info.NumFrames-1)/info.FramesPerSecond]';
|
---|
| 1151 | npx=get(handles.npx,'String');
|
---|
| 1152 | npy=get(handles.npy,'String');
|
---|
| 1153 | if isequal(npx,'') || isequal(npy,'')
|
---|
| 1154 | set(handles.npx,'String',num2str(info.Width));%fills nbre of pixels x box
|
---|
| 1155 | set(handles.npy,'String',num2str(info.Height));%fills nbre of pixels y box
|
---|
| 1156 | end
|
---|
| 1157 | elseif ~isempty(imformats(FileExt(2:end))) %&& isequal(NomType,'*')% multi-frame image
|
---|
| 1158 | testima=1;
|
---|
| 1159 | imainfo=imfinfo([FileBase FileIndices FileExt]);
|
---|
| 1160 | if length(imainfo) >1 %case of image with multiple frames
|
---|
| 1161 | nbfield_1=length(imainfo);
|
---|
| 1162 | nburst_1=1;
|
---|
| 1163 | %set(handles.last_i,'String',num2str(length(imainfo)));%fills last_field box
|
---|
| 1164 | end
|
---|
| 1165 | else
|
---|
| 1166 | %set(handles.last_i,'String','');%fills last_field box
|
---|
| 1167 | set(handles.npx,'String','');%fills nbre of pixels x box
|
---|
| 1168 | set(handles.npy,'String','');%fills nbre of pixels y box
|
---|
| 1169 | end
|
---|
| 1170 |
|
---|
| 1171 | % find scaling parameters
|
---|
| 1172 | filexml=[FileBase '.xml'];
|
---|
| 1173 | fileciv=[FileBase '.civ'];
|
---|
| 1174 | warntext='';%default warning text
|
---|
| 1175 | if exist(filexml,'file')
|
---|
| 1176 | [XmlData,warntext]=imadoc2struct(filexml);
|
---|
| 1177 | if ~isempty(warntext)
|
---|
| 1178 | msgbox_uvmat('WARNING',warntext)
|
---|
| 1179 | end
|
---|
| 1180 | if isfield(XmlData,'Camera')
|
---|
| 1181 | % if isfield(XmlData.Camera,'NbSlice')&& ~isempty(XmlData.Camera.NbSlice)
|
---|
| 1182 | % NbSlice=XmlData.Camera.NbSlice;
|
---|
| 1183 | % end
|
---|
| 1184 | if isfield(XmlData.Camera,'TimeUnit')&& ~isempty(XmlData.Camera.TimeUnit)
|
---|
| 1185 | TimeUnit=XmlData.Camera.TimeUnit;
|
---|
| 1186 | end
|
---|
| 1187 | end
|
---|
| 1188 | elseif exist(fileciv,'file')% if .civ file found
|
---|
| 1189 | [error,XmlData.Time,TimeUnit,mode,npx,npy,pxcmx,pxcmy]=read_imatext([FileBase '.civ']);
|
---|
| 1190 | GeometryCalib.R=[pxcmx 0 0; 0 pxcmy 0;0 0 0];
|
---|
| 1191 | GeometryCalib.Tx=0;
|
---|
| 1192 | GeometryCalib.Ty=0;
|
---|
| 1193 | GeometryCalib.Tz=1;
|
---|
| 1194 | GeometryCalib.dpx=1;
|
---|
| 1195 | GeometryCalib.dpy=1;
|
---|
| 1196 | GeometryCalib.sx=1;
|
---|
| 1197 | GeometryCalib.Cx=0;
|
---|
| 1198 | GeometryCalib.Cy=0;
|
---|
| 1199 | GeometryCalib.f=1;
|
---|
| 1200 | GeometryCalib.kappa1=0;
|
---|
| 1201 | GeometryCalib.CoordUnit='cm';
|
---|
| 1202 | XmlData.GeometryCalib=GeometryCalib;
|
---|
| 1203 | if error==2, warntext=['no file ' FileBase '.civ'];
|
---|
| 1204 | elseif error==1, warntext='inconsistent number of fields in the .civ file';
|
---|
| 1205 | end
|
---|
| 1206 |
|
---|
| 1207 | set(handles.npx,'String',num2str(npx));%fills nbre of pixels x box
|
---|
| 1208 | set(handles.npy,'String',num2str(npy));%fills nbre of pixels y box
|
---|
| 1209 | set(handles.pxcm,'String',num2str(pxcmx));%fills scale x (pixel/cm) box
|
---|
| 1210 | set(handles.pycm,'String',num2str(pxcmy));%fills scale y (pixel/cm) box
|
---|
| 1211 | set(handles.pxcm,'Visible','on');%fills scale x (pixel/cm) box
|
---|
| 1212 | set(handles.pycm,'Visible','on');%fills scale y (pixel/cm) box
|
---|
| 1213 | end
|
---|
| 1214 | if ~isempty(TimeUnit_1) && ~isequal(TimeUnit_1,TimeUnit)
|
---|
[38] | 1215 | msgbox_uvmat('WARNING','the time units for the second series differs from the first one')
|
---|
[2] | 1216 | end
|
---|
| 1217 |
|
---|
| 1218 | % store last index in handles.lat_i and .last_j
|
---|
| 1219 | if ~isempty(XmlData.Time)
|
---|
| 1220 | nbfield_1=size(XmlData.Time,1);
|
---|
| 1221 | nburst_1=size(XmlData.Time,2);
|
---|
| 1222 | end
|
---|
| 1223 | last_i_cell=get(handles.last_i,'String');
|
---|
| 1224 | if isempty(nbfield_1)
|
---|
| 1225 | last_i_cell{2}='';
|
---|
| 1226 | else
|
---|
| 1227 | last_i_cell{2}=num2str(nbfield_1);
|
---|
| 1228 | end
|
---|
| 1229 | set(handles.last_i,'String',last_i_cell)
|
---|
| 1230 | last_j_cell=get(handles.last_j,'String');
|
---|
| 1231 | if isempty(nburst_1)
|
---|
| 1232 | last_j_cell{2}='';
|
---|
| 1233 | else
|
---|
| 1234 | last_j_cell{2}=num2str(nburst_1);
|
---|
| 1235 | end
|
---|
| 1236 | set(handles.last_j,'String',last_j_cell);
|
---|
| 1237 | if ~isequal(last_i_cell{1},last_i_cell{2}) || ~isequal(last_j_cell{1},last_j_cell{2})
|
---|
[38] | 1238 | msgbox_uvmat('WARNING','the numbers of input file of the second series differs from the first one')
|
---|
[2] | 1239 | end
|
---|
| 1240 |
|
---|
| 1241 | % store calibration data
|
---|
| 1242 | GeometryCalib=XmlData.GeometryCalib;
|
---|
| 1243 | if isempty(GeometryCalib)
|
---|
| 1244 | if isfield(UvData, 'GeometryCalib_1')
|
---|
| 1245 | UvData=rmfield(UvData,'GeometryCalib_1');
|
---|
| 1246 | end
|
---|
| 1247 | else
|
---|
| 1248 | UvData.GeometryCalib_1=GeometryCalib;
|
---|
| 1249 | if (isfield(GeometryCalib,'R')& ~isequal(GeometryCalib.R(2,1),0) & ~isequal(GeometryCalib.R(1,2),0)) |...
|
---|
| 1250 | (isfield(GeometryCalib,'kappa1')& ~isequal(GeometryCalib.kappa1,0))
|
---|
| 1251 | set(handles.pxcm,'String','var')
|
---|
| 1252 | set(handles.pycm,'String','var')
|
---|
| 1253 | else
|
---|
| 1254 | pixcmx=GeometryCalib.f*GeometryCalib.R(1,1)*GeometryCalib.sx/(GeometryCalib.Tz*GeometryCalib.dpx);
|
---|
| 1255 | pixcmy=GeometryCalib.f*GeometryCalib.R(2,2)/(GeometryCalib.Tz*GeometryCalib.dpy);
|
---|
| 1256 | set(handles.pxcm,'String',num2str(pixcmx))
|
---|
| 1257 | set(handles.pycm,'String',num2str(pixcmy))
|
---|
| 1258 | end
|
---|
| 1259 | end
|
---|
| 1260 | UvData.XmlData_1=XmlData;
|
---|
| 1261 | set(huvmat,'UserData',UvData)%update the data attached to the uvmat interface
|
---|
| 1262 |
|
---|
| 1263 | if ~isequal(warntext,'')
|
---|
[38] | 1264 | msgbox_uvmat('WARNING',warntext)
|
---|
[2] | 1265 | end
|
---|
| 1266 |
|
---|
| 1267 | set(handles.RootPath_1,'BackgroundColor',[1 1 1])% signa the end the input operation
|
---|
| 1268 | drawnow
|
---|
| 1269 |
|
---|
| 1270 | set_scan_options(hObject, eventdata, handles)
|
---|
| 1271 |
|
---|
| 1272 |
|
---|
| 1273 | %---------------------------------------------------
|
---|
| 1274 | % switch file index scanning options scan_i and scan_j in an exclusive way
|
---|
| 1275 | function scan_i_Callback(hObject, eventdata, handles)
|
---|
| 1276 | %---------------------------------------------------
|
---|
| 1277 | if get(handles.scan_i,'Value')==1
|
---|
| 1278 | set(handles.scan_i,'BackgroundColor',[1 1 0])
|
---|
| 1279 | set(handles.scan_j,'Value',0)
|
---|
| 1280 | set(handles.scan_j,'BackgroundColor',[0.831 0.816 0.784])
|
---|
| 1281 | else
|
---|
| 1282 | set(handles.scan_i,'BackgroundColor',[0.831 0.816 0.784])
|
---|
| 1283 | set(handles.scan_j,'Value',1)
|
---|
| 1284 | set(handles.scan_j,'BackgroundColor',[1 1 0])
|
---|
| 1285 | end
|
---|
| 1286 | %-------------------------------------------------------------------
|
---|
| 1287 | %---------------------------------------------------
|
---|
| 1288 | % switch file index scanning options scan_i and scan_j in an exclusive way
|
---|
| 1289 | function scan_j_Callback(hObject, eventdata, handles)
|
---|
| 1290 | %---------------------------------------------------
|
---|
| 1291 | %-------------------------------------------------------------------
|
---|
| 1292 | if get(handles.scan_j,'Value')==1
|
---|
| 1293 | set(handles.scan_j,'BackgroundColor',[1 1 0])
|
---|
| 1294 | set(handles.scan_i,'Value',0)
|
---|
| 1295 | set(handles.scan_i,'BackgroundColor',[0.831 0.816 0.784])
|
---|
| 1296 | else
|
---|
| 1297 | set(handles.scan_j,'BackgroundColor',[0.831 0.816 0.784])
|
---|
| 1298 | set(handles.scan_i,'Value',1)
|
---|
| 1299 | set(handles.scan_i,'BackgroundColor',[1 1 0])
|
---|
| 1300 | end
|
---|
| 1301 |
|
---|
| 1302 | %-------------------------------------------------------------------
|
---|
| 1303 | function i1_Callback(hObject, eventdata, handles)
|
---|
| 1304 | %-------------------------------------------------------------------
|
---|
| 1305 | % [filebase,num1,num_a,num2,num_b,ext,NomType,subdir]=read_input_file(handles);
|
---|
| 1306 | [FileName,RootPath,filebase,xx,FileExt]=read_file_boxes(handles);
|
---|
| 1307 | NomType=get(handles.FileIndex,'UserData');
|
---|
| 1308 | num1=stra2num(get(handles.i1,'String'));
|
---|
| 1309 | num2=stra2num(get(handles.i2,'String'));
|
---|
| 1310 | num_a=stra2num(get(handles.j1,'String'));
|
---|
| 1311 | num_b=stra2num(get(handles.j2,'String'));
|
---|
| 1312 | indices=name_generator('',num1,num_a,'',NomType,1,num2,num_b,'');
|
---|
| 1313 | set(handles.FileIndex,'String',indices)
|
---|
| 1314 | if get(handles.SubField,'Value')==1
|
---|
| 1315 | NomType_1=get(handles.FileIndex_1,'String');
|
---|
| 1316 | FileExt_1=get(handles.FileExt_1,'String');
|
---|
| 1317 | [P,F,str1,str2,str_a,str_b,Ext,NomType_1]=name2display(['xx' NomType_1 FileExt_1]);
|
---|
| 1318 | indices=name_generator('',num1,num_a,'',NomType_1,1,num2,num_b,'');
|
---|
| 1319 | set(handles.FileIndex_1,'String',indices)
|
---|
| 1320 | end
|
---|
| 1321 | run0_Callback(hObject, eventdata, handles)
|
---|
| 1322 |
|
---|
| 1323 | %-------------------------------------------------------------------
|
---|
| 1324 | function i2_Callback(hObject, eventdata, handles)
|
---|
| 1325 | i1_Callback(hObject, eventdata, handles)
|
---|
| 1326 | %-------------------------------------------------------------------
|
---|
| 1327 |
|
---|
| 1328 | %-------------------------------------------------------------------
|
---|
| 1329 | function j1_Callback(hObject, eventdata, handles)
|
---|
| 1330 | i1_Callback(hObject, eventdata, handles)
|
---|
| 1331 | %-------------------------------------------------------------------
|
---|
| 1332 |
|
---|
| 1333 | %-------------------------------------------------------------------
|
---|
| 1334 | function j2_Callback(hObject, eventdata, handles)
|
---|
| 1335 | i1_Callback(hObject, eventdata, handles)
|
---|
| 1336 | %-------------------------------------------------------------------
|
---|
| 1337 |
|
---|
| 1338 | %-------------------------------------------------------------------
|
---|
| 1339 | function slices_Callback(hObject, eventdata, handles)
|
---|
| 1340 | %-------------------------------------------------------------------
|
---|
| 1341 | if get(handles.slices,'Value')==1
|
---|
| 1342 | set(handles.slices,'BackgroundColor',[1 1 0])
|
---|
| 1343 | set(handles.nb_slice,'Visible','on')
|
---|
| 1344 | set(handles.z_text,'Visible','on')
|
---|
| 1345 | set(handles.z_index,'Visible','on')
|
---|
| 1346 | nb_slice_Callback(hObject, eventdata, handles)
|
---|
| 1347 | % z=mod(num_i1-1,nbslice)+1;
|
---|
| 1348 | % set(handles.z_index,'String',num2str(z))
|
---|
| 1349 | else
|
---|
| 1350 | set(handles.nb_slice,'Visible','off')
|
---|
| 1351 | set(handles.slices,'BackgroundColor',[0.7 0.7 0.7])
|
---|
| 1352 | set(handles.z_text,'Visible','off')
|
---|
| 1353 | set(handles.z_index,'Visible','off')
|
---|
| 1354 | set(handles.masklevel,'Value',1)
|
---|
| 1355 | set(handles.masklevel,'String',{'1'})
|
---|
| 1356 | end
|
---|
| 1357 |
|
---|
| 1358 | %-------------------------------------------------------------------
|
---|
| 1359 | function nb_slice_Callback(hObject, eventdata, handles)
|
---|
| 1360 | %-------------------------------------------------------------------
|
---|
| 1361 | num_i1=str2num(get(handles.i1,'String'));
|
---|
| 1362 | nbslice=str2num(get(handles.nb_slice,'String'));
|
---|
| 1363 | z=mod(num_i1-1,nbslice)+1;
|
---|
| 1364 | set(handles.z_index,'String',num2str(z))
|
---|
| 1365 | for ilist=1:nbslice
|
---|
| 1366 | list_index{ilist,1}=num2str(ilist);
|
---|
| 1367 | end
|
---|
| 1368 | set(handles.masklevel,'String',list_index)
|
---|
| 1369 | set(handles.masklevel,'Value',z)
|
---|
| 1370 |
|
---|
| 1371 |
|
---|
| 1372 | %-------------------------------------------------------------------
|
---|
| 1373 | % --- Executes on button press in view_xml.
|
---|
| 1374 | function view_xml_Callback(hObject, eventdata, handles)
|
---|
| 1375 | [FileName,RootPath,FileBase,FileIndices,FileExt]=read_file_boxes(handles);
|
---|
| 1376 | option=get(handles.view_xml,'String');
|
---|
| 1377 | if isequal(option,'view .xml')
|
---|
| 1378 | FileXml=[FileBase '.xml'];
|
---|
| 1379 | heditxml=editxml(FileXml);
|
---|
| 1380 | end
|
---|
| 1381 |
|
---|
| 1382 | %-------------------------------------------------------------------
|
---|
| 1383 | % --- Executes on button press in mask_test.
|
---|
| 1384 | function mask_test_Callback(hObject, eventdata, handles)
|
---|
| 1385 | %-------------------------------------------------------------------
|
---|
| 1386 | if isequal(get(handles.mask_test,'Value'),1)
|
---|
| 1387 | [FF,RootPath,FileBase]=read_file_boxes(handles);
|
---|
| 1388 | num_i1=stra2num(get(handles.i1,'String'));
|
---|
| 1389 | num_j1=stra2num(get(handles.j1,'String'));
|
---|
| 1390 | currentdir=pwd;
|
---|
| 1391 | cd(RootPath);
|
---|
| 1392 | maskfiles=dir('*_*mask_*.png');%look for a mask file
|
---|
| 1393 | cd(currentdir);%come back to the working directory
|
---|
| 1394 | mdetect=0;
|
---|
| 1395 | if isempty(maskfiles)
|
---|
| 1396 | msgbox_uvmat('ERROR','no mask file detected (format ..._xxmask_ii.png needed), use the menu bar Tools/Make mask')
|
---|
| 1397 | return
|
---|
| 1398 | end
|
---|
| 1399 | for ilist=1:length(maskfiles)
|
---|
| 1400 | maskname=maskfiles(ilist).name;% take the first mask file in the list
|
---|
| 1401 | [rr,ff,x1,x2,xa,xb,xext,Mask_NomType{ilist}]=name2display(maskname);
|
---|
| 1402 | if ~strcmp(Mask_NomType{ilist},Mask_NomType{1})
|
---|
| 1403 | msgbox_uvmat('ERROR',['inconsistent mask types ' Mask_NomType{1} Mask_NomType{ilist } ' coexist in the current image directory'])
|
---|
| 1404 | return
|
---|
| 1405 | end
|
---|
| 1406 | [Path2,Name,ext]=fileparts(maskname);
|
---|
| 1407 | Namedouble=double(Name);
|
---|
| 1408 | val=(48>Namedouble)|(Namedouble>57);% select the non-numerical characters
|
---|
| 1409 | ind_mask=findstr('mask',Name);
|
---|
| 1410 | i=ind_mask-1;
|
---|
| 1411 | while val(i)==0 & i>0
|
---|
| 1412 | i=i-1;
|
---|
| 1413 | end
|
---|
| 1414 | nbmask_str=str2num(Name(i+1:ind_mask-1));
|
---|
| 1415 | if ~isempty(nbmask_str)
|
---|
| 1416 | nbslice(ilist)=nbmask_str; % number of different masks (slices)
|
---|
| 1417 | end
|
---|
| 1418 | end
|
---|
| 1419 | if isequal(min(nbslice),max(nbslice))
|
---|
| 1420 | nbslice=nbslice(1);
|
---|
| 1421 | else
|
---|
| 1422 | msgbox_uvmat('ERROR','several inconsistent mask sets coexist in the current image directory')
|
---|
| 1423 | return
|
---|
| 1424 | end
|
---|
| 1425 | if ~isempty(nbslice) && Name(i)=='_'
|
---|
| 1426 | Mask.Base=[FileBase Name(i:ind_mask+3)];
|
---|
| 1427 | Mask.NbSlice=nbslice;
|
---|
| 1428 | num_i1=mod(num_i1-1,nbslice)+1
|
---|
| 1429 | Mask.NomType=Mask_NomType{1};
|
---|
| 1430 | [maskname,mdetect]=name_generator(Mask.Base,num_i1,num_j1,'.png',Mask.NomType)%
|
---|
| 1431 | mdetect=exist(maskname,'file')
|
---|
| 1432 | if mdetect
|
---|
| 1433 | set(handles.nb_slice,'String',Name(i+1:ind_mask-1));
|
---|
| 1434 | set(handles.nb_slice,'BackgroundColor',[1 1 0])
|
---|
| 1435 | set(handles.mask_test,'UserData',Mask);
|
---|
| 1436 | set(handles.mask_test,'BackgroundColor',[1 1 0])
|
---|
| 1437 | if nbslice > 1
|
---|
| 1438 | set(handles.slices,'value',1)
|
---|
| 1439 | slices_Callback(hObject, eventdata, handles)
|
---|
| 1440 | end
|
---|
| 1441 | end
|
---|
| 1442 | end
|
---|
| 1443 | if mdetect==0
|
---|
| 1444 | msgbox_uvmat('ERROR','no mask file detected (format ..._xxmask_ii.png needed), use the menu bar Tools/Make mask')
|
---|
| 1445 | set(handles.mask_test,'Value',0)
|
---|
| 1446 | return
|
---|
| 1447 | end
|
---|
| 1448 | update_mask(handles,num_i1,num_j1);
|
---|
| 1449 | else
|
---|
| 1450 | MaskData=get(handles.mask_test,'UserData');
|
---|
| 1451 | if isfield(MaskData,'maskhandle') && ishandle(MaskData.maskhandle)
|
---|
| 1452 | delete(MaskData.maskhandle)
|
---|
| 1453 | end
|
---|
| 1454 | set(handles.mask_test,'UserData',[])
|
---|
| 1455 | huvmat=get(handles.mask_test,'parent');
|
---|
| 1456 | UvData=get(huvmat,'UserData');
|
---|
| 1457 | if isfield(UvData,'MaskName')
|
---|
| 1458 | UvData=rmfield(UvData,'MaskName');
|
---|
| 1459 | set(huvmat,'UserData',UvData)
|
---|
| 1460 | end
|
---|
| 1461 | set(handles.mask_test,'BackgroundColor',[0.7 0.7 0.7])
|
---|
| 1462 | end
|
---|
| 1463 |
|
---|
| 1464 | %-------------------------------------------------------------------
|
---|
| 1465 | function update_mask(handles,num_i1,num_j1)
|
---|
| 1466 | %-------------------------------------------------------------------
|
---|
| 1467 |
|
---|
| 1468 | MaskData=get(handles.mask_test,'UserData');
|
---|
| 1469 | if isfield(MaskData,'maskhandle')&& ishandle(MaskData.maskhandle)
|
---|
| 1470 | uistack(MaskData.maskhandle,'top');
|
---|
| 1471 | end
|
---|
| 1472 | num_i1_mask=mod(num_i1-1,MaskData.NbSlice)+1;
|
---|
| 1473 | [MaskName,mdetect]=name_generator(MaskData.Base,num_i1_mask,num_j1,'.png',MaskData.NomType);
|
---|
| 1474 | huvmat=get(handles.mask_test,'parent');
|
---|
| 1475 | UvData=get(huvmat,'UserData');
|
---|
| 1476 |
|
---|
| 1477 | %update mask image if the mask is new
|
---|
| 1478 | if ~ (isfield(UvData,'MaskName') && isequal(UvData.MaskName,MaskName))
|
---|
| 1479 | UvData.MaskName=MaskName; %update the recorded name on UvData
|
---|
| 1480 | set(huvmat,'UserData',UvData);
|
---|
| 1481 | if mdetect==0
|
---|
| 1482 | if isfield(MaskData,'maskhandle')&& ishandle(MaskData.maskhandle)
|
---|
| 1483 | delete(MaskData.maskhandle)
|
---|
| 1484 | end
|
---|
| 1485 | else
|
---|
| 1486 | %read mask image
|
---|
| 1487 | Mask.AName='image';
|
---|
| 1488 | Mask.A=imread(MaskName);
|
---|
| 1489 | npxy=size(Mask.A);
|
---|
| 1490 | Mask.AX=[0.5 npxy(2)-0.5];
|
---|
| 1491 | Mask.AY=[npxy(1)-0.5 0.5 ];
|
---|
| 1492 | Mask.CoordType='px';
|
---|
| 1493 | if isequal(get(handles.slices,'Value'),1)
|
---|
| 1494 | NbSlice=str2num(get(handles.nb_slice,'String'));
|
---|
| 1495 | num_i1=str2num(get(handles.i1,'String'));
|
---|
| 1496 | Mask.ZIndex=mod(num_i1-1,NbSlice)+1;
|
---|
| 1497 | end
|
---|
| 1498 | %px to phys or other transform on field
|
---|
[39] | 1499 | menu_transform=get(handles.transform_fct,'String');
|
---|
| 1500 | choice_value=get(handles.transform_fct,'Value');
|
---|
| 1501 | transform_name=menu_transform{choice_value};%name of the transform fct given by the menu 'transform_fct'
|
---|
| 1502 | transform_list=get(handles.transform_fct,'UserData');
|
---|
[38] | 1503 | transform=transform_list{choice_value};
|
---|
| 1504 | if ~isequal(transform_name,'') && ~isequal(transform_name,'px')
|
---|
[2] | 1505 | if isfield(UvData,'XmlData') && isfield(UvData.XmlData,'GeometryCalib')%use geometry calib recorded from the ImaDoc xml file as first priority
|
---|
| 1506 | Calib=UvData.XmlData.GeometryCalib;
|
---|
[38] | 1507 | Mask=transform(Mask,UvData.XmlData);
|
---|
[2] | 1508 | end
|
---|
| 1509 | end
|
---|
| 1510 | flagmask=Mask.A < 200;
|
---|
| 1511 |
|
---|
| 1512 | %make brown color image
|
---|
| 1513 | imflag(:,:,1)=0.9*flagmask;
|
---|
| 1514 | imflag(:,:,2)=0.7*flagmask;
|
---|
| 1515 | imflag(:,:,3)=zeros(size(flagmask));
|
---|
| 1516 |
|
---|
| 1517 | %update mask image
|
---|
| 1518 | hmask=[]; %default
|
---|
| 1519 | if isfield(MaskData,'maskhandle')&& ishandle(MaskData.maskhandle)
|
---|
| 1520 | hmask=MaskData.maskhandle;
|
---|
| 1521 | end
|
---|
| 1522 | if ~isempty(hmask)
|
---|
| 1523 | set(hmask,'CData',imflag)
|
---|
| 1524 | set(hmask,'AlphaData',flagmask*0.6)
|
---|
| 1525 | set(hmask,'XData',Mask.AX);
|
---|
| 1526 | set(hmask,'YData',Mask.AY);
|
---|
| 1527 | % uistack(hmask,'top')
|
---|
| 1528 | else
|
---|
| 1529 | axes(handles.axes3)
|
---|
| 1530 | hold on
|
---|
| 1531 | MaskData.maskhandle=image(Mask.AX,Mask.AY,imflag,'Tag','mask','HitTest','off','AlphaData',0.6*flagmask);
|
---|
| 1532 | % set(MaskData.maskhandle,'AlphaData',0.6*flagmask)
|
---|
| 1533 | set(handles.mask_test,'UserData',MaskData)
|
---|
| 1534 | end
|
---|
| 1535 | end
|
---|
| 1536 | end
|
---|
| 1537 |
|
---|
| 1538 |
|
---|
| 1539 | %-------------------------------------------------------------------
|
---|
| 1540 | function MenuExportFigure_Callback(hObject, eventdata, handles)
|
---|
| 1541 | %-------------------------------------------------------------------
|
---|
| 1542 | huvmat=get(handles.MenuExport,'parent');
|
---|
| 1543 | UvData=get(huvmat,'UserData');
|
---|
| 1544 | hfig=figure;
|
---|
| 1545 | newaxes=copyobj(handles.axes3,hfig);
|
---|
| 1546 | map=colormap(handles.axes3);
|
---|
| 1547 | colormap(map);%transmit the current colormap to the zoom fig
|
---|
| 1548 | colorbar
|
---|
| 1549 |
|
---|
| 1550 | %-------------------------------------------------------------------
|
---|
| 1551 | %-------------------------------------------------------------------
|
---|
| 1552 | % III - MAIN REFRESH FUNCTIONS : 'FRAME PLOT'
|
---|
| 1553 | %-------------------------------------------------------------------
|
---|
| 1554 | %-------------------------------------------------------------------
|
---|
| 1555 |
|
---|
| 1556 | %Executes on button press in runplus: make one step forward and call
|
---|
| 1557 | %run0. The step forward is along the fields series 1 or 2 depending on
|
---|
| 1558 | %the scan_i and scan_j check box (exclusive each other)
|
---|
| 1559 | %-------------------------------------------------------------------
|
---|
| 1560 | function runplus_Callback(hObject, eventdata, handles)
|
---|
| 1561 | increment=str2num(get(handles.increment_scan,'String')); %get the field increment d
|
---|
| 1562 | runpm(hObject,eventdata,handles,increment)
|
---|
| 1563 |
|
---|
| 1564 | %-------------------------------------------------------------------
|
---|
| 1565 | %Executes on button press in runmin: make one step backward and call
|
---|
| 1566 | %run0. The step backward is along the fields series 1 or 2 depending on
|
---|
| 1567 | %the scan_i and scan_j check box (exclusive each other)
|
---|
| 1568 | %-------------------------------------------------------------------
|
---|
| 1569 | function runmin_Callback(hObject, eventdata, handles)
|
---|
| 1570 | increment=-str2num(get(handles.increment_scan,'String')); %get the field increment d
|
---|
| 1571 | runpm(hObject,eventdata,handles,increment)
|
---|
| 1572 |
|
---|
| 1573 | %-------------------------------------------------------------------
|
---|
| 1574 | %Executes on button press in runmin: make one step backward and call
|
---|
| 1575 | %run0. The step backward is along the fields series 1 or 2 depending on
|
---|
| 1576 | %the scan_i and scan_j check box (exclusive each other)
|
---|
| 1577 | %-------------------------------------------------------------------
|
---|
| 1578 | function RunMovie_Callback(hObject, eventdata, handles)
|
---|
| 1579 | %------------------------------------------------------------------
|
---|
| 1580 | set(handles.RunMovie,'BackgroundColor',[1 1 0])%paint the command button in yellow
|
---|
| 1581 | drawnow
|
---|
| 1582 | increment=str2num(get(handles.increment_scan,'String')); %get the field increment d
|
---|
| 1583 | set(handles.STOP,'Visible','on')
|
---|
| 1584 | set(handles.speed,'Visible','on')
|
---|
| 1585 | set(handles.speed_txt,'Visible','on')
|
---|
| 1586 | set(handles.RunMovie,'BusyAction','queue')
|
---|
| 1587 | testavi=0;
|
---|
| 1588 | huvmat=get(handles.RunMovie,'parent');
|
---|
| 1589 | UvData=get(huvmat,'UserData');
|
---|
| 1590 |
|
---|
| 1591 | while get(handles.speed,'Value')~=0 & isequal(get(handles.RunMovie,'BusyAction'),'queue') % enable STOP command
|
---|
| 1592 | runpm(hObject,eventdata,handles,increment)
|
---|
| 1593 | pause(1.02-get(handles.speed,'Value'))% wait for next image
|
---|
| 1594 | end
|
---|
| 1595 | if isfield(UvData,'aviobj') && ~isempty( UvData.aviobj),
|
---|
| 1596 | UvData.aviobj=close(UvData.aviobj);
|
---|
| 1597 | set(huvmat,'UserData',UvData);
|
---|
| 1598 | end
|
---|
| 1599 | set(handles.RunMovie,'BackgroundColor',[1 0 0])%paint the command buttonback to red
|
---|
| 1600 |
|
---|
| 1601 | %-------------------------------------------------------------------
|
---|
| 1602 | function STOP_Callback(hObject, eventdata, handles)
|
---|
| 1603 | %-------------------------------------------------------------------
|
---|
| 1604 | set(handles.run0,'BusyAction','Cancel')
|
---|
| 1605 | set(handles.RunMovie,'BusyAction','Cancel')
|
---|
| 1606 | set(handles.MenuExportMovie,'BusyAction','Cancel')
|
---|
| 1607 |
|
---|
| 1608 |
|
---|
| 1609 | %------------------------------------------------------------------
|
---|
| 1610 | function runpm(hObject,eventdata,handles,increment)
|
---|
| 1611 | %------------------------------------------------------------------
|
---|
| 1612 | %read the data on the current input rootfile(s)
|
---|
| 1613 |
|
---|
| 1614 | [FileName,RootPath,filebase,FileIndices,FileExt,subdir]=read_file_boxes(handles);
|
---|
| 1615 | NomType=get(handles.FileIndex,'UserData');
|
---|
| 1616 |
|
---|
| 1617 | num1=stra2num(get(handles.i1,'String'));
|
---|
| 1618 | num2=stra2num(get(handles.i2,'String'));
|
---|
| 1619 | num_a=stra2num(get(handles.j1,'String'));
|
---|
| 1620 | num_b=stra2num(get(handles.j2,'String'));
|
---|
| 1621 |
|
---|
| 1622 | sub_value= get(handles.SubField,'Value');
|
---|
| 1623 | if sub_value ==1
|
---|
| 1624 | [FileName_1,RootPath_1,filebase_1,FileIndices_1,FileExt_1,SubDir_1]=read_file_boxes_1(handles);
|
---|
| 1625 | end
|
---|
| 1626 |
|
---|
| 1627 | comp_input=get(handles.fix_pair,'Value');
|
---|
| 1628 | if isequal(NomType,'_i1-i2')|isequal(NomType,'_i1-i2_j')
|
---|
| 1629 | comp_input=1; %impose a fixed pair interval
|
---|
| 1630 | set(handles.fix_pair,'Value',1)
|
---|
| 1631 | end
|
---|
| 1632 |
|
---|
| 1633 | %case of scanning along the first direction (rootfile numbers)
|
---|
| 1634 | if get(handles.scan_i,'Value')==1% case of scanning along field numbers
|
---|
| 1635 | num1=num1+increment;
|
---|
| 1636 | num2=num2+increment;
|
---|
| 1637 | if comp_input==0% find a free pair
|
---|
| 1638 | [filename,num_i1_out,num_j1_out,num_i2_out,num_j2_out]=...
|
---|
| 1639 | name_generator(filebase,num1,num_a,FileExt,NomType,0,num2,num_b,subdir);
|
---|
| 1640 | if exist(filename,'file')
|
---|
| 1641 | num_a=num_j1_out;
|
---|
| 1642 | num_b=num_j2_out;
|
---|
| 1643 | end
|
---|
| 1644 | end
|
---|
| 1645 | if sub_value>=2
|
---|
| 1646 | num_i1=num_i1+increment;
|
---|
| 1647 | num_i2=num_i2+increment;
|
---|
| 1648 | end
|
---|
| 1649 | else % case of scanning along the second direction (burst numbers)
|
---|
| 1650 | lastfield_cell=get(handles.last_j,'String'); % get the last field number
|
---|
| 1651 | lastfield=str2num(lastfield_cell{1});
|
---|
| 1652 | num_a=num_a+increment;
|
---|
| 1653 | num_b=num_b+increment;
|
---|
| 1654 | if sub_value >=2
|
---|
| 1655 | num_j1=num_j1+increment;
|
---|
| 1656 | num_j2=num_j2+increment;
|
---|
| 1657 | elseif ~isempty(lastfield) && num_a>lastfield
|
---|
| 1658 | num_a=1;
|
---|
| 1659 | num1=num1+1;
|
---|
| 1660 | num2=num2+1;
|
---|
| 1661 | end
|
---|
| 1662 | end
|
---|
| 1663 |
|
---|
| 1664 | % display the new open numbers
|
---|
| 1665 | set(handles.i1,'String',num2stra(num1,NomType,1));
|
---|
| 1666 | set(handles.i2,'String',num2stra(num2,NomType,1));
|
---|
| 1667 | set(handles.j1,'String',num2stra(num_a,NomType,2));
|
---|
| 1668 | set(handles.j2,'String',num2stra(num_b,NomType,2));
|
---|
| 1669 | [indices]=name_generator('',num1,num_a,'',NomType,1,num2,num_b,'');
|
---|
| 1670 | set(handles.FileIndex,'String',indices);
|
---|
| 1671 | if sub_value ==1
|
---|
| 1672 | NomType_1=get(handles.FileIndex_1,'UserData');
|
---|
| 1673 | [indices]=...
|
---|
| 1674 | name_generator('',num1,num_a,'',NomType_1,1,num2,num_b,'');
|
---|
| 1675 | set(handles.FileIndex_1,'String',indices);
|
---|
| 1676 | end
|
---|
| 1677 |
|
---|
| 1678 | % refresh plots
|
---|
| 1679 | run0_Callback(hObject, eventdata, handles); %run
|
---|
| 1680 |
|
---|
| 1681 |
|
---|
| 1682 | %-------------------------------------------------------
|
---|
| 1683 | % --- Executes on button press in movie_pair.
|
---|
| 1684 | %-------------------------------------------------------
|
---|
| 1685 | function movie_pair_Callback(hObject, eventdata, handles)
|
---|
| 1686 | %initialisation
|
---|
| 1687 | set(handles.movie_pair,'BackgroundColor',[1 1 0])%paint the command button in yellow
|
---|
| 1688 | drawnow
|
---|
| 1689 | list_fields=get(handles.Fields,'String');% list menu fields
|
---|
| 1690 | index_fields=get(handles.Fields,'Value');% selected string index
|
---|
| 1691 | FieldName=list_fields{index_fields}; % selected field
|
---|
| 1692 | huvmat=get(handles.movie_pair,'parent');
|
---|
| 1693 | if isequal(FieldName,'image')
|
---|
| 1694 | run0_Callback(hObject, eventdata, handles)%display the first image
|
---|
| 1695 | UvData=get(huvmat,'UserData');
|
---|
| 1696 | else
|
---|
[38] | 1697 | msgbox_uvmat('ERROR','an image or movie must be first introduced as input')
|
---|
[2] | 1698 | return
|
---|
| 1699 | end
|
---|
| 1700 | [ff,rr,filebase,xx,Ext,SubDir]=read_file_boxes(handles);
|
---|
| 1701 | NomType=get(handles.FileIndex,'UserData');
|
---|
| 1702 | num_i2=str2num(get(handles.i2,'String'));
|
---|
| 1703 | num_j2=str2num(get(handles.j2,'String'));
|
---|
| 1704 | if ~isempty(num_j2)
|
---|
| 1705 | num_i1=str2num(get(handles.i1,'String'));
|
---|
| 1706 | [imaname_1,idetect]=name_generator(filebase,num_i1,num_j2,Ext,NomType);
|
---|
| 1707 | if idetect==0
|
---|
[38] | 1708 | msgbox_uvmat('ERROR',['second input open (-) ' imaname_1 ' not found']);
|
---|
[2] | 1709 | return
|
---|
| 1710 | end
|
---|
| 1711 | set(handles.i2,'String',''); % indicates that the second index i2 is not used
|
---|
| 1712 | elseif ~isempty(num_i2)
|
---|
| 1713 | num_j1=str2num(get(handles.j1,'String'));
|
---|
| 1714 | [imaname_1,idetect]=name_generator(filebase,num_i2,num_j1,Ext,NomType);
|
---|
| 1715 | if idetect==0
|
---|
[38] | 1716 | msgbox_uvmat('ERROR',['second input open (-) ' imaname_1 ' not found']);
|
---|
[2] | 1717 | return
|
---|
| 1718 | end
|
---|
| 1719 | else
|
---|
[38] | 1720 | msgbox_uvmat('ERROR', 'a second image index i2 or j2 is needed to show the pair as a movie')
|
---|
[2] | 1721 | return
|
---|
| 1722 | end
|
---|
| 1723 |
|
---|
| 1724 | %read the second image
|
---|
| 1725 | Field.AName='image';
|
---|
| 1726 | Field.AX=UvData.Field.AX;
|
---|
| 1727 | Field.AY=UvData.Field.AY;
|
---|
| 1728 | Field.CoordType='px';
|
---|
| 1729 | [Field.A,error]=read_image(imaname_1,NomType,num_i2);
|
---|
| 1730 |
|
---|
| 1731 |
|
---|
| 1732 | %px to phys or other transform on field
|
---|
[39] | 1733 | menu_transform=get(handles.transform_fct,'String');
|
---|
| 1734 | choice_value=get(handles.transform_fct,'Value');
|
---|
| 1735 | transform_name=menu_transform{choice_value};%name of the transform fct given by the menu 'transform_fct'
|
---|
| 1736 | transform_list=get(handles.transform_fct,'UserData');
|
---|
[38] | 1737 | transform=transform_list{choice_value};
|
---|
| 1738 | if ~isequal(transform_name,'') && ~isequal(transform_name,'px')
|
---|
[2] | 1739 | if isfield(UvData,'XmlData') && isfield(UvData.XmlData,'GeometryCalib')%use geometry calib recorded from the ImaDoc xml file as first priority
|
---|
[38] | 1740 | Field=transform(Field,UvData.XmlData);
|
---|
[2] | 1741 | end
|
---|
| 1742 | end
|
---|
| 1743 |
|
---|
| 1744 | % make movie until movie speed is set to 0 or STOP is activated
|
---|
| 1745 | hima=findobj(handles.axes3,'Tag','ima');% %handles.axes3 =main plotting window (A GENERALISER)
|
---|
| 1746 | set(handles.STOP,'Visible','on')
|
---|
| 1747 | set(handles.speed,'Visible','on')
|
---|
| 1748 | set(handles.speed_txt,'Visible','on')
|
---|
| 1749 | while get(handles.speed,'Value')~=0 & isequal(get(handles.run0,'BusyAction'),'queue'); % enable STOP command
|
---|
| 1750 | % read and plot the series of images in non erase mode
|
---|
| 1751 | set(hima,'CData',Field.A);
|
---|
| 1752 | pause(1.02-get(handles.speed,'Value'));% wait for next image
|
---|
| 1753 | set(hima,'CData',UvData.Field.A);
|
---|
| 1754 | pause(1.02-get(handles.speed,'Value'));% wait for next image
|
---|
| 1755 | end
|
---|
| 1756 | set(handles.movie_pair,'BackgroundColor',[1 0 0])%paint the command button in red
|
---|
| 1757 |
|
---|
| 1758 | %run0_Callback(hObject, eventdata, handles)
|
---|
| 1759 |
|
---|
| 1760 | %-------------------------------------------------------
|
---|
| 1761 | % --- Executes on button press in run0.
|
---|
| 1762 | %-------------------------------------------------
|
---|
| 1763 | function run0_Callback(hObject, eventdata, handles)
|
---|
| 1764 |
|
---|
| 1765 | %initialisation
|
---|
| 1766 | set(handles.run0,'BackgroundColor',[1 1 0])%paint the command button in yellow
|
---|
| 1767 | drawnow
|
---|
| 1768 | abstime=[];
|
---|
| 1769 | abstime_1=[];
|
---|
| 1770 | dt=[];
|
---|
| 1771 | CalibCell={};%default
|
---|
| 1772 | Field={};
|
---|
| 1773 | huvmat=get(handles.run0,'parent');
|
---|
| 1774 | UvData=get(huvmat,'UserData');
|
---|
| 1775 | if isfield(UvData,'Txt')
|
---|
| 1776 | UvData=rmfield(UvData,'Txt');%erase previous error message
|
---|
| 1777 | end
|
---|
| 1778 | set(handles.run0,'BusyAction','queue');
|
---|
| 1779 | if ishandle(handles.UVMAT_title) %remove title panel on uvmat
|
---|
| 1780 | delete(handles.UVMAT_title)
|
---|
| 1781 | end
|
---|
| 1782 |
|
---|
| 1783 | % determine the main input file information for action
|
---|
| 1784 | TestInputFile=1;%default
|
---|
| 1785 | if isfield(UvData,'TestInputFile')&& isequal(UvData.TestInputFile,0),
|
---|
| 1786 | TestInputFile=0;
|
---|
| 1787 | end
|
---|
| 1788 | num_i1=[];%default
|
---|
| 1789 | if TestInputFile
|
---|
| 1790 | [filename,RootPath,filebase,xx,Ext,SubDir]=read_file_boxes(handles);
|
---|
| 1791 | if ~exist(filename,'file')
|
---|
| 1792 | msgbox_uvmat('ERROR',['input file ' filename ' does not exist'])
|
---|
| 1793 | return
|
---|
| 1794 | end
|
---|
| 1795 | num_i1=stra2num(get(handles.i1,'String'));
|
---|
| 1796 | num_i2=stra2num(get(handles.i2,'String'));
|
---|
| 1797 | num_j1=stra2num(get(handles.j1,'String'));
|
---|
| 1798 | num_j2=stra2num(get(handles.j2,'String'));
|
---|
| 1799 | NomType=get(handles.FileIndex,'UserData');
|
---|
| 1800 | %update the z position index
|
---|
| 1801 | % if isequal(get(handles.nb_slice,'String'),'vol.')%case of volume
|
---|
| 1802 | % set(handles.z_index,'String',get(handles.j1,'String'));
|
---|
| 1803 | % else
|
---|
| 1804 | nbslice=str2num(get(handles.nb_slice,'String'));
|
---|
| 1805 | z_index=mod(num_i1-1,nbslice)+1;
|
---|
| 1806 | if ~isempty(nbslice)
|
---|
| 1807 | z_index=mod(num_i1-1,nbslice)+1;
|
---|
| 1808 | set(handles.z_index,'String',num2str(z_index))
|
---|
| 1809 | % refresh menu for save_mask if relevant
|
---|
| 1810 | masknumber=get(handles.masklevel,'String');
|
---|
| 1811 | if length(masknumber)>=z_index
|
---|
| 1812 | set(handles.masklevel,'Value',z_index)
|
---|
| 1813 | end
|
---|
| 1814 | end
|
---|
| 1815 | % end
|
---|
| 1816 | % choose the main field
|
---|
| 1817 | testima=0;
|
---|
| 1818 | if isequal(lower(Ext),'.avi')||isequal(lower(Ext),'.vol')
|
---|
| 1819 | testima=1;
|
---|
| 1820 | FieldName='image';
|
---|
| 1821 | else
|
---|
| 1822 | form=imformats(Ext([2:end]));
|
---|
| 1823 | if ~isempty(form)% if the extension corresponds to an image format recognized by Matlab
|
---|
| 1824 | testima=1;
|
---|
| 1825 | FieldName='image';
|
---|
| 1826 | end
|
---|
| 1827 | end
|
---|
| 1828 | else
|
---|
| 1829 | filename=[];
|
---|
| 1830 | FieldName='get_field...';
|
---|
| 1831 | testima=0;
|
---|
| 1832 | end
|
---|
| 1833 | VelType=[];%default
|
---|
| 1834 |
|
---|
| 1835 | if ~testima
|
---|
| 1836 | list_fields=get(handles.Fields,'String');% list menu fields
|
---|
| 1837 | index_fields=get(handles.Fields,'Value');% selected string index
|
---|
| 1838 | FieldName= list_fields{index_fields}; % selected field
|
---|
| 1839 | if isequal(FieldName,'get_field...')% read the field names on the interface get_field...
|
---|
| 1840 | VelType=get(handles.Fields,'UserData');
|
---|
| 1841 | Field{1}=get(handles.Fields,'UserData');
|
---|
| 1842 | else
|
---|
| 1843 | VelType=setfield(handles);
|
---|
| 1844 | %enable_transform(handles,'on')% no field transform (possible transform in the GUI get_field)
|
---|
| 1845 | end
|
---|
| 1846 | end
|
---|
| 1847 |
|
---|
| 1848 | % choose a second field if Subfield option is 'on'
|
---|
| 1849 | filename_1=[];
|
---|
| 1850 | VelType_1=[];%default
|
---|
| 1851 | FieldName_1=[];
|
---|
| 1852 | scal_color=[];
|
---|
| 1853 | testvel=0;
|
---|
| 1854 | testX=0;%default
|
---|
| 1855 | VelType_1=setfield_1(handles);
|
---|
| 1856 | sub_value=get(handles.SubField,'Value');
|
---|
| 1857 | if sub_value==1
|
---|
| 1858 | filename_1=read_file_boxes_1(handles);
|
---|
| 1859 | if ~exist(filename_1,'file')
|
---|
| 1860 | msgbox_uvmat('ERROR',['second file ' filename_1 ' does not exist'])
|
---|
| 1861 | return
|
---|
| 1862 | end
|
---|
| 1863 | NomType_1=get(handles.FileIndex_1,'UserData');
|
---|
| 1864 | list_fields=get(handles.Fields_1,'String');% list menu fields
|
---|
| 1865 | index_fields=get(handles.Fields_1,'Value');% selected string index
|
---|
| 1866 | FieldName_1= list_fields{index_fields}; % selected field
|
---|
| 1867 | if isequal(VelType_1,'*')% free veltype choice
|
---|
| 1868 | VelType_1=[];
|
---|
| 1869 | elseif isequal(VelType_1,'"')% veltype the same as for the first field
|
---|
| 1870 | if isempty(VelType)
|
---|
| 1871 | VelType_1=[];
|
---|
| 1872 | else
|
---|
| 1873 | VelType_1=VelType;
|
---|
| 1874 | end
|
---|
| 1875 | end
|
---|
| 1876 | end
|
---|
| 1877 |
|
---|
| 1878 | % test for keeping the previous stored data if the input files are unchanged
|
---|
| 1879 | test_keepdata_1=0;%defautl
|
---|
| 1880 | test_keepdata=0;
|
---|
| 1881 | if sub_value>=2
|
---|
| 1882 | if ~isequal(NomType_1,'*')%in cas of a series of files (not avi movie)
|
---|
| 1883 | if isfield(UvData,'filename_1')& isfield(UvData,'VelType_1') & isfield(UvData,'FieldName_1')
|
---|
| 1884 | test_keepdata_1= isequal(filename_1,UvData.filename_1)&...
|
---|
| 1885 | isequal(VelType_1,UvData.filename_1) & isequal(FieldName_1,UvData.FieldName_1);
|
---|
| 1886 |
|
---|
| 1887 | end
|
---|
| 1888 | end
|
---|
| 1889 | end
|
---|
| 1890 |
|
---|
| 1891 | %read the input field(s)
|
---|
| 1892 | testima_1=isequal(FieldName_1,'image');
|
---|
| 1893 | %read images
|
---|
| 1894 | if ~isempty(filename) && testima
|
---|
| 1895 | if isfield(UvData,'MovieObject')
|
---|
| 1896 | A=read(UvData.MovieObject,num_i1);
|
---|
| 1897 | else
|
---|
| 1898 | [A,error]=read_image(filename,NomType,num_i1);
|
---|
| 1899 | if ~isequal(error,0)
|
---|
| 1900 | msgbox_uvmat('ERROR',error)
|
---|
| 1901 | return
|
---|
| 1902 | end
|
---|
| 1903 | end
|
---|
| 1904 | npxy=size(A);
|
---|
| 1905 | set(handles.npx,'String',num2str(npxy(2)));% display image size on the interface
|
---|
| 1906 | set(handles.npy,'String',num2str(npxy(1)));
|
---|
| 1907 | Rangx=[0.5 npxy(2)-0.5]; % coordinates of the first and last pixel centers
|
---|
| 1908 | Rangy=[npxy(1)-0.5 0.5]; %
|
---|
| 1909 | npx=str2num(get(handles.npx,'String'));
|
---|
| 1910 | npy=str2num(get(handles.npy,'String'));
|
---|
| 1911 | if isfield(UvData.XmlData,'Time')
|
---|
| 1912 | abs_time=UvData.XmlData.Time;
|
---|
| 1913 | end
|
---|
| 1914 | Field{1}.AName='image';
|
---|
| 1915 | Field{1}.ListVarName={'AY','AX','A'}; %
|
---|
| 1916 | if size(A,3)==3;%color
|
---|
| 1917 | Field{1}.VarDimName={'AY','AX',{'AY','AX','rgb'}}; %
|
---|
| 1918 | else
|
---|
| 1919 | Field{1}.VarDimName={'AY','AX',{'AY','AX'}}; %
|
---|
| 1920 | end
|
---|
| 1921 | Field{1}.AY=Rangy;
|
---|
| 1922 | Field{1}.AX=Rangx;
|
---|
| 1923 | Field{1}.A=A;
|
---|
| 1924 | Field{1}.CoordType='px'; %used for mouse_motion
|
---|
| 1925 | Field{1}.CoordUnit='pixel'; %used for mouse_motion
|
---|
| 1926 | end
|
---|
| 1927 | if ~isfield(UvData,'Txt')& ~isempty(filename_1) & testima_1
|
---|
| 1928 | [A,error]=read_image(filename_1,NomType_1,num_i1);
|
---|
| 1929 | if ~isequal(error,0)
|
---|
| 1930 | msgbox_uvmat('ERROR',error)
|
---|
| 1931 | return
|
---|
| 1932 | end
|
---|
| 1933 | npxy=size(A);
|
---|
| 1934 | set(handles.npx,'String',num2str(npxy(2)));% display image size on the interface
|
---|
| 1935 | set(handles.npy,'String',num2str(npxy(1)));
|
---|
| 1936 | Rangx=[0.5 npxy(2)-0.5]; % coordinates of the first and last pixel centers
|
---|
| 1937 | Rangy=[npxy(1)-0.5 0.5]; %
|
---|
| 1938 | npx=str2num(get(handles.npx,'String'));
|
---|
| 1939 | npy=str2num(get(handles.npy,'String'));
|
---|
| 1940 | if isfield(UvData,'XmlData_1') && isfield(UvData.XmlData_1,'Time')
|
---|
| 1941 | abs_time=UvData.XmlData_1.Time;
|
---|
| 1942 | end
|
---|
| 1943 | Field{2}.AName='image';
|
---|
| 1944 | Field{2}.ListVarName={'AY','AX','A'}; %
|
---|
| 1945 | if size(A,3)==3;%color
|
---|
| 1946 | Field{2}.VarDimName={'AY','AX',{'AY','AX','rgb'}}; %
|
---|
| 1947 | else
|
---|
| 1948 | Field{2}.VarDimName={'AY','AX',{'AY','AX'}}; %
|
---|
| 1949 | end
|
---|
| 1950 | Field{2}.AY=Rangy;
|
---|
| 1951 | Field{2}.AX=Rangx;
|
---|
| 1952 | Field{2}.A=A;
|
---|
| 1953 | Field{2}.CoordType='px'; %used for mouse_motion
|
---|
| 1954 | Field{2}.CoordUnit='px'; %used for move_mou
|
---|
| 1955 | end
|
---|
| 1956 |
|
---|
| 1957 | %read ncfile(s)
|
---|
| 1958 | CivStage_1=0;%default
|
---|
| 1959 | VelType_out_1=[];
|
---|
| 1960 | InputField={FieldName};
|
---|
| 1961 | InputField_1={FieldName_1};
|
---|
| 1962 | if ~isfield(UvData,'Txt') && ((~isempty(filename)&~testima) || (~isempty(filename_1)&~testima_1)) ;
|
---|
| 1963 | %read the velocity field(s) from netcdf rootfile(s)
|
---|
| 1964 | list_code=get(handles.col_vec,'String');% list menu fields
|
---|
| 1965 | index_code=get(handles.col_vec,'Value');% selected string index
|
---|
| 1966 | scal_color= list_code{index_code(1)}; % selected field
|
---|
| 1967 | if isequal(FieldName,'velocity')&& ~isequal(scal_color,'black') && ~isequal(scal_color,'white')
|
---|
| 1968 | InputField=[InputField scal_color];
|
---|
| 1969 | end
|
---|
| 1970 | if isequal(FieldName_1,'velocity') && ~isequal(scal_color,'black') && ~isequal(scal_color,'white')
|
---|
| 1971 | InputField_1=[InputField_1 scal_color];
|
---|
| 1972 | end
|
---|
| 1973 | if ~testima %read the first nc field
|
---|
| 1974 | if isequal(FieldName,'get_field...')% read the field names on the interface get_field.
|
---|
| 1975 | test_detect=0;%default
|
---|
| 1976 | VelType=get(handles.Fields,'UserData');
|
---|
| 1977 | hget_field=findobj(allchild(0),'Name','get_field');%find the get_field... GUI
|
---|
| 1978 | if isempty(hget_field)
|
---|
| 1979 | hget_field= get_field(filename);%open the get_field GUI
|
---|
| 1980 | end
|
---|
| 1981 | test_detect=1;
|
---|
| 1982 | hhget_field=guidata(hget_field);
|
---|
| 1983 | set(hhget_field.inputfile,'String',filename)% update the list of input fields in get_field
|
---|
| 1984 | set(hhget_field.ACTION,'Value',1)% PLOT option selected
|
---|
| 1985 | set(hhget_field.list_fig,'Value',2)% plotting axes =uvmat selected
|
---|
| 1986 | [Field{1},errormsg]=read_get_field(hget_field); %read the names of the variables to plot in the get_field GUI
|
---|
| 1987 | if ~isempty(errormsg)
|
---|
| 1988 | msgbox_uvmat('ERROR',['error in uvmat/run0_Callback/read_get_field: ' errormsg])
|
---|
| 1989 | return
|
---|
| 1990 | end
|
---|
| 1991 | CivStage=0;
|
---|
| 1992 | VelType_out=[];
|
---|
| 1993 | else
|
---|
| 1994 | [Field{1},VelType_out]=read_civxdata(filename,InputField,VelType);
|
---|
| 1995 | if isfield(Field{1},'Txt')
|
---|
| 1996 | msgbox_uvmat('ERROR',Field{1}.Txt)
|
---|
| 1997 | return
|
---|
| 1998 | end
|
---|
| 1999 | CivStage=Field{1}.CivStage;
|
---|
| 2000 | UvData.NbDim=Field{1}.nb_dim;
|
---|
| 2001 | end
|
---|
| 2002 | end
|
---|
| 2003 | if ~isempty(filename_1) && ~testima_1 %read the second file
|
---|
| 2004 | if isequal(FieldName_1,'get_field...')% read the field names on the interface get_field.
|
---|
| 2005 | test_detect=0;%default
|
---|
| 2006 | hget_field=findobj(allchild(0),'Name','get_field_1');%find the get_field... GUI
|
---|
| 2007 | if isempty(hget_field)
|
---|
| 2008 | hget_field= get_field(filename_1);%open the get_field GUI
|
---|
| 2009 | set(hget_field,'name','get_field_1')
|
---|
| 2010 | % enable_transform(handles,'off')% no field transform (possible transform in the GUI get_field)
|
---|
| 2011 | end
|
---|
| 2012 | test_detect=1;
|
---|
| 2013 | hhget_field=guidata(hget_field);%handles of GUI elements in get_field
|
---|
| 2014 | SubField=get_field('read_var_names',hObject,eventdata,hhget_field); %read the names of the variables to plot in the get_field GUI
|
---|
| 2015 | [Field{2},var_detect]=nc2struct(filename_1,SubField.ListVarName); %read the corresponding input data
|
---|
| 2016 | Field{2}.VarAttribute=SubField.VarAttribute;
|
---|
[39] | 2017 | % if isequal(get(hhget_field.transform_fct,'Visible'),'on')
|
---|
| 2018 | % list_transform=get(hhget_field.transform_fct,'String');
|
---|
| 2019 | % val_list=get(hhget_field.transform_fct,'Value');
|
---|
[38] | 2020 | % transf=list_transform{val_list};
|
---|
| 2021 | % if ~isempty(transf)
|
---|
| 2022 | % Field{2}=feval(transf,Field{2});
|
---|
| 2023 | % end
|
---|
| 2024 | % end
|
---|
[2] | 2025 |
|
---|
| 2026 | %update the display on get_field
|
---|
| 2027 | set(hhget_field.inputfile,'String',filename_1)
|
---|
| 2028 | set(hhget_field.variables,'Value',1)
|
---|
| 2029 | Tabchar={''};%default
|
---|
| 2030 | Tabcell=[];
|
---|
| 2031 | if isfield(Field{2},'ListGlobalAttribute')& ~isempty(Field{2}.ListGlobalAttribute)
|
---|
| 2032 | for iline=1:length(Field{2}.ListGlobalAttribute)
|
---|
| 2033 | Tabcell{iline,1}=Field{2}.ListGlobalAttribute{iline};
|
---|
| 2034 | if isfield(Field{2}, Field{2}.ListGlobalAttribute{iline})
|
---|
| 2035 | eval(['val=Field{2}.' Field{2}.ListGlobalAttribute{iline} ';'])
|
---|
| 2036 | if ischar(val);
|
---|
| 2037 | Tabcell{iline,2}=val;
|
---|
| 2038 | else
|
---|
| 2039 | Tabcell{iline,2}=num2str(val);
|
---|
| 2040 | end
|
---|
| 2041 | end
|
---|
| 2042 | end
|
---|
| 2043 | if ~isempty(Tabcell)
|
---|
| 2044 | Tabchar=cell2tab(Tabcell,'=');
|
---|
| 2045 | Tabchar=[{''};Tabchar];
|
---|
| 2046 | end
|
---|
| 2047 | end
|
---|
| 2048 | set(hhget_field.attributes,'String',Tabchar);%update list of global attributes in get_field
|
---|
| 2049 | else
|
---|
| 2050 | [Field{2},VelType_out_1]=read_civxdata(filename_1,[],VelType_1);
|
---|
| 2051 | CivStage_1=Field{2}.CivStage;
|
---|
| 2052 | end
|
---|
| 2053 | if testima
|
---|
| 2054 | VelType_out=VelType_out_1;
|
---|
| 2055 | end
|
---|
| 2056 | end
|
---|
| 2057 | end
|
---|
| 2058 |
|
---|
| 2059 | %update the display buttons for the first velocity type (first menuline)
|
---|
| 2060 | veltype_handles=[handles.civ1 handles.interp1 handles.filter1 handles.civ2 handles.interp2 handles.filter2];
|
---|
| 2061 | if testima
|
---|
| 2062 | reset_vel_type(veltype_handles)
|
---|
| 2063 | elseif isempty(VelType)
|
---|
| 2064 | set_veltype_display(veltype_handles,CivStage)%update the display of available velocity types for the first field
|
---|
| 2065 | if isempty(VelType_out)
|
---|
| 2066 | reset_vel_type(veltype_handles)
|
---|
| 2067 | else
|
---|
| 2068 | handle1=eval(['handles.' VelType_out]);
|
---|
| 2069 | reset_vel_type(veltype_handles,handle1)
|
---|
| 2070 | end
|
---|
| 2071 | end
|
---|
| 2072 |
|
---|
| 2073 | %update the display buttons for the second velocity type (second menuline)
|
---|
| 2074 | veltype_handles_1=[handles.civ1_1 handles.interp1_1 handles.filter1_1 handles.civ2_1 handles.interp2_1 handles.filter2_1];
|
---|
| 2075 | if testima_1
|
---|
| 2076 | reset_vel_type(veltype_handles_1)
|
---|
| 2077 | elseif isempty(VelType_1)
|
---|
| 2078 | set_veltype_display(veltype_handles_1,CivStage_1)%update the display of available velocity types for the first field
|
---|
| 2079 | if isempty(VelType_out_1)
|
---|
| 2080 | reset_vel_type(veltype_handles_1)
|
---|
| 2081 | else
|
---|
| 2082 | handle1=eval(['handles.' VelType_out_1 '_1']);
|
---|
| 2083 | reset_vel_type(veltype_handles_1,handle1)
|
---|
| 2084 | end
|
---|
| 2085 | end
|
---|
| 2086 |
|
---|
| 2087 | %introduce w as background image by default for a new series (only for nbdim=2)
|
---|
| 2088 | if ~isfield(UvData,'NewSeries')
|
---|
| 2089 | UvData.NewSeries=1;
|
---|
| 2090 | end
|
---|
| 2091 | %put W as background image by default if NbDim=2:
|
---|
| 2092 | if ~isfield(UvData,'NbDim')|isempty(UvData.NbDim)|~isequal(UvData.NbDim,3)
|
---|
| 2093 | if UvData.NewSeries && isequal(get(handles.SubField,'Value'),0) && isfield(Field{1},'W') && ~isempty(Field{1}.W);
|
---|
| 2094 | set(handles.SubField,'Value',1);
|
---|
| 2095 | menu=update_menu(handles.Fields_1,'w');%update the menu for the background scalar nd set the choice to 'w'
|
---|
| 2096 | set(handles.RootPath_1,'String','"')
|
---|
| 2097 | set(handles.RootFile_1,'String','"')
|
---|
| 2098 | set(handles.SubDir_1,'String','"');
|
---|
| 2099 | [indices]=name_generator('',num_i1,num_j1,'',NomType,1,num_i2,num_j2,'');
|
---|
| 2100 | set(handles.FileIndex_1,'String',indices)
|
---|
| 2101 | set(handles.FileExt_1,'String','"');
|
---|
| 2102 | set(handles.Fields_1,'Visible','on');
|
---|
| 2103 | set(handles.Fields_1,'Visible','on');
|
---|
| 2104 | set(handles.RootPath_1,'Visible','on')
|
---|
| 2105 | set(handles.RootFile_1,'Visible','on')
|
---|
| 2106 | set(handles.SubDir_1,'Visible','on');
|
---|
| 2107 | set(handles.FileIndex_1,'Visible','on');
|
---|
| 2108 | set(handles.FileExt_1,'Visible','on');
|
---|
| 2109 | set(handles.Fields_1,'Visible','on');
|
---|
| 2110 | Field{1}.AName='w';
|
---|
| 2111 | testscal=1;
|
---|
| 2112 | end
|
---|
| 2113 | end
|
---|
| 2114 |
|
---|
| 2115 | %multislice case
|
---|
| 2116 | if TestInputFile &&(~isfield(UvData,'NbDim') || isequal(UvData.NbDim,2))&&...%2D case
|
---|
| 2117 | isfield(UvData,'XmlData') && isfield(UvData.XmlData,'GeometryCalib')&& isfield(UvData.XmlData.GeometryCalib,'SliceCoord')
|
---|
| 2118 | % nbfield2=str2num(get(handles.last_j,'String'));
|
---|
| 2119 | siz=size(UvData.XmlData.GeometryCalib.SliceCoord);
|
---|
| 2120 | if siz(1)>1
|
---|
| 2121 | NbSlice=siz(1);
|
---|
| 2122 | set(handles.slices,'Visible','on')
|
---|
| 2123 | set(handles.slices,'Value',1)
|
---|
| 2124 | else
|
---|
| 2125 | NbSlice=1;
|
---|
| 2126 | end
|
---|
| 2127 | set(handles.nb_slice,'String',num2str(NbSlice))
|
---|
| 2128 | slices_Callback(hObject, eventdata, handles)
|
---|
| 2129 | % Coord=UvData.XmlData.GeometryCalib.SliceCoord;
|
---|
| 2130 | % ZIndex=num_i1-NbSlice*(floor((num_i1-1)/NbSlice));
|
---|
| 2131 | % Field{1}.Z=ZIndex;
|
---|
| 2132 | end
|
---|
| 2133 |
|
---|
| 2134 | %store the current open names, fields and vel types in uvmat interface
|
---|
| 2135 | UvData.filename=filename;
|
---|
| 2136 | UvData.filename_1=filename_1;
|
---|
| 2137 | UvData.VelType=VelType;
|
---|
| 2138 | UvData.VelType_1=VelType_1;
|
---|
| 2139 | UvData.FieldName=FieldName;
|
---|
| 2140 | UvData.FieldName_1=FieldName_1;
|
---|
| 2141 | if ~isempty(scal_color)
|
---|
| 2142 | UvData.CName=scal_color;
|
---|
| 2143 | end
|
---|
| 2144 |
|
---|
| 2145 | %coordinate transform or user fct
|
---|
| 2146 | XmlData=[];%default
|
---|
| 2147 | if isfield(UvData,'XmlData')%use geometry calib recorded from the ImaDoc xml file as first priority
|
---|
| 2148 | XmlData=UvData.XmlData;
|
---|
| 2149 | end
|
---|
| 2150 | XmlData_1=[];%default
|
---|
| 2151 | if isfield(UvData,'XmlData_1')
|
---|
| 2152 | XmlData_1=UvData.XmlData_1;
|
---|
| 2153 | end
|
---|
[39] | 2154 | menu_transform=get(handles.transform_fct,'String');
|
---|
| 2155 | choice_value=get(handles.transform_fct,'Value');
|
---|
| 2156 | %transform=menu_transform{choice_value};%name of the transform fct given by the menu 'transform_fct'
|
---|
| 2157 | transform_list=get(handles.transform_fct,'UserData');
|
---|
| 2158 | transform=transform_list{choice_value};%selected function handles
|
---|
[2] | 2159 |
|
---|
| 2160 | % z index
|
---|
| 2161 | if TestInputFile
|
---|
| 2162 | Field{1}.ZIndex=mod(num_i1-1,nbslice)+1;
|
---|
| 2163 | end
|
---|
| 2164 | %px to phys or other transform on field
|
---|
[38] | 2165 | if ~isempty(transform)
|
---|
[2] | 2166 | if length(Field)>=2
|
---|
| 2167 | Field{2}.ZIndex=mod(num_i1-1,nbslice)+1;
|
---|
[38] | 2168 | [Field{1},Field{2}]=transform(Field{1},XmlData,Field{2},XmlData_1);
|
---|
[2] | 2169 | if isempty(Field{2})
|
---|
| 2170 | Field(2)=[];
|
---|
| 2171 | end
|
---|
| 2172 | else
|
---|
[38] | 2173 | Field{1}=transform(Field{1},XmlData);
|
---|
[2] | 2174 | end
|
---|
| 2175 | end
|
---|
| 2176 |
|
---|
| 2177 | %calculate scalar
|
---|
| 2178 | if ~testima && ~isequal(FieldName,'get_field...')%
|
---|
| 2179 | Field{1}=calc_field(InputField,Field{1});
|
---|
| 2180 | end
|
---|
| 2181 | if length(Field)==2 && ~testima_1 && ~isequal(FieldName,'get_field...')
|
---|
| 2182 | Field{2}=calc_field(InputField_1,Field{2});
|
---|
| 2183 | end
|
---|
| 2184 |
|
---|
| 2185 | % combine the two input fields (e.g. substract velocity fields)
|
---|
| 2186 | if numel(Field)==2
|
---|
| 2187 | if ~(isequal(get(handles.movie_pair,'Value'),1) & isequal(FieldName,'image') & isequal(FieldName_1,'image')) %combine fields if not viewing image pairs
|
---|
| 2188 | UvData.Field=sub_field(Field{1},Field{2}); %TO UPDATE FOR MORE GENERAL INPUT
|
---|
| 2189 | end
|
---|
| 2190 | else
|
---|
| 2191 | UvData.Field=Field{1};
|
---|
| 2192 | end
|
---|
| 2193 | UvData.NewSeries=0;% put to 0 the test for a new field series (set by RootPath_callback)
|
---|
| 2194 | % test 3D , default projection menuplane and typical mesh (needed to menuopen set_object)
|
---|
| 2195 | test_x=0;
|
---|
| 2196 | test_z=0;% test for unstructured z coordinate
|
---|
| 2197 | UvData.ZMax=0;
|
---|
| 2198 | UvData.ZMin=0;%default
|
---|
| 2199 | UvData.Mesh=1; %default
|
---|
| 2200 | [UvData.Field,errormsg]=check_field_structure(UvData.Field);
|
---|
| 2201 | if ~isempty(errormsg)
|
---|
| 2202 | msgbox_uvmat('ERROR',['error in uvmat/run0_Callback/check_field_structure: ' errormsg])
|
---|
| 2203 | return
|
---|
| 2204 | end
|
---|
| 2205 | [CellVarIndex,NbDim,VarType]=find_field_indices(UvData.Field);
|
---|
| 2206 | [NbDim,imax]=max(NbDim);
|
---|
| 2207 | if isempty(imax)
|
---|
| 2208 | DimVarIndex=0;
|
---|
| 2209 | coord_x=[];
|
---|
| 2210 | else
|
---|
| 2211 | VarIndex=CellVarIndex{imax};
|
---|
| 2212 | coord_x=VarType{imax}.coord_x;
|
---|
| 2213 | end
|
---|
| 2214 | if isfield(UvData,'NbDim') & ~isempty(UvData.NbDim)
|
---|
| 2215 | NbDim=UvData.NbDim;
|
---|
| 2216 | else
|
---|
| 2217 | UvData.NbDim=NbDim;
|
---|
| 2218 | end
|
---|
| 2219 | if ~isempty(CellVarIndex) & ~isempty(VarType{imax}.coord_x) & ~isempty(VarType{imax}.coord_y) %unstructured coordinate z
|
---|
| 2220 | XName=UvData.Field.ListVarName{VarType{imax}.coord_x};
|
---|
| 2221 | YName=UvData.Field.ListVarName{VarType{imax}.coord_y};
|
---|
| 2222 | test_x=1;
|
---|
| 2223 | elseif isfield(UvData.Field,'X')&isfield(UvData.Field,'Y')
|
---|
| 2224 | XName='X';
|
---|
| 2225 | YName='Y';
|
---|
| 2226 | test_x=1;
|
---|
| 2227 | end
|
---|
| 2228 | if test_x
|
---|
| 2229 | eval(['UvData.XMax=max(UvData.Field.' XName ');'])
|
---|
| 2230 | eval(['UvData.XMin=min(UvData.Field.' XName ');'])
|
---|
| 2231 | eval(['UvData.YMax=max(UvData.Field.' YName ');'])
|
---|
| 2232 | eval(['UvData.YMin=min(UvData.Field.' YName ');'])
|
---|
| 2233 | eval(['nbvec=length(UvData.Field.' XName ');'])
|
---|
| 2234 | if NbDim==3%
|
---|
| 2235 | if ~isempty(CellVarIndex) & ~isempty(VarType{imax}.coord_z)%unstructured coordinate z
|
---|
| 2236 | ZName=UvData.ListVarName{VarType{imax}.coord_z};
|
---|
| 2237 | eval(['UvData.ZMax=max(UvData.Field.' ZName ');'])
|
---|
| 2238 | eval(['UvData.ZMin=min(UvData.Field.' ZName ');'])
|
---|
| 2239 | test_z=1;
|
---|
| 2240 | elseif isfield(UvData,'Z')% usual civ data
|
---|
| 2241 | UvData.ZMax=max(UvData.Z);
|
---|
| 2242 | UvData.ZMin=min(UvData.Z);
|
---|
| 2243 | test_z=1;
|
---|
| 2244 | end
|
---|
| 2245 | end
|
---|
| 2246 | if isequal(UvData.ZMin,UvData.ZMax)%no z dependency
|
---|
| 2247 | NbDim=2;
|
---|
| 2248 | test_z=0;
|
---|
| 2249 | end
|
---|
| 2250 | if test_z
|
---|
| 2251 | UvData.Mesh=((UvData.XMax-UvData.XMin)*(UvData.YMax-UvData.YMin)*(UvData.ZMax-UvData.ZMin))/nbvec;% volume per vector
|
---|
| 2252 | UvData.Mesh=(UvData.Mesh)^(1/3);
|
---|
| 2253 | else
|
---|
| 2254 | UvData.Mesh=sqrt((UvData.XMax-UvData.XMin)*(UvData.YMax-UvData.YMin)/nbvec);%2D
|
---|
| 2255 | end
|
---|
| 2256 | end
|
---|
| 2257 | %case of structured coordinates
|
---|
| 2258 | if isfield(UvData.Field,'AX') & isfield(UvData.Field,'AY')& isfield(UvData.Field,'A')
|
---|
| 2259 | UvData.XMax=max(UvData.Field.AX);
|
---|
| 2260 | UvData.XMin=min(UvData.Field.AX);
|
---|
| 2261 | UvData.YMax=max(UvData.Field.AY);
|
---|
| 2262 | UvData.YMin=min(UvData.Field.AY);
|
---|
| 2263 | np_A=size(UvData.Field.A);
|
---|
| 2264 | UvData.Mesh=sqrt((UvData.XMax-UvData.XMin)*(UvData.YMax-UvData.YMin)/((np_A(1)-1) * (np_A(2)-1))) ;
|
---|
| 2265 | end
|
---|
| 2266 | if isempty(coord_x)&~isempty(CellVarIndex)
|
---|
| 2267 | VarIndex=CellVarIndex{imax}; % list of variable indices
|
---|
| 2268 | DimIndex=UvData.Field.VarDimIndex{VarIndex(1)}; %list of dim indices for the variable
|
---|
| 2269 | if NbDim==3
|
---|
| 2270 | nbpoints=UvData.Field.DimValue(DimIndex(1));
|
---|
| 2271 | %Zvar=DimVarIndex(DimIndex(1));
|
---|
| 2272 | %Zvar=DimVarIndex(1);
|
---|
| 2273 | Zvar=VarType{imax}.coord_3;
|
---|
| 2274 | if Zvar~=0 % z is a dimension variable
|
---|
| 2275 | ZName=UvData.Field.ListVarName{Zvar};
|
---|
| 2276 | eval(['UvData.ZMax=max(UvData.Field.' ZName ');'])
|
---|
| 2277 | eval(['UvData.ZMin=min(UvData.Field.' ZName ');'])
|
---|
| 2278 | else
|
---|
| 2279 | testcoord_z=0;
|
---|
| 2280 | if length(UvData.Field.VarAttribute)>=VarIndex(1)
|
---|
| 2281 | if isfield(UvData.Field.VarAttribute{VarIndex(1)},'Coord_1')%regular grid
|
---|
| 2282 | Coord_z=UvData.Field.VarAttribute{VarIndex(1)}.Coord_1;
|
---|
| 2283 | UvData.ZMax=max(Coord_z);
|
---|
| 2284 | UvData.ZMin=min(Coord_z);
|
---|
| 2285 | testcoord_z=1;
|
---|
| 2286 | end
|
---|
| 2287 | end
|
---|
| 2288 | if ~testcoord_z
|
---|
| 2289 | UvData.ZMin=1;
|
---|
| 2290 | UvData.ZMax=UvData.Field.DimValue(DimIndex(1));
|
---|
| 2291 | end
|
---|
| 2292 | end
|
---|
| 2293 | UvData.Mesh=(UvData.ZMax-UvData.ZMin)/(nbpoints-1);
|
---|
| 2294 | elseif NbDim==2
|
---|
| 2295 | nbpoints_y=UvData.Field.DimValue(DimIndex(1));
|
---|
| 2296 | Yvar=VarType{imax}.coord_y;
|
---|
| 2297 | if Yvar~=0 % x is a dimension variable
|
---|
| 2298 | YName=UvData.Field.ListVarName{Yvar};
|
---|
| 2299 | eval(['UvData.YMax=max(UvData.Field.' YName ');'])
|
---|
| 2300 | eval(['UvData.YMin=min(UvData.Field.' YName ');'])
|
---|
| 2301 | else
|
---|
| 2302 | testcoord_y=0;
|
---|
| 2303 | if ~testcoord_y
|
---|
| 2304 | UvData.YMin=1;
|
---|
| 2305 | UvData.YMax=UvData.Field.DimValue(DimIndex(1));
|
---|
| 2306 | end
|
---|
| 2307 | end
|
---|
| 2308 | DY=(UvData.YMax-UvData.YMin)/(nbpoints_y-1);
|
---|
| 2309 | nbpoints_x=UvData.Field.DimValue(DimIndex(2));
|
---|
| 2310 | Xvar=VarType{imax}.coord_x;
|
---|
| 2311 | if Xvar~=0 % x is a dimension variable
|
---|
| 2312 | XName=UvData.Field.ListVarName{Xvar};
|
---|
| 2313 | eval(['UvData.XMax=max(UvData.Field.' XName ');'])
|
---|
| 2314 | eval(['UvData.XMin=min(UvData.Field.' XName ');'])
|
---|
| 2315 | else
|
---|
| 2316 | testcoord_x=0;
|
---|
| 2317 | if ~testcoord_x
|
---|
| 2318 | UvData.XMin=1;
|
---|
| 2319 | UvData.XMax=UvData.Field.DimValue(DimIndex(2));
|
---|
| 2320 | end
|
---|
| 2321 | end
|
---|
| 2322 | DX=(UvData.XMax-UvData.XMin)/(nbpoints_x-1);
|
---|
| 2323 | UvData.Mesh= sqrt(DX*DY);
|
---|
| 2324 | end
|
---|
| 2325 | end
|
---|
| 2326 |
|
---|
| 2327 | %create a default projection menuplane
|
---|
| 2328 | UvData.Object{1}.Style='plane';%main plotting plane
|
---|
| 2329 | UvData.Object{1}.ProjMode='projection';%main plotting plane
|
---|
| 2330 | if ~isfield(UvData.Object{1},'plotaxes')
|
---|
| 2331 | UvData.Object{1}.plotaxes=handles.axes3;%default plotting axis
|
---|
| 2332 | set(handles.list_object,'String',{'1-PLANE';'...'});
|
---|
| 2333 | set(handles.list_object,'Value',1);
|
---|
| 2334 | end
|
---|
| 2335 |
|
---|
| 2336 | %3D case (menuvolume)
|
---|
| 2337 | if NbDim==3
|
---|
| 2338 | UvData.Object{1}.NbDim=UvData.NbDim;%test for 3D objects
|
---|
| 2339 | UvData.Object{1}.RangeZ=UvData.Mesh;%main plotting plane
|
---|
| 2340 | UvData.Object{1}.Coord(1,3)=(UvData.ZMin+UvData.ZMax)/2;%section at a middle plane chosen
|
---|
| 2341 | UvData.Object{1}.Phi=0;
|
---|
| 2342 | UvData.Object{1}.Theta=0;
|
---|
| 2343 | UvData.Object{1}.Psi=0;
|
---|
| 2344 | UvData.Object{1}.HandlesDisplay=plot(0,0,'Tag','proj_object');% A REVOIR
|
---|
| 2345 | PlotHandles=get_plot_handles(handles);
|
---|
| 2346 | ZBounds(1)=UvData.ZMin; %minimum for the Z slider
|
---|
| 2347 | ZBounds(2)=UvData.ZMax;%maximum for the Z slider
|
---|
| 2348 | set_object(UvData.Object{1},PlotHandles,ZBounds);
|
---|
| 2349 | set(handles.list_object,'Value',1);
|
---|
| 2350 | %multilevel case (single menuplane in a 3D space)
|
---|
| 2351 | elseif isfield(UvData,'Z')
|
---|
| 2352 | if isfield(UvData,'CoordType')& isequal(UvData.CoordType,'phys') & isfield(UvData,'XmlData')
|
---|
| 2353 | XmlData=UvData.XmlData;
|
---|
| 2354 | if isfield(XmlData,'PlanePos')
|
---|
| 2355 | UvData.Object{1}.Coord=XmlData.PlanePos(UvData.ZIndex,:);
|
---|
| 2356 | end
|
---|
| 2357 | if isfield(XmlData,'PlaneAngle')
|
---|
| 2358 | siz=size(XmlData.PlaneAngle);
|
---|
| 2359 | indangle=min(siz(1),UvData.ZIndex);%take first angle if a single angle is defined (translating scanning)
|
---|
| 2360 | UvData.Object{1}.Phi=XmlData.PlaneAngle(indangle,1);
|
---|
| 2361 | UvData.Object{1}.Theta=XmlData.PlaneAngle(indangle,2);
|
---|
| 2362 | UvData.Object{1}.Psi=XmlData.PlaneAngle(indangle,3);
|
---|
| 2363 | end
|
---|
| 2364 | elseif isfield(UvData,'ZIndex')
|
---|
| 2365 | UvData.Object{1}.ZObject=UvData.ZIndex;
|
---|
| 2366 | end
|
---|
| 2367 | end
|
---|
| 2368 |
|
---|
| 2369 | %Plot the projections on all existing projection objects
|
---|
| 2370 | keeplim=get(handles.FixedLimits,'Value');
|
---|
| 2371 | %reset the min and max of scalar if only the mask is displayed
|
---|
| 2372 | if isfield(UvData,'Mask')&~isfield(UvData,'A')
|
---|
| 2373 | set(handles.MinA,'String','0')
|
---|
| 2374 | set(handles.MaxA,'String','255')
|
---|
| 2375 | end
|
---|
| 2376 |
|
---|
| 2377 | Object=UvData.Object;
|
---|
| 2378 | for iobj=1:length(Object)
|
---|
| 2379 | if ~isempty(Object{iobj})%& isfield(Object{iobj},'plotaxes')& ishandle(Object{iobj}.plotaxes)
|
---|
| 2380 | %Projeter les champs sur l'objet:*
|
---|
| 2381 | ObjectData=proj_field(UvData.Field,Object{iobj},iobj);
|
---|
| 2382 |
|
---|
| 2383 | %use of mask
|
---|
| 2384 | if isfield(ObjectData,'NbDim')&isequal(ObjectData.NbDim,2)
|
---|
| 2385 | if isfield(ObjectData,'Mask') & isfield(ObjectData,'A')
|
---|
| 2386 | flag_mask=double(ObjectData.Mask>200);%=0 for masked regions
|
---|
| 2387 | AX=ObjectData.AX;
|
---|
| 2388 | AY=ObjectData.AY;
|
---|
| 2389 | MaskX=ObjectData.MaskX;
|
---|
| 2390 | MaskY=ObjectData.MaskY;
|
---|
| 2391 | if ~isequal(MaskX,AX)|~isequal(MaskY,AY)
|
---|
| 2392 | nxy=size(flag_mask);
|
---|
| 2393 | sizpx=(ObjectData.MaskX(end)-ObjectData.MaskX(1))/(nxy(2)-1);%size of a mask pixel
|
---|
| 2394 | sizpy=(ObjectData.MaskY(1)-ObjectData.MaskY(end))/(nxy(1)-1);
|
---|
| 2395 | x_mask=[ObjectData.MaskX(1):sizpx:ObjectData.MaskX(end)]; % pixel x coordinates for image display
|
---|
| 2396 | y_mask=[ObjectData.MaskY(1):-sizpy:ObjectData.MaskY(end)];% pixel x coordinates for image display
|
---|
| 2397 | %project on the positions of the scalar
|
---|
| 2398 | npxy=size(ObjectData.A);
|
---|
| 2399 | dxy(1)=(ObjectData.AY(end)-ObjectData.AY(1))/(npxy(1)-1);%grid mesh in y
|
---|
| 2400 | dxy(2)=(ObjectData.AX(end)-ObjectData.AX(1))/(npxy(2)-1);%grid mesh in x
|
---|
| 2401 | xi=[ObjectData.AX(1):dxy(2):ObjectData.AX(end)];
|
---|
| 2402 | yi=[ObjectData.AY(1):dxy(1):ObjectData.AY(end)];
|
---|
| 2403 | [XI,YI]=meshgrid(xi,yi);% creates the matrix of regular coordinates
|
---|
| 2404 | flag_mask = interp2(x_mask,y_mask,flag_mask,XI,YI);
|
---|
| 2405 | end
|
---|
| 2406 | AClass=class(ObjectData.A);
|
---|
| 2407 | ObjectData.A=flag_mask.*double(ObjectData.A);
|
---|
| 2408 | ObjectData.A=feval(AClass,ObjectData.A);
|
---|
| 2409 | ind_off=[];
|
---|
| 2410 | if isfield(ObjectData,'ListVarName')
|
---|
| 2411 | for ilist=1:length(ObjectData.ListVarName)
|
---|
| 2412 | if isequal(ObjectData.ListVarName{ilist},'Mask')|isequal(ObjectData.ListVarName{ilist},'MaskX')|isequal(ObjectData.ListVarName{ilist},'MaskY')
|
---|
| 2413 | ind_off=[ind_off ilist];
|
---|
| 2414 | end
|
---|
| 2415 | end
|
---|
| 2416 | ObjectData.ListVarName(ind_off)=[];
|
---|
| 2417 | ObjectData.VarDimIndex(ind_off)=[];
|
---|
| 2418 | ind_off=[];
|
---|
| 2419 | for ilist=1:length(ObjectData.ListDimName)
|
---|
| 2420 | if isequal(ObjectData.ListDimName{ilist},'MaskX')|isequal(ObjectData.ListDimName{ilist},'MaskY')
|
---|
| 2421 | ind_off=[ind_off ilist];
|
---|
| 2422 | end
|
---|
| 2423 | end
|
---|
| 2424 | ObjectData.ListDimName(ind_off)=[];
|
---|
| 2425 | ObjectData.DimValue(ind_off)=[];
|
---|
| 2426 | end
|
---|
| 2427 | end
|
---|
| 2428 | end
|
---|
| 2429 | if ~isempty(ObjectData)
|
---|
| 2430 | haxes=[];%default
|
---|
| 2431 | if isfield(Object{iobj},'plotaxes')
|
---|
| 2432 | haxes=Object{iobj}.plotaxes;%axes used for representing the projection on the object
|
---|
| 2433 | end
|
---|
| 2434 | PosColorbar=[];%default: no colorbar
|
---|
| 2435 | if ishandle(haxes) & isequal(get(haxes,'Tag'),'axes3')& isfield(UvData,'PosColorbar')
|
---|
| 2436 | PosColorbar=UvData.PosColorbar;%prescribe the colorbar position on the uvmat interface
|
---|
| 2437 | else
|
---|
| 2438 | PosColorbar='*';%default position
|
---|
| 2439 | end
|
---|
| 2440 | PlotParam=read_plot_param(handles);%read plotting parameters on the uvmat interface
|
---|
| 2441 | [PlotType,ScalOut,UvData.Object{iobj}.plotaxes]=plot_field(ObjectData,haxes,PlotParam,keeplim,PosColorbar);
|
---|
| 2442 | if isequal(PlotType,'none')
|
---|
| 2443 | hget_field=findobj(allchild(0),'name','get_field');
|
---|
| 2444 | if isempty(hget_field)
|
---|
| 2445 | get_field([],ObjectData)% the projected field cannot be automatically plotted: use get_field to specify the variablesdelete(hget_field)
|
---|
| 2446 | else
|
---|
| 2447 | msgbox_uvmat('ERROR','The field defined by get_field cannot be plotted')
|
---|
| 2448 | end
|
---|
| 2449 | end
|
---|
| 2450 | UvData.Object{iobj}.PlotParam=ScalOut; %record the plotting parameters
|
---|
| 2451 | end
|
---|
| 2452 |
|
---|
| 2453 | end
|
---|
| 2454 | end
|
---|
| 2455 |
|
---|
| 2456 | %display the updated plotting parameters for the base menuplane
|
---|
| 2457 | write_plot_param(handles,UvData.Object{1}.PlotParam);% update the display of the plotting parameters
|
---|
| 2458 | set(huvmat,'UserData',UvData)
|
---|
| 2459 |
|
---|
| 2460 | %update the mask
|
---|
| 2461 | if isequal(get(handles.mask_test,'Value'),1)%if the mask option is on
|
---|
| 2462 | update_mask(handles,num_i1,num_i2);
|
---|
| 2463 | end
|
---|
| 2464 |
|
---|
| 2465 | %prepare the menus of histograms (for the whole menuvolume in 3D case)
|
---|
| 2466 | menu_histo=(UvData.Field.ListVarName)';
|
---|
| 2467 | ind_bad=[];
|
---|
| 2468 | nb_histo=1;
|
---|
| 2469 | for ivar=1:numel(menu_histo)
|
---|
| 2470 | if isfield(UvData.Field,'VarAttribute') && numel(UvData.Field.VarAttribute)>=ivar && isfield(UvData.Field.VarAttribute{ivar},'Role')
|
---|
| 2471 | Role=UvData.Field.VarAttribute{ivar}.Role;
|
---|
| 2472 | switch Role
|
---|
| 2473 | case {'coord_x','coord_y','coord_z','dimvar'}
|
---|
| 2474 | ind_bad=[ind_bad ivar];
|
---|
| 2475 | case {'vector_y'}
|
---|
| 2476 | nb_histo=nb_histo+1;
|
---|
| 2477 | end
|
---|
| 2478 | end
|
---|
| 2479 | DimCell=UvData.Field.VarDimName{ivar};
|
---|
| 2480 | DimName='';
|
---|
| 2481 | if ischar(DimCell)
|
---|
| 2482 | DimName=DimCell;
|
---|
| 2483 | elseif iscell(DimCell)&& numel(DimCell)==1
|
---|
| 2484 | DimName=DimCell{1};
|
---|
| 2485 | end
|
---|
| 2486 | if strcmp(DimName,menu_histo{ivar})
|
---|
| 2487 | ind_bad=[ind_bad ivar];
|
---|
| 2488 | end
|
---|
| 2489 | end
|
---|
| 2490 | menu_histo(ind_bad)=[];
|
---|
| 2491 | test_v=0;
|
---|
| 2492 | if ~isempty(menu_histo)
|
---|
| 2493 | set(handles.histo1_menu,'Value',1)
|
---|
| 2494 | set(handles.histo1_menu,'String',menu_histo)
|
---|
| 2495 | histo1_menu_Callback(hObject, eventdata, handles)
|
---|
| 2496 | if nb_histo > 1
|
---|
| 2497 | test_v=1;
|
---|
| 2498 | set(handles.histo2_menu,'Visible','on')
|
---|
| 2499 | set(handles.histo_v,'Visible','on')
|
---|
| 2500 | set(handles.histo2_menu,'String',menu_histo)
|
---|
| 2501 | set(handles.histo2_menu,'Value',2)
|
---|
| 2502 | histo2_menu_Callback(hObject, eventdata, handles)
|
---|
| 2503 | end
|
---|
| 2504 | end
|
---|
| 2505 | if ~test_v
|
---|
| 2506 | set(handles.histo2_menu,'Visible','off')
|
---|
| 2507 | set(handles.histo_v,'Visible','off')
|
---|
| 2508 | cla(handles.histo_v)
|
---|
| 2509 | set(handles.histo2_menu,'Value',1)
|
---|
| 2510 | end
|
---|
| 2511 |
|
---|
| 2512 | %display time
|
---|
| 2513 | testimedoc=0;
|
---|
| 2514 | if isfield(UvData,'XmlData') && isfield(UvData.XmlData,'Time')
|
---|
| 2515 | if isempty(num_i2)
|
---|
| 2516 | num_i2=num_i1;
|
---|
| 2517 | end
|
---|
| 2518 | if isempty(num_j1)
|
---|
| 2519 | num_j1=1;
|
---|
| 2520 | end
|
---|
| 2521 | if isempty(num_j2)
|
---|
| 2522 | num_j2=num_j1;
|
---|
| 2523 | end
|
---|
| 2524 | siz=size(UvData.XmlData.Time);
|
---|
| 2525 | if siz(1)>=max(num_i1,num_i2) & siz(2)>=max(num_j1,num_j2)
|
---|
| 2526 | abstime=(UvData.XmlData.Time(num_i1,num_j1)+UvData.XmlData.Time(num_i2,num_j2))/2;%overset the time read from files
|
---|
| 2527 | dt=(UvData.XmlData.Time(num_i2,num_j2)-UvData.XmlData.Time(num_i1,num_j1));
|
---|
| 2528 | testimedoc=1;
|
---|
| 2529 | end
|
---|
| 2530 | end
|
---|
| 2531 | if isfield(UvData,'XmlData_1') && isfield(UvData.XmlData_1,'Time')
|
---|
| 2532 | [P,F,str1,str2,str_a,str_b,E,NomType]=name2display(['xx' get(handles.FileIndex_1,'String') get(handles.FileExt_1,'String')]);
|
---|
| 2533 | num_i2=str2num(str2);
|
---|
| 2534 | if isempty(num_i2)
|
---|
| 2535 | num_i2=num_i1;
|
---|
| 2536 | end
|
---|
| 2537 | num_j1=str2num(str_a);
|
---|
| 2538 | if isempty(num_j1)
|
---|
| 2539 | num_j1=1;
|
---|
| 2540 | end
|
---|
| 2541 | num_j2=str2num(str_b);
|
---|
| 2542 | if isempty(num_j2)
|
---|
| 2543 | num_j2=num_j1;
|
---|
| 2544 | end
|
---|
| 2545 | num_i1=str2num(str1);
|
---|
| 2546 | siz=size(UvData.XmlData_1.Time);
|
---|
| 2547 | if siz(1)>=max(num_i1,num_i2) & siz(2)>=max(num_j1,num_j2)
|
---|
| 2548 | 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
|
---|
| 2549 | end
|
---|
| 2550 | end
|
---|
| 2551 | set(handles.abs_time,'String',num2str(abstime,4))
|
---|
| 2552 | set(handles.abs_time_1,'String',num2str(abstime_1,4))
|
---|
| 2553 | if testimedoc && isfield(UvData,'dt')
|
---|
| 2554 | dt=UvData.dt;
|
---|
| 2555 | end
|
---|
| 2556 | if isequal(dt,0)
|
---|
| 2557 | set(handles.Dt_txt,'String','')
|
---|
| 2558 | else
|
---|
| 2559 | if ~(isfield(UvData,'TimeUnit') && ~isempty(UvData.TimeUnit))
|
---|
| 2560 | set(handles.Dt_txt,'String',['Dt=' num2str(1000*dt,3) ' 10^(-3)'] )
|
---|
| 2561 | else
|
---|
| 2562 | set(handles.Dt_txt,'String',['Dt=' num2str(1000*dt,3) ' m' UvData.TimeUnit] )
|
---|
| 2563 | end
|
---|
| 2564 | end
|
---|
| 2565 | set(handles.run0,'BackgroundColor',[1 0 0])
|
---|
| 2566 |
|
---|
| 2567 |
|
---|
| 2568 |
|
---|
| 2569 | %-------------------------------------------------------------------
|
---|
| 2570 | % --- translate coordinate to matrix index
|
---|
| 2571 | %-------------------------------------------------------------------
|
---|
| 2572 | function [indx,indy]=pos2ind(x0,rangx0,nxy)
|
---|
| 2573 | indx=1+round((nxy(2)-1)*(x0-rangx0(1))/(rangx0(2)-rangx0(1)));% index x of pixel
|
---|
| 2574 | indy=1+round((nxy(1)-1)*(y12-rangy0(1))/(rangy0(2)-rangy0(1)));% index y of pixel
|
---|
| 2575 |
|
---|
| 2576 | %-------------------------------------------------------------------
|
---|
| 2577 | % --- Executes on button press in 'FixedLimits'.
|
---|
| 2578 | %-------------------------------------------------------------------
|
---|
| 2579 | function FixedLimits_Callback(hObject, eventdata, handles)
|
---|
| 2580 | test=get(handles.FixedLimits,'Value');
|
---|
| 2581 | if test
|
---|
| 2582 | set(handles.FixedLimits,'BackgroundColor',[1 1 0])
|
---|
| 2583 | else
|
---|
| 2584 | set(handles.FixedLimits,'BackgroundColor',[0.7 0.7 0.7])
|
---|
| 2585 | end
|
---|
| 2586 |
|
---|
| 2587 | %-------------------------------------------------------------------
|
---|
| 2588 | % --- Executes on button press in auto_xy.
|
---|
| 2589 | function auto_xy_Callback(hObject, eventdata, handles)
|
---|
| 2590 | test=get(handles.auto_xy,'Value');
|
---|
| 2591 | if test
|
---|
| 2592 | set(handles.auto_xy,'BackgroundColor',[1 1 0])
|
---|
| 2593 | cla(handles.axes3)
|
---|
| 2594 | update_plot(handles)
|
---|
| 2595 | else
|
---|
| 2596 | set(handles.auto_xy,'BackgroundColor',[0.7 0.7 0.7])
|
---|
| 2597 | update_plot(handles)
|
---|
| 2598 | % axis(handles.axes3,'image')
|
---|
| 2599 | end
|
---|
| 2600 |
|
---|
| 2601 |
|
---|
| 2602 | %-------------------------------------------------------------------
|
---|
| 2603 |
|
---|
| 2604 | %-------------------------------------------------------------------
|
---|
| 2605 | % --- Executes on button press in 'zoom'.
|
---|
| 2606 | %-------------------------------------------------------------------
|
---|
| 2607 | function zoom_Callback(hObject, eventdata, handles)
|
---|
| 2608 | huvmat=get(handles.zoom,'parent');%general input
|
---|
| 2609 | UvData=get(huvmat,'UserData');
|
---|
| 2610 | if (get(handles.zoom,'Value') == 1);
|
---|
| 2611 | set(handles.zoom,'BackgroundColor',[1 1 0])
|
---|
| 2612 | set(handles.FixedLimits,'Value',1)% propose by default fixed limits for the plotting axes
|
---|
| 2613 | set(handles.FixedLimits,'BackgroundColor',[1 1 0])
|
---|
| 2614 | %UvData.ZoomOn=1; %test for mouse action
|
---|
| 2615 | else
|
---|
| 2616 | set(handles.zoom,'BackgroundColor',[0.7 0.7 0.7])
|
---|
| 2617 | %UvData.ZoomOn=0; %test for mouse action
|
---|
| 2618 | end
|
---|
| 2619 | set(huvmat,'UserData',UvData);
|
---|
| 2620 |
|
---|
| 2621 | %-------------------------------------------------------------------
|
---|
| 2622 | %----Executes on button press in 'record': records the current flags of manual correction.
|
---|
| 2623 | %-------------------------------------------------------------------
|
---|
| 2624 | function record_Callback(hObject, eventdata, handles)
|
---|
| 2625 | % [filebase,num_i1,num_j1,num_i2,num_j2,Ext,NomType,SubDir]=read_input_file(handles);
|
---|
| 2626 | filename=read_file_boxes(handles);
|
---|
| 2627 | AxeData=get(gca,'UserData');
|
---|
| 2628 | [erread,message]=fileattrib(filename);
|
---|
| 2629 | if ~isempty(message) & ~isequal(message.UserWrite,1)
|
---|
| 2630 | msgbox_uvmat('ERROR',['no writting access to ' filename])
|
---|
| 2631 | return
|
---|
| 2632 | end
|
---|
| 2633 | nc=netcdf(filename,'write'); %open netcdf file
|
---|
| 2634 | result=redef(nc);
|
---|
[38] | 2635 | if isempty(result), msgbox_uvmat('ERROR','##Bad redef operation.'),end
|
---|
[2] | 2636 | test_civ2=isequal(get(handles.civ2,'BackgroundColor'),[1 1 0]);
|
---|
| 2637 | if ~test_civ2
|
---|
| 2638 | test_civ1=isequal(get(handles.civ1,'BackgroundColor'),[1 1 0]);
|
---|
| 2639 | end
|
---|
| 2640 | if test_civ2 % for civ2
|
---|
| 2641 |
|
---|
| 2642 | theDim=nc('nb_vectors2') ;% get the number of velocity vectors
|
---|
| 2643 | nb_vectors2=size(theDim);
|
---|
| 2644 | var_FixFlag=ncvar('vec2_FixFlag',nc);% var_FixFlag will be written as the netcdf variable vec_FixFlag
|
---|
| 2645 | var_FixFlag(1:nb_vectors2)=AxeData.FF;%
|
---|
| 2646 | elseif test_civ1 % for civ1
|
---|
| 2647 |
|
---|
| 2648 | theDim=nc('nb_vectors') ;% get the number of velocity vectors
|
---|
| 2649 | nb_vectors=size(theDim);
|
---|
| 2650 | var_FixFlag=ncvar('vec_FixFlag',nc);% var_FixFlag will be written as the netcdf variable vec_FixFlag
|
---|
| 2651 | var_FixFlag(1:nb_vectors)=AxeData.FF;%
|
---|
| 2652 | else
|
---|
| 2653 | msgbox_uvmat('ERROR','manual correction only possible for CIV1 or CIV2 velocity fields')
|
---|
| 2654 | end
|
---|
| 2655 | fin=close(nc);
|
---|
| 2656 |
|
---|
| 2657 |
|
---|
| 2658 |
|
---|
| 2659 | %-------------------------------------------------------------------
|
---|
| 2660 | %determines the fields to read from the interface
|
---|
| 2661 | %------------------------------------------------------------------
|
---|
| 2662 | function [VelType,civ]=setfield(handles)
|
---|
| 2663 |
|
---|
| 2664 | VelType=[]; %default
|
---|
| 2665 | if (get(handles.civ1,'Value') == 1);
|
---|
| 2666 | VelType='civ1';
|
---|
| 2667 | % interp1
|
---|
| 2668 | elseif (get(handles.interp1,'Value') == 1);
|
---|
| 2669 | VelType='interp1';
|
---|
| 2670 | % filter1
|
---|
| 2671 | elseif (get(handles.filter1,'Value') == 1);
|
---|
| 2672 | VelType='filter1';
|
---|
| 2673 | % CIV2
|
---|
| 2674 | elseif (get(handles.civ2,'Value') == 1);
|
---|
| 2675 | VelType='civ2';
|
---|
| 2676 | % interp2
|
---|
| 2677 | elseif (get(handles.interp2,'Value') == 1);
|
---|
| 2678 | VelType='interp2';
|
---|
| 2679 | % filter2
|
---|
| 2680 | elseif (get(handles.filter2,'Value') == 1);
|
---|
| 2681 | VelType='filter2';
|
---|
| 2682 | end
|
---|
| 2683 |
|
---|
| 2684 | if isequal(get(handles.filter2,'Visible'),'on');
|
---|
| 2685 | civ=6;
|
---|
| 2686 | % interp1
|
---|
| 2687 | elseif isequal(get(handles.interp2,'Visible'),'on');
|
---|
| 2688 | civ=5;
|
---|
| 2689 | % filter1
|
---|
| 2690 | elseif isequal(get(handles.civ2,'Visible'),'on');
|
---|
| 2691 | civ=4;
|
---|
| 2692 | % CIV2
|
---|
| 2693 | elseif isequal(get(handles.filter1,'Visible'),'on');
|
---|
| 2694 | civ=3;
|
---|
| 2695 | % interp2
|
---|
| 2696 | elseif isequal(get(handles.interp1,'Visible'),'on');
|
---|
| 2697 | civ=2;
|
---|
| 2698 | % filter2
|
---|
| 2699 | elseif isequal(get(handles.civ1,'Visible'),'on');
|
---|
| 2700 | civ=1;
|
---|
| 2701 | else
|
---|
| 2702 | civ=0;
|
---|
| 2703 | end
|
---|
| 2704 |
|
---|
| 2705 | %-------------------------------------------------------------------
|
---|
| 2706 | %determines the veltype of the second field to read from the iinterface
|
---|
| 2707 | %------------------------------------------------------------------
|
---|
| 2708 | function VelType=setfield_1(handles)
|
---|
| 2709 |
|
---|
| 2710 | VelType=[]; %default
|
---|
| 2711 | if (get(handles.civ1_1,'Value') == 1);
|
---|
| 2712 | VelType='civ1';
|
---|
| 2713 | % interp1
|
---|
| 2714 | elseif (get(handles.interp1_1,'Value') == 1);
|
---|
| 2715 | VelType='interp1';
|
---|
| 2716 | % filter1
|
---|
| 2717 | elseif (get(handles.filter1_1,'Value') == 1);
|
---|
| 2718 | VelType='filter1';
|
---|
| 2719 | % CIV2
|
---|
| 2720 | elseif (get(handles.civ2_1,'Value') == 1);
|
---|
| 2721 | VelType='civ2';
|
---|
| 2722 | % interp2
|
---|
| 2723 | elseif (get(handles.interp2_1,'Value') == 1);
|
---|
| 2724 | VelType='interp2';
|
---|
| 2725 | % filter2
|
---|
| 2726 | elseif (get(handles.filter2_1,'Value') == 1);
|
---|
| 2727 | VelType='filter2';
|
---|
| 2728 | end
|
---|
| 2729 |
|
---|
| 2730 |
|
---|
| 2731 | %---------------------------------------------------
|
---|
| 2732 | % --- Executes on button press in SubField
|
---|
| 2733 | function SubField_Callback(hObject, eventdata, handles)
|
---|
| 2734 | huvmat=get(handles.run0,'parent');
|
---|
| 2735 | UvData=get(huvmat,'UserData');
|
---|
| 2736 | if get(handles.SubField,'Value')==0% if the subfield button is desactivated
|
---|
| 2737 | set(handles.RootPath_1,'String','')
|
---|
| 2738 | set(handles.RootFile_1,'String','')
|
---|
| 2739 | set(handles.SubDir_1,'String','');
|
---|
| 2740 | set(handles.FileIndex_1,'String','');
|
---|
| 2741 | set(handles.FileExt_1,'String','');
|
---|
| 2742 | set(handles.RootPath_1,'Visible','off')
|
---|
| 2743 | set(handles.RootFile_1,'Visible','off')
|
---|
| 2744 | set(handles.SubDir_1,'Visible','off');
|
---|
| 2745 | set(handles.FileIndex_1,'Visible','off');
|
---|
| 2746 | set(handles.FileExt_1,'Visible','off');
|
---|
| 2747 | set(handles.Fields_1,'Value',1);%set to blank state
|
---|
| 2748 | set_veltype_display([handles.civ1_1 handles.interp1_1 handles.filter1_1 ...
|
---|
| 2749 | handles.civ2_1 handles.interp2_1 handles.filter2_1],0)
|
---|
| 2750 | if isfield(UvData,'XmlData_1')
|
---|
| 2751 | UvData=rmfield(UvData,'XmlData_1');
|
---|
| 2752 | end
|
---|
| 2753 | set(huvmat,'UserData',UvData);
|
---|
| 2754 | run0_Callback(hObject, eventdata, handles); %run
|
---|
| 2755 | else
|
---|
| 2756 | MenuBrowse_1_Callback(hObject, eventdata, handles)
|
---|
| 2757 | end
|
---|
| 2758 |
|
---|
| 2759 | % %----------------------------------------------
|
---|
| 2760 | % %read the data displayed for the input rootfile windows (new)
|
---|
| 2761 | % %-------------------------------------------------
|
---|
| 2762 | function [FileName,RootPath,FileBase,FileIndices,FileExt,SubDir]=read_file_boxes(handles)
|
---|
| 2763 | RootPath=get(handles.RootPath,'String');
|
---|
| 2764 | FileName=RootPath; %default
|
---|
| 2765 | SubDir=get(handles.SubDir,'String');
|
---|
| 2766 | if ~isempty(SubDir) && ~isequal(SubDir,'')
|
---|
| 2767 | if (isequal(SubDir(1),'/')|| isequal(SubDir(1),'\'))
|
---|
| 2768 | SubDir(1)=[]; %suppress possible / or \ separator
|
---|
| 2769 | end
|
---|
| 2770 | FileName=fullfile(RootPath,SubDir);
|
---|
| 2771 | end
|
---|
| 2772 | RootFile=get(handles.RootFile,'String');
|
---|
| 2773 | if ~isempty(RootFile) && ~isequal(RootFile,'')
|
---|
| 2774 | if (isequal(RootFile(1),'/')|| isequal(RootFile(1),'\'))
|
---|
| 2775 | RootFile(1)=[]; %suppress possible / or \ separator
|
---|
| 2776 | end
|
---|
| 2777 | FileName=fullfile(FileName,RootFile);
|
---|
| 2778 | end
|
---|
| 2779 | FileBase=fullfile(RootPath,RootFile);
|
---|
| 2780 | FileIndices=get(handles.FileIndex,'String');
|
---|
| 2781 | FileExt=get(handles.FileExt,'String');
|
---|
| 2782 | FileName=[FileName FileIndices FileExt];
|
---|
| 2783 |
|
---|
| 2784 | %----------------------------------------------
|
---|
| 2785 | %read the data displayed for the second input rootfile windows
|
---|
| 2786 | %-------------------------------------------------
|
---|
| 2787 | function [FileName_1,RootPath_1,FileBase_1,FileIndices_1,FileExt_1,SubDir_1]=read_file_boxes_1(handles)
|
---|
| 2788 | RootPath_1=get(handles.RootPath_1,'String'); % read the data from the file1_input window
|
---|
| 2789 | if isequal(RootPath_1,'"'),RootPath_1=get(handles.RootPath,'String'); end;
|
---|
| 2790 | FileName_1=RootPath_1; %default
|
---|
| 2791 | SubDir_1=get(handles.SubDir_1,'String');
|
---|
| 2792 | if isequal(SubDir_1,'"')
|
---|
| 2793 | SubDir_1=get(handles.SubDir,'String');
|
---|
| 2794 | end
|
---|
| 2795 | if ~isempty(SubDir_1) && ~isequal(SubDir_1,'')
|
---|
| 2796 | if (isequal(SubDir_1(1),'/')|| isequal(SubDir_1(1),'\'))
|
---|
| 2797 | SubDir_1(1)=[]; %suppress possible / or \ separator
|
---|
| 2798 | end
|
---|
| 2799 | FileName_1=fullfile(RootPath_1,SubDir_1);
|
---|
| 2800 | end
|
---|
| 2801 | RootFile_1=get(handles.RootFile_1,'String');
|
---|
| 2802 | if isequal(RootFile_1,'"'),RootFile_1=get(handles.RootFile,'String'); end;
|
---|
| 2803 | if ~isempty(RootFile_1) && ~isequal(RootFile_1,'')
|
---|
| 2804 | if ~(isequal(RootFile_1(1),'/')|isequal(RootFile_1(1),'\'))
|
---|
| 2805 | RootFile_1(1)=[];%suppress possible / or \ separator
|
---|
| 2806 | end
|
---|
| 2807 | FileName_1=fullfile(FileName_1,RootFile_1);
|
---|
| 2808 | end
|
---|
| 2809 | FileBase_1=fullfile(RootPath_1,RootFile_1);
|
---|
| 2810 | FileIndices_1=get(handles.FileIndex_1,'String');
|
---|
| 2811 | FileExt_1=get(handles.FileExt_1,'String');
|
---|
| 2812 | if isequal(FileExt_1,'"'),FileExt_1=get(handles.FileExt,'String'); end;
|
---|
| 2813 | FileName_1=[FileName_1 FileIndices_1 FileExt_1];
|
---|
| 2814 |
|
---|
| 2815 | %---------------------------------------------------
|
---|
| 2816 | % --- Executes on menu selection Fields
|
---|
| 2817 | function Fields_Callback(hObject, eventdata, handles)
|
---|
| 2818 | %-------------------------------------------------
|
---|
| 2819 | huvmat=get(handles.Fields,'parent');
|
---|
| 2820 | list_fields=get(handles.Fields,'String');% list menu fields
|
---|
| 2821 | index_fields=get(handles.Fields,'Value');% selected string index
|
---|
| 2822 | field= list_fields{index_fields(1)}; % selected string
|
---|
| 2823 | if isequal(field,'get_field...')
|
---|
| 2824 | veltype_handles=[handles.civ1 handles.interp1 handles.filter1 handles.civ2 handles.interp2 handles.filter2];
|
---|
| 2825 | set_veltype_display(veltype_handles,0) % unvisible civ buttons
|
---|
| 2826 | filename=read_file_boxes(handles);
|
---|
| 2827 | hget_field=findobj(allchild(0),'name','get_field');
|
---|
| 2828 | if ~isempty(hget_field)
|
---|
| 2829 | delete(hget_field)
|
---|
| 2830 | end
|
---|
| 2831 | get_field(filename)
|
---|
| 2832 | return %no action
|
---|
| 2833 | end
|
---|
| 2834 | list_fields=get(handles.Fields_1,'String');% list menu fields
|
---|
| 2835 | index_fields=get(handles.Fields_1,'Value');% selected string index
|
---|
| 2836 | field_1= list_fields{index_fields(1)}; % selected string
|
---|
| 2837 | UvData=get(huvmat,'UserData');
|
---|
| 2838 |
|
---|
| 2839 | %read the rootfile input display
|
---|
| 2840 | FileExt=get(handles.FileExt,'String');
|
---|
| 2841 | [P,F,str1,str2,str_a,str_b,E,NomType]=name2display(['xxx' get(handles.FileIndex,'String') FileExt]);
|
---|
| 2842 | NomTypeNew=NomType;%default
|
---|
| 2843 | if isequal(field,'image')
|
---|
| 2844 | % transform netc type to the corresponding image type
|
---|
| 2845 | if isequal(NomType,'_i1-i2_j')||isequal(NomType,'_i_j1-j2')|| isequal(NomType,'#_ab')|| isequal(NomType,'_i1-i2')
|
---|
| 2846 | UvData.SubDir=get(handles.SubDir,'String'); %preserve the subdir in memory
|
---|
| 2847 | if ~isempty(UvData.SubDir) && (isequal(UvData.SubDir(1),'/')|isequal(UvData.SubDir(1),'/'))
|
---|
| 2848 | UvData.SubDir(1)=[];
|
---|
| 2849 | end
|
---|
| 2850 | set(handles.SubDir,'String','')
|
---|
| 2851 | set(handles.FileExt,'String','.png');
|
---|
| 2852 | if isequal(NomType,'_i1-i2_j')|isequal(NomType,'_i_j1-j2')
|
---|
| 2853 | NomTypeNew='_i_j';
|
---|
| 2854 | elseif isequal(NomType,'#_ab')
|
---|
| 2855 | NomTypeNew='#a';
|
---|
| 2856 | elseif isequal(NomType,'_i1-i2')
|
---|
| 2857 | NomTypeNew='_i';
|
---|
| 2858 | end
|
---|
| 2859 | end
|
---|
| 2860 | veltype_handles=[handles.civ1 handles.interp1 handles.filter1 handles.civ2 handles.interp2 handles.filter2];
|
---|
| 2861 | set_veltype_display(veltype_handles,0) % unvisible civ buttons
|
---|
| 2862 | else
|
---|
| 2863 | ext=get(handles.FileExt,'String');
|
---|
| 2864 | if ~isequal(ext,'.nc') %find the new NomType if the previous display was not already a netcdf file
|
---|
| 2865 | MenuBrowse_Callback(hObject, eventdata, handles)
|
---|
| 2866 | end
|
---|
| 2867 | if isequal(field,'vort') || isequal(field,'div') || isequal(field,'strain')
|
---|
| 2868 | set(handles.civ1,'BackgroundColor',[0.702 0.702 0.702]) % put their color to grey
|
---|
| 2869 | set(handles.civ2,'BackgroundColor',[0.702 0.702 0.702])
|
---|
| 2870 | set(handles.interp1,'BackgroundColor',[0.702 0.702 0.702])
|
---|
| 2871 | set(handles.interp2,'BackgroundColor',[0.702 0.702 0.702])
|
---|
| 2872 | elseif isequal(field,'more...');
|
---|
| 2873 | set(handles.civ1,'BackgroundColor',[0.702 0.702 0.702]) % put their color to grey
|
---|
| 2874 | set(handles.civ2,'BackgroundColor',[0.702 0.702 0.702])
|
---|
| 2875 | str=calc_field;%get the list of available scalars by the function calc_scal
|
---|
| 2876 | [ind_answer,v] = listdlg('PromptString','Select a file:',...
|
---|
| 2877 | 'SelectionMode','single',...
|
---|
| 2878 | 'ListString',str);
|
---|
| 2879 | % edit the choice in the field and action menu
|
---|
| 2880 | scalar=cell2mat(str(ind_answer));
|
---|
| 2881 | menu=update_menu(handles.Fields,scalar);
|
---|
| 2882 | menu=[{''};menu];
|
---|
| 2883 | set(handles.Fields_1,'String',menu);% store the selected scalar type
|
---|
| 2884 | end
|
---|
| 2885 | end
|
---|
| 2886 | indices=name_generator('',str2num(str1),str2num(str_a),'',NomTypeNew,1,str2num(str2),str2num(str_b),'');
|
---|
| 2887 | set(handles.FileIndex,'String',indices)
|
---|
| 2888 | set(handles.FileIndex,'UserData',NomTypeNew)
|
---|
| 2889 | %common to Fields_1_Callback
|
---|
| 2890 | if isequal(field,'image')|isequal(field_1,'image')
|
---|
| 2891 | set(handles.npx_title,'Visible','on')% visible npx,pxcm... buttons
|
---|
| 2892 | set(handles.npy_title,'Visible','on')
|
---|
| 2893 | set(handles.npx,'Visible','on')
|
---|
| 2894 | set(handles.npy,'Visible','on')
|
---|
| 2895 | set(handles.fix_pair,'Value',0)
|
---|
| 2896 | else
|
---|
| 2897 | set(handles.npx_title,'Visible','off')% visible npx,pxcm... buttons
|
---|
| 2898 | set(handles.npy_title,'Visible','off')
|
---|
| 2899 | set(handles.npx,'Visible','off')
|
---|
| 2900 | set(handles.npy,'Visible','off')
|
---|
| 2901 | set(handles.fix_pair,'Value',1)
|
---|
| 2902 | end
|
---|
| 2903 | if isequal(field,'velocity')|isequal(field_1,'velocity');
|
---|
| 2904 | state_vect='on';
|
---|
| 2905 | else
|
---|
| 2906 | state_vect='off';
|
---|
| 2907 | end
|
---|
| 2908 | if ~isequal(field,'velocity')|(~isequal(field_1,'velocity'));
|
---|
| 2909 | state_scal='on';
|
---|
| 2910 | else
|
---|
| 2911 | state_scal='off';
|
---|
| 2912 | end
|
---|
| 2913 | setfield(handles);% update the field structure ('civ1'....)
|
---|
| 2914 |
|
---|
| 2915 | if ~isfield(UvData,'NewSeries')|isequal(UvData.NewSeries,0)
|
---|
| 2916 | run0_Callback(hObject, eventdata, handles)
|
---|
| 2917 | end
|
---|
| 2918 |
|
---|
| 2919 | %---------------------------------------------------
|
---|
| 2920 | % --- Executes on menu selection Fields
|
---|
| 2921 | function Fields_1_Callback(hObject, eventdata, handles)
|
---|
| 2922 | %-------------------------------------------------
|
---|
| 2923 | huvmat=get(handles.Fields_1,'parent');
|
---|
| 2924 | list_fields=get(handles.Fields,'String');% list menu fields
|
---|
| 2925 | index_fields=get(handles.Fields,'Value');% selected string index
|
---|
| 2926 | field= list_fields{index_fields(1)}; % selected string
|
---|
| 2927 | list_fields=get(handles.Fields_1,'String');% list menu fields
|
---|
| 2928 | index_fields=get(handles.Fields_1,'Value');% selected string index
|
---|
| 2929 | field_1= list_fields{index_fields(1)}; % selected string for the second field
|
---|
| 2930 | if isequal(field_1,'') %remove second field if 'blank' field is selected
|
---|
| 2931 | set(handles.SubField,'Value',0)
|
---|
| 2932 | SubField_Callback(hObject, eventdata, handles)
|
---|
| 2933 | return
|
---|
| 2934 | end
|
---|
| 2935 | UvData=get(huvmat,'UserData');
|
---|
| 2936 |
|
---|
| 2937 | %read the rootfile input display
|
---|
| 2938 | FileExt_prev=get(handles.FileExt_1,'String');
|
---|
| 2939 | if isempty(FileExt_prev)|isequal(FileExt_prev,'')
|
---|
| 2940 | FileExt_1=get(handles.FileExt,'String');
|
---|
| 2941 | else
|
---|
| 2942 | FileExt_1=FileExt_prev;
|
---|
| 2943 | end
|
---|
| 2944 | NomType_1=get(handles.FileIndex_1,'UserData');
|
---|
| 2945 | if isempty(NomType_1)|isequal(NomType_1,'')
|
---|
| 2946 | NomType_1=get(handles.FileIndex,'UserData');
|
---|
| 2947 | end
|
---|
| 2948 | NomTypeNew=NomType_1;%default
|
---|
| 2949 |
|
---|
| 2950 | set(handles.SubField,'Value',1)%introduce second field
|
---|
| 2951 | if isfield(UvData,'XmlData')
|
---|
| 2952 | UvData.XmlData_1=UvData.XmlData;
|
---|
| 2953 | end
|
---|
| 2954 | set(handles.FileIndex_1,'Visible','on')
|
---|
| 2955 | set(handles.FileExt_1,'Visible','on')
|
---|
| 2956 | RootPath_1=get(handles.RootPath_1,'String');
|
---|
| 2957 | RootFile_1=get(handles.RootFile_1,'String');
|
---|
| 2958 | if isempty(RootPath_1)|isequal(RootPath_1,'')
|
---|
| 2959 | set(handles.RootPath_1,'String','"')
|
---|
| 2960 | end
|
---|
| 2961 | if isempty(RootFile_1) | isequal(RootFile_1,'')
|
---|
| 2962 | set(handles.RootFile_1,'String','"')
|
---|
| 2963 | end
|
---|
| 2964 | if ~isempty(RootFile_1)&(isequal(RootFile_1(1),'/')|isequal(RootFile_1(1),'\'))
|
---|
| 2965 | RootFile_1(1)=[];
|
---|
| 2966 | end
|
---|
| 2967 |
|
---|
| 2968 | if isequal(field_1,'get_field...')
|
---|
| 2969 | veltype_handles=[handles.civ1 handles.interp1 handles.filter1 handles.civ2 handles.interp2 handles.filter2];
|
---|
| 2970 | set_veltype_display(veltype_handles,0) % unvisible civ buttons
|
---|
| 2971 | filename=read_file_boxes_1(handles);
|
---|
| 2972 | hget_field=findobj(allchild(0),'name','get_field_1');
|
---|
| 2973 | if ~isempty(hget_field)
|
---|
| 2974 | delete(hget_field)
|
---|
| 2975 | end
|
---|
| 2976 | hget_field=get_field(filename);
|
---|
| 2977 | set(hget_field,'name','get_field_1')
|
---|
| 2978 | return %no action
|
---|
| 2979 | end
|
---|
| 2980 | if isequal(field_1,'image')
|
---|
| 2981 | % transform netc type to the corresponding image type
|
---|
| 2982 | set(handles.FileExt_1,'String','.png');
|
---|
| 2983 | if isequal(NomType_1,'_i1-i2_j')|isequal(NomType_1,'_i_j1-j2')| isequal(NomType_1,'#_ab')| isequal(NomType_1,'_i1-i2')
|
---|
| 2984 | UvData.SubDir_1=get(handles.SubDir_1,'String'); %preserve the subdir in memory
|
---|
| 2985 | set(handles.SubDir_1,'String','')
|
---|
| 2986 | % set(handles.FileExt_1,'String','.png');
|
---|
| 2987 | if isequal(NomType_1,'_i1-i2_j')|isequal(NomType_1,'_i_j1-j2')
|
---|
| 2988 | NomTypeNew='_i_j';
|
---|
| 2989 | elseif isequal(NomType_1,'#_ab')
|
---|
| 2990 | NomTypeNew='#a';
|
---|
| 2991 | elseif isequal(NomType_1,'_i1-i2')
|
---|
| 2992 | NomTypeNew='_i';
|
---|
| 2993 | end
|
---|
| 2994 | end
|
---|
| 2995 | veltype_handles=[handles.civ1_1 handles.interp1_1 handles.filter1_1 handles.civ2_1 handles.interp2_1 handles.filter2_1];
|
---|
| 2996 | set_veltype_display(veltype_handles,0) % unvisible civ buttons
|
---|
| 2997 | else
|
---|
| 2998 | set(handles.SubDir_1,'Visible','on')
|
---|
| 2999 | if ~isequal(FileExt_prev,'.nc') %find the new NomType if the previous display was not already a netcdf file
|
---|
| 3000 | veltype_handles=[handles.civ1_1 handles.interp1_1 handles.filter1_1 handles.civ2_1 handles.interp2_1 handles.filter2_1];
|
---|
| 3001 | set_veltype_display(veltype_handles,6); % make all civ buttons visible
|
---|
| 3002 | RootPath_1=get(handles.RootPath_1,'String');
|
---|
| 3003 | RootFile_1=get(handles.RootFile_1,'String');
|
---|
| 3004 | if isempty(RootPath_1)|isequal(RootPath_1,'')
|
---|
| 3005 | set(handles.RootPath_1,'String','"')
|
---|
| 3006 | end
|
---|
| 3007 | if isempty(RootFile_1) | isequal(RootFile_1,'')
|
---|
| 3008 | set(handles.RootFile_1,'String','"')
|
---|
| 3009 | end
|
---|
| 3010 | if ~isempty(RootFile_1)&(isequal(RootFile_1(1),'/')|isequal(RootFile_1(1),'\'))
|
---|
| 3011 | RootFile_1(1)=[];
|
---|
| 3012 | end
|
---|
| 3013 | filebase_1=fullfile(RootPath_1,RootFile_1);
|
---|
| 3014 | SubDir_1=get(handles.SubDir,'String');
|
---|
| 3015 | if isempty(SubDir_1)|isequal(SubDir_1,'')
|
---|
| 3016 | if isfield(UvData,'SubDir_1')
|
---|
| 3017 | SubDir_1=UvData.SubDir_1;%retrieve previous subdir
|
---|
| 3018 | else
|
---|
| 3019 | SubDir_1='?';
|
---|
| 3020 | end
|
---|
| 3021 | end
|
---|
| 3022 | if isequal(NomType_1,'#_ab')|isequal(NomType_1,'_i1-i2_j')|isequal(NomType_1,'_i_j1-j2')|isequal(NomType_1,'_i1-i2')
|
---|
| 3023 | NomTypeNew=NomType_1;
|
---|
| 3024 | elseif isequal(NomType_1,'#a')
|
---|
| 3025 | [filename,idetect,n1,na,n2,nb,SubDir_1]=name_generator(filebase_1, str2num(str1),str2num(str_a),'.nc','#_ab',0,[],[],SubDir_1);
|
---|
| 3026 | NomTypeNew='#_ab';
|
---|
| 3027 | elseif isequal(NomType_1,'_i_j')
|
---|
| 3028 | [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);
|
---|
| 3029 | if idetect==1
|
---|
| 3030 | NomTypeNew='_i1-i2_j';
|
---|
| 3031 | else
|
---|
| 3032 | NomTypeNew='_i_j1-j2';
|
---|
| 3033 | end
|
---|
| 3034 | else %for instance avi files or any ima_num series
|
---|
| 3035 | [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);
|
---|
| 3036 | NomTypeNew='_i1-i2';
|
---|
| 3037 | end
|
---|
| 3038 | [Path,Name]=fileparts(filebase_1);
|
---|
| 3039 | set(handles.FileExt_1,'String','.nc');
|
---|
| 3040 | if ~isempty(SubDir_1) & ~isequal(SubDir_1,'''')& ~isequal(SubDir_1,'"')
|
---|
| 3041 | SubDir_1=['/' SubDir_1];
|
---|
| 3042 | end
|
---|
| 3043 | set(handles.SubDir_1,'String',SubDir_1);
|
---|
| 3044 | end
|
---|
| 3045 | if isequal(field,'vort') | isequal(field,'div') | isequal(field,'strain')
|
---|
| 3046 | set(handles.civ1_1,'BackgroundColor',[0.702 0.702 0.702]) % put their color to grey
|
---|
| 3047 | set(handles.civ2_1,'BackgroundColor',[0.702 0.702 0.702])
|
---|
| 3048 | set(handles.interp1_1,'BackgroundColor',[0.702 0.702 0.702])
|
---|
| 3049 | set(handles.interp2_1,'BackgroundColor',[0.702 0.702 0.702])
|
---|
| 3050 | elseif isequal(field_1,'more...'); %add new item to the menu
|
---|
| 3051 | set(handles.civ1_1,'BackgroundColor',[0.702 0.702 0.702]) % put their color to grey
|
---|
| 3052 | set(handles.civ2_1,'BackgroundColor',[0.702 0.702 0.702])
|
---|
| 3053 | str=calc_field;%get the list of available scalars by the function calc_scal
|
---|
| 3054 | [ind_answer,v] = listdlg('PromptString','Select a file:',...
|
---|
| 3055 | 'SelectionMode','single',...
|
---|
| 3056 | 'ListString',str);
|
---|
| 3057 | % edit the choice in the field and action menu
|
---|
| 3058 | scalar=cell2mat(str(ind_answer));
|
---|
| 3059 | menu=update_menu(handles.Fields_1,scalar);
|
---|
| 3060 | set(handles.Fields_1,'String',menu);% store the selected scalar type
|
---|
| 3061 | end
|
---|
| 3062 | end
|
---|
| 3063 | str1=get(handles.i1,'String');
|
---|
| 3064 | str2=get(handles.i2,'String');
|
---|
| 3065 | str_a=get(handles.j1,'String');
|
---|
| 3066 | str_b=get(handles.j2,'String');
|
---|
| 3067 | indices=name_generator('',str2num(str1),stra2num(str_a),'',NomTypeNew,1,str2num(str2),stra2num(str_b),'');
|
---|
| 3068 | set(handles.FileIndex_1,'String',indices)
|
---|
| 3069 | set(handles.FileIndex_1,'UserData',NomTypeNew)
|
---|
| 3070 |
|
---|
| 3071 | %common to Fields_Callback
|
---|
| 3072 | if isequal(field,'image')|isequal(field_1,'image')
|
---|
| 3073 | set(handles.npx_title,'Visible','on')% visible npx,pxcm... buttons
|
---|
| 3074 | set(handles.npy_title,'Visible','on')
|
---|
| 3075 | set(handles.npx,'Visible','on')
|
---|
| 3076 | set(handles.npy,'Visible','on')
|
---|
| 3077 | set(handles.fix_pair,'Value',0)
|
---|
| 3078 | else
|
---|
| 3079 | set(handles.npx_title,'Visible','off')% visible npx,pxcm... buttons
|
---|
| 3080 | set(handles.npy_title,'Visible','off')
|
---|
| 3081 | set(handles.npx,'Visible','off')
|
---|
| 3082 | set(handles.npy,'Visible','off')
|
---|
| 3083 | set(handles.fix_pair,'Value',1)
|
---|
| 3084 | end
|
---|
| 3085 | if isequal(field,'velocity')|isequal(field_1,'velocity');
|
---|
| 3086 | state_vect='on';
|
---|
| 3087 | else
|
---|
| 3088 | state_vect='off';
|
---|
| 3089 | end
|
---|
| 3090 | if ~isequal(field,'velocity')|(~isequal(field_1,'velocity')&~isequal(field_1,''));
|
---|
| 3091 | state_scal='on';
|
---|
| 3092 | else
|
---|
| 3093 | state_scal='off';
|
---|
| 3094 | end
|
---|
| 3095 | set(huvmat,'UserData',UvData)
|
---|
| 3096 | setfield(handles);% update the field structure ('civ1'....)
|
---|
| 3097 | if ~isfield(UvData,'NewSeries')|isequal(UvData.NewSeries,0)
|
---|
| 3098 | run0_Callback(hObject, eventdata, handles)
|
---|
| 3099 | end
|
---|
| 3100 |
|
---|
| 3101 |
|
---|
| 3102 | %-----------------------------------
|
---|
| 3103 | %set the visibility of relevant velocity type menus:
|
---|
| 3104 | %-----------------------------------
|
---|
| 3105 | %Civ=0; all states 'off'
|
---|
| 3106 | %Civ=6; all states 'on'
|
---|
| 3107 | function set_veltype_display(handles,Civ)
|
---|
| 3108 | if isequal(Civ,0)
|
---|
| 3109 | imax=0;
|
---|
| 3110 | % set(handles(1),'Visible','on') % unvisible civ buttons
|
---|
| 3111 | % else
|
---|
| 3112 | % set(handles(1),'String','civ1')
|
---|
| 3113 | % end
|
---|
| 3114 | elseif isequal(Civ,1)
|
---|
| 3115 | imax=1;
|
---|
| 3116 | elseif isequal(Civ,2) | isequal(Civ,3)
|
---|
| 3117 | imax=3;
|
---|
| 3118 | elseif isequal(Civ,4) | isequal(Civ,5)
|
---|
| 3119 | imax=4;
|
---|
| 3120 | elseif isequal(Civ,6)
|
---|
| 3121 | imax=6;
|
---|
| 3122 | end
|
---|
| 3123 | for ibutton=1:imax;
|
---|
| 3124 | set(handles(ibutton),'Visible','on') % unvisible civ buttons
|
---|
| 3125 | end
|
---|
| 3126 | % for ibutton=max(imax+1,2):6;
|
---|
| 3127 | for ibutton=imax+1:6;
|
---|
| 3128 | set(handles(ibutton),'Visible','off') % unvisible civ buttons
|
---|
| 3129 | set(handles(ibutton),'Value',0)%unactivate unvisible buttons
|
---|
| 3130 | end
|
---|
| 3131 |
|
---|
| 3132 | %-------------------------------------------------------------------
|
---|
| 3133 | % --- Executes on button press in civ1.
|
---|
| 3134 | function civ1_Callback(hObject, eventdata, handles)
|
---|
| 3135 | %-------------------------------------------------------------------
|
---|
| 3136 | if get(handles.civ1,'Value')==1
|
---|
| 3137 | reset_vel_type([handles.interp1 handles.civ2 handles.filter1 handles.interp1 handles.interp2 handles.filter2],handles.civ1)
|
---|
| 3138 | else
|
---|
| 3139 | reset_vel_type([handles.civ1 handles.filter1 handles.interp1 handles.civ2 handles.interp2 handles.filter2])
|
---|
| 3140 | end
|
---|
| 3141 | run0_Callback(hObject, eventdata, handles)
|
---|
| 3142 |
|
---|
| 3143 | %-------------------------------------------------------------------
|
---|
| 3144 | % --- Executes on button press in interp1.
|
---|
| 3145 | function interp1_Callback(hObject, eventdata, handles)
|
---|
| 3146 | %-------------------------------------------------------------------
|
---|
| 3147 | if get(handles.interp1,'Value')==1
|
---|
| 3148 | reset_vel_type([handles.civ1 handles.civ2 handles.filter1 handles.interp2 handles.filter2],handles.interp1)
|
---|
| 3149 | else
|
---|
| 3150 | reset_vel_type([handles.civ1 handles.filter1 handles.interp1 handles.civ2 handles.interp2 handles.filter2])
|
---|
| 3151 | end
|
---|
| 3152 | run0_Callback(hObject, eventdata, handles)
|
---|
| 3153 |
|
---|
| 3154 | %-------------------------------------------------------------------
|
---|
| 3155 | % --- Executes on button press in filter1.
|
---|
| 3156 | function filter1_Callback(hObject, eventdata, handles)
|
---|
| 3157 | %-------------------------------------------------------------------
|
---|
| 3158 | if get(handles.filter1,'Value')==1
|
---|
| 3159 | reset_vel_type([handles.civ1 handles.civ2 handles.interp1 handles.interp2 handles.filter2],handles.filter1)
|
---|
| 3160 | else
|
---|
| 3161 | reset_vel_type([handles.civ1 handles.filter1 handles.interp1 handles.civ2 handles.interp2 handles.filter2])
|
---|
| 3162 | end
|
---|
| 3163 | run0_Callback(hObject, eventdata, handles)
|
---|
| 3164 |
|
---|
| 3165 | %-------------------------------------------------------------------
|
---|
| 3166 | % --- Executes on button press in civ2.
|
---|
| 3167 | function civ2_Callback(hObject, eventdata, handles)
|
---|
| 3168 | %-------------------------------------------------------------------
|
---|
| 3169 | if get(handles.civ2,'Value')==1
|
---|
| 3170 | reset_vel_type([handles.civ1 handles.filter1 handles.interp1 handles.interp2 handles.filter2],handles.civ2)
|
---|
| 3171 | else
|
---|
| 3172 | reset_vel_type([handles.civ1 handles.filter1 handles.interp1 handles.civ2 handles.interp2 handles.filter2])
|
---|
| 3173 | end
|
---|
| 3174 | run0_Callback(hObject, eventdata, handles)
|
---|
| 3175 |
|
---|
| 3176 | %-----------------------------------------
|
---|
| 3177 | % --- Executes on button press in interp2.
|
---|
| 3178 | %-------------------------------------------
|
---|
| 3179 | function interp2_Callback(hObject, eventdata, handles)
|
---|
| 3180 | if get(handles.interp2,'Value')==1
|
---|
| 3181 | reset_vel_type([handles.civ1 handles.filter1 handles.interp1 handles.civ2 handles.filter2],handles.interp2)
|
---|
| 3182 | else
|
---|
| 3183 | reset_vel_type([handles.civ1 handles.filter1 handles.interp1 handles.civ2 handles.interp2 handles.filter2])
|
---|
| 3184 | end
|
---|
| 3185 | run0_Callback(hObject, eventdata, handles)
|
---|
| 3186 | %---------------------------------------------
|
---|
| 3187 | % --- Executes on button press in filter2.
|
---|
| 3188 | %-------------------------------------------
|
---|
| 3189 | function filter2_Callback(hObject, eventdata, handles)
|
---|
| 3190 | if get(handles.filter2,'Value')==1
|
---|
| 3191 | reset_vel_type([handles.civ1 handles.filter1 handles.interp1 handles.civ2 handles.interp2],handles.filter2)
|
---|
| 3192 | else
|
---|
| 3193 | reset_vel_type([handles.civ1 handles.filter1 handles.interp1 handles.civ2 handles.interp2 handles.filter2])
|
---|
| 3194 | end
|
---|
| 3195 | run0_Callback(hObject, eventdata, handles)
|
---|
| 3196 |
|
---|
| 3197 | %---------------------------------------------
|
---|
| 3198 | function civ1_1_Callback(hObject, eventdata, handles)
|
---|
| 3199 | %---------------------------------------------
|
---|
| 3200 | if get(handles.civ1_1,'Value')==1
|
---|
| 3201 | reset_vel_type([handles.interp1_1 handles.civ2_1 handles.filter1_1 handles.interp1_1 handles.interp2_1 handles.filter2_1],handles.civ1_1)
|
---|
| 3202 | else
|
---|
| 3203 | reset_vel_type([handles.civ1_1 handles.filter1_1 handles.interp1_1 handles.civ2_1 handles.interp2_1 handles.filter2_1])
|
---|
| 3204 | end
|
---|
| 3205 | run0_Callback(hObject, eventdata, handles)
|
---|
| 3206 |
|
---|
| 3207 | %--------------------------------------------
|
---|
| 3208 | function interp1_1_Callback(hObject, eventdata, handles)
|
---|
| 3209 | %--------------------------------------------
|
---|
| 3210 | if get(handles.interp1_1,'Value')==1
|
---|
| 3211 | reset_vel_type([handles.civ1_1 handles.civ2_1 handles.filter1_1 handles.interp2_1 handles.filter2_1],handles.interp1_1)
|
---|
| 3212 | else
|
---|
| 3213 | reset_vel_type([handles.civ1_1 handles.filter1_1 handles.interp1_1 handles.civ2_1 handles.interp2_1 handles.filter2_1])
|
---|
| 3214 | end
|
---|
| 3215 | run0_Callback(hObject, eventdata, handles)
|
---|
| 3216 |
|
---|
| 3217 | %--------------------------------------------
|
---|
| 3218 | function filter1_1_Callback(hObject, eventdata, handles)
|
---|
| 3219 | %--------------------------------------------
|
---|
| 3220 | if get(handles.filter1_1,'Value')==1
|
---|
| 3221 | reset_vel_type([handles.interp1_1 handles.civ2_1 handles.interp1_1 handles.interp2_1 handles.filter2_1],handles.filter1_1)
|
---|
| 3222 | else
|
---|
| 3223 | reset_vel_type([handles.civ1_1 handles.filter1_1 handles.interp1_1 handles.civ2_1 handles.interp2_1 handles.filter2_1])
|
---|
| 3224 | end
|
---|
| 3225 | run0_Callback(hObject, eventdata, handles)
|
---|
| 3226 |
|
---|
| 3227 | %--------------------------------------------
|
---|
| 3228 | function civ2_1_Callback(hObject, eventdata, handles)
|
---|
| 3229 | %--------------------------------------------
|
---|
| 3230 | if get(handles.civ2_1,'Value')==1
|
---|
| 3231 | reset_vel_type([handles.civ1_1 handles.interp1_1 handles.filter1_1 handles.interp2_1 handles.filter2_1],handles.civ2_1)
|
---|
| 3232 | else
|
---|
| 3233 | reset_vel_type([handles.civ1_1 handles.filter1_1 handles.interp1_1 handles.civ2_1 handles.interp2_1 handles.filter2_1])
|
---|
| 3234 | end
|
---|
| 3235 | run0_Callback(hObject, eventdata, handles)
|
---|
| 3236 |
|
---|
| 3237 | %--------------------------------------------
|
---|
| 3238 | function interp2_1_Callback(hObject, eventdata, handles)
|
---|
| 3239 | %--------------------------------------------
|
---|
| 3240 | if get(handles.interp2_1,'Value')==1
|
---|
| 3241 | reset_vel_type([handles.civ1_1 handles.civ2_1 handles.filter1_1 handles.interp1_1 handles.filter2_1],handles.interp2_1)
|
---|
| 3242 | else
|
---|
| 3243 | reset_vel_type([handles.civ1_1 handles.filter1_1 handles.interp1_1 handles.civ2_1 handles.interp2_1 handles.filter2_1])
|
---|
| 3244 | end
|
---|
| 3245 | run0_Callback(hObject, eventdata, handles)
|
---|
| 3246 |
|
---|
| 3247 | %--------------------------------------------
|
---|
| 3248 | function filter2_1_Callback(hObject, eventdata, handles)
|
---|
| 3249 | %--------------------------------------------
|
---|
| 3250 | if get(handles.filter2_1,'Value')==1
|
---|
| 3251 | reset_vel_type([handles.civ1_1 handles.interp1_1 handles.civ2_1 handles.filter1_1 handles.interp1_1 handles.interp2_1],handles.filter2_1)
|
---|
| 3252 | else
|
---|
| 3253 | reset_vel_type([handles.civ1_1 handles.filter1_1 handles.interp1_1 handles.civ2_1 handles.interp2_1 handles.filter2_1])
|
---|
| 3254 | end
|
---|
| 3255 | run0_Callback(hObject, eventdata, handles)
|
---|
| 3256 |
|
---|
| 3257 | %-----------------------------------------------
|
---|
| 3258 | % --- reset civ buttons
|
---|
| 3259 | function reset_vel_type(handles_civ0,handle1)
|
---|
| 3260 | for ibutton=1:length(handles_civ0)
|
---|
| 3261 | set(handles_civ0(ibutton),'BackgroundColor',[0.831 0.816 0.784])
|
---|
| 3262 | set(handles_civ0(ibutton),'Value',0)
|
---|
| 3263 | end
|
---|
| 3264 | if exist('handle1','var')%handles of selected button
|
---|
| 3265 | set(handle1,'BackgroundColor',[1 1 0])
|
---|
| 3266 | end
|
---|
| 3267 |
|
---|
| 3268 | %------------------------------------------------
|
---|
| 3269 | function create_Callback(hObject,eventdata,handles)
|
---|
| 3270 | %------------------------------------------------
|
---|
| 3271 | if ishandle(handles.UVMAT_title)
|
---|
| 3272 | delete(handles.UVMAT_title)
|
---|
| 3273 | end
|
---|
| 3274 | huvmat=get(handles.create,'parent');
|
---|
| 3275 | UvData=get(huvmat,'UserData');%read UvData properties stored on the uvmat interface (handles huvmat)
|
---|
| 3276 | if isequal(get(handles.create,'Value'),1)
|
---|
| 3277 | set(handles.zoom,'Value',0)
|
---|
| 3278 | zoom_Callback(hObject, eventdata, handles)
|
---|
| 3279 | set(handles.create,'BackgroundColor',[1 1 0]) %visualise in yellow
|
---|
| 3280 | set(handles.edit_vect,'Value',0)
|
---|
| 3281 | edit_vect_Callback(hObject, eventdata, handles)
|
---|
| 3282 | set(handles.edit,'Value',0)
|
---|
| 3283 | set(handles.edit,'BackgroundColor',[0.7 0.7 0.7])
|
---|
| 3284 | list_object=get(handles.list_object,'String');
|
---|
| 3285 | if ~isempty(list_object)
|
---|
| 3286 | set(handles.list_object,'Value',length(list_object))
|
---|
| 3287 | end
|
---|
| 3288 | MouseAction='create_object';
|
---|
| 3289 | hset_object=findobj(allchild(0),'Name','set_object');
|
---|
| 3290 | uistack(hset_object,'top')
|
---|
| 3291 | else
|
---|
| 3292 | set(handles.create,'BackgroundColor',[0 1 0])
|
---|
| 3293 | set(handles.edit,'Value',1)
|
---|
| 3294 | set(handles.edit,'BackgroundColor',[1 1 0])
|
---|
| 3295 | MouseAction='none';
|
---|
| 3296 | end
|
---|
| 3297 |
|
---|
| 3298 | UvData.MouseAction=MouseAction;
|
---|
| 3299 | set(huvmat,'UserData',UvData);
|
---|
| 3300 |
|
---|
| 3301 | %------------------------------------------------
|
---|
| 3302 | function POINTS_Callback(hObject,eventdata,handles)
|
---|
| 3303 | %------------------------------------------------
|
---|
| 3304 | if ishandle(handles.UVMAT_title)
|
---|
| 3305 | delete(handles.UVMAT_title)
|
---|
| 3306 | end
|
---|
| 3307 | huvmat=get(handles.create,'parent');
|
---|
| 3308 | UvData=get(huvmat,'UserData');%read UvData properties stored on the uvmat interface (handles huvmat)
|
---|
| 3309 | if isequal(get(handles.create,'Value'),1)
|
---|
| 3310 | set(handles.zoom,'Value',0)
|
---|
| 3311 | zoom_Callback(hObject, eventdata, handles)
|
---|
| 3312 | set(handles.edit_vect,'Value',0)
|
---|
| 3313 | edit_vect_Callback(hObject, eventdata, handles)
|
---|
| 3314 | set(handles.edit,'Value',0)
|
---|
| 3315 | set(handles.edit,'BackgroundColor',[0.7 0.7 0.7])
|
---|
| 3316 | %set(handles.grid,'Value',0)
|
---|
| 3317 | %set(handles.grid,'BackgroundColor',[0 1 0])
|
---|
| 3318 | % initiate set_object GUI
|
---|
| 3319 | data.TITLE='POINTS';
|
---|
| 3320 | if isfield(UvData,'CoordType')
|
---|
| 3321 | data.CoordType=UvData.CoordType;
|
---|
| 3322 | end
|
---|
| 3323 | if isfield(UvData,'Mesh')&~isempty(UvData.Mesh)
|
---|
| 3324 | data.RangeY=UvData.Mesh;
|
---|
| 3325 | elseif isfield(UvData,'AX')&isfield(UvData,'AY')& isfield(UvData,'A')%only image
|
---|
| 3326 | np=size(UvData.Field.A);
|
---|
| 3327 | meshx=(UvData.Field.AX(end)-UvData.Field.AX(1))/np(2);
|
---|
| 3328 | meshy=abs(UvData.Field.AY(end)-UvData.Field.AY(1))/np(1);
|
---|
| 3329 | data.RangeY=max(meshx,meshy);
|
---|
| 3330 | data.DX=max(meshx,meshy);
|
---|
| 3331 | end
|
---|
| 3332 | data.Coord=[0 0 0]; %default
|
---|
| 3333 | data.ParentButton=handles.create;
|
---|
| 3334 | PlotHandles=get_plot_handles(handles);%get the handles of the graphic objects setting the plotting parameters
|
---|
| 3335 | [hset_object,UvData.sethandles]=set_object(data,PlotHandles);% call the set_object interface
|
---|
| 3336 | if isfield(UvData,'SetObjectOrigin')
|
---|
| 3337 | pos_uvmat=get(huvmat,'Position');
|
---|
| 3338 | pos_set_object(1:2)=UvData.SetObjectOrigin + pos_uvmat(1:2);
|
---|
| 3339 | pos_set_object(3:4)=UvData.SetObjectSize .* pos_uvmat(3:4);
|
---|
| 3340 | set(hset_object,'Position',pos_set_object)
|
---|
| 3341 | end
|
---|
| 3342 | %set(hset_object,'Position',[pos_uvmat(1) pos_uvmat(2)-0.05*pos_uvmat(4) 0.2*pos_uvmat(3) 0.5*pos_uvmat(4)]);
|
---|
| 3343 | list_object=get(handles.list_object,'String');
|
---|
| 3344 | if ~isempty(list_object)
|
---|
| 3345 | set(handles.list_object,'Value',length(list_object))
|
---|
| 3346 | end
|
---|
| 3347 | MouseAction='create_object';
|
---|
| 3348 | %UvData.ZoomOn=0;
|
---|
| 3349 | else
|
---|
| 3350 | set(handles.create,'BackgroundColor',[0 1 0])
|
---|
| 3351 | set(handles.edit,'Value',1)
|
---|
| 3352 | set(handles.edit,'BackgroundColor',[1 1 0])
|
---|
| 3353 | MouseAction='none';
|
---|
| 3354 | end
|
---|
| 3355 |
|
---|
| 3356 | UvData.MouseAction=MouseAction;
|
---|
| 3357 | set(huvmat,'UserData',UvData);
|
---|
| 3358 |
|
---|
| 3359 | %-----------------------------------------------------------
|
---|
| 3360 | function LINE_Callback(hObject, eventdata, handles)
|
---|
| 3361 | %-------------------------------------------------
|
---|
| 3362 | if ishandle(handles.UVMAT_title)
|
---|
| 3363 | delete(handles.UVMAT_title)
|
---|
| 3364 | end
|
---|
[40] | 3365 | % handles.uvmat
|
---|
[2] | 3366 | huvmat=get(handles.create,'parent');
|
---|
| 3367 | UvData=get(huvmat,'UserData');%read UvData properties stored on the uvmat interface
|
---|
[40] | 3368 | set(handles.zoom,'Value',0)
|
---|
| 3369 | zoom_Callback(hObject, eventdata, handles)
|
---|
| 3370 | set(handles.edit_vect,'BackgroundColor',[0.7 0.7 0.7])
|
---|
| 3371 | set(handles.edit_vect,'Value',0)
|
---|
| 3372 | edit_vect_Callback(hObject, eventdata, handles)
|
---|
| 3373 | set(handles.edit,'BackgroundColor',[0.7 0.7 0.7])
|
---|
| 3374 | set(handles.edit,'Value',0)
|
---|
| 3375 | set(handles.list_object,'Value',1);
|
---|
| 3376 | edit_vect_Callback(hObject, eventdata, handles)
|
---|
| 3377 | set(handles.edit,'BackgroundColor',[0.7 0.7 0.7])
|
---|
| 3378 | set(handles.cal,'Value',0)
|
---|
| 3379 | set(handles.cal,'BackgroundColor',[0 1 0])
|
---|
[2] | 3380 | % initiate the set_object GUI
|
---|
[40] | 3381 | data.TITLE='LINE';
|
---|
| 3382 | if isfield(UvData,'CoordType')
|
---|
| 3383 | data.CoordType=UvData.CoordType;
|
---|
| 3384 | end
|
---|
| 3385 | if isfield(UvData,'Mesh')&~isempty(UvData.Mesh)
|
---|
| 3386 | data.RangeX=UvData.Mesh;
|
---|
| 3387 | data.RangeY=UvData.Mesh;
|
---|
| 3388 | data.DX=UvData.Mesh;
|
---|
| 3389 | data.DY=UvData.Mesh;
|
---|
| 3390 | elseif isfield(UvData.Field,'AX')&isfield(UvData.Field,'AY')& isfield(UvData.Field,'A')%only image
|
---|
| 3391 | np=size(UvData.Field.A);
|
---|
| 3392 | meshx=(UvData.Field.AX(end)-UvData.Field.AX(1))/np(2);
|
---|
| 3393 | meshy=abs(UvData.Field.AY(end)-UvData.Field.AY(1))/np(1);
|
---|
| 3394 | data.RangeY=max(meshx,meshy);
|
---|
| 3395 | data.RangeX=max(meshx,meshy);
|
---|
| 3396 | data.DX=max(meshx,meshy);
|
---|
| 3397 | end
|
---|
| 3398 | if isfield(data,'DX')
|
---|
| 3399 | data.Coord=[[0 0 0];[data.DX 0 0]]; %default
|
---|
| 3400 | else
|
---|
| 3401 | data.Coord=[[0 0 0];[1 0 0]]; %default
|
---|
| 3402 | end
|
---|
| 3403 | data.ParentButton=handles.create;
|
---|
| 3404 | PlotHandles=get_plot_handles(handles);%get the handles of the interface elements setting the plotting parameters
|
---|
| 3405 | [hset_object,UvData.sethandles]=set_object(data,PlotHandles);% call the set_object interface with action on haxes,
|
---|
| 3406 | % associate the set_edit interface handle to the plotting axes
|
---|
| 3407 | pos_uvmat=get(huvmat,'Position');
|
---|
| 3408 | if isfield(UvData,'SetObjectOrigin')
|
---|
| 3409 | pos_set_object(1:2)=UvData.SetObjectOrigin + pos_uvmat(1:2);
|
---|
| 3410 | pos_set_object(3:4)=UvData.SetObjectSize .* pos_uvmat(3:4);
|
---|
| 3411 | set(hset_object,'Position',pos_set_object)
|
---|
| 3412 | end
|
---|
| 3413 | list_object=get(handles.list_object,'String');
|
---|
| 3414 | if ~isempty(list_object)
|
---|
| 3415 | set(handles.list_object,'Value',length(list_object))
|
---|
| 3416 | end
|
---|
| 3417 | MouseAction='create_object';
|
---|
[2] | 3418 | UvData.MouseAction=MouseAction;
|
---|
| 3419 | set(huvmat,'UserData',UvData)
|
---|
| 3420 |
|
---|
| 3421 | %-----------------------------------------------------------
|
---|
| 3422 | function PATCH_Callback(hObject, eventdata, handles)
|
---|
| 3423 | %-----------------------------------------------------------
|
---|
| 3424 | if ishandle(handles.UVMAT_title)
|
---|
| 3425 | delete(handles.UVMAT_title)
|
---|
| 3426 | end
|
---|
| 3427 | huvmat=get(handles.create,'parent');
|
---|
| 3428 | UvData=get(huvmat,'UserData');%read UvData properties stored on the uvmat interface
|
---|
| 3429 | % if isequal(get(handles.PATCH,'Value'),1)
|
---|
| 3430 | set(handles.zoom,'Value',0)
|
---|
| 3431 | set(handles.zoom,'BackgroundColor',[0.7 0.7 0.7])
|
---|
| 3432 | % set(handles.create,'Value',0)%suppress the other options if LINE is chosen
|
---|
| 3433 | % set(handles.create,'BackgroundColor',[0 1 0])
|
---|
| 3434 | % set(handles.LINE,'Value',0)
|
---|
| 3435 | % set(handles.LINE,'BackgroundColor',[0 1 0])
|
---|
| 3436 | % set(handles.PATCH,'Value',1)
|
---|
| 3437 | % set(handles.PATCH,'BackgroundColor',[1 1 0])
|
---|
| 3438 | % set(handles.PLANE,'Value',0)
|
---|
| 3439 | % set(handles.PLANE,'BackgroundColor',[0 1 0])%put activated buttons to yellow
|
---|
| 3440 | % set(handles.VOLUME,'Value',0)
|
---|
| 3441 | % set(handles.VOLUME,'BackgroundColor',[0 1 0])
|
---|
| 3442 | %set(handles.makemask,'Value',0)
|
---|
| 3443 | %makemask_Callback(hObject, eventdata, handles)
|
---|
| 3444 | set(handles.edit_vect,'Value',0)
|
---|
| 3445 | edit_vect_Callback(hObject, eventdata, handles)
|
---|
| 3446 | set(handles.edit,'Value',0)
|
---|
| 3447 | set(handles.edit,'BackgroundColor',[0.7 0.7 0.7])
|
---|
| 3448 | set(handles.edit_vect,'Value',0)
|
---|
| 3449 | edit_vect_Callback(hObject, eventdata, handles)
|
---|
| 3450 | set(handles.cal,'Value',0)
|
---|
| 3451 | set(handles.cal,'BackgroundColor',[0 1 0])
|
---|
| 3452 | %set(handles.grid,'Value',0)
|
---|
| 3453 | %set(handles.grid,'BackgroundColor',[0 1 0])
|
---|
| 3454 | %initiate set_object GUI
|
---|
| 3455 | data.TITLE='PATCH';
|
---|
| 3456 | if isfield(UvData,'CoordType')
|
---|
| 3457 | data.CoordType=UvData.CoordType;
|
---|
| 3458 | end
|
---|
| 3459 | if isfield(UvData,'Mesh')&~isempty(UvData.Mesh)
|
---|
| 3460 | data.YMax=UvData.Mesh;
|
---|
| 3461 | elseif isfield(UvData.Field,'AX')&isfield(UvData.Field,'AY')& isfield(UvData.Field,'A')%only image
|
---|
| 3462 | np=size(UvData.Field.A);
|
---|
| 3463 | meshx=(UvData.Field.AX(end)-UvData.Field.AX(1))/(np(2)-1);
|
---|
| 3464 | meshy=abs(UvData.Field.AY(end)-UvData.Field.AY(1))/(np(1)-1);
|
---|
| 3465 | data.YMax=max(meshx,meshy);
|
---|
| 3466 | data.DX=max(meshx,meshy);
|
---|
| 3467 | end
|
---|
| 3468 | data.Coord=[0 0 0]; %default
|
---|
| 3469 | data.ParentButton=handles.create;
|
---|
| 3470 | PlotHandles=get_plot_handles(handles);%get the handles of the graphic objects setting the plotting parameters
|
---|
| 3471 | [hset_object,UvData.sethandles]=set_object(data,PlotHandles);% call the set_object interface
|
---|
| 3472 | pos_uvmat=get(huvmat,'Position');
|
---|
| 3473 | if isfield(UvData,'SetObjectOrigin')
|
---|
| 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 | list_object=get(handles.list_object,'String');
|
---|
| 3479 | if ~isempty(list_object)
|
---|
| 3480 | set(handles.list_object,'Value',length(list_object))
|
---|
| 3481 | end
|
---|
| 3482 | UvData.MouseAction='create_object';
|
---|
| 3483 | set(huvmat,'UserData',UvData);
|
---|
| 3484 | %-------------------------------------------------------
|
---|
| 3485 | function PLANE_Callback(hObject, eventdata, handles)
|
---|
| 3486 | %-------------------------------------------------------
|
---|
| 3487 | if ishandle(handles.UVMAT_title)
|
---|
| 3488 | delete(handles.UVMAT_title)
|
---|
| 3489 | end
|
---|
| 3490 | huvmat=get(handles.create,'parent');
|
---|
| 3491 | UvData=get(huvmat,'UserData');%read UvData properties stored on the uvmat interface
|
---|
| 3492 | set(handles.zoom,'Value',0)
|
---|
| 3493 | set(handles.zoom,'BackgroundColor',[0.7 0.7 0.7])
|
---|
| 3494 | set(handles.edit_vect,'Value',0)
|
---|
| 3495 | edit_vect_Callback(hObject, eventdata, handles)
|
---|
| 3496 | set(handles.edit,'Value',0)
|
---|
| 3497 | set(handles.edit,'BackgroundColor',[0.7 0.7 0.7])
|
---|
| 3498 | set(handles.cal,'Value',0)
|
---|
| 3499 | set(handles.cal,'BackgroundColor',[0 1 0])
|
---|
| 3500 | %set(handles.grid,'Value',0)
|
---|
| 3501 | %set(handles.grid,'BackgroundColor',[0 1 0])
|
---|
| 3502 | %initiate set_object GUI
|
---|
| 3503 | data.TITLE='PLANE';
|
---|
| 3504 | if isfield(UvData,'CoordType')
|
---|
| 3505 | data.CoordType=UvData.CoordType;
|
---|
| 3506 | end
|
---|
| 3507 | %Si 3D data.nbdim=3;
|
---|
| 3508 | %Si 2D
|
---|
| 3509 | if isfield(UvData,'Mesh')&~isempty(UvData.Mesh)
|
---|
| 3510 | data.ZMax=UvData.Mesh;
|
---|
| 3511 | data.DX=UvData.Mesh;
|
---|
| 3512 | data.DY=UvData.Mesh;
|
---|
| 3513 | elseif isfield(UvData.Field,'AX')&isfield(UvData.Field,'AY')& isfield(UvData.Field,'A')%only image
|
---|
| 3514 | np=size(UvData.Field.A);
|
---|
| 3515 | meshx=(UvData.Field.AX(end)-UvData.Field.AX(1))/(np(2)-1);
|
---|
| 3516 | meshy=abs(UvData.Field.AY(end)-UvData.Field.AY(1))/(np(1)-1);
|
---|
| 3517 | data.DX=max(meshx,meshy);
|
---|
| 3518 | end
|
---|
| 3519 | if isfield(UvData,'DX')
|
---|
| 3520 | data.DX=UvData.DX;
|
---|
| 3521 | end
|
---|
| 3522 | if isfield(UvData,'DY')
|
---|
| 3523 | data.DY=UvData.DY;
|
---|
| 3524 | elseif isfield(UvData,'Mesh')
|
---|
| 3525 | data.DY=UvData.Mesh;
|
---|
| 3526 | end
|
---|
| 3527 | if isfield(UvData.Field,'X')& isfield(UvData.Field,'Y')
|
---|
| 3528 | data.Coord=[0 0 0];
|
---|
| 3529 | data.Style='plane';
|
---|
| 3530 | data.Phi=0;
|
---|
| 3531 | data.IndexObj=1; %act on the first reference plane by default
|
---|
| 3532 | haxes= handles.axes3;%GENERALISER
|
---|
| 3533 | plot_object(data,[],haxes,'m'); %plot the axes of the default plane
|
---|
| 3534 | end
|
---|
| 3535 | data.ParentButton=handles.create;
|
---|
| 3536 | PlotHandles=get_plot_handles(handles);%get the handles of the graphic objects setting the plotting parameters
|
---|
| 3537 | ZBounds=0; % default
|
---|
| 3538 | if isfield(UvData,'ZMin') && isfield(UvData,'ZMax')
|
---|
| 3539 | ZBounds(1)=UvData.ZMin; %minimum for the Z slider
|
---|
| 3540 | ZBounds(2)=UvData.ZMax;%maximum for the Z slider
|
---|
| 3541 | end
|
---|
| 3542 | [hset_object,UvData.sethandles]=set_object(data,PlotHandles,ZBounds);% call the set_object interface with action on haxes,
|
---|
| 3543 | if isfield(UvData,'SetObjectOrigin')
|
---|
| 3544 | pos_uvmat=get(huvmat,'Position');
|
---|
| 3545 | pos_set_object(1:2)=UvData.SetObjectOrigin + pos_uvmat(1:2);
|
---|
| 3546 | pos_set_object(3:4)=UvData.SetObjectSize .* pos_uvmat(3:4);
|
---|
| 3547 | set(hset_object,'Position',pos_set_object)
|
---|
| 3548 | end
|
---|
| 3549 | list_object=get(handles.list_object,'String');
|
---|
| 3550 | nbobject=length(list_object);
|
---|
| 3551 | set(handles.list_object,'Value',nbobject)
|
---|
| 3552 | UvData.MouseAction='create_object';
|
---|
| 3553 | set(huvmat,'UserData',UvData)
|
---|
| 3554 |
|
---|
| 3555 | %-------------------------------------------------------
|
---|
| 3556 | % --- Executes on button press in MENUVOLUME.
|
---|
| 3557 | %-------------------------------------------------------
|
---|
| 3558 | function VOLUME_Callback(hObject, eventdata, handles)
|
---|
| 3559 | %errordlg('command VOL not implemented yet')
|
---|
| 3560 | if ishandle(handles.UVMAT_title)
|
---|
| 3561 | delete(handles.UVMAT_title)
|
---|
| 3562 | end
|
---|
| 3563 | huvmat=get(handles.create,'parent');
|
---|
| 3564 | UvData=get(huvmat,'UserData');%read UvData properties stored on the uvmat interface
|
---|
| 3565 | if isequal(get(handles.VOLUME,'Value'),1)
|
---|
| 3566 | set(handles.zoom,'Value',0)
|
---|
| 3567 | set(handles.zoom,'BackgroundColor',[0.7 0.7 0.7])
|
---|
| 3568 | set(handles.edit_vect,'Value',0)
|
---|
| 3569 | edit_vect_Callback(hObject, eventdata, handles)
|
---|
| 3570 | set(handles.edit,'Value',0)
|
---|
| 3571 | set(handles.edit,'BackgroundColor',[0.7 0.7 0.7])
|
---|
| 3572 | set(handles.cal,'Value',0)
|
---|
| 3573 | set(handles.cal,'BackgroundColor',[0 1 0])
|
---|
| 3574 | set(handles.edit_vect,'Value',0)
|
---|
| 3575 | edit_vect_Callback(hObject, eventdata, handles)
|
---|
| 3576 | %initiate set_object GUI
|
---|
| 3577 | data.TITLE='VOLUME';
|
---|
| 3578 | if isfield(UvData,'CoordType')
|
---|
| 3579 | data.CoordType=UvData.CoordType;
|
---|
| 3580 | end
|
---|
| 3581 | if isfield(UvData,'Mesh')&~isempty(UvData.Mesh)
|
---|
| 3582 | data.RangeY=UvData.Mesh;
|
---|
| 3583 | data.RangeX=UvData.Mesh;
|
---|
| 3584 | data.DX=UvData.Mesh;
|
---|
| 3585 | data.DY=UvData.Mesh;
|
---|
| 3586 | elseif isfield(UvData.Field,'AX')&isfield(UvData.Field,'AY')& isfield(UvData.Field,'A')%only image
|
---|
| 3587 | np=size(UvData.Field.A);
|
---|
| 3588 | meshx=(UvData.Field.AX(end)-UvData.Field.AX(1))/np(2);
|
---|
| 3589 | meshy=abs(UvData.Field.AY(end)-UvData.Field.AY(1))/np(1);
|
---|
| 3590 | data.RangeY=max(meshx,meshy);
|
---|
| 3591 | data.RangeX=max(meshx,meshy);
|
---|
| 3592 | data.DX=max(meshx,meshy);
|
---|
| 3593 | end
|
---|
| 3594 | data.ParentButton=handles.VOLUME;
|
---|
| 3595 | PlotHandles=get_plot_handles(handles);%get the handles of the interface elements setting the plotting parameters
|
---|
| 3596 | [hset_object,UvData.sethandles]=set_object(data,PlotHandles);% call the set_object interface with action on haxes,
|
---|
| 3597 | % associate the set_edit interface handle to the plotting axes
|
---|
| 3598 | if isfield(UvData,'SetObjectOrigin')
|
---|
| 3599 | pos_uvmat=get(huvmat,'Position');
|
---|
| 3600 | pos_set_object(1:2)=UvData.SetObjectOrigin + pos_uvmat(1:2);
|
---|
| 3601 | pos_set_object(3:4)=UvData.SetObjectSize .* pos_uvmat(3:4);
|
---|
| 3602 | set(hset_object,'Position',pos_set_object)
|
---|
| 3603 | end
|
---|
| 3604 | UvData.MouseAction='create_object';
|
---|
| 3605 | else
|
---|
| 3606 | set(handles.VOLUME,'BackgroundColor',[0 1 0])
|
---|
| 3607 | UvData.MouseAction='none';
|
---|
| 3608 | end
|
---|
| 3609 | set(huvmat,'UserData',UvData)
|
---|
| 3610 |
|
---|
| 3611 | %-------------------------------------------------------
|
---|
| 3612 | function edit_vect_Callback(hObject, eventdata, handles)
|
---|
| 3613 | %-------------------------------------------------------
|
---|
| 3614 | huvmat=get(handles.edit_vect,'parent');
|
---|
| 3615 | UvData=get(huvmat,'UserData');%read UvData properties stored on the uvmat interface
|
---|
| 3616 | if isequal(get(handles.edit_vect,'Value'),1)
|
---|
| 3617 | set(handles.record,'Visible','on')
|
---|
| 3618 | set(handles.edit_vect,'BackgroundColor',[1 1 0])
|
---|
| 3619 | set(handles.edit,'Value',0)
|
---|
| 3620 | set(handles.create,'Value',0)
|
---|
| 3621 | set(handles.create,'BackgroundColor',[0 1 0])
|
---|
| 3622 | set(handles.edit,'BackgroundColor',[0.7 0.7 0.7])
|
---|
| 3623 | set(gcf,'Pointer','arrow')
|
---|
| 3624 | UvData.MouseAction='edit_vect';
|
---|
| 3625 | else
|
---|
| 3626 | set(handles.record,'Visible','off')
|
---|
| 3627 | set(handles.edit_vect,'BackgroundColor',[0.7 0.7 0.7])
|
---|
| 3628 | UvData.MouseAction='none';
|
---|
| 3629 | end
|
---|
| 3630 | set(huvmat,'UserData',UvData)
|
---|
| 3631 |
|
---|
| 3632 | %----------------------------------------------
|
---|
| 3633 | function save_mask_Callback(hObject, eventdata, handles)
|
---|
| 3634 | %-----------------------------------------------------------------------
|
---|
| 3635 | huvmat=get(handles.save_mask,'parent');
|
---|
| 3636 | UvData=get(huvmat,'UserData');
|
---|
| 3637 |
|
---|
| 3638 | hpatch=findobj(huvmat,'Type','patch');
|
---|
| 3639 | flag=1;
|
---|
| 3640 | npx=size(UvData.Field.A,2);
|
---|
| 3641 | npy=size(UvData.Field.A,1);
|
---|
| 3642 | xi=[0.5:npx-0.5];
|
---|
| 3643 | yi=[0.5:npy-0.5];
|
---|
| 3644 | [Xi,Yi]=meshgrid(xi,yi);
|
---|
| 3645 | if isfield(UvData,'Object')
|
---|
| 3646 | for iobj=1:length(UvData.Object)
|
---|
| 3647 | ObjectData=UvData.Object{iobj};
|
---|
| 3648 | if isfield(ObjectData,'ProjMode') &&(isequal(ObjectData.ProjMode,'mask_inside')||isequal(ObjectData.ProjMode,'mask_outside'));
|
---|
| 3649 | flagobj=1;
|
---|
| 3650 | testphys=0; %coordinates in pixels by default
|
---|
| 3651 | if isfield(ObjectData,'CoordType') && isequal(ObjectData.CoordType,'phys')
|
---|
| 3652 | if isfield(UvData,'XmlData')&& isfield(UvData.XmlData,'GeometryCalib')
|
---|
| 3653 | Calib=UvData.XmlData.GeometryCalib;
|
---|
| 3654 | testphys=1;
|
---|
| 3655 | end
|
---|
| 3656 | end
|
---|
| 3657 | if isfield(ObjectData,'Coord')& isfield(ObjectData,'Style')
|
---|
| 3658 | if isequal(ObjectData.Style,'polygon')
|
---|
| 3659 | X=ObjectData.Coord(:,1);
|
---|
| 3660 | Y=ObjectData.Coord(:,2);
|
---|
| 3661 | if testphys
|
---|
| 3662 | [X,Y]=px_XYZ(Calib,X,Y,0);% to generalise with 3D cases
|
---|
| 3663 | end
|
---|
| 3664 | flagobj=~inpolygon(Xi,Yi,X,Y);%=0 inside the polygon, 1 outside
|
---|
| 3665 | elseif isequal(ObjectData.Style,'ellipse')
|
---|
| 3666 | if testphys
|
---|
| 3667 | %[X,Y]=px_XYZ(Calib,X,Y,0);% TODO:create a polygon boundary and transform to phys
|
---|
| 3668 | end
|
---|
| 3669 | RangeX=max(ObjectData.RangeX);
|
---|
| 3670 | RangeY=max(ObjectData.RangeY);
|
---|
| 3671 | X2Max=RangeX*RangeX;
|
---|
| 3672 | Y2Max=RangeY*RangeY;
|
---|
| 3673 | distX=(Xi-ObjectData.Coord(1,1));
|
---|
| 3674 | distY=(Yi-ObjectData.Coord(1,2));
|
---|
| 3675 | flagobj=(distX.*distX/X2Max+distY.*distY/Y2Max)>1;
|
---|
| 3676 | elseif isequal(ObjectData.Style,'rectangle')
|
---|
| 3677 | if testphys
|
---|
| 3678 | %[X,Y]=px_XYZ(Calib,X,Y,0);% TODO:create a polygon boundary and transform to phys
|
---|
| 3679 | end
|
---|
| 3680 | distX=abs(Xi-ObjectData.Coord(1,1));
|
---|
| 3681 | distY=abs(Yi-ObjectData.Coord(1,2));
|
---|
| 3682 | flagobj=distX>max(ObjectData.RangeX) | distY>max(ObjectData.RangeY);
|
---|
| 3683 | end
|
---|
| 3684 | if isequal(ObjectData.ProjMode,'mask_outside')
|
---|
| 3685 | flagobj=~flagobj;
|
---|
| 3686 | end
|
---|
| 3687 | flag=flag & flagobj;
|
---|
| 3688 | end
|
---|
| 3689 | end
|
---|
| 3690 | end
|
---|
| 3691 | end
|
---|
| 3692 | % flag=~flag;
|
---|
| 3693 | %mask name
|
---|
| 3694 | RootPath=get(handles.RootPath,'String');
|
---|
| 3695 | RootFile=get(handles.RootFile,'String');
|
---|
| 3696 | if ~isempty(RootFile)&(isequal(RootFile(1),'/')| isequal(RootFile(1),'\'))
|
---|
| 3697 | RootFile(1)=[];
|
---|
| 3698 | end
|
---|
| 3699 | filebase=fullfile(RootPath,RootFile);
|
---|
| 3700 | list=get(handles.masklevel,'String');
|
---|
| 3701 | masknumber=num2str(length(list));
|
---|
| 3702 | maskindex=get(handles.masklevel,'Value');
|
---|
| 3703 | mask_name=name_generator([filebase '_' masknumber 'mask'],maskindex,1,'.png','_i');
|
---|
| 3704 | imflag=uint8(255*(0.392+0.608*flag));% =100 for flag=0 (vectors not computed when 20<imflag<200)
|
---|
| 3705 | imflag=flipdim(imflag,1);
|
---|
| 3706 | % imflag=uint8(255*flag);% =0 for flag=0 (vectors=0 when 20<imflag<200)
|
---|
[38] | 3707 | msgbox_uvmat('CONFIRMATION',[mask_name ' saved'])
|
---|
[2] | 3708 | imwrite(imflag,mask_name,'BitDepth',8);
|
---|
| 3709 |
|
---|
| 3710 | %display the mask
|
---|
| 3711 | %update_mask(handles,num_i1,num_j1)
|
---|
| 3712 | figure;
|
---|
| 3713 | vec=linspace(0,1,256);%define a linear greyscale colormap
|
---|
| 3714 | map=[vec' vec' vec'];
|
---|
| 3715 | colormap(map)
|
---|
| 3716 |
|
---|
| 3717 | image(imflag);
|
---|
| 3718 |
|
---|
| 3719 | %-------------------------------------------------------------------
|
---|
| 3720 | %-------------------------------------------------------------------
|
---|
| 3721 | % - FUNCTIONS FOR SETTING PLOTTING PARAMETERS
|
---|
| 3722 |
|
---|
| 3723 | %------------------------------------------------------------------
|
---|
| 3724 |
|
---|
| 3725 |
|
---|
| 3726 |
|
---|
| 3727 | %------------------------------------------------------------------
|
---|
| 3728 | % --- Executes on selection change in col_vec: choice of the color code.
|
---|
| 3729 | %
|
---|
| 3730 | function col_vec_Callback(hObject, eventdata, handles)
|
---|
| 3731 | %------------------------------------------------------------------
|
---|
| 3732 | % edit the choice for color code
|
---|
| 3733 | list_code=get(handles.col_vec,'String');% list menu fields
|
---|
| 3734 | index_code=get(handles.col_vec,'Value');% selected string index
|
---|
| 3735 | col_code= list_code{index_code(1)}; % selected field
|
---|
| 3736 | if isequal(col_code,'black') | isequal(col_code,'white')
|
---|
| 3737 | set(handles.slider1,'Visible','off')
|
---|
| 3738 | set(handles.slider2,'Visible','off')
|
---|
| 3739 | set(handles.colcode1,'Visible','off')
|
---|
| 3740 | set(handles.colcode2,'Visible','off')
|
---|
| 3741 | set(handles.AutoVecColor,'Visible','off')
|
---|
| 3742 | set_vec_col_bar(handles)
|
---|
| 3743 | else
|
---|
| 3744 | set(handles.slider1,'Visible','on')
|
---|
| 3745 | set(handles.slider2,'Visible','on')
|
---|
| 3746 | set(handles.colcode1,'Visible','on')
|
---|
| 3747 | set(handles.colcode2,'Visible','on')
|
---|
| 3748 | set(handles.AutoVecColor,'Visible','on')
|
---|
| 3749 | if isequal(col_code,'ima_cor')
|
---|
| 3750 | set(handles.AutoVecColor,'Value',0)%fixed scale by default
|
---|
| 3751 | set(handles.vec_col_bar,'Value',0)% 3 colors r,g,b by default
|
---|
| 3752 | set(handles.slider1,'Min',0);
|
---|
| 3753 | set(handles.slider1,'Max',1);
|
---|
| 3754 | set(handles.slider2,'Min',0);
|
---|
| 3755 | set(handles.slider2,'Max',1);
|
---|
| 3756 | % set(handles.min_title_vec,'String','0')
|
---|
| 3757 | set(handles.max_vec,'String','1')
|
---|
| 3758 | set(handles.colcode1,'String','0.333')
|
---|
| 3759 | colcode1_Callback(hObject, eventdata, handles)
|
---|
| 3760 | set(handles.colcode2,'String','0.666')
|
---|
| 3761 | colcode2_Callback(hObject, eventdata, handles)
|
---|
| 3762 | else
|
---|
| 3763 | set(handles.AutoVecColor,'Value',1)%auto scale between min,max by default
|
---|
| 3764 | set(handles.vec_col_bar,'Value',1)% colormap 'jet' by default
|
---|
| 3765 | minval=get(handles.slider1,'Min');
|
---|
| 3766 | maxval=get(handles.slider1,'Max');
|
---|
| 3767 | set(handles.slider1,'Value',minval)
|
---|
| 3768 | set(handles.slider2,'Value',maxval)
|
---|
| 3769 | set_vec_col_bar(handles)
|
---|
| 3770 | end
|
---|
| 3771 | % slider_update(handles)
|
---|
| 3772 | end
|
---|
| 3773 | %replot the current graph
|
---|
| 3774 | run0_Callback(hObject, eventdata, handles)
|
---|
| 3775 |
|
---|
| 3776 |
|
---|
| 3777 | %----------------------------------------------------------------
|
---|
| 3778 | % -- Executes on slider movement to set the color code
|
---|
| 3779 | %
|
---|
| 3780 | function slider1_Callback(hObject, eventdata, handles)
|
---|
| 3781 | %------------------------------------------------------------------
|
---|
| 3782 | slider1=get(handles.slider1,'Value');
|
---|
| 3783 | min_val=str2num(get(handles.min_vec,'String'));
|
---|
| 3784 | max_val=str2num(get(handles.max_vec,'String'));
|
---|
| 3785 | col=min_val+(max_val-min_val)*slider1;
|
---|
| 3786 | set(handles.colcode1,'String',num2str(col))
|
---|
| 3787 | if(get(handles.slider2,'Value') < col)%move also the second slider at the same value if needed
|
---|
| 3788 | set(handles.slider2,'Value',col)
|
---|
| 3789 | set(handles.colcode2,'String',num2str(col))
|
---|
| 3790 | end
|
---|
| 3791 | colcode1_Callback(hObject, eventdata, handles)
|
---|
| 3792 |
|
---|
| 3793 | %----------------------------------------------------------------
|
---|
| 3794 | % Executes on slider movement to set the color code
|
---|
| 3795 | %----------------------------------------------------------------
|
---|
| 3796 | function slider2_Callback(hObject, eventdata, handles)
|
---|
| 3797 | slider2=get(handles.slider2,'Value');
|
---|
| 3798 | min_val=str2num(get(handles.min_vec,'String'));
|
---|
| 3799 | max_val=str2num(get(handles.max_vec,'String'));
|
---|
| 3800 | col=min_val+(max_val-min_val)*slider2;
|
---|
| 3801 | set(handles.colcode2,'String',num2str(col))
|
---|
| 3802 | if(get(handles.slider1,'Value') > col)%move also the first slider at the same value if needed
|
---|
| 3803 | set(handles.slider1,'Value',col)
|
---|
| 3804 | set(handles.colcode1,'String',num2str(col))
|
---|
| 3805 | end
|
---|
| 3806 | colcode2_Callback(hObject, eventdata, handles)
|
---|
| 3807 |
|
---|
| 3808 | %----------------------------------------------------------------
|
---|
| 3809 | %execute on return carriage on the edit box corresponding to slider 1
|
---|
| 3810 | %----------------------------------------------------------------
|
---|
| 3811 | function colcode1_Callback(hObject, eventdata, handles)
|
---|
| 3812 | % col=str2num(get(handles.colcode1,'String'));
|
---|
| 3813 | % set(handles.slider1,'Value',col)
|
---|
| 3814 | set_vec_col_bar(handles)
|
---|
| 3815 | update_plot(handles)
|
---|
| 3816 |
|
---|
| 3817 | %----------------------------------------------------------------
|
---|
| 3818 | %execute on return carriage on the edit box corresponding to slider 2
|
---|
| 3819 | %----------------------------------------------------------------
|
---|
| 3820 | function colcode2_Callback(hObject, eventdata, handles)
|
---|
| 3821 | % col=str2num(get(handles.colcode2,'String'));
|
---|
| 3822 | % set(handles.slider2,'Value',col)
|
---|
| 3823 | % slider2_Callback(hObject, eventdata, handles)
|
---|
| 3824 | set_vec_col_bar(handles)
|
---|
| 3825 | update_plot(handles)
|
---|
| 3826 | %------------------------------------------------------------
|
---|
| 3827 | %update the slider values after displaying vectors
|
---|
| 3828 | %--------------------------------------------------------
|
---|
| 3829 | % function slider_update(handles,auto,minC,colcode1,colcode2,maxC)
|
---|
| 3830 | % set(handles.slider1,'Min',minC)
|
---|
| 3831 | % set(handles.slider1,'Max',maxC)
|
---|
| 3832 | % set(handles.slider2,'Min',minC)
|
---|
| 3833 | % set(handles.slider2,'Max',maxC)
|
---|
| 3834 | % set(handles.min_title_vec,'String',num2str(minC))
|
---|
| 3835 | % set(handles.max_vec,'String',num2str(maxC))
|
---|
| 3836 | % if auto
|
---|
| 3837 | % set(handles.colcode1,'String',num2str(colcode1,3))%update display
|
---|
| 3838 | % set(handles.colcode2,'String',num2str(colcode2,3))
|
---|
| 3839 | % end
|
---|
| 3840 | % set(handles.slider1,'Value',colcode1)%update slider with constant display
|
---|
| 3841 | % set(handles.slider2,'Value',colcode2)
|
---|
| 3842 | % set_vec_col_bar(handles)
|
---|
| 3843 |
|
---|
| 3844 |
|
---|
| 3845 | %-------------------------------------------------------
|
---|
| 3846 | % --- Executes on button press in AutoVecColor.
|
---|
| 3847 | %-------------------------------------------------------
|
---|
| 3848 | function vec_col_bar_Callback(hObject, eventdata, handles)
|
---|
| 3849 | set_vec_col_bar(handles)
|
---|
| 3850 |
|
---|
| 3851 | % %--------------------------------------------
|
---|
| 3852 | % %update the display of color code for vectors
|
---|
| 3853 | % %--------------------------------------------
|
---|
| 3854 | % function set_vec_col_bar(handles)
|
---|
| 3855 | % %get the image of the color display button 'vec_col_bar' in pixels
|
---|
| 3856 | % uni=get(handles.vec_col_bar,'Unit');
|
---|
| 3857 | % set(handles.vec_col_bar,'Unit','pixel')
|
---|
| 3858 | % pos_vert=get(handles.vec_col_bar,'Position');
|
---|
| 3859 | % set(handles.vec_col_bar,'Unit','Normalized')
|
---|
| 3860 | % width=ceil(pos_vert(3));
|
---|
| 3861 | % height=ceil(pos_vert(4));
|
---|
| 3862 | % %get slider indications
|
---|
| 3863 | % colcode.min=get(handles.slider1,'Min');
|
---|
| 3864 | % colcode.max=get(handles.slider1,'Max');
|
---|
| 3865 | % colcode.colcode1=get(handles.slider1,'Value');
|
---|
| 3866 | % colcode.colcode2=get(handles.slider2,'Value');
|
---|
| 3867 | % colcode.option=get(handles.vec_col_bar,'Value');
|
---|
| 3868 | % colcode.auto=1;
|
---|
| 3869 | % list_code=get(handles.col_vec,'String');% list menu fields
|
---|
| 3870 | % index_code=get(handles.col_vec,'Value');% selected string index
|
---|
| 3871 | % colcode.CName= list_code{index_code(1)}; % selected field used for vector color
|
---|
| 3872 | % vec_C=colcode.min+(colcode.max-colcode.min)*[0.5:width-0.5]/width;%sample of vec_C values from min to max
|
---|
| 3873 | % [colorlist,col_vec]=set_col_vec(colcode,vec_C);
|
---|
| 3874 | % oneheight=ones(1,height);
|
---|
| 3875 | % A1=colorlist(col_vec,1)*oneheight;
|
---|
| 3876 | % A2=colorlist(col_vec,2)*oneheight;
|
---|
| 3877 | % A3=colorlist(col_vec,3)*oneheight;
|
---|
| 3878 | % A(:,:,1)=A1';
|
---|
| 3879 | % A(:,:,2)=A2';
|
---|
| 3880 | % A(:,:,3)=A3';
|
---|
| 3881 | % set(handles.vec_col_bar,'Cdata',A)
|
---|
| 3882 |
|
---|
| 3883 | %--------------------------------------------------------
|
---|
| 3884 | % --- Executes on button press in cal.
|
---|
| 3885 | function cal_Callback(hObject, eventdata, handles)
|
---|
| 3886 |
|
---|
| 3887 | huvmat=get(handles.cal,'parent');%handles of the uvmat interface
|
---|
| 3888 | UvData=get(huvmat,'UserData');%read UvData properties stored on the uvmat interface
|
---|
| 3889 | %reinitialize the edit interface associated with uvmat
|
---|
| 3890 | value=get(handles.cal,'Value');
|
---|
| 3891 | if value
|
---|
| 3892 | set(handles.cal,'BackgroundColor',[1 1 0])
|
---|
| 3893 | %suppress the other options if MENULINE is chosen
|
---|
| 3894 | set(handles.zoom,'Value',0)
|
---|
| 3895 | set(handles.zoom,'BackgroundColor',[0.7 0.7 0.7])
|
---|
| 3896 | set(handles.create,'Value',0)
|
---|
| 3897 | set(handles.create,'BackgroundColor',[0 1 0])
|
---|
| 3898 | set(handles.create,'enable','off')
|
---|
| 3899 | set(handles.edit_vect,'Value',0)
|
---|
| 3900 | set(handles.edit_vect,'enable','off')
|
---|
| 3901 | edit_vect_Callback(hObject, eventdata, handles)
|
---|
| 3902 | set(handles.edit,'Value',0)
|
---|
| 3903 | set(handles.edit,'BackgroundColor',[0.7 0.7 0.7])
|
---|
| 3904 | set(handles.edit,'enable','off')
|
---|
| 3905 | set(handles.list_object,'Value',1)
|
---|
| 3906 | % initiate display of GUI geometry_calib
|
---|
| 3907 | data=[]; %default
|
---|
| 3908 | if isfield(UvData,'CoordType')
|
---|
| 3909 | data.CoordType=UvData.CoordType;
|
---|
| 3910 | end
|
---|
| 3911 | %data.ParentButton=handles.cal; % transmit the handles of the calling button to the GUI geometry_calib
|
---|
| 3912 | pos=get(huvmat,'Position');
|
---|
| 3913 | pos(1)=pos(1)+pos(3)-0.311+0.04; %0.311= width of the geometry_calib interface (units relative to the srcreen)
|
---|
| 3914 | pos(2)=pos(2)-0.02;
|
---|
| 3915 | [FileName,RootPath,FileBase,FileIndices,FileExt,SubDir]=read_file_boxes(handles);
|
---|
| 3916 | % [filebase,num_i1,num_j1,num_i2,num_j2,Ext,NomType,SubDir]=read_input_file(handles);
|
---|
| 3917 | % [inputfile,idetect]=name_generator(filebase,num_i1,num_j1,Ext,NomType,1,num_i2,num_j2,SubDir);
|
---|
| 3918 | [UvData.hset_object,UvData.sethandles]=geometry_calib(handles,pos,FileName);% call the set_object interface
|
---|
| 3919 | pos_uvmat=get(huvmat,'Position');
|
---|
| 3920 | %pos_cal(1:2)=UvData.CalOrigin + pos_uvmat(1:2);
|
---|
| 3921 | if isfield(UvData,'CalOrigin')
|
---|
| 3922 | pos_cal(1)=pos_uvmat(1)+UvData.CalOrigin(1)*pos_uvmat(3);
|
---|
| 3923 | pos_cal(2)=pos_uvmat(2)+UvData.CalOrigin(2)*pos_uvmat(4);
|
---|
| 3924 | pos_cal(3:4)=UvData.CalSize .* pos_uvmat(3:4);
|
---|
| 3925 | set(UvData.hset_object,'Position',pos_cal)
|
---|
| 3926 | end
|
---|
| 3927 | UvData.MouseAction='calib';
|
---|
| 3928 | else
|
---|
| 3929 | UvData.MouseAction='none';
|
---|
| 3930 | hgeometry_calib=findobj(allchild(0),'Name','geometry_calib');
|
---|
| 3931 | % if ~isempty(hgeometry_calib)
|
---|
| 3932 | % answer=questdlg('close the GUI geometry-calib?');
|
---|
| 3933 | % if isequal(answer,'Yes')
|
---|
| 3934 | % delete(hgeometry_calib)
|
---|
| 3935 | % set(handles.cal,'BackgroundColor',[0 1 0])
|
---|
| 3936 | % else
|
---|
| 3937 | % set(handles.cal,'Value',1)% keep the calibration function active
|
---|
| 3938 | % end
|
---|
| 3939 | % end
|
---|
| 3940 | set(handles.edit_vect,'enable','on')
|
---|
| 3941 | set(handles.edit,'enable','on')
|
---|
| 3942 | set(handles.create,'enable','on')
|
---|
| 3943 | % set(handles.LINE,'enable','on')
|
---|
| 3944 | % set(handles.PATCH,'enable','on')
|
---|
| 3945 | % set(handles.PLANE,'enable','on')
|
---|
| 3946 | % set(handles.VOLUME,'enable','on')
|
---|
| 3947 | %set(handles.makemask,'enable','on')
|
---|
| 3948 | hh=findobj(handles.axes3,'Tag','calib_points');
|
---|
| 3949 | if ~isempty(hh)
|
---|
| 3950 | delete(hh)
|
---|
| 3951 | end
|
---|
| 3952 | hhh=findobj(handles.axes3,'Tag','calib_marker');
|
---|
| 3953 | if ~isempty(hhh)
|
---|
| 3954 | delete(hhh)
|
---|
| 3955 | end
|
---|
| 3956 | end
|
---|
| 3957 | set(huvmat,'UserData',UvData);
|
---|
| 3958 |
|
---|
| 3959 | %-------------------------------------------------------------
|
---|
[39] | 3960 | % --- Executes on selection change in transform_fct.
|
---|
| 3961 | function transform_fct_Callback(hObject, eventdata, handles)
|
---|
[2] | 3962 | %-------------------------------------------------------------
|
---|
[39] | 3963 | global nb_builtin
|
---|
| 3964 |
|
---|
| 3965 | huvmat=get(handles.transform_fct,'parent');
|
---|
| 3966 | menu=get(handles.transform_fct,'String');
|
---|
| 3967 | ind_coord=get(handles.transform_fct,'Value');
|
---|
[2] | 3968 | coord_option=menu{ind_coord};
|
---|
[39] | 3969 | list_transform=get(handles.transform_fct,'UserData');
|
---|
[40] | 3970 | ff=functions(list_transform{end});
|
---|
[2] | 3971 | if isequal(coord_option,'more...');
|
---|
| 3972 | coord_fct='';
|
---|
[39] | 3973 |
|
---|
| 3974 | % if exist(profil_perso,'file')
|
---|
| 3975 | % h=load (profil_perso);
|
---|
| 3976 | % if isfield(h,'transform_fct')
|
---|
| 3977 | % transform_fct=h.transform_fct;
|
---|
| 3978 | % end
|
---|
| 3979 | % end
|
---|
[2] | 3980 | prompt = {'Enter the name of the transform function'};
|
---|
| 3981 | dlg_title = 'user defined transform';
|
---|
| 3982 | num_lines= 1;
|
---|
| 3983 | [FileName, PathName, filterindex] = uigetfile( ...
|
---|
| 3984 | {'*.m', ' (*.m)';
|
---|
| 3985 | '*.m', '.m files '; ...
|
---|
| 3986 | '*.*', 'All Files (*.*)'}, ...
|
---|
[39] | 3987 | 'Pick a file', ff.file);
|
---|
[2] | 3988 | if isequal(PathName(end),'/')||isequal(PathName(end),'\')
|
---|
| 3989 | PathName(end)=[];
|
---|
| 3990 | end
|
---|
[39] | 3991 | transform_selected =fullfile(PathName,FileName);
|
---|
| 3992 | if ~exist(transform_selected,'file')
|
---|
| 3993 | % msgbox_uvmat('ERROR',['procesing fct ' transform_selected ' not found'])
|
---|
| 3994 | return
|
---|
| 3995 | end
|
---|
| 3996 | [ppp,transform,ext_fct]=fileparts(FileName);% removes extension .m
|
---|
| 3997 | if ~isequal(ext_fct,'.m')
|
---|
| 3998 | msgbox_uvmat('ERROR','a Matlab function .m must be introduced');
|
---|
| 3999 | return
|
---|
| 4000 | end
|
---|
| 4001 | menu=update_menu(handles.transform_fct,transform);%add the selected fct to the menu
|
---|
| 4002 | ind_coord=get(handles.transform_fct,'Value');
|
---|
| 4003 | addpath(PathName)
|
---|
| 4004 | list_transform{ind_coord}=str2func(transform);% create the function handle corresponding to the newly seleced function
|
---|
| 4005 | set(handles.transform_fct,'UserData',list_transform)
|
---|
| 4006 | rmpath(PathName)
|
---|
| 4007 | % save the new menu in the personal file 'uvmat_perso.mat'
|
---|
| 4008 | dir_perso=prefdir;%personal Matalb directory
|
---|
| 4009 | profil_perso=fullfile(dir_perso,'uvmat_perso.mat');
|
---|
| 4010 | if exist(profil_perso,'file')
|
---|
| 4011 | for ilist=nb_builtin+1:numel(list_transform)
|
---|
| 4012 | ff=functions(list_transform{ilist});
|
---|
| 4013 | transform_fct{ilist-nb_builtin}=ff.file;
|
---|
| 4014 | end
|
---|
| 4015 | save (profil_perso,'transform_fct','-append'); %store the root name for future opening of uvmat
|
---|
| 4016 | end
|
---|
[2] | 4017 | end
|
---|
| 4018 |
|
---|
| 4019 | %check the current path to the selected function
|
---|
[40] | 4020 | if isa(list_transform{ind_coord},'function_handle')
|
---|
| 4021 | func=functions(list_transform{ind_coord});
|
---|
| 4022 | set(handles.path_transform,'String',fileparts(func.file)); %show the path to the senlected function
|
---|
| 4023 | else
|
---|
| 4024 | set(handles.path_transform,'String','')
|
---|
| 4025 | end
|
---|
[38] | 4026 | %CurrentPath=fileparts(which(coord_option));
|
---|
| 4027 | % if ~isequal(PathName,CurrentPath)
|
---|
| 4028 | % addpath(PathName)
|
---|
| 4029 | % errormsg=check_functions;
|
---|
| 4030 | % msgbox_uvmat('WARNING',[['path ' PathName ' added to the current Matlab pathes'];errormsg])
|
---|
| 4031 | % end
|
---|
| 4032 | %set(handles.path_transform,'String',fullfile(PathName,' ')); %show the path to the senlected function
|
---|
[2] | 4033 | set(handles.FixedLimits,'Value',0)
|
---|
| 4034 | set(handles.FixedLimits,'BackgroundColor',[0.7 0.7 0.7])
|
---|
| 4035 |
|
---|
| 4036 | UvData=get(huvmat,'UserData');
|
---|
| 4037 |
|
---|
| 4038 | %delete drawn objects
|
---|
| 4039 | hother=findobj('Tag','proj_object');%find all the proj objects
|
---|
| 4040 | for iobj=1:length(hother)
|
---|
| 4041 | delete_object(hother(iobj))
|
---|
| 4042 | end
|
---|
| 4043 | hother=findobj('Tag','DeformPoint');%find all the proj objects
|
---|
| 4044 | for iobj=1:length(hother)
|
---|
| 4045 | delete_object(hother(iobj))
|
---|
| 4046 | end
|
---|
| 4047 | hh=findobj('Tag','calib_points');
|
---|
| 4048 | if ~isempty(hh)
|
---|
| 4049 | delete(hh)
|
---|
| 4050 | end
|
---|
| 4051 | hhh=findobj('Tag','calib_marker');
|
---|
| 4052 | if ~isempty(hhh)
|
---|
| 4053 | delete(hhh)
|
---|
| 4054 | end
|
---|
| 4055 | if isfield(UvData,'Object')
|
---|
| 4056 | nbobject=length(UvData.Object);
|
---|
| 4057 | UvData.Object([2:nbobject])=[];
|
---|
| 4058 | end
|
---|
| 4059 |
|
---|
| 4060 | %delete mask if it is displayed
|
---|
| 4061 | if isequal(get(handles.mask_test,'Value'),1)%if the mask option is on
|
---|
| 4062 | UvData=rmfield(UvData,'MaskName'); %will impose mask refresh
|
---|
| 4063 | end
|
---|
| 4064 | set(huvmat,'UserData',UvData)
|
---|
| 4065 | run0_Callback(hObject, eventdata, handles)
|
---|
| 4066 |
|
---|
| 4067 | %--------------------------------------------
|
---|
| 4068 | function histo1_menu_Callback(hObject, eventdata, handles)
|
---|
| 4069 | %--------------------------------------------
|
---|
| 4070 | %plot first histo
|
---|
| 4071 | huvmat=get(handles.histo1_menu,'parent');
|
---|
| 4072 | histo_menu=get(handles.histo1_menu,'String');
|
---|
| 4073 | histo_value=get(handles.histo1_menu,'Value');
|
---|
| 4074 | FieldName=histo_menu{histo_value};
|
---|
| 4075 | UvData=get(huvmat,'UserData');
|
---|
| 4076 | update_histo(handles.histo_u,huvmat,FieldName)
|
---|
| 4077 |
|
---|
| 4078 | %----------------------------------------------
|
---|
| 4079 | function histo2_menu_Callback(hObject, eventdata, handles)
|
---|
| 4080 | %----------------------------------------------
|
---|
| 4081 | %plot second histo
|
---|
| 4082 | huvmat=get(handles.histo2_menu,'parent');
|
---|
| 4083 | histo_menu=get(handles.histo2_menu,'String');
|
---|
| 4084 | histo_value=get(handles.histo2_menu,'Value');
|
---|
| 4085 | FieldName=histo_menu{histo_value};
|
---|
| 4086 | UvData=get(huvmat,'UserData');
|
---|
| 4087 | update_histo(handles.histo_v,huvmat,FieldName)
|
---|
| 4088 |
|
---|
| 4089 |
|
---|
| 4090 | %--------------------------------------------
|
---|
| 4091 | %read the field .Fieldname stored in UvData and plot its histogram
|
---|
| 4092 | function update_histo(haxes,huvmat,FieldName)
|
---|
| 4093 | UvData=get(huvmat,'UserData');
|
---|
| 4094 |
|
---|
| 4095 | if ~isfield(UvData.Field,FieldName)
|
---|
| 4096 | msgbox_uvmat('ERROR',['no field ' FieldName ' for histogram'])
|
---|
| 4097 | return
|
---|
| 4098 | end
|
---|
| 4099 | Field=UvData.Field;
|
---|
| 4100 | FieldHisto=eval(['Field.' FieldName]);
|
---|
| 4101 | if isfield(Field,'FF') & ~isempty(Field.FF) & isequal(size(Field.FF),size(FieldHisto))
|
---|
| 4102 | indsel=find(Field.FF==0);%find values marked as false
|
---|
| 4103 | if ~isempty(indsel)
|
---|
| 4104 | FieldHisto=FieldHisto(indsel);
|
---|
| 4105 | end
|
---|
| 4106 | end
|
---|
| 4107 | if isempty(Field)
|
---|
| 4108 | msgbox_uvmat('ERROR',['empty field ' FieldName])
|
---|
| 4109 | else
|
---|
| 4110 | nxy=size(FieldHisto);
|
---|
| 4111 | Amin=double(min(min(min(FieldHisto))));%min of image
|
---|
| 4112 | Amax=double(max(max(max(FieldHisto))));%max of image
|
---|
| 4113 | if isequal(Amin,Amax)
|
---|
| 4114 | Histo.Txt=['uniform field =' num2str(Amin)];
|
---|
| 4115 | else
|
---|
| 4116 | Histo.ListVarName={FieldName,'histo'};
|
---|
| 4117 | if numel(nxy)==2
|
---|
| 4118 | Histo.VarDimName={FieldName,FieldName}; %dimensions for the histogram
|
---|
| 4119 | else %color images
|
---|
| 4120 | Histo.VarDimName={FieldName,{FieldName,'rgb'}}; %dimensions for the histogram
|
---|
| 4121 | end
|
---|
| 4122 | %unit
|
---|
| 4123 | units=[]; %default
|
---|
| 4124 | for ivar=1:numel(Field.ListVarName)
|
---|
| 4125 | if strcmp(Field.ListVarName{ivar},FieldName)
|
---|
| 4126 | if isfield(Field,'VarAttribute') && numel(Field.VarAttribute)>=ivar && isfield(Field.VarAttribute{ivar},'units')
|
---|
| 4127 | units=Field.VarAttribute{ivar}.units;
|
---|
| 4128 | break
|
---|
| 4129 | end
|
---|
| 4130 | end
|
---|
| 4131 | end
|
---|
| 4132 | if ~isempty(units)
|
---|
| 4133 | Histo.VarAttribute{1}.units=units;
|
---|
| 4134 | end
|
---|
| 4135 | eval(['Histo.' FieldName '=linspace(Amin,Amax,50);'])%absissa values for histo
|
---|
| 4136 | for col=1:size(FieldHisto,3)
|
---|
| 4137 | B=FieldHisto(:,:,col);
|
---|
| 4138 | C=reshape(double(B),1,nxy(1)*nxy(2));% reshape in a vector
|
---|
| 4139 | eval(['Histo.histo(:,col)=hist(C, Histo.' FieldName ');']); %calculate histogram
|
---|
| 4140 | end
|
---|
| 4141 | set(haxes,'XLimMode','auto')%reset auto mode (after zoom effect)
|
---|
| 4142 | set(haxes,'YLimMode','auto')
|
---|
| 4143 | plot_field(Histo,haxes);
|
---|
| 4144 | end
|
---|
| 4145 | end
|
---|
| 4146 |
|
---|
| 4147 |
|
---|
| 4148 |
|
---|
| 4149 | %------------------------------------------------
|
---|
| 4150 | %CALLBACKS FOR PLOTTING PARAMETERS
|
---|
| 4151 | %-------------------------------------------------
|
---|
| 4152 |
|
---|
| 4153 | %-----------------------------------------------------------------
|
---|
| 4154 | function MinA_Callback(hObject, eventdata, handles)
|
---|
| 4155 | %------------------------------------------
|
---|
| 4156 | set(handles.AutoScal,'Value',1) %suppress auto mode
|
---|
| 4157 | set(handles.AutoScal,'BackgroundColor',[1 1 0])
|
---|
| 4158 | update_plot(handles)
|
---|
| 4159 |
|
---|
| 4160 | %-----------------------------------------------------------------
|
---|
| 4161 | function MaxA_Callback(hObject, eventdata, handles)
|
---|
| 4162 | %--------------------------------------------
|
---|
| 4163 | set(handles.AutoScal,'Value',1) %suppress auto mode
|
---|
| 4164 | set(handles.AutoScal,'BackgroundColor',[1 1 0])
|
---|
| 4165 | update_plot(handles)
|
---|
| 4166 |
|
---|
| 4167 | %-----------------------------------------------
|
---|
| 4168 | function AutoScal_Callback(hObject, eventdata, handles)
|
---|
| 4169 | %--------------------------------------------
|
---|
| 4170 | test=get(handles.AutoScal,'Value');
|
---|
| 4171 | if test
|
---|
| 4172 | set(handles.AutoScal,'BackgroundColor',[1 1 0])
|
---|
| 4173 | else
|
---|
| 4174 | set(handles.AutoScal,'BackgroundColor',[0.7 0.7 0.7])
|
---|
| 4175 | update_plot(handles);
|
---|
| 4176 | % set(handles.MinA,'String',num2str(ScalOut.MinA,3))
|
---|
| 4177 | % set(handles.MaxA,'String',num2str(ScalOut.MaxA,3))
|
---|
| 4178 | end
|
---|
| 4179 |
|
---|
| 4180 | %-------------------------------------------------------------------
|
---|
| 4181 | function BW_Callback(hObject, eventdata, handles)
|
---|
| 4182 | %-------------------------------------------------------------------
|
---|
| 4183 | update_plot(handles)
|
---|
| 4184 |
|
---|
| 4185 | %-------------------------------------------------------------------
|
---|
| 4186 | function Contours_Callback(hObject, eventdata, handles)
|
---|
| 4187 | %-------------------------------------------------------------------
|
---|
| 4188 | val=get(handles.Contours,'Value');
|
---|
| 4189 | if val==2
|
---|
| 4190 | set(handles.interval_txt,'Visible','on')
|
---|
| 4191 | set(handles.IncrA,'Visible','on')
|
---|
| 4192 | else
|
---|
| 4193 | set(handles.interval_txt,'Visible','off')
|
---|
| 4194 | set(handles.IncrA,'Visible','off')
|
---|
| 4195 | end
|
---|
| 4196 | update_plot(handles)
|
---|
| 4197 |
|
---|
| 4198 | %-------------------------------------------------------------------
|
---|
| 4199 | function IncrA_Callback(hObject, eventdata, handles)
|
---|
| 4200 | %-------------------------------------------------------------------
|
---|
| 4201 | update_plot(handles)
|
---|
| 4202 |
|
---|
| 4203 | %-------------------------------------------------------------------
|
---|
| 4204 | function HideWarning_Callback(hObject, eventdata, handles)
|
---|
| 4205 | %-------------------------------------------------------------------
|
---|
| 4206 | update_plot(handles)
|
---|
| 4207 |
|
---|
| 4208 | %-------------------------------------------------------------------
|
---|
| 4209 | function HideFalse_Callback(hObject, eventdata, handles)
|
---|
| 4210 | %-------------------------------------------------------------------
|
---|
| 4211 | update_plot(handles)
|
---|
| 4212 |
|
---|
| 4213 | %-------------------------------------------------------------------
|
---|
| 4214 | function VecScale_Callback(hObject, eventdata, handles)
|
---|
| 4215 | %-------------------------------------------------------------------
|
---|
| 4216 | set(handles.AutoVec,'Value',1);
|
---|
| 4217 | set(handles.AutoVec,'BackgroundColor',[1 1 0])
|
---|
| 4218 | update_plot(handles)
|
---|
| 4219 |
|
---|
| 4220 | %-------------------------------------------------------------------
|
---|
| 4221 | function AutoVec_Callback(hObject, eventdata, handles)
|
---|
| 4222 | %-------------------------------------------------------------------
|
---|
| 4223 | test=get(handles.AutoVec,'Value');
|
---|
| 4224 | if test
|
---|
| 4225 | set(handles.AutoVec,'BackgroundColor',[1 1 0])
|
---|
| 4226 | else
|
---|
| 4227 | update_plot(handles);
|
---|
| 4228 | %set(handles.VecScale,'String',num2str(ScalOut.VecScale,3))
|
---|
| 4229 | set(handles.AutoVec,'BackgroundColor',[0.7 0.7 0.7])
|
---|
| 4230 | end
|
---|
| 4231 |
|
---|
| 4232 | %-------------------------------------------------------
|
---|
| 4233 | % --- Executes on selection change in decimate4 (nb_vec/4).
|
---|
| 4234 | %-------------------------------------------------------
|
---|
| 4235 | function decimate4_Callback(hObject, eventdata, handles)
|
---|
| 4236 | update_plot(handles)
|
---|
| 4237 |
|
---|
| 4238 |
|
---|
| 4239 | %-------------------------------------------------------
|
---|
| 4240 | % --- Executes on selection change in color_code menu
|
---|
| 4241 | %-------------------------------------------------------
|
---|
| 4242 | function color_code_Callback(hObject, eventdata, handles)
|
---|
| 4243 | set_vec_col_bar(handles)
|
---|
| 4244 | update_plot(handles);
|
---|
| 4245 |
|
---|
| 4246 | %-------------------------------------------------------
|
---|
| 4247 | % --- Executes on button press in AutoVecColor.
|
---|
| 4248 | %-------------------------------------------------------
|
---|
| 4249 | function AutoVecColor_Callback(hObject, eventdata, handles)
|
---|
| 4250 | test=get(handles.AutoVecColor,'Value');
|
---|
| 4251 | if test
|
---|
| 4252 | set(handles.AutoVecColor,'BackgroundColor',[1 1 0])
|
---|
| 4253 | else
|
---|
| 4254 | update_plot(handles);
|
---|
| 4255 | %set(handles.VecScale,'String',num2str(ScalOut.VecScale,3))
|
---|
| 4256 | set(handles.AutoVecColor,'BackgroundColor',[0.7 0.7 0.7])
|
---|
| 4257 | end
|
---|
| 4258 | %set_vec_col_bar(handles)
|
---|
| 4259 |
|
---|
| 4260 | %-------------------------------------------------------
|
---|
| 4261 | % --- Executes on selection change in max_vec.
|
---|
| 4262 | %-------------------------------------------------------
|
---|
| 4263 | function min_vec_Callback(hObject, eventdata, handles)
|
---|
| 4264 | max_vec_Callback(hObject, eventdata, handles)
|
---|
| 4265 |
|
---|
| 4266 | % --- Executes on selection change in max_vec.
|
---|
| 4267 | function max_vec_Callback(hObject, eventdata, handles)
|
---|
| 4268 | set(handles.AutoVecColor,'Value',1)
|
---|
| 4269 | AutoVecColor_Callback(hObject, eventdata, handles)
|
---|
| 4270 | min_val=str2num(get(handles.min_vec,'String'));
|
---|
| 4271 | max_val=str2num(get(handles.max_vec,'String'));
|
---|
| 4272 | slider1=get(handles.slider1,'Value');
|
---|
| 4273 | slider2=get(handles.slider2,'Value');
|
---|
| 4274 | colcode1=min_val+(max_val-min_val)*slider1;
|
---|
| 4275 | colcode2=min_val+(max_val-min_val)*slider2;
|
---|
| 4276 | set(handles.colcode1,'String',num2str(colcode1))
|
---|
| 4277 | set(handles.colcode2,'String',num2str(colcode2))
|
---|
| 4278 | update_plot(handles);
|
---|
| 4279 |
|
---|
| 4280 | %-------------------------------------------------------------------
|
---|
| 4281 | %update the display of color code for vectors
|
---|
| 4282 | function set_vec_col_bar(handles)
|
---|
| 4283 | %-------------------------------------------------------------------
|
---|
| 4284 | %get the image of the color display button 'vec_col_bar' in pixels
|
---|
| 4285 | set(handles.vec_col_bar,'Unit','pixel');
|
---|
| 4286 | pos_vert=get(handles.vec_col_bar,'Position');
|
---|
| 4287 | set(handles.vec_col_bar,'Unit','Normalized');
|
---|
| 4288 | width=ceil(pos_vert(3));
|
---|
| 4289 | height=ceil(pos_vert(4));
|
---|
| 4290 |
|
---|
| 4291 | %get slider indications
|
---|
| 4292 | list=get(handles.color_code,'String');
|
---|
| 4293 | ichoice=get(handles.color_code,'Value');
|
---|
| 4294 | colcode.ColorCode=list{ichoice};
|
---|
| 4295 | colcode.MinC=str2num(get(handles.min_vec,'String'));
|
---|
| 4296 | colcode.MaxC=str2num(get(handles.max_vec,'String'));
|
---|
| 4297 | test3color=strcmp(colcode.ColorCode,'rgb') || strcmp(colcode.ColorCode,'bgr');
|
---|
| 4298 | if test3color
|
---|
| 4299 | colcode.colcode1=str2num(get(handles.colcode1,'String'));
|
---|
| 4300 | colcode.colcode2=str2num(get(handles.colcode2,'String'));
|
---|
| 4301 | end
|
---|
| 4302 | % colcode.option=get(handles.vec_col_bar,'Value');
|
---|
| 4303 | colcode.FixedCbounds=0;
|
---|
| 4304 | % list_code=get(handles.col_vec,'String');% list menu fields
|
---|
| 4305 | % index_code=get(handles.col_vec,'Value');% selected string index
|
---|
| 4306 | % colcode.CName= list_code{index_code(1)}; % selected field used for vector color
|
---|
| 4307 | colcode.FixedCbounds=1;
|
---|
| 4308 | vec_C=colcode.MinC+(colcode.MaxC-colcode.MinC)*[0.5:width-0.5]/width;%sample of vec_C values from min to max
|
---|
| 4309 | [colorlist,col_vec]=set_col_vec(colcode,vec_C);
|
---|
| 4310 | oneheight=ones(1,height);
|
---|
| 4311 | A1=colorlist(col_vec,1)*oneheight;
|
---|
| 4312 | A2=colorlist(col_vec,2)*oneheight;
|
---|
| 4313 | A3=colorlist(col_vec,3)*oneheight;
|
---|
| 4314 | A(:,:,1)=A1';
|
---|
| 4315 | A(:,:,2)=A2';
|
---|
| 4316 | A(:,:,3)=A3';
|
---|
| 4317 | set(handles.vec_col_bar,'Cdata',A)
|
---|
| 4318 |
|
---|
| 4319 |
|
---|
| 4320 | %-------------------------------------------------------------------
|
---|
| 4321 | function [PlotType,ScalOut]=update_plot(handles)
|
---|
| 4322 | %-------------------------------------------------------------------
|
---|
| 4323 | haxes= handles.axes3;
|
---|
| 4324 | AxeData=get(haxes,'UserData');
|
---|
| 4325 | PlotParam=read_plot_param(handles);
|
---|
| 4326 | [PlotType,PlotParamOut]= plot_field(AxeData,haxes,PlotParam,1);
|
---|
| 4327 | write_plot_param(handles,PlotParamOut); %update the auto plot parameters
|
---|
| 4328 |
|
---|
| 4329 | %-------------------------------------------------------------------
|
---|
| 4330 | % --- Executes on button press in grid.
|
---|
| 4331 | function grid_Callback(hObject, eventdata, handles)
|
---|
| 4332 | %-------------------------------------------------------------------
|
---|
| 4333 | huvmat=get(handles.create,'parent');
|
---|
| 4334 | UvData=get(huvmat,'UserData');%read UvData properties stored on the uvmat interface
|
---|
| 4335 |
|
---|
| 4336 | %suppress the other options if grid is chosen
|
---|
| 4337 | set(handles.create,'Value',0)
|
---|
| 4338 | set(handles.create,'BackgroundColor',[0 1 0])
|
---|
| 4339 | set(handles.edit_vect,'Value',0)
|
---|
| 4340 | edit_vect_Callback(hObject, eventdata, handles)
|
---|
| 4341 | set(handles.edit,'BackgroundColor',[0.7 0.7 0.7])
|
---|
| 4342 | set(handles.edit_vect,'Value',0)
|
---|
| 4343 | edit_vect_Callback(hObject, eventdata, handles)
|
---|
| 4344 | set(handles.edit,'BackgroundColor',[0.7 0.7 0.7])
|
---|
| 4345 | set(handles.list_object,'Value',1)
|
---|
| 4346 | set(handles.cal,'Value',0)
|
---|
| 4347 | set(handles.cal,'BackgroundColor',[0 1 0])
|
---|
| 4348 |
|
---|
| 4349 | %prepare display of the set_grid GUI
|
---|
| 4350 | data.fixedtitle=1;
|
---|
| 4351 | FileName=read_file_boxes(handles);
|
---|
| 4352 | [hset_object,UvData.sethandles]=set_grid(FileName);% call the set_object interface
|
---|
| 4353 | set(huvmat,'UserData',UvData);
|
---|
| 4354 |
|
---|
| 4355 |
|
---|
| 4356 | %-------------------------------------------------------------------
|
---|
| 4357 | % --- Executes on selection change in edit.
|
---|
| 4358 | function edit_Callback(hObject, eventdata, handles)
|
---|
| 4359 | %-------------------------------------------------------------------
|
---|
| 4360 | huvmat=get(handles.list_object,'parent');
|
---|
| 4361 | UvData=get(huvmat,'UserData');%read UvData properties stored on the uvmat interface
|
---|
| 4362 | test=get(handles.edit,'Value');
|
---|
| 4363 | if test
|
---|
| 4364 | UvData.MouseAction='edit_object';
|
---|
| 4365 | set(handles.edit,'BackgroundColor',[1,1,0])
|
---|
| 4366 | %suppress the other options
|
---|
| 4367 | set(handles.zoom,'Value',0)
|
---|
| 4368 | zoom_Callback(hObject, eventdata, handles)
|
---|
| 4369 | set(handles.create,'Value',0)
|
---|
| 4370 | set(handles.create,'BackgroundColor',[0 1 0])
|
---|
| 4371 | % set(handles.LINE,'Value',0)
|
---|
| 4372 | % set(handles.LINE,'BackgroundColor',[0 1 0])
|
---|
| 4373 | % set(handles.PATCH,'Value',0)
|
---|
| 4374 | % set(handles.PATCH,'BackgroundColor',[0 1 0])
|
---|
| 4375 | % set(handles.PLANE,'Value',0)
|
---|
| 4376 | % set(handles.PLANE,'BackgroundColor',[0 1 0])%put activated buttons to yellow
|
---|
| 4377 | % set(handles.VOLUME,'Value',0)
|
---|
| 4378 | % set(handles.VOLUME,'BackgroundColor',[0 1 0])
|
---|
| 4379 | set(handles.edit_vect,'Value',0)
|
---|
| 4380 | edit_vect_Callback(hObject, eventdata, handles)
|
---|
| 4381 | set(handles.cal,'Value',0)
|
---|
| 4382 | set(handles.cal,'BackgroundColor',[0 1 0])
|
---|
| 4383 | %set(handles.grid,'Value',0)
|
---|
| 4384 | %set(handles.grid,'BackgroundColor',[0 1 0])
|
---|
| 4385 | list_object_Callback(hObject, eventdata, handles)
|
---|
| 4386 | else
|
---|
| 4387 | UvData.MouseAction='none';
|
---|
| 4388 | set(handles.edit,'BackgroundColor',[0.7,0.7,0.7])
|
---|
| 4389 | end
|
---|
| 4390 | set(huvmat,'UserData',UvData);
|
---|
| 4391 |
|
---|
| 4392 | %--------------------------------------------------------
|
---|
| 4393 | % --- Executes on selection change in list_object.
|
---|
| 4394 | %--------------------------------------------------------
|
---|
| 4395 | function list_object_Callback(hObject, eventdata, handles)
|
---|
| 4396 | huvmat=get(handles.list_object,'parent');
|
---|
| 4397 | UvData=get(huvmat,'UserData');%read UvData properties stored on the uvmat interface
|
---|
| 4398 | list_str=get(handles.list_object,'String');
|
---|
| 4399 | IndexObj=get(handles.list_object,'Value');
|
---|
| 4400 |
|
---|
| 4401 | if ~(length(UvData.Object)>=IndexObj);
|
---|
| 4402 | return
|
---|
| 4403 | end
|
---|
| 4404 | ObjectData=UvData.Object{IndexObj};
|
---|
| 4405 | ObjectData.desable_open=1; % desable the OPEN option in the set_object GUI (editing mode)
|
---|
| 4406 | if isequal(get(handles.edit,'Value'),0)
|
---|
| 4407 | ObjectData.desable_plot=1; % desable the PLOT option in the set_object GUI (editing mode
|
---|
| 4408 | end
|
---|
| 4409 | PlotHandles=get_plot_handles(handles);%get the handles of the interface elements setting the plotting parameters
|
---|
| 4410 | ZBounds=0; % default
|
---|
| 4411 | if isfield(UvData,'ZMin') && isfield(UvData,'ZMax')
|
---|
| 4412 | ZBounds(1)=UvData.ZMin; %minimum for the Z slider
|
---|
| 4413 | ZBounds(2)=UvData.ZMax;%maximum for the Z slider
|
---|
| 4414 | end
|
---|
| 4415 | AxeData.hset_object=set_object(ObjectData,PlotHandles,ZBounds);% call the set_object interface,
|
---|
| 4416 | pos_uvmat=get(huvmat,'Position');
|
---|
| 4417 | if isfield(UvData,'SetObjectOrigin')
|
---|
| 4418 | pos_set_object(1:2)=UvData.SetObjectOrigin + pos_uvmat(1:2);
|
---|
| 4419 | pos_set_object(3:4)=UvData.SetObjectSize .* pos_uvmat(3:4);
|
---|
| 4420 | set(AxeData.hset_object,'Position',pos_set_object)
|
---|
| 4421 | end
|
---|
| 4422 | hother=findobj('Tag','proj_object');%find all the proj objects
|
---|
| 4423 | for iobj=1:length(hother)
|
---|
| 4424 | if isequal(get(hother(iobj),'Type'),'rectangle')|isequal(get(hother(iobj),'Type'),'patch')
|
---|
| 4425 | set(hother(iobj),'EdgeColor','b')
|
---|
| 4426 | if isequal(get(hother(iobj),'FaceColor'),'m')
|
---|
| 4427 | set(hother(iobj),'FaceColor','b')
|
---|
| 4428 | end
|
---|
| 4429 | elseif isequal(get(hother(iobj),'Type'),'image')
|
---|
| 4430 | Acolor=get(hother(iobj),'CData');
|
---|
| 4431 | Acolor(:,:,1)=zeros(size(Acolor,1),size(Acolor,2));
|
---|
| 4432 | set(hother(iobj),'CData',Acolor);
|
---|
| 4433 | else
|
---|
| 4434 | set(hother(iobj),'Color','b')
|
---|
| 4435 | end
|
---|
| 4436 | set(hother(iobj),'Selected','off')
|
---|
| 4437 | end
|
---|
| 4438 | hother=findobj('Tag','DeformPoint');
|
---|
| 4439 | set(hother,'Color','b');
|
---|
| 4440 | set(hother,'Selected','off')
|
---|
| 4441 | if isfield(ObjectData,'HandlesDisplay')
|
---|
| 4442 | for iview=1:length(ObjectData.HandlesDisplay)
|
---|
| 4443 | if ishandle(ObjectData.HandlesDisplay(iview))
|
---|
| 4444 | uistack(ObjectData.HandlesDisplay(iview),'top')
|
---|
| 4445 | linetype=get(ObjectData.HandlesDisplay(iview),'Type');
|
---|
| 4446 | if isequal(linetype,'line')
|
---|
| 4447 | set(ObjectData.HandlesDisplay(iview),'Color','m'); %set the selected object to magenta color
|
---|
| 4448 | elseif isequal(linetype,'rectangle')
|
---|
| 4449 | set(ObjectData.HandlesDisplay(iview),'EdgeColor','m'); %set the selected object to magenta color
|
---|
| 4450 | elseif isequal(linetype,'patch')
|
---|
| 4451 | set(ObjectData.HandlesDisplay(iview),'FaceColor','m'); %set the selected object to magenta color
|
---|
| 4452 | end
|
---|
| 4453 | SubObjectData=get(ObjectData.HandlesDisplay(iview),'UserData');
|
---|
| 4454 | if isfield(SubObjectData,'SubObject')& ishandle(SubObjectData.SubObject)
|
---|
| 4455 | uistack(SubObjectData.SubObject,'top')
|
---|
| 4456 | for iobj=1:length(SubObjectData.SubObject)
|
---|
| 4457 | hsub=SubObjectData.SubObject(iobj);
|
---|
| 4458 | if isequal(get(hsub,'Type'),'rectangle')
|
---|
| 4459 | set(hsub,'EdgeColor','m'); %set the selected object to magenta color
|
---|
| 4460 | elseif isequal(get(hsub,'Type'),'image')
|
---|
| 4461 | Acolor=get(hsub,'CData');
|
---|
| 4462 | Acolor(:,:,1)=Acolor(:,:,3);
|
---|
| 4463 | set(hsub,'CData',Acolor);
|
---|
| 4464 | else
|
---|
| 4465 | set(hsub,'Color','m')
|
---|
| 4466 | end
|
---|
| 4467 | end
|
---|
| 4468 | end
|
---|
| 4469 | if isfield(SubObjectData,'DeformPoint')& ishandle(SubObjectData.DeformPoint)
|
---|
| 4470 | set(SubObjectData.DeformPoint,'Color','m')
|
---|
| 4471 | end
|
---|
| 4472 | end
|
---|
| 4473 | end
|
---|
| 4474 | end
|
---|
| 4475 |
|
---|
| 4476 | %------------------------------------------------------
|
---|
| 4477 | % --- Executes on button press in Menu/Export/field in workspace.
|
---|
| 4478 | %------------------------------------------------------
|
---|
| 4479 | function MenuExportField_Callback(hObject, eventdata, handles)
|
---|
| 4480 |
|
---|
| 4481 | global CurData
|
---|
| 4482 | huvmat=get(handles.RootPath,'parent');
|
---|
| 4483 | CurData=get(huvmat,'UserData');
|
---|
| 4484 | evalin('base','global CurData')%make CurData global in the workspace
|
---|
| 4485 | display(['UserData of uvmat :'])
|
---|
| 4486 | evalin('base','CurData') %display CurData in the workspace
|
---|
| 4487 | commandwindow;
|
---|
| 4488 |
|
---|
| 4489 | %------------------------------------------------------
|
---|
| 4490 | % --- Executes on button press in Menu/Export/extract figure.
|
---|
| 4491 | %------------------------------------------------------
|
---|
| 4492 | function MenuExport_plot_Callback(hObject, eventdata, handles)
|
---|
| 4493 | huvmat=get(handles.MenuExport_plot,'parent');
|
---|
| 4494 | UvData=get(huvmat,'UserData');
|
---|
| 4495 | hfig=figure;
|
---|
| 4496 | newaxes=copyobj(handles.axes3,hfig);
|
---|
| 4497 | map=colormap(handles.axes3);
|
---|
| 4498 | colormap(map);%transmit the current colormap to the zoom fig
|
---|
| 4499 | colorbar
|
---|
| 4500 |
|
---|
| 4501 |
|
---|
| 4502 | % --------------------------------------------------------------------
|
---|
| 4503 | function Insert_Callback(hObject, eventdata, handles)
|
---|
| 4504 |
|
---|
| 4505 |
|
---|
| 4506 | % --------------------------------------------------------------------
|
---|
| 4507 | function MenuRun_Callback(hObject, eventdata, handles)
|
---|
| 4508 | % --------------------------------------------------------------------
|
---|
| 4509 |
|
---|
| 4510 | % --------------------------------------------------------------------
|
---|
| 4511 | function MenuHelp_Callback(hObject, eventdata, handles)
|
---|
| 4512 | % --------------------------------------------------------------------
|
---|
| 4513 | path_to_uvmat=which ('uvmat');% check the path of uvmat
|
---|
| 4514 | pathelp=fileparts(path_to_uvmat);
|
---|
[36] | 4515 | helpfile=fullfile(pathelp,'uvmat_doc','uvmat_doc.html');
|
---|
| 4516 | 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] | 4517 | else
|
---|
[36] | 4518 | addpath (fullfile(pathelp,'uvmat_doc'))
|
---|
[2] | 4519 | web(helpfile);
|
---|
| 4520 | end
|
---|
| 4521 |
|
---|
| 4522 | % --------------------------------------------------------------------
|
---|
| 4523 | function MenuOpen_Callback(hObject, eventdata, handles)
|
---|
| 4524 | % --------------------------------------------------------------------
|
---|
| 4525 | % --------------------------------------------------------------------
|
---|
| 4526 | function MenuOpen_1_Callback(hObject, eventdata, handles)
|
---|
| 4527 | % --------------------------------------------------------------------
|
---|
| 4528 | % --------------------------------------------------------------------
|
---|
| 4529 | function MenuExport_Callback(hObject, eventdata, handles)
|
---|
| 4530 | % --------------------------------------------------------------------
|
---|
| 4531 |
|
---|
| 4532 | % --------------------------------------------------------------------
|
---|
| 4533 | function MenuExportMovie_Callback(hObject, eventdata, handles)
|
---|
| 4534 | % --------------------------------------------------------------------
|
---|
| 4535 | set(handles.MenuExportMovie,'BusyAction','queue')% activate the button
|
---|
| 4536 | huvmat=get(handles.run0,'parent');
|
---|
| 4537 | UvData=get(huvmat,'UserData');
|
---|
| 4538 | [xx,xx,FileBase]=read_file_boxes(handles);
|
---|
| 4539 | %read the current input file name
|
---|
| 4540 | 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)'};
|
---|
| 4541 | dlg_title = 'select properties of the output avi movie';
|
---|
| 4542 | num_lines= 1;
|
---|
| 4543 | nbfield_cell=get(handles.last_i,'String');
|
---|
| 4544 | def = {[FileBase '_out.avi'];'10';'1';'[0.03 0.05 0.95 0.92]';'10'};
|
---|
| 4545 | answer = inputdlg(prompt,dlg_title,num_lines,def,'on');
|
---|
| 4546 | aviname=answer{1};
|
---|
| 4547 | fps=str2num(answer{2});
|
---|
| 4548 | % check for existing file with output name aviname
|
---|
| 4549 | if exist(aviname,'file')
|
---|
| 4550 | backup=aviname;
|
---|
| 4551 | testexist=2;
|
---|
| 4552 | while testexist==2
|
---|
| 4553 | backup=[backup '~'];
|
---|
| 4554 | testexist=exist(backup,'file');
|
---|
| 4555 | end
|
---|
| 4556 | [success,message]=copyfile(aviname,backup);%make backup of the existing file
|
---|
| 4557 | if isequal(success,1)
|
---|
| 4558 | delete(aviname)%delete existing file
|
---|
| 4559 | else
|
---|
| 4560 | msgbox_uvmat('ERROR',message)
|
---|
| 4561 | return
|
---|
| 4562 | end
|
---|
| 4563 | end
|
---|
| 4564 | %create avi open
|
---|
| 4565 | aviobj=avifile(aviname,'Compression','None','fps',fps);
|
---|
| 4566 |
|
---|
| 4567 | %display first view for tests
|
---|
| 4568 | newfig=figure;
|
---|
| 4569 | newaxes=copyobj(handles.axes3,newfig);%new plotting axes in the new figure
|
---|
| 4570 | set(newaxes,'Tag','movieaxes')
|
---|
| 4571 | nbpix=[512 384]*str2num(answer{3});
|
---|
| 4572 | set(gcf,'Position',[1 1 nbpix])% resolution XVGA
|
---|
| 4573 | set(newaxes,'Position',eval(answer{4}));
|
---|
| 4574 | map=colormap(handles.axes3);
|
---|
| 4575 | colormap(map);%transmit the current colormap to the zoom fig
|
---|
| 4576 | msgbox_uvmat('INPUT_Y-N',{['adjust figure ' num2str(newfig) ' with its matlab edit menu '] ;...
|
---|
| 4577 | ['then press OK to get the avi movie as a copy of figure ' num2str(newfig) ' display']});
|
---|
| 4578 | UvData.Object{1}.plotaxes=newaxes;% the axis in the new figure becomes the current main plotting axes
|
---|
| 4579 | set(huvmat,'UserData',UvData);
|
---|
| 4580 | increment=str2num(get(handles.increment_scan,'String')); %get the field increment d
|
---|
| 4581 | set(handles.STOP,'Visible','on')
|
---|
| 4582 | set(handles.speed,'Visible','on')
|
---|
| 4583 | set(handles.speed_txt,'Visible','on')
|
---|
| 4584 | set(handles.RunMovie,'BusyAction','queue')
|
---|
| 4585 |
|
---|
| 4586 | imin=str2num(get(handles.i1,'String'));
|
---|
| 4587 | imax=str2num(answer{5});
|
---|
| 4588 | % if isfield(UvData,'Time')
|
---|
| 4589 | htitle=get(newaxes,'Title');
|
---|
| 4590 | xlim=get(newaxes,'XLim');
|
---|
| 4591 | ylim=get(newaxes,'YLim');
|
---|
| 4592 | set(htitle,'Position',[xlim(2)+0.07*(xlim(2)-xlim(1)) ylim(2)-0.05*(ylim(2)-ylim(1)) 0])
|
---|
| 4593 | time_str=get(handles.abs_time,'String');
|
---|
| 4594 | set(htitle,'String',['t=' time_str])
|
---|
| 4595 | set(handles.speed,'Value',1)
|
---|
| 4596 | for i=1:imax
|
---|
| 4597 | if get(handles.speed,'Value')~=0 & isequal(get(handles.MenuExportMovie,'BusyAction'),'queue') % enable STOP command
|
---|
| 4598 | runpm(hObject,eventdata,handles,increment)
|
---|
| 4599 | drawnow
|
---|
| 4600 | time_str=get(handles.abs_time,'String');
|
---|
| 4601 | if ishandle(htitle)
|
---|
| 4602 | set(htitle,'String',['t=' time_str])
|
---|
| 4603 | end
|
---|
| 4604 | mov=getframe(newfig);
|
---|
| 4605 | aviobj=addframe(aviobj,mov);
|
---|
| 4606 | end
|
---|
| 4607 | end
|
---|
| 4608 | aviobj=close(aviobj);
|
---|
| 4609 | UvData.Object{1}.plotaxes=handles.axes3;
|
---|
| 4610 | set(huvmat,'UserData',UvData);
|
---|
| 4611 | msgbox_uvmat('CONFIRMATION',{['movie ' aviname ' created '];['with ' num2str(imax) ' frames']})
|
---|
| 4612 |
|
---|
| 4613 |
|
---|
| 4614 | % ------------------------------------------------------------------
|
---|
| 4615 | function MenuCalib_Callback(hObject, eventdata, handles)
|
---|
| 4616 | set(handles.TOOLS_txt,'Visible','on')
|
---|
| 4617 | set(handles.frame_tools,'Visible','on')
|
---|
| 4618 | set(handles.cal,'Visible','on')
|
---|
| 4619 | set(handles.cal,'Value',1)
|
---|
| 4620 | cal_Callback(hObject,eventdata,handles)
|
---|
| 4621 |
|
---|
| 4622 | % ------------------------------------------------------------------
|
---|
| 4623 | function MenuMask_Callback(hObject, eventdata, handles)
|
---|
| 4624 | set(handles.TOOLS_txt,'Visible','on')
|
---|
| 4625 | set(handles.frame_tools,'Visible','on')
|
---|
| 4626 | set(handles.create,'Visible','on')
|
---|
| 4627 | set(handles.create,'Value',1)
|
---|
| 4628 | set(handles.create,'BackgroundColor',[1 1 0]) %visualise in yellow
|
---|
| 4629 | set(handles.save_mask,'Visible','on')
|
---|
| 4630 | set(handles.masklevel,'Visible','on')
|
---|
| 4631 | if isequal(get(handles.z_index,'Visible'),'on')
|
---|
| 4632 | nb_slice=str2num(get(handles.nb_slice,'String'));
|
---|
| 4633 | for ilist=1:nb_slice
|
---|
| 4634 | list_index{ilist,1}=num2str(ilist);
|
---|
| 4635 | end
|
---|
| 4636 | set(handles.masklevel,'String',list_index)
|
---|
| 4637 | val=str2num(get(handles.z_index,'String'));
|
---|
| 4638 | if val<=nb_slice
|
---|
| 4639 | set(handles.masklevel,'Value',val)
|
---|
| 4640 | end
|
---|
| 4641 | else
|
---|
| 4642 | set(handles.masklevel,'String',{'1'})
|
---|
| 4643 | set(handles.masklevel,'Value',1)
|
---|
| 4644 | end
|
---|
| 4645 | if ishandle(handles.UVMAT_title)
|
---|
| 4646 | delete(handles.UVMAT_title)
|
---|
| 4647 | end
|
---|
| 4648 | huvmat=get(handles.create,'parent');
|
---|
| 4649 | UvData=get(huvmat,'UserData');%read UvData properties stored on the uvmat interface
|
---|
| 4650 | set(handles.zoom,'Value',0)
|
---|
| 4651 | set(handles.zoom,'BackgroundColor',[0.7 0.7 0.7])
|
---|
| 4652 | set(handles.edit_vect,'Value',0)
|
---|
| 4653 | edit_vect_Callback(hObject, eventdata, handles)
|
---|
| 4654 | set(handles.edit,'Value',0)
|
---|
| 4655 | set(handles.edit,'BackgroundColor',[0.7 0.7 0.7])
|
---|
| 4656 | set(handles.edit_vect,'Value',0)
|
---|
| 4657 | edit_vect_Callback(hObject, eventdata, handles)
|
---|
| 4658 | set(handles.cal,'Value',0)
|
---|
| 4659 | set(handles.cal,'BackgroundColor',[0 1 0])
|
---|
| 4660 |
|
---|
| 4661 | %initiate the GUI set_object
|
---|
| 4662 | data.TITLE='MASK';
|
---|
| 4663 | if isfield(UvData,'CoordType')
|
---|
| 4664 | data.CoordType=UvData.CoordType;
|
---|
| 4665 | end
|
---|
| 4666 | if isfield(UvData,'Mesh')&&~isempty(UvData.Mesh)
|
---|
| 4667 | data.YMax=UvData.Mesh;
|
---|
| 4668 | elseif isfield(UvData.Field,'AX')&&isfield(UvData.Field,'AY')&& isfield(UvData.Field,'A')%only image
|
---|
| 4669 | np=size(UvData.Field.A);
|
---|
| 4670 | meshx=(UvData.Field.AX(end)-UvData.Field.AX(1))/(np(2)-1);
|
---|
| 4671 | meshy=abs(UvData.Field.AY(end)-UvData.Field.AY(1))/(np(1)-1);
|
---|
| 4672 | data.YMax=max(meshx,meshy);
|
---|
| 4673 | data.DX=max(meshx,meshy);
|
---|
| 4674 | end
|
---|
| 4675 | data.Coord=[0 0 0]; %default
|
---|
| 4676 | PlotHandles=get_plot_handles(handles);%get the handles of the graphic objects setting the plotting parameters
|
---|
| 4677 | [hset_object,UvData.sethandles]=set_object(data,PlotHandles);% call the set_object interface
|
---|
| 4678 | pos_uvmat=get(huvmat,'Position');
|
---|
| 4679 | if isfield(UvData,'SetObjectOrigin')
|
---|
| 4680 | pos_set_object(1:2)=UvData.SetObjectOrigin + pos_uvmat(1:2);
|
---|
| 4681 | pos_set_object(3:4)=UvData.SetObjectSize .* pos_uvmat(3:4);
|
---|
| 4682 | set(hset_object,'Position',pos_set_object)
|
---|
| 4683 | end
|
---|
| 4684 | list_object=get(handles.list_object,'String');
|
---|
| 4685 | if ~isempty(list_object)
|
---|
| 4686 | set(handles.list_object,'Value',length(list_object))
|
---|
| 4687 | end
|
---|
| 4688 | UvData.MouseAction='create_object';
|
---|
| 4689 | set(huvmat,'UserData',UvData);
|
---|
| 4690 |
|
---|
| 4691 | % ------------------------------------------------------------------
|
---|
| 4692 | %-- open the GUI set_grid.fig to create grid
|
---|
| 4693 | function MenuGrid_Callback(hObject, eventdata, handles)
|
---|
| 4694 | set(handles.TOOLS_txt,'Visible','on')
|
---|
| 4695 | set(handles.frame_tools,'Visible','on')
|
---|
| 4696 | grid_Callback(hObject,eventdata,handles)
|
---|
| 4697 |
|
---|
| 4698 | %----------------------------------------------------------------
|
---|
| 4699 | % open the GUI 'series'
|
---|
| 4700 | %----------------------------------------------------------------
|
---|
| 4701 | function MenuSeries_Callback(hObject, eventdata, handles)
|
---|
[40] | 4702 | %-------------------------------------------------------------------
|
---|
[2] | 4703 |
|
---|
| 4704 | [param.FileName]=read_file_boxes(handles);
|
---|
| 4705 | if isequal(get(handles.SubField,'Value'),1)
|
---|
| 4706 | FileName_1=read_file_boxes_1(handles);%
|
---|
| 4707 | if ~isequal(FileName_1,param.FileName)
|
---|
| 4708 | param.FileName_1=FileName_1;
|
---|
| 4709 | end
|
---|
| 4710 | end
|
---|
| 4711 | param.NomType=get(handles.FileIndex,'UserData');
|
---|
| 4712 | param.NomType_1=get(handles.FileIndex_1,'UserData');
|
---|
| 4713 | param.comp_input=get(handles.fix_pair,'Value');
|
---|
| 4714 | huvmat=get(handles.MenuSeries,'parent');
|
---|
| 4715 | UvData=get(huvmat,'UserData');
|
---|
| 4716 | if isfield(UvData,'Time')
|
---|
| 4717 | param.Time=UvData.XmlData.Time;
|
---|
| 4718 | end
|
---|
| 4719 | if isequal(get(handles.scan_i,'Value'),1)
|
---|
| 4720 | param.incr_i=str2num(get(handles.increment_scan,'String'));
|
---|
| 4721 | elseif isequal(get(handles.scan_j,'Value'),1)
|
---|
| 4722 | param.incr_j=str2num(get(handles.increment_scan,'String'));
|
---|
| 4723 | end
|
---|
| 4724 | param.list_fields=get(handles.Fields,'String');% list menu fields
|
---|
| 4725 | param.list_fields(1)=[]; %suppress 'image' option
|
---|
| 4726 | param.index_fields=get(handles.Fields,'Value');% selected string index
|
---|
| 4727 | if param.index_fields>1
|
---|
| 4728 | param.index_fields=param.index_fields-1;
|
---|
| 4729 | end
|
---|
| 4730 | param.list_fields_1=get(handles.Fields_1,'String');% list menu fields
|
---|
| 4731 | param.list_fields_1(1)=[]; %suppress 'image' option
|
---|
| 4732 | param.index_fields_1=get(handles.Fields_1,'Value')-1;% selected string index
|
---|
| 4733 | if param.index_fields_1>1
|
---|
| 4734 | param.index_fields_1=param.index_fields_1-1;
|
---|
| 4735 | end
|
---|
| 4736 | param.civ1=get(handles.civ1,'Value');
|
---|
| 4737 | param.civ2=get(handles.civ2,'Value');
|
---|
| 4738 | param.interp1=get(handles.interp1,'Value');
|
---|
| 4739 | param.interp2=get(handles.interp2,'Value');
|
---|
| 4740 | param.filter1=get(handles.filter1,'Value');
|
---|
| 4741 | param.filter2=get(handles.filter2,'Value');
|
---|
[39] | 4742 | param.menu_coord_str=get(handles.transform_fct,'String');
|
---|
| 4743 | param.menu_coord_val=get(handles.transform_fct,'Value');
|
---|
[2] | 4744 |
|
---|
| 4745 | series(param); %run the series interface
|
---|
| 4746 |
|
---|
| 4747 | % ------------------------------------------------------------------
|
---|
| 4748 | % -- open the GUI civ.fig for civx (PIV)
|
---|
| 4749 | % ------------------------------------------------------------------
|
---|
| 4750 | function MenuPIV_Callback(hObject, eventdata, handles)
|
---|
| 4751 |
|
---|
| 4752 | [FileName,RootPath,filebase,FileIndices,ext,SubDir]=read_file_boxes(handles);
|
---|
| 4753 | [P,F,str1,str2,str_a,str_b]=name2display(FileName);
|
---|
| 4754 | num1=stra2num(str1);
|
---|
| 4755 | num2=stra2num(str2);
|
---|
| 4756 | num_a=stra2num(str_a);
|
---|
| 4757 | num_b=stra2num(str_b);
|
---|
| 4758 | NomType=get(handles.FileIndex,'UserData');
|
---|
| 4759 | ind_opening=1; % default (images): will advice civ1 option by default in the civ interface
|
---|
| 4760 | if isequal(ext,'.nc') || isequal(ext,'.cdf')% netcdf files
|
---|
| 4761 | ind_opening=2;% propose 'fix' as the default option
|
---|
| 4762 | % +read the current netcdf rootfile
|
---|
| 4763 | Data=nc2struct(FileName,[]);
|
---|
| 4764 | if isfield(Data,'fix') & isequal(Data.fix,1)
|
---|
| 4765 | ind_opening=3;
|
---|
| 4766 | end
|
---|
| 4767 | if isfield(Data,'patch') & isequal(Data.patch,1)
|
---|
| 4768 | ind_opening=4;
|
---|
| 4769 | end
|
---|
| 4770 | if isfield(Data,'civ2') & isequal(Data.civ2,1)
|
---|
| 4771 | ind_opening=5;
|
---|
| 4772 | end
|
---|
| 4773 | if isfield(Data,'fix2') & isequal(Data.fix2,1)
|
---|
| 4774 | ind_opening=6;
|
---|
| 4775 | end
|
---|
| 4776 | end
|
---|
| 4777 | varargin{1}=filebase;
|
---|
| 4778 | varargin{2}=NomType;
|
---|
| 4779 | varargin{3}=num1;
|
---|
| 4780 | varargin{4}=num2;
|
---|
| 4781 | varargin{5}=num_a;
|
---|
| 4782 | varargin{6}=num_b;
|
---|
| 4783 | varargin{7}=SubDir;
|
---|
| 4784 | varargin{8}=ind_opening;% A REVOIR +TRANSMETTRE IMADOC INFO
|
---|
| 4785 | varargin{11}=ext;
|
---|
| 4786 | civ(varargin);% interface de civ(not in the uvmat file)
|
---|
| 4787 |
|
---|
| 4788 | % ------------------------------------------------------------------
|
---|
| 4789 | function MenuTools_Callback(hObject, eventdata, handles)
|
---|
| 4790 |
|
---|
| 4791 | % ------------------------------------------------------------------
|
---|
| 4792 | function MenuEdit_Callback(hObject, eventdata, handles)
|
---|
| 4793 |
|
---|
| 4794 | %--------------------------------------------------------------------------
|
---|
| 4795 | function enable_transform(handles,state)
|
---|
[39] | 4796 | set(handles.transform_fct,'Visible',state)
|
---|
[2] | 4797 | set(handles.TRANSFORM_txt,'Visible',state)
|
---|
[39] | 4798 | set(handles.transform_fct,'Visible',state)
|
---|
[2] | 4799 | set(handles.path_transform,'Visible',state)
|
---|
| 4800 | set(handles.pxcmx_txt,'Visible',state)
|
---|
| 4801 | set(handles.pxcmy_txt,'Visible',state)
|
---|
| 4802 | set(handles.pxcm,'Visible',state)
|
---|
| 4803 | set(handles.pycm,'Visible',state)
|
---|
| 4804 |
|
---|
[40] | 4805 | %------------------------------------------------------------------------
|
---|
[2] | 4806 | function MenuEditVectors_Callback(hObject, eventdata, handles)
|
---|
[40] | 4807 | %------------------------------------------------------------------------
|
---|
[2] | 4808 | set(handles.edit_vect,'Visible','on')
|
---|
| 4809 | set(handles.edit_vect,'Value',1)
|
---|
| 4810 | edit_vect_Callback(hObject, eventdata, handles)
|
---|
| 4811 |
|
---|
[40] | 4812 | % --------------------------------------------------------------------
|
---|
| 4813 | function Menupoints_Callback(hObject, eventdata, handles)
|
---|
| 4814 | % set(handles.create,'Visible','on')
|
---|
| 4815 | % set(handles.create,'Value',1)
|
---|
| 4816 | % POINTS_Callback(hObject,eventdata,handles)
|
---|
| 4817 | data.Style='points';
|
---|
| 4818 | data.ProjMode='projection';%default
|
---|
| 4819 | PlotHandles=get_plot_handles(handles);%get the handles of the interface elements setting the plotting parameters
|
---|
| 4820 | create_object(data,handles.uvmat,PlotHandles)
|
---|
[2] | 4821 |
|
---|
[40] | 4822 | % --------------------------------------------------------------------
|
---|
| 4823 | function Menuline_Callback(hObject, eventdata, handles)
|
---|
| 4824 | % set(handles.create,'Visible','on')
|
---|
| 4825 | % set(handles.create,'Value',1)
|
---|
| 4826 | % LINE_Callback(hObject,eventdata,handles)
|
---|
| 4827 | data.Style='line';
|
---|
| 4828 | data.ProjMode='projection';%default
|
---|
| 4829 | PlotHandles=get_plot_handles(handles);%get the handles of the interface elements setting the plotting parameters
|
---|
| 4830 | create_object(data,handles.uvmat,PlotHandles)
|
---|
[2] | 4831 |
|
---|
[40] | 4832 | %------------------------------------------------------------------------
|
---|
| 4833 | function Menupolyline_Callback(hObject, eventdata, handles)
|
---|
| 4834 | %------------------------------------------------------------------------
|
---|
| 4835 | data.Style='polyline';
|
---|
| 4836 | data.ProjMode='projection';%default
|
---|
| 4837 | PlotHandles=get_plot_handles(handles);%get the handles of the interface elements setting the plotting parameters
|
---|
| 4838 | create_object(data,handles.uvmat,PlotHandles)
|
---|
[2] | 4839 |
|
---|
[40] | 4840 | % ------------------------------------------------------------------
|
---|
| 4841 | function Menupolygon_Callback(hObject, eventdata, handles)
|
---|
| 4842 | set(handles.create,'Visible','on')
|
---|
| 4843 | set(handles.create,'Value',1)
|
---|
| 4844 | PATCH_Callback(hObject,eventdata,handles)
|
---|
| 4845 |
|
---|
| 4846 | %------------------------------------------------------------------------
|
---|
| 4847 | function Menurectangle_Callback(hObject, eventdata, handles)
|
---|
| 4848 | %------------------------------------------------------------------------
|
---|
| 4849 | data.Style='rectangle';
|
---|
| 4850 | data.ProjMode='inside';%default
|
---|
| 4851 | PlotHandles=get_plot_handles(handles);%get the handles of the interface elements setting the plotting parameters
|
---|
| 4852 | create_object(data,handles.uvmat,PlotHandles)
|
---|
| 4853 |
|
---|
| 4854 | %------------------------------------------------------------------------
|
---|
| 4855 | function Menuellipse_Callback(hObject, eventdata, handles)
|
---|
| 4856 | %------------------------------------------------------------------------
|
---|
| 4857 | data.Style='ellipse';
|
---|
| 4858 | data.ProjMode='inside';%default
|
---|
| 4859 | PlotHandles=get_plot_handles(handles);%get the handles of the interface elements setting the plotting parameters
|
---|
| 4860 | create_object(data,handles.uvmat,PlotHandles)
|
---|
| 4861 |
|
---|
| 4862 | % ------------------------------------------------------------------
|
---|
| 4863 | function Menuplane_Callback(hObject, eventdata, handles)
|
---|
| 4864 | % set(handles.create,'Visible','on')
|
---|
| 4865 | % set(handles.create,'Value',1)
|
---|
| 4866 | % PLANE_Callback(hObject,eventdata,handles)
|
---|
| 4867 | data.Style='plane';
|
---|
| 4868 | data.ProjMode='projection';%default
|
---|
| 4869 | PlotHandles=get_plot_handles(handles);%get the handles of the interface elements setting the plotting parameters
|
---|
| 4870 | create_object(data,handles.uvmat,PlotHandles)
|
---|
| 4871 |
|
---|
| 4872 | % ------------------------------------------------------------------
|
---|
| 4873 | function Menuvolume_Callback(hObject, eventdata, handles)
|
---|
| 4874 | set(handles.create,'Visible','on')
|
---|
| 4875 | set(handles.create,'Value',1)
|
---|
| 4876 | VOLUME_Callback(hObject,eventdata,handles)
|
---|
| 4877 |
|
---|
| 4878 | %------------------------------------------------------------------------
|
---|
| 4879 | function MenuBrowseObject_Callback(hObject, eventdata, handles)
|
---|
| 4880 | %------------------------------------------------------------------------
|
---|
| 4881 | %get the object file
|
---|
| 4882 | [FileName, PathName, filterindex] = uigetfile( ...
|
---|
| 4883 | {'*.xml;*.mat', ' (*.xml,*.mat)';
|
---|
| 4884 | '*.xml', '.xml files '; ...
|
---|
| 4885 | '*.mat', '.mat matlab files '}, ...
|
---|
| 4886 | 'Pick a file',get(handles.RootPath,'String'));
|
---|
| 4887 | fileinput=[PathName FileName];%complete file name
|
---|
| 4888 | testblank=findstr(fileinput,' ');%look for blanks
|
---|
| 4889 | if ~isempty(testblank)
|
---|
| 4890 | msgbox_uvmat('ERROR','forbidden input file name: contain blanks')
|
---|
| 4891 | return
|
---|
| 4892 | end
|
---|
| 4893 | sizf=size(fileinput);
|
---|
| 4894 | if (~ischar(fileinput)||~isequal(sizf(1),1)),return;end
|
---|
| 4895 |
|
---|
| 4896 | %read the file
|
---|
| 4897 | t=xmltree(fileinput);
|
---|
| 4898 | data=convert(t);
|
---|
| 4899 | if ~isfield(data,'Style')
|
---|
| 4900 | data.Style='points';
|
---|
| 4901 | end
|
---|
| 4902 | if ~isfield(data,'ProjMode')
|
---|
| 4903 | data.ProjMode='none';
|
---|
| 4904 | end
|
---|
| 4905 | PlotHandles=get_plot_handles(handles);%get the handles of the interface elements setting the plotting parameters
|
---|
| 4906 | create_object(data,handles.uvmat,PlotHandles)
|
---|
| 4907 |
|
---|
| 4908 | %------------------------------------------------------------------------
|
---|
| 4909 | function create_object(data,huvmat,PlotHandles)
|
---|
| 4910 | %------------------------------------------------------------------------
|
---|
| 4911 | hset_object=findobj(allchild(0),'Name','set_object')
|
---|
| 4912 | if ~isempty(hset_object)
|
---|
| 4913 | delete(hset_object)% delete existing version of set_object
|
---|
| 4914 | end
|
---|
| 4915 | UvData=get(huvmat,'UserData');
|
---|
| 4916 | if isfield(UvData,'CoordType')
|
---|
| 4917 | data.CoordType=UvData.CoordType;
|
---|
| 4918 | end
|
---|
| 4919 | if isfield(UvData,'Mesh')&~isempty(UvData.Mesh)
|
---|
| 4920 | data.RangeX=UvData.Mesh;
|
---|
| 4921 | data.RangeY=UvData.Mesh;
|
---|
| 4922 | data.DX=UvData.Mesh;
|
---|
| 4923 | data.DY=UvData.Mesh;
|
---|
| 4924 | elseif isfield(UvData.Field,'AX')&isfield(UvData.Field,'AY')& isfield(UvData.Field,'A')%only image
|
---|
| 4925 | np=size(UvData.Field.A);
|
---|
| 4926 | meshx=(UvData.Field.AX(end)-UvData.Field.AX(1))/np(2);
|
---|
| 4927 | meshy=abs(UvData.Field.AY(end)-UvData.Field.AY(1))/np(1);
|
---|
| 4928 | data.RangeY=max(meshx,meshy);
|
---|
| 4929 | data.RangeX=max(meshx,meshy);
|
---|
| 4930 | data.DX=max(meshx,meshy);
|
---|
| 4931 | end
|
---|
| 4932 | if isfield(data,'DX')
|
---|
| 4933 | data.Coord=[[0 0 0];[data.DX 0 0]]; %default
|
---|
| 4934 | else
|
---|
| 4935 | data.Coord=[[0 0 0];[1 0 0]]; %default
|
---|
| 4936 | end
|
---|
| 4937 | %data.ParentButton=handles.create;
|
---|
| 4938 |
|
---|
| 4939 | [hset_object,UvData.sethandles]=set_object(data,PlotHandles);% call the set_object interface
|
---|
| 4940 | UvData.MouseAction='create_object';
|
---|
| 4941 | set(huvmat,'UserData',UvData)
|
---|
| 4942 |
|
---|
| 4943 |
|
---|