Changeset 379 for trunk/src/proj_field.m


Ignore:
Timestamp:
Jan 27, 2012, 1:59:18 AM (12 years ago)
Author:
sommeria
Message:

several bugs corrected
set_object.fig rationalized so that read_set_object is replaced by the rgeneral fct read_GUI.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/proj_field.m

    r372 r379  
    1717%INPUT
    1818% ObjectData: structure characterizing the projection object
    19 %    .Style : style of projection object
    20 %    .ProjMode=type of projection ;
    21 %    .CoordType: 'px' or 'phys' type of coordinates defining the object position
     19%    .Type : type of projection object
     20%    .ProjMode=mode of projection ;
     21%    .CoordUnit: 'px', 'cm' units for the coordinates defining the object
    2222%    .Phi  angle of rotation (=0 by default)
    2323%    .ProjAngle=angle of projection;
     
    8888end
    8989
    90 %% in the absence of object Style or projection mode, or object coordinaes, the input field is just tranfered without change
    91 if ~isfield(ObjectData,'Style')||~isfield(ObjectData,'ProjMode')
     90%% in the absence of object Type or projection mode, or object coordinaes, the input field is just tranfered without change
     91if ~isfield(ObjectData,'Type')||~isfield(ObjectData,'ProjMode')
    9292    ProjData=FieldData;
    9393    return
    9494end
    9595if ~isfield(ObjectData,'Coord')
    96     if strcmp(ObjectData.Style,'plane')
     96    if strcmp(ObjectData.Type,'plane')
    9797        ObjectData.Coord=[0 0 0];%default
    9898    else
     
    124124
    125125%% apply projection depending on the object style
    126 switch ObjectData.Style
     126switch ObjectData.Type
    127127    case 'points'
    128128    [ProjData,errormsg]=proj_points(FieldData,ObjectData);
     
    480480%select the indices in the range of action
    481481    testin=[];%default
    482     if isequal(ObjectData.Style,'rectangle')
     482    if isequal(ObjectData.Type,'rectangle')
    483483%            if ~isfield(ObjectData,'RangeX')|~isfield(ObjectData,'RangeY')
    484484%                 errormsg='rectangle half sides RangeX and RangeY needed'
     
    494494           testin=distX<widthx & distY<widthy;
    495495       end
    496     elseif isequal(ObjectData.Style,'polygon')
     496    elseif isequal(ObjectData.Type,'polygon')
    497497        if testX
    498498            testin=inpolygon(coord_x,coord_y,ObjectData.Coord(:,1),ObjectData.Coord(:,2));
     
    502502           testin=[]; %A REVOIR
    503503       end
    504     elseif isequal(ObjectData.Style,'ellipse')
     504    elseif isequal(ObjectData.Type,'ellipse')
    505505       X2Max=widthx*widthx;
    506506       Y2Max=(widthy)*(widthy);
     
    567567ProjMode='projection';%direct projection on the line by default
    568568if isfield(ObjectData,'ProjMode'),ProjMode=ObjectData.ProjMode; end;
    569 ProjAngle=90; %90 degrees projection by default
    570 if isfield(FieldData,'ProjAngle'),ProjAngle=ObjectData.ProjAngle; end;
     569% ProjAngle=90; %90 degrees projection by default
     570% if isfield(FieldData,'ProjAngle'),ProjAngle=ObjectData.ProjAngle; end;
    571571width=0;%default width of the projection band
    572 if isfield(ObjectData,'Range')&size(ObjectData.Range,2)>=2
     572if isfield(ObjectData,'Range')&&size(ObjectData.Range,2)>=2
    573573    width=abs(ObjectData.Range(1,2));
    574574end
     
    777777    %case of structured coordinates
    778778    elseif  numel(VarType.coord)>=2 & VarType.coord(1:2) > 0;
    779         if ~isequal(ObjectData.Style,'line')% exclude polyline
    780             errormsg=['no  projection available on ' ObjectData.Style 'for structured coordinates']; %
     779        if ~isequal(ObjectData.Type,'line')% exclude polyline
     780            errormsg=['no  projection available on ' ObjectData.Type 'for structured coordinates']; %
    781781        else
    782782            test_Amat=1;%image or 2D matrix
     
    949949testangle=~isequal(PlaneAngle,[0 0 0]);% && ~test90y && ~test90x;%=1 for slanted plane
    950950
    951 % Phi=0;%default
    952 % Theta=0;
    953 % Psi=0;
    954 % if isfield(ObjectData,'Phi')&& ~isempty(ObjectData.Phi)
    955 %     Phi=(pi/180)*ObjectData.Phi;%first Euler angle in radian
    956 % end
    957 % if isfield(ObjectData,'Theta')&& ~isempty(ObjectData.Theta)
    958 %     Theta=(pi/180)*ObjectData.Theta;%second Euler angle in radian
    959 % end
    960 % if isfield(ObjectData,'Psi')&& ~isempty(ObjectData.Psi)
    961 %     Psi=(pi/180)*ObjectData.Psi;%third Euler angle in radian
    962 % end
    963 
    964 %components of the unity vector normal to the projection plane
    965 % NormVec_X=-sin(Phi)*sin(Theta);
    966 % NormVec_Y=cos(Phi)*sin(Theta);
    967 % NormVec_Z=cos(Theta);
    968 
    969951%mesh sizes DX and DY
    970952DX=0;
    971953DY=0; %default
    972 if isfield(ObjectData,'DX')&~isempty(ObjectData.DX)
     954if isfield(ObjectData,'DX') && ~isempty(ObjectData.DX)
    973955     DX=abs(ObjectData.DX);%mesh of interpolation points
    974956end
    975 if isfield(ObjectData,'DY')&~isempty(ObjectData.DY)
     957if isfield(ObjectData,'DY') && ~isempty(ObjectData.DY)
    976958     DY=abs(ObjectData.DY);%mesh of interpolation points
    977959end
     
    21872169%% transfer coordinate unit
    21882170if isfield(FieldData,'CoordUnit')
    2189     if isfield(ObjectData,'CoordUnit')&~isequal(FieldData.CoordUnit,ObjectData.CoordUnit)
    2190         errormsg=[ObjectData.Style ' in ' ObjectData.CoordUnit ' coordinates, while field in ' FieldData.CoordUnit ];
     2171    if isfield(ObjectData,'CoordUnit') && ~strcmp(FieldData.CoordUnit,ObjectData.CoordUnit)
     2172        errormsg=[ObjectData.Type ' in ' ObjectData.CoordUnit ' coordinates, while field in ' FieldData.CoordUnit ];
    21912173        return
    21922174    else
     
    21962178
    21972179%% store the properties of the projection object
    2198 ListObject={'Style','ProjMode','RangeX','RangeY','RangeZ','Phi','Theta','Psi','Coord'};
     2180ListObject={'Type','ProjMode','RangeX','RangeY','RangeZ','Phi','Theta','Psi','Coord'};
    21992181for ilist=1:length(ListObject)
    22002182    if isfield(ObjectData,ListObject{ilist})
Note: See TracChangeset for help on using the changeset viewer.