From: dish Date: Wed, 19 Jun 2024 13:25:31 +0000 (+0000) Subject: [bos #41917][EDF] SHAPER_TestRectangleCentered1.py test failed. Added debug output... X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=34b12ccd8c22c2d4f676f3706d923499ddcbb363;p=modules%2Fshaper.git [bos #41917][EDF] SHAPER_TestRectangleCentered1.py test failed. Added debug output. Added middle point constraint to rectangle (commented). Added a variant with sending move event from setValue (commented). Store edge thickness as an integer with a custom ID, instead of TDataStd_Integer::GetID(). --- diff --git a/src/Model/Model_Objects.cpp b/src/Model/Model_Objects.cpp index ffdd25689..570423b9d 100644 --- a/src/Model/Model_Objects.cpp +++ b/src/Model/Model_Objects.cpp @@ -113,6 +113,8 @@ static const int TAG_FEATURE_ARGUMENTS = 1; ///< where the arguments are locate static const int TAG_FEATURE_RESULTS = 2; ///< where the results are located static const int TAG_RESULT_SHAPES = 2; ///< where the shapes are located +/*static*/ const Standard_GUID Model_Objects::ATTR_ID_SHAPE_THICKNESS = Standard_GUID("7cd0b171-fb15-477b-909f-e66d36e541ff"); + /// /// 0:1:2 - where features are located /// 0:1:2:N:1 - data of the feature N @@ -805,6 +807,7 @@ void Model_Objects::setAttribute(const Handle(TDF_Attribute)& theAttribute, aResultLabel = resultLabel(theResult->data(), index(aMain)); else aResultLabel = resultLabel(theResult->data(), index(theResult)); + TDF_Label anAttributeLabel = subShapeLabel(aResultLabel, index(theResult, theShape)).FindChild(TAG_FEATURE_ARGUMENTS); if (theAttribute->ID() == TDataStd_IntegerArray::GetID()) @@ -814,19 +817,18 @@ void Model_Objects::setAttribute(const Handle(TDF_Attribute)& theAttribute, Handle(TDataStd_IntegerArray)::DownCast(theAttribute); if (anAttributeLabel.FindAttribute(TDataStd_IntegerArray::GetID(), anColor)) - { anAttributeLabel.ForgetAttribute(TDataStd_IntegerArray::GetID()); - } + anAttributeLabel.AddAttribute(anAttr); static const Events_ID anEvent = Events_Loop::eventByName(EVENT_OBJECT_UPDATED); ModelAPI_EventCreator::get()->sendUpdated(theResult, anEvent); } - else if (theAttribute->ID() == TDataStd_Integer::GetID()) { + else if (theAttribute->ID() == Model_Objects::ATTR_ID_SHAPE_THICKNESS) { Handle(TDataStd_Integer) aThicknessAttr; Handle(TDataStd_Integer) anAttr = Handle(TDataStd_Integer)::DownCast(theAttribute); - if (anAttributeLabel.FindAttribute(TDataStd_Integer::GetID(), aThicknessAttr)) - anAttributeLabel.ForgetAttribute(TDataStd_Integer::GetID()); + if (anAttributeLabel.FindAttribute(Model_Objects::ATTR_ID_SHAPE_THICKNESS, aThicknessAttr)) + anAttributeLabel.ForgetAttribute(Model_Objects::ATTR_ID_SHAPE_THICKNESS); anAttributeLabel.AddAttribute(anAttr); static const Events_ID anEvent = Events_Loop::eventByName(EVENT_OBJECT_UPDATED); @@ -946,7 +948,7 @@ void Model_Objects::getSubShapesWithEdgeThickness( aSub->setImpl(new TopoDS_Shape(aNamedShape->Get())); Handle(TDataStd_Integer) aEdgeThicknessAttr; - aCurSubShape.FindChild(TAG_FEATURE_ARGUMENTS).FindAttribute(TDataStd_Integer::GetID(), aEdgeThicknessAttr); + aCurSubShape.FindChild(TAG_FEATURE_ARGUMENTS).FindAttribute(Model_Objects::ATTR_ID_SHAPE_THICKNESS, aEdgeThicknessAttr); if (aEdgeThicknessAttr.IsNull()) continue; @@ -977,7 +979,7 @@ void Model_Objects::removeSubShapeEdgeThickness(const std::shared_ptr #include #include +#include #include #include #include @@ -45,6 +46,8 @@ extern int kUNDEFINED_FEATURE_INDEX; class Model_Objects { public: + static const Standard_GUID ATTR_ID_SHAPE_THICKNESS; + //! Registers the feature in the data structure //! \param theFeature feature that must be added to the data structure //! \param theAfterThis the feature will be added after this feature; diff --git a/src/Model/Model_ResultBody.cpp b/src/Model/Model_ResultBody.cpp index 2368d0e8c..2ae4a8b5e 100644 --- a/src/Model/Model_ResultBody.cpp +++ b/src/Model/Model_ResultBody.cpp @@ -271,6 +271,7 @@ void Model_ResultBody::setSubShapeEdgeThickness( document()->storeShape(data(), theResult, theSubShape); Handle(TDataStd_Integer) aThickness = new TDataStd_Integer(); + aThickness->SetID(Model_Objects::ATTR_ID_SHAPE_THICKNESS); aThickness->Set(theEdgeThickness); anObjects->setAttribute(aThickness, theResult, theSubShape); } @@ -283,9 +284,9 @@ int Model_ResultBody::getSubShapeEdgeThickness(const std::shared_ptr(document())->objects(); - auto anAttr = Handle(TDataStd_Integer)::DownCast(anObjects->getAttribute(TDataStd_Integer::GetID(), theResult, theSubShape)); + auto anAttr = Handle(TDataStd_Integer)::DownCast(anObjects->getAttribute(Model_Objects::ATTR_ID_SHAPE_THICKNESS, theResult, theSubShape)); if (anAttr.IsNull()) - return; + return -1; return anAttr->Get(); } diff --git a/src/Model/Model_ResultPart.cpp b/src/Model/Model_ResultPart.cpp index e44fb02ab..c2c4b893e 100644 --- a/src/Model/Model_ResultPart.cpp +++ b/src/Model/Model_ResultPart.cpp @@ -454,6 +454,7 @@ void Model_ResultPart::setSubShapeEdgeThickness(const std::shared_ptrstoreShape(data(), original(), theSubShape); Handle(TDataStd_Integer) aThickness = new TDataStd_Integer(); + aThickness->SetID(Model_Objects::ATTR_ID_SHAPE_THICKNESS); aThickness->Set(theThickness); anObjects->setAttribute(aThickness, original(), theSubShape); } @@ -463,12 +464,12 @@ int Model_ResultPart::getSubShapeEdgeThickness(const std::shared_ptrimpl(); TopoDS_Shape aSubShape = theSubShape->impl(); if (!shape()->isSubShape(theSubShape)) - return; + return -1; Model_Objects* anObjects = std::dynamic_pointer_cast(document())->objects(); - Handle(TDataStd_Integer) anAttr = Handle(TDataStd_Integer)::DownCast(anObjects->getAttribute(TDataStd_Integer::GetID(), original(), theSubShape)); + Handle(TDataStd_Integer) anAttr = Handle(TDataStd_Integer)::DownCast(anObjects->getAttribute(Model_Objects::ATTR_ID_SHAPE_THICKNESS, original(), theSubShape)); if (anAttr.IsNull()) - return; + return -1; return anAttr->Get(); } diff --git a/src/XGUI/XGUI_Displayer.cpp b/src/XGUI/XGUI_Displayer.cpp index 045f350f5..c564a221f 100644 --- a/src/XGUI/XGUI_Displayer.cpp +++ b/src/XGUI/XGUI_Displayer.cpp @@ -400,23 +400,20 @@ bool XGUI_Displayer::redisplay(ObjectPtr theObject, bool theUpdateViewer) Handle(AIS_ColoredShape) aResShape = Handle(AIS_ColoredShape)::DownCast(aAISIO); Handle(ModuleBase_ResultPrs) aResPrsShape = Handle(ModuleBase_ResultPrs)::DownCast(aResShape); - if (!aColoredShapes.empty() && !aResPrsShape.IsNull()) - { - for (std::map>::const_iterator anIter(aColoredShapes.cbegin()); - anIter != aColoredShapes.cend(); ++anIter) - { - if (aAISObj->getShape()->isSubShape(anIter->first)) - { - Quantity_Color aColorQ(anIter->second.at(0) / 255., + if (!aColoredShapes.empty() && !aResPrsShape.IsNull()) { + for (auto anIter = aColoredShapes.cbegin(); anIter != aColoredShapes.cend(); ++anIter) { + if (aAISObj->getShape()->isSubShape(anIter->first)) { + Quantity_Color aColorQ( + anIter->second.at(0) / 255., anIter->second.at(1) / 255., anIter->second.at(2) / 255., - Quantity_TOC_RGB); + Quantity_TOC_RGB + ); aResPrsShape->SetCustomColor(anIter->first->impl(), aColorQ); } } } - else - { + else { aResShape->ClearCustomAspects(); } // Set deflection diff --git a/src/XGUI/XGUI_Selection.cpp b/src/XGUI/XGUI_Selection.cpp index 6e2ad3f7e..eef2dde9d 100644 --- a/src/XGUI/XGUI_Selection.cpp +++ b/src/XGUI/XGUI_Selection.cpp @@ -400,11 +400,19 @@ QObjectPtrList XGUI_Selection::selectedPresentations() const return aSelectedList; } +/* + Quantity_Color aColorQ(anIter->second.at(0) / 255., + anIter->second.at(1) / 255., + anIter->second.at(2) / 255., + Quantity_TOC_RGB); + aResPrsShape->SetCustomColor(anIter->first->impl(), aColorQ); +*/ + QMap> XGUI_Selection::selectedObjectsAndSubObjects() const { QMap> aSelectedObjects; - // Add all objects, which selected in Viewer + // Add all objects, which are selected in Viewer. QList aValues = getSelected(ModuleBase_ISelection::Viewer); foreach(ModuleBase_ViewerPrsPtr aPrs, aValues) { @@ -412,30 +420,34 @@ QMap> XGUI_Selection::selectedObjectsAndSubObject GeomShapePtr aShape = aPrs->shape(); aSelectedObjects[aResult].push_back(aShape); + + std::wcout << "aShape adress" << reinterpret_cast(aShape.get()) << std::endl; } - // Add object, which selected in browser, but not selected in Viewer + // Add object, which is selected in browser, but is not selected in Viewer. QObjectPtrList anObjects = selectedObjects(); - foreach(ObjectPtr anObject, anObjects) - { + foreach(ObjectPtr anObject, anObjects) { ResultBodyPtr aResultBody = std::dynamic_pointer_cast(anObject); if (!aResultBody.get()) continue; + GeomShapePtr aBodyShape = aResultBody->shape(); if (aSelectedObjects.contains(aResultBody)) continue; + bool isContains = false; - foreach(GeomShapePtr aCurShape, aSelectedObjects[aResultBody]) - { - if (aCurShape->impl().IsEqual(aBodyShape->impl())) - { + foreach(GeomShapePtr aCurShape, aSelectedObjects[aResultBody]) { + if (aCurShape->impl().IsEqual(aBodyShape->impl())) { isContains = true; break; } } + if (!isContains) aSelectedObjects[aResultBody].push_back(aBodyShape); + + std::wcout << "aBodyShape adress" << reinterpret_cast(aBodyShape.get()) << std::endl; } return aSelectedObjects; } diff --git a/src/XGUI/XGUI_Workshop.cpp b/src/XGUI/XGUI_Workshop.cpp index dd89da764..501f06885 100644 --- a/src/XGUI/XGUI_Workshop.cpp +++ b/src/XGUI/XGUI_Workshop.cpp @@ -971,6 +971,8 @@ void XGUI_Workshop::applyEdgeThicknessToCanvas(const QMapaction("EDGE_THICKNESS_CMD")->text(); session->startOperation(description.toStdString()); + std::wcout << "theSelectedObjects.size() = " << theSelectedObjects.size() << std::endl; + std::wcout << "foreach result START" << std::endl; // 4. Set new value to all results and subshapes of results. foreach(ResultPtr result, theSelectedObjects.keys()) { if (!result) @@ -978,10 +980,8 @@ void XGUI_Workshop::applyEdgeThicknessToCanvas(const QMap(result); - std::wcout << "theSelectedObjects.size() = " << theSelectedObjects.size() << std::endl; - std::wcout << "foreach START" << std::endl; - if (theSelectedObjects.contains(result)) - std::wcout << "theSelectedObjects[result].size = " << theSelectedObjects[result].size() << std::endl; + std::wcout << "foreach shape START" << std::endl; + std::wcout << "theSelectedObjects[result].size = " << theSelectedObjects[result].size() << std::endl; foreach(GeomShapePtr shape, theSelectedObjects[result]) { if (result->shape()->impl().IsEqual(shape->impl()) || !isSubShapeWithEdgeThickness) { @@ -1010,8 +1010,9 @@ void XGUI_Workshop::applyEdgeThicknessToCanvas(const QMapflush(Events_Loop::eventByName(EVENT_OBJECT_TO_REDISPLAY)); session->finishOperation(); @@ -3019,7 +3020,7 @@ void XGUI_Workshop::changeEdgeThickness(const QMap aValues = mySelector->selection()->getSelected(ModuleBase_ISelection::Viewer); const bool isSubShapeWithEdgeThickness = Config_PropManager::boolean("Visualization", "result_subshape_with_edge_thickness"); foreach(ResultPtr result, theSelectedObjects.keys()) { @@ -3061,10 +3062,10 @@ void XGUI_Workshop::changeEdgeThickness(const QMapsetWindowTitle(tr("Edge Thickness")); XGUI_EdgeThicknessWidget* edgeThicknessWidget = new XGUI_EdgeThicknessWidget(dialog); + edgeThicknessWidget->setValue(thickness); + dialog->setContent(edgeThicknessWidget); mySelectedObjects = theSelectedObjects; connect(edgeThicknessWidget, SIGNAL(thicknessValueChanged(int)), this, SLOT(onEdgeThicknessValueChanged(int))); - dialog->setContent(edgeThicknessWidget); - edgeThicknessWidget->setValue(thickness); if (dialog->exec() != QDialog::Accepted) applyEdgeThicknessToCanvas(theSelectedObjects, thickness);