1 # -*- coding: utf-8 -*-
2 # Copyright (C) 2007-2013 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 import string,types,os,re
25 from PyQt4.QtGui import *
26 from PyQt4.QtCore import *
27 from Extensions.i18n import tr
28 listeSuffixe=('bmp','png','jpg' ,'txt','med')
31 class FacultatifOuOptionnel:
33 def setReglesEtAide(self):
34 from monWidgetCommande import MonWidgetCommande
37 listeRegles = self.node.item.get_regles()
40 if listeRegles==() and hasattr(self,"RBRegle"): self.RBRegle.close()
41 if isinstance(self,MonWidgetCommande):return
42 cle_doc = self.node.item.get_docu()
43 if cle_doc == None and hasattr(self,"RBInfo") : self.RBInfo.close()
47 def setPoubelle(self):
48 if not(hasattr(self,"RBPoubelle")):return
49 if self.node.item.object.isoblig() :
51 icon1.addPixmap(QtGui.QPixmap("/home/A96028/Install_EficasV1/KarineEficas/Editeur/icons/deleteRondVide.png"), QtGui.QIcon.Normal, QtGui.QIcon.Off)
52 self.RBPoubelle.setIcon(icon1)
54 self.RBPoubelle.show()
55 self.connect(self.RBPoubelle,SIGNAL("clicked()"),self.aDetruire)
61 if not(hasattr (self,'RBValide')) : return
63 if self.node.item.object.isvalid() :
64 icon=QIcon(self.repIcon+"/ast-green-ball.png")
66 icon=QIcon(self.repIcon+"/ast-red-ball.png")
67 self.RBValide.setIcon(icon)
69 def rendVisible(self):
70 self.editor.fenetreCentraleAffichee.scrollAreaCommandes.ensureWidgetVisible(self)
76 def BFichierVisu(self):
77 fichier=self.lineEditVal.text()
78 if fichier == None or str(fichier)=="" : return
79 from qtCommun import ViewText
81 cmd="xdg-open "+str(fichier)
87 nomFichier=QFileInfo(fichier).baseName()
88 maVue=ViewText(self,entete=nomFichier)
93 QMessageBox.warning( None,
94 tr("Visualisation Fichier "),
95 tr("Impossibilite d'afficher le Fichier"),)
97 def BFichierPressed(self):
98 mctype = self.node.item.get_definition().type
101 elif hasattr(mctype[0], "filters"):
102 filters = mctype[0].filters
105 if len(mctype) > 2 and mctype[2] == "Sauvegarde":
106 fichier = QFileDialog.getSaveFileName(self.appliEficas,
107 tr('Sauvegarder Fichier'),
108 self.appliEficas.CONFIGURATION.savedir,
111 fichier = QFileDialog.getOpenFileName(self.appliEficas,
112 tr('Ouvrir Fichier'),
113 self.appliEficas.CONFIGURATION.savedir,
116 if not(fichier.isNull()):
117 ulfile = os.path.abspath(unicode(fichier))
118 self.appliEficas.CONFIGURATION.savedir=os.path.split(ulfile)[0]
119 self.lineEditVal.setText(fichier)
120 self.editor.affiche_infos(tr("Fichier selectionne"))
121 self.LEValeurPressed()
122 if (QFileInfo(fichier).suffix() in listeSuffixe ):
124 if (not hasattr(self,"BSelectInFile")):
125 self.BSelectInFile = QPushButton(self.Widget8)
126 self.BSelectInFile.setMinimumSize(QSize(140,40))
127 self.BSelectInFile.setObjectName("BSelectInFile")
128 self.gridLayout.addWidget(self.BSelectInFile,1,1,1,1)
129 self.BSelectInFile.setText(tr("Selection"))
130 self.connect(self.BSelectInFile,SIGNAL("clicked()"),self.BSelectInFilePressed)
132 self.BSelectInFile.setVisible(1)
133 elif hasattr(self, "BSelectInFile"):
134 self.BSelectInFile.setVisible(0)
136 def BRepertoirePressed(self):
137 directory = QFileDialog.getExistingDirectory(self.appliEficas,
138 directory = self.appliEficas.CONFIGURATION.savedir,
139 options = QFileDialog.ShowDirsOnly)
141 if not directory.isNull():
142 absdir = os.path.abspath(unicode(directory))
143 self.appliEficas.CONFIGURATION.savedir = os.path.dirname(absdir)
144 self.lineEditVal.setText(directory)
145 self.LEValeurPressed()
147 def BSelectInFilePressed(self):
148 from monSelectImage import MonSelectImage
149 MonSelectImage(file=self.image,parent=self).show()
153 def BSalomePressed(self):
154 self.editor.affiche_infos(QString(""))
157 genea=self.node.item.get_genealogie()
158 kwType = self.node.item.get_definition().type[0]
160 if "GROUP_NO" in e: kwType = "GROUP_NO"
161 if "GROUP_MA" in e: kwType = "GROUP_MA"
163 if 'grno' in repr(kwType): kwType = "GROUP_NO"
164 if 'grma' in repr(kwType): kwType = "GROUP_NO"
166 if kwType in ("GROUP_NO","GROUP_MA"):
167 selection, commentaire = self.appliEficas.selectGroupFromSalome(kwType,editor=self.editor)
169 mc = self.node.item.get_definition()
171 if (isinstance(mc.type,types.TupleType) and len(mc.type) > 1 and "(*.med)" in mc.type[1] ):
172 selection, commentaire = self.appliEficas.selectMeshFile(editor=self.editor)
173 print selection, commentaire
174 if commentaire != "" :
175 QMessageBox.warning( None,
176 tr("Export Med vers Fichier "),
177 tr("Impossibilite d exporter le Fichier"),)
180 self.lineEditVal.setText(QString(selection))
183 from Accas import SalomeEntry
184 if isinstance(kwType, types.ClassType) and issubclass(kwType, SalomeEntry):
185 selection, commentaire = self.appliEficas.selectEntryFromSalome(kwType,editor=self.editor)
187 if commentaire !="" :
188 self.editor.affiche_infos(tr(QString(commentaire)))
190 if selection == [] : return
191 for geomElt in selection:
193 monTexte= monTexte[0:-1]
194 self.lineEditVal.setText(QString(monTexte))
196 def BView2DPressed(self):
197 valeur=self.lineEditVal.text()
198 if valeur == QString("") : return
201 ok, msgError = self.appliEficas.displayShape(valeur)
203 self.appliEficas.affiche_infos(msgError,Qt.red)
205 def BParametresPressed(self):
206 liste=self.node.item.get_liste_param_possible()
207 from monListeParamPanel import MonListeParamPanel
208 MonListeParamPanel(liste=liste,parent=self).show()