source: trunk/src/view_field.m @ 764

Last change on this file since 764 was 752, checked in by sommeria, 11 years ago

various update

File size: 34.7 KB
Line 
1%'view_field': function associated with the GUI 'view_field.fig' for images and data field visualization
2%------------------------------------------------------------------------
3% function huvmat=view_field(input)
4%
5%OUTPUT
6% huvmat=current handles of the GUI view_field.fig
7%%
8%
9%INPUT:
10% input: input file name (if character chain), or input image matrix to
11% visualize, or Matlab structure representing  netcdf fields (with fields
12% ListVarName....)
13%
14%AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
15%  Copyright Joel Sommeria,  2008, LEGI / CNRS-UJF-INPG, joel.sommeria@legi.grenoble-inp.fr.
16%AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
17%     This open is part of the toolbox VIEW_FIELD.
18%
19%     VIEW_FIELD is free software; you can redistribute it and/or modify
20%     it under the terms of the GNU General Public License as published by
21%     the Free Software Foundation; either version 2 of the License, or
22%     (at your option) any later version.
23%
24%     VIEW_FIELD is distributed in the hope that it will be useful,
25%     but WITHOUT ANY WARRANTY; without even the implied warranty of
26%     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
27%     GNU General Public License (open VIEW_FIELD/COPYING.txt) for more details.
28%AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
29
30%-------------------------------------------------------------------
31%  I - MAIN FUNCTION VIEW_FIELD (DO NOT MODIFY)
32%-------------------------------------------------------------------
33%-------------------------------------------------------------------
34function varargout = view_field(varargin)
35
36% Begin initialization code - DO NOT EDIT
37gui_Singleton = 1;
38gui_State = struct('gui_Name',          mfilename, ...
39                   'gui_Singleton',     gui_Singleton, ...
40                   'gui_OpeningFcn',    @view_field_OpeningFcn, ...
41                   'gui_OutputFcn',     @view_field_OutputFcn, ...
42                   'gui_LayoutFcn',     [], ...
43                   'gui_Callback',      []);
44if nargin && ischar(varargin{1})
45    gui_State.gui_Callback = str2func(varargin{1});
46end
47
48if nargout
49    varargout{1:nargout} = gui_mainfcn(gui_State, varargin{:});
50else
51    gui_mainfcn(gui_State, varargin{:});
52end
53% End initialization code - DO NOT EDIT
54
55%-------------------------------------------------------------------
56% --- Executes just before view_field is made visible.
57function view_field_OpeningFcn(hObject, eventdata, handles, Field )
58%-------------------------------------------------------------------
59
60% Choose default command menuline output for view_field
61handles.output = handles.view_field;
62
63% Update handles structure
64guidata(hObject, handles);
65
66%functions for the mouse and keyboard
67set(hObject,'WindowKeyPressFcn',{'keyboard_callback',handles})%set keyboard action function
68set(hObject,'WindowButtonMotionFcn',{'mouse_motion',handles})%set mouse action functio
69set(hObject,'WindowButtonDownFcn',{'mouse_down'})%set mouse click action function
70set(hObject,'WindowButtonUpFcn',{'mouse_up',handles})
71set(hObject,'DeleteFcn',{@closefcn})%
72set(hObject,'ResizeFcn',{@ResizeFcn,handles})%
73ViewFieldData.PlotAxes=[];%initiates the record of the current field (will be updated by plot_field)
74set(handles.view_field,'Units','pixels')
75ViewFieldData.GUISize=get(handles.view_field,'Position');
76set(handles.view_field,'UserData',ViewFieldData);%store the initial fig size in UserData
77AxeData.LimEditBox=1; %initialise AxeData, the parent figure sets plot parameters
78set(handles.PlotAxes,'UserData',AxeData)
79if exist('Field','var')
80    [PlotType,PlotParamOut]= plot_field(Field,handles.PlotAxes);%,PlotParam,KeepLim,PosColorbar)
81    set(handles.Axes,'Visible','on')
82    if isfield(PlotParamOut,'Vectors')
83        set(handles.Vectors,'Visible','on')
84    else
85        set(handles.Vectors,'Visible','off')
86    end
87    if isfield(PlotParamOut,'Scalar')
88        set(handles.Scalar,'Visible','on')
89    else
90        set(handles.Scalar,'Visible','off')
91    end
92   
93    errormsg=fill_GUI(PlotParamOut,hObject);
94    if ~isempty(errormsg)
95        msgbox_uvmat('ERROR',errormsg)
96        return
97    end
98    %write_plot_param(handles,PlotParamOut);% update the display of the plotting parameters
99end
100
101%put the GUI on the lower right of the sceen
102pos_view_field=get(hObject,'Position');
103set(0,'Unit','pixel')
104ScreenSize=get(0,'ScreenSize');
105pos_view_field(1)=ScreenSize(1)+ScreenSize(3)-pos_view_field(3);
106pos_view_field(2)=ScreenSize(2);
107set(hObject,'Position',pos_view_field)
108
109%------------------------------------------------------------------------
110%--- activated when resizing the GUI view_field
111 function ResizeFcn(gcbo,eventdata,handles)
112%------------------------------------------------------------------------     
113set(handles.view_field,'Units','pixels')
114size_fig=get(handles.view_field,'Position');
115Data=get(handles.view_field,'UserData');
116Data.GUISize=size_fig;
117set(handles.view_field,'UserData',Data)
118
119%% reset position of text_display and TableDisplay
120% reset position of text_display
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
127set(handles.TableDisplay,'Position',pos_1)
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)
133
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
140%% reset position of Axes
141pos_2=get(handles.Axes,'Position');% [lower x lower y width height] for frame 'Coordinates'
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
144set(handles.Axes,'Position',pos_2)
145
146%% reset position of  Scalar
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
149if strcmp(get(handles.Scalar,'visible'),'on')
150    pos_3(2)=pos_2(2)-pos_3(4); % set 'Scalar' to the lower edge of frame 'Coordinates' if visible
151else
152    pos_3(2)=pos_2(2);% set 'Scalar' to the lower edge of frame 'text display' if  unvisible
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
167set(handles.PlotAxes,'Units','pixels')
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));
173set(handles.PlotAxes,'Position',pos)
174set(handles.PlotAxes,'Units','normalized')
175
176%------------------------------------------------------------------------
177%------------------------------------------------------------------------
178% --- Outputs from this function are returned to the command menuline.
179function varargout = view_field_OutputFcn(hObject, eventdata, handles)
180%------------------------------------------------------------------------
181varargout{1} = handles.output;% the only output argument is the handle to the GUI figure
182varargout{2} = strcmp(get(handles.PlotAxes,'Visible'),'on');% check active plot axis
183
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);
191    set(hhuvmat.CheckViewField,'Value',0)
192    %set(hhuvmat.edit_object,'BackgroundColor',[0.7 0.7 0.7])%put unactivated buttons to gree
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
199        hother=[findobj(hhuvmat.PlotAxes,'Tag','proj_object');findobj(hhuvmat.PlotAxes,'Tag','DeformPoint')];%find all the proj object and deform point representations
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
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
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;
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);
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
305            axes(handles.PlotAxes)
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;
319hc=copyobj(handles.PlotAxes,hfig);
320set(hc,'Position',[0.1 0.1 0.8 0.8])
321h=findobj(handles.PlotAxes,'tag','ima'); %look for image in the plot
322if ~isempty(h)
323    h=findobj(handles.PlotAxes,'tag','ima'); %look for image in the plot
324    map=colormap(handles.PlotAxes);
325    colormap(map);%transmit the current colormap to the zoom fig
326    colorbar
327end
328
329% --------------------------------------------------------------------
330function MenuExportAxis_Callback(hObject, eventdata, handles)
331ListFig=findobj(allchild(0),'Type','figure');
332nb_option=0;
333menu={};
334for ilist=1:numel(ListFig)
335    FigName=get(ListFig(ilist),'name');
336    if isempty(FigName)
337        FigName=['figure ' num2str(ListFig(ilist))];
338    end
339    if ~strcmp(FigName,'uvmat')
340        ListAxes=findobj(ListFig(ilist),'Type','axes');
341        ListTags=get(ListAxes,'Tag');
342        if ~isempty(ListTags) && ~isempty(find(~strcmp('Colorbar',ListTags), 1))
343            ListAxes=ListAxes(~strcmp('Colorbar',ListTags));
344            if numel(ListAxes)==1
345                nb_option=nb_option+1;
346                menu{nb_option}=FigName ;
347                AxesHandle(nb_option)=ListAxes;
348            else
349                nb_axis=0;
350                for iaxes=1:numel(ListAxes)
351                    nb_axis=nb_axis+1;
352                    nb_option=nb_option+1;
353                    menu{nb_option}=[FigName '_' num2str(nb_axis)];
354                    AxesHandle(nb_option)=ListAxes(nb_axis);
355                end
356            end
357        end
358    end
359end
360if isempty(menu)
361    answer=msgbox_uvmat('INPUT_Y-N','no existing plotting axes available, create new figure?');
362    if strcmp(answer,'Yes')
363        hfig=figure;
364        copyobj(handles.PlotAxes,hfig);
365    else
366        return
367    end
368    map=colormap(handles.PlotAxes);
369    colormap(map);%transmit the current colormap to the zoom fig
370    colorbar
371else
372    answer=msgbox_uvmat('INPUT_MENU','select a figure/axis on which the current uvmat plot will be exported',menu);
373    if isempty(answer)
374        return
375    else
376        axes(AxesHandle(answer))
377        hold on
378        hchild=get(handles.PlotAxes,'children');
379        copyobj(hchild,gca);
380    end
381end
382
383%-------------------------------------------------------------------
384%-------------------------------------------------------------------
385% III - MAIN REFRESH FUNCTIONS : 'FRAME PLOT'
386%-------------------------------------------------------------------
387%-------------------------------------------------------------------
388
389%Executes on button press in runplus: make one step forward and call
390%run0. The step forward is along the fields series 1 or 2 depending on
391%the scan_i and scan_j check box (exclusive each other)
392%-------------------------------------------------------------------
393function runplus_Callback(hObject, eventdata, handles)
394increment=str2num(get(handles.increment_scan,'String')); %get the field increment d
395runpm(hObject,eventdata,handles,increment)
396
397%-------------------------------------------------------------------
398%Executes on button press in runmin: make one step backward and call
399%run0. The step backward is along the fields series 1 or 2 depending on
400%the scan_i and scan_j check box (exclusive each other)
401%-------------------------------------------------------------------
402function runmin_Callback(hObject, eventdata, handles)
403increment=-str2num(get(handles.increment_scan,'String')); %get the field increment d
404runpm(hObject,eventdata,handles,increment)
405
406%------------------------------------------------------------------------
407% --- translate coordinate to matrix index
408%------------------------------------------------------------------------
409function [indx,indy]=pos2ind(x0,rangx0,nxy)
410indx=1+round((nxy(2)-1)*(x0-rangx0(1))/(rangx0(2)-rangx0(1)));% index x of pixel 
411indy=1+round((nxy(1)-1)*(y12-rangy0(1))/(rangy0(2)-rangy0(1)));% index y of pixel
412
413%------------------------------------------------------------------------
414% --- Executes on button press in 'CheckZoom'.
415%------------------------------------------------------------------------
416function CheckZoom_Callback(hObject, eventdata, handles)
417
418if get(handles.CheckZoom,'Value')
419    set(handles.CheckFixLimits,'Value',1)% propose by default fixed limits for the plotting axes
420    set(handles.CheckZoomFig,'Value',0)%desactivate zoom fig
421end
422
423%------------------------------------------------------------------------
424% --- Executes on button press in CheckZoomFig.
425%------------------------------------------------------------------------
426function CheckZoomFig_Callback(hObject, eventdata, handles)
427if get(handles.CheckZoomFig,'Value')
428    set(handles.CheckZoom,'value',0)
429end
430
431%------------------------------------------------------------------------
432% --- Executes on button press in 'FixLimits'.
433%------------------------------------------------------------------------
434function CheckFixLimits_Callback(hObject, eventdata, handles)
435test=get(handles.CheckFixLimits,'Value');
436update_plot(handles)
437 
438%------------------------------------------------------------------------
439% --- Executes on button press in CheckFixAspectRatio.
440%------------------------------------------------------------------------
441function CheckFixAspectRatio_Callback(hObject, eventdata, handles)
442if get(handles.CheckFixAspectRatio,'Value')
443    update_plot(handles);
444else
445    update_plot(handles);
446end
447
448%------------------------------------------------------------------------
449function num_AspectRatio_Callback(hObject, eventdata, handles)
450%------------------------------------------------------------------------
451set(handles.CheckFixAspectRatio,'Value',1)% select the fixed aspect ratio button
452update_plot(handles);
453
454%-------------------------------------------------------------------
455%-------------------------------------------------------------------
456%  - FUNCTIONS FOR SETTING PLOTTING PARAMETERS
457
458%------------------------------------------------------------------
459
460
461%------------------------------------------------------------------
462% --- Executes on selection change in col_vec: choice of the color code.
463%
464function col_vec_Callback(hObject, eventdata, handles)
465%------------------------------------------------------------------
466% edit the choice for color code
467list_code=get(handles.col_vec,'String');% list menu fields
468index_code=get(handles.col_vec,'Value');% selected string index
469col_code= list_code{index_code(1)}; % selected field
470if isequal(col_code,'black') | isequal(col_code,'white')
471   set(handles.slider1,'Visible','off')
472   set(handles.slider2,'Visible','off')
473   set(handles.colcode1,'Visible','off')
474   set(handles.colcode2,'Visible','off')
475   set(handles.AutoVecColor,'Visible','off')
476   set_vec_col_bar(handles)
477else
478   set(handles.slider1,'Visible','on')
479   set(handles.slider2,'Visible','on')
480   set(handles.colcode1,'Visible','on')
481   set(handles.colcode2,'Visible','on')
482   set(handles.AutoVecColor,'Visible','on') 
483   if isequal(col_code,'ima_cor')
484       set(handles.AutoVecColor,'Value',0)%fixed scale by default
485       set(handles.vec_col_bar,'Value',0)% 3 colors r,g,b by default
486       set(handles.slider1,'Min',0);
487       set(handles.slider1,'Max',1);
488       set(handles.slider2,'Min',0);
489       set(handles.slider2,'Max',1);
490 %      set(handles.min_C_title_vec,'String','0')
491       set(handles.max_vec,'String','1')
492       set(handles.colcode1,'String','0.333')
493       colcode1_Callback(hObject, eventdata, handles)
494       set(handles.colcode2,'String','0.666')
495       colcode2_Callback(hObject, eventdata, handles)
496   else
497       set(handles.AutoVecColor,'Value',1)%auto scale between min,max by default
498       set(handles.vec_col_bar,'Value',1)% colormap 'jet' by default
499       minval=get(handles.slider1,'Min');
500       maxval=get(handles.slider1,'Max');
501       set(handles.slider1,'Value',minval)
502       set(handles.slider2,'Value',maxval)
503       set_vec_col_bar(handles)
504   end
505%    slider_update(handles)
506end
507%replot the current graph
508run0_Callback(hObject, eventdata, handles)
509
510
511%----------------------------------------------------------------
512% -- Executes on slider movement to set the color code
513%
514function slider1_Callback(hObject, eventdata, handles)
515%------------------------------------------------------------------
516slider1=get(handles.slider1,'Value');
517min_val=str2num(get(handles.min_vec,'String'));
518max_val=str2num(get(handles.max_vec,'String'));
519col=min_val+(max_val-min_val)*slider1;
520set(handles.colcode1,'String',num2str(col))
521if(get(handles.slider2,'Value') < col)%move also the second slider at the same value if needed
522    set(handles.slider2,'Value',col)
523    set(handles.colcode2,'String',num2str(col))
524end
525colcode1_Callback(hObject, eventdata, handles)
526
527%----------------------------------------------------------------
528% Executes on slider movement to set the color code
529%----------------------------------------------------------------
530function slider2_Callback(hObject, eventdata, handles)
531slider2=get(handles.slider2,'Value');
532min_val=str2num(get(handles.min_vec,'String'));
533max_val=str2num(get(handles.max_vec,'String'));
534col=min_val+(max_val-min_val)*slider2;
535set(handles.colcode2,'String',num2str(col))
536if(get(handles.slider1,'Value') > col)%move also the first slider at the same value if needed
537    set(handles.slider1,'Value',col)
538    set(handles.colcode1,'String',num2str(col))
539end
540colcode2_Callback(hObject, eventdata, handles)
541
542%----------------------------------------------------------------
543%execute on return carriage on the edit box corresponding to slider 1
544%----------------------------------------------------------------
545function colcode1_Callback(hObject, eventdata, handles)
546% col=str2num(get(handles.colcode1,'String'));
547% set(handles.slider1,'Value',col)
548set_vec_col_bar(handles)
549update_plot(handles)
550
551%----------------------------------------------------------------
552%execute on return carriage on the edit box corresponding to slider 2
553%----------------------------------------------------------------
554function colcode2_Callback(hObject, eventdata, handles)
555% col=str2num(get(handles.colcode2,'String'));
556% set(handles.slider2,'Value',col)
557% slider2_Callback(hObject, eventdata, handles)
558set_vec_col_bar(handles)
559update_plot(handles)
560
561%-------------------------------------------------------
562% --- Executes on button press in AutoVecColor.
563%-------------------------------------------------------
564function vec_col_bar_Callback(hObject, eventdata, handles)
565set_vec_col_bar(handles)
566
567%------------------------------------------------
568%CALLBACKS FOR PLOTTING PARAMETERS
569%-------------------------------------------------
570
571%------------------------------------------------------------------------
572function num_MinX_Callback(hObject, eventdata, handles)
573%------------------------------------------------------------------------
574set(handles.CheckFixLimits,'Value',1) %suppress auto mode
575% set(handles.CheckFixLimits,'BackgroundColor',[1 1 0])
576update_plot(handles);
577
578%------------------------------------------------------------------------
579function num_MaxX_Callback(hObject, eventdata, handles)
580%------------------------------------------------------------------------
581set(handles.CheckFixLimits,'Value',1) %suppress auto mode
582% set(handles.CheckFixLimits,'BackgroundColor',[1 1 0])
583update_plot(handles);
584
585%------------------------------------------------------------------------
586function num_MinY_Callback(hObject, eventdata, handles)
587%------------------------------------------
588set(handles.CheckFixLimits,'Value',1) %suppress auto mode
589% set(handles.CheckFixLimits,'BackgroundColor',[1 1 0])
590update_plot(handles);
591
592%------------------------------------------------------------------------
593function num_MaxY_Callback(hObject, eventdata, handles)
594%------------------------------------------------------------------------
595set(handles.CheckFixLimits,'Value',1) %suppress auto mode
596% set(handles.CheckFixLimits,'BackgroundColor',[1 1 0])
597update_plot(handles);
598
599%-----------------------------------------------------------------
600function num_MinA_Callback(hObject, eventdata, handles)
601%------------------------------------------
602set(handles.CheckFixScalar,'Value',1) %suppress auto mode
603set(handles.CheckFixScalar,'BackgroundColor',[1 1 0])
604update_plot(handles)
605
606%-----------------------------------------------------------------
607function num_MaxA_Callback(hObject, eventdata, handles)
608%--------------------------------------------
609set(handles.CheckFixScalar,'Value',1) %suppress auto mode
610% set(handles.CheckFixScalar,'BackgroundColor',[1 1 0])
611update_plot(handles)
612
613%-----------------------------------------------
614function CheckFixScalar_Callback(hObject, eventdata, handles)
615%--------------------------------------------
616test=get(handles.CheckFixScalar,'Value');
617% if test
618%     set(handles.CheckFixScalar,'BackgroundColor',[1 1 0])
619% else
620%     set(handles.CheckFixScalar,'BackgroundColor',[0.7 0.7 0.7])
621%     update_plot(handles);
622% %     set(handles.MinA,'String',num2str(ScalOut.MinA,3))
623% %     set(handles.MaxA,'String',num2str(ScalOut.MaxA,3))
624% end
625
626%-------------------------------------------------------------------
627function CheckBW_Callback(hObject, eventdata, handles)
628%-------------------------------------------------------------------
629update_plot(handles)
630
631%-------------------------------------------------------------------
632function ListContour_Callback(hObject, eventdata, handles)
633%-------------------------------------------------------------------
634val=get(handles.Contours,'Value');
635if val==2
636    set(handles.interval_txt,'Visible','on')
637    set(handles.IncrA,'Visible','on')
638else
639    set(handles.interval_txt,'Visible','off')
640    set(handles.IncrA,'Visible','off')
641end
642update_plot(handles)
643
644%-------------------------------------------------------------------
645function IncrA_Callback(hObject, eventdata, handles)
646%-------------------------------------------------------------------
647update_plot(handles)
648
649%-------------------------------------------------------------------
650function HideWarning_Callback(hObject, eventdata, handles)
651%-------------------------------------------------------------------
652update_plot(handles)
653
654%-------------------------------------------------------------------
655function HideFalse_Callback(hObject, eventdata, handles)
656%-------------------------------------------------------------------
657update_plot(handles)
658
659%-------------------------------------------------------------------
660function num_VecScale_Callback(hObject, eventdata, handles)
661%-------------------------------------------------------------------
662set(handles.CheckFixVectors,'Value',1);
663update_plot(handles)
664
665%-------------------------------------------------------------------
666function FixVec_Callback(hObject, eventdata, handles)
667%-------------------------------------------------------------------
668test=get(handles.FixVec,'Value');
669if test
670    set(handles.FixVec,'BackgroundColor',[1 1 0])
671else
672    update_plot(handles);
673    %set(handles.VecScale,'String',num2str(ScalOut.VecScale,3))
674%     set(handles.FixVec,'BackgroundColor',[0.7 0.7 0.7])
675end
676
677%-------------------------------------------------------
678% --- Executes on selection change in decimate4 (nb_vec/4).
679%-------------------------------------------------------
680function CheckDecimate4_Callback(hObject, eventdata, handles)
681update_plot(handles)
682
683
684%-------------------------------------------------------
685% --- Executes on selection change in color_code menu
686%-------------------------------------------------------
687function color_code_Callback(hObject, eventdata, handles)
688set_vec_col_bar(handles)
689update_plot(handles);
690
691%-------------------------------------------------------
692% --- Executes on button press in AutoVecColor.
693%-------------------------------------------------------
694function AutoVecColor_Callback(hObject, eventdata, handles)
695test=get(handles.AutoVecColor,'Value');
696if test
697    set(handles.AutoVecColor,'BackgroundColor',[1 1 0])
698else
699    update_plot(handles);
700    %set(handles.VecScale,'String',num2str(ScalOut.VecScale,3))
701    set(handles.AutoVecColor,'BackgroundColor',[0.7 0.7 0.7])
702end
703%set_vec_col_bar(handles)
704
705%-------------------------------------------------------
706% --- Executes on selection change in max_vec.
707%-------------------------------------------------------
708function min_vec_Callback(hObject, eventdata, handles)
709max_vec_Callback(hObject, eventdata, handles)
710
711% --- Executes on selection change in max_vec.
712function max_vec_Callback(hObject, eventdata, handles)
713set(handles.AutoVecColor,'Value',1)
714AutoVecColor_Callback(hObject, eventdata, handles)
715min_val=str2num(get(handles.min_vec,'String'));
716max_val=str2num(get(handles.max_vec,'String'));
717slider1=get(handles.slider1,'Value');
718slider2=get(handles.slider2,'Value');
719colcode1=min_val+(max_val-min_val)*slider1;
720colcode2=min_val+(max_val-min_val)*slider2;
721set(handles.colcode1,'String',num2str(colcode1))
722set(handles.colcode2,'String',num2str(colcode2))
723update_plot(handles);
724
725%-------------------------------------------------------------------
726%update the display of color code for vectors
727function set_vec_col_bar(handles)
728%-------------------------------------------------------------------
729%get the image of the color display button 'vec_col_bar' in pixels
730set(handles.vec_col_bar,'Unit','pixel');
731pos_vert=get(handles.vec_col_bar,'Position');
732set(handles.vec_col_bar,'Unit','Normalized');
733width=ceil(pos_vert(3));
734height=ceil(pos_vert(4));
735
736%get slider indications
737list=get(handles.color_code,'String');
738ichoice=get(handles.color_code,'Value');
739colcode.ColorCode=list{ichoice};
740colcode.MinC=str2num(get(handles.min_vec,'String'));
741colcode.MaxC=str2num(get(handles.max_vec,'String'));
742test3color=strcmp(colcode.ColorCode,'rgb') || strcmp(colcode.ColorCode,'bgr');
743if test3color
744    colcode.colcode1=str2num(get(handles.colcode1,'String'));
745    colcode.colcode2=str2num(get(handles.colcode2,'String'));
746end
747colcode.FixedCbounds=0;
748colcode.FixedCbounds=1;
749vec_C=colcode.MinC+(colcode.MaxC-colcode.MinC)*[0.5:width-0.5]/width;%sample of vec_C values from min to max
750[colorlist,col_vec]=set_col_vec(colcode,vec_C);
751oneheight=ones(1,height);
752A1=colorlist(col_vec,1)*oneheight;
753A2=colorlist(col_vec,2)*oneheight;
754A3=colorlist(col_vec,3)*oneheight;
755A(:,:,1)=A1';
756A(:,:,2)=A2';
757A(:,:,3)=A3';
758set(handles.vec_col_bar,'Cdata',A)
759
760%-------------------------------------------------------------------
761function update_plot(handles)
762%-------------------------------------------------------------------
763Data=get(handles.view_field,'UserData');
764AxeData=Data.PlotAxes;% retrieve the current plotted data
765PlotParam=read_GUI(handles.view_field);
766[PP,PlotParamOut]= plot_field(AxeData,handles.PlotAxes,PlotParam);
767errormsg=fill_GUI(PlotParamOut,handles.view_field);
768if ~isempty(errormsg)
769    msgbox_uvmat('ERROR',errormsg)
770    return
771end
772hedit=findobj(handles.view_field,'Style','edit');
773set(hedit,'BackgroundColor',[1 1 1])
774
775%------------------------------------------------------------------------
776% --- Executes on button press in Menu/Export/field in workspace.
777function MenuExportField_Callback(hObject, eventdata, handles)
778%------------------------------------------------------------------------
779global Data_view_field
780% huvmat=findobj(allchild(0),'Name','uvmat');
781Data_view_field=get(handles.view_field,'UserData');
782Data_view_field=Data_view_field.PlotAxes;
783% Data_view_field=UvData.ProjField_2;
784evalin('base','global Data_view_field')%make CurData global in the workspace
785display(['UserData of view_field :'])
786evalin('base','Data_view_field') %display CurData in the workspace
787commandwindow;
788
789%------------------------------------------------------------------------
790% --- Executes on button press in Menu/Export/extract figure.
791function MenuExport_plot_Callback(hObject, eventdata, handles)
792%------------------------------------------------------------------------
793huvmat=get(handles.MenuExport_plot,'parent');
794UvData=get(huvmat,'UserData');
795hfig=figure;
796newaxes=copyobj(handles.PlotAxes,hfig);
797map=colormap(handles.PlotAxes);
798colormap(map);%transmit the current colormap to the zoom fig
799colorbar
800
801
802% --- Executes on selection change in ColorCode.
803function ColorCode_Callback(hObject, eventdata, handles)
804
805
806% --- Executes on selection change in ColorScalar.
807function ColorScalar_Callback(hObject, eventdata, handles)
808
809
810function num_ColCode2_Callback(hObject, eventdata, handles)
811
812
813
814% --- Executes on button press in CheckTable.
815function CheckTable_Callback(hObject, eventdata, handles)
816if get(handles.CheckTable,'Value')
817    set(handles.TableDisplay,'Visible','on')
818else
819    set(handles.TableDisplay,'Visible','off')
820end
821   
Note: See TracBrowser for help on using the repository browser.