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

SMESHGUI_CreatePolyhedralVolumeDlg Class Reference

#include <SMESHGUI_CreatePolyhedralVolumeDlg.h>

Inheritance diagram for SMESHGUI_CreatePolyhedralVolumeDlg:
Inheritance graph
[legend]

Public Slots

void onAdd ()
void onRemove ()

Public Member Functions

 SMESHGUI_CreatePolyhedralVolumeDlg (SMESHGUI *)
 ~SMESHGUI_CreatePolyhedralVolumeDlg ()

Private Types

typedef QList
< SMESH::SMESH_GroupBase_var > 
GrpList

Private Slots

void ConstructorsClicked (int)
void ClickOnPreview (bool)
void ClickOnOk ()
void ClickOnCancel ()
void ClickOnApply ()
void ClickOnHelp ()
void SetEditCurrentArgument ()
void SelectionIntoArgument ()
void DeactivateActiveDialog ()
void ActivateThisDialog ()
void onTextChange (const QString &)
void onListSelectionChanged ()

Private Member Functions

void Init ()
void closeEvent (QCloseEvent *)
void enterEvent (QEvent *)
void hideEvent (QHideEvent *)
void keyPressEvent (QKeyEvent *)
int GetConstructorId ()
void displaySimulation ()
bool isValid ()
int checkEditLine (bool=true)

Private Attributes

SMESHGUImySMESHGUI
 Checking for indices, return 1 if all ok, esle -1.
LightApp_SelectionMgr * mySelectionMgr
SVTK_Selector * mySelector
QString myIDs
int myNbOkElements
QLineEdit * myEditCurrentArgument
SMESH::SMESH_Mesh_var myMesh
SMESH_ActormyActor
SMESH::TPolySimulationmySimulation
QString myEntry
GrpList myGroups
QGroupBoxConstructorsBox
QButtonGroup * GroupConstructors
QRadioButton * RadioButton1
QRadioButton * RadioButton2
QCheckBox * Preview
QGroupBoxGroupGroups
QLabel * TextLabel_GroupName
QComboBox * ComboBox_GroupName
QGroupBoxGroupButtons
QPushButton * buttonOk
QPushButton * buttonCancel
QPushButton * buttonApply
QPushButton * buttonHelp
QGroupBoxGroupContent
QLabel * TextLabelIds
QPushButton * SelectElementsButton
QLineEdit * LineEditElements
QListWidget * myFacesByNodes
QLabel * myFacesByNodesLabel
QPushButton * AddButton
QPushButton * RemoveButton
QString myHelpFileName

Detailed Description

Definition at line 63 of file SMESHGUI_CreatePolyhedralVolumeDlg.h.


Member Typedef Documentation

typedef QList<SMESH::SMESH_GroupBase_var> SMESHGUI_CreatePolyhedralVolumeDlg.GrpList [private]

Definition at line 72 of file SMESHGUI_CreatePolyhedralVolumeDlg.h.


Constructor & Destructor Documentation

SMESHGUI_CreatePolyhedralVolumeDlg::SMESHGUI_CreatePolyhedralVolumeDlg ( SMESHGUI theModule)

Definition at line 190 of file SMESHGUI_CreatePolyhedralVolumeDlg.cxx.

