| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| |
|
| |
|
| | #include <QApplication> |
| | #include <QDoubleSpinBox> |
| | #include <QGridLayout> |
| | #include <memory> |
| |
|
| |
|
| | #include <App/Application.h> |
| | #include <Base/Parameter.h> |
| | #include <Base/Tools.h> |
| | #include <Gui/MainWindow.h> |
| | #include <Gui/View3DSettings.h> |
| | #include <Gui/Navigation/NavigationStyle.h> |
| | #include <Gui/View3DInventor.h> |
| | #include <Gui/View3DInventorViewer.h> |
| |
|
| | #include "DlgSettingsNavigation.h" |
| | #include "ui_DlgSettingsNavigation.h" |
| |
|
| | #include "../ui_MouseButtons.h" |
| |
|
| | using namespace Gui::Dialog; |
| |
|
| | |
| |
|
| | |
| | |
| | |
| | |
| | DlgSettingsNavigation::DlgSettingsNavigation(QWidget* parent) |
| | : PreferencePage(parent) |
| | , ui(new Ui_DlgSettingsNavigation) |
| | , q0(0) |
| | , q1(0) |
| | , q2(0) |
| | , q3(1) |
| | { |
| | ui->setupUi(this); |
| | ui->naviCubeBaseColor->setAllowTransparency(true); |
| | ui->rotationCenterColor->setAllowTransparency(true); |
| | retranslate(); |
| | #if !defined(_USE_3DCONNEXION_SDK) && !defined(SPNAV_FOUND) |
| | ui->legacySpaceMouseDevices->setDisabled(true); |
| | #elif !defined(USE_3DCONNEXION_NAVLIB) |
| | ui->spaceMouseDevice->setHidden(true); |
| | ui->legacySpaceMouseDevices->setHidden(true); |
| | #endif |
| | } |
| |
|
| | |
| | |
| | |
| | DlgSettingsNavigation::~DlgSettingsNavigation() = default; |
| |
|
| | void DlgSettingsNavigation::saveSettings() |
| | { |
| | |
| | |
| | ParameterGrp::handle hGrp = App::GetApplication().GetParameterGroupByPath( |
| | "User parameter:BaseApp/Preferences/View" |
| | ); |
| | QVariant data |
| | = ui->comboNavigationStyle->itemData(ui->comboNavigationStyle->currentIndex(), Qt::UserRole); |
| | hGrp->SetASCII("NavigationStyle", (const char*)data.toByteArray()); |
| |
|
| | int index = ui->comboOrbitStyle->currentIndex(); |
| | hGrp->SetInt("OrbitStyle", index); |
| | index = ui->comboRotationMode->currentIndex(); |
| | hGrp->SetInt("RotationMode", index); |
| |
|
| | ui->checkBoxZoomAtCursor->onSave(); |
| | ui->checkBoxInvertZoom->onSave(); |
| | ui->checkBoxDisableTilt->onSave(); |
| | ui->rotationCenterSize->onSave(); |
| | ui->rotationCenterColor->onSave(); |
| | ui->spinBoxZoomStep->onSave(); |
| | ui->spinBoxAnimationDuration->onSave(); |
| | ui->checkBoxSpinningAnimations->onSave(); |
| | ui->checkBoxEnableLongPressClarifySelection->onSave(); |
| | ui->spinBoxLongPressTimeout->onSave(); |
| | ui->qspinNewDocScale->onSave(); |
| | ui->prefStepByTurn->onSave(); |
| | ui->naviCubeCorner->onSave(); |
| | ui->naviCubeToNearest->onSave(); |
| | ui->prefCubeSize->onSave(); |
| | ui->naviCubeBaseColor->onSave(); |
| | ui->naviCubeInactiveOpacity->onSave(); |
| | ui->legacySpaceMouseDevices->onSave(); |
| | if (property("LegacySpaceMouse").toBool() != ui->legacySpaceMouseDevices->isChecked()) { |
| | requireRestart(); |
| | } |
| |
|
| | bool showNaviCube = ui->groupBoxNaviCube->isChecked(); |
| | hGrp->SetBool("ShowNaviCube", showNaviCube); |
| |
|
| | bool showRotationCenter = ui->groupBoxRotationCenter->isChecked(); |
| | hGrp->SetBool("ShowRotationCenter", showRotationCenter); |
| |
|
| | bool useNavigationAnimations = ui->groupBoxAnimations->isChecked(); |
| | hGrp->SetBool("UseNavigationAnimations", useNavigationAnimations); |
| |
|
| | QVariant camera = ui->comboNewDocView->itemData(ui->comboNewDocView->currentIndex(), Qt::UserRole); |
| | hGrp->SetASCII("NewDocumentCameraOrientation", (const char*)camera.toByteArray()); |
| | if (camera == QByteArray("Custom")) { |
| | ParameterGrp::handle hCustom = hGrp->GetGroup("Custom"); |
| | hCustom->SetFloat("Q0", q0); |
| | hCustom->SetFloat("Q1", q1); |
| | hCustom->SetFloat("Q2", q2); |
| | hCustom->SetFloat("Q3", q3); |
| | } |
| | hGrp = App::GetApplication().GetParameterGroupByPath("User parameter:BaseApp/Preferences/NaviCube"); |
| | if (ui->naviCubeFontName->currentIndex()) { |
| | hGrp->SetASCII("FontString", ui->naviCubeFontName->currentText().toLatin1()); |
| | } |
| | else { |
| | hGrp->RemoveASCII("FontString"); |
| | } |
| | } |
| |
|
| | void DlgSettingsNavigation::loadSettings() |
| | { |
| | ui->checkBoxZoomAtCursor->onRestore(); |
| | ui->checkBoxInvertZoom->onRestore(); |
| | ui->checkBoxDisableTilt->onRestore(); |
| | ui->rotationCenterSize->onRestore(); |
| | ui->rotationCenterColor->onRestore(); |
| | ui->spinBoxZoomStep->onRestore(); |
| | ui->spinBoxAnimationDuration->onRestore(); |
| | ui->checkBoxSpinningAnimations->onRestore(); |
| | ui->checkBoxEnableLongPressClarifySelection->onRestore(); |
| | ui->spinBoxLongPressTimeout->onRestore(); |
| | ui->qspinNewDocScale->onRestore(); |
| | ui->prefStepByTurn->onRestore(); |
| | ui->naviCubeCorner->onRestore(); |
| | ui->naviCubeToNearest->onRestore(); |
| | ui->prefCubeSize->onRestore(); |
| | ui->naviCubeBaseColor->onRestore(); |
| | ui->naviCubeInactiveOpacity->onRestore(); |
| | ui->legacySpaceMouseDevices->onRestore(); |
| | setProperty("LegacySpaceMouse", ui->legacySpaceMouseDevices->isChecked()); |
| |
|
| | ParameterGrp::handle hGrp = App::GetApplication().GetParameterGroupByPath( |
| | "User parameter:BaseApp/Preferences/View" |
| | ); |
| | std::string model |
| | = hGrp->GetASCII("NavigationStyle", CADNavigationStyle::getClassTypeId().getName()); |
| | int index = ui->comboNavigationStyle->findData(QByteArray(model.c_str())); |
| | if (index > -1) { |
| | ui->comboNavigationStyle->setCurrentIndex(index); |
| | } |
| |
|
| | index = hGrp->GetInt("OrbitStyle", int(NavigationStyle::RoundedArcball)); |
| | index = Base::clamp(index, 0, ui->comboOrbitStyle->count() - 1); |
| | ui->comboOrbitStyle->setCurrentIndex(index); |
| |
|
| | index = hGrp->GetInt("RotationMode", 0); |
| | ui->comboRotationMode->setCurrentIndex(index); |
| |
|
| | bool showNaviCube = hGrp->GetBool("ShowNaviCube", true); |
| | ui->groupBoxNaviCube->setChecked(showNaviCube); |
| |
|
| | bool showRotationCenter = hGrp->GetBool("ShowRotationCenter", true); |
| | ui->groupBoxRotationCenter->setChecked(showRotationCenter); |
| |
|
| | bool useNavigationAnimations = hGrp->GetBool("UseNavigationAnimations", true); |
| | ui->groupBoxAnimations->setChecked(useNavigationAnimations); |
| |
|
| | addOrientations(); |
| |
|
| | connect(ui->mouseButton, &QPushButton::clicked, this, &DlgSettingsNavigation::onMouseButtonClicked); |
| |
|
| | |
| |
|
| | |
| | #if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) |
| | QStringList familyNames = QFontDatabase().families(QFontDatabase::Any); |
| | #else |
| | QStringList familyNames = QFontDatabase::families(QFontDatabase::Any); |
| | #endif |
| | ui->naviCubeFontName->addItems(familyNames); |
| |
|
| | hGrp = App::GetApplication().GetParameterGroupByPath("User parameter:BaseApp/Preferences/NaviCube"); |
| | int indexFamilyNames = familyNames.indexOf(QString::fromStdString(hGrp->GetASCII("FontString"))); |
| | ui->naviCubeFontName->setCurrentIndex(indexFamilyNames + 1); |
| | } |
| |
|
| | void DlgSettingsNavigation::addOrientations() |
| | { |
| | ui->comboNewDocView->addItem(tr("Isometric"), QByteArray("Isometric")); |
| | ui->comboNewDocView->addItem(tr("Dimetric"), QByteArray("Dimetric")); |
| | ui->comboNewDocView->addItem(tr("Trimetric"), QByteArray("Trimetric")); |
| | ui->comboNewDocView->addItem(tr("Top"), QByteArray("Top")); |
| | ui->comboNewDocView->addItem(tr("Front"), QByteArray("Front")); |
| | ui->comboNewDocView->addItem(tr("Left"), QByteArray("Left")); |
| | ui->comboNewDocView->addItem(tr("Right"), QByteArray("Right")); |
| | ui->comboNewDocView->addItem(tr("Rear"), QByteArray("Rear")); |
| | ui->comboNewDocView->addItem(tr("Bottom"), QByteArray("Bottom")); |
| | ui->comboNewDocView->addItem(tr("Custom"), QByteArray("Custom")); |
| |
|
| | ParameterGrp::handle hGrp = App::GetApplication().GetParameterGroupByPath( |
| | "User parameter:BaseApp/Preferences/View" |
| | ); |
| | std::string camera = hGrp->GetASCII("NewDocumentCameraOrientation", "Trimetric"); |
| | int index = ui->comboNewDocView->findData(QByteArray(camera.c_str())); |
| | if (index > -1) { |
| | ui->comboNewDocView->setCurrentIndex(index); |
| | } |
| | if (camera == "Custom") { |
| | ParameterGrp::handle hCustom = hGrp->GetGroup("Custom"); |
| | q0 = hCustom->GetFloat("Q0", q0); |
| | q1 = hCustom->GetFloat("Q1", q1); |
| | q2 = hCustom->GetFloat("Q2", q2); |
| | q3 = hCustom->GetFloat("Q3", q3); |
| | } |
| |
|
| | connect( |
| | ui->comboNewDocView, |
| | qOverload<int>(&QComboBox::currentIndexChanged), |
| | this, |
| | &DlgSettingsNavigation::onNewDocViewChanged |
| | ); |
| | } |
| |
|
| | void DlgSettingsNavigation::translateOrientations() |
| | { |
| | ui->comboNewDocView->setItemText(0, tr("Isometric")); |
| | ui->comboNewDocView->setItemText(1, tr("Dimetric")); |
| | ui->comboNewDocView->setItemText(2, tr("Trimetric")); |
| | ui->comboNewDocView->setItemText(3, tr("Top")); |
| | ui->comboNewDocView->setItemText(4, tr("Front")); |
| | ui->comboNewDocView->setItemText(5, tr("Left")); |
| | ui->comboNewDocView->setItemText(6, tr("Right")); |
| | ui->comboNewDocView->setItemText(7, tr("Rear")); |
| | ui->comboNewDocView->setItemText(8, tr("Bottom")); |
| | ui->comboNewDocView->setItemText(9, tr("Custom")); |
| | } |
| |
|
| | void DlgSettingsNavigation::resetSettingsToDefaults() |
| | { |
| | ParameterGrp::handle hGrp; |
| | hGrp = App::GetApplication().GetParameterGroupByPath("User parameter:BaseApp/Preferences/View"); |
| | |
| | hGrp->RemoveASCII("NavigationStyle"); |
| | |
| | hGrp->RemoveInt("OrbitStyle"); |
| | |
| | hGrp->RemoveInt("RotationMode"); |
| | |
| | hGrp->RemoveBool("ShowNaviCube"); |
| | |
| | hGrp->RemoveBool("ShowRotationCenter"); |
| | |
| | hGrp->RemoveBool("UseNavigationAnimations"); |
| | |
| | hGrp->RemoveASCII("NewDocumentCameraOrientation"); |
| |
|
| | hGrp = hGrp->GetGroup("Custom"); |
| | |
| | hGrp->RemoveFloat("Q0"); |
| | |
| | hGrp->RemoveFloat("Q1"); |
| | |
| | hGrp->RemoveFloat("Q2"); |
| | |
| | hGrp->RemoveFloat("Q3"); |
| |
|
| | |
| | PreferencePage::resetSettingsToDefaults(); |
| | } |
| |
|
| | void DlgSettingsNavigation::onMouseButtonClicked() |
| | { |
| | QDialog dlg(this); |
| | Ui_MouseButtons uimb; |
| | uimb.setupUi(&dlg); |
| |
|
| | QVariant data |
| | = ui->comboNavigationStyle->itemData(ui->comboNavigationStyle->currentIndex(), Qt::UserRole); |
| | void* instance = Base::Type::createInstanceByName((const char*)data.toByteArray()); |
| | std::unique_ptr<UserNavigationStyle> ns(static_cast<UserNavigationStyle*>(instance)); |
| | uimb.groupBox->setTitle( |
| | uimb.groupBox->title() + QStringLiteral(" ") + ui->comboNavigationStyle->currentText() |
| | ); |
| | QString descr; |
| | descr = qApp->translate( |
| | (const char*)data.toByteArray(), |
| | ns->mouseButtons(NavigationStyle::SELECTION) |
| | ); |
| | descr.replace(QLatin1String("\n"), QLatin1String("<p>")); |
| | uimb.selectionLabel->setText(QStringLiteral("<b>%1</b>").arg(descr)); |
| | descr = qApp->translate((const char*)data.toByteArray(), ns->mouseButtons(NavigationStyle::PANNING)); |
| | descr.replace(QLatin1String("\n"), QLatin1String("<p>")); |
| | uimb.panningLabel->setText(QStringLiteral("<b>%1</b>").arg(descr)); |
| | descr = qApp->translate( |
| | (const char*)data.toByteArray(), |
| | ns->mouseButtons(NavigationStyle::DRAGGING) |
| | ); |
| | descr.replace(QLatin1String("\n"), QLatin1String("<p>")); |
| | uimb.rotationLabel->setText(QStringLiteral("<b>%1</b>").arg(descr)); |
| | descr = qApp->translate((const char*)data.toByteArray(), ns->mouseButtons(NavigationStyle::ZOOMING)); |
| | descr.replace(QLatin1String("\n"), QLatin1String("<p>")); |
| | uimb.zoomingLabel->setText(QStringLiteral("<b>%1</b>").arg(descr)); |
| | dlg.exec(); |
| | } |
| |
|
| | |
| | |
| | |
| | void DlgSettingsNavigation::changeEvent(QEvent* e) |
| | { |
| | if (e->type() == QEvent::LanguageChange) { |
| | int navigation = ui->comboNavigationStyle->currentIndex(); |
| | int orbit = ui->comboOrbitStyle->currentIndex(); |
| | int corner = ui->naviCubeCorner->currentIndex(); |
| | ui->retranslateUi(this); |
| | retranslate(); |
| | translateOrientations(); |
| | ui->comboNavigationStyle->setCurrentIndex(navigation); |
| | ui->comboOrbitStyle->setCurrentIndex(orbit); |
| | ui->naviCubeCorner->setCurrentIndex(corner); |
| | } |
| | else { |
| | QWidget::changeEvent(e); |
| | } |
| | } |
| |
|
| | void DlgSettingsNavigation::retranslate() |
| | { |
| | ui->comboNavigationStyle->clear(); |
| |
|
| | |
| | std::map<Base::Type, std::string> styles = UserNavigationStyle::getUserFriendlyNames(); |
| | for (const auto& style : styles) { |
| | QByteArray data(style.first.getName()); |
| | QString name = QApplication::translate(style.first.getName(), style.second.c_str()); |
| |
|
| | ui->comboNavigationStyle->addItem(name, data); |
| | } |
| | } |
| |
|
| | void DlgSettingsNavigation::onNewDocViewChanged(int index) |
| | { |
| | QVariant camera = ui->comboNewDocView->itemData(index, Qt::UserRole); |
| | if (camera == QByteArray("Custom")) { |
| | CameraDialog dlg(this); |
| | dlg.setValues(q0, q1, q2, q3); |
| | if (dlg.exec()) { |
| | dlg.getValues(q0, q1, q2, q3); |
| | } |
| | } |
| | } |
| |
|
| | |
| |
|
| | CameraDialog::CameraDialog(QWidget* parent) |
| | : QDialog(parent) |
| | { |
| | this->setWindowTitle(tr("Camera Settings")); |
| |
|
| | QGridLayout* gridLayout; |
| | gridLayout = new QGridLayout(this); |
| |
|
| | QGroupBox* groupBox; |
| | groupBox = new QGroupBox(this); |
| | groupBox->setTitle(tr("Orientation")); |
| | gridLayout->addWidget(groupBox, 0, 0, 1, 1); |
| |
|
| | QDialogButtonBox* buttonBox; |
| | buttonBox = new QDialogButtonBox(this); |
| | buttonBox->setOrientation(Qt::Horizontal); |
| | buttonBox->setStandardButtons(QDialogButtonBox::Cancel | QDialogButtonBox::Ok); |
| | gridLayout->addWidget(buttonBox, 3, 0, 1, 1); |
| |
|
| | QGridLayout* layout; |
| | layout = new QGridLayout(groupBox); |
| |
|
| | |
| | auto label0 = new QLabel(groupBox); |
| | label0->setText(tr("Q0")); |
| | layout->addWidget(label0, 0, 0, 1, 1); |
| |
|
| | sb0 = new QDoubleSpinBox(groupBox); |
| | sb0->setRange(-1, 1); |
| | sb0->setSingleStep(0.1); |
| | layout->addWidget(sb0, 0, 1, 1, 1); |
| |
|
| | |
| | auto label1 = new QLabel(groupBox); |
| | label1->setText(tr("Q1")); |
| | layout->addWidget(label1, 1, 0, 1, 1); |
| |
|
| | sb1 = new QDoubleSpinBox(groupBox); |
| | sb1->setRange(-1, 1); |
| | sb1->setSingleStep(0.1); |
| | layout->addWidget(sb1, 1, 1, 1, 1); |
| |
|
| | |
| | auto label2 = new QLabel(groupBox); |
| | label2->setText(tr("Q2")); |
| | layout->addWidget(label2, 2, 0, 1, 1); |
| |
|
| | sb2 = new QDoubleSpinBox(groupBox); |
| | sb2->setRange(-1, 1); |
| | sb2->setSingleStep(0.1); |
| | layout->addWidget(sb2, 2, 1, 1, 1); |
| |
|
| | |
| | auto label3 = new QLabel(groupBox); |
| | label3->setText(tr("Q3")); |
| | layout->addWidget(label3, 3, 0, 1, 1); |
| |
|
| | sb3 = new QDoubleSpinBox(groupBox); |
| | sb3->setRange(-1, 1); |
| | sb3->setSingleStep(0.1); |
| | layout->addWidget(sb3, 3, 1, 1, 1); |
| |
|
| | auto currentViewButton = new QPushButton(this); |
| | currentViewButton->setText(tr("Current View")); |
| | currentViewButton->setObjectName(QStringLiteral("currentView")); |
| | layout->addWidget(currentViewButton, 4, 1, 2, 1); |
| |
|
| | connect(buttonBox, &QDialogButtonBox::accepted, this, &QDialog::accept); |
| | connect(buttonBox, &QDialogButtonBox::rejected, this, &QDialog::reject); |
| | connect(currentViewButton, &QPushButton::clicked, this, &CameraDialog::onCurrentViewClicked); |
| | } |
| |
|
| | CameraDialog::~CameraDialog() = default; |
| |
|
| | void CameraDialog::setValues(double q0, double q1, double q2, double q3) |
| | { |
| | sb0->setValue(q0); |
| | sb1->setValue(q1); |
| | sb2->setValue(q2); |
| | sb3->setValue(q3); |
| | } |
| |
|
| | void CameraDialog::getValues(double& q0, double& q1, double& q2, double& q3) const |
| | { |
| | q0 = sb0->value(); |
| | q1 = sb1->value(); |
| | q2 = sb2->value(); |
| | q3 = sb3->value(); |
| | } |
| |
|
| | void CameraDialog::onCurrentViewClicked() |
| | { |
| | auto mdi = qobject_cast<View3DInventor*>(getMainWindow()->activeWindow()); |
| | if (mdi) { |
| | SbRotation rot = mdi->getViewer()->getCameraOrientation(); |
| | const float* q = rot.getValue(); |
| | sb0->setValue(q[0]); |
| | sb1->setValue(q[1]); |
| | sb2->setValue(q[2]); |
| | sb3->setValue(q[3]); |
| | } |
| | } |
| |
|
| | #include "moc_DlgSettingsNavigation.cpp" |
| |
|