]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Preselection for extrusion/revolution
authornds <natalia.donis@opencascade.com>
Wed, 24 Jun 2015 10:28:04 +0000 (13:28 +0300)
committernds <natalia.donis@opencascade.com>
Wed, 24 Jun 2015 10:28:04 +0000 (13:28 +0300)
src/FeaturesPlugin/extrusion_widget.xml
src/FeaturesPlugin/revolution_widget.xml
src/Model/Model_ResultConstruction.cpp
src/ModuleBase/ModuleBase_Tools.cpp
src/ModuleBase/ModuleBase_WidgetSelector.cpp
src/ModuleBase/ModuleBase_WidgetSelector.h

index 5e1c3fe8e6f59e52edb90630376caf0e7fdd2b0b..12e7181a74323205261825f0a3aa0e0e17e68a2a 100644 (file)
@@ -5,8 +5,7 @@
     label="Select a sketch face"
     icon=":icons/sketch.png"
     tooltip="Select a sketch face"
-    use_choice="false"
-    type_choice="Faces Compound">
+    type_choice="Faces">
     <validator id="PartSet_SketchEntityValidator" parameters="Sketch"/>
   </multi_selector>
   <toolbox id="CreationMethod">
index add5d7a8b6a7b246c2b88d0360530024424d8c38..47b5ee04e7c4344daba778d77ee3d217ceb71f8f 100644 (file)
@@ -5,8 +5,7 @@
     label="Select a sketch face"
     icon=":icons/sketch.png"
     tooltip="Select a sketch face"
-    use_choice="false"
-    type_choice="Faces Compound">
+    type_choice="Faces">
     <validator id="PartSet_SketchEntityValidator" parameters="Sketch"/>
   </multi_selector>
   <shape_selector id="axis_object"
index d2f3104dab769b742f2e74ad018a845f4b538aea..2a8893a7ea0de836b78b73d151bd5fb529094ae5 100644 (file)
@@ -60,14 +60,16 @@ int Model_ResultConstruction::facesNum()
   if (!myFacesUpToDate) {
     std::shared_ptr<GeomAPI_PlanarEdges> aWirePtr = 
       std::dynamic_pointer_cast<GeomAPI_PlanarEdges>(myShape);
-    std::list<std::shared_ptr<GeomAPI_Shape> > aFaces;
-    GeomAlgoAPI_SketchBuilder::createFaces(aWirePtr->origin(), aWirePtr->dirX(),
-      aWirePtr->norm(), aWirePtr, aFaces);
-    std::list<std::shared_ptr<GeomAPI_Shape> >::iterator aFIter = aFaces.begin();
-    for(; aFIter != aFaces.end(); aFIter++) {
-      std::shared_ptr<GeomAPI_Face> aFace(new GeomAPI_Face(*aFIter));
-      if (aFace.get())
-        myFaces.push_back(aFace);
+    if (aWirePtr.get()) {
+      std::list<std::shared_ptr<GeomAPI_Shape> > aFaces;
+      GeomAlgoAPI_SketchBuilder::createFaces(aWirePtr->origin(), aWirePtr->dirX(),
+        aWirePtr->norm(), aWirePtr, aFaces);
+      std::list<std::shared_ptr<GeomAPI_Shape> >::iterator aFIter = aFaces.begin();
+      for(; aFIter != aFaces.end(); aFIter++) {
+        std::shared_ptr<GeomAPI_Face> aFace(new GeomAPI_Face(*aFIter));
+        if (aFace.get())
+          myFaces.push_back(aFace);
+      }
     }
     myFacesUpToDate = true;
   }
index 6728d2349f657bae509228e2cf0374016ba16e95..2deb05c7c5206d77ddb3e441fe867f2770c77955 100644 (file)
@@ -204,7 +204,6 @@ TopAbs_ShapeEnum shapeType(const QString& theType)
     MyShapeTypes["shell"] = TopAbs_SHELL;
     MyShapeTypes["solid"] = TopAbs_SOLID;
     MyShapeTypes["solids"] = TopAbs_SOLID;
-    MyShapeTypes["compound"] = TopAbs_COMPOUND;
   }
   QString aType = theType.toLower();
   if (MyShapeTypes.contains(aType))
index f4a4b456f80f83b9d491164624e8e65111f95fb5..2d2bbd7d380348090ff4000e749e8771882d7882 100755 (executable)
@@ -9,6 +9,8 @@
 #include <ModuleBase_ISelection.h>
 #include <ModuleBase_IWorkshop.h>
 
