X-Git-Url: http://git.salome-platform.org/gitweb/?p=modules%2Fsmesh.git;a=blobdiff_plain;f=src%2FSMESHGUI%2FSMESHGUI_FilterDlg.h;h=5c1cfd5b56aad8d9934eb542d241ebf4ae667b04;hp=6ba1d4a79299f4419541b16d8f4abfdddfe4c7b1;hb=57b43b4d010e2d0a1529d3c131bbb9d416e63258;hpb=c3bf92bd87b770fd81631a3853f7f5bb1ac6a4e8 diff --git a/src/SMESHGUI/SMESHGUI_FilterDlg.h b/src/SMESHGUI/SMESHGUI_FilterDlg.h index 6ba1d4a79..5c1cfd5b5 100755 --- a/src/SMESHGUI/SMESHGUI_FilterDlg.h +++ b/src/SMESHGUI/SMESHGUI_FilterDlg.h @@ -1,195 +1,317 @@ -// SMESH SMESHGUI : GUI for SMESH component -// -// 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 -// -// -// -// File : SMESHGUI_FilterDlg.h -// Author : Sergey LITONIN -// Module : SMESH - - -#ifndef SMESHGUI_FilterDlg_H -#define SMESHGUI_FilterDlg_H - -#include -#include -#include -#include - -#include -#include CORBA_SERVER_HEADER(SMESH_Filter) -#include CORBA_SERVER_HEADER(SMESH_Mesh) - -class QCloseEvent; -class QWidgetStack; -class QStringList; -class QTableItem; -class QFrame; -class QEvent; -class QPushButton; -class QTable; -class SALOME_Selection; -class SMESHGUI; -class QComboBox; -class QButtonGroup; -class QCheckBox; -class QGroupBox; - - -/* - Class : SMESHGUI_FilterDlg - Description : Dialog to specify filters for VTK viewer -*/ - -class SMESHGUI_FilterDlg : public QDialog -{ - Q_OBJECT - - class Table; - - // Edge criteria - enum { FreeBorders = 0, MultiBorders, Length }; - - // Face criteria - enum { AspectRatio = 0, Warping, MinimumAngle, Taper, Skew, Area }; - - // Comparision - enum { LessThan = 0, MoreThan, EqualTo }; - - // Logical operations - enum { LO_And = 0, LO_Or, LO_Undefined }; - - // Source elements to be selected - enum { Mesh, Selection, Dialog, None }; - - typedef QMap TableMap; - -public: - SMESHGUI_FilterDlg( QWidget* parent, - const int type, - const bool theModal = true, - const char* name = 0 ); - virtual ~SMESHGUI_FilterDlg(); - - void Init( const int type ); - - void SetSelection( SALOME_Selection* ); - void SetMesh( SMESH::SMESH_Mesh_ptr ); - void SetSourceWg( QWidget* ); - -private slots: - - void onAddBtn(); - void onRemoveBtn(); - void onClearBtn(); - void onCriterionChanged( int, int ); - - void onOk(); - bool onApply(); - void onClose(); - void onDeactivate(); - -private: - - void closeEvent( QCloseEvent* e ); - void enterEvent ( QEvent * ); - - void updateBtnState(); - - // dialog creation - QFrame* createButtonFrame( QWidget*, const bool ); - QFrame* createMainFrame( QWidget* ); - Table* createTable( QWidget*, const int ); - QButtonGroup* createSourceGroup( QWidget* ); - void addRow( Table*, const int ); - QTableItem* getCriterionItem( QTable*, const int ); - QTableItem* getCompareItem( QTable* ); - QTableItem* getNotItem( QTable* ); - QTableItem* getLogOpItem( QTable* ); - const QStringList& getCriteria( const int theType ) const; - const QStringList& getCompare () const; - - // query - int getCurrType() const; - int getCriterion( const int theType, const int theRow ) const; - - // execution - bool isValid() const; - SMESH::Predicate_ptr createPredicate( const int theType ); - void insertFilterInViewer( SMESH::Predicate_ptr thePred ); - void selectInViewer( const int theType, - const QValueList& theIds ); - void filterSource( const int theType, - SMESH::Predicate_ptr thePred, - QValueList& theResIds ); - void filterSelectionSource( const int theType, - SMESH::Predicate_ptr thePred, - QValueList& theResIds ); - void getIdsFromWg( const QWidget*, QValueList& ) const; - void setIdsToWg( QWidget*, const QValueList& ); - Selection_Mode getSelMode( const int ) const; - -private: - - // widgets - QFrame* myMainFrame; - QGroupBox* myTableGrp; - - TableMap myTables; - QPushButton* myAddBtn; - QPushButton* myRemoveBtn; - QPushButton* myClearBtn; - QButtonGroup* mySourceGrp; - QCheckBox* mySetInViewer; - - QPushButton* myOkBtn; - QPushButton* myApplyBtn; - QPushButton* myCloseBtn; - - // initial fields - int myType; - SMESHGUI* mySMESHGUI; - SALOME_Selection* mySelection; - SMESH::SMESH_Mesh_ptr myMesh; - QWidget* mySourceWg; -}; - -#endif - - - - - - - - - - - - - - - - - - - - +// SMESH SMESHGUI : GUI for SMESH component +// +// 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 +// +// +// +// File : SMESHGUI_FilterDlg.h +// Author : Sergey LITONIN +// Module : SMESH + + +#ifndef SMESHGUI_FilterDlg_H +#define SMESHGUI_FilterDlg_H + +#include +#include +#include +#include + +#include "LightApp_SelectionMgr.h" +#include "SALOME_InteractiveObject.hxx" +#include "SALOME_DataMapOfIOMapOfInteger.hxx" +#include "SVTK_Selection.h" + +#include + +#include +#include CORBA_SERVER_HEADER(SMESH_Filter) +#include CORBA_SERVER_HEADER(SMESH_Mesh) + +class QButtonGroup; +class QCheckBox; +class QCloseEvent; +class QComboBox; +class QEvent; +class QGroupBox; +class QPushButton; +class QStringList; +class QTable; +class QTableItem; +class QWidgetStack; +class LightApp_SelectionMgr; +class SMESHGUI; +class SMESHGUI_FilterLibraryDlg; +class SVTK_Selector; +class SVTK_ViewWindow; + +/*! + * Class : SMESHGUI_FilterTable + * Description : Frame containig + * - Button group for switching entity type + * - Table for displaying filter criterions + * - Buttons for editing table + */ + +class SMESHGUI_FilterTable : public QFrame +{ + Q_OBJECT + + class Table; + class ComboItem; + class AdditionalWidget; + + typedef QMap TableMap; + +public: + SMESHGUI_FilterTable( SMESHGUI*, + QWidget* parent, + const int type); + SMESHGUI_FilterTable( SMESHGUI*, + QWidget* parent, + const QValueList& type); + virtual ~SMESHGUI_FilterTable(); + + void Init (const int type); + void Init (const QValueList& types); + + QGroupBox* GetTableGrp(); + + bool IsValid (const bool = true, const int theEntityType = -1) const; + int GetType() const; + 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); + bool IsEditable() const; + + int GetCriterionType (const int theRow, const int theType = -1) const; + + void GetCriterion (const int theRow, + SMESH::Filter::Criterion& theCriterion, + const int theEntityType = -1) const; + + void SetCriterion (const int theRow, + const SMESH::Filter::Criterion& theCriterion, + const int theEntityType = -1); + + void AddCriterion (const SMESH::Filter::Criterion& theCriterion, + const int theEntityType = -1); + + 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 GetThreshold (const int theRow, + QString& theText, + const int theEntityType = -1); + + void SetID( const int theRow, + const QString& theText, + const int theEntityType = -1 ); + + bool GetID( const int theRow, + QString& theText, + const int theEntityType = -1 ); + + void Update(); + +signals: + + void CopyFromClicked(); + void AddToClicked(); + void EntityTypeChanged (const int); + void NeedValidation(); + void CriterionChanged (const int theRow, const int theEntityType); + 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); + +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& getCriteria (const int theType) const; + const QMap& getCompare() const; + Table* createTable (QWidget*, const int); + QWidget* createAdditionalFrame (QWidget* theParent); + int getFirstSelectedRow() const; + void onCriterionChanged (const int, const int, const int); + + void updateBtnState(); + void removeAdditionalWidget (QTable* theTable, const int theRow); + void updateAdditionalWidget(); + + const QMap& getSupportedTypes() const; + +private: + SMESHGUI* mySMESHGUI; + + QGroupBox* myTableGrp; + QGroupBox* mySwitchTableGrp; + + TableMap myTables; + QPushButton* myAddBtn; + QPushButton* myInsertBtn; + QPushButton* myRemoveBtn; + QPushButton* myClearBtn; + QPushButton* myCopyFromBtn; + QPushButton* myAddToBtn; + + QButtonGroup* myEntityTypeGrp; + int myEntityType; + int myIsValid; + bool myIsLocked; + + SMESHGUI_FilterLibraryDlg* myLibDlg; + + QWidgetStack* myWgStack; + + QMap myAddWidgets; +}; + + +/*! + * Class : SMESHGUI_FilterDlg + * Description : Dialog to specify filters for VTK viewer + */ + +class SMESHGUI_FilterDlg : public QDialog +{ + Q_OBJECT + + // Source elements to be selected + enum { Mesh, Selection, Dialog, None }; + + // Buttons + enum { BTN_OK, BTN_Cancel, BTN_Apply, BTN_Close, BTN_Help }; + +public: + SMESHGUI_FilterDlg( SMESHGUI*, + const QValueList& types, + const char* name = 0); + + SMESHGUI_FilterDlg( SMESHGUI*, + const int type, + const char* name = 0); + virtual ~SMESHGUI_FilterDlg(); + + void Init (const QValueList& types); + void Init (const int type); + + void SetSelection(); + void SetMesh (SMESH::SMESH_Mesh_ptr); + void SetSourceWg (QWidget*); + + static SMESH::Filter::Criterion createCriterion(); + +signals: + + void Accepted(); + +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: + + void construct (const QValueList& types); + + void closeEvent (QCloseEvent*); + void enterEvent (QEvent*); + + // dialog creation + QFrame* createButtonFrame (QWidget*); + QFrame* createMainFrame (QWidget*); + QButtonGroup* createSourceGroup (QWidget*); + void updateMainButtons(); + + // execution + bool isValid() const; + bool createFilter (const int theType); + void insertFilterInViewer(); + void selectInViewer (const int theType, + const QValueList& theIds); + void filterSource (const int theType, + QValueList& theResIds); + void filterSelectionSource (const int theType, + QValueList& theResIds); + void getIdsFromWg (const QWidget*, QValueList&) const; + void setIdsToWg (QWidget*, const QValueList&); + Selection_Mode getSelMode (const int) const; + void updateSelection(); + +private: + + // widgets + QFrame* myMainFrame; + QButtonGroup* mySourceGrp; + + QCheckBox* mySetInViewer; + + QMap myButtons; + + SMESHGUI_FilterTable* myTable; + + // initial fields + QValueList myTypes; + SMESHGUI* mySMESHGUI; + LightApp_SelectionMgr* mySelectionMgr; + SVTK_Selector* mySelector; + SMESH::SMESH_Mesh_ptr myMesh; + QWidget* mySourceWg; + + SALOME_DataMapOfIOMapOfInteger myIObjects; + bool myIsSelectionChanged; + QMap< int, SMESH::Filter_var > myFilter; + QMap< int, bool > myInsertState; + QMap< int, int > myApplyToState; + + QString myHelpFileName; +}; + +#endif