Seamly2D
Code documentation
VTranslateVars Class Reference

#include <vtranslatevars.h>

Inheritance diagram for VTranslateVars:
Collaboration diagram for VTranslateVars:

Public Member Functions

 VTranslateVars ()
 
virtual ~VTranslateVars () Q_DECL_OVERRIDE
 
bool VariablesFromUser (QString &newFormula, int position, const QString &token, int &bias) const
 VariablesFromUser translate variable to internal look. More...
 
bool PostfixOperatorsFromUser (QString &newFormula, int position, const QString &token, int &bias) const
 PostfixOperatorsFromUser translate postfix operator to internal look. More...
 
bool FunctionsFromUser (QString &newFormula, int position, const QString &token, int &bias) const
 FunctionsFromUser translate function name to internal look. More...
 
bool VariablesToUser (QString &newFormula, int position, const QString &token, int &bias) const
 VariablesToUser translate variable name to user. More...
 
QString InternalVarToUser (const QString &var) const
 
QString PlaceholderToUser (const QString &var) const
 
QString PlaceholderToUserText (QString text) const
 
QString PlaceholderFromUserText (QString text) const
 
QString VarToUser (const QString &var) const
 
QString VarFromUser (const QString &var) const
 
QString PMSystemName (const QString &code) const
 
QString PMSystemAuthor (const QString &code) const
 
QString PMSystemBook (const QString &code) const
 
QString PostfixOperator (const QString &name) const
 
QString FormulaFromUser (const QString &formula, bool osSeparator) const
 FormulaFromUser replace all known tokens in formula to internal look. Also change decimal separator in numbers. More...
 
QString FormulaToUser (const QString &formula, bool osSeparator) const
 FormulaToUser replace all known tokens in formula to user look. Also change decimal separator in numbers. More...
 
virtual void Retranslate () Q_DECL_OVERRIDE
 
QMap< QString, qmu::QmuTranslationgetFunctions () const
 
- Public Member Functions inherited from VTranslateMeasurements
 VTranslateMeasurements ()
 
virtual ~VTranslateMeasurements ()
 
bool MeasurementsFromUser (QString &newFormula, int position, const QString &token, int &bias) const
 MeasurementsFromUser translate measurement to internal look. More...
 
QString MToUser (const QString &measurement) const
 
QString MNumber (const QString &measurement) const
 
QString MFormula (const QString &measurement) const
 
QString guiText (const QString &measurement) const
 
QString Description (const QString &measurement) const
 

Static Public Member Functions

static QString TryFormulaFromUser (const QString &formula, bool osSeparator)
 
static void BiasTokens (int position, int bias, QMap< int, QString > &tokens)
 BiasTokens change position for each token that have position more then "position". More...
 

Private Member Functions

void InitPatternMakingSystems ()
 
void InitVariables ()
 
void InitFunctions ()
 
void InitPostfixOperators ()
 
void InitPlaceholder ()
 
void InitSystem (const QString &code, const qmu::QmuTranslation &name, const qmu::QmuTranslation &author, const qmu::QmuTranslation &book)
 
void CorrectionsPositions (int position, int bias, QMap< int, QString > &tokens, QMap< int, QString > &numbers) const
 CorrectionsPositions correct position tokens in expression after token translation. More...
 

Private Attributes

QMap< QString, qmu::QmuTranslationPMSystemNames
 
QMap< QString, qmu::QmuTranslationPMSystemAuthors
 
QMap< QString, qmu::QmuTranslationPMSystemBooks
 
QMap< QString, qmu::QmuTranslationvariables
 
QMap< QString, qmu::QmuTranslationfunctions
 
QMap< QString, qmu::QmuTranslationpostfixOperators
 
QMap< QString, qmu::QmuTranslationplaceholders
 
QMap< QString, qmu::QmuTranslationstDescriptions
 

Additional Inherited Members

- Protected Attributes inherited from VTranslateMeasurements
QMap< QString, qmu::QmuTranslationm_measurements
 

Detailed Description

Definition at line 60 of file vtranslatevars.h.

Constructor & Destructor Documentation

◆ VTranslateVars()

VTranslateVars::VTranslateVars ( )
explicit

◆ ~VTranslateVars()

VTranslateVars::~VTranslateVars ( )
virtual

Definition at line 91 of file vtranslatevars.cpp.

Member Function Documentation

◆ BiasTokens()

void VTranslateVars::BiasTokens ( int  position,
int  bias,
QMap< int, QString > &  tokens 
)
static

BiasTokens change position for each token that have position more then "position".

Parameters
positiontoken position
biasdifference between original token length and translated
tokensall tokens

Definition at line 553 of file vtranslatevars.cpp.

Referenced by CorrectionsPositions(), and VPattern::replaceNameInFormula().

◆ CorrectionsPositions()

void VTranslateVars::CorrectionsPositions ( int  position,
int  bias,
QMap< int, QString > &  tokens,
QMap< int, QString > &  numbers 
) const
private

CorrectionsPositions correct position tokens in expression after token translation.

Because translated string can have different length compare to original need make correction after each translation. If bias = 0 correction will not happens.

Parameters
positionposition currecnt token in expression
biasdifference between original token length and translated
tokensall tokens
numbersall numbers

Definition at line 534 of file vtranslatevars.cpp.

References BiasTokens().

Referenced by FormulaFromUser(), and FormulaToUser().

◆ FormulaFromUser()

QString VTranslateVars::FormulaFromUser ( const QString &  formula,
bool  osSeparator 
) const

FormulaFromUser replace all known tokens in formula to internal look. Also change decimal separator in numbers.

Parameters
formulaexpression that need translate
Exceptions
qmu::QmuParserErrorin case of a wrong expression
Returns
translated expression

Definition at line 842 of file vtranslatevars.cpp.

References CorrectionsPositions(), FunctionsFromUser(), VTranslateMeasurements::MeasurementsFromUser(), PostfixOperatorsFromUser(), and VariablesFromUser().

◆ FormulaToUser()

QString VTranslateVars::FormulaToUser ( const QString &  formula,
bool  osSeparator 
) const

FormulaToUser replace all known tokens in formula to user look. Also change decimal separator in numbers.

Parameters
formulaexpression that need translate
Returns
translated expression

Definition at line 963 of file vtranslatevars.cpp.

References CorrectionsPositions(), functions, qmu::QmuParserError::GetExpr(), qmu::QmuParserError::GetMsg(), VTranslateMeasurements::m_measurements, postfixOperators, and VariablesToUser().

Referenced by VToolArc::SetVisualization(), VToolArcWithLength::SetVisualization(), and VToolEllipticalArc::SetVisualization().

◆ FunctionsFromUser()

bool VTranslateVars::FunctionsFromUser ( QString &  newFormula,
int  position,
const QString &  token,
int &  bias 
) const

FunctionsFromUser translate function name to internal look.

Parameters
newFormula[in|out] expression to translate
positiontoken position
tokentoken to translate
biashold change of length between translated and origin token string
Returns
true if was found function with same name.

Definition at line 647 of file vtranslatevars.cpp.

References functions.

Referenced by FormulaFromUser(), and VarFromUser().

◆ getFunctions()

QMap< QString, qmu::QmuTranslation > VTranslateVars::getFunctions ( ) const

Definition at line 1104 of file vtranslatevars.cpp.

References functions.

◆ InitFunctions()

void VTranslateVars::InitFunctions ( )
private

◆ InitPatternMakingSystems()

void VTranslateVars::InitPatternMakingSystems ( )
private

◆ InitPlaceholder()

◆ InitPostfixOperators()

void VTranslateVars::InitPostfixOperators ( )
private

Definition at line 473 of file vtranslatevars.cpp.

References cm_Oprt, in_Oprt, mm_Oprt, postfixOperators, and translate.

Referenced by Retranslate(), and VTranslateVars().

◆ InitSystem()

void VTranslateVars::InitSystem ( const QString &  code,
const qmu::QmuTranslation name,
const qmu::QmuTranslation author,
const qmu::QmuTranslation book 
)
private

Definition at line 514 of file vtranslatevars.cpp.

References PMSystemAuthors, PMSystemBooks, and PMSystemNames.

Referenced by InitPatternMakingSystems().

◆ InitVariables()

◆ InternalVarToUser()

QString VTranslateVars::InternalVarToUser ( const QString &  var) const

Definition at line 698 of file vtranslatevars.cpp.

References VariablesToUser().

Referenced by VarToUser().

◆ PlaceholderFromUserText()

QString VTranslateVars::PlaceholderFromUserText ( QString  text) const

Definition at line 743 of file vtranslatevars.cpp.

References placeholders.

◆ PlaceholderToUser()

QString VTranslateVars::PlaceholderToUser ( const QString &  var) const

Definition at line 713 of file vtranslatevars.cpp.

References placeholders.

◆ PlaceholderToUserText()

QString VTranslateVars::PlaceholderToUserText ( QString  text) const

