Changeset 954 for trunk/src/plot_object.m
 Timestamp:
 Jun 22, 2016, 1:36:50 PM (7 years ago)
 File:

 1 edited
Legend:
 Unmodified
 Added
 Removed

trunk/src/plot_object.m
r937 r954 133 133 134 134 %% determine the coordinates xline, yline,xsup,xinf, yinf,ysup determining the new object plot 135 test_line= isequal(ObjectData.Type,'points')isequal(ObjectData.Type,'line')... 136 isequal(ObjectData.Type,'polyline')isequal(ObjectData.Type,'polygon') isequal(ObjectData.Type,'plane') isequal(ObjectData.Type,'volume'); 137 test_patch=isequal(ObjectData.ProjMode,'inside')isequal(ObjectData.ProjMode,'outside')isequal(ObjectData.Type,'volume')... 138 isequal(ObjectData.ProjMode,'mask_inside')isequal(ObjectData.ProjMode,'mask_outside'); 135 %test_line= isequal(ObjectData.Type,'points')isequal(ObjectData.Type,'line')... 136 % isequal(ObjectData.Type,'polyline')isequal(ObjectData.Type,'polygon') isequal(ObjectData.Type,'plane') isequal(ObjectData.Type,'volume'); 137 %test_patch=isequal(ObjectData.ProjMode,'inside')isequal(ObjectData.ProjMode,'outside')isequal(ObjectData.Type,'volume')... 138 % isequal(ObjectData.ProjMode,'mask_inside')isequal(ObjectData.ProjMode,'mask_outside'); 139 test_line=ismember(ObjectData.Type,{'points','line','polyline','polygon','plane','plane_z','volume'}); 140 test_patch=ismember(ObjectData.ProjMode,{'inside','outside','mask_inside','mask_outside'}); 139 141 if test_line 140 142 xline=ObjectData.Coord(:,1); 141 143 yline=ObjectData.Coord(:,2); 142 144 nbpoints=numel(xline); 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') 147 xline=[xline; ObjectData.Coord(1,1)];%closing the line 148 yline=[yline; ObjectData.Coord(1,2)]; 149 elseif isequal(ObjectData.Type,'plane') isequal(ObjectData.Type,'volume') 150 if ~isfield(ObjectData,'Angle') 151 ObjectData.Angle=[0 0 0]; 152 end 153 phi=ObjectData.Angle(3)*pi/180;%angle in radians 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)=x0min(0,YMin)*sin(phi);% min end of the y axes 181 yline(8)=y0+min(0,YMin)*cos(phi); 182 xline(9)=x0YMax*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(phipi/8); 188 yline(3)=yline(2)arrow_scale*sin(phipi/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/2pi/8); 196 yline(10)=yline(9)arrow_scale*sin(phi+pi/2pi/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 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') 236 ObjectData=rmfield(ObjectData,'DX'); 237 end 238 if isfield (ObjectData,'DY') 239 ObjectData=rmfield(ObjectData,'DY'); 240 end 241 elseif isequal(ObjectData.ProjMode,'filter') 242 SubLineStyle=':';%range of projection not visible 243 end 244 end 245 if isequal(ObjectData.Type,'line')isequal(ObjectData.Type,'polyline')isequal(ObjectData.Type,'polygon') 246 if length(xline)<2 247 theta=0; 248 else 249 theta=angle(diff(xline)+1i*diff(yline)); 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(ip1))/2)/cos((theta(ip1)theta(ip))/2); 258 xinf(ip)=xline(ip)YMax*sin((theta(ip)+theta(ip1))/2)/cos((theta(ip1)theta(ip))/2); 259 ysup(ip)=yline(ip)YMax*cos((theta(ip)+theta(ip1))/2)/cos((theta(ip1)theta(ip))/2); 260 yinf(ip)=yline(ip)+YMax*cos((theta(ip)+theta(ip1))/2)/cos((theta(ip1)theta(ip))/2); 261 end 145 switch ObjectData.Type 146 case 'line_x' 147 xline=[xline; ObjectData.RangeX(2)];%creating the line 148 yline=[yline; ObjectData.RangeY(2)];%creating the line 149 case 'polygon' 150 xline=[xline; ObjectData.Coord(1,1)];%closing the line 151 yline=[yline; ObjectData.Coord(1,2)]; 152 case {'plane','volume'} 153 if ~isfield(ObjectData,'Angle') 154 ObjectData.Angle=[0 0 0]; 155 end 156 phi=ObjectData.Angle(3)*pi/180;%angle in radians 157 x0=xline(1); y0=yline(1); 158 xlim=get(haxes,'XLim'); 159 ylim=get(haxes,'YLim'); 160 graph_scale=max(abs(xlim(2)xlim(1)),abs(ylim(2)ylim(1)))/2;% estimate the length of axes plots 161 XMax=graph_scale; 162 YMax=graph_scale; 163 XMin=graph_scale; 164 YMin=graph_scale; 165 if ~isempty(XMaxRange) 166 XMax=XMaxRange; 167 end 168 if ~isempty(XMinRange) 169 XMin=XMinRange; 170 end 171 if ~isempty(YMaxRange) 172 YMax=YMaxRange; 173 end 174 if ~isempty(YMinRange) 175 YMin=YMinRange; 176 end 177 % axes lines 178 xline=NaN(1,13); 179 xline(1)=x0+min(0,XMin)*cos(phi); % min end of the x axes 180 yline(1)=y0+min(0,XMin)*sin(phi); 181 xline(2)=x0+XMax*cos(phi);% max end of the x axes 182 yline(2)=y0+XMax*sin(phi); 183 xline(8)=x0min(0,YMin)*sin(phi);% min end of the y axes 184 yline(8)=y0+min(0,YMin)*cos(phi); 185 xline(9)=x0YMax*sin(phi);% max end of the y axes 186 yline(9)=y0+YMax*cos(phi); 187 188 %arrows on x axis 189 arrow_scale=graph_scale/20; 190 xline(3)=xline(2)arrow_scale*cos(phipi/8); 191 yline(3)=yline(2)arrow_scale*sin(phipi/8); 192 xline(5)=xline(2); 193 yline(5)=yline(2); 194 xline(6)=xline(2)arrow_scale*cos(phi+pi/8); 195 yline(6)=yline(2)arrow_scale*sin(phi+pi/8); 196 197 %arrows on y axis 198 xline(10)=xline(9)arrow_scale*cos(phi+pi/2pi/8); 199 yline(10)=yline(9)arrow_scale*sin(phi+pi/2pi/8); 200 xline(12)=xline(9); 201 yline(12)=yline(9); 202 xline(13)=xline(9)arrow_scale*cos(phi+pi/2+pi/8); 203 yline(13)=yline(9)arrow_scale*sin(phi+pi/2+pi/8); 204 %xline=[Xbeg_x Xend_x NaN Ybeg_x Yend_x]; 205 %yline=[Xbeg_y Xend_y NaN Ybeg_y Yend_y]; 206 % dashed lines indicating bounds 207 xsup=NaN(1,5); 208 ysup=NaN(1,5); 209 if ~isempty(XMaxRange) 210 xsup(1)=xline(2)YMin*sin(phi); 211 ysup(1)=yline(2)+YMin*cos(phi); 212 xsup(2)=xline(2)YMax*sin(phi); 213 ysup(2)=yline(2)+YMax*cos(phi); 214 end 215 if ~isempty(YMaxRange) 216 xsup(2)=xline(2)YMax*sin(phi); 217 ysup(2)=yline(2)+YMax*cos(phi); 218 xsup(3)=xline(9)+XMin*cos(phi); 219 ysup(3)=yline(9)+XMin*sin(phi); 220 end 221 if ~isempty(XMinRange) 222 xsup(3)=xline(9)+XMin*cos(phi); 223 ysup(3)=yline(9)+XMin*sin(phi); 224 xsup(4)=x0+XMin*cos(phi)YMin*sin(phi); 225 ysup(4)=y0+XMin*sin(phi)+YMin*cos(phi); 226 end 227 if ~isempty(YMinRange) 228 xsup(4)=x0+XMin*cos(phi)YMin*sin(phi); 229 ysup(4)=y0+XMin*sin(phi)+YMin*cos(phi); 230 xsup(5)=xline(8)YMin*sin(phi); 231 ysup(5)=yline(8)+YMin*cos(phi); 232 end 233 end 234 end 235 SubLineStyle='none';%default 236 if isfield(ObjectData,'ProjMode') 237 if isequal(ObjectData.ProjMode,'projection') 238 SubLineStyle=''; %range of projection marked by dash 239 if isfield (ObjectData,'DX') 240 ObjectData=rmfield(ObjectData,'DX'); 241 end 242 if isfield (ObjectData,'DY') 243 ObjectData=rmfield(ObjectData,'DY'); 244 end 245 elseif isequal(ObjectData.ProjMode,'filter') 246 SubLineStyle=':';%range of projection not visible 247 end 248 end 249 if ismember(ObjectData.Type,{'line','polyline','polygon','plane_z'}) 250 if length(xline)<2 251 theta=0; 252 else 253 theta=angle(diff(xline)+1i*diff(yline)); 254 theta(length(xline))=theta(length(xline)1); 255 end 256 xsup(1)=xline(1)+YMax*sin(theta(1)); 257 xinf(1)=xline(1)YMax*sin(theta(1)); 258 ysup(1)=yline(1)YMax*cos(theta(1)); 259 yinf(1)=yline(1)+YMax*cos(theta(1)); 260 for ip=2:length(xline) 261 xsup(ip)=xline(ip)+YMax*sin((theta(ip)+theta(ip1))/2)/cos((theta(ip1)theta(ip))/2); 262 xinf(ip)=xline(ip)YMax*sin((theta(ip)+theta(ip1))/2)/cos((theta(ip1)theta(ip))/2); 263 ysup(ip)=yline(ip)YMax*cos((theta(ip)+theta(ip1))/2)/cos((theta(ip1)theta(ip))/2); 264 yinf(ip)=yline(ip)+YMax*cos((theta(ip)+theta(ip1))/2)/cos((theta(ip1)theta(ip))/2); 262 265 end 263 266 end … … 415 418 else% no patch image requested, erase existing ones 416 419 if isfield(PlotData,'SubObject') 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 end421 end420 for iobj=1:length(PlotData.SubObject) 421 if ishandle(PlotData.SubObject(iobj)) && strcmp(get(PlotData.SubObject(iobj),'Type'),'image') 422 delete(PlotData.SubObject(iobj)) 423 end 424 end 422 425 end 423 426 end … … 459 462 end 460 463 end 461 case {'line','polyline','polygon' }464 case {'line','polyline','polygon','plane_z'} 462 465 hh=line(xline,yline,'Color',col); 463 466 PlotData.SubObject(1)=line(xinf,yinf,'Color',col,'LineStyle',SubLineStyle,'Tag','proj_object');%draw sublines
Note: See TracChangeset
for help on using the changeset viewer.