From d3e4da9f5124fa811bbb90283fcd02131bb22f0d Mon Sep 17 00:00:00 2001 From: wmayer Date: Tue, 2 Feb 2021 21:51:11 +0100 Subject: [PATCH] Part: offer all supported STEP schemes by OCC in a combo box --- src/Mod/Import/Gui/AppImportGuiPy.cpp | 9 ++--- src/Mod/Part/App/ImportStep.h | 10 ++++- src/Mod/Part/Gui/DlgImportExportStep.ui | 50 +++++++++++++++---------- src/Mod/Part/Gui/DlgSettingsGeneral.cpp | 34 ++++++++--------- 4 files changed, 60 insertions(+), 43 deletions(-) diff --git a/src/Mod/Import/Gui/AppImportGuiPy.cpp b/src/Mod/Import/Gui/AppImportGuiPy.cpp index d6054176fe..e029d2db61 100644 --- a/src/Mod/Import/Gui/AppImportGuiPy.cpp +++ b/src/Mod/Import/Gui/AppImportGuiPy.cpp @@ -642,11 +642,10 @@ private: Base::FileInfo file(Utf8Name.c_str()); if (file.hasExtension("stp") || file.hasExtension("step")) { ParameterGrp::handle hGrp_stp = App::GetApplication().GetParameterGroupByPath("User parameter:BaseApp/Preferences/Mod/Part/STEP"); - std::string scheme = hGrp_stp->GetASCII("Scheme", "AP214IS"); - if (scheme == "AP203") - Interface_Static::SetCVal("write.step.schema", "AP203"); - else if (scheme == "AP214IS") - Interface_Static::SetCVal("write.step.schema", "AP214IS"); + std::string scheme = hGrp_stp->GetASCII("Scheme", Interface_Static::CVal("write.step.schema")); + std::list supported = Part::supportedSTEPSchemes(); + if (std::find(supported.begin(), supported.end(), scheme) != supported.end()) + Interface_Static::SetCVal("write.step.schema", scheme.c_str()); STEPCAFControl_Writer writer; Interface_Static::SetIVal("write.step.assembly",1); diff --git a/src/Mod/Part/App/ImportStep.h b/src/Mod/Part/App/ImportStep.h index f3dd1bdf6c..4d736cf0c1 100644 --- a/src/Mod/Part/App/ImportStep.h +++ b/src/Mod/Part/App/ImportStep.h @@ -41,7 +41,15 @@ namespace Part */ PartExport int ImportStepParts(App::Document *pcDoc, const char* Name); - +inline std::list supportedSTEPSchemes() { + std::list schemes; + schemes.emplace_back("AP203"); + schemes.emplace_back("AP214CD"); + schemes.emplace_back("AP214DIS"); + schemes.emplace_back("AP214IS"); + schemes.emplace_back("AP242DIS"); + return schemes; +} } //namespace Part diff --git a/src/Mod/Part/Gui/DlgImportExportStep.ui b/src/Mod/Part/Gui/DlgImportExportStep.ui index 915713a7d2..da3d331cc7 100644 --- a/src/Mod/Part/Gui/DlgImportExportStep.ui +++ b/src/Mod/Part/Gui/DlgImportExportStep.ui @@ -7,7 +7,7 @@ 0 0 445 - 637 + 699 @@ -27,20 +27,32 @@ - - - AP 203 - - - true - - - - - - - AP 214 - + + + + AP203 + + + + + AP214 Committee Draft + + + + + AP214 Draft International Standard + + + + + AP214 International Standard + + + + + AP242 Draft International Standard + + @@ -113,12 +125,12 @@ Use legacy exporter - - Mod/Import - ExportLegacy + + Mod/Import + @@ -393,8 +405,6 @@ during file reading (slower but higher details). comboBoxUnits checkBoxPcurves checkBoxExportHiddenObj - radioButtonAP203 - radioButtonAP214 checkBoxMergeCompound checkBoxUseLinkGroup checkBoxImportHiddenObj diff --git a/src/Mod/Part/Gui/DlgSettingsGeneral.cpp b/src/Mod/Part/Gui/DlgSettingsGeneral.cpp index 783f954c2f..2dee4b9150 100644 --- a/src/Mod/Part/Gui/DlgSettingsGeneral.cpp +++ b/src/Mod/Part/Gui/DlgSettingsGeneral.cpp @@ -197,9 +197,16 @@ DlgImportExportStep::DlgImportExportStep(QWidget* parent) { ui = new Ui_DlgImportExportStep(); ui->setupUi(this); + + ui->comboBoxSchema->setItemData(0, QByteArray("AP203")); + ui->comboBoxSchema->setItemData(1, QByteArray("AP214CD")); + ui->comboBoxSchema->setItemData(2, QByteArray("AP214DIS")); + ui->comboBoxSchema->setItemData(3, QByteArray("AP214IS")); + ui->comboBoxSchema->setItemData(4, QByteArray("AP242DIS")); + ui->lineEditProduct->setReadOnly(true); - ui->radioButtonAP203->setToolTip(tr("Configuration controlled 3D designs of mechanical parts and assemblies")); - ui->radioButtonAP214->setToolTip(tr("Core data for automotive mechanical design processes")); + //ui->radioButtonAP203->setToolTip(tr("Configuration controlled 3D designs of mechanical parts and assemblies")); + //ui->radioButtonAP214->setToolTip(tr("Core data for automotive mechanical design processes")); // https://tracker.dev.opencascade.org/view.php?id=25654 ui->checkBoxPcurves->setToolTip(tr("This parameter indicates whether parametric curves (curves in parametric space of surface)\n" @@ -253,15 +260,10 @@ void DlgImportExportStep::saveSettings() } // scheme - if (ui->radioButtonAP203->isChecked()) { - Interface_Static::SetCVal("write.step.schema","AP203"); - hStepGrp->SetASCII("Scheme", "AP203"); - } - else { - // possible values: AP214CD (1996), AP214DIS (1998), AP214IS (2002) - Interface_Static::SetCVal("write.step.schema","AP214IS"); - hStepGrp->SetASCII("Scheme", "AP214IS"); - } + // possible values: AP214CD (1996), AP214DIS (1998), AP214IS (2002), AP242DIS + QByteArray schema = ui->comboBoxSchema->itemData(ui->comboBoxSchema->currentIndex()).toByteArray(); + Interface_Static::SetCVal("write.step.schema",schema); + hStepGrp->SetASCII("Scheme", schema); // header info hStepGrp->SetASCII("Company", ui->lineEditCompany->text().toLatin1()); @@ -299,12 +301,10 @@ void DlgImportExportStep::loadSettings() ui->comboBoxUnits->setCurrentIndex(unit); // scheme - QString ap = QString::fromStdString(hStepGrp->GetASCII("Scheme", - Interface_Static::CVal("write.step.schema"))); - if (ap.startsWith(QLatin1String("AP203"))) - ui->radioButtonAP203->setChecked(true); - else - ui->radioButtonAP214->setChecked(true); + QByteArray ap(hStepGrp->GetASCII("Scheme", Interface_Static::CVal("write.step.schema")).c_str()); + int index = ui->comboBoxSchema->findData(QVariant(ap)); + if (index >= 0) + ui->comboBoxSchema->setCurrentIndex(index); // header info ui->lineEditCompany->setText(QString::fromStdString(hStepGrp->GetASCII("Company")));