~ubuntu-branches/ubuntu/precise/code-saturne/precise

« back to all changes in this revision

Viewing changes to salome/cfd_study/src/CFDSTUDYGUI/CFDSTUDYGUI_DialogCollector.py

  • Committer: Package Import Robot
  • Author(s): Sylvestre Ledru
  • Date: 2011-11-01 17:43:32 UTC
  • mto: (6.1.7 sid)
  • mto: This revision was merged to the branch mainline in revision 11.
  • Revision ID: package-import@ubuntu.com-20111101174332-tl4vk45no0x3emc3
Tags: upstream-2.1.0
ImportĀ upstreamĀ versionĀ 2.1.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# -*- coding: utf-8 -*-
 
2
 
 
3
#-------------------------------------------------------------------------------
 
4
 
 
5
# This file is part of Code_Saturne, a general-purpose CFD tool.
 
6
#
 
7
# Copyright (C) 1998-2011 EDF S.A.
 
8
#
 
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
 
12
# version.
 
13
#
 
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
 
17
# details.
 
18
#
 
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.
 
22
 
 
23
#-------------------------------------------------------------------------------
 
24
 
 
25
"""
 
26
Dialog Collector
 
27
================
 
28
 
 
29
This file gathers the C{QDialog} definitions of the CFD_STUDY module.
 
30
"""
 
31
 
 
32
#-------------------------------------------------------------------------------
 
33
# Standard modules
 
34
#-------------------------------------------------------------------------------
 
35
 
 
36
import os
 
37
import re
 
38
 
 
39
#-------------------------------------------------------------------------------
 
40
# Third-party modules
 
41
#-------------------------------------------------------------------------------
 
42
 
 
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
 
46
 
 
47
#For Testing
 
48
from PyQt4.QtCore import QTranslator
 
49
 
 
50
#-------------------------------------------------------------------------------
 
51
# Salome modules
 
52
#-------------------------------------------------------------------------------
 
53
 
 
54
#-------------------------------------------------------------------------------
 
55
# Application modules
 
56
#-------------------------------------------------------------------------------
 
57
 
 
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
 
66
 
 
67
from CFDSTUDYGUI_Commons import _SetCFDCode, CFD_Code, Trace, sgPyQt
 
68
from CFDSTUDYGUI_Commons import CFD_Saturne, CFD_Neptune, CheckCFD_CodeEnv
 
69
 
 
70
#-------------------------------------------------------------------------------
 
71
# Dialog definitions
 
72
#-------------------------------------------------------------------------------
 
73
 
 
74
class InfoDialog(QtGui.QDialog, Ui_InfoDialog):
 
75
    """
 
76
    Dialog informations about solver installation.
 
77
    """
 
78
    def __init__(self, parent = None):
 
79
        """
 
80
        """
 
81
        if Trace(): print 'InfoDialog.__init__'
 
82
        QtGui.QDialog.__init__(self, parent)
 
83
        Ui_InfoDialog.__init__(self,parent)
 
84
 
 
85
        self.setupUi(self)
 
86
 
 
87
 
 
88
class InfoDialogHandler(InfoDialog):
 
89
    """
 
90
    """
 
91
    def __init__(self, parent = None):
 
92
        """
 
93
        """
 
94
        if Trace(): print 'InfoDialogHandler.__init__'
 
95
        InfoDialog.__init__(self,parent)
 
96
 
 
97
        self.status = 1 #initial access status
 
98
 
 
99
        aBtn = self.findChild(QtGui.QPushButton, "OKButton")
 
100
        if aBtn != None:
 
101
            aBtn.setText(self.tr("DLG_OK_BUTTON_TEXT"))
 
102
 
 
103
        codeBG = self.findChild(QtGui.QButtonGroup, "CodeBG")
 
104
        if codeBG != None:
 
105
            codeBG.setTitle(self.tr("INFO_DLG_CFDCODE_TITLE"))
 
106
 
 
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"))
 
114
 
 
115
        self.setWindowTitle(self.tr("INFO_DLG_CAPTION"))
 
116
 
 
117
 
 
118
    def accept(self):
 
119
        if Trace(): print 'InfoDialogHandler.accept'
 
120
        if CheckCFD_CodeEnv(CFD_Code()):
 
121
            InfoDialog.accept(self)
 
122
            #block other code
 
123
            self.setCode(CFD_Code(), True)
 
124
#        else:
 
125
#            mess = self.tr("INFO_DLG_INVALID_ENV")
 
126
#            QMessageBox.critical(self, "Error", mess, QMessageBox.Ok, 0)
 
127
 
 
128
 
 
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()
 
143
        else:
 
144
            raise DialogError, "Invalid CFD_Code in InfoDialog class"
 
145
        self.labelVersionValue.setText(pkg.version)
 
146
        self.labelPrefixValue.setText(pkg.prefix)
 
147
        _SetCFDCode(code)
 
148
 
 
149
 
 
150
    def onCodeChanged(self, currenBtnId):
 
151
        codeBG = self.findChild(QtGui.QButtonGroup, "CodeBG")
 
152
        if codeBG != None:
 
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)
 
163
 
 
164
 
 
165
#-----------------------------------------------------------------------------------------------------------
 
