From: nds Date: Mon, 26 Oct 2015 12:51:21 +0000 (+0300) Subject: Edit created feature after noMoreWidgets. Restart the creation operation by click... X-Git-Tag: V_2.0.0_alfa1~6^2~32 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=a5746a7f8fd8bcd555fb16f98e312c86ca1210da;p=modules%2Fshaper.git Edit created feature after noMoreWidgets. Restart the creation operation by click in the viewer(edit is finished). --- diff --git a/src/ModuleBase/ModuleBase_IPropertyPanel.h b/src/ModuleBase/ModuleBase_IPropertyPanel.h index c8c0f1721..6335c5b67 100644 --- a/src/ModuleBase/ModuleBase_IPropertyPanel.h +++ b/src/ModuleBase/ModuleBase_IPropertyPanel.h @@ -78,7 +78,8 @@ signals: void widgetActivated(ModuleBase_ModelWidget* theWidget); /// Emited when there is no next widget - void noMoreWidgets(); + /// \param thePreviousAttributeID an attribute key of the previous active widget + void noMoreWidgets(const std::string& thePreviousAttributeID); public slots: /// Activate the next widget in the property panel diff --git a/src/PartSet/PartSet_Module.cpp b/src/PartSet/PartSet_Module.cpp index ac927a6fc..bbe6d0293 100755 --- a/src/PartSet/PartSet_Module.cpp +++ b/src/PartSet/PartSet_Module.cpp @@ -253,7 +253,7 @@ void PartSet_Module::onOperationCommitted(ModuleBase_Operation* theOperation) } ModuleBase_OperationFeature* aFOperation = dynamic_cast(theOperation); - if (!aFOperation || aFOperation->isEditOperation()) + if (!aFOperation) return; // the selection is cleared after commit the create operation // in order to do not use the same selected objects in the restarted operation @@ -270,10 +270,34 @@ void PartSet_Module::onOperationCommitted(ModuleBase_Operation* theOperation) myRestartingMode == RM_EmptyFeatureUsed)) { myLastOperationId = aFOperation->id(); myLastFeature = myRestartingMode == RM_LastFeatureUsed ? aFOperation->feature() : FeaturePtr(); - if (!sketchMgr()->sketchSolverError()) - launchOperation(myLastOperationId); + if (!sketchMgr()->sketchSolverError()) { + if (!aFOperation->isEditOperation()) { + FeaturePtr anOperationFeature = aFOperation->feature(); + if (anOperationFeature.get() != NULL) { + editFeature(anOperationFeature); + // 4. activate the first obligatory widget + if (!myPreviousAttributeID.empty()) { + ModuleBase_Operation* anEditOperation = currentOperation(); + if (anEditOperation) { + ModuleBase_IPropertyPanel* aPanel = aFOperation->propertyPanel(); + ModuleBase_ModelWidget* aPreviousAttributeWidget = 0; + QList aWidgets = aPanel->modelWidgets(); + for (int i = 0, aNb = aWidgets.size(); i < aNb && !aPreviousAttributeWidget; i++) { + if (aWidgets[i]->attributeID() == myPreviousAttributeID) + aPreviousAttributeWidget = aWidgets[i]; + } + if (aPreviousAttributeWidget) + aPreviousAttributeWidget->focusTo(); + } + } + } + } + else { + launchOperation(myLastOperationId); + breakOperationSequence(); + } + } } - breakOperationSequence(); } void PartSet_Module::breakOperationSequence() @@ -557,7 +581,10 @@ void PartSet_Module::onKeyRelease(ModuleBase_IViewWindow* theWnd, QKeyEvent* the void PartSet_Module::onEnterReleased() { - myRestartingMode = RM_EmptyFeatureUsed; + ModuleBase_OperationFeature* aFOperation = dynamic_cast + (currentOperation()); + if (!aFOperation->isEditOperation()) + myRestartingMode = RM_EmptyFeatureUsed; } void PartSet_Module::onOperationActivatedByPreselection() @@ -572,13 +599,15 @@ void PartSet_Module::onOperationActivatedByPreselection() } } -void PartSet_Module::onNoMoreWidgets() +void PartSet_Module::onNoMoreWidgets(const std::string& thePreviousAttributeID) { ModuleBase_Operation* anOperation = myWorkshop->currentOperation(); if (anOperation) { if (PartSet_SketcherMgr::isNestedSketchOperation(anOperation)) { - if (myRestartingMode != RM_Forbided) + if (myRestartingMode != RM_Forbided) { myRestartingMode = RM_LastFeatureUsed; + myPreviousAttributeID = thePreviousAttributeID; + } XGUI_ModuleConnector* aConnector = dynamic_cast(workshop()); XGUI_Workshop* aWorkshop = aConnector->workshop(); XGUI_OperationMgr* anOpMgr = aWorkshop->operationMgr(); diff --git a/src/PartSet/PartSet_Module.h b/src/PartSet/PartSet_Module.h index 6f79f8092..5128d3f19 100644 --- a/src/PartSet/PartSet_Module.h +++ b/src/PartSet/PartSet_Module.h @@ -206,7 +206,7 @@ public: public slots: /// SLOT, that is called by no more widget signal emitted by property panel /// Set a specific flag to restart the sketcher operation - void onNoMoreWidgets(); + void onNoMoreWidgets(const std::string& thePreviousAttributeID); /// Redefines the parent method in order to customize the next case: /// If the sketch nested operation is active and the presentation is not visualized in the viewer, @@ -274,6 +274,8 @@ protected slots: QString myLastOperationId; FeaturePtr myLastFeature; + std::string myPreviousAttributeID; + // Automatical restarting mode flag RestartingMode myRestartingMode; diff --git a/src/XGUI/XGUI_ActionsMgr.cpp b/src/XGUI/XGUI_ActionsMgr.cpp index 83a388576..968457ffe 100644 --- a/src/XGUI/XGUI_ActionsMgr.cpp +++ b/src/XGUI/XGUI_ActionsMgr.cpp @@ -118,9 +118,9 @@ void XGUI_ActionsMgr::update() } // TODO(SBH): Get defaults state of actions from XML and remove the following method updateByDocumentKind(); - updateCheckState(); updateByPlugins(anActiveFeature); } + updateCheckState(); } void XGUI_ActionsMgr::updateCheckState() diff --git a/src/XGUI/XGUI_PropertyPanel.cpp b/src/XGUI/XGUI_PropertyPanel.cpp index 3838f7886..d1eea7687 100644 --- a/src/XGUI/XGUI_PropertyPanel.cpp +++ b/src/XGUI/XGUI_PropertyPanel.cpp @@ -197,7 +197,9 @@ void XGUI_PropertyPanel::activateWidget(ModuleBase_ModelWidget* theWidget) if (theWidget == myActiveWidget) { return; } + std::string aPreviosAttributeID; if(myActiveWidget) { + aPreviosAttributeID = myActiveWidget->attributeID(); myActiveWidget->deactivate(); myActiveWidget->setHighlighted(false); } @@ -210,8 +212,8 @@ void XGUI_PropertyPanel::activateWidget(ModuleBase_ModelWidget* theWidget) if (myActiveWidget) { emit widgetActivated(theWidget); } else if (!isEditingMode()) { - emit noMoreWidgets(); - setFocusOnOkButton(); + emit noMoreWidgets(aPreviosAttributeID); + //setFocusOnOkButton(); } } diff --git a/src/XGUI/XGUI_Workshop.cpp b/src/XGUI/XGUI_Workshop.cpp index 3af0fc6e3..4f5e03c28 100644 --- a/src/XGUI/XGUI_Workshop.cpp +++ b/src/XGUI/XGUI_Workshop.cpp @@ -1010,7 +1010,8 @@ void XGUI_Workshop::createDockWidgets() QAction* aCancelAct = myActionsMgr->operationStateAction(XGUI_ActionsMgr::Abort); connect(aCancelAct, SIGNAL(triggered()), myOperationMgr, SLOT(onAbortOperation())); - connect(myPropertyPanel, SIGNAL(noMoreWidgets()), myModule, SLOT(onNoMoreWidgets())); + connect(myPropertyPanel, SIGNAL(noMoreWidgets(const std::string&)), + myModule, SLOT(onNoMoreWidgets(const std::string&))); connect(myPropertyPanel, SIGNAL(keyReleased(QKeyEvent*)), myOperationMgr, SLOT(onKeyReleased(QKeyEvent*))); //connect(myOperationMgr, SIGNAL(validationStateChanged(bool)),