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

« back to all changes in this revision

Viewing changes to salome/cfd_study/src/CFDSTUDYGUI/CFDSTUDYGUI_DesktopMgr.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
Desktop Manager
 
27
===============
 
28
 
 
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.
 
32
"""
 
33
 
 
34
#-------------------------------------------------------------------------------
 
35
# Standard modules
 
36
#-------------------------------------------------------------------------------
 
37
 
 
38
#-------------------------------------------------------------------------------
 
39
# Third-party modules
 
40
#-------------------------------------------------------------------------------
 
41
 
 
42
from PyQt4.QtCore import QObject, SIGNAL
 
43
 
 
44
#-------------------------------------------------------------------------------
 
45
# Salome modules
 
46
#-------------------------------------------------------------------------------
 
47
 
 
48
 
 
49
#-------------------------------------------------------------------------------
 
50
# Application modules
 
51
#-------------------------------------------------------------------------------
 
52
 
 
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 *
 
57
 
 
58
#-------------------------------------------------------------------------------
 
59
# Classes definition
 
60
#-------------------------------------------------------------------------------
 
61
 
 
62
class CFDSTUDYGUI_DesktopMgr(QObject):
 
63
    """
 
64
    Auxilliary class for GUI management amoung opened SALOME studies.
 
65
    It helps to destroy objects with corresponding Desktop.
 
66
    """
 
67
    def __init__(self):
 
68
        """
 
69
        Constructor.
 
70
        """
 
71
        QObject.__init__(self, None)
 
72
        self._ActionHandlerMap = {}
 
73
 
 
74
 
 
75
    def slotDeleteDsk(self):
 
76
        """
 
77
        Destroys objects with corresponding Desktop.
 
78
        """
 
79
        dsk = self.sender()
 
80
        if Trace(): print "CFDSTUDYGUI_DesktopMgr::slotDeleteDsk() ", dsk
 
81
        if dsk in self._ActionHandlerMap:
 
82
            del self._ActionHandlerMap[dsk]
 
83
 
 
84
 
 
85
    def getActionHandler(self, dsk):
 
86
        """
 
87
        Returns existing or creates new ActionHandler associated to a dekstop.
 
88
 
 
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}
 
93
        """
 
94
        if not dsk in self._ActionHandlerMap:
 
95
            ah = CFDSTUDYGUI_ActionsHandler()
 
96
            ah.createActions()
 
97
            self._ActionHandlerMap[dsk] = ah
 
98
            self.connect(dsk, SIGNAL("destroyed(QObject*)"), self.slotDeleteDsk)
 
99
 
 
100
        return self._ActionHandlerMap[dsk]
 
101
 
 
102
 
 
103
    def getProcessMgr(self, dsk):
 
104
        """
 
105
        Returns existing or creates new Process Manager. Usefull for the CFD code ruuning.
 
106
 
 
107
        @type dsk: C{QMainWindow}
 
108
        @param dsk: main window of a SALOME application
 
109
        @return: Process Manager.
 
110
        @rtype: C{CFDSTUDYGUI_ProcessMgr}
 
111
        """
 
112
        ah = self.getActionHandler(dsk)
 
113
        return ah.processMgr()
 
114
 
 
115
 
 
116
    def setWorkspace(self, dsk, ws):
 
117
        """
 
118
        Stores a workspace I{ws} to an associated desktop I{dsk}.
 
119
 
 
120
        @type dsk: C{QMainWindow}
 
121
        @param dsk: main window of a SALOME application.
 
122
        @type ws: C{QWidget}
 
123
        @param ws: workspace.
 
124
        """
 
125
        ah = self.getActionHandler(dsk)
 
126
        ah.dskAgent().setWorkspace(ws)
 
127
        #updates in ProcessMgr automatically