source: trunk/src/view_field.m @ 177

Last change on this file since 177 was 158, checked in by sommeria, 14 years ago

CoordType? not used, replaced by CoordUnit?
bug repair in check_field_structure

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