From e2d69609b773079de94c6b73db3577bb369cd33b Mon Sep 17 00:00:00 2001 From: mpv Date: Mon, 14 Oct 2019 15:22:36 +0300 Subject: [PATCH] Fix for the problem of the nightly unit-tests performance. --- src/CollectionPlugin/CMakeLists.txt | 1 + src/CollectionPlugin/Test/TestGroupMove26.py | 46 +++++++++++++++++++ src/FeaturesPlugin/FeaturesPlugin_Recover.cpp | 2 + src/Model/Model_AttributeSelection.cpp | 15 ++++-- src/Model/Model_AttributeSelection.h | 4 +- .../macros/compoundVertices/feature.py | 2 - src/XGUI/XGUI_Workshop.cpp | 12 +++-- 7 files changed, 70 insertions(+), 12 deletions(-) create mode 100644 src/CollectionPlugin/Test/TestGroupMove26.py diff --git a/src/CollectionPlugin/CMakeLists.txt b/src/CollectionPlugin/CMakeLists.txt index 4da31a317..619c42de6 100644 --- a/src/CollectionPlugin/CMakeLists.txt +++ b/src/CollectionPlugin/CMakeLists.txt @@ -143,6 +143,7 @@ ADD_UNIT_TESTS( TestGroupMove23.py TestGroupMove24.py TestGroupMove25.py + TestGroupMove26.py TestGroupShareTopology.py TestGroupAddition.py TestGroupAddition_Error.py diff --git a/src/CollectionPlugin/Test/TestGroupMove26.py b/src/CollectionPlugin/Test/TestGroupMove26.py new file mode 100644 index 000000000..14bd39a66 --- /dev/null +++ b/src/CollectionPlugin/Test/TestGroupMove26.py @@ -0,0 +1,46 @@ +# Copyright (C) 2014-2019 CEA/DEN, EDF R&D +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License, or (at your option) any later version. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# +# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +# + +# Check that if particular result of group is concealed, other results are not concealed +# and don't treated like that by the move to the history algorithm + +from salome.shaper import model +from ModelAPI import * + +model.begin() +partSet = model.moduleDocument() +Part_1 = model.addPart(partSet) +Part_1_doc = Part_1.document() +Sketch_1 = model.addSketch(Part_1_doc, model.defaultPlane("XOY")) +SketchCircle_1 = Sketch_1.addCircle(10.07512315270936, 19.52832512315271, 5.646825151450413) +SketchCircle_2 = Sketch_1.addCircle(-17.04064039408868, -4.229064039408867, 10.0065552781921) +model.do() +Extrusion_1 = model.addExtrusion(Part_1_doc, [model.selection("FACE", "Sketch_1/Face-SketchCircle_2_2f"), model.selection("FACE", "Sketch_1/Face-SketchCircle_1_2r")], model.selection(), 10, 0) +Group_1 = model.addGroup(Part_1_doc, "Solids", [model.selection("SOLID", "Extrusion_1_1")]) +RemoveResults_1 = model.addRemoveResults(Part_1_doc, [model.selection("SOLID", "Extrusion_1_2")]) +model.do() +Part_1_doc.moveFeature(Group_1.feature(), RemoveResults_1.feature()) +model.end() + +aFactory = ModelAPI_Session.get().validators() +assert(aFactory.validate(Group_1.feature())) +selectionList = Group_1.feature().selectionList("group_list") +assert(selectionList.size() == 1) + +assert(model.checkPythonDump()) diff --git a/src/FeaturesPlugin/FeaturesPlugin_Recover.cpp b/src/FeaturesPlugin/FeaturesPlugin_Recover.cpp index bae08ab42..9082ea168 100644 --- a/src/FeaturesPlugin/FeaturesPlugin_Recover.cpp +++ b/src/FeaturesPlugin/FeaturesPlugin_Recover.cpp @@ -46,7 +46,9 @@ void FeaturesPlugin_Recover::initAttributes() data()->addAttribute(METHOD(), ModelAPI_AttributeString::typeId()); if (!string(METHOD())->isInitialized()) { myClearListOnTypeChange = false; + data()->blockSendAttributeUpdated(true, false); string(METHOD())->setValue(METHOD_DEFAULT()); + data()->blockSendAttributeUpdated(false, false); myClearListOnTypeChange = true; } ModelAPI_Session::get()->validators()->registerNotObligatory(getKind(), METHOD()); diff --git a/src/Model/Model_AttributeSelection.cpp b/src/Model/Model_AttributeSelection.cpp index c985315b4..d636a3804 100644 --- a/src/Model/Model_AttributeSelection.cpp +++ b/src/Model/Model_AttributeSelection.cpp @@ -1282,14 +1282,21 @@ void Model_AttributeSelection::computeValues( void Model_AttributeSelection::concealedFeature( - const FeaturePtr theFeature, const FeaturePtr theStop, std::list& theConcealers) + const FeaturePtr theFeature, const FeaturePtr theStop, std::list& theConcealers, + const ResultPtr theResultOfFeature) { std::set alreadyProcessed; alreadyProcessed.insert(theFeature); if (theStop.get()) alreadyProcessed.insert(theStop); /// iterate all results to find the concealment-attribute - const std::list& aRootRes = theFeature->results(); + std::list aRootRes; + if (theResultOfFeature.get()) { + ResultPtr aRoot = ModelAPI_Tools::bodyOwner(theResultOfFeature, true); + aRootRes.push_back(aRoot ? aRoot : theResultOfFeature); + } else { // all results of a feature + aRootRes = theFeature->results(); + } std::list::const_iterator aRootIter = aRootRes.cbegin(); for(; aRootIter != aRootRes.cend(); aRootIter++) { std::list allRes; @@ -1398,7 +1405,7 @@ bool Model_AttributeSelection::searchNewContext(std::shared_ptr FeaturePtr aThisFeature = std::dynamic_pointer_cast(owner()); FeaturePtr aContextOwner = theDoc->feature(theContext); std::list aConcealers; - concealedFeature(aContextOwner, aThisFeature, aConcealers); + concealedFeature(aContextOwner, aThisFeature, aConcealers, theContext); std::list::iterator aConcealer = aConcealers.begin(); for(; aConcealer != aConcealers.end(); aConcealer++) { std::list aRefResults; @@ -1471,7 +1478,7 @@ void Model_AttributeSelection::updateInHistory(bool& theRemove) if (aFeature.get()) { FeaturePtr aThisFeature = std::dynamic_pointer_cast(owner()); std::list aConcealers; - concealedFeature(aFeature, aThisFeature, aConcealers); + concealedFeature(aFeature, aThisFeature, aConcealers, ResultPtr()); if (aConcealers.empty()) return; bool aChanged = false; diff --git a/src/Model/Model_AttributeSelection.h b/src/Model/Model_AttributeSelection.h index b7d81ff74..bd26925b3 100644 --- a/src/Model/Model_AttributeSelection.h +++ b/src/Model/Model_AttributeSelection.h @@ -203,8 +203,10 @@ protected: TDF_Label baseDocumentLab(); /// Returns features that conceals theFeature and located in history before theStop + /// theResultOfFeature if not null defines exact referenced result of a feature void concealedFeature( - const FeaturePtr theFeature, const FeaturePtr theStop, std::list& theConcealers); + const FeaturePtr theFeature, const FeaturePtr theStop, std::list& theConcealers, + const ResultPtr theResultOfFeature); friend class Model_Data; friend class Model_AttributeSelectionList; diff --git a/src/PythonAddons/macros/compoundVertices/feature.py b/src/PythonAddons/macros/compoundVertices/feature.py index bf5ce564b..517978dc0 100644 --- a/src/PythonAddons/macros/compoundVertices/feature.py +++ b/src/PythonAddons/macros/compoundVertices/feature.py @@ -2,7 +2,6 @@ Author: Nathalie Gore """ -from qtsalome import QMessageBox from salome.shaper import model from salome.shaper import geom import ModelAPI @@ -79,7 +78,6 @@ class compoundVertices(model.Feature): for line in file: coord = line.split(self.separator) if len(coord) != 3: - #QMessageBox.warning( self, 'Error!', '3D coords waited!' ) return x = float(coord[0]); y = float(coord[1]); z = float(coord[2]); point = model.addPoint(part, x,y,z); point.execute(True); self.lfeatures.append(point) diff --git a/src/XGUI/XGUI_Workshop.cpp b/src/XGUI/XGUI_Workshop.cpp index 085da94fa..d52167fa4 100644 --- a/src/XGUI/XGUI_Workshop.cpp +++ b/src/XGUI/XGUI_Workshop.cpp @@ -1799,17 +1799,19 @@ void XGUI_Workshop::deleteObjects() if (!(hasResult || hasFeature || hasParameter || hasFolder)) return; - // Remove from the list non-deletable objects: infinite constuctions which are not in history + // Remove from the list non-deletable objects: infinite constructions which are not in history bool notDelete = true; QObjectPtrList::iterator aIt; for (aIt = anObjects.begin(); aIt != anObjects.end(); aIt++) { ObjectPtr aObj = (*aIt); ResultConstructionPtr aConstr = std::dynamic_pointer_cast(aObj); FeaturePtr aFeature = ModelAPI_Feature::feature(aObj); - notDelete = (!aFeature->isInHistory()) && aConstr->isInfinite(); - if (notDelete) { - anObjects.removeAll(aObj); - aIt--; + if (aFeature) { + notDelete = (!aFeature->isInHistory()) && aConstr->isInfinite(); + if (notDelete) { + anObjects.removeAll(aObj); + aIt--; + } } } // delete objects -- 2.39.2