diff --git a/apps/graph/cartesian_function_store.cpp b/apps/graph/cartesian_function_store.cpp index d7acf19c9..b2a5db2ea 100644 --- a/apps/graph/cartesian_function_store.cpp +++ b/apps/graph/cartesian_function_store.cpp @@ -8,7 +8,6 @@ extern "C" { namespace Graph { constexpr int CartesianFunctionStore::k_maxNumberOfFunctions; -constexpr KDColor CartesianFunctionStore::k_defaultColors[k_maxNumberOfFunctions]; constexpr const char * CartesianFunctionStore::k_functionNames[k_maxNumberOfFunctions]; CartesianFunctionStore::CartesianFunctionStore() : @@ -89,22 +88,6 @@ const char * CartesianFunctionStore::firstAvailableName() { return k_functionNames[0]; } -const KDColor CartesianFunctionStore::firstAvailableColor() { - for (int k = 0; k < k_maxNumberOfFunctions; k++) { - int j = 0; - while (j < m_numberOfFunctions) { - if (m_functions[j].color() == k_defaultColors[k]) { - break; - } - j++; - } - if (j == m_numberOfFunctions) { - return k_defaultColors[k]; - } - } - return k_defaultColors[0]; -} - void CartesianFunctionStore::removeAll() { for (int i = 0; i < m_numberOfFunctions; i++) { CartesianFunction emptyFunction("", KDColorBlack); diff --git a/apps/graph/cartesian_function_store.h b/apps/graph/cartesian_function_store.h index ad2e0a497..fb37e9639 100644 --- a/apps/graph/cartesian_function_store.h +++ b/apps/graph/cartesian_function_store.h @@ -23,10 +23,6 @@ public: static constexpr int k_maxNumberOfFunctions = 4; private: const char * firstAvailableName() override; - const KDColor firstAvailableColor() override; - static constexpr KDColor k_defaultColors[k_maxNumberOfFunctions] = { - Palette::Red, Palette::Blue, Palette::Green, Palette::YellowDark, - }; static constexpr const char * k_functionNames[k_maxNumberOfFunctions] = { "f", "g", "h", "p", }; diff --git a/apps/sequence/sequence_store.cpp b/apps/sequence/sequence_store.cpp index 6a51047bc..1ec18d06e 100644 --- a/apps/sequence/sequence_store.cpp +++ b/apps/sequence/sequence_store.cpp @@ -7,7 +7,6 @@ extern "C" { namespace Sequence { -constexpr KDColor SequenceStore::k_defaultColors[MaxNumberOfSequences]; constexpr const char * SequenceStore::k_sequenceNames[MaxNumberOfSequences]; uint32_t SequenceStore::storeChecksum() { @@ -82,22 +81,6 @@ const char * SequenceStore::firstAvailableName() { return k_sequenceNames[0]; } -const KDColor SequenceStore::firstAvailableColor() { - for (int k = 0; k < MaxNumberOfSequences; k++) { - int j = 0; - while (j < m_numberOfFunctions) { - if (m_sequences[j].color() == k_defaultColors[k]) { - break; - } - j++; - } - if (j == m_numberOfFunctions) { - return k_defaultColors[k]; - } - } - return k_defaultColors[0]; -} - void SequenceStore::removeAll() { for (int i = 0; i < m_numberOfFunctions; i++) { Sequence emptySequence("", KDColorBlack); diff --git a/apps/sequence/sequence_store.h b/apps/sequence/sequence_store.h index 423bff97d..5d14004f3 100644 --- a/apps/sequence/sequence_store.h +++ b/apps/sequence/sequence_store.h @@ -29,9 +29,6 @@ public: }; private: const KDColor firstAvailableColor() override; - static constexpr KDColor k_defaultColors[MaxNumberOfSequences] = { - Palette::Red, Palette::Blue//, Palette::YellowDark - }; Sequence m_sequences[MaxNumberOfSequences]; }; diff --git a/apps/shared/float_pair_store.h b/apps/shared/float_pair_store.h index 7b9c05238..41eda91e5 100644 --- a/apps/shared/float_pair_store.h +++ b/apps/shared/float_pair_store.h @@ -1,6 +1,8 @@ #ifndef SHARED_FLOAT_PAIR_STORE_H #define SHARED_FLOAT_PAIR_STORE_H +#include +#include #include #include @@ -33,6 +35,15 @@ public: void resetColumn(int series, int i); double sumOfColumn(int series, int i) const; uint32_t storeChecksum(); + + static KDColor colorOfSeriesAtIndex(int i) { + assert(i >= 0 && i < k_numberOfSeries); + return Palette::DataColor[i]; + } + static KDColor colorLightOfSeriesAtIndex(int i) { + assert(i >= 0 && i < k_numberOfSeries); + return Palette::DataColorLight[i]; + } protected: virtual double defaultValue(int series, int i, int j); int m_numberOfPairs[k_numberOfSeries]; diff --git a/apps/shared/function_store.cpp b/apps/shared/function_store.cpp index 0f7894076..e3a1f56d4 100644 --- a/apps/shared/function_store.cpp +++ b/apps/shared/function_store.cpp @@ -70,4 +70,20 @@ void FunctionStore::tidy() { } } +const KDColor FunctionStore::firstAvailableColor() { + for (int k = 0; k < maxNumberOfFunctions(); k++) { + int j = 0; + while (j < m_numberOfFunctions) { + if (functionAtIndex(j)->color() == Palette::DataColor[k]) { + break; + } + j++; + } + if (j == m_numberOfFunctions) { + return Palette::DataColor[k]; + } + } + return Palette::DataColor[0]; +} + } diff --git a/apps/shared/function_store.h b/apps/shared/function_store.h index 93d1c2397..f3cae3faf 100644 --- a/apps/shared/function_store.h +++ b/apps/shared/function_store.h @@ -28,10 +28,10 @@ public: virtual char symbol() const = 0; void tidy(); protected: + const KDColor firstAvailableColor(); int m_numberOfFunctions; private: virtual const char * firstAvailableName() = 0; - virtual const KDColor firstAvailableColor() = 0; }; } diff --git a/apps/statistics/calculation_controller.cpp b/apps/statistics/calculation_controller.cpp index 824417743..b9cb84ea4 100644 --- a/apps/statistics/calculation_controller.cpp +++ b/apps/statistics/calculation_controller.cpp @@ -53,10 +53,9 @@ void CalculationController::willDisplayCellAtLocation(HighlightCell * cell, int // Display a series title cell int seriesNumber = m_store->indexOfKthNonEmptySeries(i-1); char titleBuffer[] = {'V', static_cast('0'+seriesNumber), '/', 'N', static_cast('0'+seriesNumber), 0}; - KDColor colors[] = {Palette::Red, Palette::Blue, Palette::Green}; StoreTitleCell * storeTitleCell = static_cast(cell); storeTitleCell->setText(titleBuffer); - storeTitleCell->setColor(colors[seriesNumber]); + storeTitleCell->setColor(FloatPairStore::colorOfSeriesAtIndex(seriesNumber)); return; } if (i == 0) { diff --git a/apps/statistics/multiple_boxes_view.cpp b/apps/statistics/multiple_boxes_view.cpp index 26a27cd89..79a184946 100644 --- a/apps/statistics/multiple_boxes_view.cpp +++ b/apps/statistics/multiple_boxes_view.cpp @@ -7,10 +7,9 @@ namespace Statistics { MultipleBoxesView::MultipleBoxesView(BoxController * controller, Store * store, BoxView::Quantile * selectedQuantile) : MultipleDataView(store), - m_boxView1(controller, store, 0, nullptr, selectedQuantile, Palette::Red, Palette::RedLight), - m_boxView2(controller, store, 1, nullptr, selectedQuantile, Palette::Blue, Palette::BlueLight), - m_boxView3(controller, store, 2, nullptr, selectedQuantile, Palette::Green, Palette::GreenLight), - // TODO Share colors with stats/store_controller + m_boxView1(controller, store, 0, nullptr, selectedQuantile, FloatPairStore::colorOfSeriesAtIndex(0), FloatPairStore::colorLightOfSeriesAtIndex(0)), + m_boxView2(controller, store, 1, nullptr, selectedQuantile, FloatPairStore::colorOfSeriesAtIndex(1), FloatPairStore::colorLightOfSeriesAtIndex(0)), + m_boxView3(controller, store, 2, nullptr, selectedQuantile, FloatPairStore::colorOfSeriesAtIndex(2), FloatPairStore::colorLightOfSeriesAtIndex(0)), m_axisView(store), m_bannerView() { diff --git a/apps/statistics/multiple_histograms_view.cpp b/apps/statistics/multiple_histograms_view.cpp index 8c7ac869a..7d4126c03 100644 --- a/apps/statistics/multiple_histograms_view.cpp +++ b/apps/statistics/multiple_histograms_view.cpp @@ -7,10 +7,9 @@ namespace Statistics { MultipleHistogramsView::MultipleHistogramsView(HistogramController * controller, Store * store) : MultipleDataView(store), - m_histogramView1(controller, store, 0, nullptr, Palette::Red), - m_histogramView2(controller, store, 1, nullptr, Palette::Blue), - m_histogramView3(controller, store, 2, nullptr, Palette::Green), - // TODO Share colors with stats/store_controller + m_histogramView1(controller, store, 0, nullptr, FloatPairStore::colorOfSeriesAtIndex(0)), + m_histogramView2(controller, store, 1, nullptr, FloatPairStore::colorOfSeriesAtIndex(1)), + m_histogramView3(controller, store, 2, nullptr, FloatPairStore::colorOfSeriesAtIndex(2)), m_bannerView(), m_okView() { diff --git a/apps/statistics/store_controller.cpp b/apps/statistics/store_controller.cpp index ac9a15638..24026b514 100644 --- a/apps/statistics/store_controller.cpp +++ b/apps/statistics/store_controller.cpp @@ -33,8 +33,7 @@ void StoreController::willDisplayCellAtLocation(HighlightCell * cell, int i, int I18n::Message sizesMessages[] = {I18n::Message::Sizes1, I18n::Message::Sizes2, I18n::Message::Sizes3}; mytitleCell->setText(I18n::translate(sizesMessages[seriesIndex])); } - KDColor colors[] = {Palette::Red, Palette::Blue, Palette::Green}; - mytitleCell->setColor(m_store->numberOfPairsOfSeries(seriesIndex) == 0 ? Palette::GreyDark : colors[seriesIndex]); // TODO Share GreyDark and other colors with graph/list_controller + mytitleCell->setColor(m_store->numberOfPairsOfSeries(seriesIndex) == 0 ? Palette::GreyDark : Store::colorOfSeriesAtIndex(seriesIndex)); // TODO Share GreyDark with graph/list_controller } HighlightCell * StoreController::titleCells(int index) { diff --git a/escher/include/escher/palette.h b/escher/include/escher/palette.h index ab6457712..c78c6aea9 100644 --- a/escher/include/escher/palette.h +++ b/escher/include/escher/palette.h @@ -30,6 +30,8 @@ public: constexpr static KDColor Orange = KDColor::RGB24(0xfe871f); constexpr static KDColor Green = KDColor::RGB24(0x50c102); constexpr static KDColor GreenLight = KDColor::RGB24(0x52db8f); + constexpr static KDColor DataColor[] = {Red, Blue, Green, YellowDark}; + constexpr static KDColor DataColorLight[] = {RedLight, BlueLight, GreenLight, YellowLight}; }; #endif diff --git a/escher/src/palette.cpp b/escher/src/palette.cpp index 719638922..ba4b72151 100644 --- a/escher/src/palette.cpp +++ b/escher/src/palette.cpp @@ -25,3 +25,5 @@ constexpr KDColor Palette::BlueLight; constexpr KDColor Palette::Orange; constexpr KDColor Palette::Green; constexpr KDColor Palette::GreenLight; +constexpr KDColor Palette::DataColor[]; +constexpr KDColor Palette::DataColorLight[];