source: trunk/src/view_field.m @ 99

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

plot_field.m, update_obj.m do not change figure names
view_field.m,uvmat.m cleaning code

File size: 37.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
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,haxes]= 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)
609update_plot(handles)
610
611
612%-------------------------------------------------------
613% --- Executes on selection change in color_code menu
614%-------------------------------------------------------
615function color_code_Callback(hObject, eventdata, handles)
616set_vec_col_bar(handles)
617update_plot(handles);
618
619%-------------------------------------------------------
620% --- Executes on button press in AutoVecColor.
621%-------------------------------------------------------
622function AutoVecColor_Callback(hObject, eventdata, handles)
623test=get(handles.AutoVecColor,'Value');
624if test
625    set(handles.AutoVecColor,'BackgroundColor',[1 1 0])
626else
627    update_plot(handles);
628    %set(handles.VecScale,'String',num2str(ScalOut.VecScale,3))
629    set(handles.AutoVecColor,'BackgroundColor',[0.7 0.7 0.7])
630end
631%set_vec_col_bar(handles)
632
633%-------------------------------------------------------
634% --- Executes on selection change in max_vec.
635%-------------------------------------------------------
636function min_vec_Callback(hObject, eventdata, handles)
637max_vec_Callback(hObject, eventdata, handles)
638
639% --- Executes on selection change in max_vec.
640function max_vec_Callback(hObject, eventdata, handles)
641set(handles.AutoVecColor,'Value',1)
642AutoVecColor_Callback(hObject, eventdata, handles)
643min_val=str2num(get(handles.min_vec,'String'));
644max_val=str2num(get(handles.max_vec,'String'));
645slider1=get(handles.slider1,'Value');
646slider2=get(handles.slider2,'Value');
647colcode1=min_val+(max_val-min_val)*slider1;
648colcode2=min_val+(max_val-min_val)*slider2;
649set(handles.colcode1,'String',num2str(colcode1))
650set(handles.colcode2,'String',num2str(colcode2))
651update_plot(handles);
652
653%-------------------------------------------------------------------
654%update the display of color code for vectors
655function set_vec_col_bar(handles)
656%-------------------------------------------------------------------
657%get the image of the color display button 'vec_col_bar' in pixels
658set(handles.vec_col_bar,'Unit','pixel');
659pos_vert=get(handles.vec_col_bar,'Position');
660set(handles.vec_col_bar,'Unit','Normalized');
661width=ceil(pos_vert(3));
662height=ceil(pos_vert(4));
663
664%get slider indications
665list=get(handles.color_code,'String');
666ichoice=get(handles.color_code,'Value');
667colcode.ColorCode=list{ichoice};
668colcode.MinC=str2num(get(handles.min_vec,'String'));
669colcode.MaxC=str2num(get(handles.max_vec,'String'));
670test3color=strcmp(colcode.ColorCode,'rgb') || strcmp(colcode.ColorCode,'bgr');
671if test3color
672    colcode.colcode1=str2num(get(handles.colcode1,'String'));
673    colcode.colcode2=str2num(get(handles.colcode2,'String'));
674end
675% colcode.option=get(handles.vec_col_bar,'Value');
676colcode.FixedCbounds=0;
677% list_code=get(handles.col_vec,'String');% list menu fields
678% index_code=get(handles.col_vec,'Value');% selected string index
679% colcode.CName= list_code{index_code(1)}; % selected field used for vector color
680colcode.FixedCbounds=1;
681vec_C=colcode.MinC+(colcode.MaxC-colcode.MinC)*[0.5:width-0.5]/width;%sample of vec_C values from min to max
682[colorlist,col_vec]=set_col_vec(colcode,vec_C);
683oneheight=ones(1,height);
684A1=colorlist(col_vec,1)*oneheight;
685A2=colorlist(col_vec,2)*oneheight;
686A3=colorlist(col_vec,3)*oneheight;
687A(:,:,1)=A1';
688A(:,:,2)=A2';
689A(:,:,3)=A3';
690set(handles.vec_col_bar,'Cdata',A)
691
692
693%-------------------------------------------------------------------
694function [PlotType,ScalOut]=update_plot(handles)
695%-------------------------------------------------------------------
696haxes= handles.axes3;
697huvmat=findobj(allchild(0),'tag','uvmat');
698ProjField=get(haxes,'UserData');
699%
700% AxeData=get(haxes,'UserData');
701PlotParam=read_plot_param(handles);
702[PlotType,PlotParamOut]= plot_field(ProjField,haxes,PlotParam,1);
703write_plot_param(handles,PlotParamOut); %update the auto plot parameters
704
705%------------------------------------------------------
706% --- Executes on button press in Menu/Export/field in workspace.
707%------------------------------------------------------
708function MenuExportField_Callback(hObject, eventdata, handles)
709
710global CurData
711huvmat=findobj(allchild(0),'Name','uvmat');
712UvData=get(huvmat,'UserData');
713CurData=UvData.ProjField_2;
714evalin('base','global CurData')%make CurData global in the workspace
715display(['UserData of view_field :'])
716evalin('base','CurData') %display CurData in the workspace
717commandwindow;
718
719%------------------------------------------------------
720% --- Executes on button press in Menu/Export/extract figure.
721%------------------------------------------------------
722function MenuExport_plot_Callback(hObject, eventdata, handles)
723huvmat=get(handles.MenuExport_plot,'parent');
724UvData=get(huvmat,'UserData');
725hfig=figure;
726newaxes=copyobj(handles.axes3,hfig);
727map=colormap(handles.axes3);
728colormap(map);%transmit the current colormap to the zoom fig
729colorbar
730
731
732
733function npx_Callback(hObject, eventdata, handles)
734
735
736
737function npy_Callback(hObject, eventdata, handles)
738
739
740function edit86_Callback(hObject, eventdata, handles)
741
742
743function edit87_Callback(hObject, eventdata, handles)
744
745
746% --- Executes on button press in auto_sclar.
747function auto_sclar_Callback(hObject, eventdata, handles)
748% hObject    handle to auto_sclar (see GCBO)
749% eventdata  reserved - to be defined in a future version of MATLAB
750% handles    structure with handles and user data (see GUIDATA)
751
752% Hint: get(hObject,'Value') returns toggle state of auto_sclar
753
754
755function edit88_Callback(hObject, eventdata, handles)
756
757
758
759% --- Executes on button press in AutoScal.
760function checkbox40_Callback(hObject, eventdata, handles)
761% hObject    handle to AutoScal (see GCBO)
762% eventdata  reserved - to be defined in a future version of MATLAB
763% handles    structure with handles and user data (see GUIDATA)
764
765% Hint: get(hObject,'Value') returns toggle state of AutoScal
766
767
768
769function edit82_Callback(hObject, eventdata, handles)
770
771
772
773function edit83_Callback(hObject, eventdata, handles)
774% hObject    handle to min_vec (see GCBO)
775% eventdata  reserved - to be defined in a future version of MATLAB
776% handles    structure with handles and user data (see GUIDATA)
777
778% Hints: get(hObject,'String') returns contents of min_vec as text
779%        str2double(get(hObject,'String')) returns contents of min_vec as a double
780
781
782% --- Executes on slider movement.
783function slider9_Callback(hObject, eventdata, handles)
784% hObject    handle to slider2 (see GCBO)
785% eventdata  reserved - to be defined in a future version of MATLAB
786% handles    structure with handles and user data (see GUIDATA)
787
788% Hints: get(hObject,'Value') returns position of slider
789%        get(hObject,'Min') and get(hObject,'Max') to determine range of slider
790
791
792% --- Executes on slider movement.
793function slider10_Callback(hObject, eventdata, handles)
794% hObject    handle to slider1 (see GCBO)
795% eventdata  reserved - to be defined in a future version of MATLAB
796% handles    structure with handles and user data (see GUIDATA)
797
798% Hints: get(hObject,'Value') returns position of slider
799%        get(hObject,'Min') and get(hObject,'Max') to determine range of
800%        slider
801
802
803% --- Executes on button press in AutoVecColor.
804function checkbox41_Callback(hObject, eventdata, handles)
805% hObject    handle to AutoVecColor (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% Hint: get(hObject,'Value') returns toggle state of AutoVecColor
810
811
812function edit89_Callback(hObject, eventdata, handles)
813% hObject    handle to max_vec (see GCBO)
814% eventdata  reserved - to be defined in a future version of MATLAB
815% handles    structure with handles and user data (see GUIDATA)
816
817% Hints: get(hObject,'String') returns contents of max_vec as text
818%        str2double(get(hObject,'String')) returns contents of max_vec as a double
819
820
821function edit90_Callback(hObject, eventdata, handles)
822% hObject    handle to colcode2 (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 colcode2 as text
827%        str2double(get(hObject,'String')) returns contents of colcode2 as a double
828
829
830
831
832function closefcn(hObject, eventdata, handles)
833huvmat=findobj(allchild(0),'Name','uvmat');
834hhuvmat=guidata(huvmat);
835list_object_2=get(hhuvmat.list_object_2,'String');
836set(hhuvmat.list_object_2,'Value',numel(list_object_2))%select the last value ('...')
837delete(hObject)
838
839
840
841% --- Executes on button press in checkbox42.
842function checkbox42_Callback(hObject, eventdata, handles)
843% hObject    handle to checkbox42 (see GCBO)
844% eventdata  reserved - to be defined in a future version of MATLAB
845% handles    structure with handles and user data (see GUIDATA)
846
847% Hint: get(hObject,'Value') returns toggle state of checkbox42
848
849
850% --- Executes on button press in checkbox43.
851function checkbox43_Callback(hObject, eventdata, handles)
852% hObject    handle to checkbox43 (see GCBO)
853% eventdata  reserved - to be defined in a future version of MATLAB
854% handles    structure with handles and user data (see GUIDATA)
855
856% Hint: get(hObject,'Value') returns toggle state of checkbox43
857
858
859% --- Executes on button press in checkbox44.
860function checkbox44_Callback(hObject, eventdata, handles)
861% hObject    handle to checkbox44 (see GCBO)
862% eventdata  reserved - to be defined in a future version of MATLAB
863% handles    structure with handles and user data (see GUIDATA)
864
865% Hint: get(hObject,'Value') returns toggle state of checkbox44
866
867
868% --- Executes on selection change in popupmenu18.
869function popupmenu18_Callback(hObject, eventdata, handles)
870
871
872function edit91_Callback(hObject, eventdata, handles)
873% hObject    handle to edit91 (see GCBO)
874% eventdata  reserved - to be defined in a future version of MATLAB
875% handles    structure with handles and user data (see GUIDATA)
876
877% Hints: get(hObject,'String') returns contents of edit91 as text
878%        str2double(get(hObject,'String')) returns contents of edit91 as a double
879
880
881% --- Executes on button press in checkbox45.
882function checkbox45_Callback(hObject, eventdata, handles)
883% hObject    handle to checkbox45 (see GCBO)
884% eventdata  reserved - to be defined in a future version of MATLAB
885% handles    structure with handles and user data (see GUIDATA)
886
887% Hint: get(hObject,'Value') returns toggle state of checkbox45
888
889
890% --- Executes on selection change in popupmenu19.
891function popupmenu19_Callback(hObject, eventdata, handles)
892% hObject    handle to popupmenu19 (see GCBO)
893% eventdata  reserved - to be defined in a future version of MATLAB
894% handles    structure with handles and user data (see GUIDATA)
895
896% Hints: contents = get(hObject,'String') returns popupmenu19 contents as cell array
897%        contents{get(hObject,'Value')} returns selected item from popupmenu19
898
899
900
901
902
903
904
905function text_display_Callback(hObject, eventdata, handles)
906% hObject    handle to text_display (see GCBO)
907% eventdata  reserved - to be defined in a future version of MATLAB
908% handles    structure with handles and user data (see GUIDATA)
909
910% Hints: get(hObject,'String') returns contents of text_display as text
911%        str2double(get(hObject,'String')) returns contents of text_display as a double
912
913
914% --- Executes during object creation, after setting all properties.
915function text_display_CreateFcn(hObject, eventdata, handles)
916% hObject    handle to text_display (see GCBO)
917% eventdata  reserved - to be defined in a future version of MATLAB
918% handles    empty - handles not created until after all CreateFcns called
919
920% Hint: edit controls usually have a white background on Windows.
921%       See ISPC and COMPUTER.
922if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
923    set(hObject,'BackgroundColor','white');
924end
925
926
Note: See TracBrowser for help on using the repository browser.