Version: 6.3.1
Public Member Functions | Private Slots | Private Member Functions | Private Attributes

SMESHGUI_DuplicateNodesDlg Class Reference

Dialog for duplication of nodes. More...

#include <SMESHGUI_DuplicateNodesDlg.h>

Inheritance diagram for SMESHGUI_DuplicateNodesDlg:
Inheritance graph
[legend]

Public Member Functions

 SMESHGUI_DuplicateNodesDlg (SMESHGUI *)
 Constructor.
 ~SMESHGUI_DuplicateNodesDlg ()
 Destructor.

Private Slots

void onConstructorsClicked (int)
 SLOT called to change the dialog operation mode.
void onOk ()
 SLOT called to apply changes and close the dialog.
void onClose ()
 SLOT called to close the dialog.
bool onApply ()
 SLOT called to apply changes.
void onHelp ()
 Show the dialog help page.
void onEditCurrentArgument ()
 SLOT called when selection button clicked.
void onSelectionChanged ()
 SLOT called when selection changed.
void onDeactivate ()
 SLOT called when dialog shoud be deativated.

Private Member Functions

void Init ()
 Destructor.
bool isValid ()
 Check if the input data is valid.
void closeEvent (QCloseEvent *)
 Receive close events.
void enterEvent (QEvent *)
 Receive dialog enter events.
void keyPressEvent (QKeyEvent *)
 Receive key press events.

Private Attributes

QLineEdit * myCurrentLineEdit
QButtonGroup * myGroupConstructors
QGroupBoxmyGroupArguments
QLabel * myTextLabel1
QLabel * myTextLabel2
QLabel * myTextLabel3
QPushButton * mySelectButton1
QPushButton * mySelectButton2
QPushButton * mySelectButton3
QLineEdit * myLineEdit1
QLineEdit * myLineEdit2
QLineEdit * myLineEdit3
QCheckBox * myCheckBoxNewGroup
QPushButton * myButtonOk
QPushButton * myButtonApply
QPushButton * myButtonClose
QPushButton * myButtonHelp
SMESHGUImySMESHGUI
LightApp_SelectionMgr * mySelectionMgr
QList< SMESH::SMESH_GroupBase_var > myGroups1
QList< SMESH::SMESH_GroupBase_var > myGroups2
QList< SMESH::SMESH_GroupBase_var > myGroups3
bool myBusy
QString myHelpFileName

Detailed Description

Dialog for duplication of nodes.

Definition at line 55 of file SMESHGUI_DuplicateNodesDlg.h.


Constructor & Destructor Documentation

SMESHGUI_DuplicateNodesDlg::SMESHGUI_DuplicateNodesDlg ( SMESHGUI theModule)

Constructor.

Parameters:
theModuleMesh module instance

Definition at line 95 of file SMESHGUI_DuplicateNodesDlg.cxx.

References SMESH.GetResourceMgr(), Init(), MARGIN, myButtonApply, myButtonClose, myButtonHelp, myButtonOk, myCheckBoxNewGroup, myGroupArguments, myGroupConstructors, myHelpFileName, myLineEdit1, myLineEdit2, myLineEdit3, mySelectButton1, mySelectButton2, mySelectButton3, mySelectionMgr, mySMESHGUI, myTextLabel1, myTextLabel2, myTextLabel3, onApply(), onClose(), onConstructorsClicked(), onDeactivate(), onEditCurrentArgument(), onHelp(), onOk(), onSelectionChanged(), and SPACING.

  : QDialog( SMESH::GetDesktop( theModule ) ),
    mySMESHGUI( theModule ),
    mySelectionMgr( SMESH::GetSelectionMgr( theModule ) )
{
  // Dialog attributes
  setModal(false);
  setAttribute(Qt::WA_DeleteOnClose, true);
  setWindowTitle(tr("SMESH_DUPLICATE_TITLE"));
  setSizeGripEnabled(true);

  // Icons for the dialog operation modes and selection button
  SUIT_ResourceMgr* aResMgr = SMESH::GetResourceMgr( mySMESHGUI );
  QPixmap iconWithoutElem (aResMgr->loadPixmap("SMESH", tr("ICON_SMESH_DUPLICATE_NODES")));
  QPixmap iconWithElem (aResMgr->loadPixmap("SMESH", tr("ICON_SMESH_DUPLICATE_NODES_WITH_ELEM")));
  QPixmap iconSelect (aResMgr->loadPixmap("SMESH", tr("ICON_SELECT")));

  // Main layout
  QVBoxLayout* aMainLayout = new QVBoxLayout(this);
  aMainLayout->setSpacing(SPACING);
  aMainLayout->setMargin(MARGIN);

  // Operation modes selector
  QGroupBox* aConstructorsBox = new QGroupBox(tr("DUPLICATION_MODE"), this);
  myGroupConstructors = new QButtonGroup(this);
  QHBoxLayout* aConstructorsBoxLayout = new QHBoxLayout(aConstructorsBox);
  aConstructorsBoxLayout->setSpacing(SPACING);
  aConstructorsBoxLayout->setMargin(MARGIN);

  QRadioButton* aRadioButton1 = new QRadioButton(aConstructorsBox);
  aRadioButton1->setIcon(iconWithoutElem);
  QRadioButton* aRadioButton2 = new QRadioButton(aConstructorsBox);
  aRadioButton2->setIcon(iconWithElem);
  
  aConstructorsBoxLayout->addWidget(aRadioButton1);
  aConstructorsBoxLayout->addWidget(aRadioButton2);
  myGroupConstructors->addButton(aRadioButton1, 0);
  myGroupConstructors->addButton(aRadioButton2, 1);

  // Arguments
  myGroupArguments = new QGroupBox(this);
  QGridLayout* aGroupArgumentsLayout = new QGridLayout(myGroupArguments);
  aGroupArgumentsLayout->setSpacing(SPACING);
  aGroupArgumentsLayout->setMargin(MARGIN);
    
  myTextLabel1 = new QLabel(myGroupArguments);
  mySelectButton1 = new QPushButton(myGroupArguments);
  mySelectButton1->setIcon(iconSelect);
  myLineEdit1 = new QLineEdit(myGroupArguments);
  myLineEdit1->setReadOnly(true);

  myTextLabel2 = new QLabel(myGroupArguments);
  mySelectButton2 = new QPushButton(myGroupArguments);
  mySelectButton2->setIcon(iconSelect);
  myLineEdit2 = new QLineEdit(myGroupArguments);
  myLineEdit2->setReadOnly(true);

  myTextLabel3 = new QLabel(myGroupArguments);
  mySelectButton3 = new QPushButton(myGroupArguments);
  mySelectButton3->setIcon(iconSelect);
  myLineEdit3 = new QLineEdit(myGroupArguments);
  myLineEdit3->setReadOnly(true);

  myCheckBoxNewGroup = new QCheckBox(tr("CONSTRUCT_NEW_GROUP_NODES"), myGroupArguments);

  aGroupArgumentsLayout->addWidget(myTextLabel1,    0, 0);
  aGroupArgumentsLayout->addWidget(mySelectButton1, 0, 1);
  aGroupArgumentsLayout->addWidget(myLineEdit1,     0, 2);
  aGroupArgumentsLayout->addWidget(myTextLabel2,    1, 0);
  aGroupArgumentsLayout->addWidget(mySelectButton2, 1, 1);
  aGroupArgumentsLayout->addWidget(myLineEdit2,     1, 2);
  aGroupArgumentsLayout->addWidget(myTextLabel3,    2, 0);
  aGroupArgumentsLayout->addWidget(mySelectButton3, 2, 1);
  aGroupArgumentsLayout->addWidget(myLineEdit3,     2, 2);
  aGroupArgumentsLayout->addWidget(myCheckBoxNewGroup, 3, 0);
  aGroupArgumentsLayout->setRowStretch(4, 1);
  
  // Buttons
  QGroupBox* aGroupButtons = new QGroupBox(this);
  QHBoxLayout* aGroupButtonsLayout = new QHBoxLayout(aGroupButtons);
  aGroupButtonsLayout->setSpacing(SPACING);
  aGroupButtonsLayout->setMargin(MARGIN);

  myButtonOk = new QPushButton(tr("SMESH_BUT_APPLY_AND_CLOSE"), aGroupButtons);
  myButtonOk->setAutoDefault(true);
  myButtonOk->setDefault(true);
  myButtonApply = new QPushButton(tr("SMESH_BUT_APPLY"), aGroupButtons);
  myButtonApply->setAutoDefault(true);
  myButtonClose = new QPushButton(tr("SMESH_BUT_CLOSE"), aGroupButtons);
  myButtonClose->setAutoDefault(true);
  myButtonHelp = new QPushButton(tr("SMESH_BUT_HELP"), aGroupButtons);
  myButtonHelp->setAutoDefault(true);

  aGroupButtonsLayout->addWidget(myButtonOk);
  aGroupButtonsLayout->addSpacing(10);
  aGroupButtonsLayout->addWidget(myButtonApply);
  aGroupButtonsLayout->addSpacing(10);
  aGroupButtonsLayout->addStretch();
  aGroupButtonsLayout->addWidget(myButtonClose);
  aGroupButtonsLayout->addWidget(myButtonHelp);

  // Add mode selector, arguments and buttons to the main layout
  aMainLayout->addWidget(aConstructorsBox);
  aMainLayout->addWidget(myGroupArguments);
  aMainLayout->addWidget(aGroupButtons);
  
  // Initialize the dialog
  Init();

  // Help file name
  myHelpFileName = "double_nodes_page.html";

  // Signals and slots connections
  connect(myGroupConstructors, SIGNAL(buttonClicked(int)), SLOT(onConstructorsClicked(int)));
     
  connect(mySelectButton1, SIGNAL (clicked()), this, SLOT(onEditCurrentArgument()));
  connect(mySelectButton2, SIGNAL (clicked()), this, SLOT(onEditCurrentArgument()));
  connect(mySelectButton3, SIGNAL (clicked()), this, SLOT(onEditCurrentArgument()));

  connect(myButtonOk,     SIGNAL(clicked()), this, SLOT(onOk()));
  connect(myButtonClose,  SIGNAL(clicked()), this, SLOT(onClose()));
  connect(myButtonApply,  SIGNAL(clicked()), this, SLOT(onApply()));
  connect(myButtonHelp,   SIGNAL(clicked()), this, SLOT(onHelp()));
  
  connect(mySelectionMgr, SIGNAL(currentSelectionChanged()), SLOT(onSelectionChanged()));

  connect(mySMESHGUI, SIGNAL (SignalDeactivateActiveDialog()), this, SLOT(onDeactivate()));
  connect(mySMESHGUI, SIGNAL (SignalCloseAllDialogs()), this, SLOT(onClose()));
}
SMESHGUI_DuplicateNodesDlg::~SMESHGUI_DuplicateNodesDlg ( )

