0001 function drawShape(sType,begPt,sLength, color, thickness,sStyle,verbose)
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022 if ~exist('verbose','var')
0023 verbose = false;
0024 end
0025 global CB_MAP_OUTPUT
0026 global mapHandle
0027 if nargin < 4
0028 color = 'b';
0029 display('No color specified');
0030 elseif strcmp(CB_MAP_OUTPUT, 'matlab')
0031 color = (1/255)*color;
0032 end
0033 if verbose
0034 if strcmp(sStyle,'DASHL')
0035 display('DASHL');
0036 style = '--';
0037 dashArray = '30, 20';
0038 elseif strcmp(sStyle,'DASHM')
0039 display('DASHM');
0040 style = '--';
0041 dashArray = '20, 20';
0042 elseif strcmp(sStyle,'DASHS')
0043 display('DASHS');
0044 style = '-.';
0045 dashArray = '10, 15';
0046 elseif strcmp(sStyle,'DOTTD')
0047 display('DOTTD');
0048 style = ':';
0049 dashArray = '0, 20';
0050 elseif strcmp(sStyle,'PLAIN')
0051 display('PLAIN');
0052 style = '-';
0053 dashArray = '';
0054 else
0055 style = '-';
0056 dashArray = '';
0057 display('Unknown Style');
0058 end
0059 else
0060 if strcmp(sStyle,'DASHL')
0061 style = '--';
0062 dashArray = '30, 20';
0063 elseif strcmp(sStyle,'DASHM')
0064 style = '--';
0065 dashArray = '20, 20';
0066 elseif strcmp(sStyle,'DASHS')
0067 style = '-.';
0068 dashArray = '10, 15';
0069 elseif strcmp(sStyle,'DOTTD')
0070 style = ':';
0071 dashArray = '0, 20';
0072 elseif strcmp(sStyle,'PLAIN')
0073 style = '-';
0074 dashArray = '';
0075 else
0076 style = '-';
0077 dashArray = '';
0078 end
0079 end
0080
0081 if strcmp(CB_MAP_OUTPUT, 'matlab')
0082 thickness = thickness/7;
0083 begPt(1,2) = -begPt(1,2);
0084 sLength(1,1) = -sLength(1,1);
0085 switch lower(sType{1})
0086 case 'line'
0087 line([begPt(1,1),(begPt(1,1)+sLength(1,2))],[begPt(1,2),(begPt(1,2)+sLength(1,1))],'Color',color,'LineWidth',thickness,'LineStyle',style);
0088 case {'rect', 'rectangle'}
0089 line([begPt(1,1),begPt(1,1)],[begPt(1,2),(begPt(1,2)+sLength(1,1))],'Color',color,'LineWidth',thickness,'LineStyle',style);
0090 line([begPt(1,1),(begPt(1,1)+sLength(1,2))],[begPt(1,2),begPt(1,2)],'Color',color,'LineWidth',thickness,'LineStyle',style);
0091 line([(begPt(1,1)+sLength(1,2)),(begPt(1,1)+sLength(1,2))],[begPt(1,2),(begPt(1,2)+sLength(1,1))],'Color',color,'LineWidth',thickness,'LineStyle',style);
0092 line([begPt(1,1),(begPt(1,1)+sLength(1,2))],[(begPt(1,2)+sLength(1,1)),(begPt(1,2)+sLength(1,1))],'Color',color,'LineWidth',thickness,'LineStyle',style);
0093 case 'circle'
0094 i = 0:pi/100:2*pi;
0095 x = .5*sLength(1,2)*cos(i)+begPt(1);
0096 y = .5*sLength(1,1)*sin(i)-begPt(2);
0097 plot(x,y,style);
0098 otherwise
0099 display('error: Unknown Shape Type');
0100 end
0101 elseif strcmp(CB_MAP_OUTPUT, 'java')
0102
0103
0104
0105
0106 x1=begPt(1,1);
0107 x2=endPt(1,1);
0108 y1=begPt(2,1);
0109 y2=endPt(2,1);
0110
0111
0112 setDataVector(mapHandle,x1,y1,x2,y2);
0113
0114 elseif strcmp(CB_MAP_OUTPUT, 'svg')
0115 if ischar(color)
0116 colorStroke = color;
0117 else if isvector(color)
0118 colorStroke = strcat('rgb(',num2str(color(1)),',',num2str(color(2)),',',num2str(color(3)),')');
0119 end
0120 end
0121 switch lower(sType{1})
0122 case 'line'
0123 fprintf(mapHandle,['<g style="stroke-linecap: round; stroke-linejoin: round; stroke-miterlimit: 20; '...
0124 'fill: %s; stroke: %s; stroke-width: %d; stroke-dasharray: %s;">\n'],colorStroke,colorStroke,thickness,dashArray);
0125 fprintf(mapHandle,'<line x1="%.2f" y1="%.2f" x2="%.2f" y2="%.2f" />\n</g>\n',begPt(1,1),begPt(1,2),begPt(1,1)+sLength(1,2),begPt(1,2)+sLength(1,1));
0126 case {'rect', 'rectangle'}
0127 fprintf(mapHandle,['<g style="stroke-linecap: round; stroke-linejoin: round; stroke-miterlimit: 20; '...
0128 'fill: none; stroke: %s; stroke-width: %d; stroke-dasharray: %s;">\n'],colorStroke,thickness,dashArray);
0129 fprintf(mapHandle,'<rect x="%.2f" y="%.2f" width="%.2f" height="%.2f" />\n</g>\n',begPt(1,1),begPt(1,2),sLength(1,2),sLength(1,1));
0130 case 'circle'
0131 fprintf(mapHandle,['<g style="stroke-linecap: round; stroke-linejoin: round; stroke-miterlimit: 20; '...
0132 'fill: none; stroke: %s; stroke-width: %d; stroke-dasharray: %s;">\n'],colorStroke,thickness,dashArray);
0133 fprintf(mapHandle,'<ellipse cx="%.2f" cy="%.2f" rx="%.2f" ry="%.2f" />\n</g>\n',begPt(1,1)+(.5*sLength(1,2)),begPt(1,2)+(.5*sLength(1,1)),.5*sLength(1,2),.5*sLength(1,1));
0134 otherwise
0135 display('Error: Unknown Shape Type');
0136 end
0137
0138 else
0139 display('Error: Invalid Output');
0140 end