Salome HOME
324ce09814896fc0f9a02ab0578ce998f74215b0
[modules/visu.git] / src / VISUGUI / VisuGUI_SelectionPanel.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 //  VISU VISUGUI : GUI of VISU component
23 //  File   : VisuGUI_SelectionPanel.h
24 //  Author : Laurent CORNABE & Hubert ROLLAND 
25 //  Module : VISU
26 //  $Header$
27 //
28 #ifndef VISUGUI_SELECTIONPANEL_H
29 #define VISUGUI_SELECTIONPANEL_H
30
31 #include "VisuGUI_Panel.h"
32
33 #include <QMap>
34
35 #include <vtkSystemIncludes.h>
36
37 class QLabel;
38 class QLineEdit;
39 class QModelIndex;
40 class QStackedWidget;
41 class QTableWidget;
42 class QTabWidget;
43
44 class VisuGUI_GaussPointsSelectionPane;
45 class VisuGUI_FindPane;
46 class VisuGUI_SelectionPrefDlg;
47
48 typedef vtkIdType TPointID;
49 typedef vtkIdType TCellID;
50
51 struct TValueData
52 {
53   QString Scalar;
54   QString Vector;
55 };
56
57 struct TPointData
58 {
59   vtkFloatingPointType X;
60   vtkFloatingPointType Y;
61   vtkFloatingPointType Z;
62   vtkIdType I;
63   vtkIdType J;
64   vtkIdType K;
65   TValueData ValueData;
66 };
67
68 typedef QMap<TPointID, TPointData> TPointDataMap;
69 typedef QMap<TCellID,  TValueData> TCellDataMap;
70
71 struct TCellToPointData
72 {
73   TValueData CellData;
74   TPointDataMap PointDataMap;
75 };
76
77 struct TPointToCellData
78 {
79   TPointData PointData;
80   TCellDataMap CellDataMap;
81 };
82   
83 typedef QMap<TCellID,  TCellToPointData> TCellToPointDataMap;
84 typedef QMap<TPointID, TPointToCellData> TPointToCellDataMap;
85
86 class VisuGUI_SelectionPanel: public VisuGUI_Panel
87 {
88   Q_OBJECT
89
90   enum MeshType { StdMesh = 0, ElnoMesh };
91   enum TableId { CellStdCell = 0, CellStdPoint, PointStd, CellElno, PointElno };
92   enum ColumnId { Cell = 0, Point, X, Y, Z, I, J, K, Scalar, Vector };
93
94 public:
95   VisuGUI_SelectionPanel( VisuGUI* theModule, QWidget* theParent = 0 );
96   virtual ~VisuGUI_SelectionPanel ();
97
98 public:
99   void                      setSelectionMode( int theId );
100
101 protected slots:
102   virtual void              onModuleActivated();
103   virtual void              onModuleDeactivated();
104
105 protected:
106   virtual void              keyPressEvent( QKeyEvent* theEvent );
107   virtual void              showEvent( QShowEvent* theEvent );
108   virtual void              closeEvent( QCloseEvent* theEvent );
109
110 private slots:
111   virtual void              onApply();
112   virtual void              onClose();
113   virtual void              onHelp();
114
115   void                      onPreferences();
116
117   void                      onSelectionModeChanged( int theId );
118   void                      onSelectionEvent();
119   void                      onPointIdEdit();
120   void                      onCellIdEdit();
121   void                      onDoubleClicked( const QModelIndex& theIndex );
122
123   void                      onIdChanged( int theFirstId, int theSecondId );
124
125 signals:
126   void                      selectionModeChanged( int );
127
128 private:
129   VisuGUI_SelectionPrefDlg* preferencesDlg();
130   void                      clearFields();
131
132   int                       column( int theTableId, int theColumnId );
133   QVariant                  data( int theTableId, int theRow, int theColumnId );
134   void                      setData( int theTableId, int theRow, int theColumnId, const QVariant& theValue );
135   void                      setRowSpan( int theTableId, int theRow, int theColumnId, int theRowSpan );
136
137 private:
138   QLabel*                   myMeshName;
139   QLabel*                   myFieldName;
140
141   QTabWidget*               myTabWidget;
142   QWidget*                  myPointsPane;
143   QWidget*                  myCellsPane;
144
145   QLineEdit*                myIDValLbl;
146   QStackedWidget*           myPointStackedWg;
147
148   QLineEdit*                myCellIDValLbl;
149   QStackedWidget*           myCellStackedWg;
150
151   QMap<int, QTableWidget*>  myTables;
152
153   QWidget*                  myActorsPane;
154   QLabel*                   myXPosLbl;
155   QLabel*                   myYPosLbl;
156   QLabel*                   myZPosLbl;
157   QLabel*                   myDXLbl;
158   QLabel*                   myDYLbl;
159   QLabel*                   myDZLbl;
160
161   VisuGUI_GaussPointsSelectionPane* myGaussPointsPane;
162
163   VisuGUI_FindPane*         myFindPane;
164
165   VisuGUI_SelectionPrefDlg* myPreferencesDlg;
166
167   bool                      myFl;
168
169   QMap< int, QList<int> >   myColumnData;
170 };
171
172 #endif