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