📄 ezentities.pas
字号:
DrawMode: TEzDrawMode; Data: Pointer = Nil ); Override;
Function PointCode( Const Pt: TEzPoint; Const Aperture: Double;
Var Distance: Double; SelectPickingInside: Boolean; UseDrawPoints: Boolean = True ): Integer; Override;
Procedure InternalClearList;
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 GroupType: TEzGroupType {$IFDEF BCB} Read GetGroupType Write SetGroupType {$ELSE} Read FGroupType Write FGroupType {$ENDIF};
Property Entities[Index: Integer]: TEzEntity Read GetEntities;
End;
{-------------------------------------------------------------------------------}
{ Vectorial fonts }
{-------------------------------------------------------------------------------}
{ one single character
Every single character is enclosed in a (0,0) to (1,1) unit
coordinates in order to support transformation }
TEzVectorChar = Class
Private
{ A multi-part vector is used }
FVector: TEzVector;
{ the extension of the character }
FExtension: TEzRect;
Public
{ pass the number of vectors to create on start up }
Constructor Create;
Destructor Destroy; Override;
Procedure LoadFromStream( stream: TStream );
Procedure SaveToStream( stream: TStream );
Procedure UpdateExtension;
Property Vector: TEzVector Read FVector;
Property Extension: TEzRect Read FExtension;
End;
{ a list of TEzVectorChar by using a sparse list if > 255 chars or
a TList if < 255 for faster access time }
TEzVectorCharList = Class
Private
FList: TList;
FSparseList: TSparseList;
FCapacity: Integer;
Function Get( Index: Integer ): TEzVectorChar;
Procedure Put( Index: Integer; Value: TEzVectorChar );
Procedure SetCapacity( Value: Integer );
Public
Constructor Create;
Destructor Destroy; Override;
Procedure Clear;
Property Items[Index: Integer]: TEzVectorChar Read Get Write Put; Default;
Property Capacity: Integer Read FCapacity Write SetCapacity;
End;
{ This class contains the list of chars that builds up the font typeface }
TEzVectorFont = Class
Private
FChars: TEzVectorCharList;
FName: String;
FMaxChar: Integer;
Function GetChar( Index: Integer ): TEzVectorChar;
Procedure SetChar( Index: Integer; VectorChar: TEzVectorChar );
Procedure SetMaxChar( Value: Integer );
Public
Constructor Create;
Destructor Destroy; Override;
Procedure LoadFromStream( Stream: TStream );
Procedure SaveToStream( Stream: TStream );
Procedure LoadFromFile( Const FileName: String );
Procedure SaveToFile( Const FileName: String );
Function GetTextExtension( Const Value: String;
Const Height: Double;
Const InterCharSpacing: Double;
Const InterLineSpacing: Double ): TEzRect;
Function GetFittedTextExtension( Const Value: String;
InterCharSpacing: Double ): TEzRect;
Property Chars[Index: Integer]: TEzVectorChar Read GetChar Write SetChar;
Property Name: String Read FName Write FName;
Property MaxChar: Integer Read FMaxChar Write SetMaxChar;
End;
{ TEzVectorFonts the list of fonts }
TEzVectorFonts = Class
Private
{ a list of TEzVectorFont }
FFontList: TList;
FNullChar: TEzVectorChar;
FDefaultFont: TEzVectorFont;
Function Get( Index: Integer ): TEzVectorFont;
Function GetDefaultFont: TEzVectorFont;
Public
Constructor Create;
Destructor Destroy; Override;
Function Count: Integer;
{ add a font file (Arial.fnt) to the list}
Procedure AddFontFile( Const FileName: String );
Procedure AddFont( VectorFont: TEzVectorFont );
{ Clear the list of fonts}
Procedure Clear;
{ delete a font by ordinal position }
Procedure Delete( Index: Integer );
{ delete a font given a font name }
Procedure DeleteByName( Const FontName: String );
{ Given a font name ("Arial") this function returns the
TEzVectorFont associated with that name.
If the given name is not found, the default font is returned }
Function FontByName( Const FontName: String ): TEzVectorFont;
{ this function return the vector font given an index on the
list of fonts }
Function FontByIndex( Index: Integer ): TEzVectorFont;
{ given a vector font, this function return the position on the list
of fonts }
Function IndexOfFont( VectorFont: TEzVectorFont ): Integer;
{ given a font name, this function return the position on the
list of fonts }
Function IndexOfFontByName( Const FontName: String ): Integer;
{ This procedure defines the default font by name
is the font name is not found, the 0 position font is used }
Procedure SetDefaultFontByName( Const FontName: String );
{ set the default font by ordinal position }
Procedure SetDefaultFontByIndex( Index: Integer );
{ populates a TStrings with the list of font names }
Procedure PopulateTo( Strings: TStrings );
Property Items[Index: Integer]: TEzVectorFont Read Get; Default;
Property NullChar: TEzVectorChar Read FNullChar;
Property DefaultFont: TEzVectorFont Read GetDefaultFont;
End;
TEzHorzAlignment = ( haLeft, haCenter, haRight );
TEzVertAlignment = ( vaTop, vaCenter, vaBottom );
{ TEzJustifVectorText - an enhanced justified vectorial text }
TEzJustifVectorText = Class( TEzClosedEntity )
Private
FVectorFont: TEzVectorFont;
FText: String;
FHeight: Double;
FAngle: Double;
FFontColor: TColor;
FHorzAlignment: TEzHorzAlignment;
FVertAlignment: TEzVertAlignment;
FInterCharSpacing: Double;
FInterLineSpacing: Double;
FTextBox: TEzRect;
{ this function returns the text extension as if not angle is given }
Function GetFontName: String;
Procedure SetFontName( Const Value: String );
Procedure SetInterCharSpacing( Const Value: Double );
Procedure SetInterLineSpacing( Const Value: Double );
Procedure SetAngle( Const Value: Double );
Procedure SetHeight( Const Value: Double );
Procedure SetTextBox( Const Value: TEzRect );
Procedure DoNormalizedVector( Const Emin, Emax: TEzPoint );
Procedure PopulatePoints;
Procedure DoRotation;
Procedure SetText( Const Value: String );
Procedure MoveAndRotateControlPoint( Var MovePt, RotatePt: TEzPoint; Grapher: TEzGrapher );
{$IFDEF BCB}
function GetAngle: Double;
function GetFontColor: TColor;
function GetHeight: Double;
function GetHorzAlignment: TEzHorzAlignment;
function GetInterCharSpacing: Double;
function GetInterLineSpacing: Double;
function GetText: String;
function GetTextBox: TEzRect;
function GetVectorFont: TEzVectorFont;
function GetVertAlignment: TEzVertAlignment;
procedure SetFontColor(const Value: TColor);
procedure SetHorzAlignment(const Value: TEzHorzAlignment);
procedure SetVectorFont(const Value: TEzVectorFont);
procedure SetVertAlignment(const Value: TEzVertAlignment);
{$ENDIF}
Protected
Function GetEntityID: TEzEntityID; Override;
Function BasicInfoAsString: string; Override;
Function AttribsAsString: string; Override;
Public
Constructor CreateEntity( Const TextBox: TEzRect; Const Height: Double; Const Text: String );
procedure Initialize; Override;
Procedure LoadFromStream( Stream: TStream ); Override;
Procedure SaveToStream( Stream: TStream ); Override;
Function StorageSize: Integer; Override;
Procedure Draw( Grapher: TEzGrapher; Canvas: TCanvas; Const Clip: TEzRect;
DrawMode: TEzDrawMode; Data: Pointer = Nil ); Override;
Procedure ApplyTransform; Override;
Procedure UpdateExtension; Override;
Function IsClosed: Boolean; Override;
Procedure UpdateControlPoint( Index: Integer; Const Value: TEzPoint; Grapher: TEzGrapher=Nil ); Override;
Procedure UpdateExtensionFromControlPts; Override;
Function GetTextExtension: TEzRect;
Procedure MakePolyPointsByCenter( Const Center: TEzPoint );
Function GetControlPoints(TransfPts: Boolean; Grapher: TEzGrapher=Nil): TEzVector; Override;
Function GetControlPointType( Index: Integer ): TEzControlPointType; Override;
Function IsEqualTo( Entity: TEzEntity; IncludeAttribs: Boolean = false): Boolean; Override;
{ The text to show on the map }
Property Text: String {$IFDEF BCB} Read GetText {$ELSE} Read FText {$ENDIF} Write SetText;
{ the height of the text inside the bounding box }
Property Height: Double {$IFDEF BCB} Read GetHeight {$ELSE} Read FHeight {$ENDIF} Write SetHeight;
{ this is the angle of the text in radians }
Property Angle: Double{$IFDEF BCB} Read GetAngle {$ELSE} Read FAngle {$ENDIF} Write SetAngle;
{ the font color }
Property FontColor: TColor {$IFDEF BCB} Read GetFontColor Write SetFontColor {$ELSE} Read FFontColor Write FFontColor {$ENDIF};
{ the vector font object used for drawing }
Property VectorFont: TEzVectorFont {$IFDEF BCB} Read GetVectorFont Write SetVectorFont {$ELSE} Read FVectorFont Write FVectorFont {$ENDIF};
{ an indirect reference to the vector font }
Property FontName: String Read GetFontName Write SetFontName; // no data associated
{ the horizontal alignment }
Property HorzAlignment: TEzHorzAlignment {$IFDEF BCB} Read GetHorzAlignment Write SetHorzAlignment {$ELSE} Read FHorzAlignment Write FHorzAlignment {$ENDIF};
{ the vertical alignment }
Property VertAlignment: TEzVertAlignment {$IFDEF BCB} Read GetVertAlignment Write SetVertAlignment {$ELSE} Read FVertAlignment Write FVertAlignment {$ENDIF};
{ the interchar spacing: 0.3 means 30% of text height }
Property InterCharSpacing: Double {$IFDEF BCB} Read GetInterCharSpacing {$ELSE} Read FInterCharSpacing {$ENDIF} Write SetInterCharSpacing;
{ the interline spacing: 0.3 means 30% of text height }
Property InterLineSpacing: Double {$IFDEF BCB} Read GetInterLineSpacing {$ELSE} Read FInterLineSpacing {$ENDIF} Write SetInterLineSpacing;
Property TextBox: TEzRect {$IFDEF BCB} Read GetTextBox {$ELSE} Read FTextBox {$ENDIF} Write SetTextBox;
End;
{ TEzFittedVectorText an enhanced multi-line fitted vectorial text }
TEzTextBorderStyle = ( tbsNone, tbsBanner, tbsCallout, tbsBulletLeader );
TEzFittedVectorText = Class( TEzClosedEntity )
Private
FVectorFont: TEzVectorFont;
FText: String;
FHeight: Double;
FWidth: Double;
FAngle: Double;
FFontColor: TColor;
FInterCharSpacing: Double;
FInterLineSpacing: Double;
FTextBorderStyle: TEzTextBorderStyle;
FPivot: TEzPoint;
FHideShadow: Boolean;
{ this function returns the text extension as if not angle is given }
Function GetFontName: String;
Procedure SetFontName( Const Value: String );
Procedure SetInterCharSpacing( Const Value: Double );
Procedure SetInterLineSpacing( Const Value: Double );
Procedure SetAngle( Const Value: Double );
Procedure SetHeight( Const Value: Double );
Procedure SetWidth( Const Value: Double );
Procedure DoNormalizedVector( Const BasePt: TEzPoint; V: TEzVector );
Procedure PopulatePoints;
Function GetBasePoint: TEzPoint;
Procedure SetBasePoint( Const Value: TEzPoint );
Procedure SetText( Const Value: String );
Procedure DoDrawing( Path: TEzVector; FittedToLen: Boolean;
Grapher: TEzGrapher; Canvas: TCanvas;
Const Clip: TEzRect; DrawMode: TEzDrawMode );
Procedure MoveAndRotateControlPoint( Var MovePt, RotatePt: TEzPoint; Grapher: TEzGrapher );
{$IFDEF BCB}
function GetAngle: Double;
function GetFontColor: TColor;
function GetHeight: Double;
function GetHideShadow: Boolean;
function GetInterCharSpacing: Double;
function GetInterLineSpacing: Double;
function GetPivot: TEzPoint;
function GetText: String;
function GetTextBorderStyle: TEzTextBorderStyle;
function GetVectorFont: TEzVectorFont;
function GetWidth: Double;
procedure SetFontColor(const Value: TColor);
procedure SetHideShadow(const Value: Boolean);
procedure SetTextBorderStyle(const Value: TEzTextBorderStyle);
procedure SetVectorFont(const Value: TEzVectorFont);
procedure SetPivot(const Value: TEzPoint);
{$ENDIF}
Protected
Function GetEntityID: TEzEntityID; Override;
Function BasicInfoAsString: string; Override;
Function AttribsAsString: string; Override;
Public
Constructor CreateEntity( Const BasePoint: TEzPoint; Const Text: String;
Const Height, Width, Angle: Double );
procedure Initialize; Override;
Procedure LoadFromStream( Stream: TStream ); Override;
Procedure SaveToStream( Stream: TStream ); Override;
Function StorageSize: Integer; Override;
Procedure Draw( Grapher: TEzGrapher; Canvas: TCanvas; Const Clip: TEzRect;
DrawMode: TEzDrawMode; Data: Pointer = Nil ); Override;
Procedure DrawToPath( Path: TEzVector; FittedToLen: Boolean;
Grapher: TEzGrapher; Canvas: TCanvas;
Const Clip: TEzRect; DrawMode: TEzDrawMode );
Procedure ApplyTransform; Override;
Procedure UpdateExtension; Override;
Function IsClosed: Boolean; Override;
Procedure UpdateControlPoint( Index: Integer; Const Value: TEzPoint; Grapher: TEzGrapher=Nil ); Override;
Procedure UpdateExtensionFromControlPts; Override;
Function GetTextExtension: TEzRect;
Procedure MakePolyPointsByCenter( Const Center: TEzPoint );
Function GetControlPoints(TransfPts: Boolean; Grapher: TEzGrapher=Nil): TEzVector; Override;
Function GetControlPointType( Index: Integer ): TEzControlPointType; Override;
Function IsEqualTo( Entity: TEzEntity; IncludeAttribs: Boolean = false): Boolean; Override;
{ The text to show on the map }
Property Text: String {$IFDEF BCB} Read GetText {$ELSE} Read FText {$ENDIF} Write SetText;
Property BasePoint: TEzPoint Read GetBasePoint Write SetBasePoint;
{ the height of the text inside the bounding box }
Property Height: Double {$IFDEF BCB} Read GetHeight {$ELSE} Read FHeight {$ENDIF} Write SetHeight;
{ the width of the text inside the bounding box }
Property Width: Double {$IFDEF BCB} Read GetWidth {$ELSE} Read FWidth {$ENDIF} Write SetWidth;
{ this is the angle of the text in radians }
Property Angle: Double {$IFDEF BCB} Read GetAngle {$ELSE} Read FAngle {$ENDIF} Write SetAngle;
{ the font color }
Property FontColor: TColor {$IFDEF BCB} Read GetFontColor Write SetFontColor {$ELSE} Read FFontColor Write FFontColor {$ENDIF};
{ the vector font object used for drawing }
Property VectorFont: TEzVectorFont {$IFDEF BCB} Read GetVectorFont Write SetVectorFont {$ELSE} Read FVectorFont Write FVectorFont {$ENDIF};
{ an indirect reference to the vector font }
Property FontName: String Read GetFontName Write SetFontName; // no data associated
{ the interchar spacing: 0.3 means 30% of text height }
Property InterCharSpacing: Double {$IFDEF BCB} Read GetInterCharSpacing {$ELSE} Read FInterCharSpacing {$ENDIF} Write SetInterCharSpacing;
{ the interline spacing: 0.3 means 30% of text height }
Property InterLineSpacing: Double {$IFDEF BCB} Read GetInterLineSpacing {$ELSE} Read FInterLineSpacing {$ENDIF} Write SetInterLineSpacing;
Property TextBorderStyle: TEzTextBorderStyle {$IFDEF BCB} Read GetTextBorderStyle {$ELSE} Read FTextBorderStyle {$ENDIF} Write FTextBorderStyle;
Property Pivot: TEzPoint {$IFDEF BCB} Read GetPivot Write SetPivot {$ELSE} Read FPivot Write FPivot {$ENDIF};
Property HideShadow: Boolean {$IFDEF BCB} Read GetHideShadow Write SetHideShadow {$ELSE} Read FHideShadow Write FHideShadow {$ENDIF};
End;
{------------------------------------------------------------------------------}
// Hatch patterns
{------------------------------------------------------------------------------}
PEzHatchData = ^TEzHatchData;
TEzHatchData = Packed Record
Angle: Double;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -