📄 ezbasegis.pas
字号:
Unit EzBaseGIS;
{***********************************************************}
{ EzGIS/CAD Components }
{ (c) 2003 EzSoft Engineering }
{ All Rights Reserved }
{***********************************************************}
{$I EZ_FLAG.PAS}
{$R EzGISRES.dcr}
Interface
Uses
Windows, SysUtils, Classes, Graphics, Controls, StdCtrls, Forms,
Messages, EzRtree, EzLib, EzBase, EzBaseExpr, Dialogs ;
Const
RTYPE = ttRTree;
Type
{ forwards }
TEzBaseLayer = Class;
TEzBaseLayers = Class;
TEzBaseGIS = Class;
TEzBaseDrawBox = Class;
TEzDrawBoxList = Class;
TEzSelection = Class;
TEzPainterThread = Class;
TEzPainterObject = Class;
TEzBaseTable = Class;
TEzEntityList = Class;
EGISException = class(Exception);
{-------------------------------------------------------------------------------}
{ TEzEntity main class }
{-------------------------------------------------------------------------------}
TEzControlPointType = ( cptNode, cptMove, cptRotate );
TEzControlPointTypes = Set Of TEzControlPointType;
{ TEzEntity }
TEzEntity = Class( TObject )
Private
FTransformMatrix: PEzMatrix;
{ temporary used }
FBitmap: TBitmap;
FWasSuspended: Boolean;
{ here follows the info only used by some entities }
FPainterObject: TEzPainterObject;
{ this is assigned from the screen bitmap or nil if printing }
FBufferBitmap: TBitmap;
{ if <> [] then the set marks what control points to show }
FControlPointsToShow: TEzControlPointTypes;
Protected
FPoints: TEzVector;
FSelectedVertex: Integer;
Function GetEntityID: TEzEntityID; Virtual; Abstract;
Function GetDrawPoints: TEzVector; Virtual;
Function BasicInfoAsString: string; Dynamic;
Function AttribsAsString: string; Dynamic;
Public
ID: Integer; { the unique ID for this entity }
FBox: TEzRect;
FOriginalSize: Integer;
Constructor Create( NPts: Integer; CanGrow: Boolean = True ); Virtual;
Destructor Destroy; Override;
Procedure Initialize; Virtual;
Function Clone: TEzEntity;
Function StorageSize: Integer; Virtual;
Procedure LoadFromStream( Stream: TStream ); Virtual;
Procedure SaveToStream( Stream: TStream ); Virtual;
Function Area: Double; Dynamic;
Function Perimeter: Double; Dynamic;
Procedure Centroid( Var CX, CY: Double ); Dynamic;
Procedure Assign( Source: TEzEntity );
Procedure DrawControlPoints( Grapher: TEzGrapher; Canvas: TCanvas;
Const VisualWindow: TEzRect; TransfPts: Boolean;
DefaultPaint: Boolean = True; HideVertexNumber: Boolean = False );
Procedure UpdateExtension; Virtual;
Procedure Draw( Grapher: TEzGrapher; Canvas: TCanvas; Const Clip: TEzRect;
DrawMode: TEzDrawMode; Data: Pointer = Nil ); Virtual; Abstract;
Procedure ShowDirection( Grapher: TEzGrapher; Canvas: TCanvas; Const Clip: TEzRect;
DrawMode: TEzDrawMode; DirectionPos: TEzDirectionpos;
Const DirectionPen: TEzPenStyle; Const DirectionBrush: TEzBrushStyle;
RevertDirection: Boolean ); Virtual;
{ returns true if this entity is visible in rectangle Clip and by
using a drawing limit given in parameter MinDrawLimit }
Function IsVisible( Const Clip: TEzRect ): Boolean;
Function PointCode( Const Pt: TEzPoint; Const Aperture: Double;
Var Distance: Double; SelectPickingInside: Boolean; UseDrawPoints: Boolean = True ): Integer; Virtual;
Procedure MoveTo( Const Pt, DragPt: TEzPoint );
Function NeedReposition: Boolean;
{ returns true if entity is closed (rectangle, polygon, ellipse, etc)}
Function IsClosed: Boolean; Virtual;
{ comparison between one entity and other }
Function CompareAgainst( Entity: TEzEntity; Operator: TEzGraphicOperator ): Boolean;
{ returns true if this entity is inside OtherEntity }
Function IsInsideEntity( _OtherEntity: TEzEntity; _FullInside: Boolean ): boolean;
{ returns true if point (X,Y) is inside this entity }
Function IsPointInsideMe( Const X, Y: Double ): Boolean;
{ returns if OtherEntity intersects to this one }
Function IntersectEntity( OtherEntity: TEzEntity;
ConsidereFullyInside: Boolean = True ): boolean;
{ returns max min extents of the entity }
Procedure MaxMinExtents( Var AXMin, AYMin, AXMax, AYMax: Double );
Function TravelDistance( Const Distance: Double;
Var p: TEzPoint; Var Index1, Index2: Integer ): Boolean;
{ returns true if the entity rotates clockwise or false if not }
Function RotatesClockWise: Boolean;
{ returns true if both entities are similar }
Function IsEqualTo( Entity: TEzEntity; IncludeAttribs: Boolean = false): Boolean; Dynamic; Abstract;
Procedure UpdateControlPoint( Index: Integer; Const Value: TEzPoint; Grapher: TEzGrapher=Nil); Dynamic;
Procedure UpdateExtensionFromControlPts; Dynamic;
Procedure BeginUpdate;
Procedure EndUpdate;
Procedure SetTransformMatrix( Const Matrix: TEzMatrix );
Function GetTransformMatrix: TEzMatrix;
Procedure ApplyTransform; Dynamic;
Function HasTransform: Boolean;
Function AsString( IncludeAttribs: Boolean = False; IncludeData: Boolean = False;
DbTable: TEzBaseTable=Nil ): string;
{ this property can return the control points of the entity. Usually, this
property is the same as property Points, but sometimes more control points
are built in order to do richest editing.
Important: If you call this function, after you use the vector returned
you must free the memory }
Function GetControlPoints(TransfPts: Boolean; Grapher: TEzGrapher=Nil): TEzVector; Virtual;
Function GetControlPointType( Index: Integer ): TEzControlPointType; Virtual;
{ this property return the list of points of the entity}
Property Points: TEzVector Read FPoints;
{ this property returns the points used to draw the entity
Usually, this is the same as Points property, but sometimes, like in
spline curves an internal vector is used }
Property DrawPoints: TEzVector Read GetDrawPoints;
{ this property is used when editing the control points and is usually
used in order to draw that control point with larger dimensions }
Property SelectedVertex: Integer Read FSelectedVertex Write FSelectedVertex;
Property EntityID: TEzEntityID Read GetEntityID;
{ If this property is assigned, then a bitmap filling will be used instead.
This class is not responsible for freeing the bitmap resources used.
An 8x8 b/w bitmap is accepted for Windows 9x }
Property Bitmap: TBitmap Read FBitmap Write FBitmap;
{ the entity was suspended before finished painting }
Property WasSuspended: Boolean Read FWasSuspended Write FWasSuspended;
{ the painting thread on this entity, used for firing some events from the
entity }
Property PainterObject: TEzPainterObject Read FPainterObject Write FPainterObject;
{ This is the bitmap where the AlphaChannel will be blended from
another created internal bitmap. Usually this corresponds to the
buffer Bitmap of the viewport and if =nil, then it means that the
output goes to the printer
This is used only in image entities, like TEzBandsBitmap, TEzPictureRef, etc.}
Property BufferBitmap: TBitmap Read FBufferBitmap Write FBufferBitmap;
Property ControlPointsToShow: TEzControlPointTypes read FControlPointsToShow write FControlPointsToShow;
End;
TEzEntityClass = Class Of TEzEntity;
{ TEzOpenedEntity }
TEzOpenedEntity = Class( TEzEntity )
Private
Function GetPenTool: TEzPenTool;
{$IFDEF BCB} (*_*)
procedure SetPenTool(const Value: TEzPenTool);
{$ENDIF}
Protected
FPenTool: TEzPenTool;
Procedure MoveAndRotateControlPts( Var MovePt, RotatePt: TEzPoint; Grapher: TEzGrapher );
Function AttribsAsString: string; Override;
Public
Constructor CreateEntity( Const Pts: Array Of TEzPoint; CanGrow: Boolean = True );
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 PointCode( Const Pt: TEzPoint; Const Aperture: Double;
Var Distance: Double; SelectPickingInside: Boolean; UseDrawPoints: Boolean = True ): Integer; Override;
Function Area: Double; Override;
Function IsEqualTo( Entity: TEzEntity; IncludeAttribs: Boolean = false): Boolean; Override;
Procedure ShowDirection( Grapher: TEzGrapher; Canvas: TCanvas; Const Clip: TEzRect;
DrawMode: TEzDrawMode; DirectionPos: TEzDirectionpos;
Const DirectionPen: TEzPenStyle;
Const DirectionBrush: TEzBrushStyle;
RevertDirection: Boolean ); Override;
Function GetControlPoints(TransfPts: Boolean; Grapher: TEzGrapher=Nil): TEzVector; Override;
Function GetControlPointType( Index: Integer ): TEzControlPointType; Override;
Property PenTool: TEzPenTool Read GetPenTool Write {$IFDEF BCB} SetPenTool {$ELSE} FPenTool {$ENDIF}; (*_*)
End;
{ TEzClosedEntity }
TEzClosedEntity = Class( TEzOpenedEntity )
Private
Function GetBrushTool: TEzBrushTool;
{$IFDEF BCB} (*_*)
procedure SetBrushTool(const Value: TEzBrushTool);
{$ENDIF}
Protected
FBrushTool: TEzBrushTool;
Function AttribsAsString: string; Override;
Public
Destructor Destroy; Override;
Procedure Initialize; Override;
Function IsClosed: Boolean; Override;
Function IsEqualTo( Entity: TEzEntity; IncludeAttribs: Boolean = false): Boolean; 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 PointCode( Const Pt: TEzPoint; Const Aperture: Double;
Var Distance: Double; SelectPickingInside: Boolean; UseDrawPoints: Boolean = True ): Integer; Override;
Property BrushTool: TEzBrushTool Read GetBrushTool Write {$IFDEF BCB} SetBrushTool {$ELSE} FBrushTool {$ENDIF}; (*_*)
End;
{-----------------------------------------------------------------------------}
// TEzBaseTable - a virtual abstract access to a database table
{-----------------------------------------------------------------------------}
TEzIndexUnique = ( iuUnique, iuDuplicates );
TEzSortStatus = ( ssAscending, ssDescending );
TEzBaseTable = Class( TObject )
Private
FGis: TEzBaseGIS;
FLongFieldNames: TStrings;
Function GetFieldAlias( FieldNo: Integer ): String;
Procedure SetFieldAlias( FieldNo: Integer; const Value: string );
function GetFieldAliasByName(const FieldName: String): string;
procedure SetFieldAliasByName(const FieldName, Value: string);
Protected
Function GetActive: boolean; Virtual; Abstract;
Procedure SetActive( Value: boolean ); Virtual; Abstract;
Function GetRecNo: Integer; Virtual; Abstract;
Procedure SetRecNo( Value: Integer ); Virtual; Abstract;
Public
{ the constructor must open the table }
Constructor Create( Gis: TEzBaseGIS; Const FName: String;
ReadWrite, Shared: Boolean ); Virtual;
Constructor CreateNoOpen( Gis: TEzBaseGIS ); Virtual;
Destructor Destroy; Override;
Procedure BeginTrans; Virtual;
Procedure RollBackTrans; Virtual;
Procedure EndTrans; Virtual;
Function DateGet( Const FieldName: String ): TDateTime; Virtual; Abstract;
Function DateGetN( FieldNo: Integer ): TDateTime; Virtual; Abstract;
Function FieldGetN( FieldNo: Integer ): String; Virtual; Abstract;
Function FieldNo( Const FieldName: String ): Integer; Virtual; Abstract;
Function FloatGetN( FieldNo: Integer ): Double; Virtual; Abstract;
Function IndexCount: Integer; Virtual; Abstract;
Function IndexAscending( Value: Integer ): boolean; Virtual; Abstract;
{Sets an index to a dBase file, example:
Index('GSDMO_06.CDX','LName'); }
Function Index( Const INames, Tag: String ): Integer; Virtual; Abstract;
{Returns the name of the tag currently used as the master index. }
Function IndexCurrent: String; Virtual; Abstract;
{Returns the state of the Unique flag of the index tag located in Value
order in the index list}
Function IndexUnique( Value: Integer ): boolean; Virtual; Abstract;
{Returns the key expression of the index tag located in Value order in the
index list}
Function IndexExpression( Value: Integer ): String; Virtual; Abstract;
{Returns the name of the index tag located in Value order in the index list.}
Function IndexTagName( Value: Integer ): String; Virtual; Abstract;
Function IndexFilter( Value: Integer ): String; Virtual; Abstract;
Function IntegerGetN( FieldNo: Integer ): Integer; Virtual; Abstract;
Function LogicGetN( FieldNo: Integer ): Boolean; Virtual; Abstract;
Procedure MemoSave( Const FieldName: String; Stream: TStream ); Virtual; Abstract;
Procedure MemoSaveN( FieldNo: Integer; Stream: TStream ); Virtual; Abstract;
Function MemoSizeN( FieldNo: Integer ): Integer; Virtual; Abstract;
Function MemoSize( Const FieldName: String ): Integer; Virtual; Abstract;
Function StringGetN( FieldNo: Integer ): String; Virtual; Abstract;
Procedure DatePut( Const FieldName: String; value: TDateTime ); Virtual; Abstract;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -