]> SALOME platform Git repositories - modules/shaper.git/blobdiff - src/PartSet/PartSet_OperationPrs.cpp
Salome HOME
ModuleBase_ViewerPrs is wrapped into shared_ptr.
[modules/shaper.git] / src / PartSet / PartSet_OperationPrs.cpp
index 90d41cdff80f67b6bfefc004b5dc7a05d1750a29..76e143c826b85faaf2e472c44602446afd8ed3c1 100755 (executable)
@@ -36,8 +36,6 @@
 
 #include <QList>
 
-static const int AIS_DEFAULT_WIDTH = 2;
-
 //#define DEBUG_EMPTY_SHAPE
 
 // multi-rotation/translation operation
@@ -95,7 +93,7 @@ void PartSet_OperationPrs::Compute(const Handle(PrsMgr_PresentationManager3d)& t
       // appendShapeIfVisible() on the step of filling myFeatureShapes list
       // the reason is to avoid empty AIS object visualized in the viewer
       //if (!aGeomShape.get()) continue;
-      TopoDS_Shape aShape = aGeomShape->impl<TopoDS_Shape>();
+      TopoDS_Shape aShape = aGeomShape.get() ? aGeomShape->impl<TopoDS_Shape>() : TopoDS_Shape();
       // change deviation coefficient to provide more precise circle
       ModuleBase_Tools::setDefaultDeviationCoefficient(aShape, aDrawer);
 
@@ -108,7 +106,7 @@ void PartSet_OperationPrs::Compute(const Handle(PrsMgr_PresentationManager3d)& t
             /// workaround for zero width. Else, there will be a crash
             if (aWidth == 0) { // width returns of TSolid shape is zero
               bool isDisplayed = !anIO->GetContext().IsNull();
-              aWidth = AIS_DEFAULT_WIDTH;// default width value
+              aWidth = PartSet_Tools::getAISDefaultWidth();// default width value
             }
             setWidth(aDrawer, aWidth);
           }
@@ -129,39 +127,6 @@ void PartSet_OperationPrs::ComputeSelection(const Handle(SelectMgr_Selection)& a
   // the presentation is not used in the selection
 }
 
-bool PartSet_OperationPrs::isVisible(XGUI_Displayer* theDisplayer, const ObjectPtr& theObject)
-{
-  bool aVisible = false;
-  GeomPresentablePtr aPrs = std::dynamic_pointer_cast<GeomAPI_IPresentable>(theObject);
-  ResultPtr aResult = std::dynamic_pointer_cast<ModelAPI_Result>(theObject);
-  if (aPrs.get() || aResult.get()) {
-    aVisible = theDisplayer->isVisible(theObject);
-    // compsolid is not visualized in the viewer, but should have presentation when all sub solids are
-    // visible. It is useful for highlight presentation where compsolid shape is selectable
-    if (!aVisible && aResult.get() && aResult->groupName() == ModelAPI_ResultCompSolid::group()) {
-      ResultCompSolidPtr aCompsolidResult = std::dynamic_pointer_cast<ModelAPI_ResultCompSolid>(aResult);
-      if (aCompsolidResult.get() != NULL) { // change colors for all sub-solids
-        bool anAllSubsVisible = aCompsolidResult->numberOfSubs() > 0;
-        for(int i = 0; i < aCompsolidResult->numberOfSubs() && anAllSubsVisible; i++) {
-          anAllSubsVisible = theDisplayer->isVisible(aCompsolidResult->subResult(i));
-        }
-        aVisible = anAllSubsVisible;
-      }
-    }
-  }
-  else {
-    // check if all results of the feature are visible
-    FeaturePtr aFeature = ModelAPI_Feature::feature(theObject);
-    std::list<ResultPtr> aResults = aFeature->results();
-    std::list<ResultPtr>::const_iterator aIt;
-    aVisible = !aResults.empty();
-    for (aIt = aResults.begin(); aIt != aResults.end(); ++aIt) {
-      aVisible = aVisible && theDisplayer->isVisible(*aIt);
-    }
-  }
-  return aVisible;
-}
-
 bool isSubObject(const ObjectPtr& theObject, const FeaturePtr& theFeature)
 {
   bool isSub = false;
@@ -224,7 +189,7 @@ void PartSet_OperationPrs::appendShapeIfVisible(ModuleBase_IWorkshop* theWorksho
                               QMap<ObjectPtr, QList<GeomShapePtr> >& theObjectShapes)
 {
   XGUI_Displayer* aDisplayer = XGUI_Tools::workshop(theWorkshop)->displayer();
-  if (isVisible(aDisplayer, theObject)) {
+  if (XGUI_Displayer::isVisible(aDisplayer, theObject)) {
     if (theGeomShape.get()) {
       if (theObjectShapes.contains(theObject))
         theObjectShapes[theObject].append(theGeomShape);
@@ -356,7 +321,7 @@ void PartSet_OperationPrs::getHighlightedShapes(ModuleBase_IWorkshop* theWorksho
 {
   theObjectShapes.clear();
 
-  QList<ModuleBase_ViewerPrs> aValues;
+  QList<ModuleBase_ViewerPrsPtr> aValues;
   ModuleBase_IPropertyPanel* aPanel = theWorkshop->propertyPanel();
   if (aPanel) {
     ModuleBase_ModelWidget* aWidget = aPanel->activeWidget();
@@ -366,20 +331,14 @@ void PartSet_OperationPrs::getHighlightedShapes(ModuleBase_IWorkshop* theWorksho
   }
 
   QList<GeomShapePtr> aShapes;
-  QList<ModuleBase_ViewerPrs>::const_iterator anIIt = aValues.begin(),
+  QList<ModuleBase_ViewerPrsPtr>::const_iterator anIIt = aValues.begin(),
                                               aILast = aValues.end();
   for (; anIIt != aILast; anIIt++) {
-    ModuleBase_ViewerPrs aPrs = *anIIt;
-    ObjectPtr anObject = aPrs.object();
+    ModuleBase_ViewerPrsPtr aPrs = *anIIt;
+    ObjectPtr anObject = aPrs->object();
 
-    GeomShapePtr aGeomShape;
-
-    TopoDS_Shape aShape = aPrs.shape();
-    if (!aShape.IsNull()) {
-      aGeomShape = GeomShapePtr(new GeomAPI_Shape());
-      aGeomShape->setImpl(new TopoDS_Shape(aShape));
-    }
-    else {
+    GeomShapePtr aGeomShape = aPrs->shape();
+    if (!aGeomShape.get() || aGeomShape->isNull()) {
       ResultPtr aResult = std::dynamic_pointer_cast<ModelAPI_Result>(anObject);
       if (aResult.get()) {
         aGeomShape = aResult->shape();