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

SMESHGUI_UnionOfTwoTrianglesDlg Class Reference

Class : SMESHGUI_UnionOfTwoTrianglesDlg Description : Construction of a quadrangle by deletion of the common border of 2 neighboring triangles. More...

#include <SMESHGUI_SingleEditDlg.h>

Inheritance diagram for SMESHGUI_UnionOfTwoTrianglesDlg:
Inheritance graph
[legend]

Public Member Functions

 SMESHGUI_UnionOfTwoTrianglesDlg (SMESHGUI *)
 Class : SMESHGUI_UnionOfTwoTrianglesDlg Description : Construction of a quadrangle by deletion of the common border of 2 neighboring triangles.
virtual ~SMESHGUI_UnionOfTwoTrianglesDlg ()
void Init ()

Protected Slots

void onOk ()
virtual bool onApply ()
void onClose ()
void onHelp ()
void onDeactivate ()
void onSelectionDone ()
void onTextChange (const QString &)

Protected Member Functions

virtual bool process (SMESH::SMESH_MeshEditor_ptr, const int, const int)
void closeEvent (QCloseEvent *)
void enterEvent (QEvent *)
void hideEvent (QHideEvent *)
void keyPressEvent (QKeyEvent *)
QWidgetcreateButtonFrame (QWidget *)
QWidgetcreateMainFrame (QWidget *)
bool isValid (const bool) const
bool getNodeIds (const QString &, int &, int &) const

Protected Attributes

bool myBusy
QPushButton * myOkBtn
QPushButton * myApplyBtn
QPushButton * myCloseBtn
QPushButton * myHelpBtn
QLineEdit * myEdge
SMESH_ActormyActor
LightApp_SelectionMgr * mySelectionMgr
SVTK_Selector * mySelector
SMESHGUImySMESHGUI
QString myHelpFileName

Detailed Description

Class : SMESHGUI_UnionOfTwoTrianglesDlg Description : Construction of a quadrangle by deletion of the common border of 2 neighboring triangles.

Definition at line 122 of file SMESHGUI_SingleEditDlg.h.


Constructor & Destructor Documentation

SMESHGUI_UnionOfTwoTrianglesDlg::SMESHGUI_UnionOfTwoTrianglesDlg ( SMESHGUI theModule)

Class : SMESHGUI_UnionOfTwoTrianglesDlg Description : Construction of a quadrangle by deletion of the common border of 2 neighboring triangles.

Definition at line 572 of file SMESHGUI_SingleEditDlg.cxx.

: SMESHGUI_SingleEditDlg(theModule)
{
  setWindowTitle(tr("CAPTION"));
  myHelpFileName = "uniting_two_triangles_page.html";
}
SMESHGUI_UnionOfTwoTrianglesDlg::~SMESHGUI_UnionOfTwoTrianglesDlg ( ) [virtual]

Definition at line 579 of file SMESHGUI_SingleEditDlg.cxx.

{
}

Member Function Documentation

void SMESHGUI_SingleEditDlg::closeEvent ( QCloseEvent *  ) [protected, inherited]

Definition at line 465 of file SMESHGUI_SingleEditDlg.cxx.

References SMESHGUI_SingleEditDlg.onClose().

{
  onClose();
}
QWidget * SMESHGUI_SingleEditDlg::createButtonFrame ( QWidget theParent) [protected, inherited]

Definition at line 145 of file SMESHGUI_SingleEditDlg.cxx.

References MARGIN, SMESHGUI_SingleEditDlg.myApplyBtn, SMESHGUI_SingleEditDlg.myCloseBtn, SMESHGUI_SingleEditDlg.myHelpBtn, SMESHGUI_SingleEditDlg.myOkBtn, and SPACING.

{
  QGroupBox* aFrame = new QGroupBox(theParent);

  myOkBtn     = new QPushButton(tr("SMESH_BUT_APPLY_AND_CLOSE"), aFrame);
  myApplyBtn  = new QPushButton(tr("SMESH_BUT_APPLY"), aFrame);
  myCloseBtn  = new QPushButton(tr("SMESH_BUT_CLOSE"), aFrame);
  myHelpBtn   = new QPushButton(tr("SMESH_BUT_HELP"),  aFrame);

  QHBoxLayout* aLay = new QHBoxLayout(aFrame);
  aLay->setMargin(MARGIN);
  aLay->setSpacing(SPACING);

  aLay->addWidget(myOkBtn);
  aLay->addSpacing(10);
  aLay->addWidget(myApplyBtn);
  aLay->addSpacing(10);
  aLay->addStretch();
  aLay->addWidget(myCloseBtn);
  aLay->addWidget(myHelpBtn);

  return aFrame;
}
QWidget * SMESHGUI_SingleEditDlg::createMainFrame ( QWidget theParent) [protected, inherited]

