Salome HOME
Revert "Synchronize adm files"
[modules/geom.git] / src / EntityGUI / EntityGUI_FieldDlg.h
1 // Copyright (C) 2007-2014  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, or (at your option) any later version.
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 //  GEOM GEOMGUI : GUI for Geometry component
24 //  File   : EntityGUI_FieldDlg.h
25
26 #ifndef EntityGUI_FieldDlg_H
27 #define EntityGUI_FieldDlg_H
28
29 #include <GEOMBase_Skeleton.h>
30
31 #include <TopAbs_ShapeEnum.hxx>
32 #include <TColStd_DataMapOfIntegerInteger.hxx>
33 #include <TColStd_IndexedMapOfInteger.hxx>
34 #include <TopTools_IndexedMapOfShape.hxx>
35
36 #include <QMap>
37 #include <QSet>
38 #include <QVector>
39 #include <QTableWidget>
40
41 class QGroupBox;
42 class QLineEdit;
43 class QPushButton;
44 class QComboBox;
45 class SalomeApp_IntSpinBox;
46
47 //=================================================================================
48 // class    : EntityGUI_FieldDlg
49 // purpose  :
50 //=================================================================================
51 class EntityGUI_FieldDlg : public GEOMBase_Skeleton
52 {
53   Q_OBJECT
54
55   class StepTable;
56   class IntSpinItem;
57   class DoubleSpinItem;
58   class CheckItem;
59   class Delegate;
60
61 public:
62   EntityGUI_FieldDlg (GeometryGUI* theGeometryGUI,
63                       GEOM::GEOM_Field_ptr theField, int stepID=0,
64                       QWidget* parent=0,
65                       bool modal=false, Qt::WindowFlags fl=0);
66   ~EntityGUI_FieldDlg();
67
68 protected:
69   // redefined from GEOMBase_Helper
70   virtual GEOM::GEOM_IOperations_ptr  createOperation();
71   virtual bool                        isValid (QString&);
72   virtual bool                        execute ();
73
74 private slots:
75   void                                ClickOnOk();
76   bool                                ClickOnApply();
77   void                                ActivateThisDialog();
78   void                                SelectionIntoArgument();
79   void                                SetEditCurrentArgument();
80
81   void                                onPrevStep();
82   void                                onNextStep();
83   void                                onAddStep();
84   void                                onRmStep();
85   void                                onStampChange();
86   void                                onDimChange();
87   void                                onTypeChange();
88   void                                onNbCompsChange();
89   void                                showCurStep();
90   void                                highlightSubShapes();
91
92 private:
93   void                                Init();
94   void                                enterEvent (QEvent*);
95   void                                activateSelection();
96
97   TopAbs_ShapeEnum                    getShapeType(int* dim=0) const;
98   int                                 getDim() const;
99   int                                 getDataType() const;
100   int                                 getCurStepID() const;
101   int                                 getNbComps() const;
102   void                                updateShapeIDs();
103   void                                updateDims(int curDim=-1);
104   int                                 getSelectedSubshapes (TColStd_IndexedMapOfInteger& map);
105
106 private:
107   bool                                myIsCreation;
108   GEOM::GEOM_Field_var                myField;
109   GEOM::GEOM_Object_var               myShape;
110   QVector< int >                      myShapeIDs;
111   TopTools_IndexedMapOfShape          myShapeMap;
112
113   int                                 myCurStepID;
114   StepTable*                          myCurStepTable;
115   QMap< int, StepTable* >             myStepTables;
116   QSet< int >                         myRemovedSteps;
117
118   int                                 myDmMode;
119   bool                                myIsHiddenMain;
120
121   QList<int>                          myHiddenFieldStepIds;
122
123   QPushButton*                        myShapeSelBtn;
124   QLineEdit*                          myShapeName;
125   QComboBox*                          myTypeCombo;
126   QComboBox*                          myDimCombo;
127   QPushButton*                        myPrevStepBtn;
128   QPushButton*                        myNextStepBtn;
129   QPushButton*                        myRmStepBtn;
130
131   SalomeApp_IntSpinBox*               myNbCompsSpin;
132   QWidget*                            mySwitchTableWdg;
133   QComboBox*                          myStepsCombo;
134   QLineEdit*                          myStepEdit;
135   SalomeApp_IntSpinBox*               myStampSpin;
136
137 };
138
139 /*
140   Class       : EntityGUI_FieldDlg::StepTable
141   Description : Table widget
142 */
143
144 class EntityGUI_FieldDlg::StepTable : public QTableWidget
145 {
146   Q_OBJECT
147
148   int                      myDataType;
149   int                      myStepID;
150   int                      myStamp;
151   GEOM::GEOM_FieldStep_var myStep;
152   bool                     myIsChanged;
153
154   QTableWidgetItem * newDefaultItem();
155
156 public:
157   StepTable( int stepID, int dataType, int nbRows, int nbColumns,
158              QString shapeName, QStringList headers,
159              GEOM::GEOM_FieldStep_ptr stepVar, QWidget* = 0 );
160   virtual ~StepTable();
161
162   QSize                    minimumSizeHint() const;
163
164   void                     setEditable( bool, int, int );
165   bool                     isEditable( int, int ) const;
166
167   void                     setReadOnly( bool );
168   bool                     isReadOnly() const;
169
170   void                     insertRows( int, int = 1 );
171   QString                  text( int, int );
172
173   QList<int>               selectedRows();
174   void                     selectRows(const QList<int>& rows);
175
176   void                     setDim( int nbRows, QString shapeName, bool setDefault=true );
177   void                     setNbComps( int nbComps );
178   void                     setDataType( int dataType );
179   void                     setStamp( int stamp ) { myStamp = stamp; }
180   int                      getStamp() { return myStamp; }
181   int                      getStepID() { return myStepID; }
182   QStringList              getHeaders();
183   void                     setHeaders(const QStringList& headers);
184   GEOM::GEOM_FieldStep_var getStep() { return myStep; }
185   void                     setValues(GEOM::GEOM_FieldStep_var& step);
186
187 public slots:
188   void                     setIsChanged() { myIsChanged = true; }
189   void                     headerDblClicked( int );
190 };
191
192 #endif