⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ezbase.pas

📁 很管用的GIS控件
💻 PAS
📖 第 1 页 / 共 5 页
字号:
Unit EzBase;

{***********************************************************}
{     EzGIS/CAD Components                                  }
{   (c) 2003 EzSoft Engineering                             }
{         All Rights Reserved                               }
{***********************************************************}

{ Miscelaneous components and other classes needed }
{$I EZ_FLAG.PAS}
Interface

Uses
  SysUtils, Windows, Classes, Graphics, Controls, EzBaseExpr, EzLib, Db;

Const
  { the width of the point in nth of an inch }
  POINT_WIDTH = 48;

Type

  TEzEntityID = ( idNone,
                  idPoint,
                  idPlace,
                  idPolyline,
                  idPolygon,
                  idRectangle,
                  idArc,
                  idEllipse,
                  idPictureRef,
                  idPersistBitmap,
                  idBandsBitmap,
                  idBandsTiff,
                  idSpline,
                  idTable,
                  idGroup,
                  idTrueTypeText,
                  idJustifVectText,
                  idFittedVectText,
                  idDimHorizontal,
                  idDimVertical,
                  idDimParallel,
                  idRtfText,
                  idBlockInsert,
                  idSplineText,
                  idCustomPicture,
                  idNode,
                  idNodeLink,
{$IFDEF ER_MAPPER}
                  idERMapper,
{$ENDIF}
                  idPreview );

  TEzEntityIDs = Set Of TEzEntityID;

const

  NonAerialEntities = [ idNone,
                        idPictureRef,
                        idPersistBitmap,
                        idBandsBitmap,
                        idTable,
                        idJustifVectText,
                        idFittedVectText,
                        idDimHorizontal,
                        idDimVertical,
                        idDimParallel,
                        idCustomPicture,
                        idNode,
                        idNodeLink,
                        idRtfText,
                        idPreview ];

  TextEntities = [ idTrueTypeText,
                   idJustifVectText,
                   idFittedVectText,
                   idRtfText,
                   idSplineText ];

  ImageEntities = [idPictureRef,
                   idPersistBitmap,
                   idBandsBitmap,
                   idCustomPicture
{$IFDEF ER_MAPPER}
                   , idERMapper
{$ENDIF}
                   ];

type

  TEzTransformType = ( ttTranslate, ttRotate, ttScale, ttMirror );
  TEzTransformTypes = Set Of TEzTransformType;

  TEzDirPos = ( dpStart, dpMiddle, dpEnd );
  TEzDirectionPos = Set Of TEzDirPos;

  TEzCoordSystem = ( csCartesian, csLatLon, csProjection );

  TEzClipAreaKind = ( cpkRectangular, cpkPolygonal );

  // polygon clipping operations
  TEzPolyClipOp = ( pcDiff, // Difference
                    pcInt, // Intersection
                    pcXor, // Exclusive or
                    pcUnion, // Union
                    pcSplit ); // Split (actually pcDIFF + pcINT is performed)

  // when populating a TMapTable or TMapScript
  TEzFilterInclude = ( fiAllRecords, fiSelection, fiExcludeSelection );

  TEzDirection = ( diForward, diBackward );
  TEzOrigin = ( orEntire, orCurrRow );

  TEzTransportImages = (tiNonExistingOnly, tiAlwaysOverwrite, tiNone );

  TDegMinSec = Packed Record
    Degrees: integer;
    Minutes: byte;
    Seconds: Double;
  End;

  TEzScaleUnits = ( suInches, suMms, suCms );

  TEzOutputDevice = ( odCanvas, odBitmap );

  TEzOutputDevices = Set Of TEzOutputDevice;

  { units }
  TEzCoordsUnits = ( cum, cukm, cudm, cucm, cumm, cukmi, cuin, cuft, cuyd,
    cumi, cufath, cuch, culink, cuus_in, cuus_ft, cuus_yd,
    cuus_ch, cuus_mi, cuind_yd, cuind_ft, cuind_ch, cudeg // cudeg = not used in calculations
    );

  TEzPJ_UNITS = Record
    id: PChar;
    to_meter: Double;
    name: PChar;
  End;

  { Object Snap Settings }
  TEzOSNAPSetting = ( osEndPoint, osMidPoint, osCenter, osIntersect,
    osPerpend, osTangent, osNearest, osOrigin, osParallel, osKeyPoint, osBisector );

  { for autolabeling position in event OnLabelEntity }
  TEzLabelPos = ( lpCenter, lpCenterUp, lpUpperLeft, lpUpperRight, lpCenterLeft,
    lpCenterRight, lpLowerLeft, lpCenterDown, lpLowerRight );

  { how to handle the overlapped text}
  TEzOverlappedTextAction = ( otaDoNothing, otaHideOverlapped, otaShowOverlappedOnColor );

  { Layer main file header (in desktop is used in .EZD file) }
  TEzLayerHeader = Packed Record
    HeaderID: SmallInt;
    VersionNumber: SmallInt; //100, 110, etc.
    RecordCount: Longint; {number of records in file }
    Extension: TEzRect; {max, min extensions of layer }
    IDCounter: Integer; // four bytes for next entity identifier

    Visible: Boolean;
    Selectable: Boolean;
    IsMemoryLayer: Boolean; { the layer is a memory/cosmethic layer ? }
    IsAnimationLayer: Boolean;
    IsIndexed: Boolean;
    CoordSystem: TEzCoordSystem;
    CoordsUnits: TEzCoordsUnits;
    UseAttachedDB: Boolean;
    NotUsed: Boolean;
    TextHasShadow: Boolean;
    TextFixedSize: Integer; { if > 0 the font is drawn with same size }
    OverlappedTextAction: TEzOverlappedTextAction;
    OverlappedTextColor: TColor; { the color with which the overlapped text is painted }
    Locked: Boolean;   { layer is locked: no copy,paste,insert,delete,etc.}
    NodeCount: Integer;
    NodeLinkCount: Integer;

    Reserved: Array[0..90] Of Byte; { for future use }
  End;

  TEzLayerName = String[60];

  { main map file header information file .EZM }
  TEzMapHeader = Packed Record
    HeaderID: smallint;
    VersionNumber: SmallInt;
    NumLayers: SmallInt; { num layers in map              }
    Extension: TEzRect; { max,min extents of map         }
    CurrentLayer: TEzLayerName; { the name of the active layer   }
    AerialViewLayer: TEzLayerName;
    LastView: TEzRect; {max,min of last view           }

    { Internal units of the map  }
    CoordSystem: TEzCoordSystem;
    CoordsUnits: TEzCoordsUnits; // previously ViewCoordSystem: TCoordSystem;
    IsAreaClipped: Boolean; {clip an area ?}
    AreaClipped: TEzRect; {the clipped rectangular area}
    ClipAreaKind: TEzClipAreaKind; {the kind of clipping: polygonal, rectangular or from selection}
    Reserved: Array[0..99] Of Byte; { reserved for future use }
  End;

  // for print preview
  TEzPrintMode = ( pmAll, pmSelection, pmExcludeSelection );

  TEzPreviewPresentation = ( ppQuality, ppDraft );

  // used in TEzDrawBox methods

  {  The developers guide explains the following enumeration more in depth }
  TEzGraphicOperator = ( goWithin,
                         goEntirelyWithin,
                         goContains,
                         goContainsEntire,
                         goIntersects,
                         goEntirelyWithinNoEdgeTouched,
                         goContainsEntireNoEdgeTouched,
                         goExtentOverlaps,
                         goShareCommonPoint,
                         goShareCommonLine,
                         goLineCross,
                         goCommonPointOrLineCross,
                         goEdgeTouch,
                         goEdgeTouchOrIntersect,
                         goPointInPolygon,
                         goCentroidInPolygon,
                         goIdentical );          { A is equal to B }


  TEzGraphicOperators = Set Of TEzGraphicOperator;

  {-----------------------------------------------------------------------------}
  {    Image handling class for idPictureRef entities                           }
  {-----------------------------------------------------------------------------}

  TEzGraphicLink = Class
  Private
    FBitmap: TBitmap;
  Public
    Constructor Create;
    Destructor Destroy; Override;
    Procedure ReadGeneric( Const FileName: String );
{$IFDEF JPEG_SUPPORT}
    Procedure readJPG( Const FileName: String );
    Procedure putJPG( Bitmap: TBitmap; Const FileName: String );
{$ENDIF}
    Procedure readBMP( Const FileName: String );
    Procedure putBMP( Bitmap: TBitmap; Const FileName: String );
{$IFDEF GIF_SUPPORT}
    Procedure readGIF( Const FileName: String );
    Procedure putGIF( Bitmap: TBitmap; Const FileName: String );
{$ENDIF}
    Procedure readWMF( Const FileName: String );
    Procedure putWMF( Bitmap: TBitmap; Const FileName: String );
    Procedure readEMF( Const FileName: String );
    Procedure putEMF( Bitmap: TBitmap; Const FileName: String );
    Procedure readICO( Const FileName: String );

    { properties }
    Property Bitmap: TBitmap Read FBitmap Write FBitmap;
  End;

  { ----- TEzPreferences ----- }

  { TEzPointTool }
  TEzPointTool = Class( TPersistent )
  Private
    Function GetX: double;
    Procedure SetX( Const value: double );
    Function GetY: double;
    Procedure SetY( Const value: double );
  Public
    FPoint: TEzPoint;
    Procedure LoadFromStream( Stream: TStream );
    Procedure SaveToStream( Stream: TStream );
    Procedure Assign( Source: TPersistent ); Override;
  Published
    Property X: Double Read GetX Write SetX;
    Property Y: Double Read GetY Write SetY;
  End;

  { TEzSymbolTool }
  TEzSymbolApply = set of (saIndex, saRotangle, saHeight);

  TEzSymbolTool = Class( TPersistent )
  Private
    Function GetIndex: Integer;
    Procedure SetIndex( Value: Integer );
    Function GetRotangle: Double;
    Procedure SetRotangle( Const Value: Double );
    Function GetHeight: Double;
    Procedure SetHeight( Const Value: Double );
  Public
    FSymbolStyle: TEzSymbolStyle;
    Procedure LoadFromStream( Stream: TStream );
    Procedure SaveToStream( Stream: TStream );
    Procedure Assign( Source: TPersistent ); Override;
  Published
    Property Index: Integer Read GetIndex Write SetIndex;
    Property Rotangle: Double Read GetRotangle Write SetRotangle;
    Property Height: Double Read GetHeight Write SetHeight;
  End;

  { TEzPenTool }
  TEzPenApply = set of (paStyle, paColor, paWidth);

  TEzPenTool = Class( TPersistent )
  Private
    Function GetStyle: Integer;
    Procedure SetStyle( Value: Integer );
    Function GetColor: TColor;
    Procedure SetColor( Value: TColor );
    Function GetScale: Double;
    Procedure SetScale( Const Value: Double );
  Public
    FPenStyle: TEzPenStyle;
    Procedure LoadFromStream( Stream: TStream );
    Procedure SaveToStream( Stream: TStream );
    Procedure Assign( Source: TPersistent ); Override;
  Published
    Property Style: Integer Read GetStyle Write SetStyle;
    Property Color: TColor Read GetColor Write SetColor;
    Property Scale: Double Read GetScale Write SetScale;
    Property Width: Double Read GetScale Write SetScale;
  End;

  { TEzBrushTool }
  TEzBrushApply = set of (baPattern, baForeColor, baBackColor);

  TEzBrushTool = Class( TPersistent )
  Private
    Function GetPattern: Integer;
    Procedure SetPattern( Value: Integer );
    Function GetColor: TColor;
    Procedure SetColor( Value: TColor );
    Function GetAngle: Single;
    Procedure SetAngle( Const Value: Single );
    Function GetScale: Double;
    Procedure SetScale( Const Value: Double );
    Function GetBackColor: TColor;
    Function GetForeColor: TColor;
    Procedure SetBackColor( Const Value: TColor );
    Procedure SetForeColor( Const Value: TColor );
  Public
    FBrushStyle: TEzBrushStyle;
    Procedure LoadFromStream( Stream: TStream );
    Procedure SaveToStream( Stream: TStream );
    Procedure Assign( Source: TPersistent ); Override;

    { first choice is used if a hatch pattern is used }
    { second choice is used if a bitmap fill pattern is used }
    Property Color: TColor Read GetColor Write SetColor Default clblack;
    Property Scale: Double Read GetScale Write SetScale;
    Property Angle: Single Read GetAngle Write SetAngle;
  Published
    Property Pattern: Integer Read GetPattern Write SetPattern;
    Property ForeColor: TColor Read GetForeColor Write SetForeColor;
    Property BackColor: TColor Read GetBackColor Write SetBackColor;
  End;

  { TEzFontTool }
  TEzFontApply = Set Of (faName, faAngle, faHeight, faColor, faStyle);

  TEzFontTool = Class( TPersistent )
  Private
    Function GetName: String;
    Procedure SetName( Const Value: String );
    Function GetColor: TColor;
    Procedure SetCOlor( Value: TColor );
    Function GetAngle: Single;
    Procedure SetAngle( Const Value: Single );
    Function GetHeight: Double;
    Procedure SetHeight( Const Value: Double );
    Function GetStyle: TFontStyles;
    Procedure SetStyle( Const Value: TFontStyles );
  Public
    FFontStyle: TEzFontStyle;
    Constructor Create;
    Procedure LoadFromStream( Stream: TStream );
    Procedure SaveToStream( Stream: TStream );
    Procedure Assign( Source: TPersistent ); Override;
  Published
    Property Name: String Read GetName Write SetName;
    Property Angle: Single Read GetAngle Write SetAngle;
    Property Height: Double Read GetHeight Write SetHeight;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -