X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FPartSet%2FPartSet_SketcherReetntrantMgr.cpp;h=15cf843d3072df5989d5dd1d08db2db2f0d81a1e;hb=031179ada6681b874314c450eeda806f9f8abd28;hp=083cbd36f4dde52f511f144efa0ec8d72c4679a1;hpb=dc225cf2e6d0e7d29fbe74e35af1959152e90721;p=modules%2Fshaper.git diff --git a/src/PartSet/PartSet_SketcherReetntrantMgr.cpp b/src/PartSet/PartSet_SketcherReetntrantMgr.cpp index 083cbd36f..15cf843d3 100755 --- a/src/PartSet/PartSet_SketcherReetntrantMgr.cpp +++ b/src/PartSet/PartSet_SketcherReetntrantMgr.cpp @@ -25,12 +25,15 @@ #include #include +#include + PartSet_SketcherReetntrantMgr::PartSet_SketcherReetntrantMgr(ModuleBase_IWorkshop* theWorkshop) : QObject(theWorkshop), myWorkshop(theWorkshop), myRestartingMode(RM_None), myIsFlagsBlocked(false), - myIsInternalEditOperation(false) + myIsInternalEditOperation(false), + myNoMoreWidgetsAttribute("") { } @@ -176,16 +179,27 @@ void PartSet_SketcherReetntrantMgr::onNoMoreWidgets(const std::string& thePrevio if (!isActiveMgr()) return; + // we should avoid processing of the signal about no more widgets attributes and + // do this after the restart operaion is finished if it was called + // onNoMoreWidgets depends on myIsFlagsBlocked and fill myNoMoreWidgetsAttribute + // if it should be called after restart + if (myIsFlagsBlocked) { + myNoMoreWidgetsAttribute = thePreviousAttributeID; + return; + } + ModuleBase_OperationFeature* aFOperation = dynamic_cast (myWorkshop->currentOperation()); - if (!myWorkshop->module()->getFeatureError(aFOperation->feature(), false).isEmpty()) + if (!myWorkshop->module()->getFeatureError(aFOperation->feature()).isEmpty()) return; if (aFOperation && PartSet_SketcherMgr::isNestedSketchOperation(aFOperation)) { bool isStarted = false; - if (myRestartingMode != RM_Forbided) { - myRestartingMode = RM_LastFeatureUsed; - isStarted = startInternalEdit(thePreviousAttributeID); + if (!module()->sketchMgr()->sketchSolverError()) { + if (myRestartingMode != RM_Forbided) { + myRestartingMode = RM_LastFeatureUsed; + isStarted = startInternalEdit(thePreviousAttributeID); + } } if (!isStarted) aFOperation->commit(); @@ -199,13 +213,22 @@ bool PartSet_SketcherReetntrantMgr::processEnter(const std::string& thePreviousA if (!isActiveMgr()) return isDone; + // empty previous attribute means that the Apply/Ok button has focus and the enter + // should not lead to start edition mode of the previous operation + if (thePreviousAttributeID.empty()) + return isDone; + ModuleBase_OperationFeature* aFOperation = dynamic_cast (myWorkshop->currentOperation()); - if (!myWorkshop->module()->getFeatureError(aFOperation->feature(), false).isEmpty()) + if (!myWorkshop->module()->getFeatureError(aFOperation->feature()).isEmpty()) return isDone; - myRestartingMode = RM_EmptyFeatureUsed; - isDone = startInternalEdit(thePreviousAttributeID); + bool isSketchSolverError = module()->sketchMgr()->sketchSolverError(); + + if (!isSketchSolverError) { + myRestartingMode = RM_EmptyFeatureUsed; + isDone = startInternalEdit(thePreviousAttributeID); + } return isDone; } @@ -268,6 +291,12 @@ bool PartSet_SketcherReetntrantMgr::isActiveMgr() const bool PartSet_SketcherReetntrantMgr::startInternalEdit(const std::string& thePreviousAttributeID) { bool isDone = false; + /// this is workaround for ModuleBase_WidgetEditor, used in SALOME mode. Sometimes key enter + /// event comes two times, so we should not start another internal edit operation + /// the Apply button becomes disabled becase the second additional internal feature is created + if (myIsInternalEditOperation) + return true; + ModuleBase_OperationFeature* aFOperation = dynamic_cast (myWorkshop->currentOperation()); @@ -297,9 +326,25 @@ bool PartSet_SketcherReetntrantMgr::startInternalEdit(const std::string& thePrev aPreviousAttributeWidget = aWidgets[i]; } // If the current widget is a selector, do nothing, it processes the mouse press - if (aPreviousAttributeWidget && !aPreviousAttributeWidget->isViewerSelector()) { - aPreviousAttributeWidget->focusTo(); - aPreviousAttributeWidget->selectContent(); + if (aPreviousAttributeWidget) { + if (!aPreviousAttributeWidget->isViewerSelector()) { + aPreviousAttributeWidget->focusTo(); + aPreviousAttributeWidget->selectContent(); + } + else { + // in case of shape multi selector, the widget does not lose focus by filling + // like it is in shape selector. So, if enter is pressed, the multi shape selector + // control should be deactivated. The focus is moved to Apply button and there + // should not be active control visualized in property panel + if (aPreviousAttributeWidget == aPanel->activeWidget()) { + aPanel->activateWidget(NULL, false); + } + // if there is no the next widget to be automatically activated, the Ok button in property + // panel should accept the focus(example is parallel constraint on sketch lines) + QToolButton* anOkBtn = aPanel->findChild(PROP_PANEL_OK); + if (anOkBtn) + anOkBtn->setFocus(Qt::TabFocusReason); + } } } } @@ -328,11 +373,20 @@ void PartSet_SketcherReetntrantMgr::restartOperation() ModuleBase_OperationFeature* aFOperation = dynamic_cast( myWorkshop->currentOperation()); if (aFOperation) { + myNoMoreWidgetsAttribute = ""; myIsFlagsBlocked = true; aFOperation->commit(); module()->launchOperation(aFOperation->id()); myIsFlagsBlocked = false; resetFlags(); + // we should avoid processing of the signal about no more widgets attributes and + // do this after the restart operaion is finished if it was called + // onNoMoreWidgets depends on myIsFlagsBlocked and fill myNoMoreWidgetsAttribute + // if it should be called after restart + if (!myNoMoreWidgetsAttribute.empty()) { + onNoMoreWidgets(myNoMoreWidgetsAttribute); + myNoMoreWidgetsAttribute = ""; + } } } } @@ -362,7 +416,10 @@ void PartSet_SketcherReetntrantMgr::createInternalFeature() QList aWidgets = aFactory.getModelWidgets(); foreach (ModuleBase_ModelWidget* aWidget, aWidgets) { - aWidget->setFeature(myInternalFeature, true); + bool isStoreValue = !aFOperation->isEditOperation() && + !aWidget->getDefaultValue().empty() && + !aWidget->isComputedDefault(); + aWidget->setFeature(myInternalFeature, isStoreValue); } ModuleBase_ModelWidget* aFirstWidget = ModuleBase_IPropertyPanel::findFirstAcceptingValueWidget (aWidgets);