References AddButton, buttonApply, buttonCancel, buttonHelp, buttonOk, ComboBox_GroupName, ConstructorsBox, SMESH.GetResourceMgr(), SMESH.GetSelector(), SMESH.GetViewWindow(), GroupButtons, GroupConstructors, GroupContent, GroupGroups, Init(), LineEditElements, MARGIN, myFacesByNodes, myFacesByNodesLabel, myHelpFileName, mySelector, mySMESHGUI, Preview, RadioButton1, RadioButton2, RemoveButton, SelectElementsButton, SMESHGUI.SetActiveDialogBox(), SPACING, TextLabel_GroupName, and TextLabelIds.

  : QDialog( SMESH::GetDesktop( theModule ) ),
    mySMESHGUI( theModule ),
    mySelectionMgr( SMESH::GetSelectionMgr( theModule ) )
{
  QPixmap image0( SMESH::GetResourceMgr( mySMESHGUI )->loadPixmap( "SMESH",tr("ICON_SELECT")));

  setModal(false);
  setAttribute(Qt::WA_DeleteOnClose, true);
  setWindowTitle( tr( "SMESH_CREATE_POLYHEDRAL_VOLUME_TITLE" ) );
  setSizeGripEnabled( true );

  QVBoxLayout* topLayout = new QVBoxLayout( this ); 
  topLayout->setSpacing( SPACING );
  topLayout->setMargin( MARGIN );

  /***************************************************************/
  ConstructorsBox = new QGroupBox(tr( "SMESH_ELEMENTS_TYPE" ), this);
  GroupConstructors = new QButtonGroup(this);
  QHBoxLayout* ConstructorsBoxLayout = new QHBoxLayout( ConstructorsBox );
  ConstructorsBoxLayout->setSpacing( SPACING );
  ConstructorsBoxLayout->setMargin( MARGIN );

  RadioButton1 = new QRadioButton( tr( "MESH_NODE" ),  ConstructorsBox );
  RadioButton2 = new QRadioButton( tr( "SMESH_FACE" ), ConstructorsBox );

  ConstructorsBoxLayout->addWidget( RadioButton1 );
  ConstructorsBoxLayout->addWidget( RadioButton2 );
  GroupConstructors->addButton(RadioButton1, 0);
  GroupConstructors->addButton(RadioButton2, 1);
  
  /***************************************************************/
  GroupContent = new QGroupBox( tr( "SMESH_CONTENT" ), this );
  QGridLayout* GroupContentLayout = new QGridLayout( GroupContent );
  GroupContentLayout->setSpacing( SPACING );
  GroupContentLayout->setMargin( MARGIN );
  
  TextLabelIds = new QLabel( tr( "SMESH_ID_NODES" ), GroupContent );
  SelectElementsButton  = new QPushButton( GroupContent );
  SelectElementsButton->setIcon( image0 );
  LineEditElements  = new QLineEdit( GroupContent );
  LineEditElements->setValidator( new SMESHGUI_IdValidator( this ) );

  myFacesByNodesLabel = new QLabel( tr( "FACES_BY_NODES" ), GroupContent );
  myFacesByNodes = new QListWidget( GroupContent);
  myFacesByNodes->setSelectionMode( QListWidget::ExtendedSelection );
  myFacesByNodes->setMinimumHeight( 150);

  AddButton = new QPushButton( tr( "SMESH_BUT_ADD" ), GroupContent );
  RemoveButton = new QPushButton( tr( "SMESH_BUT_REMOVE" ), GroupContent );

  Preview = new QCheckBox( tr( "SMESH_POLYEDRE_PREVIEW" ), GroupContent );

  GroupContentLayout->addWidget( TextLabelIds,         0, 0 );
  GroupContentLayout->addWidget( SelectElementsButton, 0, 1 );
  GroupContentLayout->addWidget( LineEditElements,     0, 2, 1, 2 );
  GroupContentLayout->addWidget( myFacesByNodesLabel,  1, 0 );
  GroupContentLayout->addWidget( myFacesByNodes,       2, 0, 3, 3 );
  GroupContentLayout->addWidget( AddButton,            2, 3 );
  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 );
  GroupButtonsLayout->setSpacing( SPACING );
  GroupButtonsLayout->setMargin( MARGIN );

  buttonOk = new QPushButton( tr( "SMESH_BUT_APPLY_AND_CLOSE" ), GroupButtons );
  buttonOk->setAutoDefault( true );
  buttonOk->setDefault( true );
  buttonApply = new QPushButton( tr( "SMESH_BUT_APPLY" ), GroupButtons );
  buttonApply->setAutoDefault( true );
  buttonCancel = new QPushButton( tr( "SMESH_BUT_CLOSE" ), GroupButtons );
  buttonCancel->setAutoDefault( true );
  buttonHelp = new QPushButton( tr("SMESH_BUT_HELP" ), GroupButtons );
  buttonHelp->setAutoDefault(true);

  GroupButtonsLayout->addWidget( buttonOk );
  GroupButtonsLayout->addSpacing( 10 );
  GroupButtonsLayout->addWidget( buttonApply );
  GroupButtonsLayout->addSpacing( 10 );
  GroupButtonsLayout->addStretch();
  GroupButtonsLayout->addWidget( buttonCancel );
  GroupButtonsLayout->addWidget( buttonHelp);

  /***************************************************************/
  topLayout->addWidget( ConstructorsBox );
  topLayout->addWidget( GroupContent );
  topLayout->addWidget( GroupGroups );
  topLayout->addWidget( GroupButtons );
  
  mySelector = (SMESH::GetViewWindow( mySMESHGUI ))->GetSelector();
  
  RadioButton1->setChecked( true );
 
  mySMESHGUI->SetActiveDialogBox( (QDialog*)this );

  myHelpFileName = "adding_nodes_and_elements_page.html#adding_polyhedrons_anchor";
  
  Init();
}
SMESHGUI_CreatePolyhedralVolumeDlg::~SMESHGUI_CreatePolyhedralVolumeDlg ( )

Definition at line 311 of file SMESHGUI_CreatePolyhedralVolumeDlg.cxx.

References mySimulation.

{
  delete mySimulation;
}

Member Function Documentation

void SMESHGUI_CreatePolyhedralVolumeDlg::ActivateThisDialog ( ) [private, slot]

Definition at line 1012 of file SMESHGUI_CreatePolyhedralVolumeDlg.cxx.

References ConstructorsBox, SMESHGUI.EmitSignalDeactivateDialog(), SMESH.GetViewWindow(), GroupButtons, GroupContent, mySMESHGUI, SelectionIntoArgument(), and SMESHGUI.SetActiveDialogBox().

Referenced by enterEvent().

{
  /* Emit a signal to deactivate the active dialog */
  mySMESHGUI->EmitSignalDeactivateDialog();   
  ConstructorsBox->setEnabled(true);
  GroupContent->setEnabled(true);
  GroupButtons->setEnabled(true);
  
  mySMESHGUI->SetActiveDialogBox( (QDialog*)this );

  if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
    aViewWindow->SetSelectionMode( FaceSelection );
  SelectionIntoArgument();
}
int SMESHGUI_CreatePolyhedralVolumeDlg::checkEditLine ( bool  checkLast = true) [private]

Definition at line 835 of file SMESHGUI_CreatePolyhedralVolumeDlg.cxx.

References SMESH.FindActorByObject(), SMDS_Mesh.FindElement(), SMDS_Mesh.FindNode(), GetConstructorId(), SMDS_Mesh.GetElementType(), SMDS_MeshElement.GetID(), SMESH_Actor.GetObject(), myActor, myEditCurrentArgument, myMesh, and SMDSAbs_Face.

Referenced by ClickOnApply(), ClickOnOk(), onAdd(), onTextChange(), and SelectionIntoArgument().

{
  QString aString = "";
  SMDS_Mesh* aMesh = 0;
  
  if(myMesh->_is_nil()) return 1;
  if(!myActor){
    myActor = SMESH::FindActorByObject(myMesh);
    if(!myActor)
      return 1;
  }
    
  aMesh = myActor->GetObject()->GetMesh();

  // checking for nodes
  if (checkLast && myEditCurrentArgument->text().right(1) != QString(" ") ) return 1;
  QStringList aListId = myEditCurrentArgument->text().split( " ", QString::SkipEmptyParts );
  for ( int i = 0; i < aListId.count(); i++ ){
    switch (GetConstructorId()){
    case 0:{ // nodes
      const SMDS_MeshNode    * aNode = aMesh->FindNode( aListId[ i ].toInt() );
      if( !aNode ){
        SUIT_MessageBox::warning(this,
                                 tr("SMESH_POLYEDRE_CREATE_ERROR"),
                                 tr("The incorrect indices of nodes!"));
        
        myEditCurrentArgument->clear();
        myEditCurrentArgument->setText( aString );
        return -1;
      }

      break;
    }
    case 1:{ // faces
      bool aElemIsOK = true;
      const SMDS_MeshElement * aElem = aMesh->FindElement( aListId[ i ].toInt() );
      if (!aElem)
        {
          aElemIsOK = false;
        }
      else
        {
          SMDSAbs_ElementType aType = aMesh->GetElementType( aElem->GetID(),true );
          if (aType != SMDSAbs_Face){
            aElemIsOK = false;
          }
        }
      if (!aElemIsOK){
        SUIT_MessageBox::warning(this,
                                 tr("SMESH_POLYEDRE_CREATE_ERROR"),
                                 tr("The incorrect indices of faces!"));
        
        myEditCurrentArgument->clear();
        myEditCurrentArgument->setText( aString );
        return -1;
      }
      break;
    }
    }
    aString += aListId[ i ] + " "; 
  }

  return 1;
}
void SMESHGUI_CreatePolyhedralVolumeDlg::ClickOnApply ( ) [private, slot]

Definition at line 442 of file SMESHGUI_CreatePolyhedralVolumeDlg.cxx.

References SMESH.AddGroup(), SMESH_controls.aGroup, SMESH_BelongToGeom.anIds, checkEditLine(), ComboBox_GroupName, SMESH_Actor.eVolumes, GetConstructorId(), SMESH_Actor.GetEntityMode(), SMESHGUI.GetSMESHGUI(), GroupGroups, SMESHGUI.isActiveStudyLocked(), isValid(), SMESHGUI.Modified(), myActor, myEditCurrentArgument, myFacesByNodes, myGroups, myMesh, myNbOkElements, mySMESHGUI, SMESH_AdvancedEditor.res, SMESH_Actor.SetEntityMode(), SMESH.UpdateView(), and SMESH.VOLUME.

Referenced by ClickOnOk(), and Init().

{
  if( !isValid() )
    return;

  if ( myNbOkElements>0 && !mySMESHGUI->isActiveStudyLocked())
    {
      if(checkEditLine(false) == -1) {return;}
      busy = true;
      long anElemId = -1;

      bool addToGroup = GroupGroups->isChecked();
      QString aGroupName;
      
      SMESH::SMESH_GroupBase_var aGroup;
      int idx = 0;
      if( addToGroup ) {
        aGroupName = ComboBox_GroupName->currentText();
        for ( int i = 1; i < ComboBox_GroupName->count(); i++ ) {
          QString aName = ComboBox_GroupName->itemText( i );
          if ( aGroupName == aName && ( i == ComboBox_GroupName->currentIndex() || idx == 0 ) )
            idx = i;
        }
        if ( idx > 0 ) {
          SMESH::SMESH_GroupOnGeom_var aGeomGroup = SMESH::SMESH_GroupOnGeom::_narrow( myGroups[idx-1] );
          if ( !aGeomGroup->_is_nil() ) {
            int res = SUIT_MessageBox::question( this, tr( "SMESH_WRN_WARNING" ),
                                                 tr( "MESH_STANDALONE_GRP_CHOSEN" ).arg( aGroupName ),
                                                 tr( "SMESH_BUT_YES" ), tr( "SMESH_BUT_NO" ), 0, 1 );
            if ( res == 1 ) return;
          }
          aGroup = myGroups[idx-1];
        }
      }

      if (GetConstructorId() == 0)
        {
          SMESH::long_array_var anIdsOfNodes = new SMESH::long_array;
          SMESH::long_array_var aQuantities  = new SMESH::long_array;

          aQuantities->length( myFacesByNodes->count() );

          TColStd_ListOfInteger aNodesIds;

          int aNbQuantities = 0;
          for (int i = 0; i < myFacesByNodes->count(); i++ ) {
            QStringList anIds = myFacesByNodes->item(i)->text().split( " ", QString::SkipEmptyParts );
            for (QStringList::iterator it = anIds.begin(); it != anIds.end(); ++it)
              aNodesIds.Append( (*it).toInt() );

            aQuantities[aNbQuantities++] = anIds.count();
          }

          anIdsOfNodes->length(aNodesIds.Extent());

          int aNbIdsOfNodes = 0;
          TColStd_ListIteratorOfListOfInteger It;
          It.Initialize(aNodesIds);
          for( ;It.More();It.Next())
            anIdsOfNodes[aNbIdsOfNodes++] = It.Value();
            
          try{
            SUIT_OverrideCursor aWaitCursor;
            SMESH::SMESH_MeshEditor_var aMeshEditor = myMesh->GetMeshEditor();
            anElemId = aMeshEditor->AddPolyhedralVolume(anIdsOfNodes, aQuantities);
          }catch(SALOME::SALOME_Exception& exc){
            INFOS("Follow exception was cought:\n\t"<<exc.details.text);
          }catch(std::exception& exc){
            INFOS("Follow exception was cought:\n\t"<<exc.what());
          }catch(...){
            INFOS("Unknown exception was cought !!!");
          }
        }
      else if (GetConstructorId() == 1)
        {
          SMESH::long_array_var anIdsOfFaces = new SMESH::long_array;
          
          QStringList aListId = myEditCurrentArgument->text().split( " ", QString::SkipEmptyParts );
          anIdsOfFaces->length(aListId.count());
          for ( int i = 0; i < aListId.count(); i++ )
            anIdsOfFaces[i] = aListId[i].toInt();
          
          try{
            SUIT_OverrideCursor aWaitCursor;
            SMESH::SMESH_MeshEditor_var aMeshEditor = myMesh->GetMeshEditor();
            anElemId = aMeshEditor->AddPolyhedralVolumeByFaces(anIdsOfFaces);
          }catch(SALOME::SALOME_Exception& exc){
            INFOS("Follow exception was cought:\n\t"<<exc.details.text);
          }catch(std::exception& exc){
            INFOS("Follow exception was cought:\n\t"<<exc.what());
          }catch(...){
            INFOS("Unknown exception was cought !!!");
          }
        }

      if ( anElemId != -1 && addToGroup && !aGroupName.isEmpty() ) {
        SMESH::SMESH_Group_var aGroupUsed;
        if ( aGroup->_is_nil() ) {
          // create new group 
          aGroupUsed = SMESH::AddGroup( myMesh, SMESH::VOLUME, aGroupName );
          if ( !aGroupUsed->_is_nil() ) {
            myGroups.append(SMESH::SMESH_GroupBase::_duplicate(aGroupUsed));
            ComboBox_GroupName->addItem( aGroupName );
          }
        }
        else {
          SMESH::SMESH_GroupOnGeom_var aGeomGroup = SMESH::SMESH_GroupOnGeom::_narrow( aGroup );
          if ( !aGeomGroup->_is_nil() ) {
            aGroupUsed = myMesh->ConvertToStandalone( aGeomGroup );
            if ( !aGroupUsed->_is_nil() && idx > 0 ) {
              myGroups[idx-1] = SMESH::SMESH_GroupBase::_duplicate(aGroupUsed);
              SMESHGUI::GetSMESHGUI()->getApp()->updateObjectBrowser();
            }
          }
          else
            aGroupUsed = SMESH::SMESH_Group::_narrow( aGroup );
        }
        
        if ( !aGroupUsed->_is_nil() ) {
          SMESH::long_array_var anIdList = new SMESH::long_array;
          anIdList->length( 1 );
          anIdList[0] = anElemId;
          aGroupUsed->Add( anIdList.inout() );
        }
      }

      //SALOME_ListIO aList;
      //mySelectionMgr->setSelectedObjects( aList );
      SMESH::UpdateView();
      if( myActor ){
        unsigned int anEntityMode = myActor->GetEntityMode();
        myActor->SetEntityMode(SMESH_Actor::eVolumes | anEntityMode);
      }
      //ConstructorsClicked( GetConstructorId() );
      busy = false;

      SMESHGUI::Modified();
    }
    myFacesByNodes->clear();
}
void SMESHGUI_CreatePolyhedralVolumeDlg::ClickOnCancel ( ) [private, slot]