Definition at line 724 of file vtranslatevars.cpp.

References placeholders.

◆ PMSystemAuthor()

QString VTranslateVars::PMSystemAuthor ( const QString &  code) const

Definition at line 816 of file vtranslatevars.cpp.

References PMSystemAuthors.

◆ PMSystemBook()

QString VTranslateVars::PMSystemBook ( const QString &  code) const

Definition at line 822 of file vtranslatevars.cpp.

References PMSystemBooks.

◆ PMSystemName()

QString VTranslateVars::PMSystemName ( const QString &  code) const

Definition at line 810 of file vtranslatevars.cpp.

References PMSystemNames.

◆ PostfixOperator()

QString VTranslateVars::PostfixOperator ( const QString &  name) const

Definition at line 829 of file vtranslatevars.cpp.

References postfixOperators.

◆ PostfixOperatorsFromUser()

bool VTranslateVars::PostfixOperatorsFromUser ( QString &  newFormula,
int  position,
const QString &  token,
int &  bias 
) const

PostfixOperatorsFromUser translate postfix operator to internal look.

Parameters
newFormula[in|out] expression to translate
positiontoken position
tokentoken to translate
biashold change of length between translated and origin token string
Returns
true if was found postfix operator with same name.

Definition at line 622 of file vtranslatevars.cpp.

References postfixOperators.

Referenced by FormulaFromUser(), and VarFromUser().

◆ Retranslate()

◆ TryFormulaFromUser()

QString VTranslateVars::TryFormulaFromUser ( const QString &  formula,
bool  osSeparator 
)
static

Definition at line 943 of file vtranslatevars.cpp.

References qApp.

◆ VarFromUser()

QString VTranslateVars::VarFromUser ( const QString &  var) const

◆ VariablesFromUser()

bool VTranslateVars::VariablesFromUser ( QString &  newFormula,
int  position,
const QString &  token,
int &  bias 
) const

VariablesFromUser translate variable to internal look.

Parameters
newFormula[in|out] expression to translate
positiontoken position
tokentoken to translate
biashold change of length between translated and origin token string
Returns
true if was found variable with same name.

Definition at line 583 of file vtranslatevars.cpp.

References currentLength, currentSeamAllowance, qmu::QmuTranslation::translate(), and variables.

Referenced by FormulaFromUser(), and VarFromUser().

◆ VariablesToUser()

bool VTranslateVars::VariablesToUser ( QString &  newFormula,
int  position,
const QString &  token,
int &  bias 
) const

VariablesToUser translate variable name to user.

Parameters
newFormula[in|out] expression to translate
positiontoken position
tokentoken to translate
biashold change of length between translated and origin token string
Returns
true if was found variable with same name.

Definition at line 672 of file vtranslatevars.cpp.

References currentLength, currentSeamAllowance, and variables.

Referenced by FormulaToUser(), and InternalVarToUser().

◆ VarToUser()

QString VTranslateVars::VarToUser ( const QString &  var) const

Member Data Documentation

◆ functions

QMap<QString, qmu::QmuTranslation> VTranslateVars::functions
private

◆ placeholders

QMap<QString, qmu::QmuTranslation> VTranslateVars::placeholders
private

◆ PMSystemAuthors

QMap<QString, qmu::QmuTranslation> VTranslateVars::PMSystemAuthors
private

Definition at line 99 of file vtranslatevars.h.

Referenced by InitSystem(), PMSystemAuthor(), and Retranslate().

◆ PMSystemBooks

QMap<QString, qmu::QmuTranslation> VTranslateVars::PMSystemBooks
private

Definition at line 100 of file vtranslatevars.h.

Referenced by InitSystem(), PMSystemBook(), and Retranslate().

◆ PMSystemNames

QMap<QString, qmu::QmuTranslation> VTranslateVars::PMSystemNames
private

Definition at line 98 of file vtranslatevars.h.

Referenced by InitSystem(), PMSystemName(), and Retranslate().

◆ postfixOperators

QMap<QString, qmu::QmuTranslation> VTranslateVars::postfixOperators
private

◆ stDescriptions

QMap<QString, qmu::QmuTranslation> VTranslateVars::stDescriptions
private

Definition at line 105 of file vtranslatevars.h.

Referenced by Retranslate().

◆ variables

QMap<QString, qmu::QmuTranslation> VTranslateVars::variables
private

Definition at line 101 of file vtranslatevars.h.

Referenced by InitVariables(), Retranslate(), VariablesFromUser(), and VariablesToUser().


The documentation for this class was generated from the following files: