Salome HOME
bos #20256: [CEA 18523] Porting SMESH to int 64 bits
[modules/smesh.git] / src / SMESHGUI / SMESHGUI_FilterDlg.h
old mode 100755 (executable)
new mode 100644 (file)
index d74fc68..7bad381
-//  SMESH SMESHGUI : GUI for SMESH component
+// Copyright (C) 2007-2021  CEA/DEN, EDF R&D, OPEN CASCADE
 //
-//  Copyright (C) 2003  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
-//  CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS 
-// 
-//  This library is free software; you can redistribute it and/or 
-//  modify it under the terms of the GNU Lesser General Public 
-//  License as published by the Free Software Foundation; either 
-//  version 2.1 of the License. 
-// 
-//  This library is distributed in the hope that it will be useful, 
-//  but WITHOUT ANY WARRANTY; without even the implied warranty of 
-//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU 
-//  Lesser General Public License for more details. 
-// 
-//  You should have received a copy of the GNU Lesser General Public 
-//  License along with this library; if not, write to the Free Software 
-//  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA 
-// 
-//  See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org 
+// Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
 //
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
 //
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
 //
-//  File   : SMESHGUI_FilterDlg.h
-//  Author : Sergey LITONIN      
-//  Module : SMESH
-
 
-#ifndef SMESHGUI_FilterDlg_H
-#define SMESHGUI_FilterDlg_H
+// SMESH SMESHGUI : GUI for SMESH component
+// File   : SMESHGUI_FilterDlg.h
+// Author : Sergey LITONIN, Open CASCADE S.A.S.
+//
+#ifndef SMESHGUI_FILTERDLG_H
+#define SMESHGUI_FILTERDLG_H
 
-#include <qdialog.h>
-#include <qframe.h>
-#include <qmap.h>
-#include <qvaluelist.h>
+// SMESH includes
+#include "SMESH_SMESHGUI.hxx"
 
-#include "LightApp_SelectionMgr.h"
-#include "SALOME_InteractiveObject.hxx"
-#include "SALOME_DataMapOfIOMapOfInteger.hxx"
-#include "SVTK_Selection.h"
+// Qt includes
+#include <QWidget>
+#include <QDialog>
+#include <QMap>
+#include <QList>
 
-#include <TColStd_IndexedMapOfInteger.hxx>
+// SALOME GUI includes
+#include <SALOME_DataMapOfIOMapOfInteger.hxx>
+#include <SVTK_Selection.h>
+#include <SVTK_Hash.h>
 
+// IDL includes
 #include <SALOMEconfig.h>
 #include CORBA_SERVER_HEADER(SMESH_Filter)
 #include CORBA_SERVER_HEADER(SMESH_Mesh)
 
+class LightApp_SelectionMgr;
 class QButtonGroup;
 class QCheckBox;
-class QCloseEvent;
-class QComboBox;
-class QEvent;
+class QFrame;
 class QGroupBox;
 class QPushButton;
-class QStringList;
-class QTable;
-class QTableItem;
-class QWidgetStack;
-class LightApp_SelectionMgr;
+class QStackedWidget;
+class QTableWidget;
+class QTableWidgetItem;
 class SMESHGUI;
 class SMESHGUI_FilterLibraryDlg;
+class SMESH_Actor;
 class SVTK_Selector;
-class SVTK_ViewWindow;
+
+typedef NCollection_DataMap<Handle(SALOME_InteractiveObject), SVTK_TIndexedMapOfVtkId> SALOME_DataMapOfIOMapOfVtk;
+typedef SALOME_DataMapOfIOMapOfVtk::Iterator SALOME_DataMapIteratorOfIOMapOfVtk;
 
 /*!
  *  Class       : SMESHGUI_FilterTable
- *  Description : Frame containig 
+ *  Description : Frame containin
  *                  - Button group for switching entity type
  *                  - Table for displaying filter criterions
  *                  - Buttons for editing table
  */
 
-class SMESHGUI_FilterTable : public QFrame
+class SMESHGUI_EXPORT SMESHGUI_FilterTable : public QWidget
 {
   Q_OBJECT
 
   class Table;
   class ComboItem;
+  class IntSpinItem;
+  class DoubleSpinItem;
+  class CheckItem;
   class AdditionalWidget;
+  class ComboDelegate;
 
   typedef QMap<int, Table*> TableMap;
 
 public:  
-                            SMESHGUI_FilterTable( SMESHGUI*,
-                                                 QWidget* parent, 
-                                                  const int type);
-                            SMESHGUI_FilterTable( SMESHGUI*,
-                                                 QWidget* parent, 
-                                                  const QValueList<int>& type);
-  virtual                   ~SMESHGUI_FilterTable();
+  SMESHGUI_FilterTable( SMESHGUI*, QWidget*, const int );
+  SMESHGUI_FilterTable( SMESHGUI*, QWidget*, const QList<int>& );
+  virtual ~SMESHGUI_FilterTable();
 
-  void                      Init (const int type);
-  void                      Init (const QValueList<int>& types);
+  void                      Init( const QList<int>& );
 
   QGroupBox*                GetTableGrp();
 
-  bool                      IsValid (const bool = true, const int theEntityType = -1) const;
+  bool                      IsValid( const bool = true, const int = -1 ) const;
   int                       GetType() const;
-  void                      SetType (const int);
+  void                      SetType(const int);
   void                      RestorePreviousEntityType();
-  int                       NumRows (const int theEntityType = -1) const;
-  void                      Clear (const int theEntityType = -1);
-  void                      SetEditable (const bool);
-  void                      SetEnabled (const bool);
-  void                      SetLibsEnabled (const bool);
+  int                       NumRows( const int = -1 ) const;
+  void                      Clear( const int = -1 );
+  void                      SetEditable( const bool );
+  void                      SetEnabled( const bool );
+  void                      SetLibsEnabled( const bool );
   bool                      IsEditable() const;
 
-  int                       GetCriterionType (const int theRow, const int theType = -1) const;
+  int                       GetCriterionType( const int, const int = -1 ) const;
 
-  void                      GetCriterion (const int                 theRow,
-                                          SMESH::Filter::Criterion& theCriterion,
-                                          const int                 theEntityType = -1) const;
+  void                      GetCriterion( const int,
+                                          SMESH::Filter::Criterion&,
+                                          const int = -1 ) const;
 
-  void                      SetCriterion (const int                       theRow,
-                                          const SMESH::Filter::Criterion& theCriterion,
-                                          const int                       theEntityType = -1);
+  void                      SetCriterion( const int,
+                                          const SMESH::Filter::Criterion&,
+                                          const int = -1 );
 
-  void                      AddCriterion (const SMESH::Filter::Criterion& theCriterion,
-                                          const int    theEntityType = -1);
+  void                      AddCriterion( const SMESH::Filter::Criterion&,
+                                          const int = -1 );
 
-  void                      Copy (const SMESHGUI_FilterTable*);
-  void                      SetValidity (const bool);
+  void                      Copy( const SMESHGUI_FilterTable* );
+  void                      SetValidity( const bool );
 
-  bool                      CurrentCell (int& theRow, int& theCol) const;
-  void                      SetThreshold (const int      theRow,
-                                          const QString& theText,
-                                          const int      theEntityType = -1);
+  bool                      CurrentCell( int&, int& ) const;
+  void                      SetThreshold( const int,
+                                          const QString&,
+                                          const int = -1 );
 
-  bool                      GetThreshold (const int      theRow,
-                                          QString&       theText,
-                                          const int      theEntityType = -1);
+  bool                      GetThreshold( const int,
+                                          QString&,
+                                          const int = -1 );
 
-  void                      SetID( const int      theRow,
-                                  const QString& theText,
-                                  const int      theEntityType = -1 ); 
+  void                      SetID( const int,
+                                   const QString&,
+                                   const int = -1 ); 
   
-  bool                      GetID( const int      theRow,
-                                  QString&       theText,
-                                  const int      theEntityType = -1 );
+  bool                      GetID( const int,
+                                   QString&,
+                                   const int = -1 );
 
   void                      Update();
 
 signals:
-
   void                      CopyFromClicked();
   void                      AddToClicked();
-  void                      EntityTypeChanged (const int);
+  void                      EntityTypeChanged( const int );
   void                      NeedValidation();
-  void                      CriterionChanged (const int theRow, const int theEntityType);
-  void                      CurrentChanged (int, int);
+  void                      CriterionChanged( const int, const int );
+  void                      ThresholdChanged( const int, const int );
+  void                      CurrentChanged( int, int );
 
 private slots:
-
   void                      onAddBtn();
   void                      onInsertBtn();
   void                      onRemoveBtn();
   void                      onClearBtn();
   void                      onCopyFromBtn();
   void                      onAddToBtn();
-  void                      onCriterionChanged (int, int);
-  void                      onEntityType (int);
-  void                      onCurrentChanged (int, int);
+  void                      onCriterionChanged( int, int );
+  void                      onEntityType( int );
+  void                      onCurrentChanged( int, int );
 
 private:
-
-  void                      addRow (Table*, const int, const bool toTheEnd = true);
-  QTableItem*               getCriterionItem (QTable*, const int);
-  QTableItem*               getCompareItem (QTable*);
-  QTableItem*               getUnaryItem (QTable*);
-  QTableItem*               getBinaryItem (QTable*);
-  const QMap<int, QString>& getCriteria (const int theType) const;
+  void                      addRow( Table*, const int, const bool = true );
+  QTableWidgetItem*         getCriterionItem( const int ) const;
+  QTableWidgetItem*         getCompareItem() const;
+  QTableWidgetItem*         getUnaryItem() const;
+  QTableWidgetItem*         getBinaryItem() const;
+  const QMap<int, QString>& getCriteria( const int ) const;
   const QMap<int, QString>& getCompare() const;
-  Table*                    createTable (QWidget*, const int);
-  QWidget*                  createAdditionalFrame (QWidget* theParent);
+  Table*                    createTable( QWidget*, const int );
+  QWidget*                  createAdditionalFrame( QWidget* );
   int                       getFirstSelectedRow() const;
-  void                      onCriterionChanged (const int, const int, const int);
+  void                      onCriterionChanged( const int, const int, const int );
 
   void                      updateBtnState();
-  void                      removeAdditionalWidget (QTable* theTable, const int theRow);
+  void                      removeAdditionalWidget( QTableWidget*, const int );
   void                      updateAdditionalWidget();
+  const char*               getPrecision( const int );
 
   const QMap<int, QString>& getSupportedTypes() const;
 
@@ -185,7 +184,7 @@ private:
   SMESHGUI*                 mySMESHGUI;
 
   QGroupBox*                myTableGrp;
-  QGroupBox*                mySwitchTableGrp;
+  QWidget*                  mySwitchTableGrp;
 
   TableMap                  myTables;
   QPushButton*              myAddBtn;
@@ -195,6 +194,7 @@ private:
   QPushButton*              myCopyFromBtn;  
   QPushButton*              myAddToBtn;
 
+  QGroupBox*                myEntityTypeBox;
   QButtonGroup*             myEntityTypeGrp;
   int                       myEntityType;
   int                       myIsValid;
@@ -202,9 +202,9 @@ private:
 
   SMESHGUI_FilterLibraryDlg* myLibDlg;
 
-  QWidgetStack*              myWgStack;
+  QStackedWidget*           myWgStack;
 
-  QMap<QTableItem*, AdditionalWidget*> myAddWidgets;
+  QMap<QTableWidgetItem*, AdditionalWidget*> myAddWidgets;
 };
 
 
