From c67f3261749c158a8fc0d705734bb47b752d63ca Mon Sep 17 00:00:00 2001 From: wmayer Date: Tue, 28 Oct 2014 19:27:23 +0100 Subject: [PATCH] + split STEP and IGES settings into separate pages, handle Brep mode of IGES format --- src/Mod/Part/App/AppPart.cpp | 22 +++- src/Mod/Part/Gui/AppPartGui.cpp | 4 +- src/Mod/Part/Gui/CMakeLists.txt | 4 + src/Mod/Part/Gui/DlgImportExportIges.ui | 89 ++++++++++++++++ src/Mod/Part/Gui/DlgImportExportStep.ui | 82 +++++++++++++++ src/Mod/Part/Gui/DlgSettingsGeneral.cpp | 133 +++++++++++++++++++++--- src/Mod/Part/Gui/DlgSettingsGeneral.h | 36 +++++++ src/Mod/Part/Gui/DlgSettingsGeneral.ui | 58 +---------- 8 files changed, 352 insertions(+), 76 deletions(-) create mode 100644 src/Mod/Part/Gui/DlgImportExportIges.ui create mode 100644 src/Mod/Part/Gui/DlgImportExportStep.ui diff --git a/src/Mod/Part/App/AppPart.cpp b/src/Mod/Part/App/AppPart.cpp index 03648c5da046..596cceb246e5 100644 --- a/src/Mod/Part/App/AppPart.cpp +++ b/src/Mod/Part/App/AppPart.cpp @@ -287,18 +287,32 @@ void PartExport initPart() // set the user-defined units Base::Reference hGrp = App::GetApplication().GetUserParameter() .GetGroup("BaseApp")->GetGroup("Preferences")->GetGroup("Mod/Part"); - int unit = hGrp->GetInt("Unit", 0); - switch (unit) { + int value = Interface_Static::IVal("write.iges.brep.mode"); + bool brep = hGrp->GetBool("BrepMode", value > 0); + Interface_Static::SetIVal("write.iges.brep.mode",brep ? 1 : 0); + + int unitIges = hGrp->GetInt("UnitIges", 0); + switch (unitIges) { case 1: Interface_Static::SetCVal("write.iges.unit","M"); - Interface_Static::SetCVal("write.step.unit","M"); break; case 2: Interface_Static::SetCVal("write.iges.unit","IN"); - Interface_Static::SetCVal("write.step.unit","IN"); break; default: Interface_Static::SetCVal("write.iges.unit","MM"); + break; + } + + int unitStep = hGrp->GetInt("UnitStep", 0); + switch (unitStep) { + case 1: + Interface_Static::SetCVal("write.step.unit","M"); + break; + case 2: + Interface_Static::SetCVal("write.step.unit","IN"); + break; + default: Interface_Static::SetCVal("write.step.unit","MM"); break; } diff --git a/src/Mod/Part/Gui/AppPartGui.cpp b/src/Mod/Part/Gui/AppPartGui.cpp index 2a74641e6c1b..d25ce6bdd9e9 100644 --- a/src/Mod/Part/Gui/AppPartGui.cpp +++ b/src/Mod/Part/Gui/AppPartGui.cpp @@ -5,7 +5,7 @@ * published by the Free Software Foundation; either version 2 of the * * License, or (at your option) any later version. * * for detail see the LICENCE text file. * - * J�rgen Riegel 2002 * + * Juergen Riegel 2002 * * * ***************************************************************************/ @@ -160,6 +160,8 @@ void PartGuiExport initPartGui() // register preferences pages (void)new Gui::PrefPageProducer ( QT_TRANSLATE_NOOP("QObject","Part design") ); (void)new Gui::PrefPageProducer ( QT_TRANSLATE_NOOP("QObject","Part design") ); + (void)new Gui::PrefPageProducer ( QT_TRANSLATE_NOOP("QObject","Import-Export") ); + (void)new Gui::PrefPageProducer ( QT_TRANSLATE_NOOP("QObject","Import-Export") ); (void)new Gui::PrefPageProducer ( QT_TRANSLATE_NOOP("QObject","Display") ); Gui::ViewProviderBuilder::add( Part::PropertyPartShape::getClassTypeId(), diff --git a/src/Mod/Part/Gui/CMakeLists.txt b/src/Mod/Part/Gui/CMakeLists.txt index 7ee81428b635..8d845f2ddb6f 100644 --- a/src/Mod/Part/Gui/CMakeLists.txt +++ b/src/Mod/Part/Gui/CMakeLists.txt @@ -59,6 +59,8 @@ set(PartGui_UIC_SRCS DlgBooleanOperation.ui DlgExtrusion.ui DlgFilletEdges.ui + DlgImportExportIges.ui + DlgImportExportStep.ui DlgPartBox.ui DlgPartCylinder.ui DlgPartImportIges.ui @@ -99,6 +101,8 @@ SET(PartGui_SRCS DlgFilletEdges.cpp DlgFilletEdges.h DlgFilletEdges.ui + DlgImportExportIges.ui + DlgImportExportStep.ui DlgPartBox.ui DlgPartBoxImp.cpp DlgPartBoxImp.h diff --git a/src/Mod/Part/Gui/DlgImportExportIges.ui b/src/Mod/Part/Gui/DlgImportExportIges.ui new file mode 100644 index 000000000000..8493aaf26a58 --- /dev/null +++ b/src/Mod/Part/Gui/DlgImportExportIges.ui @@ -0,0 +1,89 @@ + + + PartGui::DlgImportExportIges + + + + 0 + 0 + 445 + 187 + + + + IGES + + + + + + Export + + + + + + Units for export of IGES + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + Millimeter + + + + + Meter + + + + + Inch + + + + + + + + Enable B-REP mode + + + + + + + + + + Qt::Vertical + + + + 20 + 82 + + + + + + + + + diff --git a/src/Mod/Part/Gui/DlgImportExportStep.ui b/src/Mod/Part/Gui/DlgImportExportStep.ui new file mode 100644 index 000000000000..245db88af3c3 --- /dev/null +++ b/src/Mod/Part/Gui/DlgImportExportStep.ui @@ -0,0 +1,82 @@ + + + PartGui::DlgImportExportStep + + + + 0 + 0 + 445 + 187 + + + + STEP + + + + + + Export + + + + + + Units for export of STEP + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + Millimeter + + + + + Meter + + + + + Inch + + + + + + + + + + + Qt::Vertical + + + + 20 + 82 + + + + + + + + + diff --git a/src/Mod/Part/Gui/DlgSettingsGeneral.cpp b/src/Mod/Part/Gui/DlgSettingsGeneral.cpp index 0f5555c646b2..c008ddfc7dba 100644 --- a/src/Mod/Part/Gui/DlgSettingsGeneral.cpp +++ b/src/Mod/Part/Gui/DlgSettingsGeneral.cpp @@ -30,6 +30,8 @@ #include "DlgSettingsGeneral.h" #include "ui_DlgSettingsGeneral.h" +#include "ui_DlgImportExportIges.h" +#include "ui_DlgImportExportStep.h" using namespace PartGui; @@ -50,47 +52,148 @@ DlgSettingsGeneral::~DlgSettingsGeneral() } void DlgSettingsGeneral::saveSettings() +{ + ui->checkBooleanCheck->onSave(); + ui->checkBooleanRefine->onSave(); + ui->checkSketchBaseRefine->onSave(); + ui->checkObjectNaming->onSave(); +} + +void DlgSettingsGeneral::loadSettings() +{ + ui->checkBooleanCheck->onRestore(); + ui->checkBooleanRefine->onRestore(); + ui->checkSketchBaseRefine->onRestore(); + ui->checkObjectNaming->onRestore(); +} + +/** + * Sets the strings of the subwidgets using the current language. + */ +void DlgSettingsGeneral::changeEvent(QEvent *e) +{ + if (e->type() == QEvent::LanguageChange) { + ui->retranslateUi(this); + } + else { + QWidget::changeEvent(e); + } +} + +// ---------------------------------------------------------------------------- + +DlgImportExportIges::DlgImportExportIges(QWidget* parent) + : PreferencePage(parent) +{ + ui = new Ui_DlgImportExportIges(); + ui->setupUi(this); +} + +/** + * Destroys the object and frees any allocated resources + */ +DlgImportExportIges::~DlgImportExportIges() +{ + // no need to delete child widgets, Qt does it all for us + delete ui; +} + +void DlgImportExportIges::saveSettings() { int unit = ui->comboBoxUnits->currentIndex(); Base::Reference hGrp = App::GetApplication().GetUserParameter() .GetGroup("BaseApp")->GetGroup("Preferences")->GetGroup("Mod/Part"); - hGrp->SetInt("Unit", unit); + hGrp->SetInt("UnitIges", unit); switch (unit) { case 1: Interface_Static::SetCVal("write.iges.unit","M"); - Interface_Static::SetCVal("write.step.unit","M"); break; case 2: Interface_Static::SetCVal("write.iges.unit","IN"); - Interface_Static::SetCVal("write.step.unit","IN"); break; default: Interface_Static::SetCVal("write.iges.unit","MM"); + break; + } + + hGrp->SetBool("BrepMode", ui->checkBrepMode->isChecked()); + Interface_Static::SetIVal("write.iges.brep.mode",ui->checkBrepMode->isChecked() ? 1 : 0); +} + +void DlgImportExportIges::loadSettings() +{ + Base::Reference hGrp = App::GetApplication().GetUserParameter() + .GetGroup("BaseApp")->GetGroup("Preferences")->GetGroup("Mod/Part"); + int unit = hGrp->GetInt("UnitIges", 0); + ui->comboBoxUnits->setCurrentIndex(unit); + + int value = Interface_Static::IVal("write.iges.brep.mode"); + bool brep = hGrp->GetBool("BrepMode", value > 0); + ui->checkBrepMode->setChecked(brep); +} + +/** + * Sets the strings of the subwidgets using the current language. + */ +void DlgImportExportIges::changeEvent(QEvent *e) +{ + if (e->type() == QEvent::LanguageChange) { + ui->retranslateUi(this); + } + else { + QWidget::changeEvent(e); + } +} + +// ---------------------------------------------------------------------------- + +DlgImportExportStep::DlgImportExportStep(QWidget* parent) + : PreferencePage(parent) +{ + ui = new Ui_DlgImportExportStep(); + ui->setupUi(this); +} + +/** + * Destroys the object and frees any allocated resources + */ +DlgImportExportStep::~DlgImportExportStep() +{ + // no need to delete child widgets, Qt does it all for us + delete ui; +} + +void DlgImportExportStep::saveSettings() +{ + int unit = ui->comboBoxUnits->currentIndex(); + Base::Reference hGrp = App::GetApplication().GetUserParameter() + .GetGroup("BaseApp")->GetGroup("Preferences")->GetGroup("Mod/Part"); + hGrp->SetInt("UnitStep", unit); + switch (unit) { + case 1: + Interface_Static::SetCVal("write.step.unit","M"); + break; + case 2: + Interface_Static::SetCVal("write.step.unit","IN"); + break; + default: Interface_Static::SetCVal("write.step.unit","MM"); break; } - ui->checkBooleanCheck->onSave(); - ui->checkBooleanRefine->onSave(); - ui->checkSketchBaseRefine->onSave(); - ui->checkObjectNaming->onSave(); } -void DlgSettingsGeneral::loadSettings() +void DlgImportExportStep::loadSettings() { Base::Reference hGrp = App::GetApplication().GetUserParameter() .GetGroup("BaseApp")->GetGroup("Preferences")->GetGroup("Mod/Part"); - int unit = hGrp->GetInt("Unit", 0); + int unit = hGrp->GetInt("UnitStep", 0); ui->comboBoxUnits->setCurrentIndex(unit); - ui->checkBooleanCheck->onRestore(); - ui->checkBooleanRefine->onRestore(); - ui->checkSketchBaseRefine->onRestore(); - ui->checkObjectNaming->onRestore(); } /** * Sets the strings of the subwidgets using the current language. */ -void DlgSettingsGeneral::changeEvent(QEvent *e) +void DlgImportExportStep::changeEvent(QEvent *e) { if (e->type() == QEvent::LanguageChange) { ui->retranslateUi(this); @@ -99,5 +202,5 @@ void DlgSettingsGeneral::changeEvent(QEvent *e) QWidget::changeEvent(e); } } -#include "moc_DlgSettingsGeneral.cpp" +#include "moc_DlgSettingsGeneral.cpp" diff --git a/src/Mod/Part/Gui/DlgSettingsGeneral.h b/src/Mod/Part/Gui/DlgSettingsGeneral.h index 6b32ee72340b..5dac06fd0ed4 100644 --- a/src/Mod/Part/Gui/DlgSettingsGeneral.h +++ b/src/Mod/Part/Gui/DlgSettingsGeneral.h @@ -46,6 +46,42 @@ class DlgSettingsGeneral : public Gui::Dialog::PreferencePage Ui_DlgSettingsGeneral* ui; }; +class Ui_DlgImportExportIges; +class DlgImportExportIges : public Gui::Dialog::PreferencePage +{ + Q_OBJECT + +public: + DlgImportExportIges(QWidget* parent = 0); + ~DlgImportExportIges(); + +protected: + void saveSettings(); + void loadSettings(); + void changeEvent(QEvent *e); + +private: + Ui_DlgImportExportIges* ui; +}; + +class Ui_DlgImportExportStep; +class DlgImportExportStep : public Gui::Dialog::PreferencePage +{ + Q_OBJECT + +public: + DlgImportExportStep(QWidget* parent = 0); + ~DlgImportExportStep(); + +protected: + void saveSettings(); + void loadSettings(); + void changeEvent(QEvent *e); + +private: + Ui_DlgImportExportStep* ui; +}; + } // namespace Gui #endif // PARTGUI_DLGSETTINGSGENERAL_H diff --git a/src/Mod/Part/Gui/DlgSettingsGeneral.ui b/src/Mod/Part/Gui/DlgSettingsGeneral.ui index 4bccc5f2b394..89d134bfd000 100644 --- a/src/Mod/Part/Gui/DlgSettingsGeneral.ui +++ b/src/Mod/Part/Gui/DlgSettingsGeneral.ui @@ -15,60 +15,6 @@ - - - Export - - - - 9 - - - 6 - - - - - - Millimeter - - - - - Meter - - - - - Inch - - - - - - - - Units for export of STEP/IGES - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - Model settings @@ -116,7 +62,7 @@ - + Object naming @@ -138,7 +84,7 @@ - + Qt::Vertical