]> SALOME platform Git repositories - modules/smesh.git/commitdiff
Salome HOME
Fix of issue 0020614: EDF 1133 SMESH : Put new added elements and nodes to group
authorouv <ouv@opencascade.com>
Mon, 28 Dec 2009 16:23:43 +0000 (16:23 +0000)
committerouv <ouv@opencascade.com>
Mon, 28 Dec 2009 16:23:43 +0000 (16:23 +0000)
22 files changed:
doc/salome/gui/SMESH/images/a-createpolyhedralvolume.png
doc/salome/gui/SMESH/images/add0delement.png
doc/salome/gui/SMESH/images/addedge.png
doc/salome/gui/SMESH/images/addhexahedron.png
doc/salome/gui/SMESH/images/addnode.png
doc/salome/gui/SMESH/images/addnode_notebook.png
doc/salome/gui/SMESH/images/addpolygon.png
doc/salome/gui/SMESH/images/addquadrangle.png
doc/salome/gui/SMESH/images/addtetrahedron.png
doc/salome/gui/SMESH/images/addtriangle.png
doc/salome/gui/SMESH/images/aqt.png
doc/salome/gui/SMESH/input/adding_nodes_and_elements.doc
doc/salome/gui/SMESH/input/adding_quadratic_elements.doc
src/SMESHGUI/SMESHGUI_AddMeshElementDlg.cxx
src/SMESHGUI/SMESHGUI_AddMeshElementDlg.h
src/SMESHGUI/SMESHGUI_AddQuadraticElementDlg.cxx
src/SMESHGUI/SMESHGUI_AddQuadraticElementDlg.h
src/SMESHGUI/SMESHGUI_CreatePolyhedralVolumeDlg.cxx
src/SMESHGUI/SMESHGUI_CreatePolyhedralVolumeDlg.h
src/SMESHGUI/SMESHGUI_NodesDlg.cxx
src/SMESHGUI/SMESHGUI_NodesDlg.h
src/SMESHGUI/SMESH_msg_en.ts

index 26403226c21097c979d38116cc5b062d5d08db2c..009f71d51a2d392c0d61f56b34b1b881454c35da 100755 (executable)
Binary files a/doc/salome/gui/SMESH/images/a-createpolyhedralvolume.png and b/doc/salome/gui/SMESH/images/a-createpolyhedralvolume.png differ
index e6578f888240f0654c8c08bf4f29cd1e5869283b..4323879984d18b153c289df357553b158cad90c8 100644 (file)
Binary files a/doc/salome/gui/SMESH/images/add0delement.png and b/doc/salome/gui/SMESH/images/add0delement.png differ
index f142dffb26b2e0f6427c8e9e5bac557615728ec3..34f4fe07a009a10e8e617d6afd651ef47ba2db32 100755 (executable)
Binary files a/doc/salome/gui/SMESH/images/addedge.png and b/doc/salome/gui/SMESH/images/addedge.png differ
index 78ea3b50f98248cf9b49a63ef8e785c7b0bd432e..65d881f86d2b94b1664bb9f0f24d1f91069b9fe0 100755 (executable)
Binary files a/doc/salome/gui/SMESH/images/addhexahedron.png and b/doc/salome/gui/SMESH/images/addhexahedron.png differ
index 1f5375b9ae2763c4f6ad0a59235e64223cffdc85..bbde71e6a93e0c9f568fa9b61a44c28ff501f545 100755 (executable)
Binary files a/doc/salome/gui/SMESH/images/addnode.png and b/doc/salome/gui/SMESH/images/addnode.png differ
index 4abab33589ea61a0b79c81146f571f4348eca47f..804f806df5011f49b736e619c55711d05c9d987e 100755 (executable)
Binary files a/doc/salome/gui/SMESH/images/addnode_notebook.png and b/doc/salome/gui/SMESH/images/addnode_notebook.png differ
index 5d02dd70dab6ebae6c7d4e9716053f9dffc55591..71b81ecca7225e7735c713320b905b01dd6b287d 100755 (executable)
Binary files a/doc/salome/gui/SMESH/images/addpolygon.png and b/doc/salome/gui/SMESH/images/addpolygon.png differ
index 3e5c87c42f7507497995eacfd02c3f9cbb604d93..3dccce258c08e80204accd307703a16308c33d73 100755 (executable)
Binary files a/doc/salome/gui/SMESH/images/addquadrangle.png and b/doc/salome/gui/SMESH/images/addquadrangle.png differ
index 37dc29659045fc2bec3c69edc034517a05a48938..0289a95e4872ad25363f105a9d293e92d3ff2b1a 100755 (executable)
Binary files a/doc/salome/gui/SMESH/images/addtetrahedron.png and b/doc/salome/gui/SMESH/images/addtetrahedron.png differ
index 52a644e51c44c62c2e859324cfbacf433dffa0a5..991085fd100a6b817e7bf6059a16b62c8729fea0 100755 (executable)
Binary files a/doc/salome/gui/SMESH/images/addtriangle.png and b/doc/salome/gui/SMESH/images/addtriangle.png differ
index ae8e0d081751435e7c48f3e17d03128a730b6b6f..46ee94dae56e995bb06e2f26bd9265eb3778b3af 100755 (executable)
Binary files a/doc/salome/gui/SMESH/images/aqt.png and b/doc/salome/gui/SMESH/images/aqt.png differ
index 5cb3b15485b1e602ba115b04b8865c392e87fe04..fde5fc0f0ae1b63d60065476c835a811c7187c3e 100644 (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  
index afe9b77b51e3ea9458c659b06c9dc51a67d37211..2a587d1477e7c86ef111e227c808c795a650933e 100644 (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>
index 33c410193b8e2af5db679aaa152ec13da2bed0ca..6df9978de5b4a4e68071c822a6815e20c9e9f7d0 100644 (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;
+}
index ee10b312fb752d8cd77407fe0bf4789c50e31064..ae0c44e0f6aa286606a6738933f545ab785d7ba7 100644 (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;
index 4a9fa18acb5efd73a78a38d9d403b79a94a6d581..23b49bc1223a5bd21dab2019737eff33b4f1bea1 100644 (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;
+}
index a048a6760baaf5f62b84c464455b21d4aa1decf4..998d3284fa7c8ceb5d0b107d686f8cabade24498 100644 (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;
index c62b83711ee7a945af2c8762951cc29da944f8e2..b97b4d7f2a22d9df93283fdff758b42cfc2712a5 100644 (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;
+}
index b46d0c35bd48f316994c4a9f2eb4cfd954c6ed1f..51fbae54ca88ede9ce7e09de987989be75b34305 100644 (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;
index 76b75dbb9139c5a924b33baa70166ffe2724a853..ebc42b1987e9ef85dc86a42c9c178814b500a4ad 100644 (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>
 
 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;
 }
index 8fc28eacca9349099a15787cd6a460b3d6d09174..c40109d907ab4e0a72ed384610f222b7ce7f80cf 100644 (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;
index 10320d1635e4f2369a5b3c274e288e57d2e1bb2f..5e0e03e4fea37e3046c2b1746bed2823413064d6 100644 (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>