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)
86 #print " c est le moment de gerer le passage au suivant"
87 if not(hasattr (self,'RBValide')) : return
89 if self.node.item.object.isvalid() :
90 icon=QIcon(self.repIcon+"/ast-green-ball.png")
92 icon=QIcon(self.repIcon+"/ast-red-ball.png")
93 self.RBValide.setIcon(icon)
95 def rendVisible(self):
96 self.editor.fenetreCentraleAffichee.scrollAreaCommandes.ensureWidgetVisible(self)
100 class ContientIcones:
102 def BFichierVisu(self):
103 fichier=self.lineEditVal.text()
104 if fichier == None or str(fichier)=="" : return
105 from qtCommun import ViewText
107 cmd="xdg-open "+str(fichier)
113 nomFichier=QFileInfo(fichier).baseName()
114 maVue=ViewText(self,entete=nomFichier)
119 QMessageBox.warning( None,
120 tr("Visualisation Fichier "),
121 tr("Impossibilite d'afficher le Fichier"),)
123 def BFichierPressed(self):
124 mctype = self.node.item.get_definition().type
127 elif hasattr(mctype[0], "filters"):
128 filters = mctype[0].filters
131 if len(mctype) > 2 and mctype[2] == "Sauvegarde":
132 fichier = QFileDialog.getSaveFileName(self.appliEficas,
133 tr('Sauvegarder Fichier'),
134 self.appliEficas.CONFIGURATION.savedir,
137 fichier = QFileDialog.getOpenFileName(self.appliEficas,
138 tr('Ouvrir Fichier'),
139 self.appliEficas.CONFIGURATION.savedir,
142 if not(fichier.isNull()):
143 ulfile = os.path.abspath(unicode(fichier))
144 self.appliEficas.CONFIGURATION.savedir=os.path.split(ulfile)[0]
145 self.lineEditVal.setText(fichier)
146 self.editor.affiche_infos(tr("Fichier selectionne"))
147 self.LEValeurPressed()
148 if (QFileInfo(fichier).suffix() in listeSuffixe ):
150 if (not hasattr(self,"BSelectInFile")):
151 self.BSelectInFile = QPushButton(self.Widget8)
152 self.BSelectInFile.setMinimumSize(QSize(140,40))
153 self.BSelectInFile.setObjectName("BSelectInFile")
154 self.gridLayout.addWidget(self.BSelectInFile,1,1,1,1)
155 self.BSelectInFile.setText(tr("Selection"))
156 self.connect(self.BSelectInFile,SIGNAL("clicked()"),self.BSelectInFilePressed)
158 self.BSelectInFile.setVisible(1)
159 elif hasattr(self, "BSelectInFile"):
160 self.BSelectInFile.setVisible(0)
162 def BRepertoirePressed(self):
163 directory = QFileDialog.getExistingDirectory(self.appliEficas,
164 directory = self.appliEficas.CONFIGURATION.savedir,
165 options = QFileDialog.ShowDirsOnly)
167 if not directory.isNull():
168 absdir = os.path.abspath(unicode(directory))
169 self.appliEficas.CONFIGURATION.savedir = os.path.dirname(absdir)
170 self.lineEditVal.setText(directory)
171 self.LEValeurPressed()
173 def BSelectInFilePressed(self):
174 from monSelectImage import MonSelectImage
175 MonSelectImage(file=self.image,parent=self).show()
179 def BSalomePressed(self):
180 self.editor.affiche_infos(QString(""))
183 genea=self.node.item.get_genealogie()
184 kwType = self.node.item.get_definition().type[0]
186 if "GROUP_NO" in e: kwType = "GROUP_NO"
187 if "GROUP_MA" in e: kwType = "GROUP_MA"
189 if 'grno' in repr(kwType): kwType = "GROUP_NO"
190 if 'grma' in repr(kwType): kwType = "GROUP_NO"
192 if kwType in ("GROUP_NO","GROUP_MA"):
193 selection, commentaire = self.appliEficas.selectGroupFromSalome(kwType,editor=self.editor)
195 mc = self.node.item.get_definition()
197 if (isinstance(mc.type,types.TupleType) and len(mc.type) > 1 and "(*.med)" in mc.type[1] ):
198 selection, commentaire = self.appliEficas.selectMeshFile(editor=self.editor)
199 print selection, commentaire
200 if commentaire != "" :
201 QMessageBox.warning( None,
202 tr("Export Med vers Fichier "),
203 tr("Impossibilite d exporter le Fichier"),)
206 self.lineEditVal.setText(QString(selection))
209 from Accas import SalomeEntry
210 if isinstance(kwType, types.ClassType) and issubclass(kwType, SalomeEntry):
211 selection, commentaire = self.appliEficas.selectEntryFromSalome(kwType,editor=self.editor)
213 if commentaire !="" :
214 self.editor.affiche_infos(tr(QString(commentaire)))
216 if selection == [] : return
217 for geomElt in selection:
219 monTexte= monTexte[0:-1]
220 self.lineEditVal.setText(QString(monTexte))
222 def BView2DPressed(self):
223 valeur=self.lineEditVal.text()
224 if valeur == QString("") : return
227 ok, msgError = self.appliEficas.displayShape(valeur)
229 self.appliEficas.affiche_infos(msgError,Qt.red)
231 def BParametresPressed(self):
232 liste=self.node.item.get_liste_param_possible()
233 from monListeParamPanel import MonListeParamPanel
234 MonListeParamPanel(liste=liste,parent=self).show()