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