-// Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE
+// Copyright (C) 2007-2010 CEA/DEN, EDF R&D, OPEN CASCADE
//
// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
//
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
//
-// SMESH SMESHGUI : GUI for SMESH component
-// File : SMESHGUI_MeshOp.cxx
-// Author : Sergey LITONIN, Open CASCADE S.A.S.
+// SMESH SMESHGUI : GUI for SMESH component
+// File : SMESHGUI_MeshOp.cxx
+// Author : Sergey LITONIN, Open CASCADE S.A.S.
// SMESH includes
#include "SMESHGUI_MeshOp.h"
#include <SALOMEconfig.h>
#include CORBA_CLIENT_HEADER(SMESH_Gen)
+//To disable automatic genericobj management, the following line should be commented.
+//Otherwise, it should be uncommented. Refer to KERNEL_SRC/src/SALOMEDSImpl/SALOMEDSImpl_AttributeIOR.cxx
+#define WITHGENERICOBJ
+
//================================================================================
/*!
* \brief Constructor
else if ( !myToCreate )
aResult = editMeshOrSubMesh( aMess );
if ( aResult )
+ {
+ SMESHGUI::Modified();
update( UF_ObjBrowser | UF_Model );
+ }
}
catch ( const SALOME::SALOME_Exception& S_ex )
{
* \retval bool - check result
*/
//================================================================================
-
bool SMESHGUI_MeshOp::isSubshapeOk() const
{
if ( !myToCreate || myIsMesh ) // not submesh creation
//================================================================================
/*!
* \brief Return name of the algorithm that does not support submeshes and makes
- * submesh creation useless
+ * submesh creation useless
* \retval char* - string is to be deleted!!!
*/
//================================================================================
-
char* SMESHGUI_MeshOp::isSubmeshIgnored() const
{
if ( myToCreate && !myIsMesh ) {
* \retval _PTR(SObject) - the found submesh SObject
*/
//================================================================================
-
_PTR(SObject) SMESHGUI_MeshOp::getSubmeshByGeom() const
{
QString aMeshEntry = myDlg->selectedObject( SMESHGUI_MeshDlg::Mesh );
bool editSubmesh = ( !sm->_is_nil() &&
SUIT_MessageBox::question( myDlg, tr( "SMESH_WARNING" ),
tr( "EDIT_SUBMESH_QUESTION"),
- SUIT_MessageBox::Yes |
+ SUIT_MessageBox::Yes |
SUIT_MessageBox::No,
SUIT_MessageBox::No )
== SUIT_MessageBox::Yes );
* \retval bool - check result
*/
//================================================================================
-
static bool isCompatible(const HypothesisData* theAlgoData,
const HypothesisData* theHypData,
const int theHypType)
* \retval SMESH::SMESH_Hypothesis_var - the hypothesis holding parameter values
*/
//================================================================================
-
SMESH::SMESH_Hypothesis_var
SMESHGUI_MeshOp::getInitParamsHypothesis( const QString& aHypType,
const QString& aServerLib ) const
}
}
- return SMESHGUI::GetSMESHGen()->GetHypothesisParameterValues( aHypType.toLatin1().data(),
- aServerLib.toLatin1().data(),
- aMeshVar,
- aGeomVar,
- /*byMesh = */isSubMesh);
-
+ SMESH::SMESH_Hypothesis_var hyp =
+ SMESHGUI::GetSMESHGen()->GetHypothesisParameterValues( aHypType.toLatin1().data(),
+ aServerLib.toLatin1().data(),
+ aMeshVar,
+ aGeomVar,
+ /*byMesh = */isSubMesh);
+ if ( hyp->_is_nil() && isSubMesh )
+ hyp = SMESHGUI::GetSMESHGen()->GetHypothesisParameterValues( aHypType.toLatin1().data(),
+ aServerLib.toLatin1().data(),
+ aMeshVar,
+ aGeomVar,
+ /*byMesh = */false);
+ return hyp;
}
//================================================================================
* \retval int - dimention
*/
//================================================================================
-
static int getTabDim (const QObject* tab, SMESHGUI_MeshDlg* dlg )
{
int aDim = -1;
* \param theTypeName - specifies hypothesis to be created
*/
//================================================================================
-
void SMESHGUI_MeshOp::createHypothesis(const int theDim,
const int theType,
const QString& theTypeName)
QString aClientLibName = aData->ClientLibName;
if (aClientLibName == "") {
// Call hypothesis creation server method (without GUI)
- SMESH::CreateHypothesis(theTypeName, aHypName, false);
+ SMESH::SMESH_Hypothesis_var aHyp =
+ SMESH::CreateHypothesis(theTypeName, aHypName, false);
+#ifdef WITHGENERICOBJ
+ if (!CORBA::is_nil(aHyp))
+ aHyp->Destroy();
+#endif
} else {
// Get hypotheses creator client (GUI)
// BUG 0020378
aGeomEntry = myDlg->selectedObject( SMESHGUI_MeshDlg::Geom );
aMeshEntry = myDlg->selectedObject( SMESHGUI_MeshDlg::Mesh );
anObjEntry = myDlg->selectedObject( SMESHGUI_MeshDlg::Obj );
-
+
if ( aMeshEntry != "" ) { // Get Geom object from Mesh
_PTR(SObject) pObj = studyDS()->FindObjectID( aMeshEntry.toLatin1().data() );
GEOM::GEOM_Object_var aGeomVar = SMESH::GetShapeOnMeshOrSubMesh( pObj );
aMeshEntry = ( aGeomVar->_is_nil() ) ? "" : aMeshEntry = aGeomVar->GetStudyEntry();
}
-
+
if ( aMeshEntry == "" && aGeomEntry == "" ) {
_PTR(SObject) pObj = studyDS()->FindObjectID( anObjEntry.toLatin1().data() );
GEOM::GEOM_Object_var aGeomVar = SMESH::GetShapeOnMeshOrSubMesh( pObj );
}
}
}
-
+
aCreator->setShapeEntry( aGeomEntry );
if ( aMeshEntry != "" )
aCreator->setMainShapeEntry( aMeshEntry );
aCreator->create(initParamHyp, aHypName, myDlg, this, SLOT( onHypoCreated( int ) ) );
dialog = true;
}
- else
- SMESH::CreateHypothesis(theTypeName, aHypName, false);
+ else {
+ SMESH::SMESH_Hypothesis_var aHyp =
+ SMESH::CreateHypothesis(theTypeName, aHypName, false);
+#ifdef WITHGENERICOBJ
+ if (!CORBA::is_nil(aHyp))
+ aHyp->Destroy();
+#endif
+ }
}
if( !dialog )
* \retval HypothesisData* - result data, may be 0
*/
//================================================================================
-
HypothesisData* SMESHGUI_MeshOp::hypData( const int theDim,
const int theHypType,
const int theIndex)
* \param theIndex - algorithm index
*/
//================================================================================
-
void SMESHGUI_MeshOp::onAlgoSelected( const int theIndex,
const int theDim )
{
if ( !anAlgoVar->_is_nil() )
SMESH::AddHypothesisOnMesh( aMeshVar, anAlgoVar );
}
-
+#ifdef WITHGENERICOBJ
+ // obj has been published in study. Its refcount has been incremented.
+ // It is safe to decrement its refcount
+ // so that it will be destroyed when the entry in study will be removed
+ if (aMeshSO)
+ aMeshVar->Destroy();
+#endif
}
return true;
}
QString aNewGeomGroupName ("Auto_group_for_");
aNewGeomGroupName += aName;
SALOMEDS::SObject_var aNewGroupSO =
- geomGen->AddInStudy(aSMESHGen->GetCurrentStudy(), aGeomVar,
+ geomGen->AddInStudy(aSMESHGen->GetCurrentStudy(), aGeomVar,
aNewGeomGroupName.toLatin1().data(), mainGeom);
}
}
if (aClientLibName == "")
{
// Call hypothesis creation server method (without GUI)
- SMESH::CreateHypothesis(aHypName, aHypData->Label, true);
+ SMESH::SMESH_Hypothesis_var aHyp =
+ SMESH::CreateHypothesis(aHypName, aHypData->Label, true);
+#ifdef WITHGENERICOBJ
+ if (!CORBA::is_nil(aHyp))
+ aHyp->Destroy();
+#endif
}
else
{
// Create algorithm
if (aCreator)
aCreator->create(true, aHypName, myDlg, 0, QString::null );
- else
- SMESH::CreateHypothesis(aHypName, aHypData->Label, true);
+ else {
+ SMESH::SMESH_Hypothesis_var aHyp =
+ SMESH::CreateHypothesis(aHypName, aHypData->Label, true);
+#ifdef WITHGENERICOBJ
+ if (!CORBA::is_nil(aHyp))
+ aHyp->Destroy();
+#endif
+ }
}
QStringList tmpList;
_PTR(SComponent) aFather = SMESH::GetActiveStudyDocument()->FindComponent( "SMESH" );
//================================================================================
/*!
* \brief Verifies whether given operator is valid for this one
- * \param theOtherOp - other operation
- * \return Returns TRUE if the given operator is valid for this one, FALSE otherwise
-*
-* method redefined from base class verifies whether given operator is valid for
-* this one (i.e. can be started "above" this operator). In current implementation method
-* retuns false if theOtherOp operation is not intended for deleting objects or mesh
-* elements.
-*/
+ * \param theOtherOp - other operation
+ * \return Returns TRUE if the given operator is valid for this one, FALSE otherwise
+ *
+ * method redefined from base class verifies whether given operator is valid for
+ * this one (i.e. can be started "above" this operator). In current implementation method
+ * retuns false if theOtherOp operation is not intended for deleting objects or mesh
+ * elements.
+ */
//================================================================================
bool SMESHGUI_MeshOp::isValid( SUIT_Operation* theOp ) const
{
//================================================================================
/*!
* \brief SLOT. Is called when the user selects a way of geometry selection
- * \param theByMesh - true if the user wants to find geometry by mesh element
+ * \param theByMesh - true if the user wants to find geometry by mesh element
*/
//================================================================================
-
void SMESHGUI_MeshOp::onGeomSelectionByMesh( bool theByMesh )
{
if ( theByMesh ) {
* \brief SLOT. Is called when Ok is pressed in SMESHGUI_ShapeByMeshDlg
*/
//================================================================================
-
void SMESHGUI_MeshOp::onPublishShapeByMeshDlg(SUIT_Operation* op)
{
if ( myShapeByMeshOp == op ) {
* \brief SLOT. Is called when Close is pressed in SMESHGUI_ShapeByMeshDlg
*/
//================================================================================
-
void SMESHGUI_MeshOp::onCloseShapeByMeshDlg(SUIT_Operation* op)
{
if ( myShapeByMeshOp == op && myDlg ) {
//================================================================================
/*!
* \brief Selects a SObject
- * \param theSObj - the SObject to select
+ * \param theSObj - the SObject to select
*/
//================================================================================
-
void SMESHGUI_MeshOp::selectObject( _PTR(SObject) theSObj ) const
{
if ( LightApp_SelectionMgr* sm = selectionMgr() ) {