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