Changeset 627
- Timestamp:
- May 3, 2013, 10:11:43 AM (12 years ago)
- Location:
- trunk/src
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/activate.m
r620 r627 7 7 % PanelTag: tag name of a uipanel containing the element, =[] if no panel 8 8 % ObjectTag: tag name of the element 9 % Position=[x y] coordinates set for the mouse relative to the object (default =[] corresponds to the centre [0.5 0.5] 9 10 % Value: value set to the element, for instance string to select on a menu 10 11 11 function activate(FigTag,PanelTag,ObjectTag, Value)12 function activate(FigTag,PanelTag,ObjectTag,Position,Value) 12 13 hFig=findobj(allchild(0),'tag',FigTag); 13 14 set(0,'CurrentFigure',hFig) 15 % xx=double(get(hFig,'CurrentCharacter')); %get the keyboard character 16 % if isequal(xx,27) % key escape 17 % pause 18 % end 14 19 handles=guidata(hFig); 15 20 unit_0=get(0,'Unit'); 16 21 unit=get(hFig,'Unit'); 17 22 set(hFig,'Unit',unit_0) 18 FramePos=get(hFig,'Position'); 23 FramePos=get(hFig,'Position');% position of the figure 19 24 set(hFig,'Unit',unit) 20 25 if isempty(PanelTag) … … 27 32 FramePos=FramePos+get(hPanel,'Position'); 28 33 set(hPanel,'Unit',unit) 34 end 35 if ~exist('Position','var') 36 Position=[]; 37 end 38 if isempty(Position) 39 Position=[0.5 0.5]; 40 end 41 if ~exist('Value','var') 42 Value=[]; 29 43 end 30 44 hObject=handles.(ObjectTag); … … 39 53 end 40 54 errormsg=fill_GUI(Param,hFig); 55 if ~isempty(errormsg) 56 disp(errormsg) 57 end 58 % if isequal(get(handles.(ObjectTag),'Style'),'pushbutton') 59 % set(handles.(ObjectTag),'Value',Value) 60 % end 41 61 end 42 62 unit=get(hObject,'Unit'); … … 44 64 Pos=get(hObject,'Position'); 45 65 set(hObject,'Unit',unit) 46 set(0,'PointerLocation',FramePos(1:2)+Pos(1:2))47 BackgroundColor=get(hObject,'BackgroundColor');48 set( hObject,'BackgroundColor',[1 1 0])66 CurrentPointerLoc=get(0,'PointerLocation'); 67 NewPointerLoc=FramePos(1:2)+Pos(1:2)+Position.*Pos(3:4); 68 set(0,'PointerLocation',FramePos(1:2)+Pos(1:2)+Position.*Pos(3:4)) 49 69 for ipos=1:10 50 set(0,'PointerLocation', FramePos(1:2)+Pos(1:2)+0.5*(ipos/10)*Pos(3:4))70 set(0,'PointerLocation',CurrentPointerLoc+0.1*ipos*(NewPointerLoc-CurrentPointerLoc)) 51 71 pause(0.2) 52 72 end 73 if strcmp(get(hObject,'Style'),'axes') 74 mouse_down(hFig,[]) 75 mouse_up(hFig,[]) 76 else 77 BackgroundColor=get(hObject,'BackgroundColor'); 78 set(hObject,'BackgroundColor',[1 1 0])% mark activation of the object 79 drawnow 53 80 feval(FigTag,[ObjectTag '_Callback'],hObject,[],handles); 81 pause(2) 54 82 set(hObject,'BackgroundColor',BackgroundColor) 83 end 55 84 end 85 %%%%text display 86 if isempty(Value) 87 disp(['mouse select ' ObjectTag ' in ' FigTag ' ' PanelTag]) 88 else 89 disp(['set ' Value ' in ' FigTag ' ' PanelTag ' ' ObjectTag]) 90 end -
trunk/src/demo_uvmat.m
r620 r627 2 2 3 3 %%%% Demo 1%%%% 4 pause on5 4 % brigtness 6 activate('uvmat','Scalar','num_MaxA',100) 7 pause 8 activate('uvmat','Scalar','CheckFixScalar',0) 9 pause 10 activate('uvmat','Scalar','CheckZoom',1) 11 pause 12 activate('uvmat',[],'movie_pair',1) 13 pause 14 activate('uvmat',[],'STOP',1) 15 activate('uvmat',[],'i1','2') 5 huvmat=findobj(allchild(0),'Tag','uvmat'); 6 figure(huvmat) 7 activate('uvmat','Scalar','num_MaxA',[],100) 8 activate('uvmat','Scalar','CheckFixScalar',[],0) 9 activate('uvmat','Coordinates','CheckZoom',[],1) 10 activate('uvmat',[],'PlotAxes',[0.2 0.6]) 11 %activate('uvmat',[],'movie_pair',[],1) 12 %activate('uvmat',[],'STOP',[],1) 13 activate('uvmat',[],'i1',[],'2') -
trunk/src/mouse_down.m
r625 r627 118 118 if isfield(FigData,tagaxes) 119 119 Field=FigData.(tagaxes); 120 [CellVarIndex,NbDim,VarType]=find_field_cells(Field);%analyse the physical fields contained in Field 121 for icell=1:numel(CellVarIndex)%look for all physical fields 120 [CellInfo,NbDim,errormsg]=find_field_cells(Field);%analyse the physical fields contained in Field 121 if isempty(errormsg) 122 for icell=1:numel(CellInfo)%look for all physical fields 122 123 if NbDim(icell)==2 % select 2D field 123 if isfield(Field,'CoordMesh') && ~isempty(Field.CoordMesh)&& ~isempty(VarType{icell}.coord_x) && ~isempty(VarType{icell}.coord_y)%case of unstructured data 124 X=Field.(Field.ListVarName{VarType{icell}.coord_x}); 125 Y=Field.(Field.ListVarName{VarType{icell}.coord_y}); 124 if isfield(Field,'CoordMesh') && ~isempty(Field.CoordMesh)&&... 125 ~isempty(CellInfo{icell}.VarIndex_coord_x) && ~isempty(CellInfo{icell}.VarIndex_coord_y)%case of unstructured data 126 X=Field.(Field.ListVarName{CellInfo{icell}.VarIndex_coord_x}); 127 Y=Field.(Field.ListVarName{CellInfo{icell}.VarIndex_coord_y}); 126 128 flag_vec=(X<(xy(1,1)+Field.CoordMesh/4) & X>(xy(1,1)-Field.CoordMesh/4)) & ...%flagx=1 for the vectors with x position selected by the mouse 127 129 (Y<(xy(1,2)+Field.CoordMesh/4) & Y>(xy(1,2)-Field.CoordMesh/4));%f … … 129 131 end 130 132 end 133 end 131 134 end 132 135 end … … 173 176 end 174 177 175 %% delete the current zoom rectangle176 % if isfield(AxeData,'CurrentRectZoom') && ~isempty(AxeData.CurrentRectZoom) && ishandle(AxeData.CurrentRectZoom)177 % delete(AxeData.CurrentRectZoom)178 % AxeData.CurrentRectZoom=[];179 % end180 181 178 %% zoom has first priority, stop here 182 179 if CheckZoom 183 180 return 181 end 182 183 %% Creation of a display window zoom of text_display 184 if isequal(get(hObject,'SelectionType'),'alt') && strcmp(htype,'axes') && ~test_edit && ~test_create 185 set(0,'Unit','pixels') 186 GUISize=get(0,'ScreenSize');% get the size of the screen, to put the fig on the upper right 187 Width=300;% fig width in points (1/72 inch) 188 Height=200; 189 Left=GUI_pos(1)+GUI_pos(3)-Width; %right edge close to the right, with margin=40 190 Bottom=GUI_pos(2)+GUI_pos(4)-Height; %put fig at top right 191 hfig_text=figure('Name','text_display','MenuBar','none','NumberTitle','off','Position',[Left,Bottom,Width,Height]); 192 AxeData.htext_display=uicontrol('Style','edit','Units','normalized', 'Position', [0.05 0.05 0.9 0.9],'Max',2,'BackgroundColor',[1 1 1],... 193 'FontUnits','points','FontSize',14); 194 set(hchild,'UserData',AxeData); 195 return %leave the function once a uicontrol has been selected 184 196 end 185 197 … … 380 392 set(AxeData.CurrentObject,'UserData',PlotData); %record the object index in the graph (memory used for mouse motion) 381 393 AxeData.Drawing='create';% flag for mouse motion 382 383 384 %initiate a new object (no data .Coord yet recorded) 385 %if ~isfield(UvData.ProjObject{IndexObj},'Coord'); 386 % ObjectData.Coord=[]; 387 388 % if isempty(ListObject) 389 % ListObject={ObjectName}; 390 % else 391 % ListObject{end}=ObjectName; 392 % end 393 % UvData.ProjObject{IndexObj}=[]; %create a new empty object 394 % UvData.ProjObject{IndexObj}.DisplayHandle.uvmat=hhuvmat.PlotAxes; % axes for plot_object 395 % UvData.ProjObject{IndexObj}.DisplayHandle.view_field=[]; %no plot handle before plot_field operation 396 397 % PlotData=get(AxeData.CurrentObject,'UserData'); 398 % PlotData.IndexObj=IndexObj; 399 % set(AxeData.CurrentObject,'UserData',PlotData); %record the object index in the graph (memory used for mouse motion) 400 % AxeData.Drawing='create';% flag for mouse motion 394 401 395 %show object coordinates in the GUI set_object 402 396 h_set_object=findobj(allchild(0),'Tag','set_object'); … … 475 469 if ~isfield(Field,'FF') 476 470 Field.ListVarName=[Field.ListVarName 'FF']; 477 Field.VarDimName=[Field.VarDimName Field.VarDimName{ VarType{icell}.coord_x}];471 Field.VarDimName=[Field.VarDimName Field.VarDimName{CellInfo{icell}.VarIndex_coord_x}]; 478 472 nbvar=length(Field.ListVarName); 479 473 Field.VarAttribute{nbvar}.Role='errorflag'; -
trunk/src/mouse_motion.m
r625 r627 39 39 hPlotAxes=hhCurrentFig.PlotAxes';% handles of the main plot axes 40 40 AxeData=get(hPlotAxes,'UserData');% data attached to the axis 41 htext_display(1)=handles.text_display; 42 if isfield(AxeData,'htext_display')&&ishandle(AxeData.htext_display) 43 htext_display(2)=AxeData.htext_display; 44 end 41 45 test_draw=0;%test for mouse drawing of object, =0 by default 42 46 if isfield(AxeData,'Drawing')&& ~isempty(AxeData.Drawing) … … 288 292 text_displ(ind_blank)=[]; 289 293 end 290 set(handles.text_display,'String',text_displ) 294 %set(handles.text_display,'String',text_displ) 295 set(htext_display,'String',text_displ) 291 296 else 292 set(handles.text_display,'String',get(handles.text_display,'UserData')) 297 %set(handles.text_display,'String',get(handles.text_display,'UserData')) 298 set(htext_display,'String',get(handles.text_display,'UserData')) 293 299 end 294 300 -
trunk/src/mouse_up.m
r625 r627 172 172 set(hhuvmat.edit_object,'Value',1);% 173 173 set(hhuvmat.edit_object,'Enable','on');% 174 set(hhuvmat.MenuEditObject,'Enable','on');%175 set(hhuvmat.MenuEdit,'Enable','on');%174 % set(hhuvmat.MenuEditObject,'Enable','on');% 175 % set(hhuvmat.MenuEdit,'Enable','on');% 176 176 set(get(h_set_object,'children'),'Enable','on') 177 177 end … … 376 376 end 377 377 378 %% display the data of the current object selected with the mouse right click379 if isequal(get(hcurrentfig,'SelectionType'),'alt') && ~CheckZoom && (~isfield(AxeData,'Drawing')||~isequal(AxeData.Drawing,'create'))380 hother=findobj('Tag','proj_object');%find all the proj objects381 nbselect=0;382 %test the existence of selected objects:383 for iproj=1:length(hother);384 iselect=isequal(get(hother(iproj),'Selected'),'on');%reset all the proj objects in 'blue' by default385 nbselect=nbselect+iselect;386 end387 hother=findobj('Tag','proj_object','Type','line');%find all the proj objects388 set(hother,'Color','b');%reset all the proj objects in 'blue' by default389 set(hother,'Selected','off')390 hother=findobj('Tag','proj_object','Type','rectangle');391 set(hother,'EdgeColor','b');392 set(hother,'Selected','off')393 hother=findobj('Tag','proj_object','Type','patch');394 set(hother,'FaceColor','b');395 if isequal(get(gco,'Type'),'image')396 currentobj=get(gco,'parent');%parent axes of the image397 else398 currentobj=gco;%default399 end400 % if ((nbselect==0) && isequal(get(currentobj,'Type'),'axes')) || isequal(currentobj,huvmat)401 % hcurrentfig=get(currentobj,'parent');402 % figname=get(hcurrentfig,'name');403 % eval(['global Data_' figname])404 % eval(['Data_' figname '=get(currentobj,''UserData'')']);405 % evalin('base',['global Data_' figname])%make CurData global in the workspace406 % objtype=get(currentobj,'Type');407 % display(['UserData of ' objtype ':'])408 % evalin('base',['Data_' figname]) %display CurData in the workspace409 % commandwindow %brings the Matlab command window to the front410 % end411 end412 378 413 379 %% update -
trunk/src/set_object.m
r625 r627 579 579 580 580 %% update the GUI uvmat 581 set(hhuvmat.MenuEditObject,'enable','on')581 % set(hhuvmat.MenuEditObject,'enable','on') 582 582 set(hhuvmat.edit_object,'Value',1) % set uvmat to object edit mode to allow further object update 583 583 %set(hhuvmat.edit_object,'BackgroundColor',[1 1 0]);% paint the edit text in yellow -
trunk/src/uvmat.m
r625 r627 2551 2551 UvData.ProjObject{1}.Type='plane';%main plotting plane 2552 2552 UvData.ProjObject{1}.ProjMode='projection';%main plotting plane 2553 UvData.ProjObject{1}.Coord=[0 0 0];2553 % UvData.ProjObject{1}.Coord=[0 0 0]; 2554 2554 UvData.ProjObject{1}.DisplayHandle.uvmat=[]; %plane not visible in uvmat 2555 2555 UvData.ProjObject{1}.DisplayHandle.view_field=[]; %plane not visible in uvmat … … 2619 2619 end 2620 2620 end 2621 %write_plot_param(handles,PlotParamOut) %update the auto plot parameters2622 2621 2623 2622 %% 2D or 3D fieldname are generally projected … … 2945 2944 return 2946 2945 end 2947 test_civ2=isequal(get(handles.civ2,'BackgroundColor'),[1 1 0]); 2948 test_civ1=isequal(get(handles.VelType,'BackgroundColor'),[1 1 0]); 2946 MenuVelType=get(handles.VelType,'String'); 2947 test_civ2=strcmp(MenuVelType{get(handles.VelType,'Value')},'civ2'); 2948 test_civ1=strcmp(MenuVelType{get(handles.VelType,'Value')},'civ1'); 2949 2949 if ~test_civ2 && ~test_civ1 2950 2950 msgbox_uvmat('ERROR','manual correction only possible for CIV1 or CIV2 velocity fields') 2951 2951 end 2952 2952 if test_civ2 2953 nbname='nb_vec tors2';2954 flagname=' vec2_FixFlag';2955 attrname='fix2';2953 nbname='nb_vec_2'; 2954 flagname='Civ2_FF'; 2955 CivStage=5; 2956 2956 end 2957 2957 if test_civ1 2958 nbname='nb_vec tors';2959 flagname=' vec_FixFlag';2960 attrname='fix';2958 nbname='nb_vec_1'; 2959 flagname='Civ1_FF'; 2960 CivStage=2; 2961 2961 end 2962 2962 %write fix flags in the netcdf file 2963 2963 UvData=get(handles.uvmat,'UserData'); 2964 2964 hhh=which('netcdf.open');% look for built-in matlab netcdf library 2965 if ~isequal(hhh,'')% case of newbuiltin Matlab netcdf library2965 if ~isequal(hhh,'')% case of builtin Matlab netcdf library 2966 2966 nc=netcdf.open(FileName,'NC_WRITE'); 2967 2967 netcdf.reDef(nc); 2968 netcdf.putAtt(nc,netcdf.getConstant('NC_GLOBAL'), attrname,1);2968 netcdf.putAtt(nc,netcdf.getConstant('NC_GLOBAL'),'CivStage',CivStage); 2969 2969 dimid = netcdf.inqDimID(nc,nbname); 2970 2970 try … … 3728 3728 if ~strcmp(CoordUnit,CoordUnitPrev) 3729 3729 set(handles.CheckFixLimits,'Value',0) 3730 set(handles.CheckFixLimits,'BackgroundColor',[0.7 0.7 0.7])3730 % set(handles.CheckFixLimits,'BackgroundColor',[0.7 0.7 0.7]) 3731 3731 hother=findobj('Tag','proj_object');%find all the proj objects 3732 3732 for iobj=1:length(hother) … … 3777 3777 %------------------------------------------------------------------------ 3778 3778 set(handles.CheckFixLimits,'Value',1) %suppress auto mode 3779 set(handles.CheckFixLimits,'BackgroundColor',[1 1 0])3779 % set(handles.CheckFixLimits,'BackgroundColor',[1 1 0]) 3780 3780 update_plot(handles); 3781 3781 … … 3784 3784 %------------------------------------------------------------------------ 3785 3785 set(handles.CheckFixLimits,'Value',1) %suppress auto mode 3786 set(handles.CheckFixLimits,'BackgroundColor',[1 1 0])3786 % set(handles.CheckFixLimits,'BackgroundColor',[1 1 0]) 3787 3787 update_plot(handles); 3788 3788 … … 3791 3791 %------------------------------------------ 3792 3792 set(handles.CheckFixLimits,'Value',1) %suppress auto mode 3793 set(handles.CheckFixLimits,'BackgroundColor',[1 1 0])3793 % set(handles.CheckFixLimits,'BackgroundColor',[1 1 0]) 3794 3794 update_plot(handles); 3795 3795 … … 3798 3798 %------------------------------------------------------------------------ 3799 3799 set(handles.CheckFixLimits,'Value',1) %suppress auto mode 3800 set(handles.CheckFixLimits,'BackgroundColor',[1 1 0])3800 % set(handles.CheckFixLimits,'BackgroundColor',[1 1 0]) 3801 3801 update_plot(handles); 3802 3802 … … 3808 3808 %------------------------------------------ 3809 3809 set(handles.CheckFixScalar,'Value',1) %suppress auto mode 3810 set(handles.CheckFixScalar,'BackgroundColor',[1 1 0])3810 % set(handles.CheckFixScalar,'BackgroundColor',[1 1 0]) 3811 3811 MinA=str2double(get(handles.num_MinA,'String')); 3812 3812 MaxA=str2double(get(handles.num_MaxA,'String')); … … 3824 3824 %------------------------------------------------------------------------ 3825 3825 set(handles.CheckFixScalar,'Value',1) %suppress auto mode 3826 set(handles.CheckFixScalar,'BackgroundColor',[1 1 0])3826 % set(handles.CheckFixScalar,'BackgroundColor',[1 1 0]) 3827 3827 MinA=str2double(get(handles.num_MinA,'String')); 3828 3828 MaxA=str2double(get(handles.num_MaxA,'String')); … … 3841 3841 test=get(handles.CheckFixScalar,'Value'); 3842 3842 if test 3843 set(handles.CheckFixScalar,'BackgroundColor',[1 1 0])3843 % set(handles.CheckFixScalar,'BackgroundColor',[1 1 0]) 3844 3844 else 3845 set(handles.CheckFixScalar,'BackgroundColor',[0.7 0.7 0.7])3845 % set(handles.CheckFixScalar,'BackgroundColor',[0.7 0.7 0.7]) 3846 3846 update_plot(handles); 3847 3847 end … … 3901 3901 test=get(handles.CheckFixVectors,'Value'); 3902 3902 if test 3903 set(handles.CheckFixVectors,'BackgroundColor',[1 1 0])3903 % set(handles.CheckFixVectors,'BackgroundColor',[1 1 0]) 3904 3904 else 3905 3905 update_plot(handles); 3906 3906 %set(handles.num_VecScale,'String',num2str(ScalOut.num_VecScale,3)) 3907 set(handles.CheckFixVectors,'BackgroundColor',[0.7 0.7 0.7])3907 % set(handles.CheckFixVectors,'BackgroundColor',[0.7 0.7 0.7]) 3908 3908 end 3909 3909 … … 4853 4853 4854 4854 4855 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%4856 % MenuEdit Callbacks4857 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%4858 % ------------------------------------------------------------------------4859 function MenuEditObject_Callback(hObject, eventdata, handles)4860 % ------------------------------------------------------------------------4861 set(handles.edit_object,'Value',1)4862 edit_Callback(hObject, eventdata, handles)4863 4864 % ------------------------------------------------------------------------4865 function MenuEditVectors_Callback(hObject, eventdata, handles)4866 % ------------------------------------------------------------------------4867 set(handles.edit_vect,'Visible','on')4868 set(handles.edit_vect,'Value',1)4869 edit_vect_Callback(hObject, eventdata, handles)4855 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 4856 % % MenuEdit Callbacks 4857 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 4858 % %------------------------------------------------------------------------ 4859 % function MenuEditObject_Callback(hObject, eventdata, handles) 4860 % %------------------------------------------------------------------------ 4861 % set(handles.edit_object,'Value',1) 4862 % edit_Callback(hObject, eventdata, handles) 4863 % 4864 % %------------------------------------------------------------------------ 4865 % function MenuEditVectors_Callback(hObject, eventdata, handles) 4866 % %------------------------------------------------------------------------ 4867 % set(handles.edit_vect,'Visible','on') 4868 % set(handles.edit_vect,'Value',1) 4869 % edit_vect_Callback(hObject, eventdata, handles) 4870 4870 4871 4871 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% … … 5046 5046 set(handles.ListObject,'Value',val); 5047 5047 flag=1; 5048 if ~isfield(UvData.Field,'A') 5049 msgbox_uvmat('ERROR','an image needs to be opened to set the mask size'); 5050 return 5051 end 5048 5052 npx=size(UvData.Field.A,2); 5049 5053 npy=size(UvData.Field.A,1); … … 5374 5378 end 5375 5379 end 5376 5377
Note: See TracChangeset
for help on using the changeset viewer.