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

📄 qiplotaxis.pas

📁 iocopm3.04源码,一套很好的工控开发工具
💻 PAS
📖 第 1 页 / 共 5 页
字号:
end;
//****************************************************************************************************************************************************
constructor TiPlotAxis.Create(AOwner: TObject; AOnChange, AOnInsert, AOnRemove, AOnRename: TNotifyEvent);
begin
  inherited Create(AOwner, AOnChange, AOnInsert, AOnRemove, AOnRename);

  FSpan                      := 100;
  FPreviousSpan              := 100;

  FMajorLength               := 7;
  FMinorLength               := 3;
  FMinorCount                := 1;

  FTitleMargin               := 0.25;

  FGridLinesVisible          := True;

  FScaleLinesShow            := True;

  FLabelsVisible             := True;
  FLabelSeparation           := 2;
  FLabelsMargin              := 0.25;

  FLabelsFormatStyle         := iptfValue;
  FDateTimeFormat            := 'hh:nn:ss';
  FLabelsPrecisionStyle      := ipsSignificantDigits;
  FLabelsPrecision           := 3;
  FLabelsMinLength           := 5;

  FCursorUseDefaultFormat    := True;
  FCursorFormatStyle         := iptfValue;
  FCursorDateTimeFormat      := 'hh:nn:ss';
  FCursorPrecisionStyle      := ipsSignificantDigits;
  FCursorPrecision           := 3;
  FCursorMinLength           := 5;

  FLegendUseDefaultFormat    := True;
  FLegendFormatStyle         := iptfValue;
  FLegendDateTimeFormat      := 'hh:nn:ss';
  FLegendPrecisionStyle      := ipsSignificantDigits;
  FLegendPrecision           := 3;
  FLegendMinLength           := 5;

  FStackingEndsMargin        := 0.5;

  FCartesianChildRefAxisName := '<None>';
  FAlignRefAxisName          := '<None>';

  FInnerMargin               := 5;
  FOuterMargin               := 5;

  FCursorScaler              := 1;
  FCursorPrecision           := 3;

  FScrollMax                 := 100;
  FScrollMinMaxEnabled       := False;

  FScaleLinesColor           := clWhite;
  FScaleLineShow             := True;

  TrackingEnabled            := True;

  FRestoreValuesOnResume     := True;

  FTickList                  := TStringList.Create;
  FTickList.Sorted           := False;

  FLabelsFont                := TFont.Create;
  FLabelsFont.OnChange       := TriggerChange;
  FLabelsFont.Color          := clWhite;

  FTitleFont                 := TFont.Create;
  FTitleFont.OnChange        := TriggerChange;
  FTitleFont.Color           := clWhite;
  FTitleFont.Name            := 'Arial';
  FTitleFont.Size            := 10;
  FTitleFont.Style           := [fsBold];
end;
//****************************************************************************************************************************************************
destructor TiPlotAxis.Destroy;
begin
  FLabelsFont.Free;
  FTitleFont.Free;

  ClearTickList;
  FTickList.Free;

  inherited Destroy;
end;
//****************************************************************************************************************************************************
procedure TiPlotAxis.NotificationRemove(Sender: TObject);
begin
  if Sender = FCartesianRefAxis then FCartesianRefAxis := nil;
  if Sender = FAlignRefAxis     then FAlignRefAxis     := nil;
end;
//****************************************************************************************************************************************************
procedure TiPlotAxis.NotificationRename(Sender: TObject);
begin
  if Sender = FCartesianRefAxis then FCartesianChildRefAxisName := (Sender as TiPlotAxis).Name;
end;
//****************************************************************************************************************************************************
procedure TiPlotAxis.SetCartesianChildRefAxisName(const Value: String);
begin
  if FCartesianChildRefAxisName <> Value then
    begin
      FCartesianChildRefAxisName := Value;
      FCartesianRefAxis          := nil;
      TriggerChange(Self);
    end;
end;
//****************************************************************************************************************************************************
procedure TiPlotAxis.SetAlignRefAxisName(const Value: String);
begin
  if FAlignRefAxisName <> Value then
    begin
      FAlignRefAxisName := Value;
      FAlignRefAxis     := nil;
      TriggerChange(Self);
    end;
end;
//****************************************************************************************************************************************************
function TiPlotAxis.GetCartesianRefAxis: TiPlotAxis;
begin
  if not Assigned(FCartesianRefAxis) then
    begin
      if Self is TiPlotXAxis then FCartesianRefAxis := TiPlotComponentAccess(Owner).GetYAxisByName(FCartesianChildRefAxisName)
      else                        FCartesianRefAxis := TiPlotComponentAccess(Owner).GetXAxisByName(FCartesianChildRefAxisName);
    end;
  Result := FCartesianRefAxis;
