Ignore:
Timestamp:
Mar 29, 2010, 6:34:55 PM (11 years ago)
Author:
sommeria
Message:

civ3D updated: introduction of image size
imadoc2struct: reding of image size from the xml file
set_object, view_field and related functions: improvement of projection object editing
mouse: possibility of adjusting the calibrations points with the mouse

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/mouse_motion.m

    r67 r71  
    2727    return
    2828end
     29test_draw=0;
    2930test_create=0;%default
    30 test_edit=0;%default
    31 test_edit=isfield(handles,'edit') & get(handles.edit,'Value');% edit test for mouse shap: an arrow
    32 test_zoom=isfield(handles,'zoom')& get(handles.zoom,'Value');% edit test for mouse shap: an arrow
     31test_object=0; %default
     32test_edit=isfield(handles,'edit') && get(handles.edit,'Value');% edit test for mouse shap: an arrow
     33test_zoom_draw=0; %default
     34test_ruler=0;
     35huvmat=findobj(allchild(0),'Name','uvmat');%find the uvmat interface handle
     36if ~isempty(huvmat)
     37    UvData=get(huvmat,'UserData');
     38    test_ruler=isfield(UvData,'MouseAction') && isequal(UvData.MouseAction,'ruler');
     39end
     40
    3341
    3442%find the current axe 'haxes' and display the current mouse position or uicontrol tag
     
    3846text_displ_4='';
    3947
    40 haxes=[];
    4148AxeData=[];%default
    4249mouse=[];
     
    4451
    4552pointershape='arrow';% default pointer is an arrow
    46 currentfig=gcbo;%store gcbo as variable currentfig
     53currentfig=hObject;
    4754xy_fig=get(currentfig,'CurrentPoint');% current point of the current figure (gcbo)
    4855hchild=get(currentfig,'Children');%handles of all objects in the current figure
    4956
    50 % loop on all the objects in the current figure (selected by the last mouse click)
     57% loop on all the objects in the current figure and detect whether the mouse is over a plot  axes
     58haxes=[];
    5159for ichild=1:length(hchild)
    5260    obj_pos=get(hchild(ichild),'Position');%position of the object
     
    6876            ivec=[];
    6977            AxeData=get(haxes,'UserData');% data attached to the axis
    70              if ~test_edit && ~test_zoom
     78            if isfield(AxeData,'Drawing')&& ~isempty(AxeData.Drawing)
     79                test_draw=~isequal(AxeData.Drawing,'off');
     80            end
     81            test_zoom_draw=test_draw && isequal(AxeData.Drawing,'zoom')&& isfield(AxeData,'CurrentOrigin') && isequal(get(gcf,'SelectionType'),'normal');
     82            test_object=test_draw && isfield(AxeData,'CurrentObject') && ~isempty(AxeData.CurrentObject) && ishandle(AxeData.CurrentObject);       
     83             if ~test_edit && ~test_zoom_draw && ~test_ruler
    7184                 pointershape='crosshair';%set pointer with cross shape (default when mouse is over an axis)
    72 %                % pointershape='crosshair';%set pointer with cross shape (default over axis)
    7385             end
    7486            if isfield(AxeData,'X') && isfield(AxeData,'Y') && isfield(AxeData,'Mesh')% test on the existence of a vector field in the current axis
     
    7890                    ivec=find(flag_vec,1);% search the (first) selected vector index ivec
    7991                    hhh=findobj(haxes,'Tag','vector_marker');
    80                     if ~isempty(ivec)
    81                         %ivec=ivec(1);%choice the first selected vector if several are selected
    82                         if ~test_create
    83                             pointershape='arrow'; %mouse indicates  the detection of a vector
    84                             if isempty(hhh)
    85                                 set(currentfig,'CurrentAxes',haxes)
    86                                 rectangle('Curvature',[1 1],...
    87                   'Position',[AxeData.X(ivec)-AxeData.Mesh AxeData.Y(ivec)/2-AxeData.Mesh/2 AxeData.Mesh AxeData.Mesh],'EdgeColor','m',...
    88                   'LineStyle','-','Tag','vector_marker');
    89 %                                 line(AxeData.X(ivec),AxeData.Y(ivec),'Color','m','Tag','vector_marker','LineStyle','.','Marker','o','MarkerSize',AxeData.Mesh);
    90                             else
    91                                 set(hhh,'Position',[AxeData.X(ivec)-AxeData.Mesh/2 AxeData.Y(ivec)-AxeData.Mesh/2 AxeData.Mesh AxeData.Mesh])
     92                    if ~isempty(ivec)
     93                        if ~test_object % mark the vectors with a circle in the absence of other operations
     94                            if  ~test_create && ~test_edit && ~test_ruler
     95                                pointershape='arrow'; %mouse indicates  the detection of a vector
     96                                if isempty(hhh)
     97                                     hstack=findobj(allchild(0),'Type','figure');%current stack order of figures in matlab
     98                                    axes(haxes)
     99                                    rectangle('Curvature',[1 1],...
     100                      'Position',[AxeData.X(ivec)-AxeData.Mesh/2 AxeData.Y(ivec)-AxeData.Mesh/2 AxeData.Mesh AxeData.Mesh],'EdgeColor','m',...
     101                      'LineStyle','-','Tag','vector_marker');
     102                                    set(0,'Children',hstack);%put back the initial figure stack after plot creation
     103                                else
     104                                    set(hhh,'Position',[AxeData.X(ivec)-AxeData.Mesh/2 AxeData.Y(ivec)-AxeData.Mesh/2 AxeData.Mesh AxeData.Mesh])
     105                                end
    92106                            end
    93                         end                 
     107                        end
    94108                        mouse.X=AxeData.X(ivec);
    95109                        mouse.Y=AxeData.Y(ivec);
     
    193207set(handles.text_display_3,'String',text_displ_3);
    194208set(handles.text_display_4,'String',text_displ_4);
     209if ~test_draw
     210    return
     211end
     212% At this stage  if no drawing  operation is done
     213
     214
     215%%%%%%%%%%%%%
     216%draw a zoom rectangle if no object creation is selected
     217if test_zoom_draw
     218   xy_rect=AxeData.CurrentOrigin;
     219   if ~isempty(xy_rect)
     220        rect(1)=min(xy(1,1),xy_rect(1));%origin rectangle, x coordinate
     221        rect(2)=min(xy(1,2),xy_rect(2));%origin rectangle, y coordinate
     222        rect(3)=abs(xy(1,1)-xy_rect(1));%rectangle width
     223        rect(4)=abs(xy(1,2)-xy_rect(2));%rectangle height
     224        if rect(3)>0 & rect(4)>0
     225            if isfield(AxeData,'CurrentRectZoom')& ishandle(AxeData.CurrentRectZoom)
     226                set(AxeData.CurrentRectZoom,'Position',rect);%update the rectangle position
     227            else
     228                AxeData.CurrentRectZoom=rectangle('Position',rect,'LineStyle',':','Tag','rect_zoom');
     229                set(haxes,'UserData',AxeData)
     230            end
     231        end
     232   end
     233    pointershape='arrow';
     234end
    195235
    196236%%%%%%%%%%%%%%%%%
    197237%create or modify an object
    198 huvmat=findobj(allchild(0),'Name','uvmat');%find the uvmat interface handle
    199 if ~isempty(huvmat)
    200     UvData=get(huvmat,'UserData');
    201 end
    202 if ~isempty(huvmat) & isfield(AxeData,'CurrentObject') & ishandle(AxeData.CurrentObject) & isfield(AxeData,'Drawing') & ~isequal(AxeData.Drawing,'off')
     238
     239if ~isempty(huvmat) && test_object
    203240    PlotData=get(AxeData.CurrentObject,'UserData');
    204241    huvmat=findobj(allchild(0),'Name','uvmat');%find the uvmat interface handle
     
    250287end   
    251288
    252 %%%%%%%%%%%%%
    253 %draw a zoom rectangle if no object creation is selected
    254 if ~isempty(haxes) & isfield(AxeData,'Drawing')& isequal(AxeData.Drawing,'zoom')& isfield(AxeData,'CurrentOrigin')...
    255         & isequal(get(gcf,'SelectionType'),'normal')%
    256    xy_rect=AxeData.CurrentOrigin;
    257    if ~isempty(xy_rect)
    258         rect(1)=min(xy(1,1),xy_rect(1));%origin rectangle, x coordinate
    259         rect(2)=min(xy(1,2),xy_rect(2));%origin rectangle, y coordinate
    260         rect(3)=abs(xy(1,1)-xy_rect(1));%rectangle width
    261         rect(4)=abs(xy(1,2)-xy_rect(2));%rectangle height
    262         if rect(3)>0 & rect(4)>0
    263             if isfield(AxeData,'CurrentRectZoom')& ishandle(AxeData.CurrentRectZoom)
    264                 set(AxeData.CurrentRectZoom,'Position',rect);%update the rectangle position
    265             else
    266                 AxeData.CurrentRectZoom=rectangle('Position',rect,'LineStyle',':','Tag','rect_zoom');
    267                 set(haxes,'UserData',AxeData)
    268             end
    269         end
    270    end
    271 % end
    272 % if test_zoom
    273     pointershape='arrow';
    274 end
    275 
    276289% detect calibration points if the GUI geometry_calib is opened
    277290h_geometry_calib=findobj(allchild(0),'Name','geometry_calib'); %find the geomterty_calib GUI
    278 if ~test_zoom && ~isempty(h_geometry_calib)
     291if ~test_zoom_draw && ~isempty(h_geometry_calib)
    279292    pointershape='crosshair';%default for geometry_calib: ready to create new points
    280293    hh_geometry_calib=guidata(h_geometry_calib);
     
    303316                    hhh=findobj('Tag','calib_marker');%look for handle of point marker (circle)
    304317                    if ~isempty(hhh)
    305                         set(hhh,'XData',XCoord(index_point))
    306                         set(hhh,'YData',YCoord(index_point))
     318                        set(hhh,'Position',[XCoord(index_point)-ind_range/2 YCoord(index_point)-ind_range/2 ind_range ind_range])
     319%                         set(hhh,'XData',XCoord(index_point))
     320%                         set(hhh,'YData',YCoord(index_point))
    307321                    end
    308322                end         
     
    313327
    314328%draw ruler
    315 if ~isempty(huvmat)
    316     UvData=get(huvmat,'UserData');
    317     if isfield(UvData,'MouseAction') && isequal(UvData.MouseAction,'ruler')
     329if test_ruler && isequal(AxeData.Drawing,'ruler')
    318330           if isfield(UvData,'RulerHandle')
    319331               pointershape='crosshair';
     
    322334                set(UvData.RulerHandle,'YData',RulerCoord(:,2));
    323335           end
    324     end
    325336end
    326337set(currentfig,'Pointer',pointershape);
Note: See TracChangeset for help on using the changeset viewer.