source: trunk/src/view_field.m @ 146

Last change on this file since 146 was 144, checked in by sommeria, 14 years ago

connection between uvmat and get_field improved, cleaning of GUI get_field

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