mirror of
https://github.com/AlexandreRouma/SDRPlusPlus.git
synced 2025-02-02 12:54:44 +01:00
Added position option for the bandplan
This commit is contained in:
parent
11766a2c41
commit
2c334c08ac
@ -104,6 +104,7 @@ int sdrpp_main(int argc, char *argv[]) {
|
||||
defConfig["bandColors"]["military"] = "#FFFF00FF";
|
||||
defConfig["bandPlan"] = "General";
|
||||
defConfig["bandPlanEnabled"] = true;
|
||||
defConfig["bandPlanPos"] = 0;
|
||||
defConfig["centerTuning"] = false;
|
||||
defConfig["colorMap"] = "Classic";
|
||||
defConfig["fastFFT"] = false;
|
||||
|
@ -6,6 +6,9 @@
|
||||
namespace bandplanmenu {
|
||||
int bandplanId;
|
||||
bool bandPlanEnabled;
|
||||
int bandPlanPos = 0;
|
||||
|
||||
const char* bandPlanPosTxt = "Bottom\0Top\0";
|
||||
|
||||
void init() {
|
||||
// todo: check if the bandplan wasn't removed
|
||||
@ -26,18 +29,31 @@ namespace bandplanmenu {
|
||||
|
||||
bandPlanEnabled = core::configManager.conf["bandPlanEnabled"];
|
||||
bandPlanEnabled ? gui::waterfall.showBandplan() : gui::waterfall.hideBandplan();
|
||||
bandPlanPos = core::configManager.conf["bandPlanPos"];
|
||||
gui::waterfall.setBandPlanPos(bandPlanPos);
|
||||
}
|
||||
|
||||
void draw(void* ctx) {
|
||||
float menuColumnWidth = ImGui::GetContentRegionAvailWidth();
|
||||
ImGui::PushItemWidth(menuColumnWidth);
|
||||
if (ImGui::Combo("##_4_", &bandplanId, bandplan::bandplanNameTxt.c_str())) {
|
||||
if (ImGui::Combo("##_bandplan_name_", &bandplanId, bandplan::bandplanNameTxt.c_str())) {
|
||||
gui::waterfall.bandplan = &bandplan::bandplans[bandplan::bandplanNames[bandplanId]];
|
||||
core::configManager.aquire();
|
||||
core::configManager.conf["bandPlan"] = bandplan::bandplanNames[bandplanId];
|
||||
core::configManager.release(true);
|
||||
}
|
||||
ImGui::PopItemWidth();
|
||||
|
||||
ImGui::Text("Position");
|
||||
ImGui::SameLine();
|
||||
ImGui::SetNextItemWidth(menuColumnWidth - ImGui::GetCursorPosX());
|
||||
if (ImGui::Combo("##_bandplan_pos_", &bandPlanPos, bandPlanPosTxt)) {
|
||||
gui::waterfall.setBandPlanPos(bandPlanPos);
|
||||
core::configManager.aquire();
|
||||
core::configManager.conf["bandPlanPos"] = bandPlanPos;
|
||||
core::configManager.release(true);
|
||||
}
|
||||
|
||||
if (ImGui::Checkbox("Enabled", &bandPlanEnabled)) {
|
||||
bandPlanEnabled ? gui::waterfall.showBandplan() : gui::waterfall.hideBandplan();
|
||||
core::configManager.aquire();
|
||||
|
@ -367,6 +367,18 @@ namespace ImGui {
|
||||
ImVec2 txtSz;
|
||||
bool startVis, endVis;
|
||||
uint32_t color, colorTrans;
|
||||
|
||||
float height = ImGui::CalcTextSize("0").y * 2.5f;
|
||||
float bpBottom;
|
||||
|
||||
if (bandPlanPos == BANDPLAN_POS_BOTTOM) {
|
||||
bpBottom = widgetPos.y + fftHeight + 10;
|
||||
}
|
||||
else {
|
||||
bpBottom = widgetPos.y + height + 10;
|
||||
}
|
||||
|
||||
|
||||
for (int i = 0; i < count; i++) {
|
||||
start = bandplan->bands[i].start;
|
||||
end = bandplan->bands[i].end;
|
||||
@ -386,7 +398,6 @@ namespace ImGui {
|
||||
cPos = widgetPos.x + 50 + ((center - lowerFreq) * horizScale);
|
||||
width = bPos - aPos;
|
||||
txtSz = ImGui::CalcTextSize(bandplan->bands[i].name.c_str());
|
||||
float height = txtSz.y * 2.5f;
|
||||
if (bandplan::colorTable.find(bandplan->bands[i].type.c_str()) != bandplan::colorTable.end()) {
|
||||
color = bandplan::colorTable[bandplan->bands[i].type].colorValue;
|
||||
colorTrans = bandplan::colorTable[bandplan->bands[i].type].transColorValue;
|
||||
@ -402,19 +413,19 @@ namespace ImGui {
|
||||
bPos = widgetPos.x + 51;
|
||||
}
|
||||
if (width >= 1.0) {
|
||||
window->DrawList->AddRectFilled(ImVec2(roundf(aPos), widgetPos.y + fftHeight + 10 - height),
|
||||
ImVec2(roundf(bPos), widgetPos.y + fftHeight + 10), colorTrans);
|
||||
window->DrawList->AddRectFilled(ImVec2(roundf(aPos), bpBottom - height),
|
||||
ImVec2(roundf(bPos), bpBottom), colorTrans);
|
||||
if (startVis) {
|
||||
window->DrawList->AddLine(ImVec2(roundf(aPos), widgetPos.y + fftHeight + 10 - height - 1),
|
||||
ImVec2(roundf(aPos), widgetPos.y + fftHeight + 9), color);
|
||||
window->DrawList->AddLine(ImVec2(roundf(aPos), bpBottom - height - 1),
|
||||
ImVec2(roundf(aPos), bpBottom - 1), color);
|
||||
}
|
||||
if (endVis) {
|
||||
window->DrawList->AddLine(ImVec2(roundf(bPos), widgetPos.y + fftHeight + 10 - height - 1),
|
||||
ImVec2(roundf(bPos), widgetPos.y + fftHeight + 9), color);
|
||||
window->DrawList->AddLine(ImVec2(roundf(bPos), bpBottom - height - 1),
|
||||
ImVec2(roundf(bPos), bpBottom - 1), color);
|
||||
}
|
||||
}
|
||||
if (txtSz.x <= width) {
|
||||
window->DrawList->AddText(ImVec2(cPos - (txtSz.x / 2.0), widgetPos.y + fftHeight + 10 - (height / 2.0f) - (txtSz.y / 2.0f)),
|
||||
window->DrawList->AddText(ImVec2(cPos - (txtSz.x / 2.0), bpBottom - (height / 2.0f) - (txtSz.y / 2.0f)),
|
||||
IM_COL32(255, 255, 255, 255), bandplan->bands[i].name.c_str());
|
||||
}
|
||||
}
|
||||
@ -821,6 +832,10 @@ namespace ImGui {
|
||||
memset(rawFFTs, 0, rawFFTSize * waterfallHeight * sizeof(float));
|
||||
}
|
||||
|
||||
void WaterFall::setBandPlanPos(int pos) {
|
||||
bandPlanPos = pos;
|
||||
}
|
||||
|
||||
void WaterfallVFO::setOffset(double offset) {
|
||||
generalOffset = offset;
|
||||
if (reference == REF_CENTER) {
|
||||
|
@ -109,6 +109,8 @@ namespace ImGui {
|
||||
|
||||
void setFullWaterfallUpdate(bool fullUpdate);
|
||||
|
||||
void setBandPlanPos(int pos);
|
||||
|
||||
bool centerFreqMoved = false;
|
||||
bool vfoFreqChanged = false;
|
||||
bool bandplanEnabled = false;
|
||||
@ -125,6 +127,12 @@ namespace ImGui {
|
||||
_REF_COUNT
|
||||
};
|
||||
|
||||
enum {
|
||||
BANDPLAN_POS_BOTTOM,
|
||||
BANDPLAN_POS_TOP,
|
||||
_BANDPLAN_POS_COUNT
|
||||
};
|
||||
|
||||
|
||||
private:
|
||||
void drawWaterfall();
|
||||
@ -210,5 +218,7 @@ namespace ImGui {
|
||||
|
||||
bool _fastFFT = true;
|
||||
bool _fullUpdate = true;
|
||||
|
||||
int bandPlanPos = BANDPLAN_POS_BOTTOM;
|
||||
};
|
||||
};
|
Loading…
x
Reference in New Issue
Block a user