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

📄 ievect.pas

📁 ·ImageEn 2.3.0 ImageEn一组用于图像处理、查看和分析的Delphi控件。能够保存几种图像格式
💻 PAS
📖 第 1 页 / 共 2 页
字号:
(*
Copyright (c) 1998-2007 by HiComponents. All rights reserved.

This software comes without express or implied warranty.
In no case shall the author be liable for any damage or unwanted behavior of any
computer hardware and/or software.

HiComponents grants you the right to include the compiled component
in your application, whether COMMERCIAL, SHAREWARE, or FREEWARE,
BUT YOU MAY NOT DISTRIBUTE THIS SOURCE CODE OR ITS COMPILED .DCU IN ANY FORM.

ImageEn, IEvolution and ImageEn ActiveX may not be included in any commercial,
shareware or freeware libraries or components.

email: support@hicomponents.com

http://www.hicomponents.com
*)

unit ievect;

{$R-}
{$Q-}

{$I ie.inc}

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Menus, ImageEnView,
  Controls, StdCtrls, Forms, hyieutils, hyiedefs, ietextc, imageenio;

const
  strunits: array[0..7] of string = ('pixels', 'inches', 'km', 'mt', 'cm', 'mm', 'microns', 'nanometers');
  NULLOBJ = -4;
  DEFWIDTH = 64;
  DEFHEIGHT = 64;
  IEVECTCLIPFORMAT_NAME: string = 'IMAGEEN VECT';
  // IEV file format
  IEVMAGIC = 'IEV'; // magic number
  IEVVER: byte = 78; // current version

var
  IEVECTCLIPFORMAT: integer;

type

{!!
<FS>TIEMemoEditCharInfo

<FM>Declaration<FC>
}
  // specifies the char info (font, color, alignment)
  TIEMemoEditCharInfo = class
    Font:TFont;
    Align:TIEAlignment;
    constructor Create;
    destructor Destroy; override;
  end;
{!!}

{!!
<FS>TIERotateCenter

<FM>Declaration<FC>
IERotateCenter = (ierObject, ierImage);

<FM>Description<FN>

<TABLE>
<R> <H>Value</H> <H>Description</H> </R>
<R> <C>ierObject</C> <C>rotation center is the object</C> </R>
<R> <C>ierImage</C> <C>rotation center is the image</C> </R>
</TABLE>

!!}
  TIERotateCenter = (ierObject, ierImage);

{!!
<FS>TIECurve

<FM>Declaration<FC>
TIECurve = (iecNone, iecEllipse, iecCosine, iecVertical, iecHorizontal, iecArc);

<FM>Description<FN>
<TABLE>
<R> <H>Value</H> <H>Description</H> </R>
<R> <C>iecNone</C> <C>no curve (useful to remove a curve also created with SetObjTextCurve)</C> </R>
<R> <C>iecEllipse</C> <C>create an ellipting curve</C> </R>
<R> <C>iecCosine</C> <C>create a cosine curve</C> </R>
<R> <C>iecVertical</C> <C>create a vertical text</C> </R>
<R> <C>iecHorizontal</C> <C>create an horizontal text</C> </R>
<R> <C>iecArc</C> <C>create an arc</C> </R>
</TABLE>
!!}
  TIECurve = (iecNone, iecEllipse, iecCosine, iecVertical, iecHorizontal, iecArc);


{!!
<FS>TDPoint

<FM>Declaration<FC>
}
  TDPoint = record
    X, y: double;
  end;
{!!}

{!!
<FS>TDPointArray

<FM>Declaration<FC>
type TDPointArray = array[0 . . Maxint div 32] of <A TDPoint>;
!!}
  TDPointArray = array[0..Maxint div 32] of TDPoint;

{!!
<FS>PDPointArray

<FM>Declaration<FC>
type PDPointArray = ^<A TDPointArray>;
!!}
  PDPointArray = ^TDPointArray;