Destructor.

Definition at line 228 of file SMESHGUI_DuplicateNodesDlg.cxx.

{
}

Member Function Documentation

void SMESHGUI_DuplicateNodesDlg::closeEvent ( QCloseEvent *  ) [private]

Receive close events.

Reimplemented from QWidget class.

Definition at line 576 of file SMESHGUI_DuplicateNodesDlg.cxx.

References onClose().

{
  onClose();
}
void SMESHGUI_DuplicateNodesDlg::enterEvent ( QEvent *  ) [private]

Receive dialog enter events.

Activates the dialog when the mouse cursor enters. Reimplemented from QWidget class.

Definition at line 558 of file SMESHGUI_DuplicateNodesDlg.cxx.

References SMESHGUI.EmitSignalDeactivateDialog(), SMESH.GetViewWindow(), GROUP, mySelectionMgr, mySMESHGUI, and SMESHGUI.SetActiveDialogBox().

{
  if ( !isEnabled() ) {
    mySMESHGUI->EmitSignalDeactivateDialog();
    setEnabled(true);
    mySMESHGUI->SetActiveDialogBox((QDialog*)this);
    
    // Set selection mode
    if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
      aViewWindow->SetSelectionMode(ActorSelection);
    mySelectionMgr->installFilter(new SMESH_TypeFilter (GROUP));
  }
}
void SMESHGUI_DuplicateNodesDlg::Init ( ) [private]

Destructor.

Definition at line 235 of file SMESHGUI_DuplicateNodesDlg.cxx.

References SMESH.GetViewWindow(), GROUP, myBusy, myCheckBoxNewGroup, myCurrentLineEdit, myGroupConstructors, myGroups1, myGroups2, myGroups3, myLineEdit1, mySelectionMgr, mySMESHGUI, onConstructorsClicked(), and SMESHGUI.SetActiveDialogBox().

Referenced by onApply(), and SMESHGUI_DuplicateNodesDlg().

