Back to index

salome-smesh  6.5.0
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]
Collaboration diagram for SMESHGUI_FilterDlg:
Collaboration graph
[legend]

List of all members.

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)
SMESH::Filter_var GetFilter () const
 Return the current filter.
void SetFilter (SMESH::Filter_var filter, int type)
 Sets a filter to the table.

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 *)
QWidget * createButtonFrame (QWidget *)
QWidget * createMainFrame (QWidget *)
QWidget * createSourceGroup (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

QWidget * myMainFrame
QButtonGroup * mySourceGrp
QCheckBox * mySetInViewer
QMap< int, QPushButton * > myButtons
SMESHGUI_FilterTable * myTable
QList< int > myTypes
SMESHGUI * mySMESHGUI
LightApp_SelectionMgr * mySelectionMgr
SVTK_Selector * mySelector
SMESH::SMESH_Mesh_var myMesh
bool myInitSourceWgOnApply
QWidget * mySourceWg
SALOME_DataMapOfIOMapOfInteger myIObjects
bool myIsSelectionChanged
QMap< int, SMESH::Filter_var > myFilter
QMap< int, bool > myInsertState
QMap< int, int > myApplyToState
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 2413 of file SMESHGUI_FilterDlg.cxx.

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

  construct(theTypes);
}

Here is the call graph for this function:

SMESHGUI_FilterDlg::SMESHGUI_FilterDlg ( SMESHGUI *  theModule,
const int  theType 
)

Definition at line 2430 of file SMESHGUI_FilterDlg.cxx.

: 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);
}

Here is the call graph for this function:

Definition at line 2603 of file SMESHGUI_FilterDlg.cxx.

{
}

Member Function Documentation

void SMESHGUI_FilterDlg::Accepted ( ) [signal]

Here is the caller graph for this function:

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

Definition at line 2787 of file SMESHGUI_FilterDlg.cxx.

{
  onClose();
}

Here is the call graph for this function:

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

Definition at line 2448 of file SMESHGUI_FilterDlg.cxx.

{
  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);
}

Here is the call graph for this function:

Here is the caller graph for this function:

QWidget * SMESHGUI_FilterDlg::createButtonFrame ( QWidget *  theParent) [private]

Definition at line 2569 of file SMESHGUI_FilterDlg.cxx.

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

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 3335 of file SMESHGUI_FilterDlg.cxx.

{
   SMESH::Filter::Criterion aCriterion;

  aCriterion.Type          = SMESH::FT_Undefined;
  aCriterion.Compare       = SMESH::FT_Undefined;
  aCriterion.Threshold     = 0;
  aCriterion.UnaryOp       = SMESH::FT_Undefined;
  aCriterion.BinaryOp      = SMESH::FT_Undefined;
  aCriterion.ThresholdStr  = "";
  aCriterion.ThresholdID   = "";
  aCriterion.TypeOfElement = SMESH::ALL;

  return aCriterion;
}

Here is the caller graph for this function:

bool SMESHGUI_FilterDlg::createFilter ( const int  theType) [private]

Definition at line 3069 of file SMESHGUI_FilterDlg.cxx.

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

Here is the call graph for this function:

Here is the caller graph for this function:

QWidget * SMESHGUI_FilterDlg::createMainFrame ( QWidget *  theParent) [private]

Definition at line 2477 of file SMESHGUI_FilterDlg.cxx.

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

Here is the call graph for this function:

Here is the caller graph for this function:

QWidget * SMESHGUI_FilterDlg::createSourceGroup ( QWidget *  theParent) [private]

Definition at line 2521 of file SMESHGUI_FilterDlg.cxx.

{
  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);

  aMeshBtn->setChecked(true);

  return aBox;
}

Here is the caller graph for this function:

void SMESHGUI_FilterDlg::enterEvent ( QEvent *  ) [private]

Definition at line 2775 of file SMESHGUI_FilterDlg.cxx.

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

Definition at line 3206 of file SMESHGUI_FilterDlg.cxx.

{
  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();
  myFilter[ theType ]->SetMesh(myMesh);
  TColStd_MapIteratorOfMapOfInteger aResIter(aToBeFiltered);
  for ( ; aResIter.More(); aResIter.Next())
    if (aPred->IsSatisfy(aResIter.Key()))
      theResIds.append(aResIter.Key());
}

Here is the call graph for this function:

Here is the caller graph for this function:

void SMESHGUI_FilterDlg::filterSource ( const int  theType,
QList< int > &  theResIds 
) [private]

Definition at line 3156 of file SMESHGUI_FilterDlg.cxx.

{
  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();
    myFilter[ theType ]->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);
}

Here is the call graph for this function:

Here is the caller graph for this function:

SMESH::Filter_var SMESHGUI_FilterDlg::GetFilter ( ) const

Return the current filter.

Definition at line 3105 of file SMESHGUI_FilterDlg.cxx.

{
  SMESH::Filter_var filter;
  try {
    int aCurrType = myTable->GetType();
    filter = myFilter[ aCurrType ];
  }
  catch(...)
  {
  }
  return filter._retn();
}

Here is the caller graph for this function:

void SMESHGUI_FilterDlg::getIdsFromWg ( const QWidget *  theWg,
QList< int > &  theRes 
) const [private]

Definition at line 2796 of file SMESHGUI_FilterDlg.cxx.

{
  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();
      }
    }
  }
}

Here is the caller graph for this function:

Selection_Mode SMESHGUI_FilterDlg::getSelMode ( const int  theType) const [private]

Definition at line 2838 of file SMESHGUI_FilterDlg.cxx.

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

}

Here is the caller graph for this function:

void SMESHGUI_FilterDlg::Init ( const QList< int > &  theTypes)

Definition at line 2622 of file SMESHGUI_FilterDlg.cxx.

{
  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() ] :
                      Mesh)->setChecked(true);
}

Here is the call graph for this function:

Here is the caller graph for this function:

void SMESHGUI_FilterDlg::Init ( const int  type)

Definition at line 2611 of file SMESHGUI_FilterDlg.cxx.

{
  QList<int> aTypes;
  aTypes.append(type);
  Init(aTypes);
}

Here is the call graph for this function:

Definition at line 3133 of file SMESHGUI_FilterDlg.cxx.

{
  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);
    }
  }
}

Here is the call graph for this function:

Here is the caller graph for this function:

bool SMESHGUI_FilterDlg::isValid ( ) const [private]

Definition at line 2880 of file SMESHGUI_FilterDlg.cxx.

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

Here is the call graph for this function:

Here is the caller graph for this function:

void SMESHGUI_FilterDlg::keyPressEvent ( QKeyEvent *  e) [private]

Definition at line 3476 of file SMESHGUI_FilterDlg.cxx.

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

  if ( e->key() == Qt::Key_F1 ) {
    e->accept();
    onHelp();
  }
}

Here is the call graph for this function:

bool SMESHGUI_FilterDlg::onApply ( ) [private, slot]

Definition at line 3030 of file SMESHGUI_FilterDlg.cxx.

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

Here is the call graph for this function:

Here is the caller graph for this function:

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

Definition at line 2706 of file SMESHGUI_FilterDlg.cxx.

{
  // 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;
}

Here is the call graph for this function:

Here is the caller graph for this function:

void SMESHGUI_FilterDlg::onCriterionChanged ( const int  ,
const int   
) [private, slot]

Definition at line 3404 of file SMESHGUI_FilterDlg.cxx.

Here is the call graph for this function:

Here is the caller graph for this function:

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

Definition at line 3413 of file SMESHGUI_FilterDlg.cxx.

Here is the call graph for this function:

Here is the caller graph for this function:

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

Definition at line 2766 of file SMESHGUI_FilterDlg.cxx.

{
  setEnabled(false);
}

Here is the caller graph for this function:

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

Definition at line 2742 of file SMESHGUI_FilterDlg.cxx.

{
  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));
  }
}

Here is the caller graph for this function:

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

Definition at line 2689 of file SMESHGUI_FilterDlg.cxx.

{
  if (onApply())
  {
    mySelectionMgr->clearFilters();
    disconnect(mySMESHGUI, 0, this, 0);
    disconnect(mySelectionMgr, 0, this, 0);
    mySMESHGUI->ResetState();
    accept();
    emit Accepted();
  }
}

Here is the call graph for this function:

Here is the caller graph for this function:

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

Definition at line 3357 of file SMESHGUI_FilterDlg.cxx.

{
  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());
    }
  }
}

Here is the call graph for this function:

Here is the caller graph for this function:

void SMESHGUI_FilterDlg::selectInViewer ( const int  theType,
const QList< int > &  theIds 
) [private]

Definition at line 3275 of file SMESHGUI_FilterDlg.cxx.

{
  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);
}

Here is the call graph for this function:

Here is the caller graph for this function:

void SMESHGUI_FilterDlg::SetFilter ( SMESH::Filter_var  filter,
int  type 
)

