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

📄 iplotchannel.pas

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

      for i := StartIndex to StopIndex do
        begin
          if DataEmpty[i] then Continue;
          if DataNull[i]  then
            begin
              Point1Empty := True;
              Continue;
            end;

          if Point1Empty then
            begin
              Point1Empty  := False;
              Point1XValue := DataX[i];
              Point1YValue := DataY[i];
            end
          else
            begin
              DrawQuadPolygon(Canvas, XYAxisReverse, PointDouble(Point1XValue, FFillReference),
                                                     PointDouble(Point1XValue, Point1YValue),
                                                     PointDouble(DataX[i],     DataY[i]),
                                                     PointDouble(DataX[i],     FFillReference));

              Point1XValue := DataX[i];
              Point1YValue := DataY[i];
            end;
        end;

    end;
end;
//****************************************************************************************************************************************************
procedure TiPlotChannel.DrawBar(Canvas: TCanvas; XYAxisReverse: Boolean);
var
  i      : Integer;
  YStart : Integer;
  YStop  : Integer;
  XStart : Integer;
  XStop  : Integer;
  ARect  : TRect;
begin
  if not FBarEnabled then Exit;
  with Canvas do
    begin
      for i := StartIndex to StopIndex do
        begin
          if     DataNull [i]      then Continue;
          if     DataEmpty[i]      then Continue;
          if not DataBarVisible[i] then Continue;

          if FBarBrushUseChannelColor then Brush.Color := Color else Brush.Color := DataBarBrushColor[i];
          if FBarPenUseChannelColor   then Pen.Color   := Color else Pen.Color   := DataBarPenColor[i];
                                                                     Pen.Width   := DataBarPenWidth[i];
                                                                     Pen.Style   := DataBarPenStyle[i];
                                                                     Brush.Style := DataBarBrushStyle[i];

          XStart := XAxis.PositionToPixels(DataX[i] - DataBarWidth[i]/2);
          XStop  := XAxis.PositionToPixels(DataX[i] + DataBarWidth[i]/2);

          YStart := YAxis.PositionToPixels(DataBarReference[i]);
          YStop  := YAxis.PositionToPixels(DataY[i]);

          if XYAxisReverse then ARect := iRect(YStart, XStart, YStop, XStop)
            else                ARect := iRect(XStart, YStart, XStop, YStop);

          Rectangle(ARect.Left, ARect.Top, ARect.Right, ARect.Bottom);
        end;
    end;
end;
//****************************************************************************************************************************************************
procedure TiPlotChannel.DrawHighLow(Canvas: TCanvas; XYAxisReverse: Boolean);
var
  i           : Integer;
  YStart      : Integer;
  YStop       : Integer;
  XStart      : Integer;
  XStop       : Integer;
  ARect       : TRect;
  WidthPixel  : Integer;
  HeightPixel : Integer;
  BarCenterX  : Integer;
  CenterY     : Integer;
  BarRect     : TRect;
begin
  if not FHighLowEnabled then Exit;

  with Canvas do
    begin
      Pen.Width   := 0;
      Pen.Style   := psSolid;
      Brush.Style := bsSolid;

      for i := StartIndex to StopIndex do
        begin
          if     DataNull [i]      then Continue;
          if     DataEmpty[i]      then Continue;

          WidthPixel := XAxis.WidthToPixels(FHighLowBarWidth);

          XStart := XAxis.PositionToPixels(DataX[i]) + WidthPixel - WidthPixel div 2 - 1;
          XStop  := XAxis.PositionToPixels(DataX[i]) -              WidthPixel div 2;

          YStart := YAxis.PositionToPixels(DataLow [i]);
          YStop  := YAxis.PositionToPixels(DataHigh[i]);

          if XStart = XStop then XStop := XStart + 1;
          if YStart = YStop then YStop := YStart + 1;

          BarCenterX := (XStart + XStop) div 2;

          if XYAxisReverse then BarRect := iRect(YStart, XStart, YStop, XStop)
            else                BarRect := iRect(XStart, YStart, XStop, YStop);

          if FHighLowOpenShow then
            begin

              WidthPixel  := XAxis.WidthToPixels(FHighLowOpenWidth);
              XStart      := BarCenterX - WidthPixel + 1;
              XStop       := BarCenterX;

              HeightPixel := YAxis.WidthToPixels(FHighLowOpenHeight);
              CenterY     := YAxis.PositionToPixels(DataOpen[i]);

              YStart      := CenterY + HeightPixel - HeightPixel div 2 - 1;
              YStop       := CenterY -               HeightPixel div 2;

              Brush.Color := FHighLowOpenColor;
              Pen.Color   := FHighLowOpenColor;

              if XStart = XStop then XStop := XStart + 1;
              if YStart = YStop then YStop := YStart + 1;

              if XYAxisReverse then ARect := iRect(YStart, XStart, YStop, XStop)
                else                ARect := iRect(XStart, YStart, XStop, YStop);

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

          if FHighLowCloseShow then
            begin
              WidthPixel  := XAxis.WidthToPixels(FHighLowCloseWidth);
              XStart      := BarCenterX;
              XStop       := BarCenterX + WidthPixel - 1;

              HeightPixel := YAxis.WidthToPixels(FHighLowCloseHeight);
              CenterY     := YAxis.PositionToPixels(DataClose[i]);

              YStart      := CenterY + HeightPixel - HeightPixel div 2 - 1;
              YStop       := CenterY -               HeightPixel div 2;

              Brush.Color := FHighLowCloseColor;
              Pen.Color   := FHighLowCloseColor;

              if XStart = XStop then XStop := XStart + 1;
              if YStart = YStop then YStop := YStart + 1;

              if XYAxisReverse then ARect := iRect(YStart, XStart, YStop, XStop)
                else                ARect := iRect(XStart, YStart, XStop, YStop);

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

          Brush.Color := FHighLowBarColor;
          Pen.Color   := FHighLowBarColor;
          Rectangle(BarRect.Left, BarRect.Top, BarRect.Right, BarRect.Bottom);
        end;
    end;