Definition at line 599 of file SMESHGUI_CreatePolyhedralVolumeDlg.cxx.

References SMESH.GetViewWindow(), mySelectionMgr, mySimulation, mySMESHGUI, SMESHGUI.ResetState(), SMESH.SetPointRepresentation(), and SMESH.TPolySimulation.SetVisibility().

Referenced by ClickOnOk(), closeEvent(), hideEvent(), and Init().

{
  mySelectionMgr->clearFilters();
  //SALOME_ListIO aList;
  //mySelectionMgr->setSelectedObjects( aList );
  SMESH::SetPointRepresentation(false);
  mySimulation->SetVisibility(false);
  if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
    aViewWindow->SetSelectionMode( ActorSelection );
  disconnect( mySelectionMgr, 0, this, 0 );
  mySMESHGUI->ResetState();
  reject();
}
void SMESHGUI_CreatePolyhedralVolumeDlg::ClickOnHelp ( ) [private, slot]

Definition at line 617 of file SMESHGUI_CreatePolyhedralVolumeDlg.cxx.

References myHelpFileName, and mySMESHGUI.

Referenced by Init(), and keyPressEvent().

{
  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_CreatePolyhedralVolumeDlg::ClickOnOk ( ) [private, slot]

Definition at line 587 of file SMESHGUI_CreatePolyhedralVolumeDlg.cxx.

References checkEditLine(), ClickOnApply(), and ClickOnCancel().

Referenced by Init().

{
  if(checkEditLine(false) == -1) {return;}
  ClickOnApply();
  ClickOnCancel();
}
void SMESHGUI_CreatePolyhedralVolumeDlg::ClickOnPreview ( bool  theToggled) [private, slot]

Definition at line 433 of file SMESHGUI_CreatePolyhedralVolumeDlg.cxx.

References displaySimulation(), and Preview.

Referenced by Init().

                                                                      {
  Preview->setChecked(theToggled);
  displaySimulation();
}
void SMESHGUI_CreatePolyhedralVolumeDlg::closeEvent ( QCloseEvent *  e) [private]

Definition at line 1044 of file SMESHGUI_CreatePolyhedralVolumeDlg.cxx.

References ClickOnCancel().

{
  /* same than click on cancel button */
  ClickOnCancel();
}
void SMESHGUI_CreatePolyhedralVolumeDlg::ConstructorsClicked ( int  constructorId) [private, slot]

Definition at line 364 of file SMESHGUI_CreatePolyhedralVolumeDlg.cxx.

References AddButton, buttonApply, buttonOk, SMESH.GetViewWindow(), myActor, myEditCurrentArgument, myFacesByNodes, myFacesByNodesLabel, myNbOkElements, mySelectionMgr, mySimulation, mySMESHGUI, Preview, RemoveButton, SMESH.SetPointRepresentation(), SMESH_Actor.SetPointRepresentation(), SMESH.TPolySimulation.SetVisibility(), and TextLabelIds.

Referenced by Init().

{
  //disconnect(mySelectionMgr, 0, this, 0);

  SALOME_ListIO io;
  mySelectionMgr->selectedObjects( io );
  SALOME_ListIO aList;
  mySelectionMgr->setSelectedObjects( aList );
  myEditCurrentArgument->clear();
  myNbOkElements = 0;
  buttonApply->setEnabled(false);
  buttonOk->setEnabled(false);
  mySimulation->SetVisibility(false);

  switch(constructorId)
    {
    case 0 :
      { 
        if ( myActor ){
          myActor->SetPointRepresentation(true);
        }
        else
          SMESH::SetPointRepresentation(true);
        if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
          aViewWindow->SetSelectionMode(NodeSelection);
        
        AddButton->setEnabled(false);
        RemoveButton->setEnabled(false);
        TextLabelIds->setText( tr( "SMESH_ID_NODES" ) );
        myFacesByNodesLabel->show();
        myFacesByNodes->clear();
        myFacesByNodes->show();
        AddButton->show();
        RemoveButton->show();
        Preview->show();
        break;
      }
    case 1 :
      {
        if( myActor ){
          myActor->SetPointRepresentation(false);
        } else {
          SMESH::SetPointRepresentation(false);
        }
        if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
          aViewWindow->SetSelectionMode(FaceSelection);
        
        TextLabelIds->setText( tr( "SMESH_ID_FACES" ) );
        myFacesByNodesLabel->hide();
        myFacesByNodes->hide();
        AddButton->hide();
        RemoveButton->hide();
        Preview->show();
        break;
      }
    }
  
  //connect(mySelectionMgr, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument()));
  mySelectionMgr->setSelectedObjects( io );

  QApplication::instance()->processEvents();
  updateGeometry();
  resize(100,100);
}
void SMESHGUI_CreatePolyhedralVolumeDlg::DeactivateActiveDialog ( ) [private, slot]
void SMESHGUI_CreatePolyhedralVolumeDlg::displaySimulation ( ) [private]

Definition at line 904 of file SMESHGUI_CreatePolyhedralVolumeDlg.cxx.

References AddButton, SMESH_BelongToGeom.anIds, SMDS_Mesh.FindElement(), SMDS_Mesh.FindNode(), GetConstructorId(), SMDS_Mesh.GetElementType(), SMDS_MeshElement.GetID(), SMESH_Actor.GetObject(), GroupButtons, myActor, myEditCurrentArgument, myFacesByNodes, myNbOkElements, mySimulation, SMDS_MeshElement.nodesIterator(), Preview, SMESH.TPolySimulation.ResetGrid(), SMESH.TPolySimulation.SetPosition(), SMESH.TPolySimulation.SetVisibility(), SMDSAbs_Face, and SMESH.UpdateView().

Referenced by ClickOnPreview(), onAdd(), onRemove(), onTextChange(), and SelectionIntoArgument().

{
  if ( (myNbOkElements || AddButton->isEnabled()) && GroupButtons->isEnabled() && myActor)
    {
      SMESH::TPolySimulation::TVTKIds aVTKIds;
      vtkIdType aType = VTK_CONVEX_POINT_SET;
      SMDS_Mesh* aMesh = 0;
      if ( myActor ){
        aMesh = myActor->GetObject()->GetMesh();
      }
      if (GetConstructorId() == 0 && aMesh){
        if (!AddButton->isEnabled()){
          mySimulation->ResetGrid(true);
          for (int i = 0; i < myFacesByNodes->count(); i++) {
            QStringList anIds = myFacesByNodes->item(i)->text().split( " ", QString::SkipEmptyParts );
            SMESH::TPolySimulation::TVTKIds aVTKIds_faces;
            for (QStringList::iterator it = anIds.begin(); it != anIds.end(); ++it){
              const SMDS_MeshNode* aNode = aMesh->FindNode( (*it).toInt() );
              if (!aNode) continue;
              vtkIdType aId = myActor->GetObject()->GetNodeVTKId( (*it).toInt() );
              aVTKIds.push_back(aId);
              aVTKIds_faces.push_back(aId);
            }
            if(!Preview->isChecked()){
              aType = VTK_POLYGON;
              mySimulation->SetPosition(myActor, aType, aVTKIds_faces,false);
            }
          }
          if(myFacesByNodes->count() == 0){
            mySimulation->SetVisibility(false);
          } else {
            mySimulation->SetVisibility(true);
          }
          if(Preview->isChecked()){
            mySimulation->SetPosition(myActor, aType, aVTKIds);
          }
        } else {
          // add ids from edit line
          QStringList anEditIds = myEditCurrentArgument->text().split( " ", QString::SkipEmptyParts );
          for ( int i = 0; i < anEditIds.count(); i++ )
            aVTKIds.push_back( myActor->GetObject()->GetNodeVTKId( anEditIds[ i ].toInt() ));
          aType = VTK_POLYGON;
          mySimulation->SetPosition(myActor, aType, aVTKIds);
        }
      }else if(GetConstructorId() == 1 && aMesh){
        QStringList aListId = myEditCurrentArgument->text().split( " ", QString::SkipEmptyParts );
        for ( int i = 0; i < aListId.count(); i++ )
          {
            const SMDS_MeshElement * anElem = aMesh->FindElement( aListId[ i ].toInt() );
            if ( !anElem ) continue;
            SMDSAbs_ElementType aFaceType = aMesh->GetElementType( anElem->GetID(),true );
            if (aFaceType != SMDSAbs_Face) continue;
              
            SMDS_ElemIteratorPtr anIter = anElem->nodesIterator();
            SMESH::TPolySimulation::TVTKIds aVTKIds_faces;
            while( anIter->more() )
              if ( const SMDS_MeshNode* aNode = (SMDS_MeshNode*)anIter->next() ){
                vtkIdType aId = myActor->GetObject()->GetNodeVTKId( aNode->GetID() );
                aVTKIds.push_back(aId);
                aVTKIds_faces.push_back(aId);
              }
            if(!Preview->isChecked()){
              aType = VTK_POLYGON;
              mySimulation->SetPosition(myActor, aType, aVTKIds_faces);
            }
          }
        if(Preview->isChecked())
          mySimulation->SetPosition(myActor, aType, aVTKIds);
      }
      SMESH::UpdateView();
    }
}
void SMESHGUI_CreatePolyhedralVolumeDlg::enterEvent ( QEvent *  e) [private]

Definition at line 1032 of file SMESHGUI_CreatePolyhedralVolumeDlg.cxx.

References ActivateThisDialog(), and ConstructorsBox.

{
  if ( ConstructorsBox->isEnabled() )
    return;  
  ActivateThisDialog();
}
int SMESHGUI_CreatePolyhedralVolumeDlg::GetConstructorId ( ) [private]
void SMESHGUI_CreatePolyhedralVolumeDlg::hideEvent ( QHideEvent *  e) [private]

Definition at line 1056 of file SMESHGUI_CreatePolyhedralVolumeDlg.cxx.

References ClickOnCancel().

{
  if ( !isMinimized() )
    ClickOnCancel();
}
void SMESHGUI_CreatePolyhedralVolumeDlg::Init ( ) [private]

Definition at line 322 of file SMESHGUI_CreatePolyhedralVolumeDlg.cxx.

References AddButton, buttonApply, buttonCancel, buttonHelp, buttonOk, ClickOnApply(), ClickOnCancel(), ClickOnHelp(), ClickOnOk(), ClickOnPreview(), ConstructorsClicked(), DeactivateActiveDialog(), GroupConstructors, GroupGroups, LineEditElements, myActor, myEditCurrentArgument, myFacesByNodes, myNbOkElements, mySelectionMgr, mySimulation, mySMESHGUI, onAdd(), onListSelectionChanged(), onRemove(), onTextChange(), Preview, RemoveButton, SelectElementsButton, SelectionIntoArgument(), SMESHGUI.SetActiveDialogBox(), and SetEditCurrentArgument().

Referenced by SMESHGUI_CreatePolyhedralVolumeDlg().

{
  myEditCurrentArgument = LineEditElements;
  mySMESHGUI->SetActiveDialogBox( (QDialog*)this );

  /* reset "Add to group" control */
  GroupGroups->setChecked( false );

  myNbOkElements = 0;
  myActor = 0;

  mySimulation = new SMESH::TPolySimulation( dynamic_cast<SalomeApp_Application*>( mySMESHGUI->application() ) );

  /* signals and slots connections */
  connect(buttonOk,     SIGNAL( clicked() ), SLOT( ClickOnOk() ) );
  connect(buttonCancel, SIGNAL( clicked() ), SLOT( ClickOnCancel() ) );
  connect(buttonApply,  SIGNAL( clicked() ), SLOT( ClickOnApply() ) );
  connect(buttonHelp,   SIGNAL( clicked() ), SLOT( ClickOnHelp() ) );

  connect(GroupConstructors, SIGNAL(buttonClicked(int) ), SLOT( ConstructorsClicked(int) ) );
  connect(SelectElementsButton, SIGNAL( clicked() ), SLOT( SetEditCurrentArgument() ) );
  connect(LineEditElements, SIGNAL( textChanged(const QString&) ), SLOT(onTextChange(const QString&)));

  connect(myFacesByNodes, SIGNAL(itemSelectionChanged()), this, SLOT(onListSelectionChanged()));
  connect(AddButton, SIGNAL(clicked()), this, SLOT(onAdd()));
  connect(RemoveButton, SIGNAL(clicked()), this, SLOT(onRemove()));
  
  connect( mySMESHGUI, SIGNAL ( SignalDeactivateActiveDialog() ), this, SLOT( DeactivateActiveDialog() ) );
  connect( mySelectionMgr, SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) );
  connect( Preview, SIGNAL(toggled(bool)), this, SLOT(ClickOnPreview(bool)));
  /* to close dialog if study change */
  connect( mySMESHGUI, SIGNAL ( SignalCloseAllDialogs() ), this, SLOT( ClickOnCancel() ) );
  
  ConstructorsClicked(0);
  SelectionIntoArgument();
}
bool SMESHGUI_CreatePolyhedralVolumeDlg::isValid ( ) [private]

