mirror of
https://github.com/AlexandreRouma/SDRPlusPlus.git
synced 2025-02-02 21:04:45 +01:00
More work on MacOS and the scheduler
This commit is contained in:
parent
0ab4d16f9d
commit
40e2564ef9
@ -43,13 +43,17 @@ inline void doZoom(int offset, int width, int outWidth, float* data, float* out,
|
|||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
float sFactor = ceilf(factor);
|
float sFactor = ceilf(factor);
|
||||||
|
float uFactor;
|
||||||
float id = offset;
|
float id = offset;
|
||||||
float val, maxVal;
|
float val, maxVal;
|
||||||
|
int sId;
|
||||||
uint32_t maxId;
|
uint32_t maxId;
|
||||||
for (int i = 0; i < outWidth; i++) {
|
for (int i = 0; i < outWidth; i++) {
|
||||||
maxVal = -INFINITY;
|
maxVal = -INFINITY;
|
||||||
for (int j = 0; j < sFactor; j++) {
|
sId = (int)id;
|
||||||
if (data[(int)id + j] > maxVal) { maxVal = data[(int)id + j]; }
|
uFactor = (sId + sFactor > width) ? sFactor - ((sId + sFactor) - width) : sFactor;
|
||||||
|
for (int j = 0; j < uFactor; j++) {
|
||||||
|
if (data[sId + j] > maxVal) { maxVal = data[sId + j]; }
|
||||||
}
|
}
|
||||||
out[i] = maxVal;
|
out[i] = maxVal;
|
||||||
id += factor;
|
id += factor;
|
||||||
|
14
macos/set_library_path.sh
Normal file
14
macos/set_library_path.sh
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
set -e
|
||||||
|
|
||||||
|
WANTED_LIB=$1
|
||||||
|
NEW_PATH=$2
|
||||||
|
EXEC=$3
|
||||||
|
|
||||||
|
get_first_arg() {
|
||||||
|
echo $1
|
||||||
|
}
|
||||||
|
|
||||||
|
CURRENT_RPATH=$(get_first_arg $(otool -L $EXEC | grep $WANTED_LIB))
|
||||||
|
|
||||||
|
echo $CURRENT_RPATH
|
@ -11,12 +11,18 @@ namespace sched_action {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void showEditMenu() {
|
void prepareEditMenu() {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool showEditMenu(bool& valid) {
|
||||||
|
valid = false;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
void loadFromConfig(json config) {
|
void loadFromConfig(json config) {
|
||||||
if (config.contains("recorder")) { recorderName = config["recorder"]; }
|
if (config.contains("recorder")) { recorderName = config["recorder"]; }
|
||||||
|
name = "Start \"" + recorderName + "\"";
|
||||||
}
|
}
|
||||||
|
|
||||||
json saveToConfig() {
|
json saveToConfig() {
|
||||||
@ -27,16 +33,13 @@ namespace sched_action {
|
|||||||
|
|
||||||
|
|
||||||
std::string getName() {
|
std::string getName() {
|
||||||
return "Start \"" + recorderName + "\"";
|
return name;
|
||||||
}
|
|
||||||
|
|
||||||
bool isValid() {
|
|
||||||
return valid;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::string recorderName;
|
std::string recorderName;
|
||||||
bool valid = false;
|
|
||||||
|
std::string name = "Start \"\"";
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -1,49 +1,143 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
#include <sched_action.h>
|
#include <sched_action.h>
|
||||||
#include <utils/freq_formatting.h>
|
#include <utils/freq_formatting.h>
|
||||||
|
#include <gui/tuner.h>
|
||||||
|
#include <signal_path/signal_path.h>
|
||||||
|
|
||||||
namespace sched_action {
|
namespace sched_action {
|
||||||
|
|
||||||
|
const int tuningModes[] = {
|
||||||
|
tuner::TUNER_MODE_NORMAL,
|
||||||
|
tuner::TUNER_MODE_CENTER
|
||||||
|
};
|
||||||
|
|
||||||
|
const int tuningModeCount = sizeof(tuningModes) / sizeof(int);
|
||||||
|
|
||||||
|
const char* tuningModesStr[] = {
|
||||||
|
"Normal",
|
||||||
|
"Center"
|
||||||
|
};
|
||||||
|
|
||||||
class TuneVFOClass : public ActionClass {
|
class TuneVFOClass : public ActionClass {
|
||||||
public:
|
public:
|
||||||
TuneVFOClass() {}
|
TuneVFOClass() {
|
||||||
|
for (auto& mode : tuningModesStr) {
|
||||||
|
tuningModesTxt += mode;
|
||||||
|
tuningModesTxt += '\0';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
~TuneVFOClass() {}
|
~TuneVFOClass() {}
|
||||||
|
|
||||||
void trigger() {
|
void trigger() {
|
||||||
|
if (vfoName.empty()) { return; }
|
||||||
|
tuner::tune(tuningMode, vfoName, frequency);
|
||||||
}
|
}
|
||||||
|
|
||||||
void prepareEditMenu() {}
|
void prepareEditMenu() {
|
||||||
|
tmpFrequency = frequency;
|
||||||
|
|
||||||
void validateEditMenu() {}
|
// TODO: Find tuning mode
|
||||||
|
tuningModeId = 0;
|
||||||
|
|
||||||
void showEditMenu() {
|
// Generate text list
|
||||||
|
vfoNameId = -1;
|
||||||
|
vfoNames.clear();
|
||||||
|
vfoNamesTxt.clear();
|
||||||
|
int id = 0;
|
||||||
|
for (auto& [name, vfo] : gui::waterfall.vfos) {
|
||||||
|
vfoNames.push_back(name);
|
||||||
|
vfoNamesTxt += name;
|
||||||
|
vfoNamesTxt += '\0';
|
||||||
|
if (name == vfoName) {
|
||||||
|
vfoNameId = id;
|
||||||
|
}
|
||||||
|
id++;
|
||||||
|
}
|
||||||
|
|
||||||
|
// If VFO not found, reset the name
|
||||||
|
if (id < 0 && !vfoNames.empty()) {
|
||||||
|
vfoNameId = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Search ID of the tuning mode
|
||||||
|
tuningModeId = -1;
|
||||||
|
for (int i = 0; i < tuningModeCount; i++) {
|
||||||
|
if (tuningModes[i] == tuningMode) {
|
||||||
|
tuningModeId = i;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (tuningModeId < 0) {
|
||||||
|
tuningModeId = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
bool showEditMenu(bool& valid) {
|
||||||
|
ImGui::LeftLabel("VFO");
|
||||||
|
ImGui::SetNextItemWidth(250 - ImGui::GetCursorPosX());
|
||||||
|
ImGui::Combo("##scheduler_action_tunevfo_edit_vfo", &vfoNameId, vfoNamesTxt.c_str());
|
||||||
|
|
||||||
|
ImGui::LeftLabel("Frequency");
|
||||||
|
ImGui::SetNextItemWidth(250 - ImGui::GetCursorPosX());
|
||||||
|
ImGui::InputDouble("Hz##scheduler_action_tunevfo_edit_freq", &tmpFrequency);
|
||||||
|
|
||||||
|
ImGui::LeftLabel("Tuning Mode");
|
||||||
|
ImGui::SetNextItemWidth(250 - ImGui::GetCursorPosX());
|
||||||
|
ImGui::Combo("##scheduler_action_tunevfo_edit_tmode", &tuningModeId, tuningModesTxt.c_str());
|
||||||
|
|
||||||
|
if (ImGui::Button("Apply")) {
|
||||||
|
vfoName = vfoNames[vfoNameId];
|
||||||
|
frequency = tmpFrequency;
|
||||||
|
tuningMode = tuningModes[tuningModeId];
|
||||||
|
valid = true;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
ImGui::SameLine();
|
||||||
|
if (ImGui::Button("Cancel")) {
|
||||||
|
valid = false;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void loadFromConfig(json config) {
|
void loadFromConfig(json config) {
|
||||||
if (config.contains("vfo")) { vfoName = config["vfo"]; }
|
if (config.contains("vfo")) { vfoName = config["vfo"]; }
|
||||||
if (config.contains("frequency")) { frequency = config["frequency"]; }
|
if (config.contains("frequency")) { frequency = config["frequency"]; }
|
||||||
|
if (config.contains("tuningMode")) { tuningMode = config["tuningMode"]; }
|
||||||
|
|
||||||
|
name = "Tune \"" + vfoName + "\" to " + utils::formatFreq(frequency);
|
||||||
}
|
}
|
||||||
|
|
||||||
json saveToConfig() {
|
json saveToConfig() {
|
||||||
json config;
|
json config;
|
||||||
config["vfo"] = vfoName;
|
config["vfo"] = vfoName;
|
||||||
config["frequency"] = frequency;
|
config["frequency"] = frequency;
|
||||||
|
config["tuningMode"] = tuningMode;
|
||||||
return config;
|
return config;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string getName() {
|
std::string getName() {
|
||||||
return "Tune \"" + vfoName + "\" to " + utils::formatFreq(frequency);
|
return name;
|
||||||
}
|
|
||||||
|
|
||||||
bool isValid() {
|
|
||||||
return valid;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::string vfoName;
|
std::string tuningModesTxt;
|
||||||
double frequency;
|
std::vector<std::string> vfoNames;
|
||||||
bool valid = false;
|
std::string vfoNamesTxt;
|
||||||
|
|
||||||
|
std::string vfoName = "";
|
||||||
|
double frequency = 0;
|
||||||
|
int tuningMode = 0;
|
||||||
|
|
||||||
|
double tmpFrequency;
|
||||||
|
int tuningModeId;
|
||||||
|
|
||||||
|
int vfoNameId = -1;
|
||||||
|
|
||||||
|
std::string name;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -66,7 +66,7 @@ private:
|
|||||||
// If editing, show menu
|
// If editing, show menu
|
||||||
if (!_this->editedTask.empty()) {
|
if (!_this->editedTask.empty()) {
|
||||||
gui::mainWindow.lockWaterfallControls = true;
|
gui::mainWindow.lockWaterfallControls = true;
|
||||||
std::string id = "Edit##scheduler_edit_task_" + _this->name;
|
std::string id = "Edit Task##scheduler_edit_task_" + _this->name;
|
||||||
ImGui::OpenPopup(id.c_str());
|
ImGui::OpenPopup(id.c_str());
|
||||||
if (ImGui::BeginPopup(id.c_str(), ImGuiWindowFlags_NoResize)) {
|
if (ImGui::BeginPopup(id.c_str(), ImGuiWindowFlags_NoResize)) {
|
||||||
bool valid = false;
|
bool valid = false;
|
||||||
@ -97,7 +97,6 @@ private:
|
|||||||
for (auto& [name, bm] : _this->tasks) {
|
for (auto& [name, bm] : _this->tasks) {
|
||||||
ImGui::TableNextRow();
|
ImGui::TableNextRow();
|
||||||
ImGui::TableSetColumnIndex(0);
|
ImGui::TableSetColumnIndex(0);
|
||||||
ImVec2 min = ImGui::GetCursorPos();
|
|
||||||
|
|
||||||
if (ImGui::Selectable((name + "##_freq_mgr_bkm_name_" + _this->name).c_str(), &bm.selected, ImGuiSelectableFlags_SpanAllColumns | ImGuiSelectableFlags_SelectOnClick)) {
|
if (ImGui::Selectable((name + "##_freq_mgr_bkm_name_" + _this->name).c_str(), &bm.selected, ImGuiSelectableFlags_SpanAllColumns | ImGuiSelectableFlags_SelectOnClick)) {
|
||||||
// if shift or control isn't pressed, deselect all others
|
// if shift or control isn't pressed, deselect all others
|
||||||
|
@ -8,17 +8,22 @@ using namespace nlohmann;
|
|||||||
namespace sched_action {
|
namespace sched_action {
|
||||||
class ActionClass {
|
class ActionClass {
|
||||||
public:
|
public:
|
||||||
virtual ~ActionClass() {
|
virtual ~ActionClass() {};
|
||||||
spdlog::warn("Base destructor");
|
|
||||||
};
|
|
||||||
virtual void trigger() = 0;
|
virtual void trigger() = 0;
|
||||||
virtual void prepareEditMenu() = 0;
|
virtual void prepareEditMenu() = 0;
|
||||||
virtual void validateEditMenu() = 0;
|
virtual bool showEditMenu(bool& valid) = 0;
|
||||||
virtual void showEditMenu() = 0;
|
|
||||||
virtual void loadFromConfig(json config) = 0;
|
virtual void loadFromConfig(json config) = 0;
|
||||||
virtual json saveToConfig() = 0;
|
virtual json saveToConfig() = 0;
|
||||||
virtual std::string getName() = 0;
|
virtual std::string getName() = 0;
|
||||||
virtual bool isValid() = 0;
|
|
||||||
|
virtual bool isValid() {
|
||||||
|
return valid;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool selected = false;
|
||||||
|
|
||||||
|
private:
|
||||||
|
bool valid = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef std::shared_ptr<ActionClass> Action;
|
typedef std::shared_ptr<ActionClass> Action;
|
||||||
|
@ -23,10 +23,35 @@ public:
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void prepareEditMenu() {
|
||||||
|
for (auto& act : actions) {
|
||||||
|
act->selected = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
bool showEditMenu(char* name, bool& valid) {
|
bool showEditMenu(char* name, bool& valid) {
|
||||||
ImGui::LeftLabel("Name");
|
ImGui::LeftLabel("Name");
|
||||||
ImGui::InputText("##scheduler_task_edit_name", name, 1023);
|
ImGui::InputText("##scheduler_task_edit_name", name, 1023);
|
||||||
|
|
||||||
|
if (editedAction >= 0) {
|
||||||
|
bool valid = false;
|
||||||
|
|
||||||
|
std::string id = "Edit Action##scheduler_edit_action";
|
||||||
|
ImGui::OpenPopup(id.c_str());
|
||||||
|
if (ImGui::BeginPopup(id.c_str(), ImGuiWindowFlags_NoResize)) {
|
||||||
|
bool valid = false;
|
||||||
|
bool open = actions[editedAction]->showEditMenu(valid);
|
||||||
|
|
||||||
|
// Stop editing of closed
|
||||||
|
if (!open) {
|
||||||
|
// TODO: Do something if valid I think
|
||||||
|
editedAction = -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
ImGui::EndPopup();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (ImGui::BeginTable("scheduler_task_triggers", 1, ImGuiTableFlags_Borders | ImGuiTableFlags_RowBg | ImGuiTableFlags_ScrollY, ImVec2(0, 100))) {
|
if (ImGui::BeginTable("scheduler_task_triggers", 1, ImGuiTableFlags_Borders | ImGuiTableFlags_RowBg | ImGuiTableFlags_ScrollY, ImVec2(0, 100))) {
|
||||||
ImGui::TableSetupColumn("Triggers");
|
ImGui::TableSetupColumn("Triggers");
|
||||||
ImGui::TableSetupScrollFreeze(1, 1);
|
ImGui::TableSetupScrollFreeze(1, 1);
|
||||||
@ -45,10 +70,31 @@ public:
|
|||||||
ImGui::TableSetupScrollFreeze(1, 1);
|
ImGui::TableSetupScrollFreeze(1, 1);
|
||||||
ImGui::TableHeadersRow();
|
ImGui::TableHeadersRow();
|
||||||
|
|
||||||
|
int id = 0;
|
||||||
for (auto& act : actions) {
|
for (auto& act : actions) {
|
||||||
ImGui::TableNextRow();
|
ImGui::TableNextRow();
|
||||||
ImGui::TableSetColumnIndex(0);
|
ImGui::TableSetColumnIndex(0);
|
||||||
ImGui::Text(act->getName().c_str());
|
|
||||||
|
if (ImGui::Selectable((act->getName() + "##scheduler_task_actions_entry").c_str(), &act->selected, ImGuiSelectableFlags_SpanAllColumns | ImGuiSelectableFlags_SelectOnClick)) {
|
||||||
|
// if shift or control isn't pressed, deselect all others
|
||||||
|
if (!ImGui::IsKeyDown(GLFW_KEY_LEFT_SHIFT) && !ImGui::IsKeyDown(GLFW_KEY_RIGHT_SHIFT) &&
|
||||||
|
!ImGui::IsKeyDown(GLFW_KEY_LEFT_CONTROL) && !ImGui::IsKeyDown(GLFW_KEY_RIGHT_CONTROL)) {
|
||||||
|
int _id = 0;
|
||||||
|
for (auto& _act : actions) {
|
||||||
|
if (_id == id) { continue; }
|
||||||
|
_act->selected = false;
|
||||||
|
_id++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Open edit menu on double click
|
||||||
|
if (ImGui::TableGetHoveredColumn() >= 0 && ImGui::IsItemHovered() && ImGui::IsMouseDoubleClicked(ImGuiMouseButton_Left) && editedAction < 0) {
|
||||||
|
editedAction = id;
|
||||||
|
act->prepareEditMenu();
|
||||||
|
}
|
||||||
|
|
||||||
|
id++;
|
||||||
}
|
}
|
||||||
|
|
||||||
ImGui::EndTable();
|
ImGui::EndTable();
|
||||||
@ -72,4 +118,6 @@ public:
|
|||||||
private:
|
private:
|
||||||
std::vector<sched_action::Action> actions;
|
std::vector<sched_action::Action> actions;
|
||||||
|
|
||||||
|
int editedAction = -1;
|
||||||
|
|
||||||
};
|
};
|
Loading…
x
Reference in New Issue
Block a user