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

📄 iplotdataview.pas

📁 iocopm3.04源码,一套很好的工控开发工具
💻 PAS
📖 第 1 页 / 共 3 页
字号:
    begin
      FGridYAxisName := Value;
      FYAxis := nil;
      TriggerChange(Self);
    end;
end;
//****************************************************************************************************************************************************
procedure TiPlotDataView.SetGridLineMajorStyle(const Value: TiPlotGridLineStyle);
begin
  if FGridLineMajorStyle <> Value then
    begin
      FGridLineMajorStyle := Value;
      TriggerChange(Self);
    end;
end;
//****************************************************************************************************************************************************
procedure TiPlotDataView.SetGridLineMinorStyle(const Value: TiPlotGridLineStyle);
begin
  if FGridLineMinorStyle <> Value then
    begin
      FGridLineMinorStyle := Value;
      TriggerChange(Self);
    end;
end;
//****************************************************************************************************************************************************
procedure TiPlotDataView.SetGridLineXMajorStyle(const Value: TiPlotGridLineStyle);
begin
  if FGridLineXMajorStyle <> Value then
    begin
      FGridLineXMajorStyle := Value;
      TriggerChange(Self);
    end;
end;
//****************************************************************************************************************************************************
procedure TiPlotDataView.SetGridLineXMinorStyle(const Value: TiPlotGridLineStyle);
begin
  if FGridLineXMinorStyle <> Value then
    begin
      FGridLineXMinorStyle := Value;
      TriggerChange(Self);
    end;
end;
//****************************************************************************************************************************************************
procedure TiPlotDataView.SetGridLineYMajorStyle(const Value: TiPlotGridLineStyle);
begin
  if FGridLineYMajorStyle <> Value then
    begin
      FGridLineYMajorStyle := Value;
      TriggerChange(Self);
    end;
end;
//****************************************************************************************************************************************************
procedure TiPlotDataView.SetGridLineYMinorStyle(const Value: TiPlotGridLineStyle);
begin
  if FGridLineYMinorStyle <> Value then
    begin
      FGridLineYMinorStyle := Value;
      TriggerChange(Self);
    end;
end;
//****************************************************************************************************************************************************
procedure TiPlotDataView.Draw(const Canvas: TCanvas; const BackGroundColor: TColor);
begin
  inherited;
  with Canvas do
    begin
      DrawGrid(Canvas, BackGroundColor);
      if UserSelected then
        begin
          Pen.Color   := BackGroundColor;
          Brush.Style := bsClear;
          Brush.Color := BackGroundColor;

          PolyLine([Point(DrawRect.Left,  DrawRect.Top   ), Point(DrawRect.Left,    DrawRect.Bottom)]);
          PolyLine([Point(DrawRect.Right, DrawRect.Top   ), Point(DrawRect.Right,   DrawRect.Bottom)]);
          PolyLine([Point(DrawRect.Left,  DrawRect.Top   ), Point(DrawRect.Right,   DrawRect.Top   )]);
          PolyLine([Point(DrawRect.Left,  DrawRect.Bottom), Point(DrawRect.Right+1, DrawRect.Bottom)]);

          Font.Color := clWhite;
          iDrawFocusRect2(Canvas, Rect(DrawRect.Left, DrawRect.Top, DrawRect.Right+1, DrawRect.Bottom+1));
        end;

      case Mode of
        ipdvmZoomBox      : if FMouseDown then
                              begin
                                Font.Color := clWhite;
                                iDrawFocusRect2(Canvas, Rect(FMouseDownX, FMouseDownY, FMouseMoveX, FMouseMoveY));
                              end;
      end;
    end;
end;
//****************************************************************************************************************************************************
procedure TiPlotDataView.DrawGrid(const Canvas: TCanvas; const BackGroundColor: TColor);
var
  x          : Integer;
  MajorColor : TColor;
  MinorColor : TColor;
  MajorWidth : Integer;
  MinorWidth : Integer;
  MajorStyle : TiPlotGridLineStyle;
  MinorStyle : TiPlotGridLineStyle;
