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

📄 iplotannotation.pas

📁 iocopm3.04源码,一套很好的工控开发工具
💻 PAS
📖 第 1 页 / 共 5 页
字号:

                                  Brush.Color := BrushColor;
                                  Brush.Style := BrushStyle;

                                  Ellipse(ARect.Left, ARect.Top, ARect.Right, ARect.Bottom);

                                  FShowing  := True;
                                  FDrawRect := ARect;

                                  IntersectRect(FClickRect, ARect, FDataView.DrawRect);

                                  IntersectRect(FSizeTopLeftRect,     Rect(ARect.Left  - 3, ARect.Top    - 3, ARect.Left  + 3, ARect.Top    + 3), FDataView.DrawRect);
                                  IntersectRect(FSizeTopRightRect,    Rect(ARect.Right - 3, ARect.Top    - 3, ARect.Right + 3, ARect.Top    + 3), FDataView.DrawRect);
                                  IntersectRect(FSizeBottomLeftRect,  Rect(ARect.Left  - 3, ARect.Bottom - 3, ARect.Left  + 3, ARect.Bottom + 3), FDataView.DrawRect);
                                  IntersectRect(FSizeBottomRightRect, Rect(ARect.Right - 3, ARect.Bottom - 3, ARect.Right + 3, ARect.Bottom + 3), FDataView.DrawRect);

                                  if UserSelected and FShowFocusRect then
                                    begin
                                      if Pen.Style = psSolid then Brush.Color := Pen.Color;
                                      Brush.Style := bsSolid;
                                      Pen.Style   := psSolid;

                                      {$IFDEF iVCL}
                                      InvertRect(Canvas.Handle, FSizeTopLeftRect);
                                      InvertRect(Canvas.Handle, FSizeTopRightRect);
                                      InvertRect(Canvas.Handle, FSizeBottomLeftRect);
                                      InvertRect(Canvas.Handle, FSizeBottomRightRect);
                                      {$ENDIF}

                                      {$IFDEF iCLX}
                                      iRectangle(Canvas, FSizeTopLeftRect);
                                      iRectangle(Canvas, FSizeTopRightRect);
                                      iRectangle(Canvas, FSizeBottomLeftRect);
                                      iRectangle(Canvas, FSizeBottomRightRect);
                                      {$ENDIF}
                                    end;
                                end;
                            end;
        ipasTextRectangle : begin
                              ARect := iXYReverseRect(XYAxesReversed, PositionXToPixels(X - FWidth/2), PositionYToPixels(Y - FHeight/2),
                                                                      PositionXToPixels(X + FWidth/2), PositionYToPixels(Y + FHeight/2));

                              if IntersectRect(DummyRect, FDataView.DrawRect, ARect) then
                                begin
                                  Pen.Color   := PenColor;
                                  Pen.Width   := PenWidth;
                                  Pen.Style   := PenStyle;

                                  Brush.Color := BrushColor;
                                  Brush.Style := BrushStyle;

                                  Rectangle(ARect.Left, ARect.Top, ARect.Right, ARect.Bottom);

                                  FShowing  := True;
                                  FDrawRect := ARect;

                                  IntersectRect(FClickRect, ARect, FDataView.DrawRect);

                                  IntersectRect(FSizeTopLeftRect,     Rect(ARect.Left  - 3, ARect.Top    - 3, ARect.Left  + 3, ARect.Top    + 3), FDataView.DrawRect);
                                  IntersectRect(FSizeTopRightRect,    Rect(ARect.Right - 3, ARect.Top    - 3, ARect.Right + 3, ARect.Top    + 3), FDataView.DrawRect);
                                  IntersectRect(FSizeBottomLeftRect,  Rect(ARect.Left  - 3, ARect.Bottom - 3, ARect.Left  + 3, ARect.Bottom + 3), FDataView.DrawRect);
                                  IntersectRect(FSizeBottomRightRect, Rect(ARect.Right - 3, ARect.Bottom - 3, ARect.Right + 3, ARect.Bottom + 3), FDataView.DrawRect);

                                  if UserSelected and FShowFocusRect then
                                    begin
                                      if Pen.Style = psSolid then Brush.Color := Pen.Color;
                                      Brush.Style := bsSolid;
                                      Pen.Style   := psSolid;

                                      {$IFDEF iVCL}
                                      InvertRect(Canvas.Handle, FSizeTopLeftRect);
                                      InvertRect(Canvas.Handle, FSizeTopRightRect);
                                      InvertRect(Canvas.Handle, FSizeBottomLeftRect);
                                      InvertRect(Canvas.Handle, FSizeBottomRightRect);
                                      {$ENDIF}

                                      {$IFDEF iCLX}
                                      iRectangle(Canvas, FSizeTopLeftRect);
                                      iRectangle(Canvas, FSizeTopRightRect);
                                      iRectangle(Canvas, FSizeBottomLeftRect);
                                      iRectangle(Canvas, FSizeBottomRightRect);
                                      {$ENDIF}
                                    end;

                                  Font.Assign(Self.Font);
                                  Brush.Style := bsClear;
                                  ATextFlags  := [itfNoClip, itfSingleLine];
                                  ATextRect   := ARect;

                                  case FTextHorzAlignment of
                                    iahCenter : begin
                                                  ATextFlags       := ATextFlags + [itfHCenter];
                                                end;
                                    iahLeft   : begin
                                                  ATextFlags       := ATextFlags + [itfHLeft];
                                                  ATextRect.Left   := ATextRect.Left + Round(TextWidth('A')*FTextHorzMargin);
                                                end;
                                    iahRight  : begin
                                                  ATextFlags       := ATextFlags + [itfHRight];
                                                  ATextRect.Right  := ATextRect.Right - Round(TextWidth('A')*FTextHorzMargin);
                                                end;
                                  end;

                                  case FTextVertAlignment of
                                    iavCenter : begin
                                                  ATextFlags       := ATextFlags + [itfVCenter];
                                                end;
                                    iavTop    : begin
                                                  ATextFlags       := ATextFlags + [itfVTop];
                                                  ATextRect.Top    := ATextRect.Top    + Round(TextHeight('A')*FTextVertMargin);
                                                end;
                                    iavBottom : begin
                                                  ATextFlags       := ATextFlags + [itfVBottom];
                                                  ATextRect.Bottom := ATextRect.Bottom - Round(TextHeight('A')*FTextVertMargin);
                                                end;
                                  end;

                                  iDrawText(Canvas, Text, ATextRect, ATextFlags);
                                end;
                            end;
        ipasImage         : begin
                              case FImageListIndex of
                                0    : ImageList := TiPlotComponentAccess(Owner).ImageList0;
                                1    : ImageList := TiPlotComponentAccess(Owner).ImageList1;
                                else   ImageList := TiPlotComponentAccess(Owner).ImageList2;
                              end;

                              APoint1 := iXYReversePoint(XYAxesReversed, PixelsX, PixelsY);
                              APoint1.X := APoint1.X - ImageList.Width  div 2;
                              APoint1.Y := APoint1.Y - ImageList.Height div 2;
                              ARect    := Rect(APoint1.X,                   APoint1.Y,
                                               APoint1.X + ImageList.Width, APoint1.Y + ImageList.Height);

                              if IntersectRect(DummyRect, FDataView.DrawRect, ARect) then
                                begin
                                  FShowing := True;
                                  {$ifdef iVCL}ImageList.Draw(Canvas, APoint1.X, APoint1.Y, FImageIndex,          Enabled);{$endif}
                                  {$ifdef iCLX}ImageList.Draw(Canvas, APoint1.X, APoint1.Y, FImageIndex, itImage, Enabled);{$endif}

                                  FClickRect := ARect;
                                end;
                            end;
      end;
    end;
