Salome HOME
Merging with WPdev
[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.salome-platform.org/ or email : webmaster.salome@opencascade.com
19
20 #ifndef SMESHGUI_Utils_HeaderFile
21 #define SMESHGUI_Utils_HeaderFile
22
23 #include "SMESH_SMESHGUI.hxx"
24
25 #include <omniORB4/CORBA.h>
26
27 #include "SALOMEDSClient_definitions.hxx"
28 #include "SALOME_InteractiveObject.hxx"
29 #include "LightApp_DataOwner.h"
30
31 class QString;
32
33 class SUIT_ViewWindow;
34 class SUIT_Desktop;
35 class SUIT_Study;
36 class SUIT_ResourceMgr;
37
38 class CAM_Module;
39
40 class SALOMEDSClient_Study;
41 class SALOMEDSClient_SObject;
42
43 class SalomeApp_Study;
44 class SalomeApp_Module;
45 class LightApp_SelectionMgr;
46
47 namespace SMESH {
48
49 SMESHGUI_EXPORT
50   SUIT_Desktop*
51   GetDesktop(const CAM_Module* theModule);
52
53 SMESHGUI_EXPORT
54   LightApp_SelectionMgr*
55   GetSelectionMgr(const SalomeApp_Module* theModule);
56
57 SMESHGUI_EXPORT
58   SalomeApp_Study*
59   GetAppStudy(const CAM_Module* theModule);
60
61 SMESHGUI_EXPORT
62   SUIT_ResourceMgr*
63   GetResourceMgr( const SalomeApp_Module* );
64   
65 SMESHGUI_EXPORT
66   _PTR(Study)
67   GetCStudy(const SalomeApp_Study* theStudy);
68
69 SMESHGUI_EXPORT
70   CORBA::Object_var DataOwnerToObject(const LightApp_DataOwnerPtr& theOwner);
71
72   template<class TInterface> typename TInterface::_var_type
73     DataOwnerToInterface(const LightApp_DataOwnerPtr& theDataOwner)
74     {
75       CORBA::Object_var anObj = DataOwnerToObject(theDataOwner);
76       if(!CORBA::is_nil(anObj))
77         return TInterface::_narrow(anObj);
78       return TInterface::_nil();
79     }
80
81
82 SMESHGUI_EXPORT
83   SUIT_Study* GetActiveStudy();
84
85 SMESHGUI_EXPORT
86   SUIT_ViewWindow* GetActiveWindow();
87
88 SMESHGUI_EXPORT
89   _PTR(Study) GetActiveStudyDocument();
90
91 SMESHGUI_EXPORT
92   _PTR(SObject) FindSObject(CORBA::Object_ptr theObject);
93
94 SMESHGUI_EXPORT
95   void SetName  (_PTR(SObject) theSObject, const char* theName);
96
97 SMESHGUI_EXPORT
98   void SetValue (_PTR(SObject) theSObject, const char* theValue);
99   void setFileType (_PTR(SObject) theSObject, const char* theValue);
100   void setFileName (_PTR(SObject) theSObject, const char* theValue);
101
102 SMESHGUI_EXPORT
103   CORBA::Object_var SObjectToObject (_PTR(SObject) theSObject,
104                                      _PTR(Study) theStudy);
105
106 SMESHGUI_EXPORT
107   CORBA::Object_var SObjectToObject(_PTR(SObject) theSObject);
108
109   template<class TInterface> typename TInterface::_var_type
110     SObjectToInterface(_PTR(SObject) theSObject)
111     {
112       CORBA::Object_var anObj = SObjectToObject(theSObject);
113       if(!CORBA::is_nil(anObj))
114         return TInterface::_narrow(anObj);
115       return TInterface::_nil();
116     }
117
118 SMESHGUI_EXPORT
119   CORBA::Object_var IObjectToObject(const Handle(SALOME_InteractiveObject)& theIO);
120
121   template<class TInterface> typename TInterface::_var_type
122     IObjectToInterface(const Handle(SALOME_InteractiveObject)& theIO)
123     {
124       CORBA::Object_var anObj = IObjectToObject(theIO);
125       if(!CORBA::is_nil(anObj))
126         return TInterface::_narrow(anObj);
127       return TInterface::_nil();
128     }
129
130 SMESHGUI_EXPORT
131   CORBA::Object_var IORToObject(const char* theIOR);
132
133   template<class TInterface> typename TInterface::_var_type
134     IORToInterface(const char* theIOR)
135     {
136       CORBA::Object_var anObj = IORToObject(theIOR);
137       if(!CORBA::is_nil(anObj))
138         return TInterface::_narrow(anObj);
139       return TInterface::_nil();
140     }
141
142 SMESHGUI_EXPORT
143   int GetNameOfSelectedIObjects (LightApp_SelectionMgr*, QString& theName);
144
145 SMESHGUI_EXPORT
146   _PTR(SObject) GetMeshOrSubmesh (_PTR(SObject) theSObject);
147
148 SMESHGUI_EXPORT
149   void ModifiedMesh (_PTR(SObject) theSObject, bool theIsRight);
150
151 //  void UpdateObjBrowser (bool);
152 }
153
154 #endif