]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Fixed issue for ctest CEA_2020/Lot2_AutoColor
authorJérôme <jerome.lucas@cesgenslab.fr>
Wed, 9 Dec 2020 16:37:41 +0000 (17:37 +0100)
committerJérôme <jerome.lucas@cesgenslab.fr>
Wed, 9 Dec 2020 16:37:41 +0000 (17:37 +0100)
src/ModelAPI/ModelAPI_Feature.cpp
src/PartSet/PartSet_Module.cpp
src/XGUI/XGUI_Workshop.cpp

index 0307d08ccc86cc43f1642a002da03964633e95d1..84fcecef1569818aa3350929d824344b9ebb2dcc 100644 (file)
@@ -74,12 +74,16 @@ void ModelAPI_Feature::setResult(const std::shared_ptr<ModelAPI_Result>& theResu
   if (!isDisabled()) // disabled feature may be executed when it is added as not enabled (#2078)
     theResult->setDisabled(theResult, false);
 
-  bool anIsAutoColor = Config_PropManager::boolean("Visualization", "result_group_Auto_color");
+  Config_Prop* aProp = Config_PropManager::findProp("Visualization", "result_group_Auto_color");
 
-  if (anIsAutoColor && theResult->groupName() == ModelAPI_ResultGroup::group()) {
-    std::vector<int> aColor;
-    ModelAPI_Tools::findRandomColor(aColor);
-    ModelAPI_Tools::setColor(theResult,  aColor);
+  if (aProp) {
+    bool anIsAutoColor = Config_PropManager::boolean("Visualization", "result_group_Auto_color");
+
+    if (anIsAutoColor && theResult->groupName() == ModelAPI_ResultGroup::group()) {
+      std::vector<int> aColor;
+      ModelAPI_Tools::findRandomColor(aColor);
+      ModelAPI_Tools::setColor(theResult,  aColor);
+    }
   }
 }
 
index 0f3a4cfd1bdffe06498ec348ca22c48ec7f187c1..62ed1bd1fd85b0168c85a402097d7d9e5a2ec49c 100644 (file)
@@ -1659,7 +1659,8 @@ void PartSet_Module::processEvent(const std::shared_ptr<Events_Message>& theMess
     CompositeFeaturePtr aSketch = mySketchMgr->activeSketch();
     if (aSketch.get()) {
       ModuleBase_Operation* anOperation = myWorkshop->currentOperation();
-      if (PartSet_SketcherMgr::isSketchOperation(anOperation))
+      if (PartSet_SketcherMgr::isSketchOperation(anOperation)&&
+        mySketchMgr->previewSketchPlane()->isDisplayed())
         mySketchMgr->previewSketchPlane()->createSketchPlane(aSketch, myWorkshop);
     }
   }
index 76605cbae4dc89c2e4abcf51043211093c35c5e0..91030638000729da75e8e5a8b41519ec5ceb6141 100644 (file)
@@ -2518,40 +2518,43 @@ void XGUI_Workshop::changeAutoColor(const QObjectPtrList& theObjects)
   aMgr->startOperation(aDescription.toStdString());
 
   Config_Prop* aProp = Config_PropManager::findProp("Visualization", "result_group_Auto_color");
-  bool anIsAutoColor = Config_PropManager::boolean("Visualization", "result_group_Auto_color");
 
-  if (anIsAutoColor) {
-     contextMenuMgr()->action("AUTOCOLOR_CMD")->setText(tr("Auto color"));
-     aProp->setValue("false");
-  } else {
-    // set the value to all results
-    foreach (ObjectPtr anObj, theObjects) {
-      DocumentPtr aDocument = anObj->document();
-      std::list<FeaturePtr> anAllFeatures = allFeatures(aDocument);
-      // find the object iterator
-      std::list<FeaturePtr>::iterator aObjectIt = anAllFeatures.begin();
-      for (; aObjectIt !=  anAllFeatures.end(); ++ aObjectIt) {
-        FeaturePtr aFeature = *aObjectIt;
-        if (aFeature.get()) {
-          std::list<ResultPtr> aResults;
-          ModelAPI_Tools::allResults(aFeature, aResults);
-          std::list<std::shared_ptr<ModelAPI_Result> >::const_iterator aIt;
-          for (aIt = aResults.cbegin(); aIt != aResults.cend(); aIt++) {
-            ResultPtr aGroupResult = *aIt;
-            if (aGroupResult.get() && aGroupResult->groupName() == ModelAPI_ResultGroup::group()) {
-              ModelAPI_Tools::findRandomColor(aColor);
-              ModelAPI_Tools::setColor(aGroupResult, aColor);
+  if (aProp) {
+    bool anIsAutoColor = Config_PropManager::boolean("Visualization", "result_group_Auto_color");
+    
+    if (anIsAutoColor) {
+      contextMenuMgr()->action("AUTOCOLOR_CMD")->setText(tr("Auto color"));
+      aProp->setValue("false");
+    } else {
+      // set the value to all results
+      foreach (ObjectPtr anObj, theObjects) {
+        DocumentPtr aDocument = anObj->document();
+        std::list<FeaturePtr> anAllFeatures = allFeatures(aDocument);
+        // find the object iterator
+        std::list<FeaturePtr>::iterator aObjectIt = anAllFeatures.begin();
+        for (; aObjectIt !=  anAllFeatures.end(); ++ aObjectIt) {
+          FeaturePtr aFeature = *aObjectIt;
+          if (aFeature.get()) {
+            std::list<ResultPtr> aResults;
+            ModelAPI_Tools::allResults(aFeature, aResults);
+            std::list<std::shared_ptr<ModelAPI_Result> >::const_iterator aIt;
+            for (aIt = aResults.cbegin(); aIt != aResults.cend(); aIt++) {
+              ResultPtr aGroupResult = *aIt;
+              if (aGroupResult.get() && aGroupResult->groupName() == ModelAPI_ResultGroup::group()) {
+                ModelAPI_Tools::findRandomColor(aColor);
+                ModelAPI_Tools::setColor(aGroupResult, aColor);
+              }
             }
           }
         }
       }
+      Events_Loop::loop()->flush(Events_Loop::eventByName(EVENT_OBJECT_TO_REDISPLAY));
+      aMgr->finishOperation();
+      updateCommandStatus();
+      myViewerProxy->update();
+      contextMenuMgr()->action("AUTOCOLOR_CMD")->setText(tr("Disable auto color"));
+      aProp->setValue("true");
     }
-    Events_Loop::loop()->flush(Events_Loop::eventByName(EVENT_OBJECT_TO_REDISPLAY));
-    aMgr->finishOperation();
-    updateCommandStatus();
-    myViewerProxy->update();
-    contextMenuMgr()->action("AUTOCOLOR_CMD")->setText(tr("Disable auto color"));
-    aProp->setValue("true");
   }
 }