Definition at line 1175 of file SMESHGUI_CreatePolyhedralVolumeDlg.cxx.

References ComboBox_GroupName, and GroupGroups.

Referenced by ClickOnApply().

{
  if( GroupGroups->isChecked() && ComboBox_GroupName->currentText().isEmpty() ) {
    SUIT_MessageBox::warning( this, tr( "SMESH_WRN_WARNING" ), tr( "GROUP_NAME_IS_EMPTY" ) );
    return false;
  }
  return true;
}
void SMESHGUI_CreatePolyhedralVolumeDlg::keyPressEvent ( QKeyEvent *  e) [private]

Definition at line 1159 of file SMESHGUI_CreatePolyhedralVolumeDlg.cxx.

References ClickOnHelp().

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

  if ( e->key() == Qt::Key_F1 ) {
    e->accept();
    ClickOnHelp();
  }
}
void SMESHGUI_CreatePolyhedralVolumeDlg::onAdd ( ) [slot]

Definition at line 1076 of file SMESHGUI_CreatePolyhedralVolumeDlg.cxx.

References AddButton, buttonApply, buttonOk, checkEditLine(), displaySimulation(), myActor, myEditCurrentArgument, myFacesByNodes, myMesh, myNbOkElements, mySelectionMgr, and onListSelectionChanged().

