Changeset 627


Ignore:
Timestamp:
May 3, 2013, 10:11:43 AM (12 years ago)
Author:
sommeria
Message:

a few bugs repaired, display of the local mouse indication in a separate window

Location:
trunk/src
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/activate.m

    r620 r627  
    77% PanelTag: tag name of a uipanel containing the element, =[] if no panel
    88% 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]
    910% Value: value set to the element, for instance string to select on a menu
    1011
    11 function activate(FigTag,PanelTag,ObjectTag,Value)
     12function activate(FigTag,PanelTag,ObjectTag,Position,Value)
    1213hFig=findobj(allchild(0),'tag',FigTag);
    1314set(0,'CurrentFigure',hFig)
     15% xx=double(get(hFig,'CurrentCharacter')); %get the keyboard character
     16% if isequal(xx,27) % key escape
     17%     pause
     18% end
    1419handles=guidata(hFig);
    1520unit_0=get(0,'Unit');
    1621unit=get(hFig,'Unit');
    1722set(hFig,'Unit',unit_0)
    18 FramePos=get(hFig,'Position');
     23FramePos=get(hFig,'Position');% position of the figure
    1924set(hFig,'Unit',unit)
    2025if isempty(PanelTag)
     
    2732    FramePos=FramePos+get(hPanel,'Position');
    2833    set(hPanel,'Unit',unit)
     34end
     35if ~exist('Position','var')
     36    Position=[];
     37end
     38if isempty(Position)
     39    Position=[0.5 0.5];
     40end
     41if ~exist('Value','var')
     42    Value=[];
    2943end
    3044hObject=handles.(ObjectTag);
     
    3953        end
    4054        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
    4161    end
    4262    unit=get(hObject,'Unit');
     
    4464    Pos=get(hObject,'Position');
    4565    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)) 
    4969    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))
    5171        pause(0.2)
    5272    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
    5380    feval(FigTag,[ObjectTag '_Callback'],hObject,[],handles);
     81        pause(2)
    5482    set(hObject,'BackgroundColor',BackgroundColor)
     83    end
    5584end
     85%%%%text display
     86if isempty(Value)
     87disp(['mouse select ' ObjectTag ' in ' FigTag ' ' PanelTag])
     88else
     89    disp(['set ' Value ' in ' FigTag ' ' PanelTag ' ' ObjectTag])
     90end
  • trunk/src/demo_uvmat.m

    r620 r627  
    22
    33%%%% Demo 1%%%%
    4 pause on
    54% 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')
     5huvmat=findobj(allchild(0),'Tag','uvmat');
     6figure(huvmat)
     7activate('uvmat','Scalar','num_MaxA',[],100)
     8activate('uvmat','Scalar','CheckFixScalar',[],0)
     9activate('uvmat','Coordinates','CheckZoom',[],1)
     10activate('uvmat',[],'PlotAxes',[0.2 0.6])
     11%activate('uvmat',[],'movie_pair',[],1)
     12%activate('uvmat',[],'STOP',[],1)
     13activate('uvmat',[],'i1',[],'2')
  • trunk/src/mouse_down.m

    r625 r627  
    118118                if isfield(FigData,tagaxes)
    119119                    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
    122123                        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});
    126128                                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
    127129                                    (Y<(xy(1,2)+Field.CoordMesh/4) & Y>(xy(1,2)-Field.CoordMesh/4));%f
     
    129131                            end
    130132                        end
     133                    end
    131134                    end
    132135                end
     
    173176end
    174177
    175 %% delete the current zoom rectangle
    176 % if isfield(AxeData,'CurrentRectZoom') && ~isempty(AxeData.CurrentRectZoom) && ishandle(AxeData.CurrentRectZoom)
    177 %     delete(AxeData.CurrentRectZoom)
    178 %     AxeData.CurrentRectZoom=[];
    179 % end
    180 
    181178%% zoom has first priority, stop here
    182179if CheckZoom
    183180    return
     181end
     182
     183%% Creation of a display window zoom of text_display
     184if 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
    184196end
    185197
     
    380392    set(AxeData.CurrentObject,'UserData',PlotData); %record the object index in the graph (memory used for mouse motion)
    381393    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
    401395    %show object coordinates in the GUI set_object
    402396    h_set_object=findobj(allchild(0),'Tag','set_object');
     
    475469    if ~isfield(Field,'FF')
    476470        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}];
    478472        nbvar=length(Field.ListVarName);
    479473        Field.VarAttribute{nbvar}.Role='errorflag';
  • trunk/src/mouse_motion.m

    r625 r627  
    3939hPlotAxes=hhCurrentFig.PlotAxes';% handles of the main plot axes
    4040AxeData=get(hPlotAxes,'UserData');% data attached to the axis
     41htext_display(1)=handles.text_display;
     42if isfield(AxeData,'htext_display')&&ishandle(AxeData.htext_display)
     43    htext_display(2)=AxeData.htext_display;
     44end
    4145test_draw=0;%test for mouse drawing of object, =0 by default
    4246if isfield(AxeData,'Drawing')&& ~isempty(AxeData.Drawing)
     
    288292        text_displ(ind_blank)=[];
    289293    end
    290     set(handles.text_display,'String',text_displ)
     294    %set(handles.text_display,'String',text_displ)
     295    set(htext_display,'String',text_displ)
    291296else
    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'))
    293299end
    294300
  • trunk/src/mouse_up.m

    r625 r627  
    172172            set(hhuvmat.edit_object,'Value',1);%           
    173173            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');%
    176176            set(get(h_set_object,'children'),'Enable','on')
    177177        end
     
    376376end
    377377
    378 %% display the data of the current object selected with the mouse right click
    379 if isequal(get(hcurrentfig,'SelectionType'),'alt') && ~CheckZoom && (~isfield(AxeData,'Drawing')||~isequal(AxeData.Drawing,'create'))
    380     hother=findobj('Tag','proj_object');%find all the proj objects
    381     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 default
    385         nbselect=nbselect+iselect;
    386     end
    387     hother=findobj('Tag','proj_object','Type','line');%find all the proj objects
    388     set(hother,'Color','b');%reset all the proj objects in 'blue' by default
    389     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 image
    397     else
    398         currentobj=gco;%default
    399     end
    400 %     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 workspace
    406 %         objtype=get(currentobj,'Type');
    407 %         display(['UserData of ' objtype ':'])
    408 %         evalin('base',['Data_' figname]) %display CurData in the workspace
    409 %         commandwindow %brings the Matlab command window to the front
    410 %     end
    411 end
    412378
    413379%% update
  • trunk/src/set_object.m

    r625 r627  
    579579
    580580%% update the GUI uvmat
    581 set(hhuvmat.MenuEditObject,'enable','on')
     581% set(hhuvmat.MenuEditObject,'enable','on')
    582582set(hhuvmat.edit_object,'Value',1) % set uvmat to object edit mode to allow further object update
    583583%set(hhuvmat.edit_object,'BackgroundColor',[1 1 0]);% paint the edit text in yellow
  • trunk/src/uvmat.m

    r625 r627  
    25512551        UvData.ProjObject{1}.Type='plane';%main plotting plane
    25522552        UvData.ProjObject{1}.ProjMode='projection';%main plotting plane
    2553         UvData.ProjObject{1}.Coord=[0 0 0];
     2553       % UvData.ProjObject{1}.Coord=[0 0 0];
    25542554        UvData.ProjObject{1}.DisplayHandle.uvmat=[]; %plane not visible in uvmat
    25552555        UvData.ProjObject{1}.DisplayHandle.view_field=[]; %plane not visible in uvmat
     
    26192619        end
    26202620    end
    2621     %write_plot_param(handles,PlotParamOut) %update the auto plot parameters
    26222621   
    26232622%% 2D or 3D fieldname are generally projected
     
    29452944     return
    29462945end
    2947 test_civ2=isequal(get(handles.civ2,'BackgroundColor'),[1 1 0]);
    2948 test_civ1=isequal(get(handles.VelType,'BackgroundColor'),[1 1 0]);
     2946MenuVelType=get(handles.VelType,'String');
     2947test_civ2=strcmp(MenuVelType{get(handles.VelType,'Value')},'civ2');
     2948test_civ1=strcmp(MenuVelType{get(handles.VelType,'Value')},'civ1');
    29492949if ~test_civ2 && ~test_civ1
    29502950    msgbox_uvmat('ERROR','manual correction only possible for CIV1 or CIV2 velocity fields')
    29512951end
    29522952if test_civ2
    2953     nbname='nb_vectors2';
    2954    flagname='vec2_FixFlag';
    2955    attrname='fix2';
     2953    nbname='nb_vec_2';
     2954   flagname='Civ2_FF';
     2955   CivStage=5;
    29562956end
    29572957if test_civ1
    2958     nbname='nb_vectors';
    2959    flagname='vec_FixFlag';
    2960    attrname='fix';
     2958    nbname='nb_vec_1';
     2959   flagname='Civ1_FF';
     2960    CivStage=2;
    29612961end
    29622962%write fix flags in the netcdf file
    29632963UvData=get(handles.uvmat,'UserData');
    29642964hhh=which('netcdf.open');% look for built-in matlab netcdf library
    2965 if ~isequal(hhh,'')% case of new builtin Matlab netcdf library
     2965if ~isequal(hhh,'')% case of builtin Matlab netcdf library
    29662966    nc=netcdf.open(FileName,'NC_WRITE');
    29672967    netcdf.reDef(nc);
    2968     netcdf.putAtt(nc,netcdf.getConstant('NC_GLOBAL'),attrname,1);
     2968    netcdf.putAtt(nc,netcdf.getConstant('NC_GLOBAL'),'CivStage',CivStage);
    29692969    dimid = netcdf.inqDimID(nc,nbname);
    29702970    try
     
    37283728if ~strcmp(CoordUnit,CoordUnitPrev)
    37293729    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])
    37313731    hother=findobj('Tag','proj_object');%find all the proj objects
    37323732    for iobj=1:length(hother)
     
    37773777%------------------------------------------------------------------------
    37783778set(handles.CheckFixLimits,'Value',1) %suppress auto mode
    3779 set(handles.CheckFixLimits,'BackgroundColor',[1 1 0])
     3779% set(handles.CheckFixLimits,'BackgroundColor',[1 1 0])
    37803780update_plot(handles);
    37813781
     
    37843784%------------------------------------------------------------------------
    37853785set(handles.CheckFixLimits,'Value',1) %suppress auto mode
    3786 set(handles.CheckFixLimits,'BackgroundColor',[1 1 0])
     3786% set(handles.CheckFixLimits,'BackgroundColor',[1 1 0])
    37873787update_plot(handles);
    37883788
     
    37913791%------------------------------------------
    37923792set(handles.CheckFixLimits,'Value',1) %suppress auto mode
    3793 set(handles.CheckFixLimits,'BackgroundColor',[1 1 0])
     3793% set(handles.CheckFixLimits,'BackgroundColor',[1 1 0])
    37943794update_plot(handles);
    37953795
     
    37983798%------------------------------------------------------------------------
    37993799set(handles.CheckFixLimits,'Value',1) %suppress auto mode
    3800 set(handles.CheckFixLimits,'BackgroundColor',[1 1 0])
     3800% set(handles.CheckFixLimits,'BackgroundColor',[1 1 0])
    38013801update_plot(handles);
    38023802
     
    38083808%------------------------------------------
    38093809set(handles.CheckFixScalar,'Value',1) %suppress auto mode
    3810 set(handles.CheckFixScalar,'BackgroundColor',[1 1 0])
     3810% set(handles.CheckFixScalar,'BackgroundColor',[1 1 0])
    38113811MinA=str2double(get(handles.num_MinA,'String'));
    38123812MaxA=str2double(get(handles.num_MaxA,'String'));
     
    38243824%------------------------------------------------------------------------
    38253825set(handles.CheckFixScalar,'Value',1) %suppress auto mode
    3826 set(handles.CheckFixScalar,'BackgroundColor',[1 1 0])
     3826% set(handles.CheckFixScalar,'BackgroundColor',[1 1 0])
    38273827MinA=str2double(get(handles.num_MinA,'String'));
    38283828MaxA=str2double(get(handles.num_MaxA,'String'));
     
    38413841test=get(handles.CheckFixScalar,'Value');
    38423842if test
    3843     set(handles.CheckFixScalar,'BackgroundColor',[1 1 0])
     3843%     set(handles.CheckFixScalar,'BackgroundColor',[1 1 0])
    38443844else
    3845     set(handles.CheckFixScalar,'BackgroundColor',[0.7 0.7 0.7])
     3845%     set(handles.CheckFixScalar,'BackgroundColor',[0.7 0.7 0.7])
    38463846    update_plot(handles);
    38473847end
     
    39013901test=get(handles.CheckFixVectors,'Value');
    39023902if test
    3903     set(handles.CheckFixVectors,'BackgroundColor',[1 1 0])
     3903%     set(handles.CheckFixVectors,'BackgroundColor',[1 1 0])
    39043904else
    39053905    update_plot(handles);
    39063906    %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])
    39083908end
    39093909
     
    48534853
    48544854
    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)
     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)
    48704870
    48714871%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
     
    50465046    set(handles.ListObject,'Value',val);
    50475047    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
    50485052    npx=size(UvData.Field.A,2);
    50495053    npy=size(UvData.Field.A,1);
     
    53745378    end
    53755379end
    5376 
    5377 
Note: See TracChangeset for help on using the changeset viewer.