Added support for fractional inch user setting.
This commit is contained in:
@@ -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)
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user