1 // Copyright (C) 2007-2019 CEA/DEN, EDF R&D
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, or (at your option) any later version.
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.
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
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
21 // File : HYBRIDPluginGUI_HypothesisCreator.h
22 // Author : Christian VAN WAMBEKE (CEA)
25 #ifndef HYBRIDPLUGINGUI_HypothesisCreator_HeaderFile
26 #define HYBRIDPLUGINGUI_HypothesisCreator_HeaderFile
29 #if defined HYBRIDPluginGUI_EXPORTS
30 #define HYBRIDPLUGINGUI_EXPORT __declspec( dllexport )
32 #define HYBRIDPLUGINGUI_EXPORT __declspec( dllimport )
35 #define HYBRIDPLUGINGUI_EXPORT
38 #include <SMESHGUI_Hypotheses.h>
39 #include <GeomSelectionTools.h>
40 #include <TopAbs_ShapeEnum.hxx>
42 #include <QItemDelegate>
46 #include <GEOM_Client.hxx>
47 #include CORBA_SERVER_HEADER(HYBRIDPlugin_Algorithm)
48 #include CORBA_SERVER_HEADER(SMESH_Gen)
49 #include CORBA_SERVER_HEADER(SMESH_Mesh)
57 class QTableWidgetItem;
60 class HYBRIDPluginGUI_StdWidget;
61 class HYBRIDPluginGUI_AdvWidget;
62 class LightApp_SelectionMgr;
63 class SMESHGUI_SpinBox;
64 class SUIT_SelectionFilter;
65 class StdMeshersGUI_ObjectReferenceParamWdg;
66 class StdMeshersGUI_SubShapeSelectorWdg;
72 QTEnfVertex(double size, double x=0., double y=0., double z=0., QString name="", QString geomEntry="", QString groupName="", bool isCompound = false);
75 bool operator == (const QTEnfVertex* other) const {
77 if (this->coords.size() && other->coords.size())
78 return (this->coords == other->coords);
80 return (this->geomEntry == other->geomEntry);
89 std::vector<double> coords;
92 typedef QList< QTEnfVertex* > QEnfVertexList;
97 std::string geomEntry;
99 std::vector<double> coords;
100 std::string groupName;
104 struct CompareEnfVertices
106 bool operator () (const TEnfVertex* e1, const TEnfVertex* e2) const {
108 if (e1->coords.size() && e2->coords.size())
109 return (e1->coords < e2->coords);
111 return (e1->geomEntry < e2->geomEntry);
117 // List of enforced vertices
118 typedef std::set< TEnfVertex*, CompareEnfVertices > TEnfVertexList;
125 std::string groupName;
128 struct CompareEnfMeshes
130 bool operator () (const TEnfMesh* e1, const TEnfMesh* e2) const {
132 if (e1->entry == e2->entry)
133 return (e1->elementType < e2->elementType);
135 return (e1->entry < e2->entry);
141 // List of enforced meshes
142 typedef std::set< TEnfMesh*, CompareEnfMeshes > TEnfMeshList;
146 bool myHeightIsRelative, myImprinting, mySnapping, myLayersOnAllWrap,
147 myKeepFiles, myLogInStandardOutput, myRemoveLogOnSuccess;
148 int myOptimizationLevel, myCollisionMode, myBoundaryLayersGrowth, myElementGeneration;
149 QString myName,myWorkingDir;
151 short myVerboseLevel;
152 TEnfVertexList myEnforcedVertices;
153 TEnfMeshList myEnforcedMeshes;
154 double myHeightFirstLayer,
155 myBoundaryLayersProgression,
157 myBoundaryLayersMaxElemAngle;
158 short myNbOfBoundaryLayers;
159 // IDs of faces with layers
160 SMESH::long_array_var myFaceWLIds;
161 // IDs of faces with imprinting
162 SMESH::long_array_var myFaceWIIds;
163 // IDs of faces with snapping
164 SMESH::long_array_var myFaceWSIds;
166 } HYBRIDHypothesisData;
169 \brief Class for creation of HYBRID 3D hypotheses
171 class HYBRIDPLUGINGUI_EXPORT HYBRIDPluginGUI_HypothesisCreator : public SMESHGUI_GenericHypothesisCreator
176 HYBRIDPluginGUI_HypothesisCreator( const QString& );
177 virtual ~HYBRIDPluginGUI_HypothesisCreator();
179 virtual bool checkParams(QString& msg) const;
180 virtual QString helpPage() const;
183 virtual QFrame* buildFrame ();
184 virtual void retrieveParams() const;
185 virtual QString storeParams () const;
187 virtual QString caption() const;
188 virtual QPixmap icon() const;
189 virtual QString type() const;
193 void onDirBtnClicked();
194 void updateWidgets();
196 void addEnforcedVertex(double x=0, double y=0, double z=0, double size = 0,
197 std::string vertexName = "", std::string geomEntry = "", std::string groupName = "",
198 bool isCompound = false);
199 void onAddEnforcedVertex();
200 void onRemoveEnforcedVertex();
201 void synchronizeCoords();
202 void updateEnforcedVertexValues(QTableWidgetItem* );
203 void onSelectEnforcedVertex();
204 void clearEnforcedVertexWidgets();
205 void checkVertexIsDefined();
206 void clearEnfVertexSelection();
208 void addEnforcedMesh(std::string name, std::string entry, int elementType, std::string groupName = "");
209 void onAddEnforcedMesh();
210 void onRemoveEnforcedMesh();
211 //void synchronizeEnforcedMesh();
212 void checkEnfMeshIsDefined();
213 void onTabChanged( int );
216 void vertexDefined(bool);
217 void enfMeshDefined(bool);
220 bool readParamsFromHypo( HYBRIDHypothesisData& ) const;
221 bool readParamsFromWidgets( HYBRIDHypothesisData& ) const;
222 bool storeParamsToHypo( const HYBRIDHypothesisData& ) const;
223 GeomSelectionTools* getGeomSelectionTool();
224 GEOM::GEOM_Gen_var getGeomEngine();
229 HYBRIDPluginGUI_StdWidget* myStdWidget;
230 HYBRIDPluginGUI_AdvWidget* myAdvWidget;
232 mutable HYBRIDPlugin::string_array_var myOptions, myCustomOptions;
235 QPixmap iconVertex, iconCompound;
236 StdMeshersGUI_ObjectReferenceParamWdg *myEnfVertexWdg;
237 GEOM::GEOM_Object_var myEnfVertex;
238 QTableWidget* myEnforcedTableWidget;
239 SMESHGUI_SpinBox* myXCoord;
240 SMESHGUI_SpinBox* myYCoord;
241 SMESHGUI_SpinBox* myZCoord;
242 SMESHGUI_SpinBox* mySizeValue;
243 QLineEdit* myGroupName;
244 // QGroupBox* makeGroupsCheck;
245 // QCheckBox* myGlobalGroupName;
246 QPushButton* addVertexButton;
247 QPushButton* removeVertexButton;
249 QWidget* myEnfMeshGroup;
250 StdMeshersGUI_ObjectReferenceParamWdg *myEnfMeshWdg;
251 // SMESH::SMESH_IDSource_var myEnfMesh;
252 QComboBox* myEnfMeshConstraint;
253 QStringList myEnfMeshConstraintLabels;
254 // SMESH::mesh_array_var myEnfMeshArray;
255 QTableWidget* myEnforcedMeshTableWidget;
256 QLineEdit* myMeshGroupName;
257 QPushButton* addEnfMeshButton;
258 QPushButton* removeEnfMeshButton;
260 GeomSelectionTools* GeomToolSelected;
262 SMESHGUI_SpinBox* myHeightFirstLayerSpin;
263 QSpinBox* myNbOfBoundaryLayersSpin;
264 SMESHGUI_SpinBox* myBoundaryLayersProgressionSpin;
265 SMESHGUI_SpinBox* myCoreSizeSpin;
266 SMESHGUI_SpinBox* myMultinormalsAngleSpin;
267 QCheckBox* mySmoothNormalsCheck;
270 StdMeshersGUI_SubShapeSelectorWdg* myFaceSelectorLayers;
271 StdMeshersGUI_SubShapeSelectorWdg* myFaceSelectorImprinting;
272 StdMeshersGUI_SubShapeSelectorWdg* myFaceSelectorSnapping;
275 class EnforcedVertexTableWidgetDelegate : public QItemDelegate
280 EnforcedVertexTableWidgetDelegate(QObject *parent = 0);
282 QWidget *createEditor(QWidget *parent, const QStyleOptionViewItem &option,
283 const QModelIndex &index) const;
285 void setEditorData(QWidget *editor, const QModelIndex &index) const;
286 void setModelData(QWidget *editor, QAbstractItemModel *model,
287 const QModelIndex &index) const;
289 void updateEditorGeometry(QWidget *editor,
290 const QStyleOptionViewItem &option, const QModelIndex &index) const;
292 bool vertexExists(QAbstractItemModel *model, const QModelIndex &index, QString value) const;
295 class EnforcedMeshTableWidgetDelegate : public QItemDelegate
300 EnforcedMeshTableWidgetDelegate(QObject *parent = 0);
302 QWidget *createEditor(QWidget *parent, const QStyleOptionViewItem &option,
303 const QModelIndex &index) const;
305 void setEditorData(QWidget *editor, const QModelIndex &index) const;
306 void setModelData(QWidget *editor, QAbstractItemModel *model,
307 const QModelIndex &index) const;
309 void updateEditorGeometry(QWidget *editor,
310 const QStyleOptionViewItem &option, const QModelIndex &index) const;