end;
//****************************************************************************************************************************************************
procedure TiPlotChannel.DrawHighLowCandleStick(Canvas: TCanvas; XYAxisReverse: Boolean);
var
  i          : Integer;
  YStart     : Integer;
  YStop      : Integer;
  XStart     : Integer;
  XStop      : Integer;
  WidthPixel : Integer;
  BarRect    : TRect;
begin
  if not FHighLowEnabled then Exit;

  with Canvas do
    begin
      Pen.Width   := 0;
      Pen.Style   := psSolid;
      Brush.Style := bsSolid;

      for i := StartIndex to StopIndex do
        begin
          if     DataNull [i]      then Continue;
          if     DataEmpty[i]      then Continue;

          Pen.Color := FHighLowShadowColor;

          XStart := XAxis.PositionToPixels(DataX[i]);
          XStop  := XAxis.PositionToPixels(DataX[i]);

          YStart := YAxis.PositionToPixels(DataHigh[i]);
          YStop  := YAxis.PositionToPixels(DataLow [i]);

          Polyline([Point(XStart, YStart), Point(XStop, YStop)]);

          WidthPixel := XAxis.WidthToPixels(FHighLowBarWidth);

          XStart := XAxis.PositionToPixels(DataX[i]) + WidthPixel div 2 + 1;
          XStop  := XAxis.PositionToPixels(DataX[i]) - WidthPixel div 2;

          YStart := YAxis.PositionToPixels(DataOpen [i]);
          YStop  := YAxis.PositionToPixels(DataClose[i]);

          if DataClose[i] < DataOpen[i] then Brush.Color := FHighLowBearishColor
          else                               Brush.Color := FHighLowBullishColor;

          if XStart = XStop then XStop := XStart + 1;
          if YStart = YStop then YStop := YStart + 1;

          if XYAxisReverse then BarRect := iRect(YStart, XStart, YStop, XStop)
            else                BarRect := iRect(XStart, YStart, XStop, YStop);

          Rectangle(BarRect.Left, BarRect.Top, BarRect.Right, BarRect.Bottom);
        end;
    end;
end;
//****************************************************************************************************************************************************
procedure TiPlotChannel.DrawDifferential(Canvas: TCanvas; XYAxisReverse: Boolean);
var
  i            : Integer;
  Point1Empty  : Boolean;
  Point1XValue : Double;
  Point1YValue : Double;
begin
  if Count = 0 then Exit;

  Point1Empty  := True;
  Point1XValue := 0;
  Point1YValue := 0;

  Canvas.Brush.Style := FFillStyle;
  if FillUseChannelColor then Canvas.Brush.Color := Color else Canvas.Brush.Color := FillColor;

  if (StartIndex <> -1) and (StopIndex <> -1) then
    begin
      for i := StartIndex to StopIndex do
        begin
          if DataEmpty[i] then Continue;
          if DataNull[i]  then
            begin
              if not Point1Empty then
                begin
                  if FFillEnabled and (FFillStyle <> bsClear) then
                    begin
                      Canvas.Pen.Color := Canvas.Brush.Color;
                      DrawQuadPolygon(Canvas, XYAxisReverse, PointDouble(Point1XValue, FFillReference),
                                                             PointDouble(Point1XValue, Point1YValue),
                                                             PointDouble(DataX[i],     Point1YValue),
                                                             PointDouble(DataX[i],     FFillReference));
                      Canvas.Pen.Color := Color;
                    end;
                  DrawLine(Canvas, XYAxisReverse, Point1XValue, Point1YValue, DataX[i], Point1YValue, ipurScale);
                end;
              Point1Empty := True;
              Continue;
            end;

          if Point1Empty then
            begin
              Point1Empty  := False;
              Point1XValue := DataX[i];
              Point1YValue := DataY[i];
            end
          else
            begin
              if FFillEnabled  and (FFillStyle <> bsClear) then
                begin
                  Canvas.Pen.Color := Canvas.Brush.Color;
                  DrawQuadPolygon(Canvas, XYAxisReverse, PointDouble(Point1XValue, FFillReference),
                                                         PointDouble(Point1XValue, Point1YValue),
                                                         PointDouble(DataX[i],     Point1YValue),
                                                         PointDouble(DataX[i],     FFillReference));
                  Canvas.Pen.Color := Color;
                end;

              DrawLine(Canvas, XYAxisReverse, Point1XValue, Point1YValue, DataX[i], Point1YValue, ipurScale);
              DrawLine(Canvas, XYAxisReverse, DataX[i],     Point1YValue, DataX[i], DataY[i], ipurScale);

              Point1XValue := DataX[i];
              Point1YValue := DataY[i];
            end;
        end;
      end
  else
    begin
      for i := Count-1 downto 0 do
        begin
          if DataEmpty[i] then Continue;
          if DataNull[i]  then Continue;
          Point1Empty  := False;
          Point1XValue := DataX[i];

⌨️ 快捷键说明

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