]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
[bos #35154][EDF](2023-T1) Edge thickness.
authordish <dmitrii.shvydkoi@opencascade.com>
Fri, 14 Jun 2024 12:45:33 +0000 (12:45 +0000)
committerdish <dmitrii.shvydkoi@opencascade.com>
Fri, 14 Jun 2024 12:45:33 +0000 (12:45 +0000)
Fix setting thickness to individual edges.

src/ModelAPI/ModelAPI_Tools.cpp
src/XGUI/XGUI_Displayer.cpp
src/XGUI/XGUI_Workshop.cpp

index 2c59a5c9039ec9f774b44d73f3dc9160a46b84cb..e531081822a2995c49d1ee4c1dc9e626f6af31e0 100644 (file)
@@ -1417,27 +1417,42 @@ void setSubShapeEdgeThickness(
   std::shared_ptr<GeomAPI_Shape> theSubShape,
   int theEdgeThickness
 ) {
-  if (!theResult || theSubShape->isNull())
+  std::wcout << "ModelAPI_Tools::setSubShapeEdgeThickness() START" << std::endl;
+
+  if (!theResult || theSubShape->isNull()) {
+    std::wcout << "if (!theResult || theSubShape->isNull())" << std::endl;
+    std::wcout << "ModelAPI_Tools::setSubShapeEdgeThickness() END" << std::endl;
     return;
+  }
 
-  if (!theResult->shape()->isSubShape(theSubShape))
+  if (!theResult->shape()->isSubShape(theSubShape)) {
+    std::wcout << "if (!theResult->shape()->isSubShape(theSubShape))" << std::endl;
+    std::wcout << "ModelAPI_Tools::setSubShapeEdgeThickness() END" << std::endl;
     return;
+  }
 
   auto resultBody = std::dynamic_pointer_cast<ModelAPI_ResultBody>(theResult);
   if (resultBody) {
+    std::wcout << "if (resultBody)" << std::endl;
     resultBody = mainBody(resultBody);
     resultBody->setSubShapeEdgeThickness(theResult, theSubShape, theEdgeThickness);
   }
   else {
+    std::wcout << "NOT if (resultBody)" << std::endl;
+
     const auto resultPart = std::dynamic_pointer_cast<ModelAPI_ResultPart>(theResult);
-    if (!resultPart)
+    if (!resultPart) {
+      std::wcout << "if (!resultPart)" << std::endl;
+      std::wcout << "ModelAPI_Tools::setSubShapeEdgeThickness() END" << std::endl;
       return;
+    }
 
     resultPart->setSubShapeEdgeThickness(theSubShape, theEdgeThickness);
   }
 
   static const Events_ID EVENT = Events_Loop::eventByName(EVENT_OBJECT_TO_REDISPLAY);
   ModelAPI_EventCreator::get()->sendUpdated(theResult, EVENT);
+  std::wcout << "ModelAPI_Tools::setSubShapeEdgeThickness() END" << std::endl;
 }
 
 //******************************************************
index 4f67eaf8c74c2998ceb7c14eb4a48ca59a4584d0..045f350f570154c11f5b1ef075795dd36de92b67 100644 (file)
@@ -96,6 +96,8 @@
 
 #include <set>
 
+#include <iostream>
+
 #ifdef _MSC_VER
 #pragma warning(disable: 4702)
 #endif
@@ -248,7 +250,7 @@ bool XGUI_Displayer::display(ObjectPtr theObject, AISObjectPtr theAIS,
 
     // bos#40617: Apply clipping planes
     // Retrieve the clipping plane from the OCCT Presentation Manager directly,
-    // as they are stored in the ViewModel of the OCCViewer in GUI, where we 
+    // as they are stored in the ViewModel of the OCCViewer in GUI, where we
     // don't have access to.
     Handle(ViewerData_AISShape) aShape = Handle(ViewerData_AISShape)::DownCast (anAISIO);
     if (!aShape.IsNull() && aShape->IsClippable()) {
@@ -427,13 +429,38 @@ bool XGUI_Displayer::redisplay(ObjectPtr theObject, bool theUpdateViewer)
       if ((aTransparency >= 0) && (aTransparency != aAISObj->getTransparency()))
         aAISObj->setTransparency(aTransparency);
 
-      // Set edge thickness
+      // Set edge thickness.
       const int aEdgeThickness = ModelAPI_Tools::getEdgeThickness(aResult);
-      // std::cout << "aEdgeThickness " << aEdgeThickness << "\t";
-      // std::cout << "aAISObj->width() " << aAISObj->width() << std::endl;
       if ((aEdgeThickness > 0) && (aEdgeThickness != aAISObj->width()))
         aAISObj->setWidth(aEdgeThickness);
 
+      { // Set subshapes' edge thickness.
+        std::wcout << "XGUI_Displayer::redisplay/Set subshapes' edge thickness. START" << std::endl;
+
+        std::map<GeomShapePtr, int> subShapesAndThicknesses;
+        ModelAPI_Tools::getSubShapesWithEdgeThickness(aResult, subShapesAndThicknesses);
+        Handle(AIS_ColoredShape) aResShape = Handle(AIS_ColoredShape)::DownCast(aAISIO);
+        Handle(ModuleBase_ResultPrs) aResPrsShape = Handle(ModuleBase_ResultPrs)::DownCast(aResShape);
+
+        std::wcout << "subShapesAndThicknesses.size = " << subShapesAndThicknesses.size() << std::endl;
+
+        if (!subShapesAndThicknesses.empty() && !aResPrsShape.IsNull()) {
+          for (auto it = subShapesAndThicknesses.cbegin(); it != subShapesAndThicknesses.cend(); ++it) {
+            const auto& subShape = it->first;
+            const auto& subShapeThickness = it->second;
+            std::wcout << "subShapeThickness = " << subShapeThickness << std::endl;
+
+            if (aAISObj->getShape()->isSubShape(subShape))
+              aResPrsShape->SetCustomWidth(subShape->impl<TopoDS_Shape>(), subShapeThickness);
+          }
+        }
+        else {
+          aResShape->ClearCustomAspects();
+        }
+
+        std::wcout << "XGUI_Displayer::redisplay/Set subshapes' edge thickness. END" << std::endl;
+      }
+
       // Set Iso-Lines
       Handle(ModuleBase_ResultPrs) aResPrs = Handle(ModuleBase_ResultPrs)::DownCast(aAISIO);
       if (!aResPrs.IsNull())
index 8baa5dd57a0f22f97e9fe280b97748beb87a6719..dd89da764eafd4cd010e442ba0980c28324d4115 100644 (file)
@@ -961,7 +961,10 @@ void XGUI_Workshop::setGrantedFeatures(ModuleBase_Operation* theOperation)
 //******************************************************
 void XGUI_Workshop::applyEdgeThicknessToCanvas(const QMap<ResultPtr, QList<GeomShapePtr>>& theSelectedObjects, int theThickness)
 {
+  std::wcout << "XGUI_Workshop::applyEdgeThicknessToCanvas( theThickness = " << theThickness << ") START" << std::endl;
+
   const bool isSubShapeWithEdgeThickness = Config_PropManager::boolean("Visualization", "result_subshape_with_edge_thickness");
+  std::wcout << "isSubShapeWithEdgeThickness = " << (isSubShapeWithEdgeThickness ? "true" : "false") << std::endl;
 
   // 3. Abort previous operation and start a new one.
   SessionPtr session = ModelAPI_Session::get();
@@ -974,12 +977,24 @@ void XGUI_Workshop::applyEdgeThicknessToCanvas(const QMap<ResultPtr, QList<GeomS
       continue;
 
     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;
+
     foreach(GeomShapePtr shape, theSelectedObjects[result]) {
       if (result->shape()->impl<TopoDS_Shape>().IsEqual(shape->impl<TopoDS_Shape>()) || !isSubShapeWithEdgeThickness) {
+        std::wcout << "If 1" << std::endl;
+
         if (result) {
+          std::wcout << "if (result)" << std::endl;
+
           // Change edge thickness for all sub-solids.
           std::list<ResultPtr> allSubResults;
           ModelAPI_Tools::allSubs(bodyResult, allSubResults);
+          std::wcout << "allSubResults.size() = " << allSubResults.size() << std::endl;
+
           for (auto itSubRes = allSubResults.begin(); itSubRes != allSubResults.end(); itSubRes++) {
             ModelAPI_Tools::setEdgeThickness(*itSubRes, theThickness);
           }
@@ -990,15 +1005,20 @@ void XGUI_Workshop::applyEdgeThicknessToCanvas(const QMap<ResultPtr, QList<GeomS
         if (!isSubShapeWithEdgeThickness)
           break;
       }
-      else if (!shape->isNull())
+      else if (!shape->isNull()) {
+        std::wcout << "else if (!shape->isNull())" << std::endl;
         ModelAPI_Tools::setSubShapeEdgeThickness(result, shape, theThickness);
+      }
     }
+    std::wcout << "foreach END" << std::endl;
   }
 
   Events_Loop::loop()->flush(Events_Loop::eventByName(EVENT_OBJECT_TO_REDISPLAY));
   session->finishOperation();
   updateCommandStatus();
   myViewerProxy->update();
+
+  std::wcout << "XGUI_Workshop::applyEdgeThicknessToCanvas( theThickness = " << theThickness << ") END" << std::endl;
 }
 
 //******************************************************
@@ -3000,6 +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;
+  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()) {
     if (!result)