[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 | % |
---|
| 81 | % fields are opened and visualised by the sub-function refresh_field.m |
---|
| 82 | % (called by uvmat_opening, RUN0, runp and runm) |
---|
| 83 | % The function first reads the name of the input file from the edit boxes of the GUI |
---|
| 84 | % A second input file can be introduced for filed comparison |
---|
| 85 | % It then reads the input file(s) with the appropriate function, read for |
---|
| 86 | % images, read_civxdata.m for CIVx PIV data, nc2struct for other netcdf |
---|
| 87 | % files. |
---|
| 88 | % Main input open second input open(_1) second image (pair animation) |
---|
| 89 | % | | |
---|
| 90 | % | | |
---|
| 91 | % Field{1} Field{2} |
---|
| 92 | % | |
---|
| 93 | % coord transform (phys.m) or other user defined fct acting on Field{i} | |
---|
| 94 | % Field{i} |
---|
| 95 | % | |
---|
| 96 | % calc_field.m: calculate scalar or other derived fields (vort, div..). |
---|
| 97 | % |
---|
| 98 | % sub_field.m: combine the input Field{i} in a single set of fields (vector + scalar): |
---|
| 99 | % Field{i=1->3}.X --> UvData.X | |
---|
| 100 | % | |
---|
| 101 | % UvData |
---|
| 102 | % | |
---|
| 103 | % plot histograms of the whole field |
---|
| 104 | % proj_field.m: project the set of fields on the current projection objects defined by UvData.Object |
---|
| 105 | % | | |
---|
| 106 | % ObjectData |
---|
| 107 | % | |
---|
| 108 | % plot_field.m: plot the projected fields and store them as | |
---|
| 109 | % UvData.axes3 | |
---|
| 110 | % | |
---|
| 111 | % AxeData |
---|
| 112 | % |
---|
| 113 | %%%%%%%%%%%%%% SCALARS: %%%%%%%%%%%%??%%% |
---|
| 114 | % scalars are displayed either as an image or countour plot, either as a color of |
---|
| 115 | % velocity vectors. The scalar values in the first case is represented by |
---|
| 116 | % UvData.Field.A, and by UvData.Field.C in the second case. The corresponding set of X |
---|
| 117 | % and Y coordinates are represented by UvData.Field.AX and UvData.Field.AY, and .X and |
---|
| 118 | % .Y for C (the same as velocity vectors). If A is a nxxny matrix (scalar |
---|
| 119 | % on a regtular grid), then .AX andf.AY contains only two elements, represneting the |
---|
| 120 | % coordinates of the four image corners. The scalar name is represented by |
---|
| 121 | % the strings .AName and/or .CName. |
---|
| 122 | % If the scalar exists in an input open (image or scalar stored under its |
---|
| 123 | % name in a netcdf open), it is directly read at the level of Field{1}or Field{2}. |
---|
| 124 | % Else only its name AName is recorded in Field{i}, and its field is then calculated |
---|
| 125 | %by the fuction calc_scal after the coordinate transform or after projection on an edit_object |
---|
| 126 | |
---|
| 127 | % Properties attached to plotting figures (standard Matlab properties): |
---|
| 128 | % 'CurrentAxes'= gca or get(gcf,'CurrentAxes'); |
---|
| 129 | % 'CurrentPoint'=get(gcf,'CurrentPoint'): figure coordinates of the point over which the mouse is positioned |
---|
| 130 | % 'CurrentCharacter'=get(gcf,'CurrentCharacter'): last character typed over the figure where the mouse is positioned |
---|
| 131 | % 'WindowButtonMotionFcn': function permanently called by mouse motion over the figure |
---|
| 132 | % 'KeyPressFcn': function called by pressing a key on the key board |
---|
| 133 | % 'WindowButtonDownFcn': function called by pressing the mouse over the figure |
---|
| 134 | % 'WindowButtonUpFcn': function called by releasing the mouse pressure over the figure |
---|
| 135 | |
---|
| 136 | % Properties attached to plotting axes: |
---|
| 137 | % 'CurrentPoint'=get(gca,'CurrentPoint'); (standard Matlab) same as for the figure, but position in plot coordinates. |
---|
| 138 | % AxeData:=get(gca,'UserData'); |
---|
| 139 | % AxeData.Drawing = create: create a new object |
---|
| 140 | % = deform: modify an existing object by moving its defining create |
---|
| 141 | % = off: no current drawing action |
---|
| 142 | % = translate: translate an existing object |
---|
| 143 | % = calibration: move a calibration point |
---|
| 144 | % = CheckZoom: isolate a subregion for CheckZoom in=1 if an object is being currently drawn, 0 else (set to 0 by releasing mouse button) |
---|
| 145 | % .CurrentOrigin: Origin of a curently drawn edit_object |
---|
| 146 | % .CurrentLine: currently drawn menuline (A REVOIR) |
---|
| 147 | % .CurrentObject: handle of the currently drawn edit_object |
---|
| 148 | % .CurrentRectZoom: current rectangle used for CheckZoom |
---|
| 149 | |
---|
| 150 | % Properties attached to projection objects (create, menuline, menuplane...): |
---|
| 151 | % 'Tag'='proj_object': for all projection objects |
---|
| 152 | % ObjectData.Type=...: style of projection object: |
---|
| 153 | % .ProjMode |
---|
| 154 | % .Coord: defines the position of the object |
---|
| 155 | % .XMin,YMin.... |
---|
| 156 | % .XMax,YMax.... |
---|
| 157 | % .DX,DY,DZ |
---|
| 158 | % .Phi, .Theta, .Psi : Euler angles |
---|
| 159 | % .X,.Y,.U,.V.... : field data projected on the object |
---|
| 160 | % .IndexObj: index in the list of UvData.Object |
---|
| 161 | %during plotting |
---|
| 162 | % .plotaxes: handles of the current axes used to plot the result of field projection on the object |
---|
| 163 | % .plothandle: vector of handle(s) of the object graphic represnetation in all the opened plotting axes |
---|
| 164 | % To each projection object #iobj, corresponds an axis |
---|
| 165 | % Object{iobj}.plotaxes and nbobj representation graphs Object{iobj}.plothandles(:) (where nbobj is the |
---|
| 166 | % nbre of current objects opened in uvmat. Note that Object{iobj}.plothandles(iobj)=[] : an object is not represented in its own projection field; |
---|
| 167 | |
---|
| 168 | %------------------------------------------------------------------------ |
---|
| 169 | %------------------------------------------------------------------------ |
---|
[402] | 170 | % I - MAIN FUNCTION UVMAT |
---|
[387] | 171 | %------------------------------------------------------------------------ |
---|
| 172 | %------------------------------------------------------------------------ |
---|
| 173 | function varargout = uvmat(varargin) |
---|
| 174 | |
---|
| 175 | % Begin initialization code - DO NOT EDIT |
---|
| 176 | gui_Singleton = 1; |
---|
| 177 | gui_State = struct('gui_Name', mfilename, ... |
---|
| 178 | 'gui_Singleton', gui_Singleton, ... |
---|
| 179 | 'gui_OpeningFcn', @uvmat_OpeningFcn, ... |
---|
| 180 | 'gui_OutputFcn', @uvmat_OutputFcn, ... |
---|
| 181 | 'gui_LayoutFcn', [], ... |
---|
| 182 | 'gui_Callback', []); |
---|
| 183 | if nargin && ischar(varargin{1})&& ~isempty(regexp(varargin{1},'_Callback','once')) |
---|
| 184 | gui_State.gui_Callback = str2func(varargin{1}); |
---|
| 185 | end |
---|
| 186 | |
---|
| 187 | if nargout |
---|
| 188 | varargout{1:nargout} = gui_mainfcn(gui_State, varargin{:}); |
---|
| 189 | else |
---|
| 190 | gui_mainfcn(gui_State, varargin{:}); |
---|
| 191 | end |
---|
| 192 | % End initialization code - DO NOT EDIT |
---|
| 193 | |
---|
| 194 | %------------------------------------------------------------------------ |
---|
| 195 | % --- Executes just before the GUI uvmat is made visible. |
---|
| 196 | function uvmat_OpeningFcn(hObject, eventdata, handles, input ) |
---|
| 197 | %------------------------------------------------------------------------ |
---|
| 198 | |
---|
| 199 | %% Choose default command menuline output for uvmat (standard GUI) |
---|
| 200 | handles.output = hObject; |
---|
| 201 | |
---|
| 202 | %% Update handles structure (standard GUI) |
---|
| 203 | guidata(hObject, handles); |
---|
| 204 | |
---|
| 205 | %% check the path and date of modification of all functions in uvmat |
---|
| 206 | path_to_uvmat=which ('uvmat');% check the path detected for source file uvmat |
---|
| 207 | [errormsg,date_str,svn_info]=check_files;%check the path of the functions called by uvmat.m |
---|
| 208 | date_str=['last modification: ' date_str]; |
---|
| 209 | |
---|
| 210 | |
---|
| 211 | %% set the position of colorbar and ancillary GUIs: |
---|
| 212 | set(hObject,'Units','Normalized') |
---|
| 213 | movegui(hObject,'center') |
---|
| 214 | UvData.OpenParam.PosColorbar=[0.805 0.022 0.019 0.445]; |
---|
| 215 | UvData.OpenParam.SetObjectOrigin=[-0.05 -0.03]; %position for set_object |
---|
| 216 | UvData.OpenParam.SetObjectSize=[0.3 0.7]; |
---|
| 217 | UvData.OpenParam.CalOrigin=[0.95 -0.03];%position for geometry_calib (TO IMPROVE) |
---|
| 218 | UvData.OpenParam.CalSize=[0.28 1]; |
---|
| 219 | UvData.axes3=[];%initiate the record of plotted field |
---|
| 220 | UvData.axes2=[]; |
---|
| 221 | UvData.axes1=[]; |
---|
| 222 | AxeData.LimEditBox=1; %initialise AxeData |
---|
| 223 | set(handles.axes3,'UserData',AxeData) |
---|
| 224 | |
---|
| 225 | %% set functions for the mouse and keyboard |
---|
| 226 | set(handles.histo_u,'NextPlot','replacechildren'); |
---|
| 227 | set(handles.histo_v,'NextPlot','replacechildren'); |
---|
| 228 | set(hObject,'KeyPressFcn',{'keyboard_callback',handles})%set keyboard action function |
---|
| 229 | set(hObject,'WindowButtonMotionFcn',{'mouse_motion',handles})%set mouse action functio |
---|
| 230 | set(hObject,'WindowButtonDownFcn',{'mouse_down'})%set mouse click action function |
---|
| 231 | set(hObject,'WindowButtonUpFcn',{'mouse_up',handles}) |
---|
| 232 | set(hObject,'DeleteFcn',{@closefcn})% |
---|
| 233 | |
---|
| 234 | %% refresh projection plane |
---|
| 235 | UvData.Object{1}.ProjMode='projection';%main plotting plane |
---|
[402] | 236 | set(handles.ListObject,'Value',1)% default: empty projection object |
---|
| 237 | set(handles.ListObject,'String',{''}) |
---|
[387] | 238 | set(handles.Fields,'Value',1) |
---|
| 239 | set(handles.Fields,'string',{''}) |
---|
| 240 | |
---|
| 241 | %% TRANSFORM menu: builtin fcts |
---|
| 242 | menu_str={'';'phys';'px';'phys_polar'}; |
---|
| 243 | UvData.OpenParam.NbBuiltin=numel(menu_str); %number of functions |
---|
| 244 | path_uvmat=fileparts(which('uvmat')); |
---|
| 245 | 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) |
---|
| 246 | addpath(fullfile(path_uvmat,'transform_field'))%add the path to transform functions, |
---|
| 247 | fct_handle{1,1}=[]; |
---|
| 248 | testexist=zeros(size(menu_str'));%default |
---|
| 249 | testexist(1)=1; |
---|
| 250 | for ilist=2:length(menu_str) |
---|
| 251 | if exist(menu_str{ilist},'file') |
---|
| 252 | fct_handle{ilist,1}=str2func(menu_str{ilist}); |
---|
| 253 | testexist(ilist)=1; |
---|
| 254 | else |
---|
| 255 | testexist(ilist)=0; |
---|
| 256 | end |
---|
| 257 | end |
---|
| 258 | rmpath(fullfile(path_uvmat,'transform_field')) |
---|
| 259 | |
---|
| 260 | %% load the list of previously browsed files in menus Open and Open_1 |
---|
| 261 | dir_perso=prefdir; % path to the directory .matlab for personal data |
---|
| 262 | profil_perso=fullfile(dir_perso,'uvmat_perso.mat');% personal data file uvmauvmat_perso.mat' in .matlab |
---|
| 263 | if exist(profil_perso,'file') |
---|
| 264 | h=load (profil_perso); |
---|
| 265 | if isfield(h,'MenuFile') |
---|
| 266 | for ifile=1:min(length(h.MenuFile),5) |
---|
| 267 | eval(['set(handles.MenuFile_' num2str(ifile) ',''Label'',h.MenuFile{ifile});']) |
---|
| 268 | eval(['set(handles.MenuFile_' num2str(ifile) '_1,''Label'',h.MenuFile{ifile});']) |
---|
| 269 | end |
---|
| 270 | end |
---|
| 271 | if isfield(h,'transform_fct') && iscell(h.transform_fct) |
---|
| 272 | for ilist=1:length(h.transform_fct); |
---|
| 273 | if exist(h.transform_fct{ilist},'file') |
---|
| 274 | [path,file]=fileparts(h.transform_fct{ilist}); |
---|
| 275 | addpath(path) |
---|
| 276 | h_func=str2func(file); |
---|
| 277 | rmpath(path) |
---|
| 278 | testexist=[testexist 1]; |
---|
| 279 | else |
---|
| 280 | file=''; |
---|
| 281 | h_func=[]; |
---|
| 282 | testexist=[testexist 0]; |
---|
| 283 | end |
---|
| 284 | fct_handle=[fct_handle; {h_func}]; %concatene the list of paths |
---|
| 285 | menu_str=[menu_str; {file}]; |
---|
| 286 | end |
---|
| 287 | end |
---|
| 288 | end |
---|
| 289 | menu_str=menu_str(testexist==1);%=menu_str(testexist~=0) |
---|
| 290 | fct_handle=fct_handle(testexist==1); |
---|
| 291 | menu_str=[menu_str;{'more...'}]; |
---|
| 292 | set(handles.transform_fct,'String',menu_str) |
---|
| 293 | set(handles.transform_fct,'UserData',fct_handle)% store the list of path in UserData of ACTION |
---|
| 294 | |
---|
| 295 | %% case of an input argument for uvmat |
---|
| 296 | testinputfield=0; |
---|
| 297 | inputfile=[]; |
---|
| 298 | Field=[]; |
---|
| 299 | if exist('input','var') |
---|
| 300 | % if ~isempty(errormsg) |
---|
| 301 | % msgbox_uvmat('WARNING',errormsg) |
---|
| 302 | % end |
---|
| 303 | if ishandle(handles.UVMAT_title) |
---|
| 304 | delete(handles.UVMAT_title) |
---|
| 305 | end |
---|
| 306 | if isstruct(input) |
---|
| 307 | if isfield(input,'InputFile') |
---|
| 308 | inputfile=input.InputFile; |
---|
| 309 | end |
---|
| 310 | if isfield(input,'TimeIndex') |
---|
| 311 | set(handles.i1,num2str(input.TimeIndex)) |
---|
| 312 | end |
---|
| 313 | if isfield(input,'FieldsString') |
---|
| 314 | UvData.FieldsString=input.FieldsString; |
---|
| 315 | end |
---|
| 316 | elseif ischar(input)% file name introduced as input |
---|
| 317 | inputfile=input; |
---|
| 318 | elseif isnumeric(input)%simple matrix introduced as input |
---|
| 319 | sizinput=size(input); |
---|
| 320 | if sizinput(1)<=1 || sizinput(2)<=1 |
---|
| 321 | msgbox_uvmat('ERROR','bad input for uvmat: file name, structure or numerical matrix accepted') |
---|
| 322 | return |
---|
| 323 | end |
---|
| 324 | UvData.Field.ListVarName={'A','coord_y','coord_x'}; |
---|
| 325 | UvData.Field.VarDimName={{'coord_y','coord_x'},'cord_y','coord_x'}; |
---|
| 326 | UvData.Field.A=input; |
---|
| 327 | UvData.Field.coord_x=[0.5 size(input,2)-0.5]; |
---|
| 328 | UvData.Field.coord_y=[size(input,1)-0.5 0.5]; |
---|
| 329 | testinputfield=1; |
---|
| 330 | end |
---|
| 331 | else |
---|
| 332 | if ishandle(handles.UVMAT_title) |
---|
| 333 | set(handles.UVMAT_title,'String',... |
---|
| 334 | [{'Copyright LEGI UMR 5519 /CNRS-UJF-Grenoble INP, 2010'};... |
---|
| 335 | {'GNU General Public License'};... |
---|
| 336 | {path_to_uvmat};... |
---|
| 337 | {date_str};... |
---|
| 338 | {['SVN revision : ' num2str(svn_info.cur_rev)]};... |
---|
| 339 | errormsg]); |
---|
| 340 | end |
---|
| 341 | end |
---|
| 342 | set(handles.uvmat,'UserData',UvData) |
---|
| 343 | if ~isempty(inputfile) |
---|
| 344 | %%%%% display the input field %%%%%%% |
---|
| 345 | display_file_name(hObject, eventdata, handles,inputfile) |
---|
| 346 | %%%%%%% |
---|
| 347 | testinputfield=1; |
---|
| 348 | end |
---|
| 349 | |
---|
| 350 | %% plot input field if exists |
---|
| 351 | if testinputfield |
---|
| 352 | %delete drawn objects |
---|
| 353 | hother=findobj(handles.axes3,'Tag','proj_object');%find all the proj objects |
---|
| 354 | for iobj=1:length(hother) |
---|
| 355 | delete_object(hother(iobj)) |
---|
| 356 | end |
---|
| 357 | if isempty(inputfile) |
---|
| 358 | errormsg=refresh_field(handles,[],[],[],[],[],[],{Field}); |
---|
| 359 | set(handles.MenuTools,'Enable','on') |
---|
| 360 | set(handles.OBJECT_txt,'Visible','on') |
---|
| 361 | set(handles.edit_object,'Visible','on') |
---|
| 362 | set(handles.ListObject,'Visible','on') |
---|
| 363 | set(handles.frame_object,'Visible','on') |
---|
| 364 | if ~isempty(errormsg) |
---|
| 365 | msgbox_uvmat('ERROR',errormsg) |
---|
| 366 | end |
---|
| 367 | end |
---|
| 368 | end |
---|
| 369 | |
---|
| 370 | set_vec_col_bar(handles) %update the display of color code for vectors |
---|
| 371 | |
---|
| 372 | %------------------------------------------------------------------------ |
---|
| 373 | % --- Outputs from this function are returned to the command menuline. |
---|
| 374 | function varargout = uvmat_OutputFcn(hObject, eventdata, handles) |
---|
| 375 | varargout{1} = handles.output;% the only output argument is the handle to the GUI figure |
---|
| 376 | |
---|
| 377 | %------------------------------------------------------------------------ |
---|
[402] | 378 | % --- executed when closing uvmat: delete or desactivate the associated figures if exist |
---|
| 379 | function closefcn(gcbo,eventdata) |
---|
[387] | 380 | %------------------------------------------------------------------------ |
---|
[402] | 381 | hh=findobj(allchild(0),'tag','view_field'); |
---|
| 382 | if ~isempty(hh) |
---|
| 383 | delete(hh) |
---|
| 384 | end |
---|
| 385 | hh=findobj(allchild(0),'tag','geometry_calib'); |
---|
| 386 | if ~isempty(hh) |
---|
| 387 | delete(hh) |
---|
| 388 | end |
---|
| 389 | hh=findobj(allchild(0),'tag','set_object'); |
---|
| 390 | if ~isempty(hh) |
---|
| 391 | hhh=findobj(hh,'tag','PLOT'); |
---|
| 392 | set(hhh,'enable','off') |
---|
| 393 | end |
---|
| 394 | |
---|
| 395 | %------------------------------------------------------------------------ |
---|
| 396 | %------------------------------------------------------------------------ |
---|
[387] | 397 | % II - FUNCTIONS FOR INTRODUCING THE INPUT FILES |
---|
| 398 | % automatically sets the global properties when the rootfile name is introduced |
---|
| 399 | % then activate the view-field action if selected |
---|
| 400 | % it is activated either by clicking on the RootPath window or by the |
---|
| 401 | % browser |
---|
| 402 | %------------------------------------------------------------------------ |
---|
| 403 | %------------------------------------------------------------------------ |
---|
| 404 | % --- Executes on the menu Open/Browse... |
---|
| 405 | % search the files, recognize their type according to their name and fill the rootfile input windows |
---|
| 406 | function MenuBrowse_Callback(hObject, eventdata, handles) |
---|
| 407 | [RootPath,SubDir,RootFile,FileIndices,FileExt]=read_file_boxes(handles); |
---|
| 408 | oldfile=[fullfile(RootPath,SubDir,RootFile) FileIndices FileExt]; |
---|
| 409 | % oldfile=read_file_box,es(handles); |
---|
| 410 | if isempty(oldfile)||isequal(oldfile,'') %loads the previously stored file name and set it as default in the file_input box |
---|
| 411 | dir_perso=prefdir; |
---|
| 412 | profil_perso=fullfile(dir_perso,'uvmat_perso.mat'); |
---|
| 413 | if exist(profil_perso,'file') |
---|
| 414 | h=load (profil_perso); |
---|
| 415 | if isfield(h,'MenuFile_1') |
---|
| 416 | oldfile=h.MenuFile_1; |
---|
| 417 | end |
---|
| 418 | end |
---|
| 419 | end |
---|
| 420 | [FileName, PathName] = uigetfile( ... |
---|
| 421 | {'*.xml;*.xls;*.civ;*.png;*.jpg;*.tif;*.avi;*.AVI;*.vol;*.nc;*.cmx;*.fig;*.log;*.dat;*.bat;', ' (*.xml,*.xls,*.civ,*.jpg ,*.png, .tif, *.avi,*.vol,*.nc,*.cmx,*.fig,*.log,*.dat,*.bat)'; |
---|
| 422 | '*.xml', '.xml files '; ... |
---|
| 423 | '*.xls', '.xls files '; ... |
---|
| 424 | '*.civ', '.civ files '; ... |
---|
| 425 | '*.jpg',' jpeg image files'; ... |
---|
| 426 | '*.png','.png image files'; ... |
---|
| 427 | '*.tif','.tif image files'; ... |
---|
| 428 | '*.avi;*.AVI','.avi movie files'; ... |
---|
| 429 | '*.vol','.volume images (png)'; ... |
---|
| 430 | '*.nc','.netcdf files'; ... |
---|
| 431 | '*.cdf','.netcdf files'; ... |
---|
| 432 | '*.cmx','.cmx text files ';... |
---|
| 433 | '*.fig','.fig files (matlab fig)';... |
---|
| 434 | '*.log','.log text files ';... |
---|
| 435 | '*.dat','.dat text files ';... |
---|
| 436 | '*.bat','.bat system command text files';... |
---|
| 437 | '*.*', 'All Files (*.*)'}, ... |
---|
| 438 | 'Pick a file',oldfile); |
---|
| 439 | fileinput=[PathName FileName];%complete file name |
---|
| 440 | sizf=size(fileinput); |
---|
| 441 | if (~ischar(fileinput)||~isequal(sizf(1),1)),return;end |
---|
| 442 | |
---|
| 443 | % display the selected field and related information |
---|
| 444 | display_file_name(hObject, eventdata, handles,fileinput) |
---|
| 445 | |
---|
| 446 | % ----------------------------------------------------------------------- |
---|
| 447 | % --- Open again the file whose name has been recorded in MenuFile_1 |
---|
| 448 | function MenuFile_1_Callback(hObject, eventdata, handles) |
---|
| 449 | %------------------------------------------------------------------------ |
---|
| 450 | fileinput=get(handles.MenuFile_1,'Label'); |
---|
| 451 | display_file_name(hObject, eventdata, handles,fileinput) |
---|
| 452 | |
---|
| 453 | % ----------------------------------------------------------------------- |
---|
| 454 | % --- Open again the file whose name has been recorded in MenuFile_2 |
---|
| 455 | function MenuFile_2_Callback(hObject, eventdata, handles) |
---|
| 456 | %------------------------------------------------------------------------ |
---|
| 457 | fileinput=get(handles.MenuFile_2,'Label'); |
---|
| 458 | display_file_name(hObject, eventdata, handles,fileinput) |
---|
| 459 | |
---|
| 460 | % ----------------------------------------------------------------------- |
---|
| 461 | % --- Open again the file whose name has been recorded in MenuFile_3 |
---|
| 462 | function MenuFile_3_Callback(hObject, eventdata, handles) |
---|
| 463 | %------------------------------------------------------------------------ |
---|
| 464 | fileinput=get(handles.MenuFile_3,'Label'); |
---|
| 465 | display_file_name(hObject, eventdata, handles,fileinput) |
---|
| 466 | |
---|
| 467 | % ----------------------------------------------------------------------- |
---|
| 468 | % --- Open again the file whose name has been recorded in MenuFile_4 |
---|
| 469 | function MenuFile_4_Callback(hObject, eventdata, handles) |
---|
| 470 | %------------------------------------------------------------------------ |
---|
| 471 | fileinput=get(handles.MenuFile_4,'Label'); |
---|
| 472 | display_file_name(hObject, eventdata, handles,fileinput) |
---|
| 473 | |
---|
| 474 | % ----------------------------------------------------------------------- |
---|
| 475 | % --- Open again the file whose name has been recorded in MenuFile_5 |
---|
| 476 | function MenuFile_5_Callback(hObject, eventdata, handles) |
---|
| 477 | %------------------------------------------------------------------------ |
---|
| 478 | fileinput=get(handles.MenuFile_5,'Label'); |
---|
| 479 | display_file_name(hObject, eventdata, handles,fileinput) |
---|
| 480 | |
---|
[402] | 481 | %------------------------------------------------------------------------ |
---|
| 482 | % --- Executes on the menu Open/Browse_1 for the second input field, |
---|
| 483 | % search the files, recognize their type according to their name and fill the rootfile input windows |
---|
| 484 | function MenuBrowse_1_Callback(hObject, eventdata, handles) |
---|
| 485 | %------------------------------------------------------------------------ |
---|
| 486 | % huvmat=get(handles.run0,'parent'); |
---|
| 487 | UvData=get(handles.uvmat,'UserData'); |
---|
| 488 | |
---|
| 489 | RootPath=get(handles.RootPath,'String'); |
---|
| 490 | [FileName, PathName, filterindex] = uigetfile( ... |
---|
| 491 | {'*.xml;*.xls;*.civ;*.jpg;*.png;*.avi;*.AVI;*.nc;*.cmx;*.fig;*.log;*.dat', ' (*.xml,*.xls,*.civ, *.jpg,*.png, *.avi,*.nc,*.cmx ,*.fig,*.log,*.dat)'; |
---|
| 492 | '*.xml', '.xml files '; ... |
---|
| 493 | '*.xls', '.xls files '; ... |
---|
| 494 | '*.civ', '.civ files '; ... |
---|
| 495 | '*.jpg','.jpg image files'; ... |
---|
| 496 | '*.png','.png image files'; ... |
---|
| 497 | '*.avi;*.AVI','.avi movie files'; ... |
---|
| 498 | '*.nc','.netcdf files'; ... |
---|
| 499 | '*.cdf','.netcdf files'; ... |
---|
| 500 | '*.cmx','.cmx text files';... |
---|
| 501 | '*.cmx2','.cmx2 text files';... |
---|
| 502 | '*.fig','.fig files (matlab fig)';... |
---|
| 503 | '*.log','.log text files ';... |
---|
| 504 | '*.dat','.dat text files ';... |
---|
| 505 | '*.*', 'All Files (*.*)'}, ... |
---|
| 506 | 'Pick a second file for comparison',RootPath); |
---|
| 507 | fileinput_1=[PathName FileName];%complete file name |
---|
| 508 | sizf=size(fileinput_1); |
---|
| 509 | if (~ischar(fileinput_1)||~isequal(sizf(1),1)),return;end |
---|
| 510 | |
---|
| 511 | % refresh the current displayed field |
---|
| 512 | set(handles.SubField,'Value',1) |
---|
| 513 | display_file_name(hObject,eventdata,handles,fileinput_1,2) |
---|
| 514 | |
---|
| 515 | %update list of recent files in the menubar |
---|
| 516 | MenuFile_1=fileinput_1; |
---|
| 517 | MenuFile_2=get(handles.MenuFile_1,'Label'); |
---|
| 518 | MenuFile_3=get(handles.MenuFile_2,'Label'); |
---|
| 519 | MenuFile_4=get(handles.MenuFile_3,'Label'); |
---|
| 520 | MenuFile_5=get(handles.MenuFile_4,'Label'); |
---|
| 521 | set(handles.MenuFile_1,'Label',MenuFile_1) |
---|
| 522 | set(handles.MenuFile_2,'Label',MenuFile_2) |
---|
| 523 | set(handles.MenuFile_3,'Label',MenuFile_3) |
---|
| 524 | set(handles.MenuFile_4,'Label',MenuFile_4) |
---|
| 525 | set(handles.MenuFile_5,'Label',MenuFile_5) |
---|
| 526 | set(handles.MenuFile_1_1,'Label',MenuFile_1) |
---|
| 527 | set(handles.MenuFile_2_1,'Label',MenuFile_2) |
---|
| 528 | set(handles.MenuFile_3_1,'Label',MenuFile_3) |
---|
| 529 | set(handles.MenuFile_4_1,'Label',MenuFile_4) |
---|
| 530 | set(handles.MenuFile_5_1,'Label',MenuFile_5) |
---|
| 531 | dir_perso=prefdir; |
---|
| 532 | profil_perso=fullfile(dir_perso,'uvmat_perso.mat'); |
---|
| 533 | if exist(profil_perso,'file') |
---|
| 534 | save (profil_perso,'MenuFile_1','MenuFile_2','MenuFile_3','MenuFile_4', 'MenuFile_5','-append'); %store the file names for future opening of uvmat |
---|
| 535 | else |
---|
| 536 | txt=ver('MATLAB'); |
---|
| 537 | Release=txt.Release; |
---|
| 538 | relnumb=str2double(Release(3:4)); |
---|
| 539 | if relnumb >= 14 |
---|
| 540 | save (profil_perso,'MenuFile_1','MenuFile_2','MenuFile_3','MenuFile_4', 'MenuFile_5','-V6'); %store the file names for future opening of uvmat |
---|
| 541 | else |
---|
| 542 | save (profil_perso,'MenuFile_1','MenuFile_2','MenuFile_3','MenuFile_4', 'MenuFile_5'); %store the file names for future opening of uvmat |
---|
| 543 | end |
---|
| 544 | end |
---|
| 545 | |
---|
| 546 | % ----------------------------------------------------------------------- |
---|
| 547 | % --- Open again as second field the file whose name has been recorded in MenuFile_1 |
---|
| 548 | function MenuFile_1_1_Callback(hObject, eventdata, handles) |
---|
| 549 | % ----------------------------------------------------------------------- |
---|
| 550 | fileinput_1=get(handles.MenuFile_1_1,'Label'); |
---|
| 551 | set(handles.SubField,'Value',1) |
---|
| 552 | display_file_name(hObject,eventdata,handles,fileinput_1,2) |
---|
| 553 | |
---|
| 554 | % ----------------------------------------------------------------------- |
---|
| 555 | % --- Open again as second field the file whose name has been recorded in MenuFile_2 |
---|
| 556 | function MenuFile_2_1_Callback(hObject, eventdata, handles) |
---|
| 557 | % ----------------------------------------------------------------------- |
---|
| 558 | fileinput_1=get(handles.MenuFile_2_1,'Label'); |
---|
| 559 | set(handles.SubField,'Value',1) |
---|
| 560 | display_file_name(hObject,eventdata,handles,fileinput_1,2) |
---|
| 561 | |
---|
| 562 | % ----------------------------------------------------------------------- |
---|
| 563 | % --- Open again as second field the file whose name has been recorded in MenuFile_3 |
---|
| 564 | function MenuFile_3_1_Callback(hObject, eventdata, handles) |
---|
| 565 | % ----------------------------------------------------------------------- |
---|
| 566 | fileinput_1=get(handles.MenuFile_3_1,'Label'); |
---|
| 567 | set(handles.SubField,'Value',1) |
---|
| 568 | display_file_name(hObject,eventdata,handles,fileinput_1,2) |
---|
| 569 | |
---|
| 570 | % ----------------------------------------------------------------------- |
---|
| 571 | % --- Open again as second field the file whose name has been recorded in MenuFile_4 |
---|
| 572 | function MenuFile_4_1_Callback(hObject, eventdata, handles) |
---|
| 573 | % ----------------------------------------------------------------------- |
---|
| 574 | fileinput_1=get(handles.MenuFile_4_1,'Label'); |
---|
| 575 | set(handles.SubField,'Value',1) |
---|
| 576 | display_file_name(hObject,eventdata,handles,fileinput_1,2) |
---|
| 577 | |
---|
| 578 | % ----------------------------------------------------------------------- |
---|
| 579 | % --- Open again as second field the file whose name has been recorded in MenuFile_5 |
---|
| 580 | function MenuFile_5_1_Callback(hObject, eventdata, handles) |
---|
| 581 | % ----------------------------------------------------------------------- |
---|
| 582 | fileinput_1=get(handles.MenuFile_5_1,'Label'); |
---|
| 583 | set(handles.SubField,'Value',1) |
---|
| 584 | display_file_name(hObject,eventdata,handles,fileinput_1,2) |
---|
| 585 | |
---|
| 586 | %------------------------------------------------------------------------ |
---|
| 587 | % --- Called by action in RootPath edit box |
---|
| 588 | function RootPath_Callback(hObject,eventdata,handles) |
---|
| 589 | %------------------------------------------------------------------------ |
---|
| 590 | % read the current input file name: |
---|
| 591 | [RootPath,SubDir,RootFile,FileIndices,FileExt]=read_file_boxes(handles); |
---|
| 592 | % detect the file type, get the movie object if relevant, and look for the corresponding file series: |
---|
| 593 | [RootPath,SubDir,RootFile,i1_series,i2_series,j1_series,j2_series,tild,FileType,MovieObject]=find_file_series(fullfile(RootPath,SubDir),[RootFile FileIndices FileExt]); |
---|
| 594 | % initiate the input file series and refresh the current field view: |
---|
| 595 | update_rootinfo(handles,i1_series,i2_series,j1_series,j2_series,FileType,MovieObject); |
---|
| 596 | |
---|
| 597 | %----------------------------------------------------------------------- |
---|
| 598 | % --- Called by action in RootPath_1 edit box |
---|
| 599 | function RootPath_1_Callback(hObject,eventdata,handles) |
---|
| 600 | % ----------------------------------------------------------------------- |
---|
| 601 | % update_rootinfo_1(hObject,eventdata,handles) |
---|
| 602 | [RootPath,SubDir,RootFile,FileIndices,FileExt]=read_file_boxes_1(handles); |
---|
| 603 | % detect the file type, get the movie object if relevant, and look for the corresponding file series: |
---|
| 604 | [RootPath,SubDir,RootFile,i1_series,i2_series,j1_series,j2_series,tild,FileType,MovieObject]=find_file_series(fullfile(RootPath,SubDir),[RootFile FileIndices FileExt]); |
---|
| 605 | % initiate the input file series and refresh the current field view: |
---|
| 606 | update_rootinfo(handles,i1_series,i2_series,j1_series,j2_series,FileType,MovieObject,2); |
---|
| 607 | |
---|
| 608 | %------------------------------------------------------------------------ |
---|
| 609 | % --- Called by action in RootFile edit box |
---|
| 610 | function SubDir_Callback(hObject, eventdata, handles) |
---|
| 611 | %------------------------------------------------------------------------ |
---|
| 612 | %refresh the menu of input fields |
---|
| 613 | Fields_Callback(hObject, eventdata, handles); |
---|
| 614 | % refresh the current field view |
---|
| 615 | run0_Callback(hObject, eventdata, handles); |
---|
| 616 | |
---|
| 617 | %------------------------------------------------------------------------ |
---|
| 618 | % --- Called by action in RootFile edit box |
---|
| 619 | function RootFile_Callback(hObject, eventdata, handles) |
---|
| 620 | %------------------------------------------------------------------------ |
---|
| 621 | RootPath_Callback(hObject,eventdata,handles) |
---|
| 622 | |
---|
| 623 | %----------------------------------------------------------------------- |
---|
| 624 | % --- Called by action in RootFile_1 edit box |
---|
| 625 | function RootFile_1_Callback(hObject, eventdata, handles) |
---|
| 626 | % ----------------------------------------------------------------------- |
---|
| 627 | RootPath_1_Callback(hObject,eventdata,handles) |
---|
| 628 | |
---|
| 629 | %------------------------------------------------------------------------ |
---|
| 630 | % --- Called by action in FileIndex edit box |
---|
| 631 | function FileIndex_Callback(hObject, eventdata, handles) |
---|
| 632 | %------------------------------------------------------------------------ |
---|
| 633 | [tild,tild,tild,i1,i2,j1,j2]=fileparts_uvmat(get(handles.FileIndex,'String')); |
---|
| 634 | set(handles.i1,'String',num2str(i1)); |
---|
| 635 | set(handles.i2,'String',num2str(i2)); |
---|
| 636 | set(handles.j1,'String',num2str(j1)); |
---|
| 637 | set(handles.j2,'String',num2str(j2)); |
---|
| 638 | |
---|
| 639 | % refresh the current field view |
---|
| 640 | run0_Callback(hObject, eventdata, handles) |
---|
| 641 | |
---|
| 642 | %------------------------------------------------------------------------ |
---|
| 643 | % --- Called by action in FileIndex_1 edit box |
---|
| 644 | function FileIndex_1_Callback(hObject, eventdata, handles) |
---|
| 645 | %------------------------------------------------------------------------ |
---|
| 646 | run0_Callback(hObject, eventdata, handles) |
---|
| 647 | |
---|
| 648 | %------------------------------------------------------------------------ |
---|
| 649 | % --- Called by action in NomType edit box |
---|
| 650 | function NomType_Callback(hObject, eventdata, handles) |
---|
| 651 | %------------------------------------------------------------------------ |
---|
| 652 | i1=str2num(get(handles.i1,'String')); |
---|
| 653 | i2=str2num(get(handles.i2,'String')); |
---|
| 654 | j1=str2num(get(handles.j1,'String')); |
---|
| 655 | j2=str2num(get(handles.j2,'String')); |
---|
| 656 | FileIndex=fullfile_uvmat('','','','',get(handles.NomType,'String'),i1,i2,j1,j2); |
---|
| 657 | set(handles.FileIndex,'String',FileIndex) |
---|
| 658 | % refresh the current settings and refresh the field view |
---|
| 659 | RootPath_Callback(hObject,eventdata,handles) |
---|
| 660 | |
---|
| 661 | %------------------------------------------------------------------------ |
---|
| 662 | % --- Called by action in NomType edit box |
---|
| 663 | function NomType_1_Callback(hObject, eventdata, handles) |
---|
| 664 | %------------------------------------------------------------------------ |
---|
| 665 | i1=str2num(get(handles.i1,'String')); |
---|
| 666 | i2=str2num(get(handles.i2,'String')); |
---|
| 667 | j1=str2num(get(handles.j1,'String')); |
---|
| 668 | j2=str2num(get(handles.j2,'String')); |
---|
| 669 | FileIndex=fullfile_uvmat('','','','',get(handles.NomType_1,'String'),i1,i2,j1,j2); |
---|
| 670 | set(handles.FileIndex_1,'String',FileIndex) |
---|
| 671 | % refresh the current settings and refresh the field view |
---|
| 672 | RootPath_1_Callback(hObject,eventdata,handles) |
---|
| 673 | |
---|
[387] | 674 | %------------------------------------------------------------------------ |
---|
| 675 | % --- Fills the edit boxes RootPath, RootFile,NomType...from an input file name 'fileinput' |
---|
| 676 | function display_file_name(hObject, eventdata, handles,fileinput,index) |
---|
| 677 | %------------------------------------------------------------------------ |
---|
| 678 | %% look for the input file existence |
---|
| 679 | if ~exist(fileinput,'file') |
---|
| 680 | msgbox_uvmat('ERROR',['input file ' fileinput ' does not exist']) |
---|
| 681 | return |
---|
| 682 | end |
---|
| 683 | |
---|
| 684 | %% set the mouse pointer to 'watch' |
---|
| 685 | set(handles.uvmat,'Pointer','watch') |
---|
| 686 | set(handles.RootPath,'BackgroundColor',[1 1 0]) |
---|
| 687 | drawnow |
---|
| 688 | |
---|
| 689 | %% define the relevant handles for the first fiel series (index=1) or the second file series (index=2) |
---|
| 690 | if ~exist('index','var') |
---|
| 691 | index=1; |
---|
| 692 | end |
---|
| 693 | if index==1 |
---|
| 694 | handles_RootPath=handles.RootPath; |
---|
| 695 | handles_SubDir=handles.SubDir; |
---|
| 696 | handles_RootFile=handles.RootFile; |
---|
| 697 | handles_FileIndex=handles.FileIndex; |
---|
| 698 | handles_NomType=handles.NomType; |
---|
| 699 | handles_FileExt=handles.FileExt; |
---|
[399] | 700 | % handles_Fields=handles.Fields; |
---|
[387] | 701 | elseif index==2 |
---|
| 702 | handles_RootPath=handles.RootPath_1; |
---|
| 703 | handles_SubDir=handles.SubDir_1; |
---|
| 704 | handles_RootFile=handles.RootFile_1; |
---|
| 705 | handles_FileIndex=handles.FileIndex_1; |
---|
| 706 | handles_NomType=handles.NomType_1; |
---|
| 707 | handles_FileExt=handles.FileExt_1; |
---|
[399] | 708 | % handles_Fields=handles.Fields_1; |
---|
[387] | 709 | set(handles.RootPath_1,'Visible','on') |
---|
| 710 | set(handles.RootFile_1,'Visible','on') |
---|
| 711 | set(handles.SubDir_1,'Visible','on'); |
---|
| 712 | set(handles.FileIndex_1,'Visible','on'); |
---|
| 713 | set(handles.FileExt_1,'Visible','on'); |
---|
| 714 | set(handles.NomType_1,'Visible','on'); |
---|
| 715 | end |
---|
| 716 | |
---|
| 717 | %% detect root name, nomenclature and indices in the input file name: |
---|
[398] | 718 | [FilePath,FileName,FileExt]=fileparts(fileinput); |
---|
[387] | 719 | % detect the file type, get the movie object if relevant, and look for the corresponding file series: |
---|
[398] | 720 | % the root name and indices may be corrected by including the first index i1 if a corresponding xml file exists |
---|
| 721 | [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] | 722 | |
---|
| 723 | %% open the file or fill the GUI uvmat according to the detected file type |
---|
| 724 | switch FileType |
---|
| 725 | case '' |
---|
| 726 | msgbox_uvmat('ERROR','invalid input file type') |
---|
| 727 | case 'txt' |
---|
| 728 | edit(fileinput) |
---|
| 729 | case 'figure' %display matlab figure |
---|
| 730 | hfig=open(fileinput); |
---|
| 731 | set(hfig,'WindowButtonMotionFcn','mouse_motion')%set mouse action functio |
---|
| 732 | set(hfig,'WindowButtonUpFcn','mouse_up')%set mouse click action function |
---|
| 733 | set(hfig,'WindowButtonUpFcn','mouse_down')%set mouse click action function |
---|
| 734 | case {'xml','xls'} % edit xml or Excel files |
---|
| 735 | editxml(fileinput); |
---|
| 736 | otherwise |
---|
| 737 | set(handles_RootPath,'String',RootPath); |
---|
| 738 | rootname=fullfile(RootPath,SubDir,RootFile); |
---|
| 739 | set(handles_SubDir,'String',['/' SubDir]); |
---|
| 740 | set(handles_RootFile,'String',['/' RootFile]); %display the separator |
---|
| 741 | indices=fileinput(length(rootname)+1:end); |
---|
| 742 | indices(end-length(FileExt)+1:end)=[]; %remove extension |
---|
| 743 | set(handles_FileIndex,'String',indices); |
---|
| 744 | set(handles_NomType,'String',NomType); |
---|
| 745 | set(handles_FileExt,'String',FileExt); |
---|
| 746 | if index==1 |
---|
| 747 | % fill file index counters if the first file series is opened |
---|
| 748 | set(handles.i1,'String',num2str(i1)); |
---|
| 749 | set(handles.i2,'String',num2str(i2)); |
---|
| 750 | set(handles.j1,'String',num2stra(j1,NomType)); |
---|
| 751 | set(handles.j2,'String',num2stra(j2,NomType)); |
---|
| 752 | else %read the current field index if the second file series is opened |
---|
| 753 | i1=str2num(get(handles.i1,'String')); |
---|
| 754 | i2=str2num(get(handles.i2,'String')); |
---|
| 755 | j1=stra2num(get(handles.j1,'String')); |
---|
| 756 | j2=stra2num(get(handles.j2,'String')); |
---|
| 757 | end |
---|
| 758 | |
---|
| 759 | % synchronise indices of the second input file if it exists |
---|
| 760 | if get(handles.SubField,'Value')==1% if the subfield button is activated, update the field numbers |
---|
| 761 | Input=read_GUI(handles.InputFile); |
---|
| 762 | if ~isfield(Input,'RootPath_1')||strcmp(Input.RootPath_1,'"') |
---|
| 763 | Input.RootPath_1=Input.RootPath; |
---|
| 764 | end |
---|
| 765 | if ~isfield(Input,'SubDir_1')||strcmp(Input.SubDir_1,'"') |
---|
| 766 | Input.SubDir_1=Input.SubDir; |
---|
| 767 | end |
---|
| 768 | if ~isfield(Input,'RootFile_1')||strcmp(Input.RootFile_1,'"') |
---|
| 769 | Input.RootFile_1=Input.RootFile; |
---|
| 770 | end |
---|
| 771 | %updtate the indices of the second field series to correspond to the newly opened one |
---|
| 772 | FileName_1=fullfile_uvmat(Input.RootPath_1,Input.SubDir_1,Input.RootFile_1,Input.FileExt_1,Input.NomType_1,i1,i2,j1,j2); |
---|
| 773 | if exist(FileName_1,'file') |
---|
| 774 | FileIndex_1=fullfile_uvmat('','','','',Input.NomType_1,i1,i2,j1,j2); |
---|
| 775 | set(handles.FileIndex_1,'String',FileIndex_1) |
---|
| 776 | else |
---|
| 777 | set(handles.SubField,'Value',0) |
---|
| 778 | SubField_Callback(hObject, eventdata, handles) |
---|
| 779 | end |
---|
| 780 | end |
---|
| 781 | |
---|
| 782 | %enable other menus |
---|
| 783 | set(handles.MenuOpen_1,'Enable','on') |
---|
| 784 | set(handles.MenuFile_1_1,'Enable','on') |
---|
| 785 | set(handles.MenuFile_2_1,'Enable','on') |
---|
| 786 | set(handles.MenuFile_3_1,'Enable','on') |
---|
| 787 | set(handles.MenuFile_4_1,'Enable','on') |
---|
| 788 | set(handles.MenuFile_5_1,'Enable','on') |
---|
| 789 | set(handles.MenuExport,'Enable','on') |
---|
| 790 | set(handles.MenuExportFigure,'Enable','on') |
---|
| 791 | set(handles.MenuExportMovie,'Enable','on') |
---|
| 792 | set(handles.MenuTools,'Enable','on') |
---|
| 793 | set(handles.OBJECT_txt,'Visible','on') |
---|
| 794 | set(handles.edit_object,'Visible','on') |
---|
| 795 | set(handles.ListObject,'Visible','on') |
---|
| 796 | set(handles.frame_object,'Visible','on') |
---|
| 797 | |
---|
| 798 | % initiate input file series and refresh the current field view: |
---|
| 799 | update_rootinfo(handles,i1_series,i2_series,j1_series,j2_series,FileType,MovieObject,index); |
---|
| 800 | |
---|
| 801 | end |
---|
| 802 | |
---|
| 803 | %% set back the mouse pointer to arrow |
---|
| 804 | set(handles.uvmat,'Pointer','arrow') |
---|
| 805 | |
---|
| 806 | |
---|
| 807 | %------------------------------------------------------------------------ |
---|
| 808 | % --- Update information about a new field series (indices to scan, timing, |
---|
| 809 | % calibration from an xml file, then refresh current plots |
---|
[397] | 810 | function update_rootinfo(handles,i1_series,i2_series,j1_series,j2_series,FileType,VideoObject,index) |
---|
[387] | 811 | %------------------------------------------------------------------------ |
---|
| 812 | %% define the relevant handles depending on the index (1=first file series, 2= second file series) |
---|
| 813 | if ~exist('index','var') |
---|
| 814 | index=1; |
---|
| 815 | end |
---|
| 816 | if index==1 |
---|
| 817 | handles_RootPath=handles.RootPath; |
---|
| 818 | handles_Fields=handles.Fields; |
---|
| 819 | elseif index==2 |
---|
| 820 | handles_RootPath=handles.RootPath_1; |
---|
| 821 | handles_Fields=handles.Fields_1; |
---|
| 822 | end |
---|
| 823 | |
---|
| 824 | set(handles_RootPath,'BackgroundColor',[1 1 0]) |
---|
| 825 | drawnow |
---|
| 826 | set(handles.Fields,'UserData',[])% reinialize data from uvmat opening |
---|
| 827 | UvData=get(handles.uvmat,'UserData');%huvmat=handles of the uvmat interface |
---|
| 828 | UvData.NewSeries=1; %flag for run0: begin a new series |
---|
| 829 | UvData.TestInputFile=1; |
---|
| 830 | UvData.FileType{index}=FileType; |
---|
| 831 | UvData.i1_series{index}=i1_series; |
---|
| 832 | UvData.i2_series{index}=i2_series; |
---|
| 833 | UvData.j1_series{index}=j1_series; |
---|
| 834 | UvData.j2_series{index}=j2_series; |
---|
| 835 | % set(handles.CheckFixPair,'Value',1) % activate by default the comp_input '-'input window |
---|
| 836 | set(handles.FixVelType,'Value',0); %desactivate fixed veltype |
---|
| 837 | if index==1 |
---|
| 838 | [RootPath,SubDir,RootFile,FileIndices,FileExt]=read_file_boxes(handles); |
---|
| 839 | else |
---|
| 840 | [RootPath,SubDir,RootFile,FileIndices,FileExt]=read_file_boxes_1(handles); |
---|
| 841 | end |
---|
| 842 | FileName=[fullfile(RootPath,SubDir,RootFile) FileIndices FileExt]; |
---|
| 843 | FileBase=fullfile(RootPath,RootFile); |
---|
| 844 | if ~exist(FileName,'file') |
---|
| 845 | msgbox_uvmat('ERROR',['input file ' FileName ' not found']); |
---|
| 846 | return |
---|
| 847 | end |
---|
| 848 | nbfield=[];%default |
---|
| 849 | nbfield_j=[];%default |
---|
| 850 | |
---|
| 851 | %% read timing and total frame number from the current file (movie files) !! may be overrid by xml file |
---|
| 852 | XmlData.Time=[];%default |
---|
| 853 | XmlData.GeometryCalib=[];%default |
---|
| 854 | TimeUnit=[];%default |
---|
| 855 | testima=0; %test for image input |
---|
| 856 | imainfo=[]; |
---|
| 857 | ColorType='falsecolor'; %default |
---|
[397] | 858 | hhh=[]; |
---|
| 859 | UvData.MovieObject{index}=VideoObject; |
---|
| 860 | if ~isempty(VideoObject) |
---|
| 861 | imainfo=get(VideoObject); |
---|
[387] | 862 | testima=1; |
---|
| 863 | nbfield_j=1; |
---|
| 864 | TimeUnit='s'; |
---|
[397] | 865 | XmlData.Time=(0:1/imainfo.FrameRate:(imainfo.NumberOfFrames-1)/imainfo.FrameRate)'; |
---|
| 866 | % % nbfield=imainfo.NumberOfFrames; |
---|
| 867 | set(handles.Dt_txt,'String',['Dt=' num2str(1000/imainfo.FrameRate) 'ms']);%display the elementary time interval in millisec |
---|
| 868 | ColorType='truecolor'; |
---|
[387] | 869 | elseif ~isempty(FileExt(2:end))&&(~isempty(imformats(FileExt(2:end))) || isequal(FileExt,'.vol'))%&& isequal(NomType,'*')% multi-frame image |
---|
| 870 | testima=1; |
---|
| 871 | if ~isequal(SubDir,'') |
---|
[397] | 872 | RootFile=get(handles.RootFile,'String'); |
---|
[387] | 873 | imainfo=imfinfo([fullfile(RootPath,SubDir,RootFile) FileIndices FileExt]); |
---|
| 874 | else |
---|
| 875 | imainfo=imfinfo([FileBase FileIndices FileExt]); |
---|
| 876 | end |
---|
| 877 | ColorType=imainfo.ColorType;%='truecolor' for color images |
---|
| 878 | if length(imainfo) >1 %case of image with multiple frames |
---|
| 879 | nbfield=length(imainfo); |
---|
| 880 | nbfield_j=1; |
---|
[397] | 881 | end |
---|
[387] | 882 | end |
---|
| 883 | if isfield(imainfo,'Width') && isfield(imainfo,'Height') |
---|
| 884 | if length(imainfo)>1 |
---|
| 885 | set(handles.num_Npx,'String',num2str(imainfo(1).Width));%fills nbre of pixels x box |
---|
| 886 | set(handles.num_Npy,'String',num2str(imainfo(1).Height));%fills nbre of pixels x box |
---|
| 887 | else |
---|
| 888 | set(handles.num_Npx,'String',num2str(imainfo.Width));%fills nbre of pixels x box |
---|
| 889 | set(handles.num_Npy,'String',num2str(imainfo.Height));%fills nbre of pixels x box |
---|
| 890 | end |
---|
| 891 | else |
---|
| 892 | set(handles.num_Npx,'String','');%fills nbre of pixels x box |
---|
| 893 | set(handles.num_Npy,'String','');%fills nbre of pixels x box |
---|
| 894 | end |
---|
| 895 | set(handles.CheckBW,'Value',strcmp(ColorType,'grayscale'))% select handles.CheckBW if grayscale image |
---|
| 896 | |
---|
| 897 | %% read parameters (time, geometric calibration..) from a documentation file (.xml advised) |
---|
| 898 | filexml=[FileBase '.xml']; |
---|
| 899 | fileciv=[FileBase '.civ']; |
---|
| 900 | warntext='';%default warning message |
---|
| 901 | NbSlice=1;%default |
---|
| 902 | set(handles.RootPath,'BackgroundColor',[1 1 1]) |
---|
| 903 | if exist(filexml,'file') |
---|
| 904 | set(handles.view_xml,'Visible','on') |
---|
| 905 | set(handles.view_xml,'BackgroundColor',[1 1 0]) |
---|
| 906 | set(handles.view_xml,'String','view .xml') |
---|
| 907 | drawnow |
---|
| 908 | [XmlData,warntext]=imadoc2struct(filexml); |
---|
| 909 | if ~isempty(warntext) |
---|
| 910 | msgbox_uvmat('WARNING',warntext) |
---|
| 911 | end |
---|
| 912 | if isfield(XmlData,'TimeUnit') |
---|
| 913 | if isfield(XmlData,'TimeUnit')&& ~isempty(XmlData.TimeUnit) |
---|
| 914 | TimeUnit=XmlData.TimeUnit; |
---|
| 915 | end |
---|
| 916 | end |
---|
| 917 | set(handles.view_xml,'BackgroundColor',[1 1 1]) |
---|
| 918 | drawnow |
---|
| 919 | if isfield(XmlData, 'GeometryCalib') && ~isempty(XmlData.GeometryCalib) |
---|
| 920 | if isfield(XmlData.GeometryCalib,'VolumeScan') && isequal(XmlData.GeometryCalib.VolumeScan,'y') |
---|
| 921 | set (handles.nb_slice,'String','volume') |
---|
| 922 | end |
---|
| 923 | hgeometry_calib=findobj('tag','geometry_calib'); |
---|
| 924 | if ~isempty(hgeometry_calib) |
---|
| 925 | GUserData=get(hgeometry_calib,'UserData'); |
---|
| 926 | if ~(isfield(GUserData,'XmlInputFile') && strcmp(GUserData.XmlInputFile,filexml)) |
---|
| 927 | answer=msgbox_uvmat('INPUT_Y-N','replace the display of geometry_calib with the new input data?'); |
---|
| 928 | if strcmp(answer,'Yes') |
---|
| 929 | geometry_calib(filexml);%diplay the new calibration points and parameters in geometry_calib |
---|
| 930 | end |
---|
| 931 | end |
---|
| 932 | end |
---|
| 933 | end |
---|
| 934 | elseif exist(fileciv,'file')% if .civ file found |
---|
| 935 | [error,XmlData.Time,TimeUnit,mode,npx,npy,pxcmx,pxcmy]=read_imatext([FileBase '.civ']); |
---|
| 936 | GeometryCalib.R=[pxcmx 0 0; 0 pxcmy 0;0 0 0]; |
---|
| 937 | GeometryCalib.Tx=0; |
---|
| 938 | GeometryCalib.Ty=0; |
---|
| 939 | GeometryCalib.Tz=1; |
---|
| 940 | GeometryCalib.dpx=1; |
---|
| 941 | GeometryCalib.dpy=1; |
---|
| 942 | GeometryCalib.sx=1; |
---|
| 943 | GeometryCalib.Cx=0; |
---|
| 944 | GeometryCalib.Cy=0; |
---|
| 945 | GeometryCalib.f=1; |
---|
| 946 | GeometryCalib.kappa1=0; |
---|
| 947 | GeometryCalib.CoordUnit='cm'; |
---|
| 948 | XmlData.GeometryCalib=GeometryCalib; |
---|
| 949 | if error==2, warntext=['no file ' FileBase '.civ']; |
---|
| 950 | elseif error==1, warntext='inconsistent number of fields in the .civ file'; |
---|
| 951 | end |
---|
| 952 | set(handles.num_Npx,'String',num2str(npx));%fills nbre of pixels x box |
---|
| 953 | set(handles.num_Npy,'String',num2str(npy));%fills nbre of pixels y box |
---|
| 954 | set(handles.pxcm,'String',num2str(pxcmx));%fills scale x (pixel/cm) box |
---|
| 955 | set(handles.pycm,'String',num2str(pxcmy));%fills scale y (pixel/cm) box |
---|
| 956 | set(handles.pxcm,'Visible','on');%fills scale x (pixel/cm) box |
---|
| 957 | set(handles.pycm,'Visible','on');%fills scale y (pixel/cm) box |
---|
| 958 | set(handles.view_xml,'Visible','on') |
---|
| 959 | set(handles.view_xml,'String','view .civ') |
---|
| 960 | else |
---|
| 961 | set(handles.view_xml,'Visible','off') |
---|
| 962 | end |
---|
| 963 | |
---|
| 964 | %% store last index in handles.lat_i and .last_j |
---|
| 965 | nbfield=max(max(i2_series)); |
---|
| 966 | if isempty(nbfield) |
---|
| 967 | nbfield=max(max(i1_series)); |
---|
| 968 | end |
---|
| 969 | nbfield_j=max(max(j2_series)); |
---|
| 970 | if isempty(nbfield_j) |
---|
| 971 | nbfield_j=max(max(j1_series)); |
---|
| 972 | end |
---|
| 973 | if ~isempty(XmlData.Time) |
---|
| 974 | % nbfield=size(XmlData.Time,1); |
---|
| 975 | % nbfield_j=size(XmlData.Time,2); |
---|
| 976 | %transform .Time to a column vector if it is a line vector the nomenclature uses a single index |
---|
| 977 | if isequal(nbfield,1) && ~isequal(nbfield_j,1)% .Time is a line vector |
---|
| 978 | NomType=get(handles.NomType,'String'); |
---|
| 979 | if numel(NomType)>=2 &&(strcmp(NomType,'_i')||strcmp(NomType(1:2),'%0')||strcmp(NomType(1:2),'_%')) |
---|
| 980 | XmlData.Time=(XmlData.Time)'; |
---|
| 981 | % nbfield=nbfield_j; |
---|
| 982 | % nbfield_j=1; |
---|
| 983 | end |
---|
| 984 | end |
---|
| 985 | end |
---|
| 986 | last_i_cell=get(handles.last_i,'String'); |
---|
| 987 | if isempty(nbfield) |
---|
| 988 | last_i_cell{1}=''; |
---|
| 989 | else |
---|
| 990 | last_i_cell{1}=num2str(nbfield); |
---|
| 991 | end |
---|
| 992 | set(handles.last_i,'String',last_i_cell) |
---|
| 993 | last_j_cell=get(handles.last_j,'String'); |
---|
| 994 | if isempty(nbfield_j) |
---|
| 995 | last_j_cell{1}=''; |
---|
| 996 | else |
---|
| 997 | last_j_cell{1}=num2str(nbfield_j); |
---|
| 998 | end |
---|
| 999 | set(handles.last_j,'String',last_j_cell); |
---|
| 1000 | |
---|
| 1001 | %% store geometric calibration in UvData |
---|
| 1002 | if isfield(XmlData,'GeometryCalib') |
---|
| 1003 | GeometryCalib=XmlData.GeometryCalib; |
---|
| 1004 | if isempty(GeometryCalib) |
---|
| 1005 | set(handles.pxcm,'String','') |
---|
| 1006 | set(handles.pycm,'String','') |
---|
| 1007 | set(handles.transform_fct,'Value',1); % no transform by default |
---|
| 1008 | else |
---|
| 1009 | if (isfield(GeometryCalib,'R')&& ~isequal(GeometryCalib.R(2,1),0) && ~isequal(GeometryCalib.R(1,2),0)) ||... |
---|
| 1010 | (isfield(GeometryCalib,'kappa1')&& ~isequal(GeometryCalib.kappa1,0)) |
---|
| 1011 | set(handles.pxcm,'String','var') |
---|
| 1012 | set(handles.pycm,'String','var') |
---|
| 1013 | elseif isfield(GeometryCalib,'fx_fy') |
---|
| 1014 | pixcmx=GeometryCalib.fx_fy(1);%*GeometryCalib.R(1,1)*GeometryCalib.sx/(GeometryCalib.Tz*GeometryCalib.dpx); |
---|
| 1015 | pixcmy=GeometryCalib.fx_fy(2);%*GeometryCalib.R(2,2)/(GeometryCalib.Tz*GeometryCalib.dpy); |
---|
| 1016 | set(handles.pxcm,'String',num2str(pixcmx)) |
---|
| 1017 | set(handles.pycm,'String',num2str(pixcmy)) |
---|
| 1018 | end |
---|
| 1019 | if ~get(handles.CheckFixLimits,'Value') |
---|
| 1020 | set(handles.transform_fct,'Value',2); % phys transform by default if fixedLimits is off |
---|
| 1021 | end |
---|
| 1022 | if isfield(GeometryCalib,'SliceCoord') |
---|
| 1023 | |
---|
| 1024 | siz=size(GeometryCalib.SliceCoord); |
---|
| 1025 | if siz(1)>1 |
---|
| 1026 | NbSlice=siz(1); |
---|
| 1027 | set(handles.slices,'Visible','on') |
---|
| 1028 | set(handles.slices,'Value',1) |
---|
| 1029 | end |
---|
| 1030 | if isfield(GeometryCalib,'VolumeScan') && isequal(GeometryCalib.VolumeScan,'y') |
---|
| 1031 | set(handles.nb_slice,'String','volume') |
---|
| 1032 | else |
---|
| 1033 | set(handles.nb_slice,'String',num2str(NbSlice)) |
---|
| 1034 | end |
---|
| 1035 | slices_Callback([],[], handles) |
---|
| 1036 | end |
---|
| 1037 | end |
---|
| 1038 | end |
---|
| 1039 | |
---|
| 1040 | %% update the data attached to the uvmat interface |
---|
| 1041 | if ~isempty(TimeUnit) |
---|
| 1042 | set(handles.time_txt,'String',['time (' TimeUnit ')']) |
---|
| 1043 | end |
---|
| 1044 | UvData.TimeUnit=TimeUnit; |
---|
| 1045 | UvData.XmlData{index}=XmlData; |
---|
| 1046 | UvData.NewSeries=1; |
---|
| 1047 | % UvData.MovieObject=MovieObject; |
---|
| 1048 | |
---|
| 1049 | %display warning message |
---|
| 1050 | if ~isequal(warntext,'') |
---|
| 1051 | msgbox_uvmat('WARNING',warntext); |
---|
| 1052 | end |
---|
| 1053 | |
---|
| 1054 | %% set default options in menu 'Fields' |
---|
| 1055 | if ~testima |
---|
| 1056 | testcivx=0; |
---|
| 1057 | if isfield(UvData,'FieldsString') && isequal(UvData.FieldsString,{'get_field...'})% field menu defined as input (from get_field) |
---|
| 1058 | set(handles_Fields,'Value',1) |
---|
| 1059 | set(handles_Fields,'String',{'get_field...'}) |
---|
| 1060 | UvData=rmfield(UvData,'FieldsString'); |
---|
| 1061 | else |
---|
| 1062 | Data=nc2struct(FileName,'ListGlobalAttribute','Conventions','absolut_time_T0','civ'); |
---|
| 1063 | if strcmp(Data.Conventions,'uvmat/civdata') ||( ~isempty(Data.absolut_time_T0)&& ~isequal(Data.civ,0))%if the new input is Civx |
---|
| 1064 | FieldList=calc_field; |
---|
| 1065 | set(handles_Fields,'String',[{'image'};FieldList;{'get_field...'}]);%standard menu for civx data |
---|
| 1066 | set(handles_Fields,'Value',2) % set menu to 'velocity' |
---|
| 1067 | col_vec=FieldList; |
---|
| 1068 | col_vec(1)=[];%remove 'velocity' option for vector color (must be a scalar) |
---|
| 1069 | testcivx=1; |
---|
| 1070 | end |
---|
| 1071 | if ~testcivx |
---|
| 1072 | set(handles_Fields,'Value',1) % set menu to 'get_field... |
---|
| 1073 | set(handles_Fields,'String',{'get_field...'}) |
---|
| 1074 | col_vec={'get_field...'}; |
---|
| 1075 | end |
---|
| 1076 | set(handles.ListColorScalar,'String',col_vec) |
---|
| 1077 | end |
---|
| 1078 | end |
---|
| 1079 | set(handles.uvmat,'UserData',UvData) |
---|
| 1080 | |
---|
| 1081 | %% set index navigation options and refresh plots |
---|
| 1082 | scan_option='i';%default |
---|
| 1083 | state_j='off'; %default |
---|
| 1084 | if index==2 |
---|
| 1085 | if get(handles.scan_j,'Value') |
---|
| 1086 | scan_option='j'; %keep the scan option for the second fiel series |
---|
| 1087 | end |
---|
| 1088 | if strcmp(get(handles.j1,'Visible'),'on') |
---|
| 1089 | state_j='on'; |
---|
| 1090 | end |
---|
| 1091 | end |
---|
| 1092 | if ~isempty(j1_series) |
---|
| 1093 | state_j='on'; |
---|
| 1094 | if isequal(nbfield,1) &&index==1 |
---|
| 1095 | scan_option='j'; %scan j index by default if nbfield=1 |
---|
| 1096 | end |
---|
| 1097 | end |
---|
| 1098 | if isequal(scan_option,'i') |
---|
| 1099 | set(handles.scan_i,'Value',1) |
---|
| 1100 | scan_i_Callback([],[], handles); |
---|
| 1101 | else |
---|
| 1102 | set(handles.scan_j,'Value',1) |
---|
| 1103 | scan_j_Callback([],[], handles); |
---|
| 1104 | end |
---|
| 1105 | set(handles.scan_j,'Visible',state_j) |
---|
| 1106 | set(handles.j1,'Visible',state_j) |
---|
| 1107 | set(handles.j2,'Visible',state_j) |
---|
| 1108 | set(handles.last_j,'Visible',state_j); |
---|
| 1109 | set(handles.frame_j,'Visible',state_j); |
---|
| 1110 | set(handles.j_text,'Visible',state_j); |
---|
| 1111 | if ~isempty(i2_series)||~isempty(j2_series) |
---|
| 1112 | set(handles.CheckFixPair,'Visible','on') |
---|
| 1113 | elseif index==1 |
---|
| 1114 | set(handles.CheckFixPair,'Visible','off') |
---|
| 1115 | end |
---|
| 1116 | |
---|
| 1117 | %% view the field |
---|
| 1118 | run0_Callback([],[], handles); %view field |
---|
| 1119 | mask_test=get(handles.CheckMask,'value'); |
---|
| 1120 | if mask_test |
---|
| 1121 | MaskData=get(handles.CheckMask,'UserData'); |
---|
| 1122 | if isfield(MaskData,'maskhandle') && ishandle(MaskData.maskhandle) |
---|
| 1123 | delete(MaskData.maskhandle) %delete old mask |
---|
| 1124 | end |
---|
| 1125 | CheckMask_Callback([],[],handles) |
---|
| 1126 | end |
---|
| 1127 | |
---|
| 1128 | %% update list of recent files in the menubar |
---|
| 1129 | MenuFile=[{get(handles.MenuFile_1,'Label')};{get(handles.MenuFile_2,'Label')};... |
---|
| 1130 | {get(handles.MenuFile_3,'Label')};{get(handles.MenuFile_4,'Label')};{get(handles.MenuFile_5,'Label')}]; |
---|
| 1131 | str_find=strcmp(FileName,MenuFile); |
---|
| 1132 | if isempty(find(str_find,1)) |
---|
| 1133 | MenuFile=[{FileName};MenuFile];%insert the current file if not already in the list |
---|
| 1134 | end |
---|
| 1135 | for ifile=1:min(length(MenuFile),5) |
---|
| 1136 | eval(['set(handles.MenuFile_' num2str(ifile) ',''Label'',MenuFile{ifile});']) |
---|
| 1137 | eval(['set(handles.MenuFile_' num2str(ifile) '_1,''Label'',MenuFile{ifile});']) |
---|
| 1138 | end |
---|
| 1139 | dir_perso=prefdir; |
---|
| 1140 | profil_perso=fullfile(dir_perso,'uvmat_perso.mat'); |
---|
| 1141 | if exist(profil_perso,'file') |
---|
| 1142 | save (profil_perso,'MenuFile','-append'); %store the file names for future opening of uvmat |
---|
| 1143 | else |
---|
| 1144 | save (profil_perso,'MenuFile','-V6'); %store the file names for future opening of uvmat |
---|
| 1145 | end |
---|
| 1146 | |
---|
| 1147 | |
---|
| 1148 | %------------------------------------------------------------------------ |
---|
| 1149 | % --- switch file index scanning options scan_i and scan_j in an exclusive way |
---|
| 1150 | function scan_i_Callback(hObject, eventdata, handles) |
---|
| 1151 | %------------------------------------------------------------------------ |
---|
| 1152 | if get(handles.scan_i,'Value')==1 |
---|
| 1153 | set(handles.scan_i,'BackgroundColor',[1 1 0]) |
---|
| 1154 | set(handles.scan_j,'Value',0) |
---|
| 1155 | else |
---|
| 1156 | set(handles.scan_i,'BackgroundColor',[0.831 0.816 0.784]) |
---|
| 1157 | set(handles.scan_j,'Value',1) |
---|
| 1158 | end |
---|
| 1159 | scan_j_Callback(hObject, eventdata, handles) |
---|
| 1160 | |
---|
| 1161 | %------------------------------------------------------------------------ |
---|
| 1162 | % --- switch file index scanning options scan_i and scan_j in an exclusive way |
---|
| 1163 | function scan_j_Callback(hObject, eventdata, handles) |
---|
| 1164 | %------------------------------------------------------------------------ |
---|
| 1165 | if get(handles.scan_j,'Value')==1 |
---|
| 1166 | set(handles.scan_j,'BackgroundColor',[1 1 0]) |
---|
| 1167 | set(handles.scan_i,'Value',0) |
---|
| 1168 | set(handles.scan_i,'BackgroundColor',[0.831 0.816 0.784]) |
---|
| 1169 | % NomType=get(handles.NomType,'String'); |
---|
| 1170 | % switch NomType |
---|
| 1171 | % case {'_1_1-2','#_ab','%3dab'},% pair with j index |
---|
| 1172 | % set(handles.CheckFixPair,'Visible','on')% option fixed pair on/off made visible (choice of avaible pair with buttons + and - if ='off') |
---|
| 1173 | % otherwise |
---|
| 1174 | % set(handles.CheckFixPair,'Visible','off') |
---|
| 1175 | % end |
---|
| 1176 | else |
---|
| 1177 | set(handles.scan_j,'BackgroundColor',[0.831 0.816 0.784]) |
---|
| 1178 | set(handles.scan_i,'Value',1) |
---|
| 1179 | set(handles.scan_i,'BackgroundColor',[1 1 0]) |
---|
| 1180 | set(handles.CheckFixPair,'Visible','off') |
---|
| 1181 | end |
---|
| 1182 | |
---|
| 1183 | %------------------------------------------------------------------------ |
---|
| 1184 | function i1_Callback(hObject, eventdata, handles) |
---|
| 1185 | %------------------------------------------------------------------------ |
---|
| 1186 | set(handles.i1,'BackgroundColor',[0.7 0.7 0.7]) |
---|
| 1187 | NomType=get(handles.NomType,'String'); |
---|
| 1188 | i1=stra2num(get(handles.i1,'String')); |
---|
| 1189 | i2=stra2num(get(handles.i2,'String')); |
---|
| 1190 | j1=stra2num(get(handles.j1,'String')); |
---|
| 1191 | j2=stra2num(get(handles.j2,'String')); |
---|
| 1192 | indices=fullfile_uvmat('','','','',NomType,i1,i2,j1,j2); |
---|
| 1193 | %indices=name_generator('',num1,num_a,'',NomType,1,num2,num_b,''); |
---|
| 1194 | set(handles.FileIndex,'String',indices) |
---|
| 1195 | set(handles.FileIndex,'BackgroundColor',[0.7 0.7 0.7]) |
---|
| 1196 | if get(handles.SubField,'Value')==1 |
---|
| 1197 | NomType_1=get(handles.NomType_1,'String'); |
---|
| 1198 | indices=fullfile_uvmat('','','','',NomType,i1,i2,j1,j2); |
---|
| 1199 | %indices=name_generator('',num1,num_a,'',NomType_1,1,num2,num_b,''); |
---|
| 1200 | set(handles.FileIndex_1,'String',indices) |
---|
| 1201 | set(handles.FileIndex_1,'BackgroundColor',[0.7 0.7 0.7]) |
---|
| 1202 | end |
---|
| 1203 | |
---|
| 1204 | %------------------------------------------------------------------------ |
---|
| 1205 | function i2_Callback(hObject, eventdata, handles) |
---|
| 1206 | %------------------------------------------------------------------------ |
---|
| 1207 | set(handles.i2,'BackgroundColor',[0.7 0.7 0.7]) |
---|
| 1208 | i1_Callback(hObject, eventdata, handles) |
---|
| 1209 | |
---|
| 1210 | %------------------------------------------------------------------------ |
---|
| 1211 | function j1_Callback(hObject, eventdata, handles) |
---|
| 1212 | %------------------------------------------------------------------------ |
---|
| 1213 | set(handles.j1,'BackgroundColor',[0.7 0.7 0.7]) |
---|
| 1214 | i1_Callback(hObject, eventdata, handles) |
---|
| 1215 | |
---|
| 1216 | %------------------------------------------------------------------------ |
---|
| 1217 | function j2_Callback(hObject, eventdata, handles) |
---|
| 1218 | %------------------------------------------------------------------------ |
---|
| 1219 | set(handles.j2,'BackgroundColor',[0.7 0.7 0.7]) |
---|
| 1220 | i1_Callback(hObject, eventdata, handles) |
---|
| 1221 | |
---|
| 1222 | %------------------------------------------------------------------------ |
---|
| 1223 | function slices_Callback(hObject, eventdata, handles) |
---|
| 1224 | %------------------------------------------------------------------------ |
---|
| 1225 | if get(handles.slices,'Value')==1 |
---|
| 1226 | set(handles.slices,'BackgroundColor',[1 1 0]) |
---|
| 1227 | set(handles.nb_slice,'Visible','on') |
---|
| 1228 | set(handles.z_text,'Visible','on') |
---|
| 1229 | set(handles.z_index,'Visible','on') |
---|
| 1230 | nb_slice_Callback(hObject, eventdata, handles) |
---|
| 1231 | else |
---|
| 1232 | set(handles.nb_slice,'Visible','off') |
---|
| 1233 | set(handles.slices,'BackgroundColor',[0.7 0.7 0.7]) |
---|
| 1234 | set(handles.z_text,'Visible','off') |
---|
| 1235 | set(handles.z_index,'Visible','off') |
---|
| 1236 | set(handles.masklevel,'Value',1) |
---|
| 1237 | set(handles.masklevel,'String',{'1'}) |
---|
| 1238 | end |
---|
| 1239 | |
---|
| 1240 | %------------------------------------------------------------------------ |
---|
| 1241 | function nb_slice_Callback(hObject, eventdata, handles) |
---|
| 1242 | %------------------------------------------------------------------------ |
---|
| 1243 | nb_slice_str=get(handles.nb_slice,'String'); |
---|
| 1244 | if isequal(nb_slice_str,'volume') |
---|
| 1245 | num=stra2num(get(handles.j1,'String')); |
---|
| 1246 | last_j=get(handles.last_j,'String'); |
---|
| 1247 | nbslice=str2double(last_j{1}); |
---|
| 1248 | else |
---|
| 1249 | num=str2double(get(handles.i1,'String')); |
---|
| 1250 | nbslice=str2double(get(handles.nb_slice,'String')); |
---|
| 1251 | end |
---|
| 1252 | z=mod(num-1,nbslice)+1; |
---|
| 1253 | set(handles.z_index,'String',num2str(z)) |
---|
| 1254 | for ilist=1:nbslice |
---|
| 1255 | list_index{ilist,1}=num2str(ilist); |
---|
| 1256 | end |
---|
| 1257 | set(handles.masklevel,'String',list_index) |
---|
| 1258 | set(handles.masklevel,'Value',z) |
---|
| 1259 | |
---|
| 1260 | %------------------------------------------------------------------------ |
---|
| 1261 | % --- Executes on button press in view_xml. |
---|
| 1262 | function view_xml_Callback(hObject, eventdata, handles) |
---|
| 1263 | %------------------------------------------------------------------------ |
---|
| 1264 | %[FileName,RootPath,FileBase,FileIndices,FileExt]=read_file_boxes(handles); |
---|
| 1265 | [RootPath,SubDir,RootFile,FileIndices,FileExt]=read_file_boxes(handles); |
---|
| 1266 | FileBase=fullfile(RootPath,RootFile); |
---|
| 1267 | option=get(handles.view_xml,'String'); |
---|
| 1268 | if isequal(option,'view .xml') |
---|
| 1269 | FileXml=[FileBase '.xml']; |
---|
| 1270 | heditxml=editxml(FileXml); |
---|
| 1271 | end |
---|
| 1272 | |
---|
| 1273 | %------------------------------------------------------------------------ |
---|
| 1274 | % --- Executes on button press in CheckMask. |
---|
| 1275 | function CheckMask_Callback(hObject, eventdata, handles) |
---|
| 1276 | %------------------------------------------------------------------------ |
---|
| 1277 | %case of view mask selection |
---|
| 1278 | if isequal(get(handles.CheckMask,'Value'),1) |
---|
| 1279 | % [FF,RootPath,FileBase]=read_file_boxes(handles); |
---|
| 1280 | [RootPath,SubDir,RootFile,FileIndices,FileExt]=read_file_boxes(handles); |
---|
| 1281 | FileBase=fullfile(RootPath,RootFile); |
---|
| 1282 | num_i1=stra2num(get(handles.i1,'String')); |
---|
| 1283 | num_j1=stra2num(get(handles.j1,'String')); |
---|
| 1284 | currentdir=pwd; |
---|
| 1285 | cd(RootPath); |
---|
| 1286 | maskfiles=dir('*_*mask_*.png');%look for a mask file |
---|
| 1287 | cd(currentdir);%come back to the working directory |
---|
| 1288 | mdetect=0; |
---|
| 1289 | if ~isempty(maskfiles) |
---|
| 1290 | for ilist=1:length(maskfiles) |
---|
| 1291 | maskname=maskfiles(ilist).name;% take the first mask file in the list |
---|
| 1292 | [tild,tild,tild,tild,tild,tild,tild,MaskExt,Mask_NomType{ilist}]=fileparts_uvmat(maskname); |
---|
| 1293 | % [rr,ff,x1,x2,xa,xb,xext,Mask_NomType{ilist}]=name2display(maskname); |
---|
| 1294 | [tild,Name]=fileparts(maskname); |
---|
| 1295 | Namedouble=double(Name); |
---|
| 1296 | val=(48>Namedouble)|(Namedouble>57);% select the non-numerical characters |
---|
| 1297 | ind_mask=findstr('mask',Name); |
---|
| 1298 | i=ind_mask-1; |
---|
| 1299 | while val(i)==0 && i>0 |
---|
| 1300 | i=i-1; |
---|
| 1301 | end |
---|
| 1302 | nbmask_str=str2num(Name(i+1:ind_mask-1)); |
---|
| 1303 | if ~isempty(nbmask_str) |
---|
| 1304 | nbslice(ilist)=nbmask_str; % number of different masks (slices) |
---|
| 1305 | end |
---|
| 1306 | end |
---|
| 1307 | if isequal(min(nbslice),max(nbslice)) |
---|
| 1308 | nbslice=nbslice(1); |
---|
| 1309 | else |
---|
| 1310 | msgbox_uvmat('ERROR','several inconsistent mask sets coexist in the current image directory') |
---|
| 1311 | return |
---|
| 1312 | end |
---|
| 1313 | if ~isempty(nbslice) && Name(i)=='_' |
---|
| 1314 | Mask.Base=[FileBase Name(i:ind_mask+3)]; |
---|
| 1315 | Mask.NbSlice=nbslice; |
---|
| 1316 | num_i1=mod(num_i1-1,nbslice)+1; |
---|
| 1317 | Mask.NomType=regexprep(Mask_NomType{1},'0','');%remove '0' in nom type for masks |
---|
| 1318 | [RootPath,RootFile]=fileparts(Mask.Base); |
---|
| 1319 | maskname=fullfile_uvmat(RootPath,'',RootFile,'.png',Mask.NomType,num_i1,[],num_j1); |
---|
| 1320 | %maskname=name_generator(Mask.Base,num_i1,num_j1,'.png',Mask.NomType);% |
---|
| 1321 | mdetect=exist(maskname,'file'); |
---|
| 1322 | if mdetect |
---|
| 1323 | set(handles.nb_slice,'String',Name(i+1:ind_mask-1)); |
---|
| 1324 | set(handles.nb_slice,'BackgroundColor',[1 1 0]) |
---|
| 1325 | set(handles.CheckMask,'UserData',Mask); |
---|
| 1326 | set(handles.CheckMask,'BackgroundColor',[1 1 0]) |
---|
| 1327 | if nbslice > 1 |
---|
| 1328 | set(handles.slices,'value',1) |
---|
| 1329 | slices_Callback(hObject, eventdata, handles) |
---|
| 1330 | end |
---|
| 1331 | end |
---|
| 1332 | end |
---|
| 1333 | end |
---|
| 1334 | errormsg=[];%default |
---|
| 1335 | if mdetect==0 |
---|
| 1336 | [FileName, PathName, filterindex] = uigetfile( ... |
---|
| 1337 | {'*.png', ' (*.png)'; |
---|
| 1338 | '*.png', '.png files '; ... |
---|
| 1339 | '*.*', 'All Files (*.*)'}, ... |
---|
| 1340 | 'Pick a mask file *.png',FileBase); |
---|
| 1341 | maskname=fullfile(PathName,FileName); |
---|
| 1342 | if ~exist(maskname,'file') |
---|
| 1343 | errormsg='no file browsed'; |
---|
| 1344 | end |
---|
| 1345 | [RootDir,tild,RootFile,tild,tild,tild,tild,tild,Mask.NomType]=fileparts_uvmat(maskname); |
---|
| 1346 | % [RootDir,RootFile,x1,x2,xa,xb,xext,Mask.NomType]=name2display(maskname); |
---|
| 1347 | Mask.Base=fullfile(RootDir,RootFile); |
---|
| 1348 | Mask.NbSlice=1; |
---|
| 1349 | set(handles.CheckMask,'UserData',Mask); |
---|
| 1350 | set(handles.CheckMask,'BackgroundColor',[1 1 0]) |
---|
| 1351 | end |
---|
| 1352 | if isempty(errormsg) |
---|
| 1353 | errormsg=update_mask(handles,num_i1,num_j1); |
---|
| 1354 | end |
---|
| 1355 | if ~isempty(errormsg) |
---|
| 1356 | set(handles.CheckMask,'Value',0) |
---|
| 1357 | set(handles.CheckMask,'BackgroundColor',[0.7 0.7 0.7]) |
---|
| 1358 | end |
---|
| 1359 | else % desactivate mask display |
---|
| 1360 | MaskData=get(handles.CheckMask,'UserData'); |
---|
| 1361 | if isfield(MaskData,'maskhandle') && ishandle(MaskData.maskhandle) |
---|
| 1362 | delete(MaskData.maskhandle) |
---|
| 1363 | end |
---|
| 1364 | set(handles.CheckMask,'UserData',[]) |
---|
| 1365 | UvData=get(handles.uvmat,'UserData'); |
---|
| 1366 | if isfield(UvData,'MaskName') |
---|
| 1367 | UvData=rmfield(UvData,'MaskName'); |
---|
| 1368 | set(handles.uvmat,'UserData',UvData) |
---|
| 1369 | end |
---|
| 1370 | set(handles.CheckMask,'BackgroundColor',[0.7 0.7 0.7]) |
---|
| 1371 | end |
---|
| 1372 | |
---|
| 1373 | %------------------------------------------------------------------------ |
---|
| 1374 | function errormsg=update_mask(handles,num_i1,num_j1) |
---|
| 1375 | %------------------------------------------------------------------------ |
---|
| 1376 | errormsg=[];%default |
---|
| 1377 | MaskData=get(handles.CheckMask,'UserData'); |
---|
| 1378 | if isfield(MaskData,'maskhandle')&& ishandle(MaskData.maskhandle) |
---|
| 1379 | uistack(MaskData.maskhandle,'top'); |
---|
| 1380 | end |
---|
| 1381 | num_i1_mask=mod(num_i1-1,MaskData.NbSlice)+1; |
---|
| 1382 | [RootPath,RootFile]=fileparts(MaskData.Base); |
---|
| 1383 | MaskName=fullfile_uvmat(RootPath,'',RootFile,'.png',MaskData.NomType,num_i1_mask,[],num_j1); |
---|
| 1384 | %MaskName=name_generator(MaskData.Base,num_i1_mask,num_j1,'.png',MaskData.NomType); |
---|
| 1385 | % huvmat=get(handles.CheckMask,'parent'); |
---|
| 1386 | UvData=get(handles.uvmat,'UserData'); |
---|
| 1387 | %update mask image if the mask is new |
---|
| 1388 | if ~ (isfield(UvData,'MaskName') && isequal(UvData.MaskName,MaskName)) |
---|
| 1389 | UvData.MaskName=MaskName; %update the recorded name on UvData |
---|
| 1390 | set(handles.uvmat,'UserData',UvData); |
---|
| 1391 | if ~exist(MaskName,'file') |
---|
| 1392 | if isfield(MaskData,'maskhandle')&& ishandle(MaskData.maskhandle) |
---|
| 1393 | delete(MaskData.maskhandle) |
---|
| 1394 | end |
---|
| 1395 | else |
---|
| 1396 | %read mask image |
---|
| 1397 | Mask.AName='image'; |
---|
| 1398 | Mask.A=imread(MaskName); |
---|
| 1399 | npxy=size(Mask.A); |
---|
| 1400 | test_error=0; |
---|
| 1401 | if length(npxy)>2 |
---|
| 1402 | errormsg=[MaskName ' is not a grey scale image']; |
---|
| 1403 | return |
---|
| 1404 | elseif ~isa(Mask.A,'uint8') |
---|
| 1405 | errormsg=[MaskName ' is not a 8 bit grey level image']; |
---|
| 1406 | return |
---|
| 1407 | end |
---|
| 1408 | Mask.AX=[0.5 npxy(2)-0.5]; |
---|
| 1409 | Mask.AY=[npxy(1)-0.5 0.5 ]; |
---|
| 1410 | Mask.CoordUnit='pixel'; |
---|
| 1411 | if isequal(get(handles.slices,'Value'),1) |
---|
| 1412 | NbSlice=str2num(get(handles.nb_slice,'String')); |
---|
| 1413 | num_i1=str2num(get(handles.i1,'String')); |
---|
| 1414 | Mask.ZIndex=mod(num_i1-1,NbSlice)+1; |
---|
| 1415 | end |
---|
| 1416 | %px to phys or other transform on field |
---|
| 1417 | menu_transform=get(handles.transform_fct,'String'); |
---|
| 1418 | choice_value=get(handles.transform_fct,'Value'); |
---|
| 1419 | transform_name=menu_transform{choice_value};%name of the transform fct given by the menu 'transform_fct' |
---|
| 1420 | transform_list=get(handles.transform_fct,'UserData'); |
---|
| 1421 | transform=transform_list{choice_value}; |
---|
| 1422 | if ~isequal(transform_name,'') && ~isequal(transform_name,'px') |
---|
| 1423 | if isfield(UvData,'XmlData') && isfield(UvData.XmlData{1},'GeometryCalib')%use geometry calib recorded from the ImaDoc xml file as first priority |
---|
| 1424 | Calib=UvData.XmlData{1}.GeometryCalib; |
---|
| 1425 | Mask=transform(Mask,UvData.XmlData{1}); |
---|
| 1426 | end |
---|
| 1427 | end |
---|
| 1428 | flagmask=Mask.A < 200; |
---|
| 1429 | |
---|
| 1430 | %make brown color image |
---|
| 1431 | imflag(:,:,1)=0.9*flagmask; |
---|
| 1432 | imflag(:,:,2)=0.7*flagmask; |
---|
| 1433 | imflag(:,:,3)=zeros(size(flagmask)); |
---|
| 1434 | |
---|
| 1435 | %update mask image |
---|
| 1436 | hmask=[]; %default |
---|
| 1437 | if isfield(MaskData,'maskhandle')&& ishandle(MaskData.maskhandle) |
---|
| 1438 | hmask=MaskData.maskhandle; |
---|
| 1439 | end |
---|
| 1440 | if ~isempty(hmask) |
---|
| 1441 | set(hmask,'CData',imflag) |
---|
| 1442 | set(hmask,'AlphaData',flagmask*0.6) |
---|
| 1443 | set(hmask,'XData',Mask.AX); |
---|
| 1444 | set(hmask,'YData',Mask.AY); |
---|
| 1445 | % uistack(hmask,'top') |
---|
| 1446 | else |
---|
| 1447 | axes(handles.axes3) |
---|
| 1448 | hold on |
---|
| 1449 | MaskData.maskhandle=image(Mask.AX,Mask.AY,imflag,'Tag','mask','HitTest','off','AlphaData',0.6*flagmask); |
---|
| 1450 | % set(MaskData.maskhandle,'AlphaData',0.6*flagmask) |
---|
| 1451 | set(handles.CheckMask,'UserData',MaskData) |
---|
| 1452 | end |
---|
| 1453 | end |
---|
| 1454 | end |
---|
| 1455 | |
---|
| 1456 | %------------------------------------------------------------------------ |
---|
| 1457 | %------------------------------------------------------------------------ |
---|
| 1458 | % III - MAIN REFRESH FUNCTIONS : 'FRAME PLOT' |
---|
| 1459 | %------------------------------------------------------------------------ |
---|
| 1460 | |
---|
| 1461 | %------------------------------------------------------------------------ |
---|
| 1462 | % --- Executes on button press in runplus: make one step forward and call |
---|
| 1463 | % --- run0. The step forward is along the fields series 1 or 2 depending on |
---|
| 1464 | % --- the scan_i and scan_j check box (exclusive each other) |
---|
| 1465 | function runplus_Callback(hObject, eventdata, handles) |
---|
| 1466 | %------------------------------------------------------------------------ |
---|
| 1467 | set(handles.runplus,'BackgroundColor',[1 1 0])%paint the command button in yellow |
---|
| 1468 | drawnow |
---|
| 1469 | %TODO: introduce the option: increment ='*' to move to the next available view |
---|
| 1470 | increment=str2num(get(handles.increment_scan,'String')); %get the field increment d |
---|
| 1471 | % if isnan(increment) |
---|
| 1472 | % set(handles.increment_scan,'String','1')%default value |
---|
| 1473 | % increment=1; |
---|
| 1474 | % end |
---|
| 1475 | errormsg=runpm(hObject,eventdata,handles,increment); |
---|
| 1476 | if ~isempty(errormsg) |
---|
| 1477 | msgbox_uvmat('ERROR',errormsg); |
---|
| 1478 | end |
---|
| 1479 | set(handles.runplus,'BackgroundColor',[1 0 0])%paint the command button back to red |
---|
| 1480 | |
---|
| 1481 | %------------------------------------------------------------------------ |
---|
| 1482 | % --- Executes on button press in runmin: make one step backward and call |
---|
| 1483 | % --- run0. The step backward is along the fields series 1 or 2 depending on |
---|
| 1484 | % --- the scan_i and scan_j check box (exclusive each other) |
---|
| 1485 | function runmin_Callback(hObject, eventdata, handles) |
---|
| 1486 | %------------------------------------------------------------------------ |
---|
| 1487 | set(handles.runmin,'BackgroundColor',[1 1 0])%paint the command button in yellow |
---|
| 1488 | drawnow |
---|
| 1489 | increment=-str2num(get(handles.increment_scan,'String')); %get the field increment d |
---|
| 1490 | % if isnan(increment) |
---|
| 1491 | % set(handles.increment_scan,'String','1')%default value |
---|
| 1492 | % increment=1; |
---|
| 1493 | % end |
---|
| 1494 | errormsg=runpm(hObject,eventdata,handles,increment); |
---|
| 1495 | if ~isempty(errormsg) |
---|
| 1496 | msgbox_uvmat('ERROR',errormsg); |
---|
| 1497 | end |
---|
| 1498 | set(handles.runmin,'BackgroundColor',[1 0 0])%paint the command button back to red |
---|
| 1499 | |
---|
| 1500 | %------------------------------------------------------------------------ |
---|
| 1501 | % -- Executes on button press in Movie: make a series of +> steps |
---|
| 1502 | function Movie_Callback(hObject, eventdata, handles) |
---|
| 1503 | %------------------------------------------------------------------------ |
---|
| 1504 | set(handles.Movie,'BackgroundColor',[1 1 0])%paint the command button in yellow |
---|
| 1505 | drawnow |
---|
| 1506 | increment=str2num(get(handles.increment_scan,'String')); %get the field increment d |
---|
| 1507 | % if isnan(increment) |
---|
| 1508 | % set(handles.increment_scan,'String','1')%default value |
---|
| 1509 | % increment=1; |
---|
| 1510 | % end |
---|
| 1511 | set(handles.STOP,'Visible','on') |
---|
| 1512 | set(handles.speed,'Visible','on') |
---|
| 1513 | set(handles.speed_txt,'Visible','on') |
---|
| 1514 | set(handles.Movie,'BusyAction','queue') |
---|
| 1515 | UvData=get(handles.uvmat,'UserData'); |
---|
| 1516 | |
---|
| 1517 | while get(handles.speed,'Value')~=0 && isequal(get(handles.Movie,'BusyAction'),'queue') % enable STOP command |
---|
| 1518 | errormsg=runpm(hObject,eventdata,handles,increment); |
---|
| 1519 | if ~isempty(errormsg) |
---|
| 1520 | set(handles.Movie,'BackgroundColor',[1 0 0])%paint the command buttonback to red |
---|
| 1521 | return |
---|
| 1522 | end |
---|
| 1523 | pause(1.02-get(handles.speed,'Value'))% wait for next image |
---|
| 1524 | end |
---|
| 1525 | if isfield(UvData,'aviobj') && ~isempty( UvData.aviobj), |
---|
| 1526 | UvData.aviobj=close(UvData.aviobj); |
---|
| 1527 | set(handles.uvmat,'UserData',UvData); |
---|
| 1528 | end |
---|
| 1529 | set(handles.Movie,'BackgroundColor',[1 0 0])%paint the command buttonback to red |
---|
| 1530 | |
---|
| 1531 | %------------------------------------------------------------------------ |
---|
| 1532 | % -- Executes on button press in Movie: make a series of <- steps |
---|
| 1533 | function MovieBackward_Callback(hObject, eventdata, handles) |
---|
| 1534 | %------------------------------------------------------------------------ |
---|
| 1535 | set(handles.MovieBackward,'BackgroundColor',[1 1 0])%paint the command button in yellow |
---|
| 1536 | drawnow |
---|
| 1537 | increment=-str2num(get(handles.increment_scan,'String')); %get the field increment d |
---|
| 1538 | set(handles.STOP,'Visible','on') |
---|
| 1539 | set(handles.speed,'Visible','on') |
---|
| 1540 | set(handles.speed_txt,'Visible','on') |
---|
| 1541 | set(handles.MovieBackward,'BusyAction','queue') |
---|
| 1542 | UvData=get(handles.uvmat,'UserData'); |
---|
| 1543 | |
---|
| 1544 | while get(handles.speed,'Value')~=0 && isequal(get(handles.MovieBackward,'BusyAction'),'queue') % enable STOP command |
---|
| 1545 | errormsg=runpm(hObject,eventdata,handles,increment); |
---|
| 1546 | if ~isempty(errormsg) |
---|
| 1547 | set(handles.MovieBackward,'BackgroundColor',[1 0 0])%paint the command buttonback to red |
---|
| 1548 | return |
---|
| 1549 | end |
---|
| 1550 | pause(1.02-get(handles.speed,'Value'))% wait for next image |
---|
| 1551 | end |
---|
| 1552 | if isfield(UvData,'aviobj') && ~isempty( UvData.aviobj), |
---|
| 1553 | UvData.aviobj=close(UvData.aviobj); |
---|
| 1554 | set(handles.uvmat,'UserData',UvData); |
---|
| 1555 | end |
---|
| 1556 | set(handles.MovieBackward,'BackgroundColor',[1 0 0])%paint the command buttonback to red |
---|
| 1557 | |
---|
| 1558 | %------------------------------------------------------------------------ |
---|
| 1559 | function STOP_Callback(hObject, eventdata, handles) |
---|
| 1560 | %------------------------------------------------------------------------ |
---|
| 1561 | set(handles.movie_pair,'BusyAction','Cancel') |
---|
| 1562 | set(handles.movie_pair,'value',0) |
---|
| 1563 | set(handles.Movie,'BusyAction','Cancel') |
---|
| 1564 | set(handles.MovieBackward,'BusyAction','Cancel') |
---|
| 1565 | set(handles.MenuExportMovie,'BusyAction','Cancel') |
---|
| 1566 | set(handles.movie_pair,'BackgroundColor',[1 0 0])%paint the command buttonback to red |
---|
| 1567 | set(handles.Movie,'BackgroundColor',[1 0 0])%paint the command buttonback to red |
---|
| 1568 | set(handles.MovieBackward,'BackgroundColor',[1 0 0])%paint the command buttonback to red |
---|
| 1569 | |
---|
| 1570 | %------------------------------------------------------------------------ |
---|
| 1571 | % --- function activated by runplus and run minus |
---|
| 1572 | function errormsg=runpm(hObject,eventdata,handles,increment) |
---|
| 1573 | %------------------------------------------------------------------------ |
---|
| 1574 | errormsg='';%default |
---|
| 1575 | %% check for movie pair status |
---|
| 1576 | movie_status=get(handles.movie_pair,'Value'); |
---|
| 1577 | if isequal(movie_status,1) |
---|
| 1578 | STOP_Callback(hObject, eventdata, handles)%interrupt movie pair if active |
---|
| 1579 | end |
---|
| 1580 | |
---|
| 1581 | %% read the current input file name(s) and field indices |
---|
| 1582 | InputFile=read_GUI(handles.InputFile); |
---|
| 1583 | InputFile.RootFile=regexprep(InputFile.RootFile,'^[\\/]|[\\/]$','');%suppress possible / or \ separator at the beginning or the end of the string |
---|
| 1584 | InputFile.SubDir=regexprep(InputFile.SubDir,'^[\\/]|[\\/]$','');%suppress possible / or \ separator at the beginning or the end of the string |
---|
| 1585 | FileExt=InputFile.FileExt; |
---|
| 1586 | NomType=get(handles.NomType,'String'); |
---|
| 1587 | i1=str2num(get(handles.i1,'String'));%read the field indices (for movie, it is not given by the file name) |
---|
| 1588 | i2=[];%default |
---|
| 1589 | if strcmp(get(handles.i2,'Visible'),'on') |
---|
| 1590 | i2=str2num(get(handles.i2,'String')); |
---|
| 1591 | end |
---|
| 1592 | j1=[]; |
---|
| 1593 | if strcmp(get(handles.j1,'Visible'),'on') |
---|
| 1594 | j1=stra2num(get(handles.j1,'String')); |
---|
| 1595 | end |
---|
| 1596 | j2=j1; |
---|
| 1597 | if strcmp(get(handles.j2,'Visible'),'on') |
---|
| 1598 | j2=stra2num(get(handles.j2,'String')); |
---|
| 1599 | end |
---|
| 1600 | sub_value= get(handles.SubField,'Value'); |
---|
| 1601 | if sub_value % a second input file has been entered |
---|
| 1602 | [FileName_1,RootPath_1,filebase_1,FileIndices_1,FileExt_1,SubDir_1]=read_file_boxes_1(handles); |
---|
| 1603 | [tild,tild,tild,i1_1,i2_1,j1_1,j2_1]=fileparts_uvmat(FileIndices_1); |
---|
| 1604 | NomType_1=get(handles.NomType_1,'String'); |
---|
| 1605 | else |
---|
| 1606 | filename_1=[]; |
---|
| 1607 | end |
---|
| 1608 | |
---|
| 1609 | %% increment (or decrement) the field indices and update the input filename(s) |
---|
| 1610 | CheckSearch=0; |
---|
| 1611 | if isempty(increment) |
---|
| 1612 | CheckSearch=1;% search for the next available file |
---|
| 1613 | set(handles.CheckFixPair,'Value',0) |
---|
| 1614 | end |
---|
| 1615 | CheckFixPair=get(handles.CheckFixPair,'Value')||(isempty(i2)&&isempty(j2)); |
---|
| 1616 | if CheckFixPair |
---|
| 1617 | if get(handles.scan_i,'Value')==1% case of scanning along index i |
---|
| 1618 | i1=i1+increment; |
---|
| 1619 | i2=i2+increment; |
---|
| 1620 | if sub_value |
---|
| 1621 | i1_1=i1_1+increment; |
---|
| 1622 | i2_1=i2_1+increment; |
---|
| 1623 | end |
---|
| 1624 | else % case of scanning along index j (burst numbers) |
---|
| 1625 | j1=j1+increment; |
---|
| 1626 | j2=j2+increment; |
---|
| 1627 | if sub_value |
---|
| 1628 | j1_1=j1_1+increment; |
---|
| 1629 | j2_1=j2_1+increment; |
---|
| 1630 | end |
---|
| 1631 | end |
---|
| 1632 | else |
---|
| 1633 | UvData=get(handles.uvmat,'UserData'); |
---|
| 1634 | ref_i=i1; |
---|
| 1635 | if ~isempty(i2) |
---|
| 1636 | ref_i=floor((i1+i2)/2); |
---|
| 1637 | end |
---|
| 1638 | ref_j=1; |
---|
| 1639 | if ~isempty(j1) |
---|
| 1640 | ref_j=j1; |
---|
| 1641 | if ~isempty(j2) |
---|
| 1642 | ref_j=floor((j1+j2)/2); |
---|
| 1643 | end |
---|
| 1644 | end |
---|
| 1645 | if ~isempty(increment) |
---|
| 1646 | if get(handles.scan_i,'Value')==1% case of scanning along index i |
---|
| 1647 | ref_i=ref_i+increment; |
---|
| 1648 | else % case of scanning along index j (burst numbers) |
---|
| 1649 | ref_j=ref_j+increment; |
---|
| 1650 | end |
---|
[388] | 1651 | else % free increment |
---|
[387] | 1652 | if isequal(get(handles.runplus,'BackgroundColor'),[1 1 0])% if runplus is activated |
---|
| 1653 | step=1; |
---|
| 1654 | else |
---|
| 1655 | step=-1; |
---|
| 1656 | end |
---|
| 1657 | if get(handles.scan_i,'Value')==1% case of scanning along index i |
---|
| 1658 | ref_i=ref_i+step; |
---|
| 1659 | 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 |
---|
| 1660 | ref_i=ref_i+step; |
---|
| 1661 | end |
---|
| 1662 | else % case of scanning along index j (burst numbers) |
---|
| 1663 | ref_j=ref_j+step; |
---|
| 1664 | 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 |
---|
| 1665 | ref_j=ref_j+step; |
---|
| 1666 | end |
---|
| 1667 | end |
---|
| 1668 | end |
---|
| 1669 | if ref_i<0 |
---|
| 1670 | errormsg='minimum i index reached'; |
---|
| 1671 | elseif ref_j<0 |
---|
| 1672 | errormsg='minimum j index reached'; |
---|
| 1673 | elseif ref_i+1>size(UvData.i1_series{1},1) |
---|
| 1674 | errormsg='maximum i index reached'; |
---|
| 1675 | elseif ref_j+1>size(UvData.i1_series{1},2) |
---|
| 1676 | errormsg='maximum j index reached'; |
---|
| 1677 | end |
---|
| 1678 | if ~isempty(errormsg) |
---|
| 1679 | return |
---|
| 1680 | end |
---|
| 1681 | if get(handles.scan_i,'Value')==1% case of scanning along index i |
---|
[388] | 1682 | i1_subseries=UvData.i1_series{1}(ref_i+1,ref_j+1,:); |
---|
[387] | 1683 | else |
---|
[388] | 1684 | i1_subseries=UvData.i1_series{1}(ref_i+1,ref_j+1,:); |
---|
[387] | 1685 | end |
---|
| 1686 | i1_subseries=i1_subseries(i1_subseries>0); |
---|
| 1687 | if isempty(i1_subseries) |
---|
| 1688 | errormsg='no next file'; |
---|
| 1689 | return |
---|
| 1690 | end |
---|
| 1691 | i1=i1_subseries(end); |
---|
| 1692 | if ~isempty(UvData.i2_series{1}) |
---|
| 1693 | if get(handles.scan_i,'Value')==1% case of scanning along index i |
---|
[388] | 1694 | i2_subseries=UvData.i2_series{1}(ref_i+1,ref_j+1,:); |
---|
[387] | 1695 | else |
---|
[388] | 1696 | i2_subseries=UvData.i2_series{1}(ref_i+1,ref_j+1,:); |
---|
[387] | 1697 | end |
---|
| 1698 | i2_subseries=i2_subseries(i2_subseries>0); |
---|
| 1699 | i2=i2_subseries(end); |
---|
| 1700 | end |
---|
| 1701 | if ~isempty(UvData.j1_series{1}) |
---|
| 1702 | if get(handles.scan_i,'Value')==1% case of scanning along index i |
---|
[388] | 1703 | j1_subseries=UvData.j1_series{1}(ref_i+1,ref_j+1,:); |
---|
[387] | 1704 | else |
---|
[388] | 1705 | j1_subseries=UvData.j1_series{1}(ref_i+1,ref_j+1,:); |
---|
[387] | 1706 | end |
---|
| 1707 | j1_subseries=j1_subseries(j1_subseries>0); |
---|
| 1708 | j1=j1_subseries(end); |
---|
| 1709 | end |
---|
| 1710 | if ~isempty(UvData.j2_series{1}) |
---|
| 1711 | if get(handles.scan_i,'Value')==1% case of scanning along index i |
---|
[388] | 1712 | j2_subseries=UvData.j2_series{1}(ref_i+1,ref_j+1,:); |
---|
[387] | 1713 | else |
---|
[388] | 1714 | j2_subseries=UvData.j2_series{1}(ref_i+1,ref_j+1,:); |
---|
[387] | 1715 | end |
---|
| 1716 | j2_subseries=j2_subseries(j2_subseries>0); |
---|
| 1717 | j2=j2_subseries(end); |
---|
| 1718 | end |
---|
| 1719 | |
---|
| 1720 | end |
---|
| 1721 | filename=fullfile_uvmat(InputFile.RootPath,InputFile.SubDir,InputFile.RootFile,FileExt,NomType,i1,i2,j1,j2); |
---|
| 1722 | if sub_value |
---|
| 1723 | filename_1=fullfile_uvmat(InputFile.RootPath_1,InputFile.SubDir_1,InputFile.RootFile_1,FileExt_1,NomType_1,i1_1,i2_1,j1_1,j2_1); |
---|
| 1724 | end |
---|
| 1725 | |
---|
| 1726 | %% refresh plots |
---|
| 1727 | errormsg=refresh_field(handles,filename,filename_1,i1,i2,j1,j2); |
---|
| 1728 | |
---|
| 1729 | %% update the index counters if the index move is successfull |
---|
| 1730 | if isempty(errormsg) |
---|
| 1731 | set(handles.i1,'String',num2stra(i1,NomType,1)); |
---|
| 1732 | if isequal(i2,i1) |
---|
| 1733 | set(handles.i2,'String',''); |
---|
| 1734 | else |
---|
| 1735 | set(handles.i2,'String',num2stra(i2,NomType,1)); |
---|
| 1736 | end |
---|
| 1737 | set(handles.j1,'String',num2stra(j1,NomType,2)); |
---|
| 1738 | if isequal(j2,j1) |
---|
| 1739 | set(handles.j2,'String',''); |
---|
| 1740 | else |
---|
| 1741 | set(handles.j2,'String',num2stra(j2,NomType,2)); |
---|
| 1742 | end |
---|
| 1743 | % [indices]=name_generator('',i1,j1,'',NomType,1,i2,j2,''); |
---|
| 1744 | indices=fullfile_uvmat('','','','',NomType,i1,i2,j1,j2); |
---|
| 1745 | set(handles.FileIndex,'String',indices); |
---|
| 1746 | if ~isempty(filename_1) |
---|
| 1747 | indices_1=fullfile_uvmat('','','','',NomType_1,i1_1,i2_1,j1_1,j2_1); |
---|
| 1748 | %indices_1=name_generator('',i1_1,j1_1,'',NomType_1,1,i2_1,j2_1,''); |
---|
| 1749 | set(handles.FileIndex_1,'String',indices_1); |
---|
| 1750 | end |
---|
| 1751 | if isequal(movie_status,1) |
---|
| 1752 | set(handles.movie_pair,'Value',1) |
---|
| 1753 | movie_pair_Callback(hObject, eventdata, handles); %reactivate moviepair if it was activated |
---|
| 1754 | end |
---|
| 1755 | end |
---|
| 1756 | |
---|
| 1757 | %------------------------------------------------------------------------ |
---|
| 1758 | % --- Executes on button press in movie_pair: create an alternating movie with two view |
---|
| 1759 | function movie_pair_Callback(hObject, eventdata, handles) |
---|
| 1760 | %------------------------------------------------------------------------ |
---|
| 1761 | %% stop movie action if the movie_pair button is off |
---|
| 1762 | if ~get(handles.movie_pair,'value') |
---|
| 1763 | set(handles.movie_pair,'BusyAction','Cancel')%stop movie pair if button is 'off' |
---|
| 1764 | set(handles.i2,'String','') |
---|
| 1765 | set(handles.j2,'String','') |
---|
| 1766 | return |
---|
| 1767 | else |
---|
| 1768 | set(handles.movie_pair,'BusyAction','queue') |
---|
| 1769 | end |
---|
| 1770 | |
---|
| 1771 | %% initialisation |
---|
| 1772 | set(handles.movie_pair,'BackgroundColor',[1 1 0])%paint the command button in yellow |
---|
| 1773 | drawnow |
---|
| 1774 | list_fields=get(handles.Fields,'String');% list menu fields |
---|
| 1775 | index_fields=get(handles.Fields,'Value');% selected string index |
---|
| 1776 | FieldName=list_fields{index_fields}; % selected field |
---|
| 1777 | UvData=get(handles.uvmat,'UserData'); |
---|
| 1778 | if isequal(FieldName,'image') |
---|
| 1779 | test_1=0; |
---|
| 1780 | [RootPath,SubDir,RootFile,FileIndices,Ext]=read_file_boxes(handles); |
---|
| 1781 | NomType=get(handles.NomType,'String'); |
---|
| 1782 | else |
---|
| 1783 | list_fields=get(handles.Fields_1,'String');% list menu fields |
---|
| 1784 | index_fields=get(handles.Fields_1,'Value');% selected string index |
---|
| 1785 | FieldName=list_fields{index_fields}; % selected field |
---|
| 1786 | if isequal(FieldName,'image') |
---|
| 1787 | test_1=1; |
---|
| 1788 | [RootPath,tild,RootFile,FileIndex_1,Ext,NomType]=read_file_boxes_1(handles); |
---|
| 1789 | else |
---|
| 1790 | msgbox_uvmat('ERROR','an image or movie must be first introduced as input') |
---|
| 1791 | set(handles.movie_pair,'BackgroundColor',[1 0 0])%paint the command button in red |
---|
| 1792 | set(handles.movie_pair,'Value',0) |
---|
| 1793 | return |
---|
| 1794 | end |
---|
| 1795 | end |
---|
| 1796 | num_i1=str2num(get(handles.i1,'String')); |
---|
| 1797 | num_j1=stra2num(get(handles.j1,'String')); |
---|
| 1798 | num_i2=str2num(get(handles.i2,'String')); |
---|
| 1799 | num_j2=stra2num(get(handles.j2,'String')); |
---|
| 1800 | if isempty(num_j2) |
---|
| 1801 | if isempty(num_i2) |
---|
| 1802 | msgbox_uvmat('ERROR', 'a second image index i2 or j2 is needed to show the pair as a movie') |
---|
| 1803 | set(handles.movie_pair,'BackgroundColor',[1 0 0])%paint the command button in red |
---|
| 1804 | set(handles.movie_pair,'Value',0) |
---|
| 1805 | return |
---|
| 1806 | else |
---|
| 1807 | num_j2=num_j1;%repeat the index i1 by default |
---|
| 1808 | end |
---|
| 1809 | end |
---|
| 1810 | if isempty(num_i2) |
---|
| 1811 | num_i2=num_i1;%repeat the index i1 by default |
---|
| 1812 | end |
---|
| 1813 | % imaname_1=name_generator(filebase,num_i2,num_j2,Ext,NomType); |
---|
| 1814 | imaname_1=fullfile_uvmat(RootPath,'',RootFile,Ext,NomType,num_i2,[],num_j2); |
---|
| 1815 | if ~exist(imaname_1,'file') |
---|
| 1816 | msgbox_uvmat('ERROR',['second input open (-) ' imaname_1 ' not found']); |
---|
| 1817 | set(handles.movie_pair,'BackgroundColor',[1 0 0])%paint the command button in red |
---|
| 1818 | set(handles.movie_pair,'Value',0) |
---|
| 1819 | return |
---|
| 1820 | end |
---|
| 1821 | |
---|
| 1822 | %% read the second image |
---|
| 1823 | Field.AName='image'; |
---|
| 1824 | if test_1 |
---|
| 1825 | Field_a=UvData.Field_1; |
---|
| 1826 | else |
---|
| 1827 | Field_a=UvData.Field; |
---|
| 1828 | end |
---|
| 1829 | Field_b.AX=Field_a.AX; |
---|
| 1830 | Field_b.AY=Field_a.AY; |
---|
| 1831 | % z index |
---|
| 1832 | nbslice=str2double(get(handles.nb_slice,'String')); |
---|
| 1833 | if ~isempty(nbslice) |
---|
| 1834 | Field_b.ZIndex=mod(num_i2-1,nbslice)+1; |
---|
| 1835 | end |
---|
| 1836 | Field_b.CoordUnit='pixel'; |
---|
| 1837 | |
---|
| 1838 | %% determine the input file type |
---|
| 1839 | if (test_1 && isfield(UvData,'MovieObject')&& numel(UvData.MovieObject>=2))||(~test_1 && ~isempty(UvData.MovieObject{1})) |
---|
| 1840 | FileType='movie'; |
---|
| 1841 | elseif isequal(lower(Ext),'.avi') |
---|
| 1842 | FileType='avi'; |
---|
| 1843 | elseif isequal(lower(Ext),'.vol') |
---|
| 1844 | FileType='vol'; |
---|
| 1845 | else |
---|
| 1846 | form=imformats(Ext(2:end)); |
---|
| 1847 | if ~isempty(form)% if the extension corresponds to an image format recognized by Matlab |
---|
| 1848 | if isequal(NomType,'*'); |
---|
| 1849 | FileType='multimage'; |
---|
| 1850 | else |
---|
| 1851 | FileType='image'; |
---|
| 1852 | end |
---|
| 1853 | end |
---|
| 1854 | end |
---|
| 1855 | switch FileType |
---|
| 1856 | case 'movie' |
---|
| 1857 | if test_1 |
---|
| 1858 | Field_b.A=read(UvData.MovieObject{2},num_i2); |
---|
| 1859 | else |
---|
| 1860 | Field_b.A=read(UvData.MovieObject{1},num_i2); |
---|
| 1861 | end |
---|
| 1862 | case 'avi' |
---|
| 1863 | mov=aviread(imaname_1,num_i2); |
---|
| 1864 | Field_b.A=frame2im(mov(1)); |
---|
| 1865 | case 'vol' |
---|
| 1866 | Field_b.A=imread(imaname_1); |
---|
| 1867 | case 'multimage' |
---|
| 1868 | Field_b.A=imread(imaname_1,num_i2); |
---|
| 1869 | case 'image' |
---|
| 1870 | Field_b.A=imread(imaname_1); |
---|
| 1871 | end |
---|
| 1872 | if get(handles.slices,'Value') |
---|
| 1873 | Field.ZIndex=str2double(get(handles.z_index,'String')); |
---|
| 1874 | end |
---|
| 1875 | |
---|
| 1876 | %px to phys or other transform on field |
---|
| 1877 | menu_transform=get(handles.transform_fct,'String'); |
---|
| 1878 | choice_value=get(handles.transform_fct,'Value'); |
---|
| 1879 | transform_name=menu_transform{choice_value};%name of the transform fct given by the menu 'transform_fct' |
---|
| 1880 | transform_list=get(handles.transform_fct,'UserData'); |
---|
| 1881 | transform=transform_list{choice_value}; |
---|
| 1882 | if ~isequal(transform_name,'') && ~isequal(transform_name,'px') |
---|
| 1883 | 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 |
---|
| 1884 | Field_a=transform(Field_a,UvData.XmlData{2});%the first field has been stored without transform |
---|
| 1885 | Field_b=transform(Field_b,UvData.XmlData{2}); |
---|
| 1886 | elseif ~test_1 && isfield(UvData,'XmlData') && isfield(UvData.XmlData{1},'GeometryCalib')%use geometry calib |
---|
| 1887 | Field_b=transform(Field_b,UvData.XmlData{1}); |
---|
| 1888 | end |
---|
| 1889 | end |
---|
| 1890 | |
---|
| 1891 | % make movie until movie speed is set to 0 or STOP is activated |
---|
| 1892 | hima=findobj(handles.axes3,'Tag','ima');% %handles.axes3 =main plotting window (A GENERALISER) |
---|
| 1893 | set(handles.STOP,'Visible','on') |
---|
| 1894 | set(handles.speed,'Visible','on') |
---|
| 1895 | set(handles.speed_txt,'Visible','on') |
---|
| 1896 | while get(handles.speed,'Value')~=0 && isequal(get(handles.movie_pair,'BusyAction'),'queue')%isequal(get(handles.run0,'BusyAction'),'queue'); % enable STOP command |
---|
| 1897 | % read and plot the series of images in non erase mode |
---|
| 1898 | set(hima,'CData',Field_b.A); |
---|
| 1899 | pause(1.02-get(handles.speed,'Value'));% wait for next image |
---|
| 1900 | set(hima,'CData',Field_a.A); |
---|
| 1901 | pause(1.02-get(handles.speed,'Value'));% wait for next image |
---|
| 1902 | end |
---|
| 1903 | set(handles.movie_pair,'BackgroundColor',[1 0 0])%paint the command button in red |
---|
| 1904 | set(handles.movie_pair,'Value',0) |
---|
| 1905 | |
---|
| 1906 | %------------------------------------------------------------------------ |
---|
| 1907 | % --- Executes on button press in run0. |
---|
| 1908 | function run0_Callback(hObject, eventdata, handles) |
---|
| 1909 | %------------------------------------------------------------------------ |
---|
| 1910 | set(handles.run0,'BackgroundColor',[1 1 0])%paint the command button in yellow |
---|
| 1911 | drawnow |
---|
| 1912 | [RootPath,SubDir,RootFile,FileIndices,FileExt]=read_file_boxes(handles); |
---|
| 1913 | filename=[fullfile(RootPath,SubDir,RootFile) FileIndices FileExt]; |
---|
| 1914 | filename_1=[];%default |
---|
| 1915 | if get(handles.SubField,'Value') |
---|
| 1916 | [RootPath_1,SubDir_1,RootFile_1,FileIndices_1,FileExt_1]=read_file_boxes_1(handles); |
---|
| 1917 | filename_1=[fullfile(RootPath_1,SubDir_1,RootFile_1) FileIndices_1 FileExt_1]; |
---|
| 1918 | end |
---|
| 1919 | num_i1=stra2num(get(handles.i1,'String')); |
---|
| 1920 | num_i2=stra2num(get(handles.i2,'String')); |
---|
| 1921 | num_j1=stra2num(get(handles.j1,'String')); |
---|
| 1922 | num_j2=stra2num(get(handles.j2,'String')); |
---|
| 1923 | |
---|
| 1924 | errormsg=refresh_field(handles,filename,filename_1,num_i1,num_i2,num_j1,num_j2); |
---|
| 1925 | |
---|
| 1926 | if ~isempty(errormsg) |
---|
| 1927 | msgbox_uvmat('ERROR',errormsg); |
---|
| 1928 | else |
---|
| 1929 | set(handles.i1,'BackgroundColor',[1 1 1]) |
---|
| 1930 | set(handles.i2,'BackgroundColor',[1 1 1]) |
---|
| 1931 | set(handles.j1,'BackgroundColor',[1 1 1]) |
---|
| 1932 | set(handles.j2,'BackgroundColor',[1 1 1]) |
---|
| 1933 | set(handles.FileIndex,'BackgroundColor',[1 1 1]) |
---|
| 1934 | set(handles.FileIndex_1,'BackgroundColor',[1 1 1]) |
---|
| 1935 | end |
---|
| 1936 | set(handles.run0,'BackgroundColor',[1 0 0]) |
---|
| 1937 | |
---|
| 1938 | |
---|
| 1939 | %------------------------------------------------------------------------ |
---|
| 1940 | % --- read the input files and refresh all the plots, including projection. |
---|
| 1941 | % OUTPUT: |
---|
| 1942 | % errormsg: error message char string =[] by default |
---|
| 1943 | % INPUT: |
---|
| 1944 | % filename: first input file (=[] in the absence of input file) |
---|
| 1945 | % filename_1: second input file (=[] in the asbsenc of secodn input file) |
---|
| 1946 | % num_i1,num_i2,num_j1,num_j2; frame indices |
---|
| 1947 | % Field: structure describing an optional input field (then replace the input file) |
---|
[397] | 1948 | |
---|
[387] | 1949 | function errormsg=refresh_field(handles,filename,filename_1,num_i1,num_i2,num_j1,num_j2,Field) |
---|
| 1950 | %------------------------------------------------------------------------ |
---|
| 1951 | |
---|
| 1952 | %% initialisation |
---|
| 1953 | abstime=[]; |
---|
| 1954 | abstime_1=[]; |
---|
| 1955 | dt=[]; |
---|
| 1956 | if ~exist('Field','var') |
---|
| 1957 | Field={}; |
---|
| 1958 | end |
---|
| 1959 | UvData=get(handles.uvmat,'UserData'); |
---|
| 1960 | if ishandle(handles.UVMAT_title) %remove title panel on uvmat |
---|
| 1961 | delete(handles.UVMAT_title) |
---|
| 1962 | end |
---|
| 1963 | |
---|
| 1964 | %% determine the main input file information for action |
---|
| 1965 | FileType=[];%default |
---|
| 1966 | if ~exist(filename,'file') |
---|
| 1967 | errormsg=['input file ' filename ' does not exist']; |
---|
| 1968 | return |
---|
| 1969 | end |
---|
| 1970 | NomType=get(handles.NomType,'String'); |
---|
| 1971 | % NomType=get(handles.FileIndex,'UserData'); |
---|
| 1972 | %update the z position index |
---|
| 1973 | nbslice_str=get(handles.nb_slice,'String'); |
---|
| 1974 | if isequal(nbslice_str,'volume')%NOT USED |
---|
| 1975 | z_index=num_j1; |
---|
| 1976 | set(handles.z_index,'String',num2str(z_index)) |
---|
| 1977 | else |
---|
| 1978 | nbslice=str2num(nbslice_str); |
---|
| 1979 | z_index=mod(num_i1-1,nbslice)+1; |
---|
| 1980 | set(handles.z_index,'String',num2str(z_index)) |
---|
| 1981 | end |
---|
| 1982 | % refresh menu for save_mask if relevant |
---|
| 1983 | masknumber=get(handles.masklevel,'String'); |
---|
| 1984 | if length(masknumber)>=z_index |
---|
| 1985 | set(handles.masklevel,'Value',z_index) |
---|
| 1986 | end |
---|
| 1987 | |
---|
| 1988 | %% read the first input field if a filename has been introduced |
---|
| 1989 | if ~isempty(filename) |
---|
| 1990 | ObjectName=filename; |
---|
| 1991 | FieldName=[];%default |
---|
| 1992 | VelType=[];%default |
---|
[399] | 1993 | % FileExt=get(handles.FileExt,'String'); |
---|
[387] | 1994 | FileType=UvData.FileType{1}; |
---|
| 1995 | switch FileType |
---|
| 1996 | % if strcmp(Ext,'.nc')||strcmp(Ext,'.cdf') |
---|
| 1997 | case {'civx','civdata','netcdf'}; |
---|
| 1998 | list_fields=get(handles.Fields,'String');% list menu fields |
---|
| 1999 | index_fields=get(handles.Fields,'Value');% selected string index |
---|
| 2000 | FieldName= list_fields{index_fields}; % selected field |
---|
| 2001 | if ~strcmp(FieldName,'get_field...') |
---|
[389] | 2002 | if get(handles.FixVelType,'Value') |
---|
| 2003 | VelTypeList=get(handles.VelType,'String'); |
---|
| 2004 | VelType=VelTypeList{get(handles.VelType,'Value')}; |
---|
| 2005 | % VelType=setfield(handles);% read the velocity type. |
---|
[387] | 2006 | end |
---|
| 2007 | end |
---|
| 2008 | if strcmp(FieldName,'velocity') |
---|
| 2009 | list_code=get(handles.ListColorCode,'String');% list menu fields |
---|
| 2010 | index_code=get(handles.ListColorCode,'Value');% selected string index |
---|
| 2011 | if ~strcmp(list_code{index_code},'black') && ~strcmp(list_code{index_code},'white') |
---|
| 2012 | list_code=get(handles.ListColorScalar,'String');% list menu fields |
---|
| 2013 | index_code=get(handles.ListColorScalar,'Value');% selected string index |
---|
| 2014 | ParamIn.ColorVar= list_code{index_code}; % selected field |
---|
| 2015 | end |
---|
| 2016 | end |
---|
| 2017 | case 'video' |
---|
| 2018 | ObjectName=UvData.MovieObject{1}; |
---|
| 2019 | case 'vol' %TODO: update |
---|
| 2020 | if isfield(UvData.XmlData,'Npy') && isfield(UvData.XmlData,'Npx') |
---|
| 2021 | ParamIn.Npy=UvData.XmlData.Npy; |
---|
| 2022 | ParamIn.Npx=UvData.XmlData.Npx; |
---|
| 2023 | else |
---|
| 2024 | errormsg='Npx and Npy need to be defined in the xml file for volume images .vol'; |
---|
| 2025 | return |
---|
| 2026 | end |
---|
| 2027 | end |
---|
| 2028 | ParamIn.FieldName=FieldName; |
---|
| 2029 | ParamIn.VelType=VelType; |
---|
| 2030 | ParamIn.GUIName='get_field'; |
---|
| 2031 | [Field{1},ParamOut,errormsg] = read_field(ObjectName,FileType,ParamIn,num_i1); |
---|
| 2032 | if ~isempty(errormsg) |
---|
| 2033 | errormsg=['error in reading ' filename ': ' errormsg]; |
---|
| 2034 | return |
---|
| 2035 | end |
---|
| 2036 | if isfield(ParamOut,'Npx')&& isfield(ParamOut,'Npy') |
---|
| 2037 | set(handles.num_Npx,'String',num2str(ParamOut.Npx));% display image size on the interface |
---|
| 2038 | set(handles.num_Npy,'String',num2str(ParamOut.Npy)); |
---|
| 2039 | end |
---|
| 2040 | if isfield(ParamOut,'TimeIndex') |
---|
| 2041 | set(handles.i1,'String',num2str(ParamOut.TimeIndex)) |
---|
| 2042 | end |
---|
| 2043 | if isfield(ParamOut,'TimeValue') |
---|
| 2044 | Field{1}.Time=ParamOut.TimeValue; |
---|
| 2045 | end |
---|
| 2046 | end |
---|
| 2047 | |
---|
| 2048 | %% choose a second field filename_1 if defined |
---|
| 2049 | VelType_1=[];%default |
---|
| 2050 | FieldName_1=[]; |
---|
| 2051 | ParamOut_1=[]; |
---|
| 2052 | if ~isempty(filename_1) |
---|
| 2053 | if ~exist(filename_1,'file') |
---|
| 2054 | errormsg=['second file ' filename_1 ' does not exist']; |
---|
| 2055 | return |
---|
| 2056 | end |
---|
| 2057 | Name=filename_1; |
---|
| 2058 | FileType_1=UvData.FileType{2}; |
---|
| 2059 | switch FileType_1 |
---|
| 2060 | % if strcmp(Ext,'.nc')||strcmp(Ext,'.cdf') |
---|
| 2061 | case {'civx','civdata','netcdf'}; |
---|
| 2062 | list_fields=get(handles.Fields_1,'String');% list menu fields |
---|
[389] | 2063 | FieldName_1= list_fields{get(handles.Fields_1,'Value')}; % selected field |
---|
[387] | 2064 | if ~strcmp(FieldName,'get_field...') |
---|
[389] | 2065 | if get(handles.FixVelType,'Value') |
---|
| 2066 | VelTypeList=get(handles.VelType_1,'String'); |
---|
| 2067 | VelType_1=VelTypeList{get(handles.VelType_1,'Value')};% read the velocity type. |
---|
| 2068 | % VelType_1=setfield(handles);% read the velocity type. |
---|
[387] | 2069 | end |
---|
| 2070 | end |
---|
| 2071 | if strcmp(FieldName_1,'velocity') |
---|
| 2072 | list_code=get(handles.ListColorCode,'String');% list menu fields |
---|
| 2073 | index_code=get(handles.ListColorCode,'Value');% selected string index |
---|
| 2074 | if ~strcmp(list_code{index_code},'black') && ~strcmp(list_code{index_code},'white') |
---|
| 2075 | list_code=get(handles.ListColorScalar,'String');% list menu fields |
---|
| 2076 | index_code=get(handles.ListColorScalar,'Value');% selected string index |
---|
| 2077 | ParamIn.ColorVar= list_code{index_code}; % selected field |
---|
| 2078 | end |
---|
| 2079 | end |
---|
| 2080 | case 'video' |
---|
| 2081 | Name=UvData.MovieObject{2}; |
---|
| 2082 | case 'vol' %TODO: update |
---|
| 2083 | if isfield(UvData.XmlData,'Npy') && isfield(UvData.XmlData,'Npx') |
---|
| 2084 | ParamIn.Npy=UvData.XmlData.Npy; |
---|
| 2085 | ParamIn.Npx=UvData.XmlData.Npx; |
---|
| 2086 | else |
---|
| 2087 | errormsg='Npx and Npy need to be defined in the xml file for volume images .vol'; |
---|
| 2088 | return |
---|
| 2089 | end |
---|
| 2090 | end |
---|
| 2091 | NomType_1=get(handles.NomType_1,'String'); |
---|
| 2092 | test_keepdata_1=0;% test for keeping the previous stored data if the input files are unchanged |
---|
| 2093 | if ~isequal(NomType_1,'*')%in case of a series of files (not avi movie) |
---|
[389] | 2094 | if isfield(UvData,'filename_1')%&& isfield(UvData,'VelType_1') && isfield(UvData,'FieldName_1') |
---|
| 2095 | test_keepdata_1= strcmp(filename_1,UvData.filename_1) ;%&& strcmp(FieldName_1,UvData.FieldName_1); |
---|
[387] | 2096 | end |
---|
| 2097 | end |
---|
| 2098 | if test_keepdata_1 |
---|
[389] | 2099 | Field{2}=UvData.Field_1;% keep the stored field |
---|
[387] | 2100 | else |
---|
| 2101 | ParamIn.FieldName=FieldName_1; |
---|
| 2102 | ParamIn.VelType=VelType_1; |
---|
| 2103 | ParamIn.GUIName='get_field_1'; |
---|
| 2104 | [Field{2},ParamOut_1,errormsg] = read_field(Name,FileType_1,ParamIn,num_i1); |
---|
| 2105 | if ~isempty(errormsg) |
---|
| 2106 | errormsg=['error in reading ' FieldName_1 ' in ' filename_1 ': ' errormsg]; |
---|
| 2107 | return |
---|
| 2108 | end |
---|
| 2109 | UvData.Field_1=Field{2}; %store the second field for possible use at next RUN |
---|
| 2110 | end |
---|
| 2111 | % end |
---|
| 2112 | end |
---|
| 2113 | |
---|
| 2114 | %% update uvmat interface |
---|
| 2115 | if isfield(ParamOut,'Npx') |
---|
| 2116 | set(handles.num_Npx,'String',num2str(ParamOut.Npx));% display image size on the interface |
---|
| 2117 | set(handles.num_Npy,'String',num2str(ParamOut.Npy)); |
---|
| 2118 | elseif isfield(ParamOut_1,'Npx') |
---|
| 2119 | set(handles.num_Npx,'String',num2str(ParamOut_1.Npx));% display image size on the interface |
---|
| 2120 | set(handles.num_Npy,'String',num2str(ParamOut_1.Npy)); |
---|
| 2121 | end |
---|
| 2122 | |
---|
| 2123 | %% update the display menu for the first velocity type (first menuline) |
---|
| 2124 | test_veltype=0; |
---|
| 2125 | % if ~isequal(FileType,'netcdf')|| isequal(FieldName,'get_field...') |
---|
| 2126 | if (strcmp(FileType,'civx')||strcmp(FileType,'civdata'))&& ~strcmp(FieldName,'get_field...') |
---|
| 2127 | test_veltype=1; |
---|
| 2128 | set(handles.VelType,'Visible','on') |
---|
| 2129 | set(handles.VelType_1,'Visible','on') |
---|
| 2130 | set(handles.FixVelType,'Visible','on') |
---|
| 2131 | menu=set_veltype_display(ParamOut.CivStage,FileType); |
---|
| 2132 | index_menu=strcmp(ParamOut.VelType,menu);%look for VelType in the menu |
---|
| 2133 | index_val=find(index_menu,1); |
---|
| 2134 | if isempty(index_val) |
---|
| 2135 | index_val=1; |
---|
| 2136 | end |
---|
| 2137 | set(handles.VelType,'Value',index_val) |
---|
| 2138 | if ~get(handles.SubField,'value') |
---|
| 2139 | set(handles.VelType,'String',menu) |
---|
| 2140 | set(handles.VelType_1,'Value',1) |
---|
| 2141 | set(handles.VelType_1,'String',[{''};menu]) |
---|
| 2142 | end |
---|
| 2143 | else |
---|
| 2144 | set(handles.VelType,'Visible','off') |
---|
| 2145 | end |
---|
| 2146 | field_index=strcmp(ParamOut.FieldName,ParamOut.FieldList); |
---|
| 2147 | set(handles.Fields,'String',ParamOut.FieldList); %update the field menu |
---|
| 2148 | set(handles.Fields,'Value',find(field_index,1)) |
---|
| 2149 | |
---|
| 2150 | %% update the display menu for the second velocity type (second menuline) |
---|
| 2151 | test_veltype_1=0; |
---|
| 2152 | if isempty(filename_1) |
---|
| 2153 | set(handles.Fields_1,'Value',1); %update the field menu |
---|
| 2154 | set(handles.Fields_1,'String',[{''};ParamOut.FieldList]); %update the field menu |
---|
| 2155 | else |
---|
[389] | 2156 | if (~strcmp(FileType_1,'netcdf')&&~strcmp(FileType_1,'civdata')&&~strcmp(FileType_1,'civx'))|| isequal(FieldName_1,'get_field...') |
---|
[387] | 2157 | set(handles.VelType_1,'Visible','off') |
---|
| 2158 | else |
---|
| 2159 | test_veltype_1=1; |
---|
| 2160 | set(handles.VelType_1,'Visible','on') |
---|
| 2161 | if ~get(handles.FixVelType,'Value') |
---|
| 2162 | menu=set_veltype_display(ParamOut_1.CivStage); |
---|
| 2163 | index_menu=strcmp(ParamOut_1.VelType,menu); |
---|
| 2164 | set(handles.VelType_1,'Value',1+find(index_menu,1)) |
---|
| 2165 | set(handles.VelType_1,'String',[{''};menu]) |
---|
| 2166 | end |
---|
| 2167 | end |
---|
| 2168 | end |
---|
| 2169 | if test_veltype||test_veltype_1 |
---|
| 2170 | set(handles.FixVelType,'Visible','on') |
---|
| 2171 | else |
---|
| 2172 | set(handles.FixVelType,'Visible','off') |
---|
| 2173 | end |
---|
| 2174 | |
---|
| 2175 | %% introduce w as background image by default for a new series (only for nbdim=2) |
---|
| 2176 | if ~isfield(UvData,'NewSeries') |
---|
| 2177 | UvData.NewSeries=1; |
---|
| 2178 | end |
---|
| 2179 | %put W as background image by default if NbDim=2: |
---|
| 2180 | if UvData.NewSeries && isequal(get(handles.SubField,'Value'),0) && isfield(Field{1},'W') && ~isempty(Field{1}.W) && ~isequal(Field{1}.NbDim,3); |
---|
| 2181 | set(handles.SubField,'Value',1); |
---|
| 2182 | set(handles.RootPath_1,'String','"') |
---|
| 2183 | set(handles.RootFile_1,'String','"') |
---|
| 2184 | set(handles.SubDir_1,'String','"'); |
---|
| 2185 | indices=fullfile_uvmat('','','','',NomType,num_i1,num_i2,num_j1,num_j2); |
---|
| 2186 | set(handles.FileIndex_1,'String',indices) |
---|
| 2187 | set(handles.FileExt_1,'String','"'); |
---|
| 2188 | set(handles.Fields_1,'Visible','on'); |
---|
| 2189 | set(handles.Fields_1,'Visible','on'); |
---|
| 2190 | set(handles.RootPath_1,'Visible','on') |
---|
| 2191 | set(handles.RootFile_1,'Visible','on') |
---|
| 2192 | set(handles.SubDir_1,'Visible','on'); |
---|
| 2193 | set(handles.FileIndex_1,'Visible','on'); |
---|
| 2194 | set(handles.FileExt_1,'Visible','on'); |
---|
| 2195 | set(handles.Fields_1,'Visible','on'); |
---|
| 2196 | Field{1}.AName='w'; |
---|
| 2197 | end |
---|
| 2198 | |
---|
| 2199 | %% store the current open names, fields and vel types in uvmat interface |
---|
| 2200 | UvData.filename_1=filename_1; |
---|
| 2201 | |
---|
| 2202 | %% apply coordinate transform or other user fct |
---|
| 2203 | XmlData=[];%default |
---|
| 2204 | XmlData_1=[];%default |
---|
| 2205 | if isfield(UvData,'XmlData')%use geometry calib recorded from the ImaDoc xml file as first priority |
---|
| 2206 | XmlData=UvData.XmlData{1}; |
---|
| 2207 | if numel(UvData.XmlData)==2 |
---|
| 2208 | XmlData_1=UvData.XmlData{2}; |
---|
| 2209 | end |
---|
| 2210 | end |
---|
| 2211 | choice_value=get(handles.transform_fct,'Value'); |
---|
| 2212 | transform_list=get(handles.transform_fct,'UserData'); |
---|
| 2213 | transform=transform_list{choice_value};%selected function handles |
---|
| 2214 | % z index |
---|
| 2215 | if ~isempty(filename) |
---|
| 2216 | Field{1}.ZIndex=z_index; |
---|
| 2217 | end |
---|
| 2218 | %px to phys or other transform on field |
---|
[389] | 2219 | if ~isempty(transform) |
---|
[387] | 2220 | if length(Field)>=2 |
---|
| 2221 | Field{2}.ZIndex=z_index; |
---|
| 2222 | [Field{1},Field{2}]=transform(Field{1},XmlData,Field{2},XmlData_1); |
---|
| 2223 | if isempty(Field{2}) |
---|
| 2224 | Field(2)=[]; |
---|
| 2225 | end |
---|
| 2226 | else |
---|
| 2227 | Field{1}=transform(Field{1},XmlData); |
---|
| 2228 | end |
---|
[389] | 2229 | %% update tps in phys coordinates if needed |
---|
| 2230 | if (strcmp(VelType,'filter1')||strcmp(VelType,'filter2'))&& strcmp(FileType,'civdata')&&isfield(Field{1},'U')&& isfield(Field{1},'V') |
---|
| 2231 | Field{1}.X=Field{1}.X(Field{1}.FF==0); |
---|
| 2232 | Field{1}.Y=Field{1}.Y(Field{1}.FF==0); |
---|
| 2233 | Field{1}.U=Field{1}.U(Field{1}.FF==0); |
---|
| 2234 | Field{1}.V=Field{1}.V(Field{1}.FF==0); |
---|
| 2235 | [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); |
---|
| 2236 | end |
---|
| 2237 | if numel(Field)==2 && ~test_keepdata_1 && isequal(FileType_1(1:3),'civ') && ~isequal(ParamOut_1.FieldName,'get_field...')%&&~isempty(FieldName_1) |
---|
| 2238 | %update tps in phys coordinates if needed |
---|
| 2239 | if (strcmp(VelType_1,'filter1')||strcmp(VelType_1,'filter2'))&& strcmp(FileType_1,'civdata')&&isfield(Field{2},'U')&& isfield(Field{2},'V') |
---|
| 2240 | Field{2}.X=Field{2}.X(Field{2}.FF==0); |
---|
| 2241 | Field{2}.Y=Field{1}.Y(Field{2}.FF==0); |
---|
| 2242 | Field{2}.U=Field{1}.U(Field{2}.FF==0); |
---|
| 2243 | Field{2}.V=Field{1}.V(Field{2}.FF==0); |
---|
| 2244 | [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); |
---|
| 2245 | end |
---|
| 2246 | end |
---|
[387] | 2247 | end |
---|
| 2248 | |
---|
| 2249 | %% calculate scalar |
---|
[397] | 2250 | % if (strcmp(FileType,'civdata')||strcmp(FileType,'civx'))&&~strcmp(ParamOut.FieldName,'velocity')&& ~strcmp(ParamOut.FieldName,'get_field...');% ~isequal(ParamOut.CivStage,0)%&&~isempty(FieldName)% |
---|
| 2251 | % Field{1}=calc_field([{ParamOut.FieldName} {ParamOut.ColorVar}],Field{1}); |
---|
| 2252 | % end |
---|
| 2253 | % if numel(Field)==2 && ~test_keepdata_1 && (strcmp(FileType,'civdata')||strcmp(FileType,'civx')) &&~strcmp(ParamOut.FieldName,'velocity') && ~strcmp(ParamOut_1.FieldName,'get_field...') |
---|
| 2254 | % Field{2}=calc_field([{ParamOut_1.FieldName} {ParamOut_1.ColorVar}],Field{2}); |
---|
| 2255 | % end |
---|
[387] | 2256 | |
---|
| 2257 | %% combine the two input fields (e.g. substract velocity fields) |
---|
| 2258 | if numel(Field)==2 |
---|
[402] | 2259 | [UvData.Field,errormsg]=sub_field(Field{1},Field{2}); |
---|
[387] | 2260 | else |
---|
| 2261 | UvData.Field=Field{1}; |
---|
| 2262 | end |
---|
[402] | 2263 | if ~isempty(errormsg) |
---|
| 2264 | errormsg=['error in uvmat/refresh_field/sub_field:' errormsg]; |
---|
| 2265 | return |
---|
| 2266 | end |
---|
[399] | 2267 | UvData.Field.FieldList={FieldName}; % TODO: to generalise, used for proj_field with tps interpolation |
---|
[387] | 2268 | |
---|
| 2269 | %% get bounds and mesh (needed for mouse action and to open set_object) |
---|
| 2270 | test_x=0; |
---|
| 2271 | test_z=0;% test for unstructured z coordinate |
---|
| 2272 | [UvData.Field,errormsg]=check_field_structure(UvData.Field); |
---|
| 2273 | if ~isempty(errormsg) |
---|
| 2274 | errormsg=['error in uvmat/refresh_field/check_field_structure: ' errormsg]; |
---|
| 2275 | return |
---|
| 2276 | end |
---|
| 2277 | [CellVarIndex,NbDim,VarType,errormsg]=find_field_indices(UvData.Field); |
---|
| 2278 | if ~isempty(errormsg) |
---|
| 2279 | errormsg=['error in uvmat/refresh_field/find_field_indices: ' errormsg]; |
---|
| 2280 | return |
---|
| 2281 | end |
---|
| 2282 | [NbDim,imax]=max(NbDim); |
---|
| 2283 | if isfield(UvData.Field,'NbDim') |
---|
| 2284 | NbDim=UvData.Field.NbDim;% deal with plane fields containing z coordinates |
---|
| 2285 | end |
---|
| 2286 | if ~isempty(VarType{imax}.coord_x) && ~isempty(VarType{imax}.coord_y) %unstructured coordinates |
---|
| 2287 | XName=UvData.Field.ListVarName{VarType{imax}.coord_x}; |
---|
| 2288 | YName=UvData.Field.ListVarName{VarType{imax}.coord_y}; |
---|
| 2289 | eval(['nbvec=length(UvData.Field.' XName ');'])%nbre of measurement points (e.g. vectors) |
---|
| 2290 | test_x=1;%test for unstructured coordinates |
---|
| 2291 | if ~isempty(VarType{imax}.coord_z) |
---|
| 2292 | ZName=UvData.Field.ListVarName{VarType{imax}.coord_z}; |
---|
| 2293 | else |
---|
| 2294 | NbDim=2; |
---|
| 2295 | end |
---|
| 2296 | elseif numel(VarType)>=imax && numel(VarType{imax}.coord)>=NbDim && VarType{imax}.coord(NbDim)>0 %structured coordinate |
---|
| 2297 | XName=UvData.Field.ListVarName{VarType{imax}.coord(NbDim)}; |
---|
| 2298 | if NbDim>1 |
---|
| 2299 | YName=UvData.Field.ListVarName{VarType{imax}.coord(NbDim-1)}; %structured coordinates |
---|
| 2300 | end |
---|
| 2301 | end |
---|
| 2302 | if NbDim==3 |
---|
| 2303 | if ~test_x |
---|
| 2304 | ZName=UvData.Field.ListVarName{VarType{imax}.coord(1)};%structured coordinates in 3D |
---|
| 2305 | end |
---|
| 2306 | eval(['ZMax=max(UvData.Field.' ZName ');']) |
---|
| 2307 | eval(['ZMin=min(UvData.Field.' ZName ');']) |
---|
| 2308 | UvData.Field.ZMax=ZMax; |
---|
| 2309 | UvData.Field.ZMin=ZMin; |
---|
| 2310 | test_z=1; |
---|
| 2311 | if isequal(ZMin,ZMax)%no z dependency |
---|
| 2312 | NbDim=2; |
---|
| 2313 | test_z=0; |
---|
| 2314 | end |
---|
| 2315 | end |
---|
| 2316 | if exist('XName','var') |
---|
| 2317 | eval(['XMax=max(max(UvData.Field.' XName '));']) |
---|
| 2318 | eval(['XMin=min(min(UvData.Field.' XName '));']) |
---|
| 2319 | UvData.Field.NbDim=NbDim; |
---|
| 2320 | UvData.Field.XMax=XMax; |
---|
| 2321 | UvData.Field.XMin=XMin; |
---|
| 2322 | if NbDim >1 |
---|
| 2323 | eval(['YMax=max(max(UvData.Field.' YName '));']) |
---|
| 2324 | eval(['YMin=min(min(UvData.Field.' YName '));']) |
---|
| 2325 | UvData.Field.YMax=YMax; |
---|
| 2326 | UvData.Field.YMin=YMin; |
---|
| 2327 | end |
---|
| 2328 | eval(['nbvec=length(UvData.Field.' XName ');']) |
---|
| 2329 | if test_x %unstructured coordinates |
---|
| 2330 | if test_z |
---|
| 2331 | UvData.Field.Mesh=((XMax-XMin)*(YMax-YMin)*(ZMax-ZMin))/nbvec;% volume per vector |
---|
| 2332 | UvData.Field.Mesh=(UvData.Field.Mesh)^(1/3); |
---|
| 2333 | else |
---|
| 2334 | UvData.Field.Mesh=sqrt((XMax-XMin)*(YMax-YMin)/nbvec);%2D |
---|
| 2335 | end |
---|
| 2336 | else |
---|
| 2337 | VarIndex=CellVarIndex{imax}; % list of variable indices |
---|
| 2338 | DimIndex=UvData.Field.VarDimIndex{VarIndex(1)}; %list of dim indices for the variable |
---|
| 2339 | nbpoints_x=UvData.Field.DimValue(DimIndex(NbDim)); |
---|
| 2340 | DX=(XMax-XMin)/(nbpoints_x-1); |
---|
| 2341 | if NbDim >1 |
---|
| 2342 | nbpoints_y=UvData.Field.DimValue(DimIndex(NbDim-1)); |
---|
| 2343 | DY=(YMax-YMin)/(nbpoints_y-1); |
---|
| 2344 | end |
---|
| 2345 | if NbDim==3 |
---|
| 2346 | nbpoints_z=UvData.Field.DimValue(DimIndex(1)); |
---|
| 2347 | DZ=(ZMax-ZMin)/(nbpoints_z-1); |
---|
| 2348 | UvData.Field.Mesh=(DX*DY*DZ)^(1/3); |
---|
| 2349 | UvData.Field.ZMax=ZMax; |
---|
| 2350 | UvData.Field.ZMin=ZMin; |
---|
| 2351 | else |
---|
| 2352 | UvData.Field.Mesh=DX;%sqrt(DX*DY); |
---|
| 2353 | end |
---|
| 2354 | end |
---|
| 2355 | end |
---|
| 2356 | |
---|
| 2357 | %% 3D case (menuvolume) |
---|
| 2358 | if NbDim==3% && UvData.NewSeries |
---|
| 2359 | test_set_object=1; |
---|
| 2360 | hset_object=findobj(allchild(0),'tag','set_object');% look for the set_object GUI |
---|
| 2361 | ZBounds(1)=UvData.Field.ZMin; %minimum for the Z slider |
---|
| 2362 | ZBounds(2)=UvData.Field.ZMax;%maximum for the Z slider |
---|
| 2363 | if ~isempty(hset_object) %if set_object is detected |
---|
| 2364 | % hhset_object=guidata(hset_object); |
---|
| 2365 | % % ZBounds_old(1)=get(hhset_object.z_slider,'Min'); |
---|
| 2366 | % % ZBounds_old(2)=get(hhset_object.z_slider,'Max'); |
---|
| 2367 | % % if isequal(ZBounds_old,ZBounds) |
---|
| 2368 | % test_set_object=0;% do not refresh the GUI set_object |
---|
| 2369 | % else |
---|
| 2370 | delete(hset_object);% delete the GUI set_object if it does not fit |
---|
| 2371 | % end |
---|
| 2372 | end |
---|
| 2373 | if test_set_object% reinitiate the GUI set_object |
---|
| 2374 | 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 |
---|
| 2375 | UvData.Object{1}.Type='plane';%main plotting plane |
---|
| 2376 | UvData.Object{1}.ProjMode='projection';%main plotting plane |
---|
| 2377 | UvData.Object{1}.DisplayHandle_uvmat=[]; %plane not visible in uvmat |
---|
| 2378 | UvData.Object{1}.NbDim=NbDim;%test for 3D objects |
---|
| 2379 | UvData.Object{1}.RangeZ=UvData.Field.Mesh;%main plotting plane |
---|
| 2380 | UvData.Object{1}.Coord(1,3)=(UvData.Field.ZMin+UvData.Field.ZMax)/2;%section at a middle plane chosen |
---|
| 2381 | UvData.Object{1}.Angle=[0 0 0]; |
---|
| 2382 | % UvData.Object{1}.Theta=0; |
---|
| 2383 | % UvData.Object{1}.Psi=0; |
---|
| 2384 | UvData.Object{1}.HandlesDisplay=plot(0,0,'Tag','proj_object');% A REVOIR |
---|
| 2385 | % PlotHandles=get_plot_handles(handles); |
---|
| 2386 | UvData.Object{1}.Name='1-PLANE'; |
---|
| 2387 | UvData.Object{1}.enable_plot=1; |
---|
| 2388 | set_object(UvData.Object{1},handles,ZBounds); |
---|
| 2389 | set(handles.ListObject,'Value',1); |
---|
| 2390 | set(handles.ListObject,'String',{'1-PLANE'}); |
---|
| 2391 | set(handles.edit_object,'Value',1)% put the plane in edit mode to enable the z cursor |
---|
| 2392 | edit_object_Callback([],[], handles) |
---|
| 2393 | end |
---|
| 2394 | %multilevel case (single menuplane in a 3D space) |
---|
| 2395 | elseif isfield(UvData,'Z') |
---|
| 2396 | if isfield(UvData,'CoordType')&& isequal(UvData.CoordType,'phys') && isfield(UvData,'XmlData') |
---|
| 2397 | XmlData=UvData.XmlData{1}; |
---|
| 2398 | if isfield(XmlData,'PlanePos') |
---|
| 2399 | UvData.Object{1}.Coord=XmlData.PlanePos(UvData.ZIndex,:); |
---|
| 2400 | end |
---|
| 2401 | if isfield(XmlData,'PlaneAngle') |
---|
| 2402 | siz=size(XmlData.PlaneAngle); |
---|
| 2403 | indangle=min(siz(1),UvData.ZIndex);%take first angle if a single angle is defined (translating scanning) |
---|
| 2404 | UvData.Object{1}.PlaneAngle=XmlData.PlaneAngle(indangle,:); |
---|
| 2405 | end |
---|
| 2406 | elseif isfield(UvData,'ZIndex') |
---|
| 2407 | UvData.Object{1}.ZObject=UvData.ZIndex; |
---|
| 2408 | end |
---|
| 2409 | else |
---|
[389] | 2410 | % % create a default projection |
---|
| 2411 | % UvData.Object{1}.ProjMode='projection';%main plotting plane |
---|
| 2412 | % UvData.Object{1}.DisplayHandle_uvmat=[]; %plane not visible in uvmat |
---|
| 2413 | % set(handles.ListObject,'Value',1); |
---|
| 2414 | % list_object=get(handles.ListObject,'String'); |
---|
| 2415 | % if isempty(list_object) |
---|
| 2416 | % list_object={''}; |
---|
| 2417 | % elseif ~isempty(list_object{1}) |
---|
| 2418 | % list_object=[{''};list_object]; |
---|
| 2419 | % end |
---|
| 2420 | % set(handles.ListObject,'String',list_object); |
---|
| 2421 | % % set(handles.list_object_2,'String',list_object); |
---|
[387] | 2422 | end |
---|
| 2423 | testnewseries=UvData.NewSeries; |
---|
| 2424 | UvData.NewSeries=0;% put to 0 the test for a new field series (set by RootPath_callback) |
---|
| 2425 | set(handles.uvmat,'UserData',UvData) |
---|
| 2426 | |
---|
| 2427 | %% reset the min and max of scalar if only the mask is displayed(TODO: check the need) |
---|
| 2428 | if isfield(UvData,'Mask')&& ~isfield(UvData,'A') |
---|
| 2429 | set(handles.num_MinA,'String','0') |
---|
| 2430 | set(handles.num_MaxA,'String','255') |
---|
| 2431 | end |
---|
| 2432 | |
---|
| 2433 | %% Plot the projections on the selected projection objects |
---|
| 2434 | % main projection object (uvmat display) |
---|
| 2435 | list_object=get(handles.ListObject,'String'); |
---|
| 2436 | if isequal(list_object,{''})%refresh list of objects if the menu is empty |
---|
| 2437 | UvData.Object={[]}; |
---|
| 2438 | set(handles.ListObject,'Value',1) |
---|
| 2439 | end |
---|
| 2440 | IndexObj=get(handles.ListObject,'Value');%selected projection object for main view |
---|
| 2441 | if IndexObj(1)> numel(UvData.Object) |
---|
| 2442 | IndexObj(1)=1;%select the first object if the selected one does not exist |
---|
| 2443 | set(handles.ListObject,'Value',1) |
---|
| 2444 | end |
---|
| 2445 | plot_handles{1}=handles; |
---|
| 2446 | if isfield(UvData,'plotaxes')%case of movies |
---|
| 2447 | haxes(1)=UvData.plotaxes; |
---|
| 2448 | else |
---|
| 2449 | haxes(1)=handles.axes3; |
---|
| 2450 | end |
---|
| 2451 | %PlotParam{1}=read_plot_param(handles);%read plotting parameters on the uvmat interfac |
---|
| 2452 | PlotParam{1}=read_GUI(handles.uvmat); |
---|
| 2453 | if ~isfield(PlotParam{1},'Vectors') |
---|
| 2454 | PlotParam{1}.Vectors.MaxVec=1; |
---|
| 2455 | PlotParam{1}.Vectors.MinVec=0; |
---|
| 2456 | PlotParam{1}.Vectors.CheckFixVecColor=1; |
---|
| 2457 | PlotParam{1}.Vectors.ColCode1=0.33; |
---|
| 2458 | PlotParam{1}.Vectors.ColCode2=0.66; |
---|
| 2459 | PlotParam{1}.Vectors.ListColorScalar={'ima_cor'}; |
---|
| 2460 | PlotParam{1}.Vectors.ListColorCode= {'rgb'}; |
---|
| 2461 | end |
---|
| 2462 | keeplim(1)=get(handles.CheckFixLimits,'Value');% test for fixed graph limits |
---|
| 2463 | PosColorbar{1}=UvData.OpenParam.PosColorbar;%prescribe the colorbar position on the uvmat interface |
---|
| 2464 | |
---|
| 2465 | % second projection object (view_field display) |
---|
| 2466 | if length( IndexObj)>=2 |
---|
| 2467 | view_field_handle=findobj(allchild(0),'tag','view_field');%handles of the view_field GUI |
---|
| 2468 | if ~isempty(view_field_handle) |
---|
| 2469 | plot_handles{2}=guidata(view_field_handle); |
---|
| 2470 | haxes(2)=plot_handles{2}.axes3; |
---|
| 2471 | %PlotParam{2}=read_plot_param(plot_handles{2});%read plotting parameters on the viewinterface |
---|
| 2472 | PlotParam{2}=read_GUI(handles.uvmat);%read plotting parameters on the uvmat interface |
---|
| 2473 | keeplim(2)=get(plot_handles{2}.CheckFixLimits,'Value'); |
---|
| 2474 | PosColorbar{2}='*'; %TODO: deal with colorbar position on view_field |
---|
| 2475 | end |
---|
| 2476 | end |
---|
| 2477 | |
---|
| 2478 | %loop on the projection objects: one or two |
---|
| 2479 | for imap=1:numel(IndexObj) |
---|
| 2480 | iobj=IndexObj(imap); |
---|
[402] | 2481 | if iobj==1 && ~isfield(UvData.Object{iobj},'Type')% case with no projection (only for the first empty object) |
---|
| 2482 | ord=10^(floor(log10(UvData.Field.Mesh)));%order of magnitude |
---|
| 2483 | if UvData.Field.Mesh/ord>=5 |
---|
| 2484 | mesh=5*ord; |
---|
| 2485 | elseif UvData.Field.Mesh/ord>=2 |
---|
| 2486 | mesh=2*ord; |
---|
| 2487 | else |
---|
| 2488 | mesh=ord; |
---|
| 2489 | end |
---|
| 2490 | coord_x=UvData.Field.XMin:mesh:UvData.Field.XMax; |
---|
| 2491 | coord_y=UvData.Field.YMin:mesh:UvData.Field.YMax; |
---|
| 2492 | [XI,YI]=meshgrid(coord_x,coord_y); |
---|
| 2493 | XI=reshape(XI,[],1); |
---|
| 2494 | YI=reshape(YI,[],1); |
---|
| 2495 | [ObjectData,errormsg]=calc_field({FieldName},UvData.Field,[XI YI]); |
---|
| 2496 | else |
---|
| 2497 | [ObjectData,errormsg]=proj_field(UvData.Field,UvData.Object{iobj});% project field on the object |
---|
| 2498 | end |
---|
[387] | 2499 | if ~isempty(errormsg) |
---|
| 2500 | return |
---|
| 2501 | end |
---|
| 2502 | % if testnewseries && isfield(ObjectData,'CoordUnit')&& isfield(PlotParam{imap},'Coordinates') |
---|
[402] | 2503 | % PlotParam{imap}.Coordinates=rmfield(PlotParam{imap}.Coordinates,'CheckFixEqual'); %set FixEqual to depend on the field (=1 if Data.CoordUnit=1 in plot_field) |
---|
| 2504 | % end |
---|
[387] | 2505 | if testnewseries && isfield(ObjectData,'CoordUnit') |
---|
| 2506 | PlotParam{imap}.Coordinates.CheckFixEqual=1; |
---|
| 2507 | end |
---|
| 2508 | %use of mask (TODO: check) |
---|
| 2509 | if isfield(ObjectData,'NbDim') && isequal(ObjectData.NbDim,2) && isfield(ObjectData,'Mask') && isfield(ObjectData,'A') |
---|
| 2510 | flag_mask=double(ObjectData.Mask>200);%=0 for masked regions |
---|
| 2511 | AX=ObjectData.AX;%x coordiantes for the scalar field |
---|
| 2512 | AY=ObjectData.AY;%y coordinates for the scalar field |
---|
| 2513 | MaskX=ObjectData.MaskX;%x coordiantes for the mask |
---|
| 2514 | MaskY=ObjectData.MaskY;%y coordiantes for the mask |
---|
| 2515 | if ~isequal(MaskX,AX)||~isequal(MaskY,AY) |
---|
| 2516 | nxy=size(flag_mask); |
---|
| 2517 | sizpx=(ObjectData.MaskX(end)-ObjectData.MaskX(1))/(nxy(2)-1);%size of a mask pixel |
---|
| 2518 | sizpy=(ObjectData.MaskY(1)-ObjectData.MaskY(end))/(nxy(1)-1); |
---|
| 2519 | x_mask=ObjectData.MaskX(1):sizpx:ObjectData.MaskX(end); % pixel x coordinates for image display |
---|
| 2520 | y_mask=ObjectData.MaskY(1):-sizpy:ObjectData.MaskY(end);% pixel x coordinates for image display |
---|
| 2521 | %project on the positions of the scalar |
---|
| 2522 | npxy=size(ObjectData.A); |
---|
| 2523 | dxy(1)=(ObjectData.AY(end)-ObjectData.AY(1))/(npxy(1)-1);%grid mesh in y |
---|
| 2524 | dxy(2)=(ObjectData.AX(end)-ObjectData.AX(1))/(npxy(2)-1);%grid mesh in x |
---|
| 2525 | xi=ObjectData.AX(1):dxy(2):ObjectData.AX(end); |
---|
| 2526 | yi=ObjectData.AY(1):dxy(1):ObjectData.AY(end); |
---|
| 2527 | [XI,YI]=meshgrid(xi,yi);% creates the matrix of regular coordinates |
---|
| 2528 | flag_mask = interp2(x_mask,y_mask,flag_mask,XI,YI); |
---|
| 2529 | end |
---|
| 2530 | AClass=class(ObjectData.A); |
---|
| 2531 | ObjectData.A=flag_mask.*double(ObjectData.A); |
---|
| 2532 | ObjectData.A=feval(AClass,ObjectData.A); |
---|
| 2533 | ind_off=[]; |
---|
| 2534 | if isfield(ObjectData,'ListVarName') |
---|
| 2535 | for ilist=1:length(ObjectData.ListVarName) |
---|
| 2536 | if isequal(ObjectData.ListVarName{ilist},'Mask')||isequal(ObjectData.ListVarName{ilist},'MaskX')||isequal(ObjectData.ListVarName{ilist},'MaskY') |
---|
| 2537 | ind_off=[ind_off ilist]; |
---|
| 2538 | end |
---|
| 2539 | end |
---|
| 2540 | ObjectData.ListVarName(ind_off)=[]; |
---|
| 2541 | ObjectData.VarDimIndex(ind_off)=[]; |
---|
| 2542 | ind_off=[]; |
---|
| 2543 | for ilist=1:length(ObjectData.ListDimName) |
---|
| 2544 | if isequal(ObjectData.ListDimName{ilist},'MaskX') || isequal(ObjectData.ListDimName{ilist},'MaskY') |
---|
| 2545 | ind_off=[ind_off ilist]; |
---|
| 2546 | end |
---|
| 2547 | end |
---|
| 2548 | ObjectData.ListDimName(ind_off)=[]; |
---|
| 2549 | ObjectData.DimValue(ind_off)=[]; |
---|
| 2550 | end |
---|
[402] | 2551 | end |
---|
[387] | 2552 | if ~isempty(ObjectData) |
---|
| 2553 | PlotType='none'; %default |
---|
| 2554 | if imap==2 && isempty(view_field_handle) |
---|
| 2555 | view_field(ObjectData) |
---|
| 2556 | else |
---|
| 2557 | [PlotType,PlotParamOut]=plot_field(ObjectData,haxes(imap),PlotParam{imap},PosColorbar{imap}); |
---|
| 2558 | write_plot_param(plot_handles{imap},PlotParamOut) %update the auto plot parameters |
---|
| 2559 | if isfield(Field,'Mesh')&&~isempty(Field.Mesh) |
---|
| 2560 | ObjectData.Mesh=Field.Mesh; % gives an estimated mesh size (useful for mouse action on the plot) |
---|
| 2561 | end |
---|
| 2562 | end |
---|
| 2563 | if isequal(PlotType,'none') |
---|
| 2564 | hget_field=findobj(allchild(0),'name','get_field'); |
---|
| 2565 | if isempty(hget_field) |
---|
| 2566 | get_field(filename)% the projected field cannot be automatically plotted: use get_field to specify the variablesdelete(hget_field) |
---|
| 2567 | end |
---|
| 2568 | errormsg='The field defined by get_field cannot be plotted'; |
---|
| 2569 | return |
---|
| 2570 | end |
---|
| 2571 | end |
---|
| 2572 | end |
---|
| 2573 | |
---|
| 2574 | %% update the mask |
---|
| 2575 | if isequal(get(handles.CheckMask,'Value'),1)%if the mask option is on |
---|
| 2576 | update_mask(handles,num_i1,num_i2); |
---|
| 2577 | end |
---|
| 2578 | |
---|
| 2579 | %% prepare the menus of histograms and plot them (histogram of the whole volume in 3D case) |
---|
| 2580 | menu_histo=(UvData.Field.ListVarName)';%list of field variables to be displayed for the menu of histogram display |
---|
| 2581 | ind_bad=[]; |
---|
| 2582 | nb_histo=1; |
---|
| 2583 | |
---|
| 2584 | % suppress coordinates from the histogram menu |
---|
| 2585 | for ivar=1:numel(menu_histo)%l loop on field variables: |
---|
| 2586 | if isfield(UvData.Field,'VarAttribute') && numel(UvData.Field.VarAttribute)>=ivar && isfield(UvData.Field.VarAttribute{ivar},'Role') |
---|
| 2587 | Role=UvData.Field.VarAttribute{ivar}.Role; |
---|
| 2588 | switch Role |
---|
| 2589 | case {'coord_x','coord_y','coord_z','dimvar'} |
---|
| 2590 | ind_bad=[ind_bad ivar]; |
---|
| 2591 | case {'vector_y'} |
---|
| 2592 | nb_histo=nb_histo+1; |
---|
| 2593 | end |
---|
| 2594 | end |
---|
| 2595 | DimCell=UvData.Field.VarDimName{ivar}; |
---|
| 2596 | DimName=''; |
---|
| 2597 | if ischar(DimCell) |
---|
| 2598 | DimName=DimCell; |
---|
| 2599 | elseif iscell(DimCell)&& numel(DimCell)==1 |
---|
| 2600 | DimName=DimCell{1}; |
---|
| 2601 | end |
---|
| 2602 | if strcmp(DimName,menu_histo{ivar}) |
---|
| 2603 | ind_bad=[ind_bad ivar]; |
---|
| 2604 | end |
---|
| 2605 | end |
---|
| 2606 | menu_histo(ind_bad)=[]; |
---|
| 2607 | |
---|
| 2608 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
---|
| 2609 | % display menus and plot histograms |
---|
| 2610 | test_v=0; |
---|
| 2611 | if ~isempty(menu_histo) |
---|
| 2612 | set(handles.histo1_menu,'Value',1) |
---|
| 2613 | set(handles.histo1_menu,'String',menu_histo) |
---|
| 2614 | histo1_menu_Callback(handles.histo1_menu, [], handles)% plot first histogram |
---|
| 2615 | % case of more than one variables (eg vector components) |
---|
| 2616 | if nb_histo > 1 |
---|
| 2617 | test_v=1; |
---|
| 2618 | set(handles.histo2_menu,'Visible','on') |
---|
| 2619 | set(handles.histo_v,'Visible','on') |
---|
| 2620 | set(handles.histo2_menu,'String',menu_histo) |
---|
| 2621 | set(handles.histo2_menu,'Value',2) |
---|
| 2622 | histo2_menu_Callback(handles.histo2_menu,[], handles)% plot second histogram |
---|
| 2623 | end |
---|
| 2624 | end |
---|
| 2625 | if ~test_v |
---|
| 2626 | set(handles.histo2_menu,'Visible','off') |
---|
| 2627 | set(handles.histo_v,'Visible','off') |
---|
| 2628 | cla(handles.histo_v) |
---|
| 2629 | set(handles.histo2_menu,'Value',1) |
---|
| 2630 | end |
---|
| 2631 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
---|
| 2632 | |
---|
| 2633 | %% display time |
---|
| 2634 | testimedoc=0; |
---|
| 2635 | TimeUnit=''; |
---|
| 2636 | if isfield(UvData.Field,'Time') |
---|
| 2637 | abstime=UvData.Field.Time;%time read from the netcdf input file |
---|
| 2638 | end |
---|
| 2639 | if isfield(UvData,'Field_1') && isfield(UvData.Field_1,'Time') |
---|
| 2640 | abstime_1=UvData.Field_1.Time;%time read from the netcdf input file |
---|
| 2641 | end |
---|
| 2642 | if isfield(UvData.Field,'dt') |
---|
| 2643 | dt=UvData.Field.dt;%dt read from the netcdf input file |
---|
| 2644 | if isfield(UvData.Field,'TimeUnit') |
---|
| 2645 | TimeUnit=UvData.Field.TimeUnit; |
---|
| 2646 | end |
---|
| 2647 | elseif isfield(UvData,'Field_1') && isfield(UvData.Field_1,'dt')%dt obtained from the second field if not defined in the first |
---|
| 2648 | dt=UvData.Field_1.dt;%dt read from the netcdf input file |
---|
| 2649 | if isfield(UvData.Field_1,'TimeUnit') |
---|
| 2650 | TimeUnit=UvData.Field_1.TimeUnit; |
---|
| 2651 | end |
---|
| 2652 | end |
---|
| 2653 | % time from xml file overset previous result |
---|
| 2654 | if isfield(UvData,'XmlData') && isfield(UvData.XmlData{1},'Time') |
---|
| 2655 | if isempty(num_i2)||isnan(num_i2) |
---|
| 2656 | num_i2=num_i1; |
---|
| 2657 | end |
---|
| 2658 | if isempty(num_j1)||isnan(num_j1) |
---|
| 2659 | num_j1=1; |
---|
| 2660 | end |
---|
| 2661 | if isempty(num_j2)||isnan(num_j2) |
---|
| 2662 | num_j2=num_j1; |
---|
| 2663 | end |
---|
| 2664 | siz=size(UvData.XmlData{1}.Time); |
---|
| 2665 | if siz(1)>=max(num_i1,num_i2) && siz(2)>=max(num_j1,num_j2) |
---|
| 2666 | abstime=(UvData.XmlData{1}.Time(num_i1,num_j1)+UvData.XmlData{1}.Time(num_i2,num_j2))/2;%overset the time read from files |
---|
| 2667 | dt=(UvData.XmlData{1}.Time(num_i2,num_j2)-UvData.XmlData{1}.Time(num_i1,num_j1)); |
---|
| 2668 | testimedoc=1; |
---|
| 2669 | if isfield(UvData.XmlData{1},'TimeUnit') |
---|
| 2670 | TimeUnit=UvData.XmlData{1}.TimeUnit; |
---|
| 2671 | end |
---|
| 2672 | end |
---|
| 2673 | if numel(UvData.XmlData)==2 |
---|
| 2674 | [tild,tild,tild,num_i1,num_i2,num_j1,num_j2]=fileparts_uvmat(['xx' get(handles.FileIndex_1,'String') get(handles.FileExt_1,'String')]); |
---|
| 2675 | % [P,F,str1,str2,str_a,str_b,E]=name2display(['xx' get(handles.FileIndex_1,'String') get(handles.FileExt_1,'String')]); |
---|
| 2676 | if isempty(num_i2) |
---|
| 2677 | num_i2=num_i1; |
---|
| 2678 | end |
---|
| 2679 | if isempty(num_j1) |
---|
| 2680 | num_j1=1; |
---|
| 2681 | end |
---|
| 2682 | if isempty(num_j2) |
---|
| 2683 | num_j2=num_j1; |
---|
| 2684 | end |
---|
| 2685 | siz=size(UvData.XmlData{2}.Time); |
---|
| 2686 | if ~isempty(num_i1) && siz(1)>=max(num_i1,num_i2) && siz(2)>=max(num_j1,num_j2) |
---|
| 2687 | 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 |
---|
| 2688 | end |
---|
| 2689 | end |
---|
| 2690 | end |
---|
| 2691 | |
---|
| 2692 | if ~isequal(numel(abstime),1) |
---|
| 2693 | abstime=[]; |
---|
| 2694 | end |
---|
| 2695 | if ~isequal(numel(abstime_1),1) |
---|
| 2696 | abstime_1=[]; |
---|
| 2697 | end |
---|
| 2698 | set(handles.abs_time,'String',num2str(abstime,4)) |
---|
| 2699 | set(handles.abs_time_1,'String',num2str(abstime_1,4)) |
---|
| 2700 | if testimedoc && isfield(UvData,'dt') |
---|
| 2701 | dt=UvData.dt; |
---|
| 2702 | end |
---|
| 2703 | if isempty(dt)||isequal(dt,0) |
---|
| 2704 | set(handles.Dt_txt,'String','') |
---|
| 2705 | else |
---|
| 2706 | if isempty(TimeUnit) |
---|
| 2707 | set(handles.Dt_txt,'String',['Dt=' num2str(1000*dt,3) ' 10^(-3)'] ) |
---|
| 2708 | else |
---|
| 2709 | set(handles.Dt_txt,'String',['Dt=' num2str(1000*dt,3) ' m' TimeUnit] ) |
---|
| 2710 | end |
---|
| 2711 | end |
---|
| 2712 | |
---|
| 2713 | |
---|
| 2714 | %------------------------------------------------------------------- |
---|
| 2715 | % --- translate coordinate to matrix index |
---|
| 2716 | %------------------------------------------------------------------- |
---|
| 2717 | function [indx,indy]=pos2ind(x0,rangx0,nxy) |
---|
| 2718 | indx=1+round((nxy(2)-1)*(x0-rangx0(1))/(rangx0(2)-rangx0(1)));% index x of pixel |
---|
| 2719 | indy=1+round((nxy(1)-1)*(y12-rangy0(1))/(rangy0(2)-rangy0(1)));% index y of pixel |
---|
| 2720 | |
---|
| 2721 | %------------------------------------------------------------------- |
---|
| 2722 | % --- Executes on button press in 'CheckFixLimits'. |
---|
| 2723 | %------------------------------------------------------------------- |
---|
| 2724 | function CheckFixLimits_Callback(hObject, eventdata, handles) |
---|
| 2725 | test=get(handles.CheckFixLimits,'Value'); |
---|
| 2726 | if test |
---|
| 2727 | set(handles.CheckFixLimits,'BackgroundColor',[1 1 0]) |
---|
| 2728 | else |
---|
| 2729 | set(handles.CheckFixLimits,'BackgroundColor',[0.7 0.7 0.7]) |
---|
| 2730 | update_plot(handles); |
---|
| 2731 | end |
---|
| 2732 | |
---|
| 2733 | %------------------------------------------------------------------- |
---|
| 2734 | % --- Executes on button press in CheckFixEqual. |
---|
| 2735 | function CheckFixEqual_Callback(hObject, eventdata, handles) |
---|
| 2736 | test=get(handles.CheckFixEqual,'Value'); |
---|
| 2737 | if test |
---|
| 2738 | set(handles.CheckFixEqual,'BackgroundColor',[1 1 0]) |
---|
| 2739 | cla(handles.axes3) |
---|
| 2740 | update_plot(handles); |
---|
| 2741 | else |
---|
| 2742 | set(handles.CheckFixEqual,'BackgroundColor',[0.7 0.7 0.7]) |
---|
| 2743 | update_plot(handles); |
---|
| 2744 | % axis(handles.axes3,'image') |
---|
| 2745 | end |
---|
| 2746 | |
---|
| 2747 | %------------------------------------------------------------------- |
---|
| 2748 | |
---|
| 2749 | %------------------------------------------------------------------- |
---|
| 2750 | % --- Executes on button press in 'CheckZoom'. |
---|
| 2751 | %------------------------------------------------------------------- |
---|
| 2752 | function CheckZoom_Callback(hObject, eventdata, handles) |
---|
| 2753 | |
---|
| 2754 | if (get(handles.CheckZoom,'Value') == 1); |
---|
| 2755 | set(handles.CheckZoom,'BackgroundColor',[1 1 0]) |
---|
| 2756 | set(handles.CheckFixLimits,'Value',1)% propose by default fixed limits for the plotting axes |
---|
| 2757 | set(handles.CheckFixLimits,'BackgroundColor',[1 1 0]) |
---|
| 2758 | else |
---|
| 2759 | set(handles.CheckZoom,'BackgroundColor',[0.7 0.7 0.7]) |
---|
| 2760 | end |
---|
| 2761 | |
---|
| 2762 | %------------------------------------------------------------------- |
---|
| 2763 | %----Executes on button press in 'record': records the current flags of manual correction. |
---|
| 2764 | %------------------------------------------------------------------- |
---|
| 2765 | function record_Callback(hObject, eventdata, handles) |
---|
| 2766 | % [filebase,num_i1,num_j1,num_i2,num_j2,Ext,NomType,SubDir]=read_input_file(handles); |
---|
| 2767 | [RootPath,SubDir,RootFile,FileIndices,FileExt]=read_file_boxes(handles); |
---|
| 2768 | filename=[fullfile(RootPath,SubDir,RootFile) FileIndices FileExt]; |
---|
| 2769 | %filename=read_file_boxes(handles); |
---|
| 2770 | [erread,message]=fileattrib(filename); |
---|
| 2771 | if ~isempty(message) && ~isequal(message.UserWrite,1) |
---|
| 2772 | msgbox_uvmat('ERROR',['no writting access to ' filename]) |
---|
| 2773 | return |
---|
| 2774 | end |
---|
| 2775 | test_civ2=isequal(get(handles.civ2,'BackgroundColor'),[1 1 0]); |
---|
| 2776 | test_civ1=isequal(get(handles.VelType,'BackgroundColor'),[1 1 0]); |
---|
| 2777 | if ~test_civ2 && ~test_civ1 |
---|
| 2778 | msgbox_uvmat('ERROR','manual correction only possible for CIV1 or CIV2 velocity fields') |
---|
| 2779 | end |
---|
| 2780 | if test_civ2 |
---|
| 2781 | nbname='nb_vectors2'; |
---|
| 2782 | flagname='vec2_FixFlag'; |
---|
| 2783 | attrname='fix2'; |
---|
| 2784 | end |
---|
| 2785 | if test_civ1 |
---|
| 2786 | nbname='nb_vectors'; |
---|
| 2787 | flagname='vec_FixFlag'; |
---|
| 2788 | attrname='fix'; |
---|
| 2789 | end |
---|
| 2790 | %write fix flags in the netcdf file |
---|
| 2791 | UvData=get(handles.uvmat,'UserData'); |
---|
| 2792 | hhh=which('netcdf.open');% look for built-in matlab netcdf library |
---|
| 2793 | if ~isequal(hhh,'')% case of new builtin Matlab netcdf library |
---|
| 2794 | nc=netcdf.open(filename,'NC_WRITE'); |
---|
| 2795 | netcdf.reDef(nc); |
---|
| 2796 | netcdf.putAtt(nc,netcdf.getConstant('NC_GLOBAL'),attrname,1); |
---|
| 2797 | dimid = netcdf.inqDimID(nc,nbname); |
---|
| 2798 | try |
---|
| 2799 | varid = netcdf.inqVarID(nc,flagname);% look for already existing fixflag variable |
---|
| 2800 | catch |
---|
| 2801 | varid=netcdf.defVar(nc,flagname,'double',dimid);%create fixflag variable if it does not exist |
---|
| 2802 | end |
---|
| 2803 | netcdf.endDef(nc); |
---|
| 2804 | netcdf.putVar(nc,varid,UvData.axes3.FF); |
---|
| 2805 | netcdf.close(nc); |
---|
| 2806 | else %old netcdf library |
---|
| 2807 | netcdf_toolbox(filename,AxeData,attrname,nbname,flagname) |
---|
| 2808 | end |
---|
| 2809 | |
---|
| 2810 | %------------------------------------------------------------------- |
---|
| 2811 | %----Correct the netcdf file, using toolbox (old versions of Matlab). |
---|
| 2812 | %------------------------------------------------------------------- |
---|
| 2813 | function netcdf_toolbox(filename,AxeData,attrname,nbname,flagname) |
---|
| 2814 | nc=netcdf(filename,'write'); %open netcdf file |
---|
| 2815 | result=redef(nc); |
---|
| 2816 | eval(['nc.' attrname '=1;']); |
---|
| 2817 | theDim=nc(nbname) ;% get the number of velocity vectors |
---|
| 2818 | nb_vectors=size(theDim); |
---|
| 2819 | var_FixFlag=ncvar(flagname,nc);% var_FixFlag will be written as the netcdf variable vec_FixFlag |
---|
| 2820 | var_FixFlag(1:nb_vectors)=AxeData.FF;% |
---|
| 2821 | fin=close(nc); |
---|
| 2822 | |
---|
| 2823 | %--------------------------------------------------- |
---|
| 2824 | % --- Executes on button press in SubField |
---|
| 2825 | function SubField_Callback(hObject, eventdata, handles) |
---|
| 2826 | % huvmat=get(handles.run0,'parent'); |
---|
| 2827 | UvData=get(handles.uvmat,'UserData'); |
---|
| 2828 | if get(handles.SubField,'Value')==0% if the subfield button is desactivated |
---|
| 2829 | set(handles.RootPath_1,'String','') |
---|
| 2830 | set(handles.RootFile_1,'String','') |
---|
| 2831 | set(handles.SubDir_1,'String',''); |
---|
| 2832 | set(handles.FileIndex_1,'String',''); |
---|
| 2833 | set(handles.FileExt_1,'String',''); |
---|
| 2834 | set(handles.RootPath_1,'Visible','off') |
---|
| 2835 | set(handles.RootFile_1,'Visible','off') |
---|
| 2836 | set(handles.SubDir_1,'Visible','off'); |
---|
| 2837 | set(handles.NomType_1,'Visible','off'); |
---|
| 2838 | set(handles.abs_time_1,'Visible','off') |
---|
| 2839 | set(handles.FileIndex_1,'Visible','off'); |
---|
| 2840 | set(handles.FileExt_1,'Visible','off'); |
---|
| 2841 | set(handles.Fields_1,'Value',1);%set to blank state |
---|
| 2842 | set(handles.VelType_1,'Value',1);%set to blank state |
---|
| 2843 | if ~strcmp(get(handles.VelType,'Visible'),'on') |
---|
| 2844 | set(handles.VelType_1,'Visible','off') |
---|
| 2845 | end |
---|
| 2846 | if isfield(UvData,'XmlData_1') |
---|
| 2847 | UvData=rmfield(UvData,'XmlData_1'); |
---|
| 2848 | end |
---|
| 2849 | set(handles.uvmat,'UserData',UvData); |
---|
| 2850 | run0_Callback(hObject, eventdata, handles); %run |
---|
| 2851 | else |
---|
| 2852 | MenuBrowse_1_Callback(hObject, eventdata, handles) |
---|
| 2853 | end |
---|
| 2854 | |
---|
| 2855 | %------------------------------------------------------------------------ |
---|
| 2856 | % --- read the data displayed for the input rootfile windows (new): TODO use read_GUI |
---|
| 2857 | |
---|
| 2858 | function [RootPath,SubDir,RootFile,FileIndices,FileExt]=read_file_boxes(handles) |
---|
| 2859 | %------------------------------------------------------------------------ |
---|
| 2860 | InputFile=read_GUI(handles.InputFile); |
---|
| 2861 | RootPath=InputFile.RootPath; |
---|
| 2862 | SubDir=regexprep(InputFile.SubDir,'/|\',''); |
---|
| 2863 | RootFile=regexprep(InputFile.RootFile,'/|\',''); |
---|
| 2864 | FileIndices=InputFile.FileIndex; |
---|
| 2865 | FileExt=InputFile.FileExt; |
---|
| 2866 | |
---|
| 2867 | |
---|
| 2868 | %------------------------------------------------------------------------ |
---|
| 2869 | % ---- read the data displayed for the second input rootfile windows |
---|
| 2870 | function [RootPath_1,SubDir_1,RootFile_1,FileIndex_1,FileExt_1,NomType_1]=read_file_boxes_1(handles) |
---|
| 2871 | %------------------------------------------------------------------------ |
---|
| 2872 | RootPath_1=get(handles.RootPath_1,'String'); % read the data from the file1_input window |
---|
| 2873 | if isequal(get(handles.RootPath_1,'Visible'),'off') || isequal(RootPath_1,'"') |
---|
| 2874 | RootPath_1=get(handles.RootPath,'String'); |
---|
| 2875 | end; |
---|
| 2876 | SubDir_1=get(handles.SubDir_1,'String'); |
---|
| 2877 | if isequal(get(handles.SubDir_1,'Visible'),'off')|| isequal(SubDir_1,'"') |
---|
| 2878 | SubDir_1=get(handles.SubDir,'String'); |
---|
| 2879 | end |
---|
| 2880 | SubDir_1=regexprep(SubDir_1,'\<[\\/]|[\\/]\>','');%suppress possible / or \ separator at the beginning or the end of the string |
---|
| 2881 | RootFile_1=get(handles.RootFile_1,'String'); |
---|
| 2882 | if isequal(get(handles.RootFile_1,'Visible'),'off') || isequal(RootFile_1,'"') |
---|
| 2883 | RootFile_1=get(handles.RootFile,'String'); |
---|
| 2884 | end |
---|
| 2885 | RootFile_1=regexprep(RootFile_1,'\<[\\/]|[\\/]\>','');%suppress possible / or \ separator at the beginning or the end of the string |
---|
| 2886 | FileIndex_1=get(handles.FileIndex_1,'String'); |
---|
| 2887 | if isequal(get(handles.FileIndex_1,'Visible'),'off')|| isequal(FileIndex_1,'"') |
---|
| 2888 | FileIndex_1=get(handles.FileIndex,'String'); |
---|
| 2889 | end |
---|
| 2890 | FileExt_1=get(handles.FileExt_1,'String'); |
---|
| 2891 | if isequal(get(handles.FileExt_1,'Visible'),'off') || isequal(FileExt_1,'"') |
---|
| 2892 | FileExt_1=get(handles.FileExt,'String');%read FileExt by default |
---|
| 2893 | end |
---|
| 2894 | NomType_1=get(handles.NomType_1,'String'); |
---|
| 2895 | if isequal(get(handles.NomType_1,'Visible'),'off') || isequal(NomType_1,'"') |
---|
| 2896 | NomType_1=get(handles.NomType,'String');%read FileExt by default |
---|
| 2897 | end |
---|
| 2898 | %------------------------------------------------------------------------ |
---|
| 2899 | % --- Executes on menu selection Fields |
---|
| 2900 | function Fields_Callback(hObject, eventdata, handles) |
---|
| 2901 | %------------------------------------------------------------------------ |
---|
| 2902 | list_fields=get(handles.Fields,'String');% list menu fields |
---|
| 2903 | index_fields=get(handles.Fields,'Value');% selected string index |
---|
| 2904 | field= list_fields{index_fields(1)}; % selected string |
---|
| 2905 | if isequal(field,'get_field...') |
---|
| 2906 | set(handles.FixVelType,'visible','off') |
---|
| 2907 | set(handles.VelType,'visible','off') |
---|
| 2908 | set(handles.VelType_1,'visible','off') |
---|
| 2909 | [RootPath,SubDir,RootFile,FileIndices,FileExt]=read_file_boxes(handles); |
---|
| 2910 | filename=[fullfile(RootPath,SubDir,RootFile) FileIndices FileExt]; |
---|
| 2911 | %filename=read_file_boxes(handles); |
---|
| 2912 | hget_field=findobj(allchild(0),'name','get_field'); |
---|
| 2913 | if ~isempty(hget_field) |
---|
| 2914 | delete(hget_field) |
---|
| 2915 | end |
---|
| 2916 | hget_field=get_field(filename); |
---|
| 2917 | set(hget_field,'Name','get_field') |
---|
| 2918 | hhget_field=guidata(hget_field); |
---|
| 2919 | set(hhget_field.list_fig,'Value',1) |
---|
| 2920 | set(hhget_field.list_fig,'String',{'uvmat'}) |
---|
| 2921 | set(handles.transform_fct,'Value',1)% no transform by default |
---|
| 2922 | set(handles.path_transform,'String','') |
---|
| 2923 | return %no action |
---|
| 2924 | end |
---|
| 2925 | list_fields=get(handles.Fields_1,'String');% list menu fields |
---|
| 2926 | index_fields=get(handles.Fields_1,'Value');% selected string index |
---|
| 2927 | field_1= list_fields{index_fields(1)}; % selected string |
---|
| 2928 | UvData=get(handles.uvmat,'UserData'); |
---|
| 2929 | |
---|
| 2930 | %read the rootfile input display |
---|
| 2931 | [RootPath,SubDir,RootFile,FileIndices,FileExt]=read_file_boxes(handles); |
---|
| 2932 | FileName=[fullfile(RootPath,SubDir,RootFile) FileIndices FileExt]; |
---|
| 2933 | [tild,tild,tild,i1,i2,j1,j2,tild,NomType]=fileparts_uvmat(['xxx' get(handles.FileIndex,'String') FileExt]); |
---|
| 2934 | % NomTypeNew=NomType;%default |
---|
| 2935 | if isequal(field,'image') |
---|
| 2936 | % if isequal(NomType,'_1-2_1')||isequal(NomType,'_1_1-2') |
---|
| 2937 | % NomTypeNew='_1_1'; |
---|
| 2938 | % elseif isequal(NomType,'#_ab') |
---|
| 2939 | % NomTypeNew='#a'; |
---|
| 2940 | % elseif isequal(NomType,'_1-2') |
---|
| 2941 | % NomTypeNew='_1'; |
---|
| 2942 | % end |
---|
| 2943 | imagename=fullfile_uvmat(RootPath,SubDir,RootFile,'.png',NomType,i1,[],j1,[]); |
---|
| 2944 | if ~exist(imagename,'file') |
---|
| 2945 | [FileName,PathName] = uigetfile( ... |
---|
| 2946 | {'*.png;*.jpg;*.tif;*.avi;*.AVI;*.vol', ' (*.png, .tif, *.avi,*.vol)'; |
---|
| 2947 | '*.jpg',' jpeg image files'; ... |
---|
| 2948 | '*.png','.png image files'; ... |
---|
| 2949 | '*.tif','.tif image files'; ... |
---|
| 2950 | '*.avi;*.AVI','.avi movie files'; ... |
---|
| 2951 | '*.vol','.volume images (png)'; ... |
---|
| 2952 | '*.*', 'All Files (*.*)'}, ... |
---|
| 2953 | 'Pick an image',imagename); |
---|
| 2954 | imagename=[PathName FileName]; |
---|
| 2955 | end |
---|
| 2956 | % display the selected field and related information |
---|
| 2957 | display_file_name(hObject, eventdata, handles,imagename)%display the image |
---|
| 2958 | return |
---|
| 2959 | else |
---|
| 2960 | ext=get(handles.FileExt,'String'); |
---|
| 2961 | if ~isequal(ext,'.nc') %find the new NomType if the previous display was not already a netcdf file |
---|
| 2962 | [FileName,PathName] = uigetfile( ... |
---|
| 2963 | {'*.nc', ' (*.nc)'; |
---|
| 2964 | '*.nc',' netcdf files'; ... |
---|
| 2965 | '*.*', 'All Files (*.*)'}, ... |
---|
| 2966 | 'Pick a netcdf file',FileBase); |
---|
| 2967 | filename=[PathName FileName]; |
---|
| 2968 | % display the selected field and related information |
---|
| 2969 | display_file_name(hObject, eventdata, handles,filename) |
---|
| 2970 | return |
---|
| 2971 | end |
---|
| 2972 | end |
---|
| 2973 | indices=fullfile_uvmat('','','','',NomType,i1,i2,j1,j2); |
---|
| 2974 | set(handles.FileIndex,'String',indices) |
---|
| 2975 | % set(handles.NomType,'String',NomType) |
---|
| 2976 | |
---|
| 2977 | %common to Fields_1_Callback |
---|
| 2978 | if isequal(field,'image')||isequal(field_1,'image') |
---|
| 2979 | set(handles.TitleNpx,'Visible','on')% visible npx,pxcm... buttons |
---|
| 2980 | set(handles.TitleNpy,'Visible','on') |
---|
| 2981 | set(handles.num_Npx,'Visible','on') |
---|
| 2982 | set(handles.num_Npy,'Visible','on') |
---|
| 2983 | else |
---|
| 2984 | set(handles.TitleNpx,'Visible','off')% visible npx,pxcm... buttons |
---|
| 2985 | set(handles.TitleNpy,'Visible','off') |
---|
| 2986 | set(handles.num_Npx,'Visible','off') |
---|
| 2987 | set(handles.num_Npy,'Visible','off') |
---|
| 2988 | end |
---|
| 2989 | if ~(isfield(UvData,'NewSeries')&&isequal(UvData.NewSeries,1)) |
---|
| 2990 | run0_Callback(hObject, eventdata, handles) |
---|
| 2991 | end |
---|
| 2992 | |
---|
| 2993 | %--------------------------------------------------- |
---|
| 2994 | % --- Executes on menu selection Fields |
---|
| 2995 | function Fields_1_Callback(hObject, eventdata, handles) |
---|
| 2996 | %------------------------------------------------- |
---|
| 2997 | %% read input data |
---|
| 2998 | check_new=~get(handles.SubField,'Value'); %check_new=1 if a second field was not previously entered |
---|
| 2999 | UvData=get(handles.uvmat,'UserData'); |
---|
| 3000 | if check_new && isfield(UvData,'XmlData') |
---|
| 3001 | UvData.XmlData{2}=UvData.XmlData{1}; |
---|
| 3002 | end |
---|
[389] | 3003 | if isfield(UvData,'Field_1') |
---|
| 3004 | UvData=rmfield(UvData,'Field_1');% remove the stored second field (a new one needs to be read) |
---|
| 3005 | end |
---|
[402] | 3006 | UvData.filename_1='';% desactivate the use of a constant second file |
---|
[387] | 3007 | list_fields=get(handles.Fields,'String');% list menu fields |
---|
| 3008 | index_fields=get(handles.Fields,'Value');% selected string index |
---|
| 3009 | field= list_fields{index_fields(1)}; % selected string |
---|
| 3010 | list_fields=get(handles.Fields_1,'String');% list menu fields |
---|
| 3011 | index_fields=get(handles.Fields_1,'Value');% selected string index |
---|
| 3012 | field_1= list_fields{index_fields(1)}; % selected string for the second field |
---|
| 3013 | if isequal(field_1,'')||(numel(UvData.FileType)>=2 && strcmp(UvData.FileType{2},'image')) |
---|
| 3014 | set(handles.SubField,'Value',0) |
---|
| 3015 | check_new=1; |
---|
| 3016 | SubField_Callback(hObject, eventdata, handles) |
---|
| 3017 | if isempty(field_1)%remove second field if 'blank' field is selected |
---|
| 3018 | return |
---|
| 3019 | end |
---|
| 3020 | end |
---|
| 3021 | set(handles.SubField,'Value',1)%state that a second field is now entered |
---|
| 3022 | |
---|
| 3023 | %% read the rootfile input display |
---|
| 3024 | [RootPath_1,SubDir_1,RootFile_1,FileIndex_1,FileExt_1,NomTYpe_1]=read_file_boxes_1(handles); |
---|
| 3025 | filename_1=[fullfile(RootPath_1,SubDir_1,RootFile_1) FileIndex_1 FileExt_1]; |
---|
| 3026 | [tild,tild,tild,i1,i2,j1,j2]=fileparts_uvmat(get(handles.FileIndex,'String')); |
---|
| 3027 | set(handles.FileIndex_1,'Visible','on') |
---|
| 3028 | set(handles.FileExt_1,'Visible','on') |
---|
| 3029 | switch field_1 |
---|
| 3030 | case 'get_field...' |
---|
| 3031 | set_veltype_display(0) % no veltype display |
---|
| 3032 | hget_field=findobj(allchild(0),'name','get_field_1'); |
---|
| 3033 | if ~isempty(hget_field) |
---|
| 3034 | delete(hget_field) |
---|
| 3035 | end |
---|
| 3036 | hget_field=get_field(filename_1); |
---|
| 3037 | set(hget_field,'name','get_field_1') |
---|
| 3038 | hhget_field=guidata(hget_field); |
---|
| 3039 | set(hhget_field.list_fig,'Value',1) |
---|
| 3040 | set(hhget_field.list_fig,'String',{'uvmat'}) |
---|
| 3041 | set(handles.transform_fct,'Value',1)% no transform by default |
---|
| 3042 | set(handles.path_transform,'String','') |
---|
| 3043 | case 'image' |
---|
| 3044 | % transform netc type to the corresponding image type |
---|
| 3045 | NomType=get(handles.NomType,'string'); |
---|
| 3046 | check_letter=~isempty(regexp(NomType,'[ab|AB]$'));%detect pair label by letter |
---|
| 3047 | % NomType_1=NomType; |
---|
| 3048 | % if check_letter |
---|
| 3049 | % NomType_1=NomType_1(1:end-1); |
---|
| 3050 | % else |
---|
| 3051 | % r=regexp(NomType_1,'.-(?<num2>\d+$','names'); |
---|
| 3052 | % if ~isempty(r) |
---|
| 3053 | % NomType_1=regexprep(NomType_1,['-' r.num2],''); |
---|
| 3054 | % end |
---|
| 3055 | % end |
---|
| 3056 | imagename=fullfile_uvmat(RootPath_1,'',RootFile_1,'.png',NomType,i1,[],j1); |
---|
| 3057 | if ~exist(imagename,'file') |
---|
| 3058 | [FileName,PathName] = uigetfile( ... |
---|
| 3059 | {'*.png;*.jpg;*.tif;*.avi;*.AVI;*.vol', ' (*.png, .tif, *.avi,*.vol)'; |
---|
| 3060 | '*.jpg',' jpeg image files'; ... |
---|
| 3061 | '*.png','.png image files'; ... |
---|
| 3062 | '*.tif','.tif image files'; ... |
---|
| 3063 | '*.avi;*.AVI','.avi movie files'; ... |
---|
| 3064 | '*.vol','.volume images (png)'; ... |
---|
| 3065 | '*.*', 'All Files (*.*)'}, ... |
---|
| 3066 | 'Pick an image',imagename); |
---|
| 3067 | % display the selected field and related information |
---|
| 3068 | imagename=[PathName FileName]; |
---|
| 3069 | end |
---|
| 3070 | set(handles.TitleNpx,'Visible','on')% visible npx,pxcm... buttons |
---|
| 3071 | set(handles.TitleNpy,'Visible','on') |
---|
| 3072 | set(handles.num_Npx,'Visible','on') |
---|
| 3073 | set(handles.num_Npy,'Visible','on') |
---|
| 3074 | display_file_name(hObject, eventdata, handles,imagename,2)%display the imag |
---|
| 3075 | otherwise |
---|
| 3076 | if check_new |
---|
| 3077 | UvData.FileType{2}=UvData.FileType{1}; |
---|
| 3078 | set(handles.FileIndex_1,'String',get(handles.FileIndex,'String')) |
---|
| 3079 | set(handles.FileExt_1,'String',get(handles.FileExt,'String')) |
---|
| 3080 | end |
---|
| 3081 | if ~isequal(field,'image') |
---|
| 3082 | set(handles.TitleNpx,'Visible','off')% visible npx,pxcm... buttons |
---|
| 3083 | set(handles.TitleNpy,'Visible','off') |
---|
| 3084 | set(handles.num_Npx,'Visible','off') |
---|
| 3085 | set(handles.num_Npy,'Visible','off') |
---|
| 3086 | end |
---|
| 3087 | set(handles.uvmat,'UserData',UvData) |
---|
[389] | 3088 | % setfield(handles);% update the field structure ('civ1'....) |
---|
[387] | 3089 | if ~(isfield(UvData,'NewSeries')&&isequal(UvData.NewSeries,1)) |
---|
| 3090 | run0_Callback(hObject, eventdata, handles) |
---|
| 3091 | end |
---|
| 3092 | end |
---|
| 3093 | |
---|
| 3094 | %------------------------------------------------------------------------ |
---|
| 3095 | % --- set the visibility of relevant velocity type menus: |
---|
| 3096 | function menu=set_veltype_display(Civ,FileType) |
---|
| 3097 | %------------------------------------------------------------------------ |
---|
| 3098 | if ~exist('FileType','var') |
---|
| 3099 | FileType='civx'; |
---|
| 3100 | end |
---|
| 3101 | switch FileType |
---|
| 3102 | case 'civx' |
---|
[389] | 3103 | menu={'civ1';'interp1';'filter1';'civ2';'interp2';'filter2'}; |
---|
| 3104 | if isequal(Civ,0) |
---|
| 3105 | imax=0; |
---|
| 3106 | elseif isequal(Civ,1) || isequal(Civ,2) |
---|
| 3107 | imax=1; |
---|
| 3108 | elseif isequal(Civ,3) |
---|
| 3109 | imax=3; |
---|
| 3110 | elseif isequal(Civ,4) || isequal(Civ,5) |
---|
| 3111 | imax=4; |
---|
| 3112 | elseif isequal(Civ,6) %patch2 |
---|
| 3113 | imax=6; |
---|
| 3114 | end |
---|
[387] | 3115 | case 'civdata' |
---|
[389] | 3116 | menu={'civ1';'filter1';'civ2';'filter2'}; |
---|
| 3117 | if isequal(Civ,0) |
---|
| 3118 | imax=0; |
---|
| 3119 | elseif isequal(Civ,1) || isequal(Civ,2) |
---|
| 3120 | imax=1; |
---|
| 3121 | elseif isequal(Civ,3) |
---|
| 3122 | imax=2; |
---|
| 3123 | elseif isequal(Civ,4) || isequal(Civ,5) |
---|
| 3124 | imax=3; |
---|
| 3125 | elseif isequal(Civ,6) %patch2 |
---|
| 3126 | imax=4; |
---|
| 3127 | end |
---|
[387] | 3128 | end |
---|
[389] | 3129 | |
---|
| 3130 | |
---|
| 3131 | |
---|
[387] | 3132 | menu=menu(1:imax); |
---|
| 3133 | |
---|
| 3134 | %------------------------------------------------------------------------ |
---|
[402] | 3135 | % --- Executes on button press in FixVelType. |
---|
| 3136 | function FixVelType_Callback(hObject, eventdata, handles) |
---|
| 3137 | %------------------------------------------------------------------------ |
---|
| 3138 | val=get(handles.FixVelType,'Value'); |
---|
| 3139 | if ~val |
---|
| 3140 | run0_Callback(hObject, eventdata, handles) |
---|
| 3141 | end |
---|
| 3142 | |
---|
| 3143 | %------------------------------------------------------------------------ |
---|
[387] | 3144 | % --- Executes on button press in VelType. |
---|
| 3145 | function VelType_Callback(hObject, eventdata, handles) |
---|
| 3146 | %------------------------------------------------------------------------ |
---|
| 3147 | set(handles.FixVelType,'Value',1) |
---|
| 3148 | run0_Callback(hObject, eventdata, handles) |
---|
| 3149 | |
---|
| 3150 | %------------------------------------------------------------------------ |
---|
[402] | 3151 | % --- Executes on button press in VelType_1. |
---|
[387] | 3152 | function VelType_1_Callback(hObject, eventdata, handles) |
---|
| 3153 | %------------------------------------------------------------------------ |
---|
| 3154 | |
---|
| 3155 | set(handles.FixVelType,'Value',1)% the velocity type is now imposed by the GUI (not automatic) |
---|
[389] | 3156 | UvData=get(handles.uvmat,'UserData'); |
---|
[387] | 3157 | %refresh field with a second filename=first fiel name |
---|
| 3158 | set(handles.run0,'BackgroundColor',[1 1 0])%paint the command button in yellow |
---|
| 3159 | drawnow |
---|
| 3160 | InputFile=read_GUI(handles.InputFile); |
---|
| 3161 | [RootPath,SubDir,RootFile,FileIndices,FileExt]=read_file_boxes(handles); |
---|
| 3162 | filename=[fullfile(RootPath,SubDir,RootFile) FileIndices FileExt]; |
---|
[389] | 3163 | % VelTypeList=get(handles.VelType_1,'String'); |
---|
| 3164 | % VelType_1=VelTypeList{get(handles.VelType_1,'Value')}; |
---|
| 3165 | if isempty(InputFile.VelType_1) |
---|
[387] | 3166 | filename_1='';% we plot the current field without the second field |
---|
| 3167 | set(handles.SubField,'Value',0) |
---|
| 3168 | SubField_Callback(hObject, eventdata, handles) |
---|
| 3169 | elseif get(handles.SubField,'Value')% if subfield is already 'on' |
---|
| 3170 | [RootPath_1,SubDir_1,RootFile_1,FileIndices_1,FileExt_1]=read_file_boxes_1(handles); |
---|
| 3171 | filename_1=[fullfile(RootPath_1,SubDir_1,RootFile_1) FileIndices_1 FileExt_1]; |
---|
[389] | 3172 | % UvData.VelType{2}=InputFile.VelType_1; |
---|
[387] | 3173 | else |
---|
| 3174 | filename_1=filename;% we compare two fields in the same file |
---|
[389] | 3175 | UvData.FileType{2}=UvData.FileType{1}; |
---|
| 3176 | % UvData.VelType{2}=InputFile.VelType_1; |
---|
[387] | 3177 | set(handles.SubField,'Value',1) |
---|
| 3178 | end |
---|
[389] | 3179 | if isfield(UvData,'Field_1') |
---|
| 3180 | UvData=rmfield(UvData,'Field_1');% removes the stored second field if it exists |
---|
| 3181 | end |
---|
[402] | 3182 | UvData.filename_1='';% desactivate the use of a constant second file |
---|
[389] | 3183 | set(handles.uvmat,'UserData',UvData) |
---|
[387] | 3184 | num_i1=stra2num(get(handles.i1,'String')); |
---|
| 3185 | num_i2=stra2num(get(handles.i2,'String')); |
---|
| 3186 | num_j1=stra2num(get(handles.j1,'String')); |
---|
| 3187 | num_j2=stra2num(get(handles.j2,'String')); |
---|
| 3188 | |
---|
| 3189 | errormsg=refresh_field(handles,filename,filename_1,num_i1,num_i2,num_j1,num_j2); |
---|
| 3190 | |
---|
| 3191 | if ~isempty(errormsg) |
---|
| 3192 | msgbox_uvmat('ERROR',errormsg); |
---|
| 3193 | else |
---|
| 3194 | set(handles.i1,'BackgroundColor',[1 1 1]) |
---|
| 3195 | set(handles.i2,'BackgroundColor',[1 1 1]) |
---|
| 3196 | set(handles.j1,'BackgroundColor',[1 1 1]) |
---|
| 3197 | set(handles.j2,'BackgroundColor',[1 1 1]) |
---|
| 3198 | set(handles.FileIndex,'BackgroundColor',[1 1 1]) |
---|
| 3199 | set(handles.FileIndex_1,'BackgroundColor',[1 1 1]) |
---|
| 3200 | end |
---|
| 3201 | set(handles.run0,'BackgroundColor',[1 0 0]) |
---|
| 3202 | |
---|
| 3203 | %----------------------------------------------- |
---|
| 3204 | % --- reset civ buttons |
---|
| 3205 | function reset_vel_type(handles_civ0,handle1) |
---|
| 3206 | for ibutton=1:length(handles_civ0) |
---|
| 3207 | set(handles_civ0(ibutton),'BackgroundColor',[0.831 0.816 0.784]) |
---|
| 3208 | set(handles_civ0(ibutton),'Value',0) |
---|
| 3209 | end |
---|
| 3210 | if exist('handle1','var')%handles of selected button |
---|
| 3211 | set(handle1,'BackgroundColor',[1 1 0]) |
---|
| 3212 | end |
---|
| 3213 | |
---|
| 3214 | %------------------------------------------------------- |
---|
| 3215 | % --- Executes on button press in MENUVOLUME. |
---|
| 3216 | %------------------------------------------------------- |
---|
| 3217 | function VOLUME_Callback(hObject, eventdata, handles) |
---|
| 3218 | %errordlg('command VOL not implemented yet') |
---|
| 3219 | if ishandle(handles.UVMAT_title) |
---|
| 3220 | delete(handles.UVMAT_title) |
---|
| 3221 | end |
---|
| 3222 | UvData=get(handles.uvmat,'UserData');%read UvData properties stored on the uvmat interface |
---|
| 3223 | if isequal(get(handles.VOLUME,'Value'),1) |
---|
| 3224 | set(handles.CheckZoom,'Value',0) |
---|
| 3225 | set(handles.CheckZoom,'BackgroundColor',[0.7 0.7 0.7]) |
---|
| 3226 | set(handles.edit_vect,'Value',0) |
---|
| 3227 | edit_vect_Callback(hObject, eventdata, handles) |
---|
| 3228 | set(handles.edit_object,'Value',0) |
---|
| 3229 | set(handles.edit_object,'BackgroundColor',[0.7 0.7 0.7]) |
---|
| 3230 | % set(handles.cal,'Value',0) |
---|
| 3231 | % set(handles.cal,'BackgroundColor',[0 1 0]) |
---|
| 3232 | set(handles.edit_vect,'Value',0) |
---|
| 3233 | edit_vect_Callback(hObject, eventdata, handles) |
---|
| 3234 | %initiate set_object GUI |
---|
| 3235 | data.Name='VOLUME'; |
---|
| 3236 | if isfield(UvData,'CoordType') |
---|
| 3237 | data.CoordType=UvData.CoordType; |
---|
| 3238 | end |
---|
| 3239 | if isfield(UvData,'Mesh')&~isempty(UvData.Mesh) |
---|
| 3240 | data.RangeY=UvData.Mesh; |
---|
| 3241 | data.RangeX=UvData.Mesh; |
---|
| 3242 | data.DX=UvData.Mesh; |
---|
| 3243 | data.DY=UvData.Mesh; |
---|
| 3244 | elseif isfield(UvData.Field,'AX')&isfield(UvData.Field,'AY')& isfield(UvData.Field,'A')%only image |
---|
| 3245 | np=size(UvData.Field.A); |
---|
| 3246 | meshx=(UvData.Field.AX(end)-UvData.Field.AX(1))/np(2); |
---|
| 3247 | meshy=abs(UvData.Field.AY(end)-UvData.Field.AY(1))/np(1); |
---|
| 3248 | data.RangeY=max(meshx,meshy); |
---|
| 3249 | data.RangeX=max(meshx,meshy); |
---|
| 3250 | data.DX=max(meshx,meshy); |
---|
| 3251 | end |
---|
| 3252 | data.ParentButton=handles.VOLUME; |
---|
| 3253 | PlotHandles=get_plot_handles(handles);%get the handles of the interface elements setting the plotting parameters |
---|
| 3254 | [hset_object,UvData.sethandles]=set_object(data,PlotHandles);% call the set_object interface with action on haxes, |
---|
| 3255 | % associate the set_object interface handle to the plotting axes |
---|
| 3256 | if isfield(UvData.OpenParam,'SetObjectOrigin') |
---|
| 3257 | pos_uvmat=get(handles.uvmat,'Position'); |
---|
| 3258 | pos_set_object(1:2)=UvData.OpenParam.SetObjectOrigin + pos_uvmat(1:2); |
---|
| 3259 | pos_set_object(3:4)=UvData.OpenParam.SetObjectSize .* pos_uvmat(3:4); |
---|
| 3260 | set(hset_object,'Position',pos_set_object) |
---|
| 3261 | end |
---|
| 3262 | UvData.MouseAction='create_object'; |
---|
| 3263 | else |
---|
| 3264 | set(handles.VOLUME,'BackgroundColor',[0 1 0]) |
---|
| 3265 | UvData.MouseAction='none'; |
---|
| 3266 | end |
---|
| 3267 | set(handles.uvmat,'UserData',UvData) |
---|
| 3268 | |
---|
| 3269 | %------------------------------------------------------- |
---|
| 3270 | function edit_vect_Callback(hObject, eventdata, handles) |
---|
| 3271 | %------------------------------------------------------- |
---|
| 3272 | % |
---|
| 3273 | % UvData=get(handles.uvmat,'UserData');%read UvData properties stored on the uvmat interface |
---|
| 3274 | if isequal(get(handles.edit_vect,'Value'),1) |
---|
| 3275 | test_civ2=isequal(get(handles.civ2,'BackgroundColor'),[1 1 0]); |
---|
| 3276 | test_civ1=isequal(get(handles.VelType,'BackgroundColor'),[1 1 0]); |
---|
| 3277 | if ~test_civ2 && ~test_civ1 |
---|
| 3278 | msgbox_uvmat('ERROR','manual correction only possible for CIV1 or CIV2 velocity fields') |
---|
| 3279 | end |
---|
| 3280 | set(handles.record,'Visible','on') |
---|
| 3281 | set(handles.edit_vect,'BackgroundColor',[1 1 0]) |
---|
| 3282 | set(handles.edit_object,'Value',0) |
---|
| 3283 | set(handles.CheckZoom,'Value',0) |
---|
| 3284 | set(handles.CheckZoom,'BackgroundColor',[0.7 0.7 0.7]) |
---|
| 3285 | % set(handles.create,'Value',0) |
---|
| 3286 | % set(handles.create,'BackgroundColor',[0 1 0]) |
---|
| 3287 | set(handles.edit_object,'BackgroundColor',[0.7 0.7 0.7]) |
---|
| 3288 | set(gcf,'Pointer','arrow') |
---|
| 3289 | % UvData.MouseAction='edit_vect'; |
---|
| 3290 | else |
---|
| 3291 | set(handles.record,'Visible','off') |
---|
| 3292 | set(handles.edit_vect,'BackgroundColor',[0.7 0.7 0.7]) |
---|
| 3293 | % UvData.MouseAction='none'; |
---|
| 3294 | end |
---|
| 3295 | % set(handles.uvmat,'UserData',UvData) |
---|
| 3296 | |
---|
| 3297 | %---------------------------------------------- |
---|
| 3298 | function save_mask_Callback(hObject, eventdata, handles) |
---|
| 3299 | %----------------------------------------------------------------------- |
---|
| 3300 | UvData=get(handles.uvmat,'UserData'); |
---|
| 3301 | |
---|
| 3302 | flag=1; |
---|
| 3303 | npx=size(UvData.Field.A,2); |
---|
| 3304 | npy=size(UvData.Field.A,1); |
---|
| 3305 | xi=0.5:npx-0.5; |
---|
| 3306 | yi=0.5:npy-0.5; |
---|
| 3307 | [Xi,Yi]=meshgrid(xi,yi); |
---|
| 3308 | if isfield(UvData,'Object') |
---|
| 3309 | for iobj=1:length(UvData.Object) |
---|
| 3310 | ObjectData=UvData.Object{iobj}; |
---|
| 3311 | if isfield(ObjectData,'ProjMode') &&(isequal(ObjectData.ProjMode,'mask_inside')||isequal(ObjectData.ProjMode,'mask_outside')); |
---|
| 3312 | flagobj=1; |
---|
| 3313 | testphys=0; %coordinates in pixels by default |
---|
| 3314 | if isfield(ObjectData,'CoordType') && isequal(ObjectData.CoordType,'phys') |
---|
| 3315 | if isfield(UvData,'XmlData')&& isfield(UvData.XmlData{1},'GeometryCalib') |
---|
| 3316 | Calib=UvData.XmlData{1}.GeometryCalib; |
---|
| 3317 | testphys=1; |
---|
| 3318 | end |
---|
| 3319 | end |
---|
| 3320 | if isfield(ObjectData,'Coord')& isfield(ObjectData,'Style') |
---|
| 3321 | if isequal(ObjectData.Type,'polygon') |
---|
| 3322 | X=ObjectData.Coord(:,1); |
---|
| 3323 | Y=ObjectData.Coord(:,2); |
---|
| 3324 | if testphys |
---|
| 3325 | [X,Y]=px_XYZ(Calib,X,Y,0);% to generalise with 3D cases |
---|
| 3326 | end |
---|
| 3327 | flagobj=~inpolygon(Xi,Yi,X',Y');%=0 inside the polygon, 1 outside |
---|
| 3328 | elseif isequal(ObjectData.Type,'ellipse') |
---|
| 3329 | if testphys |
---|
| 3330 | %[X,Y]=px_XYZ(Calib,X,Y,0);% TODO:create a polygon boundary and transform to phys |
---|
| 3331 | end |
---|
| 3332 | RangeX=max(ObjectData.RangeX); |
---|
| 3333 | RangeY=max(ObjectData.RangeY); |
---|
| 3334 | X2Max=RangeX*RangeX; |
---|
| 3335 | Y2Max=RangeY*RangeY; |
---|
| 3336 | distX=(Xi-ObjectData.Coord(1,1)); |
---|
| 3337 | distY=(Yi-ObjectData.Coord(1,2)); |
---|
| 3338 | flagobj=(distX.*distX/X2Max+distY.*distY/Y2Max)>1; |
---|
| 3339 | elseif isequal(ObjectData.Type,'rectangle') |
---|
| 3340 | if testphys |
---|
| 3341 | %[X,Y]=px_XYZ(Calib,X,Y,0);% TODO:create a polygon boundary and transform to phys |
---|
| 3342 | end |
---|
| 3343 | distX=abs(Xi-ObjectData.Coord(1,1)); |
---|
| 3344 | distY=abs(Yi-ObjectData.Coord(1,2)); |
---|
| 3345 | flagobj=distX>max(ObjectData.RangeX) | distY>max(ObjectData.RangeY); |
---|
| 3346 | end |
---|
| 3347 | if isequal(ObjectData.ProjMode,'mask_outside') |
---|
| 3348 | flagobj=~flagobj; |
---|
| 3349 | end |
---|
| 3350 | flag=flag & flagobj; |
---|
| 3351 | end |
---|
| 3352 | end |
---|
| 3353 | end |
---|
| 3354 | end |
---|
| 3355 | % flag=~flag; |
---|
| 3356 | %mask name |
---|
| 3357 | RootPath=get(handles.RootPath,'String'); |
---|
| 3358 | RootFile=get(handles.RootFile,'String'); |
---|
| 3359 | RootFile=regexprep(RootFile,'\<[\\/]|[\\/]\>','');%suppress possible / or \ separator at the beginning or the end of the string |
---|
| 3360 | filebase=fullfile(RootPath,RootFile); |
---|
| 3361 | list=get(handles.masklevel,'String'); |
---|
| 3362 | masknumber=num2str(length(list)); |
---|
| 3363 | maskindex=get(handles.masklevel,'Value'); |
---|
| 3364 | mask_name=fullfile_uvmat(RootPath,SubDir,[RootFile '_' masknumber 'mask'],'.png','_1',maskindex); |
---|
| 3365 | %mask_name=name_generator([filebase '_' masknumber 'mask'],maskindex,1,'.png','_i'); |
---|
| 3366 | imflag=uint8(255*(0.392+0.608*flag));% =100 for flag=0 (vectors not computed when 20<imflag<200) |
---|
| 3367 | imflag=flipdim(imflag,1); |
---|
| 3368 | % imflag=uint8(255*flag);% =0 for flag=0 (vectors=0 when 20<imflag<200) |
---|
| 3369 | msgbox_uvmat('CONFIRMATION',[mask_name ' saved']) |
---|
| 3370 | imwrite(imflag,mask_name,'BitDepth',8); |
---|
| 3371 | |
---|
| 3372 | %display the mask |
---|
| 3373 | figure; |
---|
| 3374 | vec=linspace(0,1,256);%define a linear greyscale colormap |
---|
| 3375 | map=[vec' vec' vec']; |
---|
| 3376 | colormap(map) |
---|
| 3377 | |
---|
| 3378 | image(imflag); |
---|
| 3379 | |
---|
| 3380 | %------------------------------------------------------------------- |
---|
| 3381 | %------------------------------------------------------------------- |
---|
| 3382 | % - FUNCTIONS FOR SETTING PLOTTING PARAMETERS |
---|
| 3383 | |
---|
| 3384 | %------------------------------------------------------------------ |
---|
| 3385 | |
---|
| 3386 | %------------------------------------------------------------------ |
---|
| 3387 | % --- Executes on selection change in ListColorScalar: choice of the color code. |
---|
| 3388 | function ListColorScalar_Callback(hObject, eventdata, handles) |
---|
| 3389 | %------------------------------------------------------------------ |
---|
| 3390 | % edit the choice for color code |
---|
| 3391 | list_code=get(handles.ListColorScalar,'String');% list menu fields |
---|
| 3392 | index_code=get(handles.ListColorScalar,'Value');% selected string index |
---|
| 3393 | col_code= list_code{index_code(1)}; % selected field |
---|
| 3394 | if isequal(col_code,'black') || isequal(col_code,'white') |
---|
| 3395 | set(handles.Slider1,'Visible','off') |
---|
| 3396 | set(handles.Slider2,'Visible','off') |
---|
| 3397 | set(handles.num_ColCode1,'Visible','off') |
---|
| 3398 | set(handles.num_ColCode2,'Visible','off') |
---|
| 3399 | set(handles.CheckFixVecColor,'Visible','off') |
---|
| 3400 | set_vec_col_bar(handles) |
---|
| 3401 | else |
---|
| 3402 | set(handles.Slider1,'Visible','on') |
---|
| 3403 | set(handles.Slider2,'Visible','on') |
---|
| 3404 | set(handles.num_ColCode1,'Visible','on') |
---|
| 3405 | set(handles.num_ColCode2,'Visible','on') |
---|
| 3406 | set(handles.CheckFixVecColor,'Visible','on') |
---|
| 3407 | if isequal(col_code,'ima_cor') |
---|
| 3408 | set(handles.CheckFixVecColor,'Value',0)%fixed scale by default |
---|
| 3409 | set(handles.VecColBar,'Value',0)% 3 colors r,g,b by default |
---|
| 3410 | set(handles.Slider1,'Min',0); |
---|
| 3411 | set(handles.Slider1,'Max',1); |
---|
| 3412 | set(handles.Slider2,'Min',0); |
---|
| 3413 | set(handles.Slider2,'Max',1); |
---|
| 3414 | % set(handles.min_title_vec,'String','0') |
---|
| 3415 | set(handles.num_MaxVec,'String','1') |
---|
| 3416 | set(handles.num_ColCode1,'String','0.333') |
---|
| 3417 | num_ColCode1_Callback(hObject, eventdata, handles) |
---|
| 3418 | set(handles.num_ColCode2,'String','0.666') |
---|
| 3419 | num_ColCode2_Callback(hObject, eventdata, handles) |
---|
| 3420 | else |
---|
| 3421 | set(handles.CheckFixVecColor,'Value',1)%auto scale between min,max by default |
---|
| 3422 | set(handles.VecColBar,'Value',1)% colormap 'jet' by default |
---|
| 3423 | minval=get(handles.Slider1,'Min'); |
---|
| 3424 | maxval=get(handles.Slider1,'Max'); |
---|
| 3425 | set(handles.Slider1,'Value',minval) |
---|
| 3426 | set(handles.Slider2,'Value',maxval) |
---|
| 3427 | set_vec_col_bar(handles) |
---|
| 3428 | end |
---|
| 3429 | % slider_update(handles) |
---|
| 3430 | end |
---|
| 3431 | %replot the current graph |
---|
| 3432 | run0_Callback(hObject, eventdata, handles) |
---|
| 3433 | |
---|
| 3434 | |
---|
| 3435 | %---------------------------------------------------------------- |
---|
| 3436 | % -- Executes on slider movement to set the color code |
---|
| 3437 | % |
---|
| 3438 | function Slider1_Callback(hObject, eventdata, handles) |
---|
| 3439 | %------------------------------------------------------------------ |
---|
| 3440 | slider1=get(handles.Slider1,'Value'); |
---|
| 3441 | min_val=str2num(get(handles.num_MinVec,'String')); |
---|
| 3442 | max_val=str2num(get(handles.num_MaxVec,'String')); |
---|
| 3443 | col=min_val+(max_val-min_val)*slider1; |
---|
| 3444 | set(handles.num_ColCode1,'String',num2str(col)) |
---|
| 3445 | if(get(handles.Slider2,'Value') < col)%move also the second slider at the same value if needed |
---|
| 3446 | set(handles.Slider2,'Value',col) |
---|
| 3447 | set(handles.num_ColCode2,'String',num2str(col)) |
---|
| 3448 | end |
---|
| 3449 | num_ColCode1_Callback(hObject, eventdata, handles) |
---|
| 3450 | |
---|
| 3451 | %---------------------------------------------------------------- |
---|
| 3452 | % Executes on slider movement to set the color code |
---|
| 3453 | %---------------------------------------------------------------- |
---|
| 3454 | function Slider2_Callback(hObject, eventdata, handles) |
---|
| 3455 | slider2=get(handles.Slider2,'Value'); |
---|
| 3456 | min_val=str2num(get(handles.num_MinVec,'String')); |
---|
| 3457 | max_val=str2num(get(handles.num_MaxVec,'String')); |
---|
| 3458 | col=min_val+(max_val-min_val)*slider2; |
---|
| 3459 | set(handles.num_ColCode2,'String',num2str(col)) |
---|
| 3460 | if(get(handles.Slider1,'Value') > col)%move also the first slider at the same value if needed |
---|
| 3461 | set(handles.Slider1,'Value',col) |
---|
| 3462 | set(handles.num_ColCode1,'String',num2str(col)) |
---|
| 3463 | end |
---|
| 3464 | num_ColCode2_Callback(hObject, eventdata, handles) |
---|
| 3465 | |
---|
| 3466 | %---------------------------------------------------------------- |
---|
| 3467 | % --- Execute on return carriage on the edit box corresponding to slider 1 |
---|
| 3468 | %---------------------------------------------------------------- |
---|
| 3469 | function num_ColCode1_Callback(hObject, eventdata, handles) |
---|
| 3470 | set_vec_col_bar(handles) |
---|
| 3471 | update_plot(handles); |
---|
| 3472 | |
---|
| 3473 | %---------------------------------------------------------------- |
---|
| 3474 | % --- Execute on return carriage on the edit box corresponding to slider 2 |
---|
| 3475 | %---------------------------------------------------------------- |
---|
| 3476 | function num_ColCode2_Callback(hObject, eventdata, handles) |
---|
| 3477 | set_vec_col_bar(handles) |
---|
| 3478 | update_plot(handles); |
---|
| 3479 | %------------------------------------------------------------------------ |
---|
| 3480 | %------------------------------------------------------- |
---|
| 3481 | % --- Executes on button press in CheckFixVecColor. |
---|
| 3482 | %------------------------------------------------------- |
---|
| 3483 | function VecColBar_Callback(hObject, eventdata, handles) |
---|
| 3484 | set_vec_col_bar(handles) |
---|
| 3485 | |
---|
| 3486 | %------------------------------------------------------------- |
---|
| 3487 | % --- Executes on selection change in transform_fct. |
---|
| 3488 | function transform_fct_Callback(hObject, eventdata, handles) |
---|
| 3489 | %------------------------------------------------------------- |
---|
| 3490 | UvData=get(handles.uvmat,'UserData'); |
---|
| 3491 | menu=get(handles.transform_fct,'String'); |
---|
| 3492 | ind_coord=get(handles.transform_fct,'Value'); |
---|
| 3493 | coord_option=menu{ind_coord}; |
---|
| 3494 | list_transform=get(handles.transform_fct,'UserData'); |
---|
| 3495 | ff=functions(list_transform{end}); |
---|
| 3496 | if isequal(coord_option,'more...'); |
---|
| 3497 | coord_fct=''; |
---|
| 3498 | prompt = {'Enter the name of the transform function'}; |
---|
| 3499 | dlg_title = 'user defined transform'; |
---|
| 3500 | num_lines= 1; |
---|
| 3501 | [FileName, PathName] = uigetfile( ... |
---|
| 3502 | {'*.m', ' (*.m)'; |
---|
| 3503 | '*.m', '.m files '; ... |
---|
| 3504 | '*.*', 'All Files (*.*)'}, ... |
---|
| 3505 | 'Pick a file', ff.file); |
---|
| 3506 | if isequal(PathName(end),'/')||isequal(PathName(end),'\') |
---|
| 3507 | PathName(end)=[]; |
---|
| 3508 | end |
---|
| 3509 | transform_selected =fullfile(PathName,FileName); |
---|
| 3510 | if ~exist(transform_selected,'file') |
---|
| 3511 | return |
---|
| 3512 | end |
---|
| 3513 | [ppp,transform,ext_fct]=fileparts(FileName);% removes extension .m |
---|
| 3514 | if ~isequal(ext_fct,'.m') |
---|
| 3515 | msgbox_uvmat('ERROR','a Matlab function .m must be introduced'); |
---|
| 3516 | return |
---|
| 3517 | end |
---|
| 3518 | menu=update_menu(handles.transform_fct,transform);%add the selected fct to the menu |
---|
| 3519 | ind_coord=get(handles.transform_fct,'Value'); |
---|
| 3520 | addpath(PathName) |
---|
| 3521 | list_transform{ind_coord}=str2func(transform);% create the function handle corresponding to the newly seleced function |
---|
| 3522 | set(handles.transform_fct,'UserData',list_transform) |
---|
| 3523 | rmpath(PathName) |
---|
| 3524 | % save the new menu in the personal file 'uvmat_perso.mat' |
---|
| 3525 | dir_perso=prefdir;%personal Matalb directory |
---|
| 3526 | profil_perso=fullfile(dir_perso,'uvmat_perso.mat'); |
---|
| 3527 | if exist(profil_perso,'file') |
---|
| 3528 | nb_builtin=UvData.OpenParam.NbBuiltin; |
---|
| 3529 | for ilist=nb_builtin+1:numel(list_transform) |
---|
| 3530 | ff=functions(list_transform{ilist}); |
---|
| 3531 | transform_fct{ilist-nb_builtin}=ff.file; |
---|
| 3532 | end |
---|
| 3533 | save (profil_perso,'transform_fct','-append'); %store the root name for future opening of uvmat |
---|
| 3534 | end |
---|
| 3535 | end |
---|
| 3536 | |
---|
| 3537 | %check the current path to the selected function |
---|
| 3538 | if isa(list_transform{ind_coord},'function_handle') |
---|
| 3539 | func=functions(list_transform{ind_coord}); |
---|
| 3540 | set(handles.path_transform,'String',fileparts(func.file)); %show the path to the senlected function |
---|
| 3541 | else |
---|
| 3542 | set(handles.path_transform,'String','') |
---|
| 3543 | end |
---|
| 3544 | |
---|
| 3545 | set(handles.CheckFixLimits,'Value',0) |
---|
| 3546 | set(handles.CheckFixLimits,'BackgroundColor',[0.7 0.7 0.7]) |
---|
| 3547 | |
---|
| 3548 | %delete drawn objects |
---|
| 3549 | hother=findobj('Tag','proj_object');%find all the proj objects |
---|
| 3550 | for iobj=1:length(hother) |
---|
| 3551 | delete_object(hother(iobj)) |
---|
| 3552 | end |
---|
| 3553 | hother=findobj('Tag','DeformPoint');%find all the proj objects |
---|
| 3554 | for iobj=1:length(hother) |
---|
| 3555 | delete_object(hother(iobj)) |
---|
| 3556 | end |
---|
| 3557 | hh=findobj('Tag','calib_points'); |
---|
| 3558 | if ~isempty(hh) |
---|
| 3559 | delete(hh) |
---|
| 3560 | end |
---|
| 3561 | hhh=findobj('Tag','calib_marker'); |
---|
| 3562 | if ~isempty(hhh) |
---|
| 3563 | delete(hhh) |
---|
| 3564 | end |
---|
| 3565 | if isfield(UvData,'Object') |
---|
| 3566 | UvData.Object=UvData.Object(1); |
---|
| 3567 | end |
---|
| 3568 | set(handles.ListObject,'Value',1) |
---|
| 3569 | set(handles.ListObject,'String',{''}) |
---|
| 3570 | |
---|
| 3571 | %delete mask if it is displayed |
---|
| 3572 | if isequal(get(handles.CheckMask,'Value'),1)%if the mask option is on |
---|
| 3573 | UvData=rmfield(UvData,'MaskName'); %will impose mask refresh |
---|
| 3574 | end |
---|
| 3575 | set(handles.uvmat,'UserData',UvData) |
---|
| 3576 | run0_Callback(hObject, eventdata, handles) |
---|
| 3577 | |
---|
| 3578 | %------------------------------------------------------------------------ |
---|
| 3579 | function histo1_menu_Callback(hObject, eventdata, handles) |
---|
| 3580 | %-------------------------------------------- |
---|
| 3581 | %plot first histo |
---|
| 3582 | %huvmat=get(handles.histo1_menu,'parent'); |
---|
| 3583 | histo_menu=get(handles.histo1_menu,'String'); |
---|
| 3584 | histo_value=get(handles.histo1_menu,'Value'); |
---|
| 3585 | FieldName=histo_menu{histo_value}; |
---|
| 3586 | update_histo(handles.histo_u,handles.uvmat,FieldName) |
---|
| 3587 | |
---|
| 3588 | %------------------------------------------------------------------------ |
---|
| 3589 | function histo2_menu_Callback(hObject, eventdata, handles) |
---|
| 3590 | %------------------------------------------------------------------------ |
---|
| 3591 | %plot second histo |
---|
| 3592 | %huvmat=get(handles.histo2_menu,'parent'); |
---|
| 3593 | histo_menu=get(handles.histo2_menu,'String'); |
---|
| 3594 | histo_value=get(handles.histo2_menu,'Value'); |
---|
| 3595 | FieldName=histo_menu{histo_value}; |
---|
| 3596 | update_histo(handles.histo_v,handles.uvmat,FieldName) |
---|
| 3597 | |
---|
| 3598 | %------------------------------------------------------------------------ |
---|
| 3599 | %read the field .Fieldname stored in UvData and plot its histogram |
---|
| 3600 | function update_histo(haxes,huvmat,FieldName) |
---|
| 3601 | %------------------------------------------------------------------------ |
---|
| 3602 | UvData=get(huvmat,'UserData'); |
---|
| 3603 | if ~isfield(UvData.Field,FieldName) |
---|
| 3604 | msgbox_uvmat('ERROR',['no field ' FieldName ' for histogram']) |
---|
| 3605 | return |
---|
| 3606 | end |
---|
| 3607 | Field=UvData.Field; |
---|
| 3608 | FieldHisto=eval(['Field.' FieldName]); |
---|
| 3609 | if isfield(Field,'FF') && ~isempty(Field.FF) && isequal(size(Field.FF),size(FieldHisto)) |
---|
| 3610 | indsel=find(Field.FF==0);%find values marked as false |
---|
| 3611 | if ~isempty(indsel) |
---|
| 3612 | FieldHisto=FieldHisto(indsel); |
---|
| 3613 | end |
---|
| 3614 | end |
---|
| 3615 | if isempty(Field) |
---|
| 3616 | msgbox_uvmat('ERROR',['empty field ' FieldName]) |
---|
| 3617 | else |
---|
| 3618 | nxy=size(FieldHisto); |
---|
| 3619 | Amin=double(min(min(min(FieldHisto))));%min of image |
---|
| 3620 | Amax=double(max(max(max(FieldHisto))));%max of image |
---|
| 3621 | if isequal(Amin,Amax) |
---|
| 3622 | %msgbox_uvmat('WARNING',['uniform field =' num2str(Amin)]); |
---|
| 3623 | cla(haxes) |
---|
| 3624 | else |
---|
| 3625 | Histo.ListVarName={FieldName,'histo'}; |
---|
| 3626 | if isfield(Field,'NbDim') && isequal(Field.NbDim,3) |
---|
| 3627 | Histo.VarDimName={FieldName,FieldName}; %dimensions for the histogram |
---|
| 3628 | else |
---|
| 3629 | if numel(nxy)==2 |
---|
| 3630 | Histo.VarDimName={FieldName,FieldName}; %dimensions for the histogram |
---|
| 3631 | else |
---|
| 3632 | Histo.VarDimName={FieldName,{FieldName,'rgb'}}; %dimensions for the histogram |
---|
| 3633 | end |
---|
| 3634 | end |
---|
| 3635 | %unit |
---|
| 3636 | units=[]; %default |
---|
| 3637 | for ivar=1:numel(Field.ListVarName) |
---|
| 3638 | if strcmp(Field.ListVarName{ivar},FieldName) |
---|
| 3639 | if isfield(Field,'VarAttribute') && numel(Field.VarAttribute)>=ivar && isfield(Field.VarAttribute{ivar},'units') |
---|
| 3640 | units=Field.VarAttribute{ivar}.units; |
---|
| 3641 | break |
---|
| 3642 | end |
---|
| 3643 | end |
---|
| 3644 | end |
---|
| 3645 | if ~isempty(units) |
---|
| 3646 | Histo.VarAttribute{1}.units=units; |
---|
| 3647 | end |
---|
| 3648 | eval(['Histo.' FieldName '=linspace(Amin,Amax,50);'])%absissa values for histo |
---|
| 3649 | if isfield(Field,'NbDim') && isequal(Field.NbDim,3) |
---|
| 3650 | C=reshape(double(FieldHisto),1,[]);% reshape in a vector |
---|
| 3651 | eval(['Histo.histo(:,1)=hist(C, Histo.' FieldName ');']); %calculate histogram |
---|
| 3652 | else |
---|
| 3653 | for col=1:size(FieldHisto,3) |
---|
| 3654 | B=FieldHisto(:,:,col); |
---|
| 3655 | C=reshape(double(B),1,nxy(1)*nxy(2));% reshape in a vector |
---|
| 3656 | eval(['Histo.histo(:,col)=hist(C, Histo.' FieldName ');']); %calculate histogram |
---|
| 3657 | end |
---|
| 3658 | end |
---|
| 3659 | plot_field(Histo,haxes); |
---|
| 3660 | end |
---|
| 3661 | end |
---|
| 3662 | |
---|
| 3663 | %------------------------------------------------ |
---|
| 3664 | %CALLBACKS FOR PLOTTING PARAMETERS |
---|
| 3665 | %------------------------------------------------- |
---|
| 3666 | |
---|
| 3667 | %------------------------------------------------------------------------ |
---|
| 3668 | function num_MinX_Callback(hObject, eventdata, handles) |
---|
| 3669 | %------------------------------------------------------------------------ |
---|
| 3670 | set(handles.CheckFixLimits,'Value',1) %suppress auto mode |
---|
| 3671 | set(handles.CheckFixLimits,'BackgroundColor',[1 1 0]) |
---|
| 3672 | update_plot(handles); |
---|
| 3673 | |
---|
| 3674 | %------------------------------------------------------------------------ |
---|
| 3675 | function num_MaxX_Callback(hObject, eventdata, handles) |
---|
| 3676 | %------------------------------------------------------------------------ |
---|
| 3677 | set(handles.CheckFixLimits,'Value',1) %suppress auto mode |
---|
| 3678 | set(handles.CheckFixLimits,'BackgroundColor',[1 1 0]) |
---|
| 3679 | update_plot(handles); |
---|
| 3680 | |
---|
| 3681 | %------------------------------------------------------------------------ |
---|
| 3682 | function num_MinY_Callback(hObject, eventdata, handles) |
---|
| 3683 | %------------------------------------------ |
---|
| 3684 | set(handles.CheckFixLimits,'Value',1) %suppress auto mode |
---|
| 3685 | set(handles.CheckFixLimits,'BackgroundColor',[1 1 0]) |
---|
| 3686 | update_plot(handles); |
---|
| 3687 | |
---|
| 3688 | %------------------------------------------------------------------------ |
---|
| 3689 | function num_MaxY_Callback(hObject, eventdata, handles) |
---|
| 3690 | %------------------------------------------------------------------------ |
---|
| 3691 | set(handles.CheckFixLimits,'Value',1) %suppress auto mode |
---|
| 3692 | set(handles.CheckFixLimits,'BackgroundColor',[1 1 0]) |
---|
| 3693 | update_plot(handles); |
---|
| 3694 | |
---|
| 3695 | %------------------------------------------------------------------------ |
---|
| 3696 | function num_MinA_Callback(hObject, eventdata, handles) |
---|
| 3697 | %------------------------------------------ |
---|
| 3698 | set(handles.CheckFixScalar,'Value',1) %suppress auto mode |
---|
| 3699 | set(handles.CheckFixScalar,'BackgroundColor',[1 1 0]) |
---|
| 3700 | MinA=str2double(get(handles.num_MinA,'String')); |
---|
| 3701 | MaxA=str2double(get(handles.num_MaxA,'String')); |
---|
| 3702 | if MinA>MaxA% switch minA and maxA in case of error |
---|
| 3703 | MinA_old=MinA; |
---|
| 3704 | MinA=MaxA; |
---|
| 3705 | MaxA=MinA_old; |
---|
| 3706 | set(handles.num_MinA,'String',num2str(MinA,5)); |
---|
| 3707 | set(handles.num_MaxA,'String',num2str(MaxA,5)); |
---|
| 3708 | end |
---|
| 3709 | update_plot(handles); |
---|
| 3710 | |
---|
| 3711 | %------------------------------------------------------------------------ |
---|
| 3712 | function num_MaxA_Callback(hObject, eventdata, handles) |
---|
| 3713 | %------------------------------------------------------------------------ |
---|
| 3714 | set(handles.CheckFixScalar,'Value',1) %suppress auto mode |
---|
| 3715 | set(handles.CheckFixScalar,'BackgroundColor',[1 1 0]) |
---|
| 3716 | MinA=str2double(get(handles.num_MinA,'String')); |
---|
| 3717 | MaxA=str2double(get(handles.num_MaxA,'String')); |
---|
| 3718 | if MinA>MaxA% switch minA and maxA in case of error |
---|
| 3719 | MinA_old=MinA; |
---|
| 3720 | MinA=MaxA; |
---|
| 3721 | MaxA=MinA_old; |
---|
| 3722 | set(handles.num_MinA,'String',num2str(MinA,5)); |
---|
| 3723 | set(handles.num_MaxA,'String',num2str(MaxA,5)); |
---|
| 3724 | end |
---|
| 3725 | update_plot(handles); |
---|
| 3726 | |
---|
| 3727 | %------------------------------------------------------------------------ |
---|
| 3728 | function CheckFixScalar_Callback(hObject, eventdata, handles) |
---|
| 3729 | %------------------------------------------------------------------------ |
---|
| 3730 | test=get(handles.CheckFixScalar,'Value'); |
---|
| 3731 | if test |
---|
| 3732 | set(handles.CheckFixScalar,'BackgroundColor',[1 1 0]) |
---|
| 3733 | else |
---|
| 3734 | set(handles.CheckFixScalar,'BackgroundColor',[0.7 0.7 0.7]) |
---|
| 3735 | update_plot(handles); |
---|
| 3736 | end |
---|
| 3737 | |
---|
| 3738 | %------------------------------------------------------------------- |
---|
| 3739 | function CheckBW_Callback(hObject, eventdata, handles) |
---|
| 3740 | %------------------------------------------------------------------- |
---|
| 3741 | update_plot(handles); |
---|
| 3742 | |
---|
| 3743 | %------------------------------------------------------------------- |
---|
| 3744 | function ListContour_Callback(hObject, eventdata, handles) |
---|
| 3745 | %------------------------------------------------------------------- |
---|
| 3746 | val=get(handles.ListContour,'Value'); |
---|
| 3747 | if val==2 |
---|
| 3748 | set(handles.interval_txt,'Visible','on') |
---|
| 3749 | set(handles.num_IncrA,'Visible','on') |
---|
| 3750 | else |
---|
| 3751 | set(handles.interval_txt,'Visible','off') |
---|
| 3752 | set(handles.num_IncrA,'Visible','off') |
---|
| 3753 | end |
---|
| 3754 | update_plot(handles); |
---|
| 3755 | |
---|
| 3756 | %------------------------------------------------------------------- |
---|
| 3757 | function num_IncrA_Callback(hObject, eventdata, handles) |
---|
| 3758 | %------------------------------------------------------------------- |
---|
| 3759 | update_plot(handles); |
---|
| 3760 | |
---|
| 3761 | %------------------------------------------------------------------- |
---|
| 3762 | function CheckHideWarning_Callback(hObject, eventdata, handles) |
---|
| 3763 | %------------------------------------------------------------------- |
---|
| 3764 | update_plot(handles); |
---|
| 3765 | |
---|
| 3766 | %------------------------------------------------------------------- |
---|
| 3767 | function CheckHideFalse_Callback(hObject, eventdata, handles) |
---|
| 3768 | %------------------------------------------------------------------- |
---|
| 3769 | update_plot(handles); |
---|
| 3770 | |
---|
| 3771 | %------------------------------------------------------------------- |
---|
| 3772 | function num_VecScale_Callback(hObject, eventdata, handles) |
---|
| 3773 | %------------------------------------------------------------------- |
---|
| 3774 | set(handles.CheckFixVectors,'Value',1); |
---|
| 3775 | set(handles.CheckFixVectors,'BackgroundColor',[1 1 0]) |
---|
| 3776 | update_plot(handles); |
---|
| 3777 | |
---|
| 3778 | %------------------------------------------------------------------- |
---|
| 3779 | function CheckFixVectors_Callback(hObject, eventdata, handles) |
---|
| 3780 | %------------------------------------------------------------------- |
---|
| 3781 | test=get(handles.CheckFixVectors,'Value'); |
---|
| 3782 | if test |
---|
| 3783 | set(handles.CheckFixVectors,'BackgroundColor',[1 1 0]) |
---|
| 3784 | else |
---|
| 3785 | update_plot(handles); |
---|
| 3786 | %set(handles.num_VecScale,'String',num2str(ScalOut.num_VecScale,3)) |
---|
| 3787 | set(handles.CheckFixVectors,'BackgroundColor',[0.7 0.7 0.7]) |
---|
| 3788 | end |
---|
| 3789 | |
---|
| 3790 | %------------------------------------------------------------------------ |
---|
| 3791 | % --- Executes on selection change in CheckDecimate4 (nb_vec/4). |
---|
| 3792 | function CheckDecimate4_Callback(hObject, eventdata, handles) |
---|
| 3793 | %------------------------------------------------------------------------ |
---|
| 3794 | update_plot(handles); |
---|
| 3795 | |
---|
| 3796 | %------------------------------------------------------------------------ |
---|
| 3797 | % --- Executes on selection change in ListColorCode menu |
---|
| 3798 | function ListColorCode_Callback(hObject, eventdata, handles) |
---|
| 3799 | %------------------------------------------------------------------------ |
---|
| 3800 | set_vec_col_bar(handles) |
---|
| 3801 | update_plot(handles); |
---|
| 3802 | |
---|
| 3803 | %------------------------------------------------------------------------ |
---|
| 3804 | % --- Executes on button press in CheckFixVecColor. |
---|
| 3805 | function CheckFixVecColor_Callback(hObject, eventdata, handles) |
---|
| 3806 | %------------------------------------------------------------------------ |
---|
| 3807 | test=get(handles.CheckFixVecColor,'Value'); |
---|
| 3808 | if test |
---|
| 3809 | set(handles.CheckFixVecColor,'BackgroundColor',[1 1 0]) |
---|
| 3810 | else |
---|
| 3811 | update_plot(handles); |
---|
| 3812 | %set(handles.num_VecScale,'String',num2str(ScalOut.num_VecScale,3)) |
---|
| 3813 | set(handles.CheckFixVecColor,'BackgroundColor',[0.7 0.7 0.7]) |
---|
| 3814 | end |
---|
| 3815 | |
---|
| 3816 | %------------------------------------------------------------------------ |
---|
| 3817 | % --- Executes on selection change in num_MaxVec. |
---|
| 3818 | function num_MinVec_Callback(hObject, eventdata, handles) |
---|
| 3819 | %------------------------------------------------------------------------ |
---|
| 3820 | max_vec_Callback(hObject, eventdata, handles) |
---|
| 3821 | |
---|
| 3822 | %------------------------------------------------------------------------ |
---|
| 3823 | % --- Executes on selection change in num_MaxVec. |
---|
| 3824 | function num_MaxVec_Callback(hObject, eventdata, handles) |
---|
| 3825 | %------------------------------------------------------------------------ |
---|
| 3826 | set(handles.CheckFixVecColor,'Value',1) |
---|
| 3827 | CheckFixVecColor_Callback(hObject, eventdata, handles) |
---|
| 3828 | min_val=str2num(get(handles.num_MinVec,'String')); |
---|
| 3829 | max_val=str2num(get(handles.num_MaxVec,'String')); |
---|
| 3830 | slider1=get(handles.Slider1,'Value'); |
---|
| 3831 | slider2=get(handles.Slider2,'Value'); |
---|
| 3832 | colcode1=min_val+(max_val-min_val)*slider1; |
---|
| 3833 | colcode2=min_val+(max_val-min_val)*slider2; |
---|
| 3834 | set(handles.num_ColCode1,'String',num2str(colcode1)) |
---|
| 3835 | set(handles.num_ColCode2,'String',num2str(colcode2)) |
---|
| 3836 | update_plot(handles); |
---|
| 3837 | |
---|
| 3838 | %------------------------------------------------------------------------ |
---|
| 3839 | % --- update the display of color code for vectors |
---|
| 3840 | function set_vec_col_bar(handles) |
---|
| 3841 | %------------------------------------------------------------------------ |
---|
| 3842 | %get the image of the color display button 'VecColBar' in pixels |
---|
| 3843 | set(handles.VecColBar,'Unit','pixel'); |
---|
| 3844 | pos_vert=get(handles.VecColBar,'Position'); |
---|
| 3845 | set(handles.VecColBar,'Unit','Normalized'); |
---|
| 3846 | width=ceil(pos_vert(3)); |
---|
| 3847 | height=ceil(pos_vert(4)); |
---|
| 3848 | |
---|
| 3849 | %get slider indications |
---|
| 3850 | list=get(handles.ListColorCode,'String'); |
---|
| 3851 | ichoice=get(handles.ListColorCode,'Value'); |
---|
| 3852 | colcode.ListColorCode=list{ichoice}; |
---|
| 3853 | colcode.MinVec=str2num(get(handles.num_MinVec,'String')); |
---|
| 3854 | colcode.MaxVec=str2num(get(handles.num_MaxVec,'String')); |
---|
| 3855 | test3color=strcmp(colcode.ListColorCode,'rgb') || strcmp(colcode.ListColorCode,'bgr'); |
---|
| 3856 | if test3color |
---|
| 3857 | colcode.ColCode1=str2num(get(handles.num_ColCode1,'String')); |
---|
| 3858 | colcode.ColCode2=str2num(get(handles.num_ColCode2,'String')); |
---|
| 3859 | end |
---|
| 3860 | % colcode.FixedCbounds=0; |
---|
| 3861 | %colcode.CheckFixVecColor=1; |
---|
| 3862 | vec_C=colcode.MinVec+(colcode.MaxVec-colcode.MinVec)*(0.5:width-0.5)/width;%sample of vec_C values from min to max |
---|
| 3863 | [colorlist,col_vec]=set_col_vec(colcode,vec_C); |
---|
| 3864 | oneheight=ones(1,height); |
---|
| 3865 | A1=colorlist(col_vec,1)*oneheight; |
---|
| 3866 | A2=colorlist(col_vec,2)*oneheight; |
---|
| 3867 | A3=colorlist(col_vec,3)*oneheight; |
---|
| 3868 | A(:,:,1)=A1'; |
---|
| 3869 | A(:,:,2)=A2'; |
---|
| 3870 | A(:,:,3)=A3'; |
---|
| 3871 | set(handles.VecColBar,'Cdata',A) |
---|
| 3872 | |
---|
| 3873 | %------------------------------------------------------------------- |
---|
| 3874 | function update_plot(handles) |
---|
| 3875 | %------------------------------------------------------------------- |
---|
| 3876 | UvData=get(handles.uvmat,'UserData'); |
---|
| 3877 | AxeData=UvData.axes3;% retrieve the current plotted data |
---|
| 3878 | PlotParam=read_GUI(handles.uvmat); |
---|
[399] | 3879 | [tild,PlotParamOut]= plot_field(AxeData,handles.axes3,PlotParam); |
---|
[387] | 3880 | write_plot_param(handles,PlotParamOut); %update the auto plot parameters |
---|
| 3881 | |
---|
[402] | 3882 | %------------------------------------------------------------------------ |
---|
| 3883 | %------------------------------------------------------------------------ |
---|
| 3884 | % SELECTION AND EDITION OF PROJECTION OBJECTS |
---|
| 3885 | %------------------------------------------------------------------------ |
---|
| 3886 | %------------------------------------------------------------------------ |
---|
[387] | 3887 | |
---|
| 3888 | %------------------------------------------------------------------------ |
---|
| 3889 | % --- Executes on selection change in ListObject. |
---|
| 3890 | function ListObject_Callback(hObject, eventdata, handles) |
---|
| 3891 | %------------------------------------------------------------------------ |
---|
| 3892 | list_str=get(handles.ListObject,'String'); |
---|
| 3893 | IndexObj_old=get(handles.ListObject,'UserData');%retrieve previous selection |
---|
| 3894 | IndexObj=get(handles.ListObject,'Value');%present object selection |
---|
| 3895 | |
---|
| 3896 | %% we select two objects or more at once (using the Ctrl key), keep only the last two items: the first is projected on uvmat, the second on view_field |
---|
| 3897 | if length(IndexObj)>2 |
---|
| 3898 | IndexObj=[IndexObj(end-1) IndexObj(end)];%keeps only the last two selected items at most |
---|
| 3899 | end |
---|
| 3900 | |
---|
| 3901 | %% we select one object |
---|
| 3902 | if length(IndexObj)==1% |
---|
| 3903 | if length(IndexObj_old)>=2 && isequal(IndexObj_old(1),IndexObj) % we select the first previously selected object-> |
---|
| 3904 | IndexObj=[1 IndexObj_old(2)];% it desactivates this object and selects the first object for uvmat |
---|
| 3905 | elseif length(IndexObj_old)>=2 && isequal(IndexObj_old(2),IndexObj) % we select the second previously selected object-> |
---|
| 3906 | IndexObj=IndexObj_old(1);% it desactivates this object and keeps only the first previously selected object (uvmat) |
---|
| 3907 | else % |
---|
| 3908 | IndexObj=[IndexObj_old(1) IndexObj];% activates a second object while keeping the first previously selected one |
---|
| 3909 | end |
---|
| 3910 | end |
---|
[402] | 3911 | |
---|
| 3912 | %% The second object is selected, it is displayed in set_object if this GUI is already opened |
---|
| 3913 | UvData=get(handles.uvmat,'UserData'); |
---|
| 3914 | ObjectData=UvData.Object{IndexObj(end)}; |
---|
| 3915 | hset_object=findobj(allchild(0),'tag','set_object'); |
---|
| 3916 | if ~isempty(hset_object) |
---|
| 3917 | delete(hset_object)% delete to refesh the content |
---|
| 3918 | ZBounds=0; % default |
---|
| 3919 | if isfield(UvData.Field,'ZMin') && isfield(UvData.Field,'ZMax') |
---|
| 3920 | ZBounds(1)=UvData.Field.ZMin; %minimum for the Z slider |
---|
| 3921 | ZBounds(2)=UvData.Field.ZMax;%maximum for the Z slider |
---|
| 3922 | end |
---|
| 3923 | ObjectData.Name=list_str{IndexObj(end)}; |
---|
| 3924 | set_object(ObjectData,[],ZBounds); |
---|
| 3925 | end |
---|
| 3926 | % desactivate the edit object mode |
---|
| 3927 | set(handles.edit_object,'Value',0) |
---|
| 3928 | set(handles.edit_object,'BackgroundColor',[0.7,0.7,0.7]) |
---|
| 3929 | |
---|
| 3930 | %% update the object value stored in ListObject |
---|
[387] | 3931 | set(handles.ListObject,'Value',IndexObj); % marks the selected objects in the list |
---|
| 3932 | set(handles.ListObject,'UserData',IndexObj)% keep the current object selection in memory for next time |
---|
[402] | 3933 | % |
---|
| 3934 | % UvData=get(handles.uvmat,'UserData');%read UvData properties stored on the uvmat interface |
---|
| 3935 | % if numel(UvData.Object)<max(IndexObj); |
---|
| 3936 | % msgbox_uvmat('ERROR','invalid object list') |
---|
| 3937 | % return |
---|
| 3938 | % end |
---|
| 3939 | % if numel(IndexObj)>=2 |
---|
| 3940 | % UvData.Object=update_obj(UvData,IndexObj(1),IndexObj(2));%update the current object graphic representation |
---|
| 3941 | % set(handles.uvmat,'UserData',UvData) |
---|
| 3942 | % end |
---|
[387] | 3943 | |
---|
[402] | 3944 | %% update the main plot (on uvmat) if the first selected object has been changed |
---|
| 3945 | if ~isequal(IndexObj(1),IndexObj_old(1)) |
---|
| 3946 | ProjData= proj_field(UvData.Field,ObjectData);%project the current interface field on UvData.Object{IndexObj(1)} |
---|
| 3947 | plot_field(ProjData,handles.axes3,read_GUI(handles.uvmat));%read plotting parameters on the uvmat interfacPlotHandles); |
---|
[387] | 3948 | end |
---|
| 3949 | |
---|
[402] | 3950 | %% update the second plot (on view_field) if view_field is already openened |
---|
| 3951 | axes_view_field=[];%default |
---|
[387] | 3952 | if length(IndexObj)==2 && (length(IndexObj_old)==1 || ~isequal(IndexObj(2),IndexObj_old(2))) |
---|
[402] | 3953 | hview_field=findobj(allchild(0),'tag','view_field'); |
---|
[387] | 3954 | if ~isempty(hview_field) |
---|
[402] | 3955 | PlotHandles=guidata(hview_field); |
---|
| 3956 | ProjData= proj_field(UvData.Field,ObjectData);%project the current interface field on ObjectData |
---|
| 3957 | axes_view_field=PlotHandles.axes3; |
---|
| 3958 | plot_field(ProjData,axes_view_field,read_GUI(hview_field));%read plotting parameters on the uvmat interfacPlotHandles); |
---|
[387] | 3959 | end |
---|
| 3960 | end |
---|
| 3961 | |
---|
[402] | 3962 | %% update the color of the graphic object representation: the selected object in magenta, others in blue |
---|
| 3963 | update_object_color(handles.axes3,axes_view_field,UvData.Object{IndexObj(end)}.DisplayHandle_uvmat) |
---|
[387] | 3964 | |
---|
| 3965 | %------------------------------------------------------------------------ |
---|
[402] | 3966 | %--- update the color representation of objects (indicating the selected ones) |
---|
| 3967 | function update_object_color(axes_uvmat,axes_view_field,DisplayHandle) |
---|
[387] | 3968 | %------------------------------------------------------------------------ |
---|
[402] | 3969 | if isempty(axes_view_field)% case with no view_field plot |
---|
| 3970 | hother=[findobj(axes_uvmat,'Tag','proj_object');findobj(axes_uvmat,'Tag','DeformPoint')];%find all the proj object and deform point representations |
---|
[387] | 3971 | else |
---|
[402] | 3972 | hother=[findobj(axes_uvmat,'Tag','proj_object') ;findobj(axes_view_field,'Tag','proj_object');... %find all the proj object representations |
---|
| 3973 | findobj(axes_uvmat,'Tag','DeformPoint'); findobj(axes_view_field,'Tag','DeformPoint')];%find all the deform point representations |
---|
[387] | 3974 | end |
---|
| 3975 | for iobj=1:length(hother) |
---|
| 3976 | if isequal(get(hother(iobj),'Type'),'rectangle')||isequal(get(hother(iobj),'Type'),'patch') |
---|
| 3977 | set(hother(iobj),'EdgeColor','b') |
---|
| 3978 | if isequal(get(hother(iobj),'FaceColor'),'m') |
---|
| 3979 | set(hother(iobj),'FaceColor','b') |
---|
| 3980 | end |
---|
| 3981 | elseif isequal(get(hother(iobj),'Type'),'image') |
---|
| 3982 | Acolor=get(hother(iobj),'CData'); |
---|
| 3983 | Acolor(:,:,1)=zeros(size(Acolor,1),size(Acolor,2)); |
---|
| 3984 | set(hother(iobj),'CData',Acolor); |
---|
| 3985 | else |
---|
| 3986 | set(hother(iobj),'Color','b') |
---|
| 3987 | end |
---|
| 3988 | set(hother(iobj),'Selected','off') |
---|
| 3989 | end |
---|
| 3990 | if ~isempty(DisplayHandle) |
---|
[402] | 3991 | linetype=get(DisplayHandle,'Type'); |
---|
| 3992 | if isequal(linetype,'line') |
---|
| 3993 | set(DisplayHandle,'Color','m'); %set the selected object to magenta color |
---|
| 3994 | elseif isequal(linetype,'rectangle') |
---|
| 3995 | set(DisplayHandle,'EdgeColor','m'); %set the selected object to magenta color |
---|
| 3996 | elseif isequal(linetype,'patch') |
---|
| 3997 | set(DisplayHandle,'FaceColor','m'); %set the selected object to magenta color |
---|
| 3998 | end |
---|
| 3999 | SubObjectData=get(DisplayHandle,'UserData'); |
---|
| 4000 | if isfield(SubObjectData,'SubObject') & ishandle(SubObjectData.SubObject) |
---|
| 4001 | for iobj=1:length(SubObjectData.SubObject) |
---|
| 4002 | hsub=SubObjectData.SubObject(iobj); |
---|
| 4003 | if isequal(get(hsub,'Type'),'rectangle') |
---|
| 4004 | set(hsub,'EdgeColor','m'); %set the selected object to magenta color |
---|
| 4005 | elseif isequal(get(hsub,'Type'),'image') |
---|
| 4006 | Acolor=get(hsub,'CData'); |
---|
| 4007 | Acolor(:,:,1)=Acolor(:,:,3); |
---|
| 4008 | set(hsub,'CData',Acolor); |
---|
| 4009 | else |
---|
| 4010 | set(hsub,'Color','m') |
---|
| 4011 | end |
---|
[387] | 4012 | end |
---|
| 4013 | end |
---|
[402] | 4014 | if isfield(SubObjectData,'DeformPoint') & ishandle(SubObjectData.DeformPoint) |
---|
| 4015 | set(SubObjectData.DeformPoint,'Color','m') |
---|
| 4016 | end |
---|
[387] | 4017 | end |
---|
[402] | 4018 | |
---|
| 4019 | %------------------------------------------------------------------------ |
---|
| 4020 | % --- Executes on button press in ViewObject. |
---|
| 4021 | function ViewObject_Callback(hObject, eventdata, handles) |
---|
| 4022 | %------------------------------------------------------------------------ |
---|
| 4023 | IndexObj=get(handles.ListObject,'Value'); |
---|
| 4024 | % IndexObj=IndexObj(end); %keeps only the second value |
---|
| 4025 | UvData=get(handles.uvmat,'UserData');%read UvData properties stored on the uvmat interface |
---|
| 4026 | if numel(UvData.Object)<IndexObj(end);% error in UvData |
---|
| 4027 | msgbox_uvmat('ERROR','invalid object list') |
---|
| 4028 | return |
---|
[387] | 4029 | end |
---|
[402] | 4030 | % ObjectData=UvData.Object{IndexObj(}; |
---|
| 4031 | ZBounds=0; % default |
---|
| 4032 | if isfield(UvData.Field,'ZMin') && isfield(UvData.Field,'ZMax') |
---|
| 4033 | ZBounds(1)=UvData.Field.ZMin; %minimum for the Z slider |
---|
| 4034 | ZBounds(2)=UvData.Field.ZMax;%maximum for the Z slider |
---|
[387] | 4035 | end |
---|
[402] | 4036 | hset_object=findobj(allchild(0),'tag','set_object'); |
---|
| 4037 | if ~isempty(hset_object) |
---|
| 4038 | delete(hset_object)% delete existing version of set_object |
---|
| 4039 | end |
---|
| 4040 | set(handles.ListObject,'Value',IndexObj);%restore ListObject selection after set_object deletion |
---|
| 4041 | if ~isfield(UvData.Object{IndexObj(1)},'Type')% default plane |
---|
| 4042 | UvData.Object{IndexObj(1)}.Type='plane'; |
---|
| 4043 | end |
---|
| 4044 | list_object=get(handles.ListObject,'String'); |
---|
| 4045 | UvData.Object{IndexObj(end)}.Name=list_object{IndexObj(end)}; |
---|
| 4046 | hset_object=set_object(UvData.Object{IndexObj(end)},[],ZBounds); |
---|
| 4047 | hhset_object=guidata(hset_object); |
---|
| 4048 | if get(handles.edit_object,'Value')% edit mode |
---|
| 4049 | set(hhset_object.PLOT,'Enable','on') |
---|
| 4050 | else |
---|
| 4051 | set(hhset_object.PLOT,'Enable','off') |
---|
| 4052 | end |
---|
[387] | 4053 | |
---|
[402] | 4054 | %% show the second plot (on view_field) |
---|
| 4055 | if length(IndexObj)==2 |
---|
| 4056 | ProjData= proj_field(UvData.Field,UvData.Object{IndexObj(2)});%project the current field on ObjectData |
---|
| 4057 | hview_field=findobj(allchild(0),'tag','view_field'); |
---|
| 4058 | if isempty(hview_field) |
---|
| 4059 | hview_field=view_field; |
---|
| 4060 | end |
---|
| 4061 | PlotHandles=guidata(hview_field); |
---|
| 4062 | plot_field(ProjData,PlotHandles.axes3,read_GUI(hview_field));%read plotting parameters on the uvmat interfacPlotHandles); |
---|
| 4063 | end |
---|
| 4064 | |
---|
| 4065 | %------------------------------------------------------------------- |
---|
| 4066 | % --- Executes on selection change in edit_object. |
---|
| 4067 | function edit_object_Callback(hObject, eventdata, handles) |
---|
| 4068 | %------------------------------------------------------------------- |
---|
| 4069 | UvData=get(handles.uvmat,'UserData');%read UvData properties stored on the uvmat interface |
---|
| 4070 | if get(handles.edit_object,'Value') |
---|
| 4071 | set(handles.edit_object,'BackgroundColor',[1,1,0]) |
---|
| 4072 | %suppress the other options |
---|
| 4073 | set(handles.CheckZoom,'Value',0) |
---|
| 4074 | CheckZoom_Callback(hObject, eventdata, handles) |
---|
| 4075 | hgeometry_calib=findobj(allchild(0),'tag','geometry_calib'); |
---|
| 4076 | if ishandle(hgeometry_calib) |
---|
| 4077 | hhgeometry_calib=guidata(hgeometry_calib); |
---|
| 4078 | set(hhgeometry_calib.edit_append,'Value',0)% desactivate mouse action in geometry_calib |
---|
| 4079 | set(hhgeometry_calib.edit_append,'BackgroundColor',[0.7 0.7 0.7]) |
---|
| 4080 | end |
---|
| 4081 | hset_object=findobj(allchild(0),'Tag','set_object'); |
---|
| 4082 | if isempty(hset_object)% open the GUI set_object with data of the currently selected object |
---|
| 4083 | ViewObject_Callback(hObject, eventdata, handles) |
---|
| 4084 | hset_object=findobj(allchild(0),'Tag','set_object'); |
---|
| 4085 | end |
---|
| 4086 | hhset_object=guidata(hset_object); |
---|
| 4087 | set(hhset_object.PLOT,'enable','on'); |
---|
| 4088 | else |
---|
| 4089 | set(handles.edit_object,'BackgroundColor',[0.7,0.7,0.7]) |
---|
| 4090 | hset_object=findobj(allchild(0),'Tag','set_object'); |
---|
| 4091 | if ~isempty(hset_object)% open the |
---|
| 4092 | hhset_object=guidata(hset_object); |
---|
| 4093 | set(hhset_object.PLOT,'enable','off'); |
---|
| 4094 | end |
---|
| 4095 | end |
---|
| 4096 | |
---|
| 4097 | %------------------------------------------------------------------------ |
---|
| 4098 | % --- Executes on button press in delete_object. |
---|
| 4099 | function delete_object_Callback(hObject, eventdata, handles) |
---|
| 4100 | %------------------------------------------------------------------------ |
---|
| 4101 | IndexObj=get(handles.ListObject,'Value'); |
---|
| 4102 | if IndexObj(end)>1 |
---|
| 4103 | delete_object(IndexObj(end)) |
---|
| 4104 | end |
---|
| 4105 | |
---|
| 4106 | %------------------------------------------------------------------------ |
---|
| 4107 | %------------------------------------------------------------------------ |
---|
| 4108 | % II - TOOLS FROM THE UPPER MENU BAR |
---|
| 4109 | %------------------------------------------------------------------------ |
---|
| 4110 | %------------------------------------------------------------------------ |
---|
| 4111 | |
---|
| 4112 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
---|
| 4113 | % Export Menu Callbacks |
---|
| 4114 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
---|
| 4115 | %------------------------------------------------------------------------ |
---|
[387] | 4116 | % --- Executes on button press in Menu/Export/field in workspace. |
---|
| 4117 | function MenuExportField_Callback(hObject, eventdata, handles) |
---|
[402] | 4118 | %------------------------------------------------------------------------ |
---|
[387] | 4119 | global Data_uvmat |
---|
| 4120 | Data_uvmat=get(handles.uvmat,'UserData'); |
---|
| 4121 | evalin('base','global Data_uvmat')%make CurData global in the workspace |
---|
| 4122 | display('current field :') |
---|
| 4123 | evalin('base','Data_uvmat') %display CurData in the workspace |
---|
| 4124 | commandwindow; %brings the Matlab command window to the front |
---|
| 4125 | |
---|
[402] | 4126 | %------------------------------------------------------------------------ |
---|
[387] | 4127 | % --- Executes on button press in Menu/Export/extract figure. |
---|
[402] | 4128 | function MenuExportFigure_Callback(hObject, eventdata, handles) |
---|
| 4129 | %------------------------------------------------------------------------ |
---|
| 4130 | % huvmat=get(handles.MenuExport,'parent'); |
---|
[387] | 4131 | hfig=figure; |
---|
[402] | 4132 | copyobj(handles.axes3,hfig); |
---|
[387] | 4133 | map=colormap(handles.axes3); |
---|
| 4134 | colormap(map);%transmit the current colormap to the zoom fig |
---|
| 4135 | colorbar |
---|
| 4136 | |
---|
[402] | 4137 | % %------------------------------------------------------ |
---|
| 4138 | % % --- Executes on button press in Menu/Export/extract figure. |
---|
| 4139 | % %------------------------------------------------------ |
---|
| 4140 | % function MenuExport_plot_Callback(hObject, eventdata, handles) |
---|
| 4141 | % huvmat=get(handles.MenuExport_plot,'parent'); |
---|
| 4142 | % UvData=get(huvmat,'UserData'); |
---|
| 4143 | % hfig=figure; |
---|
| 4144 | % newaxes=copyobj(handles.axes3,hfig); |
---|
| 4145 | % map=colormap(handles.axes3); |
---|
| 4146 | % colormap(map);%transmit the current colormap to the zoom fig |
---|
| 4147 | % colorbar |
---|
[387] | 4148 | |
---|
[402] | 4149 | % |
---|
| 4150 | % % -------------------------------------------------------------------- |
---|
| 4151 | % function Insert_Callback(hObject, eventdata, handles) |
---|
| 4152 | % |
---|
[387] | 4153 | |
---|
| 4154 | %------------------------------------------------------------------------ |
---|
| 4155 | % -------------------------------------------------------------------- |
---|
| 4156 | function MenuExportMovie_Callback(hObject, eventdata, handles) |
---|
| 4157 | % -------------------------------------------------------------------- |
---|
| 4158 | set(handles.MenuExportMovie,'BusyAction','queue')% activate the button |
---|
| 4159 | huvmat=get(handles.run0,'parent'); |
---|
| 4160 | UvData=get(huvmat,'UserData'); |
---|
| 4161 | %[xx,xx,FileBase]=read_file_boxes(handles); |
---|
| 4162 | [RootPath,SubDir,RootFile,FileIndices,FileExt]=read_file_boxes(handles); |
---|
| 4163 | FileBase=fullfile(RootPath,RootFile); |
---|
| 4164 | %read the current input file name |
---|
| 4165 | 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)'}; |
---|
| 4166 | dlg_title = 'select properties of the output avi movie'; |
---|
| 4167 | num_lines= 1; |
---|
| 4168 | % nbfield_cell=get(handles.last_i,'String'); |
---|
| 4169 | def = {[FileBase '_out.avi'];'10';'1';'[0.03 0.05 0.95 0.92]';'10'}; |
---|
| 4170 | answer = inputdlg(prompt,dlg_title,num_lines,def,'on'); |
---|
| 4171 | aviname=answer{1}; |
---|
| 4172 | fps=str2double(answer{2}); |
---|
| 4173 | % check for existing file with output name aviname |
---|
| 4174 | if exist(aviname,'file') |
---|
| 4175 | backup=aviname; |
---|
| 4176 | testexist=2; |
---|
| 4177 | while testexist==2 |
---|
| 4178 | backup=[backup '~']; |
---|
| 4179 | testexist=exist(backup,'file'); |
---|
| 4180 | end |
---|
| 4181 | [success,message]=copyfile(aviname,backup);%make backup of the existing file |
---|
| 4182 | if isequal(success,1) |
---|
| 4183 | delete(aviname)%delete existing file |
---|
| 4184 | else |
---|
| 4185 | msgbox_uvmat('ERROR',message) |
---|
| 4186 | return |
---|
| 4187 | end |
---|
| 4188 | end |
---|
| 4189 | %create avi open |
---|
| 4190 | aviobj=avifile(aviname,'Compression','None','fps',fps); |
---|
| 4191 | |
---|
| 4192 | %display first view for tests |
---|
| 4193 | newfig=figure; |
---|
| 4194 | newaxes=copyobj(handles.axes3,newfig);%new plotting axes in the new figure |
---|
| 4195 | set(newaxes,'Tag','movieaxes') |
---|
| 4196 | nbpix=[512 384]*str2double(answer{3}); |
---|
| 4197 | set(gcf,'Position',[1 1 nbpix])% resolution XVGA |
---|
| 4198 | set(newaxes,'Position',eval(answer{4})); |
---|
| 4199 | map=colormap(handles.axes3); |
---|
| 4200 | colormap(map);%transmit the current colormap to the zoom fig |
---|
| 4201 | msgbox_uvmat('INPUT_Y-N',{['adjust figure ' num2str(newfig) ' with its matlab edit menu '] ;... |
---|
| 4202 | ['then press OK to get the avi movie as a copy of figure ' num2str(newfig) ' display']}); |
---|
| 4203 | UvData.plotaxes=newaxes;% the axis in the new figure becomes the current main plotting axes |
---|
| 4204 | set(huvmat,'UserData',UvData); |
---|
| 4205 | increment=str2num(get(handles.increment_scan,'String')); %get the field increment d |
---|
| 4206 | set(handles.STOP,'Visible','on') |
---|
| 4207 | set(handles.speed,'Visible','on') |
---|
| 4208 | set(handles.speed_txt,'Visible','on') |
---|
| 4209 | set(handles.Movie,'BusyAction','queue') |
---|
| 4210 | |
---|
| 4211 | %imin=str2double(get(handles.i1,'String')); |
---|
| 4212 | imax=str2double(answer{5}); |
---|
| 4213 | % if isfield(UvData,'Time') |
---|
| 4214 | htitle=get(newaxes,'Title'); |
---|
| 4215 | xlim=get(newaxes,'XLim'); |
---|
| 4216 | ylim=get(newaxes,'YLim'); |
---|
| 4217 | set(htitle,'Position',[xlim(2)+0.07*(xlim(2)-xlim(1)) ylim(2)-0.05*(ylim(2)-ylim(1)) 0]) |
---|
| 4218 | time_str=get(handles.abs_time,'String'); |
---|
| 4219 | set(htitle,'String',['t=' time_str]) |
---|
| 4220 | set(handles.speed,'Value',1) |
---|
| 4221 | for i=1:imax |
---|
| 4222 | if get(handles.speed,'Value')~=0 && isequal(get(handles.MenuExportMovie,'BusyAction'),'queue') % enable STOP command |
---|
| 4223 | runpm(hObject,eventdata,handles,increment)% run plus |
---|
| 4224 | drawnow |
---|
| 4225 | time_str=get(handles.abs_time,'String'); |
---|
| 4226 | if ishandle(htitle) |
---|
| 4227 | set(htitle,'String',['t=' time_str]) |
---|
| 4228 | end |
---|
| 4229 | mov=getframe(newfig); |
---|
| 4230 | aviobj=addframe(aviobj,mov); |
---|
| 4231 | end |
---|
| 4232 | end |
---|
| 4233 | aviobj=close(aviobj); |
---|
| 4234 | UvData=rmfield(UvData,'plotaxes'); |
---|
| 4235 | %UvData.Object{1}.plotaxes=handles.axes3; |
---|
| 4236 | set(huvmat,'UserData',UvData); |
---|
| 4237 | msgbox_uvmat('CONFIRMATION',{['movie ' aviname ' created '];['with ' num2str(imax) ' frames']}) |
---|
| 4238 | |
---|
[402] | 4239 | |
---|
| 4240 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
---|
| 4241 | % Projection Objects Menu Callbacks |
---|
| 4242 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
---|
| 4243 | |
---|
| 4244 | % ----------------------------------------------------------------------- |
---|
| 4245 | function Menupoints_Callback(hObject, eventdata, handles) |
---|
[387] | 4246 | %------------------------------------------------------------------------ |
---|
[402] | 4247 | data.Type='points'; |
---|
| 4248 | data.ProjMode='projection';%default |
---|
| 4249 | create_object(data,handles) |
---|
| 4250 | |
---|
| 4251 | % ----------------------------------------------------------------------- |
---|
| 4252 | function Menuline_Callback(hObject, eventdata, handles) |
---|
| 4253 | %------------------------------------------------------------------------ |
---|
| 4254 | data.Type='line'; |
---|
| 4255 | data.ProjMode='projection';%default |
---|
| 4256 | create_object(data,handles) |
---|
| 4257 | |
---|
| 4258 | %------------------------------------------------------------------------ |
---|
| 4259 | function Menupolyline_Callback(hObject, eventdata, handles) |
---|
| 4260 | %------------------------------------------------------------------------ |
---|
| 4261 | data.Type='polyline'; |
---|
| 4262 | data.ProjMode='projection';%default |
---|
| 4263 | create_object(data,handles) |
---|
| 4264 | |
---|
| 4265 | %------------------------------------------------------------------------ |
---|
| 4266 | function Menupolygon_Callback(hObject, eventdata, handles) |
---|
| 4267 | %------------------------------------------------------------------------ |
---|
| 4268 | data.Type='polygon'; |
---|
| 4269 | data.ProjMode='inside';%default |
---|
| 4270 | create_object(data,handles) |
---|
| 4271 | |
---|
| 4272 | %------------------------------------------------------------------------ |
---|
| 4273 | function Menurectangle_Callback(hObject, eventdata, handles) |
---|
| 4274 | %------------------------------------------------------------------------ |
---|
| 4275 | data.Type='rectangle'; |
---|
| 4276 | data.ProjMode='inside';%default |
---|
| 4277 | create_object(data,handles) |
---|
| 4278 | |
---|
| 4279 | %------------------------------------------------------------------------ |
---|
| 4280 | function Menuellipse_Callback(hObject, eventdata, handles) |
---|
| 4281 | %------------------------------------------------------------------------ |
---|
| 4282 | data.Type='ellipse'; |
---|
| 4283 | data.ProjMode='inside';%default |
---|
| 4284 | create_object(data,handles) |
---|
| 4285 | |
---|
| 4286 | %------------------------------------------------------------------------ |
---|
| 4287 | function MenuMaskObject_Callback(hObject, eventdata, handles) |
---|
| 4288 | %------------------------------------------------------------------------ |
---|
| 4289 | data.Type='polygon'; |
---|
| 4290 | data.TypeMenu={'polygon'}; |
---|
| 4291 | data.ProjMode='mask_inside';%default |
---|
| 4292 | data.ProjModeMenu={'mask_inside';'mask_outside'}; |
---|
| 4293 | create_object(data,handles) |
---|
| 4294 | |
---|
| 4295 | %------------------------------------------------------------------------ |
---|
| 4296 | function Menuplane_Callback(hObject, eventdata, handles) |
---|
| 4297 | %------------------------------------------------------------------------ |
---|
| 4298 | data.Type='plane'; |
---|
| 4299 | data.ProjMode='projection';%default |
---|
| 4300 | create_object(data,handles) |
---|
| 4301 | |
---|
| 4302 | %------------------------------------------------------------------------ |
---|
| 4303 | function Menuvolume_Callback(hObject, eventdata, handles) |
---|
| 4304 | %------------------------------------------------------------------------ |
---|
| 4305 | data.Type='volume'; |
---|
| 4306 | data.ProjMode='interp';%default |
---|
| 4307 | % set(handles.create,'Visible','on') |
---|
| 4308 | % set(handles.create,'Value',1) |
---|
| 4309 | % VOLUME_Callback(hObject,eventdata,handles) |
---|
| 4310 | create_object(data,handles) |
---|
| 4311 | |
---|
| 4312 | %------------------------------------------------------------------------ |
---|
| 4313 | % --- generic function used for the creation of a projection object |
---|
| 4314 | function create_object(data,handles) |
---|
| 4315 | %------------------------------------------------------------------------ |
---|
| 4316 | |
---|
| 4317 | hgeometry_calib=findobj(allchild(0),'tag','geometry_calib'); |
---|
| 4318 | if ishandle(hgeometry_calib) |
---|
| 4319 | hhgeometry_calib=guidata(hgeometry_calib); |
---|
| 4320 | set(hhgeometry_calib.edit_append,'Value',0)% desactivate mouse action in geometry_calib |
---|
| 4321 | set(hhgeometry_calib.edit_append,'BackgroundColor',[0.7 0.7 0.7]) |
---|
| 4322 | end |
---|
| 4323 | UvData=get(handles.uvmat,'UserData'); |
---|
| 4324 | set(handles.edit_object,'Value',0); %suppress the object edit mode |
---|
| 4325 | set(handles.edit_object,'BackgroundColor',[0.7,0.7,0.7]) |
---|
| 4326 | % data.enable_plot=1; |
---|
| 4327 | data.Coord=[0 0]; %default |
---|
| 4328 | if isfield(UvData,'Field') |
---|
| 4329 | Field=UvData.Field; |
---|
| 4330 | if isfield(Field,'Mesh')&&~isempty(Field.Mesh) |
---|
| 4331 | ord=10^(floor(log10(Field.Mesh)));%order of magnitude |
---|
| 4332 | if Field.Mesh/ord>=5 |
---|
| 4333 | mesh=5*ord; |
---|
| 4334 | elseif Field.Mesh/ord>=2 |
---|
| 4335 | mesh=2*ord; |
---|
| 4336 | else |
---|
| 4337 | mesh=ord; |
---|
| 4338 | end |
---|
| 4339 | data.RangeX=mesh; |
---|
| 4340 | data.RangeY=mesh; |
---|
| 4341 | data.DX=mesh; |
---|
| 4342 | data.DY=mesh; |
---|
| 4343 | elseif isfield(Field,'AX')&& isfield(Field,'AY')&& isfield(Field,'A')%only image |
---|
| 4344 | np=size(Field.A); |
---|
| 4345 | meshx=(Field.AX(end)-Field.AX(1))/np(2); |
---|
| 4346 | meshy=abs(Field.AY(end)-Field.AY(1))/np(1); |
---|
| 4347 | data.RangeY=max(meshx,meshy); |
---|
| 4348 | data.RangeX=max(meshx,meshy); |
---|
| 4349 | data.DX=max(meshx,meshy); |
---|
| 4350 | end |
---|
| 4351 | if isfield(Field,'NbDim')&& isequal(Field.NbDim,3) |
---|
| 4352 | data.Coord=[0 0 0]; %default |
---|
| 4353 | end |
---|
| 4354 | if isfield(Field,'CoordUnit') |
---|
| 4355 | data.CoordUnit=Field.CoordUnit; |
---|
| 4356 | end |
---|
| 4357 | end |
---|
| 4358 | if ishandle(handles.UVMAT_title) |
---|
| 4359 | delete(handles.UVMAT_title)%delete the initial display of uvmat if no field has been entered |
---|
| 4360 | end |
---|
| 4361 | hset_object=findobj(allchild(0),'tag','set_object'); |
---|
| 4362 | IndexObj=get(handles.ListObject,'Value') |
---|
| 4363 | if ~isempty(hset_object) |
---|
| 4364 | delete(hset_object)% delete existing version of set_object |
---|
| 4365 | end |
---|
| 4366 | set(handles.ListObject,'Value',IndexObj) |
---|
| 4367 | hset_object=set_object(data,handles);% call the set_object interface |
---|
| 4368 | hhset_object=guidata(hset_object); |
---|
| 4369 | set(hhset_object.PLOT,'enable','on')% activate the refresh button |
---|
| 4370 | set(handles.MenuObject,'checked','on') |
---|
| 4371 | set(handles.uvmat,'UserData',UvData) |
---|
| 4372 | set(handles.CheckZoom,'Value',0) |
---|
| 4373 | CheckZoom_Callback(handles.uvmat, [], handles) |
---|
| 4374 | set(handles.delete_object,'Visible','on') |
---|
| 4375 | |
---|
| 4376 | |
---|
| 4377 | %------------------------------------------------------------------------ |
---|
| 4378 | function MenuBrowseObject_Callback(hObject, eventdata, handles) |
---|
| 4379 | %------------------------------------------------------------------------ |
---|
| 4380 | %get the object file |
---|
| 4381 | [FileName, PathName, filterindex] = uigetfile( ... |
---|
| 4382 | {'*.xml;*.mat', ' (*.xml,*.mat)'; |
---|
| 4383 | '*.xml', '.xml files '; ... |
---|
| 4384 | '*.mat', '.mat matlab files '}, ... |
---|
| 4385 | 'Pick an xml Object file',get(handles.RootPath,'String')); |
---|
| 4386 | fileinput=[PathName FileName];%complete file name |
---|
| 4387 | sizf=size(fileinput); |
---|
| 4388 | if (~ischar(fileinput)||~isequal(sizf(1),1)),return;end |
---|
| 4389 | |
---|
| 4390 | %read the file |
---|
| 4391 | data=xml2struct(fileinput); |
---|
| 4392 | data.enable_plot=1; |
---|
| 4393 | [tild,data.Name]=fileparts(FileName); |
---|
| 4394 | hset_object=findobj(allchild(0),'tag','set_object'); |
---|
| 4395 | if ~isempty(hset_object) |
---|
| 4396 | delete(hset_object)% delete existing version of set_object |
---|
| 4397 | end |
---|
| 4398 | set_object(data);% call the set_object interface |
---|
| 4399 | set(handles.edit_object,'Value',0); %suppress the object edit mode |
---|
| 4400 | set(handles.edit_object,'BackgroundColor',[0.7,0.7,0.7]) |
---|
| 4401 | set(handles.MenuObject,'checked','on') |
---|
| 4402 | set(handles.delete_object,'Visible','on') |
---|
| 4403 | |
---|
| 4404 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
---|
| 4405 | % MenuEdit Callbacks |
---|
| 4406 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
---|
| 4407 | %------------------------------------------------------------------------ |
---|
| 4408 | function MenuEditObject_Callback(hObject, eventdata, handles) |
---|
| 4409 | %------------------------------------------------------------------------ |
---|
| 4410 | set(handles.edit_object,'Value',1) |
---|
| 4411 | edit_Callback(hObject, eventdata, handles) |
---|
| 4412 | |
---|
| 4413 | % %------------------------------------------------------------------------ |
---|
| 4414 | % function enable_transform(handles,state) |
---|
| 4415 | % %------------------------------------------------------------------------ |
---|
| 4416 | % set(handles.transform_fct,'Visible',state) |
---|
| 4417 | % set(handles.TRANSFORM_txt,'Visible',state) |
---|
| 4418 | % set(handles.transform_fct,'Visible',state) |
---|
| 4419 | % set(handles.path_transform,'Visible',state) |
---|
| 4420 | % set(handles.pxcmx_txt,'Visible',state) |
---|
| 4421 | % set(handles.pxcmy_txt,'Visible',state) |
---|
| 4422 | % set(handles.pxcm,'Visible',state) |
---|
| 4423 | % set(handles.pycm,'Visible',state) |
---|
| 4424 | |
---|
| 4425 | %------------------------------------------------------------------------ |
---|
| 4426 | function MenuEditVectors_Callback(hObject, eventdata, handles) |
---|
| 4427 | %------------------------------------------------------------------------ |
---|
| 4428 | set(handles.edit_vect,'Visible','on') |
---|
| 4429 | set(handles.edit_vect,'Value',1) |
---|
| 4430 | edit_vect_Callback(hObject, eventdata, handles) |
---|
| 4431 | |
---|
| 4432 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
---|
| 4433 | % MenuTools Callbacks |
---|
| 4434 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
---|
| 4435 | %------------------------------------------------------------------------ |
---|
[387] | 4436 | function MenuCalib_Callback(hObject, eventdata, handles) |
---|
| 4437 | %------------------------------------------------------------------------ |
---|
| 4438 | |
---|
| 4439 | UvData=get(handles.uvmat,'UserData');%read UvData properties stored on the uvmat interface |
---|
| 4440 | |
---|
| 4441 | %suppress competing options |
---|
| 4442 | set(handles.CheckZoom,'Value',0) |
---|
| 4443 | set(handles.CheckZoom,'BackgroundColor',[0.7 0.7 0.7]) |
---|
| 4444 | set(handles.ListObject,'Value',1) |
---|
| 4445 | % initiate display of GUI geometry_calib |
---|
| 4446 | data=[]; %default |
---|
| 4447 | if isfield(UvData,'CoordType') |
---|
| 4448 | data.CoordType=UvData.CoordType; |
---|
| 4449 | end |
---|
| 4450 | pos=get(handles.uvmat,'Position'); |
---|
| 4451 | pos(1)=pos(1)+pos(3)-0.311+0.04; %0.311= width of the geometry_calib interface (units relative to the srcreen) |
---|
| 4452 | pos(2)=pos(2)-0.02; |
---|
| 4453 | [RootPath,SubDir,RootFile,FileIndices,FileExt]=read_file_boxes(handles); |
---|
| 4454 | FileName=[fullfile(RootPath,SubDir,RootFile) FileIndices FileExt]; |
---|
| 4455 | set(handles.view_xml,'Backgroundcolor',[1 1 0])%indicate the reading of the current xml file by geometry_calib |
---|
| 4456 | if isfield(UvData.OpenParam,'CalOrigin') |
---|
| 4457 | pos_uvmat=get(handles.uvmat,'Position'); |
---|
| 4458 | pos_cal(1)=pos_uvmat(1)+UvData.OpenParam.CalOrigin(1)*pos_uvmat(3); |
---|
| 4459 | pos_cal(2)=pos_uvmat(2)+UvData.OpenParam.CalOrigin(2)*pos_uvmat(4); |
---|
| 4460 | pos_cal(3:4)=UvData.OpenParam.CalSize .* pos_uvmat(3:4); |
---|
| 4461 | end |
---|
| 4462 | geometry_calib(FileName,pos_cal);% call the geometry_calib interface |
---|
| 4463 | set(handles.view_xml,'Backgroundcolor',[1 1 1])%indicate the end of reading of the current xml file by geometry_calib |
---|
| 4464 | set(handles.MenuCalib,'checked','on')% indicate that MenuCalib is activated, test used by mouse action |
---|
| 4465 | |
---|
| 4466 | %------------------------------------------------------------------------ |
---|
| 4467 | function MenuMask_Callback(hObject, eventdata, handles) |
---|
| 4468 | %------------------------------------------------------------------------ |
---|
| 4469 | UvData=get(handles.uvmat,'UserData');%read UvData properties stored on the uvmat interface |
---|
| 4470 | ListObj=UvData.Object; |
---|
| 4471 | select=zeros(1,numel(ListObj)); |
---|
| 4472 | for iobj=1:numel(ListObj); |
---|
| 4473 | if strcmp(ListObj{iobj}.ProjMode,'mask_inside')||strcmp(ListObj{iobj}.ProjMode,'mask_outside') |
---|
| 4474 | select(iobj)=1; |
---|
| 4475 | end |
---|
| 4476 | end |
---|
| 4477 | val=find(select); |
---|
| 4478 | if isempty(val) |
---|
| 4479 | msgbox_uvmat('ERROR','polygons must be first created by Projection object/mask polygon in the menu bar'); |
---|
| 4480 | return |
---|
| 4481 | else |
---|
| 4482 | set(handles.ListObject,'Max',2);%allow multiple selection |
---|
| 4483 | set(handles.ListObject,'Value',val); |
---|
| 4484 | flag=1; |
---|
| 4485 | npx=size(UvData.Field.A,2); |
---|
| 4486 | npy=size(UvData.Field.A,1); |
---|
| 4487 | xi=0.5:npx-0.5; |
---|
| 4488 | yi=0.5:npy-0.5; |
---|
| 4489 | [Xi,Yi]=meshgrid(xi,yi); |
---|
| 4490 | if isfield(UvData,'Object') |
---|
| 4491 | for iobj=1:length(UvData.Object) |
---|
| 4492 | ObjectData=UvData.Object{iobj}; |
---|
| 4493 | if isfield(ObjectData,'ProjMode') &&(isequal(ObjectData.ProjMode,'mask_inside')||isequal(ObjectData.ProjMode,'mask_outside')); |
---|
| 4494 | flagobj=1; |
---|
| 4495 | testphys=0; %coordinates in pixels by default |
---|
| 4496 | if isfield(ObjectData,'CoordUnit') && ~isequal(ObjectData.CoordUnit,'pixel') |
---|
| 4497 | if isfield(UvData,'XmlData')&& isfield(UvData.XmlData{1},'GeometryCalib') |
---|
| 4498 | Calib=UvData.XmlData{1}.GeometryCalib; |
---|
| 4499 | testphys=1; |
---|
| 4500 | end |
---|
| 4501 | end |
---|
| 4502 | if isfield(ObjectData,'Coord')&& isfield(ObjectData,'Type') |
---|
| 4503 | if isequal(ObjectData.Type,'polygon') |
---|
| 4504 | X=ObjectData.Coord(:,1); |
---|
| 4505 | Y=ObjectData.Coord(:,2); |
---|
| 4506 | if testphys |
---|
| 4507 | [X,Y]=px_XYZ(Calib,X,Y,0);% to generalise with 3D cases |
---|
| 4508 | end |
---|
| 4509 | flagobj=~inpolygon(Xi,Yi,X',Y');%=0 inside the polygon, 1 outside |
---|
| 4510 | elseif isequal(ObjectData.Type,'ellipse') |
---|
| 4511 | if testphys |
---|
| 4512 | %[X,Y]=px_XYZ(Calib,X,Y,0);% TODO:create a polygon boundary and transform to phys |
---|
| 4513 | end |
---|
| 4514 | RangeX=max(ObjectData.RangeX); |
---|
| 4515 | RangeY=max(ObjectData.RangeY); |
---|
| 4516 | X2Max=RangeX*RangeX; |
---|
| 4517 | Y2Max=RangeY*RangeY; |
---|
| 4518 | distX=(Xi-ObjectData.Coord(1,1)); |
---|
| 4519 | distY=(Yi-ObjectData.Coord(1,2)); |
---|
| 4520 | flagobj=(distX.*distX/X2Max+distY.*distY/Y2Max)>1; |
---|
| 4521 | elseif isequal(ObjectData.Type,'rectangle') |
---|
| 4522 | if testphys |
---|
| 4523 | %[X,Y]=px_XYZ(Calib,X,Y,0);% TODO:create a polygon boundary and transform to phys |
---|
| 4524 | end |
---|
| 4525 | distX=abs(Xi-ObjectData.Coord(1,1)); |
---|
| 4526 | distY=abs(Yi-ObjectData.Coord(1,2)); |
---|
| 4527 | flagobj=distX>max(ObjectData.RangeX) | distY>max(ObjectData.RangeY); |
---|
| 4528 | end |
---|
| 4529 | if isequal(ObjectData.ProjMode,'mask_outside') |
---|
| 4530 | flagobj=~flagobj; |
---|
| 4531 | end |
---|
| 4532 | flag=flag & flagobj; |
---|
| 4533 | end |
---|
| 4534 | end |
---|
| 4535 | end |
---|
| 4536 | end |
---|
| 4537 | %mask name |
---|
| 4538 | RootPath=get(handles.RootPath,'String'); |
---|
| 4539 | RootFile=get(handles.RootFile,'String'); |
---|
| 4540 | if ~isempty(RootFile)&&(isequal(RootFile(1),'/')|| isequal(RootFile(1),'\')) |
---|
| 4541 | RootFile(1)=[]; |
---|
| 4542 | end |
---|
| 4543 | filebase=fullfile(RootPath,RootFile); |
---|
| 4544 | list=get(handles.masklevel,'String'); |
---|
| 4545 | masknumber=num2str(length(list)); |
---|
| 4546 | maskindex=get(handles.masklevel,'Value'); |
---|
| 4547 | mask_name=fullfile_uvmat(RootPath,'',[RootFile '_' masknumber 'mask'],'.png','_1',maskindex); |
---|
| 4548 | %mask_name=name_generator([filebase '_' masknumber 'mask'],maskindex,1,'.png','_i'); |
---|
| 4549 | imflag=uint8(255*(0.392+0.608*flag));% =100 for flag=0 (vectors not computed when 20<imflag<200) |
---|
| 4550 | imflag=flipdim(imflag,1); |
---|
| 4551 | |
---|
| 4552 | %display the mask |
---|
| 4553 | hfigmask=figure; |
---|
| 4554 | set(hfigmask,'Name','mask image') |
---|
| 4555 | vec=linspace(0,1,256);%define a linear greyscale colormap |
---|
| 4556 | map=[vec' vec' vec']; |
---|
| 4557 | colormap(map) |
---|
| 4558 | image(imflag); |
---|
| 4559 | answer=msgbox_uvmat('INPUT_TXT','mask file name:', mask_name); |
---|
| 4560 | if ~strcmp(answer,'Cancel') |
---|
| 4561 | mask_dir=fileparts(answer); |
---|
| 4562 | if ~exist(mask_dir,'dir') |
---|
| 4563 | msgbox_uvmat('ERROR',['directory ' mask_dir ' does not exist']) |
---|
| 4564 | return |
---|
| 4565 | end |
---|
| 4566 | imwrite(imflag,answer,'BitDepth',8); |
---|
| 4567 | end |
---|
| 4568 | set(handles.ListObject,'Value',1) |
---|
| 4569 | % set(handles.ListObject,'Max',1) |
---|
| 4570 | end |
---|
| 4571 | |
---|
| 4572 | %------------------------------------------------------------------------ |
---|
| 4573 | %-- open the GUI set_grid.fig to create grid |
---|
| 4574 | function MenuGrid_Callback(hObject, eventdata, handles) |
---|
| 4575 | %------------------------------------------------------------------------ |
---|
| 4576 | %suppress the other options if grid is chosen |
---|
| 4577 | set(handles.edit_vect,'Value',0) |
---|
| 4578 | edit_vect_Callback(hObject, eventdata, handles) |
---|
| 4579 | set(handles.edit_object,'BackgroundColor',[0.7 0.7 0.7]) |
---|
| 4580 | set(handles.ListObject,'Value',1) |
---|
| 4581 | |
---|
| 4582 | %prepare display of the set_grid GUI |
---|
| 4583 | [RootPath,SubDir,RootFile,FileIndices,FileExt]=read_file_boxes(handles); |
---|
| 4584 | FileName=[fullfile(RootPath,SubDir,RootFile) FileIndices FileExt]; |
---|
| 4585 | CoordList=get(handles.transform_fct,'String'); |
---|
| 4586 | val=get(handles.transform_fct,'Value'); |
---|
| 4587 | set_grid(FileName,CoordList{val});% call the set_object interface |
---|
| 4588 | |
---|
[402] | 4589 | |
---|
[387] | 4590 | %------------------------------------------------------------------------ |
---|
[402] | 4591 | function MenuRuler_Callback(hObject, eventdata, handles) |
---|
| 4592 | %------------------------------------------------------------------------ |
---|
| 4593 | set(handles.CheckZoom,'Value',0) |
---|
| 4594 | CheckZoom_Callback(handles.uvmat, [], handles) |
---|
| 4595 | set(handles.MenuRuler,'checked','on') |
---|
| 4596 | UvData=get(handles.uvmat,'UserData'); |
---|
| 4597 | UvData.MouseAction='ruler'; |
---|
| 4598 | set(handles.uvmat,'UserData',UvData); |
---|
| 4599 | |
---|
| 4600 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
---|
| 4601 | % MenuRun Callbacks |
---|
| 4602 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
---|
| 4603 | |
---|
| 4604 | %------------------------------------------------------------------------ |
---|
[387] | 4605 | % open the GUI 'series' |
---|
| 4606 | function MenuSeries_Callback(hObject, eventdata, handles) |
---|
| 4607 | %------------------------------------------------------------------------ |
---|
| 4608 | series; %first display of the GUI to fill waiting time |
---|
| 4609 | [RootPath,SubDir,RootFile,FileIndices,FileExt]=read_file_boxes(handles); |
---|
| 4610 | param.FileName=[fullfile(RootPath,SubDir,RootFile) FileIndices FileExt]; |
---|
| 4611 | if isequal(get(handles.SubField,'Value'),1) |
---|
| 4612 | [RootPath_1,SubDir_1,RootFile_1,FileIndices_1,FileExt_1]=read_file_boxes_1(handles); |
---|
| 4613 | FileName_1=[fullfile(RootPath_1,SubDir_1,RootFile_1) FileIndices_1 FileExt_1]; |
---|
| 4614 | if ~isequal(FileName_1,param.FileName) |
---|
| 4615 | param.FileName_1=FileName_1; |
---|
| 4616 | end |
---|
| 4617 | end |
---|
| 4618 | param.NomType=get(handles.NomType,'String'); |
---|
| 4619 | param.NomType_1=get(handles.NomType_1,'String'); |
---|
| 4620 | param.CheckFixPair=get(handles.CheckFixPair,'Value'); |
---|
| 4621 | huvmat=get(handles.MenuSeries,'parent'); |
---|
| 4622 | UvData=get(huvmat,'UserData'); |
---|
| 4623 | if isfield(UvData,'XmlData')&& isfield(UvData.XmlData{1},'Time') |
---|
| 4624 | param.Time=UvData.XmlData{1}.Time; |
---|
| 4625 | end |
---|
| 4626 | if isequal(get(handles.scan_i,'Value'),1) |
---|
| 4627 | param.incr_i=str2num(get(handles.increment_scan,'String')); |
---|
| 4628 | elseif isequal(get(handles.scan_j,'Value'),1) |
---|
| 4629 | param.incr_j=str2num(get(handles.increment_scan,'String')); |
---|
| 4630 | end |
---|
| 4631 | param.list_fields=get(handles.Fields,'String');% list menu fields |
---|
| 4632 | param.list_fields(1)=[]; %suppress 'image' option |
---|
| 4633 | param.index_fields=get(handles.Fields,'Value');% selected string index |
---|
| 4634 | if param.index_fields>1 |
---|
| 4635 | param.index_fields=param.index_fields-1; |
---|
| 4636 | end |
---|
| 4637 | param.list_fields_1=get(handles.Fields_1,'String');% list menu fields |
---|
| 4638 | param.list_fields_1(1)=[]; %suppress 'image' option |
---|
| 4639 | param.index_fields_1=get(handles.Fields_1,'Value')-1;% selected string index |
---|
| 4640 | if param.index_fields_1>1 |
---|
| 4641 | param.index_fields_1=param.index_fields_1-1; |
---|
| 4642 | end |
---|
| 4643 | param.menu_coord_str=get(handles.transform_fct,'String'); |
---|
| 4644 | param.menu_coord_val=get(handles.transform_fct,'Value'); |
---|
| 4645 | series(param); %run the series interface |
---|
| 4646 | |
---|
| 4647 | %------------------------------------------------------------------------ |
---|
[402] | 4648 | % -- open the GUI civ.fig for PIV |
---|
[387] | 4649 | function MenuPIV_Callback(hObject, eventdata, handles) |
---|
| 4650 | %------------------------------------------------------------------------ |
---|
| 4651 | [RootPath,SubDir,RootFile,FileIndices,FileExt]=read_file_boxes(handles); |
---|
| 4652 | FileName=[fullfile(RootPath,SubDir,RootFile) FileIndices FileExt]; |
---|
| 4653 | civ(FileName);% interface de civ(not in the uvmat file) |
---|
| 4654 | |
---|
[402] | 4655 | % -------------------------------------------------------------------- |
---|
| 4656 | function MenuHelp_Callback(hObject, eventdata, handles) |
---|
| 4657 | % -------------------------------------------------------------------- |
---|
| 4658 | path_to_uvmat=which ('uvmat');% check the path of uvmat |
---|
| 4659 | pathelp=fileparts(path_to_uvmat); |
---|
| 4660 | helpfile=fullfile(pathelp,'uvmat_doc','uvmat_doc.html'); |
---|
| 4661 | if isempty(dir(helpfile)), msgbox_uvmat('ERROR','Please put the help file uvmat_doc.html in the sub-directory /uvmat_doc of the UVMAT package') |
---|
| 4662 | else |
---|
| 4663 | addpath (fullfile(pathelp,'uvmat_doc')) |
---|
| 4664 | web(helpfile); |
---|
[387] | 4665 | end |
---|
| 4666 | |
---|
| 4667 | |
---|
| 4668 | |
---|
| 4669 | |
---|