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

« back to all changes in this revision

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

  • Committer: Package Import Robot
  • Author(s): Sylvestre Ledru
  • Date: 2011-11-24 00:00:08 UTC
  • mfrom: (6.1.9 sid)
  • Revision ID: package-import@ubuntu.com-20111124000008-2vo99e38267942q5
Tags: 2.1.0-3
Install a missing file

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
Solver GUI
 
27
==========
 
28
 
 
29
The two solvers I{Code_Saturne} and C{NEPTUNE_CFD} have their own GUI. The
 
30
purpose of the class C{CFDSTUDYGUI_SolverGUI} is to display the solver GUI of
 
31
the selected code in the SALOME workspace.
 
32
"""
 
33
 
 
34
#-------------------------------------------------------------------------------
 
35
# Standard modules
 
36
#-------------------------------------------------------------------------------
 
37
 
 
38
import os, sys
 
39
import string
 
40
 
 
41
#-------------------------------------------------------------------------------
 
42
# Third-party modules
 
43
#-------------------------------------------------------------------------------
 
44
 
 
45
from PyQt4.QtGui import QApplication, QMainWindow, QDockWidget, QTreeView, QMessageBox
 
46
from PyQt4.QtCore import Qt, QObject, QEvent, SIGNAL, SLOT
 
47
 
 
48
#-------------------------------------------------------------------------------
 
49
# Salome modules
 
50
#-------------------------------------------------------------------------------
 
51
 
 
52
#-------------------------------------------------------------------------------
 
53
# Application modules
 
54
#-------------------------------------------------------------------------------
 
55
 
 
56
from CFDSTUDYGUI_Commons import CFD_Code, Trace, CFD_Saturne, CFD_Neptune, sgPyQt
 
57
from CFDSTUDYGUI_Commons import LogModeOn, LogModeOff, LoggingMgr, LoggingAgent
 
58
import CFDSTUDYGUI_DataModel
 
59
 
 
60
#-------------------------------------------------------------------------------
 
61
# Global definitions
 
62
#-------------------------------------------------------------------------------
 
63
 
 
64
_d_DockWindows = {}
 
65
_d_DockWindowsBrowser = {}
 
66
_d_DockWindowsRuncase = {}
 
67
 
 
68
_selectedMainViewCase = []
 
69
mw=None
 
70
 
 
71
_LoggingMgr = LoggingMgr()
 
72
 
 
73
#-------------------------------------------------------------------------------
 
74
# Function definitions
 
75
#-------------------------------------------------------------------------------
 
76
 
 
77
def getDockWindowsLists():
 
78
    """
 
79
    """
 
80
    studyId = sgPyQt.getStudyId()
 
81
    if studyId in _d_DockWindows.keys() and studyId in _d_DockWindowsBrowser.keys():
 
82
        return True #_d_DockWindows[studyId],_d_DockWindowsBrowser[studyId]
 
83
    else :
 
84
        return False
 
85
 
 
86
 
 
87
def tabObjectBrowser():
 
88
    """
 
89
    Regroupe en onglets les DockWidgets contenant des QTreeView:
 
90
    Object Browser et arbres CFDSTUDY
 
91
    """
 
92
    dsk = sgPyQt.getDesktop()
 
93
    ldock=dsk.findChildren(QDockWidget)
 
94
    ldocktree=[]
 
95
    for i in ldock:
 
96
        lo=i.findChildren(QTreeView)
 
97
        if len(lo):
 
98
            ldocktree.append(i)
 
99
    for i in range(1, len(ldocktree)):
 
100
        dsk.tabifyDockWidget(ldocktree[0], ldocktree[i])
 
101
 
 
102
 
 
103
def updateObjectBrowser():
 
104
    """
 
105
    force le regroupement en onglets des QTreeView apres updateObjBrowser
 
106
    """
 
107
    studyId = sgPyQt.getStudyId()
 
108
    sgPyQt.updateObjBrowser(studyId, 1)
 
109
    tabObjectBrowser()
 
110
 
 
111
 
 
112
def updateDockWindows() :
 
113
    """
 
114
    force le regroupement en onglets des fenetres d'etudes CFD
 
