diff --git a/src/Mod/Fem/Gui/DlgSettingsFemCcx.ui b/src/Mod/Fem/Gui/DlgSettingsFemCcx.ui index 9288fc4351..ac0346f146 100644 --- a/src/Mod/Fem/Gui/DlgSettingsFemCcx.ui +++ b/src/Mod/Fem/Gui/DlgSettingsFemCcx.ui @@ -34,34 +34,8 @@ - - - - CalculiX binary - - - - - - - Search in known binary directories - - - true - - - UseStandardCcxLocation - - - Mod/Fem/Ccx - - - - - false - 100 @@ -69,15 +43,12 @@ - CCX binary path + CalculiX path - - - false - + 0 @@ -968,37 +939,5 @@ Only takes effect if 'Pipeline only' is enabled - - cb_ccx_binary_std - toggled(bool) - l_ccx_binary_path - setDisabled(bool) - - - 406 - 45 - - - 148 - 68 - - - - - cb_ccx_binary_std - toggled(bool) - fc_ccx_binary_path - setDisabled(bool) - - - 406 - 45 - - - 406 - 68 - - - diff --git a/src/Mod/Fem/Gui/DlgSettingsFemCcxImp.cpp b/src/Mod/Fem/Gui/DlgSettingsFemCcxImp.cpp index e668dce16b..8ef54f9c31 100644 --- a/src/Mod/Fem/Gui/DlgSettingsFemCcxImp.cpp +++ b/src/Mod/Fem/Gui/DlgSettingsFemCcxImp.cpp @@ -26,6 +26,7 @@ #include "PreCompiled.h" #ifndef _PreComp_ #include +#include #include #endif @@ -47,9 +48,9 @@ DlgSettingsFemCcxImp::DlgSettingsFemCcxImp(QWidget* parent) ui->dsb_ccx_initial_time_increment->setMaximum(std::numeric_limits::max()); connect(ui->fc_ccx_binary_path, - &Gui::PrefFileChooser::fileNameChanged, + &Gui::PrefFileChooser::fileNameSelected, this, - &DlgSettingsFemCcxImp::onfileNameChanged); + &DlgSettingsFemCcxImp::onfileNameSelected); } DlgSettingsFemCcxImp::~DlgSettingsFemCcxImp() = default; @@ -83,7 +84,6 @@ void DlgSettingsFemCcxImp::saveSettings() ui->cb_int_editor->onSave(); ui->fc_ext_editor->onSave(); - ui->cb_ccx_binary_std->onSave(); ui->fc_ccx_binary_path->onSave(); ui->cb_split_inp_writer->onSave(); } @@ -112,7 +112,6 @@ void DlgSettingsFemCcxImp::loadSettings() ui->cb_int_editor->onRestore(); ui->fc_ext_editor->onRestore(); - ui->cb_ccx_binary_std->onRestore(); ui->fc_ccx_binary_path->onRestore(); ui->cb_split_inp_writer->onRestore(); @@ -148,14 +147,10 @@ void DlgSettingsFemCcxImp::changeEvent(QEvent* e) } } -void DlgSettingsFemCcxImp::onfileNameChanged(QString FileName) +void DlgSettingsFemCcxImp::onfileNameSelected(const QString& fileName) { - if (!QFileInfo::exists(FileName)) { - QMessageBox::critical(this, - tr("File does not exist"), - tr("The specified executable\n'%1'\n does not exist!\n" - "Specify another file.") - .arg(FileName)); + if (!fileName.isEmpty() && QStandardPaths::findExecutable(fileName).isEmpty()) { + QMessageBox::critical(this, tr("CalculiX"), tr("Executable '%1' not found").arg(fileName)); } } diff --git a/src/Mod/Fem/Gui/DlgSettingsFemCcxImp.h b/src/Mod/Fem/Gui/DlgSettingsFemCcxImp.h index 792602a75a..048183c4eb 100644 --- a/src/Mod/Fem/Gui/DlgSettingsFemCcxImp.h +++ b/src/Mod/Fem/Gui/DlgSettingsFemCcxImp.h @@ -42,7 +42,7 @@ public: ~DlgSettingsFemCcxImp() override; protected Q_SLOTS: - void onfileNameChanged(QString FileName); + void onfileNameSelected(const QString& fileName); protected: void saveSettings() override; diff --git a/src/Mod/Fem/Gui/DlgSettingsFemElmer.ui b/src/Mod/Fem/Gui/DlgSettingsFemElmer.ui index 04ec2bd10f..205c3d2e2c 100644 --- a/src/Mod/Fem/Gui/DlgSettingsFemElmer.ui +++ b/src/Mod/Fem/Gui/DlgSettingsFemElmer.ui @@ -33,17 +33,20 @@ - + + + + 100 + 0 + + - ElmerGrid + ElmerSolver path - - - - false - + + 0 @@ -69,7 +72,7 @@ - <html><head/><body><p>Leave blank to use default Elmer elmer binary file</p><p><span style=" font-weight:600;">Note:</span> To use multithreading you must specify here<br> the executable variant with the suffix &quot;_mpi&quot;.</p></body></html> + Leave blank to use default ElmerSolver binary file elmerBinaryPath @@ -79,27 +82,21 @@ - - + + + + + 100 + 0 + + - Search in known binary directories - - - true - - - UseStandardGridLocation - - - Mod/Fem/Elmer + ElmerGrid path - - - false - + 0 @@ -135,61 +132,6 @@ - - - - ElmerSolver - - - - - - - Search in known binary directories - - - true - - - UseStandardElmerLocation - - - Mod/Fem/Elmer - - - - - - - false - - - - 100 - 0 - - - - ElmerGrid binary path - - - - - - - false - - - - 100 - 0 - - - - ElmerSolver binary path - - - @@ -198,40 +140,27 @@ Options - - - - - Multithreading - - - - - - - - - true - + + + + + - CPU cores to be used + Number of processes - - - - true + + + + Qt::AlignLeft|Qt::AlignTrailing|Qt::AlignVCenter - <html><head/><body><p><span style=" font-weight:600;">Note:</span> It is recommended to use an even number of cores to benefit from mesh symmetries. (Using 8 cores can be faster than 9 cores.)<br/><span style=" font-weight:600;">Note too:</span> In extreme cases ElmerSolver might not converge if the core number is too high.</p></body></html> + Number of parallel tasks. Set to `1` if Elmer does not use MPI.<br>It is recommended to use an even number of cores to benefit from mesh symmetries<br>(Using 8 cores can be faster than 9 cores).<br>In extreme cases ElmerSolver might not converge if the core number is too high. 1 - - 32 - UseNumberOfCores @@ -240,48 +169,27 @@ - - - - Qt::Horizontal + + + + Merge mesh volume regions processed by each CPU core to make boundaries invisible. - - - 40 - 20 - + + Filter results - + + true + + + FilterMultiCPUResults + + + Mod/Fem/Elmer + + - - - - Multi-core CPU support - - - - - - - The mesh volume regions processed by each CPU core -will be merged to make the volume boundaries invisible. - - - Filter results - - - true - - - FilterMultiCPUResults - - - Mod/Fem/Elmer - - - @@ -292,7 +200,7 @@ will be merged to make the volume boundaries invisible. - + Save result in binary format @@ -311,7 +219,7 @@ will be merged to make the volume boundaries invisible. - + Save the index of geometric entities @@ -352,11 +260,6 @@ will be merged to make the volume boundaries invisible. - - Gui::FileChooser - QWidget -
Gui/FileDialog.h
-
Gui::PrefFileChooser Gui::FileChooser @@ -376,70 +279,4 @@ will be merged to make the volume boundaries invisible. - - - cb_grid_binary_std - toggled(bool) - l_grid_binary_path - setDisabled(bool) - - - 247 - 45 - - - 71 - 68 - - - - - cb_grid_binary_std - toggled(bool) - fc_grid_binary_path - setDisabled(bool) - - - 247 - 45 - - - 247 - 68 - - - - - cb_elmer_binary_std - toggled(bool) - fc_elmer_binary_path - setDisabled(bool) - - - 247 - 91 - - - 247 - 114 - - - - - cb_elmer_binary_std - toggled(bool) - l_elmer_binary_path - setDisabled(bool) - - - 247 - 91 - - - 71 - 114 - - - - diff --git a/src/Mod/Fem/Gui/DlgSettingsFemElmerImp.cpp b/src/Mod/Fem/Gui/DlgSettingsFemElmerImp.cpp index adbd9ed9f4..a40fa3c9b7 100644 --- a/src/Mod/Fem/Gui/DlgSettingsFemElmerImp.cpp +++ b/src/Mod/Fem/Gui/DlgSettingsFemElmerImp.cpp @@ -25,7 +25,7 @@ #include "PreCompiled.h" #ifndef _PreComp_ #include -#include +#include #endif #include "DlgSettingsFemElmerImp.h" @@ -40,56 +40,40 @@ DlgSettingsFemElmerImp::DlgSettingsFemElmerImp(QWidget* parent) { ui->setupUi(this); - // determine number of CPU cores - processor_count = QThread::idealThreadCount(); - ui->sb_elmer_num_cores->setMaximum(processor_count); - connect(ui->fc_grid_binary_path, - &Gui::PrefFileChooser::fileNameChanged, + &Gui::PrefFileChooser::fileNameSelected, this, - &DlgSettingsFemElmerImp::onfileNameChanged); + &DlgSettingsFemElmerImp::onfileNameSelected); connect(ui->fc_elmer_binary_path, - &Gui::PrefFileChooser::fileNameChanged, + &Gui::PrefFileChooser::fileNameSelected, this, - &DlgSettingsFemElmerImp::onfileNameChanged); - connect(ui->fc_elmer_binary_path, - &Gui::PrefFileChooser::fileNameChanged, - this, - &DlgSettingsFemElmerImp::onfileNameChangedMT); - connect(ui->sb_elmer_num_cores, - qOverload(&Gui::PrefSpinBox::valueChanged), - this, - &DlgSettingsFemElmerImp::onCoresValueChanged); + &DlgSettingsFemElmerImp::onfileNameSelected); } DlgSettingsFemElmerImp::~DlgSettingsFemElmerImp() = default; void DlgSettingsFemElmerImp::saveSettings() { - ui->cb_elmer_binary_std->onSave(); ui->fc_elmer_binary_path->onSave(); - - ui->cb_grid_binary_std->onSave(); ui->fc_grid_binary_path->onSave(); - ui->sb_elmer_num_cores->onSave(); - ui->cb_elmer_filtering->onSave(); - ui->ckb_elmer_format->onSave(); - ui->ckb_elmer_geom_id->onSave(); + ui->sb_num_processes->onSave(); + + ui->cb_filtering->onSave(); + ui->ckb_binary_format->onSave(); + ui->ckb_geom_id->onSave(); } void DlgSettingsFemElmerImp::loadSettings() { - ui->cb_elmer_binary_std->onRestore(); ui->fc_elmer_binary_path->onRestore(); - - ui->cb_grid_binary_std->onRestore(); ui->fc_grid_binary_path->onRestore(); - ui->sb_elmer_num_cores->onRestore(); - ui->cb_elmer_filtering->onRestore(); - ui->ckb_elmer_format->onRestore(); - ui->ckb_elmer_geom_id->onRestore(); + ui->sb_num_processes->onRestore(); + + ui->cb_filtering->onRestore(); + ui->ckb_binary_format->onRestore(); + ui->ckb_geom_id->onRestore(); } /** @@ -105,55 +89,10 @@ void DlgSettingsFemElmerImp::changeEvent(QEvent* e) } } -void DlgSettingsFemElmerImp::onfileNameChanged(QString FileName) +void DlgSettingsFemElmerImp::onfileNameSelected(const QString& fileName) { - if (!QFileInfo::exists(FileName)) { - QMessageBox::critical(this, - tr("File does not exist"), - tr("The specified executable\n'%1'\n does not exist!\n" - "Specify another file.") - .arg(FileName)); - } -} - -void DlgSettingsFemElmerImp::onfileNameChangedMT(QString FileName) -{ - ui->sb_elmer_num_cores->setMaximum(processor_count); - - if (ui->sb_elmer_num_cores->value() == 1) { - return; - } - -#if defined(FC_OS_WIN32) - // name ends with "_mpi.exe" - if (!FileName.endsWith(QLatin1String("_mpi.exe"))) { - QMessageBox::warning(this, - tr("FEM Elmer: Not suitable for multithreading"), - tr("Wrong Elmer setting: You use more than one CPU core.\n" - "Therefore an executable with the suffix '_mpi.exe' is required.")); - ui->sb_elmer_num_cores->setValue(1); - ui->sb_elmer_num_cores->setMaximum(1); - return; - } -#elif defined(FC_OS_LINUX) || defined(FC_OS_CYGWIN) || defined(FC_OS_MACOSX) || defined(FC_OS_BSD) - // name ends with "_mpi" - if (!FileName.endsWith(QLatin1String("_mpi"))) { - QMessageBox::warning(this, - tr("FEM Elmer: Not suitable for multithreading"), - tr("Wrong Elmer setting: You use more than one CPU core.\n" - "Therefore an executable with the suffix '_mpi' is required.")); - ui->sb_elmer_num_cores->setValue(1); - ui->sb_elmer_num_cores->setMaximum(1); - return; - } -#endif -} - -void DlgSettingsFemElmerImp::onCoresValueChanged(int cores) -{ - if (cores > 1) { - // check if the right executable is loaded - onfileNameChangedMT(ui->fc_elmer_binary_path->fileName()); + if (!fileName.isEmpty() && QStandardPaths::findExecutable(fileName).isEmpty()) { + QMessageBox::critical(this, tr("Elmer"), tr("Executable '%1' not found").arg(fileName)); } } diff --git a/src/Mod/Fem/Gui/DlgSettingsFemElmerImp.h b/src/Mod/Fem/Gui/DlgSettingsFemElmerImp.h index a5b5e11a9b..827dcfe136 100644 --- a/src/Mod/Fem/Gui/DlgSettingsFemElmerImp.h +++ b/src/Mod/Fem/Gui/DlgSettingsFemElmerImp.h @@ -41,9 +41,7 @@ public: ~DlgSettingsFemElmerImp() override; protected Q_SLOTS: - void onfileNameChanged(QString FileName); - void onfileNameChangedMT(QString FileName); - void onCoresValueChanged(int cores); + void onfileNameSelected(const QString& fileName); protected: void saveSettings() override; diff --git a/src/Mod/Fem/Gui/DlgSettingsFemGmsh.ui b/src/Mod/Fem/Gui/DlgSettingsFemGmsh.ui index 1549fbe5cd..fd3d875ef7 100644 --- a/src/Mod/Fem/Gui/DlgSettingsFemGmsh.ui +++ b/src/Mod/Fem/Gui/DlgSettingsFemGmsh.ui @@ -86,7 +86,7 @@ - Gmsh binary path + Gmsh path
diff --git a/src/Mod/Fem/Gui/DlgSettingsFemGmshImp.cpp b/src/Mod/Fem/Gui/DlgSettingsFemGmshImp.cpp index aa51594c4a..dc907b8340 100644 --- a/src/Mod/Fem/Gui/DlgSettingsFemGmshImp.cpp +++ b/src/Mod/Fem/Gui/DlgSettingsFemGmshImp.cpp @@ -83,15 +83,10 @@ void DlgSettingsFemGmshImp::changeEvent(QEvent* e) } } -void DlgSettingsFemGmshImp::onfileNameSelected(QString FileName) +void DlgSettingsFemGmshImp::onfileNameSelected(const QString& fileName) { - if (!FileName.isEmpty() && QStandardPaths::findExecutable(FileName).isEmpty()) { - QMessageBox::critical( - this, - tr("Not an executable binary"), - tr("The specified file \n'%1'\n does not exist or is not executable.\n" - "Specify another file.") - .arg(FileName)); + if (!fileName.isEmpty() && QStandardPaths::findExecutable(fileName).isEmpty()) { + QMessageBox::critical(this, tr("Gmsh"), tr("Executable '%1' not found").arg(fileName)); } } diff --git a/src/Mod/Fem/Gui/DlgSettingsFemGmshImp.h b/src/Mod/Fem/Gui/DlgSettingsFemGmshImp.h index aeb5737b4b..a9e3cd5843 100644 --- a/src/Mod/Fem/Gui/DlgSettingsFemGmshImp.h +++ b/src/Mod/Fem/Gui/DlgSettingsFemGmshImp.h @@ -41,7 +41,7 @@ public: ~DlgSettingsFemGmshImp() override; protected Q_SLOTS: - void onfileNameSelected(QString FileName); + void onfileNameSelected(const QString& fileName); protected: void saveSettings() override; diff --git a/src/Mod/Fem/Gui/DlgSettingsFemMystran.ui b/src/Mod/Fem/Gui/DlgSettingsFemMystran.ui index f8c5e82b28..4b0fd76606 100644 --- a/src/Mod/Fem/Gui/DlgSettingsFemMystran.ui +++ b/src/Mod/Fem/Gui/DlgSettingsFemMystran.ui @@ -34,22 +34,6 @@ - - - - Search in known binary directories - - - true - - - UseStandardMystranLocation - - - Mod/Fem/Mystran - - - @@ -62,15 +46,12 @@ - Mystran binary path + Mystran path - - - false - + 0 @@ -96,7 +77,7 @@ - Leave blank to use default Mystran binary file location + Leave blank to use default mystran binary file mystranBinaryPath @@ -170,38 +151,4 @@ - - - cb_mystran_binary_std - toggled(bool) - l_mystran_binary_path - setDisabled(bool) - - - 406 - 45 - - - 148 - 68 - - - - - cb_mystran_binary_std - toggled(bool) - fc_mystran_binary_path - setDisabled(bool) - - - 406 - 45 - - - 406 - 68 - - - - diff --git a/src/Mod/Fem/Gui/DlgSettingsFemMystranImp.cpp b/src/Mod/Fem/Gui/DlgSettingsFemMystranImp.cpp index d5eef4e3bb..e7692a00de 100644 --- a/src/Mod/Fem/Gui/DlgSettingsFemMystranImp.cpp +++ b/src/Mod/Fem/Gui/DlgSettingsFemMystranImp.cpp @@ -25,6 +25,7 @@ #include "PreCompiled.h" #ifndef _PreComp_ #include +#include #endif #include "DlgSettingsFemMystranImp.h" @@ -40,23 +41,21 @@ DlgSettingsFemMystranImp::DlgSettingsFemMystranImp(QWidget* parent) ui->setupUi(this); connect(ui->fc_mystran_binary_path, - &Gui::PrefFileChooser::fileNameChanged, + &Gui::PrefFileChooser::fileNameSelected, this, - &DlgSettingsFemMystranImp::onfileNameChanged); + &DlgSettingsFemMystranImp::onfileNameSelected); } DlgSettingsFemMystranImp::~DlgSettingsFemMystranImp() = default; void DlgSettingsFemMystranImp::saveSettings() { - ui->cb_mystran_binary_std->onSave(); ui->fc_mystran_binary_path->onSave(); ui->cb_mystran_write_comments->onSave(); } void DlgSettingsFemMystranImp::loadSettings() { - ui->cb_mystran_binary_std->onRestore(); ui->fc_mystran_binary_path->onRestore(); ui->cb_mystran_write_comments->onRestore(); } @@ -74,14 +73,10 @@ void DlgSettingsFemMystranImp::changeEvent(QEvent* e) } } -void DlgSettingsFemMystranImp::onfileNameChanged(QString FileName) +void DlgSettingsFemMystranImp::onfileNameSelected(const QString& fileName) { - if (!QFileInfo::exists(FileName)) { - QMessageBox::critical(this, - tr("File does not exist"), - tr("The specified executable\n'%1'\n does not exist!\n" - "Specify another file.") - .arg(FileName)); + if (!fileName.isEmpty() && QStandardPaths::findExecutable(fileName).isEmpty()) { + QMessageBox::critical(this, tr("Mystran"), tr("Executable '%1' not found").arg(fileName)); } } diff --git a/src/Mod/Fem/Gui/DlgSettingsFemMystranImp.h b/src/Mod/Fem/Gui/DlgSettingsFemMystranImp.h index e00f3f6bdb..08a1a2d96c 100644 --- a/src/Mod/Fem/Gui/DlgSettingsFemMystranImp.h +++ b/src/Mod/Fem/Gui/DlgSettingsFemMystranImp.h @@ -42,7 +42,7 @@ public: ~DlgSettingsFemMystranImp() override; protected Q_SLOTS: - void onfileNameChanged(QString FileName); + void onfileNameSelected(const QString& fileName); protected: void saveSettings() override; diff --git a/src/Mod/Fem/Gui/DlgSettingsFemZ88.ui b/src/Mod/Fem/Gui/DlgSettingsFemZ88.ui index 3de679c26f..53c18dedbf 100644 --- a/src/Mod/Fem/Gui/DlgSettingsFemZ88.ui +++ b/src/Mod/Fem/Gui/DlgSettingsFemZ88.ui @@ -34,33 +34,8 @@ - - - - - 0 - 20 - - - - Search in known binary directories - - - true - - - UseStandardZ88Location - - - Mod/Fem/Z88 - - - - + - - true - 0 @@ -74,15 +49,12 @@ - z88r binary path + z88r path - - - - false - + + 0 @@ -92,7 +64,7 @@ 0 - 20 + 0 @@ -108,7 +80,7 @@ - Leave blank to use default Z88, z88r binary file + Leave blank to use default z88r binary file z88BinaryPath @@ -332,38 +304,4 @@ that "MAXKOI" needs to be increased. - - - cb_z88_binary_std - toggled(bool) - l_z88_binary_path - setDisabled(bool) - - - 406 - 45 - - - 148 - 68 - - - - - cb_z88_binary_std - toggled(bool) - fc_z88_binary_path - setDisabled(bool) - - - 406 - 45 - - - 406 - 68 - - - - diff --git a/src/Mod/Fem/Gui/DlgSettingsFemZ88Imp.cpp b/src/Mod/Fem/Gui/DlgSettingsFemZ88Imp.cpp index 91cab3df54..ddbd2b7b8d 100644 --- a/src/Mod/Fem/Gui/DlgSettingsFemZ88Imp.cpp +++ b/src/Mod/Fem/Gui/DlgSettingsFemZ88Imp.cpp @@ -25,6 +25,7 @@ #include "PreCompiled.h" #ifndef _PreComp_ #include +#include #endif #include @@ -42,16 +43,15 @@ DlgSettingsFemZ88Imp::DlgSettingsFemZ88Imp(QWidget* parent) ui->setupUi(this); connect(ui->fc_z88_binary_path, - &Gui::PrefFileChooser::fileNameChanged, + &Gui::PrefFileChooser::fileNameSelected, this, - &DlgSettingsFemZ88Imp::onfileNameChanged); + &DlgSettingsFemZ88Imp::onfileNameSelected); } DlgSettingsFemZ88Imp::~DlgSettingsFemZ88Imp() = default; void DlgSettingsFemZ88Imp::saveSettings() { - ui->cb_z88_binary_std->onSave(); ui->fc_z88_binary_path->onSave(); ParameterGrp::handle hGrp = App::GetApplication().GetParameterGroupByPath( @@ -66,7 +66,6 @@ void DlgSettingsFemZ88Imp::saveSettings() void DlgSettingsFemZ88Imp::loadSettings() { - ui->cb_z88_binary_std->onRestore(); ui->fc_z88_binary_path->onRestore(); ui->cmb_solver->onRestore(); ui->sb_Z88_MaxGS->onRestore(); @@ -100,33 +99,11 @@ void DlgSettingsFemZ88Imp::changeEvent(QEvent* e) } } -void DlgSettingsFemZ88Imp::onfileNameChanged(QString FileName) +void DlgSettingsFemZ88Imp::onfileNameSelected(const QString& fileName) { - if (!QFileInfo::exists(FileName)) { - QMessageBox::critical(this, - tr("File does not exist"), - tr("The specified z88r executable\n'%1'\n does not exist!\n" - "Specify another file.") - .arg(FileName)); - return; + if (!fileName.isEmpty() && QStandardPaths::findExecutable(fileName).isEmpty()) { + QMessageBox::critical(this, tr("Z88"), tr("Executable '%1' not found").arg(fileName)); } - - // since the Z88 folder is full of files like "z88h", "z88o" etc. one can easily make a - // mistake and is then lost why the solver fails. Therefore check for the correct filename. - auto strName = FileName.toStdString(); -#if defined(FC_OS_WIN32) - if (strName.substr(strName.length() - 8) != "z88r.exe") { - QMessageBox::critical(this, - tr("Wrong file"), - tr("You must specify the path to the z88r.exe!")); - return; - } -#elif defined(FC_OS_LINUX) || defined(FC_OS_CYGWIN) || defined(FC_OS_MACOSX) || defined(FC_OS_BSD) - if (strName.substr(strName.length() - 4) != "z88r") { - QMessageBox::critical(this, tr("Wrong file"), tr("You must specify the path to the z88r!")); - return; - } -#endif } #include "moc_DlgSettingsFemZ88Imp.cpp" diff --git a/src/Mod/Fem/Gui/DlgSettingsFemZ88Imp.h b/src/Mod/Fem/Gui/DlgSettingsFemZ88Imp.h index 9097756226..3cef1bea80 100644 --- a/src/Mod/Fem/Gui/DlgSettingsFemZ88Imp.h +++ b/src/Mod/Fem/Gui/DlgSettingsFemZ88Imp.h @@ -42,7 +42,7 @@ public: ~DlgSettingsFemZ88Imp() override; protected Q_SLOTS: - void onfileNameChanged(QString FileName); + void onfileNameSelected(const QString& fileName); protected: void saveSettings() override; diff --git a/src/Mod/Fem/femsolver/settings.py b/src/Mod/Fem/femsolver/settings.py index 90d3bd5292..ff1a520b2f 100644 --- a/src/Mod/Fem/femsolver/settings.py +++ b/src/Mod/Fem/femsolver/settings.py @@ -214,10 +214,9 @@ class _SolverDlg: WRITE_COMMENTS_PARAM = "writeCommentsToInputFile" - def __init__(self, default, param_path, use_default, custom_path): + def __init__(self, default, param_path, custom_path): self.default = default self.param_path = param_path - self.use_default = use_default self.custom_path = custom_path self.param_group = FreeCAD.ParamGet(self.param_path) @@ -229,15 +228,11 @@ class _SolverDlg: # TODO the binaries provided with the FreeCAD distribution should be found # without any additional user input # see ccxttols, it works for Windows and Linux there - binary = self.default + binary = self.param_group.GetString(self.custom_path) + if not binary: + binary = self.default FreeCAD.Console.PrintLog(f"Solver binary path default: {binary} \n") - # check if use_default is set to True - # if True the standard binary path will be overwritten with a user binary path - if self.param_group.GetBool(self.use_default, True) is False: - binary = self.param_group.GetString(self.custom_path) - FreeCAD.Console.PrintLog(f"Solver binary path user setting: {binary} \n") - # get the whole binary path name for the given command or binary path and return it # None is returned if the binary has not been found # The user does not know what exactly has going wrong. @@ -264,31 +259,26 @@ _SOLVER_PARAM = { "Calculix": _SolverDlg( default="ccx", param_path=_PARAM_PATH + "Ccx", - use_default="UseStandardCcxLocation", custom_path="ccxBinaryPath", ), "ElmerSolver": _SolverDlg( default="ElmerSolver", param_path=_PARAM_PATH + "Elmer", - use_default="UseStandardElmerLocation", custom_path="elmerBinaryPath", ), "ElmerGrid": _SolverDlg( default="ElmerGrid", param_path=_PARAM_PATH + "Elmer", - use_default="UseStandardGridLocation", custom_path="gridBinaryPath", ), "Mystran": _SolverDlg( default="mystran", param_path=_PARAM_PATH + "Mystran", - use_default="UseStandardMystranLocation", custom_path="mystranBinaryPath", ), "Z88": _SolverDlg( default="z88r", param_path=_PARAM_PATH + "Z88", - use_default="UseStandardZ88Location", custom_path="z88BinaryPath", ), } diff --git a/src/Mod/Fem/femtaskpanels/task_solver_ccxtools.py b/src/Mod/Fem/femtaskpanels/task_solver_ccxtools.py index 91143c5dbc..d1909a0067 100644 --- a/src/Mod/Fem/femtaskpanels/task_solver_ccxtools.py +++ b/src/Mod/Fem/femtaskpanels/task_solver_ccxtools.py @@ -68,7 +68,10 @@ class _TaskPanel: # task panel, may be deactivate write and run button. self.fea = ccx(solver_object) self.fea.setup_working_dir() - self.fea.setup_ccx() + try: + self.fea.setup_ccx() + except FileNotFoundError as e: + FreeCAD.Console.PrintWarning(e.args[0]) self.Calculix = QtCore.QProcess() self.Timer = QtCore.QTimer() diff --git a/src/Mod/Fem/femtools/ccxtools.py b/src/Mod/Fem/femtools/ccxtools.py index 311ae865a6..058269658b 100644 --- a/src/Mod/Fem/femtools/ccxtools.py +++ b/src/Mod/Fem/femtools/ccxtools.py @@ -32,6 +32,7 @@ __url__ = "https://www.freecad.org" import os import sys import subprocess +import shutil import FreeCAD @@ -400,52 +401,24 @@ class FemToolsCcx(QtCore.QRunnable, QtCore.QObject): Defaults to 'CalculiX'. Expected output from `ccx` when run empty. """ - error_title = "No or wrong CalculiX binary ccx" - error_message = "" - from platform import system + self.ccx_binary = ccx_binary + if self.ccx_binary is None: + self.ccx_binary = FreeCAD.ParamGet( + "User parameter:BaseApp/Preferences/Mod/Fem/Ccx" + ).GetString("ccxBinaryPath", "") - ccx_std_location = FreeCAD.ParamGet( - "User parameter:BaseApp/Preferences/Mod/Fem/Ccx" - ).GetBool("UseStandardCcxLocation", True) - if ccx_std_location: - if system() == "Windows": - ccx_path = FreeCAD.getHomePath() + "bin/ccx.exe" - FreeCAD.ParamGet("User parameter:BaseApp/Preferences/Mod/Fem/Ccx").SetString( - "ccxBinaryPath", ccx_path - ) - self.ccx_binary = ccx_path - elif system() in ("Linux", "Darwin"): - p1 = subprocess.Popen(["which", "ccx"], stdout=subprocess.PIPE) - if p1.wait() == 0: - ccx_path = p1.stdout.read().decode("utf8").split("\n")[0] - elif p1.wait() == 1: - error_message = ( - "FEM: CalculiX binary ccx not found in " - "standard system binary path. " - "Please install ccx or set path to binary " - "in FEM preferences tab CalculiX.\n" - ) - if FreeCAD.GuiUp: - QtGui.QMessageBox.critical(None, error_title, error_message) - raise Exception(error_message) - self.ccx_binary = ccx_path + if not self.ccx_binary: + # search in system + self.ccx_binary = shutil.which("ccx") else: - if not ccx_binary: - self.ccx_prefs = FreeCAD.ParamGet("User parameter:BaseApp/Preferences/Mod/Fem/Ccx") - ccx_binary = self.ccx_prefs.GetString("ccxBinaryPath", "") - if not ccx_binary: - FreeCAD.ParamGet("User parameter:BaseApp/Preferences/Mod/Fem/Ccx").SetBool( - "UseStandardCcxLocation", True - ) - error_message = ( - "FEM: CalculiX binary ccx path not set at all. " - "The use of standard path was activated in " - "FEM preferences tab CalculiX. Please try again!\n" - ) - if FreeCAD.GuiUp: - QtGui.QMessageBox.critical(None, error_title, error_message) - FreeCAD.Console.PrintError(error_message) - self.ccx_binary = ccx_binary + # check user defined path + self.ccx_binary = shutil.which(self.ccx_binary) + + if self.ccx_binary is None: + raise FileNotFoundError( + "CalculiX binary not found\n" + "Install CalculiX or set path to binary in FEM user preferences" + ) ccx_stdout = None ccx_stderr = None @@ -474,7 +447,7 @@ class FemToolsCcx(QtCore.QRunnable, QtCore.QObject): error_message = ( "FEM: CalculiX binary ccx '{}' not found. " "Please set the CalculiX binary ccx path in " - "FEM preferences tab CalculiX.\n".format(ccx_binary) + "FEM preferences tab CalculiX.\n".format(self.ccx_binary) ) if FreeCAD.GuiUp: QtGui.QMessageBox.critical(None, error_title, error_message) @@ -487,7 +460,7 @@ class FemToolsCcx(QtCore.QRunnable, QtCore.QObject): "contain expected phrase '{}'. " "There are some problems when running the ccx binary. " "Check if ccx runs standalone without FreeCAD.\n".format( - ccx_binary, ccx_stdout, ccx_binary_sig + self.ccx_binary, ccx_stdout, ccx_binary_sig ) ) if FreeCAD.GuiUp: