mirror of
https://github.com/UpsilonNumworks/Upsilon.git
synced 2026-03-28 01:59:59 +01:00
[apps/graph/values_controller] Split table into three pieces
This commit is contained in:
@@ -54,6 +54,14 @@ void ValuesController::willDisplayCellAtLocation(HighlightCell * cell, int i, in
|
||||
}
|
||||
}
|
||||
|
||||
int ValuesController::typeAtLocation(int i, int j) {
|
||||
int plotTypeIndex = 0;
|
||||
while (plotTypeIndex < 3 && i >= m_numberOfColumnsForType[plotTypeIndex]) {
|
||||
i -= m_numberOfColumnsForType[plotTypeIndex++];
|
||||
}
|
||||
return Shared::ValuesController::typeAtLocation(i, j);
|
||||
}
|
||||
|
||||
I18n::Message ValuesController::emptyMessage() {
|
||||
if (functionStore()->numberOfDefinedModels() == 0) {
|
||||
return I18n::Message::NoFunction;
|
||||
@@ -68,14 +76,21 @@ Ion::Storage::Record ValuesController::recordAtColumn(int i) {
|
||||
|
||||
Ion::Storage::Record ValuesController::recordAtColumn(int i, bool * isDerivative) {
|
||||
assert(typeAtLocation(i, 0) == 1);
|
||||
int plotTypeIndex = 0;
|
||||
while (plotTypeIndex < 3 && i >= m_numberOfColumnsForType[plotTypeIndex]) {
|
||||
i -= m_numberOfColumnsForType[plotTypeIndex++];
|
||||
}
|
||||
CartesianFunction::PlotType plotType = static_cast<CartesianFunction::PlotType>(plotTypeIndex);
|
||||
int index = 1;
|
||||
for (int k = 0; k < functionStore()->numberOfActiveFunctions(); k++) {
|
||||
Ion::Storage::Record record = functionStore()->activeRecordAtIndex(k);
|
||||
if (index <= i && i < index + numberOfColumnsForRecord(record)) {
|
||||
*isDerivative = i != index;
|
||||
for (int k = 0; k < functionStore()->numberOfActiveFunctionsOfType(plotType); k++) {
|
||||
Ion::Storage::Record record = functionStore()->activeRecordOfTypeAtIndex(plotType, k);
|
||||
const int numberOfColumnsForCurrentRecord = numberOfColumnsForRecord(record);
|
||||
if (index <= i && i < index + numberOfColumnsForCurrentRecord) {
|
||||
ExpiringPointer<CartesianFunction> f = functionStore()->modelForRecord(record);
|
||||
*isDerivative = i != index && f->plotType() == CartesianFunction::PlotType::Cartesian;
|
||||
return record;
|
||||
}
|
||||
index += numberOfColumnsForRecord(record);
|
||||
index += numberOfColumnsForCurrentRecord;
|
||||
}
|
||||
assert(false);
|
||||
return nullptr;
|
||||
@@ -83,7 +98,10 @@ Ion::Storage::Record ValuesController::recordAtColumn(int i, bool * isDerivative
|
||||
|
||||
int ValuesController::numberOfColumnsForRecord(Ion::Storage::Record record) const {
|
||||
ExpiringPointer<CartesianFunction> f = functionStore()->modelForRecord(record);
|
||||
return 1 + f->displayDerivative();
|
||||
CartesianFunction::PlotType plotType = f->plotType();
|
||||
return 1 +
|
||||
(plotType == CartesianFunction::PlotType::Cartesian && f->displayDerivative()) +
|
||||
(plotType == CartesianFunction::PlotType::Parametric);
|
||||
}
|
||||
|
||||
int ValuesController::maxNumberOfCells() {
|
||||
@@ -107,6 +125,9 @@ EvenOddBufferTextCell * ValuesController::floatCells(int j) {
|
||||
ViewController * ValuesController::functionParameterController() {
|
||||
bool isDerivative = false;
|
||||
Ion::Storage::Record record = recordAtColumn(selectedColumn(), &isDerivative);
|
||||
if (functionStore()->modelForRecord(record)->plotType() != CartesianFunction::PlotType::Cartesian) {
|
||||
return nullptr;
|
||||
}
|
||||
if (isDerivative) {
|
||||
m_derivativeParameterController.setRecord(record);
|
||||
return &m_derivativeParameterController;
|
||||
@@ -132,12 +153,20 @@ double ValuesController::evaluationOfAbscissaAtColumn(double abscissa, int colum
|
||||
}
|
||||
|
||||
void ValuesController::updateNumberOfColumns() {
|
||||
int result = 1;
|
||||
for (int plotTypeIndex = 0; plotTypeIndex < 3; plotTypeIndex++) {
|
||||
m_numberOfColumnsForType[plotTypeIndex] = 0;
|
||||
}
|
||||
for (int i = 0; i < functionStore()->numberOfActiveFunctions(); i++) {
|
||||
Ion::Storage::Record record = functionStore()->activeRecordAtIndex(i);
|
||||
result += numberOfColumnsForRecord(record);
|
||||
ExpiringPointer<CartesianFunction> f = functionStore()->modelForRecord(record);
|
||||
int plotTypeIndex = static_cast<int>(f->plotType());
|
||||
m_numberOfColumnsForType[plotTypeIndex] += numberOfColumnsForRecord(record);
|
||||
}
|
||||
m_numberOfColumns = 0;
|
||||
for (int plotTypeIndex = 0; plotTypeIndex < 3; plotTypeIndex++) {
|
||||
m_numberOfColumnsForType[plotTypeIndex] += (m_numberOfColumnsForType[plotTypeIndex] > 0);
|
||||
m_numberOfColumns += m_numberOfColumnsForType[plotTypeIndex];
|
||||
}
|
||||
m_numberOfColumns = result;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -18,6 +18,7 @@ public:
|
||||
return const_cast<Button *>(&m_setIntervalButton);
|
||||
}
|
||||
void willDisplayCellAtLocation(HighlightCell * cell, int i, int j) override;
|
||||
int typeAtLocation(int i, int j) override;
|
||||
I18n::Message emptyMessage() override;
|
||||
Shared::IntervalParameterController * intervalParameterController() override {
|
||||
return &m_intervalParameterController;
|
||||
@@ -25,10 +26,10 @@ public:
|
||||
IntervalParameterSelectorController * intervalParameterSelectorController() {
|
||||
return &m_intervalParameterSelectorController;
|
||||
}
|
||||
void updateNumberOfColumns() override;
|
||||
private:
|
||||
constexpr static int k_maxNumberOfCells = 50;
|
||||
constexpr static int k_maxNumberOfFunctions = 5;
|
||||
void updateNumberOfColumns() override;
|
||||
Ion::Storage::Record recordAtColumn(int i) override;
|
||||
Ion::Storage::Record recordAtColumn(int i, bool * isDerivative);
|
||||
int numberOfColumnsForRecord(Ion::Storage::Record record) const;
|
||||
@@ -41,6 +42,7 @@ private:
|
||||
ViewController * functionParameterController() override;
|
||||
I18n::Message valuesParameterControllerPageTitle() const override;
|
||||
|
||||
int m_numberOfColumnsForType[3];
|
||||
Shared::BufferFunctionTitleCell m_functionTitleCells[k_maxNumberOfFunctions];
|
||||
EvenOddBufferTextCell m_floatCells[k_maxNumberOfCells];
|
||||
FunctionParameterController m_functionParameterController;
|
||||
|
||||
@@ -177,7 +177,7 @@ HighlightCell * ValuesController::reusableCell(int index, int type) {
|
||||
int ValuesController::reusableCellCount(int type) {
|
||||
switch (type) {
|
||||
case 0:
|
||||
return 1;
|
||||
return 3;
|
||||
case 1:
|
||||
return maxNumberOfFunctions();
|
||||
case 2:
|
||||
|
||||
@@ -60,7 +60,7 @@ private:
|
||||
return Interval::k_maxNumberOfElements;
|
||||
};
|
||||
virtual double evaluationOfAbscissaAtColumn(double abscissa, int columnIndex);
|
||||
constexpr static int k_maxNumberOfAbscissaCells = 10;
|
||||
constexpr static int k_maxNumberOfAbscissaCells = 30;
|
||||
virtual int maxNumberOfCells() = 0;
|
||||
virtual int maxNumberOfFunctions() = 0;
|
||||
SelectableTableView m_selectableTableView;
|
||||
@@ -76,4 +76,3 @@ private:
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
Reference in New Issue
Block a user