mirror of
https://github.com/AlexandreRouma/SDRPlusPlus.git
synced 2024-11-10 12:47:40 +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.ctx = this;
|
||||
sigpath::vfoManager.vfoCreatedEvent.bindHandler(vfoCreatedHandler);
|
||||
sigpath::vfoManager.vfoCreatedEvent.bindHandler(&vfoCreatedHandler);
|
||||
|
||||
spdlog::info("Loading modules");
|
||||
|
||||
|
@ -72,7 +72,7 @@ namespace vfo_color_menu {
|
||||
}
|
||||
|
||||
vfoAddHndl.handler = vfoAddHandler;
|
||||
sigpath::vfoManager.vfoCreatedEvent.bindHandler(vfoAddHndl);
|
||||
sigpath::vfoManager.vfoCreatedEvent.bindHandler(&vfoAddHndl);
|
||||
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
|
||||
window->DrawList->AddLine(ImVec2(widgetPos.x + 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),
|
||||
ImVec2(widgetPos.x + 50, widgetPos.y + fftHeight + 9),
|
||||
text, 1.0);
|
||||
|
||||
|
||||
}
|
||||
|
||||
void WaterFall::drawWaterfall() {
|
||||
|
@ -5,6 +5,7 @@
|
||||
#include <imgui/imgui.h>
|
||||
#include <imgui/imgui_internal.h>
|
||||
#include <GL/glew.h>
|
||||
#include <utils/event.h>
|
||||
|
||||
#define WATERFALL_RESOLUTION 1000000
|
||||
|
||||
@ -141,6 +142,18 @@ namespace ImGui {
|
||||
std::string selectedVFO = "";
|
||||
bool selectedVFOChanged = false;
|
||||
|
||||
struct FFTRedrawArgs {
|
||||
ImVec2 min;
|
||||
ImVec2 max;
|
||||
double lowFreq;
|
||||
double highFreq;
|
||||
double freqToPixelRatio;
|
||||
double pixelToFreqRatio;
|
||||
ImGuiWindow* window;
|
||||
};
|
||||
|
||||
Event<FFTRedrawArgs> onFFTRedraw;
|
||||
|
||||
enum {
|
||||
REF_LOWER,
|
||||
REF_CENTER,
|
||||
|
@ -14,11 +14,11 @@ SinkManager::SinkManager() {
|
||||
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);
|
||||
}
|
||||
|
||||
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;
|
||||
srChange.bindHandler(srChangeHandler);
|
||||
_sampleRate = sampleRate;
|
||||
|
@ -25,9 +25,9 @@ public:
|
||||
class Stream {
|
||||
public:
|
||||
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 stop();
|
||||
|
@ -22,16 +22,16 @@ public:
|
||||
|
||||
void emit(T value) {
|
||||
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);
|
||||
}
|
||||
|
||||
void unbindHandler(const EventHandler<T>& handler) {
|
||||
if (handlers.find(handler) == handlers.end()) {
|
||||
void unbindHandler(EventHandler<T>* handler) {
|
||||
if (std::find(handlers.begin(), handlers.end(), handler) == handlers.end()) {
|
||||
spdlog::error("Tried to remove a non-existant event handler");
|
||||
return;
|
||||
}
|
||||
@ -39,6 +39,6 @@ public:
|
||||
}
|
||||
|
||||
private:
|
||||
std::vector<EventHandler<T>> handlers;
|
||||
std::vector<EventHandler<T>*> handlers;
|
||||
|
||||
};
|
@ -55,11 +55,16 @@ public:
|
||||
refreshLists();
|
||||
loadByName(selList);
|
||||
|
||||
fftRedrawHandler.ctx = this;
|
||||
fftRedrawHandler.handler = fftRedraw;
|
||||
|
||||
gui::menu.registerEntry(name, menuHandler, this, NULL);
|
||||
gui::waterfall.onFFTRedraw.bindHandler(&fftRedrawHandler);
|
||||
}
|
||||
|
||||
~FrequencyManagerModule() {
|
||||
gui::menu.removeEntry(name);
|
||||
gui::waterfall.onFFTRedraw.unbindHandler(&fftRedrawHandler);
|
||||
}
|
||||
|
||||
void enable() {
|
||||
@ -461,6 +466,8 @@ private:
|
||||
if (selectedNames.size() == 0 && _this->selectedListName != "") { style::endDisabled(); }
|
||||
ImGui::EndTable();
|
||||
|
||||
ImGui::Checkbox("Show on FFT", &_this->showBookmarksOnFFT);
|
||||
|
||||
if (_this->selectedListName == "") { style::endDisabled(); }
|
||||
|
||||
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;
|
||||
bool importOpen = false;
|
||||
bool exportOpen = false;
|
||||
@ -550,6 +583,10 @@ private:
|
||||
bool newListOpen = false;
|
||||
bool renameListOpen = false;
|
||||
|
||||
bool showBookmarksOnFFT = false;
|
||||
|
||||
EventHandler<ImGui::WaterFall::FFTRedrawArgs> fftRedrawHandler;
|
||||
|
||||
std::map<std::string, FrequencyBookmark> bookmarks;
|
||||
|
||||
std::string editedBookmarkName = "";
|
||||
|
@ -56,7 +56,7 @@ public:
|
||||
|
||||
srChangeHandler.ctx = this;
|
||||
srChangeHandler.handler = sampleRateChangeHandler;
|
||||
stream.init(wfmDemod.getOutput(), srChangeHandler, audioSampRate);
|
||||
stream.init(wfmDemod.getOutput(), &srChangeHandler, audioSampRate);
|
||||
sigpath::sinkManager.registerStream(name, &stream);
|
||||
|
||||
selectDemodById(demodId);
|
||||
|
Loading…
Reference in New Issue
Block a user