Starts implementing text support

git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@1473 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
sekelsenmat 2011-01-30 15:35:48 +00:00
parent 21518cb872
commit 0c5b5b1913
3 changed files with 36 additions and 11 deletions

View File

@ -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;

View File

@ -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(':<DrawFPVectorialToCanvas');
{$endif}

View File

@ -61,6 +61,8 @@ object frmFPVViewer: TfrmFPVViewer
Height = 23
Top = 99
Width = 46
MaxValue = 1000
MinValue = -1000
TabOrder = 3
end
object spinStartY: TSpinEdit
@ -68,6 +70,8 @@ object frmFPVViewer: TfrmFPVViewer
Height = 23
Top = 99
Width = 50
MaxValue = 1000
MinValue = -1000
TabOrder = 4
end
object Label3: TLabel
@ -120,8 +124,8 @@ object frmFPVViewer: TfrmFPVViewer
end
end
object Page2: TPage
ClientWidth = 1344
ClientHeight = 1252
ClientWidth = 2688
ClientHeight = 2504
object DXFTreeView: TTreeView
Left = 8
Height = 313