From 148f4adef0cf6dbd196c8003a3103ab3593113c2 Mon Sep 17 00:00:00 2001 From: Rexbas Date: Sat, 23 Sep 2023 22:30:42 +0200 Subject: [PATCH] Gui: Add rotation center indicator color, transparency and size preferences --- .../PreferencePages/DlgSettingsNavigation.cpp | 17 ++- .../PreferencePages/DlgSettingsNavigation.ui | 116 ++++++++++++++---- src/Gui/View3DInventorViewer.cpp | 17 ++- 3 files changed, 122 insertions(+), 28 deletions(-) diff --git a/src/Gui/PreferencePages/DlgSettingsNavigation.cpp b/src/Gui/PreferencePages/DlgSettingsNavigation.cpp index ee65c0d091..758a6c54c2 100644 --- a/src/Gui/PreferencePages/DlgSettingsNavigation.cpp +++ b/src/Gui/PreferencePages/DlgSettingsNavigation.cpp @@ -58,6 +58,7 @@ DlgSettingsNavigation::DlgSettingsNavigation(QWidget* parent) { ui->setupUi(this); ui->naviCubeBaseColor->setAllowTransparency(true); + ui->rotationCenterColor->setAllowTransparency(true); retranslate(); } @@ -84,7 +85,8 @@ void DlgSettingsNavigation::saveSettings() ui->checkBoxZoomAtCursor->onSave(); ui->checkBoxInvertZoom->onSave(); ui->checkBoxDisableTilt->onSave(); - ui->checkBoxShowRotationCenter->onSave(); + ui->rotationCenterSize->onSave(); + ui->rotationCenterColor->onSave(); ui->spinBoxZoomStep->onSave(); ui->checkBoxUseAutoRotation->onSave(); ui->qspinNewDocScale->onSave(); @@ -97,6 +99,9 @@ void DlgSettingsNavigation::saveSettings() bool showNaviCube = ui->groupBoxNaviCube->isChecked(); hGrp->SetBool("ShowNaviCube", showNaviCube); + bool showRotationCenter = ui->groupBoxRotationCenter->isChecked(); + hGrp->SetBool("ShowRotationCenter", showRotationCenter); + QVariant camera = ui->comboNewDocView->itemData(ui->comboNewDocView->currentIndex(), Qt::UserRole); hGrp->SetASCII("NewDocumentCameraOrientation", (const char*)camera.toByteArray()); @@ -110,7 +115,7 @@ void DlgSettingsNavigation::saveSettings() hGrp = App::GetApplication().GetParameterGroupByPath( "User parameter:BaseApp/Preferences/NaviCube"); if (ui->naviCubeFontName->currentIndex()) { - hGrp->SetASCII("FontString", ui->naviCubeFontName->currentText().toLatin1()); + hGrp->SetASCII("FontString", ui->naviCubeFontName->currentText().toLatin1()); } else { hGrp->RemoveASCII("FontString"); } @@ -121,7 +126,8 @@ void DlgSettingsNavigation::loadSettings() ui->checkBoxZoomAtCursor->onRestore(); ui->checkBoxInvertZoom->onRestore(); ui->checkBoxDisableTilt->onRestore(); - ui->checkBoxShowRotationCenter->onRestore(); + ui->rotationCenterSize->onRestore(); + ui->rotationCenterColor->onRestore(); ui->spinBoxZoomStep->onRestore(); ui->checkBoxUseAutoRotation->onRestore(); ui->qspinNewDocScale->onRestore(); @@ -147,6 +153,9 @@ void DlgSettingsNavigation::loadSettings() bool showNaviCube = hGrp->GetBool("ShowNaviCube", true); ui->groupBoxNaviCube->setChecked(showNaviCube); + bool showRotationCenter = hGrp->GetBool("ShowRotationCenter", true); + ui->groupBoxRotationCenter->setChecked(showRotationCenter); + ui->comboNewDocView->addItem(tr("Isometric"), QByteArray("Isometric")); ui->comboNewDocView->addItem(tr("Dimetric"), QByteArray("Dimetric")); ui->comboNewDocView->addItem(tr("Trimetric"), QByteArray("Trimetric")); @@ -182,7 +191,7 @@ void DlgSettingsNavigation::loadSettings() QStringList familyNames = QFontDatabase::families(QFontDatabase::Any); #endif ui->naviCubeFontName->addItems(familyNames); - + hGrp = App::GetApplication().GetParameterGroupByPath( "User parameter:BaseApp/Preferences/NaviCube"); int indexFamilyNames = familyNames.indexOf( diff --git a/src/Gui/PreferencePages/DlgSettingsNavigation.ui b/src/Gui/PreferencePages/DlgSettingsNavigation.ui index c2c33a3370..6ccab19a45 100644 --- a/src/Gui/PreferencePages/DlgSettingsNavigation.ui +++ b/src/Gui/PreferencePages/DlgSettingsNavigation.ui @@ -6,8 +6,8 @@ 0 0 - 432 - 423 + 484 + 586 @@ -229,6 +229,99 @@ + + + + Rotation center indicator + + + true + + + + + + Sphere size + + + + + + + Color and transparency + + + + + + + + 60 + 16777215 + + + + The size of the rotation center indicator + + + 1 + + + 1.0 + + + 100.0 + + + 0.5 + + + 5.0 + + + RotationCenterSize + + + View + + + + + + + The color of the rotation center indicator + + + + 255 + 0 + 0 + + + + RotationCenterColor + + + View + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + @@ -615,25 +708,6 @@ Mouse tilting is not disabled by this setting. - - - - Show the rotation center when dragging. - - - Enable rotation center indication - - - true - - - ShowRotationCenter - - - View - - - diff --git a/src/Gui/View3DInventorViewer.cpp b/src/Gui/View3DInventorViewer.cpp index 54736ed640..ee2a800766 100644 --- a/src/Gui/View3DInventorViewer.cpp +++ b/src/Gui/View3DInventorViewer.cpp @@ -1317,6 +1317,17 @@ void View3DInventorViewer::showRotationCenter(bool show) } if (!rotationCenterGroup) { + float size = App::GetApplication() + .GetParameterGroupByPath("User parameter:BaseApp/Preferences/View") + ->GetFloat("RotationCenterSize", 5.0); + + unsigned long rotationCenterColor = + App::GetApplication() + .GetParameterGroupByPath("User parameter:BaseApp/Preferences/View") + ->GetUnsigned("RotationCenterColor", 4278190131); + + QColor color = App::Color::fromPackedRGBA(rotationCenterColor); + rotationCenterGroup = new SoSkipBoundingGroup(); auto sphere = new SoSphere(); @@ -1332,8 +1343,8 @@ void View3DInventorViewer::showRotationCenter(bool show) complexity->value = 1; auto material = new SoMaterial(); - material->emissiveColor = SbColor(1, 0, 0); - material->transparency = 0.8F; + material->emissiveColor = SbColor(color.redF(), color.greenF(), color.blueF()); + material->transparency = 1.0F - color.alphaF(); auto translation = new SoTranslation(); translation->translation.setValue(center); @@ -1345,7 +1356,7 @@ void View3DInventorViewer::showRotationCenter(bool show) auto scaledSphere = new SoShapeScale(); scaledSphere->setPart("shape", annotation); - scaledSphere->scaleFactor = 4.0; + scaledSphere->scaleFactor = size; rotationCenterGroup->addChild(translation); rotationCenterGroup->addChild(hidden);