Definition at line 119 of file SMESHGUI_SingleEditDlg.cxx.

References SMESH.GetResourceMgr(), MARGIN, SMESHGUI_SingleEditDlg.myEdge, SMESHGUI_SingleEditDlg.mySMESHGUI, and SPACING.

{
  QGroupBox* aMainGrp = new QGroupBox(tr("EDGE_BETWEEN"), theParent);
  QHBoxLayout* aLay = new QHBoxLayout(aMainGrp);
  aLay->setMargin(MARGIN);
  aLay->setSpacing(SPACING);

  QPixmap aPix (SMESH::GetResourceMgr( mySMESHGUI )->loadPixmap("SMESH", tr("ICON_SELECT")));

  QLabel* aLab = new QLabel(tr("SMESH_EDGE"), aMainGrp);
  QPushButton* aBtn = new QPushButton(aMainGrp);
  aBtn->setIcon(aPix);
  myEdge = new QLineEdit(aMainGrp);
  myEdge->setValidator(new QRegExpValidator(QRegExp("[\\d]*-[\\d]*"), this));

  aLay->addWidget(aLab);
  aLay->addWidget(aBtn);
  aLay->addWidget(myEdge);

  return aMainGrp;
}
void SMESHGUI_SingleEditDlg::enterEvent ( QEvent *  ) [protected, inherited]

Definition at line 451 of file SMESHGUI_SingleEditDlg.cxx.

References SMESHGUI.EmitSignalDeactivateDialog(), SMESH.GetViewWindow(), and SMESHGUI_SingleEditDlg.mySMESHGUI.

{
  if (!isEnabled()) {
    mySMESHGUI->EmitSignalDeactivateDialog();
    if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
      aViewWindow->SetSelectionMode(EdgeOfCellSelection);
    setEnabled(true);
  }
}
bool SMESHGUI_SingleEditDlg::getNodeIds ( const QString &  theStr,
int theId1,
int theId2 
) const [protected, inherited]

Definition at line 183 of file SMESHGUI_SingleEditDlg.cxx.

Referenced by SMESHGUI_SingleEditDlg.isValid(), SMESHGUI_SingleEditDlg.onApply(), and SMESHGUI_SingleEditDlg.onTextChange().

{
  if (!theStr.contains('-'))
    return false;

  bool ok1, ok2;
  QString str1 = theStr.section('-', 0, 0, QString::SectionSkipEmpty);
  QString str2 = theStr.section('-', 1, 1, QString::SectionSkipEmpty);
  theId1 = str1.toInt(&ok1);
  theId2 = str2.toInt(&ok2);

  return ok1 & ok2;
}
void SMESHGUI_SingleEditDlg::hideEvent ( QHideEvent *  ) [protected, inherited]

Definition at line 474 of file SMESHGUI_SingleEditDlg.cxx.

References SMESHGUI_SingleEditDlg.onClose().

{
  if (!isMinimized())
    onClose();
}
void SMESHGUI_SingleEditDlg::Init ( ) [inherited]

Definition at line 210 of file SMESHGUI_SingleEditDlg.cxx.

References SMESH.GetViewWindow(), SMESHGUI_SingleEditDlg.myActor, SMESHGUI_SingleEditDlg.myApplyBtn, SMESHGUI_SingleEditDlg.myBusy, SMESHGUI_SingleEditDlg.myCloseBtn, SMESHGUI_SingleEditDlg.myEdge, SMESHGUI_SingleEditDlg.myHelpBtn, SMESHGUI_SingleEditDlg.myOkBtn, SMESHGUI_SingleEditDlg.mySelectionMgr, SMESHGUI_SingleEditDlg.mySMESHGUI, SMESHGUI_SingleEditDlg.onApply(), SMESHGUI_SingleEditDlg.onClose(), SMESHGUI_SingleEditDlg.onDeactivate(), SMESHGUI_SingleEditDlg.onHelp(), SMESHGUI_SingleEditDlg.onOk(), SMESHGUI_SingleEditDlg.onSelectionDone(), SMESHGUI_SingleEditDlg.onTextChange(), and SMESHGUI.SetActiveDialogBox().