{!!
<FS>TIEVObjectKind

<FM>Declaration<FC>
type TIEVObjectKind = (iekNONE, iekLINE, iekBOX, iekELLIPSE, iekARC, iekBITMAP, iekTEXT, iekRULER, iekPOLYLINE, iekANGLE, iekMEMO, iekLINELABEL);

<FM>Description<FN>
Object type.
<TABLE>
<R> <H>Value</H> <H>Description</H> </R>
<R> <C>iekLINE</C> <C>line object</C> </R>
<R> <C>iekBOX</C> <C>box object</C> </R>
<R> <C>iekELLIPSE</C> <C>ellipse object</C> </R>
<R> <C>iekARC</C> <C>arc object (only to read DXF)</C> </R>
<R> <C>iekBITMAP</C> <C>bitmap object</C> </R>
<R> <C>iekTEXT</C> <C>text object</C> </R>
<R> <C>iekRULER</C> <C>ruler object</C> </R>
<R> <C>iekPOLYLINE</C> <C>poly line (open polygon), also good for free hand painting</C> </R>
<R> <C>iekANGLE</C> <C>an angle measurement object</C> </R>
<R> <C>iekMEMO</C> <C>a multiline text object</C> </R>
<R> <C>iekLINELABEL</C> <C>a line object with a text associated</C> </R>
</TABLE>
!!}
  TIEVObjectKind = (iekNONE, iekLINE, iekBOX, iekELLIPSE, iekARC, iekBITMAP, iekTEXT, iekRULER, iekPOLYLINE, iekANGLE, iekMEMO, iekLINELABEL, iekEXTENDED);

  // shape types for iekLINE/iekLINELABEL (initial and ending shapes)
{!!
<FS>TIEShape

<FM>Declaration<FC>
type TIEShape = (iesNONE, iesINARROW, iesOUTARROW);

<FM>Description<FN>
<TABLE>
<R> <H>Value</H> <H>Description</H> </R>
<R> <C>iesNONE</C> <C>no shape</C> </R>
<R> <C>iesINARROW</C> <C>arrow toward the center of object</C> </R>
<R> <C>iesOUTARROW</C> <C>arrow toward the extremes of object</C> </R>
</TABLE>
!!}
  TIEShape = (iesNONE, iesINARROW, iesOUTARROW);

{!!
<FS>TIEVRulerType

<FM>Declaration<FC>
TIEVRulerType = (iertRULER, iertQUOTEBEGIN, iertQUOTECENTER, iertQUOTEEND);

<FM>Description<FN>
<TABLE>
<R> <H>Value</H> <H>Description</H> </R>
<R> <C>iertRULER</C> <C>the standard ruler</C> </R>
<R> <C>iertQUOTEBEGIN</C> <C>display the length value on the left</C> </R>
<R> <C>iertQUOTECENTER</C> <C>display the length value on the center</C> </R>
<R> <C>iertQUOTEEND</C> <C>display the length value on the right</C> </R>
</TABLE>
!!}
  TIEVRulerType = (iertRULER, iertQUOTEBEGIN, iertQUOTECENTER, iertQUOTEEND);



{!!
<FS>TIEVBitmap

<FM>Declaration<FC>
type TIEVBitmap = record fBitmap: TBitmap; fRefCount: integer; end;

!!}
  // Bitmap for a iekBitmap object
  TIEVBitmap = record
    fBitmap: TIEBitmap;
    fRefCount: integer; // objects count that own this bitmap (0 is not allowed)
  end;
  
{!!
<FS>PIEVBitmap

<FM>Declaration<FC>
type PIEVBitmap = ^<A TIEVBitmap>;

!!}
  PIEVBitmap = ^TIEVBitmap;

{!!
<FS>TIEVBitmapArray

<FM>Declaration<FC>
type TIEVBitmapArray = array[0 . . MaxInt div 128] of <A TIEVBitmap>;

!!}
  TIEVBitmapArray = array[0..MaxInt div 128] of TIEVBitmap;

{!!
<FS>PIEVBitmapArray

<FM>Declaration<FC>
type PIEVBitmapArray = ^<A TIEVBitmapArray>;

!!}
  PIEVBitmapArray = ^TIEVBitmapArray;

{!!
<FS>TIEVStyle

<FM>Declaration<FC>
TIEVStyle = set of (ievsSelectable, ievsMoveable, ievsSizeable, ievsVisible);

<FM>Description<FN>
<TABLE>
<R> <H>Value</H> <H>Description</H> </R>
<R> <C>ievsSelectable</C> <C>the object is selectable (user can select it)</C> </R>
<R> <C>ievsMoveable</C> <C>the object is moveable (draggable) - requires ievsSelectable</C> </R>
<R> <C>ievsSizeable</C> <C>the object is sizeable (user can change borders) - requires ievsSelectable</C> </R>
<R> <C>ievsVisible</C> <C>the object is visible</C> </R>
</TABLE>
!!}
  TIEVStyle = set of (ievsSelectable, ievsMoveable, ievsSizeable, ievsVisible);


