Skip to content

Commit

Permalink
Gui: Add rotation center indicator color, transparency and size prefe…
Browse files Browse the repository at this point in the history
…rences
  • Loading branch information
Rexbas committed Sep 23, 2023
1 parent 5a81fcd commit 148f4ad
Show file tree
Hide file tree
Showing 3 changed files with 122 additions and 28 deletions.
17 changes: 13 additions & 4 deletions src/Gui/PreferencePages/DlgSettingsNavigation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ DlgSettingsNavigation::DlgSettingsNavigation(QWidget* parent)
{
ui->setupUi(this);
ui->naviCubeBaseColor->setAllowTransparency(true);
ui->rotationCenterColor->setAllowTransparency(true);
retranslate();
}

Expand All @@ -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();
Expand All @@ -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());
Expand All @@ -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");
}
Expand All @@ -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();
Expand All @@ -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"));
Expand Down Expand Up @@ -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(
Expand Down
116 changes: 95 additions & 21 deletions src/Gui/PreferencePages/DlgSettingsNavigation.ui
Original file line number Diff line number Diff line change
Expand Up @@ -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">
Expand Down Expand Up @@ -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">
Expand Down Expand Up @@ -615,25 +708,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>
Expand Down
17 changes: 14 additions & 3 deletions src/Gui/View3DInventorViewer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<QColor>(rotationCenterColor);

rotationCenterGroup = new SoSkipBoundingGroup();

auto sphere = new SoSphere();
Expand All @@ -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);
Expand All @@ -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);
Expand Down

0 comments on commit 148f4ad

Please sign in to comment.