[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 |
---|
[591] | 36 | % .NbBuiltin: nbre of functions always displayed in TransformName menu |
---|
[511] | 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 | % | |
---|
[581] | 70 | % (tps_coeff_field.m) calculate tps coefficients (for filter projection or spatial derivatives). |
---|
[512] | 71 | % | |
---|
| 72 | % UvData.Field-------------->histogram |
---|
| 73 | % _____________|____________ |
---|
| 74 | % | | |
---|
[595] | 75 | % proj_field.m proj_field.m project the field on the projection objects (use set_field_list.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 | |
---|
[591] | 217 | %% load the list of previously browsed files in menus Open, Open_1 and TransformName |
---|
[576] | 218 | dir_perso=prefdir; % path to the directory .matlab containing the personal data of the current user |
---|
| 219 | profil_perso=fullfile(dir_perso,'uvmat_perso.mat');% personal data file uvmat_perso.mat' in .matlab |
---|
[387] | 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) |
---|
[576] | 224 | set(handles.(['MenuFile_' num2str(ifile)]),'Label',h.MenuFile{ifile}); |
---|
| 225 | set(handles.(['MenuFile_' num2str(ifile) '_1']),'Label',h.MenuFile{ifile}); |
---|
[507] | 226 | end |
---|
| 227 | end |
---|
[576] | 228 | if isfield(h,'RootPath') |
---|
| 229 | set(handles.RootPath,'UserData',h.RootPath); %store the previous campaign in the UserData of RootPath |
---|
| 230 | end |
---|
[523] | 231 | if isfield(h,'transform_fct') && iscell(h.transform_fct) % load the menu of transform fct set by user |
---|
[387] | 232 | for ilist=1:length(h.transform_fct); |
---|
| 233 | if exist(h.transform_fct{ilist},'file') |
---|
[507] | 234 | [path,file]=fileparts(h.transform_fct{ilist}); |
---|
| 235 | transform_menu=[transform_menu; {file}]; |
---|
| 236 | path_list=[path_list; {path}]; |
---|
[387] | 237 | end |
---|
| 238 | end |
---|
[507] | 239 | end |
---|
[387] | 240 | end |
---|
[523] | 241 | transform_menu=[transform_menu;{'more...'}];%append the option more.. to the menu |
---|
[591] | 242 | set(handles.TransformName,'String',transform_menu)% display the menu of transform fcts |
---|
| 243 | set(handles.TransformName,'UserData',path_list)% store the corresponding list of path in UserData of uicontrol transform_fct |
---|
| 244 | set(handles.TransformPath,'String','') |
---|
| 245 | set(handles.TransformPath,'UserData',[]) |
---|
[387] | 246 | |
---|
| 247 | %% case of an input argument for uvmat |
---|
| 248 | testinputfield=0; |
---|
| 249 | inputfile=[]; |
---|
| 250 | Field=[]; |
---|
| 251 | if exist('input','var') |
---|
| 252 | if ishandle(handles.UVMAT_title) |
---|
| 253 | delete(handles.UVMAT_title) |
---|
| 254 | end |
---|
| 255 | if isstruct(input) |
---|
| 256 | if isfield(input,'InputFile') |
---|
| 257 | inputfile=input.InputFile; |
---|
| 258 | end |
---|
| 259 | if isfield(input,'TimeIndex') |
---|
| 260 | set(handles.i1,num2str(input.TimeIndex)) |
---|
| 261 | end |
---|
| 262 | if isfield(input,'FieldsString') |
---|
| 263 | UvData.FieldsString=input.FieldsString; |
---|
| 264 | end |
---|
| 265 | elseif ischar(input)% file name introduced as input |
---|
| 266 | inputfile=input; |
---|
| 267 | elseif isnumeric(input)%simple matrix introduced as input |
---|
| 268 | sizinput=size(input); |
---|
| 269 | if sizinput(1)<=1 || sizinput(2)<=1 |
---|
| 270 | msgbox_uvmat('ERROR','bad input for uvmat: file name, structure or numerical matrix accepted') |
---|
| 271 | return |
---|
| 272 | end |
---|
| 273 | UvData.Field.ListVarName={'A','coord_y','coord_x'}; |
---|
| 274 | UvData.Field.VarDimName={{'coord_y','coord_x'},'cord_y','coord_x'}; |
---|
| 275 | UvData.Field.A=input; |
---|
| 276 | UvData.Field.coord_x=[0.5 size(input,2)-0.5]; |
---|
| 277 | UvData.Field.coord_y=[size(input,1)-0.5 0.5]; |
---|
| 278 | testinputfield=1; |
---|
| 279 | end |
---|
| 280 | else |
---|
[476] | 281 | %% check the path and date of modification of all functions in uvmat |
---|
| 282 | path_to_uvmat=which ('uvmat');% check the path detected for source file uvmat |
---|
| 283 | [infomsg,date_str,svn_info]=check_files;%check the path of the functions called by uvmat.m |
---|
| 284 | date_str=['last modification: ' date_str]; |
---|
| 285 | if ishandle(handles.UVMAT_title) |
---|
| 286 | set(handles.UVMAT_title,'String',... |
---|
| 287 | [{'Copyright LEGI UMR 5519 /CNRS-UJF-Grenoble INP, 2010'};... |
---|
| 288 | {'GNU General Public License'};... |
---|
| 289 | {path_to_uvmat};... |
---|
| 290 | {date_str};... |
---|
| 291 | infomsg]); |
---|
| 292 | end |
---|
[387] | 293 | end |
---|
| 294 | set(handles.uvmat,'UserData',UvData) |
---|
| 295 | if ~isempty(inputfile) |
---|
| 296 | %%%%% display the input field %%%%%%% |
---|
[406] | 297 | display_file_name(handles,inputfile) |
---|
[387] | 298 | %%%%%%% |
---|
| 299 | end |
---|
| 300 | |
---|
| 301 | set_vec_col_bar(handles) %update the display of color code for vectors |
---|
| 302 | |
---|
| 303 | %------------------------------------------------------------------------ |
---|
| 304 | % --- Outputs from this function are returned to the command menuline. |
---|
| 305 | function varargout = uvmat_OutputFcn(hObject, eventdata, handles) |
---|
| 306 | varargout{1} = handles.output;% the only output argument is the handle to the GUI figure |
---|
| 307 | |
---|
| 308 | %------------------------------------------------------------------------ |
---|
[402] | 309 | % --- executed when closing uvmat: delete or desactivate the associated figures if exist |
---|
| 310 | function closefcn(gcbo,eventdata) |
---|
[387] | 311 | %------------------------------------------------------------------------ |
---|
[402] | 312 | hh=findobj(allchild(0),'tag','view_field'); |
---|
| 313 | if ~isempty(hh) |
---|
| 314 | delete(hh) |
---|
| 315 | end |
---|
| 316 | hh=findobj(allchild(0),'tag','geometry_calib'); |
---|
| 317 | if ~isempty(hh) |
---|
| 318 | delete(hh) |
---|
| 319 | end |
---|
| 320 | hh=findobj(allchild(0),'tag','set_object'); |
---|
| 321 | if ~isempty(hh) |
---|
| 322 | hhh=findobj(hh,'tag','PLOT'); |
---|
| 323 | set(hhh,'enable','off') |
---|
| 324 | end |
---|
| 325 | |
---|
| 326 | %------------------------------------------------------------------------ |
---|
| 327 | %------------------------------------------------------------------------ |
---|
[387] | 328 | % II - FUNCTIONS FOR INTRODUCING THE INPUT FILES |
---|
| 329 | % automatically sets the global properties when the rootfile name is introduced |
---|
| 330 | % then activate the view-field action if selected |
---|
| 331 | % it is activated either by clicking on the RootPath window or by the |
---|
| 332 | % browser |
---|
| 333 | %------------------------------------------------------------------------ |
---|
| 334 | %------------------------------------------------------------------------ |
---|
| 335 | % --- Executes on the menu Open/Browse... |
---|
| 336 | % search the files, recognize their type according to their name and fill the rootfile input windows |
---|
| 337 | function MenuBrowse_Callback(hObject, eventdata, handles) |
---|
| 338 | [RootPath,SubDir,RootFile,FileIndices,FileExt]=read_file_boxes(handles); |
---|
[512] | 339 | oldfile=fullfile(RootPath,SubDir); |
---|
[576] | 340 | if isempty(oldfile) %loads the previously stored file name and set it as default in the file_input box |
---|
| 341 | oldfile=get(handles.RootPath,'UserData'); |
---|
[387] | 342 | end |
---|
[421] | 343 | [FileName, PathName] = uigetfile({'*.*','All Files(*.*)'},'Pick a file',oldfile); |
---|
[530] | 344 | if ~ischar(FileName),return,end %abandon if the browser is cancelled |
---|
[387] | 345 | fileinput=[PathName FileName];%complete file name |
---|
| 346 | |
---|
[503] | 347 | %% display the selected field and related information |
---|
[406] | 348 | display_file_name( handles,fileinput) |
---|
[387] | 349 | |
---|
| 350 | % ----------------------------------------------------------------------- |
---|
[569] | 351 | % --- Executes on the menu Open/Browse campaign... |
---|
| 352 | % search the file inside a campaign, using the GUI view_data |
---|
| 353 | function MenuBrowseCampaign_Callback(hObject, eventdata, handles) |
---|
| 354 | % ----------------------------------------------------------------------- |
---|
[576] | 355 | RootPath=get(handles.RootPath,'String'); |
---|
| 356 | if isempty(RootPath) |
---|
| 357 | RootPath=get(handles.RootPath,'UserData');%use Rootpath recored from the personal file at uvmat opening |
---|
| 358 | end |
---|
| 359 | CampaignPath=fileparts(fileparts(RootPath)); |
---|
[569] | 360 | DirFull = uigetdir(CampaignPath,'Select a Campaign dir, then press OK'); |
---|
| 361 | if ~ischar(DirFull)|| ~exist(DirFull,'dir') |
---|
| 362 | return |
---|
| 363 | end |
---|
| 364 | OutPut=browse_data(DirFull);% open the GUI browse_data to get select a campaign dir, experiment and device |
---|
| 365 | if ~isfield(OutPut,'Campaign') |
---|
| 366 | return |
---|
| 367 | end |
---|
| 368 | DirName=fullfile(OutPut.Campaign,OutPut.Experiment{1},OutPut.Device{1}); |
---|
| 369 | hdir=dir(DirName); %list files and dirs |
---|
| 370 | for ilist=1:numel(hdir) |
---|
| 371 | if ~isequal(hdir(ilist).isdir,1)%look for files, not dir |
---|
| 372 | FileName=hdir(ilist).name; |
---|
| 373 | FileType=get_file_type(fullfile(DirName,FileName)); |
---|
| 374 | switch FileType |
---|
| 375 | case {'image','multimage','civx','civdata','netcdf'} |
---|
| 376 | break |
---|
| 377 | end |
---|
| 378 | end |
---|
| 379 | end |
---|
| 380 | |
---|
| 381 | %% display the selected field and related information |
---|
| 382 | display_file_name( handles,fullfile(DirName,FileName)) |
---|
| 383 | |
---|
| 384 | % ----------------------------------------------------------------------- |
---|
[387] | 385 | % --- Open again the file whose name has been recorded in MenuFile_1 |
---|
| 386 | function MenuFile_1_Callback(hObject, eventdata, handles) |
---|
| 387 | %------------------------------------------------------------------------ |
---|
| 388 | fileinput=get(handles.MenuFile_1,'Label'); |
---|
[406] | 389 | display_file_name( handles,fileinput) |
---|
[387] | 390 | |
---|
| 391 | % ----------------------------------------------------------------------- |
---|
| 392 | % --- Open again the file whose name has been recorded in MenuFile_2 |
---|
| 393 | function MenuFile_2_Callback(hObject, eventdata, handles) |
---|
| 394 | %------------------------------------------------------------------------ |
---|
| 395 | fileinput=get(handles.MenuFile_2,'Label'); |
---|
[406] | 396 | display_file_name(handles,fileinput) |
---|
[387] | 397 | |
---|
| 398 | % ----------------------------------------------------------------------- |
---|
| 399 | % --- Open again the file whose name has been recorded in MenuFile_3 |
---|
| 400 | function MenuFile_3_Callback(hObject, eventdata, handles) |
---|
| 401 | %------------------------------------------------------------------------ |
---|
| 402 | fileinput=get(handles.MenuFile_3,'Label'); |
---|
[406] | 403 | display_file_name(handles,fileinput) |
---|
[387] | 404 | |
---|
| 405 | % ----------------------------------------------------------------------- |
---|
| 406 | % --- Open again the file whose name has been recorded in MenuFile_4 |
---|
| 407 | function MenuFile_4_Callback(hObject, eventdata, handles) |
---|
| 408 | %------------------------------------------------------------------------ |
---|
| 409 | fileinput=get(handles.MenuFile_4,'Label'); |
---|
[406] | 410 | display_file_name(handles,fileinput) |
---|
[387] | 411 | |
---|
| 412 | % ----------------------------------------------------------------------- |
---|
| 413 | % --- Open again the file whose name has been recorded in MenuFile_5 |
---|
| 414 | function MenuFile_5_Callback(hObject, eventdata, handles) |
---|
| 415 | %------------------------------------------------------------------------ |
---|
| 416 | fileinput=get(handles.MenuFile_5,'Label'); |
---|
[406] | 417 | display_file_name(handles,fileinput) |
---|
[387] | 418 | |
---|
[402] | 419 | %------------------------------------------------------------------------ |
---|
| 420 | % --- Executes on the menu Open/Browse_1 for the second input field, |
---|
| 421 | % search the files, recognize their type according to their name and fill the rootfile input windows |
---|
| 422 | function MenuBrowse_1_Callback(hObject, eventdata, handles) |
---|
| 423 | %------------------------------------------------------------------------ |
---|
| 424 | RootPath=get(handles.RootPath,'String'); |
---|
[421] | 425 | [FileName, PathName] = uigetfile({'*.*','All Files(*.*)'},'Pick a file',RootPath); |
---|
[530] | 426 | if ~ischar(FileName),return,end %abandon if the browser is cancelled |
---|
[402] | 427 | fileinput_1=[PathName FileName];%complete file name |
---|
| 428 | |
---|
| 429 | % refresh the current displayed field |
---|
| 430 | set(handles.SubField,'Value',1) |
---|
[406] | 431 | display_file_name(handles,fileinput_1,2) |
---|
[402] | 432 | |
---|
| 433 | %update list of recent files in the menubar |
---|
| 434 | MenuFile_1=fileinput_1; |
---|
| 435 | MenuFile_2=get(handles.MenuFile_1,'Label'); |
---|
| 436 | MenuFile_3=get(handles.MenuFile_2,'Label'); |
---|
| 437 | MenuFile_4=get(handles.MenuFile_3,'Label'); |
---|
| 438 | MenuFile_5=get(handles.MenuFile_4,'Label'); |
---|
| 439 | set(handles.MenuFile_1,'Label',MenuFile_1) |
---|
| 440 | set(handles.MenuFile_2,'Label',MenuFile_2) |
---|
| 441 | set(handles.MenuFile_3,'Label',MenuFile_3) |
---|
| 442 | set(handles.MenuFile_4,'Label',MenuFile_4) |
---|
| 443 | set(handles.MenuFile_5,'Label',MenuFile_5) |
---|
| 444 | set(handles.MenuFile_1_1,'Label',MenuFile_1) |
---|
| 445 | set(handles.MenuFile_2_1,'Label',MenuFile_2) |
---|
| 446 | set(handles.MenuFile_3_1,'Label',MenuFile_3) |
---|
| 447 | set(handles.MenuFile_4_1,'Label',MenuFile_4) |
---|
| 448 | set(handles.MenuFile_5_1,'Label',MenuFile_5) |
---|
[576] | 449 | % dir_perso=prefdir; |
---|
| 450 | % profil_perso=fullfile(dir_perso,'uvmat_perso.mat'); |
---|
| 451 | % if exist(profil_perso,'file') |
---|
| 452 | % save (profil_perso,'MenuFile_1','MenuFile_2','MenuFile_3','MenuFile_4', 'MenuFile_5','-append'); %store the file names for future opening of uvmat |
---|
| 453 | % else |
---|
| 454 | % txt=ver('MATLAB'); |
---|
| 455 | % Release=txt.Release; |
---|
| 456 | % relnumb=str2double(Release(3:4)); |
---|
| 457 | % if relnumb >= 14 |
---|
| 458 | % save (profil_perso,'MenuFile_1','MenuFile_2','MenuFile_3','MenuFile_4', 'MenuFile_5','-V6'); %store the file names for future opening of uvmat |
---|
| 459 | % else |
---|
| 460 | % save (profil_perso,'MenuFile_1','MenuFile_2','MenuFile_3','MenuFile_4', 'MenuFile_5'); %store the file names for future opening of uvmat |
---|
| 461 | % end |
---|
| 462 | % end |
---|
[402] | 463 | |
---|
[569] | 464 | % -------------------------------------------------------------------- |
---|
| 465 | function MenuBrowseCampaign_1_Callback(hObject, eventdata, handles) |
---|
[402] | 466 | % ----------------------------------------------------------------------- |
---|
[569] | 467 | CampaignPath=fileparts(fileparts(get(handles.RootPath,'String'))); |
---|
| 468 | DirFull = uigetdir(CampaignPath,'Select a Campaign dir, then press OK'); |
---|
| 469 | if ~ischar(DirFull)|| ~exist(DirFull,'dir') |
---|
| 470 | return |
---|
| 471 | end |
---|
| 472 | OutPut=browse_data(DirFull);% open the GUI browse_data to get select a campaign dir, experiment and device |
---|
| 473 | if ~isfield(OutPut,'Campaign') |
---|
| 474 | return |
---|
| 475 | end |
---|
| 476 | DirName=fullfile(OutPut.Campaign,OutPut.Experiment{1},OutPut.Device{1}); |
---|
| 477 | hdir=dir(DirName); %list files and dirs |
---|
| 478 | for ilist=1:numel(hdir) |
---|
| 479 | if ~isequal(hdir(ilist).isdir,1)%look for files, not dir |
---|
| 480 | FileName=hdir(ilist).name; |
---|
| 481 | FileType=get_file_type(fullfile(DirName,FileName)); |
---|
| 482 | switch FileType |
---|
| 483 | case {'image','multimage','civx','civdata','netcdf'} |
---|
| 484 | break |
---|
| 485 | end |
---|
| 486 | end |
---|
| 487 | end |
---|
| 488 | |
---|
| 489 | %% display the selected field and related information |
---|
| 490 | set(handles.SubField,'Value',1) |
---|
| 491 | display_file_name( handles,fullfile(DirName,FileName),2) |
---|
| 492 | |
---|
| 493 | % ----------------------------------------------------------------------- |
---|
[402] | 494 | % --- Open again as second field the file whose name has been recorded in MenuFile_1 |
---|
| 495 | function MenuFile_1_1_Callback(hObject, eventdata, handles) |
---|
| 496 | % ----------------------------------------------------------------------- |
---|
| 497 | fileinput_1=get(handles.MenuFile_1_1,'Label'); |
---|
| 498 | set(handles.SubField,'Value',1) |
---|
[406] | 499 | display_file_name(handles,fileinput_1,2) |
---|
[402] | 500 | |
---|
| 501 | % ----------------------------------------------------------------------- |
---|
| 502 | % --- Open again as second field the file whose name has been recorded in MenuFile_2 |
---|
| 503 | function MenuFile_2_1_Callback(hObject, eventdata, handles) |
---|
| 504 | % ----------------------------------------------------------------------- |
---|
| 505 | fileinput_1=get(handles.MenuFile_2_1,'Label'); |
---|
| 506 | set(handles.SubField,'Value',1) |
---|
[406] | 507 | display_file_name(handles,fileinput_1,2) |
---|
[402] | 508 | |
---|
| 509 | % ----------------------------------------------------------------------- |
---|
| 510 | % --- Open again as second field the file whose name has been recorded in MenuFile_3 |
---|
| 511 | function MenuFile_3_1_Callback(hObject, eventdata, handles) |
---|
| 512 | % ----------------------------------------------------------------------- |
---|
| 513 | fileinput_1=get(handles.MenuFile_3_1,'Label'); |
---|
| 514 | set(handles.SubField,'Value',1) |
---|
[406] | 515 | display_file_name(handles,fileinput_1,2) |
---|
[402] | 516 | |
---|
| 517 | % ----------------------------------------------------------------------- |
---|
| 518 | % --- Open again as second field the file whose name has been recorded in MenuFile_4 |
---|
| 519 | function MenuFile_4_1_Callback(hObject, eventdata, handles) |
---|
| 520 | % ----------------------------------------------------------------------- |
---|
| 521 | fileinput_1=get(handles.MenuFile_4_1,'Label'); |
---|
| 522 | set(handles.SubField,'Value',1) |
---|
[406] | 523 | display_file_name(handles,fileinput_1,2) |
---|
[402] | 524 | |
---|
| 525 | % ----------------------------------------------------------------------- |
---|
| 526 | % --- Open again as second field the file whose name has been recorded in MenuFile_5 |
---|
| 527 | function MenuFile_5_1_Callback(hObject, eventdata, handles) |
---|
| 528 | % ----------------------------------------------------------------------- |
---|
| 529 | fileinput_1=get(handles.MenuFile_5_1,'Label'); |
---|
| 530 | set(handles.SubField,'Value',1) |
---|
[406] | 531 | display_file_name(handles,fileinput_1,2) |
---|
[402] | 532 | |
---|
| 533 | %------------------------------------------------------------------------ |
---|
| 534 | % --- Called by action in RootPath edit box |
---|
| 535 | function RootPath_Callback(hObject,eventdata,handles) |
---|
| 536 | %------------------------------------------------------------------------ |
---|
| 537 | % read the current input file name: |
---|
| 538 | [RootPath,SubDir,RootFile,FileIndices,FileExt]=read_file_boxes(handles); |
---|
[456] | 539 | if ~exist(fullfile(RootPath,SubDir),'dir') |
---|
| 540 | msgbox_uvmat('ERROR',['directory ' fullfile(RootPath,SubDir) ' does not exist']) |
---|
| 541 | return |
---|
| 542 | end |
---|
[402] | 543 | % detect the file type, get the movie object if relevant, and look for the corresponding file series: |
---|
[599] | 544 | [RootPath,SubDir,RootFile,i1_series,i2_series,j1_series,j2_series,tild,FileType,FileInfo,MovieObject]=find_file_series(fullfile(RootPath,SubDir),[RootFile FileIndices FileExt]); |
---|
[402] | 545 | % initiate the input file series and refresh the current field view: |
---|
[599] | 546 | update_rootinfo(handles,i1_series,i2_series,j1_series,j2_series,FileType,FileInfo,MovieObject,1); |
---|
[402] | 547 | |
---|
| 548 | %----------------------------------------------------------------------- |
---|
| 549 | % --- Called by action in RootPath_1 edit box |
---|
| 550 | function RootPath_1_Callback(hObject,eventdata,handles) |
---|
| 551 | % ----------------------------------------------------------------------- |
---|
| 552 | % update_rootinfo_1(hObject,eventdata,handles) |
---|
| 553 | [RootPath,SubDir,RootFile,FileIndices,FileExt]=read_file_boxes_1(handles); |
---|
[456] | 554 | if ~exist(fullfile(RootPath,SubDir),'dir') |
---|
| 555 | msgbox_uvmat('ERROR',['directory ' fullfile(RootPath,SubDir) ' does not exist']) |
---|
| 556 | return |
---|
| 557 | end |
---|
[402] | 558 | % detect the file type, get the movie object if relevant, and look for the corresponding file series: |
---|
| 559 | [RootPath,SubDir,RootFile,i1_series,i2_series,j1_series,j2_series,tild,FileType,MovieObject]=find_file_series(fullfile(RootPath,SubDir),[RootFile FileIndices FileExt]); |
---|
| 560 | % initiate the input file series and refresh the current field view: |
---|
| 561 | update_rootinfo(handles,i1_series,i2_series,j1_series,j2_series,FileType,MovieObject,2); |
---|
| 562 | |
---|
| 563 | %------------------------------------------------------------------------ |
---|
| 564 | % --- Called by action in RootFile edit box |
---|
| 565 | function SubDir_Callback(hObject, eventdata, handles) |
---|
| 566 | %------------------------------------------------------------------------ |
---|
[526] | 567 | %refresh the menu of input fieldname |
---|
[402] | 568 | Fields_Callback(hObject, eventdata, handles); |
---|
| 569 | % refresh the current field view |
---|
| 570 | run0_Callback(hObject, eventdata, handles); |
---|
| 571 | |
---|
| 572 | %------------------------------------------------------------------------ |
---|
| 573 | % --- Called by action in RootFile edit box |
---|
| 574 | function RootFile_Callback(hObject, eventdata, handles) |
---|
| 575 | %------------------------------------------------------------------------ |
---|
| 576 | RootPath_Callback(hObject,eventdata,handles) |
---|
| 577 | |
---|
| 578 | %----------------------------------------------------------------------- |
---|
| 579 | % --- Called by action in RootFile_1 edit box |
---|
| 580 | function RootFile_1_Callback(hObject, eventdata, handles) |
---|
| 581 | % ----------------------------------------------------------------------- |
---|
| 582 | RootPath_1_Callback(hObject,eventdata,handles) |
---|
| 583 | |
---|
| 584 | %------------------------------------------------------------------------ |
---|
| 585 | % --- Called by action in FileIndex edit box |
---|
| 586 | function FileIndex_Callback(hObject, eventdata, handles) |
---|
| 587 | %------------------------------------------------------------------------ |
---|
| 588 | [tild,tild,tild,i1,i2,j1,j2]=fileparts_uvmat(get(handles.FileIndex,'String')); |
---|
| 589 | set(handles.i1,'String',num2str(i1)); |
---|
| 590 | set(handles.i2,'String',num2str(i2)); |
---|
| 591 | set(handles.j1,'String',num2str(j1)); |
---|
| 592 | set(handles.j2,'String',num2str(j2)); |
---|
| 593 | |
---|
| 594 | % refresh the current field view |
---|
| 595 | run0_Callback(hObject, eventdata, handles) |
---|
| 596 | |
---|
| 597 | %------------------------------------------------------------------------ |
---|
| 598 | % --- Called by action in FileIndex_1 edit box |
---|
| 599 | function FileIndex_1_Callback(hObject, eventdata, handles) |
---|
| 600 | %------------------------------------------------------------------------ |
---|
| 601 | run0_Callback(hObject, eventdata, handles) |
---|
| 602 | |
---|
| 603 | %------------------------------------------------------------------------ |
---|
| 604 | % --- Called by action in NomType edit box |
---|
| 605 | function NomType_Callback(hObject, eventdata, handles) |
---|
| 606 | %------------------------------------------------------------------------ |
---|
| 607 | i1=str2num(get(handles.i1,'String')); |
---|
| 608 | i2=str2num(get(handles.i2,'String')); |
---|
| 609 | j1=str2num(get(handles.j1,'String')); |
---|
| 610 | j2=str2num(get(handles.j2,'String')); |
---|
| 611 | FileIndex=fullfile_uvmat('','','','',get(handles.NomType,'String'),i1,i2,j1,j2); |
---|
| 612 | set(handles.FileIndex,'String',FileIndex) |
---|
| 613 | % refresh the current settings and refresh the field view |
---|
| 614 | RootPath_Callback(hObject,eventdata,handles) |
---|
| 615 | |
---|
| 616 | %------------------------------------------------------------------------ |
---|
| 617 | % --- Called by action in NomType edit box |
---|
| 618 | function NomType_1_Callback(hObject, eventdata, handles) |
---|
| 619 | %------------------------------------------------------------------------ |
---|
| 620 | i1=str2num(get(handles.i1,'String')); |
---|
| 621 | i2=str2num(get(handles.i2,'String')); |
---|
| 622 | j1=str2num(get(handles.j1,'String')); |
---|
| 623 | j2=str2num(get(handles.j2,'String')); |
---|
| 624 | FileIndex=fullfile_uvmat('','','','',get(handles.NomType_1,'String'),i1,i2,j1,j2); |
---|
| 625 | set(handles.FileIndex_1,'String',FileIndex) |
---|
| 626 | % refresh the current settings and refresh the field view |
---|
| 627 | RootPath_1_Callback(hObject,eventdata,handles) |
---|
| 628 | |
---|
[387] | 629 | %------------------------------------------------------------------------ |
---|
| 630 | % --- Fills the edit boxes RootPath, RootFile,NomType...from an input file name 'fileinput' |
---|
[406] | 631 | function display_file_name(handles,fileinput,index) |
---|
[387] | 632 | %------------------------------------------------------------------------ |
---|
| 633 | %% look for the input file existence |
---|
| 634 | if ~exist(fileinput,'file') |
---|
| 635 | msgbox_uvmat('ERROR',['input file ' fileinput ' does not exist']) |
---|
| 636 | return |
---|
| 637 | end |
---|
| 638 | |
---|
| 639 | %% set the mouse pointer to 'watch' |
---|
| 640 | set(handles.uvmat,'Pointer','watch') |
---|
| 641 | set(handles.RootPath,'BackgroundColor',[1 1 0]) |
---|
| 642 | drawnow |
---|
| 643 | |
---|
[406] | 644 | %% define the relevant handles for the first field series (index=1) or the second file series (index=2) |
---|
[387] | 645 | if ~exist('index','var') |
---|
| 646 | index=1; |
---|
| 647 | end |
---|
| 648 | if index==1 |
---|
| 649 | handles_RootPath=handles.RootPath; |
---|
| 650 | handles_SubDir=handles.SubDir; |
---|
| 651 | handles_RootFile=handles.RootFile; |
---|
| 652 | handles_FileIndex=handles.FileIndex; |
---|
| 653 | handles_NomType=handles.NomType; |
---|
| 654 | handles_FileExt=handles.FileExt; |
---|
| 655 | elseif index==2 |
---|
| 656 | handles_RootPath=handles.RootPath_1; |
---|
| 657 | handles_SubDir=handles.SubDir_1; |
---|
| 658 | handles_RootFile=handles.RootFile_1; |
---|
| 659 | handles_FileIndex=handles.FileIndex_1; |
---|
| 660 | handles_NomType=handles.NomType_1; |
---|
| 661 | handles_FileExt=handles.FileExt_1; |
---|
| 662 | set(handles.RootPath_1,'Visible','on') |
---|
| 663 | set(handles.RootFile_1,'Visible','on') |
---|
| 664 | set(handles.SubDir_1,'Visible','on'); |
---|
| 665 | set(handles.FileIndex_1,'Visible','on'); |
---|
| 666 | set(handles.FileExt_1,'Visible','on'); |
---|
| 667 | set(handles.NomType_1,'Visible','on'); |
---|
| 668 | end |
---|
| 669 | |
---|
| 670 | %% detect root name, nomenclature and indices in the input file name: |
---|
[398] | 671 | [FilePath,FileName,FileExt]=fileparts(fileinput); |
---|
[387] | 672 | % detect the file type, get the movie object if relevant, and look for the corresponding file series: |
---|
[398] | 673 | % the root name and indices may be corrected by including the first index i1 if a corresponding xml file exists |
---|
[599] | 674 | [RootPath,SubDir,RootFile,i1_series,i2_series,j1_series,j2_series,NomType,FileType,FileInfo,MovieObject,i1,i2,j1,j2]=find_file_series(FilePath,[FileName FileExt]); |
---|
[387] | 675 | |
---|
| 676 | %% open the file or fill the GUI uvmat according to the detected file type |
---|
| 677 | switch FileType |
---|
| 678 | case '' |
---|
| 679 | msgbox_uvmat('ERROR','invalid input file type') |
---|
| 680 | case 'txt' |
---|
| 681 | edit(fileinput) |
---|
| 682 | case 'figure' %display matlab figure |
---|
| 683 | hfig=open(fileinput); |
---|
| 684 | set(hfig,'WindowButtonMotionFcn','mouse_motion')%set mouse action functio |
---|
| 685 | set(hfig,'WindowButtonUpFcn','mouse_up')%set mouse click action function |
---|
| 686 | set(hfig,'WindowButtonUpFcn','mouse_down')%set mouse click action function |
---|
[503] | 687 | case 'xml' % edit xml files |
---|
[507] | 688 | t=xmltree(fileinput); |
---|
[508] | 689 | % the xml file marks a project or project link, open datatree_browser |
---|
[507] | 690 | if strcmp(get(t,1,'name'),'Project')&& exist(regexprep(fileinput,'.xml$',''),'dir') |
---|
[503] | 691 | datatree_browser(fileinput) |
---|
[508] | 692 | else % other xml file, open the xml editor |
---|
[503] | 693 | editxml(fileinput); |
---|
| 694 | end |
---|
[508] | 695 | case 'xls'% Excel file opended by editxml |
---|
[387] | 696 | editxml(fileinput); |
---|
| 697 | otherwise |
---|
| 698 | set(handles_RootPath,'String',RootPath); |
---|
| 699 | rootname=fullfile(RootPath,SubDir,RootFile); |
---|
| 700 | set(handles_SubDir,'String',['/' SubDir]); |
---|
| 701 | set(handles_RootFile,'String',['/' RootFile]); %display the separator |
---|
| 702 | indices=fileinput(length(rootname)+1:end); |
---|
| 703 | indices(end-length(FileExt)+1:end)=[]; %remove extension |
---|
| 704 | set(handles_FileIndex,'String',indices); |
---|
| 705 | set(handles_NomType,'String',NomType); |
---|
| 706 | set(handles_FileExt,'String',FileExt); |
---|
| 707 | if index==1 |
---|
| 708 | % fill file index counters if the first file series is opened |
---|
| 709 | set(handles.i1,'String',num2str(i1)); |
---|
| 710 | set(handles.i2,'String',num2str(i2)); |
---|
| 711 | set(handles.j1,'String',num2stra(j1,NomType)); |
---|
| 712 | set(handles.j2,'String',num2stra(j2,NomType)); |
---|
[515] | 713 | else %read the current field index to synchronise with the first series |
---|
| 714 | i1_s=str2num(get(handles.i1,'String')); |
---|
| 715 | i2_0=str2num(get(handles.i2,'String')); |
---|
| 716 | if ~isempty(i2_0) |
---|
| 717 | i2_s=i2_0; |
---|
| 718 | else |
---|
| 719 | i2_s=i2; |
---|
| 720 | end |
---|
| 721 | j1_0=stra2num(get(handles.j1,'String')); |
---|
| 722 | if ~isempty(j1_0) |
---|
| 723 | j1_s=j1_0; |
---|
| 724 | else |
---|
| 725 | j1_s=j1; |
---|
| 726 | end |
---|
| 727 | j2_0=stra2num(get(handles.j2,'String')); |
---|
| 728 | if ~isempty(j2_0) |
---|
| 729 | j2_s=j2_0; |
---|
| 730 | else |
---|
| 731 | j2_s=j2; |
---|
| 732 | end |
---|
[387] | 733 | end |
---|
| 734 | |
---|
| 735 | % synchronise indices of the second input file if it exists |
---|
| 736 | if get(handles.SubField,'Value')==1% if the subfield button is activated, update the field numbers |
---|
| 737 | Input=read_GUI(handles.InputFile); |
---|
| 738 | if ~isfield(Input,'RootPath_1')||strcmp(Input.RootPath_1,'"') |
---|
| 739 | Input.RootPath_1=Input.RootPath; |
---|
| 740 | end |
---|
| 741 | if ~isfield(Input,'SubDir_1')||strcmp(Input.SubDir_1,'"') |
---|
| 742 | Input.SubDir_1=Input.SubDir; |
---|
| 743 | end |
---|
| 744 | if ~isfield(Input,'RootFile_1')||strcmp(Input.RootFile_1,'"') |
---|
| 745 | Input.RootFile_1=Input.RootFile; |
---|
| 746 | end |
---|
[405] | 747 | if ~isfield(Input,'FileExt_1')||strcmp(Input.FileExt_1,'"') |
---|
| 748 | Input.FileExt_1=Input.FileExt; |
---|
| 749 | end |
---|
| 750 | if ~isfield(Input,'NomType_1')||strcmp(Input.NomType_1,'"') |
---|
| 751 | Input.NomType_1=Input.NomType; |
---|
| 752 | end |
---|
[387] | 753 | %updtate the indices of the second field series to correspond to the newly opened one |
---|
[515] | 754 | 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] | 755 | if exist(FileName_1,'file') |
---|
[515] | 756 | FileIndex_1=fullfile_uvmat('','','','',Input.NomType_1,i1_s,i2_s,j1_s,j2_s); |
---|
| 757 | else |
---|
[387] | 758 | FileIndex_1=fullfile_uvmat('','','','',Input.NomType_1,i1,i2,j1,j2); |
---|
[408] | 759 | msgbox_uvmat('WARNING','unable to synchronise the indices of the two series') |
---|
[387] | 760 | end |
---|
[515] | 761 | set(handles.FileIndex_1,'String',FileIndex_1) |
---|
[387] | 762 | end |
---|
| 763 | |
---|
| 764 | %enable other menus |
---|
| 765 | set(handles.MenuOpen_1,'Enable','on') |
---|
| 766 | set(handles.MenuFile_1_1,'Enable','on') |
---|
| 767 | set(handles.MenuFile_2_1,'Enable','on') |
---|
| 768 | set(handles.MenuFile_3_1,'Enable','on') |
---|
| 769 | set(handles.MenuFile_4_1,'Enable','on') |
---|
| 770 | set(handles.MenuFile_5_1,'Enable','on') |
---|
| 771 | set(handles.MenuExport,'Enable','on') |
---|
| 772 | set(handles.MenuExportFigure,'Enable','on') |
---|
| 773 | set(handles.MenuExportMovie,'Enable','on') |
---|
| 774 | set(handles.MenuTools,'Enable','on') |
---|
[503] | 775 | |
---|
[387] | 776 | % initiate input file series and refresh the current field view: |
---|
| 777 | update_rootinfo(handles,i1_series,i2_series,j1_series,j2_series,FileType,MovieObject,index); |
---|
| 778 | |
---|
| 779 | end |
---|
| 780 | |
---|
[503] | 781 | %% update list of recent files in the menubar and save it for future opening |
---|
| 782 | MenuFile=[{get(handles.MenuFile_1,'Label')};{get(handles.MenuFile_2,'Label')};... |
---|
| 783 | {get(handles.MenuFile_3,'Label')};{get(handles.MenuFile_4,'Label')};{get(handles.MenuFile_5,'Label')}]; |
---|
| 784 | str_find=strcmp(fileinput,MenuFile); |
---|
| 785 | if isempty(find(str_find,1)) |
---|
| 786 | MenuFile=[{fileinput};MenuFile];%insert the current file if not already in the list |
---|
| 787 | end |
---|
| 788 | for ifile=1:min(length(MenuFile),5) |
---|
[576] | 789 | set(handles.(['MenuFile_' num2str(ifile)]),'Label',MenuFile{ifile}); |
---|
| 790 | set(handles.(['MenuFile_' num2str(ifile) '_1']),'Label',MenuFile{ifile}); |
---|
[503] | 791 | end |
---|
| 792 | dir_perso=prefdir; |
---|
| 793 | profil_perso=fullfile(dir_perso,'uvmat_perso.mat'); |
---|
| 794 | if exist(profil_perso,'file') |
---|
[576] | 795 | save (profil_perso,'MenuFile','RootPath','-append'); %store the file names for future opening of uvmat |
---|
[503] | 796 | else |
---|
[576] | 797 | save (profil_perso,'MenuFile','RootPath','-V6'); %store the file names for future opening of uvmat |
---|
[503] | 798 | end |
---|
| 799 | |
---|
[387] | 800 | %% set back the mouse pointer to arrow |
---|
| 801 | set(handles.uvmat,'Pointer','arrow') |
---|
| 802 | |
---|
| 803 | |
---|
| 804 | %------------------------------------------------------------------------ |
---|
| 805 | % --- Update information about a new field series (indices to scan, timing, |
---|
| 806 | % calibration from an xml file, then refresh current plots |
---|
[515] | 807 | |
---|
[397] | 808 | function update_rootinfo(handles,i1_series,i2_series,j1_series,j2_series,FileType,VideoObject,index) |
---|
[387] | 809 | %------------------------------------------------------------------------ |
---|
| 810 | %% define the relevant handles depending on the index (1=first file series, 2= second file series) |
---|
| 811 | if ~exist('index','var') |
---|
| 812 | index=1; |
---|
| 813 | end |
---|
| 814 | if index==1 |
---|
| 815 | handles_RootPath=handles.RootPath; |
---|
[526] | 816 | handles_Fields=handles.FieldName; |
---|
[387] | 817 | elseif index==2 |
---|
| 818 | handles_RootPath=handles.RootPath_1; |
---|
[526] | 819 | handles_Fields=handles.FieldName_1; |
---|
[387] | 820 | end |
---|
| 821 | |
---|
| 822 | set(handles_RootPath,'BackgroundColor',[1 1 0]) |
---|
| 823 | drawnow |
---|
[526] | 824 | set(handles.FieldName,'UserData',[])% reinialize data from uvmat opening |
---|
[387] | 825 | UvData=get(handles.uvmat,'UserData');%huvmat=handles of the uvmat interface |
---|
| 826 | UvData.NewSeries=1; %flag for run0: begin a new series |
---|
[511] | 827 | UvData.FileName_1='';% name of the current second field (used to detect a constant field during file scanning) |
---|
[387] | 828 | UvData.FileType{index}=FileType; |
---|
| 829 | UvData.i1_series{index}=i1_series; |
---|
| 830 | UvData.i2_series{index}=i2_series; |
---|
| 831 | UvData.j1_series{index}=j1_series; |
---|
| 832 | UvData.j2_series{index}=j2_series; |
---|
| 833 | set(handles.FixVelType,'Value',0); %desactivate fixed veltype |
---|
| 834 | if index==1 |
---|
| 835 | [RootPath,SubDir,RootFile,FileIndices,FileExt]=read_file_boxes(handles); |
---|
| 836 | else |
---|
| 837 | [RootPath,SubDir,RootFile,FileIndices,FileExt]=read_file_boxes_1(handles); |
---|
| 838 | end |
---|
| 839 | FileName=[fullfile(RootPath,SubDir,RootFile) FileIndices FileExt]; |
---|
| 840 | FileBase=fullfile(RootPath,RootFile); |
---|
| 841 | if ~exist(FileName,'file') |
---|
| 842 | msgbox_uvmat('ERROR',['input file ' FileName ' not found']); |
---|
| 843 | return |
---|
| 844 | end |
---|
| 845 | |
---|
| 846 | %% read timing and total frame number from the current file (movie files) !! may be overrid by xml file |
---|
| 847 | XmlData.Time=[];%default |
---|
| 848 | XmlData.GeometryCalib=[];%default |
---|
[494] | 849 | TimeUnit='';%default |
---|
| 850 | Time=[]; |
---|
[548] | 851 | % testima=0; %test for image input |
---|
[387] | 852 | imainfo=[]; |
---|
| 853 | ColorType='falsecolor'; %default |
---|
[548] | 854 | % hhh=[]; |
---|
[397] | 855 | UvData.MovieObject{index}=VideoObject; |
---|
| 856 | if ~isempty(VideoObject) |
---|
| 857 | imainfo=get(VideoObject); |
---|
[548] | 858 | % testima=1; |
---|
[387] | 859 | TimeUnit='s'; |
---|
[494] | 860 | if isempty(j1_series); %frame index along i |
---|
| 861 | Time=(0:1/imainfo.FrameRate:(imainfo.NumberOfFrames)/imainfo.FrameRate)'; |
---|
| 862 | else |
---|
[548] | 863 | Time=ones(size(i1_series,1),1)*(0:1/imainfo.FrameRate:(imainfo.NumberOfFrames)/imainfo.FrameRate); |
---|
[494] | 864 | end |
---|
[397] | 865 | set(handles.Dt_txt,'String',['Dt=' num2str(1000/imainfo.FrameRate) 'ms']);%display the elementary time interval in millisec |
---|
| 866 | ColorType='truecolor'; |
---|
[387] | 867 | elseif ~isempty(FileExt(2:end))&&(~isempty(imformats(FileExt(2:end))) || isequal(FileExt,'.vol'))%&& isequal(NomType,'*')% multi-frame image |
---|
[548] | 868 | % testima=1; |
---|
[387] | 869 | if ~isequal(SubDir,'') |
---|
| 870 | imainfo=imfinfo([fullfile(RootPath,SubDir,RootFile) FileIndices FileExt]); |
---|
| 871 | else |
---|
| 872 | imainfo=imfinfo([FileBase FileIndices FileExt]); |
---|
| 873 | end |
---|
| 874 | ColorType=imainfo.ColorType;%='truecolor' for color images |
---|
| 875 | end |
---|
| 876 | if isfield(imainfo,'Width') && isfield(imainfo,'Height') |
---|
| 877 | if length(imainfo)>1 |
---|
| 878 | set(handles.num_Npx,'String',num2str(imainfo(1).Width));%fills nbre of pixels x box |
---|
| 879 | set(handles.num_Npy,'String',num2str(imainfo(1).Height));%fills nbre of pixels x box |
---|
| 880 | else |
---|
| 881 | set(handles.num_Npx,'String',num2str(imainfo.Width));%fills nbre of pixels x box |
---|
| 882 | set(handles.num_Npy,'String',num2str(imainfo.Height));%fills nbre of pixels x box |
---|
| 883 | end |
---|
| 884 | else |
---|
| 885 | set(handles.num_Npx,'String','');%fills nbre of pixels x box |
---|
| 886 | set(handles.num_Npy,'String','');%fills nbre of pixels x box |
---|
| 887 | end |
---|
| 888 | set(handles.CheckBW,'Value',strcmp(ColorType,'grayscale'))% select handles.CheckBW if grayscale image |
---|
| 889 | |
---|
| 890 | %% read parameters (time, geometric calibration..) from a documentation file (.xml advised) |
---|
[469] | 891 | XmlFileName=find_imadoc(RootPath,SubDir,RootFile,FileExt); |
---|
| 892 | [tild,tild,DocExt]=fileparts(XmlFileName); |
---|
[387] | 893 | warntext='';%default warning message |
---|
| 894 | NbSlice=1;%default |
---|
| 895 | set(handles.RootPath,'BackgroundColor',[1 1 1]) |
---|
[469] | 896 | if ~isempty(XmlFileName) |
---|
[387] | 897 | set(handles.view_xml,'Visible','on') |
---|
| 898 | set(handles.view_xml,'BackgroundColor',[1 1 0]) |
---|
| 899 | set(handles.view_xml,'String','view .xml') |
---|
| 900 | drawnow |
---|
[469] | 901 | [XmlDataRead,warntext]=imadoc2struct(XmlFileName); |
---|
[387] | 902 | if ~isempty(warntext) |
---|
[456] | 903 | msgbox_uvmat('WARNING',warntext) |
---|
[387] | 904 | end |
---|
[456] | 905 | if isempty(XmlDataRead) |
---|
| 906 | set(handles.view_xml,'Visible','off') |
---|
| 907 | else |
---|
| 908 | set(handles.view_xml,'String',['view ' DocExt]) |
---|
| 909 | XmlData=XmlDataRead; |
---|
| 910 | if isfield(XmlData,'TimeUnit') |
---|
| 911 | if isfield(XmlData,'TimeUnit')&& ~isempty(XmlData.TimeUnit) |
---|
| 912 | TimeUnit=XmlData.TimeUnit; |
---|
| 913 | end |
---|
[387] | 914 | end |
---|
[456] | 915 | set(handles.view_xml,'BackgroundColor',[1 1 1]) |
---|
| 916 | drawnow |
---|
| 917 | if isfield(XmlData, 'GeometryCalib') && ~isempty(XmlData.GeometryCalib) |
---|
| 918 | if isfield(XmlData.GeometryCalib,'VolumeScan') && isequal(XmlData.GeometryCalib.VolumeScan,'y') |
---|
[589] | 919 | set (handles.slices,'String','volume') |
---|
[456] | 920 | end |
---|
| 921 | hgeometry_calib=findobj('tag','geometry_calib'); |
---|
| 922 | if ~isempty(hgeometry_calib) |
---|
| 923 | GUserData=get(hgeometry_calib,'UserData'); |
---|
[469] | 924 | if ~(isfield(GUserData,'XmlInputFile') && strcmp(GUserData.XmlInputFile,XmlFileName)) |
---|
[456] | 925 | answer=msgbox_uvmat('INPUT_Y-N','replace the display of geometry_calib with the new input data?'); |
---|
| 926 | if strcmp(answer,'Yes') |
---|
[469] | 927 | geometry_calib(XmlFileName);%diplay the new calibration points and parameters in geometry_calib |
---|
[456] | 928 | end |
---|
[387] | 929 | end |
---|
| 930 | end |
---|
| 931 | end |
---|
[441] | 932 | end |
---|
[387] | 933 | end |
---|
[494] | 934 | if ~(isfield(XmlData,'Time')&& ~isempty(XmlData.Time)) |
---|
| 935 | XmlData.Time=Time; %time set by video |
---|
| 936 | end |
---|
[387] | 937 | |
---|
| 938 | %% store last index in handles.lat_i and .last_j |
---|
[496] | 939 | nbfield=max(max(max(i2_series))); |
---|
[387] | 940 | if isempty(nbfield) |
---|
[496] | 941 | nbfield=max(max(max(i1_series))); |
---|
[387] | 942 | end |
---|
[496] | 943 | nbfield_j=max(max(max(j2_series))); |
---|
[387] | 944 | if isempty(nbfield_j) |
---|
[552] | 945 | nbfield_j=max(max(max(j1_series))); |
---|
[387] | 946 | end |
---|
| 947 | if ~isempty(XmlData.Time) |
---|
| 948 | %transform .Time to a column vector if it is a line vector the nomenclature uses a single index |
---|
[441] | 949 | if isequal(size(XmlData.Time,1),1) |
---|
[552] | 950 | %NomType=get(handles.NomType,'String'); |
---|
[456] | 951 | XmlData.Time=(XmlData.Time)'; |
---|
[387] | 952 | end |
---|
| 953 | end |
---|
| 954 | last_i_cell=get(handles.last_i,'String'); |
---|
| 955 | if isempty(nbfield) |
---|
[552] | 956 | last_i_cell{index}=''; |
---|
[387] | 957 | else |
---|
[552] | 958 | last_i_cell{index}=num2str(nbfield); |
---|
[387] | 959 | end |
---|
| 960 | set(handles.last_i,'String',last_i_cell) |
---|
| 961 | last_j_cell=get(handles.last_j,'String'); |
---|
| 962 | if isempty(nbfield_j) |
---|
[552] | 963 | last_j_cell{index}=''; |
---|
[387] | 964 | else |
---|
[552] | 965 | last_j_cell{index}=num2str(nbfield_j); |
---|
[387] | 966 | end |
---|
| 967 | set(handles.last_j,'String',last_j_cell); |
---|
| 968 | |
---|
| 969 | %% store geometric calibration in UvData |
---|
| 970 | if isfield(XmlData,'GeometryCalib') |
---|
| 971 | GeometryCalib=XmlData.GeometryCalib; |
---|
| 972 | if isempty(GeometryCalib) |
---|
| 973 | set(handles.pxcm,'String','') |
---|
| 974 | set(handles.pycm,'String','') |
---|
[591] | 975 | set(handles.TransformName,'Value',1); % no transform by default |
---|
[387] | 976 | else |
---|
| 977 | if (isfield(GeometryCalib,'R')&& ~isequal(GeometryCalib.R(2,1),0) && ~isequal(GeometryCalib.R(1,2),0)) ||... |
---|
| 978 | (isfield(GeometryCalib,'kappa1')&& ~isequal(GeometryCalib.kappa1,0)) |
---|
| 979 | set(handles.pxcm,'String','var') |
---|
| 980 | set(handles.pycm,'String','var') |
---|
| 981 | elseif isfield(GeometryCalib,'fx_fy') |
---|
| 982 | pixcmx=GeometryCalib.fx_fy(1);%*GeometryCalib.R(1,1)*GeometryCalib.sx/(GeometryCalib.Tz*GeometryCalib.dpx); |
---|
| 983 | pixcmy=GeometryCalib.fx_fy(2);%*GeometryCalib.R(2,2)/(GeometryCalib.Tz*GeometryCalib.dpy); |
---|
| 984 | set(handles.pxcm,'String',num2str(pixcmx)) |
---|
| 985 | set(handles.pycm,'String',num2str(pixcmy)) |
---|
| 986 | end |
---|
| 987 | if ~get(handles.CheckFixLimits,'Value') |
---|
[591] | 988 | set(handles.TransformName,'Value',3); % phys transform by default if fixedLimits is off |
---|
[387] | 989 | end |
---|
[508] | 990 | if isfield(GeometryCalib,'SliceCoord') |
---|
[387] | 991 | siz=size(GeometryCalib.SliceCoord); |
---|
| 992 | if siz(1)>1 |
---|
| 993 | NbSlice=siz(1); |
---|
| 994 | set(handles.slices,'Visible','on') |
---|
| 995 | set(handles.slices,'Value',1) |
---|
| 996 | end |
---|
| 997 | if isfield(GeometryCalib,'VolumeScan') && isequal(GeometryCalib.VolumeScan,'y') |
---|
[589] | 998 | set(handles.num_NbSlice,'Visible','off') |
---|
[387] | 999 | else |
---|
[589] | 1000 | set(handles.num_NbSlice,'Visible','on') |
---|
[497] | 1001 | set(handles.num_NbSlice,'String',num2str(NbSlice)) |
---|
[387] | 1002 | end |
---|
| 1003 | slices_Callback([],[], handles) |
---|
| 1004 | end |
---|
| 1005 | end |
---|
| 1006 | end |
---|
| 1007 | |
---|
| 1008 | %% update the data attached to the uvmat interface |
---|
| 1009 | if ~isempty(TimeUnit) |
---|
| 1010 | set(handles.time_txt,'String',['time (' TimeUnit ')']) |
---|
| 1011 | end |
---|
| 1012 | UvData.TimeUnit=TimeUnit; |
---|
| 1013 | UvData.XmlData{index}=XmlData; |
---|
| 1014 | UvData.NewSeries=1; |
---|
| 1015 | % UvData.MovieObject=MovieObject; |
---|
| 1016 | |
---|
| 1017 | %display warning message |
---|
| 1018 | if ~isequal(warntext,'') |
---|
| 1019 | msgbox_uvmat('WARNING',warntext); |
---|
| 1020 | end |
---|
| 1021 | |
---|
[526] | 1022 | %% set default options in menu 'FieldName' |
---|
[517] | 1023 | switch FileType |
---|
| 1024 | case {'civx','civdata'} |
---|
[581] | 1025 | % [FieldList,ColorList]=calc_field; |
---|
| 1026 | [FieldList,ColorList]=set_field_list('U','V','C'); |
---|
[525] | 1027 | set(handles_Fields,'String',[{'image'};FieldList;{'get_field...'}]);%standard menu for civx data |
---|
| 1028 | set(handles_Fields,'Value',2) % set menu to 'velocity |
---|
[580] | 1029 | if index==1 |
---|
| 1030 | set(handles.FieldName_1,'Value',1); |
---|
| 1031 | set(handles.FieldName_1,'String',[{''};{'image'};FieldList;{'get_field...'}]);%standard menu for civx data reproduced for the second field |
---|
| 1032 | end |
---|
[525] | 1033 | set(handles.ColorScalar,'Value',1) |
---|
| 1034 | set(handles.ColorScalar,'String',ColorList) |
---|
| 1035 | set(handles.Vectors,'Visible','on') |
---|
| 1036 | set(handles.Coord_x,'Value',1); |
---|
| 1037 | set(handles.Coord_x,'String',{'X'}); |
---|
| 1038 | set(handles.Coord_y,'Value',1); |
---|
| 1039 | set(handles.Coord_y,'String',{'Y'}); |
---|
[517] | 1040 | case 'netcdf' |
---|
[387] | 1041 | set(handles_Fields,'Value',1) |
---|
| 1042 | set(handles_Fields,'String',{'get_field...'}) |
---|
[595] | 1043 | FieldName_Callback([],[], handles) |
---|
| 1044 | % hget_field=get_field(FileName); |
---|
| 1045 | % hhget_field=guidata(hget_field); |
---|
| 1046 | % get_field('RUN_Callback',hhget_field.RUN,[],hhget_field); |
---|
[517] | 1047 | otherwise |
---|
| 1048 | set(handles_Fields,'Value',1) % set menu to 'image' |
---|
| 1049 | set(handles_Fields,'String',{'image'}) |
---|
[525] | 1050 | set(handles.Coord_x,'Value',1); |
---|
| 1051 | set(handles.Coord_x,'String',{'AX'}); |
---|
| 1052 | set(handles.Coord_y,'Value',1); |
---|
| 1053 | set(handles.Coord_y,'String',{'AY'}); |
---|
[387] | 1054 | end |
---|
| 1055 | set(handles.uvmat,'UserData',UvData) |
---|
| 1056 | |
---|
| 1057 | %% set index navigation options and refresh plots |
---|
| 1058 | scan_option='i';%default |
---|
| 1059 | state_j='off'; %default |
---|
| 1060 | if index==2 |
---|
| 1061 | if get(handles.scan_j,'Value') |
---|
[494] | 1062 | scan_option='j'; %keep the scan option for the second file series |
---|
[387] | 1063 | end |
---|
| 1064 | if strcmp(get(handles.j1,'Visible'),'on') |
---|
| 1065 | state_j='on'; |
---|
| 1066 | end |
---|
| 1067 | end |
---|
[515] | 1068 | [ref_j,ref_i]=find(squeeze(i1_series(1,:,:))); |
---|
[387] | 1069 | if ~isempty(j1_series) |
---|
| 1070 | state_j='on'; |
---|
[494] | 1071 | if index==1 |
---|
[515] | 1072 | if isequal(ref_i,ref_i(1)*ones(size(ref_j)))% if ref_i is always equal to its first value |
---|
[494] | 1073 | scan_option='j'; %scan j indext |
---|
| 1074 | end |
---|
| 1075 | end |
---|
[387] | 1076 | end |
---|
| 1077 | if isequal(scan_option,'i') |
---|
[494] | 1078 | diff_ref_i=diff(ref_i,1); |
---|
| 1079 | if isempty(diff_ref_i) |
---|
| 1080 | diff_ref_i=1; |
---|
| 1081 | end |
---|
| 1082 | if isequal (diff_ref_i,diff_ref_i(1)*ones(size(diff_ref_i))) |
---|
[511] | 1083 | set(handles.num_IndexIncrement,'String',num2str(diff_ref_i(1))) |
---|
[494] | 1084 | end |
---|
[387] | 1085 | set(handles.scan_i,'Value',1) |
---|
| 1086 | scan_i_Callback([],[], handles); |
---|
| 1087 | else |
---|
[494] | 1088 | diff_ref_j=diff(ref_j); |
---|
| 1089 | if isempty(diff_ref_j) |
---|
| 1090 | diff_ref_j=1; |
---|
| 1091 | end |
---|
| 1092 | if isequal (diff_ref_j,diff_ref_j(1)*ones(size(diff_ref_j))) |
---|
[511] | 1093 | set(handles.num_IndexIncrement,'String',num2str(diff_ref_j(1))) |
---|
[494] | 1094 | end |
---|
[387] | 1095 | set(handles.scan_j,'Value',1) |
---|
| 1096 | scan_j_Callback([],[], handles); |
---|
| 1097 | end |
---|
| 1098 | set(handles.scan_j,'Visible',state_j) |
---|
| 1099 | set(handles.j1,'Visible',state_j) |
---|
| 1100 | set(handles.j2,'Visible',state_j) |
---|
| 1101 | set(handles.last_j,'Visible',state_j); |
---|
| 1102 | set(handles.frame_j,'Visible',state_j); |
---|
| 1103 | set(handles.j_text,'Visible',state_j); |
---|
| 1104 | if ~isempty(i2_series)||~isempty(j2_series) |
---|
| 1105 | set(handles.CheckFixPair,'Visible','on') |
---|
| 1106 | elseif index==1 |
---|
| 1107 | set(handles.CheckFixPair,'Visible','off') |
---|
| 1108 | end |
---|
| 1109 | |
---|
[508] | 1110 | %% apply the effect of the transform fct and view the field |
---|
[591] | 1111 | transform=get(handles.TransformPath,'UserData'); |
---|
[515] | 1112 | if index==2 && (~isa(transform,'function_handle')||nargin(transform)<3) |
---|
[591] | 1113 | set(handles.TransformName,'value',2); % set transform to sub_field if the current fct doe not accept two input fields |
---|
[515] | 1114 | end |
---|
[591] | 1115 | TransformName_Callback([],[],handles) |
---|
[387] | 1116 | mask_test=get(handles.CheckMask,'value'); |
---|
| 1117 | if mask_test |
---|
| 1118 | MaskData=get(handles.CheckMask,'UserData'); |
---|
| 1119 | if isfield(MaskData,'maskhandle') && ishandle(MaskData.maskhandle) |
---|
| 1120 | delete(MaskData.maskhandle) %delete old mask |
---|
| 1121 | end |
---|
| 1122 | CheckMask_Callback([],[],handles) |
---|
| 1123 | end |
---|
| 1124 | |
---|
| 1125 | %------------------------------------------------------------------------ |
---|
| 1126 | % --- switch file index scanning options scan_i and scan_j in an exclusive way |
---|
| 1127 | function scan_i_Callback(hObject, eventdata, handles) |
---|
| 1128 | %------------------------------------------------------------------------ |
---|
| 1129 | if get(handles.scan_i,'Value')==1 |
---|
[589] | 1130 | % set(handles.scan_i,'BackgroundColor',[1 1 0]) |
---|
[387] | 1131 | set(handles.scan_j,'Value',0) |
---|
| 1132 | else |
---|
[589] | 1133 | % set(handles.scan_i,'BackgroundColor',[0.831 0.816 0.784]) |
---|
[387] | 1134 | set(handles.scan_j,'Value',1) |
---|
| 1135 | end |
---|
| 1136 | scan_j_Callback(hObject, eventdata, handles) |
---|
| 1137 | |
---|
| 1138 | %------------------------------------------------------------------------ |
---|
| 1139 | % --- switch file index scanning options scan_i and scan_j in an exclusive way |
---|
| 1140 | function scan_j_Callback(hObject, eventdata, handles) |
---|
| 1141 | %------------------------------------------------------------------------ |
---|
| 1142 | if get(handles.scan_j,'Value')==1 |
---|
[589] | 1143 | % set(handles.scan_j,'BackgroundColor',[1 1 0]) |
---|
[387] | 1144 | set(handles.scan_i,'Value',0) |
---|
[589] | 1145 | % set(handles.scan_i,'BackgroundColor',[0.831 0.816 0.784]) |
---|
[387] | 1146 | % NomType=get(handles.NomType,'String'); |
---|
| 1147 | % switch NomType |
---|
| 1148 | % case {'_1_1-2','#_ab','%3dab'},% pair with j index |
---|
| 1149 | % set(handles.CheckFixPair,'Visible','on')% option fixed pair on/off made visible (choice of avaible pair with buttons + and - if ='off') |
---|
| 1150 | % otherwise |
---|
| 1151 | % set(handles.CheckFixPair,'Visible','off') |
---|
| 1152 | % end |
---|
| 1153 | else |
---|
[589] | 1154 | % set(handles.scan_j,'BackgroundColor',[0.831 0.816 0.784]) |
---|
[387] | 1155 | set(handles.scan_i,'Value',1) |
---|
[589] | 1156 | % set(handles.scan_i,'BackgroundColor',[1 1 0]) |
---|
[387] | 1157 | set(handles.CheckFixPair,'Visible','off') |
---|
| 1158 | end |
---|
| 1159 | |
---|
| 1160 | %------------------------------------------------------------------------ |
---|
| 1161 | function i1_Callback(hObject, eventdata, handles) |
---|
| 1162 | %------------------------------------------------------------------------ |
---|
[515] | 1163 | update_ij(handles,1) |
---|
[387] | 1164 | |
---|
| 1165 | %------------------------------------------------------------------------ |
---|
| 1166 | function i2_Callback(hObject, eventdata, handles) |
---|
| 1167 | %------------------------------------------------------------------------ |
---|
[515] | 1168 | update_ij(handles,2) |
---|
[387] | 1169 | |
---|
| 1170 | %------------------------------------------------------------------------ |
---|
| 1171 | function j1_Callback(hObject, eventdata, handles) |
---|
| 1172 | %------------------------------------------------------------------------ |
---|
[515] | 1173 | update_ij(handles,3) |
---|
[387] | 1174 | |
---|
| 1175 | %------------------------------------------------------------------------ |
---|
| 1176 | function j2_Callback(hObject, eventdata, handles) |
---|
| 1177 | %------------------------------------------------------------------------ |
---|
[515] | 1178 | update_ij(handles,4) |
---|
[387] | 1179 | |
---|
| 1180 | %------------------------------------------------------------------------ |
---|
[515] | 1181 | %--- update the index display after action on edit boxes i1, i2, j1 or j2 |
---|
| 1182 | function update_ij(handles,index_rank) |
---|
| 1183 | NomType=get(handles.NomType,'String'); |
---|
| 1184 | indices=get(handles.FileIndex,'String'); |
---|
| 1185 | [tild,tild,tild,i1,i2,j1,j2]=fileparts_uvmat(indices);% the indices for the second series taken from FileIndex |
---|
| 1186 | switch index_rank |
---|
| 1187 | case 1 |
---|
| 1188 | indices=fullfile_uvmat('','','','',NomType,stra2num(get(handles.i1,'String')),i2,j1,j2); |
---|
| 1189 | 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 |
---|
| 1190 | case 2 |
---|
| 1191 | indices=fullfile_uvmat('','','','',NomType,i1,stra2num(get(handles.i2,'String')),j1,j2); |
---|
| 1192 | 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 |
---|
| 1193 | case 3 |
---|
| 1194 | indices=fullfile_uvmat('','','','',NomType,i1,i2,stra2num(get(handles.j1,'String')),j2); |
---|
| 1195 | 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 |
---|
| 1196 | case 4 |
---|
| 1197 | indices=fullfile_uvmat('','','','',NomType,i1,i2,j1,stra2num(get(handles.j2,'String'))); |
---|
| 1198 | 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 |
---|
| 1199 | end |
---|
| 1200 | set(handles.FileIndex,'String',indices) |
---|
| 1201 | 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 |
---|
| 1202 | % update the second index if relevant |
---|
| 1203 | if strcmp(get(handles.FileIndex_1,'Visible'),'on') |
---|
| 1204 | NomType_1=get(handles.NomType_1,'String'); |
---|
| 1205 | indices_1=get(handles.FileIndex_1,'String'); |
---|
| 1206 | [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 |
---|
| 1207 | switch index_rank |
---|
| 1208 | case 1 |
---|
| 1209 | indices_1=fullfile_uvmat('','','','',NomType_1,stra2num(get(handles.i1,'String')),i2_1,j1_1,j2_1); |
---|
| 1210 | case 2 |
---|
| 1211 | indices_1=fullfile_uvmat('','','','',NomType_1,i1_1,stra2num(get(handles.i2,'String')),j1_1,j2_1); |
---|
| 1212 | case 3 |
---|
| 1213 | indices_1=fullfile_uvmat('','','','',NomType_1,i1_1,i2_1,stra2num(get(handles.j1,'String')),j2_1); |
---|
| 1214 | case 4 |
---|
| 1215 | indices_1=fullfile_uvmat('','','','',NomType_1,i1_1,i2_1,j1_1,stra2num(get(handles.j2,'String'))); |
---|
| 1216 | end |
---|
| 1217 | set(handles.FileIndex_1,'String',indices_1) |
---|
| 1218 | 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 |
---|
| 1219 | end |
---|
| 1220 | |
---|
| 1221 | %------------------------------------------------------------------------ |
---|
| 1222 | |
---|
| 1223 | %------------------------------------------------------------------------ |
---|
[387] | 1224 | function slices_Callback(hObject, eventdata, handles) |
---|
| 1225 | %------------------------------------------------------------------------ |
---|
[589] | 1226 | if strcmp(get(handles.slices,'String'),'slices') |
---|
| 1227 | if get(handles.slices,'Value')==1 |
---|
| 1228 | set(handles.num_NbSlice,'Visible','on') |
---|
| 1229 | set(handles.z_text,'Visible','on') |
---|
| 1230 | set(handles.z_index,'Visible','on') |
---|
| 1231 | num_NbSlice_Callback(hObject, eventdata, handles) |
---|
| 1232 | else |
---|
| 1233 | set(handles.num_NbSlice,'Visible','off') |
---|
| 1234 | set(handles.z_text,'Visible','off') |
---|
| 1235 | set(handles.z_index,'Visible','off') |
---|
| 1236 | set(handles.masklevel,'Value',1) |
---|
| 1237 | set(handles.masklevel,'String',{'1'}) |
---|
| 1238 | end |
---|
[387] | 1239 | end |
---|
| 1240 | |
---|
| 1241 | %------------------------------------------------------------------------ |
---|
[497] | 1242 | function num_NbSlice_Callback(hObject, eventdata, handles) |
---|
[387] | 1243 | %------------------------------------------------------------------------ |
---|
[589] | 1244 | mode=get(handles.slices,'String'); |
---|
[497] | 1245 | nb_slice_str=get(handles.num_NbSlice,'String'); |
---|
[589] | 1246 | if strcmp(mode,'volume') |
---|
| 1247 | z=stra2num(get(handles.j1,'String')); |
---|
[387] | 1248 | else |
---|
| 1249 | num=str2double(get(handles.i1,'String')); |
---|
[497] | 1250 | nbslice=str2double(get(handles.num_NbSlice,'String')); |
---|
[589] | 1251 | z=mod(num-1,nbslice)+1; |
---|
[387] | 1252 | end |
---|
| 1253 | set(handles.z_index,'String',num2str(z)) |
---|
| 1254 | for ilist=1:nbslice |
---|
| 1255 | list_index{ilist,1}=num2str(ilist); |
---|
| 1256 | end |
---|
| 1257 | set(handles.masklevel,'String',list_index) |
---|
| 1258 | set(handles.masklevel,'Value',z) |
---|
| 1259 | |
---|
| 1260 | %------------------------------------------------------------------------ |
---|
| 1261 | % --- Executes on button press in view_xml. |
---|
| 1262 | function view_xml_Callback(hObject, eventdata, handles) |
---|
| 1263 | %------------------------------------------------------------------------ |
---|
| 1264 | %[FileName,RootPath,FileBase,FileIndices,FileExt]=read_file_boxes(handles); |
---|
| 1265 | [RootPath,SubDir,RootFile,FileIndices,FileExt]=read_file_boxes(handles); |
---|
| 1266 | FileBase=fullfile(RootPath,RootFile); |
---|
| 1267 | option=get(handles.view_xml,'String'); |
---|
| 1268 | if isequal(option,'view .xml') |
---|
[494] | 1269 | FileXml=fullfile(RootPath,[SubDir '.xml']); |
---|
| 1270 | if ~exist(FileXml,'file')% case of civ files , removes the extension for subdir |
---|
| 1271 | FileXml=fullfile(RootPath,[regexprep(SubDir,'\..+$','') '.xml']); |
---|
| 1272 | end |
---|
[387] | 1273 | heditxml=editxml(FileXml); |
---|
| 1274 | end |
---|
| 1275 | |
---|
| 1276 | %------------------------------------------------------------------------ |
---|
| 1277 | % --- Executes on button press in CheckMask. |
---|
| 1278 | function CheckMask_Callback(hObject, eventdata, handles) |
---|
| 1279 | %------------------------------------------------------------------------ |
---|
| 1280 | %case of view mask selection |
---|
| 1281 | if isequal(get(handles.CheckMask,'Value'),1) |
---|
| 1282 | [RootPath,SubDir,RootFile,FileIndices,FileExt]=read_file_boxes(handles); |
---|
| 1283 | FileBase=fullfile(RootPath,RootFile); |
---|
| 1284 | num_i1=stra2num(get(handles.i1,'String')); |
---|
| 1285 | num_j1=stra2num(get(handles.j1,'String')); |
---|
| 1286 | currentdir=pwd; |
---|
| 1287 | cd(RootPath); |
---|
| 1288 | maskfiles=dir('*_*mask_*.png');%look for a mask file |
---|
| 1289 | cd(currentdir);%come back to the working directory |
---|
| 1290 | mdetect=0; |
---|
| 1291 | if ~isempty(maskfiles) |
---|
| 1292 | for ilist=1:length(maskfiles) |
---|
| 1293 | maskname=maskfiles(ilist).name;% take the first mask file in the list |
---|
| 1294 | [tild,tild,tild,tild,tild,tild,tild,MaskExt,Mask_NomType{ilist}]=fileparts_uvmat(maskname); |
---|
| 1295 | [tild,Name]=fileparts(maskname); |
---|
| 1296 | Namedouble=double(Name); |
---|
| 1297 | val=(48>Namedouble)|(Namedouble>57);% select the non-numerical characters |
---|
| 1298 | ind_mask=findstr('mask',Name); |
---|
| 1299 | i=ind_mask-1; |
---|
| 1300 | while val(i)==0 && i>0 |
---|
| 1301 | i=i-1; |
---|
| 1302 | end |
---|
| 1303 | nbmask_str=str2num(Name(i+1:ind_mask-1)); |
---|
| 1304 | if ~isempty(nbmask_str) |
---|
| 1305 | nbslice(ilist)=nbmask_str; % number of different masks (slices) |
---|
| 1306 | end |
---|
| 1307 | end |
---|
| 1308 | if isequal(min(nbslice),max(nbslice)) |
---|
| 1309 | nbslice=nbslice(1); |
---|
| 1310 | else |
---|
| 1311 | msgbox_uvmat('ERROR','several inconsistent mask sets coexist in the current image directory') |
---|
| 1312 | return |
---|
| 1313 | end |
---|
| 1314 | if ~isempty(nbslice) && Name(i)=='_' |
---|
| 1315 | Mask.Base=[FileBase Name(i:ind_mask+3)]; |
---|
| 1316 | Mask.NbSlice=nbslice; |
---|
| 1317 | num_i1=mod(num_i1-1,nbslice)+1; |
---|
| 1318 | Mask.NomType=regexprep(Mask_NomType{1},'0','');%remove '0' in nom type for masks |
---|
| 1319 | [RootPath,RootFile]=fileparts(Mask.Base); |
---|
| 1320 | maskname=fullfile_uvmat(RootPath,'',RootFile,'.png',Mask.NomType,num_i1,[],num_j1); |
---|
| 1321 | %maskname=name_generator(Mask.Base,num_i1,num_j1,'.png',Mask.NomType);% |
---|
| 1322 | mdetect=exist(maskname,'file'); |
---|
| 1323 | if mdetect |
---|
[497] | 1324 | set(handles.num_NbSlice,'String',Name(i+1:ind_mask-1)); |
---|
[589] | 1325 | set(handles.num_NbSlice,'BackgroundColor',[1 1 0]) |
---|
[387] | 1326 | set(handles.CheckMask,'UserData',Mask); |
---|
| 1327 | set(handles.CheckMask,'BackgroundColor',[1 1 0]) |
---|
| 1328 | if nbslice > 1 |
---|
| 1329 | set(handles.slices,'value',1) |
---|
| 1330 | slices_Callback(hObject, eventdata, handles) |
---|
| 1331 | end |
---|
| 1332 | end |
---|
| 1333 | end |
---|
| 1334 | end |
---|
| 1335 | errormsg=[];%default |
---|
| 1336 | if mdetect==0 |
---|
| 1337 | [FileName, PathName, filterindex] = uigetfile( ... |
---|
| 1338 | {'*.png', ' (*.png)'; |
---|
| 1339 | '*.png', '.png files '; ... |
---|
| 1340 | '*.*', 'All Files (*.*)'}, ... |
---|
| 1341 | 'Pick a mask file *.png',FileBase); |
---|
[530] | 1342 | if ~ischar(FileName),return,end %abandon if the browser is cancelled |
---|
[387] | 1343 | maskname=fullfile(PathName,FileName); |
---|
[444] | 1344 | [RootDir,SubDir,RootFile,tild,tild,tild,tild,tild,Mask.NomType]=fileparts_uvmat(maskname); |
---|
| 1345 | Mask.Base=fullfile(RootDir,SubDir,RootFile); |
---|
[387] | 1346 | Mask.NbSlice=1; |
---|
| 1347 | set(handles.CheckMask,'UserData',Mask); |
---|
| 1348 | set(handles.CheckMask,'BackgroundColor',[1 1 0]) |
---|
| 1349 | end |
---|
| 1350 | if isempty(errormsg) |
---|
| 1351 | errormsg=update_mask(handles,num_i1,num_j1); |
---|
| 1352 | end |
---|
| 1353 | if ~isempty(errormsg) |
---|
| 1354 | set(handles.CheckMask,'Value',0) |
---|
| 1355 | set(handles.CheckMask,'BackgroundColor',[0.7 0.7 0.7]) |
---|
| 1356 | end |
---|
| 1357 | else % desactivate mask display |
---|
| 1358 | MaskData=get(handles.CheckMask,'UserData'); |
---|
| 1359 | if isfield(MaskData,'maskhandle') && ishandle(MaskData.maskhandle) |
---|
| 1360 | delete(MaskData.maskhandle) |
---|
| 1361 | end |
---|
| 1362 | set(handles.CheckMask,'UserData',[]) |
---|
| 1363 | UvData=get(handles.uvmat,'UserData'); |
---|
| 1364 | if isfield(UvData,'MaskName') |
---|
| 1365 | UvData=rmfield(UvData,'MaskName'); |
---|
| 1366 | set(handles.uvmat,'UserData',UvData) |
---|
| 1367 | end |
---|
| 1368 | set(handles.CheckMask,'BackgroundColor',[0.7 0.7 0.7]) |
---|
| 1369 | end |
---|
| 1370 | |
---|
| 1371 | %------------------------------------------------------------------------ |
---|
| 1372 | function errormsg=update_mask(handles,num_i1,num_j1) |
---|
| 1373 | %------------------------------------------------------------------------ |
---|
| 1374 | errormsg=[];%default |
---|
| 1375 | MaskData=get(handles.CheckMask,'UserData'); |
---|
| 1376 | if isfield(MaskData,'maskhandle')&& ishandle(MaskData.maskhandle) |
---|
| 1377 | uistack(MaskData.maskhandle,'top'); |
---|
| 1378 | end |
---|
| 1379 | num_i1_mask=mod(num_i1-1,MaskData.NbSlice)+1; |
---|
| 1380 | [RootPath,RootFile]=fileparts(MaskData.Base); |
---|
| 1381 | MaskName=fullfile_uvmat(RootPath,'',RootFile,'.png',MaskData.NomType,num_i1_mask,[],num_j1); |
---|
| 1382 | UvData=get(handles.uvmat,'UserData'); |
---|
| 1383 | %update mask image if the mask is new |
---|
| 1384 | if ~ (isfield(UvData,'MaskName') && isequal(UvData.MaskName,MaskName)) |
---|
| 1385 | UvData.MaskName=MaskName; %update the recorded name on UvData |
---|
| 1386 | set(handles.uvmat,'UserData',UvData); |
---|
| 1387 | if ~exist(MaskName,'file') |
---|
| 1388 | if isfield(MaskData,'maskhandle')&& ishandle(MaskData.maskhandle) |
---|
| 1389 | delete(MaskData.maskhandle) |
---|
| 1390 | end |
---|
| 1391 | else |
---|
| 1392 | %read mask image |
---|
[542] | 1393 | [Mask,tild,errormsg] = read_field(MaskName,'image'); |
---|
| 1394 | % Mask.AName='image'; |
---|
| 1395 | % Mask.A=imread(MaskName); |
---|
| 1396 | if ~isempty(errormsg) |
---|
| 1397 | return |
---|
| 1398 | end |
---|
[387] | 1399 | npxy=size(Mask.A); |
---|
| 1400 | if length(npxy)>2 |
---|
| 1401 | errormsg=[MaskName ' is not a grey scale image']; |
---|
| 1402 | return |
---|
| 1403 | elseif ~isa(Mask.A,'uint8') |
---|
| 1404 | errormsg=[MaskName ' is not a 8 bit grey level image']; |
---|
| 1405 | return |
---|
| 1406 | end |
---|
[542] | 1407 | % Mask.AX=[0.5 npxy(2)-0.5]; |
---|
| 1408 | % Mask.AY=[npxy(1)-0.5 0.5 ]; |
---|
| 1409 | % Mask.CoordUnit='pixel'; |
---|
[387] | 1410 | if isequal(get(handles.slices,'Value'),1) |
---|
[497] | 1411 | NbSlice=str2num(get(handles.num_NbSlice,'String')); |
---|
[387] | 1412 | num_i1=str2num(get(handles.i1,'String')); |
---|
| 1413 | Mask.ZIndex=mod(num_i1-1,NbSlice)+1; |
---|
| 1414 | end |
---|
| 1415 | %px to phys or other transform on field |
---|
[591] | 1416 | menu_transform=get(handles.TransformName,'String'); |
---|
| 1417 | choice_value=get(handles.TransformName,'Value'); |
---|
[387] | 1418 | transform_name=menu_transform{choice_value};%name of the transform fct given by the menu 'transform_fct' |
---|
[591] | 1419 | transform=get(handles.TransformPath,'UserData'); |
---|
[387] | 1420 | if ~isequal(transform_name,'') && ~isequal(transform_name,'px') |
---|
| 1421 | if isfield(UvData,'XmlData') && isfield(UvData.XmlData{1},'GeometryCalib')%use geometry calib recorded from the ImaDoc xml file as first priority |
---|
| 1422 | Calib=UvData.XmlData{1}.GeometryCalib; |
---|
| 1423 | Mask=transform(Mask,UvData.XmlData{1}); |
---|
| 1424 | end |
---|
| 1425 | end |
---|
| 1426 | flagmask=Mask.A < 200; |
---|
| 1427 | |
---|
| 1428 | %make brown color image |
---|
| 1429 | imflag(:,:,1)=0.9*flagmask; |
---|
| 1430 | imflag(:,:,2)=0.7*flagmask; |
---|
| 1431 | imflag(:,:,3)=zeros(size(flagmask)); |
---|
| 1432 | |
---|
| 1433 | %update mask image |
---|
| 1434 | hmask=[]; %default |
---|
| 1435 | if isfield(MaskData,'maskhandle')&& ishandle(MaskData.maskhandle) |
---|
| 1436 | hmask=MaskData.maskhandle; |
---|
| 1437 | end |
---|
| 1438 | if ~isempty(hmask) |
---|
| 1439 | set(hmask,'CData',imflag) |
---|
| 1440 | set(hmask,'AlphaData',flagmask*0.6) |
---|
| 1441 | set(hmask,'XData',Mask.AX); |
---|
| 1442 | set(hmask,'YData',Mask.AY); |
---|
| 1443 | % uistack(hmask,'top') |
---|
| 1444 | else |
---|
[511] | 1445 | axes(handles.PlotAxes) |
---|
[387] | 1446 | hold on |
---|
[452] | 1447 | MaskData.maskhandle=image(Mask.AX,Mask.AY,imflag,'Tag','mask','HitTest','off','AlphaData',0.6*ones(size(flagmask))); |
---|
[387] | 1448 | set(handles.CheckMask,'UserData',MaskData) |
---|
| 1449 | end |
---|
| 1450 | end |
---|
| 1451 | end |
---|
| 1452 | |
---|
| 1453 | %------------------------------------------------------------------------ |
---|
| 1454 | %------------------------------------------------------------------------ |
---|
| 1455 | % III - MAIN REFRESH FUNCTIONS : 'FRAME PLOT' |
---|
| 1456 | %------------------------------------------------------------------------ |
---|
| 1457 | |
---|
| 1458 | %------------------------------------------------------------------------ |
---|
| 1459 | % --- Executes on button press in runplus: make one step forward and call |
---|
[526] | 1460 | % --- run0. The step forward is along the fieldname series 1 or 2 depending on |
---|
[387] | 1461 | % --- the scan_i and scan_j check box (exclusive each other) |
---|
| 1462 | function runplus_Callback(hObject, eventdata, handles) |
---|
| 1463 | %------------------------------------------------------------------------ |
---|
| 1464 | set(handles.runplus,'BackgroundColor',[1 1 0])%paint the command button in yellow |
---|
| 1465 | drawnow |
---|
| 1466 | %TODO: introduce the option: increment ='*' to move to the next available view |
---|
[511] | 1467 | increment=str2num(get(handles.num_IndexIncrement,'String')); %get the field increment d |
---|
[387] | 1468 | % if isnan(increment) |
---|
[511] | 1469 | % set(handles.num_IndexIncrement,'String','1')%default value |
---|
[387] | 1470 | % increment=1; |
---|
| 1471 | % end |
---|
| 1472 | errormsg=runpm(hObject,eventdata,handles,increment); |
---|
| 1473 | if ~isempty(errormsg) |
---|
| 1474 | msgbox_uvmat('ERROR',errormsg); |
---|
| 1475 | end |
---|
| 1476 | set(handles.runplus,'BackgroundColor',[1 0 0])%paint the command button back to red |
---|
| 1477 | |
---|
| 1478 | %------------------------------------------------------------------------ |
---|
| 1479 | % --- Executes on button press in runmin: make one step backward and call |
---|
[526] | 1480 | % --- run0. The step backward is along the fieldname series 1 or 2 depending on |
---|
[387] | 1481 | % --- the scan_i and scan_j check box (exclusive each other) |
---|
| 1482 | function runmin_Callback(hObject, eventdata, handles) |
---|
| 1483 | %------------------------------------------------------------------------ |
---|
| 1484 | set(handles.runmin,'BackgroundColor',[1 1 0])%paint the command button in yellow |
---|
| 1485 | drawnow |
---|
[511] | 1486 | increment=-str2num(get(handles.num_IndexIncrement,'String')); %get the field increment d |
---|
[387] | 1487 | % if isnan(increment) |
---|
[511] | 1488 | % set(handles.num_IndexIncrement,'String','1')%default value |
---|
[387] | 1489 | % increment=1; |
---|
| 1490 | % end |
---|
| 1491 | errormsg=runpm(hObject,eventdata,handles,increment); |
---|
| 1492 | if ~isempty(errormsg) |
---|
| 1493 | msgbox_uvmat('ERROR',errormsg); |
---|
| 1494 | end |
---|
| 1495 | set(handles.runmin,'BackgroundColor',[1 0 0])%paint the command button back to red |
---|
| 1496 | |
---|
| 1497 | %------------------------------------------------------------------------ |
---|
| 1498 | % -- Executes on button press in Movie: make a series of +> steps |
---|
| 1499 | function Movie_Callback(hObject, eventdata, handles) |
---|
| 1500 | %------------------------------------------------------------------------ |
---|
| 1501 | set(handles.Movie,'BackgroundColor',[1 1 0])%paint the command button in yellow |
---|
| 1502 | drawnow |
---|
[511] | 1503 | increment=str2num(get(handles.num_IndexIncrement,'String')); %get the field increment d |
---|
[387] | 1504 | % if isnan(increment) |
---|
[511] | 1505 | % set(handles.num_IndexIncrement,'String','1')%default value |
---|
[387] | 1506 | % increment=1; |
---|
| 1507 | % end |
---|
| 1508 | set(handles.STOP,'Visible','on') |
---|
| 1509 | set(handles.speed,'Visible','on') |
---|
| 1510 | set(handles.speed_txt,'Visible','on') |
---|
| 1511 | set(handles.Movie,'BusyAction','queue') |
---|
| 1512 | UvData=get(handles.uvmat,'UserData'); |
---|
| 1513 | |
---|
[435] | 1514 | while get(handles.Movie,'Value')==1 && get(handles.speed,'Value')~=0 && isequal(get(handles.Movie,'BusyAction'),'queue') % enable STOP command |
---|
[387] | 1515 | errormsg=runpm(hObject,eventdata,handles,increment); |
---|
| 1516 | if ~isempty(errormsg) |
---|
| 1517 | set(handles.Movie,'BackgroundColor',[1 0 0])%paint the command buttonback to red |
---|
| 1518 | return |
---|
| 1519 | end |
---|
| 1520 | pause(1.02-get(handles.speed,'Value'))% wait for next image |
---|
| 1521 | end |
---|
| 1522 | if isfield(UvData,'aviobj') && ~isempty( UvData.aviobj), |
---|
| 1523 | UvData.aviobj=close(UvData.aviobj); |
---|
| 1524 | set(handles.uvmat,'UserData',UvData); |
---|
| 1525 | end |
---|
| 1526 | set(handles.Movie,'BackgroundColor',[1 0 0])%paint the command buttonback to red |
---|
| 1527 | |
---|
| 1528 | %------------------------------------------------------------------------ |
---|
| 1529 | % -- Executes on button press in Movie: make a series of <- steps |
---|
| 1530 | function MovieBackward_Callback(hObject, eventdata, handles) |
---|
| 1531 | %------------------------------------------------------------------------ |
---|
| 1532 | set(handles.MovieBackward,'BackgroundColor',[1 1 0])%paint the command button in yellow |
---|
| 1533 | drawnow |
---|
[511] | 1534 | increment=-str2num(get(handles.num_IndexIncrement,'String')); %get the field increment d |
---|
[387] | 1535 | set(handles.STOP,'Visible','on') |
---|
| 1536 | set(handles.speed,'Visible','on') |
---|
| 1537 | set(handles.speed_txt,'Visible','on') |
---|
| 1538 | set(handles.MovieBackward,'BusyAction','queue') |
---|
| 1539 | UvData=get(handles.uvmat,'UserData'); |
---|
| 1540 | |
---|
[435] | 1541 | while get(handles.MovieBackward,'Value')==1 && get(handles.speed,'Value')~=0 && isequal(get(handles.MovieBackward,'BusyAction'),'queue') % enable STOP command |
---|
[387] | 1542 | errormsg=runpm(hObject,eventdata,handles,increment); |
---|
| 1543 | if ~isempty(errormsg) |
---|
| 1544 | set(handles.MovieBackward,'BackgroundColor',[1 0 0])%paint the command buttonback to red |
---|
| 1545 | return |
---|
| 1546 | end |
---|
| 1547 | pause(1.02-get(handles.speed,'Value'))% wait for next image |
---|
| 1548 | end |
---|
| 1549 | if isfield(UvData,'aviobj') && ~isempty( UvData.aviobj), |
---|
| 1550 | UvData.aviobj=close(UvData.aviobj); |
---|
| 1551 | set(handles.uvmat,'UserData',UvData); |
---|
| 1552 | end |
---|
| 1553 | set(handles.MovieBackward,'BackgroundColor',[1 0 0])%paint the command buttonback to red |
---|
| 1554 | |
---|
| 1555 | %------------------------------------------------------------------------ |
---|
| 1556 | function STOP_Callback(hObject, eventdata, handles) |
---|
| 1557 | %------------------------------------------------------------------------ |
---|
| 1558 | set(handles.movie_pair,'BusyAction','Cancel') |
---|
| 1559 | set(handles.movie_pair,'value',0) |
---|
| 1560 | set(handles.Movie,'BusyAction','Cancel') |
---|
| 1561 | set(handles.MovieBackward,'BusyAction','Cancel') |
---|
| 1562 | set(handles.MenuExportMovie,'BusyAction','Cancel') |
---|
| 1563 | set(handles.movie_pair,'BackgroundColor',[1 0 0])%paint the command buttonback to red |
---|
| 1564 | set(handles.Movie,'BackgroundColor',[1 0 0])%paint the command buttonback to red |
---|
| 1565 | set(handles.MovieBackward,'BackgroundColor',[1 0 0])%paint the command buttonback to red |
---|
| 1566 | |
---|
| 1567 | %------------------------------------------------------------------------ |
---|
| 1568 | % --- function activated by runplus and run minus |
---|
| 1569 | function errormsg=runpm(hObject,eventdata,handles,increment) |
---|
| 1570 | %------------------------------------------------------------------------ |
---|
| 1571 | errormsg='';%default |
---|
| 1572 | %% check for movie pair status |
---|
| 1573 | movie_status=get(handles.movie_pair,'Value'); |
---|
| 1574 | if isequal(movie_status,1) |
---|
| 1575 | STOP_Callback(hObject, eventdata, handles)%interrupt movie pair if active |
---|
| 1576 | end |
---|
| 1577 | |
---|
| 1578 | %% read the current input file name(s) and field indices |
---|
| 1579 | InputFile=read_GUI(handles.InputFile); |
---|
| 1580 | InputFile.RootFile=regexprep(InputFile.RootFile,'^[\\/]|[\\/]$','');%suppress possible / or \ separator at the beginning or the end of the string |
---|
| 1581 | InputFile.SubDir=regexprep(InputFile.SubDir,'^[\\/]|[\\/]$','');%suppress possible / or \ separator at the beginning or the end of the string |
---|
| 1582 | FileExt=InputFile.FileExt; |
---|
| 1583 | NomType=get(handles.NomType,'String'); |
---|
| 1584 | i1=str2num(get(handles.i1,'String'));%read the field indices (for movie, it is not given by the file name) |
---|
| 1585 | i2=[];%default |
---|
| 1586 | if strcmp(get(handles.i2,'Visible'),'on') |
---|
| 1587 | i2=str2num(get(handles.i2,'String')); |
---|
| 1588 | end |
---|
| 1589 | j1=[]; |
---|
| 1590 | if strcmp(get(handles.j1,'Visible'),'on') |
---|
| 1591 | j1=stra2num(get(handles.j1,'String')); |
---|
| 1592 | end |
---|
| 1593 | j2=j1; |
---|
| 1594 | if strcmp(get(handles.j2,'Visible'),'on') |
---|
| 1595 | j2=stra2num(get(handles.j2,'String')); |
---|
| 1596 | end |
---|
| 1597 | sub_value= get(handles.SubField,'Value'); |
---|
| 1598 | if sub_value % a second input file has been entered |
---|
[428] | 1599 | [InputFile.RootPath_1,InputFile.SubDir_1,InputFile.RootFile_1,InputFile.FileIndex_1,InputFile.FileExt_1,InputFile.NomType_1]=read_file_boxes_1(handles); |
---|
[515] | 1600 | [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] | 1601 | else |
---|
| 1602 | filename_1=[]; |
---|
| 1603 | end |
---|
| 1604 | |
---|
| 1605 | %% increment (or decrement) the field indices and update the input filename(s) |
---|
| 1606 | if isempty(increment) |
---|
| 1607 | set(handles.CheckFixPair,'Value',0) |
---|
| 1608 | end |
---|
| 1609 | CheckFixPair=get(handles.CheckFixPair,'Value')||(isempty(i2)&&isempty(j2)); |
---|
[427] | 1610 | |
---|
| 1611 | % the pair i1-i2 or j1-j2 is imposed (check box CheckFixPair selected) |
---|
[540] | 1612 | i1_1=i1; |
---|
| 1613 | i2_1=i2; |
---|
| 1614 | j1_1=j1; |
---|
| 1615 | j2_1=j2; |
---|
[387] | 1616 | if CheckFixPair |
---|
| 1617 | if get(handles.scan_i,'Value')==1% case of scanning along index i |
---|
| 1618 | i1=i1+increment; |
---|
| 1619 | i2=i2+increment; |
---|
| 1620 | if sub_value |
---|
| 1621 | i1_1=i1_1+increment; |
---|
| 1622 | i2_1=i2_1+increment; |
---|
| 1623 | end |
---|
[515] | 1624 | |
---|
[387] | 1625 | else % case of scanning along index j (burst numbers) |
---|
| 1626 | j1=j1+increment; |
---|
| 1627 | j2=j2+increment; |
---|
| 1628 | if sub_value |
---|
| 1629 | j1_1=j1_1+increment; |
---|
| 1630 | j2_1=j2_1+increment; |
---|
| 1631 | end |
---|
| 1632 | end |
---|
[427] | 1633 | |
---|
[511] | 1634 | % 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] | 1635 | else |
---|
| 1636 | UvData=get(handles.uvmat,'UserData'); |
---|
| 1637 | ref_i=i1; |
---|
| 1638 | if ~isempty(i2) |
---|
[427] | 1639 | ref_i=floor((i1+i2)/2);% current reference index i |
---|
[387] | 1640 | end |
---|
| 1641 | ref_j=1; |
---|
| 1642 | if ~isempty(j1) |
---|
| 1643 | ref_j=j1; |
---|
| 1644 | if ~isempty(j2) |
---|
[427] | 1645 | ref_j=floor((j1+j2)/2);% current reference index j |
---|
[387] | 1646 | end |
---|
| 1647 | end |
---|
| 1648 | if ~isempty(increment) |
---|
| 1649 | if get(handles.scan_i,'Value')==1% case of scanning along index i |
---|
[427] | 1650 | ref_i=ref_i+increment;% increment the current reference index i |
---|
[387] | 1651 | else % case of scanning along index j (burst numbers) |
---|
[427] | 1652 | ref_j=ref_j+increment;% increment the current reference index j if scan_j option is used |
---|
[387] | 1653 | end |
---|
[388] | 1654 | else % free increment |
---|
[511] | 1655 | runaction=get(gcbo,'tag'); |
---|
| 1656 | if strcmp(runaction,'runplus')||strcmp(runaction,'Movie')% if runplus or movie is activated |
---|
[387] | 1657 | step=1; |
---|
| 1658 | else |
---|
| 1659 | step=-1; |
---|
| 1660 | end |
---|
| 1661 | if get(handles.scan_i,'Value')==1% case of scanning along index i |
---|
| 1662 | ref_i=ref_i+step; |
---|
[512] | 1663 | 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] | 1664 | ref_i=ref_i+step; |
---|
| 1665 | end |
---|
| 1666 | else % case of scanning along index j (burst numbers) |
---|
| 1667 | ref_j=ref_j+step; |
---|
[512] | 1668 | 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] | 1669 | ref_j=ref_j+step; |
---|
| 1670 | end |
---|
| 1671 | end |
---|
| 1672 | end |
---|
| 1673 | if ref_i<0 |
---|
| 1674 | errormsg='minimum i index reached'; |
---|
| 1675 | elseif ref_j<0 |
---|
| 1676 | errormsg='minimum j index reached'; |
---|
[512] | 1677 | elseif ref_i+1>size(UvData.i1_series{1},3) |
---|
[511] | 1678 | errormsg='maximum i index reached (reload the input file to update the index bound)'; |
---|
[387] | 1679 | elseif ref_j+1>size(UvData.i1_series{1},2) |
---|
[511] | 1680 | errormsg='maximum j index reached (reload the input file to update the index bound)'; |
---|
[387] | 1681 | end |
---|
[511] | 1682 | if ~isempty(errormsg),return,end |
---|
[512] | 1683 | siz=size(UvData.i1_series{1}); |
---|
[515] | 1684 | 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] | 1685 | i1_subseries=UvData.i1_series{1}(ref_indices); |
---|
| 1686 | ref_indices=ref_indices(i1_subseries>0); |
---|
| 1687 | if isempty(ref_indices)% case of pairs (free index i) |
---|
[515] | 1688 | ref_indices=ref_i*siz(1)*siz(2)+1:(ref_i+1)*siz(1)*siz(2); |
---|
[512] | 1689 | i1_subseries=UvData.i1_series{1}(ref_indices); |
---|
| 1690 | ref_indices=ref_indices(i1_subseries>0); |
---|
[511] | 1691 | end |
---|
[512] | 1692 | if isempty(ref_indices),errormsg='no next frame: set num_IndexIncrement =''*'' to reach the next existing file';return |
---|
[387] | 1693 | end |
---|
[512] | 1694 | i1=UvData.i1_series{1}(ref_indices(end)); |
---|
[387] | 1695 | if ~isempty(UvData.i2_series{1}) |
---|
[512] | 1696 | i2=UvData.i2_series{1}(ref_indices(end)); |
---|
[387] | 1697 | end |
---|
| 1698 | if ~isempty(UvData.j1_series{1}) |
---|
[512] | 1699 | j1=UvData.j1_series{1}(ref_indices(end)); |
---|
[387] | 1700 | end |
---|
| 1701 | if ~isempty(UvData.j2_series{1}) |
---|
[512] | 1702 | j2=UvData.j2_series{1}(ref_indices(end)); |
---|
[515] | 1703 | end |
---|
| 1704 | |
---|
| 1705 | % case of a second file series |
---|
| 1706 | if sub_value |
---|
| 1707 | ref_i_1=i1_1; |
---|
| 1708 | if ~isempty(i2_1) |
---|
| 1709 | ref_i_1=floor((i1_1+i2_1)/2);% current reference index i |
---|
| 1710 | end |
---|
| 1711 | ref_j_1=1; |
---|
| 1712 | if ~isempty(j1_1) |
---|
| 1713 | ref_j_1=j1_1; |
---|
| 1714 | if ~isempty(j2_1) |
---|
| 1715 | ref_j_1=floor((j1_1+j2_1)/2);% current reference index j |
---|
| 1716 | end |
---|
| 1717 | end |
---|
| 1718 | if ~isempty(increment) |
---|
| 1719 | if get(handles.scan_i,'Value')==1% case of scanning along index i |
---|
| 1720 | ref_i_1=ref_i_1+increment;% increment the current reference index i |
---|
| 1721 | else % case of scanning along index j (burst numbers) |
---|
| 1722 | ref_j_1=ref_j_1+increment;% increment the current reference index j if scan_j option is used |
---|
| 1723 | end |
---|
| 1724 | else % free increment, synchronise the ref indices with the first series |
---|
| 1725 | ref_i_1=ref_i; |
---|
| 1726 | ref_j_1=ref_j; |
---|
| 1727 | end |
---|
| 1728 | if numel(UvData.i1_series)==1 |
---|
| 1729 | UvData.i1_series{2}=UvData.i1_series{1}; |
---|
| 1730 | UvData.j1_series{2}=UvData.j1_series{1}; |
---|
| 1731 | UvData.i2_series{2}=UvData.i2_series{1}; |
---|
| 1732 | UvData.j2_series{2}=UvData.j2_series{1}; |
---|
| 1733 | end |
---|
| 1734 | if ref_i_1<0 |
---|
| 1735 | errormsg='minimum i index reached'; |
---|
| 1736 | elseif ref_j_1<0 |
---|
| 1737 | errormsg='minimum j index reached'; |
---|
| 1738 | elseif ref_i_1+1>size(UvData.i1_series{2},3) |
---|
| 1739 | errormsg='maximum i index reached for the second series (reload the input file to update the index bound)'; |
---|
| 1740 | elseif ref_j_1+1>size(UvData.i1_series{2},2) |
---|
| 1741 | errormsg='maximum j index reached for the second series(reload the input file to update the index bound)'; |
---|
| 1742 | end |
---|
| 1743 | if ~isempty(errormsg),return,end |
---|
| 1744 | siz=size(UvData.i1_series{2}); |
---|
| 1745 | 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); |
---|
| 1746 | i1_subseries=UvData.i1_series{2}(ref_indices); |
---|
| 1747 | ref_indices=ref_indices(i1_subseries>0); |
---|
| 1748 | if isempty(ref_indices)% case of pairs (free index i) |
---|
| 1749 | ref_indices=ref_i_1*siz(1)*siz(2)+1:(ref_i_1+1)*siz(1)*siz(2); |
---|
| 1750 | i1_subseries=UvData.i1_series{2}(ref_indices); |
---|
| 1751 | ref_indices=ref_indices(i1_subseries>0); |
---|
| 1752 | end |
---|
| 1753 | i1_1=UvData.i1_series{2}(ref_indices(end)); |
---|
[427] | 1754 | if ~isempty(UvData.i2_series{2}) |
---|
[515] | 1755 | i2_1=UvData.i2_series{2}(ref_indices(end)); |
---|
[427] | 1756 | end |
---|
| 1757 | if ~isempty(UvData.j1_series{2}) |
---|
[515] | 1758 | j1_1=UvData.j1_series{2}(ref_indices(end)); |
---|
[427] | 1759 | end |
---|
| 1760 | if ~isempty(UvData.j2_series{2}) |
---|
[515] | 1761 | j2_1=UvData.j2_series{1}(ref_indices(end)); |
---|
| 1762 | end |
---|
| 1763 | else% the second series (if needed) is the same file as the first |
---|
| 1764 | i1_1=i1; |
---|
| 1765 | i2_1=i2; |
---|
| 1766 | j1_1=j1; |
---|
| 1767 | j2_1=j2; |
---|
[387] | 1768 | end |
---|
| 1769 | end |
---|
| 1770 | filename=fullfile_uvmat(InputFile.RootPath,InputFile.SubDir,InputFile.RootFile,FileExt,NomType,i1,i2,j1,j2); |
---|
| 1771 | if sub_value |
---|
[428] | 1772 | 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] | 1773 | end |
---|
| 1774 | |
---|
| 1775 | %% refresh plots |
---|
[515] | 1776 | errormsg=refresh_field(handles,filename,filename_1,i1,i2,j1,j2,i1_1,i2_1,j1_1,j2_1); |
---|
[387] | 1777 | |
---|
| 1778 | %% update the index counters if the index move is successfull |
---|
| 1779 | if isempty(errormsg) |
---|
| 1780 | set(handles.i1,'String',num2stra(i1,NomType,1)); |
---|
| 1781 | if isequal(i2,i1) |
---|
| 1782 | set(handles.i2,'String',''); |
---|
| 1783 | else |
---|
| 1784 | set(handles.i2,'String',num2stra(i2,NomType,1)); |
---|
| 1785 | end |
---|
| 1786 | set(handles.j1,'String',num2stra(j1,NomType,2)); |
---|
| 1787 | if isequal(j2,j1) |
---|
| 1788 | set(handles.j2,'String',''); |
---|
| 1789 | else |
---|
| 1790 | set(handles.j2,'String',num2stra(j2,NomType,2)); |
---|
| 1791 | end |
---|
| 1792 | indices=fullfile_uvmat('','','','',NomType,i1,i2,j1,j2); |
---|
| 1793 | set(handles.FileIndex,'String',indices); |
---|
| 1794 | if ~isempty(filename_1) |
---|
[428] | 1795 | indices_1=fullfile_uvmat('','','','',InputFile.NomType_1,i1_1,i2_1,j1_1,j2_1); |
---|
[387] | 1796 | set(handles.FileIndex_1,'String',indices_1); |
---|
| 1797 | end |
---|
| 1798 | if isequal(movie_status,1) |
---|
| 1799 | set(handles.movie_pair,'Value',1) |
---|
| 1800 | movie_pair_Callback(hObject, eventdata, handles); %reactivate moviepair if it was activated |
---|
| 1801 | end |
---|
| 1802 | end |
---|
| 1803 | |
---|
| 1804 | %------------------------------------------------------------------------ |
---|
| 1805 | % --- Executes on button press in movie_pair: create an alternating movie with two view |
---|
| 1806 | function movie_pair_Callback(hObject, eventdata, handles) |
---|
| 1807 | %------------------------------------------------------------------------ |
---|
| 1808 | %% stop movie action if the movie_pair button is off |
---|
| 1809 | if ~get(handles.movie_pair,'value') |
---|
| 1810 | set(handles.movie_pair,'BusyAction','Cancel')%stop movie pair if button is 'off' |
---|
| 1811 | set(handles.i2,'String','') |
---|
| 1812 | set(handles.j2,'String','') |
---|
| 1813 | return |
---|
| 1814 | else |
---|
| 1815 | set(handles.movie_pair,'BusyAction','queue') |
---|
| 1816 | end |
---|
| 1817 | |
---|
| 1818 | %% initialisation |
---|
| 1819 | set(handles.movie_pair,'BackgroundColor',[1 1 0])%paint the command button in yellow |
---|
| 1820 | drawnow |
---|
[526] | 1821 | list_fields=get(handles.FieldName,'String');% list menu fields |
---|
| 1822 | index_fields=get(handles.FieldName,'Value');% selected string index |
---|
[387] | 1823 | FieldName=list_fields{index_fields}; % selected field |
---|
| 1824 | UvData=get(handles.uvmat,'UserData'); |
---|
| 1825 | if isequal(FieldName,'image') |
---|
[512] | 1826 | index=1; |
---|
[387] | 1827 | [RootPath,SubDir,RootFile,FileIndices,Ext]=read_file_boxes(handles); |
---|
| 1828 | NomType=get(handles.NomType,'String'); |
---|
| 1829 | else |
---|
[526] | 1830 | list_fields=get(handles.FieldName_1,'String');% list menu fields |
---|
| 1831 | index_fields=get(handles.FieldName_1,'Value');% selected string index |
---|
[387] | 1832 | FieldName=list_fields{index_fields}; % selected field |
---|
| 1833 | if isequal(FieldName,'image') |
---|
[512] | 1834 | index=2; |
---|
[387] | 1835 | [RootPath,tild,RootFile,FileIndex_1,Ext,NomType]=read_file_boxes_1(handles); |
---|
| 1836 | else |
---|
| 1837 | msgbox_uvmat('ERROR','an image or movie must be first introduced as input') |
---|
| 1838 | set(handles.movie_pair,'BackgroundColor',[1 0 0])%paint the command button in red |
---|
| 1839 | set(handles.movie_pair,'Value',0) |
---|
| 1840 | return |
---|
| 1841 | end |
---|
| 1842 | end |
---|
| 1843 | num_i1=str2num(get(handles.i1,'String')); |
---|
| 1844 | num_j1=stra2num(get(handles.j1,'String')); |
---|
| 1845 | num_i2=str2num(get(handles.i2,'String')); |
---|
| 1846 | num_j2=stra2num(get(handles.j2,'String')); |
---|
[582] | 1847 | imaname_1=''; |
---|
[387] | 1848 | if isempty(num_j2) |
---|
[582] | 1849 | if isempty(num_i2) |
---|
| 1850 | if strcmp(get(handles.j2,'Visible'),'on') %if the j box is visible |
---|
| 1851 | imaname_1=fullfile_uvmat(RootPath,SubDir,RootFile,Ext,NomType,num_i1,[],num_j1+1); |
---|
| 1852 | end |
---|
| 1853 | if exist(imaname_1,'file') |
---|
[598] | 1854 | num_j2=num_j1+1;% look by default for the next j index as the second file |
---|
| 1855 | set(handles.j2,'String',num2stra(num_j2,NomType)); |
---|
[582] | 1856 | else |
---|
| 1857 | imaname_1=fullfile_uvmat(RootPath,SubDir,RootFile,Ext,NomType,num_i1+1,[],num_j1); |
---|
| 1858 | if exist(imaname_1,'file') |
---|
| 1859 | num_i2=num_i1+1; |
---|
| 1860 | set(handles.i2,'String',num2str(num_i2)); |
---|
| 1861 | else |
---|
| 1862 | msgbox_uvmat('ERROR', 'a second image index i2 or j2 is needed to show the pair as a movie') |
---|
| 1863 | set(handles.movie_pair,'BackgroundColor',[1 0 0])%paint the command button in red |
---|
| 1864 | set(handles.movie_pair,'Value',0) |
---|
| 1865 | return |
---|
| 1866 | end |
---|
| 1867 | end |
---|
[387] | 1868 | else |
---|
| 1869 | num_j2=num_j1;%repeat the index i1 by default |
---|
| 1870 | end |
---|
| 1871 | end |
---|
| 1872 | if isempty(num_i2) |
---|
| 1873 | num_i2=num_i1;%repeat the index i1 by default |
---|
| 1874 | end |
---|
[439] | 1875 | imaname_1=fullfile_uvmat(RootPath,SubDir,RootFile,Ext,NomType,num_i2,[],num_j2); |
---|
[512] | 1876 | if strcmp(NomType,'*') |
---|
| 1877 | num_frame=num_i2; |
---|
| 1878 | else |
---|
| 1879 | num_frame=num_j2; |
---|
| 1880 | end |
---|
[387] | 1881 | if ~exist(imaname_1,'file') |
---|
| 1882 | msgbox_uvmat('ERROR',['second input open (-) ' imaname_1 ' not found']); |
---|
| 1883 | set(handles.movie_pair,'BackgroundColor',[1 0 0])%paint the command button in red |
---|
| 1884 | set(handles.movie_pair,'Value',0) |
---|
| 1885 | return |
---|
| 1886 | end |
---|
| 1887 | |
---|
[512] | 1888 | %% get the first image |
---|
| 1889 | %Field.AName='image'; |
---|
| 1890 | if index==1 |
---|
| 1891 | Field_a=UvData.Field;% movie on the second field |
---|
[387] | 1892 | else |
---|
[512] | 1893 | Field_a=UvData.Field_1;% movie on the first field |
---|
[387] | 1894 | end |
---|
| 1895 | |
---|
[512] | 1896 | %% read the second image |
---|
| 1897 | MovieObject=[]; |
---|
| 1898 | if numel(UvData.MovieObject)>=index |
---|
| 1899 | MovieObject=UvData.MovieObject{index}; |
---|
[387] | 1900 | end |
---|
[549] | 1901 | [Field_b,ParamOut,errormsg] = read_field(imaname_1,UvData.FileType{index},MovieObject,num_frame); |
---|
[512] | 1902 | % Field_b.AX=Field_a.AX; |
---|
| 1903 | % Field_b.AY=Field_a.AY; |
---|
| 1904 | % % z index |
---|
| 1905 | % nbslice=str2double(get(handles.num_NbSlice,'String')); |
---|
| 1906 | % if ~isempty(nbslice) |
---|
| 1907 | % Field_b.ZIndex=mod(num_i2-1,nbslice)+1; |
---|
| 1908 | % end |
---|
| 1909 | % Field_b.CoordUnit='pixel'; |
---|
| 1910 | % |
---|
| 1911 | % %% determine the input file type |
---|
| 1912 | % if (test_1 && isfield(UvData,'MovieObject')&& numel(UvData.MovieObject>=2))||(~test_1 && ~isempty(UvData.MovieObject{1})) |
---|
| 1913 | % FileType='movie'; |
---|
| 1914 | % elseif isequal(lower(Ext),'.avi') |
---|
| 1915 | % FileType='avi'; |
---|
| 1916 | % elseif isequal(lower(Ext),'.vol') |
---|
| 1917 | % FileType='vol'; |
---|
| 1918 | % else |
---|
| 1919 | % form=imformats(Ext(2:end)); |
---|
| 1920 | % if ~isempty(form)% if the extension corresponds to an image format recognized by Matlab |
---|
| 1921 | % if isequal(NomType,'*'); |
---|
| 1922 | % FileType='multimage'; |
---|
| 1923 | % else |
---|
| 1924 | % FileType='image'; |
---|
| 1925 | % end |
---|
| 1926 | % end |
---|
| 1927 | % end |
---|
| 1928 | % switch FileType |
---|
| 1929 | % case 'movie' |
---|
| 1930 | % if test_1 |
---|
| 1931 | % Field_b.A=read(UvData.MovieObject{2},num_i2); |
---|
| 1932 | % else |
---|
| 1933 | % Field_b.A=read(UvData.MovieObject{1},num_i2); |
---|
| 1934 | % end |
---|
| 1935 | % case 'avi' |
---|
| 1936 | % mov=aviread(imaname_1,num_i2); |
---|
| 1937 | % Field_b.A=frame2im(mov(1)); |
---|
| 1938 | % case 'vol' |
---|
| 1939 | % Field_b.A=imread(imaname_1); |
---|
| 1940 | % case 'multimage' |
---|
| 1941 | % Field_b.A=imread(imaname_1,num_i2); |
---|
| 1942 | % case 'image' |
---|
| 1943 | % Field_b.A=imread(imaname_1); |
---|
| 1944 | % end |
---|
| 1945 | % if get(handles.slices,'Value') |
---|
| 1946 | % Field.ZIndex=str2double(get(handles.z_index,'String')); |
---|
| 1947 | % end |
---|
[387] | 1948 | |
---|
| 1949 | %px to phys or other transform on field |
---|
[591] | 1950 | transform=get(handles.TransformPath,'UserData'); |
---|
[512] | 1951 | if ~isempty(transform) |
---|
| 1952 | if isfield(UvData,'XmlData') && numel(UvData.XmlData)>=index %use geometry calib recorded from the ImaDoc xml file as first priority |
---|
| 1953 | if index==2 |
---|
| 1954 | Field_a=transform(Field_a,UvData.XmlData{index});%the first field has been stored without transform |
---|
| 1955 | end |
---|
| 1956 | Field_b=transform(Field_b,UvData.XmlData{index}); |
---|
[387] | 1957 | end |
---|
| 1958 | end |
---|
| 1959 | |
---|
| 1960 | % make movie until movie speed is set to 0 or STOP is activated |
---|
[511] | 1961 | hima=findobj(handles.PlotAxes,'Tag','ima');% %handles.PlotAxes =main plotting window (A GENERALISER) |
---|
[387] | 1962 | set(handles.STOP,'Visible','on') |
---|
| 1963 | set(handles.speed,'Visible','on') |
---|
| 1964 | set(handles.speed_txt,'Visible','on') |
---|
| 1965 | while get(handles.speed,'Value')~=0 && isequal(get(handles.movie_pair,'BusyAction'),'queue')%isequal(get(handles.run0,'BusyAction'),'queue'); % enable STOP command |
---|
| 1966 | % read and plot the series of images in non erase mode |
---|
| 1967 | set(hima,'CData',Field_b.A); |
---|
| 1968 | pause(1.02-get(handles.speed,'Value'));% wait for next image |
---|
| 1969 | set(hima,'CData',Field_a.A); |
---|
| 1970 | pause(1.02-get(handles.speed,'Value'));% wait for next image |
---|
| 1971 | end |
---|
| 1972 | set(handles.movie_pair,'BackgroundColor',[1 0 0])%paint the command button in red |
---|
| 1973 | set(handles.movie_pair,'Value',0) |
---|
| 1974 | |
---|
| 1975 | %------------------------------------------------------------------------ |
---|
| 1976 | % --- Executes on button press in run0. |
---|
| 1977 | function run0_Callback(hObject, eventdata, handles) |
---|
| 1978 | %------------------------------------------------------------------------ |
---|
| 1979 | set(handles.run0,'BackgroundColor',[1 1 0])%paint the command button in yellow |
---|
| 1980 | drawnow |
---|
[515] | 1981 | [RootPath,SubDir,RootFile,FileIndex,FileExt]=read_file_boxes(handles); |
---|
| 1982 | filename=[fullfile(RootPath,SubDir,RootFile) FileIndex FileExt]; |
---|
| 1983 | filename_1='';%default |
---|
| 1984 | FileIndex_1=''; |
---|
[387] | 1985 | if get(handles.SubField,'Value') |
---|
[515] | 1986 | [RootPath_1,SubDir_1,RootFile_1,FileIndex_1,FileExt_1]=read_file_boxes_1(handles); |
---|
| 1987 | filename_1=[fullfile(RootPath_1,SubDir_1,RootFile_1) FileIndex_1 FileExt_1]; |
---|
[387] | 1988 | end |
---|
| 1989 | num_i1=stra2num(get(handles.i1,'String')); |
---|
| 1990 | num_i2=stra2num(get(handles.i2,'String')); |
---|
| 1991 | num_j1=stra2num(get(handles.j1,'String')); |
---|
| 1992 | num_j2=stra2num(get(handles.j2,'String')); |
---|
[515] | 1993 | [tild,tild,tild,i1_1,i2_1,j1_1,j2_1]=fileparts_uvmat(FileIndex_1); |
---|
[387] | 1994 | |
---|
[515] | 1995 | errormsg=refresh_field(handles,filename,filename_1,num_i1,num_i2,num_j1,num_j2,i1_1,i2_1,j1_1,j2_1); |
---|
[387] | 1996 | |
---|
| 1997 | if ~isempty(errormsg) |
---|
| 1998 | msgbox_uvmat('ERROR',errormsg); |
---|
| 1999 | else |
---|
| 2000 | set(handles.i1,'BackgroundColor',[1 1 1]) |
---|
| 2001 | set(handles.i2,'BackgroundColor',[1 1 1]) |
---|
| 2002 | set(handles.j1,'BackgroundColor',[1 1 1]) |
---|
| 2003 | set(handles.j2,'BackgroundColor',[1 1 1]) |
---|
| 2004 | set(handles.FileIndex,'BackgroundColor',[1 1 1]) |
---|
| 2005 | set(handles.FileIndex_1,'BackgroundColor',[1 1 1]) |
---|
| 2006 | end |
---|
| 2007 | set(handles.run0,'BackgroundColor',[1 0 0]) |
---|
| 2008 | |
---|
| 2009 | |
---|
| 2010 | %------------------------------------------------------------------------ |
---|
| 2011 | % --- read the input files and refresh all the plots, including projection. |
---|
| 2012 | % OUTPUT: |
---|
| 2013 | % errormsg: error message char string =[] by default |
---|
| 2014 | % INPUT: |
---|
| 2015 | % filename: first input file (=[] in the absence of input file) |
---|
| 2016 | % filename_1: second input file (=[] in the asbsenc of secodn input file) |
---|
| 2017 | % num_i1,num_i2,num_j1,num_j2; frame indices |
---|
| 2018 | % Field: structure describing an optional input field (then replace the input file) |
---|
[397] | 2019 | |
---|
[515] | 2020 | 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] | 2021 | %------------------------------------------------------------------------ |
---|
| 2022 | |
---|
| 2023 | %% initialisation |
---|
| 2024 | abstime=[]; |
---|
| 2025 | abstime_1=[]; |
---|
| 2026 | dt=[]; |
---|
| 2027 | if ~exist('Field','var') |
---|
| 2028 | Field={}; |
---|
| 2029 | end |
---|
| 2030 | UvData=get(handles.uvmat,'UserData'); |
---|
| 2031 | if ishandle(handles.UVMAT_title) %remove title panel on uvmat |
---|
| 2032 | delete(handles.UVMAT_title) |
---|
| 2033 | end |
---|
| 2034 | |
---|
| 2035 | %% determine the main input file information for action |
---|
[450] | 2036 | if ~exist(FileName,'file') |
---|
| 2037 | errormsg=['input file ' FileName ' does not exist']; |
---|
[387] | 2038 | return |
---|
| 2039 | end |
---|
| 2040 | NomType=get(handles.NomType,'String'); |
---|
[494] | 2041 | NomType_1=''; |
---|
| 2042 | if strcmp(get(handles.NomType_1,'Visible'),'on') |
---|
| 2043 | NomType_1=get(handles.NomType_1,'String'); |
---|
| 2044 | end |
---|
[387] | 2045 | %update the z position index |
---|
[589] | 2046 | mode_slice=get(handles.slices,'String'); |
---|
| 2047 | if strcmp(mode_slice,'volume') |
---|
[387] | 2048 | z_index=num_j1; |
---|
| 2049 | set(handles.z_index,'String',num2str(z_index)) |
---|
| 2050 | else |
---|
[589] | 2051 | nbslice=str2num(get(handles.num_NbSlice,'String')); |
---|
[387] | 2052 | z_index=mod(num_i1-1,nbslice)+1; |
---|
| 2053 | set(handles.z_index,'String',num2str(z_index)) |
---|
| 2054 | end |
---|
| 2055 | % refresh menu for save_mask if relevant |
---|
| 2056 | masknumber=get(handles.masklevel,'String'); |
---|
| 2057 | if length(masknumber)>=z_index |
---|
| 2058 | set(handles.masklevel,'Value',z_index) |
---|
| 2059 | end |
---|
| 2060 | |
---|
[515] | 2061 | %% test for need of tps |
---|
| 2062 | check_proj_tps=0; |
---|
| 2063 | if (strcmp(UvData.FileType{1},'civdata')||strcmp(UvData.FileType{1},'civx')) |
---|
| 2064 | for iobj=1:numel(UvData.Object) |
---|
[581] | 2065 | if isfield(UvData.Object{iobj},'ProjMode')&& strcmp(UvData.Object{iobj}.ProjMode,'interp_tps') |
---|
[515] | 2066 | check_proj_tps=1; |
---|
| 2067 | break |
---|
| 2068 | end |
---|
| 2069 | end |
---|
| 2070 | end |
---|
| 2071 | |
---|
[507] | 2072 | %% read the first input field |
---|
[421] | 2073 | ParamIn.ColorVar='';%default variable name for vector color |
---|
[445] | 2074 | frame_index=1;%default |
---|
[507] | 2075 | FieldName='';%default |
---|
| 2076 | VelType='';%default |
---|
| 2077 | switch UvData.FileType{1} |
---|
| 2078 | case {'civx','civdata','netcdf'}; |
---|
[526] | 2079 | list_fields=get(handles.FieldName,'String');% list menu fields |
---|
| 2080 | FieldName= list_fields{get(handles.FieldName,'Value')}; % selected field |
---|
[576] | 2081 | % if get_field... is selected, the GUI get_field will be used to enter fields |
---|
[507] | 2082 | if ~strcmp(FieldName,'get_field...') |
---|
| 2083 | if get(handles.FixVelType,'Value') |
---|
| 2084 | VelTypeList=get(handles.VelType,'String'); |
---|
| 2085 | VelType=VelTypeList{get(handles.VelType,'Value')}; |
---|
[387] | 2086 | end |
---|
[507] | 2087 | end |
---|
[576] | 2088 | % case of input vector field, get the scalar used for vector color |
---|
[517] | 2089 | if ~isempty(regexp(FieldName,'^vec(')) |
---|
[507] | 2090 | list_code=get(handles.ColorCode,'String');% list menu fields |
---|
| 2091 | index_code=get(handles.ColorCode,'Value');% selected string index |
---|
| 2092 | if ~strcmp(list_code{index_code},'black') && ~strcmp(list_code{index_code},'white') |
---|
| 2093 | list_code=get(handles.ColorScalar,'String');% list menu fields |
---|
| 2094 | index_code=get(handles.ColorScalar,'Value');% selected string index |
---|
| 2095 | ParamIn.ColorVar= list_code{index_code}; % selected field |
---|
[387] | 2096 | end |
---|
[507] | 2097 | end |
---|
| 2098 | case {'video','mmreader'} |
---|
| 2099 | ParamIn=UvData.MovieObject{1}; |
---|
| 2100 | if ~strcmp(NomType,'*') |
---|
| 2101 | frame_index=num_j1;%frame index for movies or multimage |
---|
| 2102 | else |
---|
| 2103 | frame_index=num_i1; |
---|
| 2104 | end |
---|
| 2105 | case 'multimage' |
---|
| 2106 | if ~strcmp(NomType,'*') |
---|
| 2107 | frame_index=num_j1;%frame index for movies or multimage |
---|
| 2108 | else |
---|
| 2109 | frame_index=num_i1; |
---|
| 2110 | end |
---|
| 2111 | case 'vol' %TODO: update |
---|
| 2112 | if isfield(UvData.XmlData,'Npy') && isfield(UvData.XmlData,'Npx') |
---|
| 2113 | ParamIn.Npy=UvData.XmlData.Npy; |
---|
| 2114 | ParamIn.Npx=UvData.XmlData.Npx; |
---|
| 2115 | else |
---|
| 2116 | errormsg='Npx and Npy need to be defined in the xml file for volume images .vol'; |
---|
| 2117 | return |
---|
| 2118 | end |
---|
[387] | 2119 | end |
---|
[507] | 2120 | if isstruct (ParamIn) |
---|
[517] | 2121 | ParamIn.FieldName=FieldName; |
---|
| 2122 | ParamIn.VelType=VelType; |
---|
| 2123 | XNameMenu=get(handles.Coord_x,'String'); |
---|
[595] | 2124 | if ~isempty(XNameMenu) |
---|
| 2125 | ParamIn.Coord_x=XNameMenu(get(handles.Coord_x,'Value')); |
---|
| 2126 | end |
---|
[517] | 2127 | YNameMenu=get(handles.Coord_y,'String'); |
---|
[595] | 2128 | if ~isempty(YNameMenu) |
---|
| 2129 | ParamIn.Coord_y=YNameMenu(get(handles.Coord_y,'Value')); |
---|
| 2130 | end |
---|
[507] | 2131 | end |
---|
[517] | 2132 | check_tps = 0; |
---|
[515] | 2133 | if strcmp(UvData.FileType{1},'civdata')&&~strcmp(ParamIn.FieldName,'velocity')&&~strcmp(ParamIn.FieldName,'get_field...') |
---|
| 2134 | check_tps=1;%tps needed to get the requested field |
---|
| 2135 | end |
---|
[507] | 2136 | [Field{1},ParamOut,errormsg] = read_field(FileName,UvData.FileType{1},ParamIn,frame_index); |
---|
| 2137 | if ~isempty(errormsg) |
---|
[527] | 2138 | errormsg=['uvmat / refresh_field / read_field( ' FileName ') / ' errormsg]; |
---|
[507] | 2139 | return |
---|
| 2140 | end |
---|
| 2141 | if isfield(ParamOut,'Npx')&& isfield(ParamOut,'Npy') |
---|
| 2142 | set(handles.num_Npx,'String',num2str(ParamOut.Npx));% display image size on the interface |
---|
| 2143 | set(handles.num_Npy,'String',num2str(ParamOut.Npy)); |
---|
| 2144 | end |
---|
| 2145 | if isfield(ParamOut,'TimeIndex')% case of time obtained from get_field |
---|
| 2146 | set(handles.i1,'String',num2str(ParamOut.TimeIndex)) |
---|
| 2147 | end |
---|
| 2148 | if isfield(ParamOut,'TimeValue') |
---|
| 2149 | Field{1}.Time=ParamOut.TimeValue;% case of time obtained from get_field |
---|
| 2150 | end |
---|
| 2151 | Field{1}.ZIndex=z_index; %used for multiplane 3D calibration |
---|
[387] | 2152 | |
---|
[576] | 2153 | |
---|
[450] | 2154 | %% choose and read a second field FileName_1 if defined |
---|
[387] | 2155 | VelType_1=[];%default |
---|
| 2156 | FieldName_1=[]; |
---|
[496] | 2157 | ParamIn_1=[]; |
---|
[387] | 2158 | ParamOut_1=[]; |
---|
[445] | 2159 | frame_index_1=1; |
---|
[450] | 2160 | if ~isempty(FileName_1) |
---|
| 2161 | if ~exist(FileName_1,'file') |
---|
| 2162 | errormsg=['second file ' FileName_1 ' does not exist']; |
---|
[387] | 2163 | return |
---|
| 2164 | end |
---|
[580] | 2165 | % Name=FileName_1; |
---|
[404] | 2166 | switch UvData.FileType{2} |
---|
[387] | 2167 | case {'civx','civdata','netcdf'}; |
---|
[526] | 2168 | list_fields=get(handles.FieldName_1,'String');% list menu fields |
---|
[520] | 2169 | if ischar(list_fields),list_fields={list_fields};end |
---|
[526] | 2170 | FieldName_1= list_fields{get(handles.FieldName_1,'Value')}; % selected field |
---|
[387] | 2171 | if ~strcmp(FieldName,'get_field...') |
---|
[389] | 2172 | if get(handles.FixVelType,'Value') |
---|
| 2173 | VelTypeList=get(handles.VelType_1,'String'); |
---|
| 2174 | VelType_1=VelTypeList{get(handles.VelType_1,'Value')};% read the velocity type. |
---|
[387] | 2175 | end |
---|
| 2176 | end |
---|
[405] | 2177 | if strcmp(FieldName_1,'velocity')&& strcmp(get(handles.ColorCode,'Visible'),'on') |
---|
| 2178 | list_code=get(handles.ColorCode,'String');% list menu fields |
---|
| 2179 | index_code=get(handles.ColorCode,'Value');% selected string index |
---|
[387] | 2180 | if ~strcmp(list_code{index_code},'black') && ~strcmp(list_code{index_code},'white') |
---|
[405] | 2181 | list_code=get(handles.ColorScalar,'String');% list menu fields |
---|
| 2182 | index_code=get(handles.ColorScalar,'Value');% selected string index |
---|
| 2183 | ParamIn_1.ColorVar= list_code{index_code}; % selected field for vector color display |
---|
[387] | 2184 | end |
---|
| 2185 | end |
---|
[435] | 2186 | case {'video','mmreader'} |
---|
[450] | 2187 | ParamIn_1=UvData.MovieObject{2}; |
---|
[445] | 2188 | if ~strcmp(NomType_1,'*') |
---|
[515] | 2189 | frame_index_1=j1_1;%frame index for movies or multimage |
---|
[445] | 2190 | else |
---|
[515] | 2191 | frame_index_1=i1_1; |
---|
[445] | 2192 | end |
---|
| 2193 | case 'multimage' |
---|
| 2194 | if ~strcmp(NomType_1,'*') |
---|
[515] | 2195 | frame_index_1=j1_1;%frame index for movies or multimage |
---|
[445] | 2196 | else |
---|
[515] | 2197 | frame_index_1=i1_1; |
---|
[445] | 2198 | end |
---|
[387] | 2199 | case 'vol' %TODO: update |
---|
| 2200 | if isfield(UvData.XmlData,'Npy') && isfield(UvData.XmlData,'Npx') |
---|
[405] | 2201 | ParamIn_1.Npy=UvData.XmlData.Npy; |
---|
| 2202 | ParamIn_1.Npx=UvData.XmlData.Npx; |
---|
[387] | 2203 | else |
---|
| 2204 | errormsg='Npx and Npy need to be defined in the xml file for volume images .vol'; |
---|
| 2205 | return |
---|
| 2206 | end |
---|
| 2207 | end |
---|
[428] | 2208 | if isequal(get(handles.NomType_1,'Visible'),'on') |
---|
[387] | 2209 | NomType_1=get(handles.NomType_1,'String'); |
---|
[428] | 2210 | else |
---|
| 2211 | NomType_1=get(handles.NomType,'String'); |
---|
| 2212 | end |
---|
[387] | 2213 | test_keepdata_1=0;% test for keeping the previous stored data if the input files are unchanged |
---|
[515] | 2214 | if ~isequal(NomType_1,'*')&& isfield(UvData,'FileName_1') |
---|
[580] | 2215 | test_keepdata_1= strcmp(FileName_1,UvData.FileName_1) ; |
---|
[387] | 2216 | end |
---|
| 2217 | if test_keepdata_1 |
---|
[389] | 2218 | Field{2}=UvData.Field_1;% keep the stored field |
---|
[427] | 2219 | ParamOut_1=UvData.ParamOut_1; |
---|
[387] | 2220 | else |
---|
[496] | 2221 | if isempty(ParamIn_1) || isstruct(ParamIn_1) |
---|
[405] | 2222 | ParamIn_1.FieldName=FieldName_1; |
---|
| 2223 | ParamIn_1.VelType=VelType_1; |
---|
| 2224 | ParamIn_1.GUIName='get_field_1'; |
---|
[515] | 2225 | end |
---|
[580] | 2226 | [Field{2},ParamOut_1,errormsg] = read_field(FileName_1,UvData.FileType{2},ParamIn_1,frame_index_1); |
---|
[387] | 2227 | if ~isempty(errormsg) |
---|
[450] | 2228 | errormsg=['error in reading ' FieldName_1 ' in ' FileName_1 ': ' errormsg]; |
---|
[387] | 2229 | return |
---|
| 2230 | end |
---|
[515] | 2231 | if isstruct(ParamOut_1)&&~strcmp(ParamOut_1.FieldName,'get_field...')&& (strcmp(UvData.FileType{2},'civdata')||strcmp(UvData.FileType{2},'civx'))... |
---|
| 2232 | &&~strcmp(ParamOut_1.FieldName,'velocity') && ~strcmp(ParamOut_1.FieldName,'get_field...') |
---|
| 2233 | if ~check_proj_tps |
---|
| 2234 | % Field{2}=calc_field([{ParamOut_1.FieldName} {ParamOut_1.ColorVar}],Field{2}); |
---|
| 2235 | end |
---|
| 2236 | end |
---|
[387] | 2237 | end |
---|
[507] | 2238 | Field{2}.ZIndex=z_index;%used for multi-plane 3D calibration |
---|
[387] | 2239 | end |
---|
| 2240 | |
---|
| 2241 | %% update uvmat interface |
---|
| 2242 | if isfield(ParamOut,'Npx') |
---|
| 2243 | set(handles.num_Npx,'String',num2str(ParamOut.Npx));% display image size on the interface |
---|
| 2244 | set(handles.num_Npy,'String',num2str(ParamOut.Npy)); |
---|
| 2245 | elseif isfield(ParamOut_1,'Npx') |
---|
| 2246 | set(handles.num_Npx,'String',num2str(ParamOut_1.Npx));% display image size on the interface |
---|
| 2247 | set(handles.num_Npy,'String',num2str(ParamOut_1.Npy)); |
---|
| 2248 | end |
---|
| 2249 | |
---|
| 2250 | %% update the display menu for the first velocity type (first menuline) |
---|
| 2251 | test_veltype=0; |
---|
| 2252 | % if ~isequal(FileType,'netcdf')|| isequal(FieldName,'get_field...') |
---|
[404] | 2253 | if (strcmp(UvData.FileType{1},'civx')||strcmp(UvData.FileType{1},'civdata'))&& ~strcmp(FieldName,'get_field...') |
---|
[387] | 2254 | test_veltype=1; |
---|
| 2255 | set(handles.VelType,'Visible','on') |
---|
| 2256 | set(handles.VelType_1,'Visible','on') |
---|
| 2257 | set(handles.FixVelType,'Visible','on') |
---|
[404] | 2258 | menu=set_veltype_display(ParamOut.CivStage,UvData.FileType{1}); |
---|
[387] | 2259 | index_menu=strcmp(ParamOut.VelType,menu);%look for VelType in the menu |
---|
| 2260 | index_val=find(index_menu,1); |
---|
| 2261 | if isempty(index_val) |
---|
| 2262 | index_val=1; |
---|
| 2263 | end |
---|
| 2264 | set(handles.VelType,'Value',index_val) |
---|
| 2265 | if ~get(handles.SubField,'value') |
---|
| 2266 | set(handles.VelType,'String',menu) |
---|
| 2267 | set(handles.VelType_1,'Value',1) |
---|
| 2268 | set(handles.VelType_1,'String',[{''};menu]) |
---|
| 2269 | end |
---|
| 2270 | else |
---|
| 2271 | set(handles.VelType,'Visible','off') |
---|
| 2272 | end |
---|
[526] | 2273 | % display the FieldName menu from the input file and pick the selected one: |
---|
[517] | 2274 | % if isstruct(ParamOut) |
---|
| 2275 | % field_index=strcmp(ParamOut.FieldName,ParamOut.FieldList); |
---|
[526] | 2276 | % set(handles.FieldName,'String',ParamOut.FieldList); %update the field menu |
---|
| 2277 | % set(handles.FieldName,'Value',find(field_index,1)) |
---|
[517] | 2278 | % end |
---|
[387] | 2279 | |
---|
| 2280 | %% update the display menu for the second velocity type (second menuline) |
---|
| 2281 | test_veltype_1=0; |
---|
[450] | 2282 | if isempty(FileName_1) |
---|
[580] | 2283 | % set(handles.FieldName_1,'Value',1); %update the field menu |
---|
| 2284 | % if isstruct(ParamOut) |
---|
| 2285 | % set(handles.FieldName_1,'String',[{''};ParamOut.FieldList]); %update the field menu |
---|
| 2286 | % end |
---|
[405] | 2287 | elseif ~test_keepdata_1 |
---|
[404] | 2288 | if (~strcmp(UvData.FileType{2},'netcdf')&&~strcmp(UvData.FileType{2},'civdata')&&~strcmp(UvData.FileType{2},'civx'))|| isequal(FieldName_1,'get_field...') |
---|
[387] | 2289 | set(handles.VelType_1,'Visible','off') |
---|
[405] | 2290 | else |
---|
[387] | 2291 | test_veltype_1=1; |
---|
| 2292 | set(handles.VelType_1,'Visible','on') |
---|
[515] | 2293 | menu=set_veltype_display(ParamOut_1.CivStage,UvData.FileType{2}); |
---|
[494] | 2294 | index_menu=strcmp(ParamOut_1.VelType,menu); |
---|
| 2295 | set(handles.VelType_1,'Value',1+find(index_menu,1)) |
---|
| 2296 | set(handles.VelType_1,'String',[{''};menu]) |
---|
[387] | 2297 | end |
---|
[405] | 2298 | % update the second field menu: the same quantity |
---|
[494] | 2299 | if isstruct(ParamOut_1) |
---|
[580] | 2300 | % set(handles.FieldName_1,'String',[{''};ParamOut_1.FieldList]); %update the field menu |
---|
| 2301 | % display the FieldName menu from the input file and pick the selected one: |
---|
| 2302 | FieldList=get(handles.FieldName_1,'String'); |
---|
| 2303 | field_index=strcmp(ParamOut_1.FieldName,FieldList); |
---|
| 2304 | if ~isempty(field_index) |
---|
| 2305 | set(handles.FieldName_1,'Value',find(field_index,1)) |
---|
| 2306 | end |
---|
[494] | 2307 | end |
---|
[387] | 2308 | end |
---|
| 2309 | if test_veltype||test_veltype_1 |
---|
[580] | 2310 | set(handles.FixVelType,'Visible','on') |
---|
[387] | 2311 | else |
---|
[580] | 2312 | set(handles.FixVelType,'Visible','off') |
---|
[387] | 2313 | end |
---|
[405] | 2314 | |
---|
| 2315 | % field_index=strcmp(ParamOut_1.FieldName,ParamOut_1.FieldList); |
---|
[526] | 2316 | % set(handles.FieldName,'String',ParamOut.FieldList); %update the field menu |
---|
| 2317 | % set(handles.FieldName,'Value',find(field_index,1)) |
---|
[387] | 2318 | |
---|
| 2319 | %% introduce w as background image by default for a new series (only for nbdim=2) |
---|
| 2320 | if ~isfield(UvData,'NewSeries') |
---|
| 2321 | UvData.NewSeries=1; |
---|
| 2322 | end |
---|
| 2323 | %put W as background image by default if NbDim=2: |
---|
| 2324 | if UvData.NewSeries && isequal(get(handles.SubField,'Value'),0) && isfield(Field{1},'W') && ~isempty(Field{1}.W) && ~isequal(Field{1}.NbDim,3); |
---|
| 2325 | set(handles.SubField,'Value',1); |
---|
| 2326 | set(handles.RootPath_1,'String','"') |
---|
| 2327 | set(handles.RootFile_1,'String','"') |
---|
| 2328 | set(handles.SubDir_1,'String','"'); |
---|
| 2329 | indices=fullfile_uvmat('','','','',NomType,num_i1,num_i2,num_j1,num_j2); |
---|
| 2330 | set(handles.FileIndex_1,'String',indices) |
---|
| 2331 | set(handles.FileExt_1,'String','"'); |
---|
[526] | 2332 | set(handles.FieldName_1,'Visible','on'); |
---|
| 2333 | set(handles.FieldName_1,'Visible','on'); |
---|
[387] | 2334 | set(handles.RootPath_1,'Visible','on') |
---|
| 2335 | set(handles.RootFile_1,'Visible','on') |
---|
| 2336 | set(handles.SubDir_1,'Visible','on'); |
---|
| 2337 | set(handles.FileIndex_1,'Visible','on'); |
---|
| 2338 | set(handles.FileExt_1,'Visible','on'); |
---|
[526] | 2339 | set(handles.FieldName_1,'Visible','on'); |
---|
[387] | 2340 | Field{1}.AName='w'; |
---|
| 2341 | end |
---|
| 2342 | |
---|
[415] | 2343 | %% display time |
---|
| 2344 | testimedoc=0; |
---|
| 2345 | TimeUnit=''; |
---|
| 2346 | if isfield(Field{1},'Time') |
---|
| 2347 | abstime=Field{1}.Time;%time read from the netcdf input file |
---|
| 2348 | end |
---|
| 2349 | if numel(Field)==2 && isfield(Field{2},'Time') |
---|
| 2350 | abstime_1=Field{2}.Time;%time read from the netcdf input file |
---|
| 2351 | end |
---|
| 2352 | if isfield(Field{1},'Dt') |
---|
| 2353 | dt=Field{1}.Dt;%dt read from the netcdf input file |
---|
| 2354 | if isfield(Field{1},'TimeUnit') |
---|
| 2355 | TimeUnit=Field{1}.TimeUnit; |
---|
| 2356 | end |
---|
| 2357 | elseif numel(Field)==2 && isfield(Field{2},'Dt')%dt obtained from the second field if not defined in the first |
---|
| 2358 | dt=Field{2}.Dt;%dt read from the netcdf input file |
---|
| 2359 | if isfield(Field{2},'TimeUnit') |
---|
| 2360 | TimeUnit=Field{2}.TimeUnit; |
---|
| 2361 | end |
---|
| 2362 | end |
---|
| 2363 | % time from xml file overset previous result |
---|
| 2364 | if isfield(UvData,'XmlData') && isfield(UvData.XmlData{1},'Time') |
---|
| 2365 | if isempty(num_i2)||isnan(num_i2) |
---|
| 2366 | num_i2=num_i1; |
---|
| 2367 | end |
---|
| 2368 | if isempty(num_j1)||isnan(num_j1) |
---|
| 2369 | num_j1=1; |
---|
| 2370 | end |
---|
| 2371 | if isempty(num_j2)||isnan(num_j2) |
---|
| 2372 | num_j2=num_j1; |
---|
| 2373 | end |
---|
| 2374 | siz=size(UvData.XmlData{1}.Time); |
---|
[554] | 2375 | if ~isempty(num_i1)&& ~isempty(num_i2) && num_i1>0 &&siz(1)>=max(num_i1,num_i2) && siz(2)>=max(num_j1,num_j2) |
---|
[415] | 2376 | abstime=(UvData.XmlData{1}.Time(num_i1,num_j1)+UvData.XmlData{1}.Time(num_i2,num_j2))/2;%overset the time read from files |
---|
| 2377 | dt=(UvData.XmlData{1}.Time(num_i2,num_j2)-UvData.XmlData{1}.Time(num_i1,num_j1)); |
---|
| 2378 | Field{1}.Dt=dt; |
---|
| 2379 | if isfield(UvData.XmlData{1},'TimeUnit') |
---|
| 2380 | TimeUnit=UvData.XmlData{1}.TimeUnit; |
---|
| 2381 | end |
---|
| 2382 | end |
---|
| 2383 | if numel(UvData.XmlData)==2 |
---|
[515] | 2384 | if isempty(i2_1) |
---|
| 2385 | i2_1=num_i1; |
---|
[415] | 2386 | end |
---|
[515] | 2387 | if isempty(j1_1) |
---|
| 2388 | j1_1=1; |
---|
[415] | 2389 | end |
---|
[515] | 2390 | if isempty(j2_1) |
---|
| 2391 | j2_1=j1_1; |
---|
[415] | 2392 | end |
---|
| 2393 | siz=size(UvData.XmlData{2}.Time); |
---|
[515] | 2394 | if ~isempty(i1_1) && siz(1)>=max(i1_1,i2_1) && siz(2)>=max(j1_1,j2_1) |
---|
| 2395 | 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 |
---|
| 2396 | Field{2}.Dt=(UvData.XmlData{2}.Time(i2_1,j2_1)-UvData.XmlData{2}.Time(i1_1,j1_1)); |
---|
[415] | 2397 | end |
---|
| 2398 | end |
---|
| 2399 | end |
---|
| 2400 | if ~isequal(numel(abstime),1) |
---|
| 2401 | abstime=[]; |
---|
| 2402 | end |
---|
| 2403 | if ~isequal(numel(abstime_1),1) |
---|
| 2404 | abstime_1=[]; |
---|
| 2405 | end |
---|
[456] | 2406 | set(handles.abs_time,'String',num2str(abstime,5)) |
---|
| 2407 | set(handles.abs_time_1,'String',num2str(abstime_1,5)) |
---|
[415] | 2408 | if isempty(dt)||isequal(dt,0) |
---|
| 2409 | set(handles.Dt_txt,'String','') |
---|
| 2410 | else |
---|
| 2411 | if isempty(TimeUnit) |
---|
| 2412 | set(handles.Dt_txt,'String',['Dt=' num2str(1000*dt,3) ' 10^(-3)'] ) |
---|
| 2413 | else |
---|
| 2414 | set(handles.Dt_txt,'String',['Dt=' num2str(1000*dt,3) ' m' TimeUnit] ) |
---|
| 2415 | end |
---|
| 2416 | end |
---|
| 2417 | |
---|
| 2418 | |
---|
[526] | 2419 | %% store the current open names, fieldname and vel types in uvmat interface |
---|
[450] | 2420 | UvData.FileName_1=FileName_1; |
---|
[512] | 2421 | UvData.ParamOut_1=ParamOut_1; |
---|
| 2422 | if numel(Field)==2 |
---|
| 2423 | UvData.Field_1=Field{2}; %store the second field for possible use at next RUN |
---|
| 2424 | end |
---|
[387] | 2425 | |
---|
| 2426 | %% apply coordinate transform or other user fct |
---|
[591] | 2427 | transform=get(handles.TransformPath,'UserData'); |
---|
[515] | 2428 | if isempty(transform) |
---|
| 2429 | UvData.Field=Field{1}; |
---|
| 2430 | else |
---|
[507] | 2431 | XmlData=[];%default |
---|
| 2432 | XmlData_1=[];%default |
---|
| 2433 | if isfield(UvData,'XmlData')%use geometry calib recorded from the ImaDoc xml file as first priority |
---|
| 2434 | XmlData=UvData.XmlData{1}; |
---|
| 2435 | if numel(UvData.XmlData)==2 |
---|
| 2436 | XmlData_1=UvData.XmlData{2}; |
---|
| 2437 | end |
---|
[387] | 2438 | end |
---|
[591] | 2439 | transform=get(handles.TransformPath,'UserData'); |
---|
[512] | 2440 | switch nargin(transform) |
---|
| 2441 | case 4 |
---|
| 2442 | if length(Field)==2 |
---|
| 2443 | UvData.Field=transform(Field{1},XmlData,Field{2},XmlData_1); |
---|
| 2444 | else |
---|
| 2445 | UvData.Field=transform(Field{1},XmlData); |
---|
| 2446 | end |
---|
| 2447 | case 3 |
---|
| 2448 | if length(Field)==2 |
---|
| 2449 | UvData.Field=transform(Field{1},XmlData,Field{2}); |
---|
| 2450 | else |
---|
| 2451 | UvData.Field=transform(Field{1},XmlData); |
---|
| 2452 | end |
---|
| 2453 | case 2 |
---|
| 2454 | UvData.Field=transform(Field{1},XmlData); |
---|
| 2455 | case 1 |
---|
| 2456 | UvData.Field=transform(Field{1}); |
---|
[387] | 2457 | end |
---|
[507] | 2458 | end |
---|
[508] | 2459 | |
---|
[515] | 2460 | %% calculate tps coefficients if needed |
---|
[581] | 2461 | UvData.Field=tps_coeff_field(UvData.Field,check_proj_tps); |
---|
[387] | 2462 | |
---|
[434] | 2463 | %% analyse input field |
---|
[530] | 2464 | %test_x=0; |
---|
| 2465 | %test_z=0;% test for unstructured z coordinate |
---|
| 2466 | %[errormsg,ListDimName,DimValue,VarDimIndex]=check_field_structure(UvData.Field);% check the input field structure |
---|
| 2467 | % if ~isempty(errormsg) |
---|
| 2468 | % errormsg=['error in uvmat/refresh_field/check_field_structure: ' errormsg];% display error |
---|
| 2469 | % return |
---|
| 2470 | % end |
---|
| 2471 | [CellInfo,NbDimArray,errormsg]=find_field_cells(UvData.Field);% analyse the input field structure |
---|
[387] | 2472 | if ~isempty(errormsg) |
---|
[527] | 2473 | errormsg=['uvmat /refresh_field / find_field_cells / ' errormsg];% display error |
---|
[387] | 2474 | return |
---|
| 2475 | end |
---|
[530] | 2476 | |
---|
| 2477 | NbDim=max(NbDimArray);% spatial dimension of the input field |
---|
| 2478 | imax=find(NbDimArray==NbDim);% indices of field cells to consider |
---|
[387] | 2479 | if isfield(UvData.Field,'NbDim') |
---|
[530] | 2480 | NbDim=double(UvData.Field.NbDim);% deal with plane fields containing z coordinates |
---|
[387] | 2481 | end |
---|
[434] | 2482 | |
---|
[576] | 2483 | %UvData.Field=get_bounds(UvData.Field); |
---|
[530] | 2484 | |
---|
[527] | 2485 | %% get bounds and mesh (needed to propose default options for projection objects) |
---|
[435] | 2486 | if NbDim>1 |
---|
[535] | 2487 | CoordMax=zeros(numel(imax),NbDim); |
---|
| 2488 | CoordMin=zeros(numel(imax),NbDim); |
---|
[564] | 2489 | Mesh=zeros(1,numel(imax)); |
---|
[530] | 2490 | for ind=1:numel(imax) |
---|
[564] | 2491 | if strcmp(CellInfo{imax(ind)}.CoordType,'tps') |
---|
| 2492 | CoordName=UvData.Field.ListVarName{CellInfo{imax(ind)}.CoordIndex};% X,Y coordinates in a single variable |
---|
[579] | 2493 | CoordMax(ind,NbDim)=max(max(UvData.Field.(CoordName)(1:end-3,1,:),[],1),[],3);% max of x component (2D case) |
---|
| 2494 | CoordMax(ind,NbDim-1)=max(max(UvData.Field.(CoordName)(1:end-3,2,:),[],1),[],3);% max of y component (2D case) |
---|
| 2495 | CoordMin(ind,NbDim)=min(min(UvData.Field.(CoordName)(1:end-3,1,:),[],1),[],3); |
---|
| 2496 | CoordMin(ind,NbDim-1)=min(min(UvData.Field.(CoordName)(1:end-3,2,:),[],1),[],3);% min of y component (2D case) |
---|
[564] | 2497 | else |
---|
| 2498 | XName=UvData.Field.ListVarName{CellInfo{imax(ind)}.CoordIndex(end)}; |
---|
| 2499 | YName=UvData.Field.ListVarName{CellInfo{imax(ind)}.CoordIndex(end-1)}; |
---|
| 2500 | CoordMax(ind,NbDim)=max(max(UvData.Field.(XName))); |
---|
| 2501 | CoordMin(ind,NbDim)=min(min(UvData.Field.(XName))); |
---|
| 2502 | CoordMax(ind,NbDim-1)=max(max(UvData.Field.(YName))); |
---|
| 2503 | CoordMin(ind,NbDim-1)=min(min(UvData.Field.(YName))); |
---|
| 2504 | % test_x=1;%test for unstructured coordinates |
---|
| 2505 | if NbDim==3 |
---|
| 2506 | ZName=UvData.Field.ListVarName{CellInfo{imax(ind)}.CoordIndex(1)}; |
---|
| 2507 | CoordMax(imax(ind),1)=max(max(UvData.Field.(ZName))); |
---|
| 2508 | CoordMin(ind,1)=min(min(UvData.Field.(ZName))); |
---|
| 2509 | end |
---|
[434] | 2510 | end |
---|
[530] | 2511 | switch CellInfo{imax(ind)}.CoordType |
---|
| 2512 | |
---|
[564] | 2513 | case {'scattered','tps'} %unstructured coordinates |
---|
| 2514 | NbPoints=CellInfo{imax(ind)}.CoordSize;% total nbre of points |
---|
| 2515 | Mesh(ind)=(prod(CoordMax(ind,:)-CoordMin(ind,:))/NbPoints)^(1/NbDim); %(volume or area per point)^(1/NbDim) |
---|
[530] | 2516 | case 'grid'%structured coordinate |
---|
[535] | 2517 | NbPoints=CellInfo{imax(ind)}.CoordSize;% nbre of points in each direction |
---|
[564] | 2518 | Mesh(ind)=min((CoordMax(ind,:)-CoordMin(ind,:))./(NbPoints-1)); |
---|
[435] | 2519 | end |
---|
[387] | 2520 | end |
---|
[575] | 2521 | UvData.Field.CoordMesh=min(Mesh); |
---|
[546] | 2522 | UvData.Field.XMax=max(CoordMax(ind,end)); |
---|
| 2523 | UvData.Field.XMin=min(CoordMin(ind,end)); |
---|
| 2524 | UvData.Field.YMax=max(CoordMax(ind,end-1)); |
---|
| 2525 | UvData.Field.YMin=max(CoordMin(ind,end-1)); |
---|
[435] | 2526 | if NbDim==3 |
---|
[546] | 2527 | UvData.Field.ZMax=max(CoordMax(ind,1)); |
---|
| 2528 | UvData.Field.ZMin=max(CoordMin(ind,1)); |
---|
[387] | 2529 | end |
---|
[435] | 2530 | % adjust the mesh to a value 1, 2 , 5 *10^n |
---|
[575] | 2531 | ord=10^(floor(log10(UvData.Field.CoordMesh)));%order of magnitude |
---|
| 2532 | if UvData.Field.CoordMesh/ord>=5 |
---|
| 2533 | UvData.Field.CoordMesh=5*ord; |
---|
| 2534 | elseif UvData.Field.CoordMesh/ord>=2 |
---|
| 2535 | UvData.Field.CoordMesh=2*ord; |
---|
[404] | 2536 | else |
---|
[575] | 2537 | UvData.Field.CoordMesh=ord; |
---|
[404] | 2538 | end |
---|
[491] | 2539 | % default projection plane |
---|
[511] | 2540 | if isempty(UvData.Object{1}) |
---|
[491] | 2541 | UvData.Object{1}.Type='plane';%main plotting plane |
---|
| 2542 | UvData.Object{1}.ProjMode='projection';%main plotting plane |
---|
| 2543 | UvData.Object{1}.DisplayHandle.uvmat=[]; %plane not visible in uvmat |
---|
| 2544 | UvData.Object{1}.DisplayHandle.view_field=[]; %plane not visible in uvmat |
---|
| 2545 | end |
---|
[435] | 2546 | %% 3D case (menuvolume) |
---|
| 2547 | if NbDim==3% && UvData.NewSeries |
---|
| 2548 | test_set_object=1; |
---|
| 2549 | hset_object=findobj(allchild(0),'tag','set_object');% look for the set_object GUI |
---|
| 2550 | ZBounds(1)=UvData.Field.ZMin; %minimum for the Z slider |
---|
| 2551 | ZBounds(2)=UvData.Field.ZMax;%maximum for the Z slider |
---|
| 2552 | if ~isempty(hset_object) %if set_object is detected |
---|
| 2553 | delete(hset_object);% delete the GUI set_object if it does not fit |
---|
[387] | 2554 | end |
---|
[435] | 2555 | if test_set_object% reinitiate the GUI set_object |
---|
| 2556 | 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 |
---|
| 2557 | UvData.Object{1}.NbDim=NbDim;%test for 3D objects |
---|
[575] | 2558 | UvData.Object{1}.RangeZ=UvData.Field.CoordMesh;%main plotting plane |
---|
[435] | 2559 | UvData.Object{1}.Coord(1,3)=(UvData.Field.ZMin+UvData.Field.ZMax)/2;%section at a middle plane chosen |
---|
| 2560 | UvData.Object{1}.Angle=[0 0 0]; |
---|
| 2561 | UvData.Object{1}.HandlesDisplay=plot(0,0,'Tag','proj_object');% A REVOIR |
---|
| 2562 | UvData.Object{1}.Name='1-PLANE'; |
---|
| 2563 | UvData.Object{1}.enable_plot=1; |
---|
| 2564 | set_object(UvData.Object{1},handles,ZBounds); |
---|
| 2565 | set(handles.ListObject,'Value',1); |
---|
| 2566 | set(handles.ListObject,'String',{'1-PLANE'}); |
---|
| 2567 | set(handles.edit_object,'Value',1)% put the plane in edit mode to enable the z cursor |
---|
| 2568 | edit_object_Callback([],[], handles) |
---|
[387] | 2569 | end |
---|
[435] | 2570 | %multilevel case (single menuplane in a 3D space) |
---|
| 2571 | elseif isfield(UvData,'Z') |
---|
| 2572 | if isfield(UvData,'CoordType')&& isequal(UvData.CoordType,'phys') && isfield(UvData,'XmlData') |
---|
| 2573 | XmlData=UvData.XmlData{1}; |
---|
| 2574 | if isfield(XmlData,'PlanePos') |
---|
| 2575 | UvData.Object{1}.Coord=XmlData.PlanePos(UvData.ZIndex,:); |
---|
| 2576 | end |
---|
| 2577 | if isfield(XmlData,'PlaneAngle') |
---|
| 2578 | siz=size(XmlData.PlaneAngle); |
---|
| 2579 | indangle=min(siz(1),UvData.ZIndex);%take first angle if a single angle is defined (translating scanning) |
---|
| 2580 | UvData.Object{1}.PlaneAngle=XmlData.PlaneAngle(indangle,:); |
---|
| 2581 | end |
---|
| 2582 | elseif isfield(UvData,'ZIndex') |
---|
| 2583 | UvData.Object{1}.ZObject=UvData.ZIndex; |
---|
| 2584 | end |
---|
[387] | 2585 | end |
---|
| 2586 | end |
---|
[435] | 2587 | |
---|
[387] | 2588 | testnewseries=UvData.NewSeries; |
---|
| 2589 | UvData.NewSeries=0;% put to 0 the test for a new field series (set by RootPath_callback) |
---|
| 2590 | set(handles.uvmat,'UserData',UvData) |
---|
| 2591 | |
---|
| 2592 | %% reset the min and max of scalar if only the mask is displayed(TODO: check the need) |
---|
[405] | 2593 | % if isfield(UvData,'Mask')&& ~isfield(UvData,'A') |
---|
| 2594 | % set(handles.num_MinA,'String','0') |
---|
| 2595 | % set(handles.num_MaxA,'String','255') |
---|
| 2596 | % end |
---|
[387] | 2597 | |
---|
[434] | 2598 | %% usual 1D (x,y) plots |
---|
| 2599 | if NbDim<=1 |
---|
| 2600 | set(handles.Objects,'Visible','off') |
---|
| 2601 | set(handles.ListObject_1_title,'Visible','off') |
---|
| 2602 | set(handles.ListObject_1,'Visible','off') |
---|
[511] | 2603 | [PlotType,PlotParamOut]=plot_field(UvData.Field,handles.PlotAxes,read_GUI(handles.uvmat)); |
---|
[598] | 2604 | errormsg=fill_GUI(PlotParamOut,handles.uvmat); |
---|
| 2605 | for list={'Scalar','Vectors'} |
---|
| 2606 | if ~isfield(PlotParamOut,list{1}) |
---|
| 2607 | set(handles.(list{1}),'Visible','off') |
---|
| 2608 | end |
---|
| 2609 | end |
---|
| 2610 | %write_plot_param(handles,PlotParamOut) %update the auto plot parameters |
---|
[434] | 2611 | |
---|
[526] | 2612 | %% 2D or 3D fieldname are generally projected |
---|
[387] | 2613 | else |
---|
[434] | 2614 | set(handles.Objects,'Visible','on') |
---|
| 2615 | set(handles.ListObject_1_title,'Visible','on') |
---|
| 2616 | set(handles.ListObject_1,'Visible','on') |
---|
| 2617 | |
---|
| 2618 | %% Plot the projections on the selected projection objects |
---|
| 2619 | % main projection object (uvmat display) |
---|
| 2620 | list_object=get(handles.ListObject_1,'String'); |
---|
[535] | 2621 | if isequal(list_object,{''})||isequal(list_object,' ')%refresh list of objects if the menu is empty |
---|
[508] | 2622 | set(handles.ListObject,'Value',1) |
---|
| 2623 | set(handles.ListObject,'String',{'plane'}) |
---|
| 2624 | UvData.Object{1}.Type='plane';%main plotting plane |
---|
| 2625 | UvData.Object{1}.ProjMode='projection';%main plotting plane |
---|
| 2626 | UvData.Object{1}.DisplayHandle.uvmat=[]; %plane not visible in uvmat |
---|
| 2627 | UvData.Object{1}.DisplayHandle.view_field=[]; %plane not visible in uvmat |
---|
[434] | 2628 | set(handles.ListObject_1,'Value',1) |
---|
[508] | 2629 | set(handles.ListObject_1,'String',{'plane'}) |
---|
[387] | 2630 | end |
---|
[434] | 2631 | IndexObj(1)=get(handles.ListObject_1,'Value');%selected projection object for main view |
---|
| 2632 | if IndexObj(1)> numel(UvData.Object) |
---|
| 2633 | IndexObj(1)=1;%select the first object if the selected one does not exist |
---|
| 2634 | set(handles.ListObject_1,'Value',1) |
---|
[387] | 2635 | end |
---|
[434] | 2636 | IndexObj(2)=get(handles.ListObject,'Value');%selected projection object for main view |
---|
| 2637 | if isequal(IndexObj(2),IndexObj(1)) |
---|
| 2638 | IndexObj(2)=[]; |
---|
| 2639 | end |
---|
| 2640 | plot_handles{1}=handles; |
---|
| 2641 | if isfield(UvData,'plotaxes')%case of movies |
---|
| 2642 | haxes(1)=UvData.plotaxes; |
---|
| 2643 | else |
---|
[511] | 2644 | haxes(1)=handles.PlotAxes; |
---|
[434] | 2645 | end |
---|
| 2646 | PlotParam{1}=read_GUI(handles.uvmat); |
---|
| 2647 | %default settings if vectors not visible |
---|
| 2648 | if ~isfield(PlotParam{1},'Vectors') |
---|
| 2649 | PlotParam{1}.Vectors.MaxVec=1; |
---|
| 2650 | PlotParam{1}.Vectors.MinVec=0; |
---|
| 2651 | PlotParam{1}.Vectors.CheckFixVecColor=1; |
---|
| 2652 | PlotParam{1}.Vectors.ColCode1=0.33; |
---|
| 2653 | PlotParam{1}.Vectors.ColCode2=0.66; |
---|
[517] | 2654 | PlotParam{1}.Vectors.ColorScalar={''}; |
---|
[434] | 2655 | PlotParam{1}.Vectors.ColorCode= {'rgb'}; |
---|
| 2656 | end |
---|
| 2657 | PosColorbar{1}=UvData.OpenParam.PosColorbar;%prescribe the colorbar position on the uvmat interface |
---|
| 2658 | |
---|
| 2659 | %% second projection object (view_field display) |
---|
| 2660 | if length( IndexObj)>=2 |
---|
| 2661 | view_field_handle=findobj(allchild(0),'tag','view_field');%handles of the view_field GUI |
---|
| 2662 | if ~isempty(view_field_handle) |
---|
| 2663 | plot_handles{2}=guidata(view_field_handle); |
---|
[511] | 2664 | haxes(2)=plot_handles{2}.PlotAxes; |
---|
[599] | 2665 | PlotParam{2}=read_GUI(view_field_handle); |
---|
| 2666 | % PlotParam{2}=read_GUI(handles.uvmat);%read plotting parameters on the uvmat interface |
---|
[434] | 2667 | PosColorbar{2}='*'; %TODO: deal with colorbar position on view_field |
---|
[421] | 2668 | end |
---|
[387] | 2669 | end |
---|
[434] | 2670 | |
---|
| 2671 | %% loop on the projection objects: one or two |
---|
| 2672 | |
---|
| 2673 | for imap=1:numel(IndexObj) |
---|
| 2674 | iobj=IndexObj(imap); |
---|
| 2675 | [ObjectData,errormsg]=proj_field(UvData.Field,UvData.Object{iobj});% project field on the object |
---|
| 2676 | if ~isempty(errormsg) |
---|
| 2677 | return |
---|
[387] | 2678 | end |
---|
[434] | 2679 | if testnewseries |
---|
| 2680 | PlotParam{imap}.Scalar.CheckBW=[]; %B/W option depends on the input field (image or scalar) |
---|
| 2681 | if isfield(ObjectData,'CoordUnit') |
---|
| 2682 | PlotParam{imap}.Coordinates.CheckFixAspectRatio=1;% set x and y scaling equal if CoordUnit is defined (common unit for x and y) |
---|
| 2683 | PlotParam{imap}.Coordinates.AspectRatio=1; %set aspect ratio to 1 |
---|
[387] | 2684 | end |
---|
[434] | 2685 | end |
---|
| 2686 | %use of mask (TODO: check) |
---|
| 2687 | if isfield(ObjectData,'NbDim') && isequal(ObjectData.NbDim,2) && isfield(ObjectData,'Mask') && isfield(ObjectData,'A') |
---|
| 2688 | flag_mask=double(ObjectData.Mask>200);%=0 for masked regions |
---|
| 2689 | AX=ObjectData.AX;%x coordiantes for the scalar field |
---|
| 2690 | AY=ObjectData.AY;%y coordinates for the scalar field |
---|
| 2691 | MaskX=ObjectData.MaskX;%x coordiantes for the mask |
---|
| 2692 | MaskY=ObjectData.MaskY;%y coordiantes for the mask |
---|
| 2693 | if ~isequal(MaskX,AX)||~isequal(MaskY,AY) |
---|
| 2694 | nxy=size(flag_mask); |
---|
| 2695 | sizpx=(ObjectData.MaskX(end)-ObjectData.MaskX(1))/(nxy(2)-1);%size of a mask pixel |
---|
| 2696 | sizpy=(ObjectData.MaskY(1)-ObjectData.MaskY(end))/(nxy(1)-1); |
---|
| 2697 | x_mask=ObjectData.MaskX(1):sizpx:ObjectData.MaskX(end); % pixel x coordinates for image display |
---|
| 2698 | y_mask=ObjectData.MaskY(1):-sizpy:ObjectData.MaskY(end);% pixel x coordinates for image display |
---|
| 2699 | %project on the positions of the scalar |
---|
| 2700 | npxy=size(ObjectData.A); |
---|
| 2701 | dxy(1)=(ObjectData.AY(end)-ObjectData.AY(1))/(npxy(1)-1);%grid mesh in y |
---|
| 2702 | dxy(2)=(ObjectData.AX(end)-ObjectData.AX(1))/(npxy(2)-1);%grid mesh in x |
---|
| 2703 | xi=ObjectData.AX(1):dxy(2):ObjectData.AX(end); |
---|
| 2704 | yi=ObjectData.AY(1):dxy(1):ObjectData.AY(end); |
---|
| 2705 | [XI,YI]=meshgrid(xi,yi);% creates the matrix of regular coordinates |
---|
| 2706 | flag_mask = interp2(x_mask,y_mask,flag_mask,XI,YI); |
---|
| 2707 | end |
---|
| 2708 | AClass=class(ObjectData.A); |
---|
| 2709 | ObjectData.A=flag_mask.*double(ObjectData.A); |
---|
| 2710 | ObjectData.A=feval(AClass,ObjectData.A); |
---|
[387] | 2711 | end |
---|
[434] | 2712 | if ~isempty(ObjectData) |
---|
[569] | 2713 | %PlotType='none'; %default |
---|
[434] | 2714 | if imap==2 && isempty(view_field_handle) |
---|
| 2715 | view_field(ObjectData) |
---|
| 2716 | else |
---|
| 2717 | [PlotType,PlotParamOut]=plot_field(ObjectData,haxes(imap),PlotParam{imap},PosColorbar{imap}); |
---|
[595] | 2718 | if imap==1 |
---|
[598] | 2719 | errormsg=fill_GUI(PlotParamOut,handles.uvmat); |
---|
[595] | 2720 | else |
---|
[596] | 2721 | errormsg=fill_GUI(PlotParamOut,view_field_handle); |
---|
[595] | 2722 | end |
---|
[598] | 2723 | for list={'Scalar','Vectors'} |
---|
| 2724 | if ~isfield(PlotParamOut,list{1}) |
---|
| 2725 | set(plot_handles{imap}.(list{1}),'Visible','off') |
---|
| 2726 | end |
---|
| 2727 | end |
---|
[575] | 2728 | if isfield(Field,'CoordMesh')&&~isempty(Field.CoordMesh) |
---|
| 2729 | ObjectData.CoordMesh=Field.CoordMesh; % gives an estimated mesh size (useful for mouse action on the plot) |
---|
[434] | 2730 | end |
---|
[387] | 2731 | end |
---|
| 2732 | end |
---|
| 2733 | end |
---|
[434] | 2734 | |
---|
| 2735 | %% update the mask |
---|
| 2736 | if isequal(get(handles.CheckMask,'Value'),1)%if the mask option is on |
---|
| 2737 | update_mask(handles,num_i1,num_i2); |
---|
| 2738 | end |
---|
| 2739 | |
---|
| 2740 | %% prepare the menus of histograms and plot them (histogram of the whole volume in 3D case) |
---|
| 2741 | menu_histo=(UvData.Field.ListVarName)';%list of field variables to be displayed for the menu of histogram display |
---|
| 2742 | ind_skip=[]; |
---|
| 2743 | % nb_histo=1; |
---|
| 2744 | Ustring=''; |
---|
| 2745 | Vstring=''; |
---|
| 2746 | % suppress coordinates from the histogram menu |
---|
| 2747 | for ivar=1:numel(menu_histo)%l loop on field variables: |
---|
| 2748 | if isfield(UvData.Field,'VarAttribute') && numel(UvData.Field.VarAttribute)>=ivar && isfield(UvData.Field.VarAttribute{ivar},'Role') |
---|
| 2749 | Role=UvData.Field.VarAttribute{ivar}.Role; |
---|
| 2750 | switch Role |
---|
| 2751 | case {'coord_x','coord_y','coord_z','dimvar'} |
---|
| 2752 | ind_skip=[ind_skip ivar]; |
---|
| 2753 | case {'vector_x'} |
---|
| 2754 | Ustring=UvData.Field.ListVarName{ivar}; |
---|
| 2755 | ind_skip=[ind_skip ivar]; |
---|
| 2756 | case {'vector_y'} |
---|
| 2757 | Vstring=UvData.Field.ListVarName{ivar}; |
---|
| 2758 | ind_skip=[ind_skip ivar]; |
---|
| 2759 | end |
---|
[387] | 2760 | end |
---|
[434] | 2761 | DimCell=UvData.Field.VarDimName{ivar}; |
---|
| 2762 | DimName=''; |
---|
| 2763 | if ischar(DimCell) |
---|
| 2764 | DimName=DimCell; |
---|
| 2765 | elseif iscell(DimCell)&& numel(DimCell)==1 |
---|
| 2766 | DimName=DimCell{1}; |
---|
| 2767 | end |
---|
| 2768 | if strcmp(DimName,menu_histo{ivar}) |
---|
| 2769 | ind_skip=[ind_skip ivar]; |
---|
| 2770 | end |
---|
[387] | 2771 | end |
---|
[434] | 2772 | menu_histo(ind_skip)=[];% remove skipped items |
---|
| 2773 | if ~isempty(Ustring) |
---|
| 2774 | menu_histo=[{[Ustring ',' Vstring]};menu_histo];% add U, V at the beginning if they exist |
---|
[387] | 2775 | end |
---|
[434] | 2776 | |
---|
| 2777 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
---|
| 2778 | % display menus and plot histograms |
---|
| 2779 | test_v=0; |
---|
| 2780 | if ~isempty(menu_histo) |
---|
| 2781 | set(handles.histo1_menu,'Value',1) |
---|
| 2782 | set(handles.histo1_menu,'String',menu_histo) |
---|
| 2783 | histo1_menu_Callback(handles.histo1_menu, [], handles)% plot first histogram |
---|
[387] | 2784 | end |
---|
| 2785 | end |
---|
| 2786 | |
---|
[424] | 2787 | %------------------------------------------------------------------------ |
---|
| 2788 | function histo1_menu_Callback(hObject, eventdata, handles) |
---|
| 2789 | %-------------------------------------------- |
---|
| 2790 | histo_menu=get(handles.histo1_menu,'String'); |
---|
| 2791 | histo_value=get(handles.histo1_menu,'Value'); |
---|
| 2792 | FieldName=histo_menu{histo_value}; |
---|
[530] | 2793 | |
---|
[424] | 2794 | UvData=get(handles.uvmat,'UserData'); |
---|
| 2795 | Field=UvData.Field; |
---|
| 2796 | r=regexp(FieldName,'(?<var1>.*)(?<sep>,)(?<var2>.*)','names'); |
---|
| 2797 | FieldName_2=''; |
---|
| 2798 | if ~isempty(r) |
---|
| 2799 | FieldName=r.var1; |
---|
| 2800 | FieldName_2=r.var2; |
---|
| 2801 | end |
---|
| 2802 | if ~isfield(UvData.Field,FieldName) |
---|
| 2803 | msgbox_uvmat('ERROR',['no field ' FieldName ' for histogram']) |
---|
| 2804 | return |
---|
| 2805 | end |
---|
| 2806 | FieldHisto=Field.(FieldName); |
---|
| 2807 | if isfield(Field,'FF') && ~isempty(Field.FF) && isequal(size(Field.FF),size(FieldHisto)) |
---|
| 2808 | indsel=find(Field.FF==0);%find values marked as false |
---|
| 2809 | if ~isempty(indsel) |
---|
| 2810 | FieldHisto=FieldHisto(indsel); |
---|
| 2811 | if ~isempty(FieldName_2) |
---|
| 2812 | FieldHisto(:,:,2)=Field.(FieldName_2)(indsel); |
---|
| 2813 | end |
---|
[387] | 2814 | end |
---|
| 2815 | end |
---|
[424] | 2816 | if isempty(Field) |
---|
| 2817 | msgbox_uvmat('ERROR',['empty field ' FieldName]) |
---|
| 2818 | else |
---|
| 2819 | nxy=size(FieldHisto); |
---|
| 2820 | Amin=double(min(min(min(FieldHisto))));%min of field value |
---|
| 2821 | Amax=double(max(max(max(FieldHisto))));%max of field value |
---|
| 2822 | if isequal(Amin,Amax) |
---|
[511] | 2823 | cla(handles.HistoAxes) |
---|
[424] | 2824 | else |
---|
| 2825 | Histo.ListVarName={FieldName,'histo'}; |
---|
| 2826 | if isfield(Field,'NbDim') && isequal(Field.NbDim,3) |
---|
| 2827 | Histo.VarDimName={FieldName,FieldName}; %dimensions for the histogram |
---|
| 2828 | else |
---|
| 2829 | if numel(nxy)==2 |
---|
| 2830 | Histo.VarDimName={FieldName,FieldName}; %dimensions for the histogram |
---|
| 2831 | else |
---|
| 2832 | Histo.VarDimName={FieldName,{FieldName,'component'}}; %dimensions for the histogram |
---|
| 2833 | end |
---|
| 2834 | end |
---|
| 2835 | %unit |
---|
| 2836 | units=[]; %default |
---|
| 2837 | for ivar=1:numel(Field.ListVarName) |
---|
| 2838 | if strcmp(Field.ListVarName{ivar},FieldName) |
---|
| 2839 | if isfield(Field,'VarAttribute') && numel(Field.VarAttribute)>=ivar && isfield(Field.VarAttribute{ivar},'units') |
---|
| 2840 | units=Field.VarAttribute{ivar}.units; |
---|
| 2841 | break |
---|
| 2842 | end |
---|
| 2843 | end |
---|
| 2844 | end |
---|
| 2845 | if ~isempty(units) |
---|
| 2846 | Histo.VarAttribute{1}.units=units; |
---|
| 2847 | end |
---|
| 2848 | eval(['Histo.' FieldName '=linspace(Amin,Amax,50);'])%absissa values for histo |
---|
| 2849 | if isfield(Field,'NbDim') && isequal(Field.NbDim,3) |
---|
| 2850 | C=reshape(double(FieldHisto),1,[]);% reshape in a vector |
---|
| 2851 | Histo.histo(:,1)=hist(C, Histo.(FieldName)); %calculate histogram |
---|
| 2852 | else |
---|
| 2853 | for col=1:size(FieldHisto,3) |
---|
| 2854 | B=FieldHisto(:,:,col); |
---|
| 2855 | C=reshape(double(B),1,nxy(1)*nxy(2));% reshape in a vector |
---|
| 2856 | Histo.histo(:,col)=hist(C, Histo.(FieldName)); %calculate histogram |
---|
| 2857 | end |
---|
| 2858 | end |
---|
[511] | 2859 | plot_field(Histo,handles.HistoAxes); |
---|
[426] | 2860 | hlegend=legend; |
---|
| 2861 | if isempty(FieldName_2) |
---|
| 2862 | set(hlegend,'String',FieldName) |
---|
| 2863 | else |
---|
| 2864 | set(hlegend,'String',{FieldName;FieldName_2}) |
---|
| 2865 | end |
---|
[424] | 2866 | end |
---|
[387] | 2867 | end |
---|
| 2868 | |
---|
| 2869 | %------------------------------------------------------------------- |
---|
| 2870 | % --- translate coordinate to matrix index |
---|
| 2871 | %------------------------------------------------------------------- |
---|
| 2872 | function [indx,indy]=pos2ind(x0,rangx0,nxy) |
---|
| 2873 | indx=1+round((nxy(2)-1)*(x0-rangx0(1))/(rangx0(2)-rangx0(1)));% index x of pixel |
---|
| 2874 | indy=1+round((nxy(1)-1)*(y12-rangy0(1))/(rangy0(2)-rangy0(1)));% index y of pixel |
---|
| 2875 | |
---|
[428] | 2876 | |
---|
[387] | 2877 | %------------------------------------------------------------------- |
---|
[428] | 2878 | % --- Executes on button press in 'CheckZoom'. |
---|
| 2879 | %------------------------------------------------------------------- |
---|
| 2880 | function CheckZoom_Callback(hObject, eventdata, handles) |
---|
| 2881 | |
---|
| 2882 | if (get(handles.CheckZoom,'Value') == 1); |
---|
| 2883 | set(handles.CheckZoom,'BackgroundColor',[1 1 0]) |
---|
| 2884 | set(handles.CheckFixLimits,'Value',1)% propose by default fixed limits for the plotting axes |
---|
| 2885 | set(handles.CheckFixLimits,'BackgroundColor',[1 1 0]) |
---|
| 2886 | else |
---|
| 2887 | set(handles.CheckZoom,'BackgroundColor',[0.7 0.7 0.7]) |
---|
| 2888 | end |
---|
| 2889 | |
---|
| 2890 | %------------------------------------------------------------------- |
---|
[387] | 2891 | % --- Executes on button press in 'CheckFixLimits'. |
---|
| 2892 | %------------------------------------------------------------------- |
---|
| 2893 | function CheckFixLimits_Callback(hObject, eventdata, handles) |
---|
| 2894 | test=get(handles.CheckFixLimits,'Value'); |
---|
| 2895 | if test |
---|
| 2896 | set(handles.CheckFixLimits,'BackgroundColor',[1 1 0]) |
---|
| 2897 | else |
---|
| 2898 | set(handles.CheckFixLimits,'BackgroundColor',[0.7 0.7 0.7]) |
---|
| 2899 | update_plot(handles); |
---|
| 2900 | end |
---|
| 2901 | |
---|
| 2902 | %------------------------------------------------------------------- |
---|
[428] | 2903 | % --- Executes on button press in CheckFixAspectRatio. |
---|
| 2904 | function CheckFixAspectRatio_Callback(hObject, eventdata, handles) |
---|
| 2905 | %------------------------------------------------------------------- |
---|
| 2906 | if get(handles.CheckFixAspectRatio,'Value') |
---|
[589] | 2907 | % set(handles.CheckFixAspectRatio,'BackgroundColor',[1 1 0]) |
---|
[387] | 2908 | update_plot(handles); |
---|
| 2909 | else |
---|
[589] | 2910 | % set(handles.CheckFixAspectRatio,'BackgroundColor',[0.7 0.7 0.7]) |
---|
[387] | 2911 | update_plot(handles); |
---|
| 2912 | end |
---|
| 2913 | |
---|
| 2914 | %------------------------------------------------------------------- |
---|
[428] | 2915 | function num_AspectRatio_Callback(hObject, eventdata, handles) |
---|
[387] | 2916 | %------------------------------------------------------------------- |
---|
[428] | 2917 | set(handles.CheckFixAspectRatio,'Value',1)% select the fixed aspect ratio button |
---|
[589] | 2918 | % set(handles.CheckFixAspectRatio,'BackgroundColor',[1 1 0])% mark in yellow |
---|
[428] | 2919 | update_plot(handles); |
---|
[387] | 2920 | %------------------------------------------------------------------- |
---|
| 2921 | |
---|
[428] | 2922 | %------------------------------------------------------------------- |
---|
[387] | 2923 | |
---|
[428] | 2924 | |
---|
| 2925 | |
---|
[387] | 2926 | %------------------------------------------------------------------- |
---|
| 2927 | %----Executes on button press in 'record': records the current flags of manual correction. |
---|
| 2928 | %------------------------------------------------------------------- |
---|
| 2929 | function record_Callback(hObject, eventdata, handles) |
---|
| 2930 | % [filebase,num_i1,num_j1,num_i2,num_j2,Ext,NomType,SubDir]=read_input_file(handles); |
---|
| 2931 | [RootPath,SubDir,RootFile,FileIndices,FileExt]=read_file_boxes(handles); |
---|
[450] | 2932 | FileName=[fullfile(RootPath,SubDir,RootFile) FileIndices FileExt]; |
---|
| 2933 | %FileName=read_file_boxes(handles); |
---|
| 2934 | [erread,message]=fileattrib(FileName); |
---|
[387] | 2935 | if ~isempty(message) && ~isequal(message.UserWrite,1) |
---|
[450] | 2936 | msgbox_uvmat('ERROR',['no writting access to ' FileName]) |
---|
[387] | 2937 | return |
---|
| 2938 | end |
---|
| 2939 | test_civ2=isequal(get(handles.civ2,'BackgroundColor'),[1 1 0]); |
---|
| 2940 | test_civ1=isequal(get(handles.VelType,'BackgroundColor'),[1 1 0]); |
---|
| 2941 | if ~test_civ2 && ~test_civ1 |
---|
| 2942 | msgbox_uvmat('ERROR','manual correction only possible for CIV1 or CIV2 velocity fields') |
---|
| 2943 | end |
---|
| 2944 | if test_civ2 |
---|
| 2945 | nbname='nb_vectors2'; |
---|
| 2946 | flagname='vec2_FixFlag'; |
---|
| 2947 | attrname='fix2'; |
---|
| 2948 | end |
---|
| 2949 | if test_civ1 |
---|
| 2950 | nbname='nb_vectors'; |
---|
| 2951 | flagname='vec_FixFlag'; |
---|
| 2952 | attrname='fix'; |
---|
| 2953 | end |
---|
| 2954 | %write fix flags in the netcdf file |
---|
| 2955 | UvData=get(handles.uvmat,'UserData'); |
---|
| 2956 | hhh=which('netcdf.open');% look for built-in matlab netcdf library |
---|
| 2957 | if ~isequal(hhh,'')% case of new builtin Matlab netcdf library |
---|
[450] | 2958 | nc=netcdf.open(FileName,'NC_WRITE'); |
---|
[387] | 2959 | netcdf.reDef(nc); |
---|
| 2960 | netcdf.putAtt(nc,netcdf.getConstant('NC_GLOBAL'),attrname,1); |
---|
| 2961 | dimid = netcdf.inqDimID(nc,nbname); |
---|
| 2962 | try |
---|
| 2963 | varid = netcdf.inqVarID(nc,flagname);% look for already existing fixflag variable |
---|
| 2964 | catch |
---|
| 2965 | varid=netcdf.defVar(nc,flagname,'double',dimid);%create fixflag variable if it does not exist |
---|
| 2966 | end |
---|
| 2967 | netcdf.endDef(nc); |
---|
[511] | 2968 | netcdf.putVar(nc,varid,UvData.PlotAxes.FF); |
---|
[387] | 2969 | netcdf.close(nc); |
---|
| 2970 | else %old netcdf library |
---|
[450] | 2971 | netcdf_toolbox(FileName,AxeData,attrname,nbname,flagname) |
---|
[387] | 2972 | end |
---|
| 2973 | |
---|
| 2974 | %------------------------------------------------------------------- |
---|
| 2975 | %----Correct the netcdf file, using toolbox (old versions of Matlab). |
---|
| 2976 | %------------------------------------------------------------------- |
---|
[450] | 2977 | function netcdf_toolbox(FileName,AxeData,attrname,nbname,flagname) |
---|
| 2978 | nc=netcdf(FileName,'write'); %open netcdf file |
---|
[387] | 2979 | result=redef(nc); |
---|
| 2980 | eval(['nc.' attrname '=1;']); |
---|
| 2981 | theDim=nc(nbname) ;% get the number of velocity vectors |
---|
| 2982 | nb_vectors=size(theDim); |
---|
| 2983 | var_FixFlag=ncvar(flagname,nc);% var_FixFlag will be written as the netcdf variable vec_FixFlag |
---|
| 2984 | var_FixFlag(1:nb_vectors)=AxeData.FF;% |
---|
| 2985 | fin=close(nc); |
---|
| 2986 | |
---|
[428] | 2987 | %------------------------------------------------------------------- |
---|
[387] | 2988 | % --- Executes on button press in SubField |
---|
| 2989 | function SubField_Callback(hObject, eventdata, handles) |
---|
[428] | 2990 | %------------------------------------------------------------------- |
---|
[387] | 2991 | UvData=get(handles.uvmat,'UserData'); |
---|
| 2992 | if get(handles.SubField,'Value')==0% if the subfield button is desactivated |
---|
| 2993 | set(handles.RootPath_1,'String','') |
---|
| 2994 | set(handles.RootFile_1,'String','') |
---|
| 2995 | set(handles.SubDir_1,'String',''); |
---|
| 2996 | set(handles.FileIndex_1,'String',''); |
---|
| 2997 | set(handles.FileExt_1,'String',''); |
---|
| 2998 | set(handles.RootPath_1,'Visible','off') |
---|
| 2999 | set(handles.RootFile_1,'Visible','off') |
---|
| 3000 | set(handles.SubDir_1,'Visible','off'); |
---|
| 3001 | set(handles.NomType_1,'Visible','off'); |
---|
| 3002 | set(handles.abs_time_1,'Visible','off') |
---|
| 3003 | set(handles.FileIndex_1,'Visible','off'); |
---|
| 3004 | set(handles.FileExt_1,'Visible','off'); |
---|
[526] | 3005 | set(handles.FieldName_1,'Value',1);%set to blank state |
---|
[387] | 3006 | set(handles.VelType_1,'Value',1);%set to blank state |
---|
[428] | 3007 | set(handles.num_Opacity,'String','')% desactivate opacity setting |
---|
[580] | 3008 | FieldList=get(handles.FieldName,'String'); |
---|
| 3009 | if numel(FieldList)>1 % if a choice of fields exists |
---|
| 3010 | set(handles.FieldName_1,'Value',1)% set second field choice to blank |
---|
| 3011 | set(handles.FieldName_1,'String',[{''};FieldList])% reproduce the menu FieldName plus a blank option |
---|
| 3012 | else |
---|
| 3013 | set(handles.FieldName_1,'String',{''})% set second field choice to blank |
---|
| 3014 | end |
---|
[387] | 3015 | if ~strcmp(get(handles.VelType,'Visible'),'on') |
---|
| 3016 | set(handles.VelType_1,'Visible','off') |
---|
| 3017 | end |
---|
| 3018 | if isfield(UvData,'XmlData_1') |
---|
| 3019 | UvData=rmfield(UvData,'XmlData_1'); |
---|
| 3020 | end |
---|
| 3021 | set(handles.uvmat,'UserData',UvData); |
---|
[591] | 3022 | transform_fct_list=get(handles.TransformName,'String'); |
---|
| 3023 | transform_fct=transform_fct_list(get(handles.TransformName,'Value')); |
---|
[515] | 3024 | if strcmp(transform_fct,'sub_field') |
---|
[591] | 3025 | set(handles.TransformName,'Value',1)%suppress the sub_field transform |
---|
[515] | 3026 | transform_fct_Callback(hObject, eventdata, handles); |
---|
| 3027 | else |
---|
| 3028 | run0_Callback(hObject, eventdata, handles) |
---|
| 3029 | end |
---|
[387] | 3030 | else |
---|
| 3031 | MenuBrowse_1_Callback(hObject, eventdata, handles) |
---|
| 3032 | end |
---|
| 3033 | |
---|
| 3034 | %------------------------------------------------------------------------ |
---|
| 3035 | % --- read the data displayed for the input rootfile windows (new): TODO use read_GUI |
---|
| 3036 | |
---|
| 3037 | function [RootPath,SubDir,RootFile,FileIndices,FileExt]=read_file_boxes(handles) |
---|
| 3038 | %------------------------------------------------------------------------ |
---|
| 3039 | InputFile=read_GUI(handles.InputFile); |
---|
| 3040 | RootPath=InputFile.RootPath; |
---|
| 3041 | SubDir=regexprep(InputFile.SubDir,'/|\',''); |
---|
| 3042 | RootFile=regexprep(InputFile.RootFile,'/|\',''); |
---|
| 3043 | FileIndices=InputFile.FileIndex; |
---|
| 3044 | FileExt=InputFile.FileExt; |
---|
| 3045 | |
---|
| 3046 | |
---|
| 3047 | %------------------------------------------------------------------------ |
---|
| 3048 | % ---- read the data displayed for the second input rootfile windows |
---|
| 3049 | function [RootPath_1,SubDir_1,RootFile_1,FileIndex_1,FileExt_1,NomType_1]=read_file_boxes_1(handles) |
---|
| 3050 | %------------------------------------------------------------------------ |
---|
| 3051 | RootPath_1=get(handles.RootPath_1,'String'); % read the data from the file1_input window |
---|
| 3052 | if isequal(get(handles.RootPath_1,'Visible'),'off') || isequal(RootPath_1,'"') |
---|
| 3053 | RootPath_1=get(handles.RootPath,'String'); |
---|
| 3054 | end; |
---|
| 3055 | SubDir_1=get(handles.SubDir_1,'String'); |
---|
| 3056 | if isequal(get(handles.SubDir_1,'Visible'),'off')|| isequal(SubDir_1,'"') |
---|
| 3057 | SubDir_1=get(handles.SubDir,'String'); |
---|
| 3058 | end |
---|
| 3059 | SubDir_1=regexprep(SubDir_1,'\<[\\/]|[\\/]\>','');%suppress possible / or \ separator at the beginning or the end of the string |
---|
| 3060 | RootFile_1=get(handles.RootFile_1,'String'); |
---|
| 3061 | if isequal(get(handles.RootFile_1,'Visible'),'off') || isequal(RootFile_1,'"') |
---|
| 3062 | RootFile_1=get(handles.RootFile,'String'); |
---|
| 3063 | end |
---|
| 3064 | RootFile_1=regexprep(RootFile_1,'\<[\\/]|[\\/]\>','');%suppress possible / or \ separator at the beginning or the end of the string |
---|
| 3065 | FileIndex_1=get(handles.FileIndex_1,'String'); |
---|
| 3066 | if isequal(get(handles.FileIndex_1,'Visible'),'off')|| isequal(FileIndex_1,'"') |
---|
| 3067 | FileIndex_1=get(handles.FileIndex,'String'); |
---|
| 3068 | end |
---|
| 3069 | FileExt_1=get(handles.FileExt_1,'String'); |
---|
| 3070 | if isequal(get(handles.FileExt_1,'Visible'),'off') || isequal(FileExt_1,'"') |
---|
| 3071 | FileExt_1=get(handles.FileExt,'String');%read FileExt by default |
---|
| 3072 | end |
---|
| 3073 | NomType_1=get(handles.NomType_1,'String'); |
---|
| 3074 | if isequal(get(handles.NomType_1,'Visible'),'off') || isequal(NomType_1,'"') |
---|
| 3075 | NomType_1=get(handles.NomType,'String');%read FileExt by default |
---|
| 3076 | end |
---|
| 3077 | %------------------------------------------------------------------------ |
---|
[526] | 3078 | % --- Executes on menu selection FieldName |
---|
| 3079 | function FieldName_Callback(hObject, eventdata, handles) |
---|
[387] | 3080 | %------------------------------------------------------------------------ |
---|
[581] | 3081 | UvData=get(handles.uvmat,'UserData'); |
---|
[526] | 3082 | list_fields=get(handles.FieldName,'String');% list menu fields |
---|
| 3083 | index_fields=get(handles.FieldName,'Value');% selected string index |
---|
[387] | 3084 | field= list_fields{index_fields(1)}; % selected string |
---|
[581] | 3085 | |
---|
| 3086 | %% fill the coordinates and variables from selections in get_field |
---|
[387] | 3087 | if isequal(field,'get_field...') |
---|
[582] | 3088 | ParamIn=[]; |
---|
[581] | 3089 | if strcmp(get(handles.VelType,'Visible'),'on') |
---|
| 3090 | % we use the civ choice as default input |
---|
| 3091 | ParamIn.SwitchVarIndexTime='attribute'; |
---|
| 3092 | ListVelType=get(handles.VelType,'String'); |
---|
| 3093 | VelType=ListVelType{get(handles.VelType,'Value')}; |
---|
| 3094 | switch VelType |
---|
| 3095 | case 'civ1' |
---|
| 3096 | ParamIn.TimeVarName='Civ1_Time'; |
---|
| 3097 | ParamIn.vector_x='Civ1_U'; |
---|
| 3098 | ParamIn.vector_y='Civ1_V'; |
---|
[582] | 3099 | ParamIn.vec_color='Civ1_C'; |
---|
[581] | 3100 | case 'filter1' |
---|
| 3101 | ParamIn.TimeVarName='Civ1_Time'; |
---|
| 3102 | ParamIn.vector_x='Civ1_U_smooth'; |
---|
| 3103 | ParamIn.vector_y='Civ1_V_smooth'; |
---|
| 3104 | case 'civ2' |
---|
| 3105 | ParamIn.TimeVarName='Civ2_Time'; |
---|
| 3106 | ParamIn.vector_x='Civ2_U'; |
---|
| 3107 | ParamIn.vector_y='Civ2_V'; |
---|
| 3108 | case 'filter2' |
---|
| 3109 | ParamIn.TimeVarName='Civ2_Time'; |
---|
| 3110 | ParamIn.vector_x='Civ2_U_smooth'; |
---|
| 3111 | ParamIn.vector_y='Civ2_V_smooth'; |
---|
[582] | 3112 | ParamIn.vec_color='Civ2_C'; |
---|
[581] | 3113 | end |
---|
| 3114 | end |
---|
[387] | 3115 | set(handles.FixVelType,'visible','off') |
---|
[581] | 3116 | set(handles.VelType,'Visible','off') |
---|
| 3117 | set(handles.VelType_1,'Visible','off') |
---|
[387] | 3118 | [RootPath,SubDir,RootFile,FileIndices,FileExt]=read_file_boxes(handles); |
---|
[450] | 3119 | FileName=[fullfile(RootPath,SubDir,RootFile) FileIndices FileExt]; |
---|
[581] | 3120 | % hget_field=findobj(allchild(0),'name','get_field'); |
---|
| 3121 | % if ~isempty(hget_field) |
---|
| 3122 | % delete(hget_field) |
---|
| 3123 | % end |
---|
| 3124 | GetFieldData=get_field(FileName,ParamIn); |
---|
| 3125 | FieldList={}; |
---|
| 3126 | VecColorList={}; |
---|
[595] | 3127 | XName=GetFieldData.XVarName; |
---|
[581] | 3128 | if GetFieldData.CheckVector |
---|
| 3129 | UName=GetFieldData.PanelVectors.vector_x; |
---|
| 3130 | VName=GetFieldData.PanelVectors.vector_y; |
---|
[586] | 3131 | XName=GetFieldData.XVarName; |
---|
| 3132 | YName=GetFieldData.YVarName; |
---|
[581] | 3133 | CName=GetFieldData.PanelVectors.vec_color; |
---|
| 3134 | [FieldList,VecColorList]=set_field_list(UName,VName,CName); |
---|
[595] | 3135 | elseif GetFieldData.CheckScalar |
---|
[581] | 3136 | AName=GetFieldData.PanelScalar.scalar; |
---|
[586] | 3137 | XName=GetFieldData.XVarName; |
---|
| 3138 | YName=GetFieldData.YVarName; |
---|
[581] | 3139 | FieldList={AName}; |
---|
[595] | 3140 | elseif GetFieldData.CheckPlot1D; |
---|
[581] | 3141 | YName=GetFieldData.CheckPlot1D.ordinate; |
---|
| 3142 | end |
---|
| 3143 | set(handles.Coord_x,'String',{XName}) |
---|
| 3144 | set(handles.Coord_y,'String',{YName}) |
---|
| 3145 | set(handles.FieldName,'Value',1) |
---|
| 3146 | set(handles.FieldName,'String',[FieldList; {'get_field...'}]); |
---|
| 3147 | set(handles.ColorScalar,'Value',1) |
---|
| 3148 | set(handles.ColorScalar,'String',VecColorList); |
---|
| 3149 | UvData.FileType{1}='netcdf'; |
---|
| 3150 | set(handles.uvmat,'UserData',UvData) |
---|
| 3151 | run0_Callback(hObject, eventdata, handles) |
---|
[517] | 3152 | return %no further action |
---|
[387] | 3153 | end |
---|
[517] | 3154 | |
---|
[387] | 3155 | |
---|
[581] | 3156 | |
---|
[387] | 3157 | %read the rootfile input display |
---|
| 3158 | [RootPath,SubDir,RootFile,FileIndices,FileExt]=read_file_boxes(handles); |
---|
| 3159 | FileName=[fullfile(RootPath,SubDir,RootFile) FileIndices FileExt]; |
---|
| 3160 | [tild,tild,tild,i1,i2,j1,j2,tild,NomType]=fileparts_uvmat(['xxx' get(handles.FileIndex,'String') FileExt]); |
---|
| 3161 | if isequal(field,'image') |
---|
[494] | 3162 | if isfield(UvData.Field,'Civ2_ImageA')%get the corresponding input image in the netcdf file |
---|
| 3163 | imagename=UvData.Field.Civ2_ImageA; |
---|
| 3164 | elseif isfield(UvData.Field,'Civ1_ImageA')% |
---|
| 3165 | imagename=UvData.Field.Civ1_ImageA; |
---|
| 3166 | else |
---|
| 3167 | SubDirBase=regexprep(SubDir,'\..*','');%take the root part of SubDir, before the first dot '.' |
---|
| 3168 | imagename=fullfile_uvmat(RootPath,SubDirBase,RootFile,'.png',NomType,i1,[],j1,[]); |
---|
| 3169 | end |
---|
[387] | 3170 | if ~exist(imagename,'file') |
---|
| 3171 | [FileName,PathName] = uigetfile( ... |
---|
| 3172 | {'*.png;*.jpg;*.tif;*.avi;*.AVI;*.vol', ' (*.png, .tif, *.avi,*.vol)'; |
---|
| 3173 | '*.jpg',' jpeg image files'; ... |
---|
| 3174 | '*.png','.png image files'; ... |
---|
| 3175 | '*.tif','.tif image files'; ... |
---|
| 3176 | '*.avi;*.AVI','.avi movie files'; ... |
---|
| 3177 | '*.vol','.volume images (png)'; ... |
---|
| 3178 | '*.*', 'All Files (*.*)'}, ... |
---|
[530] | 3179 | 'Pick an image',imagename); |
---|
| 3180 | if ~ischar(FileName),return,end %abandon if the browser is cancelled |
---|
[387] | 3181 | imagename=[PathName FileName]; |
---|
| 3182 | end |
---|
| 3183 | % display the selected field and related information |
---|
[406] | 3184 | display_file_name(handles,imagename)%display the image |
---|
[387] | 3185 | return |
---|
| 3186 | else |
---|
| 3187 | ext=get(handles.FileExt,'String'); |
---|
| 3188 | if ~isequal(ext,'.nc') %find the new NomType if the previous display was not already a netcdf file |
---|
| 3189 | [FileName,PathName] = uigetfile( ... |
---|
| 3190 | {'*.nc', ' (*.nc)'; |
---|
| 3191 | '*.nc',' netcdf files'; ... |
---|
| 3192 | '*.*', 'All Files (*.*)'}, ... |
---|
| 3193 | 'Pick a netcdf file',FileBase); |
---|
[530] | 3194 | if ~ischar(FileName),return,end %abandon if the browser is cancelled |
---|
[450] | 3195 | FullFileName=[PathName FileName]; |
---|
[387] | 3196 | % display the selected field and related information |
---|
[450] | 3197 | display_file_name( handles,FullFileName) |
---|
[387] | 3198 | return |
---|
| 3199 | end |
---|
| 3200 | end |
---|
| 3201 | indices=fullfile_uvmat('','','','',NomType,i1,i2,j1,j2); |
---|
| 3202 | set(handles.FileIndex,'String',indices) |
---|
| 3203 | |
---|
| 3204 | %common to Fields_1_Callback |
---|
[526] | 3205 | list_fields_1=get(handles.FieldName_1,'String');% list menu fields |
---|
[517] | 3206 | field_1=''; |
---|
| 3207 | if ~isempty(list_fields_1) |
---|
[526] | 3208 | field_1= list_fields_1{get(handles.FieldName_1,'Value')}; % selected string |
---|
[517] | 3209 | end |
---|
[387] | 3210 | if isequal(field,'image')||isequal(field_1,'image') |
---|
[546] | 3211 | set(handles.TitleNpxy,'Visible','on')% visible npx,pxcm... buttons |
---|
[387] | 3212 | set(handles.num_Npx,'Visible','on') |
---|
| 3213 | set(handles.num_Npy,'Visible','on') |
---|
| 3214 | else |
---|
[546] | 3215 | set(handles.TitleNpxy,'Visible','off')% visible npx,pxcm... buttons |
---|
[387] | 3216 | set(handles.num_Npx,'Visible','off') |
---|
| 3217 | set(handles.num_Npy,'Visible','off') |
---|
| 3218 | end |
---|
| 3219 | if ~(isfield(UvData,'NewSeries')&&isequal(UvData.NewSeries,1)) |
---|
| 3220 | run0_Callback(hObject, eventdata, handles) |
---|
| 3221 | end |
---|
| 3222 | |
---|
| 3223 | %--------------------------------------------------- |
---|
[526] | 3224 | % --- Executes on menu selection FieldName |
---|
| 3225 | function FieldName_1_Callback(hObject, eventdata, handles) |
---|
[387] | 3226 | %------------------------------------------------- |
---|
| 3227 | %% read input data |
---|
| 3228 | check_new=~get(handles.SubField,'Value'); %check_new=1 if a second field was not previously entered |
---|
| 3229 | UvData=get(handles.uvmat,'UserData'); |
---|
| 3230 | if check_new && isfield(UvData,'XmlData') |
---|
| 3231 | UvData.XmlData{2}=UvData.XmlData{1}; |
---|
| 3232 | end |
---|
[389] | 3233 | if isfield(UvData,'Field_1') |
---|
| 3234 | UvData=rmfield(UvData,'Field_1');% remove the stored second field (a new one needs to be read) |
---|
| 3235 | end |
---|
[450] | 3236 | UvData.FileName_1='';% desactivate the use of a constant second file |
---|
[526] | 3237 | list_fields=get(handles.FieldName,'String');% list menu fields |
---|
| 3238 | field= list_fields{get(handles.FieldName,'Value')}; % selected string |
---|
| 3239 | list_fields=get(handles.FieldName_1,'String');% list menu fields |
---|
| 3240 | field_1= list_fields{get(handles.FieldName_1,'Value')}; % selected string for the second field |
---|
[405] | 3241 | if isempty(field_1)%||(numel(UvData.FileType)>=2 && strcmp(UvData.FileType{2},'image')) |
---|
[387] | 3242 | set(handles.SubField,'Value',0) |
---|
| 3243 | SubField_Callback(hObject, eventdata, handles) |
---|
[428] | 3244 | return |
---|
[405] | 3245 | else |
---|
| 3246 | set(handles.SubField,'Value',1)%state that a second field is now entered |
---|
[387] | 3247 | end |
---|
| 3248 | |
---|
| 3249 | %% read the rootfile input display |
---|
[405] | 3250 | [RootPath_1,SubDir_1,RootFile_1,FileIndex_1,FileExt_1]=read_file_boxes_1(handles); |
---|
[450] | 3251 | FileName_1=[fullfile(RootPath_1,SubDir_1,RootFile_1) FileIndex_1 FileExt_1]; |
---|
[387] | 3252 | [tild,tild,tild,i1,i2,j1,j2]=fileparts_uvmat(get(handles.FileIndex,'String')); |
---|
| 3253 | switch field_1 |
---|
| 3254 | case 'get_field...' |
---|
| 3255 | set_veltype_display(0) % no veltype display |
---|
| 3256 | hget_field=findobj(allchild(0),'name','get_field_1'); |
---|
| 3257 | if ~isempty(hget_field) |
---|
| 3258 | delete(hget_field) |
---|
| 3259 | end |
---|
[450] | 3260 | hget_field=get_field(FileName_1); |
---|
[387] | 3261 | set(hget_field,'name','get_field_1') |
---|
| 3262 | hhget_field=guidata(hget_field); |
---|
| 3263 | set(hhget_field.list_fig,'Value',1) |
---|
| 3264 | set(hhget_field.list_fig,'String',{'uvmat'}) |
---|
[428] | 3265 | if check_new |
---|
| 3266 | UvData.FileType{2}=UvData.FileType{1}; |
---|
| 3267 | set(handles.FileIndex_1,'String',get(handles.FileIndex,'String')) |
---|
| 3268 | set(handles.uvmat,'UserData',UvData) |
---|
| 3269 | end |
---|
[387] | 3270 | case 'image' |
---|
[494] | 3271 | % get the image name corresponding to the current netcdf name (no unique correspondance) |
---|
| 3272 | if isfield(UvData.Field,'Civ2_ImageA')%get the corresponding input image in the netcdf file |
---|
| 3273 | imagename=UvData.Field.Civ2_ImageA; |
---|
| 3274 | elseif isfield(UvData.Field,'Civ1_ImageA')% |
---|
| 3275 | imagename=UvData.Field.Civ1_ImageA; |
---|
| 3276 | else |
---|
| 3277 | SubDirBase=regexprep(SubDir_1,'\..*','');%take the root part of SubDir, before the first dot '.' |
---|
| 3278 | imagename=fullfile_uvmat(RootPath_1,SubDirBase,RootFile_1,'.png',get(handles.NomType,'String'),i1,[],j1); |
---|
| 3279 | end |
---|
[405] | 3280 | if ~exist(imagename,'file') % browse for images if it is not found |
---|
[387] | 3281 | [FileName,PathName] = uigetfile( ... |
---|
| 3282 | {'*.png;*.jpg;*.tif;*.avi;*.AVI;*.vol', ' (*.png, .tif, *.avi,*.vol)'; |
---|
| 3283 | '*.jpg',' jpeg image files'; ... |
---|
| 3284 | '*.png','.png image files'; ... |
---|
| 3285 | '*.tif','.tif image files'; ... |
---|
| 3286 | '*.avi;*.AVI','.avi movie files'; ... |
---|
| 3287 | '*.vol','.volume images (png)'; ... |
---|
| 3288 | '*.*', 'All Files (*.*)'}, ... |
---|
| 3289 | 'Pick an image',imagename); |
---|
[530] | 3290 | if ~ischar(FileName),return,end %abandon if the browser is cancelled |
---|
[387] | 3291 | imagename=[PathName FileName]; |
---|
| 3292 | end |
---|
[405] | 3293 | if ~ischar(imagename)% quit if the browser has been closed |
---|
| 3294 | set(handles.SubField,'Value',0) |
---|
| 3295 | else %valid browser input: display the selected image |
---|
[546] | 3296 | set(handles.TitleNpxy,'Visible','on')% visible npx,pxcm... buttons |
---|
[405] | 3297 | set(handles.num_Npx,'Visible','on') |
---|
| 3298 | set(handles.num_Npy,'Visible','on') |
---|
[406] | 3299 | display_file_name(handles,imagename,2)%display the imag |
---|
[405] | 3300 | end |
---|
[387] | 3301 | otherwise |
---|
[580] | 3302 | check_refresh=1; |
---|
| 3303 | if check_new% if a second field was not previously entered, we just read another field in the first input file |
---|
[387] | 3304 | set(handles.FileIndex_1,'String',get(handles.FileIndex,'String')) |
---|
| 3305 | set(handles.FileExt_1,'String',get(handles.FileExt,'String')) |
---|
[580] | 3306 | |
---|
| 3307 | UvData.FileType{2}=UvData.FileType{1}; |
---|
| 3308 | UvData.XmlData{2}= UvData.XmlData{1}; |
---|
[591] | 3309 | transform=get(handles.TransformPath,'UserData'); |
---|
[580] | 3310 | if (~isa(transform,'function_handle')||nargin(transform)<3) |
---|
| 3311 | set(handles.uvmat,'UserData',UvData) |
---|
[591] | 3312 | set(handles.TransformName,'value',2); % set transform fct to 'sub_field' if the current fct does not accept two input fields |
---|
[580] | 3313 | transform_fct_Callback(hObject, eventdata, handles)% activate transform_fct_Callback and refresh current plot |
---|
| 3314 | check_refresh=0; |
---|
| 3315 | end |
---|
[387] | 3316 | end |
---|
| 3317 | if ~isequal(field,'image') |
---|
[546] | 3318 | set(handles.TitleNpxy,'Visible','off')% visible npx,pxcm... buttons |
---|
[387] | 3319 | set(handles.num_Npx,'Visible','off') |
---|
| 3320 | set(handles.num_Npy,'Visible','off') |
---|
| 3321 | end |
---|
| 3322 | set(handles.uvmat,'UserData',UvData) |
---|
[580] | 3323 | |
---|
| 3324 | if check_refresh && ~(isfield(UvData,'NewSeries')&&isequal(UvData.NewSeries,1)) |
---|
[387] | 3325 | run0_Callback(hObject, eventdata, handles) |
---|
| 3326 | end |
---|
| 3327 | end |
---|
| 3328 | |
---|
| 3329 | %------------------------------------------------------------------------ |
---|
| 3330 | % --- set the visibility of relevant velocity type menus: |
---|
| 3331 | function menu=set_veltype_display(Civ,FileType) |
---|
| 3332 | %------------------------------------------------------------------------ |
---|
| 3333 | if ~exist('FileType','var') |
---|
| 3334 | FileType='civx'; |
---|
| 3335 | end |
---|
| 3336 | switch FileType |
---|
| 3337 | case 'civx' |
---|
[389] | 3338 | menu={'civ1';'interp1';'filter1';'civ2';'interp2';'filter2'}; |
---|
| 3339 | if isequal(Civ,0) |
---|
| 3340 | imax=0; |
---|
| 3341 | elseif isequal(Civ,1) || isequal(Civ,2) |
---|
| 3342 | imax=1; |
---|
| 3343 | elseif isequal(Civ,3) |
---|
| 3344 | imax=3; |
---|
| 3345 | elseif isequal(Civ,4) || isequal(Civ,5) |
---|
| 3346 | imax=4; |
---|
| 3347 | elseif isequal(Civ,6) %patch2 |
---|
| 3348 | imax=6; |
---|
| 3349 | end |
---|
[387] | 3350 | case 'civdata' |
---|
[389] | 3351 | menu={'civ1';'filter1';'civ2';'filter2'}; |
---|
| 3352 | if isequal(Civ,0) |
---|
| 3353 | imax=0; |
---|
| 3354 | elseif isequal(Civ,1) || isequal(Civ,2) |
---|
| 3355 | imax=1; |
---|
| 3356 | elseif isequal(Civ,3) |
---|
| 3357 | imax=2; |
---|
| 3358 | elseif isequal(Civ,4) || isequal(Civ,5) |
---|
| 3359 | imax=3; |
---|
| 3360 | elseif isequal(Civ,6) %patch2 |
---|
| 3361 | imax=4; |
---|
| 3362 | end |
---|
[387] | 3363 | end |
---|
| 3364 | menu=menu(1:imax); |
---|
| 3365 | |
---|
| 3366 | %------------------------------------------------------------------------ |
---|
[402] | 3367 | % --- Executes on button press in FixVelType. |
---|
| 3368 | function FixVelType_Callback(hObject, eventdata, handles) |
---|
| 3369 | %------------------------------------------------------------------------ |
---|
[405] | 3370 | % refresh the current plot if the fixed veltype is unselected |
---|
| 3371 | if ~get(handles.FixVelType,'Value') |
---|
[402] | 3372 | run0_Callback(hObject, eventdata, handles) |
---|
| 3373 | end |
---|
| 3374 | |
---|
| 3375 | %------------------------------------------------------------------------ |
---|
[387] | 3376 | % --- Executes on button press in VelType. |
---|
| 3377 | function VelType_Callback(hObject, eventdata, handles) |
---|
| 3378 | %------------------------------------------------------------------------ |
---|
| 3379 | set(handles.FixVelType,'Value',1) |
---|
| 3380 | run0_Callback(hObject, eventdata, handles) |
---|
| 3381 | |
---|
| 3382 | %------------------------------------------------------------------------ |
---|
[515] | 3383 | % --- Executes on choice selection in VelType_1. |
---|
[387] | 3384 | function VelType_1_Callback(hObject, eventdata, handles) |
---|
| 3385 | %------------------------------------------------------------------------ |
---|
| 3386 | set(handles.FixVelType,'Value',1)% the velocity type is now imposed by the GUI (not automatic) |
---|
[389] | 3387 | UvData=get(handles.uvmat,'UserData'); |
---|
[515] | 3388 | set(handles.run0,'BackgroundColor',[1 1 0])%paint run0 button in yellow to indicate its activation |
---|
[387] | 3389 | drawnow |
---|
[515] | 3390 | InputFile=read_GUI(handles.InputFile);% read the input file parameters |
---|
| 3391 | [RootPath,SubDir,RootFile,FileIndex,FileExt]=read_file_boxes(handles); |
---|
| 3392 | [RootPath_1,SubDir_1,RootFile_1,FileIndex_1,FileExt_1]=read_file_boxes_1(handles); |
---|
| 3393 | FileName=[fullfile(RootPath,SubDir,RootFile) FileIndex FileExt];% name of the first input file |
---|
[405] | 3394 | |
---|
[515] | 3395 | check_refresh=0; |
---|
[389] | 3396 | if isempty(InputFile.VelType_1) |
---|
[515] | 3397 | FileName_1='';% we plot the first input field without the second field |
---|
[387] | 3398 | set(handles.SubField,'Value',0) |
---|
[580] | 3399 | SubField_Callback(hObject, eventdata, handles)% activate SubField_Callback and refresh current plot, removing the second field |
---|
[387] | 3400 | elseif get(handles.SubField,'Value')% if subfield is already 'on' |
---|
[515] | 3401 | FileName_1=[fullfile(RootPath_1,SubDir_1,RootFile_1) FileIndex_1 FileExt_1];% name of the second input file |
---|
[580] | 3402 | check_refresh=1;%will refresh the current plot |
---|
[515] | 3403 | else% we introduce the same file (with a different field) for the second series |
---|
| 3404 | FileName_1=FileName;% we compare two fields in the same file |
---|
[389] | 3405 | UvData.FileType{2}=UvData.FileType{1}; |
---|
[515] | 3406 | UvData.XmlData{2}= UvData.XmlData{1}; |
---|
[387] | 3407 | set(handles.SubField,'Value',1) |
---|
[591] | 3408 | transform=get(handles.TransformPath,'UserData'); |
---|
[515] | 3409 | if (~isa(transform,'function_handle')||nargin(transform)<3) |
---|
[580] | 3410 | set(handles.uvmat,'UserData',UvData) |
---|
[591] | 3411 | set(handles.TransformName,'value',2); % set transform fct to 'sub_field' if the current fct does not accept two input fields |
---|
[580] | 3412 | transform_fct_Callback(hObject, eventdata, handles)% activate transform_fct_Callback and refresh current plot |
---|
[515] | 3413 | else |
---|
| 3414 | check_refresh=1; |
---|
| 3415 | end |
---|
[387] | 3416 | end |
---|
| 3417 | |
---|
[580] | 3418 | % refresh the current plot if it has not been done previously |
---|
[515] | 3419 | if check_refresh |
---|
| 3420 | UvData.FileName_1='';% desactivate the use of a constant second file |
---|
| 3421 | set(handles.uvmat,'UserData',UvData) |
---|
| 3422 | num_i1=stra2num(get(handles.i1,'String')); |
---|
| 3423 | num_i2=stra2num(get(handles.i2,'String')); |
---|
| 3424 | num_j1=stra2num(get(handles.j1,'String')); |
---|
| 3425 | num_j2=stra2num(get(handles.j2,'String')); |
---|
| 3426 | [tild,tild,tild,i1_1,i2_1,j1_1,j2_1]=fileparts_uvmat(['xx' FileIndex_1]); |
---|
| 3427 | errormsg=refresh_field(handles,FileName,FileName_1,num_i1,num_i2,num_j1,num_j2,i1_1,i2_1,j1_1,j2_1); |
---|
| 3428 | if ~isempty(errormsg) |
---|
| 3429 | msgbox_uvmat('ERROR',errormsg); |
---|
| 3430 | else |
---|
| 3431 | set(handles.i1,'BackgroundColor',[1 1 1]) |
---|
| 3432 | set(handles.i2,'BackgroundColor',[1 1 1]) |
---|
| 3433 | set(handles.j1,'BackgroundColor',[1 1 1]) |
---|
| 3434 | set(handles.j2,'BackgroundColor',[1 1 1]) |
---|
| 3435 | set(handles.FileIndex,'BackgroundColor',[1 1 1]) |
---|
| 3436 | set(handles.FileIndex_1,'BackgroundColor',[1 1 1]) |
---|
| 3437 | end |
---|
| 3438 | set(handles.run0,'BackgroundColor',[1 0 0]) |
---|
[387] | 3439 | end |
---|
| 3440 | |
---|
[580] | 3441 | |
---|
| 3442 | %----------------------------------------------------------------------- |
---|
[387] | 3443 | % --- reset civ buttons |
---|
| 3444 | function reset_vel_type(handles_civ0,handle1) |
---|
[580] | 3445 | %----------------------------------------------------------------------- |
---|
[387] | 3446 | for ibutton=1:length(handles_civ0) |
---|
| 3447 | set(handles_civ0(ibutton),'BackgroundColor',[0.831 0.816 0.784]) |
---|
| 3448 | set(handles_civ0(ibutton),'Value',0) |
---|
| 3449 | end |
---|
| 3450 | if exist('handle1','var')%handles of selected button |
---|
| 3451 | set(handle1,'BackgroundColor',[1 1 0]) |
---|
| 3452 | end |
---|
| 3453 | |
---|
[580] | 3454 | %----------------------------------------------------------------------- |
---|
[387] | 3455 | % --- Executes on button press in MENUVOLUME. |
---|
| 3456 | function VOLUME_Callback(hObject, eventdata, handles) |
---|
[580] | 3457 | %----------------------------------------------------------------------- |
---|
[387] | 3458 | %errordlg('command VOL not implemented yet') |
---|
| 3459 | if ishandle(handles.UVMAT_title) |
---|
| 3460 | delete(handles.UVMAT_title) |
---|
| 3461 | end |
---|
| 3462 | UvData=get(handles.uvmat,'UserData');%read UvData properties stored on the uvmat interface |
---|
| 3463 | if isequal(get(handles.VOLUME,'Value'),1) |
---|
| 3464 | set(handles.CheckZoom,'Value',0) |
---|
| 3465 | set(handles.CheckZoom,'BackgroundColor',[0.7 0.7 0.7]) |
---|
| 3466 | set(handles.edit_vect,'Value',0) |
---|
| 3467 | edit_vect_Callback(hObject, eventdata, handles) |
---|
| 3468 | set(handles.edit_object,'Value',0) |
---|
| 3469 | set(handles.edit_object,'BackgroundColor',[0.7 0.7 0.7]) |
---|
| 3470 | % set(handles.cal,'Value',0) |
---|
| 3471 | % set(handles.cal,'BackgroundColor',[0 1 0]) |
---|
| 3472 | set(handles.edit_vect,'Value',0) |
---|
| 3473 | edit_vect_Callback(hObject, eventdata, handles) |
---|
| 3474 | %initiate set_object GUI |
---|
| 3475 | data.Name='VOLUME'; |
---|
| 3476 | if isfield(UvData,'CoordType') |
---|
| 3477 | data.CoordType=UvData.CoordType; |
---|
| 3478 | end |
---|
[575] | 3479 | if isfield(UvData.Field,'CoordMesh')&~isempty(UvData.Field.CoordMesh) |
---|
[404] | 3480 | data.RangeX=[UvData.Field.XMin UvData.Field.XMax]; |
---|
| 3481 | data.RangeY=[UvData.Field.YMin UvData.Field.YMax]; |
---|
[575] | 3482 | data.DX=UvData.Field.CoordMesh; |
---|
| 3483 | data.DY=UvData.Field.CoordMesh; |
---|
[387] | 3484 | elseif isfield(UvData.Field,'AX')&isfield(UvData.Field,'AY')& isfield(UvData.Field,'A')%only image |
---|
| 3485 | np=size(UvData.Field.A); |
---|
| 3486 | meshx=(UvData.Field.AX(end)-UvData.Field.AX(1))/np(2); |
---|
| 3487 | meshy=abs(UvData.Field.AY(end)-UvData.Field.AY(1))/np(1); |
---|
| 3488 | data.RangeY=max(meshx,meshy); |
---|
| 3489 | data.RangeX=max(meshx,meshy); |
---|
| 3490 | data.DX=max(meshx,meshy); |
---|
| 3491 | end |
---|
| 3492 | data.ParentButton=handles.VOLUME; |
---|
| 3493 | PlotHandles=get_plot_handles(handles);%get the handles of the interface elements setting the plotting parameters |
---|
| 3494 | [hset_object,UvData.sethandles]=set_object(data,PlotHandles);% call the set_object interface with action on haxes, |
---|
| 3495 | % associate the set_object interface handle to the plotting axes |
---|
[511] | 3496 | set(hset_object,'Position',get(handles.uvmat,'Position')+UvData.OpenParam.PosSetObject) |
---|
[387] | 3497 | UvData.MouseAction='create_object'; |
---|
| 3498 | else |
---|
| 3499 | set(handles.VOLUME,'BackgroundColor',[0 1 0]) |
---|
| 3500 | end |
---|
| 3501 | set(handles.uvmat,'UserData',UvData) |
---|
| 3502 | |
---|
| 3503 | %------------------------------------------------------- |
---|
| 3504 | function edit_vect_Callback(hObject, eventdata, handles) |
---|
| 3505 | %------------------------------------------------------- |
---|
| 3506 | % |
---|
| 3507 | if isequal(get(handles.edit_vect,'Value'),1) |
---|
[581] | 3508 | VelTypeMenu=get(handles.VelType,'String'); |
---|
| 3509 | VelType=VelTypeMenu{get(handles.VelType,'Value')}; |
---|
| 3510 | if ~strcmp(VelType,'civ2') && ~strcmp(VelType,'civ1') |
---|
[387] | 3511 | msgbox_uvmat('ERROR','manual correction only possible for CIV1 or CIV2 velocity fields') |
---|
| 3512 | end |
---|
| 3513 | set(handles.record,'Visible','on') |
---|
| 3514 | set(handles.edit_vect,'BackgroundColor',[1 1 0]) |
---|
| 3515 | set(handles.edit_object,'Value',0) |
---|
| 3516 | set(handles.CheckZoom,'Value',0) |
---|
| 3517 | set(handles.CheckZoom,'BackgroundColor',[0.7 0.7 0.7]) |
---|
| 3518 | set(handles.edit_object,'BackgroundColor',[0.7 0.7 0.7]) |
---|
| 3519 | set(gcf,'Pointer','arrow') |
---|
| 3520 | else |
---|
| 3521 | set(handles.record,'Visible','off') |
---|
| 3522 | set(handles.edit_vect,'BackgroundColor',[0.7 0.7 0.7]) |
---|
| 3523 | end |
---|
| 3524 | |
---|
| 3525 | %---------------------------------------------- |
---|
| 3526 | function save_mask_Callback(hObject, eventdata, handles) |
---|
| 3527 | %----------------------------------------------------------------------- |
---|
| 3528 | UvData=get(handles.uvmat,'UserData'); |
---|
| 3529 | |
---|
| 3530 | flag=1; |
---|
| 3531 | npx=size(UvData.Field.A,2); |
---|
| 3532 | npy=size(UvData.Field.A,1); |
---|
| 3533 | xi=0.5:npx-0.5; |
---|
| 3534 | yi=0.5:npy-0.5; |
---|
| 3535 | [Xi,Yi]=meshgrid(xi,yi); |
---|
| 3536 | if isfield(UvData,'Object') |
---|
| 3537 | for iobj=1:length(UvData.Object) |
---|
| 3538 | ObjectData=UvData.Object{iobj}; |
---|
| 3539 | if isfield(ObjectData,'ProjMode') &&(isequal(ObjectData.ProjMode,'mask_inside')||isequal(ObjectData.ProjMode,'mask_outside')); |
---|
| 3540 | flagobj=1; |
---|
| 3541 | testphys=0; %coordinates in pixels by default |
---|
| 3542 | if isfield(ObjectData,'CoordType') && isequal(ObjectData.CoordType,'phys') |
---|
| 3543 | if isfield(UvData,'XmlData')&& isfield(UvData.XmlData{1},'GeometryCalib') |
---|
| 3544 | Calib=UvData.XmlData{1}.GeometryCalib; |
---|
| 3545 | testphys=1; |
---|
| 3546 | end |
---|
| 3547 | end |
---|
| 3548 | if isfield(ObjectData,'Coord')& isfield(ObjectData,'Style') |
---|
| 3549 | if isequal(ObjectData.Type,'polygon') |
---|
| 3550 | X=ObjectData.Coord(:,1); |
---|
| 3551 | Y=ObjectData.Coord(:,2); |
---|
| 3552 | if testphys |
---|
| 3553 | [X,Y]=px_XYZ(Calib,X,Y,0);% to generalise with 3D cases |
---|
| 3554 | end |
---|
| 3555 | flagobj=~inpolygon(Xi,Yi,X',Y');%=0 inside the polygon, 1 outside |
---|
| 3556 | elseif isequal(ObjectData.Type,'ellipse') |
---|
| 3557 | if testphys |
---|
| 3558 | %[X,Y]=px_XYZ(Calib,X,Y,0);% TODO:create a polygon boundary and transform to phys |
---|
| 3559 | end |
---|
| 3560 | RangeX=max(ObjectData.RangeX); |
---|
| 3561 | RangeY=max(ObjectData.RangeY); |
---|
| 3562 | X2Max=RangeX*RangeX; |
---|
| 3563 | Y2Max=RangeY*RangeY; |
---|
| 3564 | distX=(Xi-ObjectData.Coord(1,1)); |
---|
| 3565 | distY=(Yi-ObjectData.Coord(1,2)); |
---|
| 3566 | flagobj=(distX.*distX/X2Max+distY.*distY/Y2Max)>1; |
---|
| 3567 | elseif isequal(ObjectData.Type,'rectangle') |
---|
| 3568 | if testphys |
---|
| 3569 | %[X,Y]=px_XYZ(Calib,X,Y,0);% TODO:create a polygon boundary and transform to phys |
---|
| 3570 | end |
---|
| 3571 | distX=abs(Xi-ObjectData.Coord(1,1)); |
---|
| 3572 | distY=abs(Yi-ObjectData.Coord(1,2)); |
---|
| 3573 | flagobj=distX>max(ObjectData.RangeX) | distY>max(ObjectData.RangeY); |
---|
| 3574 | end |
---|
| 3575 | if isequal(ObjectData.ProjMode,'mask_outside') |
---|
| 3576 | flagobj=~flagobj; |
---|
| 3577 | end |
---|
| 3578 | flag=flag & flagobj; |
---|
| 3579 | end |
---|
| 3580 | end |
---|
| 3581 | end |
---|
| 3582 | end |
---|
| 3583 | % flag=~flag; |
---|
| 3584 | %mask name |
---|
| 3585 | RootPath=get(handles.RootPath,'String'); |
---|
| 3586 | RootFile=get(handles.RootFile,'String'); |
---|
| 3587 | RootFile=regexprep(RootFile,'\<[\\/]|[\\/]\>','');%suppress possible / or \ separator at the beginning or the end of the string |
---|
| 3588 | filebase=fullfile(RootPath,RootFile); |
---|
| 3589 | list=get(handles.masklevel,'String'); |
---|
| 3590 | masknumber=num2str(length(list)); |
---|
| 3591 | maskindex=get(handles.masklevel,'Value'); |
---|
| 3592 | mask_name=fullfile_uvmat(RootPath,SubDir,[RootFile '_' masknumber 'mask'],'.png','_1',maskindex); |
---|
| 3593 | %mask_name=name_generator([filebase '_' masknumber 'mask'],maskindex,1,'.png','_i'); |
---|
| 3594 | imflag=uint8(255*(0.392+0.608*flag));% =100 for flag=0 (vectors not computed when 20<imflag<200) |
---|
| 3595 | imflag=flipdim(imflag,1); |
---|
| 3596 | % imflag=uint8(255*flag);% =0 for flag=0 (vectors=0 when 20<imflag<200) |
---|
| 3597 | msgbox_uvmat('CONFIRMATION',[mask_name ' saved']) |
---|
| 3598 | imwrite(imflag,mask_name,'BitDepth',8); |
---|
| 3599 | |
---|
| 3600 | %display the mask |
---|
| 3601 | figure; |
---|
| 3602 | vec=linspace(0,1,256);%define a linear greyscale colormap |
---|
| 3603 | map=[vec' vec' vec']; |
---|
| 3604 | colormap(map) |
---|
| 3605 | |
---|
| 3606 | image(imflag); |
---|
| 3607 | |
---|
| 3608 | %------------------------------------------------------------------- |
---|
| 3609 | %------------------------------------------------------------------- |
---|
| 3610 | % - FUNCTIONS FOR SETTING PLOTTING PARAMETERS |
---|
| 3611 | |
---|
| 3612 | %------------------------------------------------------------------ |
---|
| 3613 | %------------------------------------------------------------- |
---|
[591] | 3614 | % --- Executes on selection change in TransformName. |
---|
[508] | 3615 | |
---|
[591] | 3616 | function TransformName_Callback(hObject, eventdata, handles) |
---|
[387] | 3617 | %------------------------------------------------------------- |
---|
| 3618 | UvData=get(handles.uvmat,'UserData'); |
---|
[591] | 3619 | menu=get(handles.TransformName,'String');refresh |
---|
| 3620 | ichoice=get(handles.TransformName,'Value');%item number in the menu |
---|
[507] | 3621 | transform_name=menu{ichoice};% choice of the transform fct |
---|
[591] | 3622 | list_path=get(handles.TransformName,'UserData'); |
---|
[507] | 3623 | |
---|
| 3624 | %% add a new item to the menu if the option 'more...' has been selected |
---|
[591] | 3625 | prev_path=fullfile(get(handles.TransformPath,'String')); |
---|
[508] | 3626 | if ~exist(prev_path,'dir') |
---|
| 3627 | prev_path=fullfile(fileparts(which('uvmat')),'transform_field'); |
---|
| 3628 | end |
---|
[507] | 3629 | if strcmp(transform_name,'more...'); |
---|
[387] | 3630 | [FileName, PathName] = uigetfile( ... |
---|
[507] | 3631 | {'*.m', ' (*.m)'; |
---|
[387] | 3632 | '*.m', '.m files '; ... |
---|
| 3633 | '*.*', 'All Files (*.*)'}, ... |
---|
[508] | 3634 | 'Pick the transform function', prev_path); |
---|
[530] | 3635 | if ~ischar(FileName),return,end %abandon if the browser is cancelled |
---|
[507] | 3636 | path_transform_fct =fullfile(PathName,FileName); |
---|
[556] | 3637 | if isempty(regexp(FileName,'\.m$'))% detect file extension .m |
---|
[387] | 3638 | msgbox_uvmat('ERROR','a Matlab function .m must be introduced'); |
---|
| 3639 | return |
---|
[507] | 3640 | else |
---|
[556] | 3641 | transform_name=regexprep(FileName,'\.m',''); |
---|
[507] | 3642 | end |
---|
| 3643 | ichoice=find(strcmp(transform_name,menu),1);%look for the selected fct in the existing menu |
---|
| 3644 | if isempty(ichoice)% if the item is not found, add it to the menu (before 'more...' and select it) |
---|
| 3645 | menu=[menu(1:end-1);{transform_name};{'more...'}]; |
---|
| 3646 | ichoice=numel(menu)-1; |
---|
| 3647 | end |
---|
| 3648 | list_path{ichoice}=PathName;%update the list fo fct paths |
---|
[591] | 3649 | set(handles.TransformName,'String',menu) |
---|
| 3650 | set(handles.TransformName,'Value',ichoice) |
---|
[507] | 3651 | |
---|
| 3652 | % save the new menu in the personal file 'uvmat_perso.mat' |
---|
| 3653 | dir_perso=prefdir;%personal Matalb directory |
---|
| 3654 | profil_perso=fullfile(dir_perso,'uvmat_perso.mat'); |
---|
| 3655 | if exist(profil_perso,'file') |
---|
| 3656 | nb_builtin=UvData.OpenParam.NbBuiltin;% number of 'builtin' (basic) transform fcts in uvmat |
---|
[523] | 3657 | if nb_builtin<numel(list_path) |
---|
[507] | 3658 | for ilist=nb_builtin+1:numel(list_path) |
---|
[508] | 3659 | transform_fct{ilist-nb_builtin}=[fullfile(list_path{ilist},menu{ilist}) '.m']; |
---|
[507] | 3660 | end |
---|
[387] | 3661 | save (profil_perso,'transform_fct','-append'); %store the root name for future opening of uvmat |
---|
[523] | 3662 | end |
---|
[507] | 3663 | end |
---|
[387] | 3664 | end |
---|
| 3665 | |
---|
[507] | 3666 | %% create the function handle of the selected fct |
---|
[512] | 3667 | |
---|
[507] | 3668 | if isempty(list_path{ichoice})% case of no selected fct |
---|
| 3669 | transform_handle=[]; |
---|
[387] | 3670 | else |
---|
[507] | 3671 | if ~exist(list_path{ichoice},'dir') |
---|
| 3672 | msgbox_uvmat('ERROR','invalid fct path: select the transform fct again with the option more...') |
---|
| 3673 | return |
---|
| 3674 | end |
---|
| 3675 | current_dir=pwd;%current working dir |
---|
| 3676 | cd(list_path{ichoice}) |
---|
| 3677 | transform_handle=str2func(transform_name); |
---|
| 3678 | cd(current_dir) |
---|
[387] | 3679 | end |
---|
[591] | 3680 | set(handles.TransformPath,'String',list_path{ichoice}) |
---|
| 3681 | set(handles.TransformPath,'UserData',transform_handle) |
---|
| 3682 | set(handles.TransformName,'UserData',list_path) |
---|
[387] | 3683 | |
---|
[591] | 3684 | %% update the ToolTip string of the menu TransformName with the first line of the selected fct file |
---|
[507] | 3685 | if isempty(list_path{ichoice})% case of no selected fct |
---|
[591] | 3686 | set(handles.TransformName,'ToolTipString','transform_fct:choose a transform function') |
---|
[507] | 3687 | else |
---|
| 3688 | try |
---|
| 3689 | [fid,errormsg] =fopen([fullfile(list_path{ichoice},transform_name) '.m']); |
---|
| 3690 | InputText=textscan(fid,'%s',1,'delimiter','\n'); |
---|
| 3691 | fclose(fid) |
---|
[591] | 3692 | set(handles.TransformName,'ToolTipString',['transform_fct: ' InputText{1}{1}])% put the first line of the selected function as tooltip help |
---|
[507] | 3693 | end |
---|
| 3694 | end |
---|
| 3695 | |
---|
| 3696 | %% adapt the GUI to the input/output conditions of the selected transform fct |
---|
[508] | 3697 | DataOut=[]; |
---|
| 3698 | CoordUnit=''; |
---|
| 3699 | CoordUnitPrev=''; |
---|
| 3700 | if isfield(UvData,'Field')&&isfield(UvData.Field,'CoordUnit') |
---|
| 3701 | CoordUnitPrev=UvData.Field.CoordUnit; |
---|
| 3702 | end |
---|
| 3703 | if ~isempty(list_path{ichoice}) |
---|
| 3704 | if nargin(transform_handle)>1 && isfield(UvData,'XmlData')&&~isempty(UvData.XmlData) |
---|
| 3705 | XmlData=UvData.XmlData{1}; |
---|
| 3706 | DataOut=feval(transform_handle,'*',XmlData); |
---|
| 3707 | if isfield(DataOut,'CoordUnit') |
---|
| 3708 | CoordUnit=DataOut.CoordUnit; |
---|
[507] | 3709 | end |
---|
[508] | 3710 | if isfield(DataOut,'InputFieldType') |
---|
| 3711 | UvData.InputFieldType=DataOut.InputFieldType; |
---|
| 3712 | end |
---|
| 3713 | else |
---|
| 3714 | DataOut=feval(transform_handle,'*'); |
---|
[507] | 3715 | end |
---|
| 3716 | end |
---|
| 3717 | |
---|
[387] | 3718 | |
---|
[508] | 3719 | %% delete drawn objects if the output CooordUnit is different from the previous one |
---|
| 3720 | if ~strcmp(CoordUnit,CoordUnitPrev) |
---|
[541] | 3721 | set(handles.CheckFixLimits,'Value',0) |
---|
| 3722 | set(handles.CheckFixLimits,'BackgroundColor',[0.7 0.7 0.7]) |
---|
[508] | 3723 | hother=findobj('Tag','proj_object');%find all the proj objects |
---|
| 3724 | for iobj=1:length(hother) |
---|
| 3725 | delete_object(hother(iobj)) |
---|
| 3726 | end |
---|
| 3727 | hother=findobj('Tag','DeformPoint');%find all the proj objects |
---|
| 3728 | for iobj=1:length(hother) |
---|
| 3729 | delete_object(hother(iobj)) |
---|
| 3730 | end |
---|
| 3731 | hh=findobj('Tag','calib_points'); |
---|
| 3732 | if ~isempty(hh) |
---|
| 3733 | delete(hh) |
---|
| 3734 | end |
---|
| 3735 | hhh=findobj('Tag','calib_marker'); |
---|
| 3736 | if ~isempty(hhh) |
---|
| 3737 | delete(hhh) |
---|
| 3738 | end |
---|
| 3739 | % if isfield(UvData,'Object') |
---|
| 3740 | % UvData.Object=UvData.Object(1); |
---|
| 3741 | % end |
---|
| 3742 | set(handles.ListObject,'Value',1) |
---|
| 3743 | set(handles.ListObject,'String',{''}) |
---|
| 3744 | set(handles.ListObject_1,'Value',1) |
---|
| 3745 | set(handles.ListObject_1,'String',{''}) |
---|
| 3746 | set(handles.ViewObject,'value',0) |
---|
| 3747 | ViewObject_Callback(hObject, eventdata, handles) |
---|
| 3748 | set(handles.ViewField,'value',0) |
---|
| 3749 | ViewField_Callback(hObject, eventdata, handles) |
---|
| 3750 | set(handles.edit_object,'Value',0) |
---|
| 3751 | edit_object_Callback(hObject, eventdata, handles) |
---|
| 3752 | UvData.Object={[]}; |
---|
[387] | 3753 | end |
---|
[508] | 3754 | set(handles.uvmat,'UserData',UvData) |
---|
[387] | 3755 | |
---|
[508] | 3756 | %% refresh the current plot |
---|
[515] | 3757 | if isempty(list_path{ichoice}) || nargin(transform_handle)<3 |
---|
| 3758 | set(handles.SubField,'Value',0) |
---|
| 3759 | SubField_Callback(hObject, eventdata, handles) |
---|
| 3760 | else |
---|
| 3761 | run0_Callback(hObject, eventdata, handles) |
---|
| 3762 | end |
---|
[387] | 3763 | |
---|
| 3764 | %------------------------------------------------ |
---|
| 3765 | %CALLBACKS FOR PLOTTING PARAMETERS |
---|
| 3766 | %------------------------------------------------- |
---|
[405] | 3767 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
---|
| 3768 | % Plot coordinates |
---|
| 3769 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
---|
[387] | 3770 | %------------------------------------------------------------------------ |
---|
| 3771 | function num_MinX_Callback(hObject, eventdata, handles) |
---|
| 3772 | %------------------------------------------------------------------------ |
---|
| 3773 | set(handles.CheckFixLimits,'Value',1) %suppress auto mode |
---|
| 3774 | set(handles.CheckFixLimits,'BackgroundColor',[1 1 0]) |
---|
| 3775 | update_plot(handles); |
---|
| 3776 | |
---|
| 3777 | %------------------------------------------------------------------------ |
---|
| 3778 | function num_MaxX_Callback(hObject, eventdata, handles) |
---|
| 3779 | %------------------------------------------------------------------------ |
---|
| 3780 | set(handles.CheckFixLimits,'Value',1) %suppress auto mode |
---|
| 3781 | set(handles.CheckFixLimits,'BackgroundColor',[1 1 0]) |
---|
| 3782 | update_plot(handles); |
---|
| 3783 | |
---|
| 3784 | %------------------------------------------------------------------------ |
---|
| 3785 | function num_MinY_Callback(hObject, eventdata, handles) |
---|
| 3786 | %------------------------------------------ |
---|
| 3787 | set(handles.CheckFixLimits,'Value',1) %suppress auto mode |
---|
| 3788 | set(handles.CheckFixLimits,'BackgroundColor',[1 1 0]) |
---|
| 3789 | update_plot(handles); |
---|
| 3790 | |
---|
| 3791 | %------------------------------------------------------------------------ |
---|
| 3792 | function num_MaxY_Callback(hObject, eventdata, handles) |
---|
| 3793 | %------------------------------------------------------------------------ |
---|
| 3794 | set(handles.CheckFixLimits,'Value',1) %suppress auto mode |
---|
| 3795 | set(handles.CheckFixLimits,'BackgroundColor',[1 1 0]) |
---|
| 3796 | update_plot(handles); |
---|
| 3797 | |
---|
[405] | 3798 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
---|
| 3799 | % Scalar or image representation |
---|
| 3800 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
---|
[387] | 3801 | %------------------------------------------------------------------------ |
---|
| 3802 | function num_MinA_Callback(hObject, eventdata, handles) |
---|
| 3803 | %------------------------------------------ |
---|
| 3804 | set(handles.CheckFixScalar,'Value',1) %suppress auto mode |
---|
| 3805 | set(handles.CheckFixScalar,'BackgroundColor',[1 1 0]) |
---|
| 3806 | MinA=str2double(get(handles.num_MinA,'String')); |
---|
| 3807 | MaxA=str2double(get(handles.num_MaxA,'String')); |
---|
| 3808 | if MinA>MaxA% switch minA and maxA in case of error |
---|
| 3809 | MinA_old=MinA; |
---|
| 3810 | MinA=MaxA; |
---|
| 3811 | MaxA=MinA_old; |
---|
| 3812 | set(handles.num_MinA,'String',num2str(MinA,5)); |
---|
| 3813 | set(handles.num_MaxA,'String',num2str(MaxA,5)); |
---|
| 3814 | end |
---|
| 3815 | update_plot(handles); |
---|
| 3816 | |
---|
| 3817 | %------------------------------------------------------------------------ |
---|
| 3818 | function num_MaxA_Callback(hObject, eventdata, handles) |
---|
| 3819 | %------------------------------------------------------------------------ |
---|
| 3820 | set(handles.CheckFixScalar,'Value',1) %suppress auto mode |
---|
| 3821 | set(handles.CheckFixScalar,'BackgroundColor',[1 1 0]) |
---|
| 3822 | MinA=str2double(get(handles.num_MinA,'String')); |
---|
| 3823 | MaxA=str2double(get(handles.num_MaxA,'String')); |
---|
| 3824 | if MinA>MaxA% switch minA and maxA in case of error |
---|
| 3825 | MinA_old=MinA; |
---|
| 3826 | MinA=MaxA; |
---|
| 3827 | MaxA=MinA_old; |
---|
| 3828 | set(handles.num_MinA,'String',num2str(MinA,5)); |
---|
| 3829 | set(handles.num_MaxA,'String',num2str(MaxA,5)); |
---|
| 3830 | end |
---|
| 3831 | update_plot(handles); |
---|
| 3832 | |
---|
| 3833 | %------------------------------------------------------------------------ |
---|
| 3834 | function CheckFixScalar_Callback(hObject, eventdata, handles) |
---|
| 3835 | %------------------------------------------------------------------------ |
---|
| 3836 | test=get(handles.CheckFixScalar,'Value'); |
---|
| 3837 | if test |
---|
| 3838 | set(handles.CheckFixScalar,'BackgroundColor',[1 1 0]) |
---|
| 3839 | else |
---|
| 3840 | set(handles.CheckFixScalar,'BackgroundColor',[0.7 0.7 0.7]) |
---|
| 3841 | update_plot(handles); |
---|
| 3842 | end |
---|
| 3843 | |
---|
| 3844 | %------------------------------------------------------------------- |
---|
| 3845 | function CheckBW_Callback(hObject, eventdata, handles) |
---|
| 3846 | %------------------------------------------------------------------- |
---|
| 3847 | update_plot(handles); |
---|
| 3848 | |
---|
| 3849 | %------------------------------------------------------------------- |
---|
[428] | 3850 | function num_Opacity_Callback(hObject, eventdata, handles) |
---|
| 3851 | update_plot(handles); |
---|
| 3852 | %------------------------------------------------------------------- |
---|
| 3853 | |
---|
| 3854 | %------------------------------------------------------------------- |
---|
[387] | 3855 | function ListContour_Callback(hObject, eventdata, handles) |
---|
| 3856 | %------------------------------------------------------------------- |
---|
| 3857 | val=get(handles.ListContour,'Value'); |
---|
| 3858 | if val==2 |
---|
| 3859 | set(handles.interval_txt,'Visible','on') |
---|
| 3860 | set(handles.num_IncrA,'Visible','on') |
---|
| 3861 | else |
---|
| 3862 | set(handles.interval_txt,'Visible','off') |
---|
| 3863 | set(handles.num_IncrA,'Visible','off') |
---|
| 3864 | end |
---|
| 3865 | update_plot(handles); |
---|
| 3866 | |
---|
| 3867 | %------------------------------------------------------------------- |
---|
| 3868 | function num_IncrA_Callback(hObject, eventdata, handles) |
---|
| 3869 | %------------------------------------------------------------------- |
---|
| 3870 | update_plot(handles); |
---|
| 3871 | |
---|
[405] | 3872 | |
---|
| 3873 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
---|
| 3874 | % Vector representation |
---|
| 3875 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
---|
[387] | 3876 | %------------------------------------------------------------------- |
---|
| 3877 | function CheckHideWarning_Callback(hObject, eventdata, handles) |
---|
| 3878 | %------------------------------------------------------------------- |
---|
| 3879 | update_plot(handles); |
---|
| 3880 | |
---|
| 3881 | %------------------------------------------------------------------- |
---|
| 3882 | function CheckHideFalse_Callback(hObject, eventdata, handles) |
---|
| 3883 | %------------------------------------------------------------------- |
---|
| 3884 | update_plot(handles); |
---|
| 3885 | |
---|
| 3886 | %------------------------------------------------------------------- |
---|
| 3887 | function num_VecScale_Callback(hObject, eventdata, handles) |
---|
| 3888 | %------------------------------------------------------------------- |
---|
| 3889 | set(handles.CheckFixVectors,'Value',1); |
---|
| 3890 | set(handles.CheckFixVectors,'BackgroundColor',[1 1 0]) |
---|
| 3891 | update_plot(handles); |
---|
| 3892 | |
---|
| 3893 | %------------------------------------------------------------------- |
---|
| 3894 | function CheckFixVectors_Callback(hObject, eventdata, handles) |
---|
| 3895 | %------------------------------------------------------------------- |
---|
| 3896 | test=get(handles.CheckFixVectors,'Value'); |
---|
| 3897 | if test |
---|
| 3898 | set(handles.CheckFixVectors,'BackgroundColor',[1 1 0]) |
---|
| 3899 | else |
---|
| 3900 | update_plot(handles); |
---|
| 3901 | %set(handles.num_VecScale,'String',num2str(ScalOut.num_VecScale,3)) |
---|
| 3902 | set(handles.CheckFixVectors,'BackgroundColor',[0.7 0.7 0.7]) |
---|
| 3903 | end |
---|
| 3904 | |
---|
| 3905 | %------------------------------------------------------------------------ |
---|
| 3906 | % --- Executes on selection change in CheckDecimate4 (nb_vec/4). |
---|
| 3907 | function CheckDecimate4_Callback(hObject, eventdata, handles) |
---|
| 3908 | %------------------------------------------------------------------------ |
---|
[581] | 3909 | if isequal(get(handles.CheckDecimate4,'Value'),1) |
---|
| 3910 | set(handles.CheckDecimate16,'Value',0) |
---|
| 3911 | end |
---|
[387] | 3912 | update_plot(handles); |
---|
| 3913 | |
---|
| 3914 | %------------------------------------------------------------------------ |
---|
[581] | 3915 | % --- Executes on selection change in CheckDecimate16 (nb_vec/16). |
---|
| 3916 | function CheckDecimate16_Callback(hObject, eventdata, handles) |
---|
| 3917 | %------------------------------------------------------------------------ |
---|
| 3918 | if isequal(get(handles.CheckDecimate16,'Value'),1) |
---|
| 3919 | set(handles.CheckDecimate4,'Value',0) |
---|
| 3920 | end |
---|
| 3921 | update_plot(handles); |
---|
| 3922 | |
---|
| 3923 | %------------------------------------------------------------------------ |
---|
[405] | 3924 | % --- Executes on selection change in ColorCode menu |
---|
| 3925 | function ColorCode_Callback(hObject, eventdata, handles) |
---|
[387] | 3926 | %------------------------------------------------------------------------ |
---|
[405] | 3927 | % edit the choice for color code |
---|
| 3928 | update_color_code_boxes(handles); |
---|
| 3929 | update_plot(handles); |
---|
| 3930 | |
---|
| 3931 | %------------------------------------------------------------------------ |
---|
| 3932 | function update_color_code_boxes(handles) |
---|
| 3933 | %------------------------------------------------------------------------ |
---|
| 3934 | list_code=get(handles.ColorCode,'String');% list menu fields |
---|
| 3935 | colcode= list_code{get(handles.ColorCode,'Value')}; % selected field |
---|
| 3936 | enable_slider='off';%default |
---|
| 3937 | enable_bounds='off';%default |
---|
| 3938 | enable_scalar='off';%default |
---|
| 3939 | switch colcode |
---|
| 3940 | case {'rgb','bgr'} |
---|
| 3941 | enable_slider='on'; |
---|
| 3942 | enable_bounds='on'; |
---|
| 3943 | enable_scalar='on'; |
---|
| 3944 | case '64 colors' |
---|
| 3945 | enable_bounds='on'; |
---|
| 3946 | enable_scalar='on'; |
---|
| 3947 | end |
---|
| 3948 | set(handles.Slider1,'Visible',enable_slider) |
---|
| 3949 | set(handles.Slider2,'Visible', enable_slider) |
---|
| 3950 | set(handles.num_ColCode1,'Visible',enable_slider) |
---|
| 3951 | set(handles.num_ColCode2,'Visible',enable_slider) |
---|
| 3952 | set(handles.TitleColCode1,'Visible',enable_slider) |
---|
| 3953 | set(handles.TitleColCode2,'Visible',enable_slider) |
---|
| 3954 | set(handles.CheckFixVecColor,'Visible',enable_bounds) |
---|
| 3955 | set(handles.num_MinVec,'Visible',enable_bounds) |
---|
| 3956 | set(handles.num_MaxVec,'Visible',enable_bounds) |
---|
| 3957 | set(handles.ColorScalar,'Visible',enable_scalar) |
---|
[387] | 3958 | set_vec_col_bar(handles) |
---|
[405] | 3959 | |
---|
| 3960 | %------------------------------------------------------------------ |
---|
| 3961 | % --- Executes on selection change in ColorScalar: choice of the color code. |
---|
| 3962 | function ColorScalar_Callback(hObject, eventdata, handles) |
---|
| 3963 | %------------------------------------------------------------------ |
---|
| 3964 | % edit the choice for color code |
---|
| 3965 | list_scalar=get(handles.ColorScalar,'String');% list menu fields |
---|
| 3966 | col_scalar= list_scalar{get(handles.ColorScalar,'Value')}; % selected field |
---|
| 3967 | if isequal(col_scalar,'ima_cor') |
---|
| 3968 | set(handles.CheckFixVecColor,'Value',1)%fixed scale by default |
---|
| 3969 | ColorCode='rgb'; |
---|
| 3970 | set(handles.num_MinVec,'String','0') |
---|
| 3971 | set(handles.num_MaxVec,'String','1') |
---|
| 3972 | set(handles.num_ColCode1,'String','0.333') |
---|
| 3973 | set(handles.num_ColCode2,'String','0.666') |
---|
| 3974 | else |
---|
| 3975 | set(handles.CheckFixVecColor,'Value',0)%auto scale between min,max by default |
---|
| 3976 | ColorCode='64 colors'; |
---|
| 3977 | end |
---|
| 3978 | ColorCodeList=get(handles.ColorCode,'String'); |
---|
| 3979 | ichoice=find(strcmp(ColorCode,ColorCodeList),1); |
---|
| 3980 | set(handles.ColorCode,'Value',ichoice)% set color code in the menu |
---|
| 3981 | |
---|
| 3982 | update_color_code_boxes(handles); |
---|
| 3983 | %replot the current graph |
---|
| 3984 | run0_Callback(hObject, eventdata, handles) |
---|
| 3985 | |
---|
| 3986 | %---------------------------------------------------------------- |
---|
| 3987 | % -- Executes on slider movement to set the color code |
---|
| 3988 | % |
---|
| 3989 | function Slider1_Callback(hObject, eventdata, handles) |
---|
| 3990 | %------------------------------------------------------------------ |
---|
| 3991 | slider1=get(handles.Slider1,'Value'); |
---|
| 3992 | min_val=str2num(get(handles.num_MinVec,'String')); |
---|
| 3993 | max_val=str2num(get(handles.num_MaxVec,'String')); |
---|
| 3994 | col=min_val+(max_val-min_val)*slider1; |
---|
| 3995 | set(handles.num_ColCode1,'String',num2str(col)) |
---|
| 3996 | if(get(handles.Slider2,'Value') < col)%move also the second slider at the same value if needed |
---|
| 3997 | set(handles.Slider2,'Value',col) |
---|
| 3998 | set(handles.num_ColCode2,'String',num2str(col)) |
---|
| 3999 | end |
---|
| 4000 | set_vec_col_bar(handles) |
---|
[387] | 4001 | update_plot(handles); |
---|
| 4002 | |
---|
[405] | 4003 | %---------------------------------------------------------------- |
---|
| 4004 | % Executes on slider movement to set the color code |
---|
| 4005 | %---------------------------------------------------------------- |
---|
| 4006 | function Slider2_Callback(hObject, eventdata, handles) |
---|
| 4007 | slider2=get(handles.Slider2,'Value'); |
---|
| 4008 | min_val=str2num(get(handles.num_MinVec,'String')); |
---|
| 4009 | max_val=str2num(get(handles.num_MaxVec,'String')); |
---|
| 4010 | col=min_val+(max_val-min_val)*slider2; |
---|
| 4011 | set(handles.num_ColCode2,'String',num2str(col)) |
---|
| 4012 | if(get(handles.Slider1,'Value') > col)%move also the first slider at the same value if needed |
---|
| 4013 | set(handles.Slider1,'Value',col) |
---|
| 4014 | set(handles.num_ColCode1,'String',num2str(col)) |
---|
| 4015 | end |
---|
| 4016 | set_vec_col_bar(handles) |
---|
| 4017 | update_plot(handles); |
---|
| 4018 | |
---|
| 4019 | %---------------------------------------------------------------- |
---|
| 4020 | % --- Execute on return carriage on the edit box corresponding to slider 1 |
---|
| 4021 | %---------------------------------------------------------------- |
---|
| 4022 | function num_ColCode1_Callback(hObject, eventdata, handles) |
---|
| 4023 | set_vec_col_bar(handles) |
---|
| 4024 | update_plot(handles); |
---|
| 4025 | |
---|
| 4026 | %---------------------------------------------------------------- |
---|
| 4027 | % --- Execute on return carriage on the edit box corresponding to slider 2 |
---|
| 4028 | %---------------------------------------------------------------- |
---|
| 4029 | function num_ColCode2_Callback(hObject, eventdata, handles) |
---|
| 4030 | set_vec_col_bar(handles) |
---|
| 4031 | update_plot(handles); |
---|
[387] | 4032 | %------------------------------------------------------------------------ |
---|
[405] | 4033 | %------------------------------------------------------- |
---|
[387] | 4034 | % --- Executes on button press in CheckFixVecColor. |
---|
[405] | 4035 | %------------------------------------------------------- |
---|
| 4036 | function VecColBar_Callback(hObject, eventdata, handles) |
---|
| 4037 | set_vec_col_bar(handles) |
---|
| 4038 | |
---|
| 4039 | %------------------------------------------------------------------------ |
---|
| 4040 | % --- Executes on button press in CheckFixVecColor. |
---|
[387] | 4041 | function CheckFixVecColor_Callback(hObject, eventdata, handles) |
---|
| 4042 | %------------------------------------------------------------------------ |
---|
[405] | 4043 | if ~get(handles.CheckFixVecColor,'Value') |
---|
[387] | 4044 | update_plot(handles); |
---|
| 4045 | end |
---|
| 4046 | |
---|
| 4047 | %------------------------------------------------------------------------ |
---|
| 4048 | % --- Executes on selection change in num_MaxVec. |
---|
| 4049 | function num_MinVec_Callback(hObject, eventdata, handles) |
---|
| 4050 | %------------------------------------------------------------------------ |
---|
| 4051 | max_vec_Callback(hObject, eventdata, handles) |
---|
| 4052 | |
---|
| 4053 | %------------------------------------------------------------------------ |
---|
| 4054 | % --- Executes on selection change in num_MaxVec. |
---|
| 4055 | function num_MaxVec_Callback(hObject, eventdata, handles) |
---|
| 4056 | %------------------------------------------------------------------------ |
---|
| 4057 | set(handles.CheckFixVecColor,'Value',1) |
---|
| 4058 | CheckFixVecColor_Callback(hObject, eventdata, handles) |
---|
| 4059 | min_val=str2num(get(handles.num_MinVec,'String')); |
---|
| 4060 | max_val=str2num(get(handles.num_MaxVec,'String')); |
---|
| 4061 | slider1=get(handles.Slider1,'Value'); |
---|
| 4062 | slider2=get(handles.Slider2,'Value'); |
---|
| 4063 | colcode1=min_val+(max_val-min_val)*slider1; |
---|
| 4064 | colcode2=min_val+(max_val-min_val)*slider2; |
---|
| 4065 | set(handles.num_ColCode1,'String',num2str(colcode1)) |
---|
| 4066 | set(handles.num_ColCode2,'String',num2str(colcode2)) |
---|
| 4067 | update_plot(handles); |
---|
| 4068 | |
---|
| 4069 | %------------------------------------------------------------------------ |
---|
[405] | 4070 | % --- update the display of color code for vectors (on vecColBar) |
---|
[387] | 4071 | function set_vec_col_bar(handles) |
---|
| 4072 | %------------------------------------------------------------------------ |
---|
| 4073 | %get the image of the color display button 'VecColBar' in pixels |
---|
| 4074 | set(handles.VecColBar,'Unit','pixel'); |
---|
| 4075 | pos_vert=get(handles.VecColBar,'Position'); |
---|
| 4076 | set(handles.VecColBar,'Unit','Normalized'); |
---|
| 4077 | width=ceil(pos_vert(3)); |
---|
| 4078 | height=ceil(pos_vert(4)); |
---|
| 4079 | |
---|
| 4080 | %get slider indications |
---|
[405] | 4081 | list=get(handles.ColorCode,'String'); |
---|
| 4082 | ichoice=get(handles.ColorCode,'Value'); |
---|
| 4083 | colcode.ColorCode=list{ichoice}; |
---|
[387] | 4084 | colcode.MinVec=str2num(get(handles.num_MinVec,'String')); |
---|
| 4085 | colcode.MaxVec=str2num(get(handles.num_MaxVec,'String')); |
---|
[405] | 4086 | test3color=strcmp(colcode.ColorCode,'rgb') || strcmp(colcode.ColorCode,'bgr'); |
---|
[387] | 4087 | if test3color |
---|
| 4088 | colcode.ColCode1=str2num(get(handles.num_ColCode1,'String')); |
---|
| 4089 | colcode.ColCode2=str2num(get(handles.num_ColCode2,'String')); |
---|
| 4090 | end |
---|
| 4091 | vec_C=colcode.MinVec+(colcode.MaxVec-colcode.MinVec)*(0.5:width-0.5)/width;%sample of vec_C values from min to max |
---|
| 4092 | [colorlist,col_vec]=set_col_vec(colcode,vec_C); |
---|
| 4093 | oneheight=ones(1,height); |
---|
| 4094 | A1=colorlist(col_vec,1)*oneheight; |
---|
| 4095 | A2=colorlist(col_vec,2)*oneheight; |
---|
| 4096 | A3=colorlist(col_vec,3)*oneheight; |
---|
| 4097 | A(:,:,1)=A1'; |
---|
| 4098 | A(:,:,2)=A2'; |
---|
| 4099 | A(:,:,3)=A3'; |
---|
| 4100 | set(handles.VecColBar,'Cdata',A) |
---|
| 4101 | |
---|
| 4102 | %------------------------------------------------------------------- |
---|
| 4103 | function update_plot(handles) |
---|
| 4104 | %------------------------------------------------------------------- |
---|
| 4105 | UvData=get(handles.uvmat,'UserData'); |
---|
[511] | 4106 | AxeData=UvData.PlotAxes;% retrieve the current plotted data |
---|
[387] | 4107 | PlotParam=read_GUI(handles.uvmat); |
---|
[511] | 4108 | [tild,PlotParamOut]= plot_field(AxeData,handles.PlotAxes,PlotParam); |
---|
[595] | 4109 | errormsg=fill_GUI(PlotParamOut,handles.uvmat); |
---|
| 4110 | %write_plot_param(handles,PlotParamOut); %update the auto plot parameters |
---|
[387] | 4111 | |
---|
[402] | 4112 | %------------------------------------------------------------------------ |
---|
| 4113 | %------------------------------------------------------------------------ |
---|
| 4114 | % SELECTION AND EDITION OF PROJECTION OBJECTS |
---|
| 4115 | %------------------------------------------------------------------------ |
---|
| 4116 | %------------------------------------------------------------------------ |
---|
[387] | 4117 | |
---|
[410] | 4118 | % --- Executes on selection change in ListObject_1. |
---|
| 4119 | function ListObject_1_Callback(hObject, eventdata, handles) |
---|
[432] | 4120 | list_str=get(handles.ListObject,'String'); |
---|
[410] | 4121 | UvData=get(handles.uvmat,'UserData'); |
---|
| 4122 | ObjectData=UvData.Object{get(handles.ListObject_1,'Value')}; |
---|
| 4123 | |
---|
| 4124 | %% update the projection plot on uvmat |
---|
[432] | 4125 | ProjData= proj_field(UvData.Field,ObjectData);%project the current input field on object ObjectData |
---|
[511] | 4126 | plot_field(ProjData,handles.PlotAxes,read_GUI(handles.uvmat));% plot the projected field; |
---|
[432] | 4127 | %replot all the objects within the new projected field |
---|
| 4128 | for IndexObj=1:numel(list_str) |
---|
[515] | 4129 | hobject=UvData.Object{IndexObj}.DisplayHandle.uvmat; |
---|
[432] | 4130 | if isempty(hobject) || ~ishandle(hobject) |
---|
[515] | 4131 | hobject=handles.PlotAxes; |
---|
[432] | 4132 | end |
---|
| 4133 | if isequal(IndexObj,get(handles.ListObject,'Value')) |
---|
| 4134 | objectcolor='m'; %paint in magenta the currently selected object in ListObject |
---|
| 4135 | else |
---|
| 4136 | objectcolor='b'; |
---|
| 4137 | end |
---|
| 4138 | UvData.Object{IndexObj}.DisplayHandle.uvmat=plot_object(UvData.Object{IndexObj},ObjectData,hobject,objectcolor);%draw the object in uvmat |
---|
| 4139 | end |
---|
| 4140 | set(handles.uvmat,'UserData',UvData) |
---|
[410] | 4141 | |
---|
| 4142 | %% display the object parameters if the GUI set_object is already opened |
---|
[425] | 4143 | if ~get(handles.ViewObject,'Value') |
---|
[410] | 4144 | ZBounds=0; % default |
---|
| 4145 | if isfield(UvData.Field,'ZMin') && isfield(UvData.Field,'ZMax') |
---|
| 4146 | ZBounds(1)=UvData.Field.ZMin; %minimum for the Z slider |
---|
| 4147 | ZBounds(2)=UvData.Field.ZMax;%maximum for the Z slider |
---|
| 4148 | end |
---|
[425] | 4149 | ObjectData.Name=list_str{get(handles.ListObject_1,'Value')}; |
---|
[410] | 4150 | set_object(ObjectData,[],ZBounds); |
---|
[424] | 4151 | set(handles.ViewObject,'Value',1)% show that the selected object in ListObject_1 is currently visualised |
---|
[410] | 4152 | end |
---|
[432] | 4153 | |
---|
[410] | 4154 | % desactivate the edit object mode |
---|
| 4155 | set(handles.edit_object,'Value',0) |
---|
| 4156 | set(handles.edit_object,'BackgroundColor',[0.7,0.7,0.7]) |
---|
| 4157 | |
---|
[387] | 4158 | %------------------------------------------------------------------------ |
---|
| 4159 | % --- Executes on selection change in ListObject. |
---|
| 4160 | function ListObject_Callback(hObject, eventdata, handles) |
---|
| 4161 | %------------------------------------------------------------------------ |
---|
| 4162 | list_str=get(handles.ListObject,'String'); |
---|
| 4163 | IndexObj=get(handles.ListObject,'Value');%present object selection |
---|
| 4164 | |
---|
[410] | 4165 | %% The object is displayed in set_object if this GUI is already opened |
---|
[402] | 4166 | UvData=get(handles.uvmat,'UserData'); |
---|
[410] | 4167 | ObjectData=UvData.Object{IndexObj}; |
---|
[402] | 4168 | hset_object=findobj(allchild(0),'tag','set_object'); |
---|
| 4169 | if ~isempty(hset_object) |
---|
| 4170 | ZBounds=0; % default |
---|
| 4171 | if isfield(UvData.Field,'ZMin') && isfield(UvData.Field,'ZMax') |
---|
| 4172 | ZBounds(1)=UvData.Field.ZMin; %minimum for the Z slider |
---|
| 4173 | ZBounds(2)=UvData.Field.ZMax;%maximum for the Z slider |
---|
| 4174 | end |
---|
[410] | 4175 | ObjectData.Name=list_str{IndexObj}; |
---|
[402] | 4176 | set_object(ObjectData,[],ZBounds); |
---|
[424] | 4177 | set(handles.ViewField,'Value',1)% show that the selected object in ListObject is currently visualised |
---|
[402] | 4178 | end |
---|
[429] | 4179 | |
---|
| 4180 | %% desactivate the edit object mode |
---|
[402] | 4181 | set(handles.edit_object,'Value',0) |
---|
| 4182 | set(handles.edit_object,'BackgroundColor',[0.7,0.7,0.7]) |
---|
| 4183 | |
---|
[429] | 4184 | %% update the plot on view_field if view_field is already openened |
---|
| 4185 | hview_field=findobj(allchild(0),'tag','view_field'); |
---|
| 4186 | if isempty(hview_field) |
---|
[511] | 4187 | hhview_field.PlotAxes=[]; |
---|
[429] | 4188 | else |
---|
| 4189 | Data=get(hview_field,'UserData'); |
---|
| 4190 | hhview_field=guidata(hview_field); |
---|
| 4191 | ProjData= proj_field(UvData.Field,ObjectData);%project the current interface field on ObjectData |
---|
[595] | 4192 | [PlotType,PlotParam]=plot_field(ProjData,hhview_field.PlotAxes,read_GUI(hview_field));%read plotting parameters on the uvmat interface |
---|
| 4193 | |
---|
| 4194 | %write_plot_param(hhview_field,PlotParam); %update the display of plotting parameters for the current object |
---|
[429] | 4195 | haxes=findobj(hview_field,'tag','axes3'); |
---|
| 4196 | pos=get(hview_field,'Position'); |
---|
| 4197 | if strcmp(get(haxes,'Visible'),'off')%sempty(PlotParam.Coordinates)% case of no plot display (pure text table) |
---|
| 4198 | h_TableDisplay=findobj(hview_field,'tag','TableDisplay'); |
---|
| 4199 | pos_table=get(h_TableDisplay,'Position'); |
---|
| 4200 | set(hview_field,'Position',[pos(1)+pos(3)-pos_table(3) pos(2)+pos(4)-pos_table(4) pos_table(3) pos_table(4)]) |
---|
| 4201 | drawnow% needed to change position before the next command |
---|
| 4202 | set(hview_field,'UserData',Data);% restore the previously stored GUI position after GUI resizing |
---|
| 4203 | else |
---|
| 4204 | set(hview_field,'Position',Data.GUISize)% return to the previously stored GUI position and size |
---|
[387] | 4205 | end |
---|
| 4206 | end |
---|
| 4207 | |
---|
[402] | 4208 | %% update the color of the graphic object representation: the selected object in magenta, others in blue |
---|
[511] | 4209 | update_object_color(handles.PlotAxes,hhview_field.PlotAxes,UvData.Object{IndexObj}.DisplayHandle.uvmat) |
---|
[387] | 4210 | |
---|
| 4211 | %------------------------------------------------------------------------ |
---|
[402] | 4212 | %--- update the color representation of objects (indicating the selected ones) |
---|
| 4213 | function update_object_color(axes_uvmat,axes_view_field,DisplayHandle) |
---|
[387] | 4214 | %------------------------------------------------------------------------ |
---|
[402] | 4215 | if isempty(axes_view_field)% case with no view_field plot |
---|
| 4216 | hother=[findobj(axes_uvmat,'Tag','proj_object');findobj(axes_uvmat,'Tag','DeformPoint')];%find all the proj object and deform point representations |
---|
[387] | 4217 | else |
---|
[402] | 4218 | hother=[findobj(axes_uvmat,'Tag','proj_object') ;findobj(axes_view_field,'Tag','proj_object');... %find all the proj object representations |
---|
| 4219 | findobj(axes_uvmat,'Tag','DeformPoint'); findobj(axes_view_field,'Tag','DeformPoint')];%find all the deform point representations |
---|
[387] | 4220 | end |
---|
| 4221 | for iobj=1:length(hother) |
---|
| 4222 | if isequal(get(hother(iobj),'Type'),'rectangle')||isequal(get(hother(iobj),'Type'),'patch') |
---|
| 4223 | set(hother(iobj),'EdgeColor','b') |
---|
| 4224 | if isequal(get(hother(iobj),'FaceColor'),'m') |
---|
| 4225 | set(hother(iobj),'FaceColor','b') |
---|
| 4226 | end |
---|
| 4227 | elseif isequal(get(hother(iobj),'Type'),'image') |
---|
| 4228 | Acolor=get(hother(iobj),'CData'); |
---|
| 4229 | Acolor(:,:,1)=zeros(size(Acolor,1),size(Acolor,2)); |
---|
| 4230 | set(hother(iobj),'CData',Acolor); |
---|
| 4231 | else |
---|
| 4232 | set(hother(iobj),'Color','b') |
---|
| 4233 | end |
---|
| 4234 | set(hother(iobj),'Selected','off') |
---|
| 4235 | end |
---|
[432] | 4236 | if ishandle(DisplayHandle) |
---|
[402] | 4237 | linetype=get(DisplayHandle,'Type'); |
---|
| 4238 | if isequal(linetype,'line') |
---|
| 4239 | set(DisplayHandle,'Color','m'); %set the selected object to magenta color |
---|
| 4240 | elseif isequal(linetype,'rectangle') |
---|
| 4241 | set(DisplayHandle,'EdgeColor','m'); %set the selected object to magenta color |
---|
| 4242 | elseif isequal(linetype,'patch') |
---|
| 4243 | set(DisplayHandle,'FaceColor','m'); %set the selected object to magenta color |
---|
| 4244 | end |
---|
| 4245 | SubObjectData=get(DisplayHandle,'UserData'); |
---|
| 4246 | if isfield(SubObjectData,'SubObject') & ishandle(SubObjectData.SubObject) |
---|
| 4247 | for iobj=1:length(SubObjectData.SubObject) |
---|
| 4248 | hsub=SubObjectData.SubObject(iobj); |
---|
| 4249 | if isequal(get(hsub,'Type'),'rectangle') |
---|
| 4250 | set(hsub,'EdgeColor','m'); %set the selected object to magenta color |
---|
| 4251 | elseif isequal(get(hsub,'Type'),'image') |
---|
| 4252 | Acolor=get(hsub,'CData'); |
---|
| 4253 | Acolor(:,:,1)=Acolor(:,:,3); |
---|
| 4254 | set(hsub,'CData',Acolor); |
---|
| 4255 | else |
---|
| 4256 | set(hsub,'Color','m') |
---|
| 4257 | end |
---|
[387] | 4258 | end |
---|
| 4259 | end |
---|
[402] | 4260 | if isfield(SubObjectData,'DeformPoint') & ishandle(SubObjectData.DeformPoint) |
---|
| 4261 | set(SubObjectData.DeformPoint,'Color','m') |
---|
| 4262 | end |
---|
[387] | 4263 | end |
---|
[402] | 4264 | |
---|
[427] | 4265 | %------------------------------------------------------------------- |
---|
| 4266 | % --- Executes on selection change in edit_object. |
---|
| 4267 | function edit_object_Callback(hObject, eventdata, handles) |
---|
| 4268 | %------------------------------------------------------------------- |
---|
| 4269 | hset_object=findobj(allchild(0),'Tag','set_object'); |
---|
| 4270 | if get(handles.edit_object,'Value') |
---|
| 4271 | set(handles.edit_object,'BackgroundColor',[1,1,0]) |
---|
| 4272 | %suppress the other options |
---|
| 4273 | set(handles.CheckZoom,'Value',0) |
---|
| 4274 | CheckZoom_Callback(hObject, eventdata, handles) |
---|
| 4275 | hgeometry_calib=findobj(allchild(0),'tag','geometry_calib'); |
---|
| 4276 | if ishandle(hgeometry_calib) |
---|
| 4277 | hhgeometry_calib=guidata(hgeometry_calib); |
---|
| 4278 | set(hhgeometry_calib.edit_append,'Value',0)% desactivate mouse action in geometry_calib |
---|
| 4279 | set(hhgeometry_calib.edit_append,'BackgroundColor',[0.7 0.7 0.7]) |
---|
| 4280 | end |
---|
| 4281 | set(handles.ViewObject,'value',1) |
---|
| 4282 | ViewObject_Callback(hObject, eventdata, handles) |
---|
| 4283 | else % desctivate object edit mode |
---|
| 4284 | set(handles.edit_object,'BackgroundColor',[0.7,0.7,0.7]) |
---|
| 4285 | if ~isempty(hset_object)% open the |
---|
| 4286 | hhset_object=guidata(hset_object); |
---|
| 4287 | set(hhset_object.PLOT,'enable','off'); |
---|
| 4288 | set(get(hset_object,'children'),'enable','inactive') |
---|
| 4289 | end |
---|
| 4290 | end |
---|
| 4291 | |
---|
| 4292 | |
---|
[402] | 4293 | %------------------------------------------------------------------------ |
---|
[424] | 4294 | % --- Executes on button press in ViewObject. |
---|
| 4295 | function ViewObject_Callback(hObject, eventdata, handles) |
---|
[410] | 4296 | %------------------------------------------------------------------------ |
---|
[424] | 4297 | check_view=get(handles.ViewObject,'Value'); |
---|
[410] | 4298 | |
---|
| 4299 | if check_view %activate set_object |
---|
[424] | 4300 | IndexObj=get(handles.ListObject,'Value'); |
---|
| 4301 | list_object=get(handles.ListObject,'String'); |
---|
[410] | 4302 | UvData=get(handles.uvmat,'UserData');%read UvData properties stored on the uvmat interface |
---|
| 4303 | UvData.Object{IndexObj}.Name=list_object{IndexObj}; |
---|
| 4304 | if numel(UvData.Object)<IndexObj;% error in UvData |
---|
| 4305 | msgbox_uvmat('ERROR','invalid object list') |
---|
| 4306 | return |
---|
| 4307 | end |
---|
| 4308 | ZBounds=0; % default |
---|
| 4309 | if isfield(UvData.Field,'ZMin') && isfield(UvData.Field,'ZMax') |
---|
| 4310 | ZBounds(1)=UvData.Field.ZMin; %minimum for the Z slider |
---|
| 4311 | ZBounds(2)=UvData.Field.ZMax;%maximum for the Z slider |
---|
| 4312 | end |
---|
[424] | 4313 | % set(handles.ListObject_1,'Value',IndexObj);%restore ListObject selection after set_object deletion |
---|
[410] | 4314 | data=UvData.Object{IndexObj}; |
---|
| 4315 | if ~isfield(data,'Type')% default plane |
---|
| 4316 | data.Type='plane'; |
---|
| 4317 | end |
---|
[515] | 4318 | % if isfield(UvData,'Field') |
---|
| 4319 | % Field=UvData.Field; |
---|
| 4320 | % if isfield(UvData.Field,'Mesh')&&~isempty(UvData.Field.Mesh) |
---|
| 4321 | % data.RangeX=[UvData.Field.XMin UvData.Field.XMax]; |
---|
| 4322 | % if strcmp(data.Type,'line')||strcmp(data.Type,'polyline') |
---|
| 4323 | % data.RangeY=UvData.Field.Mesh; |
---|
| 4324 | % else |
---|
| 4325 | % data.RangeY=[UvData.Field.YMin UvData.Field.YMax]; |
---|
| 4326 | % end |
---|
| 4327 | % data.DX=UvData.Field.Mesh; |
---|
| 4328 | % data.DY=UvData.Field.Mesh; |
---|
| 4329 | % end |
---|
| 4330 | % if isfield(Field,'NbDim')&& isequal(Field.NbDim,3) |
---|
| 4331 | % data.Coord=[0 0 0]; %default |
---|
| 4332 | % end |
---|
| 4333 | % if isfield(Field,'CoordUnit') |
---|
| 4334 | % data.CoordUnit=Field.CoordUnit; |
---|
| 4335 | % end |
---|
| 4336 | % end |
---|
[410] | 4337 | hset_object=set_object(data,[],ZBounds); |
---|
| 4338 | hhset_object=guidata(hset_object); |
---|
| 4339 | if get(handles.edit_object,'Value')% edit mode |
---|
| 4340 | set(hhset_object.PLOT,'Enable','on') |
---|
[424] | 4341 | set(get(hset_object,'children'),'enable','on') |
---|
[410] | 4342 | else |
---|
| 4343 | set(hhset_object.PLOT,'Enable','off') |
---|
[427] | 4344 | set(get(hset_object,'children'),'enable','inactive')% deactivate the GUI except SAVE |
---|
| 4345 | set(hhset_object.SAVE,'Enable','on') |
---|
[410] | 4346 | end |
---|
| 4347 | else |
---|
| 4348 | hset_object=findobj(allchild(0),'tag','set_object'); |
---|
| 4349 | if ~isempty(hset_object) |
---|
| 4350 | delete(hset_object)% delete existing version of set_object |
---|
| 4351 | end |
---|
| 4352 | end |
---|
| 4353 | |
---|
[424] | 4354 | |
---|
[410] | 4355 | %------------------------------------------------------------------------ |
---|
[424] | 4356 | % --- Executes on button press in ViewField. |
---|
| 4357 | function ViewField_Callback(hObject, eventdata, handles) |
---|
[402] | 4358 | %------------------------------------------------------------------------ |
---|
[424] | 4359 | check_view=get(handles.ViewField,'Value'); |
---|
[387] | 4360 | |
---|
[410] | 4361 | if check_view |
---|
| 4362 | IndexObj=get(handles.ListObject,'Value'); |
---|
| 4363 | UvData=get(handles.uvmat,'UserData');%read UvData properties stored on the uvmat interface |
---|
| 4364 | if numel(UvData.Object)<IndexObj(end);% error in UvData |
---|
| 4365 | msgbox_uvmat('ERROR','invalid object list') |
---|
| 4366 | return |
---|
| 4367 | end |
---|
| 4368 | ZBounds=0; % default |
---|
| 4369 | if isfield(UvData.Field,'ZMin') && isfield(UvData.Field,'ZMax') |
---|
| 4370 | ZBounds(1)=UvData.Field.ZMin; %minimum for the Z slider |
---|
| 4371 | ZBounds(2)=UvData.Field.ZMax;%maximum for the Z slider |
---|
| 4372 | end |
---|
| 4373 | set(handles.ListObject,'Value',IndexObj);%restore ListObject selection after set_object deletion |
---|
| 4374 | if ~isfield(UvData.Object{IndexObj(1)},'Type')% default plane |
---|
| 4375 | UvData.Object{IndexObj(1)}.Type='plane'; |
---|
| 4376 | end |
---|
| 4377 | list_object=get(handles.ListObject,'String'); |
---|
| 4378 | UvData.Object{IndexObj(end)}.Name=list_object{IndexObj(end)}; |
---|
| 4379 | |
---|
[429] | 4380 | %% show the projection of the selected object on view_field |
---|
| 4381 | ProjData= proj_field(UvData.Field,UvData.Object{IndexObj});%project the current field on ObjectData |
---|
[402] | 4382 | hview_field=findobj(allchild(0),'tag','view_field'); |
---|
| 4383 | if isempty(hview_field) |
---|
| 4384 | hview_field=view_field; |
---|
| 4385 | end |
---|
[429] | 4386 | hhview_field=guidata(hview_field); |
---|
[511] | 4387 | [PlotType,PlotParam]=plot_field(ProjData,hhview_field.PlotAxes,read_GUI(hview_field));%read plotting parameters on the GUI view_field); |
---|
[595] | 4388 | errormsg=fill_GUI(PlotParam,hview_field); |
---|
[598] | 4389 | for list={'Scalar','Vectors'} |
---|
| 4390 | if ~isfield(PlotParamOut,list{1}) |
---|
| 4391 | set(hhview_field.(list{1}),'Visible','off') |
---|
| 4392 | end |
---|
| 4393 | end |
---|
[595] | 4394 | %write_plot_param(hhview_field,PlotParam); %update the display of plotting parameters for the current object |
---|
[429] | 4395 | haxes=findobj(hview_field,'tag','axes3'); |
---|
| 4396 | pos=get(hview_field,'Position'); |
---|
| 4397 | if strcmp(get(haxes,'Visible'),'off')%sempty(PlotParam.Coordinates)% case of no plot display (pure text table) |
---|
| 4398 | h_TableDisplay=findobj(hview_field,'tag','TableDisplay'); |
---|
| 4399 | pos_table=get(h_TableDisplay,'Position'); |
---|
| 4400 | set(hview_field,'Position',[pos(1)+pos(3)-pos_table(3) pos(2)+pos(4)-pos_table(4) pos_table(3) pos_table(4)]) |
---|
| 4401 | else |
---|
| 4402 | Data=get(hview_field,'UserData'); |
---|
[432] | 4403 | set(hview_field,'Position',Data.GUISize)% restore the size of view_field for plots |
---|
[429] | 4404 | end |
---|
[410] | 4405 | else |
---|
[424] | 4406 | hview_field=findobj(allchild(0),'tag','view_field'); |
---|
| 4407 | if ~isempty(hview_field) |
---|
| 4408 | delete(hview_field)% delete existing version of set_object |
---|
[410] | 4409 | end |
---|
[402] | 4410 | end |
---|
| 4411 | |
---|
[424] | 4412 | |
---|
[402] | 4413 | %------------------------------------------------------------------------ |
---|
| 4414 | % --- Executes on button press in delete_object. |
---|
| 4415 | function delete_object_Callback(hObject, eventdata, handles) |
---|
| 4416 | %------------------------------------------------------------------------ |
---|
[499] | 4417 | IndexObj=get(handles.ListObject,'Value');%projection object selected for view_field |
---|
| 4418 | IndexObj_1=get(handles.ListObject_1,'Value');%projection object selected for uvmat plot |
---|
| 4419 | if IndexObj>1 && ~isequal(IndexObj,IndexObj_1) % do not delete the object used for the uvmat plot |
---|
[410] | 4420 | delete_object(IndexObj) |
---|
[402] | 4421 | end |
---|
| 4422 | |
---|
| 4423 | %------------------------------------------------------------------------ |
---|
| 4424 | %------------------------------------------------------------------------ |
---|
| 4425 | % II - TOOLS FROM THE UPPER MENU BAR |
---|
| 4426 | %------------------------------------------------------------------------ |
---|
| 4427 | %------------------------------------------------------------------------ |
---|
| 4428 | |
---|
| 4429 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
---|
| 4430 | % Export Menu Callbacks |
---|
| 4431 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
---|
| 4432 | %------------------------------------------------------------------------ |
---|
[387] | 4433 | % --- Executes on button press in Menu/Export/field in workspace. |
---|
| 4434 | function MenuExportField_Callback(hObject, eventdata, handles) |
---|
[402] | 4435 | %------------------------------------------------------------------------ |
---|
[387] | 4436 | global Data_uvmat |
---|
| 4437 | Data_uvmat=get(handles.uvmat,'UserData'); |
---|
| 4438 | evalin('base','global Data_uvmat')%make CurData global in the workspace |
---|
| 4439 | display('current field :') |
---|
| 4440 | evalin('base','Data_uvmat') %display CurData in the workspace |
---|
| 4441 | commandwindow; %brings the Matlab command window to the front |
---|
| 4442 | |
---|
[402] | 4443 | %------------------------------------------------------------------------ |
---|
[387] | 4444 | % --- Executes on button press in Menu/Export/extract figure. |
---|
[402] | 4445 | function MenuExportFigure_Callback(hObject, eventdata, handles) |
---|
| 4446 | %------------------------------------------------------------------------ |
---|
| 4447 | % huvmat=get(handles.MenuExport,'parent'); |
---|
[387] | 4448 | hfig=figure; |
---|
[511] | 4449 | copyobj(handles.PlotAxes,hfig); |
---|
| 4450 | map=colormap(handles.PlotAxes); |
---|
[387] | 4451 | colormap(map);%transmit the current colormap to the zoom fig |
---|
| 4452 | colorbar |
---|
| 4453 | |
---|
[508] | 4454 | % -------------------------------------------------------------------- |
---|
| 4455 | function MenuExportAxis_Callback(hObject, eventdata, handles) |
---|
[581] | 4456 | ListFig=findobj(allchild(0),'Type','figure'); |
---|
| 4457 | nb_option=0; |
---|
| 4458 | menu={}; |
---|
| 4459 | for ilist=1:numel(ListFig) |
---|
| 4460 | FigName=get(ListFig(ilist),'name'); |
---|
| 4461 | if isempty(FigName) |
---|
| 4462 | FigName=['figure ' num2str(ListFig(ilist))]; |
---|
| 4463 | end |
---|
| 4464 | if ~strcmp(FigName,'uvmat') |
---|
| 4465 | ListAxes=findobj(ListFig(ilist),'Type','axes'); |
---|
| 4466 | ListTags=get(ListAxes,'Tag'); |
---|
| 4467 | if ~isempty(ListTags) && ~isempty(find(~strcmp('Colorbar',ListTags), 1)) |
---|
| 4468 | ListAxes=ListAxes(~strcmp('Colorbar',ListTags)); |
---|
| 4469 | if numel(ListAxes)==1 |
---|
| 4470 | nb_option=nb_option+1; |
---|
| 4471 | menu{nb_option}=FigName ; |
---|
| 4472 | AxesHandle(nb_option)=ListAxes; |
---|
| 4473 | else |
---|
| 4474 | nb_axis=0; |
---|
| 4475 | for iaxes=1:numel(ListAxes) |
---|
| 4476 | nb_axis=nb_axis+1; |
---|
| 4477 | nb_option=nb_option+1; |
---|
| 4478 | menu{nb_option}=[FigName '_' num2str(nb_axis)]; |
---|
| 4479 | AxesHandle(nb_option)=ListAxes(nb_axis); |
---|
| 4480 | end |
---|
| 4481 | end |
---|
| 4482 | end |
---|
| 4483 | end |
---|
[508] | 4484 | end |
---|
[581] | 4485 | if isempty(menu) |
---|
| 4486 | answer=msgbox_uvmat('INPUT_Y-N','no existing plotting axes available, create new figure?'); |
---|
| 4487 | if strcmp(answer,'Yes') |
---|
| 4488 | hfig=figure; |
---|
| 4489 | copyobj(handles.PlotAxes,hfig); |
---|
| 4490 | else |
---|
| 4491 | return |
---|
| 4492 | end |
---|
| 4493 | map=colormap(handles.PlotAxes); |
---|
| 4494 | colormap(map);%transmit the current colormap to the zoom fig |
---|
| 4495 | colorbar |
---|
| 4496 | else |
---|
| 4497 | answer=msgbox_uvmat('INPUT_MENU','select a figure/axis on which the current uvmat plot will be exported',menu); |
---|
| 4498 | if isempty(answer) |
---|
| 4499 | return |
---|
| 4500 | else |
---|
| 4501 | axes(AxesHandle(answer)) |
---|
| 4502 | hold on |
---|
| 4503 | hchild=get(handles.PlotAxes,'children'); |
---|
| 4504 | copyobj(hchild,gca); |
---|
| 4505 | end |
---|
| 4506 | end |
---|
[387] | 4507 | |
---|
[581] | 4508 | |
---|
[387] | 4509 | %------------------------------------------------------------------------ |
---|
| 4510 | % -------------------------------------------------------------------- |
---|
| 4511 | function MenuExportMovie_Callback(hObject, eventdata, handles) |
---|
| 4512 | % -------------------------------------------------------------------- |
---|
| 4513 | set(handles.MenuExportMovie,'BusyAction','queue')% activate the button |
---|
| 4514 | huvmat=get(handles.run0,'parent'); |
---|
| 4515 | UvData=get(huvmat,'UserData'); |
---|
| 4516 | %[xx,xx,FileBase]=read_file_boxes(handles); |
---|
[515] | 4517 | [RootPath,SubDir,RootFile,FileIndex,FileExt]=read_file_boxes(handles); |
---|
[387] | 4518 | FileBase=fullfile(RootPath,RootFile); |
---|
| 4519 | %read the current input file name |
---|
| 4520 | 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)'}; |
---|
| 4521 | dlg_title = 'select properties of the output avi movie'; |
---|
| 4522 | num_lines= 1; |
---|
| 4523 | def = {[FileBase '_out.avi'];'10';'1';'[0.03 0.05 0.95 0.92]';'10'}; |
---|
| 4524 | answer = inputdlg(prompt,dlg_title,num_lines,def,'on'); |
---|
| 4525 | aviname=answer{1}; |
---|
| 4526 | fps=str2double(answer{2}); |
---|
| 4527 | % check for existing file with output name aviname |
---|
| 4528 | if exist(aviname,'file') |
---|
| 4529 | backup=aviname; |
---|
| 4530 | testexist=2; |
---|
| 4531 | while testexist==2 |
---|
| 4532 | backup=[backup '~']; |
---|
| 4533 | testexist=exist(backup,'file'); |
---|
| 4534 | end |
---|
| 4535 | [success,message]=copyfile(aviname,backup);%make backup of the existing file |
---|
| 4536 | if isequal(success,1) |
---|
| 4537 | delete(aviname)%delete existing file |
---|
| 4538 | else |
---|
| 4539 | msgbox_uvmat('ERROR',message) |
---|
| 4540 | return |
---|
| 4541 | end |
---|
| 4542 | end |
---|
| 4543 | %create avi open |
---|
| 4544 | aviobj=avifile(aviname,'Compression','None','fps',fps); |
---|
| 4545 | |
---|
| 4546 | %display first view for tests |
---|
| 4547 | newfig=figure; |
---|
[511] | 4548 | newaxes=copyobj(handles.PlotAxes,newfig);%new plotting axes in the new figure |
---|
[387] | 4549 | set(newaxes,'Tag','movieaxes') |
---|
| 4550 | nbpix=[512 384]*str2double(answer{3}); |
---|
| 4551 | set(gcf,'Position',[1 1 nbpix])% resolution XVGA |
---|
| 4552 | set(newaxes,'Position',eval(answer{4})); |
---|
[511] | 4553 | map=colormap(handles.PlotAxes); |
---|
[387] | 4554 | colormap(map);%transmit the current colormap to the zoom fig |
---|
| 4555 | msgbox_uvmat('INPUT_Y-N',{['adjust figure ' num2str(newfig) ' with its matlab edit menu '] ;... |
---|
| 4556 | ['then press OK to get the avi movie as a copy of figure ' num2str(newfig) ' display']}); |
---|
| 4557 | UvData.plotaxes=newaxes;% the axis in the new figure becomes the current main plotting axes |
---|
| 4558 | set(huvmat,'UserData',UvData); |
---|
[511] | 4559 | increment=str2num(get(handles.num_IndexIncrement,'String')); %get the field increment d |
---|
[387] | 4560 | set(handles.STOP,'Visible','on') |
---|
| 4561 | set(handles.speed,'Visible','on') |
---|
| 4562 | set(handles.speed_txt,'Visible','on') |
---|
| 4563 | set(handles.Movie,'BusyAction','queue') |
---|
| 4564 | |
---|
| 4565 | %imin=str2double(get(handles.i1,'String')); |
---|
| 4566 | imax=str2double(answer{5}); |
---|
| 4567 | % if isfield(UvData,'Time') |
---|
| 4568 | htitle=get(newaxes,'Title'); |
---|
| 4569 | xlim=get(newaxes,'XLim'); |
---|
| 4570 | ylim=get(newaxes,'YLim'); |
---|
| 4571 | set(htitle,'Position',[xlim(2)+0.07*(xlim(2)-xlim(1)) ylim(2)-0.05*(ylim(2)-ylim(1)) 0]) |
---|
| 4572 | time_str=get(handles.abs_time,'String'); |
---|
| 4573 | set(htitle,'String',['t=' time_str]) |
---|
| 4574 | set(handles.speed,'Value',1) |
---|
| 4575 | for i=1:imax |
---|
| 4576 | if get(handles.speed,'Value')~=0 && isequal(get(handles.MenuExportMovie,'BusyAction'),'queue') % enable STOP command |
---|
| 4577 | runpm(hObject,eventdata,handles,increment)% run plus |
---|
| 4578 | drawnow |
---|
| 4579 | time_str=get(handles.abs_time,'String'); |
---|
| 4580 | if ishandle(htitle) |
---|
| 4581 | set(htitle,'String',['t=' time_str]) |
---|
| 4582 | end |
---|
| 4583 | mov=getframe(newfig); |
---|
| 4584 | aviobj=addframe(aviobj,mov); |
---|
| 4585 | end |
---|
| 4586 | end |
---|
| 4587 | aviobj=close(aviobj); |
---|
| 4588 | UvData=rmfield(UvData,'plotaxes'); |
---|
[511] | 4589 | %UvData.Object{1}.plotaxes=handles.PlotAxes; |
---|
[387] | 4590 | set(huvmat,'UserData',UvData); |
---|
| 4591 | msgbox_uvmat('CONFIRMATION',{['movie ' aviname ' created '];['with ' num2str(imax) ' frames']}) |
---|
| 4592 | |
---|
[402] | 4593 | |
---|
| 4594 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
---|
| 4595 | % Projection Objects Menu Callbacks |
---|
| 4596 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
---|
| 4597 | |
---|
| 4598 | % ----------------------------------------------------------------------- |
---|
| 4599 | function Menupoints_Callback(hObject, eventdata, handles) |
---|
[387] | 4600 | %------------------------------------------------------------------------ |
---|
[402] | 4601 | data.Type='points'; |
---|
| 4602 | data.ProjMode='projection';%default |
---|
[410] | 4603 | data.ProjModeMenu={};% do not restrict ProjMode menus |
---|
[402] | 4604 | create_object(data,handles) |
---|
| 4605 | |
---|
| 4606 | % ----------------------------------------------------------------------- |
---|
| 4607 | function Menuline_Callback(hObject, eventdata, handles) |
---|
| 4608 | %------------------------------------------------------------------------ |
---|
| 4609 | data.Type='line'; |
---|
| 4610 | data.ProjMode='projection';%default |
---|
[410] | 4611 | data.ProjModeMenu={};% do not restrict ProjMode menus |
---|
[402] | 4612 | create_object(data,handles) |
---|
| 4613 | |
---|
| 4614 | %------------------------------------------------------------------------ |
---|
| 4615 | function Menupolyline_Callback(hObject, eventdata, handles) |
---|
| 4616 | %------------------------------------------------------------------------ |
---|
| 4617 | data.Type='polyline'; |
---|
| 4618 | data.ProjMode='projection';%default |
---|
[410] | 4619 | data.ProjModeMenu={};% do not restrict ProjMode menus |
---|
[402] | 4620 | create_object(data,handles) |
---|
| 4621 | |
---|
| 4622 | %------------------------------------------------------------------------ |
---|
| 4623 | function Menupolygon_Callback(hObject, eventdata, handles) |
---|
| 4624 | %------------------------------------------------------------------------ |
---|
| 4625 | data.Type='polygon'; |
---|
| 4626 | data.ProjMode='inside';%default |
---|
[410] | 4627 | data.ProjModeMenu={};% do not restrict ProjMode menus |
---|
[402] | 4628 | create_object(data,handles) |
---|
| 4629 | |
---|
| 4630 | %------------------------------------------------------------------------ |
---|
| 4631 | function Menurectangle_Callback(hObject, eventdata, handles) |
---|
| 4632 | %------------------------------------------------------------------------ |
---|
| 4633 | data.Type='rectangle'; |
---|
| 4634 | data.ProjMode='inside';%default |
---|
[410] | 4635 | data.ProjModeMenu={};% do not restrict ProjMode menus |
---|
[402] | 4636 | create_object(data,handles) |
---|
| 4637 | |
---|
| 4638 | %------------------------------------------------------------------------ |
---|
| 4639 | function Menuellipse_Callback(hObject, eventdata, handles) |
---|
| 4640 | %------------------------------------------------------------------------ |
---|
| 4641 | data.Type='ellipse'; |
---|
| 4642 | data.ProjMode='inside';%default |
---|
[410] | 4643 | data.ProjModeMenu={};% do not restrict ProjMode menus |
---|
[402] | 4644 | create_object(data,handles) |
---|
| 4645 | |
---|
| 4646 | %------------------------------------------------------------------------ |
---|
| 4647 | function MenuMaskObject_Callback(hObject, eventdata, handles) |
---|
| 4648 | %------------------------------------------------------------------------ |
---|
| 4649 | data.Type='polygon'; |
---|
| 4650 | data.TypeMenu={'polygon'}; |
---|
| 4651 | data.ProjMode='mask_inside';%default |
---|
| 4652 | data.ProjModeMenu={'mask_inside';'mask_outside'}; |
---|
| 4653 | create_object(data,handles) |
---|
| 4654 | |
---|
| 4655 | %------------------------------------------------------------------------ |
---|
| 4656 | function Menuplane_Callback(hObject, eventdata, handles) |
---|
| 4657 | %------------------------------------------------------------------------ |
---|
| 4658 | data.Type='plane'; |
---|
| 4659 | data.ProjMode='projection';%default |
---|
[410] | 4660 | data.ProjModeMenu={};% do not restrict ProjMode menus |
---|
[402] | 4661 | create_object(data,handles) |
---|
| 4662 | |
---|
| 4663 | %------------------------------------------------------------------------ |
---|
| 4664 | function Menuvolume_Callback(hObject, eventdata, handles) |
---|
| 4665 | %------------------------------------------------------------------------ |
---|
| 4666 | data.Type='volume'; |
---|
[581] | 4667 | data.ProjMode='interp_lin';%default |
---|
[410] | 4668 | data.ProjModeMenu={}; |
---|
[402] | 4669 | % set(handles.create,'Visible','on') |
---|
| 4670 | % set(handles.create,'Value',1) |
---|
[410] | 4671 | % VOLUME_Callback(hObject,eventdata,handles)data.ProjModeMenu={}; |
---|
[402] | 4672 | create_object(data,handles) |
---|
| 4673 | |
---|
| 4674 | %------------------------------------------------------------------------ |
---|
| 4675 | % --- generic function used for the creation of a projection object |
---|
| 4676 | function create_object(data,handles) |
---|
| 4677 | %------------------------------------------------------------------------ |
---|
[410] | 4678 | % desactivate geometric calibration if opened |
---|
[402] | 4679 | hgeometry_calib=findobj(allchild(0),'tag','geometry_calib'); |
---|
| 4680 | if ishandle(hgeometry_calib) |
---|
| 4681 | hhgeometry_calib=guidata(hgeometry_calib); |
---|
| 4682 | set(hhgeometry_calib.edit_append,'Value',0)% desactivate mouse action in geometry_calib |
---|
| 4683 | set(hhgeometry_calib.edit_append,'BackgroundColor',[0.7 0.7 0.7]) |
---|
| 4684 | end |
---|
| 4685 | set(handles.edit_object,'Value',0); %suppress the object edit mode |
---|
| 4686 | set(handles.edit_object,'BackgroundColor',[0.7,0.7,0.7]) |
---|
[429] | 4687 | ListObject=get(handles.ListObject,'String'); |
---|
[534] | 4688 | if isempty(ListObject) |
---|
| 4689 | ListObject={''}; |
---|
| 4690 | end |
---|
[429] | 4691 | if ~strcmp(ListObject{end},'') |
---|
| 4692 | ListObject=[ListObject;{''}]; %append a blank to the list (if nort already done) to indicate the creation of a new object |
---|
| 4693 | set(handles.ListObject,'String',ListObject) |
---|
| 4694 | end |
---|
| 4695 | IndexObj=length(ListObject); |
---|
| 4696 | set(handles.ListObject,'Value',IndexObj) |
---|
[410] | 4697 | UvData=get(handles.uvmat,'UserData'); |
---|
[429] | 4698 | UvData.Object{IndexObj}=[]; %create a new empty object |
---|
[511] | 4699 | UvData.Object{IndexObj}.DisplayHandle.uvmat=handles.PlotAxes; % axes for plot_object |
---|
[432] | 4700 | UvData.Object{IndexObj}.DisplayHandle.view_field=[]; %no plot handle before plot_field operation |
---|
[410] | 4701 | data.Name=data.Type;% default name=type |
---|
[402] | 4702 | data.Coord=[0 0]; %default |
---|
| 4703 | if isfield(UvData,'Field') |
---|
| 4704 | Field=UvData.Field; |
---|
[575] | 4705 | if isfield(UvData.Field,'CoordMesh')&&~isempty(UvData.Field.CoordMesh) |
---|
[404] | 4706 | data.RangeX=[UvData.Field.XMin UvData.Field.XMax]; |
---|
[410] | 4707 | if strcmp(data.Type,'line')||strcmp(data.Type,'polyline')||strcmp(data.Type,'points') |
---|
[575] | 4708 | data.RangeY=UvData.Field.CoordMesh; |
---|
[406] | 4709 | else |
---|
| 4710 | data.RangeY=[UvData.Field.YMin UvData.Field.YMax]; |
---|
| 4711 | end |
---|
[575] | 4712 | data.DX=UvData.Field.CoordMesh; |
---|
| 4713 | data.DY=UvData.Field.CoordMesh; |
---|
[402] | 4714 | end |
---|
| 4715 | if isfield(Field,'NbDim')&& isequal(Field.NbDim,3) |
---|
| 4716 | data.Coord=[0 0 0]; %default |
---|
| 4717 | end |
---|
| 4718 | if isfield(Field,'CoordUnit') |
---|
| 4719 | data.CoordUnit=Field.CoordUnit; |
---|
| 4720 | end |
---|
| 4721 | end |
---|
| 4722 | if ishandle(handles.UVMAT_title) |
---|
| 4723 | delete(handles.UVMAT_title)%delete the initial display of uvmat if no field has been entered |
---|
| 4724 | end |
---|
| 4725 | hset_object=set_object(data,handles);% call the set_object interface |
---|
| 4726 | hhset_object=guidata(hset_object); |
---|
[421] | 4727 | hchild=get(hset_object,'children'); |
---|
| 4728 | set(hchild,'enable','on') |
---|
[402] | 4729 | set(handles.uvmat,'UserData',UvData) |
---|
[410] | 4730 | set(handles.CheckZoom,'Value',0) %desactivate the zoom for object creation by the mouse |
---|
[402] | 4731 | CheckZoom_Callback(handles.uvmat, [], handles) |
---|
| 4732 | set(handles.delete_object,'Visible','on') |
---|
| 4733 | |
---|
| 4734 | %------------------------------------------------------------------------ |
---|
| 4735 | function MenuBrowseObject_Callback(hObject, eventdata, handles) |
---|
| 4736 | %------------------------------------------------------------------------ |
---|
| 4737 | %get the object file |
---|
| 4738 | [FileName, PathName, filterindex] = uigetfile( ... |
---|
| 4739 | {'*.xml;*.mat', ' (*.xml,*.mat)'; |
---|
| 4740 | '*.xml', '.xml files '; ... |
---|
| 4741 | '*.mat', '.mat matlab files '}, ... |
---|
| 4742 | 'Pick an xml Object file',get(handles.RootPath,'String')); |
---|
| 4743 | fileinput=[PathName FileName];%complete file name |
---|
| 4744 | sizf=size(fileinput); |
---|
| 4745 | if (~ischar(fileinput)||~isequal(sizf(1),1)),return;end |
---|
| 4746 | |
---|
| 4747 | %read the file |
---|
[477] | 4748 | [data,heading]=xml2struct(fileinput); |
---|
| 4749 | if ~strcmp(heading,'ProjObject') |
---|
| 4750 | msgbox_uvmat('WARNING','The xml file does not have the heading ProjObject for projection objects') |
---|
| 4751 | end |
---|
[427] | 4752 | [tild,data.Name]=fileparts(FileName);% object name set as file name |
---|
[429] | 4753 | ListObject=get(handles.ListObject,'String'); |
---|
| 4754 | if ~strcmp(ListObject{end},'') |
---|
| 4755 | ListObject=[ListObject;{''}]; %append a blank to the list (if not already done) to indicate the creation of a new object |
---|
| 4756 | set(handles.ListObject,'String',ListObject) |
---|
| 4757 | end |
---|
[445] | 4758 | IndexObj=length(ListObject); |
---|
| 4759 | |
---|
[432] | 4760 | UvData=get(handles.uvmat,'UserData'); |
---|
| 4761 | UvData.Object{IndexObj}=[]; %create a new empty object |
---|
| 4762 | UvData.Object{IndexObj}.DisplayHandle.uvmat=[]; %no plot handle before plot_field operation |
---|
| 4763 | UvData.Object{IndexObj}.DisplayHandle.view_field=[]; %no plot handle before plot_field operation |
---|
| 4764 | set(handles.uvmat,'UserData',UvData) |
---|
[445] | 4765 | set(handles.ListObject,'Value',IndexObj) |
---|
[427] | 4766 | hset_object=set_object(data);% call the set_object interface |
---|
| 4767 | set(get(hset_object,'children'),'enable','on')% enable edit action on elements on GUI set_object |
---|
[402] | 4768 | set(handles.edit_object,'Value',0); %suppress the object edit mode |
---|
| 4769 | set(handles.edit_object,'BackgroundColor',[0.7,0.7,0.7]) |
---|
| 4770 | set(handles.delete_object,'Visible','on') |
---|
| 4771 | |
---|
[432] | 4772 | |
---|
[402] | 4773 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
---|
| 4774 | % MenuEdit Callbacks |
---|
| 4775 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
---|
| 4776 | %------------------------------------------------------------------------ |
---|
| 4777 | function MenuEditObject_Callback(hObject, eventdata, handles) |
---|
| 4778 | %------------------------------------------------------------------------ |
---|
| 4779 | set(handles.edit_object,'Value',1) |
---|
| 4780 | edit_Callback(hObject, eventdata, handles) |
---|
| 4781 | |
---|
| 4782 | %------------------------------------------------------------------------ |
---|
| 4783 | function MenuEditVectors_Callback(hObject, eventdata, handles) |
---|
| 4784 | %------------------------------------------------------------------------ |
---|
| 4785 | set(handles.edit_vect,'Visible','on') |
---|
| 4786 | set(handles.edit_vect,'Value',1) |
---|
| 4787 | edit_vect_Callback(hObject, eventdata, handles) |
---|
| 4788 | |
---|
| 4789 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
---|
| 4790 | % MenuTools Callbacks |
---|
| 4791 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
---|
| 4792 | %------------------------------------------------------------------------ |
---|
[387] | 4793 | function MenuCalib_Callback(hObject, eventdata, handles) |
---|
| 4794 | %------------------------------------------------------------------------ |
---|
| 4795 | |
---|
| 4796 | UvData=get(handles.uvmat,'UserData');%read UvData properties stored on the uvmat interface |
---|
| 4797 | |
---|
| 4798 | %suppress competing options |
---|
| 4799 | set(handles.CheckZoom,'Value',0) |
---|
| 4800 | set(handles.CheckZoom,'BackgroundColor',[0.7 0.7 0.7]) |
---|
| 4801 | set(handles.ListObject,'Value',1) |
---|
| 4802 | % initiate display of GUI geometry_calib |
---|
| 4803 | data=[]; %default |
---|
| 4804 | if isfield(UvData,'CoordType') |
---|
| 4805 | data.CoordType=UvData.CoordType; |
---|
| 4806 | end |
---|
[515] | 4807 | [RootPath,SubDir,RootFile,FileIndex,FileExt]=read_file_boxes(handles); |
---|
| 4808 | FileName=[fullfile(RootPath,SubDir,RootFile) FileIndex FileExt]; |
---|
[387] | 4809 | set(handles.view_xml,'Backgroundcolor',[1 1 0])%indicate the reading of the current xml file by geometry_calib |
---|
[517] | 4810 | pos_uvmat=get(handles.uvmat,'Position'); |
---|
| 4811 | pos_cal(1)=pos_uvmat(1)+UvData.OpenParam.PosGeometryCalib(1)*pos_uvmat(3); |
---|
| 4812 | pos_cal(2)=pos_uvmat(2)+UvData.OpenParam.PosGeometryCalib(2)*pos_uvmat(4); |
---|
| 4813 | pos_cal(3:4)=UvData.OpenParam.PosGeometryCalib(3:4).* pos_uvmat(3:4); |
---|
[387] | 4814 | geometry_calib(FileName,pos_cal);% call the geometry_calib interface |
---|
| 4815 | set(handles.view_xml,'Backgroundcolor',[1 1 1])%indicate the end of reading of the current xml file by geometry_calib |
---|
| 4816 | set(handles.MenuCalib,'checked','on')% indicate that MenuCalib is activated, test used by mouse action |
---|
| 4817 | |
---|
[566] | 4818 | |
---|
| 4819 | %----------------------------------------------------------------------- |
---|
| 4820 | function MenuLIFCalib_Callback(hObject, eventdata, handles) |
---|
[387] | 4821 | %------------------------------------------------------------------------ |
---|
[567] | 4822 | %% read UvData properties stored on the uvmat interface |
---|
| 4823 | UvData=get(handles.uvmat,'UserData'); |
---|
| 4824 | if isfield(UvData,'XmlData')&& isfield(UvData.XmlData{1},'GeometryCalib') |
---|
| 4825 | XmlData=UvData.XmlData{1}; |
---|
| 4826 | else |
---|
| 4827 | msgbox_uvmat('ERROR','geometric calibration needed: use Tools/geometric calibration in the menu bar'); |
---|
| 4828 | return |
---|
| 4829 | end |
---|
| 4830 | |
---|
| 4831 | %% read lines currently drawn |
---|
[566] | 4832 | ListObj=UvData.Object; |
---|
| 4833 | select=zeros(1,numel(ListObj)); |
---|
| 4834 | for iobj=1:numel(ListObj); |
---|
[567] | 4835 | if isfield(ListObj{iobj},'Type') && strcmp(ListObj{iobj}.Type,'line') |
---|
[566] | 4836 | select(iobj)=1; |
---|
| 4837 | end |
---|
| 4838 | end |
---|
| 4839 | val=find(select); |
---|
| 4840 | if numel(val)<2 |
---|
| 4841 | msgbox_uvmat('ERROR','light rays must be defined by at least two lines created by Projection object/line in the menu bar'); |
---|
| 4842 | return |
---|
| 4843 | else |
---|
[567] | 4844 | set(handles.ListObject,'Value',val);% show the selected lines on the list |
---|
[566] | 4845 | ObjectData=UvData.Object(val); |
---|
| 4846 | for iobj=1:length(ObjectData) |
---|
[567] | 4847 | % if isfield(ObjectData{iobj},'Coord') |
---|
| 4848 | xA(iobj)=ObjectData{iobj}.Coord(1,1); |
---|
| 4849 | yA(iobj)=ObjectData{iobj}.Coord(1,2); |
---|
| 4850 | xB(iobj)=ObjectData{iobj}.Coord(2,1); |
---|
| 4851 | yB(iobj)=ObjectData{iobj}.Coord(2,2); |
---|
| 4852 | % end |
---|
[566] | 4853 | end |
---|
| 4854 | end |
---|
| 4855 | |
---|
[567] | 4856 | %% find the origin as intersection of the two first lines (see http://www.ahristov.com/tutorial/geometry-games/intersection-lines.html ) |
---|
| 4857 | x1=xA(1);x2=xB(1); |
---|
| 4858 | x3=xA(2);x4=xB(2); |
---|
| 4859 | y1=yA(1);y2=yB(1); |
---|
| 4860 | y3=yA(2);y4=yB(2); |
---|
| 4861 | D = (x1-x2)*(y3-y4) -(y1-y2)*(x3-x4); |
---|
| 4862 | if D==0 |
---|
| 4863 | msgbox_uvmat('ERROR','the two lines are parallel'); |
---|
| 4864 | return |
---|
| 4865 | end |
---|
| 4866 | x0=((x3-x4)*(x1*y2-y1*x2)-(x1-x2)*(x3*y4-y3*x4))/D; |
---|
| 4867 | y0=((y3-y4)*(x1*y2-y1*x2)-(y1-y2)*(x3*y4-y3*x4))/D; |
---|
| 4868 | XmlData.Illumination.Origin=[x0 y0]; |
---|
| 4869 | XmlData.PolarCentre=[x0 y0]; |
---|
[566] | 4870 | |
---|
[567] | 4871 | %% display the current image in polar coordinates with origin at the illumination source |
---|
| 4872 | currentdir=pwd; |
---|
| 4873 | uvmatpath=fileparts(which('uvmat')); |
---|
| 4874 | cd(fullfile(uvmatpath,'transform_field')); |
---|
| 4875 | phys_polar=str2func('phys_polar'); |
---|
| 4876 | cd(currentdir) |
---|
| 4877 | DataOut=phys_polar(UvData.Field,XmlData); |
---|
| 4878 | view_field(DataOut); |
---|
[566] | 4879 | |
---|
[567] | 4880 | %% use the third line for reference luminosity |
---|
| 4881 | if numel(val)==3 |
---|
| 4882 | x_ref=linspace(ObjectData{3}.Coord(1,1),ObjectData{3}.Coord(2,1),10); |
---|
| 4883 | y_ref=linspace(ObjectData{3}.Coord(1,2),ObjectData{3}.Coord(2,2),10); |
---|
| 4884 | x_ref=x_ref-x0; |
---|
| 4885 | y_ref=y_ref-y0; |
---|
| 4886 | [theta_ref,r_ref] = cart2pol(x_ref,y_ref);%theta_ref and r_ref are the polar coordinates of the points on the line |
---|
| 4887 | theta_ref=theta_ref*180/pi; |
---|
| 4888 | figure |
---|
| 4889 | plot(theta_ref,r_ref) |
---|
| 4890 | azimuth_ima=linspace(DataOut.AY(1),DataOut.AY(2),size(DataOut.A,1));%profile of x index on the transformed image |
---|
| 4891 | dist_source = interp1(theta_ref,r_ref,azimuth_ima); |
---|
| 4892 | dist_source_pixel=round(size(DataOut.A,2)*(dist_source-DataOut.AX(1))/(DataOut.AX(2)-DataOut.AX(1))); |
---|
| 4893 | line_nan= isnan(dist_source_pixel); |
---|
| 4894 | dist_source_pixel(line_nan)=1; |
---|
| 4895 | width=20; %number of pixels used for reference |
---|
| 4896 | DataOut.A=double(DataOut.A); |
---|
| 4897 | Anorm=zeros(size(DataOut.A)); |
---|
| 4898 | Aval=mean(mean(DataOut.A)); |
---|
| 4899 | for iline=1:size(DataOut.A,1) |
---|
| 4900 | lum(iline)=mean(DataOut.A(iline,dist_source_pixel(iline):dist_source_pixel(iline)+width)); |
---|
| 4901 | Anorm(iline,:)=uint16(Aval*DataOut.A(iline,:)/lum(iline)); |
---|
| 4902 | end |
---|
| 4903 | lum(line_nan)=NaN; |
---|
| 4904 | figure |
---|
| 4905 | plot(1:size(DataOut.A,1),lum) |
---|
| 4906 | end |
---|
| 4907 | ImaName=regexprep([get(handles.RootFile,'String') get(handles.FileIndex,'String')],'//',''); |
---|
| 4908 | NewImageName=fullfile(get(handles.RootPath,'String'),'polar',[ImaName get(handles.FileExt,'String')]); |
---|
| 4909 | imwrite(Anorm,NewImageName,'BitDepth',16) |
---|
| 4910 | |
---|
| 4911 | %% record the origin in the xml file |
---|
| 4912 | XmlFileName=find_imadoc(get(handles.RootPath,'String'),get(handles.SubDir,'String'),get(handles.RootFile,'String'),get(handles.FileExt,'String')); |
---|
| 4913 | answer=msgbox_uvmat('INPUT_Y-N','save the illumination origin in the current xml file?'); |
---|
| 4914 | if strcmp(answer,'Yes') |
---|
| 4915 | t=xmltree(XmlFileName); %read the file |
---|
| 4916 | title=get(t,1,'name'); |
---|
| 4917 | if ~strcmp(title,'ImaDoc') |
---|
| 4918 | msgbox_uvmat('ERROR','wrong xml file'); |
---|
| 4919 | return |
---|
| 4920 | end |
---|
| 4921 | % backup the output file if it already exist, and read it |
---|
| 4922 | backupfile=XmlFileName; |
---|
| 4923 | testexist=2; |
---|
| 4924 | while testexist==2 |
---|
| 4925 | backupfile=[backupfile '~']; |
---|
| 4926 | testexist=exist(backupfile,'file'); |
---|
| 4927 | end |
---|
| 4928 | [success,message]=copyfile(XmlFileName,backupfile);%make backup |
---|
| 4929 | if success~=1 |
---|
| 4930 | errormsg=['errror in xml file backup: ' message]; |
---|
| 4931 | return |
---|
| 4932 | end |
---|
| 4933 | uid_illumination=find(t,'ImaDoc/Illumination'); |
---|
| 4934 | if isempty(uid_illumination) %if GeometryCalib does not already exists, create it |
---|
| 4935 | [t,uid_illumination]=add(t,1,'element','Illumination'); |
---|
| 4936 | end |
---|
| 4937 | uid_origin=find(t,'ImaDoc/Illumination/Origin'); |
---|
| 4938 | if ~isempty(uid_origin) %if GeometryCalib does not already exists, create it |
---|
| 4939 | t=delete(t,uid_origin); |
---|
| 4940 | end |
---|
| 4941 | % save the illumination origin |
---|
| 4942 | t=struct2xml(XmlData.Illumination,t,uid_illumination); |
---|
| 4943 | save(t,XmlFileName); |
---|
| 4944 | end |
---|
| 4945 | |
---|
| 4946 | |
---|
| 4947 | |
---|
[566] | 4948 | %------------------------------------------------------------------------ |
---|
[387] | 4949 | function MenuMask_Callback(hObject, eventdata, handles) |
---|
| 4950 | %------------------------------------------------------------------------ |
---|
| 4951 | UvData=get(handles.uvmat,'UserData');%read UvData properties stored on the uvmat interface |
---|
| 4952 | ListObj=UvData.Object; |
---|
| 4953 | select=zeros(1,numel(ListObj)); |
---|
| 4954 | for iobj=1:numel(ListObj); |
---|
| 4955 | if strcmp(ListObj{iobj}.ProjMode,'mask_inside')||strcmp(ListObj{iobj}.ProjMode,'mask_outside') |
---|
| 4956 | select(iobj)=1; |
---|
| 4957 | end |
---|
| 4958 | end |
---|
| 4959 | val=find(select); |
---|
| 4960 | if isempty(val) |
---|
| 4961 | msgbox_uvmat('ERROR','polygons must be first created by Projection object/mask polygon in the menu bar'); |
---|
| 4962 | return |
---|
| 4963 | else |
---|
| 4964 | set(handles.ListObject,'Value',val); |
---|
| 4965 | flag=1; |
---|
| 4966 | npx=size(UvData.Field.A,2); |
---|
| 4967 | npy=size(UvData.Field.A,1); |
---|
| 4968 | xi=0.5:npx-0.5; |
---|
| 4969 | yi=0.5:npy-0.5; |
---|
| 4970 | [Xi,Yi]=meshgrid(xi,yi); |
---|
[566] | 4971 | % if isfield(UvData,'Object') |
---|
[387] | 4972 | for iobj=1:length(UvData.Object) |
---|
| 4973 | ObjectData=UvData.Object{iobj}; |
---|
| 4974 | if isfield(ObjectData,'ProjMode') &&(isequal(ObjectData.ProjMode,'mask_inside')||isequal(ObjectData.ProjMode,'mask_outside')); |
---|
| 4975 | flagobj=1; |
---|
| 4976 | testphys=0; %coordinates in pixels by default |
---|
| 4977 | if isfield(ObjectData,'CoordUnit') && ~isequal(ObjectData.CoordUnit,'pixel') |
---|
| 4978 | if isfield(UvData,'XmlData')&& isfield(UvData.XmlData{1},'GeometryCalib') |
---|
| 4979 | Calib=UvData.XmlData{1}.GeometryCalib; |
---|
| 4980 | testphys=1; |
---|
| 4981 | end |
---|
| 4982 | end |
---|
| 4983 | if isfield(ObjectData,'Coord')&& isfield(ObjectData,'Type') |
---|
| 4984 | if isequal(ObjectData.Type,'polygon') |
---|
| 4985 | X=ObjectData.Coord(:,1); |
---|
| 4986 | Y=ObjectData.Coord(:,2); |
---|
| 4987 | if testphys |
---|
[542] | 4988 | pos=[X Y zeros(size(X))]; |
---|
| 4989 | if isfield(Calib,'SliceCoord') && length(Calib.SliceCoord)>=3 |
---|
| 4990 | if isfield(Calib,'SliceAngle')&&~isequal(Calib.SliceAngle,[0 0 0]) |
---|
| 4991 | om=norm(Calib.SliceAngle);%norm of rotation angle in radians |
---|
| 4992 | OmAxis=Calib.SliceAngle/om; %unit vector marking the rotation axis |
---|
| 4993 | cos_om=cos(pi*om/180); |
---|
| 4994 | sin_om=sin(pi*om/180); |
---|
| 4995 | pos=cos_om*pos+sin_om*cross(OmAxis,pos)+(1-cos_om)*(OmAxis*pos')*OmAxis; |
---|
| 4996 | end |
---|
| 4997 | pos(:,1)=pos(:,1)+Calib.SliceCoord(1); |
---|
| 4998 | pos(:,2)=pos(:,2)+Calib.SliceCoord(2); |
---|
| 4999 | pos(:,3)=pos(:,3)+Calib.SliceCoord(3); |
---|
| 5000 | end |
---|
| 5001 | [X,Y]=px_XYZ(Calib,pos(:,1),pos(:,2),pos(:,3)); |
---|
[387] | 5002 | end |
---|
| 5003 | flagobj=~inpolygon(Xi,Yi,X',Y');%=0 inside the polygon, 1 outside |
---|
| 5004 | elseif isequal(ObjectData.Type,'ellipse') |
---|
| 5005 | if testphys |
---|
| 5006 | %[X,Y]=px_XYZ(Calib,X,Y,0);% TODO:create a polygon boundary and transform to phys |
---|
| 5007 | end |
---|
| 5008 | RangeX=max(ObjectData.RangeX); |
---|
| 5009 | RangeY=max(ObjectData.RangeY); |
---|
| 5010 | X2Max=RangeX*RangeX; |
---|
| 5011 | Y2Max=RangeY*RangeY; |
---|
| 5012 | distX=(Xi-ObjectData.Coord(1,1)); |
---|
| 5013 | distY=(Yi-ObjectData.Coord(1,2)); |
---|
| 5014 | flagobj=(distX.*distX/X2Max+distY.*distY/Y2Max)>1; |
---|
| 5015 | elseif isequal(ObjectData.Type,'rectangle') |
---|
| 5016 | if testphys |
---|
| 5017 | %[X,Y]=px_XYZ(Calib,X,Y,0);% TODO:create a polygon boundary and transform to phys |
---|
| 5018 | end |
---|
| 5019 | distX=abs(Xi-ObjectData.Coord(1,1)); |
---|
| 5020 | distY=abs(Yi-ObjectData.Coord(1,2)); |
---|
| 5021 | flagobj=distX>max(ObjectData.RangeX) | distY>max(ObjectData.RangeY); |
---|
| 5022 | end |
---|
| 5023 | if isequal(ObjectData.ProjMode,'mask_outside') |
---|
| 5024 | flagobj=~flagobj; |
---|
| 5025 | end |
---|
| 5026 | flag=flag & flagobj; |
---|
| 5027 | end |
---|
| 5028 | end |
---|
| 5029 | end |
---|
[566] | 5030 | % end |
---|
[387] | 5031 | %mask name |
---|
| 5032 | RootPath=get(handles.RootPath,'String'); |
---|
[444] | 5033 | SubDir=get(handles.SubDir,'String'); |
---|
[387] | 5034 | RootFile=get(handles.RootFile,'String'); |
---|
| 5035 | if ~isempty(RootFile)&&(isequal(RootFile(1),'/')|| isequal(RootFile(1),'\')) |
---|
| 5036 | RootFile(1)=[]; |
---|
| 5037 | end |
---|
| 5038 | list=get(handles.masklevel,'String'); |
---|
| 5039 | masknumber=num2str(length(list)); |
---|
| 5040 | maskindex=get(handles.masklevel,'Value'); |
---|
[444] | 5041 | % mask_name=fullfile_uvmat(RootPath,'',[RootFile '_' masknumber 'mask'],'.png','_1',maskindex); |
---|
| 5042 | mask_name=fullfile_uvmat(RootPath,[SubDir '.mask'],'mask','.png','_1',maskindex); |
---|
[387] | 5043 | imflag=uint8(255*(0.392+0.608*flag));% =100 for flag=0 (vectors not computed when 20<imflag<200) |
---|
| 5044 | imflag=flipdim(imflag,1); |
---|
| 5045 | |
---|
| 5046 | %display the mask |
---|
| 5047 | hfigmask=figure; |
---|
| 5048 | set(hfigmask,'Name','mask image') |
---|
| 5049 | vec=linspace(0,1,256);%define a linear greyscale colormap |
---|
| 5050 | map=[vec' vec' vec']; |
---|
| 5051 | colormap(map) |
---|
| 5052 | image(imflag); |
---|
| 5053 | answer=msgbox_uvmat('INPUT_TXT','mask file name:', mask_name); |
---|
| 5054 | if ~strcmp(answer,'Cancel') |
---|
| 5055 | mask_dir=fileparts(answer); |
---|
| 5056 | if ~exist(mask_dir,'dir') |
---|
[444] | 5057 | [xx,msg1]=mkdir(mask_dir); |
---|
| 5058 | if ~strcmp(msg1,'') |
---|
| 5059 | errormsg=['cannot create ' mask_dir ': ' msg1];%error message for directory creation |
---|
| 5060 | return |
---|
| 5061 | end |
---|
[387] | 5062 | end |
---|
| 5063 | imwrite(imflag,answer,'BitDepth',8); |
---|
| 5064 | end |
---|
| 5065 | set(handles.ListObject,'Value',1) |
---|
| 5066 | end |
---|
| 5067 | |
---|
| 5068 | %------------------------------------------------------------------------ |
---|
| 5069 | %-- open the GUI set_grid.fig to create grid |
---|
| 5070 | function MenuGrid_Callback(hObject, eventdata, handles) |
---|
| 5071 | %------------------------------------------------------------------------ |
---|
| 5072 | %suppress the other options if grid is chosen |
---|
| 5073 | set(handles.edit_vect,'Value',0) |
---|
| 5074 | edit_vect_Callback(hObject, eventdata, handles) |
---|
| 5075 | set(handles.edit_object,'BackgroundColor',[0.7 0.7 0.7]) |
---|
| 5076 | set(handles.ListObject,'Value',1) |
---|
| 5077 | |
---|
| 5078 | %prepare display of the set_grid GUI |
---|
[515] | 5079 | [RootPath,SubDir,RootFile,FileIndex,FileExt]=read_file_boxes(handles); |
---|
| 5080 | FileName=[fullfile(RootPath,SubDir,RootFile) FileIndex FileExt]; |
---|
[576] | 5081 | UvData=get(handles.uvmat,'UserData'); |
---|
[591] | 5082 | % CoordList=get(handles.TransformName,'String'); |
---|
| 5083 | % val=get(handles.TransformName,'Value'); |
---|
[576] | 5084 | set_grid(FileName,UvData.Field);% call the set_object interface |
---|
[387] | 5085 | |
---|
[402] | 5086 | |
---|
[387] | 5087 | %------------------------------------------------------------------------ |
---|
[402] | 5088 | function MenuRuler_Callback(hObject, eventdata, handles) |
---|
| 5089 | %------------------------------------------------------------------------ |
---|
| 5090 | set(handles.CheckZoom,'Value',0) |
---|
| 5091 | CheckZoom_Callback(handles.uvmat, [], handles) |
---|
| 5092 | set(handles.MenuRuler,'checked','on') |
---|
| 5093 | UvData=get(handles.uvmat,'UserData'); |
---|
| 5094 | UvData.MouseAction='ruler'; |
---|
| 5095 | set(handles.uvmat,'UserData',UvData); |
---|
| 5096 | |
---|
| 5097 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
---|
| 5098 | % MenuRun Callbacks |
---|
| 5099 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
---|
| 5100 | |
---|
| 5101 | %------------------------------------------------------------------------ |
---|
[387] | 5102 | % open the GUI 'series' |
---|
| 5103 | function MenuSeries_Callback(hObject, eventdata, handles) |
---|
| 5104 | %------------------------------------------------------------------------ |
---|
[515] | 5105 | [RootPath,SubDir,RootFile,FileIndex,FileExt]=read_file_boxes(handles); |
---|
[526] | 5106 | Param.FileName=[fullfile(RootPath,SubDir,RootFile) FileIndex FileExt];%first input file name |
---|
[387] | 5107 | if isequal(get(handles.SubField,'Value'),1) |
---|
[515] | 5108 | [RootPath_1,SubDir_1,RootFile_1,FileIndex_1,FileExt_1]=read_file_boxes_1(handles); |
---|
| 5109 | FileName_1=[fullfile(RootPath_1,SubDir_1,RootFile_1) FileIndex_1 FileExt_1]; |
---|
[526] | 5110 | if ~isequal(FileName_1,Param.FileName) |
---|
| 5111 | Param.FileName_1=FileName_1;%second input file name if relevant |
---|
[387] | 5112 | end |
---|
| 5113 | end |
---|
[526] | 5114 | Param.NomType=get(handles.NomType,'String'); |
---|
| 5115 | Param.NomType_1=get(handles.NomType_1,'String'); |
---|
| 5116 | Param.CheckFixPair=get(handles.CheckFixPair,'Value'); |
---|
| 5117 | UvData=get(handles.uvmat,'UserData'); |
---|
[387] | 5118 | if isfield(UvData,'XmlData')&& isfield(UvData.XmlData{1},'Time') |
---|
[526] | 5119 | Param.Time=UvData.XmlData{1}.Time; |
---|
[387] | 5120 | end |
---|
| 5121 | if isequal(get(handles.scan_i,'Value'),1) |
---|
[526] | 5122 | Param.incr_i=str2num(get(handles.num_IndexIncrement,'String')); |
---|
[387] | 5123 | elseif isequal(get(handles.scan_j,'Value'),1) |
---|
[526] | 5124 | Param.incr_j=str2num(get(handles.num_IndexIncrement,'String')); |
---|
[387] | 5125 | end |
---|
[526] | 5126 | |
---|
| 5127 | %% transfer fields and coordinate names |
---|
| 5128 | Param.list_fields=get(handles.FieldName,'String');% list menu fields |
---|
| 5129 | FieldName=Param.list_fields{get(handles.FieldName,'Value')}; |
---|
| 5130 | ind_image=find(strcmp('image',Param.list_fields)); |
---|
| 5131 | if ~isempty(ind_image) && numel(Param.list_fields)>1 |
---|
| 5132 | Param.list_fields(ind_image)=[]; %suppress 'image' option |
---|
[387] | 5133 | end |
---|
[526] | 5134 | Param.index_fields=find(strcmp(FieldName,Param.list_fields));% selected string index |
---|
| 5135 | Param.list_fields_1=get(handles.FieldName_1,'String');% list menu fields |
---|
| 5136 | if ischar(Param.list_fields_1),Param.list_fields_1={Param.list_fields_1};end |
---|
| 5137 | FieldName_1=Param.list_fields_1{get(handles.FieldName_1,'Value')}; |
---|
| 5138 | ind_image=find(strcmp('image',Param.list_fields_1)); |
---|
| 5139 | if ~isempty(ind_image) && numel(Param.list_fields_1)>1 |
---|
| 5140 | Param.list_fields_1(ind_image)=[]; %suppress 'image' option |
---|
[387] | 5141 | end |
---|
[526] | 5142 | Param.index_fields_1=find(strcmp(FieldName_1,Param.list_fields_1));% selected string index |
---|
[591] | 5143 | TransformList=get(handles.TransformName,'String'); |
---|
| 5144 | Param.TransformName=TransformList{get(handles.TransformName,'Value')}; |
---|
[526] | 5145 | Param.Coord_x_str=get(handles.Coord_x,'String'); |
---|
| 5146 | Param.Coord_x_val=get(handles.Coord_x,'Value'); |
---|
| 5147 | Param.Coord_y_str=get(handles.Coord_y,'String'); |
---|
| 5148 | Param.Coord_y_val=get(handles.Coord_y,'Value'); |
---|
| 5149 | series(Param); %run the series interface |
---|
[387] | 5150 | |
---|
| 5151 | %------------------------------------------------------------------------ |
---|
[402] | 5152 | % -- open the GUI civ.fig for PIV |
---|
[387] | 5153 | function MenuPIV_Callback(hObject, eventdata, handles) |
---|
| 5154 | %------------------------------------------------------------------------ |
---|
[515] | 5155 | [RootPath,SubDir,RootFile,FileIndex,FileExt]=read_file_boxes(handles); |
---|
| 5156 | FileName=[fullfile(RootPath,SubDir,RootFile) FileIndex FileExt]; |
---|
[387] | 5157 | civ(FileName);% interface de civ(not in the uvmat file) |
---|
| 5158 | |
---|
[402] | 5159 | % -------------------------------------------------------------------- |
---|
| 5160 | function MenuHelp_Callback(hObject, eventdata, handles) |
---|
| 5161 | % -------------------------------------------------------------------- |
---|
| 5162 | path_to_uvmat=which ('uvmat');% check the path of uvmat |
---|
| 5163 | pathelp=fileparts(path_to_uvmat); |
---|
| 5164 | helpfile=fullfile(pathelp,'uvmat_doc','uvmat_doc.html'); |
---|
| 5165 | 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') |
---|
| 5166 | else |
---|
| 5167 | addpath (fullfile(pathelp,'uvmat_doc')) |
---|
| 5168 | web(helpfile); |
---|
[387] | 5169 | end |
---|
[497] | 5170 | |
---|
[517] | 5171 | % --- Executes on selection change in Coord_y. |
---|
| 5172 | function Coord_y_Callback(hObject, eventdata, handles) |
---|
| 5173 | |
---|
| 5174 | % --- Executes on selection change in Coord_x. |
---|
| 5175 | function Coord_x_Callback(hObject, eventdata, handles) |
---|
[546] | 5176 | |
---|
| 5177 | |
---|
| 5178 | % --- Executes on button press in CheckColorBar. |
---|
| 5179 | function CheckColorBar_Callback(hObject, eventdata, handles) |
---|
[591] | 5180 | |
---|
| 5181 | |
---|
| 5182 | |
---|
| 5183 | function TransformPath_Callback(hObject, eventdata, handles) |
---|
| 5184 | % hObject handle to TransformPath (see GCBO) |
---|
| 5185 | % eventdata reserved - to be defined in a future version of MATLAB |
---|
| 5186 | % handles structure with handles and user data (see GUIDATA) |
---|
| 5187 | |
---|
| 5188 | % Hints: get(hObject,'String') returns contents of TransformPath as text |
---|
| 5189 | % str2double(get(hObject,'String')) returns contents of TransformPath as a double |
---|
[598] | 5190 | |
---|
| 5191 | |
---|
| 5192 | %TODO: use to modify fill_GUI |
---|
| 5193 | %'write_plot_param': update the plotting parameters on the uvmat or view_field interface after a plotting operation |
---|
| 5194 | function write_plot_param(handles,PlotParam) |
---|
| 5195 | %% coordinates |
---|
| 5196 | if isempty(PlotParam.Coordinates) |
---|
| 5197 | set(handles.Coordinates,'Visible','off') |
---|
| 5198 | set(handles.PlotAxes,'Visible','off') |
---|
| 5199 | set(handles.text_display,'Visible','off') |
---|
| 5200 | set(handles.TableDisplay,'Visible','on') |
---|
| 5201 | else |
---|
| 5202 | set(handles.Coordinates,'Visible','on') |
---|
| 5203 | set(handles.PlotAxes,'Visible','on') |
---|
| 5204 | set(handles.text_display,'Visible','on') |
---|
| 5205 | if isfield(handles,'TableDisplay') |
---|
| 5206 | set(handles.TableDisplay,'Visible','off') |
---|
| 5207 | end |
---|
| 5208 | Coordinates=PlotParam.Coordinates; |
---|
| 5209 | if isfield(Coordinates,'CheckFixAspectRatio') |
---|
| 5210 | if Coordinates.CheckFixAspectRatio |
---|
| 5211 | set(handles.CheckFixAspectRatio,'Value',1) |
---|
| 5212 | else |
---|
| 5213 | set(handles.CheckFixAspectRatio,'Value',0) |
---|
| 5214 | |
---|
| 5215 | end |
---|
| 5216 | end |
---|
| 5217 | if isfield(Coordinates,'AspectRatio') |
---|
| 5218 | set(handles.num_AspectRatio,'String',num2str(Coordinates.AspectRatio)) |
---|
| 5219 | end |
---|
| 5220 | if isfield(Coordinates,'MinX') |
---|
| 5221 | set(handles.num_MinX,'String',num2str(Coordinates.MinX,4)); |
---|
| 5222 | set(handles.num_MaxX,'String',num2str(Coordinates.MaxX,4)); |
---|
| 5223 | set(handles.num_MinY,'String',num2str(Coordinates.MinY,4)); |
---|
| 5224 | set(handles.num_MaxY,'String',num2str(Coordinates.MaxY,4)); |
---|
| 5225 | else |
---|
| 5226 | set(handles.num_MinX,'String',''); |
---|
| 5227 | set(handles.num_MaxX,'String',''); |
---|
| 5228 | set(handles.num_MinY,'String',''); |
---|
| 5229 | set(handles.num_MaxY,'String',''); |
---|
| 5230 | end |
---|
| 5231 | end |
---|
| 5232 | |
---|
| 5233 | %% scalar or image parameters |
---|
| 5234 | if isfield(PlotParam,'Scalar') |
---|
| 5235 | set(handles.Scalar,'Visible','on') |
---|
| 5236 | if isfield(PlotParam.Scalar,'MaxA') |
---|
| 5237 | set(handles.num_MaxA,'String',num2str(PlotParam.Scalar.MaxA,3)); |
---|
| 5238 | end |
---|
| 5239 | if isfield(PlotParam.Scalar,'MinA') |
---|
| 5240 | set(handles.num_MinA,'String',num2str(PlotParam.Scalar.MinA,3)); |
---|
| 5241 | end |
---|
| 5242 | if isfield(PlotParam.Scalar,'IncrA') |
---|
| 5243 | set(handles.num_IncrA,'String',num2str(PlotParam.Scalar.IncrA,3)) |
---|
| 5244 | end |
---|
| 5245 | set(handles.CheckBW,'Value',PlotParam.Scalar.CheckBW) |
---|
| 5246 | if isfield(PlotParam.Scalar,'Opacity')&&isfield(handles,'num_Opacity') |
---|
| 5247 | set(handles.num_Opacity,'String',num2str(PlotParam.Scalar.Opacity)) |
---|
| 5248 | end |
---|
| 5249 | else |
---|
| 5250 | set(handles.Scalar,'Visible','off') |
---|
| 5251 | end |
---|
| 5252 | |
---|
| 5253 | %% parameter for vector field |
---|
| 5254 | if isfield(PlotParam,'Vectors') |
---|
| 5255 | set(handles.Vectors,'Visible','on') |
---|
| 5256 | if isfield(PlotParam.Vectors,'VecScale') |
---|
| 5257 | set(handles.num_VecScale,'String',num2str(PlotParam.Vectors.VecScale,3)) |
---|
| 5258 | end |
---|
| 5259 | if isfield(PlotParam.Vectors,'MinC')&& isfield(PlotParam.Vectors,'MaxC') |
---|
| 5260 | MinC=PlotParam.Vectors.MinC; |
---|
| 5261 | MaxC=PlotParam.Vectors.MaxC; |
---|
| 5262 | set(handles.num_MinVec,'String', num2str(MinC,3)); |
---|
| 5263 | set(handles.num_MaxVec,'String',num2str(MaxC,3)); |
---|
| 5264 | list=get(handles.ColorCode,'String'); |
---|
| 5265 | ichoice=get(handles.ColorCode,'Value'); |
---|
| 5266 | color_option=list{ichoice}; |
---|
| 5267 | test3color=strcmp(color_option,'rgb')||strcmp(color_option,'bgr'); |
---|
| 5268 | if test3color% need to update color thresholds |
---|
| 5269 | set(handles.num_ColCode1,'Visible','on') |
---|
| 5270 | set(handles.num_ColCode2,'Visible','on') |
---|
| 5271 | set(handles.Slider1,'Visible','on') |
---|
| 5272 | set(handles.Slider2,'Visible','on') |
---|
| 5273 | %ColCode1=MinC+(MaxC-MinC)*PlotParam.Vectors.ColCode1; |
---|
| 5274 | %ColCode2=MinC+(MaxC-MinC)*PlotParam.Vectors.ColCode2; |
---|
| 5275 | % ColCode1=MinC+(MaxC-MinC)*PlotParam.Vectors.ColCode1; |
---|
| 5276 | %ColCode2=MinC+(MaxC-MinC)*PlotParam.Vectors.ColCode2; |
---|
| 5277 | set(handles.num_ColCode1,'String',num2str(PlotParam.Vectors.ColCode1,3)) |
---|
| 5278 | set(handles.num_ColCode2,'String',num2str(PlotParam.Vectors.ColCode2,3)) |
---|
| 5279 | set(handles.Slider1,'Value',(PlotParam.Vectors.ColCode1-MinC)/(MaxC-MinC)) |
---|
| 5280 | set(handles.Slider2,'Value',(PlotParam.Vectors.ColCode2-MinC)/(MaxC-MinC)) |
---|
| 5281 | else |
---|
| 5282 | set(handles.num_ColCode1,'Visible','off') |
---|
| 5283 | set(handles.num_ColCode2,'Visible','off') |
---|
| 5284 | set(handles.Slider1,'Visible','off') |
---|
| 5285 | set(handles.Slider2,'Visible','off') |
---|
| 5286 | end |
---|
| 5287 | end |
---|
| 5288 | else |
---|
| 5289 | set(handles.Vectors,'Visible','off') |
---|
| 5290 | if isfield(handles,'edit_vect') |
---|
| 5291 | set(handles.edit_vect,'Visible','off') |
---|
| 5292 | set(handles.record,'Visible','off') |
---|
| 5293 | end |
---|
| 5294 | end |
---|