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 : 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
50 // E.A. : On windows with python 2.6, there is a conflict
51 // E.A. : between pymath.h and Standard_math.h which define
52 // E.A. : some same symbols : acosh, asinh, ...
53 #include <Standard_math.hxx>
59 #include <QItemDelegate>
61 #include <SMESHGUI_Hypotheses.h>
62 #include "StdMeshersGUI_ObjectReferenceParamWdg.h"
63 #include <SALOMEconfig.h>
68 #include <TopAbs_ShapeEnum.hxx>
69 #include <GeomSelectionTools.h>
70 #include <GEOM_Client.hxx>
71 #include CORBA_SERVER_HEADER(BLSURFPlugin_Algorithm)
85 class QTreeWidgetItem;
86 class QTableWidgetItem;
93 class SMESHGUI_SpinBox;
94 class SMESH_NumberFilter;
95 class LightApp_SelectionMgr;
96 class BLSURFPluginGUI_StdWidget;
97 class BLSURFPluginGUI_AdvWidget;
98 class StdMeshersGUI_SubShapeSelectorWdg;
99 // class DlgBlSurfHyp_Enforced;
102 typedef std::string TEnfName;
104 typedef std::string TEntry;
106 typedef std::set<TEntry> TEntryList;
107 // Enforced vertex = 3 coordinates
108 typedef std::vector<double> TEnfVertexCoords;
109 // List of enforced vertices
110 typedef std::set< TEnfVertexCoords > TEnfVertexCoordsList;
115 TEnfVertexCoords coords;
120 std::string attEntry;
124 TAttractor( const char* theAttEntry, double theStartSize, double theInfDist, double theConstDist)
125 : attEntry( theAttEntry ),
126 startSize( theStartSize ),
127 infDist( theInfDist ),
128 constDist( theConstDist )
130 void SetToDelete() { startSize = -1; }
131 bool IsToDelete() const { return startSize < 0; }
133 typedef std::vector< TAttractor > TAttractorVec;
135 struct CompareEnfVertices
137 bool operator () (const TEnfVertex* e1, const TEnfVertex* e2) const {
139 if (e1->coords.size() && e2->coords.size())
140 return (e1->coords < e2->coords);
142 return (e1->geomEntry < e2->geomEntry);
148 // List of enforced vertices
149 typedef std::set< TEnfVertex*, CompareEnfVertices > TEnfVertexList;
151 // Map Face Entry / List of enforced vertices
152 typedef std::map< TEntry, TEnfVertexList > TFaceEntryEnfVertexListMap;
154 // Map Face Entry / InternalEnforcedVertices
155 typedef std::map< TEntry, bool > TFaceEntryInternalVerticesMap;
157 // PreCad Face and Edge periodicity
158 typedef std::vector<std::string> TPreCadPeriodicity;
159 typedef std::vector< TPreCadPeriodicity > TPreCadPeriodicityVector;
163 int myTopology, myVerbosity;
164 int myPhysicalMesh, myGeometricMesh;
165 double myPhySize, myMinSize, myMaxSize;
166 bool myPhySizeRel, myMinSizeRel, myMaxSizeRel;
167 bool myUseMinSize, myUseMaxSize, myUseGradation, myUseVolumeGradation;
168 double myGradation, myVolumeGradation, myAngleMesh, myChordalError;
169 bool myAnisotropic, myOptimiseTinyEdges, myRemoveTinyEdges, myForceBadElementRemoval, myCorrectSurfaceIntersection;
170 double myAnisotropicRatio, myTinyEdgeLength, myTinyEdgeOptimisLength, myBadElementAspectRatio, myCorrectSurfaceIntersectionMaxCost;
171 bool myOptimizeMesh, myQuadraticMesh;
172 bool myAllowQuadrangles, mySmpsurface,mySmpedge,mySmppoint,myEnforcedVertex,myInternalEnforcedVerticesAllFaces;
173 // bool myPreCADMergeEdges, myPreCADProcess3DTopology, myPreCADDiscardInput;
174 // bool myGMFFileMode;
175 std::string myGMFFileName, myInternalEnforcedVerticesAllFacesGroup;
176 TEnfVertexList enfVertexList;
177 TFaceEntryEnfVertexListMap faceEntryEnfVertexListMap;
179 TGroupNameEnfVertexListMap groupNameEnfVertexListMap;
181 TPreCadPeriodicityVector preCadPeriodicityVector;
182 QStringList hyperpatches;
184 } BlsurfHypothesisData;
188 * \brief Class for creation of MG-CADSurf hypotheses
190 class BLSURFPLUGIN_GUI_EXPORT BLSURFPluginGUI_HypothesisCreator : public SMESHGUI_GenericHypothesisCreator
195 BLSURFPluginGUI_HypothesisCreator( const QString& );
196 virtual ~BLSURFPluginGUI_HypothesisCreator();
198 virtual bool checkParams(QString& msg) const;
199 virtual QString helpPage() const;
202 virtual QFrame* buildFrame ();
203 virtual void retrieveParams() const;
204 virtual QString storeParams () const;
206 virtual QString caption() const;
207 virtual QPixmap icon() const;
208 virtual QString type() const;
211 void onStateChange();
214 void onChangeOptionName( int, int );
216 void onMapGeomContentModified();
217 void onSmpItemClicked( QTreeWidgetItem *, int );
218 void onTabChanged(int);
219 void onAttractorClicked(int);
220 void onConstSizeClicked(int);
224 void onSetSizeMap(QTreeWidgetItem *, int);
225 // Enforced vertices tab
226 QTreeWidgetItem* addEnforcedFace(std::string theFaceEntry, std::string theFaceName);
227 void addEnforcedVertex(double x=0, double y=0, double z=0,
228 std::string vertexName = "",
229 std::string geomEntry = "",
230 std::string groupName = "");
231 void onAddEnforcedVertices();
232 void onRemoveEnforcedVertex();
233 void synchronizeCoords();
234 void updateEnforcedVertexValues(QTreeWidgetItem* , int );
235 void onSelectEnforcedVertex();
236 void clearEnforcedVertexWidgets();
237 void onInternalVerticesClicked(int);
239 void onPeriodicityByVerticesChecked(bool);
240 void onAddPeriodicity();
241 void onRemovePeriodicity();
242 void onPeriodicityTreeClicked(QTreeWidgetItem*, int);
243 void onPeriodicityContentModified();
245 void onHyPatchFaceSelection(bool);
246 void onHyPatchGroupSelection(bool);
247 void onHyPatchSelectionChanged();
249 void onHyPatchRemove();
252 bool readParamsFromHypo( BlsurfHypothesisData& ) const;
253 QString readParamsFromWidgets( BlsurfHypothesisData& ) const;
254 bool storeParamsToHypo( const BlsurfHypothesisData& ) const;
255 bool sizeMapsValidation();
256 bool sizeMapValidationFromRow(int,bool displayError = true);
257 bool sizeMapValidationFromEntry(QString,bool displayError = true);
258 GeomSelectionTools* getGeomSelectionTool() const;
259 GEOM::GEOM_Gen_var getGeomEngine();
260 bool insertElement( GEOM::GEOM_Object_var, bool modify = false );
261 bool insertAttractor(GEOM::GEOM_Object_var, GEOM::GEOM_Object_var, bool modify = false);
262 int findRowFromEntry(QString entry);
263 CORBA::Object_var entryToObject(QString entry);
264 static LightApp_SelectionMgr* selectionMgr();
265 void avoidSimultaneousSelection(ListOfWidgets &myCustomWidgets) const;
266 void AddPreCadSequenceToVector(BlsurfHypothesisData& h_data, BLSURFPlugin::TPeriodicityList_var preCadFacePeriodicityVector, bool onFace) const;
267 void addHyPatchToTable(const QString& tags);
268 bool hasGeom() const;
272 QTabWidget* myTabWidget;
274 BLSURFPluginGUI_StdWidget* myStdWidget;
278 BLSURFPluginGUI_AdvWidget* myAdvWidget;
282 QTreeWidget *mySizeMapTable;
283 QPushButton *addMapButton;
284 QPushButton *removeMapButton;
285 QPushButton *modifyMapButton;
287 QWidget *myAttractorGroup;
288 QWidget *mySmpStdGroup;
289 QCheckBox *myAttractorCheck;
290 QCheckBox *myConstSizeCheck;
291 QGroupBox *myDistanceGroup;
292 // QGroupBox *myParamsGroup;
293 // QWidget *myParamsGroup;
294 SMESHGUI_SpinBox *myAttSizeSpin;
295 SMESHGUI_SpinBox *myAttDistSpin;
296 SMESHGUI_SpinBox *myAttDistSpin2;
297 SMESHGUI_SpinBox *mySmpSizeSpin;
298 QLabel *myAttDistLabel;
299 QLabel *myAttDistLabel2;
300 QLabel *myAttSizeLabel;
301 // Selection widgets for size maps
302 StdMeshersGUI_ObjectReferenceParamWdg *myGeomSelWdg1;
303 StdMeshersGUI_ObjectReferenceParamWdg *myGeomSelWdg2;
304 StdMeshersGUI_ObjectReferenceParamWdg *myAttSelWdg;
305 StdMeshersGUI_ObjectReferenceParamWdg *myDistSelWdg;
306 GEOM::GEOM_Object_var mySMapObject;
307 GEOM::GEOM_Object_var myAttObject;
308 GEOM::GEOM_Object_var myDistObject;
314 StdMeshersGUI_ObjectReferenceParamWdg *myEnfFaceWdg;
315 GEOM::GEOM_Object_var myEnfFace;
316 StdMeshersGUI_ObjectReferenceParamWdg *myEnfVertexWdg;
317 GEOM::GEOM_Object_var myEnfVertex;
319 QTreeWidget* myEnforcedTreeWidget;
320 SMESHGUI_SpinBox* myXCoord;
321 SMESHGUI_SpinBox* myYCoord;
322 SMESHGUI_SpinBox* myZCoord;
324 QLineEdit* myGroupName;
326 QPushButton* addVertexButton;
327 QPushButton* removeVertexButton;
329 QCheckBox *myInternalEnforcedVerticesAllFaces;
330 QLineEdit *myInternalEnforcedVerticesAllFacesGroup;
332 // map = entry , size map
333 QMap<QString, QString> mySMPMap; // Map <face entry, size>
334 QMap<QString, TAttractorVec > myATTMap; // Map <face entry, att. entry, etc>
335 QMap<QString, TopAbs_ShapeEnum> mySMPShapeTypeMap;
336 GeomSelectionTools* GeomToolSelected;
337 LightApp_SelectionMgr* aSel;
340 QWidget* myPeriodicityGroup;
341 QSplitter* myPeriodicitySplitter;
342 QTreeWidget* myPeriodicityTreeWidget;
343 QWidget* myPeriodicityRightWidget;
344 QGridLayout* myPeriodicityRightGridLayout;
345 QGroupBox* myPeriodicityGroupBox1;
346 QGroupBox* myPeriodicityGroupBox2;
347 QGridLayout* aPeriodicityLayout1;
348 QGridLayout* myPeriodicityGroupBox1Layout;
349 QGridLayout* myPeriodicityGroupBox2Layout;
350 QRadioButton* myPeriodicityOnFaceRadioButton;
351 QRadioButton* myPeriodicityOnEdgeRadioButton;
352 QLabel* myPeriodicityMainSourceLabel;
353 QLabel* myPeriodicityMainTargetLabel;
354 QLabel* myPeriodicitySourceLabel;
355 QLabel* myPeriodicityTargetLabel;
356 StdMeshersGUI_ObjectReferenceParamWdg* myPeriodicitySourceFaceWdg;
357 GEOM::GEOM_Object_var myPeriodicityFace;
358 StdMeshersGUI_ObjectReferenceParamWdg* myPeriodicityTargetFaceWdg;
359 GEOM::GEOM_Object_var myPeriodicityEdge;
360 QLabel* myPeriodicityP1SourceLabel;
361 QLabel* myPeriodicityP2SourceLabel;
362 QLabel* myPeriodicityP3SourceLabel;
363 QLabel* myPeriodicityP1TargetLabel;
364 QLabel* myPeriodicityP2TargetLabel;
365 QLabel* myPeriodicityP3TargetLabel;
366 StdMeshersGUI_ObjectReferenceParamWdg* myPeriodicityP1SourceWdg;
367 StdMeshersGUI_ObjectReferenceParamWdg* myPeriodicityP2SourceWdg;
368 StdMeshersGUI_ObjectReferenceParamWdg* myPeriodicityP3SourceWdg;
369 StdMeshersGUI_ObjectReferenceParamWdg* myPeriodicityP1TargetWdg;
370 StdMeshersGUI_ObjectReferenceParamWdg* myPeriodicityP2TargetWdg;
371 StdMeshersGUI_ObjectReferenceParamWdg* myPeriodicityP3TargetWdg;
372 ListOfWidgets myPeriodicitySelectionWidgets;
373 QPushButton* myPeriodicityAddButton;
374 QPushButton* myPeriodicityRemoveButton;
375 QSpacerItem* myPeriodicityVerticalSpacer;
377 QTableWidget* myHyPatchTable;
378 StdMeshersGUI_SubShapeSelectorWdg* myHyPatchFaceSelector;
379 QLineEdit* myHyPatchTagsLE;
380 QPushButton* myHyPatchFaceSelBtn;
381 QPushButton* myHyPatchGroupSelBtn;
383 BLSURFPlugin::string_array_var myOptions, myPreCADOptions, myCustomOptions;
386 PyObject * main_dict;
390 class EnforcedTreeWidgetDelegate : public QItemDelegate
395 EnforcedTreeWidgetDelegate(QObject *parent = 0);
397 QWidget *createEditor(QWidget *parent, const QStyleOptionViewItem &option,
398 const QModelIndex &index) const;
400 void setEditorData(QWidget *editor, const QModelIndex &index) const;
401 void setModelData(QWidget *editor, QAbstractItemModel *model,
402 const QModelIndex &index) const;
404 void updateEditorGeometry(QWidget *editor, const QStyleOptionViewItem &option,
405 const QModelIndex &index) const;
407 bool vertexExists(QAbstractItemModel *model, const QModelIndex &index, QString value) const;
410 #endif // BLSURFPLUGINGUI_HypothesisCreator_H