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 2008-2014, LEGI / CNRS UJF G-INP, 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 axes are represented by UvData.Field.Coord_x and UvData.Field.Coord_y, 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 .Coord_x andf.Coord_y contains only two elements, represneting the |
---|
88 | % axes 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 axes 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 axes. |
---|
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 | % .Coordinates: 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.PosColorbar=[0.80 0.02 0.018 0.445]; |
---|
193 | AxeData.LimEditBox=1; %initialise AxeData |
---|
194 | set(handles.PlotAxes,'UserData',AxeData) |
---|
195 | |
---|
196 | %% set functions for the mouse and keyboard |
---|
197 | set(hObject,'WindowKeyPressFcn',{'keyboard_callback',handles})%set keyboard action function |
---|
198 | set(hObject,'WindowButtonMotionFcn',{'mouse_motion',handles})%set mouse action functio |
---|
199 | set(hObject,'WindowButtonDownFcn',{'mouse_down'})%set mouse click action function |
---|
200 | set(hObject,'WindowButtonUpFcn',{'mouse_up',handles}) |
---|
201 | set(hObject,'DeleteFcn',{@closefcn})% |
---|
202 | set(hObject,'ResizeFcn',{@ResizeFcn,handles})% |
---|
203 | |
---|
204 | %% initialisation |
---|
205 | set(handles.FieldName,'Value',1) |
---|
206 | set(handles.FieldName,'string',{''}) |
---|
207 | UvData.ProjObject={[]}; |
---|
208 | |
---|
209 | %% TRANSFORM menu: builtin fcts |
---|
210 | transform_menu={'';'sub_field';'phys';'phys_polar'}; |
---|
211 | UvData.OpenParam.NbBuiltin=numel(transform_menu); %number of functions |
---|
212 | transform_path=fullfile(path_uvmat,'transform_field'); |
---|
213 | path_list=cell(UvData.OpenParam.NbBuiltin,1); |
---|
214 | path_list{1}=''; |
---|
215 | for ilist=2:UvData.OpenParam.NbBuiltin |
---|
216 | path_list{ilist}=transform_path; % set transform_path to the path_list |
---|
217 | end |
---|
218 | |
---|
219 | %% load the list of previously browsed files in menus Open, Open_1 and TransformName |
---|
220 | dir_perso=prefdir; % path to the directory .matlab containing the personal data of the current user |
---|
221 | profil_perso=fullfile(dir_perso,'uvmat_perso.mat');% personal data file uvmat_perso.mat' in .matlab |
---|
222 | if exist(profil_perso,'file')% if the file exists |
---|
223 | h=load (profil_perso); % open the personal file |
---|
224 | if isfield(h,'MenuFile')% load the saved menu of previously opened files |
---|
225 | for ifile=1:min(length(h.MenuFile),5) |
---|
226 | set(handles.(['MenuFile_' num2str(ifile)]),'Label',h.MenuFile{ifile}); |
---|
227 | end |
---|
228 | end |
---|
229 | if isfield(h,'MenuCampaign')% load the saved menu of previously opened campaigns |
---|
230 | for ifile=1:min(length(h.MenuCampaign),5) |
---|
231 | set(handles.(['MenuCampaign_' num2str(ifile)]),'Label',h.MenuCampaign{ifile}); |
---|
232 | end |
---|
233 | end |
---|
234 | if isfield(h,'RootPath') |
---|
235 | set(handles.RootPath,'UserData',h.RootPath); %store the previous campaign in the UserData of RootPath |
---|
236 | end |
---|
237 | if isfield(h,'transform_fct') && iscell(h.transform_fct) % load the menu of transform fct set by user |
---|
238 | for ilist=1:length(h.transform_fct); |
---|
239 | if exist(h.transform_fct{ilist},'file') |
---|
240 | [path,file]=fileparts(h.transform_fct{ilist}); |
---|
241 | transform_menu=[transform_menu; {file}]; |
---|
242 | path_list=[path_list; {path}]; |
---|
243 | end |
---|
244 | end |
---|
245 | end |
---|
246 | end |
---|
247 | transform_menu=[transform_menu;{'more...'}];%append the option more.. to the menu |
---|
248 | set(handles.TransformName,'String',transform_menu)% display the menu of transform fcts |
---|
249 | set(handles.TransformName,'UserData',path_list)% store the corresponding list of path in UserData of uicontrol transform_fct |
---|
250 | set(handles.TransformPath,'String','') |
---|
251 | set(handles.TransformPath,'UserData',[]) |
---|
252 | |
---|
253 | %% case of an input argument for uvmat |
---|
254 | testinputfield=0; |
---|
255 | inputfile=[]; |
---|
256 | Field=[]; |
---|
257 | if exist('input','var') |
---|
258 | if ishandle(handles.UVMAT_title) |
---|
259 | delete(handles.UVMAT_title) |
---|
260 | end |
---|
261 | if isstruct(input) |
---|
262 | if isfield(input,'InputFile') |
---|
263 | inputfile=input.InputFile; |
---|
264 | end |
---|
265 | if isfield(input,'TimeIndex') |
---|
266 | set(handles.i1,num2str(input.TimeIndex)) |
---|
267 | end |
---|
268 | if isfield(input,'FieldsString') |
---|
269 | UvData.FieldsString=input.FieldsString; |
---|
270 | end |
---|
271 | elseif ischar(input)% file name introduced as input |
---|
272 | inputfile=input; |
---|
273 | elseif isnumeric(input)%simple matrix introduced as input |
---|
274 | sizinput=size(input); |
---|
275 | if sizinput(1)<=1 || sizinput(2)<=1 |
---|
276 | msgbox_uvmat('ERROR','bad input for uvmat: file name, structure or numerical matrix accepted') |
---|
277 | return |
---|
278 | end |
---|
279 | UvData.Field.ListVarName={'A','coord_y','coord_x'}; |
---|
280 | UvData.Field.VarDimName={{'coord_y','coord_x'},'cord_y','coord_x'}; |
---|
281 | UvData.Field.A=input; |
---|
282 | UvData.Field.coord_x=[0.5 size(input,2)-0.5]; |
---|
283 | UvData.Field.coord_y=[size(input,1)-0.5 0.5]; |
---|
284 | testinputfield=1; |
---|
285 | end |
---|
286 | else |
---|
287 | %% check the path and date of modification of all functions in uvmat |
---|
288 | path_to_uvmat=which ('uvmat');% check the path detected for source file uvmat |
---|
289 | [infomsg,date_str,svn_info]=check_files;%check the path of the functions called by uvmat.m |
---|
290 | date_str=['last modification: ' date_str]; |
---|
291 | if ishandle(handles.UVMAT_title) |
---|
292 | set(handles.UVMAT_title,'String',... |
---|
293 | [{'Copyright LEGI UMR 5519 /CNRS-UJF-Grenoble INP, 2010'};... |
---|
294 | {'GNU General Public License'};... |
---|
295 | {path_to_uvmat};... |
---|
296 | {date_str};... |
---|
297 | infomsg]); |
---|
298 | end |
---|
299 | end |
---|
300 | set(handles.uvmat,'UserData',UvData) |
---|
301 | if ~isempty(inputfile) |
---|
302 | %%%%% display the input field %%%%%%% |
---|
303 | display_file_name(handles,inputfile) |
---|
304 | %%%%%%% |
---|
305 | end |
---|
306 | |
---|
307 | set_vec_col_bar(handles) %update the display of color code for vectors |
---|
308 | |
---|
309 | %------------------------------------------------------------------------ |
---|
310 | % --- Outputs from this function are returned to the command menuline. |
---|
311 | function varargout = uvmat_OutputFcn(hObject, eventdata, handles) |
---|
312 | %------------------------------------------------------------------------ |
---|
313 | varargout{1} = handles.output;% the only output argument is the handle to the GUI figure |
---|
314 | |
---|
315 | %------------------------------------------------------------------------ |
---|
316 | % --- executed when closing uvmat: delete or desactivate the associated figures if exist |
---|
317 | function closefcn(gcbo,eventdata) |
---|
318 | %------------------------------------------------------------------------ |
---|
319 | % delete GUI 'view_field' if detected |
---|
320 | hh=findobj(allchild(0),'tag','view_field'); |
---|
321 | if ~isempty(hh) |
---|
322 | delete(hh) |
---|
323 | end |
---|
324 | % delete GUI 'geometry_calib' if detected |
---|
325 | hh=findobj(allchild(0),'tag','geometry_calib'); |
---|
326 | if ~isempty(hh) |
---|
327 | delete(hh) |
---|
328 | end |
---|
329 | % desable set_object editing action if detected |
---|
330 | hh=findobj(allchild(0),'name','set_object'); |
---|
331 | if ~isempty(hh) |
---|
332 | hhh=findobj(hh,'tag','PLOT'); |
---|
333 | set(hhh,'enable','off') |
---|
334 | end |
---|
335 | %delete the bowser if detected |
---|
336 | hh=findobj(allchild(0),'tag','browser'); |
---|
337 | if ~isempty(hh) |
---|
338 | delete(hh) |
---|
339 | end |
---|
340 | |
---|
341 | %------------------------------------------------------------------------ |
---|
342 | %--- activated when resizing the GUI view_field |
---|
343 | function ResizeFcn(gcbo,eventdata,handles) |
---|
344 | %------------------------------------------------------------------------ |
---|
345 | set(handles.uvmat,'Units','pixels') |
---|
346 | size_fig=get(handles.uvmat,'Position'); |
---|
347 | ColumnWidth=max(150,0.18*size_fig(3)); |
---|
348 | ColumnWidth=min(ColumnWidth,250); % width of the right side display column, between 150 and 250, depending on the fig width |
---|
349 | |
---|
350 | %% position of panel InputFile |
---|
351 | set(handles.InputFile,'Units','pixels') |
---|
352 | pos_InputFile=get(handles.InputFile,'Position');% [lower x lower y width height] for text_display |
---|
353 | pos_InputFile(1)=0; |
---|
354 | pos_InputFile(2)=size_fig(4)-pos_InputFile(4); % set frame InputFile to the top of the fig |
---|
355 | pos_InputFile(3)=size_fig(3); |
---|
356 | set(handles.InputFile,'Position',pos_InputFile);% [lower x lower y width height] for text_display |
---|
357 | |
---|
358 | %% reset position of text_display and TableDisplay |
---|
359 | set(handles.text_display,'Units','pixels') |
---|
360 | pos_1=get(handles.text_display,'Position');% [lower x lower y width height] for text_display |
---|
361 | pos_1(3)=1.2*ColumnWidth; |
---|
362 | pos_1(1)=size_fig(3)-pos_1(3); % set text display to the right of the fig |
---|
363 | pos_1(2)=size_fig(4)-pos_InputFile(4)-pos_1(4); % set text display to the top of the fig |
---|
364 | set(handles.text_display,'Position',pos_1) |
---|
365 | set(handles.TableDisplay,'Position',pos_1) |
---|
366 | % reset position of CheckTable |
---|
367 | set(handles.CheckTable,'Units','pixels') |
---|
368 | pos_CheckTable=get(handles.CheckTable,'Position');% [lower x lower y width height] for CheckHold |
---|
369 | pos_CheckTable(1)=pos_1(1)-pos_CheckTable(3); % set 'CheckHold' to the right of the fig |
---|
370 | pos_CheckTable(2)=pos_InputFile(2)-pos_CheckTable(4); % set 'CheckHold' to the lower edge of text display |
---|
371 | set(handles.CheckTable,'Position',pos_CheckTable) |
---|
372 | |
---|
373 | %% reset position of CheckHold |
---|
374 | % pos_CheckHold=get(handles.CheckHold,'Position');% [lower x lower y width height] for CheckHold |
---|
375 | % pos_CheckHold(1)=size_fig(3)-pos_CheckHold(3); % set 'CheckHold' to the right of the fig |
---|
376 | % pos_CheckHold(2)=pos_1(2)-pos_CheckHold(4); % set 'CheckHold' to the lower edge of text display |
---|
377 | % set(handles.CheckHold,'Position',pos_CheckHold) |
---|
378 | |
---|
379 | %% reset position of Coordinates panel |
---|
380 | set(handles.Coordinates,'Units','pixels') |
---|
381 | pos_2=get(handles.Coordinates,'Position');% [lower x lower y width height] for frame 'Coordinates' |
---|
382 | pos_2(3)=ColumnWidth; |
---|
383 | pos_2(1)=size_fig(3)-pos_2(3); % set 'Coordinates' to the right of the fig |
---|
384 | pos_2(2)=pos_1(2)-pos_2(4); % set 'Coordinates' to the lower edge of text display, allowing a margin for CheckHold |
---|
385 | set(handles.Coordinates,'Position',pos_2) |
---|
386 | |
---|
387 | %% reset position of Axes panel |
---|
388 | set(handles.Axes,'Units','pixels') |
---|
389 | pos_3=get(handles.Axes,'Position');% [lower x lower y width height] for frame 'Coordinates' |
---|
390 | pos_3(3)=ColumnWidth; |
---|
391 | pos_3(1)=size_fig(3)-pos_3(3); % set 'Coordinates' to the right of the fig |
---|
392 | pos_3(2)=pos_2(2)-pos_3(4); % set 'Coordinates' to the lower edge of text display, allowing a margin for CheckHold |
---|
393 | set(handles.Axes,'Position',pos_3) |
---|
394 | |
---|
395 | %% reset position of Scalar |
---|
396 | set(handles.Scalar,'Units','pixels') |
---|
397 | pos_4=get(handles.Scalar,'Position'); % [lower x lower y width height] for frame 'Scalar' |
---|
398 | pos_4(3)=ColumnWidth; |
---|
399 | pos_4(1)=size_fig(3)-pos_4(3); % set 'Scalar' to the right of the fig |
---|
400 | if strcmp(get(handles.Scalar,'Visible'),'on') |
---|
401 | pos_4(2)=pos_3(2)-pos_4(4); % set 'Scalar' to the lower edge of frame 'Coordinates' if visible |
---|
402 | else |
---|
403 | pos_4(2)=pos_3(2);% set 'Scalar' to the lower edge of frame 'text display' if unvisible |
---|
404 | end |
---|
405 | set(handles.Scalar,'Position',pos_4) |
---|
406 | |
---|
407 | %% reset position of Vectors |
---|
408 | set(handles.Vectors,'Units','pixels') |
---|
409 | pos_5=get(handles.Vectors,'Position'); |
---|
410 | pos_5(3)=ColumnWidth; |
---|
411 | pos_5(1)=size_fig(3)-pos_5(3); |
---|
412 | if strcmp(get(handles.Vectors,'visible'),'on') |
---|
413 | pos_5(2)=pos_4(2)-pos_5(4); |
---|
414 | else |
---|
415 | pos_5(2)=pos_4(2); |
---|
416 | end |
---|
417 | set(handles.Vectors,'Position',pos_5) |
---|
418 | |
---|
419 | %% reset position and scale of axis |
---|
420 | pos(1)=0.2*size_fig(3)+35; |
---|
421 | pos(2)=35; |
---|
422 | pos(3)=0.77*size_fig(3)-1.2*ColumnWidth; |
---|
423 | pos(4)=size_fig(4)-60; |
---|
424 | set(handles.PlotAxes,'Units','pixels') |
---|
425 | set(handles.PlotAxes,'Position',pos) |
---|
426 | set(handles.PlotAxes,'Units','normalized') |
---|
427 | |
---|
428 | |
---|
429 | |
---|
430 | %------------------------------------------------------------------------ |
---|
431 | %------------------------------------------------------------------------ |
---|
432 | % II - TOOLS FROM THE UPPER MENU BAR |
---|
433 | %------------------------------------------------------------------------ |
---|
434 | %------------------------------------------------------------------------ |
---|
435 | |
---|
436 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
---|
437 | % Open Menu Callbacks |
---|
438 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
---|
439 | |
---|
440 | %------------------------------------------------------------------------ |
---|
441 | % --- Executes on the menu Open/Browse... |
---|
442 | % search the files, recognize their type according to their name and fill the rootfile input windows |
---|
443 | function MenuBrowse_Callback(hObject, eventdata, handles) |
---|
444 | [RootPath,SubDir,RootFile,FileIndices,FileExt]=read_file_boxes(handles); |
---|
445 | oldfile=[fullfile(RootPath,SubDir,RootFile) FileIndices FileExt]; |
---|
446 | if isempty(oldfile) %loads the previously stored file name and set it as default in the file_input box |
---|
447 | oldfile=get(handles.RootPath,'UserData'); |
---|
448 | end |
---|
449 | fileinput=uigetfile_uvmat('pick an input file',oldfile); |
---|
450 | hh=dir(fileinput); |
---|
451 | if numel(hh)>1 |
---|
452 | msgbox_uvmat('ERROR','invalid input, probably a broken link'); |
---|
453 | else |
---|
454 | |
---|
455 | %% display the selected field and related information |
---|
456 | if ~isempty(fileinput) |
---|
457 | set(handles.SubField,'Value',0) |
---|
458 | desable_subfield(handles) |
---|
459 | display_file_name(handles,fileinput) |
---|
460 | end |
---|
461 | end |
---|
462 | |
---|
463 | % ----------------------------------------------------------------------- |
---|
464 | % --- Open again the file whose name has been recorded in MenuFile_1 |
---|
465 | function MenuFile_Callback(hObject, eventdata, handles) |
---|
466 | %------------------------------------------------------------------------ |
---|
467 | fileinput=get(hObject,'Label'); |
---|
468 | set(handles.SubField,'Value',0) |
---|
469 | desable_subfield(handles) |
---|
470 | errormsg=display_file_name( handles,fileinput); |
---|
471 | if ~isempty(errormsg) |
---|
472 | set(hObject,'Label','') |
---|
473 | MenuFile=[{get(handles.MenuFile_1,'Label')};{get(handles.MenuFile_2,'Label')};... |
---|
474 | {get(handles.MenuFile_3,'Label')};{get(handles.MenuFile_4,'Label')};{get(handles.MenuFile_5,'Label')}]; |
---|
475 | str_find=strcmp(get(hObject,'Label'),MenuFile); |
---|
476 | MenuFile(str_find)=[];% suppress the input file to the list |
---|
477 | for ifile=1:numel(MenuFile) |
---|
478 | set(handles.(['MenuFile_' num2str(ifile)]),'Label',MenuFile{ifile}); |
---|
479 | end |
---|
480 | end |
---|
481 | |
---|
482 | % ----------------------------------------------------------------------- |
---|
483 | % --- Executes on the menu Open/Browse campaign... |
---|
484 | % --- search the file inside a campaign, using the GUI browse_data |
---|
485 | % ----------------------------------------------------------------------- |
---|
486 | function MenuBrowseCampaign_Callback(hObject, eventdata, handles) |
---|
487 | set(handles.MenuOpenCampaign,'ForegroundColor',[1 1 0]) |
---|
488 | drawnow |
---|
489 | RootPath=get(handles.RootPath,'String'); |
---|
490 | if isempty(RootPath) |
---|
491 | RootPath=get(handles.RootPath,'UserData');%use Rootpath recored from the personal file at uvmat opening |
---|
492 | end |
---|
493 | CampaignPath=fileparts(fileparts(RootPath)); |
---|
494 | DirFull=uigetfile_uvmat('define this path as the Campaign folder:',CampaignPath,'uigetdir'); |
---|
495 | %DirFull = uigetdir(CampaignPath,'Select a Campaign dir, then press OK'); |
---|
496 | if isempty(DirFull) |
---|
497 | return |
---|
498 | end |
---|
499 | OutPut=browse_data(DirFull);% open the GUI browse_data to get select a campaign dir, experiment and device |
---|
500 | if ~isfield(OutPut,'Campaign') |
---|
501 | return |
---|
502 | end |
---|
503 | fileinput=uigetfile_uvmat('pick an input file',fullfile(OutPut.Campaign,OutPut.Experiment{1},OutPut.DataSeries{1})); |
---|
504 | hh=dir(fileinput); |
---|
505 | if numel(hh)>1 |
---|
506 | msgbox_uvmat('ERROR','invalid input, probably a broken link'); |
---|
507 | return |
---|
508 | end |
---|
509 | |
---|
510 | %% update the list of campaigns in the menubar |
---|
511 | MenuCampaign=[{get(handles.MenuCampaign_1,'Label')};{get(handles.MenuCampaign_2,'Label')};... |
---|
512 | {get(handles.MenuCampaign_3,'Label')};{get(handles.MenuCampaign_4,'Label')};{get(handles.MenuCampaign_5,'Label')}]; |
---|
513 | check_dir=isempty(find(strcmp(DirFull,MenuCampaign))); |
---|
514 | if check_dir %insert the new campaign in the list if it is not found |
---|
515 | MenuCampaign(end)=[]; %suppress the last item |
---|
516 | MenuCampaign=[{DirFull};MenuCampaign];%insert the new campaign |
---|
517 | for ilist=1:numel(MenuCampaign) |
---|
518 | set(handles.(['MenuCampaign_' num2str(ilist)]),'Label',MenuCampaign{ilist}) |
---|
519 | end |
---|
520 | % save the list for future opening: |
---|
521 | dir_perso=prefdir; |
---|
522 | profil_perso=fullfile(dir_perso,'uvmat_perso.mat'); |
---|
523 | if exist(profil_perso,'file') |
---|
524 | save (profil_perso,'MenuCampaign','RootPath','-append'); %store the file names for future opening of uvmat |
---|
525 | else |
---|
526 | save (profil_perso,'MenuCampaign','RootPath','-V6'); %store the file names for future opening of uvmat |
---|
527 | end |
---|
528 | end |
---|
529 | |
---|
530 | %% display the selected field and related information |
---|
531 | %display_file_name( handles,fullfile(DirName,FileName)) |
---|
532 | display_file_name( handles,fileinput) |
---|
533 | set(handles.MenuOpenCampaign,'ForegroundColor',[0 0 0]) |
---|
534 | |
---|
535 | % ----------------------------------------------------------------------- |
---|
536 | % --- Open again as second field the file whose name has been recorded in MenuFile_1 |
---|
537 | % ----------------------------------------------------------------------- |
---|
538 | function MenuCampaign_Callback(hObject, eventdata, handles) |
---|
539 | |
---|
540 | set(handles.MenuOpenCampaign,'ForegroundColor',[1 1 0]) |
---|
541 | OutPut=browse_data(get(hObject,'Label'));% open the GUI browse_data to get select a campaign dir, experiment and device |
---|
542 | if isfield(OutPut,'Campaign') |
---|
543 | fileinput=uigetfile_uvmat('pick an input file',fullfile(OutPut.Campaign,OutPut.Experiment{1},OutPut.DataSeries{1})); |
---|
544 | hh=dir(fileinput); |
---|
545 | if numel(hh)>1 |
---|
546 | msgbox_uvmat('ERROR','invalid input, probably a broken link'); |
---|
547 | else |
---|
548 | display_file_name(handles,fileinput) |
---|
549 | end |
---|
550 | end |
---|
551 | set(handles.MenuOpenCampaign,'ForegroundColor',[0 0 0]) |
---|
552 | |
---|
553 | |
---|
554 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
---|
555 | % Export Menu Callbacks |
---|
556 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
---|
557 | %------------------------------------------------------------------------ |
---|
558 | % --- Executes on button press in Menu/Export/field in workspace. |
---|
559 | function MenuExportField_Callback(hObject, eventdata, handles) |
---|
560 | %------------------------------------------------------------------------ |
---|
561 | global Data_uvmat |
---|
562 | Data_uvmat=get(handles.uvmat,'UserData'); |
---|
563 | evalin('base','global Data_uvmat')%make CurData global in the workspace |
---|
564 | disp('Data_uvmat.Field=') |
---|
565 | evalin('base','Data_uvmat.Field') %display CurData in the workspace |
---|
566 | commandwindow; %brings the Matlab command window to the front |
---|
567 | |
---|
568 | %------------------------------------------------------------------------ |
---|
569 | % --- Executes on button press in Menu/Export/extract figure. |
---|
570 | function MenuExportFigure_Callback(hObject, eventdata, handles) |
---|
571 | %------------------------------------------------------------------------ |
---|
572 | hfig=figure; |
---|
573 | hc=copyobj(handles.PlotAxes,hfig); |
---|
574 | set(hc,'Position',[0.1 0.1 0.8 0.8]) |
---|
575 | h=findobj(handles.PlotAxes,'tag','ima'); %look for image in the plot |
---|
576 | if ~isempty(h) |
---|
577 | map=colormap(handles.PlotAxes); |
---|
578 | colormap(map);%transmit the current colormap to the new fig |
---|
579 | colorbar |
---|
580 | end |
---|
581 | |
---|
582 | % -------------------------------------------------------------------- |
---|
583 | function MenuExportAxis_Callback(hObject, eventdata, handles) |
---|
584 | % -------------------------------------------------------------------- |
---|
585 | ListFig=findobj(allchild(0),'Type','figure'); |
---|
586 | nb_option=0; |
---|
587 | menu={}; |
---|
588 | for ilist=1:numel(ListFig) |
---|
589 | FigName=get(ListFig(ilist),'name'); |
---|
590 | if isempty(FigName) |
---|
591 | FigName=['figure ' num2str(ListFig(ilist))]; |
---|
592 | end |
---|
593 | if ~strcmp(FigName,'uvmat') |
---|
594 | ListAxes=findobj(ListFig(ilist),'Type','axes'); |
---|
595 | ListTags=get(ListAxes,'Tag'); |
---|
596 | if ~isempty(ListTags) && ~isempty(find(~strcmp('Colorbar',ListTags), 1)) |
---|
597 | ListAxes=ListAxes(~strcmp('Colorbar',ListTags)); |
---|
598 | if numel(ListAxes)==1 |
---|
599 | nb_option=nb_option+1; |
---|
600 | menu{nb_option}=FigName ; |
---|
601 | AxesHandle(nb_option)=ListAxes; |
---|
602 | else |
---|
603 | nb_axis=0; |
---|
604 | for iaxes=1:numel(ListAxes) |
---|
605 | nb_axis=nb_axis+1; |
---|
606 | nb_option=nb_option+1; |
---|
607 | menu{nb_option}=[FigName '_' num2str(nb_axis)]; |
---|
608 | AxesHandle(nb_option)=ListAxes(nb_axis); |
---|
609 | end |
---|
610 | end |
---|
611 | end |
---|
612 | end |
---|
613 | end |
---|
614 | if isempty(menu) |
---|
615 | answer=msgbox_uvmat('INPUT_Y-N','no existing plotting axes available, create new figure?'); |
---|
616 | if strcmp(answer,'Yes') |
---|
617 | hfig=figure; |
---|
618 | copyobj(handles.PlotAxes,hfig); |
---|
619 | else |
---|
620 | return |
---|
621 | end |
---|
622 | map=colormap(handles.PlotAxes); |
---|
623 | colormap(map);%transmit the current colormap to the zoom fig |
---|
624 | colorbar |
---|
625 | else |
---|
626 | answer=msgbox_uvmat('INPUT_MENU','select a figure/axis on which the current uvmat plot will be exported',menu); |
---|
627 | if isempty(answer) |
---|
628 | return |
---|
629 | else |
---|
630 | axes(AxesHandle(answer)) |
---|
631 | hold on |
---|
632 | hchild=get(handles.PlotAxes,'children'); |
---|
633 | copyobj(hchild,gca); |
---|
634 | end |
---|
635 | end |
---|
636 | |
---|
637 | |
---|
638 | %------------------------------------------------------------------------ |
---|
639 | % -------------------------------------------------------------------- |
---|
640 | function MenuExportMovie_Callback(hObject, eventdata, handles) |
---|
641 | % -------------------------------------------------------------------- |
---|
642 | set(handles.MenuExportMovie,'BusyAction','queue')% activate the button |
---|
643 | |
---|
644 | [RootPath,SubDir,RootFile,FileIndex,FileExt]=read_file_boxes(handles); |
---|
645 | FileBase=fullfile(RootPath,RootFile); |
---|
646 | |
---|
647 | %% create a fig and axis for movies |
---|
648 | figure_movie=findobj(allchild(0),'name','figure_movie'); |
---|
649 | |
---|
650 | if ~isempty(figure_movie) |
---|
651 | delete(figure_movie)%delete existing figure_movie |
---|
652 | end |
---|
653 | figure_movie=figure; |
---|
654 | nbpix=[512 384];% resolution XVGA |
---|
655 | set(figure_movie,'name','figure_movie','Position',[1 1 nbpix]) |
---|
656 | newaxes=copyobj(handles.PlotAxes,figure_movie);%new plotting axes in the new figure |
---|
657 | set(newaxes,'Tag','movieaxes') |
---|
658 | |
---|
659 | %% display time if defined in uvmat |
---|
660 | time_str=get(handles.TimeValue,'String'); |
---|
661 | if ~isempty(time_str) |
---|
662 | htitle=get(newaxes,'Title'); |
---|
663 | % xlim=get(newaxes,'XLim'); |
---|
664 | % ylim=get(newaxes,'YLim'); |
---|
665 | % set(htitle,'Position',[xlim(2)+0.07*(xlim(2)-xlim(1)) ylim(2)-0.05*(ylim(2)-ylim(1)) 0]) |
---|
666 | |
---|
667 | set(htitle,'String',['t=' time_str]) |
---|
668 | end |
---|
669 | map=colormap(handles.PlotAxes); |
---|
670 | colormap(map);%transmit the current colormap to the zoom fig |
---|
671 | colorbar |
---|
672 | |
---|
673 | %% create the GUI set_movie |
---|
674 | %set(0,'Units','points') |
---|
675 | %ScreenSize=get(0,'ScreenSize');% get the size of the screen, to put the fig on the upper right |
---|
676 | Position=get(figure_movie,'Position'); |
---|
677 | Position(2)=Position(2)+1.2*Position(4); |
---|
678 | Position(3)=1.5*Position(3); |
---|
679 | Position(4)=Position(4)/2; |
---|
680 | hfig=findobj(allchild(0),'Tag','set_movie'); |
---|
681 | if ~isempty(hfig),delete(hfig), end; %delete existing version of the GUI |
---|
682 | hfig=figure('name','set_movie','tag','set_movie','MenuBar','none','NumberTitle','off','Units','pixels',... |
---|
683 | 'Position',Position); |
---|
684 | BackgroundColor=get(hfig,'Color'); |
---|
685 | hh=0.14; % box height (relative) |
---|
686 | % first raw of the GUI |
---|
687 | uicontrol('Style','text','Units','normalized', 'Position', [0.05 0.95-hh/2 0.9 hh/2],'BackgroundColor',BackgroundColor,... |
---|
688 | 'String','movie name:','FontUnits','points','FontSize',12,'FontWeight','bold','ForegroundColor','blue','HorizontalAlignment','center');%title |
---|
689 | uicontrol('Style','edit','Units','normalized', 'Position', [0.05 0.95-1.5*hh 0.9 hh],'tag','MovieName','BackgroundColor',[1 1 1],... |
---|
690 | 'String',fullfile(RootPath,[SubDir '.movie'], [RootFile '.avi']),'FontUnits','points','FontSize',12,'FontWeight','bold','TooltipString','''MovieName'': name (with path) of the movie to create');%edit box |
---|
691 | uicontrol('Style','text','Units','normalized', 'Position', [0.05 0.95-2.5*hh 0.45 hh/2],'BackgroundColor',BackgroundColor,... |
---|
692 | 'String','frames per second:','FontUnits','points','FontSize',12,'FontWeight','bold','ForegroundColor','blue','HorizontalAlignment','center');%title |
---|
693 | uicontrol('Style','text','Units','normalized', 'Position', [0.55 0.95-2.5*hh 0.45 hh/2],'BackgroundColor',BackgroundColor,... |
---|
694 | 'String','total nbre of frames:','FontUnits','points','FontSize',12,'FontWeight','bold','ForegroundColor','blue','HorizontalAlignment','center');%title |
---|
695 | uicontrol('Style','edit','Units','normalized', 'Position', [0.05 0.95-3.5*hh 0.3 hh],'tag','num_FramePerSecond','BackgroundColor',[1 1 1],... |
---|
696 | 'String','10','FontUnits','points','FontSize',12,'FontWeight','bold','TooltipString','''num_FramePerSecond'': nbre of frames per second');%edit box |
---|
697 | uicontrol('Style','edit','Units','normalized', 'Position', [0.65 0.95-3.5*hh 0.3 hh],'tag','num_FrameNumber','BackgroundColor',[1 1 1],... |
---|
698 | 'String','10','FontUnits','points','FontSize',12,'FontWeight','bold','TooltipString','''num_FrameNumber'': total nbre of frames');%edit box |
---|
699 | uicontrol('Style','pushbutton','Units','normalized', 'Position', [0.05 0.15 0.25 hh],'BackgroundColor',[1 0 0],'String','START','Callback',@(hObject,eventdata)set_movie_START_Callback(hObject,eventdata),... |
---|
700 | 'FontWeight','bold','FontUnits','points','FontSize',12,'TooltipString','''APPLY'': apply the output to the current field series in uvmat'); |
---|
701 | uicontrol('Style','pushbutton','Units','normalized', 'Position', [0.7 0.15 0.25 hh],'Callback',@(hObject,eventdata)set_movie_Cancel_Callback(hObject,eventdata),... |
---|
702 | 'String','Cancel','FontWeight','bold','FontUnits','points','FontSize',12,'TooltipString','''Cancel'': quit GUI without action'); |
---|
703 | uicontrol('Style','text','Units','normalized', 'Position', [0.05 0.05 0.9 hh/2],'BackgroundColor',BackgroundColor,... |
---|
704 | 'String','will extract the result of ++> on uvmat: adjust figure_movie with its Matlab edit menu, then press ''START ''','FontUnits','points','FontSize',12,'FontWeight','bold','ForegroundColor','blue','HorizontalAlignment','center');%title |
---|
705 | drawnow |
---|
706 | |
---|
707 | %------------------------------------------------------------------------ |
---|
708 | % function called by pressing APPLY in the GUI set_slices |
---|
709 | function set_movie_START_Callback(hObject,eventdata) |
---|
710 | %------------------------------------------------------------------------ |
---|
711 | %% read info from the GUI set_movie |
---|
712 | hset_movie=get(hObject,'parent'); |
---|
713 | hMovieName=findobj(hset_movie,'Tag','MovieName'); |
---|
714 | MovieName=get(hMovieName,'String'); |
---|
715 | hFramePerSecond=findobj(hset_movie,'Tag','num_FramePerSecond'); |
---|
716 | fps=str2double(get(hFramePerSecond,'String')); |
---|
717 | hFrameNumber=findobj(hset_movie,'Tag','num_FrameNumber'); |
---|
718 | FrameNumber=str2double(get(hFrameNumber,'String'));% total nbre of frames |
---|
719 | |
---|
720 | %% create the movie file |
---|
721 | MovieDir=fileparts(MovieName); |
---|
722 | if ~exist(MovieDir,'dir') |
---|
723 | [success,message]=mkdir(MovieDir); |
---|
724 | if ~isequal(success,1) |
---|
725 | msgbox_uvmat('ERROR',message) |
---|
726 | return |
---|
727 | end |
---|
728 | [success,message] = fileattrib(MovieDir,'+w','g','s');% allow writing access for the group of users, recursively in the folder |
---|
729 | if success==0 |
---|
730 | msgbox_uvmat('WARNING',{['unable to set group write access to ' MovieDir ':']; message});%error message for directory creation |
---|
731 | end |
---|
732 | end |
---|
733 | if exist(MovieName,'file') |
---|
734 | backup=MovieName; |
---|
735 | testexist=2; |
---|
736 | while testexist==2 |
---|
737 | backup=[backup '~']; |
---|
738 | testexist=exist(backup,'file'); |
---|
739 | end |
---|
740 | [success,message]=copyfile(MovieName,backup);%make backup of the existing file |
---|
741 | if isequal(success,1) |
---|
742 | delete(MovieName)%delete existing file |
---|
743 | else |
---|
744 | msgbox_uvmat('ERROR',message) |
---|
745 | return |
---|
746 | end |
---|
747 | end |
---|
748 | %create avi open |
---|
749 | aviobj=avifile(MovieName,'Compression','None','fps',fps); |
---|
750 | |
---|
751 | %% get info from uvmat and adjust it |
---|
752 | huvmat=findobj(allchild(0),'Tag','uvmat'); |
---|
753 | hhuvmat=guidata(huvmat); |
---|
754 | increment=str2num(get(hhuvmat.num_IndexIncrement,'String')); %get the field increment from uvmat |
---|
755 | set(hhuvmat.STOP,'Visible','on') |
---|
756 | set(hhuvmat.speed,'Visible','on') |
---|
757 | set(hhuvmat.speed_txt,'Visible','on') |
---|
758 | set(hhuvmat.Movie,'BusyAction','queue') |
---|
759 | set(hhuvmat.speed,'Value',1) |
---|
760 | figure_movie=findobj(allchild(0),'name','figure_movie'); |
---|
761 | hhuvmat.PlotAxes=findobj(figure_movie,'Tag','movieaxes');% the axis in the new figure becomes the current main plotting axes |
---|
762 | for i=1:FrameNumber |
---|
763 | if get(hhuvmat.speed,'Value')~=0 && isequal(get(hhuvmat.MenuExportMovie,'BusyAction'),'queue') % enable STOP command |
---|
764 | runpm(hObject,eventdata,hhuvmat,increment)% run plus |
---|
765 | drawnow |
---|
766 | time_str=get(hhuvmat.TimeValue,'String'); |
---|
767 | htitle=get(hhuvmat.PlotAxes,'Title'); |
---|
768 | Title=get(htitle,'String'); |
---|
769 | set(htitle,'String',regexprep(Title,'t=\d+.\d*',['t=' time_str])) |
---|
770 | mov=getframe(figure_movie); |
---|
771 | aviobj=addframe(aviobj,mov); |
---|
772 | end |
---|
773 | end |
---|
774 | aviobj=close(aviobj); |
---|
775 | msgbox_uvmat('CONFIRMATION',{['movie ' MovieName ' created '];['with ' num2str(FrameNumber) ' frames']}) |
---|
776 | |
---|
777 | %------------------------------------------------------------------------ |
---|
778 | % function called by pressing APPLY in the GUI set_slices |
---|
779 | function set_movie_Cancel_Callback(hObject,eventdata) |
---|
780 | %------------------------------------------------------------------------ |
---|
781 | delete(hObject) |
---|
782 | |
---|
783 | |
---|
784 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
---|
785 | % Projection Objects Menu Callbacks |
---|
786 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
---|
787 | |
---|
788 | % ----------------------------------------------------------------------- |
---|
789 | function Menupoints_Callback(hObject, eventdata, handles) |
---|
790 | %------------------------------------------------------------------------ |
---|
791 | data.Type='points'; |
---|
792 | data.ProjMode='projection';%default |
---|
793 | data.ProjModeMenu={};% do not restrict ProjMode menus |
---|
794 | create_object(data,handles) |
---|
795 | |
---|
796 | % ----------------------------------------------------------------------- |
---|
797 | % --- Callback of the Menu command line |
---|
798 | %------------------------------------------------------------------------ |
---|
799 | function Menuline_Callback(hObject, eventdata, handles) |
---|
800 | %------------------------------------------------------------------------ |
---|
801 | data.Type='line'; |
---|
802 | data.ProjMode='projection';%default |
---|
803 | data.ProjModeMenu={};% do not restrict ProjMode menus |
---|
804 | create_object(data,handles) |
---|
805 | |
---|
806 | % ----------------------------------------------------------------------- |
---|
807 | % --- Callback of the Menu command line_x |
---|
808 | %------------------------------------------------------------------------ |
---|
809 | function Menuline_x_Callback(hObject, eventdata, handles) |
---|
810 | |
---|
811 | data.Type='line_x'; |
---|
812 | data.ProjMode='projection';%default |
---|
813 | data.ProjModeMenu={};% do not restrict ProjMode menus |
---|
814 | create_object(data,handles) |
---|
815 | |
---|
816 | % ----------------------------------------------------------------------- |
---|
817 | % --- Callback of the Menu command line_y |
---|
818 | % ----------------------------------------------------------------------- |
---|
819 | function Menuline_y_Callback(hObject, eventdata, handles) |
---|
820 | |
---|
821 | data.Type='line_y'; |
---|
822 | data.ProjMode='projection';%default |
---|
823 | data.ProjModeMenu={};% do not restrict ProjMode menus |
---|
824 | create_object(data,handles) |
---|
825 | |
---|
826 | %------------------------------------------------------------------------ |
---|
827 | function Menupolyline_Callback(hObject, eventdata, handles) |
---|
828 | %------------------------------------------------------------------------ |
---|
829 | data.Type='polyline'; |
---|
830 | data.ProjMode='projection';%default |
---|
831 | data.ProjModeMenu={};% do not restrict ProjMode menus |
---|
832 | create_object(data,handles) |
---|
833 | |
---|
834 | %------------------------------------------------------------------------ |
---|
835 | function Menupolygon_Callback(hObject, eventdata, handles) |
---|
836 | %------------------------------------------------------------------------ |
---|
837 | data.Type='polygon'; |
---|
838 | data.ProjMode='inside';%default |
---|
839 | data.ProjModeMenu={};% do not restrict ProjMode menus |
---|
840 | create_object(data,handles) |
---|
841 | |
---|
842 | %------------------------------------------------------------------------ |
---|
843 | function Menurectangle_Callback(hObject, eventdata, handles) |
---|
844 | %------------------------------------------------------------------------ |
---|
845 | data.Type='rectangle'; |
---|
846 | data.ProjMode='inside';%default |
---|
847 | data.ProjModeMenu={};% do not restrict ProjMode menus |
---|
848 | create_object(data,handles) |
---|
849 | |
---|
850 | %------------------------------------------------------------------------ |
---|
851 | function Menuellipse_Callback(hObject, eventdata, handles) |
---|
852 | %------------------------------------------------------------------------ |
---|
853 | data.Type='ellipse'; |
---|
854 | data.ProjMode='inside';%default |
---|
855 | data.ProjModeMenu={};% do not restrict ProjMode menus |
---|
856 | create_object(data,handles) |
---|
857 | |
---|
858 | %------------------------------------------------------------------------ |
---|
859 | function MenuMaskObject_Callback(hObject, eventdata, handles) |
---|
860 | %------------------------------------------------------------------------ |
---|
861 | data.Type='polygon'; |
---|
862 | data.TypeMenu={'polygon'}; |
---|
863 | data.ProjMode='mask_inside';%default |
---|
864 | data.ProjModeMenu={'mask_inside';'mask_outside'}; |
---|
865 | create_object(data,handles) |
---|
866 | |
---|
867 | %------------------------------------------------------------------------ |
---|
868 | function Menuplane_Callback(hObject, eventdata, handles) |
---|
869 | %------------------------------------------------------------------------ |
---|
870 | data.Type='plane'; |
---|
871 | data.ProjMode='projection';%default |
---|
872 | data.ProjModeMenu={};% do not restrict ProjMode menus |
---|
873 | create_object(data,handles) |
---|
874 | |
---|
875 | %------------------------------------------------------------------------ |
---|
876 | function Menuvolume_Callback(hObject, eventdata, handles) |
---|
877 | %------------------------------------------------------------------------ |
---|
878 | data.Type='volume'; |
---|
879 | data.ProjMode='interp_lin';%default |
---|
880 | data.ProjModeMenu={}; |
---|
881 | % set(handles.create,'Visible','on') |
---|
882 | % set(handles.create,'Value',1) |
---|
883 | % VOLUME_Callback(hObject,eventdata,handles)data.ProjModeMenu={}; |
---|
884 | create_object(data,handles) |
---|
885 | |
---|
886 | %------------------------------------------------------------------------ |
---|
887 | % --- generic function used for the creation of a projection object |
---|
888 | function create_object(data,handles) |
---|
889 | %------------------------------------------------------------------------ |
---|
890 | %% desactivate concurrent tools |
---|
891 | set(handles.MenuRuler,'checked','off')%desactivate ruler |
---|
892 | hgeometry_calib=findobj(allchild(0),'tag','geometry_calib');% search the GUI geometric calibration |
---|
893 | if ishandle(hgeometry_calib) |
---|
894 | hhgeometry_calib=guidata(hgeometry_calib); |
---|
895 | set(hhgeometry_calib.CheckEnableMouse,'Value',0)% desactivate mouse action in geometry_calib |
---|
896 | set(hhgeometry_calib.CheckEnableMouse,'BackgroundColor',[0.7 0.7 0.7]) |
---|
897 | end |
---|
898 | set(handles.CheckEditObject,'Value',0) %desactivate the object edit mode |
---|
899 | CheckEditObject_Callback([],[],handles) |
---|
900 | set(handles.CheckViewObject,'Value',0) % desactivate view_object (new object created) |
---|
901 | set(handles.CheckZoomFig,'Value',0) %desactivate zoom sub fig |
---|
902 | set(handles.CheckZoom,'Value',0) %desactivate the zoom action |
---|
903 | set(handles.MenuObject,'checked','on')% indicate object creation for mouse pointer display |
---|
904 | if ishandle(handles.UVMAT_title) |
---|
905 | delete(handles.UVMAT_title) %delete the initial display of uvmat if no field has been entered yet |
---|
906 | end |
---|
907 | |
---|
908 | %% initiate the new projection object |
---|
909 | UvData=get(handles.uvmat,'UserData'); |
---|
910 | data.Name=data.Type;% default name=type |
---|
911 | data.Coord=[0 0]; %default |
---|
912 | check_plot=0; |
---|
913 | if isfield(UvData,'Field') |
---|
914 | Field=UvData.Field; |
---|
915 | if isfield(Field,'NbDim')&& isequal(Field.NbDim,3) |
---|
916 | data.Coord=[0 0 0]; %default |
---|
917 | end |
---|
918 | if isfield(Field,'CoordUnit') |
---|
919 | data.CoordUnit=Field.CoordUnit; |
---|
920 | end |
---|
921 | if isfield(UvData.Field,'CoordMesh')&&~isempty(UvData.Field.CoordMesh) |
---|
922 | data.RangeX=[UvData.Field.XMin UvData.Field.XMax]; |
---|
923 | switch data.Type |
---|
924 | case {'line','polyline','points'} |
---|
925 | data.RangeY=UvData.Field.CoordMesh; |
---|
926 | case 'line_x' |
---|
927 | check_plot=1; %plot the line directly when set_object is opened |
---|
928 | data.Type='line'; |
---|
929 | data.RangeX=UvData.Field.XMin ; |
---|
930 | data.RangeY=UvData.Field.CoordMesh; |
---|
931 | data.Coord=[UvData.Field.XMin (UvData.Field.YMin +UvData.Field.YMax)/2;... |
---|
932 | UvData.Field.XMax (UvData.Field.YMin +UvData.Field.YMax)/2];% put line at the middle of the y axis |
---|
933 | case 'line_y' |
---|
934 | check_plot=1; %plot the line directly when set_object is opened |
---|
935 | data.Type='line'; |
---|
936 | data.RangeX=UvData.Field.YMin ; |
---|
937 | data.RangeY=UvData.Field.CoordMesh; |
---|
938 | data.Coord=[(UvData.Field.XMin+UvData.Field.XMax)/2 UvData.Field.YMin;... |
---|
939 | (UvData.Field.XMin +UvData.Field.XMax)/2 UvData.Field.YMax];% put line at the middle of the y axis |
---|
940 | case {'rectangle','ellipse'} |
---|
941 | data.RangeY=[UvData.Field.YMin UvData.Field.YMax]; |
---|
942 | data.RangeX=UvData.Field.CoordMesh; |
---|
943 | data.RangeY=UvData.Field.CoordMesh; |
---|
944 | otherwise |
---|
945 | data.RangeY=[UvData.Field.YMin UvData.Field.YMax]; |
---|
946 | end |
---|
947 | data.DX=UvData.Field.CoordMesh; |
---|
948 | data.DY=UvData.Field.CoordMesh; |
---|
949 | end |
---|
950 | end |
---|
951 | |
---|
952 | hset_object=set_object(data,handles);% call the GUI set_object |
---|
953 | hchild=get(hset_object,'children'); |
---|
954 | set(hchild,'enable','on') |
---|
955 | set(handles.DeleteObject,'Visible','on')% make the object delete button visible |
---|
956 | if check_plot |
---|
957 | hhset_object=guidata(hset_object); |
---|
958 | set_object('REFRESH_Callback',1,[],hhset_object);% call the GUI set_object |
---|
959 | end |
---|
960 | set(handles.CheckViewField,'Visible','on') |
---|
961 | set(handles.DeleteObject,'Visible','on') |
---|
962 | set(handles.ListObject_1,'Visible','on') |
---|
963 | set(handles.ListObject_1_title,'Visible','on') |
---|
964 | |
---|
965 | %------------------------------------------------------------------------ |
---|
966 | function MenuBrowseObject_Callback(hObject, eventdata, handles) |
---|
967 | %------------------------------------------------------------------------ |
---|
968 | %get the object file |
---|
969 | fileinput=uigetfile_uvmat('pick an xml object file:',get(handles.RootPath,'String'),'.xml'); |
---|
970 | if ~isempty(fileinput) |
---|
971 | %read the file |
---|
972 | [data,heading]=xml2struct(fileinput); |
---|
973 | if ~strcmp(heading,'ProjObject') |
---|
974 | msgbox_uvmat('WARNING','The xml file does not have the heading ProjObject for projection objects') |
---|
975 | end |
---|
976 | ListObject=get(handles.ListObject,'String'); |
---|
977 | ListObject=[ListObject;{data.Name}]; |
---|
978 | IndexObj=length(ListObject); |
---|
979 | UvData=get(handles.uvmat,'UserData'); |
---|
980 | UvData.ProjObject{IndexObj}=[]; %create a new empty object |
---|
981 | UvData.ProjObject{IndexObj}.DisplayHandle.uvmat=[]; %no plot handle before plot_field operation |
---|
982 | UvData.ProjObject{IndexObj}.DisplayHandle.view_field=[]; %no plot handle before plot_field operation |
---|
983 | set(handles.uvmat,'UserData',UvData) |
---|
984 | set(handles.CheckViewObject,'Value',1) |
---|
985 | set(handles.CheckViewField,'Value',1) |
---|
986 | hset_object=set_object(data);% call the set_object interface |
---|
987 | hhset_object=guidata(hset_object); |
---|
988 | set_object('REFRESH_Callback',hObject,eventdata,hhset_object);% plot projection |
---|
989 | set(handles.CheckEditObject,'Value',0); %suppress the object edit mode |
---|
990 | CheckEditObject_Callback([],[],handles) |
---|
991 | set(handles.DeleteObject,'Visible','on') |
---|
992 | end |
---|
993 | |
---|
994 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
---|
995 | % MenuTools Callbacks |
---|
996 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
---|
997 | %------------------------------------------------------------------------ |
---|
998 | function MenuCalib_Callback(hObject, eventdata, handles) |
---|
999 | %------------------------------------------------------------------------ |
---|
1000 | %% suppress the second field if exists |
---|
1001 | if get(handles.SubField,'Value') |
---|
1002 | set(handles.SubField,'Value',0) |
---|
1003 | SubField_Callback(hObject, eventdata, handles) |
---|
1004 | end |
---|
1005 | UvData=get(handles.uvmat,'UserData');%read UvData properties stored on the uvmat interface |
---|
1006 | |
---|
1007 | %% suppress competing tools |
---|
1008 | set(handles.MenuRuler,'checked','off')%desactivate ruler |
---|
1009 | set(handles.CheckZoom,'Value',0) |
---|
1010 | set(handles.CheckZoom,'BackgroundColor',[0.7 0.7 0.7]) |
---|
1011 | set(handles.ListObject,'Value',1) |
---|
1012 | |
---|
1013 | %% initiate display of the GUI geometry_calib |
---|
1014 | data=[]; %default |
---|
1015 | if isfield(UvData,'CoordType') |
---|
1016 | data.CoordType=UvData.CoordType; |
---|
1017 | end |
---|
1018 | [RootPath,SubDir,RootFile,FileIndex,FileExt]=read_file_boxes(handles); |
---|
1019 | FileName=[fullfile(RootPath,SubDir,RootFile) FileIndex FileExt]; |
---|
1020 | set(handles.view_xml,'BackgroundColor',[1 1 0])%indicate the reading of the current xml file by geometry_calib |
---|
1021 | geometry_calib(FileName);% call the geometry_calib interface |
---|
1022 | set(handles.view_xml,'BackgroundColor',[1 1 1])%indicate the end of reading of the current xml file by geometry_calib |
---|
1023 | set(handles.MenuCalib,'checked','on')% indicate that MenuCalib is activated, test used by mouse action |
---|
1024 | |
---|
1025 | |
---|
1026 | % -------------------------------------------------------------------- |
---|
1027 | % --- set the slice plane ro the set of slice planes when volume scan is used |
---|
1028 | function MenuSetSlice_Callback(hObject, eventdata, handles) |
---|
1029 | % -------------------------------------------------------------------- |
---|
1030 | %% suppress the second input field if exists |
---|
1031 | if get(handles.SubField,'Value') |
---|
1032 | set(handles.SubField,'Value',0) |
---|
1033 | SubField_Callback(hObject, eventdata, handles) |
---|
1034 | end |
---|
1035 | |
---|
1036 | UvData=get(handles.uvmat,'UserData');%read UvData properties stored on the uvmat interface |
---|
1037 | check=0; |
---|
1038 | if isfield(UvData,'XmlData')&&isfield(UvData.XmlData{1},'GeometryCalib')&& isfield(UvData.XmlData{1}.GeometryCalib,'SliceCoord') |
---|
1039 | GeometryCalib=UvData.XmlData{1}.GeometryCalib; |
---|
1040 | else |
---|
1041 | msgbox_uvmat('ERROR','3D geometric calibration needed before defining slices') |
---|
1042 | return |
---|
1043 | end |
---|
1044 | SliceCoord=GeometryCalib.SliceCoord; |
---|
1045 | InterfaceCoord=min(SliceCoord(:,3)); |
---|
1046 | if isfield(GeometryCalib,'InterfaceCoord') |
---|
1047 | InterfaceCoord=GeometryCalib.InterfaceCoord(1,3); |
---|
1048 | end |
---|
1049 | NbSlice=size(SliceCoord,1); |
---|
1050 | CheckVolumeScan=0; |
---|
1051 | if isfield(GeometryCalib,'CheckVolumeScan') |
---|
1052 | CheckVolumeScan=GeometryCalib.CheckVolumeScan; |
---|
1053 | end |
---|
1054 | RefractionIndex=1.33; |
---|
1055 | if isfield(GeometryCalib,'RefractionIndex') |
---|
1056 | RefractionIndex=GeometryCalib.RefractionIndex; |
---|
1057 | end |
---|
1058 | SliceAngle=[0 0 0]; |
---|
1059 | if isfield(GeometryCalib,'SliceAngle') |
---|
1060 | SliceAngle=GeometryCalib.SliceAngle; |
---|
1061 | end |
---|
1062 | |
---|
1063 | %% create the GUI set_slice |
---|
1064 | set(0,'Units','points') |
---|
1065 | ScreenSize=get(0,'ScreenSize');% get the size of the screen, to put the fig on the upper right |
---|
1066 | Width=350;% fig width in points (1/72 inch) |
---|
1067 | Height=min(0.8*ScreenSize(4),300); |
---|
1068 | Left=ScreenSize(3)- Width-40; %right edge close to the right, with margin=40 |
---|
1069 | Bottom=ScreenSize(4)-Height-40; %put fig at top right |
---|
1070 | hfig=findobj(allchild(0),'Tag','set_slice'); |
---|
1071 | if ~isempty(hfig),delete(hfig), end; %delete existing version of the GUI |
---|
1072 | hfig=figure('name','set_slices','tag','set_slice','MenuBar','none','NumberTitle','off','Units','pixels','Position',[Left,Bottom,Width,Height],'UserData',GeometryCalib); |
---|
1073 | BackgroundColor=get(hfig,'Color'); |
---|
1074 | hh=0.14; % box height (relative) |
---|
1075 | ii=0.01; % gap between uicontrols |
---|
1076 | |
---|
1077 | ww=(1-5*ii)/4; % box width (relative) |
---|
1078 | % first raw of the GUI |
---|
1079 | uicontrol('Style','text','Units','normalized', 'Position', [2*ii+ww 0.95-ii-0.25*hh ww hh/2],'BackgroundColor',BackgroundColor,... |
---|
1080 | 'String','first','FontUnits','points','FontSize',12,'FontWeight','bold','ForegroundColor','blue','HorizontalAlignment','center');%title |
---|
1081 | uicontrol('Style','text','Units','normalized', 'Position', [3*ii+2*ww 0.95-ii-0.25*hh ww hh/2],'BackgroundColor',BackgroundColor,... |
---|
1082 | 'String','last','FontUnits','points','FontSize',12,'FontWeight','bold','ForegroundColor','blue','HorizontalAlignment','center');%title |
---|
1083 | uicontrol('Style','text','Units','normalized', 'Position', [4*ii+3*ww 0.95-ii-0.25*hh ww hh/2],'BackgroundColor',BackgroundColor,... |
---|
1084 | 'String','surface','FontUnits','points','FontSize',12,'FontWeight','bold','ForegroundColor','blue','HorizontalAlignment','center');%title |
---|
1085 | % raw 2 of the GUI |
---|
1086 | uicontrol('Style','text','Units','normalized', 'Position', [ii 0.95-2*ii-0.75*hh ww hh/2],'BackgroundColor',BackgroundColor,... |
---|
1087 | 'String','Z','FontUnits','points','FontSize',12,'FontWeight','bold','ForegroundColor','blue','HorizontalAlignment','right');%title |
---|
1088 | uicontrol('Style','edit','Units','normalized', 'Position', [2*ii+ww 0.95-2*ii-hh ww hh],'tag','num_Z_1','BackgroundColor',[1 1 1],... |
---|
1089 | 'String',num2str(SliceCoord(1,3)),'FontUnits','points','FontSize',12,'FontWeight','bold','TooltipString','''num_Z_1'': z position of first slice');%edit box |
---|
1090 | uicontrol('Style','edit','Units','normalized', 'Position', [3*ii+2*ww 0.95-2*ii-hh ww hh],'tag','num_Z_2','BackgroundColor',[1 1 1],... |
---|
1091 | 'String',num2str(SliceCoord(end,3)),'FontUnits','points','FontSize',12,'FontWeight','bold','TooltipString','''num_Z_2'': z position of last slice');%edit box |
---|
1092 | uicontrol('Style','edit','Units','normalized', 'Position', [4*ii+3*ww 0.95-2*ii-hh ww hh],'tag','num_H','BackgroundColor',[1 1 1],... |
---|
1093 | 'String',num2str(InterfaceCoord),'FontUnits','points','FontSize',12,'FontWeight','bold','TooltipString','''num_H'': z position of the water surface (=Z_1 in air)');%edit box |
---|
1094 | % raw 3 of the GUI |
---|
1095 | uicontrol('Style','text','Units','normalized', 'Position', [2*ii+ww 0.95-3*ii-1.75*hh 2*ww hh/2],'BackgroundColor',BackgroundColor,'Tag','Refraction_title',... |
---|
1096 | 'String','refraction index','FontUnits','points','FontSize',12,'FontWeight','bold','ForegroundColor','blue','HorizontalAlignment','right');%title |
---|
1097 | uicontrol('Style','edit','Units','normalized', 'Position', [4*ii+3*ww 0.95-3*ii-2*hh ww hh],'tag','num_RefractionIndex','BackgroundColor',[1 1 1],... |
---|
1098 | 'String',num2str(RefractionIndex),'FontUnits','points','FontSize',12,'FontWeight','bold','TooltipString','''num_RefractionIndex'': refraction index of water'); |
---|
1099 | % raw 4 of the GUI |
---|
1100 | uicontrol('Style','text','Units','normalized', 'Position', [ii 0.95-4*ii-3.25*hh ww hh],'BackgroundColor',BackgroundColor,'Tag','NbSlice_title',... |
---|
1101 | 'String','NbSlice','FontUnits','points','FontSize',12,'FontWeight','bold','ForegroundColor','blue','HorizontalAlignment','right');%title |
---|
1102 | uicontrol('Style','edit','Units','normalized', 'Position', [2*ii+ww 0.95-4*ii-3*hh ww hh],'tag','num_NbSlice','BackgroundColor',[1 1 1],... |
---|
1103 | 'String',num2str(NbSlice),'FontUnits','points','FontSize',12,'FontWeight','bold','TooltipString','''num_NbSlice'':number of slices');%edit box |
---|
1104 | uicontrol('Style','checkbox','Units','normalized', 'Position', [3*ii+2*ww 0.95-4*ii-3*hh 2*ww hh],'tag','CheckVolumeScan','BackgroundColor',BackgroundColor,... |
---|
1105 | 'String','volume scan','Value',CheckVolumeScan,'FontUnits','points','FontSize',12,'FontWeight','bold','TooltipString','''CheckVolumeScan'':=1 for volume scan (z varies with j index)'); |
---|
1106 | % raw 5 of the GUI |
---|
1107 | uicontrol('Style','text','Units','normalized', 'Position', [2*ii+2*ww 0.95-5*ii-4.2*hh ww hh/2],'BackgroundColor',BackgroundColor,'Tag','Angle_title_1',... |
---|
1108 | 'String','x axis','FontUnits','points','FontSize',12,'FontWeight','bold','ForegroundColor','blue','HorizontalAlignment','center');%title |
---|
1109 | uicontrol('Style','text','Units','normalized', 'Position', [3*ii+3*ww 0.95-5*ii-4.2*hh ww hh/2],'BackgroundColor',BackgroundColor,'Tag','Angle_title_2',... |
---|
1110 | 'String','y axis','FontUnits','points','FontSize',12,'FontWeight','bold','ForegroundColor','blue','HorizontalAlignment','center');%title |
---|
1111 | % raw 6 of the GUI |
---|
1112 | uicontrol('Style','text','Units','normalized', 'Position', [ii 0.95-5*ii-4.75*hh 2*ww hh/2],'BackgroundColor',BackgroundColor,'Tag','NbSlice_title',... |
---|
1113 | 'String','tilt angle','FontUnits','points','FontSize',12,'FontWeight','bold','ForegroundColor','blue','HorizontalAlignment','right');%title |
---|
1114 | uicontrol('Style','edit','Units','normalized', 'Position', [3*ii+2*ww 0.95-5*ii-5*hh ww hh],'tag','num_SliceAngle_1','BackgroundColor',[1 1 1],... |
---|
1115 | 'String',num2str(SliceAngle(1)),'FontUnits','points','FontSize',12,'FontWeight','bold','TooltipString','''num_SliceAngle_1'':slice angle of inclination around the x axis');%edit box |
---|
1116 | uicontrol('Style','edit','Units','normalized', 'Position', [4*ii+3*ww 0.95-5*ii-5*hh ww hh],'tag','num_SliceAngle_2','BackgroundColor',[1 1 1],... |
---|
1117 | 'String',num2str(SliceAngle(2)),'FontUnits','points','FontSize',12,'FontWeight','bold','TooltipString','''num_SliceAngle_1'':slice angle of inclination around the y axis');%edit box |
---|
1118 | % raw 7 of the GUI: pushbuttons |
---|
1119 | wwp=(1-4*ii)/3; %width of the push buttons |
---|
1120 | uicontrol('Style','pushbutton','Units','normalized', 'Position', [ii ii wwp hh],'BackgroundColor',[1 0 0],'String','APPLY','Callback',@(hObject,eventdata)set_slice_APPLY_Callback(hObject,eventdata),... |
---|
1121 | 'FontWeight','bold','FontUnits','points','FontSize',12,'TooltipString','''APPLY'': apply the output to the current field series in uvmat'); |
---|
1122 | uicontrol('Style','pushbutton','Units','normalized', 'Position', [2*ii+wwp ii wwp hh],'BackgroundColor',[1 0 0],'String','REPLICATE','Callback',@(hObject,eventdata)set_slice_REPLICATE_Callback(hObject,eventdata),... |
---|
1123 | 'FontWeight','bold','FontUnits','points','FontSize',12,'TooltipString','''REPLICATE'': replicate the output for a series of experiments'); |
---|
1124 | uicontrol('Style','pushbutton','Units','normalized', 'Position', [3*ii+2*wwp ii wwp hh],'Callback',@(hObject,eventdata)set_slice_Cancel_Callback(hObject,eventdata),... |
---|
1125 | 'String','Cancel','FontWeight','bold','FontUnits','points','FontSize',12,'TooltipString','''Cancel'': quit GUI without action'); |
---|
1126 | drawnow |
---|
1127 | |
---|
1128 | %------------------------------------------------------------------------ |
---|
1129 | % function called by pressing APPLY in the GUI set_slices |
---|
1130 | function set_slice_APPLY_Callback(hObject,eventdata) |
---|
1131 | %------------------------------------------------------------------------ |
---|
1132 | |
---|
1133 | %% get the uvmat GUI data and read the current xml file |
---|
1134 | huvmat=findobj(allchild(0),'Tag','uvmat'); |
---|
1135 | hhuvmat=guidata(huvmat); |
---|
1136 | [RootPath,SubDir,RootFile,FileIndex,FileExt]=read_file_boxes(hhuvmat); |
---|
1137 | FileName=[fullfile(RootPath,SubDir,RootFile) FileIndex FileExt];%name of the xml file for calibration |
---|
1138 | [RootPath,SubDir,RootFile,tild,tild,tild,tild,FileExt]=fileparts_uvmat(FileName); |
---|
1139 | XmlFile=find_imadoc(RootPath,SubDir,RootFile,FileExt); |
---|
1140 | [s,errormsg]=imadoc2struct(XmlFile,'GeometryCalib'); |
---|
1141 | if~isempty(errormsg) |
---|
1142 | msgbox_uvmat('ERROR',errormsg) |
---|
1143 | return |
---|
1144 | end |
---|
1145 | GeometryCalib=s.GeometryCalib; |
---|
1146 | |
---|
1147 | %% read the content of the GUI set_slice |
---|
1148 | SliceData=read_GUI(get(hObject,'parent')); |
---|
1149 | GeometryCalib.NbSlice=SliceData.NbSlice; |
---|
1150 | GeometryCalib.CheckVolumeScan=SliceData.CheckVolumeScan; |
---|
1151 | Z_plane=linspace(SliceData.Z(1),SliceData.Z(2),SliceData.NbSlice); |
---|
1152 | GeometryCalib.SliceCoord=Z_plane'*[0 0 1]; |
---|
1153 | GeometryCalib.SliceAngle=zeros(GeometryCalib.NbSlice,3); |
---|
1154 | GeometryCalib.SliceAngle(:,1)=SliceData.SliceAngle(1)*ones(GeometryCalib.NbSlice,1);%rotation around x axis (to generalise) |
---|
1155 | GeometryCalib.SliceAngle(:,2)=SliceData.SliceAngle(2)*ones(GeometryCalib.NbSlice,1);%rotation around y axis (to generalise) |
---|
1156 | GeometryCalib.SliceAngle(:,3)=0; |
---|
1157 | GeometryCalib.InterfaceCoord=[0 0 SliceData.H]; |
---|
1158 | GeometryCalib.RefractionIndex=SliceData.RefractionIndex; |
---|
1159 | |
---|
1160 | %% store the result in the xml file used for calibration |
---|
1161 | errormsg=update_imadoc(GeometryCalib,XmlFile,'GeometryCalib');% introduce the calibration data in the xml file |
---|
1162 | if strcmp(errormsg,'') |
---|
1163 | msgbox_uvmat('CONFIRMATION',['slice positions saved in ' XmlFile]); |
---|
1164 | else |
---|
1165 | msgbox_uvmat('ERROR',errormsg); |
---|
1166 | end |
---|
1167 | |
---|
1168 | %% display image with new calibration in the currently opened uvmat interface |
---|
1169 | set(hhuvmat.CheckFixLimits,'Value',0)% put FixedLimits option to 'off' to plot the whole image |
---|
1170 | uvmat('InputFileREFRESH_Callback',huvmat,[],hhuvmat); %file input with xml reading in uvmat, show the image in phys coordinates |
---|
1171 | |
---|
1172 | %------------------------------------------------------------------------ |
---|
1173 | % function called by pressing REPLICATE in the GUI set_slices |
---|
1174 | function set_slice_REPLICATE_Callback(hObject,eventdata) |
---|
1175 | %------------------------------------------------------------------------ |
---|
1176 | |
---|
1177 | %% read the GUI set_slice |
---|
1178 | SliceData=read_GUI(get(hObject,'parent')); |
---|
1179 | |
---|
1180 | %% get info on the GUI uvmat |
---|
1181 | huvmat=findobj(allchild(0),'Tag','uvmat'); |
---|
1182 | hhuvmat=guidata(huvmat); |
---|
1183 | [RootPath,SubDir,RootFile,FileIndex,FileExt]=read_file_boxes(hhuvmat); |
---|
1184 | |
---|
1185 | %% open the GUI browse_data |
---|
1186 | answer=msgbox_uvmat('INPUT_TXT','Campaign to calibrate with slice position?',fileparts(RootPath)); |
---|
1187 | if strcmp(answer,'Cancel') |
---|
1188 | return |
---|
1189 | end |
---|
1190 | OutPut=browse_data(answer); |
---|
1191 | nbcalib=0; |
---|
1192 | for ilist=1:numel(OutPut.Experiment) |
---|
1193 | SubDirBase=regexprep(OutPut.DataSeries{1},'\..+$',''); |
---|
1194 | XmlFile=fullfile(OutPut.Campaign,OutPut.Experiment{ilist},[SubDirBase '.xml']); |
---|
1195 | |
---|
1196 | % read the current xml file |
---|
1197 | [s,errormsg]=imadoc2struct(XmlFile,'GeometryCalib'); |
---|
1198 | if ~isempty(errormsg) |
---|
1199 | msgbox_uvmat('ERROR',['error in reading ' XmlFile ': ' errormsg]) |
---|
1200 | return |
---|
1201 | end |
---|
1202 | GeometryCalib=s.GeometryCalib; |
---|
1203 | GeometryCalib.NbSlice=SliceData.NbSlice; |
---|
1204 | GeometryCalib.VolumeScan=SliceData.CheckVolumeScan; |
---|
1205 | Z_plane=linspace(SliceData.Z(1),SliceData.Z(2),SliceData.NbSlice); |
---|
1206 | GeometryCalib.SliceCoord=Z_plane'*[0 0 1]; |
---|
1207 | GeometryCalib.SliceAngle=zeros(GeometryCalib.NbSlice,3); |
---|
1208 | GeometryCalib.SliceAngle(:,1)=SliceData.SliceAngle(1)*ones(GeometryCalib.NbSlice,1);%rotation around x axis (to generalise) |
---|
1209 | GeometryCalib.SliceAngle(:,2)=SliceData.SliceAngle(2)*ones(GeometryCalib.NbSlice,1);%rotation around y axis (to generalise) |
---|
1210 | GeometryCalib.SliceAngle(:,3)=0; |
---|
1211 | GeometryCalib.InterfaceCoord=[0 0 SliceData.H]; |
---|
1212 | GeometryCalib.RefractionIndex=SliceData.RefractionIndex; |
---|
1213 | |
---|
1214 | % update the current xml file |
---|
1215 | errormsg=update_imadoc(GeometryCalib,XmlFile,'GeometryCalib');% introduce the calibration data in the xml file |
---|
1216 | if ~strcmp(errormsg,'') |
---|
1217 | msgbox_uvmat('ERROR',errormsg); |
---|
1218 | else |
---|
1219 | display([XmlFile ' updated with slice positions']) |
---|
1220 | nbcalib=nbcalib+1; |
---|
1221 | end |
---|
1222 | end |
---|
1223 | msgbox_uvmat('CONFIMATION',[SubDirBase ' calibrated with slice positions for ' num2str(nbcalib) ' experiments']); |
---|
1224 | |
---|
1225 | %------------------------------------------------------------------------ |
---|
1226 | % function called by pressing Cancel in the GUI set_slices |
---|
1227 | function set_slice_Cancel_Callback(hObject,eventdata) |
---|
1228 | %------------------------------------------------------------------------ |
---|
1229 | hfig=get(hObject,'parent'); |
---|
1230 | delete(hfig) |
---|
1231 | |
---|
1232 | %----------------------------------------------------------------------- |
---|
1233 | function MenuLIFCalib_Callback(hObject, eventdata, handles) |
---|
1234 | %------------------------------------------------------------------------ |
---|
1235 | %% read UvData properties stored on the uvmat interface |
---|
1236 | UvData=get(handles.uvmat,'UserData'); |
---|
1237 | if isfield(UvData,'XmlData')&& isfield(UvData.XmlData{1},'GeometryCalib') |
---|
1238 | XmlData=UvData.XmlData{1}; |
---|
1239 | else |
---|
1240 | msgbox_uvmat('ERROR','geometric calibration needed: use Tools/geometric calibration in the menu bar'); |
---|
1241 | return |
---|
1242 | end |
---|
1243 | |
---|
1244 | %% read lines currently drawn |
---|
1245 | ListObj=UvData.ProjObject; |
---|
1246 | select=zeros(1,numel(ListObj)); |
---|
1247 | for iobj=1:numel(ListObj); |
---|
1248 | if isfield(ListObj{iobj},'Type') && strcmp(ListObj{iobj}.Type,'line') |
---|
1249 | select(iobj)=1; |
---|
1250 | end |
---|
1251 | end |
---|
1252 | val=find(select); |
---|
1253 | if numel(val)<2 |
---|
1254 | msgbox_uvmat('ERROR','light rays must be defined by at least two lines created by Projection object/line in the menu bar'); |
---|
1255 | return |
---|
1256 | else |
---|
1257 | set(handles.ListObject,'Value',val);% show the selected lines on the list |
---|
1258 | ObjectData=UvData.ProjObject(val); |
---|
1259 | for iobj=1:length(ObjectData) |
---|
1260 | xA(iobj)=ObjectData{iobj}.Coord(1,1); |
---|
1261 | yA(iobj)=ObjectData{iobj}.Coord(1,2); |
---|
1262 | xB(iobj)=ObjectData{iobj}.Coord(2,1); |
---|
1263 | yB(iobj)=ObjectData{iobj}.Coord(2,2); |
---|
1264 | end |
---|
1265 | end |
---|
1266 | |
---|
1267 | %% find the origin as intersection of the two first lines (see http://www.ahristov.com/tutorial/geometry-games/intersection-lines.html ) |
---|
1268 | x1=xA(1);x2=xB(1); |
---|
1269 | x3=xA(2);x4=xB(2); |
---|
1270 | y1=yA(1);y2=yB(1); |
---|
1271 | y3=yA(2);y4=yB(2); |
---|
1272 | D = (x1-x2)*(y3-y4) -(y1-y2)*(x3-x4); |
---|
1273 | if D==0 |
---|
1274 | msgbox_uvmat('ERROR','the two lines are parallel'); |
---|
1275 | return |
---|
1276 | end |
---|
1277 | x0=((x3-x4)*(x1*y2-y1*x2)-(x1-x2)*(x3*y4-y3*x4))/D; |
---|
1278 | y0=((y3-y4)*(x1*y2-y1*x2)-(y1-y2)*(x3*y4-y3*x4))/D; |
---|
1279 | XmlData.Illumination.Origin=[x0 y0]; |
---|
1280 | XmlData.PolarCentre=[x0 y0]; |
---|
1281 | |
---|
1282 | %% display the current image in polar axes with origin at the illumination source |
---|
1283 | currentdir=pwd; |
---|
1284 | uvmatpath=fileparts(which('uvmat')); |
---|
1285 | cd(fullfile(uvmatpath,'transform_field')); |
---|
1286 | phys_polar=str2func('phys_polar'); |
---|
1287 | cd(currentdir) |
---|
1288 | DataOut=phys_polar(UvData.Field,XmlData); |
---|
1289 | view_field(DataOut); |
---|
1290 | |
---|
1291 | %% use the third line for reference luminosity |
---|
1292 | if numel(val)==3 |
---|
1293 | x_ref=linspace(ObjectData{3}.Coord(1,1),ObjectData{3}.Coord(2,1),10); |
---|
1294 | y_ref=linspace(ObjectData{3}.Coord(1,2),ObjectData{3}.Coord(2,2),10); |
---|
1295 | x_ref=x_ref-x0; |
---|
1296 | y_ref=y_ref-y0; |
---|
1297 | [theta_ref,r_ref] = cart2pol(x_ref,y_ref);%theta_ref and r_ref are the polar coordinates of the points on the line |
---|
1298 | theta_ref=theta_ref*180/pi; |
---|
1299 | figure |
---|
1300 | plot(theta_ref,r_ref) |
---|
1301 | azimuth_ima=linspace(DataOut.Coord_y(1),DataOut.Coord_y(2),size(DataOut.A,1));%profile of x index on the transformed image |
---|
1302 | dist_source = interp1(theta_ref,r_ref,azimuth_ima); |
---|
1303 | dist_source_pixel=round(size(DataOut.A,2)*(dist_source-DataOut.Coord_x(1))/(DataOut.Coord_x(2)-DataOut.Coord_x(1))); |
---|
1304 | line_nan= isnan(dist_source_pixel); |
---|
1305 | dist_source_pixel(line_nan)=1; |
---|
1306 | width=20; %number of pixels used for reference |
---|
1307 | DataOut.A=double(DataOut.A); |
---|
1308 | Anorm=zeros(size(DataOut.A)); |
---|
1309 | Aval=mean(mean(DataOut.A)); |
---|
1310 | for iline=1:size(DataOut.A,1) |
---|
1311 | lum(iline)=mean(DataOut.A(iline,dist_source_pixel(iline):dist_source_pixel(iline)+width)); |
---|
1312 | Anorm(iline,:)=uint16(Aval*DataOut.A(iline,:)/lum(iline)); |
---|
1313 | end |
---|
1314 | lum(line_nan)=NaN; |
---|
1315 | figure |
---|
1316 | plot(1:size(DataOut.A,1),lum) |
---|
1317 | end |
---|
1318 | ImaName=regexprep([get(handles.RootFile,'String') get(handles.FileIndex,'String')],'//',''); |
---|
1319 | NewImageName=fullfile(get(handles.RootPath,'String'),'polar',[ImaName get(handles.FileExt,'String')]); |
---|
1320 | imwrite(Anorm,NewImageName,'BitDepth',16) |
---|
1321 | |
---|
1322 | %% record the origin in the xml file |
---|
1323 | XmlFileName=find_imadoc(get(handles.RootPath,'String'),get(handles.SubDir,'String'),get(handles.RootFile,'String'),get(handles.FileExt,'String')); |
---|
1324 | answer=msgbox_uvmat('INPUT_Y-N','save the illumination origin in the current xml file?'); |
---|
1325 | if strcmp(answer,'Yes') |
---|
1326 | t=xmltree(XmlFileName); %read the file |
---|
1327 | title=get(t,1,'name'); |
---|
1328 | if ~strcmp(title,'ImaDoc') |
---|
1329 | msgbox_uvmat('ERROR','wrong xml file'); |
---|
1330 | return |
---|
1331 | end |
---|
1332 | % backup the output file if it already exist, and read it |
---|
1333 | backupfile=XmlFileName; |
---|
1334 | testexist=2; |
---|
1335 | while testexist==2 |
---|
1336 | backupfile=[backupfile '~']; |
---|
1337 | testexist=exist(backupfile,'file'); |
---|
1338 | end |
---|
1339 | [success,message]=copyfile(XmlFileName,backupfile);%make backup |
---|
1340 | if success~=1 |
---|
1341 | errormsg=['errror in xml file backup: ' message]; |
---|
1342 | return |
---|
1343 | end |
---|
1344 | uid_illumination=find(t,'ImaDoc/Illumination'); |
---|
1345 | if isempty(uid_illumination) %if GeometryCalib does not already exists, create it |
---|
1346 | [t,uid_illumination]=add(t,1,'element','Illumination'); |
---|
1347 | end |
---|
1348 | uid_origin=find(t,'ImaDoc/Illumination/Origin'); |
---|
1349 | if ~isempty(uid_origin) %if GeometryCalib does not already exists, create it |
---|
1350 | t=delete(t,uid_origin); |
---|
1351 | end |
---|
1352 | % save the illumination origin |
---|
1353 | t=struct2xml(XmlData.Illumination,t,uid_illumination); |
---|
1354 | save(t,XmlFileName); |
---|
1355 | end |
---|
1356 | |
---|
1357 | |
---|
1358 | |
---|
1359 | %------------------------------------------------------------------------ |
---|
1360 | function MenuMask_Callback(hObject, eventdata, handles) |
---|
1361 | %------------------------------------------------------------------------ |
---|
1362 | UvData=get(handles.uvmat,'UserData');%read UvData properties stored on the uvmat interface |
---|
1363 | ListObj=UvData.ProjObject; |
---|
1364 | select=zeros(1,numel(ListObj)); |
---|
1365 | for iobj=1:numel(ListObj); |
---|
1366 | if strcmp(ListObj{iobj}.ProjMode,'mask_inside')||strcmp(ListObj{iobj}.ProjMode,'mask_outside') |
---|
1367 | select(iobj)=1; |
---|
1368 | end |
---|
1369 | end |
---|
1370 | val=find(select); |
---|
1371 | if isempty(val) |
---|
1372 | msgbox_uvmat('ERROR','polygons must be first created by Projection object/mask polygon in the menu bar'); |
---|
1373 | return |
---|
1374 | else |
---|
1375 | set(handles.ListObject,'Value',val); |
---|
1376 | flag=1; |
---|
1377 | if ~isfield(UvData.Field,'A') |
---|
1378 | msgbox_uvmat('ERROR','an image needs to be opened to set the mask size'); |
---|
1379 | return |
---|
1380 | end |
---|
1381 | npx=size(UvData.Field.A,2); |
---|
1382 | npy=size(UvData.Field.A,1); |
---|
1383 | xi=0.5:npx-0.5; |
---|
1384 | yi=0.5:npy-0.5; |
---|
1385 | [Xi,Yi]=meshgrid(xi,yi); |
---|
1386 | for iobj=1:length(UvData.ProjObject) |
---|
1387 | ObjectData=UvData.ProjObject{iobj}; |
---|
1388 | if isfield(ObjectData,'ProjMode') &&(isequal(ObjectData.ProjMode,'mask_inside')||isequal(ObjectData.ProjMode,'mask_outside')); |
---|
1389 | flagobj=1; |
---|
1390 | testphys=0; %coordinates in pixels by default |
---|
1391 | if isfield(ObjectData,'CoordUnit') && ~isequal(ObjectData.CoordUnit,'pixel') |
---|
1392 | if isfield(UvData,'XmlData')&& isfield(UvData.XmlData{1},'GeometryCalib') |
---|
1393 | Calib=UvData.XmlData{1}.GeometryCalib; |
---|
1394 | testphys=1; |
---|
1395 | end |
---|
1396 | end |
---|
1397 | if isfield(ObjectData,'Coord')&& isfield(ObjectData,'Type') |
---|
1398 | if isequal(ObjectData.Type,'polygon') |
---|
1399 | X=ObjectData.Coord(:,1); |
---|
1400 | Y=ObjectData.Coord(:,2); |
---|
1401 | if testphys |
---|
1402 | pos=[X Y zeros(size(X))]; |
---|
1403 | if isfield(Calib,'SliceCoord') && length(Calib.SliceCoord)>=3 |
---|
1404 | if isfield(Calib,'SliceAngle')&&~isequal(Calib.SliceAngle,[0 0 0]) |
---|
1405 | om=norm(Calib.SliceAngle);%norm of rotation angle in radians |
---|
1406 | OmAxis=Calib.SliceAngle/om; %unit vector marking the rotation axis |
---|
1407 | cos_om=cos(pi*om/180); |
---|
1408 | sin_om=sin(pi*om/180); |
---|
1409 | pos=cos_om*pos+sin_om*cross(OmAxis,pos)+(1-cos_om)*(OmAxis*pos')*OmAxis; |
---|
1410 | end |
---|
1411 | pos(:,1)=pos(:,1)+Calib.SliceCoord(1); |
---|
1412 | pos(:,2)=pos(:,2)+Calib.SliceCoord(2); |
---|
1413 | pos(:,3)=pos(:,3)+Calib.SliceCoord(3); |
---|
1414 | end |
---|
1415 | [X,Y]=px_XYZ(Calib,pos(:,1),pos(:,2),pos(:,3)); |
---|
1416 | end |
---|
1417 | flagobj=~inpolygon(Xi,Yi,X',Y');%=0 inside the polygon, 1 outside |
---|
1418 | elseif isequal(ObjectData.Type,'ellipse') |
---|
1419 | if testphys |
---|
1420 | %[X,Y]=px_XYZ(Calib,X,Y,0);% TODO:create a polygon boundary and transform to phys |
---|
1421 | end |
---|
1422 | RangeX=max(ObjectData.RangeX); |
---|
1423 | RangeY=max(ObjectData.RangeY); |
---|
1424 | X2Max=RangeX*RangeX; |
---|
1425 | Y2Max=RangeY*RangeY; |
---|
1426 | distX=(Xi-ObjectData.Coord(1,1)); |
---|
1427 | distY=(Yi-ObjectData.Coord(1,2)); |
---|
1428 | flagobj=(distX.*distX/X2Max+distY.*distY/Y2Max)>1; |
---|
1429 | elseif isequal(ObjectData.Type,'rectangle') |
---|
1430 | if testphys |
---|
1431 | %[X,Y]=px_XYZ(Calib,X,Y,0);% TODO:create a polygon boundary and transform to phys |
---|
1432 | end |
---|
1433 | distX=abs(Xi-ObjectData.Coord(1,1)); |
---|
1434 | distY=abs(Yi-ObjectData.Coord(1,2)); |
---|
1435 | flagobj=distX>max(ObjectData.RangeX) | distY>max(ObjectData.RangeY); |
---|
1436 | end |
---|
1437 | if isequal(ObjectData.ProjMode,'mask_outside') |
---|
1438 | flagobj=~flagobj; |
---|
1439 | end |
---|
1440 | flag=flag & flagobj; |
---|
1441 | end |
---|
1442 | end |
---|
1443 | end |
---|
1444 | %mask name |
---|
1445 | RootPath=get(handles.RootPath,'String'); |
---|
1446 | SubDir=get(handles.SubDir,'String'); |
---|
1447 | RootFile=get(handles.RootFile,'String'); |
---|
1448 | if ~isempty(RootFile)&&(isequal(RootFile(1),'/')|| isequal(RootFile(1),'\')) |
---|
1449 | RootFile(1)=[]; |
---|
1450 | end |
---|
1451 | list=get(handles.masklevel,'String'); |
---|
1452 | masknumber=num2str(length(list)); |
---|
1453 | maskindex=get(handles.masklevel,'Value'); |
---|
1454 | mask_name=fullfile_uvmat(RootPath,[SubDir '.mask'],'mask','.png','_1',maskindex); |
---|
1455 | imflag=uint8(255*(0.392+0.608*flag));% =100 for flag=0 (vectors not computed when 20<imflag<200) |
---|
1456 | imflag=flipdim(imflag,1); |
---|
1457 | |
---|
1458 | %display the mask |
---|
1459 | hfigmask=figure; |
---|
1460 | set(hfigmask,'Name','mask image') |
---|
1461 | vec=linspace(0,1,256);%define a linear greyscale colormap |
---|
1462 | map=[vec' vec' vec']; |
---|
1463 | colormap(map) |
---|
1464 | image(imflag); |
---|
1465 | answer=msgbox_uvmat('INPUT_TXT','mask file name:', mask_name); |
---|
1466 | if ~strcmp(answer,'Cancel') |
---|
1467 | mask_dir=fileparts(answer); |
---|
1468 | if ~exist(mask_dir,'dir') |
---|
1469 | [success,msg]=mkdir(mask_dir); |
---|
1470 | if success==0 |
---|
1471 | msgbox_uvmat('ERROR',['cannot create ' mask_dir ': ' msg]);%error message for directory creation |
---|
1472 | return |
---|
1473 | end |
---|
1474 | [success,msg] = fileattrib(mask_dir,'+w','g','s');% allow writing access for the group of users, recursively in the folder |
---|
1475 | if success==0 |
---|
1476 | msgbox_uvmat('WARNING',{['unable to set group write access to ' mask_dir ':']; msg});%error message for directory creation |
---|
1477 | end |
---|
1478 | end |
---|
1479 | imwrite(imflag,answer,'BitDepth',8); |
---|
1480 | end |
---|
1481 | set(handles.ListObject,'Value',1) |
---|
1482 | end |
---|
1483 | |
---|
1484 | %------------------------------------------------------------------------ |
---|
1485 | %-- open the GUI set_grid.fig to create grid |
---|
1486 | function MenuGrid_Callback(hObject, eventdata, handles) |
---|
1487 | %------------------------------------------------------------------------ |
---|
1488 | %suppress the other options if grid is chosen |
---|
1489 | set(handles.edit_vect,'Value',0) |
---|
1490 | edit_vect_Callback(hObject, eventdata, handles) |
---|
1491 | set(handles.ListObject,'Value',1) |
---|
1492 | |
---|
1493 | %prepare display of the set_grid GUI |
---|
1494 | [RootPath,SubDir,RootFile,FileIndex,FileExt]=read_file_boxes(handles); |
---|
1495 | FileName=[fullfile(RootPath,SubDir,RootFile) FileIndex FileExt]; |
---|
1496 | UvData=get(handles.uvmat,'UserData'); |
---|
1497 | % CoordList=get(handles.TransformName,'String'); |
---|
1498 | % val=get(handles.TransformName,'Value'); |
---|
1499 | set_grid(FileName,UvData.Field);% call the set_object interface |
---|
1500 | |
---|
1501 | |
---|
1502 | %------------------------------------------------------------------------ |
---|
1503 | function MenuRuler_Callback(hObject, eventdata, handles) |
---|
1504 | %------------------------------------------------------------------------ |
---|
1505 | if strcmp(get(handles.MenuRuler,'checked'),'on') |
---|
1506 | set(handles.MenuRuler,'checked','off')%desactivate if activated |
---|
1507 | else |
---|
1508 | set(handles.MenuRuler,'checked','on')%activate if selected |
---|
1509 | set(handles.CheckZoom,'Value',0) |
---|
1510 | CheckZoom_Callback(handles.uvmat, [], handles) |
---|
1511 | UvData=get(handles.uvmat,'UserData'); |
---|
1512 | UvData.MouseAction='ruler'; |
---|
1513 | set(handles.uvmat,'UserData',UvData); |
---|
1514 | end |
---|
1515 | |
---|
1516 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
---|
1517 | % MenuRun Callbacks |
---|
1518 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
---|
1519 | |
---|
1520 | %------------------------------------------------------------------------ |
---|
1521 | % open the GUI 'series' |
---|
1522 | function MenuSeries_Callback(hObject, eventdata, handles) |
---|
1523 | %------------------------------------------------------------------------ |
---|
1524 | Param=read_GUI(handles.uvmat); |
---|
1525 | Param.HiddenData=get(handles.uvmat,'UserData'); |
---|
1526 | series(Param); %run the series interface |
---|
1527 | |
---|
1528 | % -------------------------------------------------------------------- |
---|
1529 | function MenuPIV_Callback(hObject, eventdata, handles) |
---|
1530 | Param=read_GUI(handles.uvmat); |
---|
1531 | Param.HiddenData=get(handles.uvmat,'UserData'); |
---|
1532 | hseries=series(Param); |
---|
1533 | hhseries=guidata(hseries); |
---|
1534 | ActionMenu=get(hhseries.ActionName,'String'); |
---|
1535 | index_action=find(strcmp('civ_series',ActionMenu)); |
---|
1536 | set(hhseries.ActionName,'Value',index_action); |
---|
1537 | series('ActionName_Callback',hObject,eventdata,hhseries); %file input with xml reading in uvmat, show the image in phys coordinates |
---|
1538 | |
---|
1539 | %------------------------------------------------------------------------ |
---|
1540 | % -- open the GUI civ.fig for PIV |
---|
1541 | function MenuCIVx_Callback(hObject, eventdata, handles) |
---|
1542 | %------------------------------------------------------------------------ |
---|
1543 | [RootPath,SubDir,RootFile,FileIndex,FileExt]=read_file_boxes(handles); |
---|
1544 | FileName=[fullfile(RootPath,SubDir,RootFile) FileIndex FileExt]; |
---|
1545 | civ(FileName);% interface de civ(not in the uvmat file) |
---|
1546 | |
---|
1547 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
---|
1548 | % MenuHelp Callback |
---|
1549 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
---|
1550 | % -------------------------------------------------------------------- |
---|
1551 | function MenuHelp_Callback(hObject, eventdata, handles) |
---|
1552 | % -------------------------------------------------------------------- |
---|
1553 | web('http://servforge.legi.grenoble-inp.fr/projects/soft-uvmat/wiki/UvmatHelp') |
---|
1554 | |
---|
1555 | |
---|
1556 | |
---|
1557 | |
---|
1558 | |
---|
1559 | |
---|
1560 | |
---|
1561 | |
---|
1562 | |
---|
1563 | |
---|
1564 | %------------------------------------------------------------------------ |
---|
1565 | % --- Called by action in FileIndex edit box |
---|
1566 | function FileIndex_Callback(hObject, eventdata, handles) |
---|
1567 | %------------------------------------------------------------------------ |
---|
1568 | [tild,tild,tild,i1,i2,j1,j2]=fileparts_uvmat(get(handles.FileIndex,'String')); |
---|
1569 | set(handles.i1,'String',num2str(i1));%update the counters |
---|
1570 | set(handles.i2,'String',num2str(i2)); |
---|
1571 | set(handles.j1,'String',num2str(j1)); |
---|
1572 | set(handles.j2,'String',num2str(j2)); |
---|
1573 | |
---|
1574 | |
---|
1575 | %------------------------------------------------------------------------ |
---|
1576 | % --- Called by action in NomType edit box |
---|
1577 | function NomType_Callback(hObject, eventdata, handles) |
---|
1578 | %------------------------------------------------------------------------ |
---|
1579 | i1=str2num(get(handles.i1,'String')); |
---|
1580 | i2=str2num(get(handles.i2,'String')); |
---|
1581 | j1=str2num(get(handles.j1,'String')); |
---|
1582 | j2=str2num(get(handles.j2,'String')); |
---|
1583 | FileIndex=fullfile_uvmat('','','','',get(handles.NomType,'String'),i1,i2,j1,j2); |
---|
1584 | set(handles.FileIndex,'String',FileIndex) |
---|
1585 | % refresh the current settings and refresh the field view |
---|
1586 | RootPath_Callback(hObject,eventdata,handles) |
---|
1587 | |
---|
1588 | %------------------------------------------------------------------------ |
---|
1589 | % --- Called by action in NomType edit box |
---|
1590 | function NomType_1_Callback(hObject, eventdata, handles) |
---|
1591 | %------------------------------------------------------------------------ |
---|
1592 | i1=str2num(get(handles.i1,'String')); |
---|
1593 | i2=str2num(get(handles.i2,'String')); |
---|
1594 | j1=str2num(get(handles.j1,'String')); |
---|
1595 | j2=str2num(get(handles.j2,'String')); |
---|
1596 | FileIndex=fullfile_uvmat('','','','',get(handles.NomType_1,'String'),i1,i2,j1,j2); |
---|
1597 | set(handles.FileIndex_1,'String',FileIndex) |
---|
1598 | % inputfilerefresh the current settings and inputfilerefresh the field view |
---|
1599 | RootPath_1_Callback(hObject,eventdata,handles) |
---|
1600 | |
---|
1601 | %------------------------------------------------------------------------ |
---|
1602 | % --- Executes on button press in InputFileREFRESH. |
---|
1603 | function InputFileREFRESH_Callback(hObject, eventdata, handles) |
---|
1604 | %------------------------------------------------------------------------ |
---|
1605 | set(handles.InputFileREFRESH,'BackgroundColor',[1 1 0])% set button color to yellow to indicate that refresh is under action |
---|
1606 | set(handles.uvmat,'Pointer','watch') % set the mouse pointer to 'watch' |
---|
1607 | drawnow |
---|
1608 | % read the current input file name: |
---|
1609 | [RootPath,SubDir,RootFile,FileIndices,FileExt]=read_file_boxes(handles); |
---|
1610 | % detect the file type, get the movie object if relevant, and look for the corresponding file series: |
---|
1611 | [RootPath,SubDir,RootFile,i1_series,i2_series,j1_series,j2_series,tild,FileInfo,MovieObject]=find_file_series(fullfile(RootPath,SubDir),[RootFile FileIndices FileExt]); |
---|
1612 | if isempty(i1_series) |
---|
1613 | fileinput=uigetfile_uvmat('pick an input file',fullfile(RootPath,SubDir)); |
---|
1614 | hh=dir(fileinput); |
---|
1615 | if numel(hh)>1 |
---|
1616 | msgbox_uvmat('ERROR','invalid input, probably a broken link'); |
---|
1617 | else |
---|
1618 | %% display the selected field and related information |
---|
1619 | if isempty(fileinput) |
---|
1620 | errormsg='aborted'; |
---|
1621 | else |
---|
1622 | display_file_name(handles,fileinput,1) |
---|
1623 | end |
---|
1624 | end |
---|
1625 | else |
---|
1626 | % initiate the input file series and refresh the current field view: |
---|
1627 | errormsg=update_rootinfo(handles,i1_series,i2_series,j1_series,j2_series,FileInfo,MovieObject,1); |
---|
1628 | end |
---|
1629 | |
---|
1630 | %% refresh the second series if relevant |
---|
1631 | if ~isempty(errormsg) && get(handles.SubField,'Value') |
---|
1632 | [RootPath,SubDir,RootFile,FileIndices,FileExt]=read_file_boxes_1(handles); |
---|
1633 | % detect the file type, get the movie object if relevant, and look for the corresponding file series: |
---|
1634 | [RootPath,SubDir,RootFile,i1_series,i2_series,j1_series,j2_series,tild,FileInfo,MovieObject]=find_file_series(fullfile(RootPath,SubDir),[RootFile FileIndices FileExt]); |
---|
1635 | if isempty(i1_series) |
---|
1636 | fileinput=uigetfile_uvmat('pick an input file for the second line',fullfile(RootPath,SubDir)); |
---|
1637 | hh=dir(fileinput); |
---|
1638 | if numel(hh)>1 |
---|
1639 | msgbox_uvmat('ERROR','invalid input, probably a broken link'); |
---|
1640 | else |
---|
1641 | %% display the selected field and related information |
---|
1642 | if isempty(fileinput) |
---|
1643 | errormsg='aborted'; |
---|
1644 | else |
---|
1645 | display_file_name(handles,fileinput,2) |
---|
1646 | end |
---|
1647 | end |
---|
1648 | else |
---|
1649 | % initiate the input file series and inputfilerefresh the current field view: |
---|
1650 | errormsg=update_rootinfo(handles,i1_series,i2_series,j1_series,j2_series,FileInfo,MovieObject,2); |
---|
1651 | end |
---|
1652 | end |
---|
1653 | if ~isempty(errormsg) |
---|
1654 | set(handles.InputFileREFRESH,'BackgroundColor',[1 0 1])% put back button color to magenta, input not succesfull |
---|
1655 | end |
---|
1656 | set(handles.uvmat,'Pointer','arrow')% set back the mouse pointer to arrow |
---|
1657 | |
---|
1658 | %------------------------------------------------------------------------ |
---|
1659 | % --- Fills the edit boxes RootPath, RootFile,NomType...from an input file name 'fileinput' |
---|
1660 | function errormsg=display_file_name(handles,fileinput,index) |
---|
1661 | %------------------------------------------------------------------------ |
---|
1662 | %% look for the input file existence |
---|
1663 | errormsg='';%default |
---|
1664 | if ~exist(fileinput,'file') |
---|
1665 | errormsg=['input file ' fileinput ' does not exist']; |
---|
1666 | msgbox_uvmat('ERROR',errormsg) |
---|
1667 | return |
---|
1668 | end |
---|
1669 | |
---|
1670 | %% define the relevant handles for the first field series (index=1) or the second file series (index=2) |
---|
1671 | if ~exist('index','var') |
---|
1672 | index=1; |
---|
1673 | end |
---|
1674 | if index==1 |
---|
1675 | handles_RootPath=handles.RootPath; |
---|
1676 | handles_SubDir=handles.SubDir; |
---|
1677 | handles_RootFile=handles.RootFile; |
---|
1678 | handles_FileIndex=handles.FileIndex; |
---|
1679 | handles_NomType=handles.NomType; |
---|
1680 | handles_FileExt=handles.FileExt; |
---|
1681 | elseif index==2 |
---|
1682 | handles_RootPath=handles.RootPath_1; |
---|
1683 | handles_SubDir=handles.SubDir_1; |
---|
1684 | handles_RootFile=handles.RootFile_1; |
---|
1685 | handles_FileIndex=handles.FileIndex_1; |
---|
1686 | handles_NomType=handles.NomType_1; |
---|
1687 | handles_FileExt=handles.FileExt_1; |
---|
1688 | set(handles.RootPath_1,'Visible','on') |
---|
1689 | set(handles.RootFile_1,'Visible','on') |
---|
1690 | set(handles.SubDir_1,'Visible','on'); |
---|
1691 | set(handles.FileIndex_1,'Visible','on'); |
---|
1692 | set(handles.FileExt_1,'Visible','on'); |
---|
1693 | set(handles.NomType_1,'Visible','on'); |
---|
1694 | set(handles.TimeName_1,'Visible','on') |
---|
1695 | set(handles.TimeValue_1,'Visible','on') |
---|
1696 | end |
---|
1697 | set(handles.InputFileREFRESH,'BackgroundColor',[1 1 0])% paint REFRESH button to yellow to visualise root file input |
---|
1698 | set(handles.uvmat,'Pointer','watch') % set the mouse pointer to 'watch' |
---|
1699 | drawnow |
---|
1700 | |
---|
1701 | %% detect root name, nomenclature and indices in the input file name: |
---|
1702 | [FilePath,FileName,FileExt]=fileparts(fileinput); |
---|
1703 | % detect the file type, get the movie object if relevant, and look for the corresponding file series: |
---|
1704 | % the root name and indices may be corrected by including the first index i1 if a corresponding xml file exists |
---|
1705 | [RootPath,SubDir,RootFile,i1_series,i2_series,j1_series,j2_series,NomType,FileInfo,MovieObject,i1,i2,j1,j2]=find_file_series(FilePath,[FileName FileExt]); |
---|
1706 | FileType=FileInfo.FileType; |
---|
1707 | if strcmp(FileType,'txt') |
---|
1708 | try |
---|
1709 | edit(fileinput) |
---|
1710 | catch ME |
---|
1711 | msgbox_uvmat('ERROR','invalid intput file') |
---|
1712 | end |
---|
1713 | return |
---|
1714 | elseif strcmp(FileType,'xml') |
---|
1715 | editxml(fileinput) |
---|
1716 | return |
---|
1717 | elseif strcmp(FileType,'figure') |
---|
1718 | open(fileinput) |
---|
1719 | return |
---|
1720 | end |
---|
1721 | |
---|
1722 | %% open the file or fill the GUI uvmat according to the detected file type |
---|
1723 | switch FileType |
---|
1724 | case '' |
---|
1725 | msgbox_uvmat('ERROR','invalid input file type') |
---|
1726 | case 'txt' |
---|
1727 | edit(fileinput) |
---|
1728 | case 'figure' %display matlab figure |
---|
1729 | hfig=open(fileinput); |
---|
1730 | set(hfig,'WindowButtonMotionFcn','mouse_motion')%set mouse action functio |
---|
1731 | set(hfig,'WindowButtonUpFcn','mouse_up')%set mouse click action function |
---|
1732 | set(hfig,'WindowButtonUpFcn','mouse_down')%set mouse click action function |
---|
1733 | case 'xml' % edit xml files |
---|
1734 | t=xmltree(fileinput); |
---|
1735 | % the xml file marks a project or project link, open datatree_browser |
---|
1736 | if strcmp(get(t,1,'name'),'Project')&& exist(regexprep(fileinput,'.xml$',''),'dir') |
---|
1737 | datatree_browser(fileinput) |
---|
1738 | else % other xml file, open the xml editor |
---|
1739 | editxml(fileinput); |
---|
1740 | end |
---|
1741 | case 'xls'% Excel file opended by editxml |
---|
1742 | editxml(fileinput); |
---|
1743 | otherwise |
---|
1744 | set(handles_RootPath,'String',RootPath); |
---|
1745 | rootname=fullfile(RootPath,SubDir,RootFile); |
---|
1746 | set(handles_SubDir,'String',['/' SubDir]); |
---|
1747 | set(handles_RootFile,'String',['/' RootFile]); %display the separator |
---|
1748 | indices=fileinput(length(rootname)+1:end); |
---|
1749 | indices(end-length(FileExt)+1:end)=[]; %remove extension |
---|
1750 | set(handles_FileIndex,'String',indices); |
---|
1751 | set(handles_NomType,'String',NomType); |
---|
1752 | set(handles_FileExt,'String',FileExt); |
---|
1753 | if index==1 |
---|
1754 | % fill file index counters if the first file series is opened |
---|
1755 | set(handles.i1,'String',num2str(i1)); |
---|
1756 | set(handles.i2,'String',num2str(i2)); |
---|
1757 | set(handles.j1,'String',num2stra(j1,NomType)); |
---|
1758 | set(handles.j2,'String',num2stra(j2,NomType)); |
---|
1759 | else %read the current field index to synchronise with the first series |
---|
1760 | i1_s=str2num(get(handles.i1,'String')); |
---|
1761 | i2_0=str2num(get(handles.i2,'String')); |
---|
1762 | if ~isempty(i2_0) |
---|
1763 | i2_s=i2_0; |
---|
1764 | else |
---|
1765 | i2_s=i2; |
---|
1766 | end |
---|
1767 | j1_0=stra2num(get(handles.j1,'String')); |
---|
1768 | if ~isempty(j1_0) |
---|
1769 | j1_s=j1_0; |
---|
1770 | else |
---|
1771 | j1_s=j1; |
---|
1772 | end |
---|
1773 | j2_0=stra2num(get(handles.j2,'String')); |
---|
1774 | if ~isempty(j2_0) |
---|
1775 | j2_s=j2_0; |
---|
1776 | else |
---|
1777 | j2_s=j2; |
---|
1778 | end |
---|
1779 | end |
---|
1780 | |
---|
1781 | % synchronise indices of the second input file if it exists |
---|
1782 | if get(handles.SubField,'Value')==1% if the subfield button is activated, update the field numbers |
---|
1783 | Input=read_GUI(handles.InputFile); |
---|
1784 | if ~isfield(Input,'RootPath_1')||strcmp(Input.RootPath_1,'"') |
---|
1785 | Input.RootPath_1=Input.RootPath; |
---|
1786 | end |
---|
1787 | if ~isfield(Input,'SubDir_1')||strcmp(Input.SubDir_1,'"') |
---|
1788 | Input.SubDir_1=Input.SubDir; |
---|
1789 | end |
---|
1790 | if ~isfield(Input,'RootFile_1')||strcmp(Input.RootFile_1,'"') |
---|
1791 | Input.RootFile_1=Input.RootFile; |
---|
1792 | end |
---|
1793 | if ~isfield(Input,'FileExt_1')||strcmp(Input.FileExt_1,'"') |
---|
1794 | Input.FileExt_1=Input.FileExt; |
---|
1795 | end |
---|
1796 | if ~isfield(Input,'NomType_1')||strcmp(Input.NomType_1,'"') |
---|
1797 | Input.NomType_1=Input.NomType; |
---|
1798 | end |
---|
1799 | %updtate the indices of the second field series to correspond to the newly opened one |
---|
1800 | 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); |
---|
1801 | if exist(FileName_1,'file') |
---|
1802 | FileIndex_1=fullfile_uvmat('','','','',Input.NomType_1,i1_s,i2_s,j1_s,j2_s); |
---|
1803 | else |
---|
1804 | FileIndex_1=fullfile_uvmat('','','','',Input.NomType_1,i1,i2,j1,j2); |
---|
1805 | msgbox_uvmat('WARNING','unable to synchronise the indices of the two series') |
---|
1806 | end |
---|
1807 | set(handles.FileIndex_1,'String',FileIndex_1) |
---|
1808 | end |
---|
1809 | |
---|
1810 | %enable other menus |
---|
1811 | set(handles.MenuOpenCampaign,'Enable','on') |
---|
1812 | set(handles.MenuExport,'Enable','on') |
---|
1813 | set(handles.MenuExportFigure,'Enable','on') |
---|
1814 | set(handles.MenuExportMovie,'Enable','on') |
---|
1815 | set(handles.MenuTools,'Enable','on') |
---|
1816 | |
---|
1817 | % initiate input file series and inputfilerefresh the current field view: |
---|
1818 | update_rootinfo(handles,i1_series,i2_series,j1_series,j2_series,FileInfo,MovieObject,index); |
---|
1819 | |
---|
1820 | end |
---|
1821 | |
---|
1822 | %% update list of recent files in the menubar and save it for future opening |
---|
1823 | MenuFile=[{get(handles.MenuFile_1,'Label')};{get(handles.MenuFile_2,'Label')};... |
---|
1824 | {get(handles.MenuFile_3,'Label')};{get(handles.MenuFile_4,'Label')};{get(handles.MenuFile_5,'Label')}]; |
---|
1825 | str_find=strcmp(fileinput,MenuFile); |
---|
1826 | if isempty(find(str_find,1)) |
---|
1827 | MenuFile=[{fileinput};MenuFile];%insert the current file if not already in the list |
---|
1828 | end |
---|
1829 | for ifile=1:min(length(MenuFile),5) |
---|
1830 | set(handles.(['MenuFile_' num2str(ifile)]),'Label',MenuFile{ifile}); |
---|
1831 | %set(handles.(['MenuFile_' num2str(ifile) '_1']),'Label',MenuFile{ifile}); |
---|
1832 | end |
---|
1833 | dir_perso=prefdir; |
---|
1834 | profil_perso=fullfile(dir_perso,'uvmat_perso.mat'); |
---|
1835 | if exist(profil_perso,'file') |
---|
1836 | save (profil_perso,'MenuFile','RootPath','-append'); %store the file names for future opening of uvmat |
---|
1837 | else |
---|
1838 | save (profil_perso,'MenuFile','RootPath','-V6'); %store the file names for future opening of uvmat |
---|
1839 | end |
---|
1840 | |
---|
1841 | set(handles.InputFileREFRESH,'BackgroundColor',[1 0 0])% paint back button to red to indicate update is finished |
---|
1842 | set(handles.uvmat,'Pointer','arrow')% set back the mouse pointer to arrow |
---|
1843 | |
---|
1844 | |
---|
1845 | %------------------------------------------------------------------------ |
---|
1846 | % --- Update information about a new field series (indices to scan, timing, |
---|
1847 | % calibration from an xml file, then inputfilerefresh current plots |
---|
1848 | function errormsg=update_rootinfo(handles,i1_series,i2_series,j1_series,j2_series,FileInfo,VideoObject,index) |
---|
1849 | %------------------------------------------------------------------------ |
---|
1850 | errormsg=''; %default error msg |
---|
1851 | |
---|
1852 | %% define the relevant handles depending on the index (1=first file series, 2= second file series) |
---|
1853 | if ~exist('index','var') |
---|
1854 | index=1; |
---|
1855 | end |
---|
1856 | if index==1 |
---|
1857 | handles_Fields=handles.FieldName; |
---|
1858 | elseif index==2 |
---|
1859 | handles_Fields=handles.FieldName_1; |
---|
1860 | end |
---|
1861 | set(handles.FixVelType,'Value',0); %desactivate fixed veltype by default |
---|
1862 | |
---|
1863 | %% record info in UserData of the figure uvmat |
---|
1864 | UvData=get(handles.uvmat,'UserData');%huvmat=handles of the uvmat interface |
---|
1865 | UvData.NewSeries=1; %flag for REFRESH: begin a new series |
---|
1866 | UvData.FileName_1='';% name of the current second field (used to detect a constant field during file scanning) |
---|
1867 | UvData.FileType{index}=FileInfo.FileType; |
---|
1868 | UvData.FileInfo{index}=FileInfo; |
---|
1869 | UvData.MovieObject{index}=VideoObject; |
---|
1870 | UvData.i1_series{index}=i1_series; |
---|
1871 | UvData.i2_series{index}=i2_series; |
---|
1872 | UvData.j1_series{index}=j1_series; |
---|
1873 | UvData.j2_series{index}=j2_series; |
---|
1874 | |
---|
1875 | %% read timing and total frame number from the current file (e.g. movie files) |
---|
1876 | TimeUnit='';%default |
---|
1877 | TimeName='';%default |
---|
1878 | XmlData.Time=[];%default |
---|
1879 | ColorType='falsecolor'; %default |
---|
1880 | if isfield(FileInfo,'FrameRate')% frame rate given in the file (case of video data) |
---|
1881 | TimeUnit='s'; |
---|
1882 | if isempty(j1_series); %frame index along i |
---|
1883 | XmlData.Time=zeros(FileInfo.NumberOfFrames+1,2); |
---|
1884 | XmlData.Time(:,2)=(0:1/FileInfo.FrameRate:(FileInfo.NumberOfFrames)/FileInfo.FrameRate)'; |
---|
1885 | else |
---|
1886 | XmlData.Time=[0;ones(size(i1_series,3)-1,1)]*(0:1/FileInfo.FrameRate:(FileInfo.NumberOfFrames)/FileInfo.FrameRate); |
---|
1887 | end |
---|
1888 | if strcmp(FileInfo.FileType,'rdvision') |
---|
1889 | TimeName='timestamp'; |
---|
1890 | else |
---|
1891 | TimeName='video'; |
---|
1892 | end |
---|
1893 | end |
---|
1894 | if isfield(FileInfo,'ColorType') |
---|
1895 | ColorType=FileInfo.ColorType;%='truecolor' for color images |
---|
1896 | end |
---|
1897 | set(handles.CheckBW,'Value',strcmp(ColorType,'grayscale'))% select handles.CheckBW if grayscale image |
---|
1898 | |
---|
1899 | %% read parameters (time, geometric calibration..) from a documentation file (.xml advised) |
---|
1900 | XmlData.GeometryCalib=[];%default |
---|
1901 | if index==1 |
---|
1902 | [RootPath,SubDir,RootFile,FileIndices,FileExt]=read_file_boxes(handles); |
---|
1903 | else |
---|
1904 | [RootPath,SubDir,RootFile,FileIndices,FileExt]=read_file_boxes_1(handles); |
---|
1905 | end |
---|
1906 | XmlFileName=find_imadoc(RootPath,SubDir,RootFile,FileExt); |
---|
1907 | [tild,tild,DocExt]=fileparts(XmlFileName); |
---|
1908 | warntext='';%default warning message |
---|
1909 | NbSlice=1;%default |
---|
1910 | ImaDoc_str=''; |
---|
1911 | if ~isempty(XmlFileName) |
---|
1912 | set(handles.view_xml,'Visible','on') |
---|
1913 | set(handles.view_xml,'BackgroundColor',[1 1 0])% paint to yellow color to indicate reading of the xml file |
---|
1914 | set(handles.view_xml,'String','view .xml') |
---|
1915 | drawnow |
---|
1916 | [XmlDataRead,warntext]=imadoc2struct(XmlFileName); |
---|
1917 | if ~isempty(warntext) |
---|
1918 | msgbox_uvmat('WARNING',warntext) |
---|
1919 | end |
---|
1920 | if ~isempty(XmlDataRead) |
---|
1921 | ImaDoc_str=['view ' DocExt]; % DocExt= '.xml' or .civ (obsolete case) |
---|
1922 | if isfield(XmlDataRead,'TimeUnit')&& ~isempty(XmlDataRead.TimeUnit) |
---|
1923 | TimeUnit=XmlDataRead.TimeUnit; |
---|
1924 | end |
---|
1925 | if isfield(XmlDataRead,'Time')&& ~isempty(XmlDataRead.Time) |
---|
1926 | XmlData.Time=XmlDataRead.Time; |
---|
1927 | end |
---|
1928 | set(handles.view_xml,'BackgroundColor',[1 1 1])% paint back to white |
---|
1929 | drawnow |
---|
1930 | if isfield(XmlDataRead, 'GeometryCalib') && ~isempty(XmlDataRead.GeometryCalib) |
---|
1931 | XmlData.GeometryCalib=XmlDataRead.GeometryCalib; |
---|
1932 | if isfield(XmlData.GeometryCalib,'CheckVolumeScan') && isequal(XmlData.GeometryCalib.CheckVolumeScan,1) |
---|
1933 | set (handles.slices,'String','volume') |
---|
1934 | end |
---|
1935 | % check whether the GUI geometry_calib is opened |
---|
1936 | hgeometry_calib=findobj('tag','geometry_calib'); |
---|
1937 | if ~isempty(hgeometry_calib) % check whether the display of the GUI geometry_calib is consistent with the current calib param |
---|
1938 | GUserData=get(hgeometry_calib,'UserData'); |
---|
1939 | if ~(isfield(GUserData,'XmlInputFile') && strcmp(GUserData.XmlInputFile,XmlFileName)) |
---|
1940 | answer=msgbox_uvmat('INPUT_Y-N','refresh the display of the GUI geometry_calib with the new input data?'); |
---|
1941 | if strcmp(answer,'Yes') |
---|
1942 | geometry_calib(XmlFileName);%diplay the new calibration points and parameters in geometry_calib |
---|
1943 | end |
---|
1944 | end |
---|
1945 | end |
---|
1946 | end |
---|
1947 | end |
---|
1948 | end |
---|
1949 | if isempty(ImaDoc_str) |
---|
1950 | set(handles.view_xml,'Visible','off') % no .xml (or .civ) file detected |
---|
1951 | else |
---|
1952 | set(handles.view_xml,'String',ImaDoc_str)% indicate that a xml file has been detected |
---|
1953 | end |
---|
1954 | |
---|
1955 | %% Define timing |
---|
1956 | % time not set by the input file: images or civ data: indicate that time is read from the xml file |
---|
1957 | FileType=FileInfo.FileType; |
---|
1958 | if isfield(XmlData,'Time')&& ~isempty(XmlData.Time) && ... |
---|
1959 | (strcmp(FileType,'image')|| strcmp(FileType,'multimage'))%||strcmp(FileType,'civdata')||strcmp(FileType,'civx')) |
---|
1960 | TimeName='xml'; |
---|
1961 | elseif strcmp(FileType,'civdata') |
---|
1962 | TimeName='civdata'; |
---|
1963 | elseif strcmp(FileType,'civx') |
---|
1964 | TimeName='civx'; |
---|
1965 | end |
---|
1966 | if index==1 |
---|
1967 | set(handles.TimeName,'String',TimeName) |
---|
1968 | else |
---|
1969 | set(handles.TimeName_1,'String',TimeName) |
---|
1970 | set(handles.TimeName_1,'Visible','on') |
---|
1971 | end |
---|
1972 | |
---|
1973 | %% store last index in handles.MaxIndex_i and .MaxIndex_j |
---|
1974 | nbfield=max(max(max(i2_series))); |
---|
1975 | if isempty(nbfield) |
---|
1976 | nbfield=max(max(max(i1_series))); |
---|
1977 | end |
---|
1978 | nbfield_j=max(max(max(j2_series))); |
---|
1979 | if isempty(nbfield_j) |
---|
1980 | nbfield_j=max(max(max(j1_series))); |
---|
1981 | end |
---|
1982 | if isfield(XmlData,'Time')&& ~isempty(XmlData.Time) |
---|
1983 | %transform .Time to a column vector if it is a line vector the nomenclature uses a single index |
---|
1984 | if isequal(size(XmlData.Time,1),1) |
---|
1985 | XmlData.Time=(XmlData.Time)'; |
---|
1986 | end |
---|
1987 | end |
---|
1988 | last_i_cell=get(handles.MaxIndex_i,'String'); |
---|
1989 | if isempty(nbfield) |
---|
1990 | last_i_cell{index}=''; |
---|
1991 | else |
---|
1992 | last_i_cell{index}=num2str(nbfield); |
---|
1993 | end |
---|
1994 | set(handles.MaxIndex_i,'String',last_i_cell) |
---|
1995 | last_j_cell=get(handles.MaxIndex_j,'String'); |
---|
1996 | if isempty(nbfield_j) |
---|
1997 | last_j_cell{index}=''; |
---|
1998 | else |
---|
1999 | last_j_cell{index}=num2str(nbfield_j); |
---|
2000 | end |
---|
2001 | set(handles.MaxIndex_j,'String',last_j_cell); |
---|
2002 | |
---|
2003 | %% store geometric calibration in UvData |
---|
2004 | if isfield(XmlData,'GeometryCalib') |
---|
2005 | GeometryCalib=XmlData.GeometryCalib; |
---|
2006 | if isempty(GeometryCalib) |
---|
2007 | set(handles.pxcmx,'String','') |
---|
2008 | set(handles.pxcmy,'String','') |
---|
2009 | set(handles.pxcmx,'Visible','off') |
---|
2010 | set(handles.pxcmy,'Visible','off') |
---|
2011 | set(handles.TransformName,'Value',1); % no transform by default |
---|
2012 | else |
---|
2013 | set(handles.pxcmx,'Visible','on') |
---|
2014 | set(handles.pxcmy,'Visible','on') |
---|
2015 | if (isfield(GeometryCalib,'R')&& ~isequal(GeometryCalib.R(2,1),0) && ~isequal(GeometryCalib.R(1,2),0)) ||... |
---|
2016 | (isfield(GeometryCalib,'kappa1')&& ~isequal(GeometryCalib.kappa1,0)) |
---|
2017 | set(handles.pxcmx,'String','var') |
---|
2018 | set(handles.pxcmy,'String','var') |
---|
2019 | elseif isfield(GeometryCalib,'fx_fy') |
---|
2020 | pixcmx=GeometryCalib.fx_fy(1);%*GeometryCalib.R(1,1)*GeometryCalib.sx/(GeometryCalib.Tz*GeometryCalib.dpx); |
---|
2021 | pixcmy=GeometryCalib.fx_fy(2);%*GeometryCalib.R(2,2)/(GeometryCalib.Tz*GeometryCalib.dpy); |
---|
2022 | set(handles.pxcmx,'String',num2str(pixcmx)) |
---|
2023 | set(handles.pxcmy,'String',num2str(pixcmy)) |
---|
2024 | end |
---|
2025 | if ~get(handles.CheckFixLimits,'Value') |
---|
2026 | set(handles.TransformName,'Value',3); % phys transform by default if fixedLimits is off |
---|
2027 | end |
---|
2028 | if isfield(GeometryCalib,'SliceCoord') |
---|
2029 | siz=size(GeometryCalib.SliceCoord); |
---|
2030 | if siz(1)>1 |
---|
2031 | NbSlice=siz(1); |
---|
2032 | set(handles.slices,'Visible','on') |
---|
2033 | set(handles.slices,'Value',1) |
---|
2034 | end |
---|
2035 | if isfield(GeometryCalib,'CheckVolumeScan') && isequal(GeometryCalib.CheckVolumeScan,1) |
---|
2036 | set(handles.num_NbSlice,'Visible','off') |
---|
2037 | else |
---|
2038 | set(handles.num_NbSlice,'Visible','on') |
---|
2039 | set(handles.num_NbSlice,'String',num2str(NbSlice)) |
---|
2040 | end |
---|
2041 | slices_Callback([],[], handles) |
---|
2042 | end |
---|
2043 | end |
---|
2044 | end |
---|
2045 | |
---|
2046 | %% update the data attached to the uvmat interface |
---|
2047 | if ~isempty(TimeUnit) |
---|
2048 | if index==2 && isfield(UvData,'TimeUnit') && ~strcmp(UvData.TimeUnit,TimeUnit) |
---|
2049 | msgbox_uvmat('WARNING',['time unit for second file series ' TimeUnit ' inconsistent with first series']) |
---|
2050 | else |
---|
2051 | UvData.TimeUnit=TimeUnit; |
---|
2052 | end |
---|
2053 | end |
---|
2054 | UvData.XmlData{index}=XmlData; |
---|
2055 | UvData.NewSeries=1; |
---|
2056 | |
---|
2057 | %display warning message |
---|
2058 | if ~isequal(warntext,'') |
---|
2059 | msgbox_uvmat('WARNING',warntext); |
---|
2060 | end |
---|
2061 | |
---|
2062 | %% set default options in menu 'FieldName' |
---|
2063 | switch FileType |
---|
2064 | case {'civx','civdata'} |
---|
2065 | [FieldList,ColorList]=set_field_list('U','V','C'); |
---|
2066 | set(handles_Fields,'String',[{'image'};FieldList;{'get_field...'}]);%standard menu for civx data |
---|
2067 | set(handles_Fields,'Value',2) % set menu to 'velocity |
---|
2068 | if index==1 |
---|
2069 | set(handles.FieldName_1,'Value',1); |
---|
2070 | set(handles.FieldName_1,'String',[{''};{'image'};FieldList;{'get_field...'}]);%standard menu for civx data reproduced for the second field |
---|
2071 | end |
---|
2072 | set(handles.ColorScalar,'Value',1) |
---|
2073 | set(handles.ColorScalar,'String',ColorList) |
---|
2074 | set(handles.Vectors,'Visible','on') |
---|
2075 | %set(handles.Coord_x,'Value',1); |
---|
2076 | set(handles.Coord_x,'String','X'); |
---|
2077 | set(handles.Coord_y,'String','Y'); |
---|
2078 | case 'netcdf' |
---|
2079 | set(handles_Fields,'Value',1) |
---|
2080 | set(handles_Fields,'String',{'get_field...'}) |
---|
2081 | if index==1 |
---|
2082 | FieldName_Callback([],[], handles) |
---|
2083 | else |
---|
2084 | FieldName_1_Callback([],[], handles) |
---|
2085 | end |
---|
2086 | otherwise |
---|
2087 | set(handles_Fields,'Value',1) % set menu to 'image' |
---|
2088 | set(handles_Fields,'String',{'image'}) |
---|
2089 | %set(handles.Coord_x,'Value',1); |
---|
2090 | set(handles.Coord_x,'String','Coord_x'); |
---|
2091 | set(handles.Coord_y,'String','Coord_y'); |
---|
2092 | end |
---|
2093 | set(handles.uvmat,'UserData',UvData) |
---|
2094 | |
---|
2095 | %% set index navigation options |
---|
2096 | scan_option='i';%default |
---|
2097 | state_j='off'; %default |
---|
2098 | if index==2 |
---|
2099 | if get(handles.scan_j,'Value') |
---|
2100 | scan_option='j'; %keep the scan option for the second file series |
---|
2101 | end |
---|
2102 | if strcmp(get(handles.j1,'Visible'),'on') |
---|
2103 | state_j='on'; |
---|
2104 | end |
---|
2105 | end |
---|
2106 | [ref_j,ref_i]=find(squeeze(i1_series(1,:,:))); |
---|
2107 | if ~isempty(j1_series) |
---|
2108 | state_j='on'; |
---|
2109 | if index==1 |
---|
2110 | if isequal(ref_i,ref_i(1)*ones(size(ref_j)))% if ref_i is always equal to its first value |
---|
2111 | scan_option='j'; %scan j indext |
---|
2112 | end |
---|
2113 | end |
---|
2114 | end |
---|
2115 | if isequal(scan_option,'i') |
---|
2116 | diff_ref_i=diff(ref_i,1); |
---|
2117 | if isempty(diff_ref_i) |
---|
2118 | diff_ref_i=1; |
---|
2119 | end |
---|
2120 | if isequal (diff_ref_i,diff_ref_i(1)*ones(size(diff_ref_i))) |
---|
2121 | set(handles.num_IndexIncrement,'String',num2str(diff_ref_i(1))) |
---|
2122 | end |
---|
2123 | set(handles.scan_i,'Value',1) |
---|
2124 | scan_i_Callback([],[], handles); |
---|
2125 | else |
---|
2126 | diff_ref_j=diff(ref_j); |
---|
2127 | if isempty(diff_ref_j) |
---|
2128 | diff_ref_j=1; |
---|
2129 | end |
---|
2130 | if isequal (diff_ref_j,diff_ref_j(1)*ones(size(diff_ref_j))) |
---|
2131 | set(handles.num_IndexIncrement,'String',num2str(diff_ref_j(1))) |
---|
2132 | end |
---|
2133 | set(handles.scan_j,'Value',1) |
---|
2134 | scan_j_Callback([],[], handles); |
---|
2135 | end |
---|
2136 | set(handles.scan_j,'Visible',state_j) |
---|
2137 | set(handles.j1,'Visible',state_j) |
---|
2138 | set(handles.j2,'Visible',state_j) |
---|
2139 | set(handles.MaxIndex_j,'Visible',state_j); |
---|
2140 | set(handles.j_text,'Visible',state_j); |
---|
2141 | if ~isempty(i2_series)||~isempty(j2_series) |
---|
2142 | set(handles.CheckFixPair,'Visible','on') |
---|
2143 | elseif index==1 |
---|
2144 | set(handles.CheckFixPair,'Visible','off') |
---|
2145 | end |
---|
2146 | |
---|
2147 | %% apply the effect of the transform fct and view the field |
---|
2148 | transform=get(handles.TransformPath,'UserData'); |
---|
2149 | if index==2 && (~isa(transform,'function_handle')||nargin(transform)<3) |
---|
2150 | set(handles.TransformName,'value',2); % set transform to sub_field if the current fct doe not accept two input fields |
---|
2151 | end |
---|
2152 | set(handles.InputFileREFRESH,'BackgroundColor',[1 0 0])% set button color to red to indicate that refresh has been updated |
---|
2153 | TransformName_Callback([],[],handles)% callback for the selection of transform function, then refresh the current plot |
---|
2154 | mask_test=get(handles.CheckMask,'value'); |
---|
2155 | if mask_test |
---|
2156 | MaskData=get(handles.CheckMask,'UserData'); |
---|
2157 | if isfield(MaskData,'maskhandle') && ishandle(MaskData.maskhandle) |
---|
2158 | delete(MaskData.maskhandle) %delete old mask |
---|
2159 | end |
---|
2160 | CheckMask_Callback([],[],handles) |
---|
2161 | end |
---|
2162 | |
---|
2163 | %------------------------------------------------------------------------ |
---|
2164 | % --- switch file index scanning options scan_i and scan_j in an exclusive way |
---|
2165 | %------------------------------------------------------------------------ |
---|
2166 | function scan_i_Callback(hObject, eventdata, handles) |
---|
2167 | |
---|
2168 | if get(handles.scan_i,'Value')==1 |
---|
2169 | set(handles.scan_j,'Value',0) |
---|
2170 | else |
---|
2171 | set(handles.scan_j,'Value',1) |
---|
2172 | end |
---|
2173 | scan_j_Callback(hObject, eventdata, handles) |
---|
2174 | |
---|
2175 | %------------------------------------------------------------------------ |
---|
2176 | % --- switch file index scanning options scan_i and scan_j in an exclusive way |
---|
2177 | %------------------------------------------------------------------------ |
---|
2178 | function scan_j_Callback(hObject, eventdata, handles) |
---|
2179 | |
---|
2180 | if get(handles.scan_j,'Value')==1 |
---|
2181 | set(handles.scan_i,'Value',0) |
---|
2182 | else |
---|
2183 | set(handles.scan_i,'Value',1) |
---|
2184 | set(handles.CheckFixPair,'Visible','off') |
---|
2185 | end |
---|
2186 | |
---|
2187 | %------------------------------------------------------------------------ |
---|
2188 | function i1_Callback(hObject, eventdata, handles) |
---|
2189 | %------------------------------------------------------------------------ |
---|
2190 | update_ij(handles,1) |
---|
2191 | |
---|
2192 | %------------------------------------------------------------------------ |
---|
2193 | function i2_Callback(hObject, eventdata, handles) |
---|
2194 | %------------------------------------------------------------------------ |
---|
2195 | update_ij(handles,2) |
---|
2196 | |
---|
2197 | %------------------------------------------------------------------------ |
---|
2198 | function j1_Callback(hObject, eventdata, handles) |
---|
2199 | %------------------------------------------------------------------------ |
---|
2200 | update_ij(handles,3) |
---|
2201 | |
---|
2202 | %------------------------------------------------------------------------ |
---|
2203 | function j2_Callback(hObject, eventdata, handles) |
---|
2204 | %------------------------------------------------------------------------ |
---|
2205 | update_ij(handles,4) |
---|
2206 | |
---|
2207 | %------------------------------------------------------------------------ |
---|
2208 | %--- update the index display after action on edit boxes i1, i2, j1 or j2 |
---|
2209 | %------------------------------------------------------------------------ |
---|
2210 | function update_ij(handles,index_rank) |
---|
2211 | |
---|
2212 | NomType=get(handles.NomType,'String'); |
---|
2213 | indices=get(handles.FileIndex,'String'); |
---|
2214 | [tild,tild,tild,i1,i2,j1,j2]=fileparts_uvmat(indices);% the indices for the second series taken from FileIndex |
---|
2215 | switch index_rank |
---|
2216 | case 1 |
---|
2217 | indices=fullfile_uvmat('','','','',NomType,stra2num(get(handles.i1,'String')),i2,j1,j2); |
---|
2218 | % 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 |
---|
2219 | case 2 |
---|
2220 | indices=fullfile_uvmat('','','','',NomType,i1,stra2num(get(handles.i2,'String')),j1,j2); |
---|
2221 | % 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 |
---|
2222 | case 3 |
---|
2223 | indices=fullfile_uvmat('','','','',NomType,i1,i2,stra2num(get(handles.j1,'String')),j2); |
---|
2224 | % 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 |
---|
2225 | case 4 |
---|
2226 | indices=fullfile_uvmat('','','','',NomType,i1,i2,j1,stra2num(get(handles.j2,'String'))); |
---|
2227 | % 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 |
---|
2228 | end |
---|
2229 | set(handles.FileIndex,'String',indices) |
---|
2230 | %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 |
---|
2231 | % update the second index if relevant |
---|
2232 | if strcmp(get(handles.FileIndex_1,'Visible'),'on') |
---|
2233 | NomType_1=get(handles.NomType_1,'String'); |
---|
2234 | indices_1=get(handles.FileIndex_1,'String'); |
---|
2235 | [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 |
---|
2236 | switch index_rank |
---|
2237 | case 1 |
---|
2238 | indices_1=fullfile_uvmat('','','','',NomType_1,stra2num(get(handles.i1,'String')),i2_1,j1_1,j2_1); |
---|
2239 | case 2 |
---|
2240 | indices_1=fullfile_uvmat('','','','',NomType_1,i1_1,stra2num(get(handles.i2,'String')),j1_1,j2_1); |
---|
2241 | case 3 |
---|
2242 | indices_1=fullfile_uvmat('','','','',NomType_1,i1_1,i2_1,stra2num(get(handles.j1,'String')),j2_1); |
---|
2243 | case 4 |
---|
2244 | indices_1=fullfile_uvmat('','','','',NomType_1,i1_1,i2_1,j1_1,stra2num(get(handles.j2,'String'))); |
---|
2245 | end |
---|
2246 | set(handles.FileIndex_1,'String',indices_1) |
---|
2247 | 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 |
---|
2248 | end |
---|
2249 | |
---|
2250 | %------------------------------------------------------------------------ |
---|
2251 | |
---|
2252 | %------------------------------------------------------------------------ |
---|
2253 | function slices_Callback(hObject, eventdata, handles) |
---|
2254 | %------------------------------------------------------------------------ |
---|
2255 | if strcmp(get(handles.slices,'String'),'slices') |
---|
2256 | if get(handles.slices,'Value')==1 |
---|
2257 | set(handles.num_NbSlice,'Visible','on') |
---|
2258 | set(handles.z_text,'Visible','on') |
---|
2259 | set(handles.z_index,'Visible','on') |
---|
2260 | num_NbSlice_Callback(hObject, eventdata, handles) |
---|
2261 | else |
---|
2262 | set(handles.num_NbSlice,'Visible','off') |
---|
2263 | set(handles.z_text,'Visible','off') |
---|
2264 | set(handles.z_index,'Visible','off') |
---|
2265 | set(handles.masklevel,'Value',1) |
---|
2266 | set(handles.masklevel,'String',{'1'}) |
---|
2267 | end |
---|
2268 | end |
---|
2269 | |
---|
2270 | %------------------------------------------------------------------------ |
---|
2271 | function num_NbSlice_Callback(hObject, eventdata, handles) |
---|
2272 | %------------------------------------------------------------------------ |
---|
2273 | mode=get(handles.slices,'String'); |
---|
2274 | nb_slice_str=get(handles.num_NbSlice,'String'); |
---|
2275 | if strcmp(mode,'volume') |
---|
2276 | z=stra2num(get(handles.j1,'String')); |
---|
2277 | else |
---|
2278 | num=str2double(get(handles.i1,'String')); |
---|
2279 | nbslice=str2double(get(handles.num_NbSlice,'String')); |
---|
2280 | z=mod(num-1,nbslice)+1; |
---|
2281 | end |
---|
2282 | set(handles.z_index,'String',num2str(z)) |
---|
2283 | for ilist=1:nbslice |
---|
2284 | list_index{ilist,1}=num2str(ilist); |
---|
2285 | end |
---|
2286 | set(handles.masklevel,'String',list_index) |
---|
2287 | set(handles.masklevel,'Value',z) |
---|
2288 | |
---|
2289 | %------------------------------------------------------------------------ |
---|
2290 | % --- Executes on button press in view_xml. |
---|
2291 | %------------------------------------------------------------------------ |
---|
2292 | function view_xml_Callback(hObject, eventdata, handles) |
---|
2293 | |
---|
2294 | % if TimeName defined, open the xml file corresponding to the first file |
---|
2295 | % series, else open the xml file corresponding to the second series |
---|
2296 | if isempty(get(handles.TimeName,'String'))% open the xml file corresponding to the secodn file series |
---|
2297 | [RootPath,SubDir,RootFile,FileIndices,FileExt]=read_file_boxes_1(handles); |
---|
2298 | else |
---|
2299 | [RootPath,SubDir,RootFile,FileIndices,FileExt]=read_file_boxes(handles); |
---|
2300 | end |
---|
2301 | option=get(handles.view_xml,'String'); |
---|
2302 | if isequal(option,'view .xml') |
---|
2303 | FileXml=fullfile(RootPath,[SubDir '.xml']); |
---|
2304 | if ~exist(FileXml,'file')% case of civ files , removes the extension for subdir |
---|
2305 | FileXml=fullfile(RootPath,[regexprep(SubDir,'\..+$','') '.xml']); |
---|
2306 | end |
---|
2307 | heditxml=editxml(FileXml); |
---|
2308 | end |
---|
2309 | |
---|
2310 | %------------------------------------------------------------------------ |
---|
2311 | % --- Executes on button press in CheckMask. |
---|
2312 | function CheckMask_Callback(hObject, eventdata, handles) |
---|
2313 | %------------------------------------------------------------------------ |
---|
2314 | %case of view mask selection |
---|
2315 | if isequal(get(handles.CheckMask,'Value'),1) |
---|
2316 | [RootPath,SubDir]=read_file_boxes(handles); |
---|
2317 | MaskSubDir=regexprep(SubDir,'\..*','');%take the root part of SubDir, before the first dot '.' |
---|
2318 | MaskPath=fullfile(RootPath,[MaskSubDir '.mask']); |
---|
2319 | mdetect=0; |
---|
2320 | if exist(MaskPath,'dir') |
---|
2321 | ListStruct=dir(MaskPath);%look for a mask file |
---|
2322 | ListCells=struct2cell(ListStruct);% transform dir struct to a cell arrray |
---|
2323 | check_dir=cell2mat(ListCells(4,:));% =1 for directories, =0 for files |
---|
2324 | ListFiles=ListCells(1,:);%list of file and dri names |
---|
2325 | ListFiles=ListFiles(~check_dir);%list of file names (excluding dir) |
---|
2326 | if ~isempty(ListFiles) |
---|
2327 | for ifile=1:numel(ListFiles) |
---|
2328 | [tild,tild,MaskExt]=fileparts(ListFiles{1}); |
---|
2329 | [tild,tild,MaskFile{ifile},i1_series,i2_series,j1_series,j2_series,MaskNomType,MaskFileInfo]=find_file_series(MaskPath,ListFiles{ifile},0); |
---|
2330 | MaskFileType=MaskFileInfo.FileType; |
---|
2331 | if strcmp(MaskFileType,'image') && isempty(i2_series) && isempty(j2_series) |
---|
2332 | mdetect=1; |
---|
2333 | end |
---|
2334 | if ~strcmp(MaskFile{ifile},MaskFile{1}) |
---|
2335 | mdetect=0;% cancel detection test in case of multiple masks, use the brower for selection |
---|
2336 | break |
---|
2337 | end |
---|
2338 | end |
---|
2339 | end |
---|
2340 | RootPath=MaskPath; |
---|
2341 | end |
---|
2342 | if mdetect==0 |
---|
2343 | MaskFullName=uigetfile_uvmat('pick a mask image file:',RootPath,'image'); |
---|
2344 | if isempty(MaskFullName) |
---|
2345 | set(handles.CheckMask,'Value',0) |
---|
2346 | end |
---|
2347 | [MaskPath,MaskName,MaskExt]=fileparts(MaskFullName); |
---|
2348 | [tild,tild,MaskFile,i1_series,i2_series,j1_series,j2_series,MaskNomType]=find_file_series(MaskPath,[MaskName MaskExt],0); |
---|
2349 | if ~(isempty(i2_series) && isempty(j2_series)) |
---|
2350 | MaskNomType='*'; |
---|
2351 | end |
---|
2352 | end |
---|
2353 | Mask.Path=MaskPath; |
---|
2354 | if isempty(MaskFile) |
---|
2355 | Mask.File=''; |
---|
2356 | elseif ischar(MaskFile) |
---|
2357 | Mask.File=MaskFile; |
---|
2358 | else |
---|
2359 | Mask.File=MaskFile{1}; |
---|
2360 | end |
---|
2361 | Mask.Ext=MaskExt; |
---|
2362 | Mask.NomType=MaskNomType; |
---|
2363 | set(handles.CheckMask,'UserData',Mask); |
---|
2364 | errormsg=update_mask(handles); |
---|
2365 | else % desactivate mask display |
---|
2366 | MaskData=get(handles.CheckMask,'UserData'); |
---|
2367 | if isfield(MaskData,'maskhandle') && ishandle(MaskData.maskhandle) |
---|
2368 | delete(MaskData.maskhandle) |
---|
2369 | end |
---|
2370 | set(handles.CheckMask,'UserData',[]) |
---|
2371 | UvData=get(handles.uvmat,'UserData'); |
---|
2372 | if isfield(UvData,'MaskName') |
---|
2373 | UvData=rmfield(UvData,'MaskName'); |
---|
2374 | set(handles.uvmat,'UserData',UvData) |
---|
2375 | end |
---|
2376 | set(handles.CheckMask,'BackgroundColor',[0.7 0.7 0.7]) |
---|
2377 | end |
---|
2378 | |
---|
2379 | %------------------------------------------------------------------------ |
---|
2380 | function errormsg=update_mask(handles) |
---|
2381 | %------------------------------------------------------------------------ |
---|
2382 | errormsg=[];%default |
---|
2383 | Mask=get(handles.CheckMask,'UserData'); |
---|
2384 | MaskIndex=1; |
---|
2385 | if strcmp(get(handles.z_index,'Visible'),'on') |
---|
2386 | MaskIndex=str2num(get(handles.z_index,'String')); |
---|
2387 | end |
---|
2388 | if isfield(Mask,'maskhandle')&& ishandle(Mask.maskhandle) |
---|
2389 | uistack(Mask.maskhandle,'top'); |
---|
2390 | end |
---|
2391 | MaskName=fullfile_uvmat(Mask.Path,'',Mask.File,Mask.Ext,Mask.NomType,MaskIndex); |
---|
2392 | UvData=get(handles.uvmat,'UserData'); |
---|
2393 | |
---|
2394 | %% update mask image if the mask is new |
---|
2395 | if ~ (isfield(UvData,'MaskName') && isequal(UvData.MaskName,MaskName)) |
---|
2396 | UvData.MaskName=MaskName; %update the recorded name on UvData |
---|
2397 | set(handles.uvmat,'UserData',UvData); |
---|
2398 | if ~exist(MaskName,'file') |
---|
2399 | if isfield(Mask,'maskhandle')&& ishandle(Mask.maskhandle) |
---|
2400 | delete(Mask.maskhandle) |
---|
2401 | end |
---|
2402 | else |
---|
2403 | %read mask image |
---|
2404 | [MaskField,tild,errormsg] = read_field(MaskName,'image'); |
---|
2405 | if ~isempty(errormsg) |
---|
2406 | return |
---|
2407 | end |
---|
2408 | npxy=size(MaskField.A); |
---|
2409 | if length(npxy)>2 |
---|
2410 | errormsg=[MaskName ' is not a grey scale image']; |
---|
2411 | return |
---|
2412 | elseif ~isa(MaskField.A,'uint8') |
---|
2413 | errormsg=[MaskName ' is not a 8 bit grey level image']; |
---|
2414 | return |
---|
2415 | end |
---|
2416 | MaskField.ZIndex=MaskIndex; |
---|
2417 | %px to phys or other transform on field |
---|
2418 | menu_transform=get(handles.TransformName,'String'); |
---|
2419 | choice_value=get(handles.TransformName,'Value'); |
---|
2420 | transform_name=menu_transform{choice_value};%name of the transform fct given by the menu 'transform_fct' |
---|
2421 | transform=get(handles.TransformPath,'UserData'); |
---|
2422 | if ~isequal(transform_name,'') && ~isequal(transform_name,'px') |
---|
2423 | if isfield(UvData,'XmlData') && isfield(UvData.XmlData{1},'GeometryCalib')%use geometry calib recorded from the ImaDoc xml file as first priority |
---|
2424 | Calib=UvData.XmlData{1}.GeometryCalib; |
---|
2425 | MaskField=transform(MaskField,UvData.XmlData{1}); |
---|
2426 | end |
---|
2427 | end |
---|
2428 | flagmask=MaskField.A < 200; |
---|
2429 | |
---|
2430 | %make brown color image |
---|
2431 | imflag(:,:,1)=0.9*flagmask; |
---|
2432 | imflag(:,:,2)=0.7*flagmask; |
---|
2433 | imflag(:,:,3)=zeros(size(flagmask)); |
---|
2434 | |
---|
2435 | %update mask image |
---|
2436 | hmask=[]; %default |
---|
2437 | if isfield(Mask,'maskhandle')&& ishandle(Mask.maskhandle) |
---|
2438 | hmask=Mask.maskhandle; |
---|
2439 | end |
---|
2440 | if ~isempty(hmask) |
---|
2441 | set(hmask,'CData',imflag) |
---|
2442 | set(hmask,'AlphaData',flagmask*0.6) |
---|
2443 | set(hmask,'XData',MaskField.Coord_x); |
---|
2444 | set(hmask,'YData',MaskField.Coord_y); |
---|
2445 | % uistack(hmask,'top') |
---|
2446 | else |
---|
2447 | axes(handles.PlotAxes) |
---|
2448 | hold on |
---|
2449 | Mask.maskhandle=image(MaskField.Coord_x,MaskField.Coord_y,imflag,'Tag','mask','HitTest','off','AlphaData',0.6*ones(size(flagmask))); |
---|
2450 | set(handles.CheckMask,'UserData',Mask) |
---|
2451 | end |
---|
2452 | end |
---|
2453 | end |
---|
2454 | |
---|
2455 | %------------------------------------------------------------------------ |
---|
2456 | %------------------------------------------------------------------------ |
---|
2457 | % III - MAIN InputFileREFRESH FUNCTIONS : 'FRAME PLOT' |
---|
2458 | %------------------------------------------------------------------------ |
---|
2459 | |
---|
2460 | %------------------------------------------------------------------------ |
---|
2461 | % --- Executes on button press in runplus: make one step forward and call |
---|
2462 | % --- InputFileREFRESH. The step forward is along the fieldname series 1 or 2 depending on |
---|
2463 | % --- the scan_i and scan_j check box (exclusive each other) |
---|
2464 | function runplus_Callback(hObject, eventdata, handles) |
---|
2465 | %------------------------------------------------------------------------ |
---|
2466 | |
---|
2467 | set(handles.runplus,'BackgroundColor',[1 1 0])%paint the command button in yellow |
---|
2468 | drawnow |
---|
2469 | increment=str2double(get(handles.num_IndexIncrement,'String')); %get the field increment d |
---|
2470 | if isnan(increment)% case of free increment: move to next available field index |
---|
2471 | increment='+'; |
---|
2472 | end |
---|
2473 | errormsg=runpm(hObject,eventdata,handles,increment); |
---|
2474 | if ~isempty(errormsg) |
---|
2475 | msgbox_uvmat('ERROR',errormsg); |
---|
2476 | end |
---|
2477 | |
---|
2478 | %------------------------------------------------------------------------ |
---|
2479 | % --- Executes on button press in runmin: make one step backward and call |
---|
2480 | % --- InputFileREFRESH. The step backward is along the fieldname series 1 or 2 depending on |
---|
2481 | % --- the scan_i and scan_j check box (exclusive each other) |
---|
2482 | function runmin_Callback(hObject, eventdata, handles) |
---|
2483 | %------------------------------------------------------------------------ |
---|
2484 | |
---|
2485 | set(handles.runmin,'BackgroundColor',[1 1 0])%paint the command button in yellow |
---|
2486 | drawnow |
---|
2487 | increment=-str2double(get(handles.num_IndexIncrement,'String')); %get the field increment d |
---|
2488 | if isnan(increment)% case of free increment: move to previous available field index |
---|
2489 | increment='-'; |
---|
2490 | end |
---|
2491 | errormsg=runpm(hObject,eventdata,handles,increment); |
---|
2492 | if ~isempty(errormsg) |
---|
2493 | msgbox_uvmat('ERROR',errormsg); |
---|
2494 | end |
---|
2495 | |
---|
2496 | %------------------------------------------------------------------------ |
---|
2497 | % -- Executes on button press in Movie: make a series of +> steps |
---|
2498 | function Movie_Callback(hObject, eventdata, handles) |
---|
2499 | %------------------------------------------------------------------------ |
---|
2500 | |
---|
2501 | set(handles.Movie,'BackgroundColor',[1 1 0])%paint the command button in yellow |
---|
2502 | drawnow |
---|
2503 | increment=str2double(get(handles.num_IndexIncrement,'String')); %get the field increment d |
---|
2504 | if isnan(increment)% case of free increment: move to next available field index |
---|
2505 | increment='+'; |
---|
2506 | end |
---|
2507 | set(handles.STOP,'Visible','on') |
---|
2508 | set(handles.speed,'Visible','on') |
---|
2509 | set(handles.speed_txt,'Visible','on') |
---|
2510 | set(handles.Movie,'BusyAction','queue') |
---|
2511 | UvData=get(handles.uvmat,'UserData'); |
---|
2512 | |
---|
2513 | while get(handles.Movie,'Value')==1 && get(handles.speed,'Value')~=0 && isequal(get(handles.Movie,'BusyAction'),'queue') % enable STOP command |
---|
2514 | errormsg=runpm(hObject,eventdata,handles,increment); |
---|
2515 | if ~isempty(errormsg) |
---|
2516 | set(handles.Movie,'BackgroundColor',[1 0 0])%paint the command buttonback to red |
---|
2517 | return |
---|
2518 | end |
---|
2519 | pause(1.02-get(handles.speed,'Value'))% wait for next image |
---|
2520 | end |
---|
2521 | if isfield(UvData,'aviobj') && ~isempty( UvData.aviobj), |
---|
2522 | UvData.aviobj=close(UvData.aviobj); |
---|
2523 | set(handles.uvmat,'UserData',UvData); |
---|
2524 | end |
---|
2525 | set(handles.Movie,'BackgroundColor',[1 0 0])%paint the command buttonback to red |
---|
2526 | |
---|
2527 | %------------------------------------------------------------------------ |
---|
2528 | % -- Executes on button press in Movie: make a series of <- steps |
---|
2529 | function MovieBackward_Callback(hObject, eventdata, handles) |
---|
2530 | %------------------------------------------------------------------------ |
---|
2531 | set(handles.MovieBackward,'BackgroundColor',[1 1 0])%paint the command button in yellow |
---|
2532 | drawnow |
---|
2533 | increment=-str2double(get(handles.num_IndexIncrement,'String')); %get the field increment d |
---|
2534 | if isnan(increment)% case of free increment: move to next available field index |
---|
2535 | increment='-'; |
---|
2536 | end |
---|
2537 | set(handles.STOP,'Visible','on') |
---|
2538 | set(handles.speed,'Visible','on') |
---|
2539 | set(handles.speed_txt,'Visible','on') |
---|
2540 | set(handles.MovieBackward,'BusyAction','queue') |
---|
2541 | UvData=get(handles.uvmat,'UserData'); |
---|
2542 | |
---|
2543 | while get(handles.MovieBackward,'Value')==1 && get(handles.speed,'Value')~=0 && isequal(get(handles.MovieBackward,'BusyAction'),'queue') % enable STOP command |
---|
2544 | errormsg=runpm(hObject,eventdata,handles,increment); |
---|
2545 | if ~isempty(errormsg) |
---|
2546 | set(handles.MovieBackward,'BackgroundColor',[1 0 0])%paint the command buttonback to red |
---|
2547 | return |
---|
2548 | end |
---|
2549 | pause(1.02-get(handles.speed,'Value'))% wait for next image |
---|
2550 | end |
---|
2551 | if isfield(UvData,'aviobj') && ~isempty( UvData.aviobj), |
---|
2552 | UvData.aviobj=close(UvData.aviobj); |
---|
2553 | set(handles.uvmat,'UserData',UvData); |
---|
2554 | end |
---|
2555 | set(handles.MovieBackward,'BackgroundColor',[1 0 0])%paint the command buttonback to red |
---|
2556 | |
---|
2557 | %------------------------------------------------------------------------ |
---|
2558 | function STOP_Callback(hObject, eventdata, handles) |
---|
2559 | %------------------------------------------------------------------------ |
---|
2560 | set(handles.movie_pair,'BusyAction','Cancel') |
---|
2561 | set(handles.movie_pair,'value',0) |
---|
2562 | set(handles.Movie,'BusyAction','Cancel') |
---|
2563 | set(handles.MovieBackward,'BusyAction','Cancel') |
---|
2564 | set(handles.MenuExportMovie,'BusyAction','Cancel') |
---|
2565 | %set(handles.movie_pair,'BackgroundColor',[1 0 0])%paint the command buttonback to red |
---|
2566 | set(handles.Movie,'BackgroundColor',[1 0 0])%paint the command buttonback to red |
---|
2567 | set(handles.MovieBackward,'BackgroundColor',[1 0 0])%paint the command buttonback to red |
---|
2568 | |
---|
2569 | %------------------------------------------------------------------------ |
---|
2570 | % --- function activated by runplus and run minus |
---|
2571 | function errormsg=runpm(hObject,eventdata,handles,increment) |
---|
2572 | %------------------------------------------------------------------------ |
---|
2573 | errormsg='';%default |
---|
2574 | %% check for movie pair status |
---|
2575 | movie_status=get(handles.movie_pair,'Value'); |
---|
2576 | if movie_status |
---|
2577 | STOP_Callback(hObject, eventdata, handles)%interrupt movie pair if active |
---|
2578 | end |
---|
2579 | |
---|
2580 | %% read the current input file name(s) and field indices |
---|
2581 | InputFile=read_GUI(handles.InputFile); |
---|
2582 | InputFile.RootFile=regexprep(InputFile.RootFile,'^[\\/]|[\\/]$','');%suppress possible / or \ separator at the beginning or the end of the string |
---|
2583 | InputFile.SubDir=regexprep(InputFile.SubDir,'^[\\/]|[\\/]$','');%suppress possible / or \ separator at the beginning or the end of the string |
---|
2584 | FileExt=InputFile.FileExt; |
---|
2585 | NomType=InputFile.NomType; |
---|
2586 | [tild,tild,tild,i1,i2,j1,j2]=fileparts_uvmat(InputFile.FileIndex);% check back the indices used |
---|
2587 | if isempty(i1) |
---|
2588 | i1=str2num(get(handles.i1,'String'));%read the field indices (for movie, it is not given by the file name) |
---|
2589 | elseif isempty(j1) && strcmp(get(handles.j1,'Visible'),'on') |
---|
2590 | j1=str2num(get(handles.j1,'String'));%case of indexed movie |
---|
2591 | end |
---|
2592 | if movie_status% we read the second index from the edit box |
---|
2593 | i2=str2num(get(handles.i2,'String'));%read the field indices (for movie, it is not given by the file name) |
---|
2594 | if strcmp(get(handles.j2,'Visible'),'on') |
---|
2595 | j2=str2num(get(handles.j2,'String'));% |
---|
2596 | end |
---|
2597 | end |
---|
2598 | sub_value= get(handles.SubField,'Value'); |
---|
2599 | if sub_value % a second input file has been entered |
---|
2600 | [InputFile.RootPath_1,InputFile.SubDir_1,InputFile.RootFile_1,InputFile.FileIndex_1,InputFile.FileExt_1,InputFile.NomType_1]=read_file_boxes_1(handles); |
---|
2601 | [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 |
---|
2602 | if isempty(i1_1) |
---|
2603 | i1_1=str2num(get(handles.i1,'String'));%read the field indices (for movie, it is not given by the file name) |
---|
2604 | elseif isempty(j1_1) && strcmp(get(handles.j1,'Visible'),'on') |
---|
2605 | j1_1=str2num(get(handles.j1,'String'));%case of indexed movie |
---|
2606 | end |
---|
2607 | else |
---|
2608 | filename_1=[]; |
---|
2609 | end |
---|
2610 | |
---|
2611 | %% increment (or decrement) the field indices and update the input filename(s) |
---|
2612 | if ~isnumeric(increment)% undefined increment value |
---|
2613 | set(handles.CheckFixPair,'Value',0) |
---|
2614 | end |
---|
2615 | CheckFixPair=get(handles.CheckFixPair,'Value')||(isempty(i2)&&isempty(j2)); |
---|
2616 | |
---|
2617 | % the pair i1-i2 or j1-j2 is imposed (check box CheckFixPair selected) |
---|
2618 | if CheckFixPair && isnumeric(increment) |
---|
2619 | if get(handles.scan_i,'Value')==1% case of scanning along index i |
---|
2620 | i1=i1+increment; |
---|
2621 | i2=i2+increment; |
---|
2622 | if sub_value |
---|
2623 | i1_1=i1_1+increment; |
---|
2624 | i2_1=i2_1+increment; |
---|
2625 | end |
---|
2626 | else % case of scanning along index j (burst numbers) |
---|
2627 | j1=j1+increment; |
---|
2628 | j2=j2+increment; |
---|
2629 | if sub_value |
---|
2630 | j1_1=j1_1+increment; |
---|
2631 | j2_1=j2_1+increment; |
---|
2632 | end |
---|
2633 | end |
---|
2634 | |
---|
2635 | % the pair i1-i2 or j1-j2 is free (check box CheckFixPair not selected): the list of existing indices recorded in UvData is used |
---|
2636 | else |
---|
2637 | UvData=get(handles.uvmat,'UserData'); |
---|
2638 | ref_i=i1; |
---|
2639 | if ~isempty(i2) |
---|
2640 | ref_i=floor((i1+i2)/2);% current reference index i |
---|
2641 | end |
---|
2642 | ref_j=1; |
---|
2643 | if ~isempty(j1) |
---|
2644 | ref_j=j1; |
---|
2645 | if ~isempty(j2) |
---|
2646 | ref_j=floor((j1+j2)/2);% current reference index j |
---|
2647 | end |
---|
2648 | end |
---|
2649 | if isnumeric(increment) |
---|
2650 | if get(handles.scan_i,'Value')==1% case of scanning along index i |
---|
2651 | ref_i=ref_i+increment;% increment the current reference index i |
---|
2652 | else % case of scanning along index j (burst numbers) |
---|
2653 | ref_j=ref_j+increment;% increment the current reference index j if scan_j option is used |
---|
2654 | end |
---|
2655 | else % free increment |
---|
2656 | % runaction=get(gcbo,'tag'); |
---|
2657 | if strcmp(increment,'+')% if runplus or movie is activated |
---|
2658 | step=1; |
---|
2659 | else |
---|
2660 | step=-1; |
---|
2661 | end |
---|
2662 | if get(handles.scan_i,'Value')==1% case of scanning along index i |
---|
2663 | ref_i=ref_i+step; |
---|
2664 | 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 |
---|
2665 | ref_i=ref_i+step; |
---|
2666 | end |
---|
2667 | else % case of scanning along index j (burst numbers) |
---|
2668 | ref_j=ref_j+step; |
---|
2669 | 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 |
---|
2670 | ref_j=ref_j+step; |
---|
2671 | end |
---|
2672 | end |
---|
2673 | end |
---|
2674 | if ref_i<0 |
---|
2675 | errormsg='minimum i index reached'; |
---|
2676 | elseif ref_j<0 |
---|
2677 | errormsg='minimum j index reached'; |
---|
2678 | elseif ref_i+1>size(UvData.i1_series{1},3) |
---|
2679 | errormsg='maximum i index reached (reload the input file to update the index bound)'; |
---|
2680 | elseif ref_j+1>size(UvData.i1_series{1},2) |
---|
2681 | errormsg='maximum j index reached (reload the input file to update the index bound)'; |
---|
2682 | end |
---|
2683 | if ~isempty(errormsg),return,end |
---|
2684 | siz=size(UvData.i1_series{1}); |
---|
2685 | ref_indices=ref_i*siz(1)*siz(2)+ref_j*siz(1)+1:ref_i*siz(1)*siz(2)+(ref_j+1)*siz(1); |
---|
2686 | i1_subseries=UvData.i1_series{1}(ref_indices); |
---|
2687 | ref_indices=ref_indices(i1_subseries>0); |
---|
2688 | if isempty(ref_indices)% case of pairs (free index i) |
---|
2689 | ref_indices=ref_i*siz(1)*siz(2)+1:(ref_i+1)*siz(1)*siz(2); |
---|
2690 | i1_subseries=UvData.i1_series{1}(ref_indices); |
---|
2691 | ref_indices=ref_indices(i1_subseries>0); |
---|
2692 | end |
---|
2693 | if isempty(ref_indices),errormsg='no next frame: set num_IndexIncrement =''*'' to reach the next existing file';return |
---|
2694 | end |
---|
2695 | i1=UvData.i1_series{1}(ref_indices(end)); |
---|
2696 | if ~isempty(UvData.i2_series{1}) |
---|
2697 | i2=UvData.i2_series{1}(ref_indices(end)); |
---|
2698 | end |
---|
2699 | if ~isempty(UvData.j1_series{1}) |
---|
2700 | j1=UvData.j1_series{1}(ref_indices(end)); |
---|
2701 | end |
---|
2702 | if ~isempty(UvData.j2_series{1}) |
---|
2703 | j2=UvData.j2_series{1}(ref_indices(end)); |
---|
2704 | end |
---|
2705 | |
---|
2706 | % case of a second file series |
---|
2707 | if sub_value |
---|
2708 | ref_i_1=i1_1; |
---|
2709 | if ~isempty(i2_1) |
---|
2710 | ref_i_1=floor((i1_1+i2_1)/2);% current reference index i |
---|
2711 | end |
---|
2712 | ref_j_1=1; |
---|
2713 | if ~isempty(j1_1) |
---|
2714 | ref_j_1=j1_1; |
---|
2715 | if ~isempty(j2_1) |
---|
2716 | ref_j_1=floor((j1_1+j2_1)/2);% current reference index j |
---|
2717 | end |
---|
2718 | end |
---|
2719 | if isnumeric(increment) |
---|
2720 | if get(handles.scan_i,'Value')==1% case of scanning along index i |
---|
2721 | ref_i_1=ref_i_1+increment;% increment the current reference index i |
---|
2722 | else % case of scanning along index j (burst numbers) |
---|
2723 | ref_j_1=ref_j_1+increment;% increment the current reference index j if scan_j option is used |
---|
2724 | end |
---|
2725 | else % free increment, synchronise the ref indices with the first series |
---|
2726 | ref_i_1=ref_i; |
---|
2727 | ref_j_1=ref_j; |
---|
2728 | end |
---|
2729 | if numel(UvData.i1_series)==1 |
---|
2730 | UvData.i1_series{2}=UvData.i1_series{1}; |
---|
2731 | UvData.j1_series{2}=UvData.j1_series{1}; |
---|
2732 | UvData.i2_series{2}=UvData.i2_series{1}; |
---|
2733 | UvData.j2_series{2}=UvData.j2_series{1}; |
---|
2734 | end |
---|
2735 | if ref_i_1<0 |
---|
2736 | errormsg='minimum i index reached'; |
---|
2737 | elseif ref_j_1<0 |
---|
2738 | errormsg='minimum j index reached'; |
---|
2739 | elseif ref_i_1+1>size(UvData.i1_series{2},3) |
---|
2740 | errormsg='maximum i index reached for the second series (reload the input file to update the index bound)'; |
---|
2741 | elseif ref_j_1+1>size(UvData.i1_series{2},2) |
---|
2742 | errormsg='maximum j index reached for the second series(reload the input file to update the index bound)'; |
---|
2743 | end |
---|
2744 | if ~isempty(errormsg),return,end |
---|
2745 | siz=size(UvData.i1_series{2}); |
---|
2746 | 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); |
---|
2747 | i1_subseries=UvData.i1_series{2}(ref_indices); |
---|
2748 | ref_indices=ref_indices(i1_subseries>0); |
---|
2749 | if isempty(ref_indices)% case of pairs (free index i) |
---|
2750 | ref_indices=ref_i_1*siz(1)*siz(2)+1:(ref_i_1+1)*siz(1)*siz(2); |
---|
2751 | i1_subseries=UvData.i1_series{2}(ref_indices); |
---|
2752 | ref_indices=ref_indices(i1_subseries>0); |
---|
2753 | end |
---|
2754 | i1_1=UvData.i1_series{2}(ref_indices(end)); |
---|
2755 | if ~isempty(UvData.i2_series{2}) |
---|
2756 | i2_1=UvData.i2_series{2}(ref_indices(end)); |
---|
2757 | end |
---|
2758 | if ~isempty(UvData.j1_series{2}) |
---|
2759 | j1_1=UvData.j1_series{2}(ref_indices(end)); |
---|
2760 | end |
---|
2761 | if ~isempty(UvData.j2_series{2}) |
---|
2762 | j2_1=UvData.j2_series{1}(ref_indices(end)); |
---|
2763 | end |
---|
2764 | else% the second series (if needed) is the same file as the first |
---|
2765 | i1_1=i1; |
---|
2766 | i2_1=i2; |
---|
2767 | j1_1=j1; |
---|
2768 | j2_1=j2; |
---|
2769 | end |
---|
2770 | end |
---|
2771 | filename=fullfile_uvmat(InputFile.RootPath,InputFile.SubDir,InputFile.RootFile,FileExt,NomType,i1,i2,j1,j2); |
---|
2772 | |
---|
2773 | %% refresh plots |
---|
2774 | if sub_value |
---|
2775 | 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); |
---|
2776 | errormsg=refresh_field(handles,filename,filename_1,i1,i2,j1,j2,i1_1,i2_1,j1_1,j2_1); |
---|
2777 | else |
---|
2778 | errormsg=refresh_field(handles,filename,filename_1,i1,i2,j1,j2); |
---|
2779 | end |
---|
2780 | set(handles.InputFileREFRESH,'BackgroundColor',[1 0 0]) |
---|
2781 | set(handles.runplus,'BackgroundColor',[1 0 0]) |
---|
2782 | set(handles.runmin,'BackgroundColor',[1 0 0]) |
---|
2783 | |
---|
2784 | %% update the index counters if the index move is successfull |
---|
2785 | |
---|
2786 | if isempty(errormsg) |
---|
2787 | set(handles.i1,'String',num2stra(i1,NomType,1)); |
---|
2788 | if isequal(i2,i1) |
---|
2789 | set(handles.i2,'String',''); |
---|
2790 | else |
---|
2791 | set(handles.i2,'String',num2stra(i2,NomType,1)); |
---|
2792 | end |
---|
2793 | set(handles.j1,'String',num2stra(j1,NomType,2)); |
---|
2794 | if isequal(j2,j1) |
---|
2795 | set(handles.j2,'String',''); |
---|
2796 | else |
---|
2797 | set(handles.j2,'String',num2stra(j2,NomType,2)); |
---|
2798 | end |
---|
2799 | indices=fullfile_uvmat('','','','',NomType,i1,i2,j1,j2); |
---|
2800 | set(handles.FileIndex,'String',indices); |
---|
2801 | if ~isempty(filename_1) |
---|
2802 | indices_1=fullfile_uvmat('','','','',InputFile.NomType_1,i1_1,i2_1,j1_1,j2_1); |
---|
2803 | set(handles.FileIndex_1,'String',indices_1); |
---|
2804 | end |
---|
2805 | if isequal(movie_status,1) |
---|
2806 | set(handles.movie_pair,'Value',1) |
---|
2807 | movie_pair_Callback(hObject, eventdata, handles); %reactivate moviepair if it was activated |
---|
2808 | else |
---|
2809 | if isempty(i2), set(handles.i2,'String',''); end % suppress the second index display if not used |
---|
2810 | if isempty(j2), set(handles.j2,'String',''); end |
---|
2811 | end |
---|
2812 | end |
---|
2813 | |
---|
2814 | %------------------------------------------------------------------------ |
---|
2815 | % --- Executes on button press in movie_pair: create an alternating movie with two view |
---|
2816 | function movie_pair_Callback(hObject, eventdata, handles) |
---|
2817 | %------------------------------------------------------------------------ |
---|
2818 | |
---|
2819 | %% stop movie action if the movie_pair button is off |
---|
2820 | if ~get(handles.movie_pair,'value') |
---|
2821 | set(handles.movie_pair,'BusyAction','Cancel')%stop movie pair if button is 'off' |
---|
2822 | set(handles.i2,'String','')% the second i index display is suppressed |
---|
2823 | set(handles.j2,'String','')% the second j index display is suppressed |
---|
2824 | set(handles.Dt_txt,'String','')% the time interval indication is suppressed |
---|
2825 | return |
---|
2826 | end |
---|
2827 | |
---|
2828 | %% check the input file indexing: |
---|
2829 | [RootPath,SubDir,RootFile,FileIndex,FileExt]=read_file_boxes(handles); |
---|
2830 | NomType=get(handles.NomType,'String'); |
---|
2831 | if ~isempty(find(regexp(NomType,'-'))) |
---|
2832 | msgbox_uvmat('ERROR','The movie pair requires file series with a single index on the first input line') |
---|
2833 | return |
---|
2834 | end |
---|
2835 | filename=[fullfile(RootPath,SubDir,RootFile) FileIndex FileExt];% build the input file name (first line) |
---|
2836 | |
---|
2837 | set(handles.movie_pair,'BusyAction','queue')% |
---|
2838 | set(handles.CheckFixPair,'Value',1)% impose fixed pair (needed for function runpm) |
---|
2839 | set(handles.REFRESH,'BackgroundColor',[1 1 0])%paint the command button in yellow to indicate its activity |
---|
2840 | set(handles.movie_pair,'BackgroundColor',[1 1 0])%paint the command button in yellow to indicate its activity |
---|
2841 | drawnow |
---|
2842 | % list_fields=get(handles.FieldName,'String');% list menu fields |
---|
2843 | % index_fields=get(handles.FieldName,'Value');% selected string index |
---|
2844 | % FieldName=list_fields{index_fields}; % selected field |
---|
2845 | |
---|
2846 | |
---|
2847 | % if isequal(FieldName,'image') |
---|
2848 | % index=1; |
---|
2849 | |
---|
2850 | % else |
---|
2851 | % list_fields=get(handles.FieldName_1,'String');% list menu fields |
---|
2852 | % index_fields=get(handles.FieldName_1,'Value');% selected string index |
---|
2853 | % FieldName=list_fields{index_fields}; % selected field |
---|
2854 | % if isequal(FieldName,'image') |
---|
2855 | % index=2; |
---|
2856 | % [RootPath,SubDir,RootFile,FileIndex_1,Ext,NomType]=read_file_boxes_1(handles);% get info from the second input line |
---|
2857 | % else |
---|
2858 | % msgbox_uvmat('ERROR','an image or movie must be first introduced as input') |
---|
2859 | % set(handles.movie_pair,'BackgroundColor',[1 0 0])%paint the command button in red |
---|
2860 | % set(handles.movie_pair,'Value',0) |
---|
2861 | % return |
---|
2862 | % end |
---|
2863 | % end |
---|
2864 | num_i1=str2num(get(handles.i1,'String')); |
---|
2865 | num_j1=stra2num(get(handles.j1,'String')); |
---|
2866 | num_i2=str2num(get(handles.i2,'String')); |
---|
2867 | num_j2=stra2num(get(handles.j2,'String')); |
---|
2868 | |
---|
2869 | %% determine the name 'imaname_1' of the second file in the pair |
---|
2870 | imaname_1=''; |
---|
2871 | if isempty(num_j2)% no second j index indicated |
---|
2872 | if isempty(num_i2) |
---|
2873 | if strcmp(get(handles.j2,'Visible'),'on') %if the j box is visible |
---|
2874 | imaname_1=fullfile_uvmat(RootPath,SubDir,RootFile,FileExt,NomType,num_i1,[],num_j1+1); |
---|
2875 | end |
---|
2876 | if exist(imaname_1,'file') |
---|
2877 | num_j2=num_j1+1;% look by default for the next j index as the second file |
---|
2878 | set(handles.j2,'String',num2stra(num_j2,NomType)); |
---|
2879 | else |
---|
2880 | imaname_1=fullfile_uvmat(RootPath,SubDir,RootFile,FileExt,NomType,num_i1+1,[],num_j1); |
---|
2881 | if exist(imaname_1,'file') |
---|
2882 | num_i2=num_i1+1; |
---|
2883 | set(handles.i2,'String',num2str(num_i2)); |
---|
2884 | else |
---|
2885 | msgbox_uvmat('ERROR', 'a second image index i2 or j2 is needed to show the pair as a movie') |
---|
2886 | set(handles.movie_pair,'BackgroundColor',[1 0 0])%paint the command button in red |
---|
2887 | set(handles.movie_pair,'Value',0) |
---|
2888 | return |
---|
2889 | end |
---|
2890 | end |
---|
2891 | else |
---|
2892 | num_j2=num_j1;%repeat the index i1 by default |
---|
2893 | end |
---|
2894 | end |
---|
2895 | if isempty(num_i2) |
---|
2896 | num_i2=num_i1;%repeat the index i1 by default |
---|
2897 | end |
---|
2898 | if isempty(num_j1) |
---|
2899 | num_j1=1; |
---|
2900 | end |
---|
2901 | if isempty(num_j2) |
---|
2902 | num_j2=num_j1;%repeat the index i1 by default |
---|
2903 | end |
---|
2904 | imaname_1=fullfile_uvmat(RootPath,SubDir,RootFile,FileExt,NomType,num_i2,[],num_j2); |
---|
2905 | if strcmp(NomType,'*') |
---|
2906 | num_frame=num_i2; |
---|
2907 | else |
---|
2908 | num_frame=num_j2; |
---|
2909 | end |
---|
2910 | if ~exist(imaname_1,'file') |
---|
2911 | msgbox_uvmat('ERROR',['second input open (-) ' imaname_1 ' not found']); |
---|
2912 | set(handles.movie_pair,'BackgroundColor',[1 0 0])%paint the command button in red |
---|
2913 | set(handles.movie_pair,'Value',0) |
---|
2914 | return |
---|
2915 | end |
---|
2916 | |
---|
2917 | %% display the first field in the pair (including possibly a background field from second line input filename_1) |
---|
2918 | filename_1='';%default |
---|
2919 | FileIndex_1=''; |
---|
2920 | if get(handles.SubField,'Value') |
---|
2921 | [RootPath_1,SubDir_1,RootFile_1,FileIndex_1,FileExt_1]=read_file_boxes_1(handles); |
---|
2922 | filename_1=[fullfile(RootPath_1,SubDir_1,RootFile_1) FileIndex_1 FileExt_1]; |
---|
2923 | end |
---|
2924 | % num_i1=stra2num(get(handles.i1,'String')); |
---|
2925 | % num_i2=stra2num(get(handles.i2,'String')); |
---|
2926 | % num_j1=stra2num(get(handles.j1,'String')); |
---|
2927 | % num_j2=stra2num(get(handles.j2,'String')); |
---|
2928 | [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 |
---|
2929 | if isempty(j1_1)% case of movies, the index is not given by file index |
---|
2930 | j1_1=num_j1; |
---|
2931 | end |
---|
2932 | |
---|
2933 | errormsg=refresh_field(handles,filename,filename_1,num_i1,num_i2,num_j1,num_j2,i1_1,i2_1,j1_1,j2_1); |
---|
2934 | |
---|
2935 | if isempty(errormsg) |
---|
2936 | set(handles.REFRESH,'BackgroundColor',[1 0 0])% set button color to red, update successfull |
---|
2937 | else |
---|
2938 | msgbox_uvmat('ERROR',errormsg); |
---|
2939 | set(handles.REFRESH,'BackgroundColor',[1 0 1])% keep button color magenta, input not succesfull |
---|
2940 | end |
---|
2941 | UvData=get(handles.uvmat,'UserData'); |
---|
2942 | Field_a=UvData.Field;% movie on the field defined by the second input line |
---|
2943 | |
---|
2944 | %% display time interval for the image pair |
---|
2945 | if isfield(UvData,'XmlData')&&isfield(UvData.XmlData{1},'Time')... |
---|
2946 | && size(UvData.XmlData{1}.Time,1)>=num_i2+1 && size(UvData.XmlData{1}.Time,2)>=num_j2+1 |
---|
2947 | dt=(UvData.XmlData{1}.Time(num_i2+1,num_j2+1)-UvData.XmlData{1}.Time(num_i1+1,num_j1+1)); |
---|
2948 | if isfield(UvData,'TimeUnit') |
---|
2949 | set(handles.Dt_txt,'String',['Dt=' num2str(1000*dt,3) ' m' UvData.TimeUnit] ) |
---|
2950 | else |
---|
2951 | set(handles.Dt_txt,'String',['Dt=' num2str(1000*dt,3) ' 10^(-3)'] ) |
---|
2952 | end |
---|
2953 | else |
---|
2954 | set(handles.Dt_txt,'String','') |
---|
2955 | end |
---|
2956 | |
---|
2957 | %% read the second field |
---|
2958 | if isempty(UvData.MovieObject) |
---|
2959 | [Field_b,ParamOut,errormsg] = read_field(imaname_1,UvData.FileType{index},[],num_frame); |
---|
2960 | else |
---|
2961 | [Field_b,ParamOut,errormsg] = read_field(imaname_1,UvData.FileType{1},UvData.MovieObject{1},num_frame); |
---|
2962 | end |
---|
2963 | if ~isempty(errormsg) |
---|
2964 | msgbox_uvmat('ERROR',['Error in reading second image: ' errormsg]) |
---|
2965 | return |
---|
2966 | end |
---|
2967 | |
---|
2968 | %% apply phys or other transform on the two input fields |
---|
2969 | transform=get(handles.TransformPath,'UserData'); |
---|
2970 | if ~isempty(transform) |
---|
2971 | if isfield(UvData,'XmlData') && ~isempty(UvData.XmlData) %use geometry calib recorded from the ImaDoc xml file as first priority |
---|
2972 | if nargin(transform)>=2 |
---|
2973 | Field_b=transform(Field_b,UvData.XmlData{1}); |
---|
2974 | else |
---|
2975 | Field_b=transform(Field_b); |
---|
2976 | end |
---|
2977 | end |
---|
2978 | end |
---|
2979 | |
---|
2980 | %% make movie until movie speed is set to 0 or STOP is activated |
---|
2981 | hima=findobj(handles.PlotAxes,'Tag','ima');% %handles.PlotAxes =main plotting window (A GENERALISER) |
---|
2982 | set(handles.STOP,'Visible','on') |
---|
2983 | set(handles.speed,'Visible','on') |
---|
2984 | set(handles.speed_txt,'Visible','on') |
---|
2985 | while get(handles.speed,'Value')~=0 && isequal(get(handles.movie_pair,'BusyAction'),'queue') % enable STOP command |
---|
2986 | % read and plot the series of images in non erase mode |
---|
2987 | set(hima,'CData',Field_b.A); %TODO: generalise to other kinds of fields |
---|
2988 | pause(1.02-get(handles.speed,'Value'));% wait for next image |
---|
2989 | set(hima,'CData',Field_a.A); |
---|
2990 | pause(1.02-get(handles.speed,'Value'));% wait for next image |
---|
2991 | end |
---|
2992 | set(handles.movie_pair,'BackgroundColor',[1 0 0])%paint the command button in red |
---|
2993 | set(handles.movie_pair,'Value',0) |
---|
2994 | set(handles.Dt_txt,'String','') |
---|
2995 | |
---|
2996 | %------------------------------------------------------------------------ |
---|
2997 | % --- Executes on button press in InputFileREFRESH. |
---|
2998 | function REFRESH_Callback(hObject, eventdata, handles) |
---|
2999 | %------------------------------------------------------------------------ |
---|
3000 | set(handles.REFRESH,'BackgroundColor',[1 1 0])%paint the REFRESH button in yellow to indicate its activity |
---|
3001 | drawnow |
---|
3002 | [RootPath,SubDir,RootFile,FileIndex,FileExt]=read_file_boxes(handles);%read the features of the input file name (first line) |
---|
3003 | [tild,tild,tild,i1,i2,j1,j2]=fileparts_uvmat(FileIndex);% check back the indices used |
---|
3004 | if isempty(i2), set(handles.i2,'String',''); end % suppress the second i index display if not used |
---|
3005 | if isempty(j2), set(handles.j2,'String',''); end % suppress the second j index display if not used |
---|
3006 | filename=[fullfile(RootPath,SubDir,RootFile) FileIndex FileExt];% build the input file name (first line) |
---|
3007 | filename_1='';%default second file name |
---|
3008 | FileIndex_1=''; |
---|
3009 | if get(handles.SubField,'Value')% if a second file is introduced |
---|
3010 | [RootPath_1,SubDir_1,RootFile_1,FileIndex_1,FileExt_1]=read_file_boxes_1(handles);%read the features of the input file name (second line) |
---|
3011 | filename_1=[fullfile(RootPath_1,SubDir_1,RootFile_1) FileIndex_1 FileExt_1]; %build the input file name (second line) |
---|
3012 | end |
---|
3013 | num_i1=stra2num(get(handles.i1,'String')); |
---|
3014 | num_i2=stra2num(get(handles.i2,'String')); |
---|
3015 | num_j1=stra2num(get(handles.j1,'String')); |
---|
3016 | num_j2=stra2num(get(handles.j2,'String')); |
---|
3017 | [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 |
---|
3018 | if isempty(j1_1)% case of movies, the index is not given by file index |
---|
3019 | j1_1=num_j1; |
---|
3020 | end |
---|
3021 | % in case of movies the index is set by edit boxes i1 or j1 (case of movies indexed by index i) |
---|
3022 | errormsg=refresh_field(handles,filename,filename_1,num_i1,num_i2,num_j1,num_j2,i1_1,i2_1,j1_1,j2_1); |
---|
3023 | ResizeFcn(handles.uvmat,[],handles) |
---|
3024 | if isempty(errormsg) |
---|
3025 | set(handles.REFRESH,'BackgroundColor',[1 0 0])% set button color to red, update successfull |
---|
3026 | else |
---|
3027 | msgbox_uvmat('ERROR',errormsg); |
---|
3028 | set(handles.REFRESH,'BackgroundColor',[1 0 1])% keep button color magenta, input not succesfull |
---|
3029 | end |
---|
3030 | |
---|
3031 | %------------------------------------------------------------------------ |
---|
3032 | % --- read the input files and inputfilerefresh all the plots, including projection. |
---|
3033 | % OUTPUT: |
---|
3034 | % errormsg: error message char string =[] by default |
---|
3035 | % INPUT: |
---|
3036 | % FileName: first input file (=[] in the absence of input file) |
---|
3037 | % FileName_1: second input file (=[] in the asbsence of second input file) |
---|
3038 | % num_i1,num_i2,num_j1,num_j2; frame indices |
---|
3039 | % i1_1,i2_1,j1_1,j2_1: frame indices for the second input file (needed if FileName_1 is not empty) |
---|
3040 | %------------------------------------------------------------------------ |
---|
3041 | function errormsg=refresh_field(handles,FileName,FileName_1,num_i1,num_i2,num_j1,num_j2,i1_1,i2_1,j1_1,j2_1) |
---|
3042 | %------------------------------------------------------------------------ |
---|
3043 | |
---|
3044 | %% initialisation |
---|
3045 | pointer=get(handles.uvmat,'Pointer'); |
---|
3046 | if strcmp(pointer,'watch')% reinitialise the mouse if stuck to 'watch' |
---|
3047 | set(handles.CheckZoom,'Value',0) |
---|
3048 | pointer='arrow'; |
---|
3049 | end |
---|
3050 | set(handles.uvmat,'Pointer','watch') |
---|
3051 | drawnow |
---|
3052 | if ~exist('Field','var') |
---|
3053 | Field={}; |
---|
3054 | end |
---|
3055 | UvData=get(handles.uvmat,'UserData'); |
---|
3056 | if ishandle(handles.UVMAT_title) %remove title panel on uvmat |
---|
3057 | delete(handles.UVMAT_title) |
---|
3058 | end |
---|
3059 | |
---|
3060 | %% determine the main input file information for action |
---|
3061 | if ~exist(FileName,'file') |
---|
3062 | errormsg=['input file ' FileName ' does not exist']; |
---|
3063 | return |
---|
3064 | end |
---|
3065 | NomType=get(handles.NomType,'String'); |
---|
3066 | NomType_1=''; |
---|
3067 | if strcmp(get(handles.NomType_1,'Visible'),'on') |
---|
3068 | NomType_1=get(handles.NomType_1,'String'); |
---|
3069 | end |
---|
3070 | %update the z position index |
---|
3071 | mode_slice=get(handles.slices,'String'); |
---|
3072 | if strcmp(mode_slice,'volume') |
---|
3073 | z_index=num_j1; |
---|
3074 | set(handles.z_index,'String',num2str(z_index)) |
---|
3075 | else |
---|
3076 | nbslice=str2num(get(handles.num_NbSlice,'String')); |
---|
3077 | z_index=mod(num_i1-1,nbslice)+1; |
---|
3078 | set(handles.z_index,'String',num2str(z_index)) |
---|
3079 | end |
---|
3080 | % inputfilerefresh menu for save_mask if relevant |
---|
3081 | masknumber=get(handles.masklevel,'String'); |
---|
3082 | if length(masknumber)>=z_index |
---|
3083 | set(handles.masklevel,'Value',z_index) |
---|
3084 | end |
---|
3085 | |
---|
3086 | %% test for need of tps |
---|
3087 | check_proj_tps=0; |
---|
3088 | if (strcmp(UvData.FileType{1},'civdata')||strcmp(UvData.FileType{1},'civx')) |
---|
3089 | for iobj=1:numel(UvData.ProjObject) |
---|
3090 | if isfield(UvData.ProjObject{iobj},'ProjMode')&& strcmp(UvData.ProjObject{iobj}.ProjMode,'interp_tps') |
---|
3091 | check_proj_tps=1; |
---|
3092 | break |
---|
3093 | end |
---|
3094 | end |
---|
3095 | end |
---|
3096 | |
---|
3097 | %% read the first input field |
---|
3098 | ParamIn.ColorVar='';%default variable name for vector color |
---|
3099 | frame_index=1;%default |
---|
3100 | FieldName='';%default |
---|
3101 | VelType='';%default |
---|
3102 | switch UvData.FileType{1} |
---|
3103 | case {'civx','civdata','netcdf'}; |
---|
3104 | list_fields=get(handles.FieldName,'String');% list menu fields |
---|
3105 | FieldName= list_fields{get(handles.FieldName,'Value')}; % selected field |
---|
3106 | if ~strcmp(FieldName,'get_field...') |
---|
3107 | if get(handles.FixVelType,'Value') |
---|
3108 | VelTypeList=get(handles.VelType,'String'); |
---|
3109 | VelType=VelTypeList{get(handles.VelType,'Value')}; |
---|
3110 | end |
---|
3111 | end |
---|
3112 | % case of input vector field, get the scalar used for vector color |
---|
3113 | if ~isempty(regexp(FieldName,'^vec(')) |
---|
3114 | list_code=get(handles.ColorCode,'String');% list menu fields |
---|
3115 | index_code=get(handles.ColorCode,'Value');% selected string index |
---|
3116 | if ~strcmp(list_code{index_code},'black') && ~strcmp(list_code{index_code},'white') |
---|
3117 | list_code=get(handles.ColorScalar,'String');% list menu fields |
---|
3118 | index_code=get(handles.ColorScalar,'Value');% selected string index |
---|
3119 | ParamIn.ColorVar= list_code{index_code}; % selected field |
---|
3120 | end |
---|
3121 | end |
---|
3122 | case {'video','mmreader','rdvision'} |
---|
3123 | ParamIn=UvData.MovieObject{1}; % movie object |
---|
3124 | if strcmp(NomType,'*') |
---|
3125 | frame_index=num_i1;%frame index from a single movies or multimage |
---|
3126 | else |
---|
3127 | frame_index=num_j1;% frame index from a set of indexed movies |
---|
3128 | end |
---|
3129 | case 'multimage' |
---|
3130 | if ~strcmp(NomType,'*') |
---|
3131 | MaxIndex_j_cell=get(handles.MaxIndex_j,'String'); |
---|
3132 | if num_j1>str2num(MaxIndex_j_cell{1}) |
---|
3133 | errormsg='specified frame index exceeds file content'; |
---|
3134 | return |
---|
3135 | else |
---|
3136 | frame_index=num_j1;%frame index for movies or multimage |
---|
3137 | end |
---|
3138 | else |
---|
3139 | MaxIndex_i_cell=get(handles.MaxIndex_i,'String'); |
---|
3140 | if num_i1>str2num(MaxIndex_i_cell{1}) |
---|
3141 | errormsg='specified frame index exceeds file content'; |
---|
3142 | return |
---|
3143 | else |
---|
3144 | frame_index=num_i1; |
---|
3145 | end |
---|
3146 | end |
---|
3147 | case 'vol' %TODO: update |
---|
3148 | if isfield(UvData.XmlData,'Npy') && isfield(UvData.XmlData,'Npx') |
---|
3149 | ParamIn.Npy=UvData.XmlData.Npy; |
---|
3150 | ParamIn.Npx=UvData.XmlData.Npx; |
---|
3151 | else |
---|
3152 | errormsg='Npx and Npy need to be defined in the xml file for volume images .vol'; |
---|
3153 | return |
---|
3154 | end |
---|
3155 | end |
---|
3156 | if isstruct (ParamIn) |
---|
3157 | ParamIn.FieldName=FieldName; |
---|
3158 | ParamIn.VelType=VelType; |
---|
3159 | ParamIn.Coord_x=get(handles.Coord_x,'String'); |
---|
3160 | ParamIn.Coord_y=get(handles.Coord_y,'String'); |
---|
3161 | ParamIn.Coord_z=get(handles.Coord_z,'String'); |
---|
3162 | TimeName=get(handles.TimeName,'String'); |
---|
3163 | r=regexp(TimeName,'^(?<type>(dim:)|(var:))','names');%look for 'var:' or 'dim:' at the beginning of time name |
---|
3164 | if ~isempty(r) |
---|
3165 | frame_index=num_i1;%time index chosen by i1 |
---|
3166 | if strcmp(r.type,'dim:') |
---|
3167 | ParamIn.TimeDimName=TimeName(5:end); |
---|
3168 | elseif strcmp(r.type,'var:') |
---|
3169 | ParamIn.TimeVarName=TimeName(5:end); |
---|
3170 | end |
---|
3171 | end |
---|
3172 | end |
---|
3173 | % check_tps = 0; |
---|
3174 | % if strcmp(UvData.FileType{1},'civdata')&&~strcmp(ParamIn.FieldName,'velocity')&&~strcmp(ParamIn.FieldName,'get_field...') |
---|
3175 | % check_tps=1;%tps needed to get the requested field |
---|
3176 | % end |
---|
3177 | [Field{1},ParamOut,errormsg] = read_field(FileName,UvData.FileType{1},ParamIn,frame_index); |
---|
3178 | if ~isempty(errormsg) |
---|
3179 | errormsg=['uvmat / refresh_field / read_field( ' FileName ') / ' errormsg]; |
---|
3180 | return |
---|
3181 | end |
---|
3182 | if isfield(ParamOut,'Npx')&& isfield(ParamOut,'Npy') |
---|
3183 | set(handles.num_Npx,'String',num2str(ParamOut.Npx));% display image size on the interface |
---|
3184 | set(handles.num_Npy,'String',num2str(ParamOut.Npy)); |
---|
3185 | end |
---|
3186 | Field{1}.ZIndex=z_index; %used for multiplane 3D calibration |
---|
3187 | |
---|
3188 | %% choose and read a second field FileName_1 if defined |
---|
3189 | VelType_1=[];%default |
---|
3190 | FieldName_1=[]; |
---|
3191 | ParamIn_1=[]; |
---|
3192 | ParamOut_1=[]; |
---|
3193 | frame_index_1=1; |
---|
3194 | if ~isempty(FileName_1) |
---|
3195 | if ~exist(FileName_1,'file') |
---|
3196 | errormsg=['second file ' FileName_1 ' does not exist']; |
---|
3197 | return |
---|
3198 | end |
---|
3199 | switch UvData.FileType{2} |
---|
3200 | case {'civx','civdata','netcdf'}; |
---|
3201 | list_fields=get(handles.FieldName_1,'String');% list menu fields |
---|
3202 | if ischar(list_fields),list_fields={list_fields};end |
---|
3203 | FieldName_1= list_fields{get(handles.FieldName_1,'Value')}; % selected field |
---|
3204 | if ~strcmp(FieldName,'get_field...') |
---|
3205 | if get(handles.FixVelType,'Value') |
---|
3206 | VelTypeList=get(handles.VelType_1,'String'); |
---|
3207 | VelType_1=VelTypeList{get(handles.VelType_1,'Value')};% read the velocity type. |
---|
3208 | end |
---|
3209 | end |
---|
3210 | if strcmp(FieldName_1,'velocity')&& strcmp(get(handles.ColorCode,'Visible'),'on') |
---|
3211 | list_code=get(handles.ColorCode,'String');% list menu fields |
---|
3212 | index_code=get(handles.ColorCode,'Value');% selected string index |
---|
3213 | if ~strcmp(list_code{index_code},'black') && ~strcmp(list_code{index_code},'white') |
---|
3214 | list_code=get(handles.ColorScalar,'String');% list menu fields |
---|
3215 | index_code=get(handles.ColorScalar,'Value');% selected string index |
---|
3216 | ParamIn_1.ColorVar= list_code{index_code}; % selected field for vector color display |
---|
3217 | end |
---|
3218 | end |
---|
3219 | case {'video','mmreader'} |
---|
3220 | ParamIn_1=UvData.MovieObject{2}; |
---|
3221 | if ~strcmp(NomType_1,'*') |
---|
3222 | frame_index_1=j1_1;%frame index for movies or multimage |
---|
3223 | else |
---|
3224 | frame_index_1=i1_1; |
---|
3225 | end |
---|
3226 | case 'multimage' |
---|
3227 | if strcmp(NomType_1,'*')%frame index for movies or multimage |
---|
3228 | frame_index_1=i1_1; |
---|
3229 | else |
---|
3230 | frame_index_1=j1_1; |
---|
3231 | end |
---|
3232 | case 'vol' %TODO: update |
---|
3233 | if isfield(UvData.XmlData,'Npy') && isfield(UvData.XmlData,'Npx') |
---|
3234 | ParamIn_1.Npy=UvData.XmlData.Npy; |
---|
3235 | ParamIn_1.Npx=UvData.XmlData.Npx; |
---|
3236 | else |
---|
3237 | errormsg='Npx and Npy need to be defined in the xml file for volume images .vol'; |
---|
3238 | return |
---|
3239 | end |
---|
3240 | end |
---|
3241 | if isequal(get(handles.NomType_1,'Visible'),'on') |
---|
3242 | NomType_1=get(handles.NomType_1,'String'); |
---|
3243 | else |
---|
3244 | NomType_1=get(handles.NomType,'String'); |
---|
3245 | end |
---|
3246 | test_keepdata_1=0;% test for keeping the previous stored data if the input files are unchanged |
---|
3247 | if ~isequal(NomType_1,'*')&& isfield(UvData,'FileName_1') |
---|
3248 | test_keepdata_1= strcmp(FileName_1,UvData.FileName_1) ; |
---|
3249 | end |
---|
3250 | if test_keepdata_1 |
---|
3251 | Field{2}=UvData.Field_1;% keep the stored field |
---|
3252 | ParamOut_1=UvData.ParamOut_1; |
---|
3253 | else |
---|
3254 | if isempty(ParamIn_1) || isstruct(ParamIn_1) |
---|
3255 | ParamIn_1.FieldName=FieldName_1; |
---|
3256 | ParamIn_1.VelType=VelType_1; |
---|
3257 | ParamIn_1.Coord_x=get(handles.Coord_x,'String'); |
---|
3258 | ParamIn_1.Coord_y=get(handles.Coord_y,'String'); |
---|
3259 | end |
---|
3260 | [Field{2},ParamOut_1,errormsg] = read_field(FileName_1,UvData.FileType{2},ParamIn_1,frame_index_1); |
---|
3261 | if ~isempty(errormsg) |
---|
3262 | errormsg=['error in reading ' FieldName_1 ' in ' FileName_1 ': ' errormsg]; |
---|
3263 | return |
---|
3264 | end |
---|
3265 | if isstruct(ParamOut_1)&&~strcmp(ParamOut_1.FieldName,'get_field...')&& (strcmp(UvData.FileType{2},'civdata')||strcmp(UvData.FileType{2},'civx'))... |
---|
3266 | &&~strcmp(ParamOut_1.FieldName,'velocity') && ~strcmp(ParamOut_1.FieldName,'get_field...') |
---|
3267 | if ~check_proj_tps |
---|
3268 | end |
---|
3269 | end |
---|
3270 | end |
---|
3271 | Field{2}.ZIndex=z_index;%used for multi-plane 3D calibration |
---|
3272 | end |
---|
3273 | |
---|
3274 | %% update uvmat interface |
---|
3275 | if isfield(ParamOut,'Npx') |
---|
3276 | set(handles.num_Npx,'String',num2str(ParamOut.Npx));% display image size on the interface |
---|
3277 | set(handles.num_Npy,'String',num2str(ParamOut.Npy)); |
---|
3278 | elseif isfield(ParamOut_1,'Npx') |
---|
3279 | set(handles.num_Npx,'String',num2str(ParamOut_1.Npx));% display image size on the interface |
---|
3280 | set(handles.num_Npy,'String',num2str(ParamOut_1.Npy)); |
---|
3281 | end |
---|
3282 | |
---|
3283 | %% update the display menu for the first velocity type (first menuline) |
---|
3284 | test_veltype=0; |
---|
3285 | if (strcmp(UvData.FileType{1},'civx')||strcmp(UvData.FileType{1},'civdata'))&& ~strcmp(FieldName,'get_field...') |
---|
3286 | test_veltype=1; |
---|
3287 | set(handles.VelType,'Visible','on') |
---|
3288 | set(handles.VelType_1,'Visible','on') |
---|
3289 | set(handles.FixVelType,'Visible','on') |
---|
3290 | menu=set_veltype_display(ParamOut.CivStage,UvData.FileType{1}); |
---|
3291 | index_menu=strcmp(ParamOut.VelType,menu);%look for VelType in the menu |
---|
3292 | index_val=find(index_menu,1); |
---|
3293 | if isempty(index_val) |
---|
3294 | index_val=1; |
---|
3295 | end |
---|
3296 | set(handles.VelType,'Value',index_val) |
---|
3297 | if ~get(handles.SubField,'value') |
---|
3298 | set(handles.VelType,'String',menu) |
---|
3299 | set(handles.VelType_1,'Value',1) |
---|
3300 | set(handles.VelType_1,'String',[{''};menu]) |
---|
3301 | end |
---|
3302 | else |
---|
3303 | set(handles.VelType,'Visible','off') |
---|
3304 | end |
---|
3305 | |
---|
3306 | %% update the display menu for the second velocity type (second menuline) |
---|
3307 | test_veltype_1=0; |
---|
3308 | if isempty(FileName_1) |
---|
3309 | elseif ~test_keepdata_1 |
---|
3310 | if (strcmp(UvData.FileType{2},'civx')||strcmp(UvData.FileType{2},'civdata'))&& ~strcmp(FieldName_1,'get_field...') |
---|
3311 | test_veltype_1=1; |
---|
3312 | set(handles.VelType_1,'Visible','on') |
---|
3313 | menu=set_veltype_display(ParamOut_1.CivStage,UvData.FileType{2}); |
---|
3314 | index_menu=strcmp(ParamOut_1.VelType,menu); |
---|
3315 | set(handles.VelType_1,'Value',1+find(index_menu,1)) |
---|
3316 | set(handles.VelType_1,'String',[{''};menu]) |
---|
3317 | else |
---|
3318 | set(handles.VelType_1,'Visible','off') |
---|
3319 | end |
---|
3320 | % update the second field menu: the same quantity |
---|
3321 | if isstruct(ParamOut_1) |
---|
3322 | % display the FieldName menu from the input file and pick the selected one: |
---|
3323 | FieldList=get(handles.FieldName_1,'String'); |
---|
3324 | field_index=strcmp(ParamOut_1.FieldName,FieldList); |
---|
3325 | if ~isempty(field_index) |
---|
3326 | set(handles.FieldName_1,'Value',find(field_index,1)) |
---|
3327 | end |
---|
3328 | end |
---|
3329 | end |
---|
3330 | if test_veltype||test_veltype_1 |
---|
3331 | set(handles.FixVelType,'Visible','on') |
---|
3332 | else |
---|
3333 | set(handles.FixVelType,'Visible','off') |
---|
3334 | end |
---|
3335 | |
---|
3336 | %% introduce w as background image by default for a new series (only for nbdim=2) |
---|
3337 | if ~isfield(UvData,'NewSeries') |
---|
3338 | UvData.NewSeries=1; |
---|
3339 | end |
---|
3340 | %put W as background image by default if NbDim=2: |
---|
3341 | if UvData.NewSeries && isequal(get(handles.SubField,'Value'),0) && isfield(Field{1},'W') && ~isempty(Field{1}.W) && ~isequal(Field{1}.NbDim,3); |
---|
3342 | set(handles.SubField,'Value',1); |
---|
3343 | set(handles.RootPath_1,'String','"') |
---|
3344 | set(handles.RootFile_1,'String','"') |
---|
3345 | set(handles.SubDir_1,'String','"'); |
---|
3346 | indices=fullfile_uvmat('','','','',NomType,num_i1,num_i2,num_j1,num_j2); |
---|
3347 | set(handles.FileIndex_1,'String',indices) |
---|
3348 | set(handles.FileExt_1,'String','"'); |
---|
3349 | set(handles.FieldName_1,'Visible','on'); |
---|
3350 | set(handles.FieldName_1,'Visible','on'); |
---|
3351 | set(handles.RootPath_1,'Visible','on') |
---|
3352 | set(handles.RootFile_1,'Visible','on') |
---|
3353 | set(handles.SubDir_1,'Visible','on'); |
---|
3354 | set(handles.FileIndex_1,'Visible','on'); |
---|
3355 | set(handles.FileExt_1,'Visible','on'); |
---|
3356 | set(handles.FieldName_1,'Visible','on'); |
---|
3357 | Field{1}.AName='w'; |
---|
3358 | end |
---|
3359 | |
---|
3360 | %% display time value of the current file |
---|
3361 | abstime=[];%default inputs |
---|
3362 | dt=[]; |
---|
3363 | TimeUnit=''; |
---|
3364 | if isfield(UvData,'TimeUnit') |
---|
3365 | TimeUnit=UvData.TimeUnit;%retrieve info from update_rootinfo |
---|
3366 | end |
---|
3367 | TimeName=get(handles.TimeName,'String'); |
---|
3368 | |
---|
3369 | % time from xml file or video movie |
---|
3370 | if strcmp(TimeName,'xml')||strcmp(TimeName,'video') |
---|
3371 | if isempty(num_i2)||isnan(num_i2) |
---|
3372 | num_i2=num_i1; |
---|
3373 | end |
---|
3374 | if isempty(num_j1)||isnan(num_j1) |
---|
3375 | num_j1=1; |
---|
3376 | end |
---|
3377 | if isempty(num_j2)||isnan(num_j2) |
---|
3378 | num_j2=num_j1; |
---|
3379 | end |
---|
3380 | siz=size(UvData.XmlData{1}.Time); |
---|
3381 | 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) |
---|
3382 | 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 |
---|
3383 | dt=(UvData.XmlData{1}.Time(num_i2+1,num_j2+1)-UvData.XmlData{1}.Time(num_i1+1,num_j1+1)); |
---|
3384 | Field{1}.Dt=dt; |
---|
3385 | if isfield(UvData.XmlData{1},'TimeUnit') |
---|
3386 | TimeUnit=UvData.XmlData{1}.TimeUnit; |
---|
3387 | end |
---|
3388 | end |
---|
3389 | end |
---|
3390 | |
---|
3391 | % time in the input file, not defined in a xml file or movie |
---|
3392 | if isempty(abstime) |
---|
3393 | if strcmp(TimeName,'civdata')||strcmp(TimeName,'civx')||strcmp(TimeName,'timestamp') |
---|
3394 | abstime=Field{1}.Time; |
---|
3395 | elseif ~isempty(regexp(TimeName,'^att:', 'once')) |
---|
3396 | abstime=Field{1}.(TimeName(5:end));%the time is an attribute selected by get_file |
---|
3397 | if isfield(Field{1},[TimeName(5:end) 'Unit']) |
---|
3398 | TimeUnit=Field{1}.([TimeName(5:end) 'Unit']); |
---|
3399 | else |
---|
3400 | TimeUnit=''; |
---|
3401 | end |
---|
3402 | elseif ~isempty(regexp(TimeName,'^var:')) |
---|
3403 | abstime=Field{1}.(TimeName(5:end));%the time is a variale selected by get_file |
---|
3404 | % TODO: look for time unit attribute |
---|
3405 | elseif ~isempty(regexp(TimeName,'^dim:')) |
---|
3406 | abstime=str2num(get(handles.i1,'String')); |
---|
3407 | TimeUnit='index'; |
---|
3408 | end |
---|
3409 | if isfield(Field{1},'Dt') |
---|
3410 | dt=Field{1}.Dt;%dt read from the netcdf input file |
---|
3411 | elseif numel(Field)==2 && isfield(Field{2},'Dt')%dt obtained from the second field if not defined in the first |
---|
3412 | dt=Field{2}.Dt;%dt read from the netcdf input file |
---|
3413 | end |
---|
3414 | end |
---|
3415 | set(handles.TimeValue,'String',num2str(abstime)) |
---|
3416 | |
---|
3417 | %% display time value of the second current file if relevant |
---|
3418 | abstime_1=[]; |
---|
3419 | if ~isempty(FileName_1) |
---|
3420 | TimeName_1=get(handles.TimeName_1,'String');% indicate whether time is from xml or video |
---|
3421 | % time from xml file or video movie as a second file series |
---|
3422 | if strcmp(TimeName_1,'xml')||strcmp(TimeName_1,'video') |
---|
3423 | if numel(UvData.XmlData)==2 |
---|
3424 | if isempty(i2_1) |
---|
3425 | i2_1=num_i1; |
---|
3426 | end |
---|
3427 | if isempty(j1_1) |
---|
3428 | j1_1=1; |
---|
3429 | end |
---|
3430 | if isempty(j2_1) |
---|
3431 | j2_1=j1_1; |
---|
3432 | end |
---|
3433 | siz=size(UvData.XmlData{2}.Time); |
---|
3434 | if ~isempty(i1_1) && siz(1)>=max(i1_1+1,i2_1+1) && siz(2)>=max(j1_1+1,j2_1+1) |
---|
3435 | 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 |
---|
3436 | Field{2}.Dt=(UvData.XmlData{2}.Time(i2_1+1,j2_1+1)-UvData.XmlData{2}.Time(i1_1+1,j1_1+1)); |
---|
3437 | end |
---|
3438 | end |
---|
3439 | end |
---|
3440 | |
---|
3441 | % get time in the input file of the second series, not defined in a xml file or movie |
---|
3442 | if isempty(abstime_1) && numel(Field)==2 |
---|
3443 | if strcmp(TimeName_1,'civdata')||strcmp(TimeName_1,'civx') |
---|
3444 | abstime_1=Field{2}.Time; |
---|
3445 | elseif ~isempty(regexp(TimeName_1,'^att:')) ||~isempty(regexp(TimeName_1,'^dim:'))||~isempty(regexp(TimeName_1,'^var:')) |
---|
3446 | abstime_1=Field{2}.(TimeName_1(5:end));%the time is an attribute or variale selected by get_file |
---|
3447 | end |
---|
3448 | end |
---|
3449 | set(handles.TimeValue_1,'String',num2str(abstime_1,5)) |
---|
3450 | end |
---|
3451 | |
---|
3452 | if isempty(dt)||isequal(dt,0) |
---|
3453 | set(handles.Dt_txt,'String','') |
---|
3454 | else |
---|
3455 | if isempty(TimeUnit) |
---|
3456 | set(handles.Dt_txt,'String',['Dt=' num2str(1000*dt,3) ' 10^(-3)'] ) |
---|
3457 | else |
---|
3458 | set(handles.Dt_txt,'String',['Dt=' num2str(1000*dt,3) ' m' TimeUnit] ) |
---|
3459 | end |
---|
3460 | end |
---|
3461 | |
---|
3462 | %% Time title with unit |
---|
3463 | if isempty(abstime)&&isempty(abstime_1) |
---|
3464 | Time_title=''; |
---|
3465 | else |
---|
3466 | Time_title='Time'; |
---|
3467 | if ~isempty(TimeUnit) |
---|
3468 | Time_title=['Time (' TimeUnit ')']; |
---|
3469 | end |
---|
3470 | end |
---|
3471 | set(handles.Time_title,'String',Time_title) |
---|
3472 | |
---|
3473 | %% store the current open names, fieldname and vel types in uvmat interface |
---|
3474 | UvData.FileName_1=FileName_1; |
---|
3475 | UvData.ParamOut_1=ParamOut_1; |
---|
3476 | if numel(Field)==2 |
---|
3477 | UvData.Field_1=Field{2}; %store the second field for possible use at next RUN |
---|
3478 | end |
---|
3479 | |
---|
3480 | %% apply coordinate transform or other user fct |
---|
3481 | transform=get(handles.TransformPath,'UserData'); |
---|
3482 | if isempty(transform) |
---|
3483 | UvData.Field=Field{1}; |
---|
3484 | else |
---|
3485 | XmlData=[];%default |
---|
3486 | XmlData_1=[];%default |
---|
3487 | if isfield(UvData,'XmlData')%use geometry calib recorded from the ImaDoc xml file as first priority |
---|
3488 | XmlData=UvData.XmlData{1}; |
---|
3489 | if numel(UvData.XmlData)==2 |
---|
3490 | XmlData_1=UvData.XmlData{2}; |
---|
3491 | end |
---|
3492 | end |
---|
3493 | switch nargin(transform) |
---|
3494 | case 4 |
---|
3495 | if length(Field)==2 |
---|
3496 | UvData.Field=transform(Field{1},XmlData,Field{2},XmlData_1); |
---|
3497 | else |
---|
3498 | UvData.Field=transform(Field{1},XmlData); |
---|
3499 | end |
---|
3500 | case 3 |
---|
3501 | if length(Field)==2 |
---|
3502 | UvData.Field=transform(Field{1},XmlData,Field{2}); |
---|
3503 | else |
---|
3504 | UvData.Field=transform(Field{1},XmlData); |
---|
3505 | end |
---|
3506 | case 2 |
---|
3507 | UvData.Field=transform(Field{1},XmlData); |
---|
3508 | case 1 |
---|
3509 | UvData.Field=transform(Field{1}); |
---|
3510 | end |
---|
3511 | end |
---|
3512 | |
---|
3513 | %% calculate tps coefficients if needed |
---|
3514 | UvData.Field=tps_coeff_field(UvData.Field,check_proj_tps); |
---|
3515 | |
---|
3516 | %% get bounds and dimensions of the input field |
---|
3517 | UvData.Field=find_field_bounds(UvData.Field); |
---|
3518 | |
---|
3519 | testnewseries=UvData.NewSeries; |
---|
3520 | UvData.NewSeries=0;% put to 0 the test for a new field series (set by RootPath_callback) |
---|
3521 | |
---|
3522 | %% reset the min and max of scalar if only the mask is displayed(TODO: check the need) |
---|
3523 | % if isfield(UvData,'Mask')&& ~isfield(UvData,'A') |
---|
3524 | % set(handles.num_MinA,'String','0') |
---|
3525 | % set(handles.num_MaxA,'String','255') |
---|
3526 | % end |
---|
3527 | |
---|
3528 | %% usual 1D (x,y) plots |
---|
3529 | if UvData.Field.NbDim<=1 |
---|
3530 | set(handles.Objects,'Visible','off') |
---|
3531 | [PlotType,PlotParamOut,haxes]=plot_field(UvData.Field,handles.PlotAxes,read_GUI(handles.uvmat)); |
---|
3532 | UvData.PlotAxes=UvData.Field; %store data for further plot modifications |
---|
3533 | errormsg=fill_GUI(PlotParamOut,handles.uvmat); |
---|
3534 | for list={'Scalar','Vectors'} |
---|
3535 | if ~isfield(PlotParamOut,list{1}) |
---|
3536 | set(handles.(list{1}),'Visible','off') |
---|
3537 | end |
---|
3538 | end |
---|
3539 | set(handles.uvmat,'UserData',UvData) |
---|
3540 | %% 2D or 3D fieldname are generally projected |
---|
3541 | else |
---|
3542 | set(handles.Objects,'Visible','on') |
---|
3543 | |
---|
3544 | %% Plot the projections on the selected projection objects |
---|
3545 | %if no projection object exists, create a default one |
---|
3546 | if isempty(UvData.ProjObject{1}) |
---|
3547 | set(handles.ListObject,'Value',1) |
---|
3548 | set(handles.ListObject,'String',{'plane'}) |
---|
3549 | UvData.ProjObject{1}.Type='plane';%main plotting plane |
---|
3550 | UvData.ProjObject{1}.ProjMode='projection';%main plotting plane |
---|
3551 | UvData.ProjObject{1}.DisplayHandle.uvmat=[]; %plane not visible in uvmat |
---|
3552 | UvData.ProjObject{1}.DisplayHandle.view_field=[]; %plane not visible in uvmat |
---|
3553 | set(handles.ListObject_1,'Value',1) |
---|
3554 | set(handles.ListObject_1,'String',{'plane'}) |
---|
3555 | if UvData.Field.NbDim==3 %3D case |
---|
3556 | % ZBounds(1)=UvData.Field.ZMin; %minimum for the Z slider |
---|
3557 | % ZBounds(2)=UvData.Field.ZMax;%maximum for the Z slider |
---|
3558 | UvData.ProjObject{1}.NbDim=3;%test for 3D objects |
---|
3559 | UvData.ProjObject{1}.RangeZ=UvData.Field.CoordMesh;%main plotting plane |
---|
3560 | UvData.ProjObject{1}.Coord(1,3)=(UvData.Field.ZMin+UvData.Field.ZMax)/2;%section at a middle plane chosen |
---|
3561 | UvData.ProjObject{1}.Angle=[0 0 0]; |
---|
3562 | elseif isfield(UvData,'Z') |
---|
3563 | %multilevel case (single menuplane in a 3D space) |
---|
3564 | if isfield(UvData,'CoordType')&& isequal(UvData.CoordType,'phys') && isfield(UvData,'XmlData') |
---|
3565 | XmlData=UvData.XmlData{1}; |
---|
3566 | if isfield(XmlData,'PlanePos') |
---|
3567 | UvData.ProjObject{1}.Coord=XmlData.PlanePos(UvData.ZIndex,:); |
---|
3568 | end |
---|
3569 | if isfield(XmlData,'PlaneAngle') |
---|
3570 | siz=size(XmlData.PlaneAngle); |
---|
3571 | indangle=min(siz(1),UvData.ZIndex);%take first angle if a single angle is defined (translating scanning) |
---|
3572 | UvData.ProjObject{1}.PlaneAngle=XmlData.PlaneAngle(indangle,:); |
---|
3573 | end |
---|
3574 | elseif isfield(UvData,'ZIndex') |
---|
3575 | UvData.ProjObject{1}.ZObject=UvData.ZIndex; |
---|
3576 | end |
---|
3577 | end |
---|
3578 | end |
---|
3579 | IndexObj=get(handles.ListObject_1,'Value');%selected projection object for main view |
---|
3580 | if IndexObj> numel(UvData.ProjObject) |
---|
3581 | IndexObj=1;%select the first object if the selected one does not exist |
---|
3582 | set(handles.ListObject_1,'Value',1) |
---|
3583 | end |
---|
3584 | if get(handles.CheckViewField,'Value') |
---|
3585 | IndexObj_2=get(handles.ListObject,'Value');%selected projection object for view_field |
---|
3586 | if ~isequal(IndexObj_2,IndexObj(1)) |
---|
3587 | IndexObj(2)=IndexObj_2; |
---|
3588 | end |
---|
3589 | end |
---|
3590 | plot_handles{1}=handles; |
---|
3591 | if isfield(UvData,'plotaxes')%case of movies |
---|
3592 | haxes(1)=UvData.plotaxes; |
---|
3593 | else |
---|
3594 | haxes(1)=handles.PlotAxes; |
---|
3595 | end |
---|
3596 | PlotParam{1}=read_GUI(handles.uvmat); |
---|
3597 | %default settings if vectors not visible |
---|
3598 | if ~isfield(PlotParam{1},'Vectors') |
---|
3599 | PlotParam{1}.Vectors.MaxVec=1; |
---|
3600 | PlotParam{1}.Vectors.MinVec=0; |
---|
3601 | PlotParam{1}.Vectors.CheckFixVecColor=1; |
---|
3602 | PlotParam{1}.Vectors.ColCode1=0.33; |
---|
3603 | PlotParam{1}.Vectors.ColCode2=0.66; |
---|
3604 | PlotParam{1}.Vectors.ColorScalar={''}; |
---|
3605 | PlotParam{1}.Vectors.ColorCode= {'rgb'}; |
---|
3606 | end |
---|
3607 | %PosColorbar{1}=UvData.OpenParam.PosColorbar;%prescribe the colorbar position on the uvmat interface |
---|
3608 | |
---|
3609 | %% second projection object (view_field display) |
---|
3610 | if length( IndexObj)==2 |
---|
3611 | view_field_handle=findobj(allchild(0),'tag','view_field');%handles of the view_field GUI |
---|
3612 | if ~isempty(view_field_handle) |
---|
3613 | plot_handles{2}=guidata(view_field_handle); |
---|
3614 | haxes(2)=plot_handles{2}.PlotAxes; |
---|
3615 | PlotParam{2}=read_GUI(view_field_handle); |
---|
3616 | %PosColorbar{2}='*'; %TODO: deal with colorbar position on view_field |
---|
3617 | end |
---|
3618 | end |
---|
3619 | |
---|
3620 | %% loop on the projection objects: one or two |
---|
3621 | |
---|
3622 | for imap=1:numel(IndexObj) |
---|
3623 | iobj=IndexObj(imap); |
---|
3624 | if numel(UvData.ProjObject)<iobj |
---|
3625 | break |
---|
3626 | end |
---|
3627 | if UvData.Field.NbDim==3 |
---|
3628 | UvData.ProjObject{iobj}.NbDim=3;%test for 3D objects |
---|
3629 | if ~isfield(UvData.ProjObject{iobj},'RangeZ') |
---|
3630 | UvData.ProjObject{iobj}.RangeZ=UvData.Field.CoordMesh;%main plotting plane |
---|
3631 | end |
---|
3632 | if ~(isfield(UvData.ProjObject{iobj},'Coord') && UvData.ProjObject{iobj}.Coord(1,3)<UvData.Field.ZMax && UvData.ProjObject{iobj}.Coord(1,3)>UvData.Field.ZMin) |
---|
3633 | UvData.ProjObject{iobj}.Coord(1,3)=(UvData.Field.ZMin+UvData.Field.ZMax)/2;%section at a middle plane chosen |
---|
3634 | end |
---|
3635 | end |
---|
3636 | [ObjectData,errormsg]=proj_field(UvData.Field,UvData.ProjObject{iobj});% project field on the object |
---|
3637 | if ~isempty(errormsg) |
---|
3638 | return |
---|
3639 | end |
---|
3640 | if testnewseries |
---|
3641 | PlotParam{imap}.Scalar.CheckBW=[]; %B/W option depends on the input field (image or scalar) |
---|
3642 | if isfield(ObjectData,'CoordUnit') |
---|
3643 | PlotParam{imap}.Axes.CheckFixAspectRatio=1;% set x and y scaling equal if CoordUnit is defined (common unit for x and y) |
---|
3644 | PlotParam{imap}.Axes.AspectRatio=1; %set aspect ratio to 1 |
---|
3645 | end |
---|
3646 | end |
---|
3647 | %use of mask (TODO: check) |
---|
3648 | if isfield(ObjectData,'NbDim') && isequal(ObjectData.NbDim,2) && isfield(ObjectData,'Mask') && isfield(ObjectData,'A') |
---|
3649 | flag_mask=double(ObjectData.Mask>200);%=0 for masked regions |
---|
3650 | Coord_x=ObjectData.Coord_x;%x coordiantes for the scalar field |
---|
3651 | Coord_y=ObjectData.Coord_y;%y coordinates for the scalar field |
---|
3652 | MaskX=ObjectData.MaskX;%x coordiantes for the mask |
---|
3653 | MaskY=ObjectData.MaskY;%y coordiantes for the mask |
---|
3654 | if ~isequal(MaskX,Coord_x)||~isequal(MaskY,Coord_y) |
---|
3655 | nxy=size(flag_mask); |
---|
3656 | sizpx=(ObjectData.MaskX(end)-ObjectData.MaskX(1))/(nxy(2)-1);%size of a mask pixel |
---|
3657 | sizpy=(ObjectData.MaskY(1)-ObjectData.MaskY(end))/(nxy(1)-1); |
---|
3658 | x_mask=ObjectData.MaskX(1):sizpx:ObjectData.MaskX(end); % pixel x coordinates for image display |
---|
3659 | y_mask=ObjectData.MaskY(1):-sizpy:ObjectData.MaskY(end);% pixel x coordinates for image display |
---|
3660 | %project on the positions of the scalar |
---|
3661 | npxy=size(ObjectData.A); |
---|
3662 | dxy(1)=(ObjectData.Coord_y(end)-ObjectData.Coord_y(1))/(npxy(1)-1);%grid mesh in y |
---|
3663 | dxy(2)=(ObjectData.Coord_x(end)-ObjectData.Coord_x(1))/(npxy(2)-1);%grid mesh in x |
---|
3664 | xi=ObjectData.Coord_x(1):dxy(2):ObjectData.Coord_x(end); |
---|
3665 | yi=ObjectData.Coord_y(1):dxy(1):ObjectData.Coord_y(end); |
---|
3666 | [XI,YI]=meshgrid(xi,yi);% creates the matrix of regular coordinates |
---|
3667 | flag_mask = interp2(x_mask,y_mask,flag_mask,XI,YI); |
---|
3668 | end |
---|
3669 | AClass=class(ObjectData.A); |
---|
3670 | ObjectData.A=flag_mask.*double(ObjectData.A); |
---|
3671 | ObjectData.A=feval(AClass,ObjectData.A); |
---|
3672 | end |
---|
3673 | set(handles.uvmat,'UserData',UvData) |
---|
3674 | if ~isempty(ObjectData) |
---|
3675 | %PlotType='none'; %default |
---|
3676 | if imap==2 && isempty(view_field_handle) |
---|
3677 | view_field(ObjectData) |
---|
3678 | else |
---|
3679 | [PlotType,PlotParamOut]=plot_field(ObjectData,haxes(imap),PlotParam{imap}); |
---|
3680 | if imap==1 |
---|
3681 | errormsg=fill_GUI(PlotParamOut,handles.uvmat); |
---|
3682 | else |
---|
3683 | errormsg=fill_GUI(PlotParamOut,view_field_handle); |
---|
3684 | end |
---|
3685 | for list={'Scalar','Vectors'} |
---|
3686 | if ~isfield(PlotParamOut,list{1}) |
---|
3687 | set(plot_handles{imap}.(list{1}),'Visible','off') |
---|
3688 | end |
---|
3689 | end |
---|
3690 | if isfield(Field,'CoordMesh')&&~isempty(Field.CoordMesh) |
---|
3691 | ObjectData.CoordMesh=Field.CoordMesh; % gives an estimated mesh size (useful for mouse action on the plot) |
---|
3692 | end |
---|
3693 | end |
---|
3694 | end |
---|
3695 | end |
---|
3696 | |
---|
3697 | %% update the mask |
---|
3698 | if isequal(get(handles.CheckMask,'Value'),1)%if the mask option is on |
---|
3699 | update_mask(handles); |
---|
3700 | end |
---|
3701 | |
---|
3702 | %% prepare the menus of histograms and plot them (histogram of the whole volume in 3D case) |
---|
3703 | menu_histo=(UvData.Field.ListVarName)';%list of field variables to be displayed for the menu of histogram display |
---|
3704 | ind_skip=[]; |
---|
3705 | % nb_histo=1; |
---|
3706 | Ustring=''; |
---|
3707 | Vstring=''; |
---|
3708 | % suppress axes from the histogram menu |
---|
3709 | for ivar=1:numel(menu_histo)%l loop on field variables: |
---|
3710 | if isfield(UvData.Field,'VarAttribute') && numel(UvData.Field.VarAttribute)>=ivar && isfield(UvData.Field.VarAttribute{ivar},'Role') |
---|
3711 | Role=UvData.Field.VarAttribute{ivar}.Role; |
---|
3712 | switch Role |
---|
3713 | case {'coord_x','coord_y','coord_z','dimvar'} |
---|
3714 | ind_skip=[ind_skip ivar]; |
---|
3715 | case {'vector_x'} |
---|
3716 | Ustring=UvData.Field.ListVarName{ivar}; |
---|
3717 | ind_skip=[ind_skip ivar]; |
---|
3718 | case {'vector_y'} |
---|
3719 | Vstring=UvData.Field.ListVarName{ivar}; |
---|
3720 | ind_skip=[ind_skip ivar]; |
---|
3721 | end |
---|
3722 | end |
---|
3723 | DimCell=UvData.Field.VarDimName{ivar}; |
---|
3724 | DimName=''; |
---|
3725 | if ischar(DimCell) |
---|
3726 | DimName=DimCell; |
---|
3727 | elseif iscell(DimCell)&& numel(DimCell)==1 |
---|
3728 | DimName=DimCell{1}; |
---|
3729 | end |
---|
3730 | if strcmp(DimName,menu_histo{ivar}) |
---|
3731 | ind_skip=[ind_skip ivar]; |
---|
3732 | end |
---|
3733 | end |
---|
3734 | menu_histo(ind_skip)=[];% remove skipped items |
---|
3735 | if ~isempty(Ustring) |
---|
3736 | menu_histo=[{[Ustring ',' Vstring]};menu_histo];% add U, V at the beginning if they exist |
---|
3737 | end |
---|
3738 | |
---|
3739 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
---|
3740 | % display menus and plot histograms |
---|
3741 | test_v=0; |
---|
3742 | if ~isempty(menu_histo) |
---|
3743 | set(handles.histo1_menu,'Value',1) |
---|
3744 | set(handles.histo1_menu,'String',menu_histo) |
---|
3745 | histo1_menu_Callback(handles.histo1_menu, [], handles)% plot first histogram |
---|
3746 | end |
---|
3747 | end |
---|
3748 | |
---|
3749 | if UvData.Field.NbDim==3 |
---|
3750 | set(handles.CheckEditObject,'Value',1) |
---|
3751 | CheckEditObject_Callback(handles.uvmat, [], handles) |
---|
3752 | end |
---|
3753 | %ResizeFcn(handles.uvmat,[],handles) |
---|
3754 | set(handles.uvmat,'Pointer',pointer) |
---|
3755 | |
---|
3756 | %------------------------------------------------------------------------ |
---|
3757 | function histo1_menu_Callback(hObject, eventdata, handles) |
---|
3758 | %-------------------------------------------- |
---|
3759 | %% get the current field stored in uvmat user data |
---|
3760 | UvData=get(handles.uvmat,'UserData'); |
---|
3761 | Field=UvData.Field; |
---|
3762 | |
---|
3763 | %% get from the menu 'histo1_menu' the name(s) of the fields to use |
---|
3764 | histo_menu=get(handles.histo1_menu,'String'); |
---|
3765 | histo_value=get(handles.histo1_menu,'Value'); |
---|
3766 | FieldName=histo_menu{histo_value}; |
---|
3767 | r=regexp(FieldName,'(?<var1>.*)(?<sep>,)(?<var2>.*)','names'); |
---|
3768 | FieldName_2=''; |
---|
3769 | if ~isempty(r) |
---|
3770 | FieldName=r.var1;% name of first variable |
---|
3771 | FieldName_2=r.var2;% name of second variable |
---|
3772 | end |
---|
3773 | if ~isfield(UvData.Field,FieldName) |
---|
3774 | msgbox_uvmat('ERROR',['no field ' FieldName ' for histogram']) |
---|
3775 | return |
---|
3776 | end |
---|
3777 | |
---|
3778 | %% extract the fields to use |
---|
3779 | % eliminate false data if relevant (false flag FF exists) |
---|
3780 | check_false=0; |
---|
3781 | if isfield(Field,'FF') && ~isempty(Field.FF) && isequal(size(Field.FF),size(Field.(FieldName))) |
---|
3782 | indsel=find(Field.FF==0);%find values marked as false |
---|
3783 | if ~isempty(indsel) |
---|
3784 | FieldHisto=Field.(FieldName)(indsel);%field of the first variable (U) |
---|
3785 | if ~isempty(FieldName_2) |
---|
3786 | if isfield(Field,'NbDim') && Field.NbDim==3 |
---|
3787 | FieldHisto(:,:,:,2)=Field.(FieldName_2)(indsel);%field of the second variable (U) |
---|
3788 | else |
---|
3789 | FieldHisto(:,:,2)=Field.(FieldName_2)(indsel);%field of the second variable (U) |
---|
3790 | end |
---|
3791 | end |
---|
3792 | check_false=1; |
---|
3793 | end |
---|
3794 | end |
---|
3795 | % no false data |
---|
3796 | if ~check_false |
---|
3797 | FieldHisto=Field.(FieldName);%field of the first variable (U) |
---|
3798 | if ~isempty(FieldName_2) |
---|
3799 | if isfield(Field,'NbDim') && Field.NbDim==3 |
---|
3800 | FieldHisto(:,:,:,2)=Field.(FieldName_2);%field of the second variable (V) |
---|
3801 | else |
---|
3802 | FieldHisto(:,:,2)=Field.(FieldName_2);%field of the second variable (V) |
---|
3803 | end |
---|
3804 | end |
---|
3805 | end |
---|
3806 | |
---|
3807 | %% calculate and plot histogram |
---|
3808 | if isempty(Field) |
---|
3809 | msgbox_uvmat('ERROR',['empty field ' FieldName]) |
---|
3810 | else |
---|
3811 | nxy=size(FieldHisto); |
---|
3812 | Amin=double(min(min(min(min(FieldHisto)))));%min of field value |
---|
3813 | Amax=double(max(max(max(max(FieldHisto)))));%max of field value |
---|
3814 | if isequal(Amin,Amax) |
---|
3815 | cla(handles.HistoAxes) |
---|
3816 | else |
---|
3817 | Histo.ListVarName={FieldName,'histo'}; |
---|
3818 | if isfield(Field,'NbDim') && isequal(Field.NbDim,3) |
---|
3819 | Histo.VarDimName={FieldName,FieldName}; %dimensions for the histogram |
---|
3820 | else |
---|
3821 | if numel(nxy)==2 |
---|
3822 | Histo.VarDimName={FieldName,FieldName}; %dimensions for the histogram |
---|
3823 | else |
---|
3824 | Histo.VarDimName={FieldName,{FieldName,'component'}}; %dimensions for the histogram |
---|
3825 | end |
---|
3826 | end |
---|
3827 | %unit |
---|
3828 | units=[]; %default |
---|
3829 | for ivar=1:numel(Field.ListVarName) |
---|
3830 | if strcmp(Field.ListVarName{ivar},FieldName) |
---|
3831 | if isfield(Field,'VarAttribute') && numel(Field.VarAttribute)>=ivar && isfield(Field.VarAttribute{ivar},'units') |
---|
3832 | units=Field.VarAttribute{ivar}.units; |
---|
3833 | break |
---|
3834 | end |
---|
3835 | end |
---|
3836 | end |
---|
3837 | if ~isempty(units) |
---|
3838 | Histo.VarAttribute{1}.units=units; |
---|
3839 | end |
---|
3840 | Histo.(FieldName)=linspace(Amin,Amax,50); %absissa values for histo |
---|
3841 | if isfield(Field,'NbDim') && isequal(Field.NbDim,3) |
---|
3842 | C=reshape(double(FieldHisto),1,[]);% reshape in a vector |
---|
3843 | Histo.histo(:,1)=hist(C, Histo.(FieldName)); %calculate histogram |
---|
3844 | else |
---|
3845 | for col=1:size(FieldHisto,3) |
---|
3846 | B=FieldHisto(:,:,col); |
---|
3847 | C=reshape(double(B),1,nxy(1)*nxy(2));% reshape in a vector |
---|
3848 | Histo.histo(:,col)=hist(C, Histo.(FieldName)); %calculate histogram |
---|
3849 | end |
---|
3850 | end |
---|
3851 | plot_field(Histo,handles.HistoAxes); |
---|
3852 | hlegend=legend; |
---|
3853 | if isempty(FieldName_2) |
---|
3854 | set(hlegend,'String',FieldName) |
---|
3855 | else |
---|
3856 | set(hlegend,'String',{FieldName;FieldName_2}) |
---|
3857 | end |
---|
3858 | end |
---|
3859 | end |
---|
3860 | |
---|
3861 | %------------------------------------------------------------------------ |
---|
3862 | % --- translate coordinate to matrix index |
---|
3863 | %------------------------------------------------------------------------ |
---|
3864 | function [indx,indy]=pos2ind(x0,rangx0,nxy) |
---|
3865 | indx=1+round((nxy(2)-1)*(x0-rangx0(1))/(rangx0(2)-rangx0(1)));% index x of pixel |
---|
3866 | indy=1+round((nxy(1)-1)*(y12-rangy0(1))/(rangy0(2)-rangy0(1)));% index y of pixel |
---|
3867 | |
---|
3868 | %------------------------------------------------------------------------ |
---|
3869 | % --- Executes on button press in 'CheckZoom'. |
---|
3870 | %------------------------------------------------------------------------ |
---|
3871 | function CheckZoom_Callback(hObject, eventdata, handles) |
---|
3872 | |
---|
3873 | if get(handles.CheckZoom,'Value') |
---|
3874 | set(handles.CheckFixLimits,'Value',1)% propose by default fixed limits for the plotting axes |
---|
3875 | set(handles.CheckZoomFig,'Value',0)%desactivate zoom fig |
---|
3876 | end |
---|
3877 | |
---|
3878 | |
---|
3879 | %------------------------------------------------------------------------ |
---|
3880 | % --- Executes on button press in CheckZoomFig. |
---|
3881 | %------------------------------------------------------------------------ |
---|
3882 | function CheckZoomFig_Callback(hObject, eventdata, handles) |
---|
3883 | |
---|
3884 | if get(handles.CheckZoomFig,'Value') |
---|
3885 | set(handles.CheckZoom,'value',0) |
---|
3886 | end |
---|
3887 | |
---|
3888 | %------------------------------------------------------------------------ |
---|
3889 | % --- Executes on button press in 'CheckFixLimits'. |
---|
3890 | %------------------------------------------------------------------------ |
---|
3891 | function CheckFixLimits_Callback(hObject, eventdata, handles) |
---|
3892 | |
---|
3893 | if ~get(handles.CheckFixLimits,'Value') |
---|
3894 | update_plot(handles) |
---|
3895 | set(handles.CheckZoom,'Value',0) |
---|
3896 | end |
---|
3897 | |
---|
3898 | %------------------------------------------------------------------------ |
---|
3899 | % --- Executes on button press in CheckFixAspectRatio. |
---|
3900 | function CheckFixAspectRatio_Callback(hObject, eventdata, handles) |
---|
3901 | %------------------------------------------------------------------------ |
---|
3902 | update_plot(handles); |
---|
3903 | |
---|
3904 | %------------------------------------------------------------------------ |
---|
3905 | function num_AspectRatio_Callback(hObject, eventdata, handles) |
---|
3906 | %------------------------------------------------------------------------ |
---|
3907 | set(handles.CheckFixAspectRatio,'Value',1)% select the fixed aspect ratio button |
---|
3908 | update_plot(handles); |
---|
3909 | |
---|
3910 | %------------------------------------------------------------------------ |
---|
3911 | %----Executes on button press in 'record': records the current flags of manual correction. |
---|
3912 | %------------------------------------------------------------------------ |
---|
3913 | function record_Callback(hObject, eventdata, handles) |
---|
3914 | |
---|
3915 | [RootPath,SubDir,RootFile,FileIndices,FileExt]=read_file_boxes(handles); |
---|
3916 | FileName=[fullfile(RootPath,SubDir,RootFile) FileIndices FileExt]; |
---|
3917 | [erread,message]=fileattrib(FileName); |
---|
3918 | if ~isempty(message) && ~isequal(message.UserWrite,1) |
---|
3919 | msgbox_uvmat('ERROR',['no writting access to ' FileName]) |
---|
3920 | return |
---|
3921 | end |
---|
3922 | MenuVelType=get(handles.VelType,'String'); |
---|
3923 | test_civ2=strcmp(MenuVelType{get(handles.VelType,'Value')},'civ2'); |
---|
3924 | test_civ1=strcmp(MenuVelType{get(handles.VelType,'Value')},'civ1'); |
---|
3925 | if ~test_civ2 && ~test_civ1 |
---|
3926 | msgbox_uvmat('ERROR','manual correction only possible for CIV1 or CIV2 velocity fields') |
---|
3927 | end |
---|
3928 | if test_civ2 |
---|
3929 | nbname='nb_vec_2'; |
---|
3930 | flagname='Civ2_FF'; |
---|
3931 | CivStage=5; |
---|
3932 | end |
---|
3933 | if test_civ1 |
---|
3934 | nbname='nb_vec_1'; |
---|
3935 | flagname='Civ1_FF'; |
---|
3936 | CivStage=2; |
---|
3937 | end |
---|
3938 | %write fix flags in the netcdf file |
---|
3939 | UvData=get(handles.uvmat,'UserData'); |
---|
3940 | hhh=which('netcdf.open');% look for built-in matlab netcdf library |
---|
3941 | if ~isequal(hhh,'')% case of builtin Matlab netcdf library |
---|
3942 | nc=netcdf.open(FileName,'NC_WRITE'); |
---|
3943 | netcdf.reDef(nc); |
---|
3944 | netcdf.putAtt(nc,netcdf.getConstant('NC_GLOBAL'),'CivStage',CivStage); |
---|
3945 | dimid = netcdf.inqDimID(nc,nbname); |
---|
3946 | try |
---|
3947 | varid = netcdf.inqVarID(nc,flagname);% look for already existing fixflag variable |
---|
3948 | catch |
---|
3949 | varid=netcdf.defVar(nc,flagname,'double',dimid);%create fixflag variable if it does not exist |
---|
3950 | end |
---|
3951 | netcdf.endDef(nc); |
---|
3952 | netcdf.putVar(nc,varid,UvData.PlotAxes.FF); |
---|
3953 | netcdf.close(nc); |
---|
3954 | else %old netcdf library |
---|
3955 | netcdf_toolbox(FileName,AxeData,attrname,nbname,flagname) |
---|
3956 | end |
---|
3957 | |
---|
3958 | %------------------------------------------------------------------- |
---|
3959 | %----Correct the netcdf file, using toolbox (old versions of Matlab). |
---|
3960 | %------------------------------------------------------------------- |
---|
3961 | function netcdf_toolbox(FileName,AxeData,attrname,nbname,flagname) |
---|
3962 | nc=netcdf(FileName,'write'); %open netcdf file |
---|
3963 | result=redef(nc); |
---|
3964 | eval(['nc.' attrname '=1;']); |
---|
3965 | theDim=nc(nbname) ;% get the number of velocity vectors |
---|
3966 | nb_vectors=size(theDim); |
---|
3967 | var_FixFlag=ncvar(flagname,nc);% var_FixFlag will be written as the netcdf variable vec_FixFlag |
---|
3968 | var_FixFlag(1:nb_vectors)=AxeData.FF;% |
---|
3969 | fin=close(nc); |
---|
3970 | |
---|
3971 | %----------------------------------------------------------------------- |
---|
3972 | % --- Executes on button press in SubField |
---|
3973 | %----------------------------------------------------------------------- |
---|
3974 | function SubField_Callback(hObject, eventdata, handles) |
---|
3975 | |
---|
3976 | if get(handles.SubField,'Value')==0% if the subfield button is desactivated |
---|
3977 | desable_subfield(handles) |
---|
3978 | transform_fct_list=get(handles.TransformName,'String'); |
---|
3979 | transform_fct=transform_fct_list(get(handles.TransformName,'Value')); |
---|
3980 | if strcmp(transform_fct,'sub_field') |
---|
3981 | set(handles.TransformName,'Value',1)%suppress the sub_field transform |
---|
3982 | TransformName_Callback(hObject, eventdata, handles); |
---|
3983 | else |
---|
3984 | REFRESH_Callback(hObject, eventdata, handles) |
---|
3985 | end |
---|
3986 | else |
---|
3987 | fileinput_1=uigetfile_uvmat('select a second input file:',get(handles.RootPath,'String')); |
---|
3988 | if isempty(fileinput_1) |
---|
3989 | set(handles.SubField,'Value',0) |
---|
3990 | else |
---|
3991 | % refresh the current displayed field |
---|
3992 | display_file_name(handles,fileinput_1,2) |
---|
3993 | |
---|
3994 | %update list of recent files in the menubar |
---|
3995 | MenuFile_1=fileinput_1; |
---|
3996 | MenuFile_2=get(handles.MenuFile_1,'Label'); |
---|
3997 | MenuFile_3=get(handles.MenuFile_2,'Label'); |
---|
3998 | MenuFile_4=get(handles.MenuFile_3,'Label'); |
---|
3999 | MenuFile_5=get(handles.MenuFile_4,'Label'); |
---|
4000 | set(handles.MenuFile_1,'Label',MenuFile_1) |
---|
4001 | set(handles.MenuFile_2,'Label',MenuFile_2) |
---|
4002 | set(handles.MenuFile_3,'Label',MenuFile_3) |
---|
4003 | set(handles.MenuFile_4,'Label',MenuFile_4) |
---|
4004 | set(handles.MenuFile_5,'Label',MenuFile_5) |
---|
4005 | end |
---|
4006 | end |
---|
4007 | |
---|
4008 | %----------------------------------------------------------------------- |
---|
4009 | % --- desactivate display used for a second file series |
---|
4010 | %----------------------------------------------------------------------- |
---|
4011 | function desable_subfield(handles) |
---|
4012 | |
---|
4013 | set(handles.RootPath_1,'String','') |
---|
4014 | set(handles.RootFile_1,'String','') |
---|
4015 | set(handles.SubDir_1,'String',''); |
---|
4016 | set(handles.FileIndex_1,'String',''); |
---|
4017 | set(handles.FileExt_1,'String',''); |
---|
4018 | set(handles.RootPath_1,'Visible','off') |
---|
4019 | set(handles.RootFile_1,'Visible','off') |
---|
4020 | set(handles.SubDir_1,'Visible','off'); |
---|
4021 | set(handles.NomType_1,'Visible','off'); |
---|
4022 | set(handles.FileIndex_1,'Visible','off'); |
---|
4023 | set(handles.FileExt_1,'Visible','off'); |
---|
4024 | set(handles.TimeName_1,'String',''); |
---|
4025 | set(handles.TimeName_1,'Visible','off'); |
---|
4026 | set(handles.TimeValue_1,'String',''); |
---|
4027 | set(handles.TimeValue_1,'Visible','off'); |
---|
4028 | set(handles.FieldName_1,'Value',1);%set to blank state |
---|
4029 | set(handles.VelType_1,'Value',1);%set to blank state |
---|
4030 | set(handles.num_Opacity,'String','')% desactivate opacity setting |
---|
4031 | FieldList=get(handles.FieldName,'String'); |
---|
4032 | if numel(FieldList)>1 % if a choice of fields exists |
---|
4033 | set(handles.FieldName_1,'Value',1)% set second field choice to blank |
---|
4034 | set(handles.FieldName_1,'String',[{''};FieldList])% reproduce the menu FieldName plus a blank option |
---|
4035 | else |
---|
4036 | set(handles.FieldName_1,'String',{''})% set second field choice to blank |
---|
4037 | end |
---|
4038 | if ~strcmp(get(handles.VelType,'Visible'),'on') |
---|
4039 | set(handles.VelType_1,'Visible','off') |
---|
4040 | end |
---|
4041 | UvData=get(handles.uvmat,'UserData'); |
---|
4042 | if isfield(UvData,'XmlData_1') |
---|
4043 | UvData=rmfield(UvData,'XmlData_1'); |
---|
4044 | end |
---|
4045 | set(handles.uvmat,'UserData',UvData); |
---|
4046 | |
---|
4047 | %------------------------------------------------------------------------ |
---|
4048 | % --- read the data displayed for the input rootfile windows (new): TODO use read_GUI |
---|
4049 | %------------------------------------------------------------------------ |
---|
4050 | function [RootPath,SubDir,RootFile,FileIndices,FileExt]=read_file_boxes(handles) |
---|
4051 | |
---|
4052 | InputFile=read_GUI(handles.InputFile); |
---|
4053 | RootPath=InputFile.RootPath; |
---|
4054 | SubDir=regexprep(InputFile.SubDir,'/|\',''); |
---|
4055 | RootFile=regexprep(InputFile.RootFile,'/|\',''); |
---|
4056 | FileIndices=InputFile.FileIndex; |
---|
4057 | FileExt=InputFile.FileExt; |
---|
4058 | |
---|
4059 | |
---|
4060 | %------------------------------------------------------------------------ |
---|
4061 | % ---- read the data displayed for the second input rootfile windows |
---|
4062 | %------------------------------------------------------------------------ |
---|
4063 | function [RootPath_1,SubDir_1,RootFile_1,FileIndex_1,FileExt_1,NomType_1]=read_file_boxes_1(handles) |
---|
4064 | |
---|
4065 | RootPath_1=get(handles.RootPath_1,'String'); % read the data from the file1_input window |
---|
4066 | if isequal(get(handles.RootPath_1,'Visible'),'off') || isequal(RootPath_1,'"') |
---|
4067 | RootPath_1=get(handles.RootPath,'String'); |
---|
4068 | end; |
---|
4069 | SubDir_1=get(handles.SubDir_1,'String'); |
---|
4070 | if isequal(get(handles.SubDir_1,'Visible'),'off')|| isequal(SubDir_1,'"') |
---|
4071 | SubDir_1=get(handles.SubDir,'String'); |
---|
4072 | end |
---|
4073 | SubDir_1=regexprep(SubDir_1,'\<[\\/]|[\\/]\>','');%suppress possible / or \ separator at the beginning or the end of the string |
---|
4074 | RootFile_1=get(handles.RootFile_1,'String'); |
---|
4075 | if isequal(get(handles.RootFile_1,'Visible'),'off') || isequal(RootFile_1,'"') |
---|
4076 | RootFile_1=get(handles.RootFile,'String'); |
---|
4077 | end |
---|
4078 | RootFile_1=regexprep(RootFile_1,'\<[\\/]|[\\/]\>','');%suppress possible / or \ separator at the beginning or the end of the string |
---|
4079 | FileIndex_1=get(handles.FileIndex_1,'String'); |
---|
4080 | if isequal(get(handles.FileIndex_1,'Visible'),'off')|| isequal(FileIndex_1,'"') |
---|
4081 | FileIndex_1=get(handles.FileIndex,'String'); |
---|
4082 | end |
---|
4083 | FileExt_1=get(handles.FileExt_1,'String'); |
---|
4084 | if isequal(get(handles.FileExt_1,'Visible'),'off') || isequal(FileExt_1,'"') |
---|
4085 | FileExt_1=get(handles.FileExt,'String');%read FileExt by default |
---|
4086 | end |
---|
4087 | NomType_1=get(handles.NomType_1,'String'); |
---|
4088 | if isequal(get(handles.NomType_1,'Visible'),'off') || isequal(NomType_1,'"') |
---|
4089 | NomType_1=get(handles.NomType,'String');%read FileExt by default |
---|
4090 | end |
---|
4091 | %------------------------------------------------------------------------ |
---|
4092 | % --- Executes on menu selection FieldName |
---|
4093 | |
---|
4094 | function FieldName_Callback(hObject, eventdata, handles) |
---|
4095 | %------------------------------------------------------------------------ |
---|
4096 | |
---|
4097 | %% read data from uvmat |
---|
4098 | UvData=get(handles.uvmat,'UserData'); |
---|
4099 | list_fields=get(handles.FieldName,'String');% list menu fields |
---|
4100 | index_fields=get(handles.FieldName,'Value');% selected string index |
---|
4101 | field= list_fields{index_fields(1)}; % selected string |
---|
4102 | [RootPath,SubDir,RootFile,FileIndices,FileExt]=read_file_boxes(handles); |
---|
4103 | FileName=[fullfile(RootPath,SubDir,RootFile) FileIndices FileExt]; |
---|
4104 | [tild,tild,tild,i1,i2,j1,j2,tild,NomType]=fileparts_uvmat(['xxx' get(handles.FileIndex,'String') FileExt]); |
---|
4105 | |
---|
4106 | switch field |
---|
4107 | case 'get_field...' |
---|
4108 | %% fill the axes and variables from selections in get_field |
---|
4109 | ParamIn.Title='get_field: choose input field for display in uvmat' ; |
---|
4110 | % in case of civ data, we use the civ choice as default input for the GUI get_field |
---|
4111 | if strcmp(get(handles.VelType,'Visible'),'on') |
---|
4112 | ParamIn.SwitchVarIndexTime='attribute'; |
---|
4113 | ListVelType=get(handles.VelType,'String'); |
---|
4114 | VelType=ListVelType{get(handles.VelType,'Value')}; |
---|
4115 | switch VelType |
---|
4116 | case 'civ1' |
---|
4117 | ParamIn.TimeAttrName='Civ1_Time'; |
---|
4118 | ParamIn.vector_x='Civ1_U'; |
---|
4119 | ParamIn.vector_y='Civ1_V'; |
---|
4120 | ParamIn.vec_color='Civ1_C'; |
---|
4121 | case 'filter1' |
---|
4122 | ParamIn.TimeAttrName='Civ1_Time'; |
---|
4123 | ParamIn.vector_x='Civ1_U_smooth'; |
---|
4124 | ParamIn.vector_y='Civ1_V_smooth'; |
---|
4125 | case 'civ2' |
---|
4126 | ParamIn.TimeAttrName='Civ2_Time'; |
---|
4127 | ParamIn.vector_x='Civ2_U'; |
---|
4128 | ParamIn.vector_y='Civ2_V'; |
---|
4129 | case 'filter2' |
---|
4130 | ParamIn.TimeAttrName='Civ2_Time'; |
---|
4131 | ParamIn.vector_x='Civ2_U_smooth'; |
---|
4132 | ParamIn.vector_y='Civ2_V_smooth'; |
---|
4133 | ParamIn.vec_color='Civ2_C'; |
---|
4134 | end |
---|
4135 | end |
---|
4136 | |
---|
4137 | % VelType menu desactivated |
---|
4138 | set(handles.FixVelType,'visible','off') |
---|
4139 | set(handles.VelType,'Visible','off') |
---|
4140 | |
---|
4141 | %read selection from get_field |
---|
4142 | [RootPath,SubDir,RootFile,FileIndices,FileExt]=read_file_boxes(handles); |
---|
4143 | FileName=[fullfile(RootPath,SubDir,RootFile) FileIndices FileExt]; |
---|
4144 | GetFieldData=get_field(FileName,ParamIn);% inport field names from the GUI get_field |
---|
4145 | FieldList={}; |
---|
4146 | VecColorList={''}; |
---|
4147 | ZName=''; |
---|
4148 | switch GetFieldData.FieldOption |
---|
4149 | case 'vectors' |
---|
4150 | UName=GetFieldData.PanelVectors.vector_x; |
---|
4151 | VName=GetFieldData.PanelVectors.vector_y; |
---|
4152 | YName=GetFieldData.Coordinates.Coord_y; |
---|
4153 | if isfield(GetFieldData.Coordinates,'Coord_z') |
---|
4154 | ZName=GetFieldData.Coordinates.Coord_z; |
---|
4155 | end |
---|
4156 | CName=GetFieldData.PanelVectors.vec_color; |
---|
4157 | FieldList={['vec(' UName ',' VName ')'];... |
---|
4158 | ['norm(' UName ',' VName ')'];... |
---|
4159 | UName;VName}; |
---|
4160 | VecColorList={['norm(' UName ',' VName ')'];... |
---|
4161 | UName;VName}; |
---|
4162 | if ~isempty(CName) |
---|
4163 | VecColorList=[{CName};VecColorList]; |
---|
4164 | end |
---|
4165 | case 'scalar' |
---|
4166 | AName=GetFieldData.PanelScalar.scalar; |
---|
4167 | YName=GetFieldData.Coordinates.Coord_y; |
---|
4168 | if isfield(GetFieldData.Coordinates,'Coord_z') |
---|
4169 | ZName=GetFieldData.Coordinates.Coord_z; |
---|
4170 | end |
---|
4171 | FieldList={AName}; |
---|
4172 | case '1D plot' |
---|
4173 | YName=GetFieldData.PanelOrdinate.ordinate; |
---|
4174 | case 'civdata...'%reinitiate input, return to automatic civ data reading |
---|
4175 | display_file_name(handles,FileName,1) |
---|
4176 | end |
---|
4177 | % get time as file index, attribute, variable or matrix index |
---|
4178 | if ~strcmp(GetFieldData.FieldOption,'civdata...') |
---|
4179 | XName=GetFieldData.Coordinates.Coord_x; |
---|
4180 | TimeNameStr=GetFieldData.Time.SwitchVarIndexTime; |
---|
4181 | switch TimeNameStr |
---|
4182 | case 'file index' |
---|
4183 | set(handles.TimeName,'String',''); |
---|
4184 | case 'attribute' |
---|
4185 | set(handles.TimeName,'String',['att:' GetFieldData.Time.TimeName]); |
---|
4186 | case 'variable' |
---|
4187 | set(handles.TimeName,'String',['var:' GetFieldData.Time.TimeName]) |
---|
4188 | set(handles.NomType,'String','*') |
---|
4189 | set(handles.RootFile,'String',[get(handles.RootFile,'String') get(handles.FileIndex,'String')]) |
---|
4190 | set(handles.i1,'String','1')% set counter to 1 (now the time index in the input matrix) |
---|
4191 | MaxIndex_i=get(handles.MaxIndex_i,'String'); |
---|
4192 | MaxIndex_i{1}=num2str(GetFieldData.Time.TimeDimension); |
---|
4193 | set(handles.MaxIndex_i,'String',MaxIndex_i)%TODO: record time unit |
---|
4194 | UvData=get(handles.uvmat,'UserData'); |
---|
4195 | UvData.TimeUnit=GetFieldData.Time.TimeUnit; |
---|
4196 | set(handles.uvmat,'UserData',UvData); |
---|
4197 | set(handles.FileIndex,'String','') |
---|
4198 | ParamIn.TimeVarName=GetFieldData.Time.TimeName; |
---|
4199 | case 'matrix index' |
---|
4200 | set(handles.TimeName,'String',['dim:' GetFieldData.Time.TimeName]); |
---|
4201 | set(handles.NomType,'String','*') |
---|
4202 | set(handles.RootFile,'String',[get(handles.RootFile,'String') get(handles.FileIndex,'String')]) |
---|
4203 | set(handles.i1,'String','1')% set counter to 1 (now the time index in the input matrix) |
---|
4204 | MaxIndex_i=get(handles.MaxIndex_i,'String'); |
---|
4205 | MaxIndex_i{1}=num2str(GetFieldData.Time.TimeDimension); |
---|
4206 | set(handles.MaxIndex_i,'String',MaxIndex_i)%TODO: record time unit |
---|
4207 | UvData=get(handles.uvmat,'UserData'); |
---|
4208 | UvData.TimeUnit=GetFieldData.Time.TimeUnit; |
---|
4209 | set(handles.uvmat,'UserData',UvData); |
---|
4210 | set(handles.FileIndex,'String','') |
---|
4211 | ParamIn.TimeDimName=GetFieldData.Time.TimeName; |
---|
4212 | end |
---|
4213 | set(handles.Coord_x,'String',XName) |
---|
4214 | % if ischar(YName) |
---|
4215 | % YName={YName}; |
---|
4216 | % end |
---|
4217 | set(handles.Coord_y,'String',YName) |
---|
4218 | set(handles.Coord_z,'String',ZName) |
---|
4219 | set(handles.FieldName,'Value',1) |
---|
4220 | set(handles.FieldName,'String',[FieldList; {'get_field...'}]); |
---|
4221 | set(handles.ColorScalar,'Value',1) |
---|
4222 | set(handles.ColorScalar,'String',VecColorList); |
---|
4223 | UvData.FileType{1}='netcdf'; |
---|
4224 | set(handles.uvmat,'UserData',UvData) |
---|
4225 | REFRESH_Callback(hObject, eventdata, handles) |
---|
4226 | end |
---|
4227 | |
---|
4228 | case 'image' |
---|
4229 | %% look for image corresponding to civ data |
---|
4230 | if isfield(UvData.Field,'Civ2_ImageA')%get the corresponding input image in the netcdf file |
---|
4231 | imagename=UvData.Field.Civ2_ImageA; |
---|
4232 | elseif isfield(UvData.Field,'Civ1_ImageA')% |
---|
4233 | imagename=UvData.Field.Civ1_ImageA; |
---|
4234 | else |
---|
4235 | SubDirBase=regexprep(SubDir,'\..*','');%take the root part of SubDir, before the first dot '.' |
---|
4236 | imagename=fullfile_uvmat(RootPath,SubDirBase,RootFile,'.png',NomType,i1,[],j1,[]); |
---|
4237 | end |
---|
4238 | if ~exist(imagename,'file') |
---|
4239 | imagename=uigetfile_uvmat('Pick an image file',imagename,'image'); |
---|
4240 | if isempty(imagename) |
---|
4241 | return |
---|
4242 | end |
---|
4243 | end |
---|
4244 | % display the selected field and related information |
---|
4245 | display_file_name(handles,imagename)%display the image |
---|
4246 | otherwise |
---|
4247 | REFRESH_Callback(hObject, eventdata, handles) |
---|
4248 | end |
---|
4249 | |
---|
4250 | %---------------------------------------------------------------- |
---|
4251 | % --- Executes on menu selection FieldName |
---|
4252 | function FieldName_1_Callback(hObject, eventdata, handles) |
---|
4253 | %------------------------------------------------- |
---|
4254 | |
---|
4255 | %%%%%% TODO: modify like FieldName_Callback |
---|
4256 | %% read input data |
---|
4257 | check_new=~get(handles.SubField,'Value'); %check_new=1 if a second field was not previously entered |
---|
4258 | UvData=get(handles.uvmat,'UserData'); |
---|
4259 | if check_new && isfield(UvData,'XmlData') |
---|
4260 | UvData.XmlData{2}=UvData.XmlData{1}; |
---|
4261 | end |
---|
4262 | if isfield(UvData,'Field_1') |
---|
4263 | UvData=rmfield(UvData,'Field_1');% remove the stored second field (a new one needs to be read) |
---|
4264 | end |
---|
4265 | UvData.FileName_1='';% desactivate the use of a constant second file |
---|
4266 | list_fields=get(handles.FieldName,'String');% list menu fields |
---|
4267 | field= list_fields{get(handles.FieldName,'Value')}; % selected string |
---|
4268 | list_fields=get(handles.FieldName_1,'String');% list menu fields |
---|
4269 | field_1= list_fields{get(handles.FieldName_1,'Value')}; % selected string for the second field |
---|
4270 | if isempty(field_1)%||(numel(UvData.FileType)>=2 && strcmp(UvData.FileType{2},'image')) |
---|
4271 | set(handles.SubField,'Value',0) |
---|
4272 | SubField_Callback(hObject, eventdata, handles) |
---|
4273 | return |
---|
4274 | else |
---|
4275 | set(handles.SubField,'Value',1)%state that a second field is now entered |
---|
4276 | end |
---|
4277 | |
---|
4278 | %% read the rootfile input display |
---|
4279 | [RootPath_1,SubDir_1,RootFile_1,FileIndex_1,FileExt_1]=read_file_boxes_1(handles); |
---|
4280 | FileName_1=[fullfile(RootPath_1,SubDir_1,RootFile_1) FileIndex_1 FileExt_1]; |
---|
4281 | [tild,tild,tild,i1,i2,j1,j2]=fileparts_uvmat(get(handles.FileIndex,'String')); |
---|
4282 | switch field_1 |
---|
4283 | case 'get_field...' |
---|
4284 | %% fill the axes and variables from selections in get_field |
---|
4285 | ParamIn=[]; |
---|
4286 | % in case of civ data, we use the civ choice as default input for the GUI get_field |
---|
4287 | if strcmp(get(handles.VelType_1,'Visible'),'on') |
---|
4288 | ParamIn.SwitchVarIndexTime='attribute'; |
---|
4289 | ListVelType=get(handles.VelType_1,'String'); |
---|
4290 | VelType=ListVelType{get(handles.VelType_1,'Value')}; |
---|
4291 | switch VelType |
---|
4292 | case 'civ1' |
---|
4293 | ParamIn.TimeAttrName='Civ1_Time'; |
---|
4294 | ParamIn.vector_x='Civ1_U'; |
---|
4295 | ParamIn.vector_y='Civ1_V'; |
---|
4296 | ParamIn.vec_color='Civ1_C'; |
---|
4297 | case 'filter1' |
---|
4298 | ParamIn.TimeAttrName='Civ1_Time'; |
---|
4299 | ParamIn.vector_x='Civ1_U_smooth'; |
---|
4300 | ParamIn.vector_y='Civ1_V_smooth'; |
---|
4301 | case 'civ2' |
---|
4302 | ParamIn.TimeAttrName='Civ2_Time'; |
---|
4303 | ParamIn.vector_x='Civ2_U'; |
---|
4304 | ParamIn.vector_y='Civ2_V'; |
---|
4305 | case 'filter2' |
---|
4306 | ParamIn.TimeAttrName='Civ2_Time'; |
---|
4307 | ParamIn.vector_x='Civ2_U_smooth'; |
---|
4308 | ParamIn.vector_y='Civ2_V_smooth'; |
---|
4309 | ParamIn.vec_color='Civ2_C'; |
---|
4310 | end |
---|
4311 | end |
---|
4312 | |
---|
4313 | % VelType menu desactivated |
---|
4314 | set(handles.FixVelType,'visible','off') |
---|
4315 | set(handles.VelType,'Visible','off') |
---|
4316 | |
---|
4317 | %read selection from get_field |
---|
4318 | [RootPath,SubDir,RootFile,FileIndices,FileExt]=read_file_boxes_1(handles); |
---|
4319 | FileName=[fullfile(RootPath,SubDir,RootFile) FileIndices FileExt]; |
---|
4320 | GetFieldData=get_field(FileName,ParamIn);% inport field names from the GUI get_field |
---|
4321 | FieldList={}; |
---|
4322 | VecColorList={}; |
---|
4323 | switch GetFieldData.FieldOption |
---|
4324 | case 'vectors' |
---|
4325 | UName=GetFieldData.PanelVectors.vector_x; |
---|
4326 | VName=GetFieldData.PanelVectors.vector_y; |
---|
4327 | YName=GetFieldData.Coordinates.Coord_y; |
---|
4328 | CName=GetFieldData.PanelVectors.vec_color; |
---|
4329 | FieldList={['vec(' UName ',' VName ')'];... |
---|
4330 | ['norm(' UName ',' VName ')'];... |
---|
4331 | UName;VName}; |
---|
4332 | VecColorList={['norm(' UName ',' VName ')'];... |
---|
4333 | UName;VName}; |
---|
4334 | if ~isempty(CName) |
---|
4335 | VecColorList=[{CName};VecColorList]; |
---|
4336 | end |
---|
4337 | case 'scalar' |
---|
4338 | AName=GetFieldData.PanelScalar.scalar; |
---|
4339 | YName=GetFieldData.Coordinates.Coord_y; |
---|
4340 | FieldList={AName}; |
---|
4341 | case '1D plot' |
---|
4342 | YName=GetFieldData.PanelOrdinate.ordinate; |
---|
4343 | case 'civdata...'%reinitiate input, return to automatic civ data reading |
---|
4344 | display_file_name(handles,FileName,1) |
---|
4345 | end |
---|
4346 | if ~strcmp(GetFieldData.FieldOption,'civdata...') |
---|
4347 | XName=GetFieldData.Coordinates.Coord_x; |
---|
4348 | TimeNameStr=GetFieldData.Time.SwitchVarIndexTime; |
---|
4349 | switch TimeNameStr |
---|
4350 | case 'file index' |
---|
4351 | set(handles.TimeName_1,'String',''); |
---|
4352 | case 'attribute' |
---|
4353 | set(handles.TimeName_1,'String',['att:' GetFieldData.Time.TimeName]); |
---|
4354 | case 'variable' |
---|
4355 | set(handles.TimeName_1,'String',['var:' GetFieldData.Time.TimeName]) |
---|
4356 | set(handles.NomType_1,'String','*') |
---|
4357 | set(handles.RootFile_1,'String',[get(handles.RootFile,'String') get(handles.FileIndex,'String')]) |
---|
4358 | set(handles.FileIndex_1,'String','') |
---|
4359 | ParamIn.TimeVarName=GetFieldData.Time.TimeName; |
---|
4360 | case 'matrix_index' |
---|
4361 | set(handles.TimeName_1,'String',['dim:' GetFieldData.Time.TimeName]); |
---|
4362 | set(handles.NomType_1,'String','*') |
---|
4363 | set(handles.RootFile_1,'String',[get(handles.RootFile,'String') get(handles.FileIndex,'String')]) |
---|
4364 | set(handles.FileIndex_1,'String','') |
---|
4365 | ParamIn.TimeDimName_1=GetFieldData.Time.TimeName; |
---|
4366 | end |
---|
4367 | set(handles.Coord_x,'String',XName) |
---|
4368 | % if ischar(YName) |
---|
4369 | % YName={YName}; |
---|
4370 | % end |
---|
4371 | set(handles.Coord_y,'String',YName) |
---|
4372 | set(handles.FieldName_1,'Value',1) |
---|
4373 | set(handles.FieldName_1,'String',[FieldList; {'get_field...'}]); |
---|
4374 | set(handles.ColorScalar,'Value',1) |
---|
4375 | set(handles.ColorScalar,'String',VecColorList); |
---|
4376 | UvData.FileType{2}='netcdf'; |
---|
4377 | set(handles.uvmat,'UserData',UvData) |
---|
4378 | REFRESH_Callback(hObject, eventdata, handles) |
---|
4379 | end |
---|
4380 | |
---|
4381 | % set_veltype_display(0) % no veltype display |
---|
4382 | % hget_field=findobj(allchild(0),'name','get_field_1'); |
---|
4383 | % if ~isempty(hget_field) |
---|
4384 | % delete(hget_field) |
---|
4385 | % end |
---|
4386 | % hget_field=get_field(FileName_1); |
---|
4387 | % set(hget_field,'name','get_field_1') |
---|
4388 | % hhget_field=guidata(hget_field); |
---|
4389 | % set(hhget_field.list_fig,'Value',1) |
---|
4390 | % set(hhget_field.list_fig,'String',{'uvmat'}) |
---|
4391 | % if check_new |
---|
4392 | % UvData.FileType{2}=UvData.FileType{1}; |
---|
4393 | % set(handles.FileIndex_1,'String',get(handles.FileIndex,'String')) |
---|
4394 | % set(handles.uvmat,'UserData',UvData) |
---|
4395 | % end |
---|
4396 | case 'image' |
---|
4397 | %% look for image corresponding to civ data |
---|
4398 | imagename=''; |
---|
4399 | if isfield(UvData.Field,'Civ2_ImageA')%get the corresponding input image in the netcdf file |
---|
4400 | imagename=UvData.Field.Civ2_ImageA; |
---|
4401 | elseif isfield(UvData.Field,'Civ1_ImageA')% |
---|
4402 | imagename=UvData.Field.Civ1_ImageA; |
---|
4403 | else |
---|
4404 | SubDirBase=regexprep(SubDir,'\..*','');%take the root part of SubDir, before the first dot '.' |
---|
4405 | imagename=fullfile_uvmat(RootPath,SubDirBase,RootFile,'.png',NomType,i1,[],j1,[]); |
---|
4406 | end |
---|
4407 | if ~exist(imagename,'file') |
---|
4408 | imagename=uigetfile_uvmat('Pick an image file',imagename,'image'); |
---|
4409 | |
---|
4410 | end |
---|
4411 | if isempty(imagename) |
---|
4412 | set(handles.SubField,'Value',0) |
---|
4413 | return |
---|
4414 | else |
---|
4415 | display_file_name(handles,imagename,2)%display the image as second field |
---|
4416 | end |
---|
4417 | otherwise |
---|
4418 | check_refresh=1; |
---|
4419 | if check_new% if a second field was not previously entered, we just read another field in the first input file |
---|
4420 | set(handles.FileIndex_1,'String',get(handles.FileIndex,'String')) |
---|
4421 | set(handles.FileExt_1,'String',get(handles.FileExt,'String')) |
---|
4422 | |
---|
4423 | UvData.FileType{2}=UvData.FileType{1}; |
---|
4424 | UvData.XmlData{2}= UvData.XmlData{1}; |
---|
4425 | transform=get(handles.TransformPath,'UserData'); |
---|
4426 | if (~isa(transform,'function_handle')||nargin(transform)<3) |
---|
4427 | set(handles.uvmat,'UserData',UvData) |
---|
4428 | set(handles.TransformName,'value',2); % set transform fct to 'sub_field' if the current fct does not accept two input fields |
---|
4429 | TransformName_Callback(hObject, eventdata, handles)% activate transform_fct_Callback and refresh current plot |
---|
4430 | check_refresh=0; |
---|
4431 | end |
---|
4432 | end |
---|
4433 | if ~isequal(field,'image') |
---|
4434 | set(handles.TitleNpxy,'Visible','off')% visible npx,pxcm... buttons |
---|
4435 | set(handles.num_Npx,'Visible','off') |
---|
4436 | set(handles.num_Npy,'Visible','off') |
---|
4437 | end |
---|
4438 | set(handles.uvmat,'UserData',UvData) |
---|
4439 | |
---|
4440 | if check_refresh && ~(isfield(UvData,'NewSeries')&&isequal(UvData.NewSeries,1)) |
---|
4441 | REFRESH_Callback(hObject, eventdata, handles) |
---|
4442 | end |
---|
4443 | end |
---|
4444 | |
---|
4445 | %------------------------------------------------------------------------ |
---|
4446 | % --- set the visibility of relevant velocity type menus: |
---|
4447 | function menu=set_veltype_display(Civ,FileType) |
---|
4448 | %------------------------------------------------------------------------ |
---|
4449 | if ~exist('FileType','var') |
---|
4450 | FileType='civx'; |
---|
4451 | end |
---|
4452 | switch FileType |
---|
4453 | case 'civx' |
---|
4454 | menu={'civ1';'interp1';'filter1';'civ2';'interp2';'filter2'}; |
---|
4455 | if isequal(Civ,0) |
---|
4456 | imax=0; |
---|
4457 | elseif isequal(Civ,1) || isequal(Civ,2) |
---|
4458 | imax=1; |
---|
4459 | elseif isequal(Civ,3) |
---|
4460 | imax=3; |
---|
4461 | elseif isequal(Civ,4) || isequal(Civ,5) |
---|
4462 | imax=4; |
---|
4463 | elseif isequal(Civ,6) %patch2 |
---|
4464 | imax=6; |
---|
4465 | end |
---|
4466 | case 'civdata' |
---|
4467 | menu={'civ1';'filter1';'civ2';'filter2'}; |
---|
4468 | if isequal(Civ,0) |
---|
4469 | imax=0; |
---|
4470 | elseif isequal(Civ,1) || isequal(Civ,2) |
---|
4471 | imax=1; |
---|
4472 | elseif isequal(Civ,3) |
---|
4473 | imax=2; |
---|
4474 | elseif isequal(Civ,4) || isequal(Civ,5) |
---|
4475 | imax=3; |
---|
4476 | elseif isequal(Civ,6) %patch2 |
---|
4477 | imax=4; |
---|
4478 | end |
---|
4479 | end |
---|
4480 | menu=menu(1:imax); |
---|
4481 | |
---|
4482 | %------------------------------------------------------------------------ |
---|
4483 | % --- Executes on button press in FixVelType. |
---|
4484 | function FixVelType_Callback(hObject, eventdata, handles) |
---|
4485 | %------------------------------------------------------------------------ |
---|
4486 | % inputfilerefresh the current plot if the fixed veltype is unselected |
---|
4487 | if ~get(handles.FixVelType,'Value') |
---|
4488 | REFRESH_Callback(hObject, eventdata, handles) |
---|
4489 | end |
---|
4490 | |
---|
4491 | %------------------------------------------------------------------------ |
---|
4492 | % --- Executes on button press in VelType. |
---|
4493 | function VelType_Callback(hObject, eventdata, handles) |
---|
4494 | %------------------------------------------------------------------------ |
---|
4495 | set(handles.FixVelType,'Value',1) |
---|
4496 | REFRESH_Callback(hObject, eventdata, handles) |
---|
4497 | |
---|
4498 | %------------------------------------------------------------------------ |
---|
4499 | % --- Executes on choice selection in VelType_1. |
---|
4500 | function VelType_1_Callback(hObject, eventdata, handles) |
---|
4501 | %------------------------------------------------------------------------ |
---|
4502 | set(handles.FixVelType,'Value',1)% the velocity type is now imposed by the GUI (not automatic) |
---|
4503 | UvData=get(handles.uvmat,'UserData'); |
---|
4504 | set(handles.InputFileREFRESH,'BackgroundColor',[1 1 0])%paint REFRESH button in yellow to indicate its activation |
---|
4505 | drawnow |
---|
4506 | InputFile=read_GUI(handles.InputFile);% read the input file parameters |
---|
4507 | [RootPath,SubDir,RootFile,FileIndex,FileExt]=read_file_boxes(handles); |
---|
4508 | [RootPath_1,SubDir_1,RootFile_1,FileIndex_1,FileExt_1]=read_file_boxes_1(handles); |
---|
4509 | FileName=[fullfile(RootPath,SubDir,RootFile) FileIndex FileExt];% name of the first input file |
---|
4510 | |
---|
4511 | check_refresh=0; |
---|
4512 | if isempty(InputFile.VelType_1) |
---|
4513 | FileName_1='';% we plot the first input field without the second field |
---|
4514 | set(handles.SubField,'Value',0) |
---|
4515 | SubField_Callback(hObject, eventdata, handles)% activate SubField_Callback and refresh current plot, removing the second field |
---|
4516 | elseif get(handles.SubField,'Value')% if subfield is already 'on' |
---|
4517 | FileName_1=[fullfile(RootPath_1,SubDir_1,RootFile_1) FileIndex_1 FileExt_1];% name of the second input file |
---|
4518 | check_refresh=1;%will refresh the current plot |
---|
4519 | else% we introduce the same file (with a different field) for the second series |
---|
4520 | FileName_1=FileName;% we compare two fields in the same file |
---|
4521 | UvData.FileType{2}=UvData.FileType{1}; |
---|
4522 | UvData.XmlData{2}= UvData.XmlData{1}; |
---|
4523 | set(handles.SubField,'Value',1) |
---|
4524 | transform=get(handles.TransformPath,'UserData'); |
---|
4525 | if (~isa(transform,'function_handle')||nargin(transform)<3) |
---|
4526 | set(handles.uvmat,'UserData',UvData) |
---|
4527 | set(handles.TransformName,'value',2); % set transform fct to 'sub_field' if the current fct does not accept two input fields |
---|
4528 | TransformName_Callback(hObject, eventdata, handles)% activate transform_fct_Callback and refresh current plot |
---|
4529 | else |
---|
4530 | check_refresh=1; |
---|
4531 | end |
---|
4532 | end |
---|
4533 | |
---|
4534 | % inputfilerefresh the current plot if it has not been done previously |
---|
4535 | if check_refresh |
---|
4536 | UvData.FileName_1='';% desactivate the use of a constant second file |
---|
4537 | set(handles.uvmat,'UserData',UvData) |
---|
4538 | num_i1=stra2num(get(handles.i1,'String')); |
---|
4539 | num_i2=stra2num(get(handles.i2,'String')); |
---|
4540 | num_j1=stra2num(get(handles.j1,'String')); |
---|
4541 | num_j2=stra2num(get(handles.j2,'String')); |
---|
4542 | [tild,tild,tild,i1_1,i2_1,j1_1,j2_1]=fileparts_uvmat(['xx' FileIndex_1]); |
---|
4543 | errormsg=refresh_field(handles,FileName,FileName_1,num_i1,num_i2,num_j1,num_j2,i1_1,i2_1,j1_1,j2_1); |
---|
4544 | if ~isempty(errormsg) |
---|
4545 | msgbox_uvmat('ERROR',errormsg); |
---|
4546 | else |
---|
4547 | % set(handles.i1,'BackgroundColor',[1 1 1]) |
---|
4548 | % set(handles.i2,'BackgroundColor',[1 1 1]) |
---|
4549 | % set(handles.j1,'BackgroundColor',[1 1 1]) |
---|
4550 | % set(handles.j2,'BackgroundColor',[1 1 1]) |
---|
4551 | % set(handles.FileIndex,'BackgroundColor',[1 1 1]) |
---|
4552 | % set(handles.FileIndex_1,'BackgroundColor',[1 1 1]) |
---|
4553 | end |
---|
4554 | set(handles.InputFileREFRESH,'BackgroundColor',[1 0 0]) |
---|
4555 | end |
---|
4556 | |
---|
4557 | |
---|
4558 | %------------------------------------------------------------------------ |
---|
4559 | % --- reset civ buttons |
---|
4560 | function reset_vel_type(handles_civ0,handle1) |
---|
4561 | %------------------------------------------------------------------------ |
---|
4562 | for ibutton=1:length(handles_civ0) |
---|
4563 | set(handles_civ0(ibutton),'BackgroundColor',[0.831 0.816 0.784]) |
---|
4564 | set(handles_civ0(ibutton),'Value',0) |
---|
4565 | end |
---|
4566 | if exist('handle1','var')%handles of selected button |
---|
4567 | set(handle1,'BackgroundColor',[1 1 0]) |
---|
4568 | end |
---|
4569 | |
---|
4570 | %----------------------------------------------------------------------- |
---|
4571 | % --- Executes on button press in MENUVOLUME. |
---|
4572 | function VOLUME_Callback(hObject, eventdata, handles) |
---|
4573 | %----------------------------------------------------------------------- |
---|
4574 | %errordlg('command VOL not implemented yet') |
---|
4575 | if ishandle(handles.UVMAT_title) |
---|
4576 | delete(handles.UVMAT_title) |
---|
4577 | end |
---|
4578 | UvData=get(handles.uvmat,'UserData');%read UvData properties stored on the uvmat interface |
---|
4579 | if isequal(get(handles.VOLUME,'Value'),1) |
---|
4580 | set(handles.CheckZoom,'Value',0) |
---|
4581 | % set(handles.CheckZoom,'BackgroundColor',[0.7 0.7 0.7]) |
---|
4582 | set(handles.edit_vect,'Value',0) |
---|
4583 | edit_vect_Callback(hObject, eventdata, handles) |
---|
4584 | set(handles.CheckEditObject,'Value',0) |
---|
4585 | % set(handles.CheckEditObject,'BackgroundColor',[0.7 0.7 0.7]) |
---|
4586 | % set(handles.cal,'Value',0) |
---|
4587 | % set(handles.cal,'BackgroundColor',[0 1 0]) |
---|
4588 | set(handles.edit_vect,'Value',0) |
---|
4589 | edit_vect_Callback(hObject, eventdata, handles) |
---|
4590 | %initiate set_object GUI |
---|
4591 | data.Name='VOLUME'; |
---|
4592 | if isfield(UvData,'CoordType') |
---|
4593 | data.CoordType=UvData.CoordType; |
---|
4594 | end |
---|
4595 | if isfield(UvData.Field,'CoordMesh')&~isempty(UvData.Field.CoordMesh) |
---|
4596 | data.RangeX=[UvData.Field.XMin UvData.Field.XMax]; |
---|
4597 | data.RangeY=[UvData.Field.YMin UvData.Field.YMax]; |
---|
4598 | data.DX=UvData.Field.CoordMesh; |
---|
4599 | data.DY=UvData.Field.CoordMesh; |
---|
4600 | elseif isfield(UvData.Field,'Coord_x')&isfield(UvData.Field,'Coord_y')& isfield(UvData.Field,'A')%only image |
---|
4601 | np=size(UvData.Field.A); |
---|
4602 | meshx=(UvData.Field.Coord_x(end)-UvData.Field.Coord_x(1))/np(2); |
---|
4603 | meshy=abs(UvData.Field.Coord_y(end)-UvData.Field.Coord_y(1))/np(1); |
---|
4604 | data.RangeY=max(meshx,meshy); |
---|
4605 | data.RangeX=max(meshx,meshy); |
---|
4606 | data.DX=max(meshx,meshy); |
---|
4607 | end |
---|
4608 | data.ParentButton=handles.VOLUME; |
---|
4609 | PlotHandles=get_plot_handles(handles);%get the handles of the interface elements setting the plotting parameters |
---|
4610 | [hset_object,UvData.sethandles]=set_object(data,PlotHandles);% call the set_object interface with action on haxes, |
---|
4611 | % associate the set_object interface handle to the plotting axes |
---|
4612 | set(hset_object,'name','set_object') |
---|
4613 | UvData.MouseAction='create_object'; |
---|
4614 | else |
---|
4615 | set(handles.VOLUME,'BackgroundColor',[0 1 0]) |
---|
4616 | end |
---|
4617 | set(handles.uvmat,'UserData',UvData) |
---|
4618 | |
---|
4619 | %------------------------------------------------------- |
---|
4620 | function edit_vect_Callback(hObject, eventdata, handles) |
---|
4621 | %------------------------------------------------------- |
---|
4622 | % |
---|
4623 | if isequal(get(handles.edit_vect,'Value'),1) |
---|
4624 | VelTypeMenu=get(handles.VelType,'String'); |
---|
4625 | VelType=VelTypeMenu{get(handles.VelType,'Value')}; |
---|
4626 | if ~strcmp(VelType,'civ2') && ~strcmp(VelType,'civ1') |
---|
4627 | msgbox_uvmat('ERROR','manual correction only possible for CIV1 or CIV2 velocity fields') |
---|
4628 | end |
---|
4629 | set(handles.record,'Visible','on') |
---|
4630 | set(handles.edit_vect,'BackgroundColor',[1 1 0]) |
---|
4631 | set(handles.CheckEditObject,'Value',0) |
---|
4632 | set(handles.CheckZoom,'Value',0) |
---|
4633 | set(gcf,'Pointer','arrow') |
---|
4634 | else |
---|
4635 | set(handles.record,'Visible','off') |
---|
4636 | set(handles.edit_vect,'BackgroundColor',[0.7 0.7 0.7]) |
---|
4637 | end |
---|
4638 | |
---|
4639 | %---------------------------------------------- |
---|
4640 | function save_mask_Callback(hObject, eventdata, handles) |
---|
4641 | %----------------------------------------------------------------------- |
---|
4642 | UvData=get(handles.uvmat,'UserData'); |
---|
4643 | |
---|
4644 | flag=1; |
---|
4645 | npx=size(UvData.Field.A,2); |
---|
4646 | npy=size(UvData.Field.A,1); |
---|
4647 | xi=0.5:npx-0.5; |
---|
4648 | yi=0.5:npy-0.5; |
---|
4649 | [Xi,Yi]=meshgrid(xi,yi); |
---|
4650 | if isfield(UvData,'ProjObject') |
---|
4651 | for iobj=1:length(UvData.ProjObject) |
---|
4652 | ObjectData=UvData.ProjObject{iobj}; |
---|
4653 | if isfield(ObjectData,'ProjMode') &&(isequal(ObjectData.ProjMode,'mask_inside')||isequal(ObjectData.ProjMode,'mask_outside')); |
---|
4654 | flagobj=1; |
---|
4655 | testphys=0; %coordinates in pixels by default |
---|
4656 | if isfield(ObjectData,'CoordType') && isequal(ObjectData.CoordType,'phys') |
---|
4657 | if isfield(UvData,'XmlData')&& isfield(UvData.XmlData{1},'GeometryCalib') |
---|
4658 | Calib=UvData.XmlData{1}.GeometryCalib; |
---|
4659 | testphys=1; |
---|
4660 | end |
---|
4661 | end |
---|
4662 | if isfield(ObjectData,'Coord')& isfield(ObjectData,'Style') |
---|
4663 | if isequal(ObjectData.Type,'polygon') |
---|
4664 | X=ObjectData.Coord(:,1); |
---|
4665 | Y=ObjectData.Coord(:,2); |
---|
4666 | if testphys |
---|
4667 | [X,Y]=px_XYZ(Calib,X,Y,0);% to generalise with 3D cases |
---|
4668 | end |
---|
4669 | flagobj=~inpolygon(Xi,Yi,X',Y');%=0 inside the polygon, 1 outside |
---|
4670 | elseif isequal(ObjectData.Type,'ellipse') |
---|
4671 | if testphys |
---|
4672 | %[X,Y]=px_XYZ(Calib,X,Y,0);% TODO:create a polygon boundary and transform to phys |
---|
4673 | end |
---|
4674 | RangeX=max(ObjectData.RangeX); |
---|
4675 | RangeY=max(ObjectData.RangeY); |
---|
4676 | X2Max=RangeX*RangeX; |
---|
4677 | Y2Max=RangeY*RangeY; |
---|
4678 | distX=(Xi-ObjectData.Coord(1,1)); |
---|
4679 | distY=(Yi-ObjectData.Coord(1,2)); |
---|
4680 | flagobj=(distX.*distX/X2Max+distY.*distY/Y2Max)>1; |
---|
4681 | elseif isequal(ObjectData.Type,'rectangle') |
---|
4682 | if testphys |
---|
4683 | %[X,Y]=px_XYZ(Calib,X,Y,0);% TODO:create a polygon boundary and transform to phys |
---|
4684 | end |
---|
4685 | distX=abs(Xi-ObjectData.Coord(1,1)); |
---|
4686 | distY=abs(Yi-ObjectData.Coord(1,2)); |
---|
4687 | flagobj=distX>max(ObjectData.RangeX) | distY>max(ObjectData.RangeY); |
---|
4688 | end |
---|
4689 | if isequal(ObjectData.ProjMode,'mask_outside') |
---|
4690 | flagobj=~flagobj; |
---|
4691 | end |
---|
4692 | flag=flag & flagobj; |
---|
4693 | end |
---|
4694 | end |
---|
4695 | end |
---|
4696 | end |
---|
4697 | % flag=~flag; |
---|
4698 | %mask name |
---|
4699 | RootPath=get(handles.RootPath,'String'); |
---|
4700 | RootFile=get(handles.RootFile,'String'); |
---|
4701 | RootFile=regexprep(RootFile,'\<[\\/]|[\\/]\>','');%suppress possible / or \ separator at the beginning or the end of the string |
---|
4702 | filebase=fullfile(RootPath,RootFile); |
---|
4703 | list=get(handles.masklevel,'String'); |
---|
4704 | masknumber=num2str(length(list)); |
---|
4705 | maskindex=get(handles.masklevel,'Value'); |
---|
4706 | mask_name=fullfile_uvmat(RootPath,SubDir,[RootFile '_' masknumber 'mask'],'.png','_1',maskindex); |
---|
4707 | %mask_name=name_generator([filebase '_' masknumber 'mask'],maskindex,1,'.png','_i'); |
---|
4708 | imflag=uint8(255*(0.392+0.608*flag));% =100 for flag=0 (vectors not computed when 20<imflag<200) |
---|
4709 | imflag=flipdim(imflag,1); |
---|
4710 | % imflag=uint8(255*flag);% =0 for flag=0 (vectors=0 when 20<imflag<200) |
---|
4711 | msgbox_uvmat('CONFIRMATION',[mask_name ' saved']) |
---|
4712 | imwrite(imflag,mask_name,'BitDepth',8); |
---|
4713 | |
---|
4714 | %display the mask |
---|
4715 | figure; |
---|
4716 | vec=linspace(0,1,256);%define a linear greyscale colormap |
---|
4717 | map=[vec' vec' vec']; |
---|
4718 | colormap(map) |
---|
4719 | |
---|
4720 | image(imflag); |
---|
4721 | |
---|
4722 | %------------------------------------------------------------------------ |
---|
4723 | %------------------------------------------------------------------------ |
---|
4724 | % - FUNCTIONS FOR SETTING PLOTTING PARAMETERS |
---|
4725 | |
---|
4726 | %------------------------------------------------------------------------ |
---|
4727 | %------------------------------------------------------------------------ |
---|
4728 | % --- Executes on selection change in TransformName. |
---|
4729 | |
---|
4730 | function TransformName_Callback(hObject, eventdata, handles) |
---|
4731 | %------------------------------------------------------------------------ |
---|
4732 | set(handles.TransformName,'backgroundColor',[1 1 0])% indicate activation of the menu |
---|
4733 | drawnow |
---|
4734 | UvData=get(handles.uvmat,'UserData'); |
---|
4735 | menu=get(handles.TransformName,'String');%refresh |
---|
4736 | ichoice=get(handles.TransformName,'Value');%item number in the menu |
---|
4737 | transform_name=menu{ichoice};% choice of the transform fct |
---|
4738 | list_path=get(handles.TransformName,'UserData'); |
---|
4739 | |
---|
4740 | %% handles visibility of the path to the transform function |
---|
4741 | if isempty(transform_name) |
---|
4742 | set(handles.TransformPath,'Visible','off') |
---|
4743 | else |
---|
4744 | set(handles.TransformPath,'Visible','on') |
---|
4745 | end |
---|
4746 | |
---|
4747 | %% add a new item to the menu if the option 'more...' has been selected |
---|
4748 | prev_path=fullfile(get(handles.TransformPath,'String')); |
---|
4749 | if ~exist(prev_path,'dir') |
---|
4750 | prev_path=fullfile(fileparts(which('uvmat')),'transform_field'); |
---|
4751 | end |
---|
4752 | if strcmp(transform_name,'more...'); |
---|
4753 | transform_fct_chosen=uigetfile_uvmat('Pick the transform function',prev_path,'.m'); |
---|
4754 | if ~isempty(transform_fct_chosen) |
---|
4755 | [PathName,transform_name]=fileparts(transform_fct_chosen); |
---|
4756 | ichoice=find(strcmp(transform_name,menu),1);%look for the selected fct in the existing menu |
---|
4757 | if isempty(ichoice)% if the item is not found, add it to the menu (before 'more...' and select it) |
---|
4758 | menu=[menu(1:end-1);{transform_name};{'more...'}]; |
---|
4759 | ichoice=numel(menu)-1; |
---|
4760 | end |
---|
4761 | list_path{ichoice}=PathName;%update the list fo fct paths |
---|
4762 | set(handles.TransformName,'String',menu) |
---|
4763 | set(handles.TransformName,'Value',ichoice) |
---|
4764 | |
---|
4765 | % save the new menu in the personal file 'uvmat_perso.mat' |
---|
4766 | dir_perso=prefdir;%personal Matalb directory |
---|
4767 | profil_perso=fullfile(dir_perso,'uvmat_perso.mat'); |
---|
4768 | if exist(profil_perso,'file') |
---|
4769 | nb_builtin=UvData.OpenParam.NbBuiltin;% number of 'builtin' (basic) transform fcts in uvmat |
---|
4770 | if nb_builtin<numel(list_path) |
---|
4771 | for ilist=nb_builtin+1:numel(list_path) |
---|
4772 | transform_fct{ilist-nb_builtin}=[fullfile(list_path{ilist},menu{ilist}) '.m']; |
---|
4773 | end |
---|
4774 | save (profil_perso,'transform_fct','-append'); %store the root name for future opening of uvmat |
---|
4775 | end |
---|
4776 | end |
---|
4777 | end |
---|
4778 | end |
---|
4779 | |
---|
4780 | %% create the function handle of the selected fct |
---|
4781 | if isempty(list_path{ichoice})% case of no selected fct |
---|
4782 | transform_handle=[]; |
---|
4783 | else |
---|
4784 | if ~exist(list_path{ichoice},'dir') |
---|
4785 | msgbox_uvmat('ERROR','invalid fct path: select the transform fct again with the option more...') |
---|
4786 | return |
---|
4787 | end |
---|
4788 | current_dir=pwd;%current working dir |
---|
4789 | cd(list_path{ichoice}) |
---|
4790 | transform_handle=str2func(transform_name); |
---|
4791 | cd(current_dir) |
---|
4792 | end |
---|
4793 | set(handles.TransformPath,'String',list_path{ichoice}) |
---|
4794 | set(handles.TransformPath,'UserData',transform_handle) |
---|
4795 | set(handles.TransformName,'UserData',list_path) |
---|
4796 | |
---|
4797 | %% update the ToolTip string of the menu TransformName with the first line of the selected fct file |
---|
4798 | if isempty(list_path{ichoice})% case of no selected fct |
---|
4799 | set(handles.TransformName,'ToolTipString','transform_fct:choose a transform function') |
---|
4800 | else |
---|
4801 | try |
---|
4802 | [fid,errormsg] =fopen([fullfile(list_path{ichoice},transform_name) '.m']); |
---|
4803 | InputText=textscan(fid,'%s',1,'delimiter','\n'); |
---|
4804 | fclose(fid); |
---|
4805 | set(handles.TransformName,'ToolTipString',['transform_fct: ' InputText{1}{1}])% put the first line of the selected function as tooltip help |
---|
4806 | end |
---|
4807 | end |
---|
4808 | |
---|
4809 | %% adapt the GUI to the input/output conditions of the selected transform fct |
---|
4810 | CoordUnit=''; |
---|
4811 | CoordUnitPrev=''; |
---|
4812 | if isfield(UvData,'Field')&&isfield(UvData.Field,'CoordUnit') |
---|
4813 | CoordUnitPrev=UvData.Field.CoordUnit; |
---|
4814 | end |
---|
4815 | if ~isempty(list_path{ichoice}) |
---|
4816 | if nargin(transform_handle)>1 %&& isfield(UvData,'XmlData')&&~isempty(UvData.XmlData) |
---|
4817 | XmlData=[]; |
---|
4818 | if isfield(UvData,'XmlData')&&~isempty(UvData.XmlData) |
---|
4819 | XmlData=UvData.XmlData{1}; |
---|
4820 | end |
---|
4821 | UvData.Field.Action.RUN=0;% indicate that the transform fct is called only to get input param |
---|
4822 | DataOut=feval(transform_handle,UvData.Field,XmlData);% execute the transform fct to get the required conditions |
---|
4823 | if isfield(DataOut,'CoordUnit')% set the requested coord unit (info used to possibly delete the current projection objects) |
---|
4824 | CoordUnit=DataOut.CoordUnit; |
---|
4825 | end |
---|
4826 | if isfield(DataOut,'InputFieldType')% to be used to impose a type of input file (eg. for image transform) |
---|
4827 | UvData.InputFieldType=DataOut.InputFieldType; |
---|
4828 | end |
---|
4829 | if isfield(DataOut,'TransformInput')% used to add transform parameters at selection of the transform fct |
---|
4830 | UvData.XmlData{1}.TransformInput=DataOut.TransformInput; |
---|
4831 | end |
---|
4832 | end |
---|
4833 | end |
---|
4834 | |
---|
4835 | %% delete drawn objects if the output CooordUnit is different from the previous one |
---|
4836 | if ~isempty(CoordUnit) && ~isempty(CoordUnitPrev) && ~strcmp(CoordUnit,CoordUnitPrev) |
---|
4837 | set(handles.CheckFixLimits,'Value',0) |
---|
4838 | hother=findobj('Tag','proj_object');%find all the proj objects |
---|
4839 | for iobj=1:length(hother) |
---|
4840 | delete_object(hother(iobj)) |
---|
4841 | end |
---|
4842 | hother=findobj('Tag','DeformPoint');%find all the proj objects |
---|
4843 | for iobj=1:length(hother) |
---|
4844 | delete_object(hother(iobj)) |
---|
4845 | end |
---|
4846 | hh=findobj('Tag','calib_points'); |
---|
4847 | if ~isempty(hh) |
---|
4848 | delete(hh) |
---|
4849 | end |
---|
4850 | hhh=findobj('Tag','calib_marker'); |
---|
4851 | if ~isempty(hhh) |
---|
4852 | delete(hhh) |
---|
4853 | end |
---|
4854 | set(handles.ListObject,'Value',1) |
---|
4855 | set(handles.ListObject,'String',{''}) |
---|
4856 | set(handles.ListObject_1,'Value',1) |
---|
4857 | set(handles.ListObject_1,'String',{''}) |
---|
4858 | set(handles.CheckViewObject,'value',0) |
---|
4859 | CheckViewObject_Callback(hObject, eventdata, handles) |
---|
4860 | set(handles.CheckViewField,'value',0) |
---|
4861 | CheckViewField_Callback(hObject, eventdata, handles) |
---|
4862 | set(handles.CheckEditObject,'Value',0) |
---|
4863 | CheckEditObject_Callback(hObject, eventdata, handles) |
---|
4864 | UvData.ProjObject={[]}; |
---|
4865 | end |
---|
4866 | set(handles.uvmat,'UserData',UvData) |
---|
4867 | set(handles.TransformName,'backgroundColor',[1 1 1])% indicate desactivation of the menu |
---|
4868 | drawnow |
---|
4869 | |
---|
4870 | %% inputfilerefresh the current plot |
---|
4871 | if isempty(list_path{ichoice}) || nargin(transform_handle)<3 |
---|
4872 | set(handles.SubField,'Value',0) |
---|
4873 | SubField_Callback(hObject, eventdata, handles) |
---|
4874 | else |
---|
4875 | REFRESH_Callback(hObject, eventdata, handles) |
---|
4876 | end |
---|
4877 | |
---|
4878 | %------------------------------------------------ |
---|
4879 | %CALLBACKS FOR PLOTTING PARAMETERS |
---|
4880 | %------------------------------------------------- |
---|
4881 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
---|
4882 | % Plot axes |
---|
4883 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
---|
4884 | %------------------------------------------------------------------------ |
---|
4885 | function num_MinX_Callback(hObject, eventdata, handles) |
---|
4886 | %------------------------------------------------------------------------ |
---|
4887 | set(handles.CheckFixLimits,'Value',1) %suppress auto mode |
---|
4888 | % set(handles.CheckFixLimits,'BackgroundColor',[1 1 0]) |
---|
4889 | update_plot(handles); |
---|
4890 | |
---|
4891 | %------------------------------------------------------------------------ |
---|
4892 | function num_MaxX_Callback(hObject, eventdata, handles) |
---|
4893 | %------------------------------------------------------------------------ |
---|
4894 | set(handles.CheckFixLimits,'Value',1) %suppress auto mode |
---|
4895 | % set(handles.CheckFixLimits,'BackgroundColor',[1 1 0]) |
---|
4896 | update_plot(handles); |
---|
4897 | |
---|
4898 | %------------------------------------------------------------------------ |
---|
4899 | function num_MinY_Callback(hObject, eventdata, handles) |
---|
4900 | %------------------------------------------ |
---|
4901 | set(handles.CheckFixLimits,'Value',1) %suppress auto mode |
---|
4902 | % set(handles.CheckFixLimits,'BackgroundColor',[1 1 0]) |
---|
4903 | update_plot(handles); |
---|
4904 | |
---|
4905 | %------------------------------------------------------------------------ |
---|
4906 | function num_MaxY_Callback(hObject, eventdata, handles) |
---|
4907 | %------------------------------------------------------------------------ |
---|
4908 | set(handles.CheckFixLimits,'Value',1) %suppress auto mode |
---|
4909 | % set(handles.CheckFixLimits,'BackgroundColor',[1 1 0]) |
---|
4910 | update_plot(handles); |
---|
4911 | |
---|
4912 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
---|
4913 | % Scalar or image representation |
---|
4914 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
---|
4915 | %------------------------------------------------------------------------ |
---|
4916 | function num_MinA_Callback(hObject, eventdata, handles) |
---|
4917 | %------------------------------------------ |
---|
4918 | set(handles.CheckFixScalar,'Value',1) %suppress auto mode |
---|
4919 | % set(handles.CheckFixScalar,'BackgroundColor',[1 1 0]) |
---|
4920 | MinA=str2double(get(handles.num_MinA,'String')); |
---|
4921 | MaxA=str2double(get(handles.num_MaxA,'String')); |
---|
4922 | if MinA>MaxA% switch minA and maxA in case of error |
---|
4923 | MinA_old=MinA; |
---|
4924 | MinA=MaxA; |
---|
4925 | MaxA=MinA_old; |
---|
4926 | set(handles.num_MinA,'String',num2str(MinA,5)); |
---|
4927 | set(handles.num_MaxA,'String',num2str(MaxA,5)); |
---|
4928 | end |
---|
4929 | update_plot(handles); |
---|
4930 | |
---|
4931 | %------------------------------------------------------------------------ |
---|
4932 | function num_MaxA_Callback(hObject, eventdata, handles) |
---|
4933 | %------------------------------------------------------------------------ |
---|
4934 | set(handles.CheckFixScalar,'Value',1) %suppress auto mode |
---|
4935 | % set(handles.CheckFixScalar,'BackgroundColor',[1 1 0]) |
---|
4936 | MinA=str2double(get(handles.num_MinA,'String')); |
---|
4937 | MaxA=str2double(get(handles.num_MaxA,'String')); |
---|
4938 | if MinA>MaxA% switch minA and maxA in case of error |
---|
4939 | MinA_old=MinA; |
---|
4940 | MinA=MaxA; |
---|
4941 | MaxA=MinA_old; |
---|
4942 | set(handles.num_MinA,'String',num2str(MinA,5)); |
---|
4943 | set(handles.num_MaxA,'String',num2str(MaxA,5)); |
---|
4944 | end |
---|
4945 | update_plot(handles); |
---|
4946 | |
---|
4947 | %------------------------------------------------------------------------ |
---|
4948 | function CheckFixScalar_Callback(hObject, eventdata, handles) |
---|
4949 | %------------------------------------------------------------------------ |
---|
4950 | test=get(handles.CheckFixScalar,'Value'); |
---|
4951 | if test |
---|
4952 | % set(handles.CheckFixScalar,'BackgroundColor',[1 1 0]) |
---|
4953 | else |
---|
4954 | % set(handles.CheckFixScalar,'BackgroundColor',[0.7 0.7 0.7]) |
---|
4955 | update_plot(handles); |
---|
4956 | end |
---|
4957 | |
---|
4958 | %------------------------------------------------------------------- |
---|
4959 | function CheckBW_Callback(hObject, eventdata, handles) |
---|
4960 | %------------------------------------------------------------------- |
---|
4961 | update_plot(handles); |
---|
4962 | |
---|
4963 | %------------------------------------------------------------------- |
---|
4964 | function num_Opacity_Callback(hObject, eventdata, handles) |
---|
4965 | update_plot(handles); |
---|
4966 | %------------------------------------------------------------------- |
---|
4967 | |
---|
4968 | %------------------------------------------------------------------- |
---|
4969 | function ListContour_Callback(hObject, eventdata, handles) |
---|
4970 | %------------------------------------------------------------------- |
---|
4971 | val=get(handles.ListContour,'Value'); |
---|
4972 | if val==2% option 'contours' |
---|
4973 | set(handles.interval_txt,'Visible','on') |
---|
4974 | set(handles.num_IncrA,'Visible','on') |
---|
4975 | set(handles.num_IncrA,'String','')% refresh contour interval |
---|
4976 | % set(handles.opacity_txt,'Visible','off') |
---|
4977 | % set(handles.num_Opacity,'Visible','off') |
---|
4978 | else % option 'image' |
---|
4979 | set(handles.interval_txt,'Visible','off') |
---|
4980 | set(handles.num_IncrA,'Visible','off') |
---|
4981 | % set(handles.opacity_txt,'Visible','on') |
---|
4982 | % set(handles.num_Opacity,'Visible','on') |
---|
4983 | end |
---|
4984 | update_plot(handles); |
---|
4985 | |
---|
4986 | %------------------------------------------------------------------- |
---|
4987 | function num_IncrA_Callback(hObject, eventdata, handles) |
---|
4988 | %------------------------------------------------------------------- |
---|
4989 | update_plot(handles); |
---|
4990 | |
---|
4991 | |
---|
4992 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
---|
4993 | % Vector representation |
---|
4994 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
---|
4995 | %------------------------------------------------------------------- |
---|
4996 | function CheckHideWarning_Callback(hObject, eventdata, handles) |
---|
4997 | %------------------------------------------------------------------- |
---|
4998 | update_plot(handles); |
---|
4999 | |
---|
5000 | %------------------------------------------------------------------- |
---|
5001 | function CheckHideFalse_Callback(hObject, eventdata, handles) |
---|
5002 | %------------------------------------------------------------------- |
---|
5003 | update_plot(handles); |
---|
5004 | |
---|
5005 | %------------------------------------------------------------------- |
---|
5006 | function num_VecScale_Callback(hObject, eventdata, handles) |
---|
5007 | %------------------------------------------------------------------- |
---|
5008 | set(handles.CheckFixVectors,'Value',1); |
---|
5009 | %set(handles.CheckFixVectors,'BackgroundColor',[1 1 0]) |
---|
5010 | update_plot(handles); |
---|
5011 | |
---|
5012 | %------------------------------------------------------------------- |
---|
5013 | function CheckFixVectors_Callback(hObject, eventdata, handles) |
---|
5014 | %------------------------------------------------------------------- |
---|
5015 | if ~get(handles.CheckFixVectors,'Value') |
---|
5016 | update_plot(handles); |
---|
5017 | end |
---|
5018 | |
---|
5019 | %------------------------------------------------------------------------ |
---|
5020 | % --- Executes on selection change in CheckDecimate4 (nb_vec/4). |
---|
5021 | %------------------------------------------------------------------------ |
---|
5022 | function CheckDecimate4_Callback(hObject, eventdata, handles) |
---|
5023 | |
---|
5024 | if isequal(get(handles.CheckDecimate4,'Value'),1) |
---|
5025 | set(handles.CheckDecimate16,'Value',0) |
---|
5026 | end |
---|
5027 | update_plot(handles); |
---|
5028 | |
---|
5029 | %------------------------------------------------------------------------ |
---|
5030 | % --- Executes on selection change in CheckDecimate16 (nb_vec/16). |
---|
5031 | %------------------------------------------------------------------------ |
---|
5032 | function CheckDecimate16_Callback(hObject, eventdata, handles) |
---|
5033 | |
---|
5034 | if isequal(get(handles.CheckDecimate16,'Value'),1) |
---|
5035 | set(handles.CheckDecimate4,'Value',0) |
---|
5036 | end |
---|
5037 | update_plot(handles); |
---|
5038 | |
---|
5039 | %------------------------------------------------------------------------ |
---|
5040 | % --- Executes on selection change in ColorCode menu |
---|
5041 | function ColorCode_Callback(hObject, eventdata, handles) |
---|
5042 | %------------------------------------------------------------------------ |
---|
5043 | % edit the choice for color code |
---|
5044 | update_color_code_boxes(handles); |
---|
5045 | update_plot(handles); |
---|
5046 | |
---|
5047 | %------------------------------------------------------------------------ |
---|
5048 | function update_color_code_boxes(handles) |
---|
5049 | %------------------------------------------------------------------------ |
---|
5050 | list_code=get(handles.ColorCode,'String');% list menu fields |
---|
5051 | colcode= list_code{get(handles.ColorCode,'Value')}; % selected field |
---|
5052 | enable_slider='off';%default |
---|
5053 | enable_bounds='off';%default |
---|
5054 | enable_scalar='off';%default |
---|
5055 | switch colcode |
---|
5056 | case {'rgb','bgr'} |
---|
5057 | enable_slider='on'; |
---|
5058 | enable_bounds='on'; |
---|
5059 | enable_scalar='on'; |
---|
5060 | case '64 colors' |
---|
5061 | enable_bounds='on'; |
---|
5062 | enable_scalar='on'; |
---|
5063 | end |
---|
5064 | set(handles.Slider1,'Visible',enable_slider) |
---|
5065 | set(handles.Slider2,'Visible', enable_slider) |
---|
5066 | set(handles.num_ColCode1,'Visible',enable_slider) |
---|
5067 | set(handles.num_ColCode2,'Visible',enable_slider) |
---|
5068 | set(handles.TitleColCode1,'Visible',enable_slider) |
---|
5069 | set(handles.TitleColCode2,'Visible',enable_slider) |
---|
5070 | set(handles.CheckFixVecColor,'Visible',enable_bounds) |
---|
5071 | set(handles.num_MinVec,'Visible',enable_bounds) |
---|
5072 | set(handles.num_MaxVec,'Visible',enable_bounds) |
---|
5073 | set(handles.ColorScalar,'Visible',enable_scalar) |
---|
5074 | set_vec_col_bar(handles) |
---|
5075 | |
---|
5076 | %------------------------------------------------------------------ |
---|
5077 | % --- Executes on selection change in ColorScalar: choice of the color code. |
---|
5078 | function ColorScalar_Callback(hObject, eventdata, handles) |
---|
5079 | %------------------------------------------------------------------ |
---|
5080 | % edit the choice for color code |
---|
5081 | list_scalar=get(handles.ColorScalar,'String');% list menu fields |
---|
5082 | col_scalar= list_scalar{get(handles.ColorScalar,'Value')}; % selected field |
---|
5083 | if isequal(col_scalar,'ima_cor') |
---|
5084 | set(handles.CheckFixVecColor,'Value',1)%fixed scale by default |
---|
5085 | ColorCode='rgb'; |
---|
5086 | set(handles.num_MinVec,'String','0') |
---|
5087 | set(handles.num_MaxVec,'String','1') |
---|
5088 | set(handles.num_ColCode1,'String','0.333') |
---|
5089 | set(handles.num_ColCode2,'String','0.666') |
---|
5090 | else |
---|
5091 | set(handles.CheckFixVecColor,'Value',0)%auto scale between min,max by default |
---|
5092 | ColorCode='64 colors'; |
---|
5093 | end |
---|
5094 | ColorCodeList=get(handles.ColorCode,'String'); |
---|
5095 | ichoice=find(strcmp(ColorCode,ColorCodeList),1); |
---|
5096 | set(handles.ColorCode,'Value',ichoice)% set color code in the menu |
---|
5097 | |
---|
5098 | update_color_code_boxes(handles); |
---|
5099 | %replot the current graph |
---|
5100 | REFRESH_Callback(hObject, eventdata, handles) |
---|
5101 | |
---|
5102 | %---------------------------------------------------------------- |
---|
5103 | % -- Executes on slider movement to set the color code |
---|
5104 | % |
---|
5105 | function Slider1_Callback(hObject, eventdata, handles) |
---|
5106 | %------------------------------------------------------------------ |
---|
5107 | slider1=get(handles.Slider1,'Value'); |
---|
5108 | min_val=str2num(get(handles.num_MinVec,'String')); |
---|
5109 | max_val=str2num(get(handles.num_MaxVec,'String')); |
---|
5110 | col=min_val+(max_val-min_val)*slider1; |
---|
5111 | set(handles.num_ColCode1,'String',num2str(col)) |
---|
5112 | if(get(handles.Slider2,'Value') < col)%move also the second slider at the same value if needed |
---|
5113 | set(handles.Slider2,'Value',col) |
---|
5114 | set(handles.num_ColCode2,'String',num2str(col)) |
---|
5115 | end |
---|
5116 | set_vec_col_bar(handles) |
---|
5117 | update_plot(handles); |
---|
5118 | |
---|
5119 | %---------------------------------------------------------------- |
---|
5120 | % Executes on slider movement to set the color code |
---|
5121 | %---------------------------------------------------------------- |
---|
5122 | function Slider2_Callback(hObject, eventdata, handles) |
---|
5123 | slider2=get(handles.Slider2,'Value'); |
---|
5124 | min_val=str2num(get(handles.num_MinVec,'String')); |
---|
5125 | max_val=str2num(get(handles.num_MaxVec,'String')); |
---|
5126 | col=min_val+(max_val-min_val)*slider2; |
---|
5127 | set(handles.num_ColCode2,'String',num2str(col)) |
---|
5128 | if(get(handles.Slider1,'Value') > col)%move also the first slider at the same value if needed |
---|
5129 | set(handles.Slider1,'Value',col) |
---|
5130 | set(handles.num_ColCode1,'String',num2str(col)) |
---|
5131 | end |
---|
5132 | set_vec_col_bar(handles) |
---|
5133 | update_plot(handles); |
---|
5134 | |
---|
5135 | %---------------------------------------------------------------- |
---|
5136 | % --- Execute on return carriage on the edit box corresponding to slider 1 |
---|
5137 | %---------------------------------------------------------------- |
---|
5138 | function num_ColCode1_Callback(hObject, eventdata, handles) |
---|
5139 | set_vec_col_bar(handles) |
---|
5140 | update_plot(handles); |
---|
5141 | |
---|
5142 | %---------------------------------------------------------------- |
---|
5143 | % --- Execute on return carriage on the edit box corresponding to slider 2 |
---|
5144 | %---------------------------------------------------------------- |
---|
5145 | function num_ColCode2_Callback(hObject, eventdata, handles) |
---|
5146 | set_vec_col_bar(handles) |
---|
5147 | update_plot(handles); |
---|
5148 | %------------------------------------------------------------------------ |
---|
5149 | %------------------------------------------------------- |
---|
5150 | % --- Executes on button press in CheckFixVecColor. |
---|
5151 | %------------------------------------------------------- |
---|
5152 | function VecColBar_Callback(hObject, eventdata, handles) |
---|
5153 | set_vec_col_bar(handles) |
---|
5154 | |
---|
5155 | %------------------------------------------------------------------------ |
---|
5156 | % --- Executes on button press in CheckFixVecColor. |
---|
5157 | function CheckFixVecColor_Callback(hObject, eventdata, handles) |
---|
5158 | %------------------------------------------------------------------------ |
---|
5159 | if ~get(handles.CheckFixVecColor,'Value') |
---|
5160 | update_plot(handles); |
---|
5161 | end |
---|
5162 | |
---|
5163 | %------------------------------------------------------------------------ |
---|
5164 | % --- Executes on selection change in num_MaxVec. |
---|
5165 | function num_MinVec_Callback(hObject, eventdata, handles) |
---|
5166 | %------------------------------------------------------------------------ |
---|
5167 | num_MaxVec_Callback(hObject, eventdata, handles) |
---|
5168 | |
---|
5169 | %------------------------------------------------------------------------ |
---|
5170 | % --- Executes on selection change in num_MaxVec. |
---|
5171 | function num_MaxVec_Callback(hObject, eventdata, handles) |
---|
5172 | %------------------------------------------------------------------------ |
---|
5173 | set(handles.CheckFixVecColor,'Value',1) |
---|
5174 | CheckFixVecColor_Callback(hObject, eventdata, handles) |
---|
5175 | min_val=str2num(get(handles.num_MinVec,'String')); |
---|
5176 | max_val=str2num(get(handles.num_MaxVec,'String')); |
---|
5177 | slider1=get(handles.Slider1,'Value'); |
---|
5178 | slider2=get(handles.Slider2,'Value'); |
---|
5179 | colcode1=min_val+(max_val-min_val)*slider1; |
---|
5180 | colcode2=min_val+(max_val-min_val)*slider2; |
---|
5181 | set(handles.num_ColCode1,'String',num2str(colcode1)) |
---|
5182 | set(handles.num_ColCode2,'String',num2str(colcode2)) |
---|
5183 | update_plot(handles); |
---|
5184 | |
---|
5185 | %------------------------------------------------------------------------ |
---|
5186 | % --- update the display of color code for vectors (on vecColBar) |
---|
5187 | function set_vec_col_bar(handles) |
---|
5188 | %------------------------------------------------------------------------ |
---|
5189 | %get the image of the color display button 'VecColBar' in pixels |
---|
5190 | set(handles.VecColBar,'Units','pixel'); |
---|
5191 | pos_vert=get(handles.VecColBar,'Position'); |
---|
5192 | set(handles.VecColBar,'Units','Normalized'); |
---|
5193 | width=ceil(pos_vert(3)); |
---|
5194 | height=ceil(pos_vert(4)); |
---|
5195 | |
---|
5196 | %get slider indications |
---|
5197 | list=get(handles.ColorCode,'String'); |
---|
5198 | ichoice=get(handles.ColorCode,'Value'); |
---|
5199 | colcode.ColorCode=list{ichoice}; |
---|
5200 | colcode.MinVec=str2num(get(handles.num_MinVec,'String')); |
---|
5201 | colcode.MaxVec=str2num(get(handles.num_MaxVec,'String')); |
---|
5202 | test3color=strcmp(colcode.ColorCode,'rgb') || strcmp(colcode.ColorCode,'bgr'); |
---|
5203 | if test3color |
---|
5204 | colcode.ColCode1=str2num(get(handles.num_ColCode1,'String')); |
---|
5205 | colcode.ColCode2=str2num(get(handles.num_ColCode2,'String')); |
---|
5206 | end |
---|
5207 | vec_C=colcode.MinVec+(colcode.MaxVec-colcode.MinVec)*(0.5:width-0.5)/width;%sample of vec_C values from min to max |
---|
5208 | [colorlist,col_vec]=set_col_vec(colcode,vec_C); |
---|
5209 | oneheight=ones(1,height); |
---|
5210 | A1=colorlist(col_vec,1)*oneheight; |
---|
5211 | A2=colorlist(col_vec,2)*oneheight; |
---|
5212 | A3=colorlist(col_vec,3)*oneheight; |
---|
5213 | A(:,:,1)=A1'; |
---|
5214 | A(:,:,2)=A2'; |
---|
5215 | A(:,:,3)=A3'; |
---|
5216 | set(handles.VecColBar,'Cdata',A) |
---|
5217 | |
---|
5218 | %------------------------------------------------------------------- |
---|
5219 | function update_plot(handles) |
---|
5220 | %------------------------------------------------------------------- |
---|
5221 | set(handles.REFRESH,'BackgroundColor',[1 1 0]);% display plot activity by yellow color |
---|
5222 | drawnow |
---|
5223 | UvData=get(handles.uvmat,'UserData'); |
---|
5224 | AxeData=[]; |
---|
5225 | if isfield(UvData,'PlotAxes') |
---|
5226 | AxeData=UvData.PlotAxes;% retrieve the current plotted data |
---|
5227 | end |
---|
5228 | PlotParam=read_GUI(handles.uvmat); |
---|
5229 | [tild,PlotParamOut]= plot_field(AxeData,handles.PlotAxes,PlotParam); |
---|
5230 | errormsg=fill_GUI(PlotParamOut,handles.uvmat); |
---|
5231 | if isempty(errormsg) |
---|
5232 | set(handles.REFRESH,'BackgroundColor',[1 0 0]);% operation finished, back to red color |
---|
5233 | else |
---|
5234 | msgbox_uvmat('ERROR',errormsg) |
---|
5235 | set(handles.REFRESH,'BackgroundColor',[1 0 1]);% magenta color: graph still needs to be updated |
---|
5236 | end |
---|
5237 | |
---|
5238 | |
---|
5239 | %------------------------------------------------------------------------ |
---|
5240 | %------------------------------------------------------------------------ |
---|
5241 | % SELECTION AND EDITION OF PROJECTION OBJECTS |
---|
5242 | %------------------------------------------------------------------------ |
---|
5243 | %------------------------------------------------------------------------ |
---|
5244 | |
---|
5245 | % --- Executes on selection change in ListObject_1. |
---|
5246 | function ListObject_1_Callback(hObject, eventdata, handles) |
---|
5247 | list_str=get(handles.ListObject,'String'); |
---|
5248 | UvData=get(handles.uvmat,'UserData'); |
---|
5249 | ObjectData=UvData.ProjObject{get(handles.ListObject_1,'Value')}; |
---|
5250 | |
---|
5251 | %% update the projection plot on uvmat |
---|
5252 | ProjData= proj_field(UvData.Field,ObjectData);%project the current input field on object ObjectData |
---|
5253 | plot_field(ProjData,handles.PlotAxes,read_GUI(handles.uvmat));% plot the projected field; |
---|
5254 | %replot all the objects within the new projected field |
---|
5255 | for IndexObj=1:numel(list_str) |
---|
5256 | hobject=UvData.ProjObject{IndexObj}.DisplayHandle.uvmat; |
---|
5257 | if isempty(hobject) || ~ishandle(hobject) |
---|
5258 | hobject=handles.PlotAxes; |
---|
5259 | end |
---|
5260 | if isequal(IndexObj,get(handles.ListObject,'Value')) |
---|
5261 | objectcolor='m'; %paint in magenta the currently selected object in ListObject |
---|
5262 | else |
---|
5263 | objectcolor='b'; |
---|
5264 | end |
---|
5265 | UvData.ProjObject{IndexObj}.DisplayHandle.uvmat=plot_object(UvData.ProjObject{IndexObj},ObjectData,hobject,objectcolor);%draw the object in uvmat |
---|
5266 | end |
---|
5267 | set(handles.uvmat,'UserData',UvData) |
---|
5268 | |
---|
5269 | %% display the object parameters if the GUI set_object is already opened |
---|
5270 | if ~get(handles.CheckViewObject,'Value') |
---|
5271 | ZBounds=0; % default |
---|
5272 | if isfield(UvData.Field,'ZMin') && isfield(UvData.Field,'ZMax') |
---|
5273 | ZBounds(1)=UvData.Field.ZMin; %minimum for the Z slider |
---|
5274 | ZBounds(2)=UvData.Field.ZMax;%maximum for the Z slider |
---|
5275 | end |
---|
5276 | ObjectData.Name=list_str{get(handles.ListObject_1,'Value')}; |
---|
5277 | hset_object=set_object(ObjectData,[],ZBounds); |
---|
5278 | set(hset_object,'name','set_object') |
---|
5279 | set(handles.CheckViewObject,'Value',1)% show that the selected object in ListObject_1 is currently visualised |
---|
5280 | end |
---|
5281 | |
---|
5282 | % desactivate the edit object mode |
---|
5283 | set(handles.CheckEditObject,'Value',0) |
---|
5284 | % set(handles.CheckEditObject,'BackgroundColor',[0.7,0.7,0.7]) |
---|
5285 | |
---|
5286 | %------------------------------------------------------------------------ |
---|
5287 | % --- Executes on selection change in ListObject. |
---|
5288 | function ListObject_Callback(hObject, eventdata, handles) |
---|
5289 | %------------------------------------------------------------------------ |
---|
5290 | list_str=get(handles.ListObject,'String'); |
---|
5291 | IndexObj=get(handles.ListObject,'Value');%present object selection |
---|
5292 | UvData=get(handles.uvmat,'UserData'); |
---|
5293 | if numel(UvData.ProjObject)<IndexObj |
---|
5294 | return |
---|
5295 | end |
---|
5296 | ObjectData=UvData.ProjObject{IndexObj}; |
---|
5297 | ZBounds=0; % default |
---|
5298 | if isfield(UvData.Field,'ZMin') && isfield(UvData.Field,'ZMax') |
---|
5299 | ZBounds(1)=UvData.Field.ZMin; %minimum for the Z slider |
---|
5300 | ZBounds(2)=UvData.Field.ZMax;%maximum for the Z slider |
---|
5301 | end |
---|
5302 | |
---|
5303 | %% show object features if view_object isselected |
---|
5304 | if get(handles.CheckViewObject,'value') |
---|
5305 | hset_object=set_object(ObjectData,[],ZBounds); |
---|
5306 | set(hset_object,'name','set_object') |
---|
5307 | end |
---|
5308 | |
---|
5309 | %% desactivate the edit object mode for security |
---|
5310 | set(handles.CheckEditObject,'Value',0) |
---|
5311 | |
---|
5312 | %% update the plot on view_field if view_field is already openened |
---|
5313 | hview_field=findobj(allchild(0),'tag','view_field'); |
---|
5314 | if isempty(hview_field) |
---|
5315 | hhview_field.PlotAxes=[]; |
---|
5316 | else |
---|
5317 | Data=get(hview_field,'UserData'); |
---|
5318 | hhview_field=guidata(hview_field); |
---|
5319 | ProjData= proj_field(UvData.Field,ObjectData);%project the current interface field on ObjectData |
---|
5320 | [PlotType,PlotParam]=plot_field(ProjData,hhview_field.PlotAxes,read_GUI(hview_field));%read plotting parameters on the uvmat interface |
---|
5321 | haxes=findobj(hview_field,'tag','axes3'); |
---|
5322 | pos=get(hview_field,'Position'); |
---|
5323 | if strcmp(get(haxes,'Visible'),'off')%sempty(PlotParam.Axes)% case of no plot display (pure text table) |
---|
5324 | h_TableDisplay=findobj(hview_field,'tag','TableDisplay'); |
---|
5325 | pos_table=get(h_TableDisplay,'Position'); |
---|
5326 | set(hview_field,'Position',[pos(1)+pos(3)-pos_table(3) pos(2)+pos(4)-pos_table(4) pos_table(3) pos_table(4)]) |
---|
5327 | drawnow% needed to change position before the next command |
---|
5328 | set(hview_field,'UserData',Data);% restore the previously stored GUI position after GUI resizing |
---|
5329 | else |
---|
5330 | % set(hview_field,'Position',Data.GUISize)% return to the previously stored GUI position and size |
---|
5331 | end |
---|
5332 | end |
---|
5333 | |
---|
5334 | %% update the color of the graphic object representation: the selected object in magenta, others in blue |
---|
5335 | update_object_color(handles.PlotAxes,hhview_field.PlotAxes,UvData.ProjObject{IndexObj}.DisplayHandle.uvmat) |
---|
5336 | |
---|
5337 | %------------------------------------------------------------------------ |
---|
5338 | %--- update the color representation of objects (indicating the selected ones) |
---|
5339 | function update_object_color(axes_uvmat,axes_view_field,DisplayHandle) |
---|
5340 | %------------------------------------------------------------------------ |
---|
5341 | if isempty(axes_view_field)% case with no view_field plot |
---|
5342 | hother=[findobj(axes_uvmat,'Tag','proj_object');findobj(axes_uvmat,'Tag','DeformPoint')];%find all the proj object and deform point representations |
---|
5343 | else |
---|
5344 | hother=[findobj(axes_uvmat,'Tag','proj_object') ;findobj(axes_view_field,'Tag','proj_object');... %find all the proj object representations |
---|
5345 | findobj(axes_uvmat,'Tag','DeformPoint'); findobj(axes_view_field,'Tag','DeformPoint')];%find all the deform point representations |
---|
5346 | end |
---|
5347 | for iobj=1:length(hother) |
---|
5348 | if isequal(get(hother(iobj),'Type'),'rectangle')||isequal(get(hother(iobj),'Type'),'patch') |
---|
5349 | set(hother(iobj),'EdgeColor','b') |
---|
5350 | if isequal(get(hother(iobj),'FaceColor'),'m') |
---|
5351 | set(hother(iobj),'FaceColor','b') |
---|
5352 | end |
---|
5353 | elseif isequal(get(hother(iobj),'Type'),'image') |
---|
5354 | Acolor=get(hother(iobj),'CData'); |
---|
5355 | Acolor(:,:,1)=zeros(size(Acolor,1),size(Acolor,2)); |
---|
5356 | set(hother(iobj),'CData',Acolor); |
---|
5357 | else |
---|
5358 | set(hother(iobj),'Color','b') |
---|
5359 | end |
---|
5360 | set(hother(iobj),'Selected','off') |
---|
5361 | end |
---|
5362 | if ishandle(DisplayHandle) |
---|
5363 | linetype=get(DisplayHandle,'Type'); |
---|
5364 | if isequal(linetype,'line') |
---|
5365 | set(DisplayHandle,'Color','m'); %set the selected object to magenta color |
---|
5366 | elseif isequal(linetype,'rectangle') |
---|
5367 | set(DisplayHandle,'EdgeColor','m'); %set the selected object to magenta color |
---|
5368 | elseif isequal(linetype,'patch') |
---|
5369 | set(DisplayHandle,'FaceColor','m'); %set the selected object to magenta color |
---|
5370 | end |
---|
5371 | SubObjectData=get(DisplayHandle,'UserData'); |
---|
5372 | if isfield(SubObjectData,'SubObject') & ishandle(SubObjectData.SubObject) |
---|
5373 | for iobj=1:length(SubObjectData.SubObject) |
---|
5374 | hsub=SubObjectData.SubObject(iobj); |
---|
5375 | if isequal(get(hsub,'Type'),'rectangle') |
---|
5376 | set(hsub,'EdgeColor','m'); %set the selected object to magenta color |
---|
5377 | elseif isequal(get(hsub,'Type'),'image') |
---|
5378 | Acolor=get(hsub,'CData'); |
---|
5379 | Acolor(:,:,1)=Acolor(:,:,3); |
---|
5380 | set(hsub,'CData',Acolor); |
---|
5381 | else |
---|
5382 | set(hsub,'Color','m') |
---|
5383 | end |
---|
5384 | end |
---|
5385 | end |
---|
5386 | if isfield(SubObjectData,'DeformPoint') & ishandle(SubObjectData.DeformPoint) |
---|
5387 | set(SubObjectData.DeformPoint,'Color','m') |
---|
5388 | end |
---|
5389 | end |
---|
5390 | |
---|
5391 | %------------------------------------------------------------------- |
---|
5392 | % --- Executes on selection change in CheckEditObject. |
---|
5393 | function CheckEditObject_Callback(hObject, eventdata, handles) |
---|
5394 | %------------------------------------------------------------------- |
---|
5395 | hset_object=findobj(allchild(0),'Tag','set_object'); |
---|
5396 | if get(handles.CheckEditObject,'Value') |
---|
5397 | %suppress the other options |
---|
5398 | set(handles.MenuObject,'checked','off') |
---|
5399 | set(handles.CheckZoom,'Value',0) |
---|
5400 | CheckZoom_Callback(hObject, eventdata, handles) |
---|
5401 | hgeometry_calib=findobj(allchild(0),'tag','geometry_calib'); |
---|
5402 | if ishandle(hgeometry_calib) |
---|
5403 | hhgeometry_calib=guidata(hgeometry_calib); |
---|
5404 | set(hhgeometry_calib.CheckEnableMouse,'Value',0)% desactivate mouse action in geometry_calib |
---|
5405 | set(hhgeometry_calib.CheckEnableMouse,'BackgroundColor',[0.7 0.7 0.7]) |
---|
5406 | end |
---|
5407 | set(handles.CheckViewObject,'value',1) |
---|
5408 | CheckViewObject_Callback(hObject, eventdata, handles) |
---|
5409 | else % desactivate object edit mode |
---|
5410 | if ~isempty(hset_object)% open the |
---|
5411 | set(get(hset_object,'children'),'Enable','off') |
---|
5412 | hSAVE=findobj(hset_object,'Tag','SAVE'); |
---|
5413 | set(hSAVE,'Enable','on') |
---|
5414 | end |
---|
5415 | end |
---|
5416 | |
---|
5417 | |
---|
5418 | %------------------------------------------------------------------------ |
---|
5419 | % --- Executes on button press in CheckViewObject. |
---|
5420 | function CheckViewObject_Callback(hObject, eventdata, handles) |
---|
5421 | %------------------------------------------------------------------------ |
---|
5422 | check_view=get(handles.CheckViewObject,'Value'); |
---|
5423 | |
---|
5424 | if check_view %activate set_object |
---|
5425 | IndexObj=get(handles.ListObject,'Value'); |
---|
5426 | list_object=get(handles.ListObject,'String'); |
---|
5427 | UvData=get(handles.uvmat,'UserData');%read UvData properties stored on the uvmat interface |
---|
5428 | UvData.ProjObject{IndexObj}.Name=list_object{IndexObj}; |
---|
5429 | if numel(UvData.ProjObject)<IndexObj;% error in UvData |
---|
5430 | msgbox_uvmat('ERROR','invalid object list') |
---|
5431 | return |
---|
5432 | end |
---|
5433 | ZBounds=0; % default |
---|
5434 | if isfield(UvData.Field,'ZMin') && isfield(UvData.Field,'ZMax') |
---|
5435 | ZBounds(1)=UvData.Field.ZMin; %minimum for the Z slider |
---|
5436 | ZBounds(2)=UvData.Field.ZMax;%maximum for the Z slider |
---|
5437 | end |
---|
5438 | data=UvData.ProjObject{IndexObj}; |
---|
5439 | if ~isfield(data,'Type')% default plane |
---|
5440 | data.Type='plane'; |
---|
5441 | end |
---|
5442 | hset_object=set_object(data,[],ZBounds); |
---|
5443 | set(hset_object,'name','set_object') |
---|
5444 | hhset_object=guidata(hset_object); |
---|
5445 | if get(handles.CheckEditObject,'Value')% edit mode |
---|
5446 | set(get(hset_object,'children'),'Enable','on') |
---|
5447 | else |
---|
5448 | set(get(hset_object,'children'),'Enable','off')% deactivate the GUI except SAVE |
---|
5449 | set(hhset_object.SAVE,'Enable','on') |
---|
5450 | end |
---|
5451 | else |
---|
5452 | hset_object=findobj(allchild(0),'tag','set_object'); |
---|
5453 | if ~isempty(hset_object) |
---|
5454 | delete(hset_object)% delete existing version of set_object |
---|
5455 | end |
---|
5456 | end |
---|
5457 | |
---|
5458 | |
---|
5459 | %------------------------------------------------------------------------ |
---|
5460 | % --- Executes on button press in CheckViewField. |
---|
5461 | function CheckViewField_Callback(hObject, eventdata, handles) |
---|
5462 | %------------------------------------------------------------------------ |
---|
5463 | check_view=get(handles.CheckViewField,'Value'); |
---|
5464 | |
---|
5465 | if check_view |
---|
5466 | IndexObj=get(handles.ListObject,'Value'); |
---|
5467 | UvData=get(handles.uvmat,'UserData');%read UvData properties stored on the uvmat interface |
---|
5468 | if numel(UvData.ProjObject)<IndexObj(end);% error in UvData |
---|
5469 | msgbox_uvmat('ERROR','invalid object list') |
---|
5470 | return |
---|
5471 | end |
---|
5472 | ZBounds=0; % default |
---|
5473 | if isfield(UvData.Field,'ZMin') && isfield(UvData.Field,'ZMax') |
---|
5474 | ZBounds(1)=UvData.Field.ZMin; %minimum for the Z slider |
---|
5475 | ZBounds(2)=UvData.Field.ZMax;%maximum for the Z slider |
---|
5476 | end |
---|
5477 | set(handles.ListObject,'Value',IndexObj);%restore ListObject selection after set_object deletion |
---|
5478 | if ~isfield(UvData.ProjObject{IndexObj(1)},'Type')% default plane |
---|
5479 | UvData.ProjObject{IndexObj(1)}.Type='plane'; |
---|
5480 | end |
---|
5481 | list_object=get(handles.ListObject,'String'); |
---|
5482 | UvData.ProjObject{IndexObj(end)}.Name=list_object{IndexObj(end)}; |
---|
5483 | |
---|
5484 | %% show the projection of the selected object on view_field |
---|
5485 | ProjData= proj_field(UvData.Field,UvData.ProjObject{IndexObj});%project the current field on ObjectData |
---|
5486 | hview_field=findobj(allchild(0),'tag','view_field'); |
---|
5487 | if isempty(hview_field) |
---|
5488 | hview_field=view_field; |
---|
5489 | end |
---|
5490 | hhview_field=guidata(hview_field); |
---|
5491 | [PlotType,PlotParam]=plot_field(ProjData,hhview_field.PlotAxes,read_GUI(hview_field));%read plotting parameters on the GUI view_field); |
---|
5492 | errormsg=fill_GUI(PlotParam,hview_field); |
---|
5493 | for list={'Scalar','Vectors'} |
---|
5494 | if ~isfield(PlotParam,list{1}) |
---|
5495 | set(hhview_field.(list{1}),'Visible','off') |
---|
5496 | end |
---|
5497 | end |
---|
5498 | haxes=findobj(hview_field,'tag','axes3'); |
---|
5499 | pos=get(hview_field,'Position'); |
---|
5500 | if strcmp(get(haxes,'Visible'),'off')%sempty(PlotParam.Axes)% case of no plot display (pure text table) |
---|
5501 | h_TableDisplay=findobj(hview_field,'tag','TableDisplay'); |
---|
5502 | pos_table=get(h_TableDisplay,'Position'); |
---|
5503 | set(hview_field,'Position',[pos(1)+pos(3)-pos_table(3) pos(2)+pos(4)-pos_table(4) pos_table(3) pos_table(4)]) |
---|
5504 | else |
---|
5505 | Data=get(hview_field,'UserData'); |
---|
5506 | end |
---|
5507 | else |
---|
5508 | hview_field=findobj(allchild(0),'tag','view_field'); |
---|
5509 | if ~isempty(hview_field) |
---|
5510 | delete(hview_field)% delete existing version of set_object |
---|
5511 | end |
---|
5512 | end |
---|
5513 | |
---|
5514 | |
---|
5515 | %------------------------------------------------------------------------ |
---|
5516 | % --- Executes on button press in DeleteObject. |
---|
5517 | %------------------------------------------------------------------------ |
---|
5518 | function DeleteObject_Callback(hObject, eventdata, handles) |
---|
5519 | |
---|
5520 | IndexObj=get(handles.ListObject,'Value');%projection object selected for view_field |
---|
5521 | IndexObj_1=get(handles.ListObject_1,'Value');%projection object selected for uvmat plot |
---|
5522 | if IndexObj>1 && ~isequal(IndexObj,IndexObj_1) % do not delete the object used for the uvmat plot |
---|
5523 | delete_object(IndexObj) |
---|
5524 | end |
---|
5525 | |
---|
5526 | %'DeleteObject': delete a projection object, defined by its index in the Uvmat list or by its graphic handle |
---|
5527 | %------------------------------------------------------------------------ |
---|
5528 | % function DeleteObject(hObject) |
---|
5529 | % |
---|
5530 | % INPUT: |
---|
5531 | % hObject: object index (if integer) or handle of the graphic object. If |
---|
5532 | % hObject is a subobject, the parent object is detected and deleted. |
---|
5533 | |
---|
5534 | function delete_object(IndexObj) |
---|
5535 | |
---|
5536 | huvmat=findobj('tag','uvmat');%handles of the uvmat interface |
---|
5537 | UvData=get(huvmat,'UserData'); |
---|
5538 | hlist_object=findobj(huvmat,'Tag','ListObject');%handles of the object list in the uvmat interface |
---|
5539 | list_str=get(hlist_object,'String');%objet list |
---|
5540 | if ~isempty(UvData) && isfield(UvData, 'ProjObject') && length(UvData.ProjObject)>=IndexObj |
---|
5541 | if isfield(UvData.ProjObject{IndexObj},'DisplayHandle') && isfield(UvData.ProjObject{IndexObj}.DisplayHandle,'uvmat') |
---|
5542 | hdisplay=UvData.ProjObject{IndexObj}.DisplayHandle.uvmat;%handle of the object graphic representation in uvmat |
---|
5543 | for iview=1:length(hdisplay) |
---|
5544 | if ishandle(hdisplay(iview)) && ~isequal(hdisplay(iview),0) |
---|
5545 | ObjectData=get(hdisplay(iview),'UserData'); |
---|
5546 | if isfield(ObjectData,'SubObject') && ~isempty(ObjectData.SubObject) |
---|
5547 | delete(ObjectData.SubObject(ishandle(ObjectData.SubObject)));% delete the graphic 'sub-objects (e.g. projection bounds) |
---|
5548 | end |
---|
5549 | if isfield(ObjectData,'DeformPoint')&& ~isempty(ObjectData.DeformPoint) |
---|
5550 | delete(ObjectData.DeformPoint(ishandle(ObjectData.DeformPoint)));% delete the graphic deformation points |
---|
5551 | delete(hdisplay(iview))% delete the main graphic representation of the object |
---|
5552 | end |
---|
5553 | end |
---|
5554 | ishandle(hdisplay(iview)) |
---|
5555 | end |
---|
5556 | for iobj=IndexObj+1:length(UvData.ProjObject) |
---|
5557 | hdisplay=UvData.ProjObject{iobj}.DisplayHandle.uvmat; |
---|
5558 | for iview=1:length(hdisplay) |
---|
5559 | if ishandle(hdisplay(iview)) && ~isequal(hdisplay(iview),0) |
---|
5560 | PlotData=get(hdisplay(iview),'UserData'); |
---|
5561 | PlotData.IndexObj=iobj-1; |
---|
5562 | set(hdisplay(iview),'UserData',PlotData); |
---|
5563 | end |
---|
5564 | end |
---|
5565 | end |
---|
5566 | end |
---|
5567 | UvData.ProjObject(IndexObj)=[]; |
---|
5568 | end |
---|
5569 | if numel(list_str)>=IndexObj |
---|
5570 | list_str(IndexObj)=[]; |
---|
5571 | end |
---|
5572 | set(huvmat,'UserData',UvData); |
---|
5573 | set(hlist_object,'String',list_str) |
---|
5574 | set(hlist_object,'Value',length(list_str)) |
---|
5575 | hlist_object_1=findobj(huvmat,'Tag','ListObject_1');%handles of the first object list in the uvmat interface |
---|
5576 | old_index=get(hlist_object_1,'Value'); |
---|
5577 | set(hlist_object_1,'String',list_str) |
---|
5578 | if IndexObj<=old_index |
---|
5579 | set(hlist_object_1,'Value',old_index-1) |
---|
5580 | end |
---|
5581 | |
---|
5582 | |
---|
5583 | |
---|
5584 | |
---|
5585 | %TODO: use to modify fill_GUI |
---|
5586 | %'write_plot_param': update the plotting parameters on the uvmat or view_field interface after a plotting operation |
---|
5587 | function write_plot_param(handles,PlotParam) |
---|
5588 | %% axes |
---|
5589 | if isempty(PlotParam.Axes) |
---|
5590 | set(handles.Axes,'Visible','off') |
---|
5591 | set(handles.PlotAxes,'Visible','off') |
---|
5592 | set(handles.text_display,'Visible','off') |
---|
5593 | set(handles.TableDisplay,'Visible','on') |
---|
5594 | else |
---|
5595 | set(handles.Axes,'Visible','on') |
---|
5596 | set(handles.PlotAxes,'Visible','on') |
---|
5597 | set(handles.text_display,'Visible','on') |
---|
5598 | if isfield(handles,'TableDisplay') |
---|
5599 | set(handles.TableDisplay,'Visible','off') |
---|
5600 | end |
---|
5601 | Coordinates=PlotParam.Axes; |
---|
5602 | if isfield(Coordinates,'CheckFixAspectRatio') |
---|
5603 | if Coordinates.CheckFixAspectRatio |
---|
5604 | set(handles.CheckFixAspectRatio,'Value',1) |
---|
5605 | else |
---|
5606 | set(handles.CheckFixAspectRatio,'Value',0) |
---|
5607 | |
---|
5608 | end |
---|
5609 | end |
---|
5610 | if isfield(Coordinates,'AspectRatio') |
---|
5611 | set(handles.num_AspectRatio,'String',num2str(Coordinates.AspectRatio)) |
---|
5612 | end |
---|
5613 | if isfield(Coordinates,'MinX') |
---|
5614 | set(handles.num_MinX,'String',num2str(Coordinates.MinX,4)); |
---|
5615 | set(handles.num_MaxX,'String',num2str(Coordinates.MaxX,4)); |
---|
5616 | set(handles.num_MinY,'String',num2str(Coordinates.MinY,4)); |
---|
5617 | set(handles.num_MaxY,'String',num2str(Coordinates.MaxY,4)); |
---|
5618 | else |
---|
5619 | set(handles.num_MinX,'String',''); |
---|
5620 | set(handles.num_MaxX,'String',''); |
---|
5621 | set(handles.num_MinY,'String',''); |
---|
5622 | set(handles.num_MaxY,'String',''); |
---|
5623 | end |
---|
5624 | end |
---|
5625 | |
---|
5626 | %% scalar or image parameters |
---|
5627 | if isfield(PlotParam,'Scalar') |
---|
5628 | set(handles.Scalar,'Visible','on') |
---|
5629 | if isfield(PlotParam.Scalar,'MaxA') |
---|
5630 | set(handles.num_MaxA,'String',num2str(PlotParam.Scalar.MaxA,3)); |
---|
5631 | end |
---|
5632 | if isfield(PlotParam.Scalar,'MinA') |
---|
5633 | set(handles.num_MinA,'String',num2str(PlotParam.Scalar.MinA,3)); |
---|
5634 | end |
---|
5635 | if isfield(PlotParam.Scalar,'IncrA') |
---|
5636 | set(handles.num_IncrA,'String',num2str(PlotParam.Scalar.IncrA,3)) |
---|
5637 | end |
---|
5638 | set(handles.CheckBW,'Value',PlotParam.Scalar.CheckBW) |
---|
5639 | if isfield(PlotParam.Scalar,'Opacity')&&isfield(handles,'num_Opacity') |
---|
5640 | set(handles.num_Opacity,'String',num2str(PlotParam.Scalar.Opacity)) |
---|
5641 | end |
---|
5642 | else |
---|
5643 | set(handles.Scalar,'Visible','off') |
---|
5644 | end |
---|
5645 | |
---|
5646 | %% parameter for vector field |
---|
5647 | if isfield(PlotParam,'Vectors') |
---|
5648 | set(handles.Vectors,'Visible','on') |
---|
5649 | if isfield(PlotParam.Vectors,'VecScale') |
---|
5650 | set(handles.num_VecScale,'String',num2str(PlotParam.Vectors.VecScale,3)) |
---|
5651 | end |
---|
5652 | if isfield(PlotParam.Vectors,'MinC')&& isfield(PlotParam.Vectors,'MaxC') |
---|
5653 | MinC=PlotParam.Vectors.MinC; |
---|
5654 | MaxC=PlotParam.Vectors.MaxC; |
---|
5655 | set(handles.num_MinVec,'String', num2str(MinC,3)); |
---|
5656 | set(handles.num_MaxVec,'String',num2str(MaxC,3)); |
---|
5657 | list=get(handles.ColorCode,'String'); |
---|
5658 | ichoice=get(handles.ColorCode,'Value'); |
---|
5659 | color_option=list{ichoice}; |
---|
5660 | test3color=strcmp(color_option,'rgb')||strcmp(color_option,'bgr'); |
---|
5661 | if test3color% need to update color thresholds |
---|
5662 | set(handles.num_ColCode1,'Visible','on') |
---|
5663 | set(handles.num_ColCode2,'Visible','on') |
---|
5664 | set(handles.Slider1,'Visible','on') |
---|
5665 | set(handles.Slider2,'Visible','on') |
---|
5666 | set(handles.num_ColCode1,'String',num2str(PlotParam.Vectors.ColCode1,3)) |
---|
5667 | set(handles.num_ColCode2,'String',num2str(PlotParam.Vectors.ColCode2,3)) |
---|
5668 | set(handles.Slider1,'Value',(PlotParam.Vectors.ColCode1-MinC)/(MaxC-MinC)) |
---|
5669 | set(handles.Slider2,'Value',(PlotParam.Vectors.ColCode2-MinC)/(MaxC-MinC)) |
---|
5670 | else |
---|
5671 | set(handles.num_ColCode1,'Visible','off') |
---|
5672 | set(handles.num_ColCode2,'Visible','off') |
---|
5673 | set(handles.Slider1,'Visible','off') |
---|
5674 | set(handles.Slider2,'Visible','off') |
---|
5675 | end |
---|
5676 | end |
---|
5677 | else |
---|
5678 | set(handles.Vectors,'Visible','off') |
---|
5679 | if isfield(handles,'edit_vect') |
---|
5680 | set(handles.edit_vect,'Visible','off') |
---|
5681 | set(handles.record,'Visible','off') |
---|
5682 | end |
---|
5683 | end |
---|
5684 | |
---|
5685 | % -------------------------------------------------------------------- |
---|
5686 | % --- Executes on button press in CheckTable. |
---|
5687 | % -------------------------------------------------------------------- |
---|
5688 | function CheckTable_Callback(hObject, eventdata, handles) |
---|
5689 | if get(handles.CheckTable,'Value') |
---|
5690 | set(handles.TableDisplay,'Visible','on') |
---|
5691 | else |
---|
5692 | set(handles.TableDisplay,'Visible','off') |
---|
5693 | end |
---|