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

SMESHGUI_AddQuadraticElementDlg Class Reference

#include <SMESHGUI_AddQuadraticElementDlg.h>

Inheritance diagram for SMESHGUI_AddQuadraticElementDlg:
Inheritance graph
[legend]

Public Member Functions

 SMESHGUI_AddQuadraticElementDlg (SMESHGUI *, const int)
 ~SMESHGUI_AddQuadraticElementDlg ()

Private Types

typedef QList
< SMESH::SMESH_GroupBase_var > 
GrpList

Private Slots

void onTextChange (const QString &)
void onCellTextChange (int, int)
void onReverse (int)
void onCellDoubleClicked (int, int)
void ClickOnOk ()
void ClickOnCancel ()
void ClickOnApply ()
void ClickOnHelp ()
void SetEditCorners ()
void SelectionIntoArgument ()
void DeactivateActiveDialog ()
void ActivateThisDialog ()

Private Member Functions

void Init ()
void closeEvent (QCloseEvent *)
void hideEvent (QHideEvent *)
void enterEvent (QEvent *)
void keyPressEvent (QKeyEvent *)
void displaySimulation ()
void UpdateTable (bool=true)
bool IsValid ()
void updateButtons ()
bool isValid ()

Private Attributes

SMESHGUImySMESHGUI
LightApp_SelectionMgr * mySelectionMgr
int myNbCorners
bool myBusy
SVTK_Selector * mySelector
SMESH::SMESH_Mesh_var myMesh
SMESH_ActormyActor
SMESH::TElementSimulationmySimulation
QString myEntry
GrpList myGroups
int myType
bool myIsEditCorners
QGroupBoxGroupConstructors
QRadioButton * myRadioButton1
QGroupBoxGroupArguments
QLineEdit * myCornerNodes
QPushButton * mySelectButton
QTableWidgetmyTable
QCheckBox * myReverseCB
QGroupBoxGroupGroups
QLabel * TextLabel_GroupName
QComboBox * ComboBox_GroupName
QGroupBoxGroupButtons
QPushButton * buttonOk
QPushButton * buttonCancel
QPushButton * buttonApply
QPushButton * buttonHelp
QString myHelpFileName

Detailed Description

Definition at line 65 of file SMESHGUI_AddQuadraticElementDlg.h.


Member Typedef Documentation

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

Definition at line 74 of file SMESHGUI_AddQuadraticElementDlg.h.


Constructor & Destructor Documentation

SMESHGUI_AddQuadraticElementDlg::SMESHGUI_AddQuadraticElementDlg ( SMESHGUI theModule,
const int  theType 
)

Definition at line 416 of file SMESHGUI_AddQuadraticElementDlg.cxx.

