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

SMESHGUI_FilterDlg Class Reference

Class : SMESHGUI_FilterDlg Description : Dialog to specify filters for VTK viewer. More...

#include <SMESHGUI_FilterDlg.h>

Inheritance diagram for SMESHGUI_FilterDlg:
Inheritance graph
[legend]

Signals

void Accepted ()

Public Member Functions

 SMESHGUI_FilterDlg (SMESHGUI *, const QList< int > &)
 SMESHGUI_FilterDlg (SMESHGUI *, const int)
virtual ~SMESHGUI_FilterDlg ()
void Init (const QList< int > &)
void Init (const int)
void SetSelection ()
void SetMesh (SMESH::SMESH_Mesh_var)
void SetSourceWg (QWidget *, const bool initOnApply=true)

Static Public Member Functions

static SMESH::Filter::Criterion createCriterion ()

Private Types

enum  { Mesh, Selection, Dialog, None }
enum  { BTN_OK, BTN_Apply, BTN_Close, BTN_Help }

Private Slots

void onOk ()
bool onApply ()
void onClose ()
void onHelp ()
void onDeactivate ()
void onSelectionDone ()
void onCriterionChanged (const int, const int)
void onCurrentChanged (int, int)

Private Member Functions

void construct (const QList< int > &)
void closeEvent (QCloseEvent *)
void enterEvent (QEvent *)
void keyPressEvent (QKeyEvent *)
QWidgetcreateButtonFrame (QWidget *)
QWidgetcreateMainFrame (QWidget *)
QWidgetcreateSourceGroup (QWidget *)
void updateMainButtons ()
bool isValid () const
bool createFilter (const int)
void insertFilterInViewer ()
void selectInViewer (const int, const QList< int > &)
void filterSource (const int, QList< int > &)
void filterSelectionSource (const int, QList< int > &)
void getIdsFromWg (const QWidget *, QList< int > &) const
void setIdsToWg (QWidget *, const QList< int > &)
Selection_Mode getSelMode (const int) const
void updateSelection ()

Private Attributes

QWidgetmyMainFrame
QButtonGroup * mySourceGrp
QCheckBox * mySetInViewer
QMap< int, QPushButton * > myButtons
SMESHGUI_FilterTablemyTable
QList< intmyTypes
SMESHGUImySMESHGUI
LightApp_SelectionMgr * mySelectionMgr
SVTK_Selector * mySelector
SMESH::SMESH_Mesh_var myMesh
bool myInitSourceWgOnApply
QWidgetmySourceWg
SALOME_DataMapOfIOMapOfInteger myIObjects
bool myIsSelectionChanged
QMap< int, SMESH::Filter_var > myFilter
QMap< int, boolmyInsertState
QMap< int, intmyApplyToState
QString myHelpFileName

Detailed Description

Class : SMESHGUI_FilterDlg Description : Dialog to specify filters for VTK viewer.

Definition at line 210 of file SMESHGUI_FilterDlg.h.


Member Enumeration Documentation

anonymous enum [private]
Enumerator:
Mesh 
Selection 
Dialog 
None 

Definition at line 215 of file SMESHGUI_FilterDlg.h.

anonymous enum [private]
Enumerator:
BTN_OK 
BTN_Apply 
BTN_Close 
BTN_Help 

Definition at line 218 of file SMESHGUI_FilterDlg.h.


Constructor & Destructor Documentation

SMESHGUI_FilterDlg::SMESHGUI_FilterDlg ( SMESHGUI theModule,
const QList< int > &  theTypes 
)

Definition at line 2399 of file SMESHGUI_FilterDlg.cxx.

References construct(), SMESH.GetViewWindow(), mySelector, and mySMESHGUI.

: QDialog( SMESH::GetDesktop( theModule ) ),
  mySMESHGUI( theModule ),
  mySelectionMgr( SMESH::GetSelectionMgr( theModule ) ),
  myInitSourceWgOnApply( true )
{
  if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
    mySelector = aViewWindow->GetSelector();

  construct(theTypes);
}
SMESHGUI_FilterDlg::SMESHGUI_FilterDlg ( SMESHGUI theModule,
const int  theType 
)

Definition at line 2416 of file SMESHGUI_FilterDlg.cxx.

References construct(), SMESH.GetViewWindow(), mySelector, and mySMESHGUI.

: QDialog( SMESH::GetDesktop( theModule ) ),
  mySMESHGUI( theModule ),
  mySelectionMgr( SMESH::GetSelectionMgr( theModule ) ),
  myInitSourceWgOnApply( true )
{
  if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
    mySelector = aViewWindow->GetSelector();
  QList<int> aTypes;
  aTypes.append(theType);
  construct(aTypes);
}
SMESHGUI_FilterDlg::~SMESHGUI_FilterDlg ( ) [virtual]

Definition at line 2589 of file SMESHGUI_FilterDlg.cxx.

{
}

Member Function Documentation

void SMESHGUI_FilterDlg.Accepted ( ) [signal]

Referenced by onOk().

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

Definition at line 2773 of file SMESHGUI_FilterDlg.cxx.

References onClose().

{
  onClose();
}
void SMESHGUI_FilterDlg::construct ( const QList< int > &  theTypes) [private]

Definition at line 2434 of file SMESHGUI_FilterDlg.cxx.

References createButtonFrame(), createMainFrame(), Init(), MARGIN, myHelpFileName, myMainFrame, myTypes, and SPACING.

Referenced by SMESHGUI_FilterDlg().

{
  myTypes = theTypes;

  setModal(false);
  //setAttribute(Qt::WA_DeleteOnClose, true); // VSR ??? is it required?
  setWindowTitle(tr("CAPTION"));

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

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

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

  aDlgLay->setStretchFactor(myMainFrame, 1);

  myHelpFileName = "selection_filter_library_page.html";

  Init(myTypes);
}
QWidget * SMESHGUI_FilterDlg::createButtonFrame ( QWidget theParent) [private]