{!!
<FS>PIEVObject

<FM>Declaration<FC>
!!}
  PIEVObject = ^TIEVObject;

{!!
<FS>TIEUnits

<FM>Declaration<FC>
type TIEUnits = (ieuPIXELS, ieuINCHES, ieuKM, ieuMETERS, ieuCENTIMETERS, ieuMILLIMETERS, ieuMICRONS, ieuNANOMETERS);

<FM>Description<FN>
<TABLE>
<R> <H>Value</H> <H>Description</H> </R>
<R> <C>ieuPIXELS</C> <C>pixels</C> </R>
<R> <C>ieuINCHES</C> <C>inches</C> </R>
<R> <C>ieuKM</C> <C>kilometers</C> </R>
<R> <C>ieuMETERS</C> <C>meters</C> </R>
<R> <C>ieuCENTIMETERS</C> <C>centimeters</C> </R>
<R> <C>ieuMILLIMETERS</C> <C>millimeters</C> </R>
<R> <C>ieuMICRONS</C> <C>microns</C> </R>
<R> <C>ieuNANOMETERS</C> <C>nanometers</C> </R>
</TABLE>
!!}
  TIEUnits = (ieuPIXELS, ieuINCHES, ieuKM, ieuMETERS, ieuCENTIMETERS, ieuMILLIMETERS, ieuMICRONS, ieuNANOMETERS);

