+ customize IGES header

This commit is contained in:
wmayer 2014-10-29 16:39:33 +01:00
parent b6df4a490e
commit 76906d20a0
6 changed files with 70 additions and 30 deletions

View File

@ -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>
@ -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) {

View File

@ -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>
@ -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) {

View File

@ -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");
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);
//IGES handling
Base::Reference<ParameterGrp> hIgesGrp = hGrp->GetGroup("IGES");
int value = Interface_Static::IVal("write.iges.brep.mode");
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 = hIgesGrp->GetInt("Unit", 0);
switch (unitIges) {
case 1:
Interface_Static::SetCVal("write.iges.unit","M");
@ -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");

View File

@ -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>
@ -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)

View File

@ -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>
@ -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>

View File

@ -87,7 +87,7 @@ DlgImportExportIges::DlgImportExportIges(QWidget* parent)
{
ui = new Ui_DlgImportExportIges();
ui->setupUi(this);
ui->groupBoxHeader->hide();
ui->lineEditProduct->setReadOnly(true);
}
/**
@ -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");
@ -121,20 +121,20 @@ 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");
@ -142,9 +142,13 @@ void DlgImportExportIges::loadSettings()
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")));
}
/**
@ -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");
@ -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);
}