Ignore:
Timestamp:
May 25, 2012, 8:59:59 AM (12 years ago)
Author:
sommeria
Message:

system of projection object manipulation with uvmat improved.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/mouse_motion.m

    r413 r432  
    2929end
    3030FigData=get(hObject,'UserData');
    31 
    3231if ishandle(FigData)% case of a zoom plot, the handle of the parent rectangle is stored in UserData, its parent is the plotting axes of the rectangle
    33     currentfig=get(get(FigData,'parent'),'parent');
     32    CurrentFig=get(get(FigData,'parent'),'parent');
    3433else
    35     currentfig=hObject;%usual plot
    36 end
    37 hhcurrentfig=guidata(currentfig);
    38 test_zoom=get(hhcurrentfig.CheckZoom,'Value');%test for zoom activated on the current figure
     34    CurrentFig=hObject;%usual plot
     35end
     36hhCurrentFig=guidata(CurrentFig);%handles of the elements in the GUI containing the current figure (uvmat or view_field)
     37test_zoom=get(hhCurrentFig.CheckZoom,'Value');%test for zoom activated on the current figure
    3938test_draw=0;%test for mouse drawing of object, =0 by default
    4039test_object=0; %test for object editing or creation
     
    4241test_zoom_draw=0; % test for zoom drawing
    4342test_ruler=0;%test for active ruler
    44 % test_piv=0;% test for PIV correlation display
    4543huvmat=findobj(allchild(0),'tag','uvmat');%find the uvmat interface handle
    4644if ~isempty(huvmat)
    47     hhuvmat=guidata(huvmat);
     45    hhuvmat=guidata(huvmat);%handles of the elements in uvma
    4846    test_edit_object=get(hhuvmat.edit_object,'Value');
    4947    test_ruler=isequal(get(hhuvmat.MenuRuler,'checked'),'on');
     
    5957end
    6058
    61 %find the current axe 'haxes' and display the current mouse position or uicontrol tag
     59%find the current axe 'CurrentAxes' and display the current mouse position or uicontrol tag
    6260text_displ_1='';
    6361text_displ_2='';
     
    7472hchild=get(hObject,'Children');%handles of all objects in the current figure
    7573
    76 %% loop on all the objects in the current figure and detect whether the mouse is over a plot  axes
    77 haxes=[];
     74%% loop on all the objects in the current figure, detect whether the mouse is over a plot  axes
     75CurrentAxes=[];
    7876for ichild=1:length(hchild)
    7977    obj_pos=get(hchild(ichild),'Position');
     
    8583        %if the mouse is over an axis, look at the data
    8684        if strcmp(htype,'axes')
    87             haxes=hchild(ichild);
    88             xy=get(haxes,'CurrentPoint');%xy(1,1),xy(1,2): current x,y positions in axes coordinates
    89             AxeData=get(haxes,'UserData');% data attached to the axis
     85            CurrentAxes=hchild(ichild);
     86            xy=get(CurrentAxes,'CurrentPoint');%xy(1,1),xy(1,2): current x,y positions in axes coordinates
     87            AxeData=get(CurrentAxes,'UserData');% data attached to the axis
    9088            if isfield(AxeData,'Drawing')&& ~isempty(AxeData.Drawing)
    9189                test_draw=~isequal(AxeData.Drawing,'off');%=1 if mouse drawing of object is active
     
    9694                pointershape='crosshair';%set pointer with cross shape (default when mouse is over an axis)
    9795            end
    98             FigData=get(currentfig,'UserData');
    99             tagaxes=get(haxes,'tag');
     96            FigData=get(CurrentFig,'UserData');
     97            tagaxes=get(CurrentAxes,'tag');
    10098            if isfield(FigData,tagaxes)
    10199                eval(['Field=FigData.' tagaxes ';'])
     
    117115                                    (Y<(xy(1,2)+Field.Mesh/3) & Y>(xy(1,2)-Field.Mesh/3));%f
    118116                                ivec=find(flag_vec,1);% search the (first) selected vector index ivec
    119                                 hhh=findobj(haxes,'Tag','vector_marker');
     117                                hhh=findobj(CurrentAxes,'Tag','vector_marker');
    120118                                if ~isempty(ivec)
    121119                                    % mark the vectors with a circle in the absence of other operations
     
    123121                                        pointershape='arrow'; %mouse indicates  the detection of a vector
    124122                                        if isempty(hhh)
    125                                             set(0,'CurrentFigure',currentfig)
    126                                             set(currentfig,'CurrentAxes',haxes)
     123                                            set(0,'CurrentFigure',CurrentFig)
     124                                            set(CurrentFig,'CurrentAxes',CurrentAxes)
    127125                                            rectangle('Curvature',[1 1],...
    128126                                                'Position',[X(ivec)-Field.Mesh/2 Y(ivec)-Field.Mesh/2 Field.Mesh Field.Mesh],'EdgeColor','m',...
     
    226224                        shiftx=par.Shiftx;
    227225                        shifty=par.Shifty;     
    228                         hhh=findobj(haxes,'Tag','PIV_box_marker');
    229                         hhhh=findobj(haxes,'Tag','PIV_search_marker');
     226                        hhh=findobj(CurrentAxes,'Tag','PIV_box_marker');
     227                        hhhh=findobj(CurrentAxes,'Tag','PIV_search_marker');
    230228                        if isempty(hhh)
    231                             set(0,'CurrentFigure',currentfig)
    232                             set(currentfig,'CurrentAxes',haxes)
     229                            set(0,'CurrentFigure',CurrentFig)
     230                            set(CurrentFig,'CurrentAxes',CurrentAxes)
    233231                            rectangle('Curvature',[0 0],...
    234232                                'Position',[xround-ibx2 yround-iby2 2*ibx2 2*iby2],'EdgeColor','m',...
     
    264262                                   AxeData.TitleHandle=title(num2str(par.Grid));
    265263                                    colorbar
    266                                     set(haxes,'UserData',AxeData)
     264                                    set(CurrentAxes,'UserData',AxeData)
    267265                                    set(get(AxeData.CurrentCorrImage,'parent'),'YDir','normal')
    268266                                end
     
    301299            else
    302300                AxeData.CurrentRectZoom=rectangle('Position',rect,'LineStyle',':','Tag','rect_zoom');
    303                 set(haxes,'UserData',AxeData)
     301                set(CurrentAxes,'UserData',AxeData)
    304302            end
    305303        end
     
    311309%% create or modify an object
    312310if ~isempty(huvmat) && test_object
     311    UvData=get(huvmat,'UserData');
    313312    PlotData=get(AxeData.CurrentObject,'UserData');
    314     huvmat=findobj(allchild(0),'Name','uvmat');%find the uvmat interface handle
    315     if ~isempty(huvmat)
    316         UvData=get(huvmat,'UserData');
    317         if ~isfield(PlotData,'IndexObj')
    318              return
     313    if ~isfield(PlotData,'IndexObj')
     314        return
     315    end
     316    ObjectData=UvData.Object{PlotData.IndexObj};
     317    ProjObject=[];% object (plane) whose projection is represented on the current axes
     318    if isequal(hObject,huvmat)% if the mouse ifs over the GUI uvmat
     319        ProjObject=UvData.Object{get(hhuvmat.ListObject_1,'Value')};
     320    else
     321        ProjObject=UvData.Object{get(hhuvmat.ListObject,'Value')};
     322    end
     323    XYData=AxeData.CurrentOrigin;
     324    if isequal(AxeData.Drawing,'create') && isfield(AxeData,'CurrentOrigin') && ~isempty(AxeData.CurrentOrigin)
     325        if strcmp(ObjectData.Type,'line')||strcmp(ObjectData.Type,'polyline')||strcmp(ObjectData.Type,'polygon')||strcmp(ObjectData.Type,'points')
     326            ObjectData.Coord=[ObjectData.Coord ;xy(1,1:2)];
     327            % ObjectData.Coord(end,:)=xy(1,:);
     328        elseif strcmp(ObjectData.Type,'rectangle')||strcmp(ObjectData.Type,'ellipse')||strcmp(ObjectData.Type,'volume')
     329            ObjectData.Coord(1,1)=(xy(1,1)+XYData(1))/2;%origin rectangle, x coordinate
     330            ObjectData.Coord(1,2)=(xy(1,2)+XYData(2))/2;
     331            ObjectData.RangeX=abs(xy(1,1)-XYData(1))/2;%rectangle width
     332            ObjectData.RangeY=abs(xy(1,2)-XYData(2))/2;%rectangle height
     333        elseif isequal(ObjectData.Type,'plane') %case of 'plane'
     334            DX=(xy(1,1)-ObjectData.Coord(1,1));
     335            DY=(xy(1,2)-ObjectData.Coord(1,2));
     336            ObjectData.Phi=(angle(DX+i*DY))*180/pi;%rectangle widt
     337            if isfield(ObjectData,'RangeX')
     338                XMax=sqrt(DX*DX+DY*DY);
     339                if XMax>max(ObjectData.RangeX)
     340                    ObjectData.RangeX=[min(ObjectData.RangeX) XMax];
     341                end
     342            end
    319343        end
    320         ObjectData=UvData.Object{PlotData.IndexObj};
    321         XYData=AxeData.CurrentOrigin;
    322         if isequal(AxeData.Drawing,'create') && isfield(AxeData,'CurrentOrigin') && ~isempty(AxeData.CurrentOrigin)
    323            if strcmp(ObjectData.Type,'line')||strcmp(ObjectData.Type,'polyline')||strcmp(ObjectData.Type,'polygon')||strcmp(ObjectData.Type,'points')
    324               ObjectData.Coord=[ObjectData.Coord ;xy(1,1:2)];
    325              % ObjectData.Coord(end,:)=xy(1,:);
    326            elseif strcmp(ObjectData.Type,'rectangle')||strcmp(ObjectData.Type,'ellipse')||strcmp(ObjectData.Type,'volume')
    327               ObjectData.Coord(1,1)=(xy(1,1)+XYData(1))/2;%origin rectangle, x coordinate
    328               ObjectData.Coord(1,2)=(xy(1,2)+XYData(2))/2;
    329               ObjectData.RangeX=abs(xy(1,1)-XYData(1))/2;%rectangle width
    330               ObjectData.RangeY=abs(xy(1,2)-XYData(2))/2;%rectangle height
    331            elseif isequal(ObjectData.Type,'plane') %case of 'plane'
    332                 DX=(xy(1,1)-ObjectData.Coord(1,1));
    333                 DY=(xy(1,2)-ObjectData.Coord(1,2));
    334                 ObjectData.Phi=(angle(DX+i*DY))*180/pi;%rectangle widt
    335                 if isfield(ObjectData,'RangeX')
    336                     XMax=sqrt(DX*DX+DY*DY);
    337                     if XMax>max(ObjectData.RangeX)
    338                         ObjectData.RangeX=[min(ObjectData.RangeX) XMax];
    339                     end
    340                 end
    341            end
    342             plot_object(ObjectData,[],AxeData.CurrentObject,'m');
    343             pointershape='crosshair';
    344         elseif  isequal(AxeData.Drawing,'translate')
    345             DX=xy(1,1)-XYData(1);%translation from initial position
    346             DY=xy(1,2)-XYData(2);
    347             ObjectData.Coord(:,1)=ObjectData.Coord(:,1)+DX;
    348             ObjectData.Coord(:,2)=ObjectData.Coord(:,2)+DY;
    349             plot_object(ObjectData,[],AxeData.CurrentObject,'m');
    350             pointershape='fleur';
    351         elseif  isequal(AxeData.Drawing,'deform')
    352             ind_move=AxeData.CurrentIndex;
    353             ObjectData.Coord(ind_move,1)=xy(1,1);
    354             ObjectData.Coord(ind_move,2)=xy(1,2);
    355             plot_object(ObjectData,[],AxeData.CurrentObject,'m');
    356             pointershape='circle';
    357         end
    358     end
    359 end   
     344        plot_object(ObjectData,ProjObject,AxeData.CurrentObject,'m');
     345        pointershape='crosshair';
     346    elseif  isequal(AxeData.Drawing,'translate')
     347        DX=xy(1,1)-XYData(1);%translation from initial position
     348        DY=xy(1,2)-XYData(2);
     349        ObjectData.Coord(:,1)=ObjectData.Coord(:,1)+DX;
     350        ObjectData.Coord(:,2)=ObjectData.Coord(:,2)+DY;
     351        plot_object(ObjectData,ProjObject,AxeData.CurrentObject,'m');
     352        pointershape='fleur';
     353    elseif  isequal(AxeData.Drawing,'deform')
     354        ind_move=AxeData.CurrentIndex;
     355        ObjectData.Coord(ind_move,1)=xy(1,1);
     356        ObjectData.Coord(ind_move,2)=xy(1,2);
     357        plot_object(ObjectData,ProjObject,AxeData.CurrentObject,'m');
     358        pointershape='circle';
     359    end
     360end
    360361
    361362%% detect calibration points if the GUI geometry_calib is opened
     
    371372            XCoord=(data.Coord(:,4));
    372373            YCoord=(data.Coord(:,5));
    373             xy=get(haxes,'CurrentPoint');%xy(1,1),xy(1,2): current x,y positions in axes coordinates
     374            xy=get(CurrentAxes,'CurrentPoint');%xy(1,1),xy(1,2): current x,y positions in axes coordinates
    374375            if ~isempty(xy)
    375                 xlim=get(haxes,'XLim');
     376                xlim=get(CurrentAxes,'XLim');
    376377                ind_range_x=abs((xlim(2)-xlim(1))/50);
    377                 ylim=get(haxes,'YLim');
     378                ylim=get(CurrentAxes,'YLim');
    378379                ind_range_y=abs((ylim(2)-ylim(1))/50);
    379380                ind_range=sqrt(ind_range_x*ind_range_y);
     
    414415
    415416%% update the mouse pointer
    416 set(currentfig,'Pointer',pointershape);
     417set(CurrentFig,'Pointer',pointershape);
Note: See TracChangeset for help on using the changeset viewer.