Fix of issue 0020614: EDF 1133 SMESH : Put new added elements and nodes to group

This commit is contained in:
ouv 2009-12-28 16:23:43 +00:00
parent 163dc9b8fd
commit 4863327169
22 changed files with 413 additions and 14 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 19 KiB

After

Width:  |  Height:  |  Size: 23 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 10 KiB

After

Width:  |  Height:  |  Size: 15 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 10 KiB

After

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 12 KiB

After

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 9.0 KiB

After

Width:  |  Height:  |  Size: 13 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 12 KiB

After

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 12 KiB

After

Width:  |  Height:  |  Size: 17 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 13 KiB

After

Width:  |  Height:  |  Size: 18 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 12 KiB

After

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 12 KiB

After

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 20 KiB

After

Width:  |  Height:  |  Size: 25 KiB

View File

@ -26,6 +26,10 @@ following associated submenu will appear:</li>
\image html image146.png
From this submenu select the type of element which you would like to add to your mesh.
\note All dialogs intended for adding nodes or elements to mesh provide a possibility
to add these nodes/elements to the specified group (or to create the group if it
doesn't exist). <b>Add to group</b> box allows to choose an existing group for created
node or element or to specify a name for new group.
</ol>
<b>See Also</b> sample TUI Scripts of

View File

@ -18,6 +18,11 @@ one of the following:
\image html image152.png
\note All dialogs intended for adding quadratic elements to mesh provide a possibility
to add these elements to the specified group (or to create the group if it doesn't exist).
<b>Add to group</b> box allows to choose an existing group for created element or
to specify a name for new group.
To create any <b>Quadratic Element</b> specify the nodes which will form your
triangle by selecting them in the 3D viewer with pressed Shift
button. Their numbers will appear in the dialog box as <b>Corner Nodes</b>

View File

@ -30,6 +30,7 @@
#include "SMESHGUI_Utils.h"
#include "SMESHGUI_VTKUtils.h"
#include "SMESHGUI_MeshUtils.h"
#include "SMESHGUI_GroupUtils.h"
#include "SMESHGUI_IdValidator.h"
#include <SMESH_Actor.h>
@ -64,6 +65,7 @@
#include <vtkProperty.h>
// Qt includes
#include <QComboBox>
#include <QGroupBox>
#include <QLabel>
#include <QLineEdit>
@ -358,6 +360,20 @@ SMESHGUI_AddMeshElementDlg::SMESHGUI_AddMeshElementDlg( SMESHGUI* theModule,
GroupC1Layout->addWidget(LineEditC1A1, 0, 2);
if ( Reverse ) GroupC1Layout->addWidget(Reverse, 1, 0, 1, 3);
/***************************************************************/
GroupGroups = new QGroupBox( tr( "SMESH_ADD_TO_GROUP" ), this );
GroupGroups->setCheckable( true );
QHBoxLayout* GroupGroupsLayout = new QHBoxLayout(GroupGroups);
GroupGroupsLayout->setSpacing(SPACING);
GroupGroupsLayout->setMargin(MARGIN);
TextLabel_GroupName = new QLabel( tr( "SMESH_GROUP" ), GroupGroups );
ComboBox_GroupName = new QComboBox( GroupGroups );
ComboBox_GroupName->setEditable( true );
GroupGroupsLayout->addWidget( TextLabel_GroupName );
GroupGroupsLayout->addWidget( ComboBox_GroupName, 1 );
/***************************************************************/
GroupButtons = new QGroupBox(this);
QHBoxLayout* GroupButtonsLayout = new QHBoxLayout(GroupButtons);
@ -385,6 +401,7 @@ SMESHGUI_AddMeshElementDlg::SMESHGUI_AddMeshElementDlg( SMESHGUI* theModule,
/***************************************************************/
aTopLayout->addWidget(GroupConstructors);
aTopLayout->addWidget(GroupC1);
aTopLayout->addWidget(GroupGroups);
aTopLayout->addWidget(GroupButtons);
Init(); /* Initialisations */
@ -410,6 +427,9 @@ void SMESHGUI_AddMeshElementDlg::Init()
myEditCurrentArgument = LineEditC1A1;
mySMESHGUI->SetActiveDialogBox((QDialog*)this);
/* reset "Add to group" control */
GroupGroups->setChecked( false );
myNbOkNodes = 0;
myActor = 0;
@ -446,6 +466,9 @@ void SMESHGUI_AddMeshElementDlg::Init()
//=================================================================================
void SMESHGUI_AddMeshElementDlg::ClickOnApply()
{
if( !isValid() )
return;
if (myNbOkNodes && !mySMESHGUI->isActiveStudyLocked()) {
myBusy = true;
SMESH::long_array_var anArrayOfIndices = new SMESH::long_array;
@ -458,24 +481,53 @@ void SMESHGUI_AddMeshElementDlg::ClickOnApply()
else
anArrayOfIndices[i] = aListId[ i ].toInt();
long anElemId = -1;
SMESH::SMESH_MeshEditor_var aMeshEditor = myMesh->GetMeshEditor();
switch (myElementType) {
case SMDSAbs_0DElement:
aMeshEditor->Add0DElement(anArrayOfIndices[0]); break;
anElemId = aMeshEditor->Add0DElement(anArrayOfIndices[0]); break;
case SMDSAbs_Edge:
aMeshEditor->AddEdge(anArrayOfIndices.inout()); break;
anElemId = aMeshEditor->AddEdge(anArrayOfIndices.inout()); break;
case SMDSAbs_Face: {
if(myIsPoly)
aMeshEditor->AddPolygonalFace(anArrayOfIndices.inout());
anElemId = aMeshEditor->AddPolygonalFace(anArrayOfIndices.inout());
else
aMeshEditor->AddFace(anArrayOfIndices.inout());
anElemId = aMeshEditor->AddFace(anArrayOfIndices.inout());
break;
}
case SMDSAbs_Volume:
aMeshEditor->AddVolume(anArrayOfIndices.inout()); break;
anElemId = aMeshEditor->AddVolume(anArrayOfIndices.inout()); break;
default:;
}
if( anElemId != -1 && GroupGroups->isChecked() ) {
SMESH::SMESH_Group_var aGroup;
QString aGroupName = ComboBox_GroupName->currentText();
SMESH::ListOfGroups aListOfGroups = *myMesh->GetGroups();
for( int i = 0, n = aListOfGroups.length(); i < n; i++ ) {
SMESH::SMESH_GroupBase_var aGroupBase = aListOfGroups[i];
if( !aGroupBase->_is_nil() ) {
SMESH::SMESH_Group_var aRefGroup = SMESH::SMESH_Group::_narrow( aGroupBase );
if( !aRefGroup->_is_nil() ) {
QString aRefGroupName( aRefGroup->GetName() );
if( aRefGroupName == aGroupName ) {
aGroup = aRefGroup; // // add node to existing group
break;
}
}
}
}
if( aGroup->_is_nil() ) // create new group
aGroup = SMESH::AddGroup( myMesh, (SMESH::ElementType)myElementType, aGroupName );
if( !aGroup->_is_nil() ) {
SMESH::long_array_var anIdList = new SMESH::long_array;
anIdList->length( 1 );
anIdList[0] = anElemId;
aGroup->Add( anIdList.inout() );
}
}
SALOME_ListIO aList; aList.Append( myActor->getIO() );
mySelector->ClearIndex();
mySelectionMgr->setSelectedObjects( aList, false );
@ -628,6 +680,8 @@ void SMESHGUI_AddMeshElementDlg::SelectionIntoArgument()
mySimulation->SetVisibility(false);
// SMESH::SetPointRepresentation(true);
QString aCurrentEntry = myEntry;
// get selected mesh
SALOME_ListIO aList;
mySelectionMgr->selectedObjects(aList,SVTK_Viewer::Type());
@ -636,10 +690,29 @@ void SMESHGUI_AddMeshElementDlg::SelectionIntoArgument()
return;
Handle(SALOME_InteractiveObject) anIO = aList.First();
myEntry = anIO->getEntry();
myMesh = SMESH::GetMeshByIO(anIO);
if (myMesh->_is_nil())
return;
// process groups
if ( !myMesh->_is_nil() && myEntry != aCurrentEntry ) {
ComboBox_GroupName->clear();
ComboBox_GroupName->addItem( QString() );
SMESH::ListOfGroups aListOfGroups = *myMesh->GetGroups();
for ( int i = 0, n = aListOfGroups.length(); i < n; i++ ) {
SMESH::SMESH_GroupBase_var aGroupBase = aListOfGroups[i];
if ( !aGroupBase->_is_nil() && aGroupBase->GetType() == (SMESH::ElementType)myElementType ) {
SMESH::SMESH_Group_var aGroup = SMESH::SMESH_Group::_narrow( aGroupBase );
if ( !aGroup->_is_nil() ) {
QString aGroupName( aGroup->GetName() );
if ( !aGroupName.isEmpty() )
ComboBox_GroupName->addItem( aGroupName );
}
}
}
}
myActor = SMESH::FindActorByEntry(anIO->getEntry());
if (!myActor)
return;
@ -812,3 +885,16 @@ void SMESHGUI_AddMeshElementDlg::keyPressEvent( QKeyEvent* e )
ClickOnHelp();
}
}
//=================================================================================
// function : isValid
// purpose :
//=================================================================================
bool SMESHGUI_AddMeshElementDlg::isValid()
{
if( GroupGroups->isChecked() && ComboBox_GroupName->currentText().isEmpty() ) {
SUIT_MessageBox::warning( this, tr( "SMESH_WRN_WARNING" ), tr( "GROUP_NAME_IS_EMPTY" ) );
return false;
}
return true;
}

View File

@ -38,6 +38,7 @@
#include <SALOMEconfig.h>
#include CORBA_SERVER_HEADER(SMESH_Mesh)
class QComboBox;
class QGroupBox;
class QLabel;
class QLineEdit;
@ -74,6 +75,8 @@ private:
void keyPressEvent( QKeyEvent* );
void displaySimulation();
bool isValid();
SMESHGUI* mySMESHGUI; /* Current SMESHGUI object */
LightApp_SelectionMgr* mySelectionMgr; /* User shape selection */
int myNbOkNodes; /* to check when arguments is defined */
@ -89,9 +92,13 @@ private:
SMESH::SMESH_Mesh_var myMesh;
SMESH_Actor* myActor;
SMESH::TElementSimulation* mySimulation;
QString myEntry;
QGroupBox* GroupConstructors;
QRadioButton* Constructor1;
QGroupBox* GroupGroups;
QLabel* TextLabel_GroupName;
QComboBox* ComboBox_GroupName;
QGroupBox* GroupButtons;
QPushButton* buttonOk;
QPushButton* buttonCancel;

View File

@ -30,6 +30,7 @@
#include "SMESHGUI_Utils.h"
#include "SMESHGUI_VTKUtils.h"
#include "SMESHGUI_MeshUtils.h"
#include "SMESHGUI_GroupUtils.h"
#include "SMESHGUI_IdValidator.h"
#include <SMESH_Actor.h>
@ -69,6 +70,7 @@
#include <vtkCellType.h>
// Qt includes
#include <QComboBox>
#include <QGroupBox>
#include <QLabel>
#include <QLineEdit>
@ -505,6 +507,20 @@ SMESHGUI_AddQuadraticElementDlg::SMESHGUI_AddQuadraticElementDlg( SMESHGUI* theM
aGroupArgumentsLayout->addWidget(myTable, 1, 0, 1, 3);
aGroupArgumentsLayout->addWidget(myReverseCB, 2, 0, 1, 3);
/***************************************************************/
GroupGroups = new QGroupBox( tr( "SMESH_ADD_TO_GROUP" ), this );
GroupGroups->setCheckable( true );
QHBoxLayout* GroupGroupsLayout = new QHBoxLayout(GroupGroups);
GroupGroupsLayout->setSpacing(SPACING);
GroupGroupsLayout->setMargin(MARGIN);
TextLabel_GroupName = new QLabel( tr( "SMESH_GROUP" ), GroupGroups );
ComboBox_GroupName = new QComboBox( GroupGroups );
ComboBox_GroupName->setEditable( true );
GroupGroupsLayout->addWidget( TextLabel_GroupName );
GroupGroupsLayout->addWidget( ComboBox_GroupName, 1 );
/***************************************************************/
GroupButtons = new QGroupBox(this);
QHBoxLayout* aGroupButtonsLayout = new QHBoxLayout(GroupButtons);
@ -532,6 +548,7 @@ SMESHGUI_AddQuadraticElementDlg::SMESHGUI_AddQuadraticElementDlg( SMESHGUI* theM
/***************************************************************/
aDialogLayout->addWidget(GroupConstructors);
aDialogLayout->addWidget(GroupArguments);
aDialogLayout->addWidget(GroupGroups);
aDialogLayout->addWidget(GroupButtons);
Init(); /* Initialisations */
@ -555,6 +572,9 @@ void SMESHGUI_AddQuadraticElementDlg::Init()
myRadioButton1->setChecked(true);
mySMESHGUI->SetActiveDialogBox((QDialog*)this);
/* reset "Add to group" control */
GroupGroups->setChecked( false );
myActor = 0;
int aNumRows;
@ -661,6 +681,9 @@ void SMESHGUI_AddQuadraticElementDlg::Init()
//=================================================================================
void SMESHGUI_AddQuadraticElementDlg::ClickOnApply()
{
if( !isValid() )
return;
if ( mySMESHGUI->isActiveStudyLocked() || myBusy || !IsValid() )
return;
@ -696,20 +719,53 @@ void SMESHGUI_AddQuadraticElementDlg::ClickOnApply()
for (int i = 0; i < aNumberOfIds; i++)
anArrayOfIdeces[i] = anIds[ i ];
SMESH::ElementType anElementType;
long anElemId = -1;
SMESH::SMESH_MeshEditor_var aMeshEditor = myMesh->GetMeshEditor();
switch (myType) {
case QUAD_EDGE:
aMeshEditor->AddEdge(anArrayOfIdeces.inout()); break;
anElementType = SMESH::EDGE;
anElemId = aMeshEditor->AddEdge(anArrayOfIdeces.inout()); break;
case QUAD_TRIANGLE:
case QUAD_QUADRANGLE:
aMeshEditor->AddFace(anArrayOfIdeces.inout()); break;
anElementType = SMESH::FACE;
anElemId = aMeshEditor->AddFace(anArrayOfIdeces.inout()); break;
case QUAD_TETRAHEDRON:
case QUAD_PYRAMID:
case QUAD_PENTAHEDRON:
case QUAD_HEXAHEDRON:
aMeshEditor->AddVolume(anArrayOfIdeces.inout()); break;
anElementType = SMESH::VOLUME;
anElemId = aMeshEditor->AddVolume(anArrayOfIdeces.inout()); break;
}
if( anElemId != -1 && GroupGroups->isChecked() ) {
SMESH::SMESH_Group_var aGroup;
QString aGroupName = ComboBox_GroupName->currentText();
SMESH::ListOfGroups aListOfGroups = *myMesh->GetGroups();
for( int i = 0, n = aListOfGroups.length(); i < n; i++ ) {
SMESH::SMESH_GroupBase_var aGroupBase = aListOfGroups[i];
if( !aGroupBase->_is_nil() ) {
SMESH::SMESH_Group_var aRefGroup = SMESH::SMESH_Group::_narrow( aGroupBase );
if( !aRefGroup->_is_nil() ) {
QString aRefGroupName( aRefGroup->GetName() );
if( aRefGroupName == aGroupName ) {
aGroup = aRefGroup; // // add node to existing group
break;
}
}
}
}
if( aGroup->_is_nil() ) // create new group
aGroup = SMESH::AddGroup( myMesh, anElementType, aGroupName );
if( !aGroup->_is_nil() ) {
SMESH::long_array_var anIdList = new SMESH::long_array;
anIdList->length( 1 );
anIdList[0] = anElemId;
aGroup->Add( anIdList.inout() );
}
}
SALOME_ListIO aList; aList.Append( myActor->getIO() );
mySelector->ClearIndex();
mySelectionMgr->setSelectedObjects( aList, false );
@ -827,6 +883,8 @@ void SMESHGUI_AddQuadraticElementDlg::SelectionIntoArgument()
if (myBusy) return;
BusyLocker lock( myBusy );
QString aCurrentEntry = myEntry;
if ( myIsEditCorners )
{
// clear
@ -851,6 +909,7 @@ void SMESHGUI_AddQuadraticElementDlg::SelectionIntoArgument()
}
Handle(SALOME_InteractiveObject) anIO = aList.First();
myEntry = anIO->getEntry();
myMesh = SMESH::GetMeshByIO(anIO);
if (myMesh->_is_nil()) {
updateButtons();
@ -860,6 +919,37 @@ void SMESHGUI_AddQuadraticElementDlg::SelectionIntoArgument()
myActor = SMESH::FindActorByEntry(anIO->getEntry());
}
// process groups
if ( !myMesh->_is_nil() && myEntry != aCurrentEntry ) {
SMESH::ElementType anElementType;
switch ( myType ) {
case QUAD_EDGE:
anElementType = SMESH::EDGE; break;
case QUAD_TRIANGLE:
case QUAD_QUADRANGLE:
anElementType = SMESH::FACE; break;
case QUAD_TETRAHEDRON:
case QUAD_PYRAMID:
case QUAD_PENTAHEDRON:
case QUAD_HEXAHEDRON:
anElementType = SMESH::VOLUME; break;
}
ComboBox_GroupName->clear();
ComboBox_GroupName->addItem( QString() );
SMESH::ListOfGroups aListOfGroups = *myMesh->GetGroups();
for ( int i = 0, n = aListOfGroups.length(); i < n; i++ ) {
SMESH::SMESH_GroupBase_var aGroupBase = aListOfGroups[i];
if ( !aGroupBase->_is_nil() && aGroupBase->GetType() == anElementType ) {
SMESH::SMESH_Group_var aGroup = SMESH::SMESH_Group::_narrow( aGroupBase );
if ( !aGroup->_is_nil() ) {
QString aGroupName( aGroup->GetName() );
if ( !aGroupName.isEmpty() )
ComboBox_GroupName->addItem( aGroupName );
}
}
}
}
if (!myActor) {
updateButtons();
@ -1169,3 +1259,16 @@ void SMESHGUI_AddQuadraticElementDlg::updateButtons()
buttonOk->setEnabled( valid );
buttonApply->setEnabled( valid );
}
//=================================================================================
// function : isValid
// purpose :
//=================================================================================
bool SMESHGUI_AddQuadraticElementDlg::isValid()
{
if( GroupGroups->isChecked() && ComboBox_GroupName->currentText().isEmpty() ) {
SUIT_MessageBox::warning( this, tr( "SMESH_WRN_WARNING" ), tr( "GROUP_NAME_IS_EMPTY" ) );
return false;
}
return true;
}

View File

@ -36,7 +36,9 @@
#include <SALOMEconfig.h>
#include CORBA_SERVER_HEADER(SMESH_Mesh)
class QComboBox;
class QGroupBox;
class QLabel;
class QLineEdit;
class QPushButton;
class QRadioButton;
@ -78,6 +80,8 @@ private:
bool IsValid();
void updateButtons();
bool isValid();
SMESHGUI* mySMESHGUI; /* Current SMESHGUI object */
LightApp_SelectionMgr* mySelectionMgr; /* User shape selection */
int myNbCorners; /* The required number of corners */
@ -87,6 +91,7 @@ private:
SMESH::SMESH_Mesh_var myMesh;
SMESH_Actor* myActor;
SMESH::TElementSimulation* mySimulation;
QString myEntry;
int myType;
bool myIsEditCorners;
@ -100,6 +105,10 @@ private:
QTableWidget* myTable;
QCheckBox* myReverseCB;
QGroupBox* GroupGroups;
QLabel* TextLabel_GroupName;
QComboBox* ComboBox_GroupName;
QGroupBox* GroupButtons;
QPushButton* buttonOk;
QPushButton* buttonCancel;

View File

@ -30,6 +30,7 @@
#include "SMESHGUI_Utils.h"
#include "SMESHGUI_VTKUtils.h"
#include "SMESHGUI_MeshUtils.h"
#include "SMESHGUI_GroupUtils.h"
#include "SMESHGUI_IdValidator.h"
#include <SMESH_Actor.h>
@ -63,6 +64,7 @@
// Qt includes
#include <QApplication>
#include <QButtonGroup>
#include <QComboBox>
#include <QGroupBox>
#include <QLabel>
#include <QLineEdit>
@ -246,6 +248,20 @@ SMESHGUI_CreatePolyhedralVolumeDlg::SMESHGUI_CreatePolyhedralVolumeDlg( SMESHGUI
GroupContentLayout->addWidget( RemoveButton, 3, 3 );
GroupContentLayout->addWidget( Preview, 5, 0, 1, 4 );
/***************************************************************/
GroupGroups = new QGroupBox( tr( "SMESH_ADD_TO_GROUP" ), this );
GroupGroups->setCheckable( true );
QHBoxLayout* GroupGroupsLayout = new QHBoxLayout(GroupGroups);
GroupGroupsLayout->setSpacing(SPACING);
GroupGroupsLayout->setMargin(MARGIN);
TextLabel_GroupName = new QLabel( tr( "SMESH_GROUP" ), GroupGroups );
ComboBox_GroupName = new QComboBox( GroupGroups );
ComboBox_GroupName->setEditable( true );
GroupGroupsLayout->addWidget( TextLabel_GroupName );
GroupGroupsLayout->addWidget( ComboBox_GroupName, 1 );
/***************************************************************/
GroupButtons = new QGroupBox( this );
QHBoxLayout* GroupButtonsLayout = new QHBoxLayout( GroupButtons );
@ -273,6 +289,7 @@ SMESHGUI_CreatePolyhedralVolumeDlg::SMESHGUI_CreatePolyhedralVolumeDlg( SMESHGUI
/***************************************************************/
topLayout->addWidget( ConstructorsBox );
topLayout->addWidget( GroupContent );
topLayout->addWidget( GroupGroups );
topLayout->addWidget( GroupButtons );
mySelector = (SMESH::GetViewWindow( mySMESHGUI ))->GetSelector();
@ -306,6 +323,9 @@ void SMESHGUI_CreatePolyhedralVolumeDlg::Init()
myEditCurrentArgument = LineEditElements;
mySMESHGUI->SetActiveDialogBox( (QDialog*)this );
/* reset "Add to group" control */
GroupGroups->setChecked( false );
myNbOkElements = 0;
myActor = 0;
@ -420,10 +440,14 @@ void SMESHGUI_CreatePolyhedralVolumeDlg::ClickOnPreview(bool theToggled){
//=================================================================================
void SMESHGUI_CreatePolyhedralVolumeDlg::ClickOnApply()
{
if( !isValid() )
return;
if ( myNbOkElements>0 && !mySMESHGUI->isActiveStudyLocked())
{
if(checkEditLine(false) == -1) {return;}
busy = true;
long anElemId = -1;
if (GetConstructorId() == 0)
{
SMESH::long_array_var anIdsOfNodes = new SMESH::long_array;
@ -453,7 +477,7 @@ void SMESHGUI_CreatePolyhedralVolumeDlg::ClickOnApply()
try{
SUIT_OverrideCursor aWaitCursor;
SMESH::SMESH_MeshEditor_var aMeshEditor = myMesh->GetMeshEditor();
aMeshEditor->AddPolyhedralVolume(anIdsOfNodes, aQuantities);
anElemId = aMeshEditor->AddPolyhedralVolume(anIdsOfNodes, aQuantities);
}catch(SALOME::SALOME_Exception& exc){
INFOS("Follow exception was cought:\n\t"<<exc.details.text);
}catch(std::exception& exc){
@ -474,7 +498,7 @@ void SMESHGUI_CreatePolyhedralVolumeDlg::ClickOnApply()
try{
SUIT_OverrideCursor aWaitCursor;
SMESH::SMESH_MeshEditor_var aMeshEditor = myMesh->GetMeshEditor();
aMeshEditor->AddPolyhedralVolumeByFaces(anIdsOfFaces);
anElemId = aMeshEditor->AddPolyhedralVolumeByFaces(anIdsOfFaces);
}catch(SALOME::SALOME_Exception& exc){
INFOS("Follow exception was cought:\n\t"<<exc.details.text);
}catch(std::exception& exc){
@ -483,7 +507,35 @@ void SMESHGUI_CreatePolyhedralVolumeDlg::ClickOnApply()
INFOS("Unknown exception was cought !!!");
}
}
if( anElemId != -1 && GroupGroups->isChecked() ) {
SMESH::SMESH_Group_var aGroup;
QString aGroupName = ComboBox_GroupName->currentText();
SMESH::ListOfGroups aListOfGroups = *myMesh->GetGroups();
for( int i = 0, n = aListOfGroups.length(); i < n; i++ ) {
SMESH::SMESH_GroupBase_var aGroupBase = aListOfGroups[i];
if( !aGroupBase->_is_nil() ) {
SMESH::SMESH_Group_var aRefGroup = SMESH::SMESH_Group::_narrow( aGroupBase );
if( !aRefGroup->_is_nil() ) {
QString aRefGroupName( aRefGroup->GetName() );
if( aRefGroupName == aGroupName ) {
aGroup = aRefGroup; // // add node to existing group
break;
}
}
}
}
if( aGroup->_is_nil() ) // create new group
aGroup = SMESH::AddGroup( myMesh, SMESH::VOLUME, aGroupName );
if( !aGroup->_is_nil() ) {
SMESH::long_array_var anIdList = new SMESH::long_array;
anIdList->length( 1 );
anIdList[0] = anElemId;
aGroup->Add( anIdList.inout() );
}
}
//SALOME_ListIO aList;
//mySelectionMgr->setSelectedObjects( aList );
SMESH::UpdateView();
@ -663,6 +715,8 @@ void SMESHGUI_CreatePolyhedralVolumeDlg::SelectionIntoArgument()
mySimulation->SetVisibility(false);
QString aCurrentEntry = myEntry;
// get selected mesh
SALOME_ListIO selected;
@ -672,10 +726,29 @@ void SMESHGUI_CreatePolyhedralVolumeDlg::SelectionIntoArgument()
return;
}
myEntry = selected.First()->getEntry();
myMesh = SMESH::GetMeshByIO( selected.First() );
if ( myMesh->_is_nil() )
return;
// process groups
if ( !myMesh->_is_nil() && myEntry != aCurrentEntry ) {
ComboBox_GroupName->clear();
ComboBox_GroupName->addItem( QString() );
SMESH::ListOfGroups aListOfGroups = *myMesh->GetGroups();
for ( int i = 0, n = aListOfGroups.length(); i < n; i++ ) {
SMESH::SMESH_GroupBase_var aGroupBase = aListOfGroups[i];
if ( !aGroupBase->_is_nil() && aGroupBase->GetType() == SMESH::VOLUME ) {
SMESH::SMESH_Group_var aGroup = SMESH::SMESH_Group::_narrow( aGroupBase );
if ( !aGroup->_is_nil() ) {
QString aGroupName( aGroup->GetName() );
if ( !aGroupName.isEmpty() )
ComboBox_GroupName->addItem( aGroupName );
}
}
}
}
myActor = SMESH::FindActorByObject(myMesh);
if ( !myActor )
return;
@ -1062,3 +1135,16 @@ void SMESHGUI_CreatePolyhedralVolumeDlg::keyPressEvent( QKeyEvent* e )
ClickOnHelp();
}
}
//=================================================================================
// function : isValid
// purpose :
//=================================================================================
bool SMESHGUI_CreatePolyhedralVolumeDlg::isValid()
{
if( GroupGroups->isChecked() && ComboBox_GroupName->currentText().isEmpty() ) {
SUIT_MessageBox::warning( this, tr( "SMESH_WRN_WARNING" ), tr( "GROUP_NAME_IS_EMPTY" ) );
return false;
}
return true;
}

View File

@ -37,6 +37,7 @@
#include CORBA_SERVER_HEADER(SMESH_Mesh)
class QButtonGroup;
class QComboBox;
class QGroupBox;
class QListWidget;
class QLabel;
@ -75,6 +76,8 @@ private:
int GetConstructorId();
void displaySimulation();
bool isValid();
int checkEditLine( bool = true ); /*! Checking for indices, return 1 if all ok, esle -1*/
SMESHGUI* mySMESHGUI; /* Current SMESHGUI object */
@ -88,12 +91,16 @@ private:
SMESH::SMESH_Mesh_var myMesh;
SMESH_Actor* myActor;
SMESH::TPolySimulation* mySimulation;
QString myEntry;
QGroupBox* ConstructorsBox;
QButtonGroup* GroupConstructors;
QRadioButton* RadioButton1;
QRadioButton* RadioButton2;
QCheckBox* Preview;
QGroupBox* GroupGroups;
QLabel* TextLabel_GroupName;
QComboBox* ComboBox_GroupName;
QGroupBox* GroupButtons;
QPushButton* buttonOk;
QPushButton* buttonCancel;

View File

@ -31,6 +31,7 @@
#include "SMESHGUI_Utils.h"
#include "SMESHGUI_VTKUtils.h"
#include "SMESHGUI_MeshUtils.h"
#include "SMESHGUI_GroupUtils.h"
#include <SMESH_Actor.h>
#include <SMESH_ActorUtils.h>
@ -70,6 +71,7 @@
#include <vtkPoints.h>
// Qt includes
#include <QComboBox>
#include <QGroupBox>
#include <QLabel>
#include <QPushButton>
@ -88,13 +90,14 @@
namespace SMESH
{
void AddNode( SMESH::SMESH_Mesh_ptr theMesh, float x, float y, float z, const QStringList& theParameters )
long AddNode( SMESH::SMESH_Mesh_ptr theMesh, float x, float y, float z, const QStringList& theParameters )
{
long aNodeId = -1;
SUIT_OverrideCursor wc;
try {
_PTR(SObject) aSobj = SMESH::FindSObject( theMesh );
SMESH::SMESH_MeshEditor_var aMeshEditor = theMesh->GetMeshEditor();
aMeshEditor->AddNode( x, y, z );
aNodeId = aMeshEditor->AddNode( x, y, z );
theMesh->SetParameters( theParameters.join(":").toLatin1().constData() );
_PTR(Study) aStudy = GetActiveStudyDocument();
CORBA::Long anId = aStudy->StudyId();
@ -111,6 +114,7 @@ namespace SMESH
catch ( ... ) {
INFOS( "Unknown exception was cought !!!" );
}
return aNodeId;
}
class TNodeSimulation
@ -277,6 +281,21 @@ SMESHGUI_NodesDlg::SMESHGUI_NodesDlg( SMESHGUI* theModule ):
GroupCoordinatesLayout->addWidget( TextLabel_Z );
GroupCoordinatesLayout->addWidget( SpinBox_Z );
/***************************************************************/
GroupGroups = new QGroupBox( tr( "SMESH_ADD_TO_GROUP" ), this );
GroupGroups->setCheckable( true );
QHBoxLayout* GroupGroupsLayout = new QHBoxLayout(GroupGroups);
GroupGroupsLayout->setSpacing(SPACING);
GroupGroupsLayout->setMargin(MARGIN);
TextLabel_GroupName = new QLabel( tr( "SMESH_GROUP" ), GroupGroups );
ComboBox_GroupName = new QComboBox( GroupGroups );
ComboBox_GroupName->setEditable( true );
GroupGroupsLayout->addWidget( TextLabel_GroupName );
GroupGroupsLayout->addWidget( ComboBox_GroupName, 1 );
/***************************************************************/
GroupButtons = new QGroupBox( this );
QHBoxLayout* GroupButtonsLayout = new QHBoxLayout( GroupButtons );
@ -303,6 +322,7 @@ SMESHGUI_NodesDlg::SMESHGUI_NodesDlg( SMESHGUI* theModule ):
/***************************************************************/
SMESHGUI_NodesDlgLayout->addWidget( GroupConstructors );
SMESHGUI_NodesDlgLayout->addWidget( GroupCoordinates );
SMESHGUI_NodesDlgLayout->addWidget( GroupGroups );
SMESHGUI_NodesDlgLayout->addWidget( GroupButtons );
myHelpFileName = "adding_nodes_and_elements_page.html#adding_nodes_anchor";
@ -337,6 +357,9 @@ void SMESHGUI_NodesDlg::Init()
SpinBox_Y->SetValue( 0.0 );
SpinBox_Z->SetValue( 0.0 );
/* reset "Add to group" control */
GroupGroups->setChecked( false );
mySMESHGUI->SetActiveDialogBox( this );
/* signals and slots connections */
@ -416,9 +439,37 @@ bool SMESHGUI_NodesDlg::ClickOnApply()
aParameters << SpinBox_Z->text();
mySimulation->SetVisibility( false );
SMESH::AddNode( myMesh, x, y, z, aParameters );
long aNodeId = SMESH::AddNode( myMesh, x, y, z, aParameters );
SMESH::SetPointRepresentation( true );
if( aNodeId != -1 && GroupGroups->isChecked() ) {
SMESH::SMESH_Group_var aGroup;
QString aGroupName = ComboBox_GroupName->currentText();
SMESH::ListOfGroups aListOfGroups = *myMesh->GetGroups();
for( int i = 0, n = aListOfGroups.length(); i < n; i++ ) {
SMESH::SMESH_GroupBase_var aGroupBase = aListOfGroups[i];
if( !aGroupBase->_is_nil() ) {
SMESH::SMESH_Group_var aRefGroup = SMESH::SMESH_Group::_narrow( aGroupBase );
if( !aRefGroup->_is_nil() ) {
QString aRefGroupName( aRefGroup->GetName() );
if( aRefGroupName == aGroupName ) {
aGroup = aRefGroup; // // add node to existing group
break;
}
}
}
}
if( aGroup->_is_nil() ) // create new group
aGroup = SMESH::AddGroup( myMesh, SMESH::NODE, aGroupName );
if( !aGroup->_is_nil() ) {
SMESH::long_array_var anIdList = new SMESH::long_array;
anIdList->length( 1 );
anIdList[0] = aNodeId;
aGroup->Add( anIdList.inout() );
}
}
// select myMesh
SALOME_ListIO aList;
mySelectionMgr->selectedObjects( aList );
@ -500,10 +551,13 @@ void SMESHGUI_NodesDlg::SelectionIntoArgument()
mySimulation->SetVisibility( false );
SMESH::SetPointRepresentation( true );
QString aCurrentEntry = myEntry;
const SALOME_ListIO& aList = mySelector->StoredIObjects();
if ( aList.Extent() == 1 ) {
Handle(SALOME_InteractiveObject) anIO = aList.First();
if ( anIO->hasEntry() ) {
myEntry = anIO->getEntry();
myMesh = SMESH::GetMeshByIO( anIO );
if ( myMesh->_is_nil() ) return;
QString aText;
@ -523,6 +577,24 @@ void SMESHGUI_NodesDlg::SelectionIntoArgument()
SpinBox_Z->GetValue() );
}
}
// process groups
if ( !myMesh->_is_nil() && myEntry != aCurrentEntry ) {
ComboBox_GroupName->clear();
ComboBox_GroupName->addItem( QString() );
SMESH::ListOfGroups aListOfGroups = *myMesh->GetGroups();
for( int i = 0, n = aListOfGroups.length(); i < n; i++ ) {
SMESH::SMESH_GroupBase_var aGroupBase = aListOfGroups[i];
if ( !aGroupBase->_is_nil() && aGroupBase->GetType() == SMESH::NODE ) {
SMESH::SMESH_Group_var aGroup = SMESH::SMESH_Group::_narrow( aGroupBase );
if ( !aGroup->_is_nil() ) {
QString aGroupName( aGroup->GetName() );
if ( !aGroupName.isEmpty() )
ComboBox_GroupName->addItem( aGroupName );
}
}
}
}
}
//=================================================================================
@ -623,5 +695,10 @@ bool SMESHGUI_NodesDlg::isValid()
SUIT_MessageBox::critical( this, tr( "SMESH_ERROR" ), str );
return false;
}
if( GroupGroups->isChecked() && ComboBox_GroupName->currentText().isEmpty() ) {
SUIT_MessageBox::warning( this, tr( "SMESH_WRN_WARNING" ), tr( "GROUP_NAME_IS_EMPTY" ) );
return false;
}
return true;
}

View File

@ -36,6 +36,7 @@
#include <SALOMEconfig.h>
#include CORBA_SERVER_HEADER(SMESH_Mesh)
class QComboBox;
class QGroupBox;
class QLabel;
class QPushButton;
@ -70,6 +71,7 @@ private:
SMESH::SMESH_Mesh_var myMesh;
SMESH::TNodeSimulation* mySimulation;
QString myEntry;
void Init();
void enterEvent( QEvent* );
@ -90,6 +92,10 @@ private:
QLabel* TextLabel_Y;
QLabel* TextLabel_Z;
QGroupBox* GroupGroups;
QLabel* TextLabel_GroupName;
QComboBox* ComboBox_GroupName;
QGroupBox* GroupButtons;
QPushButton* buttonApply;
QPushButton* buttonOk;

View File

@ -742,6 +742,11 @@ Please, select a mesh and try again</translation>
<source>MULTI_BORDERS</source>
<translation>Borders at Multi-Connections</translation>
</message>
<message>
<source>GROUP_NAME_IS_EMPTY</source>
<translation>Name of group is empty
Please input a name of new group or choose the existing one</translation>
</message>
<message>
<source>NODE_ID</source>
<translation>Node ID</translation>
@ -864,6 +869,10 @@ Please enter correct values and try again</translation>
<source>SMESH_ADD_TETRAS_TITLE</source>
<translation>Add Tetrahedron</translation>
</message>
<message>
<source>SMESH_ADD_TO_GROUP</source>
<translation>Add to group</translation>
</message>
<message>
<source>SMESH_ADD_TRIANGLE</source>
<translation>Add Triangle</translation>