@@ -221,73 +221,77 @@ class SMESHGUI_FilterDlg : public QDialog
   enum { Mesh, Selection, Dialog, None };
 
   // Buttons
-  enum { BTN_OK, BTN_Cancel, BTN_Apply, BTN_Close };
+  enum { BTN_OK, BTN_Apply, BTN_Close, BTN_Help };
 
 public:
-                            SMESHGUI_FilterDlg( SMESHGUI*,
-                                                const QValueList<int>& types,
-                                                const char*            name = 0);
+  SMESHGUI_FilterDlg( SMESHGUI*, const QList<int>& );
+  SMESHGUI_FilterDlg( SMESHGUI*, const int );
+  virtual ~SMESHGUI_FilterDlg();
 
-                            SMESHGUI_FilterDlg( SMESHGUI*,
-                                                const int              type,
-                                                const char*            name = 0);
-  virtual                   ~SMESHGUI_FilterDlg();
-
-  void                      Init (const QValueList<int>& types);
-  void                      Init (const int type);
+  void                      Init( const QList<int>&, const bool setInViewer=true );
+  void                      Init( const int, const bool setInViewer=true );
 
   void                      SetSelection();
-  void                      SetMesh (SMESH::SMESH_Mesh_ptr);
-  void                      SetSourceWg (QWidget*);
+  void                      SetMesh (SMESH::SMESH_Mesh_var);
+  void                      SetGroup (SMESH::SMESH_GroupOnFilter_var);
+  void                      SetSourceWg( QWidget*, const bool initOnApply = true );
+  void                      SetEnabled( bool setInViewer, bool diffSources );
 
   static SMESH::Filter::Criterion createCriterion();
 
+  SMESH::Filter_var         GetFilter() const;
+  void                      SetFilter(SMESH::Filter_var filter, int type);
+  void                      UnRegisterFilters();
+
 signals:
 
   void                      Accepted();
 
+protected slots:
+  virtual void              reject();
+
 private slots:
 
   void                      onOk();
   bool                      onApply();
-  void                      onClose();
+  void                      onHelp();
   void                      onDeactivate();
   void                      onSelectionDone();
-  void                      onCriterionChanged (const int, const int);
-  void                      onCurrentChanged (int, int);
+  void                      onCriterionChanged( const int, const int );
+  void                      onThresholdChanged( const int, const int );
+  void                      onCurrentChanged( int, int );
+  void                      onOpenView();
+  void                      onCloseView();
 
 private:
 
-  void                      construct (const QValueList<int>& types); 
+  void                      construct( const QList<int>& ); 
 
-  void                      closeEvent (QCloseEvent*);
-  void                      enterEvent (QEvent*);
+  void                      enterEvent( QEvent* );
+  void                      keyPressEvent( QKeyEvent* );
 
   // dialog creation
-  QFrame*                   createButtonFrame (QWidget*);
-  QFrame*                   createMainFrame (QWidget*);
-  QButtonGroup*             createSourceGroup (QWidget*);
+  QWidget*                  createButtonFrame( QWidget* );
+  QWidget*                  createMainFrame( QWidget* );
+  QWidget*                  createSourceGroup( QWidget* );
   void                      updateMainButtons();
 
   // execution
   bool                      isValid() const;
-  bool                      createFilter (const int theType);
+  bool                      createFilter( const int );
   void                      insertFilterInViewer();
-  void                      selectInViewer (const int              theType,
-                                            const QValueList<int>& theIds);
-  void                      filterSource (const int        theType,
-                                          QValueList<int>& theResIds);
-  void                      filterSelectionSource (const int        theType,
-                                                   QValueList<int>& theResIds);
-  void                      getIdsFromWg (const QWidget*, QValueList<int>&) const;
-  void                      setIdsToWg (QWidget*, const QValueList<int>&);
-  Selection_Mode            getSelMode (const int) const;
+  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();
+  SMESH_Actor*              getActor();
 
 private:
-
   // widgets
-  QFrame*                   myMainFrame;
+  QWidget*                  myMainFrame;
   QButtonGroup*             mySourceGrp;
 
   QCheckBox*                mySetInViewer;
@@ -297,18 +301,28 @@ private:
   SMESHGUI_FilterTable*     myTable;
 
   // initial fields
-  QValueList<int>           myTypes;
+  QList<int>                myTypes;
   SMESHGUI*                 mySMESHGUI;
   LightApp_SelectionMgr*    mySelectionMgr;
   SVTK_Selector*            mySelector;
-  SMESH::SMESH_Mesh_ptr     myMesh;
+  SMESH::SMESH_Mesh_var     myMesh;
+  SMESH::SMESH_GroupOnFilter_var myGroup;
+  bool                      myInitSourceWgOnApply;
+  bool                      myInsertEnabled;
+  bool                      myDiffSourcesEnabled;
   QWidget*                  mySourceWg;
 
-  SALOME_DataMapOfIOMapOfInteger myIObjects;
+  SALOME_DataMapOfIOMapOfVtk     myIObjects;
   bool                           myIsSelectionChanged;
   QMap< int, SMESH::Filter_var > myFilter;
   QMap< int, bool >              myInsertState;
   QMap< int, int  >              myApplyToState;
+
+  QString                   myHelpFileName;
+
+  bool                      myToRestoreSelMode;
+  int                       mySelModeToRestore;
+  void                      restoreSelMode();
 };
 
-#endif
+#endif // SMESHGUI_FILTERDLG_H