+#include <ModelAPI_ResultConstruction.h>
+
 ModuleBase_WidgetSelector::ModuleBase_WidgetSelector(QWidget* theParent,
                                                      ModuleBase_IWorkshop* theWorkshop,
                                                      const Config_WidgetAPI* theData,
@@ -58,22 +60,35 @@ void ModuleBase_WidgetSelector::onSelectionChanged()
 }
 
 //********************************************************************
-bool ModuleBase_WidgetSelector::acceptSubShape(const TopoDS_Shape& theShape) const
+bool ModuleBase_WidgetSelector::acceptSubShape(const GeomShapePtr& theShape,
+                                               const ResultPtr& theResult) const
 {
-  bool aValid = true;
-  if (theShape.IsNull()) {
-    aValid = true; // do not check the shape type if the shape is empty
-    // extrusion uses a sketch object selectected in Object browser
+  bool aValid = false;
+
+  GeomShapePtr aShape = theShape;
+  if (!aShape.get() && theResult.get()) {
+    if (theResult.get())
+      aShape = theResult->shape();
   }
-  else {
-    aValid = false;
-    TopAbs_ShapeEnum aShapeType = theShape.ShapeType();
-    QIntList aShapeTypes = getShapeTypes();
-
-    QIntList::const_iterator anIt = aShapeTypes.begin(), aLast = aShapeTypes.end();
-    for (; anIt != aLast; anIt++) {
-      if (aShapeType == *anIt)
-        aValid = true;
+  TopAbs_ShapeEnum aShapeType = TopAbs_SHAPE;
+  if (aShape.get()) {
+    // Check that the selection corresponds to selection type
+    TopoDS_Shape aTopoShape = aShape->impl<TopoDS_Shape>();
+    aShapeType = aTopoShape.ShapeType();
+  }
+
+  QIntList aShapeTypes = getShapeTypes();
+  QIntList::const_iterator anIt = aShapeTypes.begin(), aLast = aShapeTypes.end();
+  for (; anIt != aLast; anIt++) {
+    if (aShapeType == *anIt)
+      aValid = true;
+    else if (*anIt == TopAbs_FACE) {
+      // try to process the construction shape only if there is no a selected shape in the viewer
+      if (!theShape.get() && theResult.get()) {
+        ResultConstructionPtr aCResult =
+                                std::dynamic_pointer_cast<ModelAPI_ResultConstruction>(theResult);
+        aValid = aCResult.get() && aCResult->facesNum() > 0;
+      }
     }
   }
   return aValid;
@@ -109,17 +124,9 @@ void ModuleBase_WidgetSelector::activateCustom()
 bool ModuleBase_WidgetSelector::isValidSelectionCustom(const ModuleBase_ViewerPrs& thePrs)
 {
   GeomShapePtr aShape = myWorkshop->selection()->getShape(thePrs);
-  bool aValid = true;
-  if (!aShape.get()) {
-    ResultPtr aResult = myWorkshop->selection()->getResult(thePrs);
-    if (aResult.get())
-      aShape = aResult->shape();
-  }
-  if (aShape.get()) {
-    // Check that the selection corresponds to selection type
-    TopoDS_Shape aTopoShape = aShape->impl<TopoDS_Shape>();
-    aValid = acceptSubShape(aTopoShape);
-  }
+  ResultPtr aResult = myWorkshop->selection()->getResult(thePrs);
+  bool aValid = acceptSubShape(aShape, aResult);
+
   if (aValid) {
     // In order to avoid selection of the same object
     ResultPtr aResult = myWorkshop->selection()->getResult(thePrs);
index 4f3dd6e4af2807bd3b9c4d8fe96cec5a714d7a22..dd853530efea79353512265e326ac25b3c47c3b6 100755 (executable)
@@ -94,9 +94,13 @@ protected:
    /// The methiod called when widget is activated
   virtual void activateCustom();
 
-  /// Returns true if selected shape corresponds to requested shape types
+  /// Returns true if selected shape corresponds to requested shape types.
+  /// If the widget type of shapes contains the faces item, the result is converted
+  /// to construction result and the method returns true if there is at least one face
+  /// in the construction.
   /// \param theShape a shape
-  bool acceptSubShape(const TopoDS_Shape& theShape) const;
+  /// \param theResult a selected result
+  bool acceptSubShape(const GeomShapePtr& theShape, const ResultPtr& theResult) const;
 
   /// Return an object and geom shape by the viewer presentation
   /// \param thePrs a selection