166
 
 
167
class DefineLinkDialog(QtGui.QDialog, Ui_DefineLinkDialog):
 
168
    """
 
169
    QGroupBox Class with radio button added into, with fillDialog method
 
170
    """
 
171
    def __init__(self, parent = None):
 
172
        """
 
173
        """
 
174
        if Trace(): print 'InfoDialog.__init__'
 
175
        QtGui.QDialog.__init__(self, parent)
 
176
        Ui_DefineLinkDialog.__init__(self,parent)
 
177
 
 
178
        self.setupUi(self)
 
179
 
 
180
 
 
181
class DefineLinkDialogHandler(DefineLinkDialog):
 
182
    """
 
183
    QGroupBox Class with radio button added into, with fillDialog method
 
184
    """
 
185
    def __init__(self, parent=None ):
 
186
        QtGui.QDialog.__init__(self, parent)
 
187
        DefineLinkDialog.__init__(self,parent)
 
188
 
 
189
        aBtn = self.findChild(QtGui.QPushButton,"OKButton")
 
190
        aBtn.setText(self.tr("DLG_OK_BUTTON_TEXT"))
 
191
 
 
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"))
 
196
 
 
197
    def fillDialog(self, NameList):
 
198
        """
 
199
        NameList: Names of the radio buttons to be added into the QGroupBox
 
200
        """
 
201
        if Trace(): print 'DefineLinkDialogHandler.fillDialog'
 
202
        #clear previouse entry
 
203
        BtnList = self.BtnGroup.findChildren(QRadioButton)
 
204
 
 
205
        for obj in BtnList:
 
206
            self.BtnGroup.removeChild(obj)
 
207
            obj.deleteLater()
 
208
        id = 0
 
209
        vbox = QVBoxLayout()
 
210
        for i in NameList:
 
211
            aBtn = QRadioButton(i, self.BtnGroup)
 
212
            if i == NameList[0]:
 
213
                aBtn.setChecked(1)
 
214
            vbox.addWidget(aBtn, id)
 
215
            id += 1
 
216
 
 
217
        vbox.addStretch(1)
 
218
        self.BtnGroup.setLayout(vbox)
 
219
        self.updateGeometry()
 
220
 
 
221
    def currentName(self):
 
222
        if Trace(): print 'DefineLinkDialogHandler.currentName'
 
223
        BtnList = self.BtnGroup.findChildren(QRadioButton)
 
224
        for obj in BtnList:
 
225
            if obj.isChecked() == True:
 
226
                return obj.text()
 
227
 
 
228
        return ""
 
229
 
 
230
#-----------------------------------------------------------------------------------------------------------
 
231
 
 
232
class SetTreeLocationDialog(QtGui.QDialog, Ui_SetTreeLocationDialog):
 
233
    """
 
234
    Tree Location Dialog informations about environment variables
 
235
    """
 
236
    def __init__(self, parent = None):
 
237
        """
 
238
        """
 
239
        if Trace(): print 'SetTreeLocationDialog.__init__'
 
240
        QtGui.QDialog.__init__(self, parent)
 
241
        Ui_SetTreeLocationDialog.__init__(self,parent)
 
242
 
 
243
        self.setupUi(self)
 
244
 
 
245
 
 
246
class SetTreeLocationDialogHandler(SetTreeLocationDialog):
 
247
    """
 
248
    Load the CFD study location. If the name of the CFD study
 
249
    does not exists, the corresponding folder is created.
 
250
    """
 
251
    def __init__(self, parent = None):
 
252
        """
 
253
        Constructor. Initialize text and label of the QDialog.
 
254
        """
 
255
        if Trace(): print 'SetTreeLocationDialogHandler.__init__'
 
256
        SetTreeLocationDialog.__init__(self, parent)
 
257
        #AB add case mode
 
258
        self.isCaseMode = False
 
259
 
 
260
        aBtn = self.findChild(QtGui.QPushButton,"OKButton")
 
261
        if not aBtn == None:
 
262
            aBtn.setText(self.tr("DLG_OK_BUTTON_TEXT"))
 
263
 
 
264
        aBtn = self.findChild(QtGui.QPushButton,"CancelButton")
 
265
        if not aBtn == None:
 
266
            aBtn.setText(self.tr("DLG_CANCEL_BUTTON_TEXT"))
 
267
 
 
268
        self.setWindowTitle(self.tr("LOCATION_DLG_CAPTION"))
 
269
 
 
270
        aLabel = self.findChild(QtGui.QLabel,"NameLabel")
 
271
        if not aLabel == None:
 
272
            aLabel.setText(self.tr("LOCATION_DLG_STUDY_NAME"))
 
273
 
 
274
        aLabel = self.findChild(QtGui.QLabel,"CaseLabel")
 
275
        if not aLabel == None:
 
276
            aLabel.setText(self.tr("LOCATION_DLG_CASE_NAME"))
 
277
 
 
278
        aGB = self.findChild(QtGui.QGroupBox, "CaseGroupBox")
 
279
        if not aGB == None:
 
280
            aGB.setTitle(self.tr("LOCATION_DLG_ADD_CASE"))
 
281
 
 
282
        aLabel = self.findChild(QtGui.QLabel,"StudyDirLabel")
 
283
        if not aLabel == None:
 
284
            aLabel.setText(self.tr("LOCATION_DLG_STUDY_DIR_LABEL"))
 
285
 
 
286
        aLE = self.findChild(QtGui.QLineEdit,"StudyDirName")
 
287
        if aLE != None:
 
288
            aLE.clear()
 
289
 
 
290
        # Installing validator on case name
 
291
        aLE = self.findChild(QtGui.QLineEdit,"CaseLineEdit")
 
292
        if aLE != None:
 
293
            aLE.clear()
 
294
        aLE = self.findChild(QtGui.QLineEdit,"StudyLineEdit")
 
295
        if aLE != None:
 
296
            aLE.clear()
 
297
 
 
298
        self.StudyPath = ''
 
299
        self.StudyName = ''
 
300
        self.adjustSize()
 
301
 
 
302
 
 
303
    def onBrowsePath(self):
 
304
        """
 
305
        Call into ui_SetTreeLocationDialog.py from setTreeLocationDialog.ui built with qtdesigner
 
306
        """
 
307
        if Trace(): print 'SetTreeLocationDialogHandler.onBrowsePath beginning'
 
308
        aLE = self.findChild(QtGui.QLineEdit,"StudyDirName")
 
309
        if aLE != None:
 
310
            new_path = aLE.text()
 
311
 
 
312
            new_path = sgPyQt.getExistingDirectory(self, new_path, str(self.tr("SET_STUDY_LOCATION_BROWSE_CAPTION").toLatin1()))
 
313
 
 
314
            if not new_path or new_path == "":
 
315
                return
 
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)
 
322
 
 
323
 
 
324
    def setCaseMode(self, flag):
 
325
        """
 
326
        modify the Dialog look:
 
327
        flag == False -> study dans cases creation
 
328
        flag == True -> only cases creation
 
329
        """
 
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()
 
337
 
 
338
            if CFD_Code() == CFD_Neptune:
 
339
                self.findChild(QtGui.QGroupBox,"StudyGB").hide()
 
340
 
 
341
            self.findChild(QtGui.QGroupBox,"CaseGroupBox").setCheckable(False)
 
342
        else:
 
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()
 
348
 
 
349
            self.findChild(QtGui.QGroupBox,"CaseGroupBox").setCheckable(True)
 
350
            self.findChild(QtGui.QGroupBox,"CaseGroupBox").setChecked(True)
 
351
 
 
352
        self.adjustSize();
 
353
 
 
354
 
 
355
    def accept(self):
 
356
        if Trace(): print 'Beginning SetTreeLocationDialogHandler.accept self.StudyPath',self.StudyPath,'self.StudyName',self.StudyName
 
357
 
 
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")
 
362
 
 
363
        if aDirLE == None  or aNameLE == None \
 
364
               or aCaseGB == None or aCaseLE == None:
 
365
            raise DialogError, "Can't find control widget!"
 
366
 
 
367
        if self.isCaseMode == False:
 
368
            # check study directory
 
369
            aStudyDir = str(aDirLE.text().toLatin1())
 
370
 
 
371
            # create from study dir + study name
 
372
 
 
373
            aStudyDirName = str(aNameLE.text().toUpper().toLatin1())
 
374
 
 
375
            if Trace(): print 'DialogColector.SetTreeLocationDialogHandler.accept',aStudyDirName
 
376
 
 
377
            self.StudyPath = os.path.join(aStudyDir, aStudyDirName)
 
378
            self.StudyName = aStudyDirName
 
379
 
 
380
            studyObj = CFDSTUDYGUI_DataModel.FindStudyByPath(self.StudyPath)
 
381
            if studyObj != None:
 
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)
 
385
                return False
 
386
 
 
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:
 
391
                    return False
 
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:
 
396
                    return False
 
397
            else:
 
398
                mess = self.tr("LOCATION_DLG_ERROR_MESS")
 
399
                mess = mess.arg(aStudyDir)
 
400
                QMessageBox.critical(self, "Error", mess, QMessageBox.Ok, QMessageBox.NoButton)
 
401
                return False
 
402
 
 
403
        # ckeck case name
 
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)
 
407
                return False
 
408
            self.CaseNames = str(aCaseLE.text().toLatin1())
 
409
        else:
 
410
            self.CaseNames = ""
 
411
 
 
412
        SetTreeLocationDialog.accept(self)
 
413
        if Trace(): print 'Return SetTreeLocationDialogHandler.accept',self.StudyPath,self.CaseNames
 
414
 
 
415
#----------------------------------------------------------------------------------------------------------------------
 
416
 
 
417
class RunCaseDialog(QtGui.QDialog, Ui_RunCaseDialog):
 
418
    """
 
419
    Dialog informations about environment variables
 
420
    """
 
421
    def __init__(self, parent = None):
 
422
        """
 
423
        """
 
424
        if Trace(): print 'RunCaseDialog.__init__'
 
425
        QtGui.QDialog.__init__(self, parent)
 
426
        Ui_RunCaseDialog.__init__(self,parent)
 
427
 
 
428
        self.setupUi(self)
 
429
 
 
430
class RunCaseDialogHandler(RunCaseDialog):
 
431
    """
 
432
    """
 
433
    def __init__(self, parent = None):
 
434
        """
 
435
        """
 
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"))
 
440
 
 
441
        aBtn = self.findChild(QtGui.QPushButton,"CancelBtn")
 
442
        aBtn.setText(self.tr("DLG_CANCEL_BUTTON_TEXT"))
 
443
 
 
444
        aBtnGroup = self.findChild(QtGui.QGroupBox,"ModeButtonGroup")
 
445
        aBtnGroup.setTitle(self.tr("RUNCASE_DLG_MODE_TITLE"))
 
446
 
 
447
        aBtn = self.CompileModeBtn
 
448
        aBtn.setText(self.tr("RUNCASE_DLG_COMPILE_MODE_BTN_TEXT"))
 
449
 
 
450
        aBtn = self.RunModeBtn
 
451
        aBtn.setText(self.tr("RUNCASE_DLG_RUN_MODE_BTN_TEXT"))
 
452
        aBtn.setChecked(True)
 
453
 
 
454
        aGroupBox = self.findChild(QtGui.QGroupBox,"MainGroupBox")
 
455
        aGroupBox.setTitle(self.tr("RUNCASE_DLG_MAIN_GROUP_TITLE"))
 
456
 
 
457
        aLbl = self.findChild(QtGui.QLabel,"StudyLabel")
 
458
        aLbl.setText(self.tr("RUNCASE_DLG_STUDY_LABEL_TEXT"))
 
459
 
 
460
        aLbl = self.findChild(QtGui.QLabel,"CaseLabel")
 
461
        aLbl.setText(self.tr("RUNCASE_DLG_CASE_LABEL_TEXT"))
 
462
 
 
463
        self.setWindowTitle(self.tr("RUNCASE_DLG_CAPTION"))
 
464
 
 
465
        self.StudyCB = self.findChild(QtGui.QComboBox,"StudyCB")
 
466
        self.connect(self.StudyCB, SIGNAL("activated(int)"), self.slotUpdateStudy)
 
467
 
 
468
        self.CaseCB = self.findChild(QtGui.QComboBox,"CaseCB")
 
469
        self.connect(self.CaseCB, SIGNAL("activated(int)"), self.slotUpdateCase)
 
470
 
 
471
        self.adjustSize()
 
472
 
 
473
        self.InitCase = None
 
474
 
 
475
 
 
476
    def fillData(self):
 
477
        if Trace(): print 'RunCaseDialogHandler.fillData'
 
478
 
 
479
        self.StudyCB.clear()
 
480
        aStudyList = CFDSTUDYGUI_DataModel.GetStudyNameList()
 
481
        if len(aStudyList) == 0:
 
482
            self.__SetInvalidMode(True)
 
483
            return
 
484
        self.StudyCB.clear()
 
485
        self.StudyCB.addItem(self.CurrentStudy.GetName())
 
486
        aCaseList = CFDSTUDYGUI_DataModel.GetCaseNameList(self.CurrentStudy)
 
487
        self.CaseCB.clear()
 
488
 
 
489
        for i in aCaseList:
 
490
            self.CaseCB.addItem(i)
 
491
 
 
492
    def slotUpdateStudy(self, newStudyIndex):
 
493
 
 
494
        aStudyList = CFDSTUDYGUI_DataModel.GetStudyList()
 
495
 
 
496
        if newStudyIndex > len(aStudyList)-1:
 
497
            if Trace(): print "Error: not correct index of study"
 
498
            return
 
499
        #obtain study object
 
500
        aStudyObj = aStudyList[newStudyIndex]
 
501
        #init case-combobox by available cases
 
502
        aCaseList = CFDSTUDYGUI_DataModel.GetCaseNameList(aStudyObj)
 
503
 
 
504
        self.CaseCB.clear()
 
505
 
 
506
        for item in aCaseList:
 
507
            self.CaseCB.addItem(item)
 
508
 
 
509
 
 
510
    def slotUpdateCase(self, newCaseIndex):
 
511
 
 
512
        aStudyList = CFDSTUDYGUI_DataModel.GetStudyList()
 
513
 
 
514
        aStudyIndex = self.StudyCB.currentIndex()
 
515
 
 
516
        if aStudyIndex > len(aStudyList)-1:
 
517
            if Trace(): print "Error: not correct index of study"
 
518
            return
 
519
        #obtain study object
 
520
        aStudyObj = aStudyList[aStudyIndex]
 
521
 
 
522
        # current case
 
523
        aCaseList =  CFDSTUDYGUI_DataModel.GetCaseList(aStudyObj)
 
524
 
 
525
        if newCaseIndex > len(aCaseList)-1:
 
526
            if Trace(): print "Error: not correct index of case"
 
527
            return
 
528
        #obtain study object
 
529
        aCaseObj = aCaseList[newCaseIndex]
 
530
 
 
531
        # object of DATA folder
 
532
        aChildList = CFDSTUDYGUI_DataModel.ScanChildren(aCaseObj, "DATA")
 
533
        if not len(aChildList) == 1:
 
534
            return
 
535
        aDataObj =  aChildList[0]
 
536
 
 
537
        aChildList = CFDSTUDYGUI_DataModel.ScanChildren(aDataObj, "THCH")
 
538
        if not len(aChildList) == 1:
 
539
            return
 
540
        aTHCHObj =  aChildList[0]
 
541
 
 
542
        #check for SaturneGUI or NeptubeGUI file in case:
 
543
        aRunBtn = self.findChild(QtGui.QRadioButton,"RunModeBtn")
 
544
 
 
545
        flag = CFDSTUDYGUI_DataModel.checkCaseLaunchGUI(aCaseObj)
 
546
        aRunBtn.setEnabled(flag)
 
547
        if not flag:
 
548
            aCompBtn = self.findChild(QtGui.QRadioButton,"RunModeBtn")
 
549
            aCompBtn.setChecked(True)
 
550
 
 
551
 
 
552
    def __SetEnableAllUnderCase(self, param):
 
553
        if Trace(): print 'RunCaseDialogHandler.__SetEnableAllUnderCase'
 
554
        self.aRunBtn.setEnabled(param)
 
555
 
 
556
 
 
557
    def show(self):
 
558
        if Trace(): print 'RunCaseDialogHandler.show'
 
559
        self.fillData()
 
560
        RunCaseDialog.show(self)
 
561
 
 
562
 
 
563
    def setInitData(self, aCaseObj):
 
564
        self.CurrentCase = aCaseObj
 
565
 
 
566
    def setCurrentCase(self, aCase):
 
567
        self.CurrentCase = aCase
 
568
 
 
569
    # use before fill data
 
570
    def setCurrentStudy(self, theStudy):
 
571
        self.CurrentStudy = theStudy
 
572
#----------------------------------------------------------------------------------------------------------------------
 
573
 
 
574
class ECSConversionDialog(QtGui.QDialog,Ui_ECSConversionDialog):
 
575
    """
 
576
    Tree Location Dialog informations about environment variables
 
577
    """
 
578
    def __init__(self, parent = None):
 
579
        """
 
580
        """
 
581
        if Trace(): print 'ECSConversionDialog.__init__'
 
582
        QtGui.QDialog.__init__(self, parent)
 
583
        Ui_ECSConversionDialog.__init__(self,parent)
 
584
 
 
585
        self.setupUi(self)
 
586
 
 
587
class ECSConversionDialogHandler(ECSConversionDialog):
 
588
    """
 
589
    """
 
590
    def __init__(self, parent = None):
 
591
        """
 
592
        Constructor. Initialize text and label of the QDialog.
 
593
        """
 
594
        if Trace(): print 'ECSConversionDialogHandler.__init__'
 
595
        ECSConversionDialog.__init__(self, parent)
 
596
 
 
597
        self.ConvertBtn = self.findChild(QtGui.QPushButton,"ConvertBtn")
 
598
        self.ConvertBtn.setText(self.tr("ECSCONVERT_DLG_CONVERT_BUTTON"))
 
599
 
 
600
        aBtn = self.findChild(QtGui.QPushButton,"CancelBtn")
 
601
        aBtn.setText(self.tr("DLG_CANCEL_BUTTON_TEXT"))
 
602
 
 
603
        aBtnGroup = self.findChild(QtGui.QGroupBox,"OptionsGroup")
 
604
        aBtnGroup.setTitle(self.tr("ECSCONVERT_DLG_OPTIONS_TITLE"))
 
605
 
 
606
        self.VolOptBtn = self.VolOptButton
 
607
        self.VolOptBtn.setText(self.tr("ECSCONVERT_DLG_VOL_OPT_BTN_TEXT"))
 
608
        self.VolOptBtn.setChecked(True)
 
609
 
 
610
        self.BordOptBtn = self.BordOptButton
 
611
        self.BordOptBtn.setText(self.tr("ECSCONVERT_DLG_BORD_OPT_BTN_TEXT"))
 
612
 
 
613
        self.Color2GroupButton.setText(self.tr("ECSCONVERT_DLG_COLOR_OPT_BTN_TEXT"))
 
614
        self.Color2GroupButton.setChecked(True)
 
615
 
 
616
        aLabel = self.findChild(QtGui.QLabel,"CaseLabel")
 
617
        aLabel.hide()
 
618
 
 
619
        self.CaseCB = self.findChild(QtGui.QComboBox,"CaseCB")
 
620
        self.CaseCB.hide()
 
621
 
 
622
        self.ResultLabel = self.findChild(QtGui.QLabel,"ResultLabel")
 
623
        self.ResultLabel.setText(self.tr("ECSCONVERT_DLG_RESULT_LABEL_TEXT"))
 
624
 
 
625
        self.ResultName = self.findChild(QtGui.QLineEdit,"ResultNameLE")
 
626
 
 
627
        self.connect(self.ResultName, SIGNAL('textChanged(const QString&)'), self.slotResNameChanged)
 
628
 
 
629
        self.setWindowTitle(self.tr("ECSCONVERT_DLG_CAPTION"))
 
630
 
 
631
        self.adjustSize()
 
632
 
 
633
 
 
634
    def GetCaseName(self):
 
635
        return self.CaseCB.currentText()
 
636
 
 
637
 
 
638
    def IsVolOption(self):
 
639
        return self.VolOptBtn.isChecked()
 
640
 
 
641
 
 
642
    def IsBordOption(self):
 
643
        return self.BordOptBtn.isChecked()
 
644
 
 
645
 
 
646
    def IsColor2GroupOption(self):
 
647
        return self.Color2GroupButton.isChecked()
 
648
 
 
649
 
 
650
    def show(self):
 
651
        aStudy = CFDSTUDYGUI_DataModel.GetFirstStudy()
 
652
 
 
653
        self.CaseCB.clear()
 
654
 
 
655
        aCaseList = CFDSTUDYGUI_DataModel.GetCaseNameList(aStudy)
 
656
        if len(aCaseList) == 0:
 
657
            self.CaseCB.setEnabled(False)
 
658
            self.ConvertBtn.setEnabled(False)
 
659
        else:
 
660
            self.CaseCB.setEnabled(True)
 
661
            self.ConvertBtn.setEnabled(True)
 
662
            for i in aCaseList:
 
663
                self.CaseCB.insertItem(i)
 
664
 
 
665
        ECSConversionDialog.show(self)
 
666
 
 
667
    def resultFileName(self):
 
668
 
 
669
        aResName = str(self.ResultName.text().toLatin1())
 
670
        if re.match(".*\.med$", aResName) and len(aResName) > 4:
 
671
            aResName = aResName[0:len(aResName)-4]
 
672
 
 
673
        if Trace(): print "RESULT NAME is", aResName
 
674
        return aResName
 
675
 
 
676
 
 
677
    def setResultFileName(self, NewName):
 
678
        if NewName == None:
 
679
            self.ResultName.clear()
 
680
        else:
 
681
            self.ResultName.setText(NewName)
 
682
 
 
683
        self.slotResNameChanged()
 
684
 
 
685
 
 
686
    def slotResNameChanged(self):
 
687
        self.ConvertBtn.setEnabled(str(self.ResultName.text().toLatin1())!= '')
 
688
 
 
689
#----------------------------------------------------------------------------------------------------------------------
 
690
class CopyDialog(QtGui.QDialog,Ui_CopyDialog):
 
691
    """
 
692
    Dialog informations about environment variables
 
693
    """
 
694
    def __init__(self, parent = None):
 
695
        """
 
696
        """
 
697
        if Trace(): print 'CopyDialog.__init__'
 
698
        QtGui.QDialog.__init__(self, parent)
 
699
        Ui_CopyDialog.__init__(self,parent)
 
700
 
 
701
        self.setupUi(self)
 
702
 
 
703
class CopyDialogHandler(CopyDialog):
 
704
    """
 
705
    """
 
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"))
 
710
 
 
711
        aBtn = self.findChild(QtGui.QPushButton,"CancelBtn")
 
712
        aBtn.setText(self.tr("DLG_CANCEL_BUTTON_TEXT"))
 
713
 
 
714
        aLabel = self.findChild(QtGui.QLabel,"DestCaseLabel")
 
715
        aLabel.setText(self.tr("COPY_DLG_DEST_CASE_LABEL"))
 
716
 
 
717
        aLabel = self.findChild(QtGui.QLabel,"SourceCaseLabel")
 
718
        aLabel.setText(self.tr("COPY_DLG_SOURCE_CASE_LABEL"))
 
719
 
 
720
        aLabel = self.findChild(QtGui.QLabel,"FileNameLabel")
 
721
        aLabel.setText(self.tr("COPY_DLG_FILE_NAME_LABEL"))
 
722
 
 
723
        self.FileName = self.findChild(QtGui.QLabel,"FileName")
 
724
        self.SourceCaseName = self.findChild(QtGui.QLabel,"SourceCaseName")
 
725
        self.DestCaseCB = self.findChild(QtGui.QComboBox,"DestCaseCB")
 
726
 
 
727
        self.setWindowTitle(self.tr("COPY_DLG_CAPTION"))
 
728
 
 
729
 
 
730
    def show(self):
 
731
        aStudy = CFDSTUDYGUI_DataModel.GetFirstStudy()
 
732
 
 
733
        self.DestCaseCB.clear()
 
734
        if self.CopyBtn.isEnabled():
 
735
            aCaseList = CFDSTUDYGUI_DataModel.GetCaseNameList(aStudy)
 
736
 
 
737
            if len(aCaseList) == 0:
 
738
                self.DestCaseCB.setEnabled(False)
 
739
                self.CopyBtn.setEnabled(False)
 
740
            else:
 
741
                self.DestCaseCB.setEnabled(True)
 
742
                self.CopyBtn.setEnabled(True)
 
743
 
 
744
                sourceCase = str(self.SourceCaseName.text().toLatin1())
 
745
 
 
746
                for i in aCaseList:
 
747
                    if not i == sourceCase:
 
748
                        self.DestCaseCB.addItem(i)
 
749
 
 
750
        CopyDialog.exec_(self)
 
751
 
 
752
 
 
753
    def setCurrentObject(self, sobj):
 
754
        self.Object = 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())
 
759
 
 
760
            self.DestCaseCB.setEnabled(True)
 
761
            self.CopyBtn.setEnabled(True)
 
762
 
 
763
        else:
 
764
            self.FileName.setText("")
 
765
            self.SourceCaseName.SetText("")
 
766
            self.DestCaseCB.setEnabled(False)
 
767
            self.CopyBtn.setEnabled(False)
 
768
 
 
769
 
 
770
    def accept(self):
 
771
        aSourceFilePath = CFDSTUDYGUI_DataModel._GetPath(self.Object)
 
772
        aSourceCase = CFDSTUDYGUI_DataModel.GetCase(self.Object)
 
773
        aSourceCasePath = CFDSTUDYGUI_DataModel._GetPath(aSourceCase)
 
774
 
 
775
        aSourceCaseName = str(self.SourceCaseName.text().toLatin1())
 
776
        aDestCaseName = str(self.DestCaseCB.currentText().toLatin1())
 
777
 
 
778
        #check for existing of file in destinate CASE
 
779
        aDestCasePath = str(QString(aSourceCasePath).left(len(aSourceCasePath)-len(aSourceCaseName)).toLatin1())
 
780
        aDestCasePath += aDestCaseName
 
781
 
 
782
        aDestFilePath = aDestCasePath + str(QString(aSourceFilePath).right(len(aSourceFilePath)-len(aSourceCasePath)).toLatin1())
 
783
 
 
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)
 
786
            return False
 
787
 
 
788
        aCmd = "cp " + aSourceFilePath + " " + aDestFilePath
 
789
 
 
790
        status = os.system(aCmd)
 
791
        if not status == 0:
 
792
            QMessageBox.critical(self, self.tr("COPY_DLG_COPY_ERROR_CAPTION"), self.tr("COPY_DLG_COPY_ERROR_TEXT"), 1, 0)
 
793
            return False
 
794
 
 
795
        CopyDialog.accept(self)
 
796
 
 
797
 
 
798
    def destCaseName(self):
 
799
        return str(self.DestCaseCB.currentText().toLatin1())
 
800
 
 
801
 
 
802
#----------------------------------------------------------------------------------------------------------------------
 
803
 
 
804
 
 
805
class GUIActivationDialog(QtGui.QDialog,Ui_GUIActivationDialog):
 
806
    """
 
807
    Set environment variables Dialog informations
 
808
    """
 
809
    def __init__(self, parent = None):
 
810
        """
 
811
        """
 
812
        if Trace(): print 'GUIActivationDialog.__init__'
 
813
        QtGui.QDialog.__init__(self)
 
814
        Ui_GUIActivationDialog.__init__(self,parent)
 
815
        self.setupUi(self)
 
816
 
 
817
 
 
818
class GUIActivationDialogHandler(GUIActivationDialog):
 
819
    """
 
820
    """
 
821
    def __init__(self, parent = None):
 
822
 
 
823
        self.xmlfile = ""
 
824
        GUIActivationDialog.__init__(self, parent)
 
825
 
 
826
        self.ActivateBtn = self.findChild(QtGui.QPushButton,"ActivateBtn")
 
827
        self.ActivateBtn.setText(self.tr("GUIACTIVATE_DLG_ACTIVATE_BTN"))
 
828
 
 
829
        aBtn = self.findChild(QtGui.QPushButton,"CancelBtn")
 
830
        aBtn.setText(self.tr("DLG_CANCEL_BUTTON_TEXT"))
 
831
 
 
832
        self.CaseCB = self.findChild(QtGui.QComboBox,"CaseCB")
 
833
 
 
834
        aGB = self.findChild(QtGui.QGroupBox,"OptionsGB")
 
835
        aGB.setTitle(self.tr("GUIACTIVATE_DLG_OPTIONS_TITLE"))
 
836
 
 
837
        self.FileCheckBox = self.findChild(QtGui.QCheckBox,"FileCheckBox")
 
838
        self.FileCB = self.findChild(QtGui.QComboBox,"FileCB")
 
839
 
 
840
 
 
841
        self.LangCheckBox = self.findChild(QtGui.QCheckBox,"LangCheckBox")
 
842
        self.LangCB = self.findChild(QtGui.QComboBox,"LangCB")
 
843
        #sync
 
844
        self.LangCB.setEnabled(False)
 
845
 
 
846
        self.LangCheckBox.hide()
 
847
        self.LangCB.hide()
 
848
 
 
849
        self.connect(self.FileCheckBox, SIGNAL("clicked()"), self.slotUseXMLfileChange)
 
850
        self.connect(self.LangCheckBox, SIGNAL("clicked()"), self.slotUseLangChange)
 
851
 
 
852
        self.connect(self.CaseCB, SIGNAL("activated(int)"), self.slotUpdateData)
 
853
 
 
854
        self.adjustSize()
 
855
 
 
856
 
 
857
    def fillData(self, xmlFileName):
 
858
        """
 
859
        """
 
860
        if Trace(): print 'GUIActivationDialogHandler.fillData'
 
861
 
 
862
        self.disconnect(self.CaseCB, SIGNAL("activated(int)"), self.slotUpdateData)
 
863
        self.CaseCB.clear()
 
864
        self.xmlfile = xmlFileName
 
865
 
 
866
        for i in CFDSTUDYGUI_DataModel.GetCaseNameList(self.CurrentStudy):
 
867
            if self.CurrentCase and self.CurrentCase.GetName() == i:
 
868
                self.CaseCB.addItem(i)
 
869
 
 
870
        if self.xmlfile == "" :
 
871
            self.slotUpdateData()
 
872
        else:
 
873
            self.slotUpdateData()
 
874
 
 
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()
 
884
            self.LangCB.hide()
 
885
 
 
886
 
 
887
    def slotUpdateData(self):
 
888
        if Trace(): print 'GUIActivationDialogHandler.slotUpdateData'
 
889
 
 
890
        self.ActivateBtn.setEnabled(True)
 
891
        self.FileCB.clear()
 
892
 
 
893
        if self.CaseCB.currentText() == None:
 
894
            self.FileCheckBox.setEnabled(False)
 
895
            self.FileCB.setEnabled(False)
 
896
        else:
 
897
            self.FileCheckBox.setEnabled(True)
 
898
            self.FileCB.clear()
 
899
 
 
900
            # current case
 
901
            aCaseName = str(self.CaseCB.currentText().toLatin1())
 
902
            if Trace(): print "CaseName:", aCaseName
 
903
            if aCaseName == "":
 
904
                self.ActivateBtn.setEnabled(False)
 
905
                return
 
906
 
 
907
            aCase = None
 
908
            aCases =  CFDSTUDYGUI_DataModel.GetCaseList(self.CurrentStudy)
 
909
            for c in aCases:
 
910
                if c.GetName() == aCaseName:
 
911
                    aCase = c
 
912
                    break
 
913
 
 
914
            if aCase == None:
 
915
                self.ActivateBtn.setEnabled(False)
 
916
                return
 
917
 
 
918
            # object of DATA folder
 
919
            aChildList = CFDSTUDYGUI_DataModel.ScanChildren(aCase, "DATA")
 
920
            if not len(aChildList) == 1:
 
921
                self.ActivateBtn.setEnabled(False)
 
922
                return
 
923
            aDataObj =  aChildList[0]
 
924
 
 
925
            #fill File combo-box
 
926
            if self.xmlfile == "" :
 
927
                aFileList = CFDSTUDYGUI_DataModel.ScanChildNames(aDataObj, ".*\.xml$")
 
928
                if len(aFileList) == 0:
 
929
                    self.FileCheckBox.setEnabled(False);
 
930
 
 
931
                for i in aFileList:
 
932
                    self.FileCB.addItem(i)
 
933
 
 
934
                self.FileCB.setEnabled(self.FileCheckBox.isChecked())
 
935
            else :
 
936
                self.FileCB.addItem(self.xmlfile)
 
937
                self.FileCB.setEnabled(self.FileCheckBox.isChecked())
 
938
 
 
939
            #check for activation file SaturneGUI or NeptuneGUI
 
940
            if not CFDSTUDYGUI_DataModel.checkCaseLaunchGUI(aCase):
 
941
                #Warning message
 
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)
 
948
 
 
949
 
 
950
    # use before fill data
 
951
    def setCurrentCase(self, aCase):
 
952
        self.CurrentCase = aCase
 
953
 
 
954
 
 
955
    # use before fill data
 
956
    def setCurrentStudy(self, theStudy):
 
957
        self.CurrentStudy = theStudy
 
958
 
 
959
 
 
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)
 
966
            self.xmlfile = aFile
 
967
 
 
968
 
 
969
    def currentCaseName(self):
 
970
        if self.CaseCB.currentText() == 0:
 
971
            return None
 
972
 
 
973
        return str(self.CaseCB.currentText().toLatin1())
 
974
 
 
975
 
 
976
    def currentXMLfile(self):
 
977
        if not self.FileCB.isEnabled():
 
978
            return None
 
979
        return self.FileCB.currentText().toLatin1()
 
980
 
 
981
 
 
982
    def currentLanguage(self):
 
983
        return str(self.LangCB.currentText().toLatin1())
 
984
 
 
985
 
 
986
    def isUseXmlFile(self):
 
987
        return self.FileCheckBox.isChecked()
 
988
 
 
989
 
 
990
    def ifUseLangOption(self):
 
991
        return self.LangCheckBox.isChecked()
 
992
 
 
993
 
 
994
    def slotUseXMLfileChange(self):
 
995
        self.FileCB.setEnabled(self.FileCheckBox.isChecked())
 
996
 
 
997
 
 
998
    def slotUseLangChange(self):
 
999
        self.LangCB.setEnabled(self.LangCheckBox.isChecked())
 
1000
 
 
1001
 
 
1002
 
 
1003
class CFDSTUDYGUI_DialogCollector:
 
1004
    def __init__(self):
 
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()
 
1013
 
 
1014
def CFD_Code ():
 
1015
    return CFD_Saturne
 
1016
 
 
1017
if __name__ == "__main__":
 
1018
    app = QtGui.QApplication(sys.argv)
 
1019
    lang = "en"
 
1020
    qm = ["en","fr"]
 
1021
    if len(sys.argv) == 2:
 
1022
        lang = sys.argv[1]
 
1023
 
 
1024
    QM_FILE = "CFDSTUDY_msg_"+lang+".qm"
 
1025
    fi = QFileInfo(QM_FILE)
 
1026
 
 
1027
    if not fi.exists():
 
1028
        QMessageBox.warning(None, "File error",
 
1029
            "Cannot find translation for language: "+lang)
 
1030
    else:
 
1031
        translator = QTranslator()
 
1032
        translator.load(QM_FILE)
 
1033
        app.installTranslator(translator)
 
1034
    w = InfoDialogHandler()
 
1035
 
 
1036
    w.show()
 
1037
    sys.exit(app.exec_())