mirror of
https://git.vladimir.cc/vladimir/ewsdr.git
synced 2026-08-25 20:37:33 +00:00
Add wideband spectrum fill option
This commit is contained in:
@@ -39,6 +39,7 @@ type
|
||||
FSourceStartHz: Double;
|
||||
FSourceEndHz: Double;
|
||||
FMarkerHz: Double;
|
||||
FFillSpectrum: Boolean;
|
||||
FWDSPAnalyzerOpen: Boolean;
|
||||
FWDSPAnalyzerConfigured: Boolean;
|
||||
FWDSPAnalyzerID: Integer;
|
||||
@@ -64,6 +65,7 @@ type
|
||||
procedure DrawHamBand(C: TCanvas; PlotW, H: Integer; F1, F2: Double;
|
||||
const Name: string; AColor: TColor);
|
||||
procedure DrawFrequencyMarker(C: TCanvas; PlotW, H: Integer);
|
||||
procedure DrawSpectrumGradient(const SpPts: array of TPoint; PlotW, H: Integer);
|
||||
procedure UploadBitmapToGL;
|
||||
public
|
||||
constructor Create;
|
||||
@@ -73,6 +75,7 @@ type
|
||||
function SetFrequencyView(ViewStartHz, ViewEndHz, SourceStartHz,
|
||||
SourceEndHz: Double): Boolean;
|
||||
function SetMarkerHz(AHz: Double): Boolean;
|
||||
procedure SetFillSpectrum(AFill: Boolean);
|
||||
function TryPixelToFrequency(PixelX, PanelWidth: Integer;
|
||||
out FreqHz: Double): Boolean;
|
||||
procedure SetSamples(const Samples: array of SmallInt; Count: Integer);
|
||||
@@ -111,6 +114,7 @@ begin
|
||||
FSourceStartHz := 0.0;
|
||||
FSourceEndHz := FSampleRateHz * 0.5;
|
||||
FMarkerHz := 0.0;
|
||||
FFillSpectrum := False;
|
||||
FWDSPAnalyzerOpen := False;
|
||||
FWDSPAnalyzerConfigured := False;
|
||||
FWDSPAnalyzerID := WB_WDSP_ID;
|
||||
@@ -187,6 +191,13 @@ begin
|
||||
Result := True;
|
||||
end;
|
||||
|
||||
procedure TWidebandView.SetFillSpectrum(AFill: Boolean);
|
||||
begin
|
||||
if FFillSpectrum = AFill then Exit;
|
||||
FFillSpectrum := AFill;
|
||||
FDirty := True;
|
||||
end;
|
||||
|
||||
function TWidebandView.TryPixelToFrequency(PixelX, PanelWidth: Integer;
|
||||
out FreqHz: Double): Boolean;
|
||||
var
|
||||
@@ -511,6 +522,44 @@ begin
|
||||
C.LineTo(X, H);
|
||||
end;
|
||||
|
||||
procedure TWidebandView.DrawSpectrumGradient(const SpPts: array of TPoint;
|
||||
PlotW, H: Integer);
|
||||
var
|
||||
Row, Col, Alpha, YMin, Off: Integer;
|
||||
RowPtr: PByte;
|
||||
GradB, GradG, GradR: Byte;
|
||||
begin
|
||||
if (PlotW <= 0) or (H <= 0) or (Length(SpPts) < PlotW) then Exit;
|
||||
YMin := H;
|
||||
for Col := 0 to PlotW - 1 do
|
||||
if SpPts[Col].Y < YMin then YMin := SpPts[Col].Y;
|
||||
if YMin >= H then Exit;
|
||||
|
||||
FBitmap.BeginUpdate(False);
|
||||
try
|
||||
for Row := YMin to H - 1 do
|
||||
begin
|
||||
Alpha := Round((1.0 - Sqr((Row - YMin) / Max(1.0, H - YMin - 1.0))) * 200);
|
||||
if Alpha <= 0 then Continue;
|
||||
if Alpha > 200 then Alpha := 200;
|
||||
GradB := Byte(FTheme.SpecGradB * Alpha div 200);
|
||||
GradG := Byte(FTheme.SpecGradG * Alpha div 200);
|
||||
GradR := Byte(FTheme.SpecGradR * Alpha div 200);
|
||||
RowPtr := PByte(FBitmap.ScanLine[Row]);
|
||||
for Col := 0 to PlotW - 1 do
|
||||
if SpPts[Col].Y <= Row then
|
||||
begin
|
||||
Off := Col * 4;
|
||||
RowPtr[Off] := (GradB * Alpha + RowPtr[Off] * (200 - Alpha)) div 200;
|
||||
RowPtr[Off + 1] := (GradG * Alpha + RowPtr[Off + 1] * (200 - Alpha)) div 200;
|
||||
RowPtr[Off + 2] := (GradR * Alpha + RowPtr[Off + 2] * (200 - Alpha)) div 200;
|
||||
end;
|
||||
end;
|
||||
finally
|
||||
FBitmap.EndUpdate(False);
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TWidebandView.DrawCPU(W, H: Integer);
|
||||
var
|
||||
C: TCanvas;
|
||||
@@ -586,6 +635,8 @@ begin
|
||||
Y := EnsureRange(Y, 1, TopH);
|
||||
FPoints[X] := Point(X, Y);
|
||||
end;
|
||||
if FFillSpectrum then
|
||||
DrawSpectrumGradient(FPoints, PlotW, H);
|
||||
C.Pen.Color := TColor($0040FF80);
|
||||
C.Polyline(FPoints);
|
||||
end;
|
||||
|
||||
Reference in New Issue
Block a user