Referenced by Init().

{
  SALOME_ListIO selected;
  mySelectionMgr->selectedObjects( selected );
  int aNbSel = selected.Extent();
  if (aNbSel == 0 || !myActor || myMesh->_is_nil()) return;
  
  if (checkEditLine(false) == -1) return;

  busy = true;
  if ( !(myEditCurrentArgument->text().isEmpty()) )
    {
      myFacesByNodes->addItem(myEditCurrentArgument->text());
      //myFacesByNodes->setSelected(myFacesByNodes->count() - 1, true);
      myNbOkElements = 1;
      myEditCurrentArgument->clear();
      AddButton->setEnabled(false);
      buttonApply->setEnabled( myFacesByNodes->count() > 1 );
      buttonOk->setEnabled( myFacesByNodes->count() > 1 );
    }
  busy = false;
  onListSelectionChanged();
  displaySimulation();
}
void SMESHGUI_CreatePolyhedralVolumeDlg::onListSelectionChanged ( ) [private, slot]

Definition at line 1128 of file SMESHGUI_CreatePolyhedralVolumeDlg.cxx.

References SMESH_BelongToGeom.anIds, SMESH.GetViewWindow(), myActor, myFacesByNodes, mySelectionMgr, mySelector, mySMESHGUI, and RemoveButton.

