mirror of
https://github.com/AlexandreRouma/SDRPlusPlus.git
synced 2025-06-25 12:07:49 +02:00
Fixed VFO alignment
This commit is contained in:
@ -6,6 +6,7 @@
|
||||
|
||||
namespace sourecmenu {
|
||||
int sourceId = 0;
|
||||
double freqOffset = 0.0;
|
||||
|
||||
void init() {
|
||||
// Select default
|
||||
@ -13,6 +14,7 @@ namespace sourecmenu {
|
||||
if (sigpath::sourceManager.sourceNames.size() > 0) {
|
||||
sigpath::sourceManager.selectSource(sigpath::sourceManager.sourceNames[0]);
|
||||
}
|
||||
sigpath::sourceManager.setTuningOffset(0);
|
||||
}
|
||||
|
||||
void draw(void* ctx) {
|
||||
@ -29,5 +31,9 @@ namespace sourecmenu {
|
||||
}
|
||||
|
||||
sigpath::sourceManager.showSelectedMenu();
|
||||
ImGui::SetNextItemWidth(itemWidth - ImGui::CalcTextSize("Offset (Hz)").x - 10);
|
||||
if (ImGui::InputDouble("Offset (Hz)##freq_offset", &freqOffset, 1.0, 100.0)) {
|
||||
sigpath::sourceManager.setTuningOffset(freqOffset);
|
||||
}
|
||||
}
|
||||
}
|
@ -230,7 +230,9 @@ namespace ImGui {
|
||||
int refCenter = mousePos.x - (widgetPos.x + 50);
|
||||
if (refCenter >= 0 && refCenter < dataWidth && mousePos.y > widgetPos.y && mousePos.y < (widgetPos.y + widgetSize.y)) {
|
||||
double off = ((((double)refCenter / ((double)dataWidth / 2.0)) - 1.0) * (viewBandwidth / 2.0)) + viewOffset;
|
||||
vfo->setOffset(round(off / vfo->snapInterval) * vfo->snapInterval);
|
||||
off += centerFreq;
|
||||
off = (round(off / vfo->snapInterval) * vfo->snapInterval) - centerFreq;
|
||||
vfo->setOffset(off);
|
||||
}
|
||||
}
|
||||
|
||||
@ -239,7 +241,9 @@ namespace ImGui {
|
||||
int refCenter = mousePos.x - (widgetPos.x + 50);
|
||||
if (refCenter >= 0 && refCenter < dataWidth && mousePos.y > widgetPos.y && mousePos.y < (widgetPos.y + widgetSize.y)) {
|
||||
double off = ((((double)refCenter / ((double)dataWidth / 2.0)) - 1.0) * (viewBandwidth / 2.0)) + viewOffset;
|
||||
vfo->setOffset(round(off / vfo->snapInterval) * vfo->snapInterval);
|
||||
off += centerFreq;
|
||||
off = (round(off / vfo->snapInterval) * vfo->snapInterval) - centerFreq;
|
||||
vfo->setOffset(off);
|
||||
}
|
||||
}
|
||||
|
||||
@ -797,5 +801,9 @@ namespace ImGui {
|
||||
void WaterFall::hideBandplan() {
|
||||
bandplanVisible = false;
|
||||
}
|
||||
|
||||
void WaterfallVFO::setSnapInterval(double interval) {
|
||||
snapInterval = interval;
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -16,6 +16,7 @@ namespace ImGui {
|
||||
void setCenterOffset(double offset);
|
||||
void setBandwidth(double bw);
|
||||
void setReference(int ref);
|
||||
void setSnapInterval(double interval);
|
||||
void updateDrawingVars(double viewBandwidth, float dataWidth, double viewOffset, ImVec2 widgetPos, int fftHeight); // NOTE: Datawidth double???
|
||||
void draw(ImGuiWindow* window, bool selected);
|
||||
|
||||
|
@ -54,5 +54,11 @@ void SourceManager::tune(double freq) {
|
||||
if (selectedHandler == NULL) {
|
||||
return;
|
||||
}
|
||||
selectedHandler->tuneHandler(freq, selectedHandler->ctx);
|
||||
selectedHandler->tuneHandler(freq + tuneOffset, selectedHandler->ctx);
|
||||
currentFreq = freq;
|
||||
}
|
||||
|
||||
void SourceManager::setTuningOffset(double offset) {
|
||||
tuneOffset = offset;
|
||||
tune(currentFreq);
|
||||
}
|
@ -26,6 +26,7 @@ public:
|
||||
void start();
|
||||
void stop();
|
||||
void tune(double freq);
|
||||
void setTuningOffset(double offset);
|
||||
|
||||
std::vector<std::string> sourceNames;
|
||||
|
||||
@ -33,5 +34,7 @@ private:
|
||||
std::map<std::string, SourceHandler*> sources;
|
||||
std::string selectedName;
|
||||
SourceHandler* selectedHandler = NULL;
|
||||
double tuneOffset;
|
||||
double currentFreq;
|
||||
|
||||
};
|
Reference in New Issue
Block a user