{!!
<FS>TIELabelPos

<FM>Declaration<FC>
TIELabelPos = (ielBegin, ielEnd);

<FM>Description<FN>
<TABLE>
<R> <H>Value</H> <H>Description</H> </R>
<R> <C>ielBegin</C> <C>show the text at the beginning of the line</C> </R>
<R> <C>ielEnd</C> <C>show the text at the end of the line</C> </R>
</TABLE>
!!}
  TIELabelPos = (ielBegin, ielEnd);


  // note: do not define a constructor on inherited classes. Instead override "Initializa" method.
  TIEExtendedObject = class
    private
      fParent:TObject;
      fObject:PIEVObject;
      fHOBJ:integer;
      hfont: THandle;
      hpred: THandle;
      fMouseOver:boolean;
    public
      constructor Create;

      property Parent:TObject read fParent write fParent;
      property HOBJ:integer read fHOBJ;
      property MouseOver:boolean read fMouseOver;

      // helper functions
      procedure Repaint;
      procedure CreateFont(Canvas:TCanvas; Height:integer);
      procedure DestroyFont(Canvas:TCanvas);

      procedure Initialize; virtual;
      procedure Finalize; virtual;
      procedure Instance(AssignedHOBJ:integer); virtual;
      procedure SaveToStream(Stream:TStream); virtual;
      function LoadFromStream(Stream:TStream):boolean; virtual;
      function Clone:TIEExtendedObject; virtual;
      procedure MouseDown(Button: TMouseButton; Shift: TShiftState; X, Y: Integer); virtual;
      procedure MouseUp(Button: TMouseButton; Shift: TShiftState; X, Y: Integer); virtual;
      procedure MouseMove(Shift: TShiftState; X, Y: Integer); virtual;
      procedure MouseEnter; virtual;
      procedure MouseLeave; virtual;
      procedure KeyDown(CharCode:word; Shift:TShiftState); virtual;
      procedure Draw(Bitmap:TBitmap; x1,y1,x2,y2:integer; isAlpha:boolean; ZoomX,ZoomY:double); virtual;

  end;

  TIEExtendedObjectClass = class of TIEExtendedObject;


  TIEVObject = record
    // shared fields
    x1, y1, x2, y2: integer; // object rectangle (in pixel, with zoom at 100%). The coordinates are sorted (but not for Kind=iekLINE,iekLINELABEL).
    Kind: TIEVObjectKind; // object type
    Transparency: integer;
    UserData:pointer;
    UserDataLength:integer;
    AspectRatio:boolean;
    // iekLINE / iekLINELABEL
    BeginShape: TIEShape;
    EndShape: TIEShape;
    ShapeWidth: integer;
    ShapeHeight: integer;
    // iekLINELABEL
    LabelBrushColor: TColor;
    LabelBrushStyle: TBrushStyle;
    LabelPosition: TIELabelPos;
    // pen
    PenColor: TColor;
    PenStyle: TPenStyle;
    PenWidth: integer;
    // brush
    BrushColor: TColor;
    BrushStyle: TBrushStyle;
    BoxHighlight: boolean;
    // iekARC
    a1, a2: double; // starting and ending angle (radians)
    // iekBITMAP
    BitmapIdx: integer; // also valid for iekMEMO when MemoHasBitmap is true
    BitmapBorder:boolean;
    // iekTEXT / iekMEMO / iekLINELABEL / iekRULER / iekANGLE / iekEXTENDED
    Text: pchar; // allocated
    LogFont: PLogFont; // allocated
    TextAlign: TIEAlignment;
    TextAutoSize: boolean;
    FontLocked: boolean;
    CurvedPos: PDPointArray;
    CurvedLen: integer;
    CurvedCharRot: integer;
    TextEditable:boolean;
    // iekMEMO
    TextFormatRef: pintegerarray; // allocated
    TextFormat: TList; // allocated
    LineSpace: integer;
    MemoBorderColor: TColor;
    MemoBorderStyle: TPenStyle;
    MemoFixedHeight: integer;
    MemoHasBitmap: boolean;
    MemoMarginLeft:double;
    MemoMarginTop:double;
    MemoMarginRight:double;
    MemoMarginBottom:double;
    MemoCharsBrushStyle:TBrushStyle;
    // others
    Name: pchar; // object user name (allocated)
    ID: integer; // object user ID
    Style: TIEVStyle;
    // iekRULER
    RulerUnit: TIEUnits;
    RulerType: TIEVRulerType;
    // iekPOLYLINE
    PolyPoints: pointer; // array of TPoint. Coordinates are in bitmap pixels, they are never translated or resized.
                         // C++Builder doesn't work with PolyPoints as PPointArray
    PolyPointsCount: integer; // PolyPoints count
    PolyBaseX1, PolyBaseY1, PolyBaseX2, PolyBaseY2: integer; // original rectangle
    PolyClosed: boolean; // the polygon is closes (filled with a brush)
    DrawnPoints: pointer;
    DrawnPointsCount: integer;
    // iekANGLE
    AnglePoints: array[0..2] of TPoint;
    // working fields
    lx1, ly1, lx2, ly2: integer; // used when resizing objects to store original coordinates
    plim: trect; // paint limits (last paint limits)
    pwidth: integer; // painted width
    // softshadow
    softShadow: TIEVSoftShadow; // allocated
    // extended object
    extendedObject:TIEExtendedObject; // can be nil
  end;

  TIEVObjectArray = array[0..MaxInt div 512] of TIEVObject;
  PIEVObjectArray = ^TIEVObjectArray;

  // automatic mouse interactions
{!!
<FS>TIEMouseInteractVtItems

<FM>Declaration<FC>
type TIEMouseInteractVtItems = (miArea, miLineLen, miPutLine, miPutBox, miPutEllipse, miPutBitmap, miPutText, miObjectSelect, miDragLen, miPutRuler, miPutPolyline, miPutAngle, miPutMemo, miPutLineLabel, miEditPolyline, miUnStampMode);

<FM>Description<FN>
<TABLE>
<R> <H>Value</H> <H>Description</H> </R>
<R> <C>miArea</C> <C>Rectangle/polygon area measurement</C> </R>
<R> <C>miLineLen</C> <C>Line length (or distance of two points)</C> </R>
<R> <C>miPutLine</C> <C>Insert a line object</C> </R>
<R> <C>miPutBox</C> <C>Insert a rectangle object</C> </R>
<R> <C>miPutEllipse</C> <C>Insert a ellipse/circle object</C> </R>
<R> <C>miPutBitmap</C> <C>Insert a bitmap object</C> </R>
<R> <C>miPutText</C> <C>Insert a text object</C> </R>
<R> <C>miObjectSelect</C> <C>Objects select or modify (resizing an object pressing ALT key the object will maintain the aspect ratio)</C> </R>
<R> <C>miDragLen</C> <C>Dynamically measure distance without selection</C> </R>
<R> <C>miPutRuler</C> <C>Insert a ruler object</C> </R>
<R> <C>miPutPolyLine</C> <C>Insert a polyline (open polygon, or free hand painting)</C> </R>
<R> <C>miPutAngle</C> <C>Insert an angle measurement object ( three single clicks )</C> </R>
<R> <C>miPutMemo</C> <C>Insert a multi line text object</C> </R>
<R> <C>miPutLineLabel</C> <C>Insert a line with a label</C> </R>
<R> <C>miEditPolyline</C> <C>Edit (add/move/delete) points of a poyline. Press CTRL to remove a point</C> </R>
<R> <C>miUnStampMode</C> <C>Single click doesn't insert a new object</C> </R>

⌨️ 快捷键说明

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