mirror of
https://github.com/UpsilonNumworks/Upsilon.git
synced 2026-01-18 16:27:34 +01:00
[calculation] Dimension in additional output for values with units
This commit is contained in:
@@ -12,6 +12,21 @@ using namespace Shared;
|
||||
|
||||
namespace Calculation {
|
||||
|
||||
|
||||
UnitListController::UnitListController(EditExpressionController * editExpressionController) :
|
||||
ExpressionsListController(editExpressionController),
|
||||
m_dimensionMessage(I18n::Message::Default)
|
||||
{
|
||||
m_dimensionCell.setMessageFont(KDFont::LargeFont);
|
||||
}
|
||||
|
||||
bool UnitListController::handleEvent(Ion::Events::Event event) {
|
||||
if (selectedRow() == 0 && (event == Ion::Events::OK || event == Ion::Events::EXE)) {
|
||||
return true;
|
||||
}
|
||||
return ListController::handleEvent(event);
|
||||
}
|
||||
|
||||
void UnitListController::setExpression(Poincare::Expression e) {
|
||||
ExpressionsListController::setExpression(e);
|
||||
assert(!m_expression.isUninitialized());
|
||||
@@ -22,6 +37,7 @@ void UnitListController::setExpression(Poincare::Expression e) {
|
||||
for (size_t i = 0; i < k_maxNumberOfRows; i++) {
|
||||
expressions[i] = Expression();
|
||||
}
|
||||
m_dimensionMessage = I18n::Message::Default;
|
||||
|
||||
/* 1. First rows: miscellaneous classic units for some dimensions, in both
|
||||
* metric and imperial units. */
|
||||
@@ -37,7 +53,7 @@ void UnitListController::setExpression(Poincare::Expression e) {
|
||||
GlobalPreferences::sharedGlobalPreferences()->unitFormat(),
|
||||
ExpressionNode::ReductionTarget::User,
|
||||
ExpressionNode::SymbolicComputation::ReplaceAllSymbolsWithDefinitionsOrUndefined);
|
||||
int numberOfExpressions = Unit::SetAdditionalExpressions(units, value, expressions, k_maxNumberOfRows, reductionContext);
|
||||
int numberOfExpressions = Unit::SetAdditionalExpressionsAndMessage(units, value, expressions, k_maxNumberOfRows, reductionContext, &m_dimensionMessage);
|
||||
|
||||
// 2. SI units only
|
||||
assert(numberOfExpressions < k_maxNumberOfRows - 1);
|
||||
@@ -89,6 +105,44 @@ void UnitListController::setExpression(Poincare::Expression e) {
|
||||
}
|
||||
}
|
||||
|
||||
int UnitListController::numberOfRows() const {
|
||||
int messageRow = m_dimensionMessage != I18n::Message::Default ? 1 : 0;
|
||||
return ExpressionsListController::numberOfRows() + messageRow;
|
||||
}
|
||||
|
||||
void UnitListController::willDisplayCellForIndex(HighlightCell * cell, int index) {
|
||||
if (index == 0) {
|
||||
MessageTableCell * messageTableCell = (MessageTableCell *)cell;
|
||||
messageTableCell->setMessage(m_dimensionMessage);
|
||||
} else {
|
||||
ExpressionsListController::willDisplayCellForIndex(cell, index - 1);
|
||||
}
|
||||
}
|
||||
|
||||
KDCoordinate UnitListController::rowHeight(int index) {
|
||||
if (index == 0) {
|
||||
return 35;
|
||||
} else {
|
||||
return ExpressionsListController::rowHeight(index - 1);
|
||||
}
|
||||
}
|
||||
|
||||
HighlightCell * UnitListController::reusableCell(int index, int type) {
|
||||
if (type == 0) {
|
||||
return ExpressionsListController::reusableCell(index, type);
|
||||
} else {
|
||||
return &m_dimensionCell;
|
||||
}
|
||||
}
|
||||
|
||||
int UnitListController::typeAtLocation(int i, int j) {
|
||||
if (j == 0) {
|
||||
return 1;
|
||||
} else {
|
||||
return ExpressionsListController::typeAtLocation(i, j - 1);
|
||||
}
|
||||
}
|
||||
|
||||
I18n::Message UnitListController::messageAtIndex(int index) {
|
||||
return (I18n::Message)0;
|
||||
}
|
||||
|
||||
@@ -7,13 +7,23 @@ namespace Calculation {
|
||||
|
||||
class UnitListController : public ExpressionsListController {
|
||||
public:
|
||||
UnitListController(EditExpressionController * editExpressionController) :
|
||||
ExpressionsListController(editExpressionController) {}
|
||||
UnitListController(EditExpressionController * editExpressionController);
|
||||
|
||||
/* Responder */
|
||||
bool handleEvent(Ion::Events::Event event) override;
|
||||
|
||||
void setExpression(Poincare::Expression e) override;
|
||||
int reusableCellCount(int type) override { return type == 0 ? ExpressionsListController::reusableCellCount(type) : 1; }
|
||||
HighlightCell * reusableCell(int index, int type) override;
|
||||
KDCoordinate rowHeight(int j) override;
|
||||
int typeAtLocation(int i, int j) override;
|
||||
void willDisplayCellForIndex(HighlightCell * cell, int index) override;
|
||||
int numberOfRows() const override;
|
||||
|
||||
private:
|
||||
I18n::Message messageAtIndex(int index) override;
|
||||
I18n::Message m_dimensionMessage;
|
||||
MessageTableCell m_dimensionCell;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
@@ -17,4 +17,28 @@ FactorizedForm = "Factorisierte Form"
|
||||
Discriminant = "Diskriminante"
|
||||
OnlyRoot = "Wurzel"
|
||||
FirstRoot = "Erste Wurzel"
|
||||
SecondRoot = "Zweite Wurzel"
|
||||
SecondRoot = "Zweite Wurzel"
|
||||
TimeDimension = "Zeit"
|
||||
DistanceDimension = "Distanz"
|
||||
MassDimension = "Masse"
|
||||
CurrentDimension = "Betrieb"
|
||||
TemperatureDimension = "Temperatur"
|
||||
AmountOfSubstanceDimension = "Quantität der Materie"
|
||||
LuminousIntensityDimension = "Lichtintensität"
|
||||
FrequencyDimension = "Frequenz"
|
||||
ForceDimension = "Stärke"
|
||||
PressureDimension = "Druck"
|
||||
EnergyDimension = "Energie"
|
||||
PowerDimension = "Mächtig"
|
||||
ElectricChargeDimension = "Elektrische Ladung"
|
||||
ElectricPotentialDimension = "Elektrisches Potenzial"
|
||||
ElectricCapacitanceDimension = "Elektrische Kapazität"
|
||||
ElectricResistanceDimension = "Elektrischer Wiederstand"
|
||||
ElectricConductanceDimension = "elektrische Leitfähigkeit"
|
||||
MagneticFluxDimension = "magnetischer Fluss"
|
||||
MagneticFieldDimension = "Magnetfeld"
|
||||
InductanceDimension = "Induktivität"
|
||||
CatalyticActivityDimension = "Katalytische Aktivität"
|
||||
SurfaceDimension = "Auftauchen"
|
||||
VolumeDimension = "Volumen"
|
||||
SpeedDimension = "Geschwindigkeit"
|
||||
|
||||
@@ -17,4 +17,28 @@ FactorizedForm = "Factorized form"
|
||||
Discriminant = "Discriminant"
|
||||
OnlyRoot = "Root"
|
||||
FirstRoot = "First root"
|
||||
SecondRoot = "Second root"
|
||||
SecondRoot = "Second root"
|
||||
TimeDimension = "Time"
|
||||
DistanceDimension = "Distance"
|
||||
MassDimension = "Mass"
|
||||
CurrentDimension = "Running"
|
||||
TemperatureDimension = "Temperature"
|
||||
AmountOfSubstanceDimension = "Quantity of matter"
|
||||
LuminousIntensityDimension = "Light intensity"
|
||||
FrequencyDimension = "Frequency"
|
||||
ForceDimension = "Strength"
|
||||
PressureDimension = "Pressure"
|
||||
EnergyDimension = "Energy"
|
||||
PowerDimension = "Powerful"
|
||||
ElectricChargeDimension = "Electrical charge"
|
||||
ElectricPotentialDimension = "Electric potential"
|
||||
ElectricCapacitanceDimension = "Electrical capacity"
|
||||
ElectricResistanceDimension = "Electrical resistance"
|
||||
ElectricConductanceDimension = "electrical conductance"
|
||||
MagneticFluxDimension = "magnetic flux"
|
||||
MagneticFieldDimension = "Magnetic field"
|
||||
InductanceDimension = "Inductance"
|
||||
CatalyticActivityDimension = "Catalytic activity"
|
||||
SurfaceDimension = "Surface"
|
||||
VolumeDimension = "Volume"
|
||||
SpeedDimension = "Speed"
|
||||
|
||||
@@ -17,4 +17,28 @@ FactorizedForm = "Forma factorizada"
|
||||
Discriminant = "Discriminante"
|
||||
OnlyRoot = "Raíz"
|
||||
FirstRoot = "Primera raíz"
|
||||
SecondRoot = "Segunda raíz"
|
||||
SecondRoot = "Segunda raíz"
|
||||
TimeDimension = "Tiempo"
|
||||
DistanceDimension = "Distancia"
|
||||
MassDimension = "Masa"
|
||||
CurrentDimension = "Correr"
|
||||
TemperatureDimension = "La temperatura"
|
||||
AmountOfSubstanceDimension = "cantidad de materia"
|
||||
LuminousIntensityDimension = "Intensidad de luz"
|
||||
FrequencyDimension = "Frecuencia"
|
||||
ForceDimension = "Fuerza"
|
||||
PressureDimension = "Presión"
|
||||
EnergyDimension = "Energía"
|
||||
PowerDimension = "Potencia"
|
||||
ElectricChargeDimension = "Carga eléctrica"
|
||||
ElectricPotentialDimension = "Potencial eléctrico"
|
||||
ElectricCapacitanceDimension = "Capacidad eléctrica"
|
||||
ElectricResistanceDimension = "Resistencia eléctrica"
|
||||
ElectricConductanceDimension = "conductancia eléctrica"
|
||||
MagneticFluxDimension = "flujo magnético"
|
||||
MagneticFieldDimension = "Campo magnético"
|
||||
InductanceDimension = "Inductancia"
|
||||
CatalyticActivityDimension = "Actividad catalítica"
|
||||
SurfaceDimension = "Superficie"
|
||||
VolumeDimension = "Volumen"
|
||||
SpeedDimension = "Velocidad"
|
||||
|
||||
@@ -17,4 +17,28 @@ FactorizedForm = "Forme factorisée"
|
||||
Discriminant = "Discriminant"
|
||||
OnlyRoot = "Racine"
|
||||
FirstRoot = "Première racine"
|
||||
SecondRoot = "Seconde racine"
|
||||
SecondRoot = "Seconde racine"
|
||||
TimeDimension = "Temps"
|
||||
DistanceDimension = "Distance"
|
||||
MassDimension = "Masse"
|
||||
CurrentDimension = "Courant"
|
||||
TemperatureDimension = "Température"
|
||||
AmountOfSubstanceDimension = "Quantité de matière"
|
||||
LuminousIntensityDimension = "Intensité lumineuse"
|
||||
FrequencyDimension = "Fréquence"
|
||||
ForceDimension = "Force"
|
||||
PressureDimension = "Pression"
|
||||
EnergyDimension = "Énergie"
|
||||
PowerDimension = "Puissance"
|
||||
ElectricChargeDimension = "Charge électrique"
|
||||
ElectricPotentialDimension = "Potentiel électrique"
|
||||
ElectricCapacitanceDimension = "Capacité électrique"
|
||||
ElectricResistanceDimension = "Résistance électrique"
|
||||
ElectricConductanceDimension = "Conductance électrique"
|
||||
MagneticFluxDimension = "Flux magnétique"
|
||||
MagneticFieldDimension = "Champ magnétique"
|
||||
InductanceDimension = "Inductance"
|
||||
CatalyticActivityDimension = "Activité catalytique"
|
||||
SurfaceDimension = "Surface"
|
||||
VolumeDimension = "Volume"
|
||||
SpeedDimension = "Vitesse"
|
||||
@@ -17,4 +17,28 @@ FactorizedForm = "Factorizált forma"
|
||||
Discriminant = "Discriminant"
|
||||
OnlyRoot = "Gyökér"
|
||||
FirstRoot = "Első gyökér"
|
||||
SecondRoot = "Második gyökér"
|
||||
SecondRoot = "Második gyökér"
|
||||
TimeDimension = "Idő"
|
||||
DistanceDimension = "Távolság"
|
||||
MassDimension = "Tömeg"
|
||||
CurrentDimension = "Futó"
|
||||
TemperatureDimension = "Hőfok"
|
||||
AmountOfSubstanceDimension = "Az anyag mennyisége"
|
||||
LuminousIntensityDimension = "Fény intenzitása"
|
||||
FrequencyDimension = "Frekvencia"
|
||||
ForceDimension = "Erő"
|
||||
PressureDimension = "Nyomás"
|
||||
EnergyDimension = "Energia"
|
||||
PowerDimension = "Erős"
|
||||
ElectricChargeDimension = "Elektromos töltő"
|
||||
ElectricPotentialDimension = "Elektromos potenciál"
|
||||
ElectricCapacitanceDimension = "Elektromos kapacitás"
|
||||
ElectricResistanceDimension = "Elektromos ellenállás"
|
||||
ElectricConductanceDimension = "elektromos vezetőképesség"
|
||||
MagneticFluxDimension = "mágneses fluxus"
|
||||
MagneticFieldDimension = "Mágneses mező"
|
||||
InductanceDimension = "Induktivitás"
|
||||
CatalyticActivityDimension = "Katalitikus aktivitás"
|
||||
SurfaceDimension = "Felület"
|
||||
VolumeDimension = "Hangerő"
|
||||
SpeedDimension = "Sebesség"
|
||||
|
||||
@@ -17,4 +17,28 @@ FactorizedForm = "Forma fattorizzata"
|
||||
Discriminant = "Discriminante"
|
||||
OnlyRoot = "Radice"
|
||||
FirstRoot = "Prima radice"
|
||||
SecondRoot = "Seconda radice"
|
||||
SecondRoot = "Seconda radice"
|
||||
TimeDimension = "Volta"
|
||||
DistanceDimension = "Distanza"
|
||||
MassDimension = "Messa"
|
||||
CurrentDimension = "In esecuzione"
|
||||
TemperatureDimension = "Temperatura"
|
||||
AmountOfSubstanceDimension = "Quantità di materia"
|
||||
LuminousIntensityDimension = "Intensità luminosa"
|
||||
FrequencyDimension = "Frequenza"
|
||||
ForceDimension = "Forza"
|
||||
PressureDimension = "Pressione"
|
||||
EnergyDimension = "Energia"
|
||||
PowerDimension = "Potere"
|
||||
ElectricChargeDimension = "Carica elettrica"
|
||||
ElectricPotentialDimension = "Potenziale elettrico"
|
||||
ElectricCapacitanceDimension = "Capacità elettrica"
|
||||
ElectricResistanceDimension = "Resistenza elettrica"
|
||||
ElectricConductanceDimension = "conduttanza elettrica"
|
||||
MagneticFluxDimension = "flusso magnetico"
|
||||
MagneticFieldDimension = "Campo magnetico"
|
||||
InductanceDimension = "Induttanza"
|
||||
CatalyticActivityDimension = "Attività catalitica"
|
||||
SurfaceDimension = "Superficie"
|
||||
VolumeDimension = "Volume"
|
||||
SpeedDimension = "Velocità"
|
||||
|
||||
@@ -17,4 +17,28 @@ FactorizedForm = "Factorized vorm"
|
||||
Discriminant = "Discriminant"
|
||||
OnlyRoot = "Wortel"
|
||||
FirstRoot = "Eerste wortel"
|
||||
SecondRoot = "Tweede wortel"
|
||||
SecondRoot = "Tweede wortel"
|
||||
TimeDimension = "Tijd"
|
||||
DistanceDimension = "Afstand"
|
||||
MassDimension = "Massa"
|
||||
CurrentDimension = "Rennen"
|
||||
TemperatureDimension = "Temperatuur"
|
||||
AmountOfSubstanceDimension = "Hoeveelheid materie"
|
||||
LuminousIntensityDimension = "Lichtsterkte"
|
||||
FrequencyDimension = "Frequentie"
|
||||
ForceDimension = "Kracht"
|
||||
PressureDimension = "Druk"
|
||||
EnergyDimension = "Energie"
|
||||
PowerDimension = "Kracht"
|
||||
ElectricChargeDimension = "Elektrische lading"
|
||||
ElectricPotentialDimension = "elektrische potentiaal"
|
||||
ElectricCapacitanceDimension = "elektrische capaciteit:"
|
||||
ElectricResistanceDimension = "Elektrische weerstand"
|
||||
ElectricConductanceDimension = "elektrische geleiding:"
|
||||
MagneticFluxDimension = "magnetische flux"
|
||||
MagneticFieldDimension = "Magnetisch veld"
|
||||
InductanceDimension = "Inductie"
|
||||
CatalyticActivityDimension = "Katalytische activiteit"
|
||||
SurfaceDimension = "Oppervlak"
|
||||
VolumeDimension = "Volume"
|
||||
SpeedDimension = "Snelheid"
|
||||
|
||||
@@ -17,4 +17,28 @@ FactorizedForm = "Factorized form"
|
||||
Discriminant = "Discriminante"
|
||||
OnlyRoot = "Raiz"
|
||||
FirstRoot = "Primeira raiz"
|
||||
SecondRoot = "Segunda raiz"
|
||||
SecondRoot = "Segunda raiz"
|
||||
TimeDimension = "Tempo"
|
||||
DistanceDimension = "Distância"
|
||||
MassDimension = "Massa"
|
||||
CurrentDimension = "Corrida"
|
||||
TemperatureDimension = "Temperatura"
|
||||
AmountOfSubstanceDimension = "Quantidade de matéria"
|
||||
LuminousIntensityDimension = "Intensidade da luz"
|
||||
FrequencyDimension = "Frequência"
|
||||
ForceDimension = "Força"
|
||||
PressureDimension = "Pressão"
|
||||
EnergyDimension = "Energia"
|
||||
PowerDimension = "Poderoso"
|
||||
ElectricChargeDimension = "Carga elétrica"
|
||||
ElectricPotentialDimension = "Potencial elétrico"
|
||||
ElectricCapacitanceDimension = "Capacidade elétrica"
|
||||
ElectricResistanceDimension = "Resistência elétrica"
|
||||
ElectricConductanceDimension = "condutância elétrica"
|
||||
MagneticFluxDimension = "fluxo magnético"
|
||||
MagneticFieldDimension = "Campo magnético"
|
||||
InductanceDimension = "Indutância"
|
||||
CatalyticActivityDimension = "Atividade catalítica"
|
||||
SurfaceDimension = "Superfície"
|
||||
VolumeDimension = "Volume"
|
||||
SpeedDimension = "Velocidade"
|
||||
|
||||
Reference in New Issue
Block a user