1 | %'view_field': function associated with the GUI 'view_field.fig' for images and data field visualization
|
---|
2 | %------------------------------------------------------------------------
|
---|
3 | % function huvmat=view_field(input)
|
---|
4 | %
|
---|
5 | %OUTPUT
|
---|
6 | % huvmat=current handles of the GUI view_field.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 VIEW_FIELD.
|
---|
18 | %
|
---|
19 | % VIEW_FIELD 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 | % VIEW_FIELD 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 VIEW_FIELD/COPYING.txt) for more details.
|
---|
28 | %AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
|
---|
29 |
|
---|
30 | %-------------------------------------------------------------------
|
---|
31 | % I - MAIN FUNCTION VIEW_FIELD (DO NOT MODIFY)
|
---|
32 | %-------------------------------------------------------------------
|
---|
33 | %-------------------------------------------------------------------
|
---|
34 | function varargout = view_field(varargin)
|
---|
35 |
|
---|
36 | % Begin initialization code - DO NOT EDIT
|
---|
37 | gui_Singleton = 1;
|
---|
38 | gui_State = struct('gui_Name', mfilename, ...
|
---|
39 | 'gui_Singleton', gui_Singleton, ...
|
---|
40 | 'gui_OpeningFcn', @view_field_OpeningFcn, ...
|
---|
41 | 'gui_OutputFcn', @view_field_OutputFcn, ...
|
---|
42 | 'gui_LayoutFcn', [], ...
|
---|
43 | 'gui_Callback', []);
|
---|
44 | if nargin && ischar(varargin{1})
|
---|
45 | gui_State.gui_Callback = str2func(varargin{1});
|
---|
46 | end
|
---|
47 |
|
---|
48 | if nargout
|
---|
49 | varargout{1:nargout} = gui_mainfcn(gui_State, varargin{:});
|
---|
50 | else
|
---|
51 | gui_mainfcn(gui_State, varargin{:});
|
---|
52 | end
|
---|
53 | % End initialization code - DO NOT EDIT
|
---|
54 |
|
---|
55 | %-------------------------------------------------------------------
|
---|
56 | % --- Executes just before view_field is made visible.
|
---|
57 | function view_field_OpeningFcn(hObject, eventdata, handles, Field )
|
---|
58 | %-------------------------------------------------------------------
|
---|
59 |
|
---|
60 | % Choose default command menuline output for view_field
|
---|
61 | handles.output = handles.view_field;
|
---|
62 |
|
---|
63 | % Update handles structure
|
---|
64 | guidata(hObject, handles);
|
---|
65 |
|
---|
66 | dircur=pwd; %current working directory
|
---|
67 | dir_opening=dircur;
|
---|
68 |
|
---|
69 | % set the position of colorbar and ancillary GUIs:
|
---|
70 | set(hObject,'Units','Normalized')
|
---|
71 | handles_mouse=handles;
|
---|
72 | huvmat=findobj(allchild(0),'Name','uvmat');
|
---|
73 | if ~isempty(huvmat)
|
---|
74 | hhuvmat=guidata(huvmat);
|
---|
75 | set(hhuvmat.list_object_2,'Visible','on')
|
---|
76 | % handles_mouse.create=hhuvmat.create;
|
---|
77 | handles_mouse.edit=hhuvmat.edit_object;
|
---|
78 | pos_uvmat=get(huvmat,'Position');
|
---|
79 | pos_view_field(1)=pos_uvmat(1)+pos_uvmat(3)/2;
|
---|
80 | pos_view_field(2)=pos_uvmat(2)-pos_uvmat(3)/4;
|
---|
81 | pos_view_field(3:4)=pos_uvmat(3:4);
|
---|
82 | set(hObject,'Position',pos_view_field)
|
---|
83 | end
|
---|
84 |
|
---|
85 | %functions for the mouse and keyboard
|
---|
86 | set(hObject,'KeyPressFcn',{'keyboard_callback',handles_mouse})%set keyboard action function
|
---|
87 | set(hObject,'WindowButtonMotionFcn',{'mouse_motion',handles_mouse})%set mouse action functio
|
---|
88 | set(hObject,'WindowButtonDownFcn',{'mouse_down'})%set mouse click action function
|
---|
89 | set(hObject,'WindowButtonUpFcn',{'mouse_up',handles_mouse})
|
---|
90 | set(hObject,'CloseRequestFcn',{@closefcn})%
|
---|
91 | if ~exist('Field','var')
|
---|
92 | return
|
---|
93 | end
|
---|
94 |
|
---|
95 | [PlotType,PlotParamOut]= plot_field(Field,handles.axes3);%,PlotParam,KeepLim,PosColorbar)
|
---|
96 | ViewFieldData.axes3=Field;
|
---|
97 | set(handles.view_field,'UserData',ViewFieldData);%store the current field
|
---|
98 | if isfield(PlotParamOut,'Vectors')
|
---|
99 | set(handles.VECT_title,'Visible','on')
|
---|
100 | end
|
---|
101 | write_plot_param(handles,PlotParamOut);% update the display of the plotting parameters
|
---|
102 |
|
---|
103 | %-------------------------------------------------------------------
|
---|
104 | % --- Outputs from this function are returned to the command menuline.
|
---|
105 | function varargout = view_field_OutputFcn(hObject, eventdata, handles)
|
---|
106 | varargout{1} = handles.output;% the only output argument is the handle to the GUI figure
|
---|
107 |
|
---|
108 |
|
---|
109 | %-------------------------------------------------------------------
|
---|
110 | %-------------------------------------------------------------------
|
---|
111 | % II - FUNCTIONS FOR INTRODUCING THE INPUT FILES
|
---|
112 | % automatically sets the global properties when the rootfile name is introduced
|
---|
113 | % then activate the view-field action if selected
|
---|
114 | % it is activated either by clicking on the RootPath window or by the
|
---|
115 | % browser
|
---|
116 | %------------------------------------------------------------------
|
---|
117 | %------------------------------------------------------------------
|
---|
118 |
|
---|
119 | %-------------------------------------------------------------------
|
---|
120 | function update_mask(handles,num_i1,num_j1)
|
---|
121 | %-------------------------------------------------------------------
|
---|
122 |
|
---|
123 | MaskData=get(handles.mask_test,'UserData');
|
---|
124 | if isfield(MaskData,'maskhandle')&& ishandle(MaskData.maskhandle)
|
---|
125 | uistack(MaskData.maskhandle,'top');
|
---|
126 | end
|
---|
127 | num_i1_mask=mod(num_i1-1,MaskData.NbSlice)+1;
|
---|
128 | [MaskName,mdetect]=name_generator(MaskData.Base,num_i1_mask,num_j1,'.png',MaskData.NomType);
|
---|
129 | huvmat=get(handles.mask_test,'parent');
|
---|
130 | UvData=get(huvmat,'UserData');
|
---|
131 |
|
---|
132 | %update mask image if the mask is new
|
---|
133 | if ~ (isfield(UvData,'MaskName') && isequal(UvData.MaskName,MaskName))
|
---|
134 | UvData.MaskName=MaskName; %update the recorded name on UvData
|
---|
135 | set(huvmat,'UserData',UvData);
|
---|
136 | if mdetect==0
|
---|
137 | if isfield(MaskData,'maskhandle')&& ishandle(MaskData.maskhandle)
|
---|
138 | delete(MaskData.maskhandle)
|
---|
139 | end
|
---|
140 | else
|
---|
141 | %read mask image
|
---|
142 | Mask.AName='image';
|
---|
143 | Mask.A=imread(MaskName);
|
---|
144 | npxy=size(Mask.A);
|
---|
145 | Mask.AX=[0.5 npxy(2)-0.5];
|
---|
146 | Mask.AY=[npxy(1)-0.5 0.5 ];
|
---|
147 | Mask.CoordUnit='pixel';
|
---|
148 | if isequal(get(handles.slices,'Value'),1)
|
---|
149 | NbSlice=str2num(get(handles.nb_slice,'String'));
|
---|
150 | num_i1=str2num(get(handles.i1,'String'));
|
---|
151 | Mask.ZIndex=mod(num_i1-1,NbSlice)+1;
|
---|
152 | end
|
---|
153 | %px to phys or other transform on field
|
---|
154 | menu_transform=get(handles.transform_fct,'String');
|
---|
155 | choice_value=get(handles.transform_fct,'Value');
|
---|
156 | transform_name=menu_transform{choice_value};%name of the transform fct given by the menu 'transform_fct'
|
---|
157 | transform_list=get(handles.transform_fct,'UserData');
|
---|
158 | transform=transform_list{choice_value};
|
---|
159 | if ~isequal(transform_name,'') && ~isequal(transform_name,'px')
|
---|
160 | if isfield(UvData,'XmlData') && isfield(UvData.XmlData,'GeometryCalib')%use geometry calib recorded from the ImaDoc xml file as first priority
|
---|
161 | Calib=UvData.XmlData.GeometryCalib;
|
---|
162 | Mask=transform(Mask,UvData.XmlData);
|
---|
163 | end
|
---|
164 | end
|
---|
165 | flagmask=Mask.A < 200;
|
---|
166 |
|
---|
167 | %make brown color image
|
---|
168 | imflag(:,:,1)=0.9*flagmask;
|
---|
169 | imflag(:,:,2)=0.7*flagmask;
|
---|
170 | imflag(:,:,3)=zeros(size(flagmask));
|
---|
171 |
|
---|
172 | %update mask image
|
---|
173 | hmask=[]; %default
|
---|
174 | if isfield(MaskData,'maskhandle')&& ishandle(MaskData.maskhandle)
|
---|
175 | hmask=MaskData.maskhandle;
|
---|
176 | end
|
---|
177 | if ~isempty(hmask)
|
---|
178 | set(hmask,'CData',imflag)
|
---|
179 | set(hmask,'AlphaData',flagmask*0.6)
|
---|
180 | set(hmask,'XData',Mask.AX);
|
---|
181 | set(hmask,'YData',Mask.AY);
|
---|
182 | % uistack(hmask,'top')
|
---|
183 | else
|
---|
184 | axes(handles.axes3)
|
---|
185 | hold on
|
---|
186 | MaskData.maskhandle=image(Mask.AX,Mask.AY,imflag,'Tag','mask','HitTest','off','AlphaData',0.6*flagmask);
|
---|
187 | % set(MaskData.maskhandle,'AlphaData',0.6*flagmask)
|
---|
188 | set(handles.mask_test,'UserData',MaskData)
|
---|
189 | end
|
---|
190 | end
|
---|
191 | end
|
---|
192 |
|
---|
193 |
|
---|
194 | %-------------------------------------------------------------------
|
---|
195 | function MenuExportFigure_Callback(hObject, eventdata, handles)
|
---|
196 | %-------------------------------------------------------------------
|
---|
197 | huvmat=get(handles.MenuExport,'parent');
|
---|
198 | UvData=get(huvmat,'UserData');
|
---|
199 | hfig=figure;
|
---|
200 | newaxes=copyobj(handles.axes3,hfig);
|
---|
201 | map=colormap(handles.axes3);
|
---|
202 | colormap(map);%transmit the current colormap to the zoom fig
|
---|
203 | colorbar
|
---|
204 |
|
---|
205 | %-------------------------------------------------------------------
|
---|
206 | %-------------------------------------------------------------------
|
---|
207 | % III - MAIN REFRESH FUNCTIONS : 'FRAME PLOT'
|
---|
208 | %-------------------------------------------------------------------
|
---|
209 | %-------------------------------------------------------------------
|
---|
210 |
|
---|
211 | %Executes on button press in runplus: make one step forward and call
|
---|
212 | %run0. The step forward is along the fields series 1 or 2 depending on
|
---|
213 | %the scan_i and scan_j check box (exclusive each other)
|
---|
214 | %-------------------------------------------------------------------
|
---|
215 | function runplus_Callback(hObject, eventdata, handles)
|
---|
216 | increment=str2num(get(handles.increment_scan,'String')); %get the field increment d
|
---|
217 | runpm(hObject,eventdata,handles,increment)
|
---|
218 |
|
---|
219 | %-------------------------------------------------------------------
|
---|
220 | %Executes on button press in runmin: make one step backward and call
|
---|
221 | %run0. The step backward is along the fields series 1 or 2 depending on
|
---|
222 | %the scan_i and scan_j check box (exclusive each other)
|
---|
223 | %-------------------------------------------------------------------
|
---|
224 | function runmin_Callback(hObject, eventdata, handles)
|
---|
225 | increment=-str2num(get(handles.increment_scan,'String')); %get the field increment d
|
---|
226 | runpm(hObject,eventdata,handles,increment)
|
---|
227 |
|
---|
228 | %-------------------------------------------------------------------
|
---|
229 | %Executes on button press in runmin: make one step backward and call
|
---|
230 | %run0. The step backward is along the fields series 1 or 2 depending on
|
---|
231 | %the scan_i and scan_j check box (exclusive each other)
|
---|
232 | %-------------------------------------------------------------------
|
---|
233 | function RunMovie_Callback(hObject, eventdata, handles)
|
---|
234 | %------------------------------------------------------------------
|
---|
235 | set(handles.RunMovie,'BackgroundColor',[1 1 0])%paint the command button in yellow
|
---|
236 | drawnow
|
---|
237 | increment=str2num(get(handles.increment_scan,'String')); %get the field increment d
|
---|
238 | set(handles.STOP,'Visible','on')
|
---|
239 | set(handles.speed,'Visible','on')
|
---|
240 | set(handles.speed_txt,'Visible','on')
|
---|
241 | set(handles.RunMovie,'BusyAction','queue')
|
---|
242 | testavi=0;
|
---|
243 | UvData=get(handles.view_field,'UserData');
|
---|
244 |
|
---|
245 | while get(handles.speed,'Value')~=0 & isequal(get(handles.RunMovie,'BusyAction'),'queue') % enable STOP command
|
---|
246 | runpm(hObject,eventdata,handles,increment)
|
---|
247 | pause(1.02-get(handles.speed,'Value'))% wait for next image
|
---|
248 | end
|
---|
249 | if isfield(UvData,'aviobj') && ~isempty( UvData.aviobj),
|
---|
250 | UvData.aviobj=close(UvData.aviobj);
|
---|
251 | set(handles.view_field,'UserData',UvData);
|
---|
252 | end
|
---|
253 | set(handles.RunMovie,'BackgroundColor',[1 0 0])%paint the command buttonback to red
|
---|
254 |
|
---|
255 |
|
---|
256 |
|
---|
257 | %-------------------------------------------------------------------
|
---|
258 | % --- translate coordinate to matrix index
|
---|
259 | %-------------------------------------------------------------------
|
---|
260 | function [indx,indy]=pos2ind(x0,rangx0,nxy)
|
---|
261 | indx=1+round((nxy(2)-1)*(x0-rangx0(1))/(rangx0(2)-rangx0(1)));% index x of pixel
|
---|
262 | indy=1+round((nxy(1)-1)*(y12-rangy0(1))/(rangy0(2)-rangy0(1)));% index y of pixel
|
---|
263 |
|
---|
264 | %-------------------------------------------------------------------
|
---|
265 | % --- Executes on button press in 'FixedLimits'.
|
---|
266 | %-------------------------------------------------------------------
|
---|
267 | function FixedLimits_Callback(hObject, eventdata, handles)
|
---|
268 | test=get(handles.FixedLimits,'Value');
|
---|
269 | if test
|
---|
270 | set(handles.FixedLimits,'BackgroundColor',[1 1 0])
|
---|
271 | else
|
---|
272 | set(handles.FixedLimits,'BackgroundColor',[0.7 0.7 0.7])
|
---|
273 | end
|
---|
274 |
|
---|
275 | %-------------------------------------------------------------------
|
---|
276 | % --- Executes on button press in auto_xy.
|
---|
277 | function auto_xy_Callback(hObject, eventdata, handles)
|
---|
278 | test=get(handles.auto_xy,'Value');
|
---|
279 | if test
|
---|
280 | set(handles.auto_xy,'BackgroundColor',[1 1 0])
|
---|
281 | cla(handles.axes3)
|
---|
282 | update_plot(handles)
|
---|
283 | else
|
---|
284 | set(handles.auto_xy,'BackgroundColor',[0.7 0.7 0.7])
|
---|
285 | update_plot(handles)
|
---|
286 | % axis(handles.axes3,'image')
|
---|
287 | end
|
---|
288 |
|
---|
289 |
|
---|
290 | %-------------------------------------------------------------------
|
---|
291 |
|
---|
292 | %-------------------------------------------------------------------
|
---|
293 | % --- Executes on button press in 'zoom'.
|
---|
294 | %-------------------------------------------------------------------
|
---|
295 | function zoom_Callback(hObject, eventdata, handles)
|
---|
296 | if (get(handles.zoom,'Value') == 1);
|
---|
297 | set(handles.zoom,'BackgroundColor',[1 1 0])
|
---|
298 | set(handles.FixedLimits,'Value',1)% propose by default fixed limits for the plotting axes
|
---|
299 | set(handles.FixedLimits,'BackgroundColor',[1 1 0])
|
---|
300 | else
|
---|
301 | set(handles.zoom,'BackgroundColor',[0.7 0.7 0.7])
|
---|
302 | end
|
---|
303 |
|
---|
304 | %-------------------------------------------------------------------
|
---|
305 | %----Executes on button press in 'record': records the current flags of manual correction.
|
---|
306 | %-------------------------------------------------------------------
|
---|
307 | function record_Callback(hObject, eventdata, handles)
|
---|
308 | % [filebase,num_i1,num_j1,num_i2,num_j2,Ext,NomType,SubDir]=read_input_file(handles);
|
---|
309 | filename=read_file_boxes(handles);
|
---|
310 | AxeData=get(gca,'UserData');
|
---|
311 | [erread,message]=fileattrib(filename);
|
---|
312 | if ~isempty(message) && ~isequal(message.UserWrite,1)
|
---|
313 | msgbox_view_field('ERROR',['no writting access to ' filename])
|
---|
314 | return
|
---|
315 | end
|
---|
316 | test_civ2=isequal(get(handles.civ2,'BackgroundColor'),[1 1 0]);
|
---|
317 | test_civ1=isequal(get(handles.civ1,'BackgroundColor'),[1 1 0]);
|
---|
318 | if ~test_civ2 && ~test_civ1
|
---|
319 | msgbox_view_field('ERROR','manual correction only possible for CIV1 or CIV2 velocity fields')
|
---|
320 | end
|
---|
321 | if test_civ2
|
---|
322 | nbname='nb_vectors2';
|
---|
323 | flagname='vec2_FixFlag';
|
---|
324 | attrname='fix2';
|
---|
325 | end
|
---|
326 | if test_civ1
|
---|
327 | nbname='nb_vectors';
|
---|
328 | flagname='vec_FixFlag';
|
---|
329 | attrname='fix';
|
---|
330 | end
|
---|
331 | %write fix flags in the netcdf file
|
---|
332 | hhh=which('netcdf.open');% look for built-in matlab netcdf library
|
---|
333 | if ~isequal(hhh,'')% case of new builtin Matlab netcdf library
|
---|
334 | nc=netcdf.open(filename,'NC_WRITE');
|
---|
335 | netcdf.reDef(nc)
|
---|
336 | netcdf.putAtt(nc,netcdf.getConstant('NC_GLOBAL'),attrname,1)
|
---|
337 | dimid = netcdf.inqDimID(nc,nbname);
|
---|
338 | try
|
---|
339 | varid = netcdf.inqVarID(nc,flagname);% look for already existing fixflag variable
|
---|
340 | catch
|
---|
341 | varid=netcdf.defVar(nc,flagname,'double',dimid);%create fixflag variable if it does not exist
|
---|
342 | end
|
---|
343 | netcdf.endDef(nc)
|
---|
344 | netcdf.putVar(nc,varid,AxeData.FF);
|
---|
345 | netcdf.close(nc)
|
---|
346 | else %old netcdf library
|
---|
347 | netcdf_toolbox(filename,AxeData,attrname,nbname,flagname)
|
---|
348 | end
|
---|
349 |
|
---|
350 | function netcdf_toolbox(filename,AxeData,attrname,nbname,flagname)
|
---|
351 | nc=netcdf(filename,'write'); %open netcdf file
|
---|
352 | result=redef(nc);
|
---|
353 | eval(['nc.' attrname '=1;']);
|
---|
354 | theDim=nc(nbname) ;% get the number of velocity vectors
|
---|
355 | nb_vectors=size(theDim);
|
---|
356 | var_FixFlag=ncvar(flagname,nc);% var_FixFlag will be written as the netcdf variable vec_FixFlag
|
---|
357 | var_FixFlag(1:nb_vectors)=AxeData.FF;%
|
---|
358 | fin=close(nc);
|
---|
359 |
|
---|
360 |
|
---|
361 | %-------------------------------------------------------------------
|
---|
362 | %-------------------------------------------------------------------
|
---|
363 | % - FUNCTIONS FOR SETTING PLOTTING PARAMETERS
|
---|
364 |
|
---|
365 | %------------------------------------------------------------------
|
---|
366 |
|
---|
367 |
|
---|
368 | %------------------------------------------------------------------
|
---|
369 | % --- Executes on selection change in col_vec: choice of the color code.
|
---|
370 | %
|
---|
371 | function col_vec_Callback(hObject, eventdata, handles)
|
---|
372 | %------------------------------------------------------------------
|
---|
373 | % edit the choice for color code
|
---|
374 | list_code=get(handles.col_vec,'String');% list menu fields
|
---|
375 | index_code=get(handles.col_vec,'Value');% selected string index
|
---|
376 | col_code= list_code{index_code(1)}; % selected field
|
---|
377 | if isequal(col_code,'black') | isequal(col_code,'white')
|
---|
378 | set(handles.slider1,'Visible','off')
|
---|
379 | set(handles.slider2,'Visible','off')
|
---|
380 | set(handles.colcode1,'Visible','off')
|
---|
381 | set(handles.colcode2,'Visible','off')
|
---|
382 | set(handles.AutoVecColor,'Visible','off')
|
---|
383 | set_vec_col_bar(handles)
|
---|
384 | else
|
---|
385 | set(handles.slider1,'Visible','on')
|
---|
386 | set(handles.slider2,'Visible','on')
|
---|
387 | set(handles.colcode1,'Visible','on')
|
---|
388 | set(handles.colcode2,'Visible','on')
|
---|
389 | set(handles.AutoVecColor,'Visible','on')
|
---|
390 | if isequal(col_code,'ima_cor')
|
---|
391 | set(handles.AutoVecColor,'Value',0)%fixed scale by default
|
---|
392 | set(handles.vec_col_bar,'Value',0)% 3 colors r,g,b by default
|
---|
393 | set(handles.slider1,'Min',0);
|
---|
394 | set(handles.slider1,'Max',1);
|
---|
395 | set(handles.slider2,'Min',0);
|
---|
396 | set(handles.slider2,'Max',1);
|
---|
397 | % set(handles.min_C_title_vec,'String','0')
|
---|
398 | set(handles.max_vec,'String','1')
|
---|
399 | set(handles.colcode1,'String','0.333')
|
---|
400 | colcode1_Callback(hObject, eventdata, handles)
|
---|
401 | set(handles.colcode2,'String','0.666')
|
---|
402 | colcode2_Callback(hObject, eventdata, handles)
|
---|
403 | else
|
---|
404 | set(handles.AutoVecColor,'Value',1)%auto scale between min,max by default
|
---|
405 | set(handles.vec_col_bar,'Value',1)% colormap 'jet' by default
|
---|
406 | minval=get(handles.slider1,'Min');
|
---|
407 | maxval=get(handles.slider1,'Max');
|
---|
408 | set(handles.slider1,'Value',minval)
|
---|
409 | set(handles.slider2,'Value',maxval)
|
---|
410 | set_vec_col_bar(handles)
|
---|
411 | end
|
---|
412 | % slider_update(handles)
|
---|
413 | end
|
---|
414 | %replot the current graph
|
---|
415 | run0_Callback(hObject, eventdata, handles)
|
---|
416 |
|
---|
417 |
|
---|
418 | %----------------------------------------------------------------
|
---|
419 | % -- Executes on slider movement to set the color code
|
---|
420 | %
|
---|
421 | function slider1_Callback(hObject, eventdata, handles)
|
---|
422 | %------------------------------------------------------------------
|
---|
423 | slider1=get(handles.slider1,'Value');
|
---|
424 | min_val=str2num(get(handles.min_vec,'String'));
|
---|
425 | max_val=str2num(get(handles.max_vec,'String'));
|
---|
426 | col=min_val+(max_val-min_val)*slider1;
|
---|
427 | set(handles.colcode1,'String',num2str(col))
|
---|
428 | if(get(handles.slider2,'Value') < col)%move also the second slider at the same value if needed
|
---|
429 | set(handles.slider2,'Value',col)
|
---|
430 | set(handles.colcode2,'String',num2str(col))
|
---|
431 | end
|
---|
432 | colcode1_Callback(hObject, eventdata, handles)
|
---|
433 |
|
---|
434 | %----------------------------------------------------------------
|
---|
435 | % Executes on slider movement to set the color code
|
---|
436 | %----------------------------------------------------------------
|
---|
437 | function slider2_Callback(hObject, eventdata, handles)
|
---|
438 | slider2=get(handles.slider2,'Value');
|
---|
439 | min_val=str2num(get(handles.min_vec,'String'));
|
---|
440 | max_val=str2num(get(handles.max_vec,'String'));
|
---|
441 | col=min_val+(max_val-min_val)*slider2;
|
---|
442 | set(handles.colcode2,'String',num2str(col))
|
---|
443 | if(get(handles.slider1,'Value') > col)%move also the first slider at the same value if needed
|
---|
444 | set(handles.slider1,'Value',col)
|
---|
445 | set(handles.colcode1,'String',num2str(col))
|
---|
446 | end
|
---|
447 | colcode2_Callback(hObject, eventdata, handles)
|
---|
448 |
|
---|
449 | %----------------------------------------------------------------
|
---|
450 | %execute on return carriage on the edit box corresponding to slider 1
|
---|
451 | %----------------------------------------------------------------
|
---|
452 | function colcode1_Callback(hObject, eventdata, handles)
|
---|
453 | % col=str2num(get(handles.colcode1,'String'));
|
---|
454 | % set(handles.slider1,'Value',col)
|
---|
455 | set_vec_col_bar(handles)
|
---|
456 | update_plot(handles)
|
---|
457 |
|
---|
458 | %----------------------------------------------------------------
|
---|
459 | %execute on return carriage on the edit box corresponding to slider 2
|
---|
460 | %----------------------------------------------------------------
|
---|
461 | function colcode2_Callback(hObject, eventdata, handles)
|
---|
462 | % col=str2num(get(handles.colcode2,'String'));
|
---|
463 | % set(handles.slider2,'Value',col)
|
---|
464 | % slider2_Callback(hObject, eventdata, handles)
|
---|
465 | set_vec_col_bar(handles)
|
---|
466 | update_plot(handles)
|
---|
467 | %------------------------------------------------------------
|
---|
468 | %update the slider values after displaying vectors
|
---|
469 | %--------------------------------------------------------
|
---|
470 | % function slider_update(handles,auto,minC,colcode1,colcode2,maxC)
|
---|
471 | % set(handles.slider1,'Min',minC)
|
---|
472 | % set(handles.slider1,'Max',maxC)
|
---|
473 | % set(handles.slider2,'Min',minC)
|
---|
474 | % set(handles.slider2,'Max',maxC)
|
---|
475 | % set(handles.min_C_title_vec,'String',num2str(minC))
|
---|
476 | % set(handles.max_vec,'String',num2str(maxC))
|
---|
477 | % if auto
|
---|
478 | % set(handles.colcode1,'String',num2str(colcode1,3))%update display
|
---|
479 | % set(handles.colcode2,'String',num2str(colcode2,3))
|
---|
480 | % end
|
---|
481 | % set(handles.slider1,'Value',colcode1)%update slider with constant display
|
---|
482 | % set(handles.slider2,'Value',colcode2)
|
---|
483 | % set_vec_col_bar(handles)
|
---|
484 |
|
---|
485 |
|
---|
486 | %-------------------------------------------------------
|
---|
487 | % --- Executes on button press in AutoVecColor.
|
---|
488 | %-------------------------------------------------------
|
---|
489 | function vec_col_bar_Callback(hObject, eventdata, handles)
|
---|
490 | set_vec_col_bar(handles)
|
---|
491 |
|
---|
492 | % %--------------------------------------------
|
---|
493 | % %update the display of color code for vectors
|
---|
494 | % %--------------------------------------------
|
---|
495 | % function set_vec_col_bar(handles)
|
---|
496 | % %get the image of the color display button 'vec_col_bar' in pixels
|
---|
497 | % uni=get(handles.vec_col_bar,'Unit');
|
---|
498 | % set(handles.vec_col_bar,'Unit','pixel')
|
---|
499 | % pos_vert=get(handles.vec_col_bar,'Position');
|
---|
500 | % set(handles.vec_col_bar,'Unit','Normalized')
|
---|
501 | % width=ceil(pos_vert(3));
|
---|
502 | % height=ceil(pos_vert(4));
|
---|
503 | % %get slider indications
|
---|
504 | % colcode.min=get(handles.slider1,'Min');
|
---|
505 | % colcode.max=get(handles.slider1,'Max');
|
---|
506 | % colcode.colcode1=get(handles.slider1,'Value');
|
---|
507 | % colcode.colcode2=get(handles.slider2,'Value');
|
---|
508 | % colcode.option=get(handles.vec_col_bar,'Value');
|
---|
509 | % colcode.auto=1;
|
---|
510 | % list_code=get(handles.col_vec,'String');% list menu fields
|
---|
511 | % index_code=get(handles.col_vec,'Value');% selected string index
|
---|
512 | % colcode.CName= list_code{index_code(1)}; % selected field used for vector color
|
---|
513 | % vec_C=colcode.min+(colcode.max-colcode.min)*[0.5:width-0.5]/width;%sample of vec_C values from min to max
|
---|
514 | % [colorlist,col_vec]=set_col_vec(colcode,vec_C);
|
---|
515 | % oneheight=ones(1,height);
|
---|
516 | % A1=colorlist(col_vec,1)*oneheight;
|
---|
517 | % A2=colorlist(col_vec,2)*oneheight;
|
---|
518 | % A3=colorlist(col_vec,3)*oneheight;
|
---|
519 | % A(:,:,1)=A1';
|
---|
520 | % A(:,:,2)=A2';
|
---|
521 | % A(:,:,3)=A3';
|
---|
522 | % set(handles.vec_col_bar,'Cdata',A)
|
---|
523 |
|
---|
524 |
|
---|
525 | %------------------------------------------------
|
---|
526 | %CALLBACKS FOR PLOTTING PARAMETERS
|
---|
527 | %-------------------------------------------------
|
---|
528 |
|
---|
529 | %-----------------------------------------------------------------
|
---|
530 | function MinA_Callback(hObject, eventdata, handles)
|
---|
531 | %------------------------------------------
|
---|
532 | set(handles.AutoScal,'Value',1) %suppress auto mode
|
---|
533 | set(handles.AutoScal,'BackgroundColor',[1 1 0])
|
---|
534 | update_plot(handles)
|
---|
535 |
|
---|
536 | %-----------------------------------------------------------------
|
---|
537 | function MaxA_Callback(hObject, eventdata, handles)
|
---|
538 | %--------------------------------------------
|
---|
539 | set(handles.AutoScal,'Value',1) %suppress auto mode
|
---|
540 | set(handles.AutoScal,'BackgroundColor',[1 1 0])
|
---|
541 | update_plot(handles)
|
---|
542 |
|
---|
543 | %-----------------------------------------------
|
---|
544 | function AutoScal_Callback(hObject, eventdata, handles)
|
---|
545 | %--------------------------------------------
|
---|
546 | test=get(handles.AutoScal,'Value');
|
---|
547 | if test
|
---|
548 | set(handles.AutoScal,'BackgroundColor',[1 1 0])
|
---|
549 | else
|
---|
550 | set(handles.AutoScal,'BackgroundColor',[0.7 0.7 0.7])
|
---|
551 | update_plot(handles);
|
---|
552 | % set(handles.MinA,'String',num2str(ScalOut.MinA,3))
|
---|
553 | % set(handles.MaxA,'String',num2str(ScalOut.MaxA,3))
|
---|
554 | end
|
---|
555 |
|
---|
556 | %-------------------------------------------------------------------
|
---|
557 | function BW_Callback(hObject, eventdata, handles)
|
---|
558 | %-------------------------------------------------------------------
|
---|
559 | update_plot(handles)
|
---|
560 |
|
---|
561 | %-------------------------------------------------------------------
|
---|
562 | function Contours_Callback(hObject, eventdata, handles)
|
---|
563 | %-------------------------------------------------------------------
|
---|
564 | val=get(handles.Contours,'Value');
|
---|
565 | if val==2
|
---|
566 | set(handles.interval_txt,'Visible','on')
|
---|
567 | set(handles.IncrA,'Visible','on')
|
---|
568 | else
|
---|
569 | set(handles.interval_txt,'Visible','off')
|
---|
570 | set(handles.IncrA,'Visible','off')
|
---|
571 | end
|
---|
572 | update_plot(handles)
|
---|
573 |
|
---|
574 | %-------------------------------------------------------------------
|
---|
575 | function IncrA_Callback(hObject, eventdata, handles)
|
---|
576 | %-------------------------------------------------------------------
|
---|
577 | update_plot(handles)
|
---|
578 |
|
---|
579 | %-------------------------------------------------------------------
|
---|
580 | function HideWarning_Callback(hObject, eventdata, handles)
|
---|
581 | %-------------------------------------------------------------------
|
---|
582 | update_plot(handles)
|
---|
583 |
|
---|
584 | %-------------------------------------------------------------------
|
---|
585 | function HideFalse_Callback(hObject, eventdata, handles)
|
---|
586 | %-------------------------------------------------------------------
|
---|
587 | update_plot(handles)
|
---|
588 |
|
---|
589 | %-------------------------------------------------------------------
|
---|
590 | function VecScale_Callback(hObject, eventdata, handles)
|
---|
591 | %-------------------------------------------------------------------
|
---|
592 | set(handles.AutoVec,'Value',1);
|
---|
593 | set(handles.AutoVec,'BackgroundColor',[1 1 0])
|
---|
594 | update_plot(handles)
|
---|
595 |
|
---|
596 | %-------------------------------------------------------------------
|
---|
597 | function AutoVec_Callback(hObject, eventdata, handles)
|
---|
598 | %-------------------------------------------------------------------
|
---|
599 | test=get(handles.AutoVec,'Value');
|
---|
600 | if test
|
---|
601 | set(handles.AutoVec,'BackgroundColor',[1 1 0])
|
---|
602 | else
|
---|
603 | update_plot(handles);
|
---|
604 | %set(handles.VecScale,'String',num2str(ScalOut.VecScale,3))
|
---|
605 | set(handles.AutoVec,'BackgroundColor',[0.7 0.7 0.7])
|
---|
606 | end
|
---|
607 |
|
---|
608 | %-------------------------------------------------------
|
---|
609 | % --- Executes on selection change in decimate4 (nb_vec/4).
|
---|
610 | %-------------------------------------------------------
|
---|
611 | function decimate4_Callback(hObject, eventdata, handles)
|
---|
612 | 'TEST'
|
---|
613 | update_plot(handles)
|
---|
614 |
|
---|
615 |
|
---|
616 | %-------------------------------------------------------
|
---|
617 | % --- Executes on selection change in color_code menu
|
---|
618 | %-------------------------------------------------------
|
---|
619 | function color_code_Callback(hObject, eventdata, handles)
|
---|
620 | set_vec_col_bar(handles)
|
---|
621 | update_plot(handles);
|
---|
622 |
|
---|
623 | %-------------------------------------------------------
|
---|
624 | % --- Executes on button press in AutoVecColor.
|
---|
625 | %-------------------------------------------------------
|
---|
626 | function AutoVecColor_Callback(hObject, eventdata, handles)
|
---|
627 | test=get(handles.AutoVecColor,'Value');
|
---|
628 | if test
|
---|
629 | set(handles.AutoVecColor,'BackgroundColor',[1 1 0])
|
---|
630 | else
|
---|
631 | update_plot(handles);
|
---|
632 | %set(handles.VecScale,'String',num2str(ScalOut.VecScale,3))
|
---|
633 | set(handles.AutoVecColor,'BackgroundColor',[0.7 0.7 0.7])
|
---|
634 | end
|
---|
635 | %set_vec_col_bar(handles)
|
---|
636 |
|
---|
637 | %-------------------------------------------------------
|
---|
638 | % --- Executes on selection change in max_vec.
|
---|
639 | %-------------------------------------------------------
|
---|
640 | function min_vec_Callback(hObject, eventdata, handles)
|
---|
641 | max_vec_Callback(hObject, eventdata, handles)
|
---|
642 |
|
---|
643 | % --- Executes on selection change in max_vec.
|
---|
644 | function max_vec_Callback(hObject, eventdata, handles)
|
---|
645 | set(handles.AutoVecColor,'Value',1)
|
---|
646 | AutoVecColor_Callback(hObject, eventdata, handles)
|
---|
647 | min_val=str2num(get(handles.min_vec,'String'));
|
---|
648 | max_val=str2num(get(handles.max_vec,'String'));
|
---|
649 | slider1=get(handles.slider1,'Value');
|
---|
650 | slider2=get(handles.slider2,'Value');
|
---|
651 | colcode1=min_val+(max_val-min_val)*slider1;
|
---|
652 | colcode2=min_val+(max_val-min_val)*slider2;
|
---|
653 | set(handles.colcode1,'String',num2str(colcode1))
|
---|
654 | set(handles.colcode2,'String',num2str(colcode2))
|
---|
655 | update_plot(handles);
|
---|
656 |
|
---|
657 | %-------------------------------------------------------------------
|
---|
658 | %update the display of color code for vectors
|
---|
659 | function set_vec_col_bar(handles)
|
---|
660 | %-------------------------------------------------------------------
|
---|
661 | %get the image of the color display button 'vec_col_bar' in pixels
|
---|
662 | set(handles.vec_col_bar,'Unit','pixel');
|
---|
663 | pos_vert=get(handles.vec_col_bar,'Position');
|
---|
664 | set(handles.vec_col_bar,'Unit','Normalized');
|
---|
665 | width=ceil(pos_vert(3));
|
---|
666 | height=ceil(pos_vert(4));
|
---|
667 |
|
---|
668 | %get slider indications
|
---|
669 | list=get(handles.color_code,'String');
|
---|
670 | ichoice=get(handles.color_code,'Value');
|
---|
671 | colcode.ColorCode=list{ichoice};
|
---|
672 | colcode.MinC=str2num(get(handles.min_vec,'String'));
|
---|
673 | colcode.MaxC=str2num(get(handles.max_vec,'String'));
|
---|
674 | test3color=strcmp(colcode.ColorCode,'rgb') || strcmp(colcode.ColorCode,'bgr');
|
---|
675 | if test3color
|
---|
676 | colcode.colcode1=str2num(get(handles.colcode1,'String'));
|
---|
677 | colcode.colcode2=str2num(get(handles.colcode2,'String'));
|
---|
678 | end
|
---|
679 | % colcode.option=get(handles.vec_col_bar,'Value');
|
---|
680 | colcode.FixedCbounds=0;
|
---|
681 | % list_code=get(handles.col_vec,'String');% list menu fields
|
---|
682 | % index_code=get(handles.col_vec,'Value');% selected string index
|
---|
683 | % colcode.CName= list_code{index_code(1)}; % selected field used for vector color
|
---|
684 | colcode.FixedCbounds=1;
|
---|
685 | vec_C=colcode.MinC+(colcode.MaxC-colcode.MinC)*[0.5:width-0.5]/width;%sample of vec_C values from min to max
|
---|
686 | [colorlist,col_vec]=set_col_vec(colcode,vec_C);
|
---|
687 | oneheight=ones(1,height);
|
---|
688 | A1=colorlist(col_vec,1)*oneheight;
|
---|
689 | A2=colorlist(col_vec,2)*oneheight;
|
---|
690 | A3=colorlist(col_vec,3)*oneheight;
|
---|
691 | A(:,:,1)=A1';
|
---|
692 | A(:,:,2)=A2';
|
---|
693 | A(:,:,3)=A3';
|
---|
694 | set(handles.vec_col_bar,'Cdata',A)
|
---|
695 |
|
---|
696 | %-------------------------------------------------------------------
|
---|
697 | function PlotType=update_plot(handles)
|
---|
698 | %-------------------------------------------------------------------
|
---|
699 | haxes= handles.axes3;
|
---|
700 | %huvmat=findobj(allchild(0),'tag','uvmat');
|
---|
701 | ProjField=get(haxes,'UserData');
|
---|
702 | PlotParam=read_plot_param(handles);
|
---|
703 | [PlotType,PlotParamOut]= plot_field(ProjField,haxes,PlotParam,1);
|
---|
704 | write_plot_param(handles,PlotParamOut); %update the auto plot parameters
|
---|
705 |
|
---|
706 | %------------------------------------------------------
|
---|
707 | % --- Executes on button press in Menu/Export/field in workspace.
|
---|
708 | %------------------------------------------------------
|
---|
709 | function MenuExportField_Callback(hObject, eventdata, handles)
|
---|
710 |
|
---|
711 | global Data_view_field
|
---|
712 | % huvmat=findobj(allchild(0),'Name','uvmat');
|
---|
713 | Data_view_field=get(handles.view_field,'UserData');
|
---|
714 | Data_view_field=Data_view_field.axes3;
|
---|
715 | % Data_view_field=UvData.ProjField_2;
|
---|
716 | evalin('base','global Data_view_field')%make CurData global in the workspace
|
---|
717 | display(['UserData of view_field :'])
|
---|
718 | evalin('base','Data_view_field') %display CurData in the workspace
|
---|
719 | commandwindow;
|
---|
720 |
|
---|
721 | %------------------------------------------------------
|
---|
722 | % --- Executes on button press in Menu/Export/extract figure.
|
---|
723 | %------------------------------------------------------
|
---|
724 | function MenuExport_plot_Callback(hObject, eventdata, handles)
|
---|
725 | huvmat=get(handles.MenuExport_plot,'parent');
|
---|
726 | UvData=get(huvmat,'UserData');
|
---|
727 | hfig=figure;
|
---|
728 | newaxes=copyobj(handles.axes3,hfig);
|
---|
729 | map=colormap(handles.axes3);
|
---|
730 | colormap(map);%transmit the current colormap to the zoom fig
|
---|
731 | colorbar
|
---|
732 |
|
---|
733 |
|
---|
734 |
|
---|
735 | function npx_Callback(hObject, eventdata, handles)
|
---|
736 |
|
---|
737 |
|
---|
738 |
|
---|
739 | function npy_Callback(hObject, eventdata, handles)
|
---|
740 |
|
---|
741 |
|
---|
742 | function edit86_Callback(hObject, eventdata, handles)
|
---|
743 |
|
---|
744 |
|
---|
745 | function edit87_Callback(hObject, eventdata, handles)
|
---|
746 |
|
---|
747 |
|
---|
748 | % --- Executes on button press in auto_sclar.
|
---|
749 | function auto_sclar_Callback(hObject, eventdata, handles)
|
---|
750 | % hObject handle to auto_sclar (see GCBO)
|
---|
751 | % eventdata reserved - to be defined in a future version of MATLAB
|
---|
752 | % handles structure with handles and user data (see GUIDATA)
|
---|
753 |
|
---|
754 | % Hint: get(hObject,'Value') returns toggle state of auto_sclar
|
---|
755 |
|
---|
756 |
|
---|
757 |
|
---|
758 | % --- Executes on slider movement.
|
---|
759 | function slider9_Callback(hObject, eventdata, handles)
|
---|
760 | % hObject handle to slider2 (see GCBO)
|
---|
761 | % eventdata reserved - to be defined in a future version of MATLAB
|
---|
762 | % handles structure with handles and user data (see GUIDATA)
|
---|
763 |
|
---|
764 | % Hints: get(hObject,'Value') returns position of slider
|
---|
765 | % get(hObject,'Min') and get(hObject,'Max') to determine range of slider
|
---|
766 |
|
---|
767 |
|
---|
768 | % --- Executes on slider movement.
|
---|
769 | function slider10_Callback(hObject, eventdata, handles)
|
---|
770 | % hObject handle to slider1 (see GCBO)
|
---|
771 | % eventdata reserved - to be defined in a future version of MATLAB
|
---|
772 | % handles structure with handles and user data (see GUIDATA)
|
---|
773 |
|
---|
774 | % Hints: get(hObject,'Value') returns position of slider
|
---|
775 | % get(hObject,'Min') and get(hObject,'Max') to determine range of
|
---|
776 | % slider
|
---|
777 |
|
---|
778 |
|
---|
779 | function closefcn(hObject, eventdata, handles)
|
---|
780 | huvmat=findobj(allchild(0),'Name','uvmat');
|
---|
781 | if ~isempty(huvmat)
|
---|
782 | hhuvmat=guidata(huvmat);
|
---|
783 | list_object_2=get(hhuvmat.list_object_2,'String');
|
---|
784 | set(hhuvmat.list_object_2,'Value',numel(list_object_2))%select the last value ('...')
|
---|
785 | end
|
---|
786 | delete(hObject)
|
---|
787 |
|
---|
788 |
|
---|
789 | % --- Executes on selection change in popupmenu18.
|
---|
790 | function popupmenu18_Callback(hObject, eventdata, handles)
|
---|
791 |
|
---|
792 |
|
---|
793 |
|
---|
794 | function text_display_Callback(hObject, eventdata, handles)
|
---|
795 | % hObject handle to text_display (see GCBO)
|
---|
796 | % eventdata reserved - to be defined in a future version of MATLAB
|
---|
797 | % handles structure with handles and user data (see GUIDATA)
|
---|
798 |
|
---|
799 | % Hints: get(hObject,'String') returns contents of text_display as text
|
---|
800 | % str2double(get(hObject,'String')) returns contents of text_display as a double
|
---|
801 |
|
---|
802 |
|
---|
803 | % --- Executes during object creation, after setting all properties.
|
---|
804 | function text_display_CreateFcn(hObject, eventdata, handles)
|
---|
805 | % hObject handle to text_display (see GCBO)
|
---|
806 | % eventdata reserved - to be defined in a future version of MATLAB
|
---|
807 | % handles empty - handles not created until after all CreateFcns called
|
---|
808 |
|
---|
809 | % Hint: edit controls usually have a white background on Windows.
|
---|
810 | % See ISPC and COMPUTER.
|
---|
811 | if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
|
---|
812 | set(hObject,'BackgroundColor','white');
|
---|
813 | end
|
---|
814 |
|
---|
815 |
|
---|