📄 ezdgnlayer.pas
字号:
{ }
FDGNInputStream.Read( b, SizeOf( b ) );
align := b;
Case b Of
0, 1, 2: TextAlign := taLeftJustify;
6, 7, 8: TextAlign := taCenter;
12, 13, 14: TextAlign := taRightJustify;
End;
FDGNInputStream.Read( l, SizeOf( l ) );
lngthmult := LSwap( l ) * FScale;
FDGNInputStream.Read( l, SizeOf( l ) );
hgntmult := LSwap( l ) * FScale;
If FDGN_TCB.Dimension = 2 Then
Begin
FDGNInputStream.Read( l, SizeOf( l ) );
rotation := LSwap( l ) / 360000;
FDGNInputStream.Read( p2d, SizeOf( p2d ) );
Fp.X := LSwap( P2D.X );
Fp.Y := LSwap( P2D.Y );
Fp.X := Fp.X * FScale;
Fp.Y := Fp.Y * FScale;
End
Else If FDGN_TCB.Dimension = 3 Then
Begin
FDGNInputStream.Read( l, SizeOf( l ) );
FDGNInputStream.Read( l, SizeOf( l ) );
FDGNInputStream.Read( l, SizeOf( l ) );
FDGNInputStream.Read( l, SizeOf( l ) );
FDGNInputStream.Read( p3d, SizeOf( p3d ) );
Fp.X := LSwap( P3D.X );
Fp.Y := LSwap( P3D.Y );
_3Dz := LSwap( P3D.Z );
Fp.X := Fp.X * FScale;
Fp.Y := Fp.Y * FScale;
_3Dz := _3Dz * FScale;
End
Else
Exit;
str := '';
FDGNInputStream.Read( b, SizeOf( b ) );
If b <> 0 Then
Begin
FDGNInputStream.Position := FDGNInputStream.Position + 1;
For l := 0 To b Do
FDGNInputStream.Read( str[l], SizeOf( Byte ) );
str[b] := #0;
TextEntityHeight := hgntmult * FHeightQuotient;
TextWidth := lngthmult * FHeightQuotient;
TextEntityPoint.X := Fp.X;
TextEntityPoint.Y := Fp.Y + TextEntityHeight;
TextEntityPoint := Compareboundary( TextEntityPoint );
{ if p < NextEleOfNode then
TextEntityHeight := TextEntityHeight + NodeLineSpc
else
TextEntityHeight := TextEntityHeight + TextEntityHeight * 0.35;
}
rotation := ( Trunc( rotation * 100 ) Mod 36000 ) / 100;
RadRotation := DegToRad( rotation );
If ( rotation = 0 ) Then
Else If ( rotation > 0 ) And ( rotation < 90 ) Then
Begin
TextEntityPoint.X := TextEntityPoint.X - Sin( RadRotation ) * TextEntityHeight;
TextEntityPoint.Y := TextEntityPoint.Y - ( 1 - Cos( RadRotation ) ) * TextEntityHeight;
End
Else If ( rotation = 90 ) Then
Begin
TextEntityPoint.X := TextEntityPoint.X - TextEntityHeight;
TextEntityPoint.Y := TextEntityPoint.Y - TextEntityHeight;
End
Else If ( rotation > 90 ) And ( rotation < 180 ) Then
Begin
TextEntityPoint.X := TextEntityPoint.X - Cos( RadRotation - PI / 2 ) * TextEntityHeight;
TextEntityPoint.Y := TextEntityPoint.Y - TextEntityHeight;
TextEntityPoint.Y := TextEntityPoint.Y - Sin( RadRotation - PI / 2 ) * TextEntityHeight;
End
Else If ( rotation = 180 ) Then
Begin
TextEntityPoint.Y := TextEntityPoint.Y - TextEntityHeight * 2;
End
Else If ( rotation > 180 ) And ( rotation < 270 ) Then
Begin
TextEntityPoint.X := TextEntityPoint.X + Sin( RadRotation - PI ) * TextEntityHeight;
TextEntityPoint.Y := TextEntityPoint.Y - TextEntityHeight;
TextEntityPoint.Y := TextEntityPoint.Y - Cos( RadRotation - PI ) * TextEntityHeight;
End
Else If ( rotation = 270 ) Then
Begin
TextEntityPoint.X := TextEntityPoint.X + TextEntityHeight;
TextEntityPoint.Y := TextEntityPoint.Y - TextEntityHeight;
End
Else If ( rotation > 270 ) And ( rotation < 360 ) Then
Begin
TextEntityPoint.X := TextEntityPoint.X + Cos( RadRotation - PI * ( 3 / 2 ) ) * TextEntityHeight;
TextEntityPoint.Y := TextEntityPoint.Y - TextEntityHeight;
TextEntityPoint.Y := TextEntityPoint.Y + Sin( RadRotation - PI * ( 3 / 2 ) ) * TextEntityHeight;
End;
TextEntityPoint := CompareBoundary( TextEntityPoint );
If FUseTrueType Then
Begin
Result := TEzTrueTypeText.CreateEntity( TextEntityPoint, str,
TextEntityHeight, RadRotation );
with TEzTrueTypeText( Result ) do
begin
BeginUpdate;
PenTool.style := 0;
BrushTool.pattern := 0;
Fonttool.Assign(Ez_Preferences.DefTTFontStyle);
Fonttool.Height:= TextEntityHeight;
Fonttool.Color := curpen.color;
Fonttool.Angle:= RadRotation;
EndUpdate;
end;
End Else
Begin
Result := TEzFittedVectorText.CreateEntity(
TextEntityPoint, str, TextEntityHeight, TextWidth, RadRotation );
{ Result.FBox.Emin.X := lswap(Elm_hdr.xLow);
Result.FBox.Emin.Y := lswap(Elm_hdr.yLow);
Result.FBox.Emax.X := lswap(Elm_hdr.xHigh);
Result.FBox.Emax.Y := lswap(Elm_hdr.yHigh);
}
TEzJustifVectorText( Result ).FontColor := curpen.Color;
//TEzJustifVectorText(Result).Alignment := TextAlign;
TEzJustifVectorText( Result ).FontName := Ez_VectorFonts.DefaultFont.Name; //'Courier New';
End;
EntityCreated := True;
End;
End; { end of case 17 }
15:
Begin
element_str := 'Ellipse';
FDGNInputStream.Read( Disp_hdr, SizeOf( Disp_Hdr ) );
EvaluateDisp_Hdr( Disp_Hdr, curPen, curbrush );
If ( Disp_Hdr.props And $2000 ) = 0 Then {Check for Planar, 乞搁牢啊? 0 = 乞搁, 1 = 厚乞搁 }
PlanOfEle := 2
Else
PlanOfEle := 3;
FDGNInputStream.Read( byte8, SizeOf( byte8 ) );
vax2ieee( @Byte8 );
primary := Byte8 * FScale;
FDGNInputStream.Read( byte8, SizeOf( byte8 ) );
vax2ieee( @Byte8 );
secondary := Byte8 * FScale;
If FDGN_TCB.Dimension = 2 Then
Begin
FDGNInputStream.Read( l, SizeOf( l ) );
//rotation := DegToRad(LSwap(l) / 360000);
// 盔痢
FDGNInputStream.Read( Byte8, SizeOf( Byte8 ) );
vax2ieee( @Byte8 );
origin.X := Byte8 * FScale;
FDGNInputStream.Read( Byte8, SizeOf( Byte8 ) );
vax2ieee( @Byte8 );
origin.Y := Byte8 * FScale;
End
Else If FDGN_TCB.Dimension = 3 Then
Begin
// 荤盒搁 雀傈
FDGNInputStream.Read( l, SizeOf( l ) );
FDGNInputStream.Read( l, SizeOf( l ) );
FDGNInputStream.Read( l, SizeOf( l ) );
FDGNInputStream.Read( l, SizeOf( l ) );
//
FDGNInputStream.Read( Byte8, SizeOf( Byte8 ) );
vax2ieee( @Byte8 );
origin.X := Byte8 * FScale;
FDGNInputStream.Read( Byte8, SizeOf( Byte8 ) );
vax2ieee( @Byte8 );
origin.Y := Byte8 * FScale;
FDGNInputStream.Read( Byte8, SizeOf( Byte8 ) );
vax2ieee( @Byte8 );
_3Dz := Byte8 * FScale;
End
Else
Exit;
EllipRec := GetRect2DFromEllip( primary, secondary, origin );
EllipRec.Emin := CompareBoundary( EllipRec.Emin );
EllipRec.Emax := CompareBoundary( EllipRec.Emax );
Result := TEzEllipse.CreateEntity( EllipRec.Emin, EllipRec.Emax );
EntityCreated := True;
End;
16:
Begin
element_str := 'Arc';
FDGNInputStream.Read( Disp_hdr, SizeOf( Disp_Hdr ) );
EvaluateDisp_Hdr( Disp_Hdr, curPen, curbrush );
If ( Disp_Hdr.props And $2000 ) = 0 Then {Check for Planar, 乞搁牢啊? 0 = 乞搁, 1 = 厚乞搁 }
PlanOfEle := 2
Else
PlanOfEle := 3;
//
FDGNInputStream.Read( l, SizeOf( l ) );
Startang := DegToRad( LSwap( l ) / 360000 );
FDGNInputStream.Read( l, SizeOf( l ) );
//sweepang := DegToRad( LSwap( l ) / 360000 );
if (TLA(l)[2] And $80) <> 0 then
begin
TLA(l)[2] := TLA(l)[2] And $7F;
nSweepVal := -1 * LSwap( l );
end
else
begin
nSweepVal := LSwap( l );
end;
if nSweepVal = 0 then
sweepang := 360.0
else
sweepang := nSweepVal / 360000.0;
sweepang := DegToRad( sweepang );
//
FDGNInputStream.Read( byte8, SizeOf( byte8 ) );
vax2ieee( @Byte8 );
primary := Byte8 * FScale;
//
FDGNInputStream.Read( byte8, SizeOf( byte8 ) );
vax2ieee( @Byte8 );
secondary := Byte8 * FScale;
If FDGN_TCB.Dimension = 2 Then
Begin
//
FDGNInputStream.Read( l, SizeOf( l ) );
rotation := LSwap(l) / 360000.0;
RadRotation := DegToRad( rotation );
//
FDGNInputStream.Read( Byte8, SizeOf( Byte8 ) );
vax2ieee( @Byte8 );
origin.X := Byte8 * FScale;
FDGNInputStream.Read( Byte8, SizeOf( Byte8 ) );
vax2ieee( @Byte8 );
origin.Y := Byte8 * FScale;
Startang := Startang + RadRotation;
End
Else If FDGN_TCB.Dimension = 3 Then
Begin
//
FDGNInputStream.Read( l, SizeOf( l ) );
FDGNInputStream.Read( l, SizeOf( l ) );
FDGNInputStream.Read( l, SizeOf( l ) );
FDGNInputStream.Read( l, SizeOf( l ) );
// 盔痢
FDGNInputStream.Read( Byte8, SizeOf( Byte8 ) );
vax2ieee( @Byte8 );
origin.X := Byte8 * FScale;
FDGNInputStream.Read( Byte8, SizeOf( Byte8 ) );
vax2ieee( @Byte8 );
origin.Y := Byte8 * FScale;
FDGNInputStream.Read( Byte8, SizeOf( Byte8 ) );
vax2ieee( @Byte8 );
_3Dz := Byte8 * FScale;
End
Else
Exit;
// circular arcs only
If primary = secondary Then
Begin
EllipRec := GetRect2DFromEllip( primary, secondary, origin );
EllipRec.Emin := CompareBoundary( EllipRec.Emin );
EllipRec.Emax := CompareBoundary( EllipRec.Emax );
origin := CompareBoundary( origin );
Result := TEzArc.CreateEntity( Point2D( 0, 0 ), Point2D( 0, 0 ), Point2D( 0, 0 ) );
TEzArc( Result ).SetArc( origin.X, origin.Y, primary, Startang, sweepang, true );
EntityCreated := True;
End;
End;
End; { end of case }
If EntityCreated Then
Begin
If Result.Points.Count > 0 Then
Begin
If Result.EntityID In [idPolyline,idPolygon,idRectangle,idArc,idEllipse,idSpline,idSplineText] Then
Begin
If Result Is TEzOpenedEntity Then
TEzOpenedEntity( Result ).Pentool.FPenstyle := curPen;
If Result Is TEzClosedEntity Then
TEzClosedEntity( Result ).Brushtool.FBrushStyle := curbrush;
End;
End;
End;
End;
function TEzDGNFile.GetRecordCount: Integer;
begin
If FMemoryLoaded then
Result:= FElements.Count
else
Result:= FOffsets.Count;
end;
function TEzDGNFile.GetIncludedLevels(Index: Integer): Boolean;
begin
Result:= False;
If (Index < 0) Or (Index > 63) then Exit;
Result:= FIncludedLevels[Index];
end;
procedure TEzDGNFile.SetIncludedLevels(Index: Integer;
const Value: Boolean);
begin
If (Index < 0) Or (Index > 63) then Exit;
FIncludedLevels[Index]:= Value;
end;
Type
{-----------------------------------------------------------------------------}
// a bookmark for DGN layers
{-----------------------------------------------------------------------------}
TEzDGNBookmark = class
private
FRecno: Integer;
FFiltered: Boolean;
FEofCrack: Boolean;
FFilterRecno: Integer;
Fol: TIntegerList;
Public
constructor Create;
destructor Destroy; Override;
end;
{ TEzDGNBookmark }
constructor TEzDGNBookmark.Create;
begin
inherited Create;
Fol:= TIntegerList.Create;
end;
destructor TEzDGNBookmark.Destroy;
begin
Fol.Free;
inherited Destroy;
end;
{-------------------------------------------------------------------------------}
{ TDGNLayerInfo - class implementation }
{-------------------------------------------------------------------------------}
Function TDGNLayerInfo.GetIsCosmethic: boolean;
Begin
result := TDGNLayer( FLayer ).FHeader.IsMemoryLayer;
End;
Procedure TDGNLayerInfo.SetIsCosmethic( value: boolean );
Begin
If TDGNLayer( FLayer ).FHeader.IsMemoryLayer = value Then Exit;
TDGNLayer( FLayer ).FHeader.IsMemoryLayer := value;
End;
Function TDGNLayerInfo.GetLocked: Boolean;
Begin
result := TDGNLayer( FLayer ).FHeader.Locked;
End;
Procedure TDGNLayerInfo.SetLocked( Value: Boolean );
Begin
TDGNLayer( FLayer ).FHeader.Locked := Value;
End;
Function TDGNLayerInfo.GetUseAttachedDB: boolean;
Begin
result := TDGNLayer( FLayer ).FHeader.UseAttachedDB;
End;
Procedure TDGNLayerInfo.SetUseAttachedDB( Value: boolean );
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -