# -*- coding: iso-8859-1 -*-
-# Copyright (C) 2011-2012 EDF R&D
+# Copyright (C) 2011-2016 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
# Author : Guillaume Boulant (EDF)
#
-from PyQt4.QtGui import QDialog, QIcon
-from PyQt4.QtCore import QObject, SIGNAL, SLOT, Qt
+from qtsalome import QDialog, QIcon, Qt
from plugindialog_ui import Ui_PluginDialog
from inputdialog import InputDialog
from omniORB import CORBA
import SMESH
-import smesh
+from salome.smesh import smeshBuilder
+smesh = smeshBuilder.New(salome.myStudy)
import MESHJOB
gui_states = ["CAN_SELECT", "CAN_COMPUTE", "CAN_REFRESH", "CAN_PUBLISH"]
# The SALOME launcher resource is specified by its name as defined in
# the file CatalogResources.xml (see root directory of the
# application). We could have a check box in the dialog to specify
-# wether we want a local execution or a remote one.
+# whether we want a local execution or a remote one.
resource_name = "localhost"
from salome.smesh.spadder.configreader import ConfigReader
self.__ui.btnClear.setIcon(icon)
# Then, we can connect the slot to there associated button event
- self.connect(self.__ui.btnInput, SIGNAL('clicked()'), self.onInput )
- self.connect(self.__ui.btnCompute, SIGNAL('clicked()'), self.onCompute )
- self.connect(self.__ui.btnRefresh, SIGNAL('clicked()'), self.onRefresh )
- self.connect(self.__ui.btnPublish, SIGNAL('clicked()'), self.onPublish )
- self.connect(self.__ui.btnClear, SIGNAL('clicked()'), self.onClear )
+ self.__ui.btnInput.clicked.connect( self.onInput )
+ self.__ui.btnCompute.clicked.connect( self.onCompute )
+ self.__ui.btnRefresh.clicked.connect( self.onRefresh )
+ self.__ui.btnPublish.clicked.connect( self.onPublish )
+ self.__ui.btnClear.clicked.connect( self.onClear )
self.clear()
# items in the object browser:
self.__inputDialog.setWindowFlags(
self.__inputDialog.windowFlags() | Qt.WindowStaysOnTopHint)
- # The signal inputValidated emited from inputDialog is
+ # The signal inputValidated emitted from inputDialog is
# connected to the slot function onProcessInput:
- self.connect(self.__inputDialog, SIGNAL('inputValidated()'), self.onProcessInput)
+ self.__inputDialog.inputValidated.connect( self.onProcessInput )
else:
self.__ui.frameInput.setVisible(True)
name. This returns the filename.
'''
filename=str("/tmp/padder_inputfile_"+meshName+".med")
- meshObject.ExportToMEDX( filename, 0, SMESH.MED_V2_2, 1 )
+ meshObject.ExportToMEDX( filename, 0, SMESH.MED_V2_2, 1, 1 )
return filename
def clear(self):
# We first have to create the list of parameters for the
# initialize function. For that, we have to create the files
# from the mesh objects:
- meshJobParameterList=[]
+ meshJobFileList=[]
concreteIndex=0
for inputData in self.__listInputData:
# For each input data, we have to create a
- # MeshJobParameter and add it to the list.
+ # MeshJobFile and add it to the list.
filename = self.__exportMesh(inputData.meshName, inputData.meshObject)
if inputData.meshType == InputData.MESHTYPES.CONCRETE:
filetype = MESHJOB.MED_CONCRETE
else:
filetype = MESHJOB.MED_STEELBAR
- parameter = MESHJOB.MeshJobParameter(
+ parameter = MESHJOB.MeshJobFile(
file_name = filename,
file_type = filetype,
group_name = inputData.groupName)
- meshJobParameterList.append(parameter)
+ meshJobFileList.append(parameter)
jobManager = self.__getJobManager()
- self.__jobid = jobManager.initialize(meshJobParameterList, self.__configId)
+ self.__jobid = jobManager.initialize(meshJobFileList, self.__configId)
if self.__jobid < 0:
self.__log("ERR: the job can't be initialized")
self.__log("ERR: %s"%jobManager.getLastErrorMessage())
return
meshJobResults = jobManager.finalize(self.__jobid)
- if state == "ERROR":
- self.__log("ERR: jobid = "+str(self.__jobid)+" ended with error: "+meshJobResults.status)
- self.__log("ERR: %s"%jobManager.getLastErrorMessage())
+ logsdirname = os.path.join(meshJobResults.results_dirname, "logs")
+ if state == "ERROR" or meshJobResults.status is not True:
+ msgtemp = "ERR: jobid = %s ended with error: %s"
+ self.__log(msgtemp%(str(self.__jobid),jobManager.getLastErrorMessage()))
+ self.__log("ERR: see log files in %s"%logsdirname)
return
- logsdirname = os.path.join(meshJobResults.results_dirname, "logs")
- self.__log("INF: jobid="+str(self.__jobid)+" ended normally : "+meshJobResults.status)
- self.__log("INF: jobid="+str(self.__jobid)+" see log files in : "+logsdirname)
+ self.__log("INF: jobid=%s ended normally (see log files in %s)"%(str(self.__jobid),logsdirname))
medfilename = os.path.join(meshJobResults.results_dirname,
meshJobResults.outputmesh_filename)
meshname = 'padder_'+str(self.__jobid)
smesh.SetName(outputMesh.GetMesh(), meshname)
if salome.sg.hasDesktop():
- salome.sg.updateObjBrowser(0)
+ salome.sg.updateObjBrowser(False)
self.__ui.lblStatusBar.setText("Publication OK")
self.__setGuiState(["CAN_SELECT"])
#
def TEST_PluginDialog():
import sys
- from PyQt4.QtGui import QApplication
- from PyQt4.QtCore import QObject, SIGNAL, SLOT
+ from qtsalome import QApplication
app = QApplication(sys.argv)
- QObject.connect(app, SIGNAL("lastWindowClosed()"), app, SLOT("quit()"))
+ app.lastWindowClosed.connect( app.quit )
dlg=PluginDialog()
dlg.exec_()