From 0518b806d8ce25c69847ec8c403276193611b2e1 Mon Sep 17 00:00:00 2001 From: Samuel Fadel Date: Thu, 17 Sep 2015 12:20:24 -0300 Subject: Additional interactive functionalities. - Selection linking between subsample plot and main plot - Dumb "effectiveness" coloring --- effectivenessobserver.cpp | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 effectivenessobserver.cpp (limited to 'effectivenessobserver.cpp') diff --git a/effectivenessobserver.cpp b/effectivenessobserver.cpp new file mode 100644 index 0000000..305b3f8 --- /dev/null +++ b/effectivenessobserver.cpp @@ -0,0 +1,42 @@ +#include "effectivenessobserver.h" + +EffectiveInteractionEnforcer::EffectiveInteractionEnforcer(const arma::uvec &sampleIndices) + : m_sampleIndices(sampleIndices) + , m_effectiveness(arma::zeros(sampleIndices.n_elem)) +{ +} + +void EffectiveInteractionEnforcer::setSelection(const arma::uvec &selection) +{ + m_selection = selection; +} + +void EffectiveInteractionEnforcer::setMeasureDifference(const arma::vec &measure) +{ + m_measure = measure; + + if (m_selection.n_elem == 0) { + return; + } + + arma::uvec selectionIndices(m_selection); + for (auto it = selectionIndices.begin(); it != selectionIndices.end(); it++) { + *it = m_sampleIndices[*it]; + } + + double diff = arma::mean(m_measure(selectionIndices)); + int effectiveness; + if (diff > 0) { + effectiveness = 1; + } else if (diff < 0) { + effectiveness = -1; + } else { + effectiveness = 0; + } + + for (auto it = m_selection.cbegin(); it != m_selection.cend(); it++) { + m_effectiveness[*it] = effectiveness; + } + + emit effectivenessChanged(m_effectiveness); +} -- cgit v1.2.3