{
  mySMESHGUI->SetActiveDialogBox((QDialog*)this);
  myCheckBoxNewGroup->setChecked(true);

  // Set initial parameters
  myBusy = false;
  myCurrentLineEdit = myLineEdit1;

  myGroups1.clear();
  myGroups2.clear();
  myGroups3.clear();
  
  // Set selection mode
  mySelectionMgr->installFilter(new SMESH_TypeFilter(GROUP));
  if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
    aViewWindow->SetSelectionMode(ActorSelection);
  
  // Set construction mode
  int operationMode = myGroupConstructors->checkedId();
  if (operationMode < 0) {
    // The dialog has been just displayed
    operationMode = 0;
    myGroupConstructors->button(0)->setChecked(true);
  }
  onConstructorsClicked(operationMode);
}
bool SMESHGUI_DuplicateNodesDlg::isValid ( ) [private]

Check if the input data is valid.

Returns:
true id the data is valid

Definition at line 532 of file SMESHGUI_DuplicateNodesDlg.cxx.

References myGroupConstructors, myGroups1, and myGroups3.

Referenced by onApply(), and onSelectionChanged().

{
  return myGroupConstructors->checkedId() == 1 ?
    ( !myGroups1.isEmpty() && !myGroups3.isEmpty()  ) :
    ( !myGroups1.isEmpty() );
}
void SMESHGUI_DuplicateNodesDlg::keyPressEvent ( QKeyEvent *  e) [private]

Receive key press events.

Reimplemented from QWidget class.

Definition at line 585 of file SMESHGUI_DuplicateNodesDlg.cxx.

References onHelp().

{
  QDialog::keyPressEvent( e );
  if ( e->isAccepted() )
    return;

  if ( e->key() == Qt::Key_F1 ) {
    e->accept();
    onHelp();
  }
}
bool SMESHGUI_DuplicateNodesDlg::onApply ( ) [private, slot]

SLOT called to apply changes.

Definition at line 327 of file SMESHGUI_DuplicateNodesDlg.cxx.

References Init(), SMESHGUI.isActiveStudyLocked(), isValid(), SMESHGUI.Modified(), myBusy, myCheckBoxNewGroup, myGroupConstructors, myGroups1, myGroups2, myGroups3, mySelectionMgr, mySMESHGUI, and SMESH.UpdateView().

Referenced by onOk(), and SMESHGUI_DuplicateNodesDlg().

{
  if ( mySMESHGUI->isActiveStudyLocked() || !isValid() )
    return false;

  BusyLocker lock( myBusy );
 
  bool toCreateGroup = myCheckBoxNewGroup->isChecked();
  int operationMode = myGroupConstructors->checkedId();
  
  // Apply changes
  bool result = false;
  SUIT_OverrideCursor aWaitCursor;

  try {
    SMESH::SMESH_Mesh_var aMesh = myGroups1[0]->GetMesh();
    SMESH::SMESH_MeshEditor_var aMeshEditor = aMesh->GetMeshEditor();

    if ( operationMode == 0 ) {
      SMESH::ListOfGroups_var g1 = new SMESH::ListOfGroups();
      g1->length( myGroups1.count() );
      for ( int i = 0; i < myGroups1.count(); i++ )
        g1[i] = myGroups1[i];
      SMESH::ListOfGroups_var g2 = new SMESH::ListOfGroups();
      g2->length( myGroups2.count() );
      for ( int i = 0; i < myGroups2.count(); i++ )
        g2[i] = myGroups2[i];

      if ( toCreateGroup ) {
        SMESH::SMESH_GroupBase_var aNewGroup = 
          aMeshEditor->DoubleNodeGroupsNew( g1.in(), g2.in() );
        result = !CORBA::is_nil( aNewGroup );
      }
      else {
        result = aMeshEditor->DoubleNodeGroups( g1.in(), g2.in() );
      }
    }
    else {
      SMESH::ListOfGroups_var g1 = new SMESH::ListOfGroups();
      g1->length( myGroups1.count() );
      for ( int i = 0; i < myGroups1.count(); i++ )
        g1[i] = myGroups1[i];
      SMESH::ListOfGroups_var g2 = new SMESH::ListOfGroups();
      g2->length( myGroups2.count() );
      for ( int i = 0; i < myGroups2.count(); i++ )
        g2[i] = myGroups2[i];
      SMESH::ListOfGroups_var g3 = new SMESH::ListOfGroups();
      g3->length( myGroups3.count() );

      for ( int i = 0; i < myGroups3.count(); i++ )
        g3[i] = myGroups3[i];
      if ( toCreateGroup ) {
        SMESH::SMESH_GroupBase_ptr aNewGroup = 
          aMeshEditor->DoubleNodeElemGroupsNew( g1.in(), g2.in(), g3.in() );
        result = !CORBA::is_nil( aNewGroup );
      }
      else {
        result = aMeshEditor->DoubleNodeElemGroups( g1.in(), g2.in(), g3.in() );
      }
    }
  }
  catch (const SALOME::SALOME_Exception& S_ex) {
    SalomeApp_Tools::QtCatchCorbaException(S_ex);
  }
  catch ( const std::exception& exc ) {
    INFOS( "Follow exception was cought:\n\t" << exc.what() );
  } 
  catch (...){
    INFOS( "Unknown exception was cought !!!" );
  }

  if (!result) {
    SUIT_MessageBox::warning(this,
                             tr("SMESH_WRN_WARNING"),
                             tr("SMESH_OPERATION_FAILED"));
    return false;
  }

  // Update GUI
  mySelectionMgr->clearSelected();
  SMESH::UpdateView();
  SMESHGUI::Modified();
  mySMESHGUI->updateObjBrowser(true);

  // Reinitialize the dialog
  Init();
  
  return true;
}
void SMESHGUI_DuplicateNodesDlg::onClose ( ) [private, slot]

SLOT called to close the dialog.

Definition at line 429 of file SMESHGUI_DuplicateNodesDlg.cxx.

References mySelectionMgr, mySMESHGUI, and SMESHGUI.ResetState().

Referenced by closeEvent(), onOk(), and SMESHGUI_DuplicateNodesDlg().

{
  disconnect(mySelectionMgr, 0, this, 0);
  disconnect(mySMESHGUI, 0, this, 0);
  mySMESHGUI->ResetState();
  mySelectionMgr->clearFilters();
  reject();
}
void SMESHGUI_DuplicateNodesDlg::onConstructorsClicked ( int  constructorId) [private, slot]

SLOT called to change the dialog operation mode.

Parameters:
constructorIdid of the radio button in mode selector button group

Definition at line 267 of file SMESHGUI_DuplicateNodesDlg.cxx.

References myCheckBoxNewGroup, myCurrentLineEdit, myGroupArguments, myGroups1, myGroups2, myGroups3, myLineEdit1, myLineEdit2, myLineEdit3, mySelectButton3, myTextLabel1, myTextLabel2, myTextLabel3, and onSelectionChanged().

Referenced by Init(), and SMESHGUI_DuplicateNodesDlg().

{
  // Clear all fields
  myLineEdit1->clear();
  myLineEdit2->clear();
  myLineEdit3->clear();

  myGroups1.clear();
  myGroups2.clear();
  myGroups3.clear();

  // Set the first field as current
  myCurrentLineEdit = myLineEdit1;
  myCurrentLineEdit->setFocus();

  switch (constructorId) {
  case 0:
    {
      // Set text to the group of arguments and to the first two labels
      myGroupArguments->setTitle(tr("DUPLICATION_WITHOUT_ELEMS"));
      myTextLabel1->setText(tr("GROUP_NODES_TO_DUPLICATE"));
      myTextLabel2->setText(tr("GROUP_NODES_TO_REPLACE"));

      // Set checkbox title
      myCheckBoxNewGroup->setText(tr("CONSTRUCT_NEW_GROUP_NODES"));
      
      // Hide the third field
      myTextLabel3->hide();
      mySelectButton3->hide();
      myLineEdit3->hide();
      
      break;
    }
  case 1:
    {
      // Set text to the group of arguments and to all the labels
      myGroupArguments->setTitle(tr("DUPLICATION_WITH_ELEMS"));
      myTextLabel1->setText(tr("GROUP_ELEMS_TO_DUPLICATE"));
      myTextLabel2->setText(tr("GROUP_NODES_NOT_DUPLICATE"));
      myTextLabel3->setText(tr("GROUP_ELEMS_TO_REPLACE"));
      
      // Set checkbox title
      myCheckBoxNewGroup->setText(tr("CONSTRUCT_NEW_GROUP_ELEMENTS"));

      // Show the third field
      myTextLabel3->show();
      mySelectButton3->show();
      myLineEdit3->show();

      break;
    }
  }
  
  // Process selection
  onSelectionChanged();
}
void SMESHGUI_DuplicateNodesDlg::onDeactivate ( ) [private, slot]