Sets a filter to the table.

Definition at line 3124 of file SMESHGUI_FilterDlg.cxx.

{
  myFilter[ type ] = filter;
}

Here is the caller graph for this function:

void SMESHGUI_FilterDlg::setIdsToWg ( QWidget *  theWg,
const QList< int > &  theIds 
) [private]

Definition at line 2856 of file SMESHGUI_FilterDlg.cxx.

{
  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(" "));
  }
}

Here is the caller graph for this function:

void SMESHGUI_FilterDlg::SetMesh ( SMESH::SMESH_Mesh_var  theMesh)

Definition at line 2986 of file SMESHGUI_FilterDlg.cxx.

{
  if ( !theMesh->_is_nil() ) {
    myMesh = theMesh;
    if ( !myFilter[ myTable->GetType() ]->_is_nil())
      myFilter[ myTable->GetType() ]->SetMesh( theMesh );
  }
  const bool isEnable = !(myMesh->_is_nil());
  myButtons[BTN_OK]->setEnabled(isEnable);
  myButtons[BTN_Apply]->setEnabled(isEnable);
}

Definition at line 3002 of file SMESHGUI_FilterDlg.cxx.

{
  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();
}

Here is the call graph for this function:

void SMESHGUI_FilterDlg::SetSourceWg ( QWidget *  theWg,
const bool  initOnApply = true 
)

Definition at line 2975 of file SMESHGUI_FilterDlg.cxx.

{
  mySourceWg = theWg;
  myInitSourceWgOnApply = initOnApply;
}

Definition at line 2551 of file SMESHGUI_FilterDlg.cxx.

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

Here is the caller graph for this function:

Definition at line 3422 of file SMESHGUI_FilterDlg.cxx.

{
  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
    }
  }
}

Here is the caller graph for this function:


Member Data Documentation

QMap< int, int > SMESHGUI_FilterDlg::myApplyToState [private]

Definition at line 302 of file SMESHGUI_FilterDlg.h.

QMap<int, QPushButton*> SMESHGUI_FilterDlg::myButtons [private]

Definition at line 285 of file SMESHGUI_FilterDlg.h.

QMap< int, SMESH::Filter_var > SMESHGUI_FilterDlg::myFilter [private]

Definition at line 300 of file SMESHGUI_FilterDlg.h.

Definition at line 304 of file SMESHGUI_FilterDlg.h.

Definition at line 295 of file SMESHGUI_FilterDlg.h.

QMap< int, bool > SMESHGUI_FilterDlg::myInsertState [private]

Definition at line 301 of file SMESHGUI_FilterDlg.h.

SALOME_DataMapOfIOMapOfInteger SMESHGUI_FilterDlg::myIObjects [private]

Definition at line 298 of file SMESHGUI_FilterDlg.h.

Definition at line 299 of file SMESHGUI_FilterDlg.h.

QWidget* SMESHGUI_FilterDlg::myMainFrame [private]

Definition at line 280 of file SMESHGUI_FilterDlg.h.

SMESH::SMESH_Mesh_var SMESHGUI_FilterDlg::myMesh [private]

Definition at line 294 of file SMESHGUI_FilterDlg.h.

LightApp_SelectionMgr* SMESHGUI_FilterDlg::mySelectionMgr [private]

Definition at line 292 of file SMESHGUI_FilterDlg.h.

SVTK_Selector* SMESHGUI_FilterDlg::mySelector [private]

Definition at line 293 of file SMESHGUI_FilterDlg.h.

QCheckBox* SMESHGUI_FilterDlg::mySetInViewer [private]

Definition at line 283 of file SMESHGUI_FilterDlg.h.

SMESHGUI* SMESHGUI_FilterDlg::mySMESHGUI [private]

Definition at line 291 of file SMESHGUI_FilterDlg.h.

QButtonGroup* SMESHGUI_FilterDlg::mySourceGrp [private]

Definition at line 281 of file SMESHGUI_FilterDlg.h.

QWidget* SMESHGUI_FilterDlg::mySourceWg [private]

Definition at line 296 of file SMESHGUI_FilterDlg.h.

SMESHGUI_FilterTable* SMESHGUI_FilterDlg::myTable [private]

Definition at line 287 of file SMESHGUI_FilterDlg.h.

QList<int> SMESHGUI_FilterDlg::myTypes [private]

Definition at line 290 of file SMESHGUI_FilterDlg.h.


The documentation for this class was generated from the following files: