mirror of
https://git.salome-platform.org/gitpub/modules/smesh.git
synced 2024-12-29 10:50:34 +05:00
PAL11428. Implement SMESHGUI_ShapeByMeshOp operation
This commit is contained in:
parent
09762cc854
commit
e2a6b8c40e
@ -96,7 +96,7 @@ SMESHGUI_MeshOp::SMESHGUI_MeshOp( const bool theToCreate, const bool theIsMesh )
|
|||||||
myToCreate( theToCreate ),
|
myToCreate( theToCreate ),
|
||||||
myIsMesh( theIsMesh ),
|
myIsMesh( theIsMesh ),
|
||||||
myDlg( 0 ),
|
myDlg( 0 ),
|
||||||
myShapeByMeshDlg( 0 )
|
myShapeByMeshOp( 0 )
|
||||||
{
|
{
|
||||||
if ( GeometryGUI::GetGeomGen()->_is_nil() )// check that GEOM_Gen exists
|
if ( GeometryGUI::GetGeomGen()->_is_nil() )// check that GEOM_Gen exists
|
||||||
GeometryGUI::InitGeomGen();
|
GeometryGUI::InitGeomGen();
|
||||||
@ -243,10 +243,10 @@ void SMESHGUI_MeshOp::startOperation()
|
|||||||
|
|
||||||
myDlg->setHypoSets( SMESH::GetHypothesesSets() );
|
myDlg->setHypoSets( SMESH::GetHypothesesSets() );
|
||||||
|
|
||||||
selectionDone();
|
|
||||||
|
|
||||||
myDlg->setCurrentTab( SMESH::DIM_1D );
|
myDlg->setCurrentTab( SMESH::DIM_1D );
|
||||||
myDlg->show();
|
myDlg->show();
|
||||||
|
|
||||||
|
selectionDone();
|
||||||
}
|
}
|
||||||
|
|
||||||
//================================================================================
|
//================================================================================
|
||||||
@ -384,7 +384,7 @@ _PTR(SObject) SMESHGUI_MeshOp::getSubmeshByGeom() const
|
|||||||
//================================================================================
|
//================================================================================
|
||||||
void SMESHGUI_MeshOp::selectionDone()
|
void SMESHGUI_MeshOp::selectionDone()
|
||||||
{
|
{
|
||||||
if ( myShapeByMeshDlg && myShapeByMeshDlg->isShown() )
|
if ( !dlg()->isShown() )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
SMESHGUI_SelectionOp::selectionDone();
|
SMESHGUI_SelectionOp::selectionDone();
|
||||||
@ -482,7 +482,7 @@ void SMESHGUI_MeshOp::selectionDone()
|
|||||||
SMESH::SMESH_Mesh_var mesh = SMESH::SObjectToInterface<SMESH::SMESH_Mesh>( pMesh );
|
SMESH::SMESH_Mesh_var mesh = SMESH::SObjectToInterface<SMESH::SMESH_Mesh>( pMesh );
|
||||||
if ( !mesh->_is_nil() )
|
if ( !mesh->_is_nil() )
|
||||||
enable = ( shapeDim > 1 ) && ( mesh->NbEdges() > 0 );
|
enable = ( shapeDim > 1 ) && ( mesh->NbEdges() > 0 );
|
||||||
}
|
}
|
||||||
myDlg->setGeomPopupEnabled( enable );
|
myDlg->setGeomPopupEnabled( enable );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1471,22 +1471,24 @@ bool SMESHGUI_MeshOp::isValid( SUIT_Operation* theOp ) const
|
|||||||
void SMESHGUI_MeshOp::onGeomSelectionByMesh( bool theByMesh )
|
void SMESHGUI_MeshOp::onGeomSelectionByMesh( bool theByMesh )
|
||||||
{
|
{
|
||||||
if ( theByMesh ) {
|
if ( theByMesh ) {
|
||||||
if ( !myShapeByMeshDlg ) {
|
if ( !myShapeByMeshOp ) {
|
||||||
myShapeByMeshDlg = new SMESHGUI_ShapeByMeshDlg( SMESHGUI::GetSMESHGUI(), "ShapeByMeshDlg");
|
myShapeByMeshOp = new SMESHGUI_ShapeByMeshOp();
|
||||||
connect(myShapeByMeshDlg, SIGNAL(PublishShape()), SLOT(onPublishShapeByMeshDlg()));
|
connect(myShapeByMeshOp, SIGNAL(committed(SUIT_Operation*)),
|
||||||
connect(myShapeByMeshDlg, SIGNAL(Close()), SLOT(onCloseShapeByMeshDlg()));
|
SLOT(onPublishShapeByMeshDlg(SUIT_Operation*)));
|
||||||
|
connect(myShapeByMeshOp, SIGNAL(aborted(SUIT_Operation*)),
|
||||||
|
SLOT(onCloseShapeByMeshDlg(SUIT_Operation*)));
|
||||||
}
|
}
|
||||||
// set mesh object to dlg
|
// set mesh object to SMESHGUI_ShapeByMeshOp and start it
|
||||||
QString aMeshEntry = myDlg->selectedObject( SMESHGUI_MeshDlg::Mesh );
|
QString aMeshEntry = myDlg->selectedObject( SMESHGUI_MeshDlg::Mesh );
|
||||||
if ( _PTR(SObject) pMesh = studyDS()->FindObjectID( aMeshEntry.latin1() )) {
|
if ( _PTR(SObject) pMesh = studyDS()->FindObjectID( aMeshEntry.latin1() )) {
|
||||||
SMESH::SMESH_Mesh_var aMeshVar =
|
SMESH::SMESH_Mesh_var aMeshVar =
|
||||||
SMESH::SMESH_Mesh::_narrow( _CAST( SObject,pMesh )->GetObject() );
|
SMESH::SMESH_Mesh::_narrow( _CAST( SObject,pMesh )->GetObject() );
|
||||||
if ( !aMeshVar->_is_nil() ) {
|
if ( !aMeshVar->_is_nil() ) {
|
||||||
myDlg->hide();
|
myDlg->hide();
|
||||||
myDlg->activateObject( SMESHGUI_MeshDlg::Mesh );
|
myShapeByMeshOp->setModule( getSMESHGUI() );
|
||||||
myShapeByMeshDlg->Init();
|
myShapeByMeshOp->setStudy( 0 );
|
||||||
myShapeByMeshDlg->SetMesh( aMeshVar );
|
myShapeByMeshOp->SetMesh( aMeshVar );
|
||||||
myShapeByMeshDlg->show();
|
myShapeByMeshOp->start();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1498,32 +1500,21 @@ void SMESHGUI_MeshOp::onGeomSelectionByMesh( bool theByMesh )
|
|||||||
*/
|
*/
|
||||||
//================================================================================
|
//================================================================================
|
||||||
|
|
||||||
void SMESHGUI_MeshOp::onPublishShapeByMeshDlg()
|
void SMESHGUI_MeshOp::onPublishShapeByMeshDlg(SUIT_Operation* op)
|
||||||
{
|
{
|
||||||
if ( myShapeByMeshDlg ) {
|
if ( myShapeByMeshOp == op ) {
|
||||||
|
myDlg->show();
|
||||||
// Select a found geometry object
|
// Select a found geometry object
|
||||||
GEOM::GEOM_Object_var aGeomVar = myShapeByMeshDlg->GetShape();
|
GEOM::GEOM_Object_var aGeomVar = myShapeByMeshOp->GetShape();
|
||||||
if ( !aGeomVar->_is_nil() )
|
if ( !aGeomVar->_is_nil() )
|
||||||
{
|
{
|
||||||
QString ID = aGeomVar->GetStudyEntry();
|
QString ID = aGeomVar->GetStudyEntry();
|
||||||
if ( _PTR(SObject) aGeomSO = studyDS()->FindObjectID( ID.latin1() )) {
|
if ( _PTR(SObject) aGeomSO = studyDS()->FindObjectID( ID.latin1() )) {
|
||||||
SMESH::SMESH_Mesh_ptr aMeshPtr = myShapeByMeshDlg->GetMesh();
|
|
||||||
if ( !CORBA::is_nil( aMeshPtr )) {
|
|
||||||
if (_PTR(SObject) aMeshSO = SMESH::FindSObject( aMeshPtr )) {
|
|
||||||
myDlg->activateObject( SMESHGUI_MeshDlg::Mesh );
|
|
||||||
myDlg->selectObject( aMeshSO->GetName().c_str(), SMESHGUI_MeshDlg::Mesh, aMeshSO->GetID().c_str() );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
myDlg->activateObject( SMESHGUI_MeshDlg::Geom );
|
|
||||||
selectObject( aGeomSO );
|
selectObject( aGeomSO );
|
||||||
//selectionDone();
|
selectionDone();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
|
||||||
onCloseShapeByMeshDlg();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
myDlg->show();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//================================================================================
|
//================================================================================
|
||||||
@ -1532,12 +1523,10 @@ void SMESHGUI_MeshOp::onPublishShapeByMeshDlg()
|
|||||||
*/
|
*/
|
||||||
//================================================================================
|
//================================================================================
|
||||||
|
|
||||||
void SMESHGUI_MeshOp::onCloseShapeByMeshDlg()
|
void SMESHGUI_MeshOp::onCloseShapeByMeshDlg(SUIT_Operation* op)
|
||||||
{
|
{
|
||||||
if ( myDlg ) {
|
if ( myShapeByMeshOp == op && myDlg ) {
|
||||||
myDlg->show();
|
myDlg->show();
|
||||||
myDlg->activateObject( SMESHGUI_MeshDlg::Geom );
|
|
||||||
myDlg->selectObject( "", SMESHGUI_MeshDlg::Geom, "" );
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -40,7 +40,7 @@
|
|||||||
#include CORBA_SERVER_HEADER(SMESH_Mesh)
|
#include CORBA_SERVER_HEADER(SMESH_Mesh)
|
||||||
|
|
||||||
class SMESHGUI_MeshDlg;
|
class SMESHGUI_MeshDlg;
|
||||||
class SMESHGUI_ShapeByMeshDlg;
|
class SMESHGUI_ShapeByMeshOp;
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* \brief Operation for mech creation or editing
|
* \brief Operation for mech creation or editing
|
||||||
@ -71,8 +71,8 @@ protected slots:
|
|||||||
void onEditHyp( const int theHypType, const int theIndex );
|
void onEditHyp( const int theHypType, const int theIndex );
|
||||||
void onHypoSet( const QString& theSetName );
|
void onHypoSet( const QString& theSetName );
|
||||||
void onGeomSelectionByMesh( bool );
|
void onGeomSelectionByMesh( bool );
|
||||||
void onPublishShapeByMeshDlg();
|
void onPublishShapeByMeshDlg(SUIT_Operation*);
|
||||||
void onCloseShapeByMeshDlg();
|
void onCloseShapeByMeshDlg(SUIT_Operation*);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool isValid( QString& ) const;
|
bool isValid( QString& ) const;
|
||||||
@ -109,7 +109,7 @@ private:
|
|||||||
typedef QMap< int, IdToHypListMap > DimToHypMap;
|
typedef QMap< int, IdToHypListMap > DimToHypMap;
|
||||||
|
|
||||||
SMESHGUI_MeshDlg* myDlg;
|
SMESHGUI_MeshDlg* myDlg;
|
||||||
SMESHGUI_ShapeByMeshDlg* myShapeByMeshDlg;
|
SMESHGUI_ShapeByMeshOp* myShapeByMeshOp;
|
||||||
bool myToCreate;
|
bool myToCreate;
|
||||||
bool myIsMesh;
|
bool myIsMesh;
|
||||||
|
|
||||||
|
@ -76,28 +76,18 @@ enum { EDGE = 0, FACE, VOLUME };
|
|||||||
* \brief Dialog to publish a sub-shape of the mesh main shape
|
* \brief Dialog to publish a sub-shape of the mesh main shape
|
||||||
* by selecting mesh elements
|
* by selecting mesh elements
|
||||||
*/
|
*/
|
||||||
SMESHGUI_ShapeByMeshDlg::SMESHGUI_ShapeByMeshDlg( SMESHGUI* theModule,
|
SMESHGUI_ShapeByMeshDlg::SMESHGUI_ShapeByMeshDlg()
|
||||||
const char* theName)
|
: SMESHGUI_Dialog( 0, false, true, OK | Close )
|
||||||
: QDialog( SMESH::GetDesktop( theModule ), theName, false,
|
|
||||||
WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu),
|
|
||||||
mySMESHGUI( theModule ),
|
|
||||||
mySelectionMgr( SMESH::GetSelectionMgr( theModule ) )
|
|
||||||
{
|
{
|
||||||
setCaption(tr("CAPTION"));
|
setCaption(tr("CAPTION"));
|
||||||
|
|
||||||
QVBoxLayout* aDlgLay = new QVBoxLayout (this, MARGIN, SPACING);
|
QVBoxLayout* aDlgLay = new QVBoxLayout (mainFrame(), MARGIN, SPACING);
|
||||||
|
|
||||||
QFrame* aMainFrame = createMainFrame (this);
|
QFrame* aMainFrame = createMainFrame (mainFrame());
|
||||||
QFrame* aBtnFrame = createButtonFrame(this);
|
|
||||||
|
|
||||||
aDlgLay->addWidget(aMainFrame);
|
aDlgLay->addWidget(aMainFrame);
|
||||||
aDlgLay->addWidget(aBtnFrame);
|
|
||||||
|
|
||||||
aDlgLay->setStretchFactor(aMainFrame, 1);
|
aDlgLay->setStretchFactor(aMainFrame, 1);
|
||||||
|
|
||||||
myViewWindow = SMESH::GetViewWindow( mySMESHGUI );
|
|
||||||
|
|
||||||
Init();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//=======================================================================
|
//=======================================================================
|
||||||
@ -137,38 +127,9 @@ QFrame* SMESHGUI_ShapeByMeshDlg::createMainFrame (QWidget* theParent)
|
|||||||
aLayout->addWidget(aNameLabel, 2, 0);
|
aLayout->addWidget(aNameLabel, 2, 0);
|
||||||
aLayout->addWidget(myGeomName, 2, 1);
|
aLayout->addWidget(myGeomName, 2, 1);
|
||||||
|
|
||||||
connect(myElemTypeGroup, SIGNAL(clicked(int)), SLOT(onTypeChanged(int)));
|
|
||||||
connect(myElementId, SIGNAL(textChanged(const QString&)), SLOT(onElemIdChanged(const QString&)));
|
|
||||||
|
|
||||||
return aMainGrp;
|
return aMainGrp;
|
||||||
}
|
}
|
||||||
|
|
||||||
//=======================================================================
|
|
||||||
// function : createButtonFrame()
|
|
||||||
// purpose : Create frame containing buttons
|
|
||||||
//=======================================================================
|
|
||||||
QFrame* SMESHGUI_ShapeByMeshDlg::createButtonFrame (QWidget* theParent)
|
|
||||||
{
|
|
||||||
QFrame* aFrame = new QFrame(theParent);
|
|
||||||
aFrame->setFrameStyle(QFrame::Box | QFrame::Sunken);
|
|
||||||
|
|
||||||
myOkBtn = new QPushButton(tr("SMESH_BUT_OK" ), aFrame);
|
|
||||||
myCloseBtn = new QPushButton(tr("SMESH_BUT_CLOSE"), aFrame);
|
|
||||||
|
|
||||||
QSpacerItem* aSpacer = new QSpacerItem(0, 0, QSizePolicy::Expanding, QSizePolicy::Minimum);
|
|
||||||
|
|
||||||
QHBoxLayout* aLay = new QHBoxLayout(aFrame, MARGIN, SPACING);
|
|
||||||
|
|
||||||
aLay->addWidget(myOkBtn);
|
|
||||||
aLay->addItem(aSpacer);
|
|
||||||
aLay->addWidget(myCloseBtn);
|
|
||||||
|
|
||||||
connect(myOkBtn, SIGNAL(clicked()), SLOT(onOk()));
|
|
||||||
connect(myCloseBtn, SIGNAL(clicked()), SLOT(onClose()));
|
|
||||||
|
|
||||||
return aFrame;
|
|
||||||
}
|
|
||||||
|
|
||||||
//=======================================================================
|
//=======================================================================
|
||||||
// function : ~SMESHGUI_ShapeByMeshDlg()
|
// function : ~SMESHGUI_ShapeByMeshDlg()
|
||||||
// purpose : Destructor
|
// purpose : Destructor
|
||||||
@ -178,33 +139,73 @@ SMESHGUI_ShapeByMeshDlg::~SMESHGUI_ShapeByMeshDlg()
|
|||||||
// no need to delete child widgets, Qt does it all for us
|
// no need to delete child widgets, Qt does it all for us
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//================================================================================
|
||||||
|
/*!
|
||||||
|
* \brief Constructor
|
||||||
|
* \param theToCreate - if this parameter is true then operation is used for creation,
|
||||||
|
* for editing otherwise
|
||||||
|
*
|
||||||
|
* Initialize operation
|
||||||
|
*/
|
||||||
|
//================================================================================
|
||||||
|
SMESHGUI_ShapeByMeshOp::SMESHGUI_ShapeByMeshOp()
|
||||||
|
{
|
||||||
|
if ( GeometryGUI::GetGeomGen()->_is_nil() )// check that GEOM_Gen exists
|
||||||
|
GeometryGUI::InitGeomGen();
|
||||||
|
|
||||||
|
myDlg = new SMESHGUI_ShapeByMeshDlg;
|
||||||
|
|
||||||
|
connect(myDlg->myElemTypeGroup, SIGNAL(clicked(int)), SLOT(onTypeChanged(int)));
|
||||||
|
connect(myDlg->myElementId, SIGNAL(textChanged(const QString&)), SLOT(onElemIdChanged(const QString&)));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
//=======================================================================
|
//=======================================================================
|
||||||
// function : Init()
|
// function : startOperation()
|
||||||
// purpose : Init dialog fields, connect signals and slots, show dialog
|
// purpose : Init dialog fields, connect signals and slots, show dialog
|
||||||
//=======================================================================
|
//=======================================================================
|
||||||
void SMESHGUI_ShapeByMeshDlg::Init()
|
void SMESHGUI_ShapeByMeshOp::startOperation()
|
||||||
{
|
{
|
||||||
SetMesh( SMESH::SMESH_Mesh::_nil() );
|
//SetMesh( SMESH::SMESH_Mesh::_nil() );
|
||||||
myIsManualIdEnter = false;
|
myIsManualIdEnter = false;
|
||||||
|
|
||||||
//erasePreview();
|
SMESHGUI_SelectionOp::startOperation();
|
||||||
|
|
||||||
mySMESHGUI->SetActiveDialogBox((QDialog*)this);
|
//activateSelection(); // set filters
|
||||||
|
onSelectionDone(); // desable/enable [ OK ]
|
||||||
|
|
||||||
// selection and SMESHGUI
|
myDlg->show();
|
||||||
connect(mySMESHGUI, SIGNAL(SignalDeactivateActiveDialog()), SLOT(onDeactivate()));
|
}
|
||||||
connect(mySMESHGUI, SIGNAL(SignalCloseAllDialogs()), SLOT(onClose()));
|
|
||||||
|
|
||||||
setSizePolicy(QSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding));
|
//================================================================================
|
||||||
qApp->processEvents();
|
/*!
|
||||||
updateGeometry();
|
* \brief Destructor
|
||||||
adjustSize();
|
*/
|
||||||
resize(minimumSize());
|
//================================================================================
|
||||||
|
SMESHGUI_ShapeByMeshOp::~SMESHGUI_ShapeByMeshOp()
|
||||||
|
{
|
||||||
|
if ( myDlg )
|
||||||
|
delete myDlg;
|
||||||
|
}
|
||||||
|
|
||||||
activateSelection();
|
//================================================================================
|
||||||
onSelectionDone();
|
/*!
|
||||||
|
* \brief Gets dialog of this operation
|
||||||
this->show();
|
* \retval LightApp_Dialog* - pointer to dialog of this operation
|
||||||
|
*/
|
||||||
|
//================================================================================
|
||||||
|
LightApp_Dialog* SMESHGUI_ShapeByMeshOp::dlg() const
|
||||||
|
{
|
||||||
|
return myDlg;
|
||||||
|
}
|
||||||
|
|
||||||
|
//=======================================================================
|
||||||
|
// function : GetShape()
|
||||||
|
// purpose : Get published sub-shape
|
||||||
|
//=======================================================================
|
||||||
|
GEOM::GEOM_Object_ptr SMESHGUI_ShapeByMeshOp::GetShape()
|
||||||
|
{
|
||||||
|
return myGeomObj.in();
|
||||||
}
|
}
|
||||||
|
|
||||||
//=======================================================================
|
//=======================================================================
|
||||||
@ -212,28 +213,26 @@ void SMESHGUI_ShapeByMeshDlg::Init()
|
|||||||
// purpose : Set mesh to dialog
|
// purpose : Set mesh to dialog
|
||||||
//=======================================================================
|
//=======================================================================
|
||||||
|
|
||||||
void SMESHGUI_ShapeByMeshDlg::SetMesh (SMESH::SMESH_Mesh_ptr thePtr)
|
void SMESHGUI_ShapeByMeshOp::SetMesh (SMESH::SMESH_Mesh_ptr thePtr)
|
||||||
{
|
{
|
||||||
myMesh = SMESH::SMESH_Mesh::_duplicate(thePtr);
|
myMesh = SMESH::SMESH_Mesh::_duplicate(thePtr);
|
||||||
myGeomObj = GEOM::GEOM_Object::_nil();
|
myGeomObj = GEOM::GEOM_Object::_nil();
|
||||||
myHasSolids = false;
|
myHasSolids = false;
|
||||||
|
|
||||||
vector< bool > hasElement (myElemTypeGroup->count(), false);
|
vector< bool > hasElement (myDlg->myElemTypeGroup->count(), false);
|
||||||
if (!myMesh->_is_nil() && myViewWindow )
|
if (!myMesh->_is_nil() )
|
||||||
{
|
{
|
||||||
_PTR(SObject) aSobj = SMESH::FindSObject(myMesh.in());
|
// _PTR(SObject) aSobj = SMESH::FindSObject(myMesh.in());
|
||||||
SUIT_DataOwnerPtr anIObj (new LightApp_DataOwner(aSobj->GetID().c_str()));
|
// SUIT_DataOwnerPtr anIObj (new LightApp_DataOwner(aSobj->GetID().c_str()));
|
||||||
|
|
||||||
vector< int > nbShapes( TopAbs_SHAPE, 0 );
|
vector< int > nbShapes( TopAbs_SHAPE, 0 );
|
||||||
int shapeDim = 0; // max dim with several shapes
|
int shapeDim = 0; // max dim with several shapes
|
||||||
if ( mySelectionMgr->isOk(anIObj) ) // check that the mesh has a valid shape
|
//if ( /*mySelectionMgr*/ selectionMgr()->isOk(anIObj) ) // check that the mesh has a valid shape
|
||||||
{
|
{
|
||||||
_PTR(SObject) aSO = SMESH::FindSObject(myMesh.in());
|
_PTR(SObject) aSO = SMESH::FindSObject(myMesh.in());
|
||||||
GEOM::GEOM_Object_var mainShape = SMESH::GetGeom(aSO);
|
GEOM::GEOM_Object_var mainShape = SMESH::GetGeom(aSO);
|
||||||
if ( !mainShape->_is_nil() )
|
if ( !mainShape->_is_nil() )
|
||||||
{
|
{
|
||||||
if ( GeometryGUI::GetGeomGen()->_is_nil() )// check that GEOM_Gen exists
|
|
||||||
GeometryGUI::InitGeomGen();
|
|
||||||
TopoDS_Shape aShape;
|
TopoDS_Shape aShape;
|
||||||
if ( GEOMBase::GetShape(mainShape, aShape))
|
if ( GEOMBase::GetShape(mainShape, aShape))
|
||||||
{
|
{
|
||||||
@ -259,86 +258,54 @@ void SMESHGUI_ShapeByMeshDlg::SetMesh (SMESH::SMESH_Mesh_ptr thePtr)
|
|||||||
hasElement[ EDGE ] = shapeDim > 0 && myMesh->NbEdges() ;
|
hasElement[ EDGE ] = shapeDim > 0 && myMesh->NbEdges() ;
|
||||||
hasElement[ FACE ] = shapeDim > 1 && myMesh->NbFaces() ;
|
hasElement[ FACE ] = shapeDim > 1 && myMesh->NbFaces() ;
|
||||||
hasElement[ VOLUME ] = shapeDim > 2 && myMesh->NbVolumes();
|
hasElement[ VOLUME ] = shapeDim > 2 && myMesh->NbVolumes();
|
||||||
|
|
||||||
if ( hasElement[ EDGE ] && myViewWindow->GetSelector() )
|
|
||||||
{
|
|
||||||
connect(mySelectionMgr, SIGNAL(currentSelectionChanged()), SLOT(onSelectionDone()));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
myHasSolids = nbShapes[ TopAbs_SOLID ];
|
myHasSolids = nbShapes[ TopAbs_SOLID ];
|
||||||
}
|
}
|
||||||
|
|
||||||
// disable inexistant elem types
|
// disable inexistant elem types
|
||||||
for ( int i = 0; i < myElemTypeGroup->count(); ++i ) {
|
for ( int i = 0; i < myDlg->myElemTypeGroup->count(); ++i ) {
|
||||||
if ( QButton* button = myElemTypeGroup->find( i ) )
|
if ( QButton* button = myDlg->myElemTypeGroup->find( i ) )
|
||||||
button->setEnabled( hasElement[ i ] );
|
button->setEnabled( hasElement[ i ] );
|
||||||
}
|
}
|
||||||
myElementId->setEnabled( hasElement[ EDGE ] );
|
myDlg->myElementId->setEnabled( hasElement[ EDGE ] );
|
||||||
myGeomName-> setEnabled( hasElement[ EDGE ] );
|
myDlg->myGeomName-> setEnabled( hasElement[ EDGE ] );
|
||||||
|
|
||||||
setElementID("");
|
setElementID("");
|
||||||
}
|
}
|
||||||
|
|
||||||
//=======================================================================
|
//=======================================================================
|
||||||
// function : GetShape()
|
// function : commitOperation()
|
||||||
// purpose : Get published sub-shape
|
// purpose : called when "Ok" button pressed.
|
||||||
//=======================================================================
|
//=======================================================================
|
||||||
GEOM::GEOM_Object_ptr SMESHGUI_ShapeByMeshDlg::GetShape()
|
|
||||||
{
|
|
||||||
return myGeomObj.in();
|
|
||||||
}
|
|
||||||
|
|
||||||
//=======================================================================
|
void SMESHGUI_ShapeByMeshOp::commitOperation()
|
||||||
// function : onOk()
|
|
||||||
// purpose : SLOT called when "Ok" button pressed.
|
|
||||||
//=======================================================================
|
|
||||||
void SMESHGUI_ShapeByMeshDlg::onOk()
|
|
||||||
{
|
{
|
||||||
|
SMESHGUI_SelectionOp::commitOperation();
|
||||||
try {
|
try {
|
||||||
int elemID = myElementId->text().toInt();
|
int elemID = myDlg->myElementId->text().toInt();
|
||||||
myGeomObj = SMESHGUI::GetSMESHGen()->GetGeometryByMeshElement
|
myGeomObj = SMESHGUI::GetSMESHGen()->GetGeometryByMeshElement
|
||||||
( myMesh.in(), elemID, myGeomName->text().latin1());
|
( myMesh.in(), elemID, myDlg->myGeomName->text().latin1());
|
||||||
|
|
||||||
accept();
|
|
||||||
emit PublishShape();
|
|
||||||
}
|
}
|
||||||
catch (const SALOME::SALOME_Exception& S_ex) {
|
catch (const SALOME::SALOME_Exception& S_ex) {
|
||||||
SalomeApp_Tools::QtCatchCorbaException(S_ex);
|
SalomeApp_Tools::QtCatchCorbaException(S_ex);
|
||||||
}
|
}
|
||||||
catch (...) {
|
catch (...) {
|
||||||
}
|
}
|
||||||
myViewWindow->SetSelectionMode( ActorSelection );
|
|
||||||
disconnect(mySelectionMgr, 0, this, 0);
|
|
||||||
disconnect(mySMESHGUI, 0, this, 0);
|
|
||||||
mySMESHGUI->ResetState();
|
|
||||||
}
|
|
||||||
|
|
||||||
//=======================================================================
|
|
||||||
// function : onClose()
|
|
||||||
// purpose : SLOT called when "Close" button pressed. Close dialog
|
|
||||||
//=======================================================================
|
|
||||||
void SMESHGUI_ShapeByMeshDlg::onClose()
|
|
||||||
{
|
|
||||||
myViewWindow->SetSelectionMode( ActorSelection );
|
|
||||||
disconnect(mySelectionMgr, 0, this, 0);
|
|
||||||
disconnect(mySMESHGUI, 0, this, 0);
|
|
||||||
mySMESHGUI->ResetState();
|
|
||||||
reject();
|
|
||||||
emit Close();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//=======================================================================
|
//=======================================================================
|
||||||
// function : onSelectionDone()
|
// function : onSelectionDone()
|
||||||
// purpose : SLOT called when selection changed
|
// purpose : SLOT called when selection changed. Enable/desable [ OK ]
|
||||||
//=======================================================================
|
//=======================================================================
|
||||||
void SMESHGUI_ShapeByMeshDlg::onSelectionDone()
|
void SMESHGUI_ShapeByMeshOp::onSelectionDone()
|
||||||
{
|
{
|
||||||
myOkBtn->setEnabled( false );
|
myDlg->setButtonEnabled( false, QtxDialog::OK );
|
||||||
setElementID("");
|
setElementID("");
|
||||||
|
|
||||||
try {
|
try {
|
||||||
SALOME_ListIO aList;
|
SALOME_ListIO aList;
|
||||||
mySelectionMgr->selectedObjects(aList, SVTK_Viewer::Type());
|
selectionMgr()->selectedObjects(aList, SVTK_Viewer::Type());
|
||||||
if (aList.Extent() != 1)
|
if (aList.Extent() != 1)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@ -347,82 +314,42 @@ void SMESHGUI_ShapeByMeshDlg::onSelectionDone()
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
QString aString;
|
QString aString;
|
||||||
int nbElems = SMESH::GetNameOfSelectedElements(myViewWindow->GetSelector(),
|
int nbElems = SMESH::GetNameOfSelectedElements(selector(),//myViewWindow->GetSelector(),
|
||||||
aList.First(), aString);
|
aList.First(), aString);
|
||||||
if ( nbElems == 1 ) {
|
if ( nbElems == 1 ) {
|
||||||
setElementID( aString );
|
setElementID( aString );
|
||||||
myOkBtn->setEnabled( true );
|
myDlg->setButtonEnabled( true, QtxDialog::OK );
|
||||||
}
|
}
|
||||||
} catch (...) {
|
} catch (...) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//=======================================================================
|
|
||||||
// function : onDeactivate()
|
|
||||||
// purpose : SLOT called when dialog must be deativated
|
|
||||||
//=======================================================================
|
|
||||||
void SMESHGUI_ShapeByMeshDlg::onDeactivate()
|
|
||||||
{
|
|
||||||
if ( isEnabled() ) {
|
|
||||||
//disconnect(mySelectionMgr, 0, this, 0);
|
|
||||||
myViewWindow->SetSelectionMode( ActorSelection );
|
|
||||||
setEnabled(false);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//=======================================================================
|
|
||||||
// function : enterEvent()
|
|
||||||
// purpose : Event filter
|
|
||||||
//=======================================================================
|
|
||||||
void SMESHGUI_ShapeByMeshDlg::enterEvent (QEvent*)
|
|
||||||
{
|
|
||||||
// there is a stange problem that enterEvent() comes after onSave()
|
|
||||||
if ( isVisible () && !isEnabled() ) {
|
|
||||||
mySMESHGUI->EmitSignalDeactivateDialog();
|
|
||||||
setEnabled(true);
|
|
||||||
activateSelection();
|
|
||||||
//connect(mySelectionMgr, SIGNAL(currentSelectionChanged()), SLOT(onSelectionDone()));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//=================================================================================
|
|
||||||
// function : closeEvent()
|
|
||||||
// purpose : Close dialog box
|
|
||||||
//=================================================================================
|
|
||||||
void SMESHGUI_ShapeByMeshDlg::closeEvent (QCloseEvent*)
|
|
||||||
{
|
|
||||||
onClose();
|
|
||||||
}
|
|
||||||
|
|
||||||
//=======================================================================
|
//=======================================================================
|
||||||
// function : activateSelection()
|
// function : activateSelection()
|
||||||
// purpose : Activate selection in accordance with current pattern type
|
// purpose : Activate selection in accordance with current pattern type
|
||||||
//=======================================================================
|
//=======================================================================
|
||||||
void SMESHGUI_ShapeByMeshDlg::activateSelection()
|
void SMESHGUI_ShapeByMeshOp::activateSelection()
|
||||||
{
|
{
|
||||||
mySelectionMgr->clearFilters();
|
selectionMgr()->clearFilters();
|
||||||
SMESH::SetPointRepresentation(false);
|
//SMESH::SetPointRepresentation(false);
|
||||||
|
|
||||||
myGeomName->setText("");
|
myDlg->myGeomName->setText("");
|
||||||
|
|
||||||
if ( myViewWindow )
|
QString geomName;
|
||||||
{
|
Selection_Mode mode = EdgeSelection;
|
||||||
QString geomName;
|
switch ( myDlg->myElemTypeGroup->id( myDlg->myElemTypeGroup->selected() )) {
|
||||||
Selection_Mode mode = EdgeSelection;
|
case EDGE :
|
||||||
switch ( myElemTypeGroup->id( myElemTypeGroup->selected() )) {
|
mode = EdgeSelection; geomName = tr("GEOM_EDGE"); break;
|
||||||
case EDGE :
|
case FACE :
|
||||||
mode = EdgeSelection; geomName = tr("GEOM_EDGE"); break;
|
mode = FaceSelection; geomName = tr("GEOM_FACE"); break;
|
||||||
case FACE :
|
case VOLUME:
|
||||||
mode = FaceSelection; geomName = tr("GEOM_FACE"); break;
|
mode = VolumeSelection; geomName = tr(myHasSolids ? "GEOM_SOLID" : "GEOM_SHELL"); break;
|
||||||
case VOLUME:
|
default: return;
|
||||||
mode = VolumeSelection; geomName = tr(myHasSolids ? "GEOM_SOLID" : "GEOM_SHELL"); break;
|
|
||||||
default: return;
|
|
||||||
}
|
|
||||||
if ( myViewWindow->SelectionMode() != mode )
|
|
||||||
myViewWindow->SetSelectionMode( mode );
|
|
||||||
|
|
||||||
myGeomName->setText( GEOMBase::GetDefaultName( geomName ));
|
|
||||||
}
|
}
|
||||||
|
if ( selectionMode() != mode )
|
||||||
|
setSelectionMode( mode );
|
||||||
|
|
||||||
|
myDlg->myGeomName->setText( GEOMBase::GetDefaultName( geomName ));
|
||||||
}
|
}
|
||||||
|
|
||||||
//=======================================================================
|
//=======================================================================
|
||||||
@ -430,7 +357,7 @@ void SMESHGUI_ShapeByMeshDlg::activateSelection()
|
|||||||
//purpose : SLOT. Called when element type changed.
|
//purpose : SLOT. Called when element type changed.
|
||||||
//=======================================================================
|
//=======================================================================
|
||||||
|
|
||||||
void SMESHGUI_ShapeByMeshDlg::onTypeChanged (int theType)
|
void SMESHGUI_ShapeByMeshOp::onTypeChanged (int theType)
|
||||||
{
|
{
|
||||||
setElementID("");
|
setElementID("");
|
||||||
activateSelection();
|
activateSelection();
|
||||||
@ -442,16 +369,16 @@ void SMESHGUI_ShapeByMeshDlg::onTypeChanged (int theType)
|
|||||||
// Highlight the element whose Ids the user entered manually
|
// Highlight the element whose Ids the user entered manually
|
||||||
//=======================================================================
|
//=======================================================================
|
||||||
|
|
||||||
void SMESHGUI_ShapeByMeshDlg::onElemIdChanged(const QString& theNewText)
|
void SMESHGUI_ShapeByMeshOp::onElemIdChanged(const QString& theNewText)
|
||||||
{
|
{
|
||||||
myOkBtn->setEnabled( false );
|
myDlg->setButtonEnabled( false, QtxDialog::OK );
|
||||||
|
|
||||||
if ( myIsManualIdEnter && !myMesh->_is_nil() && myViewWindow )
|
if ( myIsManualIdEnter && !myMesh->_is_nil() )
|
||||||
if ( SMESH_Actor* actor = SMESH::FindActorByObject(myMesh) )
|
if ( SMESH_Actor* actor = SMESH::FindActorByObject(myMesh) )
|
||||||
if ( SMDS_Mesh* aMesh = actor->GetObject()->GetMesh() )
|
if ( SMDS_Mesh* aMesh = actor->GetObject()->GetMesh() )
|
||||||
{
|
{
|
||||||
SMDSAbs_ElementType type = SMDSAbs_Edge;
|
SMDSAbs_ElementType type = SMDSAbs_Edge;
|
||||||
switch ( myElemTypeGroup->id( myElemTypeGroup->selected() )) {
|
switch ( myDlg->myElemTypeGroup->id( myDlg->myElemTypeGroup->selected() )) {
|
||||||
case EDGE : type = SMDSAbs_Edge; break;
|
case EDGE : type = SMDSAbs_Edge; break;
|
||||||
case FACE : type = SMDSAbs_Face; break;
|
case FACE : type = SMDSAbs_Face; break;
|
||||||
case VOLUME: type = SMDSAbs_Volume; break;
|
case VOLUME: type = SMDSAbs_Volume; break;
|
||||||
@ -466,10 +393,10 @@ void SMESHGUI_ShapeByMeshDlg::onElemIdChanged(const QString& theNewText)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if ( !newIndices.IsEmpty() && newIndices.Extent() == 1 )
|
if ( !newIndices.IsEmpty() && newIndices.Extent() == 1 )
|
||||||
if ( SVTK_Selector* s = myViewWindow->GetSelector() ) {
|
if ( SVTK_Selector* s = selector() ) {
|
||||||
s->AddOrRemoveIndex( actor->getIO(), newIndices, false );
|
s->AddOrRemoveIndex( actor->getIO(), newIndices, false );
|
||||||
myViewWindow->highlight( actor->getIO(), true, true );
|
viewWindow()->highlight( actor->getIO(), true, true );
|
||||||
myOkBtn->setEnabled( true );
|
myDlg->setButtonEnabled( true, QtxDialog::OK );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -479,9 +406,9 @@ void SMESHGUI_ShapeByMeshDlg::onElemIdChanged(const QString& theNewText)
|
|||||||
//purpose : programmatically set element id
|
//purpose : programmatically set element id
|
||||||
//=======================================================================
|
//=======================================================================
|
||||||
|
|
||||||
void SMESHGUI_ShapeByMeshDlg::setElementID(const QString& theText)
|
void SMESHGUI_ShapeByMeshOp::setElementID(const QString& theText)
|
||||||
{
|
{
|
||||||
myIsManualIdEnter = false;
|
myIsManualIdEnter = false;
|
||||||
myElementId->setText(theText);
|
myDlg->myElementId->setText(theText);
|
||||||
myIsManualIdEnter = true;
|
myIsManualIdEnter = true;
|
||||||
}
|
}
|
||||||
|
@ -27,7 +27,8 @@
|
|||||||
#ifndef SMESHGUI_ShapeByMeshDlg_H
|
#ifndef SMESHGUI_ShapeByMeshDlg_H
|
||||||
#define SMESHGUI_ShapeByMeshDlg_H
|
#define SMESHGUI_ShapeByMeshDlg_H
|
||||||
|
|
||||||
#include <qdialog.h>
|
#include "SMESHGUI_Dialog.h"
|
||||||
|
#include "SMESHGUI_SelectionOp.h"
|
||||||
|
|
||||||
// IDL Headers
|
// IDL Headers
|
||||||
#include <SALOMEconfig.h>
|
#include <SALOMEconfig.h>
|
||||||
@ -48,36 +49,88 @@ class SMESHGUI;
|
|||||||
* by selecting mesh elements
|
* by selecting mesh elements
|
||||||
*/
|
*/
|
||||||
|
|
||||||
class SMESHGUI_ShapeByMeshDlg : public QDialog
|
class SMESHGUI_ShapeByMeshDlg : public SMESHGUI_Dialog
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
SMESHGUI_ShapeByMeshDlg( SMESHGUI* theModule,
|
SMESHGUI_ShapeByMeshDlg();
|
||||||
const char* theName = 0);
|
|
||||||
virtual ~SMESHGUI_ShapeByMeshDlg();
|
virtual ~SMESHGUI_ShapeByMeshDlg();
|
||||||
|
|
||||||
|
private:
|
||||||
|
|
||||||
|
// void closeEvent (QCloseEvent* e);
|
||||||
|
// void enterEvent (QEvent*);
|
||||||
|
|
||||||
|
private:
|
||||||
|
|
||||||
|
//QFrame* createButtonFrame (QWidget*);
|
||||||
|
QFrame* createMainFrame (QWidget*);
|
||||||
|
//void displayPreview();
|
||||||
|
//void erasePreview();
|
||||||
|
private:
|
||||||
|
|
||||||
|
QButtonGroup* myElemTypeGroup;
|
||||||
|
QLineEdit* myElementId;
|
||||||
|
QLineEdit* myGeomName;
|
||||||
|
|
||||||
|
// QPushButton* myOkBtn;
|
||||||
|
// QPushButton* myCloseBtn;
|
||||||
|
|
||||||
|
// SMESHGUI* mySMESHGUI;
|
||||||
|
// LightApp_SelectionMgr* mySelectionMgr;
|
||||||
|
// SVTK_ViewWindow* myViewWindow;
|
||||||
|
|
||||||
|
friend class SMESHGUI_ShapeByMeshOp;
|
||||||
|
};
|
||||||
|
|
||||||
|
class SMESHGUI_ShapeByMeshOp: public SMESHGUI_SelectionOp
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
public:
|
||||||
|
SMESHGUI_ShapeByMeshOp();
|
||||||
|
virtual ~SMESHGUI_ShapeByMeshOp();
|
||||||
|
|
||||||
|
virtual LightApp_Dialog* dlg() const;
|
||||||
|
|
||||||
void Init();
|
void Init();
|
||||||
void SetMesh (SMESH::SMESH_Mesh_ptr);
|
void SetMesh (SMESH::SMESH_Mesh_ptr);
|
||||||
SMESH::SMESH_Mesh_ptr GetMesh () { return myMesh; }
|
SMESH::SMESH_Mesh_ptr GetMesh () { return myMesh; }
|
||||||
GEOM::GEOM_Object_ptr GetShape();
|
GEOM::GEOM_Object_ptr GetShape();
|
||||||
|
|
||||||
signals:
|
protected:
|
||||||
|
|
||||||
void PublishShape();
|
virtual void commitOperation();
|
||||||
void Close();
|
virtual void startOperation();
|
||||||
|
//virtual void selectionDone();
|
||||||
|
//virtual SUIT_SelectionFilter* createFilter( const int ) const;
|
||||||
|
//virtual bool isValid( SUIT_Operation* ) const;
|
||||||
|
|
||||||
private:
|
void activateSelection();
|
||||||
|
void setElementID(const QString&);
|
||||||
|
|
||||||
void closeEvent (QCloseEvent* e);
|
/* signals: */
|
||||||
void enterEvent (QEvent*);
|
|
||||||
|
/* void PublishShape(); */
|
||||||
|
/* void Close(); */
|
||||||
|
|
||||||
|
protected slots:
|
||||||
|
|
||||||
|
virtual bool onApply() { return true; }
|
||||||
|
/* void onCreateHyp( const int theHypType, const int theIndex ); */
|
||||||
|
/* void onEditHyp( const int theHypType, const int theIndex ); */
|
||||||
|
/* void onHypoSet( const QString& theSetName ); */
|
||||||
|
/* void onGeomSelectionByMesh( bool ); */
|
||||||
|
/* void onPublishShapeByMeshDlg(); */
|
||||||
|
/* void onCloseShapeByMeshDlg(); */
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
|
|
||||||
void onOk();
|
// void onOk();
|
||||||
void onClose();
|
// void onClose();
|
||||||
|
|
||||||
void onDeactivate();
|
// void onDeactivate();
|
||||||
|
|
||||||
void onSelectionDone();
|
void onSelectionDone();
|
||||||
void onTypeChanged (int);
|
void onTypeChanged (int);
|
||||||
@ -85,26 +138,7 @@ private slots:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
QFrame* createButtonFrame (QWidget*);
|
SMESHGUI_ShapeByMeshDlg* myDlg;
|
||||||
QFrame* createMainFrame (QWidget*);
|
|
||||||
//void displayPreview();
|
|
||||||
//void erasePreview();
|
|
||||||
void activateSelection();
|
|
||||||
void setElementID(const QString&);
|
|
||||||
|
|
||||||
private:
|
|
||||||
|
|
||||||
QButtonGroup* myElemTypeGroup;
|
|
||||||
QLineEdit* myElementId;
|
|
||||||
QLineEdit* myGeomName;
|
|
||||||
|
|
||||||
QPushButton* myOkBtn;
|
|
||||||
QPushButton* myCloseBtn;
|
|
||||||
|
|
||||||
SMESHGUI* mySMESHGUI;
|
|
||||||
LightApp_SelectionMgr* mySelectionMgr;
|
|
||||||
SVTK_ViewWindow* myViewWindow;
|
|
||||||
|
|
||||||
SMESH::SMESH_Mesh_var myMesh;
|
SMESH::SMESH_Mesh_var myMesh;
|
||||||
GEOM::GEOM_Object_var myGeomObj;
|
GEOM::GEOM_Object_var myGeomObj;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user