Salome HOME
SMH: Preparation version 3.0.0 - merge (HEAD+POLYWORK)
[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 "SalomeApp_DataOwner.h"
28
29 class QString;
30
31 class SUIT_ViewWindow;
32 class SUIT_Desktop;
33 class SUIT_Study;
34
35 class CAM_Module;
36
37 class SALOMEDSClient_Study;
38 class SALOMEDSClient_SObject;
39
40 class SalomeApp_Study;
41 class SalomeApp_Module;
42 class SalomeApp_SelectionMgr;
43
44 namespace SMESH {
45
46   SUIT_Desktop*
47   GetDesktop(const CAM_Module* theModule);
48
49   SalomeApp_SelectionMgr*
50   GetSelectionMgr(const SalomeApp_Module* theModule);
51
52   SalomeApp_Study*
53   GetAppStudy(const CAM_Module* theModule);
54
55   _PTR(Study)
56   GetCStudy(const SalomeApp_Study* theStudy);
57
58   CORBA::Object_var DataOwnerToObject(const SalomeApp_DataOwnerPtr& theOwner);
59
60   template<class TInterface> typename TInterface::_var_type
61     DataOwnerToInterface(const SalomeApp_DataOwnerPtr& theDataOwner)
62     {
63       CORBA::Object_var anObj = DataOwnerToObject(theDataOwner);
64       if(!CORBA::is_nil(anObj))
65         return TInterface::_narrow(anObj);
66       return TInterface::_nil();
67     }
68
69
70   SUIT_Study* GetActiveStudy();
71
72   SUIT_ViewWindow* GetActiveWindow();
73
74   _PTR(Study) GetActiveStudyDocument();
75
76   _PTR(SObject) FindSObject(CORBA::Object_ptr theObject);
77
78   void SetName  (_PTR(SObject) theSObject, const char* theName);
79   void SetValue (_PTR(SObject) theSObject, const char* theValue);
80
81   CORBA::Object_var SObjectToObject (_PTR(SObject) theSObject,
82                                      _PTR(Study) theStudy);
83
84   CORBA::Object_var SObjectToObject(_PTR(SObject) theSObject);
85
86   template<class TInterface> typename TInterface::_var_type
87     SObjectToInterface(_PTR(SObject) theSObject)
88     {
89       CORBA::Object_var anObj = SObjectToObject(theSObject);
90       if(!CORBA::is_nil(anObj))
91         return TInterface::_narrow(anObj);
92       return TInterface::_nil();
93     }
94
95   CORBA::Object_var IObjectToObject(const Handle(SALOME_InteractiveObject)& theIO);
96
97   template<class TInterface> typename TInterface::_var_type
98     IObjectToInterface(const Handle(SALOME_InteractiveObject)& theIO)
99     {
100       CORBA::Object_var anObj = IObjectToObject(theIO);
101       if(!CORBA::is_nil(anObj))
102         return TInterface::_narrow(anObj);
103       return TInterface::_nil();
104     }
105
106   CORBA::Object_var IORToObject(const char* theIOR);
107
108   template<class TInterface> typename TInterface::_var_type
109     IORToInterface(const char* theIOR)
110     {
111       CORBA::Object_var anObj = IORToObject(theIOR);
112       if(!CORBA::is_nil(anObj))
113         return TInterface::_narrow(anObj);
114       return TInterface::_nil();
115     }
116
117   int GetNameOfSelectedIObjects (SalomeApp_SelectionMgr*, QString& theName);
118
119   _PTR(SObject) GetMeshOrSubmesh (_PTR(SObject) theSObject);
120
121   void ModifiedMesh (_PTR(SObject) theSObject, bool theIsRight);
122
123 //  void UpdateObjBrowser (bool);
124 }
125
126 #endif