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