Changeset 1080 for trunk/src/mouse_down.m
- Timestamp:
- Apr 17, 2020, 5:58:49 PM (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/mouse_down.m
r1078 r1080 37 37 return % no action if a calculation is running 38 38 end 39 hhCurrentGUI=guidata(hCurrentGUI);% tags of the children of the current GUI 39 hhCurrentGUI=guidata(hCurrentGUI);% tags of the children of the current GUI (uvmat or view_field) 40 40 CheckZoom=0; 41 41 if isfield(hhCurrentGUI,'CheckZoom') && get(hhCurrentGUI.CheckZoom,'Value');%test for zoom action, first priority … … 48 48 49 49 %% determine the currently selected items 50 hcurrentobject=gco;% current object handle (selected by the mouse )50 hcurrentobject=gco;% current object handle (selected by the mouse: it can be a drawn object, a plot axis, ..;) 51 51 CurrentGUI_tag=get(hCurrentGUI,'Tag'); 52 52 obj_tag=get(gco,'Tag');%tag of the currently selected object … … 60 60 test_create=0; 61 61 test_edit_vect=0; 62 huvmat=findobj(allchild(0),'tag','uvmat');%find the uvmat interface handle which controls the option of 62 huvmat=findobj(allchild(0),'tag','uvmat');%find the uvmat interface handle which controls the option of mouse action 63 63 if ~isempty(huvmat) 64 64 hhuvmat=guidata(huvmat);%handles of elements in uvmat 65 UvData=get(huvmat,'UserData'); 65 UvData=get(huvmat,'UserData');% contains the input field as UvData.Field 66 66 test_ruler=isequal(get(hhuvmat.MenuRuler,'checked'),'on');%test for ruler action, second priority; 67 67 test_edit=get(hhuvmat.CheckEditObject,'Value');%&& (isequal(obj_tag,'proj_object')||isequal(obj_tag,'DeformPoint'));%test for object editing, third priority … … 209 209 end 210 210 end 211 212 213 211 if ~strcmp(htype,'axes') 212 currentaxes=get(hObject,'CurrentAxes'); 213 if ~isempty(currentaxes) 214 214 AxeData=get(currentaxes,'UserData');% data attached to the axis 215 215 AxeData.Enable='off';% desactivate current axes for mouse up action 216 216 set(currentaxes,'UserData',AxeData); 217 218 217 end 218 end 219 219 220 220 %% zoom has first priority, stop here … … 380 380 end 381 381 382 %% create projection object 382 %% create projection object within the GUI uvmat 383 383 if test_create && ~isempty(xy) && ~strcmp(get(hCurrentGUI,'SelectionType'),'alt') 384 384 % activate this option if the GUI set_object is opened … … 417 417 if isempty(ObjectData.Coord)||(isfield(ObjectData,'RangeX') && size(ObjectData.RangeX,2)==2)% draw a new plane 418 418 ObjectData.Coord=xy(1,1:2);% record the coordinates marked by the mouse as origin of the new plane 419 420 if isfield(FigData,'PlotAxes') 421 Field=FigData.PlotAxes;% field represented on the plot (already projected) 422 if isfield(Field,'ProjObjectType') && strcmp(Field.ProjObjectType,'plane') && isfield(Field,'ProjObjectCoord') && length(Field.ProjObjectCoord)>=3 423 zpos=Field.ProjObjectCoord(1,3); 424 if isfield(Field,'ProjObjectAngle')&&~isequal(Field.ProjObjectAngle,[0 0 0]) 425 norm_plane=rotate_vector(Field.ProjObjectAngle,0,0,1);%angle2normal(Field.ProjObjectAngle); 426 zpos=zpos-(norm_plane(1)*(xy(1,1)-Field.ProjObjectCoord(1))+norm_plane(2)*(xy(1,2)-Field.ProjObjectCoord(2)))/norm_plane(3); 427 end 428 ObjectData.Coord(3)=zpos; 429 end 430 end 431 419 432 set(hh_set_object.Coord,'Data',ObjectData.Coord);%append the current mouse cordinates in the GUI set_object 420 433 set(hh_set_object.num_RangeX_2,'String','') … … 422 435 drawing_status='create'; 423 436 else 437 424 438 Delta_x=(xy(1,1)-ObjectData.Coord(1,1));%displacement along x 425 439 Delta_y=(xy(1,2)-ObjectData.Coord(1,2));%displacement along y 426 ObjectData.Angle(1)=(180/pi)*angle(Delta_x+i*Delta_y); 427 ObjectData.Angle(2)=90; 428 ObjectData.RangeX(1)=0; 429 ObjectData.RangeX(2)=abs(Delta_x+i*Delta_y); 430 set(hh_set_object.num_Angle_1,'String',num2str(ObjectData.Angle(1))) 431 set(hh_set_object.num_Angle_2,'String',num2str(ObjectData.Angle(2))) 432 set(hh_set_object.num_RangeX_1,'String',num2str(ObjectData.RangeX(1))) 433 set(hh_set_object.num_RangeX_2,'String',num2str(ObjectData.RangeX(2))) 440 theta=angle(Delta_x+1i*Delta_y); 441 M2=[cos(theta) -sin(theta) 0;sin(theta) cos(theta) 0;0 0 1];% rotation matrix around the vertical axis with angle theta 442 M1=[1 0 0;0 0 -1; 0 1 0]; % rotation matrix around the x axis with angle pi/2 443 Angle=rodrigues(M2*M1); 444 [RangeX,RangeY]=set_plane_bounds(theta,ObjectData.Coord(1,:),UvData.Field); 445 set(hh_set_object.num_Angle_1,'String',num2str(Angle(1))) 446 set(hh_set_object.num_Angle_2,'String',num2str(Angle(2))) 447 set(hh_set_object.num_Angle_3,'String',num2str(Angle(3))) 448 set(hh_set_object.num_RangeX_1,'String',num2str(RangeX(1))) 449 set(hh_set_object.num_RangeX_2,'String',num2str(RangeX(2))) 450 set(hh_set_object.num_RangeY_1,'String',num2str(RangeY(1))) 451 set(hh_set_object.num_RangeY_2,'String',num2str(RangeY(2))) 434 452 drawing_status='off'; 435 453 end … … 439 457 drawing_status='create'; 440 458 end 441 drawing_status='create';459 %drawing_status='create'; 442 460 %TODO replace 0 by z coord for 3D 443 461 hobject=UvData.ProjObject{IndexObj}.DisplayHandle.(CurrentGUI_tag); … … 544 562 set(haxes,'UserData',AxeData); 545 563 564 function [RangeX,RangeY]=set_plane_bounds(theta,OriginCoord,Field) 565 566 iX=[1;0;0]; 567 iY=[0;1;0]; 568 iZ=[0;0;1]; 569 % [iX_proj,iY_proj]=rotate_vector(-PlaneAngle,iX,iY,iZ);%initial coordinates of the new base vector along X and Y 570 maxnX=[]; 571 minnX=[]; 572 Max_vec=[Field.XMax Field.YMax Field.ZMax]; 573 Min_vec=[Field.XMin Field.YMin Field.ZMin]; 574 RangeY=[Field.ZMin Field.ZMax]-OriginCoord(3);% bound on Z become bound on the new z axis at 90 ? 575 iX_proj(1)=cos(theta);%cosine of the angle of the new axis with x 576 iX_proj(2)=sin(theta); 577 OriginCoord(3)=[];% work of the bounds in x, y 578 %bounds from the input field acting on the new X axis 579 ind_bound=find(iX_proj~=0);% dimensions for which the bound acts 580 Max_vec_X=(Max_vec(ind_bound)-OriginCoord(ind_bound))./iX_proj(ind_bound);%Abscissa of upper edge in the new coordinates 581 Min_vec_X=(Min_vec(ind_bound)-OriginCoord(ind_bound))./iX_proj(ind_bound);%Abscissa of lower edge in the new coordinates 582 %lower bound of X 583 RangeX(1)=max(min(Max_vec_X,Min_vec_X)); 584 %upper bound of X 585 RangeX(2)=min(max(Max_vec_X,Min_vec_X));%must be with the field range along each coordinate x,y,z 586 587 588 589 590
Note: See TracChangeset
for help on using the changeset viewer.