  TAbstractPaintObject = class
  public
    constructor Create(AId,AState:integer);virtual;
    constructor CreateFromString(const Value:string); virtual;
    function  GetAsString:string; virtual;
    property  Id:integer read FId write SetId;
    procedure GetOriginPoint(var Value:TPoint;
      AParam:integer);virtual; abstract;
    procedure Paint(AZoom:extended;ACanvas:TCanvas;
      AParam:integer);virtual; abstract;
    function  PointInside(AX,AY:extended;
      AParam:integer):boolean;virtual; abstract;
    function  PointInsideDetail(AX,AY:extended;
      var AOffsetX,AOffsetY:extended;      
      var ADetail:integer;
      AParam:integer):boolean;virtual;// ADetail: Inside=-1; 0,1,2...=Number of selected Point; Only for RectRegions: -2,-3,-4,-5=TopBound,RightBound,BottomBound,LeftBound
    procedure Repaint(AZoom:extended;AHandle:HWND;
      AScrollPosX,AScrollPosY:integer;
      AParam:integer);virtual;
    property  State:integer read FState write SetState;
    property  Selected:boolean read FSelected write SetSelected;
    property  Resized:boolean read FResized write SetResized;
    property  Moved:boolean read FMoved write SetMoved;
    property  Visible:boolean read FVisible write FVisible;
    property  Enabled:boolean read FEnabled write FEnabled;
    property  Layer:TSchemeLayer read FLayer;
    property  HintString:string read GetHintString write SetHintString;
    procedure Timer(AZoom:extended;ACanvas:TCanvas;AParam:integer);virtual;
    procedure TimerWithRepaint(AZoom:extended;AHandle:HWND;AScrollPosX,AScrollPosY:integer;
      AParam:integer);virtual;
    function  GetClippingRegion(AZoom:extended;
      AParam:integer):HRGN;virtual;
    function  GetClippingOutsideRegion(AZoom:extended;
      AParam:integer):HRGN;virtual; 
    procedure Position(AX,AY:extended;
      AParam:integer);virtual;
    procedure PositionDetail(AX,AY:extended;var ADetail:integer;
      AParam:integer);virtual;//ADetail-> PointInsideDetail
  end;

  TAbstractPaintObjectClass = class of TAbstractPaintObject;

  TSchemeLayer = class
  public
    constructor Create(AId:integer); virtual;
    constructor CreateFromString(const Value:string); virtual;
    destructor  Destroy; override;
    function  GetAsString:string; virtual;
    procedure Sort;
    property  Id:integer read FId;
    procedure Paint(AZoom:extended;ACanvas:TCanvas;AParam:integer);virtual;
    procedure Repaint(AZoom:extended;AHandle:HWND;
      AScrollPosX,AScrollPosY:integer;AParam:integer);virtual;
    property  Enabled:boolean read FEnabled write FEnabled;
    property  Visible:boolean read FVisible write FVisible;
    property  MinZoomForText:extended read FMinZoomForText write FMinZoomForText;
    property  EnabledZoomForText:boolean read FEnabledZoomForText write FEnabledZoomForText;
    property  TimerTick:boolean read FTimerTick write FTimerTick;
    function  Count:integer;
    procedure Add(Value:TAbstractPaintObject);
    procedure Delete(AId:integer);
    procedure Clear;
    property  Items[AId:integer]: TAbstractPaintObject read GetItem write SetItem;default;
    property  ItemsIndex[AIndex:integer]: TAbstractPaintObject read GetItemIndex write SetItemIndex;
    procedure Timer(AZoom:extended;ACanvas:TCanvas;ATimerTick:boolean;
      AParam:integer);virtual;
    procedure TimerWithRepaint(AZoom:extended;AHandle:HWND;
      AScrollPosX,AScrollPosY:integer;ATimerTick:boolean;
      AParam:integer);virtual;
    property  StateColor[AIdState:integer]:TColor read GetStateColor write SetStateColor;
    procedure SetAllStateColors(Value:array of TColor); //load Palette
    procedure SetAllStateColorsToColor(Value:TColor); //load Palette=Value
    procedure GetAllStateColors(var Value:array of TColor);
    function  GetItemForPoint(AX,AY:extended;AParam:integer):TAbstractPaintObject;
    function  GetObjectCountForState(Value:integer):integer;
    function  GetObjectMaxId:integer;
    procedure ExchangeUp(AIdObject:integer); 
    procedure ExchangeDown(AIdObject:integer);
  end;

  TPaintObjectShape = class(TAbstractPaintObject)
  public
    constructor Create(AId:integer;ARect:TRect;AState:integer;
      AShape:TShapeType);
    constructor CreateExt(AId:integer;AX,AY,AW,AH:extended;AState:integer;
      AShape:TShapeType); virtual;
    constructor CreateFromString(const Value:string);override;
    function  GetAsString:string; override;
    procedure GetOriginPoint(var Value:TPoint;AParam:integer);override;
    procedure GetPosition(var AX,AY,AW,AH:extended;AParam:integer);virtual;
    procedure SetPosition(AX,AY,AW,AH:extended;AParam:integer);virtual;
    procedure Paint(AZoom:extended;ACanvas:TCanvas;AParam:integer);override;
    procedure PaintText(ARect:TRect;AZoom:extended;
      ACanvas:TCanvas;AParam:integer);virtual;
    function  PointInside(AX,AY:extended;AParam:integer):boolean;override;
    function  PointInsideDetail(AX,AY:extended;
      var AOffsetX,AOffsetY:extended;var ADetail:integer;
      AParam:integer):boolean;override;
    function  GetClippingRegion(AZoom:extended;
      AParam:integer):HRGN;override;
    function  GetClippingOutsideRegion(AZoom:extended;
      AParam:integer):HRGN;override;
    procedure Position(AX,AY:extended;
      AParam:integer);override;
    procedure PositionDetail(AX,AY:extended;
      var ADetail:integer;AParam:integer);override;
    property  ShapeType: TShapeType read FShape write FShape;
    property  Text: string read FText write SetText;
  end;

  TPaintObjectZone = class(TAbstractPaintObject)
  public
    constructor Create(AId:integer; APoints:array of TPoint;
      AState:integer; ABrushStyle:TBrushStyle;
      const AString:string;
      AStringPoint:TPoint);
    constructor CreateWithAmount(AId:integer;
      APoints:array of TPoint;AAmount:integer;
      AState:integer; ABrushStyle:TBrushStyle;
      const AString:string;
      AStringPoint:TPoint);
    constructor CreateFromBuffer(AId:integer;
      ABuffer:Pointer; APointsCount:integer;
      AState:integer; ABrushStyle:TBrushStyle;
      const AString:string;
      AStringPointNumber:integer);
    constructor CreateFromString(const Value:string);override;
    function  GetAsString:string; override;
    procedure Paint(AZoom:extended;ACanvas:TCanvas;AParam:integer);override;
    procedure PaintText(AZoom:extended;ACanvas:TCanvas;
      AParam:integer);virtual;
    function  PointInside(AX,AY:extended;
      AParam:integer):boolean;override;
    function  PointInsideDetail(AX,AY:extended;
      var AOffsetX,AOffsetY:extended;
      var ADetail:integer;
      AParam:integer):boolean;override;
    function  GetClippingRegion(AZoom:extended;
      AParam:integer):HRGN;override;
    function  GetClippingOutsideRegion(AZoom:extended;
      AParam:integer):HRGN;override;
    function  GetClippingOutsideRect(AZoom:extended;
      AParam:integer):TRect;
    procedure Position(AX,AY:extended;
      AParam:integer);override;
    procedure PositionDetail(AX,AY:extended;
      var ADetail:integer;AParam:integer);override;
    property  ResizedPoint:integer read FResizedPoint write SetResizedPoint;
    property  Points[AIndex:integer]:TPoint read GetPoints write SetPoints;
    procedure DeletePoint(Value:integer);
    procedure DeleteResizedPoint;
    procedure AddPoint(Value:integer);
    procedure AddResizedPoint;
    property  Text:string read FText write FText;
    procedure GetOriginPoint(var Value:TPoint;
      AParam:integer); override;
    property  BrushStyle:TBrushStyle read FBrushStyle write SetBrushStyle;
    property  Count:integer read FPointCount;
  end;

  TPaintObjectArrow = class(TAbstractPaintObject)
  public
    constructor Create(AId:integer;
      AStart,AEnd:TPoint;
      AWidth,AState:integer);
    constructor CreateExt(AId:integer;
      AXStart,AYStart,AXEnd,AYEnd:extended;
      AWidth,AState:integer);
    constructor CreateFromString(const Value:string);override;
    function  GetAsString:string; override;
    function  PointInside(AX,AY:extended;
      AParam:integer):boolean;override;
    function  PointInsideDetail(AX,AY:extended;
      var AOffsetX,AOffsetY:extended;
      var ADetail:integer;
      AParam:integer):boolean;override;
    procedure Position(AX,AY:extended;
      AParam:integer);override;
    procedure PositionDetail(AX,AY:extended;
      var ADetail:integer;AParam:integer);override;
    procedure GetOriginPoint(var Value:TPoint;
      AParam:integer); override;
    function  GetClippingRegion(AZoom:extended;
      AParam:integer):HRGN;override;
    function  GetClippingOutsideRect(AZoom:extended;
      AParam:integer):TRect;
    procedure Paint(AZoom:extended;ACanvas:TCanvas;AParam:integer);override;
    procedure SetStart(AX,AY:extended;AParam:integer);
    procedure SetEnd(AX,AY:extended;AParam:integer);
    procedure GetStart(var AX,AY:extended;AParam:integer);
    procedure GetEnd(var AX,AY:extended;AParam:integer);
    property  VisibleArrow:boolean read FVisibleArrow write SetVisibleArrow;
    property  LengthArrow:integer read FLengthArrow write SetLengthArrow;
    property  Width:integer read FWidth write SetWidth;
  end;

  TPaintObjectText = class(TPaintObjectShape)
  public
    constructor Create(AId:integer;
      ARect:TRect;AState:integer;
      AText:string);
    constructor CreateExt(AId:integer;
      AX,AY,AW,AH:extended;AState:integer;
      AText:string);
    constructor CreateAutoSize(AId:integer;
      APoint:TPoint;ACanvas:TCanvas;AState:integer;
      AText:string);
    constructor CreateFromString(const Value:string);override;
  end;

procedure RegisterPaintObject(AClass:TAbstractPaintObjectClass);