{
  mySMESHGUI->SetActiveDialogBox((QDialog*)this);
  myBusy = false;
  myActor = 0;

  // main buttons
  connect(myOkBtn,    SIGNAL(clicked()), SLOT(onOk()));
  connect(myCloseBtn, SIGNAL(clicked()), SLOT(onClose()));
  connect(myApplyBtn, SIGNAL(clicked()), SLOT(onApply()));
  connect(myHelpBtn,  SIGNAL(clicked()), SLOT(onHelp()));

  // selection and SMESHGUI
  connect(mySelectionMgr, SIGNAL(currentSelectionChanged()), SLOT(onSelectionDone()));
  connect(mySMESHGUI, SIGNAL(SignalDeactivateActiveDialog()), SLOT(onDeactivate()));
  connect(mySMESHGUI, SIGNAL(SignalCloseAllDialogs()), SLOT(onClose()));
  connect(myEdge, SIGNAL(textChanged(const QString&)), SLOT(onTextChange(const QString&)));

  myOkBtn->setEnabled(false);
  myApplyBtn->setEnabled(false);
  setEnabled(true);

  // set selection mode
  if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
    aViewWindow->SetSelectionMode(EdgeOfCellSelection);

  onSelectionDone();
}
bool SMESHGUI_SingleEditDlg::isValid ( const bool  theMess) const [protected, inherited]

Definition at line 173 of file SMESHGUI_SingleEditDlg.cxx.

References SMESHGUI_SingleEditDlg.getNodeIds(), and SMESHGUI_SingleEditDlg.myEdge.

Referenced by SMESHGUI_SingleEditDlg.onApply().

{
  int id1, id2;
  return getNodeIds(myEdge->text(), id1, id2);
}
void SMESHGUI_SingleEditDlg::keyPressEvent ( QKeyEvent *  e) [protected, inherited]

Definition at line 529 of file SMESHGUI_SingleEditDlg.cxx.

References SMESHGUI_SingleEditDlg.onHelp().

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

  if ( e->key() == Qt::Key_F1 ) {
    e->accept();
    onHelp();
  }
}
bool SMESHGUI_SingleEditDlg::onApply ( ) [protected, virtual, slot, inherited]

Definition at line 484 of file SMESHGUI_SingleEditDlg.cxx.

References SMESH.GetDesktop(), SMESH.GetMeshByIO(), SMESHGUI_SingleEditDlg.getNodeIds(), SMESHGUI.isActiveStudyLocked(), SMESHGUI_SingleEditDlg.isValid(), SMESHGUI.Modified(), SMESHGUI_SingleEditDlg.myEdge, SMESHGUI_SingleEditDlg.mySelectionMgr, SMESHGUI_SingleEditDlg.mySelector, SMESHGUI_SingleEditDlg.mySMESHGUI, SMESHGUI_SingleEditDlg.onSelectionDone(), SMESHGUI_SingleEditDlg.process(), and SMESH.UpdateView().

Referenced by SMESHGUI_SingleEditDlg.Init(), and SMESHGUI_SingleEditDlg.onOk().

{
  if (mySMESHGUI->isActiveStudyLocked())
    return false;
  // verify validity of input data
  if (!isValid(true))
    return false;

  // get mesh, actor and nodes
  SALOME_ListIO aList;
  mySelectionMgr->selectedObjects(aList);

  SMESH::SMESH_Mesh_var aMesh = SMESH::GetMeshByIO(aList.First());

  if (aMesh->_is_nil()) {
    SUIT_MessageBox::information(SMESH::GetDesktop(mySMESHGUI), 
                                 tr("SMESH_ERROR"),
                                 tr("SMESHG_NO_MESH"));
    return false;
  }

  SMESH::SMESH_MeshEditor_var aMeshEditor = aMesh->GetMeshEditor();
  int anId1= 0, anId2 = 0;
  if (aMeshEditor->_is_nil() || !getNodeIds(myEdge->text(), anId1, anId2))
    return false;

  // perform operation
  bool aResult = process(aMeshEditor.in(), anId1, anId2);

  // update actor
  if (aResult) {
    mySelector->ClearIndex();
    mySelectionMgr->setSelectedObjects(aList, false);
    onSelectionDone();
    SMESH::UpdateView();
    SMESHGUI::Modified();
  }

  return aResult;
}
void SMESHGUI_SingleEditDlg::onClose ( ) [protected, slot, inherited]