Definition at line 2555 of file SMESHGUI_FilterDlg.cxx.

References BTN_Apply, BTN_Close, BTN_Help, BTN_OK, MARGIN, myButtons, onApply(), onClose(), onHelp(), onOk(), SPACING, and updateMainButtons().

Referenced by construct().

{
  QGroupBox* aGrp = new QGroupBox(theParent);
  QHBoxLayout* aLay = new QHBoxLayout(aGrp);
  aLay->setMargin(MARGIN);
  aLay->setSpacing(SPACING);

  myButtons[ BTN_OK     ] = new QPushButton(tr("SMESH_BUT_APPLY_AND_CLOSE"), aGrp);
  myButtons[ BTN_Apply  ] = new QPushButton(tr("SMESH_BUT_APPLY"),           aGrp);
  myButtons[ BTN_Close  ] = new QPushButton(tr("SMESH_BUT_CLOSE"),           aGrp);
  myButtons[ BTN_Help   ] = new QPushButton(tr("SMESH_BUT_HELP"),            aGrp);

  aLay->addWidget(myButtons[ BTN_OK     ]);
  aLay->addSpacing(10);
  aLay->addWidget(myButtons[ BTN_Apply  ]);
  aLay->addSpacing(10);
  aLay->addStretch();
  aLay->addWidget(myButtons[ BTN_Close  ]);
  aLay->addWidget(myButtons[ BTN_Help   ]);

  connect(myButtons[ BTN_OK     ], SIGNAL(clicked()), SLOT(onOk()));
  connect(myButtons[ BTN_Close  ], SIGNAL(clicked()), SLOT(onClose()));
  connect(myButtons[ BTN_Apply  ], SIGNAL(clicked()), SLOT(onApply()));
  connect(myButtons[ BTN_Help   ], SIGNAL(clicked()), SLOT(onHelp()));

  updateMainButtons();

  return aGrp;
}
SMESH::Filter::Criterion SMESHGUI_FilterDlg::createCriterion ( ) [static]
bool SMESHGUI_FilterDlg::createFilter ( const int  theType) [private]

Definition at line 3057 of file SMESHGUI_FilterDlg.cxx.

References SMESH_freebord.aCriterion, createCriterion(), SMESHGUI_FilterTable.GetCriterion(), SMESH.GetFilterManager(), SMESH.GetResourceMgr(), myFilter, mySMESHGUI, myTable, SMESHGUI_FilterTable.NumRows(), and SMESH.Filter.Criterion.Precision.

Referenced by onApply().

{
  SMESH::FilterManager_var aFilterMgr = SMESH::GetFilterManager();
  if (aFilterMgr->_is_nil())
    return false;

  int n = myTable->NumRows();

  SMESH::Filter::Criteria_var aCriteria = new SMESH::Filter::Criteria;
  aCriteria->length(n);

  long aPrecision = -1;
  SUIT_ResourceMgr* mgr = SMESH::GetResourceMgr( mySMESHGUI );

  if ( mgr && mgr->booleanValue( "SMESH", "use_precision", false ) )
    aPrecision = mgr->integerValue( "SMESH", "controls_precision", aPrecision );

  for (CORBA::ULong i = 0; i < n; i++) {
    SMESH::Filter::Criterion aCriterion = createCriterion();
    myTable->GetCriterion(i, aCriterion);
    aCriterion.Precision = aPrecision;
    aCriteria[ i ] = aCriterion;
  }

  myFilter[ theType ] = aFilterMgr->CreateFilter();
  myFilter[ theType ]->SetCriteria(aCriteria.inout());

  return true;
}
QWidget * SMESHGUI_FilterDlg::createMainFrame ( QWidget theParent) [private]

Definition at line 2463 of file SMESHGUI_FilterDlg.cxx.

References createSourceGroup(), SMESHGUI_FilterTable.GetTableGrp(), mySetInViewer, mySMESHGUI, myTable, myTypes, onCriterionChanged(), onCurrentChanged(), SMESHGUI_FilterTable.SetLibsEnabled(), and SPACING.

Referenced by construct().

{
  QWidget* aMainFrame = new QWidget(theParent);
  QVBoxLayout* aMainLay = new QVBoxLayout(aMainFrame);
  aMainLay->setMargin(0);
  aMainLay->setSpacing(SPACING);

  // filter frame

  myTable = new SMESHGUI_FilterTable( mySMESHGUI, aMainFrame, myTypes );
  myTable->SetLibsEnabled(true);

  QGroupBox* aGrp = myTable->GetTableGrp();
  QGridLayout* aLay = qobject_cast<QGridLayout*>( aGrp->layout() );
  int rows = aLay->rowCount();
  int cols = aLay->columnCount();

  QFrame* aLine = new QFrame(aGrp);
  aLine->setFrameStyle(QFrame::HLine | QFrame::Sunken);
  aLay->addWidget(aLine, rows++, 0, 1, cols);

  mySetInViewer = new QCheckBox(tr("SET_IN_VIEWER"), aGrp);
  mySetInViewer->setChecked(true);
  aLay->addWidget(mySetInViewer, rows++, 0, 1, cols);

  // other controls
  QWidget* aSourceGrp = createSourceGroup(aMainFrame);

  connect(myTable, SIGNAL(CriterionChanged(const int, const int)),
                    SLOT(onCriterionChanged(const int, const int)));

  connect(myTable, SIGNAL(CurrentChanged(int, int)),
                    SLOT(onCurrentChanged(int, int)));

  aMainLay->addWidget(myTable);
  aMainLay->addWidget(aSourceGrp);
  
  return aMainFrame;
}
QWidget * SMESHGUI_FilterDlg::createSourceGroup ( QWidget theParent) [private]

Definition at line 2507 of file SMESHGUI_FilterDlg.cxx.

References SMESH_freebord.aBox, Dialog, MARGIN, Mesh, mySourceGrp, Selection, and SPACING.

Referenced by createMainFrame().

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

  mySourceGrp = new QButtonGroup(theParent);

  QRadioButton* aMeshBtn = new QRadioButton(tr("MESH"),          aBox);
  QRadioButton* aSelBtn  = new QRadioButton(tr("SELECTION"),     aBox);
  QRadioButton* aDlgBtn  = new QRadioButton(tr("CURRENT_DIALOG"),aBox);

  aLay->addWidget(aMeshBtn);
  aLay->addWidget(aSelBtn);
  aLay->addWidget(aDlgBtn);

  mySourceGrp->addButton(aMeshBtn, Mesh);
  mySourceGrp->addButton(aSelBtn,  Selection);
  mySourceGrp->addButton(aDlgBtn,  Dialog);

  aSelBtn->setChecked(true);

  return aBox;
}
void SMESHGUI_FilterDlg::enterEvent ( QEvent *  ) [private]

Definition at line 2761 of file SMESHGUI_FilterDlg.cxx.

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

{
//  mySMESHGUI->EmitSignalDeactivateDialog();
  mySMESHGUI->SetActiveDialogBox((QDialog*)this);
  mySMESHGUI->ResetState();
  setEnabled(true);
}
void SMESHGUI_FilterDlg::filterSelectionSource ( const int  theType,
QList< int > &  theResIds 
) [private]

Definition at line 3164 of file SMESHGUI_FilterDlg.cxx.

References SMESH_controls.aGroup, SMESH_BelongToGeom.anIds, SMESH.FindActorByEntry(), myFilter, myIObjects, myMesh, mySelectionMgr, and SMESH.NODE.

Referenced by filterSource().

{
  theResIds.clear();
  if (myMesh->_is_nil() || mySelectionMgr == 0)
    return;

  // Create map of entities to be filtered
  TColStd_MapOfInteger aToBeFiltered;
  SALOME_DataMapIteratorOfDataMapOfIOMapOfInteger anIter(myIObjects);

  for ( ; anIter.More(); anIter.Next())
  {
    // process sub mesh
    SMESH::SMESH_subMesh_var aSubMesh = SMESH::IObjectToInterface<SMESH::SMESH_subMesh>(anIter.Key());
    if (!aSubMesh->_is_nil())
    {
      if (aSubMesh->GetFather()->GetId() == myMesh->GetId())
      {
        SMESH::long_array_var anIds =
          theType == SMESH::NODE ? aSubMesh->GetNodesId() : aSubMesh->GetElementsId();
        for (int i = 0, n = anIds->length(); i < n; i++)
          aToBeFiltered.Add(anIds[ i ]);
      }
    }

    // process group
    SMESH::SMESH_GroupBase_var aGroup =
      SMESH::IObjectToInterface<SMESH::SMESH_GroupBase>(anIter.Key());
    if (!aGroup->_is_nil())
    {
      if (aGroup->GetType() == theType && aGroup->GetMesh()->GetId() == myMesh->GetId())
      {
        SMESH::long_array_var anIds = aGroup->GetListOfID();
        for (int i = 0, n = anIds->length(); i < n; i++)
          aToBeFiltered.Add(anIds[ i ]);
      }
    }

    // process mesh
    SMESH::SMESH_Mesh_var aMeshPtr = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(anIter.Key());
    if (!aMeshPtr->_is_nil() && aMeshPtr->GetId() == myMesh->GetId())
    {
      const TColStd_IndexedMapOfInteger& aSelMap = anIter.Value();

      if (aSelMap.Extent() > 0)
      {
        if(SMESH::FindActorByEntry(anIter.Key()->getEntry()))
        {
          for (int i = 1; i <= aSelMap.Extent(); i++)
            aToBeFiltered.Add(aSelMap(i));
        }
      }
    }
  }

  // Filter entities
  SMESH::Predicate_ptr aPred = myFilter[ theType ]->GetPredicate();
  aPred->SetMesh(myMesh);
  TColStd_MapIteratorOfMapOfInteger aResIter(aToBeFiltered);
  for ( ; aResIter.More(); aResIter.Next())
    if (aPred->IsSatisfy(aResIter.Key()))
      theResIds.append(aResIter.Key());
}
void SMESHGUI_FilterDlg::filterSource ( const int  theType,
QList< int > &  theResIds 
) [private]

Definition at line 3114 of file SMESHGUI_FilterDlg.cxx.

References SMESH_BelongToGeom.anIds, Dialog, filterSelectionSource(), getIdsFromWg(), Mesh, myFilter, myInitSourceWgOnApply, myMesh, mySourceGrp, mySourceWg, Selection, and setIdsToWg().

Referenced by onApply().

{
  theResIds.clear();
  if (myFilter[ theType ]->_is_nil())
    return;

  int aSourceId = mySourceGrp->checkedId();

  if (aSourceId == Mesh)
  {
    if (myMesh->_is_nil())
      return;
    SMESH::long_array_var anIds = myFilter[ theType ]->GetElementsId(myMesh);
    for (int i = 0, n = anIds->length(); i < n; i++)
      theResIds.append(anIds[ i ]);
  }
  else if (aSourceId == Selection)
  {
    filterSelectionSource(theType, theResIds);
  }
  else if (aSourceId == Dialog)
  {
    // retrieve ids from dialog
    QList<int> aDialogIds;
    getIdsFromWg(mySourceWg, aDialogIds);

    if (myMesh->_is_nil())
    {
      theResIds = aDialogIds;
      return;
    }

    // filter ids
    SMESH::Predicate_ptr aPred = myFilter[ theType ]->GetPredicate();
    aPred->SetMesh(myMesh);
    QList<int>::const_iterator anIter;
    for (anIter = aDialogIds.begin(); anIter != aDialogIds.end(); ++ anIter)
      if (aPred->IsSatisfy(*anIter))
        theResIds.append(*anIter);
  }
  // set ids to the dialog
  if (myInitSourceWgOnApply || aSourceId == Dialog)
    setIdsToWg(mySourceWg, theResIds);
}
void SMESHGUI_FilterDlg::getIdsFromWg ( const QWidget theWg,
QList< int > &  theRes 
) const [private]

