]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Crossed cursor correction: it stayed in the application if the feature is aborted.
authornds <nds@opencascade.com>
Thu, 1 Sep 2016 15:09:59 +0000 (18:09 +0300)
committernds <nds@opencascade.com>
Thu, 1 Sep 2016 15:10:15 +0000 (18:10 +0300)
Reason of regression: correction of isNestedSketchOperation() to remove hard-coded Sketch feature kinds.

src/PartSet/PartSet_MenuMgr.cpp
src/PartSet/PartSet_Module.cpp
src/PartSet/PartSet_SketcherMgr.cpp
src/PartSet/PartSet_SketcherMgr.h
src/PartSet/PartSet_SketcherReetntrantMgr.cpp
src/PartSet/PartSet_SketcherReetntrantMgr.h
src/XGUI/XGUI_OperationMgr.cpp

index 676ed379074a7209016acbbb786282ea0eaa4239..46bba030766bddb305291746b842115b2505654d 100644 (file)
@@ -112,8 +112,7 @@ bool PartSet_MenuMgr::addViewerMenu(const QMap<QString, QAction*>& theStdActions
 
   ModuleBase_Operation* anOperation = myModule->workshop()->currentOperation();
   if (!PartSet_SketcherMgr::isSketchOperation(anOperation) &&
-      !PartSet_SketcherMgr::isNestedSketchOperation(anOperation,
-                                                    myModule->sketchMgr()->activeSketch()))
+      !myModule->sketchMgr()->isNestedSketchOperation(anOperation))
     return false;
 
   myCoinsideLines.clear();
@@ -206,8 +205,7 @@ void PartSet_MenuMgr::updateViewerMenu(const QMap<QString, QAction*>& theStdActi
   ModuleBase_Operation* anOperation = myModule->workshop()->currentOperation();
 
   bool isActiveSketch = PartSet_SketcherMgr::isSketchOperation(anOperation) ||
-                        PartSet_SketcherMgr::isNestedSketchOperation(anOperation,
-                                                            myModule->sketchMgr()->activeSketch());
+                        myModule->sketchMgr()->isNestedSketchOperation(anOperation);
   if (isActiveSketch) {
     theStdActions["WIREFRAME_CMD"]->setEnabled(false);
     theStdActions["SHADING_CMD"]->setEnabled(false);
@@ -330,14 +328,14 @@ void PartSet_MenuMgr::setAuxiliary(const bool isChecked)
 
   CompositeFeaturePtr aSketch = myModule->sketchMgr()->activeSketch();
   bool isActiveSketch = PartSet_SketcherMgr::isSketchOperation(anOperation) ||
-                        PartSet_SketcherMgr::isNestedSketchOperation(anOperation, aSketch);
+                        myModule->sketchMgr()->isNestedSketchOperation(anOperation);
   if (!isActiveSketch)
     return;
 
   QObjectPtrList anObjects;
   bool isUseTransaction = false;
   // 1. change auxiliary type of a created feature
-  if (PartSet_SketcherMgr::isNestedCreateOperation(anOperation, aSketch) &&
+  if (myModule->sketchMgr()->isNestedCreateOperation(anOperation, aSketch) &&
       PartSet_SketcherMgr::isEntity(anOperation->id().toStdString()) ) {
       ModuleBase_OperationFeature* aFOperation = dynamic_cast<ModuleBase_OperationFeature*>
                                                                (anOperation);
@@ -396,13 +394,13 @@ bool PartSet_MenuMgr::canSetAuxiliary(bool& theValue) const
 
   CompositeFeaturePtr aSketch = myModule->sketchMgr()->activeSketch();
   bool isActiveSketch = PartSet_SketcherMgr::isSketchOperation(anOperation) ||
-                        PartSet_SketcherMgr::isNestedSketchOperation(anOperation, aSketch);
+                        myModule->sketchMgr()->isNestedSketchOperation(anOperation);
   if (!isActiveSketch)
     return anEnabled;
 
   QObjectPtrList anObjects;
   // 1. change auxiliary type of a created feature
-  if (PartSet_SketcherMgr::isNestedCreateOperation(anOperation, aSketch) &&
+  if (myModule->sketchMgr()->isNestedCreateOperation(anOperation, aSketch) &&
     PartSet_SketcherMgr::isEntity(anOperation->id().toStdString()) ) {
     ModuleBase_OperationFeature* aFOperation = dynamic_cast<ModuleBase_OperationFeature*>(anOperation);
     if (aFOperation)
@@ -411,8 +409,7 @@ bool PartSet_MenuMgr::canSetAuxiliary(bool& theValue) const
   else {
     /// The operation should not be aborted here, because the method does not changed
     /// the auxilliary state, but checks the possibility to perform this
-    ///if (PartSet_SketcherMgr::isNestedSketchOperation(anOperation,
-    //                                                  myModule->sketchMgr()->activeSketch()))
+    ///if (myModule->sketchMgr()->isNestedSketchOperation(anOperation))
     ///  anOperation->abort();
     // 2. change auxiliary type of selected sketch entities
     ModuleBase_ISelection* aSelection = myModule->workshop()->selection();
index 101dfc15a5d5f5fe5128674fa59207de3ec9c053..82f73391f6cc5a29422cca24cdea6094ca278362 100755 (executable)
@@ -259,7 +259,7 @@ void PartSet_Module::connectToPropertyPanel(ModuleBase_ModelWidget* theWidget, c
 
 void PartSet_Module::operationCommitted(ModuleBase_Operation* theOperation) 
 {
-  if (PartSet_SketcherMgr::isNestedSketchOperation(theOperation, sketchMgr()->activeSketch())) {
+  if (sketchMgr()->isNestedSketchOperation(theOperation)) {
     mySketchMgr->commitNestedSketch(theOperation);
   }
 
@@ -369,8 +369,7 @@ void PartSet_Module::updateSketcherOnStart(ModuleBase_Operation* theOperation)
   if (PartSet_SketcherMgr::isSketchOperation(theOperation)) {
     mySketchMgr->startSketch(theOperation);
   }
-  else if (PartSet_SketcherMgr::isNestedSketchOperation(theOperation,
-                                                        sketchMgr()->activeSketch())) {
+  else if (sketchMgr()->isNestedSketchOperation(theOperation)) {
     mySketchMgr->startNestedSketch(theOperation);
   }
 }
@@ -401,7 +400,7 @@ void PartSet_Module::operationStopped(ModuleBase_Operation* theOperation)
   bool isModifiedResults = myCustomPrs->deactivate(ModuleBase_IModule::CustomizeResults, false);
   bool isModified = isModifiedArgs || isModifiedResults;
 
-  if (PartSet_SketcherMgr::isNestedSketchOperation(theOperation, sketchMgr()->activeSketch())) {
+  if (sketchMgr()->isNestedSketchOperation(theOperation)) {
     mySketchMgr->stopNestedSketch(theOperation);
   }
   else if (PartSet_SketcherMgr::isSketchOperation(theOperation))
@@ -490,8 +489,7 @@ bool PartSet_Module::canActivateSelection(const ObjectPtr& theObject) const
 
   ModuleBase_Operation* anOperation = myWorkshop->currentOperation();
   bool isSketchOp = PartSet_SketcherMgr::isSketchOperation(anOperation),
-       isNestedOp = PartSet_SketcherMgr::isNestedSketchOperation(anOperation,
-                                                                 sketchMgr()->activeSketch());
+       isNestedOp = sketchMgr()->isNestedSketchOperation(anOperation);
   if (isSketchOp || isNestedOp) {
     // in active sketch operation it is possible to activate operation object in selection
     // in the edit operation, e.g. points of the line can be moved when the line is edited
@@ -771,8 +769,7 @@ bool PartSet_Module::deleteObjects()
   // 1. check whether the delete should be processed in the module
   ModuleBase_Operation* anOperation = myWorkshop->currentOperation();
   bool isSketchOp = PartSet_SketcherMgr::isSketchOperation(anOperation),
-       isNestedOp = PartSet_SketcherMgr::isNestedSketchOperation(anOperation,
-                                                                 sketchMgr()->activeSketch());
+       isNestedOp = sketchMgr()->isNestedSketchOperation(anOperation);
   if (isSketchOp || isNestedOp) {
     isProcessed = true;
     // 2. find selected presentations
@@ -839,7 +836,7 @@ void PartSet_Module::onFeatureTriggered()
   if (aCmd->isCheckable() && aCmd->isChecked()) {
     // 1. check whether the delete should be processed in the module
     ModuleBase_Operation* anOperation = myWorkshop->currentOperation();
-    bool isNestedOp = PartSet_SketcherMgr::isNestedCreateOperation(anOperation);
+    bool isNestedOp = myModule->sketchMgr()->isNestedCreateOperation(anOperation);
     if (isNestedOp) {
       // in case if in the viewer nothing is displayed, the create operation should not be
       // comitted even if all values of the feature are initialized
@@ -1328,8 +1325,7 @@ GeomShapePtr PartSet_Module::findShape(const AttributePtr& theAttribute)
   GeomShapePtr aGeomShape;
 
   ModuleBase_Operation* anOperation = myWorkshop->currentOperation();
-  if (anOperation && PartSet_SketcherMgr::isNestedSketchOperation(anOperation,
-                                                                  sketchMgr()->activeSketch())) {
+  if (anOperation && sketchMgr()->isNestedSketchOperation(anOperation)) {
     aGeomShape = PartSet_Tools::findShapeBy2DPoint(theAttribute, myWorkshop);
   }
   return aGeomShape;
index 677b430cca54dab167f5cbcc176c6ae91ef124f2..03781cb7acd0925e0b94556a6ccf5e2cea934281 100755 (executable)
@@ -340,7 +340,7 @@ void PartSet_SketcherMgr::onMousePressed(ModuleBase_IViewWindow* theWnd, QMouseE
       return;
 
     bool isSketcher = isSketchOperation(aFOperation);
-    bool isSketchOpe = isNestedSketchOperation(aFOperation, activeSketch());
+    bool isSketchOpe = isNestedSketchOperation(aFOperation);
 
     // Avoid non-sketch operations
     if ((!isSketchOpe) && (!isSketcher))
@@ -419,7 +419,7 @@ void PartSet_SketcherMgr::onMouseReleased(ModuleBase_IViewWindow* theWnd, QMouse
     return;
   ModuleBase_Operation* aOp = getCurrentOperation();
   if (aOp) {
-    if (isNestedSketchOperation(aOp, activeSketch())) {
+    if (isNestedSketchOperation(aOp)) {
       // Only for sketcher operations
       if (myIsDragging) {
         if (myDragDone) {
@@ -763,38 +763,43 @@ bool PartSet_SketcherMgr::isSketchOperation(ModuleBase_Operation* theOperation)
   return theOperation && theOperation->id().toStdString() == SketchPlugin_Sketch::ID();
 }
 
-bool PartSet_SketcherMgr::isNestedSketchOperation(ModuleBase_Operation* theOperation,
-                                                  const CompositeFeaturePtr& theSketch)
+bool PartSet_SketcherMgr::isNestedSketchOperation(ModuleBase_Operation* theOperation) const
 {
   bool aNestedSketch = false;
 
-  if (theOperation && theSketch.get()) {
+  FeaturePtr anActiveSketch = activeSketch();
+  if (anActiveSketch.get() && theOperation) {
+    ModuleBase_Operation* aSketchOperation = operationMgr()->findOperation(
+                                                              anActiveSketch->getKind().c_str());
     ModuleBase_OperationFeature* aFOperation = dynamic_cast<ModuleBase_OperationFeature*>
-                                                                 (theOperation);
-    if (aFOperation) {
+                                                                                  (theOperation);
+    if (aSketchOperation && aFOperation) {
       FeaturePtr aFeature = aFOperation->feature();
-      aNestedSketch = theSketch->isSub(aFeature);
+      if (aFeature.get()) {
+        QStringList aGrantedOpIds = aSketchOperation->grantedOperationIds();
+        aNestedSketch = aGrantedOpIds.contains(aFeature->getKind().c_str());
+      }
     }
   }
   return aNestedSketch;
 }
 
 bool PartSet_SketcherMgr::isNestedCreateOperation(ModuleBase_Operation* theOperation,
-                                                  const CompositeFeaturePtr& theSketch)
+                                                  const CompositeFeaturePtr& theSketch) const
 {
   ModuleBase_OperationFeature* aFOperation = dynamic_cast<ModuleBase_OperationFeature*>
                                                                (theOperation);
   return aFOperation && !aFOperation->isEditOperation() &&
-         isNestedSketchOperation(aFOperation, theSketch);
+         isNestedSketchOperation(aFOperation);
 }
 
 bool PartSet_SketcherMgr::isNestedEditOperation(ModuleBase_Operation* theOperation,
-                                                const CompositeFeaturePtr& theSketch)
+                                                const CompositeFeaturePtr& theSketch) const
 {
   ModuleBase_OperationFeature* aFOperation = dynamic_cast<ModuleBase_OperationFeature*>
                                                                (theOperation);
   return aFOperation && aFOperation->isEditOperation() &&
-    isNestedSketchOperation(aFOperation, theSketch);
+    isNestedSketchOperation(aFOperation);
 }
 
 bool PartSet_SketcherMgr::isEntity(const std::string& theId)
@@ -1003,12 +1008,13 @@ void PartSet_SketcherMgr::stopNestedSketch(ModuleBase_Operation* theOperation)
 {
   myIsMouseOverViewProcessed = true;
   operationMgr()->onValidateOperation();
-  if (canChangeCursor(theOperation)) {
+  // when sketch nested operation is stopped the cursor should be restored unconditionally
+  //if (canChangeCursor(theOperation)) {
     QApplication::restoreOverrideCursor();
 #ifdef DEBUG_CURSOR
     qDebug("stopNestedSketch() : None");
 #endif
-  }
+  //}
   /// improvement to deselect automatically all eventual selected objects, when
   // returning to the neutral point of the Sketcher
   // if the operation is restarted, the previous selection is used to initialize started operation
@@ -1044,7 +1050,7 @@ bool PartSet_SketcherMgr::operationActivatedByPreselection()
 {
   bool isOperationStopped = false;
   ModuleBase_Operation* anOperation = getCurrentOperation();
-  if(anOperation && PartSet_SketcherMgr::isNestedSketchOperation(anOperation, activeSketch())) {
+  if(anOperation && isNestedSketchOperation(anOperation)) {
     // Set final definitions if they are necessary
     //propertyPanelDefined(aOperation);
     /// Commit sketcher operations automatically
@@ -1524,7 +1530,7 @@ void PartSet_SketcherMgr::widgetStateChanged(int thePreviousState)
                                                                            (getCurrentOperation());
   if (aFOperation) {
     if (PartSet_SketcherMgr::isSketchOperation(aFOperation) ||
-        PartSet_SketcherMgr::isNestedSketchOperation(aFOperation, activeSketch()) &&
+        isNestedSketchOperation(aFOperation) &&
         thePreviousState == ModuleBase_ModelWidget::ModifiedInPP) {
       FeaturePtr aFeature = aFOperation->feature();
       visualizeFeature(aFeature, aFOperation->isEditOperation(), canDisplayObject(aFeature));
@@ -1537,7 +1543,7 @@ void PartSet_SketcherMgr::customizePresentation(const ObjectPtr& theObject)
   ModuleBase_OperationFeature* aFOperation = dynamic_cast<ModuleBase_OperationFeature*>
                                                                            (getCurrentOperation());
   if (aFOperation && (PartSet_SketcherMgr::isSketchOperation(aFOperation) ||
-                      PartSet_SketcherMgr::isNestedSketchOperation(aFOperation, activeSketch())))
+                      isNestedSketchOperation(aFOperation)))
     SketcherPrs_Tools::sendExpressionShownEvent(myIsConstraintsShown[PartSet_Tools::Expressions]);
 
   // update entities selection priorities
index 1c8d7302c0cb4fe7ba3f2f9dbb713bd3381e798c..47ea8850adf1add3897ecfc827f1cc791ff78e40 100644 (file)
@@ -91,25 +91,24 @@ public:
   /// \return the boolean result
   static bool isSketchOperation(ModuleBase_Operation* theOperation);
 
-  /// Returns true if the operation feature is a sub in the given sketch
+  /// Returns true if the operation feature belongs to list of granted features of Sketch
+  /// operation. An operation of a sketch should be started before.
   /// \param theOperation an operation
-  /// \param theSketch a sketch feature
   /// \return the boolean result
-  static bool isNestedSketchOperation(ModuleBase_Operation* theOperation,
-                                      const CompositeFeaturePtr& theSketch);
+  bool isNestedSketchOperation(ModuleBase_Operation* theOperation) const;
 
   /// Returns true if the operation is a create and nested sketch operationn
   /// \param theOperation a checked operation
   /// \param theSketch a sketch feature
   //// \return boolean value
-  static bool isNestedCreateOperation(ModuleBase_Operation* theOperation,
-                                      const CompositeFeaturePtr& theSketch);
+  bool isNestedCreateOperation(ModuleBase_Operation* theOperation,
+                                      const CompositeFeaturePtr& /*theSketch*/) const;
 
   /// Returns true if the operation is an edit nested feature one
   /// \param theOperation a checked operation
   //// \return boolean value
-  static bool isNestedEditOperation(ModuleBase_Operation* theOperation,
-                                    const CompositeFeaturePtr& theSketch);
+  bool isNestedEditOperation(ModuleBase_Operation* theOperation,
+                                    const CompositeFeaturePtr& /*theSketch*/) const;
 
   /// Returns whether the current operation is a sketch entity - line, point, arc or circle
   /// \param theId is an id of object
index 291382149facf63b05cf4b44ca86d5ac7a19ef91..2c6dee25f13ea2090925d95c487b27549e0e8447 100755 (executable)
@@ -265,8 +265,7 @@ void PartSet_SketcherReetntrantMgr::onNoMoreWidgets(const std::string& thePrevio
   if (!myWorkshop->module()->getFeatureError(aFOperation->feature()).isEmpty())
     return;
 
-  if (aFOperation && PartSet_SketcherMgr::isNestedSketchOperation(aFOperation,
-                                                    module()->sketchMgr()->activeSketch())) {
+  if (aFOperation && module()->sketchMgr()->isNestedSketchOperation(aFOperation)) {
     bool isStarted = false;
     if (!module()->sketchMgr()->sketchSolverError()) {
       if (myRestartingMode != RM_Forbided) {
@@ -357,8 +356,7 @@ bool PartSet_SketcherReetntrantMgr::isActiveMgr() const
 
   bool anActive = PartSet_SketcherMgr::isSketchOperation(aCurrentOperation);
   if (!anActive) {
-    anActive = PartSet_SketcherMgr::isNestedSketchOperation(aCurrentOperation,
-                                                    module()->sketchMgr()->activeSketch());
+    anActive = module()->sketchMgr()->isNestedSketchOperation(aCurrentOperation);
     if (anActive) { // the manager is not active when the current operation is a usual Edit
       ModuleBase_OperationFeature* aFOperation = dynamic_cast<ModuleBase_OperationFeature*>
                                                        (myWorkshop->currentOperation());
@@ -381,8 +379,7 @@ bool PartSet_SketcherReetntrantMgr::startInternalEdit(const std::string& thePrev
   ModuleBase_OperationFeature* aFOperation = dynamic_cast<ModuleBase_OperationFeature*>
                                                      (myWorkshop->currentOperation());
 
-  if (aFOperation && PartSet_SketcherMgr::isNestedSketchOperation(aFOperation,
-                                                module()->sketchMgr()->activeSketch())) {
+  if (aFOperation && module()->sketchMgr()->isNestedSketchOperation(aFOperation)) {
     aFOperation->setEditOperation(true/*, false*/);
     createInternalFeature();
 
@@ -483,8 +480,7 @@ void PartSet_SketcherReetntrantMgr::createInternalFeature()
   ModuleBase_OperationFeature* aFOperation = dynamic_cast<ModuleBase_OperationFeature*>
                                                      (myWorkshop->currentOperation());
 
-  if (aFOperation && PartSet_SketcherMgr::isNestedSketchOperation(aFOperation,
-                                                          module()->sketchMgr()->activeSketch())) {
+  if (aFOperation && module()->sketchMgr()->isNestedSketchOperation(aFOperation)) {
     FeaturePtr anOperationFeature = aFOperation->feature();
 
     CompositeFeaturePtr aSketch = module()->sketchMgr()->activeSketch();
@@ -615,12 +611,12 @@ bool PartSet_SketcherReetntrantMgr::copyReetntrantAttributes(const FeaturePtr& t
 }
 
 bool PartSet_SketcherReetntrantMgr::isTangentArc(ModuleBase_Operation* theOperation,
-                                                 const CompositeFeaturePtr& theSketch)
+                                                 const CompositeFeaturePtr& /*theSketch*/) const
 {
   bool aTangentArc = false;
   ModuleBase_OperationFeature* aFOperation = dynamic_cast<ModuleBase_OperationFeature*>
                                                                         (theOperation);
-  if (aFOperation && PartSet_SketcherMgr::isNestedSketchOperation(aFOperation, theSketch)) {
+  if (aFOperation && module()->sketchMgr()->isNestedSketchOperation(aFOperation)) {
     FeaturePtr aFeature = aFOperation->feature();
     if (aFeature.get() && aFeature->getKind() == SketchPlugin_Arc::ID()) {
       AttributeStringPtr aTypeAttr = aFeature->data()->string(SketchPlugin_Arc::ARC_TYPE());
index 81f3433f8fbdded25b15605492f7c4a57df9d244..a18db6bcd458ecb6ebfa7ee25a2b51b664774214 100755 (executable)
@@ -161,8 +161,8 @@ private:
                                       const bool isTemporary = false);
 
   /// Checks whethe the feature of the given operation has kind an arc and the arc type is tangent
-  static bool isTangentArc(ModuleBase_Operation* theOperation,
-                           const std::shared_ptr<ModelAPI_CompositeFeature>& theSketch);
+  bool isTangentArc(ModuleBase_Operation* theOperation,
+                    const std::shared_ptr<ModelAPI_CompositeFeature>& /*theSketch*/) const;
 
   /// Accept All action is enabled if an internal edit is started. It updates the state of the button
   void updateAcceptAllAction();
index 1fb45442d3784107e2e64a645d1d1d0930059844..714b19ff1fcb71ccec01a38b8b7c2c4ee4cd4610 100644 (file)
@@ -129,9 +129,12 @@ bool XGUI_OperationMgr::hasOperation(const QString& theId) const
 
 ModuleBase_Operation* XGUI_OperationMgr::findOperation(const QString& theId) const
 {
-  foreach(ModuleBase_Operation* aOp, myOperations) {
-    if (aOp->id() == theId)
-      return aOp;
+  QList<ModuleBase_Operation*>::const_iterator anIt = myOperations.end();
+  while (anIt != myOperations.begin()) {
+    --anIt;
+    ModuleBase_Operation* anOperation = *anIt;
+    if (anOperation->id() == theId)
+      return anOperation;
   }
   return 0;
 }