115
    """
 
116
    dsk = sgPyQt.getDesktop()
 
117
    studyId = sgPyQt.getStudyId()
 
118
 
 
119
    if not getDockWindowsLists():
 
120
        return
 
121
    if len(_d_DockWindows[studyId]) > 1:
 
122
        for i in range(1,len(_d_DockWindows[studyId])):
 
123
            dsk.tabifyDockWidget(_d_DockWindows[studyId][0], _d_DockWindows[studyId][i])
 
124
 
 
125
 
 
126
def updateDockWindowsBrowser() :
 
127
    """
 
128
    force le regroupement en onglets des fenetres Browser d'etudes CFD
 
129
    """
 
130
    dsk = sgPyQt.getDesktop()
 
131
    studyId = sgPyQt.getStudyId()
 
132
 
 
133
    if not getDockWindowsLists():
 
134
        return
 
135
    if len(_d_DockWindowsBrowser[studyId]) > 1 :
 
136
        for i in range(1,len(_d_DockWindowsBrowser[studyId])):
 
137
            dsk.tabifyDockWidget(_d_DockWindowsBrowser[studyId][0], _d_DockWindowsBrowser[studyId][i])
 
138
 
 
139
 
 
140
def findDockWindow(xmlName,caseName,studyCFDName) :
 
141
    """
 
142
    find if the dockwindow corresponding to this xmlcase is already opened
 
143
    """
 
144
    import string
 
145
    name = string.join([studyCFDName,caseName,xmlName],".")
 
146
    bool_findDockWindow = False
 
147
    dsk = sgPyQt.getDesktop()
 
148
    studyId = sgPyQt.getStudyId()
 
149
    ldockWindows =dsk.findChildren(QDockWidget)
 
150
    for dock in ldockWindows:
 
151
        dockTitle = dock.windowTitle()
 
152
        if studyId not in _d_DockWindowsBrowser.keys():
 
153
            _d_DockWindowsBrowser[studyId] = []
 
154
        if (str(dockTitle) == 'Object Browser') and (dock not in _d_DockWindowsBrowser[studyId]):
 
155
            _d_DockWindowsBrowser[studyId].append(dock)
 
156
        if studyId not in _d_DockWindows.keys():
 
157
            _d_DockWindows[studyId] = []
 
158
 
 
159
        if _d_DockWindows[studyId] != [] :
 
160
            for dock in _d_DockWindows[studyId] :
 
161
                if str(name) in str(dock.windowTitle()) :
 
162
                    bool_findDockWindow = True
 
163
                    dock.show()
 
164
                    dock.raise_()
 
165
 
 
166
    return bool_findDockWindow
 
167
 
 
168
 
 
169
def removeDockWindow(caseName) :
 
170
    """
 
171
    A TESTER
 
172
    remove the CFD_study_dock_windows from remove  popup menu in object browser
 
173
    """
 
174
    dsk = sgPyQt.getDesktop()
 
175
    studyId = sgPyQt.getStudyId()
 
176
    ldockWindows =dsk.findChildren(QDockWidget)
 
177
    for dock in ldockWindows:
 
178
        dockTitle = dock.windowTitle()
 
179
        if string.split(str(dockTitle),".")[0] == str(caseName):
 
180
            if "Browser" not in str(dockTitle) :
 
181
                _d_DockWindows[studyId].remove(dock)
 
182
                dsk.removeDockWidget(dock)
 
183
                dock.setParent(None)
 
184
            else :
 
185
                _d_DockWindowsBrowser[studyId].remove(dock)
 
186
                dsk.removeDockWidget(dock)
 
187
                dock.setParent(None)
 
188
        updateObjectBrowser()
 
189
 
 
190
 
 
191
#-------------------------------------------------------------------------------
 
192
# Classes definition
 
193
#-------------------------------------------------------------------------------
 
194
 
 
195
class CFDSTUDYGUI_SolverGUI(QObject):
 
196
    """
 
197
    Auxilliary class for interaction with solvers GUI
 
