0020139: EDF 944 SMESH : Get 2D/3D element with X, Y, Z coordinates

+	SMESHGUI_FindElemByPointDlg.cxx \
This commit is contained in:
eap 2009-11-11 15:10:07 +00:00
parent f11f516780
commit 37d36cd6fc
6 changed files with 667 additions and 44 deletions

View File

@ -92,6 +92,7 @@ salomeinclude_HEADERS = \
SMESHGUI_IdValidator.h \ SMESHGUI_IdValidator.h \
SMESHGUI_MeshInfosBox.h \ SMESHGUI_MeshInfosBox.h \
SMESHGUI_Make2DFrom3DOp.h \ SMESHGUI_Make2DFrom3DOp.h \
SMESHGUI_FindElemByPointDlg.h \
SMESH_SMESHGUI.hxx SMESH_SMESHGUI.hxx
# Libraries targets # Libraries targets
@ -215,7 +216,9 @@ MOC_FILES = \
SMESHGUI_GroupOnShapeDlg_moc.cxx \ SMESHGUI_GroupOnShapeDlg_moc.cxx \
SMESHGUI_FileInfoDlg_moc.cxx \ SMESHGUI_FileInfoDlg_moc.cxx \
SMESHGUI_MeshInfosBox_moc.cxx \ SMESHGUI_MeshInfosBox_moc.cxx \
SMESHGUI_Make2DFrom3DOp_moc.cxx SMESHGUI_Make2DFrom3DOp_moc.cxx \
SMESHGUI_FindElemByPointDlg.cxx \
SMESHGUI_FindElemByPointDlg_moc.cxx
nodist_libSMESH_la_SOURCES= \ nodist_libSMESH_la_SOURCES= \
$(MOC_FILES) $(MOC_FILES)

View File

@ -25,49 +25,50 @@
// SMESH includes // SMESH includes
#include "SMESHGUI.h" #include "SMESHGUI.h"
#include "SMESHGUI_NodesDlg.h"
#include "SMESHGUI_TransparencyDlg.h"
#include "SMESHGUI_ClippingDlg.h"
#include "SMESHGUI_GroupDlg.h"
#include "SMESHGUI_RemoveNodesDlg.h"
#include "SMESHGUI_RemoveElementsDlg.h"
#include "SMESHGUI_MeshInfosDlg.h"
#include "SMESHGUI_StandardMeshInfosDlg.h"
#include "SMESHGUI_WhatIsDlg.h"
#include "SMESHGUI_Preferences_ColorDlg.h"
#include "SMESHGUI_Preferences_ScalarBarDlg.h"
#include "SMESHGUI_Hypotheses.h"
#include "SMESHGUI_MoveNodesDlg.h"
#include "SMESHGUI_AddMeshElementDlg.h" #include "SMESHGUI_AddMeshElementDlg.h"
#include "SMESHGUI_AddQuadraticElementDlg.h" #include "SMESHGUI_AddQuadraticElementDlg.h"
#include "SMESHGUI_BuildCompoundDlg.h"
#include "SMESHGUI_ClippingDlg.h"
#include "SMESHGUI_ComputeDlg.h"
#include "SMESHGUI_ConvToQuadOp.h"
#include "SMESHGUI_CreatePolyhedralVolumeDlg.h"
#include "SMESHGUI_DeleteGroupDlg.h"
#include "SMESHGUI_Displayer.h"
#include "SMESHGUI_EditMeshDlg.h"
#include "SMESHGUI_ExtrusionAlongPathDlg.h"
#include "SMESHGUI_ExtrusionDlg.h"
#include "SMESHGUI_FileInfoDlg.h"
#include "SMESHGUI_FilterDlg.h" #include "SMESHGUI_FilterDlg.h"
#include "SMESHGUI_FilterLibraryDlg.h" #include "SMESHGUI_FilterLibraryDlg.h"
#include "SMESHGUI_SingleEditDlg.h" #include "SMESHGUI_FindElemByPointDlg.h"
#include "SMESHGUI_MultiEditDlg.h" #include "SMESHGUI_GroupDlg.h"
#include "SMESHGUI_GroupOpDlg.h"
#include "SMESHGUI_GroupOnShapeDlg.h" #include "SMESHGUI_GroupOnShapeDlg.h"
#include "SMESHGUI_DeleteGroupDlg.h" #include "SMESHGUI_GroupOpDlg.h"
#include "SMESHGUI_SmoothingDlg.h" #include "SMESHGUI_Hypotheses.h"
#include "SMESHGUI_RenumberingDlg.h"
#include "SMESHGUI_ExtrusionDlg.h"
#include "SMESHGUI_ExtrusionAlongPathDlg.h"
#include "SMESHGUI_RevolutionDlg.h"
#include "SMESHGUI_TranslationDlg.h"
#include "SMESHGUI_RotationDlg.h"
#include "SMESHGUI_SymmetryDlg.h"
#include "SMESHGUI_SewingDlg.h"
#include "SMESHGUI_EditMeshDlg.h"
#include "SMESHGUI_MeshPatternDlg.h"
#include "SMESHGUI_Selection.h"
#include "SMESHGUI_CreatePolyhedralVolumeDlg.h"
#include "SMESHGUI_ConvToQuadOp.h"
#include "SMESHGUI_MeshOp.h"
#include "SMESHGUI_Displayer.h"
#include "SMESHGUI_MakeNodeAtPointDlg.h"
#include "SMESHGUI_BuildCompoundDlg.h"
#include "SMESHGUI_ComputeDlg.h"
#include "SMESHGUI_FileInfoDlg.h"
#include "SMESHGUI_Make2DFrom3DOp.h" #include "SMESHGUI_Make2DFrom3DOp.h"
#include "SMESHGUI_MakeNodeAtPointDlg.h"
#include "SMESHGUI_MeshInfosDlg.h"
#include "SMESHGUI_MeshOp.h"
#include "SMESHGUI_MeshPatternDlg.h"
#include "SMESHGUI_MoveNodesDlg.h"
#include "SMESHGUI_MultiEditDlg.h"
#include "SMESHGUI_NodesDlg.h"
#include "SMESHGUI_Preferences_ColorDlg.h"
#include "SMESHGUI_Preferences_ScalarBarDlg.h"
#include "SMESHGUI_RemoveElementsDlg.h"
#include "SMESHGUI_RemoveNodesDlg.h"
#include "SMESHGUI_RenumberingDlg.h"
#include "SMESHGUI_RevolutionDlg.h"
#include "SMESHGUI_RotationDlg.h"
#include "SMESHGUI_Selection.h"
#include "SMESHGUI_SewingDlg.h"
#include "SMESHGUI_SingleEditDlg.h"
#include "SMESHGUI_SmoothingDlg.h"
#include "SMESHGUI_StandardMeshInfosDlg.h"
#include "SMESHGUI_SymmetryDlg.h"
#include "SMESHGUI_TranslationDlg.h"
#include "SMESHGUI_TransparencyDlg.h"
#include "SMESHGUI_WhatIsDlg.h"
#include "SMESHGUI_Utils.h" #include "SMESHGUI_Utils.h"
#include "SMESHGUI_MeshUtils.h" #include "SMESHGUI_MeshUtils.h"
@ -2087,6 +2088,12 @@ bool SMESHGUI::OnGUIEvent( int theCommandID )
break; break;
} }
case 904: // FIND ELEM
{
startOperation( theCommandID );
break;
}
case 1100: // EDIT HYPOTHESIS case 1100: // EDIT HYPOTHESIS
{ {
if(checkLock(aStudy)) break; if(checkLock(aStudy)) break;
@ -2730,6 +2737,7 @@ void SMESHGUI::initialize( CAM_Application* app )
createSMESHAction( 900, "ADV_INFO", "ICON_ADV_INFO" ); createSMESHAction( 900, "ADV_INFO", "ICON_ADV_INFO" );
createSMESHAction( 902, "STD_INFO", "ICON_STD_INFO" ); createSMESHAction( 902, "STD_INFO", "ICON_STD_INFO" );
createSMESHAction( 903, "WHAT_IS", "ICON_WHAT_IS" ); createSMESHAction( 903, "WHAT_IS", "ICON_WHAT_IS" );
createSMESHAction( 904, "FIND_ELEM", "ICON_FIND_ELEM" );
createSMESHAction( 6001, "LENGTH", "ICON_LENGTH", 0, true ); createSMESHAction( 6001, "LENGTH", "ICON_LENGTH", 0, true );
createSMESHAction( 6002, "FREE_EDGE", "ICON_FREE_EDGE", 0, true ); createSMESHAction( 6002, "FREE_EDGE", "ICON_FREE_EDGE", 0, true );
createSMESHAction( 6021, "FREE_FACES", "ICON_FREE_FACES", 0, true ); createSMESHAction( 6021, "FREE_FACES", "ICON_FREE_FACES", 0, true );
@ -2881,6 +2889,7 @@ void SMESHGUI::initialize( CAM_Application* app )
createMenu( 900, meshId, -1 ); createMenu( 900, meshId, -1 );
createMenu( 902, meshId, -1 ); createMenu( 902, meshId, -1 );
createMenu( 903, meshId, -1 ); createMenu( 903, meshId, -1 );
createMenu( 904, meshId, -1 );
createMenu( separator(), meshId, -1 ); createMenu( separator(), meshId, -1 );
createMenu( 6003, ctrlId, -1 ); createMenu( 6003, ctrlId, -1 );
@ -2977,6 +2986,7 @@ void SMESHGUI::initialize( CAM_Application* app )
createTool( 900, meshTb ); createTool( 900, meshTb );
createTool( 902, meshTb ); createTool( 902, meshTb );
createTool( 903, meshTb ); createTool( 903, meshTb );
createTool( 904, meshTb );
createTool( separator(), meshTb ); createTool( separator(), meshTb );
createTool( 6001, ctrlTb ); createTool( 6001, ctrlTb );
@ -3102,6 +3112,7 @@ void SMESHGUI::initialize( CAM_Application* app )
createPopupItem( 900, OB, mesh_group ); // ADV_INFO createPopupItem( 900, OB, mesh_group ); // ADV_INFO
createPopupItem( 902, OB, mesh ); // STD_INFO createPopupItem( 902, OB, mesh ); // STD_INFO
createPopupItem( 903, OB, mesh_group ); // WHAT_IS createPopupItem( 903, OB, mesh_group ); // WHAT_IS
createPopupItem( 904, OB, mesh_group ); // FIND_ELEM
popupMgr()->insert( separator(), -1, 0 ); popupMgr()->insert( separator(), -1, 0 );
createPopupItem( 801, OB, mesh ); // CREATE_GROUP createPopupItem( 801, OB, mesh ); // CREATE_GROUP
createPopupItem( 806, OB, mesh ); // CREATE_GEO_GROUP createPopupItem( 806, OB, mesh ); // CREATE_GEO_GROUP
@ -3136,6 +3147,7 @@ void SMESHGUI::initialize( CAM_Application* app )
createPopupItem( 900, View, mesh_group ); // ADV_INFO createPopupItem( 900, View, mesh_group ); // ADV_INFO
createPopupItem( 902, View, mesh ); // STD_INFO createPopupItem( 902, View, mesh ); // STD_INFO
createPopupItem( 903, View, mesh_group ); // WHAT_IS createPopupItem( 903, View, mesh_group ); // WHAT_IS
createPopupItem( 904, View, mesh_group ); // FIND_ELEM
popupMgr()->insert( separator(), -1, 0 ); popupMgr()->insert( separator(), -1, 0 );
createPopupItem( 1136, OB + " " + View, mesh, "&& (not isAutoColor)" ); // AUTO_COLOR createPopupItem( 1136, OB + " " + View, mesh, "&& (not isAutoColor)" ); // AUTO_COLOR
@ -3891,6 +3903,12 @@ LightApp_Operation* SMESHGUI::createOperation( const int id ) const
// to do : create operation here // to do : create operation here
switch( id ) switch( id )
{ {
case 417: //convert to quadratic
op = new SMESHGUI_ConvToQuadOp();
break;
case 418: // create 2D mesh as boundary on 3D
op = new SMESHGUI_Make2DFrom3DOp();
break;
case 701: // Compute mesh case 701: // Compute mesh
op = new SMESHGUI_ComputeOp(); op = new SMESHGUI_ComputeOp();
break; break;
@ -3912,12 +3930,9 @@ LightApp_Operation* SMESHGUI::createOperation( const int id ) const
case 806: // Create group on geom case 806: // Create group on geom
op = new SMESHGUI_GroupOnShapeOp(); op = new SMESHGUI_GroupOnShapeOp();
break; break;
case 417: //convert to quadratic case 904: // Find element
op = new SMESHGUI_ConvToQuadOp(); op = new SMESHGUI_FindElemByPointOp();
break; break;
case 418: // create 2D mesh as boundary on 3D
op = new SMESHGUI_Make2DFrom3DOp();
break;
case 4067: // make mesh pass through point case 4067: // make mesh pass through point
op = new SMESHGUI_MakeNodeAtPointOp(); op = new SMESHGUI_MakeNodeAtPointOp();
break; break;

View File

@ -0,0 +1,453 @@
// Copyright (C) 2007-2008 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
// 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
//
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
//
// File : SMESHGUI_FindElemByPointDlg.cxx
// Author : Edward AGAPOV, Open CASCADE S.A.S.
// SMESH includes
//
#include "SMESHGUI_FindElemByPointDlg.h"
#include "SMESHGUI.h"
#include "SMESHGUI_MeshUtils.h"
#include "SMESHGUI_VTKUtils.h"
#include "SMESHGUI_SpinBox.h"
#include "SMESHGUI_MeshEditPreview.h"
#include <SMESH_Actor.h>
#include <SMESH_ActorUtils.h>
#include <SMESH_TypeFilter.hxx>
// SALOME GUI includes
#include <LightApp_SelectionMgr.h>
#include <QtxComboBox.h>
#include <SALOME_ListIO.hxx>
#include <SUIT_Desktop.h>
#include <SUIT_MessageBox.h>
#include <SUIT_OverrideCursor.h>
#include <SUIT_ResourceMgr.h>
#include <SVTK_ViewModel.h>
#include <SVTK_ViewWindow.h>
#include <SalomeApp_Tools.h>
#include <SalomeApp_TypeFilter.h>
// Qt includes
#include <QAbstractButton>
#include <QGridLayout>
#include <QGroupBox>
#include <QHBoxLayout>
#include <QLabel>
#include <QLineEdit>
#include <QListWidget>
#include <QPushButton>
#include <QVBoxLayout>
// VTK includes
#include <vtkProperty.h>
// IDL includes
#include <SALOMEconfig.h>
#include CORBA_SERVER_HEADER(SMESH_MeshEditor)
#define SPACING 6
#define MARGIN 11
//=======================================================================
/*!
* \brief Dialog to find elements by a point coordinates
*/
//=======================================================================
SMESHGUI_FindElemByPointDlg::SMESHGUI_FindElemByPointDlg()
: SMESHGUI_Dialog( 0, false, true, OK | Help )
{
setWindowTitle(tr("CAPTION"));
QVBoxLayout* aDlgLay = new QVBoxLayout (mainFrame());
aDlgLay->setMargin(MARGIN);;
aDlgLay->setSpacing(SPACING);
QWidget* aMainFrame = createMainFrame (mainFrame());
aDlgLay->addWidget(aMainFrame);
aDlgLay->setStretchFactor(aMainFrame, 1);
}
//=======================================================================
// function : createMainFrame()
// purpose : Create frame containing dialog's input fields
//=======================================================================
QWidget* SMESHGUI_FindElemByPointDlg::createMainFrame (QWidget* theParent)
{
QWidget* aFrame = new QWidget(theParent);
//mesh name
QGroupBox* aMeshGrp = new QGroupBox(tr("SMESH_MESH"), aFrame);
QHBoxLayout* aMeshGrpLayout = new QHBoxLayout(aMeshGrp);
aMeshGrpLayout->setMargin(MARGIN);
aMeshGrpLayout->setSpacing(SPACING);
myMeshName = new QLineEdit(aMeshGrp);
aMeshGrpLayout->addWidget(myMeshName);
// coordinates
QGroupBox* aCoordGrp = new QGroupBox(tr("SMESH_COORDINATES"), aFrame);
QHBoxLayout* aCoordGrpLayout = new QHBoxLayout(aCoordGrp);
aCoordGrpLayout->setMargin(MARGIN);
aCoordGrpLayout->setSpacing(SPACING);
QLabel* aXLabel = new QLabel(tr("SMESH_X"), aCoordGrp);
myX = new SMESHGUI_SpinBox(aCoordGrp);
QLabel* aYLabel = new QLabel(tr("SMESH_Y"), aCoordGrp);
myY = new SMESHGUI_SpinBox(aCoordGrp);
QLabel* aZLabel = new QLabel(tr("SMESH_Z"), aCoordGrp);
myZ = new SMESHGUI_SpinBox(aCoordGrp);
myX->RangeStepAndValidator(COORD_MIN, COORD_MAX, 10.0, DBL_DIGITS_DISPLAY);
myY->RangeStepAndValidator(COORD_MIN, COORD_MAX, 10.0, DBL_DIGITS_DISPLAY);
myZ->RangeStepAndValidator(COORD_MIN, COORD_MAX, 10.0, DBL_DIGITS_DISPLAY);
myX->SetValue(0);
myY->SetValue(0);
myZ->SetValue(0);
aCoordGrpLayout->addWidget(aXLabel);
aCoordGrpLayout->addWidget(myX);
aCoordGrpLayout->addWidget(aYLabel);
aCoordGrpLayout->addWidget(myY);
aCoordGrpLayout->addWidget(aZLabel);
aCoordGrpLayout->addWidget(myZ);
// Elements
QGroupBox* elementGrp = new QGroupBox(tr("Elements"), aFrame);
QGridLayout* elementGrpLayout = new QGridLayout(elementGrp);
elementGrpLayout->setSpacing(SPACING);
elementGrpLayout->setMargin(MARGIN);
myFindBtn = new QPushButton(elementGrp);
myFindBtn->setText(tr("Find"));
//myFindBtn->setCheckable(false);
myElemTypeCombo = new QtxComboBox(elementGrp);
myElemTypeCombo->addItem( tr( "MEN_ALL" )); myElemTypeCombo->setId( 0, int( SMESH::ALL ));
myElemTypeCombo->addItem( tr( "MEN_NODE" )); myElemTypeCombo->setId( 1, int( SMESH::NODE ));
myElemTypeCombo->addItem( tr( "MEN_EDGE" )); myElemTypeCombo->setId( 2, int( SMESH::EDGE ));
myElemTypeCombo->addItem( tr( "MEN_FACE" )); myElemTypeCombo->setId( 3, int( SMESH::FACE ));
myElemTypeCombo->addItem( tr("MEN_VOLUME_3D"));myElemTypeCombo->setId( 4, int( SMESH::VOLUME));
myElemTypeCombo->addItem( tr( "MEN_ELEM0D" )); myElemTypeCombo->setId( 5, int( SMESH::ELEM0D));
myFoundList = new QListWidget(elementGrp);
elementGrpLayout->addWidget( myFindBtn, 0, 0 );
elementGrpLayout->addWidget( myElemTypeCombo, 0, 1 );
elementGrpLayout->addWidget( myFoundList, 1, 0, 2, 2 );
QVBoxLayout* aLay = new QVBoxLayout(aFrame);
aLay->addWidget(aMeshGrp);
aLay->addWidget(aCoordGrp);
aLay->addWidget(elementGrp);
// OK instead of "Apply and Close"
if ( QAbstractButton* but = button(OK) )
but->setText( tr("SMESH_BUT_OK"));
return aFrame;
}
//================================================================================
/*!
* \brief Constructor
*/
//================================================================================
SMESHGUI_FindElemByPointOp::SMESHGUI_FindElemByPointOp()
:SMESHGUI_SelectionOp()
{
mySimulation = 0;
myDlg = new SMESHGUI_FindElemByPointDlg;
myHelpFileName = "mesh_through_point_page.html";
myFilter = new SMESH_TypeFilter( MESH );
myPreview = new SMESH::MeshPreviewStruct();
myPreview->nodesXYZ.length(1);
myPreview->nodesXYZ[0].x = myDlg->myX->GetValue();
myPreview->nodesXYZ[0].y = myDlg->myY->GetValue();
myPreview->nodesXYZ[0].z = myDlg->myZ->GetValue();
myPreview->elementTypes.length(1);
myPreview->elementTypes[0].SMDS_ElementType = SMESH::NODE;
myPreview->elementTypes[0].isPoly = false;
myPreview->elementTypes[0].nbNodesInElement = 1;
myPreview->elementConnectivities.length(1);
myPreview->elementConnectivities[0] = 0;
// connect signals and slots
connect(myDlg->myFindBtn, SIGNAL(clicked()), this, SLOT(onFind()));
connect(myDlg->myX, SIGNAL(valueChanged(double)), this, SLOT(redisplayPreview()));
connect(myDlg->myY, SIGNAL(valueChanged(double)), this, SLOT(redisplayPreview()));
connect(myDlg->myZ, SIGNAL(valueChanged(double)), this, SLOT(redisplayPreview()));
connect(myDlg->myFoundList, SIGNAL(itemSelectionChanged()), this, SLOT(onElemSelected()));
connect(myDlg->myElemTypeCombo,SIGNAL(currentIndexChanged(int)),this, SLOT(onElemTypeChange(int)));
}
//=======================================================================
// function : startOperation()
// purpose : Init dialog fields, connect signals and slots, show dialog
//=======================================================================
void SMESHGUI_FindElemByPointOp::startOperation()
{
// init simulation with a current View
if ( mySimulation ) delete mySimulation;
mySimulation = new SMESHGUI_MeshEditPreview(SMESH::GetViewWindow( getSMESHGUI() ));
vtkProperty* aProp = vtkProperty::New();
aProp->SetRepresentationToWireframe();
aProp->SetColor(250, 0, 250);
aProp->SetPointSize(5);
aProp->SetLineWidth( SMESH::GetFloat("SMESH:element_width",1) + 1);
mySimulation->GetActor()->SetProperty(aProp);
aProp->Delete();
myDlg->myElemTypeCombo->setCurrentId( int(SMESH::ALL));
SMESHGUI_SelectionOp::startOperation();
myDlg->show();
redisplayPreview();
onSelectionDone(); // init myMesh
}
//================================================================================
/*!
* \brief Stops operation
*/
//================================================================================
void SMESHGUI_FindElemByPointOp::stopOperation()
{
if ( mySimulation )
{
mySimulation->SetVisibility(false);
delete mySimulation;
mySimulation = 0;
}
selectionMgr()->removeFilter( myFilter );
SMESHGUI_SelectionOp::stopOperation();
}
//================================================================================
/*!
* \brief hilight found selected elements
*/
//================================================================================
void SMESHGUI_FindElemByPointOp::onElemSelected()
{
if ( !myMeshIO.IsNull() )
{
Selection_Mode selMode =
myDlg->myElemTypeCombo->currentId() == int(SMESH::NODE) ? NodeSelection : CellSelection;
if ( selectionMode() != selMode )
setSelectionMode( selMode );
QList<QListWidgetItem *> ids = myDlg->myFoundList->selectedItems();
QList<QListWidgetItem*>::iterator id = ids.begin();
TColStd_MapOfInteger idMap;
for ( ; id != ids.end(); ++id )
idMap.Add( (*id)->text().toInt() );
addOrRemoveIndex( myMeshIO, idMap, false );
SALOME_ListIO aList;
aList.Append(myMeshIO);
selectionMgr()->setSelectedObjects(aList,false);
}
}
//================================================================================
/*!
* \brief Set selection mode according to element type
*/
//================================================================================
void SMESHGUI_FindElemByPointOp::onElemTypeChange(int index)
{
Selection_Mode newMode = (index == 1) ? NodeSelection : CellSelection;
if ( selectionMode() != newMode )
{
selectionMgr()->clearFilters();
setSelectionMode( newMode );
}
myDlg->myFoundList->clear();
}
//================================================================================
/*!
* \brief perform it's intention action: find elements
*/
//================================================================================
void SMESHGUI_FindElemByPointOp::onFind()
{
if ( myMesh->_is_nil() ) {
return;
}
try {
SUIT_OverrideCursor wc;
SMESH::SMESH_MeshEditor_var aMeshEditor = myMesh->GetMeshEditor();
if (aMeshEditor->_is_nil())
return;
SMESH::long_array_var foundIds =
aMeshEditor->FindElementsByPoint( myDlg->myX->GetValue(),
myDlg->myY->GetValue(),
myDlg->myZ->GetValue(),
SMESH::ElementType( myDlg->myElemTypeCombo->currentId() ));
myDlg->myFoundList->clear();
for ( int i = 0; i < foundIds->length(); ++i )
myDlg->myFoundList->addItem( QString::number( foundIds[i] ));
if ( foundIds->length() > 0 )
myDlg->myFoundList->setCurrentRow(0);
}
catch (const SALOME::SALOME_Exception& S_ex) {
SalomeApp_Tools::QtCatchCorbaException(S_ex);
}
catch (...) {
}
}
//================================================================================
/*!
* \brief Method needed for internal cuisine
*/
//================================================================================
bool SMESHGUI_FindElemByPointOp::onApply()
{
return true;
}
//================================================================================
/*!
* \brief SLOT called when selection changed
*/
//================================================================================
void SMESHGUI_FindElemByPointOp::onSelectionDone()
{
if ( !myDlg->isVisible() || !myDlg->isEnabled() )
return;
QString oldMeshEntry, newMeshEntry;
if ( !myMeshIO.IsNull() && myMeshIO->hasEntry() )
oldMeshEntry = myMeshIO->getEntry();
myDlg->myMeshName->setText("");
myMeshIO.Nullify();
try {
SALOME_ListIO aList;
selectionMgr()->selectedObjects(aList, SVTK_Viewer::Type());
if (aList.Extent() == 1 && aList.First()->hasEntry())
{
Handle(SALOME_InteractiveObject) anIO = aList.First();
_PTR(SObject) pObj = studyDS()->FindObjectID(anIO->getEntry());
myMesh = SMESH::GetMeshByIO( anIO );
if ( pObj && !myMesh->_is_nil() )
{
myMeshIO = anIO;
myDlg->myMeshName->setText( pObj->GetName().c_str() );
newMeshEntry = anIO->getEntry();
}
}
}
catch (...) {
}
if ( oldMeshEntry != newMeshEntry || newMeshEntry.isEmpty() )
myDlg->myFoundList->clear();
myDlg->myFindBtn->setEnabled( !myMeshIO.IsNull() );
}
//================================================================================
/*!
* \brief show point by coordinates
*/
//================================================================================
void SMESHGUI_FindElemByPointOp::redisplayPreview()
{
myDlg->myFoundList->clear();
myPreview->nodesXYZ[0].x = myDlg->myX->GetValue();
myPreview->nodesXYZ[0].y = myDlg->myY->GetValue();
myPreview->nodesXYZ[0].z = myDlg->myZ->GetValue();
mySimulation->SetData(&myPreview.in());
}
//================================================================================
/*!
* \brief install filter on meshes
*/
//================================================================================
void SMESHGUI_FindElemByPointOp::activateSelection()
{
selectionMgr()->clearFilters();
selectionMgr()->installFilter( myFilter );
}
//================================================================================
/*!
* \brief Destructor
*/
//================================================================================
SMESHGUI_FindElemByPointOp::~SMESHGUI_FindElemByPointOp()
{
if ( myDlg ) { delete myDlg; myDlg = 0; }
if ( mySimulation ) { delete mySimulation; mySimulation = 0; }
if ( myFilter ) { delete myFilter; myFilter = 0; }
}
//================================================================================
/*!
* \brief Gets dialog of this operation
* \retval LightApp_Dialog* - pointer to dialog of this operation
*/
//================================================================================
LightApp_Dialog* SMESHGUI_FindElemByPointOp::dlg() const
{
return myDlg;
}

View File

@ -0,0 +1,113 @@
// Copyright (C) 2007-2008 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
// 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
//
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
//
#ifndef SMESHGUI_FindElemByPointDLG_H
#define SMESHGUI_FindElemByPointDLG_H
// SMESH includes
#include "SMESH_SMESHGUI.hxx"
#include "SMESHGUI_Dialog.h"
#include "SMESHGUI_SelectionOp.h"
#include CORBA_SERVER_HEADER(SMESH_Mesh)
class QLineEdit;
class QPushButton;
class QListWidget;
class QtxComboBox;
class SMESHGUI_SpinBox;
class SMESHGUI_MeshEditPreview;
class SMESHGUI_FindElemByPointDlg;
/*!
* \brief Operation to find elements by a point coordinates
*/
class SMESHGUI_EXPORT SMESHGUI_FindElemByPointOp: public SMESHGUI_SelectionOp
{
Q_OBJECT
public:
SMESHGUI_FindElemByPointOp();
virtual ~SMESHGUI_FindElemByPointOp();
virtual LightApp_Dialog* dlg() const;
protected:
virtual void startOperation();
virtual void stopOperation();
virtual void activateSelection();
protected slots:
virtual void onFind();
virtual bool onApply();
private slots:
void onSelectionDone();
void onElemSelected();
void onElemTypeChange(int);
void redisplayPreview();
private:
SMESHGUI_FindElemByPointDlg* myDlg;
SUIT_SelectionFilter* myFilter;
SMESHGUI_MeshEditPreview* mySimulation; // to show point coordinates
//SMESH_Actor* myMeshActor; // to show found elements
SMESH::SMESH_Mesh_var myMesh;
SMESH::MeshPreviewStruct_var myPreview;
Handle(SALOME_InteractiveObject) myMeshIO;
};
/*!
* \brief Dialog to find elements by a point coordinates
*/
class SMESHGUI_EXPORT SMESHGUI_FindElemByPointDlg : public SMESHGUI_Dialog
{
Q_OBJECT
public:
SMESHGUI_FindElemByPointDlg();
private:
QWidget* createMainFrame( QWidget* );
QLineEdit* myMeshName;
SMESHGUI_SpinBox* myX;
SMESHGUI_SpinBox* myY;
SMESHGUI_SpinBox* myZ;
QtxComboBox* myElemTypeCombo;
QPushButton* myFindBtn;
QListWidget* myFoundList;
QString myHelpFileName;
friend class SMESHGUI_FindElemByPointOp;
private slots:
//void ButtonToggled( bool );
};
#endif // SMESHGUI_FindElemByPointDLG_H

View File

@ -257,6 +257,10 @@
<source>ICON_FREE_FACES</source> <source>ICON_FREE_FACES</source>
<translation>mesh_free_faces.png</translation> <translation>mesh_free_faces.png</translation>
</message> </message>
<message>
<source>ICON_FIND_ELEM</source>
<translation>mesh_find_elem_by_point.png</translation>
</message>
<message> <message>
<source>ICON_HYPO</source> <source>ICON_HYPO</source>
<translation>mesh_hypo_length.png</translation> <translation>mesh_hypo_length.png</translation>

View File

@ -341,6 +341,10 @@
<source>MEN_FILE</source> <source>MEN_FILE</source>
<translation>File</translation> <translation>File</translation>
</message> </message>
<message>
<source>MEN_FIND_ELEM</source>
<translation>Find element by point</translation>
</message>
<message> <message>
<source>MEN_FREE_BORDER</source> <source>MEN_FREE_BORDER</source>
<translation>Free Borders</translation> <translation>Free Borders</translation>
@ -4264,6 +4268,37 @@ Please specify them and try again</translation>
<translation>Mesh to modify not selected</translation> <translation>Mesh to modify not selected</translation>
</message> </message>
</context> </context>
<context>
<name>SMESHGUI_FindElemByPointDlg</name>
<message>
<source>CAPTION</source>
<translation>Find elements at point</translation>
</message>
<message>
<source>CREATE_NEW_METHOD</source>
<translation>Create a node</translation>
</message>
<message>
<source>MESH_PASS_THROUGH_POINT</source>
<translation>Make a node at point</translation>
</message>
<message>
<source>METHOD</source>
<translation>Method</translation>
</message>
<message>
<source>MOVE_EXISTING_METHOD</source>
<translation>Move a node</translation>
</message>
<message>
<source>NODE_2MOVE</source>
<translation>Node to move</translation>
</message>
<message>
<source>NODE_2MOVE_ID</source>
<translation>ID</translation>
</message>
</context>
<context> <context>
<name>SMESHGUI_MeshDlg</name> <name>SMESHGUI_MeshDlg</name>
<message> <message>