source: trunk/src/view_field.m @ 751

Last change on this file since 751 was 748, checked in by sommeria, 11 years ago

update for 3D plots, panel Coordiantes introduces, while coordiantes now called Axes

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