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