Added support for fractional inch user setting.

This commit is contained in:
hokieengr
2018-09-15 18:10:05 -04:00
committed by wmayer
parent b102e15569
commit 77060a75a6
5 changed files with 28 additions and 5 deletions

View File

@@ -44,6 +44,10 @@
using namespace Base;
// ====== Static attributes =========================
int QuantityFormat::defaultDenominator = 8; // for 1/8"
QuantityFormat::QuantityFormat()
: option(static_cast<NumberOption>(OmitGroupSeparator | RejectGroupSeparator))
, format(Fixed)

View File

@@ -52,6 +52,19 @@ struct QuantityFormat {
NumberFormat format;
int precision;
// Default denominator of minimum fractional inch. Only used in certain
// schemas.
static int defaultDenominator; // i.e 8 for 1/8"
static inline int getDenominator() {
return defaultDenominator;
}
static inline void setDenominator(int denom)
{
defaultDenominator = denom;
}
QuantityFormat();
inline char toFormat() const {
switch (format) {

View File

@@ -229,10 +229,8 @@ QString UnitsSchemaImperialBuilding::schemaTranslate(const Quantity &quant, doub
int a,b,d; // used to compute greatest common denominator
int tmp; // temporary variable for GCD
// TEMPORARY: This will be replaced by a user setting when time permits.
// For now, it will be hardcoded to emulate the previous (1/8")
// behavior.
minden = 8; // 1/8"
// Get the current user specified minimum denominator
minden = Base::QuantityFormat::getDenominator();
// Compute and round the total number of fractional units
ntot = (int)std::round(totalInches * (double)minden);