From: nds Date: Fri, 11 Sep 2015 08:38:43 +0000 (+0300) Subject: Update error manager processing. Error is got firstly from the feature, then from... X-Git-Tag: V_1.4.0_beta4~27 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=b070f5d30325537aa8cf883a55f8d3315115c384;p=modules%2Fshaper.git Update error manager processing. Error is got firstly from the feature, then from the GUI state. Do not use validationChanged and nestedChanged signals for this. Use direct methods updateAction of error manager. Update application Accept actions by signal of model about feature state change, but not by updated signal of object. --- diff --git a/src/PartSet/PartSet_Module.cpp b/src/PartSet/PartSet_Module.cpp index e0c4b568c..c0401c517 100755 --- a/src/PartSet/PartSet_Module.cpp +++ b/src/PartSet/PartSet_Module.cpp @@ -152,8 +152,6 @@ PartSet_Module::PartSet_Module(ModuleBase_IWorkshop* theWshop) Events_Loop* aLoop = Events_Loop::loop(); aLoop->registerListener(this, Events_Loop::eventByName(EVENT_DOCUMENT_CHANGED)); - aLoop->registerListener(this, Events_Loop::eventByName(EVENT_SOLVER_FAILED)); - aLoop->registerListener(this, Events_Loop::eventByName(EVENT_SOLVER_REPAIRED)); mySelectionFilters.Append(new PartSet_GlobalFilter(myWorkshop)); mySelectionFilters.Append(new PartSet_FilterInfinite(myWorkshop)); @@ -1019,23 +1017,6 @@ void PartSet_Module::processEvent(const std::shared_ptr& theMess foreach(ObjectPtr aObj, aObjects) aDisplayer->redisplay(aObj, false); aDisplayer->updateViewer(); - } else if (theMessage->eventID() == Events_Loop::eventByName(EVENT_SOLVER_FAILED) || - theMessage->eventID() == Events_Loop::eventByName(EVENT_SOLVER_REPAIRED)) { - CompositeFeaturePtr aSketch = sketchMgr()->activeSketch(); - if (aSketch.get()) { - if (theMessage->eventID() == Events_Loop::eventByName(EVENT_SOLVER_REPAIRED)) { - // it should be moved out, validating is called to update error string of the sketch feature - if (sketchMgr()->activeSketch().get()) { - SessionPtr aMgr = ModelAPI_Session::get(); - ModelAPI_ValidatorsFactory* aFactory = aMgr->validators(); - bool aValid = aFactory->validate(sketchMgr()->activeSketch()); - } - } - - XGUI_ModuleConnector* aConnector = dynamic_cast(workshop()); - XGUI_Workshop* aWorkshop = aConnector->workshop(); - aWorkshop->errorMgr()->updateActions(aSketch); - } } } diff --git a/src/PartSet/PartSet_SketcherMgr.cpp b/src/PartSet/PartSet_SketcherMgr.cpp index 31201593e..d11636140 100644 --- a/src/PartSet/PartSet_SketcherMgr.cpp +++ b/src/PartSet/PartSet_SketcherMgr.cpp @@ -688,13 +688,6 @@ QString PartSet_SketcherMgr::getFeatureError(const FeaturePtr& theFeature) if (aSketch.get() && aSketch == theFeature) { AttributeStringPtr aAttributeString = aSketch->string(SketchPlugin_Sketch::SOLVER_ERROR()); anError = aAttributeString->value().c_str(); - if (anError.isEmpty()) { - if (isNestedCreateOperation(getCurrentOperation()) && - aSketch->numberOfSubs() == 1) { - AttributePtr aFeaturesAttr = aSketch->attribute(SketchPlugin_Sketch::FEATURES_ID()); - anError = std::string("Attribute \"" + aFeaturesAttr->id() + "\" is not initialized.").c_str(); - } - } } else if (myIsResetCurrentValue) { // this flag do not allow commit of the current operation ModuleBase_OperationFeature* aFOperation = dynamic_cast diff --git a/src/XGUI/XGUI_ErrorMgr.cpp b/src/XGUI/XGUI_ErrorMgr.cpp index 355c8d9a1..97a163665 100644 --- a/src/XGUI/XGUI_ErrorMgr.cpp +++ b/src/XGUI/XGUI_ErrorMgr.cpp @@ -59,7 +59,13 @@ void XGUI_ErrorMgr::updateActions(const FeaturePtr& theFeature) QAction* anOkAction = anActionsMgr->operationStateAction(XGUI_ActionsMgr::Accept); updateActionState(anOkAction, theFeature); } - //update AcceptAll action +} + +void XGUI_ErrorMgr::updateAcceptAllAction(const FeaturePtr& theFeature) +{ + QString anError = myWorkshop->module()->getFeatureError(theFeature); + + XGUI_ActionsMgr* anActionsMgr = workshop()->actionsMgr(); if (workshop()->isFeatureOfNested(theFeature)) { QAction* anAcceptAllAction = anActionsMgr->operationStateAction(XGUI_ActionsMgr::AcceptAll, NULL); bool anEnabled = anError.isEmpty(); diff --git a/src/XGUI/XGUI_ErrorMgr.h b/src/XGUI/XGUI_ErrorMgr.h index 656b2ca3a..c339d6cf0 100644 --- a/src/XGUI/XGUI_ErrorMgr.h +++ b/src/XGUI/XGUI_ErrorMgr.h @@ -28,6 +28,10 @@ public: void updateActions(const FeaturePtr& theFeature); + /// Update enable state of AcceptAll action if the feature uses it + /// \param theFeature a feature + void updateAcceptAllAction(const FeaturePtr& theFeature); + /// Return true if the feature has no error. If there is an error and the action /// is not valid, the dialog with the error information is shown. /// \param theAction an action, which is checked on validity diff --git a/src/XGUI/XGUI_OperationMgr.cpp b/src/XGUI/XGUI_OperationMgr.cpp index 033e1d44c..2382354ea 100644 --- a/src/XGUI/XGUI_OperationMgr.cpp +++ b/src/XGUI/XGUI_OperationMgr.cpp @@ -220,7 +220,7 @@ void XGUI_OperationMgr::updateApplyOfOperations(ModuleBase_Operation* theOperati if (theOperation) { ModuleBase_OperationFeature* aFOperation = dynamic_cast(theOperation); if (aFOperation) - anErrorMgr->updateActions(aFOperation->feature()); + anErrorMgr->updateAcceptAllAction(aFOperation->feature()); //emit nestedStateChanged(theOperation->getDescription()->operationId().toStdString(), // theOperation->isValid()); }