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

SMESHGUI_SingleEditDlg Class Reference

Class : SMESHGUI_SingleEditDlg Description : Base class for dialogs of diagonal inversion and union of two neighboring triangles. More...

#include <SMESHGUI_SingleEditDlg.h>

Inheritance diagram for SMESHGUI_SingleEditDlg:
Inheritance graph
[legend]

Public Member Functions

 SMESHGUI_SingleEditDlg (SMESHGUI *)
 Class : SMESHGUI_SingleEditDlg Description : Inversion of the diagonal of a pseudo-quadrangle formed by 2 neighboring triangles with 1 common edge.
virtual ~SMESHGUI_SingleEditDlg ()
void Init ()

Protected Slots

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

Protected Member Functions

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
virtual bool process (SMESH::SMESH_MeshEditor_ptr, const int, const int)=0

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_SingleEditDlg Description : Base class for dialogs of diagonal inversion and union of two neighboring triangles.

Definition at line 52 of file SMESHGUI_SingleEditDlg.h.


Constructor & Destructor Documentation

SMESHGUI_SingleEditDlg::SMESHGUI_SingleEditDlg ( SMESHGUI theModule)

Class : SMESHGUI_SingleEditDlg Description : Inversion of the diagonal of a pseudo-quadrangle formed by 2 neighboring triangles with 1 common edge.

Definition at line 94 of file SMESHGUI_SingleEditDlg.cxx.

References batchmode_smesh.Init(), MARGIN, and SPACING.

  : QDialog(SMESH::GetDesktop(theModule)),
    mySelector(SMESH::GetViewWindow(theModule)->GetSelector()),
    mySelectionMgr(SMESH::GetSelectionMgr(theModule)),
    mySMESHGUI(theModule)
{
  setModal(false);

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

  QWidget* aMainFrame = createMainFrame  (this);
  QWidget* aBtnFrame  = createButtonFrame(this);

  aDlgLay->addWidget(aMainFrame);
  aDlgLay->addWidget(aBtnFrame);

  Init();
}
SMESHGUI_SingleEditDlg::~SMESHGUI_SingleEditDlg ( ) [virtual]

Definition at line 202 of file SMESHGUI_SingleEditDlg.cxx.

{
}

Member Function Documentation

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

Definition at line 465 of file SMESHGUI_SingleEditDlg.cxx.

References onClose().

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

Definition at line 145 of file SMESHGUI_SingleEditDlg.cxx.

References MARGIN, myApplyBtn, myCloseBtn, myHelpBtn, 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]

Definition at line 119 of file SMESHGUI_SingleEditDlg.cxx.

References SMESH.GetResourceMgr(), MARGIN, myEdge, 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]

Definition at line 451 of file SMESHGUI_SingleEditDlg.cxx.

References SMESHGUI.EmitSignalDeactivateDialog(), SMESH.GetViewWindow(), and 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]

Definition at line 183 of file SMESHGUI_SingleEditDlg.cxx.

Referenced by isValid(), onApply(), and 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]

Definition at line 474 of file SMESHGUI_SingleEditDlg.cxx.

References onClose().

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

Definition at line 210 of file SMESHGUI_SingleEditDlg.cxx.

References SMESH.GetViewWindow(), myActor, myApplyBtn, myBusy, myCloseBtn, myEdge, myHelpBtn, myOkBtn, mySelectionMgr, mySMESHGUI, onApply(), onClose(), onDeactivate(), onHelp(), onOk(), onSelectionDone(), 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]

Definition at line 173 of file SMESHGUI_SingleEditDlg.cxx.

References getNodeIds(), and myEdge.

Referenced by onApply().

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

Definition at line 529 of file SMESHGUI_SingleEditDlg.cxx.

References onHelp().

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

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

Definition at line 484 of file SMESHGUI_SingleEditDlg.cxx.

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

Referenced by Init(), and 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]

Definition at line 254 of file SMESHGUI_SingleEditDlg.cxx.

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

Referenced by closeEvent(), hideEvent(), Init(), and 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]

Definition at line 442 of file SMESHGUI_SingleEditDlg.cxx.

Referenced by Init().

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

Definition at line 269 of file SMESHGUI_SingleEditDlg.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_SingleEditDlg::onOk ( ) [protected, slot]

Definition at line 244 of file SMESHGUI_SingleEditDlg.cxx.

References onApply(), and onClose().

Referenced by Init().

{
  if (onApply())
    onClose();
}
void SMESHGUI_SingleEditDlg::onSelectionDone ( ) [protected, slot]

Definition at line 396 of file SMESHGUI_SingleEditDlg.cxx.

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

Referenced by Init(), and 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]

Definition at line 332 of file SMESHGUI_SingleEditDlg.cxx.

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

Referenced by 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 );
    }
  }
}
virtual bool SMESHGUI_SingleEditDlg.process ( SMESH::SMESH_MeshEditor_ptr  ,
const int  ,
const int   
) [protected, pure virtual]

Field Documentation

Definition at line 91 of file SMESHGUI_SingleEditDlg.h.

Referenced by Init(), onSelectionDone(), and onTextChange().

QPushButton* SMESHGUI_SingleEditDlg.myApplyBtn [protected]

Definition at line 87 of file SMESHGUI_SingleEditDlg.h.

Referenced by createButtonFrame(), Init(), onSelectionDone(), and onTextChange().

Definition at line 85 of file SMESHGUI_SingleEditDlg.h.

Referenced by Init(), onSelectionDone(), and onTextChange().

QPushButton* SMESHGUI_SingleEditDlg.myCloseBtn [protected]

Definition at line 88 of file SMESHGUI_SingleEditDlg.h.

Referenced by createButtonFrame(), and Init().

QLineEdit* SMESHGUI_SingleEditDlg.myEdge [protected]
QPushButton* SMESHGUI_SingleEditDlg.myHelpBtn [protected]

Definition at line 89 of file SMESHGUI_SingleEditDlg.h.

Referenced by createButtonFrame(), and Init().

Definition at line 97 of file SMESHGUI_SingleEditDlg.h.

Referenced by onHelp().

QPushButton* SMESHGUI_SingleEditDlg.myOkBtn [protected]

Definition at line 86 of file SMESHGUI_SingleEditDlg.h.

Referenced by createButtonFrame(), Init(), onSelectionDone(), and onTextChange().

LightApp_SelectionMgr* SMESHGUI_SingleEditDlg.mySelectionMgr [protected]

Definition at line 93 of file SMESHGUI_SingleEditDlg.h.

Referenced by Init(), onApply(), onClose(), onSelectionDone(), and onTextChange().

SVTK_Selector* SMESHGUI_SingleEditDlg.mySelector [protected]

Definition at line 94 of file SMESHGUI_SingleEditDlg.h.

Referenced by onApply(), onSelectionDone(), and onTextChange().

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