]> SALOME platform Git repositories - tools/eficas.git/blob - InterfaceQT4/compoparam.py
Salome HOME
bug sur un mesage dans une exception sur un validator (cf JPA)
[tools/eficas.git] / InterfaceQT4 / compoparam.py
1 # -*- coding: utf-8 -*-
2 # Copyright (C) 2007-2021   EDF R&D
3 #
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.
8 #
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.
13 #
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
17 #
18 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
19 #
20 """
21    Ce module contient les classes permettant de definir les objets graphiques
22    representant un objet de type PARAMETRE, cad le panneau et l'item de l'arbre
23    d'EFICAS
24 """
25 from __future__ import absolute_import
26 try :
27     from builtins import str
28 except : pass
29
30
31 # import modules Python
32 import  types
33 from Extensions.i18n import tr
34
35 # import modules EFICAS
36 from Editeur     import Objecttreeitem
37 from . import browser
38 from . import typeNode
39
40
41 class Node(browser.JDCNode,typeNode.PopUpMenuNodePartiel):
42     def getPanel(self):
43         """
44         """
45         from .monWidgetParam  import MonWidgetParam
46         return MonWidgetParam(self, self.editor,self.item.object)
47
48     def createPopUpMenu(self):
49         typeNode.PopUpMenuNodePartiel.createPopUpMenu(self)
50         self.menu.removeAction(self.Documentation)
51
52     def doPaste(self,node_selected,pos='after'):
53         return None
54
55
56
57 class PARAMTreeItem(Objecttreeitem.ObjectTreeItem):
58     """
59     Classe servant a definir l'item porte par le noeud de l'arbre d'EFICAS
60     qui represente le PARAMETRE
61     """
62     itemNode=Node
63
64     def init(self):
65         self.setFunction = self.setValeur
66
67 # ---------------------------------------------------------------------------
68 #                   API du PARAMETRE pour l'arbre
69 # ---------------------------------------------------------------------------
70
71     def getIconName(self):
72         """
73         Retourne le nom de l'icone associee au noeud qui porte self,
74         dependant de la validite de l'objet
75         NB : un PARAMETRE est toujours valide ...
76         """
77         if self.isActif():
78             if self.isValid():
79                 return "ast-green-square"
80             else:
81                 return "ast-red-square"
82         else:
83             return "ast-white-square"
84
85     def getLabelText(self):
86         """ Retourne 3 valeurs :
87         - le texte a afficher dans le noeud representant l'item
88         - la fonte dans laquelle afficher ce texte
89         - la couleur du texte
90         """
91         return tr('PARAMETRE'),None,None
92
93     def getText(self):
94         """
95         Retourne le texte a afficher apres le nom de la commande (ici apres 'parametre')
96         Ce texte est tronque a 25 caracteres
97         """
98         texte=self.object.nom+"="+str(self.object.valeur)
99         if type(self.object.valeur) == list :
100             texte=self.nom+' = ['
101             for l in self.object.valeur :
102                 texte=texte+str(l) +","
103             texte=texte[0:-1]+']'
104         texte = texte.split('\n')[0]
105         if len(texte) < 25 :
106             return texte
107         else :
108             return texte[0:24]+'...'
109
110     def getSubList(self):
111         """
112         Retourne la liste des fils de self
113         """
114         return []
115
116 # ---------------------------------------------------------------------------
117 #       Methodes permettant la modification et la lecture des attributs
118 #       du parametre = API graphique du PARAMETRE pour Panel et EFICAS
119 # ---------------------------------------------------------------------------
120
121     def getValeur(self):
122         """
123         Retourne la valeur de l'objet PARAMETRE cad son texte
124         """
125         if self.object.valeur is None: return ''
126         else: return self.object.valeur
127
128     def getNom(self):
129         """
130         Retourne le nom du parametre
131         """
132         return self.object.nom
133
134     def setValeur(self,new_valeur):
135         """
136         Affecte valeur a l'objet PARAMETRE
137         """
138         self.object.setValeur(new_valeur)
139
140     def setNom(self,new_nom):
141         """
142         Renomme le parametre
143         """
144         self.object.setNom(new_nom)
145         #self.object.setAttribut('nom',new_nom)
146
147     def getFr(self):
148         """
149         Retourne le fr associe au parametre, cad la bulle d'aide pour EFICAS
150         """
151         return tr("Definition d'un parametre")
152
153 import Extensions.parametre
154 treeitem =PARAMTreeItem
155 objet = Extensions.parametre.PARAMETRE