X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FSMESHGUI%2FSMESHGUI_ConvToQuadOp.cxx;h=d41ae1140343bb52cd57fd208b872a1ef1bda24e;hb=e16988d5817fbd1a95bdec89a7307fc3447143e5;hp=a5095e6a923509192faf9fff23c4a5ec60701d7f;hpb=c63ee099ad2b149bd70136839c973e8910137bc5;p=modules%2Fsmesh.git diff --git a/src/SMESHGUI/SMESHGUI_ConvToQuadOp.cxx b/src/SMESHGUI/SMESHGUI_ConvToQuadOp.cxx index a5095e6a9..d41ae1140 100644 --- a/src/SMESHGUI/SMESHGUI_ConvToQuadOp.cxx +++ b/src/SMESHGUI/SMESHGUI_ConvToQuadOp.cxx @@ -1,47 +1,49 @@ -// Copyright (C) 2005 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// Copyright (C) 2007-2011 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 -// +// // This library is free software; you can redistribute it and/or // modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either +// License as published by the Free Software Foundation; either // version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // Lesser General Public License for more details. // -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // -/** -* SMESH SMESHGUI -* -* Copyright (C) 2005 CEA/DEN, EDF R&D -* -* -* -* File : SMESHGUI_ConvToQuadOp.h -* Module : SMESHGUI -*/ +// SMESH SMESHGUI : GUI for SMESH component +// File : SMESHGUI_ConvToQuadOp.cxx +// Author : Open CASCADE S.A.S. +// SMESH includes +// #include "SMESHGUI_ConvToQuadOp.h" -#include "SMESHGUI_ConvToQuadDlg.h" #include "SMESHGUI.h" +#include "SMESHGUI_ConvToQuadDlg.h" #include "SMESHGUI_Utils.h" +#include "SMDSAbs_ElementType.hxx" #include "SMESH_TypeFilter.hxx" -#include "SalomeApp_Tools.h" +// SALOME GUI includes +#include +#include +#include +#include -#include "SUIT_MessageBox.h" +// IDL includes +#include +#include CORBA_SERVER_HEADER(SMESH_MeshEditor) -#include "LightApp_UpdateFlags.h" - //================================================================================ /*! * \brief Constructor @@ -93,10 +95,13 @@ void SMESHGUI_ConvToQuadOp::startOperation() } connect( myDlg, SIGNAL( onClicked( int ) ), SLOT( ConnectRadioButtons( int ) ) ); + myHelpFileName = "convert_to_from_quadratic_mesh_page.html"; + SMESHGUI_SelectionOp::startOperation(); myDlg->SetMediumNdsOnGeom( false ); myDlg->activateObject( 0 ); + myDlg->ShowWarning( false ); myDlg->show(); selectionDone(); @@ -111,28 +116,32 @@ void SMESHGUI_ConvToQuadOp::startOperation() //================================================================================ void SMESHGUI_ConvToQuadOp::selectionDone() { - if ( !dlg()->isShown() ) + if ( !dlg()->isVisible() ) return; SMESHGUI_SelectionOp::selectionDone(); try { - QString anMeshEntry = myDlg->selectedObject( 0 ); - _PTR(SObject) pMesh = studyDS()->FindObjectID( anMeshEntry.latin1() ); - if ( !pMesh ) return; + QString anObjEntry = myDlg->selectedObject( 0 ); + _PTR(SObject) pObj = studyDS()->FindObjectID( anObjEntry.toLatin1().data() ); + if ( !pObj ) return; - SMESH::SMESH_Mesh_var mesh = - SMESH::SObjectToInterface( pMesh ); + SMESH::SMESH_IDSource_var idSource = + SMESH::SObjectToInterface( pObj ); - if( mesh->_is_nil() ) + myDlg->setButtonEnabled( true, QtxDialog::OK | QtxDialog::Apply ); + if( idSource->_is_nil() ) { myDlg->SetEnabledControls( false ); + myDlg->setButtonEnabled( false, QtxDialog::OK | QtxDialog::Apply ); + return; } - else if( ConsistMesh( mesh ) == SMESHGUI_ConvToQuadOp::Quadratic ) + MeshType meshType = ConsistMesh( idSource ); + if( meshType == SMESHGUI_ConvToQuadOp::Quadratic ) { myDlg->SetEnabledRB( 0, false ); } - else if( ConsistMesh( mesh ) == SMESHGUI_ConvToQuadOp::Linear ) + else if( meshType == SMESHGUI_ConvToQuadOp::Linear ) { myDlg->SetEnabledRB( 1, false ); } @@ -140,6 +149,22 @@ void SMESHGUI_ConvToQuadOp::selectionDone() { myDlg->SetEnabledControls( true ); } + + // show warning on non-conformal result mesh + if ( ! idSource->_is_nil() ) + { + SMESH::SMESH_subMesh_var subMesh = + SMESH::SObjectToInterface( pObj ); + bool toShow = false; + if ( !subMesh->_is_nil() ) + { + SMESH::SMESH_Mesh_var mesh = idSource->GetMesh(); + idSource = SMESH::SMESH_IDSource::_narrow( mesh ); + MeshType fullMeshType = ConsistMesh( idSource ); + toShow = ( fullMeshType != Comp ); + } + myDlg->ShowWarning( toShow ); + } } catch ( const SALOME::SALOME_Exception& S_ex ) { @@ -162,7 +187,7 @@ void SMESHGUI_ConvToQuadOp::selectionDone() SUIT_SelectionFilter* SMESHGUI_ConvToQuadOp::createFilter( const int theId ) const { if ( theId == 0 ) - return new SMESH_TypeFilter( MESH ); + return new SMESH_TypeFilter( MESHorSUBMESH ); else return 0; } @@ -176,48 +201,57 @@ SUIT_SelectionFilter* SMESHGUI_ConvToQuadOp::createFilter( const int theId ) con //================================================================================ bool SMESHGUI_ConvToQuadOp::onApply() { + SUIT_OverrideCursor aWaitCursor; QString aMess; - QString anMeshEntry = myDlg->selectedObject( 0 ); - _PTR(SObject) pMesh = studyDS()->FindObjectID( anMeshEntry.latin1() ); - if ( !pMesh ) + QString anObjEntry = myDlg->selectedObject( 0 ); + _PTR(SObject) pObj = studyDS()->FindObjectID( anObjEntry.toLatin1().data() ); + if ( !pObj ) { dlg()->show(); - SUIT_MessageBox::warn1( myDlg, - tr( "SMESH_WRN_WARNING" ), tr("MESH_IS_NOT_SELECTED"), tr( "SMESH_BUT_OK" ) ); - + SUIT_MessageBox::warning( myDlg, + tr( "SMESH_WRN_WARNING" ), tr("MESH_IS_NOT_SELECTED") ); return false; } - SMESH::SMESH_Mesh_var mesh = - SMESH::SObjectToInterface( pMesh ); + SMESH::SMESH_Mesh_var mesh; + SMESH::SMESH_IDSource_var idSource = + SMESH::SObjectToInterface( pObj ); + if( !CORBA::is_nil(idSource) ) + mesh = idSource->GetMesh(); if( CORBA::is_nil(mesh) ) { - SUIT_MessageBox::warn1( myDlg, - tr( "SMESH_WRN_WARNING" ), tr("REF_IS_NULL"), tr( "SMESH_BUT_OK" ) ); - + SUIT_MessageBox::warning( myDlg, + tr( "SMESH_WRN_WARNING" ), tr("REF_IS_NULL") ); return false; - } + } bool aResult = false; try { SMESH::SMESH_MeshEditor_var aEditor = mesh->GetMeshEditor(); + aResult = true; + SMESH::SMESH_Mesh_var sourceMesh = SMESH::SObjectToInterface( pObj ); if( !myDlg->CurrentRB() ) { bool aParam = true; if( myDlg->IsEnabledCheck() ) - aParam = myDlg->IsMediumNdsOnGeom(); + aParam = myDlg->IsMediumNdsOnGeom(); - aEditor->ConvertToQuadratic( aParam ); - aResult = true; + if ( sourceMesh->_is_nil() ) + aEditor->ConvertToQuadraticObject( aParam, idSource ); + else + aEditor->ConvertToQuadratic( aParam ); } else { - aResult = aEditor->ConvertFromQuadratic(); + if ( sourceMesh->_is_nil() ) + aEditor->ConvertFromQuadraticObject( idSource ); + else + aEditor->ConvertFromQuadratic(); } } catch ( const SALOME::SALOME_Exception& S_ex ) @@ -231,6 +265,7 @@ bool SMESHGUI_ConvToQuadOp::onApply() } if( aResult ) { + SMESHGUI::Modified(); update( UF_ObjBrowser | UF_Model | UF_Viewer ); selectionDone(); } @@ -242,45 +277,44 @@ bool SMESHGUI_ConvToQuadOp::onApply() * Determines, what elements this mesh contains. */ //================================================================================ -SMESHGUI_ConvToQuadOp::MeshType SMESHGUI_ConvToQuadOp::ConsistMesh( const SMESH::SMESH_Mesh_var& mesh) const +SMESHGUI_ConvToQuadOp::MeshType SMESHGUI_ConvToQuadOp::ConsistMesh( const SMESH::SMESH_IDSource_var& idSource) const { - int nbAllElem = 0, nbQEdges =0, nbQFaces =0, nbQVolum = 0; - int nbEdges = 0, nbFaces = 0, nbVolum = 0; - - nbAllElem = (int)mesh->NbElements(); - nbQEdges = (int)mesh->NbEdgesOfOrder(SMESH::ORDER_QUADRATIC); - nbQFaces = (int)mesh->NbFacesOfOrder(SMESH::ORDER_QUADRATIC); - nbQVolum = (int)mesh->NbVolumesOfOrder(SMESH::ORDER_QUADRATIC); - - nbEdges = (int)mesh->NbEdgesOfOrder(SMESH::ORDER_LINEAR); - nbFaces = (int)mesh->NbFacesOfOrder(SMESH::ORDER_LINEAR); - nbVolum = (int)mesh->NbVolumesOfOrder(SMESH::ORDER_LINEAR); - - if( nbAllElem == (nbQEdges+nbQFaces+nbQVolum) ) - return SMESHGUI_ConvToQuadOp::Quadratic; - else if ( nbAllElem == (nbEdges+nbFaces+nbVolum) ) - return SMESHGUI_ConvToQuadOp::Linear; - else - return SMESHGUI_ConvToQuadOp::Comp; + SMESH::long_array_var nbElemOfType = idSource->GetMeshInfo(); + bool hasQuad = ( nbElemOfType[SMDSEntity_Quad_Edge ] || + nbElemOfType[SMDSEntity_Quad_Triangle ] || + nbElemOfType[SMDSEntity_Quad_Quadrangle] || + nbElemOfType[SMDSEntity_Quad_Tetra ] || + nbElemOfType[SMDSEntity_Quad_Hexa ] || + nbElemOfType[SMDSEntity_Quad_Pyramid ] || + nbElemOfType[SMDSEntity_Quad_Penta ] ); + + bool hasLin = ( nbElemOfType[SMDSEntity_Edge ] || + nbElemOfType[SMDSEntity_Triangle ] || + nbElemOfType[SMDSEntity_Quadrangle] || + nbElemOfType[SMDSEntity_Tetra ] || + nbElemOfType[SMDSEntity_Hexa ] || + nbElemOfType[SMDSEntity_Pyramid ] || + nbElemOfType[SMDSEntity_Penta ] ); + + if ( hasQuad && hasLin ) + return Comp; + return hasQuad ? Quadratic : Linear; } - void SMESHGUI_ConvToQuadOp::ConnectRadioButtons( int id ) { - QString anMeshEntry = myDlg->selectedObject( 0 ); - _PTR(SObject) pMesh = studyDS()->FindObjectID( anMeshEntry.latin1() ); - if ( !pMesh ) return; + QString anObjEntry = myDlg->selectedObject( 0 ); + _PTR(SObject) pObj = studyDS()->FindObjectID( anObjEntry.toLatin1().data() ); + if ( !pObj ) return; - SMESH::SMESH_Mesh_var mesh = - SMESH::SObjectToInterface( pMesh ); + SMESH::SMESH_IDSource_var idSource = + SMESH::SObjectToInterface( pObj ); + SMESH::SMESH_Mesh_var mesh = idSource->GetMesh(); - GEOM::GEOM_Object_var mainGeom; - mainGeom = mesh->GetShapeToMesh(); + bool hasGeom = mesh->HasShapeToMesh(); - if( id || mainGeom->_is_nil() ) + if( id || !hasGeom ) myDlg->SetEnabledCheck( false ); else myDlg->SetEnabledCheck( true ); } - -