Salome HOME
d34944d0301f6975827f84b5f53f8dc4d962f629
[modules/smesh.git] / src / SMESHGUI / SMESHGUI_Utils.h
1 // SMESH SMESHGUI : GUI for SMESH component
2 //
3 // Copyright (C) 2003  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 // File   : SMESHGUI_Utils.h
23 // Author : Open CASCADE S.A.S.
24 //
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 class SUIT_ViewWindow;
43 class SUIT_Desktop;
44 class SUIT_Study;
45 class SUIT_ResourceMgr;
46
47 class CAM_Module;
48
49 class SALOMEDSClient_Study;
50 class SALOMEDSClient_SObject;
51
52 class SalomeApp_Study;
53 class SalomeApp_Module;
54 class LightApp_SelectionMgr;
55
56 namespace SMESH
57 {
58 SMESHGUI_EXPORT
59   SUIT_Desktop*
60   GetDesktop( const CAM_Module* );
61
62 SMESHGUI_EXPORT
63   LightApp_SelectionMgr*
64   GetSelectionMgr( const SalomeApp_Module* );
65
66 SMESHGUI_EXPORT
67   SalomeApp_Study*
68   GetAppStudy( const CAM_Module* );
69
70 SMESHGUI_EXPORT
71   SUIT_ResourceMgr*
72   GetResourceMgr( const SalomeApp_Module* );
73   
74 SMESHGUI_EXPORT
75   _PTR(Study)
76   GetCStudy( const SalomeApp_Study* );
77
78 SMESHGUI_EXPORT
79   CORBA::Object_var DataOwnerToObject( const LightApp_DataOwnerPtr& );
80
81   template<class TInterface> typename TInterface::_var_type
82     DataOwnerToInterface( const LightApp_DataOwnerPtr& theDataOwner )
83     {
84       CORBA::Object_var anObj = DataOwnerToObject(theDataOwner);
85       if(!CORBA::is_nil(anObj))
86         return TInterface::_narrow(anObj);
87       return TInterface::_nil();
88     }
89
90 SMESHGUI_EXPORT
91   SUIT_Study* GetActiveStudy();
92
93 SMESHGUI_EXPORT
94   SUIT_ViewWindow* GetActiveWindow();
95
96 SMESHGUI_EXPORT
97   _PTR(Study) GetActiveStudyDocument();
98
99 SMESHGUI_EXPORT
100   _PTR(SObject) FindSObject( CORBA::Object_ptr );
101
102 SMESHGUI_EXPORT
103   void SetName( _PTR(SObject), const QString& );
104
105 SMESHGUI_EXPORT
106   void SetValue( _PTR(SObject), const QString& );
107   void setFileType( _PTR(SObject), const QString& );
108   void setFileName( _PTR(SObject), const QString& );
109
110 SMESHGUI_EXPORT
111   CORBA::Object_var SObjectToObject( _PTR(SObject),
112                                      _PTR(Study) );
113
114 SMESHGUI_EXPORT
115   CORBA::Object_var SObjectToObject( _PTR(SObject) );
116
117   template<class TInterface> typename TInterface::_var_type
118     SObjectToInterface( _PTR(SObject) theSObject )
119     {
120       CORBA::Object_var anObj = SObjectToObject(theSObject);
121       if(!CORBA::is_nil(anObj))
122         return TInterface::_narrow(anObj);
123       return TInterface::_nil();
124     }
125
126 SMESHGUI_EXPORT
127   CORBA::Object_var IObjectToObject( const Handle(SALOME_InteractiveObject)& );
128
129   template<class TInterface> typename TInterface::_var_type
130     IObjectToInterface( const Handle(SALOME_InteractiveObject)& theIO )
131     {
132       CORBA::Object_var anObj = IObjectToObject(theIO);
133       if(!CORBA::is_nil(anObj))
134         return TInterface::_narrow(anObj);
135       return TInterface::_nil();
136     }
137
138 SMESHGUI_EXPORT
139   CORBA::Object_var IORToObject( const QString& );
140
141   template<class TInterface> typename TInterface::_var_type
142     IORToInterface( const QString& theIOR )
143     {
144       CORBA::Object_var anObj = IORToObject( theIOR );
145       if ( !CORBA::is_nil( anObj ) )
146         return TInterface::_narrow( anObj );
147       return TInterface::_nil();
148     }
149
150 SMESHGUI_EXPORT
151   int GetNameOfSelectedIObjects( LightApp_SelectionMgr*, QString& );
152
153 SMESHGUI_EXPORT
154   _PTR(SObject) GetMeshOrSubmesh( _PTR(SObject) );
155
156 SMESHGUI_EXPORT
157   void ModifiedMesh( _PTR(SObject), bool, bool = false );
158
159 SMESHGUI_EXPORT
160   void ShowHelpFile( const QString& );
161 }
162
163 #endif // SMESHGUI_UTILS_H