1 # -*- coding: iso-8859-1 -*-
2 # Copyright (C) 2014-2016 CEA/DEN, EDF R&D, OPEN CASCADE
4 # This library is free software; you can redistribute it and/or
5 # modify it under the terms of the GNU Lesser General Public
6 # License as published by the Free Software Foundation; either
7 # version 2.1 of the License, or (at your option) any later version.
9 # This library is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 # Lesser General Public License for more details.
14 # You should have received a copy of the GNU Lesser General Public
15 # License along with this library; if not, write to the Free Software
16 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
21 from GEOM import IXAOOperations
24 __libraryName__ = "XAOPluginEngine"
26 def GetXAOPluginOperations(self):
27 anOp = self.GetPluginOperations(self.myStudyId, __libraryName__)
28 return anOp._narrow(IXAOOperations)
30 ## Export a shape to XAO format
31 # @param shape The shape to export
32 # @param groups The list of groups to export
33 # @param fields The list of fields to export
34 # @param author The author of the file
35 # @param fileName The name of the file to export
36 # @return True if operation is successful or False otherwise
38 # @ingroup l2_import_export
39 def ExportXAO(self, shape, groups, fields, author, fileName):
41 Export a shape to XAO format
44 shape The shape to export
45 groups The list of groups to export
46 fields The list of fields to export
47 author The author of the file
48 fileName The name of the file to export
51 True if operation is successful or False otherwise
53 from salome.geom.geomBuilder import RaiseIfFailed
54 anOp = GetXAOPluginOperations(self)
55 res = anOp.ExportXAO(shape, groups, fields, author, fileName)
56 RaiseIfFailed("ExportXAO", anOp)
59 ## Import a shape from XAO format
60 # @param fileName The name of the file to import
61 # @param theName Object name; when specified, this parameter is used
62 # for result publication in the study. Otherwise, if automatic
63 # publication is switched on, default value is used for result name.
65 # @return tuple (\a res, \a shape, \a subShapes, \a groups, \a fields)
66 # \a res Flag indicating if the import was successful
67 # \a shape The imported shape
68 # \a subShapes The list of imported subShapes
69 # \a groups The list of imported groups
70 # \a fields The list of imported fields
72 # @ingroup l2_import_export
73 def ImportXAO(self, fileName, theName=None):
75 Import a shape from XAO format
78 fileName The name of the file to import
79 theName Object name; when specified, this parameter is used
80 for result publication in the study. Otherwise, if automatic
81 publication is switched on, default value is used for result name.
84 A tuple (res, shape, subShapes, groups, fields):
85 - res: Flag indicating if the import was successful
86 - shape: The imported shape
87 - subShapes: The list of imported subShapes
88 - groups: The list of imported groups
89 - fields: The list of imported fields
91 from salome.geom.geomBuilder import RaiseIfFailed
92 anOp = GetXAOPluginOperations(self)
93 res = anOp.ImportXAO(fileName)
94 RaiseIfFailed("ImportXAO", anOp)
95 self._autoPublish(res[1], theName, "imported")