1 // Copyright (C) 2007-2012 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
31 #if defined BLSURFPLUGIN_GUI_EXPORTS || defined BLSURFPluginGUI_EXPORTS
32 #define BLSURFPLUGIN_GUI_EXPORT __declspec( dllexport )
34 #define BLSURFPLUGIN_GUI_EXPORT __declspec( dllimport )
37 #define BLSURFPLUGIN_GUI_EXPORT
41 // E.A. : On windows with python 2.6, there is a conflict
42 // E.A. : between pymath.h and Standard_math.h which define
43 // E.A. : some same symbols : acosh, asinh, ...
44 #include <Standard_math.hxx>
50 #include <QItemDelegate>
52 #include <SMESHGUI_Hypotheses.h>
53 #include "StdMeshersGUI_ObjectReferenceParamWdg.h"
54 #include <SALOMEconfig.h>
59 #include <TopAbs_ShapeEnum.hxx>
60 #include <GeomSelectionTools.h>
61 #include <GEOM_Client.hxx>
62 #include CORBA_SERVER_HEADER(BLSURFPlugin_Algorithm)
76 class QTreeWidgetItem;
77 class QTableWidgetItem;
80 class SMESHGUI_SpinBox;
81 class LightApp_SelectionMgr;
82 class BLSURFPluginGUI_StdWidget;
83 class BLSURFPluginGUI_AdvWidget;
84 // class DlgBlSurfHyp_Enforced;
87 typedef std::string TEnfName;
89 typedef std::string TEntry;
91 typedef std::set<TEntry> TEntryList;
92 // Enforced vertex = 3 coordinates
93 typedef std::vector<double> TEnfVertexCoords;
94 // List of enforced vertices
95 typedef std::set< TEnfVertexCoords > TEnfVertexCoordsList;
100 TEnfVertexCoords coords;
105 struct CompareEnfVertices
107 bool operator () (const TEnfVertex* e1, const TEnfVertex* e2) const {
109 if (e1->coords.size() && e2->coords.size())
110 return (e1->coords < e2->coords);
112 return (e1->geomEntry < e2->geomEntry);
118 // List of enforced vertices
119 typedef std::set< TEnfVertex*, CompareEnfVertices > TEnfVertexList;
121 // Map Face Entry / List of enforced vertices
122 typedef std::map< TEntry, TEnfVertexList > TFaceEntryEnfVertexListMap;
124 // Map Face Entry / InternalEnforcedVertices
125 typedef std::map< TEntry, bool > TFaceEntryInternalVerticesMap;
129 int myTopology, myVerbosity;
130 int myPhysicalMesh, myGeometricMesh;
131 double myPhySize, myMinSize, myMaxSize;
132 bool myPhySizeRel, myMinSizeRel, myMaxSizeRel;
133 bool myUseMinSize, myUseMaxSize;
134 double myGradation, myAngleMesh, myChordalError;
135 bool myAnisotropic, myRemoveTinyEdges, myForceBadElementRemoval;
136 double myAnisotropicRatio, myTinyEdgeLength, myBadElementAspectRatio;
137 bool myOptimizeMesh, myQuadraticMesh;
138 bool myAllowQuadrangles, mySmpsurface,mySmpedge,mySmppoint,myEnforcedVertex,myInternalEnforcedVerticesAllFaces;
139 bool myPreCADMergeEdges, myPreCADProcess3DTopology, myPreCADDiscardInput;
140 // bool myGMFFileMode;
141 std::string myGMFFileName, myInternalEnforcedVerticesAllFacesGroup;
142 TEnfVertexList enfVertexList;
143 TFaceEntryEnfVertexListMap faceEntryEnfVertexListMap;
145 TGroupNameEnfVertexListMap groupNameEnfVertexListMap;
148 } BlsurfHypothesisData;
152 * \brief Class for creation of BLSURF hypotheses
154 class BLSURFPLUGIN_GUI_EXPORT BLSURFPluginGUI_HypothesisCreator : public SMESHGUI_GenericHypothesisCreator
159 BLSURFPluginGUI_HypothesisCreator( const QString& );
160 virtual ~BLSURFPluginGUI_HypothesisCreator();
162 virtual bool checkParams(QString& msg) const;
163 virtual QString helpPage() const;
166 virtual QFrame* buildFrame ();
167 virtual void retrieveParams() const;
168 virtual QString storeParams () const;
170 virtual QString caption() const;
171 virtual QPixmap icon() const;
172 virtual QString type() const;
177 void onDeleteOption();
178 void onOptionChosenInPopup( QAction* );
180 void onMapGeomContentModified();
181 void onSmpItemClicked( QTreeWidgetItem *, int );
182 void onSmpTabChanged(int);
183 void onAttractorClicked(int);
184 void onConstSizeClicked(int);
188 void onSetSizeMap(QTreeWidgetItem *, int);
189 // Enforced vertices tab
190 QTreeWidgetItem* addEnforcedFace(std::string theFaceEntry, std::string theFaceName);
191 void addEnforcedVertex(QTreeWidgetItem * theFaceItem, double x=0, double y=0, double z=0,
192 std::string vertexName = "", std::string geomEntry = "", std::string groupName = "");
193 void onAddEnforcedVertices();
194 void onRemoveEnforcedVertex();
195 void synchronizeCoords();
196 void updateEnforcedVertexValues(QTreeWidgetItem* , int );
197 void onSelectEnforcedVertex();
198 // void deactivateSelection(QWidget*, QWidget*);
199 void clearEnforcedVertexWidgets();
200 void onInternalVerticesClicked(int);
203 bool readParamsFromHypo( BlsurfHypothesisData& ) const;
204 QString readParamsFromWidgets( BlsurfHypothesisData& ) const;
205 bool storeParamsToHypo( const BlsurfHypothesisData& ) const;
206 bool sizeMapsValidation();
207 bool sizeMapValidationFromRow(int,bool displayError = true);
208 bool sizeMapValidationFromEntry(QString,bool displayError = true);
209 GeomSelectionTools* getGeomSelectionTool();
210 GEOM::GEOM_Gen_var getGeomEngine();
211 //void insertElementType( TopAbs_ShapeEnum );
212 void insertElement( GEOM::GEOM_Object_var, bool modify = false );
213 void insertAttractor(GEOM::GEOM_Object_var, GEOM::GEOM_Object_var, bool modify = false);
214 int findRowFromEntry(QString entry);
215 CORBA::Object_var entryToObject(QString entry);
216 static LightApp_SelectionMgr* selectionMgr();
221 BLSURFPluginGUI_StdWidget* myStdWidget;
225 BLSURFPluginGUI_AdvWidget* myAdvWidget;
229 QTreeWidget *mySizeMapTable;
230 QPushButton *addMapButton;
231 QPushButton *removeMapButton;
232 QPushButton *modifyMapButton;
234 QWidget *myAttractorGroup;
235 QWidget *mySmpStdGroup;
236 QCheckBox *myAttractorCheck;
237 QCheckBox *myConstSizeCheck;
238 QGroupBox *myDistanceGroup;
239 // QGroupBox *myParamsGroup;
240 // QWidget *myParamsGroup;
241 SMESHGUI_SpinBox *myAttSizeSpin;
242 SMESHGUI_SpinBox *myAttDistSpin;
243 SMESHGUI_SpinBox *myAttDistSpin2;
244 SMESHGUI_SpinBox *mySmpSizeSpin;
245 QLabel *myAttDistLabel;
246 QLabel *myAttDistLabel2;
247 QLabel *myAttSizeLabel;
248 // Selection widgets for size maps
249 StdMeshersGUI_ObjectReferenceParamWdg *myGeomSelWdg1;
250 StdMeshersGUI_ObjectReferenceParamWdg *myGeomSelWdg2;
251 StdMeshersGUI_ObjectReferenceParamWdg *myAttSelWdg;
252 StdMeshersGUI_ObjectReferenceParamWdg *myDistSelWdg;
253 GEOM::GEOM_Object_var mySMapObject;
254 GEOM::GEOM_Object_var myAttObject;
255 GEOM::GEOM_Object_var myDistObject;
261 // TODO FACE AND VERTEX SELECTION
262 StdMeshersGUI_ObjectReferenceParamWdg *myEnfFaceWdg;
263 GEOM::GEOM_Object_var myEnfFace;
264 StdMeshersGUI_ObjectReferenceParamWdg *myEnfVertexWdg;
265 GEOM::GEOM_Object_var myEnfVertex;
267 // DlgBlSurfHyp_Enforced* myEnforcedVertexWidget;
268 QTreeWidget* myEnforcedTreeWidget;
269 SMESHGUI_SpinBox* myXCoord;
270 SMESHGUI_SpinBox* myYCoord;
271 SMESHGUI_SpinBox* myZCoord;
273 QLineEdit* myGroupName;
274 // QGroupBox* makeGroupsCheck;
275 // QCheckBox* myGlobalGroupName;
277 QPushButton* addVertexButton;
278 QPushButton* removeVertexButton;
280 QCheckBox *myInternalEnforcedVerticesAllFaces;
281 QLineEdit *myInternalEnforcedVerticesAllFacesGroup;
283 // map = entry , size map
284 QMap<QString, QString> mySMPMap; // Map <face entry, size>
285 QMap<QString, QString> myATTMap; // Map <face entry, att. entry>
286 QMap<QString, double> myDistMap; // Map <entry,distance with constant size>
287 QMap<QString, double> myAttDistMap; // Map <entry, influence distance>
288 QMap<QString, TopAbs_ShapeEnum> mySMPShapeTypeMap;
289 GeomSelectionTools* GeomToolSelected;
290 LightApp_SelectionMgr* aSel;
292 BLSURFPlugin::string_array_var myOptions, myPreCADOptions;
295 PyObject * main_dict;
299 class EnforcedTreeWidgetDelegate : public QItemDelegate
304 EnforcedTreeWidgetDelegate(QObject *parent = 0);
306 QWidget *createEditor(QWidget *parent, const QStyleOptionViewItem &option,
307 const QModelIndex &index) const;
309 void setEditorData(QWidget *editor, const QModelIndex &index) const;
310 void setModelData(QWidget *editor, QAbstractItemModel *model,
311 const QModelIndex &index) const;
313 void updateEditorGeometry(QWidget *editor, const QStyleOptionViewItem &option,
314 const QModelIndex &index) const;
316 bool vertexExists(QAbstractItemModel *model, const QModelIndex &index, QString value) const;
319 #endif // BLSURFPLUGINGUI_HypothesisCreator_H