From 92ebfab47a5a96e273b04cdcb646ba26645190b0 Mon Sep 17 00:00:00 2001 From: wmayer Date: Thu, 30 Oct 2014 11:48:33 +0100 Subject: [PATCH] + customize STEP header --- src/Mod/Import/App/AppImportPy.cpp | 9 ++++-- src/Mod/Import/Gui/AppImportGuiPy.cpp | 9 ++++-- src/Mod/Part/Gui/DlgImportExportStep.ui | 43 +++++++++++++++++++++++-- src/Mod/Part/Gui/DlgSettingsGeneral.cpp | 14 +++++++- 4 files changed, 66 insertions(+), 9 deletions(-) diff --git a/src/Mod/Import/App/AppImportPy.cpp b/src/Mod/Import/App/AppImportPy.cpp index 8b1accbab..911da923a 100644 --- a/src/Mod/Import/App/AppImportPy.cpp +++ b/src/Mod/Import/App/AppImportPy.cpp @@ -235,10 +235,13 @@ static PyObject * exporter(PyObject *self, PyObject *args) #else APIHeaderSection_MakeHeader makeHeader(writer.Writer().Model()); #endif + Base::Reference hGrp = App::GetApplication().GetUserParameter() + .GetGroup("BaseApp")->GetGroup("Preferences")->GetGroup("Mod/Part")->GetGroup("STEP"); + makeHeader.SetName(new TCollection_HAsciiString((const Standard_CString)Utf8Name.c_str())); - makeHeader.SetAuthorValue (1, new TCollection_HAsciiString("FreeCAD")); - makeHeader.SetOrganizationValue (1, new TCollection_HAsciiString("FreeCAD")); - makeHeader.SetOriginatingSystem(new TCollection_HAsciiString("FreeCAD")); + makeHeader.SetAuthorValue (1, new TCollection_HAsciiString(hGrp->GetASCII("Author", "Author").c_str())); + makeHeader.SetOrganizationValue (1, new TCollection_HAsciiString(hGrp->GetASCII("Company").c_str())); + makeHeader.SetOriginatingSystem(new TCollection_HAsciiString(App::GetApplication().getExecutableName())); makeHeader.SetDescriptionValue(1, new TCollection_HAsciiString("FreeCAD Model")); IFSelect_ReturnStatus ret = writer.Write(name8bit.c_str()); if (ret == IFSelect_RetError || ret == IFSelect_RetFail || ret == IFSelect_RetStop) { diff --git a/src/Mod/Import/Gui/AppImportGuiPy.cpp b/src/Mod/Import/Gui/AppImportGuiPy.cpp index 402c4de0f..76385f343 100644 --- a/src/Mod/Import/Gui/AppImportGuiPy.cpp +++ b/src/Mod/Import/Gui/AppImportGuiPy.cpp @@ -259,10 +259,13 @@ static PyObject * exporter(PyObject *self, PyObject *args) #else APIHeaderSection_MakeHeader makeHeader(writer.Writer().Model()); #endif + Base::Reference hGrp = App::GetApplication().GetUserParameter() + .GetGroup("BaseApp")->GetGroup("Preferences")->GetGroup("Mod/Part")->GetGroup("STEP"); + makeHeader.SetName(new TCollection_HAsciiString((const Standard_CString)(Utf8Name.c_str()))); - makeHeader.SetAuthorValue (1, new TCollection_HAsciiString("FreeCAD")); - makeHeader.SetOrganizationValue (1, new TCollection_HAsciiString("FreeCAD")); - makeHeader.SetOriginatingSystem(new TCollection_HAsciiString("FreeCAD")); + makeHeader.SetAuthorValue (1, new TCollection_HAsciiString(hGrp->GetASCII("Author", "Author").c_str())); + makeHeader.SetOrganizationValue (1, new TCollection_HAsciiString(hGrp->GetASCII("Company").c_str())); + makeHeader.SetOriginatingSystem(new TCollection_HAsciiString(App::GetApplication().getExecutableName())); makeHeader.SetDescriptionValue(1, new TCollection_HAsciiString("FreeCAD Model")); IFSelect_ReturnStatus ret = writer.Write((const char*)name8bit.c_str()); if (ret == IFSelect_RetError || ret == IFSelect_RetFail || ret == IFSelect_RetStop) { diff --git a/src/Mod/Part/Gui/DlgImportExportStep.ui b/src/Mod/Part/Gui/DlgImportExportStep.ui index 245db88af..2f13c7677 100644 --- a/src/Mod/Part/Gui/DlgImportExportStep.ui +++ b/src/Mod/Part/Gui/DlgImportExportStep.ui @@ -7,13 +7,13 @@ 0 0 445 - 187 + 270 STEP - + @@ -63,6 +63,45 @@ + + + Header + + + + + + Company + + + + + + + + + + Author + + + + + + + + + + Product + + + + + + + + + + Qt::Vertical diff --git a/src/Mod/Part/Gui/DlgSettingsGeneral.cpp b/src/Mod/Part/Gui/DlgSettingsGeneral.cpp index 93c68bdc8..aef5c826e 100644 --- a/src/Mod/Part/Gui/DlgSettingsGeneral.cpp +++ b/src/Mod/Part/Gui/DlgSettingsGeneral.cpp @@ -122,8 +122,8 @@ void DlgImportExportIges::saveSettings() // header info hGrp->SetASCII("Company", ui->lineEditCompany->text().toLatin1()); - hGrp->SetASCII("Product", ui->lineEditProduct->text().toLatin1()); hGrp->SetASCII("Author", ui->lineEditAuthor->text().toLatin1()); + //hGrp->SetASCII("Product", ui->lineEditProduct->text().toLatin1()); Interface_Static::SetCVal("write.iges.header.company", ui->lineEditCompany->text().toLatin1()); Interface_Static::SetCVal("write.iges.header.author", ui->lineEditAuthor->text().toLatin1()); @@ -171,6 +171,7 @@ DlgImportExportStep::DlgImportExportStep(QWidget* parent) { ui = new Ui_DlgImportExportStep(); ui->setupUi(this); + ui->lineEditProduct->setReadOnly(true); } /** @@ -199,6 +200,11 @@ void DlgImportExportStep::saveSettings() Interface_Static::SetCVal("write.step.unit","MM"); break; } + + // header info + hGrp->SetASCII("Company", ui->lineEditCompany->text().toLatin1()); + hGrp->SetASCII("Author", ui->lineEditAuthor->text().toLatin1()); + //hGrp->SetASCII("Product", ui->lineEditProduct->text().toLatin1()); } void DlgImportExportStep::loadSettings() @@ -207,6 +213,12 @@ void DlgImportExportStep::loadSettings() .GetGroup("BaseApp")->GetGroup("Preferences")->GetGroup("Mod/Part")->GetGroup("STEP"); int unit = hGrp->GetInt("Unit", 0); ui->comboBoxUnits->setCurrentIndex(unit); + + // header info + ui->lineEditCompany->setText(QString::fromStdString(hGrp->GetASCII("Company"))); + ui->lineEditAuthor->setText(QString::fromStdString(hGrp->GetASCII("Author"))); + ui->lineEditProduct->setText(QString::fromLatin1( + Interface_Static::CVal("write.step.product.name"))); } /**