source: trunk/src/view_field.m @ 873

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

civ improved at mask edge

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