]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
[bos #41917][EDF] SHAPER_TestRectangleCentered1.py test failed. Added debug output...
authordish <dmitrii.shvydkoi@opencascade.com>
Wed, 19 Jun 2024 13:25:31 +0000 (13:25 +0000)
committerdish <dmitrii.shvydkoi@opencascade.com>
Wed, 19 Jun 2024 13:25:31 +0000 (13:25 +0000)
Store edge thickness as an integer with a custom ID, instead of TDataStd_Integer::GetID().

src/Model/Model_Objects.cpp
src/Model/Model_Objects.h
src/Model/Model_ResultBody.cpp
src/Model/Model_ResultPart.cpp
src/XGUI/XGUI_Displayer.cpp
src/XGUI/XGUI_Selection.cpp
src/XGUI/XGUI_Workshop.cpp

index ffdd25689dd065eb66c9cd16f2ff8b5b63882546..570423b9de753bfa38cbbbb96a3363f4c6c11c50 100644 (file)
@@ -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<ModelAPI_R
     if (aNamedShape.IsNull())
       continue;
 
-    aCurSubShape.FindChild(TAG_FEATURE_ARGUMENTS).ForgetAttribute(TDataStd_Integer::GetID());
+    aCurSubShape.FindChild(TAG_FEATURE_ARGUMENTS).ForgetAttribute(Model_Objects::ATTR_ID_SHAPE_THICKNESS);
   }
 }
 
index 42ec31c5622055bdf1b0512198b08d4920c05cfe..0033810b270d43041d2b2356e983f7dd79b66311 100644 (file)
@@ -30,6 +30,7 @@
 #include <NCollection_DataMap.hxx>
 #include <TDF_Label.hxx>
 #include <TDF_LabelList.hxx>
+#include <Standard_GUID.hxx>
 #include <map>
 #include <set>
 #include <vector>
@@ -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;
index 2368d0e8c39511c57d41437a4dd2c1bd2c8f83b2..2ae4a8b5e03a8562182c86176ddd3fbd13d77b70 100644 (file)
@@ -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<ModelAPI_Re
     return -1;
 
   Model_Objects* anObjects = std::dynamic_pointer_cast<Model_Document>(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();
 }
index e44fb02ab67f54889b5eec2897a56b4c4062f324..c2c4b893ed6c3edd23cc8a2a5a680c9263e5fccf 100644 (file)
@@ -454,6 +454,7 @@ void Model_ResultPart::setSubShapeEdgeThickness(const std::shared_ptr<GeomAPI_Sh
 
   document()->storeShape(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_ptr<GeomAPI_Sha
   TopoDS_Shape aShape = shape()->impl<TopoDS_Shape>();
   TopoDS_Shape aSubShape = theSubShape->impl<TopoDS_Shape>();
   if (!shape()->isSubShape(theSubShape))
-    return;
+    return -1;
 
   Model_Objects* anObjects = std::dynamic_pointer_cast<Model_Document>(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();
 }
index 045f350f570154c11f5b1ef075795dd36de92b67..c564a221f35ba4ea57550a3e7643ae0ea41a3a86 100644 (file)
@@ -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<GeomShapePtr, std::vector<int>>::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<TopoDS_Shape>(), aColorQ);
           }
         }
       }
-      else
-      {
+      else {
         aResShape->ClearCustomAspects();
       }
       // Set deflection
index 6e2ad3f7eb3768bc604c7454929afe46aa4eb896..eef2dde9d87af63e1aff1bb50d2793c58c655597 100644 (file)
@@ -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<TopoDS_Shape>(), aColorQ);
+*/
+
 QMap<ResultPtr, QList<GeomShapePtr>> XGUI_Selection::selectedObjectsAndSubObjects() const
 {
   QMap<ResultPtr, QList<GeomShapePtr>> aSelectedObjects;
 
-  // Add all objects, which selected in Viewer
+  // Add all objects, which are selected in Viewer.
   QList<ModuleBase_ViewerPrsPtr> aValues = getSelected(ModuleBase_ISelection::Viewer);
   foreach(ModuleBase_ViewerPrsPtr aPrs, aValues)
   {
@@ -412,30 +420,34 @@ QMap<ResultPtr, QList<GeomShapePtr>> XGUI_Selection::selectedObjectsAndSubObject
     GeomShapePtr aShape = aPrs->shape();
 
     aSelectedObjects[aResult].push_back(aShape);
+
+    std::wcout << "aShape adress" << reinterpret_cast<void*>(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<ModelAPI_ResultBody>(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<TopoDS_Shape>().IsEqual(aBodyShape->impl<TopoDS_Shape>()))
-      {
+    foreach(GeomShapePtr aCurShape, aSelectedObjects[aResultBody]) {
+      if (aCurShape->impl<TopoDS_Shape>().IsEqual(aBodyShape->impl<TopoDS_Shape>())) {
         isContains = true;
         break;
       }
     }
+
     if (!isContains)
       aSelectedObjects[aResultBody].push_back(aBodyShape);
+
+    std::wcout << "aBodyShape adress" << reinterpret_cast<void*>(aBodyShape.get()) << std::endl;
   }
   return aSelectedObjects;
 }
index dd89da764eafd4cd010e442ba0980c28324d4115..501f068853a4ba40bf4fdd8939bb2e662b5d296e 100644 (file)
@@ -971,6 +971,8 @@ void XGUI_Workshop::applyEdgeThicknessToCanvas(const QMap<ResultPtr, QList<GeomS
   QString description = contextMenuMgr()->action("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<ResultPtr, QList<GeomS
 
     ResultBodyPtr bodyResult = std::dynamic_pointer_cast<ModelAPI_ResultBody>(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<TopoDS_Shape>().IsEqual(shape->impl<TopoDS_Shape>()) || !isSubShapeWithEdgeThickness) {
@@ -1010,8 +1010,9 @@ void XGUI_Workshop::applyEdgeThicknessToCanvas(const QMap<ResultPtr, QList<GeomS
         ModelAPI_Tools::setSubShapeEdgeThickness(result, shape, theThickness);
       }
     }
-    std::wcout << "foreach END" << std::endl;
+    std::wcout << "foreach shape END" << std::endl;
   }
+  std::wcout << "foreach result END" << std::endl;
 
   Events_Loop::loop()->flush(Events_Loop::eventByName(EVENT_OBJECT_TO_REDISPLAY));
   session->finishOperation();
@@ -3019,7 +3020,7 @@ void XGUI_Workshop::changeEdgeThickness(const QMap<ResultPtr, QList<GeomShapePtr
 {
   // 1. Find current thickness - thickness of AIS presentation.
   // The objects are iterated until a first valid thickness is found.
-  int thickness;
+  int thickness = -1;
   QList<ModuleBase_ViewerPrsPtr> 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 QMap<ResultPtr, QList<GeomShapePtr
   const auto dialog = new XGUI_PropertyDialog(desktop());
   dialog->setWindowTitle(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);