1 // Copyright (C) 2007-2024 CEA, EDF
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 : BLSURFPluginGUI_HypothesisCreator.h
22 // Authors : Francis KLOSS (OCC) & Patrick LAUG (INRIA) & Lioka RAZAFINDRAZAKA (CEA)
23 // & Aurelien ALLEAUME (DISTENE)
24 // Size maps developement: Nicolas GEIMER (OCC) & Gilles DAVID (EURIWARE)
27 #ifndef BLSURFPLUGINGUI_HypothesisCreator_H
28 #define BLSURFPLUGINGUI_HypothesisCreator_H
30 // akl: avoid compilation warning on Linux : "_POSIX_C_SOURCE" and "_XOPEN_SOURCE" are redefined
31 #ifdef _POSIX_C_SOURCE
32 #undef _POSIX_C_SOURCE
40 #if defined BLSURFPLUGIN_GUI_EXPORTS || defined BLSURFPluginGUI_EXPORTS
41 #define BLSURFPLUGIN_GUI_EXPORT __declspec( dllexport )
43 #define BLSURFPLUGIN_GUI_EXPORT __declspec( dllimport )
46 #define BLSURFPLUGIN_GUI_EXPORT
51 // E.A. : On windows with python 2.6, there is a conflict
52 // E.A. : between pymath.h and Standard_math.h which define
53 // E.A. : some same symbols : acosh, asinh, ...
54 #include <Standard_math.hxx>
58 #include <QItemDelegate>
60 #include <SMESHGUI_Hypotheses.h>
61 #include "StdMeshersGUI_ObjectReferenceParamWdg.h"
62 #include <SALOMEconfig.h>
67 #include <TopAbs_ShapeEnum.hxx>
68 #include <GeomSelectionTools.h>
69 #include <GEOM_Client.hxx>
70 #include CORBA_SERVER_HEADER(BLSURFPlugin_Algorithm)
84 class QTreeWidgetItem;
85 class QTableWidgetItem;
92 class SMESHGUI_SpinBox;
93 class SMESH_NumberFilter;
94 class LightApp_SelectionMgr;
95 class BLSURFPluginGUI_StdWidget;
96 class BLSURFPluginGUI_AdvWidget;
97 class StdMeshersGUI_SubShapeSelectorWdg;
98 // class DlgBlSurfHyp_Enforced;
101 typedef std::string TEnfName;
103 typedef std::string TEntry;
105 typedef std::set<TEntry> TEntryList;
106 // Enforced vertex = 3 coordinates
107 typedef std::vector<double> TEnfVertexCoords;
108 // List of enforced vertices
109 typedef std::set< TEnfVertexCoords > TEnfVertexCoordsList;
114 TEnfVertexCoords coords;
119 std::string attEntry;
123 TAttractor( const char* theAttEntry, double theStartSize, double theInfDist, double theConstDist)
124 : attEntry( theAttEntry ),
125 startSize( theStartSize ),
126 infDist( theInfDist ),
127 constDist( theConstDist )
129 void SetToDelete() { startSize = -1; }
130 bool IsToDelete() const { return startSize < 0; }
132 typedef std::vector< TAttractor > TAttractorVec;
134 struct CompareEnfVertices
136 bool operator () (const TEnfVertex* e1, const TEnfVertex* e2) const {
138 if (e1->coords.size() && e2->coords.size())
139 return (e1->coords < e2->coords);
141 return (e1->geomEntry < e2->geomEntry);
147 // List of enforced vertices
148 typedef std::set< TEnfVertex*, CompareEnfVertices > TEnfVertexList;
150 // Map Face Entry / List of enforced vertices
151 typedef std::map< TEntry, TEnfVertexList > TFaceEntryEnfVertexListMap;
153 // Map Face Entry / InternalEnforcedVertices
154 typedef std::map< TEntry, bool > TFaceEntryInternalVerticesMap;
156 // PreCad Face and Edge periodicity
157 typedef std::vector<std::string> TPreCadPeriodicity;
158 typedef std::vector< TPreCadPeriodicity > TPreCadPeriodicityVector;
162 int myTopology, myVerbosity;
163 int myPhysicalMesh, myGeometricMesh;
164 double myPhySize, myMinSize, myMaxSize;
165 bool myPhySizeRel, myMinSizeRel, myMaxSizeRel;
166 bool myUseMinSize, myUseMaxSize, myUseGradation, myUseVolumeGradation;
167 double myGradation, myVolumeGradation, myAngleMesh, myChordalError;
168 bool myAnisotropic, myOptimiseTinyEdges, myRemoveTinyEdges, myForceBadElementRemoval, myCorrectSurfaceIntersection;
169 double myAnisotropicRatio, myTinyEdgeLength, myTinyEdgeOptimisLength, myBadElementAspectRatio, myCorrectSurfaceIntersectionMaxCost;
170 bool myOptimizeMesh, myQuadraticMesh;
171 bool mySmpsurface,mySmpedge,mySmppoint,myEnforcedVertex,myInternalEnforcedVerticesAllFaces;
173 bool myUseSurfaceProximity;
174 int myNbSurfaceProximityLayers;
175 double mySurfaceProximityRatio;
176 bool myUseVolumeProximity;
177 int myNbVolumeProximityLayers;
178 double myVolumeProximityRatio;
179 // bool myPreCADMergeEdges, myPreCADProcess3DTopology, myPreCADDiscardInput;
180 // bool myGMFFileMode;
181 std::string myGMFFileName, myInternalEnforcedVerticesAllFacesGroup;
182 TEnfVertexList enfVertexList;
183 TFaceEntryEnfVertexListMap faceEntryEnfVertexListMap;
185 TGroupNameEnfVertexListMap groupNameEnfVertexListMap;
187 TPreCadPeriodicityVector preCadPeriodicityVector;
188 QStringList hyperpatches, hyperEntries;
190 } BlsurfHypothesisData;
194 * \brief Class for creation of MG-CADSurf hypotheses
196 class BLSURFPLUGIN_GUI_EXPORT BLSURFPluginGUI_HypothesisCreator : public SMESHGUI_GenericHypothesisCreator
201 BLSURFPluginGUI_HypothesisCreator( const QString& );
202 virtual ~BLSURFPluginGUI_HypothesisCreator();
204 virtual bool checkParams(QString& msg) const;
205 virtual QString helpPage() const;
208 virtual QFrame* buildFrame ();
209 virtual void retrieveParams() const;
210 virtual QString storeParams () const;
212 virtual QString caption() const;
213 virtual QPixmap icon() const;
214 virtual QString type() const;
217 void onStateChange();
220 void onChangeOptionName( int, int );
222 void onMapGeomContentModified();
223 void onSmpItemClicked( QTreeWidgetItem *, int );
224 void onTabChanged(int);
225 void onAttractorClicked(int);
226 void onConstSizeClicked(int);
230 void onSetSizeMap(QTreeWidgetItem *, int);
231 // Enforced vertices tab
232 QTreeWidgetItem* addEnforcedFace(std::string theFaceEntry, std::string theFaceName);
233 void addEnforcedVertex(double x=0, double y=0, double z=0,
234 std::string vertexName = "",
235 std::string geomEntry = "",
236 std::string groupName = "");
237 void onAddEnforcedVertices();
238 void onRemoveEnforcedVertex();
239 void synchronizeCoords();
240 void updateEnforcedVertexValues(QTreeWidgetItem* , int );
241 void onSelectEnforcedVertex();
242 void clearEnforcedVertexWidgets();
243 void onInternalVerticesClicked(int);
245 void onAddEnforcedMesh();
246 void onRemoveEnforcedMesh();
247 void onEnforcedMeshSelected();
248 void onEnfMeshTableSelected();
250 void onPeriodicityByVerticesChecked(bool);
251 void onAddPeriodicity();
252 void onRemovePeriodicity();
253 void onPeriodicityTreeClicked(QTreeWidgetItem*, int);
254 void onPeriodicityContentModified();
256 void onHyPatchFaceSelection(bool);
257 void onHyPatchGroupSelection(bool);
258 void onHyPatchSelectionChanged();
260 void onHyPatchRemove();
263 bool readParamsFromHypo( BlsurfHypothesisData& ) const;
264 QString readParamsFromWidgets( BlsurfHypothesisData& ) const;
265 bool storeParamsToHypo( const BlsurfHypothesisData& ) const;
266 bool sizeMapsValidation();
267 bool sizeMapValidationFromRow(int,bool displayError = true);
268 bool sizeMapValidationFromEntry(QString,bool displayError = true);
269 GeomSelectionTools* getGeomSelectionTool() const;
270 GEOM::GEOM_Gen_var getGeomEngine();
271 bool insertElement( GEOM::GEOM_Object_var, bool modify = false );
272 bool insertAttractor(GEOM::GEOM_Object_var, GEOM::GEOM_Object_var, bool modify = false);
273 int findRowFromEntry(QString entry);
274 CORBA::Object_var entryToObject(QString entry);
275 static LightApp_SelectionMgr* selectionMgr();
276 void avoidSimultaneousSelection(ListOfWidgets &myCustomWidgets) const;
277 void AddPreCadSequenceToVector(BlsurfHypothesisData& h_data, BLSURFPlugin::TPeriodicityList_var preCadFacePeriodicityVector, bool onFace) const;
278 void addHyPatchToTable(const QString& tags, const QString& entries);
279 bool hasGeom() const;
281 void addEnforcedMesh( SMESH::SMESH_IDSource_ptr mesh, const QString& groupName );
285 QTabWidget* myTabWidget;
287 BLSURFPluginGUI_StdWidget* myStdWidget;
291 BLSURFPluginGUI_AdvWidget* myAdvWidget;
295 QTreeWidget *mySizeMapTable;
296 QPushButton *addMapButton;
297 QPushButton *removeMapButton;
298 QPushButton *modifyMapButton;
300 QWidget *myAttractorGroup;
301 QWidget *mySmpStdGroup;
302 QCheckBox *myAttractorCheck;
303 QCheckBox *myConstSizeCheck;
304 QGroupBox *myDistanceGroup;
305 // QGroupBox *myParamsGroup;
306 // QWidget *myParamsGroup;
307 SMESHGUI_SpinBox *myAttSizeSpin;
308 SMESHGUI_SpinBox *myAttDistSpin;
309 SMESHGUI_SpinBox *myAttDistSpin2;
310 SMESHGUI_SpinBox *mySmpSizeSpin;
311 QLabel *myAttDistLabel;
312 QLabel *myAttDistLabel2;
313 QLabel *myAttSizeLabel;
314 // Selection widgets for size maps
315 StdMeshersGUI_ObjectReferenceParamWdg *myGeomSelWdg1;
316 StdMeshersGUI_ObjectReferenceParamWdg *myGeomSelWdg2;
317 StdMeshersGUI_ObjectReferenceParamWdg *myAttSelWdg;
318 StdMeshersGUI_ObjectReferenceParamWdg *myDistSelWdg;
319 GEOM::GEOM_Object_var mySMapObject;
320 GEOM::GEOM_Object_var myAttObject;
321 GEOM::GEOM_Object_var myDistObject;
327 StdMeshersGUI_ObjectReferenceParamWdg *myEnfFaceWdg;
328 GEOM::GEOM_Object_var myEnfFace;
329 StdMeshersGUI_ObjectReferenceParamWdg *myEnfVertexWdg;
330 GEOM::GEOM_Object_var myEnfVertex;
332 QTreeWidget* myEnforcedTreeWidget;
333 SMESHGUI_SpinBox* myXCoord;
334 SMESHGUI_SpinBox* myYCoord;
335 SMESHGUI_SpinBox* myZCoord;
337 QLineEdit* myGroupName;
339 QPushButton* addVertexButton;
340 QPushButton* removeVertexButton;
342 QCheckBox *myInternalEnforcedVerticesAllFaces;
343 QLineEdit *myInternalEnforcedVerticesAllFacesGroup;
347 QWidget* myEnfMeshGroup;
348 StdMeshersGUI_ObjectReferenceParamWdg *myEnfMeshWdg;
349 QTableWidget* myEnfMeshTableWdg;
350 QLineEdit* myEnforcedGroupName;
351 QPushButton* myAddEnfMeshButton;
352 QPushButton* myRemoveEnfMeshButton;
356 // map = entry , size map
357 QMap<QString, QString> mySMPMap; // Map <face entry, size>
358 QMap<QString, TAttractorVec > myATTMap; // Map <face entry, att. entry, etc>
359 QMap<QString, TopAbs_ShapeEnum> mySMPShapeTypeMap;
360 GeomSelectionTools* GeomToolSelected;
361 LightApp_SelectionMgr* aSel;
364 QWidget* myPeriodicityGroup;
365 QSplitter* myPeriodicitySplitter;
366 QTreeWidget* myPeriodicityTreeWidget;
367 QWidget* myPeriodicityRightWidget;
368 QGridLayout* myPeriodicityRightGridLayout;
369 QGroupBox* myPeriodicityGroupBox1;
370 QGroupBox* myPeriodicityGroupBox2;
371 QGridLayout* aPeriodicityLayout1;
372 QGridLayout* myPeriodicityGroupBox1Layout;
373 QGridLayout* myPeriodicityGroupBox2Layout;
374 QRadioButton* myPeriodicityOnFaceRadioButton;
375 QRadioButton* myPeriodicityOnEdgeRadioButton;
376 QLabel* myPeriodicityMainSourceLabel;
377 QLabel* myPeriodicityMainTargetLabel;
378 QLabel* myPeriodicitySourceLabel;
379 QLabel* myPeriodicityTargetLabel;
380 StdMeshersGUI_ObjectReferenceParamWdg* myPeriodicitySourceFaceWdg;
381 GEOM::GEOM_Object_var myPeriodicityFace;
382 StdMeshersGUI_ObjectReferenceParamWdg* myPeriodicityTargetFaceWdg;
383 GEOM::GEOM_Object_var myPeriodicityEdge;
384 QLabel* myPeriodicityP1SourceLabel;
385 QLabel* myPeriodicityP2SourceLabel;
386 QLabel* myPeriodicityP3SourceLabel;
387 QLabel* myPeriodicityP1TargetLabel;
388 QLabel* myPeriodicityP2TargetLabel;
389 QLabel* myPeriodicityP3TargetLabel;
390 StdMeshersGUI_ObjectReferenceParamWdg* myPeriodicityP1SourceWdg;
391 StdMeshersGUI_ObjectReferenceParamWdg* myPeriodicityP2SourceWdg;
392 StdMeshersGUI_ObjectReferenceParamWdg* myPeriodicityP3SourceWdg;
393 StdMeshersGUI_ObjectReferenceParamWdg* myPeriodicityP1TargetWdg;
394 StdMeshersGUI_ObjectReferenceParamWdg* myPeriodicityP2TargetWdg;
395 StdMeshersGUI_ObjectReferenceParamWdg* myPeriodicityP3TargetWdg;
396 ListOfWidgets myPeriodicitySelectionWidgets;
397 QPushButton* myPeriodicityAddButton;
398 QPushButton* myPeriodicityRemoveButton;
399 QSpacerItem* myPeriodicityVerticalSpacer;
401 QTableWidget* myHyPatchTable;
402 StdMeshersGUI_SubShapeSelectorWdg* myHyPatchFaceSelector;
403 QLineEdit* myHyPatchTagsLE;
404 QPushButton* myHyPatchFaceSelBtn;
405 QPushButton* myHyPatchGroupSelBtn;
407 BLSURFPlugin::string_array_var myOptions, myPreCADOptions, myCustomOptions;
410 PyObject * main_dict;
414 class EnforcedTreeWidgetDelegate : public QItemDelegate
419 EnforcedTreeWidgetDelegate(QObject *parent = 0);
421 QWidget *createEditor(QWidget *parent, const QStyleOptionViewItem & option,
422 const QModelIndex &index) const;
424 void setEditorData(QWidget *editor, const QModelIndex &index) const;
425 void setModelData(QWidget *editor, QAbstractItemModel *model,
426 const QModelIndex &index) const;
428 void updateEditorGeometry(QWidget *editor, const QStyleOptionViewItem &option,
429 const QModelIndex &index) const;
431 bool vertexExists(QAbstractItemModel *model, const QModelIndex &index, QString value) const;
434 #endif // BLSURFPLUGINGUI_HypothesisCreator_H