diff --git a/apps/graph/values/values_controller.cpp b/apps/graph/values/values_controller.cpp index c0e506f43..579ea5e7d 100644 --- a/apps/graph/values/values_controller.cpp +++ b/apps/graph/values/values_controller.cpp @@ -192,8 +192,8 @@ I18n::Message ValuesController::valuesParameterMessageAtColumn(int columnIndex) ContinuousFunction::PlotType ValuesController::plotTypeAtColumn(int * i) const { int plotTypeIndex = 0; - while (plotTypeIndex < ContinuousFunction::k_numberOfPlotTypes && *i >= m_numberOfColumnsForType[plotTypeIndex]) { - *i -= m_numberOfColumnsForType[plotTypeIndex++]; + while (plotTypeIndex < ContinuousFunction::k_numberOfPlotTypes && *i >= numberOfColumnsForPlotType(plotTypeIndex)) { + *i -= numberOfColumnsForPlotType(plotTypeIndex++); } assert(plotTypeIndex < ContinuousFunction::k_numberOfPlotTypes); return static_cast(plotTypeIndex); @@ -271,22 +271,25 @@ void ValuesController::setStartEndMessages(Shared::IntervalParameterController * void ValuesController::updateNumberOfColumns() const { for (int plotTypeIndex = 0; plotTypeIndex < ContinuousFunction::k_numberOfPlotTypes; plotTypeIndex++) { - m_numberOfColumnsForType[plotTypeIndex] = 0; + m_numberOfValuesColumnsForType[plotTypeIndex] = 0; } for (int i = 0; i < functionStore()->numberOfActiveFunctions(); i++) { Ion::Storage::Record record = functionStore()->activeRecordAtIndex(i); ExpiringPointer f = functionStore()->modelForRecord(record); int plotTypeIndex = static_cast(f->plotType()); - m_numberOfColumnsForType[plotTypeIndex] += numberOfColumnsForRecord(record); + m_numberOfValuesColumnsForType[plotTypeIndex] += numberOfColumnsForRecord(record); } m_numberOfColumns = 0; for (int plotTypeIndex = 0; plotTypeIndex < ContinuousFunction::k_numberOfPlotTypes; plotTypeIndex++) { // Count abscissa column if the sub table does exist - m_numberOfColumnsForType[plotTypeIndex] += (m_numberOfColumnsForType[plotTypeIndex] > 0); - m_numberOfColumns += m_numberOfColumnsForType[plotTypeIndex]; + m_numberOfColumns += numberOfColumnsForPlotType(plotTypeIndex); } } +int ValuesController::numberOfColumnsForPlotType(int plotTypeIndex) const { + return m_numberOfValuesColumnsForType[plotTypeIndex] + (m_numberOfValuesColumnsForType[plotTypeIndex] > 0); // Count abscissa column if there is one +} + int writeMatrixBrakets(char * buffer, const int bufferSize, int type) { /* Write the double brackets required in matrix notation. * - type == 1: "[[" diff --git a/apps/graph/values/values_controller.h b/apps/graph/values/values_controller.h index dbcad5c8d..d39f4d1c0 100644 --- a/apps/graph/values/values_controller.h +++ b/apps/graph/values/values_controller.h @@ -64,6 +64,7 @@ private: EvenOddMessageTextCell * abscissaTitleCells(int j) override { assert (j >= 0 && j < abscissaTitleCellsCount()); return &m_abscissaTitleCells[j]; } ViewController * functionParameterController() override; SelectableTableView * selectableTableView() override { return &m_selectableTableView; } + int numberOfColumnsForPlotType(int plotTypeIndex) const; /* For parametric function, we display the evaluation with the form "(1;2)". * This form is not parsable so when we store it into the clipboard, we want @@ -77,7 +78,7 @@ private: }; ValuesSelectableTableView m_selectableTableView; - mutable int m_numberOfColumnsForType[Shared::ContinuousFunction::k_numberOfPlotTypes]; + mutable int m_numberOfValuesColumnsForType[Shared::ContinuousFunction::k_numberOfPlotTypes]; Shared::BufferFunctionTitleCell m_functionTitleCells[k_maxNumberOfFunctions]; Shared::HideableEvenOddBufferTextCell m_floatCells[k_maxNumberOfCells]; AbscissaTitleCell m_abscissaTitleCells[Shared::ContinuousFunction::k_numberOfPlotTypes];