Salome HOME
Merge from BR_DEBUG_3_2_0b1
[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   
94 private slots:
95
96   void                        onOk();
97   bool                        onApply();
98   void                        onClose();
99   void                        onHelp();
100
101   void                        onDeactivate();
102   
103   void                        onBrowse();
104   void                        onReturnPressed();
105   void                        onFilterChanged( const QString& );
106   void                        onAddBtnPressed();
107   void                        onDeleteBtnPressed();
108   void                        onFilterNameChanged( const QString& );
109   void                        onEntityTypeChanged( const int );
110   void                        onNeedValidation();
111
112 private:
113
114   void                        construct( const QValueList<int>& types, const int mode ); 
115   QFrame*                     createButtonFrame( QWidget* );
116   QFrame*                     createMainFrame  ( QWidget* );
117   bool                        isValid( const bool theMess = true ) const;
118   bool                        isNameValid( const bool theMess = true ) const;
119   SMESH::Filter_ptr           createFilter( const int theType = -1 );
120   QStringList                 prepareFilters() const;
121   QString                     autoExtension( const QString& ) const;
122   bool                        setSelected( const QString& );
123   int                         getIndex( const QString& ) const;
124   void                        updateControlsVisibility();
125   void                        updateMainButtons();
126   void                        enableMainButtons();
127   void                        processNewLibrary();
128   QString                     getFileName() const;
129   void                        setFileName( const QString& txt, const bool autoExtension = true );
130   QStringList                 filterWildCards( const QString& theFilter ) const;
131   QString&                    getDefaultLibraryName() const;
132   QString                     getDefaultFilterName() const;
133   void                        addFilterToLib( const QString& name );
134   void                        updateList();
135   bool                        isPermissionValid( const bool theIsExistingOnly );
136
137 private:
138
139   QFrame*                     myMainFrame;
140   QMap<int, QPushButton*>     myButtons;
141   SMESHGUI_FilterTable*       myTable;
142   QLineEdit*                  myFileName;
143   QPushButton*                myOpenBtn;
144   QListBox*                   myListBox;
145   QPushButton*                myAddBtn;
146   QPushButton*                myDeleteBtn;
147   QGroupBox*                  myNameGrp;
148   QLineEdit*                  myName;
149   SMESHGUI*                   mySMESHGUI;
150
151   QValueList<int>             myTypes;
152   int                         myMode;
153       
154   SMESH::FilterLibrary_var    myLibrary;
155   QString                     myCurrFilterName;
156   int                         myCurrFilter;
157
158   QString                     myHelpFileName;
159 };
160
161 #endif