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