+//=================================================================================
+// function : onSelectAll()
+// purpose :
+//=================================================================================
+void SMESHGUI_EditMeshDlg::onSelectAll (bool isToggled)
+{
+ if ( isToggled )
+ ListCoincident->selectAll();
+ else
+ ListCoincident->clearSelection();
+}
+
+//=================================================================================
+// function : onSelectElementFromGroup()
+// purpose :
+//=================================================================================
+void SMESHGUI_EditMeshDlg::onSelectElementFromGroup()
+{
+ if (myIsBusy || !myActor)
+ return;
+
+ TColStd_MapOfInteger anIndices;
+ QList<QListWidgetItem*> selItems = ListEdit->selectedItems();
+ QListWidgetItem* anItem;
+
+ foreach(anItem, selItems)
+ anIndices.Add(anItem->text().toInt());
+
+ SetFirstButton->setEnabled(selItems.count() == 1);
+
+ mySelector->AddOrRemoveIndex(myActor->getIO(), anIndices, false);
+ SALOME_ListIO aList;
+ aList.Append(myActor->getIO());
+ mySelectionMgr->setSelectedObjects(aList);
+
+ if (myAction == 0) {
+ myIdPreview->SetPointsData(myActor->GetObject()->GetMesh(), anIndices);
+ myIdPreview->SetPointsLabeled(!anIndices.IsEmpty(), myActor->GetVisibility());
+ }
+ else {
+ std::list< gp_XYZ > aGrCentersXYZ;
+ FindGravityCenter(anIndices, aGrCentersXYZ);
+ myIdPreview->SetElemsData(anIndices, aGrCentersXYZ);
+ myIdPreview->SetPointsLabeled(!anIndices.IsEmpty(), myActor->GetVisibility());
+ }
+}
+
+//=================================================================================
+// function : onAddGroup()
+// purpose :
+//=================================================================================
+void SMESHGUI_EditMeshDlg::onAddGroup()
+{
+ if ( myMesh->_is_nil() || LineEditMesh->text().isEmpty() )
+ return;
+
+ QString anIDs = "";
+ SMESH::GetNameOfSelectedNodes(mySelector, myActor->getIO(), anIDs);
+
+ ListCoincident->clearSelection();
+ ListCoincident->addItem(anIDs);
+ int nbGroups = ListCoincident->count();
+ if (nbGroups) {
+ ListCoincident->setCurrentRow(nbGroups-1);
+ ListCoincident->item(nbGroups-1)->setSelected(true);
+ }
+ else {
+ // VSR ? this code seems to be never executed!!!
+ ListCoincident->setCurrentRow(0);
+ //ListCoincident->setSelected(0, true); // VSR: no items - no selection
+ }
+
+ updateControls();
+}
+
+//=================================================================================
+// function : onRemoveGroup()
+// purpose :
+//=================================================================================
+void SMESHGUI_EditMeshDlg::onRemoveGroup()
+{
+ if (myEditCurrentArgument != (QWidget*)ListCoincident)
+ return;
+ myIsBusy = true;
+
+ QList<QListWidgetItem*> selItems = ListCoincident->selectedItems();
+ QListWidgetItem* anItem;
+
+ foreach(anItem, selItems)
+ delete anItem;
+
+ ListEdit->clear();
+ updateControls();
+
+ myIsBusy = false;
+}
+
+//=================================================================================
+// function : onAddElement()
+// purpose :
+//=================================================================================
+void SMESHGUI_EditMeshDlg::onAddElement()
+{
+ if (!myActor)
+ return;
+ myIsBusy = true;
+
+ QString aListStr = "";
+ int aNbNnodes = 0;
+
+ aNbNnodes = SMESH::GetNameOfSelectedNodes(mySelector, myActor->getIO(), aListStr);
+ if (aNbNnodes < 1)
+ return;
+
+ QStringList aNodes = aListStr.split(" ", QString::SkipEmptyParts);
+
+ for (QStringList::iterator it = aNodes.begin(); it != aNodes.end(); ++it) {
+ QList<QListWidgetItem*> found = ListEdit->findItems(*it, Qt::MatchExactly);
+ if ( found.count() == 0 ) {
+ QListWidgetItem* anItem = new QListWidgetItem(*it);
+ ListEdit->addItem(anItem);
+ anItem->setSelected(true);
+ }
+ else {
+ QListWidgetItem* anItem;
+ foreach(anItem, found) anItem->setSelected(true);
+ }
+ }
+
+ myIsBusy = false;
+ onEditGroup();
+}
+
+//=================================================================================
+// function : onRemoveElement()
+// purpose :
+//=================================================================================
+void SMESHGUI_EditMeshDlg::onRemoveElement()
+{
+ if (myEditCurrentArgument != (QWidget*)ListCoincident)
+ return;
+ myIsBusy = true;
+
+ QList<QListWidgetItem*> selItems = ListEdit->selectedItems();
+ QListWidgetItem* anItem;
+
+ foreach(anItem, selItems)
+ delete anItem;
+
+ myIsBusy = false;
+ onEditGroup();
+}
+
+//=================================================================================
+// function : onSetFirst()
+// purpose :
+//=================================================================================
+void SMESHGUI_EditMeshDlg::onSetFirst()
+{
+ if (myEditCurrentArgument != (QWidget*)ListCoincident)
+ return;
+ myIsBusy = true;
+
+ QList<QListWidgetItem*> selItems = ListEdit->selectedItems();
+ QListWidgetItem* anItem;
+
+ foreach(anItem, selItems) {
+ ListEdit->takeItem(ListEdit->row(anItem));
+ ListEdit->insertItem(0, anItem);
+ }
+
+ myIsBusy = false;
+ onEditGroup();
+}
+
+//=================================================================================
+// function : SetEditCurrentArgument()
+// purpose :
+//=================================================================================
+void SMESHGUI_EditMeshDlg::SetEditCurrentArgument()
+{
+ QPushButton* send = (QPushButton*)sender();
+
+ disconnect(mySelectionMgr, 0, this, 0);
+ mySelectionMgr->clearSelected();
+ mySelectionMgr->clearFilters();
+
+ if (send == SelectMeshButton) {
+ myEditCurrentArgument = (QWidget*)LineEditMesh;
+ SMESH::SetPointRepresentation(false);
+ if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
+ aViewWindow->SetSelectionMode(ActorSelection);
+ mySelectionMgr->installFilter(myMeshOrSubMeshOrGroupFilter);
+ }
+
+ myEditCurrentArgument->setFocus();
+ connect(mySelectionMgr, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument()));
+ SelectionIntoArgument();
+}
+
+//=================================================================================
+// function : SelectionIntoArgument()
+// purpose : Called when selection as changed or other case
+//=================================================================================
+void SMESHGUI_EditMeshDlg::SelectionIntoArgument()
+{
+ if (myEditCurrentArgument == (QWidget*)LineEditMesh) {
+ QString aString = "";
+ LineEditMesh->setText(aString);
+
+ ListCoincident->clear();
+ ListEdit->clear();
+ myActor = 0;
+
+ int nbSel = SMESH::GetNameOfSelectedIObjects(mySelectionMgr, aString);
+ if (nbSel != 1)
+ return;
+
+ SALOME_ListIO aList;
+ mySelectionMgr->selectedObjects(aList, SVTK_Viewer::Type());
+
+ Handle(SALOME_InteractiveObject) IO = aList.First();
+ myMesh = SMESH::GetMeshByIO(IO);
+
+ if (myMesh->_is_nil())
+ return;
+
+ myActor = SMESH::FindActorByEntry(IO->getEntry());
+ if (!myActor)
+ myActor = SMESH::FindActorByObject(myMesh);
+ if(!myActor)
+ return;
+
+ mySubMeshOrGroup = SMESH::SMESH_IDSource::_nil();
+
+ if ((!SMESH::IObjectToInterface<SMESH::SMESH_subMesh>(IO)->_is_nil() || //SUBMESH OR GROUP
+ !SMESH::IObjectToInterface<SMESH::SMESH_GroupBase>(IO)->_is_nil()) &&
+ !SMESH::IObjectToInterface<SMESH::SMESH_IDSource>(IO)->_is_nil())
+ mySubMeshOrGroup = SMESH::IObjectToInterface<SMESH::SMESH_IDSource>(IO);
+
+ LineEditMesh->setText(aString);
+
+ if (myAction == 0) {
+ SMESH::SetPointRepresentation(true);
+ if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
+ aViewWindow->SetSelectionMode(NodeSelection);
+ }
+ else
+ if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
+ aViewWindow->SetSelectionMode(CellSelection);
+ }