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()
42 if not hasattr(self,"RBInfo"):return
43 if isinstance(self,MonWidgetCommande) and self.editor.code =="MAP":
44 self.cle_doc = self.chercheDocMAP()
46 self.cle_doc = self.node.item.get_docu()
47 if self.cle_doc == None : self.RBInfo.close()
48 else : self.connect (self.RBInfo,SIGNAL("clicked()"),self.viewDoc)
51 def chercheDocMAP(self):
53 clef=self.editor.CONFIGURATION.adresse+"/"
56 for k in self.editor.readercata.cata[0].JdC.dict_groupes.keys():
57 if self.obj.nom in self.editor.readercata.cata[0].JdC.dict_groupes[k]:
60 clef+="/"+ self.obj.nom[0:-5].lower()+"/spec_"+self.obj.nom[0:-5].lower()+".html"
66 cmd="xdg-open "+self.cle_doc
69 QMessageBox.warning( self,tr( "Aide Indisponible"),tr( "l'aide n est pas installee "))
72 def setPoubelle(self):
73 if not(hasattr(self,"RBPoubelle")):return
74 if self.node.item.object.isoblig() :
76 icon1.addPixmap(QtGui.QPixmap("/home/A96028/Install_EficasV1/KarineEficas/Editeur/icons/deleteRondVide.png"), QtGui.QIcon.Normal, QtGui.QIcon.Off)
77 self.RBPoubelle.setIcon(icon1)
79 self.RBPoubelle.show()
80 self.connect(self.RBPoubelle,SIGNAL("clicked()"),self.aDetruire)
83 if hasattr(self.editor.appliEficas, 'mesScripts'):
84 if self.tree.currentItem().item.get_nom() in self.appliEficas.mesScripts.dict_commandes.keys() :
85 print 'il faut programmer le self.ajoutScript()'
88 if hasattr(self,"RBRun"): self.RBRun.close()
95 #print " c est le moment de gerer le passage au suivant"
96 if not(hasattr (self,'RBValide')) : return
98 if self.node.item.object.isvalid() :
99 icon=QIcon(self.repIcon+"/ast-green-ball.png")
101 icon=QIcon(self.repIcon+"/ast-red-ball.png")
102 self.RBValide.setIcon(icon)
104 def rendVisible(self):
105 print "je passe par rendVisible de FacultatifOuOptionnel"
106 self.editor.fenetreCentraleAffichee.scrollAreaCommandes.ensureWidgetVisible(self)
110 class ContientIcones:
112 def BFichierVisu(self):
113 fichier=self.lineEditVal.text()
114 if fichier == None or str(fichier)=="" : return
115 from qtCommun import ViewText
117 cmd="xdg-open "+str(fichier)
123 nomFichier=QFileInfo(fichier).baseName()
124 maVue=ViewText(self,entete=nomFichier)
129 QMessageBox.warning( None,
130 tr("Visualisation Fichier "),
131 tr("Impossibilite d'afficher le Fichier"),)
133 def BFichierPressed(self):
134 mctype = self.node.item.get_definition().type
137 elif hasattr(mctype[0], "filters"):
138 filters = mctype[0].filters
141 if len(mctype) > 2 and mctype[2] == "Sauvegarde":
142 fichier = QFileDialog.getSaveFileName(self.appliEficas,
143 tr('Sauvegarder Fichier'),
144 self.appliEficas.CONFIGURATION.savedir,
147 fichier = QFileDialog.getOpenFileName(self.appliEficas,
148 tr('Ouvrir Fichier'),
149 self.appliEficas.CONFIGURATION.savedir,
152 if not(fichier.isNull()):
153 ulfile = os.path.abspath(unicode(fichier))
154 self.appliEficas.CONFIGURATION.savedir=os.path.split(ulfile)[0]
155 self.lineEditVal.setText(fichier)
156 self.editor.affiche_infos(tr("Fichier selectionne"))
157 self.LEValeurPressed()
158 if (QFileInfo(fichier).suffix() in listeSuffixe ):
160 if (not hasattr(self,"BSelectInFile")):
161 self.BSelectInFile = QPushButton(self.Widget8)
162 self.BSelectInFile.setMinimumSize(QSize(140,40))
163 self.BSelectInFile.setObjectName("BSelectInFile")
164 self.gridLayout.addWidget(self.BSelectInFile,1,1,1,1)
165 self.BSelectInFile.setText(tr("Selection"))
166 self.connect(self.BSelectInFile,SIGNAL("clicked()"),self.BSelectInFilePressed)
168 self.BSelectInFile.setVisible(1)
169 elif hasattr(self, "BSelectInFile"):
170 self.BSelectInFile.setVisible(0)
172 def BRepertoirePressed(self):
173 directory = QFileDialog.getExistingDirectory(self.appliEficas,
174 directory = self.appliEficas.CONFIGURATION.savedir,
175 options = QFileDialog.ShowDirsOnly)
177 if not directory.isNull():
178 absdir = os.path.abspath(unicode(directory))
179 self.appliEficas.CONFIGURATION.savedir = os.path.dirname(absdir)
180 self.lineEditVal.setText(directory)
181 self.LEValeurPressed()
183 def BSelectInFilePressed(self):
184 from monSelectImage import MonSelectImage
185 MonSelectImage(file=self.image,parent=self).show()
189 def BSalomePressed(self):
190 self.editor.affiche_infos(QString(""))
193 genea=self.node.item.get_genealogie()
194 kwType = self.node.item.get_definition().type[0]
196 if "GROUP_NO" in e: kwType = "GROUP_NO"
197 if "GROUP_MA" in e: kwType = "GROUP_MA"
199 if 'grno' in repr(kwType): kwType = "GROUP_NO"
200 if 'grma' in repr(kwType): kwType = "GROUP_NO"
202 if kwType in ("GROUP_NO","GROUP_MA"):
203 selection, commentaire = self.appliEficas.selectGroupFromSalome(kwType,editor=self.editor)
205 mc = self.node.item.get_definition()
207 if (isinstance(mc.type,types.TupleType) and len(mc.type) > 1 and "(*.med)" in mc.type[1] ):
208 selection, commentaire = self.appliEficas.selectMeshFile(editor=self.editor)
209 print selection, commentaire
210 if commentaire != "" :
211 QMessageBox.warning( None,
212 tr("Export Med vers Fichier "),
213 tr("Impossibilite d exporter le Fichier"),)
216 self.lineEditVal.setText(QString(selection))
219 from Accas import SalomeEntry
220 if isinstance(kwType, types.ClassType) and issubclass(kwType, SalomeEntry):
221 selection, commentaire = self.appliEficas.selectEntryFromSalome(kwType,editor=self.editor)
223 if commentaire !="" :
224 self.editor.affiche_infos(tr(QString(commentaire)))
226 if selection == [] : return
227 for geomElt in selection:
229 monTexte= monTexte[0:-1]
230 self.lineEditVal.setText(QString(monTexte))
232 def BView2DPressed(self):
233 valeur=self.lineEditVal.text()
234 if valeur == QString("") : return
237 ok, msgError = self.appliEficas.displayShape(valeur)
239 self.appliEficas.affiche_infos(msgError,Qt.red)
241 def BParametresPressed(self):
242 liste=self.node.item.get_liste_param_possible()
243 from monListeParamPanel import MonListeParamPanel
244 MonListeParamPanel(liste=liste,parent=self).show()