198
    """
 
199
    def __init__(self):
 
200
        if Trace() : print "CFDSTUDY_SolverGUI.__init__ : "
 
201
        QObject.__init__(self, None)
 
202
        self._WindowsMap = {}
 
203
        self._CurrentWindow = None
 
204
        _d_DockWindows = {}
 
205
        _d_DockWindowsBrowser = {}
 
206
 
 
207
    def ExecGUI(self, WorkSpace, aTitle, aCase, Args=''):
 
208
        """
 
209
        Executes GUI for solver relatively CFDCode
 
210
        """
 
211
        if Trace() : print "CFDSTUDY_SolverGUI.ExecGUI : "
 
212
        mw = None
 
213
        if aTitle != None and aTitle != "":
 
214
            #searching in existing tabs
 
215
            win = self._findWindow(aTitle,aCase)
 
216
            if win != None:
 
217
                #need for activation
 
218
                QApplication.postEvent(win, QEvent(QEvent.FocusIn))
 
219
                return win
 
220
        else:
 
221
            aTitle = "unnamed"
 
222
            if findDockWindow(aTitle,aCase.GetName(),aCase.GetFather().GetName()) :
 
223
                mess = "A case is not finished to be set"
 
224
                QMessageBox.warning(None, "Warning : ",mess)
 
225
                return
 
226
 
 
227
        if aCase != None:
 
228
            if CFD_Code() == CFD_Saturne:
 
229
                # object of DATA folder
 
230
                aChildList = CFDSTUDYGUI_DataModel.ScanChildren(aCase, "^DATA$")
 
231
                if not len(aChildList)== 1:
 
232
                    # no DATA folder
 
233
                    if Trace(): print "CFDSTUDYGUI_SolverGUI.ExecGUI :There are not data folder in selected by user case"
 
234
                    return None
 
235
                aStartPath = CFDSTUDYGUI_DataModel._GetPath(aChildList[0])
 
236
            elif CFD_Code() == CFD_Neptune:
 
237
                aStartPath = CFDSTUDYGUI_DataModel._GetPath(aCase)
 
238
            if aStartPath != None and aStartPath != '':
 
239
                os.chdir(aStartPath)
 
240
        if CFD_Code() == CFD_Saturne:
 
241
            mw = self._ExecICS(WorkSpace, aCase, aTitle, Args)
 
242
        elif CFD_Code() == CFD_Neptune:
 
243
            mw = self._ExecIPB(WorkSpace, aTitle, Args)
 
244
        if mw != None:
 
245
            self._WindowsMap[mw] = aCase
 
246
            self._CurrentWindow = mw
 
247
            _selectedMainViewCase.append(mw)
 
248
        return mw
 
249
 
 
250
 
 
251
    def eventFilter(self, anObject, anEvent):
 
252
        if Trace() : print "CFDSTUDY_SolverGUI.eventFilter : "
 
253
        if anEvent.type() == QEvent.Close:
 
254
            del self._WindowsMap[anObject]
 
255
        elif anEvent.type() == QEvent.Hide:
 
256
            if self._CurrentWindow == anObject:
 
257
                self._CurrentWindow = None
 
258
        elif anEvent.type() == QEvent.Show:
 
259
            self._CurrentWindow = anObject
 
260
        return False
 
261
 
 
262
 
 
263
    def isActive(self):
 
264
        return self._CurrentWindow != None
 
265
 
 
266
 
 
267
    def onSaveXmlFile(self):
 
268
        if Trace() : print "CFDSTUDY_SolverGUI.onSaveXmlFile : "
 
269
        if self._CurrentWindow != None:
 
270
            if CFD_Code() == CFD_Saturne:
 
271
                self._CurrentWindow.fileSave()
 
272
 
 
273
    def onSaveAsXmlFile(self):
 
274
        """
 