begin
  if not FGridShow then Exit;

  with Canvas do
    begin
      Brush.Color := BackGroundColor;
      
      if FGridLineXMajorCustom then
        begin
          MajorColor := FGridLineXMajorColor;
          MajorWidth := FGridLineXMajorWidth;
          MajorStyle := FGridLineXMajorStyle;
        end
      else
        begin
          MajorColor := FGridLineColor;
          {$IFDEF iCLX}
          MajorWidth := 1;
          {$ELSE}
          MajorWidth := 0;
          {$ENDIF}

          MajorStyle := FGridLineMajorStyle;
        end;

      if FGridLineXMinorCustom then
        begin
          MinorColor := FGridLineXMinorColor;
          MinorWidth := FGridLineXMinorWidth;
          MinorStyle := FGridLineXMinorStyle;
        end
      else
        begin
          MinorColor := FGridLineColor;
          {$IFDEF iCLX}
          MinorWidth := 1;
          {$ELSE}
          MinorWidth := 0;
          {$ENDIF}
          MinorStyle := FGridLineMinorStyle;
        end;

      if UpperCase(FGridXAxisName) = '<ALL>' then
        with Owner as TiPlotComponent do
          begin
            for x := 0 to XAxisCount-1 do
            TiPlotAxisAccess(XAxis[x]).DrawGridLines(Canvas, DrawRect, FGridLineShowXMajors, FGridLineShowXMinors, MajorStyle, MinorStyle,  MajorColor, MinorColor, MajorWidth, MinorWidth);
          end
      else
        begin
          XAxisNeeded;
          if Assigned(FXAxis) then
            TiPlotAxisAccess(FXAxis).DrawGridLines(Canvas, DrawRect, FGridLineShowXMajors, FGridLineShowXMinors, MajorStyle, MinorStyle,  MajorColor, MinorColor, MajorWidth, MinorWidth);
        end;

      if FGridLineYMajorCustom then
        begin
          MajorColor := FGridLineYMajorColor;
          MajorWidth := FGridLineYMajorWidth;
          MajorStyle := FGridLineYMajorStyle;
        end
      else
        begin
          MajorColor := FGridLineColor;
          MajorWidth := 0;
          MajorStyle := FGridLineMajorStyle;
        end;

      if FGridLineYMinorCustom then
        begin
          MinorColor := FGridLineYMinorColor;
          MinorWidth := FGridLineYMinorWidth;
          MinorStyle := FGridLineYMinorStyle;
        end
      else
        begin
          MinorColor := FGridLineColor;
          MinorWidth := 0;
          MinorStyle := FGridLineMinorStyle;
        end;

      if UpperCase(FGridYAxisName) = '<ALL>' then
        with Owner as TiPlotComponent do
          begin
            for x := 0 to YAxisCount-1 do
            TiPlotAxisAccess(YAxis[x]).DrawGridLines(Canvas, DrawRect, FGridLineShowYMajors, FGridLineShowYMinors, MajorStyle, MinorStyle,  MajorColor, MinorColor, MajorWidth, MinorWidth);
          end
      else
        begin
          YAxisNeeded;
          if Assigned(FYAxis) then
          TiPlotAxisAccess(FYAxis).DrawGridLines(Canvas, DrawRect, FGridLineShowYMajors, FGridLineShowYMinors, MajorStyle, MinorStyle,  MajorColor, MinorColor, MajorWidth, MinorWidth);
        end;

      Pen.Color := FGridLineColor;
      Pen.Style := psSolid;
      Pen.Width := 0;

      if FGridLineShowLeft   then PolyLine([Point(DrawRect.Left,  DrawRect.Top   ), Point(DrawRect.Left,    DrawRect.Bottom)]);
      if FGridLineShowRight  then PolyLine([Point(DrawRect.Right, DrawRect.Top   ), Point(DrawRect.Right,   DrawRect.Bottom)]);
      if FGridLineShowTop    then PolyLine([Point(DrawRect.Left,  DrawRect.Top   ), Point(DrawRect.Right,   DrawRect.Top   )]);
      if FGridLineShowBottom then PolyLine([Point(DrawRect.Left,  DrawRect.Bottom), Point(DrawRect.Right+1, DrawRect.Bottom)]);
    end;
end;
//****************************************************************************************************************************************************
procedure TiPlotDataView.DrawBackground(const Canvas: TCanvas; const BackGroundColor: TColor);
begin
  with Canvas do
    begin
      if not FBackgroundTransparent then
        begin
          Brush.Style := bsSolid;
          Brush.Color := FBackgroundColor;
          FillRect(DrawRect);
        end;
    end;
end;
//****************************************************************************************************************************************************
function TiPlotDataView.PixelsXToPositionPercent(Value: Integer): Double;
begin
  Result := (Value - Left)/Width*100;
end;
//****************************************************************************************************************************************************
function TiPlotDataView.PixelsYToPositionPercent(Value: Integer): Double;
begin
  Result := (1 - (Value - Top)/Height)*100;
end;
//****************************************************************************************************************************************************
function TiPlotDataView.PositionPercentToPixelsX(Value: Double): Integer;
begin
  Result := Round(Left + Width*Value/100);
end;
//****************************************************************************************************************************************************
function TiPlotDataView.PositionPercentToPixelsY(Value: Double): Integer;
begin
  Result := round(Top + Height*(100-Value)/100);
end;
//****************************************************************************************************************************************************
procedure TiPlotDataView.NotificationSetFocus(Sender: TObject);
begin
  if Sender = Self                             then Exit;
  if not (Sender as TiPlotObject).UserSelected then Exit;
            
  SetUserSelected(False);
end;
//****************************************************************************************************************************************************
procedure TiPlotDataView.XAxisNeeded;
begin
  if not Assigned(FXAxis) then FXAxis := (Owner as TiPlotComponent).GetXAxisByName(FGridXAxisName);
end;
//****************************************************************************************************************************************************
procedure TiPlotDataView.YAxisNeeded;
begin
  if not Assigned(FYAxis) then FYAxis := (Owner as TiPlotComponent).GetYAxisByName(FGridYAxisName);
end;
//****************************************************************************************************************************************************
function TiPlotDataView.GetMode: TiPlotDataViewMode;
begin
  Result := ipdvmNone;
  if FAxesControlEnabled then Result := ipdvmScrollZoom;
  if (Owner as TiPlotComponent).ToolBar[0].ZoomBoxActive then Result := ipdvmZoomBox;
  if (Owner as TiPlotComponent).ToolBar[0].SelectActive  then Result := ipdvmSelect;
end;
//****************************************************************************************************************************************************
end.

⌨️ 快捷键说明

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