Ignore:
Timestamp:
Apr 17, 2020, 5:58:49 PM (4 years ago)
Author:
sommeria
Message:

ima2temperature.m added and various bug repairs

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/mouse_down.m

    r1078 r1080  
    3737    return % no action if a calculation is running
    3838end
    39 hhCurrentGUI=guidata(hCurrentGUI);% tags of the children of the current GUI
     39hhCurrentGUI=guidata(hCurrentGUI);% tags of the children of the current GUI (uvmat or view_field)
    4040CheckZoom=0;
    4141if isfield(hhCurrentGUI,'CheckZoom') && get(hhCurrentGUI.CheckZoom,'Value');%test for zoom action, first priority
     
    4848
    4949%% determine the currently selected items
    50 hcurrentobject=gco;% current object handle (selected by the mouse)
     50hcurrentobject=gco;% current object handle (selected by the mouse: it can be a drawn object, a plot axis, ..;)
    5151CurrentGUI_tag=get(hCurrentGUI,'Tag');
    5252obj_tag=get(gco,'Tag');%tag of the currently selected object
     
    6060test_create=0;
    6161test_edit_vect=0;
    62 huvmat=findobj(allchild(0),'tag','uvmat');%find the uvmat interface handle which controls the option of  mouse action
     62huvmat=findobj(allchild(0),'tag','uvmat');%find the uvmat interface handle which controls the option of mouse action
    6363if ~isempty(huvmat)
    6464    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
    6666    test_ruler=isequal(get(hhuvmat.MenuRuler,'checked'),'on');%test for ruler  action, second priority;
    6767    test_edit=get(hhuvmat.CheckEditObject,'Value');%&& (isequal(obj_tag,'proj_object')||isequal(obj_tag,'DeformPoint'));%test for object editing, third priority
     
    209209    end
    210210end
    211     if ~strcmp(htype,'axes')
    212         currentaxes=get(hObject,'CurrentAxes');
    213         if ~isempty(currentaxes)
     211if ~strcmp(htype,'axes')
     212    currentaxes=get(hObject,'CurrentAxes');
     213    if ~isempty(currentaxes)
    214214        AxeData=get(currentaxes,'UserData');% data attached to the axis
    215215        AxeData.Enable='off';% desactivate current axes for mouse up action
    216216        set(currentaxes,'UserData',AxeData);
    217         end
    218     end
     217    end
     218end
    219219   
    220220%% zoom has first priority, stop here
     
    380380end
    381381
    382 %%  create  projection  object
     382%%  create  projection  object within the GUI uvmat
    383383if  test_create && ~isempty(xy) && ~strcmp(get(hCurrentGUI,'SelectionType'),'alt')
    384384    % activate this option if the GUI set_object is opened
     
    417417        if isempty(ObjectData.Coord)||(isfield(ObjectData,'RangeX') && size(ObjectData.RangeX,2)==2)% draw a new plane
    418418            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           
    419432            set(hh_set_object.Coord,'Data',ObjectData.Coord);%append the current mouse cordinates in the GUI set_object
    420433            set(hh_set_object.num_RangeX_2,'String','')
     
    422435            drawing_status='create';
    423436        else
     437
    424438            Delta_x=(xy(1,1)-ObjectData.Coord(1,1));%displacement along x
    425439            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)))
    434452            drawing_status='off';
    435453        end
     
    439457        drawing_status='create';
    440458    end
    441     drawing_status='create';
     459    %drawing_status='create';
    442460    %TODO replace 0 by z coord for 3D
    443461    hobject=UvData.ProjObject{IndexObj}.DisplayHandle.(CurrentGUI_tag);
     
    544562set(haxes,'UserData',AxeData);
    545563
     564function [RangeX,RangeY]=set_plane_bounds(theta,OriginCoord,Field)   
     565
     566iX=[1;0;0];
     567iY=[0;1;0];
     568iZ=[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
     570maxnX=[];
     571minnX=[];
     572Max_vec=[Field.XMax Field.YMax Field.ZMax];
     573Min_vec=[Field.XMin Field.YMin Field.ZMin];
     574RangeY=[Field.ZMin Field.ZMax]-OriginCoord(3);% bound on Z become bound on the new z axis at 90 ?
     575iX_proj(1)=cos(theta);%cosine of the angle of the new axis with x
     576iX_proj(2)=sin(theta);
     577OriginCoord(3)=[];% work of the bounds in x, y
     578%bounds from the input field acting on the new X axis
     579ind_bound=find(iX_proj~=0);% dimensions for which the bound acts
     580Max_vec_X=(Max_vec(ind_bound)-OriginCoord(ind_bound))./iX_proj(ind_bound);%Abscissa of upper edge in the new coordinates
     581Min_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
     583RangeX(1)=max(min(Max_vec_X,Min_vec_X));
     584%upper bound of X
     585RangeX(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.