References buttonApply, buttonCancel, buttonHelp, buttonOk, ComboBox_GroupName, SMESH.GetResourceMgr(), SMESH.GetSelector(), SMESH.GetViewWindow(), GroupArguments, GroupButtons, GroupConstructors, GroupGroups, Init(), MARGIN, myCornerNodes, myRadioButton1, myReverseCB, mySelectButton, mySelector, mySimulation, mySMESHGUI, myTable, myType, QUAD_EDGE, QUAD_HEXAHEDRON, QUAD_PENTAHEDRON, QUAD_PYRAMID, QUAD_QUADRANGLE, QUAD_TETRAHEDRON, QUAD_TRIANGLE, SPACING, and TextLabel_GroupName.

  : QDialog( SMESH::GetDesktop( theModule ) ),
    mySMESHGUI( theModule ),
    mySelectionMgr( SMESH::GetSelectionMgr( theModule ) ),
    myType( theType ),
    myBusy( false )
{
  setModal( false );
  setAttribute( Qt::WA_DeleteOnClose, true );

  SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>
    (SUIT_Session::session()->activeApplication());
  
  mySimulation = new SMESH::TElementSimulation (anApp);
  mySelector = (SMESH::GetViewWindow( mySMESHGUI ))->GetSelector();

  QString anElementName;

  switch ( myType ) {
  case QUAD_EDGE:
    anElementName = QString("QUADRATIC_EDGE");
    break;
  case QUAD_TRIANGLE:
    anElementName = QString("QUADRATIC_TRIANGLE");
    break; 
  case QUAD_QUADRANGLE:
    anElementName = QString("QUADRATIC_QUADRANGLE");
    break;
  case QUAD_TETRAHEDRON:
    anElementName = QString("QUADRATIC_TETRAHEDRON");
    break;
  case QUAD_PYRAMID:
    anElementName = QString("QUADRATIC_PYRAMID");
    break;
  case QUAD_PENTAHEDRON:
    anElementName = QString("QUADRATIC_PENTAHEDRON");
    break;
  case QUAD_HEXAHEDRON:
    anElementName = QString("QUADRATIC_HEXAHEDRON");
    break;
  default:
    myType = QUAD_EDGE;
    anElementName = QString("QUADRATIC_EDGE");
  }

  QString iconName           = tr(QString("ICON_DLG_%1").arg(anElementName).toLatin1().data());
  QString caption            = tr(QString("SMESH_ADD_%1_TITLE").arg(anElementName).toLatin1().data());
  QString argumentsGrTitle   = tr(QString("SMESH_ADD_%1").arg(anElementName).toLatin1().data());
  QString constructorGrTitle = tr(QString("SMESH_%1").arg(anElementName).toLatin1().data());
  
  QPixmap image0 (SMESH::GetResourceMgr( mySMESHGUI )->loadPixmap("SMESH", iconName));
  QPixmap image1 (SMESH::GetResourceMgr( mySMESHGUI )->loadPixmap("SMESH", tr("ICON_SELECT")));

  setWindowTitle(caption);
  
  setSizeGripEnabled(true);

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

  /***************************************************************/
  GroupConstructors = new QGroupBox(constructorGrTitle, this);
  QButtonGroup* ButtonGroup = new QButtonGroup(this);
  QHBoxLayout* aGroupConstructorsLayout = new QHBoxLayout(GroupConstructors);
  aGroupConstructorsLayout->setSpacing(SPACING);
  aGroupConstructorsLayout->setMargin(MARGIN);

  myRadioButton1 = new QRadioButton(GroupConstructors);
  myRadioButton1->setIcon(image0);
  aGroupConstructorsLayout->addWidget(myRadioButton1);
  ButtonGroup->addButton(myRadioButton1, 0);

  /***************************************************************/
  GroupArguments = new QGroupBox(argumentsGrTitle, this);
  QGridLayout* aGroupArgumentsLayout = new QGridLayout(GroupArguments);
  aGroupArgumentsLayout->setSpacing(SPACING);
  aGroupArgumentsLayout->setMargin(MARGIN);

  QLabel* aCornerNodesLabel = new QLabel(tr("SMESH_CORNER_NODES"), GroupArguments);
  mySelectButton = new QPushButton(GroupArguments);
  mySelectButton->setIcon(image1);
  myCornerNodes = new QLineEdit(GroupArguments);

  myTable = new QTableWidget(GroupArguments);

  myReverseCB = new QCheckBox(tr("SMESH_REVERSE"), GroupArguments);

  aGroupArgumentsLayout->addWidget(aCornerNodesLabel, 0, 0);
  aGroupArgumentsLayout->addWidget(mySelectButton,    0, 1);
  aGroupArgumentsLayout->addWidget(myCornerNodes,     0, 2);
  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);
  aGroupButtonsLayout->setSpacing(SPACING);
  aGroupButtonsLayout->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);

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

  /***************************************************************/
  aDialogLayout->addWidget(GroupConstructors);
  aDialogLayout->addWidget(GroupArguments);
  aDialogLayout->addWidget(GroupGroups);
  aDialogLayout->addWidget(GroupButtons);

  Init(); /* Initialisations */
}
SMESHGUI_AddQuadraticElementDlg::~SMESHGUI_AddQuadraticElementDlg ( )

Definition at line 562 of file SMESHGUI_AddQuadraticElementDlg.cxx.

References mySimulation.

{
  delete mySimulation;
}

Member Function Documentation

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

Definition at line 1093 of file SMESHGUI_AddQuadraticElementDlg.cxx.

References SMESHGUI.EmitSignalDeactivateDialog(), SMESH.GetViewWindow(), GroupArguments, GroupButtons, GroupConstructors, mySMESHGUI, SelectionIntoArgument(), and SMESH.SetPointRepresentation().

Referenced by enterEvent().

{
  /* Emit a signal to deactivate the active dialog */
  mySMESHGUI->EmitSignalDeactivateDialog();

  GroupConstructors->setEnabled(true);
  GroupArguments->setEnabled(true);
  GroupButtons->setEnabled(true);

  SMESH::SetPointRepresentation(true);

  if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
    aViewWindow->SetSelectionMode( NodeSelection );
  SelectionIntoArgument();
}
void SMESHGUI_AddQuadraticElementDlg::ClickOnApply ( ) [private, slot]

Definition at line 684 of file SMESHGUI_AddQuadraticElementDlg.cxx.

References SMESH.AddGroup(), SMESH_controls.aGroup, SMESH_BelongToGeom.anIds, ComboBox_GroupName, EDGE, FACE, SMESHGUI.GetSMESHGUI(), GroupGroups, SMESHGUI.isActiveStudyLocked(), IsValid(), isValid(), SMESHGUI.Modified(), myActor, myBusy, myGroups, myMesh, myNbCorners, myReverseCB, mySelectionMgr, mySelector, mySimulation, mySMESHGUI, myTable, myType, QUAD_EDGE, QUAD_HEXAHEDRON, QUAD_PENTAHEDRON, QUAD_PYRAMID, QUAD_QUADRANGLE, QUAD_TETRAHEDRON, QUAD_TRIANGLE, SMESH_AdvancedEditor.res, SMESH.ReverseConnectivity(), SetEditCorners(), SMESH.TElementSimulation.SetVisibility(), updateButtons(), UpdateTable(), SMESH.UpdateView(), and VOLUME.

Referenced by ClickOnOk(), and Init().

