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