📄 qiplotchannelcustom.pas
字号:
procedure DeletePoints(Size: Integer);
procedure SavePropertiesToFile (FileName: String);
procedure LoadPropertiesFromFile(FileName: String);
procedure SaveDataToFile (FileName: String);
procedure LoadDataFromFile(FileName: String; ClearPreviousData: Boolean);
procedure LogActivate(Append: Boolean);
procedure LogDeactivate;
function GetXMin : Double;
function GetXMax : Double;
function GetXMean: Double;
function GetYMin : Double;
function GetYMax : Double;
function GetYMean: Double;
procedure ReCalcRunningMinMaxMean;
function GetXValueText(Value: Double): String;
function GetYValueText(Value: Double): String;
procedure GetXYEmptyNull(const Index: Integer; var X, Y: Double; var Empty, Null: Boolean);
{$IFDEF iVCL}
procedure OPCActivate;
procedure OPCActivateSuspend;
procedure OPCDeactivate;
procedure OPCUpdateSuspend;
procedure OPCUpdateResume;
{$endif}
property XAxis : TiPlotXAxis read GetXAxis;
property YAxis : TiPlotYAxis read GetYAxis;
property DrawStartIndex : Integer read FStartIndex;
property DrawStopIndex : Integer read FStopIndex;
property DataPointSize : Integer read GetDataPointSize;
property MaxDataPoints : Integer read GetMaxDataPoints;
property Capacity : Integer read GetCapacity;
property MemoryUsed : Integer read GetMemoryUsed;
property Count : Integer read GetCount write SetCount;
property DataX [const Index: Integer]: Double read GetDataX write SetDataX;
property DataY [const Index: Integer]: Double read GetDataY write SetDataY;
property DataNull [const Index: Integer]: Boolean read GetDataNull write SetDataNull;
property DataEmpty [const Index: Integer]: Boolean read GetDataEmpty write SetDataEmpty;
property DataTraceLineColor [const Index: Integer]: TColor read GetDataTraceLineColor write SetDataTraceLineColor;
property DataTraceLineWidth [const Index: Integer]: Integer read GetDataTraceLineWidth write SetDataTraceLineWidth;
property DataTraceLineStyle [const Index: Integer]: TiPlotLineStyle read GetDataTraceLineStyle write SetDataTraceLineStyle;
property DataMarkerShowing [const Index: Integer]: Boolean read GetDataMarkerShowing;
property DataMarkerShow [const Index: Integer]: Boolean read GetDataMarkerShow write SetDataMarkerShow;
property DataMarkerStyle [const Index: Integer]: TiPlotMarkerStyle read GetDataMarkerStyle write SetDataMarkerStyle;
property DataMarkerSize [const Index: Integer]: Integer read GetDataMarkerSize write SetDataMarkerSize;
property DataMarkerPenColor [const Index: Integer]: TColor read GetDataMarkerPenColor write SetDataMarkerPenColor;
property DataMarkerPenStyle [const Index: Integer]: TPenStyle read GetDataMarkerPenStyle write SetDataMarkerPenStyle;
property DataMarkerPenWidth [const Index: Integer]: Integer read GetDataMarkerPenWidth write SetDataMarkerPenWidth;
property DataMarkerBrushColor[const Index: Integer]: TColor read GetDataMarkerBrushColor write SetDataMarkerBrushColor;
property DataMarkerBrushStyle[const Index: Integer]: TBrushStyle read GetDataMarkerBrushStyle write SetDataMarkerBrushStyle;
property DataMarkerCharacter [const Index: Integer]: Char read GetDataMarkerCharacter write SetDataMarkerCharacter;
property RunningXMin : Double read FRunningXMin;
property RunningXMax : Double read FRunningXMax;
property RunningXMean : Double read FRunningXMean;
property RunningYMin : Double read FRunningYMin;
property RunningYMax : Double read FRunningYMax;
property RunningYMean : Double read FRunningYMean;
property DataXDrawMax[Index: Integer]: Double read GetDataXDrawMax;
property DataXDrawMin[Index: Integer]: Double read GetDataXDrawMin;
property DataYDrawMax[Index: Integer]: Double read GetDataYDrawMax;
property DataYDrawMin[Index: Integer]: Double read GetDataYDrawMin;
property DataCursorXText : String read FDataCursorXText;
property DataCursorYText : String read FDataCursorYText;
property DataCursorXValue : Double read FDataCursorXValue;
property DataCursorYValue : Double read FDataCursorYValue;
property DataCursorStatus : TiPlotDataPointStatus read FDataCursorStatus;
{$IFDEF iVCL}
property OPCActive : Boolean read GetOPCActive;
property OPCQualityGood : Boolean read GetOPCQualityGood;
{$endif}
published
property TitleText : String read FTitleText write SetTitleText;
property VisibleInLegend : Boolean read FVisibleInLegend write SetVisibleInLegend default True;
property RingBufferSize : Integer read GetRingBufferSize write SetRingBufferSize default 0;
property TraceVisible : Boolean read FTraceVisible write SetTraceVisible default True;
property Color : TColor read GetColor write SetColor default clRed;
property TraceLineStyle : TiPlotLineStyle read GetTraceLineStyle write SetTraceLineStyle default iplsSolid;
property TraceLineWidth : Integer read GetTraceLineWidth write SetTraceLineWidth default 1;
property MarkersAllowIndividual : Boolean read FMarkersAllowIndividual write SetMarkersAllowIndividual default False;
property MarkersPenUseChannelColor : Boolean read FMarkersPenUseChannelColor write SetMarkersPenUseChannelColor default True;
property MarkersBrushUseChannelColor : Boolean read FMarkersBrushUseChannelColor write SetMarkersBrushUseChannelColor default True;
property MarkersTurnOffLimit : Integer read FMarkersTurnOffLimit write SetMarkersTurnOffLimit;
property MarkersVisible : Boolean read GetMarkersVisible write SetMarkersVisible default False;
property MarkersSize : Integer read GetMarkersSize write SetMarkersSize default 3;
property MarkersStyle : TiPlotMarkerStyle read GetMarkersStyle write SetMarkersStyle default ipmsCircle;
property MarkersPenColor : TColor read GetMarkersPenColor write SetMarkersPenColor default clRed;
property MarkersPenStyle : TPenStyle read GetMarkersPenStyle write SetMarkersPenStyle default psSolid;
property MarkersPenWidth : Integer read GetMarkersPenWidth write SetMarkersPenWidth default 0;
property MarkersBrushColor : TColor read GetMarkersBrushColor write SetMarkersBrushColor default clRed;
property MarkersBrushStyle : TBrushStyle read GetMarkersBrushStyle write SetMarkersBrushStyle default bsSolid;
property MarkersFont : TFont read FMarkersFont write SetMarkersFont;
property XAxisName : String read FXAxisName write SetXAxisName;
property YAxisName : String read FYAxisName write SetYAxisName;
property XAxisTrackingEnabled : Boolean read FXAxisTrackingEnabled write SetXAxisTrackingEnabled default True;
property YAxisTrackingEnabled : Boolean read FYAxisTrackingEnabled write SetYAxisTrackingEnabled default True;
property LogFileName : String read FLogFileName write SetLogFileName;
property LogBufferSize : Integer read FLogBufferSize write SetLogBufferSize default 0;
property LoggingActive : Boolean read FLoggingActive;
property DataStyle : TiPlotDataStyle read FDataStyle write SetDataStyle;
property Tag : OleVariant read FTag write FTag;
{$IFDEF iVCL}
property OPCGroupName : String read GetOPCGroupName write SetOPCGroupName;
property OPCComputerName : String read GetOPCComputerName write SetOPCComputerName;
property OPCServerName : String read GetOPCServerName write SetOPCServerName;
property OPCItemName : String read GetOPCItemName write SetOPCItemName;
property OPCUpdateRate : Integer read GetOPCUpdateRate write SetOPCUpdateRate default 500;
property OPCAutoConnect : Boolean read GetOPCAutoConnect write SetOPCAutoConnect default True;
{$endif}
end;
TiPlotChannelCustomClass = class of TiPlotChannelCustom;
implementation
uses
{$ifdef iVCL} iPlotComponent, iPlotDataCursor, iPlotLegend;{$endif}
{$ifdef iCLX}QiPlotComponent, QiPlotDataCursor, QiPlotLegend;{$endif}
type
TiPlotDataCursorAccess = class(TiPlotDataCursor)end;
TiPlotComponentAccess = class(TiPlotComponent )end;
//****************************************************************************************************************************************************
constructor TiPlotChannelCustom.Create(AOwner: TObject; AOnChange, AOnInsert, AOnRemove, AOnRename: TNotifyEvent);
begin
inherited;
FDataList := TiPlotDataNullList.Create;
FVisibleInLegend := True;
FXAxisTrackingEnabled := True;
FYAxisTrackingEnabled := True;
FTraceVisible := True;
FMarkersBrushUseChannelColor := True;
FMarkersPenUseChannelColor := True;
FRunningXMax := -1E+300;
FRunningXMin := 1E+300;
FRunningXMean := 0;
FRunningYMax := -1E+300;
FRunningYMin := 1E+300;
FRunningYMean := 0;
SetColor (clRed);
SetTraceLineWidth (1);
SetTraceLineStyle (iplsSolid);
SetMarkersSize (3);
SetMarkersPenColor (clRed);
SetMarkersBrushColor(clRed);
FMarkersFont := TFont.Create;
FMarkersFont.Color := clWhite;
FMarkersFont.Style := [fsBold];
FMarkersFont.OnChange := TriggerChange;
{$IFDEF iVCL}
FOPCItemManager := TiOPCItemManager.Create;
FOPCItemManager.OnGetDesigning := TiPlotComponentAccess(Owner).DoIsDesigning;
FOPCItemManager.OnNewData := OPCNewData;
FOPCItemManager.Add;
FOPCItemManager.Items[0].PropertyName := 'Data';
{$endif}
end;
//****************************************************************************************************************************************************
destructor TiPlotChannelCustom.Destroy;
begin
{$IFDEF iVCL}FOPCItemManager.Free;{$endif}
FMarkersFont.Free;
FDataList.Free;
inherited;
end;
//****************************************************************************************************************************************************
function TiPlotChannelCustom.GetXAxis: TiPlotXAxis;
begin
if not Assigned(FXAxis)then FXAxis:=(Owner as TiPlotComponent).GetXAxisByName(FXAxisName);
Result := FXAxis;
end;
//****************************************************************************************************************************************************
function TiPlotChannelCustom.GetYAxis: TiPlotYAxis;
begin
if not Assigned(FYAxis)then FYAxis:=(Owner as TiPlotComponent).GetYAxisByName(FYAxisName);
Result := FYAxis;
end;
//****************************************************************************************************************************************************
procedure TiPlotChannelCustom.NotificationRemove(Sender: TObject);
begin
if Sender = FXAxis then FXAxis := nil;
if Sender = FYAxis then FYAxis := nil;
end;
//****************************************************************************************************************************************************
procedure TiPlotChannelCustom.NotificationRename(Sender: TObject);
begin
if Sender = FXAxis then FXAxisName := (Sender as TiPlotXAxis).Name;
if Sender = FYAxis then FYAxisName := (Sender as TiPlotYAxis).Name;
end;
//****************************************************************************************************************************************************
procedure TiPlotChannelCustom.SetXAxisName(const Value:String);
begin
if FXAxisName <> Value then
begin
FXAxisName := Value;
FXAxis := nil;
TriggerChange(Self);
end;
end;
//****************************************************************************************************************************************************
procedure TiPlotChannelCustom.SetYAxisName(const Value:String);
begin
if FYAxisName <> Value then
begin
FYAxisName := Value;
FYAxis := nil;
TriggerChange(Self);
end;
end;
//****************************************************************************************************************************************************
procedure TiPlotChannelCustom.SetTitleText (const Value:String );begin SetStringProperty (Value,FTitleText, TriggerChange );end;
procedure TiPlotChannelCustom.SetTraceVisible (const Value:Boolean);begin SetBooleanProperty(Value,FTraceVisible, TriggerChange );end;
procedure TiPlotChannelCustom.SetMarkersAllowIndividual (const Value:Boolean);begin SetBooleanProperty(Value,FMarkersAllowIndividual, TriggerChange );end;
procedure TiPlotChannelCustom.SetXAxisTrackingEnabled (const Value:Boolean);begin SetBooleanProperty(Value,FXAxisTrackingEnabled, TriggerChange );end;
procedure TiPlotChannelCustom.SetYAxisTrackingEnabled (const Value:Boolean);begin SetBooleanProperty(Value,FYAxisTrackingEnabled, TriggerChange );end;
procedure TiPlotChannelCustom.SetVisibleInLegend (const Value:Boolean);begin SetBooleanProperty(Value,FVisibleInLegend, TriggerChange );end;
procedure TiPlotChannelCustom.SetMarkersBrushUseChannelColor(const Value:Boolean);begin SetBooleanProperty(Value,FMarkersBrushUseChannelColor,TriggerChange );end;
procedure TiPlotChannelCustom.SetMarkersPenUseChannelColor (const Value:Boolean);begin SetBooleanProperty(Value,FMarkersPenUseChannelColor, TriggerChange );end;
procedure TiPlotChannelCustom.SetLogBufferSize (const Value:Integer);begin SetIntegerProperty(Value,FLogBufferSize, nil );end;
procedure TiPlotChannelCustom.SetMarkersTurnOffLimit (const Value:Integer);begin SetIntegerProperty(Value,FMarkersTurnOffLimit, TriggerChange );end;
//****************************************************************************************************************************************************
procedure TiPlotChannelCustom.SetMarkersFont(const Value: TFont);begin FMarkersFont.Assign(Value);end;
//****************************************************************************************************************************************************
{$IFDEF iVCL}
procedure TiPlotChannelCustom.SetOPCGroupName (const Value:String );begin FOPCItemManager.Items[0].GroupName := Value; end;
procedure TiPlotChannelCustom.SetOPCComputerName(const Value:String );begin FOPCItemManager.Items[0].ComputerName := Value; end;
procedure TiPlotChannelCustom.SetOPCServerName (const Value:String );begin FOPCItemManager.Items[0].ServerName := Value; end;
procedure TiPlotChannelCustom.SetOPCItemName (const Value:String );begin FOPCItemManager.Items[0].ItemName := Value; end;
procedure TiPlotChannelCustom.SetOPCUpdateRate (const Value:Integer);begin FOPCItemManager.Items[0].UpdateRate := Value; end;
procedure TiPlotChannelCustom.SetOPCAutoConnect (const Value:Boolean);begin FOPCItemManager.Items[0].AutoConnect := Value; end;
//****************************************************************************************************************************************************
function TiPlotChannelCustom.GetOPCGroupName : String; begin Result := FOPCItemManager.Items[0].GroupName; end;
function TiPlotChannelCustom.GetOPCComputerName : String; begin Result := FOPCItemManager.Items[0].ComputerName; end;
function TiPlotChannelCustom.GetOPCItemName : String; begin Result := FOPCItemManager.Items[0].ItemName; end;
function TiPlotChannelCustom.GetOPCServerName : String; begin Result := FOPCItemManager.Items[0].ServerName; end;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -