source: trunk/src/view_field.m @ 127

Last change on this file since 127 was 116, checked in by sommeria, 14 years ago

geometry_calib is now updated when a new image is viewed by uvmat
imadoc2struct corrected for time reading

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