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