275
        """
 
276
        old_xml_file = None
 
277
        xml_file = None
 
278
        if  len(_selectedMainViewCase) != 0:
 
279
            _sMainViewCase = self._CurrentWindow
 
280
            if CFD_Code() == CFD_Saturne:
 
281
                old_xml_file = _sMainViewCase.case['xmlfile']
 
282
                _sMainViewCase.fileSaveAs()
 
283
                xml_file = _sMainViewCase.case['xmlfile']
 
284
            if xml_file != None and xml_file != "" and xml_file != old_xml_file:
 
285
                #need update object browser
 
286
                case = self._WindowsMap[_sMainViewCase]
 
287
                study = CFDSTUDYGUI_DataModel.GetStudyByObj(case)
 
288
 
 
289
                obj = CFDSTUDYGUI_DataModel.checkPathUnderObject(study, xml_file)
 
290
                if obj:
 
291
                    #changes Title of the tab
 
292
                    new_title = os.path.basename(xml_file)
 
293
                    _sMainViewCase.setWindowTitle(new_title)
 
294
 
 
295
                    #updates Object Browser
 
296
                    CFDSTUDYGUI_DataModel._RebuildTreeRecursively(obj)
 
297
                    #if os.path.exists(old_xml_file) and os.path.exists(xml_file) :
 
298
                    if os.path.exists(xml_file) :
 
299
                        self.replaceDockTitleName(xml_file,old_xml_file,case,study)
 
300
 
 
301
                    updateObjectBrowser()
 
302
 
 
303
 
 
304
    def getDockTitleName(self,xml_file) :
 
305
        """
 
306
        Build the Dock Title Name STUDY.CASE.file.xml with the entire file Name
 
307
        """
 
308
        lnames = string.split(xml_file,"/")
 
309
        if len(lnames) < 4 : return None
 
310
        xmlname   = lnames[-1]
 
311
        casename  = lnames[-3]
 
312
        studyname = lnames[-4]
 
313
        return string.join([studyname,casename,xmlname],".")
 
314
 
 
315
 
 
316
    def replaceDockTitleName(self,new_xml_file,old_xml_file,case,study) :
 
317
        """
 
318
        replace dock title name in the title of the dock widget and update
 
319
        the _d_DockWindows and _d_DockWindowsBrowser dictionary
 
320
        """
 
321
        OldDockTitleName = self.getDockTitleName(old_xml_file)
 
322
        NewDockTitleName = self.getDockTitleName(new_xml_file)
 
323
 
 
324
        if NewDockTitleName == None :
 
325
            mess = "File : "+xml_file+ \
 
326
                   " is not stored into a CFDSTUDY directory structure like .../STUDY_CFD/CASE/DATA/filename.xml"
 
327
            QMessageBox.warning(None, "File Error : ",mess)
 
328
            return
 
329
        if OldDockTitleName == None :
 
330
            studyname = study.GetName()
 
331
            casename  = case.GetName()
 
332
            xmlname = "unnamed"
 
333
            OldDockTitleName = string.join([studyname,casename,xmlname],".")
 
334
        if NewDockTitleName != None :
 
335
            studyId = sgPyQt.getStudyId()
 
336
            if studyId in _d_DockWindows.keys():
 
337
                for dock in _d_DockWindows[studyId]:
 
338
                    if str(OldDockTitleName) in str(dock.windowTitle()) :
 
339
                        dock.setWindowTitle(str(NewDockTitleName))
 
340
                        dock.show()
 
341
                        dock.raise_()
 
342
            if studyId in _d_DockWindowsBrowser.keys():
 
343
                for dock in _d_DockWindowsBrowser[studyId]:
 
344
                    if str(OldDockTitleName) in str(dock.windowTitle()) :
 
345
                        dock.setWindowTitle(string.join([str(NewDockTitleName),"Browser"]))
 
346
                        dock.show()
 
347
                        dock.raise_()
 
348
        return
 
349
 
 
350
 
 
351
    def onOpenShell(self):
 
352
        """
 
353
        """
 
354
        if Trace() : print "CFDSTUDY_SolverGUI.onOpenShell : "
 
355
        if self._CurrentWindow != None :
 
356
            if CFD_Code() == CFD_Saturne:
 
357
                self._CurrentWindow.openXterm()
 
358
 
 
359
 
 
360
    def onDisplayCase(self):
 
361
        if Trace() : print "CFDSTUDY_SolverGUI.onDisplayCase : "
 
362
        _LoggingMgr.start(sys)
 
363
        if self._CurrentWindow != None:
 
364
 
 
365
            if CFD_Code() == CFD_Saturne:
 
366
                self._CurrentWindow.displayCase()
 
367
        _LoggingMgr.finish(sys)
 
368
 
 
369
    def onHelpAbout(self):
 
370
        if Trace() : print "CFDSTUDY_SolverGUI.onHelpAbout : "
 
371
        if self._CurrentWindow != None:
 
372
           if CFD_Code() == CFD_Saturne:
 
373
                self._CurrentWindow.displayAbout()
 
374
 
 
375
#-----------------------------------------------------------------------------
 
376
 
 
377
    def onSaturneReloadModule(self):
 
378
        """
 
379
        """
 
380
        if Trace() : print "CFDSTUDY_SolverGUI.onSaturneReloadModule: "
 
381
        if self._CurrentWindow != None :
 
382
            if CFD_Code() == CFD_Saturne:
 
383
                self._CurrentWindow.reload_modules()
 
384
        return
 
385
 
 
386
    def onSaturneReloadPage(self):
 
387
        """
 
388
        """
 
389
        if Trace() : print "CFDSTUDY_SolverGUI.onSaturneReloadPage: "
 
390
        if self._CurrentWindow != None :
 
391
            if CFD_Code() == CFD_Saturne:
 
392
                self._CurrentWindow.reload_page()
 
393
        return
 
394
 
 
395
    def onSaturneHelpLicense(self):
 
396
        """
 
397
        """
 
398
        if Trace() : print "CFDSTUDY_SolverGUI.onSaturneHelpLicense: "
 
399
        if self._CurrentWindow != None :
 
400
            if CFD_Code() == CFD_Saturne:
 
401
                self._CurrentWindow.displayLicence()
 
402
        return
 
403
 
 
404
    def onSaturneHelpCS(self):
 
405
        """
 
406
        """
 
407
        if Trace() : print "CFDSTUDY_SolverGUI.onSaturneHelpcs: "
 
408
        if self._CurrentWindow != None :
 
409
            if CFD_Code() == CFD_Saturne:
 
410
                self._CurrentWindow.displayCSManual()
 
411
        return
 
412
 
 
413
    def onSaturneHelpSD(self):
 
414
        """
 
415
        """
 
416
        if Trace() : print "CFDSTUDY_SolverGUI.onSaturneHelpSD: "
 
417
        if self._CurrentWindow != None :
 
418
            if CFD_Code() == CFD_Saturne:
 
419
                self._CurrentWindow.displayECSManual()
 
420
        return
 
421
 
 
422
 
 
423
    def onSaturneHelpCS_Kernel(self):
 
424
        """
 
425
        """
 
426
        if Trace() : print "CFDSTUDY_SolverGUI.onSaturneHelpCS_Kernel : "
 
427
        if self._CurrentWindow != None :
 
428
            if CFD_Code() == CFD_Saturne:
 
429
                self._CurrentWindow.displayCSKernel()
 
430
 
 
431
        return
 
432
 
 
433
 
 
434
    def onSaturneHelpCS_Infos(self):
 
435
        """
 
436
        """
 
437
        if Trace() : print "CFDSTUDYGUI_SolverGUI.onSaturneHelpCS_INFOS : "
 
438
        if self._CurrentWindow != None :
 
439
            if CFD_Code() == CFD_Saturne:
 
440
                self._CurrentWindow.displayECSInfos()
 
441
 
 
442
        return
 
443
 
 
444
 
 
445
    def onNeptuneWinBrowser(self, flag):
 
446
        if self._CurrentWindow != None:
 
447
            if CFD_Code() == CFD_Neptune:
 
448
                self._CurrentWindow.browserDockDisplay(flag)
 
449
 
 
450
 
 
451
    def onNeptuneWinIdenty(self,flag):
 
452
        if self._CurrentWindow != None:
 
453
            if CFD_Code() == CFD_Neptune:
 
454
                self._CurrentWindow.identityDockDisplay(flag)
 
455
 
 
456
 
 
457
    def _ExecIPB(self, WorkSpace, Title, Args):
 
458
        """
 
459
        A developper
 
460
        """
 
461
        pass
 
462
 
 
463
 
 
464
    def _ExecICS(self, WorkSpace, aCase, Title, Args):
 
465
        """
 
466
        """
 
467
        from Base.MainView import MainView
 
468
        from cs_gui import process_cmd_line
 
469
 
 
470
        self.Workspace = WorkSpace
 
471
        case, splash, batch_window, batch_file, tree_window, read_only = process_cmd_line(Args)
 
472
 
 
473
        mw = MainView(case, batch_window, batch_file, tree_window, read_only, aCase)
 
474
        fatherName = aCase.GetFather().GetName()
 
475
 
 
476
        aTitle = str(fatherName + "." + aCase.GetName()) + '.' + str(Title)
 
477
        mw.setWindowTitle(aTitle)
 
478
 
 
479
        dsk = sgPyQt.getDesktop()
 
480
        dock = QDockWidget(aTitle)
 
481
 
 
482
        dock.setWidget(mw.frame)
 
483
        dock.setMinimumWidth(520)
 
484
        dsk.addDockWidget(Qt.RightDockWidgetArea, dock)
 
485
 
 
486
        studyId = sgPyQt.getStudyId()
 
487
 
 
488
        if studyId not in _d_DockWindows.keys():
 
489
            _d_DockWindows[studyId] = []
 
490
        _d_DockWindows[studyId].append(dock)
 
491
 
 
492
        dock.setVisible(True)
 
493
        dock.show()
 
494
        updateDockWindows()
 
495
 
 
496
        BrowserTitle = aTitle  + " Browser"
 
497
        mw.dockWidgetBrowser.setWindowTitle(BrowserTitle)
 
498
        dsk.addDockWidget(Qt.LeftDockWidgetArea,mw.dockWidgetBrowser)
 
499
 
 
500
        if studyId not in _d_DockWindowsBrowser.keys():
 
501
            _d_DockWindowsBrowser[studyId] = []
 
502
        _d_DockWindowsBrowser[studyId].append(mw.dockWidgetBrowser)
 
503
 
 
504
        mw.dockWidgetBrowser.setVisible(True)
 
505
        mw.dockWidgetBrowser.show()
 
506
        mw.dockWidgetBrowser.raise_()
 
507
        dock.raise_()
 
508
 
 
509
        self.connect(dock, SIGNAL("visibilityChanged(bool)"), self.setdockWindowBrowserActivated)
 
510
        self.connect(mw.dockWidgetBrowser, SIGNAL("visibilityChanged(bool)"),self.setdockWindowActivated)
 
511
 
 
512
        updateDockWindowsBrowser()
 
513
        updateObjectBrowser()
 
514
        return mw
 
515
 
 
516
 
 
517
    def _findWindow(self, aTitle, aCase):
 
518
 
 
519
        if aTitle == '' or aCase == None:
 
520
            return None
 
521
 
 
522
        for win in self._WindowsMap.keys():
 
523
            if aTitle == str(win.windowTitle().toLatin1()) and \
 
524
                       aCase.GetID() == self._WindowsMap[win].GetID():
 
525
                return win
 
526
 
 
527
        return None
 
528
 
 
529
 
 
530
    def setdockWindowBrowserActivated(self,visible) :
 
531
 
 
532
        if not visible : return
 
533
        dock = self.sender()
 
534
        if dock.isActiveWindow() == False : return
 
535
        titledock = str(dock.windowTitle())
 
536
        studyId = sgPyQt.getStudyId()
 
537
        if studyId not in _d_DockWindowsBrowser.keys():
 
538
            return
 
539
        for i in range(len(_d_DockWindowsBrowser[studyId])):
 
540
            if titledock in str(_d_DockWindowsBrowser[studyId][i].windowTitle()):
 
541
                _d_DockWindowsBrowser[studyId][i].activateWindow()
 
542
                _d_DockWindowsBrowser[studyId][i].setVisible(True)
 
543
                _d_DockWindowsBrowser[studyId][i].show()
 
544
                _d_DockWindowsBrowser[studyId][i].raise_()
 
545
                self.activateCurrentWindow(titledock)
 
546
 
 
547
 
 
548
    def setdockWindowActivated(self,visible) :
 
549
 
 
550
        if not visible : return
 
551
        dock = self.sender()
 
552
        if dock.isActiveWindow() == False : return
 
553
        title = str(dock.windowTitle())
 
554
        titledock,br = string.split(title," Browser")
 
555
        studyId = sgPyQt.getStudyId()
 
556
        if studyId not in _d_DockWindowsBrowser.keys():
 
557
            return
 
558
        for i in range(len(_d_DockWindows[studyId])):
 
559
            if str(_d_DockWindows[studyId][i].windowTitle()) in str(title):
 
560
                _d_DockWindows[studyId][i].activateWindow()
 
561
                _d_DockWindows[studyId][i].setVisible(True)
 
562
                _d_DockWindows[studyId][i].show()
 
563
                _d_DockWindows[studyId][i].raise_()
 
564
                self.activateCurrentWindow(titledock)
 
565
 
 
566
 
 
567
    def activateCurrentWindow(self,title) :
 
568
        """
 
569
        """
 
570
        for mw in self._WindowsMap.keys() :
 
571
            casename = mw.case['salome'].GetName()
 
572
            xmlfile = mw.case['xmlfile']
 
573
            if xmlfile == "" or xmlfile == None :
 
574
                xmlfileName = "unnamed"
 
575
            else :
 
576
                xmlfileName = os.path.basename(xmlfile)
 
577
            fatherCaseName = mw.case['salome'].GetFather().GetName()
 
578
            if title == string.join([fatherCaseName,casename,xmlfileName],".") :
 
579
                self._CurrentWindow = mw
 
580
                if mw not in _selectedMainViewCase :
 
581
                    _selectedMainViewCase.append(mw)
 
582
                mw.activateWindow()
 
583
 
 
584
 
 
585
    def disconnectDockWindows(self) :
 
586
        """
 
587
        Hide the dock windows of CFDSTUDY GUI, when activating another Salome Component
 
588
        We can have one or several of them with the right click on the main menu bar of
 
589
        Salome
 
590
        """
 
591
        studyId = sgPyQt.getStudyId()
 
592
        if studyId not in _d_DockWindowsBrowser.keys():
 
593
            return
 
594
        if studyId not in _d_DockWindows.keys():
 
595
            return
 
596
 
 
597
        if len(_d_DockWindows[studyId]) != 0 :
 
598
            for dock in _d_DockWindows[studyId]:
 
599
                dock.hide()
 
600
 
 
601
        if len(_d_DockWindowsBrowser[studyId]) != 0 :
 
602
            for dock in _d_DockWindowsBrowser[studyId]:
 
603
                if dock.windowTitle() != 'Object Browser':
 
604
                    dock.hide()
 
605
        if studyId not in _d_DockWindowsRuncase.keys():
 
606
            return
 
607
        if len(_d_DockWindowsRuncase[studyId]) != 0:
 
608
            for dock in _d_DockWindowsRuncase[studyId]:
 
609
                dock.hide()
 
610
 
 
611
 
 
612
    def connectDockWindows(self) :
 
613
        """
 
614
        Show all the dock windows of CFDSTUDY GUI, when activating another Salome Component
 
615
        visualise les dock windows  lors d'un changement de composant
 
616
        """
 
617
        studyId = sgPyQt.getStudyId()
 
618
        if studyId not in _d_DockWindowsBrowser.keys():
 
619
            return
 
620
        if studyId not in _d_DockWindows.keys():
 
621
            return
 
622
 
 
623
        if len(_d_DockWindows[studyId]) != 0:
 
624
            for dock in _d_DockWindows[studyId]:
 
625
                dock.show()
 
626
                dock.setVisible(True)
 
627
 
 
628
        if len(_d_DockWindowsBrowser[studyId]) != 0:
 
629
            for dock in _d_DockWindowsBrowser[studyId]:
 
630
                dock.show()
 
631
                dock.setVisible(True)
 
632
 
 
633
        if studyId not in _d_DockWindowsRuncase.keys():
 
634
            return
 
635
        if len(_d_DockWindowsRuncase[studyId]) != 0:
 
636
            for dock in _d_DockWindowsRuncase[studyId]:
 
637
                dock.show()
 
638
                dock.setVisible(True)