mirror of
https://git.vladimir.cc/vladimir/ewsdr.git
synced 2026-08-25 18:43:51 +00:00
Add OpenGL spectrum renderer
This commit is contained in:
+58
-13
@@ -25,6 +25,7 @@ uses
|
||||
Classes, SysUtils, StrUtils, FreqDisplay, DeviceForm, VfoOverlay, SampleRateOverlay,
|
||||
FlatButton, FlatSlider, FlatDropDown, AppTheme, Forms, Controls, Graphics, Dialogs,
|
||||
StdCtrls, ExtCtrls, Buttons, Menus, Math, Types,
|
||||
OpenGLContext,
|
||||
FlatProgressBar,
|
||||
LCLIntf, LCLType, GraphType,
|
||||
HPSDRProtocol, HPSDRNetwork,
|
||||
@@ -32,7 +33,7 @@ uses
|
||||
Settings,
|
||||
WebServer,
|
||||
CATEngine, CATSerial, CATTcp,
|
||||
SpectrumView,
|
||||
SpectrumView, SpectrumViewOpengl,
|
||||
StatusBar,
|
||||
WinFirewall;
|
||||
|
||||
@@ -265,6 +266,7 @@ type
|
||||
|
||||
// ---- Spectrum / Waterfall view ----
|
||||
FSpecView: TSpectrumView;
|
||||
FUseOpenGLSpectrum: Boolean;
|
||||
FSpectrumWidth: Integer; // актуальная ширина для FDSPEngine и resize-детектора
|
||||
FSpectrumHeight: Integer;
|
||||
FWaterfallHeight:Integer;
|
||||
@@ -426,7 +428,7 @@ type
|
||||
|
||||
// ---- Right panel ----
|
||||
PanelRight: TPanel;
|
||||
PbSpectrum: TPaintBox;
|
||||
PbSpectrum: TControl;
|
||||
PbRuler: TPaintBox; // полоса частотных меток между спектром и водопадом
|
||||
PanelSplitter: TPanel; // перетаскиваемый разделитель спектр/водопад
|
||||
PbWaterfall: TPaintBox;
|
||||
@@ -766,6 +768,20 @@ uses SettingsForm;
|
||||
|
||||
{$R *.lfm}
|
||||
|
||||
function HasOpenGLSpectrumSwitch: Boolean;
|
||||
var
|
||||
I: Integer;
|
||||
S: string;
|
||||
begin
|
||||
Result := False;
|
||||
for I := 1 to ParamCount do
|
||||
begin
|
||||
S := LowerCase(ParamStr(I));
|
||||
if (S = '--opengl') or (S = '-opengl') or (S = '/opengl') then
|
||||
Exit(True);
|
||||
end;
|
||||
end;
|
||||
|
||||
function TMainForm.LeftPanelButtonWidth(PanelWidth, ColCount,
|
||||
ColIndex: Integer): Integer;
|
||||
var
|
||||
@@ -1452,7 +1468,11 @@ begin
|
||||
FSplitterRatio := 0.40;
|
||||
FSplitterDrag := False;
|
||||
|
||||
FSpecView := TSpectrumView.Create;
|
||||
FUseOpenGLSpectrum := HasOpenGLSpectrumSwitch;
|
||||
if FUseOpenGLSpectrum then
|
||||
FSpecView := TSpectrumViewOpenGL.Create
|
||||
else
|
||||
FSpecView := TSpectrumView.Create;
|
||||
FSpecView.VfoOverlay := FVfoOverlay;
|
||||
FSpecView.VfoA := FVfoA;
|
||||
FSpecView.VfoB := FVfoB;
|
||||
@@ -2124,14 +2144,30 @@ begin
|
||||
PbSMeterRight.OnPaint := FSpecView.PaintSMeterRight;
|
||||
PbSMeterRight.Color := CLR_PANEL;
|
||||
|
||||
PbSpectrum := TPaintBox.Create(Self);
|
||||
if FUseOpenGLSpectrum then
|
||||
begin
|
||||
PbSpectrum := TOpenGLControl.Create(Self);
|
||||
TOpenGLControl(PbSpectrum).AutoResizeViewport := False;
|
||||
TOpenGLControl(PbSpectrum).DoubleBuffered := True;
|
||||
TOpenGLControl(PbSpectrum).OnPaint := FSpecView.PaintSpectrum;
|
||||
TOpenGLControl(PbSpectrum).OnMouseDown := PbSpectrumMouseDown;
|
||||
TOpenGLControl(PbSpectrum).OnDblClick := PbSpectrumDblClick;
|
||||
TOpenGLControl(PbSpectrum).OnMouseMove := PbSpectrumMouseMove;
|
||||
TOpenGLControl(PbSpectrum).OnMouseUp := PbSpectrumMouseUp;
|
||||
TOpenGLControl(PbSpectrum).OnMouseLeave := PbSpectrumMouseLeave;
|
||||
TSpectrumViewOpenGL(FSpecView).AttachControl(TOpenGLControl(PbSpectrum));
|
||||
end
|
||||
else
|
||||
begin
|
||||
PbSpectrum := TPaintBox.Create(Self);
|
||||
TPaintBox(PbSpectrum).OnPaint := FSpecView.PaintSpectrum;
|
||||
TPaintBox(PbSpectrum).OnMouseDown := PbSpectrumMouseDown;
|
||||
TPaintBox(PbSpectrum).OnDblClick := PbSpectrumDblClick;
|
||||
TPaintBox(PbSpectrum).OnMouseMove := PbSpectrumMouseMove;
|
||||
TPaintBox(PbSpectrum).OnMouseUp := PbSpectrumMouseUp;
|
||||
TPaintBox(PbSpectrum).OnMouseLeave := PbSpectrumMouseLeave;
|
||||
end;
|
||||
PbSpectrum.Parent := PanelRight;
|
||||
PbSpectrum.OnPaint := FSpecView.PaintSpectrum;
|
||||
PbSpectrum.OnMouseDown := PbSpectrumMouseDown;
|
||||
PbSpectrum.OnDblClick := PbSpectrumDblClick;
|
||||
PbSpectrum.OnMouseMove := PbSpectrumMouseMove;
|
||||
PbSpectrum.OnMouseUp := PbSpectrumMouseUp;
|
||||
PbSpectrum.OnMouseLeave := PbSpectrumMouseLeave;
|
||||
|
||||
PbRuler := TPaintBox.Create(Self);
|
||||
PbRuler.Parent := PanelRight;
|
||||
@@ -2578,7 +2614,8 @@ begin
|
||||
DP(PanelRX); DP(PanelTX);
|
||||
DP(PanelRight);
|
||||
|
||||
PbSpectrum.Color := T.BG;
|
||||
if PbSpectrum is TPaintBox then
|
||||
TPaintBox(PbSpectrum).Color := T.BG;
|
||||
PbWaterfall.Color := T.BG;
|
||||
if PanelSMeterRight <> nil then PanelSMeterRight.Color := T.Panel;
|
||||
if PbSMeterRight <> nil then PbSMeterRight.Color := T.Panel;
|
||||
@@ -2732,7 +2769,11 @@ end;
|
||||
procedure TMainForm.OnSampleRateOverlayInvalidate(Sender: TObject);
|
||||
begin
|
||||
FSpectrumDirty := True;
|
||||
if Assigned(FSpecView) then FSpecView.SpectrumDirty := True;
|
||||
if Assigned(FSpecView) then
|
||||
begin
|
||||
FSpecView.SpectrumDirty := True;
|
||||
FSpecView.InvalidateOverlayCache;
|
||||
end;
|
||||
if Assigned(PbSpectrum) then PbSpectrum.Invalidate;
|
||||
end;
|
||||
|
||||
@@ -5610,7 +5651,11 @@ end;
|
||||
procedure TMainForm.OnVfoOverlayInvalidate(Sender: TObject);
|
||||
begin
|
||||
FSpectrumDirty := True;
|
||||
if Assigned(FSpecView) then FSpecView.SpectrumDirty := True;
|
||||
if Assigned(FSpecView) then
|
||||
begin
|
||||
FSpecView.SpectrumDirty := True;
|
||||
FSpecView.InvalidateOverlayCache;
|
||||
end;
|
||||
if Assigned(PbSpectrum) then PbSpectrum.Invalidate;
|
||||
end;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user