1 # -*- coding: iso-8859-1 -*-
2 # Copyright (C) 2010 EDF R&D
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.
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 __author__="aribes/gboulant"
23 from enumerate import Enumerate
25 import datassimModuleHelper
26 from daGuiImpl.datassimCase import DatassimCase
29 # ==============================================================================
30 # Constant parameters and identifiers
31 # ==============================================================================
33 DATASSIM_ITEM_TYPES = Enumerate([
38 # ==============================================================================
39 # Function dedicated to the data management in the salome study
40 # ==============================================================================
42 # For developpers, note that the data structures used here are:
43 # - the SALOME study whose API is defined by SALOMEDS::Study
44 # - an item in a study whose API is defined by SALOMEDS:SObject
45 # - a study component, whose API is defined by SALOMEDS::SComponent
46 # a SComponent is a reference in a study toward a SALOME component
49 def addInStudy(salomeStudyId, datassimCase):
51 This function adds in the specified SALOME study a study entry that corresponds
52 to the specified datassim case. This study case is put in a folder under
53 the DATASSIM component and is identified by the case name.
56 studyEditor = studyedit.getStudyEditor(salomeStudyId)
58 datassimRootEntry = studyEditor.findOrCreateComponent(
59 engineName = datassimModuleHelper.componentName(),
60 componentName = datassimModuleHelper.componentUserName())
62 itemName = datassimCase.get_name()
64 itemType = DATASSIM_ITEM_TYPES.DATASSIM_CASE
66 salomeStudyItem = studyEditor.createItem(
67 datassimRootEntry, itemName,
70 # _MEM_ Note that we use the comment attribute to store the serialize
71 # description of the data.
73 return salomeStudyItem
75 def updateItem(salomeStudyId, salomeStudyItem, datassimCase):
77 studyEditor = studyedit.getStudyEditor(salomeStudyId)
79 itemName = datassimCase.get_name()
82 studyEditor.setItem(salomeStudyItem,
86 def removeItem(salomeStudyId, item):
88 Remove the item from the specified study.
90 studyEditor = studyedit.getStudyEditor(salomeStudyId)
91 return studyEditor.removeItem(item,True)
94 def isValidDatassimCaseItem(salomeStudyId,item):
96 Return true if the specified item corresponds to a valid datassimCase
101 studyEditor = studyedit.getStudyEditor(salomeStudyId)
102 itemType = studyEditor.getTypeId(item)
103 if itemType != DATASSIM_ITEM_TYPES.DATASSIM_CASE: