\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
\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>
#include "SMESHGUI_Utils.h"
#include "SMESHGUI_VTKUtils.h"
#include "SMESHGUI_MeshUtils.h"
+#include "SMESHGUI_GroupUtils.h"
#include "SMESHGUI_IdValidator.h"
#include <SMESH_Actor.h>
#include <vtkProperty.h>
// Qt includes
+#include <QComboBox>
#include <QGroupBox>
#include <QLabel>
#include <QLineEdit>
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);
/***************************************************************/
aTopLayout->addWidget(GroupConstructors);
aTopLayout->addWidget(GroupC1);
+ aTopLayout->addWidget(GroupGroups);
aTopLayout->addWidget(GroupButtons);
Init(); /* Initialisations */
myEditCurrentArgument = LineEditC1A1;
mySMESHGUI->SetActiveDialogBox((QDialog*)this);
+ /* reset "Add to group" control */
+ GroupGroups->setChecked( false );
+
myNbOkNodes = 0;
myActor = 0;
//=================================================================================
void SMESHGUI_AddMeshElementDlg::ClickOnApply()
{
+ if( !isValid() )
+ return;
+
if (myNbOkNodes && !mySMESHGUI->isActiveStudyLocked()) {
myBusy = true;
SMESH::long_array_var anArrayOfIndices = new SMESH::long_array;
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 );
mySimulation->SetVisibility(false);
// SMESH::SetPointRepresentation(true);
+ QString aCurrentEntry = myEntry;
+
// get selected mesh
SALOME_ListIO aList;
mySelectionMgr->selectedObjects(aList,SVTK_Viewer::Type());
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;
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;
+}
#include <SALOMEconfig.h>
#include CORBA_SERVER_HEADER(SMESH_Mesh)
+class QComboBox;
class QGroupBox;
class QLabel;
class QLineEdit;
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 */
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;
#include "SMESHGUI_Utils.h"
#include "SMESHGUI_VTKUtils.h"
#include "SMESHGUI_MeshUtils.h"
+#include "SMESHGUI_GroupUtils.h"
#include "SMESHGUI_IdValidator.h"
#include <SMESH_Actor.h>
#include <vtkCellType.h>
// Qt includes
+#include <QComboBox>
#include <QGroupBox>
#include <QLabel>
#include <QLineEdit>
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);
/***************************************************************/
aDialogLayout->addWidget(GroupConstructors);
aDialogLayout->addWidget(GroupArguments);
+ aDialogLayout->addWidget(GroupGroups);
aDialogLayout->addWidget(GroupButtons);
Init(); /* Initialisations */
myRadioButton1->setChecked(true);
mySMESHGUI->SetActiveDialogBox((QDialog*)this);
+ /* reset "Add to group" control */
+ GroupGroups->setChecked( false );
+
myActor = 0;
int aNumRows;
//=================================================================================
void SMESHGUI_AddQuadraticElementDlg::ClickOnApply()
{
+ if( !isValid() )
+ return;
+
if ( mySMESHGUI->isActiveStudyLocked() || myBusy || !IsValid() )
return;
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 );
if (myBusy) return;
BusyLocker lock( myBusy );
+ QString aCurrentEntry = myEntry;
+
if ( myIsEditCorners )
{
// clear
}
Handle(SALOME_InteractiveObject) anIO = aList.First();
+ myEntry = anIO->getEntry();
myMesh = SMESH::GetMeshByIO(anIO);
if (myMesh->_is_nil()) {
updateButtons();
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();
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;
+}
#include <SALOMEconfig.h>
#include CORBA_SERVER_HEADER(SMESH_Mesh)
+class QComboBox;
class QGroupBox;
+class QLabel;
class QLineEdit;
class QPushButton;
class QRadioButton;
bool IsValid();
void updateButtons();
+ bool isValid();
+
SMESHGUI* mySMESHGUI; /* Current SMESHGUI object */
LightApp_SelectionMgr* mySelectionMgr; /* User shape selection */
int myNbCorners; /* The required number of corners */
SMESH::SMESH_Mesh_var myMesh;
SMESH_Actor* myActor;
SMESH::TElementSimulation* mySimulation;
+ QString myEntry;
int myType;
bool myIsEditCorners;
QTableWidget* myTable;
QCheckBox* myReverseCB;
+ QGroupBox* GroupGroups;
+ QLabel* TextLabel_GroupName;
+ QComboBox* ComboBox_GroupName;
+
QGroupBox* GroupButtons;
QPushButton* buttonOk;
QPushButton* buttonCancel;
#include "SMESHGUI_Utils.h"
#include "SMESHGUI_VTKUtils.h"
#include "SMESHGUI_MeshUtils.h"
+#include "SMESHGUI_GroupUtils.h"
#include "SMESHGUI_IdValidator.h"
#include <SMESH_Actor.h>
// Qt includes
#include <QApplication>
#include <QButtonGroup>
+#include <QComboBox>
#include <QGroupBox>
#include <QLabel>
#include <QLineEdit>
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 );
/***************************************************************/
topLayout->addWidget( ConstructorsBox );
topLayout->addWidget( GroupContent );
+ topLayout->addWidget( GroupGroups );
topLayout->addWidget( GroupButtons );
mySelector = (SMESH::GetViewWindow( mySMESHGUI ))->GetSelector();
myEditCurrentArgument = LineEditElements;
mySMESHGUI->SetActiveDialogBox( (QDialog*)this );
+ /* reset "Add to group" control */
+ GroupGroups->setChecked( false );
+
myNbOkElements = 0;
myActor = 0;
//=================================================================================
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;
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){
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){
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();
mySimulation->SetVisibility(false);
+ QString aCurrentEntry = myEntry;
+
// get selected mesh
SALOME_ListIO selected;
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;
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;
+}
#include CORBA_SERVER_HEADER(SMESH_Mesh)
class QButtonGroup;
+class QComboBox;
class QGroupBox;
class QListWidget;
class QLabel;
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 */
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;
#include "SMESHGUI_Utils.h"
#include "SMESHGUI_VTKUtils.h"
#include "SMESHGUI_MeshUtils.h"
+#include "SMESHGUI_GroupUtils.h"
#include <SMESH_Actor.h>
#include <SMESH_ActorUtils.h>
#include <vtkPoints.h>
// Qt includes
+#include <QComboBox>
#include <QGroupBox>
#include <QLabel>
#include <QPushButton>
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();
catch ( ... ) {
INFOS( "Unknown exception was cought !!!" );
}
+ return aNodeId;
}
class TNodeSimulation
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 );
/***************************************************************/
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";
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 */
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 );
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;
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 );
+ }
+ }
+ }
+ }
}
//=================================================================================
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;
}
#include <SALOMEconfig.h>
#include CORBA_SERVER_HEADER(SMESH_Mesh)
+class QComboBox;
class QGroupBox;
class QLabel;
class QPushButton;
SMESH::SMESH_Mesh_var myMesh;
SMESH::TNodeSimulation* mySimulation;
+ QString myEntry;
void Init();
void enterEvent( QEvent* );
QLabel* TextLabel_Y;
QLabel* TextLabel_Z;
+ QGroupBox* GroupGroups;
+ QLabel* TextLabel_GroupName;
+ QComboBox* ComboBox_GroupName;
+
QGroupBox* GroupButtons;
QPushButton* buttonApply;
QPushButton* buttonOk;
<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>
<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>