diff --git a/common/libeval/numeric_evaluator.cpp b/common/libeval/numeric_evaluator.cpp index bb58cb6095..723ab20e32 100644 --- a/common/libeval/numeric_evaluator.cpp +++ b/common/libeval/numeric_evaluator.cpp @@ -62,9 +62,9 @@ NUMERIC_EVALUATOR::NUMERIC_EVALUATOR( EDA_UNITS aUnits, bool aUseMils ) m_defaultUnits = Unit::Inch; break; case EDA_UNITS::MILLIMETRES: - m_defaultUnits = Unit::Metric; + m_defaultUnits = Unit::MM; break; - default:m_defaultUnits = Unit::Metric; + default:m_defaultUnits = Unit::MM; break; } } @@ -239,7 +239,13 @@ NUMERIC_EVALUATOR::Token NUMERIC_EVALUATOR::getToken() if( sizeLeft >= 2 && ch == 'm' && cptr[ 1 ] == 'm' && !isalnum( cptr[ 2 ] )) { m_token.pos += 2; - return Unit::Metric; + return Unit::MM; + } + + if( sizeLeft >= 2 && ch == 'c' && cptr[ 1 ] == 'm' && !isalnum( cptr[ 2 ] )) + { + m_token.pos += 2; + return Unit::CM; } if( sizeLeft >= 2 && ch == 'i' && cptr[ 1 ] == 'n' && !isalnum( cptr[ 2 ] )) @@ -298,13 +304,14 @@ NUMERIC_EVALUATOR::Token NUMERIC_EVALUATOR::getToken() // The factor is assigned to the terminal UNIT. The actual // conversion is done within a parser action. retval.token = UNIT; - if( m_defaultUnits == Unit::Metric ) + if( m_defaultUnits == Unit::MM ) { switch( convertFrom ) { case Unit::Inch :retval.value.dValue = 25.4; break; case Unit::Mil :retval.value.dValue = 25.4 / 1000.0; break; - case Unit::Metric :retval.value.dValue = 1.0; break; + case Unit::MM :retval.value.dValue = 1.0; break; + case Unit::CM :retval.value.dValue = 10.0; break; case Unit::Invalid :break; } } @@ -314,7 +321,8 @@ NUMERIC_EVALUATOR::Token NUMERIC_EVALUATOR::getToken() { case Unit::Inch :retval.value.dValue = 1.0; break; case Unit::Mil :retval.value.dValue = 1.0 / 1000.0; break; - case Unit::Metric :retval.value.dValue = 1.0 / 25.4; break; + case Unit::MM :retval.value.dValue = 1.0 / 25.4; break; + case Unit::CM :retval.value.dValue = 1.0 / 2.54; break; case Unit::Invalid :break; } } @@ -324,7 +332,8 @@ NUMERIC_EVALUATOR::Token NUMERIC_EVALUATOR::getToken() { case Unit::Inch :retval.value.dValue = 1.0 * 1000.0; break; case Unit::Mil :retval.value.dValue = 1.0; break; - case Unit::Metric :retval.value.dValue = 1000.0 / 25.4; break; + case Unit::MM :retval.value.dValue = 1000.0 / 25.4; break; + case Unit::CM :retval.value.dValue = 1000.0 / 2.54; break; case Unit::Invalid :break; } } diff --git a/include/libeval/numeric_evaluator.h b/include/libeval/numeric_evaluator.h index 1b2a065ae9..8b93955e60 100644 --- a/include/libeval/numeric_evaluator.h +++ b/include/libeval/numeric_evaluator.h @@ -93,7 +93,7 @@ namespace numEval class NUMERIC_EVALUATOR { - enum class Unit { Invalid, Metric, Inch, Mil }; + enum class Unit { Invalid, MM, CM, Inch, Mil }; public: NUMERIC_EVALUATOR( EDA_UNITS aUnits, bool aUseMils = false ); @@ -182,4 +182,4 @@ private: }; -#endif /* NUMERIC_EVALUATOR_H_ */ \ No newline at end of file +#endif /* NUMERIC_EVALUATOR_H_ */