📄 ezmiscelentities.pas
字号:
Unit EzMiscelEntities;
{***********************************************************}
{ EzGIS/CAD Components }
{ (c) 2003 EzSoft Engineering }
{ All Rights Reserved }
{***********************************************************}
{$I EZ_FLAG.PAS}
Interface
Uses
Controls, SysUtils, Classes, Windows, Graphics, Printers,
EzLib, EzBase, EzBaseGIS, EzEntities
{$IFDEF USE_RICHEDIT}
, ComCtrls, RichEdit
{$ENDIF}
;
Type
{------------------------------------------------------------------------------}
{ TEzPreviewEntity - Preview / Printing of the drawing }
{------------------------------------------------------------------------------}
TEzPreviewEntity = Class( TEzRectangle )
Private
FFileNo: Integer; { The Index on the list TEzPreviewBox.GisList }
FPlottedUnits: Double; { FPlottedUnits = FDrawingUnits }
FDrawingUnits: Double; { Example: 10 MMs = 1 meter }
FPaperUnits: TEzScaleUnits; { MMs CMs or INCHes }
FPrintMode: TEzPrintMode;
FPresentation: TEzPreviewPresentation;
FSelection: TEzSelection;
FPrintFrame: Boolean;
{ the proposed area to print }
FProposedPrintArea: TEzRect;
{ Calculated extension to print }
FCalculatedPrintArea: TEzRect;
Function GetGIS: TEzBaseGIS;
Procedure Preview( Grapher: TEzGrapher; Canvas: TCanvas; Const Clip: TEzRect );
Procedure Print( Grapher: TEzGrapher; Const Clip: TEzRect );
{$IFDEF BCB}
function GetCalculatedPrintArea: TEzRect;
function GetDrawingUnits: Double;
function GetFileNo: Integer;
function GetPaperUnits: TEzScaleUnits;
function GetPlottedUnits: Double;
function GetPresentation: TEzPreviewPresentation;
function GetPrintFrame: Boolean;
function GetPrintMode: TEzPrintMode;
function GetProposedPrintArea: TEzRect;
function GetSelection: TEzSelection;
procedure SetCalculatedPrintArea(const Value: TEzRect);
procedure SetDrawingUnits(const Value: Double);
procedure SetFileNo(const Value: Integer);
procedure SetPaperUnits(const Value: TEzScaleUnits);
procedure SetPlottedUnits(const Value: Double);
procedure SetPresentation(const Value: TEzPreviewPresentation);
procedure SetPrintFrame(const Value: Boolean);
procedure SetPrintMode(const Value: TEzPrintMode);
procedure SetProposedPrintArea(const Value: TEzRect);
procedure SetSelection(const Value: TEzSelection);
{$ENDIF}
Protected
Function GetEntityID: TEzEntityID; Override;
Function BasicInfoAsString: string; Override;
Public
{ methods }
Constructor CreateEntity( Const p1, p2: TEzPoint;
PrintMode: TEzPrintMode; FileNo: Integer );
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;
Procedure CalculateScales( Const WindowToFit: TEzRect );
Procedure UpdateControlPoint( Index: Integer; Const Value: TEzPoint; Grapher: TEzGrapher=Nil ); Override;
Function GetControlPoints(TransfPts: Boolean; Grapher: TEzGrapher=Nil): TEzVector; Override;
Function GetControlPointType( Index: Integer ): TEzControlPointType; Override;
Function IsEqualTo( Entity: TEzEntity; IncludeAttribs: Boolean = false): Boolean; Override;
Property GIS: TEzBaseGIS Read GetGIS;
{ The index in the list TEzPreviewBox.DrawBoxList }
Property FileNo: Integer {$IFDEF BCB} Read GetFileNo Write SetFileNo {$ELSE}Read FFileNo Write FFileNo {$ENDIF};
{ the selection used to print }
Property Selection: TEzSelection {$IFDEF BCB} Read GetSelection Write SetSelection {$ELSE} Read FSelection Write FSelection {$ENDIF};
{ units to plot... }
Property PlottedUnits: Double {$IFDEF BCB} Read GetPlottedUnits Write SetPlottedUnits {$ELSE} Read FPlottedUnits Write FPlottedUnits {$ENDIF};
{ ...correspond to drawing units }
Property DrawingUnits: Double {$IFDEF BCB} Read GetDrawingUnits Write SetDrawingUnits {$ELSE} Read FDrawingUnits Write FDrawingUnits {$ENDIF};
{ the paper units which this map was placed on a DrawBox }
Property PaperUnits: TEzScaleUnits {$IFDEF BCB} Read GetPaperUnits Write SetPaperUnits {$ELSE} Read FPaperUnits Write FPaperUnits {$ENDIF};
{ printing mode : all, selection, all but selection }
Property PrintMode: TEzPrintMode {$IFDEF BCB} Read GetPrintMode Write SetPrintMode {$ELSE} Read FPrintMode Write FPrintMode {$ENDIF};
{ print a frame around the map ? }
Property PrintFrame: Boolean {$IFDEF BCB} Read GetPrintFrame Write SetPrintFrame {$ELSE} Read FPrintFrame Write FPrintFrame {$ENDIF};
{ how the map is presented in the preview : a rectangle border or full map }
Property Presentation: TEzPreviewPresentation {$IFDEF BCB} Read GetPresentation Write SetPresentation {$ELSE} Read fPresentation Write fPresentation {$ENDIF};
{ the blue dotted rectangle on the DrawBox what u want to print }
Property ProposedPrintArea: TEzRect {$IFDEF BCB} Read GetProposedPrintArea Write SetProposedPrintArea {$ELSE} Read FProposedPrintArea Write FProposedPrintArea {$ENDIF};
{ based on ProposedPrintArea, the real extension based on scale is calculated }
Property CalculatedPrintArea: TEzRect {$IFDEF BCB} Read GetCalculatedPrintArea Write SetCalculatedPrintArea {$ELSE} Read FCalculatedPrintArea Write FCalculatedPrintArea {$ENDIF};
End;
{-------------------------------------------------------------------------------}
{ TEzTableEntity }
{-------------------------------------------------------------------------------}
TEzColumnItem = Class;
TEzColumnList = Class;
TEzTableEntity = Class;
TEzTableBorderStyle = Packed Record
Visible: Boolean;
Style: Byte;
Color: TColor;
Width: Double;
End;
TEzTitleItem = Class
Private
FColumnItem: TEzColumnItem;
FCaption: String;
FAlignment: TAlignment;
FColor: TColor;
FTransparent: Boolean;
FFont: TEzFontStyle;
Public
Constructor Create( ColumnItem: TEzColumnItem );
Property Caption: String Read FCaption Write FCaption;
Property Alignment: TAlignment Read FAlignment Write FAlignment;
Property Color: TColor Read FColor Write FColor;
Property Transparent: Boolean Read FTransparent Write FTransparent;
Property Font: TEzFontStyle Read FFont Write FFont;
End;
TEzColumnType = (ctLabel, ctColor, ctLineStyle, ctBrushStyle, ctSymbolStyle, ctBitmap );
TEzColumnItem = Class
Private
FColumnList: TEzColumnList;
FColumnType: TEzColumnType;
FStrings: TStrings;
FAlignment: TAlignment;
FColor: TColor;
FTransparent: Boolean;
FFont: TEzFontStyle;
FTitle: TEzTitleItem;
FWidth: Double;
Public
Constructor Create( ColumnList: TEzColumnList );
Destructor Destroy; Override;
Property ColumnType: TEzColumnType read FColumnType write FColumnType;
Property Strings: TStrings read FStrings;
Property Alignment: TAlignment Read FAlignment Write FAlignment;
Property Color: TColor Read FColor Write FColor;
Property Transparent: Boolean Read FTransparent Write FTransparent;
Property Font: TEzFontStyle Read FFont Write FFont;
Property Title: TEzTitleItem Read FTitle Write FTitle;
Property Width: Double Read FWidth Write FWidth;
End;
TEzColumnList = Class
Private
FItems: TList;
FTable: TEzTableEntity;
Function GetCount: Integer;
Function GetItem( Index: Integer ): TEzColumnItem;
Public
Constructor Create( Table: TEzTableEntity );
Destructor Destroy; Override;
Procedure Assign( Source: TEzColumnList );
Function Add: TEzColumnItem;
Procedure Clear;
Procedure Delete( Index: Integer );
Procedure Exchange( Index1, Index2: Integer );
function Up( Index: Integer ): Boolean;
function Down( Index: Integer ): Boolean;
Property Count: Integer Read GetCount;
Property Items[Index: Integer]: TEzColumnItem Read GetItem; Default;
End;
TEzGridOptions = Set Of ( ezgoHorzLine, ezgoVertLine );
TEzTableDrawCellEvent = Procedure( Sender: TObject; ACol, ARow: Longint;
Canvas: TCanvas; Grapher: TEzGrapher; Rect: TRect ) Of Object;
TEzTableEntity = Class( TEzRectangle )
Private
FColumns: TEzColumnList;
FOptions: TEzGridOptions;
FRowHeight: Double;
FRowCount: Integer;
FTitleHeight: Double;
FGridStyle: TEzTableBorderStyle;
FOwnerDraw: Boolean;
FBorderWidth: Double;
FDefaultDrawing: Boolean;
FLoweredColor: TColor;
FOnDrawCell: TEzTableDrawCellEvent;
Function GetColumns: TEzColumnList;
Procedure SetRowCount( Value: Integer );
{$IFDEF BCB}
function GetBorderWidth: Double;
function GetDefaultDrawing: Boolean;
function GetGridStyle: TEzTableBorderStyle;
function GetLoweredColor: TColor;
function GetOnDrawCell: TEzTableDrawCellEvent;
function GetOptions: TEzGridOptions;
function GetOwnerDraw: Boolean;
function GetRowCount: Integer;
function GetRowHeight: Double;
function GetTitleHeight: Double;
procedure SetBorderWidth(const Value: Double);
procedure SetDefaultDrawing(const Value: Boolean);
procedure SetGridStyle(const Value: TEzTableBorderStyle);
procedure SetLoweredColor(const Value: TColor);
procedure SetOnDrawCell(const Value: TEzTableDrawCellEvent);
procedure SetOptions(const Value: TEzGridOptions);
procedure SetOwnerDraw(const Value: Boolean);
procedure SetRowHeight(const Value: Double);
procedure SetTitleHeight(const Value: Double);
{$ENDIF}
Protected
Function GetEntityID: TEzEntityID; Override;
Function BasicInfoAsString: string;Override;
Public
Constructor CreateEntity( Const P1, P2: TEzPoint );
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 UpdateControlPoint( Index: Integer; Const Value: TEzPoint; Grapher: TEzGrapher=Nil ); Override;
Function GetControlPoints(TransfPts: Boolean; Grapher: TEzGrapher=Nil): TEzVector; Override;
Function GetControlPointType( Index: Integer ): TEzControlPointType; Override;
Property Columns: TEzColumnList Read GetColumns;
Property Options: TEzGridOptions {$IFDEF BCB} Read GetOptions Write SetOptions {$ELSE} Read FOptions Write FOptions {$ENDIF};
Property RowHeight: Double {$IFDEF BCB} Read GetRowHeight Write SetRowHeight {$ELSE} Read FRowHeight Write FRowHeight {$ENDIF};
Property TitleHeight: Double {$IFDEF BCB} Read GetTitleHeight Write SetTitleHeight {$ELSE} Read FTitleHeight Write FTitleHeight {$ENDIF};
Property RowCount: Integer {$IFDEF BCB} Read GetRowCount Write SetRowCount {$ELSE} Read FRowCount Write SetRowCount {$ENDIF};
Property GridStyle: TEzTableBorderStyle {$IFDEF BCB} Read GetGridStyle Write SetGridStyle {$ELSE} Read FGridStyle Write FGridStyle {$ENDIF};
Property OwnerDraw: Boolean {$IFDEF BCB} Read GetOwnerDraw Write SetOwnerDraw {$ELSE} Read FOwnerDraw Write FOwnerDraw {$ENDIF};
Property BorderWidth: Double {$IFDEF BCB} Read GetBorderWidth Write SetBorderWidth {$ELSE} Read FBorderWidth Write FBorderWidth {$ENDIF};
Property DefaultDrawing: Boolean {$IFDEF BCB} Read GetDefaultDrawing Write SetDefaultDrawing {$ELSE} Read FDefaultDrawing Write FDefaultDrawing {$ENDIF};
Property LoweredColor: TColor {$IFDEF BCB} Read GetLoweredColor Write SetLoweredColor {$ELSE} Read FLoweredColor Write FLoweredColor {$ENDIF};
Property OnDrawCell: TEzTableDrawCellEvent {$IFDEF BCB} Read GetOnDrawCell Write SetOnDrawCell {$ELSE} Read FOnDrawCell Write FOnDrawCell {$ENDIF};
End;
{-------------------------------------------------------------------------------}
// TEzRtfText
// Warning !: This entity is intended only for the preview box TEzPreviewBox
// It will not work correctly when placed on a map.
{-------------------------------------------------------------------------------}
TEzRtfText = Class( TEzClosedEntity )
Private
FLines: TStrings;
FVector: TEzVector;
Function GetLines: TStrings;
Protected
Function GetDrawPoints: TEzVector; Override;
Function GetEntityID: TEzEntityID; Override;
Public
Constructor CreateEntity( Const P1, P2: TEzPoint; Lines: TStrings );
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;
Procedure UpdateControlPoint( Index: Integer; Const Value: TEzPoint; Grapher: TEzGrapher=Nil ); Override;
Function GetControlPoints(TransfPts: Boolean; Grapher: TEzGrapher=Nil): TEzVector; Override;
Function GetControlPointType( Index: Integer ): TEzControlPointType; Override;
Property Lines: TStrings Read GetLines;
End;
{-------------------------------------------------------------------------------}
{ BlockInsert }
{-------------------------------------------------------------------------------}
TEzBlockInsert = Class( TEzEntity )
Private
{ basic data }
FBlockName: string;
FRotangle: Double;
FScaleX: Double;
FScaleY: Double;
FText: string;
FBlock: TEzSymbol;
FPreloadedSet: Boolean;
Procedure MoveAndRotateControlPts( Var MovePt, RotatePt: TEzPoint; Grapher: TEzGrapher );
function CalcBoundingBox: TEzRect;
procedure SetRotangle(const Value:Double);
procedure SetScaleX(const Value:Double);
procedure SetScaleY(const Value:Double);
Function MakePolyPoints: TEzVector;
procedure SetBlockName(const Value:string);
{$IFDEF BCB}
function GetBlockName: string;
function GetRotangle: Double;
function GetScaleX: Double;
function GetScaleY: Double;
function GetText: string;
procedure SetText(const Value: string);
{$ENDIF}
Protected
Function GetEntityID: TEzEntityID; Override;
Function BasicInfoAsString: string; Override;
Public
constructor CreateEntity(const BlockName: string;
const Pt: TEzPoint; const Rotangle, ScaleX, ScaleY: Double);
Destructor Destroy; Override;
Procedure LoadFromStream( Stream: TStream ); Override;
Procedure SaveToStream( Stream: TStream ); Override;
Function StorageSize: Integer; Override;
Procedure UpdateExtension; Override;
Procedure ApplyTransform; Override;
Procedure Draw( Grapher: TEzGrapher; Canvas: TCanvas; Const Clip: TEzRect;
DrawMode: TEzDrawMode; Data: Pointer = Nil ); Override;
Procedure UpdateControlPoint( Index: Integer; Const Value: TEzPoint; Grapher: TEzGrapher=Nil ); Override;
Function GetControlPoints(TransfPts: Boolean; Grapher: TEzGrapher=Nil): TEzVector; Override;
Function GetControlPointType( Index: Integer ): TEzControlPointType; 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;
function Block: TEzSymbol;
Property BlockName: string {$IFDEF BCB} read GetBlockName {$ELSE} read FBlockName {$ENDIF} write SetBlockName;
Property Rotangle: Double {$IFDEF BCB} read GetRotangle {$ELSE} read FRotangle {$ENDIF} write SetRotangle;
Property ScaleX: Double {$IFDEF BCB} read GetScaleX {$ELSE} read FScaleX {$ENDIF} write SetScaleX;
Property ScaleY: Double {$IFDEF BCB} read GetScaleY {$ELSE} read FScaleY {$ENDIF} write SetScaleY;
Property Text: string {$IFDEF BCB} read GetText write SetText {$ELSE} read FText write FText {$ENDIF};
End;
{-------------------------------------------------------------------------------}
// TEzSplineText
{-------------------------------------------------------------------------------}
TEzSplineText = Class( TEzSpline )
Private
FText: AnsiString;
FFontTool: TEzFontTool;
FCharSpacing: Double;
FUseTrueType: Boolean;
FFitted: Boolean;
{ if true, the polyline is used as the path for the text}
FUsePointsAsPath: Boolean;
FShowSpline: Boolean;
function GetFontTool: TEzFontTool;
procedure SetUseTrueType(const Value: Boolean);
procedure DrawTrueType(Grapher: TEzGrapher; Canvas: TCanvas;
const Clip: TEzRect; DrawMode: TEzDrawMode);
procedure DrawVectorial(Grapher: TEzGrapher; Canvas: TCanvas;
const Clip: TEzRect; DrawMode: TEzDrawMode);
{$IFDEF BCB}
function GetCharSpacing: Double;
function GetFitted: Boolean;
function GetShowSpline: Boolean;
function GetText: String;
function GetUsePointsAsPath: Boolean;
function GetUseTrueType: Boolean;
procedure SetCharSpacing(const Value: Double);
procedure SetFitted(const Value: Boolean);
procedure SetShowSpline(const Value: Boolean);
procedure SetText(const Value: String);
procedure SetUsePointsAsPath(const Value: Boolean);
{$ENDIF}
Protected
Function GetEntityID: TEzEntityID; Override;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -