]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
1. setEditOperation should setCurrentFeature to the previous feature in the previous...
authornds <nds@opencascade.com>
Thu, 5 Nov 2015 10:04:27 +0000 (13:04 +0300)
committernds <nds@opencascade.com>
Thu, 5 Nov 2015 10:04:27 +0000 (13:04 +0300)
Scenario: start circle, click, click->internal edition mode[before a new create operation it should be the same current feature which was when the create of the circle is started]
2. Control by debug information setting current feature performed before starting/commit the operation.

src/ModuleBase/ModuleBase_OperationFeature.cpp
src/PartSet/PartSet_SketcherReetntrantMgr.cpp
src/PartSet/PartSet_SketcherReetntrantMgr.h
src/XGUI/XGUI_OperationMgr.cpp

index 125e7e84b40956c41846ed7792c087387c7e4520..20331230cdfa0a81dd52b88744c8b54a00ed2d79 100755 (executable)
@@ -54,22 +54,23 @@ void ModuleBase_OperationFeature::setEditOperation(const bool theRestartTransact
   if (isEditOperation())
     return;
 
-  myIsEditing = true;
   if (theRestartTransaction) {
-    FeaturePtr aPrevFeature = myPreviousCurrentFeature;
-
+    // finsh previous create operation
+    emit beforeCommitted();
     SessionPtr aMgr = ModelAPI_Session::get();
     ModelAPI_Session::get()->finishOperation();
 
+    // start new edit operation
+    myIsEditing = true;
     QString anId = getDescription()->operationId();
     if (myIsEditing) {
       anId = anId.append(EditSuffix());
     }
     ModelAPI_Session::get()->startOperation(anId.toStdString());
     emit beforeStarted();
-
-    myPreviousCurrentFeature = aPrevFeature;
   }
+  else
+    myIsEditing = true;
 
   propertyPanel()->setEditingMode(isEditOperation());
 }
index 3834a98d8f0fb717fd6e33371ff0eeab3a641d2e..b80724885de98f1c2ae8de683f56b9252e34a7bc 100755 (executable)
@@ -273,31 +273,8 @@ bool PartSet_SketcherReetntrantMgr::startInternalEdit(const std::string& thePrev
 
   if (aFOperation && PartSet_SketcherMgr::isNestedSketchOperation(aFOperation)) {
     aFOperation->setEditOperation(true);
-    FeaturePtr anOperationFeature = aFOperation->feature();
-
-    CompositeFeaturePtr aSketch = module()->sketchMgr()->activeSketch();
-    myInternalFeature = aSketch->addFeature(anOperationFeature->getKind());
-    XGUI_PropertyPanel* aPropertyPanel = dynamic_cast<XGUI_PropertyPanel*>
-                                                 (aFOperation->propertyPanel());
 
-    myInternalWidget = new QWidget(aPropertyPanel->contentWidget()->pageWidget());
-    myInternalWidget->setVisible(false);
-
-    ModuleBase_PageWidget* anInternalPage = new ModuleBase_PageWidget(myInternalWidget);
-
-    QString aXmlRepr = aFOperation->getDescription()->xmlRepresentation();
-    ModuleBase_WidgetFactory aFactory(aXmlRepr.toStdString(), myWorkshop);
-
-    aFactory.createWidget(anInternalPage);
-    QList<ModuleBase_ModelWidget*> aWidgets = aFactory.getModelWidgets();
-
-    foreach (ModuleBase_ModelWidget* aWidget, aWidgets) {
-      aWidget->setFeature(myInternalFeature, true);
-    }
-    ModuleBase_ModelWidget* aFirstWidget = ModuleBase_IPropertyPanel::findFirstAcceptingValueWidget
-                                                                                        (aWidgets);
-    if (aFirstWidget)
-      myInternalActiveWidget = aFirstWidget;
+    createInternalFeature();
 
     myIsInternalEditOperation = true;
     isDone = true;
@@ -336,19 +313,7 @@ void PartSet_SketcherReetntrantMgr::beforeStopInternalEdit()
     disconnect(aFOperation, SIGNAL(beforeAborted()), this, SLOT(onBeforeStopped()));
   }
 
-  if (myInternalActiveWidget) {
-    ModuleBase_WidgetSelector* aWSelector = dynamic_cast<ModuleBase_WidgetSelector*>(myInternalActiveWidget);
-    if (aWSelector)
-      aWSelector->activateSelectionAndFilters(false);
-    myInternalActiveWidget = 0;
-  }
-  delete myInternalWidget;
-  myInternalWidget = 0;
-
-  QObjectPtrList anObjects;
-  anObjects.append(myInternalFeature);
-  workshop()->deleteFeatures(anObjects);
-
+  deleteInternalFeature();
 }
 
 void PartSet_SketcherReetntrantMgr::restartOperation()
@@ -366,6 +331,57 @@ void PartSet_SketcherReetntrantMgr::restartOperation()
   }
 }
 
+void PartSet_SketcherReetntrantMgr::createInternalFeature()
+{
+  ModuleBase_OperationFeature* aFOperation = dynamic_cast<ModuleBase_OperationFeature*>
+                                                     (myWorkshop->currentOperation());
+
+  if (aFOperation && PartSet_SketcherMgr::isNestedSketchOperation(aFOperation)) {
+    aFOperation->setEditOperation(true);
+    FeaturePtr anOperationFeature = aFOperation->feature();
+
+    CompositeFeaturePtr aSketch = module()->sketchMgr()->activeSketch();
+    myInternalFeature = aSketch->addFeature(anOperationFeature->getKind());
+    XGUI_PropertyPanel* aPropertyPanel = dynamic_cast<XGUI_PropertyPanel*>
+                                                  (aFOperation->propertyPanel());
+
+    myInternalWidget = new QWidget(aPropertyPanel->contentWidget()->pageWidget());
+    myInternalWidget->setVisible(false);
+
+    ModuleBase_PageWidget* anInternalPage = new ModuleBase_PageWidget(myInternalWidget);
+
+    QString aXmlRepr = aFOperation->getDescription()->xmlRepresentation();
+    ModuleBase_WidgetFactory aFactory(aXmlRepr.toStdString(), myWorkshop);
+
+    aFactory.createWidget(anInternalPage);
+    QList<ModuleBase_ModelWidget*> aWidgets = aFactory.getModelWidgets();
+
+    foreach (ModuleBase_ModelWidget* aWidget, aWidgets) {
+      aWidget->setFeature(myInternalFeature, true);
+    }
+    ModuleBase_ModelWidget* aFirstWidget = ModuleBase_IPropertyPanel::findFirstAcceptingValueWidget
+                                                                                        (aWidgets);
+    if (aFirstWidget)
+      myInternalActiveWidget = aFirstWidget;
+  }
+}
+
+void PartSet_SketcherReetntrantMgr::deleteInternalFeature()
+{
+  if (myInternalActiveWidget) {
+    ModuleBase_WidgetSelector* aWSelector = dynamic_cast<ModuleBase_WidgetSelector*>(myInternalActiveWidget);
+    if (aWSelector)
+      aWSelector->activateSelectionAndFilters(false);
+    myInternalActiveWidget = 0;
+  }
+  delete myInternalWidget;
+  myInternalWidget = 0;
+
+  QObjectPtrList anObjects;
+  anObjects.append(myInternalFeature);
+  workshop()->deleteFeatures(anObjects);
+}
+
 void PartSet_SketcherReetntrantMgr::resetFlags()
 {
   if (!myIsFlagsBlocked) {
index 8853e10dcacf7feb85363a7d21324e34b760100c..2d76dd63757233801cdd809f281de8e3afacc591 100755 (executable)
@@ -130,6 +130,12 @@ private:
   /// Commits the current operation and launches a new with the commited operation feature index
   void restartOperation();
 
+  /// Creates an internal feature and controls to process it
+  void createInternalFeature();
+
+  /// A pair method for an internal creation to remove it and clear all created controls
+  void deleteInternalFeature();
+
   /// Breaks sequense of automatically resterted operations
   void resetFlags();
 
index 05778ad7fe6a44ff89c79c4b964fc3c79e0e9736..ace0a27492e4823377b3106e4b3a30a25f6c489e 100644 (file)
@@ -17,6 +17,7 @@
 #include <ModuleBase_IViewer.h>
 #include "ModuleBase_OperationDescription.h"
 #include "ModuleBase_OperationFeature.h"
+#include "ModuleBase_Tools.h"
 
 #include "ModelAPI_CompositeFeature.h"
 #include "ModelAPI_Session.h"
@@ -25,6 +26,8 @@
 #include <QApplication>
 #include <QKeyEvent>
 
+//#define DEBUG_CURRENT_FEATURE
+
 XGUI_OperationMgr::XGUI_OperationMgr(QObject* theParent,
                                      ModuleBase_IWorkshop* theWorkshop)
 : QObject(theParent), myIsApplyEnabled(false), myWorkshop(theWorkshop)
@@ -396,9 +399,27 @@ void XGUI_OperationMgr::onBeforeOperationStarted()
     // is disabled, sketch entity is disabled as extrusion cut is created earliest then sketch.
     // As a result the sketch disappears from the viewer. However after commit it is displayed back.
     aFOperation->setPreviousCurrentFeature(aDoc->currentFeature(false));
+
+#ifdef DEBUG_CURRENT_FEATURE
+    FeaturePtr aFeature = aFOperation->feature();
+    QString aKind = aFeature ? aFeature->getKind().c_str() : "";
+    qDebug(QString("onBeforeOperationStarted(), edit operation = %1, feature = %2")
+            .arg(aFOperation->isEditOperation())
+            .arg(ModuleBase_Tools::objectInfo(aFeature)).toStdString().c_str());
+
+    qDebug(QString("\tdocument->currentFeature(false) = %1").arg(
+            ModuleBase_Tools::objectInfo(ModelAPI_Session::get()->activeDocument()->currentFeature(false))).toStdString().c_str());
+#endif
+
     if (aFOperation->isEditOperation()) // it should be performed by the feature edit only
       // in create operation, the current feature is changed by addFeature()
       aDoc->setCurrentFeature(aFOperation->feature(), false);
+
+#ifdef DEBUG_CURRENT_FEATURE
+    qDebug("\tdocument->setCurrentFeature");
+    qDebug(QString("\tdocument->currentFeature(false) = %1").arg(
+            ModuleBase_Tools::objectInfo(ModelAPI_Session::get()->activeDocument()->currentFeature(false))).toStdString().c_str());
+#endif
   }
 }
 
@@ -429,6 +450,16 @@ void XGUI_OperationMgr::onBeforeOperationCommitted()
   /// Restore the previous current feature
   ModuleBase_OperationFeature* aFOperation = dynamic_cast<ModuleBase_OperationFeature*>(aCurrentOperation);
   if (aFOperation) {
+#ifdef DEBUG_CURRENT_FEATURE
+    QString aKind = aFOperation->feature()->getKind().c_str();
+    qDebug(QString("onBeforeOperationCommitted(), edit operation = %1, feature = %2")
+            .arg(aFOperation->isEditOperation())
+            .arg(ModuleBase_Tools::objectInfo(aFOperation->feature())).toStdString().c_str());
+
+    qDebug(QString("\tdocument->currentFeature(false) = %1").arg(
+            ModuleBase_Tools::objectInfo(ModelAPI_Session::get()->activeDocument()->currentFeature(false))).toStdString().c_str());
+#endif
+
     if (aFOperation->isEditOperation()) {
       /// Restore the previous current feature
       setCurrentFeature(aFOperation->previousCurrentFeature());
@@ -440,6 +471,11 @@ void XGUI_OperationMgr::onBeforeOperationCommitted()
       if (myOperations.front() != aFOperation)
         setCurrentFeature(aFOperation->previousCurrentFeature());
     }
+#ifdef DEBUG_CURRENT_FEATURE
+    qDebug("\tdocument->setCurrentFeature");
+    qDebug(QString("\tdocument->currentFeature(false) = %1").arg(
+            ModuleBase_Tools::objectInfo(ModelAPI_Session::get()->activeDocument()->currentFeature(false))).toStdString().c_str());
+#endif
   }
 }