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

📄 iplotlegend.pas

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

            begin
              ARect.Left  := ALeft + FColumnStartChannel;
              ARect.Right := ALeft + FColumnStartChannel + FMaxWidthChannelLabel;
              iDrawText(Canvas, GetTranslation(FCaptionColumnTitle), ARect, [itfHLeft, itfVCenter, itfSingleLine, itfNoClip]);
            end;

          if FShowColumnXName then
            begin
              ARect.Left  := ALeft + FColumnStartXName;
              ARect.Right := ALeft + FColumnStartXName + FMaxWidthXName;
              iDrawText(Canvas, GetTranslation(FCaptionColumnXName), ARect, [itfHCenter, itfVCenter, itfSingleLine, itfNoClip]);
            end;

          if FShowColumnYName then
            begin
              ARect.Left  := ALeft + FColumnStartYName;
              ARect.Right := ALeft + FColumnStartYName + FMaxWidthYName;
              iDrawText(Canvas, GetTranslation(FCaptionColumnYName), ARect, [itfHCenter, itfVCenter, itfSingleLine, itfNoClip]);
           end;

          if (FShowColumnXValue2) then
            begin
              ARect.Left  := ALeft + FColumnStartXValue;
              ARect.Right := ALeft + FColumnStartXValue + FMaxWidthXValue;

              iDrawText(Canvas, GetTranslation(FCaptionColumnXValue), ARect, [itfHRight, itfVCenter, itfSingleLine, itfNoClip]);
            end;

          if (FShowColumnYValue2) then
            begin
              ARect.Left  := ALeft + FColumnStartYValue;
              ARect.Right := ALeft + FColumnStartYValue + FMaxWidthYValue;
              iDrawText(Canvas, GetTranslation(FCaptionColumnYValue), ARect, [itfHRight, itfVCenter, itfSingleLine, itfNoClip]);
            end;

          if (FShowColumnYMax) then
            begin
              ARect.Left  := ALeft + FColumnStartYMax;
              ARect.Right := ALeft + FColumnStartYMax + FMaxWidthYMax;
              iDrawText(Canvas, GetTranslation(FCaptionColumnYMax), ARect, [itfHRight, itfVCenter, itfSingleLine, itfNoClip]);
            end;

          if (FShowColumnYMin) then
            begin
              ARect.Left  := ALeft + FColumnStartYMin;
              ARect.Right := ALeft + FColumnStartYMin + FMaxWidthYMin;
              iDrawText(Canvas, GetTranslation(FCaptionColumnYMin), ARect, [itfHRight, itfVCenter, itfSingleLine, itfNoClip]);
            end;

          if (FShowColumnYMean) then
            begin
              ARect.Left  := ALeft + FColumnStartYMean;
              ARect.Right := ALeft + FColumnStartYMean + FMaxWidthYMean;
              iDrawText(Canvas, GetTranslation(FCaptionColumnYMean), ARect, [itfHRight, itfVCenter, itfSingleLine, itfNoClip]);
            end;
        end;
    end;
end;
//****************************************************************************************************************************************************
procedure TiPlotLegend.DrawLine(const Canvas: TCanvas; X, Y: Integer; AColor : TColor; LineStyle : TiPlotLineStyle);
var
  i : Integer;
begin
  with Canvas do
    begin
      Pen.Color := AColor;
      Pen.Width := 1;
      for i := -1 to 1 do
        case LineStyle of
          iplsSolid      : begin
                             PolyLine([Point(X,      Y+i), Point(X + 13, Y+i)]);
                           end;
          iplsDash       : begin
                             PolyLine([Point(X,      Y+i), Point(X +  5, Y+i)]);
                             PolyLine([Point(X +  8, Y+i), Point(X + 13, Y+i)]);
                           end;
          iplsDot        : begin
                             PolyLine([Point(X,      Y+i), Point(X +  2, Y+i)]);
                             PolyLine([Point(X +  4, Y+i), Point(X +  6, Y+i)]);
                             PolyLine([Point(X +  8, Y+i), Point(X + 10, Y+i)]);
                           end;
          iplsDashDot    : begin
                             PolyLine([Point(X,      Y+i), Point(X +  5, Y+i)]);
                             PolyLine([Point(X +  7, Y+i), Point(X +  9, Y+i)]);
                           end;
          iplsDashDotDot : begin
                             PolyLine([Point(X,      Y+i), Point(X +  5, Y+i)]);
                             PolyLine([Point(X +  7, Y+i), Point(X +  9, Y+i)]);
                             PolyLine([Point(X + 11, Y+i), Point(X + 13, Y+i)]);
                           end;
        end;
    end;
end;
//****************************************************************************************************************************************************
procedure TiPlotLegend.DrawUpButton(const Canvas: TCanvas);
var
  CenterPoint : TPoint;
begin
  if not FUpButton.Visible then Exit;
  with Canvas do
    begin
      FUpButton.Draw(Canvas, BackGroundColor);

      if FUpButton.Enabled then
        begin
          Pen.Color   := clBlack;
          Brush.Color := clBlack;
        end
      else
        begin
          Pen.Color   := clGray;
          Brush.Color := clGray;
        end;

      CenterPoint.X := (FUpButton.Left   + FUpButton.Right) div 2;
      CenterPoint.Y := (FUpButton.Bottom + FUpButton.Top  ) div 2;

      Polygon([Point(CenterPoint.x - 4, CenterPoint.y + 2),
               Point(CenterPoint.x + 4, CenterPoint.y + 2),
               Point(CenterPoint.x,     CenterPoint.y - 2)]);
    end;
