diff --git a/apps/graph/graph/graph_controller.cpp b/apps/graph/graph/graph_controller.cpp index fe087d4a3..3e542295f 100644 --- a/apps/graph/graph/graph_controller.cpp +++ b/apps/graph/graph/graph_controller.cpp @@ -32,7 +32,7 @@ void GraphController::reloadBannerView() { return; } char buffer[k_maxNumberOfCharacters+Complex::bufferSizeForFloatsWithPrecision(Constant::LargeNumberOfSignificantDigits)]; - const char * legend = "00(x) = "; + const char * legend = "00(x)="; int legendLength = strlen(legend); strlcpy(buffer, legend, legendLength+1); if (m_functionStore->numberOfActiveFunctions() == 0) { diff --git a/apps/regression/graph_controller.cpp b/apps/regression/graph_controller.cpp index f7a685091..4ccb06257 100644 --- a/apps/regression/graph_controller.cpp +++ b/apps/regression/graph_controller.cpp @@ -54,23 +54,34 @@ bool GraphController::handleEnter() { } void GraphController::reloadBannerView() { - m_bannerView.setLegendAtIndex((char *)"y = ax+b", 0); + m_bannerView.setLegendAtIndex((char *)" y=ax+b ", 0); char buffer[k_maxNumberOfCharacters + Complex::bufferSizeForFloatsWithPrecision(Constant::LargeNumberOfSignificantDigits)]; - const char * legend = "a = "; + int numberOfChar = 0; + const char * legend = "a="; float slope = m_store->slope(); int legendLength = strlen(legend); strlcpy(buffer, legend, legendLength+1); - Complex::convertFloatToText(slope, buffer+legendLength, Complex::bufferSizeForFloatsWithPrecision(Constant::LargeNumberOfSignificantDigits), Constant::LargeNumberOfSignificantDigits); + numberOfChar += legendLength; + numberOfChar += Complex::convertFloatToText(slope, buffer+numberOfChar, Complex::bufferSizeForFloatsWithPrecision(Constant::LargeNumberOfSignificantDigits), Constant::LargeNumberOfSignificantDigits); + legend = " "; + legendLength = strlen(legend); + strlcpy(buffer+numberOfChar, legend, legendLength+1); m_bannerView.setLegendAtIndex(buffer, 1); - legend = "b = "; + numberOfChar = 0; + legend = "b="; float yIntercept = m_store->yIntercept(); legendLength = strlen(legend); strlcpy(buffer, legend, legendLength+1); - Complex::convertFloatToText(yIntercept, buffer+legendLength, Complex::bufferSizeForFloatsWithPrecision(Constant::LargeNumberOfSignificantDigits), Constant::LargeNumberOfSignificantDigits); + numberOfChar += legendLength; + numberOfChar += Complex::convertFloatToText(yIntercept, buffer+numberOfChar, Complex::bufferSizeForFloatsWithPrecision(Constant::LargeNumberOfSignificantDigits), Constant::LargeNumberOfSignificantDigits); + legend = " "; + legendLength = strlen(legend); + strlcpy(buffer+numberOfChar, legend, legendLength+1); m_bannerView.setLegendAtIndex(buffer, 2); - legend = "x = "; + numberOfChar = 0; + legend = " x="; float x = m_cursor.x(); // Display a specific legend if the mean dot is selected if (m_selectedDotIndex == m_store->numberOfPairs()) { @@ -80,10 +91,15 @@ void GraphController::reloadBannerView() { } legendLength = strlen(legend); strlcpy(buffer, legend, legendLength+1); - Complex::convertFloatToText(x, buffer+legendLength, Complex::bufferSizeForFloatsWithPrecision(Constant::LargeNumberOfSignificantDigits), Constant::LargeNumberOfSignificantDigits); + numberOfChar += legendLength; + numberOfChar += Complex::convertFloatToText(x, buffer+numberOfChar, Complex::bufferSizeForFloatsWithPrecision(Constant::LargeNumberOfSignificantDigits), Constant::LargeNumberOfSignificantDigits); + legend = " "; + legendLength = strlen(legend); + strlcpy(buffer+numberOfChar, legend, legendLength+1); m_bannerView.setLegendAtIndex(buffer, 3); - legend = "y = "; + numberOfChar = 0; + legend = " y="; float y = m_cursor.y(); if (m_selectedDotIndex == m_store->numberOfPairs()) { constexpr static char legY[] = {Ion::Charset::YBar, ' ', '=', ' ', 0}; @@ -92,7 +108,11 @@ void GraphController::reloadBannerView() { } legendLength = strlen(legend); strlcpy(buffer, legend, legendLength+1); - Complex::convertFloatToText(y, buffer+legendLength, Complex::bufferSizeForFloatsWithPrecision(Constant::LargeNumberOfSignificantDigits), Constant::LargeNumberOfSignificantDigits); + numberOfChar += legendLength; + numberOfChar += Complex::convertFloatToText(y, buffer+numberOfChar, Complex::bufferSizeForFloatsWithPrecision(Constant::LargeNumberOfSignificantDigits), Constant::LargeNumberOfSignificantDigits); + legend = " "; + legendLength = strlen(legend); + strlcpy(buffer+numberOfChar, legend, legendLength+1); m_bannerView.setLegendAtIndex(buffer, 4); } diff --git a/apps/shared/function_graph_controller.cpp b/apps/shared/function_graph_controller.cpp index 89ed200a0..f06b64fbf 100644 --- a/apps/shared/function_graph_controller.cpp +++ b/apps/shared/function_graph_controller.cpp @@ -104,15 +104,22 @@ bool FunctionGraphController::handleEnter() { void FunctionGraphController::reloadBannerView() { char buffer[k_maxNumberOfCharacters+Complex::bufferSizeForFloatsWithPrecision(Constant::LargeNumberOfSignificantDigits)]; - const char * legend = "0 = "; + const char * legend = "0="; int legendLength = strlen(legend); + int numberOfChar = 0; strlcpy(buffer, legend, legendLength+1); + numberOfChar += legendLength; buffer[0] = functionStore()->symbol(); - Complex::convertFloatToText(m_cursor.x(), buffer+ legendLength, Complex::bufferSizeForFloatsWithPrecision(Constant::LargeNumberOfSignificantDigits), Constant::LargeNumberOfSignificantDigits); + numberOfChar += Complex::convertFloatToText(m_cursor.x(), buffer+numberOfChar, Complex::bufferSizeForFloatsWithPrecision(Constant::LargeNumberOfSignificantDigits), Constant::LargeNumberOfSignificantDigits); + legend = " "; + legendLength = strlen(legend); + strlcpy(buffer+numberOfChar, legend, legendLength+1); bannerView()->setLegendAtIndex(buffer, 0); - legend = "0(x) = "; + numberOfChar = 0; + legend = "0(x)="; legendLength = strlen(legend); + numberOfChar += legendLength; strlcpy(buffer, legend, legendLength+1); buffer[2] = functionStore()->symbol(); if (functionStore()->numberOfActiveFunctions() == 0) { @@ -120,7 +127,10 @@ void FunctionGraphController::reloadBannerView() { } Function * f = functionStore()->activeFunctionAtIndex(m_indexFunctionSelectedByCursor); buffer[0] = f->name()[0]; - Complex::convertFloatToText(m_cursor.y(), buffer+legendLength, Complex::bufferSizeForFloatsWithPrecision(Constant::LargeNumberOfSignificantDigits), Constant::LargeNumberOfSignificantDigits); + numberOfChar += Complex::convertFloatToText(m_cursor.y(), buffer+legendLength, Complex::bufferSizeForFloatsWithPrecision(Constant::LargeNumberOfSignificantDigits), Constant::LargeNumberOfSignificantDigits); + legend = " "; + legendLength = strlen(legend); + strlcpy(buffer+numberOfChar, legend, legendLength+1); bannerView()->setLegendAtIndex(buffer, 1); } diff --git a/apps/statistics/histogram_controller.cpp b/apps/statistics/histogram_controller.cpp index 74f63d310..9603f82db 100644 --- a/apps/statistics/histogram_controller.cpp +++ b/apps/statistics/histogram_controller.cpp @@ -135,30 +135,41 @@ Responder * HistogramController::tabController() const { void HistogramController::reloadBannerView() { char buffer[k_maxNumberOfCharacters+ Complex::bufferSizeForFloatsWithPrecision(Constant::LargeNumberOfSignificantDigits)*2]; - const char * legend = "Interval ["; + int numberOfChar = 0; + const char * legend = "Intervalle ["; int legendLength = strlen(legend); strlcpy(buffer, legend, legendLength+1); + numberOfChar += legendLength; float lowerBound = m_store->startOfBarAtIndex(m_selectedBarIndex); - int lowerBoundNumberOfChar = Complex::convertFloatToText(lowerBound, buffer+legendLength, Complex::bufferSizeForFloatsWithPrecision(Constant::LargeNumberOfSignificantDigits), Constant::LargeNumberOfSignificantDigits); - buffer[legendLength+lowerBoundNumberOfChar] = ';'; + numberOfChar += Complex::convertFloatToText(lowerBound, buffer+numberOfChar, Complex::bufferSizeForFloatsWithPrecision(Constant::LargeNumberOfSignificantDigits), Constant::LargeNumberOfSignificantDigits); + buffer[numberOfChar++] = ';'; float upperBound = m_store->endOfBarAtIndex(m_selectedBarIndex); - int upperBoundNumberOfChar = Complex::convertFloatToText(upperBound, buffer+legendLength+lowerBoundNumberOfChar+1, Complex::bufferSizeForFloatsWithPrecision(Constant::LargeNumberOfSignificantDigits), Constant::LargeNumberOfSignificantDigits); - buffer[legendLength+lowerBoundNumberOfChar+upperBoundNumberOfChar+1] = '['; - buffer[legendLength+lowerBoundNumberOfChar+upperBoundNumberOfChar+2] = 0; + numberOfChar += Complex::convertFloatToText(upperBound, buffer+numberOfChar, Complex::bufferSizeForFloatsWithPrecision(Constant::LargeNumberOfSignificantDigits), Constant::LargeNumberOfSignificantDigits); + buffer[numberOfChar++] = '['; + legend = " "; + legendLength = strlen(legend); + strlcpy(buffer+numberOfChar, legend, legendLength+1); m_bannerView.setLegendAtIndex(buffer, 0); + numberOfChar = 0; legend = "Effectif: "; legendLength = strlen(legend); strlcpy(buffer, legend, legendLength+1); + numberOfChar += legendLength; float size = m_store->heightOfBarAtIndex(m_selectedBarIndex); - Complex::convertFloatToText(size, buffer+legendLength, Complex::bufferSizeForFloatsWithPrecision(Constant::LargeNumberOfSignificantDigits), Constant::LargeNumberOfSignificantDigits); + numberOfChar += Complex::convertFloatToText(size, buffer+numberOfChar, Complex::bufferSizeForFloatsWithPrecision(Constant::LargeNumberOfSignificantDigits), Constant::LargeNumberOfSignificantDigits); + legend = " "; + legendLength = strlen(legend); + strlcpy(buffer+numberOfChar, legend, legendLength+1); m_bannerView.setLegendAtIndex(buffer, 1); + numberOfChar = 0; legend = "Frequence: "; legendLength = strlen(legend); strlcpy(buffer, legend, legendLength+1); + numberOfChar += legendLength; float frequency = size/m_store->sumOfColumn(1); - Complex::convertFloatToText(frequency, buffer+legendLength, Complex::bufferSizeForFloatsWithPrecision(Constant::LargeNumberOfSignificantDigits), Constant::LargeNumberOfSignificantDigits); + numberOfChar += Complex::convertFloatToText(frequency, buffer+legendLength, Complex::bufferSizeForFloatsWithPrecision(Constant::LargeNumberOfSignificantDigits), Constant::LargeNumberOfSignificantDigits); m_bannerView.setLegendAtIndex(buffer, 2); }