diff --git a/src/Mod/Import/App/AppImportPy.cpp b/src/Mod/Import/App/AppImportPy.cpp index ce5919f4c7..e233603d0a 100644 --- a/src/Mod/Import/App/AppImportPy.cpp +++ b/src/Mod/Import/App/AppImportPy.cpp @@ -157,9 +157,16 @@ private: hApp->NewDocument(TCollection_ExtendedString("MDTV-CAF"), hDoc); if (file.hasExtension({"stp", "step"})) { +#if OCC_VERSION_HEX >= 0x070800 + Resource_FormatType cp = Resource_FormatType_UTF8; +#endif try { Import::ReaderStep reader(file); +#if OCC_VERSION_HEX < 0x070800 reader.read(hDoc); +#else + reader.read(hDoc, cp); +#endif } catch (OSD_Exception& e) { Base::Console().Error("%s\n", e.GetMessageString()); diff --git a/src/Mod/Import/App/ReaderStep.cpp b/src/Mod/Import/App/ReaderStep.cpp index 47cbb48f5b..682a4dbf51 100644 --- a/src/Mod/Import/App/ReaderStep.cpp +++ b/src/Mod/Import/App/ReaderStep.cpp @@ -42,7 +42,11 @@ ReaderStep::ReaderStep(const Base::FileInfo& file) // NOLINT : file {file} {} +#if OCC_VERSION_HEX < 0x070800 void ReaderStep::read(Handle(TDocStd_Document) hDoc) // NOLINT +#else +void ReaderStep::read(Handle(TDocStd_Document) hDoc, Resource_FormatType codePage) // NOLINT +#endif { std::string utf8Name = file.filePath(); std::string name8bit = Part::encodeFilename(utf8Name); @@ -51,7 +55,14 @@ void ReaderStep::read(Handle(TDocStd_Document) hDoc) // NOLINT aReader.SetNameMode(true); aReader.SetLayerMode(true); aReader.SetSHUOMode(true); +#if OCC_VERSION_HEX < 0x070800 if (aReader.ReadFile(name8bit.c_str()) != IFSelect_RetDone) { +#else + Handle(StepData_StepModel) aStepModel = new StepData_StepModel; + aStepModel->InternalParameters.InitFromStatic(); + aStepModel->SetSourceCodePage(codePage); + if (aReader.ReadFile(name8bit.c_str(), aStepModel->InternalParameters) != IFSelect_RetDone) { +#endif throw Base::FileException("Cannot read STEP file", file); } diff --git a/src/Mod/Import/App/ReaderStep.h b/src/Mod/Import/App/ReaderStep.h index febd1760a3..7491c1f4d2 100644 --- a/src/Mod/Import/App/ReaderStep.h +++ b/src/Mod/Import/App/ReaderStep.h @@ -27,6 +27,8 @@ #include #include #include +#include +#include namespace Import { @@ -35,8 +37,11 @@ class ImportExport ReaderStep { public: explicit ReaderStep(const Base::FileInfo& file); - +#if OCC_VERSION_HEX < 0x070800 void read(Handle(TDocStd_Document) hDoc); +#else + void read(Handle(TDocStd_Document) hDoc, Resource_FormatType codePage); +#endif private: Base::FileInfo file; diff --git a/src/Mod/Import/Gui/AppImportGuiPy.cpp b/src/Mod/Import/Gui/AppImportGuiPy.cpp index 106cb0bd3b..5c45be8c50 100644 --- a/src/Mod/Import/Gui/AppImportGuiPy.cpp +++ b/src/Mod/Import/Gui/AppImportGuiPy.cpp @@ -164,6 +164,16 @@ private: if (mode < 0) { mode = ocaf.getMode(); } +#if OCC_VERSION_HEX >= 0x070800 + auto handle = App::GetApplication().GetParameterGroupByPath( + "User parameter:BaseApp/Preferences/Mod/Import/hSTEP"); + if (handle->GetBool("ReadShowDialogImport", false)) { + Gui::Command::doCommand(Gui::Command::Gui, + "Gui.showPreferences('Import-Export', 8)"); + } + Part::OCAF::ImportExportSettings settings; + Resource_FormatType cp = settings.getImportCodePage(); +#endif if (mode && !pcDoc->isSaved()) { auto gdoc = Gui::Application::Instance->getDocument(pcDoc); if (!gdoc->save()) { @@ -173,7 +183,11 @@ private: try { Import::ReaderStep reader(file); +#if OCC_VERSION_HEX < 0x070800 reader.read(hDoc); +#else + reader.read(hDoc, cp); +#endif } catch (OSD_Exception& e) { Base::Console().Error("%s\n", e.GetMessageString()); @@ -483,7 +497,11 @@ private: if (file.hasExtension({"stp", "step"})) { Import::ReaderStep reader(file); +#if OCC_VERSION_HEX < 0x070800 reader.read(hDoc); +#else + reader.read(hDoc, Resource_FormatType_UTF8); +#endif } else if (file.hasExtension({"igs", "iges"})) { Import::ReaderIges reader(file); diff --git a/src/Mod/Part/App/OCAF/ImportExportSettings.cpp b/src/Mod/Part/App/OCAF/ImportExportSettings.cpp index b914de11fa..36dc9a7f71 100644 --- a/src/Mod/Part/App/OCAF/ImportExportSettings.cpp +++ b/src/Mod/Part/App/OCAF/ImportExportSettings.cpp @@ -22,7 +22,7 @@ #include "PreCompiled.h" #ifndef _PreComp_ -# include +#include #endif #include "ImportExportSettings.h" @@ -99,6 +99,48 @@ void ImportExportSettings::initIGES(Base::Reference hGrp) } } +#if OCC_VERSION_HEX >= 0x070800 + +void ImportExportSettings::setImportCodePage(int cpIndex) +{ + pGroup->SetInt("ImportCodePage", cpIndex); +} + +Resource_FormatType ImportExportSettings::getImportCodePage() const +{ + Resource_FormatType result; + int codePageIndex = pGroup->GetInt("ImportCodePage", 0); + int i=0; + for (const auto& codePageIt : codePageList) { + if (i == codePageIndex) + { + result = codePageIt.codePage; + break; + } + i++; + } + return result; +} + +std::list ImportExportSettings::getCodePageList() const +{ + return codePageList; +} + +void ImportExportSettings::setReadShowDialogImport(bool on) +{ + auto grp = pGroup->GetGroup("hSTEP"); + grp->SetBool("ReadShowDialogImport", on); +} + +bool ImportExportSettings::getReadShowDialogImport() const +{ + auto grp = pGroup->GetGroup("hSTEP"); + return grp->GetBool("ReadShowDialogImport", false); +} + +#endif + void ImportExportSettings::initSTEP(Base::Reference hGrp) { //STEP handling diff --git a/src/Mod/Part/App/OCAF/ImportExportSettings.h b/src/Mod/Part/App/OCAF/ImportExportSettings.h index 22c7294d2b..f9da619481 100644 --- a/src/Mod/Part/App/OCAF/ImportExportSettings.h +++ b/src/Mod/Part/App/OCAF/ImportExportSettings.h @@ -26,7 +26,10 @@ #include #include #include - +#include +#if OCC_VERSION_HEX >= 0x070800 +#include +#endif namespace Part { @@ -54,7 +57,12 @@ public: ObjectPerDocument = 3, ObjectPerDirectory = 4, }; - +#if OCC_VERSION_HEX >= 0x070800 + struct CodePage { + std::string codePageName; + Resource_FormatType codePage; + }; +#endif static void initialize(); ImportExportSettings(); @@ -94,6 +102,14 @@ public: void setImportMode(ImportMode); ImportMode getImportMode() const; +#if OCC_VERSION_HEX >= 0x070800 + void setReadShowDialogImport(bool); + bool getReadShowDialogImport() const; + + void setImportCodePage(int); + Resource_FormatType getImportCodePage() const; + std::list getCodePageList() const; +#endif private: static void initGeneral(Base::Reference hGrp); static void initSTEP(Base::Reference hGrp); @@ -103,6 +119,37 @@ private: mutable STEP::ImportExportSettingsPtr step; mutable IGES::ImportExportSettingsPtr iges; ParameterGrp::handle pGroup; +#if OCC_VERSION_HEX >= 0x070800 + std::list codePageList { + {"No conversion", Resource_FormatType_NoConversion}, + {"Multi-byte UTF-8 encoding", Resource_FormatType_UTF8}, + {"SJIS (Shift Japanese Industrial Standards) encoding", Resource_FormatType_SJIS}, + {"EUC (Extended Unix Code) ", Resource_FormatType_EUC}, + {"GB (Guobiao) encoding for Simplified Chinese", Resource_FormatType_GB}, + {"GBK (Unified Chinese) encoding", Resource_FormatType_GBK}, + {"Big5 (Traditional Chinese) encoding", Resource_FormatType_Big5}, + //{"active system-defined locale; this value is strongly NOT recommended to use", Resource_FormatType_SystemLocale}, + {"ISO 8859-1 (Western European) encoding", Resource_FormatType_iso8859_1}, + {"ISO 8859-2 (Central European) encoding", Resource_FormatType_iso8859_2}, + {"ISO 8859-3 (Turkish) encoding", Resource_FormatType_iso8859_3}, + {"ISO 8859-4 (Northern European) encoding", Resource_FormatType_iso8859_4}, + {"ISO 8859-5 (Cyrillic) encoding", Resource_FormatType_iso8859_5}, + {"ISO 8859-6 (Arabic) encoding", Resource_FormatType_iso8859_6}, + {"ISO 8859-7 (Greek) encoding", Resource_FormatType_iso8859_7}, + {"ISO 8859-8 (Hebrew) encoding", Resource_FormatType_iso8859_8}, + {"ISO 8859-9 (Turkish) encoding", Resource_FormatType_iso8859_9}, + {"ISO 850 (Western European) encoding", Resource_FormatType_CP850}, + {"CP1250 (Central European) encoding", Resource_FormatType_CP1250}, + {"CP1251 (Cyrillic) encoding", Resource_FormatType_CP1251}, + {"CP1252 (Western European) encoding", Resource_FormatType_CP1252}, + {"CP1253 (Greek) encoding", Resource_FormatType_CP1253}, + {"CP1254 (Turkish) encoding", Resource_FormatType_CP1254}, + {"CP1255 (Hebrew) encoding", Resource_FormatType_CP1255}, + {"CP1256 (Arabic) encoding", Resource_FormatType_CP1256}, + {"CP1257 (Baltic) encoding", Resource_FormatType_CP1257}, + {"CP1258 (Vietnamese) encoding", Resource_FormatType_CP1258}, + }; +#endif }; } //namespace OCAF diff --git a/src/Mod/Part/Gui/DlgImportStep.cpp b/src/Mod/Part/Gui/DlgImportStep.cpp index a0438fff90..6a0b9bd71a 100644 --- a/src/Mod/Part/Gui/DlgImportStep.cpp +++ b/src/Mod/Part/Gui/DlgImportStep.cpp @@ -27,7 +27,7 @@ #include "DlgImportStep.h" #include "ui_DlgImportStep.h" - +#include using namespace PartGui; @@ -36,7 +36,6 @@ DlgImportStep::DlgImportStep(QWidget* parent) , ui(new Ui_DlgImportStep) { ui->setupUi(this); - Part::OCAF::ImportExportSettings settings; ui->checkBoxMergeCompound->setChecked(settings.getReadShapeCompoundMode()); ui->checkBoxImportHiddenObj->setChecked(settings.getImportHiddenObject()); @@ -45,6 +44,20 @@ DlgImportStep::DlgImportStep(QWidget* parent) ui->checkBoxReduceObjects->setChecked(settings.getReduceObjects()); ui->checkBoxExpandCompound->setChecked(settings.getExpandCompound()); ui->checkBoxShowProgress->setChecked(settings.getShowProgress()); +#if OCC_VERSION_HEX >= 0x070800 + ui->checkBoxShowOnImport->setChecked(settings.getReadShowDialogImport()); + std::list codepagelist; + codepagelist = settings.getCodePageList(); + for (const auto& codePage : codepagelist) { + ui->comboBoxImportCodePage->addItem(QString::fromStdString(codePage.codePageName)); + } +#else + // hide options that not supported in this OCCT version (7.8.0) + ui->label_6->hide(); + ui->checkBoxShowOnImport->hide(); + ui->comboBoxImportCodePage->hide(); +#endif + } /** @@ -55,6 +68,10 @@ DlgImportStep::~DlgImportStep() = default; void DlgImportStep::saveSettings() { // (h)STEP of Import module +#if OCC_VERSION_HEX >= 0x070800 + ui->checkBoxShowOnImport->onSave(); + ui->comboBoxImportCodePage->onSave(); +#endif ui->checkBoxMergeCompound->onSave(); ui->checkBoxImportHiddenObj->onSave(); ui->checkBoxUseLinkGroup->onSave(); @@ -68,6 +85,10 @@ void DlgImportStep::saveSettings() void DlgImportStep::loadSettings() { // (h)STEP of Import module +#if OCC_VERSION_HEX >= 0x070800 + ui->checkBoxShowOnImport->onRestore(); + ui->comboBoxImportCodePage->onRestore(); +#endif ui->checkBoxMergeCompound->onRestore(); ui->checkBoxImportHiddenObj->onRestore(); ui->checkBoxUseLinkGroup->onRestore(); diff --git a/src/Mod/Part/Gui/DlgImportStep.ui b/src/Mod/Part/Gui/DlgImportStep.ui index 3c943c1c00..00661ca8b7 100644 --- a/src/Mod/Part/Gui/DlgImportStep.ui +++ b/src/Mod/Part/Gui/DlgImportStep.ui @@ -7,7 +7,7 @@ 0 0 445 - 292 + 365 @@ -20,6 +20,22 @@ Import + + + + If checked, this Dialog will be shown during Import + + + Show this Dialog when importing + + + ReadShowDialogImport + + + Mod/Import/hSTEP + + + @@ -133,6 +149,42 @@ during file reading (slower but higher details). + + + + + + true + + + + 197 + 0 + + + + CodePage + + + + + + + + 0 + 0 + + + + ImportCodePage + + + Mod/Import + + + + + @@ -208,7 +260,6 @@ during file reading (slower but higher details). checkBoxImportHiddenObj checkBoxReduceObjects checkBoxExpandCompound - checkBoxShowProgress checkBoxUseBaseName comboBoxImportMode