source: trunk/src/view_field.m @ 789

Last change on this file since 789 was 772, checked in by sommeria, 11 years ago

manip corrections and cleaning

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%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    % deselect the object in ListObject when view_field is closed
193    if isempty(findobj(allchild(0),'Tag','set_object'))
194        ObjIndex=get(hhuvmat.ListObject,'Value');
195        ObjIndex=ObjIndex(1);%keep only the first object selected
196        set(hhuvmat.ListObject,'Value',ObjIndex)
197        % draw all object colors in blue (unselected) in uvmat
198        hother=[findobj(hhuvmat.PlotAxes,'Tag','proj_object');findobj(hhuvmat.PlotAxes,'Tag','DeformPoint')];%find all the proj object and deform point representations
199        for iobj=1:length(hother)
200            if isequal(get(hother(iobj),'Type'),'rectangle')||isequal(get(hother(iobj),'Type'),'patch')
201                set(hother(iobj),'EdgeColor','b')
202                if isequal(get(hother(iobj),'FaceColor'),'m')
203                    set(hother(iobj),'FaceColor','b')
204                end
205            elseif isequal(get(hother(iobj),'Type'),'image')
206                Acolor=get(hother(iobj),'CData');
207                Acolor(:,:,1)=zeros(size(Acolor,1),size(Acolor,2));
208                set(hother(iobj),'CData',Acolor);
209            else
210                set(hother(iobj),'Color','b')
211            end
212            set(hother(iobj),'Selected','off')
213        end
214    end
215end
216hciv=findobj(allchild(0),'Tag','civ_input');%find the current civ GUI
217if ~isempty(hciv)
218    hhciv=guidata(hciv);
219    set(hhciv.TestCiv1,'Value',0)% desactivate  TestCiv1 if on
220    set(hhciv.TestCiv1,'BackgroundColor',[0 1 0])%
221end
222corrfig=findobj(allchild(0),'tag','corrfig');% look for a civ correlation window used with TesCiv1
223if ~isempty(corrfig)
224    delete(corrfig)
225end
226
227%-------------------------------------------------------------------
228%-------------------------------------------------------------------
229% II - FUNCTIONS FOR INTRODUCING THE INPUT FILES
230% automatically sets the global properties when the rootfile name is introduced
231% then activate the view-field action if selected
232% it is activated either by clicking on the RootPath window or by the
233% browser
234%------------------------------------------------------------------
235%------------------------------------------------------------------
236
237%-------------------------------------------------------------------
238function update_mask(handles,num_i1,num_j1)
239%-------------------------------------------------------------------
240
241MaskData=get(handles.mask_test,'UserData');
242if isfield(MaskData,'maskhandle')&& ishandle(MaskData.maskhandle)
243    uistack(MaskData.maskhandle,'top');
244end
245num_i1_mask=mod(num_i1-1,MaskData.NbSlice)+1;
246[RootPath,RootFile]=fullfile(MaskData.Base);
247MaskName=fullfile_uvmat(RootPath,'',RootFile,'.png',MaskData.NomType,num_i1_mask,[],num_j1);
248%[MaskName,mdetect]=name_generator(MaskData.Base,num_i1_mask,num_j1,'.png',MaskData.NomType);
249huvmat=get(handles.mask_test,'parent');
250UvData=get(huvmat,'UserData');
251
252%update mask image if the mask is new
253if ~ (isfield(UvData,'MaskName') && isequal(UvData.MaskName,MaskName))
254    UvData.MaskName=MaskName; %update the recorded name on UvData
255    set(huvmat,'UserData',UvData);
256    if mdetect==0
257        if isfield(MaskData,'maskhandle')&& ishandle(MaskData.maskhandle)
258            delete(MaskData.maskhandle)   
259        end
260    else
261        %read mask image
262        Mask.AName='image';
263        Mask.A=imread(MaskName);
264        npxy=size(Mask.A);
265        Mask.AX=[0.5 npxy(2)-0.5];
266        Mask.AY=[npxy(1)-0.5 0.5 ];
267        Mask.CoordUnit='pixel';
268        if isequal(get(handles.slices,'Value'),1)
269           NbSlice=str2num(get(handles.nb_slice,'String'));
270           num_i1=str2num(get(handles.i1,'String'));
271           Mask.ZIndex=mod(num_i1-1,NbSlice)+1;
272        end
273        %px to phys or other transform on field
274         menu_transform=get(handles.transform_fct,'String');
275        choice_value=get(handles.transform_fct,'Value');
276        transform_name=menu_transform{choice_value};%name of the transform fct  given by the menu 'transform_fct'
277        transform_list=get(handles.transform_fct,'UserData');
278        transform=transform_list{choice_value};
279        if  ~isequal(transform_name,'') && ~isequal(transform_name,'px')
280            if isfield(UvData,'XmlData') && isfield(UvData.XmlData,'GeometryCalib')%use geometry calib recorded from the ImaDoc xml file as first priority
281                Calib=UvData.XmlData.GeometryCalib;
282                Mask=transform(Mask,UvData.XmlData);
283            end
284        end
285        flagmask=Mask.A < 200;
286       
287        %make brown color image
288        imflag(:,:,1)=0.9*flagmask;
289        imflag(:,:,2)=0.7*flagmask;
290        imflag(:,:,3)=zeros(size(flagmask));
291       
292        %update mask image
293        hmask=[]; %default
294        if isfield(MaskData,'maskhandle')&& ishandle(MaskData.maskhandle)
295            hmask=MaskData.maskhandle;
296        end
297        if ~isempty(hmask)
298            set(hmask,'CData',imflag)   
299            set(hmask,'AlphaData',flagmask*0.6)
300            set(hmask,'XData',Mask.AX);
301            set(hmask,'YData',Mask.AY);
302%             uistack(hmask,'top')
303        else
304            axes(handles.PlotAxes)
305            hold on   
306            MaskData.maskhandle=image(Mask.AX,Mask.AY,imflag,'Tag','mask','HitTest','off','AlphaData',0.6*flagmask);
307%             set(MaskData.maskhandle,'AlphaData',0.6*flagmask)
308            set(handles.mask_test,'UserData',MaskData)
309        end
310    end
311end
312
313
314%-------------------------------------------------------------------
315function MenuExportFigure_Callback(hObject, eventdata, handles)
316%-------------------------------------------------------------------
317hfig=figure;
318hc=copyobj(handles.PlotAxes,hfig);
319set(hc,'Position',[0.1 0.1 0.8 0.8])
320h=findobj(handles.PlotAxes,'tag','ima'); %look for image in the plot
321if ~isempty(h)
322    h=findobj(handles.PlotAxes,'tag','ima'); %look for image in the plot
323    map=colormap(handles.PlotAxes);
324    colormap(map);%transmit the current colormap to the zoom fig
325    colorbar
326end
327
328% --------------------------------------------------------------------
329function MenuExportAxis_Callback(hObject, eventdata, handles)
330ListFig=findobj(allchild(0),'Type','figure');
331nb_option=0;
332menu={};
333for ilist=1:numel(ListFig)
334    FigName=get(ListFig(ilist),'name');
335    if isempty(FigName)
336        FigName=['figure ' num2str(ListFig(ilist))];
337    end
338    if ~strcmp(FigName,'uvmat')
339        ListAxes=findobj(ListFig(ilist),'Type','axes');
340        ListTags=get(ListAxes,'Tag');
341        if ~isempty(ListTags) && ~isempty(find(~strcmp('Colorbar',ListTags), 1))
342            ListAxes=ListAxes(~strcmp('Colorbar',ListTags));
343            if numel(ListAxes)==1
344                nb_option=nb_option+1;
345                menu{nb_option}=FigName ;
346                AxesHandle(nb_option)=ListAxes;
347            else
348                nb_axis=0;
349                for iaxes=1:numel(ListAxes)
350                    nb_axis=nb_axis+1;
351                    nb_option=nb_option+1;
352                    menu{nb_option}=[FigName '_' num2str(nb_axis)];
353                    AxesHandle(nb_option)=ListAxes(nb_axis);
354                end
355            end
356        end
357    end
358end
359if isempty(menu)
360    answer=msgbox_uvmat('INPUT_Y-N','no existing plotting axes available, create new figure?');
361    if strcmp(answer,'Yes')
362        hfig=figure;
363        copyobj(handles.PlotAxes,hfig);
364    else
365        return
366    end
367    map=colormap(handles.PlotAxes);
368    colormap(map);%transmit the current colormap to the zoom fig
369    colorbar
370else
371    answer=msgbox_uvmat('INPUT_MENU','select a figure/axis on which the current uvmat plot will be exported',menu);
372    if isempty(answer)
373        return
374    else
375        axes(AxesHandle(answer))
376        hold on
377        hchild=get(handles.PlotAxes,'children');
378        copyobj(hchild,gca);
379    end
380end
381
382%-------------------------------------------------------------------
383%-------------------------------------------------------------------
384% III - MAIN REFRESH FUNCTIONS : 'FRAME PLOT'
385%-------------------------------------------------------------------
386%-------------------------------------------------------------------
387
388%Executes on button press in runplus: make one step forward and call
389%run0. The step forward is along the fields series 1 or 2 depending on
390%the scan_i and scan_j check box (exclusive each other)
391%-------------------------------------------------------------------
392function runplus_Callback(hObject, eventdata, handles)
393increment=str2num(get(handles.increment_scan,'String')); %get the field increment d
394runpm(hObject,eventdata,handles,increment)
395
396%-------------------------------------------------------------------
397%Executes on button press in runmin: make one step backward and call
398%run0. The step backward is along the fields series 1 or 2 depending on
399%the scan_i and scan_j check box (exclusive each other)
400%-------------------------------------------------------------------
401function runmin_Callback(hObject, eventdata, handles)
402increment=-str2num(get(handles.increment_scan,'String')); %get the field increment d
403runpm(hObject,eventdata,handles,increment)
404
405%------------------------------------------------------------------------
406% --- translate coordinate to matrix index
407%------------------------------------------------------------------------
408function [indx,indy]=pos2ind(x0,rangx0,nxy)
409indx=1+round((nxy(2)-1)*(x0-rangx0(1))/(rangx0(2)-rangx0(1)));% index x of pixel 
410indy=1+round((nxy(1)-1)*(y12-rangy0(1))/(rangy0(2)-rangy0(1)));% index y of pixel
411
412%------------------------------------------------------------------------
413% --- Executes on button press in 'CheckZoom'.
414%------------------------------------------------------------------------
415function CheckZoom_Callback(hObject, eventdata, handles)
416
417if get(handles.CheckZoom,'Value')
418    set(handles.CheckFixLimits,'Value',1)% propose by default fixed limits for the plotting axes
419    set(handles.CheckZoomFig,'Value',0)%desactivate zoom fig
420end
421
422%------------------------------------------------------------------------
423% --- Executes on button press in CheckZoomFig.
424%------------------------------------------------------------------------
425function CheckZoomFig_Callback(hObject, eventdata, handles)
426if get(handles.CheckZoomFig,'Value')
427    set(handles.CheckZoom,'value',0)
428end
429
430%------------------------------------------------------------------------
431% --- Executes on button press in 'FixLimits'.
432%------------------------------------------------------------------------
433function CheckFixLimits_Callback(hObject, eventdata, handles)
434test=get(handles.CheckFixLimits,'Value');
435update_plot(handles)
436 
437%------------------------------------------------------------------------
438% --- Executes on button press in CheckFixAspectRatio.
439%------------------------------------------------------------------------
440function CheckFixAspectRatio_Callback(hObject, eventdata, handles)
441if get(handles.CheckFixAspectRatio,'Value')
442    update_plot(handles);
443else
444    update_plot(handles);
445end
446
447%------------------------------------------------------------------------
448function num_AspectRatio_Callback(hObject, eventdata, handles)
449%------------------------------------------------------------------------
450set(handles.CheckFixAspectRatio,'Value',1)% select the fixed aspect ratio button
451update_plot(handles);
452
453%-------------------------------------------------------------------
454%-------------------------------------------------------------------
455%  - FUNCTIONS FOR SETTING PLOTTING PARAMETERS
456
457%------------------------------------------------------------------
458
459
460%------------------------------------------------------------------
461% --- Executes on selection change in col_vec: choice of the color code.
462%
463function col_vec_Callback(hObject, eventdata, handles)
464%------------------------------------------------------------------
465% edit the choice for color code
466list_code=get(handles.col_vec,'String');% list menu fields
467index_code=get(handles.col_vec,'Value');% selected string index
468col_code= list_code{index_code(1)}; % selected field
469if isequal(col_code,'black') | isequal(col_code,'white')
470   set(handles.slider1,'Visible','off')
471   set(handles.slider2,'Visible','off')
472   set(handles.colcode1,'Visible','off')
473   set(handles.colcode2,'Visible','off')
474   set(handles.AutoVecColor,'Visible','off')
475   set_vec_col_bar(handles)
476else
477   set(handles.slider1,'Visible','on')
478   set(handles.slider2,'Visible','on')
479   set(handles.colcode1,'Visible','on')
480   set(handles.colcode2,'Visible','on')
481   set(handles.AutoVecColor,'Visible','on') 
482   if isequal(col_code,'ima_cor')
483       set(handles.AutoVecColor,'Value',0)%fixed scale by default
484       set(handles.vec_col_bar,'Value',0)% 3 colors r,g,b by default
485       set(handles.slider1,'Min',0);
486       set(handles.slider1,'Max',1);
487       set(handles.slider2,'Min',0);
488       set(handles.slider2,'Max',1);
489 %      set(handles.min_C_title_vec,'String','0')
490       set(handles.max_vec,'String','1')
491       set(handles.colcode1,'String','0.333')
492       colcode1_Callback(hObject, eventdata, handles)
493       set(handles.colcode2,'String','0.666')
494       colcode2_Callback(hObject, eventdata, handles)
495   else
496       set(handles.AutoVecColor,'Value',1)%auto scale between min,max by default
497       set(handles.vec_col_bar,'Value',1)% colormap 'jet' by default
498       minval=get(handles.slider1,'Min');
499       maxval=get(handles.slider1,'Max');
500       set(handles.slider1,'Value',minval)
501       set(handles.slider2,'Value',maxval)
502       set_vec_col_bar(handles)
503   end
504%    slider_update(handles)
505end
506%replot the current graph
507run0_Callback(hObject, eventdata, handles)
508
509
510%----------------------------------------------------------------
511% -- Executes on slider movement to set the color code
512%
513function slider1_Callback(hObject, eventdata, handles)
514%------------------------------------------------------------------
515slider1=get(handles.slider1,'Value');
516min_val=str2num(get(handles.min_vec,'String'));
517max_val=str2num(get(handles.max_vec,'String'));
518col=min_val+(max_val-min_val)*slider1;
519set(handles.colcode1,'String',num2str(col))
520if(get(handles.slider2,'Value') < col)%move also the second slider at the same value if needed
521    set(handles.slider2,'Value',col)
522    set(handles.colcode2,'String',num2str(col))
523end
524colcode1_Callback(hObject, eventdata, handles)
525
526%----------------------------------------------------------------
527% Executes on slider movement to set the color code
528%----------------------------------------------------------------
529function slider2_Callback(hObject, eventdata, handles)
530slider2=get(handles.slider2,'Value');
531min_val=str2num(get(handles.min_vec,'String'));
532max_val=str2num(get(handles.max_vec,'String'));
533col=min_val+(max_val-min_val)*slider2;
534set(handles.colcode2,'String',num2str(col))
535if(get(handles.slider1,'Value') > col)%move also the first slider at the same value if needed
536    set(handles.slider1,'Value',col)
537    set(handles.colcode1,'String',num2str(col))
538end
539colcode2_Callback(hObject, eventdata, handles)
540
541%----------------------------------------------------------------
542%execute on return carriage on the edit box corresponding to slider 1
543%----------------------------------------------------------------
544function colcode1_Callback(hObject, eventdata, handles)
545% col=str2num(get(handles.colcode1,'String'));
546% set(handles.slider1,'Value',col)
547set_vec_col_bar(handles)
548update_plot(handles)
549
550%----------------------------------------------------------------
551%execute on return carriage on the edit box corresponding to slider 2
552%----------------------------------------------------------------
553function colcode2_Callback(hObject, eventdata, handles)
554% col=str2num(get(handles.colcode2,'String'));
555% set(handles.slider2,'Value',col)
556% slider2_Callback(hObject, eventdata, handles)
557set_vec_col_bar(handles)
558update_plot(handles)
559
560%-------------------------------------------------------
561% --- Executes on button press in AutoVecColor.
562%-------------------------------------------------------
563function vec_col_bar_Callback(hObject, eventdata, handles)
564set_vec_col_bar(handles)
565
566%------------------------------------------------
567%CALLBACKS FOR PLOTTING PARAMETERS
568%-------------------------------------------------
569
570%------------------------------------------------------------------------
571function num_MinX_Callback(hObject, eventdata, handles)
572%------------------------------------------------------------------------
573set(handles.CheckFixLimits,'Value',1) %suppress auto mode
574% set(handles.CheckFixLimits,'BackgroundColor',[1 1 0])
575update_plot(handles);
576
577%------------------------------------------------------------------------
578function num_MaxX_Callback(hObject, eventdata, handles)
579%------------------------------------------------------------------------
580set(handles.CheckFixLimits,'Value',1) %suppress auto mode
581% set(handles.CheckFixLimits,'BackgroundColor',[1 1 0])
582update_plot(handles);
583
584%------------------------------------------------------------------------
585function num_MinY_Callback(hObject, eventdata, handles)
586%------------------------------------------
587set(handles.CheckFixLimits,'Value',1) %suppress auto mode
588% set(handles.CheckFixLimits,'BackgroundColor',[1 1 0])
589update_plot(handles);
590
591%------------------------------------------------------------------------
592function num_MaxY_Callback(hObject, eventdata, handles)
593%------------------------------------------------------------------------
594set(handles.CheckFixLimits,'Value',1) %suppress auto mode
595% set(handles.CheckFixLimits,'BackgroundColor',[1 1 0])
596update_plot(handles);
597
598%-----------------------------------------------------------------
599function num_MinA_Callback(hObject, eventdata, handles)
600%------------------------------------------
601set(handles.CheckFixScalar,'Value',1) %suppress auto mode
602set(handles.CheckFixScalar,'BackgroundColor',[1 1 0])
603update_plot(handles)
604
605%-----------------------------------------------------------------
606function num_MaxA_Callback(hObject, eventdata, handles)
607%--------------------------------------------
608set(handles.CheckFixScalar,'Value',1) %suppress auto mode
609% set(handles.CheckFixScalar,'BackgroundColor',[1 1 0])
610update_plot(handles)
611
612%-----------------------------------------------
613function CheckFixScalar_Callback(hObject, eventdata, handles)
614%--------------------------------------------
615test=get(handles.CheckFixScalar,'Value');
616% if test
617%     set(handles.CheckFixScalar,'BackgroundColor',[1 1 0])
618% else
619%     set(handles.CheckFixScalar,'BackgroundColor',[0.7 0.7 0.7])
620%     update_plot(handles);
621% %     set(handles.MinA,'String',num2str(ScalOut.MinA,3))
622% %     set(handles.MaxA,'String',num2str(ScalOut.MaxA,3))
623% end
624
625%-------------------------------------------------------------------
626function CheckBW_Callback(hObject, eventdata, handles)
627%-------------------------------------------------------------------
628update_plot(handles)
629
630%-------------------------------------------------------------------
631function ListContour_Callback(hObject, eventdata, handles)
632%-------------------------------------------------------------------
633val=get(handles.Contours,'Value');
634if val==2
635    set(handles.interval_txt,'Visible','on')
636    set(handles.IncrA,'Visible','on')
637else
638    set(handles.interval_txt,'Visible','off')
639    set(handles.IncrA,'Visible','off')
640end
641update_plot(handles)
642
643%-------------------------------------------------------------------
644function IncrA_Callback(hObject, eventdata, handles)
645%-------------------------------------------------------------------
646update_plot(handles)
647
648%-------------------------------------------------------------------
649function HideWarning_Callback(hObject, eventdata, handles)
650%-------------------------------------------------------------------
651update_plot(handles)
652
653%-------------------------------------------------------------------
654function HideFalse_Callback(hObject, eventdata, handles)
655%-------------------------------------------------------------------
656update_plot(handles)
657
658%-------------------------------------------------------------------
659function num_VecScale_Callback(hObject, eventdata, handles)
660%-------------------------------------------------------------------
661set(handles.CheckFixVectors,'Value',1);
662update_plot(handles)
663
664%-------------------------------------------------------------------
665function FixVec_Callback(hObject, eventdata, handles)
666%-------------------------------------------------------------------
667test=get(handles.FixVec,'Value');
668if test
669    set(handles.FixVec,'BackgroundColor',[1 1 0])
670else
671    update_plot(handles);
672    %set(handles.VecScale,'String',num2str(ScalOut.VecScale,3))
673%     set(handles.FixVec,'BackgroundColor',[0.7 0.7 0.7])
674end
675
676%-------------------------------------------------------
677% --- Executes on selection change in decimate4 (nb_vec/4).
678%-------------------------------------------------------
679function CheckDecimate4_Callback(hObject, eventdata, handles)
680update_plot(handles)
681
682
683%-------------------------------------------------------
684% --- Executes on selection change in color_code menu
685%-------------------------------------------------------
686function color_code_Callback(hObject, eventdata, handles)
687set_vec_col_bar(handles)
688update_plot(handles);
689
690%-------------------------------------------------------
691% --- Executes on button press in AutoVecColor.
692%-------------------------------------------------------
693function AutoVecColor_Callback(hObject, eventdata, handles)
694test=get(handles.AutoVecColor,'Value');
695if test
696    set(handles.AutoVecColor,'BackgroundColor',[1 1 0])
697else
698    update_plot(handles);
699    %set(handles.VecScale,'String',num2str(ScalOut.VecScale,3))
700    set(handles.AutoVecColor,'BackgroundColor',[0.7 0.7 0.7])
701end
702%set_vec_col_bar(handles)
703
704%-------------------------------------------------------
705% --- Executes on selection change in max_vec.
706%-------------------------------------------------------
707function min_vec_Callback(hObject, eventdata, handles)
708max_vec_Callback(hObject, eventdata, handles)
709
710% --- Executes on selection change in max_vec.
711function max_vec_Callback(hObject, eventdata, handles)
712set(handles.AutoVecColor,'Value',1)
713AutoVecColor_Callback(hObject, eventdata, handles)
714min_val=str2num(get(handles.min_vec,'String'));
715max_val=str2num(get(handles.max_vec,'String'));
716slider1=get(handles.slider1,'Value');
717slider2=get(handles.slider2,'Value');
718colcode1=min_val+(max_val-min_val)*slider1;
719colcode2=min_val+(max_val-min_val)*slider2;
720set(handles.colcode1,'String',num2str(colcode1))
721set(handles.colcode2,'String',num2str(colcode2))
722update_plot(handles);
723
724%-------------------------------------------------------------------
725%update the display of color code for vectors
726function set_vec_col_bar(handles)
727%-------------------------------------------------------------------
728%get the image of the color display button 'vec_col_bar' in pixels
729set(handles.vec_col_bar,'Unit','pixel');
730pos_vert=get(handles.vec_col_bar,'Position');
731set(handles.vec_col_bar,'Unit','Normalized');
732width=ceil(pos_vert(3));
733height=ceil(pos_vert(4));
734
735%get slider indications
736list=get(handles.color_code,'String');
737ichoice=get(handles.color_code,'Value');
738colcode.ColorCode=list{ichoice};
739colcode.MinC=str2num(get(handles.min_vec,'String'));
740colcode.MaxC=str2num(get(handles.max_vec,'String'));
741test3color=strcmp(colcode.ColorCode,'rgb') || strcmp(colcode.ColorCode,'bgr');
742if test3color
743    colcode.colcode1=str2num(get(handles.colcode1,'String'));
744    colcode.colcode2=str2num(get(handles.colcode2,'String'));
745end
746colcode.FixedCbounds=0;
747colcode.FixedCbounds=1;
748vec_C=colcode.MinC+(colcode.MaxC-colcode.MinC)*[0.5:width-0.5]/width;%sample of vec_C values from min to max
749[colorlist,col_vec]=set_col_vec(colcode,vec_C);
750oneheight=ones(1,height);
751A1=colorlist(col_vec,1)*oneheight;
752A2=colorlist(col_vec,2)*oneheight;
753A3=colorlist(col_vec,3)*oneheight;
754A(:,:,1)=A1';
755A(:,:,2)=A2';
756A(:,:,3)=A3';
757set(handles.vec_col_bar,'Cdata',A)
758
759%-------------------------------------------------------------------
760function update_plot(handles)
761%-------------------------------------------------------------------
762Data=get(handles.view_field,'UserData');
763AxeData=Data.PlotAxes;% retrieve the current plotted data
764PlotParam=read_GUI(handles.view_field);
765[PP,PlotParamOut]= plot_field(AxeData,handles.PlotAxes,PlotParam);
766errormsg=fill_GUI(PlotParamOut,handles.view_field);
767if ~isempty(errormsg)
768    msgbox_uvmat('ERROR',errormsg)
769    return
770end
771hedit=findobj(handles.view_field,'Style','edit');
772set(hedit,'BackgroundColor',[1 1 1])
773
774%------------------------------------------------------------------------
775% --- Executes on button press in Menu/Export/field in workspace.
776function MenuExportField_Callback(hObject, eventdata, handles)
777%------------------------------------------------------------------------
778global Data_view_field
779% huvmat=findobj(allchild(0),'Name','uvmat');
780Data_view_field=get(handles.view_field,'UserData');
781Data_view_field=Data_view_field.PlotAxes;
782% Data_view_field=UvData.ProjField_2;
783evalin('base','global Data_view_field')%make CurData global in the workspace
784display(['UserData of view_field :'])
785evalin('base','Data_view_field') %display CurData in the workspace
786commandwindow;
787
788%------------------------------------------------------------------------
789% --- Executes on button press in Menu/Export/extract figure.
790function MenuExport_plot_Callback(hObject, eventdata, handles)
791%------------------------------------------------------------------------
792huvmat=get(handles.MenuExport_plot,'parent');
793UvData=get(huvmat,'UserData');
794hfig=figure;
795newaxes=copyobj(handles.PlotAxes,hfig);
796map=colormap(handles.PlotAxes);
797colormap(map);%transmit the current colormap to the zoom fig
798colorbar
799
800
801% --- Executes on selection change in ColorCode.
802function ColorCode_Callback(hObject, eventdata, handles)
803
804
805% --- Executes on selection change in ColorScalar.
806function ColorScalar_Callback(hObject, eventdata, handles)
807
808
809function num_ColCode2_Callback(hObject, eventdata, handles)
810
811
812
813% --- Executes on button press in CheckTable.
814function CheckTable_Callback(hObject, eventdata, handles)
815if get(handles.CheckTable,'Value')
816    set(handles.TableDisplay,'Visible','on')
817else
818    set(handles.TableDisplay,'Visible','off')
819end
820   
Note: See TracBrowser for help on using the repository browser.