[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 | % .PosGeometryCalib: size of set_object |
---|
[591] | 35 | % .NbBuiltin: nbre of functions always displayed in TransformName menu |
---|
[622] | 36 | % .ProjObject: cell array of structures representing the current projection objects, as produced by 'set_object.m'={[]} by default |
---|
[511] | 37 | % .NewSeries: =0/1 flag telling whether a new field series has been opened |
---|
| 38 | % .FileName_1: name of the current second field (used to detect a constant field during file scanning) |
---|
| 39 | % .FileType: current file type, as defined by the fct get_file_type.m) |
---|
| 40 | % .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 |
---|
| 41 | % .MovieObject: current movie object |
---|
| 42 | % .TimeUnit: unit for time |
---|
[526] | 43 | % .XmlData: cell array of 1 or 2 structures representing the xml files associated with the input fieldname (containing timing and geometry calibration) |
---|
[511] | 44 | % .Field: cell array of 1 or 2 structures representing the current input field(s) |
---|
| 45 | % .PlotAxes: field structure representing the current field plotted on the main axes (used for mouse operations) |
---|
| 46 | % .HistoAxes: idem for histogram axes |
---|
[387] | 47 | |
---|
| 48 | % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%% DATA FLOW (for run0_Callback) %%%%%%%%%%%%%%%%%%%%: |
---|
| 49 | % |
---|
[406] | 50 | % |
---|
| 51 | % 1) Input filenames are determined by MenuBrowse (first field), MenuBrowse_1 |
---|
[512] | 52 | % (second field), or by the stored file name .FileName_1, or as an input of uvmat. |
---|
| 53 | % 2) These functions call 'uvmat/display_file_name.m' which detects the file series, and fills the file index boxes |
---|
| 54 | % 3) Then 'uvmat/update_rootinfo.m' Updates information about a new field series (indices to scan, timing, calibration from an xml file) |
---|
[526] | 55 | % 4) Then fieldname are opened and visualised by the main sub-function 'uvmat/refresh_field.m' |
---|
[512] | 56 | % The function first reads the name of the input file(s) (one or two) from the edit boxes of the GUI |
---|
| 57 | % It then reads the input file(s) with the function read_field.m and perform the following list of operations: |
---|
[387] | 58 | % |
---|
[512] | 59 | % %%%%%%%% structure of uvmat/refresh_field.m %%%%%%%% |
---|
[387] | 60 | % |
---|
[512] | 61 | % Main input open second input open_1 |
---|
| 62 | % | | |
---|
| 63 | % read_field.m read_field.m |
---|
| 64 | % | | |
---|
| 65 | % Field{1} Field{2} |
---|
| 66 | % | | |
---|
[526] | 67 | % --->transform fct<--- transform (e.g. phys.m) and combine input fieldname |
---|
[512] | 68 | % | |
---|
[581] | 69 | % (tps_coeff_field.m) calculate tps coefficients (for filter projection or spatial derivatives). |
---|
[512] | 70 | % | |
---|
| 71 | % UvData.Field-------------->histogram |
---|
| 72 | % _____________|____________ |
---|
| 73 | % | | |
---|
[595] | 74 | % proj_field.m proj_field.m project the field on the projection objects (use set_field_list.m) |
---|
[512] | 75 | % | | |
---|
| 76 | % UvData.PlotAxes ViewData.PlotAxes (on view_field) |
---|
| 77 | % | | |
---|
[526] | 78 | % plot_field.m (uvmat) plot_field.m (view_field) plot the projected fieldname |
---|
[512] | 79 | % |
---|
| 80 | % |
---|
[387] | 81 | %%%%%%%%%%%%%% SCALARS: %%%%%%%%%%%%??%%% |
---|
| 82 | % scalars are displayed either as an image or countour plot, either as a color of |
---|
| 83 | % velocity vectors. The scalar values in the first case is represented by |
---|
| 84 | % UvData.Field.A, and by UvData.Field.C in the second case. The corresponding set of X |
---|
| 85 | % and Y coordinates are represented by UvData.Field.AX and UvData.Field.AY, and .X and |
---|
| 86 | % .Y for C (the same as velocity vectors). If A is a nxxny matrix (scalar |
---|
| 87 | % on a regtular grid), then .AX andf.AY contains only two elements, represneting the |
---|
| 88 | % coordinates of the four image corners. The scalar name is represented by |
---|
| 89 | % the strings .AName and/or .CName. |
---|
| 90 | % If the scalar exists in an input open (image or scalar stored under its |
---|
| 91 | % name in a netcdf open), it is directly read at the level of Field{1}or Field{2}. |
---|
| 92 | % Else only its name AName is recorded in Field{i}, and its field is then calculated |
---|
| 93 | %by the fuction calc_scal after the coordinate transform or after projection on an edit_object |
---|
| 94 | |
---|
| 95 | % Properties attached to plotting figures (standard Matlab properties): |
---|
| 96 | % 'CurrentAxes'= gca or get(gcf,'CurrentAxes'); |
---|
| 97 | % 'CurrentPoint'=get(gcf,'CurrentPoint'): figure coordinates of the point over which the mouse is positioned |
---|
| 98 | % 'CurrentCharacter'=get(gcf,'CurrentCharacter'): last character typed over the figure where the mouse is positioned |
---|
| 99 | % 'WindowButtonMotionFcn': function permanently called by mouse motion over the figure |
---|
| 100 | % 'KeyPressFcn': function called by pressing a key on the key board |
---|
| 101 | % 'WindowButtonDownFcn': function called by pressing the mouse over the figure |
---|
| 102 | % 'WindowButtonUpFcn': function called by releasing the mouse pressure over the figure |
---|
| 103 | |
---|
| 104 | % Properties attached to plotting axes: |
---|
| 105 | % 'CurrentPoint'=get(gca,'CurrentPoint'); (standard Matlab) same as for the figure, but position in plot coordinates. |
---|
| 106 | % AxeData:=get(gca,'UserData'); |
---|
| 107 | % AxeData.Drawing = create: create a new object |
---|
| 108 | % = deform: modify an existing object by moving its defining create |
---|
| 109 | % = off: no current drawing action |
---|
| 110 | % = translate: translate an existing object |
---|
| 111 | % = calibration: move a calibration point |
---|
| 112 | % = CheckZoom: isolate a subregion for CheckZoom in=1 if an object is being currently drawn, 0 else (set to 0 by releasing mouse button) |
---|
| 113 | % .CurrentOrigin: Origin of a curently drawn edit_object |
---|
| 114 | % .CurrentLine: currently drawn menuline (A REVOIR) |
---|
| 115 | % .CurrentObject: handle of the currently drawn edit_object |
---|
| 116 | % .CurrentRectZoom: current rectangle used for CheckZoom |
---|
| 117 | |
---|
| 118 | % Properties attached to projection objects (create, menuline, menuplane...): |
---|
| 119 | % 'Tag'='proj_object': for all projection objects |
---|
| 120 | % ObjectData.Type=...: style of projection object: |
---|
| 121 | % .ProjMode |
---|
| 122 | % .Coord: defines the position of the object |
---|
| 123 | % .XMin,YMin.... |
---|
| 124 | % .XMax,YMax.... |
---|
| 125 | % .DX,DY,DZ |
---|
| 126 | % .Phi, .Theta, .Psi : Euler angles |
---|
| 127 | % .X,.Y,.U,.V.... : field data projected on the object |
---|
[622] | 128 | % .IndexObj: index in the list of UvData.ProjObject |
---|
[387] | 129 | %during plotting |
---|
| 130 | % .plotaxes: handles of the current axes used to plot the result of field projection on the object |
---|
| 131 | % .plothandle: vector of handle(s) of the object graphic represnetation in all the opened plotting axes |
---|
| 132 | % To each projection object #iobj, corresponds an axis |
---|
| 133 | % Object{iobj}.plotaxes and nbobj representation graphs Object{iobj}.plothandles(:) (where nbobj is the |
---|
| 134 | % nbre of current objects opened in uvmat. Note that Object{iobj}.plothandles(iobj)=[] : an object is not represented in its own projection field; |
---|
| 135 | |
---|
| 136 | %------------------------------------------------------------------------ |
---|
| 137 | %------------------------------------------------------------------------ |
---|
[406] | 138 | % I - MAIN FUNCTION uvmat |
---|
[387] | 139 | %------------------------------------------------------------------------ |
---|
| 140 | %------------------------------------------------------------------------ |
---|
| 141 | function varargout = uvmat(varargin) |
---|
| 142 | |
---|
| 143 | % Begin initialization code - DO NOT EDIT |
---|
| 144 | gui_Singleton = 1; |
---|
| 145 | gui_State = struct('gui_Name', mfilename, ... |
---|
| 146 | 'gui_Singleton', gui_Singleton, ... |
---|
| 147 | 'gui_OpeningFcn', @uvmat_OpeningFcn, ... |
---|
| 148 | 'gui_OutputFcn', @uvmat_OutputFcn, ... |
---|
| 149 | 'gui_LayoutFcn', [], ... |
---|
| 150 | 'gui_Callback', []); |
---|
| 151 | if nargin && ischar(varargin{1})&& ~isempty(regexp(varargin{1},'_Callback','once')) |
---|
| 152 | gui_State.gui_Callback = str2func(varargin{1}); |
---|
| 153 | end |
---|
| 154 | |
---|
| 155 | if nargout |
---|
| 156 | varargout{1:nargout} = gui_mainfcn(gui_State, varargin{:}); |
---|
| 157 | else |
---|
| 158 | gui_mainfcn(gui_State, varargin{:}); |
---|
| 159 | end |
---|
| 160 | % End initialization code - DO NOT EDIT |
---|
| 161 | |
---|
| 162 | %------------------------------------------------------------------------ |
---|
| 163 | % --- Executes just before the GUI uvmat is made visible. |
---|
| 164 | function uvmat_OpeningFcn(hObject, eventdata, handles, input ) |
---|
| 165 | %------------------------------------------------------------------------ |
---|
| 166 | |
---|
| 167 | %% Choose default command menuline output for uvmat (standard GUI) |
---|
| 168 | handles.output = hObject; |
---|
| 169 | |
---|
| 170 | %% Update handles structure (standard GUI) |
---|
| 171 | guidata(hObject, handles); |
---|
| 172 | |
---|
[507] | 173 | %% add the path to uvmat (useful if uvmat has been opened in the working directory and a working directory change occured) |
---|
| 174 | path_uvmat=fileparts(which('uvmat')); |
---|
| 175 | |
---|
[609] | 176 | %% set the position of the GUI, colorbar and ancillary GUIs: |
---|
| 177 | set(hObject,'Units','pixels')% |
---|
| 178 | set(0,'Units','pixels'); |
---|
| 179 | ScreenSize=get(0,'ScreenSize');%size of the current screen |
---|
| 180 | Width=1050; |
---|
| 181 | Height=700; |
---|
| 182 | %adjust to screen size (reduced by a min margin) |
---|
| 183 | RescaleFactor=min((ScreenSize(3)-80)/Width,(ScreenSize(4)-80)/Height); |
---|
| 184 | if RescaleFactor>1 |
---|
| 185 | RescaleFactor=RescaleFactor/2+1/2; %reduce the rescale factor to provide an increased margin for a big screen |
---|
| 186 | end |
---|
| 187 | Width=Width*RescaleFactor; |
---|
| 188 | Height=Height*RescaleFactor; |
---|
| 189 | LeftX=80*RescaleFactor;%position of the left fig side, in pixels (put to the left side, with some margin) |
---|
| 190 | LowY=round(ScreenSize(4)/2-Height/2); % put at the middle height on the screen |
---|
| 191 | set(hObject,'Position',[LeftX LowY Width Height]) |
---|
| 192 | |
---|
| 193 | %set(hObject,'Units','Normalized') |
---|
| 194 | |
---|
[546] | 195 | %UvData.OpenParam.PosColorbar=[0.8450 0.0900 0.0190 0.3600]; |
---|
[387] | 196 | UvData.OpenParam.PosColorbar=[0.805 0.022 0.019 0.445]; |
---|
[609] | 197 | %UvData.OpenParam.PosSetObject=[-0.05 -0.03 0.3 0.7]; %position for set_object |
---|
[517] | 198 | UvData.OpenParam.PosGeometryCalib=[0.95 -0.03 0.28 1 ];%position for geometry_calib (TO IMPROVE) |
---|
[511] | 199 | % UvData.OpenParam.CalSize=[0.28 1]; |
---|
| 200 | % UvData.PlotAxes=[];%initiate the record of plotted field |
---|
| 201 | % UvData.axes2=[]; |
---|
| 202 | % UvData.axes1=[]; |
---|
[387] | 203 | AxeData.LimEditBox=1; %initialise AxeData |
---|
[511] | 204 | set(handles.PlotAxes,'UserData',AxeData) |
---|
[387] | 205 | |
---|
| 206 | %% set functions for the mouse and keyboard |
---|
| 207 | set(hObject,'KeyPressFcn',{'keyboard_callback',handles})%set keyboard action function |
---|
| 208 | set(hObject,'WindowButtonMotionFcn',{'mouse_motion',handles})%set mouse action functio |
---|
| 209 | set(hObject,'WindowButtonDownFcn',{'mouse_down'})%set mouse click action function |
---|
| 210 | set(hObject,'WindowButtonUpFcn',{'mouse_up',handles}) |
---|
| 211 | set(hObject,'DeleteFcn',{@closefcn})% |
---|
| 212 | |
---|
[511] | 213 | %% initialisation |
---|
[526] | 214 | set(handles.FieldName,'Value',1) |
---|
| 215 | set(handles.FieldName,'string',{''}) |
---|
[622] | 216 | UvData.ProjObject={[]}; |
---|
[387] | 217 | |
---|
| 218 | %% TRANSFORM menu: builtin fcts |
---|
[515] | 219 | transform_menu={'';'sub_field';'phys';'phys_polar'}; |
---|
[507] | 220 | UvData.OpenParam.NbBuiltin=numel(transform_menu); %number of functions |
---|
| 221 | transform_path=fullfile(path_uvmat,'transform_field'); |
---|
[528] | 222 | path_list=cell(UvData.OpenParam.NbBuiltin,1); |
---|
[507] | 223 | path_list{1}=''; |
---|
[523] | 224 | for ilist=2:UvData.OpenParam.NbBuiltin |
---|
| 225 | path_list{ilist}=transform_path; % set transform_path to the path_list |
---|
| 226 | end |
---|
[387] | 227 | |
---|
[591] | 228 | %% load the list of previously browsed files in menus Open, Open_1 and TransformName |
---|
[576] | 229 | dir_perso=prefdir; % path to the directory .matlab containing the personal data of the current user |
---|
| 230 | profil_perso=fullfile(dir_perso,'uvmat_perso.mat');% personal data file uvmat_perso.mat' in .matlab |
---|
[387] | 231 | if exist(profil_perso,'file') |
---|
[507] | 232 | h=load (profil_perso); |
---|
[523] | 233 | if isfield(h,'MenuFile')% load the menu of previously opened files |
---|
[507] | 234 | for ifile=1:min(length(h.MenuFile),5) |
---|
[576] | 235 | set(handles.(['MenuFile_' num2str(ifile)]),'Label',h.MenuFile{ifile}); |
---|
| 236 | set(handles.(['MenuFile_' num2str(ifile) '_1']),'Label',h.MenuFile{ifile}); |
---|
[507] | 237 | end |
---|
| 238 | end |
---|
[576] | 239 | if isfield(h,'RootPath') |
---|
| 240 | set(handles.RootPath,'UserData',h.RootPath); %store the previous campaign in the UserData of RootPath |
---|
| 241 | end |
---|
[523] | 242 | if isfield(h,'transform_fct') && iscell(h.transform_fct) % load the menu of transform fct set by user |
---|
[387] | 243 | for ilist=1:length(h.transform_fct); |
---|
| 244 | if exist(h.transform_fct{ilist},'file') |
---|
[507] | 245 | [path,file]=fileparts(h.transform_fct{ilist}); |
---|
| 246 | transform_menu=[transform_menu; {file}]; |
---|
| 247 | path_list=[path_list; {path}]; |
---|
[387] | 248 | end |
---|
| 249 | end |
---|
[507] | 250 | end |
---|
[387] | 251 | end |
---|
[523] | 252 | transform_menu=[transform_menu;{'more...'}];%append the option more.. to the menu |
---|
[591] | 253 | set(handles.TransformName,'String',transform_menu)% display the menu of transform fcts |
---|
| 254 | set(handles.TransformName,'UserData',path_list)% store the corresponding list of path in UserData of uicontrol transform_fct |
---|
| 255 | set(handles.TransformPath,'String','') |
---|
| 256 | set(handles.TransformPath,'UserData',[]) |
---|
[387] | 257 | |
---|
| 258 | %% case of an input argument for uvmat |
---|
| 259 | testinputfield=0; |
---|
| 260 | inputfile=[]; |
---|
| 261 | Field=[]; |
---|
| 262 | if exist('input','var') |
---|
| 263 | if ishandle(handles.UVMAT_title) |
---|
| 264 | delete(handles.UVMAT_title) |
---|
| 265 | end |
---|
| 266 | if isstruct(input) |
---|
| 267 | if isfield(input,'InputFile') |
---|
| 268 | inputfile=input.InputFile; |
---|
| 269 | end |
---|
| 270 | if isfield(input,'TimeIndex') |
---|
| 271 | set(handles.i1,num2str(input.TimeIndex)) |
---|
| 272 | end |
---|
| 273 | if isfield(input,'FieldsString') |
---|
| 274 | UvData.FieldsString=input.FieldsString; |
---|
| 275 | end |
---|
| 276 | elseif ischar(input)% file name introduced as input |
---|
| 277 | inputfile=input; |
---|
| 278 | elseif isnumeric(input)%simple matrix introduced as input |
---|
| 279 | sizinput=size(input); |
---|
| 280 | if sizinput(1)<=1 || sizinput(2)<=1 |
---|
| 281 | msgbox_uvmat('ERROR','bad input for uvmat: file name, structure or numerical matrix accepted') |
---|
| 282 | return |
---|
| 283 | end |
---|
| 284 | UvData.Field.ListVarName={'A','coord_y','coord_x'}; |
---|
| 285 | UvData.Field.VarDimName={{'coord_y','coord_x'},'cord_y','coord_x'}; |
---|
| 286 | UvData.Field.A=input; |
---|
| 287 | UvData.Field.coord_x=[0.5 size(input,2)-0.5]; |
---|
| 288 | UvData.Field.coord_y=[size(input,1)-0.5 0.5]; |
---|
| 289 | testinputfield=1; |
---|
| 290 | end |
---|
| 291 | else |
---|
[476] | 292 | %% check the path and date of modification of all functions in uvmat |
---|
| 293 | path_to_uvmat=which ('uvmat');% check the path detected for source file uvmat |
---|
| 294 | [infomsg,date_str,svn_info]=check_files;%check the path of the functions called by uvmat.m |
---|
| 295 | date_str=['last modification: ' date_str]; |
---|
| 296 | if ishandle(handles.UVMAT_title) |
---|
| 297 | set(handles.UVMAT_title,'String',... |
---|
| 298 | [{'Copyright LEGI UMR 5519 /CNRS-UJF-Grenoble INP, 2010'};... |
---|
| 299 | {'GNU General Public License'};... |
---|
| 300 | {path_to_uvmat};... |
---|
| 301 | {date_str};... |
---|
| 302 | infomsg]); |
---|
| 303 | end |
---|
[387] | 304 | end |
---|
| 305 | set(handles.uvmat,'UserData',UvData) |
---|
| 306 | if ~isempty(inputfile) |
---|
| 307 | %%%%% display the input field %%%%%%% |
---|
[406] | 308 | display_file_name(handles,inputfile) |
---|
[387] | 309 | %%%%%%% |
---|
| 310 | end |
---|
| 311 | |
---|
| 312 | set_vec_col_bar(handles) %update the display of color code for vectors |
---|
| 313 | |
---|
| 314 | %------------------------------------------------------------------------ |
---|
| 315 | % --- Outputs from this function are returned to the command menuline. |
---|
| 316 | function varargout = uvmat_OutputFcn(hObject, eventdata, handles) |
---|
| 317 | varargout{1} = handles.output;% the only output argument is the handle to the GUI figure |
---|
| 318 | |
---|
| 319 | %------------------------------------------------------------------------ |
---|
[402] | 320 | % --- executed when closing uvmat: delete or desactivate the associated figures if exist |
---|
| 321 | function closefcn(gcbo,eventdata) |
---|
[387] | 322 | %------------------------------------------------------------------------ |
---|
[402] | 323 | hh=findobj(allchild(0),'tag','view_field'); |
---|
| 324 | if ~isempty(hh) |
---|
| 325 | delete(hh) |
---|
| 326 | end |
---|
| 327 | hh=findobj(allchild(0),'tag','geometry_calib'); |
---|
| 328 | if ~isempty(hh) |
---|
| 329 | delete(hh) |
---|
| 330 | end |
---|
| 331 | hh=findobj(allchild(0),'tag','set_object'); |
---|
| 332 | if ~isempty(hh) |
---|
| 333 | hhh=findobj(hh,'tag','PLOT'); |
---|
| 334 | set(hhh,'enable','off') |
---|
| 335 | end |
---|
| 336 | |
---|
| 337 | %------------------------------------------------------------------------ |
---|
| 338 | %------------------------------------------------------------------------ |
---|
[387] | 339 | % II - FUNCTIONS FOR INTRODUCING THE INPUT FILES |
---|
| 340 | % automatically sets the global properties when the rootfile name is introduced |
---|
| 341 | % then activate the view-field action if selected |
---|
| 342 | % it is activated either by clicking on the RootPath window or by the |
---|
| 343 | % browser |
---|
| 344 | %------------------------------------------------------------------------ |
---|
| 345 | %------------------------------------------------------------------------ |
---|
| 346 | % --- Executes on the menu Open/Browse... |
---|
| 347 | % search the files, recognize their type according to their name and fill the rootfile input windows |
---|
| 348 | function MenuBrowse_Callback(hObject, eventdata, handles) |
---|
| 349 | [RootPath,SubDir,RootFile,FileIndices,FileExt]=read_file_boxes(handles); |
---|
[609] | 350 | oldfile=[fullfile(RootPath,SubDir,RootFile) FileIndices FileExt]; |
---|
[576] | 351 | if isempty(oldfile) %loads the previously stored file name and set it as default in the file_input box |
---|
| 352 | oldfile=get(handles.RootPath,'UserData'); |
---|
[387] | 353 | end |
---|
[609] | 354 | fileinput=uigetfile_uvmat('select an input file:',oldfile); |
---|
[611] | 355 | |
---|
| 356 | %% display the selected field and related information |
---|
[609] | 357 | if ~isempty(fileinput) |
---|
[606] | 358 | display_file_name(handles,fileinput) |
---|
| 359 | end |
---|
[387] | 360 | |
---|
| 361 | % ----------------------------------------------------------------------- |
---|
[569] | 362 | % --- Executes on the menu Open/Browse campaign... |
---|
| 363 | % search the file inside a campaign, using the GUI view_data |
---|
| 364 | function MenuBrowseCampaign_Callback(hObject, eventdata, handles) |
---|
| 365 | % ----------------------------------------------------------------------- |
---|
[576] | 366 | RootPath=get(handles.RootPath,'String'); |
---|
| 367 | if isempty(RootPath) |
---|
| 368 | RootPath=get(handles.RootPath,'UserData');%use Rootpath recored from the personal file at uvmat opening |
---|
| 369 | end |
---|
| 370 | CampaignPath=fileparts(fileparts(RootPath)); |
---|
[569] | 371 | DirFull = uigetdir(CampaignPath,'Select a Campaign dir, then press OK'); |
---|
| 372 | if ~ischar(DirFull)|| ~exist(DirFull,'dir') |
---|
| 373 | return |
---|
| 374 | end |
---|
| 375 | OutPut=browse_data(DirFull);% open the GUI browse_data to get select a campaign dir, experiment and device |
---|
| 376 | if ~isfield(OutPut,'Campaign') |
---|
| 377 | return |
---|
| 378 | end |
---|
| 379 | DirName=fullfile(OutPut.Campaign,OutPut.Experiment{1},OutPut.Device{1}); |
---|
| 380 | hdir=dir(DirName); %list files and dirs |
---|
| 381 | for ilist=1:numel(hdir) |
---|
| 382 | if ~isequal(hdir(ilist).isdir,1)%look for files, not dir |
---|
| 383 | FileName=hdir(ilist).name; |
---|
| 384 | FileType=get_file_type(fullfile(DirName,FileName)); |
---|
| 385 | switch FileType |
---|
| 386 | case {'image','multimage','civx','civdata','netcdf'} |
---|
| 387 | break |
---|
| 388 | end |
---|
| 389 | end |
---|
| 390 | end |
---|
| 391 | |
---|
| 392 | %% display the selected field and related information |
---|
| 393 | display_file_name( handles,fullfile(DirName,FileName)) |
---|
| 394 | |
---|
| 395 | % ----------------------------------------------------------------------- |
---|
[387] | 396 | % --- Open again the file whose name has been recorded in MenuFile_1 |
---|
| 397 | function MenuFile_1_Callback(hObject, eventdata, handles) |
---|
| 398 | %------------------------------------------------------------------------ |
---|
| 399 | fileinput=get(handles.MenuFile_1,'Label'); |
---|
[406] | 400 | display_file_name( handles,fileinput) |
---|
[387] | 401 | |
---|
| 402 | % ----------------------------------------------------------------------- |
---|
| 403 | % --- Open again the file whose name has been recorded in MenuFile_2 |
---|
| 404 | function MenuFile_2_Callback(hObject, eventdata, handles) |
---|
| 405 | %------------------------------------------------------------------------ |
---|
| 406 | fileinput=get(handles.MenuFile_2,'Label'); |
---|
[406] | 407 | display_file_name(handles,fileinput) |
---|
[387] | 408 | |
---|
| 409 | % ----------------------------------------------------------------------- |
---|
| 410 | % --- Open again the file whose name has been recorded in MenuFile_3 |
---|
| 411 | function MenuFile_3_Callback(hObject, eventdata, handles) |
---|
| 412 | %------------------------------------------------------------------------ |
---|
| 413 | fileinput=get(handles.MenuFile_3,'Label'); |
---|
[406] | 414 | display_file_name(handles,fileinput) |
---|
[387] | 415 | |
---|
| 416 | % ----------------------------------------------------------------------- |
---|
| 417 | % --- Open again the file whose name has been recorded in MenuFile_4 |
---|
| 418 | function MenuFile_4_Callback(hObject, eventdata, handles) |
---|
| 419 | %------------------------------------------------------------------------ |
---|
| 420 | fileinput=get(handles.MenuFile_4,'Label'); |
---|
[406] | 421 | display_file_name(handles,fileinput) |
---|
[387] | 422 | |
---|
| 423 | % ----------------------------------------------------------------------- |
---|
| 424 | % --- Open again the file whose name has been recorded in MenuFile_5 |
---|
| 425 | function MenuFile_5_Callback(hObject, eventdata, handles) |
---|
| 426 | %------------------------------------------------------------------------ |
---|
| 427 | fileinput=get(handles.MenuFile_5,'Label'); |
---|
[406] | 428 | display_file_name(handles,fileinput) |
---|
[387] | 429 | |
---|
[402] | 430 | %------------------------------------------------------------------------ |
---|
| 431 | % --- Executes on the menu Open/Browse_1 for the second input field, |
---|
| 432 | % search the files, recognize their type according to their name and fill the rootfile input windows |
---|
| 433 | function MenuBrowse_1_Callback(hObject, eventdata, handles) |
---|
| 434 | %------------------------------------------------------------------------ |
---|
| 435 | RootPath=get(handles.RootPath,'String'); |
---|
[609] | 436 | SubDir=get(handles.SubDir,'String'); |
---|
| 437 | fileinput_1=uigetfile_uvmat('select a second input file:',fullfile(RootPath,SubDir)); |
---|
| 438 | if ~isempty(fileinput_1) |
---|
| 439 | % [FileName, PathName] = uigetfile({'*.*','All Files(*.*)'},'Pick a file',RootPath); |
---|
| 440 | % if ~ischar(FileName),return,end %abandon if the browser is cancelled |
---|
| 441 | % fileinput_1=[PathName FileName];%complete file name |
---|
| 442 | |
---|
| 443 | % refresh the current displayed field |
---|
| 444 | set(handles.SubField,'Value',1) |
---|
| 445 | display_file_name(handles,fileinput_1,2) |
---|
| 446 | |
---|
| 447 | %update list of recent files in the menubar |
---|
| 448 | MenuFile_1=fileinput_1; |
---|
| 449 | MenuFile_2=get(handles.MenuFile_1,'Label'); |
---|
| 450 | MenuFile_3=get(handles.MenuFile_2,'Label'); |
---|
| 451 | MenuFile_4=get(handles.MenuFile_3,'Label'); |
---|
| 452 | MenuFile_5=get(handles.MenuFile_4,'Label'); |
---|
| 453 | set(handles.MenuFile_1,'Label',MenuFile_1) |
---|
| 454 | set(handles.MenuFile_2,'Label',MenuFile_2) |
---|
| 455 | set(handles.MenuFile_3,'Label',MenuFile_3) |
---|
| 456 | set(handles.MenuFile_4,'Label',MenuFile_4) |
---|
| 457 | set(handles.MenuFile_5,'Label',MenuFile_5) |
---|
| 458 | set(handles.MenuFile_1_1,'Label',MenuFile_1) |
---|
| 459 | set(handles.MenuFile_2_1,'Label',MenuFile_2) |
---|
| 460 | set(handles.MenuFile_3_1,'Label',MenuFile_3) |
---|
| 461 | set(handles.MenuFile_4_1,'Label',MenuFile_4) |
---|
| 462 | set(handles.MenuFile_5_1,'Label',MenuFile_5) |
---|
| 463 | end |
---|
[402] | 464 | |
---|
[569] | 465 | % -------------------------------------------------------------------- |
---|
| 466 | function MenuBrowseCampaign_1_Callback(hObject, eventdata, handles) |
---|
[402] | 467 | % ----------------------------------------------------------------------- |
---|
[569] | 468 | CampaignPath=fileparts(fileparts(get(handles.RootPath,'String'))); |
---|
| 469 | DirFull = uigetdir(CampaignPath,'Select a Campaign dir, then press OK'); |
---|
| 470 | if ~ischar(DirFull)|| ~exist(DirFull,'dir') |
---|
| 471 | return |
---|
| 472 | end |
---|
| 473 | OutPut=browse_data(DirFull);% open the GUI browse_data to get select a campaign dir, experiment and device |
---|
| 474 | if ~isfield(OutPut,'Campaign') |
---|
| 475 | return |
---|
| 476 | end |
---|
| 477 | DirName=fullfile(OutPut.Campaign,OutPut.Experiment{1},OutPut.Device{1}); |
---|
| 478 | hdir=dir(DirName); %list files and dirs |
---|
| 479 | for ilist=1:numel(hdir) |
---|
| 480 | if ~isequal(hdir(ilist).isdir,1)%look for files, not dir |
---|
| 481 | FileName=hdir(ilist).name; |
---|
| 482 | FileType=get_file_type(fullfile(DirName,FileName)); |
---|
| 483 | switch FileType |
---|
| 484 | case {'image','multimage','civx','civdata','netcdf'} |
---|
| 485 | break |
---|
| 486 | end |
---|
| 487 | end |
---|
| 488 | end |
---|
| 489 | |
---|
| 490 | %% display the selected field and related information |
---|
| 491 | set(handles.SubField,'Value',1) |
---|
| 492 | display_file_name( handles,fullfile(DirName,FileName),2) |
---|
| 493 | |
---|
| 494 | % ----------------------------------------------------------------------- |
---|
[402] | 495 | % --- Open again as second field the file whose name has been recorded in MenuFile_1 |
---|
| 496 | function MenuFile_1_1_Callback(hObject, eventdata, handles) |
---|
| 497 | % ----------------------------------------------------------------------- |
---|
| 498 | fileinput_1=get(handles.MenuFile_1_1,'Label'); |
---|
| 499 | set(handles.SubField,'Value',1) |
---|
[406] | 500 | display_file_name(handles,fileinput_1,2) |
---|
[402] | 501 | |
---|
| 502 | % ----------------------------------------------------------------------- |
---|
| 503 | % --- Open again as second field the file whose name has been recorded in MenuFile_2 |
---|
| 504 | function MenuFile_2_1_Callback(hObject, eventdata, handles) |
---|
| 505 | % ----------------------------------------------------------------------- |
---|
| 506 | fileinput_1=get(handles.MenuFile_2_1,'Label'); |
---|
| 507 | set(handles.SubField,'Value',1) |
---|
[406] | 508 | display_file_name(handles,fileinput_1,2) |
---|
[402] | 509 | |
---|
| 510 | % ----------------------------------------------------------------------- |
---|
| 511 | % --- Open again as second field the file whose name has been recorded in MenuFile_3 |
---|
| 512 | function MenuFile_3_1_Callback(hObject, eventdata, handles) |
---|
| 513 | % ----------------------------------------------------------------------- |
---|
| 514 | fileinput_1=get(handles.MenuFile_3_1,'Label'); |
---|
| 515 | set(handles.SubField,'Value',1) |
---|
[406] | 516 | display_file_name(handles,fileinput_1,2) |
---|
[402] | 517 | |
---|
| 518 | % ----------------------------------------------------------------------- |
---|
| 519 | % --- Open again as second field the file whose name has been recorded in MenuFile_4 |
---|
| 520 | function MenuFile_4_1_Callback(hObject, eventdata, handles) |
---|
| 521 | % ----------------------------------------------------------------------- |
---|
| 522 | fileinput_1=get(handles.MenuFile_4_1,'Label'); |
---|
| 523 | set(handles.SubField,'Value',1) |
---|
[406] | 524 | display_file_name(handles,fileinput_1,2) |
---|
[402] | 525 | |
---|
| 526 | % ----------------------------------------------------------------------- |
---|
| 527 | % --- Open again as second field the file whose name has been recorded in MenuFile_5 |
---|
| 528 | function MenuFile_5_1_Callback(hObject, eventdata, handles) |
---|
| 529 | % ----------------------------------------------------------------------- |
---|
| 530 | fileinput_1=get(handles.MenuFile_5_1,'Label'); |
---|
| 531 | set(handles.SubField,'Value',1) |
---|
[406] | 532 | display_file_name(handles,fileinput_1,2) |
---|
[402] | 533 | |
---|
| 534 | %------------------------------------------------------------------------ |
---|
| 535 | % --- Called by action in RootPath edit box |
---|
| 536 | function RootPath_Callback(hObject,eventdata,handles) |
---|
| 537 | %------------------------------------------------------------------------ |
---|
| 538 | % read the current input file name: |
---|
| 539 | [RootPath,SubDir,RootFile,FileIndices,FileExt]=read_file_boxes(handles); |
---|
[456] | 540 | if ~exist(fullfile(RootPath,SubDir),'dir') |
---|
| 541 | msgbox_uvmat('ERROR',['directory ' fullfile(RootPath,SubDir) ' does not exist']) |
---|
| 542 | return |
---|
| 543 | end |
---|
[402] | 544 | % detect the file type, get the movie object if relevant, and look for the corresponding file series: |
---|
[599] | 545 | [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] | 546 | % initiate the input file series and refresh the current field view: |
---|
[601] | 547 | update_rootinfo(handles,i1_series,i2_series,j1_series,j2_series,FileType,MovieObject,1); |
---|
[402] | 548 | |
---|
| 549 | %----------------------------------------------------------------------- |
---|
| 550 | % --- Called by action in RootPath_1 edit box |
---|
| 551 | function RootPath_1_Callback(hObject,eventdata,handles) |
---|
| 552 | % ----------------------------------------------------------------------- |
---|
| 553 | % update_rootinfo_1(hObject,eventdata,handles) |
---|
| 554 | [RootPath,SubDir,RootFile,FileIndices,FileExt]=read_file_boxes_1(handles); |
---|
[456] | 555 | if ~exist(fullfile(RootPath,SubDir),'dir') |
---|
| 556 | msgbox_uvmat('ERROR',['directory ' fullfile(RootPath,SubDir) ' does not exist']) |
---|
| 557 | return |
---|
| 558 | end |
---|
[402] | 559 | % detect the file type, get the movie object if relevant, and look for the corresponding file series: |
---|
| 560 | [RootPath,SubDir,RootFile,i1_series,i2_series,j1_series,j2_series,tild,FileType,MovieObject]=find_file_series(fullfile(RootPath,SubDir),[RootFile FileIndices FileExt]); |
---|
| 561 | % initiate the input file series and refresh the current field view: |
---|
| 562 | update_rootinfo(handles,i1_series,i2_series,j1_series,j2_series,FileType,MovieObject,2); |
---|
| 563 | |
---|
| 564 | %------------------------------------------------------------------------ |
---|
| 565 | % --- Called by action in RootFile edit box |
---|
| 566 | function SubDir_Callback(hObject, eventdata, handles) |
---|
| 567 | %------------------------------------------------------------------------ |
---|
[526] | 568 | %refresh the menu of input fieldname |
---|
[402] | 569 | Fields_Callback(hObject, eventdata, handles); |
---|
| 570 | % refresh the current field view |
---|
| 571 | run0_Callback(hObject, eventdata, handles); |
---|
| 572 | |
---|
| 573 | %------------------------------------------------------------------------ |
---|
| 574 | % --- Called by action in RootFile edit box |
---|
| 575 | function RootFile_Callback(hObject, eventdata, handles) |
---|
| 576 | %------------------------------------------------------------------------ |
---|
| 577 | RootPath_Callback(hObject,eventdata,handles) |
---|
| 578 | |
---|
| 579 | %----------------------------------------------------------------------- |
---|
| 580 | % --- Called by action in RootFile_1 edit box |
---|
| 581 | function RootFile_1_Callback(hObject, eventdata, handles) |
---|
| 582 | % ----------------------------------------------------------------------- |
---|
| 583 | RootPath_1_Callback(hObject,eventdata,handles) |
---|
| 584 | |
---|
| 585 | %------------------------------------------------------------------------ |
---|
| 586 | % --- Called by action in FileIndex edit box |
---|
| 587 | function FileIndex_Callback(hObject, eventdata, handles) |
---|
| 588 | %------------------------------------------------------------------------ |
---|
| 589 | [tild,tild,tild,i1,i2,j1,j2]=fileparts_uvmat(get(handles.FileIndex,'String')); |
---|
| 590 | set(handles.i1,'String',num2str(i1)); |
---|
| 591 | set(handles.i2,'String',num2str(i2)); |
---|
| 592 | set(handles.j1,'String',num2str(j1)); |
---|
| 593 | set(handles.j2,'String',num2str(j2)); |
---|
| 594 | |
---|
| 595 | % refresh the current field view |
---|
| 596 | run0_Callback(hObject, eventdata, handles) |
---|
| 597 | |
---|
| 598 | %------------------------------------------------------------------------ |
---|
| 599 | % --- Called by action in FileIndex_1 edit box |
---|
| 600 | function FileIndex_1_Callback(hObject, eventdata, handles) |
---|
| 601 | %------------------------------------------------------------------------ |
---|
| 602 | run0_Callback(hObject, eventdata, handles) |
---|
| 603 | |
---|
| 604 | %------------------------------------------------------------------------ |
---|
| 605 | % --- Called by action in NomType edit box |
---|
| 606 | function NomType_Callback(hObject, eventdata, handles) |
---|
| 607 | %------------------------------------------------------------------------ |
---|
| 608 | i1=str2num(get(handles.i1,'String')); |
---|
| 609 | i2=str2num(get(handles.i2,'String')); |
---|
| 610 | j1=str2num(get(handles.j1,'String')); |
---|
| 611 | j2=str2num(get(handles.j2,'String')); |
---|
| 612 | FileIndex=fullfile_uvmat('','','','',get(handles.NomType,'String'),i1,i2,j1,j2); |
---|
| 613 | set(handles.FileIndex,'String',FileIndex) |
---|
| 614 | % refresh the current settings and refresh the field view |
---|
| 615 | RootPath_Callback(hObject,eventdata,handles) |
---|
| 616 | |
---|
| 617 | %------------------------------------------------------------------------ |
---|
| 618 | % --- Called by action in NomType edit box |
---|
| 619 | function NomType_1_Callback(hObject, eventdata, handles) |
---|
| 620 | %------------------------------------------------------------------------ |
---|
| 621 | i1=str2num(get(handles.i1,'String')); |
---|
| 622 | i2=str2num(get(handles.i2,'String')); |
---|
| 623 | j1=str2num(get(handles.j1,'String')); |
---|
| 624 | j2=str2num(get(handles.j2,'String')); |
---|
| 625 | FileIndex=fullfile_uvmat('','','','',get(handles.NomType_1,'String'),i1,i2,j1,j2); |
---|
| 626 | set(handles.FileIndex_1,'String',FileIndex) |
---|
| 627 | % refresh the current settings and refresh the field view |
---|
| 628 | RootPath_1_Callback(hObject,eventdata,handles) |
---|
| 629 | |
---|
[387] | 630 | %------------------------------------------------------------------------ |
---|
| 631 | % --- Fills the edit boxes RootPath, RootFile,NomType...from an input file name 'fileinput' |
---|
[406] | 632 | function display_file_name(handles,fileinput,index) |
---|
[387] | 633 | %------------------------------------------------------------------------ |
---|
| 634 | %% look for the input file existence |
---|
| 635 | if ~exist(fileinput,'file') |
---|
| 636 | msgbox_uvmat('ERROR',['input file ' fileinput ' does not exist']) |
---|
| 637 | return |
---|
| 638 | end |
---|
| 639 | |
---|
| 640 | %% set the mouse pointer to 'watch' |
---|
| 641 | set(handles.uvmat,'Pointer','watch') |
---|
| 642 | set(handles.RootPath,'BackgroundColor',[1 1 0]) |
---|
| 643 | drawnow |
---|
| 644 | |
---|
[406] | 645 | %% define the relevant handles for the first field series (index=1) or the second file series (index=2) |
---|
[387] | 646 | if ~exist('index','var') |
---|
| 647 | index=1; |
---|
| 648 | end |
---|
| 649 | if index==1 |
---|
| 650 | handles_RootPath=handles.RootPath; |
---|
| 651 | handles_SubDir=handles.SubDir; |
---|
| 652 | handles_RootFile=handles.RootFile; |
---|
| 653 | handles_FileIndex=handles.FileIndex; |
---|
| 654 | handles_NomType=handles.NomType; |
---|
| 655 | handles_FileExt=handles.FileExt; |
---|
| 656 | elseif index==2 |
---|
| 657 | handles_RootPath=handles.RootPath_1; |
---|
| 658 | handles_SubDir=handles.SubDir_1; |
---|
| 659 | handles_RootFile=handles.RootFile_1; |
---|
| 660 | handles_FileIndex=handles.FileIndex_1; |
---|
| 661 | handles_NomType=handles.NomType_1; |
---|
| 662 | handles_FileExt=handles.FileExt_1; |
---|
| 663 | set(handles.RootPath_1,'Visible','on') |
---|
| 664 | set(handles.RootFile_1,'Visible','on') |
---|
| 665 | set(handles.SubDir_1,'Visible','on'); |
---|
| 666 | set(handles.FileIndex_1,'Visible','on'); |
---|
| 667 | set(handles.FileExt_1,'Visible','on'); |
---|
| 668 | set(handles.NomType_1,'Visible','on'); |
---|
| 669 | end |
---|
| 670 | |
---|
| 671 | %% detect root name, nomenclature and indices in the input file name: |
---|
[398] | 672 | [FilePath,FileName,FileExt]=fileparts(fileinput); |
---|
[387] | 673 | % detect the file type, get the movie object if relevant, and look for the corresponding file series: |
---|
[398] | 674 | % the root name and indices may be corrected by including the first index i1 if a corresponding xml file exists |
---|
[599] | 675 | [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] | 676 | |
---|
| 677 | %% open the file or fill the GUI uvmat according to the detected file type |
---|
| 678 | switch FileType |
---|
| 679 | case '' |
---|
| 680 | msgbox_uvmat('ERROR','invalid input file type') |
---|
| 681 | case 'txt' |
---|
| 682 | edit(fileinput) |
---|
| 683 | case 'figure' %display matlab figure |
---|
| 684 | hfig=open(fileinput); |
---|
| 685 | set(hfig,'WindowButtonMotionFcn','mouse_motion')%set mouse action functio |
---|
| 686 | set(hfig,'WindowButtonUpFcn','mouse_up')%set mouse click action function |
---|
| 687 | set(hfig,'WindowButtonUpFcn','mouse_down')%set mouse click action function |
---|
[503] | 688 | case 'xml' % edit xml files |
---|
[507] | 689 | t=xmltree(fileinput); |
---|
[508] | 690 | % the xml file marks a project or project link, open datatree_browser |
---|
[507] | 691 | if strcmp(get(t,1,'name'),'Project')&& exist(regexprep(fileinput,'.xml$',''),'dir') |
---|
[503] | 692 | datatree_browser(fileinput) |
---|
[508] | 693 | else % other xml file, open the xml editor |
---|
[503] | 694 | editxml(fileinput); |
---|
| 695 | end |
---|
[508] | 696 | case 'xls'% Excel file opended by editxml |
---|
[387] | 697 | editxml(fileinput); |
---|
| 698 | otherwise |
---|
| 699 | set(handles_RootPath,'String',RootPath); |
---|
| 700 | rootname=fullfile(RootPath,SubDir,RootFile); |
---|
| 701 | set(handles_SubDir,'String',['/' SubDir]); |
---|
| 702 | set(handles_RootFile,'String',['/' RootFile]); %display the separator |
---|
| 703 | indices=fileinput(length(rootname)+1:end); |
---|
| 704 | indices(end-length(FileExt)+1:end)=[]; %remove extension |
---|
| 705 | set(handles_FileIndex,'String',indices); |
---|
| 706 | set(handles_NomType,'String',NomType); |
---|
| 707 | set(handles_FileExt,'String',FileExt); |
---|
| 708 | if index==1 |
---|
| 709 | % fill file index counters if the first file series is opened |
---|
| 710 | set(handles.i1,'String',num2str(i1)); |
---|
| 711 | set(handles.i2,'String',num2str(i2)); |
---|
| 712 | set(handles.j1,'String',num2stra(j1,NomType)); |
---|
| 713 | set(handles.j2,'String',num2stra(j2,NomType)); |
---|
[515] | 714 | else %read the current field index to synchronise with the first series |
---|
| 715 | i1_s=str2num(get(handles.i1,'String')); |
---|
| 716 | i2_0=str2num(get(handles.i2,'String')); |
---|
| 717 | if ~isempty(i2_0) |
---|
| 718 | i2_s=i2_0; |
---|
| 719 | else |
---|
| 720 | i2_s=i2; |
---|
| 721 | end |
---|
| 722 | j1_0=stra2num(get(handles.j1,'String')); |
---|
| 723 | if ~isempty(j1_0) |
---|
| 724 | j1_s=j1_0; |
---|
| 725 | else |
---|
| 726 | j1_s=j1; |
---|
| 727 | end |
---|
| 728 | j2_0=stra2num(get(handles.j2,'String')); |
---|
| 729 | if ~isempty(j2_0) |
---|
| 730 | j2_s=j2_0; |
---|
| 731 | else |
---|
| 732 | j2_s=j2; |
---|
| 733 | end |
---|
[387] | 734 | end |
---|
| 735 | |
---|
| 736 | % synchronise indices of the second input file if it exists |
---|
| 737 | if get(handles.SubField,'Value')==1% if the subfield button is activated, update the field numbers |
---|
| 738 | Input=read_GUI(handles.InputFile); |
---|
| 739 | if ~isfield(Input,'RootPath_1')||strcmp(Input.RootPath_1,'"') |
---|
| 740 | Input.RootPath_1=Input.RootPath; |
---|
| 741 | end |
---|
| 742 | if ~isfield(Input,'SubDir_1')||strcmp(Input.SubDir_1,'"') |
---|
| 743 | Input.SubDir_1=Input.SubDir; |
---|
| 744 | end |
---|
| 745 | if ~isfield(Input,'RootFile_1')||strcmp(Input.RootFile_1,'"') |
---|
| 746 | Input.RootFile_1=Input.RootFile; |
---|
| 747 | end |
---|
[405] | 748 | if ~isfield(Input,'FileExt_1')||strcmp(Input.FileExt_1,'"') |
---|
| 749 | Input.FileExt_1=Input.FileExt; |
---|
| 750 | end |
---|
| 751 | if ~isfield(Input,'NomType_1')||strcmp(Input.NomType_1,'"') |
---|
| 752 | Input.NomType_1=Input.NomType; |
---|
| 753 | end |
---|
[387] | 754 | %updtate the indices of the second field series to correspond to the newly opened one |
---|
[515] | 755 | 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] | 756 | if exist(FileName_1,'file') |
---|
[515] | 757 | FileIndex_1=fullfile_uvmat('','','','',Input.NomType_1,i1_s,i2_s,j1_s,j2_s); |
---|
| 758 | else |
---|
[387] | 759 | FileIndex_1=fullfile_uvmat('','','','',Input.NomType_1,i1,i2,j1,j2); |
---|
[408] | 760 | msgbox_uvmat('WARNING','unable to synchronise the indices of the two series') |
---|
[387] | 761 | end |
---|
[515] | 762 | set(handles.FileIndex_1,'String',FileIndex_1) |
---|
[387] | 763 | end |
---|
| 764 | |
---|
| 765 | %enable other menus |
---|
| 766 | set(handles.MenuOpen_1,'Enable','on') |
---|
| 767 | set(handles.MenuFile_1_1,'Enable','on') |
---|
| 768 | set(handles.MenuFile_2_1,'Enable','on') |
---|
| 769 | set(handles.MenuFile_3_1,'Enable','on') |
---|
| 770 | set(handles.MenuFile_4_1,'Enable','on') |
---|
| 771 | set(handles.MenuFile_5_1,'Enable','on') |
---|
| 772 | set(handles.MenuExport,'Enable','on') |
---|
| 773 | set(handles.MenuExportFigure,'Enable','on') |
---|
| 774 | set(handles.MenuExportMovie,'Enable','on') |
---|
| 775 | set(handles.MenuTools,'Enable','on') |
---|
[503] | 776 | |
---|
[387] | 777 | % initiate input file series and refresh the current field view: |
---|
| 778 | update_rootinfo(handles,i1_series,i2_series,j1_series,j2_series,FileType,MovieObject,index); |
---|
| 779 | |
---|
| 780 | end |
---|
| 781 | |
---|
[503] | 782 | %% update list of recent files in the menubar and save it for future opening |
---|
| 783 | MenuFile=[{get(handles.MenuFile_1,'Label')};{get(handles.MenuFile_2,'Label')};... |
---|
| 784 | {get(handles.MenuFile_3,'Label')};{get(handles.MenuFile_4,'Label')};{get(handles.MenuFile_5,'Label')}]; |
---|
| 785 | str_find=strcmp(fileinput,MenuFile); |
---|
| 786 | if isempty(find(str_find,1)) |
---|
| 787 | MenuFile=[{fileinput};MenuFile];%insert the current file if not already in the list |
---|
| 788 | end |
---|
| 789 | for ifile=1:min(length(MenuFile),5) |
---|
[576] | 790 | set(handles.(['MenuFile_' num2str(ifile)]),'Label',MenuFile{ifile}); |
---|
| 791 | set(handles.(['MenuFile_' num2str(ifile) '_1']),'Label',MenuFile{ifile}); |
---|
[503] | 792 | end |
---|
| 793 | dir_perso=prefdir; |
---|
| 794 | profil_perso=fullfile(dir_perso,'uvmat_perso.mat'); |
---|
| 795 | if exist(profil_perso,'file') |
---|
[576] | 796 | save (profil_perso,'MenuFile','RootPath','-append'); %store the file names for future opening of uvmat |
---|
[503] | 797 | else |
---|
[576] | 798 | save (profil_perso,'MenuFile','RootPath','-V6'); %store the file names for future opening of uvmat |
---|
[503] | 799 | end |
---|
| 800 | |
---|
[387] | 801 | %% set back the mouse pointer to arrow |
---|
| 802 | set(handles.uvmat,'Pointer','arrow') |
---|
| 803 | |
---|
| 804 | |
---|
| 805 | %------------------------------------------------------------------------ |
---|
| 806 | % --- Update information about a new field series (indices to scan, timing, |
---|
| 807 | % calibration from an xml file, then refresh current plots |
---|
[515] | 808 | |
---|
[397] | 809 | function update_rootinfo(handles,i1_series,i2_series,j1_series,j2_series,FileType,VideoObject,index) |
---|
[387] | 810 | %------------------------------------------------------------------------ |
---|
| 811 | %% define the relevant handles depending on the index (1=first file series, 2= second file series) |
---|
| 812 | if ~exist('index','var') |
---|
| 813 | index=1; |
---|
| 814 | end |
---|
| 815 | if index==1 |
---|
| 816 | handles_RootPath=handles.RootPath; |
---|
[526] | 817 | handles_Fields=handles.FieldName; |
---|
[387] | 818 | elseif index==2 |
---|
| 819 | handles_RootPath=handles.RootPath_1; |
---|
[526] | 820 | handles_Fields=handles.FieldName_1; |
---|
[387] | 821 | end |
---|
| 822 | |
---|
| 823 | set(handles_RootPath,'BackgroundColor',[1 1 0]) |
---|
| 824 | drawnow |
---|
[526] | 825 | set(handles.FieldName,'UserData',[])% reinialize data from uvmat opening |
---|
[387] | 826 | UvData=get(handles.uvmat,'UserData');%huvmat=handles of the uvmat interface |
---|
| 827 | UvData.NewSeries=1; %flag for run0: begin a new series |
---|
[511] | 828 | UvData.FileName_1='';% name of the current second field (used to detect a constant field during file scanning) |
---|
[387] | 829 | UvData.FileType{index}=FileType; |
---|
| 830 | UvData.i1_series{index}=i1_series; |
---|
| 831 | UvData.i2_series{index}=i2_series; |
---|
| 832 | UvData.j1_series{index}=j1_series; |
---|
| 833 | UvData.j2_series{index}=j2_series; |
---|
| 834 | set(handles.FixVelType,'Value',0); %desactivate fixed veltype |
---|
| 835 | if index==1 |
---|
| 836 | [RootPath,SubDir,RootFile,FileIndices,FileExt]=read_file_boxes(handles); |
---|
| 837 | else |
---|
| 838 | [RootPath,SubDir,RootFile,FileIndices,FileExt]=read_file_boxes_1(handles); |
---|
| 839 | end |
---|
| 840 | FileName=[fullfile(RootPath,SubDir,RootFile) FileIndices FileExt]; |
---|
| 841 | FileBase=fullfile(RootPath,RootFile); |
---|
| 842 | if ~exist(FileName,'file') |
---|
| 843 | msgbox_uvmat('ERROR',['input file ' FileName ' not found']); |
---|
| 844 | return |
---|
| 845 | end |
---|
| 846 | |
---|
| 847 | %% read timing and total frame number from the current file (movie files) !! may be overrid by xml file |
---|
| 848 | XmlData.Time=[];%default |
---|
| 849 | XmlData.GeometryCalib=[];%default |
---|
[494] | 850 | TimeUnit='';%default |
---|
| 851 | Time=[]; |
---|
[387] | 852 | imainfo=[]; |
---|
| 853 | ColorType='falsecolor'; %default |
---|
[397] | 854 | UvData.MovieObject{index}=VideoObject; |
---|
| 855 | if ~isempty(VideoObject) |
---|
| 856 | imainfo=get(VideoObject); |
---|
[387] | 857 | TimeUnit='s'; |
---|
[494] | 858 | if isempty(j1_series); %frame index along i |
---|
[615] | 859 | Time=zeros(imainfo.NumberOfFrames+1,2); |
---|
| 860 | Time(:,2)=(0:1/imainfo.FrameRate:(imainfo.NumberOfFrames)/imainfo.FrameRate)'; |
---|
[494] | 861 | else |
---|
[615] | 862 | Time=[0;ones(size(i1_series,3)-1,1)]*(0:1/imainfo.FrameRate:(imainfo.NumberOfFrames)/imainfo.FrameRate); |
---|
[494] | 863 | end |
---|
[397] | 864 | set(handles.Dt_txt,'String',['Dt=' num2str(1000/imainfo.FrameRate) 'ms']);%display the elementary time interval in millisec |
---|
| 865 | ColorType='truecolor'; |
---|
[387] | 866 | elseif ~isempty(FileExt(2:end))&&(~isempty(imformats(FileExt(2:end))) || isequal(FileExt,'.vol'))%&& isequal(NomType,'*')% multi-frame image |
---|
[548] | 867 | % testima=1; |
---|
[387] | 868 | if ~isequal(SubDir,'') |
---|
| 869 | imainfo=imfinfo([fullfile(RootPath,SubDir,RootFile) FileIndices FileExt]); |
---|
| 870 | else |
---|
| 871 | imainfo=imfinfo([FileBase FileIndices FileExt]); |
---|
| 872 | end |
---|
| 873 | ColorType=imainfo.ColorType;%='truecolor' for color images |
---|
| 874 | end |
---|
| 875 | if isfield(imainfo,'Width') && isfield(imainfo,'Height') |
---|
| 876 | if length(imainfo)>1 |
---|
| 877 | set(handles.num_Npx,'String',num2str(imainfo(1).Width));%fills nbre of pixels x box |
---|
| 878 | set(handles.num_Npy,'String',num2str(imainfo(1).Height));%fills nbre of pixels x box |
---|
| 879 | else |
---|
| 880 | set(handles.num_Npx,'String',num2str(imainfo.Width));%fills nbre of pixels x box |
---|
| 881 | set(handles.num_Npy,'String',num2str(imainfo.Height));%fills nbre of pixels x box |
---|
| 882 | end |
---|
| 883 | else |
---|
| 884 | set(handles.num_Npx,'String','');%fills nbre of pixels x box |
---|
| 885 | set(handles.num_Npy,'String','');%fills nbre of pixels x box |
---|
| 886 | end |
---|
| 887 | set(handles.CheckBW,'Value',strcmp(ColorType,'grayscale'))% select handles.CheckBW if grayscale image |
---|
| 888 | |
---|
| 889 | %% read parameters (time, geometric calibration..) from a documentation file (.xml advised) |
---|
[469] | 890 | XmlFileName=find_imadoc(RootPath,SubDir,RootFile,FileExt); |
---|
| 891 | [tild,tild,DocExt]=fileparts(XmlFileName); |
---|
[387] | 892 | warntext='';%default warning message |
---|
| 893 | NbSlice=1;%default |
---|
[611] | 894 | ImaDoc_str=''; |
---|
[387] | 895 | set(handles.RootPath,'BackgroundColor',[1 1 1]) |
---|
[469] | 896 | if ~isempty(XmlFileName) |
---|
[387] | 897 | set(handles.view_xml,'Visible','on') |
---|
[611] | 898 | set(handles.view_xml,'BackgroundColor',[1 1 0])% paint to yellow color to indicate reading of the xml file |
---|
[387] | 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 |
---|
[611] | 905 | if ~isempty(XmlDataRead) |
---|
| 906 | ImaDoc_str=['view ' DocExt]; |
---|
[456] | 907 | XmlData=XmlDataRead; |
---|
| 908 | if isfield(XmlData,'TimeUnit') |
---|
| 909 | if isfield(XmlData,'TimeUnit')&& ~isempty(XmlData.TimeUnit) |
---|
| 910 | TimeUnit=XmlData.TimeUnit; |
---|
| 911 | end |
---|
[387] | 912 | end |
---|
[611] | 913 | set(handles.view_xml,'BackgroundColor',[1 1 1])% paint black to white |
---|
[456] | 914 | drawnow |
---|
| 915 | if isfield(XmlData, 'GeometryCalib') && ~isempty(XmlData.GeometryCalib) |
---|
| 916 | if isfield(XmlData.GeometryCalib,'VolumeScan') && isequal(XmlData.GeometryCalib.VolumeScan,'y') |
---|
[589] | 917 | set (handles.slices,'String','volume') |
---|
[456] | 918 | end |
---|
| 919 | hgeometry_calib=findobj('tag','geometry_calib'); |
---|
| 920 | if ~isempty(hgeometry_calib) |
---|
| 921 | GUserData=get(hgeometry_calib,'UserData'); |
---|
[469] | 922 | if ~(isfield(GUserData,'XmlInputFile') && strcmp(GUserData.XmlInputFile,XmlFileName)) |
---|
[456] | 923 | answer=msgbox_uvmat('INPUT_Y-N','replace the display of geometry_calib with the new input data?'); |
---|
| 924 | if strcmp(answer,'Yes') |
---|
[469] | 925 | geometry_calib(XmlFileName);%diplay the new calibration points and parameters in geometry_calib |
---|
[456] | 926 | end |
---|
[387] | 927 | end |
---|
| 928 | end |
---|
| 929 | end |
---|
[441] | 930 | end |
---|
[387] | 931 | end |
---|
[494] | 932 | if ~(isfield(XmlData,'Time')&& ~isempty(XmlData.Time)) |
---|
| 933 | XmlData.Time=Time; %time set by video |
---|
| 934 | end |
---|
[611] | 935 | if isempty(ImaDoc_str) |
---|
| 936 | set(handles.view_xml,'Visible','off') |
---|
| 937 | else |
---|
| 938 | set(handles.view_xml,'String',ImaDoc_str) |
---|
| 939 | end |
---|
[387] | 940 | |
---|
| 941 | %% store last index in handles.lat_i and .last_j |
---|
[496] | 942 | nbfield=max(max(max(i2_series))); |
---|
[387] | 943 | if isempty(nbfield) |
---|
[496] | 944 | nbfield=max(max(max(i1_series))); |
---|
[387] | 945 | end |
---|
[496] | 946 | nbfield_j=max(max(max(j2_series))); |
---|
[387] | 947 | if isempty(nbfield_j) |
---|
[552] | 948 | nbfield_j=max(max(max(j1_series))); |
---|
[387] | 949 | end |
---|
| 950 | if ~isempty(XmlData.Time) |
---|
| 951 | %transform .Time to a column vector if it is a line vector the nomenclature uses a single index |
---|
[441] | 952 | if isequal(size(XmlData.Time,1),1) |
---|
[552] | 953 | %NomType=get(handles.NomType,'String'); |
---|
[456] | 954 | XmlData.Time=(XmlData.Time)'; |
---|
[387] | 955 | end |
---|
| 956 | end |
---|
| 957 | last_i_cell=get(handles.last_i,'String'); |
---|
| 958 | if isempty(nbfield) |
---|
[552] | 959 | last_i_cell{index}=''; |
---|
[387] | 960 | else |
---|
[552] | 961 | last_i_cell{index}=num2str(nbfield); |
---|
[387] | 962 | end |
---|
| 963 | set(handles.last_i,'String',last_i_cell) |
---|
| 964 | last_j_cell=get(handles.last_j,'String'); |
---|
| 965 | if isempty(nbfield_j) |
---|
[552] | 966 | last_j_cell{index}=''; |
---|
[387] | 967 | else |
---|
[552] | 968 | last_j_cell{index}=num2str(nbfield_j); |
---|
[387] | 969 | end |
---|
| 970 | set(handles.last_j,'String',last_j_cell); |
---|
| 971 | |
---|
| 972 | %% store geometric calibration in UvData |
---|
| 973 | if isfield(XmlData,'GeometryCalib') |
---|
| 974 | GeometryCalib=XmlData.GeometryCalib; |
---|
| 975 | if isempty(GeometryCalib) |
---|
| 976 | set(handles.pxcm,'String','') |
---|
| 977 | set(handles.pycm,'String','') |
---|
[591] | 978 | set(handles.TransformName,'Value',1); % no transform by default |
---|
[387] | 979 | else |
---|
| 980 | if (isfield(GeometryCalib,'R')&& ~isequal(GeometryCalib.R(2,1),0) && ~isequal(GeometryCalib.R(1,2),0)) ||... |
---|
| 981 | (isfield(GeometryCalib,'kappa1')&& ~isequal(GeometryCalib.kappa1,0)) |
---|
| 982 | set(handles.pxcm,'String','var') |
---|
| 983 | set(handles.pycm,'String','var') |
---|
| 984 | elseif isfield(GeometryCalib,'fx_fy') |
---|
| 985 | pixcmx=GeometryCalib.fx_fy(1);%*GeometryCalib.R(1,1)*GeometryCalib.sx/(GeometryCalib.Tz*GeometryCalib.dpx); |
---|
| 986 | pixcmy=GeometryCalib.fx_fy(2);%*GeometryCalib.R(2,2)/(GeometryCalib.Tz*GeometryCalib.dpy); |
---|
| 987 | set(handles.pxcm,'String',num2str(pixcmx)) |
---|
| 988 | set(handles.pycm,'String',num2str(pixcmy)) |
---|
| 989 | end |
---|
| 990 | if ~get(handles.CheckFixLimits,'Value') |
---|
[591] | 991 | set(handles.TransformName,'Value',3); % phys transform by default if fixedLimits is off |
---|
[387] | 992 | end |
---|
[508] | 993 | if isfield(GeometryCalib,'SliceCoord') |
---|
[387] | 994 | siz=size(GeometryCalib.SliceCoord); |
---|
| 995 | if siz(1)>1 |
---|
| 996 | NbSlice=siz(1); |
---|
| 997 | set(handles.slices,'Visible','on') |
---|
| 998 | set(handles.slices,'Value',1) |
---|
| 999 | end |
---|
| 1000 | if isfield(GeometryCalib,'VolumeScan') && isequal(GeometryCalib.VolumeScan,'y') |
---|
[589] | 1001 | set(handles.num_NbSlice,'Visible','off') |
---|
[387] | 1002 | else |
---|
[589] | 1003 | set(handles.num_NbSlice,'Visible','on') |
---|
[497] | 1004 | set(handles.num_NbSlice,'String',num2str(NbSlice)) |
---|
[387] | 1005 | end |
---|
| 1006 | slices_Callback([],[], handles) |
---|
| 1007 | end |
---|
| 1008 | end |
---|
| 1009 | end |
---|
| 1010 | |
---|
| 1011 | %% update the data attached to the uvmat interface |
---|
| 1012 | if ~isempty(TimeUnit) |
---|
| 1013 | set(handles.time_txt,'String',['time (' TimeUnit ')']) |
---|
| 1014 | end |
---|
| 1015 | UvData.TimeUnit=TimeUnit; |
---|
| 1016 | UvData.XmlData{index}=XmlData; |
---|
| 1017 | UvData.NewSeries=1; |
---|
| 1018 | % UvData.MovieObject=MovieObject; |
---|
| 1019 | |
---|
| 1020 | %display warning message |
---|
| 1021 | if ~isequal(warntext,'') |
---|
| 1022 | msgbox_uvmat('WARNING',warntext); |
---|
| 1023 | end |
---|
| 1024 | |
---|
[526] | 1025 | %% set default options in menu 'FieldName' |
---|
[517] | 1026 | switch FileType |
---|
| 1027 | case {'civx','civdata'} |
---|
[581] | 1028 | % [FieldList,ColorList]=calc_field; |
---|
| 1029 | [FieldList,ColorList]=set_field_list('U','V','C'); |
---|
[525] | 1030 | set(handles_Fields,'String',[{'image'};FieldList;{'get_field...'}]);%standard menu for civx data |
---|
| 1031 | set(handles_Fields,'Value',2) % set menu to 'velocity |
---|
[580] | 1032 | if index==1 |
---|
| 1033 | set(handles.FieldName_1,'Value',1); |
---|
| 1034 | set(handles.FieldName_1,'String',[{''};{'image'};FieldList;{'get_field...'}]);%standard menu for civx data reproduced for the second field |
---|
| 1035 | end |
---|
[525] | 1036 | set(handles.ColorScalar,'Value',1) |
---|
| 1037 | set(handles.ColorScalar,'String',ColorList) |
---|
| 1038 | set(handles.Vectors,'Visible','on') |
---|
| 1039 | set(handles.Coord_x,'Value',1); |
---|
| 1040 | set(handles.Coord_x,'String',{'X'}); |
---|
| 1041 | set(handles.Coord_y,'Value',1); |
---|
| 1042 | set(handles.Coord_y,'String',{'Y'}); |
---|
[517] | 1043 | case 'netcdf' |
---|
[387] | 1044 | set(handles_Fields,'Value',1) |
---|
| 1045 | set(handles_Fields,'String',{'get_field...'}) |
---|
[595] | 1046 | FieldName_Callback([],[], handles) |
---|
| 1047 | % hget_field=get_field(FileName); |
---|
| 1048 | % hhget_field=guidata(hget_field); |
---|
| 1049 | % get_field('RUN_Callback',hhget_field.RUN,[],hhget_field); |
---|
[517] | 1050 | otherwise |
---|
| 1051 | set(handles_Fields,'Value',1) % set menu to 'image' |
---|
| 1052 | set(handles_Fields,'String',{'image'}) |
---|
[525] | 1053 | set(handles.Coord_x,'Value',1); |
---|
| 1054 | set(handles.Coord_x,'String',{'AX'}); |
---|
| 1055 | set(handles.Coord_y,'Value',1); |
---|
| 1056 | set(handles.Coord_y,'String',{'AY'}); |
---|
[387] | 1057 | end |
---|
| 1058 | set(handles.uvmat,'UserData',UvData) |
---|
| 1059 | |
---|
| 1060 | %% set index navigation options and refresh plots |
---|
| 1061 | scan_option='i';%default |
---|
| 1062 | state_j='off'; %default |
---|
| 1063 | if index==2 |
---|
| 1064 | if get(handles.scan_j,'Value') |
---|
[494] | 1065 | scan_option='j'; %keep the scan option for the second file series |
---|
[387] | 1066 | end |
---|
| 1067 | if strcmp(get(handles.j1,'Visible'),'on') |
---|
| 1068 | state_j='on'; |
---|
| 1069 | end |
---|
| 1070 | end |
---|
[515] | 1071 | [ref_j,ref_i]=find(squeeze(i1_series(1,:,:))); |
---|
[387] | 1072 | if ~isempty(j1_series) |
---|
| 1073 | state_j='on'; |
---|
[494] | 1074 | if index==1 |
---|
[515] | 1075 | if isequal(ref_i,ref_i(1)*ones(size(ref_j)))% if ref_i is always equal to its first value |
---|
[494] | 1076 | scan_option='j'; %scan j indext |
---|
| 1077 | end |
---|
| 1078 | end |
---|
[387] | 1079 | end |
---|
| 1080 | if isequal(scan_option,'i') |
---|
[494] | 1081 | diff_ref_i=diff(ref_i,1); |
---|
| 1082 | if isempty(diff_ref_i) |
---|
| 1083 | diff_ref_i=1; |
---|
| 1084 | end |
---|
| 1085 | if isequal (diff_ref_i,diff_ref_i(1)*ones(size(diff_ref_i))) |
---|
[511] | 1086 | set(handles.num_IndexIncrement,'String',num2str(diff_ref_i(1))) |
---|
[494] | 1087 | end |
---|
[387] | 1088 | set(handles.scan_i,'Value',1) |
---|
| 1089 | scan_i_Callback([],[], handles); |
---|
| 1090 | else |
---|
[494] | 1091 | diff_ref_j=diff(ref_j); |
---|
| 1092 | if isempty(diff_ref_j) |
---|
| 1093 | diff_ref_j=1; |
---|
| 1094 | end |
---|
| 1095 | if isequal (diff_ref_j,diff_ref_j(1)*ones(size(diff_ref_j))) |
---|
[511] | 1096 | set(handles.num_IndexIncrement,'String',num2str(diff_ref_j(1))) |
---|
[494] | 1097 | end |
---|
[387] | 1098 | set(handles.scan_j,'Value',1) |
---|
| 1099 | scan_j_Callback([],[], handles); |
---|
| 1100 | end |
---|
| 1101 | set(handles.scan_j,'Visible',state_j) |
---|
| 1102 | set(handles.j1,'Visible',state_j) |
---|
| 1103 | set(handles.j2,'Visible',state_j) |
---|
| 1104 | set(handles.last_j,'Visible',state_j); |
---|
| 1105 | set(handles.frame_j,'Visible',state_j); |
---|
| 1106 | set(handles.j_text,'Visible',state_j); |
---|
| 1107 | if ~isempty(i2_series)||~isempty(j2_series) |
---|
| 1108 | set(handles.CheckFixPair,'Visible','on') |
---|
| 1109 | elseif index==1 |
---|
| 1110 | set(handles.CheckFixPair,'Visible','off') |
---|
| 1111 | end |
---|
| 1112 | |
---|
[508] | 1113 | %% apply the effect of the transform fct and view the field |
---|
[591] | 1114 | transform=get(handles.TransformPath,'UserData'); |
---|
[515] | 1115 | if index==2 && (~isa(transform,'function_handle')||nargin(transform)<3) |
---|
[591] | 1116 | set(handles.TransformName,'value',2); % set transform to sub_field if the current fct doe not accept two input fields |
---|
[515] | 1117 | end |
---|
[591] | 1118 | TransformName_Callback([],[],handles) |
---|
[387] | 1119 | mask_test=get(handles.CheckMask,'value'); |
---|
| 1120 | if mask_test |
---|
| 1121 | MaskData=get(handles.CheckMask,'UserData'); |
---|
| 1122 | if isfield(MaskData,'maskhandle') && ishandle(MaskData.maskhandle) |
---|
| 1123 | delete(MaskData.maskhandle) %delete old mask |
---|
| 1124 | end |
---|
| 1125 | CheckMask_Callback([],[],handles) |
---|
| 1126 | end |
---|
| 1127 | |
---|
| 1128 | %------------------------------------------------------------------------ |
---|
| 1129 | % --- switch file index scanning options scan_i and scan_j in an exclusive way |
---|
| 1130 | function scan_i_Callback(hObject, eventdata, handles) |
---|
| 1131 | %------------------------------------------------------------------------ |
---|
| 1132 | if get(handles.scan_i,'Value')==1 |
---|
[589] | 1133 | % set(handles.scan_i,'BackgroundColor',[1 1 0]) |
---|
[387] | 1134 | set(handles.scan_j,'Value',0) |
---|
| 1135 | else |
---|
[589] | 1136 | % set(handles.scan_i,'BackgroundColor',[0.831 0.816 0.784]) |
---|
[387] | 1137 | set(handles.scan_j,'Value',1) |
---|
| 1138 | end |
---|
| 1139 | scan_j_Callback(hObject, eventdata, handles) |
---|
| 1140 | |
---|
| 1141 | %------------------------------------------------------------------------ |
---|
| 1142 | % --- switch file index scanning options scan_i and scan_j in an exclusive way |
---|
| 1143 | function scan_j_Callback(hObject, eventdata, handles) |
---|
| 1144 | %------------------------------------------------------------------------ |
---|
| 1145 | if get(handles.scan_j,'Value')==1 |
---|
[589] | 1146 | % set(handles.scan_j,'BackgroundColor',[1 1 0]) |
---|
[387] | 1147 | set(handles.scan_i,'Value',0) |
---|
[589] | 1148 | % set(handles.scan_i,'BackgroundColor',[0.831 0.816 0.784]) |
---|
[387] | 1149 | % NomType=get(handles.NomType,'String'); |
---|
| 1150 | % switch NomType |
---|
| 1151 | % case {'_1_1-2','#_ab','%3dab'},% pair with j index |
---|
| 1152 | % set(handles.CheckFixPair,'Visible','on')% option fixed pair on/off made visible (choice of avaible pair with buttons + and - if ='off') |
---|
| 1153 | % otherwise |
---|
| 1154 | % set(handles.CheckFixPair,'Visible','off') |
---|
| 1155 | % end |
---|
| 1156 | else |
---|
[589] | 1157 | % set(handles.scan_j,'BackgroundColor',[0.831 0.816 0.784]) |
---|
[387] | 1158 | set(handles.scan_i,'Value',1) |
---|
[589] | 1159 | % set(handles.scan_i,'BackgroundColor',[1 1 0]) |
---|
[387] | 1160 | set(handles.CheckFixPair,'Visible','off') |
---|
| 1161 | end |
---|
| 1162 | |
---|
| 1163 | %------------------------------------------------------------------------ |
---|
| 1164 | function i1_Callback(hObject, eventdata, handles) |
---|
| 1165 | %------------------------------------------------------------------------ |
---|
[515] | 1166 | update_ij(handles,1) |
---|
[387] | 1167 | |
---|
| 1168 | %------------------------------------------------------------------------ |
---|
| 1169 | function i2_Callback(hObject, eventdata, handles) |
---|
| 1170 | %------------------------------------------------------------------------ |
---|
[515] | 1171 | update_ij(handles,2) |
---|
[387] | 1172 | |
---|
| 1173 | %------------------------------------------------------------------------ |
---|
| 1174 | function j1_Callback(hObject, eventdata, handles) |
---|
| 1175 | %------------------------------------------------------------------------ |
---|
[515] | 1176 | update_ij(handles,3) |
---|
[387] | 1177 | |
---|
| 1178 | %------------------------------------------------------------------------ |
---|
| 1179 | function j2_Callback(hObject, eventdata, handles) |
---|
| 1180 | %------------------------------------------------------------------------ |
---|
[515] | 1181 | update_ij(handles,4) |
---|
[387] | 1182 | |
---|
| 1183 | %------------------------------------------------------------------------ |
---|
[515] | 1184 | %--- update the index display after action on edit boxes i1, i2, j1 or j2 |
---|
| 1185 | function update_ij(handles,index_rank) |
---|
| 1186 | NomType=get(handles.NomType,'String'); |
---|
| 1187 | indices=get(handles.FileIndex,'String'); |
---|
| 1188 | [tild,tild,tild,i1,i2,j1,j2]=fileparts_uvmat(indices);% the indices for the second series taken from FileIndex |
---|
| 1189 | switch index_rank |
---|
| 1190 | case 1 |
---|
| 1191 | indices=fullfile_uvmat('','','','',NomType,stra2num(get(handles.i1,'String')),i2,j1,j2); |
---|
| 1192 | 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 |
---|
| 1193 | case 2 |
---|
| 1194 | indices=fullfile_uvmat('','','','',NomType,i1,stra2num(get(handles.i2,'String')),j1,j2); |
---|
| 1195 | 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 |
---|
| 1196 | case 3 |
---|
| 1197 | indices=fullfile_uvmat('','','','',NomType,i1,i2,stra2num(get(handles.j1,'String')),j2); |
---|
| 1198 | 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 |
---|
| 1199 | case 4 |
---|
| 1200 | indices=fullfile_uvmat('','','','',NomType,i1,i2,j1,stra2num(get(handles.j2,'String'))); |
---|
| 1201 | 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 |
---|
| 1202 | end |
---|
| 1203 | set(handles.FileIndex,'String',indices) |
---|
| 1204 | 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 |
---|
| 1205 | % update the second index if relevant |
---|
| 1206 | if strcmp(get(handles.FileIndex_1,'Visible'),'on') |
---|
| 1207 | NomType_1=get(handles.NomType_1,'String'); |
---|
| 1208 | indices_1=get(handles.FileIndex_1,'String'); |
---|
| 1209 | [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 |
---|
| 1210 | switch index_rank |
---|
| 1211 | case 1 |
---|
| 1212 | indices_1=fullfile_uvmat('','','','',NomType_1,stra2num(get(handles.i1,'String')),i2_1,j1_1,j2_1); |
---|
| 1213 | case 2 |
---|
| 1214 | indices_1=fullfile_uvmat('','','','',NomType_1,i1_1,stra2num(get(handles.i2,'String')),j1_1,j2_1); |
---|
| 1215 | case 3 |
---|
| 1216 | indices_1=fullfile_uvmat('','','','',NomType_1,i1_1,i2_1,stra2num(get(handles.j1,'String')),j2_1); |
---|
| 1217 | case 4 |
---|
| 1218 | indices_1=fullfile_uvmat('','','','',NomType_1,i1_1,i2_1,j1_1,stra2num(get(handles.j2,'String'))); |
---|
| 1219 | end |
---|
| 1220 | set(handles.FileIndex_1,'String',indices_1) |
---|
| 1221 | 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 |
---|
| 1222 | end |
---|
| 1223 | |
---|
| 1224 | %------------------------------------------------------------------------ |
---|
| 1225 | |
---|
| 1226 | %------------------------------------------------------------------------ |
---|
[387] | 1227 | function slices_Callback(hObject, eventdata, handles) |
---|
| 1228 | %------------------------------------------------------------------------ |
---|
[589] | 1229 | if strcmp(get(handles.slices,'String'),'slices') |
---|
| 1230 | if get(handles.slices,'Value')==1 |
---|
| 1231 | set(handles.num_NbSlice,'Visible','on') |
---|
| 1232 | set(handles.z_text,'Visible','on') |
---|
| 1233 | set(handles.z_index,'Visible','on') |
---|
| 1234 | num_NbSlice_Callback(hObject, eventdata, handles) |
---|
| 1235 | else |
---|
| 1236 | set(handles.num_NbSlice,'Visible','off') |
---|
| 1237 | set(handles.z_text,'Visible','off') |
---|
| 1238 | set(handles.z_index,'Visible','off') |
---|
| 1239 | set(handles.masklevel,'Value',1) |
---|
| 1240 | set(handles.masklevel,'String',{'1'}) |
---|
| 1241 | end |
---|
[387] | 1242 | end |
---|
| 1243 | |
---|
| 1244 | %------------------------------------------------------------------------ |
---|
[497] | 1245 | function num_NbSlice_Callback(hObject, eventdata, handles) |
---|
[387] | 1246 | %------------------------------------------------------------------------ |
---|
[589] | 1247 | mode=get(handles.slices,'String'); |
---|
[497] | 1248 | nb_slice_str=get(handles.num_NbSlice,'String'); |
---|
[589] | 1249 | if strcmp(mode,'volume') |
---|
| 1250 | z=stra2num(get(handles.j1,'String')); |
---|
[387] | 1251 | else |
---|
| 1252 | num=str2double(get(handles.i1,'String')); |
---|
[497] | 1253 | nbslice=str2double(get(handles.num_NbSlice,'String')); |
---|
[589] | 1254 | z=mod(num-1,nbslice)+1; |
---|
[387] | 1255 | end |
---|
| 1256 | set(handles.z_index,'String',num2str(z)) |
---|
| 1257 | for ilist=1:nbslice |
---|
| 1258 | list_index{ilist,1}=num2str(ilist); |
---|
| 1259 | end |
---|
| 1260 | set(handles.masklevel,'String',list_index) |
---|
| 1261 | set(handles.masklevel,'Value',z) |
---|
| 1262 | |
---|
| 1263 | %------------------------------------------------------------------------ |
---|
| 1264 | % --- Executes on button press in view_xml. |
---|
| 1265 | function view_xml_Callback(hObject, eventdata, handles) |
---|
| 1266 | %------------------------------------------------------------------------ |
---|
| 1267 | %[FileName,RootPath,FileBase,FileIndices,FileExt]=read_file_boxes(handles); |
---|
| 1268 | [RootPath,SubDir,RootFile,FileIndices,FileExt]=read_file_boxes(handles); |
---|
| 1269 | FileBase=fullfile(RootPath,RootFile); |
---|
| 1270 | option=get(handles.view_xml,'String'); |
---|
| 1271 | if isequal(option,'view .xml') |
---|
[494] | 1272 | FileXml=fullfile(RootPath,[SubDir '.xml']); |
---|
| 1273 | if ~exist(FileXml,'file')% case of civ files , removes the extension for subdir |
---|
| 1274 | FileXml=fullfile(RootPath,[regexprep(SubDir,'\..+$','') '.xml']); |
---|
| 1275 | end |
---|
[387] | 1276 | heditxml=editxml(FileXml); |
---|
| 1277 | end |
---|
| 1278 | |
---|
| 1279 | %------------------------------------------------------------------------ |
---|
| 1280 | % --- Executes on button press in CheckMask. |
---|
| 1281 | function CheckMask_Callback(hObject, eventdata, handles) |
---|
| 1282 | %------------------------------------------------------------------------ |
---|
| 1283 | %case of view mask selection |
---|
| 1284 | if isequal(get(handles.CheckMask,'Value'),1) |
---|
| 1285 | [RootPath,SubDir,RootFile,FileIndices,FileExt]=read_file_boxes(handles); |
---|
| 1286 | FileBase=fullfile(RootPath,RootFile); |
---|
| 1287 | num_i1=stra2num(get(handles.i1,'String')); |
---|
| 1288 | num_j1=stra2num(get(handles.j1,'String')); |
---|
| 1289 | currentdir=pwd; |
---|
| 1290 | cd(RootPath); |
---|
| 1291 | maskfiles=dir('*_*mask_*.png');%look for a mask file |
---|
| 1292 | cd(currentdir);%come back to the working directory |
---|
| 1293 | mdetect=0; |
---|
| 1294 | if ~isempty(maskfiles) |
---|
| 1295 | for ilist=1:length(maskfiles) |
---|
| 1296 | maskname=maskfiles(ilist).name;% take the first mask file in the list |
---|
| 1297 | [tild,tild,tild,tild,tild,tild,tild,MaskExt,Mask_NomType{ilist}]=fileparts_uvmat(maskname); |
---|
| 1298 | [tild,Name]=fileparts(maskname); |
---|
| 1299 | Namedouble=double(Name); |
---|
| 1300 | val=(48>Namedouble)|(Namedouble>57);% select the non-numerical characters |
---|
| 1301 | ind_mask=findstr('mask',Name); |
---|
| 1302 | i=ind_mask-1; |
---|
| 1303 | while val(i)==0 && i>0 |
---|
| 1304 | i=i-1; |
---|
| 1305 | end |
---|
| 1306 | nbmask_str=str2num(Name(i+1:ind_mask-1)); |
---|
| 1307 | if ~isempty(nbmask_str) |
---|
| 1308 | nbslice(ilist)=nbmask_str; % number of different masks (slices) |
---|
| 1309 | end |
---|
| 1310 | end |
---|
| 1311 | if isequal(min(nbslice),max(nbslice)) |
---|
| 1312 | nbslice=nbslice(1); |
---|
| 1313 | else |
---|
| 1314 | msgbox_uvmat('ERROR','several inconsistent mask sets coexist in the current image directory') |
---|
| 1315 | return |
---|
| 1316 | end |
---|
| 1317 | if ~isempty(nbslice) && Name(i)=='_' |
---|
| 1318 | Mask.Base=[FileBase Name(i:ind_mask+3)]; |
---|
| 1319 | Mask.NbSlice=nbslice; |
---|
| 1320 | num_i1=mod(num_i1-1,nbslice)+1; |
---|
| 1321 | Mask.NomType=regexprep(Mask_NomType{1},'0','');%remove '0' in nom type for masks |
---|
| 1322 | [RootPath,RootFile]=fileparts(Mask.Base); |
---|
| 1323 | maskname=fullfile_uvmat(RootPath,'',RootFile,'.png',Mask.NomType,num_i1,[],num_j1); |
---|
| 1324 | %maskname=name_generator(Mask.Base,num_i1,num_j1,'.png',Mask.NomType);% |
---|
| 1325 | mdetect=exist(maskname,'file'); |
---|
| 1326 | if mdetect |
---|
[497] | 1327 | set(handles.num_NbSlice,'String',Name(i+1:ind_mask-1)); |
---|
[589] | 1328 | set(handles.num_NbSlice,'BackgroundColor',[1 1 0]) |
---|
[387] | 1329 | set(handles.CheckMask,'UserData',Mask); |
---|
| 1330 | set(handles.CheckMask,'BackgroundColor',[1 1 0]) |
---|
| 1331 | if nbslice > 1 |
---|
| 1332 | set(handles.slices,'value',1) |
---|
| 1333 | slices_Callback(hObject, eventdata, handles) |
---|
| 1334 | end |
---|
| 1335 | end |
---|
| 1336 | end |
---|
| 1337 | end |
---|
| 1338 | errormsg=[];%default |
---|
| 1339 | if mdetect==0 |
---|
| 1340 | [FileName, PathName, filterindex] = uigetfile( ... |
---|
| 1341 | {'*.png', ' (*.png)'; |
---|
| 1342 | '*.png', '.png files '; ... |
---|
| 1343 | '*.*', 'All Files (*.*)'}, ... |
---|
| 1344 | 'Pick a mask file *.png',FileBase); |
---|
[530] | 1345 | if ~ischar(FileName),return,end %abandon if the browser is cancelled |
---|
[387] | 1346 | maskname=fullfile(PathName,FileName); |
---|
[444] | 1347 | [RootDir,SubDir,RootFile,tild,tild,tild,tild,tild,Mask.NomType]=fileparts_uvmat(maskname); |
---|
| 1348 | Mask.Base=fullfile(RootDir,SubDir,RootFile); |
---|
[387] | 1349 | Mask.NbSlice=1; |
---|
| 1350 | set(handles.CheckMask,'UserData',Mask); |
---|
| 1351 | set(handles.CheckMask,'BackgroundColor',[1 1 0]) |
---|
| 1352 | end |
---|
| 1353 | if isempty(errormsg) |
---|
| 1354 | errormsg=update_mask(handles,num_i1,num_j1); |
---|
| 1355 | end |
---|
| 1356 | if ~isempty(errormsg) |
---|
| 1357 | set(handles.CheckMask,'Value',0) |
---|
| 1358 | set(handles.CheckMask,'BackgroundColor',[0.7 0.7 0.7]) |
---|
| 1359 | end |
---|
| 1360 | else % desactivate mask display |
---|
| 1361 | MaskData=get(handles.CheckMask,'UserData'); |
---|
| 1362 | if isfield(MaskData,'maskhandle') && ishandle(MaskData.maskhandle) |
---|
| 1363 | delete(MaskData.maskhandle) |
---|
| 1364 | end |
---|
| 1365 | set(handles.CheckMask,'UserData',[]) |
---|
| 1366 | UvData=get(handles.uvmat,'UserData'); |
---|
| 1367 | if isfield(UvData,'MaskName') |
---|
| 1368 | UvData=rmfield(UvData,'MaskName'); |
---|
| 1369 | set(handles.uvmat,'UserData',UvData) |
---|
| 1370 | end |
---|
| 1371 | set(handles.CheckMask,'BackgroundColor',[0.7 0.7 0.7]) |
---|
| 1372 | end |
---|
| 1373 | |
---|
| 1374 | %------------------------------------------------------------------------ |
---|
| 1375 | function errormsg=update_mask(handles,num_i1,num_j1) |
---|
| 1376 | %------------------------------------------------------------------------ |
---|
| 1377 | errormsg=[];%default |
---|
| 1378 | MaskData=get(handles.CheckMask,'UserData'); |
---|
| 1379 | if isfield(MaskData,'maskhandle')&& ishandle(MaskData.maskhandle) |
---|
| 1380 | uistack(MaskData.maskhandle,'top'); |
---|
| 1381 | end |
---|
| 1382 | num_i1_mask=mod(num_i1-1,MaskData.NbSlice)+1; |
---|
| 1383 | [RootPath,RootFile]=fileparts(MaskData.Base); |
---|
| 1384 | MaskName=fullfile_uvmat(RootPath,'',RootFile,'.png',MaskData.NomType,num_i1_mask,[],num_j1); |
---|
| 1385 | UvData=get(handles.uvmat,'UserData'); |
---|
| 1386 | %update mask image if the mask is new |
---|
| 1387 | if ~ (isfield(UvData,'MaskName') && isequal(UvData.MaskName,MaskName)) |
---|
| 1388 | UvData.MaskName=MaskName; %update the recorded name on UvData |
---|
| 1389 | set(handles.uvmat,'UserData',UvData); |
---|
| 1390 | if ~exist(MaskName,'file') |
---|
| 1391 | if isfield(MaskData,'maskhandle')&& ishandle(MaskData.maskhandle) |
---|
| 1392 | delete(MaskData.maskhandle) |
---|
| 1393 | end |
---|
| 1394 | else |
---|
| 1395 | %read mask image |
---|
[542] | 1396 | [Mask,tild,errormsg] = read_field(MaskName,'image'); |
---|
| 1397 | % Mask.AName='image'; |
---|
| 1398 | % Mask.A=imread(MaskName); |
---|
| 1399 | if ~isempty(errormsg) |
---|
| 1400 | return |
---|
| 1401 | end |
---|
[387] | 1402 | npxy=size(Mask.A); |
---|
| 1403 | if length(npxy)>2 |
---|
| 1404 | errormsg=[MaskName ' is not a grey scale image']; |
---|
| 1405 | return |
---|
| 1406 | elseif ~isa(Mask.A,'uint8') |
---|
| 1407 | errormsg=[MaskName ' is not a 8 bit grey level image']; |
---|
| 1408 | return |
---|
| 1409 | end |
---|
[542] | 1410 | % Mask.AX=[0.5 npxy(2)-0.5]; |
---|
| 1411 | % Mask.AY=[npxy(1)-0.5 0.5 ]; |
---|
| 1412 | % Mask.CoordUnit='pixel'; |
---|
[387] | 1413 | if isequal(get(handles.slices,'Value'),1) |
---|
[497] | 1414 | NbSlice=str2num(get(handles.num_NbSlice,'String')); |
---|
[387] | 1415 | num_i1=str2num(get(handles.i1,'String')); |
---|
| 1416 | Mask.ZIndex=mod(num_i1-1,NbSlice)+1; |
---|
| 1417 | end |
---|
| 1418 | %px to phys or other transform on field |
---|
[591] | 1419 | menu_transform=get(handles.TransformName,'String'); |
---|
| 1420 | choice_value=get(handles.TransformName,'Value'); |
---|
[387] | 1421 | transform_name=menu_transform{choice_value};%name of the transform fct given by the menu 'transform_fct' |
---|
[591] | 1422 | transform=get(handles.TransformPath,'UserData'); |
---|
[387] | 1423 | if ~isequal(transform_name,'') && ~isequal(transform_name,'px') |
---|
| 1424 | if isfield(UvData,'XmlData') && isfield(UvData.XmlData{1},'GeometryCalib')%use geometry calib recorded from the ImaDoc xml file as first priority |
---|
| 1425 | Calib=UvData.XmlData{1}.GeometryCalib; |
---|
| 1426 | Mask=transform(Mask,UvData.XmlData{1}); |
---|
| 1427 | end |
---|
| 1428 | end |
---|
| 1429 | flagmask=Mask.A < 200; |
---|
| 1430 | |
---|
| 1431 | %make brown color image |
---|
| 1432 | imflag(:,:,1)=0.9*flagmask; |
---|
| 1433 | imflag(:,:,2)=0.7*flagmask; |
---|
| 1434 | imflag(:,:,3)=zeros(size(flagmask)); |
---|
| 1435 | |
---|
| 1436 | %update mask image |
---|
| 1437 | hmask=[]; %default |
---|
| 1438 | if isfield(MaskData,'maskhandle')&& ishandle(MaskData.maskhandle) |
---|
| 1439 | hmask=MaskData.maskhandle; |
---|
| 1440 | end |
---|
| 1441 | if ~isempty(hmask) |
---|
| 1442 | set(hmask,'CData',imflag) |
---|
| 1443 | set(hmask,'AlphaData',flagmask*0.6) |
---|
| 1444 | set(hmask,'XData',Mask.AX); |
---|
| 1445 | set(hmask,'YData',Mask.AY); |
---|
| 1446 | % uistack(hmask,'top') |
---|
| 1447 | else |
---|
[511] | 1448 | axes(handles.PlotAxes) |
---|
[387] | 1449 | hold on |
---|
[452] | 1450 | MaskData.maskhandle=image(Mask.AX,Mask.AY,imflag,'Tag','mask','HitTest','off','AlphaData',0.6*ones(size(flagmask))); |
---|
[387] | 1451 | set(handles.CheckMask,'UserData',MaskData) |
---|
| 1452 | end |
---|
| 1453 | end |
---|
| 1454 | end |
---|
| 1455 | |
---|
| 1456 | %------------------------------------------------------------------------ |
---|
| 1457 | %------------------------------------------------------------------------ |
---|
| 1458 | % III - MAIN REFRESH FUNCTIONS : 'FRAME PLOT' |
---|
| 1459 | %------------------------------------------------------------------------ |
---|
| 1460 | |
---|
| 1461 | %------------------------------------------------------------------------ |
---|
| 1462 | % --- Executes on button press in runplus: make one step forward and call |
---|
[526] | 1463 | % --- run0. The step forward is along the fieldname series 1 or 2 depending on |
---|
[387] | 1464 | % --- the scan_i and scan_j check box (exclusive each other) |
---|
| 1465 | function runplus_Callback(hObject, eventdata, handles) |
---|
| 1466 | %------------------------------------------------------------------------ |
---|
| 1467 | set(handles.runplus,'BackgroundColor',[1 1 0])%paint the command button in yellow |
---|
| 1468 | drawnow |
---|
| 1469 | %TODO: introduce the option: increment ='*' to move to the next available view |
---|
[511] | 1470 | increment=str2num(get(handles.num_IndexIncrement,'String')); %get the field increment d |
---|
[387] | 1471 | % if isnan(increment) |
---|
[511] | 1472 | % set(handles.num_IndexIncrement,'String','1')%default value |
---|
[387] | 1473 | % increment=1; |
---|
| 1474 | % end |
---|
| 1475 | errormsg=runpm(hObject,eventdata,handles,increment); |
---|
| 1476 | if ~isempty(errormsg) |
---|
| 1477 | msgbox_uvmat('ERROR',errormsg); |
---|
| 1478 | end |
---|
| 1479 | set(handles.runplus,'BackgroundColor',[1 0 0])%paint the command button back to red |
---|
| 1480 | |
---|
| 1481 | %------------------------------------------------------------------------ |
---|
| 1482 | % --- Executes on button press in runmin: make one step backward and call |
---|
[526] | 1483 | % --- run0. The step backward is along the fieldname series 1 or 2 depending on |
---|
[387] | 1484 | % --- the scan_i and scan_j check box (exclusive each other) |
---|
| 1485 | function runmin_Callback(hObject, eventdata, handles) |
---|
| 1486 | %------------------------------------------------------------------------ |
---|
| 1487 | set(handles.runmin,'BackgroundColor',[1 1 0])%paint the command button in yellow |
---|
| 1488 | drawnow |
---|
[511] | 1489 | increment=-str2num(get(handles.num_IndexIncrement,'String')); %get the field increment d |
---|
[387] | 1490 | % if isnan(increment) |
---|
[511] | 1491 | % set(handles.num_IndexIncrement,'String','1')%default value |
---|
[387] | 1492 | % increment=1; |
---|
| 1493 | % end |
---|
| 1494 | errormsg=runpm(hObject,eventdata,handles,increment); |
---|
| 1495 | if ~isempty(errormsg) |
---|
| 1496 | msgbox_uvmat('ERROR',errormsg); |
---|
| 1497 | end |
---|
| 1498 | set(handles.runmin,'BackgroundColor',[1 0 0])%paint the command button back to red |
---|
| 1499 | |
---|
| 1500 | %------------------------------------------------------------------------ |
---|
| 1501 | % -- Executes on button press in Movie: make a series of +> steps |
---|
| 1502 | function Movie_Callback(hObject, eventdata, handles) |
---|
| 1503 | %------------------------------------------------------------------------ |
---|
| 1504 | set(handles.Movie,'BackgroundColor',[1 1 0])%paint the command button in yellow |
---|
| 1505 | drawnow |
---|
[511] | 1506 | increment=str2num(get(handles.num_IndexIncrement,'String')); %get the field increment d |
---|
[387] | 1507 | % if isnan(increment) |
---|
[511] | 1508 | % set(handles.num_IndexIncrement,'String','1')%default value |
---|
[387] | 1509 | % increment=1; |
---|
| 1510 | % end |
---|
| 1511 | set(handles.STOP,'Visible','on') |
---|
| 1512 | set(handles.speed,'Visible','on') |
---|
| 1513 | set(handles.speed_txt,'Visible','on') |
---|
| 1514 | set(handles.Movie,'BusyAction','queue') |
---|
| 1515 | UvData=get(handles.uvmat,'UserData'); |
---|
| 1516 | |
---|
[435] | 1517 | while get(handles.Movie,'Value')==1 && get(handles.speed,'Value')~=0 && isequal(get(handles.Movie,'BusyAction'),'queue') % enable STOP command |
---|
[387] | 1518 | errormsg=runpm(hObject,eventdata,handles,increment); |
---|
| 1519 | if ~isempty(errormsg) |
---|
| 1520 | set(handles.Movie,'BackgroundColor',[1 0 0])%paint the command buttonback to red |
---|
| 1521 | return |
---|
| 1522 | end |
---|
| 1523 | pause(1.02-get(handles.speed,'Value'))% wait for next image |
---|
| 1524 | end |
---|
| 1525 | if isfield(UvData,'aviobj') && ~isempty( UvData.aviobj), |
---|
| 1526 | UvData.aviobj=close(UvData.aviobj); |
---|
| 1527 | set(handles.uvmat,'UserData',UvData); |
---|
| 1528 | end |
---|
| 1529 | set(handles.Movie,'BackgroundColor',[1 0 0])%paint the command buttonback to red |
---|
| 1530 | |
---|
| 1531 | %------------------------------------------------------------------------ |
---|
| 1532 | % -- Executes on button press in Movie: make a series of <- steps |
---|
| 1533 | function MovieBackward_Callback(hObject, eventdata, handles) |
---|
| 1534 | %------------------------------------------------------------------------ |
---|
| 1535 | set(handles.MovieBackward,'BackgroundColor',[1 1 0])%paint the command button in yellow |
---|
| 1536 | drawnow |
---|
[511] | 1537 | increment=-str2num(get(handles.num_IndexIncrement,'String')); %get the field increment d |
---|
[387] | 1538 | set(handles.STOP,'Visible','on') |
---|
| 1539 | set(handles.speed,'Visible','on') |
---|
| 1540 | set(handles.speed_txt,'Visible','on') |
---|
| 1541 | set(handles.MovieBackward,'BusyAction','queue') |
---|
| 1542 | UvData=get(handles.uvmat,'UserData'); |
---|
| 1543 | |
---|
[435] | 1544 | while get(handles.MovieBackward,'Value')==1 && get(handles.speed,'Value')~=0 && isequal(get(handles.MovieBackward,'BusyAction'),'queue') % enable STOP command |
---|
[387] | 1545 | errormsg=runpm(hObject,eventdata,handles,increment); |
---|
| 1546 | if ~isempty(errormsg) |
---|
| 1547 | set(handles.MovieBackward,'BackgroundColor',[1 0 0])%paint the command buttonback to red |
---|
| 1548 | return |
---|
| 1549 | end |
---|
| 1550 | pause(1.02-get(handles.speed,'Value'))% wait for next image |
---|
| 1551 | end |
---|
| 1552 | if isfield(UvData,'aviobj') && ~isempty( UvData.aviobj), |
---|
| 1553 | UvData.aviobj=close(UvData.aviobj); |
---|
| 1554 | set(handles.uvmat,'UserData',UvData); |
---|
| 1555 | end |
---|
| 1556 | set(handles.MovieBackward,'BackgroundColor',[1 0 0])%paint the command buttonback to red |
---|
| 1557 | |
---|
| 1558 | %------------------------------------------------------------------------ |
---|
| 1559 | function STOP_Callback(hObject, eventdata, handles) |
---|
| 1560 | %------------------------------------------------------------------------ |
---|
| 1561 | set(handles.movie_pair,'BusyAction','Cancel') |
---|
| 1562 | set(handles.movie_pair,'value',0) |
---|
| 1563 | set(handles.Movie,'BusyAction','Cancel') |
---|
| 1564 | set(handles.MovieBackward,'BusyAction','Cancel') |
---|
| 1565 | set(handles.MenuExportMovie,'BusyAction','Cancel') |
---|
| 1566 | set(handles.movie_pair,'BackgroundColor',[1 0 0])%paint the command buttonback to red |
---|
| 1567 | set(handles.Movie,'BackgroundColor',[1 0 0])%paint the command buttonback to red |
---|
| 1568 | set(handles.MovieBackward,'BackgroundColor',[1 0 0])%paint the command buttonback to red |
---|
| 1569 | |
---|
| 1570 | %------------------------------------------------------------------------ |
---|
| 1571 | % --- function activated by runplus and run minus |
---|
| 1572 | function errormsg=runpm(hObject,eventdata,handles,increment) |
---|
| 1573 | %------------------------------------------------------------------------ |
---|
| 1574 | errormsg='';%default |
---|
| 1575 | %% check for movie pair status |
---|
| 1576 | movie_status=get(handles.movie_pair,'Value'); |
---|
| 1577 | if isequal(movie_status,1) |
---|
| 1578 | STOP_Callback(hObject, eventdata, handles)%interrupt movie pair if active |
---|
| 1579 | end |
---|
| 1580 | |
---|
| 1581 | %% read the current input file name(s) and field indices |
---|
| 1582 | InputFile=read_GUI(handles.InputFile); |
---|
| 1583 | InputFile.RootFile=regexprep(InputFile.RootFile,'^[\\/]|[\\/]$','');%suppress possible / or \ separator at the beginning or the end of the string |
---|
| 1584 | InputFile.SubDir=regexprep(InputFile.SubDir,'^[\\/]|[\\/]$','');%suppress possible / or \ separator at the beginning or the end of the string |
---|
| 1585 | FileExt=InputFile.FileExt; |
---|
| 1586 | NomType=get(handles.NomType,'String'); |
---|
| 1587 | i1=str2num(get(handles.i1,'String'));%read the field indices (for movie, it is not given by the file name) |
---|
| 1588 | i2=[];%default |
---|
| 1589 | if strcmp(get(handles.i2,'Visible'),'on') |
---|
| 1590 | i2=str2num(get(handles.i2,'String')); |
---|
| 1591 | end |
---|
| 1592 | j1=[]; |
---|
| 1593 | if strcmp(get(handles.j1,'Visible'),'on') |
---|
| 1594 | j1=stra2num(get(handles.j1,'String')); |
---|
| 1595 | end |
---|
| 1596 | j2=j1; |
---|
| 1597 | if strcmp(get(handles.j2,'Visible'),'on') |
---|
| 1598 | j2=stra2num(get(handles.j2,'String')); |
---|
| 1599 | end |
---|
| 1600 | sub_value= get(handles.SubField,'Value'); |
---|
| 1601 | if sub_value % a second input file has been entered |
---|
[428] | 1602 | [InputFile.RootPath_1,InputFile.SubDir_1,InputFile.RootFile_1,InputFile.FileIndex_1,InputFile.FileExt_1,InputFile.NomType_1]=read_file_boxes_1(handles); |
---|
[515] | 1603 | [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] | 1604 | else |
---|
| 1605 | filename_1=[]; |
---|
| 1606 | end |
---|
| 1607 | |
---|
| 1608 | %% increment (or decrement) the field indices and update the input filename(s) |
---|
| 1609 | if isempty(increment) |
---|
| 1610 | set(handles.CheckFixPair,'Value',0) |
---|
| 1611 | end |
---|
| 1612 | CheckFixPair=get(handles.CheckFixPair,'Value')||(isempty(i2)&&isempty(j2)); |
---|
[427] | 1613 | |
---|
| 1614 | % the pair i1-i2 or j1-j2 is imposed (check box CheckFixPair selected) |
---|
[540] | 1615 | i1_1=i1; |
---|
| 1616 | i2_1=i2; |
---|
| 1617 | j1_1=j1; |
---|
| 1618 | j2_1=j2; |
---|
[387] | 1619 | if CheckFixPair |
---|
| 1620 | if get(handles.scan_i,'Value')==1% case of scanning along index i |
---|
| 1621 | i1=i1+increment; |
---|
| 1622 | i2=i2+increment; |
---|
| 1623 | if sub_value |
---|
| 1624 | i1_1=i1_1+increment; |
---|
| 1625 | i2_1=i2_1+increment; |
---|
| 1626 | end |
---|
[515] | 1627 | |
---|
[387] | 1628 | else % case of scanning along index j (burst numbers) |
---|
| 1629 | j1=j1+increment; |
---|
| 1630 | j2=j2+increment; |
---|
| 1631 | if sub_value |
---|
| 1632 | j1_1=j1_1+increment; |
---|
| 1633 | j2_1=j2_1+increment; |
---|
| 1634 | end |
---|
| 1635 | end |
---|
[427] | 1636 | |
---|
[511] | 1637 | % 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] | 1638 | else |
---|
| 1639 | UvData=get(handles.uvmat,'UserData'); |
---|
| 1640 | ref_i=i1; |
---|
| 1641 | if ~isempty(i2) |
---|
[427] | 1642 | ref_i=floor((i1+i2)/2);% current reference index i |
---|
[387] | 1643 | end |
---|
| 1644 | ref_j=1; |
---|
| 1645 | if ~isempty(j1) |
---|
| 1646 | ref_j=j1; |
---|
| 1647 | if ~isempty(j2) |
---|
[427] | 1648 | ref_j=floor((j1+j2)/2);% current reference index j |
---|
[387] | 1649 | end |
---|
| 1650 | end |
---|
| 1651 | if ~isempty(increment) |
---|
| 1652 | if get(handles.scan_i,'Value')==1% case of scanning along index i |
---|
[427] | 1653 | ref_i=ref_i+increment;% increment the current reference index i |
---|
[387] | 1654 | else % case of scanning along index j (burst numbers) |
---|
[427] | 1655 | ref_j=ref_j+increment;% increment the current reference index j if scan_j option is used |
---|
[387] | 1656 | end |
---|
[388] | 1657 | else % free increment |
---|
[511] | 1658 | runaction=get(gcbo,'tag'); |
---|
| 1659 | if strcmp(runaction,'runplus')||strcmp(runaction,'Movie')% if runplus or movie is activated |
---|
[387] | 1660 | step=1; |
---|
| 1661 | else |
---|
| 1662 | step=-1; |
---|
| 1663 | end |
---|
| 1664 | if get(handles.scan_i,'Value')==1% case of scanning along index i |
---|
| 1665 | ref_i=ref_i+step; |
---|
[512] | 1666 | 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] | 1667 | ref_i=ref_i+step; |
---|
| 1668 | end |
---|
| 1669 | else % case of scanning along index j (burst numbers) |
---|
| 1670 | ref_j=ref_j+step; |
---|
[512] | 1671 | 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] | 1672 | ref_j=ref_j+step; |
---|
| 1673 | end |
---|
| 1674 | end |
---|
| 1675 | end |
---|
| 1676 | if ref_i<0 |
---|
| 1677 | errormsg='minimum i index reached'; |
---|
| 1678 | elseif ref_j<0 |
---|
| 1679 | errormsg='minimum j index reached'; |
---|
[512] | 1680 | elseif ref_i+1>size(UvData.i1_series{1},3) |
---|
[511] | 1681 | errormsg='maximum i index reached (reload the input file to update the index bound)'; |
---|
[387] | 1682 | elseif ref_j+1>size(UvData.i1_series{1},2) |
---|
[511] | 1683 | errormsg='maximum j index reached (reload the input file to update the index bound)'; |
---|
[387] | 1684 | end |
---|
[511] | 1685 | if ~isempty(errormsg),return,end |
---|
[512] | 1686 | siz=size(UvData.i1_series{1}); |
---|
[515] | 1687 | 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] | 1688 | i1_subseries=UvData.i1_series{1}(ref_indices); |
---|
| 1689 | ref_indices=ref_indices(i1_subseries>0); |
---|
| 1690 | if isempty(ref_indices)% case of pairs (free index i) |
---|
[515] | 1691 | ref_indices=ref_i*siz(1)*siz(2)+1:(ref_i+1)*siz(1)*siz(2); |
---|
[512] | 1692 | i1_subseries=UvData.i1_series{1}(ref_indices); |
---|
| 1693 | ref_indices=ref_indices(i1_subseries>0); |
---|
[511] | 1694 | end |
---|
[512] | 1695 | if isempty(ref_indices),errormsg='no next frame: set num_IndexIncrement =''*'' to reach the next existing file';return |
---|
[387] | 1696 | end |
---|
[512] | 1697 | i1=UvData.i1_series{1}(ref_indices(end)); |
---|
[387] | 1698 | if ~isempty(UvData.i2_series{1}) |
---|
[512] | 1699 | i2=UvData.i2_series{1}(ref_indices(end)); |
---|
[387] | 1700 | end |
---|
| 1701 | if ~isempty(UvData.j1_series{1}) |
---|
[512] | 1702 | j1=UvData.j1_series{1}(ref_indices(end)); |
---|
[387] | 1703 | end |
---|
| 1704 | if ~isempty(UvData.j2_series{1}) |
---|
[512] | 1705 | j2=UvData.j2_series{1}(ref_indices(end)); |
---|
[515] | 1706 | end |
---|
| 1707 | |
---|
| 1708 | % case of a second file series |
---|
| 1709 | if sub_value |
---|
| 1710 | ref_i_1=i1_1; |
---|
| 1711 | if ~isempty(i2_1) |
---|
| 1712 | ref_i_1=floor((i1_1+i2_1)/2);% current reference index i |
---|
| 1713 | end |
---|
| 1714 | ref_j_1=1; |
---|
| 1715 | if ~isempty(j1_1) |
---|
| 1716 | ref_j_1=j1_1; |
---|
| 1717 | if ~isempty(j2_1) |
---|
| 1718 | ref_j_1=floor((j1_1+j2_1)/2);% current reference index j |
---|
| 1719 | end |
---|
| 1720 | end |
---|
| 1721 | if ~isempty(increment) |
---|
| 1722 | if get(handles.scan_i,'Value')==1% case of scanning along index i |
---|
| 1723 | ref_i_1=ref_i_1+increment;% increment the current reference index i |
---|
| 1724 | else % case of scanning along index j (burst numbers) |
---|
| 1725 | ref_j_1=ref_j_1+increment;% increment the current reference index j if scan_j option is used |
---|
| 1726 | end |
---|
| 1727 | else % free increment, synchronise the ref indices with the first series |
---|
| 1728 | ref_i_1=ref_i; |
---|
| 1729 | ref_j_1=ref_j; |
---|
| 1730 | end |
---|
| 1731 | if numel(UvData.i1_series)==1 |
---|
| 1732 | UvData.i1_series{2}=UvData.i1_series{1}; |
---|
| 1733 | UvData.j1_series{2}=UvData.j1_series{1}; |
---|
| 1734 | UvData.i2_series{2}=UvData.i2_series{1}; |
---|
| 1735 | UvData.j2_series{2}=UvData.j2_series{1}; |
---|
| 1736 | end |
---|
| 1737 | if ref_i_1<0 |
---|
| 1738 | errormsg='minimum i index reached'; |
---|
| 1739 | elseif ref_j_1<0 |
---|
| 1740 | errormsg='minimum j index reached'; |
---|
| 1741 | elseif ref_i_1+1>size(UvData.i1_series{2},3) |
---|
| 1742 | errormsg='maximum i index reached for the second series (reload the input file to update the index bound)'; |
---|
| 1743 | elseif ref_j_1+1>size(UvData.i1_series{2},2) |
---|
| 1744 | errormsg='maximum j index reached for the second series(reload the input file to update the index bound)'; |
---|
| 1745 | end |
---|
| 1746 | if ~isempty(errormsg),return,end |
---|
| 1747 | siz=size(UvData.i1_series{2}); |
---|
| 1748 | 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); |
---|
| 1749 | i1_subseries=UvData.i1_series{2}(ref_indices); |
---|
| 1750 | ref_indices=ref_indices(i1_subseries>0); |
---|
| 1751 | if isempty(ref_indices)% case of pairs (free index i) |
---|
| 1752 | ref_indices=ref_i_1*siz(1)*siz(2)+1:(ref_i_1+1)*siz(1)*siz(2); |
---|
| 1753 | i1_subseries=UvData.i1_series{2}(ref_indices); |
---|
| 1754 | ref_indices=ref_indices(i1_subseries>0); |
---|
| 1755 | end |
---|
| 1756 | i1_1=UvData.i1_series{2}(ref_indices(end)); |
---|
[427] | 1757 | if ~isempty(UvData.i2_series{2}) |
---|
[515] | 1758 | i2_1=UvData.i2_series{2}(ref_indices(end)); |
---|
[427] | 1759 | end |
---|
| 1760 | if ~isempty(UvData.j1_series{2}) |
---|
[515] | 1761 | j1_1=UvData.j1_series{2}(ref_indices(end)); |
---|
[427] | 1762 | end |
---|
| 1763 | if ~isempty(UvData.j2_series{2}) |
---|
[515] | 1764 | j2_1=UvData.j2_series{1}(ref_indices(end)); |
---|
| 1765 | end |
---|
| 1766 | else% the second series (if needed) is the same file as the first |
---|
| 1767 | i1_1=i1; |
---|
| 1768 | i2_1=i2; |
---|
| 1769 | j1_1=j1; |
---|
| 1770 | j2_1=j2; |
---|
[387] | 1771 | end |
---|
| 1772 | end |
---|
| 1773 | filename=fullfile_uvmat(InputFile.RootPath,InputFile.SubDir,InputFile.RootFile,FileExt,NomType,i1,i2,j1,j2); |
---|
| 1774 | if sub_value |
---|
[428] | 1775 | 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] | 1776 | end |
---|
| 1777 | |
---|
| 1778 | %% refresh plots |
---|
[515] | 1779 | errormsg=refresh_field(handles,filename,filename_1,i1,i2,j1,j2,i1_1,i2_1,j1_1,j2_1); |
---|
[387] | 1780 | |
---|
| 1781 | %% update the index counters if the index move is successfull |
---|
| 1782 | if isempty(errormsg) |
---|
| 1783 | set(handles.i1,'String',num2stra(i1,NomType,1)); |
---|
| 1784 | if isequal(i2,i1) |
---|
| 1785 | set(handles.i2,'String',''); |
---|
| 1786 | else |
---|
| 1787 | set(handles.i2,'String',num2stra(i2,NomType,1)); |
---|
| 1788 | end |
---|
| 1789 | set(handles.j1,'String',num2stra(j1,NomType,2)); |
---|
| 1790 | if isequal(j2,j1) |
---|
| 1791 | set(handles.j2,'String',''); |
---|
| 1792 | else |
---|
| 1793 | set(handles.j2,'String',num2stra(j2,NomType,2)); |
---|
| 1794 | end |
---|
| 1795 | indices=fullfile_uvmat('','','','',NomType,i1,i2,j1,j2); |
---|
| 1796 | set(handles.FileIndex,'String',indices); |
---|
| 1797 | if ~isempty(filename_1) |
---|
[428] | 1798 | indices_1=fullfile_uvmat('','','','',InputFile.NomType_1,i1_1,i2_1,j1_1,j2_1); |
---|
[387] | 1799 | set(handles.FileIndex_1,'String',indices_1); |
---|
| 1800 | end |
---|
| 1801 | if isequal(movie_status,1) |
---|
| 1802 | set(handles.movie_pair,'Value',1) |
---|
| 1803 | movie_pair_Callback(hObject, eventdata, handles); %reactivate moviepair if it was activated |
---|
| 1804 | end |
---|
| 1805 | end |
---|
| 1806 | |
---|
| 1807 | %------------------------------------------------------------------------ |
---|
| 1808 | % --- Executes on button press in movie_pair: create an alternating movie with two view |
---|
| 1809 | function movie_pair_Callback(hObject, eventdata, handles) |
---|
| 1810 | %------------------------------------------------------------------------ |
---|
[622] | 1811 | |
---|
[387] | 1812 | %% stop movie action if the movie_pair button is off |
---|
| 1813 | if ~get(handles.movie_pair,'value') |
---|
| 1814 | set(handles.movie_pair,'BusyAction','Cancel')%stop movie pair if button is 'off' |
---|
| 1815 | set(handles.i2,'String','') |
---|
| 1816 | set(handles.j2,'String','') |
---|
| 1817 | return |
---|
| 1818 | else |
---|
| 1819 | set(handles.movie_pair,'BusyAction','queue') |
---|
| 1820 | end |
---|
| 1821 | |
---|
| 1822 | %% initialisation |
---|
| 1823 | set(handles.movie_pair,'BackgroundColor',[1 1 0])%paint the command button in yellow |
---|
| 1824 | drawnow |
---|
[526] | 1825 | list_fields=get(handles.FieldName,'String');% list menu fields |
---|
| 1826 | index_fields=get(handles.FieldName,'Value');% selected string index |
---|
[387] | 1827 | FieldName=list_fields{index_fields}; % selected field |
---|
| 1828 | UvData=get(handles.uvmat,'UserData'); |
---|
| 1829 | if isequal(FieldName,'image') |
---|
[512] | 1830 | index=1; |
---|
[387] | 1831 | [RootPath,SubDir,RootFile,FileIndices,Ext]=read_file_boxes(handles); |
---|
| 1832 | NomType=get(handles.NomType,'String'); |
---|
| 1833 | else |
---|
[526] | 1834 | list_fields=get(handles.FieldName_1,'String');% list menu fields |
---|
| 1835 | index_fields=get(handles.FieldName_1,'Value');% selected string index |
---|
[387] | 1836 | FieldName=list_fields{index_fields}; % selected field |
---|
| 1837 | if isequal(FieldName,'image') |
---|
[512] | 1838 | index=2; |
---|
[387] | 1839 | [RootPath,tild,RootFile,FileIndex_1,Ext,NomType]=read_file_boxes_1(handles); |
---|
| 1840 | else |
---|
| 1841 | msgbox_uvmat('ERROR','an image or movie must be first introduced as input') |
---|
| 1842 | set(handles.movie_pair,'BackgroundColor',[1 0 0])%paint the command button in red |
---|
| 1843 | set(handles.movie_pair,'Value',0) |
---|
| 1844 | return |
---|
| 1845 | end |
---|
| 1846 | end |
---|
| 1847 | num_i1=str2num(get(handles.i1,'String')); |
---|
| 1848 | num_j1=stra2num(get(handles.j1,'String')); |
---|
| 1849 | num_i2=str2num(get(handles.i2,'String')); |
---|
| 1850 | num_j2=stra2num(get(handles.j2,'String')); |
---|
[582] | 1851 | imaname_1=''; |
---|
[387] | 1852 | if isempty(num_j2) |
---|
[582] | 1853 | if isempty(num_i2) |
---|
| 1854 | if strcmp(get(handles.j2,'Visible'),'on') %if the j box is visible |
---|
| 1855 | imaname_1=fullfile_uvmat(RootPath,SubDir,RootFile,Ext,NomType,num_i1,[],num_j1+1); |
---|
| 1856 | end |
---|
| 1857 | if exist(imaname_1,'file') |
---|
[598] | 1858 | num_j2=num_j1+1;% look by default for the next j index as the second file |
---|
| 1859 | set(handles.j2,'String',num2stra(num_j2,NomType)); |
---|
[582] | 1860 | else |
---|
| 1861 | imaname_1=fullfile_uvmat(RootPath,SubDir,RootFile,Ext,NomType,num_i1+1,[],num_j1); |
---|
| 1862 | if exist(imaname_1,'file') |
---|
| 1863 | num_i2=num_i1+1; |
---|
| 1864 | set(handles.i2,'String',num2str(num_i2)); |
---|
| 1865 | else |
---|
| 1866 | msgbox_uvmat('ERROR', 'a second image index i2 or j2 is needed to show the pair as a movie') |
---|
| 1867 | set(handles.movie_pair,'BackgroundColor',[1 0 0])%paint the command button in red |
---|
| 1868 | set(handles.movie_pair,'Value',0) |
---|
| 1869 | return |
---|
| 1870 | end |
---|
| 1871 | end |
---|
[387] | 1872 | else |
---|
| 1873 | num_j2=num_j1;%repeat the index i1 by default |
---|
| 1874 | end |
---|
| 1875 | end |
---|
| 1876 | if isempty(num_i2) |
---|
| 1877 | num_i2=num_i1;%repeat the index i1 by default |
---|
| 1878 | end |
---|
[439] | 1879 | imaname_1=fullfile_uvmat(RootPath,SubDir,RootFile,Ext,NomType,num_i2,[],num_j2); |
---|
[512] | 1880 | if strcmp(NomType,'*') |
---|
| 1881 | num_frame=num_i2; |
---|
| 1882 | else |
---|
| 1883 | num_frame=num_j2; |
---|
| 1884 | end |
---|
[387] | 1885 | if ~exist(imaname_1,'file') |
---|
| 1886 | msgbox_uvmat('ERROR',['second input open (-) ' imaname_1 ' not found']); |
---|
| 1887 | set(handles.movie_pair,'BackgroundColor',[1 0 0])%paint the command button in red |
---|
| 1888 | set(handles.movie_pair,'Value',0) |
---|
| 1889 | return |
---|
| 1890 | end |
---|
| 1891 | |
---|
[512] | 1892 | %% get the first image |
---|
| 1893 | %Field.AName='image'; |
---|
| 1894 | if index==1 |
---|
| 1895 | Field_a=UvData.Field;% movie on the second field |
---|
[387] | 1896 | else |
---|
[512] | 1897 | Field_a=UvData.Field_1;% movie on the first field |
---|
[387] | 1898 | end |
---|
| 1899 | |
---|
[512] | 1900 | %% read the second image |
---|
| 1901 | MovieObject=[]; |
---|
| 1902 | if numel(UvData.MovieObject)>=index |
---|
| 1903 | MovieObject=UvData.MovieObject{index}; |
---|
[387] | 1904 | end |
---|
[549] | 1905 | [Field_b,ParamOut,errormsg] = read_field(imaname_1,UvData.FileType{index},MovieObject,num_frame); |
---|
[512] | 1906 | % Field_b.AX=Field_a.AX; |
---|
| 1907 | % Field_b.AY=Field_a.AY; |
---|
| 1908 | % % z index |
---|
| 1909 | % nbslice=str2double(get(handles.num_NbSlice,'String')); |
---|
| 1910 | % if ~isempty(nbslice) |
---|
| 1911 | % Field_b.ZIndex=mod(num_i2-1,nbslice)+1; |
---|
| 1912 | % end |
---|
| 1913 | % Field_b.CoordUnit='pixel'; |
---|
| 1914 | % |
---|
| 1915 | % %% determine the input file type |
---|
| 1916 | % if (test_1 && isfield(UvData,'MovieObject')&& numel(UvData.MovieObject>=2))||(~test_1 && ~isempty(UvData.MovieObject{1})) |
---|
| 1917 | % FileType='movie'; |
---|
| 1918 | % elseif isequal(lower(Ext),'.avi') |
---|
| 1919 | % FileType='avi'; |
---|
| 1920 | % elseif isequal(lower(Ext),'.vol') |
---|
| 1921 | % FileType='vol'; |
---|
| 1922 | % else |
---|
| 1923 | % form=imformats(Ext(2:end)); |
---|
| 1924 | % if ~isempty(form)% if the extension corresponds to an image format recognized by Matlab |
---|
| 1925 | % if isequal(NomType,'*'); |
---|
| 1926 | % FileType='multimage'; |
---|
| 1927 | % else |
---|
| 1928 | % FileType='image'; |
---|
| 1929 | % end |
---|
| 1930 | % end |
---|
| 1931 | % end |
---|
| 1932 | % switch FileType |
---|
| 1933 | % case 'movie' |
---|
| 1934 | % if test_1 |
---|
| 1935 | % Field_b.A=read(UvData.MovieObject{2},num_i2); |
---|
| 1936 | % else |
---|
| 1937 | % Field_b.A=read(UvData.MovieObject{1},num_i2); |
---|
| 1938 | % end |
---|
| 1939 | % case 'avi' |
---|
| 1940 | % mov=aviread(imaname_1,num_i2); |
---|
| 1941 | % Field_b.A=frame2im(mov(1)); |
---|
| 1942 | % case 'vol' |
---|
| 1943 | % Field_b.A=imread(imaname_1); |
---|
| 1944 | % case 'multimage' |
---|
| 1945 | % Field_b.A=imread(imaname_1,num_i2); |
---|
| 1946 | % case 'image' |
---|
| 1947 | % Field_b.A=imread(imaname_1); |
---|
| 1948 | % end |
---|
| 1949 | % if get(handles.slices,'Value') |
---|
| 1950 | % Field.ZIndex=str2double(get(handles.z_index,'String')); |
---|
| 1951 | % end |
---|
[387] | 1952 | |
---|
| 1953 | %px to phys or other transform on field |
---|
[591] | 1954 | transform=get(handles.TransformPath,'UserData'); |
---|
[512] | 1955 | if ~isempty(transform) |
---|
| 1956 | if isfield(UvData,'XmlData') && numel(UvData.XmlData)>=index %use geometry calib recorded from the ImaDoc xml file as first priority |
---|
| 1957 | if index==2 |
---|
| 1958 | Field_a=transform(Field_a,UvData.XmlData{index});%the first field has been stored without transform |
---|
| 1959 | end |
---|
| 1960 | Field_b=transform(Field_b,UvData.XmlData{index}); |
---|
[387] | 1961 | end |
---|
| 1962 | end |
---|
| 1963 | |
---|
| 1964 | % make movie until movie speed is set to 0 or STOP is activated |
---|
[511] | 1965 | hima=findobj(handles.PlotAxes,'Tag','ima');% %handles.PlotAxes =main plotting window (A GENERALISER) |
---|
[387] | 1966 | set(handles.STOP,'Visible','on') |
---|
| 1967 | set(handles.speed,'Visible','on') |
---|
| 1968 | set(handles.speed_txt,'Visible','on') |
---|
| 1969 | while get(handles.speed,'Value')~=0 && isequal(get(handles.movie_pair,'BusyAction'),'queue')%isequal(get(handles.run0,'BusyAction'),'queue'); % enable STOP command |
---|
| 1970 | % read and plot the series of images in non erase mode |
---|
| 1971 | set(hima,'CData',Field_b.A); |
---|
| 1972 | pause(1.02-get(handles.speed,'Value'));% wait for next image |
---|
| 1973 | set(hima,'CData',Field_a.A); |
---|
| 1974 | pause(1.02-get(handles.speed,'Value'));% wait for next image |
---|
| 1975 | end |
---|
| 1976 | set(handles.movie_pair,'BackgroundColor',[1 0 0])%paint the command button in red |
---|
| 1977 | set(handles.movie_pair,'Value',0) |
---|
| 1978 | |
---|
| 1979 | %------------------------------------------------------------------------ |
---|
| 1980 | % --- Executes on button press in run0. |
---|
| 1981 | function run0_Callback(hObject, eventdata, handles) |
---|
| 1982 | %------------------------------------------------------------------------ |
---|
| 1983 | set(handles.run0,'BackgroundColor',[1 1 0])%paint the command button in yellow |
---|
| 1984 | drawnow |
---|
[515] | 1985 | [RootPath,SubDir,RootFile,FileIndex,FileExt]=read_file_boxes(handles); |
---|
| 1986 | filename=[fullfile(RootPath,SubDir,RootFile) FileIndex FileExt]; |
---|
| 1987 | filename_1='';%default |
---|
| 1988 | FileIndex_1=''; |
---|
[387] | 1989 | if get(handles.SubField,'Value') |
---|
[515] | 1990 | [RootPath_1,SubDir_1,RootFile_1,FileIndex_1,FileExt_1]=read_file_boxes_1(handles); |
---|
| 1991 | filename_1=[fullfile(RootPath_1,SubDir_1,RootFile_1) FileIndex_1 FileExt_1]; |
---|
[387] | 1992 | end |
---|
| 1993 | num_i1=stra2num(get(handles.i1,'String')); |
---|
| 1994 | num_i2=stra2num(get(handles.i2,'String')); |
---|
| 1995 | num_j1=stra2num(get(handles.j1,'String')); |
---|
| 1996 | num_j2=stra2num(get(handles.j2,'String')); |
---|
[609] | 1997 | [tild,tild,tild,i1_1,i2_1,j1_1,j2_1]=fileparts_uvmat(FileIndex_1);% get the indices of the second series from the string FileIndex_1 |
---|
| 1998 | if isempty(j1_1)% case of movies, the index is not given by file index |
---|
| 1999 | j1_1=num_j1; |
---|
| 2000 | end |
---|
[387] | 2001 | |
---|
[515] | 2002 | errormsg=refresh_field(handles,filename,filename_1,num_i1,num_i2,num_j1,num_j2,i1_1,i2_1,j1_1,j2_1); |
---|
[387] | 2003 | |
---|
| 2004 | if ~isempty(errormsg) |
---|
| 2005 | msgbox_uvmat('ERROR',errormsg); |
---|
| 2006 | else |
---|
| 2007 | set(handles.i1,'BackgroundColor',[1 1 1]) |
---|
| 2008 | set(handles.i2,'BackgroundColor',[1 1 1]) |
---|
| 2009 | set(handles.j1,'BackgroundColor',[1 1 1]) |
---|
| 2010 | set(handles.j2,'BackgroundColor',[1 1 1]) |
---|
| 2011 | set(handles.FileIndex,'BackgroundColor',[1 1 1]) |
---|
| 2012 | set(handles.FileIndex_1,'BackgroundColor',[1 1 1]) |
---|
| 2013 | end |
---|
| 2014 | set(handles.run0,'BackgroundColor',[1 0 0]) |
---|
| 2015 | |
---|
| 2016 | |
---|
| 2017 | %------------------------------------------------------------------------ |
---|
| 2018 | % --- read the input files and refresh all the plots, including projection. |
---|
| 2019 | % OUTPUT: |
---|
| 2020 | % errormsg: error message char string =[] by default |
---|
| 2021 | % INPUT: |
---|
| 2022 | % filename: first input file (=[] in the absence of input file) |
---|
| 2023 | % filename_1: second input file (=[] in the asbsenc of secodn input file) |
---|
| 2024 | % num_i1,num_i2,num_j1,num_j2; frame indices |
---|
| 2025 | % Field: structure describing an optional input field (then replace the input file) |
---|
[397] | 2026 | |
---|
[515] | 2027 | 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] | 2028 | %------------------------------------------------------------------------ |
---|
| 2029 | |
---|
| 2030 | %% initialisation |
---|
| 2031 | if ~exist('Field','var') |
---|
| 2032 | Field={}; |
---|
| 2033 | end |
---|
| 2034 | UvData=get(handles.uvmat,'UserData'); |
---|
| 2035 | if ishandle(handles.UVMAT_title) %remove title panel on uvmat |
---|
| 2036 | delete(handles.UVMAT_title) |
---|
| 2037 | end |
---|
| 2038 | |
---|
| 2039 | %% determine the main input file information for action |
---|
[450] | 2040 | if ~exist(FileName,'file') |
---|
| 2041 | errormsg=['input file ' FileName ' does not exist']; |
---|
[387] | 2042 | return |
---|
| 2043 | end |
---|
| 2044 | NomType=get(handles.NomType,'String'); |
---|
[494] | 2045 | NomType_1=''; |
---|
| 2046 | if strcmp(get(handles.NomType_1,'Visible'),'on') |
---|
| 2047 | NomType_1=get(handles.NomType_1,'String'); |
---|
| 2048 | end |
---|
[387] | 2049 | %update the z position index |
---|
[589] | 2050 | mode_slice=get(handles.slices,'String'); |
---|
| 2051 | if strcmp(mode_slice,'volume') |
---|
[387] | 2052 | z_index=num_j1; |
---|
| 2053 | set(handles.z_index,'String',num2str(z_index)) |
---|
| 2054 | else |
---|
[589] | 2055 | nbslice=str2num(get(handles.num_NbSlice,'String')); |
---|
[387] | 2056 | z_index=mod(num_i1-1,nbslice)+1; |
---|
| 2057 | set(handles.z_index,'String',num2str(z_index)) |
---|
| 2058 | end |
---|
| 2059 | % refresh menu for save_mask if relevant |
---|
| 2060 | masknumber=get(handles.masklevel,'String'); |
---|
| 2061 | if length(masknumber)>=z_index |
---|
| 2062 | set(handles.masklevel,'Value',z_index) |
---|
| 2063 | end |
---|
| 2064 | |
---|
[515] | 2065 | %% test for need of tps |
---|
| 2066 | check_proj_tps=0; |
---|
| 2067 | if (strcmp(UvData.FileType{1},'civdata')||strcmp(UvData.FileType{1},'civx')) |
---|
[622] | 2068 | for iobj=1:numel(UvData.ProjObject) |
---|
| 2069 | if isfield(UvData.ProjObject{iobj},'ProjMode')&& strcmp(UvData.ProjObject{iobj}.ProjMode,'interp_tps') |
---|
[515] | 2070 | check_proj_tps=1; |
---|
| 2071 | break |
---|
| 2072 | end |
---|
| 2073 | end |
---|
| 2074 | end |
---|
| 2075 | |
---|
[507] | 2076 | %% read the first input field |
---|
[421] | 2077 | ParamIn.ColorVar='';%default variable name for vector color |
---|
[445] | 2078 | frame_index=1;%default |
---|
[507] | 2079 | FieldName='';%default |
---|
| 2080 | VelType='';%default |
---|
| 2081 | switch UvData.FileType{1} |
---|
| 2082 | case {'civx','civdata','netcdf'}; |
---|
[526] | 2083 | list_fields=get(handles.FieldName,'String');% list menu fields |
---|
| 2084 | FieldName= list_fields{get(handles.FieldName,'Value')}; % selected field |
---|
[576] | 2085 | % if get_field... is selected, the GUI get_field will be used to enter fields |
---|
[507] | 2086 | if ~strcmp(FieldName,'get_field...') |
---|
| 2087 | if get(handles.FixVelType,'Value') |
---|
| 2088 | VelTypeList=get(handles.VelType,'String'); |
---|
| 2089 | VelType=VelTypeList{get(handles.VelType,'Value')}; |
---|
[387] | 2090 | end |
---|
[507] | 2091 | end |
---|
[576] | 2092 | % case of input vector field, get the scalar used for vector color |
---|
[517] | 2093 | if ~isempty(regexp(FieldName,'^vec(')) |
---|
[507] | 2094 | list_code=get(handles.ColorCode,'String');% list menu fields |
---|
| 2095 | index_code=get(handles.ColorCode,'Value');% selected string index |
---|
| 2096 | if ~strcmp(list_code{index_code},'black') && ~strcmp(list_code{index_code},'white') |
---|
| 2097 | list_code=get(handles.ColorScalar,'String');% list menu fields |
---|
| 2098 | index_code=get(handles.ColorScalar,'Value');% selected string index |
---|
| 2099 | ParamIn.ColorVar= list_code{index_code}; % selected field |
---|
[387] | 2100 | end |
---|
[507] | 2101 | end |
---|
| 2102 | case {'video','mmreader'} |
---|
| 2103 | ParamIn=UvData.MovieObject{1}; |
---|
| 2104 | if ~strcmp(NomType,'*') |
---|
| 2105 | frame_index=num_j1;%frame index for movies or multimage |
---|
| 2106 | else |
---|
| 2107 | frame_index=num_i1; |
---|
| 2108 | end |
---|
| 2109 | case 'multimage' |
---|
| 2110 | if ~strcmp(NomType,'*') |
---|
| 2111 | frame_index=num_j1;%frame index for movies or multimage |
---|
| 2112 | else |
---|
| 2113 | frame_index=num_i1; |
---|
| 2114 | end |
---|
| 2115 | case 'vol' %TODO: update |
---|
| 2116 | if isfield(UvData.XmlData,'Npy') && isfield(UvData.XmlData,'Npx') |
---|
| 2117 | ParamIn.Npy=UvData.XmlData.Npy; |
---|
| 2118 | ParamIn.Npx=UvData.XmlData.Npx; |
---|
| 2119 | else |
---|
| 2120 | errormsg='Npx and Npy need to be defined in the xml file for volume images .vol'; |
---|
| 2121 | return |
---|
| 2122 | end |
---|
[387] | 2123 | end |
---|
[507] | 2124 | if isstruct (ParamIn) |
---|
[517] | 2125 | ParamIn.FieldName=FieldName; |
---|
| 2126 | ParamIn.VelType=VelType; |
---|
| 2127 | XNameMenu=get(handles.Coord_x,'String'); |
---|
[595] | 2128 | if ~isempty(XNameMenu) |
---|
| 2129 | ParamIn.Coord_x=XNameMenu(get(handles.Coord_x,'Value')); |
---|
| 2130 | end |
---|
[517] | 2131 | YNameMenu=get(handles.Coord_y,'String'); |
---|
[595] | 2132 | if ~isempty(YNameMenu) |
---|
| 2133 | ParamIn.Coord_y=YNameMenu(get(handles.Coord_y,'Value')); |
---|
| 2134 | end |
---|
[507] | 2135 | end |
---|
[517] | 2136 | check_tps = 0; |
---|
[515] | 2137 | if strcmp(UvData.FileType{1},'civdata')&&~strcmp(ParamIn.FieldName,'velocity')&&~strcmp(ParamIn.FieldName,'get_field...') |
---|
| 2138 | check_tps=1;%tps needed to get the requested field |
---|
| 2139 | end |
---|
[507] | 2140 | [Field{1},ParamOut,errormsg] = read_field(FileName,UvData.FileType{1},ParamIn,frame_index); |
---|
| 2141 | if ~isempty(errormsg) |
---|
[527] | 2142 | errormsg=['uvmat / refresh_field / read_field( ' FileName ') / ' errormsg]; |
---|
[507] | 2143 | return |
---|
| 2144 | end |
---|
| 2145 | if isfield(ParamOut,'Npx')&& isfield(ParamOut,'Npy') |
---|
| 2146 | set(handles.num_Npx,'String',num2str(ParamOut.Npx));% display image size on the interface |
---|
| 2147 | set(handles.num_Npy,'String',num2str(ParamOut.Npy)); |
---|
| 2148 | end |
---|
| 2149 | if isfield(ParamOut,'TimeIndex')% case of time obtained from get_field |
---|
| 2150 | set(handles.i1,'String',num2str(ParamOut.TimeIndex)) |
---|
| 2151 | end |
---|
| 2152 | if isfield(ParamOut,'TimeValue') |
---|
| 2153 | Field{1}.Time=ParamOut.TimeValue;% case of time obtained from get_field |
---|
| 2154 | end |
---|
| 2155 | Field{1}.ZIndex=z_index; %used for multiplane 3D calibration |
---|
[387] | 2156 | |
---|
[576] | 2157 | |
---|
[450] | 2158 | %% choose and read a second field FileName_1 if defined |
---|
[387] | 2159 | VelType_1=[];%default |
---|
| 2160 | FieldName_1=[]; |
---|
[496] | 2161 | ParamIn_1=[]; |
---|
[387] | 2162 | ParamOut_1=[]; |
---|
[445] | 2163 | frame_index_1=1; |
---|
[450] | 2164 | if ~isempty(FileName_1) |
---|
| 2165 | if ~exist(FileName_1,'file') |
---|
| 2166 | errormsg=['second file ' FileName_1 ' does not exist']; |
---|
[387] | 2167 | return |
---|
| 2168 | end |
---|
[580] | 2169 | % Name=FileName_1; |
---|
[404] | 2170 | switch UvData.FileType{2} |
---|
[387] | 2171 | case {'civx','civdata','netcdf'}; |
---|
[526] | 2172 | list_fields=get(handles.FieldName_1,'String');% list menu fields |
---|
[520] | 2173 | if ischar(list_fields),list_fields={list_fields};end |
---|
[526] | 2174 | FieldName_1= list_fields{get(handles.FieldName_1,'Value')}; % selected field |
---|
[387] | 2175 | if ~strcmp(FieldName,'get_field...') |
---|
[389] | 2176 | if get(handles.FixVelType,'Value') |
---|
| 2177 | VelTypeList=get(handles.VelType_1,'String'); |
---|
| 2178 | VelType_1=VelTypeList{get(handles.VelType_1,'Value')};% read the velocity type. |
---|
[387] | 2179 | end |
---|
| 2180 | end |
---|
[405] | 2181 | if strcmp(FieldName_1,'velocity')&& strcmp(get(handles.ColorCode,'Visible'),'on') |
---|
| 2182 | list_code=get(handles.ColorCode,'String');% list menu fields |
---|
| 2183 | index_code=get(handles.ColorCode,'Value');% selected string index |
---|
[387] | 2184 | if ~strcmp(list_code{index_code},'black') && ~strcmp(list_code{index_code},'white') |
---|
[405] | 2185 | list_code=get(handles.ColorScalar,'String');% list menu fields |
---|
| 2186 | index_code=get(handles.ColorScalar,'Value');% selected string index |
---|
| 2187 | ParamIn_1.ColorVar= list_code{index_code}; % selected field for vector color display |
---|
[387] | 2188 | end |
---|
| 2189 | end |
---|
[435] | 2190 | case {'video','mmreader'} |
---|
[450] | 2191 | ParamIn_1=UvData.MovieObject{2}; |
---|
[445] | 2192 | if ~strcmp(NomType_1,'*') |
---|
[515] | 2193 | frame_index_1=j1_1;%frame index for movies or multimage |
---|
[445] | 2194 | else |
---|
[515] | 2195 | frame_index_1=i1_1; |
---|
[445] | 2196 | end |
---|
| 2197 | case 'multimage' |
---|
[609] | 2198 | if strcmp(NomType_1,'*')%frame index for movies or multimage |
---|
| 2199 | frame_index_1=i1_1; |
---|
[445] | 2200 | else |
---|
[609] | 2201 | frame_index_1=j1_1; |
---|
[445] | 2202 | end |
---|
[387] | 2203 | case 'vol' %TODO: update |
---|
| 2204 | if isfield(UvData.XmlData,'Npy') && isfield(UvData.XmlData,'Npx') |
---|
[405] | 2205 | ParamIn_1.Npy=UvData.XmlData.Npy; |
---|
| 2206 | ParamIn_1.Npx=UvData.XmlData.Npx; |
---|
[387] | 2207 | else |
---|
| 2208 | errormsg='Npx and Npy need to be defined in the xml file for volume images .vol'; |
---|
| 2209 | return |
---|
| 2210 | end |
---|
| 2211 | end |
---|
[428] | 2212 | if isequal(get(handles.NomType_1,'Visible'),'on') |
---|
[387] | 2213 | NomType_1=get(handles.NomType_1,'String'); |
---|
[428] | 2214 | else |
---|
| 2215 | NomType_1=get(handles.NomType,'String'); |
---|
| 2216 | end |
---|
[387] | 2217 | test_keepdata_1=0;% test for keeping the previous stored data if the input files are unchanged |
---|
[515] | 2218 | if ~isequal(NomType_1,'*')&& isfield(UvData,'FileName_1') |
---|
[580] | 2219 | test_keepdata_1= strcmp(FileName_1,UvData.FileName_1) ; |
---|
[387] | 2220 | end |
---|
| 2221 | if test_keepdata_1 |
---|
[389] | 2222 | Field{2}=UvData.Field_1;% keep the stored field |
---|
[427] | 2223 | ParamOut_1=UvData.ParamOut_1; |
---|
[387] | 2224 | else |
---|
[496] | 2225 | if isempty(ParamIn_1) || isstruct(ParamIn_1) |
---|
[405] | 2226 | ParamIn_1.FieldName=FieldName_1; |
---|
| 2227 | ParamIn_1.VelType=VelType_1; |
---|
| 2228 | ParamIn_1.GUIName='get_field_1'; |
---|
[515] | 2229 | end |
---|
[580] | 2230 | [Field{2},ParamOut_1,errormsg] = read_field(FileName_1,UvData.FileType{2},ParamIn_1,frame_index_1); |
---|
[387] | 2231 | if ~isempty(errormsg) |
---|
[450] | 2232 | errormsg=['error in reading ' FieldName_1 ' in ' FileName_1 ': ' errormsg]; |
---|
[387] | 2233 | return |
---|
| 2234 | end |
---|
[515] | 2235 | if isstruct(ParamOut_1)&&~strcmp(ParamOut_1.FieldName,'get_field...')&& (strcmp(UvData.FileType{2},'civdata')||strcmp(UvData.FileType{2},'civx'))... |
---|
| 2236 | &&~strcmp(ParamOut_1.FieldName,'velocity') && ~strcmp(ParamOut_1.FieldName,'get_field...') |
---|
| 2237 | if ~check_proj_tps |
---|
| 2238 | % Field{2}=calc_field([{ParamOut_1.FieldName} {ParamOut_1.ColorVar}],Field{2}); |
---|
| 2239 | end |
---|
| 2240 | end |
---|
[387] | 2241 | end |
---|
[507] | 2242 | Field{2}.ZIndex=z_index;%used for multi-plane 3D calibration |
---|
[387] | 2243 | end |
---|
| 2244 | |
---|
| 2245 | %% update uvmat interface |
---|
| 2246 | if isfield(ParamOut,'Npx') |
---|
| 2247 | set(handles.num_Npx,'String',num2str(ParamOut.Npx));% display image size on the interface |
---|
| 2248 | set(handles.num_Npy,'String',num2str(ParamOut.Npy)); |
---|
| 2249 | elseif isfield(ParamOut_1,'Npx') |
---|
| 2250 | set(handles.num_Npx,'String',num2str(ParamOut_1.Npx));% display image size on the interface |
---|
| 2251 | set(handles.num_Npy,'String',num2str(ParamOut_1.Npy)); |
---|
| 2252 | end |
---|
| 2253 | |
---|
| 2254 | %% update the display menu for the first velocity type (first menuline) |
---|
| 2255 | test_veltype=0; |
---|
| 2256 | % if ~isequal(FileType,'netcdf')|| isequal(FieldName,'get_field...') |
---|
[404] | 2257 | if (strcmp(UvData.FileType{1},'civx')||strcmp(UvData.FileType{1},'civdata'))&& ~strcmp(FieldName,'get_field...') |
---|
[387] | 2258 | test_veltype=1; |
---|
| 2259 | set(handles.VelType,'Visible','on') |
---|
| 2260 | set(handles.VelType_1,'Visible','on') |
---|
| 2261 | set(handles.FixVelType,'Visible','on') |
---|
[404] | 2262 | menu=set_veltype_display(ParamOut.CivStage,UvData.FileType{1}); |
---|
[387] | 2263 | index_menu=strcmp(ParamOut.VelType,menu);%look for VelType in the menu |
---|
| 2264 | index_val=find(index_menu,1); |
---|
| 2265 | if isempty(index_val) |
---|
| 2266 | index_val=1; |
---|
| 2267 | end |
---|
| 2268 | set(handles.VelType,'Value',index_val) |
---|
| 2269 | if ~get(handles.SubField,'value') |
---|
| 2270 | set(handles.VelType,'String',menu) |
---|
| 2271 | set(handles.VelType_1,'Value',1) |
---|
| 2272 | set(handles.VelType_1,'String',[{''};menu]) |
---|
| 2273 | end |
---|
| 2274 | else |
---|
| 2275 | set(handles.VelType,'Visible','off') |
---|
| 2276 | end |
---|
[526] | 2277 | % display the FieldName menu from the input file and pick the selected one: |
---|
[517] | 2278 | % if isstruct(ParamOut) |
---|
| 2279 | % field_index=strcmp(ParamOut.FieldName,ParamOut.FieldList); |
---|
[526] | 2280 | % set(handles.FieldName,'String',ParamOut.FieldList); %update the field menu |
---|
| 2281 | % set(handles.FieldName,'Value',find(field_index,1)) |
---|
[517] | 2282 | % end |
---|
[387] | 2283 | |
---|
| 2284 | %% update the display menu for the second velocity type (second menuline) |
---|
| 2285 | test_veltype_1=0; |
---|
[450] | 2286 | if isempty(FileName_1) |
---|
[580] | 2287 | % set(handles.FieldName_1,'Value',1); %update the field menu |
---|
| 2288 | % if isstruct(ParamOut) |
---|
| 2289 | % set(handles.FieldName_1,'String',[{''};ParamOut.FieldList]); %update the field menu |
---|
| 2290 | % end |
---|
[405] | 2291 | elseif ~test_keepdata_1 |
---|
[404] | 2292 | if (~strcmp(UvData.FileType{2},'netcdf')&&~strcmp(UvData.FileType{2},'civdata')&&~strcmp(UvData.FileType{2},'civx'))|| isequal(FieldName_1,'get_field...') |
---|
[387] | 2293 | set(handles.VelType_1,'Visible','off') |
---|
[405] | 2294 | else |
---|
[387] | 2295 | test_veltype_1=1; |
---|
| 2296 | set(handles.VelType_1,'Visible','on') |
---|
[515] | 2297 | menu=set_veltype_display(ParamOut_1.CivStage,UvData.FileType{2}); |
---|
[494] | 2298 | index_menu=strcmp(ParamOut_1.VelType,menu); |
---|
| 2299 | set(handles.VelType_1,'Value',1+find(index_menu,1)) |
---|
| 2300 | set(handles.VelType_1,'String',[{''};menu]) |
---|
[387] | 2301 | end |
---|
[405] | 2302 | % update the second field menu: the same quantity |
---|
[494] | 2303 | if isstruct(ParamOut_1) |
---|
[580] | 2304 | % set(handles.FieldName_1,'String',[{''};ParamOut_1.FieldList]); %update the field menu |
---|
| 2305 | % display the FieldName menu from the input file and pick the selected one: |
---|
| 2306 | FieldList=get(handles.FieldName_1,'String'); |
---|
| 2307 | field_index=strcmp(ParamOut_1.FieldName,FieldList); |
---|
| 2308 | if ~isempty(field_index) |
---|
| 2309 | set(handles.FieldName_1,'Value',find(field_index,1)) |
---|
| 2310 | end |
---|
[494] | 2311 | end |
---|
[387] | 2312 | end |
---|
| 2313 | if test_veltype||test_veltype_1 |
---|
[580] | 2314 | set(handles.FixVelType,'Visible','on') |
---|
[387] | 2315 | else |
---|
[580] | 2316 | set(handles.FixVelType,'Visible','off') |
---|
[387] | 2317 | end |
---|
[405] | 2318 | |
---|
| 2319 | % field_index=strcmp(ParamOut_1.FieldName,ParamOut_1.FieldList); |
---|
[526] | 2320 | % set(handles.FieldName,'String',ParamOut.FieldList); %update the field menu |
---|
| 2321 | % set(handles.FieldName,'Value',find(field_index,1)) |
---|
[387] | 2322 | |
---|
| 2323 | %% introduce w as background image by default for a new series (only for nbdim=2) |
---|
| 2324 | if ~isfield(UvData,'NewSeries') |
---|
| 2325 | UvData.NewSeries=1; |
---|
| 2326 | end |
---|
| 2327 | %put W as background image by default if NbDim=2: |
---|
| 2328 | if UvData.NewSeries && isequal(get(handles.SubField,'Value'),0) && isfield(Field{1},'W') && ~isempty(Field{1}.W) && ~isequal(Field{1}.NbDim,3); |
---|
| 2329 | set(handles.SubField,'Value',1); |
---|
| 2330 | set(handles.RootPath_1,'String','"') |
---|
| 2331 | set(handles.RootFile_1,'String','"') |
---|
| 2332 | set(handles.SubDir_1,'String','"'); |
---|
| 2333 | indices=fullfile_uvmat('','','','',NomType,num_i1,num_i2,num_j1,num_j2); |
---|
| 2334 | set(handles.FileIndex_1,'String',indices) |
---|
| 2335 | set(handles.FileExt_1,'String','"'); |
---|
[526] | 2336 | set(handles.FieldName_1,'Visible','on'); |
---|
| 2337 | set(handles.FieldName_1,'Visible','on'); |
---|
[387] | 2338 | set(handles.RootPath_1,'Visible','on') |
---|
| 2339 | set(handles.RootFile_1,'Visible','on') |
---|
| 2340 | set(handles.SubDir_1,'Visible','on'); |
---|
| 2341 | set(handles.FileIndex_1,'Visible','on'); |
---|
| 2342 | set(handles.FileExt_1,'Visible','on'); |
---|
[526] | 2343 | set(handles.FieldName_1,'Visible','on'); |
---|
[387] | 2344 | Field{1}.AName='w'; |
---|
| 2345 | end |
---|
| 2346 | |
---|
[415] | 2347 | %% display time |
---|
[615] | 2348 | abstime=[];%default inputs |
---|
| 2349 | abstime_1=[]; |
---|
| 2350 | dt=[]; |
---|
[415] | 2351 | TimeUnit=''; |
---|
[615] | 2352 | % time from xml file or video movie |
---|
[415] | 2353 | if isfield(UvData,'XmlData') && isfield(UvData.XmlData{1},'Time') |
---|
| 2354 | if isempty(num_i2)||isnan(num_i2) |
---|
| 2355 | num_i2=num_i1; |
---|
| 2356 | end |
---|
| 2357 | if isempty(num_j1)||isnan(num_j1) |
---|
| 2358 | num_j1=1; |
---|
| 2359 | end |
---|
| 2360 | if isempty(num_j2)||isnan(num_j2) |
---|
| 2361 | num_j2=num_j1; |
---|
| 2362 | end |
---|
| 2363 | siz=size(UvData.XmlData{1}.Time); |
---|
[615] | 2364 | if ~isempty(num_i1)&& ~isempty(num_i2) && num_i1>=0 &&siz(1)>=max(num_i1+1,num_i2+1) && siz(2)>=max(num_j1+1,num_j2+1) |
---|
[611] | 2365 | abstime=(UvData.XmlData{1}.Time(num_i1+1,num_j1+1)+UvData.XmlData{1}.Time(num_i2+1,num_j2+1))/2;%overset the time read from files |
---|
| 2366 | dt=(UvData.XmlData{1}.Time(num_i2+1,num_j2+1)-UvData.XmlData{1}.Time(num_i1+1,num_j1+1)); |
---|
[415] | 2367 | Field{1}.Dt=dt; |
---|
| 2368 | if isfield(UvData.XmlData{1},'TimeUnit') |
---|
| 2369 | TimeUnit=UvData.XmlData{1}.TimeUnit; |
---|
| 2370 | end |
---|
| 2371 | end |
---|
| 2372 | if numel(UvData.XmlData)==2 |
---|
[515] | 2373 | if isempty(i2_1) |
---|
| 2374 | i2_1=num_i1; |
---|
[415] | 2375 | end |
---|
[515] | 2376 | if isempty(j1_1) |
---|
| 2377 | j1_1=1; |
---|
[415] | 2378 | end |
---|
[515] | 2379 | if isempty(j2_1) |
---|
| 2380 | j2_1=j1_1; |
---|
[415] | 2381 | end |
---|
| 2382 | siz=size(UvData.XmlData{2}.Time); |
---|
[615] | 2383 | if ~isempty(i1_1) && siz(1)>=max(i1_1+1,i2_1+1) && siz(2)>=max(j1_1+1,j2_1+1) |
---|
| 2384 | abstime_1=(UvData.XmlData{2}.Time(i1_1+1,j1_1+1)+UvData.XmlData{2}.Time(i2_1+1,j2_1+1))/2;%overset the time read from files |
---|
| 2385 | Field{2}.Dt=(UvData.XmlData{2}.Time(i2_1+1,j2_1+1)-UvData.XmlData{2}.Time(i1_1+1,j1_1+1)); |
---|
[415] | 2386 | end |
---|
| 2387 | end |
---|
| 2388 | end |
---|
[615] | 2389 | % if isfield(Field{1},'Time') |
---|
| 2390 | % abstime=Field{1}.Time;%time read from the netcdf input file |
---|
| 2391 | % end |
---|
| 2392 | % if numel(Field)==2 && isfield(Field{2},'Time') |
---|
| 2393 | % abstime_1=Field{2}.Time;%time read from the netcdf input file |
---|
| 2394 | % end |
---|
| 2395 | |
---|
| 2396 | % look for timing in the input file if not defined in a xml file or movie |
---|
| 2397 | if isempty(abstime) |
---|
| 2398 | if isfield(Field{1},'Dt') |
---|
| 2399 | dt=Field{1}.Dt;%dt read from the netcdf input file |
---|
| 2400 | if isfield(Field{1},'TimeUnit') |
---|
| 2401 | TimeUnit=Field{1}.TimeUnit; |
---|
| 2402 | end |
---|
| 2403 | elseif numel(Field)==2 && isfield(Field{2},'Dt')%dt obtained from the second field if not defined in the first |
---|
| 2404 | dt=Field{2}.Dt;%dt read from the netcdf input file |
---|
| 2405 | if isfield(Field{2},'TimeUnit') |
---|
| 2406 | TimeUnit=Field{2}.TimeUnit; |
---|
| 2407 | end |
---|
[415] | 2408 | end |
---|
[615] | 2409 | end |
---|
| 2410 | % if ~isequal(numel(abstime),1) |
---|
| 2411 | % abstime=[]; |
---|
| 2412 | % end |
---|
| 2413 | % if ~isequal(numel(abstime_1),1) |
---|
| 2414 | % abstime_1=[]; |
---|
| 2415 | % end |
---|
[456] | 2416 | set(handles.abs_time,'String',num2str(abstime,5)) |
---|
| 2417 | set(handles.abs_time_1,'String',num2str(abstime_1,5)) |
---|
[415] | 2418 | if isempty(dt)||isequal(dt,0) |
---|
| 2419 | set(handles.Dt_txt,'String','') |
---|
| 2420 | else |
---|
| 2421 | if isempty(TimeUnit) |
---|
| 2422 | set(handles.Dt_txt,'String',['Dt=' num2str(1000*dt,3) ' 10^(-3)'] ) |
---|
| 2423 | else |
---|
| 2424 | set(handles.Dt_txt,'String',['Dt=' num2str(1000*dt,3) ' m' TimeUnit] ) |
---|
| 2425 | end |
---|
| 2426 | end |
---|
| 2427 | |
---|
| 2428 | |
---|
[526] | 2429 | %% store the current open names, fieldname and vel types in uvmat interface |
---|
[450] | 2430 | UvData.FileName_1=FileName_1; |
---|
[512] | 2431 | UvData.ParamOut_1=ParamOut_1; |
---|
| 2432 | if numel(Field)==2 |
---|
| 2433 | UvData.Field_1=Field{2}; %store the second field for possible use at next RUN |
---|
| 2434 | end |
---|
[387] | 2435 | |
---|
| 2436 | %% apply coordinate transform or other user fct |
---|
[591] | 2437 | transform=get(handles.TransformPath,'UserData'); |
---|
[515] | 2438 | if isempty(transform) |
---|
| 2439 | UvData.Field=Field{1}; |
---|
| 2440 | else |
---|
[507] | 2441 | XmlData=[];%default |
---|
| 2442 | XmlData_1=[];%default |
---|
| 2443 | if isfield(UvData,'XmlData')%use geometry calib recorded from the ImaDoc xml file as first priority |
---|
| 2444 | XmlData=UvData.XmlData{1}; |
---|
| 2445 | if numel(UvData.XmlData)==2 |
---|
| 2446 | XmlData_1=UvData.XmlData{2}; |
---|
| 2447 | end |
---|
[387] | 2448 | end |
---|
[591] | 2449 | transform=get(handles.TransformPath,'UserData'); |
---|
[512] | 2450 | switch nargin(transform) |
---|
| 2451 | case 4 |
---|
| 2452 | if length(Field)==2 |
---|
| 2453 | UvData.Field=transform(Field{1},XmlData,Field{2},XmlData_1); |
---|
| 2454 | else |
---|
| 2455 | UvData.Field=transform(Field{1},XmlData); |
---|
| 2456 | end |
---|
| 2457 | case 3 |
---|
| 2458 | if length(Field)==2 |
---|
| 2459 | UvData.Field=transform(Field{1},XmlData,Field{2}); |
---|
| 2460 | else |
---|
| 2461 | UvData.Field=transform(Field{1},XmlData); |
---|
| 2462 | end |
---|
| 2463 | case 2 |
---|
| 2464 | UvData.Field=transform(Field{1},XmlData); |
---|
| 2465 | case 1 |
---|
| 2466 | UvData.Field=transform(Field{1}); |
---|
[387] | 2467 | end |
---|
[507] | 2468 | end |
---|
[508] | 2469 | |
---|
[515] | 2470 | %% calculate tps coefficients if needed |
---|
[581] | 2471 | UvData.Field=tps_coeff_field(UvData.Field,check_proj_tps); |
---|
[387] | 2472 | |
---|
[434] | 2473 | %% analyse input field |
---|
[530] | 2474 | %test_x=0; |
---|
| 2475 | %test_z=0;% test for unstructured z coordinate |
---|
| 2476 | %[errormsg,ListDimName,DimValue,VarDimIndex]=check_field_structure(UvData.Field);% check the input field structure |
---|
| 2477 | % if ~isempty(errormsg) |
---|
| 2478 | % errormsg=['error in uvmat/refresh_field/check_field_structure: ' errormsg];% display error |
---|
| 2479 | % return |
---|
| 2480 | % end |
---|
| 2481 | [CellInfo,NbDimArray,errormsg]=find_field_cells(UvData.Field);% analyse the input field structure |
---|
[387] | 2482 | if ~isempty(errormsg) |
---|
[527] | 2483 | errormsg=['uvmat /refresh_field / find_field_cells / ' errormsg];% display error |
---|
[387] | 2484 | return |
---|
| 2485 | end |
---|
[530] | 2486 | |
---|
| 2487 | NbDim=max(NbDimArray);% spatial dimension of the input field |
---|
| 2488 | imax=find(NbDimArray==NbDim);% indices of field cells to consider |
---|
[387] | 2489 | if isfield(UvData.Field,'NbDim') |
---|
[530] | 2490 | NbDim=double(UvData.Field.NbDim);% deal with plane fields containing z coordinates |
---|
[387] | 2491 | end |
---|
[434] | 2492 | |
---|
[576] | 2493 | %UvData.Field=get_bounds(UvData.Field); |
---|
[530] | 2494 | |
---|
[527] | 2495 | %% get bounds and mesh (needed to propose default options for projection objects) |
---|
[435] | 2496 | if NbDim>1 |
---|
[535] | 2497 | CoordMax=zeros(numel(imax),NbDim); |
---|
| 2498 | CoordMin=zeros(numel(imax),NbDim); |
---|
[564] | 2499 | Mesh=zeros(1,numel(imax)); |
---|
[530] | 2500 | for ind=1:numel(imax) |
---|
[564] | 2501 | if strcmp(CellInfo{imax(ind)}.CoordType,'tps') |
---|
| 2502 | CoordName=UvData.Field.ListVarName{CellInfo{imax(ind)}.CoordIndex};% X,Y coordinates in a single variable |
---|
[579] | 2503 | CoordMax(ind,NbDim)=max(max(UvData.Field.(CoordName)(1:end-3,1,:),[],1),[],3);% max of x component (2D case) |
---|
| 2504 | CoordMax(ind,NbDim-1)=max(max(UvData.Field.(CoordName)(1:end-3,2,:),[],1),[],3);% max of y component (2D case) |
---|
| 2505 | CoordMin(ind,NbDim)=min(min(UvData.Field.(CoordName)(1:end-3,1,:),[],1),[],3); |
---|
| 2506 | CoordMin(ind,NbDim-1)=min(min(UvData.Field.(CoordName)(1:end-3,2,:),[],1),[],3);% min of y component (2D case) |
---|
[564] | 2507 | else |
---|
| 2508 | XName=UvData.Field.ListVarName{CellInfo{imax(ind)}.CoordIndex(end)}; |
---|
| 2509 | YName=UvData.Field.ListVarName{CellInfo{imax(ind)}.CoordIndex(end-1)}; |
---|
| 2510 | CoordMax(ind,NbDim)=max(max(UvData.Field.(XName))); |
---|
| 2511 | CoordMin(ind,NbDim)=min(min(UvData.Field.(XName))); |
---|
| 2512 | CoordMax(ind,NbDim-1)=max(max(UvData.Field.(YName))); |
---|
| 2513 | CoordMin(ind,NbDim-1)=min(min(UvData.Field.(YName))); |
---|
| 2514 | % test_x=1;%test for unstructured coordinates |
---|
| 2515 | if NbDim==3 |
---|
| 2516 | ZName=UvData.Field.ListVarName{CellInfo{imax(ind)}.CoordIndex(1)}; |
---|
| 2517 | CoordMax(imax(ind),1)=max(max(UvData.Field.(ZName))); |
---|
| 2518 | CoordMin(ind,1)=min(min(UvData.Field.(ZName))); |
---|
| 2519 | end |
---|
[434] | 2520 | end |
---|
[530] | 2521 | switch CellInfo{imax(ind)}.CoordType |
---|
| 2522 | |
---|
[564] | 2523 | case {'scattered','tps'} %unstructured coordinates |
---|
| 2524 | NbPoints=CellInfo{imax(ind)}.CoordSize;% total nbre of points |
---|
| 2525 | Mesh(ind)=(prod(CoordMax(ind,:)-CoordMin(ind,:))/NbPoints)^(1/NbDim); %(volume or area per point)^(1/NbDim) |
---|
[530] | 2526 | case 'grid'%structured coordinate |
---|
[535] | 2527 | NbPoints=CellInfo{imax(ind)}.CoordSize;% nbre of points in each direction |
---|
[564] | 2528 | Mesh(ind)=min((CoordMax(ind,:)-CoordMin(ind,:))./(NbPoints-1)); |
---|
[435] | 2529 | end |
---|
[387] | 2530 | end |
---|
[575] | 2531 | UvData.Field.CoordMesh=min(Mesh); |
---|
[546] | 2532 | UvData.Field.XMax=max(CoordMax(ind,end)); |
---|
| 2533 | UvData.Field.XMin=min(CoordMin(ind,end)); |
---|
| 2534 | UvData.Field.YMax=max(CoordMax(ind,end-1)); |
---|
| 2535 | UvData.Field.YMin=max(CoordMin(ind,end-1)); |
---|
[435] | 2536 | if NbDim==3 |
---|
[546] | 2537 | UvData.Field.ZMax=max(CoordMax(ind,1)); |
---|
| 2538 | UvData.Field.ZMin=max(CoordMin(ind,1)); |
---|
[387] | 2539 | end |
---|
[435] | 2540 | % adjust the mesh to a value 1, 2 , 5 *10^n |
---|
[575] | 2541 | ord=10^(floor(log10(UvData.Field.CoordMesh)));%order of magnitude |
---|
| 2542 | if UvData.Field.CoordMesh/ord>=5 |
---|
| 2543 | UvData.Field.CoordMesh=5*ord; |
---|
| 2544 | elseif UvData.Field.CoordMesh/ord>=2 |
---|
| 2545 | UvData.Field.CoordMesh=2*ord; |
---|
[404] | 2546 | else |
---|
[575] | 2547 | UvData.Field.CoordMesh=ord; |
---|
[404] | 2548 | end |
---|
[491] | 2549 | % default projection plane |
---|
[622] | 2550 | if isempty(UvData.ProjObject{1}) |
---|
| 2551 | UvData.ProjObject{1}.Type='plane';%main plotting plane |
---|
| 2552 | UvData.ProjObject{1}.ProjMode='projection';%main plotting plane |
---|
[627] | 2553 | % UvData.ProjObject{1}.Coord=[0 0 0]; |
---|
[622] | 2554 | UvData.ProjObject{1}.DisplayHandle.uvmat=[]; %plane not visible in uvmat |
---|
| 2555 | UvData.ProjObject{1}.DisplayHandle.view_field=[]; %plane not visible in uvmat |
---|
[491] | 2556 | end |
---|
[435] | 2557 | %% 3D case (menuvolume) |
---|
| 2558 | if NbDim==3% && UvData.NewSeries |
---|
| 2559 | test_set_object=1; |
---|
| 2560 | hset_object=findobj(allchild(0),'tag','set_object');% look for the set_object GUI |
---|
| 2561 | ZBounds(1)=UvData.Field.ZMin; %minimum for the Z slider |
---|
| 2562 | ZBounds(2)=UvData.Field.ZMax;%maximum for the Z slider |
---|
| 2563 | if ~isempty(hset_object) %if set_object is detected |
---|
| 2564 | delete(hset_object);% delete the GUI set_object if it does not fit |
---|
[387] | 2565 | end |
---|
[435] | 2566 | if test_set_object% reinitiate the GUI set_object |
---|
[622] | 2567 | delete_object(1);% delete the current projection object in the list UvData.ProjObject, delete its graphic representations and update the list displayed in handles.ListObject and 2 |
---|
| 2568 | UvData.ProjObject{1}.NbDim=NbDim;%test for 3D objects |
---|
| 2569 | UvData.ProjObject{1}.RangeZ=UvData.Field.CoordMesh;%main plotting plane |
---|
| 2570 | UvData.ProjObject{1}.Coord(1,3)=(UvData.Field.ZMin+UvData.Field.ZMax)/2;%section at a middle plane chosen |
---|
| 2571 | UvData.ProjObject{1}.Angle=[0 0 0]; |
---|
| 2572 | UvData.ProjObject{1}.HandlesDisplay=plot(0,0,'Tag','proj_object');% A REVOIR |
---|
| 2573 | UvData.ProjObject{1}.Name='1-PLANE'; |
---|
| 2574 | UvData.ProjObject{1}.enable_plot=1; |
---|
| 2575 | set_object(UvData.ProjObject{1},handles,ZBounds); |
---|
[435] | 2576 | set(handles.ListObject,'Value',1); |
---|
| 2577 | set(handles.ListObject,'String',{'1-PLANE'}); |
---|
| 2578 | set(handles.edit_object,'Value',1)% put the plane in edit mode to enable the z cursor |
---|
| 2579 | edit_object_Callback([],[], handles) |
---|
[387] | 2580 | end |
---|
[435] | 2581 | %multilevel case (single menuplane in a 3D space) |
---|
| 2582 | elseif isfield(UvData,'Z') |
---|
| 2583 | if isfield(UvData,'CoordType')&& isequal(UvData.CoordType,'phys') && isfield(UvData,'XmlData') |
---|
| 2584 | XmlData=UvData.XmlData{1}; |
---|
| 2585 | if isfield(XmlData,'PlanePos') |
---|
[622] | 2586 | UvData.ProjObject{1}.Coord=XmlData.PlanePos(UvData.ZIndex,:); |
---|
[435] | 2587 | end |
---|
| 2588 | if isfield(XmlData,'PlaneAngle') |
---|
| 2589 | siz=size(XmlData.PlaneAngle); |
---|
| 2590 | indangle=min(siz(1),UvData.ZIndex);%take first angle if a single angle is defined (translating scanning) |
---|
[622] | 2591 | UvData.ProjObject{1}.PlaneAngle=XmlData.PlaneAngle(indangle,:); |
---|
[435] | 2592 | end |
---|
| 2593 | elseif isfield(UvData,'ZIndex') |
---|
[622] | 2594 | UvData.ProjObject{1}.ZObject=UvData.ZIndex; |
---|
[435] | 2595 | end |
---|
[387] | 2596 | end |
---|
| 2597 | end |
---|
[435] | 2598 | |
---|
[387] | 2599 | testnewseries=UvData.NewSeries; |
---|
| 2600 | UvData.NewSeries=0;% put to 0 the test for a new field series (set by RootPath_callback) |
---|
| 2601 | set(handles.uvmat,'UserData',UvData) |
---|
| 2602 | |
---|
| 2603 | %% reset the min and max of scalar if only the mask is displayed(TODO: check the need) |
---|
[405] | 2604 | % if isfield(UvData,'Mask')&& ~isfield(UvData,'A') |
---|
| 2605 | % set(handles.num_MinA,'String','0') |
---|
| 2606 | % set(handles.num_MaxA,'String','255') |
---|
| 2607 | % end |
---|
[387] | 2608 | |
---|
[434] | 2609 | %% usual 1D (x,y) plots |
---|
| 2610 | if NbDim<=1 |
---|
| 2611 | set(handles.Objects,'Visible','off') |
---|
| 2612 | set(handles.ListObject_1_title,'Visible','off') |
---|
| 2613 | set(handles.ListObject_1,'Visible','off') |
---|
[511] | 2614 | [PlotType,PlotParamOut]=plot_field(UvData.Field,handles.PlotAxes,read_GUI(handles.uvmat)); |
---|
[598] | 2615 | errormsg=fill_GUI(PlotParamOut,handles.uvmat); |
---|
| 2616 | for list={'Scalar','Vectors'} |
---|
| 2617 | if ~isfield(PlotParamOut,list{1}) |
---|
| 2618 | set(handles.(list{1}),'Visible','off') |
---|
| 2619 | end |
---|
| 2620 | end |
---|
[434] | 2621 | |
---|
[526] | 2622 | %% 2D or 3D fieldname are generally projected |
---|
[387] | 2623 | else |
---|
[434] | 2624 | set(handles.Objects,'Visible','on') |
---|
| 2625 | set(handles.ListObject_1_title,'Visible','on') |
---|
| 2626 | set(handles.ListObject_1,'Visible','on') |
---|
| 2627 | |
---|
| 2628 | %% Plot the projections on the selected projection objects |
---|
| 2629 | % main projection object (uvmat display) |
---|
| 2630 | list_object=get(handles.ListObject_1,'String'); |
---|
[535] | 2631 | if isequal(list_object,{''})||isequal(list_object,' ')%refresh list of objects if the menu is empty |
---|
[508] | 2632 | set(handles.ListObject,'Value',1) |
---|
| 2633 | set(handles.ListObject,'String',{'plane'}) |
---|
[622] | 2634 | UvData.ProjObject{1}.Type='plane';%main plotting plane |
---|
| 2635 | UvData.ProjObject{1}.ProjMode='projection';%main plotting plane |
---|
| 2636 | UvData.ProjObject{1}.DisplayHandle.uvmat=[]; %plane not visible in uvmat |
---|
| 2637 | UvData.ProjObject{1}.DisplayHandle.view_field=[]; %plane not visible in uvmat |
---|
[434] | 2638 | set(handles.ListObject_1,'Value',1) |
---|
[508] | 2639 | set(handles.ListObject_1,'String',{'plane'}) |
---|
[387] | 2640 | end |
---|
[434] | 2641 | IndexObj(1)=get(handles.ListObject_1,'Value');%selected projection object for main view |
---|
[622] | 2642 | if IndexObj(1)> numel(UvData.ProjObject) |
---|
[434] | 2643 | IndexObj(1)=1;%select the first object if the selected one does not exist |
---|
| 2644 | set(handles.ListObject_1,'Value',1) |
---|
[387] | 2645 | end |
---|
[434] | 2646 | IndexObj(2)=get(handles.ListObject,'Value');%selected projection object for main view |
---|
| 2647 | if isequal(IndexObj(2),IndexObj(1)) |
---|
| 2648 | IndexObj(2)=[]; |
---|
| 2649 | end |
---|
| 2650 | plot_handles{1}=handles; |
---|
| 2651 | if isfield(UvData,'plotaxes')%case of movies |
---|
| 2652 | haxes(1)=UvData.plotaxes; |
---|
| 2653 | else |
---|
[511] | 2654 | haxes(1)=handles.PlotAxes; |
---|
[434] | 2655 | end |
---|
| 2656 | PlotParam{1}=read_GUI(handles.uvmat); |
---|
| 2657 | %default settings if vectors not visible |
---|
| 2658 | if ~isfield(PlotParam{1},'Vectors') |
---|
| 2659 | PlotParam{1}.Vectors.MaxVec=1; |
---|
| 2660 | PlotParam{1}.Vectors.MinVec=0; |
---|
| 2661 | PlotParam{1}.Vectors.CheckFixVecColor=1; |
---|
| 2662 | PlotParam{1}.Vectors.ColCode1=0.33; |
---|
| 2663 | PlotParam{1}.Vectors.ColCode2=0.66; |
---|
[517] | 2664 | PlotParam{1}.Vectors.ColorScalar={''}; |
---|
[434] | 2665 | PlotParam{1}.Vectors.ColorCode= {'rgb'}; |
---|
| 2666 | end |
---|
| 2667 | PosColorbar{1}=UvData.OpenParam.PosColorbar;%prescribe the colorbar position on the uvmat interface |
---|
| 2668 | |
---|
| 2669 | %% second projection object (view_field display) |
---|
| 2670 | if length( IndexObj)>=2 |
---|
| 2671 | view_field_handle=findobj(allchild(0),'tag','view_field');%handles of the view_field GUI |
---|
| 2672 | if ~isempty(view_field_handle) |
---|
| 2673 | plot_handles{2}=guidata(view_field_handle); |
---|
[511] | 2674 | haxes(2)=plot_handles{2}.PlotAxes; |
---|
[599] | 2675 | PlotParam{2}=read_GUI(view_field_handle); |
---|
| 2676 | % PlotParam{2}=read_GUI(handles.uvmat);%read plotting parameters on the uvmat interface |
---|
[434] | 2677 | PosColorbar{2}='*'; %TODO: deal with colorbar position on view_field |
---|
[421] | 2678 | end |
---|
[387] | 2679 | end |
---|
[434] | 2680 | |
---|
| 2681 | %% loop on the projection objects: one or two |
---|
| 2682 | |
---|
| 2683 | for imap=1:numel(IndexObj) |
---|
| 2684 | iobj=IndexObj(imap); |
---|
[622] | 2685 | if numel(UvData.ProjObject)<iobj |
---|
[606] | 2686 | break |
---|
| 2687 | end |
---|
[622] | 2688 | [ObjectData,errormsg]=proj_field(UvData.Field,UvData.ProjObject{iobj});% project field on the object |
---|
[434] | 2689 | if ~isempty(errormsg) |
---|
| 2690 | return |
---|
[387] | 2691 | end |
---|
[434] | 2692 | if testnewseries |
---|
| 2693 | PlotParam{imap}.Scalar.CheckBW=[]; %B/W option depends on the input field (image or scalar) |
---|
| 2694 | if isfield(ObjectData,'CoordUnit') |
---|
| 2695 | PlotParam{imap}.Coordinates.CheckFixAspectRatio=1;% set x and y scaling equal if CoordUnit is defined (common unit for x and y) |
---|
| 2696 | PlotParam{imap}.Coordinates.AspectRatio=1; %set aspect ratio to 1 |
---|
[387] | 2697 | end |
---|
[434] | 2698 | end |
---|
| 2699 | %use of mask (TODO: check) |
---|
| 2700 | if isfield(ObjectData,'NbDim') && isequal(ObjectData.NbDim,2) && isfield(ObjectData,'Mask') && isfield(ObjectData,'A') |
---|
| 2701 | flag_mask=double(ObjectData.Mask>200);%=0 for masked regions |
---|
| 2702 | AX=ObjectData.AX;%x coordiantes for the scalar field |
---|
| 2703 | AY=ObjectData.AY;%y coordinates for the scalar field |
---|
| 2704 | MaskX=ObjectData.MaskX;%x coordiantes for the mask |
---|
| 2705 | MaskY=ObjectData.MaskY;%y coordiantes for the mask |
---|
| 2706 | if ~isequal(MaskX,AX)||~isequal(MaskY,AY) |
---|
| 2707 | nxy=size(flag_mask); |
---|
| 2708 | sizpx=(ObjectData.MaskX(end)-ObjectData.MaskX(1))/(nxy(2)-1);%size of a mask pixel |
---|
| 2709 | sizpy=(ObjectData.MaskY(1)-ObjectData.MaskY(end))/(nxy(1)-1); |
---|
| 2710 | x_mask=ObjectData.MaskX(1):sizpx:ObjectData.MaskX(end); % pixel x coordinates for image display |
---|
| 2711 | y_mask=ObjectData.MaskY(1):-sizpy:ObjectData.MaskY(end);% pixel x coordinates for image display |
---|
| 2712 | %project on the positions of the scalar |
---|
| 2713 | npxy=size(ObjectData.A); |
---|
| 2714 | dxy(1)=(ObjectData.AY(end)-ObjectData.AY(1))/(npxy(1)-1);%grid mesh in y |
---|
| 2715 | dxy(2)=(ObjectData.AX(end)-ObjectData.AX(1))/(npxy(2)-1);%grid mesh in x |
---|
| 2716 | xi=ObjectData.AX(1):dxy(2):ObjectData.AX(end); |
---|
| 2717 | yi=ObjectData.AY(1):dxy(1):ObjectData.AY(end); |
---|
| 2718 | [XI,YI]=meshgrid(xi,yi);% creates the matrix of regular coordinates |
---|
| 2719 | flag_mask = interp2(x_mask,y_mask,flag_mask,XI,YI); |
---|
| 2720 | end |
---|
| 2721 | AClass=class(ObjectData.A); |
---|
| 2722 | ObjectData.A=flag_mask.*double(ObjectData.A); |
---|
| 2723 | ObjectData.A=feval(AClass,ObjectData.A); |
---|
[387] | 2724 | end |
---|
[434] | 2725 | if ~isempty(ObjectData) |
---|
[569] | 2726 | %PlotType='none'; %default |
---|
[434] | 2727 | if imap==2 && isempty(view_field_handle) |
---|
| 2728 | view_field(ObjectData) |
---|
| 2729 | else |
---|
| 2730 | [PlotType,PlotParamOut]=plot_field(ObjectData,haxes(imap),PlotParam{imap},PosColorbar{imap}); |
---|
[595] | 2731 | if imap==1 |
---|
[598] | 2732 | errormsg=fill_GUI(PlotParamOut,handles.uvmat); |
---|
[595] | 2733 | else |
---|
[596] | 2734 | errormsg=fill_GUI(PlotParamOut,view_field_handle); |
---|
[595] | 2735 | end |
---|
[598] | 2736 | for list={'Scalar','Vectors'} |
---|
| 2737 | if ~isfield(PlotParamOut,list{1}) |
---|
| 2738 | set(plot_handles{imap}.(list{1}),'Visible','off') |
---|
| 2739 | end |
---|
| 2740 | end |
---|
[575] | 2741 | if isfield(Field,'CoordMesh')&&~isempty(Field.CoordMesh) |
---|
| 2742 | ObjectData.CoordMesh=Field.CoordMesh; % gives an estimated mesh size (useful for mouse action on the plot) |
---|
[434] | 2743 | end |
---|
[387] | 2744 | end |
---|
| 2745 | end |
---|
| 2746 | end |
---|
[434] | 2747 | |
---|
| 2748 | %% update the mask |
---|
| 2749 | if isequal(get(handles.CheckMask,'Value'),1)%if the mask option is on |
---|
| 2750 | update_mask(handles,num_i1,num_i2); |
---|
| 2751 | end |
---|
| 2752 | |
---|
| 2753 | %% prepare the menus of histograms and plot them (histogram of the whole volume in 3D case) |
---|
| 2754 | menu_histo=(UvData.Field.ListVarName)';%list of field variables to be displayed for the menu of histogram display |
---|
| 2755 | ind_skip=[]; |
---|
| 2756 | % nb_histo=1; |
---|
| 2757 | Ustring=''; |
---|
| 2758 | Vstring=''; |
---|
| 2759 | % suppress coordinates from the histogram menu |
---|
| 2760 | for ivar=1:numel(menu_histo)%l loop on field variables: |
---|
| 2761 | if isfield(UvData.Field,'VarAttribute') && numel(UvData.Field.VarAttribute)>=ivar && isfield(UvData.Field.VarAttribute{ivar},'Role') |
---|
| 2762 | Role=UvData.Field.VarAttribute{ivar}.Role; |
---|
| 2763 | switch Role |
---|
| 2764 | case {'coord_x','coord_y','coord_z','dimvar'} |
---|
| 2765 | ind_skip=[ind_skip ivar]; |
---|
| 2766 | case {'vector_x'} |
---|
| 2767 | Ustring=UvData.Field.ListVarName{ivar}; |
---|
| 2768 | ind_skip=[ind_skip ivar]; |
---|
| 2769 | case {'vector_y'} |
---|
| 2770 | Vstring=UvData.Field.ListVarName{ivar}; |
---|
| 2771 | ind_skip=[ind_skip ivar]; |
---|
| 2772 | end |
---|
[387] | 2773 | end |
---|
[434] | 2774 | DimCell=UvData.Field.VarDimName{ivar}; |
---|
| 2775 | DimName=''; |
---|
| 2776 | if ischar(DimCell) |
---|
| 2777 | DimName=DimCell; |
---|
| 2778 | elseif iscell(DimCell)&& numel(DimCell)==1 |
---|
| 2779 | DimName=DimCell{1}; |
---|
| 2780 | end |
---|
| 2781 | if strcmp(DimName,menu_histo{ivar}) |
---|
| 2782 | ind_skip=[ind_skip ivar]; |
---|
| 2783 | end |
---|
[387] | 2784 | end |
---|
[434] | 2785 | menu_histo(ind_skip)=[];% remove skipped items |
---|
| 2786 | if ~isempty(Ustring) |
---|
| 2787 | menu_histo=[{[Ustring ',' Vstring]};menu_histo];% add U, V at the beginning if they exist |
---|
[387] | 2788 | end |
---|
[434] | 2789 | |
---|
| 2790 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
---|
| 2791 | % display menus and plot histograms |
---|
| 2792 | test_v=0; |
---|
| 2793 | if ~isempty(menu_histo) |
---|
| 2794 | set(handles.histo1_menu,'Value',1) |
---|
| 2795 | set(handles.histo1_menu,'String',menu_histo) |
---|
| 2796 | histo1_menu_Callback(handles.histo1_menu, [], handles)% plot first histogram |
---|
[387] | 2797 | end |
---|
| 2798 | end |
---|
| 2799 | |
---|
[424] | 2800 | %------------------------------------------------------------------------ |
---|
| 2801 | function histo1_menu_Callback(hObject, eventdata, handles) |
---|
| 2802 | %-------------------------------------------- |
---|
| 2803 | histo_menu=get(handles.histo1_menu,'String'); |
---|
| 2804 | histo_value=get(handles.histo1_menu,'Value'); |
---|
| 2805 | FieldName=histo_menu{histo_value}; |
---|
[530] | 2806 | |
---|
[424] | 2807 | UvData=get(handles.uvmat,'UserData'); |
---|
| 2808 | Field=UvData.Field; |
---|
| 2809 | r=regexp(FieldName,'(?<var1>.*)(?<sep>,)(?<var2>.*)','names'); |
---|
| 2810 | FieldName_2=''; |
---|
| 2811 | if ~isempty(r) |
---|
| 2812 | FieldName=r.var1; |
---|
| 2813 | FieldName_2=r.var2; |
---|
| 2814 | end |
---|
| 2815 | if ~isfield(UvData.Field,FieldName) |
---|
| 2816 | msgbox_uvmat('ERROR',['no field ' FieldName ' for histogram']) |
---|
| 2817 | return |
---|
| 2818 | end |
---|
| 2819 | FieldHisto=Field.(FieldName); |
---|
| 2820 | if isfield(Field,'FF') && ~isempty(Field.FF) && isequal(size(Field.FF),size(FieldHisto)) |
---|
| 2821 | indsel=find(Field.FF==0);%find values marked as false |
---|
| 2822 | if ~isempty(indsel) |
---|
| 2823 | FieldHisto=FieldHisto(indsel); |
---|
| 2824 | if ~isempty(FieldName_2) |
---|
| 2825 | FieldHisto(:,:,2)=Field.(FieldName_2)(indsel); |
---|
| 2826 | end |
---|
[387] | 2827 | end |
---|
| 2828 | end |
---|
[424] | 2829 | if isempty(Field) |
---|
| 2830 | msgbox_uvmat('ERROR',['empty field ' FieldName]) |
---|
| 2831 | else |
---|
| 2832 | nxy=size(FieldHisto); |
---|
| 2833 | Amin=double(min(min(min(FieldHisto))));%min of field value |
---|
| 2834 | Amax=double(max(max(max(FieldHisto))));%max of field value |
---|
| 2835 | if isequal(Amin,Amax) |
---|
[511] | 2836 | cla(handles.HistoAxes) |
---|
[424] | 2837 | else |
---|
| 2838 | Histo.ListVarName={FieldName,'histo'}; |
---|
| 2839 | if isfield(Field,'NbDim') && isequal(Field.NbDim,3) |
---|
| 2840 | Histo.VarDimName={FieldName,FieldName}; %dimensions for the histogram |
---|
| 2841 | else |
---|
| 2842 | if numel(nxy)==2 |
---|
| 2843 | Histo.VarDimName={FieldName,FieldName}; %dimensions for the histogram |
---|
| 2844 | else |
---|
| 2845 | Histo.VarDimName={FieldName,{FieldName,'component'}}; %dimensions for the histogram |
---|
| 2846 | end |
---|
| 2847 | end |
---|
| 2848 | %unit |
---|
| 2849 | units=[]; %default |
---|
| 2850 | for ivar=1:numel(Field.ListVarName) |
---|
| 2851 | if strcmp(Field.ListVarName{ivar},FieldName) |
---|
| 2852 | if isfield(Field,'VarAttribute') && numel(Field.VarAttribute)>=ivar && isfield(Field.VarAttribute{ivar},'units') |
---|
| 2853 | units=Field.VarAttribute{ivar}.units; |
---|
| 2854 | break |
---|
| 2855 | end |
---|
| 2856 | end |
---|
| 2857 | end |
---|
| 2858 | if ~isempty(units) |
---|
| 2859 | Histo.VarAttribute{1}.units=units; |
---|
| 2860 | end |
---|
| 2861 | eval(['Histo.' FieldName '=linspace(Amin,Amax,50);'])%absissa values for histo |
---|
| 2862 | if isfield(Field,'NbDim') && isequal(Field.NbDim,3) |
---|
| 2863 | C=reshape(double(FieldHisto),1,[]);% reshape in a vector |
---|
| 2864 | Histo.histo(:,1)=hist(C, Histo.(FieldName)); %calculate histogram |
---|
| 2865 | else |
---|
| 2866 | for col=1:size(FieldHisto,3) |
---|
| 2867 | B=FieldHisto(:,:,col); |
---|
| 2868 | C=reshape(double(B),1,nxy(1)*nxy(2));% reshape in a vector |
---|
| 2869 | Histo.histo(:,col)=hist(C, Histo.(FieldName)); %calculate histogram |
---|
| 2870 | end |
---|
| 2871 | end |
---|
[511] | 2872 | plot_field(Histo,handles.HistoAxes); |
---|
[426] | 2873 | hlegend=legend; |
---|
| 2874 | if isempty(FieldName_2) |
---|
| 2875 | set(hlegend,'String',FieldName) |
---|
| 2876 | else |
---|
| 2877 | set(hlegend,'String',{FieldName;FieldName_2}) |
---|
| 2878 | end |
---|
[424] | 2879 | end |
---|
[387] | 2880 | end |
---|
| 2881 | |
---|
[622] | 2882 | %------------------------------------------------------------------------ |
---|
[387] | 2883 | % --- translate coordinate to matrix index |
---|
[622] | 2884 | %------------------------------------------------------------------------ |
---|
[387] | 2885 | function [indx,indy]=pos2ind(x0,rangx0,nxy) |
---|
| 2886 | indx=1+round((nxy(2)-1)*(x0-rangx0(1))/(rangx0(2)-rangx0(1)));% index x of pixel |
---|
| 2887 | indy=1+round((nxy(1)-1)*(y12-rangy0(1))/(rangy0(2)-rangy0(1)));% index y of pixel |
---|
| 2888 | |
---|
[622] | 2889 | %------------------------------------------------------------------------ |
---|
[428] | 2890 | % --- Executes on button press in 'CheckZoom'. |
---|
[622] | 2891 | %------------------------------------------------------------------------ |
---|
[428] | 2892 | function CheckZoom_Callback(hObject, eventdata, handles) |
---|
| 2893 | |
---|
[622] | 2894 | if get(handles.CheckZoom,'Value') |
---|
[428] | 2895 | set(handles.CheckFixLimits,'Value',1)% propose by default fixed limits for the plotting axes |
---|
[622] | 2896 | set(handles.CheckZoomFig,'Value',0)%desactivate zoom fig |
---|
[428] | 2897 | end |
---|
| 2898 | |
---|
[622] | 2899 | %------------------------------------------------------------------------ |
---|
| 2900 | % --- Executes on button press in CheckZoomFig. |
---|
| 2901 | %------------------------------------------------------------------------ |
---|
| 2902 | function CheckZoomFig_Callback(hObject, eventdata, handles) |
---|
| 2903 | |
---|
| 2904 | if get(handles.CheckZoomFig,'Value') |
---|
| 2905 | set(handles.CheckZoom,'value',0) |
---|
| 2906 | end |
---|
| 2907 | |
---|
| 2908 | %------------------------------------------------------------------------ |
---|
[387] | 2909 | % --- Executes on button press in 'CheckFixLimits'. |
---|
[622] | 2910 | %------------------------------------------------------------------------ |
---|
[387] | 2911 | function CheckFixLimits_Callback(hObject, eventdata, handles) |
---|
[622] | 2912 | |
---|
| 2913 | if ~get(handles.CheckFixLimits,'Value') |
---|
[387] | 2914 | update_plot(handles); |
---|
| 2915 | end |
---|
| 2916 | |
---|
[622] | 2917 | %------------------------------------------------------------------------ |
---|
[428] | 2918 | % --- Executes on button press in CheckFixAspectRatio. |
---|
| 2919 | function CheckFixAspectRatio_Callback(hObject, eventdata, handles) |
---|
[622] | 2920 | %------------------------------------------------------------------------ |
---|
| 2921 | |
---|
[428] | 2922 | if get(handles.CheckFixAspectRatio,'Value') |
---|
[387] | 2923 | update_plot(handles); |
---|
| 2924 | else |
---|
| 2925 | update_plot(handles); |
---|
| 2926 | end |
---|
| 2927 | |
---|
[622] | 2928 | %------------------------------------------------------------------------ |
---|
[428] | 2929 | function num_AspectRatio_Callback(hObject, eventdata, handles) |
---|
[622] | 2930 | %------------------------------------------------------------------------ |
---|
[428] | 2931 | set(handles.CheckFixAspectRatio,'Value',1)% select the fixed aspect ratio button |
---|
| 2932 | update_plot(handles); |
---|
[387] | 2933 | |
---|
[622] | 2934 | %------------------------------------------------------------------------ |
---|
[387] | 2935 | %----Executes on button press in 'record': records the current flags of manual correction. |
---|
[622] | 2936 | %------------------------------------------------------------------------ |
---|
[387] | 2937 | function record_Callback(hObject, eventdata, handles) |
---|
[622] | 2938 | |
---|
[387] | 2939 | [RootPath,SubDir,RootFile,FileIndices,FileExt]=read_file_boxes(handles); |
---|
[450] | 2940 | FileName=[fullfile(RootPath,SubDir,RootFile) FileIndices FileExt]; |
---|
| 2941 | [erread,message]=fileattrib(FileName); |
---|
[387] | 2942 | if ~isempty(message) && ~isequal(message.UserWrite,1) |
---|
[450] | 2943 | msgbox_uvmat('ERROR',['no writting access to ' FileName]) |
---|
[387] | 2944 | return |
---|
| 2945 | end |
---|
[627] | 2946 | MenuVelType=get(handles.VelType,'String'); |
---|
| 2947 | test_civ2=strcmp(MenuVelType{get(handles.VelType,'Value')},'civ2'); |
---|
| 2948 | test_civ1=strcmp(MenuVelType{get(handles.VelType,'Value')},'civ1'); |
---|
[387] | 2949 | if ~test_civ2 && ~test_civ1 |
---|
| 2950 | msgbox_uvmat('ERROR','manual correction only possible for CIV1 or CIV2 velocity fields') |
---|
| 2951 | end |
---|
| 2952 | if test_civ2 |
---|
[627] | 2953 | nbname='nb_vec_2'; |
---|
| 2954 | flagname='Civ2_FF'; |
---|
| 2955 | CivStage=5; |
---|
[387] | 2956 | end |
---|
| 2957 | if test_civ1 |
---|
[627] | 2958 | nbname='nb_vec_1'; |
---|
| 2959 | flagname='Civ1_FF'; |
---|
| 2960 | CivStage=2; |
---|
[387] | 2961 | end |
---|
| 2962 | %write fix flags in the netcdf file |
---|
| 2963 | UvData=get(handles.uvmat,'UserData'); |
---|
| 2964 | hhh=which('netcdf.open');% look for built-in matlab netcdf library |
---|
[627] | 2965 | if ~isequal(hhh,'')% case of builtin Matlab netcdf library |
---|
[450] | 2966 | nc=netcdf.open(FileName,'NC_WRITE'); |
---|
[387] | 2967 | netcdf.reDef(nc); |
---|
[627] | 2968 | netcdf.putAtt(nc,netcdf.getConstant('NC_GLOBAL'),'CivStage',CivStage); |
---|
[387] | 2969 | dimid = netcdf.inqDimID(nc,nbname); |
---|
| 2970 | try |
---|
| 2971 | varid = netcdf.inqVarID(nc,flagname);% look for already existing fixflag variable |
---|
| 2972 | catch |
---|
| 2973 | varid=netcdf.defVar(nc,flagname,'double',dimid);%create fixflag variable if it does not exist |
---|
| 2974 | end |
---|
| 2975 | netcdf.endDef(nc); |
---|
[511] | 2976 | netcdf.putVar(nc,varid,UvData.PlotAxes.FF); |
---|
[387] | 2977 | netcdf.close(nc); |
---|
| 2978 | else %old netcdf library |
---|
[450] | 2979 | netcdf_toolbox(FileName,AxeData,attrname,nbname,flagname) |
---|
[387] | 2980 | end |
---|
| 2981 | |
---|
| 2982 | %------------------------------------------------------------------- |
---|
| 2983 | %----Correct the netcdf file, using toolbox (old versions of Matlab). |
---|
| 2984 | %------------------------------------------------------------------- |
---|
[450] | 2985 | function netcdf_toolbox(FileName,AxeData,attrname,nbname,flagname) |
---|
| 2986 | nc=netcdf(FileName,'write'); %open netcdf file |
---|
[387] | 2987 | result=redef(nc); |
---|
| 2988 | eval(['nc.' attrname '=1;']); |
---|
| 2989 | theDim=nc(nbname) ;% get the number of velocity vectors |
---|
| 2990 | nb_vectors=size(theDim); |
---|
| 2991 | var_FixFlag=ncvar(flagname,nc);% var_FixFlag will be written as the netcdf variable vec_FixFlag |
---|
| 2992 | var_FixFlag(1:nb_vectors)=AxeData.FF;% |
---|
| 2993 | fin=close(nc); |
---|
| 2994 | |
---|
[428] | 2995 | %------------------------------------------------------------------- |
---|
[387] | 2996 | % --- Executes on button press in SubField |
---|
| 2997 | function SubField_Callback(hObject, eventdata, handles) |
---|
[428] | 2998 | %------------------------------------------------------------------- |
---|
[387] | 2999 | UvData=get(handles.uvmat,'UserData'); |
---|
| 3000 | if get(handles.SubField,'Value')==0% if the subfield button is desactivated |
---|
| 3001 | set(handles.RootPath_1,'String','') |
---|
| 3002 | set(handles.RootFile_1,'String','') |
---|
| 3003 | set(handles.SubDir_1,'String',''); |
---|
| 3004 | set(handles.FileIndex_1,'String',''); |
---|
| 3005 | set(handles.FileExt_1,'String',''); |
---|
| 3006 | set(handles.RootPath_1,'Visible','off') |
---|
| 3007 | set(handles.RootFile_1,'Visible','off') |
---|
| 3008 | set(handles.SubDir_1,'Visible','off'); |
---|
| 3009 | set(handles.NomType_1,'Visible','off'); |
---|
| 3010 | set(handles.abs_time_1,'Visible','off') |
---|
| 3011 | set(handles.FileIndex_1,'Visible','off'); |
---|
| 3012 | set(handles.FileExt_1,'Visible','off'); |
---|
[526] | 3013 | set(handles.FieldName_1,'Value',1);%set to blank state |
---|
[387] | 3014 | set(handles.VelType_1,'Value',1);%set to blank state |
---|
[428] | 3015 | set(handles.num_Opacity,'String','')% desactivate opacity setting |
---|
[580] | 3016 | FieldList=get(handles.FieldName,'String'); |
---|
| 3017 | if numel(FieldList)>1 % if a choice of fields exists |
---|
| 3018 | set(handles.FieldName_1,'Value',1)% set second field choice to blank |
---|
| 3019 | set(handles.FieldName_1,'String',[{''};FieldList])% reproduce the menu FieldName plus a blank option |
---|
| 3020 | else |
---|
| 3021 | set(handles.FieldName_1,'String',{''})% set second field choice to blank |
---|
| 3022 | end |
---|
[387] | 3023 | if ~strcmp(get(handles.VelType,'Visible'),'on') |
---|
| 3024 | set(handles.VelType_1,'Visible','off') |
---|
| 3025 | end |
---|
| 3026 | if isfield(UvData,'XmlData_1') |
---|
| 3027 | UvData=rmfield(UvData,'XmlData_1'); |
---|
| 3028 | end |
---|
| 3029 | set(handles.uvmat,'UserData',UvData); |
---|
[591] | 3030 | transform_fct_list=get(handles.TransformName,'String'); |
---|
| 3031 | transform_fct=transform_fct_list(get(handles.TransformName,'Value')); |
---|
[515] | 3032 | if strcmp(transform_fct,'sub_field') |
---|
[591] | 3033 | set(handles.TransformName,'Value',1)%suppress the sub_field transform |
---|
[515] | 3034 | transform_fct_Callback(hObject, eventdata, handles); |
---|
| 3035 | else |
---|
| 3036 | run0_Callback(hObject, eventdata, handles) |
---|
| 3037 | end |
---|
[387] | 3038 | else |
---|
| 3039 | MenuBrowse_1_Callback(hObject, eventdata, handles) |
---|
| 3040 | end |
---|
| 3041 | |
---|
| 3042 | %------------------------------------------------------------------------ |
---|
| 3043 | % --- read the data displayed for the input rootfile windows (new): TODO use read_GUI |
---|
| 3044 | |
---|
| 3045 | function [RootPath,SubDir,RootFile,FileIndices,FileExt]=read_file_boxes(handles) |
---|
| 3046 | %------------------------------------------------------------------------ |
---|
| 3047 | InputFile=read_GUI(handles.InputFile); |
---|
| 3048 | RootPath=InputFile.RootPath; |
---|
| 3049 | SubDir=regexprep(InputFile.SubDir,'/|\',''); |
---|
| 3050 | RootFile=regexprep(InputFile.RootFile,'/|\',''); |
---|
| 3051 | FileIndices=InputFile.FileIndex; |
---|
| 3052 | FileExt=InputFile.FileExt; |
---|
| 3053 | |
---|
| 3054 | |
---|
| 3055 | %------------------------------------------------------------------------ |
---|
| 3056 | % ---- read the data displayed for the second input rootfile windows |
---|
| 3057 | function [RootPath_1,SubDir_1,RootFile_1,FileIndex_1,FileExt_1,NomType_1]=read_file_boxes_1(handles) |
---|
| 3058 | %------------------------------------------------------------------------ |
---|
| 3059 | RootPath_1=get(handles.RootPath_1,'String'); % read the data from the file1_input window |
---|
| 3060 | if isequal(get(handles.RootPath_1,'Visible'),'off') || isequal(RootPath_1,'"') |
---|
| 3061 | RootPath_1=get(handles.RootPath,'String'); |
---|
| 3062 | end; |
---|
| 3063 | SubDir_1=get(handles.SubDir_1,'String'); |
---|
| 3064 | if isequal(get(handles.SubDir_1,'Visible'),'off')|| isequal(SubDir_1,'"') |
---|
| 3065 | SubDir_1=get(handles.SubDir,'String'); |
---|
| 3066 | end |
---|
| 3067 | SubDir_1=regexprep(SubDir_1,'\<[\\/]|[\\/]\>','');%suppress possible / or \ separator at the beginning or the end of the string |
---|
| 3068 | RootFile_1=get(handles.RootFile_1,'String'); |
---|
| 3069 | if isequal(get(handles.RootFile_1,'Visible'),'off') || isequal(RootFile_1,'"') |
---|
| 3070 | RootFile_1=get(handles.RootFile,'String'); |
---|
| 3071 | end |
---|
| 3072 | RootFile_1=regexprep(RootFile_1,'\<[\\/]|[\\/]\>','');%suppress possible / or \ separator at the beginning or the end of the string |
---|
| 3073 | FileIndex_1=get(handles.FileIndex_1,'String'); |
---|
| 3074 | if isequal(get(handles.FileIndex_1,'Visible'),'off')|| isequal(FileIndex_1,'"') |
---|
| 3075 | FileIndex_1=get(handles.FileIndex,'String'); |
---|
| 3076 | end |
---|
| 3077 | FileExt_1=get(handles.FileExt_1,'String'); |
---|
| 3078 | if isequal(get(handles.FileExt_1,'Visible'),'off') || isequal(FileExt_1,'"') |
---|
| 3079 | FileExt_1=get(handles.FileExt,'String');%read FileExt by default |
---|
| 3080 | end |
---|
| 3081 | NomType_1=get(handles.NomType_1,'String'); |
---|
| 3082 | if isequal(get(handles.NomType_1,'Visible'),'off') || isequal(NomType_1,'"') |
---|
| 3083 | NomType_1=get(handles.NomType,'String');%read FileExt by default |
---|
| 3084 | end |
---|
| 3085 | %------------------------------------------------------------------------ |
---|
[526] | 3086 | % --- Executes on menu selection FieldName |
---|
| 3087 | function FieldName_Callback(hObject, eventdata, handles) |
---|
[387] | 3088 | %------------------------------------------------------------------------ |
---|
[581] | 3089 | UvData=get(handles.uvmat,'UserData'); |
---|
[526] | 3090 | list_fields=get(handles.FieldName,'String');% list menu fields |
---|
| 3091 | index_fields=get(handles.FieldName,'Value');% selected string index |
---|
[387] | 3092 | field= list_fields{index_fields(1)}; % selected string |
---|
[581] | 3093 | |
---|
| 3094 | %% fill the coordinates and variables from selections in get_field |
---|
[387] | 3095 | if isequal(field,'get_field...') |
---|
[582] | 3096 | ParamIn=[]; |
---|
[581] | 3097 | if strcmp(get(handles.VelType,'Visible'),'on') |
---|
| 3098 | % we use the civ choice as default input |
---|
| 3099 | ParamIn.SwitchVarIndexTime='attribute'; |
---|
| 3100 | ListVelType=get(handles.VelType,'String'); |
---|
| 3101 | VelType=ListVelType{get(handles.VelType,'Value')}; |
---|
| 3102 | switch VelType |
---|
| 3103 | case 'civ1' |
---|
| 3104 | ParamIn.TimeVarName='Civ1_Time'; |
---|
| 3105 | ParamIn.vector_x='Civ1_U'; |
---|
| 3106 | ParamIn.vector_y='Civ1_V'; |
---|
[582] | 3107 | ParamIn.vec_color='Civ1_C'; |
---|
[581] | 3108 | case 'filter1' |
---|
| 3109 | ParamIn.TimeVarName='Civ1_Time'; |
---|
| 3110 | ParamIn.vector_x='Civ1_U_smooth'; |
---|
| 3111 | ParamIn.vector_y='Civ1_V_smooth'; |
---|
| 3112 | case 'civ2' |
---|
| 3113 | ParamIn.TimeVarName='Civ2_Time'; |
---|
| 3114 | ParamIn.vector_x='Civ2_U'; |
---|
| 3115 | ParamIn.vector_y='Civ2_V'; |
---|
| 3116 | case 'filter2' |
---|
| 3117 | ParamIn.TimeVarName='Civ2_Time'; |
---|
| 3118 | ParamIn.vector_x='Civ2_U_smooth'; |
---|
| 3119 | ParamIn.vector_y='Civ2_V_smooth'; |
---|
[582] | 3120 | ParamIn.vec_color='Civ2_C'; |
---|
[581] | 3121 | end |
---|
| 3122 | end |
---|
[387] | 3123 | set(handles.FixVelType,'visible','off') |
---|
[581] | 3124 | set(handles.VelType,'Visible','off') |
---|
| 3125 | set(handles.VelType_1,'Visible','off') |
---|
[387] | 3126 | [RootPath,SubDir,RootFile,FileIndices,FileExt]=read_file_boxes(handles); |
---|
[450] | 3127 | FileName=[fullfile(RootPath,SubDir,RootFile) FileIndices FileExt]; |
---|
[581] | 3128 | % hget_field=findobj(allchild(0),'name','get_field'); |
---|
| 3129 | % if ~isempty(hget_field) |
---|
| 3130 | % delete(hget_field) |
---|
| 3131 | % end |
---|
| 3132 | GetFieldData=get_field(FileName,ParamIn); |
---|
| 3133 | FieldList={}; |
---|
| 3134 | VecColorList={}; |
---|
[595] | 3135 | XName=GetFieldData.XVarName; |
---|
[581] | 3136 | if GetFieldData.CheckVector |
---|
| 3137 | UName=GetFieldData.PanelVectors.vector_x; |
---|
| 3138 | VName=GetFieldData.PanelVectors.vector_y; |
---|
[586] | 3139 | XName=GetFieldData.XVarName; |
---|
| 3140 | YName=GetFieldData.YVarName; |
---|
[581] | 3141 | CName=GetFieldData.PanelVectors.vec_color; |
---|
| 3142 | [FieldList,VecColorList]=set_field_list(UName,VName,CName); |
---|
[595] | 3143 | elseif GetFieldData.CheckScalar |
---|
[581] | 3144 | AName=GetFieldData.PanelScalar.scalar; |
---|
[586] | 3145 | XName=GetFieldData.XVarName; |
---|
| 3146 | YName=GetFieldData.YVarName; |
---|
[581] | 3147 | FieldList={AName}; |
---|
[595] | 3148 | elseif GetFieldData.CheckPlot1D; |
---|
[581] | 3149 | YName=GetFieldData.CheckPlot1D.ordinate; |
---|
| 3150 | end |
---|
| 3151 | set(handles.Coord_x,'String',{XName}) |
---|
| 3152 | set(handles.Coord_y,'String',{YName}) |
---|
| 3153 | set(handles.FieldName,'Value',1) |
---|
| 3154 | set(handles.FieldName,'String',[FieldList; {'get_field...'}]); |
---|
| 3155 | set(handles.ColorScalar,'Value',1) |
---|
| 3156 | set(handles.ColorScalar,'String',VecColorList); |
---|
| 3157 | UvData.FileType{1}='netcdf'; |
---|
| 3158 | set(handles.uvmat,'UserData',UvData) |
---|
| 3159 | run0_Callback(hObject, eventdata, handles) |
---|
[517] | 3160 | return %no further action |
---|
[387] | 3161 | end |
---|
[517] | 3162 | |
---|
[387] | 3163 | |
---|
[581] | 3164 | |
---|
[387] | 3165 | %read the rootfile input display |
---|
| 3166 | [RootPath,SubDir,RootFile,FileIndices,FileExt]=read_file_boxes(handles); |
---|
| 3167 | FileName=[fullfile(RootPath,SubDir,RootFile) FileIndices FileExt]; |
---|
| 3168 | [tild,tild,tild,i1,i2,j1,j2,tild,NomType]=fileparts_uvmat(['xxx' get(handles.FileIndex,'String') FileExt]); |
---|
| 3169 | if isequal(field,'image') |
---|
[494] | 3170 | if isfield(UvData.Field,'Civ2_ImageA')%get the corresponding input image in the netcdf file |
---|
| 3171 | imagename=UvData.Field.Civ2_ImageA; |
---|
| 3172 | elseif isfield(UvData.Field,'Civ1_ImageA')% |
---|
| 3173 | imagename=UvData.Field.Civ1_ImageA; |
---|
| 3174 | else |
---|
| 3175 | SubDirBase=regexprep(SubDir,'\..*','');%take the root part of SubDir, before the first dot '.' |
---|
| 3176 | imagename=fullfile_uvmat(RootPath,SubDirBase,RootFile,'.png',NomType,i1,[],j1,[]); |
---|
| 3177 | end |
---|
[387] | 3178 | if ~exist(imagename,'file') |
---|
| 3179 | [FileName,PathName] = uigetfile( ... |
---|
| 3180 | {'*.png;*.jpg;*.tif;*.avi;*.AVI;*.vol', ' (*.png, .tif, *.avi,*.vol)'; |
---|
| 3181 | '*.jpg',' jpeg image files'; ... |
---|
| 3182 | '*.png','.png image files'; ... |
---|
| 3183 | '*.tif','.tif image files'; ... |
---|
| 3184 | '*.avi;*.AVI','.avi movie files'; ... |
---|
| 3185 | '*.vol','.volume images (png)'; ... |
---|
| 3186 | '*.*', 'All Files (*.*)'}, ... |
---|
[530] | 3187 | 'Pick an image',imagename); |
---|
| 3188 | if ~ischar(FileName),return,end %abandon if the browser is cancelled |
---|
[387] | 3189 | imagename=[PathName FileName]; |
---|
| 3190 | end |
---|
| 3191 | % display the selected field and related information |
---|
[406] | 3192 | display_file_name(handles,imagename)%display the image |
---|
[387] | 3193 | return |
---|
| 3194 | else |
---|
| 3195 | ext=get(handles.FileExt,'String'); |
---|
| 3196 | if ~isequal(ext,'.nc') %find the new NomType if the previous display was not already a netcdf file |
---|
| 3197 | [FileName,PathName] = uigetfile( ... |
---|
| 3198 | {'*.nc', ' (*.nc)'; |
---|
| 3199 | '*.nc',' netcdf files'; ... |
---|
| 3200 | '*.*', 'All Files (*.*)'}, ... |
---|
| 3201 | 'Pick a netcdf file',FileBase); |
---|
[530] | 3202 | if ~ischar(FileName),return,end %abandon if the browser is cancelled |
---|
[450] | 3203 | FullFileName=[PathName FileName]; |
---|
[387] | 3204 | % display the selected field and related information |
---|
[450] | 3205 | display_file_name( handles,FullFileName) |
---|
[387] | 3206 | return |
---|
| 3207 | end |
---|
| 3208 | end |
---|
| 3209 | indices=fullfile_uvmat('','','','',NomType,i1,i2,j1,j2); |
---|
| 3210 | set(handles.FileIndex,'String',indices) |
---|
| 3211 | |
---|
| 3212 | %common to Fields_1_Callback |
---|
[526] | 3213 | list_fields_1=get(handles.FieldName_1,'String');% list menu fields |
---|
[517] | 3214 | field_1=''; |
---|
| 3215 | if ~isempty(list_fields_1) |
---|
[526] | 3216 | field_1= list_fields_1{get(handles.FieldName_1,'Value')}; % selected string |
---|
[517] | 3217 | end |
---|
[387] | 3218 | if isequal(field,'image')||isequal(field_1,'image') |
---|
[546] | 3219 | set(handles.TitleNpxy,'Visible','on')% visible npx,pxcm... buttons |
---|
[387] | 3220 | set(handles.num_Npx,'Visible','on') |
---|
| 3221 | set(handles.num_Npy,'Visible','on') |
---|
| 3222 | else |
---|
[546] | 3223 | set(handles.TitleNpxy,'Visible','off')% visible npx,pxcm... buttons |
---|
[387] | 3224 | set(handles.num_Npx,'Visible','off') |
---|
| 3225 | set(handles.num_Npy,'Visible','off') |
---|
| 3226 | end |
---|
| 3227 | if ~(isfield(UvData,'NewSeries')&&isequal(UvData.NewSeries,1)) |
---|
| 3228 | run0_Callback(hObject, eventdata, handles) |
---|
| 3229 | end |
---|
| 3230 | |
---|
[622] | 3231 | %---------------------------------------------------------------- |
---|
[526] | 3232 | % --- Executes on menu selection FieldName |
---|
| 3233 | function FieldName_1_Callback(hObject, eventdata, handles) |
---|
[387] | 3234 | %------------------------------------------------- |
---|
| 3235 | %% read input data |
---|
| 3236 | check_new=~get(handles.SubField,'Value'); %check_new=1 if a second field was not previously entered |
---|
| 3237 | UvData=get(handles.uvmat,'UserData'); |
---|
| 3238 | if check_new && isfield(UvData,'XmlData') |
---|
| 3239 | UvData.XmlData{2}=UvData.XmlData{1}; |
---|
| 3240 | end |
---|
[389] | 3241 | if isfield(UvData,'Field_1') |
---|
| 3242 | UvData=rmfield(UvData,'Field_1');% remove the stored second field (a new one needs to be read) |
---|
| 3243 | end |
---|
[450] | 3244 | UvData.FileName_1='';% desactivate the use of a constant second file |
---|
[526] | 3245 | list_fields=get(handles.FieldName,'String');% list menu fields |
---|
| 3246 | field= list_fields{get(handles.FieldName,'Value')}; % selected string |
---|
| 3247 | list_fields=get(handles.FieldName_1,'String');% list menu fields |
---|
| 3248 | field_1= list_fields{get(handles.FieldName_1,'Value')}; % selected string for the second field |
---|
[405] | 3249 | if isempty(field_1)%||(numel(UvData.FileType)>=2 && strcmp(UvData.FileType{2},'image')) |
---|
[387] | 3250 | set(handles.SubField,'Value',0) |
---|
| 3251 | SubField_Callback(hObject, eventdata, handles) |
---|
[428] | 3252 | return |
---|
[405] | 3253 | else |
---|
| 3254 | set(handles.SubField,'Value',1)%state that a second field is now entered |
---|
[387] | 3255 | end |
---|
| 3256 | |
---|
| 3257 | %% read the rootfile input display |
---|
[405] | 3258 | [RootPath_1,SubDir_1,RootFile_1,FileIndex_1,FileExt_1]=read_file_boxes_1(handles); |
---|
[450] | 3259 | FileName_1=[fullfile(RootPath_1,SubDir_1,RootFile_1) FileIndex_1 FileExt_1]; |
---|
[387] | 3260 | [tild,tild,tild,i1,i2,j1,j2]=fileparts_uvmat(get(handles.FileIndex,'String')); |
---|
| 3261 | switch field_1 |
---|
| 3262 | case 'get_field...' |
---|
| 3263 | set_veltype_display(0) % no veltype display |
---|
| 3264 | hget_field=findobj(allchild(0),'name','get_field_1'); |
---|
| 3265 | if ~isempty(hget_field) |
---|
| 3266 | delete(hget_field) |
---|
| 3267 | end |
---|
[450] | 3268 | hget_field=get_field(FileName_1); |
---|
[387] | 3269 | set(hget_field,'name','get_field_1') |
---|
| 3270 | hhget_field=guidata(hget_field); |
---|
| 3271 | set(hhget_field.list_fig,'Value',1) |
---|
| 3272 | set(hhget_field.list_fig,'String',{'uvmat'}) |
---|
[428] | 3273 | if check_new |
---|
| 3274 | UvData.FileType{2}=UvData.FileType{1}; |
---|
| 3275 | set(handles.FileIndex_1,'String',get(handles.FileIndex,'String')) |
---|
| 3276 | set(handles.uvmat,'UserData',UvData) |
---|
| 3277 | end |
---|
[387] | 3278 | case 'image' |
---|
[494] | 3279 | % get the image name corresponding to the current netcdf name (no unique correspondance) |
---|
| 3280 | if isfield(UvData.Field,'Civ2_ImageA')%get the corresponding input image in the netcdf file |
---|
| 3281 | imagename=UvData.Field.Civ2_ImageA; |
---|
| 3282 | elseif isfield(UvData.Field,'Civ1_ImageA')% |
---|
| 3283 | imagename=UvData.Field.Civ1_ImageA; |
---|
| 3284 | else |
---|
| 3285 | SubDirBase=regexprep(SubDir_1,'\..*','');%take the root part of SubDir, before the first dot '.' |
---|
| 3286 | imagename=fullfile_uvmat(RootPath_1,SubDirBase,RootFile_1,'.png',get(handles.NomType,'String'),i1,[],j1); |
---|
| 3287 | end |
---|
[405] | 3288 | if ~exist(imagename,'file') % browse for images if it is not found |
---|
[387] | 3289 | [FileName,PathName] = uigetfile( ... |
---|
| 3290 | {'*.png;*.jpg;*.tif;*.avi;*.AVI;*.vol', ' (*.png, .tif, *.avi,*.vol)'; |
---|
| 3291 | '*.jpg',' jpeg image files'; ... |
---|
| 3292 | '*.png','.png image files'; ... |
---|
| 3293 | '*.tif','.tif image files'; ... |
---|
| 3294 | '*.avi;*.AVI','.avi movie files'; ... |
---|
| 3295 | '*.vol','.volume images (png)'; ... |
---|
| 3296 | '*.*', 'All Files (*.*)'}, ... |
---|
| 3297 | 'Pick an image',imagename); |
---|
[530] | 3298 | if ~ischar(FileName),return,end %abandon if the browser is cancelled |
---|
[387] | 3299 | imagename=[PathName FileName]; |
---|
| 3300 | end |
---|
[405] | 3301 | if ~ischar(imagename)% quit if the browser has been closed |
---|
| 3302 | set(handles.SubField,'Value',0) |
---|
| 3303 | else %valid browser input: display the selected image |
---|
[546] | 3304 | set(handles.TitleNpxy,'Visible','on')% visible npx,pxcm... buttons |
---|
[405] | 3305 | set(handles.num_Npx,'Visible','on') |
---|
| 3306 | set(handles.num_Npy,'Visible','on') |
---|
[406] | 3307 | display_file_name(handles,imagename,2)%display the imag |
---|
[405] | 3308 | end |
---|
[387] | 3309 | otherwise |
---|
[580] | 3310 | check_refresh=1; |
---|
| 3311 | if check_new% if a second field was not previously entered, we just read another field in the first input file |
---|
[387] | 3312 | set(handles.FileIndex_1,'String',get(handles.FileIndex,'String')) |
---|
| 3313 | set(handles.FileExt_1,'String',get(handles.FileExt,'String')) |
---|
[580] | 3314 | |
---|
| 3315 | UvData.FileType{2}=UvData.FileType{1}; |
---|
| 3316 | UvData.XmlData{2}= UvData.XmlData{1}; |
---|
[591] | 3317 | transform=get(handles.TransformPath,'UserData'); |
---|
[580] | 3318 | if (~isa(transform,'function_handle')||nargin(transform)<3) |
---|
| 3319 | set(handles.uvmat,'UserData',UvData) |
---|
[591] | 3320 | set(handles.TransformName,'value',2); % set transform fct to 'sub_field' if the current fct does not accept two input fields |
---|
[580] | 3321 | transform_fct_Callback(hObject, eventdata, handles)% activate transform_fct_Callback and refresh current plot |
---|
| 3322 | check_refresh=0; |
---|
| 3323 | end |
---|
[387] | 3324 | end |
---|
| 3325 | if ~isequal(field,'image') |
---|
[546] | 3326 | set(handles.TitleNpxy,'Visible','off')% visible npx,pxcm... buttons |
---|
[387] | 3327 | set(handles.num_Npx,'Visible','off') |
---|
| 3328 | set(handles.num_Npy,'Visible','off') |
---|
| 3329 | end |
---|
| 3330 | set(handles.uvmat,'UserData',UvData) |
---|
[580] | 3331 | |
---|
| 3332 | if check_refresh && ~(isfield(UvData,'NewSeries')&&isequal(UvData.NewSeries,1)) |
---|
[387] | 3333 | run0_Callback(hObject, eventdata, handles) |
---|
| 3334 | end |
---|
| 3335 | end |
---|
| 3336 | |
---|
| 3337 | %------------------------------------------------------------------------ |
---|
| 3338 | % --- set the visibility of relevant velocity type menus: |
---|
| 3339 | function menu=set_veltype_display(Civ,FileType) |
---|
| 3340 | %------------------------------------------------------------------------ |
---|
| 3341 | if ~exist('FileType','var') |
---|
| 3342 | FileType='civx'; |
---|
| 3343 | end |
---|
| 3344 | switch FileType |
---|
| 3345 | case 'civx' |
---|
[389] | 3346 | menu={'civ1';'interp1';'filter1';'civ2';'interp2';'filter2'}; |
---|
| 3347 | if isequal(Civ,0) |
---|
| 3348 | imax=0; |
---|
| 3349 | elseif isequal(Civ,1) || isequal(Civ,2) |
---|
| 3350 | imax=1; |
---|
| 3351 | elseif isequal(Civ,3) |
---|
| 3352 | imax=3; |
---|
| 3353 | elseif isequal(Civ,4) || isequal(Civ,5) |
---|
| 3354 | imax=4; |
---|
| 3355 | elseif isequal(Civ,6) %patch2 |
---|
| 3356 | imax=6; |
---|
| 3357 | end |
---|
[387] | 3358 | case 'civdata' |
---|
[389] | 3359 | menu={'civ1';'filter1';'civ2';'filter2'}; |
---|
| 3360 | if isequal(Civ,0) |
---|
| 3361 | imax=0; |
---|
| 3362 | elseif isequal(Civ,1) || isequal(Civ,2) |
---|
| 3363 | imax=1; |
---|
| 3364 | elseif isequal(Civ,3) |
---|
| 3365 | imax=2; |
---|
| 3366 | elseif isequal(Civ,4) || isequal(Civ,5) |
---|
| 3367 | imax=3; |
---|
| 3368 | elseif isequal(Civ,6) %patch2 |
---|
| 3369 | imax=4; |
---|
| 3370 | end |
---|
[387] | 3371 | end |
---|
| 3372 | menu=menu(1:imax); |
---|
| 3373 | |
---|
| 3374 | %------------------------------------------------------------------------ |
---|
[402] | 3375 | % --- Executes on button press in FixVelType. |
---|
| 3376 | function FixVelType_Callback(hObject, eventdata, handles) |
---|
| 3377 | %------------------------------------------------------------------------ |
---|
[405] | 3378 | % refresh the current plot if the fixed veltype is unselected |
---|
| 3379 | if ~get(handles.FixVelType,'Value') |
---|
[402] | 3380 | run0_Callback(hObject, eventdata, handles) |
---|
| 3381 | end |
---|
| 3382 | |
---|
| 3383 | %------------------------------------------------------------------------ |
---|
[387] | 3384 | % --- Executes on button press in VelType. |
---|
| 3385 | function VelType_Callback(hObject, eventdata, handles) |
---|
| 3386 | %------------------------------------------------------------------------ |
---|
| 3387 | set(handles.FixVelType,'Value',1) |
---|
| 3388 | run0_Callback(hObject, eventdata, handles) |
---|
| 3389 | |
---|
| 3390 | %------------------------------------------------------------------------ |
---|
[515] | 3391 | % --- Executes on choice selection in VelType_1. |
---|
[387] | 3392 | function VelType_1_Callback(hObject, eventdata, handles) |
---|
| 3393 | %------------------------------------------------------------------------ |
---|
| 3394 | set(handles.FixVelType,'Value',1)% the velocity type is now imposed by the GUI (not automatic) |
---|
[389] | 3395 | UvData=get(handles.uvmat,'UserData'); |
---|
[515] | 3396 | set(handles.run0,'BackgroundColor',[1 1 0])%paint run0 button in yellow to indicate its activation |
---|
[387] | 3397 | drawnow |
---|
[515] | 3398 | InputFile=read_GUI(handles.InputFile);% read the input file parameters |
---|
| 3399 | [RootPath,SubDir,RootFile,FileIndex,FileExt]=read_file_boxes(handles); |
---|
| 3400 | [RootPath_1,SubDir_1,RootFile_1,FileIndex_1,FileExt_1]=read_file_boxes_1(handles); |
---|
| 3401 | FileName=[fullfile(RootPath,SubDir,RootFile) FileIndex FileExt];% name of the first input file |
---|
[405] | 3402 | |
---|
[515] | 3403 | check_refresh=0; |
---|
[389] | 3404 | if isempty(InputFile.VelType_1) |
---|
[515] | 3405 | FileName_1='';% we plot the first input field without the second field |
---|
[387] | 3406 | set(handles.SubField,'Value',0) |
---|
[580] | 3407 | SubField_Callback(hObject, eventdata, handles)% activate SubField_Callback and refresh current plot, removing the second field |
---|
[387] | 3408 | elseif get(handles.SubField,'Value')% if subfield is already 'on' |
---|
[515] | 3409 | FileName_1=[fullfile(RootPath_1,SubDir_1,RootFile_1) FileIndex_1 FileExt_1];% name of the second input file |
---|
[580] | 3410 | check_refresh=1;%will refresh the current plot |
---|
[515] | 3411 | else% we introduce the same file (with a different field) for the second series |
---|
| 3412 | FileName_1=FileName;% we compare two fields in the same file |
---|
[389] | 3413 | UvData.FileType{2}=UvData.FileType{1}; |
---|
[515] | 3414 | UvData.XmlData{2}= UvData.XmlData{1}; |
---|
[387] | 3415 | set(handles.SubField,'Value',1) |
---|
[591] | 3416 | transform=get(handles.TransformPath,'UserData'); |
---|
[515] | 3417 | if (~isa(transform,'function_handle')||nargin(transform)<3) |
---|
[580] | 3418 | set(handles.uvmat,'UserData',UvData) |
---|
[591] | 3419 | set(handles.TransformName,'value',2); % set transform fct to 'sub_field' if the current fct does not accept two input fields |
---|
[580] | 3420 | transform_fct_Callback(hObject, eventdata, handles)% activate transform_fct_Callback and refresh current plot |
---|
[515] | 3421 | else |
---|
| 3422 | check_refresh=1; |
---|
| 3423 | end |
---|
[387] | 3424 | end |
---|
| 3425 | |
---|
[580] | 3426 | % refresh the current plot if it has not been done previously |
---|
[515] | 3427 | if check_refresh |
---|
| 3428 | UvData.FileName_1='';% desactivate the use of a constant second file |
---|
| 3429 | set(handles.uvmat,'UserData',UvData) |
---|
| 3430 | num_i1=stra2num(get(handles.i1,'String')); |
---|
| 3431 | num_i2=stra2num(get(handles.i2,'String')); |
---|
| 3432 | num_j1=stra2num(get(handles.j1,'String')); |
---|
| 3433 | num_j2=stra2num(get(handles.j2,'String')); |
---|
| 3434 | [tild,tild,tild,i1_1,i2_1,j1_1,j2_1]=fileparts_uvmat(['xx' FileIndex_1]); |
---|
| 3435 | errormsg=refresh_field(handles,FileName,FileName_1,num_i1,num_i2,num_j1,num_j2,i1_1,i2_1,j1_1,j2_1); |
---|
| 3436 | if ~isempty(errormsg) |
---|
| 3437 | msgbox_uvmat('ERROR',errormsg); |
---|
| 3438 | else |
---|
| 3439 | set(handles.i1,'BackgroundColor',[1 1 1]) |
---|
| 3440 | set(handles.i2,'BackgroundColor',[1 1 1]) |
---|
| 3441 | set(handles.j1,'BackgroundColor',[1 1 1]) |
---|
| 3442 | set(handles.j2,'BackgroundColor',[1 1 1]) |
---|
| 3443 | set(handles.FileIndex,'BackgroundColor',[1 1 1]) |
---|
| 3444 | set(handles.FileIndex_1,'BackgroundColor',[1 1 1]) |
---|
| 3445 | end |
---|
| 3446 | set(handles.run0,'BackgroundColor',[1 0 0]) |
---|
[387] | 3447 | end |
---|
| 3448 | |
---|
[580] | 3449 | |
---|
[622] | 3450 | %------------------------------------------------------------------------ |
---|
[387] | 3451 | % --- reset civ buttons |
---|
| 3452 | function reset_vel_type(handles_civ0,handle1) |
---|
[622] | 3453 | %------------------------------------------------------------------------ |
---|
[387] | 3454 | for ibutton=1:length(handles_civ0) |
---|
| 3455 | set(handles_civ0(ibutton),'BackgroundColor',[0.831 0.816 0.784]) |
---|
| 3456 | set(handles_civ0(ibutton),'Value',0) |
---|
| 3457 | end |
---|
| 3458 | if exist('handle1','var')%handles of selected button |
---|
| 3459 | set(handle1,'BackgroundColor',[1 1 0]) |
---|
| 3460 | end |
---|
| 3461 | |
---|
[580] | 3462 | %----------------------------------------------------------------------- |
---|
[387] | 3463 | % --- Executes on button press in MENUVOLUME. |
---|
| 3464 | function VOLUME_Callback(hObject, eventdata, handles) |
---|
[580] | 3465 | %----------------------------------------------------------------------- |
---|
[387] | 3466 | %errordlg('command VOL not implemented yet') |
---|
| 3467 | if ishandle(handles.UVMAT_title) |
---|
| 3468 | delete(handles.UVMAT_title) |
---|
| 3469 | end |
---|
| 3470 | UvData=get(handles.uvmat,'UserData');%read UvData properties stored on the uvmat interface |
---|
| 3471 | if isequal(get(handles.VOLUME,'Value'),1) |
---|
| 3472 | set(handles.CheckZoom,'Value',0) |
---|
[623] | 3473 | % set(handles.CheckZoom,'BackgroundColor',[0.7 0.7 0.7]) |
---|
[387] | 3474 | set(handles.edit_vect,'Value',0) |
---|
| 3475 | edit_vect_Callback(hObject, eventdata, handles) |
---|
| 3476 | set(handles.edit_object,'Value',0) |
---|
[623] | 3477 | % set(handles.edit_object,'BackgroundColor',[0.7 0.7 0.7]) |
---|
[387] | 3478 | % set(handles.cal,'Value',0) |
---|
| 3479 | % set(handles.cal,'BackgroundColor',[0 1 0]) |
---|
| 3480 | set(handles.edit_vect,'Value',0) |
---|
| 3481 | edit_vect_Callback(hObject, eventdata, handles) |
---|
| 3482 | %initiate set_object GUI |
---|
| 3483 | data.Name='VOLUME'; |
---|
| 3484 | if isfield(UvData,'CoordType') |
---|
| 3485 | data.CoordType=UvData.CoordType; |
---|
| 3486 | end |
---|
[575] | 3487 | if isfield(UvData.Field,'CoordMesh')&~isempty(UvData.Field.CoordMesh) |
---|
[404] | 3488 | data.RangeX=[UvData.Field.XMin UvData.Field.XMax]; |
---|
| 3489 | data.RangeY=[UvData.Field.YMin UvData.Field.YMax]; |
---|
[575] | 3490 | data.DX=UvData.Field.CoordMesh; |
---|
| 3491 | data.DY=UvData.Field.CoordMesh; |
---|
[387] | 3492 | elseif isfield(UvData.Field,'AX')&isfield(UvData.Field,'AY')& isfield(UvData.Field,'A')%only image |
---|
| 3493 | np=size(UvData.Field.A); |
---|
| 3494 | meshx=(UvData.Field.AX(end)-UvData.Field.AX(1))/np(2); |
---|
| 3495 | meshy=abs(UvData.Field.AY(end)-UvData.Field.AY(1))/np(1); |
---|
| 3496 | data.RangeY=max(meshx,meshy); |
---|
| 3497 | data.RangeX=max(meshx,meshy); |
---|
| 3498 | data.DX=max(meshx,meshy); |
---|
| 3499 | end |
---|
| 3500 | data.ParentButton=handles.VOLUME; |
---|
| 3501 | PlotHandles=get_plot_handles(handles);%get the handles of the interface elements setting the plotting parameters |
---|
| 3502 | [hset_object,UvData.sethandles]=set_object(data,PlotHandles);% call the set_object interface with action on haxes, |
---|
| 3503 | % associate the set_object interface handle to the plotting axes |
---|
[609] | 3504 | %set(hset_object,'Position',get(handles.uvmat,'Position')+UvData.OpenParam.PosSetObject) |
---|
[387] | 3505 | UvData.MouseAction='create_object'; |
---|
| 3506 | else |
---|
| 3507 | set(handles.VOLUME,'BackgroundColor',[0 1 0]) |
---|
| 3508 | end |
---|
| 3509 | set(handles.uvmat,'UserData',UvData) |
---|
| 3510 | |
---|
| 3511 | %------------------------------------------------------- |
---|
| 3512 | function edit_vect_Callback(hObject, eventdata, handles) |
---|
| 3513 | %------------------------------------------------------- |
---|
| 3514 | % |
---|
| 3515 | if isequal(get(handles.edit_vect,'Value'),1) |
---|
[581] | 3516 | VelTypeMenu=get(handles.VelType,'String'); |
---|
| 3517 | VelType=VelTypeMenu{get(handles.VelType,'Value')}; |
---|
| 3518 | if ~strcmp(VelType,'civ2') && ~strcmp(VelType,'civ1') |
---|
[387] | 3519 | msgbox_uvmat('ERROR','manual correction only possible for CIV1 or CIV2 velocity fields') |
---|
| 3520 | end |
---|
| 3521 | set(handles.record,'Visible','on') |
---|
| 3522 | set(handles.edit_vect,'BackgroundColor',[1 1 0]) |
---|
| 3523 | set(handles.edit_object,'Value',0) |
---|
| 3524 | set(handles.CheckZoom,'Value',0) |
---|
[623] | 3525 | % set(handles.CheckZoom,'BackgroundColor',[0.7 0.7 0.7]) |
---|
| 3526 | % set(handles.edit_object,'BackgroundColor',[0.7 0.7 0.7]) |
---|
[387] | 3527 | set(gcf,'Pointer','arrow') |
---|
| 3528 | else |
---|
| 3529 | set(handles.record,'Visible','off') |
---|
| 3530 | set(handles.edit_vect,'BackgroundColor',[0.7 0.7 0.7]) |
---|
| 3531 | end |
---|
| 3532 | |
---|
| 3533 | %---------------------------------------------- |
---|
| 3534 | function save_mask_Callback(hObject, eventdata, handles) |
---|
| 3535 | %----------------------------------------------------------------------- |
---|
| 3536 | UvData=get(handles.uvmat,'UserData'); |
---|
| 3537 | |
---|
| 3538 | flag=1; |
---|
| 3539 | npx=size(UvData.Field.A,2); |
---|
| 3540 | npy=size(UvData.Field.A,1); |
---|
| 3541 | xi=0.5:npx-0.5; |
---|
| 3542 | yi=0.5:npy-0.5; |
---|
| 3543 | [Xi,Yi]=meshgrid(xi,yi); |
---|
[622] | 3544 | if isfield(UvData,'ProjObject') |
---|
| 3545 | for iobj=1:length(UvData.ProjObject) |
---|
| 3546 | ObjectData=UvData.ProjObject{iobj}; |
---|
[387] | 3547 | if isfield(ObjectData,'ProjMode') &&(isequal(ObjectData.ProjMode,'mask_inside')||isequal(ObjectData.ProjMode,'mask_outside')); |
---|
| 3548 | flagobj=1; |
---|
| 3549 | testphys=0; %coordinates in pixels by default |
---|
| 3550 | if isfield(ObjectData,'CoordType') && isequal(ObjectData.CoordType,'phys') |
---|
| 3551 | if isfield(UvData,'XmlData')&& isfield(UvData.XmlData{1},'GeometryCalib') |
---|
| 3552 | Calib=UvData.XmlData{1}.GeometryCalib; |
---|
| 3553 | testphys=1; |
---|
| 3554 | end |
---|
| 3555 | end |
---|
| 3556 | if isfield(ObjectData,'Coord')& isfield(ObjectData,'Style') |
---|
| 3557 | if isequal(ObjectData.Type,'polygon') |
---|
| 3558 | X=ObjectData.Coord(:,1); |
---|
| 3559 | Y=ObjectData.Coord(:,2); |
---|
| 3560 | if testphys |
---|
| 3561 | [X,Y]=px_XYZ(Calib,X,Y,0);% to generalise with 3D cases |
---|
| 3562 | end |
---|
| 3563 | flagobj=~inpolygon(Xi,Yi,X',Y');%=0 inside the polygon, 1 outside |
---|
| 3564 | elseif isequal(ObjectData.Type,'ellipse') |
---|
| 3565 | if testphys |
---|
| 3566 | %[X,Y]=px_XYZ(Calib,X,Y,0);% TODO:create a polygon boundary and transform to phys |
---|
| 3567 | end |
---|
| 3568 | RangeX=max(ObjectData.RangeX); |
---|
| 3569 | RangeY=max(ObjectData.RangeY); |
---|
| 3570 | X2Max=RangeX*RangeX; |
---|
| 3571 | Y2Max=RangeY*RangeY; |
---|
| 3572 | distX=(Xi-ObjectData.Coord(1,1)); |
---|
| 3573 | distY=(Yi-ObjectData.Coord(1,2)); |
---|
| 3574 | flagobj=(distX.*distX/X2Max+distY.*distY/Y2Max)>1; |
---|
| 3575 | elseif isequal(ObjectData.Type,'rectangle') |
---|
| 3576 | if testphys |
---|
| 3577 | %[X,Y]=px_XYZ(Calib,X,Y,0);% TODO:create a polygon boundary and transform to phys |
---|
| 3578 | end |
---|
| 3579 | distX=abs(Xi-ObjectData.Coord(1,1)); |
---|
| 3580 | distY=abs(Yi-ObjectData.Coord(1,2)); |
---|
| 3581 | flagobj=distX>max(ObjectData.RangeX) | distY>max(ObjectData.RangeY); |
---|
| 3582 | end |
---|
| 3583 | if isequal(ObjectData.ProjMode,'mask_outside') |
---|
| 3584 | flagobj=~flagobj; |
---|
| 3585 | end |
---|
| 3586 | flag=flag & flagobj; |
---|
| 3587 | end |
---|
| 3588 | end |
---|
| 3589 | end |
---|
| 3590 | end |
---|
| 3591 | % flag=~flag; |
---|
| 3592 | %mask name |
---|
| 3593 | RootPath=get(handles.RootPath,'String'); |
---|
| 3594 | RootFile=get(handles.RootFile,'String'); |
---|
| 3595 | RootFile=regexprep(RootFile,'\<[\\/]|[\\/]\>','');%suppress possible / or \ separator at the beginning or the end of the string |
---|
| 3596 | filebase=fullfile(RootPath,RootFile); |
---|
| 3597 | list=get(handles.masklevel,'String'); |
---|
| 3598 | masknumber=num2str(length(list)); |
---|
| 3599 | maskindex=get(handles.masklevel,'Value'); |
---|
| 3600 | mask_name=fullfile_uvmat(RootPath,SubDir,[RootFile '_' masknumber 'mask'],'.png','_1',maskindex); |
---|
| 3601 | %mask_name=name_generator([filebase '_' masknumber 'mask'],maskindex,1,'.png','_i'); |
---|
| 3602 | imflag=uint8(255*(0.392+0.608*flag));% =100 for flag=0 (vectors not computed when 20<imflag<200) |
---|
| 3603 | imflag=flipdim(imflag,1); |
---|
| 3604 | % imflag=uint8(255*flag);% =0 for flag=0 (vectors=0 when 20<imflag<200) |
---|
| 3605 | msgbox_uvmat('CONFIRMATION',[mask_name ' saved']) |
---|
| 3606 | imwrite(imflag,mask_name,'BitDepth',8); |
---|
| 3607 | |
---|
| 3608 | %display the mask |
---|
| 3609 | figure; |
---|
| 3610 | vec=linspace(0,1,256);%define a linear greyscale colormap |
---|
| 3611 | map=[vec' vec' vec']; |
---|
| 3612 | colormap(map) |
---|
| 3613 | |
---|
| 3614 | image(imflag); |
---|
| 3615 | |
---|
[622] | 3616 | %------------------------------------------------------------------------ |
---|
| 3617 | %------------------------------------------------------------------------ |
---|
[387] | 3618 | % - FUNCTIONS FOR SETTING PLOTTING PARAMETERS |
---|
| 3619 | |
---|
[622] | 3620 | %------------------------------------------------------------------------ |
---|
| 3621 | %------------------------------------------------------------------------ |
---|
[591] | 3622 | % --- Executes on selection change in TransformName. |
---|
[508] | 3623 | |
---|
[591] | 3624 | function TransformName_Callback(hObject, eventdata, handles) |
---|
[622] | 3625 | %------------------------------------------------------------------------ |
---|
[387] | 3626 | UvData=get(handles.uvmat,'UserData'); |
---|
[591] | 3627 | menu=get(handles.TransformName,'String');refresh |
---|
| 3628 | ichoice=get(handles.TransformName,'Value');%item number in the menu |
---|
[507] | 3629 | transform_name=menu{ichoice};% choice of the transform fct |
---|
[591] | 3630 | list_path=get(handles.TransformName,'UserData'); |
---|
[507] | 3631 | |
---|
| 3632 | %% add a new item to the menu if the option 'more...' has been selected |
---|
[591] | 3633 | prev_path=fullfile(get(handles.TransformPath,'String')); |
---|
[508] | 3634 | if ~exist(prev_path,'dir') |
---|
| 3635 | prev_path=fullfile(fileparts(which('uvmat')),'transform_field'); |
---|
| 3636 | end |
---|
[507] | 3637 | if strcmp(transform_name,'more...'); |
---|
[387] | 3638 | [FileName, PathName] = uigetfile( ... |
---|
[507] | 3639 | {'*.m', ' (*.m)'; |
---|
[387] | 3640 | '*.m', '.m files '; ... |
---|
| 3641 | '*.*', 'All Files (*.*)'}, ... |
---|
[508] | 3642 | 'Pick the transform function', prev_path); |
---|
[530] | 3643 | if ~ischar(FileName),return,end %abandon if the browser is cancelled |
---|
[507] | 3644 | path_transform_fct =fullfile(PathName,FileName); |
---|
[556] | 3645 | if isempty(regexp(FileName,'\.m$'))% detect file extension .m |
---|
[387] | 3646 | msgbox_uvmat('ERROR','a Matlab function .m must be introduced'); |
---|
| 3647 | return |
---|
[507] | 3648 | else |
---|
[556] | 3649 | transform_name=regexprep(FileName,'\.m',''); |
---|
[507] | 3650 | end |
---|
| 3651 | ichoice=find(strcmp(transform_name,menu),1);%look for the selected fct in the existing menu |
---|
| 3652 | if isempty(ichoice)% if the item is not found, add it to the menu (before 'more...' and select it) |
---|
| 3653 | menu=[menu(1:end-1);{transform_name};{'more...'}]; |
---|
| 3654 | ichoice=numel(menu)-1; |
---|
| 3655 | end |
---|
| 3656 | list_path{ichoice}=PathName;%update the list fo fct paths |
---|
[591] | 3657 | set(handles.TransformName,'String',menu) |
---|
| 3658 | set(handles.TransformName,'Value',ichoice) |
---|
[507] | 3659 | |
---|
| 3660 | % save the new menu in the personal file 'uvmat_perso.mat' |
---|
| 3661 | dir_perso=prefdir;%personal Matalb directory |
---|
| 3662 | profil_perso=fullfile(dir_perso,'uvmat_perso.mat'); |
---|
| 3663 | if exist(profil_perso,'file') |
---|
| 3664 | nb_builtin=UvData.OpenParam.NbBuiltin;% number of 'builtin' (basic) transform fcts in uvmat |
---|
[523] | 3665 | if nb_builtin<numel(list_path) |
---|
[507] | 3666 | for ilist=nb_builtin+1:numel(list_path) |
---|
[508] | 3667 | transform_fct{ilist-nb_builtin}=[fullfile(list_path{ilist},menu{ilist}) '.m']; |
---|
[507] | 3668 | end |
---|
[387] | 3669 | save (profil_perso,'transform_fct','-append'); %store the root name for future opening of uvmat |
---|
[523] | 3670 | end |
---|
[507] | 3671 | end |
---|
[387] | 3672 | end |
---|
| 3673 | |
---|
[507] | 3674 | %% create the function handle of the selected fct |
---|
[512] | 3675 | |
---|
[507] | 3676 | if isempty(list_path{ichoice})% case of no selected fct |
---|
| 3677 | transform_handle=[]; |
---|
[387] | 3678 | else |
---|
[507] | 3679 | if ~exist(list_path{ichoice},'dir') |
---|
| 3680 | msgbox_uvmat('ERROR','invalid fct path: select the transform fct again with the option more...') |
---|
| 3681 | return |
---|
| 3682 | end |
---|
| 3683 | current_dir=pwd;%current working dir |
---|
| 3684 | cd(list_path{ichoice}) |
---|
| 3685 | transform_handle=str2func(transform_name); |
---|
| 3686 | cd(current_dir) |
---|
[387] | 3687 | end |
---|
[591] | 3688 | set(handles.TransformPath,'String',list_path{ichoice}) |
---|
| 3689 | set(handles.TransformPath,'UserData',transform_handle) |
---|
| 3690 | set(handles.TransformName,'UserData',list_path) |
---|
[387] | 3691 | |
---|
[591] | 3692 | %% update the ToolTip string of the menu TransformName with the first line of the selected fct file |
---|
[507] | 3693 | if isempty(list_path{ichoice})% case of no selected fct |
---|
[591] | 3694 | set(handles.TransformName,'ToolTipString','transform_fct:choose a transform function') |
---|
[507] | 3695 | else |
---|
| 3696 | try |
---|
| 3697 | [fid,errormsg] =fopen([fullfile(list_path{ichoice},transform_name) '.m']); |
---|
| 3698 | InputText=textscan(fid,'%s',1,'delimiter','\n'); |
---|
| 3699 | fclose(fid) |
---|
[591] | 3700 | set(handles.TransformName,'ToolTipString',['transform_fct: ' InputText{1}{1}])% put the first line of the selected function as tooltip help |
---|
[507] | 3701 | end |
---|
| 3702 | end |
---|
| 3703 | |
---|
| 3704 | %% adapt the GUI to the input/output conditions of the selected transform fct |
---|
[508] | 3705 | DataOut=[]; |
---|
| 3706 | CoordUnit=''; |
---|
| 3707 | CoordUnitPrev=''; |
---|
| 3708 | if isfield(UvData,'Field')&&isfield(UvData.Field,'CoordUnit') |
---|
| 3709 | CoordUnitPrev=UvData.Field.CoordUnit; |
---|
| 3710 | end |
---|
| 3711 | if ~isempty(list_path{ichoice}) |
---|
| 3712 | if nargin(transform_handle)>1 && isfield(UvData,'XmlData')&&~isempty(UvData.XmlData) |
---|
| 3713 | XmlData=UvData.XmlData{1}; |
---|
| 3714 | DataOut=feval(transform_handle,'*',XmlData); |
---|
| 3715 | if isfield(DataOut,'CoordUnit') |
---|
| 3716 | CoordUnit=DataOut.CoordUnit; |
---|
[507] | 3717 | end |
---|
[508] | 3718 | if isfield(DataOut,'InputFieldType') |
---|
| 3719 | UvData.InputFieldType=DataOut.InputFieldType; |
---|
| 3720 | end |
---|
| 3721 | else |
---|
| 3722 | DataOut=feval(transform_handle,'*'); |
---|
[507] | 3723 | end |
---|
| 3724 | end |
---|
| 3725 | |
---|
[387] | 3726 | |
---|
[508] | 3727 | %% delete drawn objects if the output CooordUnit is different from the previous one |
---|
| 3728 | if ~strcmp(CoordUnit,CoordUnitPrev) |
---|
[541] | 3729 | set(handles.CheckFixLimits,'Value',0) |
---|
[627] | 3730 | % set(handles.CheckFixLimits,'BackgroundColor',[0.7 0.7 0.7]) |
---|
[508] | 3731 | hother=findobj('Tag','proj_object');%find all the proj objects |
---|
| 3732 | for iobj=1:length(hother) |
---|
| 3733 | delete_object(hother(iobj)) |
---|
| 3734 | end |
---|
| 3735 | hother=findobj('Tag','DeformPoint');%find all the proj objects |
---|
| 3736 | for iobj=1:length(hother) |
---|
| 3737 | delete_object(hother(iobj)) |
---|
| 3738 | end |
---|
| 3739 | hh=findobj('Tag','calib_points'); |
---|
| 3740 | if ~isempty(hh) |
---|
| 3741 | delete(hh) |
---|
| 3742 | end |
---|
| 3743 | hhh=findobj('Tag','calib_marker'); |
---|
| 3744 | if ~isempty(hhh) |
---|
| 3745 | delete(hhh) |
---|
| 3746 | end |
---|
| 3747 | set(handles.ListObject,'Value',1) |
---|
| 3748 | set(handles.ListObject,'String',{''}) |
---|
| 3749 | set(handles.ListObject_1,'Value',1) |
---|
| 3750 | set(handles.ListObject_1,'String',{''}) |
---|
| 3751 | set(handles.ViewObject,'value',0) |
---|
| 3752 | ViewObject_Callback(hObject, eventdata, handles) |
---|
| 3753 | set(handles.ViewField,'value',0) |
---|
| 3754 | ViewField_Callback(hObject, eventdata, handles) |
---|
| 3755 | set(handles.edit_object,'Value',0) |
---|
| 3756 | edit_object_Callback(hObject, eventdata, handles) |
---|
[622] | 3757 | UvData.ProjObject={[]}; |
---|
[387] | 3758 | end |
---|
[508] | 3759 | set(handles.uvmat,'UserData',UvData) |
---|
[387] | 3760 | |
---|
[508] | 3761 | %% refresh the current plot |
---|
[515] | 3762 | if isempty(list_path{ichoice}) || nargin(transform_handle)<3 |
---|
| 3763 | set(handles.SubField,'Value',0) |
---|
| 3764 | SubField_Callback(hObject, eventdata, handles) |
---|
| 3765 | else |
---|
| 3766 | run0_Callback(hObject, eventdata, handles) |
---|
| 3767 | end |
---|
[387] | 3768 | |
---|
| 3769 | %------------------------------------------------ |
---|
| 3770 | %CALLBACKS FOR PLOTTING PARAMETERS |
---|
| 3771 | %------------------------------------------------- |
---|
[405] | 3772 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
---|
| 3773 | % Plot coordinates |
---|
| 3774 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
---|
[387] | 3775 | %------------------------------------------------------------------------ |
---|
| 3776 | function num_MinX_Callback(hObject, eventdata, handles) |
---|
| 3777 | %------------------------------------------------------------------------ |
---|
| 3778 | set(handles.CheckFixLimits,'Value',1) %suppress auto mode |
---|
[627] | 3779 | % set(handles.CheckFixLimits,'BackgroundColor',[1 1 0]) |
---|
[387] | 3780 | update_plot(handles); |
---|
| 3781 | |
---|
| 3782 | %------------------------------------------------------------------------ |
---|
| 3783 | function num_MaxX_Callback(hObject, eventdata, handles) |
---|
| 3784 | %------------------------------------------------------------------------ |
---|
| 3785 | set(handles.CheckFixLimits,'Value',1) %suppress auto mode |
---|
[627] | 3786 | % set(handles.CheckFixLimits,'BackgroundColor',[1 1 0]) |
---|
[387] | 3787 | update_plot(handles); |
---|
| 3788 | |
---|
| 3789 | %------------------------------------------------------------------------ |
---|
| 3790 | function num_MinY_Callback(hObject, eventdata, handles) |
---|
| 3791 | %------------------------------------------ |
---|
| 3792 | set(handles.CheckFixLimits,'Value',1) %suppress auto mode |
---|
[627] | 3793 | % set(handles.CheckFixLimits,'BackgroundColor',[1 1 0]) |
---|
[387] | 3794 | update_plot(handles); |
---|
| 3795 | |
---|
| 3796 | %------------------------------------------------------------------------ |
---|
| 3797 | function num_MaxY_Callback(hObject, eventdata, handles) |
---|
| 3798 | %------------------------------------------------------------------------ |
---|
| 3799 | set(handles.CheckFixLimits,'Value',1) %suppress auto mode |
---|
[627] | 3800 | % set(handles.CheckFixLimits,'BackgroundColor',[1 1 0]) |
---|
[387] | 3801 | update_plot(handles); |
---|
| 3802 | |
---|
[405] | 3803 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
---|
| 3804 | % Scalar or image representation |
---|
| 3805 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
---|
[387] | 3806 | %------------------------------------------------------------------------ |
---|
| 3807 | function num_MinA_Callback(hObject, eventdata, handles) |
---|
| 3808 | %------------------------------------------ |
---|
| 3809 | set(handles.CheckFixScalar,'Value',1) %suppress auto mode |
---|
[627] | 3810 | % set(handles.CheckFixScalar,'BackgroundColor',[1 1 0]) |
---|
[387] | 3811 | MinA=str2double(get(handles.num_MinA,'String')); |
---|
| 3812 | MaxA=str2double(get(handles.num_MaxA,'String')); |
---|
| 3813 | if MinA>MaxA% switch minA and maxA in case of error |
---|
| 3814 | MinA_old=MinA; |
---|
| 3815 | MinA=MaxA; |
---|
| 3816 | MaxA=MinA_old; |
---|
| 3817 | set(handles.num_MinA,'String',num2str(MinA,5)); |
---|
| 3818 | set(handles.num_MaxA,'String',num2str(MaxA,5)); |
---|
| 3819 | end |
---|
| 3820 | update_plot(handles); |
---|
| 3821 | |
---|
| 3822 | %------------------------------------------------------------------------ |
---|
| 3823 | function num_MaxA_Callback(hObject, eventdata, handles) |
---|
| 3824 | %------------------------------------------------------------------------ |
---|
| 3825 | set(handles.CheckFixScalar,'Value',1) %suppress auto mode |
---|
[627] | 3826 | % set(handles.CheckFixScalar,'BackgroundColor',[1 1 0]) |
---|
[387] | 3827 | MinA=str2double(get(handles.num_MinA,'String')); |
---|
| 3828 | MaxA=str2double(get(handles.num_MaxA,'String')); |
---|
| 3829 | if MinA>MaxA% switch minA and maxA in case of error |
---|
| 3830 | MinA_old=MinA; |
---|
| 3831 | MinA=MaxA; |
---|
| 3832 | MaxA=MinA_old; |
---|
| 3833 | set(handles.num_MinA,'String',num2str(MinA,5)); |
---|
| 3834 | set(handles.num_MaxA,'String',num2str(MaxA,5)); |
---|
| 3835 | end |
---|
| 3836 | update_plot(handles); |
---|
| 3837 | |
---|
| 3838 | %------------------------------------------------------------------------ |
---|
| 3839 | function CheckFixScalar_Callback(hObject, eventdata, handles) |
---|
| 3840 | %------------------------------------------------------------------------ |
---|
| 3841 | test=get(handles.CheckFixScalar,'Value'); |
---|
| 3842 | if test |
---|
[627] | 3843 | % set(handles.CheckFixScalar,'BackgroundColor',[1 1 0]) |
---|
[387] | 3844 | else |
---|
[627] | 3845 | % set(handles.CheckFixScalar,'BackgroundColor',[0.7 0.7 0.7]) |
---|
[387] | 3846 | update_plot(handles); |
---|
| 3847 | end |
---|
| 3848 | |
---|
| 3849 | %------------------------------------------------------------------- |
---|
| 3850 | function CheckBW_Callback(hObject, eventdata, handles) |
---|
| 3851 | %------------------------------------------------------------------- |
---|
| 3852 | update_plot(handles); |
---|
| 3853 | |
---|
| 3854 | %------------------------------------------------------------------- |
---|
[428] | 3855 | function num_Opacity_Callback(hObject, eventdata, handles) |
---|
| 3856 | update_plot(handles); |
---|
| 3857 | %------------------------------------------------------------------- |
---|
| 3858 | |
---|
| 3859 | %------------------------------------------------------------------- |
---|
[387] | 3860 | function ListContour_Callback(hObject, eventdata, handles) |
---|
| 3861 | %------------------------------------------------------------------- |
---|
| 3862 | val=get(handles.ListContour,'Value'); |
---|
| 3863 | if val==2 |
---|
| 3864 | set(handles.interval_txt,'Visible','on') |
---|
| 3865 | set(handles.num_IncrA,'Visible','on') |
---|
| 3866 | else |
---|
| 3867 | set(handles.interval_txt,'Visible','off') |
---|
| 3868 | set(handles.num_IncrA,'Visible','off') |
---|
| 3869 | end |
---|
| 3870 | update_plot(handles); |
---|
| 3871 | |
---|
| 3872 | %------------------------------------------------------------------- |
---|
| 3873 | function num_IncrA_Callback(hObject, eventdata, handles) |
---|
| 3874 | %------------------------------------------------------------------- |
---|
| 3875 | update_plot(handles); |
---|
| 3876 | |
---|
[405] | 3877 | |
---|
| 3878 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
---|
| 3879 | % Vector representation |
---|
| 3880 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
---|
[387] | 3881 | %------------------------------------------------------------------- |
---|
| 3882 | function CheckHideWarning_Callback(hObject, eventdata, handles) |
---|
| 3883 | %------------------------------------------------------------------- |
---|
| 3884 | update_plot(handles); |
---|
| 3885 | |
---|
| 3886 | %------------------------------------------------------------------- |
---|
| 3887 | function CheckHideFalse_Callback(hObject, eventdata, handles) |
---|
| 3888 | %------------------------------------------------------------------- |
---|
| 3889 | update_plot(handles); |
---|
| 3890 | |
---|
| 3891 | %------------------------------------------------------------------- |
---|
| 3892 | function num_VecScale_Callback(hObject, eventdata, handles) |
---|
| 3893 | %------------------------------------------------------------------- |
---|
| 3894 | set(handles.CheckFixVectors,'Value',1); |
---|
| 3895 | set(handles.CheckFixVectors,'BackgroundColor',[1 1 0]) |
---|
| 3896 | update_plot(handles); |
---|
| 3897 | |
---|
| 3898 | %------------------------------------------------------------------- |
---|
| 3899 | function CheckFixVectors_Callback(hObject, eventdata, handles) |
---|
| 3900 | %------------------------------------------------------------------- |
---|
| 3901 | test=get(handles.CheckFixVectors,'Value'); |
---|
| 3902 | if test |
---|
[627] | 3903 | % set(handles.CheckFixVectors,'BackgroundColor',[1 1 0]) |
---|
[387] | 3904 | else |
---|
| 3905 | update_plot(handles); |
---|
| 3906 | %set(handles.num_VecScale,'String',num2str(ScalOut.num_VecScale,3)) |
---|
[627] | 3907 | % set(handles.CheckFixVectors,'BackgroundColor',[0.7 0.7 0.7]) |
---|
[387] | 3908 | end |
---|
| 3909 | |
---|
| 3910 | %------------------------------------------------------------------------ |
---|
| 3911 | % --- Executes on selection change in CheckDecimate4 (nb_vec/4). |
---|
[622] | 3912 | %------------------------------------------------------------------------ |
---|
[387] | 3913 | function CheckDecimate4_Callback(hObject, eventdata, handles) |
---|
[622] | 3914 | |
---|
[581] | 3915 | if isequal(get(handles.CheckDecimate4,'Value'),1) |
---|
| 3916 | set(handles.CheckDecimate16,'Value',0) |
---|
| 3917 | end |
---|
[387] | 3918 | update_plot(handles); |
---|
| 3919 | |
---|
| 3920 | %------------------------------------------------------------------------ |
---|
[581] | 3921 | % --- Executes on selection change in CheckDecimate16 (nb_vec/16). |
---|
[622] | 3922 | %------------------------------------------------------------------------ |
---|
[581] | 3923 | function CheckDecimate16_Callback(hObject, eventdata, handles) |
---|
[622] | 3924 | |
---|
[581] | 3925 | if isequal(get(handles.CheckDecimate16,'Value'),1) |
---|
| 3926 | set(handles.CheckDecimate4,'Value',0) |
---|
| 3927 | end |
---|
| 3928 | update_plot(handles); |
---|
| 3929 | |
---|
| 3930 | %------------------------------------------------------------------------ |
---|
[405] | 3931 | % --- Executes on selection change in ColorCode menu |
---|
| 3932 | function ColorCode_Callback(hObject, eventdata, handles) |
---|
[387] | 3933 | %------------------------------------------------------------------------ |
---|
[405] | 3934 | % edit the choice for color code |
---|
| 3935 | update_color_code_boxes(handles); |
---|
| 3936 | update_plot(handles); |
---|
| 3937 | |
---|
| 3938 | %------------------------------------------------------------------------ |
---|
| 3939 | function update_color_code_boxes(handles) |
---|
| 3940 | %------------------------------------------------------------------------ |
---|
| 3941 | list_code=get(handles.ColorCode,'String');% list menu fields |
---|
| 3942 | colcode= list_code{get(handles.ColorCode,'Value')}; % selected field |
---|
| 3943 | enable_slider='off';%default |
---|
| 3944 | enable_bounds='off';%default |
---|
| 3945 | enable_scalar='off';%default |
---|
| 3946 | switch colcode |
---|
| 3947 | case {'rgb','bgr'} |
---|
| 3948 | enable_slider='on'; |
---|
| 3949 | enable_bounds='on'; |
---|
| 3950 | enable_scalar='on'; |
---|
| 3951 | case '64 colors' |
---|
| 3952 | enable_bounds='on'; |
---|
| 3953 | enable_scalar='on'; |
---|
| 3954 | end |
---|
| 3955 | set(handles.Slider1,'Visible',enable_slider) |
---|
| 3956 | set(handles.Slider2,'Visible', enable_slider) |
---|
| 3957 | set(handles.num_ColCode1,'Visible',enable_slider) |
---|
| 3958 | set(handles.num_ColCode2,'Visible',enable_slider) |
---|
| 3959 | set(handles.TitleColCode1,'Visible',enable_slider) |
---|
| 3960 | set(handles.TitleColCode2,'Visible',enable_slider) |
---|
| 3961 | set(handles.CheckFixVecColor,'Visible',enable_bounds) |
---|
| 3962 | set(handles.num_MinVec,'Visible',enable_bounds) |
---|
| 3963 | set(handles.num_MaxVec,'Visible',enable_bounds) |
---|
| 3964 | set(handles.ColorScalar,'Visible',enable_scalar) |
---|
[387] | 3965 | set_vec_col_bar(handles) |
---|
[405] | 3966 | |
---|
| 3967 | %------------------------------------------------------------------ |
---|
| 3968 | % --- Executes on selection change in ColorScalar: choice of the color code. |
---|
| 3969 | function ColorScalar_Callback(hObject, eventdata, handles) |
---|
| 3970 | %------------------------------------------------------------------ |
---|
| 3971 | % edit the choice for color code |
---|
| 3972 | list_scalar=get(handles.ColorScalar,'String');% list menu fields |
---|
| 3973 | col_scalar= list_scalar{get(handles.ColorScalar,'Value')}; % selected field |
---|
| 3974 | if isequal(col_scalar,'ima_cor') |
---|
| 3975 | set(handles.CheckFixVecColor,'Value',1)%fixed scale by default |
---|
| 3976 | ColorCode='rgb'; |
---|
| 3977 | set(handles.num_MinVec,'String','0') |
---|
| 3978 | set(handles.num_MaxVec,'String','1') |
---|
| 3979 | set(handles.num_ColCode1,'String','0.333') |
---|
| 3980 | set(handles.num_ColCode2,'String','0.666') |
---|
| 3981 | else |
---|
| 3982 | set(handles.CheckFixVecColor,'Value',0)%auto scale between min,max by default |
---|
| 3983 | ColorCode='64 colors'; |
---|
| 3984 | end |
---|
| 3985 | ColorCodeList=get(handles.ColorCode,'String'); |
---|
| 3986 | ichoice=find(strcmp(ColorCode,ColorCodeList),1); |
---|
| 3987 | set(handles.ColorCode,'Value',ichoice)% set color code in the menu |
---|
| 3988 | |
---|
| 3989 | update_color_code_boxes(handles); |
---|
| 3990 | %replot the current graph |
---|
| 3991 | run0_Callback(hObject, eventdata, handles) |
---|
| 3992 | |
---|
| 3993 | %---------------------------------------------------------------- |
---|
| 3994 | % -- Executes on slider movement to set the color code |
---|
| 3995 | % |
---|
| 3996 | function Slider1_Callback(hObject, eventdata, handles) |
---|
| 3997 | %------------------------------------------------------------------ |
---|
| 3998 | slider1=get(handles.Slider1,'Value'); |
---|
| 3999 | min_val=str2num(get(handles.num_MinVec,'String')); |
---|
| 4000 | max_val=str2num(get(handles.num_MaxVec,'String')); |
---|
| 4001 | col=min_val+(max_val-min_val)*slider1; |
---|
| 4002 | set(handles.num_ColCode1,'String',num2str(col)) |
---|
| 4003 | if(get(handles.Slider2,'Value') < col)%move also the second slider at the same value if needed |
---|
| 4004 | set(handles.Slider2,'Value',col) |
---|
| 4005 | set(handles.num_ColCode2,'String',num2str(col)) |
---|
| 4006 | end |
---|
| 4007 | set_vec_col_bar(handles) |
---|
[387] | 4008 | update_plot(handles); |
---|
| 4009 | |
---|
[405] | 4010 | %---------------------------------------------------------------- |
---|
| 4011 | % Executes on slider movement to set the color code |
---|
| 4012 | %---------------------------------------------------------------- |
---|
| 4013 | function Slider2_Callback(hObject, eventdata, handles) |
---|
| 4014 | slider2=get(handles.Slider2,'Value'); |
---|
| 4015 | min_val=str2num(get(handles.num_MinVec,'String')); |
---|
| 4016 | max_val=str2num(get(handles.num_MaxVec,'String')); |
---|
| 4017 | col=min_val+(max_val-min_val)*slider2; |
---|
| 4018 | set(handles.num_ColCode2,'String',num2str(col)) |
---|
| 4019 | if(get(handles.Slider1,'Value') > col)%move also the first slider at the same value if needed |
---|
| 4020 | set(handles.Slider1,'Value',col) |
---|
| 4021 | set(handles.num_ColCode1,'String',num2str(col)) |
---|
| 4022 | end |
---|
| 4023 | set_vec_col_bar(handles) |
---|
| 4024 | update_plot(handles); |
---|
| 4025 | |
---|
| 4026 | %---------------------------------------------------------------- |
---|
| 4027 | % --- Execute on return carriage on the edit box corresponding to slider 1 |
---|
| 4028 | %---------------------------------------------------------------- |
---|
| 4029 | function num_ColCode1_Callback(hObject, eventdata, handles) |
---|
| 4030 | set_vec_col_bar(handles) |
---|
| 4031 | update_plot(handles); |
---|
| 4032 | |
---|
| 4033 | %---------------------------------------------------------------- |
---|
| 4034 | % --- Execute on return carriage on the edit box corresponding to slider 2 |
---|
| 4035 | %---------------------------------------------------------------- |
---|
| 4036 | function num_ColCode2_Callback(hObject, eventdata, handles) |
---|
| 4037 | set_vec_col_bar(handles) |
---|
| 4038 | update_plot(handles); |
---|
[387] | 4039 | %------------------------------------------------------------------------ |
---|
[405] | 4040 | %------------------------------------------------------- |
---|
[387] | 4041 | % --- Executes on button press in CheckFixVecColor. |
---|
[405] | 4042 | %------------------------------------------------------- |
---|
| 4043 | function VecColBar_Callback(hObject, eventdata, handles) |
---|
| 4044 | set_vec_col_bar(handles) |
---|
| 4045 | |
---|
| 4046 | %------------------------------------------------------------------------ |
---|
| 4047 | % --- Executes on button press in CheckFixVecColor. |
---|
[387] | 4048 | function CheckFixVecColor_Callback(hObject, eventdata, handles) |
---|
| 4049 | %------------------------------------------------------------------------ |
---|
[405] | 4050 | if ~get(handles.CheckFixVecColor,'Value') |
---|
[387] | 4051 | update_plot(handles); |
---|
| 4052 | end |
---|
| 4053 | |
---|
| 4054 | %------------------------------------------------------------------------ |
---|
| 4055 | % --- Executes on selection change in num_MaxVec. |
---|
| 4056 | function num_MinVec_Callback(hObject, eventdata, handles) |
---|
| 4057 | %------------------------------------------------------------------------ |
---|
| 4058 | max_vec_Callback(hObject, eventdata, handles) |
---|
| 4059 | |
---|
| 4060 | %------------------------------------------------------------------------ |
---|
| 4061 | % --- Executes on selection change in num_MaxVec. |
---|
| 4062 | function num_MaxVec_Callback(hObject, eventdata, handles) |
---|
| 4063 | %------------------------------------------------------------------------ |
---|
| 4064 | set(handles.CheckFixVecColor,'Value',1) |
---|
| 4065 | CheckFixVecColor_Callback(hObject, eventdata, handles) |
---|
| 4066 | min_val=str2num(get(handles.num_MinVec,'String')); |
---|
| 4067 | max_val=str2num(get(handles.num_MaxVec,'String')); |
---|
| 4068 | slider1=get(handles.Slider1,'Value'); |
---|
| 4069 | slider2=get(handles.Slider2,'Value'); |
---|
| 4070 | colcode1=min_val+(max_val-min_val)*slider1; |
---|
| 4071 | colcode2=min_val+(max_val-min_val)*slider2; |
---|
| 4072 | set(handles.num_ColCode1,'String',num2str(colcode1)) |
---|
| 4073 | set(handles.num_ColCode2,'String',num2str(colcode2)) |
---|
| 4074 | update_plot(handles); |
---|
| 4075 | |
---|
| 4076 | %------------------------------------------------------------------------ |
---|
[405] | 4077 | % --- update the display of color code for vectors (on vecColBar) |
---|
[387] | 4078 | function set_vec_col_bar(handles) |
---|
| 4079 | %------------------------------------------------------------------------ |
---|
| 4080 | %get the image of the color display button 'VecColBar' in pixels |
---|
| 4081 | set(handles.VecColBar,'Unit','pixel'); |
---|
| 4082 | pos_vert=get(handles.VecColBar,'Position'); |
---|
| 4083 | set(handles.VecColBar,'Unit','Normalized'); |
---|
| 4084 | width=ceil(pos_vert(3)); |
---|
| 4085 | height=ceil(pos_vert(4)); |
---|
| 4086 | |
---|
| 4087 | %get slider indications |
---|
[405] | 4088 | list=get(handles.ColorCode,'String'); |
---|
| 4089 | ichoice=get(handles.ColorCode,'Value'); |
---|
| 4090 | colcode.ColorCode=list{ichoice}; |
---|
[387] | 4091 | colcode.MinVec=str2num(get(handles.num_MinVec,'String')); |
---|
| 4092 | colcode.MaxVec=str2num(get(handles.num_MaxVec,'String')); |
---|
[405] | 4093 | test3color=strcmp(colcode.ColorCode,'rgb') || strcmp(colcode.ColorCode,'bgr'); |
---|
[387] | 4094 | if test3color |
---|
| 4095 | colcode.ColCode1=str2num(get(handles.num_ColCode1,'String')); |
---|
| 4096 | colcode.ColCode2=str2num(get(handles.num_ColCode2,'String')); |
---|
| 4097 | end |
---|
| 4098 | vec_C=colcode.MinVec+(colcode.MaxVec-colcode.MinVec)*(0.5:width-0.5)/width;%sample of vec_C values from min to max |
---|
| 4099 | [colorlist,col_vec]=set_col_vec(colcode,vec_C); |
---|
| 4100 | oneheight=ones(1,height); |
---|
| 4101 | A1=colorlist(col_vec,1)*oneheight; |
---|
| 4102 | A2=colorlist(col_vec,2)*oneheight; |
---|
| 4103 | A3=colorlist(col_vec,3)*oneheight; |
---|
| 4104 | A(:,:,1)=A1'; |
---|
| 4105 | A(:,:,2)=A2'; |
---|
| 4106 | A(:,:,3)=A3'; |
---|
| 4107 | set(handles.VecColBar,'Cdata',A) |
---|
| 4108 | |
---|
| 4109 | %------------------------------------------------------------------- |
---|
| 4110 | function update_plot(handles) |
---|
| 4111 | %------------------------------------------------------------------- |
---|
| 4112 | UvData=get(handles.uvmat,'UserData'); |
---|
[511] | 4113 | AxeData=UvData.PlotAxes;% retrieve the current plotted data |
---|
[387] | 4114 | PlotParam=read_GUI(handles.uvmat); |
---|
[511] | 4115 | [tild,PlotParamOut]= plot_field(AxeData,handles.PlotAxes,PlotParam); |
---|
[595] | 4116 | errormsg=fill_GUI(PlotParamOut,handles.uvmat); |
---|
| 4117 | %write_plot_param(handles,PlotParamOut); %update the auto plot parameters |
---|
[387] | 4118 | |
---|
[402] | 4119 | %------------------------------------------------------------------------ |
---|
| 4120 | %------------------------------------------------------------------------ |
---|
| 4121 | % SELECTION AND EDITION OF PROJECTION OBJECTS |
---|
| 4122 | %------------------------------------------------------------------------ |
---|
| 4123 | %------------------------------------------------------------------------ |
---|
[387] | 4124 | |
---|
[410] | 4125 | % --- Executes on selection change in ListObject_1. |
---|
| 4126 | function ListObject_1_Callback(hObject, eventdata, handles) |
---|
[432] | 4127 | list_str=get(handles.ListObject,'String'); |
---|
[410] | 4128 | UvData=get(handles.uvmat,'UserData'); |
---|
[622] | 4129 | ObjectData=UvData.ProjObject{get(handles.ListObject_1,'Value')}; |
---|
[410] | 4130 | |
---|
| 4131 | %% update the projection plot on uvmat |
---|
[432] | 4132 | ProjData= proj_field(UvData.Field,ObjectData);%project the current input field on object ObjectData |
---|
[511] | 4133 | plot_field(ProjData,handles.PlotAxes,read_GUI(handles.uvmat));% plot the projected field; |
---|
[432] | 4134 | %replot all the objects within the new projected field |
---|
| 4135 | for IndexObj=1:numel(list_str) |
---|
[622] | 4136 | hobject=UvData.ProjObject{IndexObj}.DisplayHandle.uvmat; |
---|
[432] | 4137 | if isempty(hobject) || ~ishandle(hobject) |
---|
[515] | 4138 | hobject=handles.PlotAxes; |
---|
[432] | 4139 | end |
---|
| 4140 | if isequal(IndexObj,get(handles.ListObject,'Value')) |
---|
| 4141 | objectcolor='m'; %paint in magenta the currently selected object in ListObject |
---|
| 4142 | else |
---|
| 4143 | objectcolor='b'; |
---|
| 4144 | end |
---|
[622] | 4145 | UvData.ProjObject{IndexObj}.DisplayHandle.uvmat=plot_object(UvData.ProjObject{IndexObj},ObjectData,hobject,objectcolor);%draw the object in uvmat |
---|
[432] | 4146 | end |
---|
| 4147 | set(handles.uvmat,'UserData',UvData) |
---|
[410] | 4148 | |
---|
| 4149 | %% display the object parameters if the GUI set_object is already opened |
---|
[425] | 4150 | if ~get(handles.ViewObject,'Value') |
---|
[410] | 4151 | ZBounds=0; % default |
---|
| 4152 | if isfield(UvData.Field,'ZMin') && isfield(UvData.Field,'ZMax') |
---|
| 4153 | ZBounds(1)=UvData.Field.ZMin; %minimum for the Z slider |
---|
| 4154 | ZBounds(2)=UvData.Field.ZMax;%maximum for the Z slider |
---|
| 4155 | end |
---|
[425] | 4156 | ObjectData.Name=list_str{get(handles.ListObject_1,'Value')}; |
---|
[410] | 4157 | set_object(ObjectData,[],ZBounds); |
---|
[424] | 4158 | set(handles.ViewObject,'Value',1)% show that the selected object in ListObject_1 is currently visualised |
---|
[410] | 4159 | end |
---|
[432] | 4160 | |
---|
[410] | 4161 | % desactivate the edit object mode |
---|
| 4162 | set(handles.edit_object,'Value',0) |
---|
[623] | 4163 | % set(handles.edit_object,'BackgroundColor',[0.7,0.7,0.7]) |
---|
[410] | 4164 | |
---|
[387] | 4165 | %------------------------------------------------------------------------ |
---|
| 4166 | % --- Executes on selection change in ListObject. |
---|
| 4167 | function ListObject_Callback(hObject, eventdata, handles) |
---|
| 4168 | %------------------------------------------------------------------------ |
---|
| 4169 | list_str=get(handles.ListObject,'String'); |
---|
| 4170 | IndexObj=get(handles.ListObject,'Value');%present object selection |
---|
[402] | 4171 | UvData=get(handles.uvmat,'UserData'); |
---|
[622] | 4172 | ObjectData=UvData.ProjObject{IndexObj}; |
---|
[402] | 4173 | ZBounds=0; % default |
---|
| 4174 | if isfield(UvData.Field,'ZMin') && isfield(UvData.Field,'ZMax') |
---|
| 4175 | ZBounds(1)=UvData.Field.ZMin; %minimum for the Z slider |
---|
| 4176 | ZBounds(2)=UvData.Field.ZMax;%maximum for the Z slider |
---|
| 4177 | end |
---|
[625] | 4178 | |
---|
| 4179 | %% show object features if view_object isselected |
---|
| 4180 | if get(handles.ViewObject,'value') |
---|
[402] | 4181 | set_object(ObjectData,[],ZBounds); |
---|
| 4182 | end |
---|
[429] | 4183 | |
---|
[625] | 4184 | %% The object is displayed in set_object if this GUI is already opened |
---|
| 4185 | % |
---|
| 4186 | % hset_object=findobj(allchild(0),'tag','set_object'); |
---|
| 4187 | % if ~isempty(hset_object) |
---|
| 4188 | % |
---|
| 4189 | % ObjectData.Name=list_str{IndexObj}; |
---|
| 4190 | % set_object(ObjectData,[],ZBounds); |
---|
| 4191 | % set(handles.ViewField,'Value',1)% show that the selected object in ListObject is currently visualised |
---|
| 4192 | % end |
---|
| 4193 | |
---|
| 4194 | %% desactivate the edit object mode for security |
---|
[402] | 4195 | set(handles.edit_object,'Value',0) |
---|
[625] | 4196 | |
---|
[623] | 4197 | % set(handles.edit_object,'BackgroundColor',[0.7,0.7,0.7]) |
---|
[402] | 4198 | |
---|
[429] | 4199 | %% update the plot on view_field if view_field is already openened |
---|
| 4200 | hview_field=findobj(allchild(0),'tag','view_field'); |
---|
| 4201 | if isempty(hview_field) |
---|
[511] | 4202 | hhview_field.PlotAxes=[]; |
---|
[429] | 4203 | else |
---|
| 4204 | Data=get(hview_field,'UserData'); |
---|
| 4205 | hhview_field=guidata(hview_field); |
---|
| 4206 | ProjData= proj_field(UvData.Field,ObjectData);%project the current interface field on ObjectData |
---|
[595] | 4207 | [PlotType,PlotParam]=plot_field(ProjData,hhview_field.PlotAxes,read_GUI(hview_field));%read plotting parameters on the uvmat interface |
---|
| 4208 | |
---|
| 4209 | %write_plot_param(hhview_field,PlotParam); %update the display of plotting parameters for the current object |
---|
[429] | 4210 | haxes=findobj(hview_field,'tag','axes3'); |
---|
| 4211 | pos=get(hview_field,'Position'); |
---|
| 4212 | if strcmp(get(haxes,'Visible'),'off')%sempty(PlotParam.Coordinates)% case of no plot display (pure text table) |
---|
| 4213 | h_TableDisplay=findobj(hview_field,'tag','TableDisplay'); |
---|
| 4214 | pos_table=get(h_TableDisplay,'Position'); |
---|
| 4215 | set(hview_field,'Position',[pos(1)+pos(3)-pos_table(3) pos(2)+pos(4)-pos_table(4) pos_table(3) pos_table(4)]) |
---|
| 4216 | drawnow% needed to change position before the next command |
---|
| 4217 | set(hview_field,'UserData',Data);% restore the previously stored GUI position after GUI resizing |
---|
| 4218 | else |
---|
| 4219 | set(hview_field,'Position',Data.GUISize)% return to the previously stored GUI position and size |
---|
[387] | 4220 | end |
---|
| 4221 | end |
---|
| 4222 | |
---|
[402] | 4223 | %% update the color of the graphic object representation: the selected object in magenta, others in blue |
---|
[622] | 4224 | update_object_color(handles.PlotAxes,hhview_field.PlotAxes,UvData.ProjObject{IndexObj}.DisplayHandle.uvmat) |
---|
[387] | 4225 | |
---|
| 4226 | %------------------------------------------------------------------------ |
---|
[402] | 4227 | %--- update the color representation of objects (indicating the selected ones) |
---|
| 4228 | function update_object_color(axes_uvmat,axes_view_field,DisplayHandle) |
---|
[387] | 4229 | %------------------------------------------------------------------------ |
---|
[402] | 4230 | if isempty(axes_view_field)% case with no view_field plot |
---|
| 4231 | hother=[findobj(axes_uvmat,'Tag','proj_object');findobj(axes_uvmat,'Tag','DeformPoint')];%find all the proj object and deform point representations |
---|
[387] | 4232 | else |
---|
[402] | 4233 | hother=[findobj(axes_uvmat,'Tag','proj_object') ;findobj(axes_view_field,'Tag','proj_object');... %find all the proj object representations |
---|
| 4234 | findobj(axes_uvmat,'Tag','DeformPoint'); findobj(axes_view_field,'Tag','DeformPoint')];%find all the deform point representations |
---|
[387] | 4235 | end |
---|
| 4236 | for iobj=1:length(hother) |
---|
| 4237 | if isequal(get(hother(iobj),'Type'),'rectangle')||isequal(get(hother(iobj),'Type'),'patch') |
---|
| 4238 | set(hother(iobj),'EdgeColor','b') |
---|
| 4239 | if isequal(get(hother(iobj),'FaceColor'),'m') |
---|
| 4240 | set(hother(iobj),'FaceColor','b') |
---|
| 4241 | end |
---|
| 4242 | elseif isequal(get(hother(iobj),'Type'),'image') |
---|
| 4243 | Acolor=get(hother(iobj),'CData'); |
---|
| 4244 | Acolor(:,:,1)=zeros(size(Acolor,1),size(Acolor,2)); |
---|
| 4245 | set(hother(iobj),'CData',Acolor); |
---|
| 4246 | else |
---|
| 4247 | set(hother(iobj),'Color','b') |
---|
| 4248 | end |
---|
| 4249 | set(hother(iobj),'Selected','off') |
---|
| 4250 | end |
---|
[432] | 4251 | if ishandle(DisplayHandle) |
---|
[402] | 4252 | linetype=get(DisplayHandle,'Type'); |
---|
| 4253 | if isequal(linetype,'line') |
---|
| 4254 | set(DisplayHandle,'Color','m'); %set the selected object to magenta color |
---|
| 4255 | elseif isequal(linetype,'rectangle') |
---|
| 4256 | set(DisplayHandle,'EdgeColor','m'); %set the selected object to magenta color |
---|
| 4257 | elseif isequal(linetype,'patch') |
---|
| 4258 | set(DisplayHandle,'FaceColor','m'); %set the selected object to magenta color |
---|
| 4259 | end |
---|
| 4260 | SubObjectData=get(DisplayHandle,'UserData'); |
---|
| 4261 | if isfield(SubObjectData,'SubObject') & ishandle(SubObjectData.SubObject) |
---|
| 4262 | for iobj=1:length(SubObjectData.SubObject) |
---|
| 4263 | hsub=SubObjectData.SubObject(iobj); |
---|
| 4264 | if isequal(get(hsub,'Type'),'rectangle') |
---|
| 4265 | set(hsub,'EdgeColor','m'); %set the selected object to magenta color |
---|
| 4266 | elseif isequal(get(hsub,'Type'),'image') |
---|
| 4267 | Acolor=get(hsub,'CData'); |
---|
| 4268 | Acolor(:,:,1)=Acolor(:,:,3); |
---|
| 4269 | set(hsub,'CData',Acolor); |
---|
| 4270 | else |
---|
| 4271 | set(hsub,'Color','m') |
---|
| 4272 | end |
---|
[387] | 4273 | end |
---|
| 4274 | end |
---|
[402] | 4275 | if isfield(SubObjectData,'DeformPoint') & ishandle(SubObjectData.DeformPoint) |
---|
| 4276 | set(SubObjectData.DeformPoint,'Color','m') |
---|
| 4277 | end |
---|
[387] | 4278 | end |
---|
[402] | 4279 | |
---|
[427] | 4280 | %------------------------------------------------------------------- |
---|
| 4281 | % --- Executes on selection change in edit_object. |
---|
| 4282 | function edit_object_Callback(hObject, eventdata, handles) |
---|
| 4283 | %------------------------------------------------------------------- |
---|
| 4284 | hset_object=findobj(allchild(0),'Tag','set_object'); |
---|
[625] | 4285 | if get(handles.edit_object,'Value') |
---|
[427] | 4286 | %suppress the other options |
---|
| 4287 | set(handles.CheckZoom,'Value',0) |
---|
| 4288 | CheckZoom_Callback(hObject, eventdata, handles) |
---|
| 4289 | hgeometry_calib=findobj(allchild(0),'tag','geometry_calib'); |
---|
| 4290 | if ishandle(hgeometry_calib) |
---|
| 4291 | hhgeometry_calib=guidata(hgeometry_calib); |
---|
| 4292 | set(hhgeometry_calib.edit_append,'Value',0)% desactivate mouse action in geometry_calib |
---|
| 4293 | end |
---|
| 4294 | set(handles.ViewObject,'value',1) |
---|
| 4295 | ViewObject_Callback(hObject, eventdata, handles) |
---|
[625] | 4296 | else % desactivate object edit mode |
---|
[427] | 4297 | if ~isempty(hset_object)% open the |
---|
[625] | 4298 | set(get(hset_object,'children'),'Enable','off') |
---|
| 4299 | hSAVE=findobj(hset_object,'Tag','SAVE'); |
---|
| 4300 | set(hSAVE,'Enable','on') |
---|
[427] | 4301 | end |
---|
| 4302 | end |
---|
| 4303 | |
---|
| 4304 | |
---|
[402] | 4305 | %------------------------------------------------------------------------ |
---|
[424] | 4306 | % --- Executes on button press in ViewObject. |
---|
| 4307 | function ViewObject_Callback(hObject, eventdata, handles) |
---|
[410] | 4308 | %------------------------------------------------------------------------ |
---|
[424] | 4309 | check_view=get(handles.ViewObject,'Value'); |
---|
[410] | 4310 | |
---|
| 4311 | if check_view %activate set_object |
---|
[424] | 4312 | IndexObj=get(handles.ListObject,'Value'); |
---|
| 4313 | list_object=get(handles.ListObject,'String'); |
---|
[410] | 4314 | UvData=get(handles.uvmat,'UserData');%read UvData properties stored on the uvmat interface |
---|
[622] | 4315 | UvData.ProjObject{IndexObj}.Name=list_object{IndexObj}; |
---|
| 4316 | if numel(UvData.ProjObject)<IndexObj;% error in UvData |
---|
[410] | 4317 | msgbox_uvmat('ERROR','invalid object list') |
---|
| 4318 | return |
---|
| 4319 | end |
---|
| 4320 | ZBounds=0; % default |
---|
| 4321 | if isfield(UvData.Field,'ZMin') && isfield(UvData.Field,'ZMax') |
---|
| 4322 | ZBounds(1)=UvData.Field.ZMin; %minimum for the Z slider |
---|
| 4323 | ZBounds(2)=UvData.Field.ZMax;%maximum for the Z slider |
---|
| 4324 | end |
---|
[622] | 4325 | data=UvData.ProjObject{IndexObj}; |
---|
[410] | 4326 | if ~isfield(data,'Type')% default plane |
---|
| 4327 | data.Type='plane'; |
---|
| 4328 | end |
---|
| 4329 | hset_object=set_object(data,[],ZBounds); |
---|
| 4330 | hhset_object=guidata(hset_object); |
---|
| 4331 | if get(handles.edit_object,'Value')% edit mode |
---|
[625] | 4332 | set(get(hset_object,'children'),'Enable','on') |
---|
[410] | 4333 | else |
---|
[625] | 4334 | set(get(hset_object,'children'),'Enable','off')% deactivate the GUI except SAVE |
---|
[427] | 4335 | set(hhset_object.SAVE,'Enable','on') |
---|
[410] | 4336 | end |
---|
| 4337 | else |
---|
| 4338 | hset_object=findobj(allchild(0),'tag','set_object'); |
---|
| 4339 | if ~isempty(hset_object) |
---|
| 4340 | delete(hset_object)% delete existing version of set_object |
---|
| 4341 | end |
---|
| 4342 | end |
---|
| 4343 | |
---|
[424] | 4344 | |
---|
[410] | 4345 | %------------------------------------------------------------------------ |
---|
[424] | 4346 | % --- Executes on button press in ViewField. |
---|
| 4347 | function ViewField_Callback(hObject, eventdata, handles) |
---|
[402] | 4348 | %------------------------------------------------------------------------ |
---|
[424] | 4349 | check_view=get(handles.ViewField,'Value'); |
---|
[387] | 4350 | |
---|
[410] | 4351 | if check_view |
---|
| 4352 | IndexObj=get(handles.ListObject,'Value'); |
---|
| 4353 | UvData=get(handles.uvmat,'UserData');%read UvData properties stored on the uvmat interface |
---|
[622] | 4354 | if numel(UvData.ProjObject)<IndexObj(end);% error in UvData |
---|
[410] | 4355 | msgbox_uvmat('ERROR','invalid object list') |
---|
| 4356 | return |
---|
| 4357 | end |
---|
| 4358 | ZBounds=0; % default |
---|
| 4359 | if isfield(UvData.Field,'ZMin') && isfield(UvData.Field,'ZMax') |
---|
| 4360 | ZBounds(1)=UvData.Field.ZMin; %minimum for the Z slider |
---|
| 4361 | ZBounds(2)=UvData.Field.ZMax;%maximum for the Z slider |
---|
| 4362 | end |
---|
| 4363 | set(handles.ListObject,'Value',IndexObj);%restore ListObject selection after set_object deletion |
---|
[622] | 4364 | if ~isfield(UvData.ProjObject{IndexObj(1)},'Type')% default plane |
---|
| 4365 | UvData.ProjObject{IndexObj(1)}.Type='plane'; |
---|
[410] | 4366 | end |
---|
| 4367 | list_object=get(handles.ListObject,'String'); |
---|
[622] | 4368 | UvData.ProjObject{IndexObj(end)}.Name=list_object{IndexObj(end)}; |
---|
[410] | 4369 | |
---|
[429] | 4370 | %% show the projection of the selected object on view_field |
---|
[622] | 4371 | ProjData= proj_field(UvData.Field,UvData.ProjObject{IndexObj});%project the current field on ObjectData |
---|
[402] | 4372 | hview_field=findobj(allchild(0),'tag','view_field'); |
---|
| 4373 | if isempty(hview_field) |
---|
| 4374 | hview_field=view_field; |
---|
| 4375 | end |
---|
[429] | 4376 | hhview_field=guidata(hview_field); |
---|
[511] | 4377 | [PlotType,PlotParam]=plot_field(ProjData,hhview_field.PlotAxes,read_GUI(hview_field));%read plotting parameters on the GUI view_field); |
---|
[595] | 4378 | errormsg=fill_GUI(PlotParam,hview_field); |
---|
[609] | 4379 | for list={'Scalar','Vectors'} |
---|
| 4380 | if ~isfield(PlotParam,list{1}) |
---|
| 4381 | set(hhview_field.(list{1}),'Visible','off') |
---|
| 4382 | end |
---|
| 4383 | end |
---|
[595] | 4384 | %write_plot_param(hhview_field,PlotParam); %update the display of plotting parameters for the current object |
---|
[429] | 4385 | haxes=findobj(hview_field,'tag','axes3'); |
---|
| 4386 | pos=get(hview_field,'Position'); |
---|
| 4387 | if strcmp(get(haxes,'Visible'),'off')%sempty(PlotParam.Coordinates)% case of no plot display (pure text table) |
---|
| 4388 | h_TableDisplay=findobj(hview_field,'tag','TableDisplay'); |
---|
| 4389 | pos_table=get(h_TableDisplay,'Position'); |
---|
| 4390 | set(hview_field,'Position',[pos(1)+pos(3)-pos_table(3) pos(2)+pos(4)-pos_table(4) pos_table(3) pos_table(4)]) |
---|
| 4391 | else |
---|
| 4392 | Data=get(hview_field,'UserData'); |
---|
[432] | 4393 | set(hview_field,'Position',Data.GUISize)% restore the size of view_field for plots |
---|
[429] | 4394 | end |
---|
[410] | 4395 | else |
---|
[424] | 4396 | hview_field=findobj(allchild(0),'tag','view_field'); |
---|
| 4397 | if ~isempty(hview_field) |
---|
| 4398 | delete(hview_field)% delete existing version of set_object |
---|
[410] | 4399 | end |
---|
[402] | 4400 | end |
---|
| 4401 | |
---|
[424] | 4402 | |
---|
[402] | 4403 | %------------------------------------------------------------------------ |
---|
| 4404 | % --- Executes on button press in delete_object. |
---|
[622] | 4405 | %------------------------------------------------------------------------ |
---|
[402] | 4406 | function delete_object_Callback(hObject, eventdata, handles) |
---|
[622] | 4407 | |
---|
[499] | 4408 | IndexObj=get(handles.ListObject,'Value');%projection object selected for view_field |
---|
| 4409 | IndexObj_1=get(handles.ListObject_1,'Value');%projection object selected for uvmat plot |
---|
| 4410 | if IndexObj>1 && ~isequal(IndexObj,IndexObj_1) % do not delete the object used for the uvmat plot |
---|
[410] | 4411 | delete_object(IndexObj) |
---|
[402] | 4412 | end |
---|
| 4413 | |
---|
[622] | 4414 | %'delete_object': delete a projection object, defined by its index in the Uvmat list or by its graphic handle |
---|
[402] | 4415 | %------------------------------------------------------------------------ |
---|
[622] | 4416 | % function delete_object(hObject) |
---|
| 4417 | % |
---|
| 4418 | % INPUT: |
---|
| 4419 | % hObject: object index (if integer) or handle of the graphic object. If |
---|
| 4420 | % hObject is a subobject, the parent object is detected and deleted. |
---|
| 4421 | |
---|
| 4422 | function delete_object(IndexObj) |
---|
| 4423 | |
---|
| 4424 | huvmat=findobj('tag','uvmat');%handles of the uvmat interface |
---|
| 4425 | UvData=get(huvmat,'UserData'); |
---|
| 4426 | hlist_object=findobj(huvmat,'Tag','ListObject');%handles of the object list in the uvmat interface |
---|
| 4427 | list_str=get(hlist_object,'String');%objet list |
---|
| 4428 | % if isequal(floor(hObject),hObject) %case of an index |
---|
| 4429 | if ~isempty(UvData) && isfield(UvData, 'ProjObject') && length(UvData.ProjObject)>=IndexObj |
---|
| 4430 | if isfield(UvData.ProjObject{IndexObj},'DisplayHandle') && isfield(UvData.ProjObject{IndexObj}.DisplayHandle,'uvmat') |
---|
| 4431 | hdisplay=UvData.ProjObject{IndexObj}.DisplayHandle.uvmat; |
---|
| 4432 | for iview=1:length(hdisplay) |
---|
| 4433 | if ishandle(hdisplay(iview)) && ~isequal(hdisplay(iview),0) |
---|
| 4434 | ObjectData=get(hdisplay(iview),'UserData'); |
---|
| 4435 | if isfield(ObjectData,'SubObject') & ishandle(ObjectData.SubObject) |
---|
| 4436 | delete(ObjectData.SubObject); |
---|
| 4437 | end |
---|
| 4438 | if isfield(ObjectData,'DeformPoint') & ishandle(ObjectData.DeformPoint) |
---|
| 4439 | delete(ObjectData.DeformPoint); |
---|
| 4440 | end |
---|
| 4441 | delete(hdisplay(iview)) |
---|
| 4442 | end |
---|
| 4443 | ishandle(hdisplay(iview)) |
---|
| 4444 | end |
---|
| 4445 | for iobj=IndexObj+1:length(UvData.ProjObject) |
---|
| 4446 | hdisplay=UvData.ProjObject{iobj}.DisplayHandle.uvmat; |
---|
| 4447 | for iview=1:length(hdisplay) |
---|
| 4448 | if ishandle(hdisplay(iview)) && ~isequal(hdisplay(iview),0) |
---|
| 4449 | PlotData=get(hdisplay(iview),'UserData'); |
---|
| 4450 | PlotData.IndexObj=iobj-1; |
---|
| 4451 | set(hdisplay(iview),'UserData',PlotData); |
---|
| 4452 | end |
---|
| 4453 | end |
---|
| 4454 | end |
---|
| 4455 | end |
---|
| 4456 | UvData.ProjObject(IndexObj)=[]; |
---|
| 4457 | if ~isempty(list_str) |
---|
| 4458 | list_str(IndexObj)=[]; |
---|
| 4459 | end |
---|
| 4460 | end |
---|
| 4461 | % elseif ishandle(hObject)%object handle |
---|
| 4462 | % userdata=get(hObject,'UserData'); |
---|
| 4463 | % if ishandle(userdata)%the selected line depends on a parent line |
---|
| 4464 | % hdisplay=userdata;% the parent object becomes the current one |
---|
| 4465 | % else |
---|
| 4466 | % hdisplay=hObject;% the selected object becomes the current one |
---|
| 4467 | % end |
---|
| 4468 | % PlotData=get(hdisplay,'UserData'); |
---|
| 4469 | % if isfield(PlotData,'SubObject') & ishandle(PlotData.SubObject) |
---|
| 4470 | % delete(PlotData.SubObject); |
---|
| 4471 | % end |
---|
| 4472 | % if isfield(PlotData,'DeformPoint') & ishandle(PlotData.DeformPoint) |
---|
| 4473 | % delete(PlotData.DeformPoint); |
---|
| 4474 | % end |
---|
| 4475 | % delete(hdisplay); |
---|
| 4476 | % if isfield(PlotData,'IndexObj') |
---|
| 4477 | % IndexObj=PlotData.IndexObj; |
---|
| 4478 | % if isequal(round(IndexObj),IndexObj) & IndexObj>=1 & length(list_str) > IndexObj |
---|
| 4479 | % if isfield(UvData,'ProjObject')& length(UvData.ProjObject) > IndexObj |
---|
| 4480 | % UvData.ProjObject(IndexObj)=[]; |
---|
| 4481 | % end |
---|
| 4482 | % list_str(IndexObj)=[]; |
---|
| 4483 | % end |
---|
| 4484 | % end |
---|
| 4485 | % end |
---|
| 4486 | set(huvmat,'UserData',UvData); |
---|
| 4487 | set(hlist_object,'String',list_str) |
---|
| 4488 | set(hlist_object,'Value',length(list_str)) |
---|
| 4489 | hlist_object_1=findobj(huvmat,'Tag','ListObject_1');%handles of the first object list in the uvmat interface |
---|
| 4490 | old_index=get(hlist_object_1,'Value'); |
---|
| 4491 | set(hlist_object_1,'String',list_str) |
---|
| 4492 | if IndexObj<=old_index |
---|
| 4493 | set(hlist_object_1,'Value',old_index-1) |
---|
| 4494 | end |
---|
| 4495 | |
---|
[402] | 4496 | %------------------------------------------------------------------------ |
---|
[622] | 4497 | %------------------------------------------------------------------------ |
---|
[402] | 4498 | % II - TOOLS FROM THE UPPER MENU BAR |
---|
| 4499 | %------------------------------------------------------------------------ |
---|
| 4500 | %------------------------------------------------------------------------ |
---|
| 4501 | |
---|
| 4502 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
---|
| 4503 | % Export Menu Callbacks |
---|
| 4504 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
---|
| 4505 | %------------------------------------------------------------------------ |
---|
[387] | 4506 | % --- Executes on button press in Menu/Export/field in workspace. |
---|
| 4507 | function MenuExportField_Callback(hObject, eventdata, handles) |
---|
[402] | 4508 | %------------------------------------------------------------------------ |
---|
[387] | 4509 | global Data_uvmat |
---|
| 4510 | Data_uvmat=get(handles.uvmat,'UserData'); |
---|
| 4511 | evalin('base','global Data_uvmat')%make CurData global in the workspace |
---|
| 4512 | display('current field :') |
---|
| 4513 | evalin('base','Data_uvmat') %display CurData in the workspace |
---|
| 4514 | commandwindow; %brings the Matlab command window to the front |
---|
| 4515 | |
---|
[402] | 4516 | %------------------------------------------------------------------------ |
---|
[387] | 4517 | % --- Executes on button press in Menu/Export/extract figure. |
---|
[402] | 4518 | function MenuExportFigure_Callback(hObject, eventdata, handles) |
---|
| 4519 | %------------------------------------------------------------------------ |
---|
| 4520 | % huvmat=get(handles.MenuExport,'parent'); |
---|
[387] | 4521 | hfig=figure; |
---|
[511] | 4522 | copyobj(handles.PlotAxes,hfig); |
---|
| 4523 | map=colormap(handles.PlotAxes); |
---|
[387] | 4524 | colormap(map);%transmit the current colormap to the zoom fig |
---|
| 4525 | colorbar |
---|
| 4526 | |
---|
[508] | 4527 | % -------------------------------------------------------------------- |
---|
| 4528 | function MenuExportAxis_Callback(hObject, eventdata, handles) |
---|
[581] | 4529 | ListFig=findobj(allchild(0),'Type','figure'); |
---|
| 4530 | nb_option=0; |
---|
| 4531 | menu={}; |
---|
| 4532 | for ilist=1:numel(ListFig) |
---|
| 4533 | FigName=get(ListFig(ilist),'name'); |
---|
| 4534 | if isempty(FigName) |
---|
| 4535 | FigName=['figure ' num2str(ListFig(ilist))]; |
---|
| 4536 | end |
---|
| 4537 | if ~strcmp(FigName,'uvmat') |
---|
| 4538 | ListAxes=findobj(ListFig(ilist),'Type','axes'); |
---|
| 4539 | ListTags=get(ListAxes,'Tag'); |
---|
| 4540 | if ~isempty(ListTags) && ~isempty(find(~strcmp('Colorbar',ListTags), 1)) |
---|
| 4541 | ListAxes=ListAxes(~strcmp('Colorbar',ListTags)); |
---|
| 4542 | if numel(ListAxes)==1 |
---|
| 4543 | nb_option=nb_option+1; |
---|
| 4544 | menu{nb_option}=FigName ; |
---|
| 4545 | AxesHandle(nb_option)=ListAxes; |
---|
| 4546 | else |
---|
| 4547 | nb_axis=0; |
---|
| 4548 | for iaxes=1:numel(ListAxes) |
---|
| 4549 | nb_axis=nb_axis+1; |
---|
| 4550 | nb_option=nb_option+1; |
---|
| 4551 | menu{nb_option}=[FigName '_' num2str(nb_axis)]; |
---|
| 4552 | AxesHandle(nb_option)=ListAxes(nb_axis); |
---|
| 4553 | end |
---|
| 4554 | end |
---|
| 4555 | end |
---|
| 4556 | end |
---|
[508] | 4557 | end |
---|
[581] | 4558 | if isempty(menu) |
---|
| 4559 | answer=msgbox_uvmat('INPUT_Y-N','no existing plotting axes available, create new figure?'); |
---|
| 4560 | if strcmp(answer,'Yes') |
---|
| 4561 | hfig=figure; |
---|
| 4562 | copyobj(handles.PlotAxes,hfig); |
---|
| 4563 | else |
---|
| 4564 | return |
---|
| 4565 | end |
---|
| 4566 | map=colormap(handles.PlotAxes); |
---|
| 4567 | colormap(map);%transmit the current colormap to the zoom fig |
---|
| 4568 | colorbar |
---|
| 4569 | else |
---|
| 4570 | answer=msgbox_uvmat('INPUT_MENU','select a figure/axis on which the current uvmat plot will be exported',menu); |
---|
| 4571 | if isempty(answer) |
---|
| 4572 | return |
---|
| 4573 | else |
---|
| 4574 | axes(AxesHandle(answer)) |
---|
| 4575 | hold on |
---|
| 4576 | hchild=get(handles.PlotAxes,'children'); |
---|
| 4577 | copyobj(hchild,gca); |
---|
| 4578 | end |
---|
| 4579 | end |
---|
[387] | 4580 | |
---|
[581] | 4581 | |
---|
[387] | 4582 | %------------------------------------------------------------------------ |
---|
| 4583 | % -------------------------------------------------------------------- |
---|
| 4584 | function MenuExportMovie_Callback(hObject, eventdata, handles) |
---|
| 4585 | % -------------------------------------------------------------------- |
---|
| 4586 | set(handles.MenuExportMovie,'BusyAction','queue')% activate the button |
---|
| 4587 | huvmat=get(handles.run0,'parent'); |
---|
| 4588 | UvData=get(huvmat,'UserData'); |
---|
| 4589 | %[xx,xx,FileBase]=read_file_boxes(handles); |
---|
[515] | 4590 | [RootPath,SubDir,RootFile,FileIndex,FileExt]=read_file_boxes(handles); |
---|
[387] | 4591 | FileBase=fullfile(RootPath,RootFile); |
---|
| 4592 | %read the current input file name |
---|
| 4593 | 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)'}; |
---|
| 4594 | dlg_title = 'select properties of the output avi movie'; |
---|
| 4595 | num_lines= 1; |
---|
| 4596 | def = {[FileBase '_out.avi'];'10';'1';'[0.03 0.05 0.95 0.92]';'10'}; |
---|
| 4597 | answer = inputdlg(prompt,dlg_title,num_lines,def,'on'); |
---|
| 4598 | aviname=answer{1}; |
---|
| 4599 | fps=str2double(answer{2}); |
---|
| 4600 | % check for existing file with output name aviname |
---|
| 4601 | if exist(aviname,'file') |
---|
| 4602 | backup=aviname; |
---|
| 4603 | testexist=2; |
---|
| 4604 | while testexist==2 |
---|
| 4605 | backup=[backup '~']; |
---|
| 4606 | testexist=exist(backup,'file'); |
---|
| 4607 | end |
---|
| 4608 | [success,message]=copyfile(aviname,backup);%make backup of the existing file |
---|
| 4609 | if isequal(success,1) |
---|
| 4610 | delete(aviname)%delete existing file |
---|
| 4611 | else |
---|
| 4612 | msgbox_uvmat('ERROR',message) |
---|
| 4613 | return |
---|
| 4614 | end |
---|
| 4615 | end |
---|
| 4616 | %create avi open |
---|
| 4617 | aviobj=avifile(aviname,'Compression','None','fps',fps); |
---|
| 4618 | |
---|
| 4619 | %display first view for tests |
---|
| 4620 | newfig=figure; |
---|
[511] | 4621 | newaxes=copyobj(handles.PlotAxes,newfig);%new plotting axes in the new figure |
---|
[387] | 4622 | set(newaxes,'Tag','movieaxes') |
---|
| 4623 | nbpix=[512 384]*str2double(answer{3}); |
---|
| 4624 | set(gcf,'Position',[1 1 nbpix])% resolution XVGA |
---|
| 4625 | set(newaxes,'Position',eval(answer{4})); |
---|
[511] | 4626 | map=colormap(handles.PlotAxes); |
---|
[387] | 4627 | colormap(map);%transmit the current colormap to the zoom fig |
---|
| 4628 | msgbox_uvmat('INPUT_Y-N',{['adjust figure ' num2str(newfig) ' with its matlab edit menu '] ;... |
---|
| 4629 | ['then press OK to get the avi movie as a copy of figure ' num2str(newfig) ' display']}); |
---|
| 4630 | UvData.plotaxes=newaxes;% the axis in the new figure becomes the current main plotting axes |
---|
| 4631 | set(huvmat,'UserData',UvData); |
---|
[511] | 4632 | increment=str2num(get(handles.num_IndexIncrement,'String')); %get the field increment d |
---|
[387] | 4633 | set(handles.STOP,'Visible','on') |
---|
| 4634 | set(handles.speed,'Visible','on') |
---|
| 4635 | set(handles.speed_txt,'Visible','on') |
---|
| 4636 | set(handles.Movie,'BusyAction','queue') |
---|
| 4637 | |
---|
| 4638 | %imin=str2double(get(handles.i1,'String')); |
---|
| 4639 | imax=str2double(answer{5}); |
---|
| 4640 | % if isfield(UvData,'Time') |
---|
| 4641 | htitle=get(newaxes,'Title'); |
---|
| 4642 | xlim=get(newaxes,'XLim'); |
---|
| 4643 | ylim=get(newaxes,'YLim'); |
---|
| 4644 | set(htitle,'Position',[xlim(2)+0.07*(xlim(2)-xlim(1)) ylim(2)-0.05*(ylim(2)-ylim(1)) 0]) |
---|
| 4645 | time_str=get(handles.abs_time,'String'); |
---|
| 4646 | set(htitle,'String',['t=' time_str]) |
---|
| 4647 | set(handles.speed,'Value',1) |
---|
| 4648 | for i=1:imax |
---|
| 4649 | if get(handles.speed,'Value')~=0 && isequal(get(handles.MenuExportMovie,'BusyAction'),'queue') % enable STOP command |
---|
| 4650 | runpm(hObject,eventdata,handles,increment)% run plus |
---|
| 4651 | drawnow |
---|
| 4652 | time_str=get(handles.abs_time,'String'); |
---|
| 4653 | if ishandle(htitle) |
---|
| 4654 | set(htitle,'String',['t=' time_str]) |
---|
| 4655 | end |
---|
| 4656 | mov=getframe(newfig); |
---|
| 4657 | aviobj=addframe(aviobj,mov); |
---|
| 4658 | end |
---|
| 4659 | end |
---|
| 4660 | aviobj=close(aviobj); |
---|
| 4661 | UvData=rmfield(UvData,'plotaxes'); |
---|
| 4662 | set(huvmat,'UserData',UvData); |
---|
| 4663 | msgbox_uvmat('CONFIRMATION',{['movie ' aviname ' created '];['with ' num2str(imax) ' frames']}) |
---|
| 4664 | |
---|
[402] | 4665 | |
---|
| 4666 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
---|
| 4667 | % Projection Objects Menu Callbacks |
---|
| 4668 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
---|
| 4669 | |
---|
| 4670 | % ----------------------------------------------------------------------- |
---|
| 4671 | function Menupoints_Callback(hObject, eventdata, handles) |
---|
[387] | 4672 | %------------------------------------------------------------------------ |
---|
[402] | 4673 | data.Type='points'; |
---|
| 4674 | data.ProjMode='projection';%default |
---|
[410] | 4675 | data.ProjModeMenu={};% do not restrict ProjMode menus |
---|
[402] | 4676 | create_object(data,handles) |
---|
| 4677 | |
---|
| 4678 | % ----------------------------------------------------------------------- |
---|
| 4679 | function Menuline_Callback(hObject, eventdata, handles) |
---|
| 4680 | %------------------------------------------------------------------------ |
---|
| 4681 | data.Type='line'; |
---|
| 4682 | data.ProjMode='projection';%default |
---|
[410] | 4683 | data.ProjModeMenu={};% do not restrict ProjMode menus |
---|
[402] | 4684 | create_object(data,handles) |
---|
| 4685 | |
---|
| 4686 | %------------------------------------------------------------------------ |
---|
| 4687 | function Menupolyline_Callback(hObject, eventdata, handles) |
---|
| 4688 | %------------------------------------------------------------------------ |
---|
| 4689 | data.Type='polyline'; |
---|
| 4690 | data.ProjMode='projection';%default |
---|
[410] | 4691 | data.ProjModeMenu={};% do not restrict ProjMode menus |
---|
[402] | 4692 | create_object(data,handles) |
---|
| 4693 | |
---|
| 4694 | %------------------------------------------------------------------------ |
---|
| 4695 | function Menupolygon_Callback(hObject, eventdata, handles) |
---|
| 4696 | %------------------------------------------------------------------------ |
---|
| 4697 | data.Type='polygon'; |
---|
| 4698 | data.ProjMode='inside';%default |
---|
[410] | 4699 | data.ProjModeMenu={};% do not restrict ProjMode menus |
---|
[402] | 4700 | create_object(data,handles) |
---|
| 4701 | |
---|
| 4702 | %------------------------------------------------------------------------ |
---|
| 4703 | function Menurectangle_Callback(hObject, eventdata, handles) |
---|
| 4704 | %------------------------------------------------------------------------ |
---|
| 4705 | data.Type='rectangle'; |
---|
| 4706 | data.ProjMode='inside';%default |
---|
[410] | 4707 | data.ProjModeMenu={};% do not restrict ProjMode menus |
---|
[402] | 4708 | create_object(data,handles) |
---|
| 4709 | |
---|
| 4710 | %------------------------------------------------------------------------ |
---|
| 4711 | function Menuellipse_Callback(hObject, eventdata, handles) |
---|
| 4712 | %------------------------------------------------------------------------ |
---|
| 4713 | data.Type='ellipse'; |
---|
| 4714 | data.ProjMode='inside';%default |
---|
[410] | 4715 | data.ProjModeMenu={};% do not restrict ProjMode menus |
---|
[402] | 4716 | create_object(data,handles) |
---|
| 4717 | |
---|
| 4718 | %------------------------------------------------------------------------ |
---|
| 4719 | function MenuMaskObject_Callback(hObject, eventdata, handles) |
---|
| 4720 | %------------------------------------------------------------------------ |
---|
| 4721 | data.Type='polygon'; |
---|
| 4722 | data.TypeMenu={'polygon'}; |
---|
| 4723 | data.ProjMode='mask_inside';%default |
---|
| 4724 | data.ProjModeMenu={'mask_inside';'mask_outside'}; |
---|
| 4725 | create_object(data,handles) |
---|
| 4726 | |
---|
| 4727 | %------------------------------------------------------------------------ |
---|
| 4728 | function Menuplane_Callback(hObject, eventdata, handles) |
---|
| 4729 | %------------------------------------------------------------------------ |
---|
| 4730 | data.Type='plane'; |
---|
| 4731 | data.ProjMode='projection';%default |
---|
[410] | 4732 | data.ProjModeMenu={};% do not restrict ProjMode menus |
---|
[402] | 4733 | create_object(data,handles) |
---|
| 4734 | |
---|
| 4735 | %------------------------------------------------------------------------ |
---|
| 4736 | function Menuvolume_Callback(hObject, eventdata, handles) |
---|
| 4737 | %------------------------------------------------------------------------ |
---|
| 4738 | data.Type='volume'; |
---|
[581] | 4739 | data.ProjMode='interp_lin';%default |
---|
[410] | 4740 | data.ProjModeMenu={}; |
---|
[402] | 4741 | % set(handles.create,'Visible','on') |
---|
| 4742 | % set(handles.create,'Value',1) |
---|
[410] | 4743 | % VOLUME_Callback(hObject,eventdata,handles)data.ProjModeMenu={}; |
---|
[402] | 4744 | create_object(data,handles) |
---|
| 4745 | |
---|
| 4746 | %------------------------------------------------------------------------ |
---|
| 4747 | % --- generic function used for the creation of a projection object |
---|
| 4748 | function create_object(data,handles) |
---|
| 4749 | %------------------------------------------------------------------------ |
---|
[622] | 4750 | %% desactivate concurrent tools |
---|
| 4751 | hgeometry_calib=findobj(allchild(0),'tag','geometry_calib');% search the GUI geometric calibration |
---|
[402] | 4752 | if ishandle(hgeometry_calib) |
---|
| 4753 | hhgeometry_calib=guidata(hgeometry_calib); |
---|
| 4754 | set(hhgeometry_calib.edit_append,'Value',0)% desactivate mouse action in geometry_calib |
---|
| 4755 | end |
---|
[622] | 4756 | set(handles.edit_object,'Value',0) %desactivate the object edit mode |
---|
[625] | 4757 | edit_object_Callback([],[],handles) |
---|
| 4758 | set(handles.ViewObject,'Value',0) % desactivate view_object (new object created) |
---|
[622] | 4759 | set(handles.CheckZoomFig,'Value',0) %desactivate zoom sub fig |
---|
| 4760 | set(handles.CheckZoom,'Value',0) %desactivate the zoom action |
---|
| 4761 | if ishandle(handles.UVMAT_title) |
---|
| 4762 | delete(handles.UVMAT_title) %delete the initial display of uvmat if no field has been entered yet |
---|
| 4763 | end |
---|
| 4764 | |
---|
[625] | 4765 | %% append a new line to the list of projection objects A METTRE PLUS TARD |
---|
| 4766 | % ListObject=get(handles.ListObject,'String'); |
---|
| 4767 | % if isempty(ListObject) |
---|
| 4768 | % ListObject={''}; |
---|
| 4769 | % end |
---|
| 4770 | % if ~strcmp(ListObject{end},'') |
---|
| 4771 | % ListObject=[ListObject;{''}]; %append a blank to the list (if nort already done) to indicate the creation of a new object |
---|
| 4772 | % set(handles.ListObject,'String',ListObject) |
---|
| 4773 | % end |
---|
| 4774 | % IndexObj=length(ListObject); |
---|
| 4775 | % set(handles.ListObject,'Value',IndexObj) |
---|
[410] | 4776 | UvData=get(handles.uvmat,'UserData'); |
---|
[625] | 4777 | % UvData.ProjObject{IndexObj}=[]; %create a new empty object |
---|
| 4778 | % UvData.ProjObject{IndexObj}.DisplayHandle.uvmat=handles.PlotAxes; % axes for plot_object |
---|
| 4779 | % UvData.ProjObject{IndexObj}.DisplayHandle.view_field=[]; %no plot handle before plot_field operation |
---|
| 4780 | % set(handles.uvmat,'UserData',UvData) |
---|
[622] | 4781 | |
---|
| 4782 | %% initiate the new projection object |
---|
[410] | 4783 | data.Name=data.Type;% default name=type |
---|
[402] | 4784 | data.Coord=[0 0]; %default |
---|
| 4785 | if isfield(UvData,'Field') |
---|
| 4786 | Field=UvData.Field; |
---|
[575] | 4787 | if isfield(UvData.Field,'CoordMesh')&&~isempty(UvData.Field.CoordMesh) |
---|
[404] | 4788 | data.RangeX=[UvData.Field.XMin UvData.Field.XMax]; |
---|
[410] | 4789 | if strcmp(data.Type,'line')||strcmp(data.Type,'polyline')||strcmp(data.Type,'points') |
---|
[575] | 4790 | data.RangeY=UvData.Field.CoordMesh; |
---|
[406] | 4791 | else |
---|
| 4792 | data.RangeY=[UvData.Field.YMin UvData.Field.YMax]; |
---|
| 4793 | end |
---|
[575] | 4794 | data.DX=UvData.Field.CoordMesh; |
---|
| 4795 | data.DY=UvData.Field.CoordMesh; |
---|
[622] | 4796 | if strcmp(data.Type,'rectangle')||strcmp(data.Type,'ellipse') |
---|
| 4797 | data.RangeX=UvData.Field.CoordMesh; |
---|
| 4798 | data.RangeY=UvData.Field.CoordMesh; |
---|
| 4799 | end |
---|
[402] | 4800 | end |
---|
| 4801 | if isfield(Field,'NbDim')&& isequal(Field.NbDim,3) |
---|
| 4802 | data.Coord=[0 0 0]; %default |
---|
| 4803 | end |
---|
| 4804 | if isfield(Field,'CoordUnit') |
---|
| 4805 | data.CoordUnit=Field.CoordUnit; |
---|
| 4806 | end |
---|
| 4807 | end |
---|
[622] | 4808 | hset_object=set_object(data,handles);% call the GUI set_object |
---|
[421] | 4809 | hchild=get(hset_object,'children'); |
---|
| 4810 | set(hchild,'enable','on') |
---|
[622] | 4811 | |
---|
| 4812 | |
---|
[402] | 4813 | set(handles.delete_object,'Visible','on') |
---|
| 4814 | |
---|
| 4815 | %------------------------------------------------------------------------ |
---|
| 4816 | function MenuBrowseObject_Callback(hObject, eventdata, handles) |
---|
| 4817 | %------------------------------------------------------------------------ |
---|
| 4818 | %get the object file |
---|
| 4819 | [FileName, PathName, filterindex] = uigetfile( ... |
---|
| 4820 | {'*.xml;*.mat', ' (*.xml,*.mat)'; |
---|
| 4821 | '*.xml', '.xml files '; ... |
---|
| 4822 | '*.mat', '.mat matlab files '}, ... |
---|
| 4823 | 'Pick an xml Object file',get(handles.RootPath,'String')); |
---|
| 4824 | fileinput=[PathName FileName];%complete file name |
---|
| 4825 | sizf=size(fileinput); |
---|
| 4826 | if (~ischar(fileinput)||~isequal(sizf(1),1)),return;end |
---|
| 4827 | |
---|
| 4828 | %read the file |
---|
[477] | 4829 | [data,heading]=xml2struct(fileinput); |
---|
| 4830 | if ~strcmp(heading,'ProjObject') |
---|
| 4831 | msgbox_uvmat('WARNING','The xml file does not have the heading ProjObject for projection objects') |
---|
| 4832 | end |
---|
[427] | 4833 | [tild,data.Name]=fileparts(FileName);% object name set as file name |
---|
[429] | 4834 | ListObject=get(handles.ListObject,'String'); |
---|
| 4835 | if ~strcmp(ListObject{end},'') |
---|
| 4836 | ListObject=[ListObject;{''}]; %append a blank to the list (if not already done) to indicate the creation of a new object |
---|
| 4837 | set(handles.ListObject,'String',ListObject) |
---|
| 4838 | end |
---|
[445] | 4839 | IndexObj=length(ListObject); |
---|
| 4840 | |
---|
[432] | 4841 | UvData=get(handles.uvmat,'UserData'); |
---|
[622] | 4842 | UvData.ProjObject{IndexObj}=[]; %create a new empty object |
---|
| 4843 | UvData.ProjObject{IndexObj}.DisplayHandle.uvmat=[]; %no plot handle before plot_field operation |
---|
| 4844 | UvData.ProjObject{IndexObj}.DisplayHandle.view_field=[]; %no plot handle before plot_field operation |
---|
[432] | 4845 | set(handles.uvmat,'UserData',UvData) |
---|
[445] | 4846 | set(handles.ListObject,'Value',IndexObj) |
---|
[427] | 4847 | hset_object=set_object(data);% call the set_object interface |
---|
| 4848 | set(get(hset_object,'children'),'enable','on')% enable edit action on elements on GUI set_object |
---|
[402] | 4849 | set(handles.edit_object,'Value',0); %suppress the object edit mode |
---|
[625] | 4850 | edit_object_Callback([],[],handles) |
---|
[623] | 4851 | % set(handles.edit_object,'BackgroundColor',[0.7,0.7,0.7]) |
---|
[402] | 4852 | set(handles.delete_object,'Visible','on') |
---|
| 4853 | |
---|
[432] | 4854 | |
---|
[627] | 4855 | % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
---|
| 4856 | % % MenuEdit Callbacks |
---|
| 4857 | % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
---|
| 4858 | % %------------------------------------------------------------------------ |
---|
| 4859 | % function MenuEditObject_Callback(hObject, eventdata, handles) |
---|
| 4860 | % %------------------------------------------------------------------------ |
---|
| 4861 | % set(handles.edit_object,'Value',1) |
---|
| 4862 | % edit_Callback(hObject, eventdata, handles) |
---|
| 4863 | % |
---|
| 4864 | % %------------------------------------------------------------------------ |
---|
| 4865 | % function MenuEditVectors_Callback(hObject, eventdata, handles) |
---|
| 4866 | % %------------------------------------------------------------------------ |
---|
| 4867 | % set(handles.edit_vect,'Visible','on') |
---|
| 4868 | % set(handles.edit_vect,'Value',1) |
---|
| 4869 | % edit_vect_Callback(hObject, eventdata, handles) |
---|
[402] | 4870 | |
---|
| 4871 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
---|
| 4872 | % MenuTools Callbacks |
---|
| 4873 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
---|
| 4874 | %------------------------------------------------------------------------ |
---|
[387] | 4875 | function MenuCalib_Callback(hObject, eventdata, handles) |
---|
| 4876 | %------------------------------------------------------------------------ |
---|
| 4877 | |
---|
| 4878 | UvData=get(handles.uvmat,'UserData');%read UvData properties stored on the uvmat interface |
---|
| 4879 | |
---|
| 4880 | %suppress competing options |
---|
| 4881 | set(handles.CheckZoom,'Value',0) |
---|
| 4882 | set(handles.CheckZoom,'BackgroundColor',[0.7 0.7 0.7]) |
---|
| 4883 | set(handles.ListObject,'Value',1) |
---|
| 4884 | % initiate display of GUI geometry_calib |
---|
| 4885 | data=[]; %default |
---|
| 4886 | if isfield(UvData,'CoordType') |
---|
| 4887 | data.CoordType=UvData.CoordType; |
---|
| 4888 | end |
---|
[515] | 4889 | [RootPath,SubDir,RootFile,FileIndex,FileExt]=read_file_boxes(handles); |
---|
| 4890 | FileName=[fullfile(RootPath,SubDir,RootFile) FileIndex FileExt]; |
---|
[387] | 4891 | set(handles.view_xml,'Backgroundcolor',[1 1 0])%indicate the reading of the current xml file by geometry_calib |
---|
[517] | 4892 | pos_uvmat=get(handles.uvmat,'Position'); |
---|
| 4893 | pos_cal(1)=pos_uvmat(1)+UvData.OpenParam.PosGeometryCalib(1)*pos_uvmat(3); |
---|
| 4894 | pos_cal(2)=pos_uvmat(2)+UvData.OpenParam.PosGeometryCalib(2)*pos_uvmat(4); |
---|
| 4895 | pos_cal(3:4)=UvData.OpenParam.PosGeometryCalib(3:4).* pos_uvmat(3:4); |
---|
[387] | 4896 | geometry_calib(FileName,pos_cal);% call the geometry_calib interface |
---|
| 4897 | set(handles.view_xml,'Backgroundcolor',[1 1 1])%indicate the end of reading of the current xml file by geometry_calib |
---|
| 4898 | set(handles.MenuCalib,'checked','on')% indicate that MenuCalib is activated, test used by mouse action |
---|
| 4899 | |
---|
[566] | 4900 | |
---|
| 4901 | %----------------------------------------------------------------------- |
---|
| 4902 | function MenuLIFCalib_Callback(hObject, eventdata, handles) |
---|
[387] | 4903 | %------------------------------------------------------------------------ |
---|
[567] | 4904 | %% read UvData properties stored on the uvmat interface |
---|
| 4905 | UvData=get(handles.uvmat,'UserData'); |
---|
| 4906 | if isfield(UvData,'XmlData')&& isfield(UvData.XmlData{1},'GeometryCalib') |
---|
| 4907 | XmlData=UvData.XmlData{1}; |
---|
| 4908 | else |
---|
| 4909 | msgbox_uvmat('ERROR','geometric calibration needed: use Tools/geometric calibration in the menu bar'); |
---|
| 4910 | return |
---|
| 4911 | end |
---|
| 4912 | |
---|
| 4913 | %% read lines currently drawn |
---|
[622] | 4914 | ListObj=UvData.ProjObject; |
---|
[566] | 4915 | select=zeros(1,numel(ListObj)); |
---|
| 4916 | for iobj=1:numel(ListObj); |
---|
[567] | 4917 | if isfield(ListObj{iobj},'Type') && strcmp(ListObj{iobj}.Type,'line') |
---|
[566] | 4918 | select(iobj)=1; |
---|
| 4919 | end |
---|
| 4920 | end |
---|
| 4921 | val=find(select); |
---|
| 4922 | if numel(val)<2 |
---|
| 4923 | msgbox_uvmat('ERROR','light rays must be defined by at least two lines created by Projection object/line in the menu bar'); |
---|
| 4924 | return |
---|
| 4925 | else |
---|
[567] | 4926 | set(handles.ListObject,'Value',val);% show the selected lines on the list |
---|
[622] | 4927 | ObjectData=UvData.ProjObject(val); |
---|
[566] | 4928 | for iobj=1:length(ObjectData) |
---|
[567] | 4929 | % if isfield(ObjectData{iobj},'Coord') |
---|
| 4930 | xA(iobj)=ObjectData{iobj}.Coord(1,1); |
---|
| 4931 | yA(iobj)=ObjectData{iobj}.Coord(1,2); |
---|
| 4932 | xB(iobj)=ObjectData{iobj}.Coord(2,1); |
---|
| 4933 | yB(iobj)=ObjectData{iobj}.Coord(2,2); |
---|
| 4934 | % end |
---|
[566] | 4935 | end |
---|
| 4936 | end |
---|
| 4937 | |
---|
[567] | 4938 | %% find the origin as intersection of the two first lines (see http://www.ahristov.com/tutorial/geometry-games/intersection-lines.html ) |
---|
| 4939 | x1=xA(1);x2=xB(1); |
---|
| 4940 | x3=xA(2);x4=xB(2); |
---|
| 4941 | y1=yA(1);y2=yB(1); |
---|
| 4942 | y3=yA(2);y4=yB(2); |
---|
| 4943 | D = (x1-x2)*(y3-y4) -(y1-y2)*(x3-x4); |
---|
| 4944 | if D==0 |
---|
| 4945 | msgbox_uvmat('ERROR','the two lines are parallel'); |
---|
| 4946 | return |
---|
| 4947 | end |
---|
| 4948 | x0=((x3-x4)*(x1*y2-y1*x2)-(x1-x2)*(x3*y4-y3*x4))/D; |
---|
| 4949 | y0=((y3-y4)*(x1*y2-y1*x2)-(y1-y2)*(x3*y4-y3*x4))/D; |
---|
| 4950 | XmlData.Illumination.Origin=[x0 y0]; |
---|
| 4951 | XmlData.PolarCentre=[x0 y0]; |
---|
[566] | 4952 | |
---|
[567] | 4953 | %% display the current image in polar coordinates with origin at the illumination source |
---|
| 4954 | currentdir=pwd; |
---|
| 4955 | uvmatpath=fileparts(which('uvmat')); |
---|
| 4956 | cd(fullfile(uvmatpath,'transform_field')); |
---|
| 4957 | phys_polar=str2func('phys_polar'); |
---|
| 4958 | cd(currentdir) |
---|
| 4959 | DataOut=phys_polar(UvData.Field,XmlData); |
---|
| 4960 | view_field(DataOut); |
---|
[566] | 4961 | |
---|
[567] | 4962 | %% use the third line for reference luminosity |
---|
| 4963 | if numel(val)==3 |
---|
| 4964 | x_ref=linspace(ObjectData{3}.Coord(1,1),ObjectData{3}.Coord(2,1),10); |
---|
| 4965 | y_ref=linspace(ObjectData{3}.Coord(1,2),ObjectData{3}.Coord(2,2),10); |
---|
| 4966 | x_ref=x_ref-x0; |
---|
| 4967 | y_ref=y_ref-y0; |
---|
| 4968 | [theta_ref,r_ref] = cart2pol(x_ref,y_ref);%theta_ref and r_ref are the polar coordinates of the points on the line |
---|
| 4969 | theta_ref=theta_ref*180/pi; |
---|
| 4970 | figure |
---|
| 4971 | plot(theta_ref,r_ref) |
---|
| 4972 | azimuth_ima=linspace(DataOut.AY(1),DataOut.AY(2),size(DataOut.A,1));%profile of x index on the transformed image |
---|
| 4973 | dist_source = interp1(theta_ref,r_ref,azimuth_ima); |
---|
| 4974 | dist_source_pixel=round(size(DataOut.A,2)*(dist_source-DataOut.AX(1))/(DataOut.AX(2)-DataOut.AX(1))); |
---|
| 4975 | line_nan= isnan(dist_source_pixel); |
---|
| 4976 | dist_source_pixel(line_nan)=1; |
---|
| 4977 | width=20; %number of pixels used for reference |
---|
| 4978 | DataOut.A=double(DataOut.A); |
---|
| 4979 | Anorm=zeros(size(DataOut.A)); |
---|
| 4980 | Aval=mean(mean(DataOut.A)); |
---|
| 4981 | for iline=1:size(DataOut.A,1) |
---|
| 4982 | lum(iline)=mean(DataOut.A(iline,dist_source_pixel(iline):dist_source_pixel(iline)+width)); |
---|
| 4983 | Anorm(iline,:)=uint16(Aval*DataOut.A(iline,:)/lum(iline)); |
---|
| 4984 | end |
---|
| 4985 | lum(line_nan)=NaN; |
---|
| 4986 | figure |
---|
| 4987 | plot(1:size(DataOut.A,1),lum) |
---|
| 4988 | end |
---|
| 4989 | ImaName=regexprep([get(handles.RootFile,'String') get(handles.FileIndex,'String')],'//',''); |
---|
| 4990 | NewImageName=fullfile(get(handles.RootPath,'String'),'polar',[ImaName get(handles.FileExt,'String')]); |
---|
| 4991 | imwrite(Anorm,NewImageName,'BitDepth',16) |
---|
| 4992 | |
---|
| 4993 | %% record the origin in the xml file |
---|
| 4994 | XmlFileName=find_imadoc(get(handles.RootPath,'String'),get(handles.SubDir,'String'),get(handles.RootFile,'String'),get(handles.FileExt,'String')); |
---|
| 4995 | answer=msgbox_uvmat('INPUT_Y-N','save the illumination origin in the current xml file?'); |
---|
| 4996 | if strcmp(answer,'Yes') |
---|
| 4997 | t=xmltree(XmlFileName); %read the file |
---|
| 4998 | title=get(t,1,'name'); |
---|
| 4999 | if ~strcmp(title,'ImaDoc') |
---|
| 5000 | msgbox_uvmat('ERROR','wrong xml file'); |
---|
| 5001 | return |
---|
| 5002 | end |
---|
| 5003 | % backup the output file if it already exist, and read it |
---|
| 5004 | backupfile=XmlFileName; |
---|
| 5005 | testexist=2; |
---|
| 5006 | while testexist==2 |
---|
| 5007 | backupfile=[backupfile '~']; |
---|
| 5008 | testexist=exist(backupfile,'file'); |
---|
| 5009 | end |
---|
| 5010 | [success,message]=copyfile(XmlFileName,backupfile);%make backup |
---|
| 5011 | if success~=1 |
---|
| 5012 | errormsg=['errror in xml file backup: ' message]; |
---|
| 5013 | return |
---|
| 5014 | end |
---|
| 5015 | uid_illumination=find(t,'ImaDoc/Illumination'); |
---|
| 5016 | if isempty(uid_illumination) %if GeometryCalib does not already exists, create it |
---|
| 5017 | [t,uid_illumination]=add(t,1,'element','Illumination'); |
---|
| 5018 | end |
---|
| 5019 | uid_origin=find(t,'ImaDoc/Illumination/Origin'); |
---|
| 5020 | if ~isempty(uid_origin) %if GeometryCalib does not already exists, create it |
---|
| 5021 | t=delete(t,uid_origin); |
---|
| 5022 | end |
---|
| 5023 | % save the illumination origin |
---|
| 5024 | t=struct2xml(XmlData.Illumination,t,uid_illumination); |
---|
| 5025 | save(t,XmlFileName); |
---|
| 5026 | end |
---|
| 5027 | |
---|
| 5028 | |
---|
| 5029 | |
---|
[566] | 5030 | %------------------------------------------------------------------------ |
---|
[387] | 5031 | function MenuMask_Callback(hObject, eventdata, handles) |
---|
| 5032 | %------------------------------------------------------------------------ |
---|
| 5033 | UvData=get(handles.uvmat,'UserData');%read UvData properties stored on the uvmat interface |
---|
[622] | 5034 | ListObj=UvData.ProjObject; |
---|
[387] | 5035 | select=zeros(1,numel(ListObj)); |
---|
| 5036 | for iobj=1:numel(ListObj); |
---|
| 5037 | if strcmp(ListObj{iobj}.ProjMode,'mask_inside')||strcmp(ListObj{iobj}.ProjMode,'mask_outside') |
---|
| 5038 | select(iobj)=1; |
---|
| 5039 | end |
---|
| 5040 | end |
---|
| 5041 | val=find(select); |
---|
| 5042 | if isempty(val) |
---|
| 5043 | msgbox_uvmat('ERROR','polygons must be first created by Projection object/mask polygon in the menu bar'); |
---|
| 5044 | return |
---|
| 5045 | else |
---|
| 5046 | set(handles.ListObject,'Value',val); |
---|
| 5047 | flag=1; |
---|
[627] | 5048 | if ~isfield(UvData.Field,'A') |
---|
| 5049 | msgbox_uvmat('ERROR','an image needs to be opened to set the mask size'); |
---|
| 5050 | return |
---|
| 5051 | end |
---|
[387] | 5052 | npx=size(UvData.Field.A,2); |
---|
| 5053 | npy=size(UvData.Field.A,1); |
---|
| 5054 | xi=0.5:npx-0.5; |
---|
| 5055 | yi=0.5:npy-0.5; |
---|
| 5056 | [Xi,Yi]=meshgrid(xi,yi); |
---|
[622] | 5057 | for iobj=1:length(UvData.ProjObject) |
---|
| 5058 | ObjectData=UvData.ProjObject{iobj}; |
---|
[387] | 5059 | if isfield(ObjectData,'ProjMode') &&(isequal(ObjectData.ProjMode,'mask_inside')||isequal(ObjectData.ProjMode,'mask_outside')); |
---|
| 5060 | flagobj=1; |
---|
| 5061 | testphys=0; %coordinates in pixels by default |
---|
| 5062 | if isfield(ObjectData,'CoordUnit') && ~isequal(ObjectData.CoordUnit,'pixel') |
---|
| 5063 | if isfield(UvData,'XmlData')&& isfield(UvData.XmlData{1},'GeometryCalib') |
---|
| 5064 | Calib=UvData.XmlData{1}.GeometryCalib; |
---|
| 5065 | testphys=1; |
---|
| 5066 | end |
---|
| 5067 | end |
---|
| 5068 | if isfield(ObjectData,'Coord')&& isfield(ObjectData,'Type') |
---|
| 5069 | if isequal(ObjectData.Type,'polygon') |
---|
| 5070 | X=ObjectData.Coord(:,1); |
---|
| 5071 | Y=ObjectData.Coord(:,2); |
---|
| 5072 | if testphys |
---|
[542] | 5073 | pos=[X Y zeros(size(X))]; |
---|
| 5074 | if isfield(Calib,'SliceCoord') && length(Calib.SliceCoord)>=3 |
---|
| 5075 | if isfield(Calib,'SliceAngle')&&~isequal(Calib.SliceAngle,[0 0 0]) |
---|
| 5076 | om=norm(Calib.SliceAngle);%norm of rotation angle in radians |
---|
| 5077 | OmAxis=Calib.SliceAngle/om; %unit vector marking the rotation axis |
---|
| 5078 | cos_om=cos(pi*om/180); |
---|
| 5079 | sin_om=sin(pi*om/180); |
---|
| 5080 | pos=cos_om*pos+sin_om*cross(OmAxis,pos)+(1-cos_om)*(OmAxis*pos')*OmAxis; |
---|
| 5081 | end |
---|
| 5082 | pos(:,1)=pos(:,1)+Calib.SliceCoord(1); |
---|
| 5083 | pos(:,2)=pos(:,2)+Calib.SliceCoord(2); |
---|
| 5084 | pos(:,3)=pos(:,3)+Calib.SliceCoord(3); |
---|
| 5085 | end |
---|
| 5086 | [X,Y]=px_XYZ(Calib,pos(:,1),pos(:,2),pos(:,3)); |
---|
[387] | 5087 | end |
---|
| 5088 | flagobj=~inpolygon(Xi,Yi,X',Y');%=0 inside the polygon, 1 outside |
---|
| 5089 | elseif isequal(ObjectData.Type,'ellipse') |
---|
| 5090 | if testphys |
---|
| 5091 | %[X,Y]=px_XYZ(Calib,X,Y,0);% TODO:create a polygon boundary and transform to phys |
---|
| 5092 | end |
---|
| 5093 | RangeX=max(ObjectData.RangeX); |
---|
| 5094 | RangeY=max(ObjectData.RangeY); |
---|
| 5095 | X2Max=RangeX*RangeX; |
---|
| 5096 | Y2Max=RangeY*RangeY; |
---|
| 5097 | distX=(Xi-ObjectData.Coord(1,1)); |
---|
| 5098 | distY=(Yi-ObjectData.Coord(1,2)); |
---|
| 5099 | flagobj=(distX.*distX/X2Max+distY.*distY/Y2Max)>1; |
---|
| 5100 | elseif isequal(ObjectData.Type,'rectangle') |
---|
| 5101 | if testphys |
---|
| 5102 | %[X,Y]=px_XYZ(Calib,X,Y,0);% TODO:create a polygon boundary and transform to phys |
---|
| 5103 | end |
---|
| 5104 | distX=abs(Xi-ObjectData.Coord(1,1)); |
---|
| 5105 | distY=abs(Yi-ObjectData.Coord(1,2)); |
---|
| 5106 | flagobj=distX>max(ObjectData.RangeX) | distY>max(ObjectData.RangeY); |
---|
| 5107 | end |
---|
| 5108 | if isequal(ObjectData.ProjMode,'mask_outside') |
---|
| 5109 | flagobj=~flagobj; |
---|
| 5110 | end |
---|
| 5111 | flag=flag & flagobj; |
---|
| 5112 | end |
---|
| 5113 | end |
---|
| 5114 | end |
---|
[566] | 5115 | % end |
---|
[387] | 5116 | %mask name |
---|
| 5117 | RootPath=get(handles.RootPath,'String'); |
---|
[444] | 5118 | SubDir=get(handles.SubDir,'String'); |
---|
[387] | 5119 | RootFile=get(handles.RootFile,'String'); |
---|
| 5120 | if ~isempty(RootFile)&&(isequal(RootFile(1),'/')|| isequal(RootFile(1),'\')) |
---|
| 5121 | RootFile(1)=[]; |
---|
| 5122 | end |
---|
| 5123 | list=get(handles.masklevel,'String'); |
---|
| 5124 | masknumber=num2str(length(list)); |
---|
| 5125 | maskindex=get(handles.masklevel,'Value'); |
---|
[444] | 5126 | % mask_name=fullfile_uvmat(RootPath,'',[RootFile '_' masknumber 'mask'],'.png','_1',maskindex); |
---|
| 5127 | mask_name=fullfile_uvmat(RootPath,[SubDir '.mask'],'mask','.png','_1',maskindex); |
---|
[387] | 5128 | imflag=uint8(255*(0.392+0.608*flag));% =100 for flag=0 (vectors not computed when 20<imflag<200) |
---|
| 5129 | imflag=flipdim(imflag,1); |
---|
| 5130 | |
---|
| 5131 | %display the mask |
---|
| 5132 | hfigmask=figure; |
---|
| 5133 | set(hfigmask,'Name','mask image') |
---|
| 5134 | vec=linspace(0,1,256);%define a linear greyscale colormap |
---|
| 5135 | map=[vec' vec' vec']; |
---|
| 5136 | colormap(map) |
---|
| 5137 | image(imflag); |
---|
| 5138 | answer=msgbox_uvmat('INPUT_TXT','mask file name:', mask_name); |
---|
| 5139 | if ~strcmp(answer,'Cancel') |
---|
| 5140 | mask_dir=fileparts(answer); |
---|
| 5141 | if ~exist(mask_dir,'dir') |
---|
[444] | 5142 | [xx,msg1]=mkdir(mask_dir); |
---|
| 5143 | if ~strcmp(msg1,'') |
---|
| 5144 | errormsg=['cannot create ' mask_dir ': ' msg1];%error message for directory creation |
---|
| 5145 | return |
---|
| 5146 | end |
---|
[387] | 5147 | end |
---|
| 5148 | imwrite(imflag,answer,'BitDepth',8); |
---|
| 5149 | end |
---|
| 5150 | set(handles.ListObject,'Value',1) |
---|
| 5151 | end |
---|
| 5152 | |
---|
| 5153 | %------------------------------------------------------------------------ |
---|
| 5154 | %-- open the GUI set_grid.fig to create grid |
---|
| 5155 | function MenuGrid_Callback(hObject, eventdata, handles) |
---|
| 5156 | %------------------------------------------------------------------------ |
---|
| 5157 | %suppress the other options if grid is chosen |
---|
| 5158 | set(handles.edit_vect,'Value',0) |
---|
| 5159 | edit_vect_Callback(hObject, eventdata, handles) |
---|
[623] | 5160 | % set(handles.edit_object,'BackgroundColor',[0.7 0.7 0.7]) |
---|
[387] | 5161 | set(handles.ListObject,'Value',1) |
---|
| 5162 | |
---|
| 5163 | %prepare display of the set_grid GUI |
---|
[515] | 5164 | [RootPath,SubDir,RootFile,FileIndex,FileExt]=read_file_boxes(handles); |
---|
| 5165 | FileName=[fullfile(RootPath,SubDir,RootFile) FileIndex FileExt]; |
---|
[576] | 5166 | UvData=get(handles.uvmat,'UserData'); |
---|
[591] | 5167 | % CoordList=get(handles.TransformName,'String'); |
---|
| 5168 | % val=get(handles.TransformName,'Value'); |
---|
[576] | 5169 | set_grid(FileName,UvData.Field);% call the set_object interface |
---|
[387] | 5170 | |
---|
[402] | 5171 | |
---|
[387] | 5172 | %------------------------------------------------------------------------ |
---|
[402] | 5173 | function MenuRuler_Callback(hObject, eventdata, handles) |
---|
| 5174 | %------------------------------------------------------------------------ |
---|
| 5175 | set(handles.CheckZoom,'Value',0) |
---|
| 5176 | CheckZoom_Callback(handles.uvmat, [], handles) |
---|
| 5177 | set(handles.MenuRuler,'checked','on') |
---|
| 5178 | UvData=get(handles.uvmat,'UserData'); |
---|
| 5179 | UvData.MouseAction='ruler'; |
---|
| 5180 | set(handles.uvmat,'UserData',UvData); |
---|
| 5181 | |
---|
| 5182 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
---|
| 5183 | % MenuRun Callbacks |
---|
| 5184 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
---|
| 5185 | |
---|
| 5186 | %------------------------------------------------------------------------ |
---|
[387] | 5187 | % open the GUI 'series' |
---|
| 5188 | function MenuSeries_Callback(hObject, eventdata, handles) |
---|
| 5189 | %------------------------------------------------------------------------ |
---|
[515] | 5190 | [RootPath,SubDir,RootFile,FileIndex,FileExt]=read_file_boxes(handles); |
---|
[526] | 5191 | Param.FileName=[fullfile(RootPath,SubDir,RootFile) FileIndex FileExt];%first input file name |
---|
[387] | 5192 | if isequal(get(handles.SubField,'Value'),1) |
---|
[515] | 5193 | [RootPath_1,SubDir_1,RootFile_1,FileIndex_1,FileExt_1]=read_file_boxes_1(handles); |
---|
| 5194 | FileName_1=[fullfile(RootPath_1,SubDir_1,RootFile_1) FileIndex_1 FileExt_1]; |
---|
[526] | 5195 | if ~isequal(FileName_1,Param.FileName) |
---|
| 5196 | Param.FileName_1=FileName_1;%second input file name if relevant |
---|
[387] | 5197 | end |
---|
| 5198 | end |
---|
[526] | 5199 | Param.NomType=get(handles.NomType,'String'); |
---|
| 5200 | Param.NomType_1=get(handles.NomType_1,'String'); |
---|
| 5201 | Param.CheckFixPair=get(handles.CheckFixPair,'Value'); |
---|
| 5202 | UvData=get(handles.uvmat,'UserData'); |
---|
[387] | 5203 | if isfield(UvData,'XmlData')&& isfield(UvData.XmlData{1},'Time') |
---|
[526] | 5204 | Param.Time=UvData.XmlData{1}.Time; |
---|
[387] | 5205 | end |
---|
| 5206 | if isequal(get(handles.scan_i,'Value'),1) |
---|
[526] | 5207 | Param.incr_i=str2num(get(handles.num_IndexIncrement,'String')); |
---|
[387] | 5208 | elseif isequal(get(handles.scan_j,'Value'),1) |
---|
[526] | 5209 | Param.incr_j=str2num(get(handles.num_IndexIncrement,'String')); |
---|
[387] | 5210 | end |
---|
[526] | 5211 | |
---|
| 5212 | %% transfer fields and coordinate names |
---|
| 5213 | Param.list_fields=get(handles.FieldName,'String');% list menu fields |
---|
| 5214 | FieldName=Param.list_fields{get(handles.FieldName,'Value')}; |
---|
| 5215 | ind_image=find(strcmp('image',Param.list_fields)); |
---|
| 5216 | if ~isempty(ind_image) && numel(Param.list_fields)>1 |
---|
| 5217 | Param.list_fields(ind_image)=[]; %suppress 'image' option |
---|
[387] | 5218 | end |
---|
[526] | 5219 | Param.index_fields=find(strcmp(FieldName,Param.list_fields));% selected string index |
---|
| 5220 | Param.list_fields_1=get(handles.FieldName_1,'String');% list menu fields |
---|
| 5221 | if ischar(Param.list_fields_1),Param.list_fields_1={Param.list_fields_1};end |
---|
| 5222 | FieldName_1=Param.list_fields_1{get(handles.FieldName_1,'Value')}; |
---|
| 5223 | ind_image=find(strcmp('image',Param.list_fields_1)); |
---|
| 5224 | if ~isempty(ind_image) && numel(Param.list_fields_1)>1 |
---|
| 5225 | Param.list_fields_1(ind_image)=[]; %suppress 'image' option |
---|
[387] | 5226 | end |
---|
[526] | 5227 | Param.index_fields_1=find(strcmp(FieldName_1,Param.list_fields_1));% selected string index |
---|
[591] | 5228 | TransformList=get(handles.TransformName,'String'); |
---|
| 5229 | Param.TransformName=TransformList{get(handles.TransformName,'Value')}; |
---|
[526] | 5230 | Param.Coord_x_str=get(handles.Coord_x,'String'); |
---|
| 5231 | Param.Coord_x_val=get(handles.Coord_x,'Value'); |
---|
| 5232 | Param.Coord_y_str=get(handles.Coord_y,'String'); |
---|
| 5233 | Param.Coord_y_val=get(handles.Coord_y,'Value'); |
---|
| 5234 | series(Param); %run the series interface |
---|
[387] | 5235 | |
---|
| 5236 | %------------------------------------------------------------------------ |
---|
[402] | 5237 | % -- open the GUI civ.fig for PIV |
---|
[387] | 5238 | function MenuPIV_Callback(hObject, eventdata, handles) |
---|
| 5239 | %------------------------------------------------------------------------ |
---|
[515] | 5240 | [RootPath,SubDir,RootFile,FileIndex,FileExt]=read_file_boxes(handles); |
---|
| 5241 | FileName=[fullfile(RootPath,SubDir,RootFile) FileIndex FileExt]; |
---|
[387] | 5242 | civ(FileName);% interface de civ(not in the uvmat file) |
---|
| 5243 | |
---|
[402] | 5244 | % -------------------------------------------------------------------- |
---|
| 5245 | function MenuHelp_Callback(hObject, eventdata, handles) |
---|
| 5246 | % -------------------------------------------------------------------- |
---|
| 5247 | path_to_uvmat=which ('uvmat');% check the path of uvmat |
---|
| 5248 | pathelp=fileparts(path_to_uvmat); |
---|
| 5249 | helpfile=fullfile(pathelp,'uvmat_doc','uvmat_doc.html'); |
---|
| 5250 | 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') |
---|
| 5251 | else |
---|
| 5252 | addpath (fullfile(pathelp,'uvmat_doc')) |
---|
| 5253 | web(helpfile); |
---|
[387] | 5254 | end |
---|
[497] | 5255 | |
---|
[517] | 5256 | % --- Executes on selection change in Coord_y. |
---|
| 5257 | function Coord_y_Callback(hObject, eventdata, handles) |
---|
| 5258 | |
---|
| 5259 | % --- Executes on selection change in Coord_x. |
---|
| 5260 | function Coord_x_Callback(hObject, eventdata, handles) |
---|
[546] | 5261 | |
---|
| 5262 | |
---|
| 5263 | % --- Executes on button press in CheckColorBar. |
---|
| 5264 | function CheckColorBar_Callback(hObject, eventdata, handles) |
---|
[591] | 5265 | |
---|
| 5266 | |
---|
| 5267 | |
---|
| 5268 | function TransformPath_Callback(hObject, eventdata, handles) |
---|
| 5269 | % hObject handle to TransformPath (see GCBO) |
---|
| 5270 | % eventdata reserved - to be defined in a future version of MATLAB |
---|
| 5271 | % handles structure with handles and user data (see GUIDATA) |
---|
| 5272 | |
---|
| 5273 | % Hints: get(hObject,'String') returns contents of TransformPath as text |
---|
| 5274 | % str2double(get(hObject,'String')) returns contents of TransformPath as a double |
---|
[598] | 5275 | |
---|
| 5276 | |
---|
| 5277 | %TODO: use to modify fill_GUI |
---|
| 5278 | %'write_plot_param': update the plotting parameters on the uvmat or view_field interface after a plotting operation |
---|
| 5279 | function write_plot_param(handles,PlotParam) |
---|
| 5280 | %% coordinates |
---|
| 5281 | if isempty(PlotParam.Coordinates) |
---|
| 5282 | set(handles.Coordinates,'Visible','off') |
---|
| 5283 | set(handles.PlotAxes,'Visible','off') |
---|
| 5284 | set(handles.text_display,'Visible','off') |
---|
| 5285 | set(handles.TableDisplay,'Visible','on') |
---|
| 5286 | else |
---|
| 5287 | set(handles.Coordinates,'Visible','on') |
---|
| 5288 | set(handles.PlotAxes,'Visible','on') |
---|
| 5289 | set(handles.text_display,'Visible','on') |
---|
| 5290 | if isfield(handles,'TableDisplay') |
---|
| 5291 | set(handles.TableDisplay,'Visible','off') |
---|
| 5292 | end |
---|
| 5293 | Coordinates=PlotParam.Coordinates; |
---|
| 5294 | if isfield(Coordinates,'CheckFixAspectRatio') |
---|
| 5295 | if Coordinates.CheckFixAspectRatio |
---|
| 5296 | set(handles.CheckFixAspectRatio,'Value',1) |
---|
| 5297 | else |
---|
| 5298 | set(handles.CheckFixAspectRatio,'Value',0) |
---|
| 5299 | |
---|
| 5300 | end |
---|
| 5301 | end |
---|
| 5302 | if isfield(Coordinates,'AspectRatio') |
---|
| 5303 | set(handles.num_AspectRatio,'String',num2str(Coordinates.AspectRatio)) |
---|
| 5304 | end |
---|
| 5305 | if isfield(Coordinates,'MinX') |
---|
| 5306 | set(handles.num_MinX,'String',num2str(Coordinates.MinX,4)); |
---|
| 5307 | set(handles.num_MaxX,'String',num2str(Coordinates.MaxX,4)); |
---|
| 5308 | set(handles.num_MinY,'String',num2str(Coordinates.MinY,4)); |
---|
| 5309 | set(handles.num_MaxY,'String',num2str(Coordinates.MaxY,4)); |
---|
| 5310 | else |
---|
| 5311 | set(handles.num_MinX,'String',''); |
---|
| 5312 | set(handles.num_MaxX,'String',''); |
---|
| 5313 | set(handles.num_MinY,'String',''); |
---|
| 5314 | set(handles.num_MaxY,'String',''); |
---|
| 5315 | end |
---|
| 5316 | end |
---|
| 5317 | |
---|
| 5318 | %% scalar or image parameters |
---|
| 5319 | if isfield(PlotParam,'Scalar') |
---|
| 5320 | set(handles.Scalar,'Visible','on') |
---|
| 5321 | if isfield(PlotParam.Scalar,'MaxA') |
---|
| 5322 | set(handles.num_MaxA,'String',num2str(PlotParam.Scalar.MaxA,3)); |
---|
| 5323 | end |
---|
| 5324 | if isfield(PlotParam.Scalar,'MinA') |
---|
| 5325 | set(handles.num_MinA,'String',num2str(PlotParam.Scalar.MinA,3)); |
---|
| 5326 | end |
---|
| 5327 | if isfield(PlotParam.Scalar,'IncrA') |
---|
| 5328 | set(handles.num_IncrA,'String',num2str(PlotParam.Scalar.IncrA,3)) |
---|
| 5329 | end |
---|
| 5330 | set(handles.CheckBW,'Value',PlotParam.Scalar.CheckBW) |
---|
| 5331 | if isfield(PlotParam.Scalar,'Opacity')&&isfield(handles,'num_Opacity') |
---|
| 5332 | set(handles.num_Opacity,'String',num2str(PlotParam.Scalar.Opacity)) |
---|
| 5333 | end |
---|
| 5334 | else |
---|
| 5335 | set(handles.Scalar,'Visible','off') |
---|
| 5336 | end |
---|
| 5337 | |
---|
| 5338 | %% parameter for vector field |
---|
| 5339 | if isfield(PlotParam,'Vectors') |
---|
| 5340 | set(handles.Vectors,'Visible','on') |
---|
| 5341 | if isfield(PlotParam.Vectors,'VecScale') |
---|
| 5342 | set(handles.num_VecScale,'String',num2str(PlotParam.Vectors.VecScale,3)) |
---|
| 5343 | end |
---|
| 5344 | if isfield(PlotParam.Vectors,'MinC')&& isfield(PlotParam.Vectors,'MaxC') |
---|
| 5345 | MinC=PlotParam.Vectors.MinC; |
---|
| 5346 | MaxC=PlotParam.Vectors.MaxC; |
---|
| 5347 | set(handles.num_MinVec,'String', num2str(MinC,3)); |
---|
| 5348 | set(handles.num_MaxVec,'String',num2str(MaxC,3)); |
---|
| 5349 | list=get(handles.ColorCode,'String'); |
---|
| 5350 | ichoice=get(handles.ColorCode,'Value'); |
---|
| 5351 | color_option=list{ichoice}; |
---|
| 5352 | test3color=strcmp(color_option,'rgb')||strcmp(color_option,'bgr'); |
---|
| 5353 | if test3color% need to update color thresholds |
---|
| 5354 | set(handles.num_ColCode1,'Visible','on') |
---|
| 5355 | set(handles.num_ColCode2,'Visible','on') |
---|
| 5356 | set(handles.Slider1,'Visible','on') |
---|
| 5357 | set(handles.Slider2,'Visible','on') |
---|
| 5358 | %ColCode1=MinC+(MaxC-MinC)*PlotParam.Vectors.ColCode1; |
---|
| 5359 | %ColCode2=MinC+(MaxC-MinC)*PlotParam.Vectors.ColCode2; |
---|
| 5360 | % ColCode1=MinC+(MaxC-MinC)*PlotParam.Vectors.ColCode1; |
---|
| 5361 | %ColCode2=MinC+(MaxC-MinC)*PlotParam.Vectors.ColCode2; |
---|
| 5362 | set(handles.num_ColCode1,'String',num2str(PlotParam.Vectors.ColCode1,3)) |
---|
| 5363 | set(handles.num_ColCode2,'String',num2str(PlotParam.Vectors.ColCode2,3)) |
---|
| 5364 | set(handles.Slider1,'Value',(PlotParam.Vectors.ColCode1-MinC)/(MaxC-MinC)) |
---|
| 5365 | set(handles.Slider2,'Value',(PlotParam.Vectors.ColCode2-MinC)/(MaxC-MinC)) |
---|
| 5366 | else |
---|
| 5367 | set(handles.num_ColCode1,'Visible','off') |
---|
| 5368 | set(handles.num_ColCode2,'Visible','off') |
---|
| 5369 | set(handles.Slider1,'Visible','off') |
---|
| 5370 | set(handles.Slider2,'Visible','off') |
---|
| 5371 | end |
---|
| 5372 | end |
---|
| 5373 | else |
---|
| 5374 | set(handles.Vectors,'Visible','off') |
---|
| 5375 | if isfield(handles,'edit_vect') |
---|
| 5376 | set(handles.edit_vect,'Visible','off') |
---|
| 5377 | set(handles.record,'Visible','off') |
---|
| 5378 | end |
---|
| 5379 | end |
---|