Referenced by Init(), and onAdd().

{
  if (busy || !myActor) return;
  busy = true;

  SALOME_ListIO aList;
  mySelectionMgr->setSelectedObjects( aList );
  TColStd_MapOfInteger aIndexes;

  QList<QListWidgetItem*> selItems = myFacesByNodes->selectedItems();
  QListWidgetItem* anItem;
  foreach( anItem, selItems ) {
    QStringList anIds = anItem->text().split( " ", QString::SkipEmptyParts );
    for (QStringList::iterator it = anIds.begin(); it != anIds.end(); ++it)
      aIndexes.Add((*it).toInt());
  }
  RemoveButton->setEnabled(selItems.count() > 0);
  mySelector->AddOrRemoveIndex(myActor->getIO(), aIndexes, true );
  if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
    aViewWindow->highlight( myActor->getIO(), true, true );
  mySelectionMgr->clearFilters(); 
  aList.Append( myActor->getIO() );
  mySelectionMgr->setSelectedObjects( aList );
  
  busy = false;
}
void SMESHGUI_CreatePolyhedralVolumeDlg::onRemove ( ) [slot]

Definition at line 1105 of file SMESHGUI_CreatePolyhedralVolumeDlg.cxx.

References buttonApply, buttonOk, displaySimulation(), myFacesByNodes, myNbOkElements, and RemoveButton.

Referenced by Init().

{
  busy = true;
  QList<QListWidgetItem*> selItems = myFacesByNodes->selectedItems();
  QListWidgetItem* anItem;

  if ( selItems.count() > 0 ) myNbOkElements = 1;

  foreach( anItem, selItems )
    delete anItem;

  RemoveButton->setEnabled( myFacesByNodes->count() > 0 );
  buttonOk->setEnabled( myFacesByNodes->count() > 1 );
  buttonApply->setEnabled( myFacesByNodes->count() > 1 );

  busy = false;
  displaySimulation();
}
void SMESHGUI_CreatePolyhedralVolumeDlg::onTextChange ( const QString &  theNewText) [private, slot]

Definition at line 642 of file SMESHGUI_CreatePolyhedralVolumeDlg.cxx.

References AddButton, buttonApply, buttonOk, checkEditLine(), displaySimulation(), SMDS_Mesh.FindElement(), SMDS_Mesh.FindNode(), GetConstructorId(), SMDS_MeshElement.GetID(), SMESH_Actor.GetObject(), SMESH.GetViewWindow(), myActor, myNbOkElements, mySelector, mySimulation, mySMESHGUI, and SMESH.TPolySimulation.SetVisibility().

Referenced by Init().

{
  if ( busy ) return;
  if (checkEditLine() == -1) return;
  busy = true;

  mySimulation->SetVisibility(false);

  SMDS_Mesh* aMesh = 0;
  if ( myActor )
    aMesh = myActor->GetObject()->GetMesh();

  if (GetConstructorId() == 0)
    {
      if ( aMesh ) {
        TColStd_MapOfInteger newIndices;
      
        QStringList aListId = theNewText.split( " ", QString::SkipEmptyParts );
        for ( int i = 0; i < aListId.count(); i++ ) {
          const SMDS_MeshNode * n = aMesh->FindNode( aListId[ i ].toInt() );
          if ( n ) {
            newIndices.Add(n->GetID());
            myNbOkElements++;
          }
        }
      
        mySelector->AddOrRemoveIndex( myActor->getIO(), newIndices, false );
      
        if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
          aViewWindow->highlight( myActor->getIO(), true, true );
      
        if ( myNbOkElements>0 && aListId.count()>=3)
          AddButton->setEnabled(true);
        else
          AddButton->setEnabled(false);
      
        displaySimulation();
      }
    } else if (GetConstructorId() == 1)
      {
        myNbOkElements = 0;
        buttonOk->setEnabled( false );
        buttonApply->setEnabled( false );
      
        // check entered ids of faces and hilight them
        QStringList aListId;
        if ( aMesh ) {
          TColStd_MapOfInteger newIndices;
      
          aListId = theNewText.split( " ", QString::SkipEmptyParts );

          for ( int i = 0; i < aListId.count(); i++ ) {
            const SMDS_MeshElement * e = aMesh->FindElement( aListId[ i ].toInt() );
            if ( e ) {
              newIndices.Add(e->GetID());
              myNbOkElements++;  
            }
          }

          mySelector->AddOrRemoveIndex( myActor->getIO(), newIndices, false );
          if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
            aViewWindow->highlight( myActor->getIO(), true, true );
      
          if ( myNbOkElements ) {
            if (aListId.count()>1){ 
              buttonOk->setEnabled( true );
              buttonApply->setEnabled( true );
            }
            else{
              buttonOk->setEnabled( false );
              buttonApply->setEnabled( false );
            }
            if(aListId.count()>1)
              displaySimulation();
          }
        }
      }
  busy = false;
}
void SMESHGUI_CreatePolyhedralVolumeDlg::SelectionIntoArgument ( ) [private, slot]

