Salome HOME
Merging with WPdev
[modules/smesh.git] / src / SMESHGUI / SMESHGUI_FilterLibraryDlg.h
1 //  SMESH SMESHGUI : GUI for SMESH component
2 //
3 //  Copyright (C) 2003  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. 
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 //
24 //  File   : SMESHGUI_FilterLibraryDlg.h
25 //  Author : Sergey LITONIN
26 //  Module : SMESH
27
28
29 #ifndef SMESHGUI_FilterLibraryDlg_H
30 #define SMESHGUI_FilterLibraryDlg_H
31
32 #include "SMESH_SMESHGUI.hxx"
33
34 #include <qdialog.h>
35 #include <SMESHGUI_FilterDlg.h>
36
37 #include <SALOMEconfig.h>
38 #include CORBA_SERVER_HEADER(SMESH_Filter)
39
40 class QCloseEvent;
41 class QListBox;
42 class QFrame;
43 class QEvent;
44 class QLineEdit;
45 class QPushButton;
46 class QGroupBox;
47
48 /*
49   Class       : SMESHGUI_FilterLibraryDlg
50   Description : Dialog to specify filters for VTK viewer
51 */
52
53 class SMESHGUI_EXPORT SMESHGUI_FilterLibraryDlg : public QDialog
54
55   Q_OBJECT
56   
57   // Buttons
58   enum { BTN_OK, BTN_Cancel, BTN_Apply, BTN_Close, BTN_Help };
59
60   class Dialog;
61   
62 public:
63   
64   // Mode
65   enum { ADD_TO, COPY_FROM, EDIT };
66     
67 public:
68   
69                               SMESHGUI_FilterLibraryDlg( SMESHGUI*,
70                                                          QWidget*,
71                                                          const QValueList<int>& types,
72                                                          const int              mode,
73                                                          const char*            name = 0 );
74                                                 
75                               SMESHGUI_FilterLibraryDlg( SMESHGUI*,
76                                                          QWidget*,
77                                                          const int              type,
78                                                          const int              mode,
79                                                          const char*            name = 0 );
80                                                          
81   virtual                     ~SMESHGUI_FilterLibraryDlg();
82                             
83   void                        Init( const QValueList<int>& types, const int theMode );
84   void                        Init( const int type, const int theMode );
85   
86   const SMESHGUI_FilterTable* GetTable() const;
87   void                        SetTable( const SMESHGUI_FilterTable* );
88
89 private:
90
91   void                        closeEvent( QCloseEvent* e ) ;
92   void                        enterEvent ( QEvent * ) ;            
93   void                        keyPressEvent( QKeyEvent* e );
94   
95 private slots:
96
97   void                        onOk();
98   bool                        onApply();
99   void                        onClose();
100   void                        onHelp();
101
102   void                        onDeactivate();
103   
104   void                        onBrowse();
105   void                        onReturnPressed();
106   void                        onFilterChanged( const QString& );
107   void                        onAddBtnPressed();
108   void                        onDeleteBtnPressed();
109   void                        onFilterNameChanged( const QString& );
110   void                        onEntityTypeChanged( const int );
111   void                        onNeedValidation();
112
113 private:
114
115   void                        construct( const QValueList<int>& types, const int mode ); 
116   QFrame*                     createButtonFrame( QWidget* );
117   QFrame*                     createMainFrame  ( QWidget* );
118   bool                        isValid( const bool theMess = true ) const;
119   bool                        isNameValid( const bool theMess = true ) const;
120   SMESH::Filter_ptr           createFilter( const int theType = -1 );
121   QStringList                 prepareFilters() const;
122   QString                     autoExtension( const QString& ) const;
123   bool                        setSelected( const QString& );
124   int                         getIndex( const QString& ) const;
125   void                        updateControlsVisibility();
126   void                        updateMainButtons();
127   void                        enableMainButtons();
128   void                        processNewLibrary();
129   QString                     getFileName() const;
130   void                        setFileName( const QString& txt, const bool autoExtension = true );
131   QStringList                 filterWildCards( const QString& theFilter ) const;
132   QString&                    getDefaultLibraryName() const;
133   QString                     getDefaultFilterName() const;
134   void                        addFilterToLib( const QString& name );
135   void                        updateList();
136   bool                        isPermissionValid( const bool theIsExistingOnly );
137
138 private:
139
140   QFrame*                     myMainFrame;
141   QMap<int, QPushButton*>     myButtons;
142   SMESHGUI_FilterTable*       myTable;
143   QLineEdit*                  myFileName;
144   QPushButton*                myOpenBtn;
145   QListBox*                   myListBox;
146   QPushButton*                myAddBtn;
147   QPushButton*                myDeleteBtn;
148   QGroupBox*                  myNameGrp;
149   QLineEdit*                  myName;
150   SMESHGUI*                   mySMESHGUI;
151
152   QValueList<int>             myTypes;
153   int                         myMode;
154       
155   SMESH::FilterLibrary_var    myLibrary;
156   QString                     myCurrFilterName;
157   int                         myCurrFilter;
158
159   QString                     myHelpFileName;
160 };
161
162 #endif