From 00a11a63665016c8522e202a182143a5bb8c26d9 Mon Sep 17 00:00:00 2001 From: hokieengr Date: Wed, 12 Sep 2018 13:52:06 -0400 Subject: [PATCH] Added option to select minimum fractional inch displayed Load/save operation complete. Not yet integrated with the display code. Also would like to disable option when non supported (those not using fractional inches) are selected. --- src/Gui/DlgSettingsUnits.ui | 121 +++++++++++++++++++++++--------- src/Gui/DlgSettingsUnitsImp.cpp | 10 +++ 2 files changed, 97 insertions(+), 34 deletions(-) diff --git a/src/Gui/DlgSettingsUnits.ui b/src/Gui/DlgSettingsUnits.ui index 4d74ec8bf2..62183c6ae8 100644 --- a/src/Gui/DlgSettingsUnits.ui +++ b/src/Gui/DlgSettingsUnits.ui @@ -20,6 +20,40 @@ Units settings + + + + Qt::Vertical + + + + 20 + 79 + + + + + + + + + + Number of decimals: + + + + + + + 1 + + + 12 + + + + + @@ -70,28 +104,7 @@ - - - - - - Number of decimals: - - - - - - - 1 - - - 12 - - - - - - + @@ -114,18 +127,58 @@ - - - - Qt::Vertical - - - - 20 - 79 - - - + + + + + + Minimum fractional inch: + + + + + + + <html><head/><body><p>Minimum fractional inch to display.</p></body></html> + + + + 1/2" + + + + + 1/4" + + + + + 1/8" + + + + + 1/16" + + + + + 1/32" + + + + + 1/64" + + + + + 1/128" + + + + + diff --git a/src/Gui/DlgSettingsUnitsImp.cpp b/src/Gui/DlgSettingsUnitsImp.cpp index 5022bfb5f5..7b735f7886 100644 --- a/src/Gui/DlgSettingsUnitsImp.cpp +++ b/src/Gui/DlgSettingsUnitsImp.cpp @@ -80,7 +80,16 @@ void DlgSettingsUnitsImp::saveSettings() ("User parameter:BaseApp/Preferences/Units"); hGrp->SetInt("UserSchema", ui->comboBox_ViewSystem->currentIndex()); hGrp->SetInt("Decimals", ui->spinBoxDecimals->value()); + hGrp->SetInt("FracInchIndex", ui->comboBox_FracInch->currentIndex()); + + // Set actual value Base::UnitsApi::setDecimals(ui->spinBoxDecimals->value()); + + // Convert the combobox index to the its integer denominator. Currently + // with 1/2, 1/4, through 1/128, this little equation directly computes the + // denominator given the combobox integer. + int minFracInch = std::pow(2, ui->comboBox_FracInch->currentIndex() + 1); + hGrp->SetInt("minFracInch", minFracInch); } void DlgSettingsUnitsImp::loadSettings() @@ -89,6 +98,7 @@ void DlgSettingsUnitsImp::loadSettings() ("User parameter:BaseApp/Preferences/Units"); ui->comboBox_ViewSystem->setCurrentIndex(hGrp->GetInt("UserSchema",0)); ui->spinBoxDecimals->setValue(hGrp->GetInt("Decimals",Base::UnitsApi::getDecimals())); + ui->comboBox_FracInch->setCurrentIndex(hGrp->GetInt("FracInchIndex",2)); // 2==1/8" } /**