Definition at line 726 of file SMESHGUI_CreatePolyhedralVolumeDlg.cxx.

References AddButton, SMESH_controls.aGroup, buttonApply, buttonOk, checkEditLine(), ComboBox_GroupName, displaySimulation(), SMESH.FindActorByObject(), GetConstructorId(), SMESH.GetMeshByIO(), SMESH.GetNameOfSelectedElements(), SMESH.GetNameOfSelectedNodes(), GroupButtons, myActor, myEditCurrentArgument, myEntry, myFacesByNodes, myGroups, myMesh, myNbOkElements, mySelectionMgr, mySelector, mySimulation, SMESH.TPolySimulation.SetVisibility(), and VOLUME.

Referenced by ActivateThisDialog(), Init(), and SetEditCurrentArgument().

{
  if ( busy ) return;
  
  // clear
  
  if (GetConstructorId() == 1 || myFacesByNodes->count() <= 1)
    {
      myNbOkElements = 0;
      AddButton->setEnabled(false);
      buttonOk->setEnabled( false );
      buttonApply->setEnabled( false );
    }

  myActor = 0;

  busy = true;
  myEditCurrentArgument->setText( "" );
  busy = false;
  if ( !GroupButtons->isEnabled() ) // inactive
    return;
  
  mySimulation->SetVisibility(false);
  
  QString aCurrentEntry = myEntry;

  // get selected mesh
  
  SALOME_ListIO selected;
  mySelectionMgr->selectedObjects( selected );
  int nbSel = selected.Extent();
  if(nbSel != 1){
    return;
  }
  
  myEntry = selected.First()->getEntry();
  myMesh = SMESH::GetMeshByIO( selected.First() );
  if ( myMesh->_is_nil() )
    return;
  
  // process groups
  if ( !myMesh->_is_nil() && myEntry != aCurrentEntry ) {
    myGroups.clear();
    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 aGroup = aListOfGroups[i];
      if ( !aGroup->_is_nil() && aGroup->GetType() == SMESH::VOLUME ) {
        QString aGroupName( aGroup->GetName() );
        if ( !aGroupName.isEmpty() ) {
          myGroups.append(SMESH::SMESH_GroupBase::_duplicate(aGroup));
          ComboBox_GroupName->addItem( aGroupName );
        }
      }
    }
  }

  myActor = SMESH::FindActorByObject(myMesh);
  if ( !myActor )
    return;
  
  // get selected nodes/faces
  QString aString = "";
  int anbNodes=0,aNbFaces=0;
  switch(GetConstructorId()){
  case 0:{
    anbNodes = SMESH::GetNameOfSelectedNodes(mySelector, myActor->getIO(), aString);
    if (anbNodes >= 3)
      AddButton->setEnabled(true);
    else if (anbNodes < 3){
      AddButton->setEnabled(false);
    }
    busy = true;
    myEditCurrentArgument->setText( aString );
    if (checkEditLine() == -1) {busy = false;return;}
    busy = false;
    break;
  }
  case 1:{
    // get selected faces
    aNbFaces = SMESH::GetNameOfSelectedElements(mySelector, myActor->getIO(), aString);
    if (aNbFaces<=1){
      buttonOk->setEnabled( false );
      buttonApply->setEnabled( false );
    } else {
      buttonOk->setEnabled( true );
      buttonApply->setEnabled( true );
    }
    busy = true;
    myEditCurrentArgument->setText( aString );
    if (checkEditLine() == -1) {busy = false;return;}
    busy = false;
    
    // OK
    myNbOkElements = 1;
    break;
  }
  default: return;
  }
  if(anbNodes>2 || aNbFaces>1)
    displaySimulation();
}
void SMESHGUI_CreatePolyhedralVolumeDlg::SetEditCurrentArgument ( ) [private, slot]

Definition at line 981 of file SMESHGUI_CreatePolyhedralVolumeDlg.cxx.

References LineEditElements, myEditCurrentArgument, SelectElementsButton, and SelectionIntoArgument().

Referenced by Init().

{
  QPushButton* send = (QPushButton*)sender();
  if(send == SelectElementsButton) {
    LineEditElements->setFocus();
    myEditCurrentArgument = LineEditElements;
  }
  SelectionIntoArgument();
}

Field Documentation

Definition at line 97 of file SMESHGUI_CreatePolyhedralVolumeDlg.h.

Referenced by SelectionIntoArgument().

Definition at line 98 of file SMESHGUI_CreatePolyhedralVolumeDlg.h.

Referenced by ClickOnApply(), and SelectionIntoArgument().

Definition at line 89 of file SMESHGUI_CreatePolyhedralVolumeDlg.h.

SMESH::SMESH_Mesh_var SMESHGUI_CreatePolyhedralVolumeDlg.myMesh [private]
LightApp_SelectionMgr* SMESHGUI_CreatePolyhedralVolumeDlg.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