end;
//****************************************************************************************************************************************************
function TiPlotAnnotation.iMouseHitTest(MouseData: TiPlotMouseData): Boolean;
begin
  Result := inherited iMouseHitTest(MouseData);
  if not TiPlotComponentAccess(Owner).SelectModeActive then Exit;
  if FShowing then
    begin
      if PtInRect(FClickRect,           Point(MouseData.X, MouseData.Y)) then Result := True;
      if PtInRect(FSizeTopLeftRect,     Point(MouseData.X, MouseData.Y)) then Result := True;
      if PtInRect(FSizeTopRightRect,    Point(MouseData.X, MouseData.Y)) then Result := True;
      if PtInRect(FSizeBottomLeftRect,  Point(MouseData.X, MouseData.Y)) then Result := True;
      if PtInRect(FSizeBottomRightRect, Point(MouseData.X, MouseData.Y)) then Result := True;
    end;
end;
//****************************************************************************************************************************************************
function TiPlotAnnotation.GetMousePointer(APoint: TPoint): TCursor;
begin
  if FUserCanSize and IsSizeable and UserSelected then
    begin
      if      PtInRect(FSizeTopLeftRect,     APoint) then Result := crSizeNWSE
      else if PtInRect(FSizeBottomRightRect, APoint) then Result := crSizeNWSE
      else if PtInRect(FSizeTopRightRect,    APoint) then Result := crSizeNESW
      else if PtInRect(FSizeBottomLeftRect,  APoint) then Result := crSizeNESW
      else                                                Result := crHandPoint;
    end
  else Result := crHandPoint;