Definition at line 2782 of file SMESHGUI_FilterDlg.cxx.

Referenced by filterSource().

{
  theRes.clear();
  if (theWg == 0)
    return;

  if (theWg->inherits("QListWidget"))
  {
    const QListWidget* aListBox = qobject_cast<const QListWidget*>( theWg );
    bool b;
    for (int i = 0, n = aListBox->count(); i < n; i++)
    {
      int anId = aListBox->item(i)->text().toInt(&b);
      if (b)
        theRes.append(anId);
    }
  }
  else if (theWg->inherits("QLineEdit"))
  {
    const QLineEdit* aLineEdit = qobject_cast<const QLineEdit*>( theWg );
    QString aStr = aLineEdit->text();
    QRegExp aRegExp("(\\d+)");
    bool b;
    int aPos = 0;
    while (aPos >= 0)
    {
      aPos = aRegExp.indexIn(aStr, aPos);
      if (aPos > -1)
      {
        int anId = aRegExp.cap(1).toInt(&b);
        if (b)
          theRes.append(anId);
        aPos += aRegExp.matchedLength();
      }
    }
  }
}
Selection_Mode SMESHGUI_FilterDlg::getSelMode ( const int  theType) const [private]

Definition at line 2824 of file SMESHGUI_FilterDlg.cxx.

References SMESH.ALL, SMESH.EDGE, SMESH.FACE, SMESH.NODE, and SMESH.VOLUME.

Referenced by selectInViewer().

{
  switch (theType)
  {
    case SMESH::NODE   : return NodeSelection;
    case SMESH::EDGE   : return EdgeSelection;
    case SMESH::FACE   : return FaceSelection;
    case SMESH::VOLUME : return VolumeSelection;
    case SMESH::ALL    : return CellSelection;
    default            : return ActorSelection;
  }

}
void SMESHGUI_FilterDlg::Init ( const int  type)

Definition at line 2597 of file SMESHGUI_FilterDlg.cxx.

References Init().

{
  QList<int> aTypes;
  aTypes.append(type);
  Init(aTypes);
}
void SMESHGUI_FilterDlg::Init ( const QList< int > &  theTypes)

Definition at line 2608 of file SMESHGUI_FilterDlg.cxx.

References SMESHGUI_FilterTable.AddCriterion(), SMESH.ALL, SMESHGUI_FilterTable.Clear(), SMESH.EDGE, SMESH.FACE, SMESHGUI_FilterTable.Init(), myApplyToState, myFilter, myInsertState, myIObjects, myIsSelectionChanged, myMesh, mySetInViewer, mySMESHGUI, mySourceGrp, mySourceWg, myTable, myTypes, SMESH.NODE, onClose(), onDeactivate(), Selection, SMESHGUI.SetActiveDialogBox(), updateMainButtons(), updateSelection(), and SMESH.VOLUME.

Referenced by construct(), Init(), SMESHGUI_MultiEditDlg.onFilterBtn(), SMESHGUI_SmoothingDlg.setFilters(), SMESHGUI_RevolutionDlg.setFilters(), SMESHGUI_GroupDlg.setFilters(), SMESHGUI_ExtrusionDlg.setFilters(), and SMESHGUI_ExtrusionAlongPathDlg.setFilters().

{
  mySourceWg  = 0;
  myTypes     = theTypes;
  myMesh      = SMESH::SMESH_Mesh::_nil();
  myIObjects.Clear();
  myIsSelectionChanged = false;

  myTable->Init(theTypes);

  // set caption
  if (theTypes.count() == 1)
  {
    int aType = theTypes.first();
    if      (aType == SMESH::NODE  ) setWindowTitle(tr("NODES_TLT"));
    else if (aType == SMESH::EDGE  ) setWindowTitle(tr("EDGES_TLT"));
    else if (aType == SMESH::FACE  ) setWindowTitle(tr("FACES_TLT"));
    else if (aType == SMESH::VOLUME) setWindowTitle(tr("VOLUMES_TLT"));
    else if (aType == SMESH::ALL)    setWindowTitle(tr("TLT"));
  }
  else
    setWindowTitle(tr("TLT"));

  qApp->processEvents();
  updateGeometry();
  adjustSize();
  setEnabled(true);

  mySMESHGUI->SetActiveDialogBox((QDialog*)this);

  connect(mySMESHGUI, SIGNAL(SignalDeactivateActiveDialog()), SLOT(onDeactivate()));
  connect(mySMESHGUI, SIGNAL(SignalCloseAllDialogs()), SLOT(onClose()));
  
  updateMainButtons();
  updateSelection();

  // Initialise filter table with values of previous filter
  QList<int>::const_iterator anIter;
  for (anIter = theTypes.begin(); anIter != theTypes.end(); ++anIter)
  {
    myTable->Clear(*anIter);
    if (!myFilter[ *anIter ]->_is_nil())
    {
      SMESH::Filter::Criteria_var aCriteria = new SMESH::Filter::Criteria;
      if (myFilter[ *anIter ]->GetCriteria(aCriteria))
      {
        for (int i = 0, n = aCriteria->length(); i < n; i++)
          myTable->AddCriterion(aCriteria[ i ], *anIter);
      }
    }
  }

  if (myInsertState.contains(theTypes.first()))
    mySetInViewer->setChecked(myInsertState[ theTypes.first() ]);
  else
    mySetInViewer->setChecked(true);

  mySourceGrp->button(myApplyToState.contains(theTypes.first()) ? 
                      myApplyToState[ theTypes.first() ] :
                      Selection)->setChecked(true);
}
void SMESHGUI_FilterDlg::insertFilterInViewer ( ) [private]

Definition at line 3091 of file SMESHGUI_FilterDlg.cxx.

