[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 | %=======================================================================
|
---|
[908] | 23 | % Copyright 2008-2015, LEGI UMR 5519 / CNRS UJF G-INP, Grenoble, France
|
---|
[809] | 24 | % http://www.legi.grenoble-inp.fr
|
---|
| 25 | % Joel.Sommeria - Joel.Sommeria (A) legi.cnrs.fr
|
---|
| 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] | 40 | function [hh]=plot_object(ObjectData,ProjObject,hplot,col)
|
---|
| 41 |
|
---|
[156] | 42 | %% default output
|
---|
[8] | 43 | hh=[];%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] | 45 | if ~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] | 57 | end
|
---|
[625] | 58 | XMin=0;%default range for the graph
|
---|
[8] | 59 | XMax=0;
|
---|
| 60 | YMin=0;
|
---|
| 61 | YMax=0;
|
---|
| 62 | ZMin=0;
|
---|
| 63 | ZMax=0;
|
---|
[625] | 64 | XMinRange=[];%default range set by input
|
---|
| 65 | XMaxRange=[];
|
---|
| 66 | YMinRange=[];
|
---|
| 67 | YMaxRange=[];
|
---|
| 68 | ZMinRange=[];
|
---|
| 69 | ZMaxRange=[];
|
---|
[8] | 70 |
|
---|
[156] | 71 | %% determine the plotting axes (with handle 'haxes')
|
---|
[8] | 72 | test_newobj=1;
|
---|
| 73 | if 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
|
---|
| 91 | else
|
---|
[231] | 92 | currentfig=figure; %create new figure
|
---|
[8] | 93 | hplot=axes;%create new axes
|
---|
| 94 | haxes=hplot;
|
---|
| 95 | end
|
---|
[231] | 96 | set(0,'CurrentFigure',currentfig)%set the currentfigure as the current one
|
---|
| 97 | set(currentfig,'CurrentAxes',haxes);%set the current axes in the current figure
|
---|
[8] | 98 |
|
---|
[156] | 99 | %% default input parameters
|
---|
[177] | 100 | if ~isfield(ObjectData,'ProjMode')||isempty(ObjectData.ProjMode)
|
---|
[8] | 101 | ObjectData.ProjMode='projection';%default
|
---|
| 102 | end
|
---|
[177] | 103 | if ~isfield(ObjectData,'Coord')||isempty(ObjectData.Coord)
|
---|
[8] | 104 | ObjectData.Coord=[0 0 0];%default
|
---|
| 105 | end
|
---|
[379] | 106 | if 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] | 113 | end
|
---|
[379] | 114 | if 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] | 121 | end
|
---|
[379] | 122 | if isfield(ObjectData,'RangeZ')&&~isempty(ObjectData.RangeZ)
|
---|
| 123 | ZMax=max(ObjectData.RangeZ);
|
---|
| 124 | ZMin=min(ObjectData.RangeZ);
|
---|
[625] | 125 | ZMaxRange=max(ObjectData.RangeZ);
|
---|
| 126 | ZMinRange=min(ObjectData.RangeZ);
|
---|
[8] | 127 | end
|
---|
[625] | 128 | if strcmp(ObjectData.Type,'points') && strcmp(ObjectData.ProjMode,'projection')
|
---|
| 129 | YMax=max(XMax,YMax);
|
---|
| 130 | YMax=max(YMax,ZMax);
|
---|
[8] | 131 | end
|
---|
| 132 | sizcoord=size(ObjectData.Coord);
|
---|
| 133 |
|
---|
[156] | 134 | %% determine the coordinates xline, yline,xsup,xinf, yinf,ysup determining the new object plot
|
---|
[655] | 135 | test_line= isequal(ObjectData.Type,'points')||isequal(ObjectData.Type,'line')||...
|
---|
[650] | 136 | isequal(ObjectData.Type,'polyline')||isequal(ObjectData.Type,'polygon')|| isequal(ObjectData.Type,'plane')|| isequal(ObjectData.Type,'volume');
|
---|
[379] | 137 | test_patch=isequal(ObjectData.ProjMode,'inside')||isequal(ObjectData.ProjMode,'outside')||isequal(ObjectData.Type,'volume')...
|
---|
[8] | 138 | ||isequal(ObjectData.ProjMode,'mask_inside')||isequal(ObjectData.ProjMode,'mask_outside');
|
---|
| 139 | if test_line
|
---|
| 140 | xline=ObjectData.Coord(:,1);
|
---|
| 141 | yline=ObjectData.Coord(:,2);
|
---|
[177] | 142 | nbpoints=numel(xline);
|
---|
[650] | 143 | if isequal(ObjectData.Type,'line_x')
|
---|
| 144 | xline=[xline; ObjectData.RangeX(2)];%creating the line
|
---|
| 145 | yline=[yline; ObjectData.RangeY(2)];%creating the line
|
---|
| 146 | elseif isequal(ObjectData.Type,'polygon')
|
---|
[8] | 147 | xline=[xline; ObjectData.Coord(1,1)];%closing the line
|
---|
| 148 | yline=[yline; ObjectData.Coord(1,2)];
|
---|
[379] | 149 | elseif isequal(ObjectData.Type,'plane')|| isequal(ObjectData.Type,'volume')
|
---|
[625] | 150 | if ~isfield(ObjectData,'Angle')
|
---|
| 151 | ObjectData.Angle=[0 0 0];
|
---|
| 152 | end
|
---|
[397] | 153 | phi=ObjectData.Angle(3)*pi/180;%angle in radians
|
---|
[625] | 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;
|
---|
| 164 | end
|
---|
| 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);
|
---|
| 176 | xline(1)=x0+min(0,XMin)*cos(phi); % min end of the x axes
|
---|
| 177 | yline(1)=y0+min(0,XMin)*sin(phi);
|
---|
| 178 | xline(2)=x0+XMax*cos(phi);% max end of the x axes
|
---|
| 179 | yline(2)=y0+XMax*sin(phi);
|
---|
| 180 | xline(8)=x0-min(0,YMin)*sin(phi);% min end of the y axes
|
---|
| 181 | yline(8)=y0+min(0,YMin)*cos(phi);
|
---|
| 182 | xline(9)=x0-YMax*sin(phi);% max end of the y axes
|
---|
| 183 | yline(9)=y0+YMax*cos(phi);
|
---|
| 184 |
|
---|
| 185 | %arrows on x axis
|
---|
| 186 | arrow_scale=graph_scale/20;
|
---|
| 187 | xline(3)=xline(2)-arrow_scale*cos(phi-pi/8);
|
---|
| 188 | yline(3)=yline(2)-arrow_scale*sin(phi-pi/8);
|
---|
| 189 | xline(5)=xline(2);
|
---|
| 190 | yline(5)=yline(2);
|
---|
| 191 | xline(6)=xline(2)-arrow_scale*cos(phi+pi/8);
|
---|
| 192 | yline(6)=yline(2)-arrow_scale*sin(phi+pi/8);
|
---|
| 193 |
|
---|
| 194 | %arrows on y axis
|
---|
| 195 | xline(10)=xline(9)-arrow_scale*cos(phi+pi/2-pi/8);
|
---|
| 196 | yline(10)=yline(9)-arrow_scale*sin(phi+pi/2-pi/8);
|
---|
| 197 | xline(12)=xline(9);
|
---|
| 198 | yline(12)=yline(9);
|
---|
| 199 | xline(13)=xline(9)-arrow_scale*cos(phi+pi/2+pi/8);
|
---|
| 200 | yline(13)=yline(9)-arrow_scale*sin(phi+pi/2+pi/8);
|
---|
| 201 | %xline=[Xbeg_x Xend_x NaN Ybeg_x Yend_x];
|
---|
| 202 | %yline=[Xbeg_y Xend_y NaN Ybeg_y Yend_y];
|
---|
| 203 | % dashed lines indicating bounds
|
---|
| 204 | xsup=NaN(1,5);
|
---|
| 205 | ysup=NaN(1,5);
|
---|
| 206 | if ~isempty(XMaxRange)
|
---|
| 207 | xsup(1)=xline(2)-YMin*sin(phi);
|
---|
| 208 | ysup(1)=yline(2)+YMin*cos(phi);
|
---|
| 209 | xsup(2)=xline(2)-YMax*sin(phi);
|
---|
| 210 | ysup(2)=yline(2)+YMax*cos(phi);
|
---|
| 211 | end
|
---|
| 212 | if ~isempty(YMaxRange)
|
---|
| 213 | xsup(2)=xline(2)-YMax*sin(phi);
|
---|
| 214 | ysup(2)=yline(2)+YMax*cos(phi);
|
---|
| 215 | xsup(3)=xline(9)+XMin*cos(phi);
|
---|
| 216 | ysup(3)=yline(9)+XMin*sin(phi);
|
---|
| 217 | end
|
---|
| 218 | if ~isempty(XMinRange)
|
---|
| 219 | xsup(3)=xline(9)+XMin*cos(phi);
|
---|
| 220 | ysup(3)=yline(9)+XMin*sin(phi);
|
---|
| 221 | xsup(4)=x0+XMin*cos(phi)-YMin*sin(phi);
|
---|
| 222 | ysup(4)=y0+XMin*sin(phi)+YMin*cos(phi);
|
---|
| 223 | end
|
---|
| 224 | if ~isempty(YMinRange)
|
---|
| 225 | xsup(4)=x0+XMin*cos(phi)-YMin*sin(phi);
|
---|
| 226 | ysup(4)=y0+XMin*sin(phi)+YMin*cos(phi);
|
---|
| 227 | xsup(5)=xline(8)-YMin*sin(phi);
|
---|
| 228 | ysup(5)=yline(8)+YMin*cos(phi);
|
---|
| 229 | end
|
---|
[8] | 230 | end
|
---|
| 231 | SubLineStyle='none';%default
|
---|
| 232 | if isfield(ObjectData,'ProjMode')
|
---|
| 233 | if isequal(ObjectData.ProjMode,'projection')
|
---|
| 234 | SubLineStyle='--'; %range of projection marked by dash
|
---|
| 235 | if isfield (ObjectData,'DX')
|
---|
[177] | 236 | ObjectData=rmfield(ObjectData,'DX');
|
---|
[8] | 237 | end
|
---|
| 238 | if isfield (ObjectData,'DY')
|
---|
[177] | 239 | ObjectData=rmfield(ObjectData,'DY');
|
---|
[8] | 240 | end
|
---|
| 241 | elseif isequal(ObjectData.ProjMode,'filter')
|
---|
| 242 | SubLineStyle=':';%range of projection not visible
|
---|
| 243 | end
|
---|
| 244 | end
|
---|
[379] | 245 | if isequal(ObjectData.Type,'line')||isequal(ObjectData.Type,'polyline')||isequal(ObjectData.Type,'polygon')
|
---|
[8] | 246 | if length(xline)<2
|
---|
| 247 | theta=0;
|
---|
| 248 | else
|
---|
[187] | 249 | theta=angle(diff(xline)+1i*diff(yline));
|
---|
[8] | 250 | theta(length(xline))=theta(length(xline)-1);
|
---|
| 251 | end
|
---|
| 252 | xsup(1)=xline(1)+YMax*sin(theta(1));
|
---|
| 253 | xinf(1)=xline(1)-YMax*sin(theta(1));
|
---|
| 254 | ysup(1)=yline(1)-YMax*cos(theta(1));
|
---|
| 255 | yinf(1)=yline(1)+YMax*cos(theta(1));
|
---|
| 256 | for ip=2:length(xline)
|
---|
| 257 | xsup(ip)=xline(ip)+YMax*sin((theta(ip)+theta(ip-1))/2)/cos((theta(ip-1)-theta(ip))/2);
|
---|
| 258 | xinf(ip)=xline(ip)-YMax*sin((theta(ip)+theta(ip-1))/2)/cos((theta(ip-1)-theta(ip))/2);
|
---|
| 259 | ysup(ip)=yline(ip)-YMax*cos((theta(ip)+theta(ip-1))/2)/cos((theta(ip-1)-theta(ip))/2);
|
---|
| 260 | yinf(ip)=yline(ip)+YMax*cos((theta(ip)+theta(ip-1))/2)/cos((theta(ip-1)-theta(ip))/2);
|
---|
| 261 | end
|
---|
| 262 | end
|
---|
| 263 | end
|
---|
| 264 |
|
---|
[156] | 265 | %% shading image
|
---|
[8] | 266 | if test_patch
|
---|
| 267 | npMx=512;
|
---|
| 268 | npMy=512;
|
---|
| 269 | flag=zeros(npMy,npMx);
|
---|
[379] | 270 | if isequal(ObjectData.Type,'ellipse')
|
---|
[8] | 271 | XimaMin=ObjectData.Coord(1,1)-XMax;
|
---|
| 272 | XimaMax=ObjectData.Coord(1,1)+XMax;
|
---|
| 273 | YimaMin=ObjectData.Coord(1,2)-YMax;
|
---|
| 274 | YimaMax=ObjectData.Coord(1,2)+YMax;
|
---|
| 275 | xlim=[1.2*XimaMin-0.2*XimaMax 1.2*XimaMax-0.2*XimaMin];%create an image around the ellipse
|
---|
| 276 | ylim=[1.2*YimaMin-0.2*YimaMax 1.2*YimaMax-0.2*YimaMin];
|
---|
| 277 | scale_x=2*1.4*XMax/npMx;
|
---|
| 278 | scale_y=2*1.4*YMax/npMy;
|
---|
[177] | 279 | xi=(0.5:npMx-0.5)*scale_x+xlim(1);
|
---|
| 280 | yi=(0.5:npMy-0.5)*scale_y+ylim(1);
|
---|
[8] | 281 | [Xi,Yi]=meshgrid(xi,yi);
|
---|
| 282 | X2Max=XMax*XMax;
|
---|
| 283 | Y2Max=YMax*YMax;
|
---|
| 284 | distX=(Xi-ObjectData.Coord(1,1));
|
---|
| 285 | distY=(Yi-ObjectData.Coord(1,2));
|
---|
| 286 | flag=(distX.*distX/X2Max+distY.*distY/Y2Max)<1;
|
---|
[379] | 287 | elseif isequal(ObjectData.Type,'rectangle')||isequal(ObjectData.Type,'volume')
|
---|
[8] | 288 | XimaMin=ObjectData.Coord(1,1)-XMax;
|
---|
| 289 | XimaMax=ObjectData.Coord(1,1)+XMax;
|
---|
| 290 | YimaMin=ObjectData.Coord(1,2)-YMax;
|
---|
| 291 | YimaMax=ObjectData.Coord(1,2)+YMax;
|
---|
| 292 | xlim=[1.2*XimaMin-0.2*XimaMax 1.2*XimaMax-0.2*XimaMin];%create an image around the ellipse
|
---|
| 293 | ylim=[1.2*YimaMin-0.2*YimaMax 1.2*YimaMax-0.2*YimaMin];
|
---|
| 294 | scale_x=2*1.4*XMax/npMx;
|
---|
| 295 | scale_y=2*1.4*YMax/npMy;
|
---|
[177] | 296 | xi=(0.5:npMx-0.5)*scale_x+xlim(1);
|
---|
| 297 | yi=(0.5:npMy-0.5)*scale_y+ylim(1);
|
---|
[8] | 298 | [Xi,Yi]=meshgrid(xi,yi);
|
---|
| 299 | distX=abs(Xi-ObjectData.Coord(1,1));
|
---|
| 300 | distY=abs(Yi-ObjectData.Coord(1,2));
|
---|
| 301 | flag=distX<XMax & distY< YMax;
|
---|
[379] | 302 | elseif isequal(ObjectData.Type,'polygon')
|
---|
[8] | 303 | XimaMin=min(ObjectData.Coord(:,1));
|
---|
| 304 | XimaMax=max(ObjectData.Coord(:,1));
|
---|
| 305 | YimaMin=min(ObjectData.Coord(:,2));
|
---|
| 306 | YimaMax=max(ObjectData.Coord(:,2));
|
---|
| 307 | xlim=[1.2*XimaMin-0.2*XimaMax 1.2*XimaMax-0.2*XimaMin];
|
---|
| 308 | ylim=[1.2*YimaMin-0.2*YimaMax 1.2*YimaMax-0.2*YimaMin];
|
---|
| 309 | [Xlim,Ylim]=meshgrid(linspace(xlim(1),xlim(2),npMx),linspace(ylim(1),ylim(2),npMy));
|
---|
| 310 | %flag=roipoly(xlim,ylim,flag,ObjectData.Coord(:,1),ObjectData.Coord(:,2));%=1 inside the polygon, 0 outsid
|
---|
| 311 | flag=inpolygon(Xlim,Ylim,ObjectData.Coord(:,1),ObjectData.Coord(:,2));%=1 inside the polygon, 0 outsid
|
---|
| 312 | end
|
---|
| 313 | if isequal(ObjectData.ProjMode,'outside')||isequal(ObjectData.ProjMode,'mask_outside')
|
---|
| 314 | flag=~flag;
|
---|
| 315 | end
|
---|
| 316 | imflag=zeros(npMx,npMy,3);
|
---|
| 317 | imflag(:,:,3)=flag; % blue color
|
---|
| 318 | if isequal(col,'m')
|
---|
| 319 | imflag(:,:,1)=flag; % magenta color
|
---|
| 320 | end
|
---|
| 321 | dx=(xlim(2)-xlim(1))/npMx;
|
---|
| 322 | dy=(ylim(2)-ylim(1))/npMy;
|
---|
| 323 | end
|
---|
| 324 |
|
---|
| 325 | PlotData=[];%default
|
---|
[177] | 326 |
|
---|
[156] | 327 | %% MODIFY AN EXISTING OBJECT PLOT
|
---|
[8] | 328 | if test_newobj==0;
|
---|
| 329 | hh=hplot;
|
---|
[625] | 330 | PlotData=get(hplot,'UserData');
|
---|
[8] | 331 | if test_line
|
---|
| 332 | set(hplot,'XData',xline)
|
---|
| 333 | set(hplot,'YData',yline)
|
---|
[625] | 334 | %modify subobjects
|
---|
| 335 | if isfield(PlotData,'SubObject')
|
---|
| 336 | if isequal(ObjectData.Type,'points')
|
---|
| 337 | if ~isequal(YMax,0)
|
---|
| 338 | for ipt=1:min(length(PlotData.SubObject),size(ObjectData.Coord,1))
|
---|
| 339 | set(PlotData.SubObject(ipt),'Position',[ObjectData.Coord(ipt,1)-YMax ObjectData.Coord(ipt,2)-YMax 2*YMax 2*YMax])
|
---|
| 340 | end
|
---|
| 341 | %complement missing points
|
---|
| 342 | if length(PlotData.SubObject)>nbpoints% fpoints in excess on the graph
|
---|
| 343 | for ii=nbpoints+1: length(PlotData.SubObject);
|
---|
| 344 | if ishandle(PlotData.SubObject(ii))
|
---|
| 345 | delete(PlotData.SubObject(ii))
|
---|
| 346 | end
|
---|
| 347 | end
|
---|
| 348 | end
|
---|
| 349 | % NbDeformPoint=nbpoints;
|
---|
| 350 |
|
---|
| 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
|
---|
[8] | 360 | set(PlotData.SubObject(1),'XData',xinf);
|
---|
| 361 | set(PlotData.SubObject(1),'YData',yinf);
|
---|
| 362 | set(PlotData.SubObject(2),'XData',xsup);
|
---|
| 363 | set(PlotData.SubObject(2),'YData',ysup);
|
---|
[625] | 364 | elseif length(PlotData.SubObject)==1
|
---|
| 365 | set(PlotData.SubObject(1),'XData',xsup);
|
---|
| 366 | set(PlotData.SubObject(1),'YData',ysup);
|
---|
| 367 | end
|
---|
[8] | 368 | end
|
---|
| 369 | if isfield(PlotData,'DeformPoint')
|
---|
[622] | 370 | NbDeformPoint=length(PlotData.DeformPoint);
|
---|
[625] | 371 | if NbDeformPoint>nbpoints% fpoints in excess on the graph
|
---|
| 372 | for ii=nbpoints+1:NbDeformPoint;
|
---|
| 373 | if ishandle(PlotData.DeformPoint(ii))
|
---|
[622] | 374 | delete(PlotData.DeformPoint(ii))
|
---|
[625] | 375 | end
|
---|
| 376 | end
|
---|
| 377 | NbDeformPoint=nbpoints;
|
---|
| 378 | end
|
---|
| 379 | for ipt=1:NbDeformPoint
|
---|
| 380 | if ishandle(PlotData.DeformPoint(ipt))
|
---|
| 381 | if nbpoints>=ipt
|
---|
[8] | 382 | set(PlotData.DeformPoint(ipt),'XData',xline(ipt),'YData',yline(ipt));
|
---|
| 383 | end
|
---|
[625] | 384 | end
|
---|
| 385 | end
|
---|
| 386 | if nbpoints>length(PlotData.DeformPoint)
|
---|
| 387 | for ipt=length(PlotData.DeformPoint)+1:nbpoints
|
---|
[8] | 388 | PlotData.DeformPoint(ipt)=line(xline(ipt),yline(ipt),'Color',col,'LineStyle','.','Tag','DeformPoint',...
|
---|
| 389 | 'SelectionHighlight','off','UserData',hplot);
|
---|
[625] | 390 | end
|
---|
| 391 | set(hplot,'UserData',PlotData)
|
---|
| 392 | end
|
---|
[8] | 393 | end
|
---|
[622] | 394 | elseif (isequal(ObjectData.Type,'rectangle')||isequal(ObjectData.Type,'ellipse'))&&XMax>0 && YMax>0
|
---|
[625] | 395 | set(hplot,'Position',[ObjectData.Coord(1,1)-XMax ObjectData.Coord(1,2)-YMax 2*XMax 2*YMax])
|
---|
[8] | 396 | end
|
---|
[625] | 397 | if test_patch
|
---|
[681] | 398 | if isfield(PlotData,'SubObject')
|
---|
[8] | 399 | for iobj=1:length(PlotData.SubObject)
|
---|
[655] | 400 | if ~ishandle(PlotData.SubObject(iobj))
|
---|
| 401 | hold on
|
---|
| 402 | hhh=image([xlim(1)+dx/2 xlim(2)-dx/2],[ylim(1)+dy/2 ylim(2)-dy/2],imflag,'Tag','proj_object','HitTest','off');
|
---|
| 403 | set(hhh,'AlphaData',(flag)*0.2)% set partial transparency to the filling color
|
---|
| 404 | PlotData.SubObject(iobj)=hhh;
|
---|
| 405 | else
|
---|
| 406 | objtype=get(PlotData.SubObject(iobj),'Type');
|
---|
| 407 | if isequal(objtype,'image')
|
---|
| 408 | set(PlotData.SubObject(iobj),'CData',imflag,'AlphaData',(flag)*0.2)
|
---|
| 409 | set(PlotData.SubObject(iobj),'XData',[xlim(1)+dx/2 xlim(2)-dx/2])
|
---|
| 410 | set(PlotData.SubObject(iobj),'YData',[ylim(1)+dy/2 ylim(2)-dy/2])
|
---|
| 411 | end
|
---|
[8] | 412 | end
|
---|
[681] | 413 | end
|
---|
| 414 | end
|
---|
[655] | 415 | else% no patch image requested, erase existing ones
|
---|
[680] | 416 | if isfield(PlotData,'SubObject')
|
---|
[655] | 417 | for iobj=1:length(PlotData.SubObject)
|
---|
| 418 | if ishandle(PlotData.SubObject(iobj)) && strcmp(get(PlotData.SubObject(iobj),'Type'),'image')
|
---|
| 419 | delete(PlotData.SubObject(iobj))
|
---|
| 420 | end
|
---|
[8] | 421 | end
|
---|
[680] | 422 | end
|
---|
[8] | 423 | end
|
---|
| 424 | end
|
---|
| 425 |
|
---|
[156] | 426 | %% create the object
|
---|
[8] | 427 | if test_newobj
|
---|
[231] | 428 | % axes(haxes)
|
---|
[8] | 429 | hother=findobj('Tag','proj_object');%find all the proj objects
|
---|
| 430 | for iobj=1:length(hother)
|
---|
[177] | 431 | if strcmp(get(hother(iobj),'Type'),'rectangle')|| strcmp(get(hother(iobj),'Type'),'patch')
|
---|
[8] | 432 | set(hother(iobj),'EdgeColor','b')
|
---|
| 433 | if isequal(get(hother(iobj),'FaceColor'),'m')
|
---|
| 434 | set(hother(iobj),'FaceColor','b')
|
---|
| 435 | end
|
---|
| 436 | elseif isequal(get(hother(iobj),'Type'),'image')
|
---|
| 437 | Acolor=get(hother(iobj),'CData');
|
---|
| 438 | Acolor(:,:,1)=zeros(size(Acolor,1),size(Acolor,2));
|
---|
| 439 | set(hother(iobj),'CData',Acolor);
|
---|
| 440 | else
|
---|
| 441 | set(hother(iobj),'Color','b')
|
---|
| 442 | end
|
---|
| 443 | set(hother(iobj),'Selected','off')
|
---|
| 444 | end
|
---|
| 445 | hother=findobj('Tag','DeformPoint');
|
---|
| 446 | set(hother,'Color','b');
|
---|
| 447 | set(hother,'Selected','off')
|
---|
[625] | 448 | switch ObjectData.Type
|
---|
| 449 | case 'points'
|
---|
| 450 | hh=line(ObjectData.Coord(:,1),ObjectData.Coord(:,2),'Color',col,'LineStyle','.','Marker','+');
|
---|
| 451 | for ipt=1:length(xline)
|
---|
[8] | 452 | PlotData.DeformPoint(ipt)=line(ObjectData.Coord(ipt,1),ObjectData.Coord(ipt,2),'Color',...
|
---|
[625] | 453 | col,'LineStyle','.','SelectionHighlight','off','UserData',hh,'Tag','DeformPoint');
|
---|
| 454 | %create circle around each point
|
---|
| 455 | if ~isequal(YMax,0)
|
---|
| 456 | PlotData.SubObject(ipt)=rectangle('Curvature',[1 1],...
|
---|
| 457 | 'Position',[ObjectData.Coord(ipt,1)-YMax ObjectData.Coord(ipt,2)-YMax 2*YMax 2*YMax],'EdgeColor',col,...
|
---|
| 458 | 'LineStyle',SubLineStyle,'Tag','proj_object');
|
---|
| 459 | end
|
---|
[8] | 460 | end
|
---|
[625] | 461 | case {'line','polyline','polygon'}
|
---|
| 462 | hh=line(xline,yline,'Color',col);
|
---|
| 463 | PlotData.SubObject(1)=line(xinf,yinf,'Color',col,'LineStyle',SubLineStyle,'Tag','proj_object');%draw sub-lines
|
---|
| 464 | PlotData.SubObject(2)=line(xsup,ysup,'Color',col,'LineStyle',SubLineStyle,'Tag','proj_object');
|
---|
| 465 | for ipt=1:sizcoord(1)
|
---|
| 466 | PlotData.DeformPoint(ipt)=line(ObjectData.Coord(ipt,1),ObjectData.Coord(ipt,2),'Color',...
|
---|
| 467 | col,'LineStyle','none','Marker','.','Tag','DeformPoint','SelectionHighlight','off','UserData',hh);
|
---|
| 468 | end
|
---|
| 469 | case {'plane','volume'}
|
---|
| 470 | hh=line(xline,yline,'Color',col);
|
---|
| 471 | PlotData.SubObject(1)=line(xsup,ysup,'Color',col,'LineStyle',SubLineStyle,'Tag','proj_object');
|
---|
| 472 | case 'rectangle'
|
---|
| 473 | hh=rectangle('Position',[ObjectData.Coord(1,1)-XMax ObjectData.Coord(1,2)-YMax 2*XMax 2*YMax],'LineWidth',2,'EdgeColor',col);
|
---|
| 474 | case 'ellipse'
|
---|
[680] | 475 | 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] | 476 | otherwise
|
---|
| 477 | msgbox_uvmat('ERROR','unknown ObjectData.Type in plot_object.m')
|
---|
| 478 | return
|
---|
[8] | 479 | end
|
---|
| 480 | set(hh,'Tag','proj_object')
|
---|
[187] | 481 | if test_patch
|
---|
| 482 | hold on
|
---|
[8] | 483 | 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] | 484 | set(hhh,'AlphaData',(flag)*0.2)% set partial transparency to the filling color
|
---|
| 485 | PlotData.SubObject=hhh;
|
---|
| 486 | end
|
---|
[8] | 487 | if isfield(PlotData,'SubObject')
|
---|
| 488 | set(PlotData.SubObject,'UserData',hh)%record the parent handles in the SubObjects
|
---|
| 489 | end
|
---|
| 490 | if isfield(PlotData,'DeformPoint')
|
---|
| 491 | for ipt=1:sizcoord(1)
|
---|
| 492 | set(PlotData.DeformPoint(ipt),'UserData',hh);%record the parent handles in the SubObjects
|
---|
| 493 | end
|
---|
| 494 | set(PlotData.DeformPoint,'UserData',hh)%record the parent handles in the SubObjects
|
---|
| 495 | end
|
---|
| 496 | end
|
---|
| 497 | set(hh,'UserData',PlotData)
|
---|