]> SALOME platform Git repositories - modules/eficas.git/blob - src/EFICASGUI/EFICASGUI.py
Salome HOME
Intégration eficas_novice
[modules/eficas.git] / src / EFICASGUI / EFICASGUI.py
1 """
2     Interface PyQt
3 """
4 import qt
5 import libSALOME_Swig
6 import SalomePyQt
7
8 # Variable globale pour stocker le Workspace de Salome
9
10 WORKSPACE=None
11 currentStudyId=None
12 desktop=None
13
14 # -----------------------------------------------------------------------------
15
16 import notifqt
17 #import Tkinter
18 #root.withdraw()
19
20 def g():
21    print "lastWindowClosed()"
22    import Tkinter
23    root=Tkinter.Tk()
24    root.destroy()
25
26 qt.QObject.connect(qt.qApp,qt.SIGNAL("lastWindowClosed()"),g)
27
28 # -----------------------------------------------------------------------------
29
30 import salome
31
32 sg=salome.sg
33 sgPyQt=SalomePyQt.SalomePyQt()
34 import salomedsgui
35 aGuiDS=salomedsgui.guiDS()
36 print "EFicasGUI :: :::::::::::::::::::::::::::::::::::::::::::::::::::::"
37
38 # -----------------------------------------------------------------------------
39
40 def setWorkSpace(workSpace):
41    print "EficasGUI --- setWorkSpace"
42    global WORKSPACE
43    print workSpace
44    WORKSPACE=workSpace
45    print "WORKSPACE: ",WORKSPACE
46    # le desktop
47    desktop=sgPyQt.getDesktop()
48
49    # creation d'une message box
50    #qt.QMessageBox.information(d,"titre","message")
51
52    # recuperation du workspace
53    ws=sgPyQt.getMainFrame()
54    print ws
55
56 # -----------------------------------------------------------------------------
57
58 def OnGUIEvent(commandID) :
59    print "EficasGUI :: OnGUIEvent :::::::::::::::::::::::::::::::::commandID,WORKSPACE = ",commandID,WORKSPACE
60    if dict_command.has_key(commandID):
61       print "OnGUIEvent ::::::::::  commande associée  : ",commandID      
62       dict_command[commandID](WORKSPACE)
63    else:
64       print "Pas de commande associée a : ",commandID
65
66 # -----------------------------------------------------------------------------
67
68 def setSettings():
69    """
70    Cette méthode permet les initialisations. On définit en particulier
71    l'identifiant de l'étude courante.
72    """
73    # le desktop
74    desktop=sgPyQt.getDesktop()
75    global currentStudyId
76    currentStudyId = sgPyQt.getStudyId()
77    print "setSettings: currentStudyId = " + str(currentStudyId)
78    # _CS_gbo_ Voir si on peut utiliser directement sgPyQt.getStudyId()
79    # dans salomedsgui?
80
81
82 # -----------------------------------------------------------------------------
83
84 def activeStudyChanged(ID):
85    # le desktop
86    desktop=sgPyQt.getDesktop()
87    global currentStudyId
88    # ne marche pas car sg est supposé résider dans une etude
89    # studyId=sg.getActiveStudyId()
90    currentStudyId=ID
91    print "_CS_GBO_ : EFICASGUI.activeStudyChanged : currentStudyId = ", currentStudyId
92    print "_CS_GBO_ : EFICASGUI.activeStudyChanged : sgPyQt.getStudyId() = ", sgPyQt.getStudyId()
93
94 def definePopup(theContext, theObject, theParent):
95    print "EFICASGUI --- definePopup"
96    theContext = ""
97    theParent = "ObjectBrowser"
98    a=salome.sg.getAllSelected()
99    if len(a) >0:
100        theObject="73"
101    return (theContext, theObject, theParent)
102
103
104 def customPopup(popup, theContext, theObject, theParent):
105    print "EFICASGUI --- customPopup"
106    popup.removeItem(99000)
107    popup.removeItem(99001)
108    popup.removeItem(99002)
109    popup.removeItem(99003)
110
111
112 # -----------------------------------------------------------------------------
113
114 import eficasSalome
115
116 def runEficas(ws):
117    print "--------------------------------------------------"
118    print currentStudyId
119    eficasSalome.runEficas(ws,"ASTER",studyId=currentStudyId)
120    
121 def runEELIH(ws,code="ASTER"):
122    # Enregistrement dans l étude
123    import eficasEtude
124    import appli
125    print "++++++++++++++++++++++++++++++++++++++++++++++++++++"
126    print currentStudyId
127    
128    MaRef=eficasEtude.Eficas_In_Study(code,studyId=currentStudyId)
129    # flag = E pour Eficas (enregistrement manuel du fichier de commandes)
130    flag = 'E'
131    moi=appli.Appli(MaRef, flag)
132    
133 def runEficaspourHomard(ws):
134    print "runEficas"
135    eficasSalome.runEficas(ws,"HOMARD")
136     
137 def runEficasHomard(ws):
138    print "runEficas"
139    eficasSalome.runEficas(None,"HOMARD")
140
141 def runEficasFichier(ws):
142    """
143    Lancement d'eficas à partir d'un fichier sélectionné dans l'arbre
144    d'étude. 
145    """
146    print "runEficasFichier"
147    attr=None
148    code="ASTER"
149    a=salome.sg.getAllSelected()
150    if len(a) == 1:
151       aGuiDS.setCurrentStudy(currentStudyId)
152       boo,attr=aGuiDS.getExternalFileAttribute("FICHIER_EFICAS_ASTER",a[0])
153       if boo :
154          code = "ASTER" 
155       else :
156          boo,attr=aGuiDS.getExternalFileAttribute("FICHIER_EFICAS_HOMARD",a[0])
157          code = "HOMARD"
158    
159    eficasSalome.runEficas(ws,code,attr,studyId=currentStudyId)
160
161 # Partie applicative
162
163 dict_command={
164                941:runEficas,
165                943:runEELIH,
166                946:runEficaspourHomard,
167                4041:runEficas,
168                4043:runEELIH,
169                4046:runEficaspourHomard,
170                9042:runEficasFichier,
171              }
172