Part: add getter/setter to ImportExportSettings and simplify DlgImportExportStep
This commit is contained in:
@@ -150,6 +150,97 @@ ImportExportSettings::ImportExportSettings()
|
||||
pGroup = App::GetApplication().GetParameterGroupByPath("User parameter:BaseApp/Preferences/Mod/Import");
|
||||
}
|
||||
|
||||
ParameterGrp::handle ImportExportSettings::getPartGroup() const
|
||||
{
|
||||
return App::GetApplication().GetParameterGroupByPath("User parameter:BaseApp/Preferences/Mod/Part");
|
||||
}
|
||||
|
||||
void ImportExportSettings::setWriteSurfaceCurveMode(bool on)
|
||||
{
|
||||
ParameterGrp::handle grp = getPartGroup()->GetGroup("General");
|
||||
grp->SetInt("WriteSurfaceCurveMode", on ? 1 : 0);
|
||||
Interface_Static::SetIVal("write.surfacecurve.mode", on ? 1 : 0);
|
||||
}
|
||||
|
||||
bool ImportExportSettings::getWriteSurfaceCurveMode() const
|
||||
{
|
||||
ParameterGrp::handle grp = getPartGroup()->GetGroup("General");
|
||||
int writesurfacecurve = Interface_Static::IVal("write.surfacecurve.mode");
|
||||
writesurfacecurve = grp->GetInt("WriteSurfaceCurveMode", writesurfacecurve);
|
||||
return (writesurfacecurve == 0 ? false : true);
|
||||
}
|
||||
|
||||
std::string ImportExportSettings::getScheme() const
|
||||
{
|
||||
Base::Reference<ParameterGrp> hStepGrp = getPartGroup()->GetGroup("STEP");
|
||||
return hStepGrp->GetASCII("Scheme", Interface_Static::CVal("write.step.schema"));
|
||||
}
|
||||
|
||||
void ImportExportSettings::setScheme(const char* scheme)
|
||||
{
|
||||
Base::Reference<ParameterGrp> hStepGrp = getPartGroup()->GetGroup("STEP");
|
||||
hStepGrp->SetASCII("Scheme", scheme);
|
||||
Interface_Static::SetCVal("write.step.schema", scheme);
|
||||
}
|
||||
|
||||
ImportExportSettings::Unit ImportExportSettings::getUnit() const
|
||||
{
|
||||
Base::Reference<ParameterGrp> hStepGrp = getPartGroup()->GetGroup("STEP");
|
||||
return static_cast<ImportExportSettings::Unit>(hStepGrp->GetInt("Unit", 0));
|
||||
}
|
||||
|
||||
void ImportExportSettings::setUnit(ImportExportSettings::Unit unit)
|
||||
{
|
||||
Base::Reference<ParameterGrp> hStepGrp = getPartGroup()->GetGroup("STEP");
|
||||
hStepGrp->SetInt("Unit", static_cast<long>(unit));
|
||||
|
||||
switch (unit) {
|
||||
case Unit::M:
|
||||
Interface_Static::SetCVal("write.step.unit","M");
|
||||
break;
|
||||
case Unit::IN:
|
||||
Interface_Static::SetCVal("write.step.unit","INCH");
|
||||
break;
|
||||
default:
|
||||
Interface_Static::SetCVal("write.step.unit","MM");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
std::string ImportExportSettings::getCompany() const
|
||||
{
|
||||
Base::Reference<ParameterGrp> hStepGrp = getPartGroup()->GetGroup("STEP");
|
||||
return hStepGrp->GetASCII("Company");
|
||||
}
|
||||
|
||||
void ImportExportSettings::setCompany(const char* name)
|
||||
{
|
||||
Base::Reference<ParameterGrp> hStepGrp = getPartGroup()->GetGroup("STEP");
|
||||
hStepGrp->SetASCII("Company", name);
|
||||
}
|
||||
|
||||
std::string ImportExportSettings::getAuthor() const
|
||||
{
|
||||
Base::Reference<ParameterGrp> hStepGrp = getPartGroup()->GetGroup("STEP");
|
||||
return hStepGrp->GetASCII("Author");
|
||||
}
|
||||
|
||||
void ImportExportSettings::setAuthor(const char* name)
|
||||
{
|
||||
Base::Reference<ParameterGrp> hStepGrp = getPartGroup()->GetGroup("STEP");
|
||||
hStepGrp->SetASCII("Author", name);
|
||||
}
|
||||
|
||||
std::string ImportExportSettings::getProductName() const
|
||||
{
|
||||
return Interface_Static::CVal("write.step.product.name");
|
||||
}
|
||||
|
||||
void ImportExportSettings::setProductName(const char* name)
|
||||
{
|
||||
Interface_Static::SetCVal("write.step.product.name", name);
|
||||
}
|
||||
|
||||
void ImportExportSettings::setReadShapeCompoundMode(bool on)
|
||||
{
|
||||
auto grp = pGroup->GetGroup("hSTEP");
|
||||
|
||||
@@ -44,33 +44,68 @@ public:
|
||||
ObjectPerDocument = 3,
|
||||
ObjectPerDirectory = 4,
|
||||
};
|
||||
enum class Unit {
|
||||
MM = 0,
|
||||
M = 1,
|
||||
IN = 2,
|
||||
};
|
||||
|
||||
static void initialize();
|
||||
ImportExportSettings();
|
||||
|
||||
void setWriteSurfaceCurveMode(bool);
|
||||
bool getWriteSurfaceCurveMode() const;
|
||||
|
||||
std::string getScheme() const;
|
||||
void setScheme(const char*);
|
||||
|
||||
Unit getUnit() const;
|
||||
void setUnit(Unit);
|
||||
|
||||
std::string getCompany() const;
|
||||
void setCompany(const char*);
|
||||
|
||||
std::string getAuthor() const;
|
||||
void setAuthor(const char*);
|
||||
|
||||
std::string getProductName() const;
|
||||
void setProductName(const char*);
|
||||
|
||||
void setReadShapeCompoundMode(bool);
|
||||
bool getReadShapeCompoundMode() const;
|
||||
|
||||
void setExportHiddenObject(bool);
|
||||
bool getExportHiddenObject() const;
|
||||
|
||||
void setImportHiddenObject(bool);
|
||||
bool getImportHiddenObject() const;
|
||||
|
||||
void setExportLegacy(bool);
|
||||
bool getExportLegacy() const;
|
||||
|
||||
void setExportKeepPlacement(bool);
|
||||
bool getExportKeepPlacement() const;
|
||||
|
||||
void setUseLinkGroup(bool);
|
||||
bool getUseLinkGroup() const;
|
||||
|
||||
void setUseBaseName(bool);
|
||||
bool getUseBaseName() const;
|
||||
|
||||
void setReduceObjects(bool);
|
||||
bool getReduceObjects() const;
|
||||
|
||||
void setExpandCompound(bool);
|
||||
bool getExpandCompound() const;
|
||||
|
||||
void setShowProgress(bool);
|
||||
bool getShowProgress() const;
|
||||
|
||||
void setImportMode(ImportMode);
|
||||
ImportMode getImportMode() const;
|
||||
|
||||
private:
|
||||
ParameterGrp::handle getPartGroup() const;
|
||||
static void initGeneral(Base::Reference<ParameterGrp> hGrp);
|
||||
static void initSTEP(Base::Reference<ParameterGrp> hGrp);
|
||||
static void initIGES(Base::Reference<ParameterGrp> hGrp);
|
||||
|
||||
@@ -241,41 +241,22 @@ DlgImportExportStep::~DlgImportExportStep()
|
||||
|
||||
void DlgImportExportStep::saveSettings()
|
||||
{
|
||||
int unit = ui->comboBoxUnits->currentIndex();
|
||||
Base::Reference<ParameterGrp> hPartGrp = App::GetApplication().GetUserParameter()
|
||||
.GetGroup("BaseApp")->GetGroup("Preferences")->GetGroup("Mod/Part");
|
||||
|
||||
// General
|
||||
Base::Reference<ParameterGrp> hGenGrp = hPartGrp->GetGroup("General");
|
||||
int writesurfacecurve = ui->checkBoxPcurves->isChecked() ? 1 : 0;
|
||||
hGenGrp->SetInt("WriteSurfaceCurveMode", writesurfacecurve);
|
||||
Interface_Static::SetIVal("write.surfacecurve.mode", writesurfacecurve);
|
||||
Part::ImportExportSettings settings;
|
||||
settings.setWriteSurfaceCurveMode(ui->checkBoxPcurves->isChecked());
|
||||
|
||||
// STEP
|
||||
Base::Reference<ParameterGrp> hStepGrp = hPartGrp->GetGroup("STEP");
|
||||
hStepGrp->SetInt("Unit", unit);
|
||||
switch (unit) {
|
||||
case 1:
|
||||
Interface_Static::SetCVal("write.step.unit","M");
|
||||
break;
|
||||
case 2:
|
||||
Interface_Static::SetCVal("write.step.unit","INCH");
|
||||
break;
|
||||
default:
|
||||
Interface_Static::SetCVal("write.step.unit","MM");
|
||||
break;
|
||||
}
|
||||
int unit = ui->comboBoxUnits->currentIndex();
|
||||
settings.setUnit(static_cast<Part::ImportExportSettings::Unit>(unit));
|
||||
|
||||
// scheme
|
||||
// possible values: AP214CD (1996), AP214DIS (1998), AP214IS (2002), AP242DIS
|
||||
// possible values: AP203, 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);
|
||||
settings.setScheme(schema);
|
||||
|
||||
// header info
|
||||
hStepGrp->SetASCII("Company", ui->lineEditCompany->text().toLatin1());
|
||||
hStepGrp->SetASCII("Author", ui->lineEditAuthor->text().toLatin1());
|
||||
//hStepGrp->SetASCII("Product", ui->lineEditProduct->text().toLatin1());
|
||||
settings.setCompany(ui->lineEditCompany->text().toLatin1());
|
||||
settings.setAuthor(ui->lineEditAuthor->text().toLatin1());
|
||||
|
||||
// (h)STEP of Import module
|
||||
ui->checkBoxMergeCompound->onSave();
|
||||
@@ -293,31 +274,23 @@ void DlgImportExportStep::saveSettings()
|
||||
|
||||
void DlgImportExportStep::loadSettings()
|
||||
{
|
||||
Base::Reference<ParameterGrp> hPartGrp = App::GetApplication().GetUserParameter()
|
||||
.GetGroup("BaseApp")->GetGroup("Preferences")->GetGroup("Mod/Part");
|
||||
|
||||
// General
|
||||
Base::Reference<ParameterGrp> hGenGrp = hPartGrp->GetGroup("General");
|
||||
int writesurfacecurve = Interface_Static::IVal("write.surfacecurve.mode");
|
||||
writesurfacecurve = hGenGrp->GetInt("WriteSurfaceCurveMode", writesurfacecurve);
|
||||
ui->checkBoxPcurves->setChecked(writesurfacecurve == 0 ? false : true);
|
||||
Part::ImportExportSettings settings;
|
||||
ui->checkBoxPcurves->setChecked(settings.getWriteSurfaceCurveMode());
|
||||
|
||||
// STEP
|
||||
Base::Reference<ParameterGrp> hStepGrp = hPartGrp->GetGroup("STEP");
|
||||
int unit = hStepGrp->GetInt("Unit", 0);
|
||||
ui->comboBoxUnits->setCurrentIndex(unit);
|
||||
ui->comboBoxUnits->setCurrentIndex(static_cast<int>(settings.getUnit()));
|
||||
|
||||
// scheme
|
||||
QByteArray ap(hStepGrp->GetASCII("Scheme", Interface_Static::CVal("write.step.schema")).c_str());
|
||||
QByteArray ap(settings.getScheme().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")));
|
||||
ui->lineEditAuthor->setText(QString::fromStdString(hStepGrp->GetASCII("Author")));
|
||||
ui->lineEditProduct->setText(QString::fromLatin1(
|
||||
Interface_Static::CVal("write.step.product.name")));
|
||||
ui->lineEditCompany->setText(QString::fromStdString(settings.getCompany()));
|
||||
ui->lineEditAuthor->setText(QString::fromStdString(settings.getAuthor()));
|
||||
ui->lineEditProduct->setText(QString::fromStdString(settings.getProductName()));
|
||||
|
||||
// (h)STEP of Import module
|
||||
ui->checkBoxMergeCompound->onRestore();
|
||||
|
||||
Reference in New Issue
Block a user