Salome HOME
Merge branch 'V9_9_BR'
[modules/smesh.git] / src / SMESHGUI / SMESHGUI_FilterLibraryDlg.h
1 // Copyright (C) 2007-2022  CEA/DEN, EDF R&D, OPEN CASCADE
2 //
3 // Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
5 //
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License, or (at your option) any later version.
10 //
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14 // Lesser General Public License for more details.
15 //
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
19 //
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
21 //
22
23 // SMESH SMESHGUI : GUI for SMESH component
24 // File   : SMESHGUI_FilterLibraryDlg.h
25 // Author : Sergey LITONIN, Open CASCADE S.A.S.
26 //
27 #ifndef SMESHGUI_FILTERLIBRARYDLG_H
28 #define SMESHGUI_FILTERLIBRARYDLG_H
29
30 // SMESH includes
31 #include "SMESH_SMESHGUI.hxx"
32
33 // Qt includes
34 #include <QDialog>
35 #include <QList>
36 #include <QMap>
37
38 // IDL includes
39 #include <SALOMEconfig.h>
40 #include CORBA_SERVER_HEADER(SMESH_Filter)
41
42 class QListWidget;
43 class QListWidgetItem;
44 class QLineEdit;
45 class QPushButton;
46 class SMESHGUI;
47 class SMESHGUI_FilterTable;
48
49 /*
50   Class       : SMESHGUI_FilterLibraryDlg
51   Description : Dialog to specify filters for VTK viewer
52 */
53
54 class SMESHGUI_EXPORT SMESHGUI_FilterLibraryDlg : public QDialog
55
56   Q_OBJECT
57   
58   // Buttons
59   enum { BTN_OK, BTN_Apply, BTN_Close, BTN_Help };
60
61   class Dialog;
62   
63 public:
64   
65   // Mode
66   enum { ADD_TO, COPY_FROM, EDIT };
67     
68 public:
69   SMESHGUI_FilterLibraryDlg( SMESHGUI*, QWidget*, const QList<int>&, const int );
70   SMESHGUI_FilterLibraryDlg( SMESHGUI*, QWidget*, const int, const int );
71   virtual ~SMESHGUI_FilterLibraryDlg();
72                             
73   void                        Init( const QList<int>&, const int );
74   void                        Init( const int, const int );
75   
76   const SMESHGUI_FilterTable* GetTable() const;
77   void                        SetTable( const SMESHGUI_FilterTable* );
78
79 private:
80   void                        enterEvent( QEvent* );            
81   void                        keyPressEvent( QKeyEvent* );
82   
83 protected slots:
84   virtual void                reject();
85
86 private slots:
87   void                        onOk();
88   bool                        onApply();
89   void                        onHelp();
90
91   void                        onDeactivate();
92   
93   void                        onBrowse();
94   void                        onReturnPressed();
95   void                        onFilterChanged();
96   void                        onAddBtnPressed();
97   void                        onDeleteBtnPressed();
98   void                        onFilterNameChanged( const QString& );
99   void                        onEntityTypeChanged( const int );
100   void                        onNeedValidation();
101   void                        onSelectionDone();
102
103 private:
104   void                        construct( const QList<int>&, const int ); 
105   QWidget*                    createButtonFrame( QWidget* );
106   QWidget*                    createMainFrame( QWidget* );
107   bool                        isValid( const bool = true ) const;
108   bool                        isNameValid( const bool = true ) const;
109   SMESH::Filter_ptr           createFilter( const int = -1 );
110   QStringList                 prepareFilters() const;
111   QString                     autoExtension( const QString& ) const;
112   bool                        setSelected( const QString& );
113   int                         getIndex( const QString& ) const;
114   void                        updateControlsVisibility();
115   void                        updateMainButtons();
116   void                        enableMainButtons();
117   void                        processNewLibrary();
118   QString                     getFileName() const;
119   void                        setFileName( const QString&, const bool = true );
120   QStringList                 filterWildCards( const QString& ) const;
121   QString&                    getDefaultLibraryName() const;
122   QString                     getDefaultFilterName() const;
123   void                        addFilterToLib( const QString& );
124   void                        updateList();
125   bool                        isPermissionValid( const bool );
126
127 private:
128
129   QWidget*                    myMainFrame;
130   QMap<int, QPushButton*>     myButtons;
131   SMESHGUI_FilterTable*       myTable;
132   QLineEdit*                  myFileName;
133   QPushButton*                myOpenBtn;
134   QListWidget*                myListBox;
135   QPushButton*                myAddBtn;
136   QPushButton*                myDeleteBtn;
137   QWidget*                    myNameGrp;
138   QLineEdit*                  myName;
139   SMESHGUI*                   mySMESHGUI;
140
141   QList<int>                  myTypes;
142   int                         myMode;
143       
144   SMESH::FilterLibrary_var    myLibrary;
145   QString                     myCurrFilterName;
146   int                         myCurrFilter;
147
148   QString                     myHelpFileName;
149 };
150
151 #endif // SMESHGUI_FILTERLIBRARYDLG_H