aboutsummaryrefslogtreecommitdiff
path: root/selectionhandler.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'selectionhandler.cpp')
-rw-r--r--selectionhandler.cpp19
1 files changed, 19 insertions, 0 deletions
diff --git a/selectionhandler.cpp b/selectionhandler.cpp
new file mode 100644
index 0000000..4c488a0
--- /dev/null
+++ b/selectionhandler.cpp
@@ -0,0 +1,19 @@
+#include "selectionhandler.h"
+
+SelectionHandler::SelectionHandler(const arma::uvec &sampleIndices)
+ : m_sampleIndices(sampleIndices)
+{
+}
+
+void SelectionHandler::setSelection(const arma::uvec &selection)
+{
+ arma::uvec newSelection(selection);
+
+ // The selecion happens over the sample indices. We use the original dataset
+ // indices in sampleIndices to translate indices.
+ for (auto it = newSelection.begin(); it != newSelection.end(); it++) {
+ *it = m_sampleIndices[*it];
+ }
+
+ emit selectionChanged(newSelection);
+}