source: trunk/src/view_field.m @ 1134

Last change on this file since 1134 was 1127, checked in by g7moreau, 12 months ago

Update Joel email

File size: 34.8 KB
RevLine 
[198]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....)
[809]13
14%=======================================================================
[1126]15% Copyright 2008-2024, LEGI UMR 5519 / CNRS UGA G-INP, Grenoble, France
[809]16%   http://www.legi.grenoble-inp.fr
[1127]17%   Joel.Sommeria - Joel.Sommeria (A) univ-grenoble-alpes.fr
[198]18%
[809]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,
[198]27%     but WITHOUT ANY WARRANTY; without even the implied warranty of
28%     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
[809]29%     GNU General Public License (see LICENSE.txt) for more details.
30%=======================================================================
[198]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
[681]69set(hObject,'WindowKeyPressFcn',{'keyboard_callback',handles})%set keyboard action function
[432]70set(hObject,'WindowButtonMotionFcn',{'mouse_motion',handles})%set mouse action functio
[198]71set(hObject,'WindowButtonDownFcn',{'mouse_down'})%set mouse click action function
[432]72set(hObject,'WindowButtonUpFcn',{'mouse_up',handles})
[406]73set(hObject,'DeleteFcn',{@closefcn})%
[429]74set(hObject,'ResizeFcn',{@ResizeFcn,handles})%
[544]75ViewFieldData.PlotAxes=[];%initiates the record of the current field (will be updated by plot_field)
[429]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
[198]79AxeData.LimEditBox=1; %initialise AxeData, the parent figure sets plot parameters
[511]80set(handles.PlotAxes,'UserData',AxeData)
[413]81if exist('Field','var')
[881]82    [PlotType,PlotParamOut]= plot_field(Field,handles.PlotAxes);
[748]83    set(handles.Axes,'Visible','on')
[413]84    if isfield(PlotParamOut,'Vectors')
85        set(handles.Vectors,'Visible','on')
[599]86    else
87        set(handles.Vectors,'Visible','off')
[413]88    end
[599]89    if isfield(PlotParamOut,'Scalar')
90        set(handles.Scalar,'Visible','on')
91    else
92        set(handles.Scalar,'Visible','off')
[881]93    end   
[591]94    errormsg=fill_GUI(PlotParamOut,hObject);
[569]95    if ~isempty(errormsg)
96        msgbox_uvmat('ERROR',errormsg)
97        return
98    end
[198]99end
[429]100
[432]101%put the GUI on the lower right of the sceen
102pos_view_field=get(hObject,'Position');
[644]103set(0,'Unit','pixel')
[432]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
[402]109%------------------------------------------------------------------------
[429]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
[690]119%% reset position of text_display and TableDisplay
120% reset position of text_display
[726]121set(handles.text_display,'Units','pixels');
[717]122pos_1=get(handles.text_display,'Position');% [lower x lower y width height] for text_display
123pos_1(1)=size_fig(3)-pos_1(3);             % set text display to the right of the fig
124pos_1(2)=size_fig(4)-pos_1(4);             % set text display to the top of the fig
125set(handles.text_display,'Position',pos_1)
126% reset position of TableDisplay
[873]127pos_TableDisplay=[pos_1(1) 2 pos_1(3) 2.2*pos_1(4)];
128set(handles.TableDisplay,'Position',pos_TableDisplay)
129
[690]130% reset position of CheckTable
131pos_CheckTable=get(handles.CheckTable,'Position');% [lower x lower y width height] for CheckHold
[873]132pos_CheckTable(1)=pos_1(1);%-pos_CheckTable(3);       % set 'CheckHold' to the right of the fig
133pos_CheckTable(2)=pos_TableDisplay(2)+pos_TableDisplay(4);%size_fig(4)-pos_CheckTable(4);          % set 'CheckHold' to the lower edge of text display
[690]134set(handles.CheckTable,'Position',pos_CheckTable)
[429]135
[644]136%% reset position of CheckHold
137pos_CheckHold=get(handles.CheckHold,'Position');% [lower x lower y width height] for CheckHold
138pos_CheckHold(1)=size_fig(3)-pos_CheckHold(3);       % set 'CheckHold' to the right of the fig
139pos_CheckHold(2)=pos_1(2)-pos_CheckHold(4);          % set 'CheckHold' to the lower edge of text display
140set(handles.CheckHold,'Position',pos_CheckHold)
141
[748]142%% reset position of Axes
143pos_2=get(handles.Axes,'Position');% [lower x lower y width height] for frame 'Coordinates'
[644]144pos_2(1)=size_fig(3)-pos_2(3);       % set 'Coordinates' to the right of the fig
145pos_2(2)=pos_CheckHold(2)-pos_2(4);          % set 'Coordinates' to the lower edge of text display, allowing a margin for CheckHold
[748]146set(handles.Axes,'Position',pos_2)
[429]147
148%% reset position of  Scalar
[644]149pos_3=get(handles.Scalar,'Position'); % [lower x lower y width height] for frame 'Scalar'
150pos_3(1)=size_fig(3)-pos_3(3);         % set 'Scalar' to the right of the fig
[429]151if strcmp(get(handles.Scalar,'visible'),'on')
[644]152    pos_3(2)=pos_2(2)-pos_3(4); % set 'Scalar' to the lower edge of frame 'Coordinates' if visible
[429]153else
[644]154    pos_3(2)=pos_2(2);% set 'Scalar' to the lower edge of frame 'text display' if  unvisible
[429]155end
156set(handles.Scalar,'Position',pos_3)
157
158%% reset position of  Vectors
159pos_4=get(handles.Vectors,'Position');
160pos_4(1)=size_fig(3)-pos_4(3);
161if strcmp(get(handles.Vectors,'visible'),'on')
162    pos_4(2)=pos_3(2)-pos_4(4);
163else
164    pos_4(2)=pos_3(2);
165end
166set(handles.Vectors,'Position',pos_4)
167
168%% reset position and scale of axis
[717]169set(handles.PlotAxes,'Units','pixels')
[429]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));
[511]175set(handles.PlotAxes,'Position',pos)
[717]176set(handles.PlotAxes,'Units','normalized')
[429]177
178%------------------------------------------------------------------------
179%------------------------------------------------------------------------
[198]180% --- Outputs from this function are returned to the command menuline.
181function varargout = view_field_OutputFcn(hObject, eventdata, handles)
[402]182%------------------------------------------------------------------------
[198]183varargout{1} = handles.output;% the only output argument is the handle to the GUI figure
[511]184varargout{2} = strcmp(get(handles.PlotAxes,'Visible'),'on');% check active plot axis
[198]185
[402]186%------------------------------------------------------------------------
187%--- activated when closing the GUI view_field
188function closefcn(gcbo,eventdata)
189%------------------------------------------------------------------------
190huvmat=findobj(allchild(0),'Tag','uvmat');%find the current uvmat interface handle
191if ~isempty(huvmat)
192    hhuvmat=guidata(huvmat);
[650]193    set(hhuvmat.CheckViewField,'Value',0)
[402]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
[544]200        hother=[findobj(hhuvmat.PlotAxes,'Tag','proj_object');findobj(hhuvmat.PlotAxes,'Tag','DeformPoint')];%find all the proj object and deform point representations
[402]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
[772]218hciv=findobj(allchild(0),'Tag','civ_input');%find the current civ GUI
[413]219if ~isempty(hciv)
220    hhciv=guidata(hciv);
221    set(hhciv.TestCiv1,'Value',0)% desactivate  TestCiv1 if on
[772]222    set(hhciv.TestCiv1,'BackgroundColor',[0 1 0])%
[413]223end
224corrfig=findobj(allchild(0),'tag','corrfig');% look for a civ correlation window used with TesCiv1
225if ~isempty(corrfig)
226    delete(corrfig)
227end
[198]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;
[356]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);
[198]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
[511]306            axes(handles.PlotAxes)
[198]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%-------------------------------------------------------------------
319hfig=figure;
[752]320hc=copyobj(handles.PlotAxes,hfig);
321set(hc,'Position',[0.1 0.1 0.8 0.8])
322h=findobj(handles.PlotAxes,'tag','ima'); %look for image in the plot
[717]323if ~isempty(h)
324    h=findobj(handles.PlotAxes,'tag','ima'); %look for image in the plot
325    map=colormap(handles.PlotAxes);
326    colormap(map);%transmit the current colormap to the zoom fig
327    colorbar
328end
[198]329
[717]330% --------------------------------------------------------------------
331function MenuExportAxis_Callback(hObject, eventdata, handles)
332ListFig=findobj(allchild(0),'Type','figure');
333nb_option=0;
334menu={};
335for ilist=1:numel(ListFig)
336    FigName=get(ListFig(ilist),'name');
337    if isempty(FigName)
[1064]338            if isnumeric( ListFig(ilist))
339              FigName=  ['figure ' num2str(ListFig(ilist))];
340            else
341                FigName=['figure ' num2str(ListFig(ilist).Number)];
342            end
[717]343    end
344    if ~strcmp(FigName,'uvmat')
345        ListAxes=findobj(ListFig(ilist),'Type','axes');
346        ListTags=get(ListAxes,'Tag');
347        if ~isempty(ListTags) && ~isempty(find(~strcmp('Colorbar',ListTags), 1))
348            ListAxes=ListAxes(~strcmp('Colorbar',ListTags));
349            if numel(ListAxes)==1
350                nb_option=nb_option+1;
351                menu{nb_option}=FigName ;
352                AxesHandle(nb_option)=ListAxes;
353            else
354                nb_axis=0;
355                for iaxes=1:numel(ListAxes)
356                    nb_axis=nb_axis+1;
357                    nb_option=nb_option+1;
358                    menu{nb_option}=[FigName '_' num2str(nb_axis)];
359                    AxesHandle(nb_option)=ListAxes(nb_axis);
360                end
361            end
362        end
363    end
364end
365if isempty(menu)
366    answer=msgbox_uvmat('INPUT_Y-N','no existing plotting axes available, create new figure?');
367    if strcmp(answer,'Yes')
368        hfig=figure;
369        copyobj(handles.PlotAxes,hfig);
370    else
371        return
372    end
373    map=colormap(handles.PlotAxes);
374    colormap(map);%transmit the current colormap to the zoom fig
375    colorbar
376else
377    answer=msgbox_uvmat('INPUT_MENU','select a figure/axis on which the current uvmat plot will be exported',menu);
378    if isempty(answer)
379        return
380    else
381        axes(AxesHandle(answer))
382        hold on
383        hchild=get(handles.PlotAxes,'children');
384        copyobj(hchild,gca);
385    end
386end
387
[198]388%-------------------------------------------------------------------
389%-------------------------------------------------------------------
390% III - MAIN REFRESH FUNCTIONS : 'FRAME PLOT'
391%-------------------------------------------------------------------
392%-------------------------------------------------------------------
393
394%Executes on button press in runplus: make one step forward and call
395%run0. The step forward is along the fields series 1 or 2 depending on
396%the scan_i and scan_j check box (exclusive each other)
397%-------------------------------------------------------------------
398function runplus_Callback(hObject, eventdata, handles)
399increment=str2num(get(handles.increment_scan,'String')); %get the field increment d
400runpm(hObject,eventdata,handles,increment)
401
402%-------------------------------------------------------------------
403%Executes on button press in runmin: make one step backward and call
404%run0. The step backward is along the fields series 1 or 2 depending on
405%the scan_i and scan_j check box (exclusive each other)
406%-------------------------------------------------------------------
407function runmin_Callback(hObject, eventdata, handles)
408increment=-str2num(get(handles.increment_scan,'String')); %get the field increment d
409runpm(hObject,eventdata,handles,increment)
410
[622]411%------------------------------------------------------------------------
[198]412% --- translate coordinate to matrix index
[622]413%------------------------------------------------------------------------
[198]414function [indx,indy]=pos2ind(x0,rangx0,nxy)
415indx=1+round((nxy(2)-1)*(x0-rangx0(1))/(rangx0(2)-rangx0(1)));% index x of pixel 
416indy=1+round((nxy(1)-1)*(y12-rangy0(1))/(rangy0(2)-rangy0(1)));% index y of pixel
417
[622]418%------------------------------------------------------------------------
419% --- Executes on button press in 'CheckZoom'.
420%------------------------------------------------------------------------
[428]421function CheckZoom_Callback(hObject, eventdata, handles)
[622]422
423if get(handles.CheckZoom,'Value')
[428]424    set(handles.CheckFixLimits,'Value',1)% propose by default fixed limits for the plotting axes
[622]425    set(handles.CheckZoomFig,'Value',0)%desactivate zoom fig
[428]426end
427
[622]428%------------------------------------------------------------------------
429% --- Executes on button press in CheckZoomFig.
430%------------------------------------------------------------------------
431function CheckZoomFig_Callback(hObject, eventdata, handles)
432if get(handles.CheckZoomFig,'Value')
433    set(handles.CheckZoom,'value',0)
434end
435
[726]436%------------------------------------------------------------------------
[198]437% --- Executes on button press in 'FixLimits'.
[726]438%------------------------------------------------------------------------
[295]439function CheckFixLimits_Callback(hObject, eventdata, handles)
440test=get(handles.CheckFixLimits,'Value');
441update_plot(handles)
[428]442 
[726]443%------------------------------------------------------------------------
[428]444% --- Executes on button press in CheckFixAspectRatio.
[726]445%------------------------------------------------------------------------
[428]446function CheckFixAspectRatio_Callback(hObject, eventdata, handles)
447if get(handles.CheckFixAspectRatio,'Value')
448    update_plot(handles);
[198]449else
[428]450    update_plot(handles);
[198]451end
452
[726]453%------------------------------------------------------------------------
[428]454function num_AspectRatio_Callback(hObject, eventdata, handles)
[726]455%------------------------------------------------------------------------
[428]456set(handles.CheckFixAspectRatio,'Value',1)% select the fixed aspect ratio button
457update_plot(handles);
[198]458
459%-------------------------------------------------------------------
460%-------------------------------------------------------------------
461%  - FUNCTIONS FOR SETTING PLOTTING PARAMETERS
462
463%------------------------------------------------------------------
464
465
466%------------------------------------------------------------------
467% --- Executes on selection change in col_vec: choice of the color code.
468%
469function col_vec_Callback(hObject, eventdata, handles)
470%------------------------------------------------------------------
471% edit the choice for color code
472list_code=get(handles.col_vec,'String');% list menu fields
473index_code=get(handles.col_vec,'Value');% selected string index
474col_code= list_code{index_code(1)}; % selected field
475if isequal(col_code,'black') | isequal(col_code,'white')
476   set(handles.slider1,'Visible','off')
477   set(handles.slider2,'Visible','off')
478   set(handles.colcode1,'Visible','off')
479   set(handles.colcode2,'Visible','off')
480   set(handles.AutoVecColor,'Visible','off')
481   set_vec_col_bar(handles)
482else
483   set(handles.slider1,'Visible','on')
484   set(handles.slider2,'Visible','on')
485   set(handles.colcode1,'Visible','on')
486   set(handles.colcode2,'Visible','on')
487   set(handles.AutoVecColor,'Visible','on') 
488   if isequal(col_code,'ima_cor')
489       set(handles.AutoVecColor,'Value',0)%fixed scale by default
490       set(handles.vec_col_bar,'Value',0)% 3 colors r,g,b by default
491       set(handles.slider1,'Min',0);
492       set(handles.slider1,'Max',1);
493       set(handles.slider2,'Min',0);
494       set(handles.slider2,'Max',1);
495 %      set(handles.min_C_title_vec,'String','0')
496       set(handles.max_vec,'String','1')
497       set(handles.colcode1,'String','0.333')
498       colcode1_Callback(hObject, eventdata, handles)
499       set(handles.colcode2,'String','0.666')
500       colcode2_Callback(hObject, eventdata, handles)
501   else
502       set(handles.AutoVecColor,'Value',1)%auto scale between min,max by default
503       set(handles.vec_col_bar,'Value',1)% colormap 'jet' by default
504       minval=get(handles.slider1,'Min');
505       maxval=get(handles.slider1,'Max');
506       set(handles.slider1,'Value',minval)
507       set(handles.slider2,'Value',maxval)
508       set_vec_col_bar(handles)
509   end
510%    slider_update(handles)
511end
512%replot the current graph
513run0_Callback(hObject, eventdata, handles)
514
515
516%----------------------------------------------------------------
517% -- Executes on slider movement to set the color code
518%
519function slider1_Callback(hObject, eventdata, handles)
520%------------------------------------------------------------------
521slider1=get(handles.slider1,'Value');
522min_val=str2num(get(handles.min_vec,'String'));
523max_val=str2num(get(handles.max_vec,'String'));
524col=min_val+(max_val-min_val)*slider1;
525set(handles.colcode1,'String',num2str(col))
526if(get(handles.slider2,'Value') < col)%move also the second slider at the same value if needed
527    set(handles.slider2,'Value',col)
528    set(handles.colcode2,'String',num2str(col))
529end
530colcode1_Callback(hObject, eventdata, handles)
531
532%----------------------------------------------------------------
533% Executes on slider movement to set the color code
534%----------------------------------------------------------------
535function slider2_Callback(hObject, eventdata, handles)
536slider2=get(handles.slider2,'Value');
537min_val=str2num(get(handles.min_vec,'String'));
538max_val=str2num(get(handles.max_vec,'String'));
539col=min_val+(max_val-min_val)*slider2;
540set(handles.colcode2,'String',num2str(col))
541if(get(handles.slider1,'Value') > col)%move also the first slider at the same value if needed
542    set(handles.slider1,'Value',col)
543    set(handles.colcode1,'String',num2str(col))
544end
545colcode2_Callback(hObject, eventdata, handles)
546
547%----------------------------------------------------------------
548%execute on return carriage on the edit box corresponding to slider 1
549%----------------------------------------------------------------
550function colcode1_Callback(hObject, eventdata, handles)
551% col=str2num(get(handles.colcode1,'String'));
552% set(handles.slider1,'Value',col)
553set_vec_col_bar(handles)
554update_plot(handles)
555
556%----------------------------------------------------------------
557%execute on return carriage on the edit box corresponding to slider 2
558%----------------------------------------------------------------
559function colcode2_Callback(hObject, eventdata, handles)
560% col=str2num(get(handles.colcode2,'String'));
561% set(handles.slider2,'Value',col)
562% slider2_Callback(hObject, eventdata, handles)
563set_vec_col_bar(handles)
564update_plot(handles)
565
566%-------------------------------------------------------
567% --- Executes on button press in AutoVecColor.
568%-------------------------------------------------------
569function vec_col_bar_Callback(hObject, eventdata, handles)
570set_vec_col_bar(handles)
571
572%------------------------------------------------
573%CALLBACKS FOR PLOTTING PARAMETERS
574%-------------------------------------------------
575
576%------------------------------------------------------------------------
[295]577function num_MinX_Callback(hObject, eventdata, handles)
[198]578%------------------------------------------------------------------------
[295]579set(handles.CheckFixLimits,'Value',1) %suppress auto mode
[625]580% set(handles.CheckFixLimits,'BackgroundColor',[1 1 0])
[198]581update_plot(handles);
582
583%------------------------------------------------------------------------
[295]584function num_MaxX_Callback(hObject, eventdata, handles)
[198]585%------------------------------------------------------------------------
[295]586set(handles.CheckFixLimits,'Value',1) %suppress auto mode
[625]587% set(handles.CheckFixLimits,'BackgroundColor',[1 1 0])
[198]588update_plot(handles);
589
590%------------------------------------------------------------------------
[295]591function num_MinY_Callback(hObject, eventdata, handles)
[198]592%------------------------------------------
[295]593set(handles.CheckFixLimits,'Value',1) %suppress auto mode
[625]594% set(handles.CheckFixLimits,'BackgroundColor',[1 1 0])
[198]595update_plot(handles);
596
597%------------------------------------------------------------------------
[295]598function num_MaxY_Callback(hObject, eventdata, handles)
[198]599%------------------------------------------------------------------------
[295]600set(handles.CheckFixLimits,'Value',1) %suppress auto mode
[625]601% set(handles.CheckFixLimits,'BackgroundColor',[1 1 0])
[198]602update_plot(handles);
603
604%-----------------------------------------------------------------
[295]605function num_MinA_Callback(hObject, eventdata, handles)
[198]606%------------------------------------------
[295]607set(handles.CheckFixScalar,'Value',1) %suppress auto mode
608set(handles.CheckFixScalar,'BackgroundColor',[1 1 0])
[198]609update_plot(handles)
610
611%-----------------------------------------------------------------
[295]612function num_MaxA_Callback(hObject, eventdata, handles)
[198]613%--------------------------------------------
[295]614set(handles.CheckFixScalar,'Value',1) %suppress auto mode
[625]615% set(handles.CheckFixScalar,'BackgroundColor',[1 1 0])
[198]616update_plot(handles)
617
618%-----------------------------------------------
[295]619function CheckFixScalar_Callback(hObject, eventdata, handles)
[198]620%--------------------------------------------
[295]621test=get(handles.CheckFixScalar,'Value');
[625]622% if test
623%     set(handles.CheckFixScalar,'BackgroundColor',[1 1 0])
624% else
625%     set(handles.CheckFixScalar,'BackgroundColor',[0.7 0.7 0.7])
626%     update_plot(handles);
627% %     set(handles.MinA,'String',num2str(ScalOut.MinA,3))
628% %     set(handles.MaxA,'String',num2str(ScalOut.MaxA,3))
629% end
[198]630
631%-------------------------------------------------------------------
[295]632function CheckBW_Callback(hObject, eventdata, handles)
[198]633%-------------------------------------------------------------------
634update_plot(handles)
635
636%-------------------------------------------------------------------
[295]637function ListContour_Callback(hObject, eventdata, handles)
[198]638%-------------------------------------------------------------------
639val=get(handles.Contours,'Value');
640if val==2
641    set(handles.interval_txt,'Visible','on')
642    set(handles.IncrA,'Visible','on')
643else
644    set(handles.interval_txt,'Visible','off')
645    set(handles.IncrA,'Visible','off')
646end
647update_plot(handles)
648
649%-------------------------------------------------------------------
650function IncrA_Callback(hObject, eventdata, handles)
651%-------------------------------------------------------------------
652update_plot(handles)
653
654%-------------------------------------------------------------------
655function HideWarning_Callback(hObject, eventdata, handles)
656%-------------------------------------------------------------------
657update_plot(handles)
658
659%-------------------------------------------------------------------
660function HideFalse_Callback(hObject, eventdata, handles)
661%-------------------------------------------------------------------
662update_plot(handles)
663
664%-------------------------------------------------------------------
[612]665function num_VecScale_Callback(hObject, eventdata, handles)
[198]666%-------------------------------------------------------------------
[612]667set(handles.CheckFixVectors,'Value',1);
[198]668update_plot(handles)
669
670%-------------------------------------------------------------------
671function FixVec_Callback(hObject, eventdata, handles)
672%-------------------------------------------------------------------
673test=get(handles.FixVec,'Value');
674if test
675    set(handles.FixVec,'BackgroundColor',[1 1 0])
676else
677    update_plot(handles);
678    %set(handles.VecScale,'String',num2str(ScalOut.VecScale,3))
[625]679%     set(handles.FixVec,'BackgroundColor',[0.7 0.7 0.7])
[198]680end
681
682%-------------------------------------------------------
683% --- Executes on selection change in decimate4 (nb_vec/4).
684%-------------------------------------------------------
[295]685function CheckDecimate4_Callback(hObject, eventdata, handles)
[198]686update_plot(handles)
687
688
689%-------------------------------------------------------
690% --- Executes on selection change in color_code menu
691%-------------------------------------------------------
692function color_code_Callback(hObject, eventdata, handles)
693set_vec_col_bar(handles)
694update_plot(handles);
695
696%-------------------------------------------------------
697% --- Executes on button press in AutoVecColor.
698%-------------------------------------------------------
699function AutoVecColor_Callback(hObject, eventdata, handles)
700test=get(handles.AutoVecColor,'Value');
701if test
702    set(handles.AutoVecColor,'BackgroundColor',[1 1 0])
703else
704    update_plot(handles);
705    %set(handles.VecScale,'String',num2str(ScalOut.VecScale,3))
706    set(handles.AutoVecColor,'BackgroundColor',[0.7 0.7 0.7])
707end
708%set_vec_col_bar(handles)
709
710%-------------------------------------------------------
711% --- Executes on selection change in max_vec.
712%-------------------------------------------------------
713function min_vec_Callback(hObject, eventdata, handles)
714max_vec_Callback(hObject, eventdata, handles)
715
716% --- Executes on selection change in max_vec.
717function max_vec_Callback(hObject, eventdata, handles)
718set(handles.AutoVecColor,'Value',1)
719AutoVecColor_Callback(hObject, eventdata, handles)
720min_val=str2num(get(handles.min_vec,'String'));
721max_val=str2num(get(handles.max_vec,'String'));
722slider1=get(handles.slider1,'Value');
723slider2=get(handles.slider2,'Value');
724colcode1=min_val+(max_val-min_val)*slider1;
725colcode2=min_val+(max_val-min_val)*slider2;
726set(handles.colcode1,'String',num2str(colcode1))
727set(handles.colcode2,'String',num2str(colcode2))
728update_plot(handles);
729
730%-------------------------------------------------------------------
731%update the display of color code for vectors
732function set_vec_col_bar(handles)
733%-------------------------------------------------------------------
734%get the image of the color display button 'vec_col_bar' in pixels
735set(handles.vec_col_bar,'Unit','pixel');
736pos_vert=get(handles.vec_col_bar,'Position');
737set(handles.vec_col_bar,'Unit','Normalized');
738width=ceil(pos_vert(3));
739height=ceil(pos_vert(4));
740
741%get slider indications
742list=get(handles.color_code,'String');
743ichoice=get(handles.color_code,'Value');
744colcode.ColorCode=list{ichoice};
745colcode.MinC=str2num(get(handles.min_vec,'String'));
746colcode.MaxC=str2num(get(handles.max_vec,'String'));
747test3color=strcmp(colcode.ColorCode,'rgb') || strcmp(colcode.ColorCode,'bgr');
748if test3color
749    colcode.colcode1=str2num(get(handles.colcode1,'String'));
750    colcode.colcode2=str2num(get(handles.colcode2,'String'));
751end
752colcode.FixedCbounds=0;
753colcode.FixedCbounds=1;
754vec_C=colcode.MinC+(colcode.MaxC-colcode.MinC)*[0.5:width-0.5]/width;%sample of vec_C values from min to max
755[colorlist,col_vec]=set_col_vec(colcode,vec_C);
756oneheight=ones(1,height);
757A1=colorlist(col_vec,1)*oneheight;
758A2=colorlist(col_vec,2)*oneheight;
759A3=colorlist(col_vec,3)*oneheight;
760A(:,:,1)=A1';
761A(:,:,2)=A2';
762A(:,:,3)=A3';
763set(handles.vec_col_bar,'Cdata',A)
764
[295]765%-------------------------------------------------------------------
766function update_plot(handles)
767%-------------------------------------------------------------------
768Data=get(handles.view_field,'UserData');
[544]769AxeData=Data.PlotAxes;% retrieve the current plotted data
[292]770PlotParam=read_GUI(handles.view_field);
[511]771[PP,PlotParamOut]= plot_field(AxeData,handles.PlotAxes,PlotParam);
[591]772errormsg=fill_GUI(PlotParamOut,handles.view_field);
[726]773if ~isempty(errormsg)
774    msgbox_uvmat('ERROR',errormsg)
775    return
776end
777hedit=findobj(handles.view_field,'Style','edit');
778set(hedit,'BackgroundColor',[1 1 1])
[198]779
[220]780%------------------------------------------------------------------------
[198]781% --- Executes on button press in Menu/Export/field in workspace.
782function MenuExportField_Callback(hObject, eventdata, handles)
[220]783%------------------------------------------------------------------------
[198]784global Data_view_field
785% huvmat=findobj(allchild(0),'Name','uvmat');
786Data_view_field=get(handles.view_field,'UserData');
[544]787Data_view_field=Data_view_field.PlotAxes;
[198]788% Data_view_field=UvData.ProjField_2;
789evalin('base','global Data_view_field')%make CurData global in the workspace
790display(['UserData of view_field :'])
791evalin('base','Data_view_field') %display CurData in the workspace
792commandwindow;
793
[220]794%------------------------------------------------------------------------
[198]795% --- Executes on button press in Menu/Export/extract figure.
796function MenuExport_plot_Callback(hObject, eventdata, handles)
[220]797%------------------------------------------------------------------------
[198]798huvmat=get(handles.MenuExport_plot,'parent');
799UvData=get(huvmat,'UserData');
800hfig=figure;
[511]801newaxes=copyobj(handles.PlotAxes,hfig);
802map=colormap(handles.PlotAxes);
[198]803colormap(map);%transmit the current colormap to the zoom fig
804colorbar
805
806
[406]807% --- Executes on selection change in ColorCode.
808function ColorCode_Callback(hObject, eventdata, handles)
809
810
811% --- Executes on selection change in ColorScalar.
812function ColorScalar_Callback(hObject, eventdata, handles)
813
[413]814
[428]815function num_ColCode2_Callback(hObject, eventdata, handles)
[413]816
[690]817
818
819% --- Executes on button press in CheckTable.
820function CheckTable_Callback(hObject, eventdata, handles)
821if get(handles.CheckTable,'Value')
822    set(handles.TableDisplay,'Visible','on')
823else
824    set(handles.TableDisplay,'Visible','off')
825end
826   
Note: See TracBrowser for help on using the repository browser.