source: trunk/src/view_field.m @ 690

Last change on this file since 690 was 690, checked in by sommeria, 10 years ago

representation of ancillary data as table improved.

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