Salome HOME
12158bef8a66e7c7919ccb974ad2bbf3a7399886
[modules/smesh.git] / src / SMESHGUI / SMESHGUI_FilterLibraryDlg.h
1 // Copyright (C) 2007-2014  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
102 private:
103   void                        construct( const QList<int>&, const int ); 
104   QWidget*                    createButtonFrame( QWidget* );
105   QWidget*                    createMainFrame( QWidget* );
106   bool                        isValid( const bool = true ) const;
107   bool                        isNameValid( const bool = true ) const;
108   SMESH::Filter_ptr           createFilter( const int = -1 );
109   QStringList                 prepareFilters() const;
110   QString                     autoExtension( const QString& ) const;
111   bool                        setSelected( const QString& );
112   int                         getIndex( const QString& ) const;
113   void                        updateControlsVisibility();
114   void                        updateMainButtons();
115   void                        enableMainButtons();
116   void                        processNewLibrary();
117   QString                     getFileName() const;
118   void                        setFileName( const QString&, const bool = true );
119   QStringList                 filterWildCards( const QString& ) const;
120   QString&                    getDefaultLibraryName() const;
121   QString                     getDefaultFilterName() const;
122   void                        addFilterToLib( const QString& );
123   void                        updateList();
124   bool                        isPermissionValid( const bool );
125
126 private:
127
128   QWidget*                    myMainFrame;
129   QMap<int, QPushButton*>     myButtons;
130   SMESHGUI_FilterTable*       myTable;
131   QLineEdit*                  myFileName;
132   QPushButton*                myOpenBtn;
133   QListWidget*                myListBox;
134   QPushButton*                myAddBtn;
135   QPushButton*                myDeleteBtn;
136   QWidget*                    myNameGrp;
137   QLineEdit*                  myName;
138   SMESHGUI*                   mySMESHGUI;
139
140   QList<int>                  myTypes;
141   int                         myMode;
142       
143   SMESH::FilterLibrary_var    myLibrary;
144   QString                     myCurrFilterName;
145   int                         myCurrFilter;
146
147   QString                     myHelpFileName;
148 };
149
150 #endif // SMESHGUI_FILTERLIBRARYDLG_H