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 self.editor.fenetreCentraleAffichee.scrollAreaCommandes.ensureWidgetVisible(self)
109 class ContientIcones:
111 def BFichierVisu(self):
112 fichier=self.lineEditVal.text()
113 if fichier == None or str(fichier)=="" : return
114 from qtCommun import ViewText
116 cmd="xdg-open "+str(fichier)
122 nomFichier=QFileInfo(fichier).baseName()
123 maVue=ViewText(self,entete=nomFichier)
128 QMessageBox.warning( None,
129 tr("Visualisation Fichier "),
130 tr("Impossibilite d'afficher le Fichier"),)
132 def BFichierPressed(self):
133 mctype = self.node.item.get_definition().type
136 elif hasattr(mctype[0], "filters"):
137 filters = mctype[0].filters
140 if len(mctype) > 2 and mctype[2] == "Sauvegarde":
141 fichier = QFileDialog.getSaveFileName(self.appliEficas,
142 tr('Sauvegarder Fichier'),
143 self.appliEficas.CONFIGURATION.savedir,
146 fichier = QFileDialog.getOpenFileName(self.appliEficas,
147 tr('Ouvrir Fichier'),
148 self.appliEficas.CONFIGURATION.savedir,
151 if not(fichier.isNull()):
152 ulfile = os.path.abspath(unicode(fichier))
153 self.appliEficas.CONFIGURATION.savedir=os.path.split(ulfile)[0]
154 self.lineEditVal.setText(fichier)
155 self.editor.affiche_infos(tr("Fichier selectionne"))
156 self.LEValeurPressed()
157 if (QFileInfo(fichier).suffix() in listeSuffixe ):
159 if (not hasattr(self,"BSelectInFile")):
160 self.BSelectInFile = QPushButton(self.Widget8)
161 self.BSelectInFile.setMinimumSize(QSize(140,40))
162 self.BSelectInFile.setObjectName("BSelectInFile")
163 self.gridLayout.addWidget(self.BSelectInFile,1,1,1,1)
164 self.BSelectInFile.setText(tr("Selection"))
165 self.connect(self.BSelectInFile,SIGNAL("clicked()"),self.BSelectInFilePressed)
167 self.BSelectInFile.setVisible(1)
168 elif hasattr(self, "BSelectInFile"):
169 self.BSelectInFile.setVisible(0)
171 def BRepertoirePressed(self):
172 directory = QFileDialog.getExistingDirectory(self.appliEficas,
173 directory = self.appliEficas.CONFIGURATION.savedir,
174 options = QFileDialog.ShowDirsOnly)
176 if not directory.isNull():
177 absdir = os.path.abspath(unicode(directory))
178 self.appliEficas.CONFIGURATION.savedir = os.path.dirname(absdir)
179 self.lineEditVal.setText(directory)
180 self.LEValeurPressed()
182 def BSelectInFilePressed(self):
183 from monSelectImage import MonSelectImage
184 MonSelectImage(file=self.image,parent=self).show()
188 def BSalomePressed(self):
189 self.editor.affiche_infos(QString(""))
192 genea=self.node.item.get_genealogie()
193 kwType = self.node.item.get_definition().type[0]
195 if "GROUP_NO" in e: kwType = "GROUP_NO"
196 if "GROUP_MA" in e: kwType = "GROUP_MA"
198 if 'grno' in repr(kwType): kwType = "GROUP_NO"
199 if 'grma' in repr(kwType): kwType = "GROUP_NO"
201 if kwType in ("GROUP_NO","GROUP_MA"):
202 selection, commentaire = self.appliEficas.selectGroupFromSalome(kwType,editor=self.editor)
204 mc = self.node.item.get_definition()
206 if (isinstance(mc.type,types.TupleType) and len(mc.type) > 1 and "(*.med)" in mc.type[1] ):
207 selection, commentaire = self.appliEficas.selectMeshFile(editor=self.editor)
208 print selection, commentaire
209 if commentaire != "" :
210 QMessageBox.warning( None,
211 tr("Export Med vers Fichier "),
212 tr("Impossibilite d exporter le Fichier"),)
215 self.lineEditVal.setText(QString(selection))
218 from Accas import SalomeEntry
219 if isinstance(kwType, types.ClassType) and issubclass(kwType, SalomeEntry):
220 selection, commentaire = self.appliEficas.selectEntryFromSalome(kwType,editor=self.editor)
222 if commentaire !="" :
223 self.editor.affiche_infos(tr(QString(commentaire)))
225 if selection == [] : return
226 for geomElt in selection:
228 monTexte= monTexte[0:-1]
229 self.lineEditVal.setText(QString(monTexte))
231 def BView2DPressed(self):
232 valeur=self.lineEditVal.text()
233 if valeur == QString("") : return
236 ok, msgError = self.appliEficas.displayShape(valeur)
238 self.appliEficas.affiche_infos(msgError,Qt.red)
240 def BParametresPressed(self):
241 liste=self.node.item.get_liste_param_possible()
242 from monListeParamPanel import MonListeParamPanel
243 MonListeParamPanel(liste=liste,parent=self).show()