[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 |
---|
[526] | 11 | % visualize, or Matlab structure representing netcdf fieldname (with fieldname |
---|
[387] | 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 | % |
---|
[511] | 30 | % Information stored on the interface:(use 'Export/field in workspace' in |
---|
| 31 | % the menu bar of uvmat to retrieve it) |
---|
| 32 | % .OpenParam: structure containing parameters defined when uvmat is opened |
---|
| 33 | % .PosColorbar: position (1x4 vector)of the colorbar (relative to the fig uvmat) |
---|
| 34 | % .PosSetObject: position of set_object |
---|
| 35 | % .PosGeometryCalib: size of set_object |
---|
| 36 | % .NbBuiltin: nbre of functions always displayed in transform_fct menu |
---|
| 37 | % .Object: cell array of structures representing the current projection objects, as produced by 'set_object.m'={[]} by default |
---|
| 38 | % .NewSeries: =0/1 flag telling whether a new field series has been opened |
---|
| 39 | % .FileName_1: name of the current second field (used to detect a constant field during file scanning) |
---|
| 40 | % .FileType: current file type, as defined by the fct get_file_type.m) |
---|
| 41 | % .i1_series,.i2_series,.j1_series,.j1_series: series of i1,i2,j1,j2 indices detected in the input dir,set by the fct find_file_series |
---|
| 42 | % .MovieObject: current movie object |
---|
| 43 | % .TimeUnit: unit for time |
---|
[526] | 44 | % .XmlData: cell array of 1 or 2 structures representing the xml files associated with the input fieldname (containing timing and geometry calibration) |
---|
[511] | 45 | % .Field: cell array of 1 or 2 structures representing the current input field(s) |
---|
| 46 | % .PlotAxes: field structure representing the current field plotted on the main axes (used for mouse operations) |
---|
| 47 | % .HistoAxes: idem for histogram axes |
---|
[387] | 48 | |
---|
| 49 | % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%% DATA FLOW (for run0_Callback) %%%%%%%%%%%%%%%%%%%%: |
---|
| 50 | % |
---|
[406] | 51 | % |
---|
| 52 | % 1) Input filenames are determined by MenuBrowse (first field), MenuBrowse_1 |
---|
[512] | 53 | % (second field), or by the stored file name .FileName_1, or as an input of uvmat. |
---|
| 54 | % 2) These functions call 'uvmat/display_file_name.m' which detects the file series, and fills the file index boxes |
---|
| 55 | % 3) Then 'uvmat/update_rootinfo.m' Updates information about a new field series (indices to scan, timing, calibration from an xml file) |
---|
[526] | 56 | % 4) Then fieldname are opened and visualised by the main sub-function 'uvmat/refresh_field.m' |
---|
[512] | 57 | % The function first reads the name of the input file(s) (one or two) from the edit boxes of the GUI |
---|
| 58 | % It then reads the input file(s) with the function read_field.m and perform the following list of operations: |
---|
[387] | 59 | % |
---|
[512] | 60 | % %%%%%%%% structure of uvmat/refresh_field.m %%%%%%%% |
---|
[387] | 61 | % |
---|
[512] | 62 | % Main input open second input open_1 |
---|
| 63 | % | | |
---|
| 64 | % read_field.m read_field.m |
---|
| 65 | % | | |
---|
| 66 | % Field{1} Field{2} |
---|
| 67 | % | | |
---|
[526] | 68 | % --->transform fct<--- transform (e.g. phys.m) and combine input fieldname |
---|
[512] | 69 | % | |
---|
| 70 | % (calc_tps.m) calculate tps coefficients (for filter projection or spatial derivatives). |
---|
| 71 | % | |
---|
| 72 | % UvData.Field-------------->histogram |
---|
| 73 | % _____________|____________ |
---|
| 74 | % | | |
---|
[515] | 75 | % proj_field.m proj_field.m project the field on the projection objects (use calc_field.m) |
---|
[512] | 76 | % | | |
---|
| 77 | % UvData.PlotAxes ViewData.PlotAxes (on view_field) |
---|
| 78 | % | | |
---|
[526] | 79 | % plot_field.m (uvmat) plot_field.m (view_field) plot the projected fieldname |
---|
[512] | 80 | % |
---|
| 81 | % |
---|
[387] | 82 | %%%%%%%%%%%%%% SCALARS: %%%%%%%%%%%%??%%% |
---|
| 83 | % scalars are displayed either as an image or countour plot, either as a color of |
---|
| 84 | % velocity vectors. The scalar values in the first case is represented by |
---|
| 85 | % UvData.Field.A, and by UvData.Field.C in the second case. The corresponding set of X |
---|
| 86 | % and Y coordinates are represented by UvData.Field.AX and UvData.Field.AY, and .X and |
---|
| 87 | % .Y for C (the same as velocity vectors). If A is a nxxny matrix (scalar |
---|
| 88 | % on a regtular grid), then .AX andf.AY contains only two elements, represneting the |
---|
| 89 | % coordinates of the four image corners. The scalar name is represented by |
---|
| 90 | % the strings .AName and/or .CName. |
---|
| 91 | % If the scalar exists in an input open (image or scalar stored under its |
---|
| 92 | % name in a netcdf open), it is directly read at the level of Field{1}or Field{2}. |
---|
| 93 | % Else only its name AName is recorded in Field{i}, and its field is then calculated |
---|
| 94 | %by the fuction calc_scal after the coordinate transform or after projection on an edit_object |
---|
| 95 | |
---|
| 96 | % Properties attached to plotting figures (standard Matlab properties): |
---|
| 97 | % 'CurrentAxes'= gca or get(gcf,'CurrentAxes'); |
---|
| 98 | % 'CurrentPoint'=get(gcf,'CurrentPoint'): figure coordinates of the point over which the mouse is positioned |
---|
| 99 | % 'CurrentCharacter'=get(gcf,'CurrentCharacter'): last character typed over the figure where the mouse is positioned |
---|
| 100 | % 'WindowButtonMotionFcn': function permanently called by mouse motion over the figure |
---|
| 101 | % 'KeyPressFcn': function called by pressing a key on the key board |
---|
| 102 | % 'WindowButtonDownFcn': function called by pressing the mouse over the figure |
---|
| 103 | % 'WindowButtonUpFcn': function called by releasing the mouse pressure over the figure |
---|
| 104 | |
---|
| 105 | % Properties attached to plotting axes: |
---|
| 106 | % 'CurrentPoint'=get(gca,'CurrentPoint'); (standard Matlab) same as for the figure, but position in plot coordinates. |
---|
| 107 | % AxeData:=get(gca,'UserData'); |
---|
| 108 | % AxeData.Drawing = create: create a new object |
---|
| 109 | % = deform: modify an existing object by moving its defining create |
---|
| 110 | % = off: no current drawing action |
---|
| 111 | % = translate: translate an existing object |
---|
| 112 | % = calibration: move a calibration point |
---|
| 113 | % = CheckZoom: isolate a subregion for CheckZoom in=1 if an object is being currently drawn, 0 else (set to 0 by releasing mouse button) |
---|
| 114 | % .CurrentOrigin: Origin of a curently drawn edit_object |
---|
| 115 | % .CurrentLine: currently drawn menuline (A REVOIR) |
---|
| 116 | % .CurrentObject: handle of the currently drawn edit_object |
---|
| 117 | % .CurrentRectZoom: current rectangle used for CheckZoom |
---|
| 118 | |
---|
| 119 | % Properties attached to projection objects (create, menuline, menuplane...): |
---|
| 120 | % 'Tag'='proj_object': for all projection objects |
---|
| 121 | % ObjectData.Type=...: style of projection object: |
---|
| 122 | % .ProjMode |
---|
| 123 | % .Coord: defines the position of the object |
---|
| 124 | % .XMin,YMin.... |
---|
| 125 | % .XMax,YMax.... |
---|
| 126 | % .DX,DY,DZ |
---|
| 127 | % .Phi, .Theta, .Psi : Euler angles |
---|
| 128 | % .X,.Y,.U,.V.... : field data projected on the object |
---|
| 129 | % .IndexObj: index in the list of UvData.Object |
---|
| 130 | %during plotting |
---|
| 131 | % .plotaxes: handles of the current axes used to plot the result of field projection on the object |
---|
| 132 | % .plothandle: vector of handle(s) of the object graphic represnetation in all the opened plotting axes |
---|
| 133 | % To each projection object #iobj, corresponds an axis |
---|
| 134 | % Object{iobj}.plotaxes and nbobj representation graphs Object{iobj}.plothandles(:) (where nbobj is the |
---|
| 135 | % nbre of current objects opened in uvmat. Note that Object{iobj}.plothandles(iobj)=[] : an object is not represented in its own projection field; |
---|
| 136 | |
---|
| 137 | %------------------------------------------------------------------------ |
---|
| 138 | %------------------------------------------------------------------------ |
---|
[406] | 139 | % I - MAIN FUNCTION uvmat |
---|
[387] | 140 | %------------------------------------------------------------------------ |
---|
| 141 | %------------------------------------------------------------------------ |
---|
| 142 | function varargout = uvmat(varargin) |
---|
| 143 | |
---|
| 144 | % Begin initialization code - DO NOT EDIT |
---|
| 145 | gui_Singleton = 1; |
---|
| 146 | gui_State = struct('gui_Name', mfilename, ... |
---|
| 147 | 'gui_Singleton', gui_Singleton, ... |
---|
| 148 | 'gui_OpeningFcn', @uvmat_OpeningFcn, ... |
---|
| 149 | 'gui_OutputFcn', @uvmat_OutputFcn, ... |
---|
| 150 | 'gui_LayoutFcn', [], ... |
---|
| 151 | 'gui_Callback', []); |
---|
| 152 | if nargin && ischar(varargin{1})&& ~isempty(regexp(varargin{1},'_Callback','once')) |
---|
| 153 | gui_State.gui_Callback = str2func(varargin{1}); |
---|
| 154 | end |
---|
| 155 | |
---|
| 156 | if nargout |
---|
| 157 | varargout{1:nargout} = gui_mainfcn(gui_State, varargin{:}); |
---|
| 158 | else |
---|
| 159 | gui_mainfcn(gui_State, varargin{:}); |
---|
| 160 | end |
---|
| 161 | % End initialization code - DO NOT EDIT |
---|
| 162 | |
---|
| 163 | %------------------------------------------------------------------------ |
---|
| 164 | % --- Executes just before the GUI uvmat is made visible. |
---|
| 165 | function uvmat_OpeningFcn(hObject, eventdata, handles, input ) |
---|
| 166 | %------------------------------------------------------------------------ |
---|
| 167 | |
---|
| 168 | %% Choose default command menuline output for uvmat (standard GUI) |
---|
| 169 | handles.output = hObject; |
---|
| 170 | |
---|
| 171 | %% Update handles structure (standard GUI) |
---|
| 172 | guidata(hObject, handles); |
---|
| 173 | |
---|
[507] | 174 | %% add the path to uvmat (useful if uvmat has been opened in the working directory and a working directory change occured) |
---|
| 175 | path_uvmat=fileparts(which('uvmat')); |
---|
| 176 | |
---|
[387] | 177 | %% set the position of colorbar and ancillary GUIs: |
---|
| 178 | set(hObject,'Units','Normalized') |
---|
| 179 | movegui(hObject,'center') |
---|
[546] | 180 | %UvData.OpenParam.PosColorbar=[0.8450 0.0900 0.0190 0.3600]; |
---|
[387] | 181 | UvData.OpenParam.PosColorbar=[0.805 0.022 0.019 0.445]; |
---|
[511] | 182 | UvData.OpenParam.PosSetObject=[-0.05 -0.03 0.3 0.7]; %position for set_object |
---|
[517] | 183 | UvData.OpenParam.PosGeometryCalib=[0.95 -0.03 0.28 1 ];%position for geometry_calib (TO IMPROVE) |
---|
[511] | 184 | % UvData.OpenParam.CalSize=[0.28 1]; |
---|
| 185 | % UvData.PlotAxes=[];%initiate the record of plotted field |
---|
| 186 | % UvData.axes2=[]; |
---|
| 187 | % UvData.axes1=[]; |
---|
[387] | 188 | AxeData.LimEditBox=1; %initialise AxeData |
---|
[511] | 189 | set(handles.PlotAxes,'UserData',AxeData) |
---|
[387] | 190 | |
---|
| 191 | %% set functions for the mouse and keyboard |
---|
| 192 | set(hObject,'KeyPressFcn',{'keyboard_callback',handles})%set keyboard action function |
---|
| 193 | set(hObject,'WindowButtonMotionFcn',{'mouse_motion',handles})%set mouse action functio |
---|
| 194 | set(hObject,'WindowButtonDownFcn',{'mouse_down'})%set mouse click action function |
---|
| 195 | set(hObject,'WindowButtonUpFcn',{'mouse_up',handles}) |
---|
| 196 | set(hObject,'DeleteFcn',{@closefcn})% |
---|
| 197 | |
---|
[511] | 198 | %% initialisation |
---|
[508] | 199 | % set(handles.ListObject,'Value',1)% default: empty projection objectproj_field |
---|
| 200 | % set(handles.ListObject,'String',{''}) |
---|
| 201 | % set(handles.ListObject_1,'Value',1)% default: empty projection objectproj_field |
---|
| 202 | % set(handles.ListObject_1,'String',{''}) |
---|
[526] | 203 | set(handles.FieldName,'Value',1) |
---|
| 204 | set(handles.FieldName,'string',{''}) |
---|
[511] | 205 | UvData.Object={[]}; |
---|
[387] | 206 | |
---|
| 207 | %% TRANSFORM menu: builtin fcts |
---|
[515] | 208 | transform_menu={'';'sub_field';'phys';'phys_polar'}; |
---|
[507] | 209 | UvData.OpenParam.NbBuiltin=numel(transform_menu); %number of functions |
---|
| 210 | transform_path=fullfile(path_uvmat,'transform_field'); |
---|
[528] | 211 | path_list=cell(UvData.OpenParam.NbBuiltin,1); |
---|
[507] | 212 | path_list{1}=''; |
---|
[523] | 213 | for ilist=2:UvData.OpenParam.NbBuiltin |
---|
| 214 | path_list{ilist}=transform_path; % set transform_path to the path_list |
---|
| 215 | end |
---|
[387] | 216 | |
---|
[507] | 217 | %% load the list of previously browsed files in menus Open, Open_1 and transform_fct |
---|
[387] | 218 | dir_perso=prefdir; % path to the directory .matlab for personal data |
---|
| 219 | profil_perso=fullfile(dir_perso,'uvmat_perso.mat');% personal data file uvmauvmat_perso.mat' in .matlab |
---|
| 220 | if exist(profil_perso,'file') |
---|
[507] | 221 | h=load (profil_perso); |
---|
[523] | 222 | if isfield(h,'MenuFile')% load the menu of previously opened files |
---|
[507] | 223 | for ifile=1:min(length(h.MenuFile),5) |
---|
| 224 | eval(['set(handles.MenuFile_' num2str(ifile) ',''Label'',h.MenuFile{ifile});']) |
---|
| 225 | eval(['set(handles.MenuFile_' num2str(ifile) '_1,''Label'',h.MenuFile{ifile});']) |
---|
| 226 | end |
---|
| 227 | end |
---|
[523] | 228 | if isfield(h,'transform_fct') && iscell(h.transform_fct) % load the menu of transform fct set by user |
---|
[387] | 229 | for ilist=1:length(h.transform_fct); |
---|
| 230 | if exist(h.transform_fct{ilist},'file') |
---|
[507] | 231 | [path,file]=fileparts(h.transform_fct{ilist}); |
---|
| 232 | transform_menu=[transform_menu; {file}]; |
---|
| 233 | path_list=[path_list; {path}]; |
---|
[387] | 234 | end |
---|
| 235 | end |
---|
[507] | 236 | end |
---|
[387] | 237 | end |
---|
[523] | 238 | transform_menu=[transform_menu;{'more...'}];%append the option more.. to the menu |
---|
| 239 | set(handles.transform_fct,'String',transform_menu)% display the menu of transform fcts |
---|
| 240 | set(handles.transform_fct,'UserData',path_list)% store the corresponding list of path in UserData of uicontrol transform_fct |
---|
[507] | 241 | set(handles.path_transform,'String','') |
---|
| 242 | set(handles.path_transform,'UserData',[]) |
---|
[387] | 243 | |
---|
| 244 | %% case of an input argument for uvmat |
---|
| 245 | testinputfield=0; |
---|
| 246 | inputfile=[]; |
---|
| 247 | Field=[]; |
---|
| 248 | if exist('input','var') |
---|
| 249 | if ishandle(handles.UVMAT_title) |
---|
| 250 | delete(handles.UVMAT_title) |
---|
| 251 | end |
---|
| 252 | if isstruct(input) |
---|
| 253 | if isfield(input,'InputFile') |
---|
| 254 | inputfile=input.InputFile; |
---|
| 255 | end |
---|
| 256 | if isfield(input,'TimeIndex') |
---|
| 257 | set(handles.i1,num2str(input.TimeIndex)) |
---|
| 258 | end |
---|
| 259 | if isfield(input,'FieldsString') |
---|
| 260 | UvData.FieldsString=input.FieldsString; |
---|
| 261 | end |
---|
| 262 | elseif ischar(input)% file name introduced as input |
---|
| 263 | inputfile=input; |
---|
| 264 | elseif isnumeric(input)%simple matrix introduced as input |
---|
| 265 | sizinput=size(input); |
---|
| 266 | if sizinput(1)<=1 || sizinput(2)<=1 |
---|
| 267 | msgbox_uvmat('ERROR','bad input for uvmat: file name, structure or numerical matrix accepted') |
---|
| 268 | return |
---|
| 269 | end |
---|
| 270 | UvData.Field.ListVarName={'A','coord_y','coord_x'}; |
---|
| 271 | UvData.Field.VarDimName={{'coord_y','coord_x'},'cord_y','coord_x'}; |
---|
| 272 | UvData.Field.A=input; |
---|
| 273 | UvData.Field.coord_x=[0.5 size(input,2)-0.5]; |
---|
| 274 | UvData.Field.coord_y=[size(input,1)-0.5 0.5]; |
---|
| 275 | testinputfield=1; |
---|
| 276 | end |
---|
| 277 | else |
---|
[476] | 278 | %% check the path and date of modification of all functions in uvmat |
---|
| 279 | path_to_uvmat=which ('uvmat');% check the path detected for source file uvmat |
---|
| 280 | [infomsg,date_str,svn_info]=check_files;%check the path of the functions called by uvmat.m |
---|
| 281 | date_str=['last modification: ' date_str]; |
---|
| 282 | if ishandle(handles.UVMAT_title) |
---|
| 283 | set(handles.UVMAT_title,'String',... |
---|
| 284 | [{'Copyright LEGI UMR 5519 /CNRS-UJF-Grenoble INP, 2010'};... |
---|
| 285 | {'GNU General Public License'};... |
---|
| 286 | {path_to_uvmat};... |
---|
| 287 | {date_str};... |
---|
| 288 | infomsg]); |
---|
| 289 | end |
---|
[387] | 290 | end |
---|
| 291 | set(handles.uvmat,'UserData',UvData) |
---|
| 292 | if ~isempty(inputfile) |
---|
| 293 | %%%%% display the input field %%%%%%% |
---|
[406] | 294 | display_file_name(handles,inputfile) |
---|
[387] | 295 | %%%%%%% |
---|
| 296 | end |
---|
| 297 | |
---|
| 298 | set_vec_col_bar(handles) %update the display of color code for vectors |
---|
| 299 | |
---|
| 300 | %------------------------------------------------------------------------ |
---|
| 301 | % --- Outputs from this function are returned to the command menuline. |
---|
| 302 | function varargout = uvmat_OutputFcn(hObject, eventdata, handles) |
---|
| 303 | varargout{1} = handles.output;% the only output argument is the handle to the GUI figure |
---|
| 304 | |
---|
| 305 | %------------------------------------------------------------------------ |
---|
[402] | 306 | % --- executed when closing uvmat: delete or desactivate the associated figures if exist |
---|
| 307 | function closefcn(gcbo,eventdata) |
---|
[387] | 308 | %------------------------------------------------------------------------ |
---|
[402] | 309 | hh=findobj(allchild(0),'tag','view_field'); |
---|
| 310 | if ~isempty(hh) |
---|
| 311 | delete(hh) |
---|
| 312 | end |
---|
| 313 | hh=findobj(allchild(0),'tag','geometry_calib'); |
---|
| 314 | if ~isempty(hh) |
---|
| 315 | delete(hh) |
---|
| 316 | end |
---|
| 317 | hh=findobj(allchild(0),'tag','set_object'); |
---|
| 318 | if ~isempty(hh) |
---|
| 319 | hhh=findobj(hh,'tag','PLOT'); |
---|
| 320 | set(hhh,'enable','off') |
---|
| 321 | end |
---|
| 322 | |
---|
| 323 | %------------------------------------------------------------------------ |
---|
| 324 | %------------------------------------------------------------------------ |
---|
[387] | 325 | % II - FUNCTIONS FOR INTRODUCING THE INPUT FILES |
---|
| 326 | % automatically sets the global properties when the rootfile name is introduced |
---|
| 327 | % then activate the view-field action if selected |
---|
| 328 | % it is activated either by clicking on the RootPath window or by the |
---|
| 329 | % browser |
---|
| 330 | %------------------------------------------------------------------------ |
---|
| 331 | %------------------------------------------------------------------------ |
---|
| 332 | % --- Executes on the menu Open/Browse... |
---|
| 333 | % search the files, recognize their type according to their name and fill the rootfile input windows |
---|
| 334 | function MenuBrowse_Callback(hObject, eventdata, handles) |
---|
| 335 | [RootPath,SubDir,RootFile,FileIndices,FileExt]=read_file_boxes(handles); |
---|
[512] | 336 | %oldfile=[fullfile(RootPath,SubDir,RootFile) FileIndices FileExt]; |
---|
| 337 | oldfile=fullfile(RootPath,SubDir); |
---|
[387] | 338 | if isempty(oldfile)||isequal(oldfile,'') %loads the previously stored file name and set it as default in the file_input box |
---|
| 339 | dir_perso=prefdir; |
---|
| 340 | profil_perso=fullfile(dir_perso,'uvmat_perso.mat'); |
---|
| 341 | if exist(profil_perso,'file') |
---|
| 342 | h=load (profil_perso); |
---|
| 343 | if isfield(h,'MenuFile_1') |
---|
| 344 | oldfile=h.MenuFile_1; |
---|
| 345 | end |
---|
| 346 | end |
---|
| 347 | end |
---|
[421] | 348 | [FileName, PathName] = uigetfile({'*.*','All Files(*.*)'},'Pick a file',oldfile); |
---|
[530] | 349 | if ~ischar(FileName),return,end %abandon if the browser is cancelled |
---|
[387] | 350 | fileinput=[PathName FileName];%complete file name |
---|
| 351 | |
---|
[503] | 352 | %% display the selected field and related information |
---|
[406] | 353 | display_file_name( handles,fileinput) |
---|
[387] | 354 | |
---|
| 355 | % ----------------------------------------------------------------------- |
---|
| 356 | % --- Open again the file whose name has been recorded in MenuFile_1 |
---|
| 357 | function MenuFile_1_Callback(hObject, eventdata, handles) |
---|
| 358 | %------------------------------------------------------------------------ |
---|
| 359 | fileinput=get(handles.MenuFile_1,'Label'); |
---|
[406] | 360 | display_file_name( handles,fileinput) |
---|
[387] | 361 | |
---|
| 362 | % ----------------------------------------------------------------------- |
---|
| 363 | % --- Open again the file whose name has been recorded in MenuFile_2 |
---|
| 364 | function MenuFile_2_Callback(hObject, eventdata, handles) |
---|
| 365 | %------------------------------------------------------------------------ |
---|
| 366 | fileinput=get(handles.MenuFile_2,'Label'); |
---|
[406] | 367 | display_file_name(handles,fileinput) |
---|
[387] | 368 | |
---|
| 369 | % ----------------------------------------------------------------------- |
---|
| 370 | % --- Open again the file whose name has been recorded in MenuFile_3 |
---|
| 371 | function MenuFile_3_Callback(hObject, eventdata, handles) |
---|
| 372 | %------------------------------------------------------------------------ |
---|
| 373 | fileinput=get(handles.MenuFile_3,'Label'); |
---|
[406] | 374 | display_file_name(handles,fileinput) |
---|
[387] | 375 | |
---|
| 376 | % ----------------------------------------------------------------------- |
---|
| 377 | % --- Open again the file whose name has been recorded in MenuFile_4 |
---|
| 378 | function MenuFile_4_Callback(hObject, eventdata, handles) |
---|
| 379 | %------------------------------------------------------------------------ |
---|
| 380 | fileinput=get(handles.MenuFile_4,'Label'); |
---|
[406] | 381 | display_file_name(handles,fileinput) |
---|
[387] | 382 | |
---|
| 383 | % ----------------------------------------------------------------------- |
---|
| 384 | % --- Open again the file whose name has been recorded in MenuFile_5 |
---|
| 385 | function MenuFile_5_Callback(hObject, eventdata, handles) |
---|
| 386 | %------------------------------------------------------------------------ |
---|
| 387 | fileinput=get(handles.MenuFile_5,'Label'); |
---|
[406] | 388 | display_file_name(handles,fileinput) |
---|
[387] | 389 | |
---|
[402] | 390 | %------------------------------------------------------------------------ |
---|
| 391 | % --- Executes on the menu Open/Browse_1 for the second input field, |
---|
| 392 | % search the files, recognize their type according to their name and fill the rootfile input windows |
---|
| 393 | function MenuBrowse_1_Callback(hObject, eventdata, handles) |
---|
| 394 | %------------------------------------------------------------------------ |
---|
| 395 | RootPath=get(handles.RootPath,'String'); |
---|
[421] | 396 | [FileName, PathName] = uigetfile({'*.*','All Files(*.*)'},'Pick a file',RootPath); |
---|
[530] | 397 | if ~ischar(FileName),return,end %abandon if the browser is cancelled |
---|
[402] | 398 | fileinput_1=[PathName FileName];%complete file name |
---|
| 399 | |
---|
| 400 | % refresh the current displayed field |
---|
| 401 | set(handles.SubField,'Value',1) |
---|
[406] | 402 | display_file_name(handles,fileinput_1,2) |
---|
[402] | 403 | |
---|
| 404 | %update list of recent files in the menubar |
---|
| 405 | MenuFile_1=fileinput_1; |
---|
| 406 | MenuFile_2=get(handles.MenuFile_1,'Label'); |
---|
| 407 | MenuFile_3=get(handles.MenuFile_2,'Label'); |
---|
| 408 | MenuFile_4=get(handles.MenuFile_3,'Label'); |
---|
| 409 | MenuFile_5=get(handles.MenuFile_4,'Label'); |
---|
| 410 | set(handles.MenuFile_1,'Label',MenuFile_1) |
---|
| 411 | set(handles.MenuFile_2,'Label',MenuFile_2) |
---|
| 412 | set(handles.MenuFile_3,'Label',MenuFile_3) |
---|
| 413 | set(handles.MenuFile_4,'Label',MenuFile_4) |
---|
| 414 | set(handles.MenuFile_5,'Label',MenuFile_5) |
---|
| 415 | set(handles.MenuFile_1_1,'Label',MenuFile_1) |
---|
| 416 | set(handles.MenuFile_2_1,'Label',MenuFile_2) |
---|
| 417 | set(handles.MenuFile_3_1,'Label',MenuFile_3) |
---|
| 418 | set(handles.MenuFile_4_1,'Label',MenuFile_4) |
---|
| 419 | set(handles.MenuFile_5_1,'Label',MenuFile_5) |
---|
| 420 | dir_perso=prefdir; |
---|
| 421 | profil_perso=fullfile(dir_perso,'uvmat_perso.mat'); |
---|
| 422 | if exist(profil_perso,'file') |
---|
| 423 | save (profil_perso,'MenuFile_1','MenuFile_2','MenuFile_3','MenuFile_4', 'MenuFile_5','-append'); %store the file names for future opening of uvmat |
---|
| 424 | else |
---|
| 425 | txt=ver('MATLAB'); |
---|
| 426 | Release=txt.Release; |
---|
| 427 | relnumb=str2double(Release(3:4)); |
---|
| 428 | if relnumb >= 14 |
---|
| 429 | save (profil_perso,'MenuFile_1','MenuFile_2','MenuFile_3','MenuFile_4', 'MenuFile_5','-V6'); %store the file names for future opening of uvmat |
---|
| 430 | else |
---|
| 431 | save (profil_perso,'MenuFile_1','MenuFile_2','MenuFile_3','MenuFile_4', 'MenuFile_5'); %store the file names for future opening of uvmat |
---|
| 432 | end |
---|
| 433 | end |
---|
| 434 | |
---|
| 435 | % ----------------------------------------------------------------------- |
---|
| 436 | % --- Open again as second field the file whose name has been recorded in MenuFile_1 |
---|
| 437 | function MenuFile_1_1_Callback(hObject, eventdata, handles) |
---|
| 438 | % ----------------------------------------------------------------------- |
---|
| 439 | fileinput_1=get(handles.MenuFile_1_1,'Label'); |
---|
| 440 | set(handles.SubField,'Value',1) |
---|
[406] | 441 | display_file_name(handles,fileinput_1,2) |
---|
[402] | 442 | |
---|
| 443 | % ----------------------------------------------------------------------- |
---|
| 444 | % --- Open again as second field the file whose name has been recorded in MenuFile_2 |
---|
| 445 | function MenuFile_2_1_Callback(hObject, eventdata, handles) |
---|
| 446 | % ----------------------------------------------------------------------- |
---|
| 447 | fileinput_1=get(handles.MenuFile_2_1,'Label'); |
---|
| 448 | set(handles.SubField,'Value',1) |
---|
[406] | 449 | display_file_name(handles,fileinput_1,2) |
---|
[402] | 450 | |
---|
| 451 | % ----------------------------------------------------------------------- |
---|
| 452 | % --- Open again as second field the file whose name has been recorded in MenuFile_3 |
---|
| 453 | function MenuFile_3_1_Callback(hObject, eventdata, handles) |
---|
| 454 | % ----------------------------------------------------------------------- |
---|
| 455 | fileinput_1=get(handles.MenuFile_3_1,'Label'); |
---|
| 456 | set(handles.SubField,'Value',1) |
---|
[406] | 457 | display_file_name(handles,fileinput_1,2) |
---|
[402] | 458 | |
---|
| 459 | % ----------------------------------------------------------------------- |
---|
| 460 | % --- Open again as second field the file whose name has been recorded in MenuFile_4 |
---|
| 461 | function MenuFile_4_1_Callback(hObject, eventdata, handles) |
---|
| 462 | % ----------------------------------------------------------------------- |
---|
| 463 | fileinput_1=get(handles.MenuFile_4_1,'Label'); |
---|
| 464 | set(handles.SubField,'Value',1) |
---|
[406] | 465 | display_file_name(handles,fileinput_1,2) |
---|
[402] | 466 | |
---|
| 467 | % ----------------------------------------------------------------------- |
---|
| 468 | % --- Open again as second field the file whose name has been recorded in MenuFile_5 |
---|
| 469 | function MenuFile_5_1_Callback(hObject, eventdata, handles) |
---|
| 470 | % ----------------------------------------------------------------------- |
---|
| 471 | fileinput_1=get(handles.MenuFile_5_1,'Label'); |
---|
| 472 | set(handles.SubField,'Value',1) |
---|
[406] | 473 | display_file_name(handles,fileinput_1,2) |
---|
[402] | 474 | |
---|
| 475 | %------------------------------------------------------------------------ |
---|
| 476 | % --- Called by action in RootPath edit box |
---|
| 477 | function RootPath_Callback(hObject,eventdata,handles) |
---|
| 478 | %------------------------------------------------------------------------ |
---|
| 479 | % read the current input file name: |
---|
| 480 | [RootPath,SubDir,RootFile,FileIndices,FileExt]=read_file_boxes(handles); |
---|
[456] | 481 | if ~exist(fullfile(RootPath,SubDir),'dir') |
---|
| 482 | msgbox_uvmat('ERROR',['directory ' fullfile(RootPath,SubDir) ' does not exist']) |
---|
| 483 | return |
---|
| 484 | end |
---|
[402] | 485 | % detect the file type, get the movie object if relevant, and look for the corresponding file series: |
---|
| 486 | [RootPath,SubDir,RootFile,i1_series,i2_series,j1_series,j2_series,tild,FileType,MovieObject]=find_file_series(fullfile(RootPath,SubDir),[RootFile FileIndices FileExt]); |
---|
| 487 | % initiate the input file series and refresh the current field view: |
---|
[406] | 488 | update_rootinfo(handles,i1_series,i2_series,j1_series,j2_series,FileType,MovieObject,1); |
---|
[402] | 489 | |
---|
| 490 | %----------------------------------------------------------------------- |
---|
| 491 | % --- Called by action in RootPath_1 edit box |
---|
| 492 | function RootPath_1_Callback(hObject,eventdata,handles) |
---|
| 493 | % ----------------------------------------------------------------------- |
---|
| 494 | % update_rootinfo_1(hObject,eventdata,handles) |
---|
| 495 | [RootPath,SubDir,RootFile,FileIndices,FileExt]=read_file_boxes_1(handles); |
---|
[456] | 496 | if ~exist(fullfile(RootPath,SubDir),'dir') |
---|
| 497 | msgbox_uvmat('ERROR',['directory ' fullfile(RootPath,SubDir) ' does not exist']) |
---|
| 498 | return |
---|
| 499 | end |
---|
[402] | 500 | % detect the file type, get the movie object if relevant, and look for the corresponding file series: |
---|
| 501 | [RootPath,SubDir,RootFile,i1_series,i2_series,j1_series,j2_series,tild,FileType,MovieObject]=find_file_series(fullfile(RootPath,SubDir),[RootFile FileIndices FileExt]); |
---|
| 502 | % initiate the input file series and refresh the current field view: |
---|
| 503 | update_rootinfo(handles,i1_series,i2_series,j1_series,j2_series,FileType,MovieObject,2); |
---|
| 504 | |
---|
| 505 | %------------------------------------------------------------------------ |
---|
| 506 | % --- Called by action in RootFile edit box |
---|
| 507 | function SubDir_Callback(hObject, eventdata, handles) |
---|
| 508 | %------------------------------------------------------------------------ |
---|
[526] | 509 | %refresh the menu of input fieldname |
---|
[402] | 510 | Fields_Callback(hObject, eventdata, handles); |
---|
| 511 | % refresh the current field view |
---|
| 512 | run0_Callback(hObject, eventdata, handles); |
---|
| 513 | |
---|
| 514 | %------------------------------------------------------------------------ |
---|
| 515 | % --- Called by action in RootFile edit box |
---|
| 516 | function RootFile_Callback(hObject, eventdata, handles) |
---|
| 517 | %------------------------------------------------------------------------ |
---|
| 518 | RootPath_Callback(hObject,eventdata,handles) |
---|
| 519 | |
---|
| 520 | %----------------------------------------------------------------------- |
---|
| 521 | % --- Called by action in RootFile_1 edit box |
---|
| 522 | function RootFile_1_Callback(hObject, eventdata, handles) |
---|
| 523 | % ----------------------------------------------------------------------- |
---|
| 524 | RootPath_1_Callback(hObject,eventdata,handles) |
---|
| 525 | |
---|
| 526 | %------------------------------------------------------------------------ |
---|
| 527 | % --- Called by action in FileIndex edit box |
---|
| 528 | function FileIndex_Callback(hObject, eventdata, handles) |
---|
| 529 | %------------------------------------------------------------------------ |
---|
| 530 | [tild,tild,tild,i1,i2,j1,j2]=fileparts_uvmat(get(handles.FileIndex,'String')); |
---|
| 531 | set(handles.i1,'String',num2str(i1)); |
---|
| 532 | set(handles.i2,'String',num2str(i2)); |
---|
| 533 | set(handles.j1,'String',num2str(j1)); |
---|
| 534 | set(handles.j2,'String',num2str(j2)); |
---|
| 535 | |
---|
| 536 | % refresh the current field view |
---|
| 537 | run0_Callback(hObject, eventdata, handles) |
---|
| 538 | |
---|
| 539 | %------------------------------------------------------------------------ |
---|
| 540 | % --- Called by action in FileIndex_1 edit box |
---|
| 541 | function FileIndex_1_Callback(hObject, eventdata, handles) |
---|
| 542 | %------------------------------------------------------------------------ |
---|
| 543 | run0_Callback(hObject, eventdata, handles) |
---|
| 544 | |
---|
| 545 | %------------------------------------------------------------------------ |
---|
| 546 | % --- Called by action in NomType edit box |
---|
| 547 | function NomType_Callback(hObject, eventdata, handles) |
---|
| 548 | %------------------------------------------------------------------------ |
---|
| 549 | i1=str2num(get(handles.i1,'String')); |
---|
| 550 | i2=str2num(get(handles.i2,'String')); |
---|
| 551 | j1=str2num(get(handles.j1,'String')); |
---|
| 552 | j2=str2num(get(handles.j2,'String')); |
---|
| 553 | FileIndex=fullfile_uvmat('','','','',get(handles.NomType,'String'),i1,i2,j1,j2); |
---|
| 554 | set(handles.FileIndex,'String',FileIndex) |
---|
| 555 | % refresh the current settings and refresh the field view |
---|
| 556 | RootPath_Callback(hObject,eventdata,handles) |
---|
| 557 | |
---|
| 558 | %------------------------------------------------------------------------ |
---|
| 559 | % --- Called by action in NomType edit box |
---|
| 560 | function NomType_1_Callback(hObject, eventdata, handles) |
---|
| 561 | %------------------------------------------------------------------------ |
---|
| 562 | i1=str2num(get(handles.i1,'String')); |
---|
| 563 | i2=str2num(get(handles.i2,'String')); |
---|
| 564 | j1=str2num(get(handles.j1,'String')); |
---|
| 565 | j2=str2num(get(handles.j2,'String')); |
---|
| 566 | FileIndex=fullfile_uvmat('','','','',get(handles.NomType_1,'String'),i1,i2,j1,j2); |
---|
| 567 | set(handles.FileIndex_1,'String',FileIndex) |
---|
| 568 | % refresh the current settings and refresh the field view |
---|
| 569 | RootPath_1_Callback(hObject,eventdata,handles) |
---|
| 570 | |
---|
[387] | 571 | %------------------------------------------------------------------------ |
---|
| 572 | % --- Fills the edit boxes RootPath, RootFile,NomType...from an input file name 'fileinput' |
---|
[406] | 573 | function display_file_name(handles,fileinput,index) |
---|
[387] | 574 | %------------------------------------------------------------------------ |
---|
| 575 | %% look for the input file existence |
---|
| 576 | if ~exist(fileinput,'file') |
---|
| 577 | msgbox_uvmat('ERROR',['input file ' fileinput ' does not exist']) |
---|
| 578 | return |
---|
| 579 | end |
---|
| 580 | |
---|
| 581 | %% set the mouse pointer to 'watch' |
---|
| 582 | set(handles.uvmat,'Pointer','watch') |
---|
| 583 | set(handles.RootPath,'BackgroundColor',[1 1 0]) |
---|
| 584 | drawnow |
---|
| 585 | |
---|
[406] | 586 | %% define the relevant handles for the first field series (index=1) or the second file series (index=2) |
---|
[387] | 587 | if ~exist('index','var') |
---|
| 588 | index=1; |
---|
| 589 | end |
---|
| 590 | if index==1 |
---|
| 591 | handles_RootPath=handles.RootPath; |
---|
| 592 | handles_SubDir=handles.SubDir; |
---|
| 593 | handles_RootFile=handles.RootFile; |
---|
| 594 | handles_FileIndex=handles.FileIndex; |
---|
| 595 | handles_NomType=handles.NomType; |
---|
| 596 | handles_FileExt=handles.FileExt; |
---|
| 597 | elseif index==2 |
---|
| 598 | handles_RootPath=handles.RootPath_1; |
---|
| 599 | handles_SubDir=handles.SubDir_1; |
---|
| 600 | handles_RootFile=handles.RootFile_1; |
---|
| 601 | handles_FileIndex=handles.FileIndex_1; |
---|
| 602 | handles_NomType=handles.NomType_1; |
---|
| 603 | handles_FileExt=handles.FileExt_1; |
---|
| 604 | set(handles.RootPath_1,'Visible','on') |
---|
| 605 | set(handles.RootFile_1,'Visible','on') |
---|
| 606 | set(handles.SubDir_1,'Visible','on'); |
---|
| 607 | set(handles.FileIndex_1,'Visible','on'); |
---|
| 608 | set(handles.FileExt_1,'Visible','on'); |
---|
| 609 | set(handles.NomType_1,'Visible','on'); |
---|
| 610 | end |
---|
| 611 | |
---|
| 612 | %% detect root name, nomenclature and indices in the input file name: |
---|
[398] | 613 | [FilePath,FileName,FileExt]=fileparts(fileinput); |
---|
[387] | 614 | % detect the file type, get the movie object if relevant, and look for the corresponding file series: |
---|
[398] | 615 | % the root name and indices may be corrected by including the first index i1 if a corresponding xml file exists |
---|
| 616 | [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] | 617 | |
---|
| 618 | %% open the file or fill the GUI uvmat according to the detected file type |
---|
| 619 | switch FileType |
---|
| 620 | case '' |
---|
| 621 | msgbox_uvmat('ERROR','invalid input file type') |
---|
| 622 | case 'txt' |
---|
| 623 | edit(fileinput) |
---|
| 624 | case 'figure' %display matlab figure |
---|
| 625 | hfig=open(fileinput); |
---|
| 626 | set(hfig,'WindowButtonMotionFcn','mouse_motion')%set mouse action functio |
---|
| 627 | set(hfig,'WindowButtonUpFcn','mouse_up')%set mouse click action function |
---|
| 628 | set(hfig,'WindowButtonUpFcn','mouse_down')%set mouse click action function |
---|
[503] | 629 | case 'xml' % edit xml files |
---|
[507] | 630 | t=xmltree(fileinput); |
---|
[508] | 631 | % the xml file marks a project or project link, open datatree_browser |
---|
[507] | 632 | if strcmp(get(t,1,'name'),'Project')&& exist(regexprep(fileinput,'.xml$',''),'dir') |
---|
[503] | 633 | datatree_browser(fileinput) |
---|
[508] | 634 | else % other xml file, open the xml editor |
---|
[503] | 635 | editxml(fileinput); |
---|
| 636 | end |
---|
[508] | 637 | case 'xls'% Excel file opended by editxml |
---|
[387] | 638 | editxml(fileinput); |
---|
| 639 | otherwise |
---|
| 640 | set(handles_RootPath,'String',RootPath); |
---|
| 641 | rootname=fullfile(RootPath,SubDir,RootFile); |
---|
| 642 | set(handles_SubDir,'String',['/' SubDir]); |
---|
| 643 | set(handles_RootFile,'String',['/' RootFile]); %display the separator |
---|
| 644 | indices=fileinput(length(rootname)+1:end); |
---|
| 645 | indices(end-length(FileExt)+1:end)=[]; %remove extension |
---|
| 646 | set(handles_FileIndex,'String',indices); |
---|
| 647 | set(handles_NomType,'String',NomType); |
---|
| 648 | set(handles_FileExt,'String',FileExt); |
---|
| 649 | if index==1 |
---|
| 650 | % fill file index counters if the first file series is opened |
---|
| 651 | set(handles.i1,'String',num2str(i1)); |
---|
| 652 | set(handles.i2,'String',num2str(i2)); |
---|
| 653 | set(handles.j1,'String',num2stra(j1,NomType)); |
---|
| 654 | set(handles.j2,'String',num2stra(j2,NomType)); |
---|
[515] | 655 | else %read the current field index to synchronise with the first series |
---|
| 656 | i1_s=str2num(get(handles.i1,'String')); |
---|
| 657 | i2_0=str2num(get(handles.i2,'String')); |
---|
| 658 | if ~isempty(i2_0) |
---|
| 659 | i2_s=i2_0; |
---|
| 660 | else |
---|
| 661 | i2_s=i2; |
---|
| 662 | end |
---|
| 663 | j1_0=stra2num(get(handles.j1,'String')); |
---|
| 664 | if ~isempty(j1_0) |
---|
| 665 | j1_s=j1_0; |
---|
| 666 | else |
---|
| 667 | j1_s=j1; |
---|
| 668 | end |
---|
| 669 | j2_0=stra2num(get(handles.j2,'String')); |
---|
| 670 | if ~isempty(j2_0) |
---|
| 671 | j2_s=j2_0; |
---|
| 672 | else |
---|
| 673 | j2_s=j2; |
---|
| 674 | end |
---|
[387] | 675 | end |
---|
| 676 | |
---|
| 677 | % synchronise indices of the second input file if it exists |
---|
| 678 | if get(handles.SubField,'Value')==1% if the subfield button is activated, update the field numbers |
---|
| 679 | Input=read_GUI(handles.InputFile); |
---|
| 680 | if ~isfield(Input,'RootPath_1')||strcmp(Input.RootPath_1,'"') |
---|
| 681 | Input.RootPath_1=Input.RootPath; |
---|
| 682 | end |
---|
| 683 | if ~isfield(Input,'SubDir_1')||strcmp(Input.SubDir_1,'"') |
---|
| 684 | Input.SubDir_1=Input.SubDir; |
---|
| 685 | end |
---|
| 686 | if ~isfield(Input,'RootFile_1')||strcmp(Input.RootFile_1,'"') |
---|
| 687 | Input.RootFile_1=Input.RootFile; |
---|
| 688 | end |
---|
[405] | 689 | if ~isfield(Input,'FileExt_1')||strcmp(Input.FileExt_1,'"') |
---|
| 690 | Input.FileExt_1=Input.FileExt; |
---|
| 691 | end |
---|
| 692 | if ~isfield(Input,'NomType_1')||strcmp(Input.NomType_1,'"') |
---|
| 693 | Input.NomType_1=Input.NomType; |
---|
| 694 | end |
---|
[387] | 695 | %updtate the indices of the second field series to correspond to the newly opened one |
---|
[515] | 696 | FileName_1=fullfile_uvmat(Input.RootPath_1,Input.SubDir_1,Input.RootFile_1,Input.FileExt_1,Input.NomType_1,i1_s,i2_s,j1_s,j2_s); |
---|
[387] | 697 | if exist(FileName_1,'file') |
---|
[515] | 698 | FileIndex_1=fullfile_uvmat('','','','',Input.NomType_1,i1_s,i2_s,j1_s,j2_s); |
---|
| 699 | else |
---|
[387] | 700 | FileIndex_1=fullfile_uvmat('','','','',Input.NomType_1,i1,i2,j1,j2); |
---|
[408] | 701 | msgbox_uvmat('WARNING','unable to synchronise the indices of the two series') |
---|
[387] | 702 | end |
---|
[515] | 703 | set(handles.FileIndex_1,'String',FileIndex_1) |
---|
[387] | 704 | end |
---|
| 705 | |
---|
| 706 | %enable other menus |
---|
| 707 | set(handles.MenuOpen_1,'Enable','on') |
---|
| 708 | set(handles.MenuFile_1_1,'Enable','on') |
---|
| 709 | set(handles.MenuFile_2_1,'Enable','on') |
---|
| 710 | set(handles.MenuFile_3_1,'Enable','on') |
---|
| 711 | set(handles.MenuFile_4_1,'Enable','on') |
---|
| 712 | set(handles.MenuFile_5_1,'Enable','on') |
---|
| 713 | set(handles.MenuExport,'Enable','on') |
---|
| 714 | set(handles.MenuExportFigure,'Enable','on') |
---|
| 715 | set(handles.MenuExportMovie,'Enable','on') |
---|
| 716 | set(handles.MenuTools,'Enable','on') |
---|
[503] | 717 | |
---|
[387] | 718 | % initiate input file series and refresh the current field view: |
---|
| 719 | update_rootinfo(handles,i1_series,i2_series,j1_series,j2_series,FileType,MovieObject,index); |
---|
| 720 | |
---|
| 721 | end |
---|
| 722 | |
---|
[503] | 723 | %% update list of recent files in the menubar and save it for future opening |
---|
| 724 | MenuFile=[{get(handles.MenuFile_1,'Label')};{get(handles.MenuFile_2,'Label')};... |
---|
| 725 | {get(handles.MenuFile_3,'Label')};{get(handles.MenuFile_4,'Label')};{get(handles.MenuFile_5,'Label')}]; |
---|
| 726 | str_find=strcmp(fileinput,MenuFile); |
---|
| 727 | if isempty(find(str_find,1)) |
---|
| 728 | MenuFile=[{fileinput};MenuFile];%insert the current file if not already in the list |
---|
| 729 | end |
---|
| 730 | for ifile=1:min(length(MenuFile),5) |
---|
| 731 | eval(['set(handles.MenuFile_' num2str(ifile) ',''Label'',MenuFile{ifile});']) |
---|
| 732 | eval(['set(handles.MenuFile_' num2str(ifile) '_1,''Label'',MenuFile{ifile});']) |
---|
| 733 | end |
---|
| 734 | dir_perso=prefdir; |
---|
| 735 | profil_perso=fullfile(dir_perso,'uvmat_perso.mat'); |
---|
| 736 | if exist(profil_perso,'file') |
---|
| 737 | save (profil_perso,'MenuFile','-append'); %store the file names for future opening of uvmat |
---|
| 738 | else |
---|
| 739 | save (profil_perso,'MenuFile','-V6'); %store the file names for future opening of uvmat |
---|
| 740 | end |
---|
| 741 | |
---|
[387] | 742 | %% set back the mouse pointer to arrow |
---|
| 743 | set(handles.uvmat,'Pointer','arrow') |
---|
| 744 | |
---|
| 745 | |
---|
| 746 | %------------------------------------------------------------------------ |
---|
| 747 | % --- Update information about a new field series (indices to scan, timing, |
---|
| 748 | % calibration from an xml file, then refresh current plots |
---|
[515] | 749 | |
---|
[397] | 750 | function update_rootinfo(handles,i1_series,i2_series,j1_series,j2_series,FileType,VideoObject,index) |
---|
[387] | 751 | %------------------------------------------------------------------------ |
---|
| 752 | %% define the relevant handles depending on the index (1=first file series, 2= second file series) |
---|
| 753 | if ~exist('index','var') |
---|
| 754 | index=1; |
---|
| 755 | end |
---|
| 756 | if index==1 |
---|
| 757 | handles_RootPath=handles.RootPath; |
---|
[526] | 758 | handles_Fields=handles.FieldName; |
---|
[387] | 759 | elseif index==2 |
---|
| 760 | handles_RootPath=handles.RootPath_1; |
---|
[526] | 761 | handles_Fields=handles.FieldName_1; |
---|
[387] | 762 | end |
---|
| 763 | |
---|
| 764 | set(handles_RootPath,'BackgroundColor',[1 1 0]) |
---|
| 765 | drawnow |
---|
[526] | 766 | set(handles.FieldName,'UserData',[])% reinialize data from uvmat opening |
---|
[387] | 767 | UvData=get(handles.uvmat,'UserData');%huvmat=handles of the uvmat interface |
---|
| 768 | UvData.NewSeries=1; %flag for run0: begin a new series |
---|
[511] | 769 | UvData.FileName_1='';% name of the current second field (used to detect a constant field during file scanning) |
---|
[387] | 770 | UvData.FileType{index}=FileType; |
---|
| 771 | UvData.i1_series{index}=i1_series; |
---|
| 772 | UvData.i2_series{index}=i2_series; |
---|
| 773 | UvData.j1_series{index}=j1_series; |
---|
| 774 | UvData.j2_series{index}=j2_series; |
---|
| 775 | set(handles.FixVelType,'Value',0); %desactivate fixed veltype |
---|
| 776 | if index==1 |
---|
| 777 | [RootPath,SubDir,RootFile,FileIndices,FileExt]=read_file_boxes(handles); |
---|
| 778 | else |
---|
| 779 | [RootPath,SubDir,RootFile,FileIndices,FileExt]=read_file_boxes_1(handles); |
---|
| 780 | end |
---|
| 781 | FileName=[fullfile(RootPath,SubDir,RootFile) FileIndices FileExt]; |
---|
| 782 | FileBase=fullfile(RootPath,RootFile); |
---|
| 783 | if ~exist(FileName,'file') |
---|
| 784 | msgbox_uvmat('ERROR',['input file ' FileName ' not found']); |
---|
| 785 | return |
---|
| 786 | end |
---|
| 787 | |
---|
| 788 | %% read timing and total frame number from the current file (movie files) !! may be overrid by xml file |
---|
| 789 | XmlData.Time=[];%default |
---|
| 790 | XmlData.GeometryCalib=[];%default |
---|
[494] | 791 | TimeUnit='';%default |
---|
| 792 | Time=[]; |
---|
[548] | 793 | % testima=0; %test for image input |
---|
[387] | 794 | imainfo=[]; |
---|
| 795 | ColorType='falsecolor'; %default |
---|
[548] | 796 | % hhh=[]; |
---|
[397] | 797 | UvData.MovieObject{index}=VideoObject; |
---|
| 798 | if ~isempty(VideoObject) |
---|
| 799 | imainfo=get(VideoObject); |
---|
[548] | 800 | % testima=1; |
---|
[387] | 801 | TimeUnit='s'; |
---|
[494] | 802 | if isempty(j1_series); %frame index along i |
---|
| 803 | Time=(0:1/imainfo.FrameRate:(imainfo.NumberOfFrames)/imainfo.FrameRate)'; |
---|
| 804 | else |
---|
[548] | 805 | Time=ones(size(i1_series,1),1)*(0:1/imainfo.FrameRate:(imainfo.NumberOfFrames)/imainfo.FrameRate); |
---|
[494] | 806 | end |
---|
[397] | 807 | set(handles.Dt_txt,'String',['Dt=' num2str(1000/imainfo.FrameRate) 'ms']);%display the elementary time interval in millisec |
---|
| 808 | ColorType='truecolor'; |
---|
[387] | 809 | elseif ~isempty(FileExt(2:end))&&(~isempty(imformats(FileExt(2:end))) || isequal(FileExt,'.vol'))%&& isequal(NomType,'*')% multi-frame image |
---|
[548] | 810 | % testima=1; |
---|
[387] | 811 | if ~isequal(SubDir,'') |
---|
| 812 | imainfo=imfinfo([fullfile(RootPath,SubDir,RootFile) FileIndices FileExt]); |
---|
| 813 | else |
---|
| 814 | imainfo=imfinfo([FileBase FileIndices FileExt]); |
---|
| 815 | end |
---|
| 816 | ColorType=imainfo.ColorType;%='truecolor' for color images |
---|
| 817 | end |
---|
| 818 | if isfield(imainfo,'Width') && isfield(imainfo,'Height') |
---|
| 819 | if length(imainfo)>1 |
---|
| 820 | set(handles.num_Npx,'String',num2str(imainfo(1).Width));%fills nbre of pixels x box |
---|
| 821 | set(handles.num_Npy,'String',num2str(imainfo(1).Height));%fills nbre of pixels x box |
---|
| 822 | else |
---|
| 823 | set(handles.num_Npx,'String',num2str(imainfo.Width));%fills nbre of pixels x box |
---|
| 824 | set(handles.num_Npy,'String',num2str(imainfo.Height));%fills nbre of pixels x box |
---|
| 825 | end |
---|
| 826 | else |
---|
| 827 | set(handles.num_Npx,'String','');%fills nbre of pixels x box |
---|
| 828 | set(handles.num_Npy,'String','');%fills nbre of pixels x box |
---|
| 829 | end |
---|
| 830 | set(handles.CheckBW,'Value',strcmp(ColorType,'grayscale'))% select handles.CheckBW if grayscale image |
---|
| 831 | |
---|
| 832 | %% read parameters (time, geometric calibration..) from a documentation file (.xml advised) |
---|
[469] | 833 | XmlFileName=find_imadoc(RootPath,SubDir,RootFile,FileExt); |
---|
| 834 | [tild,tild,DocExt]=fileparts(XmlFileName); |
---|
[387] | 835 | warntext='';%default warning message |
---|
| 836 | NbSlice=1;%default |
---|
| 837 | set(handles.RootPath,'BackgroundColor',[1 1 1]) |
---|
[469] | 838 | if ~isempty(XmlFileName) |
---|
[387] | 839 | set(handles.view_xml,'Visible','on') |
---|
| 840 | set(handles.view_xml,'BackgroundColor',[1 1 0]) |
---|
| 841 | set(handles.view_xml,'String','view .xml') |
---|
| 842 | drawnow |
---|
[469] | 843 | [XmlDataRead,warntext]=imadoc2struct(XmlFileName); |
---|
[387] | 844 | if ~isempty(warntext) |
---|
[456] | 845 | msgbox_uvmat('WARNING',warntext) |
---|
[387] | 846 | end |
---|
[456] | 847 | if isempty(XmlDataRead) |
---|
| 848 | set(handles.view_xml,'Visible','off') |
---|
| 849 | else |
---|
| 850 | set(handles.view_xml,'String',['view ' DocExt]) |
---|
| 851 | XmlData=XmlDataRead; |
---|
| 852 | if isfield(XmlData,'TimeUnit') |
---|
| 853 | if isfield(XmlData,'TimeUnit')&& ~isempty(XmlData.TimeUnit) |
---|
| 854 | TimeUnit=XmlData.TimeUnit; |
---|
| 855 | end |
---|
[387] | 856 | end |
---|
[456] | 857 | set(handles.view_xml,'BackgroundColor',[1 1 1]) |
---|
| 858 | drawnow |
---|
| 859 | if isfield(XmlData, 'GeometryCalib') && ~isempty(XmlData.GeometryCalib) |
---|
| 860 | if isfield(XmlData.GeometryCalib,'VolumeScan') && isequal(XmlData.GeometryCalib.VolumeScan,'y') |
---|
[497] | 861 | set (handles.num_NbSlice,'String','volume') |
---|
[456] | 862 | end |
---|
| 863 | hgeometry_calib=findobj('tag','geometry_calib'); |
---|
| 864 | if ~isempty(hgeometry_calib) |
---|
| 865 | GUserData=get(hgeometry_calib,'UserData'); |
---|
[469] | 866 | if ~(isfield(GUserData,'XmlInputFile') && strcmp(GUserData.XmlInputFile,XmlFileName)) |
---|
[456] | 867 | answer=msgbox_uvmat('INPUT_Y-N','replace the display of geometry_calib with the new input data?'); |
---|
| 868 | if strcmp(answer,'Yes') |
---|
[469] | 869 | geometry_calib(XmlFileName);%diplay the new calibration points and parameters in geometry_calib |
---|
[456] | 870 | end |
---|
[387] | 871 | end |
---|
| 872 | end |
---|
| 873 | end |
---|
[441] | 874 | end |
---|
[387] | 875 | end |
---|
[494] | 876 | if ~(isfield(XmlData,'Time')&& ~isempty(XmlData.Time)) |
---|
| 877 | XmlData.Time=Time; %time set by video |
---|
| 878 | end |
---|
[387] | 879 | |
---|
| 880 | %% store last index in handles.lat_i and .last_j |
---|
[496] | 881 | nbfield=max(max(max(i2_series))); |
---|
[387] | 882 | if isempty(nbfield) |
---|
[496] | 883 | nbfield=max(max(max(i1_series))); |
---|
[387] | 884 | end |
---|
[496] | 885 | nbfield_j=max(max(max(j2_series))); |
---|
[387] | 886 | if isempty(nbfield_j) |
---|
[496] | 887 | nbfield_j=max(max(max(j2_series))); |
---|
[387] | 888 | end |
---|
| 889 | if ~isempty(XmlData.Time) |
---|
| 890 | %transform .Time to a column vector if it is a line vector the nomenclature uses a single index |
---|
[441] | 891 | if isequal(size(XmlData.Time,1),1) |
---|
[387] | 892 | NomType=get(handles.NomType,'String'); |
---|
[456] | 893 | XmlData.Time=(XmlData.Time)'; |
---|
[387] | 894 | end |
---|
| 895 | end |
---|
| 896 | last_i_cell=get(handles.last_i,'String'); |
---|
| 897 | if isempty(nbfield) |
---|
| 898 | last_i_cell{1}=''; |
---|
| 899 | else |
---|
| 900 | last_i_cell{1}=num2str(nbfield); |
---|
| 901 | end |
---|
| 902 | set(handles.last_i,'String',last_i_cell) |
---|
| 903 | last_j_cell=get(handles.last_j,'String'); |
---|
| 904 | if isempty(nbfield_j) |
---|
| 905 | last_j_cell{1}=''; |
---|
| 906 | else |
---|
| 907 | last_j_cell{1}=num2str(nbfield_j); |
---|
| 908 | end |
---|
| 909 | set(handles.last_j,'String',last_j_cell); |
---|
| 910 | |
---|
| 911 | %% store geometric calibration in UvData |
---|
| 912 | if isfield(XmlData,'GeometryCalib') |
---|
| 913 | GeometryCalib=XmlData.GeometryCalib; |
---|
| 914 | if isempty(GeometryCalib) |
---|
| 915 | set(handles.pxcm,'String','') |
---|
| 916 | set(handles.pycm,'String','') |
---|
| 917 | set(handles.transform_fct,'Value',1); % no transform by default |
---|
| 918 | else |
---|
| 919 | if (isfield(GeometryCalib,'R')&& ~isequal(GeometryCalib.R(2,1),0) && ~isequal(GeometryCalib.R(1,2),0)) ||... |
---|
| 920 | (isfield(GeometryCalib,'kappa1')&& ~isequal(GeometryCalib.kappa1,0)) |
---|
| 921 | set(handles.pxcm,'String','var') |
---|
| 922 | set(handles.pycm,'String','var') |
---|
| 923 | elseif isfield(GeometryCalib,'fx_fy') |
---|
| 924 | pixcmx=GeometryCalib.fx_fy(1);%*GeometryCalib.R(1,1)*GeometryCalib.sx/(GeometryCalib.Tz*GeometryCalib.dpx); |
---|
| 925 | pixcmy=GeometryCalib.fx_fy(2);%*GeometryCalib.R(2,2)/(GeometryCalib.Tz*GeometryCalib.dpy); |
---|
| 926 | set(handles.pxcm,'String',num2str(pixcmx)) |
---|
| 927 | set(handles.pycm,'String',num2str(pixcmy)) |
---|
| 928 | end |
---|
| 929 | if ~get(handles.CheckFixLimits,'Value') |
---|
[515] | 930 | set(handles.transform_fct,'Value',3); % phys transform by default if fixedLimits is off |
---|
[387] | 931 | end |
---|
[508] | 932 | if isfield(GeometryCalib,'SliceCoord') |
---|
[387] | 933 | siz=size(GeometryCalib.SliceCoord); |
---|
| 934 | if siz(1)>1 |
---|
| 935 | NbSlice=siz(1); |
---|
| 936 | set(handles.slices,'Visible','on') |
---|
| 937 | set(handles.slices,'Value',1) |
---|
| 938 | end |
---|
| 939 | if isfield(GeometryCalib,'VolumeScan') && isequal(GeometryCalib.VolumeScan,'y') |
---|
[497] | 940 | set(handles.num_NbSlice,'String','volume') |
---|
[387] | 941 | else |
---|
[497] | 942 | set(handles.num_NbSlice,'String',num2str(NbSlice)) |
---|
[387] | 943 | end |
---|
| 944 | slices_Callback([],[], handles) |
---|
| 945 | end |
---|
| 946 | end |
---|
| 947 | end |
---|
| 948 | |
---|
| 949 | %% update the data attached to the uvmat interface |
---|
| 950 | if ~isempty(TimeUnit) |
---|
| 951 | set(handles.time_txt,'String',['time (' TimeUnit ')']) |
---|
| 952 | end |
---|
| 953 | UvData.TimeUnit=TimeUnit; |
---|
| 954 | UvData.XmlData{index}=XmlData; |
---|
| 955 | UvData.NewSeries=1; |
---|
| 956 | % UvData.MovieObject=MovieObject; |
---|
| 957 | |
---|
| 958 | %display warning message |
---|
| 959 | if ~isequal(warntext,'') |
---|
| 960 | msgbox_uvmat('WARNING',warntext); |
---|
| 961 | end |
---|
| 962 | |
---|
[526] | 963 | %% set default options in menu 'FieldName' |
---|
[517] | 964 | switch FileType |
---|
| 965 | case {'civx','civdata'} |
---|
[525] | 966 | [FieldList,ColorList]=calc_field; |
---|
| 967 | set(handles_Fields,'String',[{'image'};FieldList;{'get_field...'}]);%standard menu for civx data |
---|
| 968 | set(handles_Fields,'Value',2) % set menu to 'velocity |
---|
| 969 | set(handles.ColorScalar,'Value',1) |
---|
| 970 | set(handles.ColorScalar,'String',ColorList) |
---|
| 971 | set(handles.Vectors,'Visible','on') |
---|
| 972 | set(handles.Coord_x,'Value',1); |
---|
| 973 | set(handles.Coord_x,'String',{'X'}); |
---|
| 974 | set(handles.Coord_y,'Value',1); |
---|
| 975 | set(handles.Coord_y,'String',{'Y'}); |
---|
[517] | 976 | case 'netcdf' |
---|
[387] | 977 | set(handles_Fields,'Value',1) |
---|
| 978 | set(handles_Fields,'String',{'get_field...'}) |
---|
[517] | 979 | hget_field=get_field(FileName); |
---|
| 980 | hhget_field=guidata(hget_field); |
---|
[525] | 981 | get_field('RUN_Callback',hhget_field.RUN,[],hhget_field); |
---|
[517] | 982 | otherwise |
---|
| 983 | set(handles_Fields,'Value',1) % set menu to 'image' |
---|
| 984 | set(handles_Fields,'String',{'image'}) |
---|
[525] | 985 | set(handles.Coord_x,'Value',1); |
---|
| 986 | set(handles.Coord_x,'String',{'AX'}); |
---|
| 987 | set(handles.Coord_y,'Value',1); |
---|
| 988 | set(handles.Coord_y,'String',{'AY'}); |
---|
[387] | 989 | end |
---|
| 990 | set(handles.uvmat,'UserData',UvData) |
---|
| 991 | |
---|
| 992 | %% set index navigation options and refresh plots |
---|
| 993 | scan_option='i';%default |
---|
| 994 | state_j='off'; %default |
---|
| 995 | if index==2 |
---|
| 996 | if get(handles.scan_j,'Value') |
---|
[494] | 997 | scan_option='j'; %keep the scan option for the second file series |
---|
[387] | 998 | end |
---|
| 999 | if strcmp(get(handles.j1,'Visible'),'on') |
---|
| 1000 | state_j='on'; |
---|
| 1001 | end |
---|
| 1002 | end |
---|
[515] | 1003 | [ref_j,ref_i]=find(squeeze(i1_series(1,:,:))); |
---|
[387] | 1004 | if ~isempty(j1_series) |
---|
| 1005 | state_j='on'; |
---|
[494] | 1006 | if index==1 |
---|
[515] | 1007 | if isequal(ref_i,ref_i(1)*ones(size(ref_j)))% if ref_i is always equal to its first value |
---|
[494] | 1008 | scan_option='j'; %scan j indext |
---|
| 1009 | end |
---|
| 1010 | end |
---|
[387] | 1011 | end |
---|
| 1012 | if isequal(scan_option,'i') |
---|
[494] | 1013 | diff_ref_i=diff(ref_i,1); |
---|
| 1014 | if isempty(diff_ref_i) |
---|
| 1015 | diff_ref_i=1; |
---|
| 1016 | end |
---|
| 1017 | if isequal (diff_ref_i,diff_ref_i(1)*ones(size(diff_ref_i))) |
---|
[511] | 1018 | set(handles.num_IndexIncrement,'String',num2str(diff_ref_i(1))) |
---|
[494] | 1019 | end |
---|
[387] | 1020 | set(handles.scan_i,'Value',1) |
---|
| 1021 | scan_i_Callback([],[], handles); |
---|
| 1022 | else |
---|
[494] | 1023 | diff_ref_j=diff(ref_j); |
---|
| 1024 | if isempty(diff_ref_j) |
---|
| 1025 | diff_ref_j=1; |
---|
| 1026 | end |
---|
| 1027 | if isequal (diff_ref_j,diff_ref_j(1)*ones(size(diff_ref_j))) |
---|
[511] | 1028 | set(handles.num_IndexIncrement,'String',num2str(diff_ref_j(1))) |
---|
[494] | 1029 | end |
---|
[387] | 1030 | set(handles.scan_j,'Value',1) |
---|
| 1031 | scan_j_Callback([],[], handles); |
---|
| 1032 | end |
---|
| 1033 | set(handles.scan_j,'Visible',state_j) |
---|
| 1034 | set(handles.j1,'Visible',state_j) |
---|
| 1035 | set(handles.j2,'Visible',state_j) |
---|
| 1036 | set(handles.last_j,'Visible',state_j); |
---|
| 1037 | set(handles.frame_j,'Visible',state_j); |
---|
| 1038 | set(handles.j_text,'Visible',state_j); |
---|
| 1039 | if ~isempty(i2_series)||~isempty(j2_series) |
---|
| 1040 | set(handles.CheckFixPair,'Visible','on') |
---|
| 1041 | elseif index==1 |
---|
| 1042 | set(handles.CheckFixPair,'Visible','off') |
---|
| 1043 | end |
---|
| 1044 | |
---|
[508] | 1045 | %% apply the effect of the transform fct and view the field |
---|
[515] | 1046 | transform=get(handles.path_transform,'UserData'); |
---|
| 1047 | if index==2 && (~isa(transform,'function_handle')||nargin(transform)<3) |
---|
| 1048 | set(handles.transform_fct,'value',2); % set transform to sub_field if the current fct doe not accept two input fields |
---|
| 1049 | end |
---|
[508] | 1050 | transform_fct_Callback([],[],handles) |
---|
[387] | 1051 | mask_test=get(handles.CheckMask,'value'); |
---|
| 1052 | if mask_test |
---|
| 1053 | MaskData=get(handles.CheckMask,'UserData'); |
---|
| 1054 | if isfield(MaskData,'maskhandle') && ishandle(MaskData.maskhandle) |
---|
| 1055 | delete(MaskData.maskhandle) %delete old mask |
---|
| 1056 | end |
---|
| 1057 | CheckMask_Callback([],[],handles) |
---|
| 1058 | end |
---|
| 1059 | |
---|
| 1060 | %------------------------------------------------------------------------ |
---|
| 1061 | % --- switch file index scanning options scan_i and scan_j in an exclusive way |
---|
| 1062 | function scan_i_Callback(hObject, eventdata, handles) |
---|
| 1063 | %------------------------------------------------------------------------ |
---|
| 1064 | if get(handles.scan_i,'Value')==1 |
---|
| 1065 | set(handles.scan_i,'BackgroundColor',[1 1 0]) |
---|
| 1066 | set(handles.scan_j,'Value',0) |
---|
| 1067 | else |
---|
| 1068 | set(handles.scan_i,'BackgroundColor',[0.831 0.816 0.784]) |
---|
| 1069 | set(handles.scan_j,'Value',1) |
---|
| 1070 | end |
---|
| 1071 | scan_j_Callback(hObject, eventdata, handles) |
---|
| 1072 | |
---|
| 1073 | %------------------------------------------------------------------------ |
---|
| 1074 | % --- switch file index scanning options scan_i and scan_j in an exclusive way |
---|
| 1075 | function scan_j_Callback(hObject, eventdata, handles) |
---|
| 1076 | %------------------------------------------------------------------------ |
---|
| 1077 | if get(handles.scan_j,'Value')==1 |
---|
| 1078 | set(handles.scan_j,'BackgroundColor',[1 1 0]) |
---|
| 1079 | set(handles.scan_i,'Value',0) |
---|
| 1080 | set(handles.scan_i,'BackgroundColor',[0.831 0.816 0.784]) |
---|
| 1081 | % NomType=get(handles.NomType,'String'); |
---|
| 1082 | % switch NomType |
---|
| 1083 | % case {'_1_1-2','#_ab','%3dab'},% pair with j index |
---|
| 1084 | % set(handles.CheckFixPair,'Visible','on')% option fixed pair on/off made visible (choice of avaible pair with buttons + and - if ='off') |
---|
| 1085 | % otherwise |
---|
| 1086 | % set(handles.CheckFixPair,'Visible','off') |
---|
| 1087 | % end |
---|
| 1088 | else |
---|
| 1089 | set(handles.scan_j,'BackgroundColor',[0.831 0.816 0.784]) |
---|
| 1090 | set(handles.scan_i,'Value',1) |
---|
| 1091 | set(handles.scan_i,'BackgroundColor',[1 1 0]) |
---|
| 1092 | set(handles.CheckFixPair,'Visible','off') |
---|
| 1093 | end |
---|
| 1094 | |
---|
| 1095 | %------------------------------------------------------------------------ |
---|
| 1096 | function i1_Callback(hObject, eventdata, handles) |
---|
| 1097 | %------------------------------------------------------------------------ |
---|
[515] | 1098 | update_ij(handles,1) |
---|
[387] | 1099 | |
---|
| 1100 | %------------------------------------------------------------------------ |
---|
| 1101 | function i2_Callback(hObject, eventdata, handles) |
---|
| 1102 | %------------------------------------------------------------------------ |
---|
[515] | 1103 | update_ij(handles,2) |
---|
[387] | 1104 | |
---|
| 1105 | %------------------------------------------------------------------------ |
---|
| 1106 | function j1_Callback(hObject, eventdata, handles) |
---|
| 1107 | %------------------------------------------------------------------------ |
---|
[515] | 1108 | update_ij(handles,3) |
---|
[387] | 1109 | |
---|
| 1110 | %------------------------------------------------------------------------ |
---|
| 1111 | function j2_Callback(hObject, eventdata, handles) |
---|
| 1112 | %------------------------------------------------------------------------ |
---|
[515] | 1113 | update_ij(handles,4) |
---|
[387] | 1114 | |
---|
| 1115 | %------------------------------------------------------------------------ |
---|
[515] | 1116 | %--- update the index display after action on edit boxes i1, i2, j1 or j2 |
---|
| 1117 | function update_ij(handles,index_rank) |
---|
| 1118 | NomType=get(handles.NomType,'String'); |
---|
| 1119 | indices=get(handles.FileIndex,'String'); |
---|
| 1120 | [tild,tild,tild,i1,i2,j1,j2]=fileparts_uvmat(indices);% the indices for the second series taken from FileIndex |
---|
| 1121 | switch index_rank |
---|
| 1122 | case 1 |
---|
| 1123 | indices=fullfile_uvmat('','','','',NomType,stra2num(get(handles.i1,'String')),i2,j1,j2); |
---|
| 1124 | set(handles.i1,'BackgroundColor',[0.7 0.7 0.7])% mark the edit box in grey, then RUN0 will mark it in white for confirmation |
---|
| 1125 | case 2 |
---|
| 1126 | indices=fullfile_uvmat('','','','',NomType,i1,stra2num(get(handles.i2,'String')),j1,j2); |
---|
| 1127 | set(handles.i2,'BackgroundColor',[0.7 0.7 0.7])% mark the edit box in grey, then RUN0 will mark it in white for confirmation |
---|
| 1128 | case 3 |
---|
| 1129 | indices=fullfile_uvmat('','','','',NomType,i1,i2,stra2num(get(handles.j1,'String')),j2); |
---|
| 1130 | set(handles.j1,'BackgroundColor',[0.7 0.7 0.7])% mark the edit box in grey, then RUN0 will mark it in white for confirmation |
---|
| 1131 | case 4 |
---|
| 1132 | indices=fullfile_uvmat('','','','',NomType,i1,i2,j1,stra2num(get(handles.j2,'String'))); |
---|
| 1133 | set(handles.j2,'BackgroundColor',[0.7 0.7 0.7])% mark the edit box in grey, then RUN0 will mark it in white for confirmation |
---|
| 1134 | end |
---|
| 1135 | set(handles.FileIndex,'String',indices) |
---|
| 1136 | set(handles.FileIndex,'BackgroundColor',[0.7 0.7 0.7])% mark the edit box in grey, then RUN0 will mark it in white for confirmation |
---|
| 1137 | % update the second index if relevant |
---|
| 1138 | if strcmp(get(handles.FileIndex_1,'Visible'),'on') |
---|
| 1139 | NomType_1=get(handles.NomType_1,'String'); |
---|
| 1140 | indices_1=get(handles.FileIndex_1,'String'); |
---|
| 1141 | [tild,tild,tild,i1_1,i2_1,j1_1,j2_1]=fileparts_uvmat(indices_1);% the indices for the second series taken from FileIndex_1 |
---|
| 1142 | switch index_rank |
---|
| 1143 | case 1 |
---|
| 1144 | indices_1=fullfile_uvmat('','','','',NomType_1,stra2num(get(handles.i1,'String')),i2_1,j1_1,j2_1); |
---|
| 1145 | case 2 |
---|
| 1146 | indices_1=fullfile_uvmat('','','','',NomType_1,i1_1,stra2num(get(handles.i2,'String')),j1_1,j2_1); |
---|
| 1147 | case 3 |
---|
| 1148 | indices_1=fullfile_uvmat('','','','',NomType_1,i1_1,i2_1,stra2num(get(handles.j1,'String')),j2_1); |
---|
| 1149 | case 4 |
---|
| 1150 | indices_1=fullfile_uvmat('','','','',NomType_1,i1_1,i2_1,j1_1,stra2num(get(handles.j2,'String'))); |
---|
| 1151 | end |
---|
| 1152 | set(handles.FileIndex_1,'String',indices_1) |
---|
| 1153 | set(handles.FileIndex_1,'BackgroundColor',[0.7 0.7 0.7])% mark the edit box in grey, then RUN0 will mark it in white for confirmation |
---|
| 1154 | end |
---|
| 1155 | |
---|
| 1156 | %------------------------------------------------------------------------ |
---|
| 1157 | |
---|
| 1158 | %------------------------------------------------------------------------ |
---|
[387] | 1159 | function slices_Callback(hObject, eventdata, handles) |
---|
| 1160 | %------------------------------------------------------------------------ |
---|
| 1161 | if get(handles.slices,'Value')==1 |
---|
| 1162 | set(handles.slices,'BackgroundColor',[1 1 0]) |
---|
[497] | 1163 | set(handles.num_NbSlice,'Visible','on') |
---|
[387] | 1164 | set(handles.z_text,'Visible','on') |
---|
| 1165 | set(handles.z_index,'Visible','on') |
---|
[497] | 1166 | num_NbSlice_Callback(hObject, eventdata, handles) |
---|
[387] | 1167 | else |
---|
[497] | 1168 | set(handles.num_NbSlice,'Visible','off') |
---|
[387] | 1169 | set(handles.slices,'BackgroundColor',[0.7 0.7 0.7]) |
---|
| 1170 | set(handles.z_text,'Visible','off') |
---|
| 1171 | set(handles.z_index,'Visible','off') |
---|
| 1172 | set(handles.masklevel,'Value',1) |
---|
| 1173 | set(handles.masklevel,'String',{'1'}) |
---|
| 1174 | end |
---|
| 1175 | |
---|
| 1176 | %------------------------------------------------------------------------ |
---|
[497] | 1177 | function num_NbSlice_Callback(hObject, eventdata, handles) |
---|
[387] | 1178 | %------------------------------------------------------------------------ |
---|
[497] | 1179 | nb_slice_str=get(handles.num_NbSlice,'String'); |
---|
[387] | 1180 | if isequal(nb_slice_str,'volume') |
---|
| 1181 | num=stra2num(get(handles.j1,'String')); |
---|
| 1182 | last_j=get(handles.last_j,'String'); |
---|
| 1183 | nbslice=str2double(last_j{1}); |
---|
| 1184 | else |
---|
| 1185 | num=str2double(get(handles.i1,'String')); |
---|
[497] | 1186 | nbslice=str2double(get(handles.num_NbSlice,'String')); |
---|
[387] | 1187 | end |
---|
| 1188 | z=mod(num-1,nbslice)+1; |
---|
| 1189 | set(handles.z_index,'String',num2str(z)) |
---|
| 1190 | for ilist=1:nbslice |
---|
| 1191 | list_index{ilist,1}=num2str(ilist); |
---|
| 1192 | end |
---|
| 1193 | set(handles.masklevel,'String',list_index) |
---|
| 1194 | set(handles.masklevel,'Value',z) |
---|
| 1195 | |
---|
| 1196 | %------------------------------------------------------------------------ |
---|
| 1197 | % --- Executes on button press in view_xml. |
---|
| 1198 | function view_xml_Callback(hObject, eventdata, handles) |
---|
| 1199 | %------------------------------------------------------------------------ |
---|
| 1200 | %[FileName,RootPath,FileBase,FileIndices,FileExt]=read_file_boxes(handles); |
---|
| 1201 | [RootPath,SubDir,RootFile,FileIndices,FileExt]=read_file_boxes(handles); |
---|
| 1202 | FileBase=fullfile(RootPath,RootFile); |
---|
| 1203 | option=get(handles.view_xml,'String'); |
---|
| 1204 | if isequal(option,'view .xml') |
---|
[494] | 1205 | FileXml=fullfile(RootPath,[SubDir '.xml']); |
---|
| 1206 | if ~exist(FileXml,'file')% case of civ files , removes the extension for subdir |
---|
| 1207 | FileXml=fullfile(RootPath,[regexprep(SubDir,'\..+$','') '.xml']); |
---|
| 1208 | end |
---|
[387] | 1209 | heditxml=editxml(FileXml); |
---|
| 1210 | end |
---|
| 1211 | |
---|
| 1212 | %------------------------------------------------------------------------ |
---|
| 1213 | % --- Executes on button press in CheckMask. |
---|
| 1214 | function CheckMask_Callback(hObject, eventdata, handles) |
---|
| 1215 | %------------------------------------------------------------------------ |
---|
| 1216 | %case of view mask selection |
---|
| 1217 | if isequal(get(handles.CheckMask,'Value'),1) |
---|
| 1218 | [RootPath,SubDir,RootFile,FileIndices,FileExt]=read_file_boxes(handles); |
---|
| 1219 | FileBase=fullfile(RootPath,RootFile); |
---|
| 1220 | num_i1=stra2num(get(handles.i1,'String')); |
---|
| 1221 | num_j1=stra2num(get(handles.j1,'String')); |
---|
| 1222 | currentdir=pwd; |
---|
| 1223 | cd(RootPath); |
---|
| 1224 | maskfiles=dir('*_*mask_*.png');%look for a mask file |
---|
| 1225 | cd(currentdir);%come back to the working directory |
---|
| 1226 | mdetect=0; |
---|
| 1227 | if ~isempty(maskfiles) |
---|
| 1228 | for ilist=1:length(maskfiles) |
---|
| 1229 | maskname=maskfiles(ilist).name;% take the first mask file in the list |
---|
| 1230 | [tild,tild,tild,tild,tild,tild,tild,MaskExt,Mask_NomType{ilist}]=fileparts_uvmat(maskname); |
---|
| 1231 | [tild,Name]=fileparts(maskname); |
---|
| 1232 | Namedouble=double(Name); |
---|
| 1233 | val=(48>Namedouble)|(Namedouble>57);% select the non-numerical characters |
---|
| 1234 | ind_mask=findstr('mask',Name); |
---|
| 1235 | i=ind_mask-1; |
---|
| 1236 | while val(i)==0 && i>0 |
---|
| 1237 | i=i-1; |
---|
| 1238 | end |
---|
| 1239 | nbmask_str=str2num(Name(i+1:ind_mask-1)); |
---|
| 1240 | if ~isempty(nbmask_str) |
---|
| 1241 | nbslice(ilist)=nbmask_str; % number of different masks (slices) |
---|
| 1242 | end |
---|
| 1243 | end |
---|
| 1244 | if isequal(min(nbslice),max(nbslice)) |
---|
| 1245 | nbslice=nbslice(1); |
---|
| 1246 | else |
---|
| 1247 | msgbox_uvmat('ERROR','several inconsistent mask sets coexist in the current image directory') |
---|
| 1248 | return |
---|
| 1249 | end |
---|
| 1250 | if ~isempty(nbslice) && Name(i)=='_' |
---|
| 1251 | Mask.Base=[FileBase Name(i:ind_mask+3)]; |
---|
| 1252 | Mask.NbSlice=nbslice; |
---|
| 1253 | num_i1=mod(num_i1-1,nbslice)+1; |
---|
| 1254 | Mask.NomType=regexprep(Mask_NomType{1},'0','');%remove '0' in nom type for masks |
---|
| 1255 | [RootPath,RootFile]=fileparts(Mask.Base); |
---|
| 1256 | maskname=fullfile_uvmat(RootPath,'',RootFile,'.png',Mask.NomType,num_i1,[],num_j1); |
---|
| 1257 | %maskname=name_generator(Mask.Base,num_i1,num_j1,'.png',Mask.NomType);% |
---|
| 1258 | mdetect=exist(maskname,'file'); |
---|
| 1259 | if mdetect |
---|
[497] | 1260 | set(handles.num_NbSlice,'String',Name(i+1:ind_mask-1)); |
---|
| 1261 | set(handles.num_NbSlice,'BackgroundColor',[1 1 0]) |
---|
[387] | 1262 | set(handles.CheckMask,'UserData',Mask); |
---|
| 1263 | set(handles.CheckMask,'BackgroundColor',[1 1 0]) |
---|
| 1264 | if nbslice > 1 |
---|
| 1265 | set(handles.slices,'value',1) |
---|
| 1266 | slices_Callback(hObject, eventdata, handles) |
---|
| 1267 | end |
---|
| 1268 | end |
---|
| 1269 | end |
---|
| 1270 | end |
---|
| 1271 | errormsg=[];%default |
---|
| 1272 | if mdetect==0 |
---|
| 1273 | [FileName, PathName, filterindex] = uigetfile( ... |
---|
| 1274 | {'*.png', ' (*.png)'; |
---|
| 1275 | '*.png', '.png files '; ... |
---|
| 1276 | '*.*', 'All Files (*.*)'}, ... |
---|
| 1277 | 'Pick a mask file *.png',FileBase); |
---|
[530] | 1278 | if ~ischar(FileName),return,end %abandon if the browser is cancelled |
---|
[387] | 1279 | maskname=fullfile(PathName,FileName); |
---|
[444] | 1280 | [RootDir,SubDir,RootFile,tild,tild,tild,tild,tild,Mask.NomType]=fileparts_uvmat(maskname); |
---|
| 1281 | Mask.Base=fullfile(RootDir,SubDir,RootFile); |
---|
[387] | 1282 | Mask.NbSlice=1; |
---|
| 1283 | set(handles.CheckMask,'UserData',Mask); |
---|
| 1284 | set(handles.CheckMask,'BackgroundColor',[1 1 0]) |
---|
| 1285 | end |
---|
| 1286 | if isempty(errormsg) |
---|
| 1287 | errormsg=update_mask(handles,num_i1,num_j1); |
---|
| 1288 | end |
---|
| 1289 | if ~isempty(errormsg) |
---|
| 1290 | set(handles.CheckMask,'Value',0) |
---|
| 1291 | set(handles.CheckMask,'BackgroundColor',[0.7 0.7 0.7]) |
---|
| 1292 | end |
---|
| 1293 | else % desactivate mask display |
---|
| 1294 | MaskData=get(handles.CheckMask,'UserData'); |
---|
| 1295 | if isfield(MaskData,'maskhandle') && ishandle(MaskData.maskhandle) |
---|
| 1296 | delete(MaskData.maskhandle) |
---|
| 1297 | end |
---|
| 1298 | set(handles.CheckMask,'UserData',[]) |
---|
| 1299 | UvData=get(handles.uvmat,'UserData'); |
---|
| 1300 | if isfield(UvData,'MaskName') |
---|
| 1301 | UvData=rmfield(UvData,'MaskName'); |
---|
| 1302 | set(handles.uvmat,'UserData',UvData) |
---|
| 1303 | end |
---|
| 1304 | set(handles.CheckMask,'BackgroundColor',[0.7 0.7 0.7]) |
---|
| 1305 | end |
---|
| 1306 | |
---|
| 1307 | %------------------------------------------------------------------------ |
---|
| 1308 | function errormsg=update_mask(handles,num_i1,num_j1) |
---|
| 1309 | %------------------------------------------------------------------------ |
---|
| 1310 | errormsg=[];%default |
---|
| 1311 | MaskData=get(handles.CheckMask,'UserData'); |
---|
| 1312 | if isfield(MaskData,'maskhandle')&& ishandle(MaskData.maskhandle) |
---|
| 1313 | uistack(MaskData.maskhandle,'top'); |
---|
| 1314 | end |
---|
| 1315 | num_i1_mask=mod(num_i1-1,MaskData.NbSlice)+1; |
---|
| 1316 | [RootPath,RootFile]=fileparts(MaskData.Base); |
---|
| 1317 | MaskName=fullfile_uvmat(RootPath,'',RootFile,'.png',MaskData.NomType,num_i1_mask,[],num_j1); |
---|
| 1318 | UvData=get(handles.uvmat,'UserData'); |
---|
| 1319 | %update mask image if the mask is new |
---|
| 1320 | if ~ (isfield(UvData,'MaskName') && isequal(UvData.MaskName,MaskName)) |
---|
| 1321 | UvData.MaskName=MaskName; %update the recorded name on UvData |
---|
| 1322 | set(handles.uvmat,'UserData',UvData); |
---|
| 1323 | if ~exist(MaskName,'file') |
---|
| 1324 | if isfield(MaskData,'maskhandle')&& ishandle(MaskData.maskhandle) |
---|
| 1325 | delete(MaskData.maskhandle) |
---|
| 1326 | end |
---|
| 1327 | else |
---|
| 1328 | %read mask image |
---|
[542] | 1329 | [Mask,tild,errormsg] = read_field(MaskName,'image'); |
---|
| 1330 | % Mask.AName='image'; |
---|
| 1331 | % Mask.A=imread(MaskName); |
---|
| 1332 | if ~isempty(errormsg) |
---|
| 1333 | return |
---|
| 1334 | end |
---|
[387] | 1335 | npxy=size(Mask.A); |
---|
| 1336 | if length(npxy)>2 |
---|
| 1337 | errormsg=[MaskName ' is not a grey scale image']; |
---|
| 1338 | return |
---|
| 1339 | elseif ~isa(Mask.A,'uint8') |
---|
| 1340 | errormsg=[MaskName ' is not a 8 bit grey level image']; |
---|
| 1341 | return |
---|
| 1342 | end |
---|
[542] | 1343 | % Mask.AX=[0.5 npxy(2)-0.5]; |
---|
| 1344 | % Mask.AY=[npxy(1)-0.5 0.5 ]; |
---|
| 1345 | % Mask.CoordUnit='pixel'; |
---|
[387] | 1346 | if isequal(get(handles.slices,'Value'),1) |
---|
[497] | 1347 | NbSlice=str2num(get(handles.num_NbSlice,'String')); |
---|
[387] | 1348 | num_i1=str2num(get(handles.i1,'String')); |
---|
| 1349 | Mask.ZIndex=mod(num_i1-1,NbSlice)+1; |
---|
| 1350 | end |
---|
| 1351 | %px to phys or other transform on field |
---|
| 1352 | menu_transform=get(handles.transform_fct,'String'); |
---|
| 1353 | choice_value=get(handles.transform_fct,'Value'); |
---|
| 1354 | transform_name=menu_transform{choice_value};%name of the transform fct given by the menu 'transform_fct' |
---|
[541] | 1355 | % transform_list=get(handles.transform_fct,'UserData'); |
---|
| 1356 | % transform=transform_list{choice_value}; |
---|
| 1357 | transform=get(handles.path_transform,'UserData'); |
---|
[387] | 1358 | if ~isequal(transform_name,'') && ~isequal(transform_name,'px') |
---|
| 1359 | if isfield(UvData,'XmlData') && isfield(UvData.XmlData{1},'GeometryCalib')%use geometry calib recorded from the ImaDoc xml file as first priority |
---|
| 1360 | Calib=UvData.XmlData{1}.GeometryCalib; |
---|
| 1361 | Mask=transform(Mask,UvData.XmlData{1}); |
---|
| 1362 | end |
---|
| 1363 | end |
---|
| 1364 | flagmask=Mask.A < 200; |
---|
| 1365 | |
---|
| 1366 | %make brown color image |
---|
| 1367 | imflag(:,:,1)=0.9*flagmask; |
---|
| 1368 | imflag(:,:,2)=0.7*flagmask; |
---|
| 1369 | imflag(:,:,3)=zeros(size(flagmask)); |
---|
| 1370 | |
---|
| 1371 | %update mask image |
---|
| 1372 | hmask=[]; %default |
---|
| 1373 | if isfield(MaskData,'maskhandle')&& ishandle(MaskData.maskhandle) |
---|
| 1374 | hmask=MaskData.maskhandle; |
---|
| 1375 | end |
---|
| 1376 | if ~isempty(hmask) |
---|
| 1377 | set(hmask,'CData',imflag) |
---|
| 1378 | set(hmask,'AlphaData',flagmask*0.6) |
---|
| 1379 | set(hmask,'XData',Mask.AX); |
---|
| 1380 | set(hmask,'YData',Mask.AY); |
---|
| 1381 | % uistack(hmask,'top') |
---|
| 1382 | else |
---|
[511] | 1383 | axes(handles.PlotAxes) |
---|
[387] | 1384 | hold on |
---|
[452] | 1385 | size(flagmask) |
---|
| 1386 | % MaskData.maskhandle=image(Mask.AX,Mask.AY,imflag,'Tag','mask','HitTest','off','AlphaData',0.6*flagmask); |
---|
| 1387 | MaskData.maskhandle=image(Mask.AX,Mask.AY,imflag,'Tag','mask','HitTest','off','AlphaData',0.6*ones(size(flagmask))); |
---|
[387] | 1388 | % set(MaskData.maskhandle,'AlphaData',0.6*flagmask) |
---|
| 1389 | set(handles.CheckMask,'UserData',MaskData) |
---|
| 1390 | end |
---|
| 1391 | end |
---|
| 1392 | end |
---|
| 1393 | |
---|
| 1394 | %------------------------------------------------------------------------ |
---|
| 1395 | %------------------------------------------------------------------------ |
---|
| 1396 | % III - MAIN REFRESH FUNCTIONS : 'FRAME PLOT' |
---|
| 1397 | %------------------------------------------------------------------------ |
---|
| 1398 | |
---|
| 1399 | %------------------------------------------------------------------------ |
---|
| 1400 | % --- Executes on button press in runplus: make one step forward and call |
---|
[526] | 1401 | % --- run0. The step forward is along the fieldname series 1 or 2 depending on |
---|
[387] | 1402 | % --- the scan_i and scan_j check box (exclusive each other) |
---|
| 1403 | function runplus_Callback(hObject, eventdata, handles) |
---|
| 1404 | %------------------------------------------------------------------------ |
---|
| 1405 | set(handles.runplus,'BackgroundColor',[1 1 0])%paint the command button in yellow |
---|
| 1406 | drawnow |
---|
| 1407 | %TODO: introduce the option: increment ='*' to move to the next available view |
---|
[511] | 1408 | increment=str2num(get(handles.num_IndexIncrement,'String')); %get the field increment d |
---|
[387] | 1409 | % if isnan(increment) |
---|
[511] | 1410 | % set(handles.num_IndexIncrement,'String','1')%default value |
---|
[387] | 1411 | % increment=1; |
---|
| 1412 | % end |
---|
| 1413 | errormsg=runpm(hObject,eventdata,handles,increment); |
---|
| 1414 | if ~isempty(errormsg) |
---|
| 1415 | msgbox_uvmat('ERROR',errormsg); |
---|
| 1416 | end |
---|
| 1417 | set(handles.runplus,'BackgroundColor',[1 0 0])%paint the command button back to red |
---|
| 1418 | |
---|
| 1419 | %------------------------------------------------------------------------ |
---|
| 1420 | % --- Executes on button press in runmin: make one step backward and call |
---|
[526] | 1421 | % --- run0. The step backward is along the fieldname series 1 or 2 depending on |
---|
[387] | 1422 | % --- the scan_i and scan_j check box (exclusive each other) |
---|
| 1423 | function runmin_Callback(hObject, eventdata, handles) |
---|
| 1424 | %------------------------------------------------------------------------ |
---|
| 1425 | set(handles.runmin,'BackgroundColor',[1 1 0])%paint the command button in yellow |
---|
| 1426 | drawnow |
---|
[511] | 1427 | increment=-str2num(get(handles.num_IndexIncrement,'String')); %get the field increment d |
---|
[387] | 1428 | % if isnan(increment) |
---|
[511] | 1429 | % set(handles.num_IndexIncrement,'String','1')%default value |
---|
[387] | 1430 | % increment=1; |
---|
| 1431 | % end |
---|
| 1432 | errormsg=runpm(hObject,eventdata,handles,increment); |
---|
| 1433 | if ~isempty(errormsg) |
---|
| 1434 | msgbox_uvmat('ERROR',errormsg); |
---|
| 1435 | end |
---|
| 1436 | set(handles.runmin,'BackgroundColor',[1 0 0])%paint the command button back to red |
---|
| 1437 | |
---|
| 1438 | %------------------------------------------------------------------------ |
---|
| 1439 | % -- Executes on button press in Movie: make a series of +> steps |
---|
| 1440 | function Movie_Callback(hObject, eventdata, handles) |
---|
| 1441 | %------------------------------------------------------------------------ |
---|
| 1442 | set(handles.Movie,'BackgroundColor',[1 1 0])%paint the command button in yellow |
---|
| 1443 | drawnow |
---|
[511] | 1444 | increment=str2num(get(handles.num_IndexIncrement,'String')); %get the field increment d |
---|
[387] | 1445 | % if isnan(increment) |
---|
[511] | 1446 | % set(handles.num_IndexIncrement,'String','1')%default value |
---|
[387] | 1447 | % increment=1; |
---|
| 1448 | % end |
---|
| 1449 | set(handles.STOP,'Visible','on') |
---|
| 1450 | set(handles.speed,'Visible','on') |
---|
| 1451 | set(handles.speed_txt,'Visible','on') |
---|
| 1452 | set(handles.Movie,'BusyAction','queue') |
---|
| 1453 | UvData=get(handles.uvmat,'UserData'); |
---|
| 1454 | |
---|
[435] | 1455 | while get(handles.Movie,'Value')==1 && get(handles.speed,'Value')~=0 && isequal(get(handles.Movie,'BusyAction'),'queue') % enable STOP command |
---|
[387] | 1456 | errormsg=runpm(hObject,eventdata,handles,increment); |
---|
| 1457 | if ~isempty(errormsg) |
---|
| 1458 | set(handles.Movie,'BackgroundColor',[1 0 0])%paint the command buttonback to red |
---|
| 1459 | return |
---|
| 1460 | end |
---|
| 1461 | pause(1.02-get(handles.speed,'Value'))% wait for next image |
---|
| 1462 | end |
---|
| 1463 | if isfield(UvData,'aviobj') && ~isempty( UvData.aviobj), |
---|
| 1464 | UvData.aviobj=close(UvData.aviobj); |
---|
| 1465 | set(handles.uvmat,'UserData',UvData); |
---|
| 1466 | end |
---|
| 1467 | set(handles.Movie,'BackgroundColor',[1 0 0])%paint the command buttonback to red |
---|
| 1468 | |
---|
| 1469 | %------------------------------------------------------------------------ |
---|
| 1470 | % -- Executes on button press in Movie: make a series of <- steps |
---|
| 1471 | function MovieBackward_Callback(hObject, eventdata, handles) |
---|
| 1472 | %------------------------------------------------------------------------ |
---|
| 1473 | set(handles.MovieBackward,'BackgroundColor',[1 1 0])%paint the command button in yellow |
---|
| 1474 | drawnow |
---|
[511] | 1475 | increment=-str2num(get(handles.num_IndexIncrement,'String')); %get the field increment d |
---|
[387] | 1476 | set(handles.STOP,'Visible','on') |
---|
| 1477 | set(handles.speed,'Visible','on') |
---|
| 1478 | set(handles.speed_txt,'Visible','on') |
---|
| 1479 | set(handles.MovieBackward,'BusyAction','queue') |
---|
| 1480 | UvData=get(handles.uvmat,'UserData'); |
---|
| 1481 | |
---|
[435] | 1482 | while get(handles.MovieBackward,'Value')==1 && get(handles.speed,'Value')~=0 && isequal(get(handles.MovieBackward,'BusyAction'),'queue') % enable STOP command |
---|
[387] | 1483 | errormsg=runpm(hObject,eventdata,handles,increment); |
---|
| 1484 | if ~isempty(errormsg) |
---|
| 1485 | set(handles.MovieBackward,'BackgroundColor',[1 0 0])%paint the command buttonback to red |
---|
| 1486 | return |
---|
| 1487 | end |
---|
| 1488 | pause(1.02-get(handles.speed,'Value'))% wait for next image |
---|
| 1489 | end |
---|
| 1490 | if isfield(UvData,'aviobj') && ~isempty( UvData.aviobj), |
---|
| 1491 | UvData.aviobj=close(UvData.aviobj); |
---|
| 1492 | set(handles.uvmat,'UserData',UvData); |
---|
| 1493 | end |
---|
| 1494 | set(handles.MovieBackward,'BackgroundColor',[1 0 0])%paint the command buttonback to red |
---|
| 1495 | |
---|
| 1496 | %------------------------------------------------------------------------ |
---|
| 1497 | function STOP_Callback(hObject, eventdata, handles) |
---|
| 1498 | %------------------------------------------------------------------------ |
---|
| 1499 | set(handles.movie_pair,'BusyAction','Cancel') |
---|
| 1500 | set(handles.movie_pair,'value',0) |
---|
| 1501 | set(handles.Movie,'BusyAction','Cancel') |
---|
| 1502 | set(handles.MovieBackward,'BusyAction','Cancel') |
---|
| 1503 | set(handles.MenuExportMovie,'BusyAction','Cancel') |
---|
| 1504 | set(handles.movie_pair,'BackgroundColor',[1 0 0])%paint the command buttonback to red |
---|
| 1505 | set(handles.Movie,'BackgroundColor',[1 0 0])%paint the command buttonback to red |
---|
| 1506 | set(handles.MovieBackward,'BackgroundColor',[1 0 0])%paint the command buttonback to red |
---|
| 1507 | |
---|
| 1508 | %------------------------------------------------------------------------ |
---|
| 1509 | % --- function activated by runplus and run minus |
---|
| 1510 | function errormsg=runpm(hObject,eventdata,handles,increment) |
---|
| 1511 | %------------------------------------------------------------------------ |
---|
| 1512 | errormsg='';%default |
---|
| 1513 | %% check for movie pair status |
---|
| 1514 | movie_status=get(handles.movie_pair,'Value'); |
---|
| 1515 | if isequal(movie_status,1) |
---|
| 1516 | STOP_Callback(hObject, eventdata, handles)%interrupt movie pair if active |
---|
| 1517 | end |
---|
| 1518 | |
---|
| 1519 | %% read the current input file name(s) and field indices |
---|
| 1520 | InputFile=read_GUI(handles.InputFile); |
---|
| 1521 | InputFile.RootFile=regexprep(InputFile.RootFile,'^[\\/]|[\\/]$','');%suppress possible / or \ separator at the beginning or the end of the string |
---|
| 1522 | InputFile.SubDir=regexprep(InputFile.SubDir,'^[\\/]|[\\/]$','');%suppress possible / or \ separator at the beginning or the end of the string |
---|
| 1523 | FileExt=InputFile.FileExt; |
---|
| 1524 | NomType=get(handles.NomType,'String'); |
---|
| 1525 | i1=str2num(get(handles.i1,'String'));%read the field indices (for movie, it is not given by the file name) |
---|
| 1526 | i2=[];%default |
---|
| 1527 | if strcmp(get(handles.i2,'Visible'),'on') |
---|
| 1528 | i2=str2num(get(handles.i2,'String')); |
---|
| 1529 | end |
---|
| 1530 | j1=[]; |
---|
| 1531 | if strcmp(get(handles.j1,'Visible'),'on') |
---|
| 1532 | j1=stra2num(get(handles.j1,'String')); |
---|
| 1533 | end |
---|
| 1534 | j2=j1; |
---|
| 1535 | if strcmp(get(handles.j2,'Visible'),'on') |
---|
| 1536 | j2=stra2num(get(handles.j2,'String')); |
---|
| 1537 | end |
---|
| 1538 | sub_value= get(handles.SubField,'Value'); |
---|
| 1539 | if sub_value % a second input file has been entered |
---|
[428] | 1540 | [InputFile.RootPath_1,InputFile.SubDir_1,InputFile.RootFile_1,InputFile.FileIndex_1,InputFile.FileExt_1,InputFile.NomType_1]=read_file_boxes_1(handles); |
---|
[515] | 1541 | [tild,tild,tild,i1_1,i2_1,j1_1,j2_1]=fileparts_uvmat(InputFile.FileIndex_1);% the indices for the second series taken from FileIndex_1 |
---|
[387] | 1542 | else |
---|
| 1543 | filename_1=[]; |
---|
| 1544 | end |
---|
| 1545 | |
---|
| 1546 | %% increment (or decrement) the field indices and update the input filename(s) |
---|
| 1547 | if isempty(increment) |
---|
| 1548 | set(handles.CheckFixPair,'Value',0) |
---|
| 1549 | end |
---|
| 1550 | CheckFixPair=get(handles.CheckFixPair,'Value')||(isempty(i2)&&isempty(j2)); |
---|
[427] | 1551 | |
---|
| 1552 | % the pair i1-i2 or j1-j2 is imposed (check box CheckFixPair selected) |
---|
[540] | 1553 | i1_1=i1; |
---|
| 1554 | i2_1=i2; |
---|
| 1555 | j1_1=j1; |
---|
| 1556 | j2_1=j2; |
---|
[387] | 1557 | if CheckFixPair |
---|
| 1558 | if get(handles.scan_i,'Value')==1% case of scanning along index i |
---|
| 1559 | i1=i1+increment; |
---|
| 1560 | i2=i2+increment; |
---|
| 1561 | if sub_value |
---|
| 1562 | i1_1=i1_1+increment; |
---|
| 1563 | i2_1=i2_1+increment; |
---|
| 1564 | end |
---|
[515] | 1565 | |
---|
[387] | 1566 | else % case of scanning along index j (burst numbers) |
---|
| 1567 | j1=j1+increment; |
---|
| 1568 | j2=j2+increment; |
---|
| 1569 | if sub_value |
---|
| 1570 | j1_1=j1_1+increment; |
---|
| 1571 | j2_1=j2_1+increment; |
---|
| 1572 | end |
---|
| 1573 | end |
---|
[427] | 1574 | |
---|
[511] | 1575 | % the pair i1-i2 or j1-j2 is free (check box CheckFixPair not selected): the list of existing indices recorded in UvData is used |
---|
[387] | 1576 | else |
---|
| 1577 | UvData=get(handles.uvmat,'UserData'); |
---|
| 1578 | ref_i=i1; |
---|
| 1579 | if ~isempty(i2) |
---|
[427] | 1580 | ref_i=floor((i1+i2)/2);% current reference index i |
---|
[387] | 1581 | end |
---|
| 1582 | ref_j=1; |
---|
| 1583 | if ~isempty(j1) |
---|
| 1584 | ref_j=j1; |
---|
| 1585 | if ~isempty(j2) |
---|
[427] | 1586 | ref_j=floor((j1+j2)/2);% current reference index j |
---|
[387] | 1587 | end |
---|
| 1588 | end |
---|
| 1589 | if ~isempty(increment) |
---|
| 1590 | if get(handles.scan_i,'Value')==1% case of scanning along index i |
---|
[427] | 1591 | ref_i=ref_i+increment;% increment the current reference index i |
---|
[387] | 1592 | else % case of scanning along index j (burst numbers) |
---|
[427] | 1593 | ref_j=ref_j+increment;% increment the current reference index j if scan_j option is used |
---|
[387] | 1594 | end |
---|
[388] | 1595 | else % free increment |
---|
[511] | 1596 | runaction=get(gcbo,'tag'); |
---|
| 1597 | if strcmp(runaction,'runplus')||strcmp(runaction,'Movie')% if runplus or movie is activated |
---|
[387] | 1598 | step=1; |
---|
| 1599 | else |
---|
| 1600 | step=-1; |
---|
| 1601 | end |
---|
| 1602 | if get(handles.scan_i,'Value')==1% case of scanning along index i |
---|
| 1603 | ref_i=ref_i+step; |
---|
[512] | 1604 | while ref_i>=0 && size(UvData.i1_series{1},3)>=ref_i+1 && UvData.i1_series{1}(1,ref_j+1,ref_i+1)==0 |
---|
[387] | 1605 | ref_i=ref_i+step; |
---|
| 1606 | end |
---|
| 1607 | else % case of scanning along index j (burst numbers) |
---|
| 1608 | ref_j=ref_j+step; |
---|
[512] | 1609 | while ref_j>=0 && size(UvData.i1_series{1},2)>=ref_j+1 && UvData.i1_series{1}(1,ref_j+1,ref_i+1)==0 |
---|
[387] | 1610 | ref_j=ref_j+step; |
---|
| 1611 | end |
---|
| 1612 | end |
---|
| 1613 | end |
---|
| 1614 | if ref_i<0 |
---|
| 1615 | errormsg='minimum i index reached'; |
---|
| 1616 | elseif ref_j<0 |
---|
| 1617 | errormsg='minimum j index reached'; |
---|
[512] | 1618 | elseif ref_i+1>size(UvData.i1_series{1},3) |
---|
[511] | 1619 | errormsg='maximum i index reached (reload the input file to update the index bound)'; |
---|
[387] | 1620 | elseif ref_j+1>size(UvData.i1_series{1},2) |
---|
[511] | 1621 | errormsg='maximum j index reached (reload the input file to update the index bound)'; |
---|
[387] | 1622 | end |
---|
[511] | 1623 | if ~isempty(errormsg),return,end |
---|
[512] | 1624 | siz=size(UvData.i1_series{1}); |
---|
[515] | 1625 | ref_indices=ref_i*siz(1)*siz(2)+ref_j*siz(1)+1:ref_i*siz(1)*siz(2)+(ref_j+1)*siz(1); |
---|
[512] | 1626 | i1_subseries=UvData.i1_series{1}(ref_indices); |
---|
| 1627 | ref_indices=ref_indices(i1_subseries>0); |
---|
| 1628 | if isempty(ref_indices)% case of pairs (free index i) |
---|
[515] | 1629 | ref_indices=ref_i*siz(1)*siz(2)+1:(ref_i+1)*siz(1)*siz(2); |
---|
[512] | 1630 | i1_subseries=UvData.i1_series{1}(ref_indices); |
---|
| 1631 | ref_indices=ref_indices(i1_subseries>0); |
---|
[511] | 1632 | end |
---|
[512] | 1633 | if isempty(ref_indices),errormsg='no next frame: set num_IndexIncrement =''*'' to reach the next existing file';return |
---|
[387] | 1634 | end |
---|
[512] | 1635 | i1=UvData.i1_series{1}(ref_indices(end)); |
---|
[387] | 1636 | if ~isempty(UvData.i2_series{1}) |
---|
[512] | 1637 | i2=UvData.i2_series{1}(ref_indices(end)); |
---|
[387] | 1638 | end |
---|
| 1639 | if ~isempty(UvData.j1_series{1}) |
---|
[512] | 1640 | j1=UvData.j1_series{1}(ref_indices(end)); |
---|
[387] | 1641 | end |
---|
| 1642 | if ~isempty(UvData.j2_series{1}) |
---|
[512] | 1643 | j2=UvData.j2_series{1}(ref_indices(end)); |
---|
[515] | 1644 | end |
---|
| 1645 | |
---|
| 1646 | % case of a second file series |
---|
| 1647 | if sub_value |
---|
| 1648 | ref_i_1=i1_1; |
---|
| 1649 | if ~isempty(i2_1) |
---|
| 1650 | ref_i_1=floor((i1_1+i2_1)/2);% current reference index i |
---|
| 1651 | end |
---|
| 1652 | ref_j_1=1; |
---|
| 1653 | if ~isempty(j1_1) |
---|
| 1654 | ref_j_1=j1_1; |
---|
| 1655 | if ~isempty(j2_1) |
---|
| 1656 | ref_j_1=floor((j1_1+j2_1)/2);% current reference index j |
---|
| 1657 | end |
---|
| 1658 | end |
---|
| 1659 | if ~isempty(increment) |
---|
| 1660 | if get(handles.scan_i,'Value')==1% case of scanning along index i |
---|
| 1661 | ref_i_1=ref_i_1+increment;% increment the current reference index i |
---|
| 1662 | else % case of scanning along index j (burst numbers) |
---|
| 1663 | ref_j_1=ref_j_1+increment;% increment the current reference index j if scan_j option is used |
---|
| 1664 | end |
---|
| 1665 | else % free increment, synchronise the ref indices with the first series |
---|
| 1666 | ref_i_1=ref_i; |
---|
| 1667 | ref_j_1=ref_j; |
---|
| 1668 | end |
---|
| 1669 | if numel(UvData.i1_series)==1 |
---|
| 1670 | UvData.i1_series{2}=UvData.i1_series{1}; |
---|
| 1671 | UvData.j1_series{2}=UvData.j1_series{1}; |
---|
| 1672 | UvData.i2_series{2}=UvData.i2_series{1}; |
---|
| 1673 | UvData.j2_series{2}=UvData.j2_series{1}; |
---|
| 1674 | end |
---|
| 1675 | if ref_i_1<0 |
---|
| 1676 | errormsg='minimum i index reached'; |
---|
| 1677 | elseif ref_j_1<0 |
---|
| 1678 | errormsg='minimum j index reached'; |
---|
| 1679 | elseif ref_i_1+1>size(UvData.i1_series{2},3) |
---|
| 1680 | errormsg='maximum i index reached for the second series (reload the input file to update the index bound)'; |
---|
| 1681 | elseif ref_j_1+1>size(UvData.i1_series{2},2) |
---|
| 1682 | errormsg='maximum j index reached for the second series(reload the input file to update the index bound)'; |
---|
| 1683 | end |
---|
| 1684 | if ~isempty(errormsg),return,end |
---|
| 1685 | siz=size(UvData.i1_series{2}); |
---|
| 1686 | ref_indices=ref_i_1*siz(1)*siz(2)+ref_j_1*siz(1)+1:ref_i_1*siz(1)*siz(2)+(ref_j_1+1)*siz(1); |
---|
| 1687 | i1_subseries=UvData.i1_series{2}(ref_indices); |
---|
| 1688 | ref_indices=ref_indices(i1_subseries>0); |
---|
| 1689 | if isempty(ref_indices)% case of pairs (free index i) |
---|
| 1690 | ref_indices=ref_i_1*siz(1)*siz(2)+1:(ref_i_1+1)*siz(1)*siz(2); |
---|
| 1691 | i1_subseries=UvData.i1_series{2}(ref_indices); |
---|
| 1692 | ref_indices=ref_indices(i1_subseries>0); |
---|
| 1693 | end |
---|
| 1694 | i1_1=UvData.i1_series{2}(ref_indices(end)); |
---|
[427] | 1695 | if ~isempty(UvData.i2_series{2}) |
---|
[515] | 1696 | i2_1=UvData.i2_series{2}(ref_indices(end)); |
---|
[427] | 1697 | end |
---|
| 1698 | if ~isempty(UvData.j1_series{2}) |
---|
[515] | 1699 | j1_1=UvData.j1_series{2}(ref_indices(end)); |
---|
[427] | 1700 | end |
---|
| 1701 | if ~isempty(UvData.j2_series{2}) |
---|
[515] | 1702 | j2_1=UvData.j2_series{1}(ref_indices(end)); |
---|
| 1703 | end |
---|
| 1704 | else% the second series (if needed) is the same file as the first |
---|
| 1705 | i1_1=i1; |
---|
| 1706 | i2_1=i2; |
---|
| 1707 | j1_1=j1; |
---|
| 1708 | j2_1=j2; |
---|
[387] | 1709 | end |
---|
| 1710 | end |
---|
| 1711 | filename=fullfile_uvmat(InputFile.RootPath,InputFile.SubDir,InputFile.RootFile,FileExt,NomType,i1,i2,j1,j2); |
---|
| 1712 | if sub_value |
---|
[428] | 1713 | filename_1=fullfile_uvmat(InputFile.RootPath_1,InputFile.SubDir_1,InputFile.RootFile_1,InputFile.FileExt_1,InputFile.NomType_1,i1_1,i2_1,j1_1,j2_1); |
---|
[387] | 1714 | end |
---|
| 1715 | |
---|
| 1716 | %% refresh plots |
---|
[515] | 1717 | errormsg=refresh_field(handles,filename,filename_1,i1,i2,j1,j2,i1_1,i2_1,j1_1,j2_1); |
---|
[387] | 1718 | |
---|
| 1719 | %% update the index counters if the index move is successfull |
---|
| 1720 | if isempty(errormsg) |
---|
| 1721 | set(handles.i1,'String',num2stra(i1,NomType,1)); |
---|
| 1722 | if isequal(i2,i1) |
---|
| 1723 | set(handles.i2,'String',''); |
---|
| 1724 | else |
---|
| 1725 | set(handles.i2,'String',num2stra(i2,NomType,1)); |
---|
| 1726 | end |
---|
| 1727 | set(handles.j1,'String',num2stra(j1,NomType,2)); |
---|
| 1728 | if isequal(j2,j1) |
---|
| 1729 | set(handles.j2,'String',''); |
---|
| 1730 | else |
---|
| 1731 | set(handles.j2,'String',num2stra(j2,NomType,2)); |
---|
| 1732 | end |
---|
| 1733 | indices=fullfile_uvmat('','','','',NomType,i1,i2,j1,j2); |
---|
| 1734 | set(handles.FileIndex,'String',indices); |
---|
| 1735 | if ~isempty(filename_1) |
---|
[428] | 1736 | indices_1=fullfile_uvmat('','','','',InputFile.NomType_1,i1_1,i2_1,j1_1,j2_1); |
---|
[387] | 1737 | set(handles.FileIndex_1,'String',indices_1); |
---|
| 1738 | end |
---|
| 1739 | if isequal(movie_status,1) |
---|
| 1740 | set(handles.movie_pair,'Value',1) |
---|
| 1741 | movie_pair_Callback(hObject, eventdata, handles); %reactivate moviepair if it was activated |
---|
| 1742 | end |
---|
| 1743 | end |
---|
| 1744 | |
---|
| 1745 | %------------------------------------------------------------------------ |
---|
| 1746 | % --- Executes on button press in movie_pair: create an alternating movie with two view |
---|
| 1747 | function movie_pair_Callback(hObject, eventdata, handles) |
---|
| 1748 | %------------------------------------------------------------------------ |
---|
| 1749 | %% stop movie action if the movie_pair button is off |
---|
| 1750 | if ~get(handles.movie_pair,'value') |
---|
| 1751 | set(handles.movie_pair,'BusyAction','Cancel')%stop movie pair if button is 'off' |
---|
| 1752 | set(handles.i2,'String','') |
---|
| 1753 | set(handles.j2,'String','') |
---|
| 1754 | return |
---|
| 1755 | else |
---|
| 1756 | set(handles.movie_pair,'BusyAction','queue') |
---|
| 1757 | end |
---|
| 1758 | |
---|
| 1759 | %% initialisation |
---|
| 1760 | set(handles.movie_pair,'BackgroundColor',[1 1 0])%paint the command button in yellow |
---|
| 1761 | drawnow |
---|
[526] | 1762 | list_fields=get(handles.FieldName,'String');% list menu fields |
---|
| 1763 | index_fields=get(handles.FieldName,'Value');% selected string index |
---|
[387] | 1764 | FieldName=list_fields{index_fields}; % selected field |
---|
| 1765 | UvData=get(handles.uvmat,'UserData'); |
---|
| 1766 | if isequal(FieldName,'image') |
---|
[512] | 1767 | index=1; |
---|
[387] | 1768 | [RootPath,SubDir,RootFile,FileIndices,Ext]=read_file_boxes(handles); |
---|
| 1769 | NomType=get(handles.NomType,'String'); |
---|
| 1770 | else |
---|
[526] | 1771 | list_fields=get(handles.FieldName_1,'String');% list menu fields |
---|
| 1772 | index_fields=get(handles.FieldName_1,'Value');% selected string index |
---|
[387] | 1773 | FieldName=list_fields{index_fields}; % selected field |
---|
| 1774 | if isequal(FieldName,'image') |
---|
[512] | 1775 | index=2; |
---|
[387] | 1776 | [RootPath,tild,RootFile,FileIndex_1,Ext,NomType]=read_file_boxes_1(handles); |
---|
| 1777 | else |
---|
| 1778 | msgbox_uvmat('ERROR','an image or movie must be first introduced as input') |
---|
| 1779 | set(handles.movie_pair,'BackgroundColor',[1 0 0])%paint the command button in red |
---|
| 1780 | set(handles.movie_pair,'Value',0) |
---|
| 1781 | return |
---|
| 1782 | end |
---|
| 1783 | end |
---|
| 1784 | num_i1=str2num(get(handles.i1,'String')); |
---|
| 1785 | num_j1=stra2num(get(handles.j1,'String')); |
---|
| 1786 | num_i2=str2num(get(handles.i2,'String')); |
---|
| 1787 | num_j2=stra2num(get(handles.j2,'String')); |
---|
| 1788 | if isempty(num_j2) |
---|
| 1789 | if isempty(num_i2) |
---|
| 1790 | msgbox_uvmat('ERROR', 'a second image index i2 or j2 is needed to show the pair as a movie') |
---|
| 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 | else |
---|
| 1795 | num_j2=num_j1;%repeat the index i1 by default |
---|
| 1796 | end |
---|
| 1797 | end |
---|
| 1798 | if isempty(num_i2) |
---|
| 1799 | num_i2=num_i1;%repeat the index i1 by default |
---|
| 1800 | end |
---|
[439] | 1801 | imaname_1=fullfile_uvmat(RootPath,SubDir,RootFile,Ext,NomType,num_i2,[],num_j2); |
---|
[512] | 1802 | if strcmp(NomType,'*') |
---|
| 1803 | num_frame=num_i2; |
---|
| 1804 | else |
---|
| 1805 | num_frame=num_j2; |
---|
| 1806 | end |
---|
[387] | 1807 | if ~exist(imaname_1,'file') |
---|
| 1808 | msgbox_uvmat('ERROR',['second input open (-) ' imaname_1 ' not found']); |
---|
| 1809 | set(handles.movie_pair,'BackgroundColor',[1 0 0])%paint the command button in red |
---|
| 1810 | set(handles.movie_pair,'Value',0) |
---|
| 1811 | return |
---|
| 1812 | end |
---|
| 1813 | |
---|
[512] | 1814 | %% get the first image |
---|
| 1815 | %Field.AName='image'; |
---|
| 1816 | if index==1 |
---|
| 1817 | Field_a=UvData.Field;% movie on the second field |
---|
[387] | 1818 | else |
---|
[512] | 1819 | Field_a=UvData.Field_1;% movie on the first field |
---|
[387] | 1820 | end |
---|
| 1821 | |
---|
[512] | 1822 | %% read the second image |
---|
| 1823 | MovieObject=[]; |
---|
| 1824 | if numel(UvData.MovieObject)>=index |
---|
| 1825 | MovieObject=UvData.MovieObject{index}; |
---|
[387] | 1826 | end |
---|
[512] | 1827 | [Field_b,ParamOut,errormsg] = read_field(imaname_1,UvData.FileType{index},MovieObject,num_frame) |
---|
| 1828 | % Field_b.AX=Field_a.AX; |
---|
| 1829 | % Field_b.AY=Field_a.AY; |
---|
| 1830 | % % z index |
---|
| 1831 | % nbslice=str2double(get(handles.num_NbSlice,'String')); |
---|
| 1832 | % if ~isempty(nbslice) |
---|
| 1833 | % Field_b.ZIndex=mod(num_i2-1,nbslice)+1; |
---|
| 1834 | % end |
---|
| 1835 | % Field_b.CoordUnit='pixel'; |
---|
| 1836 | % |
---|
| 1837 | % %% determine the input file type |
---|
| 1838 | % if (test_1 && isfield(UvData,'MovieObject')&& numel(UvData.MovieObject>=2))||(~test_1 && ~isempty(UvData.MovieObject{1})) |
---|
| 1839 | % FileType='movie'; |
---|
| 1840 | % elseif isequal(lower(Ext),'.avi') |
---|
| 1841 | % FileType='avi'; |
---|
| 1842 | % elseif isequal(lower(Ext),'.vol') |
---|
| 1843 | % FileType='vol'; |
---|
| 1844 | % else |
---|
| 1845 | % form=imformats(Ext(2:end)); |
---|
| 1846 | % if ~isempty(form)% if the extension corresponds to an image format recognized by Matlab |
---|
| 1847 | % if isequal(NomType,'*'); |
---|
| 1848 | % FileType='multimage'; |
---|
| 1849 | % else |
---|
| 1850 | % FileType='image'; |
---|
| 1851 | % end |
---|
| 1852 | % end |
---|
| 1853 | % end |
---|
| 1854 | % switch FileType |
---|
| 1855 | % case 'movie' |
---|
| 1856 | % if test_1 |
---|
| 1857 | % Field_b.A=read(UvData.MovieObject{2},num_i2); |
---|
| 1858 | % else |
---|
| 1859 | % Field_b.A=read(UvData.MovieObject{1},num_i2); |
---|
| 1860 | % end |
---|
| 1861 | % case 'avi' |
---|
| 1862 | % mov=aviread(imaname_1,num_i2); |
---|
| 1863 | % Field_b.A=frame2im(mov(1)); |
---|
| 1864 | % case 'vol' |
---|
| 1865 | % Field_b.A=imread(imaname_1); |
---|
| 1866 | % case 'multimage' |
---|
| 1867 | % Field_b.A=imread(imaname_1,num_i2); |
---|
| 1868 | % case 'image' |
---|
| 1869 | % Field_b.A=imread(imaname_1); |
---|
| 1870 | % end |
---|
| 1871 | % if get(handles.slices,'Value') |
---|
| 1872 | % Field.ZIndex=str2double(get(handles.z_index,'String')); |
---|
| 1873 | % end |
---|
[387] | 1874 | |
---|
| 1875 | %px to phys or other transform on field |
---|
[512] | 1876 | % menu_transform=get(handles.transform_fct,'String'); |
---|
| 1877 | % choice_value=get(handles.transform_fct,'Value'); |
---|
| 1878 | % transform_name=menu_transform{choice_value};%name of the transform fct given by the menu 'transform_fct' |
---|
| 1879 | % transform_list=get(handles.transform_fct,'UserData'); |
---|
| 1880 | transform=get(handles.path_transform,'UserData'); |
---|
| 1881 | if ~isempty(transform) |
---|
| 1882 | if isfield(UvData,'XmlData') && numel(UvData.XmlData)>=index %use geometry calib recorded from the ImaDoc xml file as first priority |
---|
| 1883 | if index==2 |
---|
| 1884 | Field_a=transform(Field_a,UvData.XmlData{index});%the first field has been stored without transform |
---|
| 1885 | end |
---|
| 1886 | Field_b=transform(Field_b,UvData.XmlData{index}); |
---|
[387] | 1887 | end |
---|
| 1888 | end |
---|
| 1889 | |
---|
| 1890 | % make movie until movie speed is set to 0 or STOP is activated |
---|
[511] | 1891 | hima=findobj(handles.PlotAxes,'Tag','ima');% %handles.PlotAxes =main plotting window (A GENERALISER) |
---|
[387] | 1892 | set(handles.STOP,'Visible','on') |
---|
| 1893 | set(handles.speed,'Visible','on') |
---|
| 1894 | set(handles.speed_txt,'Visible','on') |
---|
| 1895 | while get(handles.speed,'Value')~=0 && isequal(get(handles.movie_pair,'BusyAction'),'queue')%isequal(get(handles.run0,'BusyAction'),'queue'); % enable STOP command |
---|
| 1896 | % read and plot the series of images in non erase mode |
---|
| 1897 | set(hima,'CData',Field_b.A); |
---|
| 1898 | pause(1.02-get(handles.speed,'Value'));% wait for next image |
---|
| 1899 | set(hima,'CData',Field_a.A); |
---|
| 1900 | pause(1.02-get(handles.speed,'Value'));% wait for next image |
---|
| 1901 | end |
---|
| 1902 | set(handles.movie_pair,'BackgroundColor',[1 0 0])%paint the command button in red |
---|
| 1903 | set(handles.movie_pair,'Value',0) |
---|
| 1904 | |
---|
| 1905 | %------------------------------------------------------------------------ |
---|
| 1906 | % --- Executes on button press in run0. |
---|
| 1907 | function run0_Callback(hObject, eventdata, handles) |
---|
| 1908 | %------------------------------------------------------------------------ |
---|
| 1909 | set(handles.run0,'BackgroundColor',[1 1 0])%paint the command button in yellow |
---|
| 1910 | drawnow |
---|
[515] | 1911 | [RootPath,SubDir,RootFile,FileIndex,FileExt]=read_file_boxes(handles); |
---|
| 1912 | filename=[fullfile(RootPath,SubDir,RootFile) FileIndex FileExt]; |
---|
| 1913 | filename_1='';%default |
---|
| 1914 | FileIndex_1=''; |
---|
[387] | 1915 | if get(handles.SubField,'Value') |
---|
[515] | 1916 | [RootPath_1,SubDir_1,RootFile_1,FileIndex_1,FileExt_1]=read_file_boxes_1(handles); |
---|
| 1917 | filename_1=[fullfile(RootPath_1,SubDir_1,RootFile_1) FileIndex_1 FileExt_1]; |
---|
[387] | 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')); |
---|
[515] | 1923 | [tild,tild,tild,i1_1,i2_1,j1_1,j2_1]=fileparts_uvmat(FileIndex_1); |
---|
[387] | 1924 | |
---|
[515] | 1925 | errormsg=refresh_field(handles,filename,filename_1,num_i1,num_i2,num_j1,num_j2,i1_1,i2_1,j1_1,j2_1); |
---|
[387] | 1926 | |
---|
| 1927 | if ~isempty(errormsg) |
---|
| 1928 | msgbox_uvmat('ERROR',errormsg); |
---|
| 1929 | else |
---|
| 1930 | set(handles.i1,'BackgroundColor',[1 1 1]) |
---|
| 1931 | set(handles.i2,'BackgroundColor',[1 1 1]) |
---|
| 1932 | set(handles.j1,'BackgroundColor',[1 1 1]) |
---|
| 1933 | set(handles.j2,'BackgroundColor',[1 1 1]) |
---|
| 1934 | set(handles.FileIndex,'BackgroundColor',[1 1 1]) |
---|
| 1935 | set(handles.FileIndex_1,'BackgroundColor',[1 1 1]) |
---|
| 1936 | end |
---|
| 1937 | set(handles.run0,'BackgroundColor',[1 0 0]) |
---|
| 1938 | |
---|
| 1939 | |
---|
| 1940 | %------------------------------------------------------------------------ |
---|
| 1941 | % --- read the input files and refresh all the plots, including projection. |
---|
| 1942 | % OUTPUT: |
---|
| 1943 | % errormsg: error message char string =[] by default |
---|
| 1944 | % INPUT: |
---|
| 1945 | % filename: first input file (=[] in the absence of input file) |
---|
| 1946 | % filename_1: second input file (=[] in the asbsenc of secodn input file) |
---|
| 1947 | % num_i1,num_i2,num_j1,num_j2; frame indices |
---|
| 1948 | % Field: structure describing an optional input field (then replace the input file) |
---|
[397] | 1949 | |
---|
[515] | 1950 | function errormsg=refresh_field(handles,FileName,FileName_1,num_i1,num_i2,num_j1,num_j2,i1_1,i2_1,j1_1,j2_1) |
---|
[387] | 1951 | %------------------------------------------------------------------------ |
---|
| 1952 | |
---|
| 1953 | %% initialisation |
---|
| 1954 | abstime=[]; |
---|
| 1955 | abstime_1=[]; |
---|
| 1956 | dt=[]; |
---|
| 1957 | if ~exist('Field','var') |
---|
| 1958 | Field={}; |
---|
| 1959 | end |
---|
| 1960 | UvData=get(handles.uvmat,'UserData'); |
---|
| 1961 | if ishandle(handles.UVMAT_title) %remove title panel on uvmat |
---|
| 1962 | delete(handles.UVMAT_title) |
---|
| 1963 | end |
---|
| 1964 | |
---|
| 1965 | %% determine the main input file information for action |
---|
[450] | 1966 | if ~exist(FileName,'file') |
---|
| 1967 | errormsg=['input file ' FileName ' does not exist']; |
---|
[387] | 1968 | return |
---|
| 1969 | end |
---|
| 1970 | NomType=get(handles.NomType,'String'); |
---|
[494] | 1971 | NomType_1=''; |
---|
| 1972 | if strcmp(get(handles.NomType_1,'Visible'),'on') |
---|
| 1973 | NomType_1=get(handles.NomType_1,'String'); |
---|
| 1974 | end |
---|
[387] | 1975 | %update the z position index |
---|
[497] | 1976 | nbslice_str=get(handles.num_NbSlice,'String'); |
---|
[387] | 1977 | if isequal(nbslice_str,'volume')%NOT USED |
---|
| 1978 | z_index=num_j1; |
---|
| 1979 | set(handles.z_index,'String',num2str(z_index)) |
---|
| 1980 | else |
---|
| 1981 | nbslice=str2num(nbslice_str); |
---|
| 1982 | z_index=mod(num_i1-1,nbslice)+1; |
---|
| 1983 | set(handles.z_index,'String',num2str(z_index)) |
---|
| 1984 | end |
---|
| 1985 | % refresh menu for save_mask if relevant |
---|
| 1986 | masknumber=get(handles.masklevel,'String'); |
---|
| 1987 | if length(masknumber)>=z_index |
---|
| 1988 | set(handles.masklevel,'Value',z_index) |
---|
| 1989 | end |
---|
| 1990 | |
---|
[515] | 1991 | %% test for need of tps |
---|
| 1992 | check_proj_tps=0; |
---|
| 1993 | if (strcmp(UvData.FileType{1},'civdata')||strcmp(UvData.FileType{1},'civx')) |
---|
| 1994 | for iobj=1:numel(UvData.Object) |
---|
| 1995 | if isfield(UvData.Object{iobj},'ProjMode')&& strcmp(UvData.Object{iobj}.ProjMode,'filter') |
---|
| 1996 | check_proj_tps=1; |
---|
| 1997 | break |
---|
| 1998 | end |
---|
| 1999 | end |
---|
| 2000 | end |
---|
| 2001 | |
---|
[507] | 2002 | %% read the first input field |
---|
[421] | 2003 | ParamIn.ColorVar='';%default variable name for vector color |
---|
[445] | 2004 | frame_index=1;%default |
---|
[507] | 2005 | FieldName='';%default |
---|
| 2006 | VelType='';%default |
---|
| 2007 | switch UvData.FileType{1} |
---|
| 2008 | case {'civx','civdata','netcdf'}; |
---|
[526] | 2009 | list_fields=get(handles.FieldName,'String');% list menu fields |
---|
| 2010 | FieldName= list_fields{get(handles.FieldName,'Value')}; % selected field |
---|
[507] | 2011 | if ~strcmp(FieldName,'get_field...') |
---|
| 2012 | if get(handles.FixVelType,'Value') |
---|
| 2013 | VelTypeList=get(handles.VelType,'String'); |
---|
| 2014 | VelType=VelTypeList{get(handles.VelType,'Value')}; |
---|
[387] | 2015 | end |
---|
[507] | 2016 | end |
---|
[517] | 2017 | if ~isempty(regexp(FieldName,'^vec(')) |
---|
[507] | 2018 | list_code=get(handles.ColorCode,'String');% list menu fields |
---|
| 2019 | index_code=get(handles.ColorCode,'Value');% selected string index |
---|
| 2020 | if ~strcmp(list_code{index_code},'black') && ~strcmp(list_code{index_code},'white') |
---|
| 2021 | list_code=get(handles.ColorScalar,'String');% list menu fields |
---|
| 2022 | index_code=get(handles.ColorScalar,'Value');% selected string index |
---|
| 2023 | ParamIn.ColorVar= list_code{index_code}; % selected field |
---|
[387] | 2024 | end |
---|
[507] | 2025 | end |
---|
| 2026 | case {'video','mmreader'} |
---|
| 2027 | ParamIn=UvData.MovieObject{1}; |
---|
| 2028 | if ~strcmp(NomType,'*') |
---|
| 2029 | frame_index=num_j1;%frame index for movies or multimage |
---|
| 2030 | else |
---|
| 2031 | frame_index=num_i1; |
---|
| 2032 | end |
---|
| 2033 | case 'multimage' |
---|
| 2034 | if ~strcmp(NomType,'*') |
---|
| 2035 | frame_index=num_j1;%frame index for movies or multimage |
---|
| 2036 | else |
---|
| 2037 | frame_index=num_i1; |
---|
| 2038 | end |
---|
| 2039 | case 'vol' %TODO: update |
---|
| 2040 | if isfield(UvData.XmlData,'Npy') && isfield(UvData.XmlData,'Npx') |
---|
| 2041 | ParamIn.Npy=UvData.XmlData.Npy; |
---|
| 2042 | ParamIn.Npx=UvData.XmlData.Npx; |
---|
| 2043 | else |
---|
| 2044 | errormsg='Npx and Npy need to be defined in the xml file for volume images .vol'; |
---|
| 2045 | return |
---|
| 2046 | end |
---|
[387] | 2047 | end |
---|
[507] | 2048 | if isstruct (ParamIn) |
---|
[517] | 2049 | ParamIn.FieldName=FieldName; |
---|
| 2050 | ParamIn.VelType=VelType; |
---|
| 2051 | XNameMenu=get(handles.Coord_x,'String'); |
---|
[526] | 2052 | ParamIn.Coord_x=XNameMenu(get(handles.Coord_x,'Value')); |
---|
[517] | 2053 | YNameMenu=get(handles.Coord_y,'String'); |
---|
[526] | 2054 | ParamIn.Coord_y=YNameMenu(get(handles.Coord_y,'Value')); |
---|
[507] | 2055 | end |
---|
[517] | 2056 | check_tps = 0; |
---|
[515] | 2057 | if strcmp(UvData.FileType{1},'civdata')&&~strcmp(ParamIn.FieldName,'velocity')&&~strcmp(ParamIn.FieldName,'get_field...') |
---|
| 2058 | check_tps=1;%tps needed to get the requested field |
---|
| 2059 | end |
---|
[507] | 2060 | [Field{1},ParamOut,errormsg] = read_field(FileName,UvData.FileType{1},ParamIn,frame_index); |
---|
| 2061 | if ~isempty(errormsg) |
---|
[527] | 2062 | errormsg=['uvmat / refresh_field / read_field( ' FileName ') / ' errormsg]; |
---|
[507] | 2063 | return |
---|
| 2064 | end |
---|
| 2065 | if isfield(ParamOut,'Npx')&& isfield(ParamOut,'Npy') |
---|
| 2066 | set(handles.num_Npx,'String',num2str(ParamOut.Npx));% display image size on the interface |
---|
| 2067 | set(handles.num_Npy,'String',num2str(ParamOut.Npy)); |
---|
| 2068 | end |
---|
| 2069 | if isfield(ParamOut,'TimeIndex')% case of time obtained from get_field |
---|
| 2070 | set(handles.i1,'String',num2str(ParamOut.TimeIndex)) |
---|
| 2071 | end |
---|
| 2072 | if isfield(ParamOut,'TimeValue') |
---|
| 2073 | Field{1}.Time=ParamOut.TimeValue;% case of time obtained from get_field |
---|
| 2074 | end |
---|
| 2075 | Field{1}.ZIndex=z_index; %used for multiplane 3D calibration |
---|
| 2076 | % end |
---|
[387] | 2077 | |
---|
[450] | 2078 | %% choose and read a second field FileName_1 if defined |
---|
[387] | 2079 | VelType_1=[];%default |
---|
| 2080 | FieldName_1=[]; |
---|
[496] | 2081 | ParamIn_1=[]; |
---|
[387] | 2082 | ParamOut_1=[]; |
---|
[445] | 2083 | frame_index_1=1; |
---|
[450] | 2084 | if ~isempty(FileName_1) |
---|
| 2085 | if ~exist(FileName_1,'file') |
---|
| 2086 | errormsg=['second file ' FileName_1 ' does not exist']; |
---|
[387] | 2087 | return |
---|
| 2088 | end |
---|
[450] | 2089 | Name=FileName_1; |
---|
[404] | 2090 | switch UvData.FileType{2} |
---|
[387] | 2091 | case {'civx','civdata','netcdf'}; |
---|
[526] | 2092 | list_fields=get(handles.FieldName_1,'String');% list menu fields |
---|
[520] | 2093 | if ischar(list_fields),list_fields={list_fields};end |
---|
[526] | 2094 | FieldName_1= list_fields{get(handles.FieldName_1,'Value')}; % selected field |
---|
[387] | 2095 | if ~strcmp(FieldName,'get_field...') |
---|
[389] | 2096 | if get(handles.FixVelType,'Value') |
---|
| 2097 | VelTypeList=get(handles.VelType_1,'String'); |
---|
| 2098 | VelType_1=VelTypeList{get(handles.VelType_1,'Value')};% read the velocity type. |
---|
[387] | 2099 | end |
---|
| 2100 | end |
---|
[405] | 2101 | if strcmp(FieldName_1,'velocity')&& strcmp(get(handles.ColorCode,'Visible'),'on') |
---|
| 2102 | list_code=get(handles.ColorCode,'String');% list menu fields |
---|
| 2103 | index_code=get(handles.ColorCode,'Value');% selected string index |
---|
[387] | 2104 | if ~strcmp(list_code{index_code},'black') && ~strcmp(list_code{index_code},'white') |
---|
[405] | 2105 | list_code=get(handles.ColorScalar,'String');% list menu fields |
---|
| 2106 | index_code=get(handles.ColorScalar,'Value');% selected string index |
---|
| 2107 | ParamIn_1.ColorVar= list_code{index_code}; % selected field for vector color display |
---|
[387] | 2108 | end |
---|
| 2109 | end |
---|
[435] | 2110 | case {'video','mmreader'} |
---|
[450] | 2111 | ParamIn_1=UvData.MovieObject{2}; |
---|
[445] | 2112 | if ~strcmp(NomType_1,'*') |
---|
[515] | 2113 | frame_index_1=j1_1;%frame index for movies or multimage |
---|
[445] | 2114 | else |
---|
[515] | 2115 | frame_index_1=i1_1; |
---|
[445] | 2116 | end |
---|
| 2117 | case 'multimage' |
---|
| 2118 | if ~strcmp(NomType_1,'*') |
---|
[515] | 2119 | frame_index_1=j1_1;%frame index for movies or multimage |
---|
[445] | 2120 | else |
---|
[515] | 2121 | frame_index_1=i1_1; |
---|
[445] | 2122 | end |
---|
[387] | 2123 | case 'vol' %TODO: update |
---|
| 2124 | if isfield(UvData.XmlData,'Npy') && isfield(UvData.XmlData,'Npx') |
---|
[405] | 2125 | ParamIn_1.Npy=UvData.XmlData.Npy; |
---|
| 2126 | ParamIn_1.Npx=UvData.XmlData.Npx; |
---|
[387] | 2127 | else |
---|
| 2128 | errormsg='Npx and Npy need to be defined in the xml file for volume images .vol'; |
---|
| 2129 | return |
---|
| 2130 | end |
---|
| 2131 | end |
---|
[428] | 2132 | if isequal(get(handles.NomType_1,'Visible'),'on') |
---|
[387] | 2133 | NomType_1=get(handles.NomType_1,'String'); |
---|
[428] | 2134 | else |
---|
| 2135 | NomType_1=get(handles.NomType,'String'); |
---|
| 2136 | end |
---|
[387] | 2137 | test_keepdata_1=0;% test for keeping the previous stored data if the input files are unchanged |
---|
[515] | 2138 | if ~isequal(NomType_1,'*')&& isfield(UvData,'FileName_1') |
---|
| 2139 | test_keepdata_1= strcmp(FileName_1,UvData.FileName_1) ;%&& strcmp(FieldName_1,UvData.FieldName_1); |
---|
[387] | 2140 | end |
---|
| 2141 | if test_keepdata_1 |
---|
[389] | 2142 | Field{2}=UvData.Field_1;% keep the stored field |
---|
[427] | 2143 | ParamOut_1=UvData.ParamOut_1; |
---|
[387] | 2144 | else |
---|
[496] | 2145 | if isempty(ParamIn_1) || isstruct(ParamIn_1) |
---|
[405] | 2146 | ParamIn_1.FieldName=FieldName_1; |
---|
| 2147 | ParamIn_1.VelType=VelType_1; |
---|
| 2148 | ParamIn_1.GUIName='get_field_1'; |
---|
[515] | 2149 | end |
---|
[445] | 2150 | [Field{2},ParamOut_1,errormsg] = read_field(Name,UvData.FileType{2},ParamIn_1,frame_index_1); |
---|
[387] | 2151 | if ~isempty(errormsg) |
---|
[450] | 2152 | errormsg=['error in reading ' FieldName_1 ' in ' FileName_1 ': ' errormsg]; |
---|
[387] | 2153 | return |
---|
| 2154 | end |
---|
[515] | 2155 | if isstruct(ParamOut_1)&&~strcmp(ParamOut_1.FieldName,'get_field...')&& (strcmp(UvData.FileType{2},'civdata')||strcmp(UvData.FileType{2},'civx'))... |
---|
| 2156 | &&~strcmp(ParamOut_1.FieldName,'velocity') && ~strcmp(ParamOut_1.FieldName,'get_field...') |
---|
| 2157 | if ~check_proj_tps |
---|
| 2158 | % Field{2}=calc_field([{ParamOut_1.FieldName} {ParamOut_1.ColorVar}],Field{2}); |
---|
| 2159 | end |
---|
| 2160 | end |
---|
[387] | 2161 | end |
---|
[507] | 2162 | Field{2}.ZIndex=z_index;%used for multi-plane 3D calibration |
---|
[387] | 2163 | end |
---|
| 2164 | |
---|
| 2165 | %% update uvmat interface |
---|
| 2166 | if isfield(ParamOut,'Npx') |
---|
| 2167 | set(handles.num_Npx,'String',num2str(ParamOut.Npx));% display image size on the interface |
---|
| 2168 | set(handles.num_Npy,'String',num2str(ParamOut.Npy)); |
---|
| 2169 | elseif isfield(ParamOut_1,'Npx') |
---|
| 2170 | set(handles.num_Npx,'String',num2str(ParamOut_1.Npx));% display image size on the interface |
---|
| 2171 | set(handles.num_Npy,'String',num2str(ParamOut_1.Npy)); |
---|
| 2172 | end |
---|
| 2173 | |
---|
| 2174 | %% update the display menu for the first velocity type (first menuline) |
---|
| 2175 | test_veltype=0; |
---|
| 2176 | % if ~isequal(FileType,'netcdf')|| isequal(FieldName,'get_field...') |
---|
[404] | 2177 | if (strcmp(UvData.FileType{1},'civx')||strcmp(UvData.FileType{1},'civdata'))&& ~strcmp(FieldName,'get_field...') |
---|
[387] | 2178 | test_veltype=1; |
---|
| 2179 | set(handles.VelType,'Visible','on') |
---|
| 2180 | set(handles.VelType_1,'Visible','on') |
---|
| 2181 | set(handles.FixVelType,'Visible','on') |
---|
[404] | 2182 | menu=set_veltype_display(ParamOut.CivStage,UvData.FileType{1}); |
---|
[387] | 2183 | index_menu=strcmp(ParamOut.VelType,menu);%look for VelType in the menu |
---|
| 2184 | index_val=find(index_menu,1); |
---|
| 2185 | if isempty(index_val) |
---|
| 2186 | index_val=1; |
---|
| 2187 | end |
---|
| 2188 | set(handles.VelType,'Value',index_val) |
---|
| 2189 | if ~get(handles.SubField,'value') |
---|
| 2190 | set(handles.VelType,'String',menu) |
---|
| 2191 | set(handles.VelType_1,'Value',1) |
---|
| 2192 | set(handles.VelType_1,'String',[{''};menu]) |
---|
| 2193 | end |
---|
| 2194 | else |
---|
| 2195 | set(handles.VelType,'Visible','off') |
---|
| 2196 | end |
---|
[526] | 2197 | % display the FieldName menu from the input file and pick the selected one: |
---|
[517] | 2198 | % if isstruct(ParamOut) |
---|
| 2199 | % field_index=strcmp(ParamOut.FieldName,ParamOut.FieldList); |
---|
[526] | 2200 | % set(handles.FieldName,'String',ParamOut.FieldList); %update the field menu |
---|
| 2201 | % set(handles.FieldName,'Value',find(field_index,1)) |
---|
[517] | 2202 | % end |
---|
[387] | 2203 | |
---|
| 2204 | %% update the display menu for the second velocity type (second menuline) |
---|
| 2205 | test_veltype_1=0; |
---|
[450] | 2206 | if isempty(FileName_1) |
---|
[526] | 2207 | % set(handles.FieldName_1,'Value',1); %update the field menu |
---|
[517] | 2208 | % if isstruct(ParamOut) |
---|
[526] | 2209 | % set(handles.FieldName_1,'String',[{''};ParamOut.FieldList]); %update the field menu |
---|
[517] | 2210 | % end |
---|
[405] | 2211 | elseif ~test_keepdata_1 |
---|
[404] | 2212 | if (~strcmp(UvData.FileType{2},'netcdf')&&~strcmp(UvData.FileType{2},'civdata')&&~strcmp(UvData.FileType{2},'civx'))|| isequal(FieldName_1,'get_field...') |
---|
[387] | 2213 | set(handles.VelType_1,'Visible','off') |
---|
[405] | 2214 | else |
---|
[387] | 2215 | test_veltype_1=1; |
---|
| 2216 | set(handles.VelType_1,'Visible','on') |
---|
[515] | 2217 | menu=set_veltype_display(ParamOut_1.CivStage,UvData.FileType{2}); |
---|
[494] | 2218 | index_menu=strcmp(ParamOut_1.VelType,menu); |
---|
| 2219 | set(handles.VelType_1,'Value',1+find(index_menu,1)) |
---|
| 2220 | set(handles.VelType_1,'String',[{''};menu]) |
---|
[387] | 2221 | end |
---|
[405] | 2222 | % update the second field menu: the same quantity |
---|
[494] | 2223 | if isstruct(ParamOut_1) |
---|
[526] | 2224 | set(handles.FieldName_1,'String',[{''};ParamOut_1.FieldList]); %update the field menu |
---|
| 2225 | % display the FieldName menu from the input file and pick the selected one: |
---|
[405] | 2226 | field_index=strcmp(ParamOut_1.FieldName,ParamOut_1.FieldList); |
---|
[526] | 2227 | set(handles.FieldName_1,'Value',find(field_index,1)+1) |
---|
[494] | 2228 | end |
---|
| 2229 | |
---|
[387] | 2230 | end |
---|
| 2231 | if test_veltype||test_veltype_1 |
---|
| 2232 | set(handles.FixVelType,'Visible','on') |
---|
| 2233 | else |
---|
| 2234 | set(handles.FixVelType,'Visible','off') |
---|
| 2235 | end |
---|
[405] | 2236 | |
---|
| 2237 | % field_index=strcmp(ParamOut_1.FieldName,ParamOut_1.FieldList); |
---|
[526] | 2238 | % set(handles.FieldName,'String',ParamOut.FieldList); %update the field menu |
---|
| 2239 | % set(handles.FieldName,'Value',find(field_index,1)) |
---|
[387] | 2240 | |
---|
| 2241 | %% introduce w as background image by default for a new series (only for nbdim=2) |
---|
| 2242 | if ~isfield(UvData,'NewSeries') |
---|
| 2243 | UvData.NewSeries=1; |
---|
| 2244 | end |
---|
| 2245 | %put W as background image by default if NbDim=2: |
---|
| 2246 | if UvData.NewSeries && isequal(get(handles.SubField,'Value'),0) && isfield(Field{1},'W') && ~isempty(Field{1}.W) && ~isequal(Field{1}.NbDim,3); |
---|
| 2247 | set(handles.SubField,'Value',1); |
---|
| 2248 | set(handles.RootPath_1,'String','"') |
---|
| 2249 | set(handles.RootFile_1,'String','"') |
---|
| 2250 | set(handles.SubDir_1,'String','"'); |
---|
| 2251 | indices=fullfile_uvmat('','','','',NomType,num_i1,num_i2,num_j1,num_j2); |
---|
| 2252 | set(handles.FileIndex_1,'String',indices) |
---|
| 2253 | set(handles.FileExt_1,'String','"'); |
---|
[526] | 2254 | set(handles.FieldName_1,'Visible','on'); |
---|
| 2255 | set(handles.FieldName_1,'Visible','on'); |
---|
[387] | 2256 | set(handles.RootPath_1,'Visible','on') |
---|
| 2257 | set(handles.RootFile_1,'Visible','on') |
---|
| 2258 | set(handles.SubDir_1,'Visible','on'); |
---|
| 2259 | set(handles.FileIndex_1,'Visible','on'); |
---|
| 2260 | set(handles.FileExt_1,'Visible','on'); |
---|
[526] | 2261 | set(handles.FieldName_1,'Visible','on'); |
---|
[387] | 2262 | Field{1}.AName='w'; |
---|
| 2263 | end |
---|
| 2264 | |
---|
[415] | 2265 | %% display time |
---|
| 2266 | testimedoc=0; |
---|
| 2267 | TimeUnit=''; |
---|
| 2268 | if isfield(Field{1},'Time') |
---|
| 2269 | abstime=Field{1}.Time;%time read from the netcdf input file |
---|
| 2270 | end |
---|
| 2271 | if numel(Field)==2 && isfield(Field{2},'Time') |
---|
| 2272 | abstime_1=Field{2}.Time;%time read from the netcdf input file |
---|
| 2273 | end |
---|
| 2274 | if isfield(Field{1},'Dt') |
---|
| 2275 | dt=Field{1}.Dt;%dt read from the netcdf input file |
---|
| 2276 | if isfield(Field{1},'TimeUnit') |
---|
| 2277 | TimeUnit=Field{1}.TimeUnit; |
---|
| 2278 | end |
---|
| 2279 | elseif numel(Field)==2 && isfield(Field{2},'Dt')%dt obtained from the second field if not defined in the first |
---|
| 2280 | dt=Field{2}.Dt;%dt read from the netcdf input file |
---|
| 2281 | if isfield(Field{2},'TimeUnit') |
---|
| 2282 | TimeUnit=Field{2}.TimeUnit; |
---|
| 2283 | end |
---|
| 2284 | end |
---|
| 2285 | % time from xml file overset previous result |
---|
| 2286 | if isfield(UvData,'XmlData') && isfield(UvData.XmlData{1},'Time') |
---|
| 2287 | if isempty(num_i2)||isnan(num_i2) |
---|
| 2288 | num_i2=num_i1; |
---|
| 2289 | end |
---|
| 2290 | if isempty(num_j1)||isnan(num_j1) |
---|
| 2291 | num_j1=1; |
---|
| 2292 | end |
---|
| 2293 | if isempty(num_j2)||isnan(num_j2) |
---|
| 2294 | num_j2=num_j1; |
---|
| 2295 | end |
---|
| 2296 | siz=size(UvData.XmlData{1}.Time); |
---|
[446] | 2297 | if ~isempty(num_i1)&& ~isempty(num_i2)&&siz(1)>=max(num_i1,num_i2) && siz(2)>=max(num_j1,num_j2) |
---|
[415] | 2298 | abstime=(UvData.XmlData{1}.Time(num_i1,num_j1)+UvData.XmlData{1}.Time(num_i2,num_j2))/2;%overset the time read from files |
---|
| 2299 | dt=(UvData.XmlData{1}.Time(num_i2,num_j2)-UvData.XmlData{1}.Time(num_i1,num_j1)); |
---|
| 2300 | Field{1}.Dt=dt; |
---|
| 2301 | if isfield(UvData.XmlData{1},'TimeUnit') |
---|
| 2302 | TimeUnit=UvData.XmlData{1}.TimeUnit; |
---|
| 2303 | end |
---|
| 2304 | end |
---|
| 2305 | if numel(UvData.XmlData)==2 |
---|
[515] | 2306 | if isempty(i2_1) |
---|
| 2307 | i2_1=num_i1; |
---|
[415] | 2308 | end |
---|
[515] | 2309 | if isempty(j1_1) |
---|
| 2310 | j1_1=1; |
---|
[415] | 2311 | end |
---|
[515] | 2312 | if isempty(j2_1) |
---|
| 2313 | j2_1=j1_1; |
---|
[415] | 2314 | end |
---|
| 2315 | siz=size(UvData.XmlData{2}.Time); |
---|
[515] | 2316 | if ~isempty(i1_1) && siz(1)>=max(i1_1,i2_1) && siz(2)>=max(j1_1,j2_1) |
---|
| 2317 | abstime_1=(UvData.XmlData{2}.Time(i1_1,j1_1)+UvData.XmlData{2}.Time(i2_1,j2_1))/2;%overset the time read from files |
---|
| 2318 | Field{2}.Dt=(UvData.XmlData{2}.Time(i2_1,j2_1)-UvData.XmlData{2}.Time(i1_1,j1_1)); |
---|
[415] | 2319 | end |
---|
| 2320 | end |
---|
| 2321 | end |
---|
| 2322 | if ~isequal(numel(abstime),1) |
---|
| 2323 | abstime=[]; |
---|
| 2324 | end |
---|
| 2325 | if ~isequal(numel(abstime_1),1) |
---|
| 2326 | abstime_1=[]; |
---|
| 2327 | end |
---|
[456] | 2328 | set(handles.abs_time,'String',num2str(abstime,5)) |
---|
| 2329 | set(handles.abs_time_1,'String',num2str(abstime_1,5)) |
---|
[415] | 2330 | if isempty(dt)||isequal(dt,0) |
---|
| 2331 | set(handles.Dt_txt,'String','') |
---|
| 2332 | else |
---|
| 2333 | if isempty(TimeUnit) |
---|
| 2334 | set(handles.Dt_txt,'String',['Dt=' num2str(1000*dt,3) ' 10^(-3)'] ) |
---|
| 2335 | else |
---|
| 2336 | set(handles.Dt_txt,'String',['Dt=' num2str(1000*dt,3) ' m' TimeUnit] ) |
---|
| 2337 | end |
---|
| 2338 | end |
---|
| 2339 | |
---|
| 2340 | |
---|
[526] | 2341 | %% store the current open names, fieldname and vel types in uvmat interface |
---|
[450] | 2342 | UvData.FileName_1=FileName_1; |
---|
[512] | 2343 | UvData.ParamOut_1=ParamOut_1; |
---|
| 2344 | if numel(Field)==2 |
---|
| 2345 | UvData.Field_1=Field{2}; %store the second field for possible use at next RUN |
---|
| 2346 | end |
---|
[387] | 2347 | |
---|
| 2348 | %% apply coordinate transform or other user fct |
---|
[507] | 2349 | transform=get(handles.path_transform,'UserData'); |
---|
[515] | 2350 | if isempty(transform) |
---|
| 2351 | UvData.Field=Field{1}; |
---|
| 2352 | else |
---|
[507] | 2353 | XmlData=[];%default |
---|
| 2354 | XmlData_1=[];%default |
---|
| 2355 | if isfield(UvData,'XmlData')%use geometry calib recorded from the ImaDoc xml file as first priority |
---|
| 2356 | XmlData=UvData.XmlData{1}; |
---|
| 2357 | if numel(UvData.XmlData)==2 |
---|
| 2358 | XmlData_1=UvData.XmlData{2}; |
---|
| 2359 | end |
---|
[387] | 2360 | end |
---|
[507] | 2361 | transform=get(handles.path_transform,'UserData'); |
---|
[512] | 2362 | switch nargin(transform) |
---|
| 2363 | case 4 |
---|
| 2364 | if length(Field)==2 |
---|
| 2365 | UvData.Field=transform(Field{1},XmlData,Field{2},XmlData_1); |
---|
| 2366 | else |
---|
| 2367 | UvData.Field=transform(Field{1},XmlData); |
---|
| 2368 | end |
---|
| 2369 | case 3 |
---|
| 2370 | if length(Field)==2 |
---|
| 2371 | UvData.Field=transform(Field{1},XmlData,Field{2}); |
---|
| 2372 | else |
---|
| 2373 | UvData.Field=transform(Field{1},XmlData); |
---|
| 2374 | end |
---|
| 2375 | case 2 |
---|
| 2376 | UvData.Field=transform(Field{1},XmlData); |
---|
| 2377 | case 1 |
---|
| 2378 | UvData.Field=transform(Field{1}); |
---|
[387] | 2379 | end |
---|
[507] | 2380 | end |
---|
[508] | 2381 | |
---|
[515] | 2382 | %% calculate tps coefficients if needed |
---|
| 2383 | UvData.Field=calc_tps(UvData.Field,check_proj_tps); |
---|
[387] | 2384 | |
---|
[434] | 2385 | %% analyse input field |
---|
[530] | 2386 | %test_x=0; |
---|
| 2387 | %test_z=0;% test for unstructured z coordinate |
---|
| 2388 | %[errormsg,ListDimName,DimValue,VarDimIndex]=check_field_structure(UvData.Field);% check the input field structure |
---|
| 2389 | % if ~isempty(errormsg) |
---|
| 2390 | % errormsg=['error in uvmat/refresh_field/check_field_structure: ' errormsg];% display error |
---|
| 2391 | % return |
---|
| 2392 | % end |
---|
| 2393 | [CellInfo,NbDimArray,errormsg]=find_field_cells(UvData.Field);% analyse the input field structure |
---|
[387] | 2394 | if ~isempty(errormsg) |
---|
[527] | 2395 | errormsg=['uvmat /refresh_field / find_field_cells / ' errormsg];% display error |
---|
[387] | 2396 | return |
---|
| 2397 | end |
---|
[530] | 2398 | |
---|
| 2399 | NbDim=max(NbDimArray);% spatial dimension of the input field |
---|
| 2400 | imax=find(NbDimArray==NbDim);% indices of field cells to consider |
---|
[387] | 2401 | if isfield(UvData.Field,'NbDim') |
---|
[530] | 2402 | NbDim=double(UvData.Field.NbDim);% deal with plane fields containing z coordinates |
---|
[387] | 2403 | end |
---|
[434] | 2404 | |
---|
[530] | 2405 | |
---|
[527] | 2406 | %% get bounds and mesh (needed to propose default options for projection objects) |
---|
[435] | 2407 | if NbDim>1 |
---|
[535] | 2408 | CoordMax=zeros(numel(imax),NbDim); |
---|
| 2409 | CoordMin=zeros(numel(imax),NbDim); |
---|
| 2410 | Mesh=zeros(numel(imax),NbDim); |
---|
[530] | 2411 | for ind=1:numel(imax) |
---|
| 2412 | XName=UvData.Field.ListVarName{CellInfo{imax(ind)}.CoordIndex(end)}; |
---|
| 2413 | YName=UvData.Field.ListVarName{CellInfo{imax(ind)}.CoordIndex(end-1)}; |
---|
[535] | 2414 | CoordMax(ind,NbDim)=max(max(UvData.Field.(XName))); |
---|
| 2415 | CoordMin(ind,NbDim)=min(min(UvData.Field.(XName))); |
---|
| 2416 | CoordMax(ind,NbDim-1)=max(max(UvData.Field.(YName))); |
---|
| 2417 | CoordMin(ind,NbDim-1)=min(min(UvData.Field.(YName))); |
---|
[530] | 2418 | % test_x=1;%test for unstructured coordinates |
---|
| 2419 | if NbDim==3 |
---|
| 2420 | ZName=UvData.Field.ListVarName{CellInfo{imax(ind)}.CoordIndex(1)}; |
---|
[535] | 2421 | CoordMax(imax(ind),1)=max(max(UvData.Field.(ZName))); |
---|
| 2422 | CoordMin(ind,1)=min(min(UvData.Field.(ZName))); |
---|
[434] | 2423 | end |
---|
[530] | 2424 | |
---|
| 2425 | switch CellInfo{imax(ind)}.CoordType |
---|
| 2426 | |
---|
| 2427 | case 'scattered' %unstructured coordinates |
---|
[535] | 2428 | NbPoints=CellInfo{imax(ind)}.CoordSize;% nbre of points |
---|
| 2429 | Mesh(ind,:)=(prod(CoordMax(ind,:)-CoordMin(ind,:))/NbPoints)^(1/NbDim); %(volume or area per point)^(1/NbDim) |
---|
[530] | 2430 | case 'grid'%structured coordinate |
---|
[535] | 2431 | NbPoints=CellInfo{imax(ind)}.CoordSize;% nbre of points in each direction |
---|
| 2432 | Mesh(ind,:)=min((CoordMax(ind,:)-CoordMin(ind,:))./(NbPoints-1)); |
---|
[435] | 2433 | end |
---|
[387] | 2434 | end |
---|
[530] | 2435 | UvData.Field.Mesh=min(Mesh); |
---|
[546] | 2436 | UvData.Field.XMax=max(CoordMax(ind,end)); |
---|
| 2437 | UvData.Field.XMin=min(CoordMin(ind,end)); |
---|
| 2438 | UvData.Field.YMax=max(CoordMax(ind,end-1)); |
---|
| 2439 | UvData.Field.YMin=max(CoordMin(ind,end-1)); |
---|
[435] | 2440 | if NbDim==3 |
---|
[546] | 2441 | UvData.Field.ZMax=max(CoordMax(ind,1)); |
---|
| 2442 | UvData.Field.ZMin=max(CoordMin(ind,1)); |
---|
[387] | 2443 | end |
---|
[435] | 2444 | % adjust the mesh to a value 1, 2 , 5 *10^n |
---|
| 2445 | ord=10^(floor(log10(UvData.Field.Mesh)));%order of magnitude |
---|
| 2446 | if UvData.Field.Mesh/ord>=5 |
---|
| 2447 | UvData.Field.Mesh=5*ord; |
---|
| 2448 | elseif UvData.Field.Mesh/ord>=2 |
---|
| 2449 | UvData.Field.Mesh=2*ord; |
---|
[404] | 2450 | else |
---|
[435] | 2451 | UvData.Field.Mesh=ord; |
---|
[404] | 2452 | end |
---|
[491] | 2453 | % default projection plane |
---|
[511] | 2454 | if isempty(UvData.Object{1}) |
---|
[491] | 2455 | UvData.Object{1}.Type='plane';%main plotting plane |
---|
| 2456 | UvData.Object{1}.ProjMode='projection';%main plotting plane |
---|
| 2457 | UvData.Object{1}.DisplayHandle.uvmat=[]; %plane not visible in uvmat |
---|
| 2458 | UvData.Object{1}.DisplayHandle.view_field=[]; %plane not visible in uvmat |
---|
| 2459 | end |
---|
[435] | 2460 | %% 3D case (menuvolume) |
---|
| 2461 | if NbDim==3% && UvData.NewSeries |
---|
| 2462 | test_set_object=1; |
---|
| 2463 | hset_object=findobj(allchild(0),'tag','set_object');% look for the set_object GUI |
---|
| 2464 | ZBounds(1)=UvData.Field.ZMin; %minimum for the Z slider |
---|
| 2465 | ZBounds(2)=UvData.Field.ZMax;%maximum for the Z slider |
---|
| 2466 | if ~isempty(hset_object) %if set_object is detected |
---|
| 2467 | delete(hset_object);% delete the GUI set_object if it does not fit |
---|
[387] | 2468 | end |
---|
[435] | 2469 | if test_set_object% reinitiate the GUI set_object |
---|
| 2470 | 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 |
---|
| 2471 | UvData.Object{1}.NbDim=NbDim;%test for 3D objects |
---|
| 2472 | UvData.Object{1}.RangeZ=UvData.Field.Mesh;%main plotting plane |
---|
| 2473 | UvData.Object{1}.Coord(1,3)=(UvData.Field.ZMin+UvData.Field.ZMax)/2;%section at a middle plane chosen |
---|
| 2474 | UvData.Object{1}.Angle=[0 0 0]; |
---|
| 2475 | UvData.Object{1}.HandlesDisplay=plot(0,0,'Tag','proj_object');% A REVOIR |
---|
| 2476 | UvData.Object{1}.Name='1-PLANE'; |
---|
| 2477 | UvData.Object{1}.enable_plot=1; |
---|
| 2478 | set_object(UvData.Object{1},handles,ZBounds); |
---|
| 2479 | set(handles.ListObject,'Value',1); |
---|
| 2480 | set(handles.ListObject,'String',{'1-PLANE'}); |
---|
| 2481 | set(handles.edit_object,'Value',1)% put the plane in edit mode to enable the z cursor |
---|
| 2482 | edit_object_Callback([],[], handles) |
---|
[387] | 2483 | end |
---|
[435] | 2484 | %multilevel case (single menuplane in a 3D space) |
---|
| 2485 | elseif isfield(UvData,'Z') |
---|
| 2486 | if isfield(UvData,'CoordType')&& isequal(UvData.CoordType,'phys') && isfield(UvData,'XmlData') |
---|
| 2487 | XmlData=UvData.XmlData{1}; |
---|
| 2488 | if isfield(XmlData,'PlanePos') |
---|
| 2489 | UvData.Object{1}.Coord=XmlData.PlanePos(UvData.ZIndex,:); |
---|
| 2490 | end |
---|
| 2491 | if isfield(XmlData,'PlaneAngle') |
---|
| 2492 | siz=size(XmlData.PlaneAngle); |
---|
| 2493 | indangle=min(siz(1),UvData.ZIndex);%take first angle if a single angle is defined (translating scanning) |
---|
| 2494 | UvData.Object{1}.PlaneAngle=XmlData.PlaneAngle(indangle,:); |
---|
| 2495 | end |
---|
| 2496 | elseif isfield(UvData,'ZIndex') |
---|
| 2497 | UvData.Object{1}.ZObject=UvData.ZIndex; |
---|
| 2498 | end |
---|
[387] | 2499 | end |
---|
| 2500 | end |
---|
[435] | 2501 | |
---|
[387] | 2502 | testnewseries=UvData.NewSeries; |
---|
| 2503 | UvData.NewSeries=0;% put to 0 the test for a new field series (set by RootPath_callback) |
---|
| 2504 | set(handles.uvmat,'UserData',UvData) |
---|
| 2505 | |
---|
| 2506 | %% reset the min and max of scalar if only the mask is displayed(TODO: check the need) |
---|
[405] | 2507 | % if isfield(UvData,'Mask')&& ~isfield(UvData,'A') |
---|
| 2508 | % set(handles.num_MinA,'String','0') |
---|
| 2509 | % set(handles.num_MaxA,'String','255') |
---|
| 2510 | % end |
---|
[387] | 2511 | |
---|
[434] | 2512 | %% usual 1D (x,y) plots |
---|
| 2513 | if NbDim<=1 |
---|
| 2514 | set(handles.Objects,'Visible','off') |
---|
| 2515 | set(handles.ListObject_1_title,'Visible','off') |
---|
| 2516 | set(handles.ListObject_1,'Visible','off') |
---|
[511] | 2517 | [PlotType,PlotParamOut]=plot_field(UvData.Field,handles.PlotAxes,read_GUI(handles.uvmat)); |
---|
[434] | 2518 | write_plot_param(handles,PlotParamOut) %update the auto plot parameters |
---|
| 2519 | |
---|
[526] | 2520 | %% 2D or 3D fieldname are generally projected |
---|
[387] | 2521 | else |
---|
[434] | 2522 | set(handles.Objects,'Visible','on') |
---|
| 2523 | set(handles.ListObject_1_title,'Visible','on') |
---|
| 2524 | set(handles.ListObject_1,'Visible','on') |
---|
| 2525 | |
---|
| 2526 | %% Plot the projections on the selected projection objects |
---|
| 2527 | % main projection object (uvmat display) |
---|
| 2528 | list_object=get(handles.ListObject_1,'String'); |
---|
[535] | 2529 | if isequal(list_object,{''})||isequal(list_object,' ')%refresh list of objects if the menu is empty |
---|
[508] | 2530 | set(handles.ListObject,'Value',1) |
---|
| 2531 | set(handles.ListObject,'String',{'plane'}) |
---|
| 2532 | UvData.Object{1}.Type='plane';%main plotting plane |
---|
| 2533 | UvData.Object{1}.ProjMode='projection';%main plotting plane |
---|
| 2534 | UvData.Object{1}.DisplayHandle.uvmat=[]; %plane not visible in uvmat |
---|
| 2535 | UvData.Object{1}.DisplayHandle.view_field=[]; %plane not visible in uvmat |
---|
[434] | 2536 | set(handles.ListObject_1,'Value',1) |
---|
[508] | 2537 | set(handles.ListObject_1,'String',{'plane'}) |
---|
[387] | 2538 | end |
---|
[434] | 2539 | IndexObj(1)=get(handles.ListObject_1,'Value');%selected projection object for main view |
---|
| 2540 | if IndexObj(1)> numel(UvData.Object) |
---|
| 2541 | IndexObj(1)=1;%select the first object if the selected one does not exist |
---|
| 2542 | set(handles.ListObject_1,'Value',1) |
---|
[387] | 2543 | end |
---|
[434] | 2544 | IndexObj(2)=get(handles.ListObject,'Value');%selected projection object for main view |
---|
| 2545 | if isequal(IndexObj(2),IndexObj(1)) |
---|
| 2546 | IndexObj(2)=[]; |
---|
| 2547 | end |
---|
| 2548 | plot_handles{1}=handles; |
---|
| 2549 | if isfield(UvData,'plotaxes')%case of movies |
---|
| 2550 | haxes(1)=UvData.plotaxes; |
---|
| 2551 | else |
---|
[511] | 2552 | haxes(1)=handles.PlotAxes; |
---|
[434] | 2553 | end |
---|
| 2554 | PlotParam{1}=read_GUI(handles.uvmat); |
---|
| 2555 | %default settings if vectors not visible |
---|
| 2556 | if ~isfield(PlotParam{1},'Vectors') |
---|
| 2557 | PlotParam{1}.Vectors.MaxVec=1; |
---|
| 2558 | PlotParam{1}.Vectors.MinVec=0; |
---|
| 2559 | PlotParam{1}.Vectors.CheckFixVecColor=1; |
---|
| 2560 | PlotParam{1}.Vectors.ColCode1=0.33; |
---|
| 2561 | PlotParam{1}.Vectors.ColCode2=0.66; |
---|
[517] | 2562 | PlotParam{1}.Vectors.ColorScalar={''}; |
---|
[434] | 2563 | PlotParam{1}.Vectors.ColorCode= {'rgb'}; |
---|
| 2564 | end |
---|
| 2565 | PosColorbar{1}=UvData.OpenParam.PosColorbar;%prescribe the colorbar position on the uvmat interface |
---|
| 2566 | |
---|
| 2567 | %% second projection object (view_field display) |
---|
| 2568 | if length( IndexObj)>=2 |
---|
| 2569 | view_field_handle=findobj(allchild(0),'tag','view_field');%handles of the view_field GUI |
---|
| 2570 | if ~isempty(view_field_handle) |
---|
| 2571 | plot_handles{2}=guidata(view_field_handle); |
---|
[511] | 2572 | haxes(2)=plot_handles{2}.PlotAxes; |
---|
[434] | 2573 | PlotParam{2}=read_GUI(handles.uvmat);%read plotting parameters on the uvmat interface |
---|
| 2574 | PosColorbar{2}='*'; %TODO: deal with colorbar position on view_field |
---|
[421] | 2575 | end |
---|
[387] | 2576 | end |
---|
[434] | 2577 | |
---|
| 2578 | %% loop on the projection objects: one or two |
---|
| 2579 | |
---|
| 2580 | for imap=1:numel(IndexObj) |
---|
| 2581 | iobj=IndexObj(imap); |
---|
| 2582 | [ObjectData,errormsg]=proj_field(UvData.Field,UvData.Object{iobj});% project field on the object |
---|
| 2583 | if ~isempty(errormsg) |
---|
| 2584 | return |
---|
[387] | 2585 | end |
---|
[434] | 2586 | if testnewseries |
---|
| 2587 | PlotParam{imap}.Scalar.CheckBW=[]; %B/W option depends on the input field (image or scalar) |
---|
| 2588 | if isfield(ObjectData,'CoordUnit') |
---|
| 2589 | PlotParam{imap}.Coordinates.CheckFixAspectRatio=1;% set x and y scaling equal if CoordUnit is defined (common unit for x and y) |
---|
| 2590 | PlotParam{imap}.Coordinates.AspectRatio=1; %set aspect ratio to 1 |
---|
[387] | 2591 | end |
---|
[434] | 2592 | end |
---|
| 2593 | %use of mask (TODO: check) |
---|
| 2594 | if isfield(ObjectData,'NbDim') && isequal(ObjectData.NbDim,2) && isfield(ObjectData,'Mask') && isfield(ObjectData,'A') |
---|
| 2595 | flag_mask=double(ObjectData.Mask>200);%=0 for masked regions |
---|
| 2596 | AX=ObjectData.AX;%x coordiantes for the scalar field |
---|
| 2597 | AY=ObjectData.AY;%y coordinates for the scalar field |
---|
| 2598 | MaskX=ObjectData.MaskX;%x coordiantes for the mask |
---|
| 2599 | MaskY=ObjectData.MaskY;%y coordiantes for the mask |
---|
| 2600 | if ~isequal(MaskX,AX)||~isequal(MaskY,AY) |
---|
| 2601 | nxy=size(flag_mask); |
---|
| 2602 | sizpx=(ObjectData.MaskX(end)-ObjectData.MaskX(1))/(nxy(2)-1);%size of a mask pixel |
---|
| 2603 | sizpy=(ObjectData.MaskY(1)-ObjectData.MaskY(end))/(nxy(1)-1); |
---|
| 2604 | x_mask=ObjectData.MaskX(1):sizpx:ObjectData.MaskX(end); % pixel x coordinates for image display |
---|
| 2605 | y_mask=ObjectData.MaskY(1):-sizpy:ObjectData.MaskY(end);% pixel x coordinates for image display |
---|
| 2606 | %project on the positions of the scalar |
---|
| 2607 | npxy=size(ObjectData.A); |
---|
| 2608 | dxy(1)=(ObjectData.AY(end)-ObjectData.AY(1))/(npxy(1)-1);%grid mesh in y |
---|
| 2609 | dxy(2)=(ObjectData.AX(end)-ObjectData.AX(1))/(npxy(2)-1);%grid mesh in x |
---|
| 2610 | xi=ObjectData.AX(1):dxy(2):ObjectData.AX(end); |
---|
| 2611 | yi=ObjectData.AY(1):dxy(1):ObjectData.AY(end); |
---|
| 2612 | [XI,YI]=meshgrid(xi,yi);% creates the matrix of regular coordinates |
---|
| 2613 | flag_mask = interp2(x_mask,y_mask,flag_mask,XI,YI); |
---|
| 2614 | end |
---|
| 2615 | AClass=class(ObjectData.A); |
---|
| 2616 | ObjectData.A=flag_mask.*double(ObjectData.A); |
---|
| 2617 | ObjectData.A=feval(AClass,ObjectData.A); |
---|
[530] | 2618 | % ind_off=[]; |
---|
| 2619 | % if isfield(ObjectData,'ListVarName') |
---|
| 2620 | % for ilist=1:length(ObjectData.ListVarName) |
---|
| 2621 | % if isequal(ObjectData.ListVarName{ilist},'Mask')||isequal(ObjectData.ListVarName{ilist},'MaskX')||isequal(ObjectData.ListVarName{ilist},'MaskY') |
---|
| 2622 | % ind_off=[ind_off ilist]; |
---|
| 2623 | % end |
---|
| 2624 | % end |
---|
| 2625 | % ObjectData.ListVarName(ind_off)=[]; |
---|
| 2626 | % VarDimIndex(ind_off)=[]; |
---|
| 2627 | % ind_off=[]; |
---|
| 2628 | % |
---|
| 2629 | % end |
---|
[387] | 2630 | end |
---|
[434] | 2631 | if ~isempty(ObjectData) |
---|
| 2632 | PlotType='none'; %default |
---|
| 2633 | if imap==2 && isempty(view_field_handle) |
---|
| 2634 | view_field(ObjectData) |
---|
| 2635 | else |
---|
| 2636 | [PlotType,PlotParamOut]=plot_field(ObjectData,haxes(imap),PlotParam{imap},PosColorbar{imap}); |
---|
| 2637 | write_plot_param(plot_handles{imap},PlotParamOut) %update the auto plot parameters |
---|
| 2638 | if isfield(Field,'Mesh')&&~isempty(Field.Mesh) |
---|
| 2639 | ObjectData.Mesh=Field.Mesh; % gives an estimated mesh size (useful for mouse action on the plot) |
---|
| 2640 | end |
---|
[387] | 2641 | end |
---|
| 2642 | end |
---|
| 2643 | end |
---|
[434] | 2644 | |
---|
| 2645 | %% update the mask |
---|
| 2646 | if isequal(get(handles.CheckMask,'Value'),1)%if the mask option is on |
---|
| 2647 | update_mask(handles,num_i1,num_i2); |
---|
| 2648 | end |
---|
| 2649 | |
---|
| 2650 | %% prepare the menus of histograms and plot them (histogram of the whole volume in 3D case) |
---|
| 2651 | menu_histo=(UvData.Field.ListVarName)';%list of field variables to be displayed for the menu of histogram display |
---|
| 2652 | ind_skip=[]; |
---|
| 2653 | % nb_histo=1; |
---|
| 2654 | Ustring=''; |
---|
| 2655 | Vstring=''; |
---|
| 2656 | % suppress coordinates from the histogram menu |
---|
| 2657 | for ivar=1:numel(menu_histo)%l loop on field variables: |
---|
| 2658 | if isfield(UvData.Field,'VarAttribute') && numel(UvData.Field.VarAttribute)>=ivar && isfield(UvData.Field.VarAttribute{ivar},'Role') |
---|
| 2659 | Role=UvData.Field.VarAttribute{ivar}.Role; |
---|
| 2660 | switch Role |
---|
| 2661 | case {'coord_x','coord_y','coord_z','dimvar'} |
---|
| 2662 | ind_skip=[ind_skip ivar]; |
---|
| 2663 | case {'vector_x'} |
---|
| 2664 | Ustring=UvData.Field.ListVarName{ivar}; |
---|
| 2665 | ind_skip=[ind_skip ivar]; |
---|
| 2666 | case {'vector_y'} |
---|
| 2667 | Vstring=UvData.Field.ListVarName{ivar}; |
---|
| 2668 | ind_skip=[ind_skip ivar]; |
---|
| 2669 | end |
---|
[387] | 2670 | end |
---|
[434] | 2671 | DimCell=UvData.Field.VarDimName{ivar}; |
---|
| 2672 | DimName=''; |
---|
| 2673 | if ischar(DimCell) |
---|
| 2674 | DimName=DimCell; |
---|
| 2675 | elseif iscell(DimCell)&& numel(DimCell)==1 |
---|
| 2676 | DimName=DimCell{1}; |
---|
| 2677 | end |
---|
| 2678 | if strcmp(DimName,menu_histo{ivar}) |
---|
| 2679 | ind_skip=[ind_skip ivar]; |
---|
| 2680 | end |
---|
[387] | 2681 | end |
---|
[434] | 2682 | menu_histo(ind_skip)=[];% remove skipped items |
---|
| 2683 | if ~isempty(Ustring) |
---|
| 2684 | menu_histo=[{[Ustring ',' Vstring]};menu_histo];% add U, V at the beginning if they exist |
---|
[387] | 2685 | end |
---|
[434] | 2686 | |
---|
| 2687 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
---|
| 2688 | % display menus and plot histograms |
---|
| 2689 | test_v=0; |
---|
| 2690 | if ~isempty(menu_histo) |
---|
| 2691 | set(handles.histo1_menu,'Value',1) |
---|
| 2692 | set(handles.histo1_menu,'String',menu_histo) |
---|
| 2693 | histo1_menu_Callback(handles.histo1_menu, [], handles)% plot first histogram |
---|
[387] | 2694 | end |
---|
| 2695 | end |
---|
| 2696 | |
---|
[424] | 2697 | %------------------------------------------------------------------------ |
---|
| 2698 | function histo1_menu_Callback(hObject, eventdata, handles) |
---|
| 2699 | %-------------------------------------------- |
---|
| 2700 | histo_menu=get(handles.histo1_menu,'String'); |
---|
| 2701 | histo_value=get(handles.histo1_menu,'Value'); |
---|
| 2702 | FieldName=histo_menu{histo_value}; |
---|
[530] | 2703 | |
---|
[424] | 2704 | UvData=get(handles.uvmat,'UserData'); |
---|
| 2705 | Field=UvData.Field; |
---|
| 2706 | r=regexp(FieldName,'(?<var1>.*)(?<sep>,)(?<var2>.*)','names'); |
---|
| 2707 | FieldName_2=''; |
---|
| 2708 | if ~isempty(r) |
---|
| 2709 | FieldName=r.var1; |
---|
| 2710 | FieldName_2=r.var2; |
---|
| 2711 | end |
---|
| 2712 | if ~isfield(UvData.Field,FieldName) |
---|
| 2713 | msgbox_uvmat('ERROR',['no field ' FieldName ' for histogram']) |
---|
| 2714 | return |
---|
| 2715 | end |
---|
| 2716 | FieldHisto=Field.(FieldName); |
---|
| 2717 | if isfield(Field,'FF') && ~isempty(Field.FF) && isequal(size(Field.FF),size(FieldHisto)) |
---|
| 2718 | indsel=find(Field.FF==0);%find values marked as false |
---|
| 2719 | if ~isempty(indsel) |
---|
| 2720 | FieldHisto=FieldHisto(indsel); |
---|
| 2721 | if ~isempty(FieldName_2) |
---|
| 2722 | FieldHisto(:,:,2)=Field.(FieldName_2)(indsel); |
---|
| 2723 | end |
---|
[387] | 2724 | end |
---|
| 2725 | end |
---|
[424] | 2726 | if isempty(Field) |
---|
| 2727 | msgbox_uvmat('ERROR',['empty field ' FieldName]) |
---|
| 2728 | else |
---|
| 2729 | nxy=size(FieldHisto); |
---|
| 2730 | Amin=double(min(min(min(FieldHisto))));%min of field value |
---|
| 2731 | Amax=double(max(max(max(FieldHisto))));%max of field value |
---|
| 2732 | if isequal(Amin,Amax) |
---|
[511] | 2733 | cla(handles.HistoAxes) |
---|
[424] | 2734 | else |
---|
| 2735 | Histo.ListVarName={FieldName,'histo'}; |
---|
| 2736 | if isfield(Field,'NbDim') && isequal(Field.NbDim,3) |
---|
| 2737 | Histo.VarDimName={FieldName,FieldName}; %dimensions for the histogram |
---|
| 2738 | else |
---|
| 2739 | if numel(nxy)==2 |
---|
| 2740 | Histo.VarDimName={FieldName,FieldName}; %dimensions for the histogram |
---|
| 2741 | else |
---|
| 2742 | Histo.VarDimName={FieldName,{FieldName,'component'}}; %dimensions for the histogram |
---|
| 2743 | end |
---|
| 2744 | end |
---|
| 2745 | %unit |
---|
| 2746 | units=[]; %default |
---|
| 2747 | for ivar=1:numel(Field.ListVarName) |
---|
| 2748 | if strcmp(Field.ListVarName{ivar},FieldName) |
---|
| 2749 | if isfield(Field,'VarAttribute') && numel(Field.VarAttribute)>=ivar && isfield(Field.VarAttribute{ivar},'units') |
---|
| 2750 | units=Field.VarAttribute{ivar}.units; |
---|
| 2751 | break |
---|
| 2752 | end |
---|
| 2753 | end |
---|
| 2754 | end |
---|
| 2755 | if ~isempty(units) |
---|
| 2756 | Histo.VarAttribute{1}.units=units; |
---|
| 2757 | end |
---|
| 2758 | eval(['Histo.' FieldName '=linspace(Amin,Amax,50);'])%absissa values for histo |
---|
| 2759 | if isfield(Field,'NbDim') && isequal(Field.NbDim,3) |
---|
| 2760 | C=reshape(double(FieldHisto),1,[]);% reshape in a vector |
---|
| 2761 | Histo.histo(:,1)=hist(C, Histo.(FieldName)); %calculate histogram |
---|
| 2762 | else |
---|
| 2763 | for col=1:size(FieldHisto,3) |
---|
| 2764 | B=FieldHisto(:,:,col); |
---|
| 2765 | C=reshape(double(B),1,nxy(1)*nxy(2));% reshape in a vector |
---|
| 2766 | Histo.histo(:,col)=hist(C, Histo.(FieldName)); %calculate histogram |
---|
| 2767 | end |
---|
| 2768 | end |
---|
[511] | 2769 | plot_field(Histo,handles.HistoAxes); |
---|
[426] | 2770 | hlegend=legend; |
---|
| 2771 | if isempty(FieldName_2) |
---|
| 2772 | set(hlegend,'String',FieldName) |
---|
| 2773 | else |
---|
| 2774 | set(hlegend,'String',{FieldName;FieldName_2}) |
---|
| 2775 | end |
---|
[424] | 2776 | end |
---|
[387] | 2777 | end |
---|
| 2778 | |
---|
| 2779 | %------------------------------------------------------------------- |
---|
| 2780 | % --- translate coordinate to matrix index |
---|
| 2781 | %------------------------------------------------------------------- |
---|
| 2782 | function [indx,indy]=pos2ind(x0,rangx0,nxy) |
---|
| 2783 | indx=1+round((nxy(2)-1)*(x0-rangx0(1))/(rangx0(2)-rangx0(1)));% index x of pixel |
---|
| 2784 | indy=1+round((nxy(1)-1)*(y12-rangy0(1))/(rangy0(2)-rangy0(1)));% index y of pixel |
---|
| 2785 | |
---|
[428] | 2786 | |
---|
[387] | 2787 | %------------------------------------------------------------------- |
---|
[428] | 2788 | % --- Executes on button press in 'CheckZoom'. |
---|
| 2789 | %------------------------------------------------------------------- |
---|
| 2790 | function CheckZoom_Callback(hObject, eventdata, handles) |
---|
| 2791 | |
---|
| 2792 | if (get(handles.CheckZoom,'Value') == 1); |
---|
| 2793 | set(handles.CheckZoom,'BackgroundColor',[1 1 0]) |
---|
| 2794 | set(handles.CheckFixLimits,'Value',1)% propose by default fixed limits for the plotting axes |
---|
| 2795 | set(handles.CheckFixLimits,'BackgroundColor',[1 1 0]) |
---|
| 2796 | else |
---|
| 2797 | set(handles.CheckZoom,'BackgroundColor',[0.7 0.7 0.7]) |
---|
| 2798 | end |
---|
| 2799 | |
---|
| 2800 | %------------------------------------------------------------------- |
---|
[387] | 2801 | % --- Executes on button press in 'CheckFixLimits'. |
---|
| 2802 | %------------------------------------------------------------------- |
---|
| 2803 | function CheckFixLimits_Callback(hObject, eventdata, handles) |
---|
| 2804 | test=get(handles.CheckFixLimits,'Value'); |
---|
| 2805 | if test |
---|
| 2806 | set(handles.CheckFixLimits,'BackgroundColor',[1 1 0]) |
---|
| 2807 | else |
---|
| 2808 | set(handles.CheckFixLimits,'BackgroundColor',[0.7 0.7 0.7]) |
---|
| 2809 | update_plot(handles); |
---|
| 2810 | end |
---|
| 2811 | |
---|
| 2812 | %------------------------------------------------------------------- |
---|
[428] | 2813 | % --- Executes on button press in CheckFixAspectRatio. |
---|
| 2814 | function CheckFixAspectRatio_Callback(hObject, eventdata, handles) |
---|
| 2815 | %------------------------------------------------------------------- |
---|
| 2816 | if get(handles.CheckFixAspectRatio,'Value') |
---|
| 2817 | set(handles.CheckFixAspectRatio,'BackgroundColor',[1 1 0]) |
---|
[387] | 2818 | update_plot(handles); |
---|
| 2819 | else |
---|
[428] | 2820 | set(handles.CheckFixAspectRatio,'BackgroundColor',[0.7 0.7 0.7]) |
---|
[387] | 2821 | update_plot(handles); |
---|
| 2822 | end |
---|
| 2823 | |
---|
| 2824 | %------------------------------------------------------------------- |
---|
[428] | 2825 | function num_AspectRatio_Callback(hObject, eventdata, handles) |
---|
[387] | 2826 | %------------------------------------------------------------------- |
---|
[428] | 2827 | set(handles.CheckFixAspectRatio,'Value',1)% select the fixed aspect ratio button |
---|
| 2828 | set(handles.CheckFixAspectRatio,'BackgroundColor',[1 1 0])% mark in yellow |
---|
| 2829 | update_plot(handles); |
---|
[387] | 2830 | %------------------------------------------------------------------- |
---|
| 2831 | |
---|
[428] | 2832 | %------------------------------------------------------------------- |
---|
[387] | 2833 | |
---|
[428] | 2834 | |
---|
| 2835 | |
---|
[387] | 2836 | %------------------------------------------------------------------- |
---|
| 2837 | %----Executes on button press in 'record': records the current flags of manual correction. |
---|
| 2838 | %------------------------------------------------------------------- |
---|
| 2839 | function record_Callback(hObject, eventdata, handles) |
---|
| 2840 | % [filebase,num_i1,num_j1,num_i2,num_j2,Ext,NomType,SubDir]=read_input_file(handles); |
---|
| 2841 | [RootPath,SubDir,RootFile,FileIndices,FileExt]=read_file_boxes(handles); |
---|
[450] | 2842 | FileName=[fullfile(RootPath,SubDir,RootFile) FileIndices FileExt]; |
---|
| 2843 | %FileName=read_file_boxes(handles); |
---|
| 2844 | [erread,message]=fileattrib(FileName); |
---|
[387] | 2845 | if ~isempty(message) && ~isequal(message.UserWrite,1) |
---|
[450] | 2846 | msgbox_uvmat('ERROR',['no writting access to ' FileName]) |
---|
[387] | 2847 | return |
---|
| 2848 | end |
---|
| 2849 | test_civ2=isequal(get(handles.civ2,'BackgroundColor'),[1 1 0]); |
---|
| 2850 | test_civ1=isequal(get(handles.VelType,'BackgroundColor'),[1 1 0]); |
---|
| 2851 | if ~test_civ2 && ~test_civ1 |
---|
| 2852 | msgbox_uvmat('ERROR','manual correction only possible for CIV1 or CIV2 velocity fields') |
---|
| 2853 | end |
---|
| 2854 | if test_civ2 |
---|
| 2855 | nbname='nb_vectors2'; |
---|
| 2856 | flagname='vec2_FixFlag'; |
---|
| 2857 | attrname='fix2'; |
---|
| 2858 | end |
---|
| 2859 | if test_civ1 |
---|
| 2860 | nbname='nb_vectors'; |
---|
| 2861 | flagname='vec_FixFlag'; |
---|
| 2862 | attrname='fix'; |
---|
| 2863 | end |
---|
| 2864 | %write fix flags in the netcdf file |
---|
| 2865 | UvData=get(handles.uvmat,'UserData'); |
---|
| 2866 | hhh=which('netcdf.open');% look for built-in matlab netcdf library |
---|
| 2867 | if ~isequal(hhh,'')% case of new builtin Matlab netcdf library |
---|
[450] | 2868 | nc=netcdf.open(FileName,'NC_WRITE'); |
---|
[387] | 2869 | netcdf.reDef(nc); |
---|
| 2870 | netcdf.putAtt(nc,netcdf.getConstant('NC_GLOBAL'),attrname,1); |
---|
| 2871 | dimid = netcdf.inqDimID(nc,nbname); |
---|
| 2872 | try |
---|
| 2873 | varid = netcdf.inqVarID(nc,flagname);% look for already existing fixflag variable |
---|
| 2874 | catch |
---|
| 2875 | varid=netcdf.defVar(nc,flagname,'double',dimid);%create fixflag variable if it does not exist |
---|
| 2876 | end |
---|
| 2877 | netcdf.endDef(nc); |
---|
[511] | 2878 | netcdf.putVar(nc,varid,UvData.PlotAxes.FF); |
---|
[387] | 2879 | netcdf.close(nc); |
---|
| 2880 | else %old netcdf library |
---|
[450] | 2881 | netcdf_toolbox(FileName,AxeData,attrname,nbname,flagname) |
---|
[387] | 2882 | end |
---|
| 2883 | |
---|
| 2884 | %------------------------------------------------------------------- |
---|
| 2885 | %----Correct the netcdf file, using toolbox (old versions of Matlab). |
---|
| 2886 | %------------------------------------------------------------------- |
---|
[450] | 2887 | function netcdf_toolbox(FileName,AxeData,attrname,nbname,flagname) |
---|
| 2888 | nc=netcdf(FileName,'write'); %open netcdf file |
---|
[387] | 2889 | result=redef(nc); |
---|
| 2890 | eval(['nc.' attrname '=1;']); |
---|
| 2891 | theDim=nc(nbname) ;% get the number of velocity vectors |
---|
| 2892 | nb_vectors=size(theDim); |
---|
| 2893 | var_FixFlag=ncvar(flagname,nc);% var_FixFlag will be written as the netcdf variable vec_FixFlag |
---|
| 2894 | var_FixFlag(1:nb_vectors)=AxeData.FF;% |
---|
| 2895 | fin=close(nc); |
---|
| 2896 | |
---|
[428] | 2897 | %------------------------------------------------------------------- |
---|
[387] | 2898 | % --- Executes on button press in SubField |
---|
| 2899 | function SubField_Callback(hObject, eventdata, handles) |
---|
[428] | 2900 | %------------------------------------------------------------------- |
---|
[387] | 2901 | UvData=get(handles.uvmat,'UserData'); |
---|
| 2902 | if get(handles.SubField,'Value')==0% if the subfield button is desactivated |
---|
| 2903 | set(handles.RootPath_1,'String','') |
---|
| 2904 | set(handles.RootFile_1,'String','') |
---|
| 2905 | set(handles.SubDir_1,'String',''); |
---|
| 2906 | set(handles.FileIndex_1,'String',''); |
---|
| 2907 | set(handles.FileExt_1,'String',''); |
---|
| 2908 | set(handles.RootPath_1,'Visible','off') |
---|
| 2909 | set(handles.RootFile_1,'Visible','off') |
---|
| 2910 | set(handles.SubDir_1,'Visible','off'); |
---|
| 2911 | set(handles.NomType_1,'Visible','off'); |
---|
| 2912 | set(handles.abs_time_1,'Visible','off') |
---|
| 2913 | set(handles.FileIndex_1,'Visible','off'); |
---|
| 2914 | set(handles.FileExt_1,'Visible','off'); |
---|
[526] | 2915 | set(handles.FieldName_1,'Value',1);%set to blank state |
---|
[387] | 2916 | set(handles.VelType_1,'Value',1);%set to blank state |
---|
[428] | 2917 | set(handles.num_Opacity,'String','')% desactivate opacity setting |
---|
[387] | 2918 | if ~strcmp(get(handles.VelType,'Visible'),'on') |
---|
| 2919 | set(handles.VelType_1,'Visible','off') |
---|
| 2920 | end |
---|
| 2921 | if isfield(UvData,'XmlData_1') |
---|
| 2922 | UvData=rmfield(UvData,'XmlData_1'); |
---|
| 2923 | end |
---|
| 2924 | set(handles.uvmat,'UserData',UvData); |
---|
[515] | 2925 | transform_fct_list=get(handles.transform_fct,'String'); |
---|
| 2926 | transform_fct=transform_fct_list(get(handles.transform_fct,'Value')); |
---|
| 2927 | if strcmp(transform_fct,'sub_field') |
---|
| 2928 | set(handles.transform_fct,'Value',1)%suppress the sub_field transform |
---|
| 2929 | transform_fct_Callback(hObject, eventdata, handles); |
---|
| 2930 | else |
---|
| 2931 | run0_Callback(hObject, eventdata, handles) |
---|
| 2932 | end |
---|
[387] | 2933 | else |
---|
| 2934 | MenuBrowse_1_Callback(hObject, eventdata, handles) |
---|
| 2935 | end |
---|
| 2936 | |
---|
| 2937 | %------------------------------------------------------------------------ |
---|
| 2938 | % --- read the data displayed for the input rootfile windows (new): TODO use read_GUI |
---|
| 2939 | |
---|
| 2940 | function [RootPath,SubDir,RootFile,FileIndices,FileExt]=read_file_boxes(handles) |
---|
| 2941 | %------------------------------------------------------------------------ |
---|
| 2942 | InputFile=read_GUI(handles.InputFile); |
---|
| 2943 | RootPath=InputFile.RootPath; |
---|
| 2944 | SubDir=regexprep(InputFile.SubDir,'/|\',''); |
---|
| 2945 | RootFile=regexprep(InputFile.RootFile,'/|\',''); |
---|
| 2946 | FileIndices=InputFile.FileIndex; |
---|
| 2947 | FileExt=InputFile.FileExt; |
---|
| 2948 | |
---|
| 2949 | |
---|
| 2950 | %------------------------------------------------------------------------ |
---|
| 2951 | % ---- read the data displayed for the second input rootfile windows |
---|
| 2952 | function [RootPath_1,SubDir_1,RootFile_1,FileIndex_1,FileExt_1,NomType_1]=read_file_boxes_1(handles) |
---|
| 2953 | %------------------------------------------------------------------------ |
---|
| 2954 | RootPath_1=get(handles.RootPath_1,'String'); % read the data from the file1_input window |
---|
| 2955 | if isequal(get(handles.RootPath_1,'Visible'),'off') || isequal(RootPath_1,'"') |
---|
| 2956 | RootPath_1=get(handles.RootPath,'String'); |
---|
| 2957 | end; |
---|
| 2958 | SubDir_1=get(handles.SubDir_1,'String'); |
---|
| 2959 | if isequal(get(handles.SubDir_1,'Visible'),'off')|| isequal(SubDir_1,'"') |
---|
| 2960 | SubDir_1=get(handles.SubDir,'String'); |
---|
| 2961 | end |
---|
| 2962 | SubDir_1=regexprep(SubDir_1,'\<[\\/]|[\\/]\>','');%suppress possible / or \ separator at the beginning or the end of the string |
---|
| 2963 | RootFile_1=get(handles.RootFile_1,'String'); |
---|
| 2964 | if isequal(get(handles.RootFile_1,'Visible'),'off') || isequal(RootFile_1,'"') |
---|
| 2965 | RootFile_1=get(handles.RootFile,'String'); |
---|
| 2966 | end |
---|
| 2967 | RootFile_1=regexprep(RootFile_1,'\<[\\/]|[\\/]\>','');%suppress possible / or \ separator at the beginning or the end of the string |
---|
| 2968 | FileIndex_1=get(handles.FileIndex_1,'String'); |
---|
| 2969 | if isequal(get(handles.FileIndex_1,'Visible'),'off')|| isequal(FileIndex_1,'"') |
---|
| 2970 | FileIndex_1=get(handles.FileIndex,'String'); |
---|
| 2971 | end |
---|
| 2972 | FileExt_1=get(handles.FileExt_1,'String'); |
---|
| 2973 | if isequal(get(handles.FileExt_1,'Visible'),'off') || isequal(FileExt_1,'"') |
---|
| 2974 | FileExt_1=get(handles.FileExt,'String');%read FileExt by default |
---|
| 2975 | end |
---|
| 2976 | NomType_1=get(handles.NomType_1,'String'); |
---|
| 2977 | if isequal(get(handles.NomType_1,'Visible'),'off') || isequal(NomType_1,'"') |
---|
| 2978 | NomType_1=get(handles.NomType,'String');%read FileExt by default |
---|
| 2979 | end |
---|
| 2980 | %------------------------------------------------------------------------ |
---|
[526] | 2981 | % --- Executes on menu selection FieldName |
---|
| 2982 | function FieldName_Callback(hObject, eventdata, handles) |
---|
[387] | 2983 | %------------------------------------------------------------------------ |
---|
[526] | 2984 | list_fields=get(handles.FieldName,'String');% list menu fields |
---|
| 2985 | index_fields=get(handles.FieldName,'Value');% selected string index |
---|
[387] | 2986 | field= list_fields{index_fields(1)}; % selected string |
---|
| 2987 | if isequal(field,'get_field...') |
---|
| 2988 | set(handles.FixVelType,'visible','off') |
---|
| 2989 | set(handles.VelType,'visible','off') |
---|
| 2990 | set(handles.VelType_1,'visible','off') |
---|
| 2991 | [RootPath,SubDir,RootFile,FileIndices,FileExt]=read_file_boxes(handles); |
---|
[450] | 2992 | FileName=[fullfile(RootPath,SubDir,RootFile) FileIndices FileExt]; |
---|
[387] | 2993 | hget_field=findobj(allchild(0),'name','get_field'); |
---|
| 2994 | if ~isempty(hget_field) |
---|
| 2995 | delete(hget_field) |
---|
| 2996 | end |
---|
[526] | 2997 | get_field(FileName); |
---|
[517] | 2998 | return %no further action |
---|
[387] | 2999 | end |
---|
[517] | 3000 | |
---|
[387] | 3001 | UvData=get(handles.uvmat,'UserData'); |
---|
| 3002 | |
---|
| 3003 | %read the rootfile input display |
---|
| 3004 | [RootPath,SubDir,RootFile,FileIndices,FileExt]=read_file_boxes(handles); |
---|
| 3005 | FileName=[fullfile(RootPath,SubDir,RootFile) FileIndices FileExt]; |
---|
| 3006 | [tild,tild,tild,i1,i2,j1,j2,tild,NomType]=fileparts_uvmat(['xxx' get(handles.FileIndex,'String') FileExt]); |
---|
| 3007 | if isequal(field,'image') |
---|
[494] | 3008 | if isfield(UvData.Field,'Civ2_ImageA')%get the corresponding input image in the netcdf file |
---|
| 3009 | imagename=UvData.Field.Civ2_ImageA; |
---|
| 3010 | elseif isfield(UvData.Field,'Civ1_ImageA')% |
---|
| 3011 | imagename=UvData.Field.Civ1_ImageA; |
---|
| 3012 | else |
---|
| 3013 | SubDirBase=regexprep(SubDir,'\..*','');%take the root part of SubDir, before the first dot '.' |
---|
| 3014 | imagename=fullfile_uvmat(RootPath,SubDirBase,RootFile,'.png',NomType,i1,[],j1,[]); |
---|
| 3015 | end |
---|
[387] | 3016 | if ~exist(imagename,'file') |
---|
| 3017 | [FileName,PathName] = uigetfile( ... |
---|
| 3018 | {'*.png;*.jpg;*.tif;*.avi;*.AVI;*.vol', ' (*.png, .tif, *.avi,*.vol)'; |
---|
| 3019 | '*.jpg',' jpeg image files'; ... |
---|
| 3020 | '*.png','.png image files'; ... |
---|
| 3021 | '*.tif','.tif image files'; ... |
---|
| 3022 | '*.avi;*.AVI','.avi movie files'; ... |
---|
| 3023 | '*.vol','.volume images (png)'; ... |
---|
| 3024 | '*.*', 'All Files (*.*)'}, ... |
---|
[530] | 3025 | 'Pick an image',imagename); |
---|
| 3026 | if ~ischar(FileName),return,end %abandon if the browser is cancelled |
---|
[387] | 3027 | imagename=[PathName FileName]; |
---|
| 3028 | end |
---|
| 3029 | % display the selected field and related information |
---|
[406] | 3030 | display_file_name(handles,imagename)%display the image |
---|
[387] | 3031 | return |
---|
| 3032 | else |
---|
| 3033 | ext=get(handles.FileExt,'String'); |
---|
| 3034 | if ~isequal(ext,'.nc') %find the new NomType if the previous display was not already a netcdf file |
---|
| 3035 | [FileName,PathName] = uigetfile( ... |
---|
| 3036 | {'*.nc', ' (*.nc)'; |
---|
| 3037 | '*.nc',' netcdf files'; ... |
---|
| 3038 | '*.*', 'All Files (*.*)'}, ... |
---|
| 3039 | 'Pick a netcdf file',FileBase); |
---|
[530] | 3040 | if ~ischar(FileName),return,end %abandon if the browser is cancelled |
---|
[450] | 3041 | FullFileName=[PathName FileName]; |
---|
[387] | 3042 | % display the selected field and related information |
---|
[450] | 3043 | display_file_name( handles,FullFileName) |
---|
[387] | 3044 | return |
---|
| 3045 | end |
---|
| 3046 | end |
---|
| 3047 | indices=fullfile_uvmat('','','','',NomType,i1,i2,j1,j2); |
---|
| 3048 | set(handles.FileIndex,'String',indices) |
---|
| 3049 | % set(handles.NomType,'String',NomType) |
---|
| 3050 | |
---|
| 3051 | %common to Fields_1_Callback |
---|
[526] | 3052 | list_fields_1=get(handles.FieldName_1,'String');% list menu fields |
---|
[517] | 3053 | field_1=''; |
---|
| 3054 | if ~isempty(list_fields_1) |
---|
[526] | 3055 | field_1= list_fields_1{get(handles.FieldName_1,'Value')}; % selected string |
---|
[517] | 3056 | end |
---|
[387] | 3057 | if isequal(field,'image')||isequal(field_1,'image') |
---|
[546] | 3058 | set(handles.TitleNpxy,'Visible','on')% visible npx,pxcm... buttons |
---|
[387] | 3059 | set(handles.num_Npx,'Visible','on') |
---|
| 3060 | set(handles.num_Npy,'Visible','on') |
---|
| 3061 | else |
---|
[546] | 3062 | set(handles.TitleNpxy,'Visible','off')% visible npx,pxcm... buttons |
---|
[387] | 3063 | set(handles.num_Npx,'Visible','off') |
---|
| 3064 | set(handles.num_Npy,'Visible','off') |
---|
| 3065 | end |
---|
| 3066 | if ~(isfield(UvData,'NewSeries')&&isequal(UvData.NewSeries,1)) |
---|
| 3067 | run0_Callback(hObject, eventdata, handles) |
---|
| 3068 | end |
---|
| 3069 | |
---|
| 3070 | %--------------------------------------------------- |
---|
[526] | 3071 | % --- Executes on menu selection FieldName |
---|
| 3072 | function FieldName_1_Callback(hObject, eventdata, handles) |
---|
[387] | 3073 | %------------------------------------------------- |
---|
| 3074 | %% read input data |
---|
| 3075 | check_new=~get(handles.SubField,'Value'); %check_new=1 if a second field was not previously entered |
---|
| 3076 | UvData=get(handles.uvmat,'UserData'); |
---|
| 3077 | if check_new && isfield(UvData,'XmlData') |
---|
| 3078 | UvData.XmlData{2}=UvData.XmlData{1}; |
---|
| 3079 | end |
---|
[389] | 3080 | if isfield(UvData,'Field_1') |
---|
| 3081 | UvData=rmfield(UvData,'Field_1');% remove the stored second field (a new one needs to be read) |
---|
| 3082 | end |
---|
[450] | 3083 | UvData.FileName_1='';% desactivate the use of a constant second file |
---|
[526] | 3084 | list_fields=get(handles.FieldName,'String');% list menu fields |
---|
| 3085 | field= list_fields{get(handles.FieldName,'Value')}; % selected string |
---|
| 3086 | list_fields=get(handles.FieldName_1,'String');% list menu fields |
---|
| 3087 | field_1= list_fields{get(handles.FieldName_1,'Value')}; % selected string for the second field |
---|
[405] | 3088 | if isempty(field_1)%||(numel(UvData.FileType)>=2 && strcmp(UvData.FileType{2},'image')) |
---|
[387] | 3089 | set(handles.SubField,'Value',0) |
---|
| 3090 | SubField_Callback(hObject, eventdata, handles) |
---|
[428] | 3091 | return |
---|
[405] | 3092 | else |
---|
| 3093 | set(handles.SubField,'Value',1)%state that a second field is now entered |
---|
[387] | 3094 | end |
---|
| 3095 | |
---|
| 3096 | %% read the rootfile input display |
---|
[405] | 3097 | [RootPath_1,SubDir_1,RootFile_1,FileIndex_1,FileExt_1]=read_file_boxes_1(handles); |
---|
[450] | 3098 | FileName_1=[fullfile(RootPath_1,SubDir_1,RootFile_1) FileIndex_1 FileExt_1]; |
---|
[387] | 3099 | [tild,tild,tild,i1,i2,j1,j2]=fileparts_uvmat(get(handles.FileIndex,'String')); |
---|
| 3100 | switch field_1 |
---|
| 3101 | case 'get_field...' |
---|
| 3102 | set_veltype_display(0) % no veltype display |
---|
| 3103 | hget_field=findobj(allchild(0),'name','get_field_1'); |
---|
| 3104 | if ~isempty(hget_field) |
---|
| 3105 | delete(hget_field) |
---|
| 3106 | end |
---|
[450] | 3107 | hget_field=get_field(FileName_1); |
---|
[387] | 3108 | set(hget_field,'name','get_field_1') |
---|
| 3109 | hhget_field=guidata(hget_field); |
---|
| 3110 | set(hhget_field.list_fig,'Value',1) |
---|
| 3111 | set(hhget_field.list_fig,'String',{'uvmat'}) |
---|
[428] | 3112 | if check_new |
---|
| 3113 | UvData.FileType{2}=UvData.FileType{1}; |
---|
| 3114 | set(handles.FileIndex_1,'String',get(handles.FileIndex,'String')) |
---|
| 3115 | set(handles.uvmat,'UserData',UvData) |
---|
| 3116 | end |
---|
[387] | 3117 | case 'image' |
---|
[494] | 3118 | % get the image name corresponding to the current netcdf name (no unique correspondance) |
---|
| 3119 | if isfield(UvData.Field,'Civ2_ImageA')%get the corresponding input image in the netcdf file |
---|
| 3120 | imagename=UvData.Field.Civ2_ImageA; |
---|
| 3121 | elseif isfield(UvData.Field,'Civ1_ImageA')% |
---|
| 3122 | imagename=UvData.Field.Civ1_ImageA; |
---|
| 3123 | else |
---|
| 3124 | SubDirBase=regexprep(SubDir_1,'\..*','');%take the root part of SubDir, before the first dot '.' |
---|
| 3125 | imagename=fullfile_uvmat(RootPath_1,SubDirBase,RootFile_1,'.png',get(handles.NomType,'String'),i1,[],j1); |
---|
| 3126 | end |
---|
[405] | 3127 | if ~exist(imagename,'file') % browse for images if it is not found |
---|
[387] | 3128 | [FileName,PathName] = uigetfile( ... |
---|
| 3129 | {'*.png;*.jpg;*.tif;*.avi;*.AVI;*.vol', ' (*.png, .tif, *.avi,*.vol)'; |
---|
| 3130 | '*.jpg',' jpeg image files'; ... |
---|
| 3131 | '*.png','.png image files'; ... |
---|
| 3132 | '*.tif','.tif image files'; ... |
---|
| 3133 | '*.avi;*.AVI','.avi movie files'; ... |
---|
| 3134 | '*.vol','.volume images (png)'; ... |
---|
| 3135 | '*.*', 'All Files (*.*)'}, ... |
---|
| 3136 | 'Pick an image',imagename); |
---|
[530] | 3137 | if ~ischar(FileName),return,end %abandon if the browser is cancelled |
---|
[387] | 3138 | imagename=[PathName FileName]; |
---|
| 3139 | end |
---|
[405] | 3140 | if ~ischar(imagename)% quit if the browser has been closed |
---|
| 3141 | set(handles.SubField,'Value',0) |
---|
| 3142 | else %valid browser input: display the selected image |
---|
[546] | 3143 | set(handles.TitleNpxy,'Visible','on')% visible npx,pxcm... buttons |
---|
[405] | 3144 | set(handles.num_Npx,'Visible','on') |
---|
| 3145 | set(handles.num_Npy,'Visible','on') |
---|
[406] | 3146 | display_file_name(handles,imagename,2)%display the imag |
---|
[405] | 3147 | end |
---|
[387] | 3148 | otherwise |
---|
| 3149 | if check_new |
---|
| 3150 | UvData.FileType{2}=UvData.FileType{1}; |
---|
| 3151 | set(handles.FileIndex_1,'String',get(handles.FileIndex,'String')) |
---|
| 3152 | set(handles.FileExt_1,'String',get(handles.FileExt,'String')) |
---|
| 3153 | end |
---|
| 3154 | if ~isequal(field,'image') |
---|
[546] | 3155 | set(handles.TitleNpxy,'Visible','off')% visible npx,pxcm... buttons |
---|
[387] | 3156 | set(handles.num_Npx,'Visible','off') |
---|
| 3157 | set(handles.num_Npy,'Visible','off') |
---|
| 3158 | end |
---|
| 3159 | set(handles.uvmat,'UserData',UvData) |
---|
| 3160 | if ~(isfield(UvData,'NewSeries')&&isequal(UvData.NewSeries,1)) |
---|
| 3161 | run0_Callback(hObject, eventdata, handles) |
---|
| 3162 | end |
---|
| 3163 | end |
---|
| 3164 | |
---|
| 3165 | %------------------------------------------------------------------------ |
---|
| 3166 | % --- set the visibility of relevant velocity type menus: |
---|
| 3167 | function menu=set_veltype_display(Civ,FileType) |
---|
| 3168 | %------------------------------------------------------------------------ |
---|
| 3169 | if ~exist('FileType','var') |
---|
| 3170 | FileType='civx'; |
---|
| 3171 | end |
---|
| 3172 | switch FileType |
---|
| 3173 | case 'civx' |
---|
[389] | 3174 | menu={'civ1';'interp1';'filter1';'civ2';'interp2';'filter2'}; |
---|
| 3175 | if isequal(Civ,0) |
---|
| 3176 | imax=0; |
---|
| 3177 | elseif isequal(Civ,1) || isequal(Civ,2) |
---|
| 3178 | imax=1; |
---|
| 3179 | elseif isequal(Civ,3) |
---|
| 3180 | imax=3; |
---|
| 3181 | elseif isequal(Civ,4) || isequal(Civ,5) |
---|
| 3182 | imax=4; |
---|
| 3183 | elseif isequal(Civ,6) %patch2 |
---|
| 3184 | imax=6; |
---|
| 3185 | end |
---|
[387] | 3186 | case 'civdata' |
---|
[389] | 3187 | menu={'civ1';'filter1';'civ2';'filter2'}; |
---|
| 3188 | if isequal(Civ,0) |
---|
| 3189 | imax=0; |
---|
| 3190 | elseif isequal(Civ,1) || isequal(Civ,2) |
---|
| 3191 | imax=1; |
---|
| 3192 | elseif isequal(Civ,3) |
---|
| 3193 | imax=2; |
---|
| 3194 | elseif isequal(Civ,4) || isequal(Civ,5) |
---|
| 3195 | imax=3; |
---|
| 3196 | elseif isequal(Civ,6) %patch2 |
---|
| 3197 | imax=4; |
---|
| 3198 | end |
---|
[387] | 3199 | end |
---|
| 3200 | menu=menu(1:imax); |
---|
| 3201 | |
---|
| 3202 | %------------------------------------------------------------------------ |
---|
[402] | 3203 | % --- Executes on button press in FixVelType. |
---|
| 3204 | function FixVelType_Callback(hObject, eventdata, handles) |
---|
| 3205 | %------------------------------------------------------------------------ |
---|
[405] | 3206 | % refresh the current plot if the fixed veltype is unselected |
---|
| 3207 | if ~get(handles.FixVelType,'Value') |
---|
[402] | 3208 | run0_Callback(hObject, eventdata, handles) |
---|
| 3209 | end |
---|
| 3210 | |
---|
| 3211 | %------------------------------------------------------------------------ |
---|
[387] | 3212 | % --- Executes on button press in VelType. |
---|
| 3213 | function VelType_Callback(hObject, eventdata, handles) |
---|
| 3214 | %------------------------------------------------------------------------ |
---|
| 3215 | set(handles.FixVelType,'Value',1) |
---|
| 3216 | run0_Callback(hObject, eventdata, handles) |
---|
| 3217 | |
---|
| 3218 | %------------------------------------------------------------------------ |
---|
[515] | 3219 | % --- Executes on choice selection in VelType_1. |
---|
[387] | 3220 | function VelType_1_Callback(hObject, eventdata, handles) |
---|
| 3221 | %------------------------------------------------------------------------ |
---|
| 3222 | set(handles.FixVelType,'Value',1)% the velocity type is now imposed by the GUI (not automatic) |
---|
[389] | 3223 | UvData=get(handles.uvmat,'UserData'); |
---|
[515] | 3224 | set(handles.run0,'BackgroundColor',[1 1 0])%paint run0 button in yellow to indicate its activation |
---|
[387] | 3225 | drawnow |
---|
[515] | 3226 | InputFile=read_GUI(handles.InputFile);% read the input file parameters |
---|
| 3227 | [RootPath,SubDir,RootFile,FileIndex,FileExt]=read_file_boxes(handles); |
---|
| 3228 | [RootPath_1,SubDir_1,RootFile_1,FileIndex_1,FileExt_1]=read_file_boxes_1(handles); |
---|
| 3229 | FileName=[fullfile(RootPath,SubDir,RootFile) FileIndex FileExt];% name of the first input file |
---|
[405] | 3230 | |
---|
[515] | 3231 | check_refresh=0; |
---|
[389] | 3232 | if isempty(InputFile.VelType_1) |
---|
[515] | 3233 | FileName_1='';% we plot the first input field without the second field |
---|
[387] | 3234 | set(handles.SubField,'Value',0) |
---|
[515] | 3235 | SubField_Callback(hObject, eventdata, handles)% activate SubField_Callback and refresh current display, removing the second field |
---|
[387] | 3236 | elseif get(handles.SubField,'Value')% if subfield is already 'on' |
---|
[515] | 3237 | FileName_1=[fullfile(RootPath_1,SubDir_1,RootFile_1) FileIndex_1 FileExt_1];% name of the second input file |
---|
| 3238 | check_refresh=1;%will refresh the current display |
---|
| 3239 | else% we introduce the same file (with a different field) for the second series |
---|
| 3240 | FileName_1=FileName;% we compare two fields in the same file |
---|
[389] | 3241 | UvData.FileType{2}=UvData.FileType{1}; |
---|
[515] | 3242 | UvData.XmlData{2}= UvData.XmlData{1}; |
---|
[387] | 3243 | set(handles.SubField,'Value',1) |
---|
[515] | 3244 | transform=get(handles.path_transform,'UserData'); |
---|
| 3245 | if (~isa(transform,'function_handle')||nargin(transform)<3) |
---|
| 3246 | set(handles.transform_fct,'value',2); % set transform to sub_field if the current fct doe not accept two input fields |
---|
| 3247 | transform_fct_Callback(hObject, eventdata, handles)% activate transform_fct_Callback and refresh current display |
---|
| 3248 | else |
---|
| 3249 | check_refresh=1; |
---|
| 3250 | end |
---|
[387] | 3251 | end |
---|
| 3252 | |
---|
[515] | 3253 | % refresh the current display if it has not been done previously |
---|
| 3254 | if check_refresh |
---|
| 3255 | UvData.FileName_1='';% desactivate the use of a constant second file |
---|
| 3256 | set(handles.uvmat,'UserData',UvData) |
---|
| 3257 | num_i1=stra2num(get(handles.i1,'String')); |
---|
| 3258 | num_i2=stra2num(get(handles.i2,'String')); |
---|
| 3259 | num_j1=stra2num(get(handles.j1,'String')); |
---|
| 3260 | num_j2=stra2num(get(handles.j2,'String')); |
---|
| 3261 | [tild,tild,tild,i1_1,i2_1,j1_1,j2_1]=fileparts_uvmat(['xx' FileIndex_1]); |
---|
| 3262 | errormsg=refresh_field(handles,FileName,FileName_1,num_i1,num_i2,num_j1,num_j2,i1_1,i2_1,j1_1,j2_1); |
---|
| 3263 | if ~isempty(errormsg) |
---|
| 3264 | msgbox_uvmat('ERROR',errormsg); |
---|
| 3265 | else |
---|
| 3266 | set(handles.i1,'BackgroundColor',[1 1 1]) |
---|
| 3267 | set(handles.i2,'BackgroundColor',[1 1 1]) |
---|
| 3268 | set(handles.j1,'BackgroundColor',[1 1 1]) |
---|
| 3269 | set(handles.j2,'BackgroundColor',[1 1 1]) |
---|
| 3270 | set(handles.FileIndex,'BackgroundColor',[1 1 1]) |
---|
| 3271 | set(handles.FileIndex_1,'BackgroundColor',[1 1 1]) |
---|
| 3272 | end |
---|
| 3273 | set(handles.run0,'BackgroundColor',[1 0 0]) |
---|
[387] | 3274 | end |
---|
| 3275 | |
---|
| 3276 | %----------------------------------------------- |
---|
| 3277 | % --- reset civ buttons |
---|
| 3278 | function reset_vel_type(handles_civ0,handle1) |
---|
| 3279 | for ibutton=1:length(handles_civ0) |
---|
| 3280 | set(handles_civ0(ibutton),'BackgroundColor',[0.831 0.816 0.784]) |
---|
| 3281 | set(handles_civ0(ibutton),'Value',0) |
---|
| 3282 | end |
---|
| 3283 | if exist('handle1','var')%handles of selected button |
---|
| 3284 | set(handle1,'BackgroundColor',[1 1 0]) |
---|
| 3285 | end |
---|
| 3286 | |
---|
| 3287 | %------------------------------------------------------- |
---|
| 3288 | % --- Executes on button press in MENUVOLUME. |
---|
| 3289 | %------------------------------------------------------- |
---|
| 3290 | function VOLUME_Callback(hObject, eventdata, handles) |
---|
| 3291 | %errordlg('command VOL not implemented yet') |
---|
| 3292 | if ishandle(handles.UVMAT_title) |
---|
| 3293 | delete(handles.UVMAT_title) |
---|
| 3294 | end |
---|
| 3295 | UvData=get(handles.uvmat,'UserData');%read UvData properties stored on the uvmat interface |
---|
| 3296 | if isequal(get(handles.VOLUME,'Value'),1) |
---|
| 3297 | set(handles.CheckZoom,'Value',0) |
---|
| 3298 | set(handles.CheckZoom,'BackgroundColor',[0.7 0.7 0.7]) |
---|
| 3299 | set(handles.edit_vect,'Value',0) |
---|
| 3300 | edit_vect_Callback(hObject, eventdata, handles) |
---|
| 3301 | set(handles.edit_object,'Value',0) |
---|
| 3302 | set(handles.edit_object,'BackgroundColor',[0.7 0.7 0.7]) |
---|
| 3303 | % set(handles.cal,'Value',0) |
---|
| 3304 | % set(handles.cal,'BackgroundColor',[0 1 0]) |
---|
| 3305 | set(handles.edit_vect,'Value',0) |
---|
| 3306 | edit_vect_Callback(hObject, eventdata, handles) |
---|
| 3307 | %initiate set_object GUI |
---|
| 3308 | data.Name='VOLUME'; |
---|
| 3309 | if isfield(UvData,'CoordType') |
---|
| 3310 | data.CoordType=UvData.CoordType; |
---|
| 3311 | end |
---|
[404] | 3312 | if isfield(UvData.Field,'Mesh')&~isempty(UvData.Field.Mesh) |
---|
| 3313 | data.RangeX=[UvData.Field.XMin UvData.Field.XMax]; |
---|
| 3314 | data.RangeY=[UvData.Field.YMin UvData.Field.YMax]; |
---|
| 3315 | data.DX=UvData.Field.Mesh; |
---|
| 3316 | data.DY=UvData.Field.Mesh; |
---|
[387] | 3317 | elseif isfield(UvData.Field,'AX')&isfield(UvData.Field,'AY')& isfield(UvData.Field,'A')%only image |
---|
| 3318 | np=size(UvData.Field.A); |
---|
| 3319 | meshx=(UvData.Field.AX(end)-UvData.Field.AX(1))/np(2); |
---|
| 3320 | meshy=abs(UvData.Field.AY(end)-UvData.Field.AY(1))/np(1); |
---|
| 3321 | data.RangeY=max(meshx,meshy); |
---|
| 3322 | data.RangeX=max(meshx,meshy); |
---|
| 3323 | data.DX=max(meshx,meshy); |
---|
| 3324 | end |
---|
| 3325 | data.ParentButton=handles.VOLUME; |
---|
| 3326 | PlotHandles=get_plot_handles(handles);%get the handles of the interface elements setting the plotting parameters |
---|
| 3327 | [hset_object,UvData.sethandles]=set_object(data,PlotHandles);% call the set_object interface with action on haxes, |
---|
| 3328 | % associate the set_object interface handle to the plotting axes |
---|
[511] | 3329 | set(hset_object,'Position',get(handles.uvmat,'Position')+UvData.OpenParam.PosSetObject) |
---|
[387] | 3330 | UvData.MouseAction='create_object'; |
---|
| 3331 | else |
---|
| 3332 | set(handles.VOLUME,'BackgroundColor',[0 1 0]) |
---|
| 3333 | end |
---|
| 3334 | set(handles.uvmat,'UserData',UvData) |
---|
| 3335 | |
---|
| 3336 | %------------------------------------------------------- |
---|
| 3337 | function edit_vect_Callback(hObject, eventdata, handles) |
---|
| 3338 | %------------------------------------------------------- |
---|
| 3339 | % |
---|
| 3340 | % UvData=get(handles.uvmat,'UserData');%read UvData properties stored on the uvmat interface |
---|
| 3341 | if isequal(get(handles.edit_vect,'Value'),1) |
---|
| 3342 | test_civ2=isequal(get(handles.civ2,'BackgroundColor'),[1 1 0]); |
---|
| 3343 | test_civ1=isequal(get(handles.VelType,'BackgroundColor'),[1 1 0]); |
---|
| 3344 | if ~test_civ2 && ~test_civ1 |
---|
| 3345 | msgbox_uvmat('ERROR','manual correction only possible for CIV1 or CIV2 velocity fields') |
---|
| 3346 | end |
---|
| 3347 | set(handles.record,'Visible','on') |
---|
| 3348 | set(handles.edit_vect,'BackgroundColor',[1 1 0]) |
---|
| 3349 | set(handles.edit_object,'Value',0) |
---|
| 3350 | set(handles.CheckZoom,'Value',0) |
---|
| 3351 | set(handles.CheckZoom,'BackgroundColor',[0.7 0.7 0.7]) |
---|
| 3352 | % set(handles.create,'Value',0) |
---|
| 3353 | % set(handles.create,'BackgroundColor',[0 1 0]) |
---|
| 3354 | set(handles.edit_object,'BackgroundColor',[0.7 0.7 0.7]) |
---|
| 3355 | set(gcf,'Pointer','arrow') |
---|
| 3356 | % UvData.MouseAction='edit_vect'; |
---|
| 3357 | else |
---|
| 3358 | set(handles.record,'Visible','off') |
---|
| 3359 | set(handles.edit_vect,'BackgroundColor',[0.7 0.7 0.7]) |
---|
| 3360 | end |
---|
| 3361 | |
---|
| 3362 | %---------------------------------------------- |
---|
| 3363 | function save_mask_Callback(hObject, eventdata, handles) |
---|
| 3364 | %----------------------------------------------------------------------- |
---|
| 3365 | UvData=get(handles.uvmat,'UserData'); |
---|
| 3366 | |
---|
| 3367 | flag=1; |
---|
| 3368 | npx=size(UvData.Field.A,2); |
---|
| 3369 | npy=size(UvData.Field.A,1); |
---|
| 3370 | xi=0.5:npx-0.5; |
---|
| 3371 | yi=0.5:npy-0.5; |
---|
| 3372 | [Xi,Yi]=meshgrid(xi,yi); |
---|
| 3373 | if isfield(UvData,'Object') |
---|
| 3374 | for iobj=1:length(UvData.Object) |
---|
| 3375 | ObjectData=UvData.Object{iobj}; |
---|
| 3376 | if isfield(ObjectData,'ProjMode') &&(isequal(ObjectData.ProjMode,'mask_inside')||isequal(ObjectData.ProjMode,'mask_outside')); |
---|
| 3377 | flagobj=1; |
---|
| 3378 | testphys=0; %coordinates in pixels by default |
---|
| 3379 | if isfield(ObjectData,'CoordType') && isequal(ObjectData.CoordType,'phys') |
---|
| 3380 | if isfield(UvData,'XmlData')&& isfield(UvData.XmlData{1},'GeometryCalib') |
---|
| 3381 | Calib=UvData.XmlData{1}.GeometryCalib; |
---|
| 3382 | testphys=1; |
---|
| 3383 | end |
---|
| 3384 | end |
---|
| 3385 | if isfield(ObjectData,'Coord')& isfield(ObjectData,'Style') |
---|
| 3386 | if isequal(ObjectData.Type,'polygon') |
---|
| 3387 | X=ObjectData.Coord(:,1); |
---|
| 3388 | Y=ObjectData.Coord(:,2); |
---|
| 3389 | if testphys |
---|
| 3390 | [X,Y]=px_XYZ(Calib,X,Y,0);% to generalise with 3D cases |
---|
| 3391 | end |
---|
| 3392 | flagobj=~inpolygon(Xi,Yi,X',Y');%=0 inside the polygon, 1 outside |
---|
| 3393 | elseif isequal(ObjectData.Type,'ellipse') |
---|
| 3394 | if testphys |
---|
| 3395 | %[X,Y]=px_XYZ(Calib,X,Y,0);% TODO:create a polygon boundary and transform to phys |
---|
| 3396 | end |
---|
| 3397 | RangeX=max(ObjectData.RangeX); |
---|
| 3398 | RangeY=max(ObjectData.RangeY); |
---|
| 3399 | X2Max=RangeX*RangeX; |
---|
| 3400 | Y2Max=RangeY*RangeY; |
---|
| 3401 | distX=(Xi-ObjectData.Coord(1,1)); |
---|
| 3402 | distY=(Yi-ObjectData.Coord(1,2)); |
---|
| 3403 | flagobj=(distX.*distX/X2Max+distY.*distY/Y2Max)>1; |
---|
| 3404 | elseif isequal(ObjectData.Type,'rectangle') |
---|
| 3405 | if testphys |
---|
| 3406 | %[X,Y]=px_XYZ(Calib,X,Y,0);% TODO:create a polygon boundary and transform to phys |
---|
| 3407 | end |
---|
| 3408 | distX=abs(Xi-ObjectData.Coord(1,1)); |
---|
| 3409 | distY=abs(Yi-ObjectData.Coord(1,2)); |
---|
| 3410 | flagobj=distX>max(ObjectData.RangeX) | distY>max(ObjectData.RangeY); |
---|
| 3411 | end |
---|
| 3412 | if isequal(ObjectData.ProjMode,'mask_outside') |
---|
| 3413 | flagobj=~flagobj; |
---|
| 3414 | end |
---|
| 3415 | flag=flag & flagobj; |
---|
| 3416 | end |
---|
| 3417 | end |
---|
| 3418 | end |
---|
| 3419 | end |
---|
| 3420 | % flag=~flag; |
---|
| 3421 | %mask name |
---|
| 3422 | RootPath=get(handles.RootPath,'String'); |
---|
| 3423 | RootFile=get(handles.RootFile,'String'); |
---|
| 3424 | RootFile=regexprep(RootFile,'\<[\\/]|[\\/]\>','');%suppress possible / or \ separator at the beginning or the end of the string |
---|
| 3425 | filebase=fullfile(RootPath,RootFile); |
---|
| 3426 | list=get(handles.masklevel,'String'); |
---|
| 3427 | masknumber=num2str(length(list)); |
---|
| 3428 | maskindex=get(handles.masklevel,'Value'); |
---|
| 3429 | mask_name=fullfile_uvmat(RootPath,SubDir,[RootFile '_' masknumber 'mask'],'.png','_1',maskindex); |
---|
| 3430 | %mask_name=name_generator([filebase '_' masknumber 'mask'],maskindex,1,'.png','_i'); |
---|
| 3431 | imflag=uint8(255*(0.392+0.608*flag));% =100 for flag=0 (vectors not computed when 20<imflag<200) |
---|
| 3432 | imflag=flipdim(imflag,1); |
---|
| 3433 | % imflag=uint8(255*flag);% =0 for flag=0 (vectors=0 when 20<imflag<200) |
---|
| 3434 | msgbox_uvmat('CONFIRMATION',[mask_name ' saved']) |
---|
| 3435 | imwrite(imflag,mask_name,'BitDepth',8); |
---|
| 3436 | |
---|
| 3437 | %display the mask |
---|
| 3438 | figure; |
---|
| 3439 | vec=linspace(0,1,256);%define a linear greyscale colormap |
---|
| 3440 | map=[vec' vec' vec']; |
---|
| 3441 | colormap(map) |
---|
| 3442 | |
---|
| 3443 | image(imflag); |
---|
| 3444 | |
---|
| 3445 | %------------------------------------------------------------------- |
---|
| 3446 | %------------------------------------------------------------------- |
---|
| 3447 | % - FUNCTIONS FOR SETTING PLOTTING PARAMETERS |
---|
| 3448 | |
---|
| 3449 | %------------------------------------------------------------------ |
---|
| 3450 | %------------------------------------------------------------- |
---|
| 3451 | % --- Executes on selection change in transform_fct. |
---|
[508] | 3452 | |
---|
[387] | 3453 | function transform_fct_Callback(hObject, eventdata, handles) |
---|
| 3454 | %------------------------------------------------------------- |
---|
| 3455 | UvData=get(handles.uvmat,'UserData'); |
---|
[508] | 3456 | menu=get(handles.transform_fct,'String');refresh |
---|
[507] | 3457 | ichoice=get(handles.transform_fct,'Value');%item number in the menu |
---|
| 3458 | transform_name=menu{ichoice};% choice of the transform fct |
---|
| 3459 | list_path=get(handles.transform_fct,'UserData'); |
---|
| 3460 | |
---|
| 3461 | %% add a new item to the menu if the option 'more...' has been selected |
---|
[508] | 3462 | prev_path=fullfile(get(handles.path_transform,'String')); |
---|
| 3463 | if ~exist(prev_path,'dir') |
---|
| 3464 | prev_path=fullfile(fileparts(which('uvmat')),'transform_field'); |
---|
| 3465 | end |
---|
[507] | 3466 | if strcmp(transform_name,'more...'); |
---|
[387] | 3467 | [FileName, PathName] = uigetfile( ... |
---|
[507] | 3468 | {'*.m', ' (*.m)'; |
---|
[387] | 3469 | '*.m', '.m files '; ... |
---|
| 3470 | '*.*', 'All Files (*.*)'}, ... |
---|
[508] | 3471 | 'Pick the transform function', prev_path); |
---|
[530] | 3472 | if ~ischar(FileName),return,end %abandon if the browser is cancelled |
---|
[507] | 3473 | path_transform_fct =fullfile(PathName,FileName); |
---|
| 3474 | if isempty(regexp(FileName,'.m$'))% detect file extension .m |
---|
[387] | 3475 | msgbox_uvmat('ERROR','a Matlab function .m must be introduced'); |
---|
| 3476 | return |
---|
[507] | 3477 | else |
---|
| 3478 | transform_name=regexprep(FileName,'.m',''); |
---|
| 3479 | end |
---|
| 3480 | ichoice=find(strcmp(transform_name,menu),1);%look for the selected fct in the existing menu |
---|
| 3481 | if isempty(ichoice)% if the item is not found, add it to the menu (before 'more...' and select it) |
---|
| 3482 | menu=[menu(1:end-1);{transform_name};{'more...'}]; |
---|
| 3483 | ichoice=numel(menu)-1; |
---|
| 3484 | end |
---|
| 3485 | list_path{ichoice}=PathName;%update the list fo fct paths |
---|
[508] | 3486 | set(handles.transform_fct,'String',menu) |
---|
| 3487 | set(handles.transform_fct,'Value',ichoice) |
---|
[507] | 3488 | |
---|
| 3489 | % save the new menu in the personal file 'uvmat_perso.mat' |
---|
| 3490 | dir_perso=prefdir;%personal Matalb directory |
---|
| 3491 | profil_perso=fullfile(dir_perso,'uvmat_perso.mat'); |
---|
| 3492 | if exist(profil_perso,'file') |
---|
| 3493 | nb_builtin=UvData.OpenParam.NbBuiltin;% number of 'builtin' (basic) transform fcts in uvmat |
---|
[523] | 3494 | if nb_builtin<numel(list_path) |
---|
[507] | 3495 | for ilist=nb_builtin+1:numel(list_path) |
---|
[508] | 3496 | transform_fct{ilist-nb_builtin}=[fullfile(list_path{ilist},menu{ilist}) '.m']; |
---|
[507] | 3497 | end |
---|
[387] | 3498 | save (profil_perso,'transform_fct','-append'); %store the root name for future opening of uvmat |
---|
[523] | 3499 | end |
---|
[507] | 3500 | end |
---|
[387] | 3501 | end |
---|
| 3502 | |
---|
[507] | 3503 | %% create the function handle of the selected fct |
---|
[512] | 3504 | |
---|
[507] | 3505 | if isempty(list_path{ichoice})% case of no selected fct |
---|
| 3506 | transform_handle=[]; |
---|
[387] | 3507 | else |
---|
[507] | 3508 | if ~exist(list_path{ichoice},'dir') |
---|
| 3509 | msgbox_uvmat('ERROR','invalid fct path: select the transform fct again with the option more...') |
---|
| 3510 | return |
---|
| 3511 | end |
---|
| 3512 | current_dir=pwd;%current working dir |
---|
| 3513 | cd(list_path{ichoice}) |
---|
| 3514 | transform_handle=str2func(transform_name); |
---|
| 3515 | cd(current_dir) |
---|
[387] | 3516 | end |
---|
[508] | 3517 | set(handles.path_transform,'String',list_path{ichoice}) |
---|
[507] | 3518 | set(handles.path_transform,'UserData',transform_handle) |
---|
[512] | 3519 | set(handles.transform_fct,'UserData',list_path) |
---|
[387] | 3520 | |
---|
[507] | 3521 | %% update the ToolTip string of the menu transform_fct with the first line of the selected fct file |
---|
| 3522 | if isempty(list_path{ichoice})% case of no selected fct |
---|
| 3523 | set(handles.transform_fct,'ToolTipString','transform_fct:choose a transform function') |
---|
| 3524 | else |
---|
| 3525 | try |
---|
| 3526 | [fid,errormsg] =fopen([fullfile(list_path{ichoice},transform_name) '.m']); |
---|
| 3527 | InputText=textscan(fid,'%s',1,'delimiter','\n'); |
---|
| 3528 | fclose(fid) |
---|
| 3529 | set(handles.transform_fct,'ToolTipString',['transform_fct: ' InputText{1}{1}])% put the first line of the selected function as tooltip help |
---|
| 3530 | end |
---|
| 3531 | end |
---|
| 3532 | |
---|
| 3533 | %% adapt the GUI to the input/output conditions of the selected transform fct |
---|
[508] | 3534 | DataOut=[]; |
---|
| 3535 | CoordUnit=''; |
---|
| 3536 | CoordUnitPrev=''; |
---|
| 3537 | if isfield(UvData,'Field')&&isfield(UvData.Field,'CoordUnit') |
---|
| 3538 | CoordUnitPrev=UvData.Field.CoordUnit; |
---|
| 3539 | end |
---|
| 3540 | if ~isempty(list_path{ichoice}) |
---|
| 3541 | if nargin(transform_handle)>1 && isfield(UvData,'XmlData')&&~isempty(UvData.XmlData) |
---|
| 3542 | XmlData=UvData.XmlData{1}; |
---|
| 3543 | DataOut=feval(transform_handle,'*',XmlData); |
---|
| 3544 | if isfield(DataOut,'CoordUnit') |
---|
| 3545 | CoordUnit=DataOut.CoordUnit; |
---|
[507] | 3546 | end |
---|
[508] | 3547 | if isfield(DataOut,'InputFieldType') |
---|
| 3548 | UvData.InputFieldType=DataOut.InputFieldType; |
---|
| 3549 | end |
---|
| 3550 | else |
---|
| 3551 | DataOut=feval(transform_handle,'*'); |
---|
[507] | 3552 | end |
---|
| 3553 | end |
---|
| 3554 | |
---|
[387] | 3555 | |
---|
[508] | 3556 | %% delete drawn objects if the output CooordUnit is different from the previous one |
---|
| 3557 | if ~strcmp(CoordUnit,CoordUnitPrev) |
---|
[541] | 3558 | set(handles.CheckFixLimits,'Value',0) |
---|
| 3559 | set(handles.CheckFixLimits,'BackgroundColor',[0.7 0.7 0.7]) |
---|
[508] | 3560 | hother=findobj('Tag','proj_object');%find all the proj objects |
---|
| 3561 | for iobj=1:length(hother) |
---|
| 3562 | delete_object(hother(iobj)) |
---|
| 3563 | end |
---|
| 3564 | hother=findobj('Tag','DeformPoint');%find all the proj objects |
---|
| 3565 | for iobj=1:length(hother) |
---|
| 3566 | delete_object(hother(iobj)) |
---|
| 3567 | end |
---|
| 3568 | hh=findobj('Tag','calib_points'); |
---|
| 3569 | if ~isempty(hh) |
---|
| 3570 | delete(hh) |
---|
| 3571 | end |
---|
| 3572 | hhh=findobj('Tag','calib_marker'); |
---|
| 3573 | if ~isempty(hhh) |
---|
| 3574 | delete(hhh) |
---|
| 3575 | end |
---|
| 3576 | % if isfield(UvData,'Object') |
---|
| 3577 | % UvData.Object=UvData.Object(1); |
---|
| 3578 | % end |
---|
| 3579 | set(handles.ListObject,'Value',1) |
---|
| 3580 | set(handles.ListObject,'String',{''}) |
---|
| 3581 | set(handles.ListObject_1,'Value',1) |
---|
| 3582 | set(handles.ListObject_1,'String',{''}) |
---|
| 3583 | set(handles.ViewObject,'value',0) |
---|
| 3584 | ViewObject_Callback(hObject, eventdata, handles) |
---|
| 3585 | set(handles.ViewField,'value',0) |
---|
| 3586 | ViewField_Callback(hObject, eventdata, handles) |
---|
| 3587 | set(handles.edit_object,'Value',0) |
---|
| 3588 | edit_object_Callback(hObject, eventdata, handles) |
---|
| 3589 | UvData.Object={[]}; |
---|
[387] | 3590 | end |
---|
[508] | 3591 | set(handles.uvmat,'UserData',UvData) |
---|
[387] | 3592 | |
---|
[508] | 3593 | %% refresh the current plot |
---|
[515] | 3594 | if isempty(list_path{ichoice}) || nargin(transform_handle)<3 |
---|
| 3595 | set(handles.SubField,'Value',0) |
---|
| 3596 | SubField_Callback(hObject, eventdata, handles) |
---|
| 3597 | else |
---|
| 3598 | run0_Callback(hObject, eventdata, handles) |
---|
| 3599 | end |
---|
[387] | 3600 | |
---|
| 3601 | %------------------------------------------------ |
---|
| 3602 | %CALLBACKS FOR PLOTTING PARAMETERS |
---|
| 3603 | %------------------------------------------------- |
---|
[405] | 3604 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
---|
| 3605 | % Plot coordinates |
---|
| 3606 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
---|
[387] | 3607 | %------------------------------------------------------------------------ |
---|
| 3608 | function num_MinX_Callback(hObject, eventdata, handles) |
---|
| 3609 | %------------------------------------------------------------------------ |
---|
| 3610 | set(handles.CheckFixLimits,'Value',1) %suppress auto mode |
---|
| 3611 | set(handles.CheckFixLimits,'BackgroundColor',[1 1 0]) |
---|
| 3612 | update_plot(handles); |
---|
| 3613 | |
---|
| 3614 | %------------------------------------------------------------------------ |
---|
| 3615 | function num_MaxX_Callback(hObject, eventdata, handles) |
---|
| 3616 | %------------------------------------------------------------------------ |
---|
| 3617 | set(handles.CheckFixLimits,'Value',1) %suppress auto mode |
---|
| 3618 | set(handles.CheckFixLimits,'BackgroundColor',[1 1 0]) |
---|
| 3619 | update_plot(handles); |
---|
| 3620 | |
---|
| 3621 | %------------------------------------------------------------------------ |
---|
| 3622 | function num_MinY_Callback(hObject, eventdata, handles) |
---|
| 3623 | %------------------------------------------ |
---|
| 3624 | set(handles.CheckFixLimits,'Value',1) %suppress auto mode |
---|
| 3625 | set(handles.CheckFixLimits,'BackgroundColor',[1 1 0]) |
---|
| 3626 | update_plot(handles); |
---|
| 3627 | |
---|
| 3628 | %------------------------------------------------------------------------ |
---|
| 3629 | function num_MaxY_Callback(hObject, eventdata, handles) |
---|
| 3630 | %------------------------------------------------------------------------ |
---|
| 3631 | set(handles.CheckFixLimits,'Value',1) %suppress auto mode |
---|
| 3632 | set(handles.CheckFixLimits,'BackgroundColor',[1 1 0]) |
---|
| 3633 | update_plot(handles); |
---|
| 3634 | |
---|
[405] | 3635 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
---|
| 3636 | % Scalar or image representation |
---|
| 3637 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
---|
[387] | 3638 | %------------------------------------------------------------------------ |
---|
| 3639 | function num_MinA_Callback(hObject, eventdata, handles) |
---|
| 3640 | %------------------------------------------ |
---|
| 3641 | set(handles.CheckFixScalar,'Value',1) %suppress auto mode |
---|
| 3642 | set(handles.CheckFixScalar,'BackgroundColor',[1 1 0]) |
---|
| 3643 | MinA=str2double(get(handles.num_MinA,'String')); |
---|
| 3644 | MaxA=str2double(get(handles.num_MaxA,'String')); |
---|
| 3645 | if MinA>MaxA% switch minA and maxA in case of error |
---|
| 3646 | MinA_old=MinA; |
---|
| 3647 | MinA=MaxA; |
---|
| 3648 | MaxA=MinA_old; |
---|
| 3649 | set(handles.num_MinA,'String',num2str(MinA,5)); |
---|
| 3650 | set(handles.num_MaxA,'String',num2str(MaxA,5)); |
---|
| 3651 | end |
---|
| 3652 | update_plot(handles); |
---|
| 3653 | |
---|
| 3654 | %------------------------------------------------------------------------ |
---|
| 3655 | function num_MaxA_Callback(hObject, eventdata, handles) |
---|
| 3656 | %------------------------------------------------------------------------ |
---|
| 3657 | set(handles.CheckFixScalar,'Value',1) %suppress auto mode |
---|
| 3658 | set(handles.CheckFixScalar,'BackgroundColor',[1 1 0]) |
---|
| 3659 | MinA=str2double(get(handles.num_MinA,'String')); |
---|
| 3660 | MaxA=str2double(get(handles.num_MaxA,'String')); |
---|
| 3661 | if MinA>MaxA% switch minA and maxA in case of error |
---|
| 3662 | MinA_old=MinA; |
---|
| 3663 | MinA=MaxA; |
---|
| 3664 | MaxA=MinA_old; |
---|
| 3665 | set(handles.num_MinA,'String',num2str(MinA,5)); |
---|
| 3666 | set(handles.num_MaxA,'String',num2str(MaxA,5)); |
---|
| 3667 | end |
---|
| 3668 | update_plot(handles); |
---|
| 3669 | |
---|
| 3670 | %------------------------------------------------------------------------ |
---|
| 3671 | function CheckFixScalar_Callback(hObject, eventdata, handles) |
---|
| 3672 | %------------------------------------------------------------------------ |
---|
| 3673 | test=get(handles.CheckFixScalar,'Value'); |
---|
| 3674 | if test |
---|
| 3675 | set(handles.CheckFixScalar,'BackgroundColor',[1 1 0]) |
---|
| 3676 | else |
---|
| 3677 | set(handles.CheckFixScalar,'BackgroundColor',[0.7 0.7 0.7]) |
---|
| 3678 | update_plot(handles); |
---|
| 3679 | end |
---|
| 3680 | |
---|
| 3681 | %------------------------------------------------------------------- |
---|
| 3682 | function CheckBW_Callback(hObject, eventdata, handles) |
---|
| 3683 | %------------------------------------------------------------------- |
---|
| 3684 | update_plot(handles); |
---|
| 3685 | |
---|
| 3686 | %------------------------------------------------------------------- |
---|
[428] | 3687 | function num_Opacity_Callback(hObject, eventdata, handles) |
---|
| 3688 | update_plot(handles); |
---|
| 3689 | %------------------------------------------------------------------- |
---|
| 3690 | |
---|
| 3691 | %------------------------------------------------------------------- |
---|
[387] | 3692 | function ListContour_Callback(hObject, eventdata, handles) |
---|
| 3693 | %------------------------------------------------------------------- |
---|
| 3694 | val=get(handles.ListContour,'Value'); |
---|
| 3695 | if val==2 |
---|
| 3696 | set(handles.interval_txt,'Visible','on') |
---|
| 3697 | set(handles.num_IncrA,'Visible','on') |
---|
| 3698 | else |
---|
| 3699 | set(handles.interval_txt,'Visible','off') |
---|
| 3700 | set(handles.num_IncrA,'Visible','off') |
---|
| 3701 | end |
---|
| 3702 | update_plot(handles); |
---|
| 3703 | |
---|
| 3704 | %------------------------------------------------------------------- |
---|
| 3705 | function num_IncrA_Callback(hObject, eventdata, handles) |
---|
| 3706 | %------------------------------------------------------------------- |
---|
| 3707 | update_plot(handles); |
---|
| 3708 | |
---|
[405] | 3709 | |
---|
| 3710 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
---|
| 3711 | % Vector representation |
---|
| 3712 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
---|
[387] | 3713 | %------------------------------------------------------------------- |
---|
| 3714 | function CheckHideWarning_Callback(hObject, eventdata, handles) |
---|
| 3715 | %------------------------------------------------------------------- |
---|
| 3716 | update_plot(handles); |
---|
| 3717 | |
---|
| 3718 | %------------------------------------------------------------------- |
---|
| 3719 | function CheckHideFalse_Callback(hObject, eventdata, handles) |
---|
| 3720 | %------------------------------------------------------------------- |
---|
| 3721 | update_plot(handles); |
---|
| 3722 | |
---|
| 3723 | %------------------------------------------------------------------- |
---|
| 3724 | function num_VecScale_Callback(hObject, eventdata, handles) |
---|
| 3725 | %------------------------------------------------------------------- |
---|
| 3726 | set(handles.CheckFixVectors,'Value',1); |
---|
| 3727 | set(handles.CheckFixVectors,'BackgroundColor',[1 1 0]) |
---|
| 3728 | update_plot(handles); |
---|
| 3729 | |
---|
| 3730 | %------------------------------------------------------------------- |
---|
| 3731 | function CheckFixVectors_Callback(hObject, eventdata, handles) |
---|
| 3732 | %------------------------------------------------------------------- |
---|
| 3733 | test=get(handles.CheckFixVectors,'Value'); |
---|
| 3734 | if test |
---|
| 3735 | set(handles.CheckFixVectors,'BackgroundColor',[1 1 0]) |
---|
| 3736 | else |
---|
| 3737 | update_plot(handles); |
---|
| 3738 | %set(handles.num_VecScale,'String',num2str(ScalOut.num_VecScale,3)) |
---|
| 3739 | set(handles.CheckFixVectors,'BackgroundColor',[0.7 0.7 0.7]) |
---|
| 3740 | end |
---|
| 3741 | |
---|
| 3742 | %------------------------------------------------------------------------ |
---|
| 3743 | % --- Executes on selection change in CheckDecimate4 (nb_vec/4). |
---|
| 3744 | function CheckDecimate4_Callback(hObject, eventdata, handles) |
---|
| 3745 | %------------------------------------------------------------------------ |
---|
| 3746 | update_plot(handles); |
---|
| 3747 | |
---|
| 3748 | %------------------------------------------------------------------------ |
---|
[405] | 3749 | % --- Executes on selection change in ColorCode menu |
---|
| 3750 | function ColorCode_Callback(hObject, eventdata, handles) |
---|
[387] | 3751 | %------------------------------------------------------------------------ |
---|
[405] | 3752 | % edit the choice for color code |
---|
| 3753 | update_color_code_boxes(handles); |
---|
| 3754 | update_plot(handles); |
---|
| 3755 | |
---|
| 3756 | %------------------------------------------------------------------------ |
---|
| 3757 | function update_color_code_boxes(handles) |
---|
| 3758 | %------------------------------------------------------------------------ |
---|
| 3759 | list_code=get(handles.ColorCode,'String');% list menu fields |
---|
| 3760 | colcode= list_code{get(handles.ColorCode,'Value')}; % selected field |
---|
| 3761 | enable_slider='off';%default |
---|
| 3762 | enable_bounds='off';%default |
---|
| 3763 | enable_scalar='off';%default |
---|
| 3764 | switch colcode |
---|
| 3765 | case {'rgb','bgr'} |
---|
| 3766 | enable_slider='on'; |
---|
| 3767 | enable_bounds='on'; |
---|
| 3768 | enable_scalar='on'; |
---|
| 3769 | case '64 colors' |
---|
| 3770 | enable_bounds='on'; |
---|
| 3771 | enable_scalar='on'; |
---|
| 3772 | end |
---|
| 3773 | set(handles.Slider1,'Visible',enable_slider) |
---|
| 3774 | set(handles.Slider2,'Visible', enable_slider) |
---|
| 3775 | set(handles.num_ColCode1,'Visible',enable_slider) |
---|
| 3776 | set(handles.num_ColCode2,'Visible',enable_slider) |
---|
| 3777 | set(handles.TitleColCode1,'Visible',enable_slider) |
---|
| 3778 | set(handles.TitleColCode2,'Visible',enable_slider) |
---|
| 3779 | set(handles.CheckFixVecColor,'Visible',enable_bounds) |
---|
| 3780 | set(handles.num_MinVec,'Visible',enable_bounds) |
---|
| 3781 | set(handles.num_MaxVec,'Visible',enable_bounds) |
---|
| 3782 | set(handles.ColorScalar,'Visible',enable_scalar) |
---|
[387] | 3783 | set_vec_col_bar(handles) |
---|
[405] | 3784 | |
---|
| 3785 | %------------------------------------------------------------------ |
---|
| 3786 | % --- Executes on selection change in ColorScalar: choice of the color code. |
---|
| 3787 | function ColorScalar_Callback(hObject, eventdata, handles) |
---|
| 3788 | %------------------------------------------------------------------ |
---|
| 3789 | % edit the choice for color code |
---|
| 3790 | list_scalar=get(handles.ColorScalar,'String');% list menu fields |
---|
| 3791 | col_scalar= list_scalar{get(handles.ColorScalar,'Value')}; % selected field |
---|
| 3792 | if isequal(col_scalar,'ima_cor') |
---|
| 3793 | set(handles.CheckFixVecColor,'Value',1)%fixed scale by default |
---|
| 3794 | ColorCode='rgb'; |
---|
| 3795 | set(handles.num_MinVec,'String','0') |
---|
| 3796 | set(handles.num_MaxVec,'String','1') |
---|
| 3797 | set(handles.num_ColCode1,'String','0.333') |
---|
| 3798 | set(handles.num_ColCode2,'String','0.666') |
---|
| 3799 | else |
---|
| 3800 | set(handles.CheckFixVecColor,'Value',0)%auto scale between min,max by default |
---|
| 3801 | ColorCode='64 colors'; |
---|
| 3802 | end |
---|
| 3803 | ColorCodeList=get(handles.ColorCode,'String'); |
---|
| 3804 | ichoice=find(strcmp(ColorCode,ColorCodeList),1); |
---|
| 3805 | set(handles.ColorCode,'Value',ichoice)% set color code in the menu |
---|
| 3806 | |
---|
| 3807 | update_color_code_boxes(handles); |
---|
| 3808 | %replot the current graph |
---|
| 3809 | run0_Callback(hObject, eventdata, handles) |
---|
| 3810 | |
---|
| 3811 | %---------------------------------------------------------------- |
---|
| 3812 | % -- Executes on slider movement to set the color code |
---|
| 3813 | % |
---|
| 3814 | function Slider1_Callback(hObject, eventdata, handles) |
---|
| 3815 | %------------------------------------------------------------------ |
---|
| 3816 | slider1=get(handles.Slider1,'Value'); |
---|
| 3817 | min_val=str2num(get(handles.num_MinVec,'String')); |
---|
| 3818 | max_val=str2num(get(handles.num_MaxVec,'String')); |
---|
| 3819 | col=min_val+(max_val-min_val)*slider1; |
---|
| 3820 | set(handles.num_ColCode1,'String',num2str(col)) |
---|
| 3821 | if(get(handles.Slider2,'Value') < col)%move also the second slider at the same value if needed |
---|
| 3822 | set(handles.Slider2,'Value',col) |
---|
| 3823 | set(handles.num_ColCode2,'String',num2str(col)) |
---|
| 3824 | end |
---|
| 3825 | set_vec_col_bar(handles) |
---|
[387] | 3826 | update_plot(handles); |
---|
| 3827 | |
---|
[405] | 3828 | %---------------------------------------------------------------- |
---|
| 3829 | % Executes on slider movement to set the color code |
---|
| 3830 | %---------------------------------------------------------------- |
---|
| 3831 | function Slider2_Callback(hObject, eventdata, handles) |
---|
| 3832 | slider2=get(handles.Slider2,'Value'); |
---|
| 3833 | min_val=str2num(get(handles.num_MinVec,'String')); |
---|
| 3834 | max_val=str2num(get(handles.num_MaxVec,'String')); |
---|
| 3835 | col=min_val+(max_val-min_val)*slider2; |
---|
| 3836 | set(handles.num_ColCode2,'String',num2str(col)) |
---|
| 3837 | if(get(handles.Slider1,'Value') > col)%move also the first slider at the same value if needed |
---|
| 3838 | set(handles.Slider1,'Value',col) |
---|
| 3839 | set(handles.num_ColCode1,'String',num2str(col)) |
---|
| 3840 | end |
---|
| 3841 | set_vec_col_bar(handles) |
---|
| 3842 | update_plot(handles); |
---|
| 3843 | |
---|
| 3844 | %---------------------------------------------------------------- |
---|
| 3845 | % --- Execute on return carriage on the edit box corresponding to slider 1 |
---|
| 3846 | %---------------------------------------------------------------- |
---|
| 3847 | function num_ColCode1_Callback(hObject, eventdata, handles) |
---|
| 3848 | set_vec_col_bar(handles) |
---|
| 3849 | update_plot(handles); |
---|
| 3850 | |
---|
| 3851 | %---------------------------------------------------------------- |
---|
| 3852 | % --- Execute on return carriage on the edit box corresponding to slider 2 |
---|
| 3853 | %---------------------------------------------------------------- |
---|
| 3854 | function num_ColCode2_Callback(hObject, eventdata, handles) |
---|
| 3855 | set_vec_col_bar(handles) |
---|
| 3856 | update_plot(handles); |
---|
[387] | 3857 | %------------------------------------------------------------------------ |
---|
[405] | 3858 | %------------------------------------------------------- |
---|
[387] | 3859 | % --- Executes on button press in CheckFixVecColor. |
---|
[405] | 3860 | %------------------------------------------------------- |
---|
| 3861 | function VecColBar_Callback(hObject, eventdata, handles) |
---|
| 3862 | set_vec_col_bar(handles) |
---|
| 3863 | |
---|
| 3864 | %------------------------------------------------------------------------ |
---|
| 3865 | % --- Executes on button press in CheckFixVecColor. |
---|
[387] | 3866 | function CheckFixVecColor_Callback(hObject, eventdata, handles) |
---|
| 3867 | %------------------------------------------------------------------------ |
---|
[405] | 3868 | if ~get(handles.CheckFixVecColor,'Value') |
---|
[387] | 3869 | update_plot(handles); |
---|
| 3870 | end |
---|
| 3871 | |
---|
| 3872 | %------------------------------------------------------------------------ |
---|
| 3873 | % --- Executes on selection change in num_MaxVec. |
---|
| 3874 | function num_MinVec_Callback(hObject, eventdata, handles) |
---|
| 3875 | %------------------------------------------------------------------------ |
---|
| 3876 | max_vec_Callback(hObject, eventdata, handles) |
---|
| 3877 | |
---|
| 3878 | %------------------------------------------------------------------------ |
---|
| 3879 | % --- Executes on selection change in num_MaxVec. |
---|
| 3880 | function num_MaxVec_Callback(hObject, eventdata, handles) |
---|
| 3881 | %------------------------------------------------------------------------ |
---|
| 3882 | set(handles.CheckFixVecColor,'Value',1) |
---|
| 3883 | CheckFixVecColor_Callback(hObject, eventdata, handles) |
---|
| 3884 | min_val=str2num(get(handles.num_MinVec,'String')); |
---|
| 3885 | max_val=str2num(get(handles.num_MaxVec,'String')); |
---|
| 3886 | slider1=get(handles.Slider1,'Value'); |
---|
| 3887 | slider2=get(handles.Slider2,'Value'); |
---|
| 3888 | colcode1=min_val+(max_val-min_val)*slider1; |
---|
| 3889 | colcode2=min_val+(max_val-min_val)*slider2; |
---|
| 3890 | set(handles.num_ColCode1,'String',num2str(colcode1)) |
---|
| 3891 | set(handles.num_ColCode2,'String',num2str(colcode2)) |
---|
| 3892 | update_plot(handles); |
---|
| 3893 | |
---|
| 3894 | %------------------------------------------------------------------------ |
---|
[405] | 3895 | % --- update the display of color code for vectors (on vecColBar) |
---|
[387] | 3896 | function set_vec_col_bar(handles) |
---|
| 3897 | %------------------------------------------------------------------------ |
---|
| 3898 | %get the image of the color display button 'VecColBar' in pixels |
---|
| 3899 | set(handles.VecColBar,'Unit','pixel'); |
---|
| 3900 | pos_vert=get(handles.VecColBar,'Position'); |
---|
| 3901 | set(handles.VecColBar,'Unit','Normalized'); |
---|
| 3902 | width=ceil(pos_vert(3)); |
---|
| 3903 | height=ceil(pos_vert(4)); |
---|
| 3904 | |
---|
| 3905 | %get slider indications |
---|
[405] | 3906 | list=get(handles.ColorCode,'String'); |
---|
| 3907 | ichoice=get(handles.ColorCode,'Value'); |
---|
| 3908 | colcode.ColorCode=list{ichoice}; |
---|
[387] | 3909 | colcode.MinVec=str2num(get(handles.num_MinVec,'String')); |
---|
| 3910 | colcode.MaxVec=str2num(get(handles.num_MaxVec,'String')); |
---|
[405] | 3911 | test3color=strcmp(colcode.ColorCode,'rgb') || strcmp(colcode.ColorCode,'bgr'); |
---|
[387] | 3912 | if test3color |
---|
| 3913 | colcode.ColCode1=str2num(get(handles.num_ColCode1,'String')); |
---|
| 3914 | colcode.ColCode2=str2num(get(handles.num_ColCode2,'String')); |
---|
| 3915 | end |
---|
| 3916 | vec_C=colcode.MinVec+(colcode.MaxVec-colcode.MinVec)*(0.5:width-0.5)/width;%sample of vec_C values from min to max |
---|
| 3917 | [colorlist,col_vec]=set_col_vec(colcode,vec_C); |
---|
| 3918 | oneheight=ones(1,height); |
---|
| 3919 | A1=colorlist(col_vec,1)*oneheight; |
---|
| 3920 | A2=colorlist(col_vec,2)*oneheight; |
---|
| 3921 | A3=colorlist(col_vec,3)*oneheight; |
---|
| 3922 | A(:,:,1)=A1'; |
---|
| 3923 | A(:,:,2)=A2'; |
---|
| 3924 | A(:,:,3)=A3'; |
---|
| 3925 | set(handles.VecColBar,'Cdata',A) |
---|
| 3926 | |
---|
| 3927 | %------------------------------------------------------------------- |
---|
| 3928 | function update_plot(handles) |
---|
| 3929 | %------------------------------------------------------------------- |
---|
| 3930 | UvData=get(handles.uvmat,'UserData'); |
---|
[511] | 3931 | AxeData=UvData.PlotAxes;% retrieve the current plotted data |
---|
[387] | 3932 | PlotParam=read_GUI(handles.uvmat); |
---|
[511] | 3933 | [tild,PlotParamOut]= plot_field(AxeData,handles.PlotAxes,PlotParam); |
---|
[387] | 3934 | write_plot_param(handles,PlotParamOut); %update the auto plot parameters |
---|
| 3935 | |
---|
[402] | 3936 | %------------------------------------------------------------------------ |
---|
| 3937 | %------------------------------------------------------------------------ |
---|
| 3938 | % SELECTION AND EDITION OF PROJECTION OBJECTS |
---|
| 3939 | %------------------------------------------------------------------------ |
---|
| 3940 | %------------------------------------------------------------------------ |
---|
[387] | 3941 | |
---|
[410] | 3942 | % --- Executes on selection change in ListObject_1. |
---|
| 3943 | function ListObject_1_Callback(hObject, eventdata, handles) |
---|
[432] | 3944 | list_str=get(handles.ListObject,'String'); |
---|
[410] | 3945 | UvData=get(handles.uvmat,'UserData'); |
---|
| 3946 | ObjectData=UvData.Object{get(handles.ListObject_1,'Value')}; |
---|
| 3947 | |
---|
| 3948 | %% update the projection plot on uvmat |
---|
[432] | 3949 | ProjData= proj_field(UvData.Field,ObjectData);%project the current input field on object ObjectData |
---|
[511] | 3950 | plot_field(ProjData,handles.PlotAxes,read_GUI(handles.uvmat));% plot the projected field; |
---|
[432] | 3951 | %replot all the objects within the new projected field |
---|
| 3952 | for IndexObj=1:numel(list_str) |
---|
[515] | 3953 | hobject=UvData.Object{IndexObj}.DisplayHandle.uvmat; |
---|
[432] | 3954 | if isempty(hobject) || ~ishandle(hobject) |
---|
[515] | 3955 | hobject=handles.PlotAxes; |
---|
[432] | 3956 | end |
---|
| 3957 | if isequal(IndexObj,get(handles.ListObject,'Value')) |
---|
| 3958 | objectcolor='m'; %paint in magenta the currently selected object in ListObject |
---|
| 3959 | else |
---|
| 3960 | objectcolor='b'; |
---|
| 3961 | end |
---|
| 3962 | UvData.Object{IndexObj}.DisplayHandle.uvmat=plot_object(UvData.Object{IndexObj},ObjectData,hobject,objectcolor);%draw the object in uvmat |
---|
| 3963 | end |
---|
| 3964 | set(handles.uvmat,'UserData',UvData) |
---|
[410] | 3965 | |
---|
| 3966 | %% display the object parameters if the GUI set_object is already opened |
---|
[425] | 3967 | if ~get(handles.ViewObject,'Value') |
---|
[410] | 3968 | ZBounds=0; % default |
---|
| 3969 | if isfield(UvData.Field,'ZMin') && isfield(UvData.Field,'ZMax') |
---|
| 3970 | ZBounds(1)=UvData.Field.ZMin; %minimum for the Z slider |
---|
| 3971 | ZBounds(2)=UvData.Field.ZMax;%maximum for the Z slider |
---|
| 3972 | end |
---|
[425] | 3973 | ObjectData.Name=list_str{get(handles.ListObject_1,'Value')}; |
---|
[410] | 3974 | set_object(ObjectData,[],ZBounds); |
---|
[424] | 3975 | set(handles.ViewObject,'Value',1)% show that the selected object in ListObject_1 is currently visualised |
---|
[410] | 3976 | end |
---|
[432] | 3977 | |
---|
[410] | 3978 | % desactivate the edit object mode |
---|
| 3979 | set(handles.edit_object,'Value',0) |
---|
| 3980 | set(handles.edit_object,'BackgroundColor',[0.7,0.7,0.7]) |
---|
| 3981 | |
---|
[387] | 3982 | %------------------------------------------------------------------------ |
---|
| 3983 | % --- Executes on selection change in ListObject. |
---|
| 3984 | function ListObject_Callback(hObject, eventdata, handles) |
---|
| 3985 | %------------------------------------------------------------------------ |
---|
| 3986 | list_str=get(handles.ListObject,'String'); |
---|
| 3987 | IndexObj=get(handles.ListObject,'Value');%present object selection |
---|
| 3988 | |
---|
[410] | 3989 | %% The object is displayed in set_object if this GUI is already opened |
---|
[402] | 3990 | UvData=get(handles.uvmat,'UserData'); |
---|
[410] | 3991 | ObjectData=UvData.Object{IndexObj}; |
---|
[402] | 3992 | hset_object=findobj(allchild(0),'tag','set_object'); |
---|
| 3993 | if ~isempty(hset_object) |
---|
| 3994 | ZBounds=0; % default |
---|
| 3995 | if isfield(UvData.Field,'ZMin') && isfield(UvData.Field,'ZMax') |
---|
| 3996 | ZBounds(1)=UvData.Field.ZMin; %minimum for the Z slider |
---|
| 3997 | ZBounds(2)=UvData.Field.ZMax;%maximum for the Z slider |
---|
| 3998 | end |
---|
[410] | 3999 | ObjectData.Name=list_str{IndexObj}; |
---|
[402] | 4000 | set_object(ObjectData,[],ZBounds); |
---|
[424] | 4001 | set(handles.ViewField,'Value',1)% show that the selected object in ListObject is currently visualised |
---|
[402] | 4002 | end |
---|
[429] | 4003 | |
---|
| 4004 | %% desactivate the edit object mode |
---|
[402] | 4005 | set(handles.edit_object,'Value',0) |
---|
| 4006 | set(handles.edit_object,'BackgroundColor',[0.7,0.7,0.7]) |
---|
| 4007 | |
---|
[429] | 4008 | %% update the plot on view_field if view_field is already openened |
---|
| 4009 | hview_field=findobj(allchild(0),'tag','view_field'); |
---|
| 4010 | if isempty(hview_field) |
---|
[511] | 4011 | hhview_field.PlotAxes=[]; |
---|
[429] | 4012 | else |
---|
| 4013 | Data=get(hview_field,'UserData'); |
---|
| 4014 | hhview_field=guidata(hview_field); |
---|
| 4015 | ProjData= proj_field(UvData.Field,ObjectData);%project the current interface field on ObjectData |
---|
[511] | 4016 | [PlotType,PlotParam]=plot_field(ProjData,hhview_field.PlotAxes,read_GUI(hview_field));%read plotting parameters on the uvmat interfachhview_fiel |
---|
[429] | 4017 | write_plot_param(hhview_field,PlotParam); %update the display of plotting parameters for the current object |
---|
| 4018 | haxes=findobj(hview_field,'tag','axes3'); |
---|
| 4019 | pos=get(hview_field,'Position'); |
---|
| 4020 | if strcmp(get(haxes,'Visible'),'off')%sempty(PlotParam.Coordinates)% case of no plot display (pure text table) |
---|
| 4021 | h_TableDisplay=findobj(hview_field,'tag','TableDisplay'); |
---|
| 4022 | pos_table=get(h_TableDisplay,'Position'); |
---|
| 4023 | set(hview_field,'Position',[pos(1)+pos(3)-pos_table(3) pos(2)+pos(4)-pos_table(4) pos_table(3) pos_table(4)]) |
---|
| 4024 | drawnow% needed to change position before the next command |
---|
| 4025 | set(hview_field,'UserData',Data);% restore the previously stored GUI position after GUI resizing |
---|
| 4026 | else |
---|
| 4027 | set(hview_field,'Position',Data.GUISize)% return to the previously stored GUI position and size |
---|
[387] | 4028 | end |
---|
| 4029 | end |
---|
| 4030 | |
---|
[402] | 4031 | %% update the color of the graphic object representation: the selected object in magenta, others in blue |
---|
[511] | 4032 | update_object_color(handles.PlotAxes,hhview_field.PlotAxes,UvData.Object{IndexObj}.DisplayHandle.uvmat) |
---|
[387] | 4033 | |
---|
| 4034 | %------------------------------------------------------------------------ |
---|
[402] | 4035 | %--- update the color representation of objects (indicating the selected ones) |
---|
| 4036 | function update_object_color(axes_uvmat,axes_view_field,DisplayHandle) |
---|
[387] | 4037 | %------------------------------------------------------------------------ |
---|
[402] | 4038 | if isempty(axes_view_field)% case with no view_field plot |
---|
| 4039 | hother=[findobj(axes_uvmat,'Tag','proj_object');findobj(axes_uvmat,'Tag','DeformPoint')];%find all the proj object and deform point representations |
---|
[387] | 4040 | else |
---|
[402] | 4041 | hother=[findobj(axes_uvmat,'Tag','proj_object') ;findobj(axes_view_field,'Tag','proj_object');... %find all the proj object representations |
---|
| 4042 | findobj(axes_uvmat,'Tag','DeformPoint'); findobj(axes_view_field,'Tag','DeformPoint')];%find all the deform point representations |
---|
[387] | 4043 | end |
---|
| 4044 | for iobj=1:length(hother) |
---|
| 4045 | if isequal(get(hother(iobj),'Type'),'rectangle')||isequal(get(hother(iobj),'Type'),'patch') |
---|
| 4046 | set(hother(iobj),'EdgeColor','b') |
---|
| 4047 | if isequal(get(hother(iobj),'FaceColor'),'m') |
---|
| 4048 | set(hother(iobj),'FaceColor','b') |
---|
| 4049 | end |
---|
| 4050 | elseif isequal(get(hother(iobj),'Type'),'image') |
---|
| 4051 | Acolor=get(hother(iobj),'CData'); |
---|
| 4052 | Acolor(:,:,1)=zeros(size(Acolor,1),size(Acolor,2)); |
---|
| 4053 | set(hother(iobj),'CData',Acolor); |
---|
| 4054 | else |
---|
| 4055 | set(hother(iobj),'Color','b') |
---|
| 4056 | end |
---|
| 4057 | set(hother(iobj),'Selected','off') |
---|
| 4058 | end |
---|
[432] | 4059 | if ishandle(DisplayHandle) |
---|
[402] | 4060 | linetype=get(DisplayHandle,'Type'); |
---|
| 4061 | if isequal(linetype,'line') |
---|
| 4062 | set(DisplayHandle,'Color','m'); %set the selected object to magenta color |
---|
| 4063 | elseif isequal(linetype,'rectangle') |
---|
| 4064 | set(DisplayHandle,'EdgeColor','m'); %set the selected object to magenta color |
---|
| 4065 | elseif isequal(linetype,'patch') |
---|
| 4066 | set(DisplayHandle,'FaceColor','m'); %set the selected object to magenta color |
---|
| 4067 | end |
---|
| 4068 | SubObjectData=get(DisplayHandle,'UserData'); |
---|
| 4069 | if isfield(SubObjectData,'SubObject') & ishandle(SubObjectData.SubObject) |
---|
| 4070 | for iobj=1:length(SubObjectData.SubObject) |
---|
| 4071 | hsub=SubObjectData.SubObject(iobj); |
---|
| 4072 | if isequal(get(hsub,'Type'),'rectangle') |
---|
| 4073 | set(hsub,'EdgeColor','m'); %set the selected object to magenta color |
---|
| 4074 | elseif isequal(get(hsub,'Type'),'image') |
---|
| 4075 | Acolor=get(hsub,'CData'); |
---|
| 4076 | Acolor(:,:,1)=Acolor(:,:,3); |
---|
| 4077 | set(hsub,'CData',Acolor); |
---|
| 4078 | else |
---|
| 4079 | set(hsub,'Color','m') |
---|
| 4080 | end |
---|
[387] | 4081 | end |
---|
| 4082 | end |
---|
[402] | 4083 | if isfield(SubObjectData,'DeformPoint') & ishandle(SubObjectData.DeformPoint) |
---|
| 4084 | set(SubObjectData.DeformPoint,'Color','m') |
---|
| 4085 | end |
---|
[387] | 4086 | end |
---|
[402] | 4087 | |
---|
[427] | 4088 | %------------------------------------------------------------------- |
---|
| 4089 | % --- Executes on selection change in edit_object. |
---|
| 4090 | function edit_object_Callback(hObject, eventdata, handles) |
---|
| 4091 | %------------------------------------------------------------------- |
---|
| 4092 | UvData=get(handles.uvmat,'UserData');%read UvData properties stored on the uvmat interface |
---|
| 4093 | hset_object=findobj(allchild(0),'Tag','set_object'); |
---|
| 4094 | if get(handles.edit_object,'Value') |
---|
| 4095 | set(handles.edit_object,'BackgroundColor',[1,1,0]) |
---|
| 4096 | %suppress the other options |
---|
| 4097 | set(handles.CheckZoom,'Value',0) |
---|
| 4098 | CheckZoom_Callback(hObject, eventdata, handles) |
---|
| 4099 | hgeometry_calib=findobj(allchild(0),'tag','geometry_calib'); |
---|
| 4100 | if ishandle(hgeometry_calib) |
---|
| 4101 | hhgeometry_calib=guidata(hgeometry_calib); |
---|
| 4102 | set(hhgeometry_calib.edit_append,'Value',0)% desactivate mouse action in geometry_calib |
---|
| 4103 | set(hhgeometry_calib.edit_append,'BackgroundColor',[0.7 0.7 0.7]) |
---|
| 4104 | end |
---|
| 4105 | set(handles.ViewObject,'value',1) |
---|
| 4106 | ViewObject_Callback(hObject, eventdata, handles) |
---|
| 4107 | else % desctivate object edit mode |
---|
| 4108 | set(handles.edit_object,'BackgroundColor',[0.7,0.7,0.7]) |
---|
| 4109 | if ~isempty(hset_object)% open the |
---|
| 4110 | hhset_object=guidata(hset_object); |
---|
| 4111 | set(hhset_object.PLOT,'enable','off'); |
---|
| 4112 | set(get(hset_object,'children'),'enable','inactive') |
---|
| 4113 | end |
---|
| 4114 | end |
---|
| 4115 | |
---|
| 4116 | |
---|
[402] | 4117 | %------------------------------------------------------------------------ |
---|
[424] | 4118 | % --- Executes on button press in ViewObject. |
---|
| 4119 | function ViewObject_Callback(hObject, eventdata, handles) |
---|
[410] | 4120 | %------------------------------------------------------------------------ |
---|
[424] | 4121 | check_view=get(handles.ViewObject,'Value'); |
---|
[410] | 4122 | |
---|
| 4123 | if check_view %activate set_object |
---|
[424] | 4124 | IndexObj=get(handles.ListObject,'Value'); |
---|
| 4125 | list_object=get(handles.ListObject,'String'); |
---|
[410] | 4126 | UvData=get(handles.uvmat,'UserData');%read UvData properties stored on the uvmat interface |
---|
| 4127 | UvData.Object{IndexObj}.Name=list_object{IndexObj}; |
---|
| 4128 | if numel(UvData.Object)<IndexObj;% error in UvData |
---|
| 4129 | msgbox_uvmat('ERROR','invalid object list') |
---|
| 4130 | return |
---|
| 4131 | end |
---|
| 4132 | ZBounds=0; % default |
---|
| 4133 | if isfield(UvData.Field,'ZMin') && isfield(UvData.Field,'ZMax') |
---|
| 4134 | ZBounds(1)=UvData.Field.ZMin; %minimum for the Z slider |
---|
| 4135 | ZBounds(2)=UvData.Field.ZMax;%maximum for the Z slider |
---|
| 4136 | end |
---|
[424] | 4137 | % set(handles.ListObject_1,'Value',IndexObj);%restore ListObject selection after set_object deletion |
---|
[410] | 4138 | data=UvData.Object{IndexObj}; |
---|
| 4139 | if ~isfield(data,'Type')% default plane |
---|
| 4140 | data.Type='plane'; |
---|
| 4141 | end |
---|
[515] | 4142 | % if isfield(UvData,'Field') |
---|
| 4143 | % Field=UvData.Field; |
---|
| 4144 | % if isfield(UvData.Field,'Mesh')&&~isempty(UvData.Field.Mesh) |
---|
| 4145 | % data.RangeX=[UvData.Field.XMin UvData.Field.XMax]; |
---|
| 4146 | % if strcmp(data.Type,'line')||strcmp(data.Type,'polyline') |
---|
| 4147 | % data.RangeY=UvData.Field.Mesh; |
---|
| 4148 | % else |
---|
| 4149 | % data.RangeY=[UvData.Field.YMin UvData.Field.YMax]; |
---|
| 4150 | % end |
---|
| 4151 | % data.DX=UvData.Field.Mesh; |
---|
| 4152 | % data.DY=UvData.Field.Mesh; |
---|
| 4153 | % end |
---|
| 4154 | % if isfield(Field,'NbDim')&& isequal(Field.NbDim,3) |
---|
| 4155 | % data.Coord=[0 0 0]; %default |
---|
| 4156 | % end |
---|
| 4157 | % if isfield(Field,'CoordUnit') |
---|
| 4158 | % data.CoordUnit=Field.CoordUnit; |
---|
| 4159 | % end |
---|
| 4160 | % end |
---|
[410] | 4161 | hset_object=set_object(data,[],ZBounds); |
---|
| 4162 | hhset_object=guidata(hset_object); |
---|
| 4163 | if get(handles.edit_object,'Value')% edit mode |
---|
| 4164 | set(hhset_object.PLOT,'Enable','on') |
---|
[424] | 4165 | set(get(hset_object,'children'),'enable','on') |
---|
[410] | 4166 | else |
---|
| 4167 | set(hhset_object.PLOT,'Enable','off') |
---|
[427] | 4168 | set(get(hset_object,'children'),'enable','inactive')% deactivate the GUI except SAVE |
---|
| 4169 | set(hhset_object.SAVE,'Enable','on') |
---|
[410] | 4170 | end |
---|
| 4171 | else |
---|
| 4172 | hset_object=findobj(allchild(0),'tag','set_object'); |
---|
| 4173 | if ~isempty(hset_object) |
---|
| 4174 | delete(hset_object)% delete existing version of set_object |
---|
| 4175 | end |
---|
| 4176 | end |
---|
| 4177 | |
---|
[424] | 4178 | |
---|
[410] | 4179 | %------------------------------------------------------------------------ |
---|
[424] | 4180 | % --- Executes on button press in ViewField. |
---|
| 4181 | function ViewField_Callback(hObject, eventdata, handles) |
---|
[402] | 4182 | %------------------------------------------------------------------------ |
---|
[424] | 4183 | check_view=get(handles.ViewField,'Value'); |
---|
[387] | 4184 | |
---|
[410] | 4185 | if check_view |
---|
| 4186 | IndexObj=get(handles.ListObject,'Value'); |
---|
| 4187 | UvData=get(handles.uvmat,'UserData');%read UvData properties stored on the uvmat interface |
---|
| 4188 | if numel(UvData.Object)<IndexObj(end);% error in UvData |
---|
| 4189 | msgbox_uvmat('ERROR','invalid object list') |
---|
| 4190 | return |
---|
| 4191 | end |
---|
| 4192 | ZBounds=0; % default |
---|
| 4193 | if isfield(UvData.Field,'ZMin') && isfield(UvData.Field,'ZMax') |
---|
| 4194 | ZBounds(1)=UvData.Field.ZMin; %minimum for the Z slider |
---|
| 4195 | ZBounds(2)=UvData.Field.ZMax;%maximum for the Z slider |
---|
| 4196 | end |
---|
| 4197 | set(handles.ListObject,'Value',IndexObj);%restore ListObject selection after set_object deletion |
---|
| 4198 | if ~isfield(UvData.Object{IndexObj(1)},'Type')% default plane |
---|
| 4199 | UvData.Object{IndexObj(1)}.Type='plane'; |
---|
| 4200 | end |
---|
| 4201 | list_object=get(handles.ListObject,'String'); |
---|
| 4202 | UvData.Object{IndexObj(end)}.Name=list_object{IndexObj(end)}; |
---|
| 4203 | |
---|
[429] | 4204 | %% show the projection of the selected object on view_field |
---|
| 4205 | ProjData= proj_field(UvData.Field,UvData.Object{IndexObj});%project the current field on ObjectData |
---|
[402] | 4206 | hview_field=findobj(allchild(0),'tag','view_field'); |
---|
| 4207 | if isempty(hview_field) |
---|
| 4208 | hview_field=view_field; |
---|
| 4209 | end |
---|
[429] | 4210 | hhview_field=guidata(hview_field); |
---|
[511] | 4211 | [PlotType,PlotParam]=plot_field(ProjData,hhview_field.PlotAxes,read_GUI(hview_field));%read plotting parameters on the GUI view_field); |
---|
[429] | 4212 | write_plot_param(hhview_field,PlotParam); %update the display of plotting parameters for the current object |
---|
| 4213 | haxes=findobj(hview_field,'tag','axes3'); |
---|
| 4214 | pos=get(hview_field,'Position'); |
---|
| 4215 | if strcmp(get(haxes,'Visible'),'off')%sempty(PlotParam.Coordinates)% case of no plot display (pure text table) |
---|
| 4216 | h_TableDisplay=findobj(hview_field,'tag','TableDisplay'); |
---|
| 4217 | pos_table=get(h_TableDisplay,'Position'); |
---|
| 4218 | set(hview_field,'Position',[pos(1)+pos(3)-pos_table(3) pos(2)+pos(4)-pos_table(4) pos_table(3) pos_table(4)]) |
---|
| 4219 | else |
---|
| 4220 | Data=get(hview_field,'UserData'); |
---|
[432] | 4221 | set(hview_field,'Position',Data.GUISize)% restore the size of view_field for plots |
---|
[429] | 4222 | end |
---|
[410] | 4223 | else |
---|
[424] | 4224 | hview_field=findobj(allchild(0),'tag','view_field'); |
---|
| 4225 | if ~isempty(hview_field) |
---|
| 4226 | delete(hview_field)% delete existing version of set_object |
---|
[410] | 4227 | end |
---|
[402] | 4228 | end |
---|
| 4229 | |
---|
[424] | 4230 | |
---|
[402] | 4231 | %------------------------------------------------------------------------ |
---|
| 4232 | % --- Executes on button press in delete_object. |
---|
| 4233 | function delete_object_Callback(hObject, eventdata, handles) |
---|
| 4234 | %------------------------------------------------------------------------ |
---|
[499] | 4235 | IndexObj=get(handles.ListObject,'Value');%projection object selected for view_field |
---|
| 4236 | IndexObj_1=get(handles.ListObject_1,'Value');%projection object selected for uvmat plot |
---|
| 4237 | if IndexObj>1 && ~isequal(IndexObj,IndexObj_1) % do not delete the object used for the uvmat plot |
---|
[410] | 4238 | delete_object(IndexObj) |
---|
[402] | 4239 | end |
---|
| 4240 | |
---|
| 4241 | %------------------------------------------------------------------------ |
---|
| 4242 | %------------------------------------------------------------------------ |
---|
| 4243 | % II - TOOLS FROM THE UPPER MENU BAR |
---|
| 4244 | %------------------------------------------------------------------------ |
---|
| 4245 | %------------------------------------------------------------------------ |
---|
| 4246 | |
---|
| 4247 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
---|
| 4248 | % Export Menu Callbacks |
---|
| 4249 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
---|
| 4250 | %------------------------------------------------------------------------ |
---|
[387] | 4251 | % --- Executes on button press in Menu/Export/field in workspace. |
---|
| 4252 | function MenuExportField_Callback(hObject, eventdata, handles) |
---|
[402] | 4253 | %------------------------------------------------------------------------ |
---|
[387] | 4254 | global Data_uvmat |
---|
| 4255 | Data_uvmat=get(handles.uvmat,'UserData'); |
---|
| 4256 | evalin('base','global Data_uvmat')%make CurData global in the workspace |
---|
| 4257 | display('current field :') |
---|
| 4258 | evalin('base','Data_uvmat') %display CurData in the workspace |
---|
| 4259 | commandwindow; %brings the Matlab command window to the front |
---|
| 4260 | |
---|
[402] | 4261 | %------------------------------------------------------------------------ |
---|
[387] | 4262 | % --- Executes on button press in Menu/Export/extract figure. |
---|
[402] | 4263 | function MenuExportFigure_Callback(hObject, eventdata, handles) |
---|
| 4264 | %------------------------------------------------------------------------ |
---|
| 4265 | % huvmat=get(handles.MenuExport,'parent'); |
---|
[387] | 4266 | hfig=figure; |
---|
[511] | 4267 | copyobj(handles.PlotAxes,hfig); |
---|
| 4268 | map=colormap(handles.PlotAxes); |
---|
[387] | 4269 | colormap(map);%transmit the current colormap to the zoom fig |
---|
| 4270 | colorbar |
---|
| 4271 | |
---|
[508] | 4272 | % -------------------------------------------------------------------- |
---|
| 4273 | function MenuExportAxis_Callback(hObject, eventdata, handles) |
---|
| 4274 | answer=msgbox_uvmat('CONFIRMATION','select a figure/axis on which the current uvmat plot will be exported') |
---|
| 4275 | if strcmp(answer,'Yes') |
---|
[511] | 4276 | hchild=get(handles.PlotAxes,'children'); |
---|
[508] | 4277 | copyobj(hchild,gca); |
---|
| 4278 | end |
---|
[387] | 4279 | |
---|
| 4280 | %------------------------------------------------------------------------ |
---|
| 4281 | % -------------------------------------------------------------------- |
---|
| 4282 | function MenuExportMovie_Callback(hObject, eventdata, handles) |
---|
| 4283 | % -------------------------------------------------------------------- |
---|
| 4284 | set(handles.MenuExportMovie,'BusyAction','queue')% activate the button |
---|
| 4285 | huvmat=get(handles.run0,'parent'); |
---|
| 4286 | UvData=get(huvmat,'UserData'); |
---|
| 4287 | %[xx,xx,FileBase]=read_file_boxes(handles); |
---|
[515] | 4288 | [RootPath,SubDir,RootFile,FileIndex,FileExt]=read_file_boxes(handles); |
---|
[387] | 4289 | FileBase=fullfile(RootPath,RootFile); |
---|
| 4290 | %read the current input file name |
---|
| 4291 | 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)'}; |
---|
| 4292 | dlg_title = 'select properties of the output avi movie'; |
---|
| 4293 | num_lines= 1; |
---|
| 4294 | def = {[FileBase '_out.avi'];'10';'1';'[0.03 0.05 0.95 0.92]';'10'}; |
---|
| 4295 | answer = inputdlg(prompt,dlg_title,num_lines,def,'on'); |
---|
| 4296 | aviname=answer{1}; |
---|
| 4297 | fps=str2double(answer{2}); |
---|
| 4298 | % check for existing file with output name aviname |
---|
| 4299 | if exist(aviname,'file') |
---|
| 4300 | backup=aviname; |
---|
| 4301 | testexist=2; |
---|
| 4302 | while testexist==2 |
---|
| 4303 | backup=[backup '~']; |
---|
| 4304 | testexist=exist(backup,'file'); |
---|
| 4305 | end |
---|
| 4306 | [success,message]=copyfile(aviname,backup);%make backup of the existing file |
---|
| 4307 | if isequal(success,1) |
---|
| 4308 | delete(aviname)%delete existing file |
---|
| 4309 | else |
---|
| 4310 | msgbox_uvmat('ERROR',message) |
---|
| 4311 | return |
---|
| 4312 | end |
---|
| 4313 | end |
---|
| 4314 | %create avi open |
---|
| 4315 | aviobj=avifile(aviname,'Compression','None','fps',fps); |
---|
| 4316 | |
---|
| 4317 | %display first view for tests |
---|
| 4318 | newfig=figure; |
---|
[511] | 4319 | newaxes=copyobj(handles.PlotAxes,newfig);%new plotting axes in the new figure |
---|
[387] | 4320 | set(newaxes,'Tag','movieaxes') |
---|
| 4321 | nbpix=[512 384]*str2double(answer{3}); |
---|
| 4322 | set(gcf,'Position',[1 1 nbpix])% resolution XVGA |
---|
| 4323 | set(newaxes,'Position',eval(answer{4})); |
---|
[511] | 4324 | map=colormap(handles.PlotAxes); |
---|
[387] | 4325 | colormap(map);%transmit the current colormap to the zoom fig |
---|
| 4326 | msgbox_uvmat('INPUT_Y-N',{['adjust figure ' num2str(newfig) ' with its matlab edit menu '] ;... |
---|
| 4327 | ['then press OK to get the avi movie as a copy of figure ' num2str(newfig) ' display']}); |
---|
| 4328 | UvData.plotaxes=newaxes;% the axis in the new figure becomes the current main plotting axes |
---|
| 4329 | set(huvmat,'UserData',UvData); |
---|
[511] | 4330 | increment=str2num(get(handles.num_IndexIncrement,'String')); %get the field increment d |
---|
[387] | 4331 | set(handles.STOP,'Visible','on') |
---|
| 4332 | set(handles.speed,'Visible','on') |
---|
| 4333 | set(handles.speed_txt,'Visible','on') |
---|
| 4334 | set(handles.Movie,'BusyAction','queue') |
---|
| 4335 | |
---|
| 4336 | %imin=str2double(get(handles.i1,'String')); |
---|
| 4337 | imax=str2double(answer{5}); |
---|
| 4338 | % if isfield(UvData,'Time') |
---|
| 4339 | htitle=get(newaxes,'Title'); |
---|
| 4340 | xlim=get(newaxes,'XLim'); |
---|
| 4341 | ylim=get(newaxes,'YLim'); |
---|
| 4342 | set(htitle,'Position',[xlim(2)+0.07*(xlim(2)-xlim(1)) ylim(2)-0.05*(ylim(2)-ylim(1)) 0]) |
---|
| 4343 | time_str=get(handles.abs_time,'String'); |
---|
| 4344 | set(htitle,'String',['t=' time_str]) |
---|
| 4345 | set(handles.speed,'Value',1) |
---|
| 4346 | for i=1:imax |
---|
| 4347 | if get(handles.speed,'Value')~=0 && isequal(get(handles.MenuExportMovie,'BusyAction'),'queue') % enable STOP command |
---|
| 4348 | runpm(hObject,eventdata,handles,increment)% run plus |
---|
| 4349 | drawnow |
---|
| 4350 | time_str=get(handles.abs_time,'String'); |
---|
| 4351 | if ishandle(htitle) |
---|
| 4352 | set(htitle,'String',['t=' time_str]) |
---|
| 4353 | end |
---|
| 4354 | mov=getframe(newfig); |
---|
| 4355 | aviobj=addframe(aviobj,mov); |
---|
| 4356 | end |
---|
| 4357 | end |
---|
| 4358 | aviobj=close(aviobj); |
---|
| 4359 | UvData=rmfield(UvData,'plotaxes'); |
---|
[511] | 4360 | %UvData.Object{1}.plotaxes=handles.PlotAxes; |
---|
[387] | 4361 | set(huvmat,'UserData',UvData); |
---|
| 4362 | msgbox_uvmat('CONFIRMATION',{['movie ' aviname ' created '];['with ' num2str(imax) ' frames']}) |
---|
| 4363 | |
---|
[402] | 4364 | |
---|
| 4365 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
---|
| 4366 | % Projection Objects Menu Callbacks |
---|
| 4367 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
---|
| 4368 | |
---|
| 4369 | % ----------------------------------------------------------------------- |
---|
| 4370 | function Menupoints_Callback(hObject, eventdata, handles) |
---|
[387] | 4371 | %------------------------------------------------------------------------ |
---|
[402] | 4372 | data.Type='points'; |
---|
| 4373 | data.ProjMode='projection';%default |
---|
[410] | 4374 | data.ProjModeMenu={};% do not restrict ProjMode menus |
---|
[402] | 4375 | create_object(data,handles) |
---|
| 4376 | |
---|
| 4377 | % ----------------------------------------------------------------------- |
---|
| 4378 | function Menuline_Callback(hObject, eventdata, handles) |
---|
| 4379 | %------------------------------------------------------------------------ |
---|
| 4380 | data.Type='line'; |
---|
| 4381 | data.ProjMode='projection';%default |
---|
[410] | 4382 | data.ProjModeMenu={};% do not restrict ProjMode menus |
---|
[402] | 4383 | create_object(data,handles) |
---|
| 4384 | |
---|
| 4385 | %------------------------------------------------------------------------ |
---|
| 4386 | function Menupolyline_Callback(hObject, eventdata, handles) |
---|
| 4387 | %------------------------------------------------------------------------ |
---|
| 4388 | data.Type='polyline'; |
---|
| 4389 | data.ProjMode='projection';%default |
---|
[410] | 4390 | data.ProjModeMenu={};% do not restrict ProjMode menus |
---|
[402] | 4391 | create_object(data,handles) |
---|
| 4392 | |
---|
| 4393 | %------------------------------------------------------------------------ |
---|
| 4394 | function Menupolygon_Callback(hObject, eventdata, handles) |
---|
| 4395 | %------------------------------------------------------------------------ |
---|
| 4396 | data.Type='polygon'; |
---|
| 4397 | data.ProjMode='inside';%default |
---|
[410] | 4398 | data.ProjModeMenu={};% do not restrict ProjMode menus |
---|
[402] | 4399 | create_object(data,handles) |
---|
| 4400 | |
---|
| 4401 | %------------------------------------------------------------------------ |
---|
| 4402 | function Menurectangle_Callback(hObject, eventdata, handles) |
---|
| 4403 | %------------------------------------------------------------------------ |
---|
| 4404 | data.Type='rectangle'; |
---|
| 4405 | data.ProjMode='inside';%default |
---|
[410] | 4406 | data.ProjModeMenu={};% do not restrict ProjMode menus |
---|
[402] | 4407 | create_object(data,handles) |
---|
| 4408 | |
---|
| 4409 | %------------------------------------------------------------------------ |
---|
| 4410 | function Menuellipse_Callback(hObject, eventdata, handles) |
---|
| 4411 | %------------------------------------------------------------------------ |
---|
| 4412 | data.Type='ellipse'; |
---|
| 4413 | data.ProjMode='inside';%default |
---|
[410] | 4414 | data.ProjModeMenu={};% do not restrict ProjMode menus |
---|
[402] | 4415 | create_object(data,handles) |
---|
| 4416 | |
---|
| 4417 | %------------------------------------------------------------------------ |
---|
| 4418 | function MenuMaskObject_Callback(hObject, eventdata, handles) |
---|
| 4419 | %------------------------------------------------------------------------ |
---|
| 4420 | data.Type='polygon'; |
---|
| 4421 | data.TypeMenu={'polygon'}; |
---|
| 4422 | data.ProjMode='mask_inside';%default |
---|
| 4423 | data.ProjModeMenu={'mask_inside';'mask_outside'}; |
---|
| 4424 | create_object(data,handles) |
---|
| 4425 | |
---|
| 4426 | %------------------------------------------------------------------------ |
---|
| 4427 | function Menuplane_Callback(hObject, eventdata, handles) |
---|
| 4428 | %------------------------------------------------------------------------ |
---|
| 4429 | data.Type='plane'; |
---|
| 4430 | data.ProjMode='projection';%default |
---|
[410] | 4431 | data.ProjModeMenu={};% do not restrict ProjMode menus |
---|
[402] | 4432 | create_object(data,handles) |
---|
| 4433 | |
---|
| 4434 | %------------------------------------------------------------------------ |
---|
| 4435 | function Menuvolume_Callback(hObject, eventdata, handles) |
---|
| 4436 | %------------------------------------------------------------------------ |
---|
| 4437 | data.Type='volume'; |
---|
| 4438 | data.ProjMode='interp';%default |
---|
[410] | 4439 | data.ProjModeMenu={}; |
---|
[402] | 4440 | % set(handles.create,'Visible','on') |
---|
| 4441 | % set(handles.create,'Value',1) |
---|
[410] | 4442 | % VOLUME_Callback(hObject,eventdata,handles)data.ProjModeMenu={}; |
---|
[402] | 4443 | create_object(data,handles) |
---|
| 4444 | |
---|
| 4445 | %------------------------------------------------------------------------ |
---|
| 4446 | % --- generic function used for the creation of a projection object |
---|
| 4447 | function create_object(data,handles) |
---|
| 4448 | %------------------------------------------------------------------------ |
---|
[410] | 4449 | % desactivate geometric calibration if opened |
---|
[402] | 4450 | hgeometry_calib=findobj(allchild(0),'tag','geometry_calib'); |
---|
| 4451 | if ishandle(hgeometry_calib) |
---|
| 4452 | hhgeometry_calib=guidata(hgeometry_calib); |
---|
| 4453 | set(hhgeometry_calib.edit_append,'Value',0)% desactivate mouse action in geometry_calib |
---|
| 4454 | set(hhgeometry_calib.edit_append,'BackgroundColor',[0.7 0.7 0.7]) |
---|
| 4455 | end |
---|
| 4456 | set(handles.edit_object,'Value',0); %suppress the object edit mode |
---|
| 4457 | set(handles.edit_object,'BackgroundColor',[0.7,0.7,0.7]) |
---|
[429] | 4458 | ListObject=get(handles.ListObject,'String'); |
---|
[534] | 4459 | if isempty(ListObject) |
---|
| 4460 | ListObject={''}; |
---|
| 4461 | end |
---|
[429] | 4462 | if ~strcmp(ListObject{end},'') |
---|
| 4463 | ListObject=[ListObject;{''}]; %append a blank to the list (if nort already done) to indicate the creation of a new object |
---|
| 4464 | set(handles.ListObject,'String',ListObject) |
---|
| 4465 | end |
---|
| 4466 | IndexObj=length(ListObject); |
---|
| 4467 | set(handles.ListObject,'Value',IndexObj) |
---|
[410] | 4468 | UvData=get(handles.uvmat,'UserData'); |
---|
[429] | 4469 | UvData.Object{IndexObj}=[]; %create a new empty object |
---|
[511] | 4470 | UvData.Object{IndexObj}.DisplayHandle.uvmat=handles.PlotAxes; % axes for plot_object |
---|
[432] | 4471 | UvData.Object{IndexObj}.DisplayHandle.view_field=[]; %no plot handle before plot_field operation |
---|
[410] | 4472 | data.Name=data.Type;% default name=type |
---|
[402] | 4473 | data.Coord=[0 0]; %default |
---|
| 4474 | if isfield(UvData,'Field') |
---|
| 4475 | Field=UvData.Field; |
---|
[404] | 4476 | if isfield(UvData.Field,'Mesh')&&~isempty(UvData.Field.Mesh) |
---|
| 4477 | data.RangeX=[UvData.Field.XMin UvData.Field.XMax]; |
---|
[410] | 4478 | if strcmp(data.Type,'line')||strcmp(data.Type,'polyline')||strcmp(data.Type,'points') |
---|
[406] | 4479 | data.RangeY=UvData.Field.Mesh; |
---|
| 4480 | else |
---|
| 4481 | data.RangeY=[UvData.Field.YMin UvData.Field.YMax]; |
---|
| 4482 | end |
---|
[404] | 4483 | data.DX=UvData.Field.Mesh; |
---|
| 4484 | data.DY=UvData.Field.Mesh; |
---|
[402] | 4485 | end |
---|
| 4486 | if isfield(Field,'NbDim')&& isequal(Field.NbDim,3) |
---|
| 4487 | data.Coord=[0 0 0]; %default |
---|
| 4488 | end |
---|
| 4489 | if isfield(Field,'CoordUnit') |
---|
| 4490 | data.CoordUnit=Field.CoordUnit; |
---|
| 4491 | end |
---|
| 4492 | end |
---|
| 4493 | if ishandle(handles.UVMAT_title) |
---|
| 4494 | delete(handles.UVMAT_title)%delete the initial display of uvmat if no field has been entered |
---|
| 4495 | end |
---|
| 4496 | hset_object=set_object(data,handles);% call the set_object interface |
---|
| 4497 | hhset_object=guidata(hset_object); |
---|
[421] | 4498 | hchild=get(hset_object,'children'); |
---|
| 4499 | set(hchild,'enable','on') |
---|
[402] | 4500 | set(handles.uvmat,'UserData',UvData) |
---|
[410] | 4501 | set(handles.CheckZoom,'Value',0) %desactivate the zoom for object creation by the mouse |
---|
[402] | 4502 | CheckZoom_Callback(handles.uvmat, [], handles) |
---|
| 4503 | set(handles.delete_object,'Visible','on') |
---|
| 4504 | |
---|
| 4505 | %------------------------------------------------------------------------ |
---|
| 4506 | function MenuBrowseObject_Callback(hObject, eventdata, handles) |
---|
| 4507 | %------------------------------------------------------------------------ |
---|
| 4508 | %get the object file |
---|
| 4509 | [FileName, PathName, filterindex] = uigetfile( ... |
---|
| 4510 | {'*.xml;*.mat', ' (*.xml,*.mat)'; |
---|
| 4511 | '*.xml', '.xml files '; ... |
---|
| 4512 | '*.mat', '.mat matlab files '}, ... |
---|
| 4513 | 'Pick an xml Object file',get(handles.RootPath,'String')); |
---|
| 4514 | fileinput=[PathName FileName];%complete file name |
---|
| 4515 | sizf=size(fileinput); |
---|
| 4516 | if (~ischar(fileinput)||~isequal(sizf(1),1)),return;end |
---|
| 4517 | |
---|
| 4518 | %read the file |
---|
[477] | 4519 | [data,heading]=xml2struct(fileinput); |
---|
| 4520 | if ~strcmp(heading,'ProjObject') |
---|
| 4521 | msgbox_uvmat('WARNING','The xml file does not have the heading ProjObject for projection objects') |
---|
| 4522 | end |
---|
[427] | 4523 | [tild,data.Name]=fileparts(FileName);% object name set as file name |
---|
[429] | 4524 | ListObject=get(handles.ListObject,'String'); |
---|
| 4525 | if ~strcmp(ListObject{end},'') |
---|
| 4526 | ListObject=[ListObject;{''}]; %append a blank to the list (if not already done) to indicate the creation of a new object |
---|
| 4527 | set(handles.ListObject,'String',ListObject) |
---|
| 4528 | end |
---|
[445] | 4529 | IndexObj=length(ListObject); |
---|
| 4530 | |
---|
[432] | 4531 | UvData=get(handles.uvmat,'UserData'); |
---|
| 4532 | UvData.Object{IndexObj}=[]; %create a new empty object |
---|
| 4533 | UvData.Object{IndexObj}.DisplayHandle.uvmat=[]; %no plot handle before plot_field operation |
---|
| 4534 | UvData.Object{IndexObj}.DisplayHandle.view_field=[]; %no plot handle before plot_field operation |
---|
| 4535 | set(handles.uvmat,'UserData',UvData) |
---|
[445] | 4536 | set(handles.ListObject,'Value',IndexObj) |
---|
[427] | 4537 | hset_object=set_object(data);% call the set_object interface |
---|
| 4538 | set(get(hset_object,'children'),'enable','on')% enable edit action on elements on GUI set_object |
---|
[402] | 4539 | set(handles.edit_object,'Value',0); %suppress the object edit mode |
---|
| 4540 | set(handles.edit_object,'BackgroundColor',[0.7,0.7,0.7]) |
---|
| 4541 | set(handles.delete_object,'Visible','on') |
---|
| 4542 | |
---|
[432] | 4543 | |
---|
[402] | 4544 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
---|
| 4545 | % MenuEdit Callbacks |
---|
| 4546 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
---|
| 4547 | %------------------------------------------------------------------------ |
---|
| 4548 | function MenuEditObject_Callback(hObject, eventdata, handles) |
---|
| 4549 | %------------------------------------------------------------------------ |
---|
| 4550 | set(handles.edit_object,'Value',1) |
---|
| 4551 | edit_Callback(hObject, eventdata, handles) |
---|
| 4552 | |
---|
| 4553 | %------------------------------------------------------------------------ |
---|
| 4554 | function MenuEditVectors_Callback(hObject, eventdata, handles) |
---|
| 4555 | %------------------------------------------------------------------------ |
---|
| 4556 | set(handles.edit_vect,'Visible','on') |
---|
| 4557 | set(handles.edit_vect,'Value',1) |
---|
| 4558 | edit_vect_Callback(hObject, eventdata, handles) |
---|
| 4559 | |
---|
| 4560 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
---|
| 4561 | % MenuTools Callbacks |
---|
| 4562 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
---|
| 4563 | %------------------------------------------------------------------------ |
---|
[387] | 4564 | function MenuCalib_Callback(hObject, eventdata, handles) |
---|
| 4565 | %------------------------------------------------------------------------ |
---|
| 4566 | |
---|
| 4567 | UvData=get(handles.uvmat,'UserData');%read UvData properties stored on the uvmat interface |
---|
| 4568 | |
---|
| 4569 | %suppress competing options |
---|
| 4570 | set(handles.CheckZoom,'Value',0) |
---|
| 4571 | set(handles.CheckZoom,'BackgroundColor',[0.7 0.7 0.7]) |
---|
| 4572 | set(handles.ListObject,'Value',1) |
---|
| 4573 | % initiate display of GUI geometry_calib |
---|
| 4574 | data=[]; %default |
---|
| 4575 | if isfield(UvData,'CoordType') |
---|
| 4576 | data.CoordType=UvData.CoordType; |
---|
| 4577 | end |
---|
[515] | 4578 | [RootPath,SubDir,RootFile,FileIndex,FileExt]=read_file_boxes(handles); |
---|
| 4579 | FileName=[fullfile(RootPath,SubDir,RootFile) FileIndex FileExt]; |
---|
[387] | 4580 | set(handles.view_xml,'Backgroundcolor',[1 1 0])%indicate the reading of the current xml file by geometry_calib |
---|
[517] | 4581 | pos_uvmat=get(handles.uvmat,'Position'); |
---|
| 4582 | pos_cal(1)=pos_uvmat(1)+UvData.OpenParam.PosGeometryCalib(1)*pos_uvmat(3); |
---|
| 4583 | pos_cal(2)=pos_uvmat(2)+UvData.OpenParam.PosGeometryCalib(2)*pos_uvmat(4); |
---|
| 4584 | pos_cal(3:4)=UvData.OpenParam.PosGeometryCalib(3:4).* pos_uvmat(3:4); |
---|
[387] | 4585 | geometry_calib(FileName,pos_cal);% call the geometry_calib interface |
---|
| 4586 | set(handles.view_xml,'Backgroundcolor',[1 1 1])%indicate the end of reading of the current xml file by geometry_calib |
---|
| 4587 | set(handles.MenuCalib,'checked','on')% indicate that MenuCalib is activated, test used by mouse action |
---|
| 4588 | |
---|
| 4589 | %------------------------------------------------------------------------ |
---|
| 4590 | function MenuMask_Callback(hObject, eventdata, handles) |
---|
| 4591 | %------------------------------------------------------------------------ |
---|
| 4592 | UvData=get(handles.uvmat,'UserData');%read UvData properties stored on the uvmat interface |
---|
| 4593 | ListObj=UvData.Object; |
---|
| 4594 | select=zeros(1,numel(ListObj)); |
---|
| 4595 | for iobj=1:numel(ListObj); |
---|
| 4596 | if strcmp(ListObj{iobj}.ProjMode,'mask_inside')||strcmp(ListObj{iobj}.ProjMode,'mask_outside') |
---|
| 4597 | select(iobj)=1; |
---|
| 4598 | end |
---|
| 4599 | end |
---|
| 4600 | val=find(select); |
---|
| 4601 | if isempty(val) |
---|
| 4602 | msgbox_uvmat('ERROR','polygons must be first created by Projection object/mask polygon in the menu bar'); |
---|
| 4603 | return |
---|
| 4604 | else |
---|
| 4605 | set(handles.ListObject,'Value',val); |
---|
| 4606 | flag=1; |
---|
| 4607 | npx=size(UvData.Field.A,2); |
---|
| 4608 | npy=size(UvData.Field.A,1); |
---|
| 4609 | xi=0.5:npx-0.5; |
---|
| 4610 | yi=0.5:npy-0.5; |
---|
| 4611 | [Xi,Yi]=meshgrid(xi,yi); |
---|
| 4612 | if isfield(UvData,'Object') |
---|
| 4613 | for iobj=1:length(UvData.Object) |
---|
| 4614 | ObjectData=UvData.Object{iobj}; |
---|
| 4615 | if isfield(ObjectData,'ProjMode') &&(isequal(ObjectData.ProjMode,'mask_inside')||isequal(ObjectData.ProjMode,'mask_outside')); |
---|
| 4616 | flagobj=1; |
---|
| 4617 | testphys=0; %coordinates in pixels by default |
---|
| 4618 | if isfield(ObjectData,'CoordUnit') && ~isequal(ObjectData.CoordUnit,'pixel') |
---|
| 4619 | if isfield(UvData,'XmlData')&& isfield(UvData.XmlData{1},'GeometryCalib') |
---|
| 4620 | Calib=UvData.XmlData{1}.GeometryCalib; |
---|
| 4621 | testphys=1; |
---|
| 4622 | end |
---|
| 4623 | end |
---|
| 4624 | if isfield(ObjectData,'Coord')&& isfield(ObjectData,'Type') |
---|
| 4625 | if isequal(ObjectData.Type,'polygon') |
---|
| 4626 | X=ObjectData.Coord(:,1); |
---|
| 4627 | Y=ObjectData.Coord(:,2); |
---|
| 4628 | if testphys |
---|
[542] | 4629 | pos=[X Y zeros(size(X))]; |
---|
| 4630 | if isfield(Calib,'SliceCoord') && length(Calib.SliceCoord)>=3 |
---|
| 4631 | if isfield(Calib,'SliceAngle')&&~isequal(Calib.SliceAngle,[0 0 0]) |
---|
| 4632 | om=norm(Calib.SliceAngle);%norm of rotation angle in radians |
---|
| 4633 | OmAxis=Calib.SliceAngle/om; %unit vector marking the rotation axis |
---|
| 4634 | cos_om=cos(pi*om/180); |
---|
| 4635 | sin_om=sin(pi*om/180); |
---|
| 4636 | pos=cos_om*pos+sin_om*cross(OmAxis,pos)+(1-cos_om)*(OmAxis*pos')*OmAxis; |
---|
| 4637 | end |
---|
| 4638 | pos(:,1)=pos(:,1)+Calib.SliceCoord(1); |
---|
| 4639 | pos(:,2)=pos(:,2)+Calib.SliceCoord(2); |
---|
| 4640 | pos(:,3)=pos(:,3)+Calib.SliceCoord(3); |
---|
| 4641 | end |
---|
| 4642 | [X,Y]=px_XYZ(Calib,pos(:,1),pos(:,2),pos(:,3)); |
---|
[387] | 4643 | end |
---|
| 4644 | flagobj=~inpolygon(Xi,Yi,X',Y');%=0 inside the polygon, 1 outside |
---|
| 4645 | elseif isequal(ObjectData.Type,'ellipse') |
---|
| 4646 | if testphys |
---|
| 4647 | %[X,Y]=px_XYZ(Calib,X,Y,0);% TODO:create a polygon boundary and transform to phys |
---|
| 4648 | end |
---|
| 4649 | RangeX=max(ObjectData.RangeX); |
---|
| 4650 | RangeY=max(ObjectData.RangeY); |
---|
| 4651 | X2Max=RangeX*RangeX; |
---|
| 4652 | Y2Max=RangeY*RangeY; |
---|
| 4653 | distX=(Xi-ObjectData.Coord(1,1)); |
---|
| 4654 | distY=(Yi-ObjectData.Coord(1,2)); |
---|
| 4655 | flagobj=(distX.*distX/X2Max+distY.*distY/Y2Max)>1; |
---|
| 4656 | elseif isequal(ObjectData.Type,'rectangle') |
---|
| 4657 | if testphys |
---|
| 4658 | %[X,Y]=px_XYZ(Calib,X,Y,0);% TODO:create a polygon boundary and transform to phys |
---|
| 4659 | end |
---|
| 4660 | distX=abs(Xi-ObjectData.Coord(1,1)); |
---|
| 4661 | distY=abs(Yi-ObjectData.Coord(1,2)); |
---|
| 4662 | flagobj=distX>max(ObjectData.RangeX) | distY>max(ObjectData.RangeY); |
---|
| 4663 | end |
---|
| 4664 | if isequal(ObjectData.ProjMode,'mask_outside') |
---|
| 4665 | flagobj=~flagobj; |
---|
| 4666 | end |
---|
| 4667 | flag=flag & flagobj; |
---|
| 4668 | end |
---|
| 4669 | end |
---|
| 4670 | end |
---|
| 4671 | end |
---|
| 4672 | %mask name |
---|
| 4673 | RootPath=get(handles.RootPath,'String'); |
---|
[444] | 4674 | SubDir=get(handles.SubDir,'String'); |
---|
[387] | 4675 | RootFile=get(handles.RootFile,'String'); |
---|
| 4676 | if ~isempty(RootFile)&&(isequal(RootFile(1),'/')|| isequal(RootFile(1),'\')) |
---|
| 4677 | RootFile(1)=[]; |
---|
| 4678 | end |
---|
| 4679 | list=get(handles.masklevel,'String'); |
---|
| 4680 | masknumber=num2str(length(list)); |
---|
| 4681 | maskindex=get(handles.masklevel,'Value'); |
---|
[444] | 4682 | % mask_name=fullfile_uvmat(RootPath,'',[RootFile '_' masknumber 'mask'],'.png','_1',maskindex); |
---|
| 4683 | mask_name=fullfile_uvmat(RootPath,[SubDir '.mask'],'mask','.png','_1',maskindex); |
---|
[387] | 4684 | imflag=uint8(255*(0.392+0.608*flag));% =100 for flag=0 (vectors not computed when 20<imflag<200) |
---|
| 4685 | imflag=flipdim(imflag,1); |
---|
| 4686 | |
---|
| 4687 | %display the mask |
---|
| 4688 | hfigmask=figure; |
---|
| 4689 | set(hfigmask,'Name','mask image') |
---|
| 4690 | vec=linspace(0,1,256);%define a linear greyscale colormap |
---|
| 4691 | map=[vec' vec' vec']; |
---|
| 4692 | colormap(map) |
---|
| 4693 | image(imflag); |
---|
| 4694 | answer=msgbox_uvmat('INPUT_TXT','mask file name:', mask_name); |
---|
| 4695 | if ~strcmp(answer,'Cancel') |
---|
| 4696 | mask_dir=fileparts(answer); |
---|
| 4697 | if ~exist(mask_dir,'dir') |
---|
[444] | 4698 | [xx,msg1]=mkdir(mask_dir); |
---|
| 4699 | if ~strcmp(msg1,'') |
---|
| 4700 | errormsg=['cannot create ' mask_dir ': ' msg1];%error message for directory creation |
---|
| 4701 | return |
---|
| 4702 | end |
---|
[387] | 4703 | end |
---|
| 4704 | imwrite(imflag,answer,'BitDepth',8); |
---|
| 4705 | end |
---|
| 4706 | set(handles.ListObject,'Value',1) |
---|
| 4707 | end |
---|
| 4708 | |
---|
| 4709 | %------------------------------------------------------------------------ |
---|
| 4710 | %-- open the GUI set_grid.fig to create grid |
---|
| 4711 | function MenuGrid_Callback(hObject, eventdata, handles) |
---|
| 4712 | %------------------------------------------------------------------------ |
---|
| 4713 | %suppress the other options if grid is chosen |
---|
| 4714 | set(handles.edit_vect,'Value',0) |
---|
| 4715 | edit_vect_Callback(hObject, eventdata, handles) |
---|
| 4716 | set(handles.edit_object,'BackgroundColor',[0.7 0.7 0.7]) |
---|
| 4717 | set(handles.ListObject,'Value',1) |
---|
| 4718 | |
---|
| 4719 | %prepare display of the set_grid GUI |
---|
[515] | 4720 | [RootPath,SubDir,RootFile,FileIndex,FileExt]=read_file_boxes(handles); |
---|
| 4721 | FileName=[fullfile(RootPath,SubDir,RootFile) FileIndex FileExt]; |
---|
[387] | 4722 | CoordList=get(handles.transform_fct,'String'); |
---|
| 4723 | val=get(handles.transform_fct,'Value'); |
---|
| 4724 | set_grid(FileName,CoordList{val});% call the set_object interface |
---|
| 4725 | |
---|
[402] | 4726 | |
---|
[387] | 4727 | %------------------------------------------------------------------------ |
---|
[402] | 4728 | function MenuRuler_Callback(hObject, eventdata, handles) |
---|
| 4729 | %------------------------------------------------------------------------ |
---|
| 4730 | set(handles.CheckZoom,'Value',0) |
---|
| 4731 | CheckZoom_Callback(handles.uvmat, [], handles) |
---|
| 4732 | set(handles.MenuRuler,'checked','on') |
---|
| 4733 | UvData=get(handles.uvmat,'UserData'); |
---|
| 4734 | UvData.MouseAction='ruler'; |
---|
| 4735 | set(handles.uvmat,'UserData',UvData); |
---|
| 4736 | |
---|
| 4737 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
---|
| 4738 | % MenuRun Callbacks |
---|
| 4739 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
---|
| 4740 | |
---|
| 4741 | %------------------------------------------------------------------------ |
---|
[387] | 4742 | % open the GUI 'series' |
---|
| 4743 | function MenuSeries_Callback(hObject, eventdata, handles) |
---|
| 4744 | %------------------------------------------------------------------------ |
---|
| 4745 | series; %first display of the GUI to fill waiting time |
---|
[515] | 4746 | [RootPath,SubDir,RootFile,FileIndex,FileExt]=read_file_boxes(handles); |
---|
[526] | 4747 | Param.FileName=[fullfile(RootPath,SubDir,RootFile) FileIndex FileExt];%first input file name |
---|
[387] | 4748 | if isequal(get(handles.SubField,'Value'),1) |
---|
[515] | 4749 | [RootPath_1,SubDir_1,RootFile_1,FileIndex_1,FileExt_1]=read_file_boxes_1(handles); |
---|
| 4750 | FileName_1=[fullfile(RootPath_1,SubDir_1,RootFile_1) FileIndex_1 FileExt_1]; |
---|
[526] | 4751 | if ~isequal(FileName_1,Param.FileName) |
---|
| 4752 | Param.FileName_1=FileName_1;%second input file name if relevant |
---|
[387] | 4753 | end |
---|
| 4754 | end |
---|
[526] | 4755 | Param.NomType=get(handles.NomType,'String'); |
---|
| 4756 | Param.NomType_1=get(handles.NomType_1,'String'); |
---|
| 4757 | Param.CheckFixPair=get(handles.CheckFixPair,'Value'); |
---|
| 4758 | UvData=get(handles.uvmat,'UserData'); |
---|
[387] | 4759 | if isfield(UvData,'XmlData')&& isfield(UvData.XmlData{1},'Time') |
---|
[526] | 4760 | Param.Time=UvData.XmlData{1}.Time; |
---|
[387] | 4761 | end |
---|
| 4762 | if isequal(get(handles.scan_i,'Value'),1) |
---|
[526] | 4763 | Param.incr_i=str2num(get(handles.num_IndexIncrement,'String')); |
---|
[387] | 4764 | elseif isequal(get(handles.scan_j,'Value'),1) |
---|
[526] | 4765 | Param.incr_j=str2num(get(handles.num_IndexIncrement,'String')); |
---|
[387] | 4766 | end |
---|
[526] | 4767 | |
---|
| 4768 | %% transfer fields and coordinate names |
---|
| 4769 | Param.list_fields=get(handles.FieldName,'String');% list menu fields |
---|
| 4770 | FieldName=Param.list_fields{get(handles.FieldName,'Value')}; |
---|
| 4771 | ind_image=find(strcmp('image',Param.list_fields)); |
---|
| 4772 | if ~isempty(ind_image) && numel(Param.list_fields)>1 |
---|
| 4773 | Param.list_fields(ind_image)=[]; %suppress 'image' option |
---|
[387] | 4774 | end |
---|
[526] | 4775 | Param.index_fields=find(strcmp(FieldName,Param.list_fields));% selected string index |
---|
| 4776 | Param.list_fields_1=get(handles.FieldName_1,'String');% list menu fields |
---|
| 4777 | if ischar(Param.list_fields_1),Param.list_fields_1={Param.list_fields_1};end |
---|
| 4778 | FieldName_1=Param.list_fields_1{get(handles.FieldName_1,'Value')}; |
---|
| 4779 | ind_image=find(strcmp('image',Param.list_fields_1)); |
---|
| 4780 | if ~isempty(ind_image) && numel(Param.list_fields_1)>1 |
---|
| 4781 | Param.list_fields_1(ind_image)=[]; %suppress 'image' option |
---|
[387] | 4782 | end |
---|
[526] | 4783 | Param.index_fields_1=find(strcmp(FieldName_1,Param.list_fields_1));% selected string index |
---|
| 4784 | Param.transform_str=get(handles.transform_fct,'String'); |
---|
| 4785 | Param.transform_val=get(handles.transform_fct,'Value'); |
---|
| 4786 | Param.Coord_x_str=get(handles.Coord_x,'String'); |
---|
| 4787 | Param.Coord_x_val=get(handles.Coord_x,'Value'); |
---|
| 4788 | Param.Coord_y_str=get(handles.Coord_y,'String'); |
---|
| 4789 | Param.Coord_y_val=get(handles.Coord_y,'Value'); |
---|
| 4790 | series(Param); %run the series interface |
---|
[387] | 4791 | |
---|
| 4792 | %------------------------------------------------------------------------ |
---|
[402] | 4793 | % -- open the GUI civ.fig for PIV |
---|
[387] | 4794 | function MenuPIV_Callback(hObject, eventdata, handles) |
---|
| 4795 | %------------------------------------------------------------------------ |
---|
[515] | 4796 | [RootPath,SubDir,RootFile,FileIndex,FileExt]=read_file_boxes(handles); |
---|
| 4797 | FileName=[fullfile(RootPath,SubDir,RootFile) FileIndex FileExt]; |
---|
[387] | 4798 | civ(FileName);% interface de civ(not in the uvmat file) |
---|
| 4799 | |
---|
[402] | 4800 | % -------------------------------------------------------------------- |
---|
| 4801 | function MenuHelp_Callback(hObject, eventdata, handles) |
---|
| 4802 | % -------------------------------------------------------------------- |
---|
| 4803 | path_to_uvmat=which ('uvmat');% check the path of uvmat |
---|
| 4804 | pathelp=fileparts(path_to_uvmat); |
---|
| 4805 | helpfile=fullfile(pathelp,'uvmat_doc','uvmat_doc.html'); |
---|
| 4806 | 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') |
---|
| 4807 | else |
---|
| 4808 | addpath (fullfile(pathelp,'uvmat_doc')) |
---|
| 4809 | web(helpfile); |
---|
[387] | 4810 | end |
---|
[497] | 4811 | |
---|
[507] | 4812 | |
---|
| 4813 | % -------------------------------------------------------------------- |
---|
| 4814 | function MenuSetProject_Callback(hObject, eventdata, handles) |
---|
| 4815 | RootPath=get(handles.RootPath,'String'); |
---|
| 4816 | ProjectDir = uigetdir(fileparts(fileparts(RootPath)), 'select the project source directory'); |
---|
| 4817 | datatree_browser(ProjectDir) |
---|
[512] | 4818 | |
---|
| 4819 | |
---|
| 4820 | % -------------------------------------------------------------------- |
---|
| 4821 | function MenuBrowseProject_Callback(hObject, eventdata, handles) |
---|
| 4822 | RootPath=get(handles.RootPath,'String'); |
---|
| 4823 | ProjectDir = uigetdir(fileparts(fileparts(RootPath)), 'select the project directory'); |
---|
| 4824 | datatree_browser(ProjectDir) |
---|
[517] | 4825 | |
---|
| 4826 | |
---|
| 4827 | % --- Executes on selection change in Coord_y. |
---|
| 4828 | function Coord_y_Callback(hObject, eventdata, handles) |
---|
| 4829 | |
---|
| 4830 | % --- Executes on selection change in Coord_x. |
---|
| 4831 | function Coord_x_Callback(hObject, eventdata, handles) |
---|
[546] | 4832 | |
---|
| 4833 | |
---|
| 4834 | % --- Executes on button press in CheckColorBar. |
---|
| 4835 | function CheckColorBar_Callback(hObject, eventdata, handles) |
---|
| 4836 | % hObject handle to CheckColorBar (see GCBO) |
---|
| 4837 | % eventdata reserved - to be defined in a future version of MATLAB |
---|
| 4838 | % handles structure with handles and user data (see GUIDATA) |
---|
| 4839 | |
---|
| 4840 | % Hint: get(hObject,'Value') returns toggle state of CheckColorBar |
---|