Salome HOME
Issue #1343. Improvement of Extrusion and Revolution operations: setSketchObjectToLis...
authornds <nds@opencascade.com>
Tue, 5 Apr 2016 14:42:59 +0000 (17:42 +0300)
committerdbv <dbv@opencascade.com>
Wed, 6 Apr 2016 10:25:53 +0000 (13:25 +0300)
src/FeaturesPlugin/FeaturesPlugin_CompositeSketch.cpp
src/FeaturesPlugin/FeaturesPlugin_CompositeSketch.h
src/FeaturesPlugin/FeaturesPlugin_Extrusion.cpp
src/FeaturesPlugin/FeaturesPlugin_Revolution.cpp
src/GeomValidators/GeomValidators_ShapeType.cpp [changed mode: 0644->0755]
src/PartSet/PartSet_WidgetSketchCreator.cpp
src/PartSet/PartSet_WidgetSketchCreator.h

index 17f3158ddc9d88b631d7ebc654b4e016987f45ea..b8bd1ee23397beff8c0285659dac7140c3cbf29e 100644 (file)
@@ -117,36 +117,6 @@ void FeaturesPlugin_CompositeSketch::erase()
   ModelAPI_CompositeFeature::erase();
 }
 
-//=================================================================================================
-void FeaturesPlugin_CompositeSketch::setSketchObjectToList()
-{
-  AttributeSelectionListPtr aBaseObjectsSelectionList = selectionList(BASE_OBJECTS_ID());
-  if(!aBaseObjectsSelectionList.get() || aBaseObjectsSelectionList->isInitialized()) {
-    return;
-  }
-
-  AttributeReferencePtr aSketchLauncherRef = reference(SKETCH_ID());
-  if(!aSketchLauncherRef.get() || !aSketchLauncherRef->isInitialized()) {
-    return;
-  }
-
-  FeaturePtr aSketchFeature = std::dynamic_pointer_cast<ModelAPI_Feature>(aSketchLauncherRef->value());
-
-  if(!aSketchFeature.get() || aSketchFeature->results().empty()) {
-    return;
-  }
-
-  ResultPtr aSketchRes = aSketchFeature->results().front();
-  ResultConstructionPtr aConstruction = std::dynamic_pointer_cast<ModelAPI_ResultConstruction>(aSketchRes);
-  if(!aConstruction.get()) {
-    return;
-  }
-
-  if(aBaseObjectsSelectionList->size() == 0) {
-    aBaseObjectsSelectionList->append(aSketchRes, GeomShapePtr());
-  }
-}
-
 //=================================================================================================
 void FeaturesPlugin_CompositeSketch::getBaseShapes(ListOfShape& theBaseShapesList,
                                                    const bool theIsMakeShells)
index d2c7be54e2fe699be5bd018a86b06c97f8824aa9..f83fe924be9bee115137f3cb47fefa5f5dbb82ec 100644 (file)
@@ -66,9 +66,6 @@ protected:
   /// Initializes composite sketch attributes.
   void initCompositeSketchAttribtues(const int theInitFlags);
 
-  /// Sets the sub-object to list of base.
-  void setSketchObjectToList();
-
   /// \brief Returns list of base shapes.
   /// \param[out] theBaseShapesList list of base shapes (warning: list not cleared).
   /// \param[in] theIsMakeShells if true make shells from faces with shared edges.
index 16333c306bb5e8fe98aa113255f0dc5c7e80bd9d..225e3cf481e78ac7398aab43b1fa18bcad0c055c 100644 (file)
@@ -76,9 +76,6 @@ bool FeaturesPlugin_Extrusion::makeExtrusions(ListOfShape& theBaseShapes,
 {
   theMakeShapes.clear();
 
-  /// Sub-feature of the composite should be set in the base list.
-  setSketchObjectToList();
-
   // Getting base shapes.
   getBaseShapes(theBaseShapes);
 
index ae67aa67a8734a9d07408168418147bbfa7214ad..12e053e324da48bab8f9b41016bf42da0fe62b40 100644 (file)
@@ -74,9 +74,6 @@ bool FeaturesPlugin_Revolution::makeRevolutions(ListOfShape& theBaseShapes,
 {
   theMakeShapes.clear();
 
-  /// Sub-feature of the composite should be set in the base list.
-  setSketchObjectToList();
-
   // Getting base shapes.
   getBaseShapes(theBaseShapes);
 
old mode 100644 (file)
new mode 100755 (executable)
index 48de5bdbdbbff55477c3f4e178a4e00ca97cd993..26b7481578766d01e4be63443dd54d0b11df5d99 100644 (file)
@@ -28,6 +28,7 @@
 #include <ModelAPI_AttributeSelectionList.h>
 #include <ModelAPI_Validator.h>
 #include <ModelAPI_Events.h>
+#include <ModelAPI_ResultConstruction.h>
 
 #include <SketchPlugin_SketchEntity.h>
 #include <FeaturesPlugin_CompositeBoolean.h>
@@ -125,6 +126,17 @@ AttributePtr PartSet_WidgetSketchCreator::attribute() const
   return anAttribute;
 }
 
+//********************************************************************
+void PartSet_WidgetSketchCreator::openTransaction()
+{
+  SessionPtr aMgr = ModelAPI_Session::get();
+  bool aIsOp = aMgr->isOperation();
+  if (!aIsOp) {
+    const static std::string aNestedOpID("Parameters modification");
+    aMgr->startOperation(aNestedOpID, true);
+  }
+}
+
 //********************************************************************
 bool PartSet_WidgetSketchCreator::isValidSelection(const ModuleBase_ViewerPrs& theValue)
 {
@@ -248,12 +260,13 @@ bool PartSet_WidgetSketchCreator::canCommitCurrentSketch(ModuleBase_IWorkshop* t
       bool aIsOp = aMgr->isOperation();
       if (!aIsOp)
         aMgr->startOperation();
-      aPCompositeFeature->execute(); // to fill attribute selection list
 
       std::list<AttributePtr> aSelListAttributes = aParentFeature->data()->attributes(
                                                         ModelAPI_AttributeSelectionList::typeId());
       if (aSelListAttributes.size() == 1) {
         AttributePtr aFirstAttribute = aSelListAttributes.front();
+        /// Sub-feature of the composite should be set in the base list.
+        setSketchObjectToList(aPCompositeFeature, aFirstAttribute);
 
         SessionPtr aMgr = ModelAPI_Session::get();
         ModelAPI_ValidatorsFactory* aFactory = aMgr->validators();
@@ -282,6 +295,34 @@ bool PartSet_WidgetSketchCreator::canCommitCurrentSketch(ModuleBase_IWorkshop* t
   return aCanCommit;
 }
 
+void PartSet_WidgetSketchCreator::setSketchObjectToList(const CompositeFeaturePtr& theCompositeFeature,
+                                                        const AttributePtr& theAttribute)
+{
+  if (!theCompositeFeature.get() || theCompositeFeature->numberOfSubs() != 1)
+    return;
+
+  AttributeSelectionListPtr aBaseObjectsSelectionList =
+                     std::dynamic_pointer_cast<ModelAPI_AttributeSelectionList>(theAttribute);
+  if(!aBaseObjectsSelectionList.get() || aBaseObjectsSelectionList->isInitialized()) {
+    return;
+  }
+
+  FeaturePtr aSketchFeature = theCompositeFeature->subFeature(0);
+  if(!aSketchFeature.get() || aSketchFeature->results().empty()) {
+    return;
+  }
+
+  ResultPtr aSketchRes = aSketchFeature->results().front();
+  ResultConstructionPtr aConstruction = std::dynamic_pointer_cast<ModelAPI_ResultConstruction>(aSketchRes);
+  if(!aConstruction.get()) {
+    return;
+  }
+
+  if(aBaseObjectsSelectionList->size() == 0) {
+    aBaseObjectsSelectionList->append(aSketchRes, GeomShapePtr());
+  }
+}
+
 bool PartSet_WidgetSketchCreator::isSelectionMode() const
 {
   AttributeSelectionListPtr anAttrList = myFeature->data()->selectionList(myAttributeListID);
@@ -377,24 +418,14 @@ bool PartSet_WidgetSketchCreator::focusTo()
 {
   if (isSelectionMode()) {
     activateSelectionControl();
-
-    SessionPtr aMgr = ModelAPI_Session::get();
-    bool aIsOp = aMgr->isOperation();
-    if (!aIsOp)
-      aMgr->startOperation(myFeature->getKind());
+    // Open transaction that is general for the previous nested one: it will be closed on nested commit
+    openTransaction();
     return true;
   }
   else {
-    //setVisibleSelectionControl(false);
-
     connect(myModule, SIGNAL(resumed(ModuleBase_Operation*)), SLOT(onResumed(ModuleBase_Operation*)));
-    SessionPtr aMgr = ModelAPI_Session::get();
     // Open transaction that is general for the previous nested one: it will be closed on nested commit
-    bool aIsOp = aMgr->isOperation();
-    if (!aIsOp) {
-      const static std::string aNestedOpID("Parameters modification");
-      aMgr->startOperation(aNestedOpID, true);
-    }
+    openTransaction();
     restoreValue();
   }
   return false;
index a53166444448a22d198a1c5ac495bab356046d09..1c24c125468b6e2bdb2f0bad2bec3df56bc32218 100644 (file)
@@ -76,7 +76,14 @@ public:
   /// \return boolean value
   static bool canCommitCurrentSketch(ModuleBase_IWorkshop* theWorkshop);
 
+  /// Sets the sub-object to list of base.
+  static void setSketchObjectToList(const CompositeFeaturePtr& theFeature,
+                                    const AttributePtr& theAttribute);
+
 protected:
+  /// If there is no operation in current session, start operation for modify parameters
+  void openTransaction();
+
   /// Checks whether the selection presentation contains preview planes
   /// \param theValue a selection information
   /// \return a boolean value