Salome HOME
Merge relevant changes from V8_0_0_BR branch
[plugins/blsurfplugin.git] / src / GUI / BLSURFPluginGUI_HypothesisCreator.h
index efd475aa911f98f30f5cc00e26bd8801103f7d6d..972f544bbf7a1f7111eb65c40acf5dcf7bffc5b8 100644 (file)
@@ -1,9 +1,9 @@
-// Copyright (C) 2007-2012  CEA/DEN, EDF R&D
+// Copyright (C) 2007-2015  CEA/DEN, EDF R&D
 //
 // This library is free software; you can redistribute it and/or
 // modify it under the terms of the GNU Lesser General Public
 // License as published by the Free Software Foundation; either
-// version 2.1 of the License.
+// version 2.1 of the License, or (at your option) any later version.
 //
 // This library is distributed in the hope that it will be useful,
 // but WITHOUT ANY WARRANTY; without even the implied warranty of
 #ifndef BLSURFPLUGINGUI_HypothesisCreator_H
 #define BLSURFPLUGINGUI_HypothesisCreator_H
 
+// akl: avoid compilation warning on Linux : "_POSIX_C_SOURCE" and "_XOPEN_SOURCE" are redefined
+#ifdef _POSIX_C_SOURCE
+#undef _POSIX_C_SOURCE
+#endif
+
+#ifdef _XOPEN_SOURCE
+#undef _XOPEN_SOURCE
+#endif
+
 #ifdef WIN32
   #if defined BLSURFPLUGIN_GUI_EXPORTS || defined BLSURFPluginGUI_EXPORTS
     #define BLSURFPLUGIN_GUI_EXPORT __declspec( dllexport )
@@ -37,7 +46,7 @@
   #define BLSURFPLUGIN_GUI_EXPORT
 #endif
 
-#ifdef WNT
+#ifdef WIN32
 // E.A. : On windows with python 2.6, there is a conflict
 // E.A. : between pymath.h and Standard_math.h which define
 // E.A. : some same symbols : acosh, asinh, ...
@@ -65,6 +74,7 @@ class QGroupBox;
 class QComboBox;
 class QCheckBox;
 class QLineEdit;
+class QRadioButton;
 class QTableWidget;
 class QTreeWidget;
 class QModelIndex;
@@ -75,9 +85,16 @@ class QAction;
 class QTreeWidgetItem;
 class QTableWidgetItem;
 class QObject;
+class QSplitter;
+class QGridLayout;
+class QVBoxLayout;
+class QSpacerItem;
 
 class SMESHGUI_SpinBox;
+class SMESH_NumberFilter;
 class LightApp_SelectionMgr;
+class BLSURFPluginGUI_StdWidget;
+class BLSURFPluginGUI_AdvWidget;
 // class DlgBlSurfHyp_Enforced;
 
 // Name
@@ -97,7 +114,22 @@ struct TEnfVertex{
   TEnfVertexCoords coords;
   TEnfName grpName;
 };
-
+// Attractor
+struct TAttractor{
+  std::string attEntry;
+  double      startSize;
+  double      infDist;
+  double      constDist;
+  TAttractor( const char* theAttEntry, double theStartSize, double theInfDist, double theConstDist)
+    : attEntry( theAttEntry ),
+      startSize( theStartSize ),
+      infDist( theInfDist ),
+      constDist( theConstDist )
+  {}
+  void SetToDelete() { startSize = -1; }
+  bool IsToDelete() const { return startSize < 0; }
+};
+typedef std::vector< TAttractor > TAttractorVec;
 
 struct CompareEnfVertices
 {
@@ -121,15 +153,23 @@ typedef std::map< TEntry, TEnfVertexList > TFaceEntryEnfVertexListMap;
 // Map Face Entry / InternalEnforcedVertices
 typedef std::map< TEntry, bool > TFaceEntryInternalVerticesMap;
 
+// PreCad Face and Edge periodicity
+typedef std::vector<std::string> TPreCadPeriodicity;
+typedef std::vector< TPreCadPeriodicity > TPreCadPeriodicityVector;
+
 typedef struct
 {
   int     myTopology, myVerbosity;
   int     myPhysicalMesh, myGeometricMesh;
-  double  myAngleMeshS, myAngleMeshC, myGradation;
-  double  myPhySize, myGeoMin, myGeoMax, myPhyMin,myPhyMax;
-  bool    myAllowQuadrangles, myDecimesh,mySmpsurface,mySmpedge,mySmppoint,myEnforcedVertex,myInternalEnforcedVerticesAllFaces;
-  bool    myPreCADMergeEdges, myPreCADRemoveNanoEdges, myPreCADDiscardInput;
-  double  myPreCADEpsNano;
+  double  myPhySize, myMinSize, myMaxSize;
+  bool    myPhySizeRel, myMinSizeRel, myMaxSizeRel;
+  bool    myUseMinSize, myUseMaxSize;
+  double  myGradation, myAngleMesh, myChordalError;
+  bool    myAnisotropic, myRemoveTinyEdges, myForceBadElementRemoval;
+  double  myAnisotropicRatio, myTinyEdgeLength, myBadElementAspectRatio;
+  bool    myOptimizeMesh, myQuadraticMesh;
+  bool    myAllowQuadrangles, mySmpsurface,mySmpedge,mySmppoint,myEnforcedVertex,myInternalEnforcedVerticesAllFaces;
+  bool    myPreCADMergeEdges, myPreCADProcess3DTopology, myPreCADDiscardInput;
 //   bool    myGMFFileMode;
   std::string myGMFFileName, myInternalEnforcedVerticesAllFacesGroup;
   TEnfVertexList enfVertexList;
@@ -137,34 +177,13 @@ typedef struct
   /* TODO GROUPS
   TGroupNameEnfVertexListMap groupNameEnfVertexListMap;
   */
+  TPreCadPeriodicityVector preCadPeriodicityVector;
   QString myName;
 } BlsurfHypothesisData;
 
 
-
-// class BLSURFPluginGUI_ObjectReferenceParamWdg: public StdMeshersGUI_ObjectReferenceParamWdg
-// {
-//   Q_OBJECT
-// public:
-//   BLSURFPluginGUI_ObjectReferenceParamWdg( SUIT_SelectionFilter* filter, 
-//                                          QWidget*              parent,
-//                                          bool                  multiSelection=false);
-//   BLSURFPluginGUI_ObjectReferenceParamWdg( MeshObjectType objType,
-//                                          QWidget*       parent,
-//                                          bool           multiSelection=false);
-//   ~BLSURFPluginGUI_ObjectReferenceParamWdg();
-// 
-// private:
-//   void init();
-//   
-// public slots:
-//   void activateSelectionOnly();
-//   void deactivateSelectionOnly();
-//   void setActivationStatus(bool status);
-// };
-
 /*!
- * \brief Class for creation of BLSURF hypotheses
+ * \brief Class for creation of MG-CADSurf hypotheses
 */
 class BLSURFPLUGIN_GUI_EXPORT BLSURFPluginGUI_HypothesisCreator : public SMESHGUI_GenericHypothesisCreator
 {
@@ -187,28 +206,27 @@ protected:
   virtual QString     type() const;
 
 protected slots:
-  void                onPhysicalMeshChanged();
-  void                onGeometricMeshChanged();
+  void                onStateChange();
+  // Advanced tab
   void                onAddOption();
   void                onDeleteOption();
-  void                onChooseGMFFile();
+  void                onEditOption( int, int );
+  void                onChangeOptionName( int, int );
   void                onOptionChosenInPopup( QAction* );
-  void                onTopologyChanged( int );
+  // Sizemap tab
   void                onMapGeomContentModified();
   void                onSmpItemClicked( QTreeWidgetItem *, int );
-  void                onSmpTabChanged(int);
+  void                onTabChanged(int);
   void                onAttractorClicked(int);
   void                onConstSizeClicked(int);
   void                onAddMap();
   void                onRemoveMap();
   void                onModifyMap();
   void                onSetSizeMap(QTreeWidgetItem *, int);
-
+  // Enforced vertices tab
   QTreeWidgetItem*    addEnforcedFace(std::string theFaceEntry, std::string theFaceName);
-
   void                addEnforcedVertex(QTreeWidgetItem * theFaceItem, double x=0, double y=0, double z=0, 
                                         std::string vertexName = "", std::string geomEntry = "", std::string groupName = "");
-  
   void                onAddEnforcedVertices();
   void                onRemoveEnforcedVertex();
   void                synchronizeCoords();
@@ -217,6 +235,13 @@ protected slots:
 //   void                deactivateSelection(QWidget*, QWidget*);
   void                clearEnforcedVertexWidgets();
   void                onInternalVerticesClicked(int);
+  // Periodicity tab
+  void                onPeriodicityByVerticesChecked(bool);
+//  void                onPeriodicityRadioButtonChanged();
+  void                onAddPeriodicity();
+  void                onRemovePeriodicity();
+  void                onPeriodicityTreeClicked(QTreeWidgetItem*, int);
+  void                onPeriodicityContentModified();
 
 private:
   bool                readParamsFromHypo( BlsurfHypothesisData& ) const;
@@ -225,64 +250,48 @@ private:
   bool                sizeMapsValidation();
   bool                sizeMapValidationFromRow(int,bool displayError = true);
   bool                sizeMapValidationFromEntry(QString,bool displayError = true);
-  GeomSelectionTools* getGeomSelectionTool();
+  GeomSelectionTools* getGeomSelectionTool() const;
   GEOM::GEOM_Gen_var  getGeomEngine();
   //void                insertElementType( TopAbs_ShapeEnum );
-  void                insertElement( GEOM::GEOM_Object_var, bool modify = false );
-  void                insertAttractor(GEOM::GEOM_Object_var, GEOM::GEOM_Object_var, bool modify = false);
+  bool                insertElement( GEOM::GEOM_Object_var, bool modify = false );
+  bool                insertAttractor(GEOM::GEOM_Object_var, GEOM::GEOM_Object_var, bool modify = false);
   int                 findRowFromEntry(QString entry);
   CORBA::Object_var   entryToObject(QString entry);
   static LightApp_SelectionMgr* selectionMgr();
+  void                avoidSimultaneousSelection(ListOfWidgets &myCustomWidgets) const;
+  void                AddPreCadSequenceToVector(BlsurfHypothesisData& h_data, BLSURFPlugin::TPeriodicityList_var preCadFacePeriodicityVector, bool onFace) const;
 
 private:
-  QWidget*            myStdGroup;
-  QLineEdit*          myName;
-  QComboBox*          myPhysicalMesh;
-  SMESHGUI_SpinBox*   myPhySize;
-  SMESHGUI_SpinBox*   myPhyMin;
-  SMESHGUI_SpinBox*   myPhyMax;
-  QComboBox*          myGeometricMesh;
-  SMESHGUI_SpinBox*   myAngleMeshS;
-  SMESHGUI_SpinBox*   myAngleMeshC;
-  SMESHGUI_SpinBox*   myGeoMin;
-  SMESHGUI_SpinBox*   myGeoMax;
-  SMESHGUI_SpinBox*   myGradation;
-  QCheckBox*          myAllowQuadrangles;
-  QCheckBox*          myDecimesh;
-
-  QWidget*            myAdvGroup;
-  QComboBox*          myTopology;
-  QGroupBox*          myPreCADGroupBox;
-  QCheckBox*          myPreCADMergeEdges;
-  QCheckBox*          myPreCADRemoveNanoEdges;
-  QCheckBox*          myPreCADDiscardInput;
-  SMESHGUI_SpinBox*   myPreCADEpsNano;
-  QSpinBox*           myVerbosity;
-  QTableWidget*       myOptionTable;
-  QLineEdit*          myGMFFileName;
-//   QCheckBox*          myGMFFileMode;
+  
+  QTabWidget*             myTabWidget;
+  QWidget*                myStdGroup;
+  BLSURFPluginGUI_StdWidget* myStdWidget;
+  QLineEdit*              myName;
+
+  QWidget*                myAdvGroup;
+  BLSURFPluginGUI_AdvWidget* myAdvWidget;
 
   // Sizemap widgets
-  QWidget             *mySmpGroup;
-  QTreeWidget         *mySizeMapTable;
-  QPushButton         *addMapButton;
-  QPushButton         *removeMapButton;
-  QPushButton         *modifyMapButton;
-  QTabWidget          *smpTab; 
-  QWidget             *myAttractorGroup;
-  QWidget             *mySmpStdGroup;
-  QCheckBox           *myAttractorCheck;
-  QCheckBox           *myConstSizeCheck;
-  QGroupBox           *myDistanceGroup;
-//   QGroupBox           *myParamsGroup;
-//   QWidget             *myParamsGroup;
-  SMESHGUI_SpinBox    *myAttSizeSpin;
-  SMESHGUI_SpinBox    *myAttDistSpin;
-  SMESHGUI_SpinBox    *myAttDistSpin2;
-  SMESHGUI_SpinBox    *mySmpSizeSpin;
-  QLabel              *myAttDistLabel;
-  QLabel              *myAttDistLabel2;
-  QLabel              *myAttSizeLabel;
+  QWidget                 *mySmpGroup;
+  QTreeWidget             *mySizeMapTable;
+  QPushButton             *addMapButton;
+  QPushButton             *removeMapButton;
+  QPushButton             *modifyMapButton;
+  QTabWidget              *smpTab; 
+  QWidget                 *myAttractorGroup;
+  QWidget                 *mySmpStdGroup;
+  QCheckBox               *myAttractorCheck;
+  QCheckBox               *myConstSizeCheck;
+  QGroupBox               *myDistanceGroup;
+//   QGroupBox               *myParamsGroup;
+//   QWidget                 *myParamsGroup;
+  SMESHGUI_SpinBox        *myAttSizeSpin;
+  SMESHGUI_SpinBox        *myAttDistSpin;
+  SMESHGUI_SpinBox        *myAttDistSpin2;
+  SMESHGUI_SpinBox        *mySmpSizeSpin;
+  QLabel                  *myAttDistLabel;
+  QLabel                  *myAttDistLabel2;
+  QLabel                  *myAttSizeLabel;
   // Selection widgets for size maps
   StdMeshersGUI_ObjectReferenceParamWdg *myGeomSelWdg1;
   StdMeshersGUI_ObjectReferenceParamWdg *myGeomSelWdg2;
@@ -320,13 +329,53 @@ private:
 
   // map =  entry , size map
   QMap<QString, QString>          mySMPMap;           // Map <face entry, size>
-  QMap<QString, QString>          myATTMap;           // Map <face entry, att. entry>
-  QMap<QString, double>           myDistMap;          // Map <entry,distance with constant size> 
-  QMap<QString, double>           myAttDistMap;       // Map <entry, influence distance> 
+  QMap<QString, TAttractorVec >   myATTMap;           // Map <face entry, att. entry, etc>
+  // QMap<QString, double>           myDistMap;          // Map <entry,distance with constant size> 
+  // QMap<QString, double>           myAttDistMap;       // Map <entry, influence distance> 
   QMap<QString, TopAbs_ShapeEnum> mySMPShapeTypeMap;
   GeomSelectionTools*             GeomToolSelected;
   LightApp_SelectionMgr*          aSel;
 
+  // Periodicity
+  QWidget* myPeriodicityGroup;
+  QSplitter* myPeriodicitySplitter;
+  QTreeWidget* myPeriodicityTreeWidget;
+  QWidget* myPeriodicityRightWidget;
+  QGridLayout* myPeriodicityRightGridLayout;
+  QGroupBox* myPeriodicityGroupBox1;
+  QGroupBox* myPeriodicityGroupBox2;
+  QGridLayout* aPeriodicityLayout1;
+  QGridLayout* myPeriodicityGroupBox1Layout;
+  QGridLayout* myPeriodicityGroupBox2Layout;
+  QRadioButton* myPeriodicityOnFaceRadioButton;
+  QRadioButton* myPeriodicityOnEdgeRadioButton;
+  QLabel* myPeriodicityMainSourceLabel;
+  QLabel* myPeriodicityMainTargetLabel;
+  QLabel* myPeriodicitySourceLabel;
+  QLabel* myPeriodicityTargetLabel;
+  StdMeshersGUI_ObjectReferenceParamWdg* myPeriodicitySourceFaceWdg;
+//  StdMeshersGUI_ObjectReferenceParamWdg* myPeriodicitySourceEdgeWdg;
+  GEOM::GEOM_Object_var myPeriodicityFace;
+  StdMeshersGUI_ObjectReferenceParamWdg* myPeriodicityTargetFaceWdg;
+//  StdMeshersGUI_ObjectReferenceParamWdg* myPeriodicityTargetEdgeWdg;
+  GEOM::GEOM_Object_var myPeriodicityEdge;
+  QLabel* myPeriodicityP1SourceLabel;
+  QLabel* myPeriodicityP2SourceLabel;
+  QLabel* myPeriodicityP3SourceLabel;
+  QLabel* myPeriodicityP1TargetLabel;
+  QLabel* myPeriodicityP2TargetLabel;
+  QLabel* myPeriodicityP3TargetLabel;
+  StdMeshersGUI_ObjectReferenceParamWdg* myPeriodicityP1SourceWdg;
+  StdMeshersGUI_ObjectReferenceParamWdg* myPeriodicityP2SourceWdg;
+  StdMeshersGUI_ObjectReferenceParamWdg* myPeriodicityP3SourceWdg;
+  StdMeshersGUI_ObjectReferenceParamWdg* myPeriodicityP1TargetWdg;
+  StdMeshersGUI_ObjectReferenceParamWdg* myPeriodicityP2TargetWdg;
+  StdMeshersGUI_ObjectReferenceParamWdg* myPeriodicityP3TargetWdg;
+  ListOfWidgets myPeriodicitySelectionWidgets;
+  QPushButton* myPeriodicityAddButton;
+  QPushButton* myPeriodicityRemoveButton;
+  QSpacerItem* myPeriodicityVerticalSpacer;
+
   BLSURFPlugin::string_array_var myOptions, myPreCADOptions;
 
   PyObject *          main_mod;