mirror of
https://github.com/AlexandreRouma/SDRPlusPlus.git
synced 2024-11-12 21:42:51 +01:00
Added option to show current list on FFT
This commit is contained in:
parent
5b9bd56cf2
commit
4dc0df74cf
@ -88,7 +88,7 @@ void MainWindow::init() {
|
|||||||
|
|
||||||
vfoCreatedHandler.handler = vfoAddedHandler;
|
vfoCreatedHandler.handler = vfoAddedHandler;
|
||||||
vfoCreatedHandler.ctx = this;
|
vfoCreatedHandler.ctx = this;
|
||||||
sigpath::vfoManager.vfoCreatedEvent.bindHandler(vfoCreatedHandler);
|
sigpath::vfoManager.vfoCreatedEvent.bindHandler(&vfoCreatedHandler);
|
||||||
|
|
||||||
spdlog::info("Loading modules");
|
spdlog::info("Loading modules");
|
||||||
|
|
||||||
|
@ -72,7 +72,7 @@ namespace vfo_color_menu {
|
|||||||
}
|
}
|
||||||
|
|
||||||
vfoAddHndl.handler = vfoAddHandler;
|
vfoAddHndl.handler = vfoAddHandler;
|
||||||
sigpath::vfoManager.vfoCreatedEvent.bindHandler(vfoAddHndl);
|
sigpath::vfoManager.vfoCreatedEvent.bindHandler(&vfoAddHndl);
|
||||||
core::configManager.release(modified);
|
core::configManager.release(modified);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -174,6 +174,16 @@ namespace ImGui {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
FFTRedrawArgs args;
|
||||||
|
args.min = ImVec2(widgetPos.x + 50, widgetPos.y + 9);
|
||||||
|
args.max = ImVec2(widgetPos.x + dataWidth + 50, widgetPos.y + fftHeight + 10);
|
||||||
|
args.lowFreq = lowerFreq;
|
||||||
|
args.highFreq = upperFreq;
|
||||||
|
args.freqToPixelRatio = horizScale;
|
||||||
|
args.pixelToFreqRatio = viewBandwidth / (double)dataWidth;
|
||||||
|
args.window = window;
|
||||||
|
onFFTRedraw.emit(args);
|
||||||
|
|
||||||
// X Axis
|
// X Axis
|
||||||
window->DrawList->AddLine(ImVec2(widgetPos.x + 50, widgetPos.y + fftHeight + 10),
|
window->DrawList->AddLine(ImVec2(widgetPos.x + 50, widgetPos.y + fftHeight + 10),
|
||||||
ImVec2(widgetPos.x + dataWidth + 50, widgetPos.y + fftHeight + 10),
|
ImVec2(widgetPos.x + dataWidth + 50, widgetPos.y + fftHeight + 10),
|
||||||
@ -182,8 +192,6 @@ namespace ImGui {
|
|||||||
window->DrawList->AddLine(ImVec2(widgetPos.x + 50, widgetPos.y + 9),
|
window->DrawList->AddLine(ImVec2(widgetPos.x + 50, widgetPos.y + 9),
|
||||||
ImVec2(widgetPos.x + 50, widgetPos.y + fftHeight + 9),
|
ImVec2(widgetPos.x + 50, widgetPos.y + fftHeight + 9),
|
||||||
text, 1.0);
|
text, 1.0);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void WaterFall::drawWaterfall() {
|
void WaterFall::drawWaterfall() {
|
||||||
|
@ -5,6 +5,7 @@
|
|||||||
#include <imgui/imgui.h>
|
#include <imgui/imgui.h>
|
||||||
#include <imgui/imgui_internal.h>
|
#include <imgui/imgui_internal.h>
|
||||||
#include <GL/glew.h>
|
#include <GL/glew.h>
|
||||||
|
#include <utils/event.h>
|
||||||
|
|
||||||
#define WATERFALL_RESOLUTION 1000000
|
#define WATERFALL_RESOLUTION 1000000
|
||||||
|
|
||||||
@ -141,6 +142,18 @@ namespace ImGui {
|
|||||||
std::string selectedVFO = "";
|
std::string selectedVFO = "";
|
||||||
bool selectedVFOChanged = false;
|
bool selectedVFOChanged = false;
|
||||||
|
|
||||||
|
struct FFTRedrawArgs {
|
||||||
|
ImVec2 min;
|
||||||
|
ImVec2 max;
|
||||||
|
double lowFreq;
|
||||||
|
double highFreq;
|
||||||
|
double freqToPixelRatio;
|
||||||
|
double pixelToFreqRatio;
|
||||||
|
ImGuiWindow* window;
|
||||||
|
};
|
||||||
|
|
||||||
|
Event<FFTRedrawArgs> onFFTRedraw;
|
||||||
|
|
||||||
enum {
|
enum {
|
||||||
REF_LOWER,
|
REF_LOWER,
|
||||||
REF_CENTER,
|
REF_CENTER,
|
||||||
|
@ -14,11 +14,11 @@ SinkManager::SinkManager() {
|
|||||||
registerSinkProvider("None", prov);
|
registerSinkProvider("None", prov);
|
||||||
}
|
}
|
||||||
|
|
||||||
SinkManager::Stream::Stream(dsp::stream<dsp::stereo_t>* in, const EventHandler<float>& srChangeHandler, float sampleRate) {
|
SinkManager::Stream::Stream(dsp::stream<dsp::stereo_t>* in, EventHandler<float>* srChangeHandler, float sampleRate) {
|
||||||
init(in, srChangeHandler, sampleRate);
|
init(in, srChangeHandler, sampleRate);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SinkManager::Stream::init(dsp::stream<dsp::stereo_t>* in, const EventHandler<float>& srChangeHandler, float sampleRate) {
|
void SinkManager::Stream::init(dsp::stream<dsp::stereo_t>* in, EventHandler<float>* srChangeHandler, float sampleRate) {
|
||||||
_in = in;
|
_in = in;
|
||||||
srChange.bindHandler(srChangeHandler);
|
srChange.bindHandler(srChangeHandler);
|
||||||
_sampleRate = sampleRate;
|
_sampleRate = sampleRate;
|
||||||
|
@ -25,9 +25,9 @@ public:
|
|||||||
class Stream {
|
class Stream {
|
||||||
public:
|
public:
|
||||||
Stream() {}
|
Stream() {}
|
||||||
Stream(dsp::stream<dsp::stereo_t>* in, const EventHandler<float>& srChangeHandler, float sampleRate);
|
Stream(dsp::stream<dsp::stereo_t>* in, EventHandler<float>* srChangeHandler, float sampleRate);
|
||||||
|
|
||||||
void init(dsp::stream<dsp::stereo_t>* in, const EventHandler<float>& srChangeHandler, float sampleRate);
|
void init(dsp::stream<dsp::stereo_t>* in, EventHandler<float>* srChangeHandler, float sampleRate);
|
||||||
|
|
||||||
void start();
|
void start();
|
||||||
void stop();
|
void stop();
|
||||||
|
@ -22,16 +22,16 @@ public:
|
|||||||
|
|
||||||
void emit(T value) {
|
void emit(T value) {
|
||||||
for (auto const& handler : handlers) {
|
for (auto const& handler : handlers) {
|
||||||
handler.handler(value, handler.ctx);
|
handler->handler(value, handler->ctx);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void bindHandler(const EventHandler<T>& handler) {
|
void bindHandler(EventHandler<T>* handler) {
|
||||||
handlers.push_back(handler);
|
handlers.push_back(handler);
|
||||||
}
|
}
|
||||||
|
|
||||||
void unbindHandler(const EventHandler<T>& handler) {
|
void unbindHandler(EventHandler<T>* handler) {
|
||||||
if (handlers.find(handler) == handlers.end()) {
|
if (std::find(handlers.begin(), handlers.end(), handler) == handlers.end()) {
|
||||||
spdlog::error("Tried to remove a non-existant event handler");
|
spdlog::error("Tried to remove a non-existant event handler");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -39,6 +39,6 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::vector<EventHandler<T>> handlers;
|
std::vector<EventHandler<T>*> handlers;
|
||||||
|
|
||||||
};
|
};
|
@ -55,11 +55,16 @@ public:
|
|||||||
refreshLists();
|
refreshLists();
|
||||||
loadByName(selList);
|
loadByName(selList);
|
||||||
|
|
||||||
|
fftRedrawHandler.ctx = this;
|
||||||
|
fftRedrawHandler.handler = fftRedraw;
|
||||||
|
|
||||||
gui::menu.registerEntry(name, menuHandler, this, NULL);
|
gui::menu.registerEntry(name, menuHandler, this, NULL);
|
||||||
|
gui::waterfall.onFFTRedraw.bindHandler(&fftRedrawHandler);
|
||||||
}
|
}
|
||||||
|
|
||||||
~FrequencyManagerModule() {
|
~FrequencyManagerModule() {
|
||||||
gui::menu.removeEntry(name);
|
gui::menu.removeEntry(name);
|
||||||
|
gui::waterfall.onFFTRedraw.unbindHandler(&fftRedrawHandler);
|
||||||
}
|
}
|
||||||
|
|
||||||
void enable() {
|
void enable() {
|
||||||
@ -461,6 +466,8 @@ private:
|
|||||||
if (selectedNames.size() == 0 && _this->selectedListName != "") { style::endDisabled(); }
|
if (selectedNames.size() == 0 && _this->selectedListName != "") { style::endDisabled(); }
|
||||||
ImGui::EndTable();
|
ImGui::EndTable();
|
||||||
|
|
||||||
|
ImGui::Checkbox("Show on FFT", &_this->showBookmarksOnFFT);
|
||||||
|
|
||||||
if (_this->selectedListName == "") { style::endDisabled(); }
|
if (_this->selectedListName == "") { style::endDisabled(); }
|
||||||
|
|
||||||
if (_this->createOpen) {
|
if (_this->createOpen) {
|
||||||
@ -498,6 +505,32 @@ private:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void fftRedraw(ImGui::WaterFall::FFTRedrawArgs args, void* ctx) {
|
||||||
|
FrequencyManagerModule* _this = (FrequencyManagerModule*)ctx;
|
||||||
|
if (!_this->showBookmarksOnFFT) { return; }
|
||||||
|
|
||||||
|
for (auto const [_name, bm] : _this->bookmarks) {
|
||||||
|
double centerXpos = args.min.x + std::round((bm.frequency - args.lowFreq) * args.freqToPixelRatio);
|
||||||
|
|
||||||
|
if (bm.frequency >= args.lowFreq && bm.frequency <= args.highFreq) {
|
||||||
|
args.window->DrawList->AddLine(ImVec2(centerXpos, args.min.y), ImVec2(centerXpos, args.max.y), IM_COL32(255, 255, 0, 255));
|
||||||
|
}
|
||||||
|
|
||||||
|
ImVec2 nameSize = ImGui::CalcTextSize(_name.c_str());
|
||||||
|
ImVec2 rectMin = ImVec2(centerXpos-(nameSize.x/2)-5, args.min.y);
|
||||||
|
ImVec2 rectMax = ImVec2(centerXpos+(nameSize.x/2)+5, args.min.y+nameSize.y);
|
||||||
|
ImVec2 clampedRectMin = ImVec2(std::clamp<double>(rectMin.x, args.min.x, args.max.x), rectMin.y);
|
||||||
|
ImVec2 clampedRectMax = ImVec2(std::clamp<double>(rectMax.x, args.min.x, args.max.x), rectMax.y);
|
||||||
|
|
||||||
|
if (clampedRectMax.x - clampedRectMin.x > 0) {
|
||||||
|
args.window->DrawList->AddRectFilled(clampedRectMin, clampedRectMax, IM_COL32(255, 255, 0, 255));
|
||||||
|
}
|
||||||
|
if (rectMin.x >= args.min.x && rectMax.x <= args.max.x) {
|
||||||
|
args.window->DrawList->AddText(ImVec2(centerXpos-(nameSize.x/2), args.min.y), IM_COL32(0, 0, 0, 255), _name.c_str());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
json exportedBookmarks;
|
json exportedBookmarks;
|
||||||
bool importOpen = false;
|
bool importOpen = false;
|
||||||
bool exportOpen = false;
|
bool exportOpen = false;
|
||||||
@ -550,6 +583,10 @@ private:
|
|||||||
bool newListOpen = false;
|
bool newListOpen = false;
|
||||||
bool renameListOpen = false;
|
bool renameListOpen = false;
|
||||||
|
|
||||||
|
bool showBookmarksOnFFT = false;
|
||||||
|
|
||||||
|
EventHandler<ImGui::WaterFall::FFTRedrawArgs> fftRedrawHandler;
|
||||||
|
|
||||||
std::map<std::string, FrequencyBookmark> bookmarks;
|
std::map<std::string, FrequencyBookmark> bookmarks;
|
||||||
|
|
||||||
std::string editedBookmarkName = "";
|
std::string editedBookmarkName = "";
|
||||||
|
@ -56,7 +56,7 @@ public:
|
|||||||
|
|
||||||
srChangeHandler.ctx = this;
|
srChangeHandler.ctx = this;
|
||||||
srChangeHandler.handler = sampleRateChangeHandler;
|
srChangeHandler.handler = sampleRateChangeHandler;
|
||||||
stream.init(wfmDemod.getOutput(), srChangeHandler, audioSampRate);
|
stream.init(wfmDemod.getOutput(), &srChangeHandler, audioSampRate);
|
||||||
sigpath::sinkManager.registerStream(name, &stream);
|
sigpath::sinkManager.registerStream(name, &stream);
|
||||||
|
|
||||||
selectDemodById(demodId);
|
selectDemodById(demodId);
|
||||||
|
Loading…
Reference in New Issue
Block a user