source: trunk/src/view_field.m @ 103

Last change on this file since 103 was 102, checked in by sommeria, 14 years ago

bugs corrected for projection objects

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)
607update_plot(handles)
608
609
610%-------------------------------------------------------
611% --- Executes on selection change in color_code menu
612%-------------------------------------------------------
613function color_code_Callback(hObject, eventdata, handles)
614set_vec_col_bar(handles)
615update_plot(handles);
616
617%-------------------------------------------------------
618% --- Executes on button press in AutoVecColor.
619%-------------------------------------------------------
620function AutoVecColor_Callback(hObject, eventdata, handles)
621test=get(handles.AutoVecColor,'Value');
622if test
623    set(handles.AutoVecColor,'BackgroundColor',[1 1 0])
624else
625    update_plot(handles);
626    %set(handles.VecScale,'String',num2str(ScalOut.VecScale,3))
627    set(handles.AutoVecColor,'BackgroundColor',[0.7 0.7 0.7])
628end
629%set_vec_col_bar(handles)
630
631%-------------------------------------------------------
632% --- Executes on selection change in max_vec.
633%-------------------------------------------------------
634function min_vec_Callback(hObject, eventdata, handles)
635max_vec_Callback(hObject, eventdata, handles)
636
637% --- Executes on selection change in max_vec.
638function max_vec_Callback(hObject, eventdata, handles)
639set(handles.AutoVecColor,'Value',1)
640AutoVecColor_Callback(hObject, eventdata, handles)
641min_val=str2num(get(handles.min_vec,'String'));
642max_val=str2num(get(handles.max_vec,'String'));
643slider1=get(handles.slider1,'Value');
644slider2=get(handles.slider2,'Value');
645colcode1=min_val+(max_val-min_val)*slider1;
646colcode2=min_val+(max_val-min_val)*slider2;
647set(handles.colcode1,'String',num2str(colcode1))
648set(handles.colcode2,'String',num2str(colcode2))
649update_plot(handles);
650
651%-------------------------------------------------------------------
652%update the display of color code for vectors
653function set_vec_col_bar(handles)
654%-------------------------------------------------------------------
655%get the image of the color display button 'vec_col_bar' in pixels
656set(handles.vec_col_bar,'Unit','pixel');
657pos_vert=get(handles.vec_col_bar,'Position');
658set(handles.vec_col_bar,'Unit','Normalized');
659width=ceil(pos_vert(3));
660height=ceil(pos_vert(4));
661
662%get slider indications
663list=get(handles.color_code,'String');
664ichoice=get(handles.color_code,'Value');
665colcode.ColorCode=list{ichoice};
666colcode.MinC=str2num(get(handles.min_vec,'String'));
667colcode.MaxC=str2num(get(handles.max_vec,'String'));
668test3color=strcmp(colcode.ColorCode,'rgb') || strcmp(colcode.ColorCode,'bgr');
669if test3color
670    colcode.colcode1=str2num(get(handles.colcode1,'String'));
671    colcode.colcode2=str2num(get(handles.colcode2,'String'));
672end
673% colcode.option=get(handles.vec_col_bar,'Value');
674colcode.FixedCbounds=0;
675% list_code=get(handles.col_vec,'String');% list menu fields
676% index_code=get(handles.col_vec,'Value');% selected string index
677% colcode.CName= list_code{index_code(1)}; % selected field used for vector color
678colcode.FixedCbounds=1;
679vec_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);
681oneheight=ones(1,height);
682A1=colorlist(col_vec,1)*oneheight;
683A2=colorlist(col_vec,2)*oneheight;
684A3=colorlist(col_vec,3)*oneheight;
685A(:,:,1)=A1';
686A(:,:,2)=A2';
687A(:,:,3)=A3';
688set(handles.vec_col_bar,'Cdata',A)
689
690%-------------------------------------------------------------------
691function [PlotType,ScalOut]=update_plot(handles)
692%-------------------------------------------------------------------
693haxes= handles.axes3;
694%huvmat=findobj(allchild(0),'tag','uvmat');
695ProjField=get(haxes,'UserData');
696PlotParam=read_plot_param(handles);
697[PlotType,PlotParamOut]= plot_field(ProjField,haxes,PlotParam,1);
698write_plot_param(handles,PlotParamOut); %update the auto plot parameters
699
700%------------------------------------------------------
701% --- Executes on button press in Menu/Export/field in workspace.
702%------------------------------------------------------
703function MenuExportField_Callback(hObject, eventdata, handles)
704
705global Data_view_field
706% huvmat=findobj(allchild(0),'Name','uvmat');
707Data_view_field=get(handles.axes3,'UserData');
708% Data_view_field=UvData.ProjField_2;
709evalin('base','global Data_view_field')%make CurData global in the workspace
710display(['UserData of view_field :'])
711evalin('base','Data_view_field') %display CurData in the workspace
712commandwindow;
713
714%------------------------------------------------------
715% --- Executes on button press in Menu/Export/extract figure.
716%------------------------------------------------------
717function MenuExport_plot_Callback(hObject, eventdata, handles)
718huvmat=get(handles.MenuExport_plot,'parent');
719UvData=get(huvmat,'UserData');
720hfig=figure;
721newaxes=copyobj(handles.axes3,hfig);
722map=colormap(handles.axes3);
723colormap(map);%transmit the current colormap to the zoom fig
724colorbar
725
726
727
728function npx_Callback(hObject, eventdata, handles)
729
730
731
732function npy_Callback(hObject, eventdata, handles)
733
734
735function edit86_Callback(hObject, eventdata, handles)
736
737
738function edit87_Callback(hObject, eventdata, handles)
739
740
741% --- Executes on button press in auto_sclar.
742function auto_sclar_Callback(hObject, eventdata, handles)
743% hObject    handle to auto_sclar (see GCBO)
744% eventdata  reserved - to be defined in a future version of MATLAB
745% handles    structure with handles and user data (see GUIDATA)
746
747% Hint: get(hObject,'Value') returns toggle state of auto_sclar
748
749
750
751% --- Executes on slider movement.
752function slider9_Callback(hObject, eventdata, handles)
753% hObject    handle to slider2 (see GCBO)
754% eventdata  reserved - to be defined in a future version of MATLAB
755% handles    structure with handles and user data (see GUIDATA)
756
757% Hints: get(hObject,'Value') returns position of slider
758%        get(hObject,'Min') and get(hObject,'Max') to determine range of slider
759
760
761% --- Executes on slider movement.
762function slider10_Callback(hObject, eventdata, handles)
763% hObject    handle to slider1 (see GCBO)
764% eventdata  reserved - to be defined in a future version of MATLAB
765% handles    structure with handles and user data (see GUIDATA)
766
767% Hints: get(hObject,'Value') returns position of slider
768%        get(hObject,'Min') and get(hObject,'Max') to determine range of
769%        slider
770
771
772function closefcn(hObject, eventdata, handles)
773huvmat=findobj(allchild(0),'Name','uvmat');
774hhuvmat=guidata(huvmat);
775list_object_2=get(hhuvmat.list_object_2,'String');
776set(hhuvmat.list_object_2,'Value',numel(list_object_2))%select the last value ('...')
777delete(hObject)
778
779
780
781% --- Executes on selection change in popupmenu18.
782function popupmenu18_Callback(hObject, eventdata, handles)
783
784
785function edit91_Callback(hObject, eventdata, handles)
786% hObject    handle to edit91 (see GCBO)
787% eventdata  reserved - to be defined in a future version of MATLAB
788% handles    structure with handles and user data (see GUIDATA)
789
790% Hints: get(hObject,'String') returns contents of edit91 as text
791%        str2double(get(hObject,'String')) returns contents of edit91 as a double
792
793
794% --- Executes on button press in checkbox45.
795function checkbox45_Callback(hObject, eventdata, handles)
796% hObject    handle to checkbox45 (see GCBO)
797% eventdata  reserved - to be defined in a future version of MATLAB
798% handles    structure with handles and user data (see GUIDATA)
799
800% Hint: get(hObject,'Value') returns toggle state of checkbox45
801
802
803% --- Executes on selection change in popupmenu19.
804function popupmenu19_Callback(hObject, eventdata, handles)
805% hObject    handle to popupmenu19 (see GCBO)
806% eventdata  reserved - to be defined in a future version of MATLAB
807% handles    structure with handles and user data (see GUIDATA)
808
809% Hints: contents = get(hObject,'String') returns popupmenu19 contents as cell array
810%        contents{get(hObject,'Value')} returns selected item from popupmenu19
811
812
813
814
815
816
817
818function text_display_Callback(hObject, eventdata, handles)
819% hObject    handle to text_display (see GCBO)
820% eventdata  reserved - to be defined in a future version of MATLAB
821% handles    structure with handles and user data (see GUIDATA)
822
823% Hints: get(hObject,'String') returns contents of text_display as text
824%        str2double(get(hObject,'String')) returns contents of text_display as a double
825
826
827% --- Executes during object creation, after setting all properties.
828function text_display_CreateFcn(hObject, eventdata, handles)
829% hObject    handle to text_display (see GCBO)
830% eventdata  reserved - to be defined in a future version of MATLAB
831% handles    empty - handles not created until after all CreateFcns called
832
833% Hint: edit controls usually have a white background on Windows.
834%       See ISPC and COMPUTER.
835if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
836    set(hObject,'BackgroundColor','white');
837end
838
839
Note: See TracBrowser for help on using the repository browser.