]> SALOME platform Git repositories - samples/atomgen.git/commitdiff
Salome HOME
Merge multi-study removal branch. Before_python3_27062017
authorrnv <rnv@opencascade.com>
Fri, 9 Jun 2017 10:24:08 +0000 (13:24 +0300)
committerrnv <rnv@opencascade.com>
Tue, 13 Jun 2017 09:55:14 +0000 (12:55 +0300)
CMakeLists.txt
src/ATOMGEN/ATOMGEN.py [changed mode: 0644->0755]
src/ATOMGENGUI/ATOMGENGUI.py [changed mode: 0644->0755]

index fc6effffdc9b6c08e85ce48cdc348b3b8a980a6e..3cf6441f70ed8b3a5ee3ea23088f8f2afab4677f 100755 (executable)
@@ -29,7 +29,7 @@ CMAKE_POLICY(SET CMP0003 NEW)
 STRING(TOUPPER ${PROJECT_NAME} PROJECT_NAME_UC)
 
 SET(${PROJECT_NAME_UC}_MAJOR_VERSION 8)
-SET(${PROJECT_NAME_UC}_MINOR_VERSION 1)
+SET(${PROJECT_NAME_UC}_MINOR_VERSION 3)
 SET(${PROJECT_NAME_UC}_PATCH_VERSION 0)
 SET(${PROJECT_NAME_UC}_VERSION
   ${${PROJECT_NAME_UC}_MAJOR_VERSION}.${${PROJECT_NAME_UC}_MINOR_VERSION}.${${PROJECT_NAME_UC}_PATCH_VERSION})
old mode 100644 (file)
new mode 100755 (executable)
index f72199c..58e5a38
@@ -61,10 +61,12 @@ class ATOMGEN( ATOMGEN_ORB__POA.ATOMGEN_Gen,
                                                           instanceName, interfaceName, 0 )
         SALOME_DriverPy.SALOME_DriverPy_i.__init__( self, interfaceName )
         
+        self._orb = orb
         self._naming_service = SALOME_ComponentPy.SALOME_NamingServicePy_i( self._orb )
-        self.study = None
-        self.studyData = None
-        self.entry2PyName = None
+        obj = self._naming_service.Resolve( '/Study' )
+        self.study = obj._narrow( SALOMEDS.Study )
+        self.studyData = []
+        self.entry2PyName = {}
         pass
 
     def getVersion( self ):
@@ -75,13 +77,10 @@ class ATOMGEN( ATOMGEN_ORB__POA.ATOMGEN_Gen,
         """
         Gets study data
         """
-        if self.studyData:
-            l = []
-            for m in self.studyData:
-                l.append( m._this() )
-            return l
-        print "ATOMGEN: getData() failed because study was not found"
-        return []
+        l = []
+        for m in self.studyData:
+            l.append( m._this() )
+        return l
 
     def Save( self, component, URL, isMultiFile ):
         """
@@ -98,9 +97,7 @@ class ATOMGEN( ATOMGEN_ORB__POA.ATOMGEN_Gen,
         global __entry2IOR__
         __entry2IOR__.clear()
         import StringIO, pickle
-        study = salome.myStudy
-        self.study = study
-        iter = study.NewChildIterator(component)
+        iter = self.study.NewChildIterator(component)
         data = []
         while iter.More():
             sobject = iter.Value()
@@ -110,7 +107,7 @@ class ATOMGEN( ATOMGEN_ORB__POA.ATOMGEN_Gen,
             from ATOMGEN_Data import Molecule, Atom
             mol = Molecule(attr.Value())
             __entry2IOR__[sobject.GetID()] = ObjectToString(mol._this())
-            iter1 = study.NewChildIterator(sobject)
+            iter1 = self.study.NewChildIterator(sobject)
             while iter1.More():
                 sobject1 = iter1.Value()
                 iter1.Next()
@@ -118,7 +115,7 @@ class ATOMGEN( ATOMGEN_ORB__POA.ATOMGEN_Gen,
                 if not found: continue
                 name = attr.Value()
                 x = y = z = None
-                iter2 = study.NewChildIterator(sobject1)
+                iter2 = self.study.NewChildIterator(sobject1)
                 while iter2.More():
                     sobject2 = iter2.Value()
                     iter2.Next()
@@ -156,12 +153,7 @@ class ATOMGEN( ATOMGEN_ORB__POA.ATOMGEN_Gen,
         """
         Called when study is closed
         """
-        study = salome.myStudy
-        if self.studyData:
-            self.studyData = None
-        if study == self.study:
-            self.study = None
-        pass
+        self.studyData = []
 
     def CanPublishInStudy( self, IOR ):
         """
@@ -308,12 +300,9 @@ class ATOMGEN( ATOMGEN_ORB__POA.ATOMGEN_Gen,
                 if so is not None:
                     entries.append(so.GetID())
         # store data
-        if self.studyData:
-            data = self.studyData
-            data += new_data
-            self.studyData = data
-            return entries
-        print "ATOMGEN: could not append new data"
+        data = self.studyData
+        data += new_data
+        self.studyData = data
         return entries
 
     def _translateMolecule( self, mol, i, dx, dy, dz ):
@@ -392,14 +381,14 @@ class ATOMGEN( ATOMGEN_ORB__POA.ATOMGEN_Gen,
         if self.study is None:
             return
         
-        self.entry2PyName = None
+        self.entry2PyName = {}
         iter = self.study.NewChildIterator(self.study.FindComponent(self._ComponentDataType))
         while iter.More():
             sobject = iter.Value()
-            iter.Next()            
+            iter.Next()
             found, attr = sobject.FindAttribute("AttributeName")
             if not found: continue
-            self.entry2PyName[sobject.GetID()] = self._fixPythonName(attr.Value())            
+            self.entry2PyName[sobject.GetID()] = self._fixPythonName(attr.Value())
             
     def _fixPythonName(self, in_str):
         """
old mode 100644 (file)
new mode 100755 (executable)
index 365005a..ebfd4ae
@@ -40,7 +40,7 @@ __CMD_RUN_ALGO__   = 4002
 __CMD_RUN_ALGO1__  = 4010
 
 # study data
-__study_data__ = None
+__study_data__ = {}
 
 ################################################
 # Init GUI wrappers
@@ -163,7 +163,7 @@ def activate():
     global myStudy
     global __study_data__
     myStudy = _getStudy()
-    _getEngine().study = myStudy
+    _getEngine()
 
     # create actions
     __study_data__[ "actions" ] = {}
@@ -241,10 +241,10 @@ def OnGUIEvent( commandId ):
     """
     print "ATOMGENGUI::OnGUIEvent: commandId =", commandId
     if dict_command.has_key( commandId ):
-        try:
-            dict_command[ commandId ]()
-        except Exception, e:
-            processException( e )
+#        try:
+         dict_command[ commandId ]()
+#        except Exception, e:
+#            processException( e )
     else:
        print "ATOMGENGUI::OnGUIEvent: Action is not implemented: ", commandId
     pass