[387] | 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 | % |
---|
| 9 | %INPUT: |
---|
| 10 | % input: input file name (if character chain), or input image matrix to |
---|
| 11 | % visualize, or Matlab structure representing netcdf fields (with fields |
---|
| 12 | % ListVarName....) |
---|
| 13 | % |
---|
| 14 | %AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA |
---|
| 15 | % Copyright Joel Sommeria, 2008, LEGI / CNRS-UJF-INPG, joel.sommeria@legi.grenoble-inp.fr. |
---|
| 16 | %AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA |
---|
| 17 | % This open is part of the toolbox UVMAT. |
---|
| 18 | % |
---|
| 19 | % UVMAT is free software; you can redistribute it and/or modify |
---|
| 20 | % it under the terms of the GNU General Public License as published by |
---|
| 21 | % the Free Software Foundation; either version 2 of the License, or |
---|
| 22 | % (at your option) any later version. |
---|
| 23 | % |
---|
| 24 | % UVMAT is distributed in the hope that it will be useful, |
---|
| 25 | % but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
| 26 | % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
| 27 | % GNU General Public License (open UVMAT/COPYING.txt) for more details. |
---|
| 28 | %AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA |
---|
| 29 | % |
---|
| 30 | % Information stored on the interface: |
---|
| 31 | % 'Strings' of all edit boxes and menus: get(handles.Tag,'String') |
---|
| 32 | % 'Values' of all menus and toggle buttons: get(handles.Tag,'Value') |
---|
| 33 | % Matlab structure called UvData stored as 'UserData' of the figure uvmat.fig,(can be obtained by right mouse click on the interface). |
---|
| 34 | % It contains the following fields: |
---|
| 35 | % - Fixed specifiacation of plotting figures and axes (defined bu uvmat_OpeningFcn) |
---|
| 36 | % .PosColorbar: [0.8210 0.4710 0.0190 0.4450]; specified position of the colorbar on figures |
---|
| 37 | % - Information read in the documentation open of a series (activated by RootPath_Callback) : |
---|
| 38 | % .XmlData, with fields: |
---|
| 39 | % .Time: matrix of times of the images with index i and j |
---|
| 40 | % .GeometryCalib: [1x1 struct] |
---|
| 41 | % - Information defined from the interface: |
---|
| 42 | % .NewSeries: =1 when the first view of a new field series is displayed, else 0 |
---|
| 43 | % .filename:(char string) |
---|
| 44 | % .FieldName: (char string) main field selected('image', 'velocity'...) |
---|
| 45 | % .CName: (char string)name of the scalar used for vector colors |
---|
| 46 | % .MovieObject{1}: movie object representing an input movie |
---|
| 47 | % .MovieObject{2}: idem for a second input series (_1) |
---|
| 48 | % .filename_1 : last second input file name (to deal with a constant second input without reading again the file) |
---|
| 49 | % .ZMin, .ZMax: range of the z coordinate |
---|
| 50 | %..... to complement |
---|
| 51 | % - Information on projection objects |
---|
| 52 | % .Object: {[1x1 struct]} |
---|
| 53 | % .CurrentObjectIndex: index of the projection object .Object currently selected for editing |
---|
| 54 | % -Information on the current field (Field{i}) |
---|
| 55 | % .Txt : text information to display (e.g. error message) |
---|
| 56 | % .NbDim: number of dimensions (=0 by default) |
---|
| 57 | % .NbCoord: number of vector components |
---|
| 58 | % .CoordType: expresses the type of coordinate ('px' for image, 'sig' for instruments, or 'phys') |
---|
| 59 | % .dt: time interval for the corresponding image pair |
---|
| 60 | % .Mesh: estimated typical distance between vectors |
---|
| 61 | % .ZMax: |
---|
| 62 | % .ZMin: |
---|
| 63 | % .X, .Y, .Z: set of vector coordinates |
---|
| 64 | % .U,.V,.W: corresponding set of vector components |
---|
| 65 | % .F: corresponding set of warning flags |
---|
| 66 | % .FF: corresponding set of false flags, =0 for good vectors |
---|
| 67 | % .C: corresponding values of the scalar used for vector color |
---|
| 68 | % (.X, .Y, .Z,.U,.V,.W,.F,.FF,.C are matlab vectors of the same length, |
---|
| 69 | % equal to the number of vectors stored in the input open) |
---|
| 70 | % .CName: name of the scalar .C |
---|
| 71 | % .CType: type of the scalar .C, setting how the scalar is obtained (see 'Scalars' below) |
---|
| 72 | % .A image or scalar |
---|
| 73 | % .AX: vector of dimension 2 representing the first and last values |
---|
| 74 | % of the X coordinates for the image or scalar known on a regular grid, |
---|
| 75 | % or vector of dimension .A for a scaler defined on irregular grid. |
---|
| 76 | % .AY: same as .AX along the Y direction |
---|
| 77 | % .AName: name of the scalar, ='image' for an image |
---|
| 78 | |
---|
| 79 | % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%% DATA FLOW (for run0_Callback) %%%%%%%%%%%%%%%%%%%%: |
---|
| 80 | % |
---|
[406] | 81 | % |
---|
| 82 | % 1) Input filenames are determined by MenuBrowse (first field), MenuBrowse_1 |
---|
| 83 | % (second field), or by the stored file names under Browse, or as an input of uvmat. |
---|
| 84 | % 2) These functions call 'display_file_name.m' which detects the file series, and fills the file index boxes |
---|
| 85 | % 3) Then 'update_rootinfo.m' Updates information about a new field series (indices to scan, timing, calibration from an xml file) |
---|
| 86 | % 4) Then fields are opened and visualised by the main sub-function 'refresh_field.m' |
---|
[387] | 87 | % The function first reads the name of the input file from the edit boxes of the GUI |
---|
[406] | 88 | % A second input file can be introduced for file comparison |
---|
[387] | 89 | % It then reads the input file(s) with the appropriate function, read for |
---|
| 90 | % images, read_civxdata.m for CIVx PIV data, nc2struct for other netcdf |
---|
| 91 | % files. |
---|
| 92 | % Main input open second input open(_1) second image (pair animation) |
---|
| 93 | % | | |
---|
| 94 | % | | |
---|
| 95 | % Field{1} Field{2} |
---|
| 96 | % | |
---|
| 97 | % coord transform (phys.m) or other user defined fct acting on Field{i} | |
---|
| 98 | % Field{i} |
---|
| 99 | % | |
---|
| 100 | % calc_field.m: calculate scalar or other derived fields (vort, div..). |
---|
| 101 | % |
---|
| 102 | % sub_field.m: combine the input Field{i} in a single set of fields (vector + scalar): |
---|
| 103 | % Field{i=1->3}.X --> UvData.X | |
---|
| 104 | % | |
---|
| 105 | % UvData |
---|
| 106 | % | |
---|
| 107 | % plot histograms of the whole field |
---|
| 108 | % proj_field.m: project the set of fields on the current projection objects defined by UvData.Object |
---|
| 109 | % | | |
---|
| 110 | % ObjectData |
---|
| 111 | % | |
---|
| 112 | % plot_field.m: plot the projected fields and store them as | |
---|
| 113 | % UvData.axes3 | |
---|
| 114 | % | |
---|
| 115 | % AxeData |
---|
| 116 | % |
---|
| 117 | %%%%%%%%%%%%%% SCALARS: %%%%%%%%%%%%??%%% |
---|
| 118 | % scalars are displayed either as an image or countour plot, either as a color of |
---|
| 119 | % velocity vectors. The scalar values in the first case is represented by |
---|
| 120 | % UvData.Field.A, and by UvData.Field.C in the second case. The corresponding set of X |
---|
| 121 | % and Y coordinates are represented by UvData.Field.AX and UvData.Field.AY, and .X and |
---|
| 122 | % .Y for C (the same as velocity vectors). If A is a nxxny matrix (scalar |
---|
| 123 | % on a regtular grid), then .AX andf.AY contains only two elements, represneting the |
---|
| 124 | % coordinates of the four image corners. The scalar name is represented by |
---|
| 125 | % the strings .AName and/or .CName. |
---|
| 126 | % If the scalar exists in an input open (image or scalar stored under its |
---|
| 127 | % name in a netcdf open), it is directly read at the level of Field{1}or Field{2}. |
---|
| 128 | % Else only its name AName is recorded in Field{i}, and its field is then calculated |
---|
| 129 | %by the fuction calc_scal after the coordinate transform or after projection on an edit_object |
---|
| 130 | |
---|
| 131 | % Properties attached to plotting figures (standard Matlab properties): |
---|
| 132 | % 'CurrentAxes'= gca or get(gcf,'CurrentAxes'); |
---|
| 133 | % 'CurrentPoint'=get(gcf,'CurrentPoint'): figure coordinates of the point over which the mouse is positioned |
---|
| 134 | % 'CurrentCharacter'=get(gcf,'CurrentCharacter'): last character typed over the figure where the mouse is positioned |
---|
| 135 | % 'WindowButtonMotionFcn': function permanently called by mouse motion over the figure |
---|
| 136 | % 'KeyPressFcn': function called by pressing a key on the key board |
---|
| 137 | % 'WindowButtonDownFcn': function called by pressing the mouse over the figure |
---|
| 138 | % 'WindowButtonUpFcn': function called by releasing the mouse pressure over the figure |
---|
| 139 | |
---|
| 140 | % Properties attached to plotting axes: |
---|
| 141 | % 'CurrentPoint'=get(gca,'CurrentPoint'); (standard Matlab) same as for the figure, but position in plot coordinates. |
---|
| 142 | % AxeData:=get(gca,'UserData'); |
---|
| 143 | % AxeData.Drawing = create: create a new object |
---|
| 144 | % = deform: modify an existing object by moving its defining create |
---|
| 145 | % = off: no current drawing action |
---|
| 146 | % = translate: translate an existing object |
---|
| 147 | % = calibration: move a calibration point |
---|
| 148 | % = CheckZoom: isolate a subregion for CheckZoom in=1 if an object is being currently drawn, 0 else (set to 0 by releasing mouse button) |
---|
| 149 | % .CurrentOrigin: Origin of a curently drawn edit_object |
---|
| 150 | % .CurrentLine: currently drawn menuline (A REVOIR) |
---|
| 151 | % .CurrentObject: handle of the currently drawn edit_object |
---|
| 152 | % .CurrentRectZoom: current rectangle used for CheckZoom |
---|
| 153 | |
---|
| 154 | % Properties attached to projection objects (create, menuline, menuplane...): |
---|
| 155 | % 'Tag'='proj_object': for all projection objects |
---|
| 156 | % ObjectData.Type=...: style of projection object: |
---|
| 157 | % .ProjMode |
---|
| 158 | % .Coord: defines the position of the object |
---|
| 159 | % .XMin,YMin.... |
---|
| 160 | % .XMax,YMax.... |
---|
| 161 | % .DX,DY,DZ |
---|
| 162 | % .Phi, .Theta, .Psi : Euler angles |
---|
| 163 | % .X,.Y,.U,.V.... : field data projected on the object |
---|
| 164 | % .IndexObj: index in the list of UvData.Object |
---|
| 165 | %during plotting |
---|
| 166 | % .plotaxes: handles of the current axes used to plot the result of field projection on the object |
---|
| 167 | % .plothandle: vector of handle(s) of the object graphic represnetation in all the opened plotting axes |
---|
| 168 | % To each projection object #iobj, corresponds an axis |
---|
| 169 | % Object{iobj}.plotaxes and nbobj representation graphs Object{iobj}.plothandles(:) (where nbobj is the |
---|
| 170 | % nbre of current objects opened in uvmat. Note that Object{iobj}.plothandles(iobj)=[] : an object is not represented in its own projection field; |
---|
| 171 | |
---|
| 172 | %------------------------------------------------------------------------ |
---|
| 173 | %------------------------------------------------------------------------ |
---|
[406] | 174 | % I - MAIN FUNCTION uvmat |
---|
[387] | 175 | %------------------------------------------------------------------------ |
---|
| 176 | %------------------------------------------------------------------------ |
---|
| 177 | function varargout = uvmat(varargin) |
---|
| 178 | |
---|
| 179 | % Begin initialization code - DO NOT EDIT |
---|
| 180 | gui_Singleton = 1; |
---|
| 181 | gui_State = struct('gui_Name', mfilename, ... |
---|
| 182 | 'gui_Singleton', gui_Singleton, ... |
---|
| 183 | 'gui_OpeningFcn', @uvmat_OpeningFcn, ... |
---|
| 184 | 'gui_OutputFcn', @uvmat_OutputFcn, ... |
---|
| 185 | 'gui_LayoutFcn', [], ... |
---|
| 186 | 'gui_Callback', []); |
---|
| 187 | if nargin && ischar(varargin{1})&& ~isempty(regexp(varargin{1},'_Callback','once')) |
---|
| 188 | gui_State.gui_Callback = str2func(varargin{1}); |
---|
| 189 | end |
---|
| 190 | |
---|
| 191 | if nargout |
---|
| 192 | varargout{1:nargout} = gui_mainfcn(gui_State, varargin{:}); |
---|
| 193 | else |
---|
| 194 | gui_mainfcn(gui_State, varargin{:}); |
---|
| 195 | end |
---|
| 196 | % End initialization code - DO NOT EDIT |
---|
| 197 | |
---|
| 198 | %------------------------------------------------------------------------ |
---|
| 199 | % --- Executes just before the GUI uvmat is made visible. |
---|
| 200 | function uvmat_OpeningFcn(hObject, eventdata, handles, input ) |
---|
| 201 | %------------------------------------------------------------------------ |
---|
| 202 | |
---|
| 203 | %% Choose default command menuline output for uvmat (standard GUI) |
---|
| 204 | handles.output = hObject; |
---|
| 205 | |
---|
| 206 | %% Update handles structure (standard GUI) |
---|
| 207 | guidata(hObject, handles); |
---|
| 208 | |
---|
| 209 | %% check the path and date of modification of all functions in uvmat |
---|
| 210 | path_to_uvmat=which ('uvmat');% check the path detected for source file uvmat |
---|
| 211 | [errormsg,date_str,svn_info]=check_files;%check the path of the functions called by uvmat.m |
---|
| 212 | date_str=['last modification: ' date_str]; |
---|
| 213 | |
---|
| 214 | |
---|
| 215 | %% set the position of colorbar and ancillary GUIs: |
---|
| 216 | set(hObject,'Units','Normalized') |
---|
| 217 | movegui(hObject,'center') |
---|
| 218 | UvData.OpenParam.PosColorbar=[0.805 0.022 0.019 0.445]; |
---|
| 219 | UvData.OpenParam.SetObjectOrigin=[-0.05 -0.03]; %position for set_object |
---|
| 220 | UvData.OpenParam.SetObjectSize=[0.3 0.7]; |
---|
| 221 | UvData.OpenParam.CalOrigin=[0.95 -0.03];%position for geometry_calib (TO IMPROVE) |
---|
| 222 | UvData.OpenParam.CalSize=[0.28 1]; |
---|
| 223 | UvData.axes3=[];%initiate the record of plotted field |
---|
| 224 | UvData.axes2=[]; |
---|
| 225 | UvData.axes1=[]; |
---|
| 226 | AxeData.LimEditBox=1; %initialise AxeData |
---|
| 227 | set(handles.axes3,'UserData',AxeData) |
---|
| 228 | |
---|
| 229 | %% set functions for the mouse and keyboard |
---|
[423] | 230 | % set(handles.histo_u,'NextPlot','replacechildren'); |
---|
[424] | 231 | % set(handles.histo_v,'NextPlot','replacechildren'); |
---|
[387] | 232 | set(hObject,'KeyPressFcn',{'keyboard_callback',handles})%set keyboard action function |
---|
| 233 | set(hObject,'WindowButtonMotionFcn',{'mouse_motion',handles})%set mouse action functio |
---|
| 234 | set(hObject,'WindowButtonDownFcn',{'mouse_down'})%set mouse click action function |
---|
| 235 | set(hObject,'WindowButtonUpFcn',{'mouse_up',handles}) |
---|
| 236 | set(hObject,'DeleteFcn',{@closefcn})% |
---|
| 237 | |
---|
| 238 | %% refresh projection plane |
---|
[432] | 239 | % UvData.Object{1}.ProjMode='projection';%main plotting plane |
---|
| 240 | % UvData.Object{1}.DisplayHandle.uvmat=handles.axes3; |
---|
| 241 | % UvData.Object{1}.DisplayHandle.view_field=[]; |
---|
[424] | 242 | set(handles.ListObject,'Value',1)% default: empty projection objectproj_field |
---|
[429] | 243 | set(handles.ListObject,'String',{'plane'}) |
---|
[410] | 244 | set(handles.ListObject_1,'Value',1)% default: empty projection objectproj_field |
---|
[429] | 245 | set(handles.ListObject_1,'String',{'plane'}) |
---|
[387] | 246 | set(handles.Fields,'Value',1) |
---|
| 247 | set(handles.Fields,'string',{''}) |
---|
| 248 | |
---|
| 249 | %% TRANSFORM menu: builtin fcts |
---|
| 250 | menu_str={'';'phys';'px';'phys_polar'}; |
---|
| 251 | UvData.OpenParam.NbBuiltin=numel(menu_str); %number of functions |
---|
| 252 | path_uvmat=fileparts(which('uvmat')); |
---|
| 253 | addpath (path_uvmat) ; %add the path to UVMAT, (useful in case of change of working directory after civ has been s opened in the working directory) |
---|
| 254 | addpath(fullfile(path_uvmat,'transform_field'))%add the path to transform functions, |
---|
| 255 | fct_handle{1,1}=[]; |
---|
| 256 | testexist=zeros(size(menu_str'));%default |
---|
| 257 | testexist(1)=1; |
---|
| 258 | for ilist=2:length(menu_str) |
---|
| 259 | if exist(menu_str{ilist},'file') |
---|
| 260 | fct_handle{ilist,1}=str2func(menu_str{ilist}); |
---|
| 261 | testexist(ilist)=1; |
---|
| 262 | else |
---|
| 263 | testexist(ilist)=0; |
---|
| 264 | end |
---|
| 265 | end |
---|
| 266 | rmpath(fullfile(path_uvmat,'transform_field')) |
---|
| 267 | |
---|
| 268 | %% load the list of previously browsed files in menus Open and Open_1 |
---|
| 269 | dir_perso=prefdir; % path to the directory .matlab for personal data |
---|
| 270 | profil_perso=fullfile(dir_perso,'uvmat_perso.mat');% personal data file uvmauvmat_perso.mat' in .matlab |
---|
| 271 | if exist(profil_perso,'file') |
---|
| 272 | h=load (profil_perso); |
---|
| 273 | if isfield(h,'MenuFile') |
---|
| 274 | for ifile=1:min(length(h.MenuFile),5) |
---|
| 275 | eval(['set(handles.MenuFile_' num2str(ifile) ',''Label'',h.MenuFile{ifile});']) |
---|
| 276 | eval(['set(handles.MenuFile_' num2str(ifile) '_1,''Label'',h.MenuFile{ifile});']) |
---|
| 277 | end |
---|
| 278 | end |
---|
| 279 | if isfield(h,'transform_fct') && iscell(h.transform_fct) |
---|
| 280 | for ilist=1:length(h.transform_fct); |
---|
| 281 | if exist(h.transform_fct{ilist},'file') |
---|
| 282 | [path,file]=fileparts(h.transform_fct{ilist}); |
---|
| 283 | addpath(path) |
---|
| 284 | h_func=str2func(file); |
---|
| 285 | rmpath(path) |
---|
| 286 | testexist=[testexist 1]; |
---|
| 287 | else |
---|
| 288 | file=''; |
---|
| 289 | h_func=[]; |
---|
| 290 | testexist=[testexist 0]; |
---|
| 291 | end |
---|
| 292 | fct_handle=[fct_handle; {h_func}]; %concatene the list of paths |
---|
| 293 | menu_str=[menu_str; {file}]; |
---|
| 294 | end |
---|
| 295 | end |
---|
| 296 | end |
---|
| 297 | menu_str=menu_str(testexist==1);%=menu_str(testexist~=0) |
---|
| 298 | fct_handle=fct_handle(testexist==1); |
---|
| 299 | menu_str=[menu_str;{'more...'}]; |
---|
| 300 | set(handles.transform_fct,'String',menu_str) |
---|
| 301 | set(handles.transform_fct,'UserData',fct_handle)% store the list of path in UserData of ACTION |
---|
| 302 | |
---|
| 303 | %% case of an input argument for uvmat |
---|
| 304 | testinputfield=0; |
---|
| 305 | inputfile=[]; |
---|
| 306 | Field=[]; |
---|
| 307 | if exist('input','var') |
---|
| 308 | % if ~isempty(errormsg) |
---|
| 309 | % msgbox_uvmat('WARNING',errormsg) |
---|
| 310 | % end |
---|
| 311 | if ishandle(handles.UVMAT_title) |
---|
| 312 | delete(handles.UVMAT_title) |
---|
| 313 | end |
---|
| 314 | if isstruct(input) |
---|
| 315 | if isfield(input,'InputFile') |
---|
| 316 | inputfile=input.InputFile; |
---|
| 317 | end |
---|
| 318 | if isfield(input,'TimeIndex') |
---|
| 319 | set(handles.i1,num2str(input.TimeIndex)) |
---|
| 320 | end |
---|
| 321 | if isfield(input,'FieldsString') |
---|
| 322 | UvData.FieldsString=input.FieldsString; |
---|
| 323 | end |
---|
| 324 | elseif ischar(input)% file name introduced as input |
---|
| 325 | inputfile=input; |
---|
| 326 | elseif isnumeric(input)%simple matrix introduced as input |
---|
| 327 | sizinput=size(input); |
---|
| 328 | if sizinput(1)<=1 || sizinput(2)<=1 |
---|
| 329 | msgbox_uvmat('ERROR','bad input for uvmat: file name, structure or numerical matrix accepted') |
---|
| 330 | return |
---|
| 331 | end |
---|
| 332 | UvData.Field.ListVarName={'A','coord_y','coord_x'}; |
---|
| 333 | UvData.Field.VarDimName={{'coord_y','coord_x'},'cord_y','coord_x'}; |
---|
| 334 | UvData.Field.A=input; |
---|
| 335 | UvData.Field.coord_x=[0.5 size(input,2)-0.5]; |
---|
| 336 | UvData.Field.coord_y=[size(input,1)-0.5 0.5]; |
---|
| 337 | testinputfield=1; |
---|
| 338 | end |
---|
| 339 | else |
---|
| 340 | if ishandle(handles.UVMAT_title) |
---|
| 341 | set(handles.UVMAT_title,'String',... |
---|
| 342 | [{'Copyright LEGI UMR 5519 /CNRS-UJF-Grenoble INP, 2010'};... |
---|
| 343 | {'GNU General Public License'};... |
---|
| 344 | {path_to_uvmat};... |
---|
| 345 | {date_str};... |
---|
| 346 | {['SVN revision : ' num2str(svn_info.cur_rev)]};... |
---|
| 347 | errormsg]); |
---|
| 348 | end |
---|
| 349 | end |
---|
| 350 | set(handles.uvmat,'UserData',UvData) |
---|
| 351 | if ~isempty(inputfile) |
---|
| 352 | %%%%% display the input field %%%%%%% |
---|
[406] | 353 | display_file_name(handles,inputfile) |
---|
[387] | 354 | %%%%%%% |
---|
| 355 | testinputfield=1; |
---|
| 356 | end |
---|
| 357 | |
---|
| 358 | %% plot input field if exists |
---|
| 359 | if testinputfield |
---|
| 360 | %delete drawn objects |
---|
| 361 | hother=findobj(handles.axes3,'Tag','proj_object');%find all the proj objects |
---|
| 362 | for iobj=1:length(hother) |
---|
| 363 | delete_object(hother(iobj)) |
---|
| 364 | end |
---|
| 365 | if isempty(inputfile) |
---|
| 366 | errormsg=refresh_field(handles,[],[],[],[],[],[],{Field}); |
---|
| 367 | set(handles.MenuTools,'Enable','on') |
---|
| 368 | set(handles.OBJECT_txt,'Visible','on') |
---|
| 369 | set(handles.edit_object,'Visible','on') |
---|
[410] | 370 | % set(handles.ListObject_1,'Visible','on') |
---|
[387] | 371 | set(handles.frame_object,'Visible','on') |
---|
| 372 | if ~isempty(errormsg) |
---|
| 373 | msgbox_uvmat('ERROR',errormsg) |
---|
| 374 | end |
---|
| 375 | end |
---|
| 376 | end |
---|
| 377 | |
---|
| 378 | set_vec_col_bar(handles) %update the display of color code for vectors |
---|
| 379 | |
---|
| 380 | %------------------------------------------------------------------------ |
---|
| 381 | % --- Outputs from this function are returned to the command menuline. |
---|
| 382 | function varargout = uvmat_OutputFcn(hObject, eventdata, handles) |
---|
| 383 | varargout{1} = handles.output;% the only output argument is the handle to the GUI figure |
---|
| 384 | |
---|
| 385 | %------------------------------------------------------------------------ |
---|
[402] | 386 | % --- executed when closing uvmat: delete or desactivate the associated figures if exist |
---|
| 387 | function closefcn(gcbo,eventdata) |
---|
[387] | 388 | %------------------------------------------------------------------------ |
---|
[402] | 389 | hh=findobj(allchild(0),'tag','view_field'); |
---|
| 390 | if ~isempty(hh) |
---|
| 391 | delete(hh) |
---|
| 392 | end |
---|
| 393 | hh=findobj(allchild(0),'tag','geometry_calib'); |
---|
| 394 | if ~isempty(hh) |
---|
| 395 | delete(hh) |
---|
| 396 | end |
---|
| 397 | hh=findobj(allchild(0),'tag','set_object'); |
---|
| 398 | if ~isempty(hh) |
---|
| 399 | hhh=findobj(hh,'tag','PLOT'); |
---|
| 400 | set(hhh,'enable','off') |
---|
| 401 | end |
---|
| 402 | |
---|
| 403 | %------------------------------------------------------------------------ |
---|
| 404 | %------------------------------------------------------------------------ |
---|
[387] | 405 | % II - FUNCTIONS FOR INTRODUCING THE INPUT FILES |
---|
| 406 | % automatically sets the global properties when the rootfile name is introduced |
---|
| 407 | % then activate the view-field action if selected |
---|
| 408 | % it is activated either by clicking on the RootPath window or by the |
---|
| 409 | % browser |
---|
| 410 | %------------------------------------------------------------------------ |
---|
| 411 | %------------------------------------------------------------------------ |
---|
| 412 | % --- Executes on the menu Open/Browse... |
---|
| 413 | % search the files, recognize their type according to their name and fill the rootfile input windows |
---|
| 414 | function MenuBrowse_Callback(hObject, eventdata, handles) |
---|
| 415 | [RootPath,SubDir,RootFile,FileIndices,FileExt]=read_file_boxes(handles); |
---|
| 416 | oldfile=[fullfile(RootPath,SubDir,RootFile) FileIndices FileExt]; |
---|
| 417 | if isempty(oldfile)||isequal(oldfile,'') %loads the previously stored file name and set it as default in the file_input box |
---|
| 418 | dir_perso=prefdir; |
---|
| 419 | profil_perso=fullfile(dir_perso,'uvmat_perso.mat'); |
---|
| 420 | if exist(profil_perso,'file') |
---|
| 421 | h=load (profil_perso); |
---|
| 422 | if isfield(h,'MenuFile_1') |
---|
| 423 | oldfile=h.MenuFile_1; |
---|
| 424 | end |
---|
| 425 | end |
---|
| 426 | end |
---|
[421] | 427 | % [FileName, PathName] = uigetfile( ... |
---|
| 428 | % {'*.xml;*.xls;*.civ;*.png;*.jpg;*.tif;*.avi;*.AVI;*.vol;*.nc;*.cmx;*.fig;*.log;*.dat;*.bat;', ' (*.xml,*.xls,*.civ,*.jpg ,*.png, .tif, *.avi,*.vol,*.nc,*.cmx,*.fig,*.log,*.dat,*.bat)'; |
---|
| 429 | % '*.xml', '.xml files '; ... |
---|
| 430 | % '*.xls', '.xls files '; ... |
---|
| 431 | % '*.civ', '.civ files '; ... |
---|
| 432 | % '*.jpg',' jpeg image files'; ... |
---|
| 433 | % '*.png','.png image files'; ... |
---|
| 434 | % '*.tif','.tif image files'; ... |
---|
| 435 | % '*.avi;*.AVI','.avi movie files'; ... |
---|
| 436 | % '*.vol','.volume images (png)'; ... |
---|
| 437 | % '*.nc','.netcdf files'; ... |
---|
| 438 | % '*.cdf','.netcdf files'; ... |
---|
| 439 | % '*.cmx','.cmx text files ';... |
---|
| 440 | % '*.fig','.fig files (matlab fig)';... |
---|
| 441 | % '*.log','.log text files ';... |
---|
| 442 | % '*.dat','.dat text files ';... |
---|
| 443 | % '*.bat','.bat system command text files';... |
---|
| 444 | % '*.*', 'All Files (*.*)'}, ... |
---|
| 445 | % 'Pick a file',oldfile); |
---|
| 446 | |
---|
| 447 | [FileName, PathName] = uigetfile({'*.*','All Files(*.*)'},'Pick a file',oldfile); |
---|
[387] | 448 | fileinput=[PathName FileName];%complete file name |
---|
| 449 | sizf=size(fileinput); |
---|
| 450 | if (~ischar(fileinput)||~isequal(sizf(1),1)),return;end |
---|
| 451 | |
---|
| 452 | % display the selected field and related information |
---|
[406] | 453 | display_file_name( handles,fileinput) |
---|
[387] | 454 | |
---|
| 455 | % ----------------------------------------------------------------------- |
---|
| 456 | % --- Open again the file whose name has been recorded in MenuFile_1 |
---|
| 457 | function MenuFile_1_Callback(hObject, eventdata, handles) |
---|
| 458 | %------------------------------------------------------------------------ |
---|
| 459 | fileinput=get(handles.MenuFile_1,'Label'); |
---|
[406] | 460 | display_file_name( handles,fileinput) |
---|
[387] | 461 | |
---|
| 462 | % ----------------------------------------------------------------------- |
---|
| 463 | % --- Open again the file whose name has been recorded in MenuFile_2 |
---|
| 464 | function MenuFile_2_Callback(hObject, eventdata, handles) |
---|
| 465 | %------------------------------------------------------------------------ |
---|
| 466 | fileinput=get(handles.MenuFile_2,'Label'); |
---|
[406] | 467 | display_file_name(handles,fileinput) |
---|
[387] | 468 | |
---|
| 469 | % ----------------------------------------------------------------------- |
---|
| 470 | % --- Open again the file whose name has been recorded in MenuFile_3 |
---|
| 471 | function MenuFile_3_Callback(hObject, eventdata, handles) |
---|
| 472 | %------------------------------------------------------------------------ |
---|
| 473 | fileinput=get(handles.MenuFile_3,'Label'); |
---|
[406] | 474 | display_file_name(handles,fileinput) |
---|
[387] | 475 | |
---|
| 476 | % ----------------------------------------------------------------------- |
---|
| 477 | % --- Open again the file whose name has been recorded in MenuFile_4 |
---|
| 478 | function MenuFile_4_Callback(hObject, eventdata, handles) |
---|
| 479 | %------------------------------------------------------------------------ |
---|
| 480 | fileinput=get(handles.MenuFile_4,'Label'); |
---|
[406] | 481 | display_file_name(handles,fileinput) |
---|
[387] | 482 | |
---|
| 483 | % ----------------------------------------------------------------------- |
---|
| 484 | % --- Open again the file whose name has been recorded in MenuFile_5 |
---|
| 485 | function MenuFile_5_Callback(hObject, eventdata, handles) |
---|
| 486 | %------------------------------------------------------------------------ |
---|
| 487 | fileinput=get(handles.MenuFile_5,'Label'); |
---|
[406] | 488 | display_file_name(handles,fileinput) |
---|
[387] | 489 | |
---|
[402] | 490 | %------------------------------------------------------------------------ |
---|
| 491 | % --- Executes on the menu Open/Browse_1 for the second input field, |
---|
| 492 | % search the files, recognize their type according to their name and fill the rootfile input windows |
---|
| 493 | function MenuBrowse_1_Callback(hObject, eventdata, handles) |
---|
| 494 | %------------------------------------------------------------------------ |
---|
| 495 | RootPath=get(handles.RootPath,'String'); |
---|
[421] | 496 | % [FileName, PathName, filterindex] = uigetfile( ... |
---|
| 497 | % {'*.xml;*.xls;*.civ;*.jpg;*.png;*.avi;*.AVI;*.nc;*.cmx;*.fig;*.log;*.dat', ' (*.xml,*.xls,*.civ, *.jpg,*.png, *.avi,*.nc,*.cmx ,*.fig,*.log,*.dat)'; |
---|
| 498 | % '*.xml', '.xml files '; ... |
---|
| 499 | % '*.xls', '.xls files '; ... |
---|
| 500 | % '*.civ', '.civ files '; ... |
---|
| 501 | % '*.jpg','.jpg image files'; ... |
---|
| 502 | % '*.png','.png image files'; ... |
---|
| 503 | % '*.avi;*.AVI','.avi movie files'; ... |
---|
| 504 | % '*.nc','.netcdf files'; ... |
---|
| 505 | % '*.cdf','.netcdf files'; ... |
---|
| 506 | % '*.cmx','.cmx text files';... |
---|
| 507 | % '*.cmx2','.cmx2 text files';... |
---|
| 508 | % '*.fig','.fig files (matlab fig)';... |
---|
| 509 | % '*.log','.log text files ';... |
---|
| 510 | % '*.dat','.dat text files ';... |
---|
| 511 | % '*.*', 'All Files (*.*)'}, ... |
---|
| 512 | % 'Pick a second file for comparison',RootPath); |
---|
| 513 | [FileName, PathName] = uigetfile({'*.*','All Files(*.*)'},'Pick a file',RootPath); |
---|
[402] | 514 | fileinput_1=[PathName FileName];%complete file name |
---|
| 515 | sizf=size(fileinput_1); |
---|
| 516 | if (~ischar(fileinput_1)||~isequal(sizf(1),1)),return;end |
---|
| 517 | |
---|
| 518 | % refresh the current displayed field |
---|
| 519 | set(handles.SubField,'Value',1) |
---|
[406] | 520 | display_file_name(handles,fileinput_1,2) |
---|
[402] | 521 | |
---|
| 522 | %update list of recent files in the menubar |
---|
| 523 | MenuFile_1=fileinput_1; |
---|
| 524 | MenuFile_2=get(handles.MenuFile_1,'Label'); |
---|
| 525 | MenuFile_3=get(handles.MenuFile_2,'Label'); |
---|
| 526 | MenuFile_4=get(handles.MenuFile_3,'Label'); |
---|
| 527 | MenuFile_5=get(handles.MenuFile_4,'Label'); |
---|
| 528 | set(handles.MenuFile_1,'Label',MenuFile_1) |
---|
| 529 | set(handles.MenuFile_2,'Label',MenuFile_2) |
---|
| 530 | set(handles.MenuFile_3,'Label',MenuFile_3) |
---|
| 531 | set(handles.MenuFile_4,'Label',MenuFile_4) |
---|
| 532 | set(handles.MenuFile_5,'Label',MenuFile_5) |
---|
| 533 | set(handles.MenuFile_1_1,'Label',MenuFile_1) |
---|
| 534 | set(handles.MenuFile_2_1,'Label',MenuFile_2) |
---|
| 535 | set(handles.MenuFile_3_1,'Label',MenuFile_3) |
---|
| 536 | set(handles.MenuFile_4_1,'Label',MenuFile_4) |
---|
| 537 | set(handles.MenuFile_5_1,'Label',MenuFile_5) |
---|
| 538 | dir_perso=prefdir; |
---|
| 539 | profil_perso=fullfile(dir_perso,'uvmat_perso.mat'); |
---|
| 540 | if exist(profil_perso,'file') |
---|
| 541 | save (profil_perso,'MenuFile_1','MenuFile_2','MenuFile_3','MenuFile_4', 'MenuFile_5','-append'); %store the file names for future opening of uvmat |
---|
| 542 | else |
---|
| 543 | txt=ver('MATLAB'); |
---|
| 544 | Release=txt.Release; |
---|
| 545 | relnumb=str2double(Release(3:4)); |
---|
| 546 | if relnumb >= 14 |
---|
| 547 | save (profil_perso,'MenuFile_1','MenuFile_2','MenuFile_3','MenuFile_4', 'MenuFile_5','-V6'); %store the file names for future opening of uvmat |
---|
| 548 | else |
---|
| 549 | save (profil_perso,'MenuFile_1','MenuFile_2','MenuFile_3','MenuFile_4', 'MenuFile_5'); %store the file names for future opening of uvmat |
---|
| 550 | end |
---|
| 551 | end |
---|
| 552 | |
---|
| 553 | % ----------------------------------------------------------------------- |
---|
| 554 | % --- Open again as second field the file whose name has been recorded in MenuFile_1 |
---|
| 555 | function MenuFile_1_1_Callback(hObject, eventdata, handles) |
---|
| 556 | % ----------------------------------------------------------------------- |
---|
| 557 | fileinput_1=get(handles.MenuFile_1_1,'Label'); |
---|
| 558 | set(handles.SubField,'Value',1) |
---|
[406] | 559 | display_file_name(handles,fileinput_1,2) |
---|
[402] | 560 | |
---|
| 561 | % ----------------------------------------------------------------------- |
---|
| 562 | % --- Open again as second field the file whose name has been recorded in MenuFile_2 |
---|
| 563 | function MenuFile_2_1_Callback(hObject, eventdata, handles) |
---|
| 564 | % ----------------------------------------------------------------------- |
---|
| 565 | fileinput_1=get(handles.MenuFile_2_1,'Label'); |
---|
| 566 | set(handles.SubField,'Value',1) |
---|
[406] | 567 | display_file_name(handles,fileinput_1,2) |
---|
[402] | 568 | |
---|
| 569 | % ----------------------------------------------------------------------- |
---|
| 570 | % --- Open again as second field the file whose name has been recorded in MenuFile_3 |
---|
| 571 | function MenuFile_3_1_Callback(hObject, eventdata, handles) |
---|
| 572 | % ----------------------------------------------------------------------- |
---|
| 573 | fileinput_1=get(handles.MenuFile_3_1,'Label'); |
---|
| 574 | set(handles.SubField,'Value',1) |
---|
[406] | 575 | display_file_name(handles,fileinput_1,2) |
---|
[402] | 576 | |
---|
| 577 | % ----------------------------------------------------------------------- |
---|
| 578 | % --- Open again as second field the file whose name has been recorded in MenuFile_4 |
---|
| 579 | function MenuFile_4_1_Callback(hObject, eventdata, handles) |
---|
| 580 | % ----------------------------------------------------------------------- |
---|
| 581 | fileinput_1=get(handles.MenuFile_4_1,'Label'); |
---|
| 582 | set(handles.SubField,'Value',1) |
---|
[406] | 583 | display_file_name(handles,fileinput_1,2) |
---|
[402] | 584 | |
---|
| 585 | % ----------------------------------------------------------------------- |
---|
| 586 | % --- Open again as second field the file whose name has been recorded in MenuFile_5 |
---|
| 587 | function MenuFile_5_1_Callback(hObject, eventdata, handles) |
---|
| 588 | % ----------------------------------------------------------------------- |
---|
| 589 | fileinput_1=get(handles.MenuFile_5_1,'Label'); |
---|
| 590 | set(handles.SubField,'Value',1) |
---|
[406] | 591 | display_file_name(handles,fileinput_1,2) |
---|
[402] | 592 | |
---|
| 593 | %------------------------------------------------------------------------ |
---|
| 594 | % --- Called by action in RootPath edit box |
---|
| 595 | function RootPath_Callback(hObject,eventdata,handles) |
---|
| 596 | %------------------------------------------------------------------------ |
---|
| 597 | % read the current input file name: |
---|
| 598 | [RootPath,SubDir,RootFile,FileIndices,FileExt]=read_file_boxes(handles); |
---|
| 599 | % detect the file type, get the movie object if relevant, and look for the corresponding file series: |
---|
| 600 | [RootPath,SubDir,RootFile,i1_series,i2_series,j1_series,j2_series,tild,FileType,MovieObject]=find_file_series(fullfile(RootPath,SubDir),[RootFile FileIndices FileExt]); |
---|
| 601 | % initiate the input file series and refresh the current field view: |
---|
[406] | 602 | update_rootinfo(handles,i1_series,i2_series,j1_series,j2_series,FileType,MovieObject,1); |
---|
[402] | 603 | |
---|
| 604 | %----------------------------------------------------------------------- |
---|
| 605 | % --- Called by action in RootPath_1 edit box |
---|
| 606 | function RootPath_1_Callback(hObject,eventdata,handles) |
---|
| 607 | % ----------------------------------------------------------------------- |
---|
| 608 | % update_rootinfo_1(hObject,eventdata,handles) |
---|
| 609 | [RootPath,SubDir,RootFile,FileIndices,FileExt]=read_file_boxes_1(handles); |
---|
| 610 | % detect the file type, get the movie object if relevant, and look for the corresponding file series: |
---|
| 611 | [RootPath,SubDir,RootFile,i1_series,i2_series,j1_series,j2_series,tild,FileType,MovieObject]=find_file_series(fullfile(RootPath,SubDir),[RootFile FileIndices FileExt]); |
---|
| 612 | % initiate the input file series and refresh the current field view: |
---|
| 613 | update_rootinfo(handles,i1_series,i2_series,j1_series,j2_series,FileType,MovieObject,2); |
---|
| 614 | |
---|
| 615 | %------------------------------------------------------------------------ |
---|
| 616 | % --- Called by action in RootFile edit box |
---|
| 617 | function SubDir_Callback(hObject, eventdata, handles) |
---|
| 618 | %------------------------------------------------------------------------ |
---|
| 619 | %refresh the menu of input fields |
---|
| 620 | Fields_Callback(hObject, eventdata, handles); |
---|
| 621 | % refresh the current field view |
---|
| 622 | run0_Callback(hObject, eventdata, handles); |
---|
| 623 | |
---|
| 624 | %------------------------------------------------------------------------ |
---|
| 625 | % --- Called by action in RootFile edit box |
---|
| 626 | function RootFile_Callback(hObject, eventdata, handles) |
---|
| 627 | %------------------------------------------------------------------------ |
---|
| 628 | RootPath_Callback(hObject,eventdata,handles) |
---|
| 629 | |
---|
| 630 | %----------------------------------------------------------------------- |
---|
| 631 | % --- Called by action in RootFile_1 edit box |
---|
| 632 | function RootFile_1_Callback(hObject, eventdata, handles) |
---|
| 633 | % ----------------------------------------------------------------------- |
---|
| 634 | RootPath_1_Callback(hObject,eventdata,handles) |
---|
| 635 | |
---|
| 636 | %------------------------------------------------------------------------ |
---|
| 637 | % --- Called by action in FileIndex edit box |
---|
| 638 | function FileIndex_Callback(hObject, eventdata, handles) |
---|
| 639 | %------------------------------------------------------------------------ |
---|
| 640 | [tild,tild,tild,i1,i2,j1,j2]=fileparts_uvmat(get(handles.FileIndex,'String')); |
---|
| 641 | set(handles.i1,'String',num2str(i1)); |
---|
| 642 | set(handles.i2,'String',num2str(i2)); |
---|
| 643 | set(handles.j1,'String',num2str(j1)); |
---|
| 644 | set(handles.j2,'String',num2str(j2)); |
---|
| 645 | |
---|
| 646 | % refresh the current field view |
---|
| 647 | run0_Callback(hObject, eventdata, handles) |
---|
| 648 | |
---|
| 649 | %------------------------------------------------------------------------ |
---|
| 650 | % --- Called by action in FileIndex_1 edit box |
---|
| 651 | function FileIndex_1_Callback(hObject, eventdata, handles) |
---|
| 652 | %------------------------------------------------------------------------ |
---|
| 653 | run0_Callback(hObject, eventdata, handles) |
---|
| 654 | |
---|
| 655 | %------------------------------------------------------------------------ |
---|
| 656 | % --- Called by action in NomType edit box |
---|
| 657 | function NomType_Callback(hObject, eventdata, handles) |
---|
| 658 | %------------------------------------------------------------------------ |
---|
| 659 | i1=str2num(get(handles.i1,'String')); |
---|
| 660 | i2=str2num(get(handles.i2,'String')); |
---|
| 661 | j1=str2num(get(handles.j1,'String')); |
---|
| 662 | j2=str2num(get(handles.j2,'String')); |
---|
| 663 | FileIndex=fullfile_uvmat('','','','',get(handles.NomType,'String'),i1,i2,j1,j2); |
---|
| 664 | set(handles.FileIndex,'String',FileIndex) |
---|
| 665 | % refresh the current settings and refresh the field view |
---|
| 666 | RootPath_Callback(hObject,eventdata,handles) |
---|
| 667 | |
---|
| 668 | %------------------------------------------------------------------------ |
---|
| 669 | % --- Called by action in NomType edit box |
---|
| 670 | function NomType_1_Callback(hObject, eventdata, handles) |
---|
| 671 | %------------------------------------------------------------------------ |
---|
| 672 | i1=str2num(get(handles.i1,'String')); |
---|
| 673 | i2=str2num(get(handles.i2,'String')); |
---|
| 674 | j1=str2num(get(handles.j1,'String')); |
---|
| 675 | j2=str2num(get(handles.j2,'String')); |
---|
| 676 | FileIndex=fullfile_uvmat('','','','',get(handles.NomType_1,'String'),i1,i2,j1,j2); |
---|
| 677 | set(handles.FileIndex_1,'String',FileIndex) |
---|
| 678 | % refresh the current settings and refresh the field view |
---|
| 679 | RootPath_1_Callback(hObject,eventdata,handles) |
---|
| 680 | |
---|
[387] | 681 | %------------------------------------------------------------------------ |
---|
| 682 | % --- Fills the edit boxes RootPath, RootFile,NomType...from an input file name 'fileinput' |
---|
[406] | 683 | function display_file_name(handles,fileinput,index) |
---|
[387] | 684 | %------------------------------------------------------------------------ |
---|
| 685 | %% look for the input file existence |
---|
| 686 | if ~exist(fileinput,'file') |
---|
| 687 | msgbox_uvmat('ERROR',['input file ' fileinput ' does not exist']) |
---|
| 688 | return |
---|
| 689 | end |
---|
| 690 | |
---|
| 691 | %% set the mouse pointer to 'watch' |
---|
| 692 | set(handles.uvmat,'Pointer','watch') |
---|
| 693 | set(handles.RootPath,'BackgroundColor',[1 1 0]) |
---|
| 694 | drawnow |
---|
| 695 | |
---|
[406] | 696 | %% define the relevant handles for the first field series (index=1) or the second file series (index=2) |
---|
[387] | 697 | if ~exist('index','var') |
---|
| 698 | index=1; |
---|
| 699 | end |
---|
| 700 | if index==1 |
---|
| 701 | handles_RootPath=handles.RootPath; |
---|
| 702 | handles_SubDir=handles.SubDir; |
---|
| 703 | handles_RootFile=handles.RootFile; |
---|
| 704 | handles_FileIndex=handles.FileIndex; |
---|
| 705 | handles_NomType=handles.NomType; |
---|
| 706 | handles_FileExt=handles.FileExt; |
---|
| 707 | elseif index==2 |
---|
| 708 | handles_RootPath=handles.RootPath_1; |
---|
| 709 | handles_SubDir=handles.SubDir_1; |
---|
| 710 | handles_RootFile=handles.RootFile_1; |
---|
| 711 | handles_FileIndex=handles.FileIndex_1; |
---|
| 712 | handles_NomType=handles.NomType_1; |
---|
| 713 | handles_FileExt=handles.FileExt_1; |
---|
| 714 | set(handles.RootPath_1,'Visible','on') |
---|
| 715 | set(handles.RootFile_1,'Visible','on') |
---|
| 716 | set(handles.SubDir_1,'Visible','on'); |
---|
| 717 | set(handles.FileIndex_1,'Visible','on'); |
---|
| 718 | set(handles.FileExt_1,'Visible','on'); |
---|
| 719 | set(handles.NomType_1,'Visible','on'); |
---|
| 720 | end |
---|
| 721 | |
---|
| 722 | %% detect root name, nomenclature and indices in the input file name: |
---|
[398] | 723 | [FilePath,FileName,FileExt]=fileparts(fileinput); |
---|
[387] | 724 | % detect the file type, get the movie object if relevant, and look for the corresponding file series: |
---|
[398] | 725 | % the root name and indices may be corrected by including the first index i1 if a corresponding xml file exists |
---|
| 726 | [RootPath,SubDir,RootFile,i1_series,i2_series,j1_series,j2_series,NomType,FileType,MovieObject,i1,i2,j1,j2]=find_file_series(FilePath,[FileName FileExt]); |
---|
[387] | 727 | |
---|
| 728 | %% open the file or fill the GUI uvmat according to the detected file type |
---|
| 729 | switch FileType |
---|
| 730 | case '' |
---|
| 731 | msgbox_uvmat('ERROR','invalid input file type') |
---|
| 732 | case 'txt' |
---|
| 733 | edit(fileinput) |
---|
| 734 | case 'figure' %display matlab figure |
---|
| 735 | hfig=open(fileinput); |
---|
| 736 | set(hfig,'WindowButtonMotionFcn','mouse_motion')%set mouse action functio |
---|
| 737 | set(hfig,'WindowButtonUpFcn','mouse_up')%set mouse click action function |
---|
| 738 | set(hfig,'WindowButtonUpFcn','mouse_down')%set mouse click action function |
---|
| 739 | case {'xml','xls'} % edit xml or Excel files |
---|
| 740 | editxml(fileinput); |
---|
| 741 | otherwise |
---|
| 742 | set(handles_RootPath,'String',RootPath); |
---|
| 743 | rootname=fullfile(RootPath,SubDir,RootFile); |
---|
| 744 | set(handles_SubDir,'String',['/' SubDir]); |
---|
| 745 | set(handles_RootFile,'String',['/' RootFile]); %display the separator |
---|
| 746 | indices=fileinput(length(rootname)+1:end); |
---|
| 747 | indices(end-length(FileExt)+1:end)=[]; %remove extension |
---|
| 748 | set(handles_FileIndex,'String',indices); |
---|
| 749 | set(handles_NomType,'String',NomType); |
---|
| 750 | set(handles_FileExt,'String',FileExt); |
---|
| 751 | if index==1 |
---|
| 752 | % fill file index counters if the first file series is opened |
---|
| 753 | set(handles.i1,'String',num2str(i1)); |
---|
| 754 | set(handles.i2,'String',num2str(i2)); |
---|
| 755 | set(handles.j1,'String',num2stra(j1,NomType)); |
---|
| 756 | set(handles.j2,'String',num2stra(j2,NomType)); |
---|
| 757 | else %read the current field index if the second file series is opened |
---|
| 758 | i1=str2num(get(handles.i1,'String')); |
---|
| 759 | i2=str2num(get(handles.i2,'String')); |
---|
| 760 | j1=stra2num(get(handles.j1,'String')); |
---|
| 761 | j2=stra2num(get(handles.j2,'String')); |
---|
| 762 | end |
---|
| 763 | |
---|
| 764 | % synchronise indices of the second input file if it exists |
---|
| 765 | if get(handles.SubField,'Value')==1% if the subfield button is activated, update the field numbers |
---|
| 766 | Input=read_GUI(handles.InputFile); |
---|
| 767 | if ~isfield(Input,'RootPath_1')||strcmp(Input.RootPath_1,'"') |
---|
| 768 | Input.RootPath_1=Input.RootPath; |
---|
| 769 | end |
---|
| 770 | if ~isfield(Input,'SubDir_1')||strcmp(Input.SubDir_1,'"') |
---|
| 771 | Input.SubDir_1=Input.SubDir; |
---|
| 772 | end |
---|
| 773 | if ~isfield(Input,'RootFile_1')||strcmp(Input.RootFile_1,'"') |
---|
| 774 | Input.RootFile_1=Input.RootFile; |
---|
| 775 | end |
---|
[405] | 776 | if ~isfield(Input,'FileExt_1')||strcmp(Input.FileExt_1,'"') |
---|
| 777 | Input.FileExt_1=Input.FileExt; |
---|
| 778 | end |
---|
| 779 | if ~isfield(Input,'NomType_1')||strcmp(Input.NomType_1,'"') |
---|
| 780 | Input.NomType_1=Input.NomType; |
---|
| 781 | end |
---|
[387] | 782 | %updtate the indices of the second field series to correspond to the newly opened one |
---|
| 783 | FileName_1=fullfile_uvmat(Input.RootPath_1,Input.SubDir_1,Input.RootFile_1,Input.FileExt_1,Input.NomType_1,i1,i2,j1,j2); |
---|
| 784 | if exist(FileName_1,'file') |
---|
| 785 | FileIndex_1=fullfile_uvmat('','','','',Input.NomType_1,i1,i2,j1,j2); |
---|
| 786 | set(handles.FileIndex_1,'String',FileIndex_1) |
---|
| 787 | else |
---|
[408] | 788 | msgbox_uvmat('WARNING','unable to synchronise the indices of the two series') |
---|
| 789 | % set(handles.SubField,'Value',0) |
---|
| 790 | % SubField_Callback([], [], handles) |
---|
[387] | 791 | end |
---|
| 792 | end |
---|
| 793 | |
---|
| 794 | %enable other menus |
---|
| 795 | set(handles.MenuOpen_1,'Enable','on') |
---|
| 796 | set(handles.MenuFile_1_1,'Enable','on') |
---|
| 797 | set(handles.MenuFile_2_1,'Enable','on') |
---|
| 798 | set(handles.MenuFile_3_1,'Enable','on') |
---|
| 799 | set(handles.MenuFile_4_1,'Enable','on') |
---|
| 800 | set(handles.MenuFile_5_1,'Enable','on') |
---|
| 801 | set(handles.MenuExport,'Enable','on') |
---|
| 802 | set(handles.MenuExportFigure,'Enable','on') |
---|
| 803 | set(handles.MenuExportMovie,'Enable','on') |
---|
| 804 | set(handles.MenuTools,'Enable','on') |
---|
[424] | 805 | % set(handles.OBJECT_txt,'Visible','on') |
---|
| 806 | % set(handles.edit_object,'Visible','on') |
---|
| 807 | % set(handles.ListObject_1,'Visible','on') |
---|
| 808 | % set(handles.ViewObject,'Visible','on') |
---|
| 809 | % set(handles.frame_object,'Visible','on') |
---|
[387] | 810 | |
---|
| 811 | % initiate input file series and refresh the current field view: |
---|
| 812 | update_rootinfo(handles,i1_series,i2_series,j1_series,j2_series,FileType,MovieObject,index); |
---|
| 813 | |
---|
| 814 | end |
---|
| 815 | |
---|
| 816 | %% set back the mouse pointer to arrow |
---|
| 817 | set(handles.uvmat,'Pointer','arrow') |
---|
| 818 | |
---|
| 819 | |
---|
| 820 | %------------------------------------------------------------------------ |
---|
| 821 | % --- Update information about a new field series (indices to scan, timing, |
---|
| 822 | % calibration from an xml file, then refresh current plots |
---|
[397] | 823 | function update_rootinfo(handles,i1_series,i2_series,j1_series,j2_series,FileType,VideoObject,index) |
---|
[387] | 824 | %------------------------------------------------------------------------ |
---|
| 825 | %% define the relevant handles depending on the index (1=first file series, 2= second file series) |
---|
| 826 | if ~exist('index','var') |
---|
| 827 | index=1; |
---|
| 828 | end |
---|
| 829 | if index==1 |
---|
| 830 | handles_RootPath=handles.RootPath; |
---|
| 831 | handles_Fields=handles.Fields; |
---|
| 832 | elseif index==2 |
---|
| 833 | handles_RootPath=handles.RootPath_1; |
---|
| 834 | handles_Fields=handles.Fields_1; |
---|
| 835 | end |
---|
| 836 | |
---|
| 837 | set(handles_RootPath,'BackgroundColor',[1 1 0]) |
---|
| 838 | drawnow |
---|
| 839 | set(handles.Fields,'UserData',[])% reinialize data from uvmat opening |
---|
| 840 | UvData=get(handles.uvmat,'UserData');%huvmat=handles of the uvmat interface |
---|
| 841 | UvData.NewSeries=1; %flag for run0: begin a new series |
---|
| 842 | UvData.TestInputFile=1; |
---|
| 843 | UvData.FileType{index}=FileType; |
---|
| 844 | UvData.i1_series{index}=i1_series; |
---|
| 845 | UvData.i2_series{index}=i2_series; |
---|
| 846 | UvData.j1_series{index}=j1_series; |
---|
| 847 | UvData.j2_series{index}=j2_series; |
---|
| 848 | % set(handles.CheckFixPair,'Value',1) % activate by default the comp_input '-'input window |
---|
| 849 | set(handles.FixVelType,'Value',0); %desactivate fixed veltype |
---|
| 850 | if index==1 |
---|
| 851 | [RootPath,SubDir,RootFile,FileIndices,FileExt]=read_file_boxes(handles); |
---|
| 852 | else |
---|
| 853 | [RootPath,SubDir,RootFile,FileIndices,FileExt]=read_file_boxes_1(handles); |
---|
| 854 | end |
---|
| 855 | FileName=[fullfile(RootPath,SubDir,RootFile) FileIndices FileExt]; |
---|
| 856 | FileBase=fullfile(RootPath,RootFile); |
---|
| 857 | if ~exist(FileName,'file') |
---|
| 858 | msgbox_uvmat('ERROR',['input file ' FileName ' not found']); |
---|
| 859 | return |
---|
| 860 | end |
---|
| 861 | nbfield=[];%default |
---|
| 862 | nbfield_j=[];%default |
---|
| 863 | |
---|
| 864 | %% read timing and total frame number from the current file (movie files) !! may be overrid by xml file |
---|
| 865 | XmlData.Time=[];%default |
---|
| 866 | XmlData.GeometryCalib=[];%default |
---|
| 867 | TimeUnit=[];%default |
---|
| 868 | testima=0; %test for image input |
---|
| 869 | imainfo=[]; |
---|
| 870 | ColorType='falsecolor'; %default |
---|
[397] | 871 | hhh=[]; |
---|
| 872 | UvData.MovieObject{index}=VideoObject; |
---|
| 873 | if ~isempty(VideoObject) |
---|
| 874 | imainfo=get(VideoObject); |
---|
[387] | 875 | testima=1; |
---|
| 876 | nbfield_j=1; |
---|
| 877 | TimeUnit='s'; |
---|
[397] | 878 | XmlData.Time=(0:1/imainfo.FrameRate:(imainfo.NumberOfFrames-1)/imainfo.FrameRate)'; |
---|
| 879 | % % nbfield=imainfo.NumberOfFrames; |
---|
| 880 | set(handles.Dt_txt,'String',['Dt=' num2str(1000/imainfo.FrameRate) 'ms']);%display the elementary time interval in millisec |
---|
| 881 | ColorType='truecolor'; |
---|
[387] | 882 | elseif ~isempty(FileExt(2:end))&&(~isempty(imformats(FileExt(2:end))) || isequal(FileExt,'.vol'))%&& isequal(NomType,'*')% multi-frame image |
---|
| 883 | testima=1; |
---|
| 884 | if ~isequal(SubDir,'') |
---|
[397] | 885 | RootFile=get(handles.RootFile,'String'); |
---|
[387] | 886 | imainfo=imfinfo([fullfile(RootPath,SubDir,RootFile) FileIndices FileExt]); |
---|
| 887 | else |
---|
| 888 | imainfo=imfinfo([FileBase FileIndices FileExt]); |
---|
| 889 | end |
---|
| 890 | ColorType=imainfo.ColorType;%='truecolor' for color images |
---|
| 891 | if length(imainfo) >1 %case of image with multiple frames |
---|
| 892 | nbfield=length(imainfo); |
---|
| 893 | nbfield_j=1; |
---|
[397] | 894 | end |
---|
[387] | 895 | end |
---|
| 896 | if isfield(imainfo,'Width') && isfield(imainfo,'Height') |
---|
| 897 | if length(imainfo)>1 |
---|
| 898 | set(handles.num_Npx,'String',num2str(imainfo(1).Width));%fills nbre of pixels x box |
---|
| 899 | set(handles.num_Npy,'String',num2str(imainfo(1).Height));%fills nbre of pixels x box |
---|
| 900 | else |
---|
| 901 | set(handles.num_Npx,'String',num2str(imainfo.Width));%fills nbre of pixels x box |
---|
| 902 | set(handles.num_Npy,'String',num2str(imainfo.Height));%fills nbre of pixels x box |
---|
| 903 | end |
---|
| 904 | else |
---|
| 905 | set(handles.num_Npx,'String','');%fills nbre of pixels x box |
---|
| 906 | set(handles.num_Npy,'String','');%fills nbre of pixels x box |
---|
| 907 | end |
---|
| 908 | set(handles.CheckBW,'Value',strcmp(ColorType,'grayscale'))% select handles.CheckBW if grayscale image |
---|
| 909 | |
---|
| 910 | %% read parameters (time, geometric calibration..) from a documentation file (.xml advised) |
---|
[441] | 911 | SubDirBase=regexprep(SubDir,'\..*','');%take the root part of SubDir, before the first dot '.' |
---|
| 912 | filexml=fullfile(RootPath,[SubDirBase '.xml']);% new convention: xml above the image dir |
---|
| 913 | if ~exist(filexml,'file') |
---|
| 914 | filexml=fullfile(RootPath,SubDir,[RootFile '.xml']);%old convention: xml within the image directroy |
---|
| 915 | end |
---|
[387] | 916 | warntext='';%default warning message |
---|
| 917 | NbSlice=1;%default |
---|
| 918 | set(handles.RootPath,'BackgroundColor',[1 1 1]) |
---|
| 919 | if exist(filexml,'file') |
---|
| 920 | set(handles.view_xml,'Visible','on') |
---|
| 921 | set(handles.view_xml,'BackgroundColor',[1 1 0]) |
---|
| 922 | set(handles.view_xml,'String','view .xml') |
---|
| 923 | drawnow |
---|
| 924 | [XmlData,warntext]=imadoc2struct(filexml); |
---|
| 925 | if ~isempty(warntext) |
---|
| 926 | msgbox_uvmat('WARNING',warntext) |
---|
| 927 | end |
---|
| 928 | if isfield(XmlData,'TimeUnit') |
---|
| 929 | if isfield(XmlData,'TimeUnit')&& ~isempty(XmlData.TimeUnit) |
---|
| 930 | TimeUnit=XmlData.TimeUnit; |
---|
| 931 | end |
---|
| 932 | end |
---|
| 933 | set(handles.view_xml,'BackgroundColor',[1 1 1]) |
---|
| 934 | drawnow |
---|
| 935 | if isfield(XmlData, 'GeometryCalib') && ~isempty(XmlData.GeometryCalib) |
---|
| 936 | if isfield(XmlData.GeometryCalib,'VolumeScan') && isequal(XmlData.GeometryCalib.VolumeScan,'y') |
---|
| 937 | set (handles.nb_slice,'String','volume') |
---|
| 938 | end |
---|
| 939 | hgeometry_calib=findobj('tag','geometry_calib'); |
---|
| 940 | if ~isempty(hgeometry_calib) |
---|
| 941 | GUserData=get(hgeometry_calib,'UserData'); |
---|
| 942 | if ~(isfield(GUserData,'XmlInputFile') && strcmp(GUserData.XmlInputFile,filexml)) |
---|
| 943 | answer=msgbox_uvmat('INPUT_Y-N','replace the display of geometry_calib with the new input data?'); |
---|
| 944 | if strcmp(answer,'Yes') |
---|
| 945 | geometry_calib(filexml);%diplay the new calibration points and parameters in geometry_calib |
---|
| 946 | end |
---|
| 947 | end |
---|
| 948 | end |
---|
| 949 | end |
---|
| 950 | else |
---|
[441] | 951 | fileciv=fullfile(RootPath,SubDir,[RootFile '.civ']); |
---|
| 952 | if exist(fileciv,'file')% if .civ file found (very old convention) |
---|
| 953 | [error,XmlData.Time,TimeUnit,mode,npx,npy,pxcmx,pxcmy]=read_imatext(fileciv); |
---|
| 954 | GeometryCalib.R=[pxcmx 0 0; 0 pxcmy 0;0 0 0]; |
---|
| 955 | GeometryCalib.Tx=0; |
---|
| 956 | GeometryCalib.Ty=0; |
---|
| 957 | GeometryCalib.Tz=1; |
---|
| 958 | GeometryCalib.dpx=1; |
---|
| 959 | GeometryCalib.dpy=1; |
---|
| 960 | GeometryCalib.sx=1; |
---|
| 961 | GeometryCalib.Cx=0; |
---|
| 962 | GeometryCalib.Cy=0; |
---|
| 963 | GeometryCalib.f=1; |
---|
| 964 | GeometryCalib.kappa1=0; |
---|
| 965 | GeometryCalib.CoordUnit='cm'; |
---|
| 966 | XmlData.GeometryCalib=GeometryCalib; |
---|
| 967 | if error==2, warntext=['no file ' fileciv]; |
---|
| 968 | elseif error==1, warntext='inconsistent number of fields in the .civ file'; |
---|
| 969 | end |
---|
| 970 | set(handles.num_Npx,'String',num2str(npx));%fills nbre of pixels x box |
---|
| 971 | set(handles.num_Npy,'String',num2str(npy));%fills nbre of pixels y box |
---|
| 972 | set(handles.pxcm,'String',num2str(pxcmx));%fills scale x (pixel/cm) box |
---|
| 973 | set(handles.pycm,'String',num2str(pxcmy));%fills scale y (pixel/cm) box |
---|
| 974 | set(handles.pxcm,'Visible','on');%fills scale x (pixel/cm) box |
---|
| 975 | set(handles.pycm,'Visible','on');%fills scale y (pixel/cm) box |
---|
| 976 | set(handles.view_xml,'Visible','on') |
---|
| 977 | set(handles.view_xml,'String','view .civ') |
---|
| 978 | else |
---|
| 979 | set(handles.view_xml,'Visible','off') |
---|
| 980 | end |
---|
[387] | 981 | end |
---|
| 982 | |
---|
| 983 | %% store last index in handles.lat_i and .last_j |
---|
| 984 | nbfield=max(max(i2_series)); |
---|
| 985 | if isempty(nbfield) |
---|
| 986 | nbfield=max(max(i1_series)); |
---|
| 987 | end |
---|
| 988 | nbfield_j=max(max(j2_series)); |
---|
| 989 | if isempty(nbfield_j) |
---|
| 990 | nbfield_j=max(max(j1_series)); |
---|
| 991 | end |
---|
| 992 | if ~isempty(XmlData.Time) |
---|
| 993 | %transform .Time to a column vector if it is a line vector the nomenclature uses a single index |
---|
[441] | 994 | if isequal(size(XmlData.Time,1),1) |
---|
| 995 | % if isequal(nbfield,1) && ~isequal(nbfield_j,1)% .Time is a line vector |
---|
[387] | 996 | NomType=get(handles.NomType,'String'); |
---|
[441] | 997 | % if isempty(nbfield_j) |
---|
| 998 | % if numel(NomType)>=2 &&(strcmp(NomType,'_i')||strcmp(NomType(1:2),'%0')||strcmp(NomType(1:2),'_%')) |
---|
[387] | 999 | XmlData.Time=(XmlData.Time)'; |
---|
| 1000 | end |
---|
| 1001 | end |
---|
| 1002 | last_i_cell=get(handles.last_i,'String'); |
---|
| 1003 | if isempty(nbfield) |
---|
| 1004 | last_i_cell{1}=''; |
---|
| 1005 | else |
---|
| 1006 | last_i_cell{1}=num2str(nbfield); |
---|
| 1007 | end |
---|
| 1008 | set(handles.last_i,'String',last_i_cell) |
---|
| 1009 | last_j_cell=get(handles.last_j,'String'); |
---|
| 1010 | if isempty(nbfield_j) |
---|
| 1011 | last_j_cell{1}=''; |
---|
| 1012 | else |
---|
| 1013 | last_j_cell{1}=num2str(nbfield_j); |
---|
| 1014 | end |
---|
| 1015 | set(handles.last_j,'String',last_j_cell); |
---|
| 1016 | |
---|
| 1017 | %% store geometric calibration in UvData |
---|
| 1018 | if isfield(XmlData,'GeometryCalib') |
---|
| 1019 | GeometryCalib=XmlData.GeometryCalib; |
---|
| 1020 | if isempty(GeometryCalib) |
---|
| 1021 | set(handles.pxcm,'String','') |
---|
| 1022 | set(handles.pycm,'String','') |
---|
| 1023 | set(handles.transform_fct,'Value',1); % no transform by default |
---|
| 1024 | else |
---|
| 1025 | if (isfield(GeometryCalib,'R')&& ~isequal(GeometryCalib.R(2,1),0) && ~isequal(GeometryCalib.R(1,2),0)) ||... |
---|
| 1026 | (isfield(GeometryCalib,'kappa1')&& ~isequal(GeometryCalib.kappa1,0)) |
---|
| 1027 | set(handles.pxcm,'String','var') |
---|
| 1028 | set(handles.pycm,'String','var') |
---|
| 1029 | elseif isfield(GeometryCalib,'fx_fy') |
---|
| 1030 | pixcmx=GeometryCalib.fx_fy(1);%*GeometryCalib.R(1,1)*GeometryCalib.sx/(GeometryCalib.Tz*GeometryCalib.dpx); |
---|
| 1031 | pixcmy=GeometryCalib.fx_fy(2);%*GeometryCalib.R(2,2)/(GeometryCalib.Tz*GeometryCalib.dpy); |
---|
| 1032 | set(handles.pxcm,'String',num2str(pixcmx)) |
---|
| 1033 | set(handles.pycm,'String',num2str(pixcmy)) |
---|
| 1034 | end |
---|
| 1035 | if ~get(handles.CheckFixLimits,'Value') |
---|
| 1036 | set(handles.transform_fct,'Value',2); % phys transform by default if fixedLimits is off |
---|
| 1037 | end |
---|
| 1038 | if isfield(GeometryCalib,'SliceCoord') |
---|
| 1039 | |
---|
| 1040 | siz=size(GeometryCalib.SliceCoord); |
---|
| 1041 | if siz(1)>1 |
---|
| 1042 | NbSlice=siz(1); |
---|
| 1043 | set(handles.slices,'Visible','on') |
---|
| 1044 | set(handles.slices,'Value',1) |
---|
| 1045 | end |
---|
| 1046 | if isfield(GeometryCalib,'VolumeScan') && isequal(GeometryCalib.VolumeScan,'y') |
---|
| 1047 | set(handles.nb_slice,'String','volume') |
---|
| 1048 | else |
---|
| 1049 | set(handles.nb_slice,'String',num2str(NbSlice)) |
---|
| 1050 | end |
---|
| 1051 | slices_Callback([],[], handles) |
---|
| 1052 | end |
---|
| 1053 | end |
---|
| 1054 | end |
---|
| 1055 | |
---|
| 1056 | %% update the data attached to the uvmat interface |
---|
| 1057 | if ~isempty(TimeUnit) |
---|
| 1058 | set(handles.time_txt,'String',['time (' TimeUnit ')']) |
---|
| 1059 | end |
---|
| 1060 | UvData.TimeUnit=TimeUnit; |
---|
| 1061 | UvData.XmlData{index}=XmlData; |
---|
| 1062 | UvData.NewSeries=1; |
---|
| 1063 | % UvData.MovieObject=MovieObject; |
---|
| 1064 | |
---|
| 1065 | %display warning message |
---|
| 1066 | if ~isequal(warntext,'') |
---|
| 1067 | msgbox_uvmat('WARNING',warntext); |
---|
| 1068 | end |
---|
| 1069 | |
---|
| 1070 | %% set default options in menu 'Fields' |
---|
| 1071 | if ~testima |
---|
| 1072 | testcivx=0; |
---|
| 1073 | if isfield(UvData,'FieldsString') && isequal(UvData.FieldsString,{'get_field...'})% field menu defined as input (from get_field) |
---|
| 1074 | set(handles_Fields,'Value',1) |
---|
| 1075 | set(handles_Fields,'String',{'get_field...'}) |
---|
| 1076 | UvData=rmfield(UvData,'FieldsString'); |
---|
| 1077 | else |
---|
| 1078 | Data=nc2struct(FileName,'ListGlobalAttribute','Conventions','absolut_time_T0','civ'); |
---|
| 1079 | if strcmp(Data.Conventions,'uvmat/civdata') ||( ~isempty(Data.absolut_time_T0)&& ~isequal(Data.civ,0))%if the new input is Civx |
---|
| 1080 | FieldList=calc_field; |
---|
| 1081 | set(handles_Fields,'String',[{'image'};FieldList;{'get_field...'}]);%standard menu for civx data |
---|
| 1082 | set(handles_Fields,'Value',2) % set menu to 'velocity' |
---|
| 1083 | col_vec=FieldList; |
---|
| 1084 | col_vec(1)=[];%remove 'velocity' option for vector color (must be a scalar) |
---|
| 1085 | testcivx=1; |
---|
| 1086 | end |
---|
| 1087 | if ~testcivx |
---|
| 1088 | set(handles_Fields,'Value',1) % set menu to 'get_field... |
---|
| 1089 | set(handles_Fields,'String',{'get_field...'}) |
---|
| 1090 | col_vec={'get_field...'}; |
---|
| 1091 | end |
---|
[405] | 1092 | set(handles.ColorScalar,'String',col_vec) |
---|
[387] | 1093 | end |
---|
| 1094 | end |
---|
| 1095 | set(handles.uvmat,'UserData',UvData) |
---|
| 1096 | |
---|
| 1097 | %% set index navigation options and refresh plots |
---|
| 1098 | scan_option='i';%default |
---|
| 1099 | state_j='off'; %default |
---|
| 1100 | if index==2 |
---|
| 1101 | if get(handles.scan_j,'Value') |
---|
| 1102 | scan_option='j'; %keep the scan option for the second fiel series |
---|
| 1103 | end |
---|
| 1104 | if strcmp(get(handles.j1,'Visible'),'on') |
---|
| 1105 | state_j='on'; |
---|
| 1106 | end |
---|
| 1107 | end |
---|
| 1108 | if ~isempty(j1_series) |
---|
| 1109 | state_j='on'; |
---|
| 1110 | if isequal(nbfield,1) &&index==1 |
---|
| 1111 | scan_option='j'; %scan j index by default if nbfield=1 |
---|
| 1112 | end |
---|
| 1113 | end |
---|
| 1114 | if isequal(scan_option,'i') |
---|
| 1115 | set(handles.scan_i,'Value',1) |
---|
| 1116 | scan_i_Callback([],[], handles); |
---|
| 1117 | else |
---|
| 1118 | set(handles.scan_j,'Value',1) |
---|
| 1119 | scan_j_Callback([],[], handles); |
---|
| 1120 | end |
---|
| 1121 | set(handles.scan_j,'Visible',state_j) |
---|
| 1122 | set(handles.j1,'Visible',state_j) |
---|
| 1123 | set(handles.j2,'Visible',state_j) |
---|
| 1124 | set(handles.last_j,'Visible',state_j); |
---|
| 1125 | set(handles.frame_j,'Visible',state_j); |
---|
| 1126 | set(handles.j_text,'Visible',state_j); |
---|
| 1127 | if ~isempty(i2_series)||~isempty(j2_series) |
---|
| 1128 | set(handles.CheckFixPair,'Visible','on') |
---|
| 1129 | elseif index==1 |
---|
| 1130 | set(handles.CheckFixPair,'Visible','off') |
---|
| 1131 | end |
---|
| 1132 | |
---|
| 1133 | %% view the field |
---|
| 1134 | run0_Callback([],[], handles); %view field |
---|
| 1135 | mask_test=get(handles.CheckMask,'value'); |
---|
| 1136 | if mask_test |
---|
| 1137 | MaskData=get(handles.CheckMask,'UserData'); |
---|
| 1138 | if isfield(MaskData,'maskhandle') && ishandle(MaskData.maskhandle) |
---|
| 1139 | delete(MaskData.maskhandle) %delete old mask |
---|
| 1140 | end |
---|
| 1141 | CheckMask_Callback([],[],handles) |
---|
| 1142 | end |
---|
| 1143 | |
---|
[406] | 1144 | %% update list of recent files in the menubar and save it for future opening |
---|
[387] | 1145 | MenuFile=[{get(handles.MenuFile_1,'Label')};{get(handles.MenuFile_2,'Label')};... |
---|
| 1146 | {get(handles.MenuFile_3,'Label')};{get(handles.MenuFile_4,'Label')};{get(handles.MenuFile_5,'Label')}]; |
---|
| 1147 | str_find=strcmp(FileName,MenuFile); |
---|
| 1148 | if isempty(find(str_find,1)) |
---|
| 1149 | MenuFile=[{FileName};MenuFile];%insert the current file if not already in the list |
---|
| 1150 | end |
---|
| 1151 | for ifile=1:min(length(MenuFile),5) |
---|
| 1152 | eval(['set(handles.MenuFile_' num2str(ifile) ',''Label'',MenuFile{ifile});']) |
---|
| 1153 | eval(['set(handles.MenuFile_' num2str(ifile) '_1,''Label'',MenuFile{ifile});']) |
---|
| 1154 | end |
---|
| 1155 | dir_perso=prefdir; |
---|
| 1156 | profil_perso=fullfile(dir_perso,'uvmat_perso.mat'); |
---|
| 1157 | if exist(profil_perso,'file') |
---|
| 1158 | save (profil_perso,'MenuFile','-append'); %store the file names for future opening of uvmat |
---|
| 1159 | else |
---|
| 1160 | save (profil_perso,'MenuFile','-V6'); %store the file names for future opening of uvmat |
---|
| 1161 | end |
---|
| 1162 | |
---|
| 1163 | |
---|
| 1164 | %------------------------------------------------------------------------ |
---|
| 1165 | % --- switch file index scanning options scan_i and scan_j in an exclusive way |
---|
| 1166 | function scan_i_Callback(hObject, eventdata, handles) |
---|
| 1167 | %------------------------------------------------------------------------ |
---|
| 1168 | if get(handles.scan_i,'Value')==1 |
---|
| 1169 | set(handles.scan_i,'BackgroundColor',[1 1 0]) |
---|
| 1170 | set(handles.scan_j,'Value',0) |
---|
| 1171 | else |
---|
| 1172 | set(handles.scan_i,'BackgroundColor',[0.831 0.816 0.784]) |
---|
| 1173 | set(handles.scan_j,'Value',1) |
---|
| 1174 | end |
---|
| 1175 | scan_j_Callback(hObject, eventdata, handles) |
---|
| 1176 | |
---|
| 1177 | %------------------------------------------------------------------------ |
---|
| 1178 | % --- switch file index scanning options scan_i and scan_j in an exclusive way |
---|
| 1179 | function scan_j_Callback(hObject, eventdata, handles) |
---|
| 1180 | %------------------------------------------------------------------------ |
---|
| 1181 | if get(handles.scan_j,'Value')==1 |
---|
| 1182 | set(handles.scan_j,'BackgroundColor',[1 1 0]) |
---|
| 1183 | set(handles.scan_i,'Value',0) |
---|
| 1184 | set(handles.scan_i,'BackgroundColor',[0.831 0.816 0.784]) |
---|
| 1185 | % NomType=get(handles.NomType,'String'); |
---|
| 1186 | % switch NomType |
---|
| 1187 | % case {'_1_1-2','#_ab','%3dab'},% pair with j index |
---|
| 1188 | % set(handles.CheckFixPair,'Visible','on')% option fixed pair on/off made visible (choice of avaible pair with buttons + and - if ='off') |
---|
| 1189 | % otherwise |
---|
| 1190 | % set(handles.CheckFixPair,'Visible','off') |
---|
| 1191 | % end |
---|
| 1192 | else |
---|
| 1193 | set(handles.scan_j,'BackgroundColor',[0.831 0.816 0.784]) |
---|
| 1194 | set(handles.scan_i,'Value',1) |
---|
| 1195 | set(handles.scan_i,'BackgroundColor',[1 1 0]) |
---|
| 1196 | set(handles.CheckFixPair,'Visible','off') |
---|
| 1197 | end |
---|
| 1198 | |
---|
| 1199 | %------------------------------------------------------------------------ |
---|
| 1200 | function i1_Callback(hObject, eventdata, handles) |
---|
| 1201 | %------------------------------------------------------------------------ |
---|
| 1202 | set(handles.i1,'BackgroundColor',[0.7 0.7 0.7]) |
---|
| 1203 | NomType=get(handles.NomType,'String'); |
---|
| 1204 | i1=stra2num(get(handles.i1,'String')); |
---|
| 1205 | i2=stra2num(get(handles.i2,'String')); |
---|
| 1206 | j1=stra2num(get(handles.j1,'String')); |
---|
| 1207 | j2=stra2num(get(handles.j2,'String')); |
---|
| 1208 | indices=fullfile_uvmat('','','','',NomType,i1,i2,j1,j2); |
---|
| 1209 | %indices=name_generator('',num1,num_a,'',NomType,1,num2,num_b,''); |
---|
| 1210 | set(handles.FileIndex,'String',indices) |
---|
| 1211 | set(handles.FileIndex,'BackgroundColor',[0.7 0.7 0.7]) |
---|
| 1212 | if get(handles.SubField,'Value')==1 |
---|
| 1213 | NomType_1=get(handles.NomType_1,'String'); |
---|
| 1214 | indices=fullfile_uvmat('','','','',NomType,i1,i2,j1,j2); |
---|
| 1215 | %indices=name_generator('',num1,num_a,'',NomType_1,1,num2,num_b,''); |
---|
| 1216 | set(handles.FileIndex_1,'String',indices) |
---|
| 1217 | set(handles.FileIndex_1,'BackgroundColor',[0.7 0.7 0.7]) |
---|
| 1218 | end |
---|
| 1219 | |
---|
| 1220 | %------------------------------------------------------------------------ |
---|
| 1221 | function i2_Callback(hObject, eventdata, handles) |
---|
| 1222 | %------------------------------------------------------------------------ |
---|
| 1223 | set(handles.i2,'BackgroundColor',[0.7 0.7 0.7]) |
---|
| 1224 | i1_Callback(hObject, eventdata, handles) |
---|
| 1225 | |
---|
| 1226 | %------------------------------------------------------------------------ |
---|
| 1227 | function j1_Callback(hObject, eventdata, handles) |
---|
| 1228 | %------------------------------------------------------------------------ |
---|
| 1229 | set(handles.j1,'BackgroundColor',[0.7 0.7 0.7]) |
---|
| 1230 | i1_Callback(hObject, eventdata, handles) |
---|
| 1231 | |
---|
| 1232 | %------------------------------------------------------------------------ |
---|
| 1233 | function j2_Callback(hObject, eventdata, handles) |
---|
| 1234 | %------------------------------------------------------------------------ |
---|
| 1235 | set(handles.j2,'BackgroundColor',[0.7 0.7 0.7]) |
---|
| 1236 | i1_Callback(hObject, eventdata, handles) |
---|
| 1237 | |
---|
| 1238 | %------------------------------------------------------------------------ |
---|
| 1239 | function slices_Callback(hObject, eventdata, handles) |
---|
| 1240 | %------------------------------------------------------------------------ |
---|
| 1241 | if get(handles.slices,'Value')==1 |
---|
| 1242 | set(handles.slices,'BackgroundColor',[1 1 0]) |
---|
| 1243 | set(handles.nb_slice,'Visible','on') |
---|
| 1244 | set(handles.z_text,'Visible','on') |
---|
| 1245 | set(handles.z_index,'Visible','on') |
---|
| 1246 | nb_slice_Callback(hObject, eventdata, handles) |
---|
| 1247 | else |
---|
| 1248 | set(handles.nb_slice,'Visible','off') |
---|
| 1249 | set(handles.slices,'BackgroundColor',[0.7 0.7 0.7]) |
---|
| 1250 | set(handles.z_text,'Visible','off') |
---|
| 1251 | set(handles.z_index,'Visible','off') |
---|
| 1252 | set(handles.masklevel,'Value',1) |
---|
| 1253 | set(handles.masklevel,'String',{'1'}) |
---|
| 1254 | end |
---|
| 1255 | |
---|
| 1256 | %------------------------------------------------------------------------ |
---|
| 1257 | function nb_slice_Callback(hObject, eventdata, handles) |
---|
| 1258 | %------------------------------------------------------------------------ |
---|
| 1259 | nb_slice_str=get(handles.nb_slice,'String'); |
---|
| 1260 | if isequal(nb_slice_str,'volume') |
---|
| 1261 | num=stra2num(get(handles.j1,'String')); |
---|
| 1262 | last_j=get(handles.last_j,'String'); |
---|
| 1263 | nbslice=str2double(last_j{1}); |
---|
| 1264 | else |
---|
| 1265 | num=str2double(get(handles.i1,'String')); |
---|
| 1266 | nbslice=str2double(get(handles.nb_slice,'String')); |
---|
| 1267 | end |
---|
| 1268 | z=mod(num-1,nbslice)+1; |
---|
| 1269 | set(handles.z_index,'String',num2str(z)) |
---|
| 1270 | for ilist=1:nbslice |
---|
| 1271 | list_index{ilist,1}=num2str(ilist); |
---|
| 1272 | end |
---|
| 1273 | set(handles.masklevel,'String',list_index) |
---|
| 1274 | set(handles.masklevel,'Value',z) |
---|
| 1275 | |
---|
| 1276 | %------------------------------------------------------------------------ |
---|
| 1277 | % --- Executes on button press in view_xml. |
---|
| 1278 | function view_xml_Callback(hObject, eventdata, handles) |
---|
| 1279 | %------------------------------------------------------------------------ |
---|
| 1280 | %[FileName,RootPath,FileBase,FileIndices,FileExt]=read_file_boxes(handles); |
---|
| 1281 | [RootPath,SubDir,RootFile,FileIndices,FileExt]=read_file_boxes(handles); |
---|
| 1282 | FileBase=fullfile(RootPath,RootFile); |
---|
| 1283 | option=get(handles.view_xml,'String'); |
---|
| 1284 | if isequal(option,'view .xml') |
---|
| 1285 | FileXml=[FileBase '.xml']; |
---|
| 1286 | heditxml=editxml(FileXml); |
---|
| 1287 | end |
---|
| 1288 | |
---|
| 1289 | %------------------------------------------------------------------------ |
---|
| 1290 | % --- Executes on button press in CheckMask. |
---|
| 1291 | function CheckMask_Callback(hObject, eventdata, handles) |
---|
| 1292 | %------------------------------------------------------------------------ |
---|
| 1293 | %case of view mask selection |
---|
| 1294 | if isequal(get(handles.CheckMask,'Value'),1) |
---|
| 1295 | % [FF,RootPath,FileBase]=read_file_boxes(handles); |
---|
| 1296 | [RootPath,SubDir,RootFile,FileIndices,FileExt]=read_file_boxes(handles); |
---|
| 1297 | FileBase=fullfile(RootPath,RootFile); |
---|
| 1298 | num_i1=stra2num(get(handles.i1,'String')); |
---|
| 1299 | num_j1=stra2num(get(handles.j1,'String')); |
---|
| 1300 | currentdir=pwd; |
---|
| 1301 | cd(RootPath); |
---|
| 1302 | maskfiles=dir('*_*mask_*.png');%look for a mask file |
---|
| 1303 | cd(currentdir);%come back to the working directory |
---|
| 1304 | mdetect=0; |
---|
| 1305 | if ~isempty(maskfiles) |
---|
| 1306 | for ilist=1:length(maskfiles) |
---|
| 1307 | maskname=maskfiles(ilist).name;% take the first mask file in the list |
---|
| 1308 | [tild,tild,tild,tild,tild,tild,tild,MaskExt,Mask_NomType{ilist}]=fileparts_uvmat(maskname); |
---|
| 1309 | % [rr,ff,x1,x2,xa,xb,xext,Mask_NomType{ilist}]=name2display(maskname); |
---|
| 1310 | [tild,Name]=fileparts(maskname); |
---|
| 1311 | Namedouble=double(Name); |
---|
| 1312 | val=(48>Namedouble)|(Namedouble>57);% select the non-numerical characters |
---|
| 1313 | ind_mask=findstr('mask',Name); |
---|
| 1314 | i=ind_mask-1; |
---|
| 1315 | while val(i)==0 && i>0 |
---|
| 1316 | i=i-1; |
---|
| 1317 | end |
---|
| 1318 | nbmask_str=str2num(Name(i+1:ind_mask-1)); |
---|
| 1319 | if ~isempty(nbmask_str) |
---|
| 1320 | nbslice(ilist)=nbmask_str; % number of different masks (slices) |
---|
| 1321 | end |
---|
| 1322 | end |
---|
| 1323 | if isequal(min(nbslice),max(nbslice)) |
---|
| 1324 | nbslice=nbslice(1); |
---|
| 1325 | else |
---|
| 1326 | msgbox_uvmat('ERROR','several inconsistent mask sets coexist in the current image directory') |
---|
| 1327 | return |
---|
| 1328 | end |
---|
| 1329 | if ~isempty(nbslice) && Name(i)=='_' |
---|
| 1330 | Mask.Base=[FileBase Name(i:ind_mask+3)]; |
---|
| 1331 | Mask.NbSlice=nbslice; |
---|
| 1332 | num_i1=mod(num_i1-1,nbslice)+1; |
---|
| 1333 | Mask.NomType=regexprep(Mask_NomType{1},'0','');%remove '0' in nom type for masks |
---|
| 1334 | [RootPath,RootFile]=fileparts(Mask.Base); |
---|
| 1335 | maskname=fullfile_uvmat(RootPath,'',RootFile,'.png',Mask.NomType,num_i1,[],num_j1); |
---|
| 1336 | %maskname=name_generator(Mask.Base,num_i1,num_j1,'.png',Mask.NomType);% |
---|
| 1337 | mdetect=exist(maskname,'file'); |
---|
| 1338 | if mdetect |
---|
| 1339 | set(handles.nb_slice,'String',Name(i+1:ind_mask-1)); |
---|
| 1340 | set(handles.nb_slice,'BackgroundColor',[1 1 0]) |
---|
| 1341 | set(handles.CheckMask,'UserData',Mask); |
---|
| 1342 | set(handles.CheckMask,'BackgroundColor',[1 1 0]) |
---|
| 1343 | if nbslice > 1 |
---|
| 1344 | set(handles.slices,'value',1) |
---|
| 1345 | slices_Callback(hObject, eventdata, handles) |
---|
| 1346 | end |
---|
| 1347 | end |
---|
| 1348 | end |
---|
| 1349 | end |
---|
| 1350 | errormsg=[];%default |
---|
| 1351 | if mdetect==0 |
---|
| 1352 | [FileName, PathName, filterindex] = uigetfile( ... |
---|
| 1353 | {'*.png', ' (*.png)'; |
---|
| 1354 | '*.png', '.png files '; ... |
---|
| 1355 | '*.*', 'All Files (*.*)'}, ... |
---|
| 1356 | 'Pick a mask file *.png',FileBase); |
---|
| 1357 | maskname=fullfile(PathName,FileName); |
---|
| 1358 | if ~exist(maskname,'file') |
---|
| 1359 | errormsg='no file browsed'; |
---|
| 1360 | end |
---|
| 1361 | [RootDir,tild,RootFile,tild,tild,tild,tild,tild,Mask.NomType]=fileparts_uvmat(maskname); |
---|
| 1362 | % [RootDir,RootFile,x1,x2,xa,xb,xext,Mask.NomType]=name2display(maskname); |
---|
| 1363 | Mask.Base=fullfile(RootDir,RootFile); |
---|
| 1364 | Mask.NbSlice=1; |
---|
| 1365 | set(handles.CheckMask,'UserData',Mask); |
---|
| 1366 | set(handles.CheckMask,'BackgroundColor',[1 1 0]) |
---|
| 1367 | end |
---|
| 1368 | if isempty(errormsg) |
---|
| 1369 | errormsg=update_mask(handles,num_i1,num_j1); |
---|
| 1370 | end |
---|
| 1371 | if ~isempty(errormsg) |
---|
| 1372 | set(handles.CheckMask,'Value',0) |
---|
| 1373 | set(handles.CheckMask,'BackgroundColor',[0.7 0.7 0.7]) |
---|
| 1374 | end |
---|
| 1375 | else % desactivate mask display |
---|
| 1376 | MaskData=get(handles.CheckMask,'UserData'); |
---|
| 1377 | if isfield(MaskData,'maskhandle') && ishandle(MaskData.maskhandle) |
---|
| 1378 | delete(MaskData.maskhandle) |
---|
| 1379 | end |
---|
| 1380 | set(handles.CheckMask,'UserData',[]) |
---|
| 1381 | UvData=get(handles.uvmat,'UserData'); |
---|
| 1382 | if isfield(UvData,'MaskName') |
---|
| 1383 | UvData=rmfield(UvData,'MaskName'); |
---|
| 1384 | set(handles.uvmat,'UserData',UvData) |
---|
| 1385 | end |
---|
| 1386 | set(handles.CheckMask,'BackgroundColor',[0.7 0.7 0.7]) |
---|
| 1387 | end |
---|
| 1388 | |
---|
| 1389 | %------------------------------------------------------------------------ |
---|
| 1390 | function errormsg=update_mask(handles,num_i1,num_j1) |
---|
| 1391 | %------------------------------------------------------------------------ |
---|
| 1392 | errormsg=[];%default |
---|
| 1393 | MaskData=get(handles.CheckMask,'UserData'); |
---|
| 1394 | if isfield(MaskData,'maskhandle')&& ishandle(MaskData.maskhandle) |
---|
| 1395 | uistack(MaskData.maskhandle,'top'); |
---|
| 1396 | end |
---|
| 1397 | num_i1_mask=mod(num_i1-1,MaskData.NbSlice)+1; |
---|
| 1398 | [RootPath,RootFile]=fileparts(MaskData.Base); |
---|
| 1399 | MaskName=fullfile_uvmat(RootPath,'',RootFile,'.png',MaskData.NomType,num_i1_mask,[],num_j1); |
---|
| 1400 | %MaskName=name_generator(MaskData.Base,num_i1_mask,num_j1,'.png',MaskData.NomType); |
---|
| 1401 | % huvmat=get(handles.CheckMask,'parent'); |
---|
| 1402 | UvData=get(handles.uvmat,'UserData'); |
---|
| 1403 | %update mask image if the mask is new |
---|
| 1404 | if ~ (isfield(UvData,'MaskName') && isequal(UvData.MaskName,MaskName)) |
---|
| 1405 | UvData.MaskName=MaskName; %update the recorded name on UvData |
---|
| 1406 | set(handles.uvmat,'UserData',UvData); |
---|
| 1407 | if ~exist(MaskName,'file') |
---|
| 1408 | if isfield(MaskData,'maskhandle')&& ishandle(MaskData.maskhandle) |
---|
| 1409 | delete(MaskData.maskhandle) |
---|
| 1410 | end |
---|
| 1411 | else |
---|
| 1412 | %read mask image |
---|
| 1413 | Mask.AName='image'; |
---|
| 1414 | Mask.A=imread(MaskName); |
---|
| 1415 | npxy=size(Mask.A); |
---|
| 1416 | test_error=0; |
---|
| 1417 | if length(npxy)>2 |
---|
| 1418 | errormsg=[MaskName ' is not a grey scale image']; |
---|
| 1419 | return |
---|
| 1420 | elseif ~isa(Mask.A,'uint8') |
---|
| 1421 | errormsg=[MaskName ' is not a 8 bit grey level image']; |
---|
| 1422 | return |
---|
| 1423 | end |
---|
| 1424 | Mask.AX=[0.5 npxy(2)-0.5]; |
---|
| 1425 | Mask.AY=[npxy(1)-0.5 0.5 ]; |
---|
| 1426 | Mask.CoordUnit='pixel'; |
---|
| 1427 | if isequal(get(handles.slices,'Value'),1) |
---|
| 1428 | NbSlice=str2num(get(handles.nb_slice,'String')); |
---|
| 1429 | num_i1=str2num(get(handles.i1,'String')); |
---|
| 1430 | Mask.ZIndex=mod(num_i1-1,NbSlice)+1; |
---|
| 1431 | end |
---|
| 1432 | %px to phys or other transform on field |
---|
| 1433 | menu_transform=get(handles.transform_fct,'String'); |
---|
| 1434 | choice_value=get(handles.transform_fct,'Value'); |
---|
| 1435 | transform_name=menu_transform{choice_value};%name of the transform fct given by the menu 'transform_fct' |
---|
| 1436 | transform_list=get(handles.transform_fct,'UserData'); |
---|
| 1437 | transform=transform_list{choice_value}; |
---|
| 1438 | if ~isequal(transform_name,'') && ~isequal(transform_name,'px') |
---|
| 1439 | if isfield(UvData,'XmlData') && isfield(UvData.XmlData{1},'GeometryCalib')%use geometry calib recorded from the ImaDoc xml file as first priority |
---|
| 1440 | Calib=UvData.XmlData{1}.GeometryCalib; |
---|
| 1441 | Mask=transform(Mask,UvData.XmlData{1}); |
---|
| 1442 | end |
---|
| 1443 | end |
---|
| 1444 | flagmask=Mask.A < 200; |
---|
| 1445 | |
---|
| 1446 | %make brown color image |
---|
| 1447 | imflag(:,:,1)=0.9*flagmask; |
---|
| 1448 | imflag(:,:,2)=0.7*flagmask; |
---|
| 1449 | imflag(:,:,3)=zeros(size(flagmask)); |
---|
| 1450 | |
---|
| 1451 | %update mask image |
---|
| 1452 | hmask=[]; %default |
---|
| 1453 | if isfield(MaskData,'maskhandle')&& ishandle(MaskData.maskhandle) |
---|
| 1454 | hmask=MaskData.maskhandle; |
---|
| 1455 | end |
---|
| 1456 | if ~isempty(hmask) |
---|
| 1457 | set(hmask,'CData',imflag) |
---|
| 1458 | set(hmask,'AlphaData',flagmask*0.6) |
---|
| 1459 | set(hmask,'XData',Mask.AX); |
---|
| 1460 | set(hmask,'YData',Mask.AY); |
---|
| 1461 | % uistack(hmask,'top') |
---|
| 1462 | else |
---|
| 1463 | axes(handles.axes3) |
---|
| 1464 | hold on |
---|
| 1465 | MaskData.maskhandle=image(Mask.AX,Mask.AY,imflag,'Tag','mask','HitTest','off','AlphaData',0.6*flagmask); |
---|
| 1466 | % set(MaskData.maskhandle,'AlphaData',0.6*flagmask) |
---|
| 1467 | set(handles.CheckMask,'UserData',MaskData) |
---|
| 1468 | end |
---|
| 1469 | end |
---|
| 1470 | end |
---|
| 1471 | |
---|
| 1472 | %------------------------------------------------------------------------ |
---|
| 1473 | %------------------------------------------------------------------------ |
---|
| 1474 | % III - MAIN REFRESH FUNCTIONS : 'FRAME PLOT' |
---|
| 1475 | %------------------------------------------------------------------------ |
---|
| 1476 | |
---|
| 1477 | %------------------------------------------------------------------------ |
---|
| 1478 | % --- Executes on button press in runplus: make one step forward and call |
---|
| 1479 | % --- run0. The step forward is along the fields series 1 or 2 depending on |
---|
| 1480 | % --- the scan_i and scan_j check box (exclusive each other) |
---|
| 1481 | function runplus_Callback(hObject, eventdata, handles) |
---|
| 1482 | %------------------------------------------------------------------------ |
---|
| 1483 | set(handles.runplus,'BackgroundColor',[1 1 0])%paint the command button in yellow |
---|
| 1484 | drawnow |
---|
| 1485 | %TODO: introduce the option: increment ='*' to move to the next available view |
---|
| 1486 | increment=str2num(get(handles.increment_scan,'String')); %get the field increment d |
---|
| 1487 | % if isnan(increment) |
---|
| 1488 | % set(handles.increment_scan,'String','1')%default value |
---|
| 1489 | % increment=1; |
---|
| 1490 | % end |
---|
| 1491 | errormsg=runpm(hObject,eventdata,handles,increment); |
---|
| 1492 | if ~isempty(errormsg) |
---|
| 1493 | msgbox_uvmat('ERROR',errormsg); |
---|
| 1494 | end |
---|
| 1495 | set(handles.runplus,'BackgroundColor',[1 0 0])%paint the command button back to red |
---|
| 1496 | |
---|
| 1497 | %------------------------------------------------------------------------ |
---|
| 1498 | % --- Executes on button press in runmin: make one step backward and call |
---|
| 1499 | % --- run0. The step backward is along the fields series 1 or 2 depending on |
---|
| 1500 | % --- the scan_i and scan_j check box (exclusive each other) |
---|
| 1501 | function runmin_Callback(hObject, eventdata, handles) |
---|
| 1502 | %------------------------------------------------------------------------ |
---|
| 1503 | set(handles.runmin,'BackgroundColor',[1 1 0])%paint the command button in yellow |
---|
| 1504 | drawnow |
---|
| 1505 | increment=-str2num(get(handles.increment_scan,'String')); %get the field increment d |
---|
| 1506 | % if isnan(increment) |
---|
| 1507 | % set(handles.increment_scan,'String','1')%default value |
---|
| 1508 | % increment=1; |
---|
| 1509 | % end |
---|
| 1510 | errormsg=runpm(hObject,eventdata,handles,increment); |
---|
| 1511 | if ~isempty(errormsg) |
---|
| 1512 | msgbox_uvmat('ERROR',errormsg); |
---|
| 1513 | end |
---|
| 1514 | set(handles.runmin,'BackgroundColor',[1 0 0])%paint the command button back to red |
---|
| 1515 | |
---|
| 1516 | %------------------------------------------------------------------------ |
---|
| 1517 | % -- Executes on button press in Movie: make a series of +> steps |
---|
| 1518 | function Movie_Callback(hObject, eventdata, handles) |
---|
| 1519 | %------------------------------------------------------------------------ |
---|
| 1520 | set(handles.Movie,'BackgroundColor',[1 1 0])%paint the command button in yellow |
---|
| 1521 | drawnow |
---|
| 1522 | increment=str2num(get(handles.increment_scan,'String')); %get the field increment d |
---|
| 1523 | % if isnan(increment) |
---|
| 1524 | % set(handles.increment_scan,'String','1')%default value |
---|
| 1525 | % increment=1; |
---|
| 1526 | % end |
---|
| 1527 | set(handles.STOP,'Visible','on') |
---|
| 1528 | set(handles.speed,'Visible','on') |
---|
| 1529 | set(handles.speed_txt,'Visible','on') |
---|
| 1530 | set(handles.Movie,'BusyAction','queue') |
---|
| 1531 | UvData=get(handles.uvmat,'UserData'); |
---|
| 1532 | |
---|
[435] | 1533 | while get(handles.Movie,'Value')==1 && get(handles.speed,'Value')~=0 && isequal(get(handles.Movie,'BusyAction'),'queue') % enable STOP command |
---|
[387] | 1534 | errormsg=runpm(hObject,eventdata,handles,increment); |
---|
| 1535 | if ~isempty(errormsg) |
---|
| 1536 | set(handles.Movie,'BackgroundColor',[1 0 0])%paint the command buttonback to red |
---|
| 1537 | return |
---|
| 1538 | end |
---|
| 1539 | pause(1.02-get(handles.speed,'Value'))% wait for next image |
---|
| 1540 | end |
---|
| 1541 | if isfield(UvData,'aviobj') && ~isempty( UvData.aviobj), |
---|
| 1542 | UvData.aviobj=close(UvData.aviobj); |
---|
| 1543 | set(handles.uvmat,'UserData',UvData); |
---|
| 1544 | end |
---|
| 1545 | set(handles.Movie,'BackgroundColor',[1 0 0])%paint the command buttonback to red |
---|
| 1546 | |
---|
| 1547 | %------------------------------------------------------------------------ |
---|
| 1548 | % -- Executes on button press in Movie: make a series of <- steps |
---|
| 1549 | function MovieBackward_Callback(hObject, eventdata, handles) |
---|
| 1550 | %------------------------------------------------------------------------ |
---|
| 1551 | set(handles.MovieBackward,'BackgroundColor',[1 1 0])%paint the command button in yellow |
---|
| 1552 | drawnow |
---|
| 1553 | increment=-str2num(get(handles.increment_scan,'String')); %get the field increment d |
---|
| 1554 | set(handles.STOP,'Visible','on') |
---|
| 1555 | set(handles.speed,'Visible','on') |
---|
| 1556 | set(handles.speed_txt,'Visible','on') |
---|
| 1557 | set(handles.MovieBackward,'BusyAction','queue') |
---|
| 1558 | UvData=get(handles.uvmat,'UserData'); |
---|
| 1559 | |
---|
[435] | 1560 | while get(handles.MovieBackward,'Value')==1 && get(handles.speed,'Value')~=0 && isequal(get(handles.MovieBackward,'BusyAction'),'queue') % enable STOP command |
---|
[387] | 1561 | errormsg=runpm(hObject,eventdata,handles,increment); |
---|
| 1562 | if ~isempty(errormsg) |
---|
| 1563 | set(handles.MovieBackward,'BackgroundColor',[1 0 0])%paint the command buttonback to red |
---|
| 1564 | return |
---|
| 1565 | end |
---|
| 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(handles.uvmat,'UserData',UvData); |
---|
| 1571 | end |
---|
| 1572 | set(handles.MovieBackward,'BackgroundColor',[1 0 0])%paint the command buttonback to red |
---|
| 1573 | |
---|
| 1574 | %------------------------------------------------------------------------ |
---|
| 1575 | function STOP_Callback(hObject, eventdata, handles) |
---|
| 1576 | %------------------------------------------------------------------------ |
---|
| 1577 | set(handles.movie_pair,'BusyAction','Cancel') |
---|
| 1578 | set(handles.movie_pair,'value',0) |
---|
| 1579 | set(handles.Movie,'BusyAction','Cancel') |
---|
| 1580 | set(handles.MovieBackward,'BusyAction','Cancel') |
---|
| 1581 | set(handles.MenuExportMovie,'BusyAction','Cancel') |
---|
| 1582 | set(handles.movie_pair,'BackgroundColor',[1 0 0])%paint the command buttonback to red |
---|
| 1583 | set(handles.Movie,'BackgroundColor',[1 0 0])%paint the command buttonback to red |
---|
| 1584 | set(handles.MovieBackward,'BackgroundColor',[1 0 0])%paint the command buttonback to red |
---|
| 1585 | |
---|
| 1586 | %------------------------------------------------------------------------ |
---|
| 1587 | % --- function activated by runplus and run minus |
---|
| 1588 | function errormsg=runpm(hObject,eventdata,handles,increment) |
---|
| 1589 | %------------------------------------------------------------------------ |
---|
| 1590 | errormsg='';%default |
---|
| 1591 | %% check for movie pair status |
---|
| 1592 | movie_status=get(handles.movie_pair,'Value'); |
---|
| 1593 | if isequal(movie_status,1) |
---|
| 1594 | STOP_Callback(hObject, eventdata, handles)%interrupt movie pair if active |
---|
| 1595 | end |
---|
| 1596 | |
---|
| 1597 | %% read the current input file name(s) and field indices |
---|
| 1598 | InputFile=read_GUI(handles.InputFile); |
---|
| 1599 | InputFile.RootFile=regexprep(InputFile.RootFile,'^[\\/]|[\\/]$','');%suppress possible / or \ separator at the beginning or the end of the string |
---|
| 1600 | InputFile.SubDir=regexprep(InputFile.SubDir,'^[\\/]|[\\/]$','');%suppress possible / or \ separator at the beginning or the end of the string |
---|
| 1601 | FileExt=InputFile.FileExt; |
---|
| 1602 | NomType=get(handles.NomType,'String'); |
---|
| 1603 | i1=str2num(get(handles.i1,'String'));%read the field indices (for movie, it is not given by the file name) |
---|
| 1604 | i2=[];%default |
---|
| 1605 | if strcmp(get(handles.i2,'Visible'),'on') |
---|
| 1606 | i2=str2num(get(handles.i2,'String')); |
---|
| 1607 | end |
---|
| 1608 | j1=[]; |
---|
| 1609 | if strcmp(get(handles.j1,'Visible'),'on') |
---|
| 1610 | j1=stra2num(get(handles.j1,'String')); |
---|
| 1611 | end |
---|
| 1612 | j2=j1; |
---|
| 1613 | if strcmp(get(handles.j2,'Visible'),'on') |
---|
| 1614 | j2=stra2num(get(handles.j2,'String')); |
---|
| 1615 | end |
---|
| 1616 | sub_value= get(handles.SubField,'Value'); |
---|
| 1617 | if sub_value % a second input file has been entered |
---|
[428] | 1618 | [InputFile.RootPath_1,InputFile.SubDir_1,InputFile.RootFile_1,InputFile.FileIndex_1,InputFile.FileExt_1,InputFile.NomType_1]=read_file_boxes_1(handles); |
---|
| 1619 | [tild,tild,tild,i1_1,i2_1,j1_1,j2_1]=fileparts_uvmat(InputFile.FileIndex_1); |
---|
| 1620 | % InputFile.NomType_1=get(handles.NomType_1,'String'); |
---|
[387] | 1621 | else |
---|
| 1622 | filename_1=[]; |
---|
| 1623 | end |
---|
| 1624 | |
---|
| 1625 | %% increment (or decrement) the field indices and update the input filename(s) |
---|
| 1626 | CheckSearch=0; |
---|
| 1627 | if isempty(increment) |
---|
| 1628 | CheckSearch=1;% search for the next available file |
---|
| 1629 | set(handles.CheckFixPair,'Value',0) |
---|
| 1630 | end |
---|
| 1631 | CheckFixPair=get(handles.CheckFixPair,'Value')||(isempty(i2)&&isempty(j2)); |
---|
[427] | 1632 | |
---|
| 1633 | % the pair i1-i2 or j1-j2 is imposed (check box CheckFixPair selected) |
---|
[387] | 1634 | if CheckFixPair |
---|
| 1635 | if get(handles.scan_i,'Value')==1% case of scanning along index i |
---|
| 1636 | i1=i1+increment; |
---|
| 1637 | i2=i2+increment; |
---|
| 1638 | if sub_value |
---|
| 1639 | i1_1=i1_1+increment; |
---|
| 1640 | i2_1=i2_1+increment; |
---|
| 1641 | end |
---|
| 1642 | else % case of scanning along index j (burst numbers) |
---|
| 1643 | j1=j1+increment; |
---|
| 1644 | j2=j2+increment; |
---|
| 1645 | if sub_value |
---|
| 1646 | j1_1=j1_1+increment; |
---|
| 1647 | j2_1=j2_1+increment; |
---|
| 1648 | end |
---|
| 1649 | end |
---|
[427] | 1650 | |
---|
| 1651 | % the pair i1-i2 or j1-j2 is free (check box CheckFixPair not selected): |
---|
| 1652 | % the list of existing indices recorded in UvData is used |
---|
[387] | 1653 | else |
---|
| 1654 | UvData=get(handles.uvmat,'UserData'); |
---|
| 1655 | ref_i=i1; |
---|
| 1656 | if ~isempty(i2) |
---|
[427] | 1657 | ref_i=floor((i1+i2)/2);% current reference index i |
---|
[387] | 1658 | end |
---|
| 1659 | ref_j=1; |
---|
| 1660 | if ~isempty(j1) |
---|
| 1661 | ref_j=j1; |
---|
| 1662 | if ~isempty(j2) |
---|
[427] | 1663 | ref_j=floor((j1+j2)/2);% current reference index j |
---|
[387] | 1664 | end |
---|
| 1665 | end |
---|
| 1666 | if ~isempty(increment) |
---|
| 1667 | if get(handles.scan_i,'Value')==1% case of scanning along index i |
---|
[427] | 1668 | ref_i=ref_i+increment;% increment the current reference index i |
---|
[387] | 1669 | else % case of scanning along index j (burst numbers) |
---|
[427] | 1670 | ref_j=ref_j+increment;% increment the current reference index j if scan_j option is used |
---|
[387] | 1671 | end |
---|
[388] | 1672 | else % free increment |
---|
[387] | 1673 | if isequal(get(handles.runplus,'BackgroundColor'),[1 1 0])% if runplus is activated |
---|
| 1674 | step=1; |
---|
| 1675 | else |
---|
| 1676 | step=-1; |
---|
| 1677 | end |
---|
| 1678 | if get(handles.scan_i,'Value')==1% case of scanning along index i |
---|
| 1679 | ref_i=ref_i+step; |
---|
| 1680 | while ref_i>=0 && size(UvData.i1_series{1},1)>=ref_i+1 && UvData.i1_series{1}(ref_i+1,ref_j+1,1)==0 |
---|
| 1681 | ref_i=ref_i+step; |
---|
| 1682 | end |
---|
| 1683 | else % case of scanning along index j (burst numbers) |
---|
| 1684 | ref_j=ref_j+step; |
---|
| 1685 | while ref_j>=0 && size(UvData.i1_series{1},2)>=ref_j+1 && UvData.i1_series{1}(ref_i+1,ref_j+1,1)==0 |
---|
| 1686 | ref_j=ref_j+step; |
---|
| 1687 | end |
---|
| 1688 | end |
---|
| 1689 | end |
---|
| 1690 | if ref_i<0 |
---|
| 1691 | errormsg='minimum i index reached'; |
---|
| 1692 | elseif ref_j<0 |
---|
| 1693 | errormsg='minimum j index reached'; |
---|
| 1694 | elseif ref_i+1>size(UvData.i1_series{1},1) |
---|
| 1695 | errormsg='maximum i index reached'; |
---|
| 1696 | elseif ref_j+1>size(UvData.i1_series{1},2) |
---|
| 1697 | errormsg='maximum j index reached'; |
---|
| 1698 | end |
---|
| 1699 | if ~isempty(errormsg) |
---|
| 1700 | return |
---|
| 1701 | end |
---|
[427] | 1702 | i1_subseries=UvData.i1_series{1}(ref_i+1,ref_j+1,:); |
---|
[387] | 1703 | i1_subseries=i1_subseries(i1_subseries>0); |
---|
| 1704 | if isempty(i1_subseries) |
---|
| 1705 | errormsg='no next file'; |
---|
| 1706 | return |
---|
[427] | 1707 | else |
---|
| 1708 | i1=i1_subseries(end); |
---|
[387] | 1709 | end |
---|
| 1710 | if ~isempty(UvData.i2_series{1}) |
---|
[427] | 1711 | i2_subseries=UvData.i2_series{1}(ref_i+1,ref_j+1,:); |
---|
[387] | 1712 | i2_subseries=i2_subseries(i2_subseries>0); |
---|
| 1713 | i2=i2_subseries(end); |
---|
| 1714 | end |
---|
| 1715 | if ~isempty(UvData.j1_series{1}) |
---|
[427] | 1716 | j1_subseries=UvData.j1_series{1}(ref_i+1,ref_j+1,:); |
---|
[387] | 1717 | j1_subseries=j1_subseries(j1_subseries>0); |
---|
| 1718 | j1=j1_subseries(end); |
---|
| 1719 | end |
---|
| 1720 | if ~isempty(UvData.j2_series{1}) |
---|
[427] | 1721 | j2_subseries=UvData.j2_series{1}(ref_i+1,ref_j+1,:); |
---|
[387] | 1722 | j2_subseries=j2_subseries(j2_subseries>0); |
---|
| 1723 | j2=j2_subseries(end); |
---|
[427] | 1724 | end |
---|
| 1725 | % case of a second file series |
---|
| 1726 | if numel(UvData.i1_series)>=2 |
---|
| 1727 | i1_subseries=UvData.i1_series{2}(ref_i+1,ref_j+1,:); |
---|
| 1728 | i1_subseries=i1_subseries(i1_subseries>0); |
---|
| 1729 | i1_1=i1_subseries(end); |
---|
| 1730 | if ~isempty(UvData.i2_series{2}) |
---|
| 1731 | i2_subseries=UvData.i2_series{2}(ref_i+1,ref_j+1,:); |
---|
| 1732 | i2_subseries=i2_subseries(i2_subseries>0); |
---|
| 1733 | i2_1=i2_subseries(end); |
---|
| 1734 | end |
---|
| 1735 | if ~isempty(UvData.j1_series{2}) |
---|
| 1736 | j1_subseries=UvData.j1_series{2}(ref_i+1,ref_j+1,:); |
---|
| 1737 | j1_subseries=j1_subseries(j1_subseries>0); |
---|
| 1738 | j1_1=j1_subseries(end); |
---|
| 1739 | end |
---|
| 1740 | if ~isempty(UvData.j2_series{2}) |
---|
| 1741 | j2_subseries=UvData.j2_series{2}(ref_i+1,ref_j+1,:); |
---|
| 1742 | j2_subseries=j2_subseries(j2_subseries>0); |
---|
| 1743 | j2_1=j2_subseries(end); |
---|
| 1744 | end |
---|
[387] | 1745 | end |
---|
| 1746 | end |
---|
| 1747 | filename=fullfile_uvmat(InputFile.RootPath,InputFile.SubDir,InputFile.RootFile,FileExt,NomType,i1,i2,j1,j2); |
---|
| 1748 | if sub_value |
---|
[428] | 1749 | filename_1=fullfile_uvmat(InputFile.RootPath_1,InputFile.SubDir_1,InputFile.RootFile_1,InputFile.FileExt_1,InputFile.NomType_1,i1_1,i2_1,j1_1,j2_1); |
---|
[387] | 1750 | end |
---|
| 1751 | |
---|
| 1752 | %% refresh plots |
---|
| 1753 | errormsg=refresh_field(handles,filename,filename_1,i1,i2,j1,j2); |
---|
| 1754 | |
---|
| 1755 | %% update the index counters if the index move is successfull |
---|
| 1756 | if isempty(errormsg) |
---|
| 1757 | set(handles.i1,'String',num2stra(i1,NomType,1)); |
---|
| 1758 | if isequal(i2,i1) |
---|
| 1759 | set(handles.i2,'String',''); |
---|
| 1760 | else |
---|
| 1761 | set(handles.i2,'String',num2stra(i2,NomType,1)); |
---|
| 1762 | end |
---|
| 1763 | set(handles.j1,'String',num2stra(j1,NomType,2)); |
---|
| 1764 | if isequal(j2,j1) |
---|
| 1765 | set(handles.j2,'String',''); |
---|
| 1766 | else |
---|
| 1767 | set(handles.j2,'String',num2stra(j2,NomType,2)); |
---|
| 1768 | end |
---|
| 1769 | indices=fullfile_uvmat('','','','',NomType,i1,i2,j1,j2); |
---|
| 1770 | set(handles.FileIndex,'String',indices); |
---|
| 1771 | if ~isempty(filename_1) |
---|
[428] | 1772 | indices_1=fullfile_uvmat('','','','',InputFile.NomType_1,i1_1,i2_1,j1_1,j2_1); |
---|
[387] | 1773 | set(handles.FileIndex_1,'String',indices_1); |
---|
| 1774 | end |
---|
| 1775 | if isequal(movie_status,1) |
---|
| 1776 | set(handles.movie_pair,'Value',1) |
---|
| 1777 | movie_pair_Callback(hObject, eventdata, handles); %reactivate moviepair if it was activated |
---|
| 1778 | end |
---|
| 1779 | end |
---|
| 1780 | |
---|
| 1781 | %------------------------------------------------------------------------ |
---|
| 1782 | % --- Executes on button press in movie_pair: create an alternating movie with two view |
---|
| 1783 | function movie_pair_Callback(hObject, eventdata, handles) |
---|
| 1784 | %------------------------------------------------------------------------ |
---|
| 1785 | %% stop movie action if the movie_pair button is off |
---|
| 1786 | if ~get(handles.movie_pair,'value') |
---|
| 1787 | set(handles.movie_pair,'BusyAction','Cancel')%stop movie pair if button is 'off' |
---|
| 1788 | set(handles.i2,'String','') |
---|
| 1789 | set(handles.j2,'String','') |
---|
| 1790 | return |
---|
| 1791 | else |
---|
| 1792 | set(handles.movie_pair,'BusyAction','queue') |
---|
| 1793 | end |
---|
| 1794 | |
---|
| 1795 | %% initialisation |
---|
| 1796 | set(handles.movie_pair,'BackgroundColor',[1 1 0])%paint the command button in yellow |
---|
| 1797 | drawnow |
---|
| 1798 | list_fields=get(handles.Fields,'String');% list menu fields |
---|
| 1799 | index_fields=get(handles.Fields,'Value');% selected string index |
---|
| 1800 | FieldName=list_fields{index_fields}; % selected field |
---|
| 1801 | UvData=get(handles.uvmat,'UserData'); |
---|
| 1802 | if isequal(FieldName,'image') |
---|
| 1803 | test_1=0; |
---|
| 1804 | [RootPath,SubDir,RootFile,FileIndices,Ext]=read_file_boxes(handles); |
---|
| 1805 | NomType=get(handles.NomType,'String'); |
---|
| 1806 | else |
---|
| 1807 | list_fields=get(handles.Fields_1,'String');% list menu fields |
---|
| 1808 | index_fields=get(handles.Fields_1,'Value');% selected string index |
---|
| 1809 | FieldName=list_fields{index_fields}; % selected field |
---|
| 1810 | if isequal(FieldName,'image') |
---|
| 1811 | test_1=1; |
---|
| 1812 | [RootPath,tild,RootFile,FileIndex_1,Ext,NomType]=read_file_boxes_1(handles); |
---|
| 1813 | else |
---|
| 1814 | msgbox_uvmat('ERROR','an image or movie must be first introduced as input') |
---|
| 1815 | set(handles.movie_pair,'BackgroundColor',[1 0 0])%paint the command button in red |
---|
| 1816 | set(handles.movie_pair,'Value',0) |
---|
| 1817 | return |
---|
| 1818 | end |
---|
| 1819 | end |
---|
| 1820 | num_i1=str2num(get(handles.i1,'String')); |
---|
| 1821 | num_j1=stra2num(get(handles.j1,'String')); |
---|
| 1822 | num_i2=str2num(get(handles.i2,'String')); |
---|
| 1823 | num_j2=stra2num(get(handles.j2,'String')); |
---|
| 1824 | if isempty(num_j2) |
---|
| 1825 | if isempty(num_i2) |
---|
| 1826 | msgbox_uvmat('ERROR', 'a second image index i2 or j2 is needed to show the pair as a movie') |
---|
| 1827 | set(handles.movie_pair,'BackgroundColor',[1 0 0])%paint the command button in red |
---|
| 1828 | set(handles.movie_pair,'Value',0) |
---|
| 1829 | return |
---|
| 1830 | else |
---|
| 1831 | num_j2=num_j1;%repeat the index i1 by default |
---|
| 1832 | end |
---|
| 1833 | end |
---|
| 1834 | if isempty(num_i2) |
---|
| 1835 | num_i2=num_i1;%repeat the index i1 by default |
---|
| 1836 | end |
---|
| 1837 | % imaname_1=name_generator(filebase,num_i2,num_j2,Ext,NomType); |
---|
[439] | 1838 | imaname_1=fullfile_uvmat(RootPath,SubDir,RootFile,Ext,NomType,num_i2,[],num_j2); |
---|
[387] | 1839 | if ~exist(imaname_1,'file') |
---|
| 1840 | msgbox_uvmat('ERROR',['second input open (-) ' imaname_1 ' not found']); |
---|
| 1841 | set(handles.movie_pair,'BackgroundColor',[1 0 0])%paint the command button in red |
---|
| 1842 | set(handles.movie_pair,'Value',0) |
---|
| 1843 | return |
---|
| 1844 | end |
---|
| 1845 | |
---|
| 1846 | %% read the second image |
---|
| 1847 | Field.AName='image'; |
---|
| 1848 | if test_1 |
---|
| 1849 | Field_a=UvData.Field_1; |
---|
| 1850 | else |
---|
| 1851 | Field_a=UvData.Field; |
---|
| 1852 | end |
---|
| 1853 | Field_b.AX=Field_a.AX; |
---|
| 1854 | Field_b.AY=Field_a.AY; |
---|
| 1855 | % z index |
---|
| 1856 | nbslice=str2double(get(handles.nb_slice,'String')); |
---|
| 1857 | if ~isempty(nbslice) |
---|
| 1858 | Field_b.ZIndex=mod(num_i2-1,nbslice)+1; |
---|
| 1859 | end |
---|
| 1860 | Field_b.CoordUnit='pixel'; |
---|
| 1861 | |
---|
| 1862 | %% determine the input file type |
---|
| 1863 | if (test_1 && isfield(UvData,'MovieObject')&& numel(UvData.MovieObject>=2))||(~test_1 && ~isempty(UvData.MovieObject{1})) |
---|
| 1864 | FileType='movie'; |
---|
| 1865 | elseif isequal(lower(Ext),'.avi') |
---|
| 1866 | FileType='avi'; |
---|
| 1867 | elseif isequal(lower(Ext),'.vol') |
---|
| 1868 | FileType='vol'; |
---|
| 1869 | else |
---|
| 1870 | form=imformats(Ext(2:end)); |
---|
| 1871 | if ~isempty(form)% if the extension corresponds to an image format recognized by Matlab |
---|
| 1872 | if isequal(NomType,'*'); |
---|
| 1873 | FileType='multimage'; |
---|
| 1874 | else |
---|
| 1875 | FileType='image'; |
---|
| 1876 | end |
---|
| 1877 | end |
---|
| 1878 | end |
---|
| 1879 | switch FileType |
---|
| 1880 | case 'movie' |
---|
| 1881 | if test_1 |
---|
| 1882 | Field_b.A=read(UvData.MovieObject{2},num_i2); |
---|
| 1883 | else |
---|
| 1884 | Field_b.A=read(UvData.MovieObject{1},num_i2); |
---|
| 1885 | end |
---|
| 1886 | case 'avi' |
---|
| 1887 | mov=aviread(imaname_1,num_i2); |
---|
| 1888 | Field_b.A=frame2im(mov(1)); |
---|
| 1889 | case 'vol' |
---|
| 1890 | Field_b.A=imread(imaname_1); |
---|
| 1891 | case 'multimage' |
---|
| 1892 | Field_b.A=imread(imaname_1,num_i2); |
---|
| 1893 | case 'image' |
---|
| 1894 | Field_b.A=imread(imaname_1); |
---|
| 1895 | end |
---|
| 1896 | if get(handles.slices,'Value') |
---|
| 1897 | Field.ZIndex=str2double(get(handles.z_index,'String')); |
---|
| 1898 | end |
---|
| 1899 | |
---|
| 1900 | %px to phys or other transform on field |
---|
| 1901 | menu_transform=get(handles.transform_fct,'String'); |
---|
| 1902 | choice_value=get(handles.transform_fct,'Value'); |
---|
| 1903 | transform_name=menu_transform{choice_value};%name of the transform fct given by the menu 'transform_fct' |
---|
| 1904 | transform_list=get(handles.transform_fct,'UserData'); |
---|
| 1905 | transform=transform_list{choice_value}; |
---|
| 1906 | if ~isequal(transform_name,'') && ~isequal(transform_name,'px') |
---|
| 1907 | if test_1 && isfield(UvData,'XmlData') && numel(UvData.XmlData)==2 && isfield(UvData.XmlData{2},'GeometryCalib')%use geometry calib recorded from the ImaDoc xml file as first priority |
---|
| 1908 | Field_a=transform(Field_a,UvData.XmlData{2});%the first field has been stored without transform |
---|
| 1909 | Field_b=transform(Field_b,UvData.XmlData{2}); |
---|
| 1910 | elseif ~test_1 && isfield(UvData,'XmlData') && isfield(UvData.XmlData{1},'GeometryCalib')%use geometry calib |
---|
| 1911 | Field_b=transform(Field_b,UvData.XmlData{1}); |
---|
| 1912 | end |
---|
| 1913 | end |
---|
| 1914 | |
---|
| 1915 | % make movie until movie speed is set to 0 or STOP is activated |
---|
| 1916 | hima=findobj(handles.axes3,'Tag','ima');% %handles.axes3 =main plotting window (A GENERALISER) |
---|
| 1917 | set(handles.STOP,'Visible','on') |
---|
| 1918 | set(handles.speed,'Visible','on') |
---|
| 1919 | set(handles.speed_txt,'Visible','on') |
---|
| 1920 | while get(handles.speed,'Value')~=0 && isequal(get(handles.movie_pair,'BusyAction'),'queue')%isequal(get(handles.run0,'BusyAction'),'queue'); % enable STOP command |
---|
| 1921 | % read and plot the series of images in non erase mode |
---|
| 1922 | set(hima,'CData',Field_b.A); |
---|
| 1923 | pause(1.02-get(handles.speed,'Value'));% wait for next image |
---|
| 1924 | set(hima,'CData',Field_a.A); |
---|
| 1925 | pause(1.02-get(handles.speed,'Value'));% wait for next image |
---|
| 1926 | end |
---|
| 1927 | set(handles.movie_pair,'BackgroundColor',[1 0 0])%paint the command button in red |
---|
| 1928 | set(handles.movie_pair,'Value',0) |
---|
| 1929 | |
---|
| 1930 | %------------------------------------------------------------------------ |
---|
| 1931 | % --- Executes on button press in run0. |
---|
| 1932 | function run0_Callback(hObject, eventdata, handles) |
---|
| 1933 | %------------------------------------------------------------------------ |
---|
| 1934 | set(handles.run0,'BackgroundColor',[1 1 0])%paint the command button in yellow |
---|
| 1935 | drawnow |
---|
| 1936 | [RootPath,SubDir,RootFile,FileIndices,FileExt]=read_file_boxes(handles); |
---|
| 1937 | filename=[fullfile(RootPath,SubDir,RootFile) FileIndices FileExt]; |
---|
| 1938 | filename_1=[];%default |
---|
| 1939 | if get(handles.SubField,'Value') |
---|
| 1940 | [RootPath_1,SubDir_1,RootFile_1,FileIndices_1,FileExt_1]=read_file_boxes_1(handles); |
---|
| 1941 | filename_1=[fullfile(RootPath_1,SubDir_1,RootFile_1) FileIndices_1 FileExt_1]; |
---|
| 1942 | end |
---|
| 1943 | num_i1=stra2num(get(handles.i1,'String')); |
---|
| 1944 | num_i2=stra2num(get(handles.i2,'String')); |
---|
| 1945 | num_j1=stra2num(get(handles.j1,'String')); |
---|
| 1946 | num_j2=stra2num(get(handles.j2,'String')); |
---|
| 1947 | |
---|
| 1948 | errormsg=refresh_field(handles,filename,filename_1,num_i1,num_i2,num_j1,num_j2); |
---|
| 1949 | |
---|
| 1950 | if ~isempty(errormsg) |
---|
| 1951 | msgbox_uvmat('ERROR',errormsg); |
---|
| 1952 | else |
---|
| 1953 | set(handles.i1,'BackgroundColor',[1 1 1]) |
---|
| 1954 | set(handles.i2,'BackgroundColor',[1 1 1]) |
---|
| 1955 | set(handles.j1,'BackgroundColor',[1 1 1]) |
---|
| 1956 | set(handles.j2,'BackgroundColor',[1 1 1]) |
---|
| 1957 | set(handles.FileIndex,'BackgroundColor',[1 1 1]) |
---|
| 1958 | set(handles.FileIndex_1,'BackgroundColor',[1 1 1]) |
---|
| 1959 | end |
---|
| 1960 | set(handles.run0,'BackgroundColor',[1 0 0]) |
---|
| 1961 | |
---|
| 1962 | |
---|
| 1963 | %------------------------------------------------------------------------ |
---|
| 1964 | % --- read the input files and refresh all the plots, including projection. |
---|
| 1965 | % OUTPUT: |
---|
| 1966 | % errormsg: error message char string =[] by default |
---|
| 1967 | % INPUT: |
---|
| 1968 | % filename: first input file (=[] in the absence of input file) |
---|
| 1969 | % filename_1: second input file (=[] in the asbsenc of secodn input file) |
---|
| 1970 | % num_i1,num_i2,num_j1,num_j2; frame indices |
---|
| 1971 | % Field: structure describing an optional input field (then replace the input file) |
---|
[397] | 1972 | |
---|
[387] | 1973 | function errormsg=refresh_field(handles,filename,filename_1,num_i1,num_i2,num_j1,num_j2,Field) |
---|
| 1974 | %------------------------------------------------------------------------ |
---|
| 1975 | |
---|
| 1976 | %% initialisation |
---|
| 1977 | abstime=[]; |
---|
| 1978 | abstime_1=[]; |
---|
| 1979 | dt=[]; |
---|
| 1980 | if ~exist('Field','var') |
---|
| 1981 | Field={}; |
---|
| 1982 | end |
---|
| 1983 | UvData=get(handles.uvmat,'UserData'); |
---|
| 1984 | if ishandle(handles.UVMAT_title) %remove title panel on uvmat |
---|
| 1985 | delete(handles.UVMAT_title) |
---|
| 1986 | end |
---|
| 1987 | |
---|
| 1988 | %% determine the main input file information for action |
---|
| 1989 | FileType=[];%default |
---|
| 1990 | if ~exist(filename,'file') |
---|
| 1991 | errormsg=['input file ' filename ' does not exist']; |
---|
| 1992 | return |
---|
| 1993 | end |
---|
| 1994 | NomType=get(handles.NomType,'String'); |
---|
| 1995 | % NomType=get(handles.FileIndex,'UserData'); |
---|
| 1996 | %update the z position index |
---|
| 1997 | nbslice_str=get(handles.nb_slice,'String'); |
---|
| 1998 | if isequal(nbslice_str,'volume')%NOT USED |
---|
| 1999 | z_index=num_j1; |
---|
| 2000 | set(handles.z_index,'String',num2str(z_index)) |
---|
| 2001 | else |
---|
| 2002 | nbslice=str2num(nbslice_str); |
---|
| 2003 | z_index=mod(num_i1-1,nbslice)+1; |
---|
| 2004 | set(handles.z_index,'String',num2str(z_index)) |
---|
| 2005 | end |
---|
| 2006 | % refresh menu for save_mask if relevant |
---|
| 2007 | masknumber=get(handles.masklevel,'String'); |
---|
| 2008 | if length(masknumber)>=z_index |
---|
| 2009 | set(handles.masklevel,'Value',z_index) |
---|
| 2010 | end |
---|
| 2011 | |
---|
| 2012 | %% read the first input field if a filename has been introduced |
---|
[421] | 2013 | ParamIn.ColorVar='';%default variable name for vector color |
---|
[387] | 2014 | if ~isempty(filename) |
---|
| 2015 | ObjectName=filename; |
---|
[404] | 2016 | FieldName='';%default |
---|
| 2017 | VelType='';%default |
---|
| 2018 | % FileType=UvData.FileType{1}; |
---|
| 2019 | switch UvData.FileType{1} |
---|
[387] | 2020 | case {'civx','civdata','netcdf'}; |
---|
| 2021 | list_fields=get(handles.Fields,'String');% list menu fields |
---|
[404] | 2022 | % index_fields=get(handles.Fields,'Value');% selected string index |
---|
| 2023 | FieldName= list_fields{get(handles.Fields,'Value')}; % selected field |
---|
[387] | 2024 | if ~strcmp(FieldName,'get_field...') |
---|
[389] | 2025 | if get(handles.FixVelType,'Value') |
---|
| 2026 | VelTypeList=get(handles.VelType,'String'); |
---|
| 2027 | VelType=VelTypeList{get(handles.VelType,'Value')}; |
---|
[387] | 2028 | end |
---|
| 2029 | end |
---|
| 2030 | if strcmp(FieldName,'velocity') |
---|
[405] | 2031 | list_code=get(handles.ColorCode,'String');% list menu fields |
---|
| 2032 | index_code=get(handles.ColorCode,'Value');% selected string index |
---|
[387] | 2033 | if ~strcmp(list_code{index_code},'black') && ~strcmp(list_code{index_code},'white') |
---|
[405] | 2034 | list_code=get(handles.ColorScalar,'String');% list menu fields |
---|
| 2035 | index_code=get(handles.ColorScalar,'Value');% selected string index |
---|
[387] | 2036 | ParamIn.ColorVar= list_code{index_code}; % selected field |
---|
| 2037 | end |
---|
| 2038 | end |
---|
[435] | 2039 | case {'video','mmreader'} |
---|
[387] | 2040 | ObjectName=UvData.MovieObject{1}; |
---|
| 2041 | case 'vol' %TODO: update |
---|
| 2042 | if isfield(UvData.XmlData,'Npy') && isfield(UvData.XmlData,'Npx') |
---|
| 2043 | ParamIn.Npy=UvData.XmlData.Npy; |
---|
| 2044 | ParamIn.Npx=UvData.XmlData.Npx; |
---|
| 2045 | else |
---|
| 2046 | errormsg='Npx and Npy need to be defined in the xml file for volume images .vol'; |
---|
| 2047 | return |
---|
| 2048 | end |
---|
| 2049 | end |
---|
| 2050 | ParamIn.FieldName=FieldName; |
---|
| 2051 | ParamIn.VelType=VelType; |
---|
| 2052 | ParamIn.GUIName='get_field'; |
---|
[404] | 2053 | [Field{1},ParamOut,errormsg] = read_field(ObjectName,UvData.FileType{1},ParamIn,num_i1); |
---|
[387] | 2054 | if ~isempty(errormsg) |
---|
| 2055 | errormsg=['error in reading ' filename ': ' errormsg]; |
---|
| 2056 | return |
---|
| 2057 | end |
---|
| 2058 | if isfield(ParamOut,'Npx')&& isfield(ParamOut,'Npy') |
---|
| 2059 | set(handles.num_Npx,'String',num2str(ParamOut.Npx));% display image size on the interface |
---|
| 2060 | set(handles.num_Npy,'String',num2str(ParamOut.Npy)); |
---|
| 2061 | end |
---|
[415] | 2062 | if isfield(ParamOut,'TimeIndex')% case of time obtained from get_field |
---|
[387] | 2063 | set(handles.i1,'String',num2str(ParamOut.TimeIndex)) |
---|
| 2064 | end |
---|
| 2065 | if isfield(ParamOut,'TimeValue') |
---|
[415] | 2066 | Field{1}.Time=ParamOut.TimeValue;% case of time obtained from get_field |
---|
[387] | 2067 | end |
---|
| 2068 | end |
---|
| 2069 | |
---|
[405] | 2070 | %% choose and read a second field filename_1 if defined |
---|
[387] | 2071 | VelType_1=[];%default |
---|
| 2072 | FieldName_1=[]; |
---|
| 2073 | ParamOut_1=[]; |
---|
| 2074 | if ~isempty(filename_1) |
---|
| 2075 | if ~exist(filename_1,'file') |
---|
| 2076 | errormsg=['second file ' filename_1 ' does not exist']; |
---|
| 2077 | return |
---|
| 2078 | end |
---|
| 2079 | Name=filename_1; |
---|
[404] | 2080 | switch UvData.FileType{2} |
---|
[387] | 2081 | case {'civx','civdata','netcdf'}; |
---|
| 2082 | list_fields=get(handles.Fields_1,'String');% list menu fields |
---|
[389] | 2083 | FieldName_1= list_fields{get(handles.Fields_1,'Value')}; % selected field |
---|
[387] | 2084 | if ~strcmp(FieldName,'get_field...') |
---|
[389] | 2085 | if get(handles.FixVelType,'Value') |
---|
| 2086 | VelTypeList=get(handles.VelType_1,'String'); |
---|
| 2087 | VelType_1=VelTypeList{get(handles.VelType_1,'Value')};% read the velocity type. |
---|
[387] | 2088 | end |
---|
| 2089 | end |
---|
[405] | 2090 | if strcmp(FieldName_1,'velocity')&& strcmp(get(handles.ColorCode,'Visible'),'on') |
---|
| 2091 | list_code=get(handles.ColorCode,'String');% list menu fields |
---|
| 2092 | index_code=get(handles.ColorCode,'Value');% selected string index |
---|
[387] | 2093 | if ~strcmp(list_code{index_code},'black') && ~strcmp(list_code{index_code},'white') |
---|
[405] | 2094 | list_code=get(handles.ColorScalar,'String');% list menu fields |
---|
| 2095 | index_code=get(handles.ColorScalar,'Value');% selected string index |
---|
| 2096 | ParamIn_1.ColorVar= list_code{index_code}; % selected field for vector color display |
---|
[387] | 2097 | end |
---|
| 2098 | end |
---|
[435] | 2099 | case {'video','mmreader'} |
---|
[387] | 2100 | Name=UvData.MovieObject{2}; |
---|
| 2101 | case 'vol' %TODO: update |
---|
| 2102 | if isfield(UvData.XmlData,'Npy') && isfield(UvData.XmlData,'Npx') |
---|
[405] | 2103 | ParamIn_1.Npy=UvData.XmlData.Npy; |
---|
| 2104 | ParamIn_1.Npx=UvData.XmlData.Npx; |
---|
[387] | 2105 | else |
---|
| 2106 | errormsg='Npx and Npy need to be defined in the xml file for volume images .vol'; |
---|
| 2107 | return |
---|
| 2108 | end |
---|
| 2109 | end |
---|
[428] | 2110 | if isequal(get(handles.NomType_1,'Visible'),'on') |
---|
[387] | 2111 | NomType_1=get(handles.NomType_1,'String'); |
---|
[428] | 2112 | else |
---|
| 2113 | NomType_1=get(handles.NomType,'String'); |
---|
| 2114 | end |
---|
[387] | 2115 | test_keepdata_1=0;% test for keeping the previous stored data if the input files are unchanged |
---|
| 2116 | if ~isequal(NomType_1,'*')%in case of a series of files (not avi movie) |
---|
[389] | 2117 | if isfield(UvData,'filename_1')%&& isfield(UvData,'VelType_1') && isfield(UvData,'FieldName_1') |
---|
| 2118 | test_keepdata_1= strcmp(filename_1,UvData.filename_1) ;%&& strcmp(FieldName_1,UvData.FieldName_1); |
---|
[387] | 2119 | end |
---|
| 2120 | end |
---|
| 2121 | if test_keepdata_1 |
---|
[389] | 2122 | Field{2}=UvData.Field_1;% keep the stored field |
---|
[427] | 2123 | ParamOut_1=UvData.ParamOut_1; |
---|
[387] | 2124 | else |
---|
[405] | 2125 | ParamIn_1.FieldName=FieldName_1; |
---|
| 2126 | ParamIn_1.VelType=VelType_1; |
---|
| 2127 | ParamIn_1.GUIName='get_field_1'; |
---|
| 2128 | [Field{2},ParamOut_1,errormsg] = read_field(Name,UvData.FileType{2},ParamIn_1,num_i1); |
---|
[387] | 2129 | if ~isempty(errormsg) |
---|
| 2130 | errormsg=['error in reading ' FieldName_1 ' in ' filename_1 ': ' errormsg]; |
---|
| 2131 | return |
---|
| 2132 | end |
---|
[405] | 2133 | % UvData.Field_1=Field{2}; %store the second field for possible use at next RUN |
---|
[387] | 2134 | end |
---|
| 2135 | end |
---|
| 2136 | |
---|
| 2137 | %% update uvmat interface |
---|
| 2138 | if isfield(ParamOut,'Npx') |
---|
| 2139 | set(handles.num_Npx,'String',num2str(ParamOut.Npx));% display image size on the interface |
---|
| 2140 | set(handles.num_Npy,'String',num2str(ParamOut.Npy)); |
---|
| 2141 | elseif isfield(ParamOut_1,'Npx') |
---|
| 2142 | set(handles.num_Npx,'String',num2str(ParamOut_1.Npx));% display image size on the interface |
---|
| 2143 | set(handles.num_Npy,'String',num2str(ParamOut_1.Npy)); |
---|
| 2144 | end |
---|
| 2145 | |
---|
| 2146 | %% update the display menu for the first velocity type (first menuline) |
---|
| 2147 | test_veltype=0; |
---|
| 2148 | % if ~isequal(FileType,'netcdf')|| isequal(FieldName,'get_field...') |
---|
[404] | 2149 | if (strcmp(UvData.FileType{1},'civx')||strcmp(UvData.FileType{1},'civdata'))&& ~strcmp(FieldName,'get_field...') |
---|
[387] | 2150 | test_veltype=1; |
---|
| 2151 | set(handles.VelType,'Visible','on') |
---|
| 2152 | set(handles.VelType_1,'Visible','on') |
---|
| 2153 | set(handles.FixVelType,'Visible','on') |
---|
[404] | 2154 | menu=set_veltype_display(ParamOut.CivStage,UvData.FileType{1}); |
---|
[387] | 2155 | index_menu=strcmp(ParamOut.VelType,menu);%look for VelType in the menu |
---|
| 2156 | index_val=find(index_menu,1); |
---|
| 2157 | if isempty(index_val) |
---|
| 2158 | index_val=1; |
---|
| 2159 | end |
---|
| 2160 | set(handles.VelType,'Value',index_val) |
---|
| 2161 | if ~get(handles.SubField,'value') |
---|
| 2162 | set(handles.VelType,'String',menu) |
---|
| 2163 | set(handles.VelType_1,'Value',1) |
---|
| 2164 | set(handles.VelType_1,'String',[{''};menu]) |
---|
| 2165 | end |
---|
| 2166 | else |
---|
| 2167 | set(handles.VelType,'Visible','off') |
---|
| 2168 | end |
---|
[405] | 2169 | % display the Fields menu from the input file and pick the selected one: |
---|
[387] | 2170 | field_index=strcmp(ParamOut.FieldName,ParamOut.FieldList); |
---|
| 2171 | set(handles.Fields,'String',ParamOut.FieldList); %update the field menu |
---|
| 2172 | set(handles.Fields,'Value',find(field_index,1)) |
---|
| 2173 | |
---|
| 2174 | %% update the display menu for the second velocity type (second menuline) |
---|
| 2175 | test_veltype_1=0; |
---|
| 2176 | if isempty(filename_1) |
---|
| 2177 | set(handles.Fields_1,'Value',1); %update the field menu |
---|
| 2178 | set(handles.Fields_1,'String',[{''};ParamOut.FieldList]); %update the field menu |
---|
[405] | 2179 | elseif ~test_keepdata_1 |
---|
[404] | 2180 | if (~strcmp(UvData.FileType{2},'netcdf')&&~strcmp(UvData.FileType{2},'civdata')&&~strcmp(UvData.FileType{2},'civx'))|| isequal(FieldName_1,'get_field...') |
---|
[387] | 2181 | set(handles.VelType_1,'Visible','off') |
---|
[405] | 2182 | else |
---|
[387] | 2183 | test_veltype_1=1; |
---|
| 2184 | set(handles.VelType_1,'Visible','on') |
---|
[405] | 2185 | % if ~get(handles.FixVelType,'Value') |
---|
[387] | 2186 | menu=set_veltype_display(ParamOut_1.CivStage); |
---|
| 2187 | index_menu=strcmp(ParamOut_1.VelType,menu); |
---|
| 2188 | set(handles.VelType_1,'Value',1+find(index_menu,1)) |
---|
| 2189 | set(handles.VelType_1,'String',[{''};menu]) |
---|
[405] | 2190 | % end |
---|
[387] | 2191 | end |
---|
[405] | 2192 | % update the second field menu: the same quantity |
---|
| 2193 | set(handles.Fields_1,'String',[{''};ParamOut_1.FieldList]); %update the field menu |
---|
| 2194 | % display the Fields menu from the input file and pick the selected one: |
---|
| 2195 | field_index=strcmp(ParamOut_1.FieldName,ParamOut_1.FieldList); |
---|
| 2196 | set(handles.Fields_1,'Value',find(field_index,1)+1) |
---|
| 2197 | % % synchronise with the first menu if the first selection is not 'velocity' |
---|
| 2198 | % if ~strcmp(ParamOut.FieldName,'velocity') |
---|
| 2199 | % field_index=strcmp(ParamOut_1.FieldName,ParamOut_1.FieldList); |
---|
| 2200 | % set(handles.Fields_1,'Value',field_index); %update the field menu |
---|
| 2201 | % ParamOut_1.FieldName=ParamOut.FieldName; |
---|
| 2202 | % set(handles.Fields_1,'String',ParamOut_1.FieldList) |
---|
| 2203 | % end |
---|
[387] | 2204 | end |
---|
| 2205 | if test_veltype||test_veltype_1 |
---|
| 2206 | set(handles.FixVelType,'Visible','on') |
---|
| 2207 | else |
---|
| 2208 | set(handles.FixVelType,'Visible','off') |
---|
| 2209 | end |
---|
[405] | 2210 | |
---|
| 2211 | % field_index=strcmp(ParamOut_1.FieldName,ParamOut_1.FieldList); |
---|
| 2212 | % set(handles.Fields,'String',ParamOut.FieldList); %update the field menu |
---|
| 2213 | % set(handles.Fields,'Value',find(field_index,1)) |
---|
[387] | 2214 | |
---|
| 2215 | %% introduce w as background image by default for a new series (only for nbdim=2) |
---|
| 2216 | if ~isfield(UvData,'NewSeries') |
---|
| 2217 | UvData.NewSeries=1; |
---|
| 2218 | end |
---|
| 2219 | %put W as background image by default if NbDim=2: |
---|
| 2220 | if UvData.NewSeries && isequal(get(handles.SubField,'Value'),0) && isfield(Field{1},'W') && ~isempty(Field{1}.W) && ~isequal(Field{1}.NbDim,3); |
---|
| 2221 | set(handles.SubField,'Value',1); |
---|
| 2222 | set(handles.RootPath_1,'String','"') |
---|
| 2223 | set(handles.RootFile_1,'String','"') |
---|
| 2224 | set(handles.SubDir_1,'String','"'); |
---|
| 2225 | indices=fullfile_uvmat('','','','',NomType,num_i1,num_i2,num_j1,num_j2); |
---|
| 2226 | set(handles.FileIndex_1,'String',indices) |
---|
| 2227 | set(handles.FileExt_1,'String','"'); |
---|
| 2228 | set(handles.Fields_1,'Visible','on'); |
---|
| 2229 | set(handles.Fields_1,'Visible','on'); |
---|
| 2230 | set(handles.RootPath_1,'Visible','on') |
---|
| 2231 | set(handles.RootFile_1,'Visible','on') |
---|
| 2232 | set(handles.SubDir_1,'Visible','on'); |
---|
| 2233 | set(handles.FileIndex_1,'Visible','on'); |
---|
| 2234 | set(handles.FileExt_1,'Visible','on'); |
---|
| 2235 | set(handles.Fields_1,'Visible','on'); |
---|
| 2236 | Field{1}.AName='w'; |
---|
| 2237 | end |
---|
| 2238 | |
---|
[415] | 2239 | %% display time |
---|
| 2240 | testimedoc=0; |
---|
| 2241 | TimeUnit=''; |
---|
| 2242 | if isfield(Field{1},'Time') |
---|
| 2243 | abstime=Field{1}.Time;%time read from the netcdf input file |
---|
| 2244 | end |
---|
| 2245 | if numel(Field)==2 && isfield(Field{2},'Time') |
---|
| 2246 | abstime_1=Field{2}.Time;%time read from the netcdf input file |
---|
| 2247 | end |
---|
| 2248 | if isfield(Field{1},'Dt') |
---|
| 2249 | dt=Field{1}.Dt;%dt read from the netcdf input file |
---|
| 2250 | if isfield(Field{1},'TimeUnit') |
---|
| 2251 | TimeUnit=Field{1}.TimeUnit; |
---|
| 2252 | end |
---|
| 2253 | elseif numel(Field)==2 && isfield(Field{2},'Dt')%dt obtained from the second field if not defined in the first |
---|
| 2254 | dt=Field{2}.Dt;%dt read from the netcdf input file |
---|
| 2255 | if isfield(Field{2},'TimeUnit') |
---|
| 2256 | TimeUnit=Field{2}.TimeUnit; |
---|
| 2257 | end |
---|
| 2258 | end |
---|
| 2259 | % time from xml file overset previous result |
---|
| 2260 | if isfield(UvData,'XmlData') && isfield(UvData.XmlData{1},'Time') |
---|
| 2261 | if isempty(num_i2)||isnan(num_i2) |
---|
| 2262 | num_i2=num_i1; |
---|
| 2263 | end |
---|
| 2264 | if isempty(num_j1)||isnan(num_j1) |
---|
| 2265 | num_j1=1; |
---|
| 2266 | end |
---|
| 2267 | if isempty(num_j2)||isnan(num_j2) |
---|
| 2268 | num_j2=num_j1; |
---|
| 2269 | end |
---|
| 2270 | siz=size(UvData.XmlData{1}.Time); |
---|
| 2271 | if siz(1)>=max(num_i1,num_i2) && siz(2)>=max(num_j1,num_j2) |
---|
| 2272 | abstime=(UvData.XmlData{1}.Time(num_i1,num_j1)+UvData.XmlData{1}.Time(num_i2,num_j2))/2;%overset the time read from files |
---|
| 2273 | dt=(UvData.XmlData{1}.Time(num_i2,num_j2)-UvData.XmlData{1}.Time(num_i1,num_j1)); |
---|
| 2274 | Field{1}.Dt=dt; |
---|
| 2275 | if isfield(UvData.XmlData{1},'TimeUnit') |
---|
| 2276 | TimeUnit=UvData.XmlData{1}.TimeUnit; |
---|
| 2277 | end |
---|
| 2278 | end |
---|
| 2279 | if numel(UvData.XmlData)==2 |
---|
| 2280 | [tild,tild,tild,num_i1,num_i2,num_j1,num_j2]=fileparts_uvmat(['xx' get(handles.FileIndex_1,'String') get(handles.FileExt_1,'String')]); |
---|
| 2281 | if isempty(num_i2) |
---|
| 2282 | num_i2=num_i1; |
---|
| 2283 | end |
---|
| 2284 | if isempty(num_j1) |
---|
| 2285 | num_j1=1; |
---|
| 2286 | end |
---|
| 2287 | if isempty(num_j2) |
---|
| 2288 | num_j2=num_j1; |
---|
| 2289 | end |
---|
| 2290 | siz=size(UvData.XmlData{2}.Time); |
---|
| 2291 | if ~isempty(num_i1) && siz(1)>=max(num_i1,num_i2) && siz(2)>=max(num_j1,num_j2) |
---|
| 2292 | abstime_1=(UvData.XmlData{2}.Time(num_i1,num_j1)+UvData.XmlData{2}.Time(num_i2,num_j2))/2;%overset the time read from files |
---|
| 2293 | Field{2}.Dt=(UvData.XmlData{2}.Time(num_i2,num_j2)-UvData.XmlData{2}.Time(num_i1,num_j1)); |
---|
| 2294 | end |
---|
| 2295 | end |
---|
| 2296 | end |
---|
| 2297 | if ~isequal(numel(abstime),1) |
---|
| 2298 | abstime=[]; |
---|
| 2299 | end |
---|
| 2300 | if ~isequal(numel(abstime_1),1) |
---|
| 2301 | abstime_1=[]; |
---|
| 2302 | end |
---|
| 2303 | set(handles.abs_time,'String',num2str(abstime,4)) |
---|
| 2304 | set(handles.abs_time_1,'String',num2str(abstime_1,4)) |
---|
| 2305 | % if testimedoc && isfield(UvData,'dt') |
---|
| 2306 | % dt=UvData.dt; |
---|
| 2307 | % end |
---|
| 2308 | if isempty(dt)||isequal(dt,0) |
---|
| 2309 | set(handles.Dt_txt,'String','') |
---|
| 2310 | else |
---|
| 2311 | if isempty(TimeUnit) |
---|
| 2312 | set(handles.Dt_txt,'String',['Dt=' num2str(1000*dt,3) ' 10^(-3)'] ) |
---|
| 2313 | else |
---|
| 2314 | set(handles.Dt_txt,'String',['Dt=' num2str(1000*dt,3) ' m' TimeUnit] ) |
---|
| 2315 | end |
---|
| 2316 | end |
---|
| 2317 | |
---|
| 2318 | |
---|
[387] | 2319 | %% store the current open names, fields and vel types in uvmat interface |
---|
| 2320 | UvData.filename_1=filename_1; |
---|
| 2321 | |
---|
| 2322 | %% apply coordinate transform or other user fct |
---|
| 2323 | XmlData=[];%default |
---|
| 2324 | XmlData_1=[];%default |
---|
| 2325 | if isfield(UvData,'XmlData')%use geometry calib recorded from the ImaDoc xml file as first priority |
---|
| 2326 | XmlData=UvData.XmlData{1}; |
---|
| 2327 | if numel(UvData.XmlData)==2 |
---|
| 2328 | XmlData_1=UvData.XmlData{2}; |
---|
| 2329 | end |
---|
| 2330 | end |
---|
| 2331 | choice_value=get(handles.transform_fct,'Value'); |
---|
| 2332 | transform_list=get(handles.transform_fct,'UserData'); |
---|
| 2333 | transform=transform_list{choice_value};%selected function handles |
---|
| 2334 | % z index |
---|
| 2335 | if ~isempty(filename) |
---|
| 2336 | Field{1}.ZIndex=z_index; |
---|
| 2337 | end |
---|
[389] | 2338 | if ~isempty(transform) |
---|
[387] | 2339 | if length(Field)>=2 |
---|
| 2340 | Field{2}.ZIndex=z_index; |
---|
| 2341 | [Field{1},Field{2}]=transform(Field{1},XmlData,Field{2},XmlData_1); |
---|
| 2342 | if isempty(Field{2}) |
---|
| 2343 | Field(2)=[]; |
---|
| 2344 | end |
---|
| 2345 | else |
---|
| 2346 | Field{1}=transform(Field{1},XmlData); |
---|
| 2347 | end |
---|
[389] | 2348 | %% update tps in phys coordinates if needed |
---|
[404] | 2349 | if (strcmp(VelType,'filter1')||strcmp(VelType,'filter2'))&& strcmp(UvData.FileType{1},'civdata')&&isfield(Field{1},'U')&& isfield(Field{1},'V') |
---|
[389] | 2350 | Field{1}.X=Field{1}.X(Field{1}.FF==0); |
---|
| 2351 | Field{1}.Y=Field{1}.Y(Field{1}.FF==0); |
---|
| 2352 | Field{1}.U=Field{1}.U(Field{1}.FF==0); |
---|
| 2353 | Field{1}.V=Field{1}.V(Field{1}.FF==0); |
---|
| 2354 | [Field{1}.SubRange,Field{1}.NbSites,Field{1}.Coord_tps,Field{1}.U_tps,Field{1}.V_tps]=filter_tps([Field{1}.X Field{1}.Y],Field{1}.U,Field{1}.V,[],Field{1}.Patch1_SubDomain,0); |
---|
| 2355 | end |
---|
[404] | 2356 | if numel(Field)==2 && ~test_keepdata_1 && isequal(UvData.FileType{2}(1:3),'civ') && ~isequal(ParamOut_1.FieldName,'get_field...')%&&~isempty(FieldName_1) |
---|
[389] | 2357 | %update tps in phys coordinates if needed |
---|
[404] | 2358 | if (strcmp(VelType_1,'filter1')||strcmp(VelType_1,'filter2'))&& strcmp(UvData.FileType{2},'civdata')&&isfield(Field{2},'U')&& isfield(Field{2},'V') |
---|
[389] | 2359 | Field{2}.X=Field{2}.X(Field{2}.FF==0); |
---|
| 2360 | Field{2}.Y=Field{1}.Y(Field{2}.FF==0); |
---|
| 2361 | Field{2}.U=Field{1}.U(Field{2}.FF==0); |
---|
| 2362 | Field{2}.V=Field{1}.V(Field{2}.FF==0); |
---|
| 2363 | [Field{2}.SubRange,Field{2}.NbSites,Field{2}.Coord_tps,Field{2}.U_tps,Field{2}.V_tps]=filter_tps([Field{2}.X Field{2}.Y],Field{2}.U,Field{2}.V,[],1500,0); |
---|
| 2364 | end |
---|
| 2365 | end |
---|
[387] | 2366 | end |
---|
| 2367 | |
---|
| 2368 | %% calculate scalar |
---|
[421] | 2369 | if ~strcmp(ParamOut.FieldName,'get_field...')&& (strcmp(UvData.FileType{1},'civdata')||strcmp(UvData.FileType{1},'civx'))%&&~strcmp(ParamOut.FieldName,'velocity')&& ~strcmp(ParamOut.FieldName,'get_field...');% ~isequal(ParamOut.CivStage,0)%&&~isempty(FieldName)% |
---|
[405] | 2370 | Field{1}=calc_field([{ParamOut.FieldName} {ParamOut.ColorVar}],Field{1}); |
---|
| 2371 | end |
---|
[421] | 2372 | if numel(Field)==2 && ~strcmp(ParamOut_1.FieldName,'get_field...')&& ~test_keepdata_1 && (strcmp(UvData.FileType{2},'civdata')||strcmp(UvData.FileType{2},'civx')) &&~strcmp(ParamOut_1.FieldName,'velocity') && ~strcmp(ParamOut_1.FieldName,'get_field...') |
---|
[405] | 2373 | Field{2}=calc_field([{ParamOut_1.FieldName} {ParamOut_1.ColorVar}],Field{2}); |
---|
| 2374 | end |
---|
[387] | 2375 | |
---|
| 2376 | %% combine the two input fields (e.g. substract velocity fields) |
---|
[405] | 2377 | %Field{1}.FieldList=[{ParamOut.FieldName} {ParamOut.ColorVar}]; |
---|
[387] | 2378 | if numel(Field)==2 |
---|
[405] | 2379 | % Field{2}.FieldList=[{ParamOut_1.FieldName} {ParamOut_1.ColorVar}]; |
---|
[402] | 2380 | [UvData.Field,errormsg]=sub_field(Field{1},Field{2}); |
---|
[405] | 2381 | UvData.Field_1=Field{2}; %store the second field for possible use at next RUN |
---|
[427] | 2382 | UvData.ParamOut_1=ParamOut_1; |
---|
[387] | 2383 | else |
---|
| 2384 | UvData.Field=Field{1}; |
---|
| 2385 | end |
---|
[402] | 2386 | if ~isempty(errormsg) |
---|
| 2387 | errormsg=['error in uvmat/refresh_field/sub_field:' errormsg]; |
---|
| 2388 | return |
---|
| 2389 | end |
---|
[404] | 2390 | %UvData.Field.FieldList={FieldName}; % TODO: to generalise, used for proj_field with tps interpolation |
---|
[387] | 2391 | |
---|
[434] | 2392 | %% analyse input field |
---|
[387] | 2393 | test_x=0; |
---|
| 2394 | test_z=0;% test for unstructured z coordinate |
---|
[434] | 2395 | [errormsg,ListDimName,DimValue,VarDimIndex]=check_field_structure(UvData.Field);% check the input field structure |
---|
[387] | 2396 | if ~isempty(errormsg) |
---|
[434] | 2397 | errormsg=['error in uvmat/refresh_field/check_field_structure: ' errormsg];% display error |
---|
[387] | 2398 | return |
---|
| 2399 | end |
---|
[434] | 2400 | [CellVarIndex,NbDim,VarType,errormsg]=find_field_indices(UvData.Field);% analyse the input field structure |
---|
[387] | 2401 | if ~isempty(errormsg) |
---|
[434] | 2402 | errormsg=['error in uvmat/refresh_field/find_field_indices: ' errormsg];% display error |
---|
[387] | 2403 | return |
---|
| 2404 | end |
---|
[421] | 2405 | [NbDim,imax]=max(NbDim);% spatial dimension of the input field |
---|
[387] | 2406 | if isfield(UvData.Field,'NbDim') |
---|
| 2407 | NbDim=UvData.Field.NbDim;% deal with plane fields containing z coordinates |
---|
| 2408 | end |
---|
[434] | 2409 | |
---|
| 2410 | %% get bounds and mesh (needed for mouse action and to open set_object) |
---|
[435] | 2411 | if NbDim>1 |
---|
| 2412 | XName=''; %default |
---|
| 2413 | YName=''; |
---|
| 2414 | %unstructured coordinates |
---|
| 2415 | if ~isempty(VarType{imax}.coord_x)&&~isempty(VarType{imax}.coord_y) |
---|
| 2416 | XName=UvData.Field.ListVarName{VarType{imax}.coord_x}; |
---|
[434] | 2417 | YName=UvData.Field.ListVarName{VarType{imax}.coord_y}; |
---|
| 2418 | %nbvec=length(UvData.Field.(XName));%nbre of measurement points (e.g. vectors) |
---|
| 2419 | test_x=1;%test for unstructured coordinates |
---|
| 2420 | if ~isempty(VarType{imax}.coord_z) |
---|
| 2421 | ZName=UvData.Field.ListVarName{VarType{imax}.coord_z}; |
---|
| 2422 | else |
---|
| 2423 | NbDim=2; |
---|
| 2424 | end |
---|
[435] | 2425 | %structured coordinate |
---|
| 2426 | elseif numel(VarType)>=imax && numel(VarType{imax}.coord)>=NbDim && VarType{imax}.coord(NbDim)>0 |
---|
| 2427 | XName=UvData.Field.ListVarName{VarType{imax}.coord(NbDim)}; |
---|
| 2428 | if NbDim> 1 && VarType{imax}.coord(NbDim-1)>0 |
---|
| 2429 | YName=UvData.Field.ListVarName{VarType{imax}.coord(NbDim-1)}; %structured coordinates |
---|
| 2430 | end |
---|
| 2431 | % VarIndex=CellVarIndex{imax}; % list of variable indices |
---|
| 2432 | DimIndex=VarDimIndex{CellVarIndex{imax}(1)}; %list of dim indices for the variable |
---|
| 2433 | nbpoints_x=DimValue(DimIndex(NbDim)); |
---|
| 2434 | XMax=nbpoints_x;%default |
---|
| 2435 | XMin=1;%default |
---|
[387] | 2436 | end |
---|
[435] | 2437 | |
---|
| 2438 | if NbDim==3 |
---|
| 2439 | if ~test_x |
---|
| 2440 | ZName=UvData.Field.ListVarName{VarType{imax}.coord(1)};%structured coordinates in 3D |
---|
| 2441 | end |
---|
| 2442 | ZMax=max(UvData.Field.(ZName)); |
---|
| 2443 | ZMin=min(UvData.Field.(ZName)); |
---|
| 2444 | UvData.Field.ZMax=ZMax; |
---|
| 2445 | UvData.Field.ZMin=ZMin; |
---|
| 2446 | test_z=1; |
---|
| 2447 | if isequal(ZMin,ZMax)%no z dependency |
---|
| 2448 | NbDim=2; |
---|
| 2449 | test_z=0; |
---|
| 2450 | end |
---|
[387] | 2451 | end |
---|
[435] | 2452 | if ~isempty (XName) |
---|
| 2453 | XMax=max(max(UvData.Field.(XName))); |
---|
| 2454 | XMin=min(min(UvData.Field.(XName))); |
---|
| 2455 | UvData.Field.NbDim=NbDim; |
---|
| 2456 | UvData.Field.XMax=XMax; |
---|
| 2457 | UvData.Field.XMin=XMin; |
---|
| 2458 | if NbDim >1&& ~isempty(YName) |
---|
| 2459 | YMax=max(max(UvData.Field.(YName))); |
---|
| 2460 | YMin=min(min(UvData.Field.(YName))); |
---|
| 2461 | UvData.Field.YMax=YMax; |
---|
| 2462 | UvData.Field.YMin=YMin; |
---|
| 2463 | end |
---|
| 2464 | nbvec=length(UvData.Field.(XName)); |
---|
| 2465 | if test_x %unstructured coordinates |
---|
| 2466 | if test_z |
---|
| 2467 | UvData.Field.Mesh=((XMax-XMin)*(YMax-YMin)*(ZMax-ZMin))/nbvec;% volume per vector |
---|
| 2468 | UvData.Field.Mesh=(UvData.Field.Mesh)^(1/3); |
---|
| 2469 | else |
---|
| 2470 | UvData.Field.Mesh=sqrt((XMax-XMin)*(YMax-YMin)/nbvec);%2D |
---|
| 2471 | end |
---|
| 2472 | end |
---|
| 2473 | end |
---|
| 2474 | % case of structured coordinates |
---|
[387] | 2475 | if ~test_x |
---|
[435] | 2476 | DX=(XMax-XMin)/(nbpoints_x-1); |
---|
| 2477 | if NbDim >1 |
---|
| 2478 | nbpoints_y=DimValue(DimIndex(NbDim-1)); |
---|
| 2479 | if isempty(YName)% if the y coordinate is not expressed, it is taken as the matrix index |
---|
| 2480 | DY=1; |
---|
| 2481 | UvData.Field.YMax=nbpoints_y; |
---|
| 2482 | UvData.Field.YMin=1; |
---|
| 2483 | else |
---|
| 2484 | DY=(YMax-YMin)/(nbpoints_y-1); |
---|
| 2485 | end |
---|
[387] | 2486 | end |
---|
[435] | 2487 | if NbDim==3 |
---|
| 2488 | nbpoints_z=DimValue(DimIndex(1)); |
---|
| 2489 | DZ=(ZMax-ZMin)/(nbpoints_z-1); |
---|
| 2490 | UvData.Field.Mesh=(DX*DY*DZ)^(1/3); |
---|
| 2491 | UvData.Field.ZMax=ZMax; |
---|
| 2492 | UvData.Field.ZMin=ZMin; |
---|
[421] | 2493 | else |
---|
[435] | 2494 | UvData.Field.Mesh=DX;%sqrt(DX*DY); |
---|
[387] | 2495 | end |
---|
| 2496 | end |
---|
[435] | 2497 | % adjust the mesh to a value 1, 2 , 5 *10^n |
---|
| 2498 | ord=10^(floor(log10(UvData.Field.Mesh)));%order of magnitude |
---|
| 2499 | if UvData.Field.Mesh/ord>=5 |
---|
| 2500 | UvData.Field.Mesh=5*ord; |
---|
| 2501 | elseif UvData.Field.Mesh/ord>=2 |
---|
| 2502 | UvData.Field.Mesh=2*ord; |
---|
[404] | 2503 | else |
---|
[435] | 2504 | UvData.Field.Mesh=ord; |
---|
[404] | 2505 | end |
---|
[435] | 2506 | UvData.Object{1}.Type='plane';%main plotting plane |
---|
| 2507 | UvData.Object{1}.ProjMode='projection';%main plotting plane |
---|
| 2508 | UvData.Object{1}.DisplayHandle.uvmat=[]; %plane not visible in uvmat |
---|
| 2509 | UvData.Object{1}.DisplayHandle.view_field=[]; %plane not visible in uvmat |
---|
| 2510 | |
---|
| 2511 | %% 3D case (menuvolume) |
---|
| 2512 | if NbDim==3% && UvData.NewSeries |
---|
| 2513 | test_set_object=1; |
---|
| 2514 | hset_object=findobj(allchild(0),'tag','set_object');% look for the set_object GUI |
---|
| 2515 | ZBounds(1)=UvData.Field.ZMin; %minimum for the Z slider |
---|
| 2516 | ZBounds(2)=UvData.Field.ZMax;%maximum for the Z slider |
---|
| 2517 | if ~isempty(hset_object) %if set_object is detected |
---|
| 2518 | delete(hset_object);% delete the GUI set_object if it does not fit |
---|
[387] | 2519 | end |
---|
[435] | 2520 | if test_set_object% reinitiate the GUI set_object |
---|
| 2521 | delete_object(1);% delete the current projection object in the list UvData.Object, delete its graphic representations and update the list displayed in handles.ListObject and 2 |
---|
| 2522 | UvData.Object{1}.NbDim=NbDim;%test for 3D objects |
---|
| 2523 | UvData.Object{1}.RangeZ=UvData.Field.Mesh;%main plotting plane |
---|
| 2524 | UvData.Object{1}.Coord(1,3)=(UvData.Field.ZMin+UvData.Field.ZMax)/2;%section at a middle plane chosen |
---|
| 2525 | UvData.Object{1}.Angle=[0 0 0]; |
---|
| 2526 | UvData.Object{1}.HandlesDisplay=plot(0,0,'Tag','proj_object');% A REVOIR |
---|
| 2527 | UvData.Object{1}.Name='1-PLANE'; |
---|
| 2528 | UvData.Object{1}.enable_plot=1; |
---|
| 2529 | set_object(UvData.Object{1},handles,ZBounds); |
---|
| 2530 | set(handles.ListObject,'Value',1); |
---|
| 2531 | set(handles.ListObject,'String',{'1-PLANE'}); |
---|
| 2532 | set(handles.edit_object,'Value',1)% put the plane in edit mode to enable the z cursor |
---|
| 2533 | edit_object_Callback([],[], handles) |
---|
[387] | 2534 | end |
---|
[435] | 2535 | %multilevel case (single menuplane in a 3D space) |
---|
| 2536 | elseif isfield(UvData,'Z') |
---|
| 2537 | if isfield(UvData,'CoordType')&& isequal(UvData.CoordType,'phys') && isfield(UvData,'XmlData') |
---|
| 2538 | XmlData=UvData.XmlData{1}; |
---|
| 2539 | if isfield(XmlData,'PlanePos') |
---|
| 2540 | UvData.Object{1}.Coord=XmlData.PlanePos(UvData.ZIndex,:); |
---|
| 2541 | end |
---|
| 2542 | if isfield(XmlData,'PlaneAngle') |
---|
| 2543 | siz=size(XmlData.PlaneAngle); |
---|
| 2544 | indangle=min(siz(1),UvData.ZIndex);%take first angle if a single angle is defined (translating scanning) |
---|
| 2545 | UvData.Object{1}.PlaneAngle=XmlData.PlaneAngle(indangle,:); |
---|
| 2546 | end |
---|
| 2547 | elseif isfield(UvData,'ZIndex') |
---|
| 2548 | UvData.Object{1}.ZObject=UvData.ZIndex; |
---|
| 2549 | end |
---|
[387] | 2550 | end |
---|
| 2551 | end |
---|
[435] | 2552 | |
---|
[387] | 2553 | testnewseries=UvData.NewSeries; |
---|
| 2554 | UvData.NewSeries=0;% put to 0 the test for a new field series (set by RootPath_callback) |
---|
| 2555 | set(handles.uvmat,'UserData',UvData) |
---|
| 2556 | |
---|
| 2557 | %% reset the min and max of scalar if only the mask is displayed(TODO: check the need) |
---|
[405] | 2558 | % if isfield(UvData,'Mask')&& ~isfield(UvData,'A') |
---|
| 2559 | % set(handles.num_MinA,'String','0') |
---|
| 2560 | % set(handles.num_MaxA,'String','255') |
---|
| 2561 | % end |
---|
[387] | 2562 | |
---|
[434] | 2563 | %% usual 1D (x,y) plots |
---|
| 2564 | if NbDim<=1 |
---|
| 2565 | set(handles.Objects,'Visible','off') |
---|
| 2566 | set(handles.ListObject_1_title,'Visible','off') |
---|
| 2567 | set(handles.ListObject_1,'Visible','off') |
---|
| 2568 | [PlotType,PlotParamOut]=plot_field(UvData.Field,handles.axes3,read_GUI(handles.uvmat)); |
---|
| 2569 | write_plot_param(handles,PlotParamOut) %update the auto plot parameters |
---|
| 2570 | % if isfield(Field,'Mesh')&&~isempty(Field.Mesh) |
---|
| 2571 | % ObjectData.Mesh=Field.Mesh; % gives an estimated mesh size (useful for mouse action on the plot) |
---|
| 2572 | % end |
---|
| 2573 | |
---|
| 2574 | %% 2D or 3D fields are generally projected |
---|
[387] | 2575 | else |
---|
[434] | 2576 | set(handles.Objects,'Visible','on') |
---|
| 2577 | set(handles.ListObject_1_title,'Visible','on') |
---|
| 2578 | set(handles.ListObject_1,'Visible','on') |
---|
| 2579 | |
---|
| 2580 | %% Plot the projections on the selected projection objects |
---|
| 2581 | % main projection object (uvmat display) |
---|
| 2582 | list_object=get(handles.ListObject_1,'String'); |
---|
| 2583 | if isequal(list_object,{''})%refresh list of objects if the menu is empty |
---|
| 2584 | UvData.Object={[]}; |
---|
| 2585 | set(handles.ListObject_1,'Value',1) |
---|
[387] | 2586 | end |
---|
[434] | 2587 | IndexObj(1)=get(handles.ListObject_1,'Value');%selected projection object for main view |
---|
| 2588 | if IndexObj(1)> numel(UvData.Object) |
---|
| 2589 | IndexObj(1)=1;%select the first object if the selected one does not exist |
---|
| 2590 | set(handles.ListObject_1,'Value',1) |
---|
[387] | 2591 | end |
---|
[434] | 2592 | IndexObj(2)=get(handles.ListObject,'Value');%selected projection object for main view |
---|
| 2593 | if isequal(IndexObj(2),IndexObj(1)) |
---|
| 2594 | IndexObj(2)=[]; |
---|
| 2595 | end |
---|
| 2596 | plot_handles{1}=handles; |
---|
| 2597 | if isfield(UvData,'plotaxes')%case of movies |
---|
| 2598 | haxes(1)=UvData.plotaxes; |
---|
| 2599 | else |
---|
| 2600 | haxes(1)=handles.axes3; |
---|
| 2601 | end |
---|
| 2602 | PlotParam{1}=read_GUI(handles.uvmat); |
---|
| 2603 | %default settings if vectors not visible |
---|
| 2604 | if ~isfield(PlotParam{1},'Vectors') |
---|
| 2605 | PlotParam{1}.Vectors.MaxVec=1; |
---|
| 2606 | PlotParam{1}.Vectors.MinVec=0; |
---|
| 2607 | PlotParam{1}.Vectors.CheckFixVecColor=1; |
---|
| 2608 | PlotParam{1}.Vectors.ColCode1=0.33; |
---|
| 2609 | PlotParam{1}.Vectors.ColCode2=0.66; |
---|
| 2610 | PlotParam{1}.Vectors.ColorScalar={'ima_cor'}; |
---|
| 2611 | PlotParam{1}.Vectors.ColorCode= {'rgb'}; |
---|
| 2612 | end |
---|
| 2613 | PosColorbar{1}=UvData.OpenParam.PosColorbar;%prescribe the colorbar position on the uvmat interface |
---|
| 2614 | |
---|
| 2615 | %% second projection object (view_field display) |
---|
| 2616 | if length( IndexObj)>=2 |
---|
| 2617 | view_field_handle=findobj(allchild(0),'tag','view_field');%handles of the view_field GUI |
---|
| 2618 | if ~isempty(view_field_handle) |
---|
| 2619 | plot_handles{2}=guidata(view_field_handle); |
---|
| 2620 | haxes(2)=plot_handles{2}.axes3; |
---|
| 2621 | PlotParam{2}=read_GUI(handles.uvmat);%read plotting parameters on the uvmat interface |
---|
| 2622 | PosColorbar{2}='*'; %TODO: deal with colorbar position on view_field |
---|
[421] | 2623 | end |
---|
[387] | 2624 | end |
---|
[434] | 2625 | |
---|
| 2626 | %% loop on the projection objects: one or two |
---|
| 2627 | |
---|
| 2628 | for imap=1:numel(IndexObj) |
---|
| 2629 | iobj=IndexObj(imap); |
---|
| 2630 | % if imap==2 || check_proj==0 % field not yet projected) && ~isfield(UvData.Object{iobj},'Type')% case with no projection (only for the first empty object) |
---|
| 2631 | % % [ObjectData,errormsg]=calc_field(UvData.Field.FieldList,UvData.Field); |
---|
| 2632 | % % else |
---|
| 2633 | [ObjectData,errormsg]=proj_field(UvData.Field,UvData.Object{iobj});% project field on the object |
---|
| 2634 | % end |
---|
| 2635 | if ~isempty(errormsg) |
---|
| 2636 | return |
---|
[387] | 2637 | end |
---|
[434] | 2638 | if testnewseries |
---|
| 2639 | PlotParam{imap}.Scalar.CheckBW=[]; %B/W option depends on the input field (image or scalar) |
---|
| 2640 | if isfield(ObjectData,'CoordUnit') |
---|
| 2641 | PlotParam{imap}.Coordinates.CheckFixAspectRatio=1;% set x and y scaling equal if CoordUnit is defined (common unit for x and y) |
---|
| 2642 | PlotParam{imap}.Coordinates.AspectRatio=1; %set aspect ratio to 1 |
---|
[387] | 2643 | end |
---|
[434] | 2644 | end |
---|
| 2645 | %use of mask (TODO: check) |
---|
| 2646 | if isfield(ObjectData,'NbDim') && isequal(ObjectData.NbDim,2) && isfield(ObjectData,'Mask') && isfield(ObjectData,'A') |
---|
| 2647 | flag_mask=double(ObjectData.Mask>200);%=0 for masked regions |
---|
| 2648 | AX=ObjectData.AX;%x coordiantes for the scalar field |
---|
| 2649 | AY=ObjectData.AY;%y coordinates for the scalar field |
---|
| 2650 | MaskX=ObjectData.MaskX;%x coordiantes for the mask |
---|
| 2651 | MaskY=ObjectData.MaskY;%y coordiantes for the mask |
---|
| 2652 | if ~isequal(MaskX,AX)||~isequal(MaskY,AY) |
---|
| 2653 | nxy=size(flag_mask); |
---|
| 2654 | sizpx=(ObjectData.MaskX(end)-ObjectData.MaskX(1))/(nxy(2)-1);%size of a mask pixel |
---|
| 2655 | sizpy=(ObjectData.MaskY(1)-ObjectData.MaskY(end))/(nxy(1)-1); |
---|
| 2656 | x_mask=ObjectData.MaskX(1):sizpx:ObjectData.MaskX(end); % pixel x coordinates for image display |
---|
| 2657 | y_mask=ObjectData.MaskY(1):-sizpy:ObjectData.MaskY(end);% pixel x coordinates for image display |
---|
| 2658 | %project on the positions of the scalar |
---|
| 2659 | npxy=size(ObjectData.A); |
---|
| 2660 | dxy(1)=(ObjectData.AY(end)-ObjectData.AY(1))/(npxy(1)-1);%grid mesh in y |
---|
| 2661 | dxy(2)=(ObjectData.AX(end)-ObjectData.AX(1))/(npxy(2)-1);%grid mesh in x |
---|
| 2662 | xi=ObjectData.AX(1):dxy(2):ObjectData.AX(end); |
---|
| 2663 | yi=ObjectData.AY(1):dxy(1):ObjectData.AY(end); |
---|
| 2664 | [XI,YI]=meshgrid(xi,yi);% creates the matrix of regular coordinates |
---|
| 2665 | flag_mask = interp2(x_mask,y_mask,flag_mask,XI,YI); |
---|
| 2666 | end |
---|
| 2667 | AClass=class(ObjectData.A); |
---|
| 2668 | ObjectData.A=flag_mask.*double(ObjectData.A); |
---|
| 2669 | ObjectData.A=feval(AClass,ObjectData.A); |
---|
[387] | 2670 | ind_off=[]; |
---|
[434] | 2671 | if isfield(ObjectData,'ListVarName') |
---|
| 2672 | for ilist=1:length(ObjectData.ListVarName) |
---|
| 2673 | if isequal(ObjectData.ListVarName{ilist},'Mask')||isequal(ObjectData.ListVarName{ilist},'MaskX')||isequal(ObjectData.ListVarName{ilist},'MaskY') |
---|
| 2674 | ind_off=[ind_off ilist]; |
---|
| 2675 | end |
---|
[387] | 2676 | end |
---|
[434] | 2677 | ObjectData.ListVarName(ind_off)=[]; |
---|
| 2678 | VarDimIndex(ind_off)=[]; |
---|
| 2679 | ind_off=[]; |
---|
| 2680 | for ilist=1:length(ListDimName) |
---|
| 2681 | if isequal(ListDimName{ilist},'MaskX') || isequal(ListDimName{ilist},'MaskY') |
---|
| 2682 | ind_off=[ind_off ilist]; |
---|
| 2683 | end |
---|
| 2684 | end |
---|
| 2685 | ListDimName(ind_off)=[]; |
---|
| 2686 | DimValue(ind_off)=[]; |
---|
[387] | 2687 | end |
---|
| 2688 | end |
---|
[434] | 2689 | if ~isempty(ObjectData) |
---|
| 2690 | PlotType='none'; %default |
---|
| 2691 | if imap==2 && isempty(view_field_handle) |
---|
| 2692 | view_field(ObjectData) |
---|
| 2693 | else |
---|
| 2694 | [PlotType,PlotParamOut]=plot_field(ObjectData,haxes(imap),PlotParam{imap},PosColorbar{imap}); |
---|
| 2695 | write_plot_param(plot_handles{imap},PlotParamOut) %update the auto plot parameters |
---|
| 2696 | if isfield(Field,'Mesh')&&~isempty(Field.Mesh) |
---|
| 2697 | ObjectData.Mesh=Field.Mesh; % gives an estimated mesh size (useful for mouse action on the plot) |
---|
| 2698 | end |
---|
[387] | 2699 | end |
---|
[434] | 2700 | if isequal(PlotType,'none') |
---|
| 2701 | hget_field=findobj(allchild(0),'name','get_field'); |
---|
| 2702 | if isempty(hget_field) |
---|
| 2703 | get_field(filename)% the projected field cannot be automatically plotted: use get_field to specify the variablesdelete(hget_field) |
---|
| 2704 | end |
---|
| 2705 | errormsg='The field defined by get_field cannot be plotted'; |
---|
| 2706 | return |
---|
[387] | 2707 | end |
---|
| 2708 | end |
---|
| 2709 | end |
---|
[434] | 2710 | |
---|
| 2711 | %% update the mask |
---|
| 2712 | if isequal(get(handles.CheckMask,'Value'),1)%if the mask option is on |
---|
| 2713 | update_mask(handles,num_i1,num_i2); |
---|
| 2714 | end |
---|
| 2715 | |
---|
| 2716 | %% prepare the menus of histograms and plot them (histogram of the whole volume in 3D case) |
---|
| 2717 | menu_histo=(UvData.Field.ListVarName)';%list of field variables to be displayed for the menu of histogram display |
---|
| 2718 | ind_skip=[]; |
---|
| 2719 | % nb_histo=1; |
---|
| 2720 | Ustring=''; |
---|
| 2721 | Vstring=''; |
---|
| 2722 | % suppress coordinates from the histogram menu |
---|
| 2723 | for ivar=1:numel(menu_histo)%l loop on field variables: |
---|
| 2724 | if isfield(UvData.Field,'VarAttribute') && numel(UvData.Field.VarAttribute)>=ivar && isfield(UvData.Field.VarAttribute{ivar},'Role') |
---|
| 2725 | Role=UvData.Field.VarAttribute{ivar}.Role; |
---|
| 2726 | switch Role |
---|
| 2727 | case {'coord_x','coord_y','coord_z','dimvar'} |
---|
| 2728 | ind_skip=[ind_skip ivar]; |
---|
| 2729 | case {'vector_x'} |
---|
| 2730 | Ustring=UvData.Field.ListVarName{ivar}; |
---|
| 2731 | ind_skip=[ind_skip ivar]; |
---|
| 2732 | case {'vector_y'} |
---|
| 2733 | Vstring=UvData.Field.ListVarName{ivar}; |
---|
| 2734 | ind_skip=[ind_skip ivar]; |
---|
| 2735 | end |
---|
[387] | 2736 | end |
---|
[434] | 2737 | DimCell=UvData.Field.VarDimName{ivar}; |
---|
| 2738 | DimName=''; |
---|
| 2739 | if ischar(DimCell) |
---|
| 2740 | DimName=DimCell; |
---|
| 2741 | elseif iscell(DimCell)&& numel(DimCell)==1 |
---|
| 2742 | DimName=DimCell{1}; |
---|
| 2743 | end |
---|
| 2744 | if strcmp(DimName,menu_histo{ivar}) |
---|
| 2745 | ind_skip=[ind_skip ivar]; |
---|
| 2746 | end |
---|
[387] | 2747 | end |
---|
[434] | 2748 | menu_histo(ind_skip)=[];% remove skipped items |
---|
| 2749 | if ~isempty(Ustring) |
---|
| 2750 | menu_histo=[{[Ustring ',' Vstring]};menu_histo];% add U, V at the beginning if they exist |
---|
[387] | 2751 | end |
---|
[434] | 2752 | |
---|
| 2753 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
---|
| 2754 | % display menus and plot histograms |
---|
| 2755 | test_v=0; |
---|
| 2756 | if ~isempty(menu_histo) |
---|
| 2757 | set(handles.histo1_menu,'Value',1) |
---|
| 2758 | set(handles.histo1_menu,'String',menu_histo) |
---|
| 2759 | histo1_menu_Callback(handles.histo1_menu, [], handles)% plot first histogram |
---|
[387] | 2760 | end |
---|
| 2761 | end |
---|
| 2762 | |
---|
[424] | 2763 | %------------------------------------------------------------------------ |
---|
| 2764 | function histo1_menu_Callback(hObject, eventdata, handles) |
---|
| 2765 | %-------------------------------------------- |
---|
| 2766 | %plot first histo |
---|
| 2767 | %huvmat=get(handles.histo1_menu,'parent'); |
---|
| 2768 | histo_menu=get(handles.histo1_menu,'String'); |
---|
| 2769 | histo_value=get(handles.histo1_menu,'Value'); |
---|
| 2770 | FieldName=histo_menu{histo_value}; |
---|
| 2771 | % update_histo(handles.histo_u,handles.uvmat,FieldName) |
---|
| 2772 | % |
---|
| 2773 | % %------------------------------------------------------------------------ |
---|
| 2774 | % function histo2_menu_Callback(hObject, eventdata, handles) |
---|
| 2775 | % %------------------------------------------------------------------------ |
---|
| 2776 | % %plot second histo |
---|
| 2777 | % %huvmat=get(handles.histo2_menu,'parent'); |
---|
| 2778 | % histo_menu=get(handles.histo2_menu,'String'); |
---|
| 2779 | % histo_value=get(handles.histo2_menu,'Value'); |
---|
| 2780 | % FieldName=histo_menu{histo_value}; |
---|
| 2781 | % update_histo(handles.histo_v,handles.uvmat,FieldName) |
---|
| 2782 | % |
---|
| 2783 | % %------------------------------------------------------------------------ |
---|
| 2784 | % %read the field .Fieldname stored in UvData and plot its histogram |
---|
| 2785 | % function update_histo(haxes,huvmat,FieldName) |
---|
| 2786 | %------------------------------------------------------------------------ |
---|
| 2787 | UvData=get(handles.uvmat,'UserData'); |
---|
| 2788 | Field=UvData.Field; |
---|
| 2789 | r=regexp(FieldName,'(?<var1>.*)(?<sep>,)(?<var2>.*)','names'); |
---|
| 2790 | FieldName_2=''; |
---|
| 2791 | if ~isempty(r) |
---|
| 2792 | FieldName=r.var1; |
---|
| 2793 | FieldName_2=r.var2; |
---|
| 2794 | end |
---|
| 2795 | if ~isfield(UvData.Field,FieldName) |
---|
| 2796 | msgbox_uvmat('ERROR',['no field ' FieldName ' for histogram']) |
---|
| 2797 | return |
---|
| 2798 | end |
---|
| 2799 | FieldHisto=Field.(FieldName); |
---|
| 2800 | if isfield(Field,'FF') && ~isempty(Field.FF) && isequal(size(Field.FF),size(FieldHisto)) |
---|
| 2801 | indsel=find(Field.FF==0);%find values marked as false |
---|
| 2802 | if ~isempty(indsel) |
---|
| 2803 | FieldHisto=FieldHisto(indsel); |
---|
| 2804 | if ~isempty(FieldName_2) |
---|
| 2805 | FieldHisto(:,:,2)=Field.(FieldName_2)(indsel); |
---|
| 2806 | end |
---|
[387] | 2807 | end |
---|
| 2808 | end |
---|
[424] | 2809 | if isempty(Field) |
---|
| 2810 | msgbox_uvmat('ERROR',['empty field ' FieldName]) |
---|
| 2811 | else |
---|
| 2812 | nxy=size(FieldHisto); |
---|
| 2813 | Amin=double(min(min(min(FieldHisto))));%min of field value |
---|
| 2814 | Amax=double(max(max(max(FieldHisto))));%max of field value |
---|
| 2815 | if isequal(Amin,Amax) |
---|
| 2816 | cla(handles.histo_u) |
---|
| 2817 | else |
---|
| 2818 | Histo.ListVarName={FieldName,'histo'}; |
---|
| 2819 | if isfield(Field,'NbDim') && isequal(Field.NbDim,3) |
---|
| 2820 | Histo.VarDimName={FieldName,FieldName}; %dimensions for the histogram |
---|
| 2821 | else |
---|
| 2822 | if numel(nxy)==2 |
---|
| 2823 | Histo.VarDimName={FieldName,FieldName}; %dimensions for the histogram |
---|
| 2824 | else |
---|
| 2825 | Histo.VarDimName={FieldName,{FieldName,'component'}}; %dimensions for the histogram |
---|
| 2826 | end |
---|
| 2827 | end |
---|
| 2828 | %unit |
---|
| 2829 | units=[]; %default |
---|
| 2830 | for ivar=1:numel(Field.ListVarName) |
---|
| 2831 | if strcmp(Field.ListVarName{ivar},FieldName) |
---|
| 2832 | if isfield(Field,'VarAttribute') && numel(Field.VarAttribute)>=ivar && isfield(Field.VarAttribute{ivar},'units') |
---|
| 2833 | units=Field.VarAttribute{ivar}.units; |
---|
| 2834 | break |
---|
| 2835 | end |
---|
| 2836 | end |
---|
| 2837 | end |
---|
| 2838 | if ~isempty(units) |
---|
| 2839 | Histo.VarAttribute{1}.units=units; |
---|
| 2840 | end |
---|
| 2841 | eval(['Histo.' FieldName '=linspace(Amin,Amax,50);'])%absissa values for histo |
---|
| 2842 | if isfield(Field,'NbDim') && isequal(Field.NbDim,3) |
---|
| 2843 | C=reshape(double(FieldHisto),1,[]);% reshape in a vector |
---|
| 2844 | Histo.histo(:,1)=hist(C, Histo.(FieldName)); %calculate histogram |
---|
| 2845 | else |
---|
| 2846 | for col=1:size(FieldHisto,3) |
---|
| 2847 | B=FieldHisto(:,:,col); |
---|
| 2848 | C=reshape(double(B),1,nxy(1)*nxy(2));% reshape in a vector |
---|
| 2849 | Histo.histo(:,col)=hist(C, Histo.(FieldName)); %calculate histogram |
---|
| 2850 | end |
---|
| 2851 | end |
---|
| 2852 | plot_field(Histo,handles.histo_u); |
---|
[426] | 2853 | hlegend=legend; |
---|
| 2854 | if isempty(FieldName_2) |
---|
| 2855 | set(hlegend,'String',FieldName) |
---|
| 2856 | else |
---|
| 2857 | set(hlegend,'String',{FieldName;FieldName_2}) |
---|
| 2858 | end |
---|
| 2859 | % hh=get(handles.histo_u,'children'); |
---|
| 2860 | % get(hh(1)) |
---|
| 2861 | % get(hh(2)) |
---|
[424] | 2862 | end |
---|
[387] | 2863 | end |
---|
| 2864 | |
---|
| 2865 | %------------------------------------------------------------------- |
---|
| 2866 | % --- translate coordinate to matrix index |
---|
| 2867 | %------------------------------------------------------------------- |
---|
| 2868 | function [indx,indy]=pos2ind(x0,rangx0,nxy) |
---|
| 2869 | indx=1+round((nxy(2)-1)*(x0-rangx0(1))/(rangx0(2)-rangx0(1)));% index x of pixel |
---|
| 2870 | indy=1+round((nxy(1)-1)*(y12-rangy0(1))/(rangy0(2)-rangy0(1)));% index y of pixel |
---|
| 2871 | |
---|
[428] | 2872 | |
---|
[387] | 2873 | %------------------------------------------------------------------- |
---|
[428] | 2874 | % --- Executes on button press in 'CheckZoom'. |
---|
| 2875 | %------------------------------------------------------------------- |
---|
| 2876 | function CheckZoom_Callback(hObject, eventdata, handles) |
---|
| 2877 | |
---|
| 2878 | if (get(handles.CheckZoom,'Value') == 1); |
---|
| 2879 | set(handles.CheckZoom,'BackgroundColor',[1 1 0]) |
---|
| 2880 | set(handles.CheckFixLimits,'Value',1)% propose by default fixed limits for the plotting axes |
---|
| 2881 | set(handles.CheckFixLimits,'BackgroundColor',[1 1 0]) |
---|
| 2882 | else |
---|
| 2883 | set(handles.CheckZoom,'BackgroundColor',[0.7 0.7 0.7]) |
---|
| 2884 | end |
---|
| 2885 | |
---|
| 2886 | %------------------------------------------------------------------- |
---|
[387] | 2887 | % --- Executes on button press in 'CheckFixLimits'. |
---|
| 2888 | %------------------------------------------------------------------- |
---|
| 2889 | function CheckFixLimits_Callback(hObject, eventdata, handles) |
---|
| 2890 | test=get(handles.CheckFixLimits,'Value'); |
---|
| 2891 | if test |
---|
| 2892 | set(handles.CheckFixLimits,'BackgroundColor',[1 1 0]) |
---|
| 2893 | else |
---|
| 2894 | set(handles.CheckFixLimits,'BackgroundColor',[0.7 0.7 0.7]) |
---|
| 2895 | update_plot(handles); |
---|
| 2896 | end |
---|
| 2897 | |
---|
| 2898 | %------------------------------------------------------------------- |
---|
[428] | 2899 | % --- Executes on button press in CheckFixAspectRatio. |
---|
| 2900 | function CheckFixAspectRatio_Callback(hObject, eventdata, handles) |
---|
| 2901 | %------------------------------------------------------------------- |
---|
| 2902 | if get(handles.CheckFixAspectRatio,'Value') |
---|
| 2903 | set(handles.CheckFixAspectRatio,'BackgroundColor',[1 1 0]) |
---|
[387] | 2904 | update_plot(handles); |
---|
| 2905 | else |
---|
[428] | 2906 | set(handles.CheckFixAspectRatio,'BackgroundColor',[0.7 0.7 0.7]) |
---|
[387] | 2907 | update_plot(handles); |
---|
| 2908 | end |
---|
| 2909 | |
---|
| 2910 | %------------------------------------------------------------------- |
---|
[428] | 2911 | function num_AspectRatio_Callback(hObject, eventdata, handles) |
---|
[387] | 2912 | %------------------------------------------------------------------- |
---|
[428] | 2913 | set(handles.CheckFixAspectRatio,'Value',1)% select the fixed aspect ratio button |
---|
| 2914 | set(handles.CheckFixAspectRatio,'BackgroundColor',[1 1 0])% mark in yellow |
---|
| 2915 | update_plot(handles); |
---|
[387] | 2916 | %------------------------------------------------------------------- |
---|
| 2917 | |
---|
[428] | 2918 | %------------------------------------------------------------------- |
---|
[387] | 2919 | |
---|
[428] | 2920 | |
---|
| 2921 | |
---|
[387] | 2922 | %------------------------------------------------------------------- |
---|
| 2923 | %----Executes on button press in 'record': records the current flags of manual correction. |
---|
| 2924 | %------------------------------------------------------------------- |
---|
| 2925 | function record_Callback(hObject, eventdata, handles) |
---|
| 2926 | % [filebase,num_i1,num_j1,num_i2,num_j2,Ext,NomType,SubDir]=read_input_file(handles); |
---|
| 2927 | [RootPath,SubDir,RootFile,FileIndices,FileExt]=read_file_boxes(handles); |
---|
| 2928 | filename=[fullfile(RootPath,SubDir,RootFile) FileIndices FileExt]; |
---|
| 2929 | %filename=read_file_boxes(handles); |
---|
| 2930 | [erread,message]=fileattrib(filename); |
---|
| 2931 | if ~isempty(message) && ~isequal(message.UserWrite,1) |
---|
| 2932 | msgbox_uvmat('ERROR',['no writting access to ' filename]) |
---|
| 2933 | return |
---|
| 2934 | end |
---|
| 2935 | test_civ2=isequal(get(handles.civ2,'BackgroundColor'),[1 1 0]); |
---|
| 2936 | test_civ1=isequal(get(handles.VelType,'BackgroundColor'),[1 1 0]); |
---|
| 2937 | if ~test_civ2 && ~test_civ1 |
---|
| 2938 | msgbox_uvmat('ERROR','manual correction only possible for CIV1 or CIV2 velocity fields') |
---|
| 2939 | end |
---|
| 2940 | if test_civ2 |
---|
| 2941 | nbname='nb_vectors2'; |
---|
| 2942 | flagname='vec2_FixFlag'; |
---|
| 2943 | attrname='fix2'; |
---|
| 2944 | end |
---|
| 2945 | if test_civ1 |
---|
| 2946 | nbname='nb_vectors'; |
---|
| 2947 | flagname='vec_FixFlag'; |
---|
| 2948 | attrname='fix'; |
---|
| 2949 | end |
---|
| 2950 | %write fix flags in the netcdf file |
---|
| 2951 | UvData=get(handles.uvmat,'UserData'); |
---|
| 2952 | hhh=which('netcdf.open');% look for built-in matlab netcdf library |
---|
| 2953 | if ~isequal(hhh,'')% case of new builtin Matlab netcdf library |
---|
| 2954 | nc=netcdf.open(filename,'NC_WRITE'); |
---|
| 2955 | netcdf.reDef(nc); |
---|
| 2956 | netcdf.putAtt(nc,netcdf.getConstant('NC_GLOBAL'),attrname,1); |
---|
| 2957 | dimid = netcdf.inqDimID(nc,nbname); |
---|
| 2958 | try |
---|
| 2959 | varid = netcdf.inqVarID(nc,flagname);% look for already existing fixflag variable |
---|
| 2960 | catch |
---|
| 2961 | varid=netcdf.defVar(nc,flagname,'double',dimid);%create fixflag variable if it does not exist |
---|
| 2962 | end |
---|
| 2963 | netcdf.endDef(nc); |
---|
| 2964 | netcdf.putVar(nc,varid,UvData.axes3.FF); |
---|
| 2965 | netcdf.close(nc); |
---|
| 2966 | else %old netcdf library |
---|
| 2967 | netcdf_toolbox(filename,AxeData,attrname,nbname,flagname) |
---|
| 2968 | end |
---|
| 2969 | |
---|
| 2970 | %------------------------------------------------------------------- |
---|
| 2971 | %----Correct the netcdf file, using toolbox (old versions of Matlab). |
---|
| 2972 | %------------------------------------------------------------------- |
---|
| 2973 | function netcdf_toolbox(filename,AxeData,attrname,nbname,flagname) |
---|
| 2974 | nc=netcdf(filename,'write'); %open netcdf file |
---|
| 2975 | result=redef(nc); |
---|
| 2976 | eval(['nc.' attrname '=1;']); |
---|
| 2977 | theDim=nc(nbname) ;% get the number of velocity vectors |
---|
| 2978 | nb_vectors=size(theDim); |
---|
| 2979 | var_FixFlag=ncvar(flagname,nc);% var_FixFlag will be written as the netcdf variable vec_FixFlag |
---|
| 2980 | var_FixFlag(1:nb_vectors)=AxeData.FF;% |
---|
| 2981 | fin=close(nc); |
---|
| 2982 | |
---|
[428] | 2983 | %------------------------------------------------------------------- |
---|
[387] | 2984 | % --- Executes on button press in SubField |
---|
| 2985 | function SubField_Callback(hObject, eventdata, handles) |
---|
[428] | 2986 | %------------------------------------------------------------------- |
---|
[387] | 2987 | UvData=get(handles.uvmat,'UserData'); |
---|
| 2988 | if get(handles.SubField,'Value')==0% if the subfield button is desactivated |
---|
| 2989 | set(handles.RootPath_1,'String','') |
---|
| 2990 | set(handles.RootFile_1,'String','') |
---|
| 2991 | set(handles.SubDir_1,'String',''); |
---|
| 2992 | set(handles.FileIndex_1,'String',''); |
---|
| 2993 | set(handles.FileExt_1,'String',''); |
---|
| 2994 | set(handles.RootPath_1,'Visible','off') |
---|
| 2995 | set(handles.RootFile_1,'Visible','off') |
---|
| 2996 | set(handles.SubDir_1,'Visible','off'); |
---|
| 2997 | set(handles.NomType_1,'Visible','off'); |
---|
| 2998 | set(handles.abs_time_1,'Visible','off') |
---|
| 2999 | set(handles.FileIndex_1,'Visible','off'); |
---|
| 3000 | set(handles.FileExt_1,'Visible','off'); |
---|
| 3001 | set(handles.Fields_1,'Value',1);%set to blank state |
---|
| 3002 | set(handles.VelType_1,'Value',1);%set to blank state |
---|
[428] | 3003 | set(handles.num_Opacity,'String','')% desactivate opacity setting |
---|
[387] | 3004 | if ~strcmp(get(handles.VelType,'Visible'),'on') |
---|
| 3005 | set(handles.VelType_1,'Visible','off') |
---|
| 3006 | end |
---|
| 3007 | if isfield(UvData,'XmlData_1') |
---|
| 3008 | UvData=rmfield(UvData,'XmlData_1'); |
---|
| 3009 | end |
---|
| 3010 | set(handles.uvmat,'UserData',UvData); |
---|
| 3011 | run0_Callback(hObject, eventdata, handles); %run |
---|
| 3012 | else |
---|
| 3013 | MenuBrowse_1_Callback(hObject, eventdata, handles) |
---|
| 3014 | end |
---|
| 3015 | |
---|
| 3016 | %------------------------------------------------------------------------ |
---|
| 3017 | % --- read the data displayed for the input rootfile windows (new): TODO use read_GUI |
---|
| 3018 | |
---|
| 3019 | function [RootPath,SubDir,RootFile,FileIndices,FileExt]=read_file_boxes(handles) |
---|
| 3020 | %------------------------------------------------------------------------ |
---|
| 3021 | InputFile=read_GUI(handles.InputFile); |
---|
| 3022 | RootPath=InputFile.RootPath; |
---|
| 3023 | SubDir=regexprep(InputFile.SubDir,'/|\',''); |
---|
| 3024 | RootFile=regexprep(InputFile.RootFile,'/|\',''); |
---|
| 3025 | FileIndices=InputFile.FileIndex; |
---|
| 3026 | FileExt=InputFile.FileExt; |
---|
| 3027 | |
---|
| 3028 | |
---|
| 3029 | %------------------------------------------------------------------------ |
---|
| 3030 | % ---- read the data displayed for the second input rootfile windows |
---|
| 3031 | function [RootPath_1,SubDir_1,RootFile_1,FileIndex_1,FileExt_1,NomType_1]=read_file_boxes_1(handles) |
---|
| 3032 | %------------------------------------------------------------------------ |
---|
| 3033 | RootPath_1=get(handles.RootPath_1,'String'); % read the data from the file1_input window |
---|
| 3034 | if isequal(get(handles.RootPath_1,'Visible'),'off') || isequal(RootPath_1,'"') |
---|
| 3035 | RootPath_1=get(handles.RootPath,'String'); |
---|
| 3036 | end; |
---|
| 3037 | SubDir_1=get(handles.SubDir_1,'String'); |
---|
| 3038 | if isequal(get(handles.SubDir_1,'Visible'),'off')|| isequal(SubDir_1,'"') |
---|
| 3039 | SubDir_1=get(handles.SubDir,'String'); |
---|
| 3040 | end |
---|
| 3041 | SubDir_1=regexprep(SubDir_1,'\<[\\/]|[\\/]\>','');%suppress possible / or \ separator at the beginning or the end of the string |
---|
| 3042 | RootFile_1=get(handles.RootFile_1,'String'); |
---|
| 3043 | if isequal(get(handles.RootFile_1,'Visible'),'off') || isequal(RootFile_1,'"') |
---|
| 3044 | RootFile_1=get(handles.RootFile,'String'); |
---|
| 3045 | end |
---|
| 3046 | RootFile_1=regexprep(RootFile_1,'\<[\\/]|[\\/]\>','');%suppress possible / or \ separator at the beginning or the end of the string |
---|
| 3047 | FileIndex_1=get(handles.FileIndex_1,'String'); |
---|
| 3048 | if isequal(get(handles.FileIndex_1,'Visible'),'off')|| isequal(FileIndex_1,'"') |
---|
| 3049 | FileIndex_1=get(handles.FileIndex,'String'); |
---|
| 3050 | end |
---|
| 3051 | FileExt_1=get(handles.FileExt_1,'String'); |
---|
| 3052 | if isequal(get(handles.FileExt_1,'Visible'),'off') || isequal(FileExt_1,'"') |
---|
| 3053 | FileExt_1=get(handles.FileExt,'String');%read FileExt by default |
---|
| 3054 | end |
---|
| 3055 | NomType_1=get(handles.NomType_1,'String'); |
---|
| 3056 | if isequal(get(handles.NomType_1,'Visible'),'off') || isequal(NomType_1,'"') |
---|
| 3057 | NomType_1=get(handles.NomType,'String');%read FileExt by default |
---|
| 3058 | end |
---|
| 3059 | %------------------------------------------------------------------------ |
---|
| 3060 | % --- Executes on menu selection Fields |
---|
| 3061 | function Fields_Callback(hObject, eventdata, handles) |
---|
| 3062 | %------------------------------------------------------------------------ |
---|
| 3063 | list_fields=get(handles.Fields,'String');% list menu fields |
---|
| 3064 | index_fields=get(handles.Fields,'Value');% selected string index |
---|
| 3065 | field= list_fields{index_fields(1)}; % selected string |
---|
| 3066 | if isequal(field,'get_field...') |
---|
| 3067 | set(handles.FixVelType,'visible','off') |
---|
| 3068 | set(handles.VelType,'visible','off') |
---|
| 3069 | set(handles.VelType_1,'visible','off') |
---|
| 3070 | [RootPath,SubDir,RootFile,FileIndices,FileExt]=read_file_boxes(handles); |
---|
| 3071 | filename=[fullfile(RootPath,SubDir,RootFile) FileIndices FileExt]; |
---|
| 3072 | %filename=read_file_boxes(handles); |
---|
| 3073 | hget_field=findobj(allchild(0),'name','get_field'); |
---|
| 3074 | if ~isempty(hget_field) |
---|
| 3075 | delete(hget_field) |
---|
| 3076 | end |
---|
| 3077 | hget_field=get_field(filename); |
---|
| 3078 | set(hget_field,'Name','get_field') |
---|
| 3079 | hhget_field=guidata(hget_field); |
---|
| 3080 | set(hhget_field.list_fig,'Value',1) |
---|
| 3081 | set(hhget_field.list_fig,'String',{'uvmat'}) |
---|
| 3082 | set(handles.transform_fct,'Value',1)% no transform by default |
---|
| 3083 | set(handles.path_transform,'String','') |
---|
| 3084 | return %no action |
---|
| 3085 | end |
---|
| 3086 | list_fields=get(handles.Fields_1,'String');% list menu fields |
---|
| 3087 | index_fields=get(handles.Fields_1,'Value');% selected string index |
---|
| 3088 | field_1= list_fields{index_fields(1)}; % selected string |
---|
| 3089 | UvData=get(handles.uvmat,'UserData'); |
---|
| 3090 | |
---|
| 3091 | %read the rootfile input display |
---|
| 3092 | [RootPath,SubDir,RootFile,FileIndices,FileExt]=read_file_boxes(handles); |
---|
| 3093 | FileName=[fullfile(RootPath,SubDir,RootFile) FileIndices FileExt]; |
---|
| 3094 | [tild,tild,tild,i1,i2,j1,j2,tild,NomType]=fileparts_uvmat(['xxx' get(handles.FileIndex,'String') FileExt]); |
---|
| 3095 | % NomTypeNew=NomType;%default |
---|
| 3096 | if isequal(field,'image') |
---|
| 3097 | % if isequal(NomType,'_1-2_1')||isequal(NomType,'_1_1-2') |
---|
| 3098 | % NomTypeNew='_1_1'; |
---|
| 3099 | % elseif isequal(NomType,'#_ab') |
---|
| 3100 | % NomTypeNew='#a'; |
---|
| 3101 | % elseif isequal(NomType,'_1-2') |
---|
| 3102 | % NomTypeNew='_1'; |
---|
| 3103 | % end |
---|
| 3104 | imagename=fullfile_uvmat(RootPath,SubDir,RootFile,'.png',NomType,i1,[],j1,[]); |
---|
| 3105 | if ~exist(imagename,'file') |
---|
| 3106 | [FileName,PathName] = uigetfile( ... |
---|
| 3107 | {'*.png;*.jpg;*.tif;*.avi;*.AVI;*.vol', ' (*.png, .tif, *.avi,*.vol)'; |
---|
| 3108 | '*.jpg',' jpeg image files'; ... |
---|
| 3109 | '*.png','.png image files'; ... |
---|
| 3110 | '*.tif','.tif image files'; ... |
---|
| 3111 | '*.avi;*.AVI','.avi movie files'; ... |
---|
| 3112 | '*.vol','.volume images (png)'; ... |
---|
| 3113 | '*.*', 'All Files (*.*)'}, ... |
---|
| 3114 | 'Pick an image',imagename); |
---|
| 3115 | imagename=[PathName FileName]; |
---|
| 3116 | end |
---|
| 3117 | % display the selected field and related information |
---|
[406] | 3118 | display_file_name(handles,imagename)%display the image |
---|
[387] | 3119 | return |
---|
| 3120 | else |
---|
| 3121 | ext=get(handles.FileExt,'String'); |
---|
| 3122 | if ~isequal(ext,'.nc') %find the new NomType if the previous display was not already a netcdf file |
---|
| 3123 | [FileName,PathName] = uigetfile( ... |
---|
| 3124 | {'*.nc', ' (*.nc)'; |
---|
| 3125 | '*.nc',' netcdf files'; ... |
---|
| 3126 | '*.*', 'All Files (*.*)'}, ... |
---|
| 3127 | 'Pick a netcdf file',FileBase); |
---|
| 3128 | filename=[PathName FileName]; |
---|
| 3129 | % display the selected field and related information |
---|
[406] | 3130 | display_file_name( handles,filename) |
---|
[387] | 3131 | return |
---|
| 3132 | end |
---|
| 3133 | end |
---|
| 3134 | indices=fullfile_uvmat('','','','',NomType,i1,i2,j1,j2); |
---|
| 3135 | set(handles.FileIndex,'String',indices) |
---|
| 3136 | % set(handles.NomType,'String',NomType) |
---|
| 3137 | |
---|
| 3138 | %common to Fields_1_Callback |
---|
| 3139 | if isequal(field,'image')||isequal(field_1,'image') |
---|
| 3140 | set(handles.TitleNpx,'Visible','on')% visible npx,pxcm... buttons |
---|
| 3141 | set(handles.TitleNpy,'Visible','on') |
---|
| 3142 | set(handles.num_Npx,'Visible','on') |
---|
| 3143 | set(handles.num_Npy,'Visible','on') |
---|
| 3144 | else |
---|
| 3145 | set(handles.TitleNpx,'Visible','off')% visible npx,pxcm... buttons |
---|
| 3146 | set(handles.TitleNpy,'Visible','off') |
---|
| 3147 | set(handles.num_Npx,'Visible','off') |
---|
| 3148 | set(handles.num_Npy,'Visible','off') |
---|
| 3149 | end |
---|
| 3150 | if ~(isfield(UvData,'NewSeries')&&isequal(UvData.NewSeries,1)) |
---|
| 3151 | run0_Callback(hObject, eventdata, handles) |
---|
| 3152 | end |
---|
| 3153 | |
---|
| 3154 | %--------------------------------------------------- |
---|
| 3155 | % --- Executes on menu selection Fields |
---|
| 3156 | function Fields_1_Callback(hObject, eventdata, handles) |
---|
| 3157 | %------------------------------------------------- |
---|
| 3158 | %% read input data |
---|
| 3159 | check_new=~get(handles.SubField,'Value'); %check_new=1 if a second field was not previously entered |
---|
| 3160 | UvData=get(handles.uvmat,'UserData'); |
---|
| 3161 | if check_new && isfield(UvData,'XmlData') |
---|
| 3162 | UvData.XmlData{2}=UvData.XmlData{1}; |
---|
| 3163 | end |
---|
[389] | 3164 | if isfield(UvData,'Field_1') |
---|
| 3165 | UvData=rmfield(UvData,'Field_1');% remove the stored second field (a new one needs to be read) |
---|
| 3166 | end |
---|
[402] | 3167 | UvData.filename_1='';% desactivate the use of a constant second file |
---|
[387] | 3168 | list_fields=get(handles.Fields,'String');% list menu fields |
---|
[405] | 3169 | field= list_fields{get(handles.Fields,'Value')}; % selected string |
---|
[387] | 3170 | list_fields=get(handles.Fields_1,'String');% list menu fields |
---|
[405] | 3171 | field_1= list_fields{get(handles.Fields_1,'Value')}; % selected string for the second field |
---|
| 3172 | if isempty(field_1)%||(numel(UvData.FileType)>=2 && strcmp(UvData.FileType{2},'image')) |
---|
[387] | 3173 | set(handles.SubField,'Value',0) |
---|
| 3174 | SubField_Callback(hObject, eventdata, handles) |
---|
[428] | 3175 | return |
---|
[405] | 3176 | else |
---|
| 3177 | set(handles.SubField,'Value',1)%state that a second field is now entered |
---|
[387] | 3178 | end |
---|
| 3179 | |
---|
| 3180 | %% read the rootfile input display |
---|
[405] | 3181 | [RootPath_1,SubDir_1,RootFile_1,FileIndex_1,FileExt_1]=read_file_boxes_1(handles); |
---|
[387] | 3182 | filename_1=[fullfile(RootPath_1,SubDir_1,RootFile_1) FileIndex_1 FileExt_1]; |
---|
| 3183 | [tild,tild,tild,i1,i2,j1,j2]=fileparts_uvmat(get(handles.FileIndex,'String')); |
---|
[405] | 3184 | % set(handles.FileIndex_1,'Visible','on') |
---|
| 3185 | % set(handles.FileExt_1,'Visible','on') |
---|
[387] | 3186 | switch field_1 |
---|
| 3187 | case 'get_field...' |
---|
| 3188 | set_veltype_display(0) % no veltype display |
---|
| 3189 | hget_field=findobj(allchild(0),'name','get_field_1'); |
---|
| 3190 | if ~isempty(hget_field) |
---|
| 3191 | delete(hget_field) |
---|
| 3192 | end |
---|
| 3193 | hget_field=get_field(filename_1); |
---|
| 3194 | set(hget_field,'name','get_field_1') |
---|
| 3195 | hhget_field=guidata(hget_field); |
---|
| 3196 | set(hhget_field.list_fig,'Value',1) |
---|
| 3197 | set(hhget_field.list_fig,'String',{'uvmat'}) |
---|
| 3198 | set(handles.transform_fct,'Value',1)% no transform by default |
---|
| 3199 | set(handles.path_transform,'String','') |
---|
[428] | 3200 | if check_new |
---|
| 3201 | UvData.FileType{2}=UvData.FileType{1}; |
---|
| 3202 | set(handles.FileIndex_1,'String',get(handles.FileIndex,'String')) |
---|
| 3203 | % set(handles.FileExt_1,'String',get(handles.FileExt,'String')) |
---|
| 3204 | set(handles.uvmat,'UserData',UvData) |
---|
| 3205 | end |
---|
[387] | 3206 | case 'image' |
---|
[405] | 3207 | % guess the image name corresponding to the current netcdf name (no unique correspondance) |
---|
| 3208 | imagename=fullfile_uvmat(RootPath_1,'',RootFile_1,'.png',get(handles.NomType,'String'),i1,[],j1); |
---|
| 3209 | if ~exist(imagename,'file') % browse for images if it is not found |
---|
[387] | 3210 | [FileName,PathName] = uigetfile( ... |
---|
| 3211 | {'*.png;*.jpg;*.tif;*.avi;*.AVI;*.vol', ' (*.png, .tif, *.avi,*.vol)'; |
---|
| 3212 | '*.jpg',' jpeg image files'; ... |
---|
| 3213 | '*.png','.png image files'; ... |
---|
| 3214 | '*.tif','.tif image files'; ... |
---|
| 3215 | '*.avi;*.AVI','.avi movie files'; ... |
---|
| 3216 | '*.vol','.volume images (png)'; ... |
---|
| 3217 | '*.*', 'All Files (*.*)'}, ... |
---|
| 3218 | 'Pick an image',imagename); |
---|
| 3219 | imagename=[PathName FileName]; |
---|
| 3220 | end |
---|
[405] | 3221 | if ~ischar(imagename)% quit if the browser has been closed |
---|
| 3222 | set(handles.SubField,'Value',0) |
---|
| 3223 | else %valid browser input: display the selected image |
---|
| 3224 | set(handles.TitleNpx,'Visible','on')% visible npx,pxcm... buttons |
---|
| 3225 | set(handles.TitleNpy,'Visible','on') |
---|
| 3226 | set(handles.num_Npx,'Visible','on') |
---|
| 3227 | set(handles.num_Npy,'Visible','on') |
---|
[406] | 3228 | display_file_name(handles,imagename,2)%display the imag |
---|
[405] | 3229 | end |
---|
[387] | 3230 | otherwise |
---|
| 3231 | if check_new |
---|
| 3232 | UvData.FileType{2}=UvData.FileType{1}; |
---|
| 3233 | set(handles.FileIndex_1,'String',get(handles.FileIndex,'String')) |
---|
| 3234 | set(handles.FileExt_1,'String',get(handles.FileExt,'String')) |
---|
| 3235 | end |
---|
| 3236 | if ~isequal(field,'image') |
---|
| 3237 | set(handles.TitleNpx,'Visible','off')% visible npx,pxcm... buttons |
---|
| 3238 | set(handles.TitleNpy,'Visible','off') |
---|
| 3239 | set(handles.num_Npx,'Visible','off') |
---|
| 3240 | set(handles.num_Npy,'Visible','off') |
---|
| 3241 | end |
---|
| 3242 | set(handles.uvmat,'UserData',UvData) |
---|
| 3243 | if ~(isfield(UvData,'NewSeries')&&isequal(UvData.NewSeries,1)) |
---|
| 3244 | run0_Callback(hObject, eventdata, handles) |
---|
| 3245 | end |
---|
| 3246 | end |
---|
| 3247 | |
---|
| 3248 | %------------------------------------------------------------------------ |
---|
| 3249 | % --- set the visibility of relevant velocity type menus: |
---|
| 3250 | function menu=set_veltype_display(Civ,FileType) |
---|
| 3251 | %------------------------------------------------------------------------ |
---|
| 3252 | if ~exist('FileType','var') |
---|
| 3253 | FileType='civx'; |
---|
| 3254 | end |
---|
| 3255 | switch FileType |
---|
| 3256 | case 'civx' |
---|
[389] | 3257 | menu={'civ1';'interp1';'filter1';'civ2';'interp2';'filter2'}; |
---|
| 3258 | if isequal(Civ,0) |
---|
| 3259 | imax=0; |
---|
| 3260 | elseif isequal(Civ,1) || isequal(Civ,2) |
---|
| 3261 | imax=1; |
---|
| 3262 | elseif isequal(Civ,3) |
---|
| 3263 | imax=3; |
---|
| 3264 | elseif isequal(Civ,4) || isequal(Civ,5) |
---|
| 3265 | imax=4; |
---|
| 3266 | elseif isequal(Civ,6) %patch2 |
---|
| 3267 | imax=6; |
---|
| 3268 | end |
---|
[387] | 3269 | case 'civdata' |
---|
[389] | 3270 | menu={'civ1';'filter1';'civ2';'filter2'}; |
---|
| 3271 | if isequal(Civ,0) |
---|
| 3272 | imax=0; |
---|
| 3273 | elseif isequal(Civ,1) || isequal(Civ,2) |
---|
| 3274 | imax=1; |
---|
| 3275 | elseif isequal(Civ,3) |
---|
| 3276 | imax=2; |
---|
| 3277 | elseif isequal(Civ,4) || isequal(Civ,5) |
---|
| 3278 | imax=3; |
---|
| 3279 | elseif isequal(Civ,6) %patch2 |
---|
| 3280 | imax=4; |
---|
| 3281 | end |
---|
[387] | 3282 | end |
---|
| 3283 | menu=menu(1:imax); |
---|
| 3284 | |
---|
| 3285 | %------------------------------------------------------------------------ |
---|
[402] | 3286 | % --- Executes on button press in FixVelType. |
---|
| 3287 | function FixVelType_Callback(hObject, eventdata, handles) |
---|
| 3288 | %------------------------------------------------------------------------ |
---|
[405] | 3289 | % refresh the current plot if the fixed veltype is unselected |
---|
| 3290 | if ~get(handles.FixVelType,'Value') |
---|
[402] | 3291 | run0_Callback(hObject, eventdata, handles) |
---|
| 3292 | end |
---|
| 3293 | |
---|
| 3294 | %------------------------------------------------------------------------ |
---|
[387] | 3295 | % --- Executes on button press in VelType. |
---|
| 3296 | function VelType_Callback(hObject, eventdata, handles) |
---|
| 3297 | %------------------------------------------------------------------------ |
---|
| 3298 | set(handles.FixVelType,'Value',1) |
---|
| 3299 | run0_Callback(hObject, eventdata, handles) |
---|
| 3300 | |
---|
| 3301 | %------------------------------------------------------------------------ |
---|
[402] | 3302 | % --- Executes on button press in VelType_1. |
---|
[387] | 3303 | function VelType_1_Callback(hObject, eventdata, handles) |
---|
| 3304 | %------------------------------------------------------------------------ |
---|
| 3305 | set(handles.FixVelType,'Value',1)% the velocity type is now imposed by the GUI (not automatic) |
---|
[389] | 3306 | UvData=get(handles.uvmat,'UserData'); |
---|
[405] | 3307 | %refresh field with a second filename=first file name |
---|
[387] | 3308 | set(handles.run0,'BackgroundColor',[1 1 0])%paint the command button in yellow |
---|
| 3309 | drawnow |
---|
| 3310 | InputFile=read_GUI(handles.InputFile); |
---|
| 3311 | [RootPath,SubDir,RootFile,FileIndices,FileExt]=read_file_boxes(handles); |
---|
| 3312 | filename=[fullfile(RootPath,SubDir,RootFile) FileIndices FileExt]; |
---|
[405] | 3313 | |
---|
[389] | 3314 | if isempty(InputFile.VelType_1) |
---|
[387] | 3315 | filename_1='';% we plot the current field without the second field |
---|
| 3316 | set(handles.SubField,'Value',0) |
---|
| 3317 | SubField_Callback(hObject, eventdata, handles) |
---|
| 3318 | elseif get(handles.SubField,'Value')% if subfield is already 'on' |
---|
| 3319 | [RootPath_1,SubDir_1,RootFile_1,FileIndices_1,FileExt_1]=read_file_boxes_1(handles); |
---|
| 3320 | filename_1=[fullfile(RootPath_1,SubDir_1,RootFile_1) FileIndices_1 FileExt_1]; |
---|
| 3321 | else |
---|
[405] | 3322 | filename_1=filename;% we compare two fields in the same file by default |
---|
[389] | 3323 | UvData.FileType{2}=UvData.FileType{1}; |
---|
[387] | 3324 | set(handles.SubField,'Value',1) |
---|
| 3325 | end |
---|
[389] | 3326 | if isfield(UvData,'Field_1') |
---|
| 3327 | UvData=rmfield(UvData,'Field_1');% removes the stored second field if it exists |
---|
| 3328 | end |
---|
[402] | 3329 | UvData.filename_1='';% desactivate the use of a constant second file |
---|
[389] | 3330 | set(handles.uvmat,'UserData',UvData) |
---|
[387] | 3331 | num_i1=stra2num(get(handles.i1,'String')); |
---|
| 3332 | num_i2=stra2num(get(handles.i2,'String')); |
---|
| 3333 | num_j1=stra2num(get(handles.j1,'String')); |
---|
| 3334 | num_j2=stra2num(get(handles.j2,'String')); |
---|
| 3335 | |
---|
| 3336 | errormsg=refresh_field(handles,filename,filename_1,num_i1,num_i2,num_j1,num_j2); |
---|
| 3337 | |
---|
| 3338 | if ~isempty(errormsg) |
---|
| 3339 | msgbox_uvmat('ERROR',errormsg); |
---|
| 3340 | else |
---|
| 3341 | set(handles.i1,'BackgroundColor',[1 1 1]) |
---|
| 3342 | set(handles.i2,'BackgroundColor',[1 1 1]) |
---|
| 3343 | set(handles.j1,'BackgroundColor',[1 1 1]) |
---|
| 3344 | set(handles.j2,'BackgroundColor',[1 1 1]) |
---|
| 3345 | set(handles.FileIndex,'BackgroundColor',[1 1 1]) |
---|
| 3346 | set(handles.FileIndex_1,'BackgroundColor',[1 1 1]) |
---|
| 3347 | end |
---|
| 3348 | set(handles.run0,'BackgroundColor',[1 0 0]) |
---|
| 3349 | |
---|
| 3350 | %----------------------------------------------- |
---|
| 3351 | % --- reset civ buttons |
---|
| 3352 | function reset_vel_type(handles_civ0,handle1) |
---|
| 3353 | for ibutton=1:length(handles_civ0) |
---|
| 3354 | set(handles_civ0(ibutton),'BackgroundColor',[0.831 0.816 0.784]) |
---|
| 3355 | set(handles_civ0(ibutton),'Value',0) |
---|
| 3356 | end |
---|
| 3357 | if exist('handle1','var')%handles of selected button |
---|
| 3358 | set(handle1,'BackgroundColor',[1 1 0]) |
---|
| 3359 | end |
---|
| 3360 | |
---|
| 3361 | %------------------------------------------------------- |
---|
| 3362 | % --- Executes on button press in MENUVOLUME. |
---|
| 3363 | %------------------------------------------------------- |
---|
| 3364 | function VOLUME_Callback(hObject, eventdata, handles) |
---|
| 3365 | %errordlg('command VOL not implemented yet') |
---|
| 3366 | if ishandle(handles.UVMAT_title) |
---|
| 3367 | delete(handles.UVMAT_title) |
---|
| 3368 | end |
---|
| 3369 | UvData=get(handles.uvmat,'UserData');%read UvData properties stored on the uvmat interface |
---|
| 3370 | if isequal(get(handles.VOLUME,'Value'),1) |
---|
| 3371 | set(handles.CheckZoom,'Value',0) |
---|
| 3372 | set(handles.CheckZoom,'BackgroundColor',[0.7 0.7 0.7]) |
---|
| 3373 | set(handles.edit_vect,'Value',0) |
---|
| 3374 | edit_vect_Callback(hObject, eventdata, handles) |
---|
| 3375 | set(handles.edit_object,'Value',0) |
---|
| 3376 | set(handles.edit_object,'BackgroundColor',[0.7 0.7 0.7]) |
---|
| 3377 | % set(handles.cal,'Value',0) |
---|
| 3378 | % set(handles.cal,'BackgroundColor',[0 1 0]) |
---|
| 3379 | set(handles.edit_vect,'Value',0) |
---|
| 3380 | edit_vect_Callback(hObject, eventdata, handles) |
---|
| 3381 | %initiate set_object GUI |
---|
| 3382 | data.Name='VOLUME'; |
---|
| 3383 | if isfield(UvData,'CoordType') |
---|
| 3384 | data.CoordType=UvData.CoordType; |
---|
| 3385 | end |
---|
[404] | 3386 | if isfield(UvData.Field,'Mesh')&~isempty(UvData.Field.Mesh) |
---|
| 3387 | data.RangeX=[UvData.Field.XMin UvData.Field.XMax]; |
---|
| 3388 | data.RangeY=[UvData.Field.YMin UvData.Field.YMax]; |
---|
| 3389 | data.DX=UvData.Field.Mesh; |
---|
| 3390 | data.DY=UvData.Field.Mesh; |
---|
[387] | 3391 | elseif isfield(UvData.Field,'AX')&isfield(UvData.Field,'AY')& isfield(UvData.Field,'A')%only image |
---|
| 3392 | np=size(UvData.Field.A); |
---|
| 3393 | meshx=(UvData.Field.AX(end)-UvData.Field.AX(1))/np(2); |
---|
| 3394 | meshy=abs(UvData.Field.AY(end)-UvData.Field.AY(1))/np(1); |
---|
| 3395 | data.RangeY=max(meshx,meshy); |
---|
| 3396 | data.RangeX=max(meshx,meshy); |
---|
| 3397 | data.DX=max(meshx,meshy); |
---|
| 3398 | end |
---|
| 3399 | data.ParentButton=handles.VOLUME; |
---|
| 3400 | PlotHandles=get_plot_handles(handles);%get the handles of the interface elements setting the plotting parameters |
---|
| 3401 | [hset_object,UvData.sethandles]=set_object(data,PlotHandles);% call the set_object interface with action on haxes, |
---|
| 3402 | % associate the set_object interface handle to the plotting axes |
---|
| 3403 | if isfield(UvData.OpenParam,'SetObjectOrigin') |
---|
| 3404 | pos_uvmat=get(handles.uvmat,'Position'); |
---|
| 3405 | pos_set_object(1:2)=UvData.OpenParam.SetObjectOrigin + pos_uvmat(1:2); |
---|
| 3406 | pos_set_object(3:4)=UvData.OpenParam.SetObjectSize .* pos_uvmat(3:4); |
---|
| 3407 | set(hset_object,'Position',pos_set_object) |
---|
| 3408 | end |
---|
| 3409 | UvData.MouseAction='create_object'; |
---|
| 3410 | else |
---|
| 3411 | set(handles.VOLUME,'BackgroundColor',[0 1 0]) |
---|
| 3412 | UvData.MouseAction='none'; |
---|
| 3413 | end |
---|
| 3414 | set(handles.uvmat,'UserData',UvData) |
---|
| 3415 | |
---|
| 3416 | %------------------------------------------------------- |
---|
| 3417 | function edit_vect_Callback(hObject, eventdata, handles) |
---|
| 3418 | %------------------------------------------------------- |
---|
| 3419 | % |
---|
| 3420 | % UvData=get(handles.uvmat,'UserData');%read UvData properties stored on the uvmat interface |
---|
| 3421 | if isequal(get(handles.edit_vect,'Value'),1) |
---|
| 3422 | test_civ2=isequal(get(handles.civ2,'BackgroundColor'),[1 1 0]); |
---|
| 3423 | test_civ1=isequal(get(handles.VelType,'BackgroundColor'),[1 1 0]); |
---|
| 3424 | if ~test_civ2 && ~test_civ1 |
---|
| 3425 | msgbox_uvmat('ERROR','manual correction only possible for CIV1 or CIV2 velocity fields') |
---|
| 3426 | end |
---|
| 3427 | set(handles.record,'Visible','on') |
---|
| 3428 | set(handles.edit_vect,'BackgroundColor',[1 1 0]) |
---|
| 3429 | set(handles.edit_object,'Value',0) |
---|
| 3430 | set(handles.CheckZoom,'Value',0) |
---|
| 3431 | set(handles.CheckZoom,'BackgroundColor',[0.7 0.7 0.7]) |
---|
| 3432 | % set(handles.create,'Value',0) |
---|
| 3433 | % set(handles.create,'BackgroundColor',[0 1 0]) |
---|
| 3434 | set(handles.edit_object,'BackgroundColor',[0.7 0.7 0.7]) |
---|
| 3435 | set(gcf,'Pointer','arrow') |
---|
| 3436 | % UvData.MouseAction='edit_vect'; |
---|
| 3437 | else |
---|
| 3438 | set(handles.record,'Visible','off') |
---|
| 3439 | set(handles.edit_vect,'BackgroundColor',[0.7 0.7 0.7]) |
---|
| 3440 | % UvData.MouseAction='none'; |
---|
| 3441 | end |
---|
| 3442 | % set(handles.uvmat,'UserData',UvData) |
---|
| 3443 | |
---|
| 3444 | %---------------------------------------------- |
---|
| 3445 | function save_mask_Callback(hObject, eventdata, handles) |
---|
| 3446 | %----------------------------------------------------------------------- |
---|
| 3447 | UvData=get(handles.uvmat,'UserData'); |
---|
| 3448 | |
---|
| 3449 | flag=1; |
---|
| 3450 | npx=size(UvData.Field.A,2); |
---|
| 3451 | npy=size(UvData.Field.A,1); |
---|
| 3452 | xi=0.5:npx-0.5; |
---|
| 3453 | yi=0.5:npy-0.5; |
---|
| 3454 | [Xi,Yi]=meshgrid(xi,yi); |
---|
| 3455 | if isfield(UvData,'Object') |
---|
| 3456 | for iobj=1:length(UvData.Object) |
---|
| 3457 | ObjectData=UvData.Object{iobj}; |
---|
| 3458 | if isfield(ObjectData,'ProjMode') &&(isequal(ObjectData.ProjMode,'mask_inside')||isequal(ObjectData.ProjMode,'mask_outside')); |
---|
| 3459 | flagobj=1; |
---|
| 3460 | testphys=0; %coordinates in pixels by default |
---|
| 3461 | if isfield(ObjectData,'CoordType') && isequal(ObjectData.CoordType,'phys') |
---|
| 3462 | if isfield(UvData,'XmlData')&& isfield(UvData.XmlData{1},'GeometryCalib') |
---|
| 3463 | Calib=UvData.XmlData{1}.GeometryCalib; |
---|
| 3464 | testphys=1; |
---|
| 3465 | end |
---|
| 3466 | end |
---|
| 3467 | if isfield(ObjectData,'Coord')& isfield(ObjectData,'Style') |
---|
| 3468 | if isequal(ObjectData.Type,'polygon') |
---|
| 3469 | X=ObjectData.Coord(:,1); |
---|
| 3470 | Y=ObjectData.Coord(:,2); |
---|
| 3471 | if testphys |
---|
| 3472 | [X,Y]=px_XYZ(Calib,X,Y,0);% to generalise with 3D cases |
---|
| 3473 | end |
---|
| 3474 | flagobj=~inpolygon(Xi,Yi,X',Y');%=0 inside the polygon, 1 outside |
---|
| 3475 | elseif isequal(ObjectData.Type,'ellipse') |
---|
| 3476 | if testphys |
---|
| 3477 | %[X,Y]=px_XYZ(Calib,X,Y,0);% TODO:create a polygon boundary and transform to phys |
---|
| 3478 | end |
---|
| 3479 | RangeX=max(ObjectData.RangeX); |
---|
| 3480 | RangeY=max(ObjectData.RangeY); |
---|
| 3481 | X2Max=RangeX*RangeX; |
---|
| 3482 | Y2Max=RangeY*RangeY; |
---|
| 3483 | distX=(Xi-ObjectData.Coord(1,1)); |
---|
| 3484 | distY=(Yi-ObjectData.Coord(1,2)); |
---|
| 3485 | flagobj=(distX.*distX/X2Max+distY.*distY/Y2Max)>1; |
---|
| 3486 | elseif isequal(ObjectData.Type,'rectangle') |
---|
| 3487 | if testphys |
---|
| 3488 | %[X,Y]=px_XYZ(Calib,X,Y,0);% TODO:create a polygon boundary and transform to phys |
---|
| 3489 | end |
---|
| 3490 | distX=abs(Xi-ObjectData.Coord(1,1)); |
---|
| 3491 | distY=abs(Yi-ObjectData.Coord(1,2)); |
---|
| 3492 | flagobj=distX>max(ObjectData.RangeX) | distY>max(ObjectData.RangeY); |
---|
| 3493 | end |
---|
| 3494 | if isequal(ObjectData.ProjMode,'mask_outside') |
---|
| 3495 | flagobj=~flagobj; |
---|
| 3496 | end |
---|
| 3497 | flag=flag & flagobj; |
---|
| 3498 | end |
---|
| 3499 | end |
---|
| 3500 | end |
---|
| 3501 | end |
---|
| 3502 | % flag=~flag; |
---|
| 3503 | %mask name |
---|
| 3504 | RootPath=get(handles.RootPath,'String'); |
---|
| 3505 | RootFile=get(handles.RootFile,'String'); |
---|
| 3506 | RootFile=regexprep(RootFile,'\<[\\/]|[\\/]\>','');%suppress possible / or \ separator at the beginning or the end of the string |
---|
| 3507 | filebase=fullfile(RootPath,RootFile); |
---|
| 3508 | list=get(handles.masklevel,'String'); |
---|
| 3509 | masknumber=num2str(length(list)); |
---|
| 3510 | maskindex=get(handles.masklevel,'Value'); |
---|
| 3511 | mask_name=fullfile_uvmat(RootPath,SubDir,[RootFile '_' masknumber 'mask'],'.png','_1',maskindex); |
---|
| 3512 | %mask_name=name_generator([filebase '_' masknumber 'mask'],maskindex,1,'.png','_i'); |
---|
| 3513 | imflag=uint8(255*(0.392+0.608*flag));% =100 for flag=0 (vectors not computed when 20<imflag<200) |
---|
| 3514 | imflag=flipdim(imflag,1); |
---|
| 3515 | % imflag=uint8(255*flag);% =0 for flag=0 (vectors=0 when 20<imflag<200) |
---|
| 3516 | msgbox_uvmat('CONFIRMATION',[mask_name ' saved']) |
---|
| 3517 | imwrite(imflag,mask_name,'BitDepth',8); |
---|
| 3518 | |
---|
| 3519 | %display the mask |
---|
| 3520 | figure; |
---|
| 3521 | vec=linspace(0,1,256);%define a linear greyscale colormap |
---|
| 3522 | map=[vec' vec' vec']; |
---|
| 3523 | colormap(map) |
---|
| 3524 | |
---|
| 3525 | image(imflag); |
---|
| 3526 | |
---|
| 3527 | %------------------------------------------------------------------- |
---|
| 3528 | %------------------------------------------------------------------- |
---|
| 3529 | % - FUNCTIONS FOR SETTING PLOTTING PARAMETERS |
---|
| 3530 | |
---|
| 3531 | %------------------------------------------------------------------ |
---|
| 3532 | %------------------------------------------------------------- |
---|
| 3533 | % --- Executes on selection change in transform_fct. |
---|
| 3534 | function transform_fct_Callback(hObject, eventdata, handles) |
---|
| 3535 | %------------------------------------------------------------- |
---|
| 3536 | UvData=get(handles.uvmat,'UserData'); |
---|
| 3537 | menu=get(handles.transform_fct,'String'); |
---|
| 3538 | ind_coord=get(handles.transform_fct,'Value'); |
---|
| 3539 | coord_option=menu{ind_coord}; |
---|
| 3540 | list_transform=get(handles.transform_fct,'UserData'); |
---|
| 3541 | ff=functions(list_transform{end}); |
---|
| 3542 | if isequal(coord_option,'more...'); |
---|
| 3543 | coord_fct=''; |
---|
| 3544 | prompt = {'Enter the name of the transform function'}; |
---|
| 3545 | dlg_title = 'user defined transform'; |
---|
| 3546 | num_lines= 1; |
---|
| 3547 | [FileName, PathName] = uigetfile( ... |
---|
| 3548 | {'*.m', ' (*.m)'; |
---|
| 3549 | '*.m', '.m files '; ... |
---|
| 3550 | '*.*', 'All Files (*.*)'}, ... |
---|
| 3551 | 'Pick a file', ff.file); |
---|
| 3552 | if isequal(PathName(end),'/')||isequal(PathName(end),'\') |
---|
| 3553 | PathName(end)=[]; |
---|
| 3554 | end |
---|
| 3555 | transform_selected =fullfile(PathName,FileName); |
---|
| 3556 | if ~exist(transform_selected,'file') |
---|
| 3557 | return |
---|
| 3558 | end |
---|
| 3559 | [ppp,transform,ext_fct]=fileparts(FileName);% removes extension .m |
---|
| 3560 | if ~isequal(ext_fct,'.m') |
---|
| 3561 | msgbox_uvmat('ERROR','a Matlab function .m must be introduced'); |
---|
| 3562 | return |
---|
| 3563 | end |
---|
| 3564 | menu=update_menu(handles.transform_fct,transform);%add the selected fct to the menu |
---|
| 3565 | ind_coord=get(handles.transform_fct,'Value'); |
---|
| 3566 | addpath(PathName) |
---|
| 3567 | list_transform{ind_coord}=str2func(transform);% create the function handle corresponding to the newly seleced function |
---|
| 3568 | set(handles.transform_fct,'UserData',list_transform) |
---|
| 3569 | rmpath(PathName) |
---|
| 3570 | % save the new menu in the personal file 'uvmat_perso.mat' |
---|
| 3571 | dir_perso=prefdir;%personal Matalb directory |
---|
| 3572 | profil_perso=fullfile(dir_perso,'uvmat_perso.mat'); |
---|
| 3573 | if exist(profil_perso,'file') |
---|
| 3574 | nb_builtin=UvData.OpenParam.NbBuiltin; |
---|
| 3575 | for ilist=nb_builtin+1:numel(list_transform) |
---|
| 3576 | ff=functions(list_transform{ilist}); |
---|
| 3577 | transform_fct{ilist-nb_builtin}=ff.file; |
---|
| 3578 | end |
---|
| 3579 | save (profil_perso,'transform_fct','-append'); %store the root name for future opening of uvmat |
---|
| 3580 | end |
---|
| 3581 | end |
---|
| 3582 | |
---|
[429] | 3583 | %% check the current path to the selected function |
---|
[387] | 3584 | if isa(list_transform{ind_coord},'function_handle') |
---|
| 3585 | func=functions(list_transform{ind_coord}); |
---|
| 3586 | set(handles.path_transform,'String',fileparts(func.file)); %show the path to the senlected function |
---|
| 3587 | else |
---|
| 3588 | set(handles.path_transform,'String','') |
---|
| 3589 | end |
---|
| 3590 | |
---|
| 3591 | set(handles.CheckFixLimits,'Value',0) |
---|
| 3592 | set(handles.CheckFixLimits,'BackgroundColor',[0.7 0.7 0.7]) |
---|
| 3593 | |
---|
[429] | 3594 | %% delete drawn objects |
---|
[387] | 3595 | hother=findobj('Tag','proj_object');%find all the proj objects |
---|
| 3596 | for iobj=1:length(hother) |
---|
| 3597 | delete_object(hother(iobj)) |
---|
| 3598 | end |
---|
| 3599 | hother=findobj('Tag','DeformPoint');%find all the proj objects |
---|
| 3600 | for iobj=1:length(hother) |
---|
| 3601 | delete_object(hother(iobj)) |
---|
| 3602 | end |
---|
| 3603 | hh=findobj('Tag','calib_points'); |
---|
| 3604 | if ~isempty(hh) |
---|
| 3605 | delete(hh) |
---|
| 3606 | end |
---|
| 3607 | hhh=findobj('Tag','calib_marker'); |
---|
| 3608 | if ~isempty(hhh) |
---|
| 3609 | delete(hhh) |
---|
| 3610 | end |
---|
| 3611 | if isfield(UvData,'Object') |
---|
| 3612 | UvData.Object=UvData.Object(1); |
---|
| 3613 | end |
---|
| 3614 | set(handles.ListObject,'Value',1) |
---|
[429] | 3615 | set(handles.ListObject,'String',{'plane'}) |
---|
| 3616 | set(handles.ListObject_1,'Value',1) |
---|
| 3617 | set(handles.ListObject_1,'String',{'plane'}) |
---|
[387] | 3618 | |
---|
| 3619 | %delete mask if it is displayed |
---|
[411] | 3620 | % if isequal(get(handles.CheckMask,'Value'),1)%if the mask option is on |
---|
| 3621 | % UvData=rmfield(UvData,'MaskName'); %will impose mask refresh |
---|
| 3622 | % end |
---|
[387] | 3623 | set(handles.uvmat,'UserData',UvData) |
---|
| 3624 | run0_Callback(hObject, eventdata, handles) |
---|
| 3625 | |
---|
| 3626 | |
---|
| 3627 | |
---|
| 3628 | %------------------------------------------------ |
---|
| 3629 | %CALLBACKS FOR PLOTTING PARAMETERS |
---|
| 3630 | %------------------------------------------------- |
---|
[405] | 3631 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
---|
| 3632 | % Plot coordinates |
---|
| 3633 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
---|
[387] | 3634 | %------------------------------------------------------------------------ |
---|
| 3635 | function num_MinX_Callback(hObject, eventdata, handles) |
---|
| 3636 | %------------------------------------------------------------------------ |
---|
| 3637 | set(handles.CheckFixLimits,'Value',1) %suppress auto mode |
---|
| 3638 | set(handles.CheckFixLimits,'BackgroundColor',[1 1 0]) |
---|
| 3639 | update_plot(handles); |
---|
| 3640 | |
---|
| 3641 | %------------------------------------------------------------------------ |
---|
| 3642 | function num_MaxX_Callback(hObject, eventdata, handles) |
---|
| 3643 | %------------------------------------------------------------------------ |
---|
| 3644 | set(handles.CheckFixLimits,'Value',1) %suppress auto mode |
---|
| 3645 | set(handles.CheckFixLimits,'BackgroundColor',[1 1 0]) |
---|
| 3646 | update_plot(handles); |
---|
| 3647 | |
---|
| 3648 | %------------------------------------------------------------------------ |
---|
| 3649 | function num_MinY_Callback(hObject, eventdata, handles) |
---|
| 3650 | %------------------------------------------ |
---|
| 3651 | set(handles.CheckFixLimits,'Value',1) %suppress auto mode |
---|
| 3652 | set(handles.CheckFixLimits,'BackgroundColor',[1 1 0]) |
---|
| 3653 | update_plot(handles); |
---|
| 3654 | |
---|
| 3655 | %------------------------------------------------------------------------ |
---|
| 3656 | function num_MaxY_Callback(hObject, eventdata, handles) |
---|
| 3657 | %------------------------------------------------------------------------ |
---|
| 3658 | set(handles.CheckFixLimits,'Value',1) %suppress auto mode |
---|
| 3659 | set(handles.CheckFixLimits,'BackgroundColor',[1 1 0]) |
---|
| 3660 | update_plot(handles); |
---|
| 3661 | |
---|
[405] | 3662 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
---|
| 3663 | % Scalar or image representation |
---|
| 3664 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
---|
[387] | 3665 | %------------------------------------------------------------------------ |
---|
| 3666 | function num_MinA_Callback(hObject, eventdata, handles) |
---|
| 3667 | %------------------------------------------ |
---|
| 3668 | set(handles.CheckFixScalar,'Value',1) %suppress auto mode |
---|
| 3669 | set(handles.CheckFixScalar,'BackgroundColor',[1 1 0]) |
---|
| 3670 | MinA=str2double(get(handles.num_MinA,'String')); |
---|
| 3671 | MaxA=str2double(get(handles.num_MaxA,'String')); |
---|
| 3672 | if MinA>MaxA% switch minA and maxA in case of error |
---|
| 3673 | MinA_old=MinA; |
---|
| 3674 | MinA=MaxA; |
---|
| 3675 | MaxA=MinA_old; |
---|
| 3676 | set(handles.num_MinA,'String',num2str(MinA,5)); |
---|
| 3677 | set(handles.num_MaxA,'String',num2str(MaxA,5)); |
---|
| 3678 | end |
---|
| 3679 | update_plot(handles); |
---|
| 3680 | |
---|
| 3681 | %------------------------------------------------------------------------ |
---|
| 3682 | function num_MaxA_Callback(hObject, eventdata, handles) |
---|
| 3683 | %------------------------------------------------------------------------ |
---|
| 3684 | set(handles.CheckFixScalar,'Value',1) %suppress auto mode |
---|
| 3685 | set(handles.CheckFixScalar,'BackgroundColor',[1 1 0]) |
---|
| 3686 | MinA=str2double(get(handles.num_MinA,'String')); |
---|
| 3687 | MaxA=str2double(get(handles.num_MaxA,'String')); |
---|
| 3688 | if MinA>MaxA% switch minA and maxA in case of error |
---|
| 3689 | MinA_old=MinA; |
---|
| 3690 | MinA=MaxA; |
---|
| 3691 | MaxA=MinA_old; |
---|
| 3692 | set(handles.num_MinA,'String',num2str(MinA,5)); |
---|
| 3693 | set(handles.num_MaxA,'String',num2str(MaxA,5)); |
---|
| 3694 | end |
---|
| 3695 | update_plot(handles); |
---|
| 3696 | |
---|
| 3697 | %------------------------------------------------------------------------ |
---|
| 3698 | function CheckFixScalar_Callback(hObject, eventdata, handles) |
---|
| 3699 | %------------------------------------------------------------------------ |
---|
| 3700 | test=get(handles.CheckFixScalar,'Value'); |
---|
| 3701 | if test |
---|
| 3702 | set(handles.CheckFixScalar,'BackgroundColor',[1 1 0]) |
---|
| 3703 | else |
---|
| 3704 | set(handles.CheckFixScalar,'BackgroundColor',[0.7 0.7 0.7]) |
---|
| 3705 | update_plot(handles); |
---|
| 3706 | end |
---|
| 3707 | |
---|
| 3708 | %------------------------------------------------------------------- |
---|
| 3709 | function CheckBW_Callback(hObject, eventdata, handles) |
---|
| 3710 | %------------------------------------------------------------------- |
---|
| 3711 | update_plot(handles); |
---|
| 3712 | |
---|
| 3713 | %------------------------------------------------------------------- |
---|
[428] | 3714 | function num_Opacity_Callback(hObject, eventdata, handles) |
---|
| 3715 | update_plot(handles); |
---|
| 3716 | %------------------------------------------------------------------- |
---|
| 3717 | |
---|
| 3718 | %------------------------------------------------------------------- |
---|
[387] | 3719 | function ListContour_Callback(hObject, eventdata, handles) |
---|
| 3720 | %------------------------------------------------------------------- |
---|
| 3721 | val=get(handles.ListContour,'Value'); |
---|
| 3722 | if val==2 |
---|
| 3723 | set(handles.interval_txt,'Visible','on') |
---|
| 3724 | set(handles.num_IncrA,'Visible','on') |
---|
| 3725 | else |
---|
| 3726 | set(handles.interval_txt,'Visible','off') |
---|
| 3727 | set(handles.num_IncrA,'Visible','off') |
---|
| 3728 | end |
---|
| 3729 | update_plot(handles); |
---|
| 3730 | |
---|
| 3731 | %------------------------------------------------------------------- |
---|
| 3732 | function num_IncrA_Callback(hObject, eventdata, handles) |
---|
| 3733 | %------------------------------------------------------------------- |
---|
| 3734 | update_plot(handles); |
---|
| 3735 | |
---|
[405] | 3736 | |
---|
| 3737 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
---|
| 3738 | % Vector representation |
---|
| 3739 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
---|
[387] | 3740 | %------------------------------------------------------------------- |
---|
| 3741 | function CheckHideWarning_Callback(hObject, eventdata, handles) |
---|
| 3742 | %------------------------------------------------------------------- |
---|
| 3743 | update_plot(handles); |
---|
| 3744 | |
---|
| 3745 | %------------------------------------------------------------------- |
---|
| 3746 | function CheckHideFalse_Callback(hObject, eventdata, handles) |
---|
| 3747 | %------------------------------------------------------------------- |
---|
| 3748 | update_plot(handles); |
---|
| 3749 | |
---|
| 3750 | %------------------------------------------------------------------- |
---|
| 3751 | function num_VecScale_Callback(hObject, eventdata, handles) |
---|
| 3752 | %------------------------------------------------------------------- |
---|
| 3753 | set(handles.CheckFixVectors,'Value',1); |
---|
| 3754 | set(handles.CheckFixVectors,'BackgroundColor',[1 1 0]) |
---|
| 3755 | update_plot(handles); |
---|
| 3756 | |
---|
| 3757 | %------------------------------------------------------------------- |
---|
| 3758 | function CheckFixVectors_Callback(hObject, eventdata, handles) |
---|
| 3759 | %------------------------------------------------------------------- |
---|
| 3760 | test=get(handles.CheckFixVectors,'Value'); |
---|
| 3761 | if test |
---|
| 3762 | set(handles.CheckFixVectors,'BackgroundColor',[1 1 0]) |
---|
| 3763 | else |
---|
| 3764 | update_plot(handles); |
---|
| 3765 | %set(handles.num_VecScale,'String',num2str(ScalOut.num_VecScale,3)) |
---|
| 3766 | set(handles.CheckFixVectors,'BackgroundColor',[0.7 0.7 0.7]) |
---|
| 3767 | end |
---|
| 3768 | |
---|
| 3769 | %------------------------------------------------------------------------ |
---|
| 3770 | % --- Executes on selection change in CheckDecimate4 (nb_vec/4). |
---|
| 3771 | function CheckDecimate4_Callback(hObject, eventdata, handles) |
---|
| 3772 | %------------------------------------------------------------------------ |
---|
| 3773 | update_plot(handles); |
---|
| 3774 | |
---|
| 3775 | %------------------------------------------------------------------------ |
---|
[405] | 3776 | % --- Executes on selection change in ColorCode menu |
---|
| 3777 | function ColorCode_Callback(hObject, eventdata, handles) |
---|
[387] | 3778 | %------------------------------------------------------------------------ |
---|
[405] | 3779 | % edit the choice for color code |
---|
| 3780 | update_color_code_boxes(handles); |
---|
| 3781 | update_plot(handles); |
---|
| 3782 | |
---|
| 3783 | %------------------------------------------------------------------------ |
---|
| 3784 | function update_color_code_boxes(handles) |
---|
| 3785 | %------------------------------------------------------------------------ |
---|
| 3786 | list_code=get(handles.ColorCode,'String');% list menu fields |
---|
| 3787 | colcode= list_code{get(handles.ColorCode,'Value')}; % selected field |
---|
| 3788 | enable_slider='off';%default |
---|
| 3789 | enable_bounds='off';%default |
---|
| 3790 | enable_scalar='off';%default |
---|
| 3791 | switch colcode |
---|
| 3792 | case {'rgb','bgr'} |
---|
| 3793 | enable_slider='on'; |
---|
| 3794 | enable_bounds='on'; |
---|
| 3795 | enable_scalar='on'; |
---|
| 3796 | case '64 colors' |
---|
| 3797 | enable_bounds='on'; |
---|
| 3798 | enable_scalar='on'; |
---|
| 3799 | end |
---|
| 3800 | set(handles.Slider1,'Visible',enable_slider) |
---|
| 3801 | set(handles.Slider2,'Visible', enable_slider) |
---|
| 3802 | set(handles.num_ColCode1,'Visible',enable_slider) |
---|
| 3803 | set(handles.num_ColCode2,'Visible',enable_slider) |
---|
| 3804 | set(handles.TitleColCode1,'Visible',enable_slider) |
---|
| 3805 | set(handles.TitleColCode2,'Visible',enable_slider) |
---|
| 3806 | set(handles.CheckFixVecColor,'Visible',enable_bounds) |
---|
| 3807 | set(handles.num_MinVec,'Visible',enable_bounds) |
---|
| 3808 | set(handles.num_MaxVec,'Visible',enable_bounds) |
---|
| 3809 | set(handles.ColorScalar,'Visible',enable_scalar) |
---|
[387] | 3810 | set_vec_col_bar(handles) |
---|
[405] | 3811 | |
---|
| 3812 | %------------------------------------------------------------------ |
---|
| 3813 | % --- Executes on selection change in ColorScalar: choice of the color code. |
---|
| 3814 | function ColorScalar_Callback(hObject, eventdata, handles) |
---|
| 3815 | %------------------------------------------------------------------ |
---|
| 3816 | % edit the choice for color code |
---|
| 3817 | list_scalar=get(handles.ColorScalar,'String');% list menu fields |
---|
| 3818 | col_scalar= list_scalar{get(handles.ColorScalar,'Value')}; % selected field |
---|
| 3819 | if isequal(col_scalar,'ima_cor') |
---|
| 3820 | set(handles.CheckFixVecColor,'Value',1)%fixed scale by default |
---|
| 3821 | ColorCode='rgb'; |
---|
| 3822 | set(handles.num_MinVec,'String','0') |
---|
| 3823 | set(handles.num_MaxVec,'String','1') |
---|
| 3824 | set(handles.num_ColCode1,'String','0.333') |
---|
| 3825 | set(handles.num_ColCode2,'String','0.666') |
---|
| 3826 | else |
---|
| 3827 | set(handles.CheckFixVecColor,'Value',0)%auto scale between min,max by default |
---|
| 3828 | ColorCode='64 colors'; |
---|
| 3829 | end |
---|
| 3830 | ColorCodeList=get(handles.ColorCode,'String'); |
---|
| 3831 | ichoice=find(strcmp(ColorCode,ColorCodeList),1); |
---|
| 3832 | set(handles.ColorCode,'Value',ichoice)% set color code in the menu |
---|
| 3833 | |
---|
| 3834 | update_color_code_boxes(handles); |
---|
| 3835 | %replot the current graph |
---|
| 3836 | run0_Callback(hObject, eventdata, handles) |
---|
| 3837 | |
---|
| 3838 | %---------------------------------------------------------------- |
---|
| 3839 | % -- Executes on slider movement to set the color code |
---|
| 3840 | % |
---|
| 3841 | function Slider1_Callback(hObject, eventdata, handles) |
---|
| 3842 | %------------------------------------------------------------------ |
---|
| 3843 | slider1=get(handles.Slider1,'Value'); |
---|
| 3844 | min_val=str2num(get(handles.num_MinVec,'String')); |
---|
| 3845 | max_val=str2num(get(handles.num_MaxVec,'String')); |
---|
| 3846 | col=min_val+(max_val-min_val)*slider1; |
---|
| 3847 | set(handles.num_ColCode1,'String',num2str(col)) |
---|
| 3848 | if(get(handles.Slider2,'Value') < col)%move also the second slider at the same value if needed |
---|
| 3849 | set(handles.Slider2,'Value',col) |
---|
| 3850 | set(handles.num_ColCode2,'String',num2str(col)) |
---|
| 3851 | end |
---|
| 3852 | set_vec_col_bar(handles) |
---|
[387] | 3853 | update_plot(handles); |
---|
| 3854 | |
---|
[405] | 3855 | %---------------------------------------------------------------- |
---|
| 3856 | % Executes on slider movement to set the color code |
---|
| 3857 | %---------------------------------------------------------------- |
---|
| 3858 | function Slider2_Callback(hObject, eventdata, handles) |
---|
| 3859 | slider2=get(handles.Slider2,'Value'); |
---|
| 3860 | min_val=str2num(get(handles.num_MinVec,'String')); |
---|
| 3861 | max_val=str2num(get(handles.num_MaxVec,'String')); |
---|
| 3862 | col=min_val+(max_val-min_val)*slider2; |
---|
| 3863 | set(handles.num_ColCode2,'String',num2str(col)) |
---|
| 3864 | if(get(handles.Slider1,'Value') > col)%move also the first slider at the same value if needed |
---|
| 3865 | set(handles.Slider1,'Value',col) |
---|
| 3866 | set(handles.num_ColCode1,'String',num2str(col)) |
---|
| 3867 | end |
---|
| 3868 | set_vec_col_bar(handles) |
---|
| 3869 | update_plot(handles); |
---|
| 3870 | |
---|
| 3871 | %---------------------------------------------------------------- |
---|
| 3872 | % --- Execute on return carriage on the edit box corresponding to slider 1 |
---|
| 3873 | %---------------------------------------------------------------- |
---|
| 3874 | function num_ColCode1_Callback(hObject, eventdata, handles) |
---|
| 3875 | set_vec_col_bar(handles) |
---|
| 3876 | update_plot(handles); |
---|
| 3877 | |
---|
| 3878 | %---------------------------------------------------------------- |
---|
| 3879 | % --- Execute on return carriage on the edit box corresponding to slider 2 |
---|
| 3880 | %---------------------------------------------------------------- |
---|
| 3881 | function num_ColCode2_Callback(hObject, eventdata, handles) |
---|
| 3882 | set_vec_col_bar(handles) |
---|
| 3883 | update_plot(handles); |
---|
[387] | 3884 | %------------------------------------------------------------------------ |
---|
[405] | 3885 | %------------------------------------------------------- |
---|
[387] | 3886 | % --- Executes on button press in CheckFixVecColor. |
---|
[405] | 3887 | %------------------------------------------------------- |
---|
| 3888 | function VecColBar_Callback(hObject, eventdata, handles) |
---|
| 3889 | set_vec_col_bar(handles) |
---|
| 3890 | |
---|
| 3891 | %------------------------------------------------------------------------ |
---|
| 3892 | % --- Executes on button press in CheckFixVecColor. |
---|
[387] | 3893 | function CheckFixVecColor_Callback(hObject, eventdata, handles) |
---|
| 3894 | %------------------------------------------------------------------------ |
---|
[405] | 3895 | if ~get(handles.CheckFixVecColor,'Value') |
---|
[387] | 3896 | update_plot(handles); |
---|
| 3897 | end |
---|
| 3898 | |
---|
| 3899 | %------------------------------------------------------------------------ |
---|
| 3900 | % --- Executes on selection change in num_MaxVec. |
---|
| 3901 | function num_MinVec_Callback(hObject, eventdata, handles) |
---|
| 3902 | %------------------------------------------------------------------------ |
---|
| 3903 | max_vec_Callback(hObject, eventdata, handles) |
---|
| 3904 | |
---|
| 3905 | %------------------------------------------------------------------------ |
---|
| 3906 | % --- Executes on selection change in num_MaxVec. |
---|
| 3907 | function num_MaxVec_Callback(hObject, eventdata, handles) |
---|
| 3908 | %------------------------------------------------------------------------ |
---|
| 3909 | set(handles.CheckFixVecColor,'Value',1) |
---|
| 3910 | CheckFixVecColor_Callback(hObject, eventdata, handles) |
---|
| 3911 | min_val=str2num(get(handles.num_MinVec,'String')); |
---|
| 3912 | max_val=str2num(get(handles.num_MaxVec,'String')); |
---|
| 3913 | slider1=get(handles.Slider1,'Value'); |
---|
| 3914 | slider2=get(handles.Slider2,'Value'); |
---|
| 3915 | colcode1=min_val+(max_val-min_val)*slider1; |
---|
| 3916 | colcode2=min_val+(max_val-min_val)*slider2; |
---|
| 3917 | set(handles.num_ColCode1,'String',num2str(colcode1)) |
---|
| 3918 | set(handles.num_ColCode2,'String',num2str(colcode2)) |
---|
| 3919 | update_plot(handles); |
---|
| 3920 | |
---|
| 3921 | %------------------------------------------------------------------------ |
---|
[405] | 3922 | % --- update the display of color code for vectors (on vecColBar) |
---|
[387] | 3923 | function set_vec_col_bar(handles) |
---|
| 3924 | %------------------------------------------------------------------------ |
---|
| 3925 | %get the image of the color display button 'VecColBar' in pixels |
---|
| 3926 | set(handles.VecColBar,'Unit','pixel'); |
---|
| 3927 | pos_vert=get(handles.VecColBar,'Position'); |
---|
| 3928 | set(handles.VecColBar,'Unit','Normalized'); |
---|
| 3929 | width=ceil(pos_vert(3)); |
---|
| 3930 | height=ceil(pos_vert(4)); |
---|
| 3931 | |
---|
| 3932 | %get slider indications |
---|
[405] | 3933 | list=get(handles.ColorCode,'String'); |
---|
| 3934 | ichoice=get(handles.ColorCode,'Value'); |
---|
| 3935 | colcode.ColorCode=list{ichoice}; |
---|
[387] | 3936 | colcode.MinVec=str2num(get(handles.num_MinVec,'String')); |
---|
| 3937 | colcode.MaxVec=str2num(get(handles.num_MaxVec,'String')); |
---|
[405] | 3938 | test3color=strcmp(colcode.ColorCode,'rgb') || strcmp(colcode.ColorCode,'bgr'); |
---|
[387] | 3939 | if test3color |
---|
| 3940 | colcode.ColCode1=str2num(get(handles.num_ColCode1,'String')); |
---|
| 3941 | colcode.ColCode2=str2num(get(handles.num_ColCode2,'String')); |
---|
| 3942 | end |
---|
| 3943 | vec_C=colcode.MinVec+(colcode.MaxVec-colcode.MinVec)*(0.5:width-0.5)/width;%sample of vec_C values from min to max |
---|
| 3944 | [colorlist,col_vec]=set_col_vec(colcode,vec_C); |
---|
| 3945 | oneheight=ones(1,height); |
---|
| 3946 | A1=colorlist(col_vec,1)*oneheight; |
---|
| 3947 | A2=colorlist(col_vec,2)*oneheight; |
---|
| 3948 | A3=colorlist(col_vec,3)*oneheight; |
---|
| 3949 | A(:,:,1)=A1'; |
---|
| 3950 | A(:,:,2)=A2'; |
---|
| 3951 | A(:,:,3)=A3'; |
---|
| 3952 | set(handles.VecColBar,'Cdata',A) |
---|
| 3953 | |
---|
| 3954 | %------------------------------------------------------------------- |
---|
| 3955 | function update_plot(handles) |
---|
| 3956 | %------------------------------------------------------------------- |
---|
| 3957 | UvData=get(handles.uvmat,'UserData'); |
---|
| 3958 | AxeData=UvData.axes3;% retrieve the current plotted data |
---|
| 3959 | PlotParam=read_GUI(handles.uvmat); |
---|
[399] | 3960 | [tild,PlotParamOut]= plot_field(AxeData,handles.axes3,PlotParam); |
---|
[387] | 3961 | write_plot_param(handles,PlotParamOut); %update the auto plot parameters |
---|
| 3962 | |
---|
[402] | 3963 | %------------------------------------------------------------------------ |
---|
| 3964 | %------------------------------------------------------------------------ |
---|
| 3965 | % SELECTION AND EDITION OF PROJECTION OBJECTS |
---|
| 3966 | %------------------------------------------------------------------------ |
---|
| 3967 | %------------------------------------------------------------------------ |
---|
[387] | 3968 | |
---|
[410] | 3969 | % --- Executes on selection change in ListObject_1. |
---|
| 3970 | function ListObject_1_Callback(hObject, eventdata, handles) |
---|
[432] | 3971 | list_str=get(handles.ListObject,'String'); |
---|
[410] | 3972 | UvData=get(handles.uvmat,'UserData'); |
---|
| 3973 | ObjectData=UvData.Object{get(handles.ListObject_1,'Value')}; |
---|
| 3974 | |
---|
| 3975 | %% update the projection plot on uvmat |
---|
[432] | 3976 | ProjData= proj_field(UvData.Field,ObjectData);%project the current input field on object ObjectData |
---|
| 3977 | plot_field(ProjData,handles.axes3,read_GUI(handles.uvmat));% plot the projected field; |
---|
| 3978 | %replot all the objects within the new projected field |
---|
| 3979 | for IndexObj=1:numel(list_str) |
---|
| 3980 | IndexObj |
---|
| 3981 | hobject=UvData.Object{IndexObj}.DisplayHandle.uvmat |
---|
| 3982 | if isempty(hobject) || ~ishandle(hobject) |
---|
| 3983 | hobject=handles.axes3 |
---|
| 3984 | end |
---|
| 3985 | if isequal(IndexObj,get(handles.ListObject,'Value')) |
---|
| 3986 | objectcolor='m'; %paint in magenta the currently selected object in ListObject |
---|
| 3987 | else |
---|
| 3988 | objectcolor='b'; |
---|
| 3989 | end |
---|
| 3990 | UvData.Object{IndexObj}.DisplayHandle.uvmat=plot_object(UvData.Object{IndexObj},ObjectData,hobject,objectcolor);%draw the object in uvmat |
---|
| 3991 | end |
---|
| 3992 | set(handles.uvmat,'UserData',UvData) |
---|
[410] | 3993 | |
---|
| 3994 | %% display the object parameters if the GUI set_object is already opened |
---|
[425] | 3995 | if ~get(handles.ViewObject,'Value') |
---|
[410] | 3996 | ZBounds=0; % default |
---|
| 3997 | if isfield(UvData.Field,'ZMin') && isfield(UvData.Field,'ZMax') |
---|
| 3998 | ZBounds(1)=UvData.Field.ZMin; %minimum for the Z slider |
---|
| 3999 | ZBounds(2)=UvData.Field.ZMax;%maximum for the Z slider |
---|
| 4000 | end |
---|
[425] | 4001 | ObjectData.Name=list_str{get(handles.ListObject_1,'Value')}; |
---|
[410] | 4002 | set_object(ObjectData,[],ZBounds); |
---|
[424] | 4003 | set(handles.ViewObject,'Value',1)% show that the selected object in ListObject_1 is currently visualised |
---|
[410] | 4004 | end |
---|
[432] | 4005 | |
---|
[410] | 4006 | % desactivate the edit object mode |
---|
| 4007 | set(handles.edit_object,'Value',0) |
---|
| 4008 | set(handles.edit_object,'BackgroundColor',[0.7,0.7,0.7]) |
---|
| 4009 | |
---|
[387] | 4010 | %------------------------------------------------------------------------ |
---|
| 4011 | % --- Executes on selection change in ListObject. |
---|
| 4012 | function ListObject_Callback(hObject, eventdata, handles) |
---|
| 4013 | %------------------------------------------------------------------------ |
---|
| 4014 | list_str=get(handles.ListObject,'String'); |
---|
| 4015 | IndexObj=get(handles.ListObject,'Value');%present object selection |
---|
| 4016 | |
---|
[410] | 4017 | %% The object is displayed in set_object if this GUI is already opened |
---|
[402] | 4018 | UvData=get(handles.uvmat,'UserData'); |
---|
[410] | 4019 | ObjectData=UvData.Object{IndexObj}; |
---|
[402] | 4020 | hset_object=findobj(allchild(0),'tag','set_object'); |
---|
| 4021 | if ~isempty(hset_object) |
---|
| 4022 | ZBounds=0; % default |
---|
| 4023 | if isfield(UvData.Field,'ZMin') && isfield(UvData.Field,'ZMax') |
---|
| 4024 | ZBounds(1)=UvData.Field.ZMin; %minimum for the Z slider |
---|
| 4025 | ZBounds(2)=UvData.Field.ZMax;%maximum for the Z slider |
---|
| 4026 | end |
---|
[410] | 4027 | ObjectData.Name=list_str{IndexObj}; |
---|
[402] | 4028 | set_object(ObjectData,[],ZBounds); |
---|
[424] | 4029 | set(handles.ViewField,'Value',1)% show that the selected object in ListObject is currently visualised |
---|
[402] | 4030 | end |
---|
[429] | 4031 | |
---|
| 4032 | %% desactivate the edit object mode |
---|
[402] | 4033 | set(handles.edit_object,'Value',0) |
---|
| 4034 | set(handles.edit_object,'BackgroundColor',[0.7,0.7,0.7]) |
---|
| 4035 | |
---|
[429] | 4036 | %% update the plot on view_field if view_field is already openened |
---|
| 4037 | hview_field=findobj(allchild(0),'tag','view_field'); |
---|
| 4038 | if isempty(hview_field) |
---|
| 4039 | hhview_field.axes3=[]; |
---|
| 4040 | else |
---|
| 4041 | Data=get(hview_field,'UserData'); |
---|
| 4042 | hhview_field=guidata(hview_field); |
---|
| 4043 | ProjData= proj_field(UvData.Field,ObjectData);%project the current interface field on ObjectData |
---|
| 4044 | [PlotType,PlotParam]=plot_field(ProjData,hhview_field.axes3,read_GUI(hview_field));%read plotting parameters on the uvmat interfachhview_fiel |
---|
| 4045 | write_plot_param(hhview_field,PlotParam); %update the display of plotting parameters for the current object |
---|
| 4046 | haxes=findobj(hview_field,'tag','axes3'); |
---|
| 4047 | pos=get(hview_field,'Position'); |
---|
| 4048 | if strcmp(get(haxes,'Visible'),'off')%sempty(PlotParam.Coordinates)% case of no plot display (pure text table) |
---|
| 4049 | h_TableDisplay=findobj(hview_field,'tag','TableDisplay'); |
---|
| 4050 | pos_table=get(h_TableDisplay,'Position'); |
---|
| 4051 | set(hview_field,'Position',[pos(1)+pos(3)-pos_table(3) pos(2)+pos(4)-pos_table(4) pos_table(3) pos_table(4)]) |
---|
| 4052 | drawnow% needed to change position before the next command |
---|
| 4053 | set(hview_field,'UserData',Data);% restore the previously stored GUI position after GUI resizing |
---|
| 4054 | else |
---|
| 4055 | set(hview_field,'Position',Data.GUISize)% return to the previously stored GUI position and size |
---|
[387] | 4056 | end |
---|
| 4057 | end |
---|
| 4058 | |
---|
[402] | 4059 | %% update the color of the graphic object representation: the selected object in magenta, others in blue |
---|
[432] | 4060 | update_object_color(handles.axes3,hhview_field.axes3,UvData.Object{IndexObj}.DisplayHandle.uvmat) |
---|
[387] | 4061 | |
---|
| 4062 | %------------------------------------------------------------------------ |
---|
[402] | 4063 | %--- update the color representation of objects (indicating the selected ones) |
---|
| 4064 | function update_object_color(axes_uvmat,axes_view_field,DisplayHandle) |
---|
[387] | 4065 | %------------------------------------------------------------------------ |
---|
[402] | 4066 | if isempty(axes_view_field)% case with no view_field plot |
---|
| 4067 | hother=[findobj(axes_uvmat,'Tag','proj_object');findobj(axes_uvmat,'Tag','DeformPoint')];%find all the proj object and deform point representations |
---|
[387] | 4068 | else |
---|
[402] | 4069 | hother=[findobj(axes_uvmat,'Tag','proj_object') ;findobj(axes_view_field,'Tag','proj_object');... %find all the proj object representations |
---|
| 4070 | findobj(axes_uvmat,'Tag','DeformPoint'); findobj(axes_view_field,'Tag','DeformPoint')];%find all the deform point representations |
---|
[387] | 4071 | end |
---|
| 4072 | for iobj=1:length(hother) |
---|
| 4073 | if isequal(get(hother(iobj),'Type'),'rectangle')||isequal(get(hother(iobj),'Type'),'patch') |
---|
| 4074 | set(hother(iobj),'EdgeColor','b') |
---|
| 4075 | if isequal(get(hother(iobj),'FaceColor'),'m') |
---|
| 4076 | set(hother(iobj),'FaceColor','b') |
---|
| 4077 | end |
---|
| 4078 | elseif isequal(get(hother(iobj),'Type'),'image') |
---|
| 4079 | Acolor=get(hother(iobj),'CData'); |
---|
| 4080 | Acolor(:,:,1)=zeros(size(Acolor,1),size(Acolor,2)); |
---|
| 4081 | set(hother(iobj),'CData',Acolor); |
---|
| 4082 | else |
---|
| 4083 | set(hother(iobj),'Color','b') |
---|
| 4084 | end |
---|
| 4085 | set(hother(iobj),'Selected','off') |
---|
| 4086 | end |
---|
[432] | 4087 | if ishandle(DisplayHandle) |
---|
[402] | 4088 | linetype=get(DisplayHandle,'Type'); |
---|
| 4089 | if isequal(linetype,'line') |
---|
| 4090 | set(DisplayHandle,'Color','m'); %set the selected object to magenta color |
---|
| 4091 | elseif isequal(linetype,'rectangle') |
---|
| 4092 | set(DisplayHandle,'EdgeColor','m'); %set the selected object to magenta color |
---|
| 4093 | elseif isequal(linetype,'patch') |
---|
| 4094 | set(DisplayHandle,'FaceColor','m'); %set the selected object to magenta color |
---|
| 4095 | end |
---|
| 4096 | SubObjectData=get(DisplayHandle,'UserData'); |
---|
| 4097 | if isfield(SubObjectData,'SubObject') & ishandle(SubObjectData.SubObject) |
---|
| 4098 | for iobj=1:length(SubObjectData.SubObject) |
---|
| 4099 | hsub=SubObjectData.SubObject(iobj); |
---|
| 4100 | if isequal(get(hsub,'Type'),'rectangle') |
---|
| 4101 | set(hsub,'EdgeColor','m'); %set the selected object to magenta color |
---|
| 4102 | elseif isequal(get(hsub,'Type'),'image') |
---|
| 4103 | Acolor=get(hsub,'CData'); |
---|
| 4104 | Acolor(:,:,1)=Acolor(:,:,3); |
---|
| 4105 | set(hsub,'CData',Acolor); |
---|
| 4106 | else |
---|
| 4107 | set(hsub,'Color','m') |
---|
| 4108 | end |
---|
[387] | 4109 | end |
---|
| 4110 | end |
---|
[402] | 4111 | if isfield(SubObjectData,'DeformPoint') & ishandle(SubObjectData.DeformPoint) |
---|
| 4112 | set(SubObjectData.DeformPoint,'Color','m') |
---|
| 4113 | end |
---|
[387] | 4114 | end |
---|
[402] | 4115 | |
---|
[427] | 4116 | %------------------------------------------------------------------- |
---|
| 4117 | % --- Executes on selection change in edit_object. |
---|
| 4118 | function edit_object_Callback(hObject, eventdata, handles) |
---|
| 4119 | %------------------------------------------------------------------- |
---|
| 4120 | UvData=get(handles.uvmat,'UserData');%read UvData properties stored on the uvmat interface |
---|
| 4121 | hset_object=findobj(allchild(0),'Tag','set_object'); |
---|
| 4122 | if get(handles.edit_object,'Value') |
---|
| 4123 | set(handles.edit_object,'BackgroundColor',[1,1,0]) |
---|
| 4124 | %suppress the other options |
---|
| 4125 | set(handles.CheckZoom,'Value',0) |
---|
| 4126 | CheckZoom_Callback(hObject, eventdata, handles) |
---|
| 4127 | hgeometry_calib=findobj(allchild(0),'tag','geometry_calib'); |
---|
| 4128 | if ishandle(hgeometry_calib) |
---|
| 4129 | hhgeometry_calib=guidata(hgeometry_calib); |
---|
| 4130 | set(hhgeometry_calib.edit_append,'Value',0)% desactivate mouse action in geometry_calib |
---|
| 4131 | set(hhgeometry_calib.edit_append,'BackgroundColor',[0.7 0.7 0.7]) |
---|
| 4132 | end |
---|
| 4133 | set(handles.ViewObject,'value',1) |
---|
| 4134 | ViewObject_Callback(hObject, eventdata, handles) |
---|
| 4135 | % if isempty(hset_object)% open the GUI set_object with data of the currently selected object |
---|
| 4136 | % ViewObject_Callback(hObject, eventdata, handles) |
---|
| 4137 | % % hset_object=findobj(allchild(0),'Tag','set_object'); |
---|
| 4138 | % else |
---|
| 4139 | % hhset_object=guidata(hset_object); |
---|
| 4140 | % set(hhset_object.PLOT,'enable','on'); |
---|
| 4141 | % set(get(hset_object,'children'),'enable','on') |
---|
| 4142 | % end |
---|
| 4143 | else % desctivate object edit mode |
---|
| 4144 | set(handles.edit_object,'BackgroundColor',[0.7,0.7,0.7]) |
---|
| 4145 | if ~isempty(hset_object)% open the |
---|
| 4146 | hhset_object=guidata(hset_object); |
---|
| 4147 | set(hhset_object.PLOT,'enable','off'); |
---|
| 4148 | set(get(hset_object,'children'),'enable','inactive') |
---|
| 4149 | end |
---|
| 4150 | end |
---|
| 4151 | |
---|
| 4152 | |
---|
[402] | 4153 | %------------------------------------------------------------------------ |
---|
[424] | 4154 | % --- Executes on button press in ViewObject. |
---|
| 4155 | function ViewObject_Callback(hObject, eventdata, handles) |
---|
[410] | 4156 | %------------------------------------------------------------------------ |
---|
[424] | 4157 | check_view=get(handles.ViewObject,'Value'); |
---|
[410] | 4158 | |
---|
| 4159 | if check_view %activate set_object |
---|
[424] | 4160 | IndexObj=get(handles.ListObject,'Value'); |
---|
| 4161 | list_object=get(handles.ListObject,'String'); |
---|
[410] | 4162 | UvData=get(handles.uvmat,'UserData');%read UvData properties stored on the uvmat interface |
---|
| 4163 | UvData.Object{IndexObj}.Name=list_object{IndexObj}; |
---|
| 4164 | if numel(UvData.Object)<IndexObj;% error in UvData |
---|
| 4165 | msgbox_uvmat('ERROR','invalid object list') |
---|
| 4166 | return |
---|
| 4167 | end |
---|
| 4168 | ZBounds=0; % default |
---|
| 4169 | if isfield(UvData.Field,'ZMin') && isfield(UvData.Field,'ZMax') |
---|
| 4170 | ZBounds(1)=UvData.Field.ZMin; %minimum for the Z slider |
---|
| 4171 | ZBounds(2)=UvData.Field.ZMax;%maximum for the Z slider |
---|
| 4172 | end |
---|
[424] | 4173 | % set(handles.ListObject_1,'Value',IndexObj);%restore ListObject selection after set_object deletion |
---|
[410] | 4174 | data=UvData.Object{IndexObj}; |
---|
| 4175 | if ~isfield(data,'Type')% default plane |
---|
| 4176 | data.Type='plane'; |
---|
| 4177 | end |
---|
| 4178 | if isfield(UvData,'Field') |
---|
| 4179 | Field=UvData.Field; |
---|
| 4180 | if isfield(UvData.Field,'Mesh')&&~isempty(UvData.Field.Mesh) |
---|
| 4181 | data.RangeX=[UvData.Field.XMin UvData.Field.XMax]; |
---|
| 4182 | if strcmp(data.Type,'line')||strcmp(data.Type,'polyline') |
---|
| 4183 | data.RangeY=UvData.Field.Mesh; |
---|
| 4184 | else |
---|
| 4185 | data.RangeY=[UvData.Field.YMin UvData.Field.YMax]; |
---|
| 4186 | end |
---|
| 4187 | data.DX=UvData.Field.Mesh; |
---|
| 4188 | data.DY=UvData.Field.Mesh; |
---|
| 4189 | end |
---|
| 4190 | if isfield(Field,'NbDim')&& isequal(Field.NbDim,3) |
---|
| 4191 | data.Coord=[0 0 0]; %default |
---|
| 4192 | end |
---|
| 4193 | if isfield(Field,'CoordUnit') |
---|
| 4194 | data.CoordUnit=Field.CoordUnit; |
---|
| 4195 | end |
---|
| 4196 | end |
---|
| 4197 | hset_object=set_object(data,[],ZBounds); |
---|
| 4198 | hhset_object=guidata(hset_object); |
---|
| 4199 | if get(handles.edit_object,'Value')% edit mode |
---|
| 4200 | set(hhset_object.PLOT,'Enable','on') |
---|
[424] | 4201 | set(get(hset_object,'children'),'enable','on') |
---|
[410] | 4202 | else |
---|
| 4203 | set(hhset_object.PLOT,'Enable','off') |
---|
[427] | 4204 | set(get(hset_object,'children'),'enable','inactive')% deactivate the GUI except SAVE |
---|
| 4205 | set(hhset_object.SAVE,'Enable','on') |
---|
[410] | 4206 | end |
---|
| 4207 | else |
---|
| 4208 | hset_object=findobj(allchild(0),'tag','set_object'); |
---|
| 4209 | if ~isempty(hset_object) |
---|
| 4210 | delete(hset_object)% delete existing version of set_object |
---|
| 4211 | end |
---|
| 4212 | end |
---|
| 4213 | |
---|
[424] | 4214 | |
---|
[410] | 4215 | %------------------------------------------------------------------------ |
---|
[424] | 4216 | % --- Executes on button press in ViewField. |
---|
| 4217 | function ViewField_Callback(hObject, eventdata, handles) |
---|
[402] | 4218 | %------------------------------------------------------------------------ |
---|
[424] | 4219 | check_view=get(handles.ViewField,'Value'); |
---|
[387] | 4220 | |
---|
[410] | 4221 | if check_view |
---|
| 4222 | IndexObj=get(handles.ListObject,'Value'); |
---|
| 4223 | UvData=get(handles.uvmat,'UserData');%read UvData properties stored on the uvmat interface |
---|
| 4224 | if numel(UvData.Object)<IndexObj(end);% error in UvData |
---|
| 4225 | msgbox_uvmat('ERROR','invalid object list') |
---|
| 4226 | return |
---|
| 4227 | end |
---|
| 4228 | ZBounds=0; % default |
---|
| 4229 | if isfield(UvData.Field,'ZMin') && isfield(UvData.Field,'ZMax') |
---|
| 4230 | ZBounds(1)=UvData.Field.ZMin; %minimum for the Z slider |
---|
| 4231 | ZBounds(2)=UvData.Field.ZMax;%maximum for the Z slider |
---|
| 4232 | end |
---|
| 4233 | set(handles.ListObject,'Value',IndexObj);%restore ListObject selection after set_object deletion |
---|
| 4234 | if ~isfield(UvData.Object{IndexObj(1)},'Type')% default plane |
---|
| 4235 | UvData.Object{IndexObj(1)}.Type='plane'; |
---|
| 4236 | end |
---|
| 4237 | list_object=get(handles.ListObject,'String'); |
---|
| 4238 | UvData.Object{IndexObj(end)}.Name=list_object{IndexObj(end)}; |
---|
| 4239 | |
---|
[429] | 4240 | %% show the projection of the selected object on view_field |
---|
| 4241 | ProjData= proj_field(UvData.Field,UvData.Object{IndexObj});%project the current field on ObjectData |
---|
[402] | 4242 | hview_field=findobj(allchild(0),'tag','view_field'); |
---|
| 4243 | if isempty(hview_field) |
---|
| 4244 | hview_field=view_field; |
---|
| 4245 | end |
---|
[429] | 4246 | hhview_field=guidata(hview_field); |
---|
| 4247 | [PlotType,PlotParam]=plot_field(ProjData,hhview_field.axes3,read_GUI(hview_field));%read plotting parameters on the GUI view_field); |
---|
| 4248 | write_plot_param(hhview_field,PlotParam); %update the display of plotting parameters for the current object |
---|
| 4249 | haxes=findobj(hview_field,'tag','axes3'); |
---|
| 4250 | pos=get(hview_field,'Position'); |
---|
| 4251 | if strcmp(get(haxes,'Visible'),'off')%sempty(PlotParam.Coordinates)% case of no plot display (pure text table) |
---|
| 4252 | h_TableDisplay=findobj(hview_field,'tag','TableDisplay'); |
---|
| 4253 | pos_table=get(h_TableDisplay,'Position'); |
---|
| 4254 | set(hview_field,'Position',[pos(1)+pos(3)-pos_table(3) pos(2)+pos(4)-pos_table(4) pos_table(3) pos_table(4)]) |
---|
| 4255 | else |
---|
| 4256 | Data=get(hview_field,'UserData'); |
---|
[432] | 4257 | set(hview_field,'Position',Data.GUISize)% restore the size of view_field for plots |
---|
[429] | 4258 | end |
---|
[410] | 4259 | else |
---|
[424] | 4260 | hview_field=findobj(allchild(0),'tag','view_field'); |
---|
| 4261 | if ~isempty(hview_field) |
---|
| 4262 | delete(hview_field)% delete existing version of set_object |
---|
[410] | 4263 | end |
---|
[402] | 4264 | end |
---|
| 4265 | |
---|
[424] | 4266 | |
---|
[402] | 4267 | %------------------------------------------------------------------------ |
---|
| 4268 | % --- Executes on button press in delete_object. |
---|
| 4269 | function delete_object_Callback(hObject, eventdata, handles) |
---|
| 4270 | %------------------------------------------------------------------------ |
---|
| 4271 | IndexObj=get(handles.ListObject,'Value'); |
---|
[410] | 4272 | IndexObj_1=get(handles.ListObject_1,'Value'); |
---|
| 4273 | if IndexObj>1 && ~isequal(IndexObj,IndexObj_1) |
---|
| 4274 | delete_object(IndexObj) |
---|
[402] | 4275 | end |
---|
| 4276 | |
---|
| 4277 | %------------------------------------------------------------------------ |
---|
| 4278 | %------------------------------------------------------------------------ |
---|
| 4279 | % II - TOOLS FROM THE UPPER MENU BAR |
---|
| 4280 | %------------------------------------------------------------------------ |
---|
| 4281 | %------------------------------------------------------------------------ |
---|
| 4282 | |
---|
| 4283 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
---|
| 4284 | % Export Menu Callbacks |
---|
| 4285 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
---|
| 4286 | %------------------------------------------------------------------------ |
---|
[387] | 4287 | % --- Executes on button press in Menu/Export/field in workspace. |
---|
| 4288 | function MenuExportField_Callback(hObject, eventdata, handles) |
---|
[402] | 4289 | %------------------------------------------------------------------------ |
---|
[387] | 4290 | global Data_uvmat |
---|
| 4291 | Data_uvmat=get(handles.uvmat,'UserData'); |
---|
| 4292 | evalin('base','global Data_uvmat')%make CurData global in the workspace |
---|
| 4293 | display('current field :') |
---|
| 4294 | evalin('base','Data_uvmat') %display CurData in the workspace |
---|
| 4295 | commandwindow; %brings the Matlab command window to the front |
---|
| 4296 | |
---|
[402] | 4297 | %------------------------------------------------------------------------ |
---|
[387] | 4298 | % --- Executes on button press in Menu/Export/extract figure. |
---|
[402] | 4299 | function MenuExportFigure_Callback(hObject, eventdata, handles) |
---|
| 4300 | %------------------------------------------------------------------------ |
---|
| 4301 | % huvmat=get(handles.MenuExport,'parent'); |
---|
[387] | 4302 | hfig=figure; |
---|
[402] | 4303 | copyobj(handles.axes3,hfig); |
---|
[387] | 4304 | map=colormap(handles.axes3); |
---|
| 4305 | colormap(map);%transmit the current colormap to the zoom fig |
---|
| 4306 | colorbar |
---|
| 4307 | |
---|
[402] | 4308 | % %------------------------------------------------------ |
---|
| 4309 | % % --- Executes on button press in Menu/Export/extract figure. |
---|
| 4310 | % %------------------------------------------------------ |
---|
| 4311 | % function MenuExport_plot_Callback(hObject, eventdata, handles) |
---|
| 4312 | % huvmat=get(handles.MenuExport_plot,'parent'); |
---|
| 4313 | % UvData=get(huvmat,'UserData'); |
---|
| 4314 | % hfig=figure; |
---|
| 4315 | % newaxes=copyobj(handles.axes3,hfig); |
---|
| 4316 | % map=colormap(handles.axes3); |
---|
| 4317 | % colormap(map);%transmit the current colormap to the zoom fig |
---|
| 4318 | % colorbar |
---|
[387] | 4319 | |
---|
[402] | 4320 | % |
---|
| 4321 | % % -------------------------------------------------------------------- |
---|
| 4322 | % function Insert_Callback(hObject, eventdata, handles) |
---|
| 4323 | % |
---|
[387] | 4324 | |
---|
| 4325 | %------------------------------------------------------------------------ |
---|
| 4326 | % -------------------------------------------------------------------- |
---|
| 4327 | function MenuExportMovie_Callback(hObject, eventdata, handles) |
---|
| 4328 | % -------------------------------------------------------------------- |
---|
| 4329 | set(handles.MenuExportMovie,'BusyAction','queue')% activate the button |
---|
| 4330 | huvmat=get(handles.run0,'parent'); |
---|
| 4331 | UvData=get(huvmat,'UserData'); |
---|
| 4332 | %[xx,xx,FileBase]=read_file_boxes(handles); |
---|
| 4333 | [RootPath,SubDir,RootFile,FileIndices,FileExt]=read_file_boxes(handles); |
---|
| 4334 | FileBase=fullfile(RootPath,RootFile); |
---|
| 4335 | %read the current input file name |
---|
| 4336 | 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)'}; |
---|
| 4337 | dlg_title = 'select properties of the output avi movie'; |
---|
| 4338 | num_lines= 1; |
---|
| 4339 | % nbfield_cell=get(handles.last_i,'String'); |
---|
| 4340 | def = {[FileBase '_out.avi'];'10';'1';'[0.03 0.05 0.95 0.92]';'10'}; |
---|
| 4341 | answer = inputdlg(prompt,dlg_title,num_lines,def,'on'); |
---|
| 4342 | aviname=answer{1}; |
---|
| 4343 | fps=str2double(answer{2}); |
---|
| 4344 | % check for existing file with output name aviname |
---|
| 4345 | if exist(aviname,'file') |
---|
| 4346 | backup=aviname; |
---|
| 4347 | testexist=2; |
---|
| 4348 | while testexist==2 |
---|
| 4349 | backup=[backup '~']; |
---|
| 4350 | testexist=exist(backup,'file'); |
---|
| 4351 | end |
---|
| 4352 | [success,message]=copyfile(aviname,backup);%make backup of the existing file |
---|
| 4353 | if isequal(success,1) |
---|
| 4354 | delete(aviname)%delete existing file |
---|
| 4355 | else |
---|
| 4356 | msgbox_uvmat('ERROR',message) |
---|
| 4357 | return |
---|
| 4358 | end |
---|
| 4359 | end |
---|
| 4360 | %create avi open |
---|
| 4361 | aviobj=avifile(aviname,'Compression','None','fps',fps); |
---|
| 4362 | |
---|
| 4363 | %display first view for tests |
---|
| 4364 | newfig=figure; |
---|
| 4365 | newaxes=copyobj(handles.axes3,newfig);%new plotting axes in the new figure |
---|
| 4366 | set(newaxes,'Tag','movieaxes') |
---|
| 4367 | nbpix=[512 384]*str2double(answer{3}); |
---|
| 4368 | set(gcf,'Position',[1 1 nbpix])% resolution XVGA |
---|
| 4369 | set(newaxes,'Position',eval(answer{4})); |
---|
| 4370 | map=colormap(handles.axes3); |
---|
| 4371 | colormap(map);%transmit the current colormap to the zoom fig |
---|
| 4372 | msgbox_uvmat('INPUT_Y-N',{['adjust figure ' num2str(newfig) ' with its matlab edit menu '] ;... |
---|
| 4373 | ['then press OK to get the avi movie as a copy of figure ' num2str(newfig) ' display']}); |
---|
| 4374 | UvData.plotaxes=newaxes;% the axis in the new figure becomes the current main plotting axes |
---|
| 4375 | set(huvmat,'UserData',UvData); |
---|
| 4376 | increment=str2num(get(handles.increment_scan,'String')); %get the field increment d |
---|
| 4377 | set(handles.STOP,'Visible','on') |
---|
| 4378 | set(handles.speed,'Visible','on') |
---|
| 4379 | set(handles.speed_txt,'Visible','on') |
---|
| 4380 | set(handles.Movie,'BusyAction','queue') |
---|
| 4381 | |
---|
| 4382 | %imin=str2double(get(handles.i1,'String')); |
---|
| 4383 | imax=str2double(answer{5}); |
---|
| 4384 | % if isfield(UvData,'Time') |
---|
| 4385 | htitle=get(newaxes,'Title'); |
---|
| 4386 | xlim=get(newaxes,'XLim'); |
---|
| 4387 | ylim=get(newaxes,'YLim'); |
---|
| 4388 | set(htitle,'Position',[xlim(2)+0.07*(xlim(2)-xlim(1)) ylim(2)-0.05*(ylim(2)-ylim(1)) 0]) |
---|
| 4389 | time_str=get(handles.abs_time,'String'); |
---|
| 4390 | set(htitle,'String',['t=' time_str]) |
---|
| 4391 | set(handles.speed,'Value',1) |
---|
| 4392 | for i=1:imax |
---|
| 4393 | if get(handles.speed,'Value')~=0 && isequal(get(handles.MenuExportMovie,'BusyAction'),'queue') % enable STOP command |
---|
| 4394 | runpm(hObject,eventdata,handles,increment)% run plus |
---|
| 4395 | drawnow |
---|
| 4396 | time_str=get(handles.abs_time,'String'); |
---|
| 4397 | if ishandle(htitle) |
---|
| 4398 | set(htitle,'String',['t=' time_str]) |
---|
| 4399 | end |
---|
| 4400 | mov=getframe(newfig); |
---|
| 4401 | aviobj=addframe(aviobj,mov); |
---|
| 4402 | end |
---|
| 4403 | end |
---|
| 4404 | aviobj=close(aviobj); |
---|
| 4405 | UvData=rmfield(UvData,'plotaxes'); |
---|
| 4406 | %UvData.Object{1}.plotaxes=handles.axes3; |
---|
| 4407 | set(huvmat,'UserData',UvData); |
---|
| 4408 | msgbox_uvmat('CONFIRMATION',{['movie ' aviname ' created '];['with ' num2str(imax) ' frames']}) |
---|
| 4409 | |
---|
[402] | 4410 | |
---|
| 4411 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
---|
| 4412 | % Projection Objects Menu Callbacks |
---|
| 4413 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
---|
| 4414 | |
---|
| 4415 | % ----------------------------------------------------------------------- |
---|
| 4416 | function Menupoints_Callback(hObject, eventdata, handles) |
---|
[387] | 4417 | %------------------------------------------------------------------------ |
---|
[402] | 4418 | data.Type='points'; |
---|
| 4419 | data.ProjMode='projection';%default |
---|
[410] | 4420 | data.ProjModeMenu={};% do not restrict ProjMode menus |
---|
[402] | 4421 | create_object(data,handles) |
---|
| 4422 | |
---|
| 4423 | % ----------------------------------------------------------------------- |
---|
| 4424 | function Menuline_Callback(hObject, eventdata, handles) |
---|
| 4425 | %------------------------------------------------------------------------ |
---|
| 4426 | data.Type='line'; |
---|
| 4427 | data.ProjMode='projection';%default |
---|
[410] | 4428 | data.ProjModeMenu={};% do not restrict ProjMode menus |
---|
[402] | 4429 | create_object(data,handles) |
---|
| 4430 | |
---|
| 4431 | %------------------------------------------------------------------------ |
---|
| 4432 | function Menupolyline_Callback(hObject, eventdata, handles) |
---|
| 4433 | %------------------------------------------------------------------------ |
---|
| 4434 | data.Type='polyline'; |
---|
| 4435 | data.ProjMode='projection';%default |
---|
[410] | 4436 | data.ProjModeMenu={};% do not restrict ProjMode menus |
---|
[402] | 4437 | create_object(data,handles) |
---|
| 4438 | |
---|
| 4439 | %------------------------------------------------------------------------ |
---|
| 4440 | function Menupolygon_Callback(hObject, eventdata, handles) |
---|
| 4441 | %------------------------------------------------------------------------ |
---|
| 4442 | data.Type='polygon'; |
---|
| 4443 | data.ProjMode='inside';%default |
---|
[410] | 4444 | data.ProjModeMenu={};% do not restrict ProjMode menus |
---|
[402] | 4445 | create_object(data,handles) |
---|
| 4446 | |
---|
| 4447 | %------------------------------------------------------------------------ |
---|
| 4448 | function Menurectangle_Callback(hObject, eventdata, handles) |
---|
| 4449 | %------------------------------------------------------------------------ |
---|
| 4450 | data.Type='rectangle'; |
---|
| 4451 | data.ProjMode='inside';%default |
---|
[410] | 4452 | data.ProjModeMenu={};% do not restrict ProjMode menus |
---|
[402] | 4453 | create_object(data,handles) |
---|
| 4454 | |
---|
| 4455 | %------------------------------------------------------------------------ |
---|
| 4456 | function Menuellipse_Callback(hObject, eventdata, handles) |
---|
| 4457 | %------------------------------------------------------------------------ |
---|
| 4458 | data.Type='ellipse'; |
---|
| 4459 | data.ProjMode='inside';%default |
---|
[410] | 4460 | data.ProjModeMenu={};% do not restrict ProjMode menus |
---|
[402] | 4461 | create_object(data,handles) |
---|
| 4462 | |
---|
| 4463 | %------------------------------------------------------------------------ |
---|
| 4464 | function MenuMaskObject_Callback(hObject, eventdata, handles) |
---|
| 4465 | %------------------------------------------------------------------------ |
---|
| 4466 | data.Type='polygon'; |
---|
| 4467 | data.TypeMenu={'polygon'}; |
---|
| 4468 | data.ProjMode='mask_inside';%default |
---|
| 4469 | data.ProjModeMenu={'mask_inside';'mask_outside'}; |
---|
| 4470 | create_object(data,handles) |
---|
| 4471 | |
---|
| 4472 | %------------------------------------------------------------------------ |
---|
| 4473 | function Menuplane_Callback(hObject, eventdata, handles) |
---|
| 4474 | %------------------------------------------------------------------------ |
---|
| 4475 | data.Type='plane'; |
---|
| 4476 | data.ProjMode='projection';%default |
---|
[410] | 4477 | data.ProjModeMenu={};% do not restrict ProjMode menus |
---|
[402] | 4478 | create_object(data,handles) |
---|
| 4479 | |
---|
| 4480 | %------------------------------------------------------------------------ |
---|
| 4481 | function Menuvolume_Callback(hObject, eventdata, handles) |
---|
| 4482 | %------------------------------------------------------------------------ |
---|
| 4483 | data.Type='volume'; |
---|
| 4484 | data.ProjMode='interp';%default |
---|
[410] | 4485 | data.ProjModeMenu={}; |
---|
[402] | 4486 | % set(handles.create,'Visible','on') |
---|
| 4487 | % set(handles.create,'Value',1) |
---|
[410] | 4488 | % VOLUME_Callback(hObject,eventdata,handles)data.ProjModeMenu={}; |
---|
[402] | 4489 | create_object(data,handles) |
---|
| 4490 | |
---|
| 4491 | %------------------------------------------------------------------------ |
---|
| 4492 | % --- generic function used for the creation of a projection object |
---|
| 4493 | function create_object(data,handles) |
---|
| 4494 | %------------------------------------------------------------------------ |
---|
[410] | 4495 | % desactivate geometric calibration if opened |
---|
[402] | 4496 | hgeometry_calib=findobj(allchild(0),'tag','geometry_calib'); |
---|
| 4497 | if ishandle(hgeometry_calib) |
---|
| 4498 | hhgeometry_calib=guidata(hgeometry_calib); |
---|
| 4499 | set(hhgeometry_calib.edit_append,'Value',0)% desactivate mouse action in geometry_calib |
---|
| 4500 | set(hhgeometry_calib.edit_append,'BackgroundColor',[0.7 0.7 0.7]) |
---|
| 4501 | end |
---|
| 4502 | set(handles.edit_object,'Value',0); %suppress the object edit mode |
---|
| 4503 | set(handles.edit_object,'BackgroundColor',[0.7,0.7,0.7]) |
---|
[429] | 4504 | ListObject=get(handles.ListObject,'String'); |
---|
| 4505 | if ~strcmp(ListObject{end},'') |
---|
| 4506 | ListObject=[ListObject;{''}]; %append a blank to the list (if nort already done) to indicate the creation of a new object |
---|
| 4507 | set(handles.ListObject,'String',ListObject) |
---|
| 4508 | end |
---|
| 4509 | IndexObj=length(ListObject); |
---|
| 4510 | set(handles.ListObject,'Value',IndexObj) |
---|
[410] | 4511 | UvData=get(handles.uvmat,'UserData'); |
---|
[429] | 4512 | UvData.Object{IndexObj}=[]; %create a new empty object |
---|
[432] | 4513 | UvData.Object{IndexObj}.DisplayHandle.uvmat=handles.axes3; % axes for plot_object |
---|
| 4514 | UvData.Object{IndexObj}.DisplayHandle.view_field=[]; %no plot handle before plot_field operation |
---|
[410] | 4515 | data.Name=data.Type;% default name=type |
---|
[402] | 4516 | data.Coord=[0 0]; %default |
---|
| 4517 | if isfield(UvData,'Field') |
---|
| 4518 | Field=UvData.Field; |
---|
[404] | 4519 | if isfield(UvData.Field,'Mesh')&&~isempty(UvData.Field.Mesh) |
---|
| 4520 | data.RangeX=[UvData.Field.XMin UvData.Field.XMax]; |
---|
[410] | 4521 | if strcmp(data.Type,'line')||strcmp(data.Type,'polyline')||strcmp(data.Type,'points') |
---|
[406] | 4522 | data.RangeY=UvData.Field.Mesh; |
---|
| 4523 | else |
---|
| 4524 | data.RangeY=[UvData.Field.YMin UvData.Field.YMax]; |
---|
| 4525 | end |
---|
[404] | 4526 | data.DX=UvData.Field.Mesh; |
---|
| 4527 | data.DY=UvData.Field.Mesh; |
---|
[402] | 4528 | end |
---|
| 4529 | if isfield(Field,'NbDim')&& isequal(Field.NbDim,3) |
---|
| 4530 | data.Coord=[0 0 0]; %default |
---|
| 4531 | end |
---|
| 4532 | if isfield(Field,'CoordUnit') |
---|
| 4533 | data.CoordUnit=Field.CoordUnit; |
---|
| 4534 | end |
---|
| 4535 | end |
---|
| 4536 | if ishandle(handles.UVMAT_title) |
---|
| 4537 | delete(handles.UVMAT_title)%delete the initial display of uvmat if no field has been entered |
---|
| 4538 | end |
---|
| 4539 | hset_object=set_object(data,handles);% call the set_object interface |
---|
| 4540 | hhset_object=guidata(hset_object); |
---|
[421] | 4541 | hchild=get(hset_object,'children'); |
---|
| 4542 | set(hchild,'enable','on') |
---|
[402] | 4543 | set(handles.uvmat,'UserData',UvData) |
---|
[410] | 4544 | set(handles.CheckZoom,'Value',0) %desactivate the zoom for object creation by the mouse |
---|
[402] | 4545 | CheckZoom_Callback(handles.uvmat, [], handles) |
---|
| 4546 | set(handles.delete_object,'Visible','on') |
---|
| 4547 | |
---|
| 4548 | %------------------------------------------------------------------------ |
---|
| 4549 | function MenuBrowseObject_Callback(hObject, eventdata, handles) |
---|
| 4550 | %------------------------------------------------------------------------ |
---|
| 4551 | %get the object file |
---|
| 4552 | [FileName, PathName, filterindex] = uigetfile( ... |
---|
| 4553 | {'*.xml;*.mat', ' (*.xml,*.mat)'; |
---|
| 4554 | '*.xml', '.xml files '; ... |
---|
| 4555 | '*.mat', '.mat matlab files '}, ... |
---|
| 4556 | 'Pick an xml Object file',get(handles.RootPath,'String')); |
---|
| 4557 | fileinput=[PathName FileName];%complete file name |
---|
| 4558 | sizf=size(fileinput); |
---|
| 4559 | if (~ischar(fileinput)||~isequal(sizf(1),1)),return;end |
---|
| 4560 | |
---|
| 4561 | %read the file |
---|
| 4562 | data=xml2struct(fileinput); |
---|
[429] | 4563 | |
---|
[427] | 4564 | [tild,data.Name]=fileparts(FileName);% object name set as file name |
---|
[429] | 4565 | ListObject=get(handles.ListObject,'String'); |
---|
| 4566 | if ~strcmp(ListObject{end},'') |
---|
| 4567 | ListObject=[ListObject;{''}]; %append a blank to the list (if not already done) to indicate the creation of a new object |
---|
| 4568 | set(handles.ListObject,'String',ListObject) |
---|
| 4569 | end |
---|
[432] | 4570 | UvData=get(handles.uvmat,'UserData'); |
---|
| 4571 | UvData.Object{IndexObj}=[]; %create a new empty object |
---|
| 4572 | UvData.Object{IndexObj}.DisplayHandle.uvmat=[]; %no plot handle before plot_field operation |
---|
| 4573 | UvData.Object{IndexObj}.DisplayHandle.view_field=[]; %no plot handle before plot_field operation |
---|
| 4574 | set(handles.uvmat,'UserData',UvData) |
---|
[429] | 4575 | set(handles.ListObject,'Value',length(ListObject)) |
---|
[427] | 4576 | hset_object=set_object(data);% call the set_object interface |
---|
| 4577 | set(get(hset_object,'children'),'enable','on')% enable edit action on elements on GUI set_object |
---|
[402] | 4578 | set(handles.edit_object,'Value',0); %suppress the object edit mode |
---|
| 4579 | set(handles.edit_object,'BackgroundColor',[0.7,0.7,0.7]) |
---|
| 4580 | set(handles.delete_object,'Visible','on') |
---|
| 4581 | |
---|
[432] | 4582 | |
---|
[402] | 4583 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
---|
| 4584 | % MenuEdit Callbacks |
---|
| 4585 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
---|
| 4586 | %------------------------------------------------------------------------ |
---|
| 4587 | function MenuEditObject_Callback(hObject, eventdata, handles) |
---|
| 4588 | %------------------------------------------------------------------------ |
---|
| 4589 | set(handles.edit_object,'Value',1) |
---|
| 4590 | edit_Callback(hObject, eventdata, handles) |
---|
| 4591 | |
---|
| 4592 | % %------------------------------------------------------------------------ |
---|
| 4593 | % function enable_transform(handles,state) |
---|
| 4594 | % %------------------------------------------------------------------------ |
---|
| 4595 | % set(handles.transform_fct,'Visible',state) |
---|
| 4596 | % set(handles.TRANSFORM_txt,'Visible',state) |
---|
| 4597 | % set(handles.transform_fct,'Visible',state) |
---|
| 4598 | % set(handles.path_transform,'Visible',state) |
---|
| 4599 | % set(handles.pxcmx_txt,'Visible',state) |
---|
| 4600 | % set(handles.pxcmy_txt,'Visible',state) |
---|
| 4601 | % set(handles.pxcm,'Visible',state) |
---|
| 4602 | % set(handles.pycm,'Visible',state) |
---|
| 4603 | |
---|
| 4604 | %------------------------------------------------------------------------ |
---|
| 4605 | function MenuEditVectors_Callback(hObject, eventdata, handles) |
---|
| 4606 | %------------------------------------------------------------------------ |
---|
| 4607 | set(handles.edit_vect,'Visible','on') |
---|
| 4608 | set(handles.edit_vect,'Value',1) |
---|
| 4609 | edit_vect_Callback(hObject, eventdata, handles) |
---|
| 4610 | |
---|
| 4611 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
---|
| 4612 | % MenuTools Callbacks |
---|
| 4613 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
---|
| 4614 | %------------------------------------------------------------------------ |
---|
[387] | 4615 | function MenuCalib_Callback(hObject, eventdata, handles) |
---|
| 4616 | %------------------------------------------------------------------------ |
---|
| 4617 | |
---|
| 4618 | UvData=get(handles.uvmat,'UserData');%read UvData properties stored on the uvmat interface |
---|
| 4619 | |
---|
| 4620 | %suppress competing options |
---|
| 4621 | set(handles.CheckZoom,'Value',0) |
---|
| 4622 | set(handles.CheckZoom,'BackgroundColor',[0.7 0.7 0.7]) |
---|
| 4623 | set(handles.ListObject,'Value',1) |
---|
| 4624 | % initiate display of GUI geometry_calib |
---|
| 4625 | data=[]; %default |
---|
| 4626 | if isfield(UvData,'CoordType') |
---|
| 4627 | data.CoordType=UvData.CoordType; |
---|
| 4628 | end |
---|
| 4629 | pos=get(handles.uvmat,'Position'); |
---|
| 4630 | pos(1)=pos(1)+pos(3)-0.311+0.04; %0.311= width of the geometry_calib interface (units relative to the srcreen) |
---|
| 4631 | pos(2)=pos(2)-0.02; |
---|
| 4632 | [RootPath,SubDir,RootFile,FileIndices,FileExt]=read_file_boxes(handles); |
---|
| 4633 | FileName=[fullfile(RootPath,SubDir,RootFile) FileIndices FileExt]; |
---|
| 4634 | set(handles.view_xml,'Backgroundcolor',[1 1 0])%indicate the reading of the current xml file by geometry_calib |
---|
| 4635 | if isfield(UvData.OpenParam,'CalOrigin') |
---|
| 4636 | pos_uvmat=get(handles.uvmat,'Position'); |
---|
| 4637 | pos_cal(1)=pos_uvmat(1)+UvData.OpenParam.CalOrigin(1)*pos_uvmat(3); |
---|
| 4638 | pos_cal(2)=pos_uvmat(2)+UvData.OpenParam.CalOrigin(2)*pos_uvmat(4); |
---|
| 4639 | pos_cal(3:4)=UvData.OpenParam.CalSize .* pos_uvmat(3:4); |
---|
| 4640 | end |
---|
| 4641 | geometry_calib(FileName,pos_cal);% call the geometry_calib interface |
---|
| 4642 | set(handles.view_xml,'Backgroundcolor',[1 1 1])%indicate the end of reading of the current xml file by geometry_calib |
---|
| 4643 | set(handles.MenuCalib,'checked','on')% indicate that MenuCalib is activated, test used by mouse action |
---|
| 4644 | |
---|
| 4645 | %------------------------------------------------------------------------ |
---|
| 4646 | function MenuMask_Callback(hObject, eventdata, handles) |
---|
| 4647 | %------------------------------------------------------------------------ |
---|
| 4648 | UvData=get(handles.uvmat,'UserData');%read UvData properties stored on the uvmat interface |
---|
| 4649 | ListObj=UvData.Object; |
---|
| 4650 | select=zeros(1,numel(ListObj)); |
---|
| 4651 | for iobj=1:numel(ListObj); |
---|
| 4652 | if strcmp(ListObj{iobj}.ProjMode,'mask_inside')||strcmp(ListObj{iobj}.ProjMode,'mask_outside') |
---|
| 4653 | select(iobj)=1; |
---|
| 4654 | end |
---|
| 4655 | end |
---|
| 4656 | val=find(select); |
---|
| 4657 | if isempty(val) |
---|
| 4658 | msgbox_uvmat('ERROR','polygons must be first created by Projection object/mask polygon in the menu bar'); |
---|
| 4659 | return |
---|
| 4660 | else |
---|
[410] | 4661 | % set(handles.ListObject,'Max',2);%allow multiple selection |
---|
[387] | 4662 | set(handles.ListObject,'Value',val); |
---|
| 4663 | flag=1; |
---|
| 4664 | npx=size(UvData.Field.A,2); |
---|
| 4665 | npy=size(UvData.Field.A,1); |
---|
| 4666 | xi=0.5:npx-0.5; |
---|
| 4667 | yi=0.5:npy-0.5; |
---|
| 4668 | [Xi,Yi]=meshgrid(xi,yi); |
---|
| 4669 | if isfield(UvData,'Object') |
---|
| 4670 | for iobj=1:length(UvData.Object) |
---|
| 4671 | ObjectData=UvData.Object{iobj}; |
---|
| 4672 | if isfield(ObjectData,'ProjMode') &&(isequal(ObjectData.ProjMode,'mask_inside')||isequal(ObjectData.ProjMode,'mask_outside')); |
---|
| 4673 | flagobj=1; |
---|
| 4674 | testphys=0; %coordinates in pixels by default |
---|
| 4675 | if isfield(ObjectData,'CoordUnit') && ~isequal(ObjectData.CoordUnit,'pixel') |
---|
| 4676 | if isfield(UvData,'XmlData')&& isfield(UvData.XmlData{1},'GeometryCalib') |
---|
| 4677 | Calib=UvData.XmlData{1}.GeometryCalib; |
---|
| 4678 | testphys=1; |
---|
| 4679 | end |
---|
| 4680 | end |
---|
| 4681 | if isfield(ObjectData,'Coord')&& isfield(ObjectData,'Type') |
---|
| 4682 | if isequal(ObjectData.Type,'polygon') |
---|
| 4683 | X=ObjectData.Coord(:,1); |
---|
| 4684 | Y=ObjectData.Coord(:,2); |
---|
| 4685 | if testphys |
---|
| 4686 | [X,Y]=px_XYZ(Calib,X,Y,0);% to generalise with 3D cases |
---|
| 4687 | end |
---|
| 4688 | flagobj=~inpolygon(Xi,Yi,X',Y');%=0 inside the polygon, 1 outside |
---|
| 4689 | elseif isequal(ObjectData.Type,'ellipse') |
---|
| 4690 | if testphys |
---|
| 4691 | %[X,Y]=px_XYZ(Calib,X,Y,0);% TODO:create a polygon boundary and transform to phys |
---|
| 4692 | end |
---|
| 4693 | RangeX=max(ObjectData.RangeX); |
---|
| 4694 | RangeY=max(ObjectData.RangeY); |
---|
| 4695 | X2Max=RangeX*RangeX; |
---|
| 4696 | Y2Max=RangeY*RangeY; |
---|
| 4697 | distX=(Xi-ObjectData.Coord(1,1)); |
---|
| 4698 | distY=(Yi-ObjectData.Coord(1,2)); |
---|
| 4699 | flagobj=(distX.*distX/X2Max+distY.*distY/Y2Max)>1; |
---|
| 4700 | elseif isequal(ObjectData.Type,'rectangle') |
---|
| 4701 | if testphys |
---|
| 4702 | %[X,Y]=px_XYZ(Calib,X,Y,0);% TODO:create a polygon boundary and transform to phys |
---|
| 4703 | end |
---|
| 4704 | distX=abs(Xi-ObjectData.Coord(1,1)); |
---|
| 4705 | distY=abs(Yi-ObjectData.Coord(1,2)); |
---|
| 4706 | flagobj=distX>max(ObjectData.RangeX) | distY>max(ObjectData.RangeY); |
---|
| 4707 | end |
---|
| 4708 | if isequal(ObjectData.ProjMode,'mask_outside') |
---|
| 4709 | flagobj=~flagobj; |
---|
| 4710 | end |
---|
| 4711 | flag=flag & flagobj; |
---|
| 4712 | end |
---|
| 4713 | end |
---|
| 4714 | end |
---|
| 4715 | end |
---|
| 4716 | %mask name |
---|
| 4717 | RootPath=get(handles.RootPath,'String'); |
---|
| 4718 | RootFile=get(handles.RootFile,'String'); |
---|
| 4719 | if ~isempty(RootFile)&&(isequal(RootFile(1),'/')|| isequal(RootFile(1),'\')) |
---|
| 4720 | RootFile(1)=[]; |
---|
| 4721 | end |
---|
| 4722 | filebase=fullfile(RootPath,RootFile); |
---|
| 4723 | list=get(handles.masklevel,'String'); |
---|
| 4724 | masknumber=num2str(length(list)); |
---|
| 4725 | maskindex=get(handles.masklevel,'Value'); |
---|
| 4726 | mask_name=fullfile_uvmat(RootPath,'',[RootFile '_' masknumber 'mask'],'.png','_1',maskindex); |
---|
| 4727 | %mask_name=name_generator([filebase '_' masknumber 'mask'],maskindex,1,'.png','_i'); |
---|
| 4728 | imflag=uint8(255*(0.392+0.608*flag));% =100 for flag=0 (vectors not computed when 20<imflag<200) |
---|
| 4729 | imflag=flipdim(imflag,1); |
---|
| 4730 | |
---|
| 4731 | %display the mask |
---|
| 4732 | hfigmask=figure; |
---|
| 4733 | set(hfigmask,'Name','mask image') |
---|
| 4734 | vec=linspace(0,1,256);%define a linear greyscale colormap |
---|
| 4735 | map=[vec' vec' vec']; |
---|
| 4736 | colormap(map) |
---|
| 4737 | image(imflag); |
---|
| 4738 | answer=msgbox_uvmat('INPUT_TXT','mask file name:', mask_name); |
---|
| 4739 | if ~strcmp(answer,'Cancel') |
---|
| 4740 | mask_dir=fileparts(answer); |
---|
| 4741 | if ~exist(mask_dir,'dir') |
---|
| 4742 | msgbox_uvmat('ERROR',['directory ' mask_dir ' does not exist']) |
---|
| 4743 | return |
---|
| 4744 | end |
---|
| 4745 | imwrite(imflag,answer,'BitDepth',8); |
---|
| 4746 | end |
---|
| 4747 | set(handles.ListObject,'Value',1) |
---|
| 4748 | % set(handles.ListObject,'Max',1) |
---|
| 4749 | end |
---|
| 4750 | |
---|
| 4751 | %------------------------------------------------------------------------ |
---|
| 4752 | %-- open the GUI set_grid.fig to create grid |
---|
| 4753 | function MenuGrid_Callback(hObject, eventdata, handles) |
---|
| 4754 | %------------------------------------------------------------------------ |
---|
| 4755 | %suppress the other options if grid is chosen |
---|
| 4756 | set(handles.edit_vect,'Value',0) |
---|
| 4757 | edit_vect_Callback(hObject, eventdata, handles) |
---|
| 4758 | set(handles.edit_object,'BackgroundColor',[0.7 0.7 0.7]) |
---|
| 4759 | set(handles.ListObject,'Value',1) |
---|
| 4760 | |
---|
| 4761 | %prepare display of the set_grid GUI |
---|
| 4762 | [RootPath,SubDir,RootFile,FileIndices,FileExt]=read_file_boxes(handles); |
---|
| 4763 | FileName=[fullfile(RootPath,SubDir,RootFile) FileIndices FileExt]; |
---|
| 4764 | CoordList=get(handles.transform_fct,'String'); |
---|
| 4765 | val=get(handles.transform_fct,'Value'); |
---|
| 4766 | set_grid(FileName,CoordList{val});% call the set_object interface |
---|
| 4767 | |
---|
[402] | 4768 | |
---|
[387] | 4769 | %------------------------------------------------------------------------ |
---|
[402] | 4770 | function MenuRuler_Callback(hObject, eventdata, handles) |
---|
| 4771 | %------------------------------------------------------------------------ |
---|
| 4772 | set(handles.CheckZoom,'Value',0) |
---|
| 4773 | CheckZoom_Callback(handles.uvmat, [], handles) |
---|
| 4774 | set(handles.MenuRuler,'checked','on') |
---|
| 4775 | UvData=get(handles.uvmat,'UserData'); |
---|
| 4776 | UvData.MouseAction='ruler'; |
---|
| 4777 | set(handles.uvmat,'UserData',UvData); |
---|
| 4778 | |
---|