1 // Copyright (C) 2007-2016 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_AdvWidget;
61 class LightApp_SelectionMgr;
62 class SMESHGUI_SpinBox;
63 class SUIT_SelectionFilter;
64 class StdMeshersGUI_ObjectReferenceParamWdg;
65 class StdMeshersGUI_SubShapeSelectorWdg;
71 QTEnfVertex(double size, double x=0., double y=0., double z=0., QString name="", QString geomEntry="", QString groupName="", bool isCompound = false);
74 bool operator == (const QTEnfVertex* other) const {
76 if (this->coords.size() && other->coords.size())
77 return (this->coords == other->coords);
79 return (this->geomEntry == other->geomEntry);
88 std::vector<double> coords;
91 typedef QList< QTEnfVertex* > QEnfVertexList;
96 std::string geomEntry;
98 std::vector<double> coords;
99 std::string groupName;
103 struct CompareEnfVertices
105 bool operator () (const TEnfVertex* e1, const TEnfVertex* e2) const {
107 if (e1->coords.size() && e2->coords.size())
108 return (e1->coords < e2->coords);
110 return (e1->geomEntry < e2->geomEntry);
116 // List of enforced vertices
117 typedef std::set< TEnfVertex*, CompareEnfVertices > TEnfVertexList;
124 std::string groupName;
127 struct CompareEnfMeshes
129 bool operator () (const TEnfMesh* e1, const TEnfMesh* e2) const {
131 if (e1->entry == e2->entry)
132 return (e1->elementType < e2->elementType);
134 return (e1->entry < e2->entry);
140 // List of enforced meshes
141 typedef std::set< TEnfMesh*, CompareEnfMeshes > TEnfMeshList;
145 bool myLayersOnAllWrap, myToMeshHoles, myToMakeGroupsOfDomains,
146 myKeepFiles, myToCreateNewNodes,
147 myBoundaryRecovery, myFEMCorrection,
148 myRemoveInitialCentralPoint,
149 myLogInStandardOutput, myRemoveLogOnSuccess;
150 double myMaximumMemory,myInitialMemory;
151 int myOptimizationLevel;
153 int myBoundaryLayersGrowth;
154 int myElementGeneration;
155 QString myName,myWorkingDir,myTextOption;
157 short myVerboseLevel;
158 TEnfVertexList myEnforcedVertices;
159 TEnfMeshList myEnforcedMeshes;
160 bool myAddMultinormals,
162 double myHeightFirstLayer,
163 myBoundaryLayersProgression,
166 short myNbOfBoundaryLayers;
167 // IDs of faces with layers
168 SMESH::long_array_var myFaceWLIds;
169 // IDs of faces with imprinting
170 SMESH::long_array_var myFaceWIIds;
172 } HYBRIDHypothesisData;
175 \brief Class for creation of HYBRID 3D hypotheses
177 class HYBRIDPLUGINGUI_EXPORT HYBRIDPluginGUI_HypothesisCreator : public SMESHGUI_GenericHypothesisCreator
182 HYBRIDPluginGUI_HypothesisCreator( const QString& );
183 virtual ~HYBRIDPluginGUI_HypothesisCreator();
185 virtual bool checkParams(QString& msg) const;
186 virtual QString helpPage() const;
189 virtual QFrame* buildFrame ();
190 virtual void retrieveParams() const;
191 virtual QString storeParams () const;
193 virtual QString caption() const;
194 virtual QPixmap icon() const;
195 virtual QString type() const;
198 void onLayersOnAllWrap(bool);
199 void onToMeshHoles(bool);
200 void onDirBtnClicked();
201 void updateWidgets();
203 void addEnforcedVertex(double x=0, double y=0, double z=0, double size = 0,
204 std::string vertexName = "", std::string geomEntry = "", std::string groupName = "",
205 bool isCompound = false);
206 void onAddEnforcedVertex();
207 void onRemoveEnforcedVertex();
208 void synchronizeCoords();
209 void updateEnforcedVertexValues(QTableWidgetItem* );
210 void onSelectEnforcedVertex();
211 void clearEnforcedVertexWidgets();
212 void checkVertexIsDefined();
213 void clearEnfVertexSelection();
215 void addEnforcedMesh(std::string name, std::string entry, int elementType, std::string groupName = "");
216 void onAddEnforcedMesh();
217 void onRemoveEnforcedMesh();
218 //void synchronizeEnforcedMesh();
219 void checkEnfMeshIsDefined();
220 void onTabChanged( int );
223 void vertexDefined(bool);
224 void enfMeshDefined(bool);
227 bool readParamsFromHypo( HYBRIDHypothesisData& ) const;
228 bool readParamsFromWidgets( HYBRIDHypothesisData& ) const;
229 bool storeParamsToHypo( const HYBRIDHypothesisData& ) const;
230 GeomSelectionTools* getGeomSelectionTool();
231 GEOM::GEOM_Gen_var getGeomEngine();
236 QCheckBox* myLayersOnAllWrapCheck;
237 QCheckBox* myToMeshHolesCheck;
238 QCheckBox* myToMakeGroupsOfDomains;
239 QComboBox* myOptimizationLevelCombo;
240 QComboBox* myCollisionModeCombo;
241 QComboBox* myBoundaryLayersGrowthCombo;
242 QComboBox* myElementGenerationCombo;
243 QCheckBox* myAddMultinormalsCheck;
244 QCheckBox* mySmoothNormals;
246 HYBRIDPluginGUI_AdvWidget* myAdvWidget;
249 QPixmap iconVertex, iconCompound;
250 StdMeshersGUI_ObjectReferenceParamWdg *myEnfVertexWdg;
251 GEOM::GEOM_Object_var myEnfVertex;
252 QTableWidget* myEnforcedTableWidget;
253 SMESHGUI_SpinBox* myXCoord;
254 SMESHGUI_SpinBox* myYCoord;
255 SMESHGUI_SpinBox* myZCoord;
256 SMESHGUI_SpinBox* mySizeValue;
257 QLineEdit* myGroupName;
258 // QGroupBox* makeGroupsCheck;
259 // QCheckBox* myGlobalGroupName;
260 QPushButton* addVertexButton;
261 QPushButton* removeVertexButton;
263 QWidget* myEnfMeshGroup;
264 StdMeshersGUI_ObjectReferenceParamWdg *myEnfMeshWdg;
265 // SMESH::SMESH_IDSource_var myEnfMesh;
266 QComboBox* myEnfMeshConstraint;
267 QStringList myEnfMeshConstraintLabels;
268 // SMESH::mesh_array_var myEnfMeshArray;
269 QTableWidget* myEnforcedMeshTableWidget;
270 QLineEdit* myMeshGroupName;
271 QPushButton* addEnfMeshButton;
272 QPushButton* removeEnfMeshButton;
274 GeomSelectionTools* GeomToolSelected;
276 SMESHGUI_SpinBox* myHeightFirstLayerSpin;
277 QSpinBox* myNbOfBoundaryLayersSpin;
278 SMESHGUI_SpinBox* myBoundaryLayersProgressionSpin;
279 SMESHGUI_SpinBox* myCoreSizeSpin;
280 SMESHGUI_SpinBox* myMultinormalsAngleSpin;
281 QCheckBox* mySmoothNormalsCheck;
283 StdMeshersGUI_SubShapeSelectorWdg* myFaceSelectorLayers;
284 StdMeshersGUI_SubShapeSelectorWdg* myFaceSelectorImprinting;
287 class EnforcedVertexTableWidgetDelegate : public QItemDelegate
292 EnforcedVertexTableWidgetDelegate(QObject *parent = 0);
294 QWidget *createEditor(QWidget *parent, const QStyleOptionViewItem &option,
295 const QModelIndex &index) const;
297 void setEditorData(QWidget *editor, const QModelIndex &index) const;
298 void setModelData(QWidget *editor, QAbstractItemModel *model,
299 const QModelIndex &index) const;
301 void updateEditorGeometry(QWidget *editor,
302 const QStyleOptionViewItem &option, const QModelIndex &index) const;
304 bool vertexExists(QAbstractItemModel *model, const QModelIndex &index, QString value) const;
307 class EnforcedMeshTableWidgetDelegate : public QItemDelegate
312 EnforcedMeshTableWidgetDelegate(QObject *parent = 0);
314 QWidget *createEditor(QWidget *parent, const QStyleOptionViewItem &option,
315 const QModelIndex &index) const;
317 void setEditorData(QWidget *editor, const QModelIndex &index) const;
318 void setModelData(QWidget *editor, QAbstractItemModel *model,
319 const QModelIndex &index) const;
321 void updateEditorGeometry(QWidget *editor,
322 const QStyleOptionViewItem &option, const QModelIndex &index) const;