Merge pull request #10790 from Rexbas/rotation-center-preferences

Gui: Add rotation center indicator color, transparency and size preferences
This commit is contained in:
Yorik van Havre
2023-09-26 11:01:19 +02:00
committed by GitHub
3 changed files with 120 additions and 26 deletions

View File

@@ -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->checkBoxNavigationAnimations->onSave();
ui->spinBoxAnimationDuration->onSave();
@@ -98,6 +100,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());
@@ -122,7 +127,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->checkBoxNavigationAnimations->onRestore();
ui->spinBoxAnimationDuration->onRestore();
@@ -149,6 +155,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"));

View File

@@ -6,8 +6,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>432</width>
<height>423</height>
<width>484</width>
<height>586</height>
</rect>
</property>
<property name="windowTitle">
@@ -229,6 +229,99 @@
</layout>
</widget>
</item>
<item>
<widget class="QGroupBox" name="groupBoxRotationCenter">
<property name="title">
<string>Rotation center indicator</string>
</property>
<property name="checkable">
<bool>true</bool>
</property>
<layout class="QGridLayout" name="gridLayout_3">
<item row="0" column="0">
<widget class="QLabel" name="sizeLabelRotationCenter">
<property name="text">
<string>Sphere size</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="colorLabelRotationCenter">
<property name="text">
<string>Color and transparency</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="Gui::PrefDoubleSpinBox" name="rotationCenterSize">
<property name="maximumSize">
<size>
<width>60</width>
<height>16777215</height>
</size>
</property>
<property name="toolTip">
<string>The size of the rotation center indicator</string>
</property>
<property name="decimals">
<number>1</number>
</property>
<property name="minimum">
<float>1.0</float>
</property>
<property name="maximum">
<float>100.0</float>
</property>
<property name="singleStep">
<float>0.5</float>
</property>
<property name="value">
<float>5.0</float>
</property>
<property name="prefEntry" stdset="0">
<cstring>RotationCenterSize</cstring>
</property>
<property name="prefPath" stdset="0">
<cstring>View</cstring>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="Gui::PrefColorButton" name="rotationCenterColor">
<property name="toolTip">
<string>The color of the rotation center indicator</string>
</property>
<property name="color" stdset="0">
<color alpha="51">
<red>255</red>
<green>0</green>
<blue>0</blue>
</color>
</property>
<property name="prefEntry" stdset="0">
<cstring>RotationCenterColor</cstring>
</property>
<property name="prefPath" stdset="0">
<cstring>View</cstring>
</property>
</widget>
</item>
<item row="0" column="2">
<spacer name="horizontalSpacer_4">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QGroupBox" name="GroupBox12">
<property name="enabled">
@@ -679,25 +772,6 @@ Mouse tilting is not disabled by this setting.</string>
</property>
</widget>
</item>
<item row="9" column="0">
<widget class="Gui::PrefCheckBox" name="checkBoxShowRotationCenter">
<property name="toolTip">
<string>Show the rotation center when dragging.</string>
</property>
<property name="text">
<string>Enable rotation center indication</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
<property name="prefEntry" stdset="0">
<cstring>ShowRotationCenter</cstring>
</property>
<property name="prefPath" stdset="0">
<cstring>View</cstring>
</property>
</widget>
</item>
</layout>
</widget>
</item>

View File

@@ -1319,6 +1319,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<QColor>(rotationCenterColor);
rotationCenterGroup = new SoSkipBoundingGroup();
auto sphere = new SoSphere();
@@ -1334,8 +1345,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);
@@ -1347,7 +1358,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);