source: trunk/src/view_field.m @ 935

Last change on this file since 935 was 924, checked in by g7moreau, 8 years ago
  • Update Copyright Copyright 2008-2016, LEGI UMR 5519 / CNRS UGA G-INP, Grenoble, France
File size: 34.6 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-2016, LEGI UMR 5519 / CNRS UGA 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);
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    errormsg=fill_GUI(PlotParamOut,hObject);
95    if ~isempty(errormsg)
96        msgbox_uvmat('ERROR',errormsg)
97        return
98    end
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
121set(handles.text_display,'Units','pixels');
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
127pos_TableDisplay=[pos_1(1) 2 pos_1(3) 2.2*pos_1(4)];
128set(handles.TableDisplay,'Position',pos_TableDisplay)
129
130% reset position of CheckTable
131pos_CheckTable=get(handles.CheckTable,'Position');% [lower x lower y width height] for CheckHold
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
134set(handles.CheckTable,'Position',pos_CheckTable)
135
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
142%% reset position of Axes
143pos_2=get(handles.Axes,'Position');% [lower x lower y width height] for frame 'Coordinates'
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
146set(handles.Axes,'Position',pos_2)
147
148%% reset position of  Scalar
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
151if strcmp(get(handles.Scalar,'visible'),'on')
152    pos_3(2)=pos_2(2)-pos_3(4); % set 'Scalar' to the lower edge of frame 'Coordinates' if visible
153else
154    pos_3(2)=pos_2(2);% set 'Scalar' to the lower edge of frame 'text display' if  unvisible
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
169set(handles.PlotAxes,'Units','pixels')
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)
176set(handles.PlotAxes,'Units','normalized')
177
178%------------------------------------------------------------------------
179%------------------------------------------------------------------------
180% --- Outputs from this function are returned to the command menuline.
181function varargout = view_field_OutputFcn(hObject, eventdata, handles)
182%------------------------------------------------------------------------
183varargout{1} = handles.output;% the only output argument is the handle to the GUI figure
184varargout{2} = strcmp(get(handles.PlotAxes,'Visible'),'on');% check active plot axis
185
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);
193    set(hhuvmat.CheckViewField,'Value',0)
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_input');%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',[0 1 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%-------------------------------------------------------------------
319hfig=figure;
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
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
329
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)
338        FigName=['figure ' num2str(ListFig(ilist))];
339    end
340    if ~strcmp(FigName,'uvmat')
341        ListAxes=findobj(ListFig(ilist),'Type','axes');
342        ListTags=get(ListAxes,'Tag');
343        if ~isempty(ListTags) && ~isempty(find(~strcmp('Colorbar',ListTags), 1))
344            ListAxes=ListAxes(~strcmp('Colorbar',ListTags));
345            if numel(ListAxes)==1
346                nb_option=nb_option+1;
347                menu{nb_option}=FigName ;
348                AxesHandle(nb_option)=ListAxes;
349            else
350                nb_axis=0;
351                for iaxes=1:numel(ListAxes)
352                    nb_axis=nb_axis+1;
353                    nb_option=nb_option+1;
354                    menu{nb_option}=[FigName '_' num2str(nb_axis)];
355                    AxesHandle(nb_option)=ListAxes(nb_axis);
356                end
357            end
358        end
359    end
360end
361if isempty(menu)
362    answer=msgbox_uvmat('INPUT_Y-N','no existing plotting axes available, create new figure?');
363    if strcmp(answer,'Yes')
364        hfig=figure;
365        copyobj(handles.PlotAxes,hfig);
366    else
367        return
368    end
369    map=colormap(handles.PlotAxes);
370    colormap(map);%transmit the current colormap to the zoom fig
371    colorbar
372else
373    answer=msgbox_uvmat('INPUT_MENU','select a figure/axis on which the current uvmat plot will be exported',menu);
374    if isempty(answer)
375        return
376    else
377        axes(AxesHandle(answer))
378        hold on
379        hchild=get(handles.PlotAxes,'children');
380        copyobj(hchild,gca);
381    end
382end
383
384%-------------------------------------------------------------------
385%-------------------------------------------------------------------
386% III - MAIN REFRESH FUNCTIONS : 'FRAME PLOT'
387%-------------------------------------------------------------------
388%-------------------------------------------------------------------
389
390%Executes on button press in runplus: make one step forward and call
391%run0. The step forward is along the fields series 1 or 2 depending on
392%the scan_i and scan_j check box (exclusive each other)
393%-------------------------------------------------------------------
394function runplus_Callback(hObject, eventdata, handles)
395increment=str2num(get(handles.increment_scan,'String')); %get the field increment d
396runpm(hObject,eventdata,handles,increment)
397
398%-------------------------------------------------------------------
399%Executes on button press in runmin: make one step backward and call
400%run0. The step backward is along the fields series 1 or 2 depending on
401%the scan_i and scan_j check box (exclusive each other)
402%-------------------------------------------------------------------
403function runmin_Callback(hObject, eventdata, handles)
404increment=-str2num(get(handles.increment_scan,'String')); %get the field increment d
405runpm(hObject,eventdata,handles,increment)
406
407%------------------------------------------------------------------------
408% --- translate coordinate to matrix index
409%------------------------------------------------------------------------
410function [indx,indy]=pos2ind(x0,rangx0,nxy)
411indx=1+round((nxy(2)-1)*(x0-rangx0(1))/(rangx0(2)-rangx0(1)));% index x of pixel 
412indy=1+round((nxy(1)-1)*(y12-rangy0(1))/(rangy0(2)-rangy0(1)));% index y of pixel
413
414%------------------------------------------------------------------------
415% --- Executes on button press in 'CheckZoom'.
416%------------------------------------------------------------------------
417function CheckZoom_Callback(hObject, eventdata, handles)
418
419if get(handles.CheckZoom,'Value')
420    set(handles.CheckFixLimits,'Value',1)% propose by default fixed limits for the plotting axes
421    set(handles.CheckZoomFig,'Value',0)%desactivate zoom fig
422end
423
424%------------------------------------------------------------------------
425% --- Executes on button press in CheckZoomFig.
426%------------------------------------------------------------------------
427function CheckZoomFig_Callback(hObject, eventdata, handles)
428if get(handles.CheckZoomFig,'Value')
429    set(handles.CheckZoom,'value',0)
430end
431
432%------------------------------------------------------------------------
433% --- Executes on button press in 'FixLimits'.
434%------------------------------------------------------------------------
435function CheckFixLimits_Callback(hObject, eventdata, handles)
436test=get(handles.CheckFixLimits,'Value');
437update_plot(handles)
438 
439%------------------------------------------------------------------------
440% --- Executes on button press in CheckFixAspectRatio.
441%------------------------------------------------------------------------
442function CheckFixAspectRatio_Callback(hObject, eventdata, handles)
443if get(handles.CheckFixAspectRatio,'Value')
444    update_plot(handles);
445else
446    update_plot(handles);
447end
448
449%------------------------------------------------------------------------
450function num_AspectRatio_Callback(hObject, eventdata, handles)
451%------------------------------------------------------------------------
452set(handles.CheckFixAspectRatio,'Value',1)% select the fixed aspect ratio button
453update_plot(handles);
454
455%-------------------------------------------------------------------
456%-------------------------------------------------------------------
457%  - FUNCTIONS FOR SETTING PLOTTING PARAMETERS
458
459%------------------------------------------------------------------
460
461
462%------------------------------------------------------------------
463% --- Executes on selection change in col_vec: choice of the color code.
464%
465function col_vec_Callback(hObject, eventdata, handles)
466%------------------------------------------------------------------
467% edit the choice for color code
468list_code=get(handles.col_vec,'String');% list menu fields
469index_code=get(handles.col_vec,'Value');% selected string index
470col_code= list_code{index_code(1)}; % selected field
471if isequal(col_code,'black') | isequal(col_code,'white')
472   set(handles.slider1,'Visible','off')
473   set(handles.slider2,'Visible','off')
474   set(handles.colcode1,'Visible','off')
475   set(handles.colcode2,'Visible','off')
476   set(handles.AutoVecColor,'Visible','off')
477   set_vec_col_bar(handles)
478else
479   set(handles.slider1,'Visible','on')
480   set(handles.slider2,'Visible','on')
481   set(handles.colcode1,'Visible','on')
482   set(handles.colcode2,'Visible','on')
483   set(handles.AutoVecColor,'Visible','on') 
484   if isequal(col_code,'ima_cor')
485       set(handles.AutoVecColor,'Value',0)%fixed scale by default
486       set(handles.vec_col_bar,'Value',0)% 3 colors r,g,b by default
487       set(handles.slider1,'Min',0);
488       set(handles.slider1,'Max',1);
489       set(handles.slider2,'Min',0);
490       set(handles.slider2,'Max',1);
491 %      set(handles.min_C_title_vec,'String','0')
492       set(handles.max_vec,'String','1')
493       set(handles.colcode1,'String','0.333')
494       colcode1_Callback(hObject, eventdata, handles)
495       set(handles.colcode2,'String','0.666')
496       colcode2_Callback(hObject, eventdata, handles)
497   else
498       set(handles.AutoVecColor,'Value',1)%auto scale between min,max by default
499       set(handles.vec_col_bar,'Value',1)% colormap 'jet' by default
500       minval=get(handles.slider1,'Min');
501       maxval=get(handles.slider1,'Max');
502       set(handles.slider1,'Value',minval)
503       set(handles.slider2,'Value',maxval)
504       set_vec_col_bar(handles)
505   end
506%    slider_update(handles)
507end
508%replot the current graph
509run0_Callback(hObject, eventdata, handles)
510
511
512%----------------------------------------------------------------
513% -- Executes on slider movement to set the color code
514%
515function slider1_Callback(hObject, eventdata, handles)
516%------------------------------------------------------------------
517slider1=get(handles.slider1,'Value');
518min_val=str2num(get(handles.min_vec,'String'));
519max_val=str2num(get(handles.max_vec,'String'));
520col=min_val+(max_val-min_val)*slider1;
521set(handles.colcode1,'String',num2str(col))
522if(get(handles.slider2,'Value') < col)%move also the second slider at the same value if needed
523    set(handles.slider2,'Value',col)
524    set(handles.colcode2,'String',num2str(col))
525end
526colcode1_Callback(hObject, eventdata, handles)
527
528%----------------------------------------------------------------
529% Executes on slider movement to set the color code
530%----------------------------------------------------------------
531function slider2_Callback(hObject, eventdata, handles)
532slider2=get(handles.slider2,'Value');
533min_val=str2num(get(handles.min_vec,'String'));
534max_val=str2num(get(handles.max_vec,'String'));
535col=min_val+(max_val-min_val)*slider2;
536set(handles.colcode2,'String',num2str(col))
537if(get(handles.slider1,'Value') > col)%move also the first slider at the same value if needed
538    set(handles.slider1,'Value',col)
539    set(handles.colcode1,'String',num2str(col))
540end
541colcode2_Callback(hObject, eventdata, handles)
542
543%----------------------------------------------------------------
544%execute on return carriage on the edit box corresponding to slider 1
545%----------------------------------------------------------------
546function colcode1_Callback(hObject, eventdata, handles)
547% col=str2num(get(handles.colcode1,'String'));
548% set(handles.slider1,'Value',col)
549set_vec_col_bar(handles)
550update_plot(handles)
551
552%----------------------------------------------------------------
553%execute on return carriage on the edit box corresponding to slider 2
554%----------------------------------------------------------------
555function colcode2_Callback(hObject, eventdata, handles)
556% col=str2num(get(handles.colcode2,'String'));
557% set(handles.slider2,'Value',col)
558% slider2_Callback(hObject, eventdata, handles)
559set_vec_col_bar(handles)
560update_plot(handles)
561
562%-------------------------------------------------------
563% --- Executes on button press in AutoVecColor.
564%-------------------------------------------------------
565function vec_col_bar_Callback(hObject, eventdata, handles)
566set_vec_col_bar(handles)
567
568%------------------------------------------------
569%CALLBACKS FOR PLOTTING PARAMETERS
570%-------------------------------------------------
571
572%------------------------------------------------------------------------
573function num_MinX_Callback(hObject, eventdata, handles)
574%------------------------------------------------------------------------
575set(handles.CheckFixLimits,'Value',1) %suppress auto mode
576% set(handles.CheckFixLimits,'BackgroundColor',[1 1 0])
577update_plot(handles);
578
579%------------------------------------------------------------------------
580function num_MaxX_Callback(hObject, eventdata, handles)
581%------------------------------------------------------------------------
582set(handles.CheckFixLimits,'Value',1) %suppress auto mode
583% set(handles.CheckFixLimits,'BackgroundColor',[1 1 0])
584update_plot(handles);
585
586%------------------------------------------------------------------------
587function num_MinY_Callback(hObject, eventdata, handles)
588%------------------------------------------
589set(handles.CheckFixLimits,'Value',1) %suppress auto mode
590% set(handles.CheckFixLimits,'BackgroundColor',[1 1 0])
591update_plot(handles);
592
593%------------------------------------------------------------------------
594function num_MaxY_Callback(hObject, eventdata, handles)
595%------------------------------------------------------------------------
596set(handles.CheckFixLimits,'Value',1) %suppress auto mode
597% set(handles.CheckFixLimits,'BackgroundColor',[1 1 0])
598update_plot(handles);
599
600%-----------------------------------------------------------------
601function num_MinA_Callback(hObject, eventdata, handles)
602%------------------------------------------
603set(handles.CheckFixScalar,'Value',1) %suppress auto mode
604set(handles.CheckFixScalar,'BackgroundColor',[1 1 0])
605update_plot(handles)
606
607%-----------------------------------------------------------------
608function num_MaxA_Callback(hObject, eventdata, handles)
609%--------------------------------------------
610set(handles.CheckFixScalar,'Value',1) %suppress auto mode
611% set(handles.CheckFixScalar,'BackgroundColor',[1 1 0])
612update_plot(handles)
613
614%-----------------------------------------------
615function CheckFixScalar_Callback(hObject, eventdata, handles)
616%--------------------------------------------
617test=get(handles.CheckFixScalar,'Value');
618% if test
619%     set(handles.CheckFixScalar,'BackgroundColor',[1 1 0])
620% else
621%     set(handles.CheckFixScalar,'BackgroundColor',[0.7 0.7 0.7])
622%     update_plot(handles);
623% %     set(handles.MinA,'String',num2str(ScalOut.MinA,3))
624% %     set(handles.MaxA,'String',num2str(ScalOut.MaxA,3))
625% end
626
627%-------------------------------------------------------------------
628function CheckBW_Callback(hObject, eventdata, handles)
629%-------------------------------------------------------------------
630update_plot(handles)
631
632%-------------------------------------------------------------------
633function ListContour_Callback(hObject, eventdata, handles)
634%-------------------------------------------------------------------
635val=get(handles.Contours,'Value');
636if val==2
637    set(handles.interval_txt,'Visible','on')
638    set(handles.IncrA,'Visible','on')
639else
640    set(handles.interval_txt,'Visible','off')
641    set(handles.IncrA,'Visible','off')
642end
643update_plot(handles)
644
645%-------------------------------------------------------------------
646function IncrA_Callback(hObject, eventdata, handles)
647%-------------------------------------------------------------------
648update_plot(handles)
649
650%-------------------------------------------------------------------
651function HideWarning_Callback(hObject, eventdata, handles)
652%-------------------------------------------------------------------
653update_plot(handles)
654
655%-------------------------------------------------------------------
656function HideFalse_Callback(hObject, eventdata, handles)
657%-------------------------------------------------------------------
658update_plot(handles)
659
660%-------------------------------------------------------------------
661function num_VecScale_Callback(hObject, eventdata, handles)
662%-------------------------------------------------------------------
663set(handles.CheckFixVectors,'Value',1);
664update_plot(handles)
665
666%-------------------------------------------------------------------
667function FixVec_Callback(hObject, eventdata, handles)
668%-------------------------------------------------------------------
669test=get(handles.FixVec,'Value');
670if test
671    set(handles.FixVec,'BackgroundColor',[1 1 0])
672else
673    update_plot(handles);
674    %set(handles.VecScale,'String',num2str(ScalOut.VecScale,3))
675%     set(handles.FixVec,'BackgroundColor',[0.7 0.7 0.7])
676end
677
678%-------------------------------------------------------
679% --- Executes on selection change in decimate4 (nb_vec/4).
680%-------------------------------------------------------
681function CheckDecimate4_Callback(hObject, eventdata, handles)
682update_plot(handles)
683
684
685%-------------------------------------------------------
686% --- Executes on selection change in color_code menu
687%-------------------------------------------------------
688function color_code_Callback(hObject, eventdata, handles)
689set_vec_col_bar(handles)
690update_plot(handles);
691
692%-------------------------------------------------------
693% --- Executes on button press in AutoVecColor.
694%-------------------------------------------------------
695function AutoVecColor_Callback(hObject, eventdata, handles)
696test=get(handles.AutoVecColor,'Value');
697if test
698    set(handles.AutoVecColor,'BackgroundColor',[1 1 0])
699else
700    update_plot(handles);
701    %set(handles.VecScale,'String',num2str(ScalOut.VecScale,3))
702    set(handles.AutoVecColor,'BackgroundColor',[0.7 0.7 0.7])
703end
704%set_vec_col_bar(handles)
705
706%-------------------------------------------------------
707% --- Executes on selection change in max_vec.
708%-------------------------------------------------------
709function min_vec_Callback(hObject, eventdata, handles)
710max_vec_Callback(hObject, eventdata, handles)
711
712% --- Executes on selection change in max_vec.
713function max_vec_Callback(hObject, eventdata, handles)
714set(handles.AutoVecColor,'Value',1)
715AutoVecColor_Callback(hObject, eventdata, handles)
716min_val=str2num(get(handles.min_vec,'String'));
717max_val=str2num(get(handles.max_vec,'String'));
718slider1=get(handles.slider1,'Value');
719slider2=get(handles.slider2,'Value');
720colcode1=min_val+(max_val-min_val)*slider1;
721colcode2=min_val+(max_val-min_val)*slider2;
722set(handles.colcode1,'String',num2str(colcode1))
723set(handles.colcode2,'String',num2str(colcode2))
724update_plot(handles);
725
726%-------------------------------------------------------------------
727%update the display of color code for vectors
728function set_vec_col_bar(handles)
729%-------------------------------------------------------------------
730%get the image of the color display button 'vec_col_bar' in pixels
731set(handles.vec_col_bar,'Unit','pixel');
732pos_vert=get(handles.vec_col_bar,'Position');
733set(handles.vec_col_bar,'Unit','Normalized');
734width=ceil(pos_vert(3));
735height=ceil(pos_vert(4));
736
737%get slider indications
738list=get(handles.color_code,'String');
739ichoice=get(handles.color_code,'Value');
740colcode.ColorCode=list{ichoice};
741colcode.MinC=str2num(get(handles.min_vec,'String'));
742colcode.MaxC=str2num(get(handles.max_vec,'String'));
743test3color=strcmp(colcode.ColorCode,'rgb') || strcmp(colcode.ColorCode,'bgr');
744if test3color
745    colcode.colcode1=str2num(get(handles.colcode1,'String'));
746    colcode.colcode2=str2num(get(handles.colcode2,'String'));
747end
748colcode.FixedCbounds=0;
749colcode.FixedCbounds=1;
750vec_C=colcode.MinC+(colcode.MaxC-colcode.MinC)*[0.5:width-0.5]/width;%sample of vec_C values from min to max
751[colorlist,col_vec]=set_col_vec(colcode,vec_C);
752oneheight=ones(1,height);
753A1=colorlist(col_vec,1)*oneheight;
754A2=colorlist(col_vec,2)*oneheight;
755A3=colorlist(col_vec,3)*oneheight;
756A(:,:,1)=A1';
757A(:,:,2)=A2';
758A(:,:,3)=A3';
759set(handles.vec_col_bar,'Cdata',A)
760
761%-------------------------------------------------------------------
762function update_plot(handles)
763%-------------------------------------------------------------------
764Data=get(handles.view_field,'UserData');
765AxeData=Data.PlotAxes;% retrieve the current plotted data
766PlotParam=read_GUI(handles.view_field);
767[PP,PlotParamOut]= plot_field(AxeData,handles.PlotAxes,PlotParam);
768errormsg=fill_GUI(PlotParamOut,handles.view_field);
769if ~isempty(errormsg)
770    msgbox_uvmat('ERROR',errormsg)
771    return
772end
773hedit=findobj(handles.view_field,'Style','edit');
774set(hedit,'BackgroundColor',[1 1 1])
775
776%------------------------------------------------------------------------
777% --- Executes on button press in Menu/Export/field in workspace.
778function MenuExportField_Callback(hObject, eventdata, handles)
779%------------------------------------------------------------------------
780global Data_view_field
781% huvmat=findobj(allchild(0),'Name','uvmat');
782Data_view_field=get(handles.view_field,'UserData');
783Data_view_field=Data_view_field.PlotAxes;
784% Data_view_field=UvData.ProjField_2;
785evalin('base','global Data_view_field')%make CurData global in the workspace
786display(['UserData of view_field :'])
787evalin('base','Data_view_field') %display CurData in the workspace
788commandwindow;
789
790%------------------------------------------------------------------------
791% --- Executes on button press in Menu/Export/extract figure.
792function MenuExport_plot_Callback(hObject, eventdata, handles)
793%------------------------------------------------------------------------
794huvmat=get(handles.MenuExport_plot,'parent');
795UvData=get(huvmat,'UserData');
796hfig=figure;
797newaxes=copyobj(handles.PlotAxes,hfig);
798map=colormap(handles.PlotAxes);
799colormap(map);%transmit the current colormap to the zoom fig
800colorbar
801
802
803% --- Executes on selection change in ColorCode.
804function ColorCode_Callback(hObject, eventdata, handles)
805
806
807% --- Executes on selection change in ColorScalar.
808function ColorScalar_Callback(hObject, eventdata, handles)
809
810
811function num_ColCode2_Callback(hObject, eventdata, handles)
812
813
814
815% --- Executes on button press in CheckTable.
816function CheckTable_Callback(hObject, eventdata, handles)
817if get(handles.CheckTable,'Value')
818    set(handles.TableDisplay,'Visible','on')
819else
820    set(handles.TableDisplay,'Visible','off')
821end
822   
Note: See TracBrowser for help on using the repository browser.