References getFilterId(), SMESH.GetSelector(), SMESHGUI_FilterTable.GetType(), Handle(), myFilter, mySetInViewer, myTable, SMESH.RemoveFilter(), and SMESH.SetFilter().

Referenced by onApply().

{
  if (SVTK_Selector* aSelector = SMESH::GetSelector()) {
    SMESH::ElementType anEntType = (SMESH::ElementType)myTable->GetType();

    if (myFilter[ myTable->GetType() ]->_is_nil() ||
         myFilter[ myTable->GetType() ]->GetPredicate()->_is_nil() ||
         !mySetInViewer->isChecked()) {
      SMESH::RemoveFilter(getFilterId(anEntType), aSelector);
    }
    else {
      Handle(SMESHGUI_PredicateFilter) aFilter = new SMESHGUI_PredicateFilter();
      aFilter->SetPredicate(myFilter[ myTable->GetType() ]->GetPredicate());
      SMESH::RemoveFilter(getFilterId(anEntType), aSelector); //skl for IPAL12631
      SMESH::SetFilter(aFilter, aSelector);
    }
  }
}
bool SMESHGUI_FilterDlg::isValid ( ) const [private]

Definition at line 2866 of file SMESHGUI_FilterDlg.cxx.

References SMESHGUI.desktop(), SMESH.FACE, SMESH.FT_BelongToCylinder, SMESH.FT_BelongToGenSurface, SMESH.FT_BelongToGeom, SMESH.FT_BelongToPlane, SMESH.FT_CoplanarFaces, SMESH.FT_LyingOnGeom, SMESHGUI_FilterTable.GetCriterionType(), SMESHGUI_FilterTable.GetThreshold(), Handle(), SMESHGUI_FilterTable.IsValid(), myMesh, myTable, SMESHGUI_FilterTable.NumRows(), and SMESH.SObjectToObject().

Referenced by onApply().

{
  if (!myTable->IsValid())
    return false;

  for (int i = 0, n = myTable->NumRows(); i < n; i++)
  {
    int aType = myTable->GetCriterionType(i);
    if (aType == SMESH::FT_BelongToGeom ||
        aType == SMESH::FT_BelongToPlane ||
        aType == SMESH::FT_BelongToCylinder ||
        aType == SMESH::FT_BelongToGenSurface ||
        aType == SMESH::FT_LyingOnGeom)
    {
      QString aName;
      myTable->GetThreshold(i, aName);

      std::vector<_PTR(SObject)> aList =
        SMESH::GetActiveStudyDocument()->FindObjectByName(aName.toLatin1().constData(), "GEOM");
      if (aList.size() == 0) {
        SUIT_MessageBox::information(SMESHGUI::desktop(), tr("SMESH_INSUFFICIENT_DATA"),
                                     tr("BAD_SHAPE_NAME").arg(aName));
        return false;
      }

      if (aType == SMESH::FT_BelongToCylinder ||
          aType == SMESH::FT_BelongToPlane    ||
          aType == SMESH::FT_BelongToGenSurface ) {
        CORBA::Object_var anObject = SMESH::SObjectToObject(aList[ 0 ]);
        //GEOM::GEOM_Object_var aGeomObj = GEOM::GEOM_Object::_narrow(aList[ 0 ]->GetObject());
        GEOM::GEOM_Object_var aGeomObj = GEOM::GEOM_Object::_narrow(anObject);
        if (!aGeomObj->_is_nil()) {
          TopoDS_Shape aFace;
          if (!GEOMBase::GetShape(aGeomObj, aFace) ||
               aFace.IsNull() ||
               aFace.ShapeType() != TopAbs_FACE) {
            SUIT_MessageBox::information(SMESHGUI::desktop(), tr("SMESH_INSUFFICIENT_DATA"),
                                         tr("SHAPE_IS_NOT_A_FACE").arg(aName));
            return false;
          }

          Handle(Geom_Surface) aSurf = BRep_Tool::Surface(TopoDS::Face(aFace));
          if (aSurf.IsNull()) {
            SUIT_MessageBox::information(SMESHGUI::desktop(), tr("SMESH_INSUFFICIENT_DATA"),
                                         tr("SHAPE_IS_NOT_A_FACE").arg(aName));
            return false;
          }

          if (aType == SMESH::FT_BelongToPlane && !aSurf->IsKind(STANDARD_TYPE(Geom_Plane))) {
            SUIT_MessageBox::information(SMESHGUI::desktop(), tr("SMESH_INSUFFICIENT_DATA"),
                                         tr("SHAPE_IS_NOT_A_PLANE").arg(aName));
            return false;
          }

          if (aType == SMESH::FT_BelongToCylinder && !aSurf->IsKind(STANDARD_TYPE(Geom_CylindricalSurface))) {
            SUIT_MessageBox::information(SMESHGUI::desktop(), tr("SMESH_INSUFFICIENT_DATA"),
                                         tr("SHAPE_IS_NOT_A_CYLINDER").arg(aName));
            return false;
          }
        }
      }
    }
    else if (aType == SMESH::FT_CoplanarFaces)
    {
      QString faceID;
      myTable->GetThreshold(i, faceID);
      if ( faceID.isEmpty() )
      {
        SUIT_MessageBox::information(SMESHGUI::desktop(), tr("SMESH_INSUFFICIENT_DATA"),
                                     tr("FACE_ID_NOT_SELECTED"));
        return false;
      }
      if ( myMesh->_is_nil() )
      {
        SUIT_MessageBox::information(SMESHGUI::desktop(), tr("SMESH_INSUFFICIENT_DATA"),
                                     tr("MESH_IS_NOT_SELECTED"));
        return false;
      }
      if ( myMesh->GetElementType( faceID.toLong(), /*iselem=*/true) != SMESH::FACE )
      {
        SUIT_MessageBox::information(SMESHGUI::desktop(), tr("SMESH_INSUFFICIENT_DATA"),
                                     tr("NOT_FACE_ID").arg(faceID));
        return false;
      }
    }
  }

  return true;
}
void SMESHGUI_FilterDlg::keyPressEvent ( QKeyEvent *  e) [private]

Definition at line 3434 of file SMESHGUI_FilterDlg.cxx.

References onHelp().

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

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

Definition at line 3018 of file SMESHGUI_FilterDlg.cxx.

References createFilter(), filterSource(), SMESH.GetPredicate(), SMESHGUI_FilterTable.GetType(), insertFilterInViewer(), isValid(), myApplyToState, myFilter, myInsertState, mySetInViewer, mySourceGrp, myTable, and selectInViewer().

Referenced by createButtonFrame(), and onOk().

{
  if (!isValid())
    return false;

  try {
    int aCurrType = myTable->GetType();

    if (!createFilter(aCurrType))
      return false;

    insertFilterInViewer();

    if (!myFilter[ aCurrType ]->GetPredicate()->_is_nil()) {
      QList<int> aResultIds;
      filterSource(aCurrType, aResultIds);
      // select in viewer
      selectInViewer(aCurrType, aResultIds);
    }


    myInsertState[ aCurrType ] = mySetInViewer->isChecked();
    myApplyToState[ aCurrType ] = mySourceGrp->checkedId();
  }
  catch(const SALOME::SALOME_Exception& S_ex)
  {
    SalomeApp_Tools::QtCatchCorbaException(S_ex);
  }
  catch(...)
  {
  }

  return true;
}
void SMESHGUI_FilterDlg::onClose ( ) [private, slot]

Definition at line 2692 of file SMESHGUI_FilterDlg.cxx.

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

Referenced by closeEvent(), createButtonFrame(), and Init().

{
  // Restore previously selected object
  if (mySelectionMgr)
  {
    SALOME_ListIO aList;
    mySelectionMgr->clearFilters();
    mySelectionMgr->clearSelected();
    SALOME_DataMapIteratorOfDataMapOfIOMapOfInteger anIter (myIObjects);
    for ( ; anIter.More(); anIter.Next())
    {
      aList.Append(anIter.Key());

      TColStd_MapOfInteger aResMap;
      const TColStd_IndexedMapOfInteger& anIndMap = anIter.Value();
      for (int i = 1, n = anIndMap.Extent(); i <= n; i++)
        aResMap.Add(anIndMap(i));

      mySelector->AddOrRemoveIndex( anIter.Key(), aResMap, false);
      if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
        aViewWindow->highlight( anIter.Key(), true, true );
    }
    mySelectionMgr->setSelectedObjects(aList, false);
  }

  disconnect(mySMESHGUI, 0, this, 0);
  disconnect(mySelectionMgr, 0, this, 0);
  mySMESHGUI->ResetState();
  reject();
  return;
}
void SMESHGUI_FilterDlg::onCriterionChanged ( const int  ,
const int   
) [private, slot]

Definition at line 3362 of file SMESHGUI_FilterDlg.cxx.

References updateSelection().

Referenced by createMainFrame().

void SMESHGUI_FilterDlg::onCurrentChanged ( int  ,
int   
) [private, slot]

Definition at line 3371 of file SMESHGUI_FilterDlg.cxx.

References updateSelection().

Referenced by createMainFrame().

void SMESHGUI_FilterDlg::onDeactivate ( ) [private, slot]

Definition at line 2752 of file SMESHGUI_FilterDlg.cxx.

Referenced by Init().

{
  setEnabled(false);
}
void SMESHGUI_FilterDlg::onHelp ( ) [private, slot]

Definition at line 2728 of file SMESHGUI_FilterDlg.cxx.

References myHelpFileName, and mySMESHGUI.

Referenced by createButtonFrame(), 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_FilterDlg::onOk ( ) [private, slot]

Definition at line 2675 of file SMESHGUI_FilterDlg.cxx.

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

Referenced by createButtonFrame().

{
  if (onApply())
  {
    mySelectionMgr->clearFilters();
    disconnect(mySMESHGUI, 0, this, 0);
    disconnect(mySelectionMgr, 0, this, 0);
    mySMESHGUI->ResetState();
    accept();
    emit Accepted();
  }
}
void SMESHGUI_FilterDlg::onSelectionDone ( ) [private, slot]

Definition at line 3315 of file SMESHGUI_FilterDlg.cxx.

References BTN_Apply, BTN_OK, SMESHGUI_FilterTable.CurrentCell(), SMESH.FT_BelongToCylinder, SMESH.FT_BelongToGenSurface, SMESH.FT_BelongToGeom, SMESH.FT_BelongToPlane, SMESH.FT_CoplanarFaces, SMESH.FT_LyingOnGeom, SMESHGUI_FilterTable.GetCriterionType(), smeshDC.GetName(), SMESH.GetNameOfSelectedElements(), Handle(), myButtons, myMesh, mySelector, myTable, SMESHGUI_FilterTable.SetID(), and SMESHGUI_FilterTable.SetThreshold().

Referenced by SetSelection().

{
  int aRow, aCol;
  const SALOME_ListIO& aList = mySelector->StoredIObjects();

  if ( myMesh->_is_nil() && aList.Extent()>0 ) {
    myMesh = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(aList.First());
    if ( !(myMesh->_is_nil()) ) {
      myButtons[BTN_OK]->setEnabled(true);
      myButtons[BTN_Apply]->setEnabled(true);
    }
  }

  QList<int> types; 
  types << SMESH::FT_BelongToGeom     << SMESH::FT_BelongToPlane 
        << SMESH::FT_BelongToCylinder << SMESH::FT_BelongToGenSurface
        << SMESH::FT_LyingOnGeom      << SMESH::FT_CoplanarFaces;
  if (aList.Extent() != 1 || !myTable->CurrentCell(aRow, aCol) || 
      !types.contains(myTable->GetCriterionType(aRow)))
    return;

  if ( myTable->GetCriterionType(aRow) == SMESH::FT_CoplanarFaces )
  {
    QString aString;
    int nbElems = SMESH::GetNameOfSelectedElements(mySelector,//myViewWindow->GetSelector(),
                                                   aList.First(), aString);
    if (nbElems == 1)
      myTable->SetThreshold(aRow, aString);
  }
  else
  {
    Handle(SALOME_InteractiveObject) anIO = aList.First();
    GEOM::GEOM_Object_var anObj = SMESH::IObjectToInterface<GEOM::GEOM_Object>(anIO);
    if (!anObj->_is_nil())
    {
      myTable->SetThreshold(aRow, GEOMBase::GetName(anObj));
      //myTable->SetID( aRow, GEOMBase::GetIORFromObject(anObj));
      myTable->SetID(aRow, anIO->getEntry());
    }
  }
}
void SMESHGUI_FilterDlg::selectInViewer ( const int  theType,
const QList< int > &  theIds 
) [private]

Definition at line 3233 of file SMESHGUI_FilterDlg.cxx.

References SMESH.EDGE, SMESH.EdgeFilter, SMESH.FACE, SMESH.FaceFilter, SMESH.FindActorByObject(), getSelMode(), SMESHGUI_FilterTable.GetType(), SMESH.GetViewWindow(), Handle(), myMesh, mySelectionMgr, mySelector, mySMESHGUI, myTable, SMESH.RemoveFilter(), SMESH.SetFilter(), SMESH.SetPointRepresentation(), SMESH.UnknownFilter, SMESH.VOLUME, and SMESH.VolumeFilter.

Referenced by onApply().

{
  if (mySelectionMgr == 0 || myMesh->_is_nil())
    return;

  mySelectionMgr->clearFilters();

  // Set new selection mode if necessary
  Selection_Mode aSelMode = getSelMode(theType);
  SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI );
  if ( aViewWindow && aViewWindow->SelectionMode()!=aSelMode) {
    mySelectionMgr->clearSelected();
    mySelectionMgr->clearFilters();
    if (aSelMode == NodeSelection)
      SMESH::SetPointRepresentation(true);
    aViewWindow->SetSelectionMode(aSelMode);
  }

  // Clear selection
  SMESH_Actor* anActor = SMESH::FindActorByObject(myMesh);
  if (!anActor || !anActor->hasIO())
    return;

  Handle(SALOME_InteractiveObject) anIO = anActor->getIO();
  //mySelectionMgr->clearSelected();
  //mySelectionMgr->AddIObject(anIO, false);
  SALOME_ListIO aList;
  aList.Append(anIO);
  mySelectionMgr->setSelectedObjects(aList, false);

  // Remove filter corresponding to the current type from viewer
  int aType = myTable->GetType();
  int aFilterId = SMESH::UnknownFilter;
  if      (aType == SMESH::EDGE  ) aFilterId = SMESH::EdgeFilter;
  else if (aType == SMESH::FACE  ) aFilterId = SMESH::FaceFilter;
  else if (aType == SMESH::VOLUME) aFilterId = SMESH::VolumeFilter;
  Handle(VTKViewer_Filter) aFilter = SMESH::GetFilter(aFilterId);
  SMESH::RemoveFilter(aFilterId);

  // get vtk ids
  TColStd_MapOfInteger aMap;
  QList<int>::const_iterator anIter;
  for (anIter = theIds.begin(); anIter != theIds.end(); ++anIter) {
    aMap.Add(*anIter);
  }

  // Set new selection
  mySelector->AddOrRemoveIndex(anIO, aMap, false);
  if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
    aViewWindow->highlight( anIO, true, true );

  // insert previously stored filter in viewer if necessary
  if (!aFilter.IsNull())
    SMESH::SetFilter(aFilter);
}
void SMESHGUI_FilterDlg::setIdsToWg ( QWidget theWg,
const QList< int > &  theIds 
) [private]

Definition at line 2842 of file SMESHGUI_FilterDlg.cxx.

Referenced by filterSource().

{
  if (theWg == 0)
    return;

  QStringList aStrList;
  foreach(int id, theIds)
    aStrList << QString::number(id);

  if (theWg->inherits("QListWidget"))
  {
    qobject_cast<QListWidget*>(theWg)->clear();
    qobject_cast<QListWidget*>(theWg)->addItems(aStrList);
  }
  else if (theWg->inherits("QLineEdit"))
  {
    qobject_cast<QLineEdit*>( theWg )->setText(aStrList.join(" "));
  }
}
void SMESHGUI_FilterDlg::SetMesh ( SMESH::SMESH_Mesh_var  theMesh)
void SMESHGUI_FilterDlg::SetSelection ( )

Definition at line 2990 of file SMESHGUI_FilterDlg.cxx.

References myIObjects, mySelectionMgr, mySelector, onSelectionDone(), and updateSelection().

Referenced by SMESHGUI_MultiEditDlg.onFilterBtn(), SMESHGUI_TranslationDlg.setFilters(), SMESHGUI_SymmetryDlg.setFilters(), SMESHGUI_SmoothingDlg.setFilters(), SMESHGUI_ScaleDlg.setFilters(), SMESHGUI_RotationDlg.setFilters(), SMESHGUI_RevolutionDlg.setFilters(), SMESHGUI_RemoveNodesDlg.setFilters(), SMESHGUI_RemoveElementsDlg.setFilters(), SMESHGUI_GroupDlg.setFilters(), SMESHGUI_ExtrusionDlg.setFilters(), SMESHGUI_ExtrusionAlongPathDlg.setFilters(), and SMESHGUI_CopyMeshDlg.setFilters().

