Salome HOME
Merge from V6_3_BR 06/06/2011
[modules/smesh.git] / src / SMESHGUI / SMESHGUI_Utils.h
1 // Copyright (C) 2007-2011  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
23 // SMESH SMESHGUI : GUI for SMESH component
24 // File   : SMESHGUI_Utils.h
25 // Author : Open CASCADE S.A.S.
26 //
27 #ifndef SMESHGUI_UTILS_H
28 #define SMESHGUI_UTILS_H
29
30 // SMESH includes
31 #include "SMESH_SMESHGUI.hxx"
32
33 // CORBA includes
34 #include <omniORB4/CORBA.h>
35
36 // SALOME KERNEL includes
37 #include <SALOMEDSClient_definitions.hxx>
38
39 // SALOME GUI includes
40 #include <SALOME_InteractiveObject.hxx>
41 #include <LightApp_DataOwner.h>
42
43 //OCC includes
44 #include <gp_XYZ.hxx>
45
46 class SUIT_ViewWindow;
47 class SUIT_Desktop;
48 class SUIT_Study;
49 class SUIT_ResourceMgr;
50
51 class CAM_Module;
52
53 class SALOMEDSClient_Study;
54 class SALOMEDSClient_SObject;
55
56 class SalomeApp_Study;
57 class SalomeApp_Module;
58 class LightApp_SelectionMgr;
59
60 class SMDS_MeshFace;
61
62 namespace SMESH
63 {
64 SMESHGUI_EXPORT
65   SUIT_Desktop*
66   GetDesktop( const CAM_Module* );
67
68 SMESHGUI_EXPORT
69   LightApp_SelectionMgr*
70   GetSelectionMgr( const SalomeApp_Module* );
71
72 SMESHGUI_EXPORT
73   SalomeApp_Study*
74   GetAppStudy( const CAM_Module* );
75
76 SMESHGUI_EXPORT
77   SUIT_ResourceMgr*
78   GetResourceMgr( const SalomeApp_Module* );
79   
80 SMESHGUI_EXPORT
81   _PTR(Study)
82   GetCStudy( const SalomeApp_Study* );
83
84 SMESHGUI_EXPORT
85   CORBA::Object_var DataOwnerToObject( const LightApp_DataOwnerPtr& );
86
87   template<class TInterface> typename TInterface::_var_type
88     DataOwnerToInterface( const LightApp_DataOwnerPtr& theDataOwner )
89     {
90       CORBA::Object_var anObj = DataOwnerToObject(theDataOwner);
91       if(!CORBA::is_nil(anObj))
92         return TInterface::_narrow(anObj);
93       return TInterface::_nil();
94     }
95
96 SMESHGUI_EXPORT
97   SUIT_Study* GetActiveStudy();
98
99 SMESHGUI_EXPORT
100   SUIT_ViewWindow* GetActiveWindow();
101
102 SMESHGUI_EXPORT
103   _PTR(Study) GetActiveStudyDocument();
104
105 SMESHGUI_EXPORT
106   _PTR(SObject) FindSObject( CORBA::Object_ptr );
107
108 SMESHGUI_EXPORT
109   void SetName( _PTR(SObject), const QString& );
110
111 SMESHGUI_EXPORT
112   void SetValue( _PTR(SObject), const QString& );
113   void setFileType( _PTR(SObject), const QString& );
114   void setFileName( _PTR(SObject), const QString& );
115
116 SMESHGUI_EXPORT
117   CORBA::Object_var SObjectToObject( _PTR(SObject),
118                                      _PTR(Study) );
119
120 SMESHGUI_EXPORT
121   CORBA::Object_var SObjectToObject( _PTR(SObject) );
122
123   template<class TInterface> typename TInterface::_var_type
124     SObjectToInterface( _PTR(SObject) theSObject )
125     {
126       CORBA::Object_var anObj = SObjectToObject(theSObject);
127       if(!CORBA::is_nil(anObj))
128         return TInterface::_narrow(anObj);
129       return TInterface::_nil();
130     }
131
132 SMESHGUI_EXPORT
133   _PTR(SObject) ObjectToSObject( CORBA::Object_ptr );
134
135 SMESHGUI_EXPORT
136   CORBA::Object_var IObjectToObject( const Handle(SALOME_InteractiveObject)& );
137
138   template<class TInterface> typename TInterface::_var_type
139     IObjectToInterface( const Handle(SALOME_InteractiveObject)& theIO )
140     {
141       CORBA::Object_var anObj = IObjectToObject(theIO);
142       if(!CORBA::is_nil(anObj))
143         return TInterface::_narrow(anObj);
144       return TInterface::_nil();
145     }
146
147 SMESHGUI_EXPORT
148   CORBA::Object_var IORToObject( const QString& );
149
150   template<class TInterface> typename TInterface::_var_type
151     IORToInterface( const QString& theIOR )
152     {
153       CORBA::Object_var anObj = IORToObject( theIOR );
154       if ( !CORBA::is_nil( anObj ) )
155         return TInterface::_narrow( anObj );
156       return TInterface::_nil();
157     }
158
159 SMESHGUI_EXPORT
160   int GetNameOfSelectedIObjects( LightApp_SelectionMgr*, QString& );
161
162 SMESHGUI_EXPORT
163   _PTR(SObject) GetMeshOrSubmesh( _PTR(SObject) );
164
165 SMESHGUI_EXPORT
166   void ModifiedMesh( _PTR(SObject), bool, bool = false );
167
168 SMESHGUI_EXPORT
169   void ShowHelpFile( const QString& );
170
171   /*!
172    * \brief Return the normal to a face
173     * \param theFace - input face
174     * \retval gp_XYZ - normal to a face 
175    */
176 SMESHGUI_EXPORT
177   gp_XYZ getNormale( const SMDS_MeshFace* theFace );
178
179 }
180
181 #endif // SMESHGUI_UTILS_H