📄 ezmiscelentities.pas
字号:
Function BasicInfoAsString: string; Override;
Public
Constructor CreateEntity(TrueType: Boolean; const SplineText: string );
destructor Destroy; Override;
procedure Initialize; Override;
Procedure LoadFromStream( Stream: TStream ); Override;
Procedure SaveToStream( Stream: TStream ); Override;
Procedure Draw( Grapher: TEzGrapher; Canvas: TCanvas; Const Clip: TEzRect;
DrawMode: TEzDrawMode; Data: Pointer = Nil ); Override;
Function StorageSize: Integer; Override;
Procedure UpdateExtension; Override;
Function PointCode( Const Pt: TEzPoint;
Const Aperture: Double;
Var Distance: Double;
SelectPickingInside: Boolean; UseDrawPoints: Boolean=True ): Integer; Override;
Function IsEqualTo( Entity: TEzEntity; IncludeAttribs: Boolean = false ): Boolean; Override;
Property FontTool: TEzFontTool Read GetFontTool;
Property Text: String {$IFDEF BCB} Read GetText Write SetText {$ELSE} Read FText Write FText {$ENDIF};
Property CharSpacing: Double {$IFDEF BCB} Read GetCharSpacing Write SetCharSpacing {$ELSE} Read FCharSpacing Write FCharSpacing {$ENDIF};
Property UseTrueType: Boolean {$IFDEF BCB} read GetUseTrueType {$ELSE} read FUseTrueType {$ENDIF} write SetUseTrueType;
Property Fitted: Boolean {$IFDEF BCB} read GetFitted write SetFitted {$ELSE} read FFitted write FFitted {$ENDIF};
Property UsePointsAsPath: Boolean {$IFDEF BCB} read GetUsePointsAsPath write SetUsePointsAsPath {$ELSE} read FUsePointsAsPath write FUsePointsAsPath {$ENDIF};
Property ShowSpline: Boolean {$IFDEF BCB} read GetShowSpline write SetShowSpline {$ELSE} read FShowSpline write FShowSpline {$ENDIF};
End;
Implementation
Uses
Math, EzGraphics, EzSystem, EzConsts, EzBasicCtrls, EzLineDraw, EzStrArru,
EzPreview, EzMiscelCtrls, EzBaseExpr;
{------------------------------------------------------------------------------}
{ TEzPreviewEntity - preview / printing entity }
{------------------------------------------------------------------------------}
Constructor TEzPreviewEntity.CreateEntity( Const p1, p2: TEzPoint;
PrintMode: TEzPrintMode; FileNo: Integer );
Begin
Inherited CreateEntity( p1, p2 );
FFileNo := FileNo;
FPrintMode := PrintMode;
FPrintFrame := True;
End;
Function TEzPreviewEntity.GetEntityID: TEzEntityID;
Begin
result := idPreview;
End;
Function TEzPreviewEntity.BasicInfoAsString: string;
Begin
With FProposedPrintArea do
Result:= Format(sPreviewInfo, [FPoints.AsString,FFileNo,FPlottedUnits,
FDrawingUnits,EzBaseExpr.NBoolean[FPrintFrame], X1,Y1,X2,Y2]);
End;
Function TEzPreviewEntity.GetGIS: TEzBaseGIS;
var
pb: TEzPreviewBox;
I: Integer;
Begin
Result := Nil;
If (PainterObject = Nil) Or (PainterObject.SourceGis=Nil) Then Exit;
{ debido a esto, solo se pueden colocar entidades TEzPreviewEntity en un
control TEzPreviewBox }
pb:= Nil;
for I:= 0 to PainterObject.SourceGis.DrawBoxList.Count-1 do
if PainterObject.SourceGis.DrawBoxList[I] is TEzPreviewBox then
begin
pb:= PainterObject.SourceGis.DrawBoxList[I] as TEzPreviewBox;
Break;
end;
if pb = Nil then Exit;
With pb Do
Begin
If ( FFileNo < 0 ) Or ( FFileNo > GISList.Count - 1 ) Then Exit;
Result := GISList[FFileNo].GIS;
If EqualRect2D( FProposedPrintArea, NULL_EXTENSION ) Then
FProposedPrintArea := Result.MapInfo.LastView;
End;
End;
{$IFDEF BCB}
function TEzPreviewEntity.GetCalculatedPrintArea: TEzRect;
begin
Result := FCalculatedPrintArea;
end;
function TEzPreviewEntity.GetDrawingUnits: Double;
begin
Result := FDrawingUnits;
end;
function TEzPreviewEntity.GetFileNo: Integer;
begin
Result := FFileNo;
end;
function TEzPreviewEntity.GetPaperUnits: TEzScaleUnits;
begin
Result := FPaperUnits;
end;
function TEzPreviewEntity.GetPlottedUnits: Double;
begin
Result := FplottedUnits;
end;
function TEzPreviewEntity.GetPresentation: TEzPreviewPresentation;
begin
Result := FPresentation;
end;
function TEzPreviewEntity.GetPrintFrame: Boolean;
begin
Result := FPrintFrame;
end;
function TEzPreviewEntity.GetPrintMode: TEzPrintMode;
begin
Result := FPrintMode;
end;
function TEzPreviewEntity.GetProposedPrintArea: TEzRect;
begin
Result := FProposedPrintArea;
end;
function TEzPreviewEntity.GetSelection: TEzSelection;
begin
Result := FSelection;
end;
procedure TEzPreviewEntity.SetCalculatedPrintArea(const Value: TEzRect);
begin
FCalculatedPrintArea := Value;
end;
procedure TEzPreviewEntity.SetDrawingUnits(const Value: Double);
begin
FDrawingUnits := Value;
end;
procedure TEzPreviewEntity.SetFileNo(const Value: Integer);
begin
FFileNo := Value;
end;
procedure TEzPreviewEntity.SetPaperUnits(const Value: TEzScaleUnits);
begin
FPaperUnits := Value;
end;
procedure TEzPreviewEntity.SetPlottedUnits(const Value: Double);
begin
FPlottedUnits := Value;
end;
procedure TEzPreviewEntity.SetPresentation(
const Value: TEzPreviewPresentation);
begin
FPresentation := Value;
end;
procedure TEzPreviewEntity.SetPrintFrame(const Value: Boolean);
begin
FPrintFrame := Value;
end;
procedure TEzPreviewEntity.SetPrintMode(const Value: TEzPrintMode);
begin
FPrintMode := Value;
end;
procedure TEzPreviewEntity.SetProposedPrintArea(const Value: TEzRect);
begin
FProposedPrintArea := Value;
end;
procedure TEzPreviewEntity.SetSelection(const Value: TEzSelection);
begin
FSelection := Value;
end;
{$ENDIF}
Procedure TEzPreviewEntity.CalculateScales( Const WindowToFit: TEzRect );
Var
PaperAreaWidth, PaperAreaHeight: Double;
inchesX, inchesY: Double;
mmsX, mmsY: Double;
cmsX, cmsY: Double;
DX, DY: Double;
Begin
FProposedPrintArea := WindowToFit;
With FProposedPrintArea Do
If ( Emin.X >= Emax.X ) Or ( Emin.Y >= Emax.Y ) Then
Begin
MessageToUser( SBadExtension, smsgerror, MB_ICONERROR );
Exit;
End;
inchesX := Abs( FPoints[1].X - FPoints[0].X );
inchesY := Abs( FPoints[1].Y - FPoints[0].Y );
If FPaperUnits = suMms Then
Begin
inchesX := inchesX / 25.4;
inchesY := inchesY / 25.4;
End Else If FPaperUnits = suCms Then
Begin
inchesX := inchesX / 2.54;
inchesY := inchesY / 2.54;
End;
mmsX := inchesX * 25.4;
mmsY := inchesY * 25.4;
cmsX := inchesX * 2.54;
cmsY := inchesY * 2.54;
PaperAreaWidth := inchesX;
PaperAreaHeight := inchesY;
If FPaperUnits = suMms Then
Begin
PaperAreaWidth := mmsX;
PaperAreaHeight := mmsY;
End Else If FPaperUnits = suCms Then
Begin
PaperAreaWidth := cmsX;
PaperAreaHeight := cmsY;
End;
With FProposedPrintArea Do
Begin
DX := Emax.X - Emin.X;
DY := Emax.Y - Emin.Y;
End;
FDrawingUnits := dMax( DX, DY );
FPlottedUnits := dMin( PaperAreaWidth, PaperAreaHeight );
End;
Procedure TEzPreviewEntity.Draw( Grapher: TEzGrapher; Canvas: TCanvas;
Const Clip: TEzRect; DrawMode: TEzDrawMode; Data: Pointer = Nil );
Begin
//if (Grapher.Device= adScreen) or FPrintFrame then
Inherited Draw( Grapher, Canvas, Clip, DrawMode );
If ( DrawMode In [dmRubberPen, dmSelection] ) Or ( GIS = Nil ) Then Exit;
If Grapher.Device = adScreen Then
Preview( Grapher, Canvas, Clip )
Else
Print( Grapher, Clip );
End;
Procedure TEzPreviewEntity.Preview( Grapher: TEzGrapher; Canvas: TCanvas;
Const Clip: TEzRect );
Var
DrawingScale, PaperAreaHeight, PaperAreaWidth: Double;
TmpX1, TmpY1, TmpX2, TmpY2: Double;
TmpBox, VisualWindow, VPArea: TEzRect;
TmpGrapher: TEzGrapher;
TmpRect: Windows.TRect;
Clipped: Boolean;
Begin
If ( FDrawingUnits = 0 ) Or ( fPlottedUnits = 0 ) Then Exit;
With TmpBox Do
Begin
Emin.X := dMin( FPoints[0].X, FPoints[1].X );
Emin.Y := dMin( FPoints[0].Y, FPoints[1].Y );
Emax.X := dMax( FPoints[0].X, FPoints[1].X );
Emax.Y := dMax( FPoints[0].Y, FPoints[1].Y );
End;
TmpRect := ReorderRect( Grapher.RealToRect( FPoints.Extension ) );
InflateRect( TmpRect, -1, -1 );
If FPresentation = ppDraft Then
Begin
Canvas.Font.Handle := EzSystem.DefaultFontHandle;
DrawText( Canvas.Handle, PChar( Format( '<%s>', [GIS.FileName] ) ), -1, TmpRect,
DT_SINGLELINE Or DT_CENTER Or DT_VCENTER );
Exit;
End;
DrawingScale := FDrawingUnits / FPlottedUnits;
PaperAreaWidth := Abs( TmpBox.Emax.X - TmpBox.Emin.X );
PaperAreaHeight := Abs( TmpBox.Emax.Y - TmpBox.Emin.Y );
//TmpMinDrawLimit := Globalinfo.GlobalParams.MinDrawLimit;
//Globalinfo.GlobalParams.MinDrawLimit := 0;
TmpGrapher := TEzGrapher.Create( 10, adScreen );
Try
With TmpRect Do
TmpGrapher.SetViewport( Left, Top, Right, Bottom );
FProposedPrintArea := ReorderRect2D( FProposedPrintArea );
FCalculatedPrintArea := FProposedPrintArea;
With FCalculatedPrintArea Do
Begin
TmpX1 := Emin.X;
TmpY2 := Emax.Y;
TmpX2 := TmpX1 + PaperAreaWidth * DrawingScale;
TmpY1 := TmpY2 - PaperAreaHeight * DrawingScale;
End;
With FCalculatedPrintArea Do
Begin // mark the calculated visual window
Emin.X := TmpX1;
Emin.Y := TmpY1;
Emax.X := TmpX2;
Emax.Y := TmpY2;
End;
TmpGrapher.SetWindow( TmpX1, TmpX2, TmpY1, TmpY2 );
TmpGrapher.SetViewTo( FCalculatedPrintArea ); //move screen to center!
VisualWindow := TmpGrapher.CurrentParams.VisualWindow;
// Now calculate the DrawBox rect in TEzPreviewEntity coordinates
VPArea := TmpGrapher.RectToReal( Grapher.RealToRect( Clip ) );
Clipped := FALSE;
With VisualWindow Do
Begin
If Emin.X < VPArea.Emin.X Then
Begin
Emin.X := VPArea.Emin.X;
Clipped := TRUE;
End;
If Emin.Y < VPArea.Emin.Y Then
Begin
Emin.Y := VPArea.Emin.Y;
Clipped := TRUE;
End;
If Emax.X > VPArea.Emax.X Then
Begin
Emax.X := VPArea.Emax.X;
Clipped := TRUE;
End;
If Emax.Y > VPArea.Emax.Y Then
Begin
Emax.Y := VPArea.Emax.Y;
Clipped := TRUE;
End;
End;
If Not Clipped Then
Begin
TmpRect := TmpGrapher.RealToRect( VisualWindow );
With TmpRect Do
TmpGrapher.CanvasRegionStacker.Push( Canvas, CreateRectRgn( Left, Top, Right, Bottom ) );
End;
With TEzPainterObject.Create( Nil ) Do
Try
DrawEntities( VisualWindow,
GIS,
Canvas,
TmpGrapher,
FSelection,
FALSE,
FALSE,
FPrintMode,
Self.PainterObject.SourceGis.DrawBoxList[0].ScreenBitmap );
Finally
free;
End;
Finally
TmpGrapher.CanvasRegionStacker.PopAll( Canvas );
TmpGrapher.Free;
End;
End;
{print the drawing}
Procedure TEzPreviewEntity.Print( Grapher: TEzGrapher; Const Clip: TEzRect );
Var
VPArea: TEzRect;
DrawingScale: Double;
PaperAreaHeight, PaperAreaWidth: Double;
TmpX1, TmpY1, TmpX2, TmpY2: Double;
TmpBox, VisualWindow: TEzRect;
PrinterGrapher: TEzGrapher;
TmpShowText, Clipped: Boolean;
TmpMinDrawLimit: Integer;
PrinterAreaRect, R: TRect;
{$IFDEF TRIAL_VERSION}
LogRec: TLOGFONT;
OldFont, NewFont: HFONT;
OldAlign: Integer;
{$ENDIF}
Begin
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -