1 | %'uvmat': function associated with the GUI 'uvmat.fig' for images and data field visualization |
---|
2 | %------------------------------------------------------------------------ |
---|
3 | % function huvmat=uvmat(input) |
---|
4 | % |
---|
5 | %OUTPUT |
---|
6 | % huvmat=current handles of the GUI uvmat.fig |
---|
7 | %% |
---|
8 | % |
---|
9 | %INPUT: |
---|
10 | % input: input file name (if character chain), or input image matrix to |
---|
11 | % visualize, or Matlab structure representing netcdf fieldname (with fieldname |
---|
12 | % ListVarName....) |
---|
13 | % |
---|
14 | %AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA |
---|
15 | % Copyright Joel Sommeria, 2008, LEGI / CNRS-UJF-INPG, joel.sommeria@legi.grenoble-inp.fr. |
---|
16 | %AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA |
---|
17 | % This open is part of the toolbox UVMAT. |
---|
18 | % |
---|
19 | % UVMAT is free software; you can redistribute it and/or modify |
---|
20 | % it under the terms of the GNU General Public License as published by |
---|
21 | % the Free Software Foundation; either version 2 of the License, or |
---|
22 | % (at your option) any later version. |
---|
23 | % |
---|
24 | % UVMAT is distributed in the hope that it will be useful, |
---|
25 | % but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
26 | % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
27 | % GNU General Public License (open UVMAT/COPYING.txt) for more details. |
---|
28 | %AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA |
---|
29 | % |
---|
30 | % Information stored on the interface:(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 |
---|
35 | % .NbBuiltin: nbre of functions always displayed in TransformName menu |
---|
36 | % .ProjObject: cell array of structures representing the current projection objects, as produced by 'set_object.m'={[]} by default |
---|
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 |
---|
43 | % .XmlData: cell array of 1 or 2 structures representing the xml files associated with the input fieldname (containing timing and geometry calibration) |
---|
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 |
---|
47 | |
---|
48 | % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%% DATA FLOW (for REFRESH_Callback) %%%%%%%%%%%%%%%%%%%%: |
---|
49 | % |
---|
50 | % |
---|
51 | % 1) Input filenames are determined by MenuBrowse (first field), MenuBrowseCampaign |
---|
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) |
---|
55 | % 4) Then fieldname are opened and visualised by the main sub-function 'uvmat/refresh_field.m' |
---|
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: |
---|
58 | % |
---|
59 | % %%%%%%%% structure of uvmat/refresh_field.m %%%%%%%% |
---|
60 | % |
---|
61 | % Main input open second input open_1 |
---|
62 | % | | |
---|
63 | % read_field.m read_field.m |
---|
64 | % | | |
---|
65 | % Field{1} Field{2} |
---|
66 | % | | |
---|
67 | % --->transform fct<--- transform (e.g. phys.m) and combine input fieldname |
---|
68 | % | |
---|
69 | % (tps_coeff_field.m) calculate tps coefficients (for filter projection or spatial derivatives). |
---|
70 | % | |
---|
71 | % UvData.Field-------------->histogram |
---|
72 | % _____________|____________ |
---|
73 | % | | |
---|
74 | % proj_field.m proj_field.m project the field on the projection objects (use set_field_list.m) |
---|
75 | % | | |
---|
76 | % UvData.PlotAxes ViewData.PlotAxes (on view_field) |
---|
77 | % | | |
---|
78 | % plot_field.m (uvmat) plot_field.m (view_field) plot the projected fieldname |
---|
79 | % |
---|
80 | % |
---|
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 CheckEditObject |
---|
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 CheckEditObject |
---|
114 | % .CurrentLine: currently drawn menuline (A REVOIR) |
---|
115 | % .CurrentObject: handle of the currently drawn CheckEditObject |
---|
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 |
---|
128 | % .IndexObj: index in the list of UvData.ProjObject |
---|
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 | %------------------------------------------------------------------------ |
---|
138 | % I - MAIN FUNCTION uvmat |
---|
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 | |
---|
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 | |
---|
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 | UvData.OpenParam.PosColorbar=[0.80 0.02 0.018 0.445]; |
---|
193 | % UvData.OpenParam.PosGeometryCalib=[0.95 -0.03 0.28 1 ];%position for geometry_calib |
---|
194 | AxeData.LimEditBox=1; %initialise AxeData |
---|
195 | set(handles.PlotAxes,'UserData',AxeData) |
---|
196 | % position of table Coord_y |
---|
197 | set(handles.Coord_y,'Unit','pixel') |
---|
198 | Pos=get(handles.Coord_y,'Position'); |
---|
199 | set(handles.Coord_y,'Unit','normalized') |
---|
200 | set(handles.Coord_y,'ColumnWidth',{Pos(3)}) |
---|
201 | set(handles.Coord_y,'ColumnFormat',{'char'}) |
---|
202 | set(handles.Coord_y,'ColumnEditable',false) |
---|
203 | set(handles.Coord_y,'ColumnName',{''}) |
---|
204 | |
---|
205 | %% set functions for the mouse and keyboard |
---|
206 | set(hObject,'WindowKeyPressFcn',{'keyboard_callback',handles})%set keyboard action function |
---|
207 | set(hObject,'WindowButtonMotionFcn',{'mouse_motion',handles})%set mouse action functio |
---|
208 | set(hObject,'WindowButtonDownFcn',{'mouse_down'})%set mouse click action function |
---|
209 | set(hObject,'WindowButtonUpFcn',{'mouse_up',handles}) |
---|
210 | set(hObject,'DeleteFcn',{@closefcn})% |
---|
211 | set(hObject,'ResizeFcn',{@ResizeFcn,handles})% |
---|
212 | % set(handles.RootPath,'ButtonDownFcn',{'@mouse_down_control'})%set mouse click action function |
---|
213 | |
---|
214 | %% initialisation |
---|
215 | set(handles.FieldName,'Value',1) |
---|
216 | set(handles.FieldName,'string',{''}) |
---|
217 | UvData.ProjObject={[]}; |
---|
218 | |
---|
219 | %% TRANSFORM menu: builtin fcts |
---|
220 | transform_menu={'';'sub_field';'phys';'phys_polar'}; |
---|
221 | UvData.OpenParam.NbBuiltin=numel(transform_menu); %number of functions |
---|
222 | transform_path=fullfile(path_uvmat,'transform_field'); |
---|
223 | path_list=cell(UvData.OpenParam.NbBuiltin,1); |
---|
224 | path_list{1}=''; |
---|
225 | for ilist=2:UvData.OpenParam.NbBuiltin |
---|
226 | path_list{ilist}=transform_path; % set transform_path to the path_list |
---|
227 | end |
---|
228 | |
---|
229 | %% load the list of previously browsed files in menus Open, Open_1 and TransformName |
---|
230 | dir_perso=prefdir; % path to the directory .matlab containing the personal data of the current user |
---|
231 | profil_perso=fullfile(dir_perso,'uvmat_perso.mat');% personal data file uvmat_perso.mat' in .matlab |
---|
232 | if exist(profil_perso,'file')% if the file exists |
---|
233 | h=load (profil_perso); % open the personal file |
---|
234 | if isfield(h,'MenuFile')% load the saved menu of previously opened files |
---|
235 | for ifile=1:min(length(h.MenuFile),5) |
---|
236 | set(handles.(['MenuFile_' num2str(ifile)]),'Label',h.MenuFile{ifile}); |
---|
237 | end |
---|
238 | end |
---|
239 | if isfield(h,'MenuCampaign')% load the saved menu of previously opened campaigns |
---|
240 | for ifile=1:min(length(h.MenuCampaign),5) |
---|
241 | set(handles.(['MenuCampaign_' num2str(ifile)]),'Label',h.MenuCampaign{ifile}); |
---|
242 | end |
---|
243 | end |
---|
244 | if isfield(h,'RootPath') |
---|
245 | set(handles.RootPath,'UserData',h.RootPath); %store the previous campaign in the UserData of RootPath |
---|
246 | end |
---|
247 | if isfield(h,'transform_fct') && iscell(h.transform_fct) % load the menu of transform fct set by user |
---|
248 | for ilist=1:length(h.transform_fct); |
---|
249 | if exist(h.transform_fct{ilist},'file') |
---|
250 | [path,file]=fileparts(h.transform_fct{ilist}); |
---|
251 | transform_menu=[transform_menu; {file}]; |
---|
252 | path_list=[path_list; {path}]; |
---|
253 | end |
---|
254 | end |
---|
255 | end |
---|
256 | end |
---|
257 | transform_menu=[transform_menu;{'more...'}];%append the option more.. to the menu |
---|
258 | set(handles.TransformName,'String',transform_menu)% display the menu of transform fcts |
---|
259 | set(handles.TransformName,'UserData',path_list)% store the corresponding list of path in UserData of uicontrol transform_fct |
---|
260 | set(handles.TransformPath,'String','') |
---|
261 | set(handles.TransformPath,'UserData',[]) |
---|
262 | |
---|
263 | %% case of an input argument for uvmat |
---|
264 | testinputfield=0; |
---|
265 | inputfile=[]; |
---|
266 | Field=[]; |
---|
267 | if exist('input','var') |
---|
268 | if ishandle(handles.UVMAT_title) |
---|
269 | delete(handles.UVMAT_title) |
---|
270 | end |
---|
271 | if isstruct(input) |
---|
272 | if isfield(input,'InputFile') |
---|
273 | inputfile=input.InputFile; |
---|
274 | end |
---|
275 | if isfield(input,'TimeIndex') |
---|
276 | set(handles.i1,num2str(input.TimeIndex)) |
---|
277 | end |
---|
278 | if isfield(input,'FieldsString') |
---|
279 | UvData.FieldsString=input.FieldsString; |
---|
280 | end |
---|
281 | elseif ischar(input)% file name introduced as input |
---|
282 | inputfile=input; |
---|
283 | elseif isnumeric(input)%simple matrix introduced as input |
---|
284 | sizinput=size(input); |
---|
285 | if sizinput(1)<=1 || sizinput(2)<=1 |
---|
286 | msgbox_uvmat('ERROR','bad input for uvmat: file name, structure or numerical matrix accepted') |
---|
287 | return |
---|
288 | end |
---|
289 | UvData.Field.ListVarName={'A','coord_y','coord_x'}; |
---|
290 | UvData.Field.VarDimName={{'coord_y','coord_x'},'cord_y','coord_x'}; |
---|
291 | UvData.Field.A=input; |
---|
292 | UvData.Field.coord_x=[0.5 size(input,2)-0.5]; |
---|
293 | UvData.Field.coord_y=[size(input,1)-0.5 0.5]; |
---|
294 | testinputfield=1; |
---|
295 | end |
---|
296 | else |
---|
297 | %% check the path and date of modification of all functions in uvmat |
---|
298 | path_to_uvmat=which ('uvmat');% check the path detected for source file uvmat |
---|
299 | [infomsg,date_str,svn_info]=check_files;%check the path of the functions called by uvmat.m |
---|
300 | date_str=['last modification: ' date_str]; |
---|
301 | if ishandle(handles.UVMAT_title) |
---|
302 | set(handles.UVMAT_title,'String',... |
---|
303 | [{'Copyright LEGI UMR 5519 /CNRS-UJF-Grenoble INP, 2010'};... |
---|
304 | {'GNU General Public License'};... |
---|
305 | {path_to_uvmat};... |
---|
306 | {date_str};... |
---|
307 | infomsg]); |
---|
308 | end |
---|
309 | end |
---|
310 | set(handles.uvmat,'UserData',UvData) |
---|
311 | if ~isempty(inputfile) |
---|
312 | %%%%% display the input field %%%%%%% |
---|
313 | display_file_name(handles,inputfile) |
---|
314 | %%%%%%% |
---|
315 | end |
---|
316 | |
---|
317 | set_vec_col_bar(handles) %update the display of color code for vectors |
---|
318 | |
---|
319 | %------------------------------------------------------------------------ |
---|
320 | % --- Outputs from this function are returned to the command menuline. |
---|
321 | function varargout = uvmat_OutputFcn(hObject, eventdata, handles) |
---|
322 | %------------------------------------------------------------------------ |
---|
323 | varargout{1} = handles.output;% the only output argument is the handle to the GUI figure |
---|
324 | |
---|
325 | %------------------------------------------------------------------------ |
---|
326 | % --- executed when closing uvmat: delete or desactivate the associated figures if exist |
---|
327 | function closefcn(gcbo,eventdata) |
---|
328 | %------------------------------------------------------------------------ |
---|
329 | % delete GUI 'view_field' if detected |
---|
330 | hh=findobj(allchild(0),'tag','view_field'); |
---|
331 | if ~isempty(hh) |
---|
332 | delete(hh) |
---|
333 | end |
---|
334 | % delete GUI 'geometry_calib' if detected |
---|
335 | hh=findobj(allchild(0),'tag','geometry_calib'); |
---|
336 | if ~isempty(hh) |
---|
337 | delete(hh) |
---|
338 | end |
---|
339 | % desable set_object editing action if detected |
---|
340 | hh=findobj(allchild(0),'tag','set_object'); |
---|
341 | if ~isempty(hh) |
---|
342 | hhh=findobj(hh,'tag','PLOT'); |
---|
343 | set(hhh,'enable','off') |
---|
344 | end |
---|
345 | %delete the bowser if detected |
---|
346 | hh=findobj(allchild(0),'tag','browser'); |
---|
347 | if ~isempty(hh) |
---|
348 | delete(hh) |
---|
349 | end |
---|
350 | |
---|
351 | %------------------------------------------------------------------------ |
---|
352 | %--- activated when resizing the GUI view_field |
---|
353 | function ResizeFcn(gcbo,eventdata,handles) |
---|
354 | %------------------------------------------------------------------------ |
---|
355 | set(handles.uvmat,'Units','pixels') |
---|
356 | size_fig=get(handles.uvmat,'Position'); |
---|
357 | ColumnWidth=max(150,0.18*size_fig(3)); |
---|
358 | ColumnWidth=min(ColumnWidth,250); % width of the right side display column, between 150 and 250, depending on the fig width |
---|
359 | |
---|
360 | %% position of panel InputFile |
---|
361 | set(handles.InputFile,'Units','pixels') |
---|
362 | pos_InputFile=get(handles.InputFile,'Position');% [lower x lower y width height] for text_display |
---|
363 | pos_InputFile(1)=0; |
---|
364 | pos_InputFile(2)=size_fig(4)-pos_InputFile(4); % set frame InputFile to the top of the fig |
---|
365 | pos_InputFile(3)=size_fig(3); |
---|
366 | set(handles.InputFile,'Position',pos_InputFile);% [lower x lower y width height] for text_display |
---|
367 | |
---|
368 | %% reset position of text_display and TableDisplay |
---|
369 | % if strcmp(get(handles.TableDisplay,'Visible'),'off') |
---|
370 | set(handles.text_display,'Units','pixels') |
---|
371 | pos_1=get(handles.text_display,'Position');% [lower x lower y width height] for text_display |
---|
372 | pos_1(3)=1.2*ColumnWidth; |
---|
373 | pos_1(1)=size_fig(3)-pos_1(3); % set text display to the right of the fig |
---|
374 | pos_1(2)=size_fig(4)-pos_InputFile(4)-pos_1(4); % set text display to the top of the fig |
---|
375 | set(handles.text_display,'Position',pos_1) |
---|
376 | % reset position of TableDisplay |
---|
377 | % else |
---|
378 | % set(handles.TableDisplay,'Units','pixels') |
---|
379 | % pos_1=get(handles.TableDisplay,'Position'); |
---|
380 | % pos_1(3)=1.2*ColumnWidth; |
---|
381 | % pos_1(1)=size_fig(3)-pos_1(3); |
---|
382 | % pos_1(2)=size_fig(4)-pos_InputFile(4)-pos_1(4); |
---|
383 | set(handles.TableDisplay,'Position',pos_1) |
---|
384 | % reset position of CheckTable |
---|
385 | set(handles.CheckTable,'Unit','pixels') |
---|
386 | pos_CheckTable=get(handles.CheckTable,'Position');% [lower x lower y width height] for CheckHold |
---|
387 | pos_CheckTable(1)=pos_1(1)-pos_CheckTable(3); % set 'CheckHold' to the right of the fig |
---|
388 | pos_CheckTable(2)=pos_InputFile(2)-pos_CheckTable(4); % set 'CheckHold' to the lower edge of text display |
---|
389 | set(handles.CheckTable,'Position',pos_CheckTable) |
---|
390 | % end |
---|
391 | |
---|
392 | %% reset position of CheckHold |
---|
393 | % pos_CheckHold=get(handles.CheckHold,'Position');% [lower x lower y width height] for CheckHold |
---|
394 | % pos_CheckHold(1)=size_fig(3)-pos_CheckHold(3); % set 'CheckHold' to the right of the fig |
---|
395 | % pos_CheckHold(2)=pos_1(2)-pos_CheckHold(4); % set 'CheckHold' to the lower edge of text display |
---|
396 | % set(handles.CheckHold,'Position',pos_CheckHold) |
---|
397 | |
---|
398 | %% reset position of Coordinates |
---|
399 | set(handles.Coordinates,'Units','pixels') |
---|
400 | pos_2=get(handles.Coordinates,'Position');% [lower x lower y width height] for frame 'Coordinates' |
---|
401 | pos_2(3)=ColumnWidth; |
---|
402 | pos_2(1)=size_fig(3)-pos_2(3); % set 'Coordinates' to the right of the fig |
---|
403 | pos_2(2)=pos_1(2)-pos_2(4); % set 'Coordinates' to the lower edge of text display, allowing a margin for CheckHold |
---|
404 | set(handles.Coordinates,'Position',pos_2) |
---|
405 | |
---|
406 | %% reset position of Scalar |
---|
407 | set(handles.Scalar,'Units','pixels') |
---|
408 | pos_3=get(handles.Scalar,'Position'); % [lower x lower y width height] for frame 'Scalar' |
---|
409 | pos_3(3)=ColumnWidth; |
---|
410 | pos_3(1)=size_fig(3)-pos_3(3); % set 'Scalar' to the right of the fig |
---|
411 | if strcmp(get(handles.Scalar,'Visible'),'on') |
---|
412 | pos_3(2)=pos_2(2)-pos_3(4); % set 'Scalar' to the lower edge of frame 'Coordinates' if visible |
---|
413 | else |
---|
414 | pos_3(2)=pos_2(2);% set 'Scalar' to the lower edge of frame 'text display' if unvisible |
---|
415 | end |
---|
416 | set(handles.Scalar,'Position',pos_3) |
---|
417 | |
---|
418 | %% reset position of Vectors |
---|
419 | set(handles.Vectors,'Units','pixels') |
---|
420 | pos_4=get(handles.Vectors,'Position'); |
---|
421 | pos_4(3)=ColumnWidth; |
---|
422 | pos_4(1)=size_fig(3)-pos_4(3); |
---|
423 | if strcmp(get(handles.Vectors,'visible'),'on') |
---|
424 | pos_4(2)=pos_3(2)-pos_4(4); |
---|
425 | else |
---|
426 | pos_4(2)=pos_3(2); |
---|
427 | end |
---|
428 | set(handles.Vectors,'Position',pos_4) |
---|
429 | |
---|
430 | %% reset position and scale of axis |
---|
431 | pos(1)=0.2*size_fig(3)+35; |
---|
432 | pos(2)=35; |
---|
433 | pos(3)=0.77*size_fig(3)-1.2*ColumnWidth; |
---|
434 | pos(4)=size_fig(4)-60; |
---|
435 | set(handles.PlotAxes,'Units','pixels') |
---|
436 | set(handles.PlotAxes,'Position',pos) |
---|
437 | set(handles.PlotAxes,'Units','normalized') |
---|
438 | |
---|
439 | |
---|
440 | %------------------------------------------------------------------------ |
---|
441 | %------------------------------------------------------------------------ |
---|
442 | % II - FUNCTIONS FOR INTRODUCING THE INPUT FILES |
---|
443 | % automatically sets the global properties when the rootfile name is introduced |
---|
444 | % then activate the view-field action if selected |
---|
445 | % it is activated either by clicking on the RootPath window or by the |
---|
446 | % browser |
---|
447 | %------------------------------------------------------------------------ |
---|
448 | %------------------------------------------------------------------------ |
---|
449 | % --- Executes on the menu Open/Browse... |
---|
450 | % search the files, recognize their type according to their name and fill the rootfile input windows |
---|
451 | function MenuBrowse_Callback(hObject, eventdata, handles) |
---|
452 | [RootPath,SubDir,RootFile,FileIndices,FileExt]=read_file_boxes(handles); |
---|
453 | oldfile=[fullfile(RootPath,SubDir,RootFile) FileIndices FileExt]; |
---|
454 | if isempty(oldfile) %loads the previously stored file name and set it as default in the file_input box |
---|
455 | oldfile=get(handles.RootPath,'UserData'); |
---|
456 | end |
---|
457 | fileinput=uigetfile_uvmat('pick an input file',oldfile); |
---|
458 | hh=dir(fileinput); |
---|
459 | if numel(hh)>1 |
---|
460 | msgbox_uvmat('ERROR','invalid input, probably a broken link'); |
---|
461 | else |
---|
462 | |
---|
463 | %% display the selected field and related information |
---|
464 | if ~isempty(fileinput) |
---|
465 | set(handles.SubField,'Value',0) |
---|
466 | desable_subfield(handles) |
---|
467 | display_file_name(handles,fileinput) |
---|
468 | end |
---|
469 | end |
---|
470 | |
---|
471 | % ----------------------------------------------------------------------- |
---|
472 | % --- Open again the file whose name has been recorded in MenuFile_1 |
---|
473 | function MenuFile_Callback(hObject, eventdata, handles) |
---|
474 | %------------------------------------------------------------------------ |
---|
475 | fileinput=get(hObject,'Label'); |
---|
476 | set(handles.SubField,'Value',0) |
---|
477 | desable_subfield(handles) |
---|
478 | display_file_name( handles,fileinput) |
---|
479 | |
---|
480 | |
---|
481 | % ----------------------------------------------------------------------- |
---|
482 | % --- Executes on the menu Open/Browse campaign... |
---|
483 | % --- search the file inside a campaign, using the GUI browse_data |
---|
484 | % ----------------------------------------------------------------------- |
---|
485 | function MenuBrowseCampaign_Callback(hObject, eventdata, handles) |
---|
486 | set(handles.MenuOpenCampaign,'ForegroundColor',[1 1 0]) |
---|
487 | drawnow |
---|
488 | RootPath=get(handles.RootPath,'String'); |
---|
489 | if isempty(RootPath) |
---|
490 | RootPath=get(handles.RootPath,'UserData');%use Rootpath recored from the personal file at uvmat opening |
---|
491 | end |
---|
492 | CampaignPath=fileparts(fileparts(RootPath)); |
---|
493 | DirFull=uigetfile_uvmat('define this path as the Campaign folder:',CampaignPath,'uigetdir'); |
---|
494 | %DirFull = uigetdir(CampaignPath,'Select a Campaign dir, then press OK'); |
---|
495 | if isempty(DirFull) |
---|
496 | return |
---|
497 | end |
---|
498 | OutPut=browse_data(DirFull);% open the GUI browse_data to get select a campaign dir, experiment and device |
---|
499 | if ~isfield(OutPut,'Campaign') |
---|
500 | return |
---|
501 | end |
---|
502 | DirName=fullfile(OutPut.Campaign,OutPut.Experiment{1},OutPut.DataSeries{1}); |
---|
503 | ListStruct=dir(DirName); %list files and the dir DataSeries |
---|
504 | % select the first appropriate file in the dir |
---|
505 | FileName=''; |
---|
506 | for ilist=1:numel(ListStruct) |
---|
507 | if ~isequal(ListStruct(ilist).isdir,1)%look for files, not dir |
---|
508 | FileName=ListStruct(ilist).name; |
---|
509 | FileType=get_file_type(fullfile(DirName,FileName)); |
---|
510 | switch FileType |
---|
511 | case {'image','multimage','civx','civdata','netcdf'} |
---|
512 | break |
---|
513 | end |
---|
514 | end |
---|
515 | end |
---|
516 | if isempty(FileName) |
---|
517 | msgbox_uvmat('ERROR',['no appropriate input file in the DataSeries folder ' fullfile(DirName)]) |
---|
518 | return |
---|
519 | end |
---|
520 | |
---|
521 | %% update the list of campaigns in the menubar |
---|
522 | MenuCampaign=[{get(handles.MenuCampaign_1,'Label')};{get(handles.MenuCampaign_2,'Label')};... |
---|
523 | {get(handles.MenuCampaign_3,'Label')};{get(handles.MenuCampaign_4,'Label')};{get(handles.MenuCampaign_5,'Label')}]; |
---|
524 | check_dir=isempty(find(strcmp(DirFull,MenuCampaign))); |
---|
525 | if check_dir %insert the new campaign in the list if it is not found |
---|
526 | MenuCampaign(end)=[]; %suppress the last item |
---|
527 | MenuCampaign=[{DirFull};MenuCampaign];%insert the new campaign |
---|
528 | for ilist=1:numel(MenuCampaign) |
---|
529 | set(handles.(['MenuCampaign_' num2str(ilist)]),'Label',MenuCampaign{ilist}) |
---|
530 | end |
---|
531 | % save the list for future opening: |
---|
532 | dir_perso=prefdir; |
---|
533 | profil_perso=fullfile(dir_perso,'uvmat_perso.mat'); |
---|
534 | if exist(profil_perso,'file') |
---|
535 | save (profil_perso,'MenuCampaign','RootPath','-append'); %store the file names for future opening of uvmat |
---|
536 | else |
---|
537 | save (profil_perso,'MenuCampaign','RootPath','-V6'); %store the file names for future opening of uvmat |
---|
538 | end |
---|
539 | end |
---|
540 | |
---|
541 | %% display the selected field and related information |
---|
542 | display_file_name( handles,fullfile(DirName,FileName)) |
---|
543 | |
---|
544 | set(handles.MenuOpenCampaign,'ForegroundColor',[0 0 0]) |
---|
545 | |
---|
546 | % ----------------------------------------------------------------------- |
---|
547 | % --- Open again as second field the file whose name has been recorded in MenuFile_1 |
---|
548 | % ----------------------------------------------------------------------- |
---|
549 | function MenuCampaign_Callback(hObject, eventdata, handles) |
---|
550 | |
---|
551 | set(handles.MenuOpenCampaign,'ForegroundColor',[1 1 0]) |
---|
552 | OutPut=browse_data(get(hObject,'Label'));% open the GUI browse_data to get select a campaign dir, experiment and device |
---|
553 | if ~isfield(OutPut,'Campaign') |
---|
554 | return |
---|
555 | end |
---|
556 | DirName=fullfile(OutPut.Campaign,OutPut.Experiment{1},OutPut.DataSeries{1}); |
---|
557 | hdir=dir(DirName); %list files and dirs |
---|
558 | FileName=''; |
---|
559 | for ilist=1:numel(hdir) |
---|
560 | if ~isequal(hdir(ilist).isdir,1)%look for files, not dir |
---|
561 | FileName=hdir(ilist).name; |
---|
562 | FileType=get_file_type(fullfile(DirName,FileName)); |
---|
563 | switch FileType |
---|
564 | case {'image','multimage','civx','civdata','netcdf'} |
---|
565 | break |
---|
566 | end |
---|
567 | end |
---|
568 | end |
---|
569 | if isempty(FileName) |
---|
570 | msgbox_uvmat('ERROR','no valid input file in the selected directory') |
---|
571 | else |
---|
572 | display_file_name(handles,fullfile(DirName,FileName)) |
---|
573 | end |
---|
574 | set(handles.MenuOpenCampaign,'ForegroundColor',[0 0 0]) |
---|
575 | |
---|
576 | %------------------------------------------------------------------------ |
---|
577 | % --- Called by action in FileIndex edit box |
---|
578 | function FileIndex_Callback(hObject, eventdata, handles) |
---|
579 | %------------------------------------------------------------------------ |
---|
580 | [tild,tild,tild,i1,i2,j1,j2]=fileparts_uvmat(get(handles.FileIndex,'String')); |
---|
581 | set(handles.i1,'String',num2str(i1)); |
---|
582 | set(handles.i2,'String',num2str(i2)); |
---|
583 | set(handles.j1,'String',num2str(j1)); |
---|
584 | set(handles.j2,'String',num2str(j2)); |
---|
585 | |
---|
586 | |
---|
587 | %------------------------------------------------------------------------ |
---|
588 | % --- Called by action in NomType edit box |
---|
589 | function NomType_Callback(hObject, eventdata, handles) |
---|
590 | %------------------------------------------------------------------------ |
---|
591 | i1=str2num(get(handles.i1,'String')); |
---|
592 | i2=str2num(get(handles.i2,'String')); |
---|
593 | j1=str2num(get(handles.j1,'String')); |
---|
594 | j2=str2num(get(handles.j2,'String')); |
---|
595 | FileIndex=fullfile_uvmat('','','','',get(handles.NomType,'String'),i1,i2,j1,j2); |
---|
596 | set(handles.FileIndex,'String',FileIndex) |
---|
597 | % inputfilerefresh the current settings and inputfilerefresh the field view |
---|
598 | RootPath_Callback(hObject,eventdata,handles) |
---|
599 | |
---|
600 | %------------------------------------------------------------------------ |
---|
601 | % --- Called by action in NomType edit box |
---|
602 | function NomType_1_Callback(hObject, eventdata, handles) |
---|
603 | %------------------------------------------------------------------------ |
---|
604 | i1=str2num(get(handles.i1,'String')); |
---|
605 | i2=str2num(get(handles.i2,'String')); |
---|
606 | j1=str2num(get(handles.j1,'String')); |
---|
607 | j2=str2num(get(handles.j2,'String')); |
---|
608 | FileIndex=fullfile_uvmat('','','','',get(handles.NomType_1,'String'),i1,i2,j1,j2); |
---|
609 | set(handles.FileIndex_1,'String',FileIndex) |
---|
610 | % inputfilerefresh the current settings and inputfilerefresh the field view |
---|
611 | RootPath_1_Callback(hObject,eventdata,handles) |
---|
612 | |
---|
613 | %------------------------------------------------------------------------ |
---|
614 | % --- Executes on button press in InputFileREFRESH. |
---|
615 | function InputFileREFRESH_Callback(hObject, eventdata, handles) |
---|
616 | %------------------------------------------------------------------------ |
---|
617 | set(handles.InputFileREFRESH,'BackgroundColor',[1 1 0])% set button color to yellow to indicate that refresh is under action |
---|
618 | % read the current input file name: |
---|
619 | [RootPath,SubDir,RootFile,FileIndices,FileExt]=read_file_boxes(handles); |
---|
620 | % if ~exist(fullfile(RootPath,SubDir),'dir') |
---|
621 | % msgbox_uvmat('ERROR',['directory ' fullfile(RootPath,SubDir) ' does not exist']) |
---|
622 | % return |
---|
623 | % end |
---|
624 | % detect the file type, get the movie object if relevant, and look for the corresponding file series: |
---|
625 | [RootPath,SubDir,RootFile,i1_series,i2_series,j1_series,j2_series,tild,FileType,FileInfo,MovieObject]=find_file_series(fullfile(RootPath,SubDir),[RootFile FileIndices FileExt]); |
---|
626 | % initiate the input file series and inputfilerefresh the current field view: |
---|
627 | errormsg=update_rootinfo(handles,i1_series,i2_series,j1_series,j2_series,FileType,MovieObject,1); |
---|
628 | % inputfilerefresh the second series if selected |
---|
629 | if get(handles.SubField,'Value') |
---|
630 | [RootPath,SubDir,RootFile,FileIndices,FileExt]=read_file_boxes_1(handles); |
---|
631 | if ~exist(fullfile(RootPath,SubDir),'dir') |
---|
632 | msgbox_uvmat('ERROR',['directory ' fullfile(RootPath,SubDir) ' does not exist']) |
---|
633 | return |
---|
634 | end |
---|
635 | % detect the file type, get the movie object if relevant, and look for the corresponding file series: |
---|
636 | [RootPath,SubDir,RootFile,i1_series,i2_series,j1_series,j2_series,tild,FileType,MovieObject]=find_file_series(fullfile(RootPath,SubDir),[RootFile FileIndices FileExt]); |
---|
637 | % initiate the input file series and inputfilerefresh the current field view: |
---|
638 | errormsg=update_rootinfo(handles,i1_series,i2_series,j1_series,j2_series,FileType,MovieObject,2); |
---|
639 | end |
---|
640 | |
---|
641 | if isempty(errormsg) |
---|
642 | set(handles.InputFileREFRESH,'BackgroundColor',[1 0 0])% set button color to red to indicate that refresh has been updated |
---|
643 | else |
---|
644 | set(handles.InputFileREFRESH,'BackgroundColor',[1 0 1])% keep button color magenta, input not succesfull |
---|
645 | end |
---|
646 | |
---|
647 | %------------------------------------------------------------------------ |
---|
648 | % --- Fills the edit boxes RootPath, RootFile,NomType...from an input file name 'fileinput' |
---|
649 | function display_file_name(handles,fileinput,index) |
---|
650 | %------------------------------------------------------------------------ |
---|
651 | %% look for the input file existence |
---|
652 | if ~exist(fileinput,'file') |
---|
653 | msgbox_uvmat('ERROR',['input file ' fileinput ' does not exist']) |
---|
654 | return |
---|
655 | end |
---|
656 | |
---|
657 | %% define the relevant handles for the first field series (index=1) or the second file series (index=2) |
---|
658 | if ~exist('index','var') |
---|
659 | index=1; |
---|
660 | end |
---|
661 | if index==1 |
---|
662 | handles_RootPath=handles.RootPath; |
---|
663 | handles_SubDir=handles.SubDir; |
---|
664 | handles_RootFile=handles.RootFile; |
---|
665 | handles_FileIndex=handles.FileIndex; |
---|
666 | handles_NomType=handles.NomType; |
---|
667 | handles_FileExt=handles.FileExt; |
---|
668 | elseif index==2 |
---|
669 | handles_RootPath=handles.RootPath_1; |
---|
670 | handles_SubDir=handles.SubDir_1; |
---|
671 | handles_RootFile=handles.RootFile_1; |
---|
672 | handles_FileIndex=handles.FileIndex_1; |
---|
673 | handles_NomType=handles.NomType_1; |
---|
674 | handles_FileExt=handles.FileExt_1; |
---|
675 | set(handles.RootPath_1,'Visible','on') |
---|
676 | set(handles.RootFile_1,'Visible','on') |
---|
677 | set(handles.SubDir_1,'Visible','on'); |
---|
678 | set(handles.FileIndex_1,'Visible','on'); |
---|
679 | set(handles.FileExt_1,'Visible','on'); |
---|
680 | set(handles.NomType_1,'Visible','on'); |
---|
681 | set(handles.TimeName_1,'Visible','on') |
---|
682 | set(handles.TimeValue_1,'Visible','on') |
---|
683 | end |
---|
684 | set(handles.InputFileREFRESH,'BackgroundColor',[1 1 0])% paint REFRESH button to yellow to visualise root file input |
---|
685 | set(handles.uvmat,'Pointer','watch') % set the mouse pointer to 'watch' |
---|
686 | drawnow |
---|
687 | |
---|
688 | %% detect root name, nomenclature and indices in the input file name: |
---|
689 | [FilePath,FileName,FileExt]=fileparts(fileinput); |
---|
690 | % detect the file type, get the movie object if relevant, and look for the corresponding file series: |
---|
691 | % the root name and indices may be corrected by including the first index i1 if a corresponding xml file exists |
---|
692 | [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]); |
---|
693 | |
---|
694 | if strcmp(FileType,'txt') |
---|
695 | try |
---|
696 | edit(fileinput) |
---|
697 | catch ME |
---|
698 | msgbox_uvmat('ERROR','invalid intput file') |
---|
699 | end |
---|
700 | return |
---|
701 | elseif strcmp(FileType,'xml') |
---|
702 | editxml(fileinput) |
---|
703 | return |
---|
704 | elseif strcmp(FileType,'figure') |
---|
705 | open(fileinput) |
---|
706 | return |
---|
707 | end |
---|
708 | |
---|
709 | %% open the file or fill the GUI uvmat according to the detected file type |
---|
710 | switch FileType |
---|
711 | case '' |
---|
712 | msgbox_uvmat('ERROR','invalid input file type') |
---|
713 | case 'txt' |
---|
714 | edit(fileinput) |
---|
715 | case 'figure' %display matlab figure |
---|
716 | hfig=open(fileinput); |
---|
717 | set(hfig,'WindowButtonMotionFcn','mouse_motion')%set mouse action functio |
---|
718 | set(hfig,'WindowButtonUpFcn','mouse_up')%set mouse click action function |
---|
719 | set(hfig,'WindowButtonUpFcn','mouse_down')%set mouse click action function |
---|
720 | case 'xml' % edit xml files |
---|
721 | t=xmltree(fileinput); |
---|
722 | % the xml file marks a project or project link, open datatree_browser |
---|
723 | if strcmp(get(t,1,'name'),'Project')&& exist(regexprep(fileinput,'.xml$',''),'dir') |
---|
724 | datatree_browser(fileinput) |
---|
725 | else % other xml file, open the xml editor |
---|
726 | editxml(fileinput); |
---|
727 | end |
---|
728 | case 'xls'% Excel file opended by editxml |
---|
729 | editxml(fileinput); |
---|
730 | otherwise |
---|
731 | set(handles_RootPath,'String',RootPath); |
---|
732 | rootname=fullfile(RootPath,SubDir,RootFile); |
---|
733 | set(handles_SubDir,'String',['/' SubDir]); |
---|
734 | set(handles_RootFile,'String',['/' RootFile]); %display the separator |
---|
735 | indices=fileinput(length(rootname)+1:end); |
---|
736 | indices(end-length(FileExt)+1:end)=[]; %remove extension |
---|
737 | set(handles_FileIndex,'String',indices); |
---|
738 | set(handles_NomType,'String',NomType); |
---|
739 | set(handles_FileExt,'String',FileExt); |
---|
740 | if index==1 |
---|
741 | % fill file index counters if the first file series is opened |
---|
742 | set(handles.i1,'String',num2str(i1)); |
---|
743 | set(handles.i2,'String',num2str(i2)); |
---|
744 | set(handles.j1,'String',num2stra(j1,NomType)); |
---|
745 | set(handles.j2,'String',num2stra(j2,NomType)); |
---|
746 | else %read the current field index to synchronise with the first series |
---|
747 | i1_s=str2num(get(handles.i1,'String')); |
---|
748 | i2_0=str2num(get(handles.i2,'String')); |
---|
749 | if ~isempty(i2_0) |
---|
750 | i2_s=i2_0; |
---|
751 | else |
---|
752 | i2_s=i2; |
---|
753 | end |
---|
754 | j1_0=stra2num(get(handles.j1,'String')); |
---|
755 | if ~isempty(j1_0) |
---|
756 | j1_s=j1_0; |
---|
757 | else |
---|
758 | j1_s=j1; |
---|
759 | end |
---|
760 | j2_0=stra2num(get(handles.j2,'String')); |
---|
761 | if ~isempty(j2_0) |
---|
762 | j2_s=j2_0; |
---|
763 | else |
---|
764 | j2_s=j2; |
---|
765 | end |
---|
766 | end |
---|
767 | |
---|
768 | % synchronise indices of the second input file if it exists |
---|
769 | if get(handles.SubField,'Value')==1% if the subfield button is activated, update the field numbers |
---|
770 | Input=read_GUI(handles.InputFile); |
---|
771 | if ~isfield(Input,'RootPath_1')||strcmp(Input.RootPath_1,'"') |
---|
772 | Input.RootPath_1=Input.RootPath; |
---|
773 | end |
---|
774 | if ~isfield(Input,'SubDir_1')||strcmp(Input.SubDir_1,'"') |
---|
775 | Input.SubDir_1=Input.SubDir; |
---|
776 | end |
---|
777 | if ~isfield(Input,'RootFile_1')||strcmp(Input.RootFile_1,'"') |
---|
778 | Input.RootFile_1=Input.RootFile; |
---|
779 | end |
---|
780 | if ~isfield(Input,'FileExt_1')||strcmp(Input.FileExt_1,'"') |
---|
781 | Input.FileExt_1=Input.FileExt; |
---|
782 | end |
---|
783 | if ~isfield(Input,'NomType_1')||strcmp(Input.NomType_1,'"') |
---|
784 | Input.NomType_1=Input.NomType; |
---|
785 | end |
---|
786 | %updtate the indices of the second field series to correspond to the newly opened one |
---|
787 | 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); |
---|
788 | if exist(FileName_1,'file') |
---|
789 | FileIndex_1=fullfile_uvmat('','','','',Input.NomType_1,i1_s,i2_s,j1_s,j2_s); |
---|
790 | else |
---|
791 | FileIndex_1=fullfile_uvmat('','','','',Input.NomType_1,i1,i2,j1,j2); |
---|
792 | msgbox_uvmat('WARNING','unable to synchronise the indices of the two series') |
---|
793 | end |
---|
794 | set(handles.FileIndex_1,'String',FileIndex_1) |
---|
795 | end |
---|
796 | |
---|
797 | %enable other menus |
---|
798 | set(handles.MenuOpenCampaign,'Enable','on') |
---|
799 | set(handles.MenuExport,'Enable','on') |
---|
800 | set(handles.MenuExportFigure,'Enable','on') |
---|
801 | set(handles.MenuExportMovie,'Enable','on') |
---|
802 | set(handles.MenuTools,'Enable','on') |
---|
803 | |
---|
804 | % initiate input file series and inputfilerefresh the current field view: |
---|
805 | update_rootinfo(handles,i1_series,i2_series,j1_series,j2_series,FileType,MovieObject,index); |
---|
806 | |
---|
807 | end |
---|
808 | |
---|
809 | %% update list of recent files in the menubar and save it for future opening |
---|
810 | MenuFile=[{get(handles.MenuFile_1,'Label')};{get(handles.MenuFile_2,'Label')};... |
---|
811 | {get(handles.MenuFile_3,'Label')};{get(handles.MenuFile_4,'Label')};{get(handles.MenuFile_5,'Label')}]; |
---|
812 | str_find=strcmp(fileinput,MenuFile); |
---|
813 | if isempty(find(str_find,1)) |
---|
814 | MenuFile=[{fileinput};MenuFile];%insert the current file if not already in the list |
---|
815 | end |
---|
816 | for ifile=1:min(length(MenuFile),5) |
---|
817 | set(handles.(['MenuFile_' num2str(ifile)]),'Label',MenuFile{ifile}); |
---|
818 | %set(handles.(['MenuFile_' num2str(ifile) '_1']),'Label',MenuFile{ifile}); |
---|
819 | end |
---|
820 | dir_perso=prefdir; |
---|
821 | profil_perso=fullfile(dir_perso,'uvmat_perso.mat'); |
---|
822 | if exist(profil_perso,'file') |
---|
823 | save (profil_perso,'MenuFile','RootPath','-append'); %store the file names for future opening of uvmat |
---|
824 | else |
---|
825 | save (profil_perso,'MenuFile','RootPath','-V6'); %store the file names for future opening of uvmat |
---|
826 | end |
---|
827 | |
---|
828 | set(handles.InputFileREFRESH,'BackgroundColor',[1 0 0])% paint back button to red to indicate update is finished |
---|
829 | set(handles.uvmat,'Pointer','arrow')% set back the mouse pointer to arrow |
---|
830 | |
---|
831 | |
---|
832 | %------------------------------------------------------------------------ |
---|
833 | % --- Update information about a new field series (indices to scan, timing, |
---|
834 | % calibration from an xml file, then inputfilerefresh current plots |
---|
835 | function errormsg=update_rootinfo(handles,i1_series,i2_series,j1_series,j2_series,FileType,VideoObject,index) |
---|
836 | %------------------------------------------------------------------------ |
---|
837 | errormsg=''; %default error msg |
---|
838 | %% define the relevant handles depending on the index (1=first file series, 2= second file series) |
---|
839 | if ~exist('index','var') |
---|
840 | index=1; |
---|
841 | end |
---|
842 | if index==1 |
---|
843 | handles_Fields=handles.FieldName; |
---|
844 | elseif index==2 |
---|
845 | handles_Fields=handles.FieldName_1; |
---|
846 | end |
---|
847 | |
---|
848 | set(handles.FieldName,'UserData',[])% reinialize data from uvmat opening |
---|
849 | UvData=get(handles.uvmat,'UserData');%huvmat=handles of the uvmat interface |
---|
850 | UvData.NewSeries=1; %flag for REFRESH: begin a new series |
---|
851 | UvData.FileName_1='';% name of the current second field (used to detect a constant field during file scanning) |
---|
852 | UvData.FileType{index}=FileType; |
---|
853 | UvData.i1_series{index}=i1_series; |
---|
854 | UvData.i2_series{index}=i2_series; |
---|
855 | UvData.j1_series{index}=j1_series; |
---|
856 | UvData.j2_series{index}=j2_series; |
---|
857 | set(handles.FixVelType,'Value',0); %desactivate fixed veltype |
---|
858 | if index==1 |
---|
859 | [RootPath,SubDir,RootFile,FileIndices,FileExt]=read_file_boxes(handles); |
---|
860 | else |
---|
861 | [RootPath,SubDir,RootFile,FileIndices,FileExt]=read_file_boxes_1(handles); |
---|
862 | end |
---|
863 | FileName=[fullfile(RootPath,SubDir,RootFile) FileIndices FileExt]; |
---|
864 | FileBase=fullfile(RootPath,RootFile); |
---|
865 | if ~exist(FileName,'file') |
---|
866 | errormsg=['input file ' FileName ' not found']; |
---|
867 | msgbox_uvmat('ERROR',errormsg); |
---|
868 | return |
---|
869 | end |
---|
870 | |
---|
871 | %% read timing and total frame number from the current file (movie files) !! may be overrid by xml file |
---|
872 | TimeUnit='';%default |
---|
873 | TimeName='';%default |
---|
874 | XmlData.Time=[];%default |
---|
875 | imainfo=[]; |
---|
876 | ColorType='falsecolor'; %default |
---|
877 | UvData.MovieObject{index}=VideoObject; |
---|
878 | if ~isempty(VideoObject)% case of video data |
---|
879 | imainfo=get(VideoObject); |
---|
880 | TimeUnit='s'; |
---|
881 | if isempty(j1_series); %frame index along i |
---|
882 | XmlData.Time=zeros(imainfo.NumberOfFrames+1,2); |
---|
883 | XmlData.Time(:,2)=(0:1/imainfo.FrameRate:(imainfo.NumberOfFrames)/imainfo.FrameRate)'; |
---|
884 | else |
---|
885 | XmlData.Time=[0;ones(size(i1_series,3)-1,1)]*(0:1/imainfo.FrameRate:(imainfo.NumberOfFrames)/imainfo.FrameRate); |
---|
886 | end |
---|
887 | %set(handles.Dt_txt,'String',['Dt=' num2str(1000/imainfo.FrameRate) 'ms']);%display the elementary time interval in millisec |
---|
888 | TimeName='video'; |
---|
889 | ColorType='truecolor'; |
---|
890 | elseif ~isempty(FileExt(2:end))&&(~isempty(imformats(FileExt(2:end))) || isequal(FileExt,'.vol'))%&& isequal(NomType,'*')% multi-frame image |
---|
891 | if ~isequal(SubDir,'') |
---|
892 | imainfo=imfinfo([fullfile(RootPath,SubDir,RootFile) FileIndices FileExt]); |
---|
893 | else |
---|
894 | imainfo=imfinfo([FileBase FileIndices FileExt]); |
---|
895 | end |
---|
896 | ColorType=imainfo.ColorType;%='truecolor' for color images |
---|
897 | end |
---|
898 | if isfield(imainfo,'Width') && isfield(imainfo,'Height') |
---|
899 | if length(imainfo)>1 |
---|
900 | set(handles.num_Npx,'String',num2str(imainfo(1).Width));%fills nbre of pixels x box |
---|
901 | set(handles.num_Npy,'String',num2str(imainfo(1).Height));%fills nbre of pixels x box |
---|
902 | else |
---|
903 | set(handles.num_Npx,'String',num2str(imainfo.Width));%fills nbre of pixels x box |
---|
904 | set(handles.num_Npy,'String',num2str(imainfo.Height));%fills nbre of pixels x box |
---|
905 | end |
---|
906 | else |
---|
907 | set(handles.num_Npx,'String','');%fills nbre of pixels x box |
---|
908 | set(handles.num_Npy,'String','');%fills nbre of pixels x box |
---|
909 | end |
---|
910 | set(handles.CheckBW,'Value',strcmp(ColorType,'grayscale'))% select handles.CheckBW if grayscale image |
---|
911 | |
---|
912 | %% read parameters (time, geometric calibration..) from a documentation file (.xml advised) |
---|
913 | XmlData.GeometryCalib=[];%default |
---|
914 | XmlFileName=find_imadoc(RootPath,SubDir,RootFile,FileExt); |
---|
915 | [tild,tild,DocExt]=fileparts(XmlFileName); |
---|
916 | warntext='';%default warning message |
---|
917 | NbSlice=1;%default |
---|
918 | ImaDoc_str=''; |
---|
919 | set(handles.InputFileREFRESH,'BackgroundColor',[1 1 0]) |
---|
920 | if ~isempty(XmlFileName) |
---|
921 | set(handles.view_xml,'Visible','on') |
---|
922 | set(handles.view_xml,'BackgroundColor',[1 1 0])% paint to yellow color to indicate reading of the xml file |
---|
923 | set(handles.view_xml,'String','view .xml') |
---|
924 | drawnow |
---|
925 | [XmlDataRead,warntext]=imadoc2struct(XmlFileName); |
---|
926 | if ~isempty(warntext) |
---|
927 | msgbox_uvmat('WARNING',warntext) |
---|
928 | end |
---|
929 | if ~isempty(XmlDataRead) |
---|
930 | ImaDoc_str=['view ' DocExt]; % DocExt= '.xml' or .civ (obsolete case) |
---|
931 | %XmlData=XmlDataRead; |
---|
932 | if isfield(XmlDataRead,'TimeUnit')&& ~isempty(XmlDataRead.TimeUnit) |
---|
933 | TimeUnit=XmlDataRead.TimeUnit; |
---|
934 | end |
---|
935 | if isfield(XmlDataRead,'Time')&& ~isempty(XmlDataRead.Time) |
---|
936 | XmlData.Time=XmlDataRead.Time; |
---|
937 | end |
---|
938 | set(handles.view_xml,'BackgroundColor',[1 1 1])% paint back to white |
---|
939 | drawnow |
---|
940 | if isfield(XmlDataRead, 'GeometryCalib') && ~isempty(XmlDataRead.GeometryCalib) |
---|
941 | XmlData.GeometryCalib=XmlDataRead.GeometryCalib; |
---|
942 | if isfield(XmlData.GeometryCalib,'VolumeScan') && isequal(XmlData.GeometryCalib.VolumeScan,'y') |
---|
943 | set (handles.slices,'String','volume') |
---|
944 | end |
---|
945 | % check whether the GUI geometry_calib is opened |
---|
946 | hgeometry_calib=findobj('tag','geometry_calib'); |
---|
947 | if ~isempty(hgeometry_calib) % check whether the display of the GUI geometry_calib is consistent with the current calib param |
---|
948 | GUserData=get(hgeometry_calib,'UserData'); |
---|
949 | if ~(isfield(GUserData,'XmlInputFile') && strcmp(GUserData.XmlInputFile,XmlFileName)) |
---|
950 | answer=msgbox_uvmat('INPUT_Y-N','refresh the display of the GUI geometry_calib with the new input data?'); |
---|
951 | if strcmp(answer,'Yes') |
---|
952 | geometry_calib(XmlFileName);%diplay the new calibration points and parameters in geometry_calib |
---|
953 | end |
---|
954 | end |
---|
955 | end |
---|
956 | end |
---|
957 | end |
---|
958 | end |
---|
959 | if isempty(ImaDoc_str) |
---|
960 | set(handles.view_xml,'Visible','off') % no .xml (or .civ) file detected |
---|
961 | else |
---|
962 | set(handles.view_xml,'String',ImaDoc_str)% indicate that a xml file has been detected |
---|
963 | end |
---|
964 | |
---|
965 | %% Define timing |
---|
966 | % time not set by the input file: images or civ data: indicate that time is read from the xml file |
---|
967 | if isfield(XmlData,'Time')&& ~isempty(XmlData.Time) && ... |
---|
968 | (strcmp(FileType,'image')|| strcmp(FileType,'multimage')||strcmp(FileType,'civdata')||strcmp(FileType,'civx')) |
---|
969 | TimeName='xml'; |
---|
970 | elseif strcmp(FileType,'civdata') |
---|
971 | TimeName='civdata'; |
---|
972 | elseif strcmp(FileType,'civx') |
---|
973 | TimeName='civx'; |
---|
974 | end |
---|
975 | if index==1 |
---|
976 | set(handles.TimeName,'String',TimeName) |
---|
977 | else |
---|
978 | set(handles.TimeName_1,'String',TimeName) |
---|
979 | set(handles.TimeName_1,'Visible','on') |
---|
980 | end |
---|
981 | |
---|
982 | %% store last index in handles.MaxIndex_i and .MaxIndex_j |
---|
983 | nbfield=max(max(max(i2_series))); |
---|
984 | if isempty(nbfield) |
---|
985 | nbfield=max(max(max(i1_series))); |
---|
986 | end |
---|
987 | nbfield_j=max(max(max(j2_series))); |
---|
988 | if isempty(nbfield_j) |
---|
989 | nbfield_j=max(max(max(j1_series))); |
---|
990 | end |
---|
991 | if isfield(XmlData,'Time')&& ~isempty(XmlData.Time) |
---|
992 | %transform .Time to a column vector if it is a line vector the nomenclature uses a single index |
---|
993 | if isequal(size(XmlData.Time,1),1) |
---|
994 | XmlData.Time=(XmlData.Time)'; |
---|
995 | end |
---|
996 | end |
---|
997 | last_i_cell=get(handles.MaxIndex_i,'String'); |
---|
998 | if isempty(nbfield) |
---|
999 | last_i_cell{index}=''; |
---|
1000 | else |
---|
1001 | last_i_cell{index}=num2str(nbfield); |
---|
1002 | end |
---|
1003 | set(handles.MaxIndex_i,'String',last_i_cell) |
---|
1004 | last_j_cell=get(handles.MaxIndex_j,'String'); |
---|
1005 | if isempty(nbfield_j) |
---|
1006 | last_j_cell{index}=''; |
---|
1007 | else |
---|
1008 | last_j_cell{index}=num2str(nbfield_j); |
---|
1009 | end |
---|
1010 | set(handles.MaxIndex_j,'String',last_j_cell); |
---|
1011 | |
---|
1012 | %% store geometric calibration in UvData |
---|
1013 | if isfield(XmlData,'GeometryCalib') |
---|
1014 | GeometryCalib=XmlData.GeometryCalib; |
---|
1015 | if isempty(GeometryCalib) |
---|
1016 | set(handles.pxcmx,'String','') |
---|
1017 | set(handles.pxcmy,'String','') |
---|
1018 | set(handles.pxcmx,'Visible','off') |
---|
1019 | set(handles.pxcmy,'Visible','off') |
---|
1020 | set(handles.TransformName,'Value',1); % no transform by default |
---|
1021 | else |
---|
1022 | set(handles.pxcmx,'Visible','on') |
---|
1023 | set(handles.pxcmy,'Visible','on') |
---|
1024 | if (isfield(GeometryCalib,'R')&& ~isequal(GeometryCalib.R(2,1),0) && ~isequal(GeometryCalib.R(1,2),0)) ||... |
---|
1025 | (isfield(GeometryCalib,'kappa1')&& ~isequal(GeometryCalib.kappa1,0)) |
---|
1026 | set(handles.pxcmx,'String','var') |
---|
1027 | set(handles.pxcmy,'String','var') |
---|
1028 | elseif isfield(GeometryCalib,'fx_fy') |
---|
1029 | pixcmx=GeometryCalib.fx_fy(1);%*GeometryCalib.R(1,1)*GeometryCalib.sx/(GeometryCalib.Tz*GeometryCalib.dpx); |
---|
1030 | pixcmy=GeometryCalib.fx_fy(2);%*GeometryCalib.R(2,2)/(GeometryCalib.Tz*GeometryCalib.dpy); |
---|
1031 | set(handles.pxcmx,'String',num2str(pixcmx)) |
---|
1032 | set(handles.pxcmy,'String',num2str(pixcmy)) |
---|
1033 | end |
---|
1034 | if ~get(handles.CheckFixLimits,'Value') |
---|
1035 | set(handles.TransformName,'Value',3); % phys transform by default if fixedLimits is off |
---|
1036 | end |
---|
1037 | if isfield(GeometryCalib,'SliceCoord') |
---|
1038 | siz=size(GeometryCalib.SliceCoord); |
---|
1039 | if siz(1)>1 |
---|
1040 | NbSlice=siz(1); |
---|
1041 | set(handles.slices,'Visible','on') |
---|
1042 | set(handles.slices,'Value',1) |
---|
1043 | end |
---|
1044 | if isfield(GeometryCalib,'VolumeScan') && isequal(GeometryCalib.VolumeScan,'y') |
---|
1045 | set(handles.num_NbSlice,'Visible','off') |
---|
1046 | else |
---|
1047 | set(handles.num_NbSlice,'Visible','on') |
---|
1048 | set(handles.num_NbSlice,'String',num2str(NbSlice)) |
---|
1049 | end |
---|
1050 | slices_Callback([],[], handles) |
---|
1051 | end |
---|
1052 | end |
---|
1053 | end |
---|
1054 | |
---|
1055 | %% update the data attached to the uvmat interface |
---|
1056 | if ~isempty(TimeUnit) |
---|
1057 | if index==2 && isfield(UvData,'TimeUnit') && ~strcmp(UvData.TimeUnit,TimeUnit) |
---|
1058 | msgbox_uvmat('WARNING',['time unit for second file series ' TimeUnit ' inconsistent with first series']) |
---|
1059 | else |
---|
1060 | UvData.TimeUnit=TimeUnit; |
---|
1061 | end |
---|
1062 | end |
---|
1063 | UvData.XmlData{index}=XmlData; |
---|
1064 | UvData.NewSeries=1; |
---|
1065 | |
---|
1066 | %display warning message |
---|
1067 | if ~isequal(warntext,'') |
---|
1068 | msgbox_uvmat('WARNING',warntext); |
---|
1069 | end |
---|
1070 | |
---|
1071 | %% set default options in menu 'FieldName' |
---|
1072 | switch FileType |
---|
1073 | case {'civx','civdata'} |
---|
1074 | [FieldList,ColorList]=set_field_list('U','V','C'); |
---|
1075 | set(handles_Fields,'String',[{'image'};FieldList;{'get_field...'}]);%standard menu for civx data |
---|
1076 | set(handles_Fields,'Value',2) % set menu to 'velocity |
---|
1077 | if index==1 |
---|
1078 | set(handles.FieldName_1,'Value',1); |
---|
1079 | set(handles.FieldName_1,'String',[{''};{'image'};FieldList;{'get_field...'}]);%standard menu for civx data reproduced for the second field |
---|
1080 | end |
---|
1081 | set(handles.ColorScalar,'Value',1) |
---|
1082 | set(handles.ColorScalar,'String',ColorList) |
---|
1083 | set(handles.Vectors,'Visible','on') |
---|
1084 | set(handles.Coord_x,'Value',1); |
---|
1085 | set(handles.Coord_x,'String','X'); |
---|
1086 | % set(handles.Coord_y,'Value',1); |
---|
1087 | set(handles.Coord_y,'Data',{'Y'}); |
---|
1088 | case 'netcdf' |
---|
1089 | set(handles_Fields,'Value',1) |
---|
1090 | set(handles_Fields,'String',{'get_field...'}) |
---|
1091 | if index==1 |
---|
1092 | FieldName_Callback([],[], handles) |
---|
1093 | else |
---|
1094 | FieldName_1_Callback([],[], handles) |
---|
1095 | end |
---|
1096 | otherwise |
---|
1097 | set(handles_Fields,'Value',1) % set menu to 'image' |
---|
1098 | set(handles_Fields,'String',{'image'}) |
---|
1099 | set(handles.Coord_x,'Value',1); |
---|
1100 | set(handles.Coord_x,'String','AX'); |
---|
1101 | set(handles.Coord_y,'Data',{'AY'}); |
---|
1102 | end |
---|
1103 | set(handles.uvmat,'UserData',UvData) |
---|
1104 | |
---|
1105 | %% set index navigation options and inputfilerefresh plots |
---|
1106 | scan_option='i';%default |
---|
1107 | state_j='off'; %default |
---|
1108 | if index==2 |
---|
1109 | if get(handles.scan_j,'Value') |
---|
1110 | scan_option='j'; %keep the scan option for the second file series |
---|
1111 | end |
---|
1112 | if strcmp(get(handles.j1,'Visible'),'on') |
---|
1113 | state_j='on'; |
---|
1114 | end |
---|
1115 | end |
---|
1116 | [ref_j,ref_i]=find(squeeze(i1_series(1,:,:))); |
---|
1117 | if ~isempty(j1_series) |
---|
1118 | state_j='on'; |
---|
1119 | if index==1 |
---|
1120 | if isequal(ref_i,ref_i(1)*ones(size(ref_j)))% if ref_i is always equal to its first value |
---|
1121 | scan_option='j'; %scan j indext |
---|
1122 | end |
---|
1123 | end |
---|
1124 | end |
---|
1125 | if isequal(scan_option,'i') |
---|
1126 | diff_ref_i=diff(ref_i,1); |
---|
1127 | if isempty(diff_ref_i) |
---|
1128 | diff_ref_i=1; |
---|
1129 | end |
---|
1130 | if isequal (diff_ref_i,diff_ref_i(1)*ones(size(diff_ref_i))) |
---|
1131 | set(handles.num_IndexIncrement,'String',num2str(diff_ref_i(1))) |
---|
1132 | end |
---|
1133 | set(handles.scan_i,'Value',1) |
---|
1134 | scan_i_Callback([],[], handles); |
---|
1135 | else |
---|
1136 | diff_ref_j=diff(ref_j); |
---|
1137 | if isempty(diff_ref_j) |
---|
1138 | diff_ref_j=1; |
---|
1139 | end |
---|
1140 | if isequal (diff_ref_j,diff_ref_j(1)*ones(size(diff_ref_j))) |
---|
1141 | set(handles.num_IndexIncrement,'String',num2str(diff_ref_j(1))) |
---|
1142 | end |
---|
1143 | set(handles.scan_j,'Value',1) |
---|
1144 | scan_j_Callback([],[], handles); |
---|
1145 | end |
---|
1146 | set(handles.scan_j,'Visible',state_j) |
---|
1147 | set(handles.j1,'Visible',state_j) |
---|
1148 | set(handles.j2,'Visible',state_j) |
---|
1149 | set(handles.MaxIndex_j,'Visible',state_j); |
---|
1150 | %set(handles.frame_j,'Visible',state_j); |
---|
1151 | set(handles.j_text,'Visible',state_j); |
---|
1152 | if ~isempty(i2_series)||~isempty(j2_series) |
---|
1153 | set(handles.CheckFixPair,'Visible','on') |
---|
1154 | elseif index==1 |
---|
1155 | set(handles.CheckFixPair,'Visible','off') |
---|
1156 | end |
---|
1157 | |
---|
1158 | %% apply the effect of the transform fct and view the field |
---|
1159 | transform=get(handles.TransformPath,'UserData'); |
---|
1160 | if index==2 && (~isa(transform,'function_handle')||nargin(transform)<3) |
---|
1161 | set(handles.TransformName,'value',2); % set transform to sub_field if the current fct doe not accept two input fields |
---|
1162 | end |
---|
1163 | TransformName_Callback([],[],handles) |
---|
1164 | mask_test=get(handles.CheckMask,'value'); |
---|
1165 | if mask_test |
---|
1166 | MaskData=get(handles.CheckMask,'UserData'); |
---|
1167 | if isfield(MaskData,'maskhandle') && ishandle(MaskData.maskhandle) |
---|
1168 | delete(MaskData.maskhandle) %delete old mask |
---|
1169 | end |
---|
1170 | CheckMask_Callback([],[],handles) |
---|
1171 | end |
---|
1172 | |
---|
1173 | %------------------------------------------------------------------------ |
---|
1174 | % --- switch file index scanning options scan_i and scan_j in an exclusive way |
---|
1175 | %------------------------------------------------------------------------ |
---|
1176 | function scan_i_Callback(hObject, eventdata, handles) |
---|
1177 | |
---|
1178 | if get(handles.scan_i,'Value')==1 |
---|
1179 | set(handles.scan_j,'Value',0) |
---|
1180 | else |
---|
1181 | set(handles.scan_j,'Value',1) |
---|
1182 | end |
---|
1183 | scan_j_Callback(hObject, eventdata, handles) |
---|
1184 | |
---|
1185 | %------------------------------------------------------------------------ |
---|
1186 | % --- switch file index scanning options scan_i and scan_j in an exclusive way |
---|
1187 | %------------------------------------------------------------------------ |
---|
1188 | function scan_j_Callback(hObject, eventdata, handles) |
---|
1189 | |
---|
1190 | if get(handles.scan_j,'Value')==1 |
---|
1191 | set(handles.scan_i,'Value',0) |
---|
1192 | else |
---|
1193 | set(handles.scan_i,'Value',1) |
---|
1194 | set(handles.CheckFixPair,'Visible','off') |
---|
1195 | end |
---|
1196 | |
---|
1197 | %------------------------------------------------------------------------ |
---|
1198 | function i1_Callback(hObject, eventdata, handles) |
---|
1199 | %------------------------------------------------------------------------ |
---|
1200 | update_ij(handles,1) |
---|
1201 | |
---|
1202 | %------------------------------------------------------------------------ |
---|
1203 | function i2_Callback(hObject, eventdata, handles) |
---|
1204 | %------------------------------------------------------------------------ |
---|
1205 | update_ij(handles,2) |
---|
1206 | |
---|
1207 | %------------------------------------------------------------------------ |
---|
1208 | function j1_Callback(hObject, eventdata, handles) |
---|
1209 | %------------------------------------------------------------------------ |
---|
1210 | update_ij(handles,3) |
---|
1211 | |
---|
1212 | %------------------------------------------------------------------------ |
---|
1213 | function j2_Callback(hObject, eventdata, handles) |
---|
1214 | %------------------------------------------------------------------------ |
---|
1215 | update_ij(handles,4) |
---|
1216 | |
---|
1217 | %------------------------------------------------------------------------ |
---|
1218 | %--- update the index display after action on edit boxes i1, i2, j1 or j2 |
---|
1219 | %------------------------------------------------------------------------ |
---|
1220 | function update_ij(handles,index_rank) |
---|
1221 | |
---|
1222 | NomType=get(handles.NomType,'String'); |
---|
1223 | indices=get(handles.FileIndex,'String'); |
---|
1224 | [tild,tild,tild,i1,i2,j1,j2]=fileparts_uvmat(indices);% the indices for the second series taken from FileIndex |
---|
1225 | switch index_rank |
---|
1226 | case 1 |
---|
1227 | indices=fullfile_uvmat('','','','',NomType,stra2num(get(handles.i1,'String')),i2,j1,j2); |
---|
1228 | 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 |
---|
1229 | case 2 |
---|
1230 | indices=fullfile_uvmat('','','','',NomType,i1,stra2num(get(handles.i2,'String')),j1,j2); |
---|
1231 | 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 |
---|
1232 | case 3 |
---|
1233 | indices=fullfile_uvmat('','','','',NomType,i1,i2,stra2num(get(handles.j1,'String')),j2); |
---|
1234 | 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 |
---|
1235 | case 4 |
---|
1236 | indices=fullfile_uvmat('','','','',NomType,i1,i2,j1,stra2num(get(handles.j2,'String'))); |
---|
1237 | 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 |
---|
1238 | end |
---|
1239 | set(handles.FileIndex,'String',indices) |
---|
1240 | 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 |
---|
1241 | % update the second index if relevant |
---|
1242 | if strcmp(get(handles.FileIndex_1,'Visible'),'on') |
---|
1243 | NomType_1=get(handles.NomType_1,'String'); |
---|
1244 | indices_1=get(handles.FileIndex_1,'String'); |
---|
1245 | [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 |
---|
1246 | switch index_rank |
---|
1247 | case 1 |
---|
1248 | indices_1=fullfile_uvmat('','','','',NomType_1,stra2num(get(handles.i1,'String')),i2_1,j1_1,j2_1); |
---|
1249 | case 2 |
---|
1250 | indices_1=fullfile_uvmat('','','','',NomType_1,i1_1,stra2num(get(handles.i2,'String')),j1_1,j2_1); |
---|
1251 | case 3 |
---|
1252 | indices_1=fullfile_uvmat('','','','',NomType_1,i1_1,i2_1,stra2num(get(handles.j1,'String')),j2_1); |
---|
1253 | case 4 |
---|
1254 | indices_1=fullfile_uvmat('','','','',NomType_1,i1_1,i2_1,j1_1,stra2num(get(handles.j2,'String'))); |
---|
1255 | end |
---|
1256 | set(handles.FileIndex_1,'String',indices_1) |
---|
1257 | 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 |
---|
1258 | end |
---|
1259 | |
---|
1260 | %------------------------------------------------------------------------ |
---|
1261 | |
---|
1262 | %------------------------------------------------------------------------ |
---|
1263 | function slices_Callback(hObject, eventdata, handles) |
---|
1264 | %------------------------------------------------------------------------ |
---|
1265 | if strcmp(get(handles.slices,'String'),'slices') |
---|
1266 | if get(handles.slices,'Value')==1 |
---|
1267 | set(handles.num_NbSlice,'Visible','on') |
---|
1268 | set(handles.z_text,'Visible','on') |
---|
1269 | set(handles.z_index,'Visible','on') |
---|
1270 | num_NbSlice_Callback(hObject, eventdata, handles) |
---|
1271 | else |
---|
1272 | set(handles.num_NbSlice,'Visible','off') |
---|
1273 | set(handles.z_text,'Visible','off') |
---|
1274 | set(handles.z_index,'Visible','off') |
---|
1275 | set(handles.masklevel,'Value',1) |
---|
1276 | set(handles.masklevel,'String',{'1'}) |
---|
1277 | end |
---|
1278 | end |
---|
1279 | |
---|
1280 | %------------------------------------------------------------------------ |
---|
1281 | function num_NbSlice_Callback(hObject, eventdata, handles) |
---|
1282 | %------------------------------------------------------------------------ |
---|
1283 | mode=get(handles.slices,'String'); |
---|
1284 | nb_slice_str=get(handles.num_NbSlice,'String'); |
---|
1285 | if strcmp(mode,'volume') |
---|
1286 | z=stra2num(get(handles.j1,'String')); |
---|
1287 | else |
---|
1288 | num=str2double(get(handles.i1,'String')); |
---|
1289 | nbslice=str2double(get(handles.num_NbSlice,'String')); |
---|
1290 | z=mod(num-1,nbslice)+1; |
---|
1291 | end |
---|
1292 | set(handles.z_index,'String',num2str(z)) |
---|
1293 | for ilist=1:nbslice |
---|
1294 | list_index{ilist,1}=num2str(ilist); |
---|
1295 | end |
---|
1296 | set(handles.masklevel,'String',list_index) |
---|
1297 | set(handles.masklevel,'Value',z) |
---|
1298 | |
---|
1299 | %------------------------------------------------------------------------ |
---|
1300 | % --- Executes on button press in view_xml. |
---|
1301 | %------------------------------------------------------------------------ |
---|
1302 | function view_xml_Callback(hObject, eventdata, handles) |
---|
1303 | |
---|
1304 | % if TimeName defined, open the xml file corresponding to the first file |
---|
1305 | % series, else open the xml file corresponding to the second series |
---|
1306 | if isempty(get(handles.TimeName,'String'))% open the xml file corresponding to the secodn file series |
---|
1307 | [RootPath,SubDir,RootFile,FileIndices,FileExt]=read_file_boxes_1(handles); |
---|
1308 | else |
---|
1309 | [RootPath,SubDir,RootFile,FileIndices,FileExt]=read_file_boxes(handles); |
---|
1310 | end |
---|
1311 | option=get(handles.view_xml,'String'); |
---|
1312 | if isequal(option,'view .xml') |
---|
1313 | FileXml=fullfile(RootPath,[SubDir '.xml']); |
---|
1314 | if ~exist(FileXml,'file')% case of civ files , removes the extension for subdir |
---|
1315 | FileXml=fullfile(RootPath,[regexprep(SubDir,'\..+$','') '.xml']); |
---|
1316 | end |
---|
1317 | heditxml=editxml(FileXml); |
---|
1318 | end |
---|
1319 | |
---|
1320 | %------------------------------------------------------------------------ |
---|
1321 | % --- Executes on button press in CheckMask. |
---|
1322 | function CheckMask_Callback(hObject, eventdata, handles) |
---|
1323 | %------------------------------------------------------------------------ |
---|
1324 | %case of view mask selection |
---|
1325 | if isequal(get(handles.CheckMask,'Value'),1) |
---|
1326 | [RootPath,SubDir]=read_file_boxes(handles); |
---|
1327 | MaskSubDir=regexprep(SubDir,'\..*','');%take the root part of SubDir, before the first dot '.' |
---|
1328 | MaskPath=fullfile(RootPath,[MaskSubDir '.mask']); |
---|
1329 | mdetect=0; |
---|
1330 | if exist(MaskPath,'dir') |
---|
1331 | ListStruct=dir(MaskPath);%look for a mask file |
---|
1332 | ListCells=struct2cell(ListStruct);% transform dir struct to a cell arrray |
---|
1333 | check_dir=cell2mat(ListCells(4,:));% =1 for directories, =0 for files |
---|
1334 | ListFiles=ListCells(1,:);%list of file and dri names |
---|
1335 | ListFiles=ListFiles(~check_dir);%list of file names (excluding dir) |
---|
1336 | if ~isempty(ListFiles) |
---|
1337 | for ifile=1:numel(ListFiles) |
---|
1338 | [tild,tild,MaskExt]=fileparts(ListFiles{1}); |
---|
1339 | [tild,tild,MaskFile{ifile},i1_series,i2_series,j1_series,j2_series,MaskNomType,MaskFileType]=find_file_series(MaskPath,ListFiles{ifile},0); |
---|
1340 | if strcmp(MaskFileType,'image') && isempty(i2_series) && isempty(j2_series) |
---|
1341 | mdetect=1; |
---|
1342 | end |
---|
1343 | if ~strcmp(MaskFile{ifile},MaskFile{1}) |
---|
1344 | mdetect=0;% cancel detection test in case of multiple masks, use the brower for selection |
---|
1345 | break |
---|
1346 | end |
---|
1347 | end |
---|
1348 | end |
---|
1349 | RootPath=MaskPath; |
---|
1350 | end |
---|
1351 | if mdetect==0 |
---|
1352 | MaskFullName=uigetfile_uvmat('pick a mask image file:',RootPath,'image'); |
---|
1353 | if isempty(MaskFullName) |
---|
1354 | set(handles.CheckMask,'Value',0) |
---|
1355 | end |
---|
1356 | [MaskPath,MaskName,MaskExt]=fileparts(MaskFullName); |
---|
1357 | [tild,tild,MaskFile,i1_series,i2_series,j1_series,j2_series,MaskNomType]=find_file_series(MaskPath,[MaskName MaskExt],0); |
---|
1358 | if ~(isempty(i2_series) && isempty(j2_series)) |
---|
1359 | MaskNomType='*'; |
---|
1360 | end |
---|
1361 | end |
---|
1362 | Mask.Path=MaskPath; |
---|
1363 | if isempty(MaskFile) |
---|
1364 | Mask.File=''; |
---|
1365 | else |
---|
1366 | Mask.File=MaskFile{1}; |
---|
1367 | end |
---|
1368 | Mask.Ext=MaskExt; |
---|
1369 | Mask.NomType=MaskNomType; |
---|
1370 | set(handles.CheckMask,'UserData',Mask); |
---|
1371 | errormsg=update_mask(handles); |
---|
1372 | else % desactivate mask display |
---|
1373 | MaskData=get(handles.CheckMask,'UserData'); |
---|
1374 | if isfield(MaskData,'maskhandle') && ishandle(MaskData.maskhandle) |
---|
1375 | delete(MaskData.maskhandle) |
---|
1376 | end |
---|
1377 | set(handles.CheckMask,'UserData',[]) |
---|
1378 | UvData=get(handles.uvmat,'UserData'); |
---|
1379 | if isfield(UvData,'MaskName') |
---|
1380 | UvData=rmfield(UvData,'MaskName'); |
---|
1381 | set(handles.uvmat,'UserData',UvData) |
---|
1382 | end |
---|
1383 | set(handles.CheckMask,'BackgroundColor',[0.7 0.7 0.7]) |
---|
1384 | end |
---|
1385 | |
---|
1386 | %------------------------------------------------------------------------ |
---|
1387 | function errormsg=update_mask(handles) |
---|
1388 | %------------------------------------------------------------------------ |
---|
1389 | errormsg=[];%default |
---|
1390 | Mask=get(handles.CheckMask,'UserData'); |
---|
1391 | MaskIndex=1; |
---|
1392 | if strcmp(get(handles.z_index,'Visible'),'on') |
---|
1393 | MaskIndex=str2num(get(handles.z_index,'String')); |
---|
1394 | end |
---|
1395 | if isfield(Mask,'maskhandle')&& ishandle(Mask.maskhandle) |
---|
1396 | uistack(Mask.maskhandle,'top'); |
---|
1397 | end |
---|
1398 | MaskName=fullfile_uvmat(Mask.Path,'',Mask.File,Mask.Ext,Mask.NomType,MaskIndex); |
---|
1399 | UvData=get(handles.uvmat,'UserData'); |
---|
1400 | |
---|
1401 | %% update mask image if the mask is new |
---|
1402 | if ~ (isfield(UvData,'MaskName') && isequal(UvData.MaskName,MaskName)) |
---|
1403 | UvData.MaskName=MaskName; %update the recorded name on UvData |
---|
1404 | set(handles.uvmat,'UserData',UvData); |
---|
1405 | if ~exist(MaskName,'file') |
---|
1406 | if isfield(Mask,'maskhandle')&& ishandle(Mask.maskhandle) |
---|
1407 | delete(Mask.maskhandle) |
---|
1408 | end |
---|
1409 | else |
---|
1410 | %read mask image |
---|
1411 | [MaskField,tild,errormsg] = read_field(MaskName,'image'); |
---|
1412 | if ~isempty(errormsg) |
---|
1413 | return |
---|
1414 | end |
---|
1415 | npxy=size(MaskField.A); |
---|
1416 | if length(npxy)>2 |
---|
1417 | errormsg=[MaskName ' is not a grey scale image']; |
---|
1418 | return |
---|
1419 | elseif ~isa(MaskField.A,'uint8') |
---|
1420 | errormsg=[MaskName ' is not a 8 bit grey level image']; |
---|
1421 | return |
---|
1422 | end |
---|
1423 | MaskField.ZIndex=MaskIndex; |
---|
1424 | %px to phys or other transform on field |
---|
1425 | menu_transform=get(handles.TransformName,'String'); |
---|
1426 | choice_value=get(handles.TransformName,'Value'); |
---|
1427 | transform_name=menu_transform{choice_value};%name of the transform fct given by the menu 'transform_fct' |
---|
1428 | transform=get(handles.TransformPath,'UserData'); |
---|
1429 | if ~isequal(transform_name,'') && ~isequal(transform_name,'px') |
---|
1430 | if isfield(UvData,'XmlData') && isfield(UvData.XmlData{1},'GeometryCalib')%use geometry calib recorded from the ImaDoc xml file as first priority |
---|
1431 | Calib=UvData.XmlData{1}.GeometryCalib; |
---|
1432 | MaskField=transform(MaskField,UvData.XmlData{1}); |
---|
1433 | end |
---|
1434 | end |
---|
1435 | flagmask=MaskField.A < 200; |
---|
1436 | |
---|
1437 | %make brown color image |
---|
1438 | imflag(:,:,1)=0.9*flagmask; |
---|
1439 | imflag(:,:,2)=0.7*flagmask; |
---|
1440 | imflag(:,:,3)=zeros(size(flagmask)); |
---|
1441 | |
---|
1442 | %update mask image |
---|
1443 | hmask=[]; %default |
---|
1444 | if isfield(Mask,'maskhandle')&& ishandle(Mask.maskhandle) |
---|
1445 | hmask=Mask.maskhandle; |
---|
1446 | end |
---|
1447 | if ~isempty(hmask) |
---|
1448 | set(hmask,'CData',imflag) |
---|
1449 | set(hmask,'AlphaData',flagmask*0.6) |
---|
1450 | set(hmask,'XData',MaskField.AX); |
---|
1451 | set(hmask,'YData',MaskField.AY); |
---|
1452 | % uistack(hmask,'top') |
---|
1453 | else |
---|
1454 | axes(handles.PlotAxes) |
---|
1455 | hold on |
---|
1456 | Mask.maskhandle=image(MaskField.AX,MaskField.AY,imflag,'Tag','mask','HitTest','off','AlphaData',0.6*ones(size(flagmask))); |
---|
1457 | set(handles.CheckMask,'UserData',Mask) |
---|
1458 | end |
---|
1459 | end |
---|
1460 | end |
---|
1461 | |
---|
1462 | %------------------------------------------------------------------------ |
---|
1463 | %------------------------------------------------------------------------ |
---|
1464 | % III - MAIN InputFileREFRESH FUNCTIONS : 'FRAME PLOT' |
---|
1465 | %------------------------------------------------------------------------ |
---|
1466 | |
---|
1467 | %------------------------------------------------------------------------ |
---|
1468 | % --- Executes on button press in runplus: make one step forward and call |
---|
1469 | % --- InputFileREFRESH. The step forward is along the fieldname series 1 or 2 depending on |
---|
1470 | % --- the scan_i and scan_j check box (exclusive each other) |
---|
1471 | function runplus_Callback(hObject, eventdata, handles) |
---|
1472 | %------------------------------------------------------------------------ |
---|
1473 | |
---|
1474 | set(handles.runplus,'BackgroundColor',[1 1 0])%paint the command button in yellow |
---|
1475 | drawnow |
---|
1476 | increment=str2double(get(handles.num_IndexIncrement,'String')); %get the field increment d |
---|
1477 | if isnan(increment)% case of free increment: move to next available field index |
---|
1478 | increment='+'; |
---|
1479 | end |
---|
1480 | errormsg=runpm(hObject,eventdata,handles,increment); |
---|
1481 | if ~isempty(errormsg) |
---|
1482 | msgbox_uvmat('ERROR',errormsg); |
---|
1483 | end |
---|
1484 | set(handles.runplus,'BackgroundColor',[1 0 0])%paint the command button back to red |
---|
1485 | |
---|
1486 | %------------------------------------------------------------------------ |
---|
1487 | % --- Executes on button press in runmin: make one step backward and call |
---|
1488 | % --- InputFileREFRESH. The step backward is along the fieldname series 1 or 2 depending on |
---|
1489 | % --- the scan_i and scan_j check box (exclusive each other) |
---|
1490 | function runmin_Callback(hObject, eventdata, handles) |
---|
1491 | %------------------------------------------------------------------------ |
---|
1492 | |
---|
1493 | set(handles.runmin,'BackgroundColor',[1 1 0])%paint the command button in yellow |
---|
1494 | drawnow |
---|
1495 | increment=-str2double(get(handles.num_IndexIncrement,'String')); %get the field increment d |
---|
1496 | if isnan(increment)% case of free increment: move to previous available field index |
---|
1497 | increment='-'; |
---|
1498 | end |
---|
1499 | errormsg=runpm(hObject,eventdata,handles,increment); |
---|
1500 | if ~isempty(errormsg) |
---|
1501 | msgbox_uvmat('ERROR',errormsg); |
---|
1502 | end |
---|
1503 | set(handles.runmin,'BackgroundColor',[1 0 0])%paint the command button back to red |
---|
1504 | |
---|
1505 | %------------------------------------------------------------------------ |
---|
1506 | % -- Executes on button press in Movie: make a series of +> steps |
---|
1507 | function Movie_Callback(hObject, eventdata, handles) |
---|
1508 | %------------------------------------------------------------------------ |
---|
1509 | |
---|
1510 | set(handles.Movie,'BackgroundColor',[1 1 0])%paint the command button in yellow |
---|
1511 | drawnow |
---|
1512 | increment=str2double(get(handles.num_IndexIncrement,'String')); %get the field increment d |
---|
1513 | if isnan(increment)% case of free increment: move to next available field index |
---|
1514 | increment='+'; |
---|
1515 | end |
---|
1516 | set(handles.STOP,'Visible','on') |
---|
1517 | set(handles.speed,'Visible','on') |
---|
1518 | set(handles.speed_txt,'Visible','on') |
---|
1519 | set(handles.Movie,'BusyAction','queue') |
---|
1520 | UvData=get(handles.uvmat,'UserData'); |
---|
1521 | |
---|
1522 | while get(handles.Movie,'Value')==1 && get(handles.speed,'Value')~=0 && isequal(get(handles.Movie,'BusyAction'),'queue') % enable STOP command |
---|
1523 | errormsg=runpm(hObject,eventdata,handles,increment); |
---|
1524 | if ~isempty(errormsg) |
---|
1525 | set(handles.Movie,'BackgroundColor',[1 0 0])%paint the command buttonback to red |
---|
1526 | return |
---|
1527 | end |
---|
1528 | pause(1.02-get(handles.speed,'Value'))% wait for next image |
---|
1529 | end |
---|
1530 | if isfield(UvData,'aviobj') && ~isempty( UvData.aviobj), |
---|
1531 | UvData.aviobj=close(UvData.aviobj); |
---|
1532 | set(handles.uvmat,'UserData',UvData); |
---|
1533 | end |
---|
1534 | set(handles.Movie,'BackgroundColor',[1 0 0])%paint the command buttonback to red |
---|
1535 | |
---|
1536 | %------------------------------------------------------------------------ |
---|
1537 | % -- Executes on button press in Movie: make a series of <- steps |
---|
1538 | function MovieBackward_Callback(hObject, eventdata, handles) |
---|
1539 | %------------------------------------------------------------------------ |
---|
1540 | set(handles.MovieBackward,'BackgroundColor',[1 1 0])%paint the command button in yellow |
---|
1541 | drawnow |
---|
1542 | increment=-str2double(get(handles.num_IndexIncrement,'String')); %get the field increment d |
---|
1543 | if isnan(increment)% case of free increment: move to next available field index |
---|
1544 | increment='-'; |
---|
1545 | end |
---|
1546 | set(handles.STOP,'Visible','on') |
---|
1547 | set(handles.speed,'Visible','on') |
---|
1548 | set(handles.speed_txt,'Visible','on') |
---|
1549 | set(handles.MovieBackward,'BusyAction','queue') |
---|
1550 | UvData=get(handles.uvmat,'UserData'); |
---|
1551 | |
---|
1552 | while get(handles.MovieBackward,'Value')==1 && get(handles.speed,'Value')~=0 && isequal(get(handles.MovieBackward,'BusyAction'),'queue') % enable STOP command |
---|
1553 | errormsg=runpm(hObject,eventdata,handles,increment); |
---|
1554 | if ~isempty(errormsg) |
---|
1555 | set(handles.MovieBackward,'BackgroundColor',[1 0 0])%paint the command buttonback to red |
---|
1556 | return |
---|
1557 | end |
---|
1558 | pause(1.02-get(handles.speed,'Value'))% wait for next image |
---|
1559 | end |
---|
1560 | if isfield(UvData,'aviobj') && ~isempty( UvData.aviobj), |
---|
1561 | UvData.aviobj=close(UvData.aviobj); |
---|
1562 | set(handles.uvmat,'UserData',UvData); |
---|
1563 | end |
---|
1564 | set(handles.MovieBackward,'BackgroundColor',[1 0 0])%paint the command buttonback to red |
---|
1565 | |
---|
1566 | %------------------------------------------------------------------------ |
---|
1567 | function STOP_Callback(hObject, eventdata, handles) |
---|
1568 | %------------------------------------------------------------------------ |
---|
1569 | set(handles.movie_pair,'BusyAction','Cancel') |
---|
1570 | set(handles.movie_pair,'value',0) |
---|
1571 | set(handles.Movie,'BusyAction','Cancel') |
---|
1572 | set(handles.MovieBackward,'BusyAction','Cancel') |
---|
1573 | set(handles.MenuExportMovie,'BusyAction','Cancel') |
---|
1574 | %set(handles.movie_pair,'BackgroundColor',[1 0 0])%paint the command buttonback to red |
---|
1575 | set(handles.Movie,'BackgroundColor',[1 0 0])%paint the command buttonback to red |
---|
1576 | set(handles.MovieBackward,'BackgroundColor',[1 0 0])%paint the command buttonback to red |
---|
1577 | |
---|
1578 | %------------------------------------------------------------------------ |
---|
1579 | % --- function activated by runplus and run minus |
---|
1580 | function errormsg=runpm(hObject,eventdata,handles,increment) |
---|
1581 | %------------------------------------------------------------------------ |
---|
1582 | errormsg='';%default |
---|
1583 | %% check for movie pair status |
---|
1584 | movie_status=get(handles.movie_pair,'Value'); |
---|
1585 | if isequal(movie_status,1) |
---|
1586 | STOP_Callback(hObject, eventdata, handles)%interrupt movie pair if active |
---|
1587 | end |
---|
1588 | |
---|
1589 | %% read the current input file name(s) and field indices |
---|
1590 | InputFile=read_GUI(handles.InputFile); |
---|
1591 | InputFile.RootFile=regexprep(InputFile.RootFile,'^[\\/]|[\\/]$','');%suppress possible / or \ separator at the beginning or the end of the string |
---|
1592 | InputFile.SubDir=regexprep(InputFile.SubDir,'^[\\/]|[\\/]$','');%suppress possible / or \ separator at the beginning or the end of the string |
---|
1593 | FileExt=InputFile.FileExt; |
---|
1594 | NomType=InputFile.NomType; |
---|
1595 | % i1=str2num(get(handles.i1,'String'));%read the field indices (for movie, it is not given by the file name) |
---|
1596 | % i2=[];%default |
---|
1597 | % if strcmp(get(handles.i2,'Visible'),'on') |
---|
1598 | % i2=str2num(get(handles.i2,'String')); |
---|
1599 | % end |
---|
1600 | % j1=[]; |
---|
1601 | % if strcmp(get(handles.j1,'Visible'),'on') |
---|
1602 | % j1=stra2num(get(handles.j1,'String')); |
---|
1603 | % end |
---|
1604 | % j2=j1; |
---|
1605 | % if strcmp(get(handles.j2,'Visible'),'on') |
---|
1606 | % j2=stra2num(get(handles.j2,'String')); |
---|
1607 | % end |
---|
1608 | [tild,tild,tild,i1,i2,j1,j2]=fileparts_uvmat(InputFile.FileIndex);% check back the indices used |
---|
1609 | if isempty(i1) |
---|
1610 | i1=str2num(get(handles.i1,'String'));%read the field indices (for movie, it is not given by the file name) |
---|
1611 | elseif isempty(j1) && strcmp(get(handles.j1,'Visible'),'on') |
---|
1612 | j1=str2num(get(handles.j1,'String'));%case of indexed movie |
---|
1613 | end |
---|
1614 | sub_value= get(handles.SubField,'Value'); |
---|
1615 | if sub_value % a second input file has been entered |
---|
1616 | [InputFile.RootPath_1,InputFile.SubDir_1,InputFile.RootFile_1,InputFile.FileIndex_1,InputFile.FileExt_1,InputFile.NomType_1]=read_file_boxes_1(handles); |
---|
1617 | [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 |
---|
1618 | if isempty(i1_1) |
---|
1619 | i1_1=str2num(get(handles.i1,'String'));%read the field indices (for movie, it is not given by the file name) |
---|
1620 | elseif isempty(j1_1) && strcmp(get(handles.j1,'Visible'),'on') |
---|
1621 | j1_1=str2num(get(handles.j1,'String'));%case of indexed movie |
---|
1622 | end |
---|
1623 | else |
---|
1624 | filename_1=[]; |
---|
1625 | end |
---|
1626 | |
---|
1627 | %% increment (or decrement) the field indices and update the input filename(s) |
---|
1628 | if ~isnumeric(increment)% undefined increment value |
---|
1629 | set(handles.CheckFixPair,'Value',0) |
---|
1630 | end |
---|
1631 | CheckFixPair=get(handles.CheckFixPair,'Value')||(isempty(i2)&&isempty(j2)); |
---|
1632 | |
---|
1633 | % the pair i1-i2 or j1-j2 is imposed (check box CheckFixPair selected) |
---|
1634 | if CheckFixPair && isnumeric(increment) |
---|
1635 | if get(handles.scan_i,'Value')==1% case of scanning along index i |
---|
1636 | i1=i1+increment; |
---|
1637 | i2=i2+increment; |
---|
1638 | if sub_value |
---|
1639 | i1_1=i1_1+increment; |
---|
1640 | i2_1=i2_1+increment; |
---|
1641 | end |
---|
1642 | else % case of scanning along index j (burst numbers) |
---|
1643 | j1=j1+increment; |
---|
1644 | j2=j2+increment; |
---|
1645 | if sub_value |
---|
1646 | j1_1=j1_1+increment; |
---|
1647 | j2_1=j2_1+increment; |
---|
1648 | end |
---|
1649 | end |
---|
1650 | |
---|
1651 | % the pair i1-i2 or j1-j2 is free (check box CheckFixPair not selected): the list of existing indices recorded in UvData is used |
---|
1652 | else |
---|
1653 | UvData=get(handles.uvmat,'UserData'); |
---|
1654 | ref_i=i1; |
---|
1655 | if ~isempty(i2) |
---|
1656 | ref_i=floor((i1+i2)/2);% current reference index i |
---|
1657 | end |
---|
1658 | ref_j=1; |
---|
1659 | if ~isempty(j1) |
---|
1660 | ref_j=j1; |
---|
1661 | if ~isempty(j2) |
---|
1662 | ref_j=floor((j1+j2)/2);% current reference index j |
---|
1663 | end |
---|
1664 | end |
---|
1665 | if isnumeric(increment) |
---|
1666 | if get(handles.scan_i,'Value')==1% case of scanning along index i |
---|
1667 | ref_i=ref_i+increment;% increment the current reference index i |
---|
1668 | else % case of scanning along index j (burst numbers) |
---|
1669 | ref_j=ref_j+increment;% increment the current reference index j if scan_j option is used |
---|
1670 | end |
---|
1671 | else % free increment |
---|
1672 | runaction=get(gcbo,'tag'); |
---|
1673 | if strcmp(increment,'+')% if runplus or movie is activated |
---|
1674 | step=1; |
---|
1675 | else |
---|
1676 | step=-1; |
---|
1677 | end |
---|
1678 | if get(handles.scan_i,'Value')==1% case of scanning along index i |
---|
1679 | ref_i=ref_i+step; |
---|
1680 | while ref_i>=0 && size(UvData.i1_series{1},3)>=ref_i+1 && UvData.i1_series{1}(1,ref_j+1,ref_i+1)==0 |
---|
1681 | ref_i=ref_i+step; |
---|
1682 | end |
---|
1683 | else % case of scanning along index j (burst numbers) |
---|
1684 | ref_j=ref_j+step; |
---|
1685 | while ref_j>=0 && size(UvData.i1_series{1},2)>=ref_j+1 && UvData.i1_series{1}(1,ref_j+1,ref_i+1)==0 |
---|
1686 | ref_j=ref_j+step; |
---|
1687 | end |
---|
1688 | end |
---|
1689 | end |
---|
1690 | if ref_i<0 |
---|
1691 | errormsg='minimum i index reached'; |
---|
1692 | elseif ref_j<0 |
---|
1693 | errormsg='minimum j index reached'; |
---|
1694 | elseif ref_i+1>size(UvData.i1_series{1},3) |
---|
1695 | errormsg='maximum i index reached (reload the input file to update the index bound)'; |
---|
1696 | elseif ref_j+1>size(UvData.i1_series{1},2) |
---|
1697 | errormsg='maximum j index reached (reload the input file to update the index bound)'; |
---|
1698 | end |
---|
1699 | if ~isempty(errormsg),return,end |
---|
1700 | siz=size(UvData.i1_series{1}); |
---|
1701 | ref_indices=ref_i*siz(1)*siz(2)+ref_j*siz(1)+1:ref_i*siz(1)*siz(2)+(ref_j+1)*siz(1); |
---|
1702 | i1_subseries=UvData.i1_series{1}(ref_indices); |
---|
1703 | ref_indices=ref_indices(i1_subseries>0); |
---|
1704 | if isempty(ref_indices)% case of pairs (free index i) |
---|
1705 | ref_indices=ref_i*siz(1)*siz(2)+1:(ref_i+1)*siz(1)*siz(2); |
---|
1706 | i1_subseries=UvData.i1_series{1}(ref_indices); |
---|
1707 | ref_indices=ref_indices(i1_subseries>0); |
---|
1708 | end |
---|
1709 | if isempty(ref_indices),errormsg='no next frame: set num_IndexIncrement =''*'' to reach the next existing file';return |
---|
1710 | end |
---|
1711 | i1=UvData.i1_series{1}(ref_indices(end)); |
---|
1712 | if ~isempty(UvData.i2_series{1}) |
---|
1713 | i2=UvData.i2_series{1}(ref_indices(end)); |
---|
1714 | end |
---|
1715 | if ~isempty(UvData.j1_series{1}) |
---|
1716 | j1=UvData.j1_series{1}(ref_indices(end)); |
---|
1717 | end |
---|
1718 | if ~isempty(UvData.j2_series{1}) |
---|
1719 | j2=UvData.j2_series{1}(ref_indices(end)); |
---|
1720 | end |
---|
1721 | |
---|
1722 | % case of a second file series |
---|
1723 | if sub_value |
---|
1724 | ref_i_1=i1_1; |
---|
1725 | if ~isempty(i2_1) |
---|
1726 | ref_i_1=floor((i1_1+i2_1)/2);% current reference index i |
---|
1727 | end |
---|
1728 | ref_j_1=1; |
---|
1729 | if ~isempty(j1_1) |
---|
1730 | ref_j_1=j1_1; |
---|
1731 | if ~isempty(j2_1) |
---|
1732 | ref_j_1=floor((j1_1+j2_1)/2);% current reference index j |
---|
1733 | end |
---|
1734 | end |
---|
1735 | if isnumeric(increment) |
---|
1736 | if get(handles.scan_i,'Value')==1% case of scanning along index i |
---|
1737 | ref_i_1=ref_i_1+increment;% increment the current reference index i |
---|
1738 | else % case of scanning along index j (burst numbers) |
---|
1739 | ref_j_1=ref_j_1+increment;% increment the current reference index j if scan_j option is used |
---|
1740 | end |
---|
1741 | else % free increment, synchronise the ref indices with the first series |
---|
1742 | ref_i_1=ref_i; |
---|
1743 | ref_j_1=ref_j; |
---|
1744 | end |
---|
1745 | if numel(UvData.i1_series)==1 |
---|
1746 | UvData.i1_series{2}=UvData.i1_series{1}; |
---|
1747 | UvData.j1_series{2}=UvData.j1_series{1}; |
---|
1748 | UvData.i2_series{2}=UvData.i2_series{1}; |
---|
1749 | UvData.j2_series{2}=UvData.j2_series{1}; |
---|
1750 | end |
---|
1751 | if ref_i_1<0 |
---|
1752 | errormsg='minimum i index reached'; |
---|
1753 | elseif ref_j_1<0 |
---|
1754 | errormsg='minimum j index reached'; |
---|
1755 | elseif ref_i_1+1>size(UvData.i1_series{2},3) |
---|
1756 | errormsg='maximum i index reached for the second series (reload the input file to update the index bound)'; |
---|
1757 | elseif ref_j_1+1>size(UvData.i1_series{2},2) |
---|
1758 | errormsg='maximum j index reached for the second series(reload the input file to update the index bound)'; |
---|
1759 | end |
---|
1760 | if ~isempty(errormsg),return,end |
---|
1761 | siz=size(UvData.i1_series{2}); |
---|
1762 | 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); |
---|
1763 | i1_subseries=UvData.i1_series{2}(ref_indices); |
---|
1764 | ref_indices=ref_indices(i1_subseries>0); |
---|
1765 | if isempty(ref_indices)% case of pairs (free index i) |
---|
1766 | ref_indices=ref_i_1*siz(1)*siz(2)+1:(ref_i_1+1)*siz(1)*siz(2); |
---|
1767 | i1_subseries=UvData.i1_series{2}(ref_indices); |
---|
1768 | ref_indices=ref_indices(i1_subseries>0); |
---|
1769 | end |
---|
1770 | i1_1=UvData.i1_series{2}(ref_indices(end)); |
---|
1771 | if ~isempty(UvData.i2_series{2}) |
---|
1772 | i2_1=UvData.i2_series{2}(ref_indices(end)); |
---|
1773 | end |
---|
1774 | if ~isempty(UvData.j1_series{2}) |
---|
1775 | j1_1=UvData.j1_series{2}(ref_indices(end)); |
---|
1776 | end |
---|
1777 | if ~isempty(UvData.j2_series{2}) |
---|
1778 | j2_1=UvData.j2_series{1}(ref_indices(end)); |
---|
1779 | end |
---|
1780 | else% the second series (if needed) is the same file as the first |
---|
1781 | i1_1=i1; |
---|
1782 | i2_1=i2; |
---|
1783 | j1_1=j1; |
---|
1784 | j2_1=j2; |
---|
1785 | end |
---|
1786 | end |
---|
1787 | filename=fullfile_uvmat(InputFile.RootPath,InputFile.SubDir,InputFile.RootFile,FileExt,NomType,i1,i2,j1,j2); |
---|
1788 | |
---|
1789 | %% inputfilerefresh plots |
---|
1790 | if sub_value |
---|
1791 | 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); |
---|
1792 | errormsg=refresh_field(handles,filename,filename_1,i1,i2,j1,j2,i1_1,i2_1,j1_1,j2_1); |
---|
1793 | else |
---|
1794 | errormsg=refresh_field(handles,filename,filename_1,i1,i2,j1,j2); |
---|
1795 | end |
---|
1796 | set(handles.InputFileREFRESH,'BackgroundColor',[1 0 0]) |
---|
1797 | |
---|
1798 | %% update the index counters if the index move is successfull |
---|
1799 | if isempty(errormsg) |
---|
1800 | set(handles.i1,'String',num2stra(i1,NomType,1)); |
---|
1801 | if isequal(i2,i1) |
---|
1802 | set(handles.i2,'String',''); |
---|
1803 | else |
---|
1804 | set(handles.i2,'String',num2stra(i2,NomType,1)); |
---|
1805 | end |
---|
1806 | set(handles.j1,'String',num2stra(j1,NomType,2)); |
---|
1807 | if isequal(j2,j1) |
---|
1808 | set(handles.j2,'String',''); |
---|
1809 | else |
---|
1810 | set(handles.j2,'String',num2stra(j2,NomType,2)); |
---|
1811 | end |
---|
1812 | indices=fullfile_uvmat('','','','',NomType,i1,i2,j1,j2); |
---|
1813 | set(handles.FileIndex,'String',indices); |
---|
1814 | if ~isempty(filename_1) |
---|
1815 | indices_1=fullfile_uvmat('','','','',InputFile.NomType_1,i1_1,i2_1,j1_1,j2_1); |
---|
1816 | set(handles.FileIndex_1,'String',indices_1); |
---|
1817 | end |
---|
1818 | if isequal(movie_status,1) |
---|
1819 | set(handles.movie_pair,'Value',1) |
---|
1820 | movie_pair_Callback(hObject, eventdata, handles); %reactivate moviepair if it was activated |
---|
1821 | else |
---|
1822 | if isempty(i2), set(handles.i2,'String',''); end % suppress the second index display if not used |
---|
1823 | if isempty(j2), set(handles.j2,'String',''); end |
---|
1824 | end |
---|
1825 | set(handles.i1,'BackgroundColor',[1 1 1]) |
---|
1826 | set(handles.i2,'BackgroundColor',[1 1 1]) |
---|
1827 | set(handles.j1,'BackgroundColor',[1 1 1]) |
---|
1828 | set(handles.j2,'BackgroundColor',[1 1 1]) |
---|
1829 | set(handles.FileIndex,'BackgroundColor',[1 1 1]) |
---|
1830 | set(handles.FileIndex_1,'BackgroundColor',[1 1 1]) |
---|
1831 | end |
---|
1832 | |
---|
1833 | %------------------------------------------------------------------------ |
---|
1834 | % --- Executes on button press in movie_pair: create an alternating movie with two view |
---|
1835 | function movie_pair_Callback(hObject, eventdata, handles) |
---|
1836 | %------------------------------------------------------------------------ |
---|
1837 | |
---|
1838 | %% stop movie action if the movie_pair button is off |
---|
1839 | if ~get(handles.movie_pair,'value') |
---|
1840 | set(handles.movie_pair,'BusyAction','Cancel')%stop movie pair if button is 'off' |
---|
1841 | set(handles.i2,'String','') |
---|
1842 | set(handles.j2,'String','') |
---|
1843 | set(handles.Dt_txt,'String','') |
---|
1844 | return |
---|
1845 | else |
---|
1846 | set(handles.movie_pair,'BusyAction','queue') |
---|
1847 | set(handles.InputFileREFRESH,'BackgroundColor',[1 0 0]) |
---|
1848 | end |
---|
1849 | |
---|
1850 | %% initialisation |
---|
1851 | set(handles.movie_pair,'BackgroundColor',[1 1 0])%paint the command button in yellow |
---|
1852 | drawnow |
---|
1853 | list_fields=get(handles.FieldName,'String');% list menu fields |
---|
1854 | index_fields=get(handles.FieldName,'Value');% selected string index |
---|
1855 | FieldName=list_fields{index_fields}; % selected field |
---|
1856 | UvData=get(handles.uvmat,'UserData'); |
---|
1857 | if isequal(FieldName,'image') |
---|
1858 | index=1; |
---|
1859 | [RootPath,SubDir,RootFile,FileIndices,Ext]=read_file_boxes(handles); |
---|
1860 | NomType=get(handles.NomType,'String'); |
---|
1861 | else |
---|
1862 | list_fields=get(handles.FieldName_1,'String');% list menu fields |
---|
1863 | index_fields=get(handles.FieldName_1,'Value');% selected string index |
---|
1864 | FieldName=list_fields{index_fields}; % selected field |
---|
1865 | if isequal(FieldName,'image') |
---|
1866 | index=2; |
---|
1867 | [RootPath,SubDir,RootFile,FileIndex_1,Ext,NomType]=read_file_boxes_1(handles);% get info from the second input line |
---|
1868 | else |
---|
1869 | msgbox_uvmat('ERROR','an image or movie must be first introduced as input') |
---|
1870 | set(handles.movie_pair,'BackgroundColor',[1 0 0])%paint the command button in red |
---|
1871 | set(handles.movie_pair,'Value',0) |
---|
1872 | return |
---|
1873 | end |
---|
1874 | end |
---|
1875 | num_i1=str2num(get(handles.i1,'String')); |
---|
1876 | num_j1=stra2num(get(handles.j1,'String')); |
---|
1877 | num_i2=str2num(get(handles.i2,'String')); |
---|
1878 | num_j2=stra2num(get(handles.j2,'String')); |
---|
1879 | imaname_1=''; |
---|
1880 | if isempty(num_j2) |
---|
1881 | if isempty(num_i2) |
---|
1882 | if strcmp(get(handles.j2,'Visible'),'on') %if the j box is visible |
---|
1883 | imaname_1=fullfile_uvmat(RootPath,SubDir,RootFile,Ext,NomType,num_i1,[],num_j1+1); |
---|
1884 | end |
---|
1885 | if exist(imaname_1,'file') |
---|
1886 | num_j2=num_j1+1;% look by default for the next j index as the second file |
---|
1887 | set(handles.j2,'String',num2stra(num_j2,NomType)); |
---|
1888 | else |
---|
1889 | imaname_1=fullfile_uvmat(RootPath,SubDir,RootFile,Ext,NomType,num_i1+1,[],num_j1); |
---|
1890 | if exist(imaname_1,'file') |
---|
1891 | num_i2=num_i1+1; |
---|
1892 | set(handles.i2,'String',num2str(num_i2)); |
---|
1893 | else |
---|
1894 | msgbox_uvmat('ERROR', 'a second image index i2 or j2 is needed to show the pair as a movie') |
---|
1895 | set(handles.movie_pair,'BackgroundColor',[1 0 0])%paint the command button in red |
---|
1896 | set(handles.movie_pair,'Value',0) |
---|
1897 | return |
---|
1898 | end |
---|
1899 | end |
---|
1900 | else |
---|
1901 | num_j2=num_j1;%repeat the index i1 by default |
---|
1902 | end |
---|
1903 | end |
---|
1904 | if isempty(num_i2) |
---|
1905 | num_i2=num_i1;%repeat the index i1 by default |
---|
1906 | end |
---|
1907 | if isempty(num_j1) |
---|
1908 | num_j1=1; |
---|
1909 | end |
---|
1910 | if isempty(num_j2) |
---|
1911 | num_j2=num_j1;%repeat the index i1 by default |
---|
1912 | end |
---|
1913 | imaname_1=fullfile_uvmat(RootPath,SubDir,RootFile,Ext,NomType,num_i2,[],num_j2); |
---|
1914 | if strcmp(NomType,'*') |
---|
1915 | num_frame=num_i2; |
---|
1916 | else |
---|
1917 | num_frame=num_j2; |
---|
1918 | end |
---|
1919 | if ~exist(imaname_1,'file') |
---|
1920 | msgbox_uvmat('ERROR',['second input open (-) ' imaname_1 ' not found']); |
---|
1921 | set(handles.movie_pair,'BackgroundColor',[1 0 0])%paint the command button in red |
---|
1922 | set(handles.movie_pair,'Value',0) |
---|
1923 | return |
---|
1924 | end |
---|
1925 | |
---|
1926 | %% display time interval for the image pair |
---|
1927 | if isfield(UvData,'XmlData')&&isfield(UvData.XmlData{1},'Time')... |
---|
1928 | && size(UvData.XmlData{1}.Time,1)>=num_i2+1 && size(UvData.XmlData{1}.Time,2)>=num_j2+1 |
---|
1929 | dt=(UvData.XmlData{1}.Time(num_i2+1,num_j2+1)-UvData.XmlData{1}.Time(num_i1+1,num_j1+1)); |
---|
1930 | if isfield(UvData,'TimeUnit') |
---|
1931 | set(handles.Dt_txt,'String',['Dt=' num2str(1000*dt,3) ' m' UvData.TimeUnit] ) |
---|
1932 | else |
---|
1933 | set(handles.Dt_txt,'String',['Dt=' num2str(1000*dt,3) ' 10^(-3)'] ) |
---|
1934 | end |
---|
1935 | else |
---|
1936 | set(handles.Dt_txt,'String','') |
---|
1937 | end |
---|
1938 | |
---|
1939 | %% get the first image |
---|
1940 | %Field.AName='image'; |
---|
1941 | if index==1 |
---|
1942 | Field_a=UvData.Field;% movie on the second field |
---|
1943 | else |
---|
1944 | Field_a=UvData.Field_1;% movie on the first field |
---|
1945 | end |
---|
1946 | |
---|
1947 | %% read the second image |
---|
1948 | MovieObject=[]; |
---|
1949 | if numel(UvData.MovieObject)>=index |
---|
1950 | MovieObject=UvData.MovieObject{index}; |
---|
1951 | end |
---|
1952 | [Field_b,ParamOut,errormsg] = read_field(imaname_1,UvData.FileType{index},MovieObject,num_frame); |
---|
1953 | |
---|
1954 | %px to phys or other transform on field |
---|
1955 | transform=get(handles.TransformPath,'UserData'); |
---|
1956 | if ~isempty(transform) |
---|
1957 | if isfield(UvData,'XmlData') && numel(UvData.XmlData)>=index %use geometry calib recorded from the ImaDoc xml file as first priority |
---|
1958 | if index==2 |
---|
1959 | Field_a=transform(Field_a,UvData.XmlData{index});%the first field has been stored without transform |
---|
1960 | end |
---|
1961 | if nargin(transform)>=2 |
---|
1962 | Field_b=transform(Field_b,UvData.XmlData{index}); |
---|
1963 | else |
---|
1964 | Field_b=transform(Field_b); |
---|
1965 | end |
---|
1966 | end |
---|
1967 | end |
---|
1968 | |
---|
1969 | % make movie until movie speed is set to 0 or STOP is activated |
---|
1970 | hima=findobj(handles.PlotAxes,'Tag','ima');% %handles.PlotAxes =main plotting window (A GENERALISER) |
---|
1971 | set(handles.STOP,'Visible','on') |
---|
1972 | set(handles.speed,'Visible','on') |
---|
1973 | set(handles.speed_txt,'Visible','on') |
---|
1974 | set(handles.i2,'BackgroundColor',[1 1 1])% mark the edit box in white to indicate its use as input |
---|
1975 | set(handles.j2,'BackgroundColor',[1 1 1])% mark the edit box in white to indicate its use as input |
---|
1976 | set(handles.FileIndex,'BackgroundColor',[1 1 1])% mark the edit box in white to indicate its use as input |
---|
1977 | while get(handles.speed,'Value')~=0 && isequal(get(handles.movie_pair,'BusyAction'),'queue') % enable STOP command |
---|
1978 | % read and plot the series of images in non erase mode |
---|
1979 | set(hima,'CData',Field_b.A); |
---|
1980 | pause(1.02-get(handles.speed,'Value'));% wait for next image |
---|
1981 | set(hima,'CData',Field_a.A); |
---|
1982 | pause(1.02-get(handles.speed,'Value'));% wait for next image |
---|
1983 | end |
---|
1984 | set(handles.movie_pair,'BackgroundColor',[1 0 0])%paint the command button in red |
---|
1985 | set(handles.movie_pair,'Value',0) |
---|
1986 | set(handles.Dt_txt,'String','') |
---|
1987 | |
---|
1988 | %------------------------------------------------------------------------ |
---|
1989 | % --- Executes on button press in InputFileREFRESH. |
---|
1990 | function REFRESH_Callback(hObject, eventdata, handles) |
---|
1991 | %------------------------------------------------------------------------ |
---|
1992 | set(handles.REFRESH,'BackgroundColor',[1 1 0])%paint the command button in yellow |
---|
1993 | drawnow |
---|
1994 | [RootPath,SubDir,RootFile,FileIndex,FileExt]=read_file_boxes(handles); |
---|
1995 | [tild,tild,tild,i1,i2,j1,j2]=fileparts_uvmat(FileIndex);% check back the indices used |
---|
1996 | if isempty(i2), set(handles.i2,'String',''); end % suppress the second index display if not used |
---|
1997 | if isempty(j2), set(handles.j2,'String',''); end |
---|
1998 | filename=[fullfile(RootPath,SubDir,RootFile) FileIndex FileExt]; |
---|
1999 | filename_1='';%default |
---|
2000 | FileIndex_1=''; |
---|
2001 | if get(handles.SubField,'Value') |
---|
2002 | [RootPath_1,SubDir_1,RootFile_1,FileIndex_1,FileExt_1]=read_file_boxes_1(handles); |
---|
2003 | filename_1=[fullfile(RootPath_1,SubDir_1,RootFile_1) FileIndex_1 FileExt_1]; |
---|
2004 | end |
---|
2005 | num_i1=stra2num(get(handles.i1,'String')); |
---|
2006 | num_i2=stra2num(get(handles.i2,'String')); |
---|
2007 | num_j1=stra2num(get(handles.j1,'String')); |
---|
2008 | num_j2=stra2num(get(handles.j2,'String')); |
---|
2009 | [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 |
---|
2010 | if isempty(j1_1)% case of movies, the index is not given by file index |
---|
2011 | j1_1=num_j1; |
---|
2012 | end |
---|
2013 | |
---|
2014 | errormsg=refresh_field(handles,filename,filename_1,num_i1,num_i2,num_j1,num_j2,i1_1,i2_1,j1_1,j2_1); |
---|
2015 | |
---|
2016 | if ~isempty(errormsg) |
---|
2017 | msgbox_uvmat('ERROR',errormsg); |
---|
2018 | else |
---|
2019 | set(handles.i1,'BackgroundColor',[1 1 1]) |
---|
2020 | set(handles.i2,'BackgroundColor',[1 1 1]) |
---|
2021 | set(handles.j1,'BackgroundColor',[1 1 1]) |
---|
2022 | set(handles.j2,'BackgroundColor',[1 1 1]) |
---|
2023 | set(handles.FileIndex,'BackgroundColor',[1 1 1]) |
---|
2024 | set(handles.FileIndex_1,'BackgroundColor',[1 1 1]) |
---|
2025 | set(handles.REFRESH,'BackgroundColor',[1 0 0]) |
---|
2026 | end |
---|
2027 | |
---|
2028 | %------------------------------------------------------------------------ |
---|
2029 | % --- read the input files and inputfilerefresh all the plots, including projection. |
---|
2030 | % OUTPUT: |
---|
2031 | % errormsg: error message char string =[] by default |
---|
2032 | % INPUT: |
---|
2033 | % FileName: first input file (=[] in the absence of input file) |
---|
2034 | % FileName_1: second input file (=[] in the asbsence of second input file) |
---|
2035 | % num_i1,num_i2,num_j1,num_j2; frame indices |
---|
2036 | % i1_1,i2_1,j1_1,j2_1: frame indices for the second input file (needed if FileName_1 is not empty) |
---|
2037 | %------------------------------------------------------------------------ |
---|
2038 | function errormsg=refresh_field(handles,FileName,FileName_1,num_i1,num_i2,num_j1,num_j2,i1_1,i2_1,j1_1,j2_1) |
---|
2039 | %------------------------------------------------------------------------ |
---|
2040 | |
---|
2041 | %% initialisation |
---|
2042 | if ~exist('Field','var') |
---|
2043 | Field={}; |
---|
2044 | end |
---|
2045 | UvData=get(handles.uvmat,'UserData'); |
---|
2046 | if ishandle(handles.UVMAT_title) %remove title panel on uvmat |
---|
2047 | delete(handles.UVMAT_title) |
---|
2048 | end |
---|
2049 | |
---|
2050 | %% determine the main input file information for action |
---|
2051 | if ~exist(FileName,'file') |
---|
2052 | errormsg=['input file ' FileName ' does not exist']; |
---|
2053 | return |
---|
2054 | end |
---|
2055 | NomType=get(handles.NomType,'String'); |
---|
2056 | NomType_1=''; |
---|
2057 | if strcmp(get(handles.NomType_1,'Visible'),'on') |
---|
2058 | NomType_1=get(handles.NomType_1,'String'); |
---|
2059 | end |
---|
2060 | %update the z position index |
---|
2061 | mode_slice=get(handles.slices,'String'); |
---|
2062 | if strcmp(mode_slice,'volume') |
---|
2063 | z_index=num_j1; |
---|
2064 | set(handles.z_index,'String',num2str(z_index)) |
---|
2065 | else |
---|
2066 | nbslice=str2num(get(handles.num_NbSlice,'String')); |
---|
2067 | z_index=mod(num_i1-1,nbslice)+1; |
---|
2068 | set(handles.z_index,'String',num2str(z_index)) |
---|
2069 | end |
---|
2070 | % inputfilerefresh menu for save_mask if relevant |
---|
2071 | masknumber=get(handles.masklevel,'String'); |
---|
2072 | if length(masknumber)>=z_index |
---|
2073 | set(handles.masklevel,'Value',z_index) |
---|
2074 | end |
---|
2075 | |
---|
2076 | %% test for need of tps |
---|
2077 | check_proj_tps=0; |
---|
2078 | if (strcmp(UvData.FileType{1},'civdata')||strcmp(UvData.FileType{1},'civx')) |
---|
2079 | for iobj=1:numel(UvData.ProjObject) |
---|
2080 | if isfield(UvData.ProjObject{iobj},'ProjMode')&& strcmp(UvData.ProjObject{iobj}.ProjMode,'interp_tps') |
---|
2081 | check_proj_tps=1; |
---|
2082 | break |
---|
2083 | end |
---|
2084 | end |
---|
2085 | end |
---|
2086 | |
---|
2087 | %% read the first input field |
---|
2088 | ParamIn.ColorVar='';%default variable name for vector color |
---|
2089 | frame_index=1;%default |
---|
2090 | FieldName='';%default |
---|
2091 | VelType='';%default |
---|
2092 | switch UvData.FileType{1} |
---|
2093 | case {'civx','civdata','netcdf'}; |
---|
2094 | list_fields=get(handles.FieldName,'String');% list menu fields |
---|
2095 | FieldName= list_fields{get(handles.FieldName,'Value')}; % selected field |
---|
2096 | if ~strcmp(FieldName,'get_field...') |
---|
2097 | if get(handles.FixVelType,'Value') |
---|
2098 | VelTypeList=get(handles.VelType,'String'); |
---|
2099 | VelType=VelTypeList{get(handles.VelType,'Value')}; |
---|
2100 | end |
---|
2101 | end |
---|
2102 | % case of input vector field, get the scalar used for vector color |
---|
2103 | if ~isempty(regexp(FieldName,'^vec(')) |
---|
2104 | list_code=get(handles.ColorCode,'String');% list menu fields |
---|
2105 | index_code=get(handles.ColorCode,'Value');% selected string index |
---|
2106 | if ~strcmp(list_code{index_code},'black') && ~strcmp(list_code{index_code},'white') |
---|
2107 | list_code=get(handles.ColorScalar,'String');% list menu fields |
---|
2108 | index_code=get(handles.ColorScalar,'Value');% selected string index |
---|
2109 | ParamIn.ColorVar= list_code{index_code}; % selected field |
---|
2110 | end |
---|
2111 | end |
---|
2112 | case {'video','mmreader'} |
---|
2113 | ParamIn=UvData.MovieObject{1}; |
---|
2114 | if strcmp(NomType,'*') |
---|
2115 | frame_index=num_i1;%frame index from a single movies or multimage |
---|
2116 | else |
---|
2117 | frame_index=num_j1;% frame index from a set of indexed movies |
---|
2118 | end |
---|
2119 | case 'multimage' |
---|
2120 | if ~strcmp(NomType,'*') |
---|
2121 | frame_index=num_j1;%frame index for movies or multimage |
---|
2122 | else |
---|
2123 | frame_index=num_i1; |
---|
2124 | end |
---|
2125 | case 'vol' %TODO: update |
---|
2126 | if isfield(UvData.XmlData,'Npy') && isfield(UvData.XmlData,'Npx') |
---|
2127 | ParamIn.Npy=UvData.XmlData.Npy; |
---|
2128 | ParamIn.Npx=UvData.XmlData.Npx; |
---|
2129 | else |
---|
2130 | errormsg='Npx and Npy need to be defined in the xml file for volume images .vol'; |
---|
2131 | return |
---|
2132 | end |
---|
2133 | end |
---|
2134 | if isstruct (ParamIn) |
---|
2135 | ParamIn.FieldName=FieldName; |
---|
2136 | ParamIn.VelType=VelType; |
---|
2137 | ParamIn.Coord_x=get(handles.Coord_x,'String'); |
---|
2138 | ParamIn.Coord_y=get(handles.Coord_y,'Data'); |
---|
2139 | end |
---|
2140 | check_tps = 0; |
---|
2141 | if strcmp(UvData.FileType{1},'civdata')&&~strcmp(ParamIn.FieldName,'velocity')&&~strcmp(ParamIn.FieldName,'get_field...') |
---|
2142 | check_tps=1;%tps needed to get the requested field |
---|
2143 | end |
---|
2144 | [Field{1},ParamOut,errormsg] = read_field(FileName,UvData.FileType{1},ParamIn,frame_index); |
---|
2145 | if ~isempty(errormsg) |
---|
2146 | errormsg=['uvmat / refresh_field / read_field( ' FileName ') / ' errormsg]; |
---|
2147 | return |
---|
2148 | end |
---|
2149 | if isfield(ParamOut,'Npx')&& isfield(ParamOut,'Npy') |
---|
2150 | set(handles.num_Npx,'String',num2str(ParamOut.Npx));% display image size on the interface |
---|
2151 | set(handles.num_Npy,'String',num2str(ParamOut.Npy)); |
---|
2152 | end |
---|
2153 | Field{1}.ZIndex=z_index; %used for multiplane 3D calibration |
---|
2154 | |
---|
2155 | %% choose and read a second field FileName_1 if defined |
---|
2156 | VelType_1=[];%default |
---|
2157 | FieldName_1=[]; |
---|
2158 | ParamIn_1=[]; |
---|
2159 | ParamOut_1=[]; |
---|
2160 | frame_index_1=1; |
---|
2161 | if ~isempty(FileName_1) |
---|
2162 | if ~exist(FileName_1,'file') |
---|
2163 | errormsg=['second file ' FileName_1 ' does not exist']; |
---|
2164 | return |
---|
2165 | end |
---|
2166 | switch UvData.FileType{2} |
---|
2167 | case {'civx','civdata','netcdf'}; |
---|
2168 | list_fields=get(handles.FieldName_1,'String');% list menu fields |
---|
2169 | if ischar(list_fields),list_fields={list_fields};end |
---|
2170 | FieldName_1= list_fields{get(handles.FieldName_1,'Value')}; % selected field |
---|
2171 | if ~strcmp(FieldName,'get_field...') |
---|
2172 | if get(handles.FixVelType,'Value') |
---|
2173 | VelTypeList=get(handles.VelType_1,'String'); |
---|
2174 | VelType_1=VelTypeList{get(handles.VelType_1,'Value')};% read the velocity type. |
---|
2175 | end |
---|
2176 | end |
---|
2177 | if strcmp(FieldName_1,'velocity')&& strcmp(get(handles.ColorCode,'Visible'),'on') |
---|
2178 | list_code=get(handles.ColorCode,'String');% list menu fields |
---|
2179 | index_code=get(handles.ColorCode,'Value');% selected string index |
---|
2180 | if ~strcmp(list_code{index_code},'black') && ~strcmp(list_code{index_code},'white') |
---|
2181 | list_code=get(handles.ColorScalar,'String');% list menu fields |
---|
2182 | index_code=get(handles.ColorScalar,'Value');% selected string index |
---|
2183 | ParamIn_1.ColorVar= list_code{index_code}; % selected field for vector color display |
---|
2184 | end |
---|
2185 | end |
---|
2186 | case {'video','mmreader'} |
---|
2187 | ParamIn_1=UvData.MovieObject{2}; |
---|
2188 | if ~strcmp(NomType_1,'*') |
---|
2189 | frame_index_1=j1_1;%frame index for movies or multimage |
---|
2190 | else |
---|
2191 | frame_index_1=i1_1; |
---|
2192 | end |
---|
2193 | case 'multimage' |
---|
2194 | if strcmp(NomType_1,'*')%frame index for movies or multimage |
---|
2195 | frame_index_1=i1_1; |
---|
2196 | else |
---|
2197 | frame_index_1=j1_1; |
---|
2198 | end |
---|
2199 | case 'vol' %TODO: update |
---|
2200 | if isfield(UvData.XmlData,'Npy') && isfield(UvData.XmlData,'Npx') |
---|
2201 | ParamIn_1.Npy=UvData.XmlData.Npy; |
---|
2202 | ParamIn_1.Npx=UvData.XmlData.Npx; |
---|
2203 | else |
---|
2204 | errormsg='Npx and Npy need to be defined in the xml file for volume images .vol'; |
---|
2205 | return |
---|
2206 | end |
---|
2207 | end |
---|
2208 | if isequal(get(handles.NomType_1,'Visible'),'on') |
---|
2209 | NomType_1=get(handles.NomType_1,'String'); |
---|
2210 | else |
---|
2211 | NomType_1=get(handles.NomType,'String'); |
---|
2212 | end |
---|
2213 | test_keepdata_1=0;% test for keeping the previous stored data if the input files are unchanged |
---|
2214 | if ~isequal(NomType_1,'*')&& isfield(UvData,'FileName_1') |
---|
2215 | test_keepdata_1= strcmp(FileName_1,UvData.FileName_1) ; |
---|
2216 | end |
---|
2217 | if test_keepdata_1 |
---|
2218 | Field{2}=UvData.Field_1;% keep the stored field |
---|
2219 | ParamOut_1=UvData.ParamOut_1; |
---|
2220 | else |
---|
2221 | if isempty(ParamIn_1) || isstruct(ParamIn_1) |
---|
2222 | ParamIn_1.FieldName=FieldName_1; |
---|
2223 | ParamIn_1.VelType=VelType_1; |
---|
2224 | ParamIn_1.Coord_x=get(handles.Coord_x,'String'); |
---|
2225 | ParamIn_1.Coord_y=get(handles.Coord_y,'Data'); |
---|
2226 | end |
---|
2227 | [Field{2},ParamOut_1,errormsg] = read_field(FileName_1,UvData.FileType{2},ParamIn_1,frame_index_1); |
---|
2228 | if ~isempty(errormsg) |
---|
2229 | errormsg=['error in reading ' FieldName_1 ' in ' FileName_1 ': ' errormsg]; |
---|
2230 | return |
---|
2231 | end |
---|
2232 | if isstruct(ParamOut_1)&&~strcmp(ParamOut_1.FieldName,'get_field...')&& (strcmp(UvData.FileType{2},'civdata')||strcmp(UvData.FileType{2},'civx'))... |
---|
2233 | &&~strcmp(ParamOut_1.FieldName,'velocity') && ~strcmp(ParamOut_1.FieldName,'get_field...') |
---|
2234 | if ~check_proj_tps |
---|
2235 | end |
---|
2236 | end |
---|
2237 | end |
---|
2238 | Field{2}.ZIndex=z_index;%used for multi-plane 3D calibration |
---|
2239 | end |
---|
2240 | |
---|
2241 | %% update uvmat interface |
---|
2242 | if isfield(ParamOut,'Npx') |
---|
2243 | set(handles.num_Npx,'String',num2str(ParamOut.Npx));% display image size on the interface |
---|
2244 | set(handles.num_Npy,'String',num2str(ParamOut.Npy)); |
---|
2245 | elseif isfield(ParamOut_1,'Npx') |
---|
2246 | set(handles.num_Npx,'String',num2str(ParamOut_1.Npx));% display image size on the interface |
---|
2247 | set(handles.num_Npy,'String',num2str(ParamOut_1.Npy)); |
---|
2248 | end |
---|
2249 | |
---|
2250 | %% update the display menu for the first velocity type (first menuline) |
---|
2251 | test_veltype=0; |
---|
2252 | if (strcmp(UvData.FileType{1},'civx')||strcmp(UvData.FileType{1},'civdata'))&& ~strcmp(FieldName,'get_field...') |
---|
2253 | test_veltype=1; |
---|
2254 | set(handles.VelType,'Visible','on') |
---|
2255 | set(handles.VelType_1,'Visible','on') |
---|
2256 | set(handles.FixVelType,'Visible','on') |
---|
2257 | menu=set_veltype_display(ParamOut.CivStage,UvData.FileType{1}); |
---|
2258 | index_menu=strcmp(ParamOut.VelType,menu);%look for VelType in the menu |
---|
2259 | index_val=find(index_menu,1); |
---|
2260 | if isempty(index_val) |
---|
2261 | index_val=1; |
---|
2262 | end |
---|
2263 | set(handles.VelType,'Value',index_val) |
---|
2264 | if ~get(handles.SubField,'value') |
---|
2265 | set(handles.VelType,'String',menu) |
---|
2266 | set(handles.VelType_1,'Value',1) |
---|
2267 | set(handles.VelType_1,'String',[{''};menu]) |
---|
2268 | end |
---|
2269 | else |
---|
2270 | set(handles.VelType,'Visible','off') |
---|
2271 | end |
---|
2272 | |
---|
2273 | %% update the display menu for the second velocity type (second menuline) |
---|
2274 | test_veltype_1=0; |
---|
2275 | if isempty(FileName_1) |
---|
2276 | % set(handles.FieldName_1,'Value',1); %update the field menu |
---|
2277 | % if isstruct(ParamOut) |
---|
2278 | % set(handles.FieldName_1,'String',[{''};ParamOut.FieldList]); %update the field menu |
---|
2279 | % end |
---|
2280 | elseif ~test_keepdata_1 |
---|
2281 | if (strcmp(UvData.FileType{2},'civx')||strcmp(UvData.FileType{2},'civdata'))&& ~strcmp(FieldName_1,'get_field...') |
---|
2282 | % if (~strcmp(UvData.FileType{2},'netcdf')&&~strcmp(UvData.FileType{2},'civdata')&&~strcmp(UvData.FileType{2},'civx'))|| isequal(FieldName_1,'get_field...') |
---|
2283 | test_veltype_1=1; |
---|
2284 | set(handles.VelType_1,'Visible','on') |
---|
2285 | menu=set_veltype_display(ParamOut_1.CivStage,UvData.FileType{2}); |
---|
2286 | index_menu=strcmp(ParamOut_1.VelType,menu); |
---|
2287 | set(handles.VelType_1,'Value',1+find(index_menu,1)) |
---|
2288 | set(handles.VelType_1,'String',[{''};menu]) |
---|
2289 | else |
---|
2290 | set(handles.VelType_1,'Visible','off') |
---|
2291 | end |
---|
2292 | % update the second field menu: the same quantity |
---|
2293 | if isstruct(ParamOut_1) |
---|
2294 | % display the FieldName menu from the input file and pick the selected one: |
---|
2295 | FieldList=get(handles.FieldName_1,'String'); |
---|
2296 | field_index=strcmp(ParamOut_1.FieldName,FieldList); |
---|
2297 | if ~isempty(field_index) |
---|
2298 | set(handles.FieldName_1,'Value',find(field_index,1)) |
---|
2299 | end |
---|
2300 | end |
---|
2301 | end |
---|
2302 | if test_veltype||test_veltype_1 |
---|
2303 | set(handles.FixVelType,'Visible','on') |
---|
2304 | else |
---|
2305 | set(handles.FixVelType,'Visible','off') |
---|
2306 | end |
---|
2307 | |
---|
2308 | %% introduce w as background image by default for a new series (only for nbdim=2) |
---|
2309 | if ~isfield(UvData,'NewSeries') |
---|
2310 | UvData.NewSeries=1; |
---|
2311 | end |
---|
2312 | %put W as background image by default if NbDim=2: |
---|
2313 | if UvData.NewSeries && isequal(get(handles.SubField,'Value'),0) && isfield(Field{1},'W') && ~isempty(Field{1}.W) && ~isequal(Field{1}.NbDim,3); |
---|
2314 | set(handles.SubField,'Value',1); |
---|
2315 | set(handles.RootPath_1,'String','"') |
---|
2316 | set(handles.RootFile_1,'String','"') |
---|
2317 | set(handles.SubDir_1,'String','"'); |
---|
2318 | indices=fullfile_uvmat('','','','',NomType,num_i1,num_i2,num_j1,num_j2); |
---|
2319 | set(handles.FileIndex_1,'String',indices) |
---|
2320 | set(handles.FileExt_1,'String','"'); |
---|
2321 | set(handles.FieldName_1,'Visible','on'); |
---|
2322 | set(handles.FieldName_1,'Visible','on'); |
---|
2323 | set(handles.RootPath_1,'Visible','on') |
---|
2324 | set(handles.RootFile_1,'Visible','on') |
---|
2325 | set(handles.SubDir_1,'Visible','on'); |
---|
2326 | set(handles.FileIndex_1,'Visible','on'); |
---|
2327 | set(handles.FileExt_1,'Visible','on'); |
---|
2328 | set(handles.FieldName_1,'Visible','on'); |
---|
2329 | Field{1}.AName='w'; |
---|
2330 | end |
---|
2331 | |
---|
2332 | %% display time value of the current file |
---|
2333 | abstime=[];%default inputs |
---|
2334 | dt=[]; |
---|
2335 | TimeUnit=''; |
---|
2336 | if isfield(UvData,'TimeUnit') |
---|
2337 | TimeUnit=UvData.TimeUnit;%retrieve info from update_rootinfo |
---|
2338 | end |
---|
2339 | % time from xml file or video movie |
---|
2340 | TimeName=get(handles.TimeName,'String');% indicate that time is from xml |
---|
2341 | if strcmp(TimeName,'xml')||strcmp(TimeName,'video') |
---|
2342 | if isempty(num_i2)||isnan(num_i2) |
---|
2343 | num_i2=num_i1; |
---|
2344 | end |
---|
2345 | if isempty(num_j1)||isnan(num_j1) |
---|
2346 | num_j1=1; |
---|
2347 | end |
---|
2348 | if isempty(num_j2)||isnan(num_j2) |
---|
2349 | num_j2=num_j1; |
---|
2350 | end |
---|
2351 | siz=size(UvData.XmlData{1}.Time); |
---|
2352 | 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) |
---|
2353 | 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 |
---|
2354 | dt=(UvData.XmlData{1}.Time(num_i2+1,num_j2+1)-UvData.XmlData{1}.Time(num_i1+1,num_j1+1)); |
---|
2355 | Field{1}.Dt=dt; |
---|
2356 | if isfield(UvData.XmlData{1},'TimeUnit') |
---|
2357 | TimeUnit=UvData.XmlData{1}.TimeUnit; |
---|
2358 | end |
---|
2359 | end |
---|
2360 | end |
---|
2361 | |
---|
2362 | % get time in the input file, not defined in a xml file or movie |
---|
2363 | if isempty(abstime) |
---|
2364 | if strcmp(TimeName,'civdata')||strcmp(TimeName,'civx') |
---|
2365 | abstime=Field{1}.Time; |
---|
2366 | elseif ~isempty(regexp(TimeName,'^att:'))||~isempty(regexp(TimeName,'^var:')) |
---|
2367 | abstime=Field{1}.(TimeName(5:end));%the time is an attribute or variale selected by get_file |
---|
2368 | elseif ~isempty(regexp(TimeName,'^dim:')) |
---|
2369 | abstime=str2num(get(handles.i1,'String')); |
---|
2370 | end |
---|
2371 | if isfield(Field{1},'Dt') |
---|
2372 | dt=Field{1}.Dt;%dt read from the netcdf input file |
---|
2373 | if isfield(Field{1},'TimeUnit') |
---|
2374 | TimeUnit=Field{1}.TimeUnit; |
---|
2375 | end |
---|
2376 | elseif numel(Field)==2 && isfield(Field{2},'Dt')%dt obtained from the second field if not defined in the first |
---|
2377 | dt=Field{2}.Dt;%dt read from the netcdf input file |
---|
2378 | if isfield(Field{2},'TimeUnit') |
---|
2379 | TimeUnit=Field{2}.TimeUnit; |
---|
2380 | end |
---|
2381 | end |
---|
2382 | end |
---|
2383 | set(handles.TimeValue,'String',num2str(abstime)) |
---|
2384 | |
---|
2385 | %% display time value of the second current file if relevant |
---|
2386 | abstime_1=[]; |
---|
2387 | if ~isempty(FileName_1) |
---|
2388 | TimeName_1=get(handles.TimeName_1,'String');% indicate whether time is from xml or video |
---|
2389 | % time from xml file or video movie as a second file series |
---|
2390 | if strcmp(TimeName_1,'xml')||strcmp(TimeName_1,'video') |
---|
2391 | if numel(UvData.XmlData)==2 |
---|
2392 | if isempty(i2_1) |
---|
2393 | i2_1=num_i1; |
---|
2394 | end |
---|
2395 | if isempty(j1_1) |
---|
2396 | j1_1=1; |
---|
2397 | end |
---|
2398 | if isempty(j2_1) |
---|
2399 | j2_1=j1_1; |
---|
2400 | end |
---|
2401 | siz=size(UvData.XmlData{2}.Time); |
---|
2402 | if ~isempty(i1_1) && siz(1)>=max(i1_1+1,i2_1+1) && siz(2)>=max(j1_1+1,j2_1+1) |
---|
2403 | 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 |
---|
2404 | Field{2}.Dt=(UvData.XmlData{2}.Time(i2_1+1,j2_1+1)-UvData.XmlData{2}.Time(i1_1+1,j1_1+1)); |
---|
2405 | end |
---|
2406 | end |
---|
2407 | end |
---|
2408 | |
---|
2409 | % get time in the input file of the second series, not defined in a xml file or movie |
---|
2410 | if isempty(abstime_1) && numel(Field)==2 |
---|
2411 | if strcmp(TimeName_1,'civdata')||strcmp(TimeName_1,'civx') |
---|
2412 | abstime_1=Field{2}.Time; |
---|
2413 | elseif ~isempty(regexp(TimeName_1,'^att:')) ||~isempty(regexp(TimeName_1,'^dim:'))||~isempty(regexp(TimeName_1,'^var:')) |
---|
2414 | abstime_1=Field{2}.(TimeName_1(5:end));%the time is an attribute or variale selected by get_file |
---|
2415 | end |
---|
2416 | end |
---|
2417 | set(handles.TimeValue_1,'String',num2str(abstime_1,5)) |
---|
2418 | end |
---|
2419 | |
---|
2420 | if isempty(dt)||isequal(dt,0) |
---|
2421 | set(handles.Dt_txt,'String','') |
---|
2422 | else |
---|
2423 | if isempty(TimeUnit) |
---|
2424 | set(handles.Dt_txt,'String',['Dt=' num2str(1000*dt,3) ' 10^(-3)'] ) |
---|
2425 | else |
---|
2426 | set(handles.Dt_txt,'String',['Dt=' num2str(1000*dt,3) ' m' TimeUnit] ) |
---|
2427 | end |
---|
2428 | end |
---|
2429 | |
---|
2430 | %% Time title with unit |
---|
2431 | if isempty(abstime)&&isempty(abstime_1) |
---|
2432 | Time_title=''; |
---|
2433 | else |
---|
2434 | Time_title='Time'; |
---|
2435 | if ~isempty(TimeUnit) |
---|
2436 | Time_title=['Time (' TimeUnit ')']; |
---|
2437 | end |
---|
2438 | end |
---|
2439 | set(handles.Time_title,'String',Time_title) |
---|
2440 | |
---|
2441 | %% store the current open names, fieldname and vel types in uvmat interface |
---|
2442 | UvData.FileName_1=FileName_1; |
---|
2443 | UvData.ParamOut_1=ParamOut_1; |
---|
2444 | if numel(Field)==2 |
---|
2445 | UvData.Field_1=Field{2}; %store the second field for possible use at next RUN |
---|
2446 | end |
---|
2447 | |
---|
2448 | %% apply coordinate transform or other user fct |
---|
2449 | transform=get(handles.TransformPath,'UserData'); |
---|
2450 | if isempty(transform) |
---|
2451 | UvData.Field=Field{1}; |
---|
2452 | else |
---|
2453 | XmlData=[];%default |
---|
2454 | XmlData_1=[];%default |
---|
2455 | if isfield(UvData,'XmlData')%use geometry calib recorded from the ImaDoc xml file as first priority |
---|
2456 | XmlData=UvData.XmlData{1}; |
---|
2457 | if numel(UvData.XmlData)==2 |
---|
2458 | XmlData_1=UvData.XmlData{2}; |
---|
2459 | end |
---|
2460 | end |
---|
2461 | switch nargin(transform) |
---|
2462 | case 4 |
---|
2463 | if length(Field)==2 |
---|
2464 | UvData.Field=transform(Field{1},XmlData,Field{2},XmlData_1); |
---|
2465 | else |
---|
2466 | UvData.Field=transform(Field{1},XmlData); |
---|
2467 | end |
---|
2468 | case 3 |
---|
2469 | if length(Field)==2 |
---|
2470 | UvData.Field=transform(Field{1},XmlData,Field{2}); |
---|
2471 | else |
---|
2472 | UvData.Field=transform(Field{1},XmlData); |
---|
2473 | end |
---|
2474 | case 2 |
---|
2475 | UvData.Field=transform(Field{1},XmlData); |
---|
2476 | case 1 |
---|
2477 | UvData.Field=transform(Field{1}); |
---|
2478 | end |
---|
2479 | end |
---|
2480 | |
---|
2481 | %% calculate tps coefficients if needed |
---|
2482 | UvData.Field=tps_coeff_field(UvData.Field,check_proj_tps); |
---|
2483 | |
---|
2484 | %% get bounds and dimensions of the input field |
---|
2485 | UvData.Field=find_field_bounds(UvData.Field); |
---|
2486 | |
---|
2487 | if UvData.Field.NbDim>1 |
---|
2488 | % default projection plane |
---|
2489 | if isempty(UvData.ProjObject{1}) |
---|
2490 | UvData.ProjObject{1}.Type='plane';%main plotting plane |
---|
2491 | UvData.ProjObject{1}.ProjMode='projection';%main plotting plane |
---|
2492 | % UvData.ProjObject{1}.Coord=[0 0 0]; |
---|
2493 | UvData.ProjObject{1}.DisplayHandle.uvmat=[]; %plane not visible in uvmat |
---|
2494 | UvData.ProjObject{1}.DisplayHandle.view_field=[]; %plane not visible in uvmat |
---|
2495 | end |
---|
2496 | %% 3D case (menuvolume) |
---|
2497 | if UvData.Field.NbDim==3% && UvData.NewSeries |
---|
2498 | test_set_object=1; |
---|
2499 | hset_object=findobj(allchild(0),'tag','set_object');% look for the set_object GUI |
---|
2500 | ZBounds(1)=UvData.Field.ZMin; %minimum for the Z slider |
---|
2501 | ZBounds(2)=UvData.Field.ZMax;%maximum for the Z slider |
---|
2502 | if ~isempty(hset_object) %if set_object is detected |
---|
2503 | delete(hset_object);% delete the GUI set_object if it does not fit |
---|
2504 | end |
---|
2505 | if test_set_object% reinitiate the GUI set_object |
---|
2506 | 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 |
---|
2507 | UvData.ProjObject{1}.NbDim=NbDim;%test for 3D objects |
---|
2508 | UvData.ProjObject{1}.RangeZ=UvData.Field.CoordMesh;%main plotting plane |
---|
2509 | UvData.ProjObject{1}.Coord(1,3)=(UvData.Field.ZMin+UvData.Field.ZMax)/2;%section at a middle plane chosen |
---|
2510 | UvData.ProjObject{1}.Angle=[0 0 0]; |
---|
2511 | UvData.ProjObject{1}.HandlesDisplay=plot(0,0,'Tag','proj_object');% A REVOIR |
---|
2512 | UvData.ProjObject{1}.Name='1-PLANE'; |
---|
2513 | UvData.ProjObject{1}.enable_plot=1; |
---|
2514 | set_object(UvData.ProjObject{1},handles,ZBounds); |
---|
2515 | set(handles.ListObject,'Value',1); |
---|
2516 | set(handles.ListObject,'String',{'1-PLANE'}); |
---|
2517 | set(handles.CheckEditObject,'Value',1)% put the plane in edit mode to enable the z cursor |
---|
2518 | CheckEditObject_Callback([],[], handles) |
---|
2519 | end |
---|
2520 | %multilevel case (single menuplane in a 3D space) |
---|
2521 | elseif isfield(UvData,'Z') |
---|
2522 | if isfield(UvData,'CoordType')&& isequal(UvData.CoordType,'phys') && isfield(UvData,'XmlData') |
---|
2523 | XmlData=UvData.XmlData{1}; |
---|
2524 | if isfield(XmlData,'PlanePos') |
---|
2525 | UvData.ProjObject{1}.Coord=XmlData.PlanePos(UvData.ZIndex,:); |
---|
2526 | end |
---|
2527 | if isfield(XmlData,'PlaneAngle') |
---|
2528 | siz=size(XmlData.PlaneAngle); |
---|
2529 | indangle=min(siz(1),UvData.ZIndex);%take first angle if a single angle is defined (translating scanning) |
---|
2530 | UvData.ProjObject{1}.PlaneAngle=XmlData.PlaneAngle(indangle,:); |
---|
2531 | end |
---|
2532 | elseif isfield(UvData,'ZIndex') |
---|
2533 | UvData.ProjObject{1}.ZObject=UvData.ZIndex; |
---|
2534 | end |
---|
2535 | end |
---|
2536 | end |
---|
2537 | |
---|
2538 | testnewseries=UvData.NewSeries; |
---|
2539 | UvData.NewSeries=0;% put to 0 the test for a new field series (set by RootPath_callback) |
---|
2540 | set(handles.uvmat,'UserData',UvData) |
---|
2541 | |
---|
2542 | %% reset the min and max of scalar if only the mask is displayed(TODO: check the need) |
---|
2543 | % if isfield(UvData,'Mask')&& ~isfield(UvData,'A') |
---|
2544 | % set(handles.num_MinA,'String','0') |
---|
2545 | % set(handles.num_MaxA,'String','255') |
---|
2546 | % end |
---|
2547 | |
---|
2548 | %% usual 1D (x,y) plots |
---|
2549 | if UvData.Field.NbDim<=1 |
---|
2550 | set(handles.Objects,'Visible','off') |
---|
2551 | % set(handles.ListObject_1_title,'Visible','off') |
---|
2552 | % set(handles.ListObject_1,'Visible','off') |
---|
2553 | [PlotType,PlotParamOut]=plot_field(UvData.Field,handles.PlotAxes,read_GUI(handles.uvmat)); |
---|
2554 | errormsg=fill_GUI(PlotParamOut,handles.uvmat); |
---|
2555 | for list={'Scalar','Vectors'} |
---|
2556 | if ~isfield(PlotParamOut,list{1}) |
---|
2557 | set(handles.(list{1}),'Visible','off') |
---|
2558 | end |
---|
2559 | end |
---|
2560 | |
---|
2561 | %% 2D or 3D fieldname are generally projected |
---|
2562 | else |
---|
2563 | set(handles.Objects,'Visible','on') |
---|
2564 | % set(handles.ListObject_1_title,'Visible','on') |
---|
2565 | % set(handles.ListObject_1,'Visible','on') |
---|
2566 | |
---|
2567 | %% Plot the projections on the selected projection objects |
---|
2568 | % main projection object (uvmat display) |
---|
2569 | list_object=get(handles.ListObject_1,'String'); |
---|
2570 | if isequal(list_object,{''})||isequal(list_object,' ')%refresh list of objects if the menu is empty |
---|
2571 | set(handles.ListObject,'Value',1) |
---|
2572 | set(handles.ListObject,'String',{'plane'}) |
---|
2573 | UvData.ProjObject{1}.Type='plane';%main plotting plane |
---|
2574 | UvData.ProjObject{1}.ProjMode='projection';%main plotting plane |
---|
2575 | UvData.ProjObject{1}.DisplayHandle.uvmat=[]; %plane not visible in uvmat |
---|
2576 | UvData.ProjObject{1}.DisplayHandle.view_field=[]; %plane not visible in uvmat |
---|
2577 | set(handles.ListObject_1,'Value',1) |
---|
2578 | set(handles.ListObject_1,'String',{'plane'}) |
---|
2579 | end |
---|
2580 | IndexObj=get(handles.ListObject_1,'Value');%selected projection object for main view |
---|
2581 | if IndexObj> numel(UvData.ProjObject) |
---|
2582 | IndexObj=1;%select the first object if the selected one does not exist |
---|
2583 | set(handles.ListObject_1,'Value',1) |
---|
2584 | end |
---|
2585 | if get(handles.CheckViewField,'Value') |
---|
2586 | IndexObj_2=get(handles.ListObject,'Value');%selected projection object for view_field |
---|
2587 | if ~isequal(IndexObj_2,IndexObj(1)) |
---|
2588 | IndexObj(2)=IndexObj_2; |
---|
2589 | end |
---|
2590 | end |
---|
2591 | plot_handles{1}=handles; |
---|
2592 | if isfield(UvData,'plotaxes')%case of movies |
---|
2593 | haxes(1)=UvData.plotaxes; |
---|
2594 | else |
---|
2595 | haxes(1)=handles.PlotAxes; |
---|
2596 | end |
---|
2597 | PlotParam{1}=read_GUI(handles.uvmat); |
---|
2598 | %default settings if vectors not visible |
---|
2599 | if ~isfield(PlotParam{1},'Vectors') |
---|
2600 | PlotParam{1}.Vectors.MaxVec=1; |
---|
2601 | PlotParam{1}.Vectors.MinVec=0; |
---|
2602 | PlotParam{1}.Vectors.CheckFixVecColor=1; |
---|
2603 | PlotParam{1}.Vectors.ColCode1=0.33; |
---|
2604 | PlotParam{1}.Vectors.ColCode2=0.66; |
---|
2605 | PlotParam{1}.Vectors.ColorScalar={''}; |
---|
2606 | PlotParam{1}.Vectors.ColorCode= {'rgb'}; |
---|
2607 | end |
---|
2608 | PosColorbar{1}=UvData.OpenParam.PosColorbar;%prescribe the colorbar position on the uvmat interface |
---|
2609 | |
---|
2610 | %% second projection object (view_field display) |
---|
2611 | if length( IndexObj)>=2 |
---|
2612 | view_field_handle=findobj(allchild(0),'tag','view_field');%handles of the view_field GUI |
---|
2613 | if ~isempty(view_field_handle) |
---|
2614 | plot_handles{2}=guidata(view_field_handle); |
---|
2615 | haxes(2)=plot_handles{2}.PlotAxes; |
---|
2616 | PlotParam{2}=read_GUI(view_field_handle); |
---|
2617 | % PlotParam{2}=read_GUI(handles.uvmat);%read plotting parameters on the uvmat interface |
---|
2618 | PosColorbar{2}='*'; %TODO: deal with colorbar position on view_field |
---|
2619 | end |
---|
2620 | end |
---|
2621 | |
---|
2622 | %% loop on the projection objects: one or two |
---|
2623 | |
---|
2624 | for imap=1:numel(IndexObj) |
---|
2625 | iobj=IndexObj(imap); |
---|
2626 | if numel(UvData.ProjObject)<iobj |
---|
2627 | break |
---|
2628 | end |
---|
2629 | [ObjectData,errormsg]=proj_field(UvData.Field,UvData.ProjObject{iobj});% project field on the object |
---|
2630 | if ~isempty(errormsg) |
---|
2631 | return |
---|
2632 | end |
---|
2633 | if testnewseries |
---|
2634 | PlotParam{imap}.Scalar.CheckBW=[]; %B/W option depends on the input field (image or scalar) |
---|
2635 | if isfield(ObjectData,'CoordUnit') |
---|
2636 | PlotParam{imap}.Coordinates.CheckFixAspectRatio=1;% set x and y scaling equal if CoordUnit is defined (common unit for x and y) |
---|
2637 | PlotParam{imap}.Coordinates.AspectRatio=1; %set aspect ratio to 1 |
---|
2638 | end |
---|
2639 | end |
---|
2640 | %use of mask (TODO: check) |
---|
2641 | if isfield(ObjectData,'NbDim') && isequal(ObjectData.NbDim,2) && isfield(ObjectData,'Mask') && isfield(ObjectData,'A') |
---|
2642 | flag_mask=double(ObjectData.Mask>200);%=0 for masked regions |
---|
2643 | AX=ObjectData.AX;%x coordiantes for the scalar field |
---|
2644 | AY=ObjectData.AY;%y coordinates for the scalar field |
---|
2645 | MaskX=ObjectData.MaskX;%x coordiantes for the mask |
---|
2646 | MaskY=ObjectData.MaskY;%y coordiantes for the mask |
---|
2647 | if ~isequal(MaskX,AX)||~isequal(MaskY,AY) |
---|
2648 | nxy=size(flag_mask); |
---|
2649 | sizpx=(ObjectData.MaskX(end)-ObjectData.MaskX(1))/(nxy(2)-1);%size of a mask pixel |
---|
2650 | sizpy=(ObjectData.MaskY(1)-ObjectData.MaskY(end))/(nxy(1)-1); |
---|
2651 | x_mask=ObjectData.MaskX(1):sizpx:ObjectData.MaskX(end); % pixel x coordinates for image display |
---|
2652 | y_mask=ObjectData.MaskY(1):-sizpy:ObjectData.MaskY(end);% pixel x coordinates for image display |
---|
2653 | %project on the positions of the scalar |
---|
2654 | npxy=size(ObjectData.A); |
---|
2655 | dxy(1)=(ObjectData.AY(end)-ObjectData.AY(1))/(npxy(1)-1);%grid mesh in y |
---|
2656 | dxy(2)=(ObjectData.AX(end)-ObjectData.AX(1))/(npxy(2)-1);%grid mesh in x |
---|
2657 | xi=ObjectData.AX(1):dxy(2):ObjectData.AX(end); |
---|
2658 | yi=ObjectData.AY(1):dxy(1):ObjectData.AY(end); |
---|
2659 | [XI,YI]=meshgrid(xi,yi);% creates the matrix of regular coordinates |
---|
2660 | flag_mask = interp2(x_mask,y_mask,flag_mask,XI,YI); |
---|
2661 | end |
---|
2662 | AClass=class(ObjectData.A); |
---|
2663 | ObjectData.A=flag_mask.*double(ObjectData.A); |
---|
2664 | ObjectData.A=feval(AClass,ObjectData.A); |
---|
2665 | end |
---|
2666 | if ~isempty(ObjectData) |
---|
2667 | %PlotType='none'; %default |
---|
2668 | if imap==2 && isempty(view_field_handle) |
---|
2669 | view_field(ObjectData) |
---|
2670 | else |
---|
2671 | % ObjectData.VarAttribute{5}.Role='scalar';TODO CORRECT |
---|
2672 | [PlotType,PlotParamOut]=plot_field(ObjectData,haxes(imap),PlotParam{imap},PosColorbar{imap}); |
---|
2673 | if imap==1 |
---|
2674 | errormsg=fill_GUI(PlotParamOut,handles.uvmat); |
---|
2675 | else |
---|
2676 | errormsg=fill_GUI(PlotParamOut,view_field_handle); |
---|
2677 | end |
---|
2678 | for list={'Scalar','Vectors'} |
---|
2679 | if ~isfield(PlotParamOut,list{1}) |
---|
2680 | set(plot_handles{imap}.(list{1}),'Visible','off') |
---|
2681 | end |
---|
2682 | end |
---|
2683 | if isfield(Field,'CoordMesh')&&~isempty(Field.CoordMesh) |
---|
2684 | ObjectData.CoordMesh=Field.CoordMesh; % gives an estimated mesh size (useful for mouse action on the plot) |
---|
2685 | end |
---|
2686 | end |
---|
2687 | end |
---|
2688 | end |
---|
2689 | |
---|
2690 | %% update the mask |
---|
2691 | if isequal(get(handles.CheckMask,'Value'),1)%if the mask option is on |
---|
2692 | update_mask(handles); |
---|
2693 | end |
---|
2694 | |
---|
2695 | %% prepare the menus of histograms and plot them (histogram of the whole volume in 3D case) |
---|
2696 | menu_histo=(UvData.Field.ListVarName)';%list of field variables to be displayed for the menu of histogram display |
---|
2697 | ind_skip=[]; |
---|
2698 | % nb_histo=1; |
---|
2699 | Ustring=''; |
---|
2700 | Vstring=''; |
---|
2701 | % suppress coordinates from the histogram menu |
---|
2702 | for ivar=1:numel(menu_histo)%l loop on field variables: |
---|
2703 | if isfield(UvData.Field,'VarAttribute') && numel(UvData.Field.VarAttribute)>=ivar && isfield(UvData.Field.VarAttribute{ivar},'Role') |
---|
2704 | Role=UvData.Field.VarAttribute{ivar}.Role; |
---|
2705 | switch Role |
---|
2706 | case {'coord_x','coord_y','coord_z','dimvar'} |
---|
2707 | ind_skip=[ind_skip ivar]; |
---|
2708 | case {'vector_x'} |
---|
2709 | Ustring=UvData.Field.ListVarName{ivar}; |
---|
2710 | ind_skip=[ind_skip ivar]; |
---|
2711 | case {'vector_y'} |
---|
2712 | Vstring=UvData.Field.ListVarName{ivar}; |
---|
2713 | ind_skip=[ind_skip ivar]; |
---|
2714 | end |
---|
2715 | end |
---|
2716 | DimCell=UvData.Field.VarDimName{ivar}; |
---|
2717 | DimName=''; |
---|
2718 | if ischar(DimCell) |
---|
2719 | DimName=DimCell; |
---|
2720 | elseif iscell(DimCell)&& numel(DimCell)==1 |
---|
2721 | DimName=DimCell{1}; |
---|
2722 | end |
---|
2723 | if strcmp(DimName,menu_histo{ivar}) |
---|
2724 | ind_skip=[ind_skip ivar]; |
---|
2725 | end |
---|
2726 | end |
---|
2727 | menu_histo(ind_skip)=[];% remove skipped items |
---|
2728 | if ~isempty(Ustring) |
---|
2729 | menu_histo=[{[Ustring ',' Vstring]};menu_histo];% add U, V at the beginning if they exist |
---|
2730 | end |
---|
2731 | |
---|
2732 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
---|
2733 | % display menus and plot histograms |
---|
2734 | test_v=0; |
---|
2735 | if ~isempty(menu_histo) |
---|
2736 | set(handles.histo1_menu,'Value',1) |
---|
2737 | set(handles.histo1_menu,'String',menu_histo) |
---|
2738 | histo1_menu_Callback(handles.histo1_menu, [], handles)% plot first histogram |
---|
2739 | end |
---|
2740 | end |
---|
2741 | ResizeFcn(handles.uvmat,[],handles) |
---|
2742 | |
---|
2743 | %------------------------------------------------------------------------ |
---|
2744 | function histo1_menu_Callback(hObject, eventdata, handles) |
---|
2745 | %-------------------------------------------- |
---|
2746 | histo_menu=get(handles.histo1_menu,'String'); |
---|
2747 | histo_value=get(handles.histo1_menu,'Value'); |
---|
2748 | FieldName=histo_menu{histo_value}; |
---|
2749 | |
---|
2750 | UvData=get(handles.uvmat,'UserData'); |
---|
2751 | Field=UvData.Field; |
---|
2752 | r=regexp(FieldName,'(?<var1>.*)(?<sep>,)(?<var2>.*)','names'); |
---|
2753 | FieldName_2=''; |
---|
2754 | if ~isempty(r) |
---|
2755 | FieldName=r.var1; |
---|
2756 | FieldName_2=r.var2; |
---|
2757 | end |
---|
2758 | if ~isfield(UvData.Field,FieldName) |
---|
2759 | msgbox_uvmat('ERROR',['no field ' FieldName ' for histogram']) |
---|
2760 | return |
---|
2761 | end |
---|
2762 | FieldHisto=Field.(FieldName); |
---|
2763 | if isfield(Field,'FF') && ~isempty(Field.FF) && isequal(size(Field.FF),size(FieldHisto)) |
---|
2764 | indsel=find(Field.FF==0);%find values marked as false |
---|
2765 | if ~isempty(indsel) |
---|
2766 | FieldHisto=FieldHisto(indsel); |
---|
2767 | if ~isempty(FieldName_2) |
---|
2768 | FieldHisto(:,:,2)=Field.(FieldName_2)(indsel); |
---|
2769 | end |
---|
2770 | end |
---|
2771 | elseif ~isempty(FieldName_2) |
---|
2772 | FieldHisto(:,:,2)=Field.(FieldName_2); |
---|
2773 | end |
---|
2774 | if isempty(Field) |
---|
2775 | msgbox_uvmat('ERROR',['empty field ' FieldName]) |
---|
2776 | else |
---|
2777 | nxy=size(FieldHisto); |
---|
2778 | Amin=double(min(min(min(FieldHisto))));%min of field value |
---|
2779 | Amax=double(max(max(max(FieldHisto))));%max of field value |
---|
2780 | if isequal(Amin,Amax) |
---|
2781 | cla(handles.HistoAxes) |
---|
2782 | else |
---|
2783 | Histo.ListVarName={FieldName,'histo'}; |
---|
2784 | if isfield(Field,'NbDim') && isequal(Field.NbDim,3) |
---|
2785 | Histo.VarDimName={FieldName,FieldName}; %dimensions for the histogram |
---|
2786 | else |
---|
2787 | if numel(nxy)==2 |
---|
2788 | Histo.VarDimName={FieldName,FieldName}; %dimensions for the histogram |
---|
2789 | else |
---|
2790 | Histo.VarDimName={FieldName,{FieldName,'component'}}; %dimensions for the histogram |
---|
2791 | end |
---|
2792 | end |
---|
2793 | %unit |
---|
2794 | units=[]; %default |
---|
2795 | for ivar=1:numel(Field.ListVarName) |
---|
2796 | if strcmp(Field.ListVarName{ivar},FieldName) |
---|
2797 | if isfield(Field,'VarAttribute') && numel(Field.VarAttribute)>=ivar && isfield(Field.VarAttribute{ivar},'units') |
---|
2798 | units=Field.VarAttribute{ivar}.units; |
---|
2799 | break |
---|
2800 | end |
---|
2801 | end |
---|
2802 | end |
---|
2803 | if ~isempty(units) |
---|
2804 | Histo.VarAttribute{1}.units=units; |
---|
2805 | end |
---|
2806 | eval(['Histo.' FieldName '=linspace(Amin,Amax,50);'])%absissa values for histo |
---|
2807 | if isfield(Field,'NbDim') && isequal(Field.NbDim,3) |
---|
2808 | C=reshape(double(FieldHisto),1,[]);% reshape in a vector |
---|
2809 | Histo.histo(:,1)=hist(C, Histo.(FieldName)); %calculate histogram |
---|
2810 | else |
---|
2811 | for col=1:size(FieldHisto,3) |
---|
2812 | B=FieldHisto(:,:,col); |
---|
2813 | C=reshape(double(B),1,nxy(1)*nxy(2));% reshape in a vector |
---|
2814 | Histo.histo(:,col)=hist(C, Histo.(FieldName)); %calculate histogram |
---|
2815 | end |
---|
2816 | end |
---|
2817 | plot_field(Histo,handles.HistoAxes); |
---|
2818 | hlegend=legend; |
---|
2819 | if isempty(FieldName_2) |
---|
2820 | set(hlegend,'String',FieldName) |
---|
2821 | else |
---|
2822 | set(hlegend,'String',{FieldName;FieldName_2}) |
---|
2823 | end |
---|
2824 | end |
---|
2825 | end |
---|
2826 | |
---|
2827 | %------------------------------------------------------------------------ |
---|
2828 | % --- translate coordinate to matrix index |
---|
2829 | %------------------------------------------------------------------------ |
---|
2830 | function [indx,indy]=pos2ind(x0,rangx0,nxy) |
---|
2831 | indx=1+round((nxy(2)-1)*(x0-rangx0(1))/(rangx0(2)-rangx0(1)));% index x of pixel |
---|
2832 | indy=1+round((nxy(1)-1)*(y12-rangy0(1))/(rangy0(2)-rangy0(1)));% index y of pixel |
---|
2833 | |
---|
2834 | %------------------------------------------------------------------------ |
---|
2835 | % --- Executes on button press in 'CheckZoom'. |
---|
2836 | %------------------------------------------------------------------------ |
---|
2837 | function CheckZoom_Callback(hObject, eventdata, handles) |
---|
2838 | |
---|
2839 | if get(handles.CheckZoom,'Value') |
---|
2840 | set(handles.CheckFixLimits,'Value',1)% propose by default fixed limits for the plotting axes |
---|
2841 | set(handles.CheckZoomFig,'Value',0)%desactivate zoom fig |
---|
2842 | end |
---|
2843 | |
---|
2844 | |
---|
2845 | %------------------------------------------------------------------------ |
---|
2846 | % --- Executes on button press in CheckZoomFig. |
---|
2847 | %------------------------------------------------------------------------ |
---|
2848 | function CheckZoomFig_Callback(hObject, eventdata, handles) |
---|
2849 | |
---|
2850 | if get(handles.CheckZoomFig,'Value') |
---|
2851 | set(handles.CheckZoom,'value',0) |
---|
2852 | end |
---|
2853 | |
---|
2854 | %------------------------------------------------------------------------ |
---|
2855 | % --- Executes on button press in 'CheckFixLimits'. |
---|
2856 | %------------------------------------------------------------------------ |
---|
2857 | function CheckFixLimits_Callback(hObject, eventdata, handles) |
---|
2858 | |
---|
2859 | if ~get(handles.CheckFixLimits,'Value') |
---|
2860 | update_plot(handles) |
---|
2861 | set(handles.CheckZoom,'Value',0) |
---|
2862 | end |
---|
2863 | |
---|
2864 | %------------------------------------------------------------------------ |
---|
2865 | % --- Executes on button press in CheckFixAspectRatio. |
---|
2866 | function CheckFixAspectRatio_Callback(hObject, eventdata, handles) |
---|
2867 | %------------------------------------------------------------------------ |
---|
2868 | |
---|
2869 | % if get(handles.CheckFixAspectRatio,'Value') |
---|
2870 | update_plot(handles); |
---|
2871 | % else |
---|
2872 | % update_plot(handles); |
---|
2873 | % end |
---|
2874 | |
---|
2875 | %------------------------------------------------------------------------ |
---|
2876 | function num_AspectRatio_Callback(hObject, eventdata, handles) |
---|
2877 | %------------------------------------------------------------------------ |
---|
2878 | set(handles.CheckFixAspectRatio,'Value',1)% select the fixed aspect ratio button |
---|
2879 | update_plot(handles); |
---|
2880 | |
---|
2881 | %------------------------------------------------------------------------ |
---|
2882 | %----Executes on button press in 'record': records the current flags of manual correction. |
---|
2883 | %------------------------------------------------------------------------ |
---|
2884 | function record_Callback(hObject, eventdata, handles) |
---|
2885 | |
---|
2886 | [RootPath,SubDir,RootFile,FileIndices,FileExt]=read_file_boxes(handles); |
---|
2887 | FileName=[fullfile(RootPath,SubDir,RootFile) FileIndices FileExt]; |
---|
2888 | [erread,message]=fileattrib(FileName); |
---|
2889 | if ~isempty(message) && ~isequal(message.UserWrite,1) |
---|
2890 | msgbox_uvmat('ERROR',['no writting access to ' FileName]) |
---|
2891 | return |
---|
2892 | end |
---|
2893 | MenuVelType=get(handles.VelType,'String'); |
---|
2894 | test_civ2=strcmp(MenuVelType{get(handles.VelType,'Value')},'civ2'); |
---|
2895 | test_civ1=strcmp(MenuVelType{get(handles.VelType,'Value')},'civ1'); |
---|
2896 | if ~test_civ2 && ~test_civ1 |
---|
2897 | msgbox_uvmat('ERROR','manual correction only possible for CIV1 or CIV2 velocity fields') |
---|
2898 | end |
---|
2899 | if test_civ2 |
---|
2900 | nbname='nb_vec_2'; |
---|
2901 | flagname='Civ2_FF'; |
---|
2902 | CivStage=5; |
---|
2903 | end |
---|
2904 | if test_civ1 |
---|
2905 | nbname='nb_vec_1'; |
---|
2906 | flagname='Civ1_FF'; |
---|
2907 | CivStage=2; |
---|
2908 | end |
---|
2909 | %write fix flags in the netcdf file |
---|
2910 | UvData=get(handles.uvmat,'UserData'); |
---|
2911 | hhh=which('netcdf.open');% look for built-in matlab netcdf library |
---|
2912 | if ~isequal(hhh,'')% case of builtin Matlab netcdf library |
---|
2913 | nc=netcdf.open(FileName,'NC_WRITE'); |
---|
2914 | netcdf.reDef(nc); |
---|
2915 | netcdf.putAtt(nc,netcdf.getConstant('NC_GLOBAL'),'CivStage',CivStage); |
---|
2916 | dimid = netcdf.inqDimID(nc,nbname); |
---|
2917 | try |
---|
2918 | varid = netcdf.inqVarID(nc,flagname);% look for already existing fixflag variable |
---|
2919 | catch |
---|
2920 | varid=netcdf.defVar(nc,flagname,'double',dimid);%create fixflag variable if it does not exist |
---|
2921 | end |
---|
2922 | netcdf.endDef(nc); |
---|
2923 | netcdf.putVar(nc,varid,UvData.PlotAxes.FF); |
---|
2924 | netcdf.close(nc); |
---|
2925 | else %old netcdf library |
---|
2926 | netcdf_toolbox(FileName,AxeData,attrname,nbname,flagname) |
---|
2927 | end |
---|
2928 | |
---|
2929 | %------------------------------------------------------------------- |
---|
2930 | %----Correct the netcdf file, using toolbox (old versions of Matlab). |
---|
2931 | %------------------------------------------------------------------- |
---|
2932 | function netcdf_toolbox(FileName,AxeData,attrname,nbname,flagname) |
---|
2933 | nc=netcdf(FileName,'write'); %open netcdf file |
---|
2934 | result=redef(nc); |
---|
2935 | eval(['nc.' attrname '=1;']); |
---|
2936 | theDim=nc(nbname) ;% get the number of velocity vectors |
---|
2937 | nb_vectors=size(theDim); |
---|
2938 | var_FixFlag=ncvar(flagname,nc);% var_FixFlag will be written as the netcdf variable vec_FixFlag |
---|
2939 | var_FixFlag(1:nb_vectors)=AxeData.FF;% |
---|
2940 | fin=close(nc); |
---|
2941 | |
---|
2942 | %----------------------------------------------------------------------- |
---|
2943 | % --- Executes on button press in SubField |
---|
2944 | %----------------------------------------------------------------------- |
---|
2945 | function SubField_Callback(hObject, eventdata, handles) |
---|
2946 | |
---|
2947 | if get(handles.SubField,'Value')==0% if the subfield button is desactivated |
---|
2948 | desable_subfield(handles) |
---|
2949 | transform_fct_list=get(handles.TransformName,'String'); |
---|
2950 | transform_fct=transform_fct_list(get(handles.TransformName,'Value')); |
---|
2951 | if strcmp(transform_fct,'sub_field') |
---|
2952 | set(handles.TransformName,'Value',1)%suppress the sub_field transform |
---|
2953 | TransformName_Callback(hObject, eventdata, handles); |
---|
2954 | else |
---|
2955 | REFRESH_Callback(hObject, eventdata, handles) |
---|
2956 | end |
---|
2957 | else |
---|
2958 | fileinput_1=uigetfile_uvmat('select a second input file:',get(handles.RootPath,'String')); |
---|
2959 | if isempty(fileinput_1) |
---|
2960 | set(handles.SubField,'Value',0) |
---|
2961 | else |
---|
2962 | % refresh the current displayed field |
---|
2963 | display_file_name(handles,fileinput_1,2) |
---|
2964 | |
---|
2965 | %update list of recent files in the menubar |
---|
2966 | MenuFile_1=fileinput_1; |
---|
2967 | MenuFile_2=get(handles.MenuFile_1,'Label'); |
---|
2968 | MenuFile_3=get(handles.MenuFile_2,'Label'); |
---|
2969 | MenuFile_4=get(handles.MenuFile_3,'Label'); |
---|
2970 | MenuFile_5=get(handles.MenuFile_4,'Label'); |
---|
2971 | set(handles.MenuFile_1,'Label',MenuFile_1) |
---|
2972 | set(handles.MenuFile_2,'Label',MenuFile_2) |
---|
2973 | set(handles.MenuFile_3,'Label',MenuFile_3) |
---|
2974 | set(handles.MenuFile_4,'Label',MenuFile_4) |
---|
2975 | set(handles.MenuFile_5,'Label',MenuFile_5) |
---|
2976 | end |
---|
2977 | end |
---|
2978 | |
---|
2979 | %----------------------------------------------------------------------- |
---|
2980 | % --- desactivate display used for a second file series |
---|
2981 | %----------------------------------------------------------------------- |
---|
2982 | function desable_subfield(handles) |
---|
2983 | |
---|
2984 | set(handles.RootPath_1,'String','') |
---|
2985 | set(handles.RootFile_1,'String','') |
---|
2986 | set(handles.SubDir_1,'String',''); |
---|
2987 | set(handles.FileIndex_1,'String',''); |
---|
2988 | set(handles.FileExt_1,'String',''); |
---|
2989 | set(handles.RootPath_1,'Visible','off') |
---|
2990 | set(handles.RootFile_1,'Visible','off') |
---|
2991 | set(handles.SubDir_1,'Visible','off'); |
---|
2992 | set(handles.NomType_1,'Visible','off'); |
---|
2993 | set(handles.FileIndex_1,'Visible','off'); |
---|
2994 | set(handles.FileExt_1,'Visible','off'); |
---|
2995 | set(handles.TimeName_1,'String',''); |
---|
2996 | set(handles.TimeName_1,'Visible','off'); |
---|
2997 | set(handles.TimeValue_1,'String',''); |
---|
2998 | set(handles.TimeValue_1,'Visible','off'); |
---|
2999 | set(handles.FieldName_1,'Value',1);%set to blank state |
---|
3000 | set(handles.VelType_1,'Value',1);%set to blank state |
---|
3001 | set(handles.num_Opacity,'String','')% desactivate opacity setting |
---|
3002 | FieldList=get(handles.FieldName,'String'); |
---|
3003 | if numel(FieldList)>1 % if a choice of fields exists |
---|
3004 | set(handles.FieldName_1,'Value',1)% set second field choice to blank |
---|
3005 | set(handles.FieldName_1,'String',[{''};FieldList])% reproduce the menu FieldName plus a blank option |
---|
3006 | else |
---|
3007 | set(handles.FieldName_1,'String',{''})% set second field choice to blank |
---|
3008 | end |
---|
3009 | if ~strcmp(get(handles.VelType,'Visible'),'on') |
---|
3010 | set(handles.VelType_1,'Visible','off') |
---|
3011 | end |
---|
3012 | UvData=get(handles.uvmat,'UserData'); |
---|
3013 | if isfield(UvData,'XmlData_1') |
---|
3014 | UvData=rmfield(UvData,'XmlData_1'); |
---|
3015 | end |
---|
3016 | set(handles.uvmat,'UserData',UvData); |
---|
3017 | |
---|
3018 | %------------------------------------------------------------------------ |
---|
3019 | % --- read the data displayed for the input rootfile windows (new): TODO use read_GUI |
---|
3020 | %------------------------------------------------------------------------ |
---|
3021 | function [RootPath,SubDir,RootFile,FileIndices,FileExt]=read_file_boxes(handles) |
---|
3022 | |
---|
3023 | InputFile=read_GUI(handles.InputFile); |
---|
3024 | RootPath=InputFile.RootPath; |
---|
3025 | SubDir=regexprep(InputFile.SubDir,'/|\',''); |
---|
3026 | RootFile=regexprep(InputFile.RootFile,'/|\',''); |
---|
3027 | FileIndices=InputFile.FileIndex; |
---|
3028 | FileExt=InputFile.FileExt; |
---|
3029 | |
---|
3030 | |
---|
3031 | %------------------------------------------------------------------------ |
---|
3032 | % ---- read the data displayed for the second input rootfile windows |
---|
3033 | %------------------------------------------------------------------------ |
---|
3034 | function [RootPath_1,SubDir_1,RootFile_1,FileIndex_1,FileExt_1,NomType_1]=read_file_boxes_1(handles) |
---|
3035 | |
---|
3036 | RootPath_1=get(handles.RootPath_1,'String'); % read the data from the file1_input window |
---|
3037 | if isequal(get(handles.RootPath_1,'Visible'),'off') || isequal(RootPath_1,'"') |
---|
3038 | RootPath_1=get(handles.RootPath,'String'); |
---|
3039 | end; |
---|
3040 | SubDir_1=get(handles.SubDir_1,'String'); |
---|
3041 | if isequal(get(handles.SubDir_1,'Visible'),'off')|| isequal(SubDir_1,'"') |
---|
3042 | SubDir_1=get(handles.SubDir,'String'); |
---|
3043 | end |
---|
3044 | SubDir_1=regexprep(SubDir_1,'\<[\\/]|[\\/]\>','');%suppress possible / or \ separator at the beginning or the end of the string |
---|
3045 | RootFile_1=get(handles.RootFile_1,'String'); |
---|
3046 | if isequal(get(handles.RootFile_1,'Visible'),'off') || isequal(RootFile_1,'"') |
---|
3047 | RootFile_1=get(handles.RootFile,'String'); |
---|
3048 | end |
---|
3049 | RootFile_1=regexprep(RootFile_1,'\<[\\/]|[\\/]\>','');%suppress possible / or \ separator at the beginning or the end of the string |
---|
3050 | FileIndex_1=get(handles.FileIndex_1,'String'); |
---|
3051 | if isequal(get(handles.FileIndex_1,'Visible'),'off')|| isequal(FileIndex_1,'"') |
---|
3052 | FileIndex_1=get(handles.FileIndex,'String'); |
---|
3053 | end |
---|
3054 | FileExt_1=get(handles.FileExt_1,'String'); |
---|
3055 | if isequal(get(handles.FileExt_1,'Visible'),'off') || isequal(FileExt_1,'"') |
---|
3056 | FileExt_1=get(handles.FileExt,'String');%read FileExt by default |
---|
3057 | end |
---|
3058 | NomType_1=get(handles.NomType_1,'String'); |
---|
3059 | if isequal(get(handles.NomType_1,'Visible'),'off') || isequal(NomType_1,'"') |
---|
3060 | NomType_1=get(handles.NomType,'String');%read FileExt by default |
---|
3061 | end |
---|
3062 | %------------------------------------------------------------------------ |
---|
3063 | % --- Executes on menu selection FieldName |
---|
3064 | function FieldName_Callback(hObject, eventdata, handles) |
---|
3065 | %------------------------------------------------------------------------ |
---|
3066 | |
---|
3067 | %% read data from uvmat |
---|
3068 | UvData=get(handles.uvmat,'UserData'); |
---|
3069 | list_fields=get(handles.FieldName,'String');% list menu fields |
---|
3070 | index_fields=get(handles.FieldName,'Value');% selected string index |
---|
3071 | field= list_fields{index_fields(1)}; % selected string |
---|
3072 | [RootPath,SubDir,RootFile,FileIndices,FileExt]=read_file_boxes(handles); |
---|
3073 | FileName=[fullfile(RootPath,SubDir,RootFile) FileIndices FileExt]; |
---|
3074 | [tild,tild,tild,i1,i2,j1,j2,tild,NomType]=fileparts_uvmat(['xxx' get(handles.FileIndex,'String') FileExt]); |
---|
3075 | |
---|
3076 | switch field |
---|
3077 | |
---|
3078 | case 'get_field...' |
---|
3079 | %% fill the coordinates and variables from selections in get_field |
---|
3080 | ParamIn=[]; |
---|
3081 | % in case of civ data, we use the civ choice as default input for the GUI get_field |
---|
3082 | if strcmp(get(handles.VelType,'Visible'),'on') |
---|
3083 | ParamIn.SwitchVarIndexTime='attribute'; |
---|
3084 | ListVelType=get(handles.VelType,'String'); |
---|
3085 | VelType=ListVelType{get(handles.VelType,'Value')}; |
---|
3086 | switch VelType |
---|
3087 | case 'civ1' |
---|
3088 | ParamIn.TimeAttrName='Civ1_Time'; |
---|
3089 | ParamIn.vector_x='Civ1_U'; |
---|
3090 | ParamIn.vector_y='Civ1_V'; |
---|
3091 | ParamIn.vec_color='Civ1_C'; |
---|
3092 | case 'filter1' |
---|
3093 | ParamIn.TimeAttrName='Civ1_Time'; |
---|
3094 | ParamIn.vector_x='Civ1_U_smooth'; |
---|
3095 | ParamIn.vector_y='Civ1_V_smooth'; |
---|
3096 | case 'civ2' |
---|
3097 | ParamIn.TimeAttrName='Civ2_Time'; |
---|
3098 | ParamIn.vector_x='Civ2_U'; |
---|
3099 | ParamIn.vector_y='Civ2_V'; |
---|
3100 | case 'filter2' |
---|
3101 | ParamIn.TimeAttrName='Civ2_Time'; |
---|
3102 | ParamIn.vector_x='Civ2_U_smooth'; |
---|
3103 | ParamIn.vector_y='Civ2_V_smooth'; |
---|
3104 | ParamIn.vec_color='Civ2_C'; |
---|
3105 | end |
---|
3106 | end |
---|
3107 | |
---|
3108 | % VelType menu desactivated |
---|
3109 | set(handles.FixVelType,'visible','off') |
---|
3110 | set(handles.VelType,'Visible','off') |
---|
3111 | |
---|
3112 | %read selection from get_field |
---|
3113 | [RootPath,SubDir,RootFile,FileIndices,FileExt]=read_file_boxes(handles); |
---|
3114 | FileName=[fullfile(RootPath,SubDir,RootFile) FileIndices FileExt]; |
---|
3115 | GetFieldData=get_field(FileName,ParamIn);% inport field names from the GUI get_field |
---|
3116 | FieldList={}; |
---|
3117 | VecColorList={}; |
---|
3118 | switch GetFieldData.FieldOption |
---|
3119 | case 'vectors' |
---|
3120 | UName=GetFieldData.PanelVectors.vector_x; |
---|
3121 | VName=GetFieldData.PanelVectors.vector_y; |
---|
3122 | YName={GetFieldData.Coordinates.Coord_y}; |
---|
3123 | CName=GetFieldData.PanelVectors.vec_color; |
---|
3124 | FieldList={['vec(' UName ',' VName ')'];... |
---|
3125 | ['norm(' UName ',' VName ')'];... |
---|
3126 | UName;VName}; |
---|
3127 | VecColorList={['norm(' UName ',' VName ')'];... |
---|
3128 | UName;VName}; |
---|
3129 | if ~isempty(CName) |
---|
3130 | VecColorList=[{CName};VecColorList]; |
---|
3131 | end |
---|
3132 | case 'scalar' |
---|
3133 | AName=GetFieldData.PanelScalar.scalar; |
---|
3134 | YName={GetFieldData.Coordinates.Coord_y}; |
---|
3135 | FieldList={AName}; |
---|
3136 | case '1D plot' |
---|
3137 | YName=GetFieldData.PanelOrdinate.ordinate; |
---|
3138 | case 'civdata...'%reinitiate input, return to automatic civ data reading |
---|
3139 | display_file_name(handles,FileName,1) |
---|
3140 | end |
---|
3141 | if ~strcmp(GetFieldData.FieldOption,'civdata...') |
---|
3142 | XName=GetFieldData.Coordinates.Coord_x; |
---|
3143 | TimeNameStr=GetFieldData.Time.SwitchVarIndexTime; |
---|
3144 | switch TimeNameStr |
---|
3145 | case 'file index' |
---|
3146 | set(handles.TimeName,'String',''); |
---|
3147 | case 'attribute' |
---|
3148 | set(handles.TimeName,'String',['att:' GetFieldData.Time.TimeName]); |
---|
3149 | case 'variable' |
---|
3150 | set(handles.TimeName,'String',['var:' GetFieldData.Time.TimeName]) |
---|
3151 | set(handles.NomType,'String','*') |
---|
3152 | set(handles.RootFile,'String',[get(handles.RootFile,'String') get(handles.FileIndex,'String')]) |
---|
3153 | set(handles.FileIndex,'String','') |
---|
3154 | ParamIn.TimeVarName=GetFieldData.Time.TimeName; |
---|
3155 | case 'matrix_index' |
---|
3156 | set(handles.TimeName,'String',['dim:' GetFieldData.Time.TimeName]); |
---|
3157 | set(handles.NomType,'String','*') |
---|
3158 | set(handles.RootFile,'String',[get(handles.RootFile,'String') get(handles.FileIndex,'String')]) |
---|
3159 | set(handles.FileIndex,'String','') |
---|
3160 | ParamIn.TimeDimName=GetFieldData.Time.TimeName; |
---|
3161 | end |
---|
3162 | set(handles.Coord_x,'String',XName) |
---|
3163 | if ischar(YName) |
---|
3164 | YName={YName}; |
---|
3165 | end |
---|
3166 | set(handles.Coord_y,'Data',YName) |
---|
3167 | set(handles.FieldName,'Value',1) |
---|
3168 | set(handles.FieldName,'String',[FieldList; {'get_field...'}]); |
---|
3169 | set(handles.ColorScalar,'Value',1) |
---|
3170 | set(handles.ColorScalar,'String',VecColorList); |
---|
3171 | UvData.FileType{1}='netcdf'; |
---|
3172 | set(handles.uvmat,'UserData',UvData) |
---|
3173 | REFRESH_Callback(hObject, eventdata, handles) |
---|
3174 | end |
---|
3175 | |
---|
3176 | case 'image' |
---|
3177 | %% look for image corresponding to civ data |
---|
3178 | if isfield(UvData.Field,'Civ2_ImageA')%get the corresponding input image in the netcdf file |
---|
3179 | imagename=UvData.Field.Civ2_ImageA; |
---|
3180 | elseif isfield(UvData.Field,'Civ1_ImageA')% |
---|
3181 | imagename=UvData.Field.Civ1_ImageA; |
---|
3182 | else |
---|
3183 | SubDirBase=regexprep(SubDir,'\..*','');%take the root part of SubDir, before the first dot '.' |
---|
3184 | imagename=fullfile_uvmat(RootPath,SubDirBase,RootFile,'.png',NomType,i1,[],j1,[]); |
---|
3185 | end |
---|
3186 | if ~exist(imagename,'file') |
---|
3187 | imagename=uigetfile_uvmat('Pick an image file',imagename,'image'); |
---|
3188 | if isempty(imagename) |
---|
3189 | return |
---|
3190 | end |
---|
3191 | end |
---|
3192 | % display the selected field and related information |
---|
3193 | display_file_name(handles,imagename)%display the image |
---|
3194 | otherwise |
---|
3195 | REFRESH_Callback(hObject, eventdata, handles) |
---|
3196 | end |
---|
3197 | |
---|
3198 | %---------------------------------------------------------------- |
---|
3199 | % --- Executes on menu selection FieldName |
---|
3200 | function FieldName_1_Callback(hObject, eventdata, handles) |
---|
3201 | %------------------------------------------------- |
---|
3202 | |
---|
3203 | %%%%%% TODO: modify like FieldName_Callback |
---|
3204 | %% read input data |
---|
3205 | check_new=~get(handles.SubField,'Value'); %check_new=1 if a second field was not previously entered |
---|
3206 | UvData=get(handles.uvmat,'UserData'); |
---|
3207 | if check_new && isfield(UvData,'XmlData') |
---|
3208 | UvData.XmlData{2}=UvData.XmlData{1}; |
---|
3209 | end |
---|
3210 | if isfield(UvData,'Field_1') |
---|
3211 | UvData=rmfield(UvData,'Field_1');% remove the stored second field (a new one needs to be read) |
---|
3212 | end |
---|
3213 | UvData.FileName_1='';% desactivate the use of a constant second file |
---|
3214 | list_fields=get(handles.FieldName,'String');% list menu fields |
---|
3215 | field= list_fields{get(handles.FieldName,'Value')}; % selected string |
---|
3216 | list_fields=get(handles.FieldName_1,'String');% list menu fields |
---|
3217 | field_1= list_fields{get(handles.FieldName_1,'Value')}; % selected string for the second field |
---|
3218 | if isempty(field_1)%||(numel(UvData.FileType)>=2 && strcmp(UvData.FileType{2},'image')) |
---|
3219 | set(handles.SubField,'Value',0) |
---|
3220 | SubField_Callback(hObject, eventdata, handles) |
---|
3221 | return |
---|
3222 | else |
---|
3223 | set(handles.SubField,'Value',1)%state that a second field is now entered |
---|
3224 | end |
---|
3225 | |
---|
3226 | %% read the rootfile input display |
---|
3227 | [RootPath_1,SubDir_1,RootFile_1,FileIndex_1,FileExt_1]=read_file_boxes_1(handles); |
---|
3228 | FileName_1=[fullfile(RootPath_1,SubDir_1,RootFile_1) FileIndex_1 FileExt_1]; |
---|
3229 | [tild,tild,tild,i1,i2,j1,j2]=fileparts_uvmat(get(handles.FileIndex,'String')); |
---|
3230 | switch field_1 |
---|
3231 | case 'get_field...' |
---|
3232 | %% fill the coordinates and variables from selections in get_field |
---|
3233 | ParamIn=[]; |
---|
3234 | % in case of civ data, we use the civ choice as default input for the GUI get_field |
---|
3235 | if strcmp(get(handles.VelType_1,'Visible'),'on') |
---|
3236 | ParamIn.SwitchVarIndexTime='attribute'; |
---|
3237 | ListVelType=get(handles.VelType_1,'String'); |
---|
3238 | VelType=ListVelType{get(handles.VelType_1,'Value')}; |
---|
3239 | switch VelType |
---|
3240 | case 'civ1' |
---|
3241 | ParamIn.TimeAttrName='Civ1_Time'; |
---|
3242 | ParamIn.vector_x='Civ1_U'; |
---|
3243 | ParamIn.vector_y='Civ1_V'; |
---|
3244 | ParamIn.vec_color='Civ1_C'; |
---|
3245 | case 'filter1' |
---|
3246 | ParamIn.TimeAttrName='Civ1_Time'; |
---|
3247 | ParamIn.vector_x='Civ1_U_smooth'; |
---|
3248 | ParamIn.vector_y='Civ1_V_smooth'; |
---|
3249 | case 'civ2' |
---|
3250 | ParamIn.TimeAttrName='Civ2_Time'; |
---|
3251 | ParamIn.vector_x='Civ2_U'; |
---|
3252 | ParamIn.vector_y='Civ2_V'; |
---|
3253 | case 'filter2' |
---|
3254 | ParamIn.TimeAttrName='Civ2_Time'; |
---|
3255 | ParamIn.vector_x='Civ2_U_smooth'; |
---|
3256 | ParamIn.vector_y='Civ2_V_smooth'; |
---|
3257 | ParamIn.vec_color='Civ2_C'; |
---|
3258 | end |
---|
3259 | end |
---|
3260 | |
---|
3261 | % VelType menu desactivated |
---|
3262 | set(handles.FixVelType,'visible','off') |
---|
3263 | set(handles.VelType,'Visible','off') |
---|
3264 | |
---|
3265 | %read selection from get_field |
---|
3266 | [RootPath,SubDir,RootFile,FileIndices,FileExt]=read_file_boxes_1(handles); |
---|
3267 | FileName=[fullfile(RootPath,SubDir,RootFile) FileIndices FileExt]; |
---|
3268 | GetFieldData=get_field(FileName,ParamIn);% inport field names from the GUI get_field |
---|
3269 | FieldList={}; |
---|
3270 | VecColorList={}; |
---|
3271 | switch GetFieldData.FieldOption |
---|
3272 | case 'vectors' |
---|
3273 | UName=GetFieldData.PanelVectors.vector_x; |
---|
3274 | VName=GetFieldData.PanelVectors.vector_y; |
---|
3275 | YName={GetFieldData.Coordinates.Coord_y}; |
---|
3276 | CName=GetFieldData.PanelVectors.vec_color; |
---|
3277 | FieldList={['vec(' UName ',' VName ')'];... |
---|
3278 | ['norm(' UName ',' VName ')'];... |
---|
3279 | UName;VName}; |
---|
3280 | VecColorList={['norm(' UName ',' VName ')'];... |
---|
3281 | UName;VName}; |
---|
3282 | if ~isempty(CName) |
---|
3283 | VecColorList=[{CName};VecColorList]; |
---|
3284 | end |
---|
3285 | case 'scalar' |
---|
3286 | AName=GetFieldData.PanelScalar.scalar; |
---|
3287 | YName={GetFieldData.Coordinates.Coord_y}; |
---|
3288 | FieldList={AName}; |
---|
3289 | case '1D plot' |
---|
3290 | YName=GetFieldData.PanelOrdinate.ordinate; |
---|
3291 | case 'civdata...'%reinitiate input, return to automatic civ data reading |
---|
3292 | display_file_name(handles,FileName,1) |
---|
3293 | end |
---|
3294 | if ~strcmp(GetFieldData.FieldOption,'civdata...') |
---|
3295 | XName=GetFieldData.Coordinates.Coord_x; |
---|
3296 | TimeNameStr=GetFieldData.Time.SwitchVarIndexTime; |
---|
3297 | switch TimeNameStr |
---|
3298 | case 'file index' |
---|
3299 | set(handles.TimeName_1,'String',''); |
---|
3300 | case 'attribute' |
---|
3301 | set(handles.TimeName_1,'String',['att:' GetFieldData.Time.TimeName]); |
---|
3302 | case 'variable' |
---|
3303 | set(handles.TimeName_1,'String',['var:' GetFieldData.Time.TimeName]) |
---|
3304 | set(handles.NomType_1,'String','*') |
---|
3305 | set(handles.RootFile_1,'String',[get(handles.RootFile,'String') get(handles.FileIndex,'String')]) |
---|
3306 | set(handles.FileIndex_1,'String','') |
---|
3307 | ParamIn.TimeVarName=GetFieldData.Time.TimeName; |
---|
3308 | case 'matrix_index' |
---|
3309 | set(handles.TimeName_1,'String',['dim:' GetFieldData.Time.TimeName]); |
---|
3310 | set(handles.NomType_1,'String','*') |
---|
3311 | set(handles.RootFile_1,'String',[get(handles.RootFile,'String') get(handles.FileIndex,'String')]) |
---|
3312 | set(handles.FileIndex_1,'String','') |
---|
3313 | ParamIn.TimeDimName_1=GetFieldData.Time.TimeName; |
---|
3314 | end |
---|
3315 | set(handles.Coord_x,'String',XName) |
---|
3316 | if ischar(YName) |
---|
3317 | YName={YName}; |
---|
3318 | end |
---|
3319 | set(handles.Coord_y,'Data',YName) |
---|
3320 | set(handles.FieldName_1,'Value',1) |
---|
3321 | set(handles.FieldName_1,'String',[FieldList; {'get_field...'}]); |
---|
3322 | set(handles.ColorScalar,'Value',1) |
---|
3323 | set(handles.ColorScalar,'String',VecColorList); |
---|
3324 | UvData.FileType{2}='netcdf'; |
---|
3325 | set(handles.uvmat,'UserData',UvData) |
---|
3326 | REFRESH_Callback(hObject, eventdata, handles) |
---|
3327 | end |
---|
3328 | |
---|
3329 | % set_veltype_display(0) % no veltype display |
---|
3330 | % hget_field=findobj(allchild(0),'name','get_field_1'); |
---|
3331 | % if ~isempty(hget_field) |
---|
3332 | % delete(hget_field) |
---|
3333 | % end |
---|
3334 | % hget_field=get_field(FileName_1); |
---|
3335 | % set(hget_field,'name','get_field_1') |
---|
3336 | % hhget_field=guidata(hget_field); |
---|
3337 | % set(hhget_field.list_fig,'Value',1) |
---|
3338 | % set(hhget_field.list_fig,'String',{'uvmat'}) |
---|
3339 | % if check_new |
---|
3340 | % UvData.FileType{2}=UvData.FileType{1}; |
---|
3341 | % set(handles.FileIndex_1,'String',get(handles.FileIndex,'String')) |
---|
3342 | % set(handles.uvmat,'UserData',UvData) |
---|
3343 | % end |
---|
3344 | case 'image' |
---|
3345 | %% look for image corresponding to civ data |
---|
3346 | imagename=''; |
---|
3347 | if isfield(UvData.Field,'Civ2_ImageA')%get the corresponding input image in the netcdf file |
---|
3348 | imagename=UvData.Field.Civ2_ImageA; |
---|
3349 | elseif isfield(UvData.Field,'Civ1_ImageA')% |
---|
3350 | imagename=UvData.Field.Civ1_ImageA; |
---|
3351 | else |
---|
3352 | SubDirBase=regexprep(SubDir,'\..*','');%take the root part of SubDir, before the first dot '.' |
---|
3353 | imagename=fullfile_uvmat(RootPath,SubDirBase,RootFile,'.png',NomType,i1,[],j1,[]); |
---|
3354 | end |
---|
3355 | if ~exist(imagename,'file') |
---|
3356 | imagename=uigetfile_uvmat('Pick an image file',imagename,'image'); |
---|
3357 | |
---|
3358 | end |
---|
3359 | if isempty(imagename) |
---|
3360 | set(handles.SubField,'Value',0) |
---|
3361 | return |
---|
3362 | else |
---|
3363 | display_file_name(handles,imagename,2)%display the image as second field |
---|
3364 | end |
---|
3365 | otherwise |
---|
3366 | check_refresh=1; |
---|
3367 | if check_new% if a second field was not previously entered, we just read another field in the first input file |
---|
3368 | set(handles.FileIndex_1,'String',get(handles.FileIndex,'String')) |
---|
3369 | set(handles.FileExt_1,'String',get(handles.FileExt,'String')) |
---|
3370 | |
---|
3371 | UvData.FileType{2}=UvData.FileType{1}; |
---|
3372 | UvData.XmlData{2}= UvData.XmlData{1}; |
---|
3373 | transform=get(handles.TransformPath,'UserData'); |
---|
3374 | if (~isa(transform,'function_handle')||nargin(transform)<3) |
---|
3375 | set(handles.uvmat,'UserData',UvData) |
---|
3376 | set(handles.TransformName,'value',2); % set transform fct to 'sub_field' if the current fct does not accept two input fields |
---|
3377 | TransformName_Callback(hObject, eventdata, handles)% activate transform_fct_Callback and refresh current plot |
---|
3378 | check_refresh=0; |
---|
3379 | end |
---|
3380 | end |
---|
3381 | if ~isequal(field,'image') |
---|
3382 | set(handles.TitleNpxy,'Visible','off')% visible npx,pxcm... buttons |
---|
3383 | set(handles.num_Npx,'Visible','off') |
---|
3384 | set(handles.num_Npy,'Visible','off') |
---|
3385 | end |
---|
3386 | set(handles.uvmat,'UserData',UvData) |
---|
3387 | |
---|
3388 | if check_refresh && ~(isfield(UvData,'NewSeries')&&isequal(UvData.NewSeries,1)) |
---|
3389 | REFRESH_Callback(hObject, eventdata, handles) |
---|
3390 | end |
---|
3391 | end |
---|
3392 | |
---|
3393 | %------------------------------------------------------------------------ |
---|
3394 | % --- set the visibility of relevant velocity type menus: |
---|
3395 | function menu=set_veltype_display(Civ,FileType) |
---|
3396 | %------------------------------------------------------------------------ |
---|
3397 | if ~exist('FileType','var') |
---|
3398 | FileType='civx'; |
---|
3399 | end |
---|
3400 | switch FileType |
---|
3401 | case 'civx' |
---|
3402 | menu={'civ1';'interp1';'filter1';'civ2';'interp2';'filter2'}; |
---|
3403 | if isequal(Civ,0) |
---|
3404 | imax=0; |
---|
3405 | elseif isequal(Civ,1) || isequal(Civ,2) |
---|
3406 | imax=1; |
---|
3407 | elseif isequal(Civ,3) |
---|
3408 | imax=3; |
---|
3409 | elseif isequal(Civ,4) || isequal(Civ,5) |
---|
3410 | imax=4; |
---|
3411 | elseif isequal(Civ,6) %patch2 |
---|
3412 | imax=6; |
---|
3413 | end |
---|
3414 | case 'civdata' |
---|
3415 | menu={'civ1';'filter1';'civ2';'filter2'}; |
---|
3416 | if isequal(Civ,0) |
---|
3417 | imax=0; |
---|
3418 | elseif isequal(Civ,1) || isequal(Civ,2) |
---|
3419 | imax=1; |
---|
3420 | elseif isequal(Civ,3) |
---|
3421 | imax=2; |
---|
3422 | elseif isequal(Civ,4) || isequal(Civ,5) |
---|
3423 | imax=3; |
---|
3424 | elseif isequal(Civ,6) %patch2 |
---|
3425 | imax=4; |
---|
3426 | end |
---|
3427 | end |
---|
3428 | menu=menu(1:imax); |
---|
3429 | |
---|
3430 | %------------------------------------------------------------------------ |
---|
3431 | % --- Executes on button press in FixVelType. |
---|
3432 | function FixVelType_Callback(hObject, eventdata, handles) |
---|
3433 | %------------------------------------------------------------------------ |
---|
3434 | % inputfilerefresh the current plot if the fixed veltype is unselected |
---|
3435 | if ~get(handles.FixVelType,'Value') |
---|
3436 | REFRESH_Callback(hObject, eventdata, handles) |
---|
3437 | end |
---|
3438 | |
---|
3439 | %------------------------------------------------------------------------ |
---|
3440 | % --- Executes on button press in VelType. |
---|
3441 | function VelType_Callback(hObject, eventdata, handles) |
---|
3442 | %------------------------------------------------------------------------ |
---|
3443 | set(handles.FixVelType,'Value',1) |
---|
3444 | REFRESH_Callback(hObject, eventdata, handles) |
---|
3445 | |
---|
3446 | %------------------------------------------------------------------------ |
---|
3447 | % --- Executes on choice selection in VelType_1. |
---|
3448 | function VelType_1_Callback(hObject, eventdata, handles) |
---|
3449 | %------------------------------------------------------------------------ |
---|
3450 | set(handles.FixVelType,'Value',1)% the velocity type is now imposed by the GUI (not automatic) |
---|
3451 | UvData=get(handles.uvmat,'UserData'); |
---|
3452 | set(handles.InputFileREFRESH,'BackgroundColor',[1 1 0])%paint REFRESH button in yellow to indicate its activation |
---|
3453 | drawnow |
---|
3454 | InputFile=read_GUI(handles.InputFile);% read the input file parameters |
---|
3455 | [RootPath,SubDir,RootFile,FileIndex,FileExt]=read_file_boxes(handles); |
---|
3456 | [RootPath_1,SubDir_1,RootFile_1,FileIndex_1,FileExt_1]=read_file_boxes_1(handles); |
---|
3457 | FileName=[fullfile(RootPath,SubDir,RootFile) FileIndex FileExt];% name of the first input file |
---|
3458 | |
---|
3459 | check_refresh=0; |
---|
3460 | if isempty(InputFile.VelType_1) |
---|
3461 | FileName_1='';% we plot the first input field without the second field |
---|
3462 | set(handles.SubField,'Value',0) |
---|
3463 | SubField_Callback(hObject, eventdata, handles)% activate SubField_Callback and refresh current plot, removing the second field |
---|
3464 | elseif get(handles.SubField,'Value')% if subfield is already 'on' |
---|
3465 | FileName_1=[fullfile(RootPath_1,SubDir_1,RootFile_1) FileIndex_1 FileExt_1];% name of the second input file |
---|
3466 | check_refresh=1;%will refresh the current plot |
---|
3467 | else% we introduce the same file (with a different field) for the second series |
---|
3468 | FileName_1=FileName;% we compare two fields in the same file |
---|
3469 | UvData.FileType{2}=UvData.FileType{1}; |
---|
3470 | UvData.XmlData{2}= UvData.XmlData{1}; |
---|
3471 | set(handles.SubField,'Value',1) |
---|
3472 | transform=get(handles.TransformPath,'UserData'); |
---|
3473 | if (~isa(transform,'function_handle')||nargin(transform)<3) |
---|
3474 | set(handles.uvmat,'UserData',UvData) |
---|
3475 | set(handles.TransformName,'value',2); % set transform fct to 'sub_field' if the current fct does not accept two input fields |
---|
3476 | TransformName_Callback(hObject, eventdata, handles)% activate transform_fct_Callback and refresh current plot |
---|
3477 | else |
---|
3478 | check_refresh=1; |
---|
3479 | end |
---|
3480 | end |
---|
3481 | |
---|
3482 | % inputfilerefresh the current plot if it has not been done previously |
---|
3483 | if check_refresh |
---|
3484 | UvData.FileName_1='';% desactivate the use of a constant second file |
---|
3485 | set(handles.uvmat,'UserData',UvData) |
---|
3486 | num_i1=stra2num(get(handles.i1,'String')); |
---|
3487 | num_i2=stra2num(get(handles.i2,'String')); |
---|
3488 | num_j1=stra2num(get(handles.j1,'String')); |
---|
3489 | num_j2=stra2num(get(handles.j2,'String')); |
---|
3490 | [tild,tild,tild,i1_1,i2_1,j1_1,j2_1]=fileparts_uvmat(['xx' FileIndex_1]); |
---|
3491 | errormsg=refresh_field(handles,FileName,FileName_1,num_i1,num_i2,num_j1,num_j2,i1_1,i2_1,j1_1,j2_1); |
---|
3492 | if ~isempty(errormsg) |
---|
3493 | msgbox_uvmat('ERROR',errormsg); |
---|
3494 | else |
---|
3495 | set(handles.i1,'BackgroundColor',[1 1 1]) |
---|
3496 | set(handles.i2,'BackgroundColor',[1 1 1]) |
---|
3497 | set(handles.j1,'BackgroundColor',[1 1 1]) |
---|
3498 | set(handles.j2,'BackgroundColor',[1 1 1]) |
---|
3499 | set(handles.FileIndex,'BackgroundColor',[1 1 1]) |
---|
3500 | set(handles.FileIndex_1,'BackgroundColor',[1 1 1]) |
---|
3501 | end |
---|
3502 | set(handles.InputFileREFRESH,'BackgroundColor',[1 0 0]) |
---|
3503 | end |
---|
3504 | |
---|
3505 | |
---|
3506 | %------------------------------------------------------------------------ |
---|
3507 | % --- reset civ buttons |
---|
3508 | function reset_vel_type(handles_civ0,handle1) |
---|
3509 | %------------------------------------------------------------------------ |
---|
3510 | for ibutton=1:length(handles_civ0) |
---|
3511 | set(handles_civ0(ibutton),'BackgroundColor',[0.831 0.816 0.784]) |
---|
3512 | set(handles_civ0(ibutton),'Value',0) |
---|
3513 | end |
---|
3514 | if exist('handle1','var')%handles of selected button |
---|
3515 | set(handle1,'BackgroundColor',[1 1 0]) |
---|
3516 | end |
---|
3517 | |
---|
3518 | %----------------------------------------------------------------------- |
---|
3519 | % --- Executes on button press in MENUVOLUME. |
---|
3520 | function VOLUME_Callback(hObject, eventdata, handles) |
---|
3521 | %----------------------------------------------------------------------- |
---|
3522 | %errordlg('command VOL not implemented yet') |
---|
3523 | if ishandle(handles.UVMAT_title) |
---|
3524 | delete(handles.UVMAT_title) |
---|
3525 | end |
---|
3526 | UvData=get(handles.uvmat,'UserData');%read UvData properties stored on the uvmat interface |
---|
3527 | if isequal(get(handles.VOLUME,'Value'),1) |
---|
3528 | set(handles.CheckZoom,'Value',0) |
---|
3529 | % set(handles.CheckZoom,'BackgroundColor',[0.7 0.7 0.7]) |
---|
3530 | set(handles.edit_vect,'Value',0) |
---|
3531 | edit_vect_Callback(hObject, eventdata, handles) |
---|
3532 | set(handles.CheckEditObject,'Value',0) |
---|
3533 | % set(handles.CheckEditObject,'BackgroundColor',[0.7 0.7 0.7]) |
---|
3534 | % set(handles.cal,'Value',0) |
---|
3535 | % set(handles.cal,'BackgroundColor',[0 1 0]) |
---|
3536 | set(handles.edit_vect,'Value',0) |
---|
3537 | edit_vect_Callback(hObject, eventdata, handles) |
---|
3538 | %initiate set_object GUI |
---|
3539 | data.Name='VOLUME'; |
---|
3540 | if isfield(UvData,'CoordType') |
---|
3541 | data.CoordType=UvData.CoordType; |
---|
3542 | end |
---|
3543 | if isfield(UvData.Field,'CoordMesh')&~isempty(UvData.Field.CoordMesh) |
---|
3544 | data.RangeX=[UvData.Field.XMin UvData.Field.XMax]; |
---|
3545 | data.RangeY=[UvData.Field.YMin UvData.Field.YMax]; |
---|
3546 | data.DX=UvData.Field.CoordMesh; |
---|
3547 | data.DY=UvData.Field.CoordMesh; |
---|
3548 | elseif isfield(UvData.Field,'AX')&isfield(UvData.Field,'AY')& isfield(UvData.Field,'A')%only image |
---|
3549 | np=size(UvData.Field.A); |
---|
3550 | meshx=(UvData.Field.AX(end)-UvData.Field.AX(1))/np(2); |
---|
3551 | meshy=abs(UvData.Field.AY(end)-UvData.Field.AY(1))/np(1); |
---|
3552 | data.RangeY=max(meshx,meshy); |
---|
3553 | data.RangeX=max(meshx,meshy); |
---|
3554 | data.DX=max(meshx,meshy); |
---|
3555 | end |
---|
3556 | data.ParentButton=handles.VOLUME; |
---|
3557 | PlotHandles=get_plot_handles(handles);%get the handles of the interface elements setting the plotting parameters |
---|
3558 | [hset_object,UvData.sethandles]=set_object(data,PlotHandles);% call the set_object interface with action on haxes, |
---|
3559 | % associate the set_object interface handle to the plotting axes |
---|
3560 | %set(hset_object,'Position',get(handles.uvmat,'Position')+UvData.OpenParam.PosSetObject) |
---|
3561 | UvData.MouseAction='create_object'; |
---|
3562 | else |
---|
3563 | set(handles.VOLUME,'BackgroundColor',[0 1 0]) |
---|
3564 | end |
---|
3565 | set(handles.uvmat,'UserData',UvData) |
---|
3566 | |
---|
3567 | %------------------------------------------------------- |
---|
3568 | function edit_vect_Callback(hObject, eventdata, handles) |
---|
3569 | %------------------------------------------------------- |
---|
3570 | % |
---|
3571 | if isequal(get(handles.edit_vect,'Value'),1) |
---|
3572 | VelTypeMenu=get(handles.VelType,'String'); |
---|
3573 | VelType=VelTypeMenu{get(handles.VelType,'Value')}; |
---|
3574 | if ~strcmp(VelType,'civ2') && ~strcmp(VelType,'civ1') |
---|
3575 | msgbox_uvmat('ERROR','manual correction only possible for CIV1 or CIV2 velocity fields') |
---|
3576 | end |
---|
3577 | set(handles.record,'Visible','on') |
---|
3578 | set(handles.edit_vect,'BackgroundColor',[1 1 0]) |
---|
3579 | set(handles.CheckEditObject,'Value',0) |
---|
3580 | set(handles.CheckZoom,'Value',0) |
---|
3581 | % set(handles.CheckZoom,'BackgroundColor',[0.7 0.7 0.7]) |
---|
3582 | % set(handles.CheckEditObject,'BackgroundColor',[0.7 0.7 0.7]) |
---|
3583 | set(gcf,'Pointer','arrow') |
---|
3584 | else |
---|
3585 | set(handles.record,'Visible','off') |
---|
3586 | set(handles.edit_vect,'BackgroundColor',[0.7 0.7 0.7]) |
---|
3587 | end |
---|
3588 | |
---|
3589 | %---------------------------------------------- |
---|
3590 | function save_mask_Callback(hObject, eventdata, handles) |
---|
3591 | %----------------------------------------------------------------------- |
---|
3592 | UvData=get(handles.uvmat,'UserData'); |
---|
3593 | |
---|
3594 | flag=1; |
---|
3595 | npx=size(UvData.Field.A,2); |
---|
3596 | npy=size(UvData.Field.A,1); |
---|
3597 | xi=0.5:npx-0.5; |
---|
3598 | yi=0.5:npy-0.5; |
---|
3599 | [Xi,Yi]=meshgrid(xi,yi); |
---|
3600 | if isfield(UvData,'ProjObject') |
---|
3601 | for iobj=1:length(UvData.ProjObject) |
---|
3602 | ObjectData=UvData.ProjObject{iobj}; |
---|
3603 | if isfield(ObjectData,'ProjMode') &&(isequal(ObjectData.ProjMode,'mask_inside')||isequal(ObjectData.ProjMode,'mask_outside')); |
---|
3604 | flagobj=1; |
---|
3605 | testphys=0; %coordinates in pixels by default |
---|
3606 | if isfield(ObjectData,'CoordType') && isequal(ObjectData.CoordType,'phys') |
---|
3607 | if isfield(UvData,'XmlData')&& isfield(UvData.XmlData{1},'GeometryCalib') |
---|
3608 | Calib=UvData.XmlData{1}.GeometryCalib; |
---|
3609 | testphys=1; |
---|
3610 | end |
---|
3611 | end |
---|
3612 | if isfield(ObjectData,'Coord')& isfield(ObjectData,'Style') |
---|
3613 | if isequal(ObjectData.Type,'polygon') |
---|
3614 | X=ObjectData.Coord(:,1); |
---|
3615 | Y=ObjectData.Coord(:,2); |
---|
3616 | if testphys |
---|
3617 | [X,Y]=px_XYZ(Calib,X,Y,0);% to generalise with 3D cases |
---|
3618 | end |
---|
3619 | flagobj=~inpolygon(Xi,Yi,X',Y');%=0 inside the polygon, 1 outside |
---|
3620 | elseif isequal(ObjectData.Type,'ellipse') |
---|
3621 | if testphys |
---|
3622 | %[X,Y]=px_XYZ(Calib,X,Y,0);% TODO:create a polygon boundary and transform to phys |
---|
3623 | end |
---|
3624 | RangeX=max(ObjectData.RangeX); |
---|
3625 | RangeY=max(ObjectData.RangeY); |
---|
3626 | X2Max=RangeX*RangeX; |
---|
3627 | Y2Max=RangeY*RangeY; |
---|
3628 | distX=(Xi-ObjectData.Coord(1,1)); |
---|
3629 | distY=(Yi-ObjectData.Coord(1,2)); |
---|
3630 | flagobj=(distX.*distX/X2Max+distY.*distY/Y2Max)>1; |
---|
3631 | elseif isequal(ObjectData.Type,'rectangle') |
---|
3632 | if testphys |
---|
3633 | %[X,Y]=px_XYZ(Calib,X,Y,0);% TODO:create a polygon boundary and transform to phys |
---|
3634 | end |
---|
3635 | distX=abs(Xi-ObjectData.Coord(1,1)); |
---|
3636 | distY=abs(Yi-ObjectData.Coord(1,2)); |
---|
3637 | flagobj=distX>max(ObjectData.RangeX) | distY>max(ObjectData.RangeY); |
---|
3638 | end |
---|
3639 | if isequal(ObjectData.ProjMode,'mask_outside') |
---|
3640 | flagobj=~flagobj; |
---|
3641 | end |
---|
3642 | flag=flag & flagobj; |
---|
3643 | end |
---|
3644 | end |
---|
3645 | end |
---|
3646 | end |
---|
3647 | % flag=~flag; |
---|
3648 | %mask name |
---|
3649 | RootPath=get(handles.RootPath,'String'); |
---|
3650 | RootFile=get(handles.RootFile,'String'); |
---|
3651 | RootFile=regexprep(RootFile,'\<[\\/]|[\\/]\>','');%suppress possible / or \ separator at the beginning or the end of the string |
---|
3652 | filebase=fullfile(RootPath,RootFile); |
---|
3653 | list=get(handles.masklevel,'String'); |
---|
3654 | masknumber=num2str(length(list)); |
---|
3655 | maskindex=get(handles.masklevel,'Value'); |
---|
3656 | mask_name=fullfile_uvmat(RootPath,SubDir,[RootFile '_' masknumber 'mask'],'.png','_1',maskindex); |
---|
3657 | %mask_name=name_generator([filebase '_' masknumber 'mask'],maskindex,1,'.png','_i'); |
---|
3658 | imflag=uint8(255*(0.392+0.608*flag));% =100 for flag=0 (vectors not computed when 20<imflag<200) |
---|
3659 | imflag=flipdim(imflag,1); |
---|
3660 | % imflag=uint8(255*flag);% =0 for flag=0 (vectors=0 when 20<imflag<200) |
---|
3661 | msgbox_uvmat('CONFIRMATION',[mask_name ' saved']) |
---|
3662 | imwrite(imflag,mask_name,'BitDepth',8); |
---|
3663 | |
---|
3664 | %display the mask |
---|
3665 | figure; |
---|
3666 | vec=linspace(0,1,256);%define a linear greyscale colormap |
---|
3667 | map=[vec' vec' vec']; |
---|
3668 | colormap(map) |
---|
3669 | |
---|
3670 | image(imflag); |
---|
3671 | |
---|
3672 | %------------------------------------------------------------------------ |
---|
3673 | %------------------------------------------------------------------------ |
---|
3674 | % - FUNCTIONS FOR SETTING PLOTTING PARAMETERS |
---|
3675 | |
---|
3676 | %------------------------------------------------------------------------ |
---|
3677 | %------------------------------------------------------------------------ |
---|
3678 | % --- Executes on selection change in TransformName. |
---|
3679 | |
---|
3680 | function TransformName_Callback(hObject, eventdata, handles) |
---|
3681 | %------------------------------------------------------------------------ |
---|
3682 | UvData=get(handles.uvmat,'UserData'); |
---|
3683 | menu=get(handles.TransformName,'String');%refresh |
---|
3684 | ichoice=get(handles.TransformName,'Value');%item number in the menu |
---|
3685 | transform_name=menu{ichoice};% choice of the transform fct |
---|
3686 | list_path=get(handles.TransformName,'UserData'); |
---|
3687 | |
---|
3688 | %% handles uicontrol visibility |
---|
3689 | if isempty(transform_name) |
---|
3690 | set(handles.TransformPath,'Visible','off') |
---|
3691 | else |
---|
3692 | set(handles.TransformPath,'Visible','on') |
---|
3693 | end |
---|
3694 | |
---|
3695 | |
---|
3696 | %% add a new item to the menu if the option 'more...' has been selected |
---|
3697 | prev_path=fullfile(get(handles.TransformPath,'String')); |
---|
3698 | if ~exist(prev_path,'dir') |
---|
3699 | prev_path=fullfile(fileparts(which('uvmat')),'transform_field'); |
---|
3700 | end |
---|
3701 | if strcmp(transform_name,'more...'); |
---|
3702 | transform_fct_chosen=uigetfile_uvmat('Pick the transform function',prev_path,'.m'); |
---|
3703 | if ~isempty(transform_fct_chosen) |
---|
3704 | [PathName,transform_name]=fileparts(transform_fct_chosen); |
---|
3705 | ichoice=find(strcmp(transform_name,menu),1);%look for the selected fct in the existing menu |
---|
3706 | if isempty(ichoice)% if the item is not found, add it to the menu (before 'more...' and select it) |
---|
3707 | menu=[menu(1:end-1);{transform_name};{'more...'}]; |
---|
3708 | ichoice=numel(menu)-1; |
---|
3709 | end |
---|
3710 | list_path{ichoice}=PathName;%update the list fo fct paths |
---|
3711 | set(handles.TransformName,'String',menu) |
---|
3712 | set(handles.TransformName,'Value',ichoice) |
---|
3713 | |
---|
3714 | % save the new menu in the personal file 'uvmat_perso.mat' |
---|
3715 | dir_perso=prefdir;%personal Matalb directory |
---|
3716 | profil_perso=fullfile(dir_perso,'uvmat_perso.mat'); |
---|
3717 | if exist(profil_perso,'file') |
---|
3718 | nb_builtin=UvData.OpenParam.NbBuiltin;% number of 'builtin' (basic) transform fcts in uvmat |
---|
3719 | if nb_builtin<numel(list_path) |
---|
3720 | for ilist=nb_builtin+1:numel(list_path) |
---|
3721 | transform_fct{ilist-nb_builtin}=[fullfile(list_path{ilist},menu{ilist}) '.m']; |
---|
3722 | end |
---|
3723 | save (profil_perso,'transform_fct','-append'); %store the root name for future opening of uvmat |
---|
3724 | end |
---|
3725 | end |
---|
3726 | end |
---|
3727 | end |
---|
3728 | |
---|
3729 | %% create the function handle of the selected fct |
---|
3730 | if isempty(list_path{ichoice})% case of no selected fct |
---|
3731 | transform_handle=[]; |
---|
3732 | else |
---|
3733 | if ~exist(list_path{ichoice},'dir') |
---|
3734 | msgbox_uvmat('ERROR','invalid fct path: select the transform fct again with the option more...') |
---|
3735 | return |
---|
3736 | end |
---|
3737 | current_dir=pwd;%current working dir |
---|
3738 | cd(list_path{ichoice}) |
---|
3739 | transform_handle=str2func(transform_name); |
---|
3740 | cd(current_dir) |
---|
3741 | end |
---|
3742 | set(handles.TransformPath,'String',list_path{ichoice}) |
---|
3743 | set(handles.TransformPath,'UserData',transform_handle) |
---|
3744 | set(handles.TransformName,'UserData',list_path) |
---|
3745 | |
---|
3746 | %% update the ToolTip string of the menu TransformName with the first line of the selected fct file |
---|
3747 | if isempty(list_path{ichoice})% case of no selected fct |
---|
3748 | set(handles.TransformName,'ToolTipString','transform_fct:choose a transform function') |
---|
3749 | else |
---|
3750 | try |
---|
3751 | [fid,errormsg] =fopen([fullfile(list_path{ichoice},transform_name) '.m']); |
---|
3752 | InputText=textscan(fid,'%s',1,'delimiter','\n'); |
---|
3753 | fclose(fid) |
---|
3754 | set(handles.TransformName,'ToolTipString',['transform_fct: ' InputText{1}{1}])% put the first line of the selected function as tooltip help |
---|
3755 | end |
---|
3756 | end |
---|
3757 | |
---|
3758 | %% adapt the GUI to the input/output conditions of the selected transform fct |
---|
3759 | DataOut=[]; |
---|
3760 | CoordUnit=''; |
---|
3761 | CoordUnitPrev=''; |
---|
3762 | if isfield(UvData,'Field')&&isfield(UvData.Field,'CoordUnit') |
---|
3763 | CoordUnitPrev=UvData.Field.CoordUnit; |
---|
3764 | end |
---|
3765 | if ~isempty(list_path{ichoice}) |
---|
3766 | if nargin(transform_handle)>1 && isfield(UvData,'XmlData')&&~isempty(UvData.XmlData) |
---|
3767 | XmlData=UvData.XmlData{1}; |
---|
3768 | DataOut=feval(transform_handle,'*',XmlData); |
---|
3769 | if isfield(DataOut,'CoordUnit')% set the requested coord unit (info used to possibly delete the current projection objects) |
---|
3770 | CoordUnit=DataOut.CoordUnit; |
---|
3771 | end |
---|
3772 | if isfield(DataOut,'InputFieldType')% to be used to impose a type of input file (eg. for image transform) |
---|
3773 | UvData.InputFieldType=DataOut.InputFieldType; |
---|
3774 | end |
---|
3775 | if isfield(DataOut,'XmlData')% used to add transform parameters at selection of the transform fct |
---|
3776 | ListFields=fieldnames(DataOut.XmlData); |
---|
3777 | for ilist=1:numel(ListFields) |
---|
3778 | UvData.XmlData{1}.(ListFields{ilist})=DataOut.XmlData.(ListFields{ilist}); |
---|
3779 | end |
---|
3780 | end |
---|
3781 | else |
---|
3782 | DataOut=feval(transform_handle,'*'); |
---|
3783 | end |
---|
3784 | end |
---|
3785 | |
---|
3786 | |
---|
3787 | %% delete drawn objects if the output CooordUnit is different from the previous one |
---|
3788 | if ~strcmp(CoordUnit,CoordUnitPrev) |
---|
3789 | set(handles.CheckFixLimits,'Value',0) |
---|
3790 | % set(handles.CheckFixLimits,'BackgroundColor',[0.7 0.7 0.7]) |
---|
3791 | hother=findobj('Tag','proj_object');%find all the proj objects |
---|
3792 | for iobj=1:length(hother) |
---|
3793 | delete_object(hother(iobj)) |
---|
3794 | end |
---|
3795 | hother=findobj('Tag','DeformPoint');%find all the proj objects |
---|
3796 | for iobj=1:length(hother) |
---|
3797 | delete_object(hother(iobj)) |
---|
3798 | end |
---|
3799 | hh=findobj('Tag','calib_points'); |
---|
3800 | if ~isempty(hh) |
---|
3801 | delete(hh) |
---|
3802 | end |
---|
3803 | hhh=findobj('Tag','calib_marker'); |
---|
3804 | if ~isempty(hhh) |
---|
3805 | delete(hhh) |
---|
3806 | end |
---|
3807 | set(handles.ListObject,'Value',1) |
---|
3808 | set(handles.ListObject,'String',{''}) |
---|
3809 | set(handles.ListObject_1,'Value',1) |
---|
3810 | set(handles.ListObject_1,'String',{''}) |
---|
3811 | set(handles.CheckViewObject,'value',0) |
---|
3812 | CheckViewObject_Callback(hObject, eventdata, handles) |
---|
3813 | set(handles.CheckViewField,'value',0) |
---|
3814 | CheckViewField_Callback(hObject, eventdata, handles) |
---|
3815 | set(handles.CheckEditObject,'Value',0) |
---|
3816 | CheckEditObject_Callback(hObject, eventdata, handles) |
---|
3817 | UvData.ProjObject={[]}; |
---|
3818 | end |
---|
3819 | set(handles.uvmat,'UserData',UvData) |
---|
3820 | |
---|
3821 | %% inputfilerefresh the current plot |
---|
3822 | if isempty(list_path{ichoice}) || nargin(transform_handle)<3 |
---|
3823 | set(handles.SubField,'Value',0) |
---|
3824 | SubField_Callback(hObject, eventdata, handles) |
---|
3825 | else |
---|
3826 | REFRESH_Callback(hObject, eventdata, handles) |
---|
3827 | end |
---|
3828 | |
---|
3829 | %------------------------------------------------ |
---|
3830 | %CALLBACKS FOR PLOTTING PARAMETERS |
---|
3831 | %------------------------------------------------- |
---|
3832 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
---|
3833 | % Plot coordinates |
---|
3834 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
---|
3835 | %------------------------------------------------------------------------ |
---|
3836 | function num_MinX_Callback(hObject, eventdata, handles) |
---|
3837 | %------------------------------------------------------------------------ |
---|
3838 | set(handles.CheckFixLimits,'Value',1) %suppress auto mode |
---|
3839 | % set(handles.CheckFixLimits,'BackgroundColor',[1 1 0]) |
---|
3840 | update_plot(handles); |
---|
3841 | |
---|
3842 | %------------------------------------------------------------------------ |
---|
3843 | function num_MaxX_Callback(hObject, eventdata, handles) |
---|
3844 | %------------------------------------------------------------------------ |
---|
3845 | set(handles.CheckFixLimits,'Value',1) %suppress auto mode |
---|
3846 | % set(handles.CheckFixLimits,'BackgroundColor',[1 1 0]) |
---|
3847 | update_plot(handles); |
---|
3848 | |
---|
3849 | %------------------------------------------------------------------------ |
---|
3850 | function num_MinY_Callback(hObject, eventdata, handles) |
---|
3851 | %------------------------------------------ |
---|
3852 | set(handles.CheckFixLimits,'Value',1) %suppress auto mode |
---|
3853 | % set(handles.CheckFixLimits,'BackgroundColor',[1 1 0]) |
---|
3854 | update_plot(handles); |
---|
3855 | |
---|
3856 | %------------------------------------------------------------------------ |
---|
3857 | function num_MaxY_Callback(hObject, eventdata, handles) |
---|
3858 | %------------------------------------------------------------------------ |
---|
3859 | set(handles.CheckFixLimits,'Value',1) %suppress auto mode |
---|
3860 | % set(handles.CheckFixLimits,'BackgroundColor',[1 1 0]) |
---|
3861 | update_plot(handles); |
---|
3862 | |
---|
3863 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
---|
3864 | % Scalar or image representation |
---|
3865 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
---|
3866 | %------------------------------------------------------------------------ |
---|
3867 | function num_MinA_Callback(hObject, eventdata, handles) |
---|
3868 | %------------------------------------------ |
---|
3869 | set(handles.CheckFixScalar,'Value',1) %suppress auto mode |
---|
3870 | % set(handles.CheckFixScalar,'BackgroundColor',[1 1 0]) |
---|
3871 | MinA=str2double(get(handles.num_MinA,'String')); |
---|
3872 | MaxA=str2double(get(handles.num_MaxA,'String')); |
---|
3873 | if MinA>MaxA% switch minA and maxA in case of error |
---|
3874 | MinA_old=MinA; |
---|
3875 | MinA=MaxA; |
---|
3876 | MaxA=MinA_old; |
---|
3877 | set(handles.num_MinA,'String',num2str(MinA,5)); |
---|
3878 | set(handles.num_MaxA,'String',num2str(MaxA,5)); |
---|
3879 | end |
---|
3880 | update_plot(handles); |
---|
3881 | |
---|
3882 | %------------------------------------------------------------------------ |
---|
3883 | function num_MaxA_Callback(hObject, eventdata, handles) |
---|
3884 | %------------------------------------------------------------------------ |
---|
3885 | set(handles.CheckFixScalar,'Value',1) %suppress auto mode |
---|
3886 | % set(handles.CheckFixScalar,'BackgroundColor',[1 1 0]) |
---|
3887 | MinA=str2double(get(handles.num_MinA,'String')); |
---|
3888 | MaxA=str2double(get(handles.num_MaxA,'String')); |
---|
3889 | if MinA>MaxA% switch minA and maxA in case of error |
---|
3890 | MinA_old=MinA; |
---|
3891 | MinA=MaxA; |
---|
3892 | MaxA=MinA_old; |
---|
3893 | set(handles.num_MinA,'String',num2str(MinA,5)); |
---|
3894 | set(handles.num_MaxA,'String',num2str(MaxA,5)); |
---|
3895 | end |
---|
3896 | update_plot(handles); |
---|
3897 | |
---|
3898 | %------------------------------------------------------------------------ |
---|
3899 | function CheckFixScalar_Callback(hObject, eventdata, handles) |
---|
3900 | %------------------------------------------------------------------------ |
---|
3901 | test=get(handles.CheckFixScalar,'Value'); |
---|
3902 | if test |
---|
3903 | % set(handles.CheckFixScalar,'BackgroundColor',[1 1 0]) |
---|
3904 | else |
---|
3905 | % set(handles.CheckFixScalar,'BackgroundColor',[0.7 0.7 0.7]) |
---|
3906 | update_plot(handles); |
---|
3907 | end |
---|
3908 | |
---|
3909 | %------------------------------------------------------------------- |
---|
3910 | function CheckBW_Callback(hObject, eventdata, handles) |
---|
3911 | %------------------------------------------------------------------- |
---|
3912 | update_plot(handles); |
---|
3913 | |
---|
3914 | %------------------------------------------------------------------- |
---|
3915 | function num_Opacity_Callback(hObject, eventdata, handles) |
---|
3916 | update_plot(handles); |
---|
3917 | %------------------------------------------------------------------- |
---|
3918 | |
---|
3919 | %------------------------------------------------------------------- |
---|
3920 | function ListContour_Callback(hObject, eventdata, handles) |
---|
3921 | %------------------------------------------------------------------- |
---|
3922 | val=get(handles.ListContour,'Value'); |
---|
3923 | if val==2% option 'contours' |
---|
3924 | set(handles.interval_txt,'Visible','on') |
---|
3925 | set(handles.num_IncrA,'Visible','on') |
---|
3926 | set(handles.num_IncrA,'String','')% refresh contour interval |
---|
3927 | % set(handles.opacity_txt,'Visible','off') |
---|
3928 | % set(handles.num_Opacity,'Visible','off') |
---|
3929 | else % option 'image' |
---|
3930 | set(handles.interval_txt,'Visible','off') |
---|
3931 | set(handles.num_IncrA,'Visible','off') |
---|
3932 | % set(handles.opacity_txt,'Visible','on') |
---|
3933 | % set(handles.num_Opacity,'Visible','on') |
---|
3934 | end |
---|
3935 | update_plot(handles); |
---|
3936 | |
---|
3937 | %------------------------------------------------------------------- |
---|
3938 | function num_IncrA_Callback(hObject, eventdata, handles) |
---|
3939 | %------------------------------------------------------------------- |
---|
3940 | update_plot(handles); |
---|
3941 | |
---|
3942 | |
---|
3943 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
---|
3944 | % Vector representation |
---|
3945 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
---|
3946 | %------------------------------------------------------------------- |
---|
3947 | function CheckHideWarning_Callback(hObject, eventdata, handles) |
---|
3948 | %------------------------------------------------------------------- |
---|
3949 | update_plot(handles); |
---|
3950 | |
---|
3951 | %------------------------------------------------------------------- |
---|
3952 | function CheckHideFalse_Callback(hObject, eventdata, handles) |
---|
3953 | %------------------------------------------------------------------- |
---|
3954 | update_plot(handles); |
---|
3955 | |
---|
3956 | %------------------------------------------------------------------- |
---|
3957 | function num_VecScale_Callback(hObject, eventdata, handles) |
---|
3958 | %------------------------------------------------------------------- |
---|
3959 | set(handles.CheckFixVectors,'Value',1); |
---|
3960 | set(handles.CheckFixVectors,'BackgroundColor',[1 1 0]) |
---|
3961 | update_plot(handles); |
---|
3962 | |
---|
3963 | %------------------------------------------------------------------- |
---|
3964 | function CheckFixVectors_Callback(hObject, eventdata, handles) |
---|
3965 | %------------------------------------------------------------------- |
---|
3966 | if ~get(handles.CheckFixVectors,'Value') |
---|
3967 | update_plot(handles); |
---|
3968 | end |
---|
3969 | |
---|
3970 | %------------------------------------------------------------------------ |
---|
3971 | % --- Executes on selection change in CheckDecimate4 (nb_vec/4). |
---|
3972 | %------------------------------------------------------------------------ |
---|
3973 | function CheckDecimate4_Callback(hObject, eventdata, handles) |
---|
3974 | |
---|
3975 | if isequal(get(handles.CheckDecimate4,'Value'),1) |
---|
3976 | set(handles.CheckDecimate16,'Value',0) |
---|
3977 | end |
---|
3978 | update_plot(handles); |
---|
3979 | |
---|
3980 | %------------------------------------------------------------------------ |
---|
3981 | % --- Executes on selection change in CheckDecimate16 (nb_vec/16). |
---|
3982 | %------------------------------------------------------------------------ |
---|
3983 | function CheckDecimate16_Callback(hObject, eventdata, handles) |
---|
3984 | |
---|
3985 | if isequal(get(handles.CheckDecimate16,'Value'),1) |
---|
3986 | set(handles.CheckDecimate4,'Value',0) |
---|
3987 | end |
---|
3988 | update_plot(handles); |
---|
3989 | |
---|
3990 | %------------------------------------------------------------------------ |
---|
3991 | % --- Executes on selection change in ColorCode menu |
---|
3992 | function ColorCode_Callback(hObject, eventdata, handles) |
---|
3993 | %------------------------------------------------------------------------ |
---|
3994 | % edit the choice for color code |
---|
3995 | update_color_code_boxes(handles); |
---|
3996 | update_plot(handles); |
---|
3997 | |
---|
3998 | %------------------------------------------------------------------------ |
---|
3999 | function update_color_code_boxes(handles) |
---|
4000 | %------------------------------------------------------------------------ |
---|
4001 | list_code=get(handles.ColorCode,'String');% list menu fields |
---|
4002 | colcode= list_code{get(handles.ColorCode,'Value')}; % selected field |
---|
4003 | enable_slider='off';%default |
---|
4004 | enable_bounds='off';%default |
---|
4005 | enable_scalar='off';%default |
---|
4006 | switch colcode |
---|
4007 | case {'rgb','bgr'} |
---|
4008 | enable_slider='on'; |
---|
4009 | enable_bounds='on'; |
---|
4010 | enable_scalar='on'; |
---|
4011 | case '64 colors' |
---|
4012 | enable_bounds='on'; |
---|
4013 | enable_scalar='on'; |
---|
4014 | end |
---|
4015 | set(handles.Slider1,'Visible',enable_slider) |
---|
4016 | set(handles.Slider2,'Visible', enable_slider) |
---|
4017 | set(handles.num_ColCode1,'Visible',enable_slider) |
---|
4018 | set(handles.num_ColCode2,'Visible',enable_slider) |
---|
4019 | set(handles.TitleColCode1,'Visible',enable_slider) |
---|
4020 | set(handles.TitleColCode2,'Visible',enable_slider) |
---|
4021 | set(handles.CheckFixVecColor,'Visible',enable_bounds) |
---|
4022 | set(handles.num_MinVec,'Visible',enable_bounds) |
---|
4023 | set(handles.num_MaxVec,'Visible',enable_bounds) |
---|
4024 | set(handles.ColorScalar,'Visible',enable_scalar) |
---|
4025 | set_vec_col_bar(handles) |
---|
4026 | |
---|
4027 | %------------------------------------------------------------------ |
---|
4028 | % --- Executes on selection change in ColorScalar: choice of the color code. |
---|
4029 | function ColorScalar_Callback(hObject, eventdata, handles) |
---|
4030 | %------------------------------------------------------------------ |
---|
4031 | % edit the choice for color code |
---|
4032 | list_scalar=get(handles.ColorScalar,'String');% list menu fields |
---|
4033 | col_scalar= list_scalar{get(handles.ColorScalar,'Value')}; % selected field |
---|
4034 | if isequal(col_scalar,'ima_cor') |
---|
4035 | set(handles.CheckFixVecColor,'Value',1)%fixed scale by default |
---|
4036 | ColorCode='rgb'; |
---|
4037 | set(handles.num_MinVec,'String','0') |
---|
4038 | set(handles.num_MaxVec,'String','1') |
---|
4039 | set(handles.num_ColCode1,'String','0.333') |
---|
4040 | set(handles.num_ColCode2,'String','0.666') |
---|
4041 | else |
---|
4042 | set(handles.CheckFixVecColor,'Value',0)%auto scale between min,max by default |
---|
4043 | ColorCode='64 colors'; |
---|
4044 | end |
---|
4045 | ColorCodeList=get(handles.ColorCode,'String'); |
---|
4046 | ichoice=find(strcmp(ColorCode,ColorCodeList),1); |
---|
4047 | set(handles.ColorCode,'Value',ichoice)% set color code in the menu |
---|
4048 | |
---|
4049 | update_color_code_boxes(handles); |
---|
4050 | %replot the current graph |
---|
4051 | REFRESH_Callback(hObject, eventdata, handles) |
---|
4052 | |
---|
4053 | %---------------------------------------------------------------- |
---|
4054 | % -- Executes on slider movement to set the color code |
---|
4055 | % |
---|
4056 | function Slider1_Callback(hObject, eventdata, handles) |
---|
4057 | %------------------------------------------------------------------ |
---|
4058 | slider1=get(handles.Slider1,'Value'); |
---|
4059 | min_val=str2num(get(handles.num_MinVec,'String')); |
---|
4060 | max_val=str2num(get(handles.num_MaxVec,'String')); |
---|
4061 | col=min_val+(max_val-min_val)*slider1; |
---|
4062 | set(handles.num_ColCode1,'String',num2str(col)) |
---|
4063 | if(get(handles.Slider2,'Value') < col)%move also the second slider at the same value if needed |
---|
4064 | set(handles.Slider2,'Value',col) |
---|
4065 | set(handles.num_ColCode2,'String',num2str(col)) |
---|
4066 | end |
---|
4067 | set_vec_col_bar(handles) |
---|
4068 | update_plot(handles); |
---|
4069 | |
---|
4070 | %---------------------------------------------------------------- |
---|
4071 | % Executes on slider movement to set the color code |
---|
4072 | %---------------------------------------------------------------- |
---|
4073 | function Slider2_Callback(hObject, eventdata, handles) |
---|
4074 | slider2=get(handles.Slider2,'Value'); |
---|
4075 | min_val=str2num(get(handles.num_MinVec,'String')); |
---|
4076 | max_val=str2num(get(handles.num_MaxVec,'String')); |
---|
4077 | col=min_val+(max_val-min_val)*slider2; |
---|
4078 | set(handles.num_ColCode2,'String',num2str(col)) |
---|
4079 | if(get(handles.Slider1,'Value') > col)%move also the first slider at the same value if needed |
---|
4080 | set(handles.Slider1,'Value',col) |
---|
4081 | set(handles.num_ColCode1,'String',num2str(col)) |
---|
4082 | end |
---|
4083 | set_vec_col_bar(handles) |
---|
4084 | update_plot(handles); |
---|
4085 | |
---|
4086 | %---------------------------------------------------------------- |
---|
4087 | % --- Execute on return carriage on the edit box corresponding to slider 1 |
---|
4088 | %---------------------------------------------------------------- |
---|
4089 | function num_ColCode1_Callback(hObject, eventdata, handles) |
---|
4090 | set_vec_col_bar(handles) |
---|
4091 | update_plot(handles); |
---|
4092 | |
---|
4093 | %---------------------------------------------------------------- |
---|
4094 | % --- Execute on return carriage on the edit box corresponding to slider 2 |
---|
4095 | %---------------------------------------------------------------- |
---|
4096 | function num_ColCode2_Callback(hObject, eventdata, handles) |
---|
4097 | set_vec_col_bar(handles) |
---|
4098 | update_plot(handles); |
---|
4099 | %------------------------------------------------------------------------ |
---|
4100 | %------------------------------------------------------- |
---|
4101 | % --- Executes on button press in CheckFixVecColor. |
---|
4102 | %------------------------------------------------------- |
---|
4103 | function VecColBar_Callback(hObject, eventdata, handles) |
---|
4104 | set_vec_col_bar(handles) |
---|
4105 | |
---|
4106 | %------------------------------------------------------------------------ |
---|
4107 | % --- Executes on button press in CheckFixVecColor. |
---|
4108 | function CheckFixVecColor_Callback(hObject, eventdata, handles) |
---|
4109 | %------------------------------------------------------------------------ |
---|
4110 | if ~get(handles.CheckFixVecColor,'Value') |
---|
4111 | update_plot(handles); |
---|
4112 | end |
---|
4113 | |
---|
4114 | %------------------------------------------------------------------------ |
---|
4115 | % --- Executes on selection change in num_MaxVec. |
---|
4116 | function num_MinVec_Callback(hObject, eventdata, handles) |
---|
4117 | %------------------------------------------------------------------------ |
---|
4118 | num_MaxVec_Callback(hObject, eventdata, handles) |
---|
4119 | |
---|
4120 | %------------------------------------------------------------------------ |
---|
4121 | % --- Executes on selection change in num_MaxVec. |
---|
4122 | function num_MaxVec_Callback(hObject, eventdata, handles) |
---|
4123 | %------------------------------------------------------------------------ |
---|
4124 | set(handles.CheckFixVecColor,'Value',1) |
---|
4125 | CheckFixVecColor_Callback(hObject, eventdata, handles) |
---|
4126 | min_val=str2num(get(handles.num_MinVec,'String')); |
---|
4127 | max_val=str2num(get(handles.num_MaxVec,'String')); |
---|
4128 | slider1=get(handles.Slider1,'Value'); |
---|
4129 | slider2=get(handles.Slider2,'Value'); |
---|
4130 | colcode1=min_val+(max_val-min_val)*slider1; |
---|
4131 | colcode2=min_val+(max_val-min_val)*slider2; |
---|
4132 | set(handles.num_ColCode1,'String',num2str(colcode1)) |
---|
4133 | set(handles.num_ColCode2,'String',num2str(colcode2)) |
---|
4134 | update_plot(handles); |
---|
4135 | |
---|
4136 | %------------------------------------------------------------------------ |
---|
4137 | % --- update the display of color code for vectors (on vecColBar) |
---|
4138 | function set_vec_col_bar(handles) |
---|
4139 | %------------------------------------------------------------------------ |
---|
4140 | %get the image of the color display button 'VecColBar' in pixels |
---|
4141 | set(handles.VecColBar,'Unit','pixel'); |
---|
4142 | pos_vert=get(handles.VecColBar,'Position'); |
---|
4143 | set(handles.VecColBar,'Unit','Normalized'); |
---|
4144 | width=ceil(pos_vert(3)); |
---|
4145 | height=ceil(pos_vert(4)); |
---|
4146 | |
---|
4147 | %get slider indications |
---|
4148 | list=get(handles.ColorCode,'String'); |
---|
4149 | ichoice=get(handles.ColorCode,'Value'); |
---|
4150 | colcode.ColorCode=list{ichoice}; |
---|
4151 | colcode.MinVec=str2num(get(handles.num_MinVec,'String')); |
---|
4152 | colcode.MaxVec=str2num(get(handles.num_MaxVec,'String')); |
---|
4153 | test3color=strcmp(colcode.ColorCode,'rgb') || strcmp(colcode.ColorCode,'bgr'); |
---|
4154 | if test3color |
---|
4155 | colcode.ColCode1=str2num(get(handles.num_ColCode1,'String')); |
---|
4156 | colcode.ColCode2=str2num(get(handles.num_ColCode2,'String')); |
---|
4157 | end |
---|
4158 | vec_C=colcode.MinVec+(colcode.MaxVec-colcode.MinVec)*(0.5:width-0.5)/width;%sample of vec_C values from min to max |
---|
4159 | [colorlist,col_vec]=set_col_vec(colcode,vec_C); |
---|
4160 | oneheight=ones(1,height); |
---|
4161 | A1=colorlist(col_vec,1)*oneheight; |
---|
4162 | A2=colorlist(col_vec,2)*oneheight; |
---|
4163 | A3=colorlist(col_vec,3)*oneheight; |
---|
4164 | A(:,:,1)=A1'; |
---|
4165 | A(:,:,2)=A2'; |
---|
4166 | A(:,:,3)=A3'; |
---|
4167 | set(handles.VecColBar,'Cdata',A) |
---|
4168 | |
---|
4169 | %------------------------------------------------------------------- |
---|
4170 | function update_plot(handles) |
---|
4171 | %------------------------------------------------------------------- |
---|
4172 | set(handles.REFRESH,'BackgroundColor',[1 1 0]);% display plot activity by yellow color |
---|
4173 | drawnow |
---|
4174 | UvData=get(handles.uvmat,'UserData'); |
---|
4175 | AxeData=UvData.PlotAxes;% retrieve the current plotted data |
---|
4176 | PlotParam=read_GUI(handles.uvmat); |
---|
4177 | [tild,PlotParamOut]= plot_field(AxeData,handles.PlotAxes,PlotParam); |
---|
4178 | errormsg=fill_GUI(PlotParamOut,handles.uvmat); |
---|
4179 | if ~isempty(errormsg) |
---|
4180 | msgbox_uvmat('ERROR',errormsg) |
---|
4181 | return |
---|
4182 | end |
---|
4183 | set(handles.REFRESH,'BackgroundColor',[1 0 0]); |
---|
4184 | |
---|
4185 | %------------------------------------------------------------------------ |
---|
4186 | %------------------------------------------------------------------------ |
---|
4187 | % SELECTION AND EDITION OF PROJECTION OBJECTS |
---|
4188 | %------------------------------------------------------------------------ |
---|
4189 | %------------------------------------------------------------------------ |
---|
4190 | |
---|
4191 | % --- Executes on selection change in ListObject_1. |
---|
4192 | function ListObject_1_Callback(hObject, eventdata, handles) |
---|
4193 | list_str=get(handles.ListObject,'String'); |
---|
4194 | UvData=get(handles.uvmat,'UserData'); |
---|
4195 | ObjectData=UvData.ProjObject{get(handles.ListObject_1,'Value')}; |
---|
4196 | |
---|
4197 | %% update the projection plot on uvmat |
---|
4198 | ProjData= proj_field(UvData.Field,ObjectData);%project the current input field on object ObjectData |
---|
4199 | plot_field(ProjData,handles.PlotAxes,read_GUI(handles.uvmat));% plot the projected field; |
---|
4200 | %replot all the objects within the new projected field |
---|
4201 | for IndexObj=1:numel(list_str) |
---|
4202 | hobject=UvData.ProjObject{IndexObj}.DisplayHandle.uvmat; |
---|
4203 | if isempty(hobject) || ~ishandle(hobject) |
---|
4204 | hobject=handles.PlotAxes; |
---|
4205 | end |
---|
4206 | if isequal(IndexObj,get(handles.ListObject,'Value')) |
---|
4207 | objectcolor='m'; %paint in magenta the currently selected object in ListObject |
---|
4208 | else |
---|
4209 | objectcolor='b'; |
---|
4210 | end |
---|
4211 | UvData.ProjObject{IndexObj}.DisplayHandle.uvmat=plot_object(UvData.ProjObject{IndexObj},ObjectData,hobject,objectcolor);%draw the object in uvmat |
---|
4212 | end |
---|
4213 | set(handles.uvmat,'UserData',UvData) |
---|
4214 | |
---|
4215 | %% display the object parameters if the GUI set_object is already opened |
---|
4216 | if ~get(handles.CheckViewObject,'Value') |
---|
4217 | ZBounds=0; % default |
---|
4218 | if isfield(UvData.Field,'ZMin') && isfield(UvData.Field,'ZMax') |
---|
4219 | ZBounds(1)=UvData.Field.ZMin; %minimum for the Z slider |
---|
4220 | ZBounds(2)=UvData.Field.ZMax;%maximum for the Z slider |
---|
4221 | end |
---|
4222 | ObjectData.Name=list_str{get(handles.ListObject_1,'Value')}; |
---|
4223 | set_object(ObjectData,[],ZBounds); |
---|
4224 | set(handles.CheckViewObject,'Value',1)% show that the selected object in ListObject_1 is currently visualised |
---|
4225 | end |
---|
4226 | |
---|
4227 | % desactivate the edit object mode |
---|
4228 | set(handles.CheckEditObject,'Value',0) |
---|
4229 | % set(handles.CheckEditObject,'BackgroundColor',[0.7,0.7,0.7]) |
---|
4230 | |
---|
4231 | %------------------------------------------------------------------------ |
---|
4232 | % --- Executes on selection change in ListObject. |
---|
4233 | function ListObject_Callback(hObject, eventdata, handles) |
---|
4234 | %------------------------------------------------------------------------ |
---|
4235 | list_str=get(handles.ListObject,'String'); |
---|
4236 | IndexObj=get(handles.ListObject,'Value');%present object selection |
---|
4237 | UvData=get(handles.uvmat,'UserData'); |
---|
4238 | ObjectData=UvData.ProjObject{IndexObj}; |
---|
4239 | ZBounds=0; % default |
---|
4240 | if isfield(UvData.Field,'ZMin') && isfield(UvData.Field,'ZMax') |
---|
4241 | ZBounds(1)=UvData.Field.ZMin; %minimum for the Z slider |
---|
4242 | ZBounds(2)=UvData.Field.ZMax;%maximum for the Z slider |
---|
4243 | end |
---|
4244 | |
---|
4245 | %% show object features if view_object isselected |
---|
4246 | if get(handles.CheckViewObject,'value') |
---|
4247 | set_object(ObjectData,[],ZBounds); |
---|
4248 | end |
---|
4249 | |
---|
4250 | %% The object is displayed in set_object if this GUI is already opened |
---|
4251 | % |
---|
4252 | % hset_object=findobj(allchild(0),'tag','set_object'); |
---|
4253 | % if ~isempty(hset_object) |
---|
4254 | % |
---|
4255 | % ObjectData.Name=list_str{IndexObj}; |
---|
4256 | % set_object(ObjectData,[],ZBounds); |
---|
4257 | % set(handles.CheckViewField,'Value',1)% show that the selected object in ListObject is currently visualised |
---|
4258 | % end |
---|
4259 | |
---|
4260 | %% desactivate the edit object mode for security |
---|
4261 | set(handles.CheckEditObject,'Value',0) |
---|
4262 | |
---|
4263 | % set(handles.CheckEditObject,'BackgroundColor',[0.7,0.7,0.7]) |
---|
4264 | |
---|
4265 | %% update the plot on view_field if view_field is already openened |
---|
4266 | hview_field=findobj(allchild(0),'tag','view_field'); |
---|
4267 | if isempty(hview_field) |
---|
4268 | hhview_field.PlotAxes=[]; |
---|
4269 | else |
---|
4270 | Data=get(hview_field,'UserData'); |
---|
4271 | hhview_field=guidata(hview_field); |
---|
4272 | ProjData= proj_field(UvData.Field,ObjectData);%project the current interface field on ObjectData |
---|
4273 | [PlotType,PlotParam]=plot_field(ProjData,hhview_field.PlotAxes,read_GUI(hview_field));%read plotting parameters on the uvmat interface |
---|
4274 | |
---|
4275 | %write_plot_param(hhview_field,PlotParam); %update the display of plotting parameters for the current object |
---|
4276 | haxes=findobj(hview_field,'tag','axes3'); |
---|
4277 | pos=get(hview_field,'Position'); |
---|
4278 | if strcmp(get(haxes,'Visible'),'off')%sempty(PlotParam.Coordinates)% case of no plot display (pure text table) |
---|
4279 | h_TableDisplay=findobj(hview_field,'tag','TableDisplay'); |
---|
4280 | pos_table=get(h_TableDisplay,'Position'); |
---|
4281 | set(hview_field,'Position',[pos(1)+pos(3)-pos_table(3) pos(2)+pos(4)-pos_table(4) pos_table(3) pos_table(4)]) |
---|
4282 | drawnow% needed to change position before the next command |
---|
4283 | set(hview_field,'UserData',Data);% restore the previously stored GUI position after GUI resizing |
---|
4284 | else |
---|
4285 | % set(hview_field,'Position',Data.GUISize)% return to the previously stored GUI position and size |
---|
4286 | end |
---|
4287 | end |
---|
4288 | |
---|
4289 | %% update the color of the graphic object representation: the selected object in magenta, others in blue |
---|
4290 | update_object_color(handles.PlotAxes,hhview_field.PlotAxes,UvData.ProjObject{IndexObj}.DisplayHandle.uvmat) |
---|
4291 | |
---|
4292 | %------------------------------------------------------------------------ |
---|
4293 | %--- update the color representation of objects (indicating the selected ones) |
---|
4294 | function update_object_color(axes_uvmat,axes_view_field,DisplayHandle) |
---|
4295 | %------------------------------------------------------------------------ |
---|
4296 | if isempty(axes_view_field)% case with no view_field plot |
---|
4297 | hother=[findobj(axes_uvmat,'Tag','proj_object');findobj(axes_uvmat,'Tag','DeformPoint')];%find all the proj object and deform point representations |
---|
4298 | else |
---|
4299 | hother=[findobj(axes_uvmat,'Tag','proj_object') ;findobj(axes_view_field,'Tag','proj_object');... %find all the proj object representations |
---|
4300 | findobj(axes_uvmat,'Tag','DeformPoint'); findobj(axes_view_field,'Tag','DeformPoint')];%find all the deform point representations |
---|
4301 | end |
---|
4302 | for iobj=1:length(hother) |
---|
4303 | if isequal(get(hother(iobj),'Type'),'rectangle')||isequal(get(hother(iobj),'Type'),'patch') |
---|
4304 | set(hother(iobj),'EdgeColor','b') |
---|
4305 | if isequal(get(hother(iobj),'FaceColor'),'m') |
---|
4306 | set(hother(iobj),'FaceColor','b') |
---|
4307 | end |
---|
4308 | elseif isequal(get(hother(iobj),'Type'),'image') |
---|
4309 | Acolor=get(hother(iobj),'CData'); |
---|
4310 | Acolor(:,:,1)=zeros(size(Acolor,1),size(Acolor,2)); |
---|
4311 | set(hother(iobj),'CData',Acolor); |
---|
4312 | else |
---|
4313 | set(hother(iobj),'Color','b') |
---|
4314 | end |
---|
4315 | set(hother(iobj),'Selected','off') |
---|
4316 | end |
---|
4317 | if ishandle(DisplayHandle) |
---|
4318 | linetype=get(DisplayHandle,'Type'); |
---|
4319 | if isequal(linetype,'line') |
---|
4320 | set(DisplayHandle,'Color','m'); %set the selected object to magenta color |
---|
4321 | elseif isequal(linetype,'rectangle') |
---|
4322 | set(DisplayHandle,'EdgeColor','m'); %set the selected object to magenta color |
---|
4323 | elseif isequal(linetype,'patch') |
---|
4324 | set(DisplayHandle,'FaceColor','m'); %set the selected object to magenta color |
---|
4325 | end |
---|
4326 | SubObjectData=get(DisplayHandle,'UserData'); |
---|
4327 | if isfield(SubObjectData,'SubObject') & ishandle(SubObjectData.SubObject) |
---|
4328 | for iobj=1:length(SubObjectData.SubObject) |
---|
4329 | hsub=SubObjectData.SubObject(iobj); |
---|
4330 | if isequal(get(hsub,'Type'),'rectangle') |
---|
4331 | set(hsub,'EdgeColor','m'); %set the selected object to magenta color |
---|
4332 | elseif isequal(get(hsub,'Type'),'image') |
---|
4333 | Acolor=get(hsub,'CData'); |
---|
4334 | Acolor(:,:,1)=Acolor(:,:,3); |
---|
4335 | set(hsub,'CData',Acolor); |
---|
4336 | else |
---|
4337 | set(hsub,'Color','m') |
---|
4338 | end |
---|
4339 | end |
---|
4340 | end |
---|
4341 | if isfield(SubObjectData,'DeformPoint') & ishandle(SubObjectData.DeformPoint) |
---|
4342 | set(SubObjectData.DeformPoint,'Color','m') |
---|
4343 | end |
---|
4344 | end |
---|
4345 | |
---|
4346 | %------------------------------------------------------------------- |
---|
4347 | % --- Executes on selection change in CheckEditObject. |
---|
4348 | function CheckEditObject_Callback(hObject, eventdata, handles) |
---|
4349 | %------------------------------------------------------------------- |
---|
4350 | hset_object=findobj(allchild(0),'Tag','set_object'); |
---|
4351 | if get(handles.CheckEditObject,'Value') |
---|
4352 | %suppress the other options |
---|
4353 | set(handles.MenuObject,'checked','off') |
---|
4354 | set(handles.CheckZoom,'Value',0) |
---|
4355 | CheckZoom_Callback(hObject, eventdata, handles) |
---|
4356 | hgeometry_calib=findobj(allchild(0),'tag','geometry_calib'); |
---|
4357 | if ishandle(hgeometry_calib) |
---|
4358 | hhgeometry_calib=guidata(hgeometry_calib); |
---|
4359 | set(hhgeometry_calib.CheckEnableMouse,'Value',0)% desactivate mouse action in geometry_calib |
---|
4360 | set(hhgeometry_calib.CheckEnableMouse,'BackgroundColor',[0.7 0.7 0.7]) |
---|
4361 | end |
---|
4362 | set(handles.CheckViewObject,'value',1) |
---|
4363 | CheckViewObject_Callback(hObject, eventdata, handles) |
---|
4364 | else % desactivate object edit mode |
---|
4365 | if ~isempty(hset_object)% open the |
---|
4366 | set(get(hset_object,'children'),'Enable','off') |
---|
4367 | hSAVE=findobj(hset_object,'Tag','SAVE'); |
---|
4368 | set(hSAVE,'Enable','on') |
---|
4369 | end |
---|
4370 | end |
---|
4371 | |
---|
4372 | |
---|
4373 | %------------------------------------------------------------------------ |
---|
4374 | % --- Executes on button press in CheckViewObject. |
---|
4375 | function CheckViewObject_Callback(hObject, eventdata, handles) |
---|
4376 | %------------------------------------------------------------------------ |
---|
4377 | check_view=get(handles.CheckViewObject,'Value'); |
---|
4378 | |
---|
4379 | if check_view %activate set_object |
---|
4380 | IndexObj=get(handles.ListObject,'Value'); |
---|
4381 | list_object=get(handles.ListObject,'String'); |
---|
4382 | UvData=get(handles.uvmat,'UserData');%read UvData properties stored on the uvmat interface |
---|
4383 | UvData.ProjObject{IndexObj}.Name=list_object{IndexObj}; |
---|
4384 | if numel(UvData.ProjObject)<IndexObj;% error in UvData |
---|
4385 | msgbox_uvmat('ERROR','invalid object list') |
---|
4386 | return |
---|
4387 | end |
---|
4388 | ZBounds=0; % default |
---|
4389 | if isfield(UvData.Field,'ZMin') && isfield(UvData.Field,'ZMax') |
---|
4390 | ZBounds(1)=UvData.Field.ZMin; %minimum for the Z slider |
---|
4391 | ZBounds(2)=UvData.Field.ZMax;%maximum for the Z slider |
---|
4392 | end |
---|
4393 | data=UvData.ProjObject{IndexObj}; |
---|
4394 | if ~isfield(data,'Type')% default plane |
---|
4395 | data.Type='plane'; |
---|
4396 | end |
---|
4397 | hset_object=set_object(data,[],ZBounds); |
---|
4398 | hhset_object=guidata(hset_object); |
---|
4399 | if get(handles.CheckEditObject,'Value')% edit mode |
---|
4400 | set(get(hset_object,'children'),'Enable','on') |
---|
4401 | else |
---|
4402 | set(get(hset_object,'children'),'Enable','off')% deactivate the GUI except SAVE |
---|
4403 | set(hhset_object.SAVE,'Enable','on') |
---|
4404 | end |
---|
4405 | else |
---|
4406 | hset_object=findobj(allchild(0),'tag','set_object'); |
---|
4407 | if ~isempty(hset_object) |
---|
4408 | delete(hset_object)% delete existing version of set_object |
---|
4409 | end |
---|
4410 | end |
---|
4411 | |
---|
4412 | |
---|
4413 | %------------------------------------------------------------------------ |
---|
4414 | % --- Executes on button press in CheckViewField. |
---|
4415 | function CheckViewField_Callback(hObject, eventdata, handles) |
---|
4416 | %------------------------------------------------------------------------ |
---|
4417 | check_view=get(handles.CheckViewField,'Value'); |
---|
4418 | |
---|
4419 | if check_view |
---|
4420 | IndexObj=get(handles.ListObject,'Value'); |
---|
4421 | UvData=get(handles.uvmat,'UserData');%read UvData properties stored on the uvmat interface |
---|
4422 | if numel(UvData.ProjObject)<IndexObj(end);% error in UvData |
---|
4423 | msgbox_uvmat('ERROR','invalid object list') |
---|
4424 | return |
---|
4425 | end |
---|
4426 | ZBounds=0; % default |
---|
4427 | if isfield(UvData.Field,'ZMin') && isfield(UvData.Field,'ZMax') |
---|
4428 | ZBounds(1)=UvData.Field.ZMin; %minimum for the Z slider |
---|
4429 | ZBounds(2)=UvData.Field.ZMax;%maximum for the Z slider |
---|
4430 | end |
---|
4431 | set(handles.ListObject,'Value',IndexObj);%restore ListObject selection after set_object deletion |
---|
4432 | if ~isfield(UvData.ProjObject{IndexObj(1)},'Type')% default plane |
---|
4433 | UvData.ProjObject{IndexObj(1)}.Type='plane'; |
---|
4434 | end |
---|
4435 | list_object=get(handles.ListObject,'String'); |
---|
4436 | UvData.ProjObject{IndexObj(end)}.Name=list_object{IndexObj(end)}; |
---|
4437 | |
---|
4438 | %% show the projection of the selected object on view_field |
---|
4439 | ProjData= proj_field(UvData.Field,UvData.ProjObject{IndexObj});%project the current field on ObjectData |
---|
4440 | hview_field=findobj(allchild(0),'tag','view_field'); |
---|
4441 | if isempty(hview_field) |
---|
4442 | hview_field=view_field; |
---|
4443 | end |
---|
4444 | hhview_field=guidata(hview_field); |
---|
4445 | [PlotType,PlotParam]=plot_field(ProjData,hhview_field.PlotAxes,read_GUI(hview_field));%read plotting parameters on the GUI view_field); |
---|
4446 | errormsg=fill_GUI(PlotParam,hview_field); |
---|
4447 | for list={'Scalar','Vectors'} |
---|
4448 | if ~isfield(PlotParam,list{1}) |
---|
4449 | set(hhview_field.(list{1}),'Visible','off') |
---|
4450 | end |
---|
4451 | end |
---|
4452 | %write_plot_param(hhview_field,PlotParam); %update the display of plotting parameters for the current object |
---|
4453 | haxes=findobj(hview_field,'tag','axes3'); |
---|
4454 | pos=get(hview_field,'Position'); |
---|
4455 | if strcmp(get(haxes,'Visible'),'off')%sempty(PlotParam.Coordinates)% case of no plot display (pure text table) |
---|
4456 | h_TableDisplay=findobj(hview_field,'tag','TableDisplay'); |
---|
4457 | pos_table=get(h_TableDisplay,'Position'); |
---|
4458 | set(hview_field,'Position',[pos(1)+pos(3)-pos_table(3) pos(2)+pos(4)-pos_table(4) pos_table(3) pos_table(4)]) |
---|
4459 | else |
---|
4460 | Data=get(hview_field,'UserData'); |
---|
4461 | % set(hview_field,'Position',Data.GUISize)% restore the size of view_field for plots |
---|
4462 | end |
---|
4463 | else |
---|
4464 | hview_field=findobj(allchild(0),'tag','view_field'); |
---|
4465 | if ~isempty(hview_field) |
---|
4466 | delete(hview_field)% delete existing version of set_object |
---|
4467 | end |
---|
4468 | end |
---|
4469 | |
---|
4470 | |
---|
4471 | %------------------------------------------------------------------------ |
---|
4472 | % --- Executes on button press in DeleteObject. |
---|
4473 | %------------------------------------------------------------------------ |
---|
4474 | function DeleteObject_Callback(hObject, eventdata, handles) |
---|
4475 | |
---|
4476 | IndexObj=get(handles.ListObject,'Value');%projection object selected for view_field |
---|
4477 | IndexObj_1=get(handles.ListObject_1,'Value');%projection object selected for uvmat plot |
---|
4478 | if IndexObj>1 && ~isequal(IndexObj,IndexObj_1) % do not delete the object used for the uvmat plot |
---|
4479 | delete_object(IndexObj) |
---|
4480 | end |
---|
4481 | |
---|
4482 | %'DeleteObject': delete a projection object, defined by its index in the Uvmat list or by its graphic handle |
---|
4483 | %------------------------------------------------------------------------ |
---|
4484 | % function DeleteObject(hObject) |
---|
4485 | % |
---|
4486 | % INPUT: |
---|
4487 | % hObject: object index (if integer) or handle of the graphic object. If |
---|
4488 | % hObject is a subobject, the parent object is detected and deleted. |
---|
4489 | |
---|
4490 | function delete_object(IndexObj) |
---|
4491 | |
---|
4492 | huvmat=findobj('tag','uvmat');%handles of the uvmat interface |
---|
4493 | UvData=get(huvmat,'UserData'); |
---|
4494 | hlist_object=findobj(huvmat,'Tag','ListObject');%handles of the object list in the uvmat interface |
---|
4495 | list_str=get(hlist_object,'String');%objet list |
---|
4496 | if ~isempty(UvData) && isfield(UvData, 'ProjObject') && length(UvData.ProjObject)>=IndexObj |
---|
4497 | if isfield(UvData.ProjObject{IndexObj},'DisplayHandle') && isfield(UvData.ProjObject{IndexObj}.DisplayHandle,'uvmat') |
---|
4498 | hdisplay=UvData.ProjObject{IndexObj}.DisplayHandle.uvmat;%handle of the object graphic representation in uvmat |
---|
4499 | for iview=1:length(hdisplay) |
---|
4500 | if ishandle(hdisplay(iview)) && ~isequal(hdisplay(iview),0) |
---|
4501 | ObjectData=get(hdisplay(iview),'UserData'); |
---|
4502 | if isfield(ObjectData,'SubObject') && ~isempty(ObjectData.SubObject) |
---|
4503 | delete(ObjectData.SubObject(ishandle(ObjectData.SubObject)));% delete the graphic 'sub-objects (e.g. projection bounds) |
---|
4504 | end |
---|
4505 | if isfield(ObjectData,'DeformPoint')&& ~isempty(ObjectData.DeformPoint) |
---|
4506 | delete(ObjectData.DeformPoint(ishandle(ObjectData.DeformPoint)));% delete the graphic deformation points |
---|
4507 | delete(hdisplay(iview))% delete the main graphic representation of the object |
---|
4508 | end |
---|
4509 | end |
---|
4510 | ishandle(hdisplay(iview)) |
---|
4511 | end |
---|
4512 | for iobj=IndexObj+1:length(UvData.ProjObject) |
---|
4513 | hdisplay=UvData.ProjObject{iobj}.DisplayHandle.uvmat; |
---|
4514 | for iview=1:length(hdisplay) |
---|
4515 | if ishandle(hdisplay(iview)) && ~isequal(hdisplay(iview),0) |
---|
4516 | PlotData=get(hdisplay(iview),'UserData'); |
---|
4517 | PlotData.IndexObj=iobj-1; |
---|
4518 | set(hdisplay(iview),'UserData',PlotData); |
---|
4519 | end |
---|
4520 | end |
---|
4521 | end |
---|
4522 | end |
---|
4523 | UvData.ProjObject(IndexObj)=[]; |
---|
4524 | if ~isempty(list_str) |
---|
4525 | list_str(IndexObj)=[]; |
---|
4526 | end |
---|
4527 | end |
---|
4528 | set(huvmat,'UserData',UvData); |
---|
4529 | set(hlist_object,'String',list_str) |
---|
4530 | set(hlist_object,'Value',length(list_str)) |
---|
4531 | hlist_object_1=findobj(huvmat,'Tag','ListObject_1');%handles of the first object list in the uvmat interface |
---|
4532 | old_index=get(hlist_object_1,'Value'); |
---|
4533 | set(hlist_object_1,'String',list_str) |
---|
4534 | if IndexObj<=old_index |
---|
4535 | set(hlist_object_1,'Value',old_index-1) |
---|
4536 | end |
---|
4537 | |
---|
4538 | %------------------------------------------------------------------------ |
---|
4539 | %------------------------------------------------------------------------ |
---|
4540 | % II - TOOLS FROM THE UPPER MENU BAR |
---|
4541 | %------------------------------------------------------------------------ |
---|
4542 | %------------------------------------------------------------------------ |
---|
4543 | |
---|
4544 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
---|
4545 | % Export Menu Callbacks |
---|
4546 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
---|
4547 | %------------------------------------------------------------------------ |
---|
4548 | % --- Executes on button press in Menu/Export/field in workspace. |
---|
4549 | function MenuExportField_Callback(hObject, eventdata, handles) |
---|
4550 | %------------------------------------------------------------------------ |
---|
4551 | global Data_uvmat |
---|
4552 | Data_uvmat=get(handles.uvmat,'UserData'); |
---|
4553 | evalin('base','global Data_uvmat')%make CurData global in the workspace |
---|
4554 | display('current field :') |
---|
4555 | evalin('base','Data_uvmat') %display CurData in the workspace |
---|
4556 | commandwindow; %brings the Matlab command window to the front |
---|
4557 | |
---|
4558 | %------------------------------------------------------------------------ |
---|
4559 | % --- Executes on button press in Menu/Export/extract figure. |
---|
4560 | function MenuExportFigure_Callback(hObject, eventdata, handles) |
---|
4561 | %------------------------------------------------------------------------ |
---|
4562 | hfig=figure; |
---|
4563 | copyobj(handles.PlotAxes,hfig); |
---|
4564 | h=findobj(handles.PlotAxes,'tag','ima'); %look for image in the plot |
---|
4565 | if ~isempty(h) |
---|
4566 | map=colormap(handles.PlotAxes); |
---|
4567 | colormap(map);%transmit the current colormap to the zoom fig |
---|
4568 | colorbar |
---|
4569 | end |
---|
4570 | |
---|
4571 | % -------------------------------------------------------------------- |
---|
4572 | function MenuExportAxis_Callback(hObject, eventdata, handles) |
---|
4573 | ListFig=findobj(allchild(0),'Type','figure'); |
---|
4574 | nb_option=0; |
---|
4575 | menu={}; |
---|
4576 | for ilist=1:numel(ListFig) |
---|
4577 | FigName=get(ListFig(ilist),'name'); |
---|
4578 | if isempty(FigName) |
---|
4579 | FigName=['figure ' num2str(ListFig(ilist))]; |
---|
4580 | end |
---|
4581 | if ~strcmp(FigName,'uvmat') |
---|
4582 | ListAxes=findobj(ListFig(ilist),'Type','axes'); |
---|
4583 | ListTags=get(ListAxes,'Tag'); |
---|
4584 | if ~isempty(ListTags) && ~isempty(find(~strcmp('Colorbar',ListTags), 1)) |
---|
4585 | ListAxes=ListAxes(~strcmp('Colorbar',ListTags)); |
---|
4586 | if numel(ListAxes)==1 |
---|
4587 | nb_option=nb_option+1; |
---|
4588 | menu{nb_option}=FigName ; |
---|
4589 | AxesHandle(nb_option)=ListAxes; |
---|
4590 | else |
---|
4591 | nb_axis=0; |
---|
4592 | for iaxes=1:numel(ListAxes) |
---|
4593 | nb_axis=nb_axis+1; |
---|
4594 | nb_option=nb_option+1; |
---|
4595 | menu{nb_option}=[FigName '_' num2str(nb_axis)]; |
---|
4596 | AxesHandle(nb_option)=ListAxes(nb_axis); |
---|
4597 | end |
---|
4598 | end |
---|
4599 | end |
---|
4600 | end |
---|
4601 | end |
---|
4602 | if isempty(menu) |
---|
4603 | answer=msgbox_uvmat('INPUT_Y-N','no existing plotting axes available, create new figure?'); |
---|
4604 | if strcmp(answer,'Yes') |
---|
4605 | hfig=figure; |
---|
4606 | copyobj(handles.PlotAxes,hfig); |
---|
4607 | else |
---|
4608 | return |
---|
4609 | end |
---|
4610 | map=colormap(handles.PlotAxes); |
---|
4611 | colormap(map);%transmit the current colormap to the zoom fig |
---|
4612 | colorbar |
---|
4613 | else |
---|
4614 | answer=msgbox_uvmat('INPUT_MENU','select a figure/axis on which the current uvmat plot will be exported',menu); |
---|
4615 | if isempty(answer) |
---|
4616 | return |
---|
4617 | else |
---|
4618 | axes(AxesHandle(answer)) |
---|
4619 | hold on |
---|
4620 | hchild=get(handles.PlotAxes,'children'); |
---|
4621 | copyobj(hchild,gca); |
---|
4622 | end |
---|
4623 | end |
---|
4624 | |
---|
4625 | |
---|
4626 | %------------------------------------------------------------------------ |
---|
4627 | % -------------------------------------------------------------------- |
---|
4628 | function MenuExportMovie_Callback(hObject, eventdata, handles) |
---|
4629 | % -------------------------------------------------------------------- |
---|
4630 | set(handles.MenuExportMovie,'BusyAction','queue')% activate the button |
---|
4631 | huvmat=get(handles.InputFileREFRESH,'parent'); |
---|
4632 | UvData=get(huvmat,'UserData'); |
---|
4633 | %[xx,xx,FileBase]=read_file_boxes(handles); |
---|
4634 | [RootPath,SubDir,RootFile,FileIndex,FileExt]=read_file_boxes(handles); |
---|
4635 | FileBase=fullfile(RootPath,RootFile); |
---|
4636 | %read the current input file name |
---|
4637 | 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)'}; |
---|
4638 | dlg_title = 'select properties of the output avi movie'; |
---|
4639 | num_lines= 1; |
---|
4640 | def = {[FileBase '_out.avi'];'10';'1';'[0.03 0.05 0.95 0.92]';'10'}; |
---|
4641 | answer = inputdlg(prompt,dlg_title,num_lines,def,'on'); |
---|
4642 | aviname=answer{1}; |
---|
4643 | fps=str2double(answer{2}); |
---|
4644 | % check for existing file with output name aviname |
---|
4645 | if exist(aviname,'file') |
---|
4646 | backup=aviname; |
---|
4647 | testexist=2; |
---|
4648 | while testexist==2 |
---|
4649 | backup=[backup '~']; |
---|
4650 | testexist=exist(backup,'file'); |
---|
4651 | end |
---|
4652 | [success,message]=copyfile(aviname,backup);%make backup of the existing file |
---|
4653 | if isequal(success,1) |
---|
4654 | delete(aviname)%delete existing file |
---|
4655 | else |
---|
4656 | msgbox_uvmat('ERROR',message) |
---|
4657 | return |
---|
4658 | end |
---|
4659 | end |
---|
4660 | %create avi open |
---|
4661 | aviobj=avifile(aviname,'Compression','None','fps',fps); |
---|
4662 | |
---|
4663 | %display first view for tests |
---|
4664 | newfig=figure; |
---|
4665 | newaxes=copyobj(handles.PlotAxes,newfig);%new plotting axes in the new figure |
---|
4666 | set(newaxes,'Tag','movieaxes') |
---|
4667 | nbpix=[512 384]*str2double(answer{3}); |
---|
4668 | set(gcf,'Position',[1 1 nbpix])% resolution XVGA |
---|
4669 | set(newaxes,'Position',eval(answer{4})); |
---|
4670 | map=colormap(handles.PlotAxes); |
---|
4671 | colormap(map);%transmit the current colormap to the zoom fig |
---|
4672 | msgbox_uvmat('INPUT_Y-N',{['adjust figure ' num2str(newfig) ' with its matlab edit menu '] ;... |
---|
4673 | ['then press OK to get the avi movie as a copy of figure ' num2str(newfig) ' display']}); |
---|
4674 | UvData.plotaxes=newaxes;% the axis in the new figure becomes the current main plotting axes |
---|
4675 | set(huvmat,'UserData',UvData); |
---|
4676 | increment=str2num(get(handles.num_IndexIncrement,'String')); %get the field increment d |
---|
4677 | set(handles.STOP,'Visible','on') |
---|
4678 | set(handles.speed,'Visible','on') |
---|
4679 | set(handles.speed_txt,'Visible','on') |
---|
4680 | set(handles.Movie,'BusyAction','queue') |
---|
4681 | |
---|
4682 | %imin=str2double(get(handles.i1,'String')); |
---|
4683 | imax=str2double(answer{5}); |
---|
4684 | % if isfield(UvData,'Time') |
---|
4685 | htitle=get(newaxes,'Title'); |
---|
4686 | xlim=get(newaxes,'XLim'); |
---|
4687 | ylim=get(newaxes,'YLim'); |
---|
4688 | set(htitle,'Position',[xlim(2)+0.07*(xlim(2)-xlim(1)) ylim(2)-0.05*(ylim(2)-ylim(1)) 0]) |
---|
4689 | time_str=get(handles.TimeValue,'String'); |
---|
4690 | set(htitle,'String',['t=' time_str]) |
---|
4691 | set(handles.speed,'Value',1) |
---|
4692 | for i=1:imax |
---|
4693 | if get(handles.speed,'Value')~=0 && isequal(get(handles.MenuExportMovie,'BusyAction'),'queue') % enable STOP command |
---|
4694 | runpm(hObject,eventdata,handles,increment)% run plus |
---|
4695 | drawnow |
---|
4696 | time_str=get(handles.TimeValue,'String'); |
---|
4697 | if ishandle(htitle) |
---|
4698 | set(htitle,'String',['t=' time_str]) |
---|
4699 | end |
---|
4700 | mov=getframe(newfig); |
---|
4701 | aviobj=addframe(aviobj,mov); |
---|
4702 | end |
---|
4703 | end |
---|
4704 | aviobj=close(aviobj); |
---|
4705 | UvData=rmfield(UvData,'plotaxes'); |
---|
4706 | set(huvmat,'UserData',UvData); |
---|
4707 | msgbox_uvmat('CONFIRMATION',{['movie ' aviname ' created '];['with ' num2str(imax) ' frames']}) |
---|
4708 | |
---|
4709 | |
---|
4710 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
---|
4711 | % Projection Objects Menu Callbacks |
---|
4712 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
---|
4713 | |
---|
4714 | % ----------------------------------------------------------------------- |
---|
4715 | function Menupoints_Callback(hObject, eventdata, handles) |
---|
4716 | %------------------------------------------------------------------------ |
---|
4717 | data.Type='points'; |
---|
4718 | data.ProjMode='projection';%default |
---|
4719 | data.ProjModeMenu={};% do not restrict ProjMode menus |
---|
4720 | create_object(data,handles) |
---|
4721 | |
---|
4722 | % ----------------------------------------------------------------------- |
---|
4723 | % --- Callback of the Menu command line |
---|
4724 | %------------------------------------------------------------------------ |
---|
4725 | function Menuline_Callback(hObject, eventdata, handles) |
---|
4726 | %------------------------------------------------------------------------ |
---|
4727 | data.Type='line'; |
---|
4728 | data.ProjMode='projection';%default |
---|
4729 | data.ProjModeMenu={};% do not restrict ProjMode menus |
---|
4730 | create_object(data,handles) |
---|
4731 | |
---|
4732 | % ----------------------------------------------------------------------- |
---|
4733 | % --- Callback of the Menu command line_x |
---|
4734 | %------------------------------------------------------------------------ |
---|
4735 | function Menuline_x_Callback(hObject, eventdata, handles) |
---|
4736 | |
---|
4737 | data.Type='line_x'; |
---|
4738 | data.ProjMode='projection';%default |
---|
4739 | data.ProjModeMenu={};% do not restrict ProjMode menus |
---|
4740 | create_object(data,handles) |
---|
4741 | |
---|
4742 | % ----------------------------------------------------------------------- |
---|
4743 | % --- Callback of the Menu command line_y |
---|
4744 | % ----------------------------------------------------------------------- |
---|
4745 | function Menuline_y_Callback(hObject, eventdata, handles) |
---|
4746 | |
---|
4747 | data.Type='line_y'; |
---|
4748 | data.ProjMode='projection';%default |
---|
4749 | data.ProjModeMenu={};% do not restrict ProjMode menus |
---|
4750 | create_object(data,handles) |
---|
4751 | |
---|
4752 | %------------------------------------------------------------------------ |
---|
4753 | function Menupolyline_Callback(hObject, eventdata, handles) |
---|
4754 | %------------------------------------------------------------------------ |
---|
4755 | data.Type='polyline'; |
---|
4756 | data.ProjMode='projection';%default |
---|
4757 | data.ProjModeMenu={};% do not restrict ProjMode menus |
---|
4758 | create_object(data,handles) |
---|
4759 | |
---|
4760 | %------------------------------------------------------------------------ |
---|
4761 | function Menupolygon_Callback(hObject, eventdata, handles) |
---|
4762 | %------------------------------------------------------------------------ |
---|
4763 | data.Type='polygon'; |
---|
4764 | data.ProjMode='inside';%default |
---|
4765 | data.ProjModeMenu={};% do not restrict ProjMode menus |
---|
4766 | create_object(data,handles) |
---|
4767 | |
---|
4768 | %------------------------------------------------------------------------ |
---|
4769 | function Menurectangle_Callback(hObject, eventdata, handles) |
---|
4770 | %------------------------------------------------------------------------ |
---|
4771 | data.Type='rectangle'; |
---|
4772 | data.ProjMode='inside';%default |
---|
4773 | data.ProjModeMenu={};% do not restrict ProjMode menus |
---|
4774 | create_object(data,handles) |
---|
4775 | |
---|
4776 | %------------------------------------------------------------------------ |
---|
4777 | function Menuellipse_Callback(hObject, eventdata, handles) |
---|
4778 | %------------------------------------------------------------------------ |
---|
4779 | data.Type='ellipse'; |
---|
4780 | data.ProjMode='inside';%default |
---|
4781 | data.ProjModeMenu={};% do not restrict ProjMode menus |
---|
4782 | create_object(data,handles) |
---|
4783 | |
---|
4784 | %------------------------------------------------------------------------ |
---|
4785 | function MenuMaskObject_Callback(hObject, eventdata, handles) |
---|
4786 | %------------------------------------------------------------------------ |
---|
4787 | data.Type='polygon'; |
---|
4788 | data.TypeMenu={'polygon'}; |
---|
4789 | data.ProjMode='mask_inside';%default |
---|
4790 | data.ProjModeMenu={'mask_inside';'mask_outside'}; |
---|
4791 | create_object(data,handles) |
---|
4792 | |
---|
4793 | %------------------------------------------------------------------------ |
---|
4794 | function Menuplane_Callback(hObject, eventdata, handles) |
---|
4795 | %------------------------------------------------------------------------ |
---|
4796 | data.Type='plane'; |
---|
4797 | data.ProjMode='projection';%default |
---|
4798 | data.ProjModeMenu={};% do not restrict ProjMode menus |
---|
4799 | create_object(data,handles) |
---|
4800 | |
---|
4801 | %------------------------------------------------------------------------ |
---|
4802 | function Menuvolume_Callback(hObject, eventdata, handles) |
---|
4803 | %------------------------------------------------------------------------ |
---|
4804 | data.Type='volume'; |
---|
4805 | data.ProjMode='interp_lin';%default |
---|
4806 | data.ProjModeMenu={}; |
---|
4807 | % set(handles.create,'Visible','on') |
---|
4808 | % set(handles.create,'Value',1) |
---|
4809 | % VOLUME_Callback(hObject,eventdata,handles)data.ProjModeMenu={}; |
---|
4810 | create_object(data,handles) |
---|
4811 | |
---|
4812 | %------------------------------------------------------------------------ |
---|
4813 | % --- generic function used for the creation of a projection object |
---|
4814 | function create_object(data,handles) |
---|
4815 | %------------------------------------------------------------------------ |
---|
4816 | %% desactivate concurrent tools |
---|
4817 | hgeometry_calib=findobj(allchild(0),'tag','geometry_calib');% search the GUI geometric calibration |
---|
4818 | if ishandle(hgeometry_calib) |
---|
4819 | hhgeometry_calib=guidata(hgeometry_calib); |
---|
4820 | set(hhgeometry_calib.CheckEnableMouse,'Value',0)% desactivate mouse action in geometry_calib |
---|
4821 | set(hhgeometry_calib.CheckEnableMouse,'BackgroundColor',[0.7 0.7 0.7]) |
---|
4822 | end |
---|
4823 | set(handles.CheckEditObject,'Value',0) %desactivate the object edit mode |
---|
4824 | CheckEditObject_Callback([],[],handles) |
---|
4825 | set(handles.CheckViewObject,'Value',0) % desactivate view_object (new object created) |
---|
4826 | set(handles.CheckZoomFig,'Value',0) %desactivate zoom sub fig |
---|
4827 | set(handles.CheckZoom,'Value',0) %desactivate the zoom action |
---|
4828 | set(handles.MenuObject,'checked','on')% indicate object creation for mouse pointer display |
---|
4829 | if ishandle(handles.UVMAT_title) |
---|
4830 | delete(handles.UVMAT_title) %delete the initial display of uvmat if no field has been entered yet |
---|
4831 | end |
---|
4832 | |
---|
4833 | %% initiate the new projection object |
---|
4834 | UvData=get(handles.uvmat,'UserData'); |
---|
4835 | data.Name=data.Type;% default name=type |
---|
4836 | data.Coord=[0 0]; %default |
---|
4837 | check_plot=0; |
---|
4838 | if isfield(UvData,'Field') |
---|
4839 | Field=UvData.Field; |
---|
4840 | if isfield(Field,'NbDim')&& isequal(Field.NbDim,3) |
---|
4841 | data.Coord=[0 0 0]; %default |
---|
4842 | end |
---|
4843 | if isfield(Field,'CoordUnit') |
---|
4844 | data.CoordUnit=Field.CoordUnit; |
---|
4845 | end |
---|
4846 | if isfield(UvData.Field,'CoordMesh')&&~isempty(UvData.Field.CoordMesh) |
---|
4847 | data.RangeX=[UvData.Field.XMin UvData.Field.XMax]; |
---|
4848 | switch data.Type |
---|
4849 | case {'line','polyline','points'} |
---|
4850 | data.RangeY=UvData.Field.CoordMesh; |
---|
4851 | case 'line_x' |
---|
4852 | check_plot=1; %plot the line directly when set_object is opened |
---|
4853 | data.Type='line'; |
---|
4854 | data.RangeX=UvData.Field.XMin ; |
---|
4855 | data.RangeY=UvData.Field.CoordMesh; |
---|
4856 | data.Coord=[UvData.Field.XMin (UvData.Field.YMin +UvData.Field.YMax)/2;... |
---|
4857 | UvData.Field.XMax (UvData.Field.YMin +UvData.Field.YMax)/2];% put line at the middle of the y axis |
---|
4858 | case 'line_y' |
---|
4859 | check_plot=1; %plot the line directly when set_object is opened |
---|
4860 | data.Type='line'; |
---|
4861 | data.RangeX=UvData.Field.YMin ; |
---|
4862 | data.RangeY=UvData.Field.CoordMesh; |
---|
4863 | data.Coord=[(UvData.Field.XMin+UvData.Field.XMax)/2 UvData.Field.YMin;... |
---|
4864 | (UvData.Field.XMin +UvData.Field.XMax)/2 UvData.Field.YMax];% put line at the middle of the y axis |
---|
4865 | case {'rectangle','ellipse'} |
---|
4866 | data.RangeY=[UvData.Field.YMin UvData.Field.YMax]; |
---|
4867 | data.RangeX=UvData.Field.CoordMesh; |
---|
4868 | data.RangeY=UvData.Field.CoordMesh; |
---|
4869 | otherwise |
---|
4870 | data.RangeY=[UvData.Field.YMin UvData.Field.YMax]; |
---|
4871 | end |
---|
4872 | data.DX=UvData.Field.CoordMesh; |
---|
4873 | data.DY=UvData.Field.CoordMesh; |
---|
4874 | end |
---|
4875 | end |
---|
4876 | |
---|
4877 | hset_object=set_object(data,handles);% call the GUI set_object |
---|
4878 | hchild=get(hset_object,'children'); |
---|
4879 | set(hchild,'enable','on') |
---|
4880 | set(handles.DeleteObject,'Visible','on')% make the object delete button visible |
---|
4881 | if check_plot |
---|
4882 | hhset_object=guidata(hset_object); |
---|
4883 | set_object('REFRESH_Callback',1,[],hhset_object);% call the GUI set_object |
---|
4884 | end |
---|
4885 | set(handles.CheckViewField,'Visible','on') |
---|
4886 | set(handles.DeleteObject,'Visible','on') |
---|
4887 | set(handles.ListObject_1,'Visible','on') |
---|
4888 | set(handles.ListObject_1_title,'Visible','on') |
---|
4889 | |
---|
4890 | %------------------------------------------------------------------------ |
---|
4891 | function MenuBrowseObject_Callback(hObject, eventdata, handles) |
---|
4892 | %------------------------------------------------------------------------ |
---|
4893 | %get the object file |
---|
4894 | fileinput=uigetfile_uvmat('pick an xml object file:',get(handles.RootPath,'String'),'.xml'); |
---|
4895 | if ~isempty(fileinput) |
---|
4896 | %read the file |
---|
4897 | [data,heading]=xml2struct(fileinput); |
---|
4898 | if ~strcmp(heading,'ProjObject') |
---|
4899 | msgbox_uvmat('WARNING','The xml file does not have the heading ProjObject for projection objects') |
---|
4900 | end |
---|
4901 | ListObject=get(handles.ListObject,'String'); |
---|
4902 | ListObject=[ListObject;{data.Name}]; |
---|
4903 | IndexObj=length(ListObject); |
---|
4904 | UvData=get(handles.uvmat,'UserData'); |
---|
4905 | UvData.ProjObject{IndexObj}=[]; %create a new empty object |
---|
4906 | UvData.ProjObject{IndexObj}.DisplayHandle.uvmat=[]; %no plot handle before plot_field operation |
---|
4907 | UvData.ProjObject{IndexObj}.DisplayHandle.view_field=[]; %no plot handle before plot_field operation |
---|
4908 | set(handles.uvmat,'UserData',UvData) |
---|
4909 | set(handles.CheckViewObject,'Value',1) |
---|
4910 | set(handles.CheckViewField,'Value',1) |
---|
4911 | hset_object=set_object(data);% call the set_object interface |
---|
4912 | hhset_object=guidata(hset_object); |
---|
4913 | set_object('REFRESH_Callback',hObject,eventdata,hhset_object);% plot projection |
---|
4914 | set(handles.CheckEditObject,'Value',0); %suppress the object edit mode |
---|
4915 | CheckEditObject_Callback([],[],handles) |
---|
4916 | set(handles.DeleteObject,'Visible','on') |
---|
4917 | end |
---|
4918 | |
---|
4919 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
---|
4920 | % MenuTools Callbacks |
---|
4921 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
---|
4922 | %------------------------------------------------------------------------ |
---|
4923 | function MenuCalib_Callback(hObject, eventdata, handles) |
---|
4924 | %------------------------------------------------------------------------ |
---|
4925 | |
---|
4926 | UvData=get(handles.uvmat,'UserData');%read UvData properties stored on the uvmat interface |
---|
4927 | |
---|
4928 | %suppress competing options |
---|
4929 | set(handles.CheckZoom,'Value',0) |
---|
4930 | set(handles.CheckZoom,'BackgroundColor',[0.7 0.7 0.7]) |
---|
4931 | set(handles.ListObject,'Value',1) |
---|
4932 | % initiate display of GUI geometry_calib |
---|
4933 | data=[]; %default |
---|
4934 | if isfield(UvData,'CoordType') |
---|
4935 | data.CoordType=UvData.CoordType; |
---|
4936 | end |
---|
4937 | [RootPath,SubDir,RootFile,FileIndex,FileExt]=read_file_boxes(handles); |
---|
4938 | FileName=[fullfile(RootPath,SubDir,RootFile) FileIndex FileExt]; |
---|
4939 | set(handles.view_xml,'BackgroundColor',[1 1 0])%indicate the reading of the current xml file by geometry_calib |
---|
4940 | geometry_calib(FileName);% call the geometry_calib interface |
---|
4941 | set(handles.view_xml,'BackgroundColor',[1 1 1])%indicate the end of reading of the current xml file by geometry_calib |
---|
4942 | set(handles.MenuCalib,'checked','on')% indicate that MenuCalib is activated, test used by mouse action |
---|
4943 | |
---|
4944 | |
---|
4945 | %----------------------------------------------------------------------- |
---|
4946 | function MenuLIFCalib_Callback(hObject, eventdata, handles) |
---|
4947 | %------------------------------------------------------------------------ |
---|
4948 | %% read UvData properties stored on the uvmat interface |
---|
4949 | UvData=get(handles.uvmat,'UserData'); |
---|
4950 | if isfield(UvData,'XmlData')&& isfield(UvData.XmlData{1},'GeometryCalib') |
---|
4951 | XmlData=UvData.XmlData{1}; |
---|
4952 | else |
---|
4953 | msgbox_uvmat('ERROR','geometric calibration needed: use Tools/geometric calibration in the menu bar'); |
---|
4954 | return |
---|
4955 | end |
---|
4956 | |
---|
4957 | %% read lines currently drawn |
---|
4958 | ListObj=UvData.ProjObject; |
---|
4959 | select=zeros(1,numel(ListObj)); |
---|
4960 | for iobj=1:numel(ListObj); |
---|
4961 | if isfield(ListObj{iobj},'Type') && strcmp(ListObj{iobj}.Type,'line') |
---|
4962 | select(iobj)=1; |
---|
4963 | end |
---|
4964 | end |
---|
4965 | val=find(select); |
---|
4966 | if numel(val)<2 |
---|
4967 | msgbox_uvmat('ERROR','light rays must be defined by at least two lines created by Projection object/line in the menu bar'); |
---|
4968 | return |
---|
4969 | else |
---|
4970 | set(handles.ListObject,'Value',val);% show the selected lines on the list |
---|
4971 | ObjectData=UvData.ProjObject(val); |
---|
4972 | for iobj=1:length(ObjectData) |
---|
4973 | xA(iobj)=ObjectData{iobj}.Coord(1,1); |
---|
4974 | yA(iobj)=ObjectData{iobj}.Coord(1,2); |
---|
4975 | xB(iobj)=ObjectData{iobj}.Coord(2,1); |
---|
4976 | yB(iobj)=ObjectData{iobj}.Coord(2,2); |
---|
4977 | end |
---|
4978 | end |
---|
4979 | |
---|
4980 | %% find the origin as intersection of the two first lines (see http://www.ahristov.com/tutorial/geometry-games/intersection-lines.html ) |
---|
4981 | x1=xA(1);x2=xB(1); |
---|
4982 | x3=xA(2);x4=xB(2); |
---|
4983 | y1=yA(1);y2=yB(1); |
---|
4984 | y3=yA(2);y4=yB(2); |
---|
4985 | D = (x1-x2)*(y3-y4) -(y1-y2)*(x3-x4); |
---|
4986 | if D==0 |
---|
4987 | msgbox_uvmat('ERROR','the two lines are parallel'); |
---|
4988 | return |
---|
4989 | end |
---|
4990 | x0=((x3-x4)*(x1*y2-y1*x2)-(x1-x2)*(x3*y4-y3*x4))/D; |
---|
4991 | y0=((y3-y4)*(x1*y2-y1*x2)-(y1-y2)*(x3*y4-y3*x4))/D; |
---|
4992 | XmlData.Illumination.Origin=[x0 y0]; |
---|
4993 | XmlData.PolarCentre=[x0 y0]; |
---|
4994 | |
---|
4995 | %% display the current image in polar coordinates with origin at the illumination source |
---|
4996 | currentdir=pwd; |
---|
4997 | uvmatpath=fileparts(which('uvmat')); |
---|
4998 | cd(fullfile(uvmatpath,'transform_field')); |
---|
4999 | phys_polar=str2func('phys_polar'); |
---|
5000 | cd(currentdir) |
---|
5001 | DataOut=phys_polar(UvData.Field,XmlData); |
---|
5002 | view_field(DataOut); |
---|
5003 | |
---|
5004 | %% use the third line for reference luminosity |
---|
5005 | if numel(val)==3 |
---|
5006 | x_ref=linspace(ObjectData{3}.Coord(1,1),ObjectData{3}.Coord(2,1),10); |
---|
5007 | y_ref=linspace(ObjectData{3}.Coord(1,2),ObjectData{3}.Coord(2,2),10); |
---|
5008 | x_ref=x_ref-x0; |
---|
5009 | y_ref=y_ref-y0; |
---|
5010 | [theta_ref,r_ref] = cart2pol(x_ref,y_ref);%theta_ref and r_ref are the polar coordinates of the points on the line |
---|
5011 | theta_ref=theta_ref*180/pi; |
---|
5012 | figure |
---|
5013 | plot(theta_ref,r_ref) |
---|
5014 | azimuth_ima=linspace(DataOut.AY(1),DataOut.AY(2),size(DataOut.A,1));%profile of x index on the transformed image |
---|
5015 | dist_source = interp1(theta_ref,r_ref,azimuth_ima); |
---|
5016 | dist_source_pixel=round(size(DataOut.A,2)*(dist_source-DataOut.AX(1))/(DataOut.AX(2)-DataOut.AX(1))); |
---|
5017 | line_nan= isnan(dist_source_pixel); |
---|
5018 | dist_source_pixel(line_nan)=1; |
---|
5019 | width=20; %number of pixels used for reference |
---|
5020 | DataOut.A=double(DataOut.A); |
---|
5021 | Anorm=zeros(size(DataOut.A)); |
---|
5022 | Aval=mean(mean(DataOut.A)); |
---|
5023 | for iline=1:size(DataOut.A,1) |
---|
5024 | lum(iline)=mean(DataOut.A(iline,dist_source_pixel(iline):dist_source_pixel(iline)+width)); |
---|
5025 | Anorm(iline,:)=uint16(Aval*DataOut.A(iline,:)/lum(iline)); |
---|
5026 | end |
---|
5027 | lum(line_nan)=NaN; |
---|
5028 | figure |
---|
5029 | plot(1:size(DataOut.A,1),lum) |
---|
5030 | end |
---|
5031 | ImaName=regexprep([get(handles.RootFile,'String') get(handles.FileIndex,'String')],'//',''); |
---|
5032 | NewImageName=fullfile(get(handles.RootPath,'String'),'polar',[ImaName get(handles.FileExt,'String')]); |
---|
5033 | imwrite(Anorm,NewImageName,'BitDepth',16) |
---|
5034 | |
---|
5035 | %% record the origin in the xml file |
---|
5036 | XmlFileName=find_imadoc(get(handles.RootPath,'String'),get(handles.SubDir,'String'),get(handles.RootFile,'String'),get(handles.FileExt,'String')); |
---|
5037 | answer=msgbox_uvmat('INPUT_Y-N','save the illumination origin in the current xml file?'); |
---|
5038 | if strcmp(answer,'Yes') |
---|
5039 | t=xmltree(XmlFileName); %read the file |
---|
5040 | title=get(t,1,'name'); |
---|
5041 | if ~strcmp(title,'ImaDoc') |
---|
5042 | msgbox_uvmat('ERROR','wrong xml file'); |
---|
5043 | return |
---|
5044 | end |
---|
5045 | % backup the output file if it already exist, and read it |
---|
5046 | backupfile=XmlFileName; |
---|
5047 | testexist=2; |
---|
5048 | while testexist==2 |
---|
5049 | backupfile=[backupfile '~']; |
---|
5050 | testexist=exist(backupfile,'file'); |
---|
5051 | end |
---|
5052 | [success,message]=copyfile(XmlFileName,backupfile);%make backup |
---|
5053 | if success~=1 |
---|
5054 | errormsg=['errror in xml file backup: ' message]; |
---|
5055 | return |
---|
5056 | end |
---|
5057 | uid_illumination=find(t,'ImaDoc/Illumination'); |
---|
5058 | if isempty(uid_illumination) %if GeometryCalib does not already exists, create it |
---|
5059 | [t,uid_illumination]=add(t,1,'element','Illumination'); |
---|
5060 | end |
---|
5061 | uid_origin=find(t,'ImaDoc/Illumination/Origin'); |
---|
5062 | if ~isempty(uid_origin) %if GeometryCalib does not already exists, create it |
---|
5063 | t=delete(t,uid_origin); |
---|
5064 | end |
---|
5065 | % save the illumination origin |
---|
5066 | t=struct2xml(XmlData.Illumination,t,uid_illumination); |
---|
5067 | save(t,XmlFileName); |
---|
5068 | end |
---|
5069 | |
---|
5070 | |
---|
5071 | |
---|
5072 | %------------------------------------------------------------------------ |
---|
5073 | function MenuMask_Callback(hObject, eventdata, handles) |
---|
5074 | %------------------------------------------------------------------------ |
---|
5075 | UvData=get(handles.uvmat,'UserData');%read UvData properties stored on the uvmat interface |
---|
5076 | ListObj=UvData.ProjObject; |
---|
5077 | select=zeros(1,numel(ListObj)); |
---|
5078 | for iobj=1:numel(ListObj); |
---|
5079 | if strcmp(ListObj{iobj}.ProjMode,'mask_inside')||strcmp(ListObj{iobj}.ProjMode,'mask_outside') |
---|
5080 | select(iobj)=1; |
---|
5081 | end |
---|
5082 | end |
---|
5083 | val=find(select); |
---|
5084 | if isempty(val) |
---|
5085 | msgbox_uvmat('ERROR','polygons must be first created by Projection object/mask polygon in the menu bar'); |
---|
5086 | return |
---|
5087 | else |
---|
5088 | set(handles.ListObject,'Value',val); |
---|
5089 | flag=1; |
---|
5090 | if ~isfield(UvData.Field,'A') |
---|
5091 | msgbox_uvmat('ERROR','an image needs to be opened to set the mask size'); |
---|
5092 | return |
---|
5093 | end |
---|
5094 | npx=size(UvData.Field.A,2); |
---|
5095 | npy=size(UvData.Field.A,1); |
---|
5096 | xi=0.5:npx-0.5; |
---|
5097 | yi=0.5:npy-0.5; |
---|
5098 | [Xi,Yi]=meshgrid(xi,yi); |
---|
5099 | for iobj=1:length(UvData.ProjObject) |
---|
5100 | ObjectData=UvData.ProjObject{iobj}; |
---|
5101 | if isfield(ObjectData,'ProjMode') &&(isequal(ObjectData.ProjMode,'mask_inside')||isequal(ObjectData.ProjMode,'mask_outside')); |
---|
5102 | flagobj=1; |
---|
5103 | testphys=0; %coordinates in pixels by default |
---|
5104 | if isfield(ObjectData,'CoordUnit') && ~isequal(ObjectData.CoordUnit,'pixel') |
---|
5105 | if isfield(UvData,'XmlData')&& isfield(UvData.XmlData{1},'GeometryCalib') |
---|
5106 | Calib=UvData.XmlData{1}.GeometryCalib; |
---|
5107 | testphys=1; |
---|
5108 | end |
---|
5109 | end |
---|
5110 | if isfield(ObjectData,'Coord')&& isfield(ObjectData,'Type') |
---|
5111 | if isequal(ObjectData.Type,'polygon') |
---|
5112 | X=ObjectData.Coord(:,1); |
---|
5113 | Y=ObjectData.Coord(:,2); |
---|
5114 | if testphys |
---|
5115 | pos=[X Y zeros(size(X))]; |
---|
5116 | if isfield(Calib,'SliceCoord') && length(Calib.SliceCoord)>=3 |
---|
5117 | if isfield(Calib,'SliceAngle')&&~isequal(Calib.SliceAngle,[0 0 0]) |
---|
5118 | om=norm(Calib.SliceAngle);%norm of rotation angle in radians |
---|
5119 | OmAxis=Calib.SliceAngle/om; %unit vector marking the rotation axis |
---|
5120 | cos_om=cos(pi*om/180); |
---|
5121 | sin_om=sin(pi*om/180); |
---|
5122 | pos=cos_om*pos+sin_om*cross(OmAxis,pos)+(1-cos_om)*(OmAxis*pos')*OmAxis; |
---|
5123 | end |
---|
5124 | pos(:,1)=pos(:,1)+Calib.SliceCoord(1); |
---|
5125 | pos(:,2)=pos(:,2)+Calib.SliceCoord(2); |
---|
5126 | pos(:,3)=pos(:,3)+Calib.SliceCoord(3); |
---|
5127 | end |
---|
5128 | [X,Y]=px_XYZ(Calib,pos(:,1),pos(:,2),pos(:,3)); |
---|
5129 | end |
---|
5130 | flagobj=~inpolygon(Xi,Yi,X',Y');%=0 inside the polygon, 1 outside |
---|
5131 | elseif isequal(ObjectData.Type,'ellipse') |
---|
5132 | if testphys |
---|
5133 | %[X,Y]=px_XYZ(Calib,X,Y,0);% TODO:create a polygon boundary and transform to phys |
---|
5134 | end |
---|
5135 | RangeX=max(ObjectData.RangeX); |
---|
5136 | RangeY=max(ObjectData.RangeY); |
---|
5137 | X2Max=RangeX*RangeX; |
---|
5138 | Y2Max=RangeY*RangeY; |
---|
5139 | distX=(Xi-ObjectData.Coord(1,1)); |
---|
5140 | distY=(Yi-ObjectData.Coord(1,2)); |
---|
5141 | flagobj=(distX.*distX/X2Max+distY.*distY/Y2Max)>1; |
---|
5142 | elseif isequal(ObjectData.Type,'rectangle') |
---|
5143 | if testphys |
---|
5144 | %[X,Y]=px_XYZ(Calib,X,Y,0);% TODO:create a polygon boundary and transform to phys |
---|
5145 | end |
---|
5146 | distX=abs(Xi-ObjectData.Coord(1,1)); |
---|
5147 | distY=abs(Yi-ObjectData.Coord(1,2)); |
---|
5148 | flagobj=distX>max(ObjectData.RangeX) | distY>max(ObjectData.RangeY); |
---|
5149 | end |
---|
5150 | if isequal(ObjectData.ProjMode,'mask_outside') |
---|
5151 | flagobj=~flagobj; |
---|
5152 | end |
---|
5153 | flag=flag & flagobj; |
---|
5154 | end |
---|
5155 | end |
---|
5156 | end |
---|
5157 | %mask name |
---|
5158 | RootPath=get(handles.RootPath,'String'); |
---|
5159 | SubDir=get(handles.SubDir,'String'); |
---|
5160 | RootFile=get(handles.RootFile,'String'); |
---|
5161 | if ~isempty(RootFile)&&(isequal(RootFile(1),'/')|| isequal(RootFile(1),'\')) |
---|
5162 | RootFile(1)=[]; |
---|
5163 | end |
---|
5164 | list=get(handles.masklevel,'String'); |
---|
5165 | masknumber=num2str(length(list)); |
---|
5166 | maskindex=get(handles.masklevel,'Value'); |
---|
5167 | mask_name=fullfile_uvmat(RootPath,[SubDir '.mask'],'mask','.png','_1',maskindex); |
---|
5168 | imflag=uint8(255*(0.392+0.608*flag));% =100 for flag=0 (vectors not computed when 20<imflag<200) |
---|
5169 | imflag=flipdim(imflag,1); |
---|
5170 | |
---|
5171 | %display the mask |
---|
5172 | hfigmask=figure; |
---|
5173 | set(hfigmask,'Name','mask image') |
---|
5174 | vec=linspace(0,1,256);%define a linear greyscale colormap |
---|
5175 | map=[vec' vec' vec']; |
---|
5176 | colormap(map) |
---|
5177 | image(imflag); |
---|
5178 | answer=msgbox_uvmat('INPUT_TXT','mask file name:', mask_name); |
---|
5179 | if ~strcmp(answer,'Cancel') |
---|
5180 | mask_dir=fileparts(answer); |
---|
5181 | if ~exist(mask_dir,'dir') |
---|
5182 | [xx,msg1]=mkdir(mask_dir); |
---|
5183 | if ~strcmp(msg1,'') |
---|
5184 | errormsg=['cannot create ' mask_dir ': ' msg1];%error message for directory creation |
---|
5185 | return |
---|
5186 | end |
---|
5187 | end |
---|
5188 | imwrite(imflag,answer,'BitDepth',8); |
---|
5189 | end |
---|
5190 | set(handles.ListObject,'Value',1) |
---|
5191 | end |
---|
5192 | |
---|
5193 | %------------------------------------------------------------------------ |
---|
5194 | %-- open the GUI set_grid.fig to create grid |
---|
5195 | function MenuGrid_Callback(hObject, eventdata, handles) |
---|
5196 | %------------------------------------------------------------------------ |
---|
5197 | %suppress the other options if grid is chosen |
---|
5198 | set(handles.edit_vect,'Value',0) |
---|
5199 | edit_vect_Callback(hObject, eventdata, handles) |
---|
5200 | set(handles.ListObject,'Value',1) |
---|
5201 | |
---|
5202 | %prepare display of the set_grid GUI |
---|
5203 | [RootPath,SubDir,RootFile,FileIndex,FileExt]=read_file_boxes(handles); |
---|
5204 | FileName=[fullfile(RootPath,SubDir,RootFile) FileIndex FileExt]; |
---|
5205 | UvData=get(handles.uvmat,'UserData'); |
---|
5206 | % CoordList=get(handles.TransformName,'String'); |
---|
5207 | % val=get(handles.TransformName,'Value'); |
---|
5208 | set_grid(FileName,UvData.Field);% call the set_object interface |
---|
5209 | |
---|
5210 | |
---|
5211 | %------------------------------------------------------------------------ |
---|
5212 | function MenuRuler_Callback(hObject, eventdata, handles) |
---|
5213 | %------------------------------------------------------------------------ |
---|
5214 | set(handles.CheckZoom,'Value',0) |
---|
5215 | CheckZoom_Callback(handles.uvmat, [], handles) |
---|
5216 | set(handles.MenuRuler,'checked','on') |
---|
5217 | UvData=get(handles.uvmat,'UserData'); |
---|
5218 | UvData.MouseAction='ruler'; |
---|
5219 | set(handles.uvmat,'UserData',UvData); |
---|
5220 | |
---|
5221 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
---|
5222 | % MenuRun Callbacks |
---|
5223 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
---|
5224 | |
---|
5225 | %------------------------------------------------------------------------ |
---|
5226 | % open the GUI 'series' |
---|
5227 | function MenuSeries_Callback(hObject, eventdata, handles) |
---|
5228 | %------------------------------------------------------------------------ |
---|
5229 | Param=read_param(handles); |
---|
5230 | series(Param); %run the series interface |
---|
5231 | |
---|
5232 | % -------------------------------------------------------------------- |
---|
5233 | function MenuPIV_Callback(hObject, eventdata, handles) |
---|
5234 | Param=read_param(handles); |
---|
5235 | % Param.ActionName='civ_series'; |
---|
5236 | hseries=series(Param); |
---|
5237 | hhseries=guidata(hseries); |
---|
5238 | ActionMenu=get(hhseries.ActionName,'String'); |
---|
5239 | index_action=find(strcmp('civ_series',ActionMenu)); |
---|
5240 | set(hhseries.ActionName,'Value',index_action); |
---|
5241 | series('ActionName_Callback',hObject,eventdata,hhseries); %file input with xml reading in uvmat, show the image in phys coordinates |
---|
5242 | |
---|
5243 | |
---|
5244 | %------------------------------------------------------------------------ |
---|
5245 | % -- open the GUI civ.fig for PIV |
---|
5246 | function MenuCIVx_Callback(hObject, eventdata, handles) |
---|
5247 | %------------------------------------------------------------------------ |
---|
5248 | [RootPath,SubDir,RootFile,FileIndex,FileExt]=read_file_boxes(handles); |
---|
5249 | FileName=[fullfile(RootPath,SubDir,RootFile) FileIndex FileExt]; |
---|
5250 | civ(FileName);% interface de civ(not in the uvmat file) |
---|
5251 | |
---|
5252 | function Param=read_param(handles) |
---|
5253 | |
---|
5254 | [RootPath,SubDir,RootFile,FileIndex,FileExt]=read_file_boxes(handles); |
---|
5255 | Param.FileName=[fullfile(RootPath,SubDir,RootFile) FileIndex FileExt];%first input file name |
---|
5256 | if isequal(get(handles.SubField,'Value'),1) |
---|
5257 | [RootPath_1,SubDir_1,RootFile_1,FileIndex_1,FileExt_1]=read_file_boxes_1(handles); |
---|
5258 | FileName_1=[fullfile(RootPath_1,SubDir_1,RootFile_1) FileIndex_1 FileExt_1]; |
---|
5259 | if ~isequal(FileName_1,Param.FileName) |
---|
5260 | Param.FileName_1=FileName_1;%second input file name if relevant |
---|
5261 | end |
---|
5262 | end |
---|
5263 | Param.NomType=get(handles.NomType,'String'); |
---|
5264 | Param.NomType_1=get(handles.NomType_1,'String'); |
---|
5265 | Param.CheckFixPair=get(handles.CheckFixPair,'Value'); |
---|
5266 | UvData=get(handles.uvmat,'UserData'); |
---|
5267 | if isfield(UvData,'XmlData')&& isfield(UvData.XmlData{1},'Time') |
---|
5268 | Param.Time=UvData.XmlData{1}.Time; |
---|
5269 | end |
---|
5270 | if isequal(get(handles.scan_i,'Value'),1) |
---|
5271 | Param.incr_i=str2num(get(handles.num_IndexIncrement,'String')); |
---|
5272 | elseif isequal(get(handles.scan_j,'Value'),1) |
---|
5273 | Param.incr_j=str2num(get(handles.num_IndexIncrement,'String')); |
---|
5274 | end |
---|
5275 | |
---|
5276 | %% transfer fields and coordinate names |
---|
5277 | Param.list_fields=get(handles.FieldName,'String');% list menu fields |
---|
5278 | FieldName=Param.list_fields{get(handles.FieldName,'Value')}; |
---|
5279 | ind_image=find(strcmp('image',Param.list_fields)); |
---|
5280 | if ~isempty(ind_image) && numel(Param.list_fields)>1 |
---|
5281 | Param.list_fields(ind_image)=[]; %suppress 'image' option |
---|
5282 | end |
---|
5283 | Param.index_fields=find(strcmp(FieldName,Param.list_fields));% selected string index |
---|
5284 | Param.list_fields_1=get(handles.FieldName_1,'String');% list menu fields |
---|
5285 | if ischar(Param.list_fields_1),Param.list_fields_1={Param.list_fields_1};end |
---|
5286 | FieldName_1=Param.list_fields_1{get(handles.FieldName_1,'Value')}; |
---|
5287 | ind_image=find(strcmp('image',Param.list_fields_1)); |
---|
5288 | if ~isempty(ind_image) && numel(Param.list_fields_1)>1 |
---|
5289 | Param.list_fields_1(ind_image)=[]; %suppress 'image' option |
---|
5290 | end |
---|
5291 | Param.index_fields_1=find(strcmp(FieldName_1,Param.list_fields_1));% selected string index |
---|
5292 | TransformList=get(handles.TransformName,'String'); |
---|
5293 | Param.TransformName=TransformList{get(handles.TransformName,'Value')}; |
---|
5294 | Param.Coord_x_str=get(handles.Coord_x,'String'); |
---|
5295 | Param.Coord_x_val=get(handles.Coord_x,'Value'); |
---|
5296 | Param.Coord_y_str=get(handles.Coord_y,'Data'); |
---|
5297 | |
---|
5298 | % -------------------------------------------------------------------- |
---|
5299 | function MenuHelp_Callback(hObject, eventdata, handles) |
---|
5300 | % -------------------------------------------------------------------- |
---|
5301 | web('http://servforge.legi.grenoble-inp.fr/projects/soft-uvmat/wiki/UvmatHelp') |
---|
5302 | |
---|
5303 | % path_to_uvmat=which ('uvmat');% check the path of uvmat |
---|
5304 | % pathelp=fileparts(path_to_uvmat); |
---|
5305 | % helpfile=fullfile(pathelp,'uvmat_doc','uvmat_doc.html'); |
---|
5306 | % 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') |
---|
5307 | % else |
---|
5308 | % addpath (fullfile(pathelp,'uvmat_doc')) |
---|
5309 | % web(helpfile); |
---|
5310 | % end |
---|
5311 | |
---|
5312 | % --- Executes on selection change in Coord_y. |
---|
5313 | function Coord_y_Callback(hObject, eventdata, handles) |
---|
5314 | |
---|
5315 | % --- Executes on selection change in Coord_x. |
---|
5316 | function Coord_x_Callback(hObject, eventdata, handles) |
---|
5317 | |
---|
5318 | |
---|
5319 | % --- Executes on button press in CheckColorBar. |
---|
5320 | function CheckColorBar_Callback(hObject, eventdata, handles) |
---|
5321 | |
---|
5322 | |
---|
5323 | |
---|
5324 | function TransformPath_Callback(hObject, eventdata, handles) |
---|
5325 | % hObject handle to TransformPath (see GCBO) |
---|
5326 | % eventdata reserved - to be defined in a future version of MATLAB |
---|
5327 | % handles structure with handles and user data (see GUIDATA) |
---|
5328 | |
---|
5329 | % Hints: get(hObject,'String') returns contents of TransformPath as text |
---|
5330 | % str2double(get(hObject,'String')) returns contents of TransformPath as a double |
---|
5331 | |
---|
5332 | |
---|
5333 | %TODO: use to modify fill_GUI |
---|
5334 | %'write_plot_param': update the plotting parameters on the uvmat or view_field interface after a plotting operation |
---|
5335 | function write_plot_param(handles,PlotParam) |
---|
5336 | %% coordinates |
---|
5337 | if isempty(PlotParam.Coordinates) |
---|
5338 | set(handles.Coordinates,'Visible','off') |
---|
5339 | set(handles.PlotAxes,'Visible','off') |
---|
5340 | set(handles.text_display,'Visible','off') |
---|
5341 | set(handles.TableDisplay,'Visible','on') |
---|
5342 | else |
---|
5343 | set(handles.Coordinates,'Visible','on') |
---|
5344 | set(handles.PlotAxes,'Visible','on') |
---|
5345 | set(handles.text_display,'Visible','on') |
---|
5346 | if isfield(handles,'TableDisplay') |
---|
5347 | set(handles.TableDisplay,'Visible','off') |
---|
5348 | end |
---|
5349 | Coordinates=PlotParam.Coordinates; |
---|
5350 | if isfield(Coordinates,'CheckFixAspectRatio') |
---|
5351 | if Coordinates.CheckFixAspectRatio |
---|
5352 | set(handles.CheckFixAspectRatio,'Value',1) |
---|
5353 | else |
---|
5354 | set(handles.CheckFixAspectRatio,'Value',0) |
---|
5355 | |
---|
5356 | end |
---|
5357 | end |
---|
5358 | if isfield(Coordinates,'AspectRatio') |
---|
5359 | set(handles.num_AspectRatio,'String',num2str(Coordinates.AspectRatio)) |
---|
5360 | end |
---|
5361 | if isfield(Coordinates,'MinX') |
---|
5362 | set(handles.num_MinX,'String',num2str(Coordinates.MinX,4)); |
---|
5363 | set(handles.num_MaxX,'String',num2str(Coordinates.MaxX,4)); |
---|
5364 | set(handles.num_MinY,'String',num2str(Coordinates.MinY,4)); |
---|
5365 | set(handles.num_MaxY,'String',num2str(Coordinates.MaxY,4)); |
---|
5366 | else |
---|
5367 | set(handles.num_MinX,'String',''); |
---|
5368 | set(handles.num_MaxX,'String',''); |
---|
5369 | set(handles.num_MinY,'String',''); |
---|
5370 | set(handles.num_MaxY,'String',''); |
---|
5371 | end |
---|
5372 | end |
---|
5373 | |
---|
5374 | %% scalar or image parameters |
---|
5375 | if isfield(PlotParam,'Scalar') |
---|
5376 | set(handles.Scalar,'Visible','on') |
---|
5377 | if isfield(PlotParam.Scalar,'MaxA') |
---|
5378 | set(handles.num_MaxA,'String',num2str(PlotParam.Scalar.MaxA,3)); |
---|
5379 | end |
---|
5380 | if isfield(PlotParam.Scalar,'MinA') |
---|
5381 | set(handles.num_MinA,'String',num2str(PlotParam.Scalar.MinA,3)); |
---|
5382 | end |
---|
5383 | if isfield(PlotParam.Scalar,'IncrA') |
---|
5384 | set(handles.num_IncrA,'String',num2str(PlotParam.Scalar.IncrA,3)) |
---|
5385 | end |
---|
5386 | set(handles.CheckBW,'Value',PlotParam.Scalar.CheckBW) |
---|
5387 | if isfield(PlotParam.Scalar,'Opacity')&&isfield(handles,'num_Opacity') |
---|
5388 | set(handles.num_Opacity,'String',num2str(PlotParam.Scalar.Opacity)) |
---|
5389 | end |
---|
5390 | else |
---|
5391 | set(handles.Scalar,'Visible','off') |
---|
5392 | end |
---|
5393 | |
---|
5394 | %% parameter for vector field |
---|
5395 | if isfield(PlotParam,'Vectors') |
---|
5396 | set(handles.Vectors,'Visible','on') |
---|
5397 | if isfield(PlotParam.Vectors,'VecScale') |
---|
5398 | set(handles.num_VecScale,'String',num2str(PlotParam.Vectors.VecScale,3)) |
---|
5399 | end |
---|
5400 | if isfield(PlotParam.Vectors,'MinC')&& isfield(PlotParam.Vectors,'MaxC') |
---|
5401 | MinC=PlotParam.Vectors.MinC; |
---|
5402 | MaxC=PlotParam.Vectors.MaxC; |
---|
5403 | set(handles.num_MinVec,'String', num2str(MinC,3)); |
---|
5404 | set(handles.num_MaxVec,'String',num2str(MaxC,3)); |
---|
5405 | list=get(handles.ColorCode,'String'); |
---|
5406 | ichoice=get(handles.ColorCode,'Value'); |
---|
5407 | color_option=list{ichoice}; |
---|
5408 | test3color=strcmp(color_option,'rgb')||strcmp(color_option,'bgr'); |
---|
5409 | if test3color% need to update color thresholds |
---|
5410 | set(handles.num_ColCode1,'Visible','on') |
---|
5411 | set(handles.num_ColCode2,'Visible','on') |
---|
5412 | set(handles.Slider1,'Visible','on') |
---|
5413 | set(handles.Slider2,'Visible','on') |
---|
5414 | set(handles.num_ColCode1,'String',num2str(PlotParam.Vectors.ColCode1,3)) |
---|
5415 | set(handles.num_ColCode2,'String',num2str(PlotParam.Vectors.ColCode2,3)) |
---|
5416 | set(handles.Slider1,'Value',(PlotParam.Vectors.ColCode1-MinC)/(MaxC-MinC)) |
---|
5417 | set(handles.Slider2,'Value',(PlotParam.Vectors.ColCode2-MinC)/(MaxC-MinC)) |
---|
5418 | else |
---|
5419 | set(handles.num_ColCode1,'Visible','off') |
---|
5420 | set(handles.num_ColCode2,'Visible','off') |
---|
5421 | set(handles.Slider1,'Visible','off') |
---|
5422 | set(handles.Slider2,'Visible','off') |
---|
5423 | end |
---|
5424 | end |
---|
5425 | else |
---|
5426 | set(handles.Vectors,'Visible','off') |
---|
5427 | if isfield(handles,'edit_vect') |
---|
5428 | set(handles.edit_vect,'Visible','off') |
---|
5429 | set(handles.record,'Visible','off') |
---|
5430 | end |
---|
5431 | end |
---|
5432 | |
---|
5433 | |
---|
5434 | % --- Executes on button press in CheckTable. |
---|
5435 | function CheckTable_Callback(hObject, eventdata, handles) |
---|
5436 | if get(handles.CheckTable,'Value') |
---|
5437 | set(handles.TableDisplay,'Visible','on') |
---|
5438 | else |
---|
5439 | set(handles.TableDisplay,'Visible','off') |
---|
5440 | end |
---|