end;
//****************************************************************************************************************************************************
function TiPlotAxis.GetAlignRefAxis: TiPlotAxis;
begin
  if not Assigned(FAlignRefAxis) then
    begin
      if Self is TiPlotXAxis then FAlignRefAxis := TiPlotComponentAccess(Owner).GetXAxisByName(FAlignRefAxisName)
      else                        FAlignRefAxis := TiPlotComponentAccess(Owner).GetYAxisByName(FAlignRefAxisName);
    end;
  Result := FAlignRefAxis;
end;
//****************************************************************************************************************************************************
procedure TiPlotAxis.AddMenuItems(PopupMenu: TPopUpMenu);
var
  MenuItem       : TMenuItem;
  RestoreEnabled : Boolean;
begin
  inherited;
  AddEditMenuItems(PopupMenu);

                                                             RestoreEnabled := True;
  if     FTrackingEnabled                               then RestoreEnabled := False;
  if (FPreviousMin  = FMin) and (FPreviousSpan = FSpan) then RestoreEnabled := False;

  MenuItem         := TMenuItem.Create(PopupMenu);
  MenuItem.Caption := GetTranslation('Tracking Enabled');
  MenuItem.OnClick := TrackingEnabledMenuItemClick;
  MenuItem.Checked := FTrackingEnabled;
  PopupMenu.Items.Insert(0, MenuItem);

  MenuItem            := TMenuItem.Create(PopupMenu);
  MenuItem.Caption    := GetTranslation('Update Resume Values');
  MenuItem.OnClick    := UpdateResumeValuesMenuItemClick;
  MenuItem.Enabled    := RestoreEnabled;

  PopupMenu.Items.Insert(1, MenuItem);

  MenuItem            := TMenuItem.Create(PopupMenu);
  MenuItem.Caption    := GetTranslation('Zoom to Fit');
  MenuItem.OnClick    := ZoomToFitClick;

  PopupMenu.Items.Insert(2, MenuItem);
end;
//****************************************************************************************************************************************************
procedure TiPlotAxis.DoMouseHint(MouseData: TiPlotMouseData; var HintData: TiHintData);
begin
  if not FTitleShow then
    begin
      HintData.Text := FTitle;
      HintData.Left := MouseData.X;
      HintData.Top  := MouseData.Y-20;
    end;

  if Self is TiPlotXAxis then TiPlotComponentAccess(Owner as TiPlotComponent).DoXAxisCustomizeHint(Self as TiPlotXAxis, HintData.Text);
  if Self is TiPlotYAxis then TiPlotComponentAccess(Owner as TiPlotComponent).DoYAxisCustomizeHint(Self as TiPlotYAxis, HintData.Text);
end;
//****************************************************************************************************************************************************
procedure TiPlotAxis.DoMouseLeft(MouseData: TiPlotMouseData);
begin
  if FMasterUIInput then TiPlotComponentAccess(Owner).MasterAxisMouseLeft(Self, MouseData);

  FMouseDown     := True;
  FMouseDownX    := MouseData.X;
  FMouseDownY    := MouseData.Y;
end;
//****************************************************************************************************************************************************
procedure TiPlotAxis.DoMouseMove(MouseData: TiPlotMouseData);
var
  PercentChange : Double;
begin
  if not FMouseDown then Exit;

  if FMasterUIInput then TiPlotComponentAccess(Owner).MasterAxisMouseMove(Self, MouseData);

  if FMouseDown and (not MouseData.DblClickActive) then
    begin
      TriggerInvalidateNow(Self);
      TrackingEnabled := False;
      if IsHorz then
        begin
          if FReverseScale then PercentChange := (FMouseDownX - MouseData.X)/GetSpanLength
            else                PercentChange := (MouseData.X - FMouseDownX)/GetSpanLength;
        end
      else
        begin
          if FReverseScale then PercentChange := (MouseData.Y - FMouseDownY)/GetSpanLength
            else                PercentChange := (FMouseDownY - MouseData.Y)/GetSpanLength;
        end;
                                               

      case GetActualMode of
        ipamScroll : case
                       FScaleType of
                         ipstLinear : ScrollPercentByReference(Min, Span, Max, -PercentChange);
                         ipstLog10  : ScrollPercentByReference(Min, Max,  Max, -PercentChange);
                     end;
        ipamZoom   : begin
                       case FScaleType of
                         ipstLinear : ZoomPercentByReference(Min, Span, Max, PercentChange/4);
                         ipstLog10  : ZoomPercentByReference(Min, Span, Max, PercentChange*2);
                       end;
                     end;
      end;

      FMouseDownX := MouseData.X;
      FMouseDownY := MouseData.Y;
    end;
end;
//****************************************************************************************************************************************************
procedure TiPlotAxis.DoMouseUp(MouseData: TiPlotMouseData);
begin
  if FMasterUIInput then TiPlotComponentAccess(Owner).MasterAxisMouseUp(Self, MouseData);

  try
    if FMouseDown and iMouseHitTest(MouseData) then
      begin

⌨️ 快捷键说明

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