]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
OperationPrs should not be shown if it is empty.
authornds <nds@opencascade.com>
Thu, 18 Feb 2016 15:36:24 +0000 (18:36 +0300)
committernds <nds@opencascade.com>
Thu, 18 Feb 2016 15:40:37 +0000 (18:40 +0300)
Correction for fillet, rectangle sketch features.

src/ModuleBase/ModuleBase_WidgetShapeSelector.cpp
src/PartSet/PartSet_OperationPrs.cpp
src/PartSet/PartSet_OperationPrs.h
src/PartSet/PartSet_Tools.cpp
src/SketcherPrs/SketcherPrs_Equal.cpp
src/SketcherPrs/SketcherPrs_HVDirection.cpp
src/SketcherPrs/SketcherPrs_Tangent.cpp

index 27487c72a0c00eddbf73f7565bc328ea2d698e72..13f071c21dca6f64278fd3301edd222514030ec3 100644 (file)
@@ -212,7 +212,10 @@ GeomShapePtr ModuleBase_WidgetShapeSelector::getShape() const
   if (aType == ModelAPI_AttributeReference::typeId()) {
   } else if (aType == ModelAPI_AttributeRefAttr::typeId()) {
     AttributeRefAttrPtr aRefAttr = aData->refattr(attributeID());
-    aShape = myWorkshop->module()->findShape(aRefAttr);
+    if (aRefAttr.get() && !aRefAttr->isObject()) {
+      AttributePtr anAttribute = aRefAttr->attr();
+      aShape = myWorkshop->module()->findShape(anAttribute);
+    }
   } else if (aType == ModelAPI_AttributeSelection::typeId()) {
     AttributeSelectionPtr aSelectAttr = aData->selection(attributeID());
     aShape = aSelectAttr->value();
index 99e5e1624e134f24be3dc736784b9b27bd436a39..e6a52bdd8a89073db4e618e3ede231360a51392f 100755 (executable)
@@ -257,8 +257,20 @@ void PartSet_OperationPrs::getFeatureShapes(const FeaturePtr& theFeature,
       std::shared_ptr<ModelAPI_AttributeRefList> aCurSelList =
         std::dynamic_pointer_cast<ModelAPI_AttributeRefList>(anAttribute);
       for (int i = 0; i < aCurSelList->size(); i++) {
-        GeomShapePtr aShape;
-        addValue(aCurSelList->object(i), aShape, theFeature, theObjectShapes);
+        ObjectPtr anObject = aCurSelList->object(i);
+        FeaturePtr aFeature = std::dynamic_pointer_cast<ModelAPI_Feature>(anObject);
+        // feature rectangle uses as parameters feature lines, so we should obtain line results
+        if (aFeature.get()) {
+          getResultShapes(aFeature, theWorkshop, theObjectShapes, false);
+        }
+        else {
+          ResultPtr aResult = std::dynamic_pointer_cast<ModelAPI_Result>(anObject);
+          if (aResult.get()) {
+            GeomShapePtr aShape = aResult->shape();
+            if (aShape.get())
+              addValue(aResult, aShape, theFeature, theObjectShapes);
+          }
+        }
       }
     }
     else {
@@ -270,7 +282,8 @@ void PartSet_OperationPrs::getFeatureShapes(const FeaturePtr& theFeature,
           anObject = anAttr->object();
         }
         else {
-          aShape = PartSet_Tools::findShapeBy2DPoint(anAttr, theWorkshop);
+          AttributePtr anAttribute = anAttr->attr();
+          aShape = PartSet_Tools::findShapeBy2DPoint(anAttribute, theWorkshop);
           // the distance point is not found if the point is selected in the 2nd time
           // TODO: after debug, this check can be removed
           if (!aShape.get())
@@ -294,9 +307,11 @@ void PartSet_OperationPrs::getFeatureShapes(const FeaturePtr& theFeature,
 
 void PartSet_OperationPrs::getResultShapes(const FeaturePtr& theFeature,
                                            ModuleBase_IWorkshop* theWorkshop,
-                                           QMap<ObjectPtr, QList<GeomShapePtr> >& theObjectShapes)
+                                           QMap<ObjectPtr, QList<GeomShapePtr> >& theObjectShapes,
+                                           const bool theListShouldBeCleared)
 {
-  theObjectShapes.clear();
+  if (theListShouldBeCleared)
+    theObjectShapes.clear();
 
   if (!theFeature.get())
     return;
index bf1e5a2bc6bda3cf0650d26b912387947bf6480e..51922f5d6a96fc26f951f7ba74b82310c41c9f95 100755 (executable)
@@ -100,7 +100,8 @@ private:
   /// \param theObjectShape an output map of objects
   static void getResultShapes(const FeaturePtr& theFeature,
                               ModuleBase_IWorkshop* theWorkshop,
-                              QMap<ObjectPtr, QList<GeomShapePtr> >& theObjectShapes);
+                              QMap<ObjectPtr, QList<GeomShapePtr> >& theObjectShapes,
+                              const bool theListShouldBeCleared = true);
 
   /// Fills the map by the feature object and shapes, which should be visuaziled
   /// Gets the active widget, obtain the highlighted presentations if it has such and
index 002f148e58905abdf502cbb92d86d4f53cd3266a..a41dc94fdabbd7fc710cdfa7bd27b4b396cf195c 100755 (executable)
@@ -644,52 +644,42 @@ bool PartSet_Tools::hasVertexShape(const ModuleBase_ViewerPrs& thePrs, FeaturePt
 }
 
 GeomShapePtr PartSet_Tools::findShapeBy2DPoint(const AttributePtr& theAttribute,
-                                               ModuleBase_IWorkshop* theWorkshop)
+                                                       ModuleBase_IWorkshop* theWorkshop)
 {
-  // 1. find an attribute value in attribute reference attribute value
   GeomShapePtr aShape;
-  AttributeRefAttrPtr aRefAttr =
-    std::dynamic_pointer_cast<ModelAPI_AttributeRefAttr>(theAttribute);
-  if (aRefAttr) {
-    if (!aRefAttr->isObject()) {
-      AttributePtr theAttribute = aRefAttr->attr();
-      if (theAttribute.get()) {
-        XGUI_ModuleConnector* aConnector = dynamic_cast<XGUI_ModuleConnector*>(theWorkshop);
-        XGUI_Displayer* aDisplayer = aConnector->workshop()->displayer();
-
-        // 2. find visualized vertices of the attribute and if the attribute of the vertex is
-        // the same, return it
-        FeaturePtr anAttributeFeature = ModelAPI_Feature::feature(theAttribute->owner());
-        // 2.1 get visualized results of the feature
-        const std::list<ResultPtr>& aResList = anAttributeFeature->results();
-        std::list<ResultPtr>::const_iterator anIt = aResList.begin(), aLast = aResList.end();
-        for (; anIt != aLast; anIt++) {
-          AISObjectPtr aAISObj = aDisplayer->getAISObject(*anIt);
-          if (aAISObj.get() != NULL) {
-            Handle(AIS_InteractiveObject) anAISIO = aAISObj->impl<Handle(AIS_InteractiveObject)>();
-            // 2.2 find selected owners of a visualizedd object
-            SelectMgr_IndexedMapOfOwner aSelectedOwners;
-            aConnector->workshop()->selector()->selection()->entityOwners(anAISIO, aSelectedOwners);
-            for (Standard_Integer i = 1, n = aSelectedOwners.Extent(); i <= n; i++) {
-              Handle(SelectMgr_EntityOwner) anOwner = aSelectedOwners(i);
-              if (!anOwner.IsNull()) {
-                Handle(StdSelect_BRepOwner) aBRepOwner = Handle(StdSelect_BRepOwner)::DownCast(anOwner);
-                if (!aBRepOwner.IsNull() && aBRepOwner->HasShape()) {
-                  const TopoDS_Shape& aBRepShape = aBRepOwner->Shape();
-                  if (aBRepShape.ShapeType() == TopAbs_VERTEX) {
-                    // 2.3 if the owner is vertex and an attribute of the vertex is equal to the initial
-                    // attribute, returns the shape
-                    PartSet_Module* aModule = dynamic_cast<PartSet_Module*>(theWorkshop->module());
-                    PartSet_SketcherMgr* aSketchMgr = aModule->sketchMgr();
-                    AttributePtr aPntAttr = PartSet_Tools::findAttributeBy2dPoint(anAttributeFeature,
-                                                             aBRepShape, aSketchMgr->activeSketch());
-                    if (aPntAttr.get() != NULL && aPntAttr == theAttribute) {
-                      aShape = std::shared_ptr<GeomAPI_Shape>(new GeomAPI_Shape);
-                      aShape->setImpl(new TopoDS_Shape(aBRepShape));
-                      break;
-                    }
-                  }
-                }
+  XGUI_ModuleConnector* aConnector = dynamic_cast<XGUI_ModuleConnector*>(theWorkshop);
+  XGUI_Displayer* aDisplayer = aConnector->workshop()->displayer();
+
+  // 2. find visualized vertices of the attribute and if the attribute of the vertex is
+  // the same, return it
+  FeaturePtr anAttributeFeature = ModelAPI_Feature::feature(theAttribute->owner());
+  // 2.1 get visualized results of the feature
+  const std::list<ResultPtr>& aResList = anAttributeFeature->results();
+  std::list<ResultPtr>::const_iterator anIt = aResList.begin(), aLast = aResList.end();
+  for (; anIt != aLast; anIt++) {
+    AISObjectPtr aAISObj = aDisplayer->getAISObject(*anIt);
+    if (aAISObj.get() != NULL) {
+      Handle(AIS_InteractiveObject) anAISIO = aAISObj->impl<Handle(AIS_InteractiveObject)>();
+      // 2.2 find selected owners of a visualizedd object
+      SelectMgr_IndexedMapOfOwner aSelectedOwners;
+      aConnector->workshop()->selector()->selection()->entityOwners(anAISIO, aSelectedOwners);
+      for (Standard_Integer i = 1, n = aSelectedOwners.Extent(); i <= n; i++) {
+        Handle(SelectMgr_EntityOwner) anOwner = aSelectedOwners(i);
+        if (!anOwner.IsNull()) {
+          Handle(StdSelect_BRepOwner) aBRepOwner = Handle(StdSelect_BRepOwner)::DownCast(anOwner);
+          if (!aBRepOwner.IsNull() && aBRepOwner->HasShape()) {
+            const TopoDS_Shape& aBRepShape = aBRepOwner->Shape();
+            if (aBRepShape.ShapeType() == TopAbs_VERTEX) {
+              // 2.3 if the owner is vertex and an attribute of the vertex is equal to the initial
+              // attribute, returns the shape
+              PartSet_Module* aModule = dynamic_cast<PartSet_Module*>(theWorkshop->module());
+              PartSet_SketcherMgr* aSketchMgr = aModule->sketchMgr();
+              AttributePtr aPntAttr = PartSet_Tools::findAttributeBy2dPoint(anAttributeFeature,
+                                                        aBRepShape, aSketchMgr->activeSketch());
+              if (aPntAttr.get() != NULL && aPntAttr == theAttribute) {
+                aShape = std::shared_ptr<GeomAPI_Shape>(new GeomAPI_Shape);
+                aShape->setImpl(new TopoDS_Shape(aBRepShape));
+                break;
               }
             }
           }
index ff5e21f101139ddfeb2aeb7a73b4a717f15d04cd..1a808f93587436409adcb27708e48097aa5f7b25 100644 (file)
@@ -46,9 +46,8 @@ bool SketcherPrs_Equal::IsReadyToDisplay(ModelAPI_Feature* theConstraint,
 
 bool SketcherPrs_Equal::updatePoints(double theStep) const
 {
-  if (!IsReadyToDisplay(myConstraint, myPlane)) {
+  if (!IsReadyToDisplay(myConstraint, myPlane))
     return false;
-  }
 
   ObjectPtr aObj1 = SketcherPrs_Tools::getResult(myConstraint, SketchPlugin_Constraint::ENTITY_A());
   ObjectPtr aObj2 = SketcherPrs_Tools::getResult(myConstraint, SketchPlugin_Constraint::ENTITY_B());
index c317a71b606bd810c7da23ed691b2b2269d2d7d9..bc93712401620094cc956d2e6a5fe3af0c8401d2 100644 (file)
@@ -42,9 +42,8 @@ bool SketcherPrs_HVDirection::IsReadyToDisplay(ModelAPI_Feature* theConstraint,
 
 bool SketcherPrs_HVDirection::updatePoints(double theStep) const 
 {
-  if (!SketcherPrs_HVDirection::IsReadyToDisplay(myConstraint, myPlane)) {
+  if (!IsReadyToDisplay(myConstraint, myPlane))
     return false;
-  }
 
   // Set point of the symbol
   ObjectPtr aObj = SketcherPrs_Tools::getResult(myConstraint, SketchPlugin_Constraint::ENTITY_A());
index 57fd517797506cbab8e7f6f8f2f323d6112a3153..cb86910fcee24a63618b5e199144a3f504823023 100644 (file)
@@ -49,6 +49,9 @@ bool SketcherPrs_Tangent::IsReadyToDisplay(ModelAPI_Feature* theConstraint,
 
 bool SketcherPrs_Tangent::updatePoints(double theStep) const
 {
+  if (!IsReadyToDisplay(myConstraint, myPlane))
+    return false;
+
   ObjectPtr aObj1 = SketcherPrs_Tools::getResult(myConstraint, SketchPlugin_Constraint::ENTITY_A());
   ObjectPtr aObj2 = SketcherPrs_Tools::getResult(myConstraint, SketchPlugin_Constraint::ENTITY_B());