1 # Copyright (C) 2007-2021 EDF R&D
3 # This library is free software; you can redistribute it and/or
4 # modify it under the terms of the GNU Lesser General Public
5 # License as published by the Free Software Foundation; either
6 # version 2.1 of the License.
8 # This library is distributed in the hope that it will be useful,
9 # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 # Lesser General Public License for more details.
13 # You should have received a copy of the GNU Lesser General Public
14 # License along with this library; if not, write to the Free Software
15 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
20 from __future__ import absolute_import
21 from PyQt5.QtCore import Qt, QTimer
22 from PyQt5.QtWidgets import QWidget
27 from .groupe import Groupe
28 from desWidgetFact import Ui_WidgetFact
29 from desWidgetFactTableau import Ui_WidgetFactTableau
30 from Extensions.i18n import tr
33 # PN 18 mai 2020 : affiche systematique des optionnels
34 class MonWidgetFactCommun(Groupe):
37 def __init__(self,node,editor,parentQt,definition, obj, niveau,commande):
38 #print "fact : ",node.item.nom
39 Groupe.__init__(self,node,editor,parentQt, definition,obj,niveau,commande)
40 labeltext,fonte,couleur = self.node.item.getLabelText()
41 self.GroupBox.setText(tr(labeltext))
42 self.GroupBox.setTextInteractionFlags(Qt.TextSelectableByMouse)
43 self.parentQt.commandesLayout.insertWidget(-1,self)
44 self.doitAfficherOptionnel=True
45 min,max=obj.getMinMax()
46 if max < 2 and hasattr(self, 'RBPlus') : self.RBPlus.close()
47 if max > 1 and hasattr(self, 'RBPlus') : self.RBPlus.clicked.connect(self.ajouteMCParPB)
49 def enterEvent(self,event):
50 #print "enterEvent ", self.node.item.getLabelText()[0]
51 self.doitAfficherOptionnel=True
52 QWidget.enterEvent(self,event)
53 QTimer.singleShot(500, self.delayAffiche)
55 def leaveEvent(self,event):
56 #print "leaveEvent", self.node.item.getLabelText()[0]
57 #self.doitAfficherOptionnel=False
58 QWidget.leaveEvent(self,event)
60 def delayAffiche(self):
61 #print "delayAffiche, self.doitAfficherOptionnel = ", self.doitAfficherOptionnel
62 if self.doitAfficherOptionnel and self.editor.code != "CARMELCND" :self.afficheOptionnel()
64 def ajouteMCParPB(self):
65 texteListeNom="+"+self.obj.nom
66 parentOuAjouter=self.parentQt
67 from .monWidgetBloc import MonWidgetBloc
68 while (parentOuAjouter and isinstance(parentOuAjouter, MonWidgetBloc)) :
69 parentOuAjouter=parentOuAjouter.parentQt
70 parentOuAjouter.ajoutMC(texteListeNom)
73 # def reaffiche(self, nodeAVoir=None):
74 # print ('ds reaffiche : ', self.obj.nom, self.node.firstDeplie)
75 # if self.node.editor.maConfiguration.afficheFirstPlies and self.node.firstDeplie:
76 # self.node.firstDeplie =False
78 # Groupe.reaffiche(self,nodeAVoir)
82 class MonWidgetFact(Ui_WidgetFact,MonWidgetFactCommun):
83 #def __init__(self,node,editor,parentQt,definition, obj, niveau,commande,insertIn=1):
84 # MonWidgetFactCommun.__init__(self,node,editor,parentQt, definition,obj,niveau,commande,insertIn)
85 def __init__(self,node,editor,parentQt,definition, obj, niveau,commande):
86 MonWidgetFactCommun.__init__(self,node,editor,parentQt, definition,obj,niveau,commande)
88 class MonWidgetFactTableau(Ui_WidgetFact,MonWidgetFactCommun):
89 #def __init__(self,node,editor,parentQt,definition, obj, niveau,commande,insertIn=1):
90 # MonWidgetFactCommun.__init__(self,node,editor,parentQt, definition,obj,niveau,commande,insertIn)
91 def __init__(self,node,editor,parentQt,definition, obj, niveau,commande):
92 MonWidgetFactCommun.__init__(self,node,editor,parentQt, definition,obj,niveau,commande)
93 MonWidgetFactTableau.__init__(self,node,editor,parentQt, definition,obj,niveau,commande)