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/plot_object.m

    r307 r379  
    99%
    1010% ObjectDataIn: structure representing the object properties:
    11 %        .Style : style of projection object
     11%        .Type : style of projection object
    1212%        .Coord: set of coordinates defining the object position;
    1313%        .ProjMode=type of projection ;
     
    3939%% default output
    4040hh=[];%default output
    41 if ~isfield(ObjectDataIn,'Style')|| isequal(ProjObject,ObjectDataIn)% object representation does not appear in its own projection plot
     41if ~isfield(ObjectDataIn,'Type')|| isequal(ProjObject,ObjectDataIn)% object representation does not appear in its own projection plot
    4242    return
    4343end
    44 if ~isfield(ProjObject,'Style')
     44if ~isfield(ProjObject,'Type')
    4545    ObjectData=ObjectDataIn;
    46 elseif isequal(ProjObject.Style,'plane')
     46elseif isequal(ProjObject.Type,'plane')
    4747    ObjectData=ObjectDataIn;% TODO: modify take into account rotation of axis
    4848else
    4949    return % object representation only  available in a plane
    5050end
    51 if ~isfield(ObjectData,'Style')||isempty(ObjectData.Style)||~ischar(ObjectData.Style)
    52     msgbox_uvmat('ERROR','undefined ObjectData.Style in plot_object.m')
     51if ~isfield(ObjectData,'Type')||isempty(ObjectData.Type)||~ischar(ObjectData.Type)
     52    msgbox_uvmat('ERROR','undefined ObjectData.Type in plot_object.m')
    5353    return
    5454end
    55 if ~isfield(ObjectData,'Style')||isempty(ObjectData.Style)||~ischar(ObjectData.Style)
    56     msgbox_uvmat('ERROR','undefined ObjectData.Style in plot_object.m')
     55if ~isfield(ObjectData,'Type')||isempty(ObjectData.Type)||~ischar(ObjectData.Type)
     56    msgbox_uvmat('ERROR','undefined ObjectData.Type in plot_object.m')
    5757    return
    5858end
     
    103103     ObjectData.Coord=[0 0 0];%default
    104104end
    105 if ~isfield(ObjectData,'Phi')||isempty(ObjectData.Phi)
    106      ObjectData.Phi=0;%default
    107 end
    108 if ~isfield(ObjectData,'Range')
    109     ObjectData.Range(1,1)=0; %edfault
    110 end
    111 if size(ObjectData.Range,2)>=2
    112     YMax=ObjectData.Range(1,2);%default
    113 end
    114 if size(ObjectData.Range,2)>=2 & size(ObjectData.Range,1)>=2
    115     YMin=ObjectData.Range(2,2);
    116 else
    117     YMin=0;
    118 end
    119 XMax=ObjectData.Range(1,1);
    120 if size(ObjectData.Range,1)>=2
    121     XMin=ObjectData.Range(2,1);
    122 end
    123 if isfield(ObjectData,'RangeX')
    124    XMax=max(ObjectData.RangeX);
    125    XMin=min(ObjectData.RangeX);
    126 end
    127 if isfield(ObjectData,'RangeY')
    128    YMax=max(ObjectData.RangeY);
    129    YMin=min(ObjectData.RangeY);
    130 end
    131 if isfield(ObjectData,'RangeZ')
    132    ZMax=max(ObjectData.RangeZ);
    133    ZMin=min(ObjectData.RangeZ);
    134 end
    135 if isequal(ObjectData.Style,'points')&isequal(ObjectData.ProjMode,'projection')
    136     YMax=max(XMax,YMax);
    137     YMax=max(YMax,ZMax);
    138 elseif isequal(ObjectData.Style,'rectangle')||isequal(ObjectData.Style,'ellipse')||isequal(ObjectData.Style,'volume')
    139     if  isequal(YMax,0)
    140         ylim=get(haxes,'YLim');
    141         YMax=(ylim(2)-ylim(1))/100;
    142     end
    143     if isequal(XMax,0)
    144         XMax=YMax;%default
    145     end
    146 elseif isequal(ObjectData.Style,'plane')
    147    if  isequal(XMax,0)
    148         xlim=get(haxes,'XLim');
    149         XMax=xlim(2);
    150    end
    151    if  isequal(YMax,0)
    152         ylim=get(haxes,'YLim');
    153         YMax=ylim(2);
    154    end
     105% if ~isfield(ObjectData,'Phi')||isempty(ObjectData.Phi)
     106%      ObjectData.Phi=0;%default
     107% end
     108% if ~isfield(ObjectData,'Range')
     109%     ObjectData.Range(1,1)=0; %edfault
     110% end
     111% if size(ObjectData.Range,2)>=2
     112%     YMax=ObjectData.Range(1,2);%default
     113% end
     114% if size(ObjectData.Range,2)>=2 & size(ObjectData.Range,1)>=2
     115%     YMin=ObjectData.Range(2,2);
     116% else
     117%     YMin=0;
     118% end
     119if isfield(ObjectData,'RangeX') && ~isempty(ObjectData.RangeX)
     120    XMax=max(ObjectData.RangeX);
     121    XMin=min(ObjectData.RangeX);
     122end
     123if isfield(ObjectData,'RangeY')&&~isempty(ObjectData.RangeY)
     124    YMax=max(ObjectData.RangeY);
     125    YMin=min(ObjectData.RangeY);
     126end
     127if isfield(ObjectData,'RangeZ')&&~isempty(ObjectData.RangeZ)
     128    ZMax=max(ObjectData.RangeZ);
     129    ZMin=min(ObjectData.RangeZ);
     130end
     131switch ObjectData.Type
     132    case 'points'
     133        if strcmp(ObjectData.ProjMode,'projection')
     134            YMax=max(XMax,YMax);
     135            YMax=max(YMax,ZMax);
     136        end
     137    case {'rectangle','ellipse','volume'}
     138        if  isequal(YMax,0)
     139            ylim=get(haxes,'YLim');
     140            YMax=(ylim(2)-ylim(1))/100;
     141        end
     142        if isequal(XMax,0)
     143            XMax=YMax;%default
     144        end
     145    case 'plane'
     146        if  isequal(XMax,0)
     147            xlim=get(haxes,'XLim');
     148            XMax=xlim(2);
     149        end
     150        if  isequal(YMax,0)
     151            ylim=get(haxes,'YLim');
     152            YMax=ylim(2);
     153        end
    155154end
    156155sizcoord=size(ObjectData.Coord);
    157156
    158157%% determine the coordinates xline, yline,xsup,xinf, yinf,ysup determining the new object plot
    159 test_line= isequal(ObjectData.Style,'points')|isequal(ObjectData.Style,'line')|isequal(ObjectData.Style,'polyline')|...
    160     isequal(ObjectData.Style,'polygon')| isequal(ObjectData.Style,'plane')| isequal(ObjectData.Style,'volume');
    161 test_patch=isequal(ObjectData.ProjMode,'inside')||isequal(ObjectData.ProjMode,'outside')||isequal(ObjectData.Style,'volume')...
     158test_line= isequal(ObjectData.Type,'points')|isequal(ObjectData.Type,'line')|isequal(ObjectData.Type,'polyline')|...
     159    isequal(ObjectData.Type,'polygon')| isequal(ObjectData.Type,'plane')| isequal(ObjectData.Type,'volume');
     160test_patch=isequal(ObjectData.ProjMode,'inside')||isequal(ObjectData.ProjMode,'outside')||isequal(ObjectData.Type,'volume')...
    162161    ||isequal(ObjectData.ProjMode,'mask_inside')||isequal(ObjectData.ProjMode,'mask_outside');
    163162if test_line
     
    165164    yline=ObjectData.Coord(:,2);
    166165    nbpoints=numel(xline);
    167     if isequal(ObjectData.Style,'polygon')
     166    if isequal(ObjectData.Type,'polygon')
    168167        xline=[xline; ObjectData.Coord(1,1)];%closing the line
    169168        yline=[yline; ObjectData.Coord(1,2)];
    170     elseif isequal(ObjectData.Style,'plane')|| isequal(ObjectData.Style,'volume')
     169    elseif isequal(ObjectData.Type,'plane')|| isequal(ObjectData.Type,'volume')
    171170        phi=ObjectData.Phi*pi/180;%angle in radians
    172171        Xend_x=xline(1)+XMax*cos(phi);
     
    195194        end
    196195    end
    197     if isequal(ObjectData.Style,'line')||isequal(ObjectData.Style,'polyline')||isequal(ObjectData.Style,'polygon')
     196    if isequal(ObjectData.Type,'line')||isequal(ObjectData.Type,'polyline')||isequal(ObjectData.Type,'polygon')
    198197        if length(xline)<2
    199198            theta=0;
     
    220219    npMy=512; 
    221220    flag=zeros(npMy,npMx);
    222     if isequal(ObjectData.Style,'ellipse')
     221    if isequal(ObjectData.Type,'ellipse')
    223222        XimaMin=ObjectData.Coord(1,1)-XMax;
    224223        XimaMax=ObjectData.Coord(1,1)+XMax;
     
    237236        distY=(Yi-ObjectData.Coord(1,2));
    238237        flag=(distX.*distX/X2Max+distY.*distY/Y2Max)<1;
    239     elseif isequal(ObjectData.Style,'rectangle')||isequal(ObjectData.Style,'volume')
     238    elseif isequal(ObjectData.Type,'rectangle')||isequal(ObjectData.Type,'volume')
    240239        XimaMin=ObjectData.Coord(1,1)-XMax;
    241240        XimaMax=ObjectData.Coord(1,1)+XMax;
     
    252251        distY=abs(Yi-ObjectData.Coord(1,2));
    253252        flag=distX<XMax & distY< YMax;
    254     elseif isequal(ObjectData.Style,'polygon')
     253    elseif isequal(ObjectData.Type,'polygon')
    255254        XimaMin=min(ObjectData.Coord(:,1));
    256255        XimaMax=max(ObjectData.Coord(:,1));
     
    286285    %modify subobjects
    287286        if isfield(PlotData,'SubObject')
    288            if length(PlotData.SubObject)==2 && ~isequal(ObjectData.Style,'points')&& ~isequal(ObjectData.Style,'plane');
     287           if length(PlotData.SubObject)==2 && ~isequal(ObjectData.Type,'points')&& ~isequal(ObjectData.Type,'plane');
    289288                set(PlotData.SubObject(1),'XData',xinf);
    290289                set(PlotData.SubObject(1),'YData',yinf);
    291290                set(PlotData.SubObject(2),'XData',xsup);
    292291                set(PlotData.SubObject(2),'YData',ysup);
    293            elseif isequal(ObjectData.Style,'points')&& ~isequal(YMax,0)
     292           elseif isequal(ObjectData.Type,'points')&& ~isequal(YMax,0)
    294293               for ipt=1:min(length(PlotData.SubObject),size(ObjectData.Coord,1))
    295294                    set(PlotData.SubObject(ipt),'Position',[ObjectData.Coord(ipt,1)-YMax ObjectData.Coord(ipt,2)-YMax 2*YMax 2*YMax])
     
    321320           end
    322321        end
    323     elseif isequal(ObjectData.Style,'rectangle')||isequal(ObjectData.Style,'ellipse')
     322    elseif isequal(ObjectData.Type,'rectangle')||isequal(ObjectData.Type,'ellipse')
    324323        set(hplot,'Position',[ObjectData.Coord(1,1)-XMax ObjectData.Coord(1,2)-YMax 2*XMax 2*YMax])         
    325324    end
     
    358357    set(hother,'Color','b');
    359358    set(hother,'Selected','off') 
    360     if isequal(ObjectData.Style,'points')
     359    if isequal(ObjectData.Type,'points')
    361360        hh=line(ObjectData.Coord(:,1),ObjectData.Coord(:,2),'Color',col,'LineStyle','.','Marker','+');
    362361        for ipt=1:length(xline)
     
    370369              end
    371370        end
    372     elseif  strcmp(ObjectData.Style,'line')||strcmp(ObjectData.Style,'polyline')||...       
    373           strcmp(ObjectData.Style,'polygon') ||strcmp(ObjectData.Style,'plane')||strcmp(ObjectData.Style,'volume')%  (isequal(ObjectData.Style,'polygon') & ~test_patch) |isequal(ObjectData.Style,'plane')
     371    elseif  strcmp(ObjectData.Type,'line')||strcmp(ObjectData.Type,'polyline')||...       
     372          strcmp(ObjectData.Type,'polygon') ||strcmp(ObjectData.Type,'plane')||strcmp(ObjectData.Type,'volume')%  (isequal(ObjectData.Type,'polygon') & ~test_patch) |isequal(ObjectData.Type,'plane')
    374373        hh=line(xline,yline,'Color',col);
    375         if ~strcmp(ObjectData.Style,'plane') && ~strcmp(ObjectData.Style,'volume')
     374        if ~strcmp(ObjectData.Type,'plane') && ~strcmp(ObjectData.Type,'volume')
    376375            PlotData.SubObject(1)=line(xinf,yinf,'Color',col,'LineStyle',SubLineStyle,'Tag','proj_object');%draw sub-lines
    377376            PlotData.SubObject(2)=line(xsup,ysup,'Color',col,'LineStyle',SubLineStyle,'Tag','proj_object');
     
    382381        end
    383382   
    384     elseif strcmp(ObjectData.Style,'rectangle')
     383    elseif strcmp(ObjectData.Type,'rectangle')
    385384        hh=rectangle('Position',[ObjectData.Coord(1,1)-XMax ObjectData.Coord(1,2)-YMax 2*XMax 2*YMax],'EdgeColor',col);   
    386     elseif strcmp(ObjectData.Style,'ellipse')
     385    elseif strcmp(ObjectData.Type,'ellipse')
    387386        hh=rectangle('Curvature',[1 1],'Position',[ObjectData.Coord(1,1)-XMax ObjectData.Coord(1,2)-YMax 2*XMax 2*YMax],'EdgeColor',col);
    388387    else
    389         msgbox_uvmat('ERROR','unknown ObjectData.Style in plot_object.m')
     388        msgbox_uvmat('ERROR','unknown ObjectData.Type in plot_object.m')
    390389        return
    391390    end
Note: See TracChangeset for help on using the changeset viewer.