1 # -*- coding: utf-8 -*-
2 # Copyright (C) 2007-2017 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 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
25 from __future__ import absolute_import
27 from builtins import str
31 # import modules Python
33 from Extensions.i18n import tr
35 # import modules EFICAS
36 from Editeur import Objecttreeitem
38 from . import typeNode
41 class Node(browser.JDCNode,typeNode.PopUpMenuNodePartiel):
45 from .monWidgetParam import MonWidgetParam
46 return MonWidgetParam(self, self.editor,self.item.object)
48 def createPopUpMenu(self):
49 typeNode.PopUpMenuNodePartiel.createPopUpMenu(self)
50 self.menu.removeAction(self.Documentation)
52 def doPaste(self,node_selected,pos='after'):
57 class PARAMTreeItem(Objecttreeitem.ObjectTreeItem):
59 Classe servant a definir l'item porte par le noeud de l'arbre d'EFICAS
60 qui represente le PARAMETRE
65 self.setFunction = self.setValeur
67 # ---------------------------------------------------------------------------
68 # API du PARAMETRE pour l'arbre
69 # ---------------------------------------------------------------------------
71 def getIconName(self):
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 ...
79 return "ast-green-square"
81 return "ast-red-square"
83 return "ast-white-square"
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
91 return tr('PARAMETRE'),None,None
95 Retourne le texte a afficher apres le nom de la commande (ici apres 'parametre')
96 Ce texte est tronque a 25 caracteres
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]
108 return texte[0:24]+'...'
110 def getSubList(self):
112 Retourne la liste des fils de self
116 # ---------------------------------------------------------------------------
117 # Methodes permettant la modification et la lecture des attributs
118 # du parametre = API graphique du PARAMETRE pour Panel et EFICAS
119 # ---------------------------------------------------------------------------
123 Retourne la valeur de l'objet PARAMETRE cad son texte
125 if self.object.valeur is None: return ''
126 else: return self.object.valeur
130 Retourne le nom du parametre
132 return self.object.nom
134 def setValeur(self,new_valeur):
136 Affecte valeur a l'objet PARAMETRE
138 self.object.setValeur(new_valeur)
140 def setNom(self,new_nom):
144 self.object.setNom(new_nom)
145 #self.object.setAttribut('nom',new_nom)
149 Retourne le fr associe au parametre, cad la bulle d'aide pour EFICAS
151 return tr("Definition d'un parametre")
153 import Extensions.parametre
154 treeitem =PARAMTreeItem
155 objet = Extensions.parametre.PARAMETRE