1 // Copyright (C) 2007-2014 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 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;
167 double myGradation, myAngleMesh, myChordalError;
168 bool myAnisotropic, myRemoveTinyEdges, myForceBadElementRemoval;
169 double myAnisotropicRatio, myTinyEdgeLength, myBadElementAspectRatio;
170 bool myOptimizeMesh, myQuadraticMesh;
171 bool myAllowQuadrangles, mySmpsurface,mySmpedge,mySmppoint,myEnforcedVertex,myInternalEnforcedVerticesAllFaces;
172 bool myPreCADMergeEdges, myPreCADProcess3DTopology, myPreCADDiscardInput;
173 // bool myGMFFileMode;
174 std::string myGMFFileName, myInternalEnforcedVerticesAllFacesGroup;
175 TEnfVertexList enfVertexList;
176 TFaceEntryEnfVertexListMap faceEntryEnfVertexListMap;
178 TGroupNameEnfVertexListMap groupNameEnfVertexListMap;
180 TPreCadPeriodicityVector preCadPeriodicityVector;
182 } BlsurfHypothesisData;
186 * \brief Class for creation of BLSURF hypotheses
188 class BLSURFPLUGIN_GUI_EXPORT BLSURFPluginGUI_HypothesisCreator : public SMESHGUI_GenericHypothesisCreator
193 BLSURFPluginGUI_HypothesisCreator( const QString& );
194 virtual ~BLSURFPluginGUI_HypothesisCreator();
196 virtual bool checkParams(QString& msg) const;
197 virtual QString helpPage() const;
200 virtual QFrame* buildFrame ();
201 virtual void retrieveParams() const;
202 virtual QString storeParams () const;
204 virtual QString caption() const;
205 virtual QPixmap icon() const;
206 virtual QString type() const;
209 void onStateChange();
212 void onDeleteOption();
213 void onOptionChosenInPopup( QAction* );
215 void onMapGeomContentModified();
216 void onSmpItemClicked( QTreeWidgetItem *, int );
217 void onTabChanged(int);
218 void onAttractorClicked(int);
219 void onConstSizeClicked(int);
223 void onSetSizeMap(QTreeWidgetItem *, int);
224 // Enforced vertices tab
225 QTreeWidgetItem* addEnforcedFace(std::string theFaceEntry, std::string theFaceName);
226 void addEnforcedVertex(QTreeWidgetItem * theFaceItem, double x=0, double y=0, double z=0,
227 std::string vertexName = "", std::string geomEntry = "", std::string groupName = "");
228 void onAddEnforcedVertices();
229 void onRemoveEnforcedVertex();
230 void synchronizeCoords();
231 void updateEnforcedVertexValues(QTreeWidgetItem* , int );
232 void onSelectEnforcedVertex();
233 // void deactivateSelection(QWidget*, QWidget*);
234 void clearEnforcedVertexWidgets();
235 void onInternalVerticesClicked(int);
237 void onPeriodicityByVerticesChecked(bool);
238 // void onPeriodicityRadioButtonChanged();
239 void onAddPeriodicity();
240 void onRemovePeriodicity();
241 void onPeriodicityTreeClicked(QTreeWidgetItem*, int);
242 void onPeriodicityContentModified();
245 bool readParamsFromHypo( BlsurfHypothesisData& ) const;
246 QString readParamsFromWidgets( BlsurfHypothesisData& ) const;
247 bool storeParamsToHypo( const BlsurfHypothesisData& ) const;
248 bool sizeMapsValidation();
249 bool sizeMapValidationFromRow(int,bool displayError = true);
250 bool sizeMapValidationFromEntry(QString,bool displayError = true);
251 GeomSelectionTools* getGeomSelectionTool() const;
252 GEOM::GEOM_Gen_var getGeomEngine();
253 //void insertElementType( TopAbs_ShapeEnum );
254 bool insertElement( GEOM::GEOM_Object_var, bool modify = false );
255 bool insertAttractor(GEOM::GEOM_Object_var, GEOM::GEOM_Object_var, bool modify = false);
256 int findRowFromEntry(QString entry);
257 CORBA::Object_var entryToObject(QString entry);
258 static LightApp_SelectionMgr* selectionMgr();
259 void avoidSimultaneousSelection(ListOfWidgets &myCustomWidgets) const;
260 void AddPreCadSequenceToVector(BlsurfHypothesisData& h_data, BLSURFPlugin::TPeriodicityList_var preCadFacePeriodicityVector, bool onFace) const;
264 QTabWidget* myTabWidget;
266 BLSURFPluginGUI_StdWidget* myStdWidget;
270 BLSURFPluginGUI_AdvWidget* myAdvWidget;
274 QTreeWidget *mySizeMapTable;
275 QPushButton *addMapButton;
276 QPushButton *removeMapButton;
277 QPushButton *modifyMapButton;
279 QWidget *myAttractorGroup;
280 QWidget *mySmpStdGroup;
281 QCheckBox *myAttractorCheck;
282 QCheckBox *myConstSizeCheck;
283 QGroupBox *myDistanceGroup;
284 // QGroupBox *myParamsGroup;
285 // QWidget *myParamsGroup;
286 SMESHGUI_SpinBox *myAttSizeSpin;
287 SMESHGUI_SpinBox *myAttDistSpin;
288 SMESHGUI_SpinBox *myAttDistSpin2;
289 SMESHGUI_SpinBox *mySmpSizeSpin;
290 QLabel *myAttDistLabel;
291 QLabel *myAttDistLabel2;
292 QLabel *myAttSizeLabel;
293 // Selection widgets for size maps
294 StdMeshersGUI_ObjectReferenceParamWdg *myGeomSelWdg1;
295 StdMeshersGUI_ObjectReferenceParamWdg *myGeomSelWdg2;
296 StdMeshersGUI_ObjectReferenceParamWdg *myAttSelWdg;
297 StdMeshersGUI_ObjectReferenceParamWdg *myDistSelWdg;
298 GEOM::GEOM_Object_var mySMapObject;
299 GEOM::GEOM_Object_var myAttObject;
300 GEOM::GEOM_Object_var myDistObject;
306 // TODO FACE AND VERTEX SELECTION
307 StdMeshersGUI_ObjectReferenceParamWdg *myEnfFaceWdg;
308 GEOM::GEOM_Object_var myEnfFace;
309 StdMeshersGUI_ObjectReferenceParamWdg *myEnfVertexWdg;
310 GEOM::GEOM_Object_var myEnfVertex;
312 // DlgBlSurfHyp_Enforced* myEnforcedVertexWidget;
313 QTreeWidget* myEnforcedTreeWidget;
314 SMESHGUI_SpinBox* myXCoord;
315 SMESHGUI_SpinBox* myYCoord;
316 SMESHGUI_SpinBox* myZCoord;
318 QLineEdit* myGroupName;
319 // QGroupBox* makeGroupsCheck;
320 // QCheckBox* myGlobalGroupName;
322 QPushButton* addVertexButton;
323 QPushButton* removeVertexButton;
325 QCheckBox *myInternalEnforcedVerticesAllFaces;
326 QLineEdit *myInternalEnforcedVerticesAllFacesGroup;
328 // map = entry , size map
329 QMap<QString, QString> mySMPMap; // Map <face entry, size>
330 QMap<QString, TAttractorVec > myATTMap; // Map <face entry, att. entry, etc>
331 // QMap<QString, double> myDistMap; // Map <entry,distance with constant size>
332 // QMap<QString, double> myAttDistMap; // Map <entry, influence distance>
333 QMap<QString, TopAbs_ShapeEnum> mySMPShapeTypeMap;
334 GeomSelectionTools* GeomToolSelected;
335 LightApp_SelectionMgr* aSel;
338 QWidget* myPeriodicityGroup;
339 QSplitter* myPeriodicitySplitter;
340 QTreeWidget* myPeriodicityTreeWidget;
341 QWidget* myPeriodicityRightWidget;
342 QGridLayout* myPeriodicityRightGridLayout;
343 QGroupBox* myPeriodicityGroupBox1;
344 QGroupBox* myPeriodicityGroupBox2;
345 QGridLayout* aPeriodicityLayout1;
346 QGridLayout* myPeriodicityGroupBox1Layout;
347 QGridLayout* myPeriodicityGroupBox2Layout;
348 QRadioButton* myPeriodicityOnFaceRadioButton;
349 QRadioButton* myPeriodicityOnEdgeRadioButton;
350 QLabel* myPeriodicityMainSourceLabel;
351 QLabel* myPeriodicityMainTargetLabel;
352 QLabel* myPeriodicitySourceLabel;
353 QLabel* myPeriodicityTargetLabel;
354 StdMeshersGUI_ObjectReferenceParamWdg* myPeriodicitySourceFaceWdg;
355 // StdMeshersGUI_ObjectReferenceParamWdg* myPeriodicitySourceEdgeWdg;
356 GEOM::GEOM_Object_var myPeriodicityFace;
357 StdMeshersGUI_ObjectReferenceParamWdg* myPeriodicityTargetFaceWdg;
358 // StdMeshersGUI_ObjectReferenceParamWdg* myPeriodicityTargetEdgeWdg;
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 BLSURFPlugin::string_array_var myOptions, myPreCADOptions;
380 PyObject * main_dict;
384 class EnforcedTreeWidgetDelegate : public QItemDelegate
389 EnforcedTreeWidgetDelegate(QObject *parent = 0);
391 QWidget *createEditor(QWidget *parent, const QStyleOptionViewItem &option,
392 const QModelIndex &index) const;
394 void setEditorData(QWidget *editor, const QModelIndex &index) const;
395 void setModelData(QWidget *editor, QAbstractItemModel *model,
396 const QModelIndex &index) const;
398 void updateEditorGeometry(QWidget *editor, const QStyleOptionViewItem &option,
399 const QModelIndex &index) const;
401 bool vertexExists(QAbstractItemModel *model, const QModelIndex &index, QString value) const;
404 #endif // BLSURFPLUGINGUI_HypothesisCreator_H