source: trunk/src/view_field.m @ 150

Last change on this file since 150 was 150, checked in by sommeria, 13 years ago

various corrections for plotting and using view_field and get_field. The current field of uvmat or view_field is now stored in the structure userdata.axes3. Introduction of live correlation to test PIV (civ1)

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