Salome HOME
Merge remote-tracking branch 'remotes/origin/Dev_FolderFeature'
[modules/shaper.git] / src / PythonAPI / model / dump / DumpAssistant.py
index b4a27add1a8050dc10a825b2f209a7497cd840de..0cdebfdfefe8b2e29eaf0b65026fc2cd59e74297 100644 (file)
@@ -1,3 +1,23 @@
+## Copyright (C) 2014-2017  CEA/DEN, EDF R&D
+##
+## This library is free software; you can redistribute it and/or
+## modify it under the terms of the GNU Lesser General Public
+## License as published by the Free Software Foundation; either
+## version 2.1 of the License, or (at your option) any later version.
+##
+## This library is distributed in the hope that it will be useful,
+## but WITHOUT ANY WARRANTY; without even the implied warranty of
+## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+## Lesser General Public License for more details.
+##
+## You should have received a copy of the GNU Lesser General Public
+## License along with this library; if not, write to the Free Software
+## Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+##
+## See http:##www.salome-platform.org/ or
+## email : webmaster.salome@opencascade.com<mailto:webmaster.salome@opencascade.com>
+##
+
 """Package for dumping purposes.
 """
 
@@ -29,10 +49,12 @@ class DumpAssistant(ModelHighAPI.ModelHighAPI_Dumper):
     ## Collect feature wrappers, which allow dumping (have method dump)
     def collectFeatures(self):
         self.myFeatures = {}
+        self.myWrapperNames = {}
         for aModule in sys.modules:
             for aName, anObj in inspect.getmembers(sys.modules[aModule], inspect.isclass):
                 if issubclass(anObj, ModelHighAPI.ModelHighAPI_Interface) and hasattr(anObj, "ID") and anObj.dump != ModelHighAPI.ModelHighAPI_Interface.dump:
                     self.myFeatures[anObj.ID()] = anObj
+                    self.myWrapperNames[anObj.ID()] = aName
 
     ## Create wrapper for a given feature and dump it
     def dumpFeature(self, theFeature, theForce):
@@ -50,6 +72,11 @@ class DumpAssistant(ModelHighAPI.ModelHighAPI_Dumper):
             # In case of theFeature is not a constraint, it will not be dumped.
             self.myFeatures[SketchAPI.SketchAPI_Constraint.ID()](theFeature).dump(self)
 
+    ## Create wrapper for a folder and dump it
+    def dumpFolder(self, theFolder):
+        if theFolder.ID() in self.myFeatures:
+            self.myFeatures[theFolder.ID()](theFolder).dump(self)
+
     ## Dump all parameters
     def dumpParameter(self, theFeature):
         aFeatureKind = theFeature.getKind()
@@ -63,5 +90,12 @@ class DumpAssistant(ModelHighAPI.ModelHighAPI_Dumper):
             return self.myFeatures[aFeatureKind](theFeature).attributeGetter(theAttrName)
         return std_string()
 
+    ## Return name of wrapper feature
+    def featureWrapper(self, theFeature):
+        aFeatureKind = theFeature.getKind()
+        if aFeatureKind in self.myWrapperNames:
+            return self.myWrapperNames[aFeatureKind]
+        return std_string()
+
 # Instance of dumper
 dumper = DumpAssistant
\ No newline at end of file