]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Update error manager processing. Error is got firstly from the feature, then from...
authornds <nds@opencascade.com>
Fri, 11 Sep 2015 08:38:43 +0000 (11:38 +0300)
committernds <nds@opencascade.com>
Fri, 11 Sep 2015 08:46:39 +0000 (11:46 +0300)
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.

src/PartSet/PartSet_Module.cpp
src/PartSet/PartSet_SketcherMgr.cpp
src/XGUI/XGUI_ErrorMgr.cpp
src/XGUI/XGUI_ErrorMgr.h
src/XGUI/XGUI_OperationMgr.cpp

index e0c4b568c74b213d4d359060775fd7d343fc1592..c0401c517e8d9304527b05e5b5cf43c118ef465b 100755 (executable)
@@ -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<Events_Message>& 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<XGUI_ModuleConnector*>(workshop());
-      XGUI_Workshop* aWorkshop = aConnector->workshop();
-      aWorkshop->errorMgr()->updateActions(aSketch);
-    }
   }
 }
 
index 31201593ea0452b2b03cad71d8ee7e0d5348f833..d11636140a307e043765c3149b809ca9724f9863 100644 (file)
@@ -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<ModuleBase_OperationFeature*>
index 355c8d9a1b5df7882e040fa9d5a119bec19f27fb..97a163665599dc67817db6f2b04ffd5772dd11cf 100644 (file)
@@ -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();
index 656b2ca3a41ecfcdff06bdc6eb4e134bd2edb92f..c339d6cf0bd4c652d9bb82a8f97c4282787ac180 100644 (file)
@@ -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
index 033e1d44c7c7c2461895ab8950dab8c7bc89615d..2382354ea57b469471d9588722e1b8e8f43f7d66 100644 (file)
@@ -220,7 +220,7 @@ void XGUI_OperationMgr::updateApplyOfOperations(ModuleBase_Operation* theOperati
   if (theOperation) {
     ModuleBase_OperationFeature* aFOperation = dynamic_cast<ModuleBase_OperationFeature*>(theOperation);
     if (aFOperation)
-      anErrorMgr->updateActions(aFOperation->feature());
+      anErrorMgr->updateAcceptAllAction(aFOperation->feature());
     //emit nestedStateChanged(theOperation->getDescription()->operationId().toStdString(),
     //                        theOperation->isValid());
   }