Salome HOME
PAL9391
[modules/smesh.git] / src / SMESHGUI / SMESHGUI_Utils.h
1 //  Copyright (C) 2003  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
2 //  CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
3 //
4 //  This library is free software; you can redistribute it and/or
5 //  modify it under the terms of the GNU Lesser General Public
6 //  License as published by the Free Software Foundation; either
7 //  version 2.1 of the License.
8 //
9 //  This library is distributed in the hope that it will be useful,
10 //  but WITHOUT ANY WARRANTY; without even the implied warranty of
11 //  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12 //  Lesser General Public License for more details.
13 //
14 //  You should have received a copy of the GNU Lesser General Public
15 //  License along with this library; if not, write to the Free Software
16 //  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
17 //
18 //  See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
19
20 #ifndef SMESHGUI_Utils_HeaderFile
21 #define SMESHGUI_Utils_HeaderFile
22
23 #include <CORBA.h>
24
25 #include "SALOMEDSClient_definitions.hxx"
26 #include "SALOME_InteractiveObject.hxx"
27 #include "SalomeApp_DataOwner.h"
28
29 class QString;
30
31 class SUIT_ViewWindow;
32 class SUIT_Desktop;
33 class SUIT_Study;
34 class SUIT_ResourceMgr;
35
36 class CAM_Module;
37
38 class SALOMEDSClient_Study;
39 class SALOMEDSClient_SObject;
40
41 class SalomeApp_Study;
42 class SalomeApp_Module;
43 class SalomeApp_SelectionMgr;
44
45 namespace SMESH {
46
47   SUIT_Desktop*
48   GetDesktop(const CAM_Module* theModule);
49
50   SalomeApp_SelectionMgr*
51   GetSelectionMgr(const SalomeApp_Module* theModule);
52
53   SalomeApp_Study*
54   GetAppStudy(const CAM_Module* theModule);
55
56   SUIT_ResourceMgr*
57   GetResourceMgr( const SalomeApp_Module* );
58   
59   _PTR(Study)
60   GetCStudy(const SalomeApp_Study* theStudy);
61
62   CORBA::Object_var DataOwnerToObject(const SalomeApp_DataOwnerPtr& theOwner);
63
64   template<class TInterface> typename TInterface::_var_type
65     DataOwnerToInterface(const SalomeApp_DataOwnerPtr& theDataOwner)
66     {
67       CORBA::Object_var anObj = DataOwnerToObject(theDataOwner);
68       if(!CORBA::is_nil(anObj))
69         return TInterface::_narrow(anObj);
70       return TInterface::_nil();
71     }
72
73
74   SUIT_Study* GetActiveStudy();
75
76   SUIT_ViewWindow* GetActiveWindow();
77
78   _PTR(Study) GetActiveStudyDocument();
79
80   _PTR(SObject) FindSObject(CORBA::Object_ptr theObject);
81
82   void SetName  (_PTR(SObject) theSObject, const char* theName);
83   void SetValue (_PTR(SObject) theSObject, const char* theValue);
84
85   CORBA::Object_var SObjectToObject (_PTR(SObject) theSObject,
86                                      _PTR(Study) theStudy);
87
88   CORBA::Object_var SObjectToObject(_PTR(SObject) theSObject);
89
90   template<class TInterface> typename TInterface::_var_type
91     SObjectToInterface(_PTR(SObject) theSObject)
92     {
93       CORBA::Object_var anObj = SObjectToObject(theSObject);
94       if(!CORBA::is_nil(anObj))
95         return TInterface::_narrow(anObj);
96       return TInterface::_nil();
97     }
98
99   CORBA::Object_var IObjectToObject(const Handle(SALOME_InteractiveObject)& theIO);
100
101   template<class TInterface> typename TInterface::_var_type
102     IObjectToInterface(const Handle(SALOME_InteractiveObject)& theIO)
103     {
104       CORBA::Object_var anObj = IObjectToObject(theIO);
105       if(!CORBA::is_nil(anObj))
106         return TInterface::_narrow(anObj);
107       return TInterface::_nil();
108     }
109
110   CORBA::Object_var IORToObject(const char* theIOR);
111
112   template<class TInterface> typename TInterface::_var_type
113     IORToInterface(const char* theIOR)
114     {
115       CORBA::Object_var anObj = IORToObject(theIOR);
116       if(!CORBA::is_nil(anObj))
117         return TInterface::_narrow(anObj);
118       return TInterface::_nil();
119     }
120
121   int GetNameOfSelectedIObjects (SalomeApp_SelectionMgr*, QString& theName);
122
123   _PTR(SObject) GetMeshOrSubmesh (_PTR(SObject) theSObject);
124
125   void ModifiedMesh (_PTR(SObject) theSObject, bool theIsRight);
126
127 //  void UpdateObjBrowser (bool);
128 }
129
130 #endif