Salome HOME
5282c402ebc8479c611ef2324809aadd5f5c30ff
[modules/geom.git] / src / EntityGUI / EntityGUI_FieldDlg.h
1 // Copyright (C) 2007-2023  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   virtual QList<GEOM::GeomObjPtr>     getSourceObjects();
74
75 private slots:
76   void                                ClickOnOk();
77   bool                                ClickOnApply();
78   void                                ActivateThisDialog();
79   void                                SelectionIntoArgument();
80   void                                SetEditCurrentArgument();
81
82   void                                onPrevStep();
83   void                                onNextStep();
84   void                                onAddStep();
85   void                                onRmStep();
86   void                                onStampChange();
87   void                                onDimChange();
88   void                                onTypeChange();
89   void                                onNbCompsChange();
90   void                                showCurStep();
91   void                                highlightSubShapes();
92
93 private:
94   void                                Init();
95   void                                enterEvent (QEvent*);
96   void                                activateSelection();
97
98   TopAbs_ShapeEnum                    getShapeType(int* dim=0) const;
99   int                                 getDim() const;
100   int                                 getDataType() const;
101   int                                 getCurStepID() const;
102   int                                 getNbComps() const;
103   void                                updateShapeIDs();
104   void                                updateDims(int curDim=-1);
105   int                                 getSelectedSubshapes (TColStd_IndexedMapOfInteger& map);
106
107 private:
108   bool                                myIsCreation;
109   GEOM::GEOM_Field_var                myField;
110   GEOM::GEOM_Object_var               myShape;
111   QVector< int >                      myShapeIDs;
112   TopTools_IndexedMapOfShape          myShapeMap;
113
114   int                                 myCurStepID;
115   StepTable*                          myCurStepTable;
116   QMap< int, StepTable* >             myStepTables;
117   QSet< int >                         myRemovedSteps;
118
119   int                                 myDmMode;
120   bool                                myIsHiddenMain;
121
122   QList<int>                          myHiddenFieldStepIds;
123
124   QPushButton*                        myShapeSelBtn;
125   QLineEdit*                          myShapeName;
126   QComboBox*                          myTypeCombo;
127   QComboBox*                          myDimCombo;
128   QPushButton*                        myPrevStepBtn;
129   QPushButton*                        myNextStepBtn;
130   QPushButton*                        myRmStepBtn;
131
132   SalomeApp_IntSpinBox*               myNbCompsSpin;
133   QWidget*                            mySwitchTableWdg;
134   QComboBox*                          myStepsCombo;
135   QLineEdit*                          myStepEdit;
136   SalomeApp_IntSpinBox*               myStampSpin;
137
138 };
139
140 /*
141   Class       : EntityGUI_FieldDlg::StepTable
142   Description : Table widget
143 */
144
145 class EntityGUI_FieldDlg::StepTable : public QTableWidget
146 {
147   Q_OBJECT
148
149   int                      myDataType;
150   int                      myStepID;
151   int                      myStamp;
152   GEOM::GEOM_FieldStep_var myStep;
153   bool                     myIsChanged;
154
155   QTableWidgetItem * newDefaultItem();
156
157 public:
158   StepTable( int stepID, int dataType, int nbRows, int nbColumns,
159              QString shapeName, QStringList headers,
160              GEOM::GEOM_FieldStep_ptr stepVar, QWidget* = 0 );
161   virtual ~StepTable();
162
163   QSize                    minimumSizeHint() const;
164
165   void                     setEditable( bool, int, int );
166   bool                     isEditable( int, int ) const;
167
168   void                     setReadOnly( bool );
169   bool                     isReadOnly() const;
170
171   void                     insertRows( int, int = 1 );
172   QString                  text( int, int );
173
174   QList<int>               selectedRows();
175   void                     selectRows(const QList<int>& rows);
176
177   void                     setDim( int nbRows, QString shapeName, bool setDefault=true );
178   void                     setNbComps( int nbComps );
179   void                     setDataType( int dataType );
180   void                     setStamp( int stamp ) { myStamp = stamp; }
181   int                      getStamp() { return myStamp; }
182   int                      getStepID() { return myStepID; }
183   QStringList              getHeaders();
184   void                     setHeaders(const QStringList& headers);
185   GEOM::GEOM_FieldStep_var getStep() { return myStep; }
186   void                     setValues(GEOM::GEOM_FieldStep_var& step);
187
188 public slots:
189   void                     setIsChanged() { myIsChanged = true; }
190   void                     headerDblClicked( int );
191 };
192
193 #endif