From: nds Date: Thu, 1 Sep 2016 15:09:59 +0000 (+0300) Subject: Crossed cursor correction: it stayed in the application if the feature is aborted. X-Git-Tag: V_2.5.0~83 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=64f8bd887acebdba2dfa6d5e26f0ee969ae33772;p=modules%2Fshaper.git Crossed cursor correction: it stayed in the application if the feature is aborted. Reason of regression: correction of isNestedSketchOperation() to remove hard-coded Sketch feature kinds. --- diff --git a/src/PartSet/PartSet_MenuMgr.cpp b/src/PartSet/PartSet_MenuMgr.cpp index 676ed3790..46bba0307 100644 --- a/src/PartSet/PartSet_MenuMgr.cpp +++ b/src/PartSet/PartSet_MenuMgr.cpp @@ -112,8 +112,7 @@ bool PartSet_MenuMgr::addViewerMenu(const QMap& 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& 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 (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(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(); diff --git a/src/PartSet/PartSet_Module.cpp b/src/PartSet/PartSet_Module.cpp index 101dfc15a..82f73391f 100755 --- a/src/PartSet/PartSet_Module.cpp +++ b/src/PartSet/PartSet_Module.cpp @@ -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; diff --git a/src/PartSet/PartSet_SketcherMgr.cpp b/src/PartSet/PartSet_SketcherMgr.cpp index 677b430cc..03781cb7a 100755 --- a/src/PartSet/PartSet_SketcherMgr.cpp +++ b/src/PartSet/PartSet_SketcherMgr.cpp @@ -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 - (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 (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 (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 (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 diff --git a/src/PartSet/PartSet_SketcherMgr.h b/src/PartSet/PartSet_SketcherMgr.h index 1c8d7302c..47ea8850a 100644 --- a/src/PartSet/PartSet_SketcherMgr.h +++ b/src/PartSet/PartSet_SketcherMgr.h @@ -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 diff --git a/src/PartSet/PartSet_SketcherReetntrantMgr.cpp b/src/PartSet/PartSet_SketcherReetntrantMgr.cpp index 291382149..2c6dee25f 100755 --- a/src/PartSet/PartSet_SketcherReetntrantMgr.cpp +++ b/src/PartSet/PartSet_SketcherReetntrantMgr.cpp @@ -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 (myWorkshop->currentOperation()); @@ -381,8 +379,7 @@ bool PartSet_SketcherReetntrantMgr::startInternalEdit(const std::string& thePrev ModuleBase_OperationFeature* aFOperation = dynamic_cast (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 (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 (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()); diff --git a/src/PartSet/PartSet_SketcherReetntrantMgr.h b/src/PartSet/PartSet_SketcherReetntrantMgr.h index 81f3433f8..a18db6bcd 100755 --- a/src/PartSet/PartSet_SketcherReetntrantMgr.h +++ b/src/PartSet/PartSet_SketcherReetntrantMgr.h @@ -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& theSketch); + bool isTangentArc(ModuleBase_Operation* theOperation, + const std::shared_ptr& /*theSketch*/) const; /// Accept All action is enabled if an internal edit is started. It updates the state of the button void updateAcceptAllAction(); diff --git a/src/XGUI/XGUI_OperationMgr.cpp b/src/XGUI/XGUI_OperationMgr.cpp index 1fb45442d..714b19ff1 100644 --- a/src/XGUI/XGUI_OperationMgr.cpp +++ b/src/XGUI/XGUI_OperationMgr.cpp @@ -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::const_iterator anIt = myOperations.end(); + while (anIt != myOperations.begin()) { + --anIt; + ModuleBase_Operation* anOperation = *anIt; + if (anOperation->id() == theId) + return anOperation; } return 0; }