Salome HOME
Join modifications from branch BR_3_1_0deb
[modules/smesh.git] / src / StdMeshersGUI / StdMeshersGUI_DistrTable.h
1 //  SMESH StdMeshersGUI
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   : StdMeshersGUI_DistrTable.h
25 //  Module : SMESH
26 //  $Header$
27
28 #ifndef StdMesherGUI_DistrTable_Header
29 #define StdMesherGUI_DistrTable_Header
30
31 #include <qtable.h>
32
33 #include <SALOMEconfig.h>
34 #include CORBA_SERVER_HEADER(SMESH_Mesh)
35
36 class QButton;
37 class QDoubleValidator;
38
39 /*!
40  *  \brief Values corresponding to buttons for table resize
41  */
42 typedef enum { INSERT_ROW, REMOVE_ROW } TableButton;
43
44 /*!
45  *  \brief This class represents custom table. It has only double values and
46     editor for every cell has validator
47  */
48 class StdMeshersGUI_DistrTable : public QTable
49 {
50   Q_OBJECT
51   
52 public:
53   StdMeshersGUI_DistrTable( const int rows, QWidget* = 0, const char* = 0 );
54   virtual ~StdMeshersGUI_DistrTable();
55
56 /*!
57  *  \brief Hides current editor of cell
58  */
59   void stopEditing( const bool accept );
60  
61   virtual QSize sizeHint() const;
62
63   static void sortData( SMESH::double_array& );
64
65   void data( SMESH::double_array& );
66   void setData( const SMESH::double_array& );
67
68 protected:
69   virtual QWidget* createEditor( int, int, bool ) const;
70   virtual bool     eventFilter( QObject*, QEvent* );
71   virtual void     keyPressEvent( QKeyEvent* );
72   virtual void     edit( const int, const int );
73
74 private slots:
75   void onEdit( TableButton, int );
76
77 private:
78   QDoubleValidator   *myArgV, *myFuncV;
79 };
80
81
82 /*!
83  *  \brief This class represents frame for table and buttons
84  */
85 class StdMeshersGUI_DistrTableFrame : public QFrame
86 {
87   Q_OBJECT
88
89 public:
90   StdMeshersGUI_DistrTableFrame( QWidget* );
91   ~StdMeshersGUI_DistrTableFrame();
92
93   StdMeshersGUI_DistrTable* table() const;
94
95 /*!
96  *  \brief Changes shown state of some button for table resize
97  */   
98   void setShown( const TableButton, const bool );
99
100 /*!
101  *  \brief Returns shown state of some button for table resize
102  */
103   bool isShown( const TableButton ) const;
104   
105 private:
106   QButton* button( const TableButton ) const;
107
108 private slots:
109   void onButtonClicked();
110   
111 signals:
112 /*!
113  *  \brief This signal is emitted if some of button for table resize is clicked
114  *         Second parameter is current row. Take into account that
115  *         this object resize table ( returned by table() ) automatically
116  */
117   void toEdit( TableButton, int );
118   void valueChanged( int, int );
119
120 private:
121   QButton                   *myInsertRow, *myRemoveRow;
122   StdMeshersGUI_DistrTable  *myTable;
123 };
124
125
126 #endif
127