You've already forked lazarus-ccr
Fixes the dxftokentotree.pas performance and makes the dxf reader more powerful
git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@1472 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
@ -29,12 +29,17 @@ var
|
||||
begin
|
||||
if ATokens = nil then Exit;
|
||||
|
||||
for i := 0 to ATokens.Count - 1 do
|
||||
begin
|
||||
AToken := TDXFToken(ATokens.Items[i]);
|
||||
NodeStr := Format('(%d %s)', [AToken.GroupCode, AToken.StrValue]);
|
||||
NewNode := ATreeNodes.AddChild(ABaseNode, NodeStr);
|
||||
ConvertDXFTokensToTreeNodes(AToken.Childs, NewNode.TreeNodes, NewNode);
|
||||
ATreeNodes.BeginUpdate(); // Greatly speeds up the operation
|
||||
try
|
||||
for i := 0 to ATokens.Count - 1 do
|
||||
begin
|
||||
AToken := TDXFToken(ATokens.Items[i]);
|
||||
NodeStr := Format('(%d %s)', [AToken.GroupCode, AToken.StrValue]);
|
||||
NewNode := ATreeNodes.AddChild(ABaseNode, NodeStr);
|
||||
ConvertDXFTokensToTreeNodes(AToken.Childs, NewNode.TreeNodes, NewNode);
|
||||
end;
|
||||
finally
|
||||
ATreeNodes.EndUpdate();
|
||||
end;
|
||||
end;
|
||||
|
||||
|
@ -67,8 +67,12 @@ type
|
||||
TvDXFVectorialReader = class(TvCustomVectorialReader)
|
||||
private
|
||||
FPointSeparator: TFormatSettings;
|
||||
// HEADER data
|
||||
ANGBASE: Double;
|
||||
ANGDIR: Integer;
|
||||
//
|
||||
function SeparateString(AString: string; ASeparator: Char): T10Strings;
|
||||
procedure ReadHEADER(ATokens: TDXFTokens; AData: TvVectorialDocument);
|
||||
procedure ReadENTITIES(ATokens: TDXFTokens; AData: TvVectorialDocument);
|
||||
procedure ReadENTITIES_LINE(ATokens: TDXFTokens; AData: TvVectorialDocument);
|
||||
procedure ReadENTITIES_ARC(ATokens: TDXFTokens; AData: TvVectorialDocument);
|
||||
@ -91,6 +95,12 @@ 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
|
||||
|
||||
// Group Codes for ENTITIES
|
||||
DXF_ENTITIES_TYPE = 0;
|
||||
DXF_ENTITIES_HANDLE = 5;
|
||||
@ -310,6 +320,33 @@ begin
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TvDXFVectorialReader.ReadHEADER(ATokens: TDXFTokens;
|
||||
AData: TvVectorialDocument);
|
||||
var
|
||||
i: Integer;
|
||||
CurToken: TDXFToken;
|
||||
begin
|
||||
i := 0;
|
||||
while i < ATokens.Count do
|
||||
begin
|
||||
CurToken := TDXFToken(ATokens.Items[i]);
|
||||
if CurToken.StrValue = '$ANGBASE' then
|
||||
begin
|
||||
CurToken := TDXFToken(ATokens.Items[i+1]);
|
||||
ANGBASE := StrToFloat(CurToken.StrValue, FPointSeparator);
|
||||
Inc(i);
|
||||
end
|
||||
else if CurToken.StrValue = '$ANGDIR' then
|
||||
begin
|
||||
CurToken := TDXFToken(ATokens.Items[i+1]);
|
||||
ANGDIR := StrToInt(CurToken.StrValue);
|
||||
Inc(i);
|
||||
end;
|
||||
|
||||
Inc(i);
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TvDXFVectorialReader.ReadENTITIES(ATokens: TDXFTokens; AData: TvVectorialDocument);
|
||||
var
|
||||
i: Integer;
|
||||
@ -591,6 +628,10 @@ begin
|
||||
FPointSeparator.DecimalSeparator := '.';
|
||||
FPointSeparator.ThousandSeparator := '#';// disable the thousand separator
|
||||
|
||||
// Default HEADER data
|
||||
ANGBASE := 0.0; // Starts pointing to the right / east
|
||||
ANGDIR := 0; // counter-clock wise
|
||||
|
||||
Tokenizer := TDXFTokenizer.Create;
|
||||
end;
|
||||
|
||||
@ -618,7 +659,9 @@ begin
|
||||
CurToken := TDXFToken(Tokenizer.Tokens.Items[i]);
|
||||
CurTokenFirstChild := TDXFToken(CurToken.Childs.Items[0]);
|
||||
|
||||
if CurTokenFirstChild.StrValue = 'ENTITIES' then
|
||||
if CurTokenFirstChild.StrValue = 'HEADER' then
|
||||
ReadHEADER(CurToken.Childs, AData)
|
||||
else if CurTokenFirstChild.StrValue = 'ENTITIES' then
|
||||
ReadENTITIES(CurToken.Childs, AData);
|
||||
end;
|
||||
end;
|
||||
|
@ -1,15 +1,15 @@
|
||||
object frmFPVViewer: TfrmFPVViewer
|
||||
Left = 186
|
||||
Height = 441
|
||||
Height = 473
|
||||
Top = 137
|
||||
Width = 336
|
||||
Width = 375
|
||||
Caption = 'Free Pascal Vectorial Viewer'
|
||||
ClientHeight = 441
|
||||
ClientWidth = 336
|
||||
ClientHeight = 473
|
||||
ClientWidth = 375
|
||||
LCLVersion = '0.9.31'
|
||||
object editFileName: TFileNameEdit
|
||||
Left = 8
|
||||
Height = 22
|
||||
Height = 23
|
||||
Top = 8
|
||||
Width = 304
|
||||
DialogOptions = []
|
||||
@ -31,7 +31,7 @@ object frmFPVViewer: TfrmFPVViewer
|
||||
end
|
||||
object spinScale: TFloatSpinEdit
|
||||
Left = 72
|
||||
Height = 16
|
||||
Height = 23
|
||||
Top = 72
|
||||
Width = 64
|
||||
Increment = 1
|
||||
@ -42,39 +42,39 @@ object frmFPVViewer: TfrmFPVViewer
|
||||
end
|
||||
object Label1: TLabel
|
||||
Left = 8
|
||||
Height = 17
|
||||
Height = 16
|
||||
Top = 79
|
||||
Width = 56
|
||||
Width = 47
|
||||
Caption = 'Scale by:'
|
||||
ParentColor = False
|
||||
end
|
||||
object Label2: TLabel
|
||||
Left = 8
|
||||
Height = 17
|
||||
Height = 16
|
||||
Top = 104
|
||||
Width = 73
|
||||
Width = 60
|
||||
Caption = 'Start Pos X:'
|
||||
ParentColor = False
|
||||
end
|
||||
object spinStartX: TSpinEdit
|
||||
Left = 98
|
||||
Height = 16
|
||||
Height = 23
|
||||
Top = 99
|
||||
Width = 46
|
||||
TabOrder = 3
|
||||
end
|
||||
object spinStartY: TSpinEdit
|
||||
Left = 240
|
||||
Height = 16
|
||||
Height = 23
|
||||
Top = 99
|
||||
Width = 50
|
||||
TabOrder = 4
|
||||
end
|
||||
object Label3: TLabel
|
||||
Left = 152
|
||||
Height = 17
|
||||
Height = 16
|
||||
Top = 104
|
||||
Width = 72
|
||||
Width = 60
|
||||
Caption = 'Start Pos Y:'
|
||||
ParentColor = False
|
||||
end
|
||||
@ -88,26 +88,40 @@ object frmFPVViewer: TfrmFPVViewer
|
||||
TabOrder = 5
|
||||
end
|
||||
object notebook: TNotebook
|
||||
AnchorSideRight.Control = Owner
|
||||
AnchorSideRight.Side = asrBottom
|
||||
AnchorSideBottom.Control = Owner
|
||||
AnchorSideBottom.Side = asrBottom
|
||||
Left = 0
|
||||
Height = 313
|
||||
Height = 340
|
||||
Top = 128
|
||||
Width = 336
|
||||
Width = 370
|
||||
PageIndex = 0
|
||||
Anchors = [akTop, akLeft, akRight, akBottom]
|
||||
BorderSpacing.Right = 5
|
||||
BorderSpacing.Bottom = 5
|
||||
TabOrder = 6
|
||||
TabStop = True
|
||||
object Page1: TPage
|
||||
ClientWidth = 336
|
||||
ClientHeight = 313
|
||||
ClientWidth = 370
|
||||
ClientHeight = 340
|
||||
object imageView: TImage
|
||||
AnchorSideRight.Control = Page1
|
||||
AnchorSideRight.Side = asrBottom
|
||||
AnchorSideBottom.Control = Page1
|
||||
AnchorSideBottom.Side = asrBottom
|
||||
Left = 8
|
||||
Height = 296
|
||||
Height = 327
|
||||
Top = 8
|
||||
Width = 325
|
||||
Width = 357
|
||||
Anchors = [akTop, akLeft, akRight, akBottom]
|
||||
BorderSpacing.Right = 5
|
||||
BorderSpacing.Bottom = 5
|
||||
end
|
||||
end
|
||||
object Page2: TPage
|
||||
ClientWidth = 672
|
||||
ClientHeight = 626
|
||||
ClientWidth = 1344
|
||||
ClientHeight = 1252
|
||||
object DXFTreeView: TTreeView
|
||||
Left = 8
|
||||
Height = 313
|
||||
|
@ -15,7 +15,7 @@
|
||||
<StringTable ProductVersion=""/>
|
||||
</VersionInfo>
|
||||
<BuildModes Count="1">
|
||||
<Item1 Name="Default" Default="True"/>
|
||||
<Item1 Name="default" Default="True"/>
|
||||
</BuildModes>
|
||||
<PublishOptions>
|
||||
<Version Value="2"/>
|
||||
@ -54,7 +54,7 @@
|
||||
</Units>
|
||||
</ProjectOptions>
|
||||
<CompilerOptions>
|
||||
<Version Value="9"/>
|
||||
<Version Value="10"/>
|
||||
<Target>
|
||||
<Filename Value="fpvviewer"/>
|
||||
</Target>
|
||||
|
Reference in New Issue
Block a user