2009-02-17 10:27:49 +05:00
|
|
|
// Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE
|
2006-02-07 20:01:11 +05:00
|
|
|
//
|
2009-02-17 10:27:49 +05:00
|
|
|
// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
|
2006-02-07 20:01:11 +05:00
|
|
|
// 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
|
|
|
|
// 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
|
|
|
|
// 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
|
|
|
|
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
|
|
//
|
2009-02-17 10:27:49 +05:00
|
|
|
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
|
2006-02-07 20:01:11 +05:00
|
|
|
//
|
2009-02-17 10:27:49 +05:00
|
|
|
// File : SMESHGUI_ShapeByMeshDlg.cxx
|
|
|
|
// Author : Edward AGAPOV, Open CASCADE S.A.S.
|
|
|
|
// SMESH includes
|
2006-02-07 20:01:11 +05:00
|
|
|
//
|
|
|
|
#include "SMESHGUI_ShapeByMeshDlg.h"
|
|
|
|
|
|
|
|
#include "SMESHGUI.h"
|
|
|
|
#include "SMESHGUI_GEOMGenUtils.h"
|
|
|
|
#include "SMESHGUI_IdValidator.h"
|
|
|
|
#include "SMESHGUI_MeshUtils.h"
|
|
|
|
#include "SMESHGUI_Utils.h"
|
|
|
|
#include "SMESHGUI_VTKUtils.h"
|
|
|
|
|
2009-02-17 10:27:49 +05:00
|
|
|
#include <SMDS_Mesh.hxx>
|
|
|
|
#include <SMDS_MeshNode.hxx>
|
|
|
|
#include <SMESH_Actor.h>
|
|
|
|
|
|
|
|
// SALOME GEOM includes
|
|
|
|
#include <GEOMBase.h>
|
|
|
|
#include <GeometryGUI.h>
|
2006-02-07 20:01:11 +05:00
|
|
|
|
2009-02-17 10:27:49 +05:00
|
|
|
// SALOME GUI includes
|
|
|
|
#include <LightApp_DataOwner.h>
|
|
|
|
#include <LightApp_SelectionMgr.h>
|
|
|
|
#include <SALOME_ListIO.hxx>
|
|
|
|
#include <SUIT_Desktop.h>
|
|
|
|
#include <SVTK_Selector.h>
|
|
|
|
#include <SVTK_ViewWindow.h>
|
|
|
|
#include <SVTK_ViewModel.h>
|
|
|
|
#include <SalomeApp_Tools.h>
|
2006-02-07 20:01:11 +05:00
|
|
|
|
2009-02-17 10:27:49 +05:00
|
|
|
// SALOME KERNEL includes
|
|
|
|
#include <SALOMEDSClient_SObject.hxx>
|
2006-02-07 20:01:11 +05:00
|
|
|
|
2009-02-17 10:27:49 +05:00
|
|
|
// OCCT includes
|
2006-02-07 20:01:11 +05:00
|
|
|
#include <TColStd_MapOfInteger.hxx>
|
|
|
|
#include <TopoDS_Shape.hxx>
|
|
|
|
#include <TopExp_Explorer.hxx>
|
|
|
|
|
2009-02-17 10:27:49 +05:00
|
|
|
// Qt includes
|
|
|
|
#include <QFrame>
|
|
|
|
#include <QVBoxLayout>
|
|
|
|
#include <QHBoxLayout>
|
|
|
|
#include <QGridLayout>
|
|
|
|
#include <QLineEdit>
|
|
|
|
#include <QLabel>
|
|
|
|
#include <QRadioButton>
|
|
|
|
#include <QButtonGroup>
|
|
|
|
#include <QGroupBox>
|
|
|
|
#include <QStringList>
|
|
|
|
|
|
|
|
#define SPACING 6
|
|
|
|
#define MARGIN 11
|
2008-03-07 12:47:05 +05:00
|
|
|
|
2006-02-07 20:01:11 +05:00
|
|
|
enum { EDGE = 0, FACE, VOLUME };
|
|
|
|
|
|
|
|
/*!
|
|
|
|
* \brief Dialog to publish a sub-shape of the mesh main shape
|
|
|
|
* by selecting mesh elements
|
|
|
|
*/
|
2006-05-06 14:51:48 +06:00
|
|
|
SMESHGUI_ShapeByMeshDlg::SMESHGUI_ShapeByMeshDlg()
|
|
|
|
: SMESHGUI_Dialog( 0, false, true, OK | Close )
|
2006-02-07 20:01:11 +05:00
|
|
|
{
|
2009-02-17 10:27:49 +05:00
|
|
|
setWindowTitle(tr("CAPTION"));
|
2006-02-07 20:01:11 +05:00
|
|
|
|
2009-02-17 10:27:49 +05:00
|
|
|
QVBoxLayout* aDlgLay = new QVBoxLayout (mainFrame());
|
|
|
|
aDlgLay->setMargin(MARGIN);
|
|
|
|
aDlgLay->setSpacing(SPACING);
|
2006-02-07 20:01:11 +05:00
|
|
|
|
2006-05-06 14:51:48 +06:00
|
|
|
QFrame* aMainFrame = createMainFrame (mainFrame());
|
2006-02-07 20:01:11 +05:00
|
|
|
|
|
|
|
aDlgLay->addWidget(aMainFrame);
|
|
|
|
|
|
|
|
aDlgLay->setStretchFactor(aMainFrame, 1);
|
|
|
|
}
|
|
|
|
|
|
|
|
//=======================================================================
|
|
|
|
// function : createMainFrame()
|
|
|
|
// purpose : Create frame containing dialog's input fields
|
|
|
|
//=======================================================================
|
|
|
|
QFrame* SMESHGUI_ShapeByMeshDlg::createMainFrame (QWidget* theParent)
|
|
|
|
{
|
2009-02-17 10:27:49 +05:00
|
|
|
QFrame* aMainGrp = new QFrame(theParent);
|
|
|
|
QGridLayout* aLayout = new QGridLayout(aMainGrp);
|
|
|
|
aLayout->setMargin(0);
|
|
|
|
aLayout->setSpacing(SPACING);
|
2006-02-07 20:01:11 +05:00
|
|
|
|
|
|
|
// elem type
|
2009-02-17 10:27:49 +05:00
|
|
|
myElemTypeBox = new QGroupBox(tr("SMESH_ELEMENT_TYPE"), aMainGrp);
|
|
|
|
myElemTypeGroup = new QButtonGroup(aMainGrp);
|
|
|
|
QHBoxLayout* myElemTypeBoxLayout = new QHBoxLayout(myElemTypeBox);
|
|
|
|
myElemTypeBoxLayout->setMargin(MARGIN);
|
|
|
|
myElemTypeBoxLayout->setSpacing(SPACING);
|
|
|
|
|
|
|
|
QRadioButton* aEdgeRb = new QRadioButton( tr("SMESH_EDGE"), myElemTypeBox);
|
|
|
|
QRadioButton* aFaceRb = new QRadioButton( tr("SMESH_FACE"), myElemTypeBox);
|
|
|
|
QRadioButton* aVolumeRb = new QRadioButton( tr("SMESH_VOLUME"), myElemTypeBox);
|
|
|
|
|
|
|
|
myElemTypeBoxLayout->addWidget(aEdgeRb);
|
|
|
|
myElemTypeBoxLayout->addWidget(aFaceRb);
|
|
|
|
myElemTypeBoxLayout->addWidget(aVolumeRb);
|
|
|
|
myElemTypeGroup->addButton(aEdgeRb, 0);
|
|
|
|
myElemTypeGroup->addButton(aFaceRb, 1);
|
|
|
|
myElemTypeGroup->addButton(aVolumeRb, 2);
|
|
|
|
aEdgeRb->setChecked(true);
|
|
|
|
|
2006-02-07 20:01:11 +05:00
|
|
|
// element id
|
2009-02-17 10:27:49 +05:00
|
|
|
QLabel* anIdLabel = new QLabel( tr("ELEMENT_ID"), aMainGrp );
|
|
|
|
myElementId = new QLineEdit( aMainGrp );
|
|
|
|
myElementId->setValidator( new SMESHGUI_IdValidator( theParent,
|
|
|
|
!myIsMultipleAllowed ? 1 : 0 ) ); // 0 for any number of entities
|
2006-02-07 20:01:11 +05:00
|
|
|
|
|
|
|
// shape name
|
2009-02-17 10:27:49 +05:00
|
|
|
QLabel* aNameLabel = new QLabel( tr("GEOMETRY_NAME"), aMainGrp );
|
|
|
|
myGeomName = new QLineEdit( aMainGrp );
|
2006-02-07 20:01:11 +05:00
|
|
|
|
2009-02-17 10:27:49 +05:00
|
|
|
aLayout->addWidget(myElemTypeBox, 0, 0, 1, 2);
|
2006-02-07 20:01:11 +05:00
|
|
|
aLayout->addWidget(anIdLabel, 1, 0);
|
|
|
|
aLayout->addWidget(myElementId, 1, 1);
|
|
|
|
aLayout->addWidget(aNameLabel, 2, 0);
|
|
|
|
aLayout->addWidget(myGeomName, 2, 1);
|
|
|
|
|
|
|
|
return aMainGrp;
|
|
|
|
}
|
|
|
|
|
|
|
|
//=======================================================================
|
|
|
|
// function : ~SMESHGUI_ShapeByMeshDlg()
|
|
|
|
// purpose : Destructor
|
|
|
|
//=======================================================================
|
|
|
|
SMESHGUI_ShapeByMeshDlg::~SMESHGUI_ShapeByMeshDlg()
|
|
|
|
{
|
2009-02-17 10:27:49 +05:00
|
|
|
}
|
|
|
|
|
|
|
|
void SMESHGUI_ShapeByMeshDlg:: setMultipleAllowed( bool isAllowed )
|
|
|
|
{
|
|
|
|
myIsMultipleAllowed = isAllowed;
|
2006-02-07 20:01:11 +05:00
|
|
|
}
|
|
|
|
|
2006-05-06 14:51:48 +06:00
|
|
|
//================================================================================
|
|
|
|
/*!
|
|
|
|
* \brief Constructor
|
2009-02-17 10:27:49 +05:00
|
|
|
*/
|
2006-05-06 14:51:48 +06:00
|
|
|
//================================================================================
|
2008-03-07 12:47:05 +05:00
|
|
|
SMESHGUI_ShapeByMeshOp::SMESHGUI_ShapeByMeshOp(bool isMultipleAllowed):
|
|
|
|
myIsMultipleAllowed(isMultipleAllowed)
|
2006-05-06 14:51:48 +06:00
|
|
|
{
|
|
|
|
if ( GeometryGUI::GetGeomGen()->_is_nil() )// check that GEOM_Gen exists
|
|
|
|
GeometryGUI::InitGeomGen();
|
|
|
|
|
|
|
|
myDlg = new SMESHGUI_ShapeByMeshDlg;
|
2008-03-07 12:47:05 +05:00
|
|
|
myDlg->setMultipleAllowed(myIsMultipleAllowed);
|
2006-05-06 14:51:48 +06:00
|
|
|
|
2009-02-17 10:27:49 +05:00
|
|
|
connect(myDlg->myElemTypeGroup, SIGNAL(buttonClicked(int)), SLOT(onTypeChanged(int)));
|
2006-05-06 14:51:48 +06:00
|
|
|
connect(myDlg->myElementId, SIGNAL(textChanged(const QString&)), SLOT(onElemIdChanged(const QString&)));
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2006-02-07 20:01:11 +05:00
|
|
|
//=======================================================================
|
2006-05-06 14:51:48 +06:00
|
|
|
// function : startOperation()
|
2006-02-07 20:01:11 +05:00
|
|
|
// purpose : Init dialog fields, connect signals and slots, show dialog
|
|
|
|
//=======================================================================
|
2006-05-06 14:51:48 +06:00
|
|
|
void SMESHGUI_ShapeByMeshOp::startOperation()
|
2006-02-07 20:01:11 +05:00
|
|
|
{
|
2006-05-06 14:51:48 +06:00
|
|
|
//SetMesh( SMESH::SMESH_Mesh::_nil() );
|
2006-02-07 20:01:11 +05:00
|
|
|
myIsManualIdEnter = false;
|
|
|
|
|
2006-05-06 14:51:48 +06:00
|
|
|
SMESHGUI_SelectionOp::startOperation();
|
2006-02-07 20:01:11 +05:00
|
|
|
|
2006-05-06 14:51:48 +06:00
|
|
|
//activateSelection(); // set filters
|
|
|
|
onSelectionDone(); // desable/enable [ OK ]
|
2006-02-07 20:01:11 +05:00
|
|
|
|
2006-05-06 14:51:48 +06:00
|
|
|
myDlg->show();
|
|
|
|
}
|
2006-02-07 20:01:11 +05:00
|
|
|
|
2006-05-06 14:51:48 +06:00
|
|
|
//================================================================================
|
|
|
|
/*!
|
|
|
|
* \brief Destructor
|
2009-02-17 10:27:49 +05:00
|
|
|
*/
|
2006-05-06 14:51:48 +06:00
|
|
|
//================================================================================
|
|
|
|
SMESHGUI_ShapeByMeshOp::~SMESHGUI_ShapeByMeshOp()
|
|
|
|
{
|
|
|
|
if ( myDlg )
|
|
|
|
delete myDlg;
|
|
|
|
}
|
2006-02-07 20:01:11 +05:00
|
|
|
|
2006-05-06 14:51:48 +06:00
|
|
|
//================================================================================
|
|
|
|
/*!
|
|
|
|
* \brief Gets dialog of this operation
|
2009-02-17 10:27:49 +05:00
|
|
|
* \retval LightApp_Dialog* - pointer to dialog of this operation
|
|
|
|
*/
|
2006-05-06 14:51:48 +06:00
|
|
|
//================================================================================
|
|
|
|
LightApp_Dialog* SMESHGUI_ShapeByMeshOp::dlg() const
|
|
|
|
{
|
|
|
|
return myDlg;
|
|
|
|
}
|
|
|
|
|
2009-02-17 10:27:49 +05:00
|
|
|
SMESH::SMESH_Mesh_ptr SMESHGUI_ShapeByMeshOp::GetMesh()
|
|
|
|
{
|
|
|
|
return myMesh;
|
|
|
|
}
|
|
|
|
|
2006-05-06 14:51:48 +06:00
|
|
|
//=======================================================================
|
|
|
|
// function : GetShape()
|
|
|
|
// purpose : Get published sub-shape
|
|
|
|
//=======================================================================
|
|
|
|
GEOM::GEOM_Object_ptr SMESHGUI_ShapeByMeshOp::GetShape()
|
|
|
|
{
|
|
|
|
return myGeomObj.in();
|
2006-02-07 20:01:11 +05:00
|
|
|
}
|
|
|
|
|
|
|
|
//=======================================================================
|
|
|
|
// function : SetMesh()
|
|
|
|
// purpose : Set mesh to dialog
|
|
|
|
//=======================================================================
|
|
|
|
|
2006-05-06 14:51:48 +06:00
|
|
|
void SMESHGUI_ShapeByMeshOp::SetMesh (SMESH::SMESH_Mesh_ptr thePtr)
|
2006-02-07 20:01:11 +05:00
|
|
|
{
|
|
|
|
myMesh = SMESH::SMESH_Mesh::_duplicate(thePtr);
|
|
|
|
myGeomObj = GEOM::GEOM_Object::_nil();
|
|
|
|
myHasSolids = false;
|
|
|
|
|
2009-02-17 10:27:49 +05:00
|
|
|
std::vector< bool > hasElement (myDlg->myElemTypeGroup->buttons().count(), false);
|
2006-05-06 14:51:48 +06:00
|
|
|
if (!myMesh->_is_nil() )
|
2006-02-07 20:01:11 +05:00
|
|
|
{
|
2009-02-17 10:27:49 +05:00
|
|
|
// _PTR(SObject) aSobj = SMESH::FindSObject(myMesh.in());
|
|
|
|
// SUIT_DataOwnerPtr anIObj (new LightApp_DataOwner(aSobj->GetID().c_str()));
|
|
|
|
|
|
|
|
std::vector< int > nbShapes( TopAbs_SHAPE, 0 );
|
|
|
|
int shapeDim = 0; // max dim with several shapes
|
|
|
|
//if ( /*mySelectionMgr*/ selectionMgr()->isOk(anIObj) ) // check that the mesh has a valid shape
|
2006-02-07 20:01:11 +05:00
|
|
|
{
|
2009-02-17 10:27:49 +05:00
|
|
|
_PTR(SObject) aSO = SMESH::FindSObject(myMesh.in());
|
|
|
|
GEOM::GEOM_Object_var mainShape = SMESH::GetGeom(aSO);
|
|
|
|
if ( !mainShape->_is_nil() )
|
|
|
|
{
|
|
|
|
TopoDS_Shape aShape;
|
|
|
|
if ( GEOMBase::GetShape(mainShape, aShape))
|
|
|
|
{
|
|
|
|
TopAbs_ShapeEnum types[4] = { TopAbs_EDGE, TopAbs_FACE, TopAbs_SHELL, TopAbs_SOLID };
|
|
|
|
for ( int dim = 4; dim > 0; --dim ) {
|
|
|
|
TopAbs_ShapeEnum type = types[ dim - 1 ];
|
|
|
|
TopAbs_ShapeEnum avoid = ( type == TopAbs_SHELL ) ? TopAbs_SOLID : TopAbs_SHAPE;
|
|
|
|
TopExp_Explorer exp( aShape, type, avoid );
|
|
|
|
for ( ; nbShapes[ type ] < 2 && exp.More(); exp.Next() )
|
|
|
|
++nbShapes[ type ];
|
|
|
|
if ( nbShapes[ type ] > 1 ) {
|
|
|
|
shapeDim = dim;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2006-02-07 20:01:11 +05:00
|
|
|
}
|
2009-02-17 10:27:49 +05:00
|
|
|
if (shapeDim > 0)
|
|
|
|
{
|
|
|
|
if ( nbShapes[ TopAbs_SHELL ] + nbShapes[ TopAbs_SOLID ] > 1 )
|
|
|
|
shapeDim = 3;
|
|
|
|
hasElement[ EDGE ] = shapeDim > 0 && myMesh->NbEdges();
|
|
|
|
hasElement[ FACE ] = shapeDim > 1 && myMesh->NbFaces();
|
|
|
|
hasElement[ VOLUME ] = shapeDim > 2 && myMesh->NbVolumes();
|
|
|
|
}
|
|
|
|
myHasSolids = nbShapes[ TopAbs_SOLID ];
|
2006-02-07 20:01:11 +05:00
|
|
|
}
|
|
|
|
|
|
|
|
// disable inexistant elem types
|
2009-02-17 10:27:49 +05:00
|
|
|
for ( int i = 0; i < myDlg->myElemTypeGroup->buttons().count(); ++i ) {
|
|
|
|
if ( QAbstractButton* button = myDlg->myElemTypeGroup->button( i ) )
|
2006-02-07 20:01:11 +05:00
|
|
|
button->setEnabled( hasElement[ i ] );
|
|
|
|
}
|
2006-05-06 14:51:48 +06:00
|
|
|
myDlg->myElementId->setEnabled( hasElement[ EDGE ] );
|
|
|
|
myDlg->myGeomName-> setEnabled( hasElement[ EDGE ] );
|
2006-02-07 20:01:11 +05:00
|
|
|
|
|
|
|
setElementID("");
|
|
|
|
}
|
|
|
|
|
|
|
|
//=======================================================================
|
2006-05-06 14:51:48 +06:00
|
|
|
// function : commitOperation()
|
|
|
|
// purpose : called when "Ok" button pressed.
|
2006-02-07 20:01:11 +05:00
|
|
|
//=======================================================================
|
|
|
|
|
2006-05-06 14:51:48 +06:00
|
|
|
void SMESHGUI_ShapeByMeshOp::commitOperation()
|
2006-02-07 20:01:11 +05:00
|
|
|
{
|
2006-05-06 14:51:48 +06:00
|
|
|
SMESHGUI_SelectionOp::commitOperation();
|
2006-02-07 20:01:11 +05:00
|
|
|
try {
|
2009-02-17 10:27:49 +05:00
|
|
|
QStringList aListId = myDlg->myElementId->text().split( " ", QString::SkipEmptyParts);
|
2008-03-07 12:47:05 +05:00
|
|
|
if (aListId.count() == 1)
|
|
|
|
{
|
|
|
|
int elemID = (aListId.first()).toInt();
|
2009-02-17 10:27:49 +05:00
|
|
|
myGeomObj = GEOM::GEOM_Object::_duplicate(
|
|
|
|
SMESHGUI::GetSMESHGen()->GetGeometryByMeshElement
|
|
|
|
( myMesh.in(), elemID, myDlg->myGeomName->text().toLatin1().constData()) );
|
2008-03-07 12:47:05 +05:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
GEOM::GEOM_Gen_var geomGen = SMESH::GetGEOMGen();
|
|
|
|
_PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
|
|
|
|
|
|
|
|
if (geomGen->_is_nil() || !aStudy)
|
|
|
|
return;
|
|
|
|
|
|
|
|
GEOM::GEOM_IShapesOperations_var aShapesOp =
|
|
|
|
geomGen->GetIShapesOperations(aStudy->StudyId());
|
|
|
|
if (aShapesOp->_is_nil() )
|
|
|
|
return;
|
|
|
|
|
|
|
|
TopAbs_ShapeEnum aGroupType = TopAbs_SHAPE;
|
|
|
|
|
|
|
|
std::map<double, GEOM::GEOM_Object_var> aGeomObjectsMap;
|
|
|
|
GEOM::GEOM_Object_var aGeomObject;
|
|
|
|
|
|
|
|
GEOM::GEOM_Object_var aMeshShape = myMesh->GetShapeToMesh();
|
|
|
|
|
|
|
|
for ( int i = 0; i < aListId.count(); i++ )
|
|
|
|
{
|
|
|
|
aGeomObject =
|
|
|
|
SMESHGUI::GetSMESHGen()->FindGeometryByMeshElement(myMesh.in(), aListId[i].toInt());
|
|
|
|
|
|
|
|
if (aGeomObject->_is_nil()) continue;
|
|
|
|
|
|
|
|
double anId = aShapesOp->GetSubShapeIndex(aMeshShape, aGeomObject);
|
|
|
|
if (aShapesOp->IsDone() && aGeomObjectsMap.find(anId) == aGeomObjectsMap.end())
|
|
|
|
{
|
|
|
|
aGeomObjectsMap[anId] = aGeomObject;
|
|
|
|
|
|
|
|
TopAbs_ShapeEnum aSubShapeType = (TopAbs_ShapeEnum)aGeomObject->GetShapeType();
|
|
|
|
if (i == 0)
|
|
|
|
aGroupType = aSubShapeType;
|
|
|
|
else if (aSubShapeType != aGroupType)
|
|
|
|
aGroupType = TopAbs_SHAPE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
int aNumberOfGO = aGeomObjectsMap.size();
|
|
|
|
if (aNumberOfGO == 1)
|
|
|
|
myGeomObj = (*aGeomObjectsMap.begin()).second;
|
|
|
|
else if (aNumberOfGO > 1)
|
|
|
|
{
|
|
|
|
GEOM::GEOM_IGroupOperations_var aGroupOp =
|
|
|
|
geomGen->GetIGroupOperations(aStudy->StudyId());
|
|
|
|
if(aGroupOp->_is_nil())
|
|
|
|
return;
|
|
|
|
|
|
|
|
GEOM::ListOfGO_var aGeomObjects = new GEOM::ListOfGO();
|
|
|
|
aGeomObjects->length( aNumberOfGO );
|
|
|
|
|
|
|
|
int i = 0;
|
|
|
|
std::map<double, GEOM::GEOM_Object_var>::iterator anIter;
|
|
|
|
for (anIter = aGeomObjectsMap.begin(); anIter!=aGeomObjectsMap.end(); anIter++)
|
|
|
|
aGeomObjects[i++] = (*anIter).second;
|
|
|
|
|
|
|
|
//create geometry group
|
|
|
|
myGeomObj = aGroupOp->CreateGroup(aMeshShape, aGroupType);
|
|
|
|
aGroupOp->UnionList(myGeomObj, aGeomObjects);
|
|
|
|
|
|
|
|
if (!aGroupOp->IsDone())
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
// publish the GEOM object in study
|
2009-02-17 10:27:49 +05:00
|
|
|
QString aNewGeomGroupName ( myDlg->myGeomName->text() );
|
2008-03-07 12:47:05 +05:00
|
|
|
|
|
|
|
SALOMEDS::SObject_var aNewGroupSO =
|
2009-02-17 10:27:49 +05:00
|
|
|
geomGen->AddInStudy(SMESHGUI::GetSMESHGen()->GetCurrentStudy(), myGeomObj,
|
|
|
|
aNewGeomGroupName.toLatin1().data(), aMeshShape);
|
2008-03-07 12:47:05 +05:00
|
|
|
}
|
2006-02-07 20:01:11 +05:00
|
|
|
}
|
|
|
|
catch (const SALOME::SALOME_Exception& S_ex) {
|
|
|
|
SalomeApp_Tools::QtCatchCorbaException(S_ex);
|
|
|
|
}
|
|
|
|
catch (...) {
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2009-02-17 10:27:49 +05:00
|
|
|
bool SMESHGUI_ShapeByMeshOp::onApply()
|
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2006-02-07 20:01:11 +05:00
|
|
|
//=======================================================================
|
|
|
|
// function : onSelectionDone()
|
2006-05-06 14:51:48 +06:00
|
|
|
// purpose : SLOT called when selection changed. Enable/desable [ OK ]
|
2006-02-07 20:01:11 +05:00
|
|
|
//=======================================================================
|
2006-05-06 14:51:48 +06:00
|
|
|
void SMESHGUI_ShapeByMeshOp::onSelectionDone()
|
2006-02-07 20:01:11 +05:00
|
|
|
{
|
2006-05-06 14:51:48 +06:00
|
|
|
myDlg->setButtonEnabled( false, QtxDialog::OK );
|
2006-02-07 20:01:11 +05:00
|
|
|
setElementID("");
|
|
|
|
|
|
|
|
try {
|
|
|
|
SALOME_ListIO aList;
|
2006-05-06 14:51:48 +06:00
|
|
|
selectionMgr()->selectedObjects(aList, SVTK_Viewer::Type());
|
2008-03-07 12:47:05 +05:00
|
|
|
if (!myIsMultipleAllowed && aList.Extent() != 1)
|
2006-02-07 20:01:11 +05:00
|
|
|
return;
|
|
|
|
|
|
|
|
SMESH::SMESH_Mesh_var aMesh = SMESH::GetMeshByIO(aList.First());
|
|
|
|
if (aMesh->_is_nil() || myMesh->_is_nil() || aMesh->GetId() != myMesh->GetId() )
|
|
|
|
return;
|
|
|
|
|
|
|
|
QString aString;
|
2006-05-06 14:51:48 +06:00
|
|
|
int nbElems = SMESH::GetNameOfSelectedElements(selector(),//myViewWindow->GetSelector(),
|
2006-02-07 20:01:11 +05:00
|
|
|
aList.First(), aString);
|
2008-03-07 12:47:05 +05:00
|
|
|
if (nbElems > 0) {
|
|
|
|
if (!myIsMultipleAllowed && nbElems != 1 )
|
|
|
|
return;
|
2006-02-07 20:01:11 +05:00
|
|
|
setElementID( aString );
|
2006-05-06 14:51:48 +06:00
|
|
|
myDlg->setButtonEnabled( true, QtxDialog::OK );
|
2006-02-07 20:01:11 +05:00
|
|
|
}
|
|
|
|
} catch (...) {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//=======================================================================
|
|
|
|
// function : activateSelection()
|
|
|
|
// purpose : Activate selection in accordance with current pattern type
|
|
|
|
//=======================================================================
|
2006-05-06 14:51:48 +06:00
|
|
|
void SMESHGUI_ShapeByMeshOp::activateSelection()
|
2006-02-07 20:01:11 +05:00
|
|
|
{
|
2006-05-06 14:51:48 +06:00
|
|
|
selectionMgr()->clearFilters();
|
|
|
|
//SMESH::SetPointRepresentation(false);
|
|
|
|
|
|
|
|
myDlg->myGeomName->setText("");
|
|
|
|
|
|
|
|
QString geomName;
|
|
|
|
Selection_Mode mode = EdgeSelection;
|
2009-02-17 10:27:49 +05:00
|
|
|
switch ( myDlg->myElemTypeGroup->checkedId() ) {
|
2006-05-06 14:51:48 +06:00
|
|
|
case EDGE :
|
|
|
|
mode = EdgeSelection; geomName = tr("GEOM_EDGE"); break;
|
|
|
|
case FACE :
|
|
|
|
mode = FaceSelection; geomName = tr("GEOM_FACE"); break;
|
|
|
|
case VOLUME:
|
|
|
|
mode = VolumeSelection; geomName = tr(myHasSolids ? "GEOM_SOLID" : "GEOM_SHELL"); break;
|
|
|
|
default: return;
|
2006-02-07 20:01:11 +05:00
|
|
|
}
|
2006-05-06 14:51:48 +06:00
|
|
|
if ( selectionMode() != mode )
|
|
|
|
setSelectionMode( mode );
|
|
|
|
|
|
|
|
myDlg->myGeomName->setText( GEOMBase::GetDefaultName( geomName ));
|
2006-02-07 20:01:11 +05:00
|
|
|
}
|
|
|
|
|
|
|
|
//=======================================================================
|
|
|
|
//function : onTypeChanged
|
|
|
|
//purpose : SLOT. Called when element type changed.
|
|
|
|
//=======================================================================
|
|
|
|
|
2006-05-06 14:51:48 +06:00
|
|
|
void SMESHGUI_ShapeByMeshOp::onTypeChanged (int theType)
|
2006-02-07 20:01:11 +05:00
|
|
|
{
|
|
|
|
setElementID("");
|
|
|
|
activateSelection();
|
|
|
|
}
|
|
|
|
|
|
|
|
//=======================================================================
|
|
|
|
//function : onTypeChanged
|
|
|
|
//purpose : SLOT. Called when element id is entered
|
|
|
|
// Highlight the element whose Ids the user entered manually
|
|
|
|
//=======================================================================
|
|
|
|
|
2006-05-06 14:51:48 +06:00
|
|
|
void SMESHGUI_ShapeByMeshOp::onElemIdChanged(const QString& theNewText)
|
2006-02-07 20:01:11 +05:00
|
|
|
{
|
2006-05-06 14:51:48 +06:00
|
|
|
myDlg->setButtonEnabled( false, QtxDialog::OK );
|
2006-02-07 20:01:11 +05:00
|
|
|
|
2006-05-06 14:51:48 +06:00
|
|
|
if ( myIsManualIdEnter && !myMesh->_is_nil() )
|
2009-02-17 10:27:49 +05:00
|
|
|
{
|
2006-02-07 20:01:11 +05:00
|
|
|
if ( SMESH_Actor* actor = SMESH::FindActorByObject(myMesh) )
|
2009-02-17 10:27:49 +05:00
|
|
|
{
|
2006-02-07 20:01:11 +05:00
|
|
|
if ( SMDS_Mesh* aMesh = actor->GetObject()->GetMesh() )
|
|
|
|
{
|
2009-02-17 10:27:49 +05:00
|
|
|
SMDSAbs_ElementType type = SMDSAbs_Edge;
|
|
|
|
switch ( myDlg->myElemTypeGroup->checkedId() ) {
|
|
|
|
case EDGE : type = SMDSAbs_Edge; break;
|
|
|
|
case FACE : type = SMDSAbs_Face; break;
|
|
|
|
case VOLUME: type = SMDSAbs_Volume; break;
|
|
|
|
default: return;
|
|
|
|
}
|
|
|
|
TColStd_MapOfInteger newIndices;
|
|
|
|
QStringList aListId = theNewText.split( " ", QString::SkipEmptyParts);
|
|
|
|
for ( int i = 0; i < aListId.count(); i++ ) {
|
|
|
|
if ( const SMDS_MeshElement * e = aMesh->FindElement( aListId[ i ].toInt() ))
|
|
|
|
if ( e->GetType() == type )
|
|
|
|
newIndices.Add( e->GetID() );
|
|
|
|
}
|
|
|
|
|
2008-03-07 12:47:05 +05:00
|
|
|
if ( !newIndices.IsEmpty() )
|
2009-02-17 10:27:49 +05:00
|
|
|
{
|
|
|
|
if (!myIsMultipleAllowed && newIndices.Extent() != 1)
|
|
|
|
return;
|
|
|
|
if ( SVTK_Selector* s = selector() ) {
|
|
|
|
s->AddOrRemoveIndex( actor->getIO(), newIndices, false );
|
|
|
|
viewWindow()->highlight( actor->getIO(), true, true );
|
|
|
|
myDlg->setButtonEnabled( true, QtxDialog::OK );
|
2008-03-07 12:47:05 +05:00
|
|
|
}
|
2009-02-17 10:27:49 +05:00
|
|
|
}
|
2006-02-07 20:01:11 +05:00
|
|
|
}
|
2009-02-17 10:27:49 +05:00
|
|
|
}
|
|
|
|
}
|
2006-02-07 20:01:11 +05:00
|
|
|
}
|
|
|
|
|
|
|
|
//=======================================================================
|
|
|
|
//function : setElementID
|
|
|
|
//purpose : programmatically set element id
|
|
|
|
//=======================================================================
|
|
|
|
|
2006-05-06 14:51:48 +06:00
|
|
|
void SMESHGUI_ShapeByMeshOp::setElementID(const QString& theText)
|
2006-02-07 20:01:11 +05:00
|
|
|
{
|
|
|
|
myIsManualIdEnter = false;
|
2006-05-06 14:51:48 +06:00
|
|
|
myDlg->myElementId->setText(theText);
|
2006-02-07 20:01:11 +05:00
|
|
|
myIsManualIdEnter = true;
|
|
|
|
}
|