Salome HOME
Issue #2156 Impossible to valid the sketch: better debug information about store...
[modules/shaper.git] / src / ModuleBase / ModuleBase_Tools.cpp
index 8a671f0bbf123fbfd3b78701c1a076da78ba1ebc..c505732941a6984b43cc223c2269e7a34b7f6ec8 100755 (executable)
@@ -267,6 +267,14 @@ QAction* createAction(const QIcon& theIcon, const QString& theText,
 }
 
 #ifdef _DEBUG
+QString objectName(const ObjectPtr& theObj)
+{
+  if (!theObj.get())
+    return "";
+
+  return theObj->data()->name().c_str();
+}
+
 QString objectInfo(const ObjectPtr& theObj, const bool isUseAttributesInfo)
 {
   QString aFeatureStr = "feature";
@@ -345,12 +353,13 @@ int shapeType(const QString& theType)
 }
 
 void checkObjects(const QObjectPtrList& theObjects, bool& hasResult, bool& hasFeature,
-                  bool& hasParameter, bool& hasCompositeOwner)
+                  bool& hasParameter, bool& hasCompositeOwner, bool& hasResultInHistory)
 {
   hasResult = false;
   hasFeature = false;
   hasParameter = false;
   hasCompositeOwner = false;
+  hasResultInHistory = false;
   foreach(ObjectPtr aObj, theObjects) {
     FeaturePtr aFeature = std::dynamic_pointer_cast<ModelAPI_Feature>(aObj);
     ResultPtr aResult = std::dynamic_pointer_cast<ModelAPI_Result>(aObj);
@@ -361,6 +370,12 @@ void checkObjects(const QObjectPtrList& theObjects, bool& hasResult, bool& hasFe
     hasParameter |= (aConstruction.get() != NULL);
     if (hasFeature)
       hasCompositeOwner |= (ModelAPI_Tools::compositeOwner(aFeature) != NULL);
+
+    if (!hasResultInHistory && aResult.get()) {
+      FeaturePtr aFeature = ModelAPI_Feature::feature(aResult);
+      hasResultInHistory = aFeature.get() && aFeature->isInHistory();
+    }
+
     if (hasFeature && hasResult  && hasParameter && hasCompositeOwner)
       break;
   }
@@ -412,20 +427,17 @@ void setDefaultDeviationCoefficient(const TopoDS_Shape& theShape,
 
   double aDeflection;
   if (isConstruction)
-    aDeflection = Config_PropManager::real("Visualization", "construction_deflection",
-                                           ModelAPI_ResultConstruction::DEFAULT_DEFLECTION());
+    aDeflection = Config_PropManager::real("Visualization", "construction_deflection");
   else
-    aDeflection = Config_PropManager::real("Visualization", "body_deflection",
-                                           ModelAPI_ResultBody::DEFAULT_DEFLECTION());
+    aDeflection = Config_PropManager::real("Visualization", "body_deflection");
 
   theDrawer->SetDeviationCoefficient(aDeflection);
 }
 
 Quantity_Color color(const std::string& theSection,
-                     const std::string& theName,
-                     const std::string& theDefault)
+                     const std::string& theName)
 {
-  std::vector<int> aColor = Config_PropManager::color(theSection, theName, theDefault);
+  std::vector<int> aColor = Config_PropManager::color(theSection, theName);
   return Quantity_Color(aColor[0] / 255., aColor[1] / 255., aColor[2] / 255., Quantity_TOC_RGB);
 }
 
@@ -697,7 +709,12 @@ void flushUpdated(ObjectPtr theObject)
 {
   blockUpdateViewer(true);
 
+  // Fix the problem of not previewed results of constraints applied. Flush Create/Delete
+  // (for the sketch result) to start processing of the sketch in the solver.
+  // TODO: these flushes should be moved in a separate method provided by Model
+  Events_Loop::loop()->flush(Events_Loop::eventByName(EVENT_OBJECT_CREATED));
   Events_Loop::loop()->flush(Events_Loop::eventByName(EVENT_OBJECT_UPDATED));
+  Events_Loop::loop()->flush(Events_Loop::eventByName(EVENT_OBJECT_DELETED));
 
   blockUpdateViewer(false);
 }