source: trunk/src/view_field.m @ 428

Last change on this file since 428 was 428, checked in by sommeria, 12 years ago

bugs fixed. Introduction of transparency and axis aspect ratio in uvmat

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