end;
//****************************************************************************************************************************************************
procedure TiPlotLegend.DrawDownButton(const Canvas: TCanvas);
var
  CenterPoint : TPoint;
begin
  if not FDownButton.Visible then Exit;
  with Canvas do
    begin
      FDownButton.Draw(Canvas, BackGroundColor);

      if FDownButton.Enabled then
        begin
          Pen.Color   := clBlack;
          Brush.Color := clBlack;
        end
      else
        begin
          Pen.Color   := clGray;
          Brush.Color := clGray;
        end;

      CenterPoint.X := (FDownButton.Left   + FDownButton.Right) div 2;
      CenterPoint.Y := (FDownButton.Bottom + FDownButton.Top  ) div 2;

      Polygon([Point(CenterPoint.x - 4, CenterPoint.y - 2),
               Point(CenterPoint.x + 4, CenterPoint.y - 2),
               Point(CenterPoint.x,     CenterPoint.y + 2)]);
    end;
end;
//****************************************************************************************************************************************************
function TiPlotLegend.GetRequiredWidth(const Canvas: TCanvas) : Integer;
begin
  CalcRects(Canvas);
  if Horizontal then Result := FRequiredHeight else Result := FRequiredWidth;
end;
//****************************************************************************************************************************************************
{ TiPlotLegendButton }
//****************************************************************************************************************************************************
procedure TiPlotLegendButton.Draw(const Canvas: TCanvas; const BackGroundColor: TColor);
var
  ARect : TRect;
begin
  if not Visible then exit;
  with Canvas do
    begin
      Brush.Style := bsSolid;
      ARect       := DrawRect;
      Brush.Color := clBtnFace;
      FillRect(ARect);

      if MouseDown then
        iDrawEdge(Canvas, ARect, idesSunken)
      else
        iDrawEdge(Canvas, ARect, idesRaised);
    end;
end;
//****************************************************************************************************************************************************
procedure TiPlotLegend.ButtonInvalidate(Sender: TObject);
begin
  TriggerInvalidateNow(Self);
end;
//****************************************************************************************************************************************************
procedure TiPlotLegend.DownButtonClick(Sender: TObject);
begin
  if FItemViewStartIndex < FItemList.Count-1 then FItemViewStartIndex := FItemViewStartIndex + 1;
end;
//****************************************************************************************************************************************************
procedure TiPlotLegend.UpButtonClick(Sender: TObject);
begin
  if FItemViewStartIndex > 0 then FItemViewStartIndex := FItemViewStartIndex - 1;
end;
//****************************************************************************************************************************************************
function TiPlotLegend.GetXAxisNameText(iChannel: TiPlotChannelCustom): String;
var
  XAxis : TiPlotAxis;
begin
  XAxis := TiPlotChannelCustomAccess(iChannel).XAxis;
  if Assigned(XAxis) then
    begin
      if Trim(XAxis.Title) <> '' then Result := XAxis.Title else Result := XAxis.Name;
    end
  else Result := GetTranslation('None');
end;
//****************************************************************************************************************************************************
function TiPlotLegend.GetYAxisNameText(iChannel: TiPlotChannelCustom): String;
var
  YAxis : TiPlotAxis;
begin
  YAxis := TiPlotChannelCustomAccess(iChannel).YAxis;
  if Assigned(YAxis) then
    begin
      if Trim(YAxis.Title) <> '' then Result := YAxis.Title else Result := YAxis.Name;
    end
  else Result := GetTranslation('None');
end;
//****************************************************************************************************************************************************
function TiPlotLegend.GetXAxisValueText(iChannel: TiPlotChannelCustom): String;
begin
  if iChannel.Count <> 0 then
    begin
      if Assigned(iChannel.XAxis) then
        Result := iChannel.XAxis.GetLegendText(iChannel.DataX[iChannel.Count-1])
      else Result := GetTranslation('N/A')
    end
  else Result := GetTranslation('Empty');
end;
//****************************************************************************************************************************************************
function TiPlotLegend.GetYAxisValueText(iChannel: TiPlotChannelCustom): String;
begin
  if iChannel.Count <> 0 then
    begin
      if Assigned(iChannel.YAxis) then
        Result := iChannel.YAxis.GetLegendText(iChannel.DataY[iChannel.Count-1])
      else Result := GetTranslation('N/A')
    end
  else Result := GetTranslation('Empty');
end;
//****************************************************************************************************************************************************
function TiPlotLegend.GetYAxisMaxText(iChannel: TiPlotChannelCustom): String;
begin
  if iChannel.Count <> 0 then
    begin
      if Assigned(iChannel.YAxis) then
        Result := iChannel.YAxis.GetLegendText(iChannel.RunningYMax)
      else Result := GetTranslation('N/A')
    end
  else Result := GetTranslation('Empty');
end;
//****************************************************************************************************************************************************
function TiPlotLegend

⌨️ 快捷键说明

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