Patch from bug #22042 for fpvectorial: Adds circle writing for SVG and other minor improvements

git-svn-id: trunk@37288 -
This commit is contained in:
sekelsenmat 2012-05-15 11:27:00 +00:00
parent b05ef05a04
commit 7753541bdf
2 changed files with 46 additions and 1 deletions

View File

@ -498,6 +498,7 @@ type
procedure ClearTmpPath();
procedure AppendSegmentToTmpPath(ASegment: TPathSegment);
procedure CallbackDeleteEntity(data,arg:pointer);
function GetEntityByIndex(AIndex: integer): TvEntity;
public
// Document size for page-based documents
Width, Height: Double; // in millimeters
@ -511,6 +512,7 @@ type
{ Data reading methods }
function GetEntity(ANum: Cardinal): TvEntity;
function GetEntitiesCount: Integer;
function GetLastEntity(): TvEntity;
function FindAndSelectEntity(Pos: TPoint): TvFindEntityResult;
{ Data removing methods }
procedure Clear; virtual;
@ -545,6 +547,8 @@ type
procedure AddAlignedDimension(BaseLeft, BaseRight, DimLeft, DimRight: T3DPoint);
//
function AddPoint(AX, AY, AZ: Double): TvPoint;
//
property Entities[AIndex: integer]: TvEntity read GetEntityByIndex;
end;
{@@ TvVectorialReader class reference type }
@ -1824,6 +1828,11 @@ begin
TvEntity(data).Free;
end;
function TvVectorialPage.GetEntityByIndex(AIndex: integer): TvEntity;
begin
Result:=TvEntity(FEntities.Items[AIndex]);
end;
constructor TvVectorialPage.Create(AOwner: TvVectorialDocument);
begin
inherited Create;
@ -1873,6 +1882,11 @@ begin
Result := FEntities.Count;
end;
function TvVectorialPage.GetLastEntity(): TvEntity;
begin
Result:=TvEntity(FEntities.Last);
end;
function TvVectorialPage.FindAndSelectEntity(Pos: TPoint): TvFindEntityResult;
var
lEntity: TvEntity;

View File

@ -25,6 +25,7 @@ type
procedure WriteDocumentName(AStrings: TStrings; AData: TvVectorialDocument);
procedure WritePath(AIndex: Integer; APath: TPath; AStrings: TStrings; AData: TvVectorialPage; ADoc: TvVectorialDocument);
procedure WriteText(AStrings: TStrings; lText: TvText; AData: TvVectorialPage; ADoc: TvVectorialDocument);
procedure WriteCircle(circle: TvCircle; AStrings: TStrings; AData: TvVectorialPage);
procedure WriteEntities(AStrings: TStrings; AData: TvVectorialPage; ADoc: TvVectorialDocument);
procedure ConvertFPVCoordinatesToSVGCoordinates(
const AData: TvVectorialPage;
@ -254,6 +255,35 @@ begin
AStrings.Add(TextStr + '</tspan></text>');
end;
procedure TvSVGVectorialWriter.WriteCircle(circle: TvCircle;
AStrings: TStrings; AData: TvVectorialPage);
var
cx, cy, cr, dtmp: double;
CircleStr: string;
begin
ConvertFPVCoordinatesToSVGCoordinates(
AData, circle.X, circle.Y, cx, cy);
ConvertFPVCoordinatesToSVGCoordinates(
AData, circle.Radius, 0, cr, dtmp);
CircleStr:='<circle cx="'+FloatToStr(cx,FPointSeparator)+'" cy="'+
FloatToStr(cy,FPointSeparator)+'" r="'+
FloatToStr(cr,FPointSeparator)+'"';
if circle.Pen.Style=psClear then
CircleStr:=CircleStr+' stroke="none"'
else
CircleStr:=CircleStr+' stroke="'+
'#' + FPColorToRGBHexString(circle.Pen.Color)+'"';
CircleStr:=CircleStr+' stroke-width="'+
IntToStr(circle.Pen.Width)+'"';
if circle.Brush.Style=bsClear then
CircleStr:=CircleStr+' fill="none"'
else
CircleStr:=CircleStr+' fill="'+
'#' + FPColorToRGBHexString(circle.Brush.Color)+'"';
CircleStr:=CircleStr+'/>';
AStrings.Add(CircleStr);
end;
procedure TvSVGVectorialWriter.WriteEntities(AStrings: TStrings;
AData: TvVectorialPage; ADoc: TvVectorialDocument);
var
@ -265,7 +295,8 @@ begin
lEntity := AData.GetEntity(i);
if lEntity is TPath then WritePath(i, TPath(lEntity), AStrings, AData, ADoc)
else if lEntity is TvText then WriteText(AStrings, TvText(lEntity), AData, ADoc);
else if lEntity is TvText then WriteText(AStrings, TvText(lEntity), AData, ADoc)
else if lEntity is TvCircle then WriteCircle(TvCircle(lEntity), AStrings,AData);
end;
end;