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 fields (with fields
|
---|
12 | % ListVarName....)
|
---|
13 | %
|
---|
14 | %AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
|
---|
15 | % Copyright Joel Sommeria, 2008, LEGI / CNRS-UJF-INPG, joel.sommeria@legi.grenoble-inp.fr.
|
---|
16 | %AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
|
---|
17 | % This open is part of the toolbox UVMAT.
|
---|
18 | %
|
---|
19 | % UVMAT is free software; you can redistribute it and/or modify
|
---|
20 | % it under the terms of the GNU General Public License as published by
|
---|
21 | % the Free Software Foundation; either version 2 of the License, or
|
---|
22 | % (at your option) any later version.
|
---|
23 | %
|
---|
24 | % UVMAT is distributed in the hope that it will be useful,
|
---|
25 | % but WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
26 | % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
---|
27 | % GNU General Public License (open UVMAT/COPYING.txt) for more details.
|
---|
28 | %AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
|
---|
29 | %
|
---|
30 | % Information stored on the interface:
|
---|
31 | % 'Strings' of all edit boxes and menus: get(handles.Tag,'String')
|
---|
32 | % 'Values' of all menus and toggle buttons: get(handles.Tag,'Value')
|
---|
33 | % Matlab structure stored as 'UserData' of the figure uvmat.fig,(can be obtained by right mouse click on the interface).
|
---|
34 | % It contains the following fields:
|
---|
35 | % - Fixed specifiacation of plotting figures and axes (defined bu uvmat_OpeningFcn)
|
---|
36 | % .PosColorbar: [0.8210 0.4710 0.0190 0.4450]; specified position of the colorbar on figures
|
---|
37 | % - Information read in the documentation open of a series (activated by RootPath_Callback) :
|
---|
38 | % .XmlData, with fields:
|
---|
39 | % .Time: matrix of times of the images with index i and j
|
---|
40 | % .GeometryCalib: [1x1 struct]
|
---|
41 | % - Information defined from the interface:
|
---|
42 | % .NewSeries: =1 when the first view of a new field series is displayed, else 0
|
---|
43 | % .filename:(char string)
|
---|
44 | % .VelType:(char string) type of velocity field selected
|
---|
45 | % .VelType_1:(char string) REMPLACER LE CELL ACTUEL
|
---|
46 | % .FieldName: (char string) main field selected('image', 'velocity'...)
|
---|
47 | % .FieldName_1:(char string) second field selected('image', 'velocity'...)
|
---|
48 | % .CName: (char string)name of the scalar used for vector colors
|
---|
49 | % .CoordType: (char string) coordinate transform: e.g. 'phys' or 'px'
|
---|
50 | % .MouseAction: store the current effect of mouse button (create or edit objects)
|
---|
51 | % - Information on projection objects
|
---|
52 | % .Object: {[1x1 struct]}
|
---|
53 | % .CurrentObjectIndex: index of the projection object .Object currently selected for editing
|
---|
54 | % -Information on the current field (Field{i})
|
---|
55 | % .Txt : text information to display (e.g. error message)
|
---|
56 | % .NbDim: number of dimensions (=0 by default)
|
---|
57 | % .NbCoord: number of vector components
|
---|
58 | % .CoordType: expresses the type of coordinate ('px' for image, 'sig' for instruments, or 'phys')
|
---|
59 | % .dt: time interval for the corresponding image pair
|
---|
60 | % .Mesh: estimated typical distance between vectors
|
---|
61 | % .ZMax:
|
---|
62 | % .ZMin:
|
---|
63 | % .X, .Y, .Z: set of vector coordinates
|
---|
64 | % .U,.V,.W: corresponding set of vector components
|
---|
65 | % .F: corresponding set of warning flags
|
---|
66 | % .FF: corresponding set of false flags, =0 for good vectors
|
---|
67 | % .C: corresponding values of the scalar used for vector color
|
---|
68 | % (.X, .Y, .Z,.U,.V,.W,.F,.FF,.C are matlab vectors of the same length,
|
---|
69 | % equal to the number of vectors stored in the input open)
|
---|
70 | % .CName: name of the scalar .C
|
---|
71 | % .CType: type of the scalar .C, setting how the scalar is obtained (see 'Scalars' below)
|
---|
72 | % .A image or scalar
|
---|
73 | % .AX: vector of dimension 2 representing the first and last values
|
---|
74 | % of the X coordinates for the image or scalar known on a regular grid,
|
---|
75 | % or vector of dimension .A for a scaler defined on irregular grid.
|
---|
76 | % .AY: same as .AX along the Y direction
|
---|
77 | % .AName: name of the scalar, ='image' for an image
|
---|
78 |
|
---|
79 | % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%% DATA FLOW (for run0_Callback) %%%%%%%%%%%%%%%%%%%%:
|
---|
80 | %
|
---|
81 | % Main input open second input open(_1) second image (pair animation)
|
---|
82 | % read_ncfield.m | |
|
---|
83 | % read image.m | |
|
---|
84 | % Field{1} Field{2}
|
---|
85 | % |
|
---|
86 | % coord transform (phys.m) or other user defined fct acting on Field{i} |
|
---|
87 | % Field{i}
|
---|
88 | % |
|
---|
89 | % calc_field.m: calculate scalar or other derived fields (vort, div..).
|
---|
90 | %
|
---|
91 | % sub_field.m: combine the input Field{i} in a single set of fields (vector + scalar):
|
---|
92 | % Field{i=1->3}.X --> UvData.X |
|
---|
93 | % |
|
---|
94 | % UvData
|
---|
95 | % |
|
---|
96 | % plot histograms of the whole field
|
---|
97 | % proj_field.m: project the set of fields on the current projection objects defined by UvData.Object
|
---|
98 | % | |
|
---|
99 | % ObjectData
|
---|
100 | % |
|
---|
101 | % plot_field.m: plot the projected fields and store them as user |
|
---|
102 | % data of the plotting axes |
|
---|
103 | % |
|
---|
104 | % AxeData
|
---|
105 | %
|
---|
106 | %%%%%%%%%%%%%% SCALARS: %%%%%%%%%%%%??%%%
|
---|
107 | % scalars are displayed either as an image or countour plot, either as a color of
|
---|
108 | % velocity vectors. The scalar values in the first case is represented by
|
---|
109 | % UvData.Field.A, and by UvData.Field.C in the second case. The corresponding set of X
|
---|
110 | % and Y coordinates are represented by UvData.Field.AX and UvData.Field.AY, and .X and
|
---|
111 | % .Y for C (the same as velocity vectors). If A is a nxxny matrix (scalar
|
---|
112 | % on a regtular grid), then .AX andf.AY contains only two elements, represneting the
|
---|
113 | % coordinates of the four image corners. The scalar name is represented by
|
---|
114 | % the strings .AName and/or .CName.
|
---|
115 | % If the scalar exists in an input open (image or scalar stored under its
|
---|
116 | % name in a netcdf open), it is directly read at the level of Field{1}or Field{2}.
|
---|
117 | % Else only its name AName is recorded in Field{i}, and its field is then calculated
|
---|
118 | %by the fuction calc_scal after the coordinate transform or after projection on an edit
|
---|
119 |
|
---|
120 | % Properties attached to plotting figures (standard Matlab properties):
|
---|
121 | % 'CurrentAxes'= gca or get(gcf,'CurrentAxes');
|
---|
122 | % 'CurrentPoint'=get(gcf,'CurrentPoint'): figure coordinates of the point over which the mouse is positioned
|
---|
123 | % 'CurrentCharacter'=get(gcf,'CurrentCharacter'): last character typed over the figure where the mouse is positioned
|
---|
124 | % 'WindowButtonMotionFcn': function permanently called by mouse motion over the figure
|
---|
125 | % 'KeyPressFcn': function called by pressing a key on the key board
|
---|
126 | % 'WindowButtonDownFcn': function called by pressing the mouse over the figure
|
---|
127 | % 'WindowButtonUpFcn': function called by releasing the mouse pressure over the figure
|
---|
128 |
|
---|
129 | % Properties attached to plotting axes:
|
---|
130 | % 'CurrentPoint'=get(gca,'CurrentPoint'); (standard Matlab) same as for the figure, but position in plot coordinates.
|
---|
131 | % AxeData:=get(gca,'UserData');
|
---|
132 | % AxeData.Drawing = create: create a new edit
|
---|
133 | % = deform: modify an existing edit by moving its defining create
|
---|
134 | % = off: no current drawing action
|
---|
135 | % = translate: translate an existing edit
|
---|
136 | % = zoom: isolate a subregion for zoom in=1 if an edit is being currently drawn, 0 else (set to 0 by releasing mouse button)
|
---|
137 | % .hset_edit=handle of the set_edit interface (if a projection edit is edited);
|
---|
138 | % .CurrentOrigin: Origin of a curently drawn edit
|
---|
139 | % .CurrentLine: currently drawn menuline (A REVOIR)
|
---|
140 | % .CurrentObject: handle of the currently drawn edit
|
---|
141 | % .CurrentRectZoom: current rectangle used for zoom
|
---|
142 | % .zoomon : zoom state (a revoir)
|
---|
143 | % .X, .Y, .Z: array of coordinates defining the position of the vector: ASSOCIER AU PLAN (OBJET) PLUTOT QU'A L'AXE ?
|
---|
144 | % .U, .V, .W: array of components of the vector
|
---|
145 | % .C:
|
---|
146 | % .F:
|
---|
147 | % .FF:
|
---|
148 | % .A
|
---|
149 |
|
---|
150 | % Properties attached to projection objects (create, menuline, menuplane...):
|
---|
151 | % 'Tag'='proj_edit': for all projection objects
|
---|
152 | % ObjectData.Style=...: style of projection edit:
|
---|
153 | % .ProjMode
|
---|
154 | % .Coord: defines the position of the edit
|
---|
155 | % .XMin,YMin....
|
---|
156 | % .XMax,YMax....
|
---|
157 | % .DX,DY,DZ
|
---|
158 | % .Phi, .Theta, .Psi : Euler angles
|
---|
159 | % .X,.Y,.U,.V.... : field data projected on the edit
|
---|
160 | % .IndexObj: index in the list of UvData.Object
|
---|
161 | %during plotting
|
---|
162 | % .plotaxes: handles of the current axes used to plot the result of field projection on the object
|
---|
163 | % .plothandle: vector of handle(s) of the object graphic represnetation in all the opened plotting axes
|
---|
164 | % To each projection object #iobj, corresponds an axis
|
---|
165 | % Object{iobj}.plotaxes and nbobj representation graphs Object{iobj}.plothandles(:) (where nbobj is the
|
---|
166 | % nbre of current objects opened in uvmat. Note that Object{iobj}.plothandles(iobj)=[] : an object is not represented in its own projection field;
|
---|
167 |
|
---|
168 | %------------------------------------------------------------------------
|
---|
169 | %------------------------------------------------------------------------
|
---|
170 | % I - MAIN FUNCTION UVMAT (DO NOT MODIFY)
|
---|
171 | %------------------------------------------------------------------------
|
---|
172 | %------------------------------------------------------------------------
|
---|
173 | function varargout = uvmat(varargin)
|
---|
174 |
|
---|
175 | % Begin initialization code - DO NOT EDIT
|
---|
176 | gui_Singleton = 1;
|
---|
177 | gui_State = struct('gui_Name', mfilename, ...
|
---|
178 | 'gui_Singleton', gui_Singleton, ...
|
---|
179 | 'gui_OpeningFcn', @uvmat_OpeningFcn, ...
|
---|
180 | 'gui_OutputFcn', @uvmat_OutputFcn, ...
|
---|
181 | 'gui_LayoutFcn', [], ...
|
---|
182 | 'gui_Callback', []);
|
---|
183 | if nargin && ischar(varargin{1})&& ~isempty(regexp(varargin{1},'_Callback','once'))
|
---|
184 | gui_State.gui_Callback = str2func(varargin{1});
|
---|
185 | end
|
---|
186 |
|
---|
187 | if nargout
|
---|
188 | varargout{1:nargout} = gui_mainfcn(gui_State, varargin{:});
|
---|
189 | else
|
---|
190 | gui_mainfcn(gui_State, varargin{:});
|
---|
191 | end
|
---|
192 | % End initialization code - DO NOT EDIT
|
---|
193 |
|
---|
194 | %------------------------------------------------------------------------
|
---|
195 | % --- Executes just before uvmat is made visible.
|
---|
196 | function uvmat_OpeningFcn(hObject, eventdata, handles, input )
|
---|
197 | %------------------------------------------------------------------------
|
---|
198 | global nb_builtin
|
---|
199 |
|
---|
200 | % Choose default command menuline output for uvmat
|
---|
201 | handles.output = hObject;
|
---|
202 |
|
---|
203 | % Update handles structure
|
---|
204 | guidata(hObject, handles);
|
---|
205 |
|
---|
206 | % set the position of colorbar and ancillary GUIs:
|
---|
207 | set(hObject,'Units','Normalized')
|
---|
208 | movegui(hObject,'center')
|
---|
209 | UvData.PosColorbar=[0.805 0.022 0.019 0.445];
|
---|
210 | UvData.SetObjectOrigin=[-0.05 -0.03]; %position for set_object
|
---|
211 | UvData.SetObjectSize=[0.3 0.7];
|
---|
212 | UvData.CalOrigin=[0.95 -0.03];%position for geometry_calib (TO IMPROVE)
|
---|
213 | UvData.CalSize=[0.28 1];
|
---|
214 |
|
---|
215 | %functions for the mouse and keyboard
|
---|
216 | set(handles.histo_u,'NextPlot','replacechildren');
|
---|
217 | set(handles.histo_v,'NextPlot','replacechildren');
|
---|
218 | set(hObject,'KeyPressFcn',{'keyboard_callback',handles})%set keyboard action function
|
---|
219 | set(hObject,'WindowButtonMotionFcn',{'mouse_motion',handles})%set mouse action functio
|
---|
220 | set(hObject,'WindowButtonDownFcn',{'mouse_down'})%set mouse click action function
|
---|
221 | set(hObject,'WindowButtonUpFcn',{'mouse_up',handles})
|
---|
222 | set(hObject,'DeleteFcn',{@closefcn})%
|
---|
223 |
|
---|
224 | %refresh projection plane
|
---|
225 | UvData.Object{1}.Style='plane';%main plotting plane
|
---|
226 | UvData.Object{1}.ProjMode='projection';%main plotting plane
|
---|
227 | if ~isfield(UvData.Object{1},'plotaxes')
|
---|
228 | UvData.Object{1}.plotaxes=handles.axes3;%default plotting axis
|
---|
229 | set(handles.list_object_1,'Value',1);
|
---|
230 | set(handles.list_object_1,'String',{'1-PLANE'});
|
---|
231 | end
|
---|
232 |
|
---|
233 | %TRANSFORM menu: builtin fcts
|
---|
234 | menu_str={'';'phys';'px';'phys_polar'};
|
---|
235 | nb_builtin=numel(menu_str); %number of functions
|
---|
236 | path_uvmat=fileparts(which('uvmat'));
|
---|
237 | addpath(fullfile(path_uvmat,'transform_field'))
|
---|
238 | fct_handle{1,1}=[];
|
---|
239 | testexist=zeros(size(menu_str'));%default
|
---|
240 | testexist(1)=1;
|
---|
241 | for ilist=2:length(menu_str)
|
---|
242 | if exist(menu_str{ilist},'file')
|
---|
243 | fct_handle{ilist,1}=str2func(menu_str{ilist});
|
---|
244 | testexist(ilist)=1;
|
---|
245 | else
|
---|
246 | testexist(ilist)=0;
|
---|
247 | end
|
---|
248 | end
|
---|
249 | rmpath(fullfile(path_uvmat,'transform_field'))
|
---|
250 |
|
---|
251 | %load the list of previously browsed files in menus Open and Open_1
|
---|
252 | dir_perso=prefdir; % path to the directory .matlab for personal data
|
---|
253 | profil_perso=fullfile(dir_perso,'uvmat_perso.mat');% personal data file uvmauvmat_perso.mat' in .matlab
|
---|
254 | if exist(profil_perso,'file')
|
---|
255 | h=load (profil_perso);
|
---|
256 | if isfield(h,'MenuFile_1')
|
---|
257 | set(handles.MenuFile_1,'Label',h.MenuFile_1);
|
---|
258 | set(handles.MenuFile_1_1,'Label',h.MenuFile_1);
|
---|
259 | end
|
---|
260 | if isfield(h,'MenuFile_1')
|
---|
261 | set(handles.MenuFile_2,'Label',h.MenuFile_2);
|
---|
262 | set(handles.MenuFile_2_1,'Label',h.MenuFile_2);
|
---|
263 | end
|
---|
264 | if isfield(h,'MenuFile_1')
|
---|
265 | set(handles.MenuFile_3,'Label',h.MenuFile_3);
|
---|
266 | set(handles.MenuFile_3_1,'Label',h.MenuFile_3);
|
---|
267 | end
|
---|
268 | if isfield(h,'MenuFile_1')
|
---|
269 | set(handles.MenuFile_4,'Label',h.MenuFile_4);
|
---|
270 | set(handles.MenuFile_4_1,'Label',h.MenuFile_4);
|
---|
271 | end
|
---|
272 | if isfield(h,'MenuFile_1')
|
---|
273 | set(handles.MenuFile_5,'Label',h.MenuFile_5);
|
---|
274 | set(handles.MenuFile_5_1,'Label',h.MenuFile_5);
|
---|
275 | end
|
---|
276 | if isfield(h,'transform_fct') && iscell(h.transform_fct)
|
---|
277 | for ilist=1:length(h.transform_fct);
|
---|
278 | [path,file]=fileparts(h.transform_fct{ilist});
|
---|
279 | addpath(path)
|
---|
280 | if exist(file,'file')
|
---|
281 | h_func=str2func(file);
|
---|
282 | testexist=[testexist 1];
|
---|
283 | else
|
---|
284 | h_func=[];
|
---|
285 | testexist=[testexist 0];
|
---|
286 | end
|
---|
287 | fct_handle=[fct_handle; {h_func}]; %concatene the list of paths
|
---|
288 | rmpath(path)
|
---|
289 | menu_str=[menu_str; {file}];
|
---|
290 | end
|
---|
291 | end
|
---|
292 | end
|
---|
293 | menu_str=menu_str(testexist==1);%=menu_str(testexist~=0)
|
---|
294 | fct_handle=fct_handle(testexist==1);
|
---|
295 | menu_str=[menu_str;{'more...'}];
|
---|
296 | set(handles.transform_fct,'String',menu_str)
|
---|
297 | set(handles.transform_fct,'UserData',fct_handle)% store the list of path in UserData of ACTION
|
---|
298 |
|
---|
299 | %initiates menu of vector colors
|
---|
300 | list_menu=calc_field;
|
---|
301 | %list_menu=[{'ima_cor'};{'black'};{'white'};list_menu(3:end)];
|
---|
302 | set(handles.col_vec,'String',list_menu)
|
---|
303 |
|
---|
304 | %check the path and date of modification of all functions in uvmat
|
---|
305 | path_to_uvmat=which ('uvmat');% check the path detected for source file uvmat
|
---|
306 | [errormsg,date_str]=check_functions;%check the path of the functions called by uvmat.m
|
---|
307 | date_str=['last modification: ' date_str];
|
---|
308 | %case of an input argument for uvmat
|
---|
309 | testinputfield=0;
|
---|
310 | inputfile=[];
|
---|
311 | Field=[];
|
---|
312 | if exist('input','var')
|
---|
313 | if ~isempty(errormsg)
|
---|
314 | msgbox_uvmat('WARNING',errormsg)
|
---|
315 | end
|
---|
316 | if ishandle(handles.UVMAT_title)
|
---|
317 | delete(handles.UVMAT_title)
|
---|
318 | end
|
---|
319 | if isstruct(input)
|
---|
320 | if isfield(input,'InputFile')
|
---|
321 | inputfile=input.InputFile;
|
---|
322 | end
|
---|
323 | Field=input;
|
---|
324 | elseif ischar(input)% file name introduced as input
|
---|
325 | inputfile=input;
|
---|
326 | elseif isnumeric(input)%simple matrix introduced as input
|
---|
327 | sizinput=size(input);
|
---|
328 | if sizinput(1)<=1 || sizinput(2)<=1
|
---|
329 | msgbox_uvmat('ERROR','bad input for uvmat: file name, structure or numerical matrix accepted')
|
---|
330 | return
|
---|
331 | end
|
---|
332 | Field.ListVarName={'A','coord_y','coord_x'};
|
---|
333 | Field.VarDimName={{'coord_y','coord_x'},'cord_y','coord_x'};
|
---|
334 | Field.A=input;
|
---|
335 | Field.coord_x=[0.5 size(input,2)-0.5];
|
---|
336 | Field.coord_y=[size(input,1)-0.5 0.5];
|
---|
337 | end
|
---|
338 | if ~isempty(inputfile)
|
---|
339 | display_file_name(hObject, eventdata, handles,inputfile)
|
---|
340 | testinputfield=1;
|
---|
341 | else
|
---|
342 | UvData.TestInputFile=0;
|
---|
343 | end
|
---|
344 | if ~isempty(Field)
|
---|
345 | set(handles.Fields,'Value',1)
|
---|
346 | set(handles.Fields,'String',{'get_field...'})
|
---|
347 | testinputfield=1;
|
---|
348 |
|
---|
349 | % set the colorbar position on the interface:
|
---|
350 | UvData.PosColorbar=[0.805 0.022 0.019 0.445];
|
---|
351 | elseif ischar(input)
|
---|
352 | scan_i_Callback(handles.scan_i, eventdata, handles);
|
---|
353 | end
|
---|
354 | else
|
---|
355 | if ishandle(handles.UVMAT_title)
|
---|
356 | fid=fopen('revision.log');
|
---|
357 | if fid~=-1
|
---|
358 | a=textscan(fid,'%s%s%s',1,'HeaderLines',1,'Delimiter','|');
|
---|
359 | set(handles.UVMAT_title,'String',[{'Copyright Joel Sommeria, 2008, Coriolis/ LEGI / CNRS-UJF-INPG'};{'GNU General Public License'}; {path_to_uvmat}; ...
|
---|
360 | {['at revision ' a{1}{1}]};a{3}(1);{date_str};errormsg]);
|
---|
361 | fclose(fid);
|
---|
362 | else
|
---|
363 | set(handles.UVMAT_title,'String',[{'Copyright Joel Sommeria, 2008, Coriolis/ LEGI / CNRS-UJF-INPG'};{'GNU General Public License'};{path_to_uvmat};...
|
---|
364 | {date_str};errormsg]);
|
---|
365 | end
|
---|
366 | end
|
---|
367 | end
|
---|
368 | UvData.NewSeries=1;
|
---|
369 | set(hObject,'UserData',UvData)
|
---|
370 | if testinputfield
|
---|
371 | %delete drawn objects
|
---|
372 | hother=findobj(handles.axes3,'Tag','proj_object');%find all the proj objects
|
---|
373 | for iobj=1:length(hother)
|
---|
374 | delete_object(hother(iobj))
|
---|
375 | end
|
---|
376 | if isempty(inputfile)
|
---|
377 | errormsg=refresh_field(handles,[],[],[],[],[],[],{Field});
|
---|
378 | set(handles.MenuTools,'Enable','on')
|
---|
379 | set(handles.OBJECT_txt,'Visible','on')
|
---|
380 | set(handles.edit,'Visible','on')
|
---|
381 | set(handles.list_object_1,'Visible','on')
|
---|
382 | set(handles.frame_object,'Visible','on')
|
---|
383 | if ~isempty(errormsg)
|
---|
384 | msgbox_uvmat('ERROR',errormsg)
|
---|
385 | end
|
---|
386 | else
|
---|
387 | update_rootinfo(hObject,eventdata,handles);
|
---|
388 | end
|
---|
389 | end
|
---|
390 | set_vec_col_bar(handles) %update the display of color code for vectors
|
---|
391 |
|
---|
392 | %-------------------------------------------------------------------
|
---|
393 | % --- Outputs from this function are returned to the command menuline.
|
---|
394 | function varargout = uvmat_OutputFcn(hObject, eventdata, handles)
|
---|
395 | varargout{1} = handles.output;% the only output argument is the handle to the GUI figure
|
---|
396 |
|
---|
397 | %-------------------------------------------------------------------
|
---|
398 | %-------------------------------------------------------------------
|
---|
399 | % II - FUNCTIONS FOR INTRODUCING THE INPUT FILES
|
---|
400 | % automatically sets the global properties when the rootfile name is introduced
|
---|
401 | % then activate the view-field action if selected
|
---|
402 | % it is activated either by clicking on the RootPath window or by the
|
---|
403 | % browser
|
---|
404 | %------------------------------------------------------------------
|
---|
405 | %------------------------------------------------------------------
|
---|
406 |
|
---|
407 | % --- Executes on the menu Open/Browse...
|
---|
408 | % search the files, recognize their type according to their name and fill the rootfile input windows
|
---|
409 | function MenuBrowse_Callback(hObject, eventdata, handles)
|
---|
410 | oldfile=read_file_boxes(handles);
|
---|
411 |
|
---|
412 | if isempty(oldfile)||isequal(oldfile,'') %loads the previously stored file name and set it as default in the file_input box
|
---|
413 | dir_perso=prefdir;
|
---|
414 | profil_perso=fullfile(dir_perso,'uvmat_perso.mat');
|
---|
415 | if exist(profil_perso,'file')
|
---|
416 | h=load (profil_perso);
|
---|
417 | if isfield(h,'MenuFile_1')
|
---|
418 | oldfile=h.MenuFile_1;
|
---|
419 | end
|
---|
420 | end
|
---|
421 | end
|
---|
422 | [FileName, PathName] = uigetfile( ...
|
---|
423 | {'*.xml;*.xls;*.civ;*.png;*.jpg;*.tif;*.avi;*.AVI;*.vol;*.nc;*.cmx;*.fig;*.log;*.dat;*.bat;', ' (*.xml,*.xls,*.civ,*.jpg ,*.png, .tif, *.avi,*.vol,*.nc,*.cmx ,*.fig,*.log,*.dat,*.bat)';
|
---|
424 | '*.xml', '.xml files '; ...
|
---|
425 | '*.xls', '.xls files '; ...
|
---|
426 | '*.civ', '.civ files '; ...
|
---|
427 | '*.jpg',' jpeg image files'; ...
|
---|
428 | '*.png','.png image files'; ...
|
---|
429 | '*.tif','.tif image files'; ...
|
---|
430 | '*.avi;*.AVI','.avi movie files'; ...
|
---|
431 | '*.vol','.volume images (png)'; ...
|
---|
432 | '*.nc','.netcdf files'; ...
|
---|
433 | '*.cdf','.netcdf files'; ...
|
---|
434 | '*.cmx','.cmx text files';...
|
---|
435 | '*.cmx2','.cmx2 text files';...
|
---|
436 | '*.fig','.fig files (matlab fig)';...
|
---|
437 | '*.log','.log text files ';...
|
---|
438 | '*.dat','.dat text files ';...
|
---|
439 | '*.bat','.bat system command text files';...
|
---|
440 | '*.*', 'All Files (*.*)'}, ...
|
---|
441 | 'Pick a file',oldfile);
|
---|
442 | %global filebase
|
---|
443 | fileinput=[PathName FileName];%complete file name
|
---|
444 | testblank=findstr(fileinput,' ');%look for blanks
|
---|
445 | if ~isempty(testblank)
|
---|
446 | msgbox_uvmat('ERROR',['The input file name ' fileinput ' contains blank character : This is not allowed. Please change name'])
|
---|
447 | return
|
---|
448 | end
|
---|
449 | sizf=size(fileinput);
|
---|
450 | if (~ischar(fileinput)||~isequal(sizf(1),1)),return;end
|
---|
451 |
|
---|
452 | % display the selected field and related information
|
---|
453 | display_file_name(hObject, eventdata, handles,fileinput)
|
---|
454 |
|
---|
455 | %update list of recent files in the menubar
|
---|
456 | MenuFile_1=fileinput;
|
---|
457 | MenuFile_2=get(handles.MenuFile_1,'Label');
|
---|
458 | MenuFile_3=get(handles.MenuFile_2,'Label');
|
---|
459 | MenuFile_4=get(handles.MenuFile_3,'Label');
|
---|
460 | MenuFile_5=get(handles.MenuFile_4,'Label');
|
---|
461 | set(handles.MenuFile_1,'Label',MenuFile_1)
|
---|
462 | set(handles.MenuFile_2,'Label',MenuFile_2)
|
---|
463 | set(handles.MenuFile_3,'Label',MenuFile_3)
|
---|
464 | set(handles.MenuFile_4,'Label',MenuFile_4)
|
---|
465 | set(handles.MenuFile_5,'Label',MenuFile_5)
|
---|
466 | set(handles.MenuFile_1_1,'Label',MenuFile_1)
|
---|
467 | set(handles.MenuFile_2_1,'Label',MenuFile_2)
|
---|
468 | set(handles.MenuFile_3_1,'Label',MenuFile_3)
|
---|
469 | set(handles.MenuFile_4_1,'Label',MenuFile_4)
|
---|
470 | set(handles.MenuFile_5_1,'Label',MenuFile_5)
|
---|
471 | dir_perso=prefdir;
|
---|
472 | profil_perso=fullfile(dir_perso,'uvmat_perso.mat');
|
---|
473 | if exist(profil_perso,'file')
|
---|
474 | save (profil_perso,'MenuFile_1','MenuFile_2','MenuFile_3','MenuFile_4', 'MenuFile_5','-append'); %store the file names for future opening of uvmat
|
---|
475 | else
|
---|
476 | txt=ver;
|
---|
477 | Release=txt(1).Release;
|
---|
478 | relnumb=str2double(Release(3:4));
|
---|
479 | if relnumb >= 14
|
---|
480 | save (profil_perso,'MenuFile_1','MenuFile_2','MenuFile_3','MenuFile_4', 'MenuFile_5','-V6'); %store the file names for future opening of uvmat
|
---|
481 | else
|
---|
482 | save (profil_perso,'MenuFile_1','MenuFile_2','MenuFile_3','MenuFile_4', 'MenuFile_5'); %store the file names for future opening of uvmat
|
---|
483 | end
|
---|
484 | end
|
---|
485 |
|
---|
486 | % --------------------------------------------------------------------
|
---|
487 | function MenuFile_1_Callback(hObject, eventdata, handles)
|
---|
488 | fileinput=get(handles.MenuFile_1,'Label');
|
---|
489 | display_file_name(hObject, eventdata, handles,fileinput)
|
---|
490 |
|
---|
491 | % --------------------------------------------------------------------
|
---|
492 | function MenuFile_2_Callback(hObject, eventdata, handles)
|
---|
493 | fileinput=get(handles.MenuFile_2,'Label');
|
---|
494 | display_file_name(hObject, eventdata, handles,fileinput)
|
---|
495 |
|
---|
496 | % --------------------------------------------------------------------
|
---|
497 | function MenuFile_3_Callback(hObject, eventdata, handles)
|
---|
498 | fileinput=get(handles.MenuFile_3,'Label');
|
---|
499 | display_file_name(hObject, eventdata, handles,fileinput)
|
---|
500 |
|
---|
501 | % --------------------------------------------------------------------
|
---|
502 | function MenuFile_4_Callback(hObject, eventdata, handles)
|
---|
503 | fileinput=get(handles.MenuFile_4,'Label');
|
---|
504 | display_file_name(hObject, eventdata, handles,fileinput)
|
---|
505 |
|
---|
506 | % --------------------------------------------------------------------
|
---|
507 | function MenuFile_5_Callback(hObject, eventdata, handles)
|
---|
508 | fileinput=get(handles.MenuFile_5,'Label');
|
---|
509 | display_file_name(hObject, eventdata, handles,fileinput)
|
---|
510 |
|
---|
511 | %-----------------------------------------------------------------
|
---|
512 | % fills the edit boxes RootPath, RootFile,NomType...from an input file name 'fileinput'
|
---|
513 | %----------------------------------------------------------------
|
---|
514 | function display_file_name(hObject, eventdata, handles,fileinput)
|
---|
515 | if ~exist(fileinput,'file')
|
---|
516 | msgbox_uvmat('ERROR',['input file ' fileinput ' does not exist'])
|
---|
517 | return
|
---|
518 | end
|
---|
519 | [RootPath,RootFile,i1,i2,str_a,str_b,ext,NomType,SubDir]=name2display(fileinput);
|
---|
520 | ext_test=''; %default
|
---|
521 | if ~isempty(ext)
|
---|
522 | form=imformats(ext(2:end));%test valid Matlab image formats
|
---|
523 | if ~isempty(form)
|
---|
524 | ext_test='.image';
|
---|
525 | imainfo=imfinfo(fileinput);
|
---|
526 | if length(imainfo) >1 %case of image with multiple frames
|
---|
527 | i1='1'; % set the frame counter to 1 by default
|
---|
528 | i2='';
|
---|
529 | str_a='';
|
---|
530 | str_b='';
|
---|
531 | NomType='*'; %indicate a set of indexed frames within a single file
|
---|
532 | [RootPath,RootFile]=fileparts(fileinput); %include the indices in the root file
|
---|
533 | end
|
---|
534 | elseif isequal(lower(ext),'.avi')
|
---|
535 | ext_test='.image';
|
---|
536 | i1='1'; % set the frame counter to 1 by default
|
---|
537 | i2='';
|
---|
538 | str_a='';
|
---|
539 | str_b='';
|
---|
540 | NomType='*'; %indicate a set of indexed frames within a single file
|
---|
541 | [RootPath,RootFile]=fileparts(fileinput); %include the indices in the root file
|
---|
542 | else
|
---|
543 | ext_test=lower(ext);
|
---|
544 | end
|
---|
545 | end
|
---|
546 | switch ext_test
|
---|
547 | case {'.civ','.log','.cmx','.cmx2','.txt','.bat'} %display text file
|
---|
548 | edit(fileinput)
|
---|
549 | case '.fig' %display matlab figure
|
---|
550 | hfig=open(fileinput);
|
---|
551 | set(hfig,'WindowButtonMotionFcn','mouse_motion')%set mouse action functio
|
---|
552 | set(hfig,'WindowButtonUpFcn','mouse_up')%set mouse click action function
|
---|
553 | set(hfig,'WindowButtonUpFcn','mouse_down')%set mouse click action function
|
---|
554 | case {'.xml','.xls'} % edit xml or Excel files
|
---|
555 | editxml(fileinput);
|
---|
556 | case {'.avi','.image','.vol','.nc','.cdf'}
|
---|
557 | set(handles.RootPath,'String',RootPath);
|
---|
558 | if isequal(SubDir,'')
|
---|
559 | rootname=fullfile(RootPath,RootFile);
|
---|
560 | else
|
---|
561 | rootname=fullfile(RootPath,SubDir,RootFile);
|
---|
562 | SubDir=['/' SubDir]; %display the separator
|
---|
563 | end
|
---|
564 | set(handles.SubDir,'String',SubDir);
|
---|
565 | set(handles.RootFile,'String',['/' RootFile]); %display the separator
|
---|
566 | indices=fileinput(length(rootname)+1:end);
|
---|
567 | indices(end-length(ext)+1:end)=[]; %remove extension
|
---|
568 | set(handles.FileIndex,'String',indices);
|
---|
569 | set(handles.FileIndex,'UserData',NomType);
|
---|
570 | set(handles.FileExt,'String',ext);
|
---|
571 | % fill file index counters
|
---|
572 | set(handles.i1,'String',i1);
|
---|
573 | set(handles.i2,'String',i2);
|
---|
574 | set(handles.j1,'String',str_a);
|
---|
575 | set(handles.j2,'String',str_b);
|
---|
576 |
|
---|
577 | % synchronise indices of the second input file if it exists
|
---|
578 | if get(handles.SubField,'Value')==1% if the subfield button is activated, update the field numbers
|
---|
579 | [ff,rr,FileBase_1,ii,FileExt_1,SubDir_1]=read_file_boxes_1(handles);
|
---|
580 | NomType_1=get(handles.FileIndex_1,'UserData');
|
---|
581 | FileName_1=name_generator(FileBase_1,str2double(i1),str2double(i2),FileExt_1,NomType_1,1,stra2num(str_a),stra2num(str_b),SubDir_1);
|
---|
582 | if exist(FileName_1,'file')
|
---|
583 | FileIndex_1=name_generator('',str2double(i1),str2double(i2),'',NomType_1,1,stra2num(str_a),stra2num(str_b),'');
|
---|
584 | set(handles.FileIndex_1,'String',FileIndex_1)
|
---|
585 | else
|
---|
586 | set(handles.SubField,'Value',0)
|
---|
587 | SubField_Callback(hObject, eventdata, handles)
|
---|
588 | end
|
---|
589 | end
|
---|
590 |
|
---|
591 | %enable other menus
|
---|
592 | set(handles.MenuOpen_1,'Enable','on')
|
---|
593 | set(handles.MenuFile_1_1,'Enable','on')
|
---|
594 | set(handles.MenuFile_2_1,'Enable','on')
|
---|
595 | set(handles.MenuFile_3_1,'Enable','on')
|
---|
596 | set(handles.MenuFile_4_1,'Enable','on')
|
---|
597 | set(handles.MenuFile_5_1,'Enable','on')
|
---|
598 | set(handles.MenuExport,'Enable','on')
|
---|
599 | set(handles.MenuExportFigure,'Enable','on')
|
---|
600 | set(handles.MenuExportMovie,'Enable','on')
|
---|
601 | set(handles.MenuTools,'Enable','on')
|
---|
602 | set(handles.OBJECT_txt,'Visible','on')
|
---|
603 | set(handles.edit,'Visible','on')
|
---|
604 | set(handles.list_object_1,'Visible','on')
|
---|
605 | set(handles.frame_object,'Visible','on')
|
---|
606 | % initiate input file:
|
---|
607 | update_rootinfo(hObject,eventdata,handles);
|
---|
608 | otherwise
|
---|
609 | msgbox_uvmat('ERROR',['invalid input file extension' ext])
|
---|
610 | end
|
---|
611 |
|
---|
612 | %------------------------------------------------------------------------
|
---|
613 | function RootPath_Callback(hObject,eventdata,handles)
|
---|
614 | %------------------------------------------------------------------------
|
---|
615 | update_rootinfo(hObject,eventdata,handles);
|
---|
616 |
|
---|
617 | %------------------------------------------------------------------------
|
---|
618 | %-- called by action in RootFile edit box
|
---|
619 | function SubDir_Callback(hObject, eventdata, handles)
|
---|
620 | %------------------------------------------------------------------------
|
---|
621 | %refresh the menu of input fields
|
---|
622 | Fields_Callback(hObject, eventdata, handles);
|
---|
623 | % refresh the current field
|
---|
624 | run0_Callback(hObject, eventdata, handles);
|
---|
625 |
|
---|
626 | %------------------------------------------------------------------------
|
---|
627 | % --- called by action in RootFile edit box
|
---|
628 | function RootFile_Callback(hObject, eventdata, handles)
|
---|
629 | %------------------------------------------------------------------------
|
---|
630 | update_rootinfo(hObject,eventdata,handles)
|
---|
631 |
|
---|
632 | %------------------------------------------------------------------------
|
---|
633 | % --- called by action in FileIndex edit box
|
---|
634 | function FileIndex_Callback(hObject, eventdata, handles)
|
---|
635 | %------------------------------------------------------------------------
|
---|
636 | FileIndices=get(handles.FileIndex,'String');
|
---|
637 | if isempty(str2num(FileIndices))
|
---|
638 | [pp,ff,str1,str2,str_a,str_b]=name2display(FileIndices);
|
---|
639 | else
|
---|
640 | str1=FileIndices;
|
---|
641 | str2='';
|
---|
642 | str_a='';
|
---|
643 | str_b='';
|
---|
644 | end
|
---|
645 | set(handles.i1,'String',str1);
|
---|
646 | set(handles.i2,'String',str2);
|
---|
647 | set(handles.j1,'String',str_a);
|
---|
648 | set(handles.j2,'String',str_b);
|
---|
649 | run0_Callback(hObject, eventdata, handles)
|
---|
650 |
|
---|
651 | %------------------------------------------------------------------------
|
---|
652 | % --- called by action in FileIndex_1 edit box
|
---|
653 | function FileIndex_1_Callback(hObject, eventdata, handles)
|
---|
654 | %------------------------------------------------------------------------
|
---|
655 | run0_Callback(hObject, eventdata, handles)
|
---|
656 |
|
---|
657 | %------------------------------------------------------------------------
|
---|
658 | % --- update information about a new field series (indices to scan, timing, calibration from an xml file, then refresh current plots
|
---|
659 | function update_rootinfo(hObject,eventdata,handles)
|
---|
660 | %------------------------------------------------------------------------
|
---|
661 | set(handles.RootPath,'BackgroundColor',[1 1 0])
|
---|
662 | drawnow
|
---|
663 | set(handles.Fields,'UserData',[])% reinialize data from uvmat opening
|
---|
664 | UvData=get(handles.uvmat,'UserData');%huvmat=handles of the uvmat interface
|
---|
665 | UvData.NewSeries=1; %flag for run0: begin a new series
|
---|
666 | UvData.TestInputFile=1;
|
---|
667 | set(handles.fix_pair,'Value',1) % activate by default the comp_input '-'input window
|
---|
668 |
|
---|
669 | [FileName,RootPath,FileBase,FileIndices,FileExt,SubDir]=read_file_boxes(handles);
|
---|
670 | if ~exist(FileName,'file')
|
---|
671 | msgbox_uvmat('ERROR',['input file ' FileName ' not found']);
|
---|
672 | return
|
---|
673 | end
|
---|
674 | nbfield=[];%default
|
---|
675 | nburst=[];%default
|
---|
676 |
|
---|
677 | % read timing and total frame number from the current file (movie files) !! may be overrid by xml file
|
---|
678 | XmlData.Time=[];%default
|
---|
679 | XmlData.GeometryCalib=[];%default
|
---|
680 | TimeUnit=[];%default
|
---|
681 | testima=0; %test for image input
|
---|
682 | imainfo=[];
|
---|
683 | ColorType='falsecolor'; %default
|
---|
684 | hhh='';
|
---|
685 | if isequal(lower(FileExt),'.avi') %.avi file
|
---|
686 | testima=1;
|
---|
687 | imainfo=aviinfo([FileBase FileIndices FileExt]);
|
---|
688 | nbfield=imainfo.NumFrames;
|
---|
689 | nburst=1;
|
---|
690 | set(handles.Dt_txt,'String',['Dt=' num2str(1000/imainfo.FramesPerSecond) 'ms']);%display the elementary time interval in millisec
|
---|
691 | XmlData.Time=(0:1/imainfo.FramesPerSecond:(imainfo.NumFrames-1)/imainfo.FramesPerSecond)';
|
---|
692 | TimeUnit='s';
|
---|
693 | hhh=which('mmreader');
|
---|
694 | ColorType=imainfo.ImageType;%='truecolor' for color images
|
---|
695 | elseif ~isempty(imformats(FileExt(2:end))) || isequal(FileExt,'.vol')%&& isequal(NomType,'*')% multi-frame image
|
---|
696 | testima=1;
|
---|
697 | if ~isequal(SubDir,'')
|
---|
698 | RootFile=get(handles.RootFile,'String');
|
---|
699 | imainfo=imfinfo([fullfile(RootPath,SubDir,RootFile) FileIndices FileExt]);
|
---|
700 | else
|
---|
701 | imainfo=imfinfo([FileBase FileIndices FileExt]);
|
---|
702 | end
|
---|
703 | ColorType=imainfo.ColorType;%='truecolor' for color images
|
---|
704 | if length(imainfo) >1 %case of image with multiple frames
|
---|
705 | nbfield=length(imainfo);
|
---|
706 | nburst=1;
|
---|
707 | end
|
---|
708 | end
|
---|
709 | if ~strcmp(hhh,'')&& mmreader.isPlatformSupported()% if the function is found (recent version of matlab)
|
---|
710 | UvData.MovieObject=mmreader([FileBase FileIndices FileExt]);
|
---|
711 | elseif isfield(UvData,'MovieObject')
|
---|
712 | UvData=rmfield(UvData,'MovieObject');
|
---|
713 | end
|
---|
714 | if isfield(imainfo,'Width') && isfield(imainfo,'Height')
|
---|
715 | set(handles.npx,'String',num2str(imainfo.Width));%fills nbre of pixels x box
|
---|
716 | set(handles.npy,'String',num2str(imainfo.Height));%fills nbre of pixels x box
|
---|
717 | else
|
---|
718 | set(handles.npx,'String','');%fills nbre of pixels x box
|
---|
719 | set(handles.npy,'String','');%fills nbre of pixels x box
|
---|
720 | end
|
---|
721 | set(handles.BW,'Value',strcmp(ColorType,'grayscale'))% select handles.BW if grayscale image
|
---|
722 |
|
---|
723 | % read parameters (time, geometric calibration..) from a documentation file (.xml advised)
|
---|
724 | filexml=[FileBase '.xml'];
|
---|
725 | fileciv=[FileBase '.civ'];
|
---|
726 | warntext='';%default warning message
|
---|
727 | NbSlice=1;%default
|
---|
728 |
|
---|
729 | if exist(filexml,'file')
|
---|
730 | set(handles.view_xml,'Visible','on')
|
---|
731 | set(handles.view_xml,'BackgroundColor',[1 1 0])
|
---|
732 | set(handles.RootPath,'BackgroundColor',[1 1 1])
|
---|
733 | set(handles.view_xml,'String','view .xml')
|
---|
734 | drawnow
|
---|
735 | [XmlData,warntext]=imadoc2struct(filexml);
|
---|
736 | if ~isempty(warntext)
|
---|
737 | msgbox_uvmat('WARNING',warntext)
|
---|
738 | end
|
---|
739 | if isfield(XmlData,'TimeUnit')
|
---|
740 | if isfield(XmlData,'TimeUnit')&& ~isempty(XmlData.TimeUnit)
|
---|
741 | TimeUnit=XmlData.TimeUnit;
|
---|
742 | end
|
---|
743 | end
|
---|
744 | set(handles.view_xml,'BackgroundColor',[1 1 1])
|
---|
745 | drawnow
|
---|
746 | if isfield(XmlData, 'GeometryCalib') && ~isempty(XmlData.GeometryCalib)
|
---|
747 | hgeometry_calib=findobj('tag','geometry_calib');
|
---|
748 | if ~isempty(hgeometry_calib)
|
---|
749 | GUserData=get(hgeometry_calib,'UserData');
|
---|
750 | if ~(isfield(GUserData,'XmlInputFile') && strcmp(GUserData.XmlInputFile,filexml))
|
---|
751 | answer=msgbox_uvmat('INPUT_Y-N','replace the display of geometry_calib with the new input data?');
|
---|
752 | if strcmp(answer,'Yes')
|
---|
753 | geometry_calib(filexml);%diplay the new calibration points and parameters in geometry_calib
|
---|
754 | end
|
---|
755 | end
|
---|
756 | end
|
---|
757 | end
|
---|
758 | elseif exist(fileciv,'file')% if .civ file found
|
---|
759 | [error,XmlData.Time,TimeUnit,mode,npx,npy,pxcmx,pxcmy]=read_imatext([FileBase '.civ']);
|
---|
760 | GeometryCalib.R=[pxcmx 0 0; 0 pxcmy 0;0 0 0];
|
---|
761 | GeometryCalib.Tx=0;
|
---|
762 | GeometryCalib.Ty=0;
|
---|
763 | GeometryCalib.Tz=1;
|
---|
764 | GeometryCalib.dpx=1;
|
---|
765 | GeometryCalib.dpy=1;
|
---|
766 | GeometryCalib.sx=1;
|
---|
767 | GeometryCalib.Cx=0;
|
---|
768 | GeometryCalib.Cy=0;
|
---|
769 | GeometryCalib.f=1;
|
---|
770 | GeometryCalib.kappa1=0;
|
---|
771 | GeometryCalib.CoordUnit='cm';
|
---|
772 | XmlData.GeometryCalib=GeometryCalib;
|
---|
773 | if error==2, warntext=['no file ' FileBase '.civ'];
|
---|
774 | elseif error==1, warntext='inconsistent number of fields in the .civ file';
|
---|
775 | end
|
---|
776 | set(handles.npx,'String',num2str(npx));%fills nbre of pixels x box
|
---|
777 | set(handles.npy,'String',num2str(npy));%fills nbre of pixels y box
|
---|
778 | set(handles.pxcm,'String',num2str(pxcmx));%fills scale x (pixel/cm) box
|
---|
779 | set(handles.pycm,'String',num2str(pxcmy));%fills scale y (pixel/cm) box
|
---|
780 | set(handles.pxcm,'Visible','on');%fills scale x (pixel/cm) box
|
---|
781 | set(handles.pycm,'Visible','on');%fills scale y (pixel/cm) box
|
---|
782 | set(handles.view_xml,'Visible','on')
|
---|
783 | set(handles.view_xml,'String','view .civ')
|
---|
784 | else
|
---|
785 | set(handles.view_xml,'Visible','off')
|
---|
786 | end
|
---|
787 |
|
---|
788 | % store last index in handles.lat_i and .last_j
|
---|
789 | if ~isempty(XmlData.Time)
|
---|
790 | nbfield=size(XmlData.Time,1);
|
---|
791 | nburst=size(XmlData.Time,2);
|
---|
792 | %transform .Time to a column vector if it is a line vector the nomenclature uses a single index
|
---|
793 | if isequal(nbfield,1) && ~isequal(nburst,1)% .Time is a line vector
|
---|
794 | NomType=get(handles.FileIndex,'UserData');
|
---|
795 | if numel(NomType)>=2 &&(strcmp(NomType,'_i')||strcmp(NomType(1:2),'%0')||strcmp(NomType(1:2),'_%'))
|
---|
796 | XmlData.Time=(XmlData.Time)';
|
---|
797 | nbfield=nburst;
|
---|
798 | nburst=1;
|
---|
799 | end
|
---|
800 | end
|
---|
801 | end
|
---|
802 | last_i_cell=get(handles.last_i,'String');
|
---|
803 | if isempty(nbfield)
|
---|
804 | last_i_cell{1}='';
|
---|
805 | else
|
---|
806 | last_i_cell{1}=num2str(nbfield);
|
---|
807 | end
|
---|
808 | set(handles.last_i,'String',last_i_cell)
|
---|
809 | last_j_cell=get(handles.last_j,'String');
|
---|
810 | if isempty(nburst)
|
---|
811 | last_j_cell{1}='';
|
---|
812 | else
|
---|
813 | last_j_cell{1}=num2str(nburst);
|
---|
814 | end
|
---|
815 | set(handles.last_j,'String',last_j_cell);
|
---|
816 |
|
---|
817 | % store geometric calibration in UvData
|
---|
818 | if isfield(XmlData,'GeometryCalib')
|
---|
819 | GeometryCalib=XmlData.GeometryCalib;
|
---|
820 | if isempty(GeometryCalib)
|
---|
821 | set(handles.pxcm,'String','')
|
---|
822 | set(handles.pycm,'String','')
|
---|
823 | set(handles.transform_fct,'Value',1); % no transform by default
|
---|
824 | else
|
---|
825 | if (isfield(GeometryCalib,'R')&& ~isequal(GeometryCalib.R(2,1),0) && ~isequal(GeometryCalib.R(1,2),0)) ||...
|
---|
826 | (isfield(GeometryCalib,'kappa1')&& ~isequal(GeometryCalib.kappa1,0))
|
---|
827 | set(handles.pxcm,'String','var')
|
---|
828 | set(handles.pycm,'String','var')
|
---|
829 | elseif isfield(GeometryCalib,'fx_fy')
|
---|
830 | pixcmx=GeometryCalib.fx_fy(1);%*GeometryCalib.R(1,1)*GeometryCalib.sx/(GeometryCalib.Tz*GeometryCalib.dpx);
|
---|
831 | pixcmy=GeometryCalib.fx_fy(2);%*GeometryCalib.R(2,2)/(GeometryCalib.Tz*GeometryCalib.dpy);
|
---|
832 | set(handles.pxcm,'String',num2str(pixcmx))
|
---|
833 | set(handles.pycm,'String',num2str(pixcmy))
|
---|
834 | end
|
---|
835 | if ~get(handles.FixedLimits,'Value')
|
---|
836 | set(handles.transform_fct,'Value',2); % phys transform by default if fixedLimits is off
|
---|
837 | end
|
---|
838 | if isfield(GeometryCalib,'SliceCoord')
|
---|
839 |
|
---|
840 | siz=size(GeometryCalib.SliceCoord);
|
---|
841 | if siz(1)>1
|
---|
842 | NbSlice=siz(1);
|
---|
843 | set(handles.slices,'Visible','on')
|
---|
844 | set(handles.slices,'Value',1)
|
---|
845 | end
|
---|
846 | if isfield(GeometryCalib,'NbSlice') && isequal(GeometryCalib.NbSlice,'volume')
|
---|
847 | set(handles.nb_slice,'String','volume')
|
---|
848 | else
|
---|
849 | set(handles.nb_slice,'String',num2str(NbSlice))
|
---|
850 | end
|
---|
851 | slices_Callback(hObject, eventdata, handles)
|
---|
852 | end
|
---|
853 | end
|
---|
854 | end
|
---|
855 |
|
---|
856 | %update the data attached to the uvmat interface
|
---|
857 | if ~isempty(TimeUnit)
|
---|
858 | set(handles.time_txt,'String',['time (' TimeUnit ')'])
|
---|
859 | end
|
---|
860 | UvData.TimeUnit=TimeUnit;
|
---|
861 | UvData.XmlData=XmlData;
|
---|
862 | UvData.NewSeries=1;
|
---|
863 | set(handles.uvmat,'UserData',UvData)
|
---|
864 |
|
---|
865 | %display warning message
|
---|
866 | if ~isequal(warntext,'')
|
---|
867 | msgbox_uvmat('WARNING',warntext);
|
---|
868 | end
|
---|
869 |
|
---|
870 | % set default options in menu 'Fields'
|
---|
871 | if testima
|
---|
872 | set(handles.Fields,'Value',1) % set menu to 'image'
|
---|
873 | set(handles.Fields,'String',{'image';'get_field...';'velocity';'vort';'div';'more...'})
|
---|
874 | elseif isequal(FileExt,'.nc')||isequal(FileExt,'.cdf')
|
---|
875 | Data=nc2struct(FileName,'ListGlobalAttribute','absolut_time_T0','civ');
|
---|
876 | col_vec=get(handles.col_vec,'String');
|
---|
877 | if ~isempty(Data.absolut_time_T0)&& ~isequal(Data.civ,0)
|
---|
878 | set(handles.Fields,'String',{'image';'get_field...';'velocity';'vort';'div';'more...'})
|
---|
879 | set(handles.Fields,'Value',3) % set menu to 'velocity'
|
---|
880 | col_vec{1}='ima_cor';
|
---|
881 | else %general netcdf file (not civx)
|
---|
882 | set(handles.Fields,'Value',1) % set menu to 'get_field...
|
---|
883 | set(handles.Fields,'String',{'get_field...'})
|
---|
884 | col_vec{1}='get_field...';
|
---|
885 | end
|
---|
886 | set(handles.col_vec,'String',col_vec)
|
---|
887 | else
|
---|
888 | msgbox_uvmat('ERROR',['invalid input file extension ' FileExt])
|
---|
889 | return
|
---|
890 | end
|
---|
891 |
|
---|
892 | % set index navigation options and refresh plots
|
---|
893 | set(handles.RootPath,'BackgroundColor',[1 1 1])
|
---|
894 | drawnow
|
---|
895 | set_scan_options(hObject, eventdata, handles)
|
---|
896 |
|
---|
897 |
|
---|
898 | %-------------------------------------------------------------------
|
---|
899 | %-- set index navigation options for new series input and refresh plot
|
---|
900 | %-------------------------------------------------------------------
|
---|
901 | function set_scan_options(hObject, eventdata, handles)
|
---|
902 |
|
---|
903 | % set the corresponding index navigation options
|
---|
904 | NomType=get(handles.FileIndex,'UserData');
|
---|
905 | NomType_1=get(handles.FileIndex_1,'UserData');
|
---|
906 | last_i_str=get(handles.last_i,'String');
|
---|
907 | nbfield=str2num(last_i_str{1});
|
---|
908 | if numel(last_i_str)==2
|
---|
909 | nbfield=min(nbfield,str2num(last_i_str{2}));
|
---|
910 | end
|
---|
911 | state_j='off'; %default
|
---|
912 | scan_option='i';%default
|
---|
913 | NomTypeRaw=regexprep(NomType(2:end), '-', '');
|
---|
914 | if numel(regexp(NomTypeRaw,'\D'))>=1
|
---|
915 | % case {'_i_j','_i_j1-j2','_i1-i2_j','#_ab','#A','%01dA','%02dA','%03dA','%04dA'},% two navigation indices
|
---|
916 | state_j='on';
|
---|
917 | if isequal(nbfield,1)
|
---|
918 | scan_option='j'; %scan j index by default if nbfield=1
|
---|
919 | end
|
---|
920 | end
|
---|
921 | if ~isempty(NomType_1)
|
---|
922 | NomTypeRaw=regexprep(NomType_1(2:end), '-', '');
|
---|
923 | if numel(regexp(NomTypeRaw,'\D'))>=1
|
---|
924 | % switch NomType_1
|
---|
925 | % case {'_i_j','_i_j1-j2','_i1-i2_j','#_ab'},% two navigation indices
|
---|
926 | state_j='on';
|
---|
927 | if isequal(nbfield,1)
|
---|
928 | scan_option='j';
|
---|
929 | end
|
---|
930 | end
|
---|
931 | end
|
---|
932 | if isequal(scan_option,'i')
|
---|
933 | set(handles.scan_i,'Value',1)
|
---|
934 | scan_i_Callback(hObject, eventdata, handles);
|
---|
935 | else
|
---|
936 | set(handles.scan_j,'Value',1)
|
---|
937 | scan_j_Callback(hObject, eventdata, handles);
|
---|
938 | end
|
---|
939 | set(handles.scan_j,'Visible',state_j)
|
---|
940 | set(handles.j1,'Visible',state_j)
|
---|
941 | set(handles.j2,'Visible',state_j)
|
---|
942 | set(handles.last_j,'Visible',state_j);
|
---|
943 | set(handles.frame_j,'Visible',state_j);
|
---|
944 | set(handles.j_text,'Visible',state_j);
|
---|
945 |
|
---|
946 | % view the field
|
---|
947 | run0_Callback(hObject, eventdata, handles); %view field
|
---|
948 | mask_test=get(handles.mask_test,'value');
|
---|
949 | if mask_test
|
---|
950 | MaskData=get(handles.mask_test,'UserData');
|
---|
951 | if isfield(MaskData,'maskhandle') && ishandle(MaskData.maskhandle)
|
---|
952 | delete(MaskData.maskhandle) %delete old mask
|
---|
953 | end
|
---|
954 | mask_test_Callback(hObject, eventdata, handles)
|
---|
955 | end
|
---|
956 |
|
---|
957 | %-------------------------------------------------------------------
|
---|
958 | function MenuBrowse_1_Callback(hObject, eventdata, handles)
|
---|
959 | %-------------------------------------------------------------------
|
---|
960 | % huvmat=get(handles.run0,'parent');
|
---|
961 | UvData=get(handles.uvmat,'UserData');
|
---|
962 |
|
---|
963 | RootPath=get(handles.RootPath,'String');
|
---|
964 | [FileName, PathName, filterindex] = uigetfile( ...
|
---|
965 | {'*.xml;*.xls;*.civ;*.jpg;*.png;*.avi;*.AVI;*.nc;*.cmx;*.fig;*.log;*.dat', ' (*.xml,*.xls,*.civ, *.jpg,*.png, *.avi,*.nc,*.cmx ,*.fig,*.log,*.dat)';
|
---|
966 | '*.xml', '.xml files '; ...
|
---|
967 | '*.xls', '.xls files '; ...
|
---|
968 | '*.civ', '.civ files '; ...
|
---|
969 | '*.jpg','.jpg image files'; ...
|
---|
970 | '*.png','.png image files'; ...
|
---|
971 | '*.avi;*.AVI','.avi movie files'; ...
|
---|
972 | '*.nc','.netcdf files'; ...
|
---|
973 | '*.cdf','.netcdf files'; ...
|
---|
974 | '*.cmx','.cmx text files';...
|
---|
975 | '*.cmx2','.cmx2 text files';...
|
---|
976 | '*.fig','.fig files (matlab fig)';...
|
---|
977 | '*.log','.log text files ';...
|
---|
978 | '*.dat','.dat text files ';...
|
---|
979 | '*.*', 'All Files (*.*)'}, ...
|
---|
980 | 'Pick a file',RootPath);
|
---|
981 | fileinput_1=[PathName FileName];%complete file name
|
---|
982 | testblank=findstr(fileinput_1,' ');%look for blanks
|
---|
983 | if ~isempty(testblank)
|
---|
984 | msgbox_uvmat('ERROR',['The input file name ' fileinput_1 ' contains blank character : This is not allowed. Please change name'])
|
---|
985 | return
|
---|
986 | end
|
---|
987 | sizf=size(fileinput_1);
|
---|
988 | if (~ischar(fileinput_1)||~isequal(sizf(1),1)),return;end
|
---|
989 |
|
---|
990 | % refresh the current displayed field
|
---|
991 | display_file_name_1(hObject,eventdata,handles,fileinput_1)
|
---|
992 |
|
---|
993 | %update list of recent files in the menubar
|
---|
994 | MenuFile_1=fileinput_1;
|
---|
995 | MenuFile_2=get(handles.MenuFile_1,'Label');
|
---|
996 | MenuFile_3=get(handles.MenuFile_2,'Label');
|
---|
997 | MenuFile_4=get(handles.MenuFile_3,'Label');
|
---|
998 | MenuFile_5=get(handles.MenuFile_4,'Label');
|
---|
999 | set(handles.MenuFile_1,'Label',MenuFile_1)
|
---|
1000 | set(handles.MenuFile_2,'Label',MenuFile_2)
|
---|
1001 | set(handles.MenuFile_3,'Label',MenuFile_3)
|
---|
1002 | set(handles.MenuFile_4,'Label',MenuFile_4)
|
---|
1003 | set(handles.MenuFile_5,'Label',MenuFile_5)
|
---|
1004 | set(handles.MenuFile_1_1,'Label',MenuFile_1)
|
---|
1005 | set(handles.MenuFile_2_1,'Label',MenuFile_2)
|
---|
1006 | set(handles.MenuFile_3_1,'Label',MenuFile_3)
|
---|
1007 | set(handles.MenuFile_4_1,'Label',MenuFile_4)
|
---|
1008 | set(handles.MenuFile_5_1,'Label',MenuFile_5)
|
---|
1009 | dir_perso=prefdir;
|
---|
1010 | profil_perso=fullfile(dir_perso,'uvmat_perso.mat');
|
---|
1011 | if exist(profil_perso,'file')
|
---|
1012 | save (profil_perso,'MenuFile_1','MenuFile_2','MenuFile_3','MenuFile_4', 'MenuFile_5','-append'); %store the file names for future opening of uvmat
|
---|
1013 | else
|
---|
1014 | txt=ver;
|
---|
1015 | Release=txt(1).Release;
|
---|
1016 | relnumb=str2num(Release(3:4));
|
---|
1017 | if relnumb >= 14
|
---|
1018 | save (profil_perso,'MenuFile_1','MenuFile_2','MenuFile_3','MenuFile_4', 'MenuFile_5','-V6'); %store the file names for future opening of uvmat
|
---|
1019 | else
|
---|
1020 | save (profil_perso,'MenuFile_1','MenuFile_2','MenuFile_3','MenuFile_4', 'MenuFile_5'); %store the file names for future opening of uvmat
|
---|
1021 | end
|
---|
1022 | end
|
---|
1023 |
|
---|
1024 | % --------------------------------------------------------------------
|
---|
1025 | function MenuFile_1_1_Callback(hObject, eventdata, handles)
|
---|
1026 | fileinput_1=get(handles.MenuFile_1_1,'Label');
|
---|
1027 | display_file_name_1(hObject,eventdata,handles,fileinput_1)
|
---|
1028 |
|
---|
1029 | % --------------------------------------------------------------------
|
---|
1030 | function MenuFile_2_1_Callback(hObject, eventdata, handles)
|
---|
1031 | fileinput_1=get(handles.MenuFile_2_1,'Label');
|
---|
1032 | display_file_name_1(hObject,eventdata,handles,fileinput_1)
|
---|
1033 |
|
---|
1034 | % --------------------------------------------------------------------
|
---|
1035 | function MenuFile_3_1_Callback(hObject, eventdata, handles)
|
---|
1036 | fileinput_1=get(handles.MenuFile_3_1,'Label');
|
---|
1037 | display_file_name_1(hObject,eventdata,handles,fileinput_1)
|
---|
1038 |
|
---|
1039 | % --------------------------------------------------------------------
|
---|
1040 | function MenuFile_4_1_Callback(hObject, eventdata, handles)
|
---|
1041 | fileinput_1=get(handles.MenuFile_4_1,'Label');
|
---|
1042 | display_file_name_1(hObject,eventdata,handles,fileinput_1)
|
---|
1043 |
|
---|
1044 | % --------------------------------------------------------------------
|
---|
1045 | function MenuFile_5_1_Callback(hObject, eventdata, handles)
|
---|
1046 | fileinput_1=get(handles.MenuFile_5_1,'Label');
|
---|
1047 | display_file_name_1(hObject,eventdata,handles,fileinput_1)
|
---|
1048 |
|
---|
1049 | %-----------------------------------------------------------------
|
---|
1050 | % fills the edit boxes RootPath, RootFile,NomType...from an input file name 'fileinput'
|
---|
1051 | %----------------------------------------------------------------
|
---|
1052 | function display_file_name_1(hObject,eventdata,handles,fileinput_1)
|
---|
1053 |
|
---|
1054 | %[path,name,ext]=fileparts(fileinput_1);
|
---|
1055 | [RootPath_1,RootFile_1,field_count,str2,str_a,str_b,FileExt_1,NomType_1,SubDir_1]=name2display(fileinput_1);
|
---|
1056 | nbfield_1=1; %default
|
---|
1057 | ext_test=FileExt_1;%default
|
---|
1058 | form=imformats(FileExt_1(2:end));
|
---|
1059 | if ~isempty(form) % if the extension corresponds to an image format recognized by Matlab
|
---|
1060 | imainfo=imfinfo(fileinput_1);
|
---|
1061 | nbfield_1=length(imainfo);
|
---|
1062 | ext_test='.image';
|
---|
1063 | elseif isequal(lower(FileExt_1),'.avi')
|
---|
1064 | info=aviinfo(fileinput_1);
|
---|
1065 | nbfield_1=info.NumFrames;
|
---|
1066 | ext_test='.image';
|
---|
1067 | end
|
---|
1068 |
|
---|
1069 | %open directly fig or text files
|
---|
1070 | switch ext_test
|
---|
1071 | case {'.civ','.log','.cmx','.cmx2','.txt'} %display text file
|
---|
1072 | edit(fileinput)
|
---|
1073 | return
|
---|
1074 | case '.fig' %display matlab figure
|
---|
1075 | hfig=open(fileinput);
|
---|
1076 | set(hfig,'WindowButtonMotionFcn','mouse_motion')%set mouse action functio
|
---|
1077 | set(hfig,'WindowButtonUpFcn','mouse_up')%set mouse click action function
|
---|
1078 | set(hfig,'WindowButtonUpFcn','mouse_down')%set mouse click action function
|
---|
1079 | return
|
---|
1080 | case {'.xml','.xls'} % edit xml or Excel files
|
---|
1081 | heditxml=editxml(fileinput);
|
---|
1082 | return
|
---|
1083 | case {'.image','.nc','.cdf'}
|
---|
1084 | % set(handles.FileIndex,'UserData',NomType_1);
|
---|
1085 | otherwise
|
---|
1086 | msgbox_uvmat(['invalid input file extension ' FileExt_1 ' for uvmat'],'ERROR')
|
---|
1087 | return
|
---|
1088 | end
|
---|
1089 |
|
---|
1090 | % test for image series in a single file and synchronise file indices of the two series
|
---|
1091 | if nbfield_1 >1 %case of image with multiple frames
|
---|
1092 | if nbfield_1 < num_i1
|
---|
1093 | msgbox_uvmat('ERROR','current frame index beyond the input movie length')
|
---|
1094 | return
|
---|
1095 | else
|
---|
1096 | NomType_1='*'; %indicate a set of indexed frames within a single file
|
---|
1097 | filename_new=fileinput_1;
|
---|
1098 | end
|
---|
1099 | else % cases of data files
|
---|
1100 | RootPath=get(handles.RootPath,'String');
|
---|
1101 | RootFile=get(handles.RootFile,'String');
|
---|
1102 | FileBase=fullfile(RootPath,RootFile);
|
---|
1103 | FileBase_1=fullfile(RootPath_1,RootFile_1);
|
---|
1104 | if isequal(FileBase,FileBase_1)
|
---|
1105 | filename_new=fileinput_1;
|
---|
1106 | else
|
---|
1107 | num_i1=stra2num(get(handles.i1,'String'));%get the current file indices from counters
|
---|
1108 | num_j1=stra2num(get(handles.j1,'String'));
|
---|
1109 | num_i2=stra2num(get(handles.i2,'String'));
|
---|
1110 | num_j2=stra2num(get(handles.j2,'String'));
|
---|
1111 | [filename_new,idetect]=...
|
---|
1112 | name_generator(FileBase_1,num_i1,num_j1,FileExt_1,NomType_1,1,num_i2,num_j2,SubDir_1);%create name with indices synchronised with the first file
|
---|
1113 | indices=''; %default
|
---|
1114 | if ~idetect
|
---|
1115 | msgbox_uvmat('ERROR','second input file with indices corresponding to the first one does not exist')
|
---|
1116 | return
|
---|
1117 | end
|
---|
1118 | end
|
---|
1119 | end
|
---|
1120 | set(handles.FileIndex_1,'UserData',NomType_1);
|
---|
1121 |
|
---|
1122 | % make visible and fill the second raw of edit boxes
|
---|
1123 | set(handles.RootPath_1,'Visible','on')
|
---|
1124 | set(handles.RootFile_1,'Visible','on')
|
---|
1125 | set(handles.SubDir_1,'Visible','on');
|
---|
1126 | set(handles.FileIndex_1,'Visible','on');
|
---|
1127 | set(handles.FileExt_1,'Visible','on');
|
---|
1128 | [FileName,RootPath,FileBase,FileIndices,FileExt,SubDir]=read_file_boxes(handles);
|
---|
1129 | if isequal(FileBase,FileBase_1)
|
---|
1130 | set(handles.RootPath_1,'String','"')
|
---|
1131 | set(handles.RootFile_1,'String','"');
|
---|
1132 | else
|
---|
1133 | set(handles.RootPath_1,'String',RootPath_1)
|
---|
1134 | set(handles.RootFile_1,'String',['/' RootFile_1]);
|
---|
1135 | end
|
---|
1136 | if isequal(SubDir_1,'')
|
---|
1137 | set(handles.SubDir_1,'String','');
|
---|
1138 | FileBaseSub_1=FileBase_1;
|
---|
1139 | else
|
---|
1140 | set(handles.SubDir_1,'String',['/' SubDir_1]);
|
---|
1141 | FileBaseSub_1=fullfile(FileBase_1,SubDir_1);
|
---|
1142 | end
|
---|
1143 | indices=filename_new(length(FileBaseSub_1)+1:end);
|
---|
1144 | indices(end-length(FileExt_1)+1:end)=[]; %remove extension
|
---|
1145 | set(handles.FileIndex_1,'String',indices)
|
---|
1146 | set(handles.FileIndex_1,'UserData',NomType_1)
|
---|
1147 | set(handles.FileExt_1,'String',FileExt_1);
|
---|
1148 |
|
---|
1149 | % default choice of fields
|
---|
1150 | if isequal(ext_test,'.image')
|
---|
1151 | set(handles.Fields_1,'String',{'';'image';'get_field...';'velocity';'vort';'div';'more...'})
|
---|
1152 | set(handles.Fields_1,'Value',2) % set menu to 'image'
|
---|
1153 | elseif strcmp(FileExt_1,'.nc')||strcmp(FileExt_1,'.cdf')
|
---|
1154 | Data=nc2struct(fileinput_1,[]);
|
---|
1155 | if isfield(Data,'absolut_time_T0')
|
---|
1156 | set(handles.Fields_1,'String',{'';'image';'get_field...';'velocity';'vort';'div';'more...'})
|
---|
1157 | set(handles.Fields_1,'Value',4) % set menu to 'velocity'
|
---|
1158 | else
|
---|
1159 | set(handles.Fields_1,'Value',2) % set menu to 'get_field...'
|
---|
1160 | set(handles.Fields_1,'String',{'';'get_field...'});
|
---|
1161 | end
|
---|
1162 | end
|
---|
1163 | set(handles.SubField,'Visible','on')
|
---|
1164 | set(handles.SubField,'Value',1)
|
---|
1165 | RootPath_1_Callback(hObject,eventdata,handles);
|
---|
1166 |
|
---|
1167 |
|
---|
1168 | %-----------------------------------------------------
|
---|
1169 | function RootPath_1_Callback(hObject,eventdata,handles)
|
---|
1170 | update_rootinfo_1(hObject,eventdata,handles)
|
---|
1171 |
|
---|
1172 | %-------------------------------------------------------------------
|
---|
1173 | function RootFile_1_Callback(hObject, eventdata, handles)
|
---|
1174 | update_rootinfo_1(hObject,eventdata,handles)
|
---|
1175 | %-------------------------------------------------------------------
|
---|
1176 |
|
---|
1177 | %-------------------------------------------------------------------
|
---|
1178 | function update_rootinfo_1(hObject,eventdata,handles) %A REVOIR
|
---|
1179 |
|
---|
1180 | set(handles.RootPath_1,'BackgroundColor',[1 1 0])% indicate active program by yellow color
|
---|
1181 | drawnow
|
---|
1182 | %huvmat=get(handles.RootPath,'parent');
|
---|
1183 | UvData=get(handles.uvmat,'UserData');%huvmat=handles of the uvmat interface
|
---|
1184 | UvData.NewSeries=1; %flag for run0: begin a new series
|
---|
1185 |
|
---|
1186 | [FileName,RootPath,FileBase,FileIndices,FileExt,SubDir]=read_file_boxes_1(handles);
|
---|
1187 | if ~exist(FileName,'file')
|
---|
1188 | msgbox_uvmat('ERROR',['input file ' FileName ' not found']);
|
---|
1189 | end
|
---|
1190 | nbfield_1=[];%default
|
---|
1191 | nburst_1=[];%default
|
---|
1192 | XmlData.Time=[];
|
---|
1193 | XmlData.GeometryCalib=[];%default
|
---|
1194 | TimeUnit=[];
|
---|
1195 | if isfield(UvData,'TimeUnit')
|
---|
1196 | TimeUnit=UvData.TimeUnit;
|
---|
1197 | end
|
---|
1198 | TimeUnit_1=[];
|
---|
1199 | hhh='';%default, test for movie reading with mmreader
|
---|
1200 | imainfo=[];
|
---|
1201 | if isequal(lower(FileExt),'.avi') %.avi file
|
---|
1202 | imainfo=aviinfo([FileBase FileIndices FileExt]);
|
---|
1203 | nbfield_1=imainfo.NumFrames;
|
---|
1204 | nburst_1=1;
|
---|
1205 | set(handles.Dt_txt,'String',['Dt=' num2str(1000/info.FramesPerSecond) 'ms']);%display the elementary time interval in millisec
|
---|
1206 | time=[0:1/imainfo.FramesPerSecond:(imainfo.NumFrames-1)/imainfo.FramesPerSecond]';
|
---|
1207 | ColorType=imainfo.ImageType;%='truecolor' for color images
|
---|
1208 | hhh=which('mmreader');
|
---|
1209 | elseif ~isempty(imformats(FileExt(2:end)))|| isequal(FileExt,'.vol')
|
---|
1210 | testima=1;
|
---|
1211 | if ~isequal(SubDir,'')
|
---|
1212 | RootFile=get(handles.RootFile,'String');
|
---|
1213 | imainfo=imfinfo([fullfile(RootPath,SubDir,RootFile) FileIndices FileExt]);
|
---|
1214 | else
|
---|
1215 | imainfo=imfinfo([FileBase FileIndices FileExt]);
|
---|
1216 | end
|
---|
1217 | ColorType=imainfo.ColorType;%='truecolor' for color images
|
---|
1218 | if length(imainfo) >1 %case of image with multiple frames
|
---|
1219 | nbfield_1=length(imainfo);
|
---|
1220 | nburst_1=1;
|
---|
1221 | end
|
---|
1222 | end
|
---|
1223 | if ~strcmp(hhh,'')&& mmreader.isPlatformSupported()% if the function is found (recent version of matlab)
|
---|
1224 | UvData.MovieObject_1=mmreader([FileBase FileIndices FileExt]);
|
---|
1225 | elseif isfield(UvData,'MovieObject_1')
|
---|
1226 | UvData=rmfield(UvData,'MovieObject_1');
|
---|
1227 | end
|
---|
1228 | if strcmp(get(handles.npx,'String'),'') || strcmp(get(handles.npy,'String'),'')%update npx and npy if it is not already filled by the first input field
|
---|
1229 | if isfield(imainfo,'Width') && isfield(imainfo,'Height')
|
---|
1230 | set(handles.npx,'String',num2str(imainfo.Width));%fills nbre of pixels x box
|
---|
1231 | set(handles.npy,'String',num2str(imainfo.Height));%fills nbre of pixels x box
|
---|
1232 | else
|
---|
1233 | set(handles.npx,'String','');%fills nbre of pixels x box
|
---|
1234 | set(handles.npy,'String','');%fills nbre of pixels x box
|
---|
1235 | end
|
---|
1236 | set(handles.BW,'Value',strcmp(ColorType,'grayscale'))% select handles.BW if grayscale image
|
---|
1237 | end
|
---|
1238 |
|
---|
1239 | % find scaling parameters
|
---|
1240 | filexml=[FileBase '.xml'];
|
---|
1241 | fileciv=[FileBase '.civ'];
|
---|
1242 | warntext='';%default warning text
|
---|
1243 | if exist(filexml,'file')
|
---|
1244 | [XmlData,warntext]=imadoc2struct(filexml);
|
---|
1245 | if ~isempty(warntext)
|
---|
1246 | msgbox_uvmat('WARNING',warntext)
|
---|
1247 | end
|
---|
1248 | if isfield(XmlData,'Camera')
|
---|
1249 | % if isfield(XmlData.Camera,'NbSlice')&& ~isempty(XmlData.Camera.NbSlice)
|
---|
1250 | % NbSlice=XmlData.Camera.NbSlice;
|
---|
1251 | % end
|
---|
1252 | if isfield(XmlData.Camera,'TimeUnit')&& ~isempty(XmlData.Camera.TimeUnit)
|
---|
1253 | TimeUnit=XmlData.Camera.TimeUnit;
|
---|
1254 | end
|
---|
1255 | end
|
---|
1256 | elseif exist(fileciv,'file')% if .civ file found
|
---|
1257 | [error,XmlData.Time,TimeUnit,mode,npx,npy,pxcmx,pxcmy]=read_imatext([FileBase '.civ']);
|
---|
1258 | GeometryCalib.R=[pxcmx 0 0; 0 pxcmy 0;0 0 0];
|
---|
1259 | GeometryCalib.Tx=0;
|
---|
1260 | GeometryCalib.Ty=0;
|
---|
1261 | GeometryCalib.Tz=1;
|
---|
1262 | GeometryCalib.dpx=1;
|
---|
1263 | GeometryCalib.dpy=1;
|
---|
1264 | GeometryCalib.sx=1;
|
---|
1265 | GeometryCalib.Cx=0;
|
---|
1266 | GeometryCalib.Cy=0;
|
---|
1267 | GeometryCalib.f=1;
|
---|
1268 | GeometryCalib.kappa1=0;
|
---|
1269 | GeometryCalib.CoordUnit='cm';
|
---|
1270 | XmlData.GeometryCalib=GeometryCalib;
|
---|
1271 | if error==2, warntext=['no file ' FileBase '.civ'];
|
---|
1272 | elseif error==1, warntext='inconsistent number of fields in the .civ file';
|
---|
1273 | end
|
---|
1274 |
|
---|
1275 | set(handles.npx,'String',num2str(npx));%fills nbre of pixels x box
|
---|
1276 | set(handles.npy,'String',num2str(npy));%fills nbre of pixels y box
|
---|
1277 | set(handles.pxcm,'String',num2str(pxcmx));%fills scale x (pixel/cm) box
|
---|
1278 | set(handles.pycm,'String',num2str(pxcmy));%fills scale y (pixel/cm) box
|
---|
1279 | set(handles.pxcm,'Visible','on');%fills scale x (pixel/cm) box
|
---|
1280 | set(handles.pycm,'Visible','on');%fills scale y (pixel/cm) box
|
---|
1281 | end
|
---|
1282 | if ~isempty(TimeUnit_1) && ~isequal(TimeUnit_1,TimeUnit)
|
---|
1283 | msgbox_uvmat('WARNING','the time units for the second series differs from the first one')
|
---|
1284 | end
|
---|
1285 |
|
---|
1286 | % store last index in handles.lat_i and .last_j
|
---|
1287 | if ~isempty(XmlData.Time)
|
---|
1288 | nbfield_1=size(XmlData.Time,1);
|
---|
1289 | nburst_1=size(XmlData.Time,2);
|
---|
1290 | end
|
---|
1291 | last_i_cell=get(handles.last_i,'String');
|
---|
1292 | if isempty(nbfield_1)
|
---|
1293 | last_i_cell{2}='';
|
---|
1294 | else
|
---|
1295 | last_i_cell{2}=num2str(nbfield_1);
|
---|
1296 | end
|
---|
1297 | set(handles.last_i,'String',last_i_cell)
|
---|
1298 | last_j_cell=get(handles.last_j,'String');
|
---|
1299 | if isempty(nburst_1)
|
---|
1300 | last_j_cell{2}='';
|
---|
1301 | else
|
---|
1302 | last_j_cell{2}=num2str(nburst_1);
|
---|
1303 | end
|
---|
1304 | set(handles.last_j,'String',last_j_cell);
|
---|
1305 | if ~isequal(last_i_cell{1},last_i_cell{2}) || ~isequal(last_j_cell{1},last_j_cell{2})
|
---|
1306 | msgbox_uvmat('WARNING','the numbers of input file of the second series differs from the first one')
|
---|
1307 | end
|
---|
1308 |
|
---|
1309 | % store calibration data
|
---|
1310 | GeometryCalib=XmlData.GeometryCalib;
|
---|
1311 | if isempty(GeometryCalib)
|
---|
1312 | if isfield(UvData, 'GeometryCalib_1')
|
---|
1313 | UvData=rmfield(UvData,'GeometryCalib_1');
|
---|
1314 | end
|
---|
1315 | else
|
---|
1316 | UvData.GeometryCalib_1=GeometryCalib;
|
---|
1317 | if (isfield(GeometryCalib,'R')& ~isequal(GeometryCalib.R(2,1),0) & ~isequal(GeometryCalib.R(1,2),0)) |...
|
---|
1318 | (isfield(GeometryCalib,'kappa1')& ~isequal(GeometryCalib.kappa1,0))
|
---|
1319 | set(handles.pxcm,'String','var')
|
---|
1320 | set(handles.pycm,'String','var')
|
---|
1321 | else
|
---|
1322 | pixcmx=GeometryCalib.f*GeometryCalib.R(1,1)*GeometryCalib.sx/(GeometryCalib.Tz*GeometryCalib.dpx);
|
---|
1323 | pixcmy=GeometryCalib.f*GeometryCalib.R(2,2)/(GeometryCalib.Tz*GeometryCalib.dpy);
|
---|
1324 | set(handles.pxcm,'String',num2str(pixcmx))
|
---|
1325 | set(handles.pycm,'String',num2str(pixcmy))
|
---|
1326 | end
|
---|
1327 | end
|
---|
1328 | UvData.XmlData_1=XmlData;
|
---|
1329 | set(handles.uvmat,'UserData',UvData)%update the data attached to the uvmat interface
|
---|
1330 |
|
---|
1331 | if ~isequal(warntext,'')
|
---|
1332 | msgbox_uvmat('WARNING',warntext)
|
---|
1333 | end
|
---|
1334 |
|
---|
1335 | set(handles.RootPath_1,'BackgroundColor',[1 1 1])% signa the end the input operation
|
---|
1336 | drawnow
|
---|
1337 |
|
---|
1338 | set_scan_options(hObject, eventdata, handles)
|
---|
1339 |
|
---|
1340 | %---------------------------------------------------
|
---|
1341 | % switch file index scanning options scan_i and scan_j in an exclusive way
|
---|
1342 | function scan_i_Callback(hObject, eventdata, handles)
|
---|
1343 | %---------------------------------------------------
|
---|
1344 | if get(handles.scan_i,'Value')==1
|
---|
1345 | set(handles.scan_i,'BackgroundColor',[1 1 0])
|
---|
1346 | set(handles.scan_j,'Value',0)
|
---|
1347 | % set(handles.scan_j,'BackgroundColor',[0.831 0.816 0.784])
|
---|
1348 | else
|
---|
1349 | set(handles.scan_i,'BackgroundColor',[0.831 0.816 0.784])
|
---|
1350 | set(handles.scan_j,'Value',1)
|
---|
1351 | % set(handles.scan_j,'BackgroundColor',[1 1 0])
|
---|
1352 | end
|
---|
1353 | scan_j_Callback(hObject, eventdata, handles)
|
---|
1354 |
|
---|
1355 | %-------------------------------------------------------------------
|
---|
1356 | % switch file index scanning options scan_i and scan_j in an exclusive way
|
---|
1357 | function scan_j_Callback(hObject, eventdata, handles)
|
---|
1358 | %-------------------------------------------------------------------
|
---|
1359 | if get(handles.scan_j,'Value')==1
|
---|
1360 | set(handles.scan_j,'BackgroundColor',[1 1 0])
|
---|
1361 | set(handles.scan_i,'Value',0)
|
---|
1362 | set(handles.scan_i,'BackgroundColor',[0.831 0.816 0.784])
|
---|
1363 | NomType=get(handles.FileIndex,'UserData');
|
---|
1364 | switch NomType
|
---|
1365 | case {'_i_j1-j2','#_ab','%3dab'},% pair with j index
|
---|
1366 | set(handles.fix_pair,'Visible','on')% option fixed pair on/off made visible (choice of avaible pair with buttons + and - if ='off')
|
---|
1367 | otherwise
|
---|
1368 | set(handles.fix_pair,'Visible','off')
|
---|
1369 | end
|
---|
1370 | else
|
---|
1371 | set(handles.scan_j,'BackgroundColor',[0.831 0.816 0.784])
|
---|
1372 | set(handles.scan_i,'Value',1)
|
---|
1373 | set(handles.scan_i,'BackgroundColor',[1 1 0])
|
---|
1374 | set(handles.fix_pair,'Visible','off')
|
---|
1375 | end
|
---|
1376 |
|
---|
1377 | %-------------------------------------------------------------------
|
---|
1378 | function i1_Callback(hObject, eventdata, handles)
|
---|
1379 | %-------------------------------------------------------------------
|
---|
1380 | % [filebase,num1,num_a,num2,num_b,ext,NomType,subdir]=read_input_file(handles);
|
---|
1381 | %[FileName,RootPath,filebase,xx,FileExt]=read_file_boxes(handles);
|
---|
1382 | NomType=get(handles.FileIndex,'UserData');
|
---|
1383 | num1=stra2num(get(handles.i1,'String'));
|
---|
1384 | num2=stra2num(get(handles.i2,'String'));
|
---|
1385 | num_a=stra2num(get(handles.j1,'String'));
|
---|
1386 | num_b=stra2num(get(handles.j2,'String'));
|
---|
1387 | indices=name_generator('',num1,num_a,'',NomType,1,num2,num_b,'');
|
---|
1388 | set(handles.FileIndex,'String',indices)
|
---|
1389 | if get(handles.SubField,'Value')==1
|
---|
1390 | NomType_1=get(handles.FileIndex_1,'String');
|
---|
1391 | FileExt_1=get(handles.FileExt_1,'String');
|
---|
1392 | [P,F,str1,str2,str_a,str_b,Ext,NomType_1]=name2display(['xx' NomType_1 FileExt_1]);
|
---|
1393 | indices=name_generator('',num1,num_a,'',NomType_1,1,num2,num_b,'');
|
---|
1394 | set(handles.FileIndex_1,'String',indices)
|
---|
1395 | end
|
---|
1396 | run0_Callback(hObject, eventdata, handles)
|
---|
1397 |
|
---|
1398 | %-------------------------------------------------------------------
|
---|
1399 | function i2_Callback(hObject, eventdata, handles)
|
---|
1400 | i1_Callback(hObject, eventdata, handles)
|
---|
1401 | %-------------------------------------------------------------------
|
---|
1402 |
|
---|
1403 | %-------------------------------------------------------------------
|
---|
1404 | function j1_Callback(hObject, eventdata, handles)
|
---|
1405 | i1_Callback(hObject, eventdata, handles)
|
---|
1406 | %-------------------------------------------------------------------
|
---|
1407 |
|
---|
1408 | %-------------------------------------------------------------------
|
---|
1409 | function j2_Callback(hObject, eventdata, handles)
|
---|
1410 | i1_Callback(hObject, eventdata, handles)
|
---|
1411 | %-------------------------------------------------------------------
|
---|
1412 |
|
---|
1413 | %-------------------------------------------------------------------
|
---|
1414 | function slices_Callback(hObject, eventdata, handles)
|
---|
1415 | %-------------------------------------------------------------------
|
---|
1416 | if get(handles.slices,'Value')==1
|
---|
1417 | set(handles.slices,'BackgroundColor',[1 1 0])
|
---|
1418 | set(handles.nb_slice,'Visible','on')
|
---|
1419 | set(handles.z_text,'Visible','on')
|
---|
1420 | set(handles.z_index,'Visible','on')
|
---|
1421 | nb_slice_Callback(hObject, eventdata, handles)
|
---|
1422 | else
|
---|
1423 | set(handles.nb_slice,'Visible','off')
|
---|
1424 | set(handles.slices,'BackgroundColor',[0.7 0.7 0.7])
|
---|
1425 | set(handles.z_text,'Visible','off')
|
---|
1426 | set(handles.z_index,'Visible','off')
|
---|
1427 | set(handles.masklevel,'Value',1)
|
---|
1428 | set(handles.masklevel,'String',{'1'})
|
---|
1429 | end
|
---|
1430 |
|
---|
1431 | %-------------------------------------------------------------------
|
---|
1432 | function nb_slice_Callback(hObject, eventdata, handles)
|
---|
1433 | %-------------------------------------------------------------------
|
---|
1434 | nb_slice_str=get(handles.nb_slice,'String');
|
---|
1435 | if isequal(nb_slice_str,'volume')
|
---|
1436 | num=stra2num(get(handles.j1,'String'));
|
---|
1437 | last_j=get(handles.last_j,'String');
|
---|
1438 | nbslice=str2double(last_j{1});
|
---|
1439 | else
|
---|
1440 | num=str2double(get(handles.i1,'String'));
|
---|
1441 | nbslice=str2double(get(handles.nb_slice,'String'));
|
---|
1442 | end
|
---|
1443 | z=mod(num-1,nbslice)+1;
|
---|
1444 | set(handles.z_index,'String',num2str(z))
|
---|
1445 | for ilist=1:nbslice
|
---|
1446 | list_index{ilist,1}=num2str(ilist);
|
---|
1447 | end
|
---|
1448 | set(handles.masklevel,'String',list_index)
|
---|
1449 | set(handles.masklevel,'Value',z)
|
---|
1450 |
|
---|
1451 |
|
---|
1452 | %-------------------------------------------------------------------
|
---|
1453 | % --- Executes on button press in view_xml.
|
---|
1454 | function view_xml_Callback(hObject, eventdata, handles)
|
---|
1455 | [FileName,RootPath,FileBase,FileIndices,FileExt]=read_file_boxes(handles);
|
---|
1456 | option=get(handles.view_xml,'String');
|
---|
1457 | if isequal(option,'view .xml')
|
---|
1458 | FileXml=[FileBase '.xml'];
|
---|
1459 | heditxml=editxml(FileXml);
|
---|
1460 | end
|
---|
1461 |
|
---|
1462 | %-------------------------------------------------------------------
|
---|
1463 | % --- Executes on button press in mask_test.
|
---|
1464 | function mask_test_Callback(hObject, eventdata, handles)
|
---|
1465 | %-------------------------------------------------------------------
|
---|
1466 | if isequal(get(handles.mask_test,'Value'),1)
|
---|
1467 | [FF,RootPath,FileBase]=read_file_boxes(handles);
|
---|
1468 | num_i1=stra2num(get(handles.i1,'String'));
|
---|
1469 | num_j1=stra2num(get(handles.j1,'String'));
|
---|
1470 | currentdir=pwd;
|
---|
1471 | cd(RootPath);
|
---|
1472 | maskfiles=dir('*_*mask_*.png');%look for a mask file
|
---|
1473 | cd(currentdir);%come back to the working directory
|
---|
1474 | mdetect=0;
|
---|
1475 | if isempty(maskfiles)
|
---|
1476 | msgbox_uvmat('ERROR','no mask file detected (format ..._xxmask_ii.png needed), use the menu bar Tools/Make mask')
|
---|
1477 | return
|
---|
1478 | end
|
---|
1479 | for ilist=1:length(maskfiles)
|
---|
1480 | maskname=maskfiles(ilist).name;% take the first mask file in the list
|
---|
1481 | [rr,ff,x1,x2,xa,xb,xext,Mask_NomType{ilist}]=name2display(maskname);
|
---|
1482 | if ~strcmp(Mask_NomType{ilist},Mask_NomType{1})
|
---|
1483 | msgbox_uvmat('ERROR',['inconsistent mask types ' Mask_NomType{1} Mask_NomType{ilist } ' coexist in the current image directory'])
|
---|
1484 | return
|
---|
1485 | end
|
---|
1486 | [Path2,Name,ext]=fileparts(maskname);
|
---|
1487 | Namedouble=double(Name);
|
---|
1488 | val=(48>Namedouble)|(Namedouble>57);% select the non-numerical characters
|
---|
1489 | ind_mask=findstr('mask',Name);
|
---|
1490 | i=ind_mask-1;
|
---|
1491 | while val(i)==0 && i>0
|
---|
1492 | i=i-1;
|
---|
1493 | end
|
---|
1494 | nbmask_str=str2num(Name(i+1:ind_mask-1));
|
---|
1495 | if ~isempty(nbmask_str)
|
---|
1496 | nbslice(ilist)=nbmask_str; % number of different masks (slices)
|
---|
1497 | end
|
---|
1498 | end
|
---|
1499 | if isequal(min(nbslice),max(nbslice))
|
---|
1500 | nbslice=nbslice(1);
|
---|
1501 | else
|
---|
1502 | msgbox_uvmat('ERROR','several inconsistent mask sets coexist in the current image directory')
|
---|
1503 | return
|
---|
1504 | end
|
---|
1505 | if ~isempty(nbslice) && Name(i)=='_'
|
---|
1506 | Mask.Base=[FileBase Name(i:ind_mask+3)];
|
---|
1507 | Mask.NbSlice=nbslice;
|
---|
1508 | num_i1=mod(num_i1-1,nbslice)+1;
|
---|
1509 | Mask.NomType=Mask_NomType{1};
|
---|
1510 | [maskname,mdetect]=name_generator(Mask.Base,num_i1,num_j1,'.png',Mask.NomType);%
|
---|
1511 | mdetect=exist(maskname,'file');
|
---|
1512 | if mdetect
|
---|
1513 | set(handles.nb_slice,'String',Name(i+1:ind_mask-1));
|
---|
1514 | set(handles.nb_slice,'BackgroundColor',[1 1 0])
|
---|
1515 | set(handles.mask_test,'UserData',Mask);
|
---|
1516 | set(handles.mask_test,'BackgroundColor',[1 1 0])
|
---|
1517 | if nbslice > 1
|
---|
1518 | set(handles.slices,'value',1)
|
---|
1519 | slices_Callback(hObject, eventdata, handles)
|
---|
1520 | end
|
---|
1521 | end
|
---|
1522 | end
|
---|
1523 | if mdetect==0
|
---|
1524 | msgbox_uvmat('ERROR','no mask file detected (format ..._xxmask_ii.png needed), use the menu bar Tools/Make mask')
|
---|
1525 | set(handles.mask_test,'Value',0)
|
---|
1526 | return
|
---|
1527 | end
|
---|
1528 | update_mask(handles,num_i1,num_j1);
|
---|
1529 | else
|
---|
1530 | MaskData=get(handles.mask_test,'UserData');
|
---|
1531 | if isfield(MaskData,'maskhandle') && ishandle(MaskData.maskhandle)
|
---|
1532 | delete(MaskData.maskhandle)
|
---|
1533 | end
|
---|
1534 | set(handles.mask_test,'UserData',[])
|
---|
1535 | %huvmat=get(handles.mask_test,'parent');
|
---|
1536 | UvData=get(handles.uvmat,'UserData');
|
---|
1537 | if isfield(UvData,'MaskName')
|
---|
1538 | UvData=rmfield(UvData,'MaskName');
|
---|
1539 | set(handles.uvmat,'UserData',UvData)
|
---|
1540 | end
|
---|
1541 | set(handles.mask_test,'BackgroundColor',[0.7 0.7 0.7])
|
---|
1542 | end
|
---|
1543 |
|
---|
1544 | %-------------------------------------------------------------------
|
---|
1545 | function update_mask(handles,num_i1,num_j1)
|
---|
1546 | %-------------------------------------------------------------------
|
---|
1547 |
|
---|
1548 | MaskData=get(handles.mask_test,'UserData');
|
---|
1549 | if isfield(MaskData,'maskhandle')&& ishandle(MaskData.maskhandle)
|
---|
1550 | uistack(MaskData.maskhandle,'top');
|
---|
1551 | end
|
---|
1552 | num_i1_mask=mod(num_i1-1,MaskData.NbSlice)+1;
|
---|
1553 | [MaskName,mdetect]=name_generator(MaskData.Base,num_i1_mask,num_j1,'.png',MaskData.NomType);
|
---|
1554 | huvmat=get(handles.mask_test,'parent');
|
---|
1555 | UvData=get(huvmat,'UserData');
|
---|
1556 |
|
---|
1557 | %update mask image if the mask is new
|
---|
1558 | if ~ (isfield(UvData,'MaskName') && isequal(UvData.MaskName,MaskName))
|
---|
1559 | UvData.MaskName=MaskName; %update the recorded name on UvData
|
---|
1560 | set(huvmat,'UserData',UvData);
|
---|
1561 | if mdetect==0
|
---|
1562 | if isfield(MaskData,'maskhandle')&& ishandle(MaskData.maskhandle)
|
---|
1563 | delete(MaskData.maskhandle)
|
---|
1564 | end
|
---|
1565 | else
|
---|
1566 | %read mask image
|
---|
1567 | Mask.AName='image';
|
---|
1568 | Mask.A=imread(MaskName);
|
---|
1569 | npxy=size(Mask.A);
|
---|
1570 | Mask.AX=[0.5 npxy(2)-0.5];
|
---|
1571 | Mask.AY=[npxy(1)-0.5 0.5 ];
|
---|
1572 | Mask.CoordType='px';
|
---|
1573 | if isequal(get(handles.slices,'Value'),1)
|
---|
1574 | NbSlice=str2num(get(handles.nb_slice,'String'));
|
---|
1575 | num_i1=str2num(get(handles.i1,'String'));
|
---|
1576 | Mask.ZIndex=mod(num_i1-1,NbSlice)+1;
|
---|
1577 | end
|
---|
1578 | %px to phys or other transform on field
|
---|
1579 | menu_transform=get(handles.transform_fct,'String');
|
---|
1580 | choice_value=get(handles.transform_fct,'Value');
|
---|
1581 | transform_name=menu_transform{choice_value};%name of the transform fct given by the menu 'transform_fct'
|
---|
1582 | transform_list=get(handles.transform_fct,'UserData');
|
---|
1583 | transform=transform_list{choice_value};
|
---|
1584 | if ~isequal(transform_name,'') && ~isequal(transform_name,'px')
|
---|
1585 | if isfield(UvData,'XmlData') && isfield(UvData.XmlData,'GeometryCalib')%use geometry calib recorded from the ImaDoc xml file as first priority
|
---|
1586 | Calib=UvData.XmlData.GeometryCalib;
|
---|
1587 | Mask=transform(Mask,UvData.XmlData);
|
---|
1588 | end
|
---|
1589 | end
|
---|
1590 | flagmask=Mask.A < 200;
|
---|
1591 |
|
---|
1592 | %make brown color image
|
---|
1593 | imflag(:,:,1)=0.9*flagmask;
|
---|
1594 | imflag(:,:,2)=0.7*flagmask;
|
---|
1595 | imflag(:,:,3)=zeros(size(flagmask));
|
---|
1596 |
|
---|
1597 | %update mask image
|
---|
1598 | hmask=[]; %default
|
---|
1599 | if isfield(MaskData,'maskhandle')&& ishandle(MaskData.maskhandle)
|
---|
1600 | hmask=MaskData.maskhandle;
|
---|
1601 | end
|
---|
1602 | if ~isempty(hmask)
|
---|
1603 | set(hmask,'CData',imflag)
|
---|
1604 | set(hmask,'AlphaData',flagmask*0.6)
|
---|
1605 | set(hmask,'XData',Mask.AX);
|
---|
1606 | set(hmask,'YData',Mask.AY);
|
---|
1607 | % uistack(hmask,'top')
|
---|
1608 | else
|
---|
1609 | axes(handles.axes3)
|
---|
1610 | hold on
|
---|
1611 | MaskData.maskhandle=image(Mask.AX,Mask.AY,imflag,'Tag','mask','HitTest','off','AlphaData',0.6*flagmask);
|
---|
1612 | % set(MaskData.maskhandle,'AlphaData',0.6*flagmask)
|
---|
1613 | set(handles.mask_test,'UserData',MaskData)
|
---|
1614 | end
|
---|
1615 | end
|
---|
1616 | end
|
---|
1617 |
|
---|
1618 |
|
---|
1619 | %-------------------------------------------------------------------
|
---|
1620 | function MenuExportFigure_Callback(hObject, eventdata, handles)
|
---|
1621 | %-------------------------------------------------------------------
|
---|
1622 | huvmat=get(handles.MenuExport,'parent');
|
---|
1623 | %UvData=get(huvmat,'UserData');
|
---|
1624 | hfig=figure;
|
---|
1625 | copyobj(handles.axes3,hfig);
|
---|
1626 | map=colormap(handles.axes3);
|
---|
1627 | colormap(map);%transmit the current colormap to the zoom fig
|
---|
1628 | colorbar
|
---|
1629 |
|
---|
1630 | %-------------------------------------------------------------------
|
---|
1631 | %-------------------------------------------------------------------
|
---|
1632 | % III - MAIN REFRESH FUNCTIONS : 'FRAME PLOT'
|
---|
1633 | %-------------------------------------------------------------------
|
---|
1634 |
|
---|
1635 | %-------------------------------------------------------------------
|
---|
1636 | % --- Executes on button press in runplus: make one step forward and call
|
---|
1637 | % --- run0. The step forward is along the fields series 1 or 2 depending on
|
---|
1638 | % --- the scan_i and scan_j check box (exclusive each other)
|
---|
1639 | function runplus_Callback(hObject, eventdata, handles)
|
---|
1640 | %-------------------------------------------------------------------
|
---|
1641 | set(handles.runplus,'BackgroundColor',[1 1 0])%paint the command button in yellow
|
---|
1642 | drawnow
|
---|
1643 | %TODO: introduce the option: increment ='*' to move to the next available view
|
---|
1644 | increment=str2double(get(handles.increment_scan,'String')); %get the field increment d
|
---|
1645 | if isnan(increment)
|
---|
1646 | set(handles.increment_scan,'String','1')%default value
|
---|
1647 | increment=1;
|
---|
1648 | end
|
---|
1649 | errormsg=runpm(hObject,eventdata,handles,increment);
|
---|
1650 | if ~isempty(errormsg)
|
---|
1651 | msgbox_uvmat('ERROR',errormsg);
|
---|
1652 | end
|
---|
1653 | set(handles.runplus,'BackgroundColor',[1 0 0])%paint the command button back to red
|
---|
1654 |
|
---|
1655 | %-------------------------------------------------------------------
|
---|
1656 | % --- Executes on button press in runmin: make one step backward and call
|
---|
1657 | % --- run0. The step backward is along the fields series 1 or 2 depending on
|
---|
1658 | % --- the scan_i and scan_j check box (exclusive each other)
|
---|
1659 | function runmin_Callback(hObject, eventdata, handles)
|
---|
1660 | %-------------------------------------------------------------------
|
---|
1661 | set(handles.runmin,'BackgroundColor',[1 1 0])%paint the command button in yellow
|
---|
1662 | drawnow
|
---|
1663 | increment=-str2double(get(handles.increment_scan,'String')); %get the field increment d
|
---|
1664 | if isnan(increment)
|
---|
1665 | set(handles.increment_scan,'String','1')%default value
|
---|
1666 | increment=1;
|
---|
1667 | end
|
---|
1668 | errormsg=runpm(hObject,eventdata,handles,increment);
|
---|
1669 | if ~isempty(errormsg)
|
---|
1670 | msgbox_uvmat('ERROR',errormsg);
|
---|
1671 | end
|
---|
1672 | set(handles.runmin,'BackgroundColor',[1 0 0])%paint the command button back to red
|
---|
1673 |
|
---|
1674 | %-------------------------------------------------------------------
|
---|
1675 | % -- Executes on button press in Movie: make a series of +> steps
|
---|
1676 | function Movie_Callback(hObject, eventdata, handles)
|
---|
1677 | %------------------------------------------------------------------
|
---|
1678 | set(handles.Movie,'BackgroundColor',[1 1 0])%paint the command button in yellow
|
---|
1679 | drawnow
|
---|
1680 | increment=str2double(get(handles.increment_scan,'String')); %get the field increment d
|
---|
1681 | if isnan(increment)
|
---|
1682 | set(handles.increment_scan,'String','1')%default value
|
---|
1683 | increment=1;
|
---|
1684 | end
|
---|
1685 | set(handles.STOP,'Visible','on')
|
---|
1686 | set(handles.speed,'Visible','on')
|
---|
1687 | set(handles.speed_txt,'Visible','on')
|
---|
1688 | set(handles.Movie,'BusyAction','queue')
|
---|
1689 | UvData=get(handles.uvmat,'UserData');
|
---|
1690 |
|
---|
1691 | while get(handles.speed,'Value')~=0 && isequal(get(handles.Movie,'BusyAction'),'queue') % enable STOP command
|
---|
1692 | errormsg=runpm(hObject,eventdata,handles,increment);
|
---|
1693 | if ~isempty(errormsg)
|
---|
1694 | set(handles.Movie,'BackgroundColor',[1 0 0])%paint the command buttonback to red
|
---|
1695 | return
|
---|
1696 | end
|
---|
1697 | pause(1.02-get(handles.speed,'Value'))% wait for next image
|
---|
1698 | end
|
---|
1699 | if isfield(UvData,'aviobj') && ~isempty( UvData.aviobj),
|
---|
1700 | UvData.aviobj=close(UvData.aviobj);
|
---|
1701 | set(handles.uvmat,'UserData',UvData);
|
---|
1702 | end
|
---|
1703 | set(handles.Movie,'BackgroundColor',[1 0 0])%paint the command buttonback to red
|
---|
1704 |
|
---|
1705 | %-------------------------------------------------------------------
|
---|
1706 | % -- Executes on button press in Movie: make a series of <- steps
|
---|
1707 | function MovieBackward_Callback(hObject, eventdata, handles)
|
---|
1708 | %------------------------------------------------------------------
|
---|
1709 | set(handles.MovieBackward,'BackgroundColor',[1 1 0])%paint the command button in yellow
|
---|
1710 | drawnow
|
---|
1711 | increment=-str2double(get(handles.increment_scan,'String')); %get the field increment d
|
---|
1712 | if isnan(increment)
|
---|
1713 | set(handles.increment_scan,'String','1')%default value
|
---|
1714 | increment=1;
|
---|
1715 | end
|
---|
1716 | set(handles.STOP,'Visible','on')
|
---|
1717 | set(handles.speed,'Visible','on')
|
---|
1718 | set(handles.speed_txt,'Visible','on')
|
---|
1719 | set(handles.MovieBackward,'BusyAction','queue')
|
---|
1720 | UvData=get(handles.uvmat,'UserData');
|
---|
1721 |
|
---|
1722 | while get(handles.speed,'Value')~=0 && isequal(get(handles.MovieBackward,'BusyAction'),'queue') % enable STOP command
|
---|
1723 | errormsg=runpm(hObject,eventdata,handles,increment);
|
---|
1724 | if ~isempty(errormsg)
|
---|
1725 | set(handles.MovieBackward,'BackgroundColor',[1 0 0])%paint the command buttonback to red
|
---|
1726 | return
|
---|
1727 | end
|
---|
1728 | pause(1.02-get(handles.speed,'Value'))% wait for next image
|
---|
1729 | end
|
---|
1730 | if isfield(UvData,'aviobj') && ~isempty( UvData.aviobj),
|
---|
1731 | UvData.aviobj=close(UvData.aviobj);
|
---|
1732 | set(handles.uvmat,'UserData',UvData);
|
---|
1733 | end
|
---|
1734 | set(handles.MovieBackward,'BackgroundColor',[1 0 0])%paint the command buttonback to red
|
---|
1735 |
|
---|
1736 | %-------------------------------------------------------------------
|
---|
1737 | function STOP_Callback(hObject, eventdata, handles)
|
---|
1738 | %-------------------------------------------------------------------
|
---|
1739 | set(handles.movie_pair,'BusyAction','Cancel')
|
---|
1740 | set(handles.movie_pair,'value',0)
|
---|
1741 | set(handles.Movie,'BusyAction','Cancel')
|
---|
1742 | set(handles.MovieBackward,'BusyAction','Cancel')
|
---|
1743 | set(handles.MenuExportMovie,'BusyAction','Cancel')
|
---|
1744 | set(handles.movie_pair,'BackgroundColor',[1 0 0])%paint the command buttonback to red
|
---|
1745 | set(handles.Movie,'BackgroundColor',[1 0 0])%paint the command buttonback to red
|
---|
1746 | set(handles.MovieBackward,'BackgroundColor',[1 0 0])%paint the command buttonback to red
|
---|
1747 |
|
---|
1748 | %------------------------------------------------------------------
|
---|
1749 | function errormsg=runpm(hObject,eventdata,handles,increment)
|
---|
1750 | %------------------------------------------------------------------
|
---|
1751 | %check for mï¿œovie pair status
|
---|
1752 | movie_status=get(handles.movie_pair,'Value');
|
---|
1753 | if isequal(movie_status,1)
|
---|
1754 | STOP_Callback(hObject, eventdata, handles)%interrupt movie pair if active
|
---|
1755 | end
|
---|
1756 | %read the data on the current input rootfile(s)
|
---|
1757 |
|
---|
1758 | [FileName,RootPath,filebase,FileIndices,FileExt,subdir]=read_file_boxes(handles);
|
---|
1759 | NomType=get(handles.FileIndex,'UserData');
|
---|
1760 |
|
---|
1761 | num1=stra2num(get(handles.i1,'String'));
|
---|
1762 | num2=stra2num(get(handles.i2,'String'));
|
---|
1763 | num_a=stra2num(get(handles.j1,'String'));
|
---|
1764 | num_b=stra2num(get(handles.j2,'String'));
|
---|
1765 |
|
---|
1766 | sub_value= get(handles.SubField,'Value');
|
---|
1767 | if sub_value % a second input file has been entered
|
---|
1768 | [FileName_1,RootPath_1,filebase_1,FileIndices_1,FileExt_1,SubDir_1]=read_file_boxes_1(handles);
|
---|
1769 | [pp,ff,str1,str2,str_a,str_b]=name2display(FileIndices_1);
|
---|
1770 | num1_1=stra2num(str1);%current set of indices for the second field (may be set different than the main indices)
|
---|
1771 | num2_1=stra2num(str2);
|
---|
1772 | num_a_1=stra2num(str_a);
|
---|
1773 | num_b_1=stra2num(str_b);
|
---|
1774 | NomType_1=get(handles.FileIndex_1,'UserData');
|
---|
1775 | else
|
---|
1776 | filename_1=[];
|
---|
1777 | end
|
---|
1778 |
|
---|
1779 | comp_input=get(handles.fix_pair,'Value');
|
---|
1780 |
|
---|
1781 | %case of scanning along the first direction (rootfile numbers)
|
---|
1782 | if get(handles.scan_i,'Value')==1% case of scanning along index i
|
---|
1783 | num1=num1+increment;
|
---|
1784 | num2=num2+increment;
|
---|
1785 | [filename,num1,num_a,num2,num_b]=name_generator(filebase,num1,num_a,FileExt,NomType,comp_input,num2,num_b,subdir);
|
---|
1786 | if sub_value% set the second field name and indices
|
---|
1787 | num1_1=num1_1+increment;
|
---|
1788 | num2_1=num2_1+increment;
|
---|
1789 | filename_1=name_generator(filebase_1,num1_1,num_a_1,FileExt_1,NomType_1,1,num2_1,num_b_1,SubDir_1);
|
---|
1790 | end
|
---|
1791 | else % case of scanning along index j (burst numbers)
|
---|
1792 | num_a=num_a+increment;
|
---|
1793 | num_b=num_b+increment;
|
---|
1794 | [filename,num1,num_a,num2,num_b]=name_generator(filebase,num1,num_a,FileExt,NomType,comp_input,num2,num_b,subdir);
|
---|
1795 | if sub_value
|
---|
1796 | num_a_1=num_a_1+increment;
|
---|
1797 | num_b_1=num_b_1+increment;
|
---|
1798 | filename_1=name_generator(filebase_1,num1_1,num_a_1,FileExt_1,NomType_1,1,num2_1,num_b_1,SubDir_1);
|
---|
1799 | end
|
---|
1800 | end
|
---|
1801 |
|
---|
1802 | % refresh plots
|
---|
1803 | errormsg=refresh_field(handles,filename,filename_1,num1,num2,num_a,num_b);
|
---|
1804 | if isempty(errormsg) %update the index counters
|
---|
1805 | set(handles.i1,'String',num2stra(num1,NomType,1));
|
---|
1806 | if isequal(num2,num1)
|
---|
1807 | set(handles.i2,'String','');
|
---|
1808 | else
|
---|
1809 | set(handles.i2,'String',num2stra(num2,NomType,1));
|
---|
1810 | end
|
---|
1811 | set(handles.j1,'String',num2stra(num_a,NomType,2));
|
---|
1812 | if isequal(num_b,num_a)
|
---|
1813 | set(handles.j2,'String','');
|
---|
1814 | else
|
---|
1815 | set(handles.j2,'String',num2stra(num_b,NomType,2));
|
---|
1816 | end
|
---|
1817 | [indices]=name_generator('',num1,num_a,'',NomType,1,num2,num_b,'');
|
---|
1818 | set(handles.FileIndex,'String',indices);
|
---|
1819 | if ~isempty(filename_1)
|
---|
1820 | indices_1=name_generator('',num1_1,num_a_1,'',NomType_1,1,num2_1,num_b_1,'');
|
---|
1821 | set(handles.FileIndex_1,'String',indices_1);
|
---|
1822 | end
|
---|
1823 | if isequal(movie_status,1)
|
---|
1824 | set(handles.movie_pair,'Value',1)
|
---|
1825 | movie_pair_Callback(hObject, eventdata, handles); %reactivate moviepair if it was activated
|
---|
1826 | end
|
---|
1827 | end
|
---|
1828 |
|
---|
1829 |
|
---|
1830 | %-------------------------------------------------------
|
---|
1831 | % --- Executes on button press in movie_pair: create an alternating movie with two view
|
---|
1832 | %-------------------------------------------------------
|
---|
1833 | function movie_pair_Callback(hObject, eventdata, handles)
|
---|
1834 | status=get(handles.movie_pair,'value');
|
---|
1835 | if isequal(status,0)
|
---|
1836 | set(handles.movie_pair,'BusyAction','Cancel')%stop movie pair if button is 'off'
|
---|
1837 | set(handles.i2,'String','')
|
---|
1838 | set(handles.j2,'String','')
|
---|
1839 | return
|
---|
1840 | else
|
---|
1841 | set(handles.movie_pair,'BusyAction','queue')
|
---|
1842 | end
|
---|
1843 | %initialisation
|
---|
1844 | set(handles.movie_pair,'BackgroundColor',[1 1 0])%paint the command button in yellow
|
---|
1845 | drawnow
|
---|
1846 | list_fields=get(handles.Fields,'String');% list menu fields
|
---|
1847 | index_fields=get(handles.Fields,'Value');% selected string index
|
---|
1848 | FieldName=list_fields{index_fields}; % selected field
|
---|
1849 | UvData=get(handles.uvmat,'UserData');
|
---|
1850 | if isequal(FieldName,'image')
|
---|
1851 | test_1=0;
|
---|
1852 | [ff,rr,filebase,xx,Ext,SubDir]=read_file_boxes(handles);
|
---|
1853 | NomType=get(handles.FileIndex,'UserData');
|
---|
1854 | else
|
---|
1855 | list_fields=get(handles.Fields_1,'String');% list menu fields
|
---|
1856 | index_fields=get(handles.Fields_1,'Value');% selected string index
|
---|
1857 | FieldName=list_fields{index_fields}; % selected field
|
---|
1858 | if isequal(FieldName,'image')
|
---|
1859 | test_1=1;
|
---|
1860 | [ff,rr,filebase,xx,Ext,SubDir]=read_file_boxes_1(handles);
|
---|
1861 | NomType=get(handles.FileIndex_1,'UserData');
|
---|
1862 | else
|
---|
1863 | msgbox_uvmat('ERROR','an image or movie must be first introduced as input')
|
---|
1864 | set(handles.movie_pair,'BackgroundColor',[1 0 0])%paint the command button in red
|
---|
1865 | return
|
---|
1866 | end
|
---|
1867 | end
|
---|
1868 |
|
---|
1869 | num_i1=str2double(get(handles.i1,'String'));
|
---|
1870 | num_j1=stra2num(get(handles.j1,'String'));
|
---|
1871 | num_i2=str2double(get(handles.i2,'String'));
|
---|
1872 | num_j2=stra2num(get(handles.j2,'String'));
|
---|
1873 | if isnan(num_j2)
|
---|
1874 | if isempty(num_i2)
|
---|
1875 | msgbox_uvmat('ERROR', 'a second image index i2 or j2 is needed to show the pair as a movie')
|
---|
1876 | set(handles.movie_pair,'BackgroundColor',[1 0 0])%paint the command button in red
|
---|
1877 | return
|
---|
1878 | else
|
---|
1879 | num_j2=num_j1;%repeat the index i1 by default
|
---|
1880 | end
|
---|
1881 | end
|
---|
1882 | if isnan(num_i2)
|
---|
1883 | num_i2=num_i1;%repeat the index i1 by default
|
---|
1884 | end
|
---|
1885 | imaname_1=name_generator(filebase,num_i2,num_j2,Ext,NomType);
|
---|
1886 | if ~exist(imaname_1,'file')
|
---|
1887 | msgbox_uvmat('ERROR',['second input open (-) ' imaname_1 ' not found']);
|
---|
1888 | set(handles.movie_pair,'BackgroundColor',[1 0 0])%paint the command button in red
|
---|
1889 | return
|
---|
1890 | end
|
---|
1891 |
|
---|
1892 | %read the second image
|
---|
1893 | Field.AName='image';
|
---|
1894 | if test_1
|
---|
1895 | Field_a=UvData.Field_1;
|
---|
1896 | else
|
---|
1897 | Field_a=UvData.Field;
|
---|
1898 | end
|
---|
1899 | Field_b.AX=Field_a.AX;
|
---|
1900 | Field_b.AY=Field_a.AY;
|
---|
1901 | % z index
|
---|
1902 | nbslice=str2double(get(handles.nb_slice,'String'));
|
---|
1903 | if ~isempty(nbslice)
|
---|
1904 | Field_b.ZIndex=mod(num_i2-1,nbslice)+1;
|
---|
1905 | end
|
---|
1906 | Field_b.CoordType='px';
|
---|
1907 | %determine the input file type
|
---|
1908 | if (test_1 && isfield(UvData,'MovieObject_1'))||(~test_1 && isfield(UvData,'MovieObject'))
|
---|
1909 | FileType='movie';
|
---|
1910 | elseif isequal(lower(Ext),'.avi')
|
---|
1911 | FileType='avi';
|
---|
1912 | elseif isequal(lower(Ext),'.vol')
|
---|
1913 | FileType='vol';
|
---|
1914 | else
|
---|
1915 | form=imformats(Ext(2:end));
|
---|
1916 | if ~isempty(form)% if the extension corresponds to an image format recognized by Matlab
|
---|
1917 | if isequal(NomType,'*');
|
---|
1918 | FileType='multimage';
|
---|
1919 | else
|
---|
1920 | FileType='image';
|
---|
1921 | end
|
---|
1922 | end
|
---|
1923 | end
|
---|
1924 | switch FileType
|
---|
1925 | case 'movie'
|
---|
1926 | if test_1
|
---|
1927 | Field_b.A=read(UvData.MovieObject_1,num_i2);
|
---|
1928 | else
|
---|
1929 | Field_b.A=read(UvData.MovieObject,num_i2);
|
---|
1930 | end
|
---|
1931 | case 'avi'
|
---|
1932 | mov=aviread(imaname_1,num_i2);
|
---|
1933 | Field_b.A=frame2im(mov(1));
|
---|
1934 | case 'vol'
|
---|
1935 | Field_b.A=imread(imaname_1);
|
---|
1936 | case 'multimage'
|
---|
1937 | Field_b.A=imread(imaname_1,num_i2);
|
---|
1938 | case 'image'
|
---|
1939 | Field_b.A=imread(imaname_1);
|
---|
1940 | end
|
---|
1941 | if get(handles.slices,'Value')
|
---|
1942 | Field.ZIndex=str2double(get(handles.z_index,'String'));
|
---|
1943 | end
|
---|
1944 |
|
---|
1945 | %px to phys or other transform on field
|
---|
1946 | menu_transform=get(handles.transform_fct,'String');
|
---|
1947 | choice_value=get(handles.transform_fct,'Value');
|
---|
1948 | transform_name=menu_transform{choice_value};%name of the transform fct given by the menu 'transform_fct'
|
---|
1949 | transform_list=get(handles.transform_fct,'UserData');
|
---|
1950 | transform=transform_list{choice_value};
|
---|
1951 | if ~isequal(transform_name,'') && ~isequal(transform_name,'px')
|
---|
1952 | if test_1 && isfield(UvData,'XmlData_1') && isfield(UvData.XmlData_1,'GeometryCalib')%use geometry calib recorded from the ImaDoc xml file as first priority
|
---|
1953 | Field_a=transform(Field_a,UvData.XmlData_1);%the first field has been stored without transform
|
---|
1954 | Field_b=transform(Field_b,UvData.XmlData_1);
|
---|
1955 | elseif ~test_1 && isfield(UvData,'XmlData') && isfield(UvData.XmlData,'GeometryCalib')%use geometry calib
|
---|
1956 | Field_b=transform(Field_b,UvData.XmlData);
|
---|
1957 | end
|
---|
1958 | end
|
---|
1959 |
|
---|
1960 | % make movie until movie speed is set to 0 or STOP is activated
|
---|
1961 | hima=findobj(handles.axes3,'Tag','ima');% %handles.axes3 =main plotting window (A GENERALISER)
|
---|
1962 | set(handles.STOP,'Visible','on')
|
---|
1963 | set(handles.speed,'Visible','on')
|
---|
1964 | set(handles.speed_txt,'Visible','on')
|
---|
1965 | while get(handles.speed,'Value')~=0 && isequal(get(handles.movie_pair,'BusyAction'),'queue')%isequal(get(handles.run0,'BusyAction'),'queue'); % enable STOP command
|
---|
1966 | % read and plot the series of images in non erase mode
|
---|
1967 | set(hima,'CData',Field_b.A);
|
---|
1968 | pause(1.02-get(handles.speed,'Value'));% wait for next image
|
---|
1969 | set(hima,'CData',Field_a.A);
|
---|
1970 | pause(1.02-get(handles.speed,'Value'));% wait for next image
|
---|
1971 | end
|
---|
1972 | set(handles.movie_pair,'BackgroundColor',[1 0 0])%paint the command button in red
|
---|
1973 |
|
---|
1974 | %------------------------------------------------------------------------
|
---|
1975 | % --- Executes on button press in run0.
|
---|
1976 | function run0_Callback(hObject, eventdata, handles)
|
---|
1977 | %------------------------------------------------------------------------
|
---|
1978 | set(handles.run0,'BackgroundColor',[1 1 0])%paint the command button in yellow
|
---|
1979 | drawnow
|
---|
1980 | filename=read_file_boxes(handles);
|
---|
1981 |
|
---|
1982 | filename_1=[];%default
|
---|
1983 | if get(handles.SubField,'Value')
|
---|
1984 | filename_1=read_file_boxes_1(handles);
|
---|
1985 | end
|
---|
1986 | num_i1=stra2num(get(handles.i1,'String'));
|
---|
1987 | num_i2=stra2num(get(handles.i2,'String'));
|
---|
1988 | num_j1=stra2num(get(handles.j1,'String'));
|
---|
1989 | num_j2=stra2num(get(handles.j2,'String'));
|
---|
1990 | errormsg=refresh_field(handles,filename,filename_1,num_i1,num_i2,num_j1,num_j2);
|
---|
1991 | if ~isempty(errormsg)
|
---|
1992 | msgbox_uvmat('ERROR',errormsg);
|
---|
1993 | end
|
---|
1994 | set(handles.run0,'BackgroundColor',[1 0 0])
|
---|
1995 |
|
---|
1996 | %------------------------------------------------------------------------
|
---|
1997 | % --- read the input files and refresh all the plots, including projection.
|
---|
1998 | % OUTPUT:
|
---|
1999 | % errormsg: error message char string =[] by default
|
---|
2000 | % INPUT:
|
---|
2001 | % filename: first input file (=[] in the absence of input file)
|
---|
2002 | % filename_1: second input file (=[] in the asbsenc of secodn input file)
|
---|
2003 | % num_i1,num_i2,num_j1,num_j2; frame indices
|
---|
2004 | % Field: structure describing an optional input field (then replace the input file)
|
---|
2005 | function errormsg=refresh_field(handles,filename,filename_1,num_i1,num_i2,num_j1,num_j2,Field)
|
---|
2006 | %------------------------------------------------------------------------
|
---|
2007 |
|
---|
2008 | %initialisation
|
---|
2009 | % errormsg=[]; % default error message
|
---|
2010 | abstime=[];
|
---|
2011 | abstime_1=[];
|
---|
2012 | dt=[];
|
---|
2013 | if ~exist('Field','var')
|
---|
2014 | Field={};
|
---|
2015 | end
|
---|
2016 | UvData=get(handles.uvmat,'UserData');
|
---|
2017 | %UvData =structure containing information stored outside the uicontrol of uvmat
|
---|
2018 | % .NewSeries: =1 for a new series (new root fiel introduced), 0 else
|
---|
2019 | % .MovieObject: movie object representing an input movie
|
---|
2020 | % .MovieObject_1: idem for a second input series (_1)
|
---|
2021 | % .filename_1 : last second input file name (to deal with a constant second input without reading again the file)
|
---|
2022 | % .VelType_1: last velocity type (civ1, civ2...) for the second input series
|
---|
2023 | % .FieldName_1: last field name(velocity, vorticity...) for the second input series
|
---|
2024 | % .NbDim: number of space dimensions of the input field
|
---|
2025 | % .ZMin, .ZMax: range of the z coordinate
|
---|
2026 | %..... to complement
|
---|
2027 |
|
---|
2028 | if ishandle(handles.UVMAT_title) %remove title panel on uvmat
|
---|
2029 | delete(handles.UVMAT_title)
|
---|
2030 | end
|
---|
2031 |
|
---|
2032 | %% determine the main input file information for action
|
---|
2033 | FileType=[];%default
|
---|
2034 | if ~isempty(filename)
|
---|
2035 | if ~exist(filename,'file')
|
---|
2036 | errormsg=['input file ' filename ' does not exist'];
|
---|
2037 | return
|
---|
2038 | end
|
---|
2039 | Ext=get(handles.FileExt,'String');
|
---|
2040 | NomType=get(handles.FileIndex,'UserData');
|
---|
2041 | %update the z position index
|
---|
2042 | nbslice_str=get(handles.nb_slice,'String');
|
---|
2043 | % z_index=1;%default
|
---|
2044 | if isequal(nbslice_str,'volume')
|
---|
2045 | z_index=num_j1;
|
---|
2046 | set(handles.z_index,'String',num2str(z_index))
|
---|
2047 | else
|
---|
2048 | nbslice=str2num(nbslice_str);
|
---|
2049 | z_index=mod(num_i1-1,nbslice)+1;
|
---|
2050 | set(handles.z_index,'String',num2str(z_index))
|
---|
2051 | end
|
---|
2052 | % refresh menu for save_mask if relevant
|
---|
2053 | masknumber=get(handles.masklevel,'String');
|
---|
2054 | if length(masknumber)>=z_index
|
---|
2055 | set(handles.masklevel,'Value',z_index)
|
---|
2056 | end
|
---|
2057 |
|
---|
2058 | % determine the input file type
|
---|
2059 | if isequal(Ext,'.nc')||isequal(Ext,'.cdf')
|
---|
2060 | FileType='netcdf';
|
---|
2061 | elseif isfield(UvData,'MovieObject')
|
---|
2062 | FileType='movie';
|
---|
2063 | FieldName='image';
|
---|
2064 | elseif isequal(lower(Ext),'.avi')
|
---|
2065 | FileType='avi';
|
---|
2066 | FieldName='image';
|
---|
2067 | elseif isequal(lower(Ext),'.vol')
|
---|
2068 | FileType='vol';
|
---|
2069 | FieldName='image';
|
---|
2070 | else
|
---|
2071 | form=imformats(Ext(2:end));
|
---|
2072 | if ~isempty(form)% if the extension corresponds to an image format recognized by Matlab
|
---|
2073 | if isequal(NomType,'*');
|
---|
2074 | FileType='multimage';
|
---|
2075 | else
|
---|
2076 | FileType='image';
|
---|
2077 | end
|
---|
2078 | FieldName='image';
|
---|
2079 | end
|
---|
2080 | end
|
---|
2081 | else
|
---|
2082 | FileType='netcdf';
|
---|
2083 | FieldName='get_field...';
|
---|
2084 | end
|
---|
2085 | VelType=[];%default
|
---|
2086 | if isequal(FileType,'netcdf')
|
---|
2087 | list_fields=get(handles.Fields,'String');% list menu fields
|
---|
2088 | index_fields=get(handles.Fields,'Value');% selected string index
|
---|
2089 | FieldName= list_fields{index_fields}; % selected field
|
---|
2090 | if ~isequal(FieldName,'get_field...')% read the field names on the interface get_field...
|
---|
2091 | VelType=setfield(handles);
|
---|
2092 | end
|
---|
2093 | end
|
---|
2094 | %% choose a second field if Subfield option is 'on'
|
---|
2095 | FieldName_1=[];
|
---|
2096 | scal_color=[];
|
---|
2097 | VelType_1=setfield_1(handles);
|
---|
2098 | % sub_value=get(handles.SubField,'Value');
|
---|
2099 | FileType_1='none';%default
|
---|
2100 | if ~isempty(filename_1)
|
---|
2101 | % test for a constant second field (comparison with a fixed field)
|
---|
2102 | NomType_1=get(handles.FileIndex_1,'UserData');
|
---|
2103 | Ext_1=get(handles.FileExt_1,'String');
|
---|
2104 | % determine the input file type
|
---|
2105 | if isequal(Ext_1,'.nc')||isequal(Ext_1,'.cdf')
|
---|
2106 | FileType_1='netcdf';
|
---|
2107 | elseif isfield(UvData,'MovieObject_1')
|
---|
2108 | FileType_1='movie';
|
---|
2109 | FieldName_1='image';
|
---|
2110 | elseif isequal(lower(Ext_1),'.avi')
|
---|
2111 | FileType='avi';
|
---|
2112 | FieldName_1='image';
|
---|
2113 | elseif isequal(lower(Ext_1),'.vol')
|
---|
2114 | FileType_1='vol';
|
---|
2115 | FieldName_1='image';
|
---|
2116 | else
|
---|
2117 | form=imformats(Ext_1(2:end));
|
---|
2118 | if ~isempty(form)% if the extension corresponds to an image format recognized by Matlab
|
---|
2119 | if isequal(NomType_1,'*');
|
---|
2120 | FileType_1='multimage';
|
---|
2121 | else
|
---|
2122 | FileType_1='image';
|
---|
2123 | end
|
---|
2124 | FieldName_1='image';
|
---|
2125 | end
|
---|
2126 | end
|
---|
2127 | if ~isequal(FieldName_1,'image')
|
---|
2128 | list_fields=get(handles.Fields_1,'String');% list menu fields
|
---|
2129 | index_fields=get(handles.Fields_1,'Value');% selected string index
|
---|
2130 | FieldName_1= list_fields{index_fields}; % selected field
|
---|
2131 | if isequal(VelType_1,'*')% free veltype choice
|
---|
2132 | VelType_1=[];
|
---|
2133 | elseif isequal(VelType_1,'"')% veltype the same as for the first field
|
---|
2134 | if isempty(VelType)
|
---|
2135 | VelType_1=[];
|
---|
2136 | else
|
---|
2137 | VelType_1=VelType;
|
---|
2138 | end
|
---|
2139 | end
|
---|
2140 | end
|
---|
2141 | test_keepdata_1=0;% test for keeping the previous stored data if the input files are unchanged
|
---|
2142 | if ~isequal(NomType_1,'*')%in case of a series of files (not avi movie)
|
---|
2143 | if isfield(UvData,'filename_1')&& isfield(UvData,'VelType_1') && isfield(UvData,'FieldName_1')
|
---|
2144 | test_keepdata_1= isequal(filename_1,UvData.filename_1)&&...
|
---|
2145 | isequal(VelType_1,UvData.filename_1) && isequal(FieldName_1,UvData.FieldName_1);
|
---|
2146 | end
|
---|
2147 | end
|
---|
2148 | if test_keepdata_1
|
---|
2149 | Field{2}=UvData.Field_1;
|
---|
2150 | elseif ~exist(filename_1,'file')
|
---|
2151 | errormsg=['second file ' filename_1 ' does not exist'];
|
---|
2152 | return
|
---|
2153 | end
|
---|
2154 | end
|
---|
2155 |
|
---|
2156 | %% read the input field(s)
|
---|
2157 | %read images
|
---|
2158 | if ~isempty(filename) && isequal(FieldName,'image')
|
---|
2159 | switch FileType
|
---|
2160 | case 'movie'
|
---|
2161 | try
|
---|
2162 | A=read(UvData.MovieObject,num_i1);
|
---|
2163 | catch
|
---|
2164 | errormsg=lasterr;
|
---|
2165 | return
|
---|
2166 | end
|
---|
2167 | case 'avi'
|
---|
2168 | try
|
---|
2169 | mov=aviread(filename,num_i1);
|
---|
2170 | catch
|
---|
2171 | errormsg=lasterr;
|
---|
2172 | return
|
---|
2173 | end
|
---|
2174 | A=frame2im(mov(1));
|
---|
2175 | case 'vol'
|
---|
2176 | A=imread(filename);
|
---|
2177 | case 'multimage'
|
---|
2178 | A=imread(filename,num_i1);
|
---|
2179 | case 'image'
|
---|
2180 | A=imread(filename);
|
---|
2181 | end
|
---|
2182 | npxy=size(A);
|
---|
2183 | set(handles.npx,'String',num2str(npxy(2)));% display image size on the interface
|
---|
2184 | set(handles.npy,'String',num2str(npxy(1)));
|
---|
2185 | Rangx=[0.5 npxy(2)-0.5]; % coordinates of the first and last pixel centers
|
---|
2186 | Rangy=[npxy(1)-0.5 0.5]; %
|
---|
2187 | Field{1}.AName='image';
|
---|
2188 | Field{1}.ListVarName={'AY','AX','A'}; %
|
---|
2189 | if size(A,3)==3;%color
|
---|
2190 | Field{1}.VarDimName={'AY','AX',{'AY','AX','rgb'}}; %
|
---|
2191 | else
|
---|
2192 | Field{1}.VarDimName={'AY','AX',{'AY','AX'}}; %
|
---|
2193 | end
|
---|
2194 | Field{1}.AY=Rangy;
|
---|
2195 | Field{1}.AX=Rangx;
|
---|
2196 | Field{1}.A=A;
|
---|
2197 | Field{1}.CoordType='px'; %used for mouse_motion
|
---|
2198 | Field{1}.CoordUnit='pixel'; %used for mouse_motion
|
---|
2199 | end
|
---|
2200 |
|
---|
2201 | %read a second image
|
---|
2202 | if ~isempty(filename_1) && ~test_keepdata_1 && isequal(FieldName_1,'image')
|
---|
2203 | switch FileType_1
|
---|
2204 | case 'movie'
|
---|
2205 | A=read(UvData.MovieObject_1,num_i1);
|
---|
2206 | case 'avi'
|
---|
2207 | mov=aviread(filename_1,num_i1);
|
---|
2208 | A=frame2im(mov(1));
|
---|
2209 | case 'vol'
|
---|
2210 | A=imread(filename_1);
|
---|
2211 | case 'multimage'
|
---|
2212 | A=imread(filename_1,num_i1);
|
---|
2213 | case 'image'
|
---|
2214 | A=imread(filename_1);
|
---|
2215 | case 'netcdf'
|
---|
2216 | otherwise
|
---|
2217 | errormsg=['unknown input file type ' filename_1];
|
---|
2218 | end
|
---|
2219 | npxy=size(A);
|
---|
2220 | set(handles.npx,'String',num2str(npxy(2)));% display image size on the interface
|
---|
2221 | set(handles.npy,'String',num2str(npxy(1)));
|
---|
2222 | Rangx=[0.5 npxy(2)-0.5]; % coordinates of the first and last pixel centers
|
---|
2223 | Rangy=[npxy(1)-0.5 0.5]; %
|
---|
2224 | Field{2}.AName='image';
|
---|
2225 | Field{2}.ListVarName={'AY','AX','A'}; %
|
---|
2226 | if size(A,3)==3;%color
|
---|
2227 | Field{2}.VarDimName={'AY','AX',{'AY','AX','rgb'}}; %
|
---|
2228 | else
|
---|
2229 | Field{2}.VarDimName={'AY','AX',{'AY','AX'}}; %
|
---|
2230 | end
|
---|
2231 | Field{2}.AY=Rangy;
|
---|
2232 | Field{2}.AX=Rangx;
|
---|
2233 | Field{2}.A=A;
|
---|
2234 | Field{2}.CoordType='px'; %used for mouse_motion
|
---|
2235 | Field{2}.CoordUnit='px'; %used for move_mou
|
---|
2236 | end
|
---|
2237 |
|
---|
2238 | %read ncfile(s)
|
---|
2239 | CivStage_1=0;%default
|
---|
2240 | VelType_out_1=[];
|
---|
2241 | InputField={FieldName};
|
---|
2242 | InputField_1={FieldName_1};
|
---|
2243 | if (~isempty(filename)&& isequal(FileType,'netcdf')) || (~isempty(filename_1)&& isequal(FileType_1,'netcdf')) ;
|
---|
2244 | %read the velocity field(s) from netcdf rootfile(s)
|
---|
2245 | list_code=get(handles.col_vec,'String');% list menu fields
|
---|
2246 | index_code=get(handles.col_vec,'Value');% selected string index
|
---|
2247 | scal_color= list_code{index_code(1)}; % selected field
|
---|
2248 | if isequal(FieldName,'velocity')&& ~isequal(scal_color,'black') && ~isequal(scal_color,'white')
|
---|
2249 | InputField=[InputField scal_color];
|
---|
2250 | end
|
---|
2251 | if isequal(FieldName_1,'velocity') && ~isequal(scal_color,'black') && ~isequal(scal_color,'white')
|
---|
2252 | InputField_1=[InputField_1 scal_color];
|
---|
2253 | end
|
---|
2254 | if isequal(FileType,'netcdf') %read the first nc field
|
---|
2255 | if isequal(FieldName,'get_field...')% read the field names on the interface get_field.
|
---|
2256 | hget_field=findobj(allchild(0),'Name','uvmat_field');%find the get_field... GUI
|
---|
2257 | if isempty(hget_field)
|
---|
2258 | hget_field= get_field(filename);%open the get_field GUI
|
---|
2259 | set(hget_field,'name','uvmat_field')
|
---|
2260 | elseif UvData.NewSeries% refresh the fet_field GUI for a new series
|
---|
2261 | delete(hget_field)
|
---|
2262 | hget_field= get_field(filename);%open the get_field GUI
|
---|
2263 | set(hget_field,'name','uvmat_field')%rename get_field GUI for the 'slave' mode
|
---|
2264 | end
|
---|
2265 | hhget_field=guidata(hget_field);
|
---|
2266 | funct_list=get(hhget_field.ACTION,'UserData');
|
---|
2267 | funct_index=get(hhget_field.ACTION,'Value');
|
---|
2268 | funct=funct_list{funct_index};%select the current action in get_field, e;g. PLOT
|
---|
2269 | Field{1}=funct(hget_field); %%activate the current action selected in get_field, e;g.read the names of the variables to plot
|
---|
2270 | CivStage=0;
|
---|
2271 | VelType_out=[];
|
---|
2272 | else
|
---|
2273 | [Field{1},VelType_out]=read_civxdata(filename,InputField,VelType);
|
---|
2274 | if isfield(Field{1},'Txt')
|
---|
2275 | errormsg=Field{1}.Txt;
|
---|
2276 | return
|
---|
2277 | end
|
---|
2278 | CivStage=Field{1}.CivStage;
|
---|
2279 | UvData.NbDim=Field{1}.nb_dim;
|
---|
2280 | end
|
---|
2281 | end
|
---|
2282 | if ~isempty(filename_1) && ~test_keepdata_1 && isequal(FileType_1,'netcdf') %read the second file
|
---|
2283 | if isequal(FieldName_1,'get_field...')% read the field names on the interface get_field.
|
---|
2284 | hget_field_1=findobj(allchild(0),'Name','uvmat_field_1');%find the get_field... GUI
|
---|
2285 | if isempty(hget_field_1)
|
---|
2286 | hget_field_1= get_field(filename_1);%open the get_field GUI
|
---|
2287 | set(hget_field_1,'name','uvmat_field_1')
|
---|
2288 | end
|
---|
2289 | hhget_field_1=guidata(hget_field_1);%handles of GUI elements in get_field
|
---|
2290 | funct_list=get(hhget_field_1.ACTION,'UserData');
|
---|
2291 | funct_index=get(hhget_field_1.ACTION,'Value');
|
---|
2292 | funct=funct_list{funct_index};
|
---|
2293 | Field{2}=funct(hget_field_1); %read the names of the variables to plot in the get_field GUI
|
---|
2294 | else
|
---|
2295 | [Field{2},VelType_out_1]=read_civxdata(filename_1,InputField_1,VelType_1);
|
---|
2296 | CivStage_1=Field{2}.CivStage;
|
---|
2297 | end
|
---|
2298 | if ~isequal(FileType,'netcdf')
|
---|
2299 | VelType_out=VelType_out_1;
|
---|
2300 | end
|
---|
2301 | end
|
---|
2302 | end
|
---|
2303 |
|
---|
2304 | %store the second field for possible latter use
|
---|
2305 | if numel(Field)==2
|
---|
2306 | UvData.Field_1=Field{2};
|
---|
2307 | end
|
---|
2308 |
|
---|
2309 | %% update the display buttons for the first velocity type (first menuline)
|
---|
2310 | veltype_handles=[handles.civ1 handles.interp1 handles.filter1 handles.civ2 handles.interp2 handles.filter2];
|
---|
2311 | if ~isequal(FileType,'netcdf')
|
---|
2312 | reset_vel_type(veltype_handles)
|
---|
2313 | elseif isempty(VelType) && ~isequal(FieldName,'get_field...')
|
---|
2314 | set_veltype_display(veltype_handles,CivStage)%update the display of available velocity types for the first field
|
---|
2315 | if isempty(VelType_out)
|
---|
2316 | reset_vel_type(veltype_handles)
|
---|
2317 | else
|
---|
2318 | handle1=eval(['handles.' VelType_out]);
|
---|
2319 | reset_vel_type(veltype_handles,handle1)
|
---|
2320 | end
|
---|
2321 | end
|
---|
2322 |
|
---|
2323 | %% update the display buttons for the second velocity type (second menuline)
|
---|
2324 | veltype_handles_1=[handles.civ1_1 handles.interp1_1 handles.filter1_1 handles.civ2_1 handles.interp2_1 handles.filter2_1];
|
---|
2325 | if ~isequal(FileType_1,'netcdf')
|
---|
2326 | reset_vel_type(veltype_handles_1)
|
---|
2327 | elseif isempty(VelType_1) && ~isequal(FieldName_1,'get_field...')
|
---|
2328 | set_veltype_display(veltype_handles_1,CivStage_1)%update the display of available velocity types for the first field
|
---|
2329 | if isempty(VelType_out_1)
|
---|
2330 | reset_vel_type(veltype_handles_1)
|
---|
2331 | else
|
---|
2332 | handle1=eval(['handles.' VelType_out_1 '_1']);
|
---|
2333 | reset_vel_type(veltype_handles_1,handle1)
|
---|
2334 | end
|
---|
2335 | end
|
---|
2336 |
|
---|
2337 | %% introduce w as background image by default for a new series (only for nbdim=2)
|
---|
2338 | if ~isfield(UvData,'NewSeries')
|
---|
2339 | UvData.NewSeries=1;
|
---|
2340 | end
|
---|
2341 | %put W as background image by default if NbDim=2:
|
---|
2342 | if ~isfield(UvData,'NbDim')||isempty(UvData.NbDim)||~isequal(UvData.NbDim,3)
|
---|
2343 | if UvData.NewSeries && isequal(get(handles.SubField,'Value'),0) && isfield(Field{1},'W') && ~isempty(Field{1}.W);
|
---|
2344 | set(handles.SubField,'Value',1);
|
---|
2345 | %menu=update_menu(handles.Fields_1,'w');%update the menu for the background scalar nd set the choice to 'w'
|
---|
2346 | set(handles.RootPath_1,'String','"')
|
---|
2347 | set(handles.RootFile_1,'String','"')
|
---|
2348 | set(handles.SubDir_1,'String','"');
|
---|
2349 | [indices]=name_generator('',num_i1,num_j1,'',NomType,1,num_i2,num_j2,'');
|
---|
2350 | set(handles.FileIndex_1,'String',indices)
|
---|
2351 | set(handles.FileExt_1,'String','"');
|
---|
2352 | set(handles.Fields_1,'Visible','on');
|
---|
2353 | set(handles.Fields_1,'Visible','on');
|
---|
2354 | set(handles.RootPath_1,'Visible','on')
|
---|
2355 | set(handles.RootFile_1,'Visible','on')
|
---|
2356 | set(handles.SubDir_1,'Visible','on');
|
---|
2357 | set(handles.FileIndex_1,'Visible','on');
|
---|
2358 | set(handles.FileExt_1,'Visible','on');
|
---|
2359 | set(handles.Fields_1,'Visible','on');
|
---|
2360 | Field{1}.AName='w';
|
---|
2361 | % testscal=1;
|
---|
2362 | end
|
---|
2363 | end
|
---|
2364 |
|
---|
2365 | %multislice case
|
---|
2366 | if ~isempty(filename) &&(~isfield(UvData,'NbDim') || isequal(UvData.NbDim,2))&&...%2D case
|
---|
2367 | isfield(UvData,'XmlData') && isfield(UvData.XmlData,'GeometryCalib')&& isfield(UvData.XmlData.GeometryCalib,'SliceCoord')
|
---|
2368 | siz=size(UvData.XmlData.GeometryCalib.SliceCoord);
|
---|
2369 | % if siz(1)>1
|
---|
2370 | % NbSlice=siz(1);
|
---|
2371 | % else
|
---|
2372 | % NbSlice=1;
|
---|
2373 | % end
|
---|
2374 | end
|
---|
2375 |
|
---|
2376 | %store the current open names, fields and vel types in uvmat interface
|
---|
2377 | UvData.filename=filename;
|
---|
2378 | UvData.filename_1=filename_1;
|
---|
2379 | UvData.VelType=VelType;
|
---|
2380 | UvData.VelType_1=VelType_1;
|
---|
2381 | UvData.FieldName=FieldName;
|
---|
2382 | UvData.FieldName_1=FieldName_1;
|
---|
2383 | if ~isempty(scal_color)
|
---|
2384 | UvData.CName=scal_color;
|
---|
2385 | end
|
---|
2386 |
|
---|
2387 | %% coordinate transform or user fct
|
---|
2388 | XmlData=[];%default
|
---|
2389 | if isfield(UvData,'XmlData')%use geometry calib recorded from the ImaDoc xml file as first priority
|
---|
2390 | XmlData=UvData.XmlData;
|
---|
2391 | end
|
---|
2392 | XmlData_1=[];%default
|
---|
2393 | if isfield(UvData,'XmlData_1')
|
---|
2394 | XmlData_1=UvData.XmlData_1;
|
---|
2395 | end
|
---|
2396 | % menu_transform=get(handles.transform_fct,'String');
|
---|
2397 | choice_value=get(handles.transform_fct,'Value');
|
---|
2398 | transform_list=get(handles.transform_fct,'UserData');
|
---|
2399 | transform=transform_list{choice_value};%selected function handles
|
---|
2400 | % z index
|
---|
2401 | if ~isempty(filename)
|
---|
2402 | Field{1}.ZIndex=z_index;
|
---|
2403 | end
|
---|
2404 | %px to phys or other transform on field
|
---|
2405 | if ~isempty(transform)
|
---|
2406 | if length(Field)>=2
|
---|
2407 | Field{2}.ZIndex=z_index;
|
---|
2408 | [Field{1},Field{2}]=transform(Field{1},XmlData,Field{2},XmlData_1);
|
---|
2409 | if isempty(Field{2})
|
---|
2410 | Field(2)=[];
|
---|
2411 | end
|
---|
2412 | else
|
---|
2413 | Field{1}=transform(Field{1},XmlData);
|
---|
2414 | end
|
---|
2415 | end
|
---|
2416 |
|
---|
2417 | %% calculate scalar
|
---|
2418 | if isequal(FileType,'netcdf') && ~isequal(FieldName,'get_field...')%
|
---|
2419 | Field{1}=calc_field(InputField,Field{1});
|
---|
2420 | end
|
---|
2421 | if length(Field)==2 && ~test_keepdata_1 && isequal(FileType_1,'netcdf') && ~isequal(FieldName_1,'get_field...')
|
---|
2422 | Field{2}=calc_field(InputField_1,Field{2});
|
---|
2423 | end
|
---|
2424 | % combine the two input fields (e.g. substract velocity fields)
|
---|
2425 | if numel(Field)==2
|
---|
2426 | UvData.Field=sub_field(Field{1},Field{2}); %TO UPDATE FOR MORE GENERAL INPUT
|
---|
2427 | else
|
---|
2428 | UvData.Field=Field{1};
|
---|
2429 | end
|
---|
2430 |
|
---|
2431 | %% test 3D , default projection menuplane and typical mesh (needed to menuopen set_object)
|
---|
2432 | test_x=0;
|
---|
2433 | test_z=0;% test for unstructured z coordinate
|
---|
2434 | UvData.ZMax=0;
|
---|
2435 | UvData.ZMin=0;%default
|
---|
2436 | UvData.Mesh=1; %default
|
---|
2437 | [UvData.Field,errormsg]=check_field_structure(UvData.Field);
|
---|
2438 | if ~isempty(errormsg)
|
---|
2439 | errormsg=['error in uvmat/run0_Callback/check_field_structure: ' errormsg];
|
---|
2440 | return
|
---|
2441 | end
|
---|
2442 | [CellVarIndex,NbDim,VarType]=find_field_indices(UvData.Field);
|
---|
2443 | [NbDim,imax]=max(NbDim);
|
---|
2444 | if isempty(imax)
|
---|
2445 | % DimVarIndex=0;
|
---|
2446 | coord_x=[];
|
---|
2447 | else
|
---|
2448 | % VarIndex=CellVarIndex{imax};
|
---|
2449 | coord_x=VarType{imax}.coord_x;
|
---|
2450 | end
|
---|
2451 | if isfield(UvData,'NbDim') && ~isempty(UvData.NbDim)
|
---|
2452 | NbDim=UvData.NbDim;
|
---|
2453 | else
|
---|
2454 | UvData.NbDim=NbDim;
|
---|
2455 | end
|
---|
2456 | if ~isempty(CellVarIndex) && ~isempty(VarType{imax}.coord_x) && ~isempty(VarType{imax}.coord_y) %unstructured coordinate z
|
---|
2457 | XName=UvData.Field.ListVarName{VarType{imax}.coord_x};
|
---|
2458 | YName=UvData.Field.ListVarName{VarType{imax}.coord_y};
|
---|
2459 | test_x=1;
|
---|
2460 | elseif isfield(UvData.Field,'X') && isfield(UvData.Field,'Y')
|
---|
2461 | XName='X';
|
---|
2462 | YName='Y';
|
---|
2463 | test_x=1;
|
---|
2464 | end
|
---|
2465 | if test_x
|
---|
2466 | eval(['UvData.XMax=max(UvData.Field.' XName ');'])
|
---|
2467 | eval(['UvData.XMin=min(UvData.Field.' XName ');'])
|
---|
2468 | eval(['UvData.YMax=max(UvData.Field.' YName ');'])
|
---|
2469 | eval(['UvData.YMin=min(UvData.Field.' YName ');'])
|
---|
2470 | eval(['nbvec=length(UvData.Field.' XName ');'])
|
---|
2471 | if NbDim==3%
|
---|
2472 | if ~isempty(CellVarIndex) && ~isempty(VarType{imax}.coord_z)%unstructured coordinate z
|
---|
2473 | ZName=UvData.Field.ListVarName{VarType{imax}.coord_z};
|
---|
2474 | eval(['UvData.ZMax=max(UvData.Field.' ZName ');'])
|
---|
2475 | eval(['UvData.ZMin=min(UvData.Field.' ZName ');'])
|
---|
2476 | test_z=1;
|
---|
2477 | elseif isfield(UvData,'Z')% usual civ data
|
---|
2478 | UvData.ZMax=max(UvData.Z);
|
---|
2479 | UvData.ZMin=min(UvData.Z);
|
---|
2480 | test_z=1;
|
---|
2481 | end
|
---|
2482 | end
|
---|
2483 | if isequal(UvData.ZMin,UvData.ZMax)%no z dependency
|
---|
2484 | NbDim=2;
|
---|
2485 | test_z=0;
|
---|
2486 | end
|
---|
2487 | if test_z
|
---|
2488 | UvData.Mesh=((UvData.XMax-UvData.XMin)*(UvData.YMax-UvData.YMin)*(UvData.ZMax-UvData.ZMin))/nbvec;% volume per vector
|
---|
2489 | UvData.Mesh=(UvData.Mesh)^(1/3);
|
---|
2490 | else
|
---|
2491 | UvData.Mesh=sqrt((UvData.XMax-UvData.XMin)*(UvData.YMax-UvData.YMin)/nbvec);%2D
|
---|
2492 | end
|
---|
2493 | end
|
---|
2494 |
|
---|
2495 | %case of structured coordinates
|
---|
2496 | if isfield(UvData.Field,'AX') && isfield(UvData.Field,'AY')&& isfield(UvData.Field,'A')
|
---|
2497 | UvData.XMax=max(UvData.Field.AX);
|
---|
2498 | UvData.XMin=min(UvData.Field.AX);
|
---|
2499 | UvData.YMax=max(UvData.Field.AY);
|
---|
2500 | UvData.YMin=min(UvData.Field.AY);
|
---|
2501 | np_A=size(UvData.Field.A);
|
---|
2502 | UvData.Mesh=sqrt((UvData.XMax-UvData.XMin)*(UvData.YMax-UvData.YMin)/((np_A(1)-1) * (np_A(2)-1))) ;
|
---|
2503 | end
|
---|
2504 | if isempty(coord_x) && ~isempty(CellVarIndex)
|
---|
2505 | VarIndex=CellVarIndex{imax}; % list of variable indices
|
---|
2506 | DimIndex=UvData.Field.VarDimIndex{VarIndex(1)}; %list of dim indices for the variable
|
---|
2507 | if NbDim==3
|
---|
2508 | nbpoints=UvData.Field.DimValue(DimIndex(1));
|
---|
2509 | if isfield(VarType{imax},'coord_3')&& ~isequal(VarType{imax}.coord_3,0) % z is a dimension variable
|
---|
2510 | ZName=UvData.Field.ListVarName{VarType{imax}.coord_3};
|
---|
2511 | eval(['UvData.ZMax=max(UvData.Field.' ZName ');'])
|
---|
2512 | eval(['UvData.ZMin=min(UvData.Field.' ZName ');'])
|
---|
2513 | else
|
---|
2514 | testcoord_z=0;
|
---|
2515 | if length(UvData.Field.VarAttribute)>=VarIndex(1)
|
---|
2516 | if isfield(UvData.Field.VarAttribute{VarIndex(1)},'Coord_1')%regular grid
|
---|
2517 | Coord_z=UvData.Field.VarAttribute{VarIndex(1)}.Coord_1;
|
---|
2518 | UvData.ZMax=max(Coord_z);
|
---|
2519 | UvData.ZMin=min(Coord_z);
|
---|
2520 | testcoord_z=1;
|
---|
2521 | end
|
---|
2522 | end
|
---|
2523 | if ~testcoord_z
|
---|
2524 | UvData.ZMin=1;
|
---|
2525 | UvData.ZMax=UvData.Field.DimValue(DimIndex(1));
|
---|
2526 | end
|
---|
2527 | end
|
---|
2528 | UvData.Mesh=(UvData.ZMax-UvData.ZMin)/(nbpoints-1);
|
---|
2529 | elseif NbDim==2
|
---|
2530 | nbpoints_y=UvData.Field.DimValue(DimIndex(1));
|
---|
2531 | Yvar=VarType{imax}.coord_y;
|
---|
2532 | if Yvar~=0 % x is a dimension variable
|
---|
2533 | YName=UvData.Field.ListVarName{Yvar};
|
---|
2534 | eval(['UvData.YMax=max(UvData.Field.' YName ');'])
|
---|
2535 | eval(['UvData.YMin=min(UvData.Field.' YName ');'])
|
---|
2536 | else
|
---|
2537 | testcoord_y=0;
|
---|
2538 | if ~testcoord_y
|
---|
2539 | UvData.YMin=1;
|
---|
2540 | UvData.YMax=UvData.Field.DimValue(DimIndex(1));
|
---|
2541 | end
|
---|
2542 | end
|
---|
2543 | DY=(UvData.YMax-UvData.YMin)/(nbpoints_y-1);
|
---|
2544 | nbpoints_x=UvData.Field.DimValue(DimIndex(2));
|
---|
2545 | Xvar=VarType{imax}.coord_x;
|
---|
2546 | if Xvar~=0 % x is a dimension variable
|
---|
2547 | XName=UvData.Field.ListVarName{Xvar};
|
---|
2548 | eval(['UvData.XMax=max(UvData.Field.' XName ');'])
|
---|
2549 | eval(['UvData.XMin=min(UvData.Field.' XName ');'])
|
---|
2550 | else
|
---|
2551 | testcoord_x=0;
|
---|
2552 | if ~testcoord_x
|
---|
2553 | UvData.XMin=1;
|
---|
2554 | UvData.XMax=UvData.Field.DimValue(DimIndex(2));
|
---|
2555 | end
|
---|
2556 | end
|
---|
2557 | DX=(UvData.XMax-UvData.XMin)/(nbpoints_x-1);
|
---|
2558 | UvData.Mesh= sqrt(DX*DY);
|
---|
2559 | end
|
---|
2560 | end
|
---|
2561 |
|
---|
2562 | %create a default projection menuplane
|
---|
2563 | UvData.Object{1}.Style='plane';%main plotting plane
|
---|
2564 | UvData.Object{1}.ProjMode='projection';%main plotting plane
|
---|
2565 | if ~isfield(UvData.Object{1},'plotaxes')
|
---|
2566 | UvData.Object{1}.plotaxes=handles.axes3;%default plotting axis
|
---|
2567 | set(handles.list_object_1,'Value',1);
|
---|
2568 | set(handles.list_object_1,'String',{'1-PLANE'});
|
---|
2569 | end
|
---|
2570 |
|
---|
2571 | %3D case (menuvolume)
|
---|
2572 | if NbDim==3 && UvData.NewSeries
|
---|
2573 | UvData.Object{1}.NbDim=UvData.NbDim;%test for 3D objects
|
---|
2574 | UvData.Object{1}.RangeZ=UvData.Mesh;%main plotting plane
|
---|
2575 | UvData.Object{1}.Coord(1,3)=(UvData.ZMin+UvData.ZMax)/2;%section at a middle plane chosen
|
---|
2576 | UvData.Object{1}.Phi=0;
|
---|
2577 | UvData.Object{1}.Theta=0;
|
---|
2578 | UvData.Object{1}.Psi=0;
|
---|
2579 | UvData.Object{1}.HandlesDisplay=plot(0,0,'Tag','proj_object');% A REVOIR
|
---|
2580 | PlotHandles=get_plot_handles(handles);
|
---|
2581 | ZBounds(1)=UvData.ZMin; %minimum for the Z slider
|
---|
2582 | ZBounds(2)=UvData.ZMax;%maximum for the Z slider
|
---|
2583 | UvData.Object{1}.Name='1-PLANE';
|
---|
2584 | UvData.Object{1}.enable_plot=1;
|
---|
2585 | set_object(UvData.Object{1},PlotHandles,ZBounds);
|
---|
2586 | set(handles.list_object_1,'Value',1);
|
---|
2587 | %multilevel case (single menuplane in a 3D space)
|
---|
2588 | elseif isfield(UvData,'Z')
|
---|
2589 | if isfield(UvData,'CoordType')&& isequal(UvData.CoordType,'phys') && isfield(UvData,'XmlData')
|
---|
2590 | XmlData=UvData.XmlData;
|
---|
2591 | if isfield(XmlData,'PlanePos')
|
---|
2592 | UvData.Object{1}.Coord=XmlData.PlanePos(UvData.ZIndex,:);
|
---|
2593 | end
|
---|
2594 | if isfield(XmlData,'PlaneAngle')
|
---|
2595 | siz=size(XmlData.PlaneAngle);
|
---|
2596 | indangle=min(siz(1),UvData.ZIndex);%take first angle if a single angle is defined (translating scanning)
|
---|
2597 | UvData.Object{1}.Phi=XmlData.PlaneAngle(indangle,1);
|
---|
2598 | UvData.Object{1}.Theta=XmlData.PlaneAngle(indangle,2);
|
---|
2599 | UvData.Object{1}.Psi=XmlData.PlaneAngle(indangle,3);
|
---|
2600 | end
|
---|
2601 | elseif isfield(UvData,'ZIndex')
|
---|
2602 | UvData.Object{1}.ZObject=UvData.ZIndex;
|
---|
2603 | end
|
---|
2604 | end
|
---|
2605 |
|
---|
2606 | %% reset the min and max of scalar if only the mask is displayed(TODO: check the need)
|
---|
2607 | if isfield(UvData,'Mask')&& ~isfield(UvData,'A')
|
---|
2608 | set(handles.MinA,'String','0')
|
---|
2609 | set(handles.MaxA,'String','255')
|
---|
2610 | end
|
---|
2611 |
|
---|
2612 | %% Plot the projections on the selected projection objects
|
---|
2613 |
|
---|
2614 | % main projection object (uvmat display)
|
---|
2615 | IndexObj(1)=get(handles.list_object_1,'Value');%selected projection object for main view
|
---|
2616 | if IndexObj(1)> numel(UvData.Object)
|
---|
2617 | IndexObj(1)=1;%select the first object if the selected one does not exist
|
---|
2618 | set(handles.list_object_1,'Value',1)
|
---|
2619 | end
|
---|
2620 | plot_handles{1}=handles;
|
---|
2621 | haxes(1)=handles.axes3;
|
---|
2622 | PlotParam{1}=read_plot_param(handles);%read plotting parameters on the uvmat interfac
|
---|
2623 | keeplim(1)=get(handles.FixedLimits,'Value');% test for fixed graph limits
|
---|
2624 | PosColorbar{1}=UvData.PosColorbar;%prescribe the colorbar position on the uvmat interface
|
---|
2625 |
|
---|
2626 | % second projection object (view_field display)
|
---|
2627 | IndexObj_2=get(handles.list_object_2,'Value');%selected projection object for the second view
|
---|
2628 | if isequal(get(handles.list_object_2,'Visible'),'on') && IndexObj_2 <= numel(UvData.Object)&& ~isempty(UvData.Object{IndexObj_2})
|
---|
2629 | IndexObj(2)=IndexObj_2;
|
---|
2630 | view_field_handle=findobj(allchild(0),'tag','view_field');%handles of the view_field GUI
|
---|
2631 | if ~isempty(view_field_handle)
|
---|
2632 | plot_handles{2}=guidata(view_field_handle);
|
---|
2633 | haxes(2)=plot_handles{2}.axes3;
|
---|
2634 | PlotParam{2}=read_plot_param(plot_handles{2});%read plotting parameters on the uvmat interface
|
---|
2635 | keeplim(2)=get(plot_handles{2}.FixedLimits,'Value');
|
---|
2636 | PosColorbar{2}='*'; %TODO: deal with colorbar position on view_field
|
---|
2637 | end
|
---|
2638 | end
|
---|
2639 |
|
---|
2640 | %loop on the projection objects: one or two
|
---|
2641 | for imap=1:numel(IndexObj)
|
---|
2642 | iobj=IndexObj(imap);
|
---|
2643 | ObjectData=proj_field(UvData.Field,UvData.Object{iobj},iobj);% project field on the object
|
---|
2644 |
|
---|
2645 | %use of mask (TODO: check)
|
---|
2646 | if isfield(ObjectData,'NbDim') && isequal(ObjectData.NbDim,2) && isfield(ObjectData,'Mask') && isfield(ObjectData,'A')
|
---|
2647 | flag_mask=double(ObjectData.Mask>200);%=0 for masked regions
|
---|
2648 | AX=ObjectData.AX;%x coordiantes for the scalar field
|
---|
2649 | AY=ObjectData.AY;%y coordinates for the scalar field
|
---|
2650 | MaskX=ObjectData.MaskX;%x coordiantes for the mask
|
---|
2651 | MaskY=ObjectData.MaskY;%y coordiantes for the mask
|
---|
2652 | if ~isequal(MaskX,AX)||~isequal(MaskY,AY)
|
---|
2653 | nxy=size(flag_mask);
|
---|
2654 | sizpx=(ObjectData.MaskX(end)-ObjectData.MaskX(1))/(nxy(2)-1);%size of a mask pixel
|
---|
2655 | sizpy=(ObjectData.MaskY(1)-ObjectData.MaskY(end))/(nxy(1)-1);
|
---|
2656 | x_mask=ObjectData.MaskX(1):sizpx:ObjectData.MaskX(end); % pixel x coordinates for image display
|
---|
2657 | y_mask=ObjectData.MaskY(1):-sizpy:ObjectData.MaskY(end);% pixel x coordinates for image display
|
---|
2658 | %project on the positions of the scalar
|
---|
2659 | npxy=size(ObjectData.A);
|
---|
2660 | dxy(1)=(ObjectData.AY(end)-ObjectData.AY(1))/(npxy(1)-1);%grid mesh in y
|
---|
2661 | dxy(2)=(ObjectData.AX(end)-ObjectData.AX(1))/(npxy(2)-1);%grid mesh in x
|
---|
2662 | xi=ObjectData.AX(1):dxy(2):ObjectData.AX(end);
|
---|
2663 | yi=ObjectData.AY(1):dxy(1):ObjectData.AY(end);
|
---|
2664 | [XI,YI]=meshgrid(xi,yi);% creates the matrix of regular coordinates
|
---|
2665 | flag_mask = interp2(x_mask,y_mask,flag_mask,XI,YI);
|
---|
2666 | end
|
---|
2667 | AClass=class(ObjectData.A);
|
---|
2668 | ObjectData.A=flag_mask.*double(ObjectData.A);
|
---|
2669 | ObjectData.A=feval(AClass,ObjectData.A);
|
---|
2670 | ind_off=[];
|
---|
2671 | if isfield(ObjectData,'ListVarName')
|
---|
2672 | for ilist=1:length(ObjectData.ListVarName)
|
---|
2673 | if isequal(ObjectData.ListVarName{ilist},'Mask')||isequal(ObjectData.ListVarName{ilist},'MaskX')||isequal(ObjectData.ListVarName{ilist},'MaskY')
|
---|
2674 | ind_off=[ind_off ilist];
|
---|
2675 | end
|
---|
2676 | end
|
---|
2677 | ObjectData.ListVarName(ind_off)=[];
|
---|
2678 | ObjectData.VarDimIndex(ind_off)=[];
|
---|
2679 | ind_off=[];
|
---|
2680 | for ilist=1:length(ObjectData.ListDimName)
|
---|
2681 | if isequal(ObjectData.ListDimName{ilist},'MaskX') || isequal(ObjectData.ListDimName{ilist},'MaskY')
|
---|
2682 | ind_off=[ind_off ilist];
|
---|
2683 | end
|
---|
2684 | end
|
---|
2685 | ObjectData.ListDimName(ind_off)=[];
|
---|
2686 | ObjectData.DimValue(ind_off)=[];
|
---|
2687 | end
|
---|
2688 | end
|
---|
2689 |
|
---|
2690 | if ~isempty(ObjectData)
|
---|
2691 | PlotType='none'; %default
|
---|
2692 | if imap==2 && isempty(view_field_handle)
|
---|
2693 | view_field(ObjectData)
|
---|
2694 | else
|
---|
2695 | [PlotType,PlotParamOut]=plot_field(ObjectData,haxes(imap),PlotParam{imap},keeplim(imap),PosColorbar{imap});
|
---|
2696 | write_plot_param(plot_handles{imap},PlotParamOut) %update the auto plot parameters
|
---|
2697 | if imap==1
|
---|
2698 | UvData.ProjField=ObjectData;
|
---|
2699 | else
|
---|
2700 | ViewFieldData=get(view_field_handle,'UserData');
|
---|
2701 | ViewFieldData.ProjField=ObjectData;
|
---|
2702 | set(view_field_handle,'UserData',ViewFieldData)
|
---|
2703 | end
|
---|
2704 | end
|
---|
2705 | if isequal(PlotType,'none')
|
---|
2706 | hget_field=findobj(allchild(0),'name','get_field');
|
---|
2707 | if isempty(hget_field)
|
---|
2708 | get_field([],ObjectData)% the projected field cannot be automatically plotted: use get_field to specify the variablesdelete(hget_field)
|
---|
2709 | else
|
---|
2710 | errormsg='The field defined by get_field cannot be plotted';
|
---|
2711 | return
|
---|
2712 | end
|
---|
2713 | end
|
---|
2714 | end
|
---|
2715 | end
|
---|
2716 |
|
---|
2717 | %write_plot_param(handles,UvData.Object{1}.PlotParam);% update the display of the plotting parameters
|
---|
2718 | UvData.NewSeries=0;% put to 0 the test for a new field series (set by RootPath_callback)
|
---|
2719 | set(handles.uvmat,'UserData',UvData)
|
---|
2720 |
|
---|
2721 | %% update the mask
|
---|
2722 | if isequal(get(handles.mask_test,'Value'),1)%if the mask option is on
|
---|
2723 | update_mask(handles,num_i1,num_i2);
|
---|
2724 | end
|
---|
2725 |
|
---|
2726 | %% prepare the menus of histograms and plot them (histogram of the whole volume in 3D case)
|
---|
2727 | menu_histo=(UvData.Field.ListVarName)';%list of field variables to be displayed for the menu of histogram display
|
---|
2728 | ind_bad=[];
|
---|
2729 | nb_histo=1;
|
---|
2730 |
|
---|
2731 | % suppress coordinates from the histogram menu
|
---|
2732 | for ivar=1:numel(menu_histo)%l loop on field variables:
|
---|
2733 | if isfield(UvData.Field,'VarAttribute') && numel(UvData.Field.VarAttribute)>=ivar && isfield(UvData.Field.VarAttribute{ivar},'Role')
|
---|
2734 | Role=UvData.Field.VarAttribute{ivar}.Role;
|
---|
2735 | switch Role
|
---|
2736 | case {'coord_x','coord_y','coord_z','dimvar'}
|
---|
2737 | ind_bad=[ind_bad ivar];
|
---|
2738 | case {'vector_y'}
|
---|
2739 | nb_histo=nb_histo+1;
|
---|
2740 | end
|
---|
2741 | end
|
---|
2742 | DimCell=UvData.Field.VarDimName{ivar};
|
---|
2743 | DimName='';
|
---|
2744 | if ischar(DimCell)
|
---|
2745 | DimName=DimCell;
|
---|
2746 | elseif iscell(DimCell)&& numel(DimCell)==1
|
---|
2747 | DimName=DimCell{1};
|
---|
2748 | end
|
---|
2749 | if strcmp(DimName,menu_histo{ivar})
|
---|
2750 | ind_bad=[ind_bad ivar];
|
---|
2751 | end
|
---|
2752 | end
|
---|
2753 | menu_histo(ind_bad)=[];
|
---|
2754 |
|
---|
2755 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
---|
2756 | % display menus and plot histograms
|
---|
2757 | test_v=0;
|
---|
2758 | if ~isempty(menu_histo)
|
---|
2759 | set(handles.histo1_menu,'Value',1)
|
---|
2760 | set(handles.histo1_menu,'String',menu_histo)
|
---|
2761 | histo1_menu_Callback(handles.histo1_menu, [], handles)% plot first histogram
|
---|
2762 | % case of more than one variables (eg vector components)
|
---|
2763 | if nb_histo > 1
|
---|
2764 | test_v=1;
|
---|
2765 | set(handles.histo2_menu,'Visible','on')
|
---|
2766 | set(handles.histo_v,'Visible','on')
|
---|
2767 | set(handles.histo2_menu,'String',menu_histo)
|
---|
2768 | set(handles.histo2_menu,'Value',2)
|
---|
2769 | histo2_menu_Callback(handles.histo2_menu,[], handles)% plot second histogram
|
---|
2770 | end
|
---|
2771 | end
|
---|
2772 | if ~test_v
|
---|
2773 | set(handles.histo2_menu,'Visible','off')
|
---|
2774 | set(handles.histo_v,'Visible','off')
|
---|
2775 | cla(handles.histo_v)
|
---|
2776 | set(handles.histo2_menu,'Value',1)
|
---|
2777 | end
|
---|
2778 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
---|
2779 |
|
---|
2780 | %% display time
|
---|
2781 | testimedoc=0;
|
---|
2782 | if isfield(UvData,'XmlData') && isfield(UvData.XmlData,'Time')
|
---|
2783 | if isempty(num_i2)||isnan(num_i2)
|
---|
2784 | num_i2=num_i1;
|
---|
2785 | end
|
---|
2786 | if isempty(num_j1)||isnan(num_j1)
|
---|
2787 | num_j1=1;
|
---|
2788 | end
|
---|
2789 | if isempty(num_j2)||isnan(num_j2)
|
---|
2790 | num_j2=num_j1;
|
---|
2791 | end
|
---|
2792 | siz=size(UvData.XmlData.Time);
|
---|
2793 | if siz(1)>=max(num_i1,num_i2) && siz(2)>=max(num_j1,num_j2)
|
---|
2794 | abstime=(UvData.XmlData.Time(num_i1,num_j1)+UvData.XmlData.Time(num_i2,num_j2))/2;%overset the time read from files
|
---|
2795 | dt=(UvData.XmlData.Time(num_i2,num_j2)-UvData.XmlData.Time(num_i1,num_j1));
|
---|
2796 | testimedoc=1;
|
---|
2797 | end
|
---|
2798 | end
|
---|
2799 | if isfield(UvData,'XmlData_1') && isfield(UvData.XmlData_1,'Time')
|
---|
2800 | [P,F,str1,str2,str_a,str_b,E]=name2display(['xx' get(handles.FileIndex_1,'String') get(handles.FileExt_1,'String')]);
|
---|
2801 | num_i2=str2double(str2);
|
---|
2802 | if isempty(num_i2)
|
---|
2803 | num_i2=num_i1;
|
---|
2804 | end
|
---|
2805 | num_j1=str2double(str_a);
|
---|
2806 | if isempty(num_j1)
|
---|
2807 | num_j1=1;
|
---|
2808 | end
|
---|
2809 | num_j2=str2double(str_b);
|
---|
2810 | if isempty(num_j2)
|
---|
2811 | num_j2=num_j1;
|
---|
2812 | end
|
---|
2813 | num_i1=str2double(str1);
|
---|
2814 | siz=size(UvData.XmlData_1.Time);
|
---|
2815 | if siz(1)>=max(num_i1,num_i2) && siz(2)>=max(num_j1,num_j2)
|
---|
2816 | abstime_1=(UvData.XmlData_1.Time(num_i1,num_j1)+UvData.XmlData_1.Time(num_i2,num_j2))/2;%overset the time read from files
|
---|
2817 | end
|
---|
2818 | end
|
---|
2819 | set(handles.abs_time,'String',num2str(abstime,4))
|
---|
2820 | set(handles.abs_time_1,'String',num2str(abstime_1,4))
|
---|
2821 | if testimedoc && isfield(UvData,'dt')
|
---|
2822 | dt=UvData.dt;
|
---|
2823 | end
|
---|
2824 | if isempty(dt)||isequal(dt,0)
|
---|
2825 | set(handles.Dt_txt,'String','')
|
---|
2826 | else
|
---|
2827 | if ~(isfield(UvData,'TimeUnit') && ~isempty(UvData.TimeUnit))
|
---|
2828 | set(handles.Dt_txt,'String',['Dt=' num2str(1000*dt,3) ' 10^(-3)'] )
|
---|
2829 | else
|
---|
2830 | set(handles.Dt_txt,'String',['Dt=' num2str(1000*dt,3) ' m' UvData.TimeUnit] )
|
---|
2831 | end
|
---|
2832 | end
|
---|
2833 |
|
---|
2834 | %% update the input file name in the get_field GUI
|
---|
2835 | if isequal(FieldName,'get_field...')
|
---|
2836 | set(hhget_field.inputfile,'String',filename)
|
---|
2837 | Tabchar={''};%default
|
---|
2838 | Tabcell=[];
|
---|
2839 | if isfield(Field{1},'ListGlobalAttribute')&& ~isempty(Field{1}.ListGlobalAttribute)
|
---|
2840 | for iline=1:length(Field{1}.ListGlobalAttribute)
|
---|
2841 | Tabcell{iline,1}=Field{1}.ListGlobalAttribute{iline};
|
---|
2842 | if isfield(Field{1}, Field{1}.ListGlobalAttribute{iline})
|
---|
2843 | eval(['val=Field{1}.' Field{1}.ListGlobalAttribute{iline} ';'])
|
---|
2844 | if ischar(val);
|
---|
2845 | Tabcell{iline,2}=val;
|
---|
2846 | else
|
---|
2847 | Tabcell{iline,2}=num2str(val);
|
---|
2848 | end
|
---|
2849 | end
|
---|
2850 | end
|
---|
2851 | if ~isempty(Tabcell)
|
---|
2852 | Tabchar=cell2tab(Tabcell,'=');
|
---|
2853 | Tabchar=[{''};Tabchar];
|
---|
2854 | end
|
---|
2855 | end
|
---|
2856 | set(hhget_field.attributes,'String',Tabchar);%update list of global attributes in get_field
|
---|
2857 | end
|
---|
2858 | if isequal(FieldName_1,'get_field...')
|
---|
2859 | set(hhget_field_1.inputfile,'String',filename_1)
|
---|
2860 | Tabchar={''};%default
|
---|
2861 | Tabcell=[];
|
---|
2862 | if isfield(Field{2},'ListGlobalAttribute')&& ~isempty(Field{2}.ListGlobalAttribute)
|
---|
2863 | for iline=1:length(Field{2}.ListGlobalAttribute)
|
---|
2864 | Tabcell{iline,1}=Field{2}.ListGlobalAttribute{iline};
|
---|
2865 | if isfield(Field{2}, Field{2}.ListGlobalAttribute{iline})
|
---|
2866 | eval(['val=Field{2}.' Field{2}.ListGlobalAttribute{iline} ';'])
|
---|
2867 | if ischar(val);
|
---|
2868 | Tabcell{iline,2}=val;
|
---|
2869 | else
|
---|
2870 | Tabcell{iline,2}=num2str(val);
|
---|
2871 | end
|
---|
2872 | end
|
---|
2873 | end
|
---|
2874 | if ~isempty(Tabcell)
|
---|
2875 | Tabchar=cell2tab(Tabcell,'=');
|
---|
2876 | Tabchar=[{''};Tabchar];
|
---|
2877 | end
|
---|
2878 | end
|
---|
2879 | set(hhget_field_1.attributes,'String',Tabchar);%update list of global attributes in get_field
|
---|
2880 | end
|
---|
2881 |
|
---|
2882 |
|
---|
2883 | %-------------------------------------------------------------------
|
---|
2884 | % --- translate coordinate to matrix index
|
---|
2885 | %-------------------------------------------------------------------
|
---|
2886 | function [indx,indy]=pos2ind(x0,rangx0,nxy)
|
---|
2887 | indx=1+round((nxy(2)-1)*(x0-rangx0(1))/(rangx0(2)-rangx0(1)));% index x of pixel
|
---|
2888 | indy=1+round((nxy(1)-1)*(y12-rangy0(1))/(rangy0(2)-rangy0(1)));% index y of pixel
|
---|
2889 |
|
---|
2890 | %-------------------------------------------------------------------
|
---|
2891 | % --- Executes on button press in 'FixedLimits'.
|
---|
2892 | %-------------------------------------------------------------------
|
---|
2893 | function FixedLimits_Callback(hObject, eventdata, handles)
|
---|
2894 | test=get(handles.FixedLimits,'Value');
|
---|
2895 | if test
|
---|
2896 | set(handles.FixedLimits,'BackgroundColor',[1 1 0])
|
---|
2897 | else
|
---|
2898 | set(handles.FixedLimits,'BackgroundColor',[0.7 0.7 0.7])
|
---|
2899 | update_plot(handles);
|
---|
2900 | end
|
---|
2901 |
|
---|
2902 | %-------------------------------------------------------------------
|
---|
2903 | % --- Executes on button press in auto_xy.
|
---|
2904 | function auto_xy_Callback(hObject, eventdata, handles)
|
---|
2905 | test=get(handles.auto_xy,'Value');
|
---|
2906 | if test
|
---|
2907 | set(handles.auto_xy,'BackgroundColor',[1 1 0])
|
---|
2908 | cla(handles.axes3)
|
---|
2909 | update_plot(handles);
|
---|
2910 | else
|
---|
2911 | set(handles.auto_xy,'BackgroundColor',[0.7 0.7 0.7])
|
---|
2912 | update_plot(handles);
|
---|
2913 | % axis(handles.axes3,'image')
|
---|
2914 | end
|
---|
2915 |
|
---|
2916 |
|
---|
2917 | %-------------------------------------------------------------------
|
---|
2918 |
|
---|
2919 | %-------------------------------------------------------------------
|
---|
2920 | % --- Executes on button press in 'zoom'.
|
---|
2921 | %-------------------------------------------------------------------
|
---|
2922 | function zoom_Callback(hObject, eventdata, handles)
|
---|
2923 |
|
---|
2924 | if (get(handles.zoom,'Value') == 1);
|
---|
2925 | set(handles.zoom,'BackgroundColor',[1 1 0])
|
---|
2926 | set(handles.FixedLimits,'Value',1)% propose by default fixed limits for the plotting axes
|
---|
2927 | set(handles.FixedLimits,'BackgroundColor',[1 1 0])
|
---|
2928 | else
|
---|
2929 | set(handles.zoom,'BackgroundColor',[0.7 0.7 0.7])
|
---|
2930 | end
|
---|
2931 |
|
---|
2932 |
|
---|
2933 | %-------------------------------------------------------------------
|
---|
2934 | %----Executes on button press in 'record': records the current flags of manual correction.
|
---|
2935 | %-------------------------------------------------------------------
|
---|
2936 | function record_Callback(hObject, eventdata, handles)
|
---|
2937 | % [filebase,num_i1,num_j1,num_i2,num_j2,Ext,NomType,SubDir]=read_input_file(handles);
|
---|
2938 | filename=read_file_boxes(handles);
|
---|
2939 | AxeData=get(gca,'UserData');
|
---|
2940 | [erread,message]=fileattrib(filename);
|
---|
2941 | if ~isempty(message) && ~isequal(message.UserWrite,1)
|
---|
2942 | msgbox_uvmat('ERROR',['no writting access to ' filename])
|
---|
2943 | return
|
---|
2944 | end
|
---|
2945 | test_civ2=isequal(get(handles.civ2,'BackgroundColor'),[1 1 0]);
|
---|
2946 | test_civ1=isequal(get(handles.civ1,'BackgroundColor'),[1 1 0]);
|
---|
2947 | if ~test_civ2 && ~test_civ1
|
---|
2948 | msgbox_uvmat('ERROR','manual correction only possible for CIV1 or CIV2 velocity fields')
|
---|
2949 | end
|
---|
2950 | if test_civ2
|
---|
2951 | nbname='nb_vectors2';
|
---|
2952 | flagname='vec2_FixFlag';
|
---|
2953 | attrname='fix2';
|
---|
2954 | end
|
---|
2955 | if test_civ1
|
---|
2956 | nbname='nb_vectors';
|
---|
2957 | flagname='vec_FixFlag';
|
---|
2958 | attrname='fix';
|
---|
2959 | end
|
---|
2960 | %write fix flags in the netcdf file
|
---|
2961 | hhh=which('netcdf.open');% look for built-in matlab netcdf library
|
---|
2962 | if ~isequal(hhh,'')% case of new builtin Matlab netcdf library
|
---|
2963 | nc=netcdf.open(filename,'NC_WRITE');
|
---|
2964 | netcdf.reDef(nc)
|
---|
2965 | netcdf.putAtt(nc,netcdf.getConstant('NC_GLOBAL'),attrname,1)
|
---|
2966 | dimid = netcdf.inqDimID(nc,nbname);
|
---|
2967 | try
|
---|
2968 | varid = netcdf.inqVarID(nc,flagname);% look for already existing fixflag variable
|
---|
2969 | catch
|
---|
2970 | varid=netcdf.defVar(nc,flagname,'double',dimid);%create fixflag variable if it does not exist
|
---|
2971 | end
|
---|
2972 | netcdf.endDef(nc)
|
---|
2973 | netcdf.putVar(nc,varid,AxeData.FF);
|
---|
2974 | netcdf.close(nc)
|
---|
2975 | else %old netcdf library
|
---|
2976 | netcdf_toolbox(filename,AxeData,attrname,nbname,flagname)
|
---|
2977 | end
|
---|
2978 |
|
---|
2979 | function netcdf_toolbox(filename,AxeData,attrname,nbname,flagname)
|
---|
2980 | nc=netcdf(filename,'write'); %open netcdf file
|
---|
2981 | result=redef(nc);
|
---|
2982 | eval(['nc.' attrname '=1;']);
|
---|
2983 | theDim=nc(nbname) ;% get the number of velocity vectors
|
---|
2984 | nb_vectors=size(theDim);
|
---|
2985 | var_FixFlag=ncvar(flagname,nc);% var_FixFlag will be written as the netcdf variable vec_FixFlag
|
---|
2986 | var_FixFlag(1:nb_vectors)=AxeData.FF;%
|
---|
2987 | fin=close(nc);
|
---|
2988 |
|
---|
2989 |
|
---|
2990 | %-------------------------------------------------------------------
|
---|
2991 | %determines the fields to read from the interface
|
---|
2992 | %------------------------------------------------------------------
|
---|
2993 | function [VelType,civ]=setfield(handles)
|
---|
2994 |
|
---|
2995 | VelType=[]; %default
|
---|
2996 | if (get(handles.civ1,'Value') == 1);
|
---|
2997 | VelType='civ1';
|
---|
2998 | % interp1
|
---|
2999 | elseif (get(handles.interp1,'Value') == 1);
|
---|
3000 | VelType='interp1';
|
---|
3001 | % filter1
|
---|
3002 | elseif (get(handles.filter1,'Value') == 1);
|
---|
3003 | VelType='filter1';
|
---|
3004 | % CIV2
|
---|
3005 | elseif (get(handles.civ2,'Value') == 1);
|
---|
3006 | VelType='civ2';
|
---|
3007 | % interp2
|
---|
3008 | elseif (get(handles.interp2,'Value') == 1);
|
---|
3009 | VelType='interp2';
|
---|
3010 | % filter2
|
---|
3011 | elseif (get(handles.filter2,'Value') == 1);
|
---|
3012 | VelType='filter2';
|
---|
3013 | end
|
---|
3014 |
|
---|
3015 | if isequal(get(handles.filter2,'Visible'),'on');
|
---|
3016 | civ=6;
|
---|
3017 | % interp1
|
---|
3018 | elseif isequal(get(handles.interp2,'Visible'),'on');
|
---|
3019 | civ=5;
|
---|
3020 | % filter1
|
---|
3021 | elseif isequal(get(handles.civ2,'Visible'),'on');
|
---|
3022 | civ=4;
|
---|
3023 | % CIV2
|
---|
3024 | elseif isequal(get(handles.filter1,'Visible'),'on');
|
---|
3025 | civ=3;
|
---|
3026 | % interp2
|
---|
3027 | elseif isequal(get(handles.interp1,'Visible'),'on');
|
---|
3028 | civ=2;
|
---|
3029 | % filter2
|
---|
3030 | elseif isequal(get(handles.civ1,'Visible'),'on');
|
---|
3031 | civ=1;
|
---|
3032 | else
|
---|
3033 | civ=0;
|
---|
3034 | end
|
---|
3035 |
|
---|
3036 | %-------------------------------------------------------------------
|
---|
3037 | %determines the veltype of the second field to read from the iinterface
|
---|
3038 | %------------------------------------------------------------------
|
---|
3039 | function VelType=setfield_1(handles)
|
---|
3040 |
|
---|
3041 | VelType=[]; %default
|
---|
3042 | if (get(handles.civ1_1,'Value') == 1);
|
---|
3043 | VelType='civ1';
|
---|
3044 | % interp1
|
---|
3045 | elseif (get(handles.interp1_1,'Value') == 1);
|
---|
3046 | VelType='interp1';
|
---|
3047 | % filter1
|
---|
3048 | elseif (get(handles.filter1_1,'Value') == 1);
|
---|
3049 | VelType='filter1';
|
---|
3050 | % CIV2
|
---|
3051 | elseif (get(handles.civ2_1,'Value') == 1);
|
---|
3052 | VelType='civ2';
|
---|
3053 | % interp2
|
---|
3054 | elseif (get(handles.interp2_1,'Value') == 1);
|
---|
3055 | VelType='interp2';
|
---|
3056 | % filter2
|
---|
3057 | elseif (get(handles.filter2_1,'Value') == 1);
|
---|
3058 | VelType='filter2';
|
---|
3059 | end
|
---|
3060 |
|
---|
3061 |
|
---|
3062 | %---------------------------------------------------
|
---|
3063 | % --- Executes on button press in SubField
|
---|
3064 | function SubField_Callback(hObject, eventdata, handles)
|
---|
3065 | huvmat=get(handles.run0,'parent');
|
---|
3066 | UvData=get(huvmat,'UserData');
|
---|
3067 | if get(handles.SubField,'Value')==0% if the subfield button is desactivated
|
---|
3068 | set(handles.RootPath_1,'String','')
|
---|
3069 | set(handles.RootFile_1,'String','')
|
---|
3070 | set(handles.SubDir_1,'String','');
|
---|
3071 | set(handles.FileIndex_1,'String','');
|
---|
3072 | set(handles.FileExt_1,'String','');
|
---|
3073 | set(handles.RootPath_1,'Visible','off')
|
---|
3074 | set(handles.RootFile_1,'Visible','off')
|
---|
3075 | set(handles.SubDir_1,'Visible','off');
|
---|
3076 | set(handles.FileIndex_1,'Visible','off');
|
---|
3077 | set(handles.FileExt_1,'Visible','off');
|
---|
3078 | set(handles.Fields_1,'Value',1);%set to blank state
|
---|
3079 | set_veltype_display([handles.civ1_1 handles.interp1_1 handles.filter1_1 ...
|
---|
3080 | handles.civ2_1 handles.interp2_1 handles.filter2_1],0)
|
---|
3081 | if isfield(UvData,'XmlData_1')
|
---|
3082 | UvData=rmfield(UvData,'XmlData_1');
|
---|
3083 | end
|
---|
3084 | set(huvmat,'UserData',UvData);
|
---|
3085 | run0_Callback(hObject, eventdata, handles); %run
|
---|
3086 | else
|
---|
3087 | MenuBrowse_1_Callback(hObject, eventdata, handles)
|
---|
3088 | end
|
---|
3089 |
|
---|
3090 | %------------------------------------------------------------------------
|
---|
3091 | % --- read the data displayed for the input rootfile windows (new)
|
---|
3092 | function [FileName,RootPath,FileBase,FileIndices,FileExt,SubDir]=read_file_boxes(handles)
|
---|
3093 | %------------------------------------------------------------------------
|
---|
3094 | RootPath=get(handles.RootPath,'String');
|
---|
3095 | FileName=RootPath; %default
|
---|
3096 | SubDir=get(handles.SubDir,'String');
|
---|
3097 | if ~isempty(SubDir) && ~isequal(SubDir,'')
|
---|
3098 | if (isequal(SubDir(1),'/')|| isequal(SubDir(1),'\'))
|
---|
3099 | SubDir(1)=[]; %suppress possible / or \ separator
|
---|
3100 | end
|
---|
3101 | FileName=fullfile(RootPath,SubDir);
|
---|
3102 | end
|
---|
3103 | RootFile=get(handles.RootFile,'String');
|
---|
3104 | if ~isempty(RootFile) && ~isequal(RootFile,'')
|
---|
3105 | if (isequal(RootFile(1),'/')|| isequal(RootFile(1),'\'))
|
---|
3106 | RootFile(1)=[]; %suppress possible / or \ separator
|
---|
3107 | end
|
---|
3108 | FileName=fullfile(FileName,RootFile);
|
---|
3109 | end
|
---|
3110 | FileBase=fullfile(RootPath,RootFile);
|
---|
3111 | FileIndices=get(handles.FileIndex,'String');
|
---|
3112 | FileExt=get(handles.FileExt,'String');
|
---|
3113 | FileName=[FileName FileIndices FileExt];
|
---|
3114 |
|
---|
3115 | %------------------------------------------------------------------------
|
---|
3116 | % ---- read the data displayed for the second input rootfile windows
|
---|
3117 | function [FileName_1,RootPath_1,FileBase_1,FileIndices_1,FileExt_1,SubDir_1]=read_file_boxes_1(handles)
|
---|
3118 | %------------------------------------------------------------------------
|
---|
3119 | RootPath_1=get(handles.RootPath_1,'String'); % read the data from the file1_input window
|
---|
3120 | if isequal(get(handles.RootPath_1,'Visible'),'off') || isequal(RootPath_1,'"')
|
---|
3121 | RootPath_1=get(handles.RootPath,'String');
|
---|
3122 | end;
|
---|
3123 | FileName_1=RootPath_1; %default
|
---|
3124 | SubDir_1=get(handles.SubDir_1,'String');
|
---|
3125 | if isequal(get(handles.SubDir_1,'Visible'),'off')|| isequal(SubDir_1,'"')
|
---|
3126 | SubDir_1=get(handles.SubDir,'String');
|
---|
3127 | end
|
---|
3128 | if numel(SubDir_1)>=1
|
---|
3129 | if (isequal(SubDir_1(1),'/')|| isequal(SubDir_1(1),'\'))
|
---|
3130 | SubDir_1(1)=[]; %suppress possible / or \ separator
|
---|
3131 | end
|
---|
3132 | FileName_1=fullfile(RootPath_1,SubDir_1);
|
---|
3133 | end
|
---|
3134 | RootFile_1=get(handles.RootFile_1,'String');
|
---|
3135 | if isequal(get(handles.RootFile_1,'Visible'),'off') || isequal(RootFile_1,'"')
|
---|
3136 | RootFile_1=get(handles.RootFile,'String');
|
---|
3137 | end
|
---|
3138 | if numel(RootFile_1)>=1
|
---|
3139 | if ~(isequal(RootFile_1(1),'/')|isequal(RootFile_1(1),'\'))
|
---|
3140 | RootFile_1(1)=[];%suppress possible / or \ separator
|
---|
3141 | end
|
---|
3142 | FileName_1=fullfile(FileName_1,RootFile_1);
|
---|
3143 | end
|
---|
3144 | FileBase_1=fullfile(RootPath_1,RootFile_1);
|
---|
3145 | if isequal(get(handles.FileIndex_1,'Visible'),'off')
|
---|
3146 | FileIndices_1=get(handles.FileIndex,'String');
|
---|
3147 | else
|
---|
3148 | FileIndices_1=get(handles.FileIndex_1,'String');
|
---|
3149 | end
|
---|
3150 | FileExt_1=get(handles.FileExt_1,'String');
|
---|
3151 | if isequal(FileExt_1,'"'),FileExt_1=get(handles.FileExt,'String'); end;
|
---|
3152 | FileName_1=[FileName_1 FileIndices_1 FileExt_1];
|
---|
3153 |
|
---|
3154 | %------------------------------------------------------------------------
|
---|
3155 | % --- Executes on menu selection Fields
|
---|
3156 | function Fields_Callback(hObject, eventdata, handles)
|
---|
3157 | %------------------------------------------------------------------------
|
---|
3158 | list_fields=get(handles.Fields,'String');% list menu fields
|
---|
3159 | index_fields=get(handles.Fields,'Value');% selected string index
|
---|
3160 | field= list_fields{index_fields(1)}; % selected string
|
---|
3161 | if isequal(field,'get_field...')
|
---|
3162 | veltype_handles=[handles.civ1 handles.interp1 handles.filter1 handles.civ2 handles.interp2 handles.filter2];
|
---|
3163 | set_veltype_display(veltype_handles,0) % unvisible civ buttons
|
---|
3164 | filename=read_file_boxes(handles);
|
---|
3165 | hget_field=findobj(allchild(0),'name','uvmat_field');
|
---|
3166 | if isempty(hget_field)
|
---|
3167 | hget_field=get_field(filename);
|
---|
3168 | set(hget_field,'Name','uvmat_field')
|
---|
3169 | end
|
---|
3170 | return %no action
|
---|
3171 | end
|
---|
3172 | list_fields=get(handles.Fields_1,'String');% list menu fields
|
---|
3173 | index_fields=get(handles.Fields_1,'Value');% selected string index
|
---|
3174 | field_1= list_fields{index_fields(1)}; % selected string
|
---|
3175 | UvData=get(handles.uvmat,'UserData');
|
---|
3176 |
|
---|
3177 | %read the rootfile input display
|
---|
3178 | [FileName,RootPath,FileBase,FileIndices,FileExt]=read_file_boxes(handles);
|
---|
3179 | [P,F,str1,str2,str_a,str_b,E,NomType]=name2display(['xxx' get(handles.FileIndex,'String') FileExt]);
|
---|
3180 | NomTypeNew=NomType;%default
|
---|
3181 | if isequal(field,'image')
|
---|
3182 | % transform netc type to the corresponding image type
|
---|
3183 | % if isequal(NomType,'_i1-i2_j')||isequal(NomType,'_i_j1-j2')|| isequal(NomType,'#_ab')|| isequal(NomType,'_i1-i2')
|
---|
3184 | % UvData.SubDir=get(handles.SubDir,'String'); %preserve the subdir in memory
|
---|
3185 | % if ~isempty(UvData.SubDir) && (isequal(UvData.SubDir(1),'/')||isequal(UvData.SubDir(1),'/'))
|
---|
3186 | % UvData.SubDir(1)=[];
|
---|
3187 | % end
|
---|
3188 | % set(handles.SubDir,'String','')
|
---|
3189 | % set(handles.FileExt,'String','.png');
|
---|
3190 | if isequal(NomType,'_i1-i2_j')||isequal(NomType,'_i_j1-j2')
|
---|
3191 | NomTypeNew='_i_j';
|
---|
3192 | elseif isequal(NomType,'#_ab')
|
---|
3193 | NomTypeNew='#a';
|
---|
3194 | elseif isequal(NomType,'_i1-i2')
|
---|
3195 | NomTypeNew='_i';
|
---|
3196 | end
|
---|
3197 | imagename=name_generator(FileBase,str2double(str1),str2double(str_a),'.png',NomTypeNew,1,str2double(str2),str2double(str_b),'');
|
---|
3198 | if ~exist(imagename,'file')
|
---|
3199 | [FileName,PathName] = uigetfile( ...
|
---|
3200 | {'*.png;*.jpg;*.tif;*.avi;*.AVI;*.vol', ' (*.png, .tif, *.avi,*.vol)';
|
---|
3201 | '*.jpg',' jpeg image files'; ...
|
---|
3202 | '*.png','.png image files'; ...
|
---|
3203 | '*.tif','.tif image files'; ...
|
---|
3204 | '*.avi;*.AVI','.avi movie files'; ...
|
---|
3205 | '*.vol','.volume images (png)'; ...
|
---|
3206 | '*.*', 'All Files (*.*)'}, ...
|
---|
3207 | 'Pick an image',imagename);
|
---|
3208 | % display the selected field and related information
|
---|
3209 | imagename=[PathName FileName];
|
---|
3210 | end
|
---|
3211 | display_file_name(hObject, eventdata, handles,imagename)%display the image
|
---|
3212 | return
|
---|
3213 | % end
|
---|
3214 | % veltype_handles=[handles.civ1 handles.interp1 handles.filter1 handles.civ2 handles.interp2 handles.filter2];
|
---|
3215 | % set_veltype_display(veltype_handles,0) % unvisible civ buttons
|
---|
3216 | else
|
---|
3217 | ext=get(handles.FileExt,'String');
|
---|
3218 | if ~isequal(ext,'.nc') %find the new NomType if the previous display was not already a netcdf file
|
---|
3219 | [FileName,PathName] = uigetfile( ...
|
---|
3220 | {'*.nc', ' (*.nc)';
|
---|
3221 | '*.nc',' netcdf files'; ...
|
---|
3222 | '*.*', 'All Files (*.*)'}, ...
|
---|
3223 | 'Pick a netcdf file',FileBase);
|
---|
3224 | % display the selected field and related information
|
---|
3225 | filename=[PathName FileName];
|
---|
3226 | display_file_name(hObject, eventdata, handles,filename)
|
---|
3227 | return
|
---|
3228 | % MenuBrowse_Callback(hObject, eventdata, handles)
|
---|
3229 | end
|
---|
3230 | if isequal(field,'vort') || isequal(field,'div') || isequal(field,'strain')
|
---|
3231 | set(handles.civ1,'BackgroundColor',[0.702 0.702 0.702]) % put their color to grey
|
---|
3232 | set(handles.civ2,'BackgroundColor',[0.702 0.702 0.702])
|
---|
3233 | set(handles.interp1,'BackgroundColor',[0.702 0.702 0.702])
|
---|
3234 | set(handles.interp2,'BackgroundColor',[0.702 0.702 0.702])
|
---|
3235 | elseif isequal(field,'more...');
|
---|
3236 | set(handles.civ1,'BackgroundColor',[0.702 0.702 0.702]) % put their color to grey
|
---|
3237 | set(handles.civ2,'BackgroundColor',[0.702 0.702 0.702])
|
---|
3238 | str=calc_field;%get the list of available scalars by the function calc_scal
|
---|
3239 | [ind_answer] = listdlg('PromptString','Select a file:',...
|
---|
3240 | 'SelectionMode','single',...
|
---|
3241 | 'ListString',str);
|
---|
3242 | % edit the choice in the field and action menu
|
---|
3243 | scalar=cell2mat(str(ind_answer));
|
---|
3244 | menu=update_menu(handles.Fields,scalar);
|
---|
3245 | menu=[{''};menu];
|
---|
3246 | set(handles.Fields_1,'String',menu);% store the selected scalar type
|
---|
3247 | end
|
---|
3248 | end
|
---|
3249 | indices=name_generator('',str2double(str1),str2double(str_a),'',NomTypeNew,1,str2double(str2),str2double(str_b),'');
|
---|
3250 | set(handles.FileIndex,'String',indices)
|
---|
3251 | set(handles.FileIndex,'UserData',NomTypeNew)
|
---|
3252 | %common to Fields_1_Callback
|
---|
3253 | if isequal(field,'image')||isequal(field_1,'image')
|
---|
3254 | set(handles.npx_title,'Visible','on')% visible npx,pxcm... buttons
|
---|
3255 | set(handles.npy_title,'Visible','on')
|
---|
3256 | set(handles.npx,'Visible','on')
|
---|
3257 | set(handles.npy,'Visible','on')
|
---|
3258 | else
|
---|
3259 | set(handles.npx_title,'Visible','off')% visible npx,pxcm... buttons
|
---|
3260 | set(handles.npy_title,'Visible','off')
|
---|
3261 | set(handles.npx,'Visible','off')
|
---|
3262 | set(handles.npy,'Visible','off')
|
---|
3263 | end
|
---|
3264 | setfield(handles);% update the field structure ('civ1'....)
|
---|
3265 |
|
---|
3266 | if ~isfield(UvData,'NewSeries')||isequal(UvData.NewSeries,0)
|
---|
3267 | run0_Callback(hObject, eventdata, handles)
|
---|
3268 | end
|
---|
3269 |
|
---|
3270 | %---------------------------------------------------
|
---|
3271 | % --- Executes on menu selection Fields
|
---|
3272 | function Fields_1_Callback(hObject, eventdata, handles)
|
---|
3273 | %-------------------------------------------------
|
---|
3274 | list_fields=get(handles.Fields,'String');% list menu fields
|
---|
3275 | index_fields=get(handles.Fields,'Value');% selected string index
|
---|
3276 | field= list_fields{index_fields(1)}; % selected string
|
---|
3277 | list_fields=get(handles.Fields_1,'String');% list menu fields
|
---|
3278 | index_fields=get(handles.Fields_1,'Value');% selected string index
|
---|
3279 | field_1= list_fields{index_fields(1)}; % selected string for the second field
|
---|
3280 | if isequal(field_1,'') %remove second field if 'blank' field is selected
|
---|
3281 | set(handles.SubField,'Value',0)
|
---|
3282 | SubField_Callback(hObject, eventdata, handles)
|
---|
3283 | return
|
---|
3284 | end
|
---|
3285 | UvData=get(handles.uvmat,'UserData');
|
---|
3286 |
|
---|
3287 | %read the rootfile input display
|
---|
3288 | [FileName,RootPath,FileBase,FileIndices,FileExt_prev]=read_file_boxes_1(handles);
|
---|
3289 | [P,F,str1,str2,str_a,str_b,E,NomType]=name2display(['xxx' get(handles.FileIndex,'String') FileExt_prev]);
|
---|
3290 | if isempty(FileExt_prev)|isequal(FileExt_prev,'')
|
---|
3291 | FileExt_1=get(handles.FileExt,'String');
|
---|
3292 | else
|
---|
3293 | FileExt_1=FileExt_prev;
|
---|
3294 | end
|
---|
3295 | NomType_1=get(handles.FileIndex_1,'UserData');
|
---|
3296 | if isempty(NomType_1)|isequal(NomType_1,'')
|
---|
3297 | NomType_1=get(handles.FileIndex,'UserData');
|
---|
3298 | end
|
---|
3299 | NomTypeNew=NomType_1;%default
|
---|
3300 |
|
---|
3301 | set(handles.SubField,'Value',1)%introduce second field
|
---|
3302 | if isfield(UvData,'XmlData')
|
---|
3303 | UvData.XmlData_1=UvData.XmlData;
|
---|
3304 | end
|
---|
3305 | set(handles.FileIndex_1,'Visible','on')
|
---|
3306 | set(handles.FileExt_1,'Visible','on')
|
---|
3307 | RootPath_1=get(handles.RootPath_1,'String');
|
---|
3308 | RootFile_1=get(handles.RootFile_1,'String');
|
---|
3309 | if isempty(RootPath_1)||isequal(RootPath_1,'')
|
---|
3310 | set(handles.RootPath_1,'String','"')
|
---|
3311 | end
|
---|
3312 | if isempty(RootFile_1) || isequal(RootFile_1,'')
|
---|
3313 | set(handles.RootFile_1,'String','"')
|
---|
3314 | end
|
---|
3315 | if ~isempty(RootFile_1)&&(isequal(RootFile_1(1),'/')||isequal(RootFile_1(1),'\'))
|
---|
3316 | RootFile_1(1)=[];
|
---|
3317 | end
|
---|
3318 |
|
---|
3319 | if isequal(field_1,'get_field...')
|
---|
3320 | veltype_handles=[handles.civ1 handles.interp1 handles.filter1 handles.civ2 handles.interp2 handles.filter2];
|
---|
3321 | set_veltype_display(veltype_handles,0) % unvisible civ buttons
|
---|
3322 | filename=read_file_boxes_1(handles);
|
---|
3323 | hget_field=findobj(allchild(0),'name','get_field_1');
|
---|
3324 | if ~isempty(hget_field)
|
---|
3325 | delete(hget_field)
|
---|
3326 | end
|
---|
3327 | hget_field=get_field(filename);
|
---|
3328 | set(hget_field,'name','get_field_1')
|
---|
3329 | return %no action
|
---|
3330 | end
|
---|
3331 | if isequal(field_1,'image')
|
---|
3332 | % transform netc type to the corresponding image type
|
---|
3333 | % set(handles.FileExt_1,'String','.png');
|
---|
3334 | if isequal(NomType_1,'_i1-i2_j')|isequal(NomType_1,'_i_j1-j2')| isequal(NomType_1,'#_ab')| isequal(NomType_1,'_i1-i2')
|
---|
3335 | UvData.SubDir_1=get(handles.SubDir_1,'String'); %preserve the subdir in memory
|
---|
3336 | % set(handles.SubDir_1,'String','')
|
---|
3337 | % set(handles.FileExt_1,'String','.png');
|
---|
3338 | if isequal(NomType_1,'_i1-i2_j')|isequal(NomType_1,'_i_j1-j2')
|
---|
3339 | NomTypeNew='_i_j';
|
---|
3340 | elseif isequal(NomType_1,'#_ab')
|
---|
3341 | NomTypeNew='#a';
|
---|
3342 | elseif isequal(NomType_1,'_i1-i2')
|
---|
3343 | NomTypeNew='_i';
|
---|
3344 | end
|
---|
3345 | end
|
---|
3346 | imagename=name_generator(FileBase,str2double(str1),str2double(str_a),'.png',NomTypeNew,1,str2double(str2),str2double(str_b),'');
|
---|
3347 | if ~exist(imagename,'file')
|
---|
3348 | [FileName,PathName] = uigetfile( ...
|
---|
3349 | {'*.png;*.jpg;*.tif;*.avi;*.AVI;*.vol', ' (*.png, .tif, *.avi,*.vol)';
|
---|
3350 | '*.jpg',' jpeg image files'; ...
|
---|
3351 | '*.png','.png image files'; ...
|
---|
3352 | '*.tif','.tif image files'; ...
|
---|
3353 | '*.avi;*.AVI','.avi movie files'; ...
|
---|
3354 | '*.vol','.volume images (png)'; ...
|
---|
3355 | '*.*', 'All Files (*.*)'}, ...
|
---|
3356 | 'Pick an image',imagename);
|
---|
3357 | % display the selected field and related information
|
---|
3358 | imagename=[PathName FileName];
|
---|
3359 | end
|
---|
3360 | display_file_name_1(hObject, eventdata, handles,imagename)%display the image
|
---|
3361 | return
|
---|
3362 | % veltype_handles=[handles.civ1_1 handles.interp1_1 handles.filter1_1 handles.civ2_1 handles.interp2_1 handles.filter2_1];
|
---|
3363 | % set_veltype_display(veltype_handles,0) % unvisible civ buttons
|
---|
3364 | else
|
---|
3365 | set(handles.SubDir_1,'Visible','on')
|
---|
3366 | if ~isequal(FileExt_prev,'.nc') %find the new NomType if the previous display was not already a netcdf file
|
---|
3367 | veltype_handles=[handles.civ1_1 handles.interp1_1 handles.filter1_1 handles.civ2_1 handles.interp2_1 handles.filter2_1];
|
---|
3368 | set_veltype_display(veltype_handles,6); % make all civ buttons visible
|
---|
3369 | RootPath_1=get(handles.RootPath_1,'String');
|
---|
3370 | RootFile_1=get(handles.RootFile_1,'String');
|
---|
3371 | if isempty(RootPath_1)|isequal(RootPath_1,'')
|
---|
3372 | set(handles.RootPath_1,'String','"')
|
---|
3373 | end
|
---|
3374 | if isempty(RootFile_1) | isequal(RootFile_1,'')
|
---|
3375 | set(handles.RootFile_1,'String','"')
|
---|
3376 | end
|
---|
3377 | if ~isempty(RootFile_1)&(isequal(RootFile_1(1),'/')|isequal(RootFile_1(1),'\'))
|
---|
3378 | RootFile_1(1)=[];
|
---|
3379 | end
|
---|
3380 | filebase_1=fullfile(RootPath_1,RootFile_1);
|
---|
3381 | SubDir_1=get(handles.SubDir,'String');
|
---|
3382 | if isempty(SubDir_1)||isequal(SubDir_1,'')
|
---|
3383 | if isfield(UvData,'SubDir_1')
|
---|
3384 | SubDir_1=UvData.SubDir_1;%retrieve previous subdir
|
---|
3385 | else
|
---|
3386 | SubDir_1='?';
|
---|
3387 | end
|
---|
3388 | end
|
---|
3389 | str1=get(handles.i1,'String');
|
---|
3390 | str_a=get(handles.j1,'String');
|
---|
3391 | if isequal(NomType_1,'#_ab')||isequal(NomType_1,'_i1-i2_j')||isequal(NomType_1,'_i_j1-j2')||isequal(NomType_1,'_i1-i2')
|
---|
3392 | NomTypeNew=NomType_1;
|
---|
3393 | elseif isequal(NomType_1,'#a')
|
---|
3394 | [filename, n1,na,n2,nb,SubDir_1]=name_generator(filebase_1, str2num(str1),stra2num(str_a),'.nc','#_ab',0,[],[],SubDir_1);
|
---|
3395 | NomTypeNew='#_ab';
|
---|
3396 | elseif isequal(NomType_1,'_i_j')
|
---|
3397 | [filename,n1,na,n2,nb,SubDir_1]=name_generator(filebase_1,str2num(str1),stra2num(str_a),'.nc','_i1-i2_j',0,str2num(str1),[],SubDir_1);
|
---|
3398 | if idetect==1
|
---|
3399 | NomTypeNew='_i1-i2_j';
|
---|
3400 | else
|
---|
3401 | NomTypeNew='_i_j1-j2';
|
---|
3402 | end
|
---|
3403 | else %for instance avi files or any ima_num series
|
---|
3404 | [filename,n1,na,n2,nb,SubDir_1]=name_generator(filebase_1,str2num(str1),stra2num(str_a),'.nc','_i1-i2',0,str2num(str1),[],SubDir_1);
|
---|
3405 | NomTypeNew='_i1-i2';
|
---|
3406 | end
|
---|
3407 | [Path,Name]=fileparts(filebase_1);
|
---|
3408 | set(handles.FileExt_1,'String','.nc');
|
---|
3409 | if ~isempty(SubDir_1) && ~strcmp(SubDir_1,'''')&& ~strcmp(SubDir_1,'"')&& ~strcmp(SubDir_1(1),'/')
|
---|
3410 | SubDir_1=['/' SubDir_1];
|
---|
3411 | end
|
---|
3412 | set(handles.SubDir_1,'String',SubDir_1);
|
---|
3413 | end
|
---|
3414 | if isequal(field,'vort') | isequal(field,'div') | isequal(field,'strain')
|
---|
3415 | set(handles.civ1_1,'BackgroundColor',[0.702 0.702 0.702]) % put their color to grey
|
---|
3416 | set(handles.civ2_1,'BackgroundColor',[0.702 0.702 0.702])
|
---|
3417 | set(handles.interp1_1,'BackgroundColor',[0.702 0.702 0.702])
|
---|
3418 | set(handles.interp2_1,'BackgroundColor',[0.702 0.702 0.702])
|
---|
3419 | elseif isequal(field_1,'more...'); %add new item to the menu
|
---|
3420 | set(handles.civ1_1,'BackgroundColor',[0.702 0.702 0.702]) % put their color to grey
|
---|
3421 | set(handles.civ2_1,'BackgroundColor',[0.702 0.702 0.702])
|
---|
3422 | str=calc_field;%get the list of available scalars by the function calc_scal
|
---|
3423 | [ind_answer,v] = listdlg('PromptString','Select a file:',...
|
---|
3424 | 'SelectionMode','single',...
|
---|
3425 | 'ListString',str);
|
---|
3426 | % edit the choice in the field and action menu
|
---|
3427 | scalar=cell2mat(str(ind_answer));
|
---|
3428 | menu=update_menu(handles.Fields_1,scalar);
|
---|
3429 | set(handles.Fields_1,'String',menu);% store the selected scalar type
|
---|
3430 | end
|
---|
3431 | end
|
---|
3432 | str1=get(handles.i1,'String');
|
---|
3433 | str2=get(handles.i2,'String');
|
---|
3434 | str_a=get(handles.j1,'String');
|
---|
3435 | str_b=get(handles.j2,'String');
|
---|
3436 | indices=name_generator('',str2num(str1),stra2num(str_a),'',NomTypeNew,1,str2num(str2),stra2num(str_b),'');
|
---|
3437 | set(handles.FileIndex_1,'String',indices)
|
---|
3438 | set(handles.FileIndex_1,'UserData',NomTypeNew)
|
---|
3439 |
|
---|
3440 | %common to Fields_Callback
|
---|
3441 | if isequal(field,'image')|isequal(field_1,'image')
|
---|
3442 | set(handles.npx_title,'Visible','on')% visible npx,pxcm... buttons
|
---|
3443 | set(handles.npy_title,'Visible','on')
|
---|
3444 | set(handles.npx,'Visible','on')
|
---|
3445 | set(handles.npy,'Visible','on')
|
---|
3446 | % set(handles.fix_pair,'Value',0)
|
---|
3447 | else
|
---|
3448 | set(handles.npx_title,'Visible','off')% visible npx,pxcm... buttons
|
---|
3449 | set(handles.npy_title,'Visible','off')
|
---|
3450 | set(handles.npx,'Visible','off')
|
---|
3451 | set(handles.npy,'Visible','off')
|
---|
3452 | % set(handles.fix_pair,'Value',1)
|
---|
3453 | end
|
---|
3454 | if isequal(field,'velocity')|isequal(field_1,'velocity');
|
---|
3455 | state_vect='on';
|
---|
3456 | else
|
---|
3457 | state_vect='off';
|
---|
3458 | end
|
---|
3459 | if ~isequal(field,'velocity')|(~isequal(field_1,'velocity')&~isequal(field_1,''));
|
---|
3460 | state_scal='on';
|
---|
3461 | else
|
---|
3462 | state_scal='off';
|
---|
3463 | end
|
---|
3464 | set(handles.uvmat,'UserData',UvData)
|
---|
3465 | setfield(handles);% update the field structure ('civ1'....)
|
---|
3466 | if ~isfield(UvData,'NewSeries')|isequal(UvData.NewSeries,0)
|
---|
3467 | run0_Callback(hObject, eventdata, handles)
|
---|
3468 | end
|
---|
3469 |
|
---|
3470 | %------------------------------------------------------------------------
|
---|
3471 | % --- set the visibility of relevant velocity type menus:
|
---|
3472 | function set_veltype_display(handles,Civ)
|
---|
3473 | %------------------------------------------------------------------------
|
---|
3474 | %Civ=0; all states 'off'
|
---|
3475 | %Civ=6; all states 'on'
|
---|
3476 | if isequal(Civ,0)
|
---|
3477 | imax=0;
|
---|
3478 | % set(handles(1),'Visible','on') % unvisible civ buttons
|
---|
3479 | % else
|
---|
3480 | % set(handles(1),'String','civ1')
|
---|
3481 | % end
|
---|
3482 | elseif isequal(Civ,1) || isequal(Civ,2)
|
---|
3483 | imax=1;
|
---|
3484 | elseif isequal(Civ,3)
|
---|
3485 | imax=3;
|
---|
3486 | elseif isequal(Civ,4) || isequal(Civ,5)
|
---|
3487 | imax=4;
|
---|
3488 | elseif isequal(Civ,6) %patch2
|
---|
3489 | imax=6;
|
---|
3490 | end
|
---|
3491 | for ibutton=1:imax;
|
---|
3492 | set(handles(ibutton),'Visible','on') % unvisible civ buttons
|
---|
3493 | end
|
---|
3494 | % for ibutton=max(imax+1,2):6;
|
---|
3495 | for ibutton=imax+1:6;
|
---|
3496 | set(handles(ibutton),'Visible','off') % unvisible civ buttons
|
---|
3497 | set(handles(ibutton),'Value',0)%unactivate unvisible buttons
|
---|
3498 | end
|
---|
3499 |
|
---|
3500 | %-------------------------------------------------------------------
|
---|
3501 | % --- Executes on button press in civ1.
|
---|
3502 | function civ1_Callback(hObject, eventdata, handles)
|
---|
3503 | %-------------------------------------------------------------------
|
---|
3504 | if get(handles.civ1,'Value')==1
|
---|
3505 | reset_vel_type([handles.interp1 handles.civ2 handles.filter1 handles.interp1 handles.interp2 handles.filter2],handles.civ1)
|
---|
3506 | else
|
---|
3507 | reset_vel_type([handles.civ1 handles.filter1 handles.interp1 handles.civ2 handles.interp2 handles.filter2])
|
---|
3508 | end
|
---|
3509 | run0_Callback(hObject, eventdata, handles)
|
---|
3510 |
|
---|
3511 | %-------------------------------------------------------------------
|
---|
3512 | % --- Executes on button press in interp1.
|
---|
3513 | function interp1_Callback(hObject, eventdata, handles)
|
---|
3514 | %-------------------------------------------------------------------
|
---|
3515 | if get(handles.interp1,'Value')==1
|
---|
3516 | reset_vel_type([handles.civ1 handles.civ2 handles.filter1 handles.interp2 handles.filter2],handles.interp1)
|
---|
3517 | else
|
---|
3518 | reset_vel_type([handles.civ1 handles.filter1 handles.interp1 handles.civ2 handles.interp2 handles.filter2])
|
---|
3519 | end
|
---|
3520 | run0_Callback(hObject, eventdata, handles)
|
---|
3521 |
|
---|
3522 | %-------------------------------------------------------------------
|
---|
3523 | % --- Executes on button press in filter1.
|
---|
3524 | function filter1_Callback(hObject, eventdata, handles)
|
---|
3525 | %-------------------------------------------------------------------
|
---|
3526 | if get(handles.filter1,'Value')==1
|
---|
3527 | reset_vel_type([handles.civ1 handles.civ2 handles.interp1 handles.interp2 handles.filter2],handles.filter1)
|
---|
3528 | else
|
---|
3529 | reset_vel_type([handles.civ1 handles.filter1 handles.interp1 handles.civ2 handles.interp2 handles.filter2])
|
---|
3530 | end
|
---|
3531 | run0_Callback(hObject, eventdata, handles)
|
---|
3532 |
|
---|
3533 | %-------------------------------------------------------------------
|
---|
3534 | % --- Executes on button press in civ2.
|
---|
3535 | function civ2_Callback(hObject, eventdata, handles)
|
---|
3536 | %-------------------------------------------------------------------
|
---|
3537 | if get(handles.civ2,'Value')==1
|
---|
3538 | reset_vel_type([handles.civ1 handles.filter1 handles.interp1 handles.interp2 handles.filter2],handles.civ2)
|
---|
3539 | else
|
---|
3540 | reset_vel_type([handles.civ1 handles.filter1 handles.interp1 handles.civ2 handles.interp2 handles.filter2])
|
---|
3541 | end
|
---|
3542 | run0_Callback(hObject, eventdata, handles)
|
---|
3543 |
|
---|
3544 | %-----------------------------------------
|
---|
3545 | % --- Executes on button press in interp2.
|
---|
3546 | %-------------------------------------------
|
---|
3547 | function interp2_Callback(hObject, eventdata, handles)
|
---|
3548 | if get(handles.interp2,'Value')==1
|
---|
3549 | reset_vel_type([handles.civ1 handles.filter1 handles.interp1 handles.civ2 handles.filter2],handles.interp2)
|
---|
3550 | else
|
---|
3551 | reset_vel_type([handles.civ1 handles.filter1 handles.interp1 handles.civ2 handles.interp2 handles.filter2])
|
---|
3552 | end
|
---|
3553 | run0_Callback(hObject, eventdata, handles)
|
---|
3554 | %---------------------------------------------
|
---|
3555 | % --- Executes on button press in filter2.
|
---|
3556 | %-------------------------------------------
|
---|
3557 | function filter2_Callback(hObject, eventdata, handles)
|
---|
3558 | if get(handles.filter2,'Value')==1
|
---|
3559 | reset_vel_type([handles.civ1 handles.filter1 handles.interp1 handles.civ2 handles.interp2],handles.filter2)
|
---|
3560 | else
|
---|
3561 | reset_vel_type([handles.civ1 handles.filter1 handles.interp1 handles.civ2 handles.interp2 handles.filter2])
|
---|
3562 | end
|
---|
3563 | run0_Callback(hObject, eventdata, handles)
|
---|
3564 |
|
---|
3565 | %---------------------------------------------
|
---|
3566 | function civ1_1_Callback(hObject, eventdata, handles)
|
---|
3567 | %---------------------------------------------
|
---|
3568 | if get(handles.civ1_1,'Value')==1
|
---|
3569 | reset_vel_type([handles.interp1_1 handles.civ2_1 handles.filter1_1 handles.interp1_1 handles.interp2_1 handles.filter2_1],handles.civ1_1)
|
---|
3570 | else
|
---|
3571 | reset_vel_type([handles.civ1_1 handles.filter1_1 handles.interp1_1 handles.civ2_1 handles.interp2_1 handles.filter2_1])
|
---|
3572 | end
|
---|
3573 | run0_Callback(hObject, eventdata, handles)
|
---|
3574 |
|
---|
3575 | %--------------------------------------------
|
---|
3576 | function interp1_1_Callback(hObject, eventdata, handles)
|
---|
3577 | %--------------------------------------------
|
---|
3578 | if get(handles.interp1_1,'Value')==1
|
---|
3579 | reset_vel_type([handles.civ1_1 handles.civ2_1 handles.filter1_1 handles.interp2_1 handles.filter2_1],handles.interp1_1)
|
---|
3580 | else
|
---|
3581 | reset_vel_type([handles.civ1_1 handles.filter1_1 handles.interp1_1 handles.civ2_1 handles.interp2_1 handles.filter2_1])
|
---|
3582 | end
|
---|
3583 | run0_Callback(hObject, eventdata, handles)
|
---|
3584 |
|
---|
3585 | %--------------------------------------------
|
---|
3586 | function filter1_1_Callback(hObject, eventdata, handles)
|
---|
3587 | %--------------------------------------------
|
---|
3588 | if get(handles.filter1_1,'Value')==1
|
---|
3589 | reset_vel_type([handles.interp1_1 handles.civ2_1 handles.interp1_1 handles.interp2_1 handles.filter2_1],handles.filter1_1)
|
---|
3590 | else
|
---|
3591 | reset_vel_type([handles.civ1_1 handles.filter1_1 handles.interp1_1 handles.civ2_1 handles.interp2_1 handles.filter2_1])
|
---|
3592 | end
|
---|
3593 | run0_Callback(hObject, eventdata, handles)
|
---|
3594 |
|
---|
3595 | %--------------------------------------------
|
---|
3596 | function civ2_1_Callback(hObject, eventdata, handles)
|
---|
3597 | %--------------------------------------------
|
---|
3598 | if get(handles.civ2_1,'Value')==1
|
---|
3599 | reset_vel_type([handles.civ1_1 handles.interp1_1 handles.filter1_1 handles.interp2_1 handles.filter2_1],handles.civ2_1)
|
---|
3600 | else
|
---|
3601 | reset_vel_type([handles.civ1_1 handles.filter1_1 handles.interp1_1 handles.civ2_1 handles.interp2_1 handles.filter2_1])
|
---|
3602 | end
|
---|
3603 | run0_Callback(hObject, eventdata, handles)
|
---|
3604 |
|
---|
3605 | %--------------------------------------------
|
---|
3606 | function interp2_1_Callback(hObject, eventdata, handles)
|
---|
3607 | %--------------------------------------------
|
---|
3608 | if get(handles.interp2_1,'Value')==1
|
---|
3609 | reset_vel_type([handles.civ1_1 handles.civ2_1 handles.filter1_1 handles.interp1_1 handles.filter2_1],handles.interp2_1)
|
---|
3610 | else
|
---|
3611 | reset_vel_type([handles.civ1_1 handles.filter1_1 handles.interp1_1 handles.civ2_1 handles.interp2_1 handles.filter2_1])
|
---|
3612 | end
|
---|
3613 | run0_Callback(hObject, eventdata, handles)
|
---|
3614 |
|
---|
3615 | %--------------------------------------------
|
---|
3616 | function filter2_1_Callback(hObject, eventdata, handles)
|
---|
3617 | %--------------------------------------------
|
---|
3618 | if get(handles.filter2_1,'Value')==1
|
---|
3619 | reset_vel_type([handles.civ1_1 handles.interp1_1 handles.civ2_1 handles.filter1_1 handles.interp1_1 handles.interp2_1],handles.filter2_1)
|
---|
3620 | else
|
---|
3621 | reset_vel_type([handles.civ1_1 handles.filter1_1 handles.interp1_1 handles.civ2_1 handles.interp2_1 handles.filter2_1])
|
---|
3622 | end
|
---|
3623 | run0_Callback(hObject, eventdata, handles)
|
---|
3624 |
|
---|
3625 | %-----------------------------------------------
|
---|
3626 | % --- reset civ buttons
|
---|
3627 | function reset_vel_type(handles_civ0,handle1)
|
---|
3628 | for ibutton=1:length(handles_civ0)
|
---|
3629 | set(handles_civ0(ibutton),'BackgroundColor',[0.831 0.816 0.784])
|
---|
3630 | set(handles_civ0(ibutton),'Value',0)
|
---|
3631 | end
|
---|
3632 | if exist('handle1','var')%handles of selected button
|
---|
3633 | set(handle1,'BackgroundColor',[1 1 0])
|
---|
3634 | end
|
---|
3635 |
|
---|
3636 | %-------------------------------------------------------
|
---|
3637 | % --- Executes on button press in MENUVOLUME.
|
---|
3638 | %-------------------------------------------------------
|
---|
3639 | function VOLUME_Callback(hObject, eventdata, handles)
|
---|
3640 | %errordlg('command VOL not implemented yet')
|
---|
3641 | if ishandle(handles.UVMAT_title)
|
---|
3642 | delete(handles.UVMAT_title)
|
---|
3643 | end
|
---|
3644 | UvData=get(handles.uvmat,'UserData');%read UvData properties stored on the uvmat interface
|
---|
3645 | if isequal(get(handles.VOLUME,'Value'),1)
|
---|
3646 | set(handles.zoom,'Value',0)
|
---|
3647 | set(handles.zoom,'BackgroundColor',[0.7 0.7 0.7])
|
---|
3648 | set(handles.edit_vect,'Value',0)
|
---|
3649 | edit_vect_Callback(hObject, eventdata, handles)
|
---|
3650 | set(handles.edit,'Value',0)
|
---|
3651 | set(handles.edit,'BackgroundColor',[0.7 0.7 0.7])
|
---|
3652 | % set(handles.cal,'Value',0)
|
---|
3653 | % set(handles.cal,'BackgroundColor',[0 1 0])
|
---|
3654 | set(handles.edit_vect,'Value',0)
|
---|
3655 | edit_vect_Callback(hObject, eventdata, handles)
|
---|
3656 | %initiate set_object GUI
|
---|
3657 | data.TITLE='VOLUME';
|
---|
3658 | if isfield(UvData,'CoordType')
|
---|
3659 | data.CoordType=UvData.CoordType;
|
---|
3660 | end
|
---|
3661 | if isfield(UvData,'Mesh')&~isempty(UvData.Mesh)
|
---|
3662 | data.RangeY=UvData.Mesh;
|
---|
3663 | data.RangeX=UvData.Mesh;
|
---|
3664 | data.DX=UvData.Mesh;
|
---|
3665 | data.DY=UvData.Mesh;
|
---|
3666 | elseif isfield(UvData.Field,'AX')&isfield(UvData.Field,'AY')& isfield(UvData.Field,'A')%only image
|
---|
3667 | np=size(UvData.Field.A);
|
---|
3668 | meshx=(UvData.Field.AX(end)-UvData.Field.AX(1))/np(2);
|
---|
3669 | meshy=abs(UvData.Field.AY(end)-UvData.Field.AY(1))/np(1);
|
---|
3670 | data.RangeY=max(meshx,meshy);
|
---|
3671 | data.RangeX=max(meshx,meshy);
|
---|
3672 | data.DX=max(meshx,meshy);
|
---|
3673 | end
|
---|
3674 | data.ParentButton=handles.VOLUME;
|
---|
3675 | PlotHandles=get_plot_handles(handles);%get the handles of the interface elements setting the plotting parameters
|
---|
3676 | [hset_object,UvData.sethandles]=set_object(data,PlotHandles);% call the set_object interface with action on haxes,
|
---|
3677 | % associate the set_edit interface handle to the plotting axes
|
---|
3678 | if isfield(UvData,'SetObjectOrigin')
|
---|
3679 | pos_uvmat=get(huvmat,'Position');
|
---|
3680 | pos_set_object(1:2)=UvData.SetObjectOrigin + pos_uvmat(1:2);
|
---|
3681 | pos_set_object(3:4)=UvData.SetObjectSize .* pos_uvmat(3:4);
|
---|
3682 | set(hset_object,'Position',pos_set_object)
|
---|
3683 | end
|
---|
3684 | UvData.MouseAction='create_object';
|
---|
3685 | else
|
---|
3686 | set(handles.VOLUME,'BackgroundColor',[0 1 0])
|
---|
3687 | UvData.MouseAction='none';
|
---|
3688 | end
|
---|
3689 | set(huvmat,'UserData',UvData)
|
---|
3690 |
|
---|
3691 | %-------------------------------------------------------
|
---|
3692 | function edit_vect_Callback(hObject, eventdata, handles)
|
---|
3693 | %-------------------------------------------------------
|
---|
3694 |
|
---|
3695 | UvData=get(handles.uvmat,'UserData');%read UvData properties stored on the uvmat interface
|
---|
3696 | if isequal(get(handles.edit_vect,'Value'),1)
|
---|
3697 | test_civ2=isequal(get(handles.civ2,'BackgroundColor'),[1 1 0]);
|
---|
3698 | test_civ1=isequal(get(handles.civ1,'BackgroundColor'),[1 1 0]);
|
---|
3699 | if ~test_civ2 && ~test_civ1
|
---|
3700 | msgbox_uvmat('ERROR','manual correction only possible for CIV1 or CIV2 velocity fields')
|
---|
3701 | end
|
---|
3702 | set(handles.record,'Visible','on')
|
---|
3703 | set(handles.edit_vect,'BackgroundColor',[1 1 0])
|
---|
3704 | set(handles.edit,'Value',0)
|
---|
3705 | set(handles.zoom,'Value',0)
|
---|
3706 | set(handles.zoom,'BackgroundColor',[0.7 0.7 0.7])
|
---|
3707 | % set(handles.create,'Value',0)
|
---|
3708 | % set(handles.create,'BackgroundColor',[0 1 0])
|
---|
3709 | set(handles.edit,'BackgroundColor',[0.7 0.7 0.7])
|
---|
3710 | set(gcf,'Pointer','arrow')
|
---|
3711 | UvData.MouseAction='edit_vect';
|
---|
3712 | else
|
---|
3713 | set(handles.record,'Visible','off')
|
---|
3714 | set(handles.edit_vect,'BackgroundColor',[0.7 0.7 0.7])
|
---|
3715 | UvData.MouseAction='none';
|
---|
3716 | end
|
---|
3717 | set(handles.uvmat,'UserData',UvData)
|
---|
3718 |
|
---|
3719 | %----------------------------------------------
|
---|
3720 | function save_mask_Callback(hObject, eventdata, handles)
|
---|
3721 | %-----------------------------------------------------------------------
|
---|
3722 | UvData=get(handles.uvmat,'UserData');
|
---|
3723 |
|
---|
3724 | flag=1;
|
---|
3725 | npx=size(UvData.Field.A,2);
|
---|
3726 | npy=size(UvData.Field.A,1);
|
---|
3727 | xi=[0.5:npx-0.5];
|
---|
3728 | yi=[0.5:npy-0.5];
|
---|
3729 | [Xi,Yi]=meshgrid(xi,yi);
|
---|
3730 | if isfield(UvData,'Object')
|
---|
3731 | for iobj=1:length(UvData.Object)
|
---|
3732 | ObjectData=UvData.Object{iobj};
|
---|
3733 | if isfield(ObjectData,'ProjMode') &&(isequal(ObjectData.ProjMode,'mask_inside')||isequal(ObjectData.ProjMode,'mask_outside'));
|
---|
3734 | flagobj=1;
|
---|
3735 | testphys=0; %coordinates in pixels by default
|
---|
3736 | if isfield(ObjectData,'CoordType') && isequal(ObjectData.CoordType,'phys')
|
---|
3737 | if isfield(UvData,'XmlData')&& isfield(UvData.XmlData,'GeometryCalib')
|
---|
3738 | Calib=UvData.XmlData.GeometryCalib;
|
---|
3739 | testphys=1;
|
---|
3740 | end
|
---|
3741 | end
|
---|
3742 | if isfield(ObjectData,'Coord')& isfield(ObjectData,'Style')
|
---|
3743 | if isequal(ObjectData.Style,'polygon')
|
---|
3744 | X=ObjectData.Coord(:,1);
|
---|
3745 | Y=ObjectData.Coord(:,2);
|
---|
3746 | if testphys
|
---|
3747 | [X,Y]=px_XYZ(Calib,X,Y,0);% to generalise with 3D cases
|
---|
3748 | end
|
---|
3749 | flagobj=~inpolygon(Xi,Yi,X',Y');%=0 inside the polygon, 1 outside
|
---|
3750 | elseif isequal(ObjectData.Style,'ellipse')
|
---|
3751 | if testphys
|
---|
3752 | %[X,Y]=px_XYZ(Calib,X,Y,0);% TODO:create a polygon boundary and transform to phys
|
---|
3753 | end
|
---|
3754 | RangeX=max(ObjectData.RangeX);
|
---|
3755 | RangeY=max(ObjectData.RangeY);
|
---|
3756 | X2Max=RangeX*RangeX;
|
---|
3757 | Y2Max=RangeY*RangeY;
|
---|
3758 | distX=(Xi-ObjectData.Coord(1,1));
|
---|
3759 | distY=(Yi-ObjectData.Coord(1,2));
|
---|
3760 | flagobj=(distX.*distX/X2Max+distY.*distY/Y2Max)>1;
|
---|
3761 | elseif isequal(ObjectData.Style,'rectangle')
|
---|
3762 | if testphys
|
---|
3763 | %[X,Y]=px_XYZ(Calib,X,Y,0);% TODO:create a polygon boundary and transform to phys
|
---|
3764 | end
|
---|
3765 | distX=abs(Xi-ObjectData.Coord(1,1));
|
---|
3766 | distY=abs(Yi-ObjectData.Coord(1,2));
|
---|
3767 | flagobj=distX>max(ObjectData.RangeX) | distY>max(ObjectData.RangeY);
|
---|
3768 | end
|
---|
3769 | if isequal(ObjectData.ProjMode,'mask_outside')
|
---|
3770 | flagobj=~flagobj;
|
---|
3771 | end
|
---|
3772 | flag=flag & flagobj;
|
---|
3773 | end
|
---|
3774 | end
|
---|
3775 | end
|
---|
3776 | end
|
---|
3777 | % flag=~flag;
|
---|
3778 | %mask name
|
---|
3779 | RootPath=get(handles.RootPath,'String');
|
---|
3780 | RootFile=get(handles.RootFile,'String');
|
---|
3781 | if ~isempty(RootFile)&(isequal(RootFile(1),'/')| isequal(RootFile(1),'\'))
|
---|
3782 | RootFile(1)=[];
|
---|
3783 | end
|
---|
3784 | filebase=fullfile(RootPath,RootFile);
|
---|
3785 | list=get(handles.masklevel,'String');
|
---|
3786 | masknumber=num2str(length(list));
|
---|
3787 | maskindex=get(handles.masklevel,'Value');
|
---|
3788 | mask_name=name_generator([filebase '_' masknumber 'mask'],maskindex,1,'.png','_i');
|
---|
3789 | imflag=uint8(255*(0.392+0.608*flag));% =100 for flag=0 (vectors not computed when 20<imflag<200)
|
---|
3790 | imflag=flipdim(imflag,1);
|
---|
3791 | % imflag=uint8(255*flag);% =0 for flag=0 (vectors=0 when 20<imflag<200)
|
---|
3792 | msgbox_uvmat('CONFIRMATION',[mask_name ' saved'])
|
---|
3793 | imwrite(imflag,mask_name,'BitDepth',8);
|
---|
3794 |
|
---|
3795 | %display the mask
|
---|
3796 | %update_mask(handles,num_i1,num_j1)
|
---|
3797 | figure;
|
---|
3798 | vec=linspace(0,1,256);%define a linear greyscale colormap
|
---|
3799 | map=[vec' vec' vec'];
|
---|
3800 | colormap(map)
|
---|
3801 |
|
---|
3802 | image(imflag);
|
---|
3803 |
|
---|
3804 | %-------------------------------------------------------------------
|
---|
3805 | %-------------------------------------------------------------------
|
---|
3806 | % - FUNCTIONS FOR SETTING PLOTTING PARAMETERS
|
---|
3807 |
|
---|
3808 | %------------------------------------------------------------------
|
---|
3809 |
|
---|
3810 |
|
---|
3811 |
|
---|
3812 | %------------------------------------------------------------------
|
---|
3813 | % --- Executes on selection change in col_vec: choice of the color code.
|
---|
3814 | %
|
---|
3815 | function col_vec_Callback(hObject, eventdata, handles)
|
---|
3816 | %------------------------------------------------------------------
|
---|
3817 | % edit the choice for color code
|
---|
3818 | list_code=get(handles.col_vec,'String');% list menu fields
|
---|
3819 | index_code=get(handles.col_vec,'Value');% selected string index
|
---|
3820 | col_code= list_code{index_code(1)}; % selected field
|
---|
3821 | if isequal(col_code,'black') || isequal(col_code,'white')
|
---|
3822 | set(handles.slider1,'Visible','off')
|
---|
3823 | set(handles.slider2,'Visible','off')
|
---|
3824 | set(handles.colcode1,'Visible','off')
|
---|
3825 | set(handles.colcode2,'Visible','off')
|
---|
3826 | set(handles.AutoVecColor,'Visible','off')
|
---|
3827 | set_vec_col_bar(handles)
|
---|
3828 | else
|
---|
3829 | set(handles.slider1,'Visible','on')
|
---|
3830 | set(handles.slider2,'Visible','on')
|
---|
3831 | set(handles.colcode1,'Visible','on')
|
---|
3832 | set(handles.colcode2,'Visible','on')
|
---|
3833 | set(handles.AutoVecColor,'Visible','on')
|
---|
3834 | if isequal(col_code,'ima_cor')
|
---|
3835 | set(handles.AutoVecColor,'Value',0)%fixed scale by default
|
---|
3836 | set(handles.vec_col_bar,'Value',0)% 3 colors r,g,b by default
|
---|
3837 | set(handles.slider1,'Min',0);
|
---|
3838 | set(handles.slider1,'Max',1);
|
---|
3839 | set(handles.slider2,'Min',0);
|
---|
3840 | set(handles.slider2,'Max',1);
|
---|
3841 | % set(handles.min_title_vec,'String','0')
|
---|
3842 | set(handles.max_vec,'String','1')
|
---|
3843 | set(handles.colcode1,'String','0.333')
|
---|
3844 | colcode1_Callback(hObject, eventdata, handles)
|
---|
3845 | set(handles.colcode2,'String','0.666')
|
---|
3846 | colcode2_Callback(hObject, eventdata, handles)
|
---|
3847 | else
|
---|
3848 | set(handles.AutoVecColor,'Value',1)%auto scale between min,max by default
|
---|
3849 | set(handles.vec_col_bar,'Value',1)% colormap 'jet' by default
|
---|
3850 | minval=get(handles.slider1,'Min');
|
---|
3851 | maxval=get(handles.slider1,'Max');
|
---|
3852 | set(handles.slider1,'Value',minval)
|
---|
3853 | set(handles.slider2,'Value',maxval)
|
---|
3854 | set_vec_col_bar(handles)
|
---|
3855 | end
|
---|
3856 | % slider_update(handles)
|
---|
3857 | end
|
---|
3858 | %replot the current graph
|
---|
3859 | run0_Callback(hObject, eventdata, handles)
|
---|
3860 |
|
---|
3861 |
|
---|
3862 | %----------------------------------------------------------------
|
---|
3863 | % -- Executes on slider movement to set the color code
|
---|
3864 | %
|
---|
3865 | function slider1_Callback(hObject, eventdata, handles)
|
---|
3866 | %------------------------------------------------------------------
|
---|
3867 | slider1=get(handles.slider1,'Value');
|
---|
3868 | min_val=str2num(get(handles.min_vec,'String'));
|
---|
3869 | max_val=str2num(get(handles.max_vec,'String'));
|
---|
3870 | col=min_val+(max_val-min_val)*slider1;
|
---|
3871 | set(handles.colcode1,'String',num2str(col))
|
---|
3872 | if(get(handles.slider2,'Value') < col)%move also the second slider at the same value if needed
|
---|
3873 | set(handles.slider2,'Value',col)
|
---|
3874 | set(handles.colcode2,'String',num2str(col))
|
---|
3875 | end
|
---|
3876 | colcode1_Callback(hObject, eventdata, handles)
|
---|
3877 |
|
---|
3878 | %----------------------------------------------------------------
|
---|
3879 | % Executes on slider movement to set the color code
|
---|
3880 | %----------------------------------------------------------------
|
---|
3881 | function slider2_Callback(hObject, eventdata, handles)
|
---|
3882 | slider2=get(handles.slider2,'Value');
|
---|
3883 | min_val=str2num(get(handles.min_vec,'String'));
|
---|
3884 | max_val=str2num(get(handles.max_vec,'String'));
|
---|
3885 | col=min_val+(max_val-min_val)*slider2;
|
---|
3886 | set(handles.colcode2,'String',num2str(col))
|
---|
3887 | if(get(handles.slider1,'Value') > col)%move also the first slider at the same value if needed
|
---|
3888 | set(handles.slider1,'Value',col)
|
---|
3889 | set(handles.colcode1,'String',num2str(col))
|
---|
3890 | end
|
---|
3891 | colcode2_Callback(hObject, eventdata, handles)
|
---|
3892 |
|
---|
3893 | %----------------------------------------------------------------
|
---|
3894 | %execute on return carriage on the edit box corresponding to slider 1
|
---|
3895 | %----------------------------------------------------------------
|
---|
3896 | function colcode1_Callback(hObject, eventdata, handles)
|
---|
3897 | % col=str2num(get(handles.colcode1,'String'));
|
---|
3898 | % set(handles.slider1,'Value',col)
|
---|
3899 | set_vec_col_bar(handles)
|
---|
3900 | update_plot(handles);
|
---|
3901 |
|
---|
3902 | %----------------------------------------------------------------
|
---|
3903 | %execute on return carriage on the edit box corresponding to slider 2
|
---|
3904 | %----------------------------------------------------------------
|
---|
3905 | function colcode2_Callback(hObject, eventdata, handles)
|
---|
3906 | % col=str2num(get(handles.colcode2,'String'));
|
---|
3907 | % set(handles.slider2,'Value',col)
|
---|
3908 | % slider2_Callback(hObject, eventdata, handles)
|
---|
3909 | set_vec_col_bar(handles)
|
---|
3910 | update_plot(handles);
|
---|
3911 | %------------------------------------------------------------
|
---|
3912 | %update the slider values after displaying vectors
|
---|
3913 | %--------------------------------------------------------
|
---|
3914 | % function slider_update(handles,auto,minC,colcode1,colcode2,maxC)
|
---|
3915 | % set(handles.slider1,'Min',minC)
|
---|
3916 | % set(handles.slider1,'Max',maxC)
|
---|
3917 | % set(handles.slider2,'Min',minC)
|
---|
3918 | % set(handles.slider2,'Max',maxC)
|
---|
3919 | % set(handles.min_title_vec,'String',num2str(minC))
|
---|
3920 | % set(handles.max_vec,'String',num2str(maxC))
|
---|
3921 | % if auto
|
---|
3922 | % set(handles.colcode1,'String',num2str(colcode1,3))%update display
|
---|
3923 | % set(handles.colcode2,'String',num2str(colcode2,3))
|
---|
3924 | % end
|
---|
3925 | % set(handles.slider1,'Value',colcode1)%update slider with constant display
|
---|
3926 | % set(handles.slider2,'Value',colcode2)
|
---|
3927 | % set_vec_col_bar(handles)
|
---|
3928 |
|
---|
3929 |
|
---|
3930 | %-------------------------------------------------------
|
---|
3931 | % --- Executes on button press in AutoVecColor.
|
---|
3932 | %-------------------------------------------------------
|
---|
3933 | function vec_col_bar_Callback(hObject, eventdata, handles)
|
---|
3934 | set_vec_col_bar(handles)
|
---|
3935 |
|
---|
3936 | %-------------------------------------------------------------
|
---|
3937 | % --- Executes on selection change in transform_fct.
|
---|
3938 | function transform_fct_Callback(hObject, eventdata, handles)
|
---|
3939 | %-------------------------------------------------------------
|
---|
3940 | global nb_builtin
|
---|
3941 |
|
---|
3942 | huvmat=get(handles.transform_fct,'parent');
|
---|
3943 | menu=get(handles.transform_fct,'String');
|
---|
3944 | ind_coord=get(handles.transform_fct,'Value');
|
---|
3945 | coord_option=menu{ind_coord};
|
---|
3946 | list_transform=get(handles.transform_fct,'UserData');
|
---|
3947 | ff=functions(list_transform{end});
|
---|
3948 | if isequal(coord_option,'more...');
|
---|
3949 | coord_fct='';
|
---|
3950 | prompt = {'Enter the name of the transform function'};
|
---|
3951 | dlg_title = 'user defined transform';
|
---|
3952 | num_lines= 1;
|
---|
3953 | [FileName, PathName] = uigetfile( ...
|
---|
3954 | {'*.m', ' (*.m)';
|
---|
3955 | '*.m', '.m files '; ...
|
---|
3956 | '*.*', 'All Files (*.*)'}, ...
|
---|
3957 | 'Pick a file', ff.file);
|
---|
3958 | if isequal(PathName(end),'/')||isequal(PathName(end),'\')
|
---|
3959 | PathName(end)=[];
|
---|
3960 | end
|
---|
3961 | transform_selected =fullfile(PathName,FileName);
|
---|
3962 | if ~exist(transform_selected,'file')
|
---|
3963 | return
|
---|
3964 | end
|
---|
3965 | [ppp,transform,ext_fct]=fileparts(FileName);% removes extension .m
|
---|
3966 | if ~isequal(ext_fct,'.m')
|
---|
3967 | msgbox_uvmat('ERROR','a Matlab function .m must be introduced');
|
---|
3968 | return
|
---|
3969 | end
|
---|
3970 | menu=update_menu(handles.transform_fct,transform);%add the selected fct to the menu
|
---|
3971 | ind_coord=get(handles.transform_fct,'Value');
|
---|
3972 | addpath(PathName)
|
---|
3973 | list_transform{ind_coord}=str2func(transform);% create the function handle corresponding to the newly seleced function
|
---|
3974 | set(handles.transform_fct,'UserData',list_transform)
|
---|
3975 | rmpath(PathName)
|
---|
3976 | % save the new menu in the personal file 'uvmat_perso.mat'
|
---|
3977 | dir_perso=prefdir;%personal Matalb directory
|
---|
3978 | profil_perso=fullfile(dir_perso,'uvmat_perso.mat');
|
---|
3979 | if exist(profil_perso,'file')
|
---|
3980 | for ilist=nb_builtin+1:numel(list_transform)
|
---|
3981 | ff=functions(list_transform{ilist});
|
---|
3982 | transform_fct{ilist-nb_builtin}=ff.file;
|
---|
3983 | end
|
---|
3984 | save (profil_perso,'transform_fct','-append'); %store the root name for future opening of uvmat
|
---|
3985 | end
|
---|
3986 | end
|
---|
3987 |
|
---|
3988 | %check the current path to the selected function
|
---|
3989 | if isa(list_transform{ind_coord},'function_handle')
|
---|
3990 | func=functions(list_transform{ind_coord});
|
---|
3991 | set(handles.path_transform,'String',fileparts(func.file)); %show the path to the senlected function
|
---|
3992 | else
|
---|
3993 | set(handles.path_transform,'String','')
|
---|
3994 | end
|
---|
3995 |
|
---|
3996 | set(handles.FixedLimits,'Value',0)
|
---|
3997 | set(handles.FixedLimits,'BackgroundColor',[0.7 0.7 0.7])
|
---|
3998 |
|
---|
3999 | UvData=get(huvmat,'UserData');
|
---|
4000 |
|
---|
4001 | %delete drawn objects
|
---|
4002 | hother=findobj('Tag','proj_object');%find all the proj objects
|
---|
4003 | for iobj=1:length(hother)
|
---|
4004 | delete_object(hother(iobj))
|
---|
4005 | end
|
---|
4006 | hother=findobj('Tag','DeformPoint');%find all the proj objects
|
---|
4007 | for iobj=1:length(hother)
|
---|
4008 | delete_object(hother(iobj))
|
---|
4009 | end
|
---|
4010 | hh=findobj('Tag','calib_points');
|
---|
4011 | if ~isempty(hh)
|
---|
4012 | delete(hh)
|
---|
4013 | end
|
---|
4014 | hhh=findobj('Tag','calib_marker');
|
---|
4015 | if ~isempty(hhh)
|
---|
4016 | delete(hhh)
|
---|
4017 | end
|
---|
4018 | if isfield(UvData,'Object')
|
---|
4019 | UvData.Object=UvData.Object(1);
|
---|
4020 | end
|
---|
4021 | list_object=get(handles.list_object_1,'String');
|
---|
4022 | set(handles.list_object_1,'Value',1)
|
---|
4023 | set(handles.list_object_1,'String',list_object(1))
|
---|
4024 | set(handles.list_object_2,'Value',2)
|
---|
4025 | set(handles.list_object_2,'String',[list_object(1);{'...'}])
|
---|
4026 | list_object_2_Callback(hObject, eventdata, handles)
|
---|
4027 |
|
---|
4028 | %delete mask if it is displayed
|
---|
4029 | if isequal(get(handles.mask_test,'Value'),1)%if the mask option is on
|
---|
4030 | UvData=rmfield(UvData,'MaskName'); %will impose mask refresh
|
---|
4031 | end
|
---|
4032 | set(huvmat,'UserData',UvData)
|
---|
4033 | run0_Callback(hObject, eventdata, handles)
|
---|
4034 |
|
---|
4035 | %--------------------------------------------
|
---|
4036 | function histo1_menu_Callback(hObject, eventdata, handles)
|
---|
4037 | %--------------------------------------------
|
---|
4038 | %plot first histo
|
---|
4039 | huvmat=get(handles.histo1_menu,'parent');
|
---|
4040 | histo_menu=get(handles.histo1_menu,'String');
|
---|
4041 | histo_value=get(handles.histo1_menu,'Value');
|
---|
4042 | FieldName=histo_menu{histo_value};
|
---|
4043 | % UvData=get(huvmat,'UserData');
|
---|
4044 | update_histo(handles.histo_u,huvmat,FieldName)
|
---|
4045 |
|
---|
4046 | %----------------------------------------------
|
---|
4047 | function histo2_menu_Callback(hObject, eventdata, handles)
|
---|
4048 | %----------------------------------------------
|
---|
4049 | %plot second histo
|
---|
4050 | huvmat=get(handles.histo2_menu,'parent');
|
---|
4051 | histo_menu=get(handles.histo2_menu,'String');
|
---|
4052 | histo_value=get(handles.histo2_menu,'Value');
|
---|
4053 | FieldName=histo_menu{histo_value};
|
---|
4054 | % UvData=get(huvmat,'UserData');
|
---|
4055 | update_histo(handles.histo_v,huvmat,FieldName)
|
---|
4056 |
|
---|
4057 |
|
---|
4058 | %--------------------------------------------
|
---|
4059 | %read the field .Fieldname stored in UvData and plot its histogram
|
---|
4060 | function update_histo(haxes,huvmat,FieldName)
|
---|
4061 | UvData=get(huvmat,'UserData');
|
---|
4062 | if ~isfield(UvData.Field,FieldName)
|
---|
4063 | msgbox_uvmat('ERROR',['no field ' FieldName ' for histogram'])
|
---|
4064 | return
|
---|
4065 | end
|
---|
4066 | Field=UvData.Field;
|
---|
4067 | FieldHisto=eval(['Field.' FieldName]);
|
---|
4068 | if isfield(Field,'FF') && ~isempty(Field.FF) && isequal(size(Field.FF),size(FieldHisto))
|
---|
4069 | indsel=find(Field.FF==0);%find values marked as false
|
---|
4070 | if ~isempty(indsel)
|
---|
4071 | FieldHisto=FieldHisto(indsel);
|
---|
4072 | end
|
---|
4073 | end
|
---|
4074 | if isempty(Field)
|
---|
4075 | msgbox_uvmat('ERROR',['empty field ' FieldName])
|
---|
4076 | else
|
---|
4077 | nxy=size(FieldHisto);
|
---|
4078 | Amin=double(min(min(min(FieldHisto))));%min of image
|
---|
4079 | Amax=double(max(max(max(FieldHisto))));%max of image
|
---|
4080 | if isequal(Amin,Amax)
|
---|
4081 | Histo.Txt=['uniform field =' num2str(Amin)];
|
---|
4082 | else
|
---|
4083 | Histo.ListVarName={FieldName,'histo'};
|
---|
4084 | if numel(nxy)==2
|
---|
4085 | Histo.VarDimName={FieldName,FieldName}; %dimensions for the histogram
|
---|
4086 | else %color images
|
---|
4087 | Histo.VarDimName={FieldName,{FieldName,'rgb'}}; %dimensions for the histogram
|
---|
4088 | end
|
---|
4089 | %unit
|
---|
4090 | units=[]; %default
|
---|
4091 | for ivar=1:numel(Field.ListVarName)
|
---|
4092 | if strcmp(Field.ListVarName{ivar},FieldName)
|
---|
4093 | if isfield(Field,'VarAttribute') && numel(Field.VarAttribute)>=ivar && isfield(Field.VarAttribute{ivar},'units')
|
---|
4094 | units=Field.VarAttribute{ivar}.units;
|
---|
4095 | break
|
---|
4096 | end
|
---|
4097 | end
|
---|
4098 | end
|
---|
4099 | if ~isempty(units)
|
---|
4100 | Histo.VarAttribute{1}.units=units;
|
---|
4101 | end
|
---|
4102 | eval(['Histo.' FieldName '=linspace(Amin,Amax,50);'])%absissa values for histo
|
---|
4103 | for col=1:size(FieldHisto,3)
|
---|
4104 | B=FieldHisto(:,:,col);
|
---|
4105 | C=reshape(double(B),1,nxy(1)*nxy(2));% reshape in a vector
|
---|
4106 | eval(['Histo.histo(:,col)=hist(C, Histo.' FieldName ');']); %calculate histogram
|
---|
4107 | end
|
---|
4108 | set(haxes,'XLimMode','auto')%reset auto mode (after zoom effect)
|
---|
4109 | set(haxes,'YLimMode','auto')
|
---|
4110 | plot_field(Histo,haxes);
|
---|
4111 | end
|
---|
4112 | end
|
---|
4113 |
|
---|
4114 |
|
---|
4115 |
|
---|
4116 | %------------------------------------------------
|
---|
4117 | %CALLBACKS FOR PLOTTING PARAMETERS
|
---|
4118 | %-------------------------------------------------
|
---|
4119 |
|
---|
4120 | %-----------------------------------------------------------------
|
---|
4121 | function MinA_Callback(hObject, eventdata, handles)
|
---|
4122 | %------------------------------------------
|
---|
4123 | set(handles.AutoScal,'Value',1) %suppress auto mode
|
---|
4124 | set(handles.AutoScal,'BackgroundColor',[1 1 0])
|
---|
4125 | update_plot(handles);
|
---|
4126 |
|
---|
4127 | %-----------------------------------------------------------------
|
---|
4128 | function MaxA_Callback(hObject, eventdata, handles)
|
---|
4129 | %--------------------------------------------
|
---|
4130 | set(handles.AutoScal,'Value',1) %suppress auto mode
|
---|
4131 | set(handles.AutoScal,'BackgroundColor',[1 1 0])
|
---|
4132 | update_plot(handles);
|
---|
4133 |
|
---|
4134 | %-----------------------------------------------
|
---|
4135 | function AutoScal_Callback(hObject, eventdata, handles)
|
---|
4136 | %--------------------------------------------
|
---|
4137 | test=get(handles.AutoScal,'Value');
|
---|
4138 | if test
|
---|
4139 | set(handles.AutoScal,'BackgroundColor',[1 1 0])
|
---|
4140 | else
|
---|
4141 | set(handles.AutoScal,'BackgroundColor',[0.7 0.7 0.7])
|
---|
4142 | update_plot(handles);
|
---|
4143 | end
|
---|
4144 |
|
---|
4145 | %-------------------------------------------------------------------
|
---|
4146 | function BW_Callback(hObject, eventdata, handles)
|
---|
4147 | %-------------------------------------------------------------------
|
---|
4148 | update_plot(handles);
|
---|
4149 |
|
---|
4150 | %-------------------------------------------------------------------
|
---|
4151 | function Contours_Callback(hObject, eventdata, handles)
|
---|
4152 | %-------------------------------------------------------------------
|
---|
4153 | val=get(handles.Contours,'Value');
|
---|
4154 | if val==2
|
---|
4155 | set(handles.interval_txt,'Visible','on')
|
---|
4156 | set(handles.IncrA,'Visible','on')
|
---|
4157 | else
|
---|
4158 | set(handles.interval_txt,'Visible','off')
|
---|
4159 | set(handles.IncrA,'Visible','off')
|
---|
4160 | end
|
---|
4161 | update_plot(handles);
|
---|
4162 |
|
---|
4163 | %-------------------------------------------------------------------
|
---|
4164 | function IncrA_Callback(hObject, eventdata, handles)
|
---|
4165 | %-------------------------------------------------------------------
|
---|
4166 | update_plot(handles);
|
---|
4167 |
|
---|
4168 | %-------------------------------------------------------------------
|
---|
4169 | function HideWarning_Callback(hObject, eventdata, handles)
|
---|
4170 | %-------------------------------------------------------------------
|
---|
4171 | update_plot(handles);
|
---|
4172 |
|
---|
4173 | %-------------------------------------------------------------------
|
---|
4174 | function HideFalse_Callback(hObject, eventdata, handles)
|
---|
4175 | %-------------------------------------------------------------------
|
---|
4176 | update_plot(handles);
|
---|
4177 |
|
---|
4178 | %-------------------------------------------------------------------
|
---|
4179 | function VecScale_Callback(hObject, eventdata, handles)
|
---|
4180 | %-------------------------------------------------------------------
|
---|
4181 | set(handles.AutoVec,'Value',1);
|
---|
4182 | set(handles.AutoVec,'BackgroundColor',[1 1 0])
|
---|
4183 | update_plot(handles);
|
---|
4184 |
|
---|
4185 | %-------------------------------------------------------------------
|
---|
4186 | function AutoVec_Callback(hObject, eventdata, handles)
|
---|
4187 | %-------------------------------------------------------------------
|
---|
4188 | test=get(handles.AutoVec,'Value');
|
---|
4189 | if test
|
---|
4190 | set(handles.AutoVec,'BackgroundColor',[1 1 0])
|
---|
4191 | else
|
---|
4192 | update_plot(handles);
|
---|
4193 | %set(handles.VecScale,'String',num2str(ScalOut.VecScale,3))
|
---|
4194 | set(handles.AutoVec,'BackgroundColor',[0.7 0.7 0.7])
|
---|
4195 | end
|
---|
4196 |
|
---|
4197 | %------------------------------------------------------------------------
|
---|
4198 | % --- Executes on selection change in decimate4 (nb_vec/4).
|
---|
4199 | function decimate4_Callback(hObject, eventdata, handles)
|
---|
4200 | %------------------------------------------------------------------------
|
---|
4201 | update_plot(handles);
|
---|
4202 |
|
---|
4203 | %------------------------------------------------------------------------
|
---|
4204 | % --- Executes on selection change in color_code menu
|
---|
4205 | function color_code_Callback(hObject, eventdata, handles)
|
---|
4206 | %------------------------------------------------------------------------
|
---|
4207 | set_vec_col_bar(handles)
|
---|
4208 | update_plot(handles);
|
---|
4209 |
|
---|
4210 | %------------------------------------------------------------------------
|
---|
4211 | % --- Executes on button press in AutoVecColor.
|
---|
4212 | function AutoVecColor_Callback(hObject, eventdata, handles)
|
---|
4213 | %------------------------------------------------------------------------
|
---|
4214 | test=get(handles.AutoVecColor,'Value');
|
---|
4215 | if test
|
---|
4216 | set(handles.AutoVecColor,'BackgroundColor',[1 1 0])
|
---|
4217 | else
|
---|
4218 | update_plot(handles);
|
---|
4219 | %set(handles.VecScale,'String',num2str(ScalOut.VecScale,3))
|
---|
4220 | set(handles.AutoVecColor,'BackgroundColor',[0.7 0.7 0.7])
|
---|
4221 | end
|
---|
4222 |
|
---|
4223 | %------------------------------------------------------------------------
|
---|
4224 | % --- Executes on selection change in max_vec.
|
---|
4225 | function min_vec_Callback(hObject, eventdata, handles)
|
---|
4226 | %------------------------------------------------------------------------
|
---|
4227 | max_vec_Callback(hObject, eventdata, handles)
|
---|
4228 |
|
---|
4229 | %------------------------------------------------------------------------
|
---|
4230 | % --- Executes on selection change in max_vec.
|
---|
4231 | function max_vec_Callback(hObject, eventdata, handles)
|
---|
4232 | %------------------------------------------------------------------------
|
---|
4233 | set(handles.AutoVecColor,'Value',1)
|
---|
4234 | AutoVecColor_Callback(hObject, eventdata, handles)
|
---|
4235 | min_val=str2num(get(handles.min_vec,'String'));
|
---|
4236 | max_val=str2num(get(handles.max_vec,'String'));
|
---|
4237 | slider1=get(handles.slider1,'Value');
|
---|
4238 | slider2=get(handles.slider2,'Value');
|
---|
4239 | colcode1=min_val+(max_val-min_val)*slider1;
|
---|
4240 | colcode2=min_val+(max_val-min_val)*slider2;
|
---|
4241 | set(handles.colcode1,'String',num2str(colcode1))
|
---|
4242 | set(handles.colcode2,'String',num2str(colcode2))
|
---|
4243 | update_plot(handles);
|
---|
4244 |
|
---|
4245 | %------------------------------------------------------------------------
|
---|
4246 | % --- update the display of color code for vectors
|
---|
4247 | function set_vec_col_bar(handles)
|
---|
4248 | %------------------------------------------------------------------------
|
---|
4249 | %get the image of the color display button 'vec_col_bar' in pixels
|
---|
4250 | set(handles.vec_col_bar,'Unit','pixel');
|
---|
4251 | pos_vert=get(handles.vec_col_bar,'Position');
|
---|
4252 | set(handles.vec_col_bar,'Unit','Normalized');
|
---|
4253 | width=ceil(pos_vert(3));
|
---|
4254 | height=ceil(pos_vert(4));
|
---|
4255 |
|
---|
4256 | %get slider indications
|
---|
4257 | list=get(handles.color_code,'String');
|
---|
4258 | ichoice=get(handles.color_code,'Value');
|
---|
4259 | colcode.ColorCode=list{ichoice};
|
---|
4260 | colcode.MinC=str2num(get(handles.min_vec,'String'));
|
---|
4261 | colcode.MaxC=str2num(get(handles.max_vec,'String'));
|
---|
4262 | test3color=strcmp(colcode.ColorCode,'rgb') || strcmp(colcode.ColorCode,'bgr');
|
---|
4263 | if test3color
|
---|
4264 | colcode.colcode1=str2num(get(handles.colcode1,'String'));
|
---|
4265 | colcode.colcode2=str2num(get(handles.colcode2,'String'));
|
---|
4266 | end
|
---|
4267 | % colcode.option=get(handles.vec_col_bar,'Value');
|
---|
4268 | colcode.FixedCbounds=0;
|
---|
4269 | % list_code=get(handles.col_vec,'String');% list menu fields
|
---|
4270 | % index_code=get(handles.col_vec,'Value');% selected string index
|
---|
4271 | % colcode.CName= list_code{index_code(1)}; % selected field used for vector color
|
---|
4272 | colcode.FixedCbounds=1;
|
---|
4273 | vec_C=colcode.MinC+(colcode.MaxC-colcode.MinC)*[0.5:width-0.5]/width;%sample of vec_C values from min to max
|
---|
4274 | [colorlist,col_vec]=set_col_vec(colcode,vec_C);
|
---|
4275 | oneheight=ones(1,height);
|
---|
4276 | A1=colorlist(col_vec,1)*oneheight;
|
---|
4277 | A2=colorlist(col_vec,2)*oneheight;
|
---|
4278 | A3=colorlist(col_vec,3)*oneheight;
|
---|
4279 | A(:,:,1)=A1';
|
---|
4280 | A(:,:,2)=A2';
|
---|
4281 | A(:,:,3)=A3';
|
---|
4282 | set(handles.vec_col_bar,'Cdata',A)
|
---|
4283 |
|
---|
4284 |
|
---|
4285 | %-------------------------------------------------------------------
|
---|
4286 | function update_plot(handles)
|
---|
4287 | %-------------------------------------------------------------------
|
---|
4288 | haxes= handles.axes3;
|
---|
4289 | AxeData=get(haxes,'UserData');
|
---|
4290 | PlotParam=read_plot_param(handles);
|
---|
4291 | [PlotType,PlotParamOut]= plot_field(AxeData,haxes,PlotParam,1);
|
---|
4292 | write_plot_param(handles,PlotParamOut); %update the auto plot parameters
|
---|
4293 |
|
---|
4294 | %-------------------------------------------------------------------
|
---|
4295 | % --- Executes on button press in grid.
|
---|
4296 | function grid_Callback(hObject, eventdata, handles)
|
---|
4297 |
|
---|
4298 |
|
---|
4299 |
|
---|
4300 | %-------------------------------------------------------------------
|
---|
4301 | % --- Executes on selection change in edit.
|
---|
4302 | function edit_Callback(hObject, eventdata, handles)
|
---|
4303 | %-------------------------------------------------------------------
|
---|
4304 | UvData=get(handles.uvmat,'UserData');%read UvData properties stored on the uvmat interface
|
---|
4305 | test=get(handles.edit,'Value');
|
---|
4306 | if test
|
---|
4307 | UvData.MouseAction='edit_object';
|
---|
4308 | set(handles.edit,'BackgroundColor',[1,1,0])
|
---|
4309 | %suppress the other options
|
---|
4310 | set(handles.zoom,'Value',0)
|
---|
4311 | zoom_Callback(hObject, eventdata, handles)
|
---|
4312 | set(handles.edit_vect,'Value',0)
|
---|
4313 | edit_vect_Callback(hObject, eventdata, handles)
|
---|
4314 | %list_object_Callback(hObject, eventdata, handles)
|
---|
4315 | else
|
---|
4316 | UvData.MouseAction='none';
|
---|
4317 | set(handles.edit,'BackgroundColor',[0.7,0.7,0.7])
|
---|
4318 | end
|
---|
4319 | set(handles.uvmat,'UserData',UvData);
|
---|
4320 | hset_object=findobj(allchild(0),'Tag','set_object');
|
---|
4321 | if ~isempty(hset_object)
|
---|
4322 | hhset_object=guidata(hset_object);
|
---|
4323 | if test
|
---|
4324 | set(hhset_object.PLOT,'enable','on');
|
---|
4325 | else
|
---|
4326 | set(hhset_object.PLOT,'enable','off');
|
---|
4327 | end
|
---|
4328 | end
|
---|
4329 |
|
---|
4330 | %------------------------------------------------------------------------
|
---|
4331 | % --- Executes on selection change in list_object_1.
|
---|
4332 | function list_object_1_Callback(hObject, eventdata, handles)
|
---|
4333 | %------------------------------------------------------------------------
|
---|
4334 | list_str=get(handles.list_object_1,'String');
|
---|
4335 | IndexObj=get(handles.list_object_1,'Value');
|
---|
4336 | str_1=list_str{IndexObj};
|
---|
4337 | val_2=get(handles.list_object_2,'Value');
|
---|
4338 | str_2=get(handles.list_object_2,'String');
|
---|
4339 | if isequal(val_2,IndexObj)% if the first selection is equal to the second, it will suppress the second
|
---|
4340 | set(handles.list_object_2,'Value',numel(str_2))%select the end of the list ('...')
|
---|
4341 | list_object_2_Callback(hObject, eventdata, handles)
|
---|
4342 | end
|
---|
4343 | update_object(handles,IndexObj,1,str_1)
|
---|
4344 |
|
---|
4345 | %------------------------------------------------------------------------
|
---|
4346 | % --- Executes on selection change in list_object_1.
|
---|
4347 | function list_object_2_Callback(hObject, eventdata, handles)
|
---|
4348 | %------------------------------------------------------------------------
|
---|
4349 | list_str=get(handles.list_object_2,'String');
|
---|
4350 | IndexObj=get(handles.list_object_2,'Value');
|
---|
4351 | if isequal(list_str{IndexObj},'...')
|
---|
4352 | hview_field=findobj(allchild(0),'Tag','view_field');
|
---|
4353 | if ~isempty(hview_field)
|
---|
4354 | delete(hview_field)
|
---|
4355 | end
|
---|
4356 | else
|
---|
4357 | update_object(handles,IndexObj,2,list_str{IndexObj})
|
---|
4358 | end
|
---|
4359 |
|
---|
4360 | %------------------------------------------------------------------------
|
---|
4361 | function update_object(handles,IndexObj,option,ObjectName)
|
---|
4362 | %------------------------------------------------------------------------
|
---|
4363 | UvData=get(handles.uvmat,'UserData');%read UvData properties stored on the uvmat interface
|
---|
4364 | if ~(length(UvData.Object)>=IndexObj);
|
---|
4365 | return
|
---|
4366 | end
|
---|
4367 | ObjectData=UvData.Object{IndexObj};
|
---|
4368 | ObjectData.Name=ObjectName;
|
---|
4369 | if isequal(get(handles.edit,'Value'),1)
|
---|
4370 | ObjectData.enable_plot=1; % desable the PLOT option in the set_object GUI (editing mode
|
---|
4371 | end
|
---|
4372 | PlotHandles=get_plot_handles(handles);%get the handles of the interface elements setting the plotting parameters
|
---|
4373 | ZBounds=0; % default
|
---|
4374 | if isfield(UvData,'ZMin') && isfield(UvData,'ZMax')
|
---|
4375 | ZBounds(1)=UvData.ZMin; %minimum for the Z slider
|
---|
4376 | ZBounds(2)=UvData.ZMax;%maximum for the Z slider
|
---|
4377 | end
|
---|
4378 | hset_object=findobj(allchild(0),'tag','set_object');
|
---|
4379 | if ~isempty(hset_object)
|
---|
4380 | delete(hset_object)% delete existing version of set_object
|
---|
4381 | end
|
---|
4382 | hset_object=set_object(ObjectData,PlotHandles,ZBounds);% call the set_object interface,
|
---|
4383 | %set(hset_object,'name',ObjectName)
|
---|
4384 |
|
---|
4385 | % %project the current field on the object and plot it
|
---|
4386 | % ProjData= proj_field(UvData.Field,ObjectData,IndexObj);%project the current interface field on ObjectData
|
---|
4387 | % if option==1%length(UvData.Object)>= IndexObj && isfield(UvData.Object{IndexObj},'plotaxes')&& ishandle(UvData.Object{IndexObj}.plotaxes)
|
---|
4388 | % plot_field(ProjData,handles.axes3,PlotHandles);
|
---|
4389 | % UvData.Object{IndexObj}.plotaxes=handles.axes3;
|
---|
4390 | % else
|
---|
4391 | % UvData.Object{IndexObj}.plotaxes=view_field(ProjData);
|
---|
4392 | % end
|
---|
4393 | % set(handles.uvmat,'UserData',UvData)
|
---|
4394 | hother=findobj('Tag','proj_object');%find all the proj objects
|
---|
4395 | for iobj=1:length(hother)
|
---|
4396 | if isequal(get(hother(iobj),'Type'),'rectangle')|isequal(get(hother(iobj),'Type'),'patch')
|
---|
4397 | set(hother(iobj),'EdgeColor','b')
|
---|
4398 | if isequal(get(hother(iobj),'FaceColor'),'m')
|
---|
4399 | set(hother(iobj),'FaceColor','b')
|
---|
4400 | end
|
---|
4401 | elseif isequal(get(hother(iobj),'Type'),'image')
|
---|
4402 | Acolor=get(hother(iobj),'CData');
|
---|
4403 | Acolor(:,:,1)=zeros(size(Acolor,1),size(Acolor,2));
|
---|
4404 | set(hother(iobj),'CData',Acolor);
|
---|
4405 | else
|
---|
4406 | set(hother(iobj),'Color','b')
|
---|
4407 | end
|
---|
4408 | set(hother(iobj),'Selected','off')
|
---|
4409 | end
|
---|
4410 | hother=findobj('Tag','DeformPoint');
|
---|
4411 | set(hother,'Color','b');
|
---|
4412 | set(hother,'Selected','off')
|
---|
4413 | if isfield(ObjectData,'HandlesDisplay')
|
---|
4414 | for iview=1:length(ObjectData.HandlesDisplay)
|
---|
4415 | if ishandle(ObjectData.HandlesDisplay(iview))
|
---|
4416 | uistack(ObjectData.HandlesDisplay(iview),'top')
|
---|
4417 | linetype=get(ObjectData.HandlesDisplay(iview),'Type');
|
---|
4418 | if isequal(linetype,'line')
|
---|
4419 | set(ObjectData.HandlesDisplay(iview),'Color','m'); %set the selected object to magenta color
|
---|
4420 | elseif isequal(linetype,'rectangle')
|
---|
4421 | set(ObjectData.HandlesDisplay(iview),'EdgeColor','m'); %set the selected object to magenta color
|
---|
4422 | elseif isequal(linetype,'patch')
|
---|
4423 | set(ObjectData.HandlesDisplay(iview),'FaceColor','m'); %set the selected object to magenta color
|
---|
4424 | end
|
---|
4425 | SubObjectData=get(ObjectData.HandlesDisplay(iview),'UserData');
|
---|
4426 | if isfield(SubObjectData,'SubObject')& ishandle(SubObjectData.SubObject)
|
---|
4427 | uistack(SubObjectData.SubObject,'top')
|
---|
4428 | for iobj=1:length(SubObjectData.SubObject)
|
---|
4429 | hsub=SubObjectData.SubObject(iobj);
|
---|
4430 | if isequal(get(hsub,'Type'),'rectangle')
|
---|
4431 | set(hsub,'EdgeColor','m'); %set the selected object to magenta color
|
---|
4432 | elseif isequal(get(hsub,'Type'),'image')
|
---|
4433 | Acolor=get(hsub,'CData');
|
---|
4434 | Acolor(:,:,1)=Acolor(:,:,3);
|
---|
4435 | set(hsub,'CData',Acolor);
|
---|
4436 | else
|
---|
4437 | set(hsub,'Color','m')
|
---|
4438 | end
|
---|
4439 | end
|
---|
4440 | end
|
---|
4441 | if isfield(SubObjectData,'DeformPoint')& ishandle(SubObjectData.DeformPoint)
|
---|
4442 | set(SubObjectData.DeformPoint,'Color','m')
|
---|
4443 | end
|
---|
4444 | end
|
---|
4445 | end
|
---|
4446 | end
|
---|
4447 | pause(0.1)
|
---|
4448 | figure(hset_object)%put set_object in front
|
---|
4449 |
|
---|
4450 | %------------------------------------------------------
|
---|
4451 | % --- Executes on button press in Menu/Export/field in workspace.
|
---|
4452 | %------------------------------------------------------
|
---|
4453 | function MenuExportField_Callback(hObject, eventdata, handles)
|
---|
4454 | global Data_uvmat
|
---|
4455 | Data_uvmat=get(handles.uvmat,'UserData');
|
---|
4456 | evalin('base','global Data_uvmat')%make CurData global in the workspace
|
---|
4457 | display('current field :')
|
---|
4458 | evalin('base','Data_uvmat') %display CurData in the workspace
|
---|
4459 | commandwindow; %brings the Matlab command window to the front
|
---|
4460 |
|
---|
4461 | %------------------------------------------------------
|
---|
4462 | % --- Executes on button press in Menu/Export/extract figure.
|
---|
4463 | %------------------------------------------------------
|
---|
4464 | function MenuExport_plot_Callback(hObject, eventdata, handles)
|
---|
4465 | huvmat=get(handles.MenuExport_plot,'parent');
|
---|
4466 | UvData=get(huvmat,'UserData');
|
---|
4467 | hfig=figure;
|
---|
4468 | newaxes=copyobj(handles.axes3,hfig);
|
---|
4469 | map=colormap(handles.axes3);
|
---|
4470 | colormap(map);%transmit the current colormap to the zoom fig
|
---|
4471 | colorbar
|
---|
4472 |
|
---|
4473 |
|
---|
4474 | % --------------------------------------------------------------------
|
---|
4475 | function Insert_Callback(hObject, eventdata, handles)
|
---|
4476 |
|
---|
4477 |
|
---|
4478 | % --------------------------------------------------------------------
|
---|
4479 | function MenuHelp_Callback(hObject, eventdata, handles)
|
---|
4480 | % --------------------------------------------------------------------
|
---|
4481 | path_to_uvmat=which ('uvmat');% check the path of uvmat
|
---|
4482 | pathelp=fileparts(path_to_uvmat);
|
---|
4483 | helpfile=fullfile(pathelp,'uvmat_doc','uvmat_doc.html');
|
---|
4484 | if isempty(dir(helpfile)), msgbox_uvmat('ERROR','Please put the help file uvmat_doc.html in the sub-directory /uvmat_doc of the UVMAT package')
|
---|
4485 | else
|
---|
4486 | addpath (fullfile(pathelp,'uvmat_doc'))
|
---|
4487 | web(helpfile);
|
---|
4488 | end
|
---|
4489 |
|
---|
4490 |
|
---|
4491 | % --------------------------------------------------------------------
|
---|
4492 | function MenuExportMovie_Callback(hObject, eventdata, handles)
|
---|
4493 | % --------------------------------------------------------------------
|
---|
4494 | set(handles.MenuExportMovie,'BusyAction','queue')% activate the button
|
---|
4495 | huvmat=get(handles.run0,'parent');
|
---|
4496 | UvData=get(huvmat,'UserData');
|
---|
4497 | [xx,xx,FileBase]=read_file_boxes(handles);
|
---|
4498 | %read the current input file name
|
---|
4499 | prompt = {'movie file name';'frames per second';'frame resolution (*[512x384] pixels)';'axis position relative to the frame';'total frame number (starting from the current uvmat display)'};
|
---|
4500 | dlg_title = 'select properties of the output avi movie';
|
---|
4501 | num_lines= 1;
|
---|
4502 | % nbfield_cell=get(handles.last_i,'String');
|
---|
4503 | def = {[FileBase '_out.avi'];'10';'1';'[0.03 0.05 0.95 0.92]';'10'};
|
---|
4504 | answer = inputdlg(prompt,dlg_title,num_lines,def,'on');
|
---|
4505 | aviname=answer{1};
|
---|
4506 | fps=str2double(answer{2});
|
---|
4507 | % check for existing file with output name aviname
|
---|
4508 | if exist(aviname,'file')
|
---|
4509 | backup=aviname;
|
---|
4510 | testexist=2;
|
---|
4511 | while testexist==2
|
---|
4512 | backup=[backup '~'];
|
---|
4513 | testexist=exist(backup,'file');
|
---|
4514 | end
|
---|
4515 | [success,message]=copyfile(aviname,backup);%make backup of the existing file
|
---|
4516 | if isequal(success,1)
|
---|
4517 | delete(aviname)%delete existing file
|
---|
4518 | else
|
---|
4519 | msgbox_uvmat('ERROR',message)
|
---|
4520 | return
|
---|
4521 | end
|
---|
4522 | end
|
---|
4523 | %create avi open
|
---|
4524 | aviobj=avifile(aviname,'Compression','None','fps',fps);
|
---|
4525 |
|
---|
4526 | %display first view for tests
|
---|
4527 | newfig=figure;
|
---|
4528 | newaxes=copyobj(handles.axes3,newfig);%new plotting axes in the new figure
|
---|
4529 | set(newaxes,'Tag','movieaxes')
|
---|
4530 | nbpix=[512 384]*str2double(answer{3});
|
---|
4531 | set(gcf,'Position',[1 1 nbpix])% resolution XVGA
|
---|
4532 | set(newaxes,'Position',eval(answer{4}));
|
---|
4533 | map=colormap(handles.axes3);
|
---|
4534 | colormap(map);%transmit the current colormap to the zoom fig
|
---|
4535 | msgbox_uvmat('INPUT_Y-N',{['adjust figure ' num2str(newfig) ' with its matlab edit menu '] ;...
|
---|
4536 | ['then press OK to get the avi movie as a copy of figure ' num2str(newfig) ' display']});
|
---|
4537 | UvData.Object{1}.plotaxes=newaxes;% the axis in the new figure becomes the current main plotting axes
|
---|
4538 | set(huvmat,'UserData',UvData);
|
---|
4539 | increment=str2double(get(handles.increment_scan,'String')); %get the field increment d
|
---|
4540 | if isnan(increment)
|
---|
4541 | set(handles.increment_scan,'String','1')%default value
|
---|
4542 | increment=1;
|
---|
4543 | end
|
---|
4544 | set(handles.STOP,'Visible','on')
|
---|
4545 | set(handles.speed,'Visible','on')
|
---|
4546 | set(handles.speed_txt,'Visible','on')
|
---|
4547 | set(handles.Movie,'BusyAction','queue')
|
---|
4548 |
|
---|
4549 | %imin=str2double(get(handles.i1,'String'));
|
---|
4550 | imax=str2double(answer{5});
|
---|
4551 | % if isfield(UvData,'Time')
|
---|
4552 | htitle=get(newaxes,'Title');
|
---|
4553 | xlim=get(newaxes,'XLim');
|
---|
4554 | ylim=get(newaxes,'YLim');
|
---|
4555 | set(htitle,'Position',[xlim(2)+0.07*(xlim(2)-xlim(1)) ylim(2)-0.05*(ylim(2)-ylim(1)) 0])
|
---|
4556 | time_str=get(handles.abs_time,'String');
|
---|
4557 | set(htitle,'String',['t=' time_str])
|
---|
4558 | set(handles.speed,'Value',1)
|
---|
4559 | for i=1:imax
|
---|
4560 | if get(handles.speed,'Value')~=0 && isequal(get(handles.MenuExportMovie,'BusyAction'),'queue') % enable STOP command
|
---|
4561 | runpm(hObject,eventdata,handles,increment)% run plus
|
---|
4562 | drawnow
|
---|
4563 | time_str=get(handles.abs_time,'String');
|
---|
4564 | if ishandle(htitle)
|
---|
4565 | set(htitle,'String',['t=' time_str])
|
---|
4566 | end
|
---|
4567 | mov=getframe(newfig);
|
---|
4568 | aviobj=addframe(aviobj,mov);
|
---|
4569 | end
|
---|
4570 | end
|
---|
4571 | close(aviobj);
|
---|
4572 | UvData.Object{1}.plotaxes=handles.axes3;
|
---|
4573 | set(huvmat,'UserData',UvData);
|
---|
4574 | msgbox_uvmat('CONFIRMATION',{['movie ' aviname ' created '];['with ' num2str(imax) ' frames']})
|
---|
4575 |
|
---|
4576 |
|
---|
4577 | % ------------------------------------------------------------------
|
---|
4578 | function MenuCalib_Callback(hObject, eventdata, handles)
|
---|
4579 |
|
---|
4580 | UvData=get(handles.uvmat,'UserData');%read UvData properties stored on the uvmat interface
|
---|
4581 |
|
---|
4582 | %suppress competing options
|
---|
4583 | set(handles.zoom,'Value',0)
|
---|
4584 | set(handles.zoom,'BackgroundColor',[0.7 0.7 0.7])
|
---|
4585 | set(handles.MenuMask,'enable','off')
|
---|
4586 | set(handles.MenuGrid,'enable','off')
|
---|
4587 | set(handles.MenuObject,'enable','off')
|
---|
4588 | set(handles.MenuEdit,'enable','off')
|
---|
4589 | set(handles.list_object_1,'Value',1)
|
---|
4590 | % initiate display of GUI geometry_calib
|
---|
4591 | data=[]; %default
|
---|
4592 | if isfield(UvData,'CoordType')
|
---|
4593 | data.CoordType=UvData.CoordType;
|
---|
4594 | end
|
---|
4595 | pos=get(handles.uvmat,'Position');
|
---|
4596 | pos(1)=pos(1)+pos(3)-0.311+0.04; %0.311= width of the geometry_calib interface (units relative to the srcreen)
|
---|
4597 | pos(2)=pos(2)-0.02;
|
---|
4598 | [FileName,RootPath,FileBase,FileIndices,FileExt,SubDir]=read_file_boxes(handles);
|
---|
4599 | [UvData.hset_object,UvData.sethandles]=geometry_calib(FileName,pos);% call the geometry_calib interface
|
---|
4600 | pos_uvmat=get(handles.uvmat,'Position');
|
---|
4601 |
|
---|
4602 | if isfield(UvData,'CalOrigin')
|
---|
4603 | pos_cal(1)=pos_uvmat(1)+UvData.CalOrigin(1)*pos_uvmat(3);
|
---|
4604 | pos_cal(2)=pos_uvmat(2)+UvData.CalOrigin(2)*pos_uvmat(4);
|
---|
4605 | pos_cal(3:4)=UvData.CalSize .* pos_uvmat(3:4);
|
---|
4606 | set(UvData.hset_object,'Position',pos_cal)
|
---|
4607 | end
|
---|
4608 | UvData.MouseAction='calib';
|
---|
4609 | set(handles.uvmat,'UserData',UvData);
|
---|
4610 |
|
---|
4611 |
|
---|
4612 | % ------------------------------------------------------------------
|
---|
4613 | function MenuMask_Callback(hObject, eventdata, handles)
|
---|
4614 | % set(handles.TOOLS_txt,'Visible','on')
|
---|
4615 | % set(handles.frame_tools,'Visible','on')
|
---|
4616 | % % set(handles.create,'Visible','on')
|
---|
4617 | % % set(handles.create,'Value',1)
|
---|
4618 | % % set(handles.create,'BackgroundColor',[1 1 0]) %visualise in yellow
|
---|
4619 | % set(handles.save_mask,'Visible','on')
|
---|
4620 | % set(handles.masklevel,'Visible','on')
|
---|
4621 | % if isequal(get(handles.z_index,'Visible'),'on')
|
---|
4622 | % nb_slice=str2num(get(handles.nb_slice,'String'));
|
---|
4623 | % for ilist=1:nb_slice
|
---|
4624 | % list_index{ilist,1}=num2str(ilist);
|
---|
4625 | % end
|
---|
4626 | % set(handles.masklevel,'String',list_index)
|
---|
4627 | % val=str2num(get(handles.z_index,'String'));
|
---|
4628 | % if val<=nb_slice
|
---|
4629 | % set(handles.masklevel,'Value',val)
|
---|
4630 | % end
|
---|
4631 | % else
|
---|
4632 | % set(handles.masklevel,'String',{'1'})
|
---|
4633 | % set(handles.masklevel,'Value',1)
|
---|
4634 | % end
|
---|
4635 | % if ishandle(handles.UVMAT_title)
|
---|
4636 | % delete(handles.UVMAT_title)
|
---|
4637 | % end
|
---|
4638 | UvData=get(handles.uvmat,'UserData');%read UvData properties stored on the uvmat interface
|
---|
4639 | % set(handles.zoom,'Value',0)
|
---|
4640 | % set(handles.zoom,'BackgroundColor',[0.7 0.7 0.7])
|
---|
4641 | % set(handles.edit_vect,'Value',0)
|
---|
4642 | % edit_vect_Callback(hObject, eventdata, handles)
|
---|
4643 | % set(handles.edit,'Value',0)
|
---|
4644 | % set(handles.edit,'BackgroundColor',[0.7 0.7 0.7])
|
---|
4645 | % set(handles.edit_vect,'Value',0)
|
---|
4646 | % edit_vect_Callback(hObject, eventdata, handles)
|
---|
4647 | % set(handles.cal,'Value',0)
|
---|
4648 | % set(handles.cal,'BackgroundColor',[0 1 0])
|
---|
4649 |
|
---|
4650 | %initiate the GUI set_object
|
---|
4651 | % data.TITLE='MASK';
|
---|
4652 | % if isfield(UvData,'CoordType')
|
---|
4653 | % data.CoordType=UvData.CoordType;
|
---|
4654 | % end
|
---|
4655 | % if isfield(UvData,'Mesh')&&~isempty(UvData.Mesh)
|
---|
4656 | % data.YMax=UvData.Mesh;
|
---|
4657 | % elseif isfield(UvData.Field,'AX')&&isfield(UvData.Field,'AY')&& isfield(UvData.Field,'A')%only image
|
---|
4658 | % np=size(UvData.Field.A);
|
---|
4659 | % meshx=(UvData.Field.AX(end)-UvData.Field.AX(1))/(np(2)-1);
|
---|
4660 | % meshy=abs(UvData.Field.AY(end)-UvData.Field.AY(1))/(np(1)-1);
|
---|
4661 | % data.YMax=max(meshx,meshy);
|
---|
4662 | % data.DX=max(meshx,meshy);
|
---|
4663 | % end
|
---|
4664 | % data.Coord=[0 0 0]; %default
|
---|
4665 | % PlotHandles=get_plot_handles(handles);%get the handles of the graphic objects setting the plotting parameters
|
---|
4666 | % [hset_object,UvData.sethandles]=set_object(data,PlotHandles);% call the set_object interface
|
---|
4667 | % pos_uvmat=get(handles.uvmat,'Position');
|
---|
4668 | % if isfield(UvData,'SetObjectOrigin')
|
---|
4669 | % pos_set_object(1:2)=UvData.SetObjectOrigin + pos_uvmat(1:2);
|
---|
4670 | % pos_set_object(3:4)=UvData.SetObjectSize .* pos_uvmat(3:4);
|
---|
4671 | % set(hset_object,'Position',pos_set_object)
|
---|
4672 | % end
|
---|
4673 | ListObj=UvData.Object;
|
---|
4674 | select=zeros(1,numel(ListObj));
|
---|
4675 | for iobj=1:numel(ListObj);
|
---|
4676 | if strcmp(ListObj{iobj}.ProjMode,'mask_inside')||strcmp(ListObj{iobj}.ProjMode,'mask_outside')
|
---|
4677 | select(iobj)=1;
|
---|
4678 | end
|
---|
4679 | end
|
---|
4680 | val=find(select);
|
---|
4681 | if isempty(val)
|
---|
4682 | msgbox_uvmat('ERROR','polygons must be first created by Projection object/mask polygon in the menu bar');
|
---|
4683 | return
|
---|
4684 | else
|
---|
4685 | set(handles.list_object_1,'Max',2);%allow multiple selection
|
---|
4686 | set(handles.list_object_1,'Value',val);
|
---|
4687 | % answer=msgbox_uvmat('INPUT_Y-N',['make the mask image from ' num2str(numel(val)) ' polygons']);
|
---|
4688 | % if ~isempty(answer)
|
---|
4689 | flag=1;
|
---|
4690 | npx=size(UvData.Field.A,2);
|
---|
4691 | npy=size(UvData.Field.A,1);
|
---|
4692 | xi=0.5:npx-0.5;
|
---|
4693 | yi=0.5:npy-0.5;
|
---|
4694 | [Xi,Yi]=meshgrid(xi,yi);
|
---|
4695 | if isfield(UvData,'Object')
|
---|
4696 | for iobj=1:length(UvData.Object)
|
---|
4697 | ObjectData=UvData.Object{iobj};
|
---|
4698 | if isfield(ObjectData,'ProjMode') &&(isequal(ObjectData.ProjMode,'mask_inside')||isequal(ObjectData.ProjMode,'mask_outside'));
|
---|
4699 | flagobj=1;
|
---|
4700 | testphys=0; %coordinates in pixels by default
|
---|
4701 | if isfield(ObjectData,'CoordType') && isequal(ObjectData.CoordType,'phys')
|
---|
4702 | if isfield(UvData,'XmlData')&& isfield(UvData.XmlData,'GeometryCalib')
|
---|
4703 | Calib=UvData.XmlData.GeometryCalib;
|
---|
4704 | testphys=1;
|
---|
4705 | end
|
---|
4706 | end
|
---|
4707 | if isfield(ObjectData,'Coord')& isfield(ObjectData,'Style')
|
---|
4708 | if isequal(ObjectData.Style,'polygon')
|
---|
4709 | X=ObjectData.Coord(:,1);
|
---|
4710 | Y=ObjectData.Coord(:,2);
|
---|
4711 | if testphys
|
---|
4712 | [X,Y]=px_XYZ(Calib,X,Y,0);% to generalise with 3D cases
|
---|
4713 | end
|
---|
4714 | flagobj=~inpolygon(Xi,Yi,X',Y');%=0 inside the polygon, 1 outside
|
---|
4715 | elseif isequal(ObjectData.Style,'ellipse')
|
---|
4716 | if testphys
|
---|
4717 | %[X,Y]=px_XYZ(Calib,X,Y,0);% TODO:create a polygon boundary and transform to phys
|
---|
4718 | end
|
---|
4719 | RangeX=max(ObjectData.RangeX);
|
---|
4720 | RangeY=max(ObjectData.RangeY);
|
---|
4721 | X2Max=RangeX*RangeX;
|
---|
4722 | Y2Max=RangeY*RangeY;
|
---|
4723 | distX=(Xi-ObjectData.Coord(1,1));
|
---|
4724 | distY=(Yi-ObjectData.Coord(1,2));
|
---|
4725 | flagobj=(distX.*distX/X2Max+distY.*distY/Y2Max)>1;
|
---|
4726 | elseif isequal(ObjectData.Style,'rectangle')
|
---|
4727 | if testphys
|
---|
4728 | %[X,Y]=px_XYZ(Calib,X,Y,0);% TODO:create a polygon boundary and transform to phys
|
---|
4729 | end
|
---|
4730 | distX=abs(Xi-ObjectData.Coord(1,1));
|
---|
4731 | distY=abs(Yi-ObjectData.Coord(1,2));
|
---|
4732 | flagobj=distX>max(ObjectData.RangeX) | distY>max(ObjectData.RangeY);
|
---|
4733 | end
|
---|
4734 | if isequal(ObjectData.ProjMode,'mask_outside')
|
---|
4735 | flagobj=~flagobj;
|
---|
4736 | end
|
---|
4737 | flag=flag & flagobj;
|
---|
4738 | end
|
---|
4739 | end
|
---|
4740 | end
|
---|
4741 | end
|
---|
4742 | % flag=~flag;
|
---|
4743 | %mask name
|
---|
4744 | RootPath=get(handles.RootPath,'String');
|
---|
4745 | RootFile=get(handles.RootFile,'String');
|
---|
4746 | if ~isempty(RootFile)&(isequal(RootFile(1),'/')| isequal(RootFile(1),'\'))
|
---|
4747 | RootFile(1)=[];
|
---|
4748 | end
|
---|
4749 | filebase=fullfile(RootPath,RootFile);
|
---|
4750 | list=get(handles.masklevel,'String');
|
---|
4751 | masknumber=num2str(length(list));
|
---|
4752 | maskindex=get(handles.masklevel,'Value');
|
---|
4753 | mask_name=name_generator([filebase '_' masknumber 'mask'],maskindex,1,'.png','_i');
|
---|
4754 | imflag=uint8(255*(0.392+0.608*flag));% =100 for flag=0 (vectors not computed when 20<imflag<200)
|
---|
4755 | imflag=flipdim(imflag,1);
|
---|
4756 | % imflag=uint8(255*flag);% =0 for flag=0 (vectors=0 when
|
---|
4757 | % 20<imflag<200)
|
---|
4758 |
|
---|
4759 | %display the mask
|
---|
4760 | %update_mask(handles,num_i1,num_j1)
|
---|
4761 | figure;
|
---|
4762 | vec=linspace(0,1,256);%define a linear greyscale colormap
|
---|
4763 | map=[vec' vec' vec'];
|
---|
4764 | colormap(map)
|
---|
4765 | image(imflag);
|
---|
4766 | answer=msgbox_uvmat('INPUT_TXT','mask file name:', mask_name);
|
---|
4767 | if ~strcmp(answer,'Cancel')
|
---|
4768 | imwrite(imflag,answer,'BitDepth',8);
|
---|
4769 | end
|
---|
4770 | set(handles.list_object_1,'Value',1)
|
---|
4771 | set(handles.list_object_1,'Max',1)
|
---|
4772 | % end
|
---|
4773 | end
|
---|
4774 |
|
---|
4775 |
|
---|
4776 | % UvData.MouseAction='create_object';
|
---|
4777 | set(handles.uvmat,'UserData',UvData);
|
---|
4778 |
|
---|
4779 | % ------------------------------------------------------------------
|
---|
4780 | %-- open the GUI set_grid.fig to create grid
|
---|
4781 | function MenuGrid_Callback(hObject, eventdata, handles)
|
---|
4782 | %UvData=get(handles.uvmat,'UserData');%read UvData properties stored on the uvmat interface
|
---|
4783 |
|
---|
4784 | %suppress the other options if grid is chosen
|
---|
4785 | set(handles.edit_vect,'Value',0)
|
---|
4786 | edit_vect_Callback(hObject, eventdata, handles)
|
---|
4787 | set(handles.edit,'BackgroundColor',[0.7 0.7 0.7])
|
---|
4788 | set(handles.list_object_1,'Value',1)
|
---|
4789 |
|
---|
4790 | %prepare display of the set_grid GUI
|
---|
4791 | FileName=read_file_boxes(handles);
|
---|
4792 | CoordList=get(handles.transform_fct,'String');
|
---|
4793 | val=get(handles.transform_fct,'Value');
|
---|
4794 | set_grid(FileName,CoordList{val});% call the set_object interface
|
---|
4795 | %set(handles.uvmat,'UserData',UvData);
|
---|
4796 |
|
---|
4797 | %----------------------------------------------------------------
|
---|
4798 | % open the GUI 'series'
|
---|
4799 | %----------------------------------------------------------------
|
---|
4800 | function MenuSeries_Callback(hObject, eventdata, handles)
|
---|
4801 | %-------------------------------------------------------------------
|
---|
4802 |
|
---|
4803 | [param.FileName]=read_file_boxes(handles);
|
---|
4804 | if isequal(get(handles.SubField,'Value'),1)
|
---|
4805 | FileName_1=read_file_boxes_1(handles);%
|
---|
4806 | if ~isequal(FileName_1,param.FileName)
|
---|
4807 | param.FileName_1=FileName_1;
|
---|
4808 | end
|
---|
4809 | end
|
---|
4810 | param.NomType=get(handles.FileIndex,'UserData');
|
---|
4811 | param.NomType_1=get(handles.FileIndex_1,'UserData');
|
---|
4812 | param.comp_input=get(handles.fix_pair,'Value');
|
---|
4813 | huvmat=get(handles.MenuSeries,'parent');
|
---|
4814 | UvData=get(huvmat,'UserData');
|
---|
4815 | if isfield(UvData,'Time')
|
---|
4816 | param.Time=UvData.XmlData.Time;
|
---|
4817 | end
|
---|
4818 | if isequal(get(handles.scan_i,'Value'),1)
|
---|
4819 | param.incr_i=str2double(get(handles.increment_scan,'String'));
|
---|
4820 | elseif isequal(get(handles.scan_j,'Value'),1)
|
---|
4821 | param.incr_j=str2double(get(handles.increment_scan,'String'));
|
---|
4822 | end
|
---|
4823 | param.list_fields=get(handles.Fields,'String');% list menu fields
|
---|
4824 | param.list_fields(1)=[]; %suppress 'image' option
|
---|
4825 | param.index_fields=get(handles.Fields,'Value');% selected string index
|
---|
4826 | if param.index_fields>1
|
---|
4827 | param.index_fields=param.index_fields-1;
|
---|
4828 | end
|
---|
4829 | param.list_fields_1=get(handles.Fields_1,'String');% list menu fields
|
---|
4830 | param.list_fields_1(1)=[]; %suppress 'image' option
|
---|
4831 | param.index_fields_1=get(handles.Fields_1,'Value')-1;% selected string index
|
---|
4832 | if param.index_fields_1>1
|
---|
4833 | param.index_fields_1=param.index_fields_1-1;
|
---|
4834 | end
|
---|
4835 | param.civ1=get(handles.civ1,'Value');
|
---|
4836 | param.civ2=get(handles.civ2,'Value');
|
---|
4837 | param.interp1=get(handles.interp1,'Value');
|
---|
4838 | param.interp2=get(handles.interp2,'Value');
|
---|
4839 | param.filter1=get(handles.filter1,'Value');
|
---|
4840 | param.filter2=get(handles.filter2,'Value');
|
---|
4841 | param.menu_coord_str=get(handles.transform_fct,'String');
|
---|
4842 | param.menu_coord_val=get(handles.transform_fct,'Value');
|
---|
4843 |
|
---|
4844 | series(param); %run the series interface
|
---|
4845 |
|
---|
4846 | % ------------------------------------------------------------------
|
---|
4847 | % -- open the GUI civ.fig for civx (PIV)
|
---|
4848 | % ------------------------------------------------------------------
|
---|
4849 | function MenuPIV_Callback(hObject, eventdata, handles)
|
---|
4850 |
|
---|
4851 | [FileName,RootPath,filebase,FileIndices,ext,SubDir]=read_file_boxes(handles);
|
---|
4852 | num1=stra2num(get(handles.i1,'String'));
|
---|
4853 | num2=stra2num(get(handles.i2,'String'));
|
---|
4854 | num_a=stra2num(get(handles.j1,'String'));
|
---|
4855 | num_b=stra2num(get(handles.j2,'String'));
|
---|
4856 | NomType=get(handles.FileIndex,'UserData');
|
---|
4857 | ind_opening=1; % default (images): will advice civ1 option by default in the civ interface
|
---|
4858 | if isequal(ext,'.nc') || isequal(ext,'.cdf')% netcdf files
|
---|
4859 | ind_opening=2;% propose 'fix' as the default option
|
---|
4860 | % +read the current netcdf rootfile
|
---|
4861 | Data=nc2struct(FileName,[]);
|
---|
4862 | if isfield(Data,'fix') & isequal(Data.fix,1)
|
---|
4863 | ind_opening=3;
|
---|
4864 | end
|
---|
4865 | if isfield(Data,'patch') & isequal(Data.patch,1)
|
---|
4866 | ind_opening=4;
|
---|
4867 | end
|
---|
4868 | if isfield(Data,'civ2') & isequal(Data.civ2,1)
|
---|
4869 | ind_opening=5;
|
---|
4870 | end
|
---|
4871 | if isfield(Data,'fix2') & isequal(Data.fix2,1)
|
---|
4872 | ind_opening=6;
|
---|
4873 | end
|
---|
4874 | end
|
---|
4875 | param.RootName=filebase;
|
---|
4876 | param.NomType=NomType;
|
---|
4877 | param.num1=num1;
|
---|
4878 | param.num2=num2;
|
---|
4879 | param.num_a=num_a;
|
---|
4880 | param.num_b=num_b;
|
---|
4881 | param.SubDir=SubDir;
|
---|
4882 | param.IndOpening=ind_opening;% A REVOIR +TRANSMETTRE IMADOC INFO
|
---|
4883 | param.ImaExt=ext;
|
---|
4884 | civ(param);% interface de civ(not in the uvmat file)
|
---|
4885 |
|
---|
4886 | % ------------------------------------------------------------------
|
---|
4887 | function MenuTools_Callback(hObject, eventdata, handles)
|
---|
4888 |
|
---|
4889 | % ------------------------------------------------------------------
|
---|
4890 | function MenuEditObject_Callback(hObject, eventdata, handles)
|
---|
4891 | set(handles.edit,'Value',1)
|
---|
4892 | edit_Callback(hObject, eventdata, handles)
|
---|
4893 |
|
---|
4894 | %--------------------------------------------------------------------------
|
---|
4895 | function enable_transform(handles,state)
|
---|
4896 | set(handles.transform_fct,'Visible',state)
|
---|
4897 | set(handles.TRANSFORM_txt,'Visible',state)
|
---|
4898 | set(handles.transform_fct,'Visible',state)
|
---|
4899 | set(handles.path_transform,'Visible',state)
|
---|
4900 | set(handles.pxcmx_txt,'Visible',state)
|
---|
4901 | set(handles.pxcmy_txt,'Visible',state)
|
---|
4902 | set(handles.pxcm,'Visible',state)
|
---|
4903 | set(handles.pycm,'Visible',state)
|
---|
4904 |
|
---|
4905 | %------------------------------------------------------------------------
|
---|
4906 | function MenuEditVectors_Callback(hObject, eventdata, handles)
|
---|
4907 | %------------------------------------------------------------------------
|
---|
4908 | set(handles.edit_vect,'Visible','on')
|
---|
4909 | set(handles.edit_vect,'Value',1)
|
---|
4910 | edit_vect_Callback(hObject, eventdata, handles)
|
---|
4911 |
|
---|
4912 | % --------------------------------------------------------------------
|
---|
4913 | function Menupoints_Callback(hObject, eventdata, handles)
|
---|
4914 | data.Style='points';
|
---|
4915 | data.ProjMode='projection';%default
|
---|
4916 | create_object(data,handles)
|
---|
4917 |
|
---|
4918 | % --------------------------------------------------------------------
|
---|
4919 | function Menuline_Callback(hObject, eventdata, handles)
|
---|
4920 | % set(handles.create,'Visible','on')
|
---|
4921 | % set(handles.create,'Value',1)
|
---|
4922 | % LINE_Callback(hObject,eventdata,handles)
|
---|
4923 | data.Style='line';
|
---|
4924 | data.ProjMode='projection';%default
|
---|
4925 | create_object(data,handles)
|
---|
4926 |
|
---|
4927 | %------------------------------------------------------------------------
|
---|
4928 | function Menupolyline_Callback(hObject, eventdata, handles)
|
---|
4929 | %------------------------------------------------------------------------
|
---|
4930 | data.Style='polyline';
|
---|
4931 | data.ProjMode='projection';%default
|
---|
4932 | create_object(data,handles)
|
---|
4933 |
|
---|
4934 | %------------------------------------------------------------------------
|
---|
4935 | function Menupolygon_Callback(hObject, eventdata, handles)
|
---|
4936 | %------------------------------------------------------------------------
|
---|
4937 | data.Style='polygon';
|
---|
4938 | data.ProjMode='inside';%default
|
---|
4939 | create_object(data,handles)
|
---|
4940 |
|
---|
4941 | %------------------------------------------------------------------------
|
---|
4942 | function Menurectangle_Callback(hObject, eventdata, handles)
|
---|
4943 | %------------------------------------------------------------------------
|
---|
4944 | data.Style='rectangle';
|
---|
4945 | data.ProjMode='inside';%default
|
---|
4946 | create_object(data,handles)
|
---|
4947 |
|
---|
4948 | %------------------------------------------------------------------------
|
---|
4949 | function Menuellipse_Callback(hObject, eventdata, handles)
|
---|
4950 | %------------------------------------------------------------------------
|
---|
4951 | data.Style='ellipse';
|
---|
4952 | data.ProjMode='inside';%default
|
---|
4953 | create_object(data,handles)
|
---|
4954 |
|
---|
4955 | %------------------------------------------------------------------------
|
---|
4956 | function MenuMaskObject_Callback(hObject, eventdata, handles)
|
---|
4957 | %------------------------------------------------------------------------
|
---|
4958 | data.Style='polygon';
|
---|
4959 | data.StyleMenu={'polygon'};
|
---|
4960 | data.ProjMode='mask_inside';%default
|
---|
4961 | data.ProjMenu={'mask_inside';'mask_outside'};
|
---|
4962 | create_object(data,handles)
|
---|
4963 |
|
---|
4964 | % ------------------------------------------------------------------
|
---|
4965 | function Menuplane_Callback(hObject, eventdata, handles)
|
---|
4966 | data.Style='plane';
|
---|
4967 | data.ProjMode='projection';%default
|
---|
4968 |
|
---|
4969 | create_object(data,handles)
|
---|
4970 |
|
---|
4971 | % ------------------------------------------------------------------
|
---|
4972 | function Menuvolume_Callback(hObject, eventdata, handles)
|
---|
4973 | data.Style='volume';
|
---|
4974 | data.ProjMode='interp';%default
|
---|
4975 | % set(handles.create,'Visible','on')
|
---|
4976 | % set(handles.create,'Value',1)
|
---|
4977 | % VOLUME_Callback(hObject,eventdata,handles)
|
---|
4978 | create_object(data,handles)
|
---|
4979 |
|
---|
4980 | %------------------------------------------------------------------------
|
---|
4981 | function MenuBrowseObject_Callback(hObject, eventdata, handles)
|
---|
4982 | %------------------------------------------------------------------------
|
---|
4983 | %get the object file
|
---|
4984 | [FileName, PathName, filterindex] = uigetfile( ...
|
---|
4985 | {'*.xml;*.mat', ' (*.xml,*.mat)';
|
---|
4986 | '*.xml', '.xml files '; ...
|
---|
4987 | '*.mat', '.mat matlab files '}, ...
|
---|
4988 | 'Pick an xml Object file',get(handles.RootPath,'String'));
|
---|
4989 | fileinput=[PathName FileName];%complete file name
|
---|
4990 | testblank=findstr(fileinput,' ');%look for blanks
|
---|
4991 | if ~isempty(testblank)
|
---|
4992 | msgbox_uvmat('ERROR','forbidden input file name: contain blanks')
|
---|
4993 | return
|
---|
4994 | end
|
---|
4995 | sizf=size(fileinput);
|
---|
4996 | if (~ischar(fileinput)||~isequal(sizf(1),1)),return;end
|
---|
4997 |
|
---|
4998 | %read the file
|
---|
4999 | t=xmltree(fileinput);
|
---|
5000 | data=convert(t);
|
---|
5001 | data.enable_plot=1;
|
---|
5002 | [pp,data.Name]=fileparts(FileName);
|
---|
5003 | %PlotHandles=get_plot_handles(handles);%get the handles of the interface elements setting the plotting parameters
|
---|
5004 | hset_object=findobj(allchild(0),'tag','set_object');
|
---|
5005 | if ~isempty(hset_object)
|
---|
5006 | delete(hset_object)% delete existing version of set_object
|
---|
5007 | end
|
---|
5008 | UvData=get(handles.uvmat,'UserData');
|
---|
5009 | [hset_object,UvData.sethandles]=set_object(data);% call the set_object interface
|
---|
5010 | % %position the set_object GUI with respect to uvmat
|
---|
5011 | % pos_uvmat=get(handles.uvmat,'Position');
|
---|
5012 | % if isfield(UvData,'SetObjectOrigin')
|
---|
5013 | % pos_set_object(1:2)=UvData.SetObjectOrigin + pos_uvmat(1:2);
|
---|
5014 | % pos_set_object(3:4)=UvData.SetObjectSize .* pos_uvmat(3:4);
|
---|
5015 | % set(hset_object,'Position',pos_set_object)
|
---|
5016 | % end
|
---|
5017 | set(handles.edit,'Value',0); %suppress the object edit mode
|
---|
5018 | set(handles.edit,'BackgroundColor',[0.7,0.7,0.7])
|
---|
5019 | UvData.MouseAction='create_object';
|
---|
5020 | set(handles.uvmat,'UserData',UvData)
|
---|
5021 | set(handles.delete_object,'Visible','on')
|
---|
5022 | set(handles.uvmat_title,'Visible','on')
|
---|
5023 | set(handles.view_field_title,'Visible','on')
|
---|
5024 |
|
---|
5025 | %------------------------------------------------------------------------
|
---|
5026 | % --- generic function used for the creation of a projection object
|
---|
5027 | function create_object(data,handles)
|
---|
5028 | %------------------------------------------------------------------------
|
---|
5029 | hset_object=findobj(allchild(0),'tag','set_object');
|
---|
5030 | if ~isempty(hset_object)
|
---|
5031 | delete(hset_object)% delete existing version of set_object
|
---|
5032 | end
|
---|
5033 | UvData=get(handles.uvmat,'UserData');
|
---|
5034 | set(handles.edit,'Value',0); %suppress the object edit mode
|
---|
5035 | set(handles.edit,'BackgroundColor',[0.7,0.7,0.7])
|
---|
5036 | data.enable_plot=1;
|
---|
5037 | transform_list=get(handles.transform_fct,'String');
|
---|
5038 | val=get(handles.transform_fct,'Value');
|
---|
5039 | data.CoordType=transform_list{val};
|
---|
5040 | % if isfield(UvData,'CoordType')
|
---|
5041 | % data.CoordType=UvData.CoordType;
|
---|
5042 | % end
|
---|
5043 | if isfield(UvData,'Mesh')&&~isempty(UvData.Mesh)
|
---|
5044 | data.RangeX=UvData.Mesh;
|
---|
5045 | data.RangeY=UvData.Mesh;
|
---|
5046 | data.DX=UvData.Mesh;
|
---|
5047 | data.DY=UvData.Mesh;
|
---|
5048 | elseif isfield(UvData.Field,'AX')&& isfield(UvData.Field,'AY')&& isfield(UvData.Field,'A')%only image
|
---|
5049 | np=size(UvData.Field.A);
|
---|
5050 | meshx=(UvData.Field.AX(end)-UvData.Field.AX(1))/np(2);
|
---|
5051 | meshy=abs(UvData.Field.AY(end)-UvData.Field.AY(1))/np(1);
|
---|
5052 | data.RangeY=max(meshx,meshy);
|
---|
5053 | data.RangeX=max(meshx,meshy);
|
---|
5054 | data.DX=max(meshx,meshy);
|
---|
5055 | end
|
---|
5056 | if isfield(UvData,'NbDim')
|
---|
5057 | data.NbDim=UvData.NbDim;
|
---|
5058 | end
|
---|
5059 | data.Coord=[0 0 0]; %default
|
---|
5060 | if isfield(data,'Style') && isequal(data.Style,'line')
|
---|
5061 | if isfield(data,'DX')
|
---|
5062 | data.Coord=[[0 0 0];[data.DX 0 0]]; %default
|
---|
5063 | else
|
---|
5064 | data.Coord=[[0 0 0];[1 0 0]]; %default
|
---|
5065 | end
|
---|
5066 | end
|
---|
5067 | %data.ParentButton=handles.create;
|
---|
5068 | if ishandle(handles.UVMAT_title)
|
---|
5069 | delete(handles.UVMAT_title)%delete the initial display of uvmat if no field has been entered
|
---|
5070 | end
|
---|
5071 | PlotHandles=get_plot_handles(handles);%get the handles of the interface elements setting the plotting parameters
|
---|
5072 | [hset_object,UvData.sethandles]=set_object(data,PlotHandles);% call the set_object interface
|
---|
5073 |
|
---|
5074 | UvData.MouseAction='create_object';
|
---|
5075 | set(handles.uvmat,'UserData',UvData)
|
---|
5076 | set(handles.zoom,'Value',0)
|
---|
5077 | zoom_Callback(handles.uvmat, [], handles)
|
---|
5078 | set(handles.delete_object,'Visible','on')
|
---|
5079 | set(handles.uvmat_title,'Visible','on')
|
---|
5080 | set(handles.view_field_title,'Visible','on')
|
---|
5081 |
|
---|
5082 | %------------------------------------------------------------------------
|
---|
5083 | function MenuRuler_Callback(hObject, eventdata, handles)
|
---|
5084 | %------------------------------------------------------------------------
|
---|
5085 | set(handles.zoom,'Value',0)
|
---|
5086 | zoom_Callback(handles.uvmat, [], handles)
|
---|
5087 | UvData=get(handles.uvmat,'UserData');
|
---|
5088 | UvData.MouseAction='ruler';
|
---|
5089 | set(handles.uvmat,'UserData',UvData);
|
---|
5090 |
|
---|
5091 | %------------------------------------------------------------------------
|
---|
5092 | % --- executed when closing: set the parent interface button to value 0
|
---|
5093 | function closefcn(gcbo,eventdata)
|
---|
5094 | %------------------------------------------------------------------------
|
---|
5095 | %delete all the associated figures if exist
|
---|
5096 | hh=findobj(allchild(0),'tag','view_field');
|
---|
5097 | if ~isempty(hh)
|
---|
5098 | delete(hh)
|
---|
5099 | end
|
---|
5100 | hh=findobj(allchild(0),'tag','geometry_calib');
|
---|
5101 | if ~isempty(hh)
|
---|
5102 | delete(hh)
|
---|
5103 | end
|
---|
5104 | hh=findobj(allchild(0),'tag','set_object');
|
---|
5105 | if ~isempty(hh)
|
---|
5106 | hhh=findobj(hh,'tag','PLOT');
|
---|
5107 | set(hhh,'enable','off')
|
---|
5108 | end
|
---|
5109 |
|
---|
5110 |
|
---|
5111 | % --- Executes on button press in delete_object.
|
---|
5112 | function delete_object_Callback(hObject, eventdata, handles)
|
---|
5113 | IndexObj=get(handles.list_object_2,'Value');
|
---|
5114 | if IndexObj>1
|
---|
5115 | delete_object(IndexObj)
|
---|
5116 | end
|
---|
5117 |
|
---|
5118 |
|
---|
5119 |
|
---|
5120 |
|
---|
5121 |
|
---|