Definition at line 254 of file SMESHGUI_SingleEditDlg.cxx.

References SMESH.GetViewWindow(), SMESHGUI_SingleEditDlg.mySelectionMgr, SMESHGUI_SingleEditDlg.mySMESHGUI, and SMESHGUI.ResetState().

Referenced by SMESHGUI_SingleEditDlg.closeEvent(), SMESHGUI_SingleEditDlg.hideEvent(), SMESHGUI_SingleEditDlg.Init(), and SMESHGUI_SingleEditDlg.onOk().

{
  if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
    aViewWindow->SetSelectionMode(ActorSelection);
  //mySelectionMgr->clearSelected();
  disconnect(mySelectionMgr, 0, this, 0);
  disconnect(mySMESHGUI, 0, this, 0);
  mySMESHGUI->ResetState();
  reject();
}
void SMESHGUI_SingleEditDlg::onDeactivate ( ) [protected, slot, inherited]

Definition at line 442 of file SMESHGUI_SingleEditDlg.cxx.

Referenced by SMESHGUI_SingleEditDlg.Init().

{
  setEnabled(false);
}
void SMESHGUI_SingleEditDlg::onHelp ( ) [protected, slot, inherited]

Definition at line 269 of file SMESHGUI_SingleEditDlg.cxx.

References SMESHGUI_SingleEditDlg.myHelpFileName, and SMESHGUI_SingleEditDlg.mySMESHGUI.

Referenced by SMESHGUI_SingleEditDlg.Init(), and SMESHGUI_SingleEditDlg.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_SingleEditDlg::onOk ( ) [protected, slot, inherited]
void SMESHGUI_SingleEditDlg::onSelectionDone ( ) [protected, slot, inherited]

Definition at line 396 of file SMESHGUI_SingleEditDlg.cxx.

References SMESH.FindActorByEntry(), findTriangles(), SMESH.GetEdgeNodes(), SMESH_Actor.GetObject(), Handle(), SMESHGUI_SingleEditDlg.myActor, SMESHGUI_SingleEditDlg.myApplyBtn, SMESHGUI_SingleEditDlg.myBusy, SMESHGUI_SingleEditDlg.myEdge, SMESHGUI_SingleEditDlg.myOkBtn, SMESHGUI_SingleEditDlg.mySelectionMgr, and SMESHGUI_SingleEditDlg.mySelector.

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

{
  if (myBusy) return;
  BusyLocker lock(myBusy);

  int anId1 = 0, anId2 = 0;

  myOkBtn->setEnabled(false);
  myApplyBtn->setEnabled(false);

  SALOME_ListIO aList;
  mySelectionMgr->selectedObjects(aList);

  if (aList.Extent() != 1) {
    myEdge->clear();
    return;
  }

  Handle(SALOME_InteractiveObject) anIO = aList.First();
  myActor = SMESH::FindActorByEntry(anIO->getEntry());
  if(myActor){
    TVisualObjPtr aVisualObj = myActor->GetObject();
    if(SMDS_Mesh* aMesh = aVisualObj->GetMesh())
    {
      const SMDS_MeshElement* tria[2];
      if( SMESH::GetEdgeNodes( mySelector, aVisualObj, anId1, anId2 ) >= 1 &&
          findTriangles( aMesh->FindNode( anId1 ), aMesh->FindNode( anId2 ), tria[0],tria[1] ) )
      {
        QString aText = QString("%1-%2").arg(anId1).arg(anId2);
        myEdge->setText(aText);
        
        myOkBtn->setEnabled(true);
        myApplyBtn->setEnabled(true);
      }
      else
      {
        myEdge->clear();
      }
    }
  }
}
void SMESHGUI_SingleEditDlg::onTextChange ( const QString &  theNewText) [protected, slot, inherited]

Definition at line 332 of file SMESHGUI_SingleEditDlg.cxx.

