📄 sgr_def.pas
字号:
fbposAutoMin: if Assigned(fPlot) then
with fPlot do if DoAutoMinMax(Self) then Invalidate;
else
aInvalidatePlot;
end;
end;
procedure Tsp_Axis.StoreMinMax;
begin
if Not fMinMaxStored then begin
sMin:=Min; sMax:=Max; fMinMaxStored:=True;
end
end;
procedure Tsp_Axis.RestoreMinMax;
begin
if fMinMaxStored then begin
ChangeMinMax(sMin,sMax); fMinMaxStored:=False;
end;
end;
function Tsp_Axis.TickLabel(tickNum:integer): string;
begin
Result:=inherited TickLabel(tickNum);
with fPlot do
if Assigned(fOnTickLabel)
then fOnTickLabel(Self, tickNum, TksDbl(tickNum), Result);
end;
procedure Tsp_Axis.Assign(Source: TPersistent);
var ss:Tsp_Axis;
begin
if Source is Tsp_Axis then
begin
ss:=Tsp_Axis(Source);
fFlags:=ss.fFlags;
fO:=ss.fO;
fLen:=ss.fLen;
fTicksCount:=ss.fTicksCount;
fLabelFormat:=ss.fLabelFormat;
fMargin:=ss.fMargin;
fCaption:=ss.fCaption;
fDrawCaption:=ss.fDrawCaption;
fMinMaxStored:=False;
ChangeMinMax(ss.fMin, ss.Max);
fLineAttr.Assign(ss.fLineAttr);
fGrid.Assign(ss.fGrid);
fGrid.OnChange:=GridChanged;
fLineAttr.OnChange:=LineChanged;
end else inherited Assign(Source);
end;
procedure Tsp_Axis.AssignTo(Dest: TPersistent);
begin
if Dest is Tsp_Axis then Dest.Assign(Self)
else inherited AssignTo(Dest);
end;
procedure Tsp_Axis.SetMinMax(aMin,aMax:double);
begin
if (aMin<>fMin) or (aMax<>fMax)then ChangeMinMax(aMin,aMax);
fFlags:=fFlags and Not(sdfAutoMin or sdfAutoMax);
fMinMaxStored:=False;
aInvalidatePlot;
end;
procedure Tsp_Axis.MoveMinMax(aDelta:double);
begin
ShiftScaleBy(False,0,aDelta);
fFlags:=fFlags and Not(sdfAutoMin or sdfAutoMax);
fMinMaxStored:=False;
if Assigned(fPlot) then with fPlot do begin
CustomInvalidate(False,True,True);
end;
end;
procedure Tsp_PlotMarker.SetPlot(const Value: Tsp_XYPlot);
begin
if fPlot=Value then Exit;
if Assigned(fPlot) then fPlot.RemoveMarker(Self, fWhenDraw);
fPlot:=Value;
if Assigned(fPlot) then begin
if fWXA=dsxBottom then fXAx:=fPlot.BottomAxis else fXAx:=fPlot.TopAxis;
if fWYA=dsyLeft then fYAx:=fPlot.LeftAxis else fYAx:=fPlot.RightAxis;
if Assigned(fPlot) then
begin
fPlot.AddMarker(Self, fWhenDraw);
fPlot.FreeNotification(Self);
end;
end
else begin
fXAx:=nil; fYAx:=nil;
end;
end;
procedure Tsp_PlotMarker.Notification(AComponent:TComponent; Operation:TOperation);
begin
inherited Notification(AComponent, Operation);
if (Operation=opRemove) and (AComponent=fPlot) then
begin
fPlot:=nil;
end;
end;
procedure Tsp_PlotMarker.mInvalidatePlot;
begin
if Assigned(fPlot) then with fPlot do CustomInvalidate(False,False,True);
end;
procedure Tsp_PlotMarker.SetWhenDraw(V:Tsp_WhenDrawMarker);
begin
if (V<>fWhenDraw) then begin
if Assigned(fPlot) then fPlot.RemoveMarker(Self, fWhenDraw);
fWhenDraw:=V;
if Assigned(fPlot) then fPlot.AddMarker(Self, fWhenDraw);
end;
end;
procedure Tsp_PlotMarker.SetWXA(const V:Tsp_WhatXAxis);
begin
if V<>fWXA then begin
fWXA:=V;
if fWXA=dsxBottom then fXAx:=fPlot.BottomAxis else fXAx:=fPlot.TopAxis;
mInvalidatePlot;
end;
end;
procedure Tsp_PlotMarker.SetWYA(const V:Tsp_WhatYAxis);
begin
if V<>fWYA then begin
fWYA:=V;
if fWYA=dsyLeft then fYAx:=fPlot.LeftAxis else fYAx:=fPlot.RightAxis;
mInvalidatePlot;
end;
end;
procedure Tsp_PlotMarker.SetVisible(const V:boolean);
begin
if V<>fVisible then begin
fVisible:=V;
mInvalidatePlot;
end;
end;
procedure Tsp_PlotMarker.BringToFront;
begin
if Assigned(fPlot) then fPlot.SetMarkerAt(Self, fWhenDraw, True);
end;
procedure Tsp_PlotMarker.SendToBack;
begin
if Assigned(fPlot) then fPlot.SetMarkerAt(Self, fWhenDraw, False);
end;
constructor Tsp_DataSeries.Create(AOwner:TComponent);
begin
inherited Create(AOwner);
fWXA:=dsxBottom;
fWYA:=dsyLeft;
end;
procedure Tsp_DataSeries.SetPlot(const Value: Tsp_XYPlot);
begin
if fPlot=Value then Exit;
if Assigned(fPlot) then fPlot.RemoveSeries(Self);
fPlot:=Value;
if Assigned(fPlot) then
begin
fPlot.AddSeries(Self);
fPlot.FreeNotification(Self);
end;
end;
procedure Tsp_DataSeries.Notification(AComponent:TComponent; Operation:TOperation);
begin
inherited Notification(AComponent, Operation);
if (Operation=opRemove) and (AComponent=fPlot) then
begin
fPlot:=nil;
end;
end;
procedure Tsp_DataSeries.SetActive(const V:boolean);
begin
if V<>fActive then
begin
fActive:=V;
if Assigned(fPlot) then fPlot.InvalidateSeries(Self)
end;
end;
procedure Tsp_DataSeries.SetWXA(const V:Tsp_WhatXAxis);
begin
if V<>fWXA then
begin
fWXA:=V;
if Assigned(fPlot) then with fPlot do
if DoAutoMinMax(LA) or DoAutoMinMax(RA) then Invalidate;
end;
end;
procedure Tsp_DataSeries.SetWYA(const V:Tsp_WhatYAxis);
begin
if V<>fWYA then
begin
fWYA:=V;
if Assigned(fPlot) then with fPlot do
begin
if DoAutoMinMax(BA) or DoAutoMinMax(TA) then Invalidate;
end;
end;
end;
procedure Tsp_DataSeries.SetLegend(const V:string);
begin
if V<>fLegend then begin
fLegend:=V;
DoOnChange;
end;
end;
procedure Tsp_DataSeries.DoOnChange;
begin
end;
procedure Tsp_DataSeries.DrawLegendMarker(const LCanvas:TCanvas; MR:TRect);
begin
end;
procedure Tsp_DataSeries.InvalidatePlot(const Reason:TIP_Reason);
begin
if Not Active then Exit;
if Assigned(fPlot) then with fPlot do
case Reason of
rsDataChanged: InvalidateSeries(Self);
rsAttrChanged: CustomInvalidate(False,False,True);
end;
end;
procedure Tsp_DataSeries.BringToFront;
var ci:integer;
begin
if Assigned(fPlot) then with fPlot.fSeries do
if Last<>Self then
begin
ci:=IndexOf(Self);
if (ci>-1) then Move(ci, fPlot.fSeries.Count-1);
end;
end;
procedure Tsp_DataSeries.SendToBack;
var ci:integer;
begin
if Assigned(fPlot) then with fPlot.fSeries do
begin
ci:=IndexOf(Self);
if ci>0 then Move(ci,0);
end;
end;
procedure Tsp_XYPlot.CMTextChanged(var Message: TMessage);
begin
Invalidate;
end;
procedure Tsp_XYPlot.CMFontChanged(var Message: TMessage);
begin
ValidArrange:=False;
ValidAround:=False; ValidField:=False;
FreshVFont;
inherited;
end;
procedure Tsp_XYPlot.CMSysColorChange(var Message: TMessage);
begin
SysColorChange;
inherited;
end;
procedure Tsp_XYPlot.SysColorChange;
begin
if fBuffered then
begin
fDDBBuf.Recreate(Width, Height);
if fDDBBuf.Valid then DrawPlot(fDDBBuf.Canvas, Width, Height);
end;
end;
procedure Tsp_XYPlot.WMSize(var Message: TWMSize);
begin
Invalidate;
end;
procedure Tsp_XYPlot.WMWindowPosChanged(var Message: TWMWindowPosChanged);
begin
inherited;
end;
procedure Tsp_XYPlot.WMERASEBKGND(var Message: TWMERASEBKGND);
begin
Message.Result:=1;
end;
procedure Tsp_XYPlot.SetLA(const V:Tsp_Axis);
begin
if V<>LA then LA.Assign(V);
end;
procedure Tsp_XYPlot.SetRA(const V:Tsp_Axis);
begin
if V<>RA then RA.Assign(V);
end;
procedure Tsp_XYPlot.SetBA(const V:Tsp_Axis);
begin
if V<>BA then BA.Assign(V);
end;
procedure Tsp_XYPlot.SetTA(const V:Tsp_Axis);
begin
if V<>TA then TA.Assign(V);
end;
procedure Tsp_XYPlot.SetFBColor(const V:TColor);
begin
if V<>FBColor then
begin
FBColor:=V;
CustomInvalidate(False, False, True);
end;
end;
procedure Tsp_XYPlot.SetBorderStyle(const V:Tsp_BorderStyle );
begin
if V<> FFrameStyle then begin
FFrameStyle := V;
if BufferedDisplay then BufferIsInvalid;
DrawBorder;
if csDesigning in ComponentState then Invalidate;
end;
end;
procedure Tsp_XYPlot.SetBuffered(const V:boolean);
begin
if V=fBuffered then Exit;
if V then begin
fDDBBuf:=Tsp_MemBitmap.Create(Width, Height);
end
else begin
if Assigned(fDDBBuf) then fDDBBuf.Free;
fDDBBuf:=nil;
end;
fBuffered:=Assigned(fDDBBuf);
Invalidate;
end;
procedure Tsp_XYPlot.SetZoomShift(const V:Tsp_ShiftKeys);
begin
fZoomShift:=[ssLeft]+TShiftState(V);
end;
function Tsp_XYPlot.GetZoomShift:Tsp_ShiftKeys;
var S:TShiftState;
begin
S:=fZoomShift-[ssLeft];
Result:=Tsp_ShiftKeys(S);
end;
procedure Tsp_XYPlot.SetPanShift(const V:Tsp_ShiftKeys);
begin
fPanShift:=TShiftState(V)+[ssLeft];
end;
function Tsp_XYPlot.GetPanShift:Tsp_ShiftKeys;
var S:TShiftState;
begin
S:=fPanShift-[ssLeft];
Result:=Tsp_ShiftKeys(S);
end;
procedure Tsp_XYPlot.DrawXCursor;
begin
with Canvas do begin
with Pen do begin
Mode:=pmNot;
Style:=psSolid;
end;
with FR do if (fXCursPos>Left) and (fXCursPos<Right) then
begin
MoveTo(fXCursPos, Top+1);
LineTo(fXCursPos, Bottom-1);
end;
end;
end;
procedure Tsp_XYPlot.DrawXCursorOnPaint;
begin
if fXCursOn then
begin
fXCursPos:=BA.V2P(fXCursVal);
DrawXCursor;
end;
end;
procedure Tsp_XYPlot.SetXCursVal(V:double);
var tpos:integer;
begin
tpos:=BA.V2P(V);
fXCursVal:=V;
if fXCursPos<>tpos then
begin
if fXCursOn then begin
DrawXCursor;
fXCursPos:=tpos;
DrawXCursor;
end;
end;
end;
procedure Tsp_XYPlot.SetXCursOn(const V:boolean);
begin
if V<>fXCursOn then begin
fXCursOn:=V;
if fXCursOn then DrawXCursorOnPaint else DrawXCursor;
end;
end;
function Tsp_XYPlot.GetSeriesPtr(i:integer):Tsp_DataSeries;
begin
Result:=fSeries[i];
end;
function Tsp_XYPlot.GetSeriesCount:integer;
begin
Result:=fSeries.Count;
end;
procedure Tsp_XYPlot.AddSeries(const DS:Tsp_DataSeries);
begin
if DS<>nil then begin
with fSeries do if IndexOf(DS)<0 then Add(DS);
if DS.Active then InvalidateSeries(DS);
end;
end;
procedure Tsp_XYPlot.RemoveSeries(const DS:Tsp_DataSeries);
begin
fSeries.Remove(DS);
if (DS<>nil) and DS.Active then InvalidateSeries(DS);
end;
function Tsp_XYPlot.MarkerList(const WDM:Tsp_WhenDrawMarker):TList;
begin
if WDM=dmBeforeSeries then Result:=fBSML else Result:=fASML;
end;
procedure Tsp_XYPlot.RemoveMarker(const FM:Tsp_PlotMarker; const WDM:Tsp_WhenDrawMarker);
begin
MarkerList(WDM).Remove(FM);
if (FM<>nil) and FM.Visible then CustomInvalidate(False,False,True);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -