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
Desktop represents a main frame (QMainWindow) of a SALOME application.
30
It contains a menu bar, tool bars, and central area for GUI controls of
31
components: Object Browser, Python console, 3D/2D viewers, etc.
34
#-------------------------------------------------------------------------------
36
#-------------------------------------------------------------------------------
38
#-------------------------------------------------------------------------------
40
#-------------------------------------------------------------------------------
42
from PyQt4.QtCore import QObject, SIGNAL
44
#-------------------------------------------------------------------------------
46
#-------------------------------------------------------------------------------
49
#-------------------------------------------------------------------------------
51
#-------------------------------------------------------------------------------
53
from CFDSTUDYGUI_Commons import CFD_Code, Trace, CFD_Saturne, CFD_Neptune, sgPyQt, sg
54
from CFDSTUDYGUI_ActionsHandler import CFDSTUDYGUI_ActionsHandler
55
from CFDSTUDYGUI_ProcessMgr import CFDSTUDYGUI_ProcessMgr
56
from CFDSTUDYGUI_Agents import *
58
#-------------------------------------------------------------------------------
60
#-------------------------------------------------------------------------------
62
class CFDSTUDYGUI_DesktopMgr(QObject):
64
Auxilliary class for GUI management amoung opened SALOME studies.
65
It helps to destroy objects with corresponding Desktop.
71
QObject.__init__(self, None)
72
self._ActionHandlerMap = {}
75
def slotDeleteDsk(self):
77
Destroys objects with corresponding Desktop.
80
if Trace(): print "CFDSTUDYGUI_DesktopMgr::slotDeleteDsk() ", dsk
81
if dsk in self._ActionHandlerMap:
82
del self._ActionHandlerMap[dsk]
85
def getActionHandler(self, dsk):
87
Returns existing or creates new ActionHandler associated to a dekstop.
89
@type dsk: C{QMainWindow}
90
@param dsk: main window of a SALOME application
91
@return: ActionHandler associated to the current SALOME study.
92
@rtype: C{CFDSTUDYGUI_ActionsHandler}
94
if not dsk in self._ActionHandlerMap:
95
ah = CFDSTUDYGUI_ActionsHandler()
97
self._ActionHandlerMap[dsk] = ah
98
self.connect(dsk, SIGNAL("destroyed(QObject*)"), self.slotDeleteDsk)
100
return self._ActionHandlerMap[dsk]
103
def getProcessMgr(self, dsk):
105
Returns existing or creates new Process Manager. Usefull for the CFD code ruuning.
107
@type dsk: C{QMainWindow}
108
@param dsk: main window of a SALOME application
109
@return: Process Manager.
110
@rtype: C{CFDSTUDYGUI_ProcessMgr}
112
ah = self.getActionHandler(dsk)
113
return ah.processMgr()
116
def setWorkspace(self, dsk, ws):
118
Stores a workspace I{ws} to an associated desktop I{dsk}.
120
@type dsk: C{QMainWindow}
121
@param dsk: main window of a SALOME application.
123
@param ws: workspace.
125
ah = self.getActionHandler(dsk)
126
ah.dskAgent().setWorkspace(ws)
127
#updates in ProcessMgr automatically