source: trunk/src/view_field.m @ 187

Last change on this file since 187 was 187, checked in by sommeria, 13 years ago

various bug repairs

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