# -*- coding: utf-8 -*-
-# Copyright (C) 2007-2013 EDF R&D
+# Copyright (C) 2007-2014 EDF R&D
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation; either
-# version 2.1 of the License.
+# version 2.1 of the License, or (at your option) any later version.
#
# This library is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# Modules Eficas
import os, subprocess
-from YamsPlugDialog import Ui_YamsPlugDialog
+from YamsPlugDialog_ui import Ui_YamsPlugDialog
from monViewText import MonViewText
from PyQt4.QtGui import *
from PyQt4.QtCore import *
v1=QDoubleValidator(self)
v1.setBottom(0.)
#v1.setTop(1000.) #per thousand... only if relative
- v1.setDecimals(2)
+ v1.setDecimals(3)
self.SP_Tolerance.setValidator(v1)
self.SP_Tolerance.titleForWarning="Chordal Tolerance"
self.connect(self.LE_ParamsFile,SIGNAL("returnPressed()"),self.paramsFileNameChanged)
def PBHelpPressed(self):
+ import SalomePyQt
+ sgPyQt = SalomePyQt.SalomePyQt()
try :
mydir=os.environ["SMESH_ROOT_DIR"]
except Exception:
QMessageBox.warning(self, "Help", "Help unavailable $SMESH_ROOT_DIR not found")
return
- maDoc=mydir+"/share/doc/salome/gui/SMESH/yams/_downloads/YamsWhitePaper_3.2.pdf"
- command="xdg-open "+maDoc+";"
- subprocess.call(command, shell=True)
+
+ maDoc=mydir+"/share/doc/salome/gui/SMESH/yams/index.html"
+ sgPyQt.helpContext(maDoc,"")
+
+ #maDoc=mydir+"/share/doc/salome/gui/SMESH/yams/_downloads/mg-surfopt_user_manual.pdf"
+ #command="xdg-open "+maDoc+";"
+ #subprocess.call(command, shell=True)
def PBOKPressed(self):
if not(self.PrepareLigneCommande()):
maFenetre=MonViewText(self,self.commande)
def enregistreResultat(self):
- import smesh
- import SMESH
import salome
+ import SMESH
from salome.kernel import studyedit
-
+ from salome.smesh import smeshBuilder
+ smesh = smeshBuilder.New(salome.myStudy)
+
if not os.path.isfile(self.fichierOut):
QMessageBox.warning(self, "Compute", "Result file "+self.fichierOut+" not found")
smesh.SetName(outputMesh.GetMesh(), meshname)
outputMesh.Compute() #no algorithms message for "Mesh_x" has been computed with warnings: - global 1D algorithm is missing
- self.editor = studyedit.getStudyEditor() #
+ self.editor = studyedit.getStudyEditor()
moduleEntry=self.editor.findOrCreateComponent("SMESH","SMESH")
HypReMeshEntry = self.editor.findOrCreateItem(
moduleEntry, name = "Plugins Hypotheses", icon="mesh_tree_hypo.png") #, comment = "HypoForRemeshing" )
-
+
monStudyBuilder=maStudy.NewBuilder()
monStudyBuilder.NewCommand()
newStudyIter=monStudyBuilder.NewObject(HypReMeshEntry)
self.num+=1
return True
- def PBSavePressed(self,NomHypo=False):
+ def PBSavePressed(self):
from datetime import datetime
if not(self.PrepareLigneCommande()): return
text = "# YAMS hypothesis parameters\n"
def PBSaveHypPressed(self):
"""save hypothesis in Object Browser"""
- #QMessageBox.warning(self, "save Object Browser YAMS Hypothesis", "TODO")
-
- import smesh
- import SMESH
import salome
+ import SMESH
from salome.kernel import studyedit
+ from salome.smesh import smeshBuilder
+ smesh = smeshBuilder.New(salome.myStudy)
maStudy=studyedit.getActiveStudy()
smesh.SetCurrentStudy(maStudy)
try:
tit,value=lig.split("=")
if tit=="Optimisation":
- for RB in self.GBUnit.findChildren(QRadioButton,):
- RB.setChecked(False)
- for RB in self.GBUnit.findChildren(QRadioButton,):
+ #no need: exlusives QRadioButton
+ #for RB in self.GBOptim.findChildren(QRadioButton,):
+ # RB.setChecked(False)
+ for RB in self.GBOptim.findChildren(QRadioButton,):
if RB.text()==value :
RB.setChecked(True)
break
self.paramsFile=self.LE_ParamsFile.text()
def PBMeshSmeshPressed(self):
+ from omniORB import CORBA
import salome
- import smesh
from salome.kernel import studyedit
from salome.smesh.smeshstudytools import SMeshStudyTools
from salome.gui import helper as guihelper
- from omniORB import CORBA
+ from salome.smesh import smeshBuilder
+ smesh = smeshBuilder.New(salome.myStudy)
mySObject, myEntry = guihelper.getSObjectSelected()
if CORBA.is_nil(mySObject) or mySObject==None:
- QMessageBox.critical(self, "Mesh", "select an input mesh")
+ #QMessageBox.critical(self, "Mesh", "select an input mesh")
+ self.LE_MeshSmesh.setText("")
+ self.MeshIn=""
+ self.LE_MeshFile.setText("")
+ self.fichierIn=""
return
self.smeshStudyTool = SMeshStudyTools()
try:
self.fichierIn=""
def prepareFichier(self):
- self.fichierIn="/tmp/ForYams_"+str(self.num)+".mesh"
- import SMESH
+ self.fichierIn="/tmp/ForSurfOpt_"+str(self.num)+".meshb"
self.__selectedMesh.ExportGMF(self.__selectedMesh, self.fichierIn, True)
def PrepareLigneCommande(self):
QMessageBox.critical(self, "File", "unable to read GMF Mesh in "+str(self.fichierIn))
return False
- self.commande="yams"
- verbosity=str(self.SP_Verbosity.value())
- self.commande+=" -v "+verbosity
+ self.commande="mg-surfopt.exe"
+
for obj in self.GBOptim.findChildren(QRadioButton,):
try:
if obj.isChecked():
break
except:
pass
- self.commande+=" -O "+self.style.toLatin1()
+
+ style = self.style.toLatin1()
+ # Translation of old Yams options to new MG-SurfOpt options
+ if style == "0" :
+ self.commande+= " --optimisation only"
+ elif style == "2" :
+ self.commande+= " --Hausdorff_like yes"
+ elif style == "-1":
+ self.commande+= " --enrich no"
+ elif style == "-2":
+ self.commande+= " --Hausdorff_like yes --enrich no"
+ elif style == "U" :
+ self.commande+= " --uniform_flat_subdivision yes"
+ elif style == "S" :
+ self.commande+= " --sand_paper yes"
+ elif style == "G" :
+ self.commande+= " -O G" # This option has not been updated to the new option style yet
deb=os.path.splitext(self.fichierIn)
- self.fichierOut=deb[0] + ".d.meshb"
-
- if self.RB_Absolute.isChecked()==True :
- self.commande+=" -Dabsolute"
- else :
- self.commande+=" -Drelative"
+ self.fichierOut=deb[0] + "_output.meshb"
- v=self.SP_toStr(self.SP_Tolerance)
- self.commande+=",tolerance="+v
- if self.CB_Ridge.isChecked()==False : self.commande+=",-nr"
- if self.CB_Point.isChecked()==False : self.commande+=",-ns"
- if self.SP_Geomapp.value()!=0.04 : self.commande+=",geomapp=%f"%self.SP_Geomapp.value()
- if self.SP_Ridge.value()!=45.0 : self.commande+=",ridge=%f"%self.SP_Ridge.value()
- if self.SP_MaxSize.value()!=100 : self.commande+=",maxsize=%f"%self.SP_MaxSize.value()
- if self.SP_MinSize.value()!=5 : self.commande+=",minsize=%f"%self.SP_MinSize.value()
- if self.SP_Gradation.value()!=1.3 : self.commande+=",gradation=%f"%self.SP_MaxSize.value()
- if self.CB_SplitEdge.isChecked()==True : self.commande+=",splitedge=1"
-
- if self.SP_Verbosity.value()!=3 : self.commande+=" -v %d"%self.SP_Verbosity.value()
- if self.SP_Memory.value()!=0 : self.commande+=" -m %d"%self.SP_Memory.value()
-
- self.commande+=" "+self.fichierIn
+ tolerance=self.SP_toStr(self.SP_Tolerance)
+ if not self.RB_Absolute.isChecked():
+ tolerance+="r"
+ self.commande+=" --chordal_error %s"%tolerance
+
+ if self.CB_Ridge.isChecked() == False : self.commande+=" --compute_ridges no"
+ if self.CB_Point.isChecked() == False : self.commande+=" --optimisation no"
+ if self.CB_SplitEdge.isChecked()== True : self.commande+=" --element_order quadratic"
+ if self.SP_Geomapp.value() != 15.0 : self.commande+=" --geometric_approximation_angle %f"%self.SP_Geomapp.value()
+ if self.SP_Ridge.value() != 45.0 : self.commande+=" --ridge_angle %f"%self.SP_Ridge.value()
+ if self.SP_MaxSize.value() != 100 : self.commande+=" --max_size %f" %self.SP_MaxSize.value()
+ if self.SP_MinSize.value() != 5 : self.commande+=" --min_size %f" %self.SP_MinSize.value()
+ if self.SP_Gradation.value() != 1.3 : self.commande+=" --gradation %f" %self.SP_MaxSize.value()
+ if self.SP_Memory.value() != 0 : self.commande+=" --max_memory %d" %self.SP_Memory.value()
+ if self.SP_Verbosity.value() != 3 : self.commande+=" --verbose %d" %self.SP_Verbosity.value()
+
+ self.commande+=" --in " + self.fichierIn
+ self.commande+=" --out " + self.fichierOut
+
+ print self.commande
return True
def clean(self):
self.RB_0.setChecked(True)
- self.RB_G.setChecked(False)
- self.RB_U.setChecked(False)
- self.RB_S.setChecked(False)
- self.RB_2.setChecked(False)
- self.RB_1.setChecked(False)
- self.RB_Absolute.setChecked(False)
+ #no need: exlusives QRadioButton
+ #self.RB_G.setChecked(False)
+ #self.RB_U.setChecked(False)
+ #self.RB_S.setChecked(False)
+ #self.RB_2.setChecked(False)
+ #self.RB_1.setChecked(False)
self.RB_Relative.setChecked(True)
- self.SP_Tolerance.setProperty("text", "10.")
- self.SP_Geomapp.setProperty("value", 0.04)
+ #no need: exlusives QRadioButton
+ #self.RB_Absolute.setChecked(False)
+ self.SP_Tolerance.setProperty("text", "0.001")
+ self.SP_Geomapp.setProperty("value", 15.0)
self.SP_Ridge.setProperty("value", 45.0)
self.SP_Gradation.setProperty("value", 1.3)
self.CB_Ridge.setChecked(True)
self.CB_Point.setChecked(True)
self.CB_SplitEdge.setChecked(False)
- self.SP_MaxSize.setProperty("value", -2.0)
- self.SP_MinSize.setProperty("value", -2.0)
+ self.SP_MaxSize.setProperty("value", 100)
+ self.SP_MinSize.setProperty("value", 5)
self.SP_Verbosity.setProperty("value", 3)
self.SP_Memory.setProperty("value", 0)
+ self.PBMeshSmeshPressed()
+ self.TWOptions.setCurrentIndex(0) # Reset current active tab to the first tab
__dialog=None
def getDialog():
- """
- This function returns a singleton instance of the plugin dialog.
- c est obligatoire pour faire un show sans parent...
- """
- global __dialog
- if __dialog is None:
- __dialog = MonYamsPlugDialog()
- #else :
- # __dialog.clean()
- return __dialog
+ """
+ This function returns a singleton instance of the plugin dialog.
+ It is mandatory in order to call show without a parent ...
+ """
+ global __dialog
+ if __dialog is None:
+ __dialog = MonYamsPlugDialog()
+ else :
+ __dialog.clean()
+ return __dialog
#
# ==============================================================================
# ==============================================================================
#
def TEST_MonYamsPlugDialog():
- #print "TEST_YamsMonPlugDialog"
import sys
from PyQt4.QtGui import QApplication
from PyQt4.QtCore import QObject, SIGNAL, SLOT