00001 // Copyright (C) 2007-2011 CEA/DEN, EDF R&D, OPEN CASCADE 00002 // 00003 // Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, 00004 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS 00005 // 00006 // This library is free software; you can redistribute it and/or 00007 // modify it under the terms of the GNU Lesser General Public 00008 // License as published by the Free Software Foundation; either 00009 // version 2.1 of the License. 00010 // 00011 // This library is distributed in the hope that it will be useful, 00012 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00013 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00014 // Lesser General Public License for more details. 00015 // 00016 // You should have received a copy of the GNU Lesser General Public 00017 // License along with this library; if not, write to the Free Software 00018 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 00019 // 00020 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com 00021 // 00022 00023 // SMESH SMESHGUI : GUI for SMESH component 00024 // File : SMESHGUI_Utils.h 00025 // Author : Open CASCADE S.A.S. 00026 // 00027 #ifndef SMESHGUI_UTILS_H 00028 #define SMESHGUI_UTILS_H 00029 00030 // SMESH includes 00031 #include "SMESH_SMESHGUI.hxx" 00032 00033 // CORBA includes 00034 #include <omniORB4/CORBA.h> 00035 00036 // SALOME KERNEL includes 00037 #include <SALOMEDSClient_definitions.hxx> 00038 00039 // SALOME GUI includes 00040 #include <SALOME_InteractiveObject.hxx> 00041 #include <LightApp_DataOwner.h> 00042 00043 //OCC includes 00044 #include <gp_XYZ.hxx> 00045 00046 class SUIT_ViewWindow; 00047 class SUIT_Desktop; 00048 class SUIT_Study; 00049 class SUIT_ResourceMgr; 00050 00051 class CAM_Module; 00052 00053 class SALOMEDSClient_Study; 00054 class SALOMEDSClient_SObject; 00055 00056 class SalomeApp_Study; 00057 class SalomeApp_Module; 00058 class LightApp_SelectionMgr; 00059 00060 class SMDS_MeshFace; 00061 00062 namespace SMESH 00063 { 00064 SMESHGUI_EXPORT 00065 SUIT_Desktop* 00066 GetDesktop( const CAM_Module* ); 00067 00068 SMESHGUI_EXPORT 00069 LightApp_SelectionMgr* 00070 GetSelectionMgr( const SalomeApp_Module* ); 00071 00072 SMESHGUI_EXPORT 00073 SalomeApp_Study* 00074 GetAppStudy( const CAM_Module* ); 00075 00076 SMESHGUI_EXPORT 00077 SUIT_ResourceMgr* 00078 GetResourceMgr( const SalomeApp_Module* ); 00079 00080 SMESHGUI_EXPORT 00081 _PTR(Study) 00082 GetCStudy( const SalomeApp_Study* ); 00083 00084 SMESHGUI_EXPORT 00085 CORBA::Object_var DataOwnerToObject( const LightApp_DataOwnerPtr& ); 00086 00087 template<class TInterface> typename TInterface::_var_type 00088 DataOwnerToInterface( const LightApp_DataOwnerPtr& theDataOwner ) 00089 { 00090 CORBA::Object_var anObj = DataOwnerToObject(theDataOwner); 00091 if(!CORBA::is_nil(anObj)) 00092 return TInterface::_narrow(anObj); 00093 return TInterface::_nil(); 00094 } 00095 00096 SMESHGUI_EXPORT 00097 SUIT_Study* GetActiveStudy(); 00098 00099 SMESHGUI_EXPORT 00100 SUIT_ViewWindow* GetActiveWindow(); 00101 00102 SMESHGUI_EXPORT 00103 _PTR(Study) GetActiveStudyDocument(); 00104 00105 SMESHGUI_EXPORT 00106 _PTR(SObject) FindSObject( CORBA::Object_ptr ); 00107 00108 SMESHGUI_EXPORT 00109 void SetName( _PTR(SObject), const QString& ); 00110 00111 SMESHGUI_EXPORT 00112 void SetValue( _PTR(SObject), const QString& ); 00113 void setFileType( _PTR(SObject), const QString& ); 00114 void setFileName( _PTR(SObject), const QString& ); 00115 00116 SMESHGUI_EXPORT 00117 CORBA::Object_var SObjectToObject( _PTR(SObject), 00118 _PTR(Study) ); 00119 00120 SMESHGUI_EXPORT 00121 CORBA::Object_var SObjectToObject( _PTR(SObject) ); 00122 00123 template<class TInterface> typename TInterface::_var_type 00124 SObjectToInterface( _PTR(SObject) theSObject ) 00125 { 00126 CORBA::Object_var anObj = SObjectToObject(theSObject); 00127 if(!CORBA::is_nil(anObj)) 00128 return TInterface::_narrow(anObj); 00129 return TInterface::_nil(); 00130 } 00131 00132 SMESHGUI_EXPORT 00133 _PTR(SObject) ObjectToSObject( CORBA::Object_ptr ); 00134 00135 SMESHGUI_EXPORT 00136 CORBA::Object_var IObjectToObject( const Handle(SALOME_InteractiveObject)& ); 00137 00138 template<class TInterface> typename TInterface::_var_type 00139 IObjectToInterface( const Handle(SALOME_InteractiveObject)& theIO ) 00140 { 00141 CORBA::Object_var anObj = IObjectToObject(theIO); 00142 if(!CORBA::is_nil(anObj)) 00143 return TInterface::_narrow(anObj); 00144 return TInterface::_nil(); 00145 } 00146 00147 SMESHGUI_EXPORT 00148 CORBA::Object_var IORToObject( const QString& ); 00149 00150 template<class TInterface> typename TInterface::_var_type 00151 IORToInterface( const QString& theIOR ) 00152 { 00153 CORBA::Object_var anObj = IORToObject( theIOR ); 00154 if ( !CORBA::is_nil( anObj ) ) 00155 return TInterface::_narrow( anObj ); 00156 return TInterface::_nil(); 00157 } 00158 00159 SMESHGUI_EXPORT 00160 int GetNameOfSelectedIObjects( LightApp_SelectionMgr*, QString& ); 00161 00162 SMESHGUI_EXPORT 00163 _PTR(SObject) GetMeshOrSubmesh( _PTR(SObject) ); 00164 00165 SMESHGUI_EXPORT 00166 void ModifiedMesh( _PTR(SObject), bool, bool = false ); 00167 00168 SMESHGUI_EXPORT 00169 void ShowHelpFile( const QString& ); 00170 00176 SMESHGUI_EXPORT 00177 gp_XYZ getNormale( const SMDS_MeshFace* theFace ); 00178 00179 } 00180 00181 #endif // SMESHGUI_UTILS_H