source: trunk/src/view_field.m @ 589

Last change on this file since 589 was 569, checked in by sommeria, 8 years ago

many corrections; introduction of browse_data to scan the whole set of data, used also to replicate data in calibration mode

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