Waterfall hover-state/interactivity improvements

This commit is contained in:
Charles J. Cliffe
2014-12-10 00:34:27 -05:00
parent 34a6d3f5e0
commit 380145fdaa
7 changed files with 211 additions and 68 deletions
+48 -8
View File
@@ -1,4 +1,6 @@
#include <DemodulatorMgr.h>
#include <sstream>
#include <algorithm>
DemodulatorInstance::DemodulatorInstance() :
t_Demod(NULL), t_Audio(NULL), threadQueueDemod(NULL), demodulatorThread(NULL) {
@@ -54,16 +56,16 @@ void DemodulatorInstance::run() {
t_Audio = new std::thread(&AudioThread::threadMain, audioThread);
#ifdef __APPLE__ // Already using pthreads, might as well do some custom init..
pthread_attr_t attr;
size_t size;
pthread_attr_t attr;
size_t size;
pthread_attr_init(&attr);
pthread_attr_setstacksize(&attr, 2048000);
pthread_attr_getstacksize(&attr, &size);
pthread_attr_init(&attr);
pthread_attr_setstacksize(&attr, 2048000);
pthread_attr_getstacksize(&attr, &size);
pthread_create(&t_Demod, &attr, &DemodulatorThread::pthread_helper, demodulatorThread);
pthread_attr_destroy(&attr);
pthread_attr_destroy(&attr);
std::cout << "Initialized demodulator stack size of " << size << std::endl;
std::cout << "Initialized demodulator stack size of " << size << std::endl;
#else
t_Demod = new std::thread(&DemodulatorThread::threadMain, demodulatorThread);
@@ -91,7 +93,16 @@ void DemodulatorInstance::terminate() {
t_Audio->join();
}
DemodulatorMgr::DemodulatorMgr() {
std::string DemodulatorInstance::getLabel() {
return label;
}
void DemodulatorInstance::setLabel(std::string labelStr) {
label = labelStr;
}
DemodulatorMgr::DemodulatorMgr() :
activeDemodulator(NULL), lastActiveDemodulator(NULL) {
}
@@ -101,7 +112,13 @@ DemodulatorMgr::~DemodulatorMgr() {
DemodulatorInstance *DemodulatorMgr::newThread() {
DemodulatorInstance *newDemod = new DemodulatorInstance;
demods.push_back(newDemod);
std::stringstream label;
label << demods.size();
newDemod->setLabel(label.str());
return newDemod;
}
@@ -137,3 +154,26 @@ std::vector<DemodulatorInstance *> *DemodulatorMgr::getDemodulatorsAt(int freq,
return foundDemods;
}
void DemodulatorMgr::setActiveDemodulator(DemodulatorInstance *demod, bool temporary) {
if (!temporary) {
if (activeDemodulator != NULL) {
lastActiveDemodulator = activeDemodulator;
} else {
lastActiveDemodulator = demod;
}
}
activeDemodulator = demod;
}
DemodulatorInstance *DemodulatorMgr::getActiveDemodulator() {
return activeDemodulator;
}
DemodulatorInstance *DemodulatorMgr::getLastActiveDemodulator() {
if (std::find(demods.begin(), demods.end(), lastActiveDemodulator) == demods.end()) {
lastActiveDemodulator = activeDemodulator;
}
return lastActiveDemodulator;
}
+12
View File
@@ -32,6 +32,11 @@ public:
void run();
void terminate();
std::string getLabel();
void setLabel(std::string labelStr);
private:
std::string label;
};
class DemodulatorMgr {
@@ -44,6 +49,13 @@ public:
std::vector<DemodulatorInstance *> *getDemodulatorsAt(int freq, int bandwidth);
void terminateAll();
void setActiveDemodulator(DemodulatorInstance *demod, bool temporary = true);
DemodulatorInstance *getActiveDemodulator();
DemodulatorInstance *getLastActiveDemodulator();
private:
std::vector<DemodulatorInstance *> demods;
DemodulatorInstance *activeDemodulator;
DemodulatorInstance *lastActiveDemodulator;
};