Salome HOME
4900658f9a2b2c58ac5171a1c958283437d7025e
[modules/visu.git] / src / VISUGUI / VisuGUI_SelectionPanel.h
1 // Copyright (C) 2007-2011  CEA/DEN, EDF R&D, OPEN CASCADE
2 //
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License.
7 //
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
11 // Lesser General Public License for more details.
12 //
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
16 //
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
18 //
19
20 //  VISU VISUGUI : GUI of VISU component
21 //  File   : VisuGUI_SelectionPanel.h
22 //  Author : Laurent CORNABE & Hubert ROLLAND 
23 //  Module : VISU
24 //  $Header$
25 //
26 #ifndef VISUGUI_SELECTIONPANEL_H
27 #define VISUGUI_SELECTIONPANEL_H
28
29 #include "VisuGUI_Panel.h"
30
31 #include <QMap>
32
33 #include <vtkSystemIncludes.h>
34
35 class QLabel;
36 class QLineEdit;
37 class QModelIndex;
38 class QStackedWidget;
39 class QTableWidget;
40 class QTabWidget;
41
42 class VisuGUI_GaussPointsSelectionPane;
43 class VisuGUI_FindPane;
44 class VisuGUI_SelectionPrefDlg;
45
46 typedef vtkIdType TPointID;
47 typedef vtkIdType TCellID;
48
49 struct TValueData
50 {
51   QString Scalar;
52   QString Vector;
53 };
54
55 struct TPointData
56 {
57   vtkFloatingPointType X;
58   vtkFloatingPointType Y;
59   vtkFloatingPointType Z;
60   vtkIdType I;
61   vtkIdType J;
62   vtkIdType K;
63   TValueData ValueData;
64 };
65
66 typedef QMap<TPointID, TPointData> TPointDataMap;
67 typedef QMap<TCellID,  TValueData> TCellDataMap;
68
69 struct TCellToPointData
70 {
71   TValueData CellData;
72   TPointDataMap PointDataMap;
73 };
74
75 struct TPointToCellData
76 {
77   TPointData PointData;
78   TCellDataMap CellDataMap;
79 };
80   
81 typedef QMap<TCellID,  TCellToPointData> TCellToPointDataMap;
82 typedef QMap<TPointID, TPointToCellData> TPointToCellDataMap;
83
84 class VisuGUI_SelectionPanel: public VisuGUI_Panel
85 {
86   Q_OBJECT
87
88   enum MeshType { StdMesh = 0, ElnoMesh };
89   enum TableId { CellStdCell = 0, CellStdPoint, PointStd, CellElno, PointElno };
90   enum ColumnId { Cell = 0, Point, X, Y, Z, I, J, K, Scalar, Vector };
91
92 public:
93   VisuGUI_SelectionPanel( VisuGUI* theModule, QWidget* theParent = 0 );
94   virtual ~VisuGUI_SelectionPanel ();
95
96 public:
97   void                      setSelectionMode( int theId );
98
99 protected slots:
100   virtual void              onModuleActivated();
101   virtual void              onModuleDeactivated();
102
103 protected:
104   virtual void              keyPressEvent( QKeyEvent* theEvent );
105   virtual void              showEvent( QShowEvent* theEvent );
106   virtual void              closeEvent( QCloseEvent* theEvent );
107
108 private slots:
109   virtual void              onApply();
110   virtual void              onClose();
111   virtual void              onHelp();
112
113   void                      onPreferences();
114
115   void                      onSelectionModeChanged( int theId );
116   void                      onSelectionEvent();
117   void                      onPointIdEdit();
118   void                      onCellIdEdit();
119   void                      onDoubleClicked( const QModelIndex& theIndex );
120
121   void                      onIdChanged( int theFirstId, int theSecondId );
122
123 signals:
124   void                      selectionModeChanged( int );
125
126 private:
127   VisuGUI_SelectionPrefDlg* preferencesDlg();
128   void                      clearFields();
129
130   int                       column( int theTableId, int theColumnId );
131   QVariant                  data( int theTableId, int theRow, int theColumnId );
132   void                      setData( int theTableId, int theRow, int theColumnId, const QVariant& theValue );
133   void                      setRowSpan( int theTableId, int theRow, int theColumnId, int theRowSpan );
134
135 private:
136   QLabel*                   myMeshName;
137   QLabel*                   myFieldName;
138
139   QTabWidget*               myTabWidget;
140   QWidget*                  myPointsPane;
141   QWidget*                  myCellsPane;
142
143   QLineEdit*                myIDValLbl;
144   QStackedWidget*           myPointStackedWg;
145
146   QLineEdit*                myCellIDValLbl;
147   QStackedWidget*           myCellStackedWg;
148
149   QMap<int, QTableWidget*>  myTables;
150
151   QWidget*                  myActorsPane;
152   QLabel*                   myXPosLbl;
153   QLabel*                   myYPosLbl;
154   QLabel*                   myZPosLbl;
155   QLabel*                   myDXLbl;
156   QLabel*                   myDYLbl;
157   QLabel*                   myDZLbl;
158
159   VisuGUI_GaussPointsSelectionPane* myGaussPointsPane;
160
161   VisuGUI_FindPane*         myFindPane;
162
163   VisuGUI_SelectionPrefDlg* myPreferencesDlg;
164
165   bool                      myFl;
166
167   QMap< int, QList<int> >   myColumnData;
168 };
169
170 #endif