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