mirror of
https://github.com/UpsilonNumworks/Upsilon.git
synced 2026-03-19 05:40:38 +01:00
[apps/escher] Share color selection for data (Red, blue, Green, Yellow)
This commit is contained in:
@@ -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);
|
||||
|
||||
@@ -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",
|
||||
};
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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];
|
||||
};
|
||||
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
#ifndef SHARED_FLOAT_PAIR_STORE_H
|
||||
#define SHARED_FLOAT_PAIR_STORE_H
|
||||
|
||||
#include <kandinsky/color.h>
|
||||
#include <escher/palette.h>
|
||||
#include <stdint.h>
|
||||
#include <assert.h>
|
||||
|
||||
@@ -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];
|
||||
|
||||
@@ -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];
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
@@ -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<char>('0'+seriesNumber), '/', 'N', static_cast<char>('0'+seriesNumber), 0};
|
||||
KDColor colors[] = {Palette::Red, Palette::Blue, Palette::Green};
|
||||
StoreTitleCell * storeTitleCell = static_cast<StoreTitleCell *>(cell);
|
||||
storeTitleCell->setText(titleBuffer);
|
||||
storeTitleCell->setColor(colors[seriesNumber]);
|
||||
storeTitleCell->setColor(FloatPairStore::colorOfSeriesAtIndex(seriesNumber));
|
||||
return;
|
||||
}
|
||||
if (i == 0) {
|
||||
|
||||
@@ -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()
|
||||
{
|
||||
|
||||
@@ -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()
|
||||
{
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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[];
|
||||
|
||||
Reference in New Issue
Block a user