Fixed VFO alignment

This commit is contained in:
AlexandreRouma 2020-10-20 14:59:42 +02:00
parent 6e5450ed24
commit 71f6be8d08
8 changed files with 78 additions and 50 deletions

View File

@ -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);
}
}
}

View File

@ -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;
}
};

View File

@ -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);

View File

@ -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);
}

View File

@ -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;
};

View File

@ -124,6 +124,10 @@ private:
ImGui::SliderFloat(CONCAT("##_squelch_select_", _this->name), &_this->sigPath.squelch.level, -100, 0);
ImGui::PopItemWidth();
ImGui::Text("Snap Interval");
ImGui::SetNextItemWidth(menuColumnWidth - ImGui::GetCursorPosX());
if (ImGui:)
}
static void scriptCreateHandler(void* ctx, duk_context* dukCtx, duk_idx_t objId) {
@ -315,6 +319,7 @@ private:
int bandWidth;
int bandWidthMin;
int bandWidthMax;
double snapInterval = 100000.0;
SigPath sigPath;
};

View File

@ -1,43 +1,43 @@
{
"audio": {
"Radio": {
"device": "Speakers (Realtek High Definiti",
"sampleRate": 48000.0,
"volume": 0.60546875
},
"Radio 1": {
"device": "CABLE-A Input (VB-Audio Cable A)",
"sampleRate": 48000.0,
"volume": 1.0
},
"Radio 2": {
"device": "CABLE Input (VB-Audio Virtual Cable)",
"sampleRate": 48000.0,
"volume": 1.0
}
},
"bandPlan": "General",
"bandPlanEnabled": true,
"fftHeight": 300,
"frequency": 98983691,
"max": 0.0,
"maximized": false,
"menuOrder": [
"Source",
"Radio",
"Recorder",
"Audio",
"Scripting",
"Band Plan",
"Display"
],
"menuWidth": 300,
"min": -72.05882263183594,
"showWaterfall": true,
"source": "",
"sourceSettings": {},
"windowSize": {
"h": 720,
"w": 1280
}
{
"audio": {
"Radio": {
"device": "Speakers (Realtek High Definiti",
"sampleRate": 48000.0,
"volume": 0.60546875
},
"Radio 1": {
"device": "CABLE-A Input (VB-Audio Cable A)",
"sampleRate": 48000.0,
"volume": 1.0
},
"Radio 2": {
"device": "CABLE Input (VB-Audio Virtual Cable)",
"sampleRate": 48000.0,
"volume": 1.0
}
},
"bandPlan": "General",
"bandPlanEnabled": true,
"fftHeight": 300,
"frequency": 99015000,
"max": 0.0,
"maximized": false,
"menuOrder": [
"Source",
"Radio",
"Recorder",
"Audio",
"Scripting",
"Band Plan",
"Display"
],
"menuWidth": 300,
"min": -72.05882263183594,
"showWaterfall": true,
"source": "",
"sourceSettings": {},
"windowSize": {
"h": 1053,
"w": 959
}
}

View File

@ -1,7 +1,6 @@
{
"Radio": "./radio/Release/radio.dll",
"Recorder": "./recorder/Release/recorder.dll",
"Soapy": "./soapy/Release/soapy.dll",
"RTLTCPSource": "./rtl_tcp_source/Release/rtl_tcp_source.dll",
"FileSource": "./file_source/Release/file_source.dll"
"Radio": "./radio/radio.so",
"Recorder": "./recorder/recorder.so",
"Soapy": "./soapy/soapy.so",
"RTLTCPSource": "./rtl_tcp_source/rtl_tcp_source.so"
}