1 // Copyright (C) 2007-2013 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.
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;
89 class SMESHGUI_SpinBox;
90 class LightApp_SelectionMgr;
91 class BLSURFPluginGUI_StdWidget;
92 class BLSURFPluginGUI_AdvWidget;
93 // class DlgBlSurfHyp_Enforced;
96 typedef std::string TEnfName;
98 typedef std::string TEntry;
100 typedef std::set<TEntry> TEntryList;
101 // Enforced vertex = 3 coordinates
102 typedef std::vector<double> TEnfVertexCoords;
103 // List of enforced vertices
104 typedef std::set< TEnfVertexCoords > TEnfVertexCoordsList;
109 TEnfVertexCoords coords;
114 struct CompareEnfVertices
116 bool operator () (const TEnfVertex* e1, const TEnfVertex* e2) const {
118 if (e1->coords.size() && e2->coords.size())
119 return (e1->coords < e2->coords);
121 return (e1->geomEntry < e2->geomEntry);
127 // List of enforced vertices
128 typedef std::set< TEnfVertex*, CompareEnfVertices > TEnfVertexList;
130 // Map Face Entry / List of enforced vertices
131 typedef std::map< TEntry, TEnfVertexList > TFaceEntryEnfVertexListMap;
133 // Map Face Entry / InternalEnforcedVertices
134 typedef std::map< TEntry, bool > TFaceEntryInternalVerticesMap;
138 int myTopology, myVerbosity;
139 int myPhysicalMesh, myGeometricMesh;
140 double myPhySize, myMinSize, myMaxSize;
141 bool myPhySizeRel, myMinSizeRel, myMaxSizeRel;
142 bool myUseMinSize, myUseMaxSize;
143 double myGradation, myAngleMesh, myChordalError;
144 bool myAnisotropic, myRemoveTinyEdges, myForceBadElementRemoval;
145 double myAnisotropicRatio, myTinyEdgeLength, myBadElementAspectRatio;
146 bool myOptimizeMesh, myQuadraticMesh;
147 bool myAllowQuadrangles, mySmpsurface,mySmpedge,mySmppoint,myEnforcedVertex,myInternalEnforcedVerticesAllFaces;
148 bool myPreCADMergeEdges, myPreCADProcess3DTopology, myPreCADDiscardInput;
149 // bool myGMFFileMode;
150 std::string myGMFFileName, myInternalEnforcedVerticesAllFacesGroup;
151 TEnfVertexList enfVertexList;
152 TFaceEntryEnfVertexListMap faceEntryEnfVertexListMap;
154 TGroupNameEnfVertexListMap groupNameEnfVertexListMap;
157 } BlsurfHypothesisData;
161 * \brief Class for creation of BLSURF hypotheses
163 class BLSURFPLUGIN_GUI_EXPORT BLSURFPluginGUI_HypothesisCreator : public SMESHGUI_GenericHypothesisCreator
168 BLSURFPluginGUI_HypothesisCreator( const QString& );
169 virtual ~BLSURFPluginGUI_HypothesisCreator();
171 virtual bool checkParams(QString& msg) const;
172 virtual QString helpPage() const;
175 virtual QFrame* buildFrame ();
176 virtual void retrieveParams() const;
177 virtual QString storeParams () const;
179 virtual QString caption() const;
180 virtual QPixmap icon() const;
181 virtual QString type() const;
186 void onDeleteOption();
187 void onOptionChosenInPopup( QAction* );
189 void onMapGeomContentModified();
190 void onSmpItemClicked( QTreeWidgetItem *, int );
191 void onSmpTabChanged(int);
192 void onAttractorClicked(int);
193 void onConstSizeClicked(int);
197 void onSetSizeMap(QTreeWidgetItem *, int);
198 // Enforced vertices tab
199 QTreeWidgetItem* addEnforcedFace(std::string theFaceEntry, std::string theFaceName);
200 void addEnforcedVertex(QTreeWidgetItem * theFaceItem, double x=0, double y=0, double z=0,
201 std::string vertexName = "", std::string geomEntry = "", std::string groupName = "");
202 void onAddEnforcedVertices();
203 void onRemoveEnforcedVertex();
204 void synchronizeCoords();
205 void updateEnforcedVertexValues(QTreeWidgetItem* , int );
206 void onSelectEnforcedVertex();
207 // void deactivateSelection(QWidget*, QWidget*);
208 void clearEnforcedVertexWidgets();
209 void onInternalVerticesClicked(int);
212 bool readParamsFromHypo( BlsurfHypothesisData& ) const;
213 QString readParamsFromWidgets( BlsurfHypothesisData& ) const;
214 bool storeParamsToHypo( const BlsurfHypothesisData& ) const;
215 bool sizeMapsValidation();
216 bool sizeMapValidationFromRow(int,bool displayError = true);
217 bool sizeMapValidationFromEntry(QString,bool displayError = true);
218 GeomSelectionTools* getGeomSelectionTool();
219 GEOM::GEOM_Gen_var getGeomEngine();
220 //void insertElementType( TopAbs_ShapeEnum );
221 bool insertElement( GEOM::GEOM_Object_var, bool modify = false );
222 bool insertAttractor(GEOM::GEOM_Object_var, GEOM::GEOM_Object_var, bool modify = false);
223 int findRowFromEntry(QString entry);
224 CORBA::Object_var entryToObject(QString entry);
225 static LightApp_SelectionMgr* selectionMgr();
229 QTabWidget* myTabWidget;
231 BLSURFPluginGUI_StdWidget* myStdWidget;
235 BLSURFPluginGUI_AdvWidget* myAdvWidget;
239 QTreeWidget *mySizeMapTable;
240 QPushButton *addMapButton;
241 QPushButton *removeMapButton;
242 QPushButton *modifyMapButton;
244 QWidget *myAttractorGroup;
245 QWidget *mySmpStdGroup;
246 QCheckBox *myAttractorCheck;
247 QCheckBox *myConstSizeCheck;
248 QGroupBox *myDistanceGroup;
249 // QGroupBox *myParamsGroup;
250 // QWidget *myParamsGroup;
251 SMESHGUI_SpinBox *myAttSizeSpin;
252 SMESHGUI_SpinBox *myAttDistSpin;
253 SMESHGUI_SpinBox *myAttDistSpin2;
254 SMESHGUI_SpinBox *mySmpSizeSpin;
255 QLabel *myAttDistLabel;
256 QLabel *myAttDistLabel2;
257 QLabel *myAttSizeLabel;
258 // Selection widgets for size maps
259 StdMeshersGUI_ObjectReferenceParamWdg *myGeomSelWdg1;
260 StdMeshersGUI_ObjectReferenceParamWdg *myGeomSelWdg2;
261 StdMeshersGUI_ObjectReferenceParamWdg *myAttSelWdg;
262 StdMeshersGUI_ObjectReferenceParamWdg *myDistSelWdg;
263 GEOM::GEOM_Object_var mySMapObject;
264 GEOM::GEOM_Object_var myAttObject;
265 GEOM::GEOM_Object_var myDistObject;
271 // TODO FACE AND VERTEX SELECTION
272 StdMeshersGUI_ObjectReferenceParamWdg *myEnfFaceWdg;
273 GEOM::GEOM_Object_var myEnfFace;
274 StdMeshersGUI_ObjectReferenceParamWdg *myEnfVertexWdg;
275 GEOM::GEOM_Object_var myEnfVertex;
277 // DlgBlSurfHyp_Enforced* myEnforcedVertexWidget;
278 QTreeWidget* myEnforcedTreeWidget;
279 SMESHGUI_SpinBox* myXCoord;
280 SMESHGUI_SpinBox* myYCoord;
281 SMESHGUI_SpinBox* myZCoord;
283 QLineEdit* myGroupName;
284 // QGroupBox* makeGroupsCheck;
285 // QCheckBox* myGlobalGroupName;
287 QPushButton* addVertexButton;
288 QPushButton* removeVertexButton;
290 QCheckBox *myInternalEnforcedVerticesAllFaces;
291 QLineEdit *myInternalEnforcedVerticesAllFacesGroup;
293 // map = entry , size map
294 QMap<QString, QString> mySMPMap; // Map <face entry, size>
295 QMap<QString, QString> myATTMap; // Map <face entry, att. entry>
296 QMap<QString, double> myDistMap; // Map <entry,distance with constant size>
297 QMap<QString, double> myAttDistMap; // Map <entry, influence distance>
298 QMap<QString, TopAbs_ShapeEnum> mySMPShapeTypeMap;
299 GeomSelectionTools* GeomToolSelected;
300 LightApp_SelectionMgr* aSel;
302 BLSURFPlugin::string_array_var myOptions, myPreCADOptions;
305 PyObject * main_dict;
309 class EnforcedTreeWidgetDelegate : public QItemDelegate
314 EnforcedTreeWidgetDelegate(QObject *parent = 0);
316 QWidget *createEditor(QWidget *parent, const QStyleOptionViewItem &option,
317 const QModelIndex &index) const;
319 void setEditorData(QWidget *editor, const QModelIndex &index) const;
320 void setModelData(QWidget *editor, QAbstractItemModel *model,
321 const QModelIndex &index) const;
323 void updateEditorGeometry(QWidget *editor, const QStyleOptionViewItem &option,
324 const QModelIndex &index) const;
326 bool vertexExists(QAbstractItemModel *model, const QModelIndex &index, QString value) const;
329 #endif // BLSURFPLUGINGUI_HypothesisCreator_H