end;
//****************************************************************************************************************************************************
procedure TiPlotAnnotation.DoMouseLeft(MouseData: TiPlotMouseData);
begin
  if FShowing then
    begin
      FSelectStyle := ipassNone;
      if IsSizeable then
        begin
          if      PtInRect(FSizeTopLeftRect,     Point(MouseData.X, MouseData.Y)) then FSelectStyle := ipassSizeTopLeft
          else if PtInRect(FSizeBottomRightRect, Point(MouseData.X, MouseData.Y)) then FSelectStyle := ipassSizeBottomRight
          else if PtInRect(FSizeTopRightRect,    Point(MouseData.X, MouseData.Y)) then FSelectStyle := ipassSizeTopRight
          else if PtInRect(FSizeBottomLeftRect,  Point(MouseData.X, MouseData.Y)) then FSelectStyle := ipassSizeBottomLeft
        end;

      if IsMoveable and (FSelectStyle = ipassNone) then                                FSelectStyle := ipassMove;

      FMouseDown     := True;
      FMouseDownRect := FDrawRect;
      FRectChange    := False;

      FMouseDownXPos := MousePointToXPos(Point(MouseData.X, MouseData.Y));
      FMouseDownYPos := MousePointToYPos(Point(MouseData.X, MouseData.Y));

      FMouseDownXValue  := X;
      FMouseDownYValue  := Y;
      FMouseDownX2Value := X2;
      FMouseDownY2Value := Y2;

      if XYAxesReversed and (Reference = iprtChannel) then
        begin
          FMouseDownX               := MouseData.X;
          FMouseDownY               := MouseData.Y;
          FMouseDownWidth           := FWidth;
          FMouseDownHeight          := FHeight;
          FMouseDownPositionPixelsX := PositionYToPixels(FY);
          FMouseDownPositionPixelsY := PositionXToPixels(FX);
        end
      else
        begin
          FMouseDownX               := MouseData.X;
          FMouseDownY               := MouseData.Y;
          FMouseDownWidth           := FWidth;
          FMouseDownHeight          := FHeight;
          FMouseDownPositionPixelsX := PositionXToPixels(FX);
          FMouseDownPositionPixelsY := PositionYToPixels(FY);
        end;
    end;
end;
//****************************************************************************************************************************************************
procedure TiPlotAnnotation.DoMouseMove(MouseData: TiPlotMouseData);
var
  NewRect : TRect;
  DeltaX  : Double;
  DeltaY  : Double;
begin
  if not UserSelected then Exit;
  if FMouseDown then
    begin
      case FSelectStyle of
        ipassMove            : if XYAxesReversed and (Reference = iprtChannel) then
                                 begin
                                   if FStyle = ipasRectangle then
                                     begin
                                       NewRect := FMouseDownRect;
                                       OffsetRect(NewRect, MouseData.X - FMouseDownX, MouseData.Y - FMouseDownY);
                                       SetupRectangle(NewRect);
                                     end
                                   else if FStyle = ipasEllipse then
                                     begin
                                       DeltaY := PixelsXToPosition(MouseData.X) - PixelsXToPosition(FMouseDownX);
                                       DeltaX := PixelsYToPosition(MouseData.Y) - PixelsYToPosition(FMouseDownY);

⌨️ 快捷键说明

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