Version: 9.16.0
SMESHGUI_Utils.h
Go to the documentation of this file.
1// Copyright (C) 2007-2026 CEA, EDF, 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, or (at your option) any later version.
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#include <SALOMEconfig.h>
48#include CORBA_CLIENT_HEADER(SMESH_Mesh)
49
50class SUIT_ViewWindow;
51class SUIT_Desktop;
52class SUIT_Study;
53class SUIT_ResourceMgr;
54
55class CAM_Module;
56
57class SALOMEDSClient_Study;
58class SALOMEDSClient_SObject;
59
60class SalomeApp_Study;
62class LightApp_SelectionMgr;
63
64class SMDS_MeshFace;
65
66namespace SMESH
67{
69 SUIT_Desktop*
70 GetDesktop( const CAM_Module* );
71
73 LightApp_SelectionMgr*
75
77 SalomeApp_Study*
78 GetAppStudy( const CAM_Module* );
79
81 SUIT_ResourceMgr*
83
85 CORBA::Object_var DataOwnerToObject( const LightApp_DataOwnerPtr& );
86
87 template<class TInterface> typename TInterface::_var_type
88 DataOwnerToInterface( const LightApp_DataOwnerPtr& theDataOwner )
89 {
90 CORBA::Object_var anObj = DataOwnerToObject(theDataOwner);
91 if(!CORBA::is_nil(anObj))
92 return TInterface::_narrow(anObj);
93 return TInterface::_nil();
94 }
95
97 SUIT_Study* GetActiveStudy();
98
100 SUIT_ViewWindow* GetActiveWindow();
101
103 _PTR(Study) getStudy();
104
106 _PTR(SObject) FindSObject( CORBA::Object_ptr );
107
109 void SetName( _PTR(SObject), const QString& name );
110
112 void SetValue ( _PTR(SObject), const QString& value );
113 void setFileType( _PTR(SObject), const QString& fileType );
114 void setFileName( _PTR(SObject), const QString& fileName );
115
117 CORBA::Object_var SObjectToObject( _PTR(SObject) );
118
119 template<class TInterface> typename TInterface::_var_type
120 SObjectToInterface( _PTR(SObject) theSObject )
121 {
122 CORBA::Object_var anObj = SObjectToObject(theSObject);
123 if(!CORBA::is_nil(anObj))
124 return TInterface::_narrow(anObj);
125 return TInterface::_nil();
126 }
127
129 _PTR(SObject) ObjectToSObject( CORBA::Object_ptr );
130
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
144 CORBA::Object_var IORToObject( const QString& ior );
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
156 CORBA::Object_var EntryToObject( const QString& entry );
157
158 template<class TInterface> typename TInterface::_var_type
159 EntryToInterface( const QString& theEntry )
160 {
161 CORBA::Object_var anObj = EntryToObject( theEntry );
162 if ( !CORBA::is_nil( anObj ) )
163 return TInterface::_narrow( anObj );
164 return TInterface::_nil();
165 }
166
168 int GetNameOfSelectedIObjects( LightApp_SelectionMgr*, QString& name );
169
171 QString GetName( const Handle(SALOME_InteractiveObject)& theIO );
172
174 _PTR(SObject) GetMeshOrSubmesh( _PTR(SObject) );
175
177 void ShowHelpFile( const QString& helpFileName);
178
185 gp_XYZ getNormale( const SMDS_MeshFace* theFace );
186
187
188 // type to use instead of SMESH_IDSource_var for automatic UnRegister()
189 typedef SALOME::GenericObj_wrap<SMESH_IDSource> IDSource_wrap;
190
198 template < class _STRING >
199 class toStrT : public _STRING {
200 CORBA::String_var myStr;
201 public:
202 toStrT( char* s ): _STRING( s ), myStr(s)
203 {}
204 operator const char*() const
205 { return myStr.in(); }
206 };
207 // Instantiations:
208 struct toQStr : public toStrT< QString > {
209 toQStr( char* s ): toStrT< QString >(s) {}
210 };
211 struct toStdStr : public toStrT< std::string > {
212 toStdStr( char* s ): toStrT< std::string >(s) {}
213 };
214
215 QString fromUtf8( const char* txt );
216 QString fromUtf8( const std::string& txt );
217 struct toUtf8: public std::string
218 {
219 toUtf8( const QString& txt );
220 operator const char*() const { return c_str(); }
221 };
222}
223
224#endif // SMESHGUI_UTILS_H
#define SMESHGUI_EXPORT
Definition: SMESH_SMESHGUI.hxx:36
Mesh face.
Definition: SMDS_MeshFace.hxx:41
Class useful to convert a string returned from a CORBA call to other string types w/o memory leak.
Definition: SMESHGUI_Utils.h:199
toStrT(char *s)
Definition: SMESHGUI_Utils.h:202
CORBA::String_var myStr
Definition: SMESHGUI_Utils.h:200
Definition: SMESH_ControlsClassifier.cxx:39
TInterface::_var_type DataOwnerToInterface(const LightApp_DataOwnerPtr &theDataOwner)
Definition: SMESHGUI_Utils.h:88
int GetNameOfSelectedIObjects(LightApp_SelectionMgr *theMgr, QString &theName)
Definition: SMESHGUI_Utils.cxx:235
SUIT_ViewWindow * GetActiveWindow()
Definition: SMESHGUI_Utils.cxx:104
TInterface::_var_type IORToInterface(const QString &theIOR)
Definition: SMESHGUI_Utils.h:147
Handle(VTKViewer_Filter) GetFilter(int theId
QString GetName(const Handle(SALOME_InteractiveObject)&theIO)
Definition: SMESHGUI_Utils.cxx:252
void setFileName(_PTR(SObject) theSObject, const QString &theValue)
Definition: SMESHGUI_Utils.cxx:154
_PTR(SObject) getSubShapeSO(int subShapeID
Return SO of a sub-shape.
Definition: SMESHGUI_Utils.cxx:122
SalomeApp_Study * GetAppStudy(const CAM_Module *)
LightApp_SelectionMgr * GetSelectionMgr(const SalomeApp_Module *theModule)
Definition: SMESHGUI_Utils.cxx:68
QString fromUtf8(const char *txt)
Definition: SMESHGUI_Utils.cxx:312
CORBA::Object_var IORToObject(const QString &theIOR)
Definition: SMESHGUI_Utils.cxx:222
void SetValue(_PTR(SObject) theSObject, const QString &theValue)
Definition: SMESHGUI_Utils.cxx:141
CORBA::Object_var EntryToObject(const QString &theEntry)
Definition: SMESHGUI_Utils.cxx:229
CORBA::Object_var DataOwnerToObject(const LightApp_DataOwnerPtr &theOwner)
Definition: SMESHGUI_Utils.cxx:80
SUIT_Study * GetActiveStudy()
Definition: SMESHGUI_Utils.cxx:95
SALOME::GenericObj_wrap< SMESH_IDSource > IDSource_wrap
Definition: SMESHGUI_Utils.h:189
gp_XYZ getNormale(const SMDS_MeshFace *theFace)
Return normale to a given face.
Definition: SMESHGUI_Utils.cxx:305
TInterface::_var_type EntryToInterface(const QString &theEntry)
Definition: SMESHGUI_Utils.h:159
CORBA::Object_var SObjectToObject(_PTR(SObject) theSObject)
Definition: SMESHGUI_Utils.cxx:180
void setFileType(_PTR(SObject) theSObject, const QString &theValue)
Definition: SMESHGUI_Utils.cxx:167
TInterface::_var_type SObjectToInterface(_PTR(SObject) theSObject)
Definition: SMESHGUI_Utils.h:120
SUIT_Desktop * GetDesktop(const CAM_Module *theModule)
Definition: SMESHGUI_Utils.cxx:62
void SetName(_PTR(SObject) theSObject, const QString &theName)
Definition: SMESHGUI_Utils.cxx:134
void ShowHelpFile(const QString &theHelpFileName)
Definition: SMESHGUI_Utils.cxx:283
SUIT_ResourceMgr * GetResourceMgr(const SalomeApp_Module *)
Definition: SMESHGUI_Utils.cxx:74
TInterface::_var_type IObjectToInterface(const Handle(SALOME_InteractiveObject)&theIO)
Definition: SMESHGUI_Utils.h:135
CORBA::Object_var IObjectToObject(const Handle(SALOME_InteractiveObject)&theIO)
Definition: SMESHGUI_Utils.cxx:211
Definition: SMESHGUI_Utils.h:208
toQStr(char *s)
Definition: SMESHGUI_Utils.h:209
Definition: SMESHGUI_Utils.h:211
toStdStr(char *s)
Definition: SMESHGUI_Utils.h:212
Definition: SMESHGUI_Utils.h:218
toUtf8(const QString &txt)
Definition: SMESHGUI_Utils.cxx:326