Back to index

salome-smesh  6.5.0
SMESHGUI_FilterLibraryDlg.h
Go to the documentation of this file.
00001 // Copyright (C) 2007-2012  CEA/DEN, EDF R&D, OPEN CASCADE
00002 //
00003 // Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
00004 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
00005 //
00006 // This library is free software; you can redistribute it and/or
00007 // modify it under the terms of the GNU Lesser General Public
00008 // License as published by the Free Software Foundation; either
00009 // version 2.1 of the License.
00010 //
00011 // This library is distributed in the hope that it will be useful,
00012 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00013 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00014 // Lesser General Public License for more details.
00015 //
00016 // You should have received a copy of the GNU Lesser General Public
00017 // License along with this library; if not, write to the Free Software
00018 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
00019 //
00020 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
00021 //
00022 
00023 // SMESH SMESHGUI : GUI for SMESH component
00024 // File   : SMESHGUI_FilterLibraryDlg.h
00025 // Author : Sergey LITONIN, Open CASCADE S.A.S.
00026 //
00027 #ifndef SMESHGUI_FILTERLIBRARYDLG_H
00028 #define SMESHGUI_FILTERLIBRARYDLG_H
00029 
00030 // SMESH includes
00031 #include "SMESH_SMESHGUI.hxx"
00032 
00033 // Qt includes
00034 #include <QDialog>
00035 #include <QList>
00036 #include <QMap>
00037 
00038 // IDL includes
00039 #include <SALOMEconfig.h>
00040 #include CORBA_SERVER_HEADER(SMESH_Filter)
00041 
00042 class QListWidget;
00043 class QListWidgetItem;
00044 class QLineEdit;
00045 class QPushButton;
00046 class SMESHGUI;
00047 class SMESHGUI_FilterTable;
00048 
00049 /*
00050   Class       : SMESHGUI_FilterLibraryDlg
00051   Description : Dialog to specify filters for VTK viewer
00052 */
00053 
00054 class SMESHGUI_EXPORT SMESHGUI_FilterLibraryDlg : public QDialog
00055 { 
00056   Q_OBJECT
00057   
00058   // Buttons
00059   enum { BTN_OK, BTN_Apply, BTN_Close, BTN_Help };
00060 
00061   class Dialog;
00062   
00063 public:
00064   
00065   // Mode
00066   enum { ADD_TO, COPY_FROM, EDIT };
00067     
00068 public:
00069   SMESHGUI_FilterLibraryDlg( SMESHGUI*, QWidget*, const QList<int>&, const int );
00070   SMESHGUI_FilterLibraryDlg( SMESHGUI*, QWidget*, const int, const int );
00071   virtual ~SMESHGUI_FilterLibraryDlg();
00072                             
00073   void                        Init( const QList<int>&, const int );
00074   void                        Init( const int, const int );
00075   
00076   const SMESHGUI_FilterTable* GetTable() const;
00077   void                        SetTable( const SMESHGUI_FilterTable* );
00078 
00079 private:
00080   void                        closeEvent( QCloseEvent* );
00081   void                        enterEvent( QEvent* );            
00082   void                        keyPressEvent( QKeyEvent* );
00083   
00084 private slots:
00085   void                        onOk();
00086   bool                        onApply();
00087   void                        onClose();
00088   void                        onHelp();
00089 
00090   void                        onDeactivate();
00091   
00092   void                        onBrowse();
00093   void                        onReturnPressed();
00094   void                        onFilterChanged();
00095   void                        onAddBtnPressed();
00096   void                        onDeleteBtnPressed();
00097   void                        onFilterNameChanged( const QString& );
00098   void                        onEntityTypeChanged( const int );
00099   void                        onNeedValidation();
00100 
00101 private:
00102   void                        construct( const QList<int>&, const int ); 
00103   QWidget*                    createButtonFrame( QWidget* );
00104   QWidget*                    createMainFrame( QWidget* );
00105   bool                        isValid( const bool = true ) const;
00106   bool                        isNameValid( const bool = true ) const;
00107   SMESH::Filter_ptr           createFilter( const int = -1 );
00108   QStringList                 prepareFilters() const;
00109   QString                     autoExtension( const QString& ) const;
00110   bool                        setSelected( const QString& );
00111   int                         getIndex( const QString& ) const;
00112   void                        updateControlsVisibility();
00113   void                        updateMainButtons();
00114   void                        enableMainButtons();
00115   void                        processNewLibrary();
00116   QString                     getFileName() const;
00117   void                        setFileName( const QString&, const bool = true );
00118   QStringList                 filterWildCards( const QString& ) const;
00119   QString&                    getDefaultLibraryName() const;
00120   QString                     getDefaultFilterName() const;
00121   void                        addFilterToLib( const QString& );
00122   void                        updateList();
00123   bool                        isPermissionValid( const bool );
00124 
00125 private:
00126 
00127   QWidget*                    myMainFrame;
00128   QMap<int, QPushButton*>     myButtons;
00129   SMESHGUI_FilterTable*       myTable;
00130   QLineEdit*                  myFileName;
00131   QPushButton*                myOpenBtn;
00132   QListWidget*                myListBox;
00133   QPushButton*                myAddBtn;
00134   QPushButton*                myDeleteBtn;
00135   QWidget*                    myNameGrp;
00136   QLineEdit*                  myName;
00137   SMESHGUI*                   mySMESHGUI;
00138 
00139   QList<int>                  myTypes;
00140   int                         myMode;
00141       
00142   SMESH::FilterLibrary_var    myLibrary;
00143   QString                     myCurrFilterName;
00144   int                         myCurrFilter;
00145 
00146   QString                     myHelpFileName;
00147 };
00148 
00149 #endif // SMESHGUI_FILTERLIBRARYDLG_H