References findTriangles(), SMDS_MeshElement.GetID(), SMESHGUI_SingleEditDlg.getNodeIds(), SMESH_Actor.GetObject(), SMESH.GetViewWindow(), Handle(), SMESHGUI_SingleEditDlg.myActor, SMESHGUI_SingleEditDlg.myApplyBtn, SMESHGUI_SingleEditDlg.myBusy, SMESHGUI_SingleEditDlg.myEdge, SMESHGUI_SingleEditDlg.myOkBtn, SMESHGUI_SingleEditDlg.mySelectionMgr, SMESHGUI_SingleEditDlg.mySelector, SMESHGUI_SingleEditDlg.mySMESHGUI, and SMDS_MeshElement.nodesIterator().

Referenced by SMESHGUI_SingleEditDlg.Init().

{
  if (myBusy) return;
  BusyLocker lock(myBusy);

  myOkBtn->setEnabled(false);
  myApplyBtn->setEnabled(false);

  // hilight entered edge
  if(myActor){
    if(SMDS_Mesh* aMesh = myActor->GetObject()->GetMesh()){
      Handle(SALOME_InteractiveObject) anIO = myActor->getIO();
      SALOME_ListIO aList;
      aList.Append(anIO);
      mySelectionMgr->setSelectedObjects(aList,false);
      
      TColStd_IndexedMapOfInteger selectedIndices;
      TColStd_MapOfInteger newIndices;
      mySelector->GetIndex(anIO,selectedIndices);

      int id1, id2;
      if ( !getNodeIds(myEdge->text(), id1, id2) )
        return;

      const SMDS_MeshNode* aNode1 = aMesh->FindNode( id1 );
      const SMDS_MeshNode* aNode2 = aMesh->FindNode( id2 );

      if ( !aNode1 || !aNode2 || aNode1 == aNode2 )
        return;

      // find a triangle and an edge index
      const SMDS_MeshElement* tria1;
      const SMDS_MeshElement* tria2;

      if ( findTriangles(aNode1,aNode2,tria1,tria2) )
      {
        newIndices.Add(tria1->GetID());

        const SMDS_MeshNode* a3Nodes[3];
        SMDS_ElemIteratorPtr it;
        int edgeInd = 2, i;
        for (i = 0, it = tria1->nodesIterator(); it->more(); i++) {
          a3Nodes[ i ] = static_cast<const SMDS_MeshNode*>(it->next());
          if (i > 0 && ( (a3Nodes[ i ] == aNode1 && a3Nodes[ i - 1] == aNode2) ||
                         (a3Nodes[ i ] == aNode2 && a3Nodes[ i - 1] == aNode1) ) ) {
            edgeInd = i - 1;
            break;
          }
        }
        newIndices.Add(-edgeInd-1);
        
        myOkBtn->setEnabled(true);
        myApplyBtn->setEnabled(true);
      }
      mySelector->AddOrRemoveIndex(anIO,newIndices, false);
      SMESH::GetViewWindow(mySMESHGUI)->highlight( anIO, true, true );
    }
  }
}
bool SMESHGUI_UnionOfTwoTrianglesDlg::process ( SMESH::SMESH_MeshEditor_ptr  theMeshEditor,
const int  theId1,
const int  theId2 
) [protected, virtual]

Implements SMESHGUI_SingleEditDlg.

Definition at line 583 of file SMESHGUI_SingleEditDlg.cxx.

{
  return theMeshEditor->DeleteDiag(theId1, theId2);
}

Field Documentation

QPushButton* SMESHGUI_SingleEditDlg.myApplyBtn [protected, inherited]
bool SMESHGUI_SingleEditDlg.myBusy [protected, inherited]
QPushButton* SMESHGUI_SingleEditDlg.myCloseBtn [protected, inherited]
QLineEdit* SMESHGUI_SingleEditDlg.myEdge [protected, inherited]
QPushButton* SMESHGUI_SingleEditDlg.myHelpBtn [protected, inherited]
QString SMESHGUI_SingleEditDlg.myHelpFileName [protected, inherited]

Definition at line 97 of file SMESHGUI_SingleEditDlg.h.

Referenced by SMESHGUI_SingleEditDlg.onHelp().

QPushButton* SMESHGUI_SingleEditDlg.myOkBtn [protected, inherited]
LightApp_SelectionMgr* SMESHGUI_SingleEditDlg.mySelectionMgr [protected, inherited]
SVTK_Selector* SMESHGUI_SingleEditDlg.mySelector [protected, inherited]
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