From 0c5b5b1913c9cbbe337c1149fb3fa6a5dda372f3 Mon Sep 17 00:00:00 2001 From: sekelsenmat Date: Sun, 30 Jan 2011 15:35:48 +0000 Subject: [PATCH] Starts implementing text support git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@1473 8e941d3f-bd1b-0410-a28a-d453659cc2b4 --- .../fpvectorialsrc/dxfvectorialreader.pas | 25 ++++++++++++------- .../fpvviewer/fpvectorialsrc/fpvtocanvas.pas | 14 +++++++++++ applications/fpvviewer/fpvv_mainform.lfm | 8 ++++-- 3 files changed, 36 insertions(+), 11 deletions(-) diff --git a/applications/fpvviewer/fpvectorialsrc/dxfvectorialreader.pas b/applications/fpvviewer/fpvectorialsrc/dxfvectorialreader.pas index 96d581490..02f5ab7da 100644 --- a/applications/fpvviewer/fpvectorialsrc/dxfvectorialreader.pas +++ b/applications/fpvviewer/fpvectorialsrc/dxfvectorialreader.pas @@ -95,11 +95,14 @@ implementation {$endif} const - DXF_AUTOCAD_2000_R10 = 'AC1006'; - DXF_AUTOCAD_2000_R11 = 'AC1009'; - DXF_AUTOCAD_2000_R11_and_R12 = 'AC1009'; -// DXF_AUTOCAD_2000_R11 = 'AC1009'; -// = R10, AC1009 = R11 and R12, AC1012 = R13, AC1014 = R14 + // Items in the HEADER section + + // $ACADVER + DXF_AUTOCAD_R10 = 'AC1006'; // 1988 + DXF_AUTOCAD_R11_and_R12 = 'AC1009'; // 1990 + DXF_AUTOCAD_R13 = 'AC1012'; // 1994 + DXF_AUTOCAD_R14 = 'AC1009'; // 1997 http://www.autodesk.com/techpubs/autocad/acadr14/dxf/index.htm + DXF_AUTOCAD_2000 = 'AC1500'; // 1999 http://www.autodesk.com/techpubs/autocad/acad2000/dxf/ // Group Codes for ENTITIES DXF_ENTITIES_TYPE = 0; @@ -585,8 +588,11 @@ procedure TvDXFVectorialReader.ReadENTITIES_TEXT(ATokens: TDXFTokens; var CurToken: TDXFToken; i: Integer; - PosX, PosY, PosZ: Double; - Str: string; + PosX: Double = 0.0; + PosY: Double = 0.0; + PosZ: Double = 0.0; + FontSize: Double = 10.0; + Str: string = ''; begin for i := 0 to ATokens.Count - 1 do begin @@ -594,7 +600,7 @@ begin CurToken := TDXFToken(ATokens.Items[i]); // Avoid an exception by previously checking if the conversion can be made - if CurToken.GroupCode in [10, 20, 30] then + if CurToken.GroupCode in [10, 20, 30, 40] then begin CurToken.FloatValue := StrToFloat(Trim(CurToken.StrValue), FPointSeparator); end; @@ -604,11 +610,12 @@ begin 10: PosX := CurToken.FloatValue; 20: PosY := CurToken.FloatValue; 30: PosZ := CurToken.FloatValue; + 40: FontSize := CurToken.FloatValue; end; end; // -// AData.AddEllipse(CenterX, CenterY, CenterZ, MajorHalfAxis, MinorHalfAxis, Angle); + AData.AddText(PosX, PosY, PosZ, '', Round(FontSize), Str); end; function TvDXFVectorialReader.GetCoordinateValue(AStr: shortstring): Double; diff --git a/applications/fpvviewer/fpvectorialsrc/fpvtocanvas.pas b/applications/fpvviewer/fpvectorialsrc/fpvtocanvas.pas index 8900db1b6..bd6f5aa8c 100644 --- a/applications/fpvviewer/fpvectorialsrc/fpvtocanvas.pas +++ b/applications/fpvviewer/fpvectorialsrc/fpvtocanvas.pas @@ -107,6 +107,8 @@ var CurX, CurY: Integer; // Not modified by ADestX, etc CurveLength: Integer; t: Double; + // For text + CurText: TvText; // For entities CurEntity: TvEntity; CurCircle: TvCircle; @@ -122,6 +124,7 @@ begin ADest.MoveTo(ADestX, ADestY); + // Draws all paths for i := 0 to ASource.PathCount - 1 do begin //WriteLn('i = ', i); @@ -172,6 +175,7 @@ begin end; end; + // Draws all entities for i := 0 to ASource.GetEntityCount - 1 do begin CurEntity := ASource.GetEntity(i); @@ -207,6 +211,16 @@ begin end; end; + // Draws all text + for i := 0 to ASource.GetTextCount - 1 do + begin + CurText := ASource.GetText(i); + ADest.Font.Height := Round(AmulY * CurText.FontSize); + ADest.Pen.Style := psSolid; + ADest.Pen.Color := clBlack; + ADest.TextOut(Round(CurText.X), Round(CurText.Y), CurText.Value); + end; + {$ifdef FPVECTORIALDEBUG} WriteLn(':