{
  if (mySelectionMgr)
    disconnect(mySelectionMgr, SIGNAL(currentSelectionChanged()), this, SLOT(onSelectionDone()));

  if (mySelectionMgr) {
    myIObjects.Clear();
    const SALOME_ListIO& anObjs = mySelector->StoredIObjects(); 
    SALOME_ListIteratorOfListIO anIter (anObjs);
    for ( ; anIter.More(); anIter.Next()) {
      TColStd_IndexedMapOfInteger aMap;
      mySelector->GetIndex(anIter.Value(), aMap);
      myIObjects.Bind(anIter.Value(), aMap);
    }

    connect(mySelectionMgr, SIGNAL(currentSelectionChanged()), SLOT(onSelectionDone()));

    updateSelection();
  }
  else
    myIObjects.Clear();
}
void SMESHGUI_FilterDlg::SetSourceWg ( QWidget theWg,
const bool  initOnApply = true 
)
void SMESHGUI_FilterDlg::updateMainButtons ( ) [private]

Definition at line 2537 of file SMESHGUI_FilterDlg.cxx.

References BTN_Apply, BTN_Close, myButtons, and myTypes.

Referenced by createButtonFrame(), and Init().

{
  myButtons[ BTN_Close  ]->show();
  if (myTypes.count() == 1)
  {
    myButtons[ BTN_Apply  ]->hide();
  }
  else
  {
    myButtons[ BTN_Apply  ]->show();
  }
//  updateGeometry();
}
void SMESHGUI_FilterDlg::updateSelection ( ) [private]

Definition at line 3380 of file SMESHGUI_FilterDlg.cxx.

References SMESHGUI.activeStudy(), SMESHGUI_FilterTable.CurrentCell(), SMESH.FT_BelongToCylinder, SMESH.FT_BelongToGenSurface, SMESH.FT_BelongToGeom, SMESH.FT_BelongToPlane, SMESH.FT_LyingOnGeom, SMESHGUI_FilterTable.GetCriterionType(), myIsSelectionChanged, mySelectionMgr, mySMESHGUI, and myTable.

Referenced by Init(), onCriterionChanged(), onCurrentChanged(), and SetSelection().

{
  if (mySelectionMgr == 0)
    return;

//   TColStd_MapOfInteger allTypes;
//   for( int i=0; i<10; i++ )
//     allTypes.Add( i );
  SalomeApp_Study* aStudy = dynamic_cast<SalomeApp_Study*>( mySMESHGUI->application()->activeStudy() );
  if( !aStudy )
    return;


  mySelectionMgr->clearFilters();

  int aRow, aCol;
  
  bool isCurrentCell = myTable->CurrentCell(aRow, aCol);
  int aCriterionType = myTable->GetCriterionType(aRow);
  if ( isCurrentCell &&
      (aCriterionType == SMESH::FT_BelongToGeom ||
       aCriterionType == SMESH::FT_BelongToPlane ||
       aCriterionType == SMESH::FT_BelongToCylinder ||
       aCriterionType == SMESH::FT_BelongToGenSurface ||
       aCriterionType == SMESH::FT_LyingOnGeom))
  {
    if (aCriterionType == SMESH::FT_BelongToGeom ||
        aCriterionType == SMESH::FT_BelongToGenSurface ||
        aCriterionType == SMESH::FT_LyingOnGeom) {

      mySelectionMgr->installFilter(new GEOM_SelectionFilter( aStudy, true ));

    } else if (aCriterionType == SMESH::FT_BelongToPlane) {
      mySelectionMgr->installFilter(new GEOM_FaceFilter( aStudy, StdSelect_Plane ) );

    } else if (aCriterionType == SMESH::FT_BelongToCylinder) {
      mySelectionMgr->installFilter(new GEOM_FaceFilter( aStudy, StdSelect_Cylinder ) );
    }
    myIsSelectionChanged = true;

  }
  else
  {
    if (myIsSelectionChanged) {
      // mySelectionMgr->installFilter( new GEOM_TypeFilter( aStudy, -1 ) ); // This filter deactivates selection
      // Impossible to select any object in the OB on the second opening of FilterDlg
    }
  }
}

Field Documentation

Definition at line 299 of file SMESHGUI_FilterDlg.h.

Referenced by Init(), and onApply().

QMap<int, QPushButton*> SMESHGUI_FilterDlg.myButtons [private]
QMap< int, SMESH::Filter_var > SMESHGUI_FilterDlg.myFilter [private]

Definition at line 301 of file SMESHGUI_FilterDlg.h.

Referenced by construct(), and onHelp().

Definition at line 292 of file SMESHGUI_FilterDlg.h.

Referenced by filterSource(), and SetSourceWg().

Definition at line 298 of file SMESHGUI_FilterDlg.h.

Referenced by Init(), and onApply().

SALOME_DataMapOfIOMapOfInteger SMESHGUI_FilterDlg.myIObjects [private]

Definition at line 295 of file SMESHGUI_FilterDlg.h.

Referenced by filterSelectionSource(), Init(), onClose(), and SetSelection().

Definition at line 296 of file SMESHGUI_FilterDlg.h.

Referenced by Init(), and updateSelection().

Definition at line 277 of file SMESHGUI_FilterDlg.h.

Referenced by construct().

SMESH::SMESH_Mesh_var SMESHGUI_FilterDlg.myMesh [private]
LightApp_SelectionMgr* SMESHGUI_FilterDlg.mySelectionMgr [private]
SVTK_Selector* SMESHGUI_FilterDlg.mySelector [private]
QCheckBox* SMESHGUI_FilterDlg.mySetInViewer [private]

Definition at line 280 of file SMESHGUI_FilterDlg.h.

Referenced by createMainFrame(), Init(), insertFilterInViewer(), and onApply().

QButtonGroup* SMESHGUI_FilterDlg.mySourceGrp [private]

Definition at line 278 of file SMESHGUI_FilterDlg.h.

Referenced by createSourceGroup(), filterSource(), Init(), and onApply().

Definition at line 293 of file SMESHGUI_FilterDlg.h.

Referenced by filterSource(), Init(), and SetSourceWg().

QList<int> SMESHGUI_FilterDlg.myTypes [private]

Definition at line 287 of file SMESHGUI_FilterDlg.h.

Referenced by construct(), createMainFrame(), Init(), and updateMainButtons().

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