Skip to content

Commit

Permalink
+ customize IGES header
Browse files Browse the repository at this point in the history
  • Loading branch information
wwmayer committed Oct 29, 2014
1 parent b6df4a4 commit 76906d2
Show file tree
Hide file tree
Showing 6 changed files with 68 additions and 28 deletions.
7 changes: 7 additions & 0 deletions src/Mod/Import/App/AppImportPy.cpp
Expand Up @@ -39,6 +39,8 @@
# include <IGESCAFControl_Reader.hxx>
# include <IGESCAFControl_Writer.hxx>
# include <IGESControl_Controller.hxx>
# include <IGESData_GlobalSection.hxx>
# include <IGESData_IGESModel.hxx>
# include <Interface_Static.hxx>
# include <Transfer_TransientProcess.hxx>
# include <XSControl_WorkSession.hxx>
Expand Down Expand Up @@ -247,6 +249,11 @@ static PyObject * exporter(PyObject *self, PyObject *args)
else if (file.hasExtension("igs") || file.hasExtension("iges")) {
IGESControl_Controller::Init();
IGESCAFControl_Writer writer;
IGESData_GlobalSection header = writer.Model()->GlobalSection();
header.SetAuthorName(new TCollection_HAsciiString(Interface_Static::CVal("write.iges.header.author")));
header.SetCompanyName(new TCollection_HAsciiString(Interface_Static::CVal("write.iges.header.company")));
//header.SetSendName(new TCollection_HAsciiString(Interface_Static::CVal("write.iges.header.product")));
writer.Model()->SetGlobalSection(header);
writer.Transfer(hDoc);
Standard_Boolean ret = writer.Write(name8bit.c_str());
if (!ret) {
Expand Down
7 changes: 7 additions & 0 deletions src/Mod/Import/Gui/AppImportGuiPy.cpp
Expand Up @@ -50,6 +50,8 @@
# include <IGESCAFControl_Reader.hxx>
# include <IGESCAFControl_Writer.hxx>
# include <IGESControl_Controller.hxx>
# include <IGESData_GlobalSection.hxx>
# include <IGESData_IGESModel.hxx>
# include <Interface_Static.hxx>
# include <Transfer_TransientProcess.hxx>
# include <XSControl_WorkSession.hxx>
Expand Down Expand Up @@ -271,6 +273,11 @@ static PyObject * exporter(PyObject *self, PyObject *args)
else if (file.hasExtension("igs") || file.hasExtension("iges")) {
IGESControl_Controller::Init();
IGESCAFControl_Writer writer;
IGESData_GlobalSection header = writer.Model()->GlobalSection();
header.SetAuthorName(new TCollection_HAsciiString(Interface_Static::CVal("write.iges.header.author")));
header.SetCompanyName(new TCollection_HAsciiString(Interface_Static::CVal("write.iges.header.company")));
//header.SetSendName(new TCollection_HAsciiString(Interface_Static::CVal("write.iges.header.product")));
writer.Model()->SetGlobalSection(header);
writer.Transfer(hDoc);
Standard_Boolean ret = writer.Write((const char*)name8bit.c_str());
if (!ret) {
Expand Down
16 changes: 12 additions & 4 deletions src/Mod/Part/App/AppPart.cpp
Expand Up @@ -284,14 +284,20 @@ void PartExport initPart()

IGESControl_Controller::Init();
STEPControl_Controller::Init();
// set the user-defined units
// set the user-defined settings
Base::Reference<ParameterGrp> hGrp = App::GetApplication().GetUserParameter()
.GetGroup("BaseApp")->GetGroup("Preferences")->GetGroup("Mod/Part");

//IGES handling
Base::Reference<ParameterGrp> hIgesGrp = hGrp->GetGroup("IGES");
int value = Interface_Static::IVal("write.iges.brep.mode");
bool brep = hGrp->GetBool("BrepMode", value > 0);
bool brep = hIgesGrp->GetBool("BrepMode", value > 0);
Interface_Static::SetIVal("write.iges.brep.mode",brep ? 1 : 0);
Interface_Static::SetCVal("write.iges.header.company", hIgesGrp->GetASCII("Company").c_str());
Interface_Static::SetCVal("write.iges.header.author", hIgesGrp->GetASCII("Author").c_str());
//Interface_Static::SetCVal("write.iges.header.product", hIgesGrp->GetASCII("Product").c_str());

int unitIges = hGrp->GetInt("UnitIges", 0);
int unitIges = hIgesGrp->GetInt("Unit", 0);
switch (unitIges) {
case 1:
Interface_Static::SetCVal("write.iges.unit","M");
Expand All @@ -304,7 +310,9 @@ void PartExport initPart()
break;
}

int unitStep = hGrp->GetInt("UnitStep", 0);
//STEP handling
Base::Reference<ParameterGrp> hStepGrp = hGrp->GetGroup("STEP");
int unitStep = hStepGrp->GetInt("Unit", 0);
switch (unitStep) {
case 1:
Interface_Static::SetCVal("write.step.unit","M");
Expand Down
7 changes: 7 additions & 0 deletions src/Mod/Part/App/TopoShape.cpp
Expand Up @@ -98,6 +98,8 @@
# include <IGESControl_Controller.hxx>
# include <IGESControl_Writer.hxx>
# include <IGESControl_Reader.hxx>
# include <IGESData_GlobalSection.hxx>
# include <IGESData_IGESModel.hxx>
# include <STEPControl_Writer.hxx>
# include <STEPControl_Reader.hxx>
# include <TopTools_MapOfShape.hxx>
Expand Down Expand Up @@ -695,6 +697,11 @@ void TopoShape::exportIges(const char *filename) const
// write iges file
IGESControl_Controller::Init();
IGESControl_Writer aWriter;
IGESData_GlobalSection header = aWriter.Model()->GlobalSection();
header.SetAuthorName(new TCollection_HAsciiString(Interface_Static::CVal("write.iges.header.author")));
header.SetCompanyName(new TCollection_HAsciiString(Interface_Static::CVal("write.iges.header.company")));
//header.SetSendName(new TCollection_HAsciiString(Interface_Static::CVal("write.iges.header.product")));
aWriter.Model()->SetGlobalSection(header);
aWriter.AddShape(this->_Shape);
aWriter.ComputeModel();
if (aWriter.Write(encodeFilename(filename).c_str()) != IFSelect_RetDone)
Expand Down
19 changes: 13 additions & 6 deletions src/Mod/Part/Gui/DlgImportExportIges.ui
Expand Up @@ -85,26 +85,26 @@
<item row="0" column="1">
<widget class="QLineEdit" name="lineEditCompany"/>
</item>
<item row="1" column="0">
<item row="2" column="0">
<widget class="QLabel" name="label_3">
<property name="text">
<string>Product</string>
</property>
</widget>
</item>
<item row="1" column="1">
<item row="2" column="1">
<widget class="QLineEdit" name="lineEditProduct"/>
</item>
<item row="2" column="0">
<item row="1" column="1">
<widget class="QLineEdit" name="lineEditAuthor"/>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_4">
<property name="text">
<string>Author</string>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QLineEdit" name="lineEditAuthor"/>
</item>
</layout>
</widget>
</item>
Expand All @@ -123,6 +123,13 @@
</item>
</layout>
</widget>
<tabstops>
<tabstop>comboBoxUnits</tabstop>
<tabstop>checkBrepMode</tabstop>
<tabstop>lineEditCompany</tabstop>
<tabstop>lineEditAuthor</tabstop>
<tabstop>lineEditProduct</tabstop>
</tabstops>
<resources/>
<connections/>
</ui>
40 changes: 22 additions & 18 deletions src/Mod/Part/Gui/DlgSettingsGeneral.cpp
Expand Up @@ -87,7 +87,7 @@ DlgImportExportIges::DlgImportExportIges(QWidget* parent)
{
ui = new Ui_DlgImportExportIges();
ui->setupUi(this);
ui->groupBoxHeader->hide();
ui->lineEditProduct->setReadOnly(true);
}

/**
Expand All @@ -103,8 +103,8 @@ void DlgImportExportIges::saveSettings()
{
int unit = ui->comboBoxUnits->currentIndex();
Base::Reference<ParameterGrp> hGrp = App::GetApplication().GetUserParameter()
.GetGroup("BaseApp")->GetGroup("Preferences")->GetGroup("Mod/Part");
hGrp->SetInt("UnitIges", unit);
.GetGroup("BaseApp")->GetGroup("Preferences")->GetGroup("Mod/Part")->GetGroup("IGES");
hGrp->SetInt("Unit", unit);
switch (unit) {
case 1:
Interface_Static::SetCVal("write.iges.unit","M");
Expand All @@ -121,30 +121,34 @@ void DlgImportExportIges::saveSettings()
Interface_Static::SetIVal("write.iges.brep.mode",ui->checkBrepMode->isChecked() ? 1 : 0);

// header info
//hGrp->SetASCII("CompanyIges", ui->lineEditCompany->text().toLatin1());
//hGrp->SetASCII("ProductIges", ui->lineEditProduct->text().toLatin1());
//hGrp->SetASCII("AuthorIges", ui->lineEditAuthor->text().toLatin1());
hGrp->SetASCII("Company", ui->lineEditCompany->text().toLatin1());
hGrp->SetASCII("Product", ui->lineEditProduct->text().toLatin1());
hGrp->SetASCII("Author", ui->lineEditAuthor->text().toLatin1());

//Interface_Static::SetCVal("write.iges.header.company", ui->lineEditCompany->text().toLatin1());
//Interface_Static::SetCVal("write.iges.header.product", ui->lineEditProduct->text().toLatin1());
//Interface_Static::SetCVal("write.iges.header.author", ui->lineEditAuthor->text().toLatin1());
Interface_Static::SetCVal("write.iges.header.company", ui->lineEditCompany->text().toLatin1());
Interface_Static::SetCVal("write.iges.header.author", ui->lineEditAuthor->text().toLatin1());
//Interface_Static::SetCVal("write.iges.header.product", ui->lineEditProduct->text().toLatin1());
}

void DlgImportExportIges::loadSettings()
{
Base::Reference<ParameterGrp> hGrp = App::GetApplication().GetUserParameter()
.GetGroup("BaseApp")->GetGroup("Preferences")->GetGroup("Mod/Part");
int unit = hGrp->GetInt("UnitIges", 0);
.GetGroup("BaseApp")->GetGroup("Preferences")->GetGroup("Mod/Part")->GetGroup("IGES");
int unit = hGrp->GetInt("Unit", 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);

// header info
//ui->lineEditCompany->setText(QString::fromStdString(hGrp->GetASCII("CompanyIges")));
//ui->lineEditProduct->setText(QString::fromStdString(hGrp->GetASCII("ProductIges")));
//ui->lineEditAuthor->setText(QString::fromStdString(hGrp->GetASCII("AuthorIges")));
ui->lineEditCompany->setText(QString::fromStdString(hGrp->GetASCII("Company",
Interface_Static::CVal("write.iges.header.company"))));
ui->lineEditAuthor->setText(QString::fromStdString(hGrp->GetASCII("Author",
Interface_Static::CVal("write.iges.header.author"))));
//ui->lineEditProduct->setText(QString::fromStdString(hGrp->GetASCII("Product")));
ui->lineEditProduct->setText(QString::fromLatin1(
Interface_Static::CVal("write.iges.header.product")));
}

/**
Expand Down Expand Up @@ -182,8 +186,8 @@ void DlgImportExportStep::saveSettings()
{
int unit = ui->comboBoxUnits->currentIndex();
Base::Reference<ParameterGrp> hGrp = App::GetApplication().GetUserParameter()
.GetGroup("BaseApp")->GetGroup("Preferences")->GetGroup("Mod/Part");
hGrp->SetInt("UnitStep", unit);
.GetGroup("BaseApp")->GetGroup("Preferences")->GetGroup("Mod/Part")->GetGroup("STEP");
hGrp->SetInt("Unit", unit);
switch (unit) {
case 1:
Interface_Static::SetCVal("write.step.unit","M");
Expand All @@ -200,8 +204,8 @@ void DlgImportExportStep::saveSettings()
void DlgImportExportStep::loadSettings()
{
Base::Reference<ParameterGrp> hGrp = App::GetApplication().GetUserParameter()
.GetGroup("BaseApp")->GetGroup("Preferences")->GetGroup("Mod/Part");
int unit = hGrp->GetInt("UnitStep", 0);
.GetGroup("BaseApp")->GetGroup("Preferences")->GetGroup("Mod/Part")->GetGroup("STEP");
int unit = hGrp->GetInt("Unit", 0);
ui->comboBoxUnits->setCurrentIndex(unit);
}

Expand Down

0 comments on commit 76906d2

Please sign in to comment.