Salome HOME
CCAR: merge de la version 1.14 dans la branche principale
[tools/eficas.git] / InterfaceQT / monUniqueBasePanel.py
1 # -*- coding: utf-8 -*-
2 #            CONFIGURATION MANAGEMENT OF EDF VERSION
3 # ======================================================================
4 # COPYRIGHT (C) 1991 - 2002  EDF R&D                  WWW.CODE-ASTER.ORG
5 # THIS PROGRAM IS FREE SOFTWARE; YOU CAN REDISTRIBUTE IT AND/OR MODIFY
6 # IT UNDER THE TERMS OF THE GNU GENERAL PUBLIC LICENSE AS PUBLISHED BY
7 # THE FREE SOFTWARE FOUNDATION; EITHER VERSION 2 OF THE LICENSE, OR
8 # (AT YOUR OPTION) ANY LATER VERSION.
9 #
10 # THIS PROGRAM IS DISTRIBUTED IN THE HOPE THAT IT WILL BE USEFUL, BUT
11 # WITHOUT ANY WARRANTY; WITHOUT EVEN THE IMPLIED WARRANTY OF
12 # MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. SEE THE GNU
13 # GENERAL PUBLIC LICENSE FOR MORE DETAILS.
14 #
15 # YOU SHOULD HAVE RECEIVED A COPY OF THE GNU GENERAL PUBLIC LICENSE
16 # ALONG WITH THIS PROGRAM; IF NOT, WRITE TO EDF R&D CODE_ASTER,
17 #    1 AVENUE DU GENERAL DE GAULLE, 92141 CLAMART CEDEX, FRANCE.
18 #
19 #
20 # ======================================================================
21 # Modules Python
22 import string,types,os
23
24 # Modules Eficas
25 import prefs 
26
27 from qt import *
28
29 from desUniqueBase import DUnBase
30 from qtCommun      import QTPanel
31 from qtSaisie      import SaisieValeur
32 from politiquesValidation import PolitiqueUnique
33
34 # Import des panels
35
36 class MonUniqueBasePanel(DUnBase,QTPanel,SaisieValeur):
37   """
38   Classe définissant le panel associé aux mots-clés qui demandent
39   à l'utilisateur de choisir une seule valeur parmi une liste de valeurs
40   discrètes
41   """
42   def __init__(self,node, parent = None,name = None,fl = 0):
43         self.editor=parent
44         QTPanel.__init__(self,node,parent)
45         DUnBase.__init__(self,parent,name,fl)
46         self.politique=PolitiqueUnique(node,parent)
47         self.InitLineEditVal()
48         self.InitCommentaire()
49         self.detruitBouton()
50
51   def ViewDoc(self):
52       QTPanel.ViewDoc(self)
53
54   def detruitBouton(self):
55         mc = self.node.item.get_definition()
56         type = mc.type[0]
57         #if not('grma' in repr(type)):
58         #if not('grma' in repr(type)) or not(self.editor.salome) :
59         if not(('grma' in repr(type)) or ('grno' in repr(type))) or not(self.editor.salome) :
60            self.BSalome.close()
61            self.BView2D.close()
62
63   def InitLineEditVal(self):
64         valeur=self.node.item.get_valeur()
65         valeurTexte=self.politique.GetValeurTexte(valeur)
66         if valeurTexte != None:
67            try :
68                str=QString("").setNum(valeurTexte)
69            except :
70                str=QString(valeurTexte)
71            self.lineEditVal.setText(str)
72
73
74   def InitCommentaire(self):
75       mc = self.node.item.get_definition()
76       d_aides = { 'TXM' : "Une chaîne de caractères est attendue",
77                   'R'   : "Un réel est attendu",
78                   'I'   : "Un entier est attendu"}
79       type = mc.type[0]
80       commentaire=d_aides.get(type,"Type de base inconnu")
81       aideval=self.node.item.aide()
82       commentaire=commentaire +"\n"+ aideval
83       self.Commentaire.setText(QString(commentaire))
84
85   def BOk2Pressed(self):
86         SaisieValeur.BOk2Pressed(self)
87
88   def BSupPressed(self):
89         QTPanel.BSupPressed(self)
90
91   def LEValeurPressed(self):
92         SaisieValeur.LEValeurPressed(self)
93
94   def BParametresPressed(self):
95         QTPanel.BParametresPressed(self)
96
97   def Ajout1Valeur(self,valeur):
98         SaisieValeur.LEValeurPressed(self,valeur)
99
100   def BSalomePressed(self):
101         genea=self.node.item.get_genealogie()
102         kwType = None
103         for e in genea:
104             if "GROUP_NO" in e: kwType = "GROUP_NO"
105             if "GROUP_MA" in e: kwType = "GROUP_MA"
106
107         selection, commentaire = self.editor.parent.appliEficas.selectGroupFromSalome(kwType,editor=self.editor)
108         if commentaire !="" :
109             self.Commentaire.setText(QString(commentaire))
110         monTexte=""
111         if selection == [] : return
112         for geomElt in selection:
113             monTexte=geomElt+","
114         monTexte= monTexte[0:-1]
115         self.LEValeur.setText(QString(monTexte))
116
117   def BView2DPressed(self):
118         valeur=self.LEValeur.text()
119         if valeur == QString("") : return
120         valeur = str(valeur)
121         if valeur :
122            ok, msgError = self.editor.parent.appliEficas.displayShape(valeur)
123            if not ok:
124               self.editor.parent.appli.affiche_infos(msgError)
125