SLOT called when dialog shoud be deativated.

Definition at line 543 of file SMESHGUI_DuplicateNodesDlg.cxx.

References mySelectionMgr, mySMESHGUI, SMESHGUI.ResetState(), and SMESHGUI.SetActiveDialogBox().

Referenced by SMESHGUI_DuplicateNodesDlg().

{
  if (isEnabled()) {
    mySelectionMgr->clearFilters();
    setEnabled(false);
    mySMESHGUI->ResetState();
    mySMESHGUI->SetActiveDialogBox(0);
  }
}
void SMESHGUI_DuplicateNodesDlg::onEditCurrentArgument ( ) [private, slot]

SLOT called when selection button clicked.

Definition at line 509 of file SMESHGUI_DuplicateNodesDlg.cxx.

References myCurrentLineEdit, myLineEdit1, myLineEdit2, myLineEdit3, mySelectButton1, mySelectButton2, mySelectButton3, and onSelectionChanged().

Referenced by SMESHGUI_DuplicateNodesDlg().

{
  QPushButton* send = (QPushButton*)sender();
  
  // Set current field for edition
  if (send == mySelectButton1) {
    myCurrentLineEdit = myLineEdit1;
  } 
  else if (send == mySelectButton2) {
    myCurrentLineEdit = myLineEdit2;
  }
  else if (send == mySelectButton3) {
    myCurrentLineEdit = myLineEdit3;
  }
  
  myCurrentLineEdit->setFocus();
  onSelectionChanged();
}
void SMESHGUI_DuplicateNodesDlg::onHelp ( ) [private, slot]

Show the dialog help page.

Definition at line 600 of file SMESHGUI_DuplicateNodesDlg.cxx.

References myHelpFileName, and mySMESHGUI.

Referenced by keyPressEvent(), and SMESHGUI_DuplicateNodesDlg().

{
  LightApp_Application* app = (LightApp_Application*)(SUIT_Session::session()->activeApplication());
  if (app) 
    app->onHelpContextModule(mySMESHGUI ? app->moduleName(mySMESHGUI->moduleName()) : QString(""), myHelpFileName);
  else {
    QString platform;
#ifdef WIN32
    platform = "winapplication";
#else
    platform = "application";
#endif
    SUIT_MessageBox::warning(this, tr("WRN_WARNING"),
                             tr("EXTERNAL_BROWSER_CANNOT_SHOW_PAGE").
                             arg(app->resourceMgr()->stringValue("ExternalBrowser", 
                                                                 platform)).
                             arg(myHelpFileName));
  }
}
void SMESHGUI_DuplicateNodesDlg::onOk ( ) [private, slot]

SLOT called to apply changes and close the dialog.

Definition at line 420 of file SMESHGUI_DuplicateNodesDlg.cxx.

References onApply(), and onClose().

Referenced by SMESHGUI_DuplicateNodesDlg().

{
  if (onApply())
    onClose();
}
void SMESHGUI_DuplicateNodesDlg::onSelectionChanged ( ) [private, slot]

SLOT called when selection changed.

Definition at line 441 of file SMESHGUI_DuplicateNodesDlg.cxx.

References SMESH_controls.aGroup, SMESH.EDGE, FACE, isValid(), myBusy, myButtonApply, myButtonOk, myCurrentLineEdit, myGroupConstructors, myGroups1, myGroups2, myGroups3, myLineEdit1, myLineEdit2, myLineEdit3, mySelectionMgr, and SMESH.NODE.

Referenced by onConstructorsClicked(), onEditCurrentArgument(), and SMESHGUI_DuplicateNodesDlg().

{
  if ( myBusy || !isEnabled() ) return;
  
  int operationMode = myGroupConstructors->checkedId();

  SALOME_ListIO aList;
  mySelectionMgr->selectedObjects( aList );
  //int aNbSel = aList.Extent();

  QList<SMESH::SMESH_GroupBase_var> aGroups;

  SALOME_ListIteratorOfListIO anIter ( aList );
  bool ok = true;
  for ( ; anIter.More() && ok; anIter.Next()) {
    SMESH::SMESH_GroupBase_var aGroup = SMESH::IObjectToInterface<SMESH::SMESH_GroupBase>( anIter.Value() );
    // check group is selected
    ok = !CORBA::is_nil( aGroup );
    // check groups of the same mesh are selected
    if ( ok ) {
      SMESH::SMESH_Mesh_var aMesh1;
      if ( !aGroups.isEmpty() ) aMesh1 = aGroups[0]->GetMesh();
      SMESH::SMESH_Mesh_var aMesh2 = aGroup->GetMesh();
      ok = CORBA::is_nil( aMesh1 ) || aMesh1->_is_equivalent( aMesh2 );
    }
    // check group of proper type is selected
    if ( ok ) {
      SMESH::ElementType aGroupType = aGroup->GetType();
      if ( operationMode == 0 ) {
        ok = ( myCurrentLineEdit == myLineEdit1 && aGroupType == SMESH::NODE ) ||
             ( myCurrentLineEdit == myLineEdit2 && aGroupType != SMESH::NODE );
      }
      else {
        ok = ( myCurrentLineEdit == myLineEdit1 && ( aGroupType == SMESH::EDGE ||
                                                     aGroupType == SMESH::FACE ) ) ||
             ( myCurrentLineEdit == myLineEdit2 && aGroupType == SMESH::NODE )     ||
             ( myCurrentLineEdit == myLineEdit3 && aGroupType != SMESH::NODE );
      }
    }
    if ( ok ) aGroups << aGroup;
  }

  // Clear current field
  myCurrentLineEdit->clear();

  if ( ok && !aGroups.isEmpty() ) {
    if      ( myCurrentLineEdit == myLineEdit1 ) myGroups1 = aGroups;
    else if ( myCurrentLineEdit == myLineEdit2 ) myGroups2 = aGroups;
    else if ( myCurrentLineEdit == myLineEdit3 ) myGroups3 = aGroups;
    myCurrentLineEdit->setText( aGroups.count() == 1 ? aGroups[0]->GetName() : 
                                QObject::tr( "SMESH_OBJECTS_SELECTED" ).arg( aGroups.count() ) );
  }
  else {
    if      ( myCurrentLineEdit == myLineEdit1 ) myGroups1.clear();
    else if ( myCurrentLineEdit == myLineEdit2 ) myGroups2.clear();
    else if ( myCurrentLineEdit == myLineEdit3 ) myGroups3.clear();
    myCurrentLineEdit->clear();
  }

  // Enable/disable "Apply and Close" and "Apply" buttons
  bool isDataValid = isValid();
  myButtonOk->setEnabled( isDataValid );
  myButtonApply->setEnabled( isDataValid );
}

Field Documentation

Definition at line 114 of file SMESHGUI_DuplicateNodesDlg.h.

Referenced by Init(), onApply(), and onSelectionChanged().

Definition at line 103 of file SMESHGUI_DuplicateNodesDlg.h.

Referenced by onSelectionChanged(), and SMESHGUI_DuplicateNodesDlg().

Definition at line 104 of file SMESHGUI_DuplicateNodesDlg.h.

Referenced by SMESHGUI_DuplicateNodesDlg().

Definition at line 105 of file SMESHGUI_DuplicateNodesDlg.h.

Referenced by SMESHGUI_DuplicateNodesDlg().

QPushButton* SMESHGUI_DuplicateNodesDlg.myButtonOk [private]

Definition at line 102 of file SMESHGUI_DuplicateNodesDlg.h.

Referenced by onSelectionChanged(), and SMESHGUI_DuplicateNodesDlg().

QList<SMESH::SMESH_GroupBase_var> SMESHGUI_DuplicateNodesDlg.myGroups1 [private]
QList<SMESH::SMESH_GroupBase_var> SMESHGUI_DuplicateNodesDlg.myGroups2 [private]
QList<SMESH::SMESH_GroupBase_var> SMESHGUI_DuplicateNodesDlg.myGroups3 [private]

Definition at line 116 of file SMESHGUI_DuplicateNodesDlg.h.

Referenced by onHelp(), and SMESHGUI_DuplicateNodesDlg().

LightApp_SelectionMgr* SMESHGUI_DuplicateNodesDlg.mySelectionMgr [private]
Copyright © 2007-2011 CEA/DEN, EDF R&D, OPEN CASCADE
Copyright © 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS