source: trunk/src/view_field.m @ 611

Last change on this file since 611 was 599, checked in by sommeria, 8 years ago

various bug corrections. Steps further for civ_series (still development needed)

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