{
  if( !isValid() )
    return;

  if ( mySMESHGUI->isActiveStudyLocked() || myBusy || !IsValid() )
    return;

  BusyLocker lock( myBusy );

  std::vector<vtkIdType> anIds;

  switch (myType) {
  case QUAD_EDGE:
    anIds.push_back(myTable->item(0, 0)->text().toInt());
    anIds.push_back(myTable->item(0, 2)->text().toInt());
    anIds.push_back(myTable->item(0, 1)->text().toInt());
    break;
  case QUAD_TRIANGLE:
  case QUAD_QUADRANGLE:
  case QUAD_TETRAHEDRON:
  case QUAD_PYRAMID:
  case QUAD_PENTAHEDRON:
  case QUAD_HEXAHEDRON:
    for ( int row = 0; row < myNbCorners; row++ )
      anIds.push_back(myTable->item(row, 0)->text().toInt());
    for ( int row = 0; row < myTable->rowCount(); row++ )
      anIds.push_back(myTable->item(row, 1)->text().toInt());
    break;
  }
  if ( myReverseCB->isChecked())
    SMESH::ReverseConnectivity( anIds, myType );
    
  int aNumberOfIds =  anIds.size();
  SMESH::long_array_var anArrayOfIdeces = new SMESH::long_array;
  anArrayOfIdeces->length( aNumberOfIds );
    
  for (int i = 0; i < aNumberOfIds; i++)
    anArrayOfIdeces[i] = anIds[ i ];

  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];
    }
  }

  SMESH::ElementType anElementType;
  long anElemId = -1;
  SMESH::SMESH_MeshEditor_var aMeshEditor = myMesh->GetMeshEditor();
  switch (myType) {
  case QUAD_EDGE:
    anElementType = SMESH::EDGE;
    anElemId = aMeshEditor->AddEdge(anArrayOfIdeces.inout()); break;
  case QUAD_TRIANGLE:
  case QUAD_QUADRANGLE:
    anElementType = SMESH::FACE;
    anElemId = aMeshEditor->AddFace(anArrayOfIdeces.inout()); break;
  case QUAD_TETRAHEDRON:
  case QUAD_PYRAMID:
  case QUAD_PENTAHEDRON: 
  case QUAD_HEXAHEDRON:
    anElementType = SMESH::VOLUME;
    anElemId = aMeshEditor->AddVolume(anArrayOfIdeces.inout()); break;
  default: break;
  }
    
  if ( anElemId != -1 && addToGroup && !aGroupName.isEmpty() ) {
    SMESH::SMESH_Group_var aGroupUsed;
    if ( aGroup->_is_nil() ) {
      // create new group 
      aGroupUsed = SMESH::AddGroup( myMesh, anElementType, 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; aList.Append( myActor->getIO() );
  mySelector->ClearIndex();
  mySelectionMgr->setSelectedObjects( aList, false );

  mySimulation->SetVisibility(false);
  SMESH::UpdateView();
    
  UpdateTable();
  SetEditCorners();

  updateButtons();

  SMESHGUI::Modified();
}
void SMESHGUI_AddQuadraticElementDlg::ClickOnCancel ( ) [private, slot]

Definition at line 828 of file SMESHGUI_AddQuadraticElementDlg.cxx.

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

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

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

Definition at line 844 of file SMESHGUI_AddQuadraticElementDlg.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_AddQuadraticElementDlg::ClickOnOk ( ) [private, slot]

Definition at line 818 of file SMESHGUI_AddQuadraticElementDlg.cxx.

References ClickOnApply(), and ClickOnCancel().

Referenced by Init().

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

Definition at line 1124 of file SMESHGUI_AddQuadraticElementDlg.cxx.

References ClickOnCancel().

{
  /* same than click on cancel button */
  ClickOnCancel();
}
void SMESHGUI_AddQuadraticElementDlg::DeactivateActiveDialog ( ) [private, slot]
void SMESHGUI_AddQuadraticElementDlg::displaySimulation ( ) [private]

Definition at line 1016 of file SMESHGUI_AddQuadraticElementDlg.cxx.

References SMESH_BelongToGeom.anIds, SMESH_Actor.GetObject(), IsValid(), myActor, myNbCorners, myReverseCB, mySimulation, myTable, myType, QUAD_EDGE, SMESH.TElementSimulation.SetPosition(), SMESH.TElementSimulation.SetVisibility(), and SMESH.UpdateView().

Referenced by onCellDoubleClicked(), onCellTextChange(), onReverse(), onTextChange(), and SelectionIntoArgument().

{
  if ( IsValid() )
  {
    SMESH::TElementSimulation::TVTKIds anIds;
    
    // Collect ids from the dialog
    int anID;
    bool ok;
    int aDisplayMode = VTK_SURFACE;
    
    if ( myType == QUAD_EDGE )
    {
      anIds.push_back( myActor->GetObject()->GetNodeVTKId( myTable->item(0, 0)->text().toInt() ) );
      anIds.push_back( myActor->GetObject()->GetNodeVTKId( myTable->item(0, 2)->text().toInt() ) );
      anID = myTable->item(0, 1)->text().toInt(&ok);
      if (!ok) anID = myTable->item(0, 0)->text().toInt();
      anIds.push_back( myActor->GetObject()->GetNodeVTKId(anID) );
      aDisplayMode = VTK_WIREFRAME;
    }
    else
    {
      for ( int row = 0; row < myNbCorners; row++ )
        anIds.push_back( myActor->GetObject()->GetNodeVTKId( myTable->item(row, 0)->text().toInt() ) );
      
      for ( int row = 0; row < myTable->rowCount(); row++ )
      {
        anID = myTable->item(row, 1)->text().toInt(&ok);
        if (!ok) {
          anID = myTable->item(row, 0)->text().toInt();
          aDisplayMode = VTK_WIREFRAME;
        }
        anIds.push_back( myActor->GetObject()->GetNodeVTKId(anID) );
      }
    }
    
    mySimulation->SetPosition(myActor,myType,anIds,aDisplayMode,myReverseCB->isChecked());
  }
  else
  {
    mySimulation->SetVisibility(false);
  }
  SMESH::UpdateView();
}
void SMESHGUI_AddQuadraticElementDlg::enterEvent ( QEvent *  ) [private]

Definition at line 1113 of file SMESHGUI_AddQuadraticElementDlg.cxx.

References ActivateThisDialog(), and GroupConstructors.

{
  if (GroupConstructors->isEnabled())
    return;
  ActivateThisDialog();
}
void SMESHGUI_AddQuadraticElementDlg::hideEvent ( QHideEvent *  ) [private]

Definition at line 1134 of file SMESHGUI_AddQuadraticElementDlg.cxx.

References ClickOnCancel().

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

Definition at line 571 of file SMESHGUI_AddQuadraticElementDlg.cxx.

References buttonApply, buttonCancel, buttonHelp, buttonOk, ClickOnApply(), ClickOnCancel(), ClickOnHelp(), ClickOnOk(), DeactivateActiveDialog(), SMESH.GetViewWindow(), GroupGroups, myActor, myCornerNodes, myHelpFileName, myNbCorners, myRadioButton1, myReverseCB, mySelectButton, mySelectionMgr, mySMESHGUI, myTable, myType, onCellDoubleClicked(), onCellTextChange(), onReverse(), onTextChange(), QUAD_EDGE, QUAD_HEXAHEDRON, QUAD_PENTAHEDRON, QUAD_PYRAMID, QUAD_QUADRANGLE, QUAD_TETRAHEDRON, QUAD_TRIANGLE, SelectionIntoArgument(), SMESHGUI.SetActiveDialogBox(), SetEditCorners(), and SMESH.SetPointRepresentation().

Referenced by SMESHGUI_AddQuadraticElementDlg().

{
  myRadioButton1->setChecked(true);
  mySMESHGUI->SetActiveDialogBox((QDialog*)this);
  
  /* reset "Add to group" control */
  GroupGroups->setChecked( false );

  myActor = 0;

  int aNumRows;

  switch (myType) {
  case QUAD_EDGE:
    aNumRows = 1;
    myNbCorners = 2;
    myHelpFileName = "adding_quadratic_elements_page.html#?"; //Adding_edges
    break;
  case QUAD_TRIANGLE:
    aNumRows = 3;
    myNbCorners = 3;
    myHelpFileName = "adding_quadratic_elements_page.html#?"; //Adding_triangles
    break;
  case QUAD_QUADRANGLE:
    aNumRows = 4;
    myNbCorners = 4;
    myHelpFileName = "adding_quadratic_elements_page.html#?"; //Adding_quadrangles
    break;
  case QUAD_TETRAHEDRON:
    aNumRows = 6;
    myNbCorners = 4;
    myHelpFileName = "adding_quadratic_elements_page.html#?"; //Adding_tetrahedrons
    break;
  case QUAD_PYRAMID:
    aNumRows = 8;
    myNbCorners = 5;
    myHelpFileName = "adding_quadratic_elements_page.html#?"; //Adding_pyramids
    break;
  case QUAD_PENTAHEDRON:
    aNumRows = 9;
    myNbCorners = 6;
    myHelpFileName = "adding_quadratic_elements_page.html#?"; //Adding_pentahedrons
    break; 
  case QUAD_HEXAHEDRON:
    aNumRows = 12;
    myNbCorners = 8;
    myHelpFileName = "adding_quadratic_elements_page.html#?"; //Adding_hexahedrons
    break;
  }
    
  myCornerNodes->setValidator(new SMESHGUI_IdValidator(this, myNbCorners));

  /* initialize table */
  myTable->setColumnCount(3);
  myTable->setRowCount(aNumRows);

  QStringList aColLabels;
  aColLabels.append(tr("SMESH_FIRST"));
  aColLabels.append(tr("SMESH_MIDDLE"));
  aColLabels.append(tr("SMESH_LAST"));
  myTable->setHorizontalHeaderLabels(aColLabels);
  
  for ( int col = 0; col < myTable->columnCount(); col++ )
    myTable->setColumnWidth(col, 80);

  //myTable->setColumnReadOnly(0, true); // VSR: TODO
  //myTable->setColumnReadOnly(2, true); // VSR: TODO

  myTable->setEnabled( false );
  
  for ( int row = 0; row < myTable->rowCount(); row++ )
  {
    myTable->setItem( row, 0, new QTableWidgetItem( "" ) );
    myTable->item( row, 0 )->setFlags(0);

    IdEditItem* anEditItem = new IdEditItem( "" );
    anEditItem->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEditable | Qt::ItemIsEnabled);
    myTable->setItem(row, 1, anEditItem);

    myTable->setItem( row, 2, new QTableWidgetItem( "" ) );
    myTable->item( row, 2 )->setFlags(0);
  }
  
  /* signals and slots connections */
  connect(mySelectButton, SIGNAL(clicked()), SLOT(SetEditCorners()));
  connect(mySelectionMgr, SIGNAL(currentSelectionChanged()), SLOT(SelectionIntoArgument()));
  connect(myTable,        SIGNAL(cellDoubleClicked(int, int)), SLOT(onCellDoubleClicked(int, int)));
  connect(myTable,        SIGNAL(cellChanged (int, int)), SLOT(onCellTextChange(int, int)));
  connect(myCornerNodes,  SIGNAL(textChanged(const QString&)), SLOT(onTextChange(const QString&)));
  connect(myReverseCB,    SIGNAL(stateChanged(int)), SLOT(onReverse(int)));

  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(mySMESHGUI, SIGNAL (SignalDeactivateActiveDialog()), SLOT(DeactivateActiveDialog()));
  connect(mySMESHGUI, SIGNAL (SignalStudyFrameChanged()), SLOT(ClickOnCancel()));
  connect(mySMESHGUI, SIGNAL (SignalCloseAllDialogs()), SLOT(ClickOnCancel()));

  // set selection mode
  SMESH::SetPointRepresentation(true);

  if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
    aViewWindow->SetSelectionMode( NodeSelection );

  SetEditCorners();
}
bool SMESHGUI_AddQuadraticElementDlg::IsValid ( ) [private]

Definition at line 1156 of file SMESHGUI_AddQuadraticElementDlg.cxx.

References SMDS_Mesh.FindNode(), SMESH_Actor.GetObject(), myActor, and myTable.

Referenced by ClickOnApply(), displaySimulation(), and updateButtons().

{
  SMDS_Mesh* aMesh = 0;
  if (myActor)
    aMesh = myActor->GetObject()->GetMesh();
  if (!aMesh)
    return false;

  bool ok;
  
  for ( int row = 0; row < myTable->rowCount(); row++ )
  {
    int anID =  myTable->item(row, 1)->text().toInt(&ok);
    if ( !ok )
      return false;
    
    const SMDS_MeshNode * aNode = aMesh->FindNode(anID);
    if ( !aNode )
      return false;
  }
  
  return true;
}
bool SMESHGUI_AddQuadraticElementDlg::isValid ( ) [private]

Definition at line 1299 of file SMESHGUI_AddQuadraticElementDlg.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_AddQuadraticElementDlg::keyPressEvent ( QKeyEvent *  e) [private]

Definition at line 1276 of file SMESHGUI_AddQuadraticElementDlg.cxx.

References ClickOnHelp().

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

  if ( e->key() == Qt::Key_F1 ) {
    e->accept();
    ClickOnHelp();
  }
}
void SMESHGUI_AddQuadraticElementDlg::onCellDoubleClicked ( int  theRow,
int  theCol 
) [private, slot]
void SMESHGUI_AddQuadraticElementDlg::onCellTextChange ( int  theRow,
int  theCol 
) [private, slot]
void SMESHGUI_AddQuadraticElementDlg::onReverse ( int  state) [private, slot]
void SMESHGUI_AddQuadraticElementDlg::onTextChange ( const QString &  theNewText) [private, slot]

