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