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