Definition at line 868 of file SMESHGUI_AddQuadraticElementDlg.cxx.

References displaySimulation(), SMDS_Mesh.FindNode(), SMESH_Actor.GetObject(), SMESH.GetViewWindow(), myActor, myBusy, myCornerNodes, mySelector, mySimulation, mySMESHGUI, SMESH.TElementSimulation.SetVisibility(), updateButtons(), and UpdateTable().

Referenced by Init().

{
  if (myBusy) return;
  BusyLocker lock( myBusy );
  
  mySimulation->SetVisibility(false);

  // hilight entered nodes
  SMDS_Mesh* aMesh = 0;
  if (myActor)
    aMesh = myActor->GetObject()->GetMesh();

  if (aMesh) {
    TColStd_MapOfInteger newIndices;
    
    QStringList aListId = theNewText.split(" ", QString::SkipEmptyParts);
    bool allOk = true;
    for (int i = 0; i < aListId.count(); i++) {
      if ( const SMDS_MeshNode * n = aMesh->FindNode( aListId[ i ].toInt() ) )
      {
        newIndices.Add( n->GetID() );
      }
      else
      {
        allOk = false;
        break;
      }
    }
    
    mySelector->AddOrRemoveIndex( myActor->getIO(), newIndices, false );
    if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
      aViewWindow->highlight( myActor->getIO(), true, true );
    
    if ( sender() == myCornerNodes )
      UpdateTable( allOk );
  }
  
  updateButtons();
  displaySimulation();
}
void SMESHGUI_AddQuadraticElementDlg::SelectionIntoArgument ( ) [private, slot]

Definition at line 913 of file SMESHGUI_AddQuadraticElementDlg.cxx.

References SMESH_controls.aGroup, ComboBox_GroupName, displaySimulation(), EDGE, FACE, SMESH.FindActorByEntry(), SMESH.GetMeshByIO(), SMESH.GetNameOfSelectedNodes(), GroupButtons, Handle(), myActor, myBusy, myCornerNodes, myEntry, myGroups, myIsEditCorners, myMesh, mySelectionMgr, mySelector, mySimulation, myTable, myType, QUAD_EDGE, QUAD_HEXAHEDRON, QUAD_PENTAHEDRON, QUAD_PYRAMID, QUAD_QUADRANGLE, QUAD_TETRAHEDRON, QUAD_TRIANGLE, SMESH.TElementSimulation.SetVisibility(), updateButtons(), UpdateTable(), and VOLUME.

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

{
  if (myBusy) return;
  BusyLocker lock( myBusy );
  
  QString aCurrentEntry = myEntry;

  if ( myIsEditCorners )
  {
    // clear
    myActor = 0;
    
    myCornerNodes->setText("");
    
    if (!GroupButtons->isEnabled()) // inactive
      return;
    
    mySimulation->SetVisibility(false);
      
    // get selected mesh
    SALOME_ListIO aList;
    mySelectionMgr->selectedObjects(aList,SVTK_Viewer::Type());
    
    if (aList.Extent() != 1)
    {
      UpdateTable();
      updateButtons();
      return;
    }
      
    Handle(SALOME_InteractiveObject) anIO = aList.First();
    myEntry = anIO->getEntry();
    myMesh = SMESH::GetMeshByIO(anIO);
    if (myMesh->_is_nil()) {
      updateButtons();
      return;
    }
      
    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;
    }
    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() == anElementType ) {
        QString aGroupName( aGroup->GetName() );
        if ( !aGroupName.isEmpty() ) {
          myGroups.append(SMESH::SMESH_GroupBase::_duplicate(aGroup));
          ComboBox_GroupName->addItem( aGroupName );
        }
      }
    }
  }
  
  if (!myActor) {
    updateButtons();
    return;
  }
  
  // get selected nodes
  QString aString = "";
  int nbNodes = SMESH::GetNameOfSelectedNodes(mySelector,myActor->getIO(),aString);
  
  if ( myIsEditCorners )
  {
    myCornerNodes->setText(aString);
    
    UpdateTable();
  }
  else if ( myTable->isEnabled() && nbNodes == 1 )
  {
    int theRow = myTable->currentRow(), theCol = myTable->currentColumn();
    if ( theCol == 1 )
      myTable->item(theRow, 1)->setText(aString);
  }
  
  updateButtons();
  displaySimulation();
}
void SMESHGUI_AddQuadraticElementDlg::SetEditCorners ( ) [private, slot]
void SMESHGUI_AddQuadraticElementDlg::updateButtons ( ) [private]

Definition at line 1288 of file SMESHGUI_AddQuadraticElementDlg.cxx.

References buttonApply, buttonOk, and IsValid().

Referenced by ClickOnApply(), onCellDoubleClicked(), onCellTextChange(), onReverse(), onTextChange(), SelectionIntoArgument(), and SetEditCorners().

{
  bool valid = IsValid();
  buttonOk->setEnabled( valid );
  buttonApply->setEnabled( valid );
}
void SMESHGUI_AddQuadraticElementDlg::UpdateTable ( bool  theConersValidity = true) [private]

Definition at line 1184 of file SMESHGUI_AddQuadraticElementDlg.cxx.

References FirstEdgeIds, FirstHexahedronIds, FirstPentahedronIds, FirstPyramidIds, FirstQuadrangleIds, FirstTetrahedronIds, FirstTriangleIds, LastEdgeIds, LastHexahedronIds, LastPentahedronIds, LastPyramidIds, LastQuadrangleIds, LastTetrahedronIds, LastTriangleIds, myCornerNodes, myNbCorners, myTable, myType, QUAD_EDGE, QUAD_HEXAHEDRON, QUAD_PENTAHEDRON, QUAD_PYRAMID, QUAD_QUADRANGLE, QUAD_TETRAHEDRON, and QUAD_TRIANGLE.

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

{
  QStringList aListCorners = myCornerNodes->text().split(" ", QString::SkipEmptyParts);
  
  if ( aListCorners.count() == myNbCorners && theConersValidity )
  {
    myTable->setEnabled( true );
    
    // clear the Middle column 
    for ( int row = 0; row < myTable->rowCount(); row++ )
      myTable->item( row, 1 )->setText("");
    
    int* aFirstColIds;
    int* aLastColIds;
    
    switch (myType) {
    case QUAD_EDGE:
      aFirstColIds = FirstEdgeIds;
      aLastColIds  = LastEdgeIds;
      break;
    case QUAD_TRIANGLE:
      aFirstColIds = FirstTriangleIds;
      aLastColIds  = LastTriangleIds;
      break;
    case QUAD_QUADRANGLE:
      aFirstColIds = FirstQuadrangleIds;
      aLastColIds  = LastQuadrangleIds;
      break;
    case QUAD_TETRAHEDRON:
      aFirstColIds = FirstTetrahedronIds;
      aLastColIds  = LastTetrahedronIds;
      break;
    case QUAD_PYRAMID:
      aFirstColIds = FirstPyramidIds;
      aLastColIds  = LastPyramidIds;
      break;
    case QUAD_PENTAHEDRON:
      aFirstColIds = FirstPentahedronIds;
      aLastColIds  = LastPentahedronIds;
      break; 
    case QUAD_HEXAHEDRON:
      aFirstColIds = FirstHexahedronIds;
      aLastColIds  = LastHexahedronIds;
      break;
    }
    
    // fill the First and the Last columns
    for (int i = 0, iEnd = myTable->rowCount(); i < iEnd; i++)
      myTable->item( i, 0 )->setText( aListCorners[ aFirstColIds[i] ] );
    
    for (int i = 0, iEnd = myTable->rowCount(); i < iEnd; i++)
      myTable->item( i, 2 )->setText( aListCorners[ aLastColIds[i] ] );
  }
  else
  {
    // clear table
    for ( int row = 0; row < myTable->rowCount(); row++ )
      for ( int col = 0; col < myTable->columnCount(); col++ )
        if ( QTableWidgetItem* aTWI = myTable->item(row, col) ) aTWI->setText("");
    
    myTable->setEnabled( false );
  }
}

Field Documentation

Definition at line 118 of file SMESHGUI_AddQuadraticElementDlg.h.

Referenced by Init(), and SMESHGUI_AddQuadraticElementDlg().

Definition at line 120 of file SMESHGUI_AddQuadraticElementDlg.h.

Referenced by Init(), and SMESHGUI_AddQuadraticElementDlg().

Definition at line 97 of file SMESHGUI_AddQuadraticElementDlg.h.

Referenced by SelectionIntoArgument().

Definition at line 98 of file SMESHGUI_AddQuadraticElementDlg.h.

Referenced by ClickOnApply(), and SelectionIntoArgument().

Definition at line 122 of file SMESHGUI_AddQuadraticElementDlg.h.

Referenced by ClickOnHelp(), and Init().

SMESH::SMESH_Mesh_var SMESHGUI_AddQuadraticElementDlg.myMesh [private]

Definition at line 94 of file SMESHGUI_AddQuadraticElementDlg.h.

Referenced by ClickOnApply(), and SelectionIntoArgument().

Definition at line 104 of file SMESHGUI_AddQuadraticElementDlg.h.

Referenced by Init(), and SMESHGUI_AddQuadraticElementDlg().

Definition at line 108 of file SMESHGUI_AddQuadraticElementDlg.h.

Referenced by Init(), and SMESHGUI_AddQuadraticElementDlg().

LightApp_SelectionMgr* SMESHGUI_AddQuadraticElementDlg.mySelectionMgr [private]

Definition at line 113 of file SMESHGUI_AddQuadraticElementDlg.h.

Referenced by SMESHGUI_AddQuadraticElementDlg().

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