1
# -*- coding: utf-8 -*-
3
#-------------------------------------------------------------------------------
5
# This file is part of Code_Saturne, a general-purpose CFD tool.
7
# Copyright (C) 1998-2011 EDF S.A.
9
# This program is free software; you can redistribute it and/or modify it under
10
# the terms of the GNU General Public License as published by the Free Software
11
# Foundation; either version 2 of the License, or (at your option) any later
14
# This program is distributed in the hope that it will be useful, but WITHOUT
15
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
16
# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
19
# You should have received a copy of the GNU General Public License along with
20
# this program; if not, write to the Free Software Foundation, Inc., 51 Franklin
21
# Street, Fifth Floor, Boston, MA 02110-1301, USA.
23
#-------------------------------------------------------------------------------
29
This file gathers the C{QDialog} definitions of the CFD_STUDY module.
32
#-------------------------------------------------------------------------------
34
#-------------------------------------------------------------------------------
39
#-------------------------------------------------------------------------------
41
#-------------------------------------------------------------------------------
43
from PyQt4 import QtCore, QtGui
44
from PyQt4.QtGui import QMessageBox,QDialog,QPushButton,QToolTip,QColor,QRadioButton,QTableWidget,QTableWidgetItem
45
from PyQt4.QtCore import Qt,QStringList,QString,SIGNAL
48
from PyQt4.QtCore import QTranslator
50
#-------------------------------------------------------------------------------
52
#-------------------------------------------------------------------------------
54
#-------------------------------------------------------------------------------
56
#-------------------------------------------------------------------------------
58
from ui_InfoDialog import Ui_InfoDialog
59
from ui_DefineLinkDialog import Ui_DefineLinkDialog
60
from ui_SetTreeLocationDialog import Ui_SetTreeLocationDialog
61
from ui_RunCaseDialog import Ui_RunCaseDialog
62
from ui_ECSConversionDialog import Ui_ECSConversionDialog
63
from ui_CopyDialog import Ui_CopyDialog
64
from ui_GUIActivationDialog import Ui_GUIActivationDialog
65
import CFDSTUDYGUI_DataModel
67
from CFDSTUDYGUI_Commons import _SetCFDCode, CFD_Code, Trace, sgPyQt
68
from CFDSTUDYGUI_Commons import CFD_Saturne, CFD_Neptune, CheckCFD_CodeEnv
70
#-------------------------------------------------------------------------------
72
#-------------------------------------------------------------------------------
74
class InfoDialog(QtGui.QDialog, Ui_InfoDialog):
76
Dialog informations about solver installation.
78
def __init__(self, parent = None):
81
if Trace(): print 'InfoDialog.__init__'
82
QtGui.QDialog.__init__(self, parent)
83
Ui_InfoDialog.__init__(self,parent)
88
class InfoDialogHandler(InfoDialog):
91
def __init__(self, parent = None):
94
if Trace(): print 'InfoDialogHandler.__init__'
95
InfoDialog.__init__(self,parent)
97
self.status = 1 #initial access status
99
aBtn = self.findChild(QtGui.QPushButton, "OKButton")
101
aBtn.setText(self.tr("DLG_OK_BUTTON_TEXT"))
103
codeBG = self.findChild(QtGui.QButtonGroup, "CodeBG")
105
codeBG.setTitle(self.tr("INFO_DLG_CFDCODE_TITLE"))
107
self.SaturneRB = self.findChild(QtGui.QRadioButton, "SaturneRB")
108
if self.SaturneRB != None:
109
self.SaturneRB.setText(self.tr("INFO_DLG_SATURNE_TEXT"))
110
self.SaturneRB.setChecked(True)
111
self.NeptuneRB = self.findChild(QtGui.QRadioButton, "NeptuneRB")
112
if self.NeptuneRB != None:
113
self.NeptuneRB.setText(self.tr("INFO_DLG_NEPTUNE_TEXT"))
115
self.setWindowTitle(self.tr("INFO_DLG_CAPTION"))
119
if Trace(): print 'InfoDialogHandler.accept'
120
if CheckCFD_CodeEnv(CFD_Code()):
121
InfoDialog.accept(self)
123
self.setCode(CFD_Code(), True)
125
# mess = self.tr("INFO_DLG_INVALID_ENV")
126
# QMessageBox.critical(self, "Error", mess, QMessageBox.Ok, 0)
129
def setCode(self, code, isDisableOther):
130
if Trace(): print 'InfoDialogHandler.setCode'
131
if code == CFD_Saturne:
132
self.SaturneRB.setEnabled(True)
133
self.SaturneRB.setChecked(True)
134
self.NeptuneRB.setEnabled(not isDisableOther)
135
from code_saturne import cs_package
136
pkg = cs_package.package()
137
elif code == CFD_Neptune:
138
self.NeptuneRB.setEnabled(True)
139
self.NeptuneRB.setChecked(True)
140
self.SaturneRB.setEnabled(not isDisableOther)
141
from neptune_cfd import nc_package
142
pkg = nc_package.package()
144
raise DialogError, "Invalid CFD_Code in InfoDialog class"
145
self.labelVersionValue.setText(pkg.version)
146
self.labelPrefixValue.setText(pkg.prefix)
150
def onCodeChanged(self, currenBtnId):
151
codeBG = self.findChild(QtGui.QButtonGroup, "CodeBG")
153
if codeBG.selected() == self.SaturneRB:
154
_SetCFDCode(CFD_Saturne)
155
from code_saturne import cs_package
156
pkg = cs_package.package()
157
if codeBG.selected() == self.NeptuneRB:
158
_SetCFDCode(CFD_Neptune)
159
from neptune_cfd import nc_package
160
pkg = nc_package.package()
161
self.labelVersionValue.setText(pkg.version)
162
self.labelPrefixValue.setText(pkg.prefix)
165
#-----------------------------------------------------------------------------------------------------------
167
class DefineLinkDialog(QtGui.QDialog, Ui_DefineLinkDialog):
169
QGroupBox Class with radio button added into, with fillDialog method
171
def __init__(self, parent = None):
174
if Trace(): print 'InfoDialog.__init__'
175
QtGui.QDialog.__init__(self, parent)
176
Ui_DefineLinkDialog.__init__(self,parent)
181
class DefineLinkDialogHandler(DefineLinkDialog):
183
QGroupBox Class with radio button added into, with fillDialog method
185
def __init__(self, parent=None ):
186
QtGui.QDialog.__init__(self, parent)
187
DefineLinkDialog.__init__(self,parent)
189
aBtn = self.findChild(QtGui.QPushButton,"OKButton")
190
aBtn.setText(self.tr("DLG_OK_BUTTON_TEXT"))
192
self.BtnGroup = self.MainGroup # comment: QGroupBox
193
self.BtnGroup.setTitle(self.tr("LINK_DLG_GROUP_TITLE"))
194
self.BtnGroup.setCheckable(True)
195
self.setWindowTitle(self.tr("LINK_DLG_CAPTION"))
197
def fillDialog(self, NameList):
199
NameList: Names of the radio buttons to be added into the QGroupBox
201
if Trace(): print 'DefineLinkDialogHandler.fillDialog'
202
#clear previouse entry
203
BtnList = self.BtnGroup.findChildren(QRadioButton)
206
self.BtnGroup.removeChild(obj)
211
aBtn = QRadioButton(i, self.BtnGroup)
214
vbox.addWidget(aBtn, id)
218
self.BtnGroup.setLayout(vbox)
219
self.updateGeometry()
221
def currentName(self):
222
if Trace(): print 'DefineLinkDialogHandler.currentName'
223
BtnList = self.BtnGroup.findChildren(QRadioButton)
225
if obj.isChecked() == True:
230
#-----------------------------------------------------------------------------------------------------------
232
class SetTreeLocationDialog(QtGui.QDialog, Ui_SetTreeLocationDialog):
234
Tree Location Dialog informations about environment variables
236
def __init__(self, parent = None):
239
if Trace(): print 'SetTreeLocationDialog.__init__'
240
QtGui.QDialog.__init__(self, parent)
241
Ui_SetTreeLocationDialog.__init__(self,parent)
246
class SetTreeLocationDialogHandler(SetTreeLocationDialog):
248
Load the CFD study location. If the name of the CFD study
249
does not exists, the corresponding folder is created.
251
def __init__(self, parent = None):
253
Constructor. Initialize text and label of the QDialog.
255
if Trace(): print 'SetTreeLocationDialogHandler.__init__'
256
SetTreeLocationDialog.__init__(self, parent)
258
self.isCaseMode = False
260
aBtn = self.findChild(QtGui.QPushButton,"OKButton")
262
aBtn.setText(self.tr("DLG_OK_BUTTON_TEXT"))
264
aBtn = self.findChild(QtGui.QPushButton,"CancelButton")
266
aBtn.setText(self.tr("DLG_CANCEL_BUTTON_TEXT"))
268
self.setWindowTitle(self.tr("LOCATION_DLG_CAPTION"))
270
aLabel = self.findChild(QtGui.QLabel,"NameLabel")
271
if not aLabel == None:
272
aLabel.setText(self.tr("LOCATION_DLG_STUDY_NAME"))
274
aLabel = self.findChild(QtGui.QLabel,"CaseLabel")
275
if not aLabel == None:
276
aLabel.setText(self.tr("LOCATION_DLG_CASE_NAME"))
278
aGB = self.findChild(QtGui.QGroupBox, "CaseGroupBox")
280
aGB.setTitle(self.tr("LOCATION_DLG_ADD_CASE"))
282
aLabel = self.findChild(QtGui.QLabel,"StudyDirLabel")
283
if not aLabel == None:
284
aLabel.setText(self.tr("LOCATION_DLG_STUDY_DIR_LABEL"))
286
aLE = self.findChild(QtGui.QLineEdit,"StudyDirName")
290
# Installing validator on case name
291
aLE = self.findChild(QtGui.QLineEdit,"CaseLineEdit")
294
aLE = self.findChild(QtGui.QLineEdit,"StudyLineEdit")
303
def onBrowsePath(self):
305
Call into ui_SetTreeLocationDialog.py from setTreeLocationDialog.ui built with qtdesigner
307
if Trace(): print 'SetTreeLocationDialogHandler.onBrowsePath beginning'
308
aLE = self.findChild(QtGui.QLineEdit,"StudyDirName")
310
new_path = aLE.text()
312
new_path = sgPyQt.getExistingDirectory(self, new_path, str(self.tr("SET_STUDY_LOCATION_BROWSE_CAPTION").toLatin1()))
314
if not new_path or new_path == "":
316
new_path = os.path.abspath(str(new_path))
317
if os.path.exists(os.path.join(new_path , 'MAILLAGE')) or os.path.exists(os.path.join(new_path, 'MESH')):
318
new_path, self.StudyName = os.path.split(new_path)
319
if Trace(): print 'SetTreeLocationDialogHandler.onBrowsePath done StudyDirectory',new_path,'self.StudyName',self.StudyName
320
aLE.setText(new_path)
321
self.findChild(QtGui.QLineEdit, "StudyLineEdit").setText(self.StudyName)
324
def setCaseMode(self, flag):
326
modify the Dialog look:
327
flag == False -> study dans cases creation
328
flag == True -> only cases creation
330
self.isCaseMode = flag
331
if self.isCaseMode == True:
332
self.findChild(QtGui.QPushButton,"BrowseButton").hide()
333
self.findChild(QtGui.QLineEdit,"StudyLineEdit").hide()
334
self.findChild(QtGui.QLineEdit,"StudyDirName").hide()
335
self.findChild(QtGui.QLabel,"NameLabel").hide()
336
self.findChild(QtGui.QLabel,"StudyDirLabel").hide()
338
if CFD_Code() == CFD_Neptune:
339
self.findChild(QtGui.QGroupBox,"StudyGB").hide()
341
self.findChild(QtGui.QGroupBox,"CaseGroupBox").setCheckable(False)
343
self.findChild(QtGui.QPushButton,"BrowseButton").show()
344
self.findChild(QtGui.QLineEdit,"StudyLineEdit").show()
345
self.findChild(QtGui.QLineEdit,"StudyDirName").show()
346
self.findChild(QtGui.QLabel,"NameLabel").show()
347
self.findChild(QtGui.QLabel,"StudyDirLabel").show()
349
self.findChild(QtGui.QGroupBox,"CaseGroupBox").setCheckable(True)
350
self.findChild(QtGui.QGroupBox,"CaseGroupBox").setChecked(True)
356
if Trace(): print 'Beginning SetTreeLocationDialogHandler.accept self.StudyPath',self.StudyPath,'self.StudyName',self.StudyName
358
aDirLE = self.findChild(QtGui.QLineEdit,"StudyDirName")
359
aNameLE = self.findChild(QtGui.QLineEdit,"StudyLineEdit")
360
aCaseGB = self.findChild(QtGui.QGroupBox,"CaseGroupBox")
361
aCaseLE = self.findChild(QtGui.QLineEdit,"CaseLineEdit")
363
if aDirLE == None or aNameLE == None \
364
or aCaseGB == None or aCaseLE == None:
365
raise DialogError, "Can't find control widget!"
367
if self.isCaseMode == False:
368
# check study directory
369
aStudyDir = str(aDirLE.text().toLatin1())
371
# create from study dir + study name
373
aStudyDirName = str(aNameLE.text().toUpper().toLatin1())
375
if Trace(): print 'DialogColector.SetTreeLocationDialogHandler.accept',aStudyDirName
377
self.StudyPath = os.path.join(aStudyDir, aStudyDirName)
378
self.StudyName = aStudyDirName
380
studyObj = CFDSTUDYGUI_DataModel.FindStudyByPath(self.StudyPath)
382
mess = self.tr("LOCATION_DLG_ERROR_OPEN_MESS")
383
mess = mess.arg(self.StudyPath)
384
QMessageBox.critical( self, "Error", mess, QMessageBox.Ok, QMessageBox.NoButton)
387
if os.path.isdir(self.StudyPath) and self.StudyName != '':
388
mess = self.tr("LOCATION_DLG_WARN_MESS")
389
mess = mess.arg(self.StudyPath)
390
if QMessageBox.information(self, "Information", mess, QMessageBox.Yes, QMessageBox.No) == QMessageBox.No:
392
elif os.path.isdir(aStudyDir) and self.StudyName != '':
393
mess = self.tr("LOCATION_DLG_WARN_MESS1")
394
mess = mess.arg(aStudyDir)
395
if QMessageBox.warning(self, "Warning", mess, QMessageBox.Yes, QMessageBox.No) == QMessageBox.No:
398
mess = self.tr("LOCATION_DLG_ERROR_MESS")
399
mess = mess.arg(aStudyDir)
400
QMessageBox.critical(self, "Error", mess, QMessageBox.Ok, QMessageBox.NoButton)
404
if aCaseGB.isChecked() or self.isCaseMode == True:
405
if aCaseLE.text() == "":
406
QMessageBox.critical(self, "Error", "Case name is empty!", QMessageBox.Ok, QMessageBox.NoButton)
408
self.CaseNames = str(aCaseLE.text().toLatin1())
412
SetTreeLocationDialog.accept(self)
413
if Trace(): print 'Return SetTreeLocationDialogHandler.accept',self.StudyPath,self.CaseNames
415
#----------------------------------------------------------------------------------------------------------------------
417
class RunCaseDialog(QtGui.QDialog, Ui_RunCaseDialog):
419
Dialog informations about environment variables
421
def __init__(self, parent = None):
424
if Trace(): print 'RunCaseDialog.__init__'
425
QtGui.QDialog.__init__(self, parent)
426
Ui_RunCaseDialog.__init__(self,parent)
430
class RunCaseDialogHandler(RunCaseDialog):
433
def __init__(self, parent = None):
436
if Trace(): print 'RunCaseDialogHandler.__init__'
437
RunCaseDialog.__init__(self,parent)
438
self.aRunBtn = self.findChild(QtGui.QPushButton,"RunCaseBtn")
439
self.aRunBtn.setText(self.tr("RUNCASE_DLG_RUN_BUTTON_TEXT"))
441
aBtn = self.findChild(QtGui.QPushButton,"CancelBtn")
442
aBtn.setText(self.tr("DLG_CANCEL_BUTTON_TEXT"))
444
aBtnGroup = self.findChild(QtGui.QGroupBox,"ModeButtonGroup")
445
aBtnGroup.setTitle(self.tr("RUNCASE_DLG_MODE_TITLE"))
447
aBtn = self.CompileModeBtn
448
aBtn.setText(self.tr("RUNCASE_DLG_COMPILE_MODE_BTN_TEXT"))
450
aBtn = self.RunModeBtn
451
aBtn.setText(self.tr("RUNCASE_DLG_RUN_MODE_BTN_TEXT"))
452
aBtn.setChecked(True)
454
aGroupBox = self.findChild(QtGui.QGroupBox,"MainGroupBox")
455
aGroupBox.setTitle(self.tr("RUNCASE_DLG_MAIN_GROUP_TITLE"))
457
aLbl = self.findChild(QtGui.QLabel,"StudyLabel")
458
aLbl.setText(self.tr("RUNCASE_DLG_STUDY_LABEL_TEXT"))
460
aLbl = self.findChild(QtGui.QLabel,"CaseLabel")
461
aLbl.setText(self.tr("RUNCASE_DLG_CASE_LABEL_TEXT"))
463
self.setWindowTitle(self.tr("RUNCASE_DLG_CAPTION"))
465
self.StudyCB = self.findChild(QtGui.QComboBox,"StudyCB")
466
self.connect(self.StudyCB, SIGNAL("activated(int)"), self.slotUpdateStudy)
468
self.CaseCB = self.findChild(QtGui.QComboBox,"CaseCB")
469
self.connect(self.CaseCB, SIGNAL("activated(int)"), self.slotUpdateCase)
477
if Trace(): print 'RunCaseDialogHandler.fillData'
480
aStudyList = CFDSTUDYGUI_DataModel.GetStudyNameList()
481
if len(aStudyList) == 0:
482
self.__SetInvalidMode(True)
485
self.StudyCB.addItem(self.CurrentStudy.GetName())
486
aCaseList = CFDSTUDYGUI_DataModel.GetCaseNameList(self.CurrentStudy)
490
self.CaseCB.addItem(i)
492
def slotUpdateStudy(self, newStudyIndex):
494
aStudyList = CFDSTUDYGUI_DataModel.GetStudyList()
496
if newStudyIndex > len(aStudyList)-1:
497
if Trace(): print "Error: not correct index of study"
500
aStudyObj = aStudyList[newStudyIndex]
501
#init case-combobox by available cases
502
aCaseList = CFDSTUDYGUI_DataModel.GetCaseNameList(aStudyObj)
506
for item in aCaseList:
507
self.CaseCB.addItem(item)
510
def slotUpdateCase(self, newCaseIndex):
512
aStudyList = CFDSTUDYGUI_DataModel.GetStudyList()
514
aStudyIndex = self.StudyCB.currentIndex()
516
if aStudyIndex > len(aStudyList)-1:
517
if Trace(): print "Error: not correct index of study"
520
aStudyObj = aStudyList[aStudyIndex]
523
aCaseList = CFDSTUDYGUI_DataModel.GetCaseList(aStudyObj)
525
if newCaseIndex > len(aCaseList)-1:
526
if Trace(): print "Error: not correct index of case"
529
aCaseObj = aCaseList[newCaseIndex]
531
# object of DATA folder
532
aChildList = CFDSTUDYGUI_DataModel.ScanChildren(aCaseObj, "DATA")
533
if not len(aChildList) == 1:
535
aDataObj = aChildList[0]
537
aChildList = CFDSTUDYGUI_DataModel.ScanChildren(aDataObj, "THCH")
538
if not len(aChildList) == 1:
540
aTHCHObj = aChildList[0]
542
#check for SaturneGUI or NeptubeGUI file in case:
543
aRunBtn = self.findChild(QtGui.QRadioButton,"RunModeBtn")
545
flag = CFDSTUDYGUI_DataModel.checkCaseLaunchGUI(aCaseObj)
546
aRunBtn.setEnabled(flag)
548
aCompBtn = self.findChild(QtGui.QRadioButton,"RunModeBtn")
549
aCompBtn.setChecked(True)
552
def __SetEnableAllUnderCase(self, param):
553
if Trace(): print 'RunCaseDialogHandler.__SetEnableAllUnderCase'
554
self.aRunBtn.setEnabled(param)
558
if Trace(): print 'RunCaseDialogHandler.show'
560
RunCaseDialog.show(self)
563
def setInitData(self, aCaseObj):
564
self.CurrentCase = aCaseObj
566
def setCurrentCase(self, aCase):
567
self.CurrentCase = aCase
569
# use before fill data
570
def setCurrentStudy(self, theStudy):
571
self.CurrentStudy = theStudy
572
#----------------------------------------------------------------------------------------------------------------------
574
class ECSConversionDialog(QtGui.QDialog,Ui_ECSConversionDialog):
576
Tree Location Dialog informations about environment variables
578
def __init__(self, parent = None):
581
if Trace(): print 'ECSConversionDialog.__init__'
582
QtGui.QDialog.__init__(self, parent)
583
Ui_ECSConversionDialog.__init__(self,parent)
587
class ECSConversionDialogHandler(ECSConversionDialog):
590
def __init__(self, parent = None):
592
Constructor. Initialize text and label of the QDialog.
594
if Trace(): print 'ECSConversionDialogHandler.__init__'
595
ECSConversionDialog.__init__(self, parent)
597
self.ConvertBtn = self.findChild(QtGui.QPushButton,"ConvertBtn")
598
self.ConvertBtn.setText(self.tr("ECSCONVERT_DLG_CONVERT_BUTTON"))
600
aBtn = self.findChild(QtGui.QPushButton,"CancelBtn")
601
aBtn.setText(self.tr("DLG_CANCEL_BUTTON_TEXT"))
603
aBtnGroup = self.findChild(QtGui.QGroupBox,"OptionsGroup")
604
aBtnGroup.setTitle(self.tr("ECSCONVERT_DLG_OPTIONS_TITLE"))
606
self.VolOptBtn = self.VolOptButton
607
self.VolOptBtn.setText(self.tr("ECSCONVERT_DLG_VOL_OPT_BTN_TEXT"))
608
self.VolOptBtn.setChecked(True)
610
self.BordOptBtn = self.BordOptButton
611
self.BordOptBtn.setText(self.tr("ECSCONVERT_DLG_BORD_OPT_BTN_TEXT"))
613
self.Color2GroupButton.setText(self.tr("ECSCONVERT_DLG_COLOR_OPT_BTN_TEXT"))
614
self.Color2GroupButton.setChecked(True)
616
aLabel = self.findChild(QtGui.QLabel,"CaseLabel")
619
self.CaseCB = self.findChild(QtGui.QComboBox,"CaseCB")
622
self.ResultLabel = self.findChild(QtGui.QLabel,"ResultLabel")
623
self.ResultLabel.setText(self.tr("ECSCONVERT_DLG_RESULT_LABEL_TEXT"))
625
self.ResultName = self.findChild(QtGui.QLineEdit,"ResultNameLE")
627
self.connect(self.ResultName, SIGNAL('textChanged(const QString&)'), self.slotResNameChanged)
629
self.setWindowTitle(self.tr("ECSCONVERT_DLG_CAPTION"))
634
def GetCaseName(self):
635
return self.CaseCB.currentText()
638
def IsVolOption(self):
639
return self.VolOptBtn.isChecked()
642
def IsBordOption(self):
643
return self.BordOptBtn.isChecked()
646
def IsColor2GroupOption(self):
647
return self.Color2GroupButton.isChecked()
651
aStudy = CFDSTUDYGUI_DataModel.GetFirstStudy()
655
aCaseList = CFDSTUDYGUI_DataModel.GetCaseNameList(aStudy)
656
if len(aCaseList) == 0:
657
self.CaseCB.setEnabled(False)
658
self.ConvertBtn.setEnabled(False)
660
self.CaseCB.setEnabled(True)
661
self.ConvertBtn.setEnabled(True)
663
self.CaseCB.insertItem(i)
665
ECSConversionDialog.show(self)
667
def resultFileName(self):
669
aResName = str(self.ResultName.text().toLatin1())
670
if re.match(".*\.med$", aResName) and len(aResName) > 4:
671
aResName = aResName[0:len(aResName)-4]
673
if Trace(): print "RESULT NAME is", aResName
677
def setResultFileName(self, NewName):
679
self.ResultName.clear()
681
self.ResultName.setText(NewName)
683
self.slotResNameChanged()
686
def slotResNameChanged(self):
687
self.ConvertBtn.setEnabled(str(self.ResultName.text().toLatin1())!= '')
689
#----------------------------------------------------------------------------------------------------------------------
690
class CopyDialog(QtGui.QDialog,Ui_CopyDialog):
692
Dialog informations about environment variables
694
def __init__(self, parent = None):
697
if Trace(): print 'CopyDialog.__init__'
698
QtGui.QDialog.__init__(self, parent)
699
Ui_CopyDialog.__init__(self,parent)
703
class CopyDialogHandler(CopyDialog):
706
def __init__(self, parent = None):
707
CopyDialog.__init__(self, parent)
708
self.CopyBtn = self.findChild(QtGui.QPushButton,"CopyBtn")
709
self.CopyBtn.setText(self.tr("COPY_DLG_COPY_BUTTON"))
711
aBtn = self.findChild(QtGui.QPushButton,"CancelBtn")
712
aBtn.setText(self.tr("DLG_CANCEL_BUTTON_TEXT"))
714
aLabel = self.findChild(QtGui.QLabel,"DestCaseLabel")
715
aLabel.setText(self.tr("COPY_DLG_DEST_CASE_LABEL"))
717
aLabel = self.findChild(QtGui.QLabel,"SourceCaseLabel")
718
aLabel.setText(self.tr("COPY_DLG_SOURCE_CASE_LABEL"))
720
aLabel = self.findChild(QtGui.QLabel,"FileNameLabel")
721
aLabel.setText(self.tr("COPY_DLG_FILE_NAME_LABEL"))
723
self.FileName = self.findChild(QtGui.QLabel,"FileName")
724
self.SourceCaseName = self.findChild(QtGui.QLabel,"SourceCaseName")
725
self.DestCaseCB = self.findChild(QtGui.QComboBox,"DestCaseCB")
727
self.setWindowTitle(self.tr("COPY_DLG_CAPTION"))
731
aStudy = CFDSTUDYGUI_DataModel.GetFirstStudy()
733
self.DestCaseCB.clear()
734
if self.CopyBtn.isEnabled():
735
aCaseList = CFDSTUDYGUI_DataModel.GetCaseNameList(aStudy)
737
if len(aCaseList) == 0:
738
self.DestCaseCB.setEnabled(False)
739
self.CopyBtn.setEnabled(False)
741
self.DestCaseCB.setEnabled(True)
742
self.CopyBtn.setEnabled(True)
744
sourceCase = str(self.SourceCaseName.text().toLatin1())
747
if not i == sourceCase:
748
self.DestCaseCB.addItem(i)
750
CopyDialog.exec_(self)
753
def setCurrentObject(self, sobj):
755
aCase = CFDSTUDYGUI_DataModel.GetCase(sobj)
756
if not sobj == None and not aCase == None:
757
self.FileName.setText(sobj.GetName())
758
self.SourceCaseName.setText(aCase.GetName())
760
self.DestCaseCB.setEnabled(True)
761
self.CopyBtn.setEnabled(True)
764
self.FileName.setText("")
765
self.SourceCaseName.SetText("")
766
self.DestCaseCB.setEnabled(False)
767
self.CopyBtn.setEnabled(False)
771
aSourceFilePath = CFDSTUDYGUI_DataModel._GetPath(self.Object)
772
aSourceCase = CFDSTUDYGUI_DataModel.GetCase(self.Object)
773
aSourceCasePath = CFDSTUDYGUI_DataModel._GetPath(aSourceCase)
775
aSourceCaseName = str(self.SourceCaseName.text().toLatin1())
776
aDestCaseName = str(self.DestCaseCB.currentText().toLatin1())
778
#check for existing of file in destinate CASE
779
aDestCasePath = str(QString(aSourceCasePath).left(len(aSourceCasePath)-len(aSourceCaseName)).toLatin1())
780
aDestCasePath += aDestCaseName
782
aDestFilePath = aDestCasePath + str(QString(aSourceFilePath).right(len(aSourceFilePath)-len(aSourceCasePath)).toLatin1())
784
if os.path.exists(aDestFilePath) and os.path.isfile(aDestFilePath):
785
QMessageBox.critical(self, self.tr("COPY_DLG_EXISTS_ERROR_CAPTION"), self.tr("COPY_DLG_EXISTS_ERROR_TEXT"), 1, 0)
788
aCmd = "cp " + aSourceFilePath + " " + aDestFilePath
790
status = os.system(aCmd)
792
QMessageBox.critical(self, self.tr("COPY_DLG_COPY_ERROR_CAPTION"), self.tr("COPY_DLG_COPY_ERROR_TEXT"), 1, 0)
795
CopyDialog.accept(self)
798
def destCaseName(self):
799
return str(self.DestCaseCB.currentText().toLatin1())
802
#----------------------------------------------------------------------------------------------------------------------
805
class GUIActivationDialog(QtGui.QDialog,Ui_GUIActivationDialog):
807
Set environment variables Dialog informations
809
def __init__(self, parent = None):
812
if Trace(): print 'GUIActivationDialog.__init__'
813
QtGui.QDialog.__init__(self)
814
Ui_GUIActivationDialog.__init__(self,parent)
818
class GUIActivationDialogHandler(GUIActivationDialog):
821
def __init__(self, parent = None):
824
GUIActivationDialog.__init__(self, parent)
826
self.ActivateBtn = self.findChild(QtGui.QPushButton,"ActivateBtn")
827
self.ActivateBtn.setText(self.tr("GUIACTIVATE_DLG_ACTIVATE_BTN"))
829
aBtn = self.findChild(QtGui.QPushButton,"CancelBtn")
830
aBtn.setText(self.tr("DLG_CANCEL_BUTTON_TEXT"))
832
self.CaseCB = self.findChild(QtGui.QComboBox,"CaseCB")
834
aGB = self.findChild(QtGui.QGroupBox,"OptionsGB")
835
aGB.setTitle(self.tr("GUIACTIVATE_DLG_OPTIONS_TITLE"))
837
self.FileCheckBox = self.findChild(QtGui.QCheckBox,"FileCheckBox")
838
self.FileCB = self.findChild(QtGui.QComboBox,"FileCB")
841
self.LangCheckBox = self.findChild(QtGui.QCheckBox,"LangCheckBox")
842
self.LangCB = self.findChild(QtGui.QComboBox,"LangCB")
844
self.LangCB.setEnabled(False)
846
self.LangCheckBox.hide()
849
self.connect(self.FileCheckBox, SIGNAL("clicked()"), self.slotUseXMLfileChange)
850
self.connect(self.LangCheckBox, SIGNAL("clicked()"), self.slotUseLangChange)
852
self.connect(self.CaseCB, SIGNAL("activated(int)"), self.slotUpdateData)
857
def fillData(self, xmlFileName):
860
if Trace(): print 'GUIActivationDialogHandler.fillData'
862
self.disconnect(self.CaseCB, SIGNAL("activated(int)"), self.slotUpdateData)
864
self.xmlfile = xmlFileName
866
for i in CFDSTUDYGUI_DataModel.GetCaseNameList(self.CurrentStudy):
867
if self.CurrentCase and self.CurrentCase.GetName() == i:
868
self.CaseCB.addItem(i)
870
if self.xmlfile == "" :
871
self.slotUpdateData()
873
self.slotUpdateData()
875
if CFD_Code() == CFD_Saturne:
876
self.setWindowTitle(self.tr("ICSACTIVATE_DLG_CAPTION"))
877
self.CaseLabel.setTitle(self.tr("ICSACTIVATE_DLG_CASE_LABEL"))
878
self.FileCheckBox.setChecked(False)
879
self.LangCheckBox.setChecked(False)
880
elif CFD_Code() == CFD_Neptune:
881
self.setWindowTitle(self.tr("IPBACTIVATE_DLG_CAPTION"))
882
self.CaseLabel.setTitle(self.tr("IPBACTIVATE_DLG_CASE_LABEL"))
883
self.LangCheckBox.hide()
887
def slotUpdateData(self):
888
if Trace(): print 'GUIActivationDialogHandler.slotUpdateData'
890
self.ActivateBtn.setEnabled(True)
893
if self.CaseCB.currentText() == None:
894
self.FileCheckBox.setEnabled(False)
895
self.FileCB.setEnabled(False)
897
self.FileCheckBox.setEnabled(True)
901
aCaseName = str(self.CaseCB.currentText().toLatin1())
902
if Trace(): print "CaseName:", aCaseName
904
self.ActivateBtn.setEnabled(False)
908
aCases = CFDSTUDYGUI_DataModel.GetCaseList(self.CurrentStudy)
910
if c.GetName() == aCaseName:
915
self.ActivateBtn.setEnabled(False)
918
# object of DATA folder
919
aChildList = CFDSTUDYGUI_DataModel.ScanChildren(aCase, "DATA")
920
if not len(aChildList) == 1:
921
self.ActivateBtn.setEnabled(False)
923
aDataObj = aChildList[0]
926
if self.xmlfile == "" :
927
aFileList = CFDSTUDYGUI_DataModel.ScanChildNames(aDataObj, ".*\.xml$")
928
if len(aFileList) == 0:
929
self.FileCheckBox.setEnabled(False);
932
self.FileCB.addItem(i)
934
self.FileCB.setEnabled(self.FileCheckBox.isChecked())
936
self.FileCB.addItem(self.xmlfile)
937
self.FileCB.setEnabled(self.FileCheckBox.isChecked())
939
#check for activation file SaturneGUI or NeptuneGUI
940
if not CFDSTUDYGUI_DataModel.checkCaseLaunchGUI(aCase):
942
if CFD_Code() == CFD_Saturne:
943
mess = self.tr("ICSACTIVATE_DLG_BAD_CASE_MESS")
944
elif CFD_Code() == CFD_Neptune:
945
mess = self.tr("IPBACTIVATE_DLG_BAD_CASE_MESS")
946
QMessageBox.warning(None, "Warning", mess, QMessageBox.Ok, 0)
947
self.ActivateBtn.setEnabled(False)
950
# use before fill data
951
def setCurrentCase(self, aCase):
952
self.CurrentCase = aCase
955
# use before fill data
956
def setCurrentStudy(self, theStudy):
957
self.CurrentStudy = theStudy
960
# use after fill data
961
def setCurrentXMLfile(self, aFile):
962
if self.CurrentCase != None:
963
self.FileCheckBox.setChecked(True)
964
self.FileCB.setEnabled(True)
965
#self.FileCB.setEditText(aFile)
969
def currentCaseName(self):
970
if self.CaseCB.currentText() == 0:
973
return str(self.CaseCB.currentText().toLatin1())
976
def currentXMLfile(self):
977
if not self.FileCB.isEnabled():
979
return self.FileCB.currentText().toLatin1()
982
def currentLanguage(self):
983
return str(self.LangCB.currentText().toLatin1())
986
def isUseXmlFile(self):
987
return self.FileCheckBox.isChecked()
990
def ifUseLangOption(self):
991
return self.LangCheckBox.isChecked()
994
def slotUseXMLfileChange(self):
995
self.FileCB.setEnabled(self.FileCheckBox.isChecked())
998
def slotUseLangChange(self):
999
self.LangCB.setEnabled(self.LangCheckBox.isChecked())
1003
class CFDSTUDYGUI_DialogCollector:
1005
if Trace(): print 'CFDSTUDYGUI_DialogCollector.__init__'
1006
self.SetTreeLocationDialog = SetTreeLocationDialogHandler()
1007
self.InfoDialog = InfoDialogHandler()
1008
self.DefineLinkDialog = DefineLinkDialogHandler()
1009
self.RunCaseDialog = RunCaseDialogHandler()
1010
self.ECSConversionDialog = ECSConversionDialogHandler()
1011
self.CopyDialog = CopyDialogHandler()
1012
self.GUIActivationDialog = GUIActivationDialogHandler()
1017
if __name__ == "__main__":
1018
app = QtGui.QApplication(sys.argv)
1021
if len(sys.argv) == 2:
1024
QM_FILE = "CFDSTUDY_msg_"+lang+".qm"
1025
fi = QFileInfo(QM_FILE)
1028
QMessageBox.warning(None, "File error",
1029
"Cannot find translation for language: "+lang)
1031
translator = QTranslator()
1032
translator.load(QM_FILE)
1033
app.installTranslator(translator)
1034
w = InfoDialogHandler()
1037
sys.exit(app.exec_())