]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Task #3223: Improve Python dump readability
authorArtem Zhidkov <Artem.Zhidkov@opencascade.com>
Mon, 22 Jun 2020 10:38:11 +0000 (13:38 +0300)
committerArtem Zhidkov <Artem.Zhidkov@opencascade.com>
Mon, 22 Jun 2020 10:38:11 +0000 (13:38 +0300)
Fix the wrong script generation if a group contains filters.

src/ModelHighAPI/ModelHighAPI_Dumper.cpp
src/ModelHighAPI/ModelHighAPI_Dumper.h
src/PythonAPI/model/dump/DumpAssistant.py

index 5352af49710ce0f43dc4e4116c758aae69d034f0..cf359fc6559acb4db1150315cb56120237fd05cc 100644 (file)
@@ -1060,6 +1060,16 @@ bool ModelHighAPI_Dumper::isDefaultTransparency(const ResultPtr& theResult) cons
   return fabs(anAttribute->value()) < 1.e-12;
 }
 
+bool ModelHighAPI_Dumper::dumpCommentBeforeFeature(const FeaturePtr& theFeature) const
+{
+  // currently, the comment should not be dumped only before the filters
+  FiltersFeaturePtr aFilters = std::dynamic_pointer_cast<ModelAPI_FiltersFeature>(theFeature);
+  if (aFilters)
+    return false;
+  // all other features should be commented before the dump
+  return true;
+}
+
 ModelHighAPI_Dumper& ModelHighAPI_Dumper::operator<<(const char theChar)
 {
   *myDumpStorage << theChar;
index 8f480c0f16441009b0fac907633dd444a2fae161..aceab146508946a34e8f5abf47b381a50e4a91c5 100644 (file)
@@ -356,6 +356,10 @@ public:
   MODELHIGHAPI_EXPORT virtual void exportVariable(
     const std::string& theEntry, const std::string& theVarName) const {}
 
+  /// Returns \c true if the special comment line to improve the readability
+  /// should be printed before the feature of the given kind.
+  MODELHIGHAPI_EXPORT bool dumpCommentBeforeFeature(const FeaturePtr& theFeature) const;
+
 protected:
   /// Dump "setName" command if last entity had user-defined name
   MODELHIGHAPI_EXPORT void dumpEntitySetName();
index 08007616d957acdd2d34c2abca27eb84ceb50aa2..1f254a5a926a62891e16c26d65aeaa01cec237c6 100644 (file)
@@ -67,8 +67,9 @@ class DumpAssistant(ModelHighAPI.ModelHighAPI_Dumper):
             if theForce or theFeature.isInHistory() or aFeatureKind=="Export" or aFeatureKind=="RemoveResults":
                 aDumper = self.myFeatures[aFeatureKind](theFeature)
                 # Dump comment for the operation before the dumping of the feature to improve the readability of a script.
-                self.__print__("\n### Create " + theFeature.getKind())
-                self.newline()
+                if self.dumpCommentBeforeFeature(theFeature):
+                    self.__print__("\n### Create " + theFeature.getKind())
+                    self.newline()
             else:
                 self.name(theFeature)
                 self.clearNotDumped()