From a285e89b2708de427fdce5b3b981a3ef630f5a4d Mon Sep 17 00:00:00 2001 From: Bernd Hahnebach Date: Fri, 17 Jan 2020 08:01:03 +0100 Subject: [PATCH 1/5] FEM: unit tests, improve ccx tests --- src/Mod/Fem/femtest/app/test_ccxtools.py | 27 +++++++++++++++--------- 1 file changed, 17 insertions(+), 10 deletions(-) diff --git a/src/Mod/Fem/femtest/app/test_ccxtools.py b/src/Mod/Fem/femtest/app/test_ccxtools.py index aae660ceb4..337a6e8a8b 100644 --- a/src/Mod/Fem/femtest/app/test_ccxtools.py +++ b/src/Mod/Fem/femtest/app/test_ccxtools.py @@ -549,10 +549,24 @@ class TestCcxTools(unittest.TestCase): def test_6_contact_shell_shell( self ): - test_name = "contact shell shell analysis test" - base_name = "contact_shell_shell" - test_dir = "FEM_ccx_contact_shell_shell" + # set up the example + from femexamples import contact_shell_shell as shellcontact + shellcontact.setup(self.active_doc, "ccxtools") + # test input file writing + self.input_file_writing_test( + test_name="contact shell shell analysis test", + base_name="contact_shell_shell", + test_dir="FEM_ccx_contact_shell_shell", + ) + + # ******************************************************************************************** + def input_file_writing_test( + self, + test_name, + base_name, + test_dir + ): fcc_print( "\n--------------- " "Start of FEM ccxtools {}" @@ -560,13 +574,6 @@ class TestCcxTools(unittest.TestCase): .format(test_name) ) - # set up the example - from femexamples import contact_shell_shell as shellcontact - shellcontact.setup(self.active_doc, "ccxtools") - - # code from here is independent, TODO put in separate def - # adding more inp file tests would be very simple ... - # set up analysis analysis = self.active_doc.Analysis solver_object = self.active_doc.CalculiXccxTools analysis_dir = testtools.get_unit_test_tmp_dir( From 1a8df1ab03975277f594e1f6ce75ed94f15b438c Mon Sep 17 00:00:00 2001 From: wmayer Date: Fri, 17 Jan 2020 15:06:17 +0100 Subject: [PATCH 2/5] Gui: [skip ci] in Gesture style handle release instead of press events for the keys: H, PgUp, PgDown For more details see: https://forum.freecadweb.org/viewtopic.php?f=8&t=42408&start=10#p361248 --- src/Gui/GestureNavigationStyle.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Gui/GestureNavigationStyle.cpp b/src/Gui/GestureNavigationStyle.cpp index 9f4b1143eb..662bd2eed7 100644 --- a/src/Gui/GestureNavigationStyle.cpp +++ b/src/Gui/GestureNavigationStyle.cpp @@ -324,16 +324,16 @@ public: bool press = (kbev->getState() == SoKeyboardEvent::DOWN); switch (kbev->getKey()) { case SoKeyboardEvent::H: - if (press) + if (!press) ns.onSetRotationCenter(kbev->getPosition()); break; case SoKeyboardEvent::PAGE_UP: - if(press){ + if(!press){ ns.doZoom(ns.viewer->getSoRenderManager()->getCamera(), true, posn); } break; case SoKeyboardEvent::PAGE_DOWN: - if(press){ + if(!press){ ns.doZoom(ns.viewer->getSoRenderManager()->getCamera(), false, posn); } break; From 298b1d49accef8f92947d70165521d4ff85415dd Mon Sep 17 00:00:00 2001 From: wmayer Date: Fri, 17 Jan 2020 22:57:25 +0100 Subject: [PATCH 3/5] Gui: [skip ci] clear language combo box when loading settings --- src/Gui/DlgGeneralImp.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Gui/DlgGeneralImp.cpp b/src/Gui/DlgGeneralImp.cpp index 881589b4d6..4dfcd10260 100644 --- a/src/Gui/DlgGeneralImp.cpp +++ b/src/Gui/DlgGeneralImp.cpp @@ -223,6 +223,7 @@ void DlgGeneralImp::loadSettings() int index = 1; TStringMap list = Translator::instance()->supportedLocales(); + ui->Languages->clear(); ui->Languages->addItem(QString::fromLatin1("English"), QByteArray("English")); for (TStringMap::iterator it = list.begin(); it != list.end(); ++it, index++) { QByteArray lang = it->first.c_str(); From fbd51918ff9c9fb2eef2a494263b3cfb28326c03 Mon Sep 17 00:00:00 2001 From: wmayer Date: Fri, 17 Jan 2020 23:00:26 +0100 Subject: [PATCH 4/5] Gui: [skip ci] add method to get bounding boxes of the fixed and movable groups of manual alignment --- src/Gui/ManualAlignment.cpp | 25 +++++++++++++++++++++++++ src/Gui/ManualAlignment.h | 6 ++++++ 2 files changed, 31 insertions(+) diff --git a/src/Gui/ManualAlignment.cpp b/src/Gui/ManualAlignment.cpp index 71f5546b3c..ccb0f2d8c2 100644 --- a/src/Gui/ManualAlignment.cpp +++ b/src/Gui/ManualAlignment.cpp @@ -244,6 +244,21 @@ int AlignmentGroup::count() const return this->_views.size(); } +Base::BoundBox3d AlignmentGroup::getBoundingBox() const +{ + Base::BoundBox3d box; + std::vector::const_iterator it; + for (it = this->_views.begin(); it != this->_views.end(); ++it) { + if ((*it)->isDerivedFrom(Gui::ViewProviderGeometryObject::getClassTypeId())) { + App::GeoFeature* geo = static_cast((*it)->getObject()); + const App::PropertyComplexGeoData* prop = geo->getPropertyOfGeometry(); + if (prop) + box.Add(prop->getBoundingBox()); + } + } + return box; +} + // ------------------------------------------------------------------ MovableGroup::MovableGroup() @@ -334,6 +349,16 @@ const MovableGroup& MovableGroupModel::getGroup(int i) const return this->_groups[i]; } +Base::BoundBox3d MovableGroupModel::getBoundingBox() const +{ + Base::BoundBox3d box; + std::vector::const_iterator it; + for (it = this->_groups.begin(); it != this->_groups.end(); ++it) { + box.Add(it->getBoundingBox()); + } + return box; +} + // ------------------------------------------------------------------ namespace Gui { diff --git a/src/Gui/ManualAlignment.h b/src/Gui/ManualAlignment.h index 6899886341..522f593029 100644 --- a/src/Gui/ManualAlignment.h +++ b/src/Gui/ManualAlignment.h @@ -25,6 +25,7 @@ #define GUI_MANUALALIGNMENT_H #include +#include #include #include #include @@ -123,6 +124,10 @@ public: * Return the number of added views. */ int count() const; + /** + * Get the overall bounding box of all views. + */ + Base::BoundBox3d getBoundingBox() const; protected: std::vector _pickedPoints; @@ -170,6 +175,7 @@ public: bool isEmpty() const; int count() const; const MovableGroup& getGroup(int i) const; + Base::BoundBox3d getBoundingBox() const; protected: void removeActiveGroup(); From d62eda51d63c492a94378386c0fb601fbcf7c0c8 Mon Sep 17 00:00:00 2001 From: wmayer Date: Fri, 17 Jan 2020 23:26:22 +0100 Subject: [PATCH 5/5] Import: [skip ci] fix bug when checking if std::map is empty --- src/Mod/Import/App/AppImportPy.cpp | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/src/Mod/Import/App/AppImportPy.cpp b/src/Mod/Import/App/AppImportPy.cpp index aa1dcdc19a..188af7b16e 100644 --- a/src/Mod/Import/App/AppImportPy.cpp +++ b/src/Mod/Import/App/AppImportPy.cpp @@ -163,7 +163,6 @@ private: Handle(XCAFApp_Application) hApp = XCAFApp_Application::GetApplication(); Handle(TDocStd_Document) hDoc; hApp->NewDocument(TCollection_ExtendedString("MDTV-CAF"), hDoc); - ImportOCAFExt ocaf(hDoc, pcDoc, file.fileNamePure()); if (file.hasExtension("stp") || file.hasExtension("step")) { try { @@ -230,15 +229,19 @@ private: } #if 1 - if(merge!=Py_None) + ImportOCAFExt ocaf(hDoc, pcDoc, file.fileNamePure()); + if (merge != Py_None) ocaf.setMerge(PyObject_IsTrue(merge)); - if(importHidden!=Py_None) + if (importHidden != Py_None) ocaf.setImportHiddenObject(PyObject_IsTrue(importHidden)); - if(useLinkGroup!=Py_None) + if (useLinkGroup != Py_None) ocaf.setUseLinkGroup(PyObject_IsTrue(useLinkGroup)); - if(mode>=0) + if (mode >= 0) ocaf.setMode(mode); ocaf.loadShapes(); +#elif 1 + Import::ImportOCAFCmd ocaf(hDoc, pcDoc, file.fileNamePure()); + ocaf.loadShapes(); #else Import::ImportXCAF xcaf(hDoc, pcDoc, file.fileNamePure()); xcaf.loadShapes(); @@ -246,7 +249,7 @@ private: #endif hApp->Close(hDoc); - if (!ocaf.partColors.size()) { + if (!ocaf.partColors.empty()) { Py::List list; for (auto &it : ocaf.partColors) { Py::Tuple tuple(2);