diff --git a/apps/graph/values/interval.cpp b/apps/graph/values/interval.cpp index c1804fb93..6cc588b29 100644 --- a/apps/graph/values/interval.cpp +++ b/apps/graph/values/interval.cpp @@ -16,6 +16,14 @@ int Interval::numberOfElements() { return m_numberOfElements; } +void Interval::deleteElementAtIndex(int index) { + m_numberOfElements--; + for (int k = index; k < m_numberOfElements; k++) { + m_intervalBuffer[k] = m_intervalBuffer[k+1]; + } + m_intervalBuffer[m_numberOfElements] = 0.0f; +} + float Interval::element(int i) { assert(i >= 0 && i < numberOfElements()); computeElements(); diff --git a/apps/graph/values/interval.h b/apps/graph/values/interval.h index 34455c069..69476714a 100644 --- a/apps/graph/values/interval.h +++ b/apps/graph/values/interval.h @@ -9,6 +9,7 @@ public: // Delete the implicit copy constructor: the object is heavy Interval(const Interval&) = delete; int numberOfElements(); + void deleteElementAtIndex(int index); float element(int i); float start(); float end(); diff --git a/apps/graph/values/values_controller.cpp b/apps/graph/values/values_controller.cpp index ff03d4ad7..4ae13f643 100644 --- a/apps/graph/values/values_controller.cpp +++ b/apps/graph/values/values_controller.cpp @@ -56,7 +56,12 @@ bool ValuesController::handleEvent(Ion::Events::Event event) { headerViewController()->setSelectedButton(0); return true; } - + if (event == Ion::Events::Clear && activeRow() > 0 && + (activeRow() < numberOfRows()-1 || m_interval.numberOfElements() == Interval::k_maxNumberOfElements)) { + m_interval.deleteElementAtIndex(m_selectableTableView.selectedRow()-1); + m_selectableTableView.reloadData(); + return true; + } if (event == Ion::Events::OK) { if (activeRow() == -1) { return headerViewController()->handleEvent(event);