Salome HOME
ModuleBase_ViewerPrs is wrapped into shared_ptr.
[modules/shaper.git] / src / PartSet / PartSet_OperationPrs.cpp
index 1640f4137f7cc76a4c1f7902dc460feb7036456a..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);
           }
@@ -323,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();
@@ -333,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();
-
-    GeomShapePtr aGeomShape;
+    ModuleBase_ViewerPrsPtr aPrs = *anIIt;
+    ObjectPtr anObject = aPrs->object();
 
-    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();