source: trunk/src/plot_object.m

Last change on this file was 1127, checked in by g7moreau, 3 months ago

Update Joel email

File size: 22.3 KB
RevLine 
[8]1%'plot_object': draws a projection object (points, line, plane...)
2%-------------------------------------------------------------------
[432]3% function hh=plot_object(ObjectData,ProjObject,hplot,col)
[8]4%
5%OUTPUT
6%             hh: handles of the graphic object (core part)
7%
8%INPUT:
9%
[432]10% ObjectData: structure representing the object properties:
[379]11%        .Type : style of projection object
[8]12%        .Coord: set of coordinates defining the object position;
13%        .ProjMode=type of projection ;
14%       .ProjAngle=angle of projection;
15%       .DX,.DY,.DZ=increments;
16%       .YMax,YMin: min and max Y
17% ProjObject: projection object corresponding to the current plot (e. g. plane)
18% hplot: handle of the object plot to modify or if it is an axis, the axis
19%            where the object must be plotted, or if it is a figure the plotting figure
20% col: color of the plot, e;g; 'm', 'b' ..;
21
[809]22%=======================================================================
[1126]23% Copyright 2008-2024, LEGI UMR 5519 / CNRS UGA G-INP, Grenoble, France
[809]24%   http://www.legi.grenoble-inp.fr
[1127]25%   Joel.Sommeria - Joel.Sommeria (A) univ-grenoble-alpes.fr
[809]26%
[8]27%     This file is part of the toolbox UVMAT.
[809]28%
[8]29%     UVMAT is free software; you can redistribute it and/or modify
[809]30%     it under the terms of the GNU General Public License as published
31%     by the Free Software Foundation; either version 2 of the license,
32%     or (at your option) any later version.
33%
[8]34%     UVMAT is distributed in the hope that it will be useful,
35%     but WITHOUT ANY WARRANTY; without even the implied warranty of
36%     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
[809]37%     GNU General Public License (see LICENSE.txt) for more details.
38%=======================================================================
[8]39
[432]40function [hh]=plot_object(ObjectData,ProjObject,hplot,col)
41
[156]42%% default output
[8]43hh=[];%default output
[432]44% object representation is canceled if the field is not projected on a plane or is the same as the represented object
[534]45if ~isfield(ObjectData,'Type')|| isequal(ProjObject,ObjectData)||~isfield(ProjObject,'Type')|| ~strcmp(ProjObject.Type,'plane')
[432]46    if ~isempty(hplot) && ishandle(hplot) && ~strcmp(get(hplot,'Type'),'axes')
47        ObjectPlotData=get(hplot,'UserData');
48        if isfield(ObjectPlotData,'SubObject') & ishandle(ObjectPlotData.SubObject)
49            delete(ObjectPlotData.SubObject);
50        end
51        if isfield(ObjectPlotData,'DeformPoint') & ishandle(ObjectPlotData.DeformPoint)
52            delete(ObjectPlotData.DeformPoint);
53        end
54        delete(hplot)
55    end
56    return
[8]57end
[625]58XMin=0;%default range for the graph
[8]59XMax=0;
60YMin=0;
61YMax=0;
62ZMin=0;
63ZMax=0;
[625]64XMinRange=[];%default range set by input
65XMaxRange=[];
66YMinRange=[];
67YMaxRange=[];
68ZMinRange=[];
69ZMaxRange=[];
[8]70
[156]71%% determine the plotting axes (with handle 'haxes')
[8]72test_newobj=1;
73if ishandle(hplot)
[156]74    if isequal(get(hplot,'Tag'),'proj_object')% hplot is the handle of an object representation 
[8]75        test_newobj=0;
76        haxes=get(hplot,'parent');
[231]77        currentfig=get(haxes,'parent');
[156]78    elseif isequal(get(hplot,'Type'),'axes')% hplot is the handle of an axis
[231]79        haxes=hplot;
[156]80        currentfig=get(hplot,'parent');
81    elseif isequal(get(hplot,'Type'),'figure')% hplot is the handle of a figure
82        set(0,'CurrentFigure',hplot);%set the input figure as the current one
[8]83        haxes=findobj(hplot,'Type','axes');%look for axes in the figure
84        haxes=haxes(1);
[231]85        currentfig=hplot;
[8]86    else
[231]87        currentfig=figure; %create new figure
[8]88        hplot=axes;%create new axes
89        haxes=hplot;
90    end
91else
[231]92    currentfig=figure; %create new figure
[8]93    hplot=axes;%create new axes
94    haxes=hplot;
95end
[231]96set(0,'CurrentFigure',currentfig)%set the currentfigure as the current one
97set(currentfig,'CurrentAxes',haxes);%set the current axes in the current figure
[8]98
[156]99%% default input parameters
[177]100if ~isfield(ObjectData,'ProjMode')||isempty(ObjectData.ProjMode)
[8]101     ObjectData.ProjMode='projection';%default
102end
[177]103if ~isfield(ObjectData,'Coord')||isempty(ObjectData.Coord)
[8]104     ObjectData.Coord=[0 0 0];%default
105end
[379]106if isfield(ObjectData,'RangeX') && ~isempty(ObjectData.RangeX)
107    XMax=max(ObjectData.RangeX);
108    XMin=min(ObjectData.RangeX);
[625]109        XMaxRange=max(ObjectData.RangeX);
110        if numel(ObjectData.RangeX)==2
111    XMinRange=min(ObjectData.RangeX);
112        end
[8]113end
[379]114if isfield(ObjectData,'RangeY')&&~isempty(ObjectData.RangeY)
115    YMax=max(ObjectData.RangeY);
116    YMin=min(ObjectData.RangeY);
[625]117        YMaxRange=max(ObjectData.RangeY);
118        if numel(ObjectData.RangeY)==2
119    YMinRange=min(ObjectData.RangeY);
120        end
[8]121end
[1065]122if isfield(ObjectData,'RangeInterp')&&~isempty(ObjectData.RangeInterp)
123    YMax=ObjectData.RangeInterp;
124end
[379]125if isfield(ObjectData,'RangeZ')&&~isempty(ObjectData.RangeZ)
126    ZMax=max(ObjectData.RangeZ);
127    ZMin=min(ObjectData.RangeZ);
[625]128    ZMaxRange=max(ObjectData.RangeZ);
129    ZMinRange=min(ObjectData.RangeZ);
[8]130end
[625]131if strcmp(ObjectData.Type,'points') && strcmp(ObjectData.ProjMode,'projection')
132    YMax=max(XMax,YMax);
133    YMax=max(YMax,ZMax);
[8]134end
135sizcoord=size(ObjectData.Coord);
136
[156]137%% determine the coordinates xline, yline,xsup,xinf, yinf,ysup determining the new object plot
[954]138test_line=ismember(ObjectData.Type,{'points','line','polyline','polygon','plane','plane_z','volume'});
139test_patch=ismember(ObjectData.ProjMode,{'inside','outside','mask_inside','mask_outside'});
[8]140if test_line
141    xline=ObjectData.Coord(:,1);
142    yline=ObjectData.Coord(:,2);
[177]143    nbpoints=numel(xline);
[954]144    switch ObjectData.Type
145        case 'polygon'
146            xline=[xline; ObjectData.Coord(1,1)];%closing the line
147            yline=[yline; ObjectData.Coord(1,2)];
[1080]148        case {'plane','volume'}
[954]149            if ~isfield(ObjectData,'Angle')
[1080]150                ObjectData.Angle=[0 0 0];
[8]151            end
[1080]152            cosphi=cos(ObjectData.Angle(3)*pi/180);%angle in radians
153            sinphi=sin(ObjectData.Angle(3)*pi/180);%angle in radians
[954]154            x0=xline(1); y0=yline(1);
155            xlim=get(haxes,'XLim');
156            ylim=get(haxes,'YLim');
157            graph_scale=max(abs(xlim(2)-xlim(1)),abs(ylim(2)-ylim(1)))/2;% estimate the length of axes plots
158            XMax=graph_scale;
159            YMax=graph_scale;
160            XMin=-graph_scale;
161            YMin=-graph_scale;
162            if  ~isempty(XMaxRange)
163                XMax=XMaxRange;
[8]164            end
[954]165            if  ~isempty(XMinRange)
166                XMin=XMinRange;
167            end
168            if  ~isempty(YMaxRange)
169                YMax=YMaxRange;
170            end
171            if  ~isempty(YMinRange)
172                YMin=YMinRange;
173            end
174            % axes lines
175            xline=NaN(1,13);
[955]176            xline(1)=x0+min(0,XMin)*cosphi; % min end of the x axes
177            yline(1)=y0+min(0,XMin)*sinphi;
178            xline(2)=x0+XMax*cosphi;% max end of the x axes
179            yline(2)=y0+XMax*sinphi;
180            xline(8)=x0-min(0,YMin)*sinphi;% min end of the y axes
181            yline(8)=y0+min(0,YMin)*cosphi;
182            xline(9)=x0-YMax*sinphi;% max end of the y axes
183            yline(9)=y0+YMax*cosphi;
[954]184           
185            %arrows on x axis
186            arrow_scale=graph_scale/20;
[955]187            phi=acos(cosphi);
[954]188            xline(3)=xline(2)-arrow_scale*cos(phi-pi/8);
189            yline(3)=yline(2)-arrow_scale*sin(phi-pi/8);
190            xline(5)=xline(2);
191            yline(5)=yline(2);
192            xline(6)=xline(2)-arrow_scale*cos(phi+pi/8);
193            yline(6)=yline(2)-arrow_scale*sin(phi+pi/8);
194           
195            %arrows on y axis
196            xline(10)=xline(9)-arrow_scale*cos(phi+pi/2-pi/8);
197            yline(10)=yline(9)-arrow_scale*sin(phi+pi/2-pi/8);
198            xline(12)=xline(9);
199            yline(12)=yline(9);
200            xline(13)=xline(9)-arrow_scale*cos(phi+pi/2+pi/8);
201            yline(13)=yline(9)-arrow_scale*sin(phi+pi/2+pi/8);
202            %xline=[Xbeg_x Xend_x NaN Ybeg_x Yend_x];
203            %yline=[Xbeg_y Xend_y NaN Ybeg_y Yend_y];
204            %  dashed lines indicating bounds
205            xsup=NaN(1,5);
206            ysup=NaN(1,5);
207            if ~isempty(XMaxRange)
208                xsup(1)=xline(2)-YMin*sin(phi);
209                ysup(1)=yline(2)+YMin*cos(phi);
210                xsup(2)=xline(2)-YMax*sin(phi);
211                ysup(2)=yline(2)+YMax*cos(phi);
212            end
213            if ~isempty(YMaxRange)
214                xsup(2)=xline(2)-YMax*sin(phi);
215                ysup(2)=yline(2)+YMax*cos(phi);
216                xsup(3)=xline(9)+XMin*cos(phi);
217                ysup(3)=yline(9)+XMin*sin(phi);
218            end
219            if ~isempty(XMinRange)
220                xsup(3)=xline(9)+XMin*cos(phi);
221                ysup(3)=yline(9)+XMin*sin(phi);
222                xsup(4)=x0+XMin*cos(phi)-YMin*sin(phi);
223                ysup(4)=y0+XMin*sin(phi)+YMin*cos(phi);
224            end
225            if ~isempty(YMinRange)
226                xsup(4)=x0+XMin*cos(phi)-YMin*sin(phi);
227                ysup(4)=y0+XMin*sin(phi)+YMin*cos(phi);
228                xsup(5)=xline(8)-YMin*sin(phi);
229                ysup(5)=yline(8)+YMin*cos(phi);
230            end
231    end
232end
233SubLineStyle='none';%default
234if isfield(ObjectData,'ProjMode')
235    if isequal(ObjectData.ProjMode,'projection')
236        SubLineStyle='--'; %range of projection marked by dash
237        if isfield (ObjectData,'DX')
238            ObjectData=rmfield(ObjectData,'DX');
[8]239        end
[954]240        if isfield (ObjectData,'DY')
241            ObjectData=rmfield(ObjectData,'DY');
[8]242        end
[954]243    elseif isequal(ObjectData.ProjMode,'filter')
244        SubLineStyle=':';%range of projection not visible
[8]245    end
246end
[1099]247if ismember(ObjectData.Type,{'line','polyline','polygon'})&&...
248        ismember(ObjectData.ProjMode,{'projection','interp_lin','interp_tps'})
[954]249    if length(xline)<2
250        theta=0;
251    else
252        theta=angle(diff(xline)+1i*diff(yline));
253        theta(length(xline))=theta(length(xline)-1);
254    end
255    xsup(1)=xline(1)+YMax*sin(theta(1));
256    xinf(1)=xline(1)-YMax*sin(theta(1));
257    ysup(1)=yline(1)-YMax*cos(theta(1));
258    yinf(1)=yline(1)+YMax*cos(theta(1));
259    for ip=2:length(xline)
260        xsup(ip)=xline(ip)+YMax*sin((theta(ip)+theta(ip-1))/2)/cos((theta(ip-1)-theta(ip))/2);
261        xinf(ip)=xline(ip)-YMax*sin((theta(ip)+theta(ip-1))/2)/cos((theta(ip-1)-theta(ip))/2);
262        ysup(ip)=yline(ip)-YMax*cos((theta(ip)+theta(ip-1))/2)/cos((theta(ip-1)-theta(ip))/2);
263        yinf(ip)=yline(ip)+YMax*cos((theta(ip)+theta(ip-1))/2)/cos((theta(ip-1)-theta(ip))/2);
264    end
265end
[8]266
[156]267%% shading image
[8]268if test_patch
269    npMx=512;
270    npMy=512; 
271    flag=zeros(npMy,npMx);
[379]272    if isequal(ObjectData.Type,'ellipse')
[8]273        XimaMin=ObjectData.Coord(1,1)-XMax;
274        XimaMax=ObjectData.Coord(1,1)+XMax;
275        YimaMin=ObjectData.Coord(1,2)-YMax;
276        YimaMax=ObjectData.Coord(1,2)+YMax;
277        xlim=[1.2*XimaMin-0.2*XimaMax 1.2*XimaMax-0.2*XimaMin];%create an image around the ellipse
278        ylim=[1.2*YimaMin-0.2*YimaMax 1.2*YimaMax-0.2*YimaMin];
279        scale_x=2*1.4*XMax/npMx;
280        scale_y=2*1.4*YMax/npMy;
[177]281        xi=(0.5:npMx-0.5)*scale_x+xlim(1);
282        yi=(0.5:npMy-0.5)*scale_y+ylim(1);
[8]283        [Xi,Yi]=meshgrid(xi,yi);
284        X2Max=XMax*XMax;
285        Y2Max=YMax*YMax;
286        distX=(Xi-ObjectData.Coord(1,1));
287        distY=(Yi-ObjectData.Coord(1,2));
288        flag=(distX.*distX/X2Max+distY.*distY/Y2Max)<1;
[379]289    elseif isequal(ObjectData.Type,'rectangle')||isequal(ObjectData.Type,'volume')
[8]290        XimaMin=ObjectData.Coord(1,1)-XMax;
291        XimaMax=ObjectData.Coord(1,1)+XMax;
292        YimaMin=ObjectData.Coord(1,2)-YMax;
293        YimaMax=ObjectData.Coord(1,2)+YMax;
294        xlim=[1.2*XimaMin-0.2*XimaMax 1.2*XimaMax-0.2*XimaMin];%create an image around the ellipse
295        ylim=[1.2*YimaMin-0.2*YimaMax 1.2*YimaMax-0.2*YimaMin];
296        scale_x=2*1.4*XMax/npMx;
297        scale_y=2*1.4*YMax/npMy;
[177]298        xi=(0.5:npMx-0.5)*scale_x+xlim(1);
299        yi=(0.5:npMy-0.5)*scale_y+ylim(1);
[8]300        [Xi,Yi]=meshgrid(xi,yi);
301        distX=abs(Xi-ObjectData.Coord(1,1));
302        distY=abs(Yi-ObjectData.Coord(1,2));
303        flag=distX<XMax & distY< YMax;
[379]304    elseif isequal(ObjectData.Type,'polygon')
[8]305        XimaMin=min(ObjectData.Coord(:,1));
306        XimaMax=max(ObjectData.Coord(:,1));
307        YimaMin=min(ObjectData.Coord(:,2));
308        YimaMax=max(ObjectData.Coord(:,2));
309        xlim=[1.2*XimaMin-0.2*XimaMax 1.2*XimaMax-0.2*XimaMin];
310        ylim=[1.2*YimaMin-0.2*YimaMax 1.2*YimaMax-0.2*YimaMin];
311        [Xlim,Ylim]=meshgrid(linspace(xlim(1),xlim(2),npMx),linspace(ylim(1),ylim(2),npMy));
312        %flag=roipoly(xlim,ylim,flag,ObjectData.Coord(:,1),ObjectData.Coord(:,2));%=1 inside the polygon, 0 outsid
313        flag=inpolygon(Xlim,Ylim,ObjectData.Coord(:,1),ObjectData.Coord(:,2));%=1 inside the polygon, 0 outsid
314    end
315    if isequal(ObjectData.ProjMode,'outside')||isequal(ObjectData.ProjMode,'mask_outside')
316        flag=~flag;
317    end
318    imflag=zeros(npMx,npMy,3);
319    imflag(:,:,3)=flag; % blue color
320    if isequal(col,'m')
321         imflag(:,:,1)=flag; % magenta color
322    end
323    dx=(xlim(2)-xlim(1))/npMx;
324    dy=(ylim(2)-ylim(1))/npMy;
325end
326
327PlotData=[];%default
[177]328
[156]329%% MODIFY AN EXISTING OBJECT PLOT
[1080]330if test_newobj==0
[8]331    hh=hplot;
[625]332    PlotData=get(hplot,'UserData');
[8]333    if test_line
334        set(hplot,'XData',xline)
335        set(hplot,'YData',yline)
[625]336        %modify subobjects
337        if isfield(PlotData,'SubObject')
338            if isequal(ObjectData.Type,'points')
339                if ~isequal(YMax,0)
340                    for ipt=1:min(length(PlotData.SubObject),size(ObjectData.Coord,1))
341                        set(PlotData.SubObject(ipt),'Position',[ObjectData.Coord(ipt,1)-YMax ObjectData.Coord(ipt,2)-YMax 2*YMax 2*YMax])
342                    end
343                    %complement missing points
344                    if length(PlotData.SubObject)>nbpoints% fpoints in excess on the graph
[1098]345                        for ii=nbpoints+1: length(PlotData.SubObject)
[625]346                            if ishandle(PlotData.SubObject(ii))
347                                delete(PlotData.SubObject(ii))
348                            end
349                        end
350                    end
351                    if nbpoints>length(PlotData.SubObject)
352                        for ipt=length(PlotData.SubObject)+1:nbpoints
353                            PlotData.SubObject(ipt)=rectangle('Curvature',[1 1],...
354                                'Position',[ObjectData.Coord(ipt,1)-YMax ObjectData.Coord(ipt,2)-YMax 2*YMax 2*YMax],'EdgeColor',col,...
355                                'LineStyle',SubLineStyle,'Tag','proj_object');
356                        end
357                    end
358                end
359            elseif length(PlotData.SubObject)==2
[1099]360                if ismember(ObjectData.ProjMode,{'projection','interp_lin','interp_tps'})
361                    set(PlotData.SubObject(1),'XData',xinf);
362                    set(PlotData.SubObject(1),'YData',yinf);
363                    set(PlotData.SubObject(2),'XData',xsup);
364                    set(PlotData.SubObject(2),'YData',ysup);
365                end
[625]366            elseif length(PlotData.SubObject)==1
[1099]367                if ismember(ObjectData.ProjMode,{'projection','interp_lin','interp_tps'})
368                    set(PlotData.SubObject(1),'XData',xsup);
369                    set(PlotData.SubObject(1),'YData',ysup);
370                end
[625]371            end
[1099]372            if strcmp(ObjectData.ProjMode,'none')
373                delete(PlotData.SubObject)
374                PlotData=rmfield(PlotData,'SubObject');
375            end
[8]376        end
377        if isfield(PlotData,'DeformPoint')
[622]378            NbDeformPoint=length(PlotData.DeformPoint);
[1098]379            % delete deformpoints in excess on the graph
380            if NbDeformPoint>nbpoints
[1080]381                for ii=nbpoints+1:NbDeformPoint
[625]382                    if ishandle(PlotData.DeformPoint(ii))
[622]383                        delete(PlotData.DeformPoint(ii))
[625]384                    end
385                end
386                NbDeformPoint=nbpoints;
387            end
[1098]388            % update the position of the existing deformpoints
[625]389            for ipt=1:NbDeformPoint
390                if ishandle(PlotData.DeformPoint(ipt))
391                    if nbpoints>=ipt
[8]392                        set(PlotData.DeformPoint(ipt),'XData',xline(ipt),'YData',yline(ipt));
393                    end
[625]394                end
395            end
[1098]396            % add neww deform points if requested
[625]397            if nbpoints>length(PlotData.DeformPoint)
398                for ipt=length(PlotData.DeformPoint)+1:nbpoints
[922]399                    PlotData.DeformPoint(ipt)=line(xline(ipt),yline(ipt),'Color',col,'LineStyle','-','Tag','DeformPoint',...
[1098]400                        'Marker','.','MarkerSize',12,'SelectionHighlight','off','UserData',hplot);
[625]401                end
402                set(hplot,'UserData',PlotData)
403            end
[8]404        end
[622]405    elseif (isequal(ObjectData.Type,'rectangle')||isequal(ObjectData.Type,'ellipse'))&&XMax>0 && YMax>0
[625]406        set(hplot,'Position',[ObjectData.Coord(1,1)-XMax ObjectData.Coord(1,2)-YMax 2*XMax 2*YMax])
[8]407    end
[625]408    if test_patch
[1099]409        createimage=1;
[681]410        if isfield(PlotData,'SubObject')
[1099]411            for iobj=1:length(PlotData.SubObject)
[655]412                objtype=get(PlotData.SubObject(iobj),'Type');
413                if isequal(objtype,'image')
414                    set(PlotData.SubObject(iobj),'CData',imflag,'AlphaData',(flag)*0.2)
415                    set(PlotData.SubObject(iobj),'XData',[xlim(1)+dx/2 xlim(2)-dx/2])
416                    set(PlotData.SubObject(iobj),'YData',[ylim(1)+dy/2 ylim(2)-dy/2])
[1099]417                    createimage=0;
[655]418                end
[8]419            end
[681]420        end
[1099]421        if createimage
422            hold on
423            hhh=image([xlim(1)+dx/2 xlim(2)-dx/2],[ylim(1)+dy/2 ylim(2)-dy/2],imflag,'Tag','proj_object','HitTest','off');
424            set(hhh,'AlphaData',(flag)*0.2)% set partial transparency to the filling color
425            PlotData.SubObject(1)=hhh;
426        end
[655]427    else% no patch image requested, erase existing ones
[680]428        if isfield(PlotData,'SubObject')
[954]429            for iobj=1:length(PlotData.SubObject)
430                if ishandle(PlotData.SubObject(iobj)) && strcmp(get(PlotData.SubObject(iobj),'Type'),'image')
431                    delete(PlotData.SubObject(iobj))
[1099]432                    PlotData=rmfield(PlotData,SubObject(iobj));
[954]433                end
[655]434            end
[8]435        end
436    end
437end
438
[156]439%% create the object
[8]440if test_newobj
441    hother=findobj('Tag','proj_object');%find all the proj objects
442    for iobj=1:length(hother)
[177]443        if strcmp(get(hother(iobj),'Type'),'rectangle')|| strcmp(get(hother(iobj),'Type'),'patch')
[8]444            set(hother(iobj),'EdgeColor','b')
445            if isequal(get(hother(iobj),'FaceColor'),'m')
446                set(hother(iobj),'FaceColor','b')
447            end
448        elseif isequal(get(hother(iobj),'Type'),'image')
449               Acolor=get(hother(iobj),'CData');
450               Acolor(:,:,1)=zeros(size(Acolor,1),size(Acolor,2));
451               set(hother(iobj),'CData',Acolor);
452        else
453             set(hother(iobj),'Color','b')
454        end
455        set(hother(iobj),'Selected','off')
456    end
457    hother=findobj('Tag','DeformPoint');
458    set(hother,'Color','b');
459    set(hother,'Selected','off') 
[625]460    switch ObjectData.Type
461        case 'points'
[937]462            hh=line(ObjectData.Coord(:,1),ObjectData.Coord(:,2),'Color',col,'LineStyle','none','Marker','+');
[625]463            for ipt=1:length(xline)
[8]464                PlotData.DeformPoint(ipt)=line(ObjectData.Coord(ipt,1),ObjectData.Coord(ipt,2),'Color',...
[1098]465                    col,'LineStyle','none','Marker','.','MarkerSize',12,'SelectionHighlight','off','UserData',hh,'Tag','DeformPoint');
[625]466                %create circle around each point
467                if ~isequal(YMax,0)
468                    PlotData.SubObject(ipt)=rectangle('Curvature',[1 1],...
469                        'Position',[ObjectData.Coord(ipt,1)-YMax ObjectData.Coord(ipt,2)-YMax 2*YMax 2*YMax],'EdgeColor',col,...
470                        'LineStyle',SubLineStyle,'Tag','proj_object');
471                end
[8]472            end
[955]473        case {'line','polyline','polygon'}
[625]474            hh=line(xline,yline,'Color',col);
[1099]475            if ismember(ObjectData.ProjMode,{'projection','interp_lin','interp_tps'})
[625]476                PlotData.SubObject(1)=line(xinf,yinf,'Color',col,'LineStyle',SubLineStyle,'Tag','proj_object');%draw sub-lines
477                PlotData.SubObject(2)=line(xsup,ysup,'Color',col,'LineStyle',SubLineStyle,'Tag','proj_object');
[1099]478            end
[625]479                for ipt=1:sizcoord(1)
480                    PlotData.DeformPoint(ipt)=line(ObjectData.Coord(ipt,1),ObjectData.Coord(ipt,2),'Color',...
[1098]481                        col,'LineStyle','none','Marker','.','MarkerSize',12,'Tag','DeformPoint','SelectionHighlight','off','UserData',hh);
[625]482                end
[1080]483        case {'plane','volume'}
[625]484            hh=line(xline,yline,'Color',col);
485            PlotData.SubObject(1)=line(xsup,ysup,'Color',col,'LineStyle',SubLineStyle,'Tag','proj_object');
486        case 'rectangle'
487            hh=rectangle('Position',[ObjectData.Coord(1,1)-XMax ObjectData.Coord(1,2)-YMax 2*XMax 2*YMax],'LineWidth',2,'EdgeColor',col);
488        case 'ellipse'
[680]489            hh=rectangle('Curvature',[1 1],'Position',[ObjectData.Coord(1,1)-XMax ObjectData.Coord(1,2)-YMax 2*XMax 2*YMax],'EdgeColor',col,'LineWidth',2);
[625]490        otherwise
491            msgbox_uvmat('ERROR','unknown ObjectData.Type in plot_object.m')
492            return
[8]493    end
494    set(hh,'Tag','proj_object')
[187]495     if test_patch
496         hold on
[8]497        hhh=image([xlim(1)+dx/2 xlim(2)-dx/2],[ylim(1)+dy/2 ylim(2)-dy/2],imflag,'Tag','proj_object','HitTest','off');
[187]498       set(hhh,'AlphaData',(flag)*0.2)% set partial transparency to the filling color
499         PlotData.SubObject=hhh;   
500     end
[8]501    if isfield(PlotData,'SubObject')
502        set(PlotData.SubObject,'UserData',hh)%record the parent handles in the SubObjects
503    end
504    if isfield(PlotData,'DeformPoint')
505        for ipt=1:sizcoord(1)
506            set(PlotData.DeformPoint(ipt),'UserData',hh);%record the parent handles in the SubObjects
507        end
508        set(PlotData.DeformPoint,'UserData',hh)%record the parent handles in the SubObjects
509    end
510end
[1099]511%put the deformpoints to the front
512            listc=get(gca,'children');
513            checkdeform=strcmp(get(listc,'tag'),'DeformPoint');
514            [nn,Index]=sort(checkdeform,'descend');
515            set(gca,'children',listc(Index))
[8]516set(hh,'UserData